From 03eccb3336ea8412daa63d841530126626e4318e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 10 Jan 2016 19:48:59 +0100 Subject: [PATCH 1/2] Prepare database to be able to manage a different opportunity probability for each opportunity. --- htdocs/install/mysql/migration/3.9.0-4.0.0.sql | 4 ++++ htdocs/install/mysql/tables/llx_projet.sql | 1 + htdocs/projet/class/project.class.php | 9 +++++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql index ff1e8e0652d..d0e2151e849 100644 --- a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql +++ b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql @@ -27,3 +27,7 @@ ALTER TABLE llx_accounting_bookkeeping ADD COLUMN validated tinyint DEFAULT 0 NO ALTER TABLE llx_fichinter ADD COLUMN datet date after duree; ALTER TABLE llx_fichinter ADD COLUMN datee date after duree; ALTER TABLE llx_fichinter ADD COLUMN dateo date after duree; + +ALTER TABLE llx_projet ADD COLUMN opp_percent double(5,2) after fk_opp_status; +UPDATE llx_projet as p set opp_percent = (SELECT percent from llx_c_lead_status as cls where cls.rowid = p.fk_opp_status) where opp_percent IS NULL; + diff --git a/htdocs/install/mysql/tables/llx_projet.sql b/htdocs/install/mysql/tables/llx_projet.sql index 635a135b764..ab3bbee222e 100644 --- a/htdocs/install/mysql/tables/llx_projet.sql +++ b/htdocs/install/mysql/tables/llx_projet.sql @@ -33,6 +33,7 @@ create table llx_projet public integer, -- project is public or not fk_statut integer DEFAULT 0 NOT NULL, -- open or close fk_opp_status integer DEFAULT NULL, -- if project is used to manage opportunities + opp_percent double(5,2), date_close datetime DEFAULT NULL, fk_user_close integer DEFAULT NULL, note_private text, diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index aca5fe67d0d..219736a62a7 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2012 Laurent Destailleur + * Copyright (C) 2005-2016 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2015 Marcos GarcĂ­a @@ -65,6 +65,7 @@ class Project extends CommonObject var $statut; // 0=draft, 1=opened, 2=closed var $opp_status; // opportunity status, into table llx_c_lead_status + var $opp_percent; // opportunity probability var $oldcopy; @@ -140,6 +141,7 @@ class Project extends CommonObject $sql.= ", fk_user_creat"; $sql.= ", fk_statut"; $sql.= ", fk_opp_status"; + $sql.= ", opp_percent"; $sql.= ", public"; $sql.= ", datec"; $sql.= ", dateo"; @@ -155,6 +157,7 @@ class Project extends CommonObject $sql.= ", " . $user->id; $sql.= ", ".(is_numeric($this->statut) ? $this->statut : '0'); $sql.= ", ".(is_numeric($this->opp_status) ? $this->opp_status : 'NULL'); + $sql.= ", ".(is_numeric($this->opp_percent) ? $this->opp_percent : 'NULL'); $sql.= ", " . ($this->public ? 1 : 0); $sql.= ", '".$this->db->idate($now)."'"; $sql.= ", " . ($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : 'null'); @@ -245,6 +248,7 @@ class Project extends CommonObject $sql.= ", fk_soc = " . ($this->socid > 0 ? $this->socid : "null"); $sql.= ", fk_statut = " . $this->statut; $sql.= ", fk_opp_status = " . ($this->opp_status > 0 ? $this->opp_status : 'null'); + $sql.= ", opp_percent = " . ((is_numeric($this->opp_percent) && $this->opp_percent != '') ? $this->opp_percent : 'null'); $sql.= ", public = " . ($this->public ? 1 : 0); $sql.= ", datec=" . ($this->date_c != '' ? "'".$this->db->idate($this->date_c)."'" : 'null'); $sql.= ", dateo=" . ($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : 'null'); @@ -339,7 +343,7 @@ class Project extends CommonObject if (empty($id) && empty($ref)) return -1; $sql = "SELECT rowid, ref, title, description, public, datec, opp_amount, budget_amount,"; - $sql.= " tms, dateo, datee, date_close, fk_soc, fk_user_creat, fk_user_close, fk_statut, fk_opp_status, note_private, note_public, model_pdf"; + $sql.= " tms, dateo, datee, date_close, fk_soc, fk_user_creat, fk_user_close, fk_statut, fk_opp_status, opp_percent, note_private, note_public, model_pdf"; $sql.= " FROM " . MAIN_DB_PREFIX . "projet"; if (! empty($id)) { @@ -380,6 +384,7 @@ class Project extends CommonObject $this->statut = $obj->fk_statut; $this->opp_status = $obj->fk_opp_status; $this->opp_amount = $obj->opp_amount; + $this->opp_percent = $obj->opp_percent; $this->budget_amount = $obj->budget_amount; $this->modelpdf = $obj->model_pdf; From 85898ec977e0cc548e828e118617e0f4aa1d7f97 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Jan 2016 23:48:47 +0100 Subject: [PATCH 2/2] Fix bad test --- htdocs/core/class/conf.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 2e4d0a2cfd9..35b22b1a14c 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -344,7 +344,7 @@ class Conf $this->fournisseur->facture->dir_temp =$rootfordata."/fournisseur/facture/temp"; // To prepare split of module fournisseur into fournisseur + supplier_order + supplier_invoice - if (empty($this->global->MAIN_USE_NEW_SUPPLIERMOD)) // By default, test is true + if (! empty($this->fournisseur->enabled) && empty($this->global->MAIN_USE_NEW_SUPPLIERMOD)) // By default, if module supplier is on, we set new properties { $this->supplier_order=new stdClass(); $this->supplier_order->enabled=1;