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 ff1e8e0652ddc8ea28439640cd919a1adaea24cb..d0e2151e84907ccd3f912f494ae2d91967d4d6ed 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 635a135b764fcfdb78371d55ed47ac3e8598f893..ab3bbee222ebf58b30d0726d5a0585235b34cb45 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 aca5fe67d0de99aa9a979851a2abf64dac018b09..219736a62a7cbe48f09a94785094dd4adb8047d2 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1,6 +1,6 @@ <?php /* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> - * Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net> + * Copyright (C) 2005-2016 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2014-2015 Marcos GarcĂa <marcosgdf@gmail.com> @@ -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;