Work in progress
This commit is contained in:
parent
c21300f0fa
commit
8a24f2fc91
@ -476,35 +476,50 @@ if (empty($reshook))
|
|||||||
// PREPARE SEND
|
// PREPARE SEND
|
||||||
$mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename);
|
$mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename);
|
||||||
|
|
||||||
if (! $mailfile->error)
|
if ($mailfile)
|
||||||
{
|
{
|
||||||
// SEND
|
// SEND
|
||||||
$result=$mailfile->sendfile();
|
$result=$mailfile->sendfile();
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
|
$mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2));
|
||||||
|
setEventMessages($mesg, null, 'mesgs');
|
||||||
|
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$mesg=$mailfile->error;
|
$langs->load("other");
|
||||||
|
if ($mailfile->error)
|
||||||
|
{
|
||||||
|
$mesg='';
|
||||||
|
$mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo);
|
||||||
|
$mesg.='<br>'.$mailfile->error;
|
||||||
setEventMessages($mesg, null, 'errors');
|
setEventMessages($mesg, null, 'errors');
|
||||||
}
|
}
|
||||||
// END - Send mail
|
else
|
||||||
|
{
|
||||||
|
setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dol_print_error($db,$resultPDF);
|
setEventMessages($mailfile->error,$mailfile->errors,'errors');
|
||||||
exit;
|
$action='';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings');
|
||||||
|
$action='';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Approve
|
// Approve
|
||||||
if ($action == "confirm_approve" && GETPOST("confirm") == "yes" && $id > 0 && $user->rights->expensereport->approve)
|
if ($action == "confirm_approve" && GETPOST("confirm") == "yes" && $id > 0 && $user->rights->expensereport->approve)
|
||||||
@ -535,8 +550,6 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
|
||||||
if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition
|
|
||||||
{
|
{
|
||||||
// Send mail
|
// Send mail
|
||||||
|
|
||||||
@ -554,55 +567,67 @@ if (empty($reshook))
|
|||||||
$emailFrom = $expediteur->email;
|
$emailFrom = $expediteur->email;
|
||||||
|
|
||||||
// SUBJECT
|
// SUBJECT
|
||||||
$subject = "' ERP - Note de frais validée";
|
$subject = $langs->transnoentities("ExpenseReportApproval");
|
||||||
|
|
||||||
// CONTENT
|
// CONTENT
|
||||||
$message = "Bonjour {$destinataire->firstname},\n\n";
|
$link = $urlwithroot.'/expensereport/card.php?id='.$object->id;
|
||||||
$message.= "Votre note de frais \"{$object->ref}\" vient d'être approuvé!\n";
|
$message = $langs->transnoentities("ExpenseReportApprovalMessage", $destinataire->getFullName($langs), $object->ref, $expediteur->getFullName($langs), '', $langs), $link);
|
||||||
$message.= "- Approbateur : {$expediteur->firstname} {$expediteur->lastname}\n";
|
|
||||||
$message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n";
|
|
||||||
$message.= "Bien cordialement,\n' SI";
|
|
||||||
|
|
||||||
// Génération du pdf avant attachement
|
// Rebuilt pdf
|
||||||
|
/*
|
||||||
$object->setDocModel($user,"");
|
$object->setDocModel($user,"");
|
||||||
$resultPDF = expensereport_pdf_create($db,$object,'',"",$langs);
|
$resultPDF = expensereport_pdf_create($db,$object,'',"",$langs);
|
||||||
|
|
||||||
if($resultPDF):
|
if($resultPDF
|
||||||
|
{
|
||||||
// ATTACHMENT
|
// ATTACHMENT
|
||||||
$filename=array(); $filedir=array(); $mimetype=array();
|
$filename=array(); $filedir=array(); $mimetype=array();
|
||||||
array_push($filename,dol_sanitizeFileName($object->ref).".pdf");
|
array_push($filename,dol_sanitizeFileName($object->ref).".pdf");
|
||||||
array_push($filedir, $conf->expensereport->dir_output.
|
array_push($filedir, $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref)."/".dol_sanitizeFileName($object->ref).".pdf");
|
||||||
"/".
|
|
||||||
dol_sanitizeFileName($object->ref) .
|
|
||||||
"/".
|
|
||||||
dol_sanitizeFileName($object->ref).
|
|
||||||
".pdf"
|
|
||||||
);
|
|
||||||
array_push($mimetype,"application/pdf");
|
array_push($mimetype,"application/pdf");
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// PREPARE SEND
|
// PREPARE SEND
|
||||||
$mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename,$emailCC);
|
$mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename);
|
||||||
|
|
||||||
if(!$mailfile->error):
|
|
||||||
|
|
||||||
|
if ($mailfile)
|
||||||
|
{
|
||||||
// SEND
|
// SEND
|
||||||
$result=$mailfile->sendfile();
|
$result=$mailfile->sendfile();
|
||||||
if ($result):
|
if ($result)
|
||||||
setEventMessages($langs->trans("MailSuccessfulySent",$emailFrom,$emailTo), null, 'mesgs');
|
{
|
||||||
Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
|
$mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2));
|
||||||
|
setEventMessages($mesg, null, 'mesgs');
|
||||||
|
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
|
||||||
exit;
|
exit;
|
||||||
else:
|
}
|
||||||
setEventMessages($langs->trans("ErrorFailedToSendMail",$emailFrom,$emailTo), null, 'errors');
|
else
|
||||||
endif;
|
{
|
||||||
|
$langs->load("other");
|
||||||
else:
|
if ($mailfile->error)
|
||||||
setEventMessages($langs->trans("ErrorFailedToSendMail",$emailFrom,$emailTo), null, 'errors');
|
{
|
||||||
endif;
|
$mesg='';
|
||||||
// END - Send mail
|
$mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo);
|
||||||
else : // if ($resultPDF)
|
$mesg.='<br>'.$mailfile->error;
|
||||||
dol_print_error($db,$resultPDF);
|
setEventMessages($mesg, null, 'errors');
|
||||||
exit;
|
}
|
||||||
endif;
|
else
|
||||||
|
{
|
||||||
|
setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setEventMessages($mailfile->error,$mailfile->errors,'errors');
|
||||||
|
$action='';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings');
|
||||||
|
$action='';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -639,8 +664,6 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
|
||||||
if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition
|
|
||||||
{
|
{
|
||||||
// Send mail
|
// Send mail
|
||||||
|
|
||||||
@ -666,31 +689,51 @@ if (empty($reshook))
|
|||||||
$message.= "Bien cordialement,\n' SI";
|
$message.= "Bien cordialement,\n' SI";
|
||||||
|
|
||||||
// PREPARE SEND
|
// PREPARE SEND
|
||||||
$mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message);
|
$mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename);
|
||||||
|
|
||||||
if(!$mailfile->error)
|
if ($mailfile)
|
||||||
{
|
{
|
||||||
// SEND
|
// SEND
|
||||||
$result=$mailfile->sendfile();
|
$result=$mailfile->sendfile();
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
setEventMessages($langs->trans("MailSuccessfulySent",$emailFrom,$emailTo), null, 'mesgs');
|
$mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2));
|
||||||
Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
|
setEventMessages($mesg, null, 'mesgs');
|
||||||
|
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setEventMessages($langs->trans("ErrorFailedToSendMail",$emailFrom,$emailTo), null, 'errors');
|
$langs->load("other");
|
||||||
|
if ($mailfile->error)
|
||||||
|
{
|
||||||
|
$mesg='';
|
||||||
|
$mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo);
|
||||||
|
$mesg.='<br>'.$mailfile->error;
|
||||||
|
setEventMessages($mesg, null, 'errors');
|
||||||
}
|
}
|
||||||
// END - Send mail
|
else
|
||||||
|
{
|
||||||
|
setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
setEventMessages($mailfile->error,$mailfile->errors,'errors');
|
||||||
|
$action='';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings');
|
||||||
|
$action='';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//var_dump($user->id == $object->fk_user_validator);exit;
|
//var_dump($user->id == $object->fk_user_validator);exit;
|
||||||
if ($action == "confirm_cancel" && GETPOST('confirm')=="yes" && GETPOST('detail_cancel') && $id > 0 && $user->rights->expensereport->creer)
|
if ($action == "confirm_cancel" && GETPOST('confirm')=="yes" && GETPOST('detail_cancel') && $id > 0 && $user->rights->expensereport->creer)
|
||||||
@ -723,8 +766,6 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
|
||||||
if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition
|
|
||||||
{
|
{
|
||||||
// Send mail
|
// Send mail
|
||||||
|
|
||||||
@ -750,40 +791,52 @@ if (empty($reshook))
|
|||||||
$message.= "Bien cordialement,\n' SI";
|
$message.= "Bien cordialement,\n' SI";
|
||||||
|
|
||||||
// PREPARE SEND
|
// PREPARE SEND
|
||||||
$mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message);
|
$mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename);
|
||||||
|
|
||||||
if(!$mailfile->error)
|
if ($mailfile)
|
||||||
{
|
{
|
||||||
// SEND
|
// SEND
|
||||||
$result=$mailfile->sendfile();
|
$result=$mailfile->sendfile();
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
|
$mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2));
|
||||||
|
setEventMessages($mesg, null, 'mesgs');
|
||||||
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
|
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$mesg="Impossible d'envoyer l'email.";
|
$langs->load("other");
|
||||||
|
if ($mailfile->error)
|
||||||
|
{
|
||||||
|
$mesg='';
|
||||||
|
$mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo);
|
||||||
|
$mesg.='<br>'.$mailfile->error;
|
||||||
setEventMessages($mesg, null, 'errors');
|
setEventMessages($mesg, null, 'errors');
|
||||||
}
|
}
|
||||||
// END - Send mail
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setEventMessages($mail->error, $mail->errors, 'errors');
|
setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
setEventMessages($mailfile->error,$mailfile->errors,'errors');
|
||||||
|
$action='';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings');
|
||||||
|
$action='';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
setEventMessages($langs->transnoentitiesnoconv("OnlyOwnerCanCancel"), '', 'errors'); // Should not happened
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($action == "confirm_brouillonner" && GETPOST('confirm')=="yes" && $id > 0 && $user->rights->expensereport->creer)
|
if ($action == "confirm_brouillonner" && GETPOST('confirm')=="yes" && $id > 0 && $user->rights->expensereport->creer)
|
||||||
{
|
{
|
||||||
@ -857,8 +910,6 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
|
||||||
if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition
|
|
||||||
{
|
{
|
||||||
// Send mail
|
// Send mail
|
||||||
|
|
||||||
@ -887,38 +938,51 @@ if (empty($reshook))
|
|||||||
$resultPDF = expensereport_pdf_create($db,$object,'',"",$langs);
|
$resultPDF = expensereport_pdf_create($db,$object,'',"",$langs);
|
||||||
|
|
||||||
// PREPARE SEND
|
// PREPARE SEND
|
||||||
$mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message);
|
$mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename);
|
||||||
|
|
||||||
if(!$mailfile->error):
|
|
||||||
|
|
||||||
|
if ($mailfile)
|
||||||
|
{
|
||||||
// SEND
|
// SEND
|
||||||
$result=$mailfile->sendfile();
|
$result=$mailfile->sendfile();
|
||||||
if ($result):
|
if ($result)
|
||||||
|
{
|
||||||
// Retour
|
$mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2));
|
||||||
if($result):
|
setEventMessages($mesg, null, 'mesgs');
|
||||||
Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
|
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
|
||||||
exit;
|
exit;
|
||||||
else:
|
}
|
||||||
dol_print_error($db);
|
else
|
||||||
endif;
|
{
|
||||||
|
$langs->load("other");
|
||||||
else:
|
if ($mailfile->error)
|
||||||
dol_print_error($db,$acct->error);
|
{
|
||||||
endif;
|
$mesg='';
|
||||||
|
$mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo);
|
||||||
else:
|
$mesg.='<br>'.$mailfile->error;
|
||||||
$mesg="Impossible d'envoyer l'email.";
|
|
||||||
setEventMessages($mesg, null, 'errors');
|
setEventMessages($mesg, null, 'errors');
|
||||||
endif;
|
}
|
||||||
// END - Send mail
|
else
|
||||||
|
{
|
||||||
|
setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setEventMessages($mailfile->error,$mailfile->errors,'errors');
|
||||||
|
$action='';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings');
|
||||||
|
$action='';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ($action == "addline" && $user->rights->expensereport->creer)
|
if ($action == "addline" && $user->rights->expensereport->creer)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user