Bid History strtotime

A place to discuss and receive support for the Web Auction application.

Bid History strtotime

Postby JGerrity » Sat Mar 03, 2012 8:14 am

Hello,

I'm modifying the view_product.html template to show the bid history Which is working except that I'm having trouble showing the date in a more friendly format. My code is using strval
Code: Select all
          {foreach from=$product->getRelatedRecordObjects('bids') item=bid}
        <dd>{$bid->val('username')} : ${$bid->val('bid_amount')} {$bid->strval('time_of_bid')}
      {/foreach}


When I try to use strtotime instead of strval I get the error below. Do I need to create a strtotime function?

Fatal error: Call to undefined method Dataface_RelatedRecord::strtotime()

Thanks,
J.

PS If anyone is interested, you could create a scoll box to show the history of bids so the page doesn't grow to large by wrapping it in an HTML <div> tag ie: <div style="height:120px;width:250px;overflow:scroll;">
JGerrity
 
Posts: 16
Joined: Fri Mar 02, 2012 4:43 pm

Re: Bid History strtotime

Postby shannah » Sun Mar 04, 2012 11:54 am

Use {$bid->display('time_of_bid')}

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Bid History strtotime

Postby JGerrity » Sun Mar 04, 2012 4:24 pm

Thanks Steve but that didn't work.

Result format is:

20120225204927

Which is the same as using strval. I'd like it to be similar to output of "high bidder"

2012-02-20 20:49:27

Better still would be in D:MM:YYYY and 12:hr clock without seconds that I thought I had read was possible using strtotime function...

Also, how could I reverse the order of the bids being shown?

Regards,
Jason
JGerrity
 
Posts: 16
Joined: Fri Mar 02, 2012 4:43 pm

Re: Bid History strtotime

Postby shannah » Mon Mar 05, 2012 9:09 am

Hmm... strange.... This may be a bug.

It should format it correctly when using the display method. I'll need to look into this one.
(You can always implement the time_of_bid__display() method in the bids delegate class to output your own custom format also)
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Bid History strtotime

Postby JGerrity » Tue Mar 06, 2012 8:48 am

Thanks Steve I'll look into using the delegate class.

Could you please let me know how to sort the out of bids so that the most recent is first(top)? That way, people don't have to scroll down to see recent bid history.

Cheers,
J.
JGerrity
 
Posts: 16
Joined: Fri Mar 02, 2012 4:43 pm

Re: Bid History strtotime

Postby shannah » Tue Mar 06, 2012 12:58 pm

Code: Select all
$product->getRelatedRecordObjects('bids', null, null, 0, 'time_of_bid desc');
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Bid History strtotime

Postby JGerrity » Wed Mar 07, 2012 10:12 pm

shannah wrote:Hmm... strange.... This may be a bug.

It should format it correctly when using the display method. I'll need to look into this one.
(You can always implement the time_of_bid__display() method in the bids delegate class to output your own custom format also)


Hello,

Ok I'm struggling with showing the date in bid history in anything other than a string value. I've tried the time_of_bid__display() in the bids delegate class. I've tried using $bid->htmlValue however they come back as No Access.

It does however work when you log in as a user (you can only see the dates of your bids, all others are "no access") so it looks like an access permision on the time_of_bid record.(anyway to disregard permissions for time_of_bid?)

Here is my method in the delegate class:

Code: Select all
   function time_of_bid__display(&$record){
      return date('Y-m-d g:i a', strtotime($record->strval('time_of_bid')));
   }   


I've even tried it by adding: (to disregard permissions)
Code: Select all
   function time_of_bid__display(&$record){
      $record->secureDisplay = false;
      return date('Y-m-d g:i a', strtotime($record->strval('time_of_bid')));
   }   


I continue to get the no Access result.

I've confirm no access issue by using a no_access_text($record) function and returning 'subscribe'...yep, so it now says "subscribe" instead of no access.

My view_products.html is:
Code: Select all
{$bid->val('username')} : ${$bid->val('bid_amount')} on: {$bid->display('time_of_bid')}


Your help would be appreciated as always!

Cheers,
J
JGerrity
 
Posts: 16
Joined: Fri Mar 02, 2012 4:43 pm

Re: Bid History strtotime

Postby JGerrity » Tue Mar 13, 2012 12:57 pm

..anyone got any ideas?

What I'd like show is the level of detail when someone is logged in and views the product detail page such as

gerrity : $60 on: 2012-03-13 5:58 pm
cameron : $55 on: SUBSCRIBE
gerrity : $50 on: 2012-03-13 3:44 pm

However, they shouldn't have to be logged in like gerrity was above. It's a table or field permission issue since user cameron wasn't logged in and it would say no access instead of subscribe (that's myy own troubleshooting)

Thanks,
J.
JGerrity
 
Posts: 16
Joined: Fri Mar 02, 2012 4:43 pm

Re: Bid History strtotime

Postby shannah » Wed Mar 14, 2012 10:10 am

Settings secureDisplay to false inside your display method won't have any effect because your display method won't even be called if secureDisplay was already true (which is default) and the user doesn't have permission to view that cell.

Currently the permissions on the bids table are set up to provide access ONLY for the person who made the bid. This is why you're seeing NO ACCESS. If you want to make bids public, you might just make the following change in the bids table delegate class:

Code: Select all
function getPermissions(&$record){
   /*
      $app =& Dataface_Application::getInstance();
      $del =& $app->getDelegate();
      $perms =& $del->getPermissions($record);
   */
      //if ( $record ) echo "Yes"; else echo "No";
      //if ( $record and $record->val('username') ) echo "We have a username";
      if ( isAdmin() or ( $record and ($record->strval('username') == getUsername()))) {
         $perms = Dataface_PermissionsTool::ALL();
      } else {
         $perms = Dataface_PermissionsTool::NO_ACCESS();
      }
      $perms['new'] = 1;
      return $perms;
   }


Change the line
Code: Select all
$perms = Dataface_PermissionsTool::NO_ACCESS();

to
Code: Select all
$perms = Dataface_PermissionsTool::READ_ONLY();


-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Bid History strtotime

Postby JGerrity » Wed Mar 14, 2012 1:32 pm

Perfect!

Excellent support again Steve!

Thanks,
J.
JGerrity
 
Posts: 16
Joined: Fri Mar 02, 2012 4:43 pm


Return to Web Auction Discussion

Who is online

Users browsing this forum: No registered users and 23 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved