From f640bf7c61ec37e146879f420b8e82825a445398 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 9 Feb 2016 11:56:12 +0100 Subject: [PATCH] Manage the reply-to field into mail libs --- htdocs/comm/index.php | 82 +++++++++++++++++++++++ htdocs/compta/facture/list.php | 5 +- htdocs/core/class/CMailFile.class.php | 18 ++--- htdocs/core/class/smtps.class.php | 34 +++++++++- htdocs/core/lib/functions.lib.php | 37 ++++++++-- htdocs/langs/en_US/main.lang | 2 +- htdocs/langs/en_US/supplier_proposal.lang | 1 + htdocs/theme/eldy/style.css.php | 3 + htdocs/theme/md/style.css.php | 3 + 9 files changed, 167 insertions(+), 18 deletions(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 93f9b243624..727e9904fef 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; if (! empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +if (! empty($conf->supplier_proposal->enabled)) require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; @@ -66,6 +67,7 @@ $form = new Form($db); $formfile = new FormFile($db); $companystatic=new Societe($db); if (! empty($conf->propal->enabled)) $propalstatic=new Propal($db); +if (! empty($conf->supplier_proposal->enabled)) $supplierproposalstatic=new SupplierProposal($db); if (! empty($conf->commande->enabled)) $orderstatic=new Commande($db); if (! empty($conf->fournisseur->enabled)) $supplierorderstatic=new CommandeFournisseur($db); @@ -208,6 +210,86 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) } + +/* + * Draft supplier proposals + */ +if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) +{ + $langs->load("supplier_proposal"); + + $sql = "SELECT p.rowid, p.ref, p.total_ht, p.tva as total_tva, p.total as total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; + $sql.= ", s.code_client"; + $sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p"; + $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE p.fk_statut = 0"; + $sql.= " AND p.fk_soc = s.rowid"; + $sql.= " AND p.entity IN (".getEntity('propal', 1).")"; + if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($socid) $sql.= " AND s.rowid = ".$socid; + + $resql=$db->query($sql); + if ($resql) + { + $total = 0; + $num = $db->num_rows($resql); + + print ''; + print ''; + print ''; + + if ($num > 0) + { + $i = 0; + $var=true; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + $var=!$var; + print ''; + print ''; + print ''; + $i++; + $total += $obj->total_ht; + } + if ($total>0) + { + $var=!$var; + print '"; + } + } + else + { + $var=!$var; + print ''; + } + print "
'.$langs->trans("SupplierProposalsDraft").($num?' '.$num.'':'').'
'; + $supplierproposalstatic->id=$obj->rowid; + $supplierproposalstatic->ref=$obj->ref; + $supplierproposalstatic->total_ht = $obj->total_ht; + $supplierproposalstatic->total_tva = $obj->total_tva; + $supplierproposalstatic->total_ttc = $obj->total_ttc; + print $supplierproposalstatic->getNomUrl(1); + print ''; + $companystatic->id=$obj->socid; + $companystatic->name=$obj->name; + $companystatic->client=$obj->client; + $companystatic->code_client = $obj->code_client; + $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->canvas=$obj->canvas; + print $companystatic->getNomUrl(1,'customer',16); + print ''.price($obj->total_ht).'
'.$langs->trans("Total").''.price($total)."
'.$langs->trans("NoProposal").'

"; + + $db->free($resql); + } + else + { + dol_print_error($db); + } +} + + /* * Draft orders */ diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index af0376fef0e..5068306646b 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -1,7 +1,7 @@ * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005-2015 Regis Houssin * Copyright (C) 2006 Andre Cianfarani @@ -712,8 +712,7 @@ if ($resql) $i = 0; print '
'."\n"; - - print_barre_liste($langs->trans('BillsCustomers').' '.($socid?' '.$soc->name:''),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,$massactionbutton,$num,$nbtotalofrecords,'title_accountancy.png'); + print_barre_liste($langs->trans('BillsCustomers').' '.($socid?' '.$soc->name:''),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,$massactionbutton,$num,$nbtotalofrecords,'title_accountancy.png',0,'','',$limit); if ($massaction == 'presend') { diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 82d1444ff73..c0e5bb5458a 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -37,10 +37,11 @@ class CMailFile { var $subject; // Topic: Subject of email - var $addr_from; // From: Label and EMail of sender (must include '<>'). For example '' or 'John Doe ' or '') + var $addr_from; // From: Label and EMail of sender (must include '<>'). For example '' or 'John Doe ' or ''). Note that with gmail smtps, value here is forced by google to account (but not the reply-to). // Sender: Who send the email ("Sender" has sent emails on behalf of "From"). // Use it when the "From" is an email of a domain that is a SPF protected domain, and sending smtp server is not this domain. In such case, add Sender field with an email of the protected domain. // Return-Path: Email where to send bounds. + var $reply_to; // Reply-To: Email where to send replies from mailer software (mailer use From if reply-to not defined, Gmail use gmail account if reply-to not defined) var $errors_to; // Errors-To: Email where to send errors. var $addr_to; var $addr_cc; @@ -190,6 +191,7 @@ class CMailFile // Define smtp_headers $this->subject = $subject; $this->addr_from = $from; + $this->reply_to = $from; // Set this property after constructor if you want to use another value $this->errors_to = $errors_to; $this->addr_to = $to; $this->addr_cc = $addr_cc; @@ -256,7 +258,8 @@ class CMailFile $smtps->setTO($this->getValidAddress($to,0,1)); $smtps->setFrom($this->getValidAddress($from,0,1)); $smtps->setTrackId($trackid); - + $smtps->setReplyTo($this->getValidAddress($from,0,1)); // Set property with this->smtps->setReplyTo after constructor if you want to use another value than the From + if (! empty($this->html)) { if (!empty($css)) @@ -308,6 +311,7 @@ class CMailFile $this->phpmailer->Subject($this->encodetorfc2822($subject)); $this->phpmailer->setTO($this->getValidAddress($to,0,1)); $this->phpmailer->SetFrom($this->getValidAddress($from,0,1)); + $this->phpmailer->SetReplyTo($this->getValidAddress($from,0,1)); // Set property with this->phpmailer->setReplyTo after constructor if you want to use another value than the From // TODO Add trackid into smtp header if (! empty($this->html)) @@ -341,12 +345,10 @@ class CMailFile } } - $smtps->setCC($addr_cc); - $smtps->setBCC($addr_bcc); - $smtps->setErrorsTo($errors_to); - $smtps->setDeliveryReceipt($deliveryreceipt); - - $this->smtps=$smtps; + $this->phpmailer->setCC($addr_cc); + $this->phpmailer->setBCC($addr_bcc); + $this->phpmailer->setErrorsTo($errors_to); + $this->phpmailer->setDeliveryReceipt($deliveryreceipt); } else { diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index 8b8e9e4905c..cfefa223a7d 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -817,7 +817,36 @@ class SMTPs return $_retValue; } - + /** + * Reply-To Address from which mail will be the reply-to + * + * @param string $_strReplyTo Address from which mail will be the reply-to + * @return void + */ + function setReplyTo($_strReplyTo) + { + if ( $_strReplyTo ) + $this->_msgReplyTo = $this->_strip_email($_strReplyTo); + } + + /** + * Retrieves the Address from which mail will be the reply-to + * + * @param boolean $_part To "strip" 'Real name' from address + * @return string Address from which mail will be the reply-to + */ + function getReplyTo($_part = true) + { + $_retValue = ''; + + if ( $_part === true ) + $_retValue = $this->_msgReplyTo; + else + $_retValue = $this->_msgReplyTo[$_part]; + + return $_retValue; + } + /** * Inserts given addresses into structured format. * This method takes a list of given addresses, via an array @@ -1159,7 +1188,8 @@ class SMTPs $_header .= 'Disposition-Notification-To: '.$this->getFrom('addr') . "\r\n"; if ( $this->getErrorsTo() ) $_header .= 'Errors-To: '.$this->getErrorsTo('addr') . "\r\n"; - $_header .= "Reply-To: ".$this->getFrom('addr') ."\r\n"; + if ( $this->getReplyTo() ) + $_header .= "Reply-To: ".$this->getReplyTo('addr') ."\r\n"; $_header .= 'X-Mailer: Dolibarr version ' . DOL_VERSION .' (using SMTPs Mailer)' . "\r\n" . 'Mime-Version: 1.0' . "\r\n"; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 17a1a575a97..26f549fab1f 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2968,7 +2968,7 @@ function load_fiche_titre($titre, $mesg='', $picto='title_generic.png', $pictois * @param int $pictoisfullpath 1=Icon name is a full absolute url of image * @param string $morehtml More html to show * @param string $morecss More css to the table - * @param int $limit Limit ofnumber of lines on each page + * @param int $limit Max number of lines * @return void */ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $center='', $num=-1, $totalnboflines=0, $picto='title_generic.png', $pictoisfullpath=0, $morehtml='', $morecss='', $limit=0) @@ -3016,7 +3016,7 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so { if ($totalnboflines) // If we know total nb of lines { - $maxnbofpage=(empty($conf->dol_optimize_smallscreen) ? 6 : 3); // nb before and after selected page + ... + first or last + $maxnbofpage=(empty($conf->dol_optimize_smallscreen) ? 6 : 3); // page nb before and after selected page + ... + first or last $nbpages=ceil($totalnboflines/$limit); $cpt=($page-$maxnbofpage); @@ -3055,7 +3055,7 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so $pagelist.= 'dol_use_jmobile)?' class="pagination"':'').'>dol_use_jmobile)?'class="active"':'data-role="button"').'>'.($page+1).""; } } - print_fleche_navigation($page,$file,$options,$nextpage,$pagelist,$morehtml); // output the div and ul for previous/last completed with page numbers into $pagelist + print_fleche_navigation($page, $file, $options, $nextpage, $pagelist, $morehtml, $limit, $totalnboflines); // output the div and ul for previous/last completed with page numbers into $pagelist print ''; print ''."\n"; @@ -3071,13 +3071,42 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so * @param integer $nextpage Do we show a next page button * @param string $betweenarrows HTML content to show between arrows. MUST contains '
  • ' tags or '
  • '. * @param string $afterarrows HTML content to show after arrows. Must NOT contains '
  • ' tags. + * @param string $limit Max nb of record to show ('' = unknown = default, '0' = no limit, 'x' = limit) + * @param int $totalnboflines Total number of records/lines for all pages (if known) * @return void */ -function print_fleche_navigation($page, $file, $options='', $nextpage=0, $betweenarrows='', $afterarrows='') +function print_fleche_navigation($page, $file, $options='', $nextpage=0, $betweenarrows='', $afterarrows='', $limit='', $totalnboflines=0) { global $conf, $langs; print '