Merge pull request #6109 from atm-florian/develop
fix : Bug when updating availability and demand reason on proposal because $user is not passed to trigger.
This commit is contained in:
commit
3a05bc4537
@ -1070,17 +1070,17 @@ if (empty($reshook))
|
|||||||
|
|
||||||
// Set project
|
// Set project
|
||||||
else if ($action == 'classin' && $user->rights->propal->creer) {
|
else if ($action == 'classin' && $user->rights->propal->creer) {
|
||||||
$object->setProject($_POST['projectid']);
|
$object->setProject(GETPOST('projectid','int'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delai de livraison
|
// Delai de livraison
|
||||||
else if ($action == 'setavailability' && $user->rights->propal->creer) {
|
else if ($action == 'setavailability' && $user->rights->propal->creer) {
|
||||||
$result = $object->availability($_POST['availability_id']);
|
$result = $object->set_availability($user, GETPOST('availability_id','int'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Origine de la propale
|
// Origine de la propale
|
||||||
else if ($action == 'setdemandreason' && $user->rights->propal->creer) {
|
else if ($action == 'setdemandreason' && $user->rights->propal->creer) {
|
||||||
$result = $object->demand_reason($_POST['demand_reason_id']);
|
$result = $object->set_demand_reason($user, GETPOST('demand_reason_id','int'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Conditions de reglement
|
// Conditions de reglement
|
||||||
|
|||||||
@ -1839,7 +1839,7 @@ class Propal extends CommonObject
|
|||||||
*/
|
*/
|
||||||
function set_availability($user, $id, $notrigger=0)
|
function set_availability($user, $id, $notrigger=0)
|
||||||
{
|
{
|
||||||
if (! empty($user->rights->propal->creer))
|
if (! empty($user->rights->propal->creer) && $this->statut >= self::STATUS_DRAFT)
|
||||||
{
|
{
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
@ -1849,7 +1849,7 @@ class Propal extends CommonObject
|
|||||||
$sql.= " SET fk_availability = '".$id."'";
|
$sql.= " SET fk_availability = '".$id."'";
|
||||||
$sql.= " WHERE rowid = ".$this->id;
|
$sql.= " WHERE rowid = ".$this->id;
|
||||||
|
|
||||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
dol_syslog(__METHOD__.' availability('.$availability_id.')', LOG_DEBUG);
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if (!$resql)
|
if (!$resql)
|
||||||
{
|
{
|
||||||
@ -1861,6 +1861,7 @@ class Propal extends CommonObject
|
|||||||
{
|
{
|
||||||
$this->oldcopy= clone $this;
|
$this->oldcopy= clone $this;
|
||||||
$this->fk_availability = $id;
|
$this->fk_availability = $id;
|
||||||
|
$this->availability_id = $availability_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $notrigger && empty($error))
|
if (! $notrigger && empty($error))
|
||||||
@ -1887,6 +1888,14 @@ class Propal extends CommonObject
|
|||||||
return -1*$error;
|
return -1*$error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$error_str='Propal status do not meet requirement '.$this->statut;
|
||||||
|
dol_syslog(__METHOD__.$error_str, LOG_ERR);
|
||||||
|
$this->error=$error_str;
|
||||||
|
$this->errors[]= $this->error;
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1899,14 +1908,14 @@ class Propal extends CommonObject
|
|||||||
*/
|
*/
|
||||||
function set_demand_reason($user, $id, $notrigger=0)
|
function set_demand_reason($user, $id, $notrigger=0)
|
||||||
{
|
{
|
||||||
if (! empty($user->rights->propal->creer))
|
if (! empty($user->rights->propal->creer) && $this->statut >= self::STATUS_DRAFT)
|
||||||
{
|
{
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."propal ";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."propal ";
|
||||||
$sql.= " SET fk_input_reason = '".$id."'";
|
$sql.= " SET fk_input_reason = ".$id;
|
||||||
$sql.= " WHERE rowid = ".$this->id;
|
$sql.= " WHERE rowid = ".$this->id;
|
||||||
|
|
||||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||||
@ -1922,6 +1931,7 @@ class Propal extends CommonObject
|
|||||||
{
|
{
|
||||||
$this->oldcopy= clone $this;
|
$this->oldcopy= clone $this;
|
||||||
$this->fk_input_reason = $id;
|
$this->fk_input_reason = $id;
|
||||||
|
$this->demand_reason_id = $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1949,6 +1959,14 @@ class Propal extends CommonObject
|
|||||||
return -1*$error;
|
return -1*$error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$error_str='Propal status do not meet requirement '.$this->statut;
|
||||||
|
dol_syslog(__METHOD__.$error_str, LOG_ERR);
|
||||||
|
$this->error=$error_str;
|
||||||
|
$this->errors[]= $this->error;
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2733,6 +2751,7 @@ class Propal extends CommonObject
|
|||||||
* @param int $availability_id Id of new delivery time
|
* @param int $availability_id Id of new delivery time
|
||||||
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
|
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
|
||||||
* @return int >0 if OK, <0 if KO
|
* @return int >0 if OK, <0 if KO
|
||||||
|
* @deprecated use set_availability
|
||||||
*/
|
*/
|
||||||
function availability($availability_id, $notrigger=0)
|
function availability($availability_id, $notrigger=0)
|
||||||
{
|
{
|
||||||
@ -2800,6 +2819,7 @@ class Propal extends CommonObject
|
|||||||
* @param int $demand_reason_id Id of new source demand
|
* @param int $demand_reason_id Id of new source demand
|
||||||
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
|
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
|
||||||
* @return int >0 si ok, <0 si ko
|
* @return int >0 si ok, <0 si ko
|
||||||
|
* @deprecated use set_demand_reason
|
||||||
*/
|
*/
|
||||||
function demand_reason($demand_reason_id, $notrigger=0)
|
function demand_reason($demand_reason_id, $notrigger=0)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -983,8 +983,8 @@ if ($action == 'create')
|
|||||||
$projectid = GETPOST('projectid')?GETPOST('projectid'):$object->fk_project;
|
$projectid = GETPOST('projectid')?GETPOST('projectid'):$object->fk_project;
|
||||||
$langs->load('projects');
|
$langs->load('projects');
|
||||||
print '<tr><td>' . $langs->trans('Project') . '</td><td>';
|
print '<tr><td>' . $langs->trans('Project') . '</td><td>';
|
||||||
$numprojet = $formproject->select_projects($socid, $projectid, 'projectid', 0);
|
$numprojet = $formproject->select_projects($socid, $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, $forceaddid=0, $morecss='');
|
||||||
print ' <a href="'.DOL_URL_ROOT.'/projet/card.php?socid=' . $soc->id . '&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id).'">' . $langs->trans("AddProject") . '</a>';
|
print ' <a href="'.DOL_URL_ROOT.'/projet/card.php?socid=' . $object->thirdparty->id . '&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$object->thirdparty->id.(!empty($id)?'&id='.$id:'')).'">' . $langs->trans("AddProject") . '</a>';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user