Merge pull request #3926 from frederic34/fccard

allow chaining and remove header exit
This commit is contained in:
Laurent Destailleur 2015-11-08 15:49:33 +01:00
commit 096ec3100d
3 changed files with 24 additions and 11 deletions

View File

@ -481,7 +481,7 @@ class CommandeFournisseur extends CommonOrder
} }
else else
{ {
$this->error='Not Authorized'; $this->error='NotAuthorized';
dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
return -1; return -1;
} }
@ -936,6 +936,7 @@ class CommandeFournisseur extends CommonOrder
*/ */
function commande($user, $date, $methode, $comment='') function commande($user, $date, $methode, $comment='')
{ {
global $langs;
dol_syslog(get_class($this)."::commande"); dol_syslog(get_class($this)."::commande");
$result = 0; $result = 0;
if ($user->rights->fournisseur->commande->commander) if ($user->rights->fournisseur->commande->commander)
@ -946,16 +947,24 @@ class CommandeFournisseur extends CommonOrder
dol_syslog(get_class($this)."::commande", LOG_DEBUG); dol_syslog(get_class($this)."::commande", LOG_DEBUG);
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
$this->statut = 3;
$this->methode_commande_id = $methode;
$this->date_commande = $this->db->idate($date);
$result = 1; $result = 1;
$this->log($user, 3, $date, $comment); $this->log($user, 3, $date, $comment);
} }
else else
{ {
$this->error = $this->db->lasterror();
$this->errors[] = $this->db->lasterror();
$result = -1; $result = -1;
} }
} }
else else
{ {
$result = -1;
$this->error = $langs->trans('NotAuthorized');
$this->errors[] = $lanfs->trans('NotAuthorized');
dol_syslog(get_class($this)."::commande User not Authorized", LOG_ERR); dol_syslog(get_class($this)."::commande User not Authorized", LOG_ERR);
} }
return $result ; return $result ;
@ -1762,7 +1771,7 @@ class CommandeFournisseur extends CommonOrder
*/ */
function Livraison($user, $date, $type, $comment) function Livraison($user, $date, $type, $comment)
{ {
global $conf; global $conf, $langs;
$result = 0; $result = 0;
$error = 0; $error = 0;
@ -1829,6 +1838,7 @@ class CommandeFournisseur extends CommonOrder
if ($resql) if ($resql)
{ {
$result = 0; $result = 0;
$this->statut = $statut;
$result=$this->log($user, $statut, $date, $comment); $result=$this->log($user, $statut, $date, $comment);
$this->db->commit(); $this->db->commit();
@ -1843,6 +1853,8 @@ class CommandeFournisseur extends CommonOrder
} }
else else
{ {
$this->error = $langs->trans('NotAuthorized');
$this->errors[] = $langs->trans('NotAuthorized');
dol_syslog(get_class($this)."::Livraison Not Authorized"); dol_syslog(get_class($this)."::Livraison Not Authorized");
$result = -3; $result = -3;
} }
@ -1992,6 +2004,7 @@ class CommandeFournisseur extends CommonOrder
if (! $error) if (! $error)
{ {
$this->statut = $status;
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }

View File

@ -704,15 +704,14 @@ if (empty($reshook))
if ($action == 'confirm_commande' && $confirm == 'yes' && $user->rights->fournisseur->commande->commander) 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 ($result > 0)
{ {
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
} }
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); $action = '';
exit; }
}
else else
{ {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
@ -767,15 +766,15 @@ if (empty($reshook))
{ {
$date_liv = dol_mktime(GETPOST('rehour'),GETPOST('remin'),GETPOST('resec'),GETPOST("remonth"),GETPOST("reday"),GETPOST("reyear")); $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) if ($result > 0)
{ {
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); setEventMessages($langs->trans("DeliveryStateSaved"), null);
exit; $action = '';
} }
else if($result == -3) else if($result == -3)
{ {
setEventMessage($langs->trans("NotAuthorized"), 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
else else
{ {

View File

@ -59,6 +59,7 @@ ErrorCantLoadUserFromDolibarrDatabase=Failed to find user <b>%s</b> in Dolibarr
ErrorNoVATRateDefinedForSellerCountry=Error, no vat rates defined for country '%s'. ErrorNoVATRateDefinedForSellerCountry=Error, no vat rates defined for country '%s'.
ErrorNoSocialContributionForSellerCountry=Error, no social/fiscal taxes type defined for country '%s'. ErrorNoSocialContributionForSellerCountry=Error, no social/fiscal taxes type defined for country '%s'.
ErrorFailedToSaveFile=Error, failed to save file. ErrorFailedToSaveFile=Error, failed to save file.
NotAuthorized=You are not authorized to do that.
SetDate=Set date SetDate=Set date
SelectDate=Select a date SelectDate=Select a date
SeeAlso=See also %s SeeAlso=See also %s