From 64074305d3b851155f9c37bb3c348a620f0e7c59 Mon Sep 17 00:00:00 2001 From: BENKE Charles Date: Tue, 18 Feb 2014 15:22:45 +0100 Subject: [PATCH 1/3] Update fiche.php double line --- htdocs/fichinter/fiche.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index e40d2b44daa..59359ec2b3b 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -31,7 +31,6 @@ require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/fichinter/modules_fichinter.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/fichinter.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcontract.class.php'; if (! empty($conf->projet->enabled)) { From 05865a79782f3d6d985be1bda77717fa403d2285 Mon Sep 17 00:00:00 2001 From: BENKE Charles Date: Tue, 18 Feb 2014 15:49:16 +0100 Subject: [PATCH 2/3] Update fiche.php somme other error --- htdocs/fichinter/fiche.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index 59359ec2b3b..66ebc3733be 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -857,7 +857,8 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->ficheint $form = new Form($db); $formfile = new FormFile($db); -$formcontract = new FormContract($db); +if ($conf->contrat->enabled) + $formcontract = new FormContract($db); llxHeader('',$langs->trans("Fichinter")); @@ -982,7 +983,7 @@ if ($action == 'create') $numprojet=$formproject->select_projects($soc->id,GETPOST('projectid','int'),'projectid'); if ($numprojet==0) { - print '   '.$langs->trans("AddProject").''; + print '   '.$langs->trans("AddProject").''; } print ''; } From 22854e5743d81194c53ecc640ab5919d331d1076 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 24 Feb 2014 16:50:36 +0100 Subject: [PATCH 3/3] New: Sending remind of unpayed invoices by emails (need tester) --- htdocs/compta/facture/impayees.php | 211 +++++++++++++--------- htdocs/core/class/html.formmail.class.php | 10 +- htdocs/langs/en_US/mails.lang | 3 + 3 files changed, 132 insertions(+), 92 deletions(-) diff --git a/htdocs/compta/facture/impayees.php b/htdocs/compta/facture/impayees.php index 36cc7944105..880f13d67d7 100644 --- a/htdocs/compta/facture/impayees.php +++ b/htdocs/compta/facture/impayees.php @@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; - +$langs->load("mails"); $langs->load("bills"); $id = (GETPOST('facid','int') ? GETPOST('facid','int') : GETPOST('id','int')); @@ -54,10 +54,16 @@ $resultmasssend=''; */ // Send remind email -if ($action == 'presend' && GETPOST('cancel')) $action=''; +if ($action == 'presend' && GETPOST('cancel')) +{ + $action=''; + if (GETPOST('models')=='facture_relance') $mode='sendmassremind'; // If we made a cancel from submit email form, this means we must be into mode=sendmassremind +} if ($action == 'presend' && GETPOST('sendmail')) { + if (GETPOST('models')=='facture_relance') $mode='sendmassremind'; // If we made a cancel from submit email form, this means we must be into mode=sendmassremind + if (!isset($user->email)) { $error++; @@ -70,10 +76,10 @@ if ($action == 'presend' && GETPOST('sendmail')) $error++; setEventMessage("InvoiceNotChecked","warnings"); } - + if (! $error) { - $compteEmailEnvoi = 0; + $nbsent = 0; $nbignored = 0; for ($i = 0; $i < $countToSend; $i++) @@ -83,13 +89,19 @@ if ($action == 'presend' && GETPOST('sendmail')) if ($result > 0) // Invoice was found { - if ($object->statut != 1) continue; // Payment done or started or canceled + if ($object->statut != 1) + { + continue; // Payment done or started or canceled + } - // Read PDF - $filename=dol_sanitizeFileName($object->ref); + // Read document + // TODO Use future field $object->fullpathdoc to know where is stored default file + // TODO If not defined, use $object->modelpdf (or defaut invoice config) to know what is template to use to regenerate doc. + $filename=dol_sanitizeFileName($object->ref).'.pdf'; $filedir=$conf->facture->dir_output . '/' . dol_sanitizeFileName($object->ref); - $file = $filedir . '/' . $filename.'.pdf'; // TODO What if ODT ? - + $file = $filedir . '/' . $filename; + $mime = 'application/pdf'; + if (dol_is_file($file)) { $object->fetch_thirdparty(); @@ -102,10 +114,20 @@ if ($action == 'presend' && GETPOST('sendmail')) $langs->load("commercial"); $from = $user->getFullName($langs) . ' <' . $user->email .'>'; $replyto = $from; - $message = $conf->global->RELANCES_MASSE_TEXTE_EMAIL; - $subject = $conf->global->RELANCES_MASSE_OBJET_EMAIL; - - $substitutionarray= + $subject = GETPOST('subject'); + $message = GETPOST('message'); + $sendtocc = GETPOST('sentocc'); + + $substitutionarray=array( + '__ID__' => $object->id, + '__EMAIL__' => $object->thirdparty->email, + '__CHECK_READ__' => '', + //'__LASTNAME__' => $obj2->lastname, + //'__FIRSTNAME__' => $obj2->firstname, + '__REF__' => $object->ref, + '__REFCLIENT__' => $object->thirdparty->name + ); + make_substitutions($message, $substitutionarray); $actiontypecode='AC_FAC'; @@ -116,12 +138,9 @@ if ($action == 'presend' && GETPOST('sendmail')) $actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n"; $actionmsg.=$message; } - // Create form object - include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'); - $formmail = new FormMail($db); - $formmail->clear_attached_files(); - $formmail->add_attached_files($file, $object->ref.'.pdf', 'application/pdf'); - $attachedfiles=$formmail->get_attached_files(); + + // Create form object + $attachedfiles=array('paths'=>array($file), 'names'=>array($filename), 'mimes'=>array($mime)); $filepath = $attachedfiles['paths']; $filename = $attachedfiles['names']; $mimetype = $attachedfiles['mimes']; @@ -135,7 +154,7 @@ if ($action == 'presend' && GETPOST('sendmail')) } else { - $result=$mailfile->sendfile(); + //$result=$mailfile->sendfile(); if ($result) { $resultmasssend.=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); // Must not contain " @@ -157,42 +176,53 @@ if ($action == 'presend' && GETPOST('sendmail')) if ($result < 0) { $error++; $this->errors=$interface->errors; } // Fin appel triggers - if ($error) + if (! $error) + { + $resultmasssend.=$langs->trans("MailSent").': '.$sendto."
\n"; + } + else { dol_print_error($db); } - $compteEmailEnvoi ++; + $nbsent++; } else { $langs->load("other"); - $resultmasssend.='
'; if ($mailfile->error) { $resultmasssend.=$langs->trans('ErrorFailedToSendMail',$from,$sendto); - $resultmasssend.='
'.$mailfile->error; + $resultmasssend.='
'.$mailfile->error.'
'; } else { - $resultmasssend.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; + $resultmasssend.='
No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS
'; } - $resultmasssend.='
'; } } } } else { + $nbignored++; $langs->load("other"); - print $resultmasssend='
'.$langs->trans('ErrorCantReadFile',$file).'
'; + $resultmasssend.='
'.$langs->trans('ErrorCantReadFile',$file).'
'; dol_syslog('Failed to read file: '.$file); break ; } } } - - setEventMessage($compteEmailEnvoi. '/'.$countToSend.' '.$langs->trans("RemindSent")); + + if ($nbsent) + { + $action=''; // Do not show form post if there was at least one successfull sent + setEventMessage($nbsent. '/'.$countToSend.' '.$langs->trans("RemindSent")); + } + else + { + setEventMessage($langs->trans("NoRemindSent"), 'warnings'); + } } } @@ -347,7 +377,7 @@ if (! $sortorder) $sortorder="ASC"; $limit = $conf->liste_limit; -$sql = "SELECT s.nom, s.rowid as socid"; +$sql = "SELECT s.nom, s.rowid as socid, s.email"; $sql.= ", f.rowid as facid, f.facnumber, f.increment, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.localtax1, f.localtax2, f.revenuestamp"; $sql.= ", f.datef as df, f.date_lim_reglement as datelimite"; $sql.= ", f.paye as paye, f.fk_statut, f.type"; @@ -378,7 +408,7 @@ if ($search_societe) $sql .= " AND s.nom LIKE '%".$db->escape($search_societ if ($search_montant_ht) $sql .= " AND f.total = '".$db->escape($search_montant_ht)."'"; if ($search_montant_ttc) $sql .= " AND f.total_ttc = '".$db->escape($search_montant_ttc)."'"; if (GETPOST('sf_ref')) $sql .= " AND f.facnumber LIKE '%".$db->escape(GETPOST('sf_ref'))."%'"; -$sql.= " GROUP BY s.nom, s.rowid, f.rowid, f.facnumber, f.increment, f.total, f.tva, f.total_ttc, f.localtax1, f.localtax2, f.revenuestamp, f.datef, f.date_lim_reglement, f.paye, f.fk_statut, f.type "; +$sql.= " GROUP BY s.nom, s.rowid, s.email, f.rowid, f.facnumber, f.increment, f.total, f.tva, f.total_ttc, f.localtax1, f.localtax2, f.revenuestamp, f.datef, f.date_lim_reglement, f.paye, f.fk_statut, f.type "; if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user "; $sql.= " ORDER BY "; $listfield=explode(',',$sortfield); @@ -422,11 +452,70 @@ if ($resql) dol_htmloutput_mesg($mesg); - print '
'; + print ''; + + if (! empty($mode) && $action == 'presend') + { + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + + print '
'; + print_fiche_titre($langs->trans("SendRemind"),'','').'
'; + + $topicmail="MailTopicSendRemindUnpaidInvoices"; + $modelmail="facture_relance"; + + // Cree l'objet formulaire mail + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + $formmail->withform=-1; + $formmail->fromtype = 'user'; + $formmail->fromid = $user->id; + $formmail->fromname = $user->getFullName($langs); + $formmail->frommail = $user->email; + $formmail->withfrom=1; + $liste=array(); + $formmail->withto=$langs->trans("AllRecipientSelectedForRemind"); + $formmail->withtofree=0; + $formmail->withtoreadonly=1; + $formmail->withtocc=1; + $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; + $formmail->withtopic=$langs->transnoentities($topicmail, '__FACREF__', '__REFCLIENT__'); + $formmail->withfile=$langs->trans("EachInvoiceWillBeAttachedToEmail"); + $formmail->withbody=1; + $formmail->withdeliveryreceipt=1; + $formmail->withcancel=1; + // Tableau des substitutions + //$formmail->substit['__FACREF__']=''; + $formmail->substit['__SIGNATURE__']=$user->signature; + //$formmail->substit['__REFCLIENT__']=''; + $formmail->substit['__PERSONALIZED__']=''; + $formmail->substit['__CONTACTCIVNAME__']=''; + + // Tableau des parametres complementaires du post + $formmail->param['action']=$action; + $formmail->param['models']=$modelmail; + $formmail->param['facid']=$object->id; + $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; + + print $formmail->get_form(); + print '
'."\n"; + } + print ''; print ''; if ($late) print ''; + if ($resultmasssend) + { + print '
'.$langs->trans("ResultOfMassSending").':
'."\n"; + print $langs->trans("Selected").': '.$countToSend."\n
"; + print $langs->trans("Ignored").': '.$nbignored."\n
"; + print $langs->trans("Sent").': '.$nbsent."\n
"; + //print $resultmasssend; + print '
'; + } + $i = 0; print ''; print ''; @@ -570,8 +659,9 @@ if ($resql) else { // Checkbox to send remind - print '' ; } @@ -615,64 +705,11 @@ if ($resql) } else { - $langs->load("mails"); - if ($action != 'presend') { print ''; - } - else - { - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - - print '
'; - print_fiche_titre($langs->trans("SendRemind"),'','').'
'; - - $topicmail="MailTopicSendRemindUnpaidInvoices"; - $modelmail="facture_relance"; - - // Cree l'objet formulaire mail - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - $formmail->fromtype = 'user'; - $formmail->fromid = $user->id; - $formmail->fromname = $user->getFullName($langs); - $formmail->frommail = $user->email; - $formmail->withfrom=1; - $liste=array(); - $formmail->withto=''; - $formmail->withtocc=1; - $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; - $formmail->withtopic=$langs->transnoentities($topicmail, '__FACREF__', '__REFCLIENT__'); - $formmail->withfile=$langs->trans("EachInvoiceWillBeAttachedToEmail"); - $formmail->withbody=1; - $formmail->withdeliveryreceipt=1; - $formmail->withcancel=1; - // Tableau des substitutions - //$formmail->substit['__FACREF__']=''; - $formmail->substit['__SIGNATURE__']=$user->signature; - //$formmail->substit['__REFCLIENT__']=''; - $formmail->substit['__PERSONALIZED__']=''; - $formmail->substit['__CONTACTCIVNAME__']=''; - - // Tableau des parametres complementaires du post - $formmail->param['action']=$action; - $formmail->param['models']=$modelmail; - $formmail->param['facid']=$object->id; - $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; - - print $formmail->get_form(); - - - } - - if ($resultmasssend) - { - print '
'.$langs->trans("ResultOfMassSending").':
'."\n"; - print $resultmasssend; print '
'; } } diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 7746d178e67..a76877c9994 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -35,7 +35,7 @@ class FormMail { var $db; - var $withform; + var $withform; // 1=Include HTML form tag and show submit button, 0=Do not include form tag and submit button, -1=Do not include form tag but include submit button var $fromname; var $frommail; @@ -43,7 +43,7 @@ class FormMail var $replytomail; var $toname; var $tomail; - + var $withsubstit; // Show substitution array var $withfrom; var $withto; // Show recipient emails @@ -249,7 +249,7 @@ class FormMail $form=new Form($this->db); $out.= "\n\n"; - if ($this->withform) + if ($this->withform == 1) { $out.= ''."\n"; $out.= ''; @@ -619,7 +619,7 @@ class FormMail $out.= "\n"; } - if (! empty($this->withform)) + if ($this->withform == 1 || $this->withform == -1) { $out.= '
'; - print ''; + print ''; + if ($objp->email) print ''; + else print img_picto($langs->trans("NoEMail"), 'warning.png'); print '
'; $out.= 'withform)) $out.= ''."\n"; + if ($this->withform == 1) $out.= ''."\n"; $out.= "\n"; return $out; diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index 88d499ac7e0..f91a4bc9fe3 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -83,6 +83,9 @@ EachInvoiceWillBeAttachedToEmail=A document using default invoice document templ MailTopicSendRemindUnpaidInvoices=Remind of invoice %s (%s) SendRemind=Send remind by EMails RemindSent=%S remind(s) sent +AllRecipientSelectedForRemind=All thirdparties selected and if an email is set (note that one mail per invoice will be sent) +NoRemindSent=No remind by EMail sent +ResultOfMassSending=Result of mass remind sending by EMail # Libelle des modules de liste de destinataires mailing MailingModuleDescContactCompanies=Contacts/addresses of all third parties (customer, prospect, supplier, ...)