Start to work on a mass send remind feature.

This commit is contained in:
Laurent Destailleur 2014-02-19 20:23:02 +01:00
parent 0b7f623c31
commit 6f962397e4
14 changed files with 348 additions and 85 deletions

View File

@ -132,7 +132,7 @@ if (! empty($_POST['removedfile']) || ! empty($_POST['removedfilehtml']))
if (($action == 'send' || $action == 'sendhtml') && ! GETPOST('addfile') && ! GETPOST('addfilehtml') && ! GETPOST('removedfile') && ! GETPOST('cancel')) if (($action == 'send' || $action == 'sendhtml') && ! GETPOST('addfile') && ! GETPOST('addfilehtml') && ! GETPOST('removedfile') && ! GETPOST('cancel'))
{ {
$error=0; $error=0;
$email_from=''; $email_from='';
if (! empty($_POST["fromname"])) $email_from=$_POST["fromname"].' '; if (! empty($_POST["fromname"])) $email_from=$_POST["fromname"].' ';
if (! empty($_POST["frommail"])) $email_from.='<'.$_POST["frommail"].'>'; if (! empty($_POST["frommail"])) $email_from.='<'.$_POST["frommail"].'>';
@ -144,12 +144,12 @@ if (($action == 'send' || $action == 'sendhtml') && ! GETPOST('addfile') && ! GE
$subject = $_POST['subject']; $subject = $_POST['subject'];
$body = $_POST['message']; $body = $_POST['message'];
$deliveryreceipt= $_POST["deliveryreceipt"]; $deliveryreceipt= $_POST["deliveryreceipt"];
//Check if we have to decode HTML //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))) { 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); $body=dol_html_entity_decode($body, ENT_COMPAT | ENT_HTML401);
} }
// Create form object // Create form object
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail = new FormMail($db); $formmail = new FormMail($db);
@ -693,7 +693,7 @@ else
$formmail->clear_attached_files(); $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>'; print '<br>';
} }

View File

@ -947,7 +947,7 @@ else
$formmail->param["mailid"]=$object->id; $formmail->param["mailid"]=$object->id;
$formmail->param["returnurl"]=$_SERVER['PHP_SELF']."?id=".$object->id; $formmail->param["returnurl"]=$_SERVER['PHP_SELF']."?id=".$object->id;
$formmail->show_form(); print $formmail->get_form();
print '<br>'; print '<br>';
} }

View File

@ -2149,14 +2149,14 @@ else
{ {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=modif">'.$langs->trans('Modify').'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=modif">'.$langs->trans('Modify').'</a></div>';
} }
// ReOpen // ReOpen
if (($object->statut == 2 || $object->statut == 3) && $user->rights->propal->cloturer) 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.'&amp;action=reopen'.(empty($conf->global->MAIN_JUMP_TAG)?'':'#reopen').'"'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen'.(empty($conf->global->MAIN_JUMP_TAG)?'':'#reopen').'"';
print '>'.$langs->trans('ReOpen').'</a></div>'; print '>'.$langs->trans('ReOpen').'</a></div>';
} }
// Send // Send
if ($object->statut == 1 || $object->statut == 2) 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>'; else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#">'.$langs->trans('SendByMail').'</a></div>';
} }
// Create an order // Create an order
if (! empty($conf->commande->enabled) && $object->statut == 2) 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&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("AddOrder").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/commande/fiche.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("AddOrder").'</a></div>';
} }
} }
// Create contract // Create contract
if ($conf->contrat->enabled && $object->statut == 2) if ($conf->contrat->enabled && $object->statut == 2)
{ {
$langs->load("contracts"); $langs->load("contracts");
if ($user->rights->contrat->creer) if ($user->rights->contrat->creer)
{ {
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/contrat/fiche.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans('AddContract').'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/contrat/fiche.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans('AddContract').'</a></div>';
} }
} }
// Create an invoice and classify billed // Create an invoice and classify billed
if ($object->statut == 2) 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&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("AddBill").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("AddBill").'</a></div>';
} }
$arraypropal=$object->getInvoiceArrayList(); $arraypropal=$object->getInvoiceArrayList();
if (is_array($arraypropal) && count($arraypropal) > 0) if (is_array($arraypropal) && count($arraypropal) > 0)
{ {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifybilled&amp;socid='.$object->socid.'">'.$langs->trans("ClassifyBilled").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifybilled&amp;socid='.$object->socid.'">'.$langs->trans("ClassifyBilled").'</a></div>';
} }
} }
// Close // Close
if ($object->statut == 1 && $user->rights->propal->cloturer) if ($object->statut == 1 && $user->rights->propal->cloturer)
{ {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=statut'.(empty($conf->global->MAIN_JUMP_TAG)?'':'#close').'"'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=statut'.(empty($conf->global->MAIN_JUMP_TAG)?'':'#close').'"';
print '>'.$langs->trans('Close').'</a></div>'; print '>'.$langs->trans('Close').'</a></div>';
} }
// Clone // Clone
if ($user->rights->propal->creer) if ($user->rights->propal->creer)
{ {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;socid='.$object->socid.'&amp;action=clone&amp;object='.$object->element.'">'.$langs->trans("ToClone").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;socid='.$object->socid.'&amp;action=clone&amp;object='.$object->element.'">'.$langs->trans("ToClone").'</a></div>';
} }
// Delete // Delete
if ($user->rights->propal->supprimer) if ($user->rights->propal->supprimer)
{ {
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete"'; print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete"';
print '>'.$langs->trans('Delete').'</a></div>'; print '>'.$langs->trans('Delete').'</a></div>';
} }
} }
} }
print '</div>'; print '</div>';
} }
print "<br>\n"; print "<br>\n";
@ -2374,7 +2374,7 @@ else
$formmail->add_attached_files($file,basename($file),dol_mimetype($file)); $formmail->add_attached_files($file,basename($file),dol_mimetype($file));
} }
$formmail->show_form(); print $formmail->get_form();
print '<br>'; print '<br>';
} }

View File

@ -2676,7 +2676,7 @@ else
} }
// Show form // Show form
$formmail->show_form(); print $formmail->get_form();
print '<br>'; print '<br>';
} }

View File

@ -3914,8 +3914,8 @@ else if ($id > 0 || ! empty($ref))
{ {
$liste[$key]=$value; $liste[$key]=$value;
} }
$formmail->withto=GETPOST('sendto')?GETPOST('sendto'):$liste; $formmail->withto=GETPOST('sendto')?GETPOST('sendto'):$liste; // List suggested for send to
$formmail->withtocc=$liste; $formmail->withtocc=$liste; // List suggested for CC
$formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC;
if(empty($object->ref_client)) 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->add_attached_files($file,basename($file),dol_mimetype($file));
} }
$formmail->show_form(); print $formmail->get_form();
print '<br>'; print '<br>';
} }

View File

@ -90,7 +90,7 @@ class Facture extends CommonInvoice
var $close_code; var $close_code;
//! Commentaire si mis a paye sans paiement complet //! Commentaire si mis a paye sans paiement complet
var $close_note; 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; var $paye;
//! id of source invoice if replacement invoice or credit note //! id of source invoice if replacement invoice or credit note
var $fk_facture_source; var $fk_facture_source;

View File

@ -37,6 +37,7 @@ $langs->load("bills");
$id = (GETPOST('facid','int') ? GETPOST('facid','int') : GETPOST('id','int')); $id = (GETPOST('facid','int') ? GETPOST('facid','int') : GETPOST('id','int'));
$action = GETPOST('action','alpha'); $action = GETPOST('action','alpha');
$option = GETPOST('option'); $option = GETPOST('option');
$mode=GETPOST('mode');
// Security check // Security check
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
@ -45,11 +46,157 @@ $result = restrictedArea($user,'facture',$id,'');
$diroutputpdf=$conf->facture->dir_output . '/unpaid/temp'; $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 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 * 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 ($action == "builddoc" && $user->rights->facture->lire && ! GETPOST('button_search'))
{ {
if (is_array($_POST['toGenerate'])) if (is_array($_POST['toGenerate']))
@ -61,9 +208,12 @@ if ($action == "builddoc" && $user->rights->facture->lire && ! GETPOST('button_s
// liste les fichiers // liste les fichiers
$files = array(); $files = array();
$factures_bak = $factures ; $factures_bak = $factures ;
foreach($_POST['toGenerate'] as $basename){ foreach($_POST['toGenerate'] as $basename)
foreach($factures as $facture){ {
if(strstr($facture["name"],$basename)){ foreach($factures as $facture)
{
if(strstr($facture["name"],$basename))
{
$files[] = $conf->facture->dir_output.'/'.$basename.'/'.$facture["name"]; $files[] = $conf->facture->dir_output.'/'.$basename.'/'.$facture["name"];
} }
} }
@ -121,12 +271,12 @@ if ($action == "builddoc" && $user->rights->facture->lire && ! GETPOST('button_s
} }
else else
{ {
$mesg='<div class="error">'.$langs->trans('NoPDFAvailableForChecked').'</div>'; setEventMessage($langs->trans('NoPDFAvailableForChecked'),'errors');
} }
} }
else else
{ {
$mesg='<div class="error">'.$langs->trans('InvoiceNotChecked').'</div>' ; setEventMessage($langs->trans('InvoiceNotChecked'), 'warnings');
} }
} }
@ -167,6 +317,12 @@ $(document).ready(function() {
$("#checknone").click(function() { $("#checknone").click(function() {
$(".checkformerge").attr('checked', false); $(".checkformerge").attr('checked', false);
}); });
$("#checkallsend").click(function() {
$(".checkforsend").attr('checked', true);
});
$("#checknonesend").click(function() {
$(".checkforsend").attr('checked', false);
});
}); });
</script> </script>
<?php <?php
@ -268,6 +424,7 @@ if ($resql)
print '<form id="form_generate_pdf" method="POST" action="'.$_SERVER["PHP_SELF"].'?sortfield='. $sortfield .'&sortorder='. $sortorder .'">'; 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="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).'">'; if ($late) print '<input type="hidden" name="late" value="'.dol_escape_htmltag($late).'">';
$i = 0; $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("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("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("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"; print "</tr>\n";
// Lignes des champs de filtre // Lignes des champs de filtre
@ -302,9 +466,18 @@ if ($resql)
print '<td class="liste_titre" align="right">'; 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 '<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>';
print '<td class="liste_titre" align="center">'; if (empty($mode))
if ($conf->use_javascript_ajax) print '<a href="#" id="checkall">'.$langs->trans("All").'</a> / <a href="#" id="checknone">'.$langs->trans("None").'</a>'; {
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>';
}
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"; print "</tr>\n";
if ($num > 0) if ($num > 0)
@ -384,13 +557,23 @@ if ($resql)
print $facturestatic->LibStatut($objp->paye,$objp->fk_statut,5,$objp->am); print $facturestatic->LibStatut($objp->paye,$objp->fk_statut,5,$objp->am);
print '</td>'; print '</td>';
// Checkbox if (empty($mode))
print '<td align="center">'; {
if (! empty($formfile->numoffiles)) // Checkbox to merge
print '<input id="cb'.$objp->facid.'" class="flat checkformerge" type="checkbox" name="toGenerate[]" value="'.$objp->facnumber.'">'; 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 '&nbsp;';
print '</td>' ;
}
else else
print '&nbsp;'; {
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"; print "</tr>\n";
$total_ht+=$objp->total_ht; $total_ht+=$objp->total_ht;
@ -415,17 +598,85 @@ if ($resql)
print "</table>"; print "</table>";
/*
* Show list of available documents
*/
$filedir=$diroutputpdf;
$genallowed=$user->rights->facture->lire;
$delallowed=$user->rights->facture->lire;
print '<br>'; if (empty($mode))
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")); * 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>'; print '</form>';
$db->free($resql); $db->free($resql);

View File

@ -503,39 +503,47 @@ class FormMail
{ {
$out.= '<tr>'; $out.= '<tr>';
$out.= '<td width="180">'.$langs->trans("MailFile").'</td>'; $out.= '<td width="180">'.$langs->trans("MailFile").'</td>';
$out.= '<td>'; $out.= '<td>';
// TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript if (is_numeric($this->withfile))
$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) // 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.= '<div id="attachfile_'.$key.'">'; $out.= '<script type="text/javascript" language="javascript">';
$out.= img_mime($listofnames[$key]).' '.$listofnames[$key]; $out.= 'jQuery(document).ready(function () {';
if (! $this->withfilereadonly) $out.= ' jQuery(".removedfile").click(function() {';
{ $out.= ' jQuery(".removedfilehidden").val(jQuery(this).val());';
$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.= ' });';
//$out.= ' <a href="'.$_SERVER["PHP_SELF"].'?removedfile='.($key+1).' id="removedfile_'.$key.'">'.img_delete($langs->trans("Delete").'</a>'; $out.= '})';
} $out.= '</script>'."\n";
$out.= '<br></div>'; 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 else
{ {
$out.= $langs->trans("NoAttachedFiles").'<br>'; $out.=$this->withfile;
}
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.= "</td></tr>\n"; $out.= "</td></tr>\n";
} }

View File

@ -1542,7 +1542,7 @@ else if ($id || $ref)
} }
// Show form // Show form
$formmail->show_form(); print $formmail->get_form();
print '<br>'; print '<br>';
} }

View File

@ -1709,7 +1709,7 @@ else if ($id > 0 || ! empty($ref))
$formmail->add_attached_files($file,basename($file),dol_mimetype($file)); $formmail->add_attached_files($file,basename($file),dol_mimetype($file));
} }
$formmail->show_form(); print $formmail->get_form();
print '<br>'; print '<br>';
} }

View File

@ -1634,13 +1634,13 @@ elseif (! empty($object->id))
} }
print '<td align="right" class="nowrap">'.price($line->total_ht).'</td>'; print '<td align="right" class="nowrap">'.price($line->total_ht).'</td>';
if (is_object($hookmanager)) if (is_object($hookmanager))
{ {
$parameters=array('line'=>$line,'num'=>$num,'i'=>$i); $parameters=array('line'=>$line,'num'=>$num,'i'=>$i);
$reshook=$hookmanager->executeHooks('printObjectLine',$parameters,$object,$action); $reshook=$hookmanager->executeHooks('printObjectLine',$parameters,$object,$action);
} }
if ($object->statut == 0 && $user->rights->fournisseur->commande->creer) if ($object->statut == 0 && $user->rights->fournisseur->commande->creer)
{ {
print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit_line&amp;rowid='.$line->id.'#'.$line->id.'">'; print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit_line&amp;rowid='.$line->id.'#'.$line->id.'">';
@ -2132,7 +2132,7 @@ elseif (! empty($object->id))
} }
// Show form // Show form
$formmail->show_form(); print $formmail->get_form();
print '<br>'; print '<br>';
} }

View File

@ -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_ht).'</td>';
print '<td align="right" class="nowrap">'.price($object->lines[$i]->total_ttc).'</td>'; print '<td align="right" class="nowrap">'.price($object->lines[$i]->total_ttc).'</td>';
if (is_object($hookmanager)) if (is_object($hookmanager))
{ {
$parameters=array('line'=>$object->lines[$i],'num'=>$num,'i'=>$i); $parameters=array('line'=>$object->lines[$i],'num'=>$num,'i'=>$i);
$reshook=$hookmanager->executeHooks('printObjectLine',$parameters,$object,$action); $reshook=$hookmanager->executeHooks('printObjectLine',$parameters,$object,$action);
} }
print '<td align="center" width="16">'; print '<td align="center" width="16">';
if ($object->statut == 0) print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit_line&amp;etat=0&amp;lineid='.$object->lines[$i]->rowid.'">'.img_edit().'</a>'; if ($object->statut == 0) print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit_line&amp;etat=0&amp;lineid='.$object->lines[$i]->rowid.'">'.img_edit().'</a>';
else print '&nbsp;'; else print '&nbsp;';
@ -2370,7 +2370,7 @@ else
} }
// Show form // Show form
$formmail->show_form(); print $formmail->get_form();
print '<br>'; print '<br>';
} }

View File

@ -79,6 +79,10 @@ MailtoEMail=Hyper link to email
ActivateCheckRead=Allow to use the "Unsubcribe" link ActivateCheckRead=Allow to use the "Unsubcribe" link
ActivateCheckReadKey=Key use to encrypt URL use for "Read Receipt" and "Unsubcribe" feature ActivateCheckReadKey=Key use to encrypt URL use for "Read Receipt" and "Unsubcribe" feature
EMailSentToNRecipients=EMail sent to %s recipients. 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 # Libelle des modules de liste de destinataires mailing
MailingModuleDescContactCompanies=Contacts/addresses of all third parties (customer, prospect, supplier, ...) MailingModuleDescContactCompanies=Contacts/addresses of all third parties (customer, prospect, supplier, ...)

View File

@ -1932,7 +1932,7 @@ else
$formmail->add_attached_files($file,basename($file),dol_mimetype($file)); $formmail->add_attached_files($file,basename($file),dol_mimetype($file));
} }
$formmail->show_form(); print $formmail->get_form();
print '<br>'; print '<br>';
} }