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

NEW: Add close date and user for projects.

parent 4c1d51bd
No related branches found
No related tags found
No related merge requests found
......@@ -227,3 +227,8 @@ ALTER TABLE llx_commande_fournisseurdet ADD COLUMN special_code integer DEFAULT
ALTER TABLE llx_commande_fournisseurdet ADD COLUMN rang integer DEFAULT 0;
ALTER TABLE llx_commande_fournisseurdet ADD COLUMN fk_parent_line integer NULL after fk_commande;
ALTER TABLE llx_projet ADD COLUMN date_close datetime DEFAULT NULL;
ALTER TABLE llx_projet ADD COLUMN fk_user_close integer DEFAULT NULL;
\ No newline at end of file
......@@ -32,6 +32,8 @@ create table llx_projet
fk_user_creat integer NOT NULL, -- createur du projet
public integer, -- project is public or not
fk_statut smallint DEFAULT 0 NOT NULL,
date_close datetime DEFAULT NULL,
fk_user_close integer DEFAULT NULL,
note_private text,
note_public text,
--budget_days real, -- budget in days is sum of field planned_workload of tasks
......
......@@ -49,8 +49,10 @@ class Project extends CommonObject
var $title;
var $date_start;
var $date_end;
var $date_close;
var $socid;
var $user_author_id; //!< Id of project creator. Not defined if shared project.
var $user_close_id;
var $public; //!< Tell if this is a public or private project
var $note_private;
var $note_public;
......@@ -212,6 +214,8 @@ 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.= ", date_close=" . ($this->date_close != '' ? "'".$this->db->idate($this->date_close)."'" : 'null');
$sql.= ", fk_user_close=" . ($this->fk_user_close > 0 ? $this->fk_user_close : "null");
$sql.= ", budget_amount = " . ($this->budget_amount > 0 ? $this->budget_amount : "null");
$sql.= " WHERE rowid = " . $this->id;
......@@ -299,7 +303,7 @@ class Project extends CommonObject
if (empty($id) && empty($ref)) return -1;
$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, date_close, fk_soc, fk_user_creat, fk_user_close, fk_statut, note_private, note_public,model_pdf";
$sql.= " FROM " . MAIN_DB_PREFIX . "projet";
if (! empty($id))
{
......@@ -330,10 +334,12 @@ class Project extends CommonObject
$this->datem = $this->db->jdate($obj->tms); // TODO deprecated
$this->date_start = $this->db->jdate($obj->dateo);
$this->date_end = $this->db->jdate($obj->datee);
$this->date_close = $this->db->jdate($obj->date_close);
$this->note_private = $obj->note_private;
$this->note_public = $obj->note_public;
$this->socid = $obj->fk_soc;
$this->user_author_id = $obj->fk_user_creat;
$this->user_close_id = $obj->fk_user_close;
$this->public = $obj->public;
$this->statut = $obj->fk_statut;
$this->budget_amount = $obj->budget_amount;
......@@ -682,13 +688,15 @@ class Project extends CommonObject
/**
* Close a project
*
* @param User $user User that validate
* @param User $user User that close project
* @return int <0 if KO, >0 if OK
*/
function setClose($user)
{
global $langs, $conf;
$now = dol_now();
$error=0;
if ($this->statut != 2)
......@@ -696,7 +704,7 @@ class Project extends CommonObject
$this->db->begin();
$sql = "UPDATE " . MAIN_DB_PREFIX . "projet";
$sql.= " SET fk_statut = 2";
$sql.= " SET fk_statut = 2, fk_user_close = ".$user->id.", date_close = '".$this->db->idate($now)."'";
$sql.= " WHERE rowid = " . $this->id;
$sql.= " AND entity = " . $conf->entity;
$sql.= " AND fk_statut = 1";
......
......@@ -189,7 +189,7 @@ class ProjectTest extends PHPUnit_Framework_TestCase
}
/**
* testProjectOther
* testProjectClose
*
* @param Project $localobject Project
* @return int
......@@ -205,6 +205,10 @@ class ProjectTest extends PHPUnit_Framework_TestCase
$langs=$this->savlangs;
$db=$this->savdb;
$result=$localobject->setClose($user);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0);
return $localobject->id;
}
......@@ -214,7 +218,7 @@ class ProjectTest extends PHPUnit_Framework_TestCase
* @param int $id Id of project
* @return void
*
* @depends testProjectOther
* @depends testProjectClose
* The depends says test is run only if previous is ok
*/
public function testProjectDelete($id)
......
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