FIX Deadlock situation. Can't edit anymore contract.
FIX List of automatic events was not visible.
This commit is contained in:
parent
25924f31ad
commit
5fd6057c6c
@ -699,6 +699,11 @@ else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->contr
|
|||||||
$result = $object->validate($user);
|
$result = $object->validate($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if ($action == 'reopen' && $user->rights->contrat->creer)
|
||||||
|
{
|
||||||
|
$result = $object->reopen($user);
|
||||||
|
}
|
||||||
|
|
||||||
// Close all lines
|
// Close all lines
|
||||||
else if ($action == 'confirm_close' && $confirm == 'yes' && $user->rights->contrat->creer)
|
else if ($action == 'confirm_close' && $confirm == 'yes' && $user->rights->contrat->creer)
|
||||||
{
|
{
|
||||||
@ -1839,6 +1844,11 @@ else
|
|||||||
if ($user->rights->contrat->creer) print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=valid">'.$langs->trans("Validate").'</a></div>';
|
if ($user->rights->contrat->creer) print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=valid">'.$langs->trans("Validate").'</a></div>';
|
||||||
else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("Validate").'</a></div>';
|
else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("Validate").'</a></div>';
|
||||||
}
|
}
|
||||||
|
if ($object->statut == 1 && $nbofservices)
|
||||||
|
{
|
||||||
|
if ($user->rights->contrat->creer) print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen">'.$langs->trans("Modify").'</a></div>';
|
||||||
|
else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("Modify").'</a></div>';
|
||||||
|
}
|
||||||
|
|
||||||
if (! empty($conf->facture->enabled) && $object->statut > 0 && $object->nbofservicesclosed < $nbofservices)
|
if (! empty($conf->facture->enabled) && $object->statut > 0 && $object->nbofservicesclosed < $nbofservices)
|
||||||
{
|
{
|
||||||
@ -1899,6 +1909,12 @@ else
|
|||||||
|
|
||||||
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
||||||
|
|
||||||
|
// List of actions on element
|
||||||
|
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
|
||||||
|
$formactions = new FormActions($db);
|
||||||
|
$somethingshown = $formactions->showactions($object, 'contract', $socid);
|
||||||
|
|
||||||
|
|
||||||
print '</div></div></div>';
|
print '</div></div></div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -499,6 +499,70 @@ class Contrat extends CommonObject
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unvalidate a contract
|
||||||
|
*
|
||||||
|
* @param User $user Objet User
|
||||||
|
* @param int $notrigger 1=Does not execute triggers, 0=execute triggers
|
||||||
|
* @return int <0 if KO, >0 if OK
|
||||||
|
*/
|
||||||
|
function reopen($user, $notrigger=0)
|
||||||
|
{
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||||
|
global $langs, $conf;
|
||||||
|
|
||||||
|
$now=dol_now();
|
||||||
|
|
||||||
|
$error=0;
|
||||||
|
dol_syslog(get_class($this).'::reopen user='.$user->id);
|
||||||
|
|
||||||
|
$this->db->begin();
|
||||||
|
|
||||||
|
$this->fetch_thirdparty();
|
||||||
|
|
||||||
|
$sql = "UPDATE ".MAIN_DB_PREFIX."contrat SET statut = 0";
|
||||||
|
//$sql.= ", fk_user_valid = null, date_valid = null";
|
||||||
|
$sql .= " WHERE rowid = ".$this->id . " AND statut = 1";
|
||||||
|
|
||||||
|
dol_syslog(get_class($this)."::validate", LOG_DEBUG);
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
if (! $resql)
|
||||||
|
{
|
||||||
|
dol_print_error($this->db);
|
||||||
|
$error++;
|
||||||
|
$this->error=$this->db->lasterror();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Trigger calls
|
||||||
|
if (! $error && ! $notrigger)
|
||||||
|
{
|
||||||
|
// Call trigger
|
||||||
|
$result=$this->call_trigger('CONTRACT_REOPEN',$user);
|
||||||
|
if ($result < 0) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
// End call triggers
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set new ref and define current statut
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$this->statut=0;
|
||||||
|
$this->brouillon=1;
|
||||||
|
$this->date_validation=$now;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$this->db->commit();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->db->rollback();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load a contract from database
|
* Load a contract from database
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user