2
0
forked from Wavyzz/dolibarr

New: Enhancement in project module

This commit is contained in:
Laurent Destailleur
2009-07-28 18:12:47 +00:00
parent 351e612563
commit 093b88ad8d
5 changed files with 71 additions and 31 deletions

View File

@@ -416,7 +416,7 @@ function dol_print_date($time,$format='',$to_gmt=false,$outputlangs='',$encodeto
// Analyse de la date (deprecated) Ex: 19700101, 19700101010000 // Analyse de la date (deprecated) Ex: 19700101, 19700101010000
if (eregi('^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?',$time,$reg) 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. // 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); 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; $newemail=$email;
if (empty($email)) return ' '; if (empty($email)) return ' ';
if (! empty($addlink)) if (! empty($addlink))
{ {
@@ -1439,14 +1439,17 @@ function restrictedArea($user, $feature='societe', $objectid=0, $dbtablename='',
if (empty($user->rights->$feature->lire) if (empty($user->rights->$feature->lire)
&& empty($user->rights->$feature->read)) $readok=0; && empty($user->rights->$feature->read)) $readok=0;
} }
//print "Read access is down"; if (! $readok)
if (! $readok) accessforbidden(); {
//print "Read access is down";
accessforbidden();
}
//print "Read access is ok"; //print "Read access is ok";
// Check write permission from module // Check write permission from module
$createok=1; $createok=1;
if ( (isset($_GET["action"]) && $_GET["action"] == 'create') if ( (isset($_GET["action"]) && $_GET["action"] == 'create')
|| (isset($_POST["action"]) && $_POST["action"] == 'create') ) || (isset($_POST["action"]) && $_POST["action"] == 'create') )
{ {
if ($feature == 'societe') if ($feature == 'societe')
{ {
@@ -1506,7 +1509,7 @@ function restrictedArea($user, $feature='societe', $objectid=0, $dbtablename='',
$sql.= " WHERE dbt.".$dbt_select." = ".$objectid; $sql.= " WHERE dbt.".$dbt_select." = ".$objectid;
$sql.= " AND dbt.entity IN (0,".$conf->entity.")"; $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 external user: Check permission for external users
if ($user->societe_id > 0) if ($user->societe_id > 0)
@@ -1654,7 +1657,7 @@ function dol_print_error($db='',$error='')
{ {
print $langs->trans("DolibarrHasDetectedError").".<br>\n"; print $langs->trans("DolibarrHasDetectedError").".<br>\n";
if (! empty($conf->global->MAIN_FEATURES_LEVEL)) 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.<br>\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.<br>\n";
print $langs->trans("InformationToHelpDiagnose").":<br>\n"; print $langs->trans("InformationToHelpDiagnose").":<br>\n";
print "<b>".$langs->trans("Dolibarr").":</b> ".DOL_VERSION."<br>\n";; print "<b>".$langs->trans("Dolibarr").":</b> ".DOL_VERSION."<br>\n";;

View File

@@ -41,6 +41,9 @@ class Project extends CommonObject
var $id; var $id;
var $ref; var $ref;
var $title; var $title;
var $date_c;
var $date_m;
var $date_start;
var $socid; var $socid;
var $user_resp_id; var $user_resp_id;
@@ -70,12 +73,14 @@ class Project extends CommonObject
return -1; 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.= " VALUES ('".addslashes($this->ref)."', '".addslashes($this->title)."',";
$sql.= " ".($this->socid > 0?$this->socid:"null").","; $sql.= " ".($this->socid > 0?$this->socid:"null").",";
$sql.= " ".$user->id.","; $sql.= " ".$user->id.",";
$sql.= " ".($this->user_resp_id>0?$this->user_resp_id:'null').","; $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); dol_syslog("Project::create sql=".$sql,LOG_DEBUG);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
@@ -86,8 +91,8 @@ class Project extends CommonObject
} }
else else
{ {
dol_syslog("Project::Create error -2"); $this->error=$this->db->lasterror();
$this->error=$this->db->error(); dol_syslog("Project::Create error -2 ".$this->error, LOG_ERR);
$result = -2; $result = -2;
} }
@@ -104,16 +109,19 @@ class Project extends CommonObject
$sql.= ", title = '".$this->title."'"; $sql.= ", title = '".$this->title."'";
$sql.= ", fk_soc = ".($this->socid > 0?$this->socid:"null"); $sql.= ", fk_soc = ".($this->socid > 0?$this->socid:"null");
$sql.= ", fk_user_resp = ".$this->user_resp_id; $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; $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) ) if ($this->db->query($sql) )
{ {
$result = 0; $result = 0;
} }
else else
{ {
dol_syslog($this->db->error()); $this->error=$this->db->lasterror();
dol_syslog("Project::Update error -2 ".$this->error, LOG_ERR);
$result = -2; $result = -2;
} }
} }
@@ -135,7 +143,7 @@ class Project extends CommonObject
*/ */
function fetch($id,$ref='') 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"; $sql.= " FROM ".MAIN_DB_PREFIX."projet";
if ($ref) $sql.= " WHERE ref='".$ref."'"; if ($ref) $sql.= " WHERE ref='".$ref."'";
else $sql.= " WHERE rowid=".$id; else $sql.= " WHERE rowid=".$id;
@@ -152,6 +160,9 @@ class Project extends CommonObject
$this->ref = $obj->ref; $this->ref = $obj->ref;
$this->title = $obj->title; $this->title = $obj->title;
$this->titre = $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->note = $obj->note;
$this->socid = $obj->fk_soc; $this->socid = $obj->fk_soc;
$this->societe->id = $obj->fk_soc; // For backward compatibility $this->societe->id = $obj->fk_soc; // For backward compatibility
@@ -170,7 +181,8 @@ class Project extends CommonObject
} }
else else
{ {
print $this->db->error(); $this->error=$this->db->lasterror();
dol_syslog("Project::fetch ".$this->error, LOG_ERR);
return -2; return -2;
} }
} }
@@ -210,7 +222,7 @@ class Project extends CommonObject
} }
else 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 = "INSERT INTO ".MAIN_DB_PREFIX."projet_task_actors (fk_projet_task, fk_user)";
$sql.= " VALUES (".$task_id.",".($id_resp>0?$id_resp:'null').")"; $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) ) if ($this->db->query($sql) )
{ {
$this->db->commit(); $this->db->commit();
@@ -334,7 +346,7 @@ class Project extends CommonObject
else else
{ {
$this->error=$this->db->lasterror(); $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(); $this->db->rollback();
return -3; return -3;
} }
@@ -383,8 +395,8 @@ class Project extends CommonObject
} }
else else
{ {
dol_syslog("Project::TaskAddTime error -2",LOG_ERR); $this->error=$this->db->lasterror();
$this->error=$this->db->error(); dol_syslog("Project::TaskAddTime error -2 ".$this->error,LOG_ERR);
$result = -2; $result = -2;
} }
@@ -401,8 +413,8 @@ class Project extends CommonObject
} }
else else
{ {
dol_syslog("Project::TaskAddTime error -3",LOG_ERR); $this->error=$this->db->lasterror();
$this->error=$this->db->error(); dol_syslog("Project::TaskAddTime error -3 ".$this->error, LOG_ERR);
$result = -2; $result = -2;
} }
} }

View File

@@ -57,21 +57,24 @@ $result = restrictedArea($user, 'projet', $projetid);
if ($_POST["action"] == 'add' && $user->rights->projet->creer) if ($_POST["action"] == 'add' && $user->rights->projet->creer)
{ {
//print $_POST["socid"]; //print $_POST["socid"];
$pro = new Project($db); $project = new Project($db);
$pro->ref = $_POST["ref"]; $project->ref = $_POST["ref"];
$pro->title = $_POST["title"]; $project->title = $_POST["title"];
$pro->socid = $_POST["socid"]; $project->socid = $_POST["socid"];
$pro->user_resp_id = $_POST["officer_project"]; $project->user_resp_id = $_POST["officer_project"];
$result = $pro->create($user); $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) if ($result > 0)
{ {
Header("Location:fiche.php?id=".$pro->id); Header("Location:fiche.php?id=".$project->id);
exit; exit;
} }
else else
{ {
$langs->load("errors"); $langs->load("errors");
$mesg='<div class="error">'.$langs->trans($pro->error).'</div>'; $mesg='<div class="error">'.$langs->trans($project->error).'</div>';
$_GET["action"] = 'create'; $_GET["action"] = 'create';
} }
} }
@@ -101,6 +104,8 @@ if ($_POST["action"] == 'update' && $user->rights->projet->creer)
$projet->title = $_POST["title"]; $projet->title = $_POST["title"];
$projet->socid = $_POST["socid"]; $projet->socid = $_POST["socid"];
$projet->user_resp_id = $_POST["officer_project"]; $projet->user_resp_id = $_POST["officer_project"];
$projet->dateo = dol_mktime(12,0,0,$_POST['projectmonth'],$_POST['projectday'],$_POST['projectyear']);
$projet->update($user); $projet->update($user);
$_GET["id"]=$projet->id; // On retourne sur la fiche projet $_GET["id"]=$projet->id; // On retourne sur la fiche projet
@@ -177,6 +182,11 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer)
} }
print '</td></tr>'; print '</td></tr>';
// Date
print '<tr><td>'.$langs->trans("DateStart").'</td><td>';
print $html->select_date('','project');
print '</td></tr>';
print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Create").'"></td></tr>'; print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Create").'"></td></tr>';
print '</table>'; print '</table>';
print '</form>'; print '</form>';
@@ -230,6 +240,11 @@ else
$html->select_users($projet->user_resp_id,'officer_project',1); $html->select_users($projet->user_resp_id,'officer_project',1);
print '</td></tr>'; print '</td></tr>';
// Date
print '<tr><td>'.$langs->trans("DateStart").'</td><td>';
print $html->select_date($projet->date_start,'project');
print '</td></tr>';
print '<tr><td align="center" colspan="2"><input name="update" class="button" type="submit" value="'.$langs->trans("Modify").'"> &nbsp; <input type="submit" class="button" name="cancel" Value="'.$langs->trans("Cancel").'"></td></tr>'; print '<tr><td align="center" colspan="2"><input name="update" class="button" type="submit" value="'.$langs->trans("Modify").'"> &nbsp; <input type="submit" class="button" name="cancel" Value="'.$langs->trans("Cancel").'"></td></tr>';
print '</table>'; print '</table>';
print '</form>'; print '</form>';
@@ -258,6 +273,11 @@ else
else print $langs->trans('SharedProject'); else print $langs->trans('SharedProject');
print '</td></tr>'; print '</td></tr>';
// Date
print '<tr><td>'.$langs->trans("DateStart").'</td><td>';
print dol_print_date($projet->date_start,'day');
print '</td></tr>';
print '</table>'; print '</table>';
} }

View File

@@ -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_societe_rib modify column iban_prefix varchar(34);
alter table llx_bank_account 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;

View File

@@ -23,8 +23,9 @@ create table llx_projet
rowid integer AUTO_INCREMENT PRIMARY KEY, rowid integer AUTO_INCREMENT PRIMARY KEY,
fk_soc integer, fk_soc integer,
fk_statut smallint NOT NULL, fk_statut smallint NOT NULL,
datec date, -- date creation project
tms timestamp, tms timestamp,
dateo date, -- date d'ouverture du projet dateo date, -- date start project
ref varchar(50), ref varchar(50),
entity integer DEFAULT 1 NOT NULL, -- multi company id entity integer DEFAULT 1 NOT NULL, -- multi company id
title varchar(255), title varchar(255),