diff --git a/htdocs/accountancy/class/accountancyimport.class.php b/htdocs/accountancy/class/accountancyimport.class.php index 2821478a5b3..0583e0d3b5f 100644 --- a/htdocs/accountancy/class/accountancyimport.class.php +++ b/htdocs/accountancy/class/accountancyimport.class.php @@ -93,10 +93,9 @@ class AccountancyImport public function computeAmount(&$arrayrecord, $listfields, $record_key) { // get fields indexes - $field_index_list = array_flip($listfields); - if (isset($field_index_list['debit']) && isset($field_index_list['credit'])) { - $debit_index = $field_index_list['debit']; - $credit_index = $field_index_list['credit']; + if (isset($listfields['b.debit']) && isset($listfields['b.credit'])) { + $debit_index = $listfields['b.debit']; + $credit_index = $listfields['b.credit']; $debit = (float) $arrayrecord[$debit_index]['val']; $credit = (float) $arrayrecord[$credit_index]['val']; @@ -123,9 +122,8 @@ class AccountancyImport */ public function computeDirection(&$arrayrecord, $listfields, $record_key) { - $field_index_list = array_flip($listfields); - if (isset($field_index_list['debit'])) { - $debit_index = $field_index_list['debit']; + if (isset($listfields['b.debit'])) { + $debit_index = $listfields['b.debit']; $debit = (float) $arrayrecord[$debit_index]['val']; if (!empty($debit)) { diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 1e0e14dbbc4..7f00e98c4f9 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -467,6 +467,7 @@ if (empty($reshook)) { $action = 'view'; } else { + $error++; setEventMessages($object->error, $object->errors, 'errors'); $action = 'edit'; } diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index c4b0a371726..de5fcffcd02 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -1186,12 +1186,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/fourn/facture/card.php b/htdocs/fourn/facture/card.php index d75082f475b..b39587232e8 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1533,7 +1533,7 @@ if (empty($reshook)) { $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } - } elseif ($action == 'addline' && GETPOST('submitforalllines', 'aZ09') && GETPOST('vatforalllines', 'alpha') && $usercancreate) { + } elseif ($action == 'addline' && GETPOST('submitforalllines', 'aZ09') && GETPOST('vatforalllines', 'alpha') != '' && $usercancreate) { // Define vat_rate $vat_rate = (GETPOST('vatforalllines') ? GETPOST('vatforalllines') : 0); $vat_rate = str_replace('*', '', $vat_rate); diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php index e87b37cbac7..59ac708cad1 100644 --- a/htdocs/holiday/month_report.php +++ b/htdocs/holiday/month_report.php @@ -39,7 +39,7 @@ $action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; $massaction = GETPOST('massaction', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ'); $optioncss = GETPOST('optioncss', 'aZ'); -$socid = 0; + $id = GETPOSTINT('id'); $search_ref = GETPOST('search_ref', 'alphanohtml'); @@ -73,7 +73,7 @@ if ($user->socid > 0) { // Protection if external user //$socid = $user->socid; accessforbidden(); } -$result = restrictedArea($user, 'holiday', $id, ''); +$result = restrictedArea($user, 'holiday', $id, '', 'readall'); /* diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 8bb071ef00c..7ebcc51ea89 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -273,6 +273,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); @@ -287,6 +288,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(); @@ -498,6 +500,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(); @@ -907,6 +910,8 @@ class Task extends CommonObjectLine */ public function initAsSpecimen() { + global $user; + $this->id = 0; $this->fk_project = 0; @@ -914,10 +919,12 @@ class Task extends CommonObjectLine $this->fk_task_parent = 0; $this->label = 'Specimen task TK01'; $this->duration_effective = ''; - $this->fk_user_creat = 1; + $this->fk_user_creat = $user->id; $this->progress = '25'; $this->status = 0; - $this->note = 'This is a specimen task not'; + $this->priority = 0; + $this->note_private = 'This is a specimen private note'; + $this->note_public = 'This is a specimen public note'; return 1; } @@ -960,7 +967,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,"; @@ -1075,7 +1082,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,"; @@ -1161,6 +1168,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; @@ -2079,6 +2087,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) {