NEW Add option CONTRACT_SYNC_PLANNED_DATE_OF_SERVICES
This commit is contained in:
parent
f3f39fb1ee
commit
9d0314dbae
@ -657,6 +657,8 @@ if (empty($reshook))
|
|||||||
|
|
||||||
else if ($action == 'updateline' && $user->rights->contrat->creer && ! GETPOST('cancel','alpha'))
|
else if ($action == 'updateline' && $user->rights->contrat->creer && ! GETPOST('cancel','alpha'))
|
||||||
{
|
{
|
||||||
|
$error = 0;
|
||||||
|
|
||||||
if (!empty($date_start_update) && !empty($date_end_update) && $date_start_update > $date_end_update)
|
if (!empty($date_start_update) && !empty($date_end_update) && $date_start_update > $date_end_update)
|
||||||
{
|
{
|
||||||
setEventMessages($langs->trans("Error").': '.$langs->trans("DateStartPlanned").' > '.$langs->trans("DateEndPlanned"), null, 'errors');
|
setEventMessages($langs->trans("Error").': '.$langs->trans("DateStartPlanned").' > '.$langs->trans("DateEndPlanned"), null, 'errors');
|
||||||
@ -665,12 +667,20 @@ if (empty($reshook))
|
|||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error) {
|
if (! $error)
|
||||||
$objectline = new ContratLigne($db);
|
|
||||||
if ($objectline->fetch(GETPOST('elrowid')))
|
|
||||||
{
|
{
|
||||||
|
$objectline = new ContratLigne($db);
|
||||||
|
if ($objectline->fetch(GETPOST('elrowid')) < 0)
|
||||||
|
{
|
||||||
|
setEventMessages($objectline->error, $objectline->errors, 'errors');
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
if ($date_start_real_update == '') $date_start_real_update=$objectline->date_ouverture;
|
if ($date_start_real_update == '') $date_start_real_update=$objectline->date_ouverture;
|
||||||
if ($date_end_real_update == '') $date_end_real_update=$objectline->date_cloture;
|
if ($date_end_real_update == '') $date_end_real_update=$objectline->date_cloture;
|
||||||
|
|
||||||
@ -736,22 +746,22 @@ if (empty($reshook))
|
|||||||
// TODO verifier price_min si fk_product et multiprix
|
// TODO verifier price_min si fk_product et multiprix
|
||||||
|
|
||||||
$result=$objectline->update($user);
|
$result=$objectline->update($user);
|
||||||
if ($result > 0)
|
if ($result < 0)
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
setEventMessages($objectline->error, $objectline->errors, 'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
{
|
{
|
||||||
$db->commit();
|
$db->commit();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setEventMessages($objectline->error, $objectline->errors, 'errors');
|
|
||||||
$db->rollback();
|
$db->rollback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
setEventMessages($objectline->error, $objectline->errors, 'errors');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->contrat->creer)
|
else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->contrat->creer)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2911,22 +2911,14 @@ class ContratLigne extends CommonObjectLine
|
|||||||
|
|
||||||
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if (! $resql)
|
||||||
{
|
|
||||||
$contrat=new Contrat($this->db);
|
|
||||||
$contrat->fetch($this->fk_contrat);
|
|
||||||
$result=$contrat->update_statut($user);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
$this->error="Error ".$this->db->lasterror();
|
$this->error="Error ".$this->db->lasterror();
|
||||||
$error++;
|
$error++;
|
||||||
//return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) // For avoid conflicts if trigger used
|
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) // For avoid conflicts if trigger used
|
||||||
{
|
{
|
||||||
|
|
||||||
$result=$this->insertExtraFields();
|
$result=$this->insertExtraFields();
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
@ -2934,17 +2926,35 @@ class ContratLigne extends CommonObjectLine
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($error)) {
|
// Sync dates of all services
|
||||||
|
if (! $error && ! empty($conf->global->CONTRACT_SYNC_PLANNED_DATE_OF_SERVICES))
|
||||||
|
{
|
||||||
|
$sql ='UPDATE '.MAIN_DB_PREFIX.'contratdet SET';
|
||||||
|
$sql.= " date_ouverture_prevue = ".($this->date_ouverture_prevue!=''?"'".$this->db->idate($this->date_ouverture_prevue)."'":"null").",";
|
||||||
|
$sql.= " date_fin_validite = ".($this->date_fin_validite!=''?"'".$this->db->idate($this->date_fin_validite)."'":"null");
|
||||||
|
$sql.= " WHERE fk_contrat = ".$this->fk_contrat;
|
||||||
|
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
if (! $resql)
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
$this->error="Error ".$this->db->lasterror();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
if (! $notrigger)
|
if (! $notrigger)
|
||||||
{
|
{
|
||||||
// Call trigger
|
// Call trigger
|
||||||
$result=$this->call_trigger('LINECONTRACT_UPDATE',$user);
|
$result=$this->call_trigger('LINECONTRACT_UPDATE', $user);
|
||||||
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
|
if ($result < 0) { $error++; $this->db->rollback(); }
|
||||||
// End call triggers
|
// End call triggers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($error)) {
|
if (! $error)
|
||||||
|
{
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user