Fix: Option CONTRAT_EDITWHENVALIDATED now works
This commit is contained in:
parent
7b7b9dfef3
commit
551c14f6c2
@ -661,8 +661,7 @@ class Contrat extends CommonObject
|
|||||||
*/
|
*/
|
||||||
function addline($desc, $pu, $qty, $txtva, $fk_product=0, $remise_percent=0, $date_start, $date_end, $price_base_type='HT')
|
function addline($desc, $pu, $qty, $txtva, $fk_product=0, $remise_percent=0, $date_start, $date_end, $price_base_type='HT')
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs, $conf;
|
||||||
global $conf;
|
|
||||||
|
|
||||||
// Nettoyage parametres
|
// Nettoyage parametres
|
||||||
if (! $txtva) $txtva=0;
|
if (! $txtva) $txtva=0;
|
||||||
@ -674,7 +673,7 @@ class Contrat extends CommonObject
|
|||||||
|
|
||||||
dolibarr_syslog("Contrat::addline $desc, $pu, $qty, $txtva, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type, $info_bits");
|
dolibarr_syslog("Contrat::addline $desc, $pu, $qty, $txtva, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type, $info_bits");
|
||||||
|
|
||||||
if ($this->statut == 0)
|
if ($this->statut == 0 || ($this->statut == 1 && $conf->global->CONTRAT_EDITWHENVALIDATED))
|
||||||
{
|
{
|
||||||
if ($fk_product > 0)
|
if ($fk_product > 0)
|
||||||
{
|
{
|
||||||
@ -743,6 +742,7 @@ class Contrat extends CommonObject
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
dolibarr_syslog("Contrat::addline ErrorTryToAddLineOnValidatedContract", LOG_ERR);
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -826,20 +826,24 @@ class Contrat extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Supprime une ligne de detail
|
* \brief Delete a contract line
|
||||||
* \param idligne Id de la ligne detail à supprimer
|
* \param idline Id of line to delete
|
||||||
* \return int >0 si ok, <0 si ko
|
* \return int >0 if OK, <0 if KO
|
||||||
*/
|
*/
|
||||||
function delete_line($idligne)
|
function delete_line($idline)
|
||||||
{
|
{
|
||||||
if ($this->statut == 0)
|
global $conf;
|
||||||
|
|
||||||
|
if ($contrat->statut == 0 ||
|
||||||
|
($contrat->statut == 1 && $conf->global->CONTRAT_EDITWHENVALIDATED) )
|
||||||
{
|
{
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."contratdet WHERE rowid =".$idligne;
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."contratdet";
|
||||||
|
$sql.= " WHERE rowid =".$idline;
|
||||||
|
|
||||||
|
dolibarr_syslog("Contrat::delete_line sql=".$sql);
|
||||||
if ($this->db->query($sql) )
|
if ($this->db->query($sql) )
|
||||||
{
|
{
|
||||||
$this->update_price();
|
$this->update_price();
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -334,11 +334,15 @@ if ($_GET["action"] == 'deleteline' && $user->rights->contrat->creer)
|
|||||||
$contrat->fetch($_GET["id"]);
|
$contrat->fetch($_GET["id"]);
|
||||||
$result = $contrat->delete_line($_GET["lineid"]);
|
$result = $contrat->delete_line($_GET["lineid"]);
|
||||||
|
|
||||||
if ($result == 0)
|
if ($result >= 0)
|
||||||
{
|
{
|
||||||
Header("Location: fiche.php?id=".$contrat->id);
|
Header("Location: fiche.php?id=".$contrat->id);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$mesg=$contrat->error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == 'yes' && $user->rights->contrat->creer)
|
if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == 'yes' && $user->rights->contrat->creer)
|
||||||
@ -357,7 +361,7 @@ if ($_POST["action"] == 'confirm_close' && $_POST["confirm"] == 'yes' && $user->
|
|||||||
|
|
||||||
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes')
|
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes')
|
||||||
{
|
{
|
||||||
if ($user->rights->contrat->supprimer )
|
if ($user->rights->contrat->supprimer)
|
||||||
{
|
{
|
||||||
$contrat = new Contrat($db);
|
$contrat = new Contrat($db);
|
||||||
$contrat->id = $_GET["id"];
|
$contrat->id = $_GET["id"];
|
||||||
@ -783,7 +787,8 @@ else
|
|||||||
else {
|
else {
|
||||||
print ' ';
|
print ' ';
|
||||||
}
|
}
|
||||||
if ($contrat->statut == 0 && $user->rights->contrat->creer)
|
if ( ($contrat->statut == 0 || ($contrat->statut == 1 && $conf->global->CONTRAT_EDITWHENVALIDATED))
|
||||||
|
&& $user->rights->contrat->creer)
|
||||||
{
|
{
|
||||||
print ' ';
|
print ' ';
|
||||||
print '<a href="fiche.php?id='.$id.'&action=deleteline&lineid='.$objp->rowid.'">';
|
print '<a href="fiche.php?id='.$id.'&action=deleteline&lineid='.$objp->rowid.'">';
|
||||||
@ -1067,7 +1072,8 @@ else
|
|||||||
/*
|
/*
|
||||||
* Ajouter une ligne produit/service
|
* Ajouter une ligne produit/service
|
||||||
*/
|
*/
|
||||||
if ($user->rights->contrat->creer && ($contrat->statut == 0 || $conf->global->CONTRAT_EDITWHENVALIDATED))
|
if ($user->rights->contrat->creer &&
|
||||||
|
($contrat->statut == 0 || ($contrat->statut == 1 && $conf->global->CONTRAT_EDITWHENVALIDATED)) )
|
||||||
{
|
{
|
||||||
print '<br>';
|
print '<br>';
|
||||||
print '<table class="noborder" width="100%">'; // Array with (n*2)+1 lines
|
print '<table class="noborder" width="100%">'; // Array with (n*2)+1 lines
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user