|
From: <ex...@us...> - 2015-10-06 12:36:29
|
Revision: 7365
http://sourceforge.net/p/web-erp/reponame/7365
Author: exsonqu
Date: 2015-10-06 12:36:27 +0000 (Tue, 06 Oct 2015)
Log Message:
-----------
06/10/15 UK-Steven: Contribute email customer statements feature scripts.
Modified Paths:
--------------
trunk/PrintCustStatements.php
trunk/SelectCustomer.php
Added Paths:
-----------
trunk/EmailCustStatements.php
Added: trunk/EmailCustStatements.php
===================================================================
--- trunk/EmailCustStatements.php (rev 0)
+++ trunk/EmailCustStatements.php 2015-10-06 12:36:27 UTC (rev 7365)
@@ -0,0 +1,51 @@
+<?php
+
+/* $Id: EmailCustTrans.php 6310 2013-08-29 10:42:50Z daintree $*/
+
+include ('includes/session.inc');
+include ('includes/SQL_CommonFunctions.inc');
+if (!isset($_GET['FromCust'])) {
+ $_GET['FromCust'] = $_SESSION['CustomerID'];
+}
+$Title=_('Email Customer Statement For Customer No.') . ' ' . $_GET['FromCust'];
+
+if (isset($_POST['DoIt']) AND IsEmailAddress($_POST['EmailAddr'])){
+ echo '<meta http-equiv="Refresh" content="0; url=' . $RootPath . '/PrintCustStatements.php?FromCust=' . $_SESSION['CustomerID'] . '&ToCust='.$_SESSION['CustomerID'] . '&PrintPDF=Yes&Email=' . $_POST['EmailAddr'] . '">';
+ prnMsg(_('The customer statement should have been emailed off') . '. ' . _('If this does not happen') . ' (' . _('if the browser does not support META Refresh') . ')' . '<a href="' . $RootPath . '/PrintCustStatements.php?FromCust=' . $_SESSION['CustomerID'] . '&PrintPDF=Yes&Email=' . $_POST['EmailAddr'] . '">' . _('click here') . '</a> ' . _('to email the customer statement'),'success');
+ exit;
+} elseif (isset($_POST['DoIt'])) {
+ prnMsg(_('The email address does not appear to be a valid email address. The statement was not emailed'),'warn');
+}
+include ('includes/header.inc');
+
+echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '" method="post">';
+echo '<div>';
+echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
+echo '<br /><table>';
+
+$SQL = "SELECT custbranch.email as email
+ FROM custbranch INNER JOIN debtorsmaster
+ ON custbranch.debtorno= debtorsmaster.debtorno
+ WHERE debtorsmaster.debtorno='" .$_SESSION['CustomerID'] . "' LIMIT 1";
+
+$ErrMsg = _('There was a problem retrieving the contact details for the customer');
+$ContactResult=DB_query($SQL,$db,$ErrMsg);
+
+if (DB_num_rows($ContactResult)>0){
+ $EmailAddrRow = DB_fetch_row($ContactResult);
+ $EmailAddress = $EmailAddrRow[0];
+} else {
+ $EmailAddress ='';
+}
+
+echo '<tr><td>' . _('Email to') . ':</td>
+ <td><input type="email" name="EmailAddr" autofocus="autofocus" maxlength="60" size="60" value="' . $EmailAddress . '" /></td>
+ </tr>
+ </table>';
+
+echo '<br /><div class="centre"><input type="submit" name="DoIt" value="' . _('OK') . '" />';
+echo '</div>
+ </div>
+ </form>';
+include ('includes/footer.inc');
+?>
Modified: trunk/PrintCustStatements.php
===================================================================
--- trunk/PrintCustStatements.php 2015-10-06 10:04:45 UTC (rev 7364)
+++ trunk/PrintCustStatements.php 2015-10-06 12:36:27 UTC (rev 7365)
@@ -7,7 +7,7 @@
$ViewTopic = 'ARReports';
$BookMark = 'CustomerStatements';
-
+$Title = _('Print Customer Statements');
// If this file is called from another script, we set the required POST variables from the GET
// We call this file from SelectCustomer.php when a customer is selected and we want a statement printed
@@ -180,6 +180,8 @@
include('includes/PDFStatementPageHeader.inc');
+ $Cust_Name = $StmtHeader['name'];
+ $Cust_No = $StmtHeader['debtorno'];
if ($_SESSION['Show_Settled_LastMonth']==1){
if (DB_num_rows($SetldTrans)>=1) {
@@ -434,8 +436,39 @@
} /* end loop to print statements */
if (isset($pdf)){
+ if (isset($_GET['Email'])){ //email the invoice to address supplied
+ include ('includes/htmlMimeMail.php');
+ $FileName = 'XXX_' . 'Statement_' . $Cust_No . '_' . $Cust_Name . '.pdf';
+ $pdf->Output($FileName,'F');
+ $mail = new htmlMimeMail();
- $pdf->OutputD($_SESSION['DatabaseName'] . '_CustStatements_' . date('Y-m-d') . '.pdf');
+ $Attachment = $mail->getFile($FileName);
+ $mail->setText(_('Please find attached Statements') );
+ $mail->SetSubject('Your Statement From XXX');
+ $mail->addAttachment($Attachment, $FileName, 'application/pdf');
+ if($_SESSION['SmtpSetting'] == 0){
+ $mail->setFrom($_SESSION['CompanyRecord']['coyname'] . ' <' . $_SESSION['CompanyRecord']['email'] . '>');
+ $result = $mail->send(array($_GET['Email']));
+ }else{
+ $result = SendmailBySmtp($mail,array($_GET['Email']));
+ }
+
+ unlink($FileName); //delete the temporary file
+
+ $Title = _('Emailing customer statements');
+ include('includes/header.inc');
+ echo '<p>' . _(' Customer statements has been emailed to') . ' ' . $_GET['Email'];
+ include('includes/footer.inc');
+ exit;
+
+
+ } else { //its not an email just print the invoice to PDF
+
+ $pdf->OutputD($_SESSION['DatabaseName'] . '_CustStatements_' . date('Y-m-d') . '.pdf');
+
+
+ }
+
$pdf->__destruct();
} else {
@@ -476,4 +509,4 @@
} /*end of else not PrintPDF */
-?>
\ No newline at end of file
+?>
Modified: trunk/SelectCustomer.php
===================================================================
--- trunk/SelectCustomer.php 2015-10-06 10:04:45 UTC (rev 7364)
+++ trunk/SelectCustomer.php 2015-10-06 12:36:27 UTC (rev 7365)
@@ -222,6 +222,7 @@
echo '<a href="' . $RootPath . '/CustomerAccount.php?CustomerID=' . $_SESSION['CustomerID'] . '">' . _('Customer Account statement on screen') . '</a><br />';
echo '<a href="' . $RootPath . '/Customers.php?DebtorNo=' . $_SESSION['CustomerID'] . '&Modify=No">' . _('View Customer Details') . '</a><br />';
echo '<a href="' . $RootPath . '/PrintCustStatements.php?FromCust=' . $_SESSION['CustomerID'] . '&ToCust=' . $_SESSION['CustomerID'] . '&PrintPDF=Yes">' . _('Print Customer Statement') . '</a><br />';
+ echo '<a href="' . $RootPath . '/EmailCustStatements.php?FromCust=' . $_SESSION['CustomerID'] . '&ToCust=' . $_SESSION['CustomerID'] . '&PrintPDF=Yes">' . _('Email Customer Statement') . '</a><br />';
echo '<a href="' . $RootPath . '/SelectCompletedOrder.php?SelectedCustomer=' . $_SESSION['CustomerID'] . '">' . _('Order Inquiries') . '</a><br />';
echo '<a href="' . $RootPath . '/CustomerPurchases.php?DebtorNo=' . $_SESSION['CustomerID'] . '">' . _('Show purchases from this customer') . '</a><br />';
wikiLink('Customer', $_SESSION['CustomerID']);
|