diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index 7217a53b890943a4b49cf276af467a9b9061ec2f..6024996624afd468353e19f84084155a249ab0df 100755 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -182,3 +182,5 @@ CREATE TABLE llx_expensereport_det ) ENGINE=innodb; +ALTER TABLE ll_projet ADD COLUMN budget_amount double(24,8); + diff --git a/htdocs/install/mysql/tables/llx_projet.sql b/htdocs/install/mysql/tables/llx_projet.sql index acac8c7b687ed6b9431f7f91411c497d8453128a..0bfde5c026b1ac354be8d6c39f5ca50f95c0053d 100644 --- a/htdocs/install/mysql/tables/llx_projet.sql +++ b/htdocs/install/mysql/tables/llx_projet.sql @@ -34,5 +34,7 @@ create table llx_projet fk_statut smallint DEFAULT 0 NOT NULL, note_private text, note_public text, + --budget_days real, -- budget in days is sum of field planned_workload of tasks + budget_amount double(24,8), model_pdf varchar(255) )ENGINE=innodb; diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 047f0bff0579bde1e3e42e62f280181dfdebc221..ce699df0b32e11a3695e4f90a2743ca7b9ce1fa0 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -55,8 +55,11 @@ class Project extends CommonObject var $public; //!< Tell if this is a public or private project var $note_private; var $note_public; + var $budget_amount; + var $statuts_short; var $statuts; + var $oldcopy; @@ -110,6 +113,7 @@ class Project extends CommonObject $sql.= ", datec"; $sql.= ", dateo"; $sql.= ", datee"; + $sql.= ", budget_amount"; $sql.= ", entity"; $sql.= ") VALUES ("; $sql.= "'" . $this->db->escape($this->ref) . "'"; @@ -208,6 +212,7 @@ class Project extends CommonObject $sql.= ", datec=" . ($this->date_c != '' ? "'".$this->db->idate($this->date_c)."'" : 'null'); $sql.= ", dateo=" . ($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : 'null'); $sql.= ", datee=" . ($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : 'null'); + $sql.= ", budget_amount = " . ($this->budget_amount > 0 ? $this->budget_amount : "null"); $sql.= " WHERE rowid = " . $this->id; dol_syslog(get_class($this)."::Update", LOG_DEBUG); @@ -293,8 +298,8 @@ class Project extends CommonObject { if (empty($id) && empty($ref)) return -1; - $sql = "SELECT rowid, ref, title, description, public, datec"; - $sql.= ", tms, dateo, datee, fk_soc, fk_user_creat, fk_statut, note_private, note_public,model_pdf"; + $sql = "SELECT rowid, ref, title, description, public, datec, budget_amount,"; + $sql.= " tms, dateo, datee, fk_soc, fk_user_creat, fk_statut, note_private, note_public,model_pdf"; $sql.= " FROM " . MAIN_DB_PREFIX . "projet"; if (! empty($id)) { @@ -331,6 +336,7 @@ class Project extends CommonObject $this->user_author_id = $obj->fk_user_creat; $this->public = $obj->public; $this->statut = $obj->fk_statut; + $this->budget_amount = $obj->budget_amount; $this->modelpdf = $obj->model_pdf; $this->db->free($resql); @@ -412,6 +418,10 @@ class Project extends CommonObject { $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . $tablename." WHERE fk_projet=" . $this->id; } + if ($type == 'expensereport') + { + $sql = "SELECT id as rowid FROM " . MAIN_DB_PREFIX . "expensereport as e, " . MAIN_DB_PREFIX . "expensereport_det as ed WHERE ed.fk_project=" . $this->id; + } if ($dates > 0) { if (empty($datefieldname) && ! empty($this->table_element_date)) $datefieldname=$this->table_element_date; @@ -424,10 +434,6 @@ class Project extends CommonObject if (empty($datefieldname)) return 'Error this object has no date field defined'; $sql.=" AND (".$datefieldname." <= '".$this->db->idate($datee)."' OR ".$datefieldname." IS NULL)"; } - if ($type == 'expensereport') - { - $sql ='eeee'; - } if (! $sql) return -1; //print $sql; @@ -842,6 +848,8 @@ class Project extends CommonObject $this->date_m = $now; $this->date_start = $now; $this->note_public = 'SPECIMEN'; + $this->budget_amount = 10000; + /* $nbp = rand(1, 9); $xnbp = 0; @@ -893,13 +901,6 @@ class Project extends CommonObject if ($mode == 'write' && $user->rights->projet->creer) $userAccess++; if ($mode == 'delete' && $user->rights->projet->supprimer) $userAccess++; } - // Permission are supported on users only. To have an external thirdparty contact to see a project, its user must allowed to contacts of projects. - /*if ($source == 'external' && preg_match('/PROJECT/', $userRole[$nblinks]['code']) && $user->contact_id == $userRole[$nblinks]['id']) - { - if ($mode == 'read' && $user->rights->projet->lire) $userAccess++; - if ($mode == 'write' && $user->rights->projet->creer) $userAccess++; - if ($mode == 'delete' && $user->rights->projet->supprimer) $userAccess++; - }*/ $nblinks++; } } @@ -945,11 +946,9 @@ class Project extends CommonObject { $sql.= " AND ec.element_id = p.rowid"; $sql.= " AND ( p.public = 1"; - //$sql.= " OR p.fk_user_creat = ".$user->id; $sql.= " OR ( ctc.rowid = ec.fk_c_type_contact"; $sql.= " AND ctc.element = '" . $this->element . "'"; $sql.= " AND ( (ctc.source = 'internal' AND ec.fk_socpeople = ".$user->id.")"; - //$sql.= " OR (ctc.source = 'external' AND ec.fk_socpeople = ".($user->contact_id?$user->contact_id:0).")"; // Permission are supported on users only. To have an external thirdparty contact to see a project, its user must allowed to contacts of projects. $sql.= " )"; $sql.= " ))"; } @@ -959,7 +958,6 @@ class Project extends CommonObject $sql.= " AND ctc.rowid = ec.fk_c_type_contact"; $sql.= " AND ctc.element = '" . $this->element . "'"; $sql.= " AND ( (ctc.source = 'internal' AND ec.fk_socpeople = ".$user->id.")"; - //$sql.= " OR (ctc.source = 'external' AND ec.fk_socpeople = ".($user->contact_id?$user->contact_id:0).")"; // Permission are supported on users only. To have an external thirdparty contact to see a project, its user must allowed to contacts of projects. $sql.= " )"; } if ($mode == 2)