From b23f74eab1fade18196d79819679cd43684a5b2a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Apr 2019 12:17:57 +0200 Subject: [PATCH] FIX Status of opportunity should never be -1 --- htdocs/install/mysql/migration/8.0.0-9.0.0.sql | 1 + htdocs/projet/class/project.class.php | 2 +- htdocs/projet/list.php | 9 ++++----- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql index d1cc00f403f..2d45d94aafd 100644 --- a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql +++ b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql @@ -285,5 +285,6 @@ DELETE from llx_accounting_account where rowid in (select minid from tmp_llx_acc ALTER TABLE llx_accounting_account DROP INDEX uk_accounting_account; ALTER TABLE llx_accounting_account ADD UNIQUE INDEX uk_accounting_account (account_number, entity, fk_pcg_version); +UPDATE llx_projet SET fk_opp_status = NULL WHERE fk_opp_status = -1; diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index b2642542770..4e749f4575d 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -226,7 +226,7 @@ class Project extends CommonObject $sql.= ", " . ($this->socid > 0 ? $this->socid : "null"); $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_status) && $this->opp_status > 0) ? $this->opp_status : 'NULL'); $sql.= ", ".(is_numeric($this->opp_percent) ? $this->opp_percent : 'NULL'); $sql.= ", " . ($this->public ? 1 : 0); $sql.= ", '".$this->db->idate($now)."'"; diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index ba45a5b0b32..181e3f36f88 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -276,7 +276,6 @@ if ($resql) else dol_print_error($db); if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0]='0'; // To avoid sql syntax error if not found - $distinct='DISTINCT'; // We add distinct until we are added a protection to be sure a contact of a project and task is only once. $sql = "SELECT ".$distinct." p.rowid as id, p.ref, p.title, p.fk_statut, p.fk_opp_status, p.public, p.fk_user_creat"; $sql.= ", p.datec as date_creation, p.dateo as date_start, p.datee as date_end, p.opp_amount, p.opp_percent, p.tms as date_update, p.budget_amount"; @@ -350,10 +349,10 @@ if ($search_status >= 0) if ($search_opp_status) { if (is_numeric($search_opp_status) && $search_opp_status > 0) $sql .= " AND p.fk_opp_status = ".$db->escape($search_opp_status); - if ($search_opp_status == 'all') $sql .= " AND p.fk_opp_status IS NOT NULL"; - if ($search_opp_status == 'openedopp') $sql .= " AND p.fk_opp_status IS NOT NULL AND p.fk_opp_status NOT IN (SELECT rowid FROM ".MAIN_DB_PREFIX."c_lead_status WHERE code IN ('WON','LOST'))"; - if ($search_opp_status == 'notopenedopp') $sql .= " AND (p.fk_opp_status IS NULL OR p.fk_opp_status IN (SELECT rowid FROM ".MAIN_DB_PREFIX."c_lead_status WHERE code IN ('WON')))"; - if ($search_opp_status == 'none') $sql .= " AND p.fk_opp_status IS NULL"; + if ($search_opp_status == 'all') $sql .= " AND (p.fk_opp_status IS NOT NULL AND p.fk_opp_status <> -1)"; + if ($search_opp_status == 'openedopp') $sql .= " AND p.fk_opp_status IS NOT NULL AND p.fk_opp_status <> -1 AND p.fk_opp_status NOT IN (SELECT rowid FROM ".MAIN_DB_PREFIX."c_lead_status WHERE code IN ('WON','LOST'))"; + if ($search_opp_status == 'notopenedopp') $sql .= " AND (p.fk_opp_status IS NULL OR p.fk_opp_status = -1 OR p.fk_opp_status IN (SELECT rowid FROM ".MAIN_DB_PREFIX."c_lead_status WHERE code IN ('WON')))"; + if ($search_opp_status == 'none') $sql .= " AND (p.fk_opp_status IS NULL OR p.fk_opp_status = -1)"; } if ($search_public!='') $sql .= " AND p.public = ".$db->escape($search_public); // For external user, no check is done on company permission because readability is managed by public status of project and assignement.