Better template

This commit is contained in:
Laurent Destailleur 2018-03-16 19:03:16 +01:00
parent 2bbf738cb8
commit e323084cf8
2 changed files with 14 additions and 4 deletions

View File

@ -996,7 +996,7 @@ class FormMail extends Form
* @param string $type_template Get message for type=$type_template, type='all' also included.
* @param string $user Use template public or limited to this user
* @param Translate $outputlangs Output lang object
* @param int $id Id of template to find, or -1 for first found with lower position, or 0 for first found whatever is position
* @param int $id Id of template to find, or -1 for first found with position 0, or 0 for first found whatever is position or -2 for exact match with label (no aswer if not found)
* @param int $active 1=Only active template, 0=Only disabled, -1=All
* @param string $label Label of template
* @return ModelMail
@ -1005,6 +1005,12 @@ class FormMail extends Form
{
$ret = new ModelMail();
if ($id == -2 && empty($label))
{
$this->error = 'LabelIsMandatoryWhenIdIs-2';
return -1;
}
$sql = "SELECT label, topic, joinfiles, content, content_lines, lang";
$sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates';
$sql.= " WHERE (type_template='".$db->escape($type_template)."' OR type_template='all')";
@ -1034,8 +1040,11 @@ class FormMail extends Form
$ret->content_lines = $obj->content_lines;
$ret->joinfiles = $obj->joinfiles;
}
else // If there is no template at all
{
elseif($id == -2) {
// Not found with the provided label
return -1;
}
else { // If there is no template at all
$defaultmessage='';
if ($type_template=='facture_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendInvoice"); }
elseif ($type_template=='facture_relance') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendInvoiceReminder"); }

View File

@ -461,10 +461,11 @@ class MyObject extends CommonObject
/**
* Action executed by scheduler
* CAN BE A CRON TASK
* CAN BE A CRON TASK. In such a case, paramerts come from the schedule job setup field 'Parameters'
*
* @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK)
*/
//public function doScheduledJob($param1, $param2, ...)
public function doScheduledJob()
{
global $conf, $langs;