Add patch sladame

This commit is contained in:
Laurent Destailleur 2008-08-25 22:14:58 +00:00
parent 27da67a76f
commit 14dd4191ec
3 changed files with 83 additions and 75 deletions

View File

@ -280,9 +280,10 @@ class Project extends CommonObject
$result = 0; $result = 0;
if (trim($title)) if (trim($title))
{ {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task (fk_projet, title, fk_user_creat, fk_task_parent) "; $sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task (fk_projet, title, fk_user_creat, fk_task_parent, duration_effective)";
$sql .= " VALUES (".$this->id.",'$title', ".$user->id.",".$parent.") ;"; $sql.= " VALUES (".$this->id.",'$title', ".$user->id.",".$parent.", 0)";
dolibarr_syslog("Project::CreateTask sql=".$sql,LOG_DEBUG);
if ($this->db->query($sql) ) if ($this->db->query($sql) )
{ {
$task_id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task"); $task_id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task");
@ -290,26 +291,25 @@ class Project extends CommonObject
} }
else else
{ {
dolibarr_syslog("Project::CreateTask error -2",LOG_ERR);
dolibarr_syslog($this->db->error(),LOG_ERR);
$this->error=$this->db->error(); $this->error=$this->db->error();
dolibarr_syslog("Project::CreateTask error -2 ".$this->error,LOG_ERR);
$result = -2; $result = -2;
} }
if ($result == 0) if ($result == 0)
{ {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task_actors (fk_projet_task, fk_user)";
$sql.= " VALUES (".$task_id.",".$user->id.")";
$sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task_actors (fk_projet_task, fk_user) "; dolibarr_syslog("Project::CreateTask sql=".$sql,LOG_DEBUG);
$sql .= " VALUES (".$task_id.",".$user->id.") ;";
if ($this->db->query($sql) ) if ($this->db->query($sql) )
{ {
$result = 0; $result = 0;
} }
else else
{ {
dolibarr_syslog("Project::CreateTask error -3",LOG_ERR);
$this->error=$this->db->error(); $this->error=$this->db->error();
dolibarr_syslog("Project::CreateTask error -3 ".$this->error,LOG_ERR);
$result = -2; $result = -2;
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -19,11 +19,11 @@
*/ */
/** /**
\file htdocs/projet/tasks/fiche.php \file htdocs/projet/tasks/fiche.php
\ingroup projet \ingroup projet
\brief Fiche taches d'un projet \brief Fiche taches d'un projet
\version $Id$ \version $Id$
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php");
@ -46,6 +46,8 @@ Function PLines(&$inc, $parent, $lines, &$level, $tasksrole)
$form = new Form($db); // $db est null ici mais inutile pour la fonction select_date() $form = new Form($db); // $db est null ici mais inutile pour la fonction select_date()
global $user, $bc, $langs; global $user, $bc, $langs;
$var=true;
for ($i = 0 ; $i < sizeof($lines) ; $i++) for ($i = 0 ; $i < sizeof($lines) ; $i++)
{ {
if ($parent == 0) if ($parent == 0)
@ -68,16 +70,18 @@ Function PLines(&$inc, $parent, $lines, &$level, $tasksrole)
print '<a href="task.php?id='.$lines[$i]->id.'">'.$lines[$i]->title."</a></td>\n"; print '<a href="task.php?id='.$lines[$i]->id.'">'.$lines[$i]->title."</a></td>\n";
$heure = intval($lines[$i]->duration); $heure = intval($lines[$i]->duration);
$minutes = (($lines[$i]->duration - $heure) * 60); $minutes = round((($lines[$i]->duration - $heure) * 60),0);
$minutes = substr("00"."$minutes", -2); $minutes = substr("00"."$minutes", -2);
print '<td align="right">'.$heure."&nbsp;h&nbsp;".$minutes."</td>\n"; print '<td align="right">'.$heure."&nbsp;h&nbsp;".$minutes."</td>\n";
if ($tasksrole[$lines[$i]->id] == 'admin') if ($tasksrole[$lines[$i]->id] == 'admin')
{ {
print '<td><input size="4" type="text" class="flat" name="task'.$lines[$i]->id.'" value="">'; print '<td>';
print '&nbsp;<input type="submit" class="button" value="'.$langs->trans("Save").'"></td>'; print '<input size="4" type="text" class="flat" name="task'.$lines[$i]->id.'" value="">';
print "\n<td>"; print '&nbsp;<input type="submit" class="button" value="'.$langs->trans("Save").'">';
print '</td>';
print "<td>";
print $form->select_date('',$lines[$i]->id,'','','',"addtime"); print $form->select_date('',$lines[$i]->id,'','','',"addtime");
print '</td>'; print '</td>';
} }
@ -128,44 +132,47 @@ Function PLineSelect(&$inc, $parent, $lines, &$level)
if ($_POST["action"] == 'createtask' && $user->rights->projet->creer) if ($_POST["action"] == 'createtask' && $user->rights->projet->creer)
{ {
$project = new Project($db); $project = new Project($db);
$result = $project->fetch($_GET["id"]); $result = $project->fetch($_GET["id"]);
if ($result == 0) if ($result == 0)
{ {
$task_parent = $_POST["task_parent"]?$_POST["task_parent"]:0; $task_parent = $_POST["task_parent"]?$_POST["task_parent"]:0;
$project->CreateTask($user, $_POST["task_name"], $task_parent); $project->CreateTask($user, $_POST["task_name"], $task_parent);
Header("Location:fiche.php?id=".$project->id); Header("Location:fiche.php?id=".$project->id);
} }
} }
if ($_POST["action"] == 'addtime' && $user->rights->projet->creer) if ($_POST["action"] == 'addtime' && $user->rights->projet->creer)
{ {
$project = new Project($db); $project = new Project($db);
$result = $project->fetch($_GET["id"]); $result = $project->fetch($_GET["id"]);
if ($result == 0) if ($result == 0)
{
foreach ($_POST as $key => $post)
{ {
//$pro->CreateTask($user, $_POST["task_name"]); foreach ($_POST as $key => $post)
if (substr($key,0,4) == 'task')
{
if ($post > 0)
{ {
$id = ereg_replace("task","",$key); //$pro->CreateTask($user, $_POST["task_name"]);
if (substr($key,0,4) == 'task')
{
if ($post > 0)
{
$post=intval($post)+(($post-intval($post))*(1+2/3));
$post=price2num($post);
$date = mktime(12,12,12,$_POST["$id"."month"],$_POST["$id"."day"],$_POST["$id"."year"]); $id = ereg_replace("task","",$key);
$project->TaskAddTime($user, $id , $post, $date);
$date = dolibarr_mktime(12,0,0,$_POST["$id"."month"],$_POST["$id"."day"],$_POST["$id"."year"]);
$project->TaskAddTime($user, $id , $post, $date);
}
}
} }
}
}
Header("Location:fiche.php?id=".$project->id); Header("Location:fiche.php?id=".$project->id);
exit; exit;
} }
} }
@ -175,36 +182,36 @@ llxHeader("",$langs->trans("Tasks"),"Tasks");
if ($_GET["action"] == 'create' && $user->rights->projet->creer) if ($_GET["action"] == 'create' && $user->rights->projet->creer)
{ {
print_titre($langs->trans("NewTask")); print_titre($langs->trans("NewTask"));
if ($mesg) print $mesg; if ($mesg) print $mesg;
print '<form action="fiche.php?socid='.$_GET["socid"].'" method="post">'; print '<form action="fiche.php?socid='.$_GET["socid"].'" method="post">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
print '<tr><td>'.$langs->trans("Ref").'</td><td><input size="10" type="text" name="ref"></td></tr>'; print '<tr><td>'.$langs->trans("Ref").'</td><td><input size="10" type="text" name="ref"></td></tr>';
print '<tr><td>'.$langs->trans("Label").'</td><td><input size="30" type="text" name="title"></td></tr>'; print '<tr><td>'.$langs->trans("Label").'</td><td><input size="30" type="text" name="title"></td></tr>';
print '<tr><td>'.$langs->trans("Company").'</td><td>'; print '<tr><td>'.$langs->trans("Company").'</td><td>';
$societe = new Societe($db); $societe = new Societe($db);
$societe->fetch($_GET["socid"]); $societe->fetch($_GET["socid"]);
print $societe->getNomUrl(1); print $societe->getNomUrl(1);
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans("Author").'</td><td>'.$user->fullname.'</td></tr>'; print '<tr><td>'.$langs->trans("Author").'</td><td>'.$user->fullname.'</td></tr>';
print '<tr><td colspan="2" align="center"><input type="submit" value="'.$langs->trans("Create").'"></td></tr>'; print '<tr><td colspan="2" align="center"><input type="submit" value="'.$langs->trans("Create").'"></td></tr>';
print '</table>'; print '</table>';
print '</form>'; print '</form>';
} else { } else {
/* /*
* Fiche projet en mode visu * Fiche projet en mode visu
* *
*/ */
$projet = new Project($db); $projet = new Project($db);
$projet->fetch($_GET["id"]); $projet->fetch($_GET["id"]);
@ -227,7 +234,7 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer)
$tasksarray=$projet->getTasksArray(); $tasksarray=$projet->getTasksArray();
/* Nouvelle t<EFBFBD>che */ /* Nouvelle tache */
print '<tr><td>'.$langs->trans("NewTask").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("NewTask").'</td><td colspan="3">';
print '<input type="text" size="25" name="task_name" class="flat">&nbsp;'; print '<input type="text" size="25" name="task_name" class="flat">&nbsp;';
if ($tasksarray) if ($tasksarray)
@ -240,7 +247,7 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer)
print '&nbsp;<input type="submit" class="button" value="'.$langs->trans("Add").'">'; print '&nbsp;<input type="submit" class="button" value="'.$langs->trans("Add").'">';
print '</td></tr>'; print '</td></tr>';
print '</table></form><br />'; print '</table></form><br>';
print '<form name="addtime" method="POST" action="fiche.php?id='.$projet->id.'">'; print '<form name="addtime" method="POST" action="fiche.php?id='.$projet->id.'">';
print '<input type="hidden" name="action" value="addtime">'; print '<input type="hidden" name="action" value="addtime">';

View File

@ -15,16 +15,13 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*/ */
/** /**
\file htdocs/projet/tasks/task.php \file htdocs/projet/tasks/task.php
\ingroup projet \ingroup projet
\brief Fiche tâches d'un projet \brief Fiche tâches d'un projet
\version $Revision$ \version $Id$
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
@ -32,6 +29,9 @@ require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php");
if (!$user->rights->projet->lire) accessforbidden(); if (!$user->rights->projet->lire) accessforbidden();
/*
* View
*/
llxHeader("",$langs->trans("Task")); llxHeader("",$langs->trans("Task"));
@ -110,7 +110,8 @@ if ($_GET["id"] > 0)
foreach ($tasks as $task_time) foreach ($tasks as $task_time)
{ {
print "<tr $bc[$var]>"; $var=!$var;
print "<tr ".$bc[$var].">";
print '<td>'.dolibarr_print_date($task_time[0]).'</td>'; print '<td>'.dolibarr_print_date($task_time[0]).'</td>';
print '<td>'.$task_time[1].'</td>'; print '<td>'.$task_time[1].'</td>';
print '<td>'.$task_time[3].'</td>'; print '<td>'.$task_time[3].'</td>';