Fix: Meilleur gestion erreur creation contrat.
Fix: On distingue bien le commerical principal de suivi, du commercial de signature
This commit is contained in:
parent
9e5aff617a
commit
e45fdcaa22
@ -44,6 +44,8 @@ class Contrat
|
|||||||
var $societe;
|
var $societe;
|
||||||
var $user_service;
|
var $user_service;
|
||||||
var $user_cloture;
|
var $user_cloture;
|
||||||
|
var $commercial_signature_id;
|
||||||
|
var $commercial_suivi_id;
|
||||||
|
|
||||||
var $statuts=array();
|
var $statuts=array();
|
||||||
|
|
||||||
@ -63,7 +65,9 @@ class Contrat
|
|||||||
$this->user_cloture = new User($DB);
|
$this->user_cloture = new User($DB);
|
||||||
|
|
||||||
// Statut 0=ouvert, 1=actif, 2=cloturé
|
// Statut 0=ouvert, 1=actif, 2=cloturé
|
||||||
$this->statuts=array($langs->trans("Opened"),$langs->trans("Running"),$langs->trans("Closed"));
|
$this->statuts[0]=$langs->trans("Opened");
|
||||||
|
$this->statuts[1]=$langs->trans("Running");
|
||||||
|
$this->statuts[2]=$langs->trans("Closed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -264,9 +268,12 @@ class Contrat
|
|||||||
function create($user,$lang='',$conf='')
|
function create($user,$lang='',$conf='')
|
||||||
{
|
{
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."contrat (datec, fk_soc, fk_user_author, fk_commercial_signature, fk_commercial_suivi, date_contrat)";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."contrat (datec, fk_soc, fk_user_author, fk_commercial_signature, fk_commercial_suivi, date_contrat)";
|
||||||
$sql .= " VALUES (now(),".$this->soc_id.",".$user->id.",".$this->commercial_id.",".$this->commercial_id;
|
$sql.= " VALUES (now(),".$this->soc_id.",".$user->id;
|
||||||
|
$sql.= ",".($this->commercial_signature_id>=0?$this->commercial_signature_id:"null");
|
||||||
|
$sql.= ",".($this->commercial_suivi_id>=0?$this->commercial_suivi_id:"null");
|
||||||
$sql.= ",".$this->db->idate($this->date_contrat) .")";
|
$sql.= ",".$this->db->idate($this->date_contrat) .")";
|
||||||
if ($this->db->query($sql))
|
$resql=$this->db->query($sql);
|
||||||
|
if ($resql)
|
||||||
{
|
{
|
||||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."contrat");
|
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."contrat");
|
||||||
|
|
||||||
@ -280,6 +287,7 @@ class Contrat
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$this->error=$lang->trans("UnknownError: ".$this->db->error()." - sql=".$sql);
|
||||||
dolibarr_syslog("Contrat::create - 10");
|
dolibarr_syslog("Contrat::create - 10");
|
||||||
$result = -1;
|
$result = -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -69,7 +69,8 @@ if ($_POST["action"] == 'add')
|
|||||||
|
|
||||||
$contrat->soc_id = $_POST["soc_id"];
|
$contrat->soc_id = $_POST["soc_id"];
|
||||||
$contrat->date_contrat = $datecontrat;
|
$contrat->date_contrat = $datecontrat;
|
||||||
$contrat->commercial_id = $_POST["commercial"];
|
$contrat->commercial_suivi_id = $_POST["commercial_suivi_id"];
|
||||||
|
$contrat->commercial_signature_id = $_POST["commercial_signature_id"];
|
||||||
$contrat->note = $_POST["note"];
|
$contrat->note = $_POST["note"];
|
||||||
$contrat->projetid = $_POST["projetid"];
|
$contrat->projetid = $_POST["projetid"];
|
||||||
$contrat->remise_percent = $_POST["remise_percent"];
|
$contrat->remise_percent = $_POST["remise_percent"];
|
||||||
@ -80,12 +81,16 @@ if ($_POST["action"] == 'add')
|
|||||||
$contrat->add_product($_POST["idprod3"],$_POST["qty3"],$_POST["remise_percent3"]);
|
$contrat->add_product($_POST["idprod3"],$_POST["qty3"],$_POST["remise_percent3"]);
|
||||||
$contrat->add_product($_POST["idprod4"],$_POST["qty4"],$_POST["remise_percent4"]);
|
$contrat->add_product($_POST["idprod4"],$_POST["qty4"],$_POST["remise_percent4"]);
|
||||||
*/
|
*/
|
||||||
$result = $contrat->create($user,$lang,$conf);
|
$result = $contrat->create($user,$langs,$conf);
|
||||||
if ($result == 0)
|
if ($result >= 0)
|
||||||
{
|
{
|
||||||
Header("Location: fiche.php?id=".$contrat->id);
|
Header("Location: fiche.php?id=".$contrat->id);
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
$mesg='<div class="error">'.$contrat->error.'</div>';
|
||||||
|
}
|
||||||
|
print $mesg;
|
||||||
$_GET["id"] = $contrat->id;
|
$_GET["id"] = $contrat->id;
|
||||||
|
|
||||||
$action = '';
|
$action = '';
|
||||||
@ -120,6 +125,7 @@ if ($_POST["action"] == 'addligne' && $user->rights->contrat->creer)
|
|||||||
if ($result >= 0)
|
if ($result >= 0)
|
||||||
{
|
{
|
||||||
Header("Location: fiche.php?id=".$contrat->id);
|
Header("Location: fiche.php?id=".$contrat->id);
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -252,9 +258,10 @@ if ($_GET["action"] == 'create')
|
|||||||
|
|
||||||
print '<tr><td>'.$langs->trans("Customer").':</td><td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id.'">'.$obj->nom.'</a></td></tr>';
|
print '<tr><td>'.$langs->trans("Customer").':</td><td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id.'">'.$obj->nom.'</a></td></tr>';
|
||||||
|
|
||||||
print '<tr><td width="20%">'.$langs->trans("Commercial").'</td><td>';
|
// Commercial suivi
|
||||||
|
print '<tr><td width="20%" nowrap>'.$langs->trans("SalesRepresentativeFollowUp").'</td><td>';
|
||||||
print '<select name="commercial">';
|
print '<select name="commercial_suivi_id">';
|
||||||
|
print '<option value="-1"> </option>';
|
||||||
$sql = "SELECT rowid, name, firstname FROM ".MAIN_DB_PREFIX."user ORDER BY name ";
|
$sql = "SELECT rowid, name, firstname FROM ".MAIN_DB_PREFIX."user ORDER BY name ";
|
||||||
$resql=$db->query( $sql);
|
$resql=$db->query( $sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
@ -266,7 +273,31 @@ if ($_GET["action"] == 'create')
|
|||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$row = $db->fetch_row($resql);
|
$row = $db->fetch_row($resql);
|
||||||
print '<option value="'.$row[0].'">'.$row[1] . " " . $row[2];
|
print '<option value="'.$row[0].'">'.$row[1] . " " . $row[2].'</option>';
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$db->free($resql);
|
||||||
|
|
||||||
|
}
|
||||||
|
print '</select></td></tr>';
|
||||||
|
|
||||||
|
// Commercial signature
|
||||||
|
print '<tr><td width="20%" nowrap>'.$langs->trans("SalesRepresentativeSignature").'</td><td>';
|
||||||
|
print '<select name="commercial_signature_id">';
|
||||||
|
print '<option value="-1"> </option>';
|
||||||
|
$sql = "SELECT rowid, name, firstname FROM ".MAIN_DB_PREFIX."user ORDER BY name ";
|
||||||
|
$resql=$db->query( $sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$num = $db->num_rows($resql);
|
||||||
|
if ( $num > 0 )
|
||||||
|
{
|
||||||
|
$i = 0;
|
||||||
|
while ($i < $num)
|
||||||
|
{
|
||||||
|
$row = $db->fetch_row($resql);
|
||||||
|
print '<option value="'.$row[0].'">'.$row[1] . " " . $row[2].'</option>';
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user