From 0f584ef6a2b0deb2635428a31486fc9db1877d86 Mon Sep 17 00:00:00 2001 From: Philippe Grand Date: Fri, 1 Apr 2011 10:04:49 +0000 Subject: [PATCH] To answer to this query : http://www.dolibarr.fr/forum/12-howto--aide/20784-delais-de-livraison#24930 --- build/exe/doliwamp/doliwamp.iss | 4 +- htdocs/admin/dict.php | 13 ++- htdocs/comm/propal.php | 29 +++++ htdocs/comm/propal/class/propal.class.php | 33 ++++++ htdocs/core/class/html.form.class.php | 104 ++++++++++++++++++ .../install/mysql/migration/3.0.0-3.1.0.sql | 2 + .../install/mysql/tables/llx_c_delivery.sql | 39 +++++++ htdocs/langs/fr_FR/propal.lang | 2 + 8 files changed, 222 insertions(+), 4 deletions(-) create mode 100644 htdocs/install/mysql/tables/llx_c_delivery.sql diff --git a/build/exe/doliwamp/doliwamp.iss b/build/exe/doliwamp/doliwamp.iss index a24926de2dc..f1594f9702b 100644 --- a/build/exe/doliwamp/doliwamp.iss +++ b/build/exe/doliwamp/doliwamp.iss @@ -18,9 +18,9 @@ ; ----- Change this ----- AppName=DoliWamp ; DoliWamp-x.x.x or DoliWamp-x.x.x-dev or DoliWamp-x.x.x-beta -AppVerName=DoliWamp-3.1.0-alpha +AppVerName=DoliWamp-3.0.0-beta ; DoliWamp-x.x x or DoliWamp-x.x.x-dev or DoliWamp-x.x.x-beta -OutputBaseFilename=DoliWamp-3.1.0-alpha +OutputBaseFilename=DoliWamp-3.0.0-beta ; Define full path from wich all relative path are defined ; You must modify this to put here your dolibarr root directory SourceDir=C:\Work\Data\Workspace\dolibarr diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index d59be620015..c9ebfbf8499 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -52,7 +52,7 @@ $active = 1; // Mettre ici tous les caracteristiques des dictionnaires // Ordres d'affichage des dictionnaires (0 pour espace) -$taborder=array(9,0,4,3,2,0,1,8,19,16,0,5,11,0,6,0,10,12,13,0,14,0,7,17,0,20,18,0,15); +$taborder=array(9,0,4,3,2,0,1,8,19,16,0,5,11,0,6,0,10,12,13,0,14,0,7,17,0,20,18,21,0,15); // Nom des tables des dictionnaires $tabname[1] = MAIN_DB_PREFIX."c_forme_juridique"; @@ -75,6 +75,7 @@ $tabname[17]= MAIN_DB_PREFIX."c_type_fees"; $tabname[18]= MAIN_DB_PREFIX."c_shipment_mode"; $tabname[19]= MAIN_DB_PREFIX."c_effectif"; $tabname[20]= MAIN_DB_PREFIX."c_methode_commande_fournisseur"; +$tabname[21]= MAIN_DB_PREFIX."c_delivery"; // Dictionary labels $tablib[1] = "DictionnaryCompanyJuridicalType"; @@ -97,6 +98,7 @@ $tablib[17]= "DictionnaryFees"; $tablib[18]= "DictionnarySendingMethods"; $tablib[19]= "DictionnaryStaff"; $tablib[20]= "DictionnaryOrderMethods"; +$tablib[21]= "DictionnaryDelivery"; // Requete pour extraction des donnees des dictionnaires $tabsql[1] = "SELECT f.rowid as rowid, f.code, f.libelle, p.code as pays_code, p.libelle as pays, f.active FROM ".MAIN_DB_PREFIX."c_forme_juridique as f, ".MAIN_DB_PREFIX."c_pays as p WHERE f.fk_pays=p.rowid"; @@ -119,6 +121,7 @@ $tabsql[17]= "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREF $tabsql[18]= "SELECT rowid as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_shipment_mode"; $tabsql[19]= "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_effectif"; $tabsql[20]= "SELECT rowid as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_methode_commande_fournisseur"; +$tabsql[21]= "SELECT rowid as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_delivery"; // Critere de tri du dictionnaire $tabsqlsort[1] ="pays ASC, code ASC"; @@ -141,6 +144,7 @@ $tabsqlsort[17]="code ASC"; $tabsqlsort[18]="code ASC, libelle ASC"; $tabsqlsort[19]="id ASC"; $tabsqlsort[20]="code ASC, libelle ASC"; +$tabsqlsort[21]="code ASC, libelle ASC"; // Nom des champs en resultat de select pour affichage du dictionnaire $tabfield[1] = "code,libelle,pays"; @@ -163,6 +167,7 @@ $tabfield[17]= "code,libelle"; $tabfield[18]= "code,libelle"; $tabfield[19]= "code,libelle"; $tabfield[20]= "code,libelle"; +$tabfield[21]= "code,libelle"; // Nom des champs d'edition pour modification d'un enregistrement $tabfieldvalue[1] = "code,libelle,pays"; @@ -185,6 +190,7 @@ $tabfieldvalue[17]= "code,libelle"; $tabfieldvalue[18]= "code,libelle"; $tabfieldvalue[19]= "code,libelle"; $tabfieldvalue[20]= "code,libelle"; +$tabfieldvalue[21]= "code,libelle"; // Nom des champs dans la table pour insertion d'un enregistrement $tabfieldinsert[1] = "code,libelle,fk_pays"; @@ -207,6 +213,7 @@ $tabfieldinsert[17]= "code,libelle"; $tabfieldinsert[18]= "code,libelle"; $tabfieldinsert[19]= "code,libelle"; $tabfieldinsert[20]= "code,libelle"; +$tabfieldinsert[21]= "code,libelle"; // Nom du rowid si le champ n'est pas de type autoincrement // Example: "" if id field is "rowid" and has autoincrement on @@ -231,6 +238,7 @@ $tabrowid[17]= "id"; $tabrowid[18]= "rowid"; $tabrowid[19]= "id"; $tabrowid[20]= ""; +$tabrowid[21]= ""; // Condition to show dictionnary in setup page $tabcond[1] = true; @@ -253,6 +261,7 @@ $tabcond[17]= $conf->deplacement->enabled; $tabcond[18]= $conf->expedition->enabled; $tabcond[19]= $conf->societe->enabled; $tabcond[20]= $conf->fournisseur->enabled; +$tabcond[21]= $conf->propale->enabled; complete_dictionnary_with_modules($taborder,$tabname,$tablib,$tabsql,$tabsqlsort,$tabfield,$tabfieldvalue,$tabfieldinsert,$tabrowid,$tabcond); @@ -856,7 +865,7 @@ function fieldList($fieldlist,$obj='') foreach ($fieldlist as $field => $value) { - //var_dump($obj); + if ($fieldlist[$field] == 'pays') { if (in_array('region_id',$fieldlist)) { print ' '; continue; } // For region page, we do not show the country input print ''; diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 0635ee861a6..d0811d31141 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -232,6 +232,14 @@ if ($_POST['action'] == 'setaddress' && $user->rights->propale->creer) if ($result < 0) dol_print_error($db,$object->error); } +//delai de livraison +if ($_POST['action'] == 'setdelivery' && $user->rights->propale->creer) +{ + $object->fetch($_GET["id"]); + $result=$object->set_delivery($user,$_POST['delivery']); + if ($result < 0) dol_print_error($db,$object->error); +} + // Positionne ref client if ($_POST['action'] == 'set_ref_client' && $user->rights->propale->creer) { @@ -257,6 +265,7 @@ if ($_POST['action'] == 'add' && $user->rights->propale->creer) $object->ref = $_POST['ref']; $object->datep = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); $object->date_livraison = dol_mktime(12, 0, 0, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year']); + $object->delivery = $_POST['delivery']; $object->fk_delivery_address = $_POST['fk_address']; $object->duree_validite = $_POST['duree_validite']; $object->cond_reglement_id = $_POST['cond_reglement_id']; @@ -284,6 +293,7 @@ if ($_POST['action'] == 'add' && $user->rights->propale->creer) $object->ref_client = $_POST['ref_client']; $object->datep = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); $object->date_livraison = dol_mktime(12, 0, 0, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year']); + $object->delivery = $_POST['delivery']; $object->fk_delivery_address = $_POST['fk_address']; $object->duree_validite = $_POST['duree_validite']; $object->cond_reglement_id = $_POST['cond_reglement_id']; @@ -1261,6 +1271,25 @@ if ($id > 0 || ! empty($ref)) print ''; } + // Delivery + print ''; + print ''; + if ($_GET['action'] != 'editdelivery' && $object->brouillon) print ''; + print '
'; + print $langs->trans('DeliveryPeriod'); + print 'id.'">'.img_edit($langs->trans('SetDelivery'),1).'
'; + print ''; + if ($_GET['action'] == 'editdelivery') + { + $html->form_delivery($_SERVER['PHP_SELF'].'?id='.$object->id,$object->delivery,'delivery'); + } + else + { + $html->form_delivery($_SERVER['PHP_SELF'].'?id='.$object->id,$object->delivery,'none'); + } + print ''; + print ''; + // Payment term print ''; print '
'; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 52a78378558..b9362757d45 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -95,6 +95,7 @@ class Propal extends CommonObject var $fk_address; var $address_type; var $adresse; + var $delivery; var $products=array(); @@ -617,6 +618,7 @@ class Propal extends CommonObject $sql.= ", fk_mode_reglement"; $sql.= ", ref_client"; $sql.= ", date_livraison"; + $sql.= ", delivery"; $sql.= ", entity"; $sql.= ") "; $sql.= " VALUES ("; @@ -639,6 +641,7 @@ class Propal extends CommonObject $sql.= ", ".$this->mode_reglement_id; $sql.= ", '".$this->db->escape($this->ref_client)."'"; $sql.= ", ".($this->date_livraison!=''?"'".$this->db->idate($this->date_livraison)."'":'null'); + $sql.= ", ".$this->delivery; $sql.= ", ".$conf->entity; $sql.= ")"; @@ -901,6 +904,7 @@ class Propal extends CommonObject $sql.= ", datep as dp"; $sql.= ", fin_validite as dfv"; $sql.= ", date_livraison as date_livraison"; + $sql.= ", delivery"; $sql.= ", model_pdf, ref_client"; $sql.= ", note, note_public"; $sql.= ", fk_projet, fk_statut"; @@ -954,6 +958,7 @@ class Propal extends CommonObject $this->datep = $this->db->jdate($obj->dp); $this->fin_validite = $this->db->jdate($obj->dfv); $this->date_livraison = $this->db->jdate($obj->date_livraison); + $this->delivery = $obj->delivery; $this->fk_delivery_address = $obj->fk_adresse_livraison; // TODO obsolete $this->fk_address = $obj->fk_adresse_livraison; @@ -1226,6 +1231,34 @@ class Propal extends CommonObject } } + /** + * \brief Set delivery + * \param user Objet utilisateur qui modifie + * \param delivery delai de livraison + * \return int <0 si ko, >0 si ok + */ + function set_delivery($user, $delivery) + { + if ($user->rights->propale->creer) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."propal "; + $sql.= " SET delivery = '".$delivery."'"; + $sql.= " WHERE rowid = ".$this->id; + + if ($this->db->query($sql)) + { + $this->delivery = $delivery; + return 1; + } + else + { + $this->error=$this->db->error(); + dol_syslog("Propal::set_delivery Erreur SQL"); + return -1; + } + } + } + /** * \brief Positionne numero reference client * \param user Utilisateur qui modifie diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 0f0af4d1c88..0faad6e7019 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1487,6 +1487,76 @@ class Form } } + /** + * \brief Charge dans cache la liste des délais de livraison possibles + * \return int Nb lignes chargees, 0 si deja chargees, <0 si ko + */ + function load_cache_delivery() + { + global $langs; + + if (sizeof($this->cache_delivery)) return 0; // Cache deja charge + + $sql = "SELECT rowid, code, libelle"; + $sql.= " FROM ".MAIN_DB_PREFIX.'c_delivery'; + $sql.= " WHERE active=1"; + $sql.= " ORDER BY rowid"; + dol_syslog('Form::load_cache_delivery sql='.$sql,LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + + // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut + $libelle=($langs->trans("DeliveryType".$obj->code)!=("DeliveryType".$obj->code)?$langs->trans("DeliveryType".$obj->code):($obj->libelle!='-'?$obj->libelle:'')); + $this->cache_delivery[$obj->rowid]['code'] =$obj->code; + $this->cache_delivery[$obj->rowid]['label']=$libelle; + $i++; + } + return 1; + } + else { + dol_print_error($this->db); + return -1; + } + } + + /** + * \brief Retourne la liste des types de delais de livraison possibles + * \param selected Id du type de delais pre-selectionne + * \param htmlname Nom de la zone select + * \param filtertype Pour filtre + * \param addempty Ajoute entree vide + */ + function select_delivery($selected='',$htmlname='delivery',$filtertype='',$addempty=0) + { + global $langs,$user; + + $this->load_cache_delivery(); + + print ''; + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); + } + /** * \brief Charge dans cache la liste des types de paiements possibles * \return int Nb lignes chargees, 0 si deja chargees, <0 si ko @@ -2059,6 +2129,40 @@ class Form } } + /** + * \brief Affiche formulaire de selection de delais de livraison + * \param page Page + * \param selected Id condition pre-selectionne + * \param htmlname Name of select html field + * \param addempty Ajoute entree vide + */ + function form_delivery($page, $selected='', $htmlname='delivery', $addempty=0) + { + global $langs; + if ($htmlname != "none") + { + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + $this->select_delivery($selected,$htmlname,-1,$addempty); + print '
'; + } + else + { + if ($selected) + { + $this->load_cache_delivery(); + print $this->cache_delivery[$selected]['label']; + } else { + print " "; + } + } + } + /** * \brief Affiche formulaire de selection d'une date diff --git a/htdocs/install/mysql/migration/3.0.0-3.1.0.sql b/htdocs/install/mysql/migration/3.0.0-3.1.0.sql index 170c9309e0c..629cce73e7e 100755 --- a/htdocs/install/mysql/migration/3.0.0-3.1.0.sql +++ b/htdocs/install/mysql/migration/3.0.0-3.1.0.sql @@ -42,3 +42,5 @@ ALTER TABLE llx_facturedet ADD UNIQUE INDEX uk_fk_remise_except (fk_remise_excep ALTER TABLE llx_societe ADD COLUMN fk_currency integer DEFAULT 0 AFTER fk_forme_juridique; ALTER TABLE llx_societe_remise MODIFY remise_client double(6,3) DEFAULT 0 NOT NULL; + +ALTER TABLE llx_propal ADD COLUMN delivery varchar(60) DEFAULT 0 NULL AFTER fk_adresse_livraison; diff --git a/htdocs/install/mysql/tables/llx_c_delivery.sql b/htdocs/install/mysql/tables/llx_c_delivery.sql new file mode 100644 index 00000000000..50d2cc6dc6a --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_delivery.sql @@ -0,0 +1,39 @@ +-- ======================================================================== +-- Copyright (C) 2011 Philippe GRAND +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +-- +-- $Id: llx_c_delivery.sql,v 1.2 2011/02/24 09:57:04 hregis Exp $ +-- ======================================================================== + +create table llx_c_delivery +( + `rowid` int(11) NOT NULL auto_increment, + `code` varchar(30) default NULL, + `libelle` varchar(60) default NULL, + `active` tinyint(4) NOT NULL default '1', + PRIMARY KEY (`rowid`) +)ENGINE=innodb; + +-- +-- Contenu de la table `llx_c_delivery` +-- + +INSERT INTO `llx_c_delivery` (`rowid`, `code`, `libelle`, `active`) VALUES +(1, 'DSP', 'Disponible', 1), +(2, 'USM', 'Une semaine', 1), +(3, 'DSM', 'Deux semaines', 1), +(4, 'TSM', 'Trois semaines', 1); + diff --git a/htdocs/langs/fr_FR/propal.lang b/htdocs/langs/fr_FR/propal.lang index 93dbb2a4329..e6572ecd5d4 100644 --- a/htdocs/langs/fr_FR/propal.lang +++ b/htdocs/langs/fr_FR/propal.lang @@ -80,6 +80,8 @@ ClonePropal=Cloner proposition commerciale ConfirmClonePropal=Êtes-vous sûr de vouloir cloner cette proposition commerciale %s ? ProposalsAndProposalsLines=Propositions commerciales clientes et lignes de propositions ProposalLine=Ligne de proposition +DeliveryPeriod=Délai de livraison (à réception de commande) +SetDelivery=Définir le délai de livraison ##### Types de contacts ##### TypeContact_propal_internal_SALESREPFOLL=Commercial suivi propale TypeContact_propal_external_BILLING=Contact client facturation propale