From 4a3083a4c12aecb64f906c8e1adbb8c57f26e22f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Mon, 16 May 2016 19:34:24 +0200 Subject: [PATCH] FIX Remove PHP Warning: Creating default object from empty value. --- htdocs/expensereport/card.php | 45 +++++++++-------------------------- 1 file changed, 11 insertions(+), 34 deletions(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 54a67cc6ffc..f3174935cd5 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -333,7 +333,7 @@ if ($action == "confirm_save_from_refuse" && GETPOST("confirm") == "yes" && $id if ($result > 0) { - if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) + if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition { // Send mail @@ -390,6 +390,7 @@ if ($action == "confirm_save_from_refuse" && GETPOST("confirm") == "yes" && $id else { $mesg=$mailfile->error; + setEventMessages($mesg, null, 'errors'); } // END - Send mail } @@ -438,7 +439,7 @@ if ($action == "confirm_approve" && GETPOST("confirm") == "yes" && $id > 0 && $u if ($result > 0) { - if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) + if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition { // Send mail @@ -542,7 +543,7 @@ if ($action == "confirm_refuse" && GETPOST('confirm')=="yes" && $id > 0 && $user if ($result > 0) { - if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) + if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition { // Send mail @@ -583,7 +584,6 @@ if ($action == "confirm_refuse" && GETPOST('confirm')=="yes" && $id > 0 && $user else { setEventMessages($langs->trans("ErrorFailedToSendMail",$emailFrom,$emailTo), null, 'errors'); - $mesg="Impossible d'envoyer l'email."; } // END - Send mail } @@ -627,7 +627,7 @@ if ($action == "confirm_cancel" && GETPOST('confirm')=="yes" && GETPOST('detail_ if ($result > 0) { - if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) + if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition { // Send mail @@ -667,6 +667,7 @@ if ($action == "confirm_cancel" && GETPOST('confirm')=="yes" && GETPOST('detail_ else { $mesg="Impossible d'envoyer l'email."; + setEventMessages($mesg, null, 'errors'); } // END - Send mail } @@ -756,7 +757,7 @@ if ($action == 'set_paid' && $id > 0 && $user->rights->expensereport->to_paid) if ($result > 0) { - if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) + if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition { // Send mail @@ -806,9 +807,8 @@ if ($action == 'set_paid' && $id > 0 && $user->rights->expensereport->to_paid) endif; else: - - $mesg="Impossible d'envoyer l'email."; - + $mesg="Impossible d'envoyer l'email."; + setEventMessages($mesg, null, 'errors'); endif; // END - Send mail } @@ -921,7 +921,7 @@ if ($action == 'confirm_delete_line' && GETPOST("confirm") == "yes") $total_ht = $object_ligne->total_ht; $total_tva = $object_ligne->total_tva; - $result=$object->deleteline(GETPOST("rowid")); + $result=$object->deleteline(GETPOST("rowid"), $user); if ($result >= 0) { if ($result > 0) @@ -961,7 +961,6 @@ if ($action == "updateligne" ) $rowid = $_POST['rowid']; $type_fees_id = GETPOST('fk_c_type_fees'); - $object_ligne->vatrate = price2num(GETPOST('vatrate')); $projet_id = $fk_projet; $comments = GETPOST('comments'); $qty = GETPOST('qty'); @@ -983,6 +982,7 @@ if ($action == "updateligne" ) if (! $error) { + // TODO Use update method of ExpenseReportLine $result = $object->updateline($rowid, $type_fees_id, $projet_id, $vatrate, $comments, $qty, $value_unit, $date, $id); if ($result >= 0) { @@ -1078,29 +1078,6 @@ $formfile = new FormFile($db); $formproject = new FormProjets($db); $projecttmp = new Project($db); -if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) -{ - if(!empty($_GET['mesg'])) - { - $text_mesg = explode(",",$_GET['mesg']); - - foreach($text_mesg as $text) - { - $mesg.= "- ".$langs->trans($text)."<br />"; - } - - print "<div class=\"error\" style=\"font-size:15px;background-color:#FFB3B3;\">"; - print $langs->trans("LINE_NOT_ADDED")."<br />"; - print $mesg; - print "</div>"; - } - else - { - if ($mesg) print "<div class=\"error\" style=\"font-size:16px;background-color:red;\">".$mesg."</div>"; - } -} - - // Create if ($action == 'create') { -- GitLab