FIX Status of opportunity should never be -1

This commit is contained in:
Laurent Destailleur 2019-04-08 12:17:57 +02:00
parent 81ccf4d1f0
commit b23f74eab1
3 changed files with 6 additions and 6 deletions

View File

@ -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;

View File

@ -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)."'";

View File

@ -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.