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

@@ -1439,8 +1439,11 @@ function restrictedArea($user, $feature='societe', $objectid=0, $dbtablename='',
if (empty($user->rights->$feature->lire)
&& empty($user->rights->$feature->read)) $readok=0;
}
if (! $readok)
{
//print "Read access is down";
if (! $readok) accessforbidden();
accessforbidden();
}
//print "Read access is ok";
// Check write permission from module

View File

@@ -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();
}
}
@@ -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;
}
}

View File

@@ -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='<div class="error">'.$langs->trans($pro->error).'</div>';
$mesg='<div class="error">'.$langs->trans($project->error).'</div>';
$_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 '</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 '</table>';
print '</form>';
@@ -230,6 +240,11 @@ else
$html->select_users($projet->user_resp_id,'officer_project',1);
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 '</table>';
print '</form>';
@@ -258,6 +273,11 @@ else
else print $langs->trans('SharedProject');
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>';
}

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_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,
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),