Skip to content
Snippets Groups Projects
Commit 82b3f4a1 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Add field budget_amount on project.

parent 2e0b2fb0
No related branches found
No related tags found
No related merge requests found
...@@ -182,3 +182,5 @@ CREATE TABLE llx_expensereport_det ...@@ -182,3 +182,5 @@ CREATE TABLE llx_expensereport_det
) ENGINE=innodb; ) ENGINE=innodb;
ALTER TABLE ll_projet ADD COLUMN budget_amount double(24,8);
...@@ -34,5 +34,7 @@ create table llx_projet ...@@ -34,5 +34,7 @@ create table llx_projet
fk_statut smallint DEFAULT 0 NOT NULL, fk_statut smallint DEFAULT 0 NOT NULL,
note_private text, note_private text,
note_public 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) model_pdf varchar(255)
)ENGINE=innodb; )ENGINE=innodb;
...@@ -55,8 +55,11 @@ class Project extends CommonObject ...@@ -55,8 +55,11 @@ class Project extends CommonObject
var $public; //!< Tell if this is a public or private project var $public; //!< Tell if this is a public or private project
var $note_private; var $note_private;
var $note_public; var $note_public;
var $budget_amount;
var $statuts_short; var $statuts_short;
var $statuts; var $statuts;
var $oldcopy; var $oldcopy;
...@@ -110,6 +113,7 @@ class Project extends CommonObject ...@@ -110,6 +113,7 @@ class Project extends CommonObject
$sql.= ", datec"; $sql.= ", datec";
$sql.= ", dateo"; $sql.= ", dateo";
$sql.= ", datee"; $sql.= ", datee";
$sql.= ", budget_amount";
$sql.= ", entity"; $sql.= ", entity";
$sql.= ") VALUES ("; $sql.= ") VALUES (";
$sql.= "'" . $this->db->escape($this->ref) . "'"; $sql.= "'" . $this->db->escape($this->ref) . "'";
...@@ -208,6 +212,7 @@ class Project extends CommonObject ...@@ -208,6 +212,7 @@ class Project extends CommonObject
$sql.= ", datec=" . ($this->date_c != '' ? "'".$this->db->idate($this->date_c)."'" : 'null'); $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.= ", dateo=" . ($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : 'null');
$sql.= ", datee=" . ($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : '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; $sql.= " WHERE rowid = " . $this->id;
dol_syslog(get_class($this)."::Update", LOG_DEBUG); dol_syslog(get_class($this)."::Update", LOG_DEBUG);
...@@ -293,8 +298,8 @@ class Project extends CommonObject ...@@ -293,8 +298,8 @@ class Project extends CommonObject
{ {
if (empty($id) && empty($ref)) return -1; if (empty($id) && empty($ref)) return -1;
$sql = "SELECT rowid, ref, title, description, public, datec"; $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.= " tms, dateo, datee, fk_soc, fk_user_creat, fk_statut, note_private, note_public,model_pdf";
$sql.= " FROM " . MAIN_DB_PREFIX . "projet"; $sql.= " FROM " . MAIN_DB_PREFIX . "projet";
if (! empty($id)) if (! empty($id))
{ {
...@@ -331,6 +336,7 @@ class Project extends CommonObject ...@@ -331,6 +336,7 @@ class Project extends CommonObject
$this->user_author_id = $obj->fk_user_creat; $this->user_author_id = $obj->fk_user_creat;
$this->public = $obj->public; $this->public = $obj->public;
$this->statut = $obj->fk_statut; $this->statut = $obj->fk_statut;
$this->budget_amount = $obj->budget_amount;
$this->modelpdf = $obj->model_pdf; $this->modelpdf = $obj->model_pdf;
$this->db->free($resql); $this->db->free($resql);
...@@ -412,6 +418,10 @@ class Project extends CommonObject ...@@ -412,6 +418,10 @@ class Project extends CommonObject
{ {
$sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . $tablename." WHERE fk_projet=" . $this->id; $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 ($dates > 0)
{ {
if (empty($datefieldname) && ! empty($this->table_element_date)) $datefieldname=$this->table_element_date; if (empty($datefieldname) && ! empty($this->table_element_date)) $datefieldname=$this->table_element_date;
...@@ -424,10 +434,6 @@ class Project extends CommonObject ...@@ -424,10 +434,6 @@ class Project extends CommonObject
if (empty($datefieldname)) return 'Error this object has no date field defined'; if (empty($datefieldname)) return 'Error this object has no date field defined';
$sql.=" AND (".$datefieldname." <= '".$this->db->idate($datee)."' OR ".$datefieldname." IS NULL)"; $sql.=" AND (".$datefieldname." <= '".$this->db->idate($datee)."' OR ".$datefieldname." IS NULL)";
} }
if ($type == 'expensereport')
{
$sql ='eeee';
}
if (! $sql) return -1; if (! $sql) return -1;
//print $sql; //print $sql;
...@@ -842,6 +848,8 @@ class Project extends CommonObject ...@@ -842,6 +848,8 @@ class Project extends CommonObject
$this->date_m = $now; $this->date_m = $now;
$this->date_start = $now; $this->date_start = $now;
$this->note_public = 'SPECIMEN'; $this->note_public = 'SPECIMEN';
$this->budget_amount = 10000;
/* /*
$nbp = rand(1, 9); $nbp = rand(1, 9);
$xnbp = 0; $xnbp = 0;
...@@ -893,13 +901,6 @@ class Project extends CommonObject ...@@ -893,13 +901,6 @@ class Project extends CommonObject
if ($mode == 'write' && $user->rights->projet->creer) $userAccess++; if ($mode == 'write' && $user->rights->projet->creer) $userAccess++;
if ($mode == 'delete' && $user->rights->projet->supprimer) $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++; $nblinks++;
} }
} }
...@@ -945,11 +946,9 @@ class Project extends CommonObject ...@@ -945,11 +946,9 @@ class Project extends CommonObject
{ {
$sql.= " AND ec.element_id = p.rowid"; $sql.= " AND ec.element_id = p.rowid";
$sql.= " AND ( p.public = 1"; $sql.= " AND ( p.public = 1";
//$sql.= " OR p.fk_user_creat = ".$user->id;
$sql.= " OR ( ctc.rowid = ec.fk_c_type_contact"; $sql.= " OR ( ctc.rowid = ec.fk_c_type_contact";
$sql.= " AND ctc.element = '" . $this->element . "'"; $sql.= " AND ctc.element = '" . $this->element . "'";
$sql.= " AND ( (ctc.source = 'internal' AND ec.fk_socpeople = ".$user->id.")"; $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.= " )";
$sql.= " ))"; $sql.= " ))";
} }
...@@ -959,7 +958,6 @@ class Project extends CommonObject ...@@ -959,7 +958,6 @@ class Project extends CommonObject
$sql.= " AND ctc.rowid = ec.fk_c_type_contact"; $sql.= " AND ctc.rowid = ec.fk_c_type_contact";
$sql.= " AND ctc.element = '" . $this->element . "'"; $sql.= " AND ctc.element = '" . $this->element . "'";
$sql.= " AND ( (ctc.source = 'internal' AND ec.fk_socpeople = ".$user->id.")"; $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.= " )";
} }
if ($mode == 2) if ($mode == 2)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment