mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-11 18:32:32 +01:00
Ajout possibilit d'attribuer une ref client sur une propale, utile pour les revendeurs
This commit is contained in:
@@ -101,6 +101,11 @@ if ($_GET["action"] == 'create')
|
||||
|
||||
// Ref
|
||||
print '<tr><td>'.$langs->trans("Ref").'</td><td colspan="2"><input name="ref" value="'.$numpr.'"></td></tr>';
|
||||
|
||||
// Reference client
|
||||
print '<tr><td>'.$langs->trans('RefCustomer').'</td><td>';
|
||||
print '<input type="text" name="ref_client" value=""></td>';
|
||||
print '</tr>';
|
||||
|
||||
// Societe
|
||||
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="2">'.$soc->getNomUrl(1);
|
||||
|
||||
@@ -143,7 +143,7 @@ if ($_POST['action'] == 'setdeliveryadress' && $user->rights->propale->creer)
|
||||
if ($_POST['action'] == 'set_ref_client' && $user->rights->propale->creer)
|
||||
{
|
||||
$propal = new Propal($db);
|
||||
$propal->fetch($_GET['id']);
|
||||
$propal->fetch($_GET['propalid']);
|
||||
$propal->set_ref_client($user, $_POST['ref_client']);
|
||||
}
|
||||
|
||||
@@ -605,10 +605,10 @@ if ($_GET['propalid'] > 0)
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td nowrap>';
|
||||
print $langs->trans('RefCustomer').'</td><td align="left">';
|
||||
print '</td>';
|
||||
if ($_GET['action'] != 'refcdeclient' && $propal->brouillon) print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=refcdeclient&id='.$propal->id.'">'.img_edit($langs->trans('Edit')).'</a></td>';
|
||||
if ($_GET['action'] != 'refclient' && $propal->brouillon) print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=refclient&propalid='.$propal->id.'">'.img_edit($langs->trans('Edit')).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="3">';
|
||||
if ($user->rights->propale->creer && $_GET['action'] == 'refcdeclient')
|
||||
if ($user->rights->propale->creer && $_GET['action'] == 'refclient')
|
||||
{
|
||||
print '<form action="fiche.php?id='.$id.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="set_ref_client">';
|
||||
|
||||
@@ -119,6 +119,7 @@ class Commande
|
||||
$this->date_livraison = $propal->date_livraison;
|
||||
$this->adresse_livraison_id = $propal->adresse_livraison_id;
|
||||
$this->contact_id = $propal->contactid;
|
||||
$this->ref_client = $propal->ref_client;
|
||||
|
||||
/* D<>finit la soci<63>t<EFBFBD> comme un client */
|
||||
$soc = new Societe($this->db);
|
||||
@@ -350,7 +351,7 @@ class Commande
|
||||
$sql.= ' '.$this->db->idate($this->date_commande).',';
|
||||
$sql.= ' '.$this->source.', ';
|
||||
$sql.= " '".addslashes($this->note)."', ";
|
||||
$sql.= " '".$this->ref_client."', '".$this->modelpdf.'\', \''.$this->cond_reglement_id.'\', \''.$this->mode_reglement_id.'\',';
|
||||
$sql.= " '".addslashes($this->ref_client)."', '".$this->modelpdf.'\', \''.$this->cond_reglement_id.'\', \''.$this->mode_reglement_id.'\',';
|
||||
$sql.= ' '.($this->date_livraison?$this->db->idate($this->date_livraison):'null').',';
|
||||
$sql.= " '".$this->adresse_livraison_id."',";
|
||||
$sql.= " '".$this->remise_absolue."',";
|
||||
|
||||
@@ -699,14 +699,15 @@ class Propal
|
||||
|
||||
// Insertion dans la base
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."propal (fk_soc, fk_soc_contact, price, remise, remise_percent, remise_absolue,";
|
||||
$sql.= " tva, total, datep, datec, ref, fk_user_author, note, note_public, model_pdf, fin_validite, fk_cond_reglement, fk_mode_reglement, date_livraison) ";
|
||||
$sql.= " tva, total, datep, datec, ref, fk_user_author, note, note_public, model_pdf, fin_validite,";
|
||||
$sql.= " fk_cond_reglement, fk_mode_reglement, date_livraison, ref_client) ";
|
||||
$sql.= " VALUES ($this->socidp, $this->contactid, 0, $this->remise, $this->remise_percent, $this->remise_absolue,";
|
||||
$sql.= " 0,0,".$this->db->idate($this->datep).", now(), '$this->ref', $this->author,";
|
||||
$sql.= "'".addslashes($this->note)."',";
|
||||
$sql.= "'".addslashes($this->note_public)."',";
|
||||
$sql.= "'$this->modelpdf',".$this->db->idate($this->fin_validite).",";
|
||||
$sql.= " $this->cond_reglement_id, $this->mode_reglement_id,";
|
||||
$sql.= " ".$this->db->idate($this->date_livraison).")";
|
||||
$sql.= " ".$this->db->idate($this->date_livraison).",".addslashes($this->ref_client).")";
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
@@ -964,7 +965,7 @@ class Propal
|
||||
$sql.= ", ".$this->db->pdate("datep")." as dp";
|
||||
$sql.= ", ".$this->db->pdate("fin_validite")." as dfv";
|
||||
$sql.= ", ".$this->db->pdate("date_livraison")." as date_livraison";
|
||||
$sql.= ", model_pdf";
|
||||
$sql.= ", model_pdf, ref_client";
|
||||
$sql.= ", note, note_public";
|
||||
$sql.= ", fk_projet, fk_statut, fk_user_author";
|
||||
$sql.= ", fk_cond_reglement, fk_mode_reglement, fk_adresse_livraison";
|
||||
@@ -988,6 +989,7 @@ class Propal
|
||||
$this->fin_validite = $obj->dfv;
|
||||
$this->date = $obj->dp;
|
||||
$this->ref = $obj->ref;
|
||||
$this->ref_client = $obj->ref_client;
|
||||
$this->price = $obj->price;
|
||||
$this->remise = $obj->remise;
|
||||
$this->remise_percent = $obj->remise_percent;
|
||||
@@ -1007,8 +1009,8 @@ class Propal
|
||||
$this->statut_libelle = $obj->statut_label;
|
||||
$this->cond_reglement_id = $obj->fk_cond_reglement;
|
||||
$this->mode_reglement_id = $obj->fk_mode_reglement;
|
||||
$this->date_livraison = $obj->date_livraison;
|
||||
$this->adresse_livraison_id = $obj->fk_adresse_livraison;
|
||||
$this->date_livraison = $obj->date_livraison;
|
||||
$this->adresse_livraison_id = $obj->fk_adresse_livraison;
|
||||
|
||||
$this->user_author_id = $obj->fk_user_author;
|
||||
|
||||
@@ -1230,6 +1232,38 @@ class Propal
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Positionne numero reference client
|
||||
* \param user Utilisateur qui modifie
|
||||
* \param ref_client Reference client
|
||||
* \return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function set_ref_client($user, $ref_client)
|
||||
{
|
||||
if ($user->rights->propale->creer)
|
||||
{
|
||||
dolibarr_syslog('Propale::set_ref_client this->id='.$this->id.', ref_client='.$ref_client);
|
||||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'propal SET ref_client = '.(empty($ref_client) ? 'NULL' : '\''.addslashes($ref_client).'\'');
|
||||
$sql.= ' WHERE rowid = '.$this->id;
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
$this->ref_client = $ref_client;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
dolibarr_syslog('Propale::set_ref_client Erreur '.$this->error.' - '.$sql);
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief D<>finit une remise globale relative sur la proposition
|
||||
|
||||
@@ -296,4 +296,6 @@ alter table llx_societe_remise_except modify description varchar(255) NOT NULL;
|
||||
insert into llx_c_actioncomm (id, code, type, libelle) values ( 8, 'AC_COM', 'system', 'Envoi Commande');
|
||||
update llx_actioncomm set fk_action = '8' where fk_action = '3' and label = 'Envoi commande par mail';
|
||||
|
||||
insert into llx_const (name, value, type, visible, note) VALUES ('PROPALE_VALIDITY_DURATION', '15', 'chaine', 0, 'Dur<EFBFBD>e de validit<69>e des propales');
|
||||
insert into llx_const (name, value, type, visible, note) VALUES ('PROPALE_VALIDITY_DURATION', '15', 'chaine', 0, 'Dur<EFBFBD>e de validit<69>e des propales');
|
||||
|
||||
alter table llx_propal add column ref_client varchar(30) after ref;
|
||||
@@ -27,6 +27,7 @@ create table llx_propal
|
||||
fk_soc_contact integer,
|
||||
fk_projet integer DEFAULT 0, -- projet auquel est rattache la propale
|
||||
ref varchar(30) NOT NULL, -- propal number
|
||||
ref_client varchar(30), -- customer order number
|
||||
datec datetime, -- date de creation
|
||||
datep date, -- date de la propal
|
||||
fin_validite datetime, -- date de fin de validite
|
||||
|
||||
Reference in New Issue
Block a user