[ 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/fichinter/ -> fiche.php (source)

   1  <?php
   2  /* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   * Copyright (C) 2004-2005 Laurent Destailleur  <eldy@users.sourceforge.net>
   4   *
   5   * This program is free software; you can redistribute it and/or modify
   6   * it under the terms of the GNU General Public License as published by
   7   * the Free Software Foundation; either version 2 of the License, or
   8   * (at your option) any later version.
   9   *
  10   * This program is distributed in the hope that it will be useful,
  11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13   * GNU General Public License for more details.
  14   *
  15   * You should have received a copy of the GNU General Public License
  16   * along with this program; if not, write to the Free Software
  17   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18   *
  19   * $Id: fiche.php,v 1.29 2005/11/15 23:11:21 eldy Exp $
  20   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/fichinter/fiche.php,v $
  21   */
  22  
  23  /**
  24          \file       htdocs/fichinter/fiche.php
  25          \brief      Fichier fiche intervention
  26          \ingroup    ficheinter
  27          \version    $Revision: 1.29 $
  28  */
  29  
  30  require ("./pre.inc.php");
  31  require_once(DOL_DOCUMENT_ROOT."/fichinter/fichinter.class.php");
  32  require_once(DOL_DOCUMENT_ROOT."/includes/modules/fichinter/modules_fichinter.php");
  33  require_once(DOL_DOCUMENT_ROOT."/project.class.php");
  34  
  35  // Sécurité accés client
  36  if ($user->societe_id > 0)
  37  {
  38      $action = '';
  39      $socidp = $user->societe_id;
  40  }
  41  
  42  
  43  if ($_GET["socidp"])
  44  {
  45    $sql = "SELECT s.nom, s.idp, s.prefix_comm FROM ".MAIN_DB_PREFIX."societe as s WHERE s.idp = ".$_GET["socidp"];
  46    
  47    $result = $db->query($sql);
  48    if ($result)
  49      {
  50        if ( $db->num_rows($result) )
  51          {
  52        $objsoc = $db->fetch_object($result);
  53          }
  54        $db->free($result);
  55      }
  56    else
  57      {
  58        dolibarr_print_error($db);
  59      }
  60  }
  61  
  62  
  63  /*
  64   * Traitements des actions
  65   */
  66  
  67  if ($_GET["action"] == 'valid')
  68  {
  69    $fichinter = new Fichinter($db);
  70    $fichinter->id = $_GET["id"];
  71    $fichinter->valid($user->id, $conf->fichinter->outputdir);  
  72  }
  73  
  74  if ($_POST["action"] == 'add')
  75  {
  76    $fichinter = new Fichinter($db);
  77    
  78    $fichinter->date = $db->idate(mktime(12, 1 , 1, $_POST["pmonth"], $_POST["pday"], $_POST["pyear"]));
  79    $fichinter->socidp = $_POST["socidp"];
  80    $fichinter->duree = $_POST["duree"];
  81    $fichinter->projet_id = $_POST["projetidp"];
  82    $fichinter->author = $user->id;
  83    $fichinter->note = $_POST["note"];
  84    $fichinter->ref = $_POST["ref"];
  85    
  86    $id = $fichinter->create();
  87    $_GET["id"]=$id;      // Force raffraichissement sur fiche venant d'etre créée
  88  }
  89  
  90  if ($_POST["action"] == 'update')
  91  {
  92    $fichinter = new Fichinter($db);
  93    
  94    $fichinter->date = $db->idate(mktime(12, 1 , 1, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]));
  95    $fichinter->socidp = $_POST["socidp"];
  96    $fichinter->duree = $_POST["duree"];
  97    $fichinter->projet_id = $_POST["projetidp"];
  98    $fichinter->author = $user->id;
  99    $fichinter->note = $_POST["note"];
 100    $fichinter->ref = $_POST["ref"];
 101    
 102    $fichinter->update($_POST["id"]);
 103    $_GET["id"]=$_POST["id"];      // Force raffraichissement sur fiche venant d'etre créée
 104  }
 105  
 106  /**
 107   *   Generation du pdf
 108   */
 109  if ($_GET["action"] == 'generate' && $_GET["id"])
 110  {
 111    fichinter_pdf_create($db, $_GET["id"]);
 112  }
 113  
 114  
 115  llxHeader();
 116  
 117  $sel = new Form($db);
 118  
 119  /*
 120   *
 121   * Mode creation
 122   * Creation d'une nouvelle fiche d'intervention
 123   *
 124   */
 125  if ($_GET["action"] == 'create')
 126  {
 127    print_titre($langs->trans("AddIntervention"));
 128    
 129    $numpr = "FI-"."-" . strftime("%y%m%d", time());
 130    
 131    $sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."propal WHERE ref like '$numpr%'";
 132    
 133    $resql=$db->query($sql);
 134    if ($resql)
 135      {
 136        $num = $db->result(0, 0);
 137        $db->free($resql);
 138        if ($num > 0)
 139      {
 140        $numpr .= "." . ($num + 1);
 141      }
 142      }
 143    
 144    $fix = new Fichinter($db);
 145    $numpr = $fix->get_new_num($objsoc->prefix_comm);
 146    
 147    print "<form action=\"fiche.php\" method=\"post\">";
 148    
 149    $smonth = 1;
 150    $syear = date("Y", time());
 151    print '<table class="border" width="100%">';
 152    
 153    print '<input type="hidden" name="socidp" value='.$_GET["socidp"].'>';
 154    print "<tr><td>".$langs->trans("Company")."</td><td><b>".$objsoc->nom."</td></tr>";
 155    
 156    print "<tr><td>".$langs->trans("Date")."</td><td>";
 157    $sel->select_date(time(),"p");
 158    print "</td></tr>";
 159    
 160    print "<input type=\"hidden\" name=\"action\" value=\"add\">";
 161    
 162    print "<tr><td>".$langs->trans("Ref")."</td><td><input name=\"ref\" value=\"$numpr\"></td></tr>\n";
 163    print "<tr><td>".$langs->trans("Duration")." (".$langs->trans("days").")</td><td><input name=\"duree\"></td></tr>\n";
 164    
 165    if ($conf->projet->enabled)
 166      {
 167        // Projet associ
 168        $langs->load("project");
 169        print '<tr><td valign="top">'.$langs->trans("Project").'</td><td><select name="projetidp">';
 170        print '<option value="0"></option>';
 171        
 172        $sql = 'SELECT p.rowid, p.title FROM '.MAIN_DB_PREFIX.'projet as p WHERE p.fk_soc = '.$_GET["socidp"];
 173        
 174        $resql=$db->query($sql);
 175        if ($resql)
 176      {
 177        $i = 0 ;
 178        $numprojet = $db->num_rows($resql);
 179        while ($i < $numprojet)
 180          {
 181            $projet = $db->fetch_object($resql);
 182            print "<option value=\"$projet->rowid\">$projet->title</option>";
 183            $i++;
 184          }
 185        $db->free($resql);
 186      }
 187        print '</select>';
 188        
 189        if ($numprojet==0)
 190      {
 191        print 'Cette société n\'a pas de projet.&nbsp;';
 192  
 193        $user->getrights("projet");
 194  
 195        if ($user->rights->projet->creer)
 196          {
 197            print '<a href='.DOL_URL_ROOT.'/projet/fiche.php?socidp='.$socidp.'&action=create>'.$langs->trans("Add").'</a>';
 198          }
 199      }
 200        
 201      }
 202    print '</td></tr>';
 203    
 204    print '<tr><td valign="top">'.$langs->trans("Description").'</td>';
 205    print "<td><textarea name=\"note\" wrap=\"soft\" cols=\"60\" rows=\"15\"></textarea>";
 206    print '</td></tr>';
 207    
 208    print '<tr><td colspan="2" align="center">';
 209    print '<input type="submit" class="button" value="'.$langs->trans("CreateDaftIntervention").'">';
 210    print '</td></tr>';
 211    print '</table>';
 212    print '</form>';
 213            
 214  }
 215  
 216  
 217  /*
 218  *
 219  * Mode update
 220  * Mise a jour de la fiche d'intervention
 221  *
 222  */
 223  if ($_GET["action"] == 'edit')
 224  {
 225      $fichinter = new Fichinter($db);
 226      $fichinter->fetch($_GET["id"]);
 227  
 228      dolibarr_fiche_head($head, $a, $langs->trans("EditIntervention"));
 229  
 230      /*
 231       *   Initialisation de la liste des projets
 232       */
 233      print "<form action=\"fiche.php\" method=\"post\">";
 234  
 235      print "<input type=\"hidden\" name=\"action\" value=\"update\">";
 236      print "<input type=\"hidden\" name=\"id\" value=\"".$_GET["id"]."\">";
 237  
 238      print '<table class="border" width="100%">';
 239  
 240      print '<tr><td>'.$langs->trans("Ref").'</td><td>'.$fichinter->ref.'</td></tr>';
 241  
 242      print "<tr><td>".$langs->trans("Date")."</td><td>";
 243      $sel->select_date($fichinter->date);
 244      print "</td></tr>";
 245  
 246      print '<tr><td>'.$langs->trans("Duration")." (".$langs->trans("days").')</td><td><input name="duree" value="'.$fichinter->duree.'"></td></tr>';
 247  
 248      if ($conf->projet->enabled)
 249        {
 250          // Projet associé
 251          print '<tr><td valign="top">'.$langs->trans("Project").'</td><td>';
 252          $sel->select_projects($fichinter->societe_id,$fichinter->projet_id,"projetidp");
 253          print '</td></tr>';
 254        }
 255  
 256      print '<tr><td valign="top">'.$langs->trans("Description").'</td>';
 257      print '<td><textarea name="note" wrap="soft" cols="60" rows="12">';
 258      print $fichinter->note;
 259      print '</textarea>';
 260      print '</td></tr>';
 261  
 262      print '<tr><td colspan="2" align="center">';
 263      print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
 264      print '</td></tr>';
 265      print '</table>';
 266  
 267      print '</form>';
 268  
 269      print '</div>';
 270  }
 271  
 272  /*
 273  * Mode visu
 274  *
 275  */
 276  
 277  if ($_GET["id"] && $_GET["action"] != 'edit')
 278  {
 279      if ($mesg) print $mesg."<br>";
 280      
 281      dolibarr_fiche_head($head, $a, $langs->trans("InterventionCard"));
 282  
 283      $fichinter = new Fichinter($db);
 284      $result=$fichinter->fetch($_GET["id"]);
 285      if (! $result > 0)
 286      {
 287          dolibarr_print_error($db);
 288          exit;
 289      }
 290      
 291      $fichinter->fetch_client();
 292  
 293      print '<table class="border" width="100%">';
 294      print '<tr><td>'.$langs->trans("Ref").'</td><td>'.$fichinter->ref.'</td></tr>';
 295      print '<tr><td>'.$langs->trans("Company").'</td><td><a href="../comm/fiche.php?socid='.$fichinter->client->id.'">'.$fichinter->client->nom.'</a></td></tr>';
 296      print '<tr><td width="20%">'.$langs->trans("Date").'</td><td>'.dolibarr_print_date($fichinter->date,"%A %d %B %Y").'</td></tr>';
 297      print '<tr><td>'.$langs->trans("Duration").'</td><td>'.$fichinter->duree.'</td></tr>';
 298  
 299      if ($conf->projet->enabled)
 300      {
 301          $fichinter->fetch_projet();
 302          print '<tr><td valign="top">'.$langs->trans("Ref").'</td><td>'.$fichinter->projet.'</td></tr>';
 303      }
 304      print '<tr><td>'.$langs->trans("Status").'</td><td>'.$fichinter->getLibStatut().'</td></tr>';
 305  
 306      print '<tr><td valign="top">'.$langs->trans("Description").'</td>';
 307      print '<td>';
 308      print nl2br($fichinter->note);
 309      print '</td></tr>';
 310  
 311      print '</td></tr>';
 312      print "</table>";
 313      print '</div>';
 314      
 315  
 316      /**
 317       * Barre d'actions
 318       *
 319       */
 320      print '<div class="tabsAction">';
 321  
 322      if ($user->societe_id == 0)
 323      {
 324  
 325          if ($fichinter->statut == 0)
 326          {
 327              print '<a class="tabAction" href="fiche.php?id='.$_GET["id"].'&action=edit">'.$langs->trans("Edit").'</a>';
 328          }
 329  
 330          if ($fichinter->statut == 0)
 331          {
 332              print '<a class="tabAction" href="fiche.php?id='.$_GET["id"].'&action=valid">'.$langs->trans("Valid").'</a>';
 333          }
 334  
 335          $file = $conf->fichinter->dir_output."/".$fichinter->ref."/".$fichinter->ref.pdf;
 336          if ($fichinter->statut == 0 or !file_exists($file))
 337          {
 338              $langs->load("bills");
 339              print '<a class="tabAction" href="fiche.php?id='.$_GET["id"].'&action=generate">'.$langs->trans("BuildPDF").'</a>';
 340          }
 341  
 342      }
 343      print '</div>';
 344  
 345      print '<table width="100%"><tr><td width="50%" valign="top">';
 346  
 347      /*
 348       * Documents générés
 349       */
 350      $filename=sanitize_string($fichinter->ref);
 351      $filedir=$conf->fichinter->dir_output . "/".$fichinter->ref;
 352      $urlsource=$_SERVER["PHP_SELF"]."?id=".$fichinter->id;
 353      //$genallowed=$user->rights->fichinter->creer;
 354      //$delallowed=$user->rights->fichinter->supprimer;
 355      $genallowed=0;
 356      $delallowed=0;
 357      
 358      $var=true;
 359      
 360      print "<br>\n";
 361      $sel->show_documents('ficheinter',$filename,$filedir,$urlsource,$genallowed,$delallowed,$ficheinter->modelpdf);
 362  
 363    
 364      print "</td><td>";
 365      
 366      print "&nbsp;";
 367      
 368      print "</tr></table>\n";
 369  
 370  }
 371  
 372  $db->close();
 373  llxFooter();
 374  ?>


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