diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 01e7919e7a5..31495f17a48 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -857,12 +857,36 @@ class Notify $mimefilename_list[] = $ref.".pdf"; } - $message = ''; - $message .= $langs->transnoentities("YouReceiveMailBecauseOfNotification2", $application, $mysoc->name)."\n"; - $message .= "\n"; - $message .= $mesg; + // if an e-mail template is configured for this notification code (for instance + // 'SHIPPING_VALIDATE_TEMPLATE'), we fetch this template by its label. Otherwise, a default message + // content will be sent. + $mailTemplateLabel = isset($conf->global->{$notifcode.'_TEMPLATE'}) ? $conf->global->{$notifcode.'_TEMPLATE'} : ''; + $emailTemplate = null; + if (!empty($mailTemplateLabel)) { + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $formmail = new FormMail($this->db); + $emailTemplate = $formmail->getEMailTemplate($this->db, $object_type.'_send', $user, $outputlangs, 0, 1, $labeltouse); + } + if (!empty($mailTemplateLabel) && is_object($emailTemplate) && $emailTemplate->id > 0) { + // Set output language + $outputlangs = $langs; + if ($obj->default_lang && $obj->default_lang != $langs->defaultlang) { + $outputlangs = new Translate('', $conf); + $outputlangs->setDefaultLang($obj->default_lang); + $outputlangs->loadLangs(array('main', 'other')); + } + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + $subject = make_substitutions($emailTemplate->topic, $substitutionarray, $outputlangs); + $message = make_substitutions($emailTemplate->content, $substitutionarray, $outputlangs); + } else { + $message = ''; + $message .= $langs->transnoentities("YouReceiveMailBecauseOfNotification2", $application, $mysoc->name)."\n"; + $message .= "\n"; + $message .= $mesg; - $message = nl2br($message); + $message = nl2br($message); + } // Replace keyword __SUPERVISOREMAIL__ if (preg_match('/__SUPERVISOREMAIL__/', $sendto)) { diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 20364d30a0e..6226c430a19 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -198,6 +198,7 @@ class Task extends CommonObjectLine $sql .= ", planned_workload"; $sql .= ", progress"; $sql .= ", budget_amount"; + $sql .= ", priority"; $sql .= ") VALUES ("; $sql .= (!empty($this->entity) ? (int) $this->entity : (int) $conf->entity); $sql .= ", ".((int) $this->fk_project); @@ -212,6 +213,7 @@ class Task extends CommonObjectLine $sql .= ", ".(($this->planned_workload != '' && $this->planned_workload >= 0) ? ((int) $this->planned_workload) : 'null'); $sql .= ", ".(($this->progress != '' && $this->progress >= 0) ? ((int) $this->progress) : 'null'); $sql .= ", ".(($this->budget_amount != '' && $this->budget_amount >= 0) ? ((int) $this->budget_amount) : 'null'); + $sql .= ", ".(($this->priority != '' && $this->priority >= 0) ? (int) $this->priority : 'null'); $sql .= ")"; $this->db->begin(); @@ -423,6 +425,7 @@ class Task extends CommonObjectLine $sql .= " progress=".(($this->progress != '' && $this->progress >= 0) ? $this->progress : 'null').","; $sql .= " budget_amount=".(($this->budget_amount != '' && $this->budget_amount >= 0) ? $this->budget_amount : 'null').","; $sql .= " rang=".((!empty($this->rang)) ? $this->rang : "0"); + $sql .= " priority=".((!empty($this->priority)) ? $this->priority : "0"); $sql .= " WHERE rowid=".((int) $this->id); $this->db->begin(); @@ -791,6 +794,7 @@ class Task extends CommonObjectLine $this->duration_effective = ''; $this->fk_user_creat = null; $this->progress = '25'; + $this->priority = 0; $this->fk_statut = null; $this->note = 'This is a specimen task not'; } @@ -833,7 +837,7 @@ class Task extends CommonObjectLine } $sql .= " p.rowid as projectid, p.ref, p.title as plabel, p.public, p.fk_statut as projectstatus, p.usage_bill_time,"; $sql .= " t.rowid as taskid, t.ref as taskref, t.label, t.description, t.fk_task_parent, t.duration_effective, t.progress, t.fk_statut as status,"; - $sql .= " t.dateo as date_start, t.datee as date_end, t.planned_workload, t.rang,"; + $sql .= " t.dateo as date_start, t.datee as date_end, t.planned_workload, t.rang, t.priority,"; $sql .= " t.description, "; $sql .= " t.budget_amount, "; $sql .= " s.rowid as thirdparty_id, s.nom as thirdparty_name, s.email as thirdparty_email,"; @@ -941,7 +945,7 @@ class Task extends CommonObjectLine $sql .= " GROUP BY p.rowid, p.ref, p.title, p.public, p.fk_statut, p.usage_bill_time,"; $sql .= " t.datec, t.dateo, t.datee, t.tms,"; $sql .= " t.rowid, t.ref, t.label, t.description, t.fk_task_parent, t.duration_effective, t.progress, t.fk_statut,"; - $sql .= " t.dateo, t.datee, t.planned_workload, t.rang,"; + $sql .= " t.dateo, t.datee, t.planned_workload, t.rang, t.priority,"; $sql .= " t.description, "; $sql .= " t.budget_amount, "; $sql .= " s.rowid, s.nom, s.email,"; @@ -1023,6 +1027,7 @@ class Task extends CommonObjectLine $tasks[$i]->date_start = $this->db->jdate($obj->date_start); $tasks[$i]->date_end = $this->db->jdate($obj->date_end); $tasks[$i]->rang = $obj->rang; + $tasks[$i]->priority = $obj->priority; $tasks[$i]->socid = $obj->thirdparty_id; // For backward compatibility $tasks[$i]->thirdparty_id = $obj->thirdparty_id; @@ -1903,6 +1908,7 @@ class Task extends CommonObjectLine $clone_task->date_c = $datec; $clone_task->planned_workload = $origin_task->planned_workload; $clone_task->rang = $origin_task->rang; + $clone_task->priority = $origin_task->priority; //Manage Task Date if ($clone_change_dt) {