From 311ad985075ab398b848fae4e167fc81c7dbc755 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Sun, 21 Aug 2005 12:24:33 +0000 Subject: [PATCH] Nouveau fichier --- htdocs/projet/tasks/fiche.php | 296 ++++++++++++++++++++++++++ mysql/tables/llx_projet_task_time.sql | 35 +++ 2 files changed, 331 insertions(+) create mode 100644 htdocs/projet/tasks/fiche.php create mode 100644 mysql/tables/llx_projet_task_time.sql diff --git a/htdocs/projet/tasks/fiche.php b/htdocs/projet/tasks/fiche.php new file mode 100644 index 00000000000..39ffb905823 --- /dev/null +++ b/htdocs/projet/tasks/fiche.php @@ -0,0 +1,296 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + * $Source$ + * + */ + +/** + \file htdocs/projet/tasks/fiche.php + \ingroup projet + \brief Fiche tāches d'un projet + \version $Revision$ +*/ + +require("./pre.inc.php"); + +if (!$user->rights->projet->lire) accessforbidden(); + +Function PLines(&$inc, $parent, $lines, &$level) +{ + $form = new Form($db); // $db est null ici mais inutile pour la fonction select_date() + global $bc, $langs; + for ($i = 0 ; $i < sizeof($lines) ; $i++) + { + if ($parent == 0) + $level = 0; + + if ($lines[$i][1] == $parent) + { + $var = !$var; + print ""; + + for ($k = 0 ; $k < $level ; $k++) + { + print "   "; + } + + print ''.$lines[$i][0]."\n"; + + $heure = intval($lines[$i][3]); + $minutes = (($lines[$i][3] - $heure) * 60); + $minutes = substr("00"."$minutes", -2); + + print ''.$heure." h ".$minutes."\n"; + print ''; + print ' '; + print ''; + print $form->select_date(); + print ''; + print "\n"; + $inc++; + $level++; + PLines($inc, $lines[$i][2], $lines, $level); + $level--; + } + else + { + //$level--; + } + } +} + +Function PLineSelect(&$inc, $parent, $lines, &$level) +{ + + for ($i = 0 ; $i < sizeof($lines) ; $i++) + { + if ($parent == 0) + $level = 0; + + if ($lines[$i][1] == $parent) + { + $var = !$var; + print '\n"; + + $inc++; + $level++; + PLineSelect($inc, $lines[$i][2], $lines, $level); + $level--; + } + } +} + + +if ($_POST["action"] == 'createtask' && $user->rights->projet->creer) +{ + $pro = new Project($db); + + $result = $pro->fetch($_GET["id"]); + + if ($result == 0) + { + + $pro->CreateTask($user, $_POST["task_name"], $_POST["task_parent"]); + + Header("Location:fiche.php?id=".$pro->id); + } +} + +if ($_POST["action"] == 'addtime' && $user->rights->projet->creer) +{ + $pro = new Project($db); + $result = $pro->fetch($_GET["id"]); + + if ($result == 0) + { + + foreach ($_POST as $key => $post) + { + //$pro->CreateTask($user, $_POST["task_name"]); + if (substr($key,0,4) == 'task') + { + if ($post > 0) + { + $date = mktime(12,12,12,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]); + $pro->TaskAddTime($user, ereg_replace("task","",$key) , $post, $date); + } + } + } + + Header("Location:fiche.php?id=".$pro->id); + } +} + + + +llxHeader("",$langs->trans("Project"),"Projet"); + + +if ($_GET["action"] == 'create' && $user->rights->projet->creer) +{ + print_titre($langs->trans("NewProject")); + + if ($mesg) print $mesg; + + print '
'; + + print ''; + print ''; + print ''; + + print ''; + + print ''; + print ''; + print ''; + print '
'.$langs->trans("Company").''; + + $societe = new Societe($db); + $societe->fetch($_GET["socidp"]); + print $societe->nom_url; + + print '
'.$langs->trans("Author").''.$user->fullname.'
'.$langs->trans("Ref").'
'.$langs->trans("Label").'
'; + print '
'; + +} else { + + /* + * Fiche projet en mode visu + * + */ + + $projet = new Project($db); + $projet->fetch($_GET["id"]); + $projet->societe->fetch($projet->societe->id); + + $h=0; + $head[$h][0] = DOL_URL_ROOT.'/projet/fiche.php?id='.$projet->id; + $head[$h][1] = $langs->trans("Project"); + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/fiche.php?id='.$projet->id; + $head[$h][1] = $langs->trans("Tasks"); + $hselected=$h; + $h++; + + if ($conf->propal->enabled) + { + $langs->load("propal"); + $head[$h][0] = DOL_URL_ROOT.'/projet/propal.php?id='.$projet->id; + $head[$h][1] = $langs->trans("Proposals"); + $h++; + } + + if ($conf->commande->enabled) + { + $langs->load("orders"); + $head[$h][0] = DOL_URL_ROOT.'/projet/commandes.php?id='.$projet->id; + $head[$h][1] = $langs->trans("Orders"); + $h++; + } + + if ($conf->facture->enabled) + { + $langs->load("bills"); + $head[$h][0] = DOL_URL_ROOT.'/projet/facture.php?id='.$projet->id; + $head[$h][1] = $langs->trans("Bills"); + $h++; + } + + dolibarr_fiche_head($head, $hselected, $langs->trans("Project").": ".$projet->ref); + + print '
'; + print ''; + print ''; + print ''; + print ''; + + /* Liste des tāches */ + + $sql = "SELECT t.rowid, t.title, t.fk_task_parent, t.duration_effective"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task as t"; + $sql .= " WHERE t.fk_projet =".$projet->id; + $sql .= " ORDER BY t.fk_task_parent"; + + $var=true; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + $tasks = array(); + while ($i < $num) + { + $obj = $db->fetch_object($resql); + $tasks[$i][0] = $obj->title; + $tasks[$i][1] = $obj->fk_task_parent; + $tasks[$i][2] = $obj->rowid; + $tasks[$i][3] = $obj->duration_effective; + $i++; + } + $db->free(); + } + else + { + dolibarr_print_error($db); + } + + + /* Nouvelle tāche */ + + print ''; + + print '
'.$langs->trans("Label").''.$projet->title.''.$langs->trans("Company").''.$projet->societe->nom_url.'
'.$langs->trans("NewTask").''; + print ' '; + print ' '; + print ''; + print '

'; + + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + PLines($j, 0, $tasks, $level); + print ''; + + + print "
'.$langs->trans("Task").''.$langs->trans("DurationEffective").''.$langs->trans("AddDuration").'
"; + print ''; + + +} + +$db->close(); + +llxFooter('$Date$ - $Revision$'); +?> diff --git a/mysql/tables/llx_projet_task_time.sql b/mysql/tables/llx_projet_task_time.sql new file mode 100644 index 00000000000..7d801aabb67 --- /dev/null +++ b/mysql/tables/llx_projet_task_time.sql @@ -0,0 +1,35 @@ +-- =========================================================================== +-- Copyright (C) 2005 Rodolphe Quiedeville +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +-- +-- $Id$ +-- $Source$ +-- +-- =========================================================================== + +create table llx_projet_task_time +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_task integer NOT NULL, + task_date date, + task_duration smallint UNSIGNED, + fk_user integer, + note text, + + key(fk_task), + key(fk_user) + +)type=innodb;