Expense report - Remove DEPLACEMENT_TO_CLEAN

This commit is contained in:
aspangaro 2016-12-27 06:45:36 +01:00
parent 6e00d7fee3
commit c21300f0fa
2 changed files with 72 additions and 76 deletions

View File

@ -342,11 +342,11 @@ if (empty($reshook))
$filename=array(); $filedir=array(); $mimetype=array(); $filename=array(); $filedir=array(); $mimetype=array();
// SUBJECT // SUBJECT
$subject = $langs->trans("ExpenseReportWaitingForApproval"); $subject = $langs->transnoentities("ExpenseReportWaitingForApproval");
// CONTENT // CONTENT
$link = $urlwithroot.'/expensereport/card.php?id='.$object->id; $link = $urlwithroot.'/expensereport/card.php?id='.$object->id;
$message = $langs->trans("ExpenseReportWaitingForApprovalMessage", $expediteur->getFullName($langs), get_date_range($object->date_debut,$object->date_fin,'',$langs), $link); $message = $langs->transnoentities("ExpenseReportWaitingForApprovalMessage", $expediteur->getFullName($langs), get_date_range($object->date_debut,$object->date_fin,'',$langs), $link);
// Rebuild pdf // Rebuild pdf
/* /*
@ -436,81 +436,75 @@ 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 // TO
$destinataire = new User($db);
$destinataire->fetch($object->fk_user_validator);
$emailTo = $destinataire->email;
// TO if ($emailTo)
$destinataire = new User($db); {
$destinataire->fetch($object->fk_user_validator); // FROM
$emailTo = $destinataire->email; $expediteur = new User($db);
$expediteur->fetch($object->fk_user_author);
$emailFrom = $expediteur->email;
// SUBJECT
$subject = $langs->transnoentities("ExpenseReportWaitingForReApproval");
if ($emailTo) // CONTENT
{ $link = $urlwithroot.'/expensereport/card.php?id='.$object->id;
// FROM $dateRefusEx = explode(" ",$object->date_refuse);
$expediteur = new User($db); $message = $langs->transnoentities("ExpenseReportWaitingForReApprovalMessage", $dateRefusEx[0], $object->detail_refuse, $expediteur->getFullName($langs), $langs), $link);
$expediteur->fetch($object->fk_user_author);
$emailFrom = $expediteur->email; // Rebuild pdf
/*
// SUBJECT $object->setDocModel($user,"");
$subject = "' ERP - Note de frais à re-approuver"; $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs);
// CONTENT if($resultPDF)
$dateRefusEx = explode(" ",$object->date_refuse); {
// ATTACHMENT
$message = "Bonjour {$destinataire->firstname},\n\n"; $filename=array(); $filedir=array(); $mimetype=array();
$message.= "Le {$dateRefusEx[0]} à {$dateRefusEx[1]} vous avez refusé d'approuver la note de frais \"{$object->ref}\". Vous aviez émis le motif suivant : {$object->detail_refuse}\n\n"; array_push($filename,dol_sanitizeFileName($object->ref).".pdf");
$message.= "L'auteur vient de modifier la note de frais, veuillez trouver la nouvelle version en pièce jointe.\n"; array_push($filedir,$conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref) . "/" . dol_sanitizeFileName($object->ref_number).".pdf");
$message.= "- Déclarant : {$expediteur->firstname} {$expediteur->lastname}\n"; array_push($mimetype,"application/pdf");
$message.= "- Période : du {$object->date_debut} au {$object->date_fin}\n"; }
$message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n"; */
$message.= "Bien cordialement,\n' SI";
// PREPARE SEND
// Génération du pdf avant attachement $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename);
$object->setDocModel($user,"");
$resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); if (! $mailfile->error)
{
if($resultPDF) // SEND
{ $result=$mailfile->sendfile();
// ATTACHMENT if ($result)
$filename=array(); $filedir=array(); $mimetype=array(); {
array_push($filename,dol_sanitizeFileName($object->ref).".pdf"); Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
array_push($filedir,$conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref) . "/" . dol_sanitizeFileName($object->ref_number).".pdf"); exit;
array_push($mimetype,"application/pdf"); }
else
// PREPARE SEND {
$mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); $mesg=$mailfile->error;
setEventMessages($mesg, null, 'errors');
if (! $mailfile->error) }
{ // END - Send mail
// SEND }
$result=$mailfile->sendfile(); else
if ($result) {
{ dol_print_error($db,$resultPDF);
Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit;
exit; }
} }
else }
{ }
$mesg=$mailfile->error; else
setEventMessages($mesg, null, 'errors'); {
} setEventMessages($object->error, $object->errors, 'errors');
// END - Send mail }
} }
else
{
dol_print_error($db,$resultPDF);
exit;
}
}
}
}
}
else
{
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)

View File

@ -21,7 +21,9 @@ ListToApprove=Waiting for approval
ExpensesArea=Expense reports area ExpensesArea=Expense reports area
ClassifyRefunded=Classify 'Refunded' ClassifyRefunded=Classify 'Refunded'
ExpenseReportWaitingForApproval=A new expense report has been submitted for approval ExpenseReportWaitingForApproval=A new expense report has been submitted for approval
ExpenseReportWaitingForApprovalMessage=A new expense report has been submitted and is waiting for approval.\n- User: %s\n- Period: %s\nClick here to validate: %s ExpenseReportWaitingForApprovalMessage=A new expense report has been submitted and is waiting for approval.\n - User: %s\n - Period: %s\nClick here to validate: %s
ExpenseReportWaitingForReApproval=An expense report has been submitted for re-approval
ExpenseReportWaitingForReApprovalMessage=An expense report has been submitted and is waiting for re-approval.\nThe %s, you refused to approve the expense report for this reason: %s.\nA new version has been proposed and waiting for your approval.\n - User: %s\n - Period: %s\nClick here to validate: %s
TripId=Id expense report TripId=Id expense report
AnyOtherInThisListCanValidate=Person to inform for validation. AnyOtherInThisListCanValidate=Person to inform for validation.
TripSociete=Information company TripSociete=Information company