From 17ee9ca44ba32a62a00a520a97a88174f172c128 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 13 Jun 2006 14:31:37 +0000 Subject: [PATCH] =?UTF-8?q?Ajout=20possibilit=E9=20d'attribuer=20une=20ref?= =?UTF-8?q?=20client=20sur=20une=20propale,=20utile=20pour=20les=20revende?= =?UTF-8?q?urs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/comm/addpropal.php | 5 ++++ htdocs/comm/propal.php | 6 ++-- htdocs/commande/commande.class.php | 3 +- htdocs/propal.class.php | 44 ++++++++++++++++++++++++++---- mysql/migration/2.0.0-2.1.0.sql | 4 ++- mysql/tables/llx_propal.sql | 1 + 6 files changed, 53 insertions(+), 10 deletions(-) diff --git a/htdocs/comm/addpropal.php b/htdocs/comm/addpropal.php index 679d937c9d0..989d08f9dc0 100644 --- a/htdocs/comm/addpropal.php +++ b/htdocs/comm/addpropal.php @@ -101,6 +101,11 @@ if ($_GET["action"] == 'create') // Ref print ''.$langs->trans("Ref").''; + + // Reference client + print ''.$langs->trans('RefCustomer').''; + print ''; + print ''; // Societe print ''.$langs->trans('Company').''.$soc->getNomUrl(1); diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 153dbab1406..bc83df46363 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -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 ''; - if ($_GET['action'] != 'refcdeclient' && $propal->brouillon) print ''; + if ($_GET['action'] != 'refclient' && $propal->brouillon) print ''; print '
'; print $langs->trans('RefCustomer').''; print ''.img_edit($langs->trans('Edit')).''.img_edit($langs->trans('Edit')).'
'; print ''; - if ($user->rights->propale->creer && $_GET['action'] == 'refcdeclient') + if ($user->rights->propale->creer && $_GET['action'] == 'refclient') { print '
'; print ''; diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php index 7adbfde3875..927133cc80d 100644 --- a/htdocs/commande/commande.class.php +++ b/htdocs/commande/commande.class.php @@ -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été 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."',"; diff --git a/htdocs/propal.class.php b/htdocs/propal.class.php index 54af270b313..b92d645555c 100644 --- a/htdocs/propal.class.php +++ b/htdocs/propal.class.php @@ -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 diff --git a/mysql/migration/2.0.0-2.1.0.sql b/mysql/migration/2.0.0-2.1.0.sql index de986040a7d..faecf7107df 100644 --- a/mysql/migration/2.0.0-2.1.0.sql +++ b/mysql/migration/2.0.0-2.1.0.sql @@ -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ée de validitée des propales'); \ No newline at end of file +insert into llx_const (name, value, type, visible, note) VALUES ('PROPALE_VALIDITY_DURATION', '15', 'chaine', 0, 'Durée de validitée des propales'); + +alter table llx_propal add column ref_client varchar(30) after ref; \ No newline at end of file diff --git a/mysql/tables/llx_propal.sql b/mysql/tables/llx_propal.sql index c43bf84cd7e..eb2b708d6a5 100644 --- a/mysql/tables/llx_propal.sql +++ b/mysql/tables/llx_propal.sql @@ -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