Merge pull request #3926 from frederic34/fccard
allow chaining and remove header exit
This commit is contained in:
commit
096ec3100d
@ -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)
|
||||
@ -946,16 +947,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 = $langs->trans('NotAuthorized');
|
||||
$this->errors[] = $lanfs->trans('NotAuthorized');
|
||||
dol_syslog(get_class($this)."::commande User not Authorized", LOG_ERR);
|
||||
}
|
||||
return $result ;
|
||||
@ -1762,7 +1771,7 @@ class CommandeFournisseur extends CommonOrder
|
||||
*/
|
||||
function Livraison($user, $date, $type, $comment)
|
||||
{
|
||||
global $conf;
|
||||
global $conf, $langs;
|
||||
|
||||
$result = 0;
|
||||
$error = 0;
|
||||
@ -1829,6 +1838,7 @@ class CommandeFournisseur extends CommonOrder
|
||||
if ($resql)
|
||||
{
|
||||
$result = 0;
|
||||
$this->statut = $statut;
|
||||
$result=$this->log($user, $statut, $date, $comment);
|
||||
|
||||
$this->db->commit();
|
||||
@ -1843,6 +1853,8 @@ class CommandeFournisseur extends CommonOrder
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error = $langs->trans('NotAuthorized');
|
||||
$this->errors[] = $langs->trans('NotAuthorized');
|
||||
dol_syslog(get_class($this)."::Livraison Not Authorized");
|
||||
$result = -3;
|
||||
}
|
||||
@ -1992,6 +2004,7 @@ class CommandeFournisseur extends CommonOrder
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$this->statut = $status;
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -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');
|
||||
@ -767,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
|
||||
{
|
||||
|
||||
@ -59,6 +59,7 @@ ErrorCantLoadUserFromDolibarrDatabase=Failed to find user <b>%s</b> 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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user