Start to work on a mass send remind feature.
This commit is contained in:
parent
0b7f623c31
commit
6f962397e4
@ -132,7 +132,7 @@ if (! empty($_POST['removedfile']) || ! empty($_POST['removedfilehtml']))
|
||||
if (($action == 'send' || $action == 'sendhtml') && ! GETPOST('addfile') && ! GETPOST('addfilehtml') && ! GETPOST('removedfile') && ! GETPOST('cancel'))
|
||||
{
|
||||
$error=0;
|
||||
|
||||
|
||||
$email_from='';
|
||||
if (! empty($_POST["fromname"])) $email_from=$_POST["fromname"].' ';
|
||||
if (! empty($_POST["frommail"])) $email_from.='<'.$_POST["frommail"].'>';
|
||||
@ -144,12 +144,12 @@ if (($action == 'send' || $action == 'sendhtml') && ! GETPOST('addfile') && ! GE
|
||||
$subject = $_POST['subject'];
|
||||
$body = $_POST['message'];
|
||||
$deliveryreceipt= $_POST["deliveryreceipt"];
|
||||
|
||||
|
||||
//Check if we have to decode HTML
|
||||
if (!empty($conf->global->FCKEDITOR_ENABLE_MAILING) && dol_textishtml(dol_html_entity_decode($body, ENT_COMPAT | ENT_HTML401))) {
|
||||
$body=dol_html_entity_decode($body, ENT_COMPAT | ENT_HTML401);
|
||||
}
|
||||
|
||||
|
||||
// Create form object
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
|
||||
$formmail = new FormMail($db);
|
||||
@ -693,7 +693,7 @@ else
|
||||
$formmail->clear_attached_files();
|
||||
}
|
||||
|
||||
$formmail->show_form(($action == 'testhtml'?'addfilehtml':'addfile'),($action == 'testhtml'?'removefilehtml':'removefile'));
|
||||
print $formmail->get_form(($action == 'testhtml'?'addfilehtml':'addfile'),($action == 'testhtml'?'removefilehtml':'removefile'));
|
||||
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
@ -947,7 +947,7 @@ else
|
||||
$formmail->param["mailid"]=$object->id;
|
||||
$formmail->param["returnurl"]=$_SERVER['PHP_SELF']."?id=".$object->id;
|
||||
|
||||
$formmail->show_form();
|
||||
print $formmail->get_form();
|
||||
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
@ -2149,14 +2149,14 @@ else
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=modif">'.$langs->trans('Modify').'</a></div>';
|
||||
}
|
||||
|
||||
|
||||
// ReOpen
|
||||
if (($object->statut == 2 || $object->statut == 3) && $user->rights->propal->cloturer)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen'.(empty($conf->global->MAIN_JUMP_TAG)?'':'#reopen').'"';
|
||||
print '>'.$langs->trans('ReOpen').'</a></div>';
|
||||
}
|
||||
|
||||
|
||||
// Send
|
||||
if ($object->statut == 1 || $object->statut == 2)
|
||||
{
|
||||
@ -2166,7 +2166,7 @@ else
|
||||
}
|
||||
else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#">'.$langs->trans('SendByMail').'</a></div>';
|
||||
}
|
||||
|
||||
|
||||
// Create an order
|
||||
if (! empty($conf->commande->enabled) && $object->statut == 2)
|
||||
{
|
||||
@ -2175,18 +2175,18 @@ else
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/commande/fiche.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddOrder").'</a></div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Create contract
|
||||
if ($conf->contrat->enabled && $object->statut == 2)
|
||||
{
|
||||
$langs->load("contracts");
|
||||
|
||||
|
||||
if ($user->rights->contrat->creer)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/contrat/fiche.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans('AddContract').'</a></div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Create an invoice and classify billed
|
||||
if ($object->statut == 2)
|
||||
{
|
||||
@ -2194,37 +2194,37 @@ else
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddBill").'</a></div>';
|
||||
}
|
||||
|
||||
|
||||
$arraypropal=$object->getInvoiceArrayList();
|
||||
if (is_array($arraypropal) && count($arraypropal) > 0)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=classifybilled&socid='.$object->socid.'">'.$langs->trans("ClassifyBilled").'</a></div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Close
|
||||
if ($object->statut == 1 && $user->rights->propal->cloturer)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=statut'.(empty($conf->global->MAIN_JUMP_TAG)?'':'#close').'"';
|
||||
print '>'.$langs->trans('Close').'</a></div>';
|
||||
}
|
||||
|
||||
|
||||
// Clone
|
||||
if ($user->rights->propal->creer)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object='.$object->element.'">'.$langs->trans("ToClone").'</a></div>';
|
||||
}
|
||||
|
||||
|
||||
// Delete
|
||||
if ($user->rights->propal->supprimer)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete"';
|
||||
print '>'.$langs->trans('Delete').'</a></div>';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
print "<br>\n";
|
||||
@ -2374,7 +2374,7 @@ else
|
||||
$formmail->add_attached_files($file,basename($file),dol_mimetype($file));
|
||||
}
|
||||
|
||||
$formmail->show_form();
|
||||
print $formmail->get_form();
|
||||
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
@ -2676,7 +2676,7 @@ else
|
||||
}
|
||||
|
||||
// Show form
|
||||
$formmail->show_form();
|
||||
print $formmail->get_form();
|
||||
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
@ -3914,8 +3914,8 @@ else if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
$liste[$key]=$value;
|
||||
}
|
||||
$formmail->withto=GETPOST('sendto')?GETPOST('sendto'):$liste;
|
||||
$formmail->withtocc=$liste;
|
||||
$formmail->withto=GETPOST('sendto')?GETPOST('sendto'):$liste; // List suggested for send to
|
||||
$formmail->withtocc=$liste; // List suggested for CC
|
||||
$formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC;
|
||||
if(empty($object->ref_client))
|
||||
{
|
||||
@ -3972,7 +3972,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
$formmail->add_attached_files($file,basename($file),dol_mimetype($file));
|
||||
}
|
||||
|
||||
$formmail->show_form();
|
||||
print $formmail->get_form();
|
||||
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
@ -90,7 +90,7 @@ class Facture extends CommonInvoice
|
||||
var $close_code;
|
||||
//! Commentaire si mis a paye sans paiement complet
|
||||
var $close_note;
|
||||
//! 1 if invoice paid COMPLETELY, 0 otherwise (do not use it anymore, use statut and close_code
|
||||
//! 1 if invoice paid COMPLETELY, 0 otherwise (do not use it anymore, use statut and close_code)
|
||||
var $paye;
|
||||
//! id of source invoice if replacement invoice or credit note
|
||||
var $fk_facture_source;
|
||||
|
||||
@ -37,6 +37,7 @@ $langs->load("bills");
|
||||
$id = (GETPOST('facid','int') ? GETPOST('facid','int') : GETPOST('id','int'));
|
||||
$action = GETPOST('action','alpha');
|
||||
$option = GETPOST('option');
|
||||
$mode=GETPOST('mode');
|
||||
|
||||
// Security check
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
@ -45,11 +46,157 @@ $result = restrictedArea($user,'facture',$id,'');
|
||||
$diroutputpdf=$conf->facture->dir_output . '/unpaid/temp';
|
||||
if (! $user->rights->societe->client->voir || $socid) $diroutputpdf.='/private/'.$user->id; // If user has no permission to see all, output dir is specific to user
|
||||
|
||||
$resultmasssend='';
|
||||
|
||||
|
||||
/*
|
||||
* Action
|
||||
*/
|
||||
|
||||
// Send remind email
|
||||
if ($action == 'presend' && GETPOST('cancel')) $action='';
|
||||
|
||||
if ($action == 'presend' && GETPOST('sendmail'))
|
||||
{
|
||||
if (!isset($user->email))
|
||||
{
|
||||
$error++;
|
||||
setEventMessage("NoSenderEmailDefined");
|
||||
}
|
||||
|
||||
$countToSend = count($_POST['toSend']);
|
||||
if (empty($countToSend))
|
||||
{
|
||||
$error++;
|
||||
setEventMessage("InvoiceNotChecked","warnings");
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$compteEmailEnvoi = 0;
|
||||
$nbignored = 0;
|
||||
|
||||
for ($i = 0; $i < $countToSend; $i++)
|
||||
{
|
||||
$object = new Facture($db);
|
||||
$result = $object->fetch($_POST['toSend'][$i]);
|
||||
|
||||
if ($result > 0) // Invoice was found
|
||||
{
|
||||
if ($object->statut != 1) continue; // Payment done or started or canceled
|
||||
|
||||
// Read PDF
|
||||
$filename=dol_sanitizeFileName($object->ref);
|
||||
$filedir=$conf->facture->dir_output . '/' . dol_sanitizeFileName($object->ref);
|
||||
$file = $filedir . '/' . $filename.'.pdf'; // TODO What if ODT ?
|
||||
|
||||
if (dol_is_file($file))
|
||||
{
|
||||
$object->fetch_thirdparty();
|
||||
$sendto = $object->thirdparty->email;
|
||||
|
||||
if (empty($sendto)) $nbignored++;
|
||||
|
||||
if (dol_strlen($sendto))
|
||||
{
|
||||
$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=
|
||||
make_substitutions($message, $substitutionarray);
|
||||
|
||||
$actiontypecode='AC_FAC';
|
||||
$actionmsg=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n";
|
||||
if ($message)
|
||||
{
|
||||
$actionmsg.=$langs->transnoentities('MailTopic').": ".$subject."\n";
|
||||
$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();
|
||||
$filepath = $attachedfiles['paths'];
|
||||
$filename = $attachedfiles['names'];
|
||||
$mimetype = $attachedfiles['mimes'];
|
||||
|
||||
// Send mail
|
||||
require_once(DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php');
|
||||
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt,-1);
|
||||
if ($mailfile->error)
|
||||
{
|
||||
$resultmasssend.='<div class="error">'.$mailfile->error.'</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$result=$mailfile->sendfile();
|
||||
if ($result)
|
||||
{
|
||||
$resultmasssend.=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); // Must not contain "
|
||||
|
||||
$error=0;
|
||||
|
||||
// Initialisation donnees
|
||||
$object->sendtoid = 0;
|
||||
$object->actiontypecode = $actiontypecode;
|
||||
$object->actionmsg = $actionmsg; // Long text
|
||||
$object->actionmsg2 = $actionmsg2; // Short text
|
||||
$object->fk_element = $object->id;
|
||||
$object->elementtype = $object->element;
|
||||
|
||||
// Appel des triggers
|
||||
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
||||
$interface=new Interfaces($db);
|
||||
$result=$interface->run_triggers('BILL_SENTBYMAIL',$object,$user,$langs,$conf);
|
||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||
// Fin appel triggers
|
||||
|
||||
if ($error)
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
$compteEmailEnvoi ++;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$langs->load("other");
|
||||
$resultmasssend.='<div class="error">';
|
||||
if ($mailfile->error)
|
||||
{
|
||||
$resultmasssend.=$langs->trans('ErrorFailedToSendMail',$from,$sendto);
|
||||
$resultmasssend.='<br>'.$mailfile->error;
|
||||
}
|
||||
else
|
||||
{
|
||||
$resultmasssend.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
|
||||
}
|
||||
$resultmasssend.='</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$langs->load("other");
|
||||
print $resultmasssend='<div class="error">'.$langs->trans('ErrorCantReadFile',$file).'</div>';
|
||||
dol_syslog('Failed to read file: '.$file);
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setEventMessage($compteEmailEnvoi. '/'.$countToSend.' '.$langs->trans("RemindSent"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($action == "builddoc" && $user->rights->facture->lire && ! GETPOST('button_search'))
|
||||
{
|
||||
if (is_array($_POST['toGenerate']))
|
||||
@ -61,9 +208,12 @@ if ($action == "builddoc" && $user->rights->facture->lire && ! GETPOST('button_s
|
||||
// liste les fichiers
|
||||
$files = array();
|
||||
$factures_bak = $factures ;
|
||||
foreach($_POST['toGenerate'] as $basename){
|
||||
foreach($factures as $facture){
|
||||
if(strstr($facture["name"],$basename)){
|
||||
foreach($_POST['toGenerate'] as $basename)
|
||||
{
|
||||
foreach($factures as $facture)
|
||||
{
|
||||
if(strstr($facture["name"],$basename))
|
||||
{
|
||||
$files[] = $conf->facture->dir_output.'/'.$basename.'/'.$facture["name"];
|
||||
}
|
||||
}
|
||||
@ -121,12 +271,12 @@ if ($action == "builddoc" && $user->rights->facture->lire && ! GETPOST('button_s
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg='<div class="error">'.$langs->trans('NoPDFAvailableForChecked').'</div>';
|
||||
setEventMessage($langs->trans('NoPDFAvailableForChecked'),'errors');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg='<div class="error">'.$langs->trans('InvoiceNotChecked').'</div>' ;
|
||||
setEventMessage($langs->trans('InvoiceNotChecked'), 'warnings');
|
||||
}
|
||||
}
|
||||
|
||||
@ -167,6 +317,12 @@ $(document).ready(function() {
|
||||
$("#checknone").click(function() {
|
||||
$(".checkformerge").attr('checked', false);
|
||||
});
|
||||
$("#checkallsend").click(function() {
|
||||
$(".checkforsend").attr('checked', true);
|
||||
});
|
||||
$("#checknonesend").click(function() {
|
||||
$(".checkforsend").attr('checked', false);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
@ -268,6 +424,7 @@ if ($resql)
|
||||
|
||||
print '<form id="form_generate_pdf" method="POST" action="'.$_SERVER["PHP_SELF"].'?sortfield='. $sortfield .'&sortorder='. $sortorder .'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="mode" value="'.$mode.'">';
|
||||
if ($late) print '<input type="hidden" name="late" value="'.dol_escape_htmltag($late).'">';
|
||||
|
||||
$i = 0;
|
||||
@ -283,7 +440,14 @@ if ($resql)
|
||||
print_liste_field_titre($langs->trans("Received"),$_SERVER["PHP_SELF"],"am","",$param,'align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Rest"),$_SERVER["PHP_SELF"],"am","",$param,'align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"fk_statut,paye,am","",$param,'align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Merge"),$_SERVER["PHP_SELF"],"","",$param,'align="center"',$sortfield,$sortorder);
|
||||
if (empty($mode))
|
||||
{
|
||||
print_liste_field_titre($langs->trans("PDFMerge"),$_SERVER["PHP_SELF"],"","",$param,'align="center"',$sortfield,$sortorder);
|
||||
}
|
||||
else
|
||||
{
|
||||
print_liste_field_titre($langs->trans("Remind"),$_SERVER["PHP_SELF"],"","",$param,'align="center"',$sortfield,$sortorder);
|
||||
}
|
||||
print "</tr>\n";
|
||||
|
||||
// Lignes des champs de filtre
|
||||
@ -302,9 +466,18 @@ if ($resql)
|
||||
print '<td class="liste_titre" align="right">';
|
||||
print '<input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
|
||||
print '</td>';
|
||||
print '<td class="liste_titre" align="center">';
|
||||
if ($conf->use_javascript_ajax) print '<a href="#" id="checkall">'.$langs->trans("All").'</a> / <a href="#" id="checknone">'.$langs->trans("None").'</a>';
|
||||
print '</td>';
|
||||
if (empty($mode))
|
||||
{
|
||||
print '<td class="liste_titre" align="center">';
|
||||
if ($conf->use_javascript_ajax) print '<a href="#" id="checkall">'.$langs->trans("All").'</a> / <a href="#" id="checknone">'.$langs->trans("None").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td class="liste_titre" align="center">';
|
||||
if ($conf->use_javascript_ajax) print '<a href="#" id="checkallsend">'.$langs->trans("All").'</a> / <a href="#" id="checknonesend">'.$langs->trans("None").'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
print "</tr>\n";
|
||||
|
||||
if ($num > 0)
|
||||
@ -384,13 +557,23 @@ if ($resql)
|
||||
print $facturestatic->LibStatut($objp->paye,$objp->fk_statut,5,$objp->am);
|
||||
print '</td>';
|
||||
|
||||
// Checkbox
|
||||
print '<td align="center">';
|
||||
if (! empty($formfile->numoffiles))
|
||||
print '<input id="cb'.$objp->facid.'" class="flat checkformerge" type="checkbox" name="toGenerate[]" value="'.$objp->facnumber.'">';
|
||||
if (empty($mode))
|
||||
{
|
||||
// Checkbox to merge
|
||||
print '<td align="center">';
|
||||
if (! empty($formfile->numoffiles))
|
||||
print '<input id="cb'.$objp->facid.'" class="flat checkformerge" type="checkbox" name="toGenerate[]" value="'.$objp->facnumber.'">';
|
||||
else
|
||||
print ' ';
|
||||
print '</td>' ;
|
||||
}
|
||||
else
|
||||
print ' ';
|
||||
print '</td>' ;
|
||||
{
|
||||
// Checkbox to send remind
|
||||
print '<td align="center">';
|
||||
print '<input class="flat checkforsend" type="checkbox" name="toSend[]" value="'.$objp->facid.'">';
|
||||
print '</td>' ;
|
||||
}
|
||||
|
||||
print "</tr>\n";
|
||||
$total_ht+=$objp->total_ht;
|
||||
@ -415,17 +598,85 @@ if ($resql)
|
||||
|
||||
print "</table>";
|
||||
|
||||
/*
|
||||
* Show list of available documents
|
||||
*/
|
||||
$filedir=$diroutputpdf;
|
||||
$genallowed=$user->rights->facture->lire;
|
||||
$delallowed=$user->rights->facture->lire;
|
||||
|
||||
print '<br>';
|
||||
print '<input type="hidden" name="option" value="'.$option.'">';
|
||||
// We disable multilang because we concat already existing pdf.
|
||||
$formfile->show_documents('unpaid','',$filedir,$urlsource,$genallowed,$delallowed,'',1,1,0,48,1,$param,$langs->trans("PDFMerge"),$langs->trans("PDFMerge"));
|
||||
if (empty($mode))
|
||||
{
|
||||
/*
|
||||
* Show list of available documents
|
||||
*/
|
||||
$filedir=$diroutputpdf;
|
||||
$genallowed=$user->rights->facture->lire;
|
||||
$delallowed=$user->rights->facture->lire;
|
||||
|
||||
print '<br>';
|
||||
print '<input type="hidden" name="option" value="'.$option.'">';
|
||||
// We disable multilang because we concat already existing pdf.
|
||||
$formfile->show_documents('unpaid','',$filedir,$urlsource,$genallowed,$delallowed,'',1,1,0,48,1,$param,$langs->trans("PDFMerge"),$langs->trans("PDFMerge"));
|
||||
}
|
||||
else
|
||||
{
|
||||
$langs->load("mails");
|
||||
|
||||
if ($action != 'presend')
|
||||
{
|
||||
print '<div class="tabsAction">';
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?mode=sendremind&action=presend" class="butAction" name="buttonsendremind" value="'.dol_escape_htmltag($langs->trans("SendRemind")).'">'.$langs->trans("SendRemind").'</a>';
|
||||
print '</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
|
||||
$formmail = new FormMail($db);
|
||||
|
||||
print '<br>';
|
||||
print_fiche_titre($langs->trans("SendRemind"),'','').'<br>';
|
||||
|
||||
$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 '<br><strong>'.$langs->trans("ResultOfMassSending").':</strong><br>'."\n";
|
||||
print $resultmasssend;
|
||||
print '<br>';
|
||||
}
|
||||
}
|
||||
|
||||
print '</form>';
|
||||
|
||||
$db->free($resql);
|
||||
|
||||
@ -503,39 +503,47 @@ class FormMail
|
||||
{
|
||||
$out.= '<tr>';
|
||||
$out.= '<td width="180">'.$langs->trans("MailFile").'</td>';
|
||||
|
||||
$out.= '<td>';
|
||||
// TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript
|
||||
$out.= '<input type="hidden" class="removedfilehidden" name="removedfile" value="">'."\n";
|
||||
$out.= '<script type="text/javascript" language="javascript">';
|
||||
$out.= 'jQuery(document).ready(function () {';
|
||||
$out.= ' jQuery(".removedfile").click(function() {';
|
||||
$out.= ' jQuery(".removedfilehidden").val(jQuery(this).val());';
|
||||
$out.= ' });';
|
||||
$out.= '})';
|
||||
$out.= '</script>'."\n";
|
||||
if (count($listofpaths))
|
||||
if (is_numeric($this->withfile))
|
||||
{
|
||||
foreach($listofpaths as $key => $val)
|
||||
{
|
||||
$out.= '<div id="attachfile_'.$key.'">';
|
||||
$out.= img_mime($listofnames[$key]).' '.$listofnames[$key];
|
||||
if (! $this->withfilereadonly)
|
||||
{
|
||||
$out.= ' <input type="image" style="border: 0px;" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/delete.png" value="'.($key+1).'" class="removedfile" id="removedfile_'.$key.'" name="removedfile_'.$key.'" />';
|
||||
//$out.= ' <a href="'.$_SERVER["PHP_SELF"].'?removedfile='.($key+1).' id="removedfile_'.$key.'">'.img_delete($langs->trans("Delete").'</a>';
|
||||
}
|
||||
$out.= '<br></div>';
|
||||
}
|
||||
// TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript
|
||||
$out.= '<input type="hidden" class="removedfilehidden" name="removedfile" value="">'."\n";
|
||||
$out.= '<script type="text/javascript" language="javascript">';
|
||||
$out.= 'jQuery(document).ready(function () {';
|
||||
$out.= ' jQuery(".removedfile").click(function() {';
|
||||
$out.= ' jQuery(".removedfilehidden").val(jQuery(this).val());';
|
||||
$out.= ' });';
|
||||
$out.= '})';
|
||||
$out.= '</script>'."\n";
|
||||
if (count($listofpaths))
|
||||
{
|
||||
foreach($listofpaths as $key => $val)
|
||||
{
|
||||
$out.= '<div id="attachfile_'.$key.'">';
|
||||
$out.= img_mime($listofnames[$key]).' '.$listofnames[$key];
|
||||
if (! $this->withfilereadonly)
|
||||
{
|
||||
$out.= ' <input type="image" style="border: 0px;" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/delete.png" value="'.($key+1).'" class="removedfile" id="removedfile_'.$key.'" name="removedfile_'.$key.'" />';
|
||||
//$out.= ' <a href="'.$_SERVER["PHP_SELF"].'?removedfile='.($key+1).' id="removedfile_'.$key.'">'.img_delete($langs->trans("Delete").'</a>';
|
||||
}
|
||||
$out.= '<br></div>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$out.= $langs->trans("NoAttachedFiles").'<br>';
|
||||
}
|
||||
if ($this->withfile == 2) // Can add other files
|
||||
{
|
||||
$out.= '<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans("Upload").'" />';
|
||||
$out.= ' ';
|
||||
$out.= '<input type="submit" class="button" id="'.$addfileaction.'" name="'.$addfileaction.'" value="'.$langs->trans("MailingAddFile").'" />';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$out.= $langs->trans("NoAttachedFiles").'<br>';
|
||||
}
|
||||
if ($this->withfile == 2) // Can add other files
|
||||
{
|
||||
$out.= '<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans("Upload").'" />';
|
||||
$out.= ' ';
|
||||
$out.= '<input type="submit" class="button" id="'.$addfileaction.'" name="'.$addfileaction.'" value="'.$langs->trans("MailingAddFile").'" />';
|
||||
$out.=$this->withfile;
|
||||
}
|
||||
$out.= "</td></tr>\n";
|
||||
}
|
||||
|
||||
@ -1542,7 +1542,7 @@ else if ($id || $ref)
|
||||
}
|
||||
|
||||
// Show form
|
||||
$formmail->show_form();
|
||||
print $formmail->get_form();
|
||||
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
@ -1709,7 +1709,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
$formmail->add_attached_files($file,basename($file),dol_mimetype($file));
|
||||
}
|
||||
|
||||
$formmail->show_form();
|
||||
print $formmail->get_form();
|
||||
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
@ -1634,13 +1634,13 @@ elseif (! empty($object->id))
|
||||
}
|
||||
|
||||
print '<td align="right" class="nowrap">'.price($line->total_ht).'</td>';
|
||||
|
||||
|
||||
if (is_object($hookmanager))
|
||||
{
|
||||
$parameters=array('line'=>$line,'num'=>$num,'i'=>$i);
|
||||
$reshook=$hookmanager->executeHooks('printObjectLine',$parameters,$object,$action);
|
||||
}
|
||||
|
||||
|
||||
if ($object->statut == 0 && $user->rights->fournisseur->commande->creer)
|
||||
{
|
||||
print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit_line&rowid='.$line->id.'#'.$line->id.'">';
|
||||
@ -2132,7 +2132,7 @@ elseif (! empty($object->id))
|
||||
}
|
||||
|
||||
// Show form
|
||||
$formmail->show_form();
|
||||
print $formmail->get_form();
|
||||
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
@ -1996,13 +1996,13 @@ else
|
||||
print '<td align="right" class="nowrap">'.price($object->lines[$i]->total_ht).'</td>';
|
||||
|
||||
print '<td align="right" class="nowrap">'.price($object->lines[$i]->total_ttc).'</td>';
|
||||
|
||||
|
||||
if (is_object($hookmanager))
|
||||
{
|
||||
$parameters=array('line'=>$object->lines[$i],'num'=>$num,'i'=>$i);
|
||||
$reshook=$hookmanager->executeHooks('printObjectLine',$parameters,$object,$action);
|
||||
}
|
||||
|
||||
|
||||
print '<td align="center" width="16">';
|
||||
if ($object->statut == 0) print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit_line&etat=0&lineid='.$object->lines[$i]->rowid.'">'.img_edit().'</a>';
|
||||
else print ' ';
|
||||
@ -2370,7 +2370,7 @@ else
|
||||
}
|
||||
|
||||
// Show form
|
||||
$formmail->show_form();
|
||||
print $formmail->get_form();
|
||||
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
@ -79,6 +79,10 @@ MailtoEMail=Hyper link to email
|
||||
ActivateCheckRead=Allow to use the "Unsubcribe" link
|
||||
ActivateCheckReadKey=Key use to encrypt URL use for "Read Receipt" and "Unsubcribe" feature
|
||||
EMailSentToNRecipients=EMail sent to %s recipients.
|
||||
EachInvoiceWillBeAttachedToEmail=A document using default invoice document template will be created and attached to each email.
|
||||
MailTopicSendRemindUnpaidInvoices=Remind of invoice %s (%s)
|
||||
SendRemind=Send remind by EMails
|
||||
RemindSent=%S remind(s) sent
|
||||
|
||||
# Libelle des modules de liste de destinataires mailing
|
||||
MailingModuleDescContactCompanies=Contacts/addresses of all third parties (customer, prospect, supplier, ...)
|
||||
|
||||
@ -1932,7 +1932,7 @@ else
|
||||
$formmail->add_attached_files($file,basename($file),dol_mimetype($file));
|
||||
}
|
||||
|
||||
$formmail->show_form();
|
||||
print $formmail->get_form();
|
||||
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user