diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index 15b66e4b695..269f63c862b 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -416,7 +416,7 @@ function dol_print_date($time,$format='',$to_gmt=false,$outputlangs='',$encodeto // Analyse de la date (deprecated) Ex: 19700101, 19700101010000 if (eregi('^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?',$time,$reg) - || eregi('^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$',$time,$reg)) + || eregi('^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$',$time,$reg)) { // This part of code should not be used. dol_syslog("Functions.lib::dol_print_date function call with deprecated value of time in page ".$_SERVER["PHP_SELF"], LOG_WARNING); @@ -705,7 +705,7 @@ function dol_print_email($email,$cid=0,$socid=0,$addlink=0,$max=64) $newemail=$email; - if (empty($email)) return ' '; + if (empty($email)) return ' '; if (! empty($addlink)) { @@ -1439,14 +1439,17 @@ function restrictedArea($user, $feature='societe', $objectid=0, $dbtablename='', if (empty($user->rights->$feature->lire) && empty($user->rights->$feature->read)) $readok=0; } - //print "Read access is down"; - if (! $readok) accessforbidden(); + if (! $readok) + { + //print "Read access is down"; + accessforbidden(); + } //print "Read access is ok"; // Check write permission from module $createok=1; if ( (isset($_GET["action"]) && $_GET["action"] == 'create') - || (isset($_POST["action"]) && $_POST["action"] == 'create') ) + || (isset($_POST["action"]) && $_POST["action"] == 'create') ) { if ($feature == 'societe') { @@ -1506,7 +1509,7 @@ function restrictedArea($user, $feature='societe', $objectid=0, $dbtablename='', $sql.= " WHERE dbt.".$dbt_select." = ".$objectid; $sql.= " AND dbt.entity IN (0,".$conf->entity.")"; } - else if ($feature == 'societe') + else if ($feature == 'societe') { // If external user: Check permission for external users if ($user->societe_id > 0) @@ -1654,7 +1657,7 @@ function dol_print_error($db='',$error='') { print $langs->trans("DolibarrHasDetectedError").".
\n"; if (! empty($conf->global->MAIN_FEATURES_LEVEL)) - print "You use an experimental level of features, so please do NOT report any bugs, anywhere, until going back to MAIN_FEATURES_LEVEL = 0.
\n"; + print "You use an experimental level of features, so please do NOT report any bugs, anywhere, until going back to MAIN_FEATURES_LEVEL = 0.
\n"; print $langs->trans("InformationToHelpDiagnose").":
\n"; print "".$langs->trans("Dolibarr").": ".DOL_VERSION."
\n";; diff --git a/htdocs/project.class.php b/htdocs/project.class.php index 0fa3b46065c..9fafb3a2940 100644 --- a/htdocs/project.class.php +++ b/htdocs/project.class.php @@ -41,6 +41,9 @@ class Project extends CommonObject var $id; var $ref; var $title; + var $date_c; + var $date_m; + var $date_start; var $socid; var $user_resp_id; @@ -70,12 +73,14 @@ class Project extends CommonObject return -1; } - $sql = "INSERT INTO ".MAIN_DB_PREFIX."projet (ref, title, fk_soc, fk_user_creat, fk_user_resp, dateo, fk_statut)"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."projet (ref, title, fk_soc, fk_user_creat, fk_user_resp, datec, dateo, fk_statut)"; $sql.= " VALUES ('".addslashes($this->ref)."', '".addslashes($this->title)."',"; $sql.= " ".($this->socid > 0?$this->socid:"null").","; $sql.= " ".$user->id.","; $sql.= " ".($this->user_resp_id>0?$this->user_resp_id:'null').","; - $sql.= " ".$this->db->idate(mktime()).", 0)"; + $sql.= " ".($this->datec!=''?$this->db->idate($this->datec):'null').","; + $sql.= " ".($this->dateo!=''?$this->db->idate($this->dateo):'null').","; + $sql.= " 0)"; dol_syslog("Project::create sql=".$sql,LOG_DEBUG); $resql=$this->db->query($sql); @@ -86,8 +91,8 @@ class Project extends CommonObject } else { - dol_syslog("Project::Create error -2"); - $this->error=$this->db->error(); + $this->error=$this->db->lasterror(); + dol_syslog("Project::Create error -2 ".$this->error, LOG_ERR); $result = -2; } @@ -104,16 +109,19 @@ class Project extends CommonObject $sql.= ", title = '".$this->title."'"; $sql.= ", fk_soc = ".($this->socid > 0?$this->socid:"null"); $sql.= ", fk_user_resp = ".$this->user_resp_id; + $sql.= ", datec=".($this->datec!=''?$this->db->idate($this->datec):'null'); + $sql.= ", dateo=".($this->dateo!=''?$this->db->idate($this->dateo):'null'); $sql.= " WHERE rowid = ".$this->id; - dol_syslog("Project::update sql=".$sql,LOG_DEBUG); + dol_syslog("Project::Update sql=".$sql,LOG_DEBUG); if ($this->db->query($sql) ) { $result = 0; } else { - dol_syslog($this->db->error()); + $this->error=$this->db->lasterror(); + dol_syslog("Project::Update error -2 ".$this->error, LOG_ERR); $result = -2; } } @@ -135,7 +143,7 @@ class Project extends CommonObject */ function fetch($id,$ref='') { - $sql = "SELECT rowid, ref, title, fk_soc, fk_user_creat, fk_user_resp, fk_statut, note"; + $sql = "SELECT rowid, ref, title, datec, tms, dateo, fk_soc, fk_user_creat, fk_user_resp, fk_statut, note"; $sql.= " FROM ".MAIN_DB_PREFIX."projet"; if ($ref) $sql.= " WHERE ref='".$ref."'"; else $sql.= " WHERE rowid=".$id; @@ -152,6 +160,9 @@ class Project extends CommonObject $this->ref = $obj->ref; $this->title = $obj->title; $this->titre = $obj->title; + $this->date_c = $this->db->jdate($obj->datec); + $this->date_m = $this->db->jdate($obj->tms); + $this->date_start = $this->db->jdate($obj->dateo); $this->note = $obj->note; $this->socid = $obj->fk_soc; $this->societe->id = $obj->fk_soc; // For backward compatibility @@ -170,7 +181,8 @@ class Project extends CommonObject } else { - print $this->db->error(); + $this->error=$this->db->lasterror(); + dol_syslog("Project::fetch ".$this->error, LOG_ERR); return -2; } } @@ -210,7 +222,7 @@ class Project extends CommonObject } else { - print $this->db->error(); + print $this->db->lasterror(); } } @@ -325,7 +337,7 @@ class Project extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task_actors (fk_projet_task, fk_user)"; $sql.= " VALUES (".$task_id.",".($id_resp>0?$id_resp:'null').")"; - dol_syslog("Project::CreateTask sql=".$sql,LOG_DEBUG); + dol_syslog("Project::CreateTask sql=".$sql, LOG_DEBUG); if ($this->db->query($sql) ) { $this->db->commit(); @@ -334,7 +346,7 @@ class Project extends CommonObject else { $this->error=$this->db->lasterror(); - dol_syslog("Project::CreateTask error -3 ".$this->error,LOG_ERR); + dol_syslog("Project::CreateTask error -3 ".$this->error, LOG_ERR); $this->db->rollback(); return -3; } @@ -383,8 +395,8 @@ class Project extends CommonObject } else { - dol_syslog("Project::TaskAddTime error -2",LOG_ERR); - $this->error=$this->db->error(); + $this->error=$this->db->lasterror(); + dol_syslog("Project::TaskAddTime error -2 ".$this->error,LOG_ERR); $result = -2; } @@ -401,8 +413,8 @@ class Project extends CommonObject } else { - dol_syslog("Project::TaskAddTime error -3",LOG_ERR); - $this->error=$this->db->error(); + $this->error=$this->db->lasterror(); + dol_syslog("Project::TaskAddTime error -3 ".$this->error, LOG_ERR); $result = -2; } } diff --git a/htdocs/projet/fiche.php b/htdocs/projet/fiche.php index 9065b8a8617..da7db1e8a75 100644 --- a/htdocs/projet/fiche.php +++ b/htdocs/projet/fiche.php @@ -57,21 +57,24 @@ $result = restrictedArea($user, 'projet', $projetid); if ($_POST["action"] == 'add' && $user->rights->projet->creer) { //print $_POST["socid"]; - $pro = new Project($db); - $pro->ref = $_POST["ref"]; - $pro->title = $_POST["title"]; - $pro->socid = $_POST["socid"]; - $pro->user_resp_id = $_POST["officer_project"]; - $result = $pro->create($user); + $project = new Project($db); + $project->ref = $_POST["ref"]; + $project->title = $_POST["title"]; + $project->socid = $_POST["socid"]; + $project->user_resp_id = $_POST["officer_project"]; + $project->dateo=dol_mktime(12,0,0,$_POST['projectmonth'],$_POST['projectday'],$_POST['projectyear']); + $project->datec=dol_now('tzserver'); + + $result = $project->create($user); if ($result > 0) { - Header("Location:fiche.php?id=".$pro->id); + Header("Location:fiche.php?id=".$project->id); exit; } else { $langs->load("errors"); - $mesg='
'.$langs->trans($pro->error).'
'; + $mesg='
'.$langs->trans($project->error).'
'; $_GET["action"] = 'create'; } } @@ -101,6 +104,8 @@ if ($_POST["action"] == 'update' && $user->rights->projet->creer) $projet->title = $_POST["title"]; $projet->socid = $_POST["socid"]; $projet->user_resp_id = $_POST["officer_project"]; + $projet->dateo = dol_mktime(12,0,0,$_POST['projectmonth'],$_POST['projectday'],$_POST['projectyear']); + $projet->update($user); $_GET["id"]=$projet->id; // On retourne sur la fiche projet @@ -177,6 +182,11 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer) } print ''; + // Date + print ''.$langs->trans("DateStart").''; + print $html->select_date('','project'); + print ''; + print ''; print ''; print ''; @@ -230,6 +240,11 @@ else $html->select_users($projet->user_resp_id,'officer_project',1); print ''; + // Date + print ''.$langs->trans("DateStart").''; + print $html->select_date($projet->date_start,'project'); + print ''; + print '   '; print ''; print ''; @@ -258,6 +273,11 @@ else else print $langs->trans('SharedProject'); print ''; + // Date + print ''.$langs->trans("DateStart").''; + print dol_print_date($projet->date_start,'day'); + print ''; + print ''; } diff --git a/mysql/migration/2.6.0-2.7.0.sql b/mysql/migration/2.6.0-2.7.0.sql index 943e9b4cd91..9d23e74a559 100644 --- a/mysql/migration/2.6.0-2.7.0.sql +++ b/mysql/migration/2.6.0-2.7.0.sql @@ -242,3 +242,7 @@ alter table llx_facture_fourn_det add column label varchar(255) afte alter table llx_societe_rib modify column iban_prefix varchar(34); alter table llx_bank_account modify column iban_prefix varchar(34); + + +alter table llx_projet add column datec date after fk_statut; + diff --git a/mysql/tables/llx_projet.sql b/mysql/tables/llx_projet.sql index 7fdb45fbe9c..01cc7457c10 100644 --- a/mysql/tables/llx_projet.sql +++ b/mysql/tables/llx_projet.sql @@ -23,8 +23,9 @@ create table llx_projet rowid integer AUTO_INCREMENT PRIMARY KEY, fk_soc integer, fk_statut smallint NOT NULL, + datec date, -- date creation project tms timestamp, - dateo date, -- date d'ouverture du projet + dateo date, -- date start project ref varchar(50), entity integer DEFAULT 1 NOT NULL, -- multi company id title varchar(255),