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

   1  <?php
   2  /* Copyright (C) 2003      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.12 2005/12/03 00:36:02 eldy Exp $
  20   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/compta/deplacement/fiche.php,v $
  21   */
  22  
  23  /**
  24          \file       htdocs/compta/deplacement/fiche.php
  25          \brief      Page fiche d'un déplacement
  26  */
  27  
  28  require ("./pre.inc.php");
  29  
  30  $langs->load("trips");
  31  
  32  $id=isset($_GET["id"])?$_GET["id"]:$_POST["id"];
  33  
  34  
  35  $mesg = '';
  36  
  37  
  38  /*
  39   * Actions
  40   */
  41  if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes")
  42  {
  43    $deplacement = new Deplacement($db);
  44    $deplacement->delete($_GET["id"]);
  45    Header("Location: index.php");
  46  }
  47  
  48  if ($_POST["action"] == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
  49  {
  50    $deplacement = new Deplacement($db);
  51  
  52    $deplacement->date = mktime(12, 1 , 1, 
  53                    $_POST["remonth"], 
  54                    $_POST["reday"], 
  55                    $_POST["reyear"]);
  56    
  57    $deplacement->km = $_POST["km"];
  58    $deplacement->socid = $_POST["soc_id"];
  59    $deplacement->userid = $user->id; //$_POST["km"];
  60    $id = $deplacement->create($user);
  61  
  62    if ($id)
  63      {
  64        Header ( "Location: fiche.php?id=".$id);
  65        exit;
  66      }
  67    else
  68      {
  69        dolibarr_print_error($db);
  70      }
  71  }
  72  
  73  if ($_POST["action"] == 'update' && $_POST["cancel"] <> $langs->trans("Cancel"))
  74  {
  75    $deplacement = new Deplacement($db);
  76    $result = $deplacement->fetch($_POST["id"]);
  77  
  78    $deplacement->date = mktime(12, 1 , 1, 
  79                    $_POST["remonth"], 
  80                    $_POST["reday"], 
  81                    $_POST["reyear"]);
  82    
  83    $deplacement->km     = $_POST["km"];
  84  
  85    $result = $deplacement->update($user);
  86  
  87    if ($result > 0)
  88      {
  89        Header ( "Location: fiche.php?id=".$_POST["id"]);
  90        exit;
  91      }
  92    else
  93      {
  94        print $mesg=$langs->trans("ErrorUnknown");
  95      }
  96  }
  97  
  98  
  99  
 100  llxHeader();
 101  
 102  $html = new Form($db);
 103  
 104  /*
 105   * Action create
 106   */
 107  if ($_GET["action"] == 'create')
 108  {
 109    print "<form action=\"fiche.php\" method=\"post\">\n";
 110    print '<input type="hidden" name="action" value="add">';
 111  
 112    print_fiche_titre($langs->trans("NewTrip"));
 113        
 114    print '<table class="border" width="100%">';
 115    print '<tr><td width="20%">'.$langs->trans("Person").'</td><td>'.$user->fullname.'</td></tr>';    
 116  
 117    print "<tr>";
 118    print '<td>'.$langs->trans("CompanyVisited").'</td><td>';
 119    print $html->select_societes();
 120    print '</td></tr>';
 121  
 122    print "<tr>";
 123    print '<td>'.$langs->trans("Date").'</td><td>';
 124    print $html->select_date();
 125    print '</td></tr>';
 126  
 127    print '<tr><td>'.$langs->trans("Kilometers").'</td><td><input name="km" size="10" value=""></td></tr>';
 128    print '<tr><td>&nbsp;</td><td><input type="submit" value="'.$langs->trans("Save").'">&nbsp;';
 129    print '<input type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
 130    print '</table>';
 131    print '</form>';      
 132  }
 133  else
 134  {
 135    if ($id)
 136      {
 137        $deplacement = new Deplacement($db);
 138        $result = $deplacement->fetch($id);
 139        if ($result)
 140      { 
 141      
 142        if ($mesg) print "$mesg<br>";
 143  
 144        if ($_GET["action"] == 'edit')
 145          {
 146            $h=0;
 147              
 148            $head[$h][0] = DOL_URL_ROOT."/compta/deplacement/fiche.php?id=$deplacement->id";
 149            $head[$h][1] = $langs->trans("TripCard");
 150              
 151            dolibarr_fiche_head($head, $hselected, $langs->trans("Ref").' '.$deplacement->id);
 152  
 153            print "<form action=\"fiche.php\" method=\"post\">\n";
 154            print '<input type="hidden" name="action" value="update">';
 155            print '<input type="hidden" name="id" value="'.$id.'">';
 156                  
 157            print '<table class="border" width="100%">';
 158  
 159            $soc = new Societe($db);
 160            $soc->fetch($deplacement->socid);
 161  
 162            print '<tr><td width="20%">'.$langs->trans("Personn").'</td><td>'.$user->fullname.'</td></tr>';    
 163  
 164            print "<tr>";
 165            print '<td>'.$langs->trans("CompanyVisited").'</td><td>';
 166            print $html->select_societes($soc->id);
 167            print '</td></tr>';
 168          
 169            print '<tr><td>'.$langs->trans("Date").'</td><td>';
 170            print $html->select_date($deplacement->date);
 171            print '</td></tr>';
 172            print '<tr><td>'.$langs->trans("Kilometers").'</td><td><input name="km" class="flat" size="10" value="'.$deplacement->km.'"></td></tr>';
 173  
 174            print '<tr><td align="center" colspan="2"><input type="submit" class="button" value="'.$langs->trans("Save").'"> &nbsp; ';
 175            print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'"></td></tr>';
 176            print '</table>';
 177            print '</form>';
 178            
 179            print '</div>';
 180          } 
 181        else
 182          {
 183            $h=0;
 184              
 185            $head[$h][0] = DOL_URL_ROOT."/compta/deplacement/fiche.php?id=$deplacement->id";
 186            $head[$h][1] = $langs->trans("TripCard");
 187              
 188            dolibarr_fiche_head($head, $hselected, $langs->trans("Ref").' '.$deplacement->id);
 189        
 190            /*
 191             * Confirmation de la suppression du déplacement
 192             */
 193            if ($_GET["action"] == 'delete')
 194              {
 195                
 196                  $html = new Form($db);
 197                  $html->form_confirm("fiche.php?id=".$id,$langs->trans("DeleteTrip"),$langs->trans("ConfirmDeleteTrip"),"confirm_delete");
 198      
 199                  print '<br>';
 200              }
 201  
 202            $soc = new Societe($db);
 203            $soc->fetch($deplacement->socid);
 204  
 205            print '<table class="border" width="100%">';
 206            print '<tr><td width="20%">'.$langs->trans("Personn").'</td><td><a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$user->id.'">'.$user->fullname.'</a></td></tr>';
 207            print '<tr><td width="20%">'.$langs->trans("CompanyVisited").'</td><td>'.$soc->nom_url.'</td></tr>';
 208            print '<tr><td>'.$langs->trans("Date").'</td><td>';
 209            print dolibarr_print_date($deplacement->date);
 210            print '</td></tr>';
 211            print '<tr><td>'.$langs->trans("Kilometers").'</td><td>'.$deplacement->km.'</td></tr>';    
 212            print "</table>";
 213            
 214            print '</div>';
 215          }
 216        
 217      }
 218        else
 219      {
 220        dolibarr_print_error($db);
 221      }
 222      }
 223  }
 224  
 225  
 226  /*
 227   * Barre d'actions
 228   *
 229   */
 230  
 231  print '<div class="tabsAction">';
 232  
 233  if ($_GET["action"] != 'create' && $_GET["action"] != 'edit')
 234  {
 235    print '<a class="tabAction" href="fiche.php?action=edit&id='.$id.'">'.$langs->trans('Edit').'</a>';
 236    print '<a class="butDelete" href="fiche.php?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>';
 237  }
 238  
 239  print '</div>';
 240  
 241  $db->close();
 242  
 243  llxFooter('$Date: 2005/12/03 00:36:02 $ - $Revision: 1.12 $');
 244  ?>


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