webERP Forum
Customer referance in email Subject - Printable Version

+- webERP Forum (
+-- Forum: webERP Discussion (/forumdisplay.php?fid=1)
+--- Forum: How To ? (/forumdisplay.php?fid=6)
+--- Thread: Customer referance in email Subject (/showthread.php?tid=8177)

Customer referance in email Subject - srdjanm - 06-08-2018 08:48 AM

I'm trying to add Customer Order Ref to the e-mail Subject line for email invoices.
I don't see e-mail Subject in EmailCustTrans.php. In wich file is creation of the Subject line, so that I can analyze this file.
I was thinking to add the following sql to get the Customer Order Re for the invoice to e-mail.:

$SQL = "SELECT customerref
FROM salesorders
LEFT JOIN debtortrans
ON salesorders.orderno=debtortrans.order_
WHERE debtortrans.transno='" .$_GET['FromTransNo'] . "'";

Thank you

RE: Customer referance in email Subject - TurboPT - 06-08-2018 11:15 AM

A query might not be needed (maybe), but here's some more info:

Within the EmailCustTrans.php, after submit, goes to one of two files depending on the System Parameters setting to "Invoice Orientation:"

See lines 17-27 in the EmailCustTrans file, and follow the flow from there.
If other questions should arise, please post another reply.

RE: Customer referance in email Subject - srdjanm - 06-10-2018 12:53 AM

Thank you TurboPT!!
I tested the following solution and it is in production now:

Solution: copy bellow lines to PrintCustTrans.php webERP version 4.14.1, line to replaced 492:

PHP Code:
$mail->SetSubject($InvOrCredit ' ' $FromTransNo); 
PHP Code:
/* Get Customer Order reference no. from salesorders and add it to the email Subject line - start */
$sql "SELECT customerref
            FROM salesorders
            LEFT JOIN debtortrans
            ON salesorders.orderno=debtortrans.order_
            WHERE debtortrans.transno='" 
.$_GET['FromTransNo'] . "'";
        if (
DB_num_rows($result)==1) {
$myrow DB_fetch_array($result);
$POnum $myrow['customerref'];
        else { 
$POnum '';
        if (
stripos$POnum'P') !== false || $POnum == '') {
$mail->SetSubject($InvOrCredit ' ' $FromTransNo ' ' $POnum );
        else {
$mail->SetSubject($InvOrCredit ' ' $FromTransNo ' PO: ' $POnum );

/* Get Customer Order reference no. from salesorders and add it to the email Subject line  - end */ 

RE: Customer referance in email Subject - TurboPT - 06-10-2018 02:04 AM

Assuming that you need that PO information for invoices, know that the customerref field is already part of the query at line 82 in the 4.14.1 version of the PrintCustTrans file, so you should be able to [re]use the data from that query instead?

However, the customerref field is not in the credit notes query at line 159. Assuming that you would want the same info for credit notes, it shouldn't be too much to add salesorders as a LEFT JOIN since the debtortrans table is already in this query to get the customerref info. Then the field would be available for both situations. Smile