From becce332dd84c91e2105d08235cd115ca9e28392 Mon Sep 17 00:00:00 2001 From: frederic34 Date: Sat, 7 Nov 2015 09:49:25 +0100 Subject: [PATCH 1/3] allow chaining and remove header exit --- htdocs/fourn/class/fournisseur.commande.class.php | 8 ++++++++ htdocs/fourn/commande/card.php | 7 +++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 6a83aab0155..6246b47dcd3 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -946,16 +946,24 @@ class CommandeFournisseur extends CommonOrder dol_syslog(get_class($this)."::commande", LOG_DEBUG); if ($this->db->query($sql)) { + $this->statut = 3; + $this->methode_commande_id = $methode; + $this->date_commande = $this->db->idate($date); $result = 1; $this->log($user, 3, $date, $comment); } else { + $this->error = $this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); $result = -1; } } else { + $result = -1; + $this->error = 'Not Authorized'; + $this->errors[] = 'Not Authorized'; dol_syslog(get_class($this)."::commande User not Authorized", LOG_ERR); } return $result ; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index cb1754fa8d3..8078665c321 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -704,15 +704,14 @@ if (empty($reshook)) if ($action == 'confirm_commande' && $confirm == 'yes' && $user->rights->fournisseur->commande->commander) { - $result = $object->commande($user, $_REQUEST["datecommande"], $_REQUEST["methode"], $_REQUEST['comment']); + $result = $object->commande($user, $_REQUEST["datecommande"], $_REQUEST["methode"], $_REQUEST['comment']); if ($result > 0) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); - exit; - } + $action = ''; + } else { setEventMessages($object->error, $object->errors, 'errors'); From a597d6c3793c525483b0a57a752a4e7e196e7fa6 Mon Sep 17 00:00:00 2001 From: frederic34 Date: Sat, 7 Nov 2015 10:23:56 +0100 Subject: [PATCH 2/3] allow chaining --- htdocs/fourn/class/fournisseur.commande.class.php | 3 +++ htdocs/fourn/commande/card.php | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 6246b47dcd3..d64ebe263d1 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1837,6 +1837,7 @@ class CommandeFournisseur extends CommonOrder if ($resql) { $result = 0; + $this->statut = $statut; $result=$this->log($user, $statut, $date, $comment); $this->db->commit(); @@ -1851,6 +1852,8 @@ class CommandeFournisseur extends CommonOrder } else { + $this->error = 'Not Authorized'; + $this->errors[] = 'Not Authorized'; dol_syslog(get_class($this)."::Livraison Not Authorized"); $result = -3; } diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 8078665c321..904cd5b3133 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -766,15 +766,15 @@ if (empty($reshook)) { $date_liv = dol_mktime(GETPOST('rehour'),GETPOST('remin'),GETPOST('resec'),GETPOST("remonth"),GETPOST("reday"),GETPOST("reyear")); - $result = $object->Livraison($user, $date_liv, GETPOST("type"), GETPOST("comment")); + $result = $object->Livraison($user, $date_liv, GETPOST("type"), GETPOST("comment")); if ($result > 0) { - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); - exit; - } + setEventMessages($langs->trans("DeliveryStateSaved"), null); + $action = ''; + } else if($result == -3) { - setEventMessage($langs->trans("NotAuthorized"), 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } else { From 7349862b6464e95af3c783cd89684a212960bf2f Mon Sep 17 00:00:00 2001 From: frederic34 Date: Sat, 7 Nov 2015 11:13:58 +0100 Subject: [PATCH 3/3] translations --- htdocs/fourn/class/fournisseur.commande.class.php | 14 ++++++++------ htdocs/langs/en_US/main.lang | 1 + 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index d64ebe263d1..e988893dbb4 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -481,7 +481,7 @@ class CommandeFournisseur extends CommonOrder } else { - $this->error='Not Authorized'; + $this->error='NotAuthorized'; dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR); return -1; } @@ -936,6 +936,7 @@ class CommandeFournisseur extends CommonOrder */ function commande($user, $date, $methode, $comment='') { + global $langs; dol_syslog(get_class($this)."::commande"); $result = 0; if ($user->rights->fournisseur->commande->commander) @@ -962,8 +963,8 @@ class CommandeFournisseur extends CommonOrder else { $result = -1; - $this->error = 'Not Authorized'; - $this->errors[] = 'Not Authorized'; + $this->error = $langs->trans('NotAuthorized'); + $this->errors[] = $lanfs->trans('NotAuthorized'); dol_syslog(get_class($this)."::commande User not Authorized", LOG_ERR); } return $result ; @@ -1770,7 +1771,7 @@ class CommandeFournisseur extends CommonOrder */ function Livraison($user, $date, $type, $comment) { - global $conf; + global $conf, $langs; $result = 0; $error = 0; @@ -1852,8 +1853,8 @@ class CommandeFournisseur extends CommonOrder } else { - $this->error = 'Not Authorized'; - $this->errors[] = 'Not Authorized'; + $this->error = $langs->trans('NotAuthorized'); + $this->errors[] = $langs->trans('NotAuthorized'); dol_syslog(get_class($this)."::Livraison Not Authorized"); $result = -3; } @@ -2003,6 +2004,7 @@ class CommandeFournisseur extends CommonOrder if (! $error) { + $this->statut = $status; $this->db->commit(); return 1; } diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 796c14af15e..a05b2b7c06e 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -59,6 +59,7 @@ ErrorCantLoadUserFromDolibarrDatabase=Failed to find user %s in Dolibarr ErrorNoVATRateDefinedForSellerCountry=Error, no vat rates defined for country '%s'. ErrorNoSocialContributionForSellerCountry=Error, no social/fiscal taxes type defined for country '%s'. ErrorFailedToSaveFile=Error, failed to save file. +NotAuthorized=You are not authorized to do that. SetDate=Set date SelectDate=Select a date SeeAlso=See also %s