Jump to content

Trying to show date on deliveryslip


teralite

Recommended Posts

Hi all!

 

Im trying to add customer message and date to the deliveryslip but cant get the date to work.

 

<div style="line-height: 1pt"> </div>
<table style="width: 100%">
{foreach $messages as $message}
    <tr>
        <td style="font-weight:bold; width: 100%">{l s='Message:' pdf='true'}</td>
            </tr>
            <tr>
              <td style="width:100%">
              {dateFormat date=$message->date_add full=0}
                {$message.message}
</td>
</tr>
{/foreach}
    </table>
 
What am i doing wrong?
If i use $order->date_add instead it works fine but its the wrong date i get then, i want the time of the message and not the order.
Link to comment
Share on other sites

Hi and thanks for your answers.

I really want to figure this out since im trying to learn the structure and coding of prestashop.

 

Any idea in what file i can find the array for the string that creates the $messages? 

 

Its not a SQL queary in BO atleast, i checked there =)

Edited by teralite (see edit history)
Link to comment
Share on other sites

Ok i found the array now, anyone that can help me to insert date_add there so i can get this to work?

 

class HTMLTemplateDeliverySlip extends HTMLTemplateDeliverySlipCore
{
public function getContent()
{
$customer = new Customer($this->order->id_customer);
$email = $customer->email;
$messages = $this->getSpecialOrderMessages($this->order->id, $email);
$this->smarty->assign(array(
'messages' => $messages
));
return parent::getContent();
}
 
public function getSpecialOrderMessages($id_order, $email)
{
$id_order = (int)($id_order);
/*$messages = Message::getMessagesByOrderId($id_order);
foreach($messages as $message)
$cleanmsg[]['message'] = $message['message'];
*/
$customer_thread_id = CustomerThread::getIdCustomerThreadByEmailAndIdOrder($email, $id_order);
$threads = CustomerThread::getMessageCustomerThreads($customer_thread_id);
foreach($threads as $thread)
if($thread['private']==0)
$cleanmsg[]['message'] = htmlspecialchars_decode($thread['message']);
return $cleanmsg;
}
}
Link to comment
Share on other sites

If you want, (just like the message now comes from customerthread), the customerthread.date_add, try this: (from code you provided above):

 

foreach($threads as $key => $thread)
   if($thread['private']==0) {     //  <-- don't forget brackets
      $cleanmsg[$key]['message'] = htmlspecialchars_decode($thread['message']);
      $cleanmsg[$key]['date_add'] = htmlspecialchars_decode($thread['date_add']);
   }   //   <-- don't forget brackets
return $cleanmsg;

 

I think the date_add is already in the function call result of 

$threads = CustomerThread::getMessageCustomerThreads($customer_thread_id);

 

So it might work like this... Give it a try,

pascal.

Link to comment
Share on other sites

Hi Pascal!

 

Thanks for your reply!

 

Now its a start but it seems that it now makes 2 "lines" on the output.

What im trying to do is to write out the "date" and then the "message" on the delivery slip, and with this function it now writes date_add as one line and message as one line.

I want it to be like this in the tpl file.

 

<div style="line-height: 1pt"> </div>
    <table style="width: 100%">
    {foreach $messages as $message}
        <tr>
            <td style="font-weight:bold; width: 100%">{l s='Message' pdf='true'} {dateFormat date=$message.date_add full=0}</td>
            </tr>
            <tr>
              <td style="width:100%">
                {$message.message}
            </td>
        </tr>
    {/foreach}
    </table>

 

I get the correct date now but it turns out like this on delivery slip :

 

Message 2015/02/03
Message
Vill ha den uppdelad i två delar om 3 meter vardera med varsin anslutningskabel.

 

and the final output i want to acheive is like this:

 

Message 2015/02/03
Vill ha den uppdelad i två delar om 3 meter vardera med varsin anslutningskabel.

Edited by teralite (see edit history)
Link to comment
Share on other sites

  • 3 years later...
On 1/30/2015 at 10:44 AM, tuk66 said:

Have you tried $message.date_add?

Maybe off topic, but i wanted to change the  invoice date to when the order is done and $order->date_add it was the answer. That's one big stone for me :)) Tnx!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...