[ Index ]
 

Code source de Dolibarr 2.0.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/htdocs/projet/tasks/ -> fiche.php (source)

   1  <?php
   2  /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   *
   4   * This program is free software; you can redistribute it and/or modify
   5   * it under the terms of the GNU General Public License as published by
   6   * the Free Software Foundation; either version 2 of the License, or
   7   * (at your option) any later version.
   8   *
   9   * This program is distributed in the hope that it will be useful,
  10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12   * GNU General Public License for more details.
  13   *
  14   * You should have received a copy of the GNU General Public License
  15   * along with this program; if not, write to the Free Software
  16   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17   *
  18   * $Id: fiche.php,v 1.4 2005/09/17 00:53:51 eldy Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/projet/tasks/fiche.php,v $
  20   *
  21   */
  22  
  23  /**
  24     \file       htdocs/projet/tasks/fiche.php
  25     \ingroup    projet
  26     \brief      Fiche tâches d'un projet
  27     \version    $Revision: 1.4 $
  28  */
  29  
  30  require ("./pre.inc.php");
  31  
  32  if (!$user->rights->projet->lire) accessforbidden();
  33  
  34  Function PLines(&$inc, $parent, $lines, &$level, $actors)
  35  {
  36    $form = new Form($db); // $db est null ici mais inutile pour la fonction select_date()
  37    global $user, $bc, $langs;
  38    for ($i = 0 ; $i < sizeof($lines) ; $i++)
  39      {
  40        if ($parent == 0)
  41      $level = 0;
  42  
  43        if ($lines[$i][1] == $parent)
  44      {
  45        $var = !$var;
  46        print "<tr $bc[$var]>\n<td>";
  47  
  48        for ($k = 0 ; $k < $level ; $k++)
  49          {
  50            print "&nbsp;&nbsp;&nbsp;";
  51          }
  52  
  53        print '<a href="task.php?id='.$lines[$i][2].'">'.$lines[$i][0]."</a></td>\n";
  54  
  55        $heure = intval($lines[$i][3]);
  56        $minutes = (($lines[$i][3] - $heure) * 60);
  57        $minutes = substr("00"."$minutes", -2);
  58  
  59        print '<td align="right">'.$heure."&nbsp;h&nbsp;".$minutes."</td>\n";
  60  
  61        // TODO améliorer le test
  62  
  63        if ($actors[$lines[$i][2]] == 'admin')
  64          {
  65            print '<td><input size="4" type="text" class="flat" name="task'.$lines[$i][2].'" value="">';
  66            print '&nbsp;<input type="submit" class="flat" value="'.$langs->trans("Save").'"></td>';
  67            print "\n<td>";
  68            print $form->select_date('',$lines[$i][2]);
  69            print '</td>';
  70          }
  71        else
  72          {
  73            print '<td colspan="2">&nbsp;</td>';
  74          }
  75        print "</tr>\n";
  76        $inc++;
  77        $level++;
  78        PLines($inc, $lines[$i][2], $lines, $level, $actors);
  79        $level--;
  80      }
  81        else
  82      {
  83        //$level--;
  84      }
  85      }
  86  }
  87  
  88  Function PLineSelect(&$inc, $parent, $lines, &$level)
  89  {
  90    for ($i = 0 ; $i < sizeof($lines) ; $i++)
  91      {
  92        if ($parent == 0)
  93      $level = 0;
  94  
  95        if ($lines[$i][1] == $parent)
  96      {
  97        $var = !$var;
  98        print '<option value="'.$lines[$i][2].'">';
  99  
 100        for ($k = 0 ; $k < $level ; $k++)
 101          {
 102            print "&nbsp;&nbsp;&nbsp;";
 103          }
 104  
 105        print $lines[$i][0]."</option>\n";
 106  
 107        $inc++;
 108        $level++;
 109        PLineSelect($inc, $lines[$i][2], $lines, $level);
 110        $level--;
 111      }
 112      }
 113  }
 114  
 115  
 116  if ($_POST["action"] == 'createtask' && $user->rights->projet->creer)
 117  {
 118    $pro = new Project($db);
 119  
 120    $result = $pro->fetch($_GET["id"]);
 121    
 122    if ($result == 0)
 123      {
 124  
 125        $pro->CreateTask($user, $_POST["task_name"], $_POST["task_parent"]);
 126  
 127        Header("Location:fiche.php?id=".$pro->id);
 128      }
 129  }
 130  
 131  if ($_POST["action"] == 'addtime' && $user->rights->projet->creer)
 132  {
 133    $pro = new Project($db);
 134    $result = $pro->fetch($_GET["id"]);
 135    
 136    if ($result == 0)
 137      {
 138        foreach ($_POST as $key => $post)
 139      {
 140        //$pro->CreateTask($user, $_POST["task_name"]);
 141        if (substr($key,0,4) == 'task')
 142          {
 143            if ($post > 0)
 144          {
 145            $id = ereg_replace("task","",$key);
 146  
 147            $date = mktime(12,12,12,$_POST["$id"."month"],$_POST["$id"."day"],$_POST["$id"."year"]);
 148            $pro->TaskAddTime($user, $id , $post, $date);
 149          }
 150          }
 151      }
 152        
 153        Header("Location:fiche.php?id=".$pro->id);
 154      }
 155  }
 156  
 157  
 158  
 159  llxHeader("",$langs->trans("Project"),"Projet");
 160  
 161  
 162  if ($_GET["action"] == 'create' && $user->rights->projet->creer)
 163  {
 164    print_titre($langs->trans("NewProject"));
 165  
 166    if ($mesg) print $mesg;
 167    
 168    print '<form action="fiche.php?socidp='.$_GET["socidp"].'" method="post">';
 169  
 170    print '<table class="border" width="100%">';
 171    print '<input type="hidden" name="action" value="add">';
 172    print '<tr><td>'.$langs->trans("Company").'</td><td>';
 173  
 174    $societe = new Societe($db);
 175    $societe->fetch($_GET["socidp"]); 
 176    print $societe->nom_url;
 177  
 178    print '</td></tr>';
 179  
 180    print '<tr><td>'.$langs->trans("Author").'</td><td>'.$user->fullname.'</td></tr>';
 181  
 182    print '<tr><td>'.$langs->trans("Ref").'</td><td><input size="10" type="text" name="ref"></td></tr>';
 183    print '<tr><td>'.$langs->trans("Label").'</td><td><input size="30" type="text" name="title"></td></tr>';
 184    print '<tr><td colspan="2" align="center"><input type="submit" value="'.$langs->trans("Create").'"></td></tr>';
 185    print '</table>';
 186    print '</form>';
 187  
 188  } else {
 189  
 190    /*
 191     * Fiche projet en mode visu
 192     *
 193     */
 194  
 195    $projet = new Project($db);
 196    $projet->fetch($_GET["id"]);
 197    $projet->societe->fetch($projet->societe->id);
 198    
 199    $h=0;
 200    $head[$h][0] = DOL_URL_ROOT.'/projet/fiche.php?id='.$projet->id;
 201    $head[$h][1] = $langs->trans("Project");
 202    $h++;
 203    
 204    $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/fiche.php?id='.$projet->id;
 205    $head[$h][1] = $langs->trans("Tasks");
 206    $hselected=$h;
 207    $h++;
 208  
 209    if ($conf->propal->enabled)
 210      {
 211        $langs->load("propal");
 212        $head[$h][0] = DOL_URL_ROOT.'/projet/propal.php?id='.$projet->id;
 213        $head[$h][1] = $langs->trans("Proposals");
 214        $h++;
 215      }  
 216    
 217    if ($conf->commande->enabled)
 218      {
 219        $langs->load("orders");
 220        $head[$h][0] = DOL_URL_ROOT.'/projet/commandes.php?id='.$projet->id;
 221        $head[$h][1] = $langs->trans("Orders");
 222        $h++;
 223      }
 224    
 225    if ($conf->facture->enabled)
 226      {
 227        $langs->load("bills");
 228        $head[$h][0] = DOL_URL_ROOT.'/projet/facture.php?id='.$projet->id;
 229        $head[$h][1] = $langs->trans("Bills");
 230        $h++;
 231      }
 232   
 233    dolibarr_fiche_head($head,  $hselected, $langs->trans("Project").": ".$projet->ref);
 234  
 235    print '<form method="POST" action="fiche.php?id='.$projet->id.'">';
 236    print '<input type="hidden" name="action" value="createtask">';
 237    print '<table class="border" width="100%">';
 238    print '<tr><td>'.$langs->trans("Project").'</td><td>'.$projet->title.'</td>';
 239    print '<td>'.$langs->trans("Company").'</td><td>'.$projet->societe->nom_url.'</td></tr>';
 240  
 241  
 242    /* Liste des acteurs */
 243    $sql = "SELECT a.fk_projet_task, a.role";
 244    $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_actors as a";
 245    $sql .= " WHERE a.fk_user = ".$user->id;
 246    
 247    $resql = $db->query($sql);
 248    if ($resql)
 249      {
 250        $num = $db->num_rows($resql);
 251        $i = 0;
 252        $actors = array();      
 253        while ($i < $num)
 254      {
 255        $row = $db->fetch_row($resql);
 256        $actors[$row[0]] = $row[1]; 
 257        $i++;
 258      }
 259        $db->free();
 260      }
 261    else
 262      {
 263        dolibarr_print_error($db);
 264      }
 265    
 266    /* Liste des tâches */
 267  
 268    $sql = "SELECT t.rowid, t.title, t.fk_task_parent, t.duration_effective";
 269    $sql .= " FROM ".MAIN_DB_PREFIX."projet_task as t";
 270    $sql .= " WHERE t.fk_projet =".$projet->id;
 271    $sql .= " ORDER BY t.fk_task_parent";
 272  
 273    $var=true;
 274    $resql = $db->query($sql);
 275    if ($resql)
 276      {
 277        $num = $db->num_rows($resql);
 278        $i = 0;
 279        $tasks = array();      
 280        while ($i < $num)
 281      {
 282        $obj = $db->fetch_object($resql);
 283        $tasks[$i][0] = $obj->title; 
 284        $tasks[$i][1] = $obj->fk_task_parent; 
 285        $tasks[$i][2] = $obj->rowid;
 286        $tasks[$i][3] = $obj->duration_effective; 
 287        $i++;
 288      }
 289        $db->free();
 290      }
 291    else
 292      {
 293        dolibarr_print_error($db);
 294      }
 295  
 296  
 297    /* Nouvelle tâche */
 298  
 299    print '<tr><td>'.$langs->trans("NewTask").'</td><td colspan="3">';
 300    print '<input type="text" size="25" name="task_name" class="flat">&nbsp;';
 301    print '<select class="flat" name="task_parent">';
 302    print '<option value="0" selected="true">&nbsp;</option>';
 303    PLineSelect($j, 0, $tasks, $level);  
 304    print '</select>&nbsp;';
 305    print '<input type="submit" class="flat">';
 306    print '</td></tr>';
 307  
 308    print '</table></form><br />';
 309  
 310    print '<form method="POST" action="fiche.php?id='.$projet->id.'">';
 311    print '<input type="hidden" name="action" value="addtime">';
 312    print '<table class="noborder" width="100%">';
 313    print '<tr class="liste_titre">';
 314    print '<td>'.$langs->trans("Task").'</td>';
 315    print '<td align="right">'.$langs->trans("DurationEffective").'</td>';
 316    print '<td colspan="2">'.$langs->trans("AddDuration").'</td>';
 317    print "</tr>\n";      
 318    PLines($j, 0, $tasks, $level, $actors);
 319    print '</form>';
 320  
 321    
 322    print "</table>";    
 323    print '</div>';
 324    
 325  
 326  }
 327  
 328  $db->close();
 329  
 330  llxFooter('$Date: 2005/09/17 00:53:51 $ - $Revision: 1.4 $');
 331  ?>


Généré le : Mon Nov 26 12:29:37 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics