Jump to content
  • 0

SQL Abfragen ändern / ergänzen


Go to solution Solved by Donaldiosa,

Question

Moin Forum!

 

Ich möchte auf dem PDF-Lieferschein die Mailadresse des Käufers mit anzeigen, doch finde ich im Moment nicht die passende Stelle :(

 

Die Datenbankabfrage des Lieferscheins greift auf _address zu, die Mailadresse befindet sich in _customer und beide könnten ja über das Feld id_customer bei der Abfrage verknüpft werden.

 

Doch wo sind in den Prestashop-Dateien die SQL-Abfragen abgelegt?

 

Share this post


Link to post
Share on other sites

7 answers to this question

Recommended Posts

  • 0
  • Solution

Hello tuk66 and thanks for your reply.

 
But I do'nt get then the Mailaddress because the return value of {$customer->email} is empty. But, if I enter {$address->lastname} instead, it is also empty.
 

For a simple Test, I modified the file named pdf/delivery-slip.tpl like this:

{$style_tab}
<table width="100%" id="body" border="0" cellpadding="0" cellspacing="0" style="margin:0;">
<!-- Addresses -->
<tr>
<td colspan="12">
    BeginEMAIL{$customer->email}EndEMAIL
</td>
</tr>
<tr>
<td colspan="12">
{$addresses_tab}
</td>
</tr>

Edited by Donaldiosa (see edit history)

Share this post


Link to post
Share on other sites
  • 0

Ich habe mir jetzt zunächst mit einem (ganz miserablen) Workaround weitergeholfen.

 

Im Verzeichnis classes\pdf gibt es die Klasse HTMLTemplateDeliverySlip.php.

 

Diese habe ich in der Funktion getContent() so erweitert, wie ich es normalerweise nun eigentlich absolut nicht machen würde. Aber bis ich herausgefunden habe was ich verändern muss, um die Mailadresse mit vernünftigen Codeing anzuzeigen, hilft dies schon mal weiter. Wenn es jemand jetzt schon besser weiß und mir einen Tipp geben möchte... Nehme ich gerne an ;-)

 

Wer auch dieses Problem hat, der kann ja gerna auch diesen (ganz miserablen) Workaround nutzen... Einzufügen vor "$carrier = new Carrier($this->order->id_carrier);". ca Zeile 85 der Klasse.

 

 

/* TRTEST Änderung Workaround */
    $mysql_session=mysql_connect("$TempTR_Host","$TempTR_User", "$TempTR_PW") or die ("Verbindungsaufbau fehlgeschlagen: ".mysql_error());
    mysql_select_db("$TempTR_DataBase",$mysql_session) or die ("Datenbankwahl fehlgeschlagen: ".mysql_error($mysql_session)."<br>--->$qry");
 
    $TRtelefon = substr($formatted_delivery_address, strrpos($formatted_delivery_address, "<br />") + 6, strlen($formatted_delivery_address));
    $TRqry = "SELECT c.email
              FROM `_customer` c, `_address` a
              WHERE a.phone = '" . $TRtelefon . "'
              AND a.id_customer = c.id_customer
              AND a.lastname = c.lastname
              AND a.firstname = c.firstname
              ";
    $TRresult = mysql_query($TRqry);
    $TRrow = mysql_fetch_row($TRresult);
    $TRemail = $TRrow[0];
    $formatted_delivery_address .= "<br />" . $TRemail;

Share this post


Link to post
Share on other sites
  • 0

Haben Sie verwenden versucht {$customer->email} in einer Vorlage (/pdf/*.tpl)?

 

Have you tried to use {$customer->email} in a template (/pdf/*.tpl)?

Share this post


Link to post
Share on other sites
  • 0

Sorry, das $customer Variable ist in Rechnungen zur Verfügung. Siehe die getContent Funktion in der /classes/pdf/HTMLTemplateInvoice.php-Datei und versuchen, Kundendaten zu HTMLTemplateDeliverySlip.php:

Sorry, the $customer variable is available only in invoices. See the getContent function in the /classes/pdf/HTMLTemplateInvoice.php file and try to add customer's data to HTMLTemplateDeliverySlip.php:

$data = array(
    ...
    'customer' => $customer,
    ...

Share this post


Link to post
Share on other sites
  • 0

Hello again tuk66,

 

thank you very much, that works.

 

Add the following row to this file: classes\pdf\HTMLTemplateDeliverySlip.php row-no 86 (befor $carrier = new Carrier):

 

$customer = new Customer((int)$this->order->id_customer);

 

Change the assign of smarty (row 114) from

 

$this->smarty->assign(array(
'order' => $this->order,
'order_details' => $order_details,
'delivery_address' => $formatted_delivery_address,
'invoice_address' => $formatted_invoice_address,
'order_invoice' => $this->order_invoice,
'carrier' => $carrier,
'display_product_images' => Configuration::get('PS_PDF_IMG_DELIVERY')
));

Share this post


Link to post
Share on other sites
  • 0

to

 

$this->smarty->assign(array(
'order' => $this->order,
'order_details' => $order_details,
'delivery_address' => $formatted_delivery_address,
'invoice_address' => $formatted_invoice_address,
'customer' => $customer,
'order_invoice' => $this->order_invoice,
'carrier' => $carrier,
'display_product_images' => Configuration::get('PS_PDF_IMG_DELIVERY')
));

And add this row where ever you want in this file: pdf\delivery-slip.tpl

<tr>
<td colspan="1">
    <p><b>E-Mail:</b></p>
</td>
<td colspan="11">
    <p><b>{$customer->email}</b></p>
</td>
</tr>
 
Finish!

Share this post


Link to post
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...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More