webERP Forum

Full Version: Customer referance in email Subject
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,
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
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.
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:

original:
PHP Code:
$mail->SetSubject($InvOrCredit ' ' $FromTransNo); 
new:
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'] . "'";
        
$result=DB_query($sql);
        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 */ 
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
Reference URL's