[ 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/bank/ -> ligne.php (source)

   1  <?php
   2  /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   * Copyright (C) 2003      Xavier DUTOIT        <doli@sydesy.com>
   4   * Copyright (C) 2004-2005 Laurent Destailleur  <eldy@users.sourceforge.net>
   5   * Copyright (C) 2004      Christophe Combelles <ccomb@free.fr>
   6   *
   7   * This program is free software; you can redistribute it and/or modify
   8   * it under the terms of the GNU General Public License as published by
   9   * the Free Software Foundation; either version 2 of the License, or
  10   * (at your option) any later version.
  11   *
  12   * This program is distributed in the hope that it will be useful,
  13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15   * GNU General Public License for more details.
  16   *
  17   * You should have received a copy of the GNU General Public License
  18   * along with this program; if not, write to the Free Software
  19   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20   *
  21   * $Id: ligne.php,v 1.45 2005/11/10 21:04:46 eldy Exp $
  22   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/compta/bank/ligne.php,v $
  23   */
  24   
  25  /**
  26          \file       htdocs/compta/bank/ligne.php
  27          \ingroup    compta
  28          \brief      Page édition d'une écriture bancaire
  29          \version    $Revision: 1.45 $
  30  */
  31  
  32  require ("./pre.inc.php");
  33  
  34  if (!$user->rights->banque->modifier)
  35    accessforbidden();
  36  
  37  $langs->load("banks");
  38  $langs->load("bills");
  39  
  40  
  41  $rowid=isset($_GET["rowid"])?$_GET["rowid"]:$_POST["rowid"];
  42  $orig_account=isset($_GET["orig_account"])?$_GET["orig_account"]:$_POST["orig_account"];
  43  
  44  $html = new Form($db);
  45  
  46  
  47  /*
  48   * Actions
  49   */
  50  
  51  if ($_GET["action"] == 'dvnext')
  52  {
  53    $ac = new Account($db);
  54    $ac->datev_next($_GET["rowid"]);
  55  }
  56  
  57  if ($_GET["action"] == 'dvprev')
  58  {
  59    $ac = new Account($db);
  60    $ac->datev_previous($_GET["rowid"]);
  61  }
  62  
  63  if ($_POST["action"] == 'confirm_delete_categ' && $_POST["confirm"] == "yes")
  64  {
  65    $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = $rowid AND fk_categ = ".$_GET["cat1"];
  66    if (! $db->query($sql))
  67      {
  68        dolibarr_print_error($db);
  69      }
  70  }
  71  
  72  if ($_POST["action"] == 'class')
  73  {
  74    $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = $rowid AND fk_categ = ".$_POST["cat1"];
  75    if (! $db->query($sql))
  76      {
  77        dolibarr_print_error($db);
  78      }
  79  
  80    $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class (lineid, fk_categ) VALUES (".$_GET["rowid"].", ".$_POST["cat1"].")";
  81    if (! $db->query($sql))
  82      {
  83        dolibarr_print_error($db);
  84      }
  85  }
  86  
  87  if ($_POST["action"] == "update")
  88  {
  89      // Avant de modifier la date ou le montant, on controle si ce n'est pas encore rapproche
  90      $sql = "SELECT b.rappro FROM ".MAIN_DB_PREFIX."bank as b WHERE rowid=".$rowid;
  91      $result = $db->query($sql);
  92      if ($result)
  93      {
  94          $objp = $db->fetch_object($result);
  95          if ($objp->rappro)
  96              die ("Vous ne pouvez pas modifier une écriture déjà rapprochée");
  97      }
  98  
  99      $db->begin();
 100      
 101      $amount = str_replace(' ','',$_POST['amount']);
 102      $amount = str_replace(',','.',$amount);
 103  
 104      $dateop = $_POST["doyear"].'-'.$_POST["domonth"].'-'.$_POST["doday"];
 105      $dateval= $_POST["dvyear"].'-'.$_POST["dvmonth"].'-'.$_POST["dvday"];
 106      $sql = "UPDATE ".MAIN_DB_PREFIX."bank";
 107      $sql.= " SET label='".$_POST["label"]."',";
 108      if (isset($_POST['amount'])) $sql.=" amount='$amount',";
 109      $sql.= " dateo = '".$dateop."', datev = '".$dateval."',";
 110      $sql.= " fk_account = ".$_POST['accountid'];
 111      $sql.= " WHERE rowid = $rowid;";
 112  
 113      $result = $db->query($sql);
 114      if ($result)
 115      {
 116          $db->commit();
 117      }
 118      else
 119      {    
 120          $db->rollback();
 121          dolibarr_print_error($db);
 122      }
 123  }
 124  
 125  if ($_POST["action"] == 'type')
 126  {
 127    $sql = "UPDATE ".MAIN_DB_PREFIX."bank set fk_type='".$_POST["value"]."', num_chq='".$_POST["num_chq"]."' WHERE rowid = $rowid;";
 128    $result = $db->query($sql);
 129  }
 130  
 131  if ($_POST["action"] == 'num_releve')
 132  {
 133      $db->begin();
 134      $sql = "UPDATE ".MAIN_DB_PREFIX."bank";
 135      $sql.= " SET num_releve='".$_POST["num_rel"]."'";
 136      $sql.= " WHERE rowid = ".$rowid;
 137  
 138      $result = $db->query($sql);
 139      if ($result)
 140      {
 141          $db->commit();
 142      }
 143      else
 144      {    
 145          $db->rollback();
 146          dolibarr_print_error($db);
 147      }
 148  }
 149  
 150  
 151  /*
 152   * Affichage fiche ligne ecriture en mode edition
 153   */
 154   
 155  llxHeader();
 156  
 157  // On initialise la liste des categories
 158  $sql = "SELECT rowid, label FROM ".MAIN_DB_PREFIX."bank_categ;";
 159  $result = $db->query($sql);
 160  if ($result)
 161  {
 162    $var=True;  
 163    $num = $db->num_rows($result);
 164    $i = 0;
 165    $options = "<option value=\"0\" selected=\"true\">&nbsp;</option>";
 166    while ($i < $num)
 167      {
 168        $obj = $db->fetch_object($result);
 169        $options .= "<option value=\"$obj->rowid\">$obj->label</option>\n";
 170        $i++;
 171      }
 172    $db->free($result);
 173  }
 174  
 175  $var=False;
 176  $h=0;
 177  
 178  
 179  $head[$h][0] = DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$_GET["rowid"];
 180  $head[$h][1] = $langs->trans('Card');
 181  $hselected=$h;
 182  $h++;
 183  
 184  $head[$h][0] = DOL_URL_ROOT.'/compta/bank/info.php?rowid='.$_GET["rowid"];
 185  $head[$h][1] = $langs->trans("Info");
 186  $h++;   
 187  
 188  dolibarr_fiche_head($head, $hselected, $langs->trans('LineRecord').': '.$_GET["rowid"]);
 189  
 190  
 191  $sql = "SELECT b.rowid,".$db->pdate("b.dateo")." as do,".$db->pdate("b.datev")." as dv, b.amount, b.label, b.rappro,";
 192  $sql.= " b.num_releve, b.fk_user_author, b.num_chq, b.fk_type, b.fk_account";
 193  $sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
 194  $sql.= " WHERE rowid=".$rowid;
 195  $sql.= " ORDER BY dateo ASC";
 196  $result = $db->query($sql);
 197  if ($result)
 198  {
 199      $i = 0; $total = 0;
 200      if ($db->num_rows($result))
 201      {
 202  
 203          // Confirmations
 204          if ($_GET["action"] == 'delete_categ')
 205          {
 206              $html->form_confirm("ligne.php?rowid=".$_GET["rowid"]."&amp;cat1=".$_GET["fk_categ"]."&amp;orig_account=".$orig_account,"Supprimer dans la catégorie","Etes-vous sûr de vouloir supprimer le classement dans la catégorie ?","confirm_delete_categ");
 207              print '<br>';
 208          }
 209  
 210          print '<table class="border" width="100%">';
 211  
 212          $objp = $db->fetch_object($result);
 213          $total = $total + $objp->amount;
 214  
 215          $acct=new Account($db,$objp->fk_account);
 216          $acct->fetch($objp->fk_account);
 217          $account = $acct->id;
 218  
 219          $links=$acct->get_url($rowid);
 220  
 221          // Tableau sur 4 colonne si déja rapproché, sinon sur 5 colonnes
 222  
 223          // Author
 224          print '<tr><td width="20%">'.$langs->trans("Author")."</td>";
 225          if ($objp->fk_user_author) 
 226          {
 227              $author=new User($db,$objp->fk_user_author);
 228              $author->fetch();
 229              print '<td colspan="4"><a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$author->id.'">';
 230              print img_object($langs->trans("ShowUser"),'user').' '.$author->fullname.'</a></td>';
 231          }
 232          else
 233          {
 234              print '<td colspan="4">&nbsp;</td>';
 235          }
 236          print "</tr>";
 237          
 238          $i++;
 239  
 240          print "<form method=\"post\" action=\"ligne.php?rowid=$objp->rowid\">";
 241          print "<input type=\"hidden\" name=\"action\" value=\"update\">";
 242          print "<input type=\"hidden\" name=\"orig_account\" value=\"".$orig_account."\">";
 243      
 244          // Account
 245          print "<tr><td>".$langs->trans("Account")."</td>";
 246  /*
 247          if (! $objp->rappro)
 248          {
 249              if ($user->rights->banque->modifier && $acct->type != 2 && $acct->rappro)  // Si non compte cash et si rapprochable
 250              {
 251                  print '<td colspan="3">';
 252                  $html->select_comptes($acct->id,'accountid',0);
 253                  print '</td>';
 254                  //print '<td align="center">';
 255                  //print '<input type="submit" class="button" name="conciliate" value="'.$langs->trans("Conciliate").'">';
 256                  //print '</td>';
 257              }
 258              else
 259              {
 260                  print '<td colspan="3">';
 261                  $html->select_comptes($acct->id,'accountid',0);
 262                  print '</td>';
 263              }
 264              print '<td align="center"><input type="submit" class="button" value="'.$langs->trans("Update").'"></td>';
 265          }
 266          else
 267          {
 268  */
 269              print '<td colspan="4">';
 270              print '<a href="account.php?account='.$acct->id.'">'.img_object($langs->trans("ShowAccount"),'account').' '.$acct->label.'</a>';
 271              print '<input type="hidden" name="accountid" value="'.$acct->id.'">';
 272              print '</td>';
 273  /*
 274          }
 275  */
 276          print '</tr>';
 277          
 278          // Date ope
 279          print '<tr><td>'.$langs->trans("Date").'</td>';
 280          if (! $objp->rappro)
 281          {
 282              print '<td colspan="3">';
 283              $html->select_date($objp->do,'do');
 284              print '</td><td align="center"><input type="submit" class="button" value="'.$langs->trans("Update").'"></td>';
 285          }
 286          else
 287          {
 288              print '<td colspan="4">';
 289              print dolibarr_print_date($objp->do);
 290          }
 291          print '</td></tr>';
 292          
 293          // Value date
 294          print "<tr><td>".$langs->trans("DateValue")."</td>";
 295          if (! $objp->rappro)
 296          {
 297              print '<td colspan="3">';
 298              $html->select_date($objp->dv,'dv');
 299              print ' &nbsp; ';
 300              print '<a href="ligne.php?action=dvprev&amp;account='.$_GET["account"].'&amp;rowid='.$objp->rowid.'">';
 301              print img_edit_remove() . "</a> ";
 302              print '<a href="ligne.php?action=dvnext&amp;account='.$_GET["account"].'&amp;rowid='.$objp->rowid.'">';
 303              print img_edit_add() ."</a>";
 304              print '</td><td align="center"><input type="submit" class="button" value="'.$langs->trans("Update").'">';
 305          }
 306          else
 307          {
 308              print '<td colspan="4">';
 309              print dolibarr_print_date($objp->dv);
 310          }
 311          print "</td></tr>";
 312          
 313          // Description
 314          print "<tr><td>".$langs->trans("Label")."</td>";
 315          if (! $objp->rappro)
 316          {
 317              print '<td colspan="3">';
 318              print '<input name="label" class="flat" value="'.$objp->label.'" size="50">';
 319              print '</td>';
 320              print '<td align="center"><input type="submit" class="button" value="'.$langs->trans("Update").'">';
 321          }
 322          else
 323          {
 324              print '<td colspan="4">';
 325              print $objp->label;            
 326          }
 327          print '</td></tr>';
 328  
 329          // Affiche liens
 330          if (sizeof($links)) {
 331              print "<tr><td>".$langs->trans("Links")."</td>";
 332              print '<td colspan="3">';
 333              foreach($links as $key=>$val)
 334              {
 335                  if ($key) print '<br>';
 336                  if ($links[$key]['type']=='payment') {
 337                      print '<a href="'.DOL_URL_ROOT.'/compta/paiement/fiche.php?id='.$links[$key]['url_id'].'">';
 338                      print img_object($langs->trans('ShowPayment'),'payment').' ';
 339                      print $langs->trans("Payment");
 340                      print '</a>';
 341                  }
 342                  else if ($links[$key]['type']=='company') {
 343                      print '<a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$links[$key]['url_id'].'">';
 344                      print img_object($langs->trans('ShowCustomer'),'company').' ';
 345                      print $links[$key]['label'];
 346                      print '</a>';
 347                  }
 348                  else {
 349                      print '<a href="'.$links[$key]['url'].$links[$key]['url_id'].'">';
 350                      print $links[$key]['label'];
 351                      print '</a>';
 352                  }
 353              }
 354              print '</td><td>&nbsp;</td></tr>';
 355          }
 356              
 357          // Amount
 358          print "<tr><td>".$langs->trans("Amount")."</td>";
 359          if (! $objp->rappro)
 360          {
 361              print '<td colspan="3">';
 362              print '<input name="amount" class="flat" size="10" value="'.price($objp->amount).'"> '.$langs->trans("Currency".$conf->monnaie);
 363              print '</td><td align="center"><input type="submit" class="button" value="'.$langs->trans("Update").'">';
 364          }
 365          else
 366          {
 367              print '<td colspan="4">';
 368              print price($objp->amount);
 369          }
 370          print "</td></tr>";
 371      
 372          print "</form>";
 373      
 374          // Type paiement
 375          print "<tr><td>".$langs->trans("Type")." / ".$langs->trans("Numero")."</td><td colspan=\"3\">";
 376          print "<form method=\"post\" action=\"ligne.php?rowid=$objp->rowid\">";
 377          print '<input type="hidden" name="action" value="type">';
 378          print "<input type=\"hidden\" name=\"orig_account\" value=\"".$orig_account."\">";
 379          print $html->select_types_paiements($objp->fk_type,"value",'',2);
 380          print '<input type="text" class="flat" name="num_chq" value="'.(empty($objp->num_chq) ? '' : $objp->num_chq).'">';
 381          print '</td><td align="center"><input type="submit" class="button" value="'.$langs->trans("Update").'">';
 382          print "</form>";
 383          print "</td></tr>";
 384      
 385          // Releve rappro
 386          if ($acct->rappro)  // Si compte rapprochable
 387          {
 388              print "<tr><td>".$langs->trans("Conciliation")."</td>";
 389              print "<form method=\"post\" action=\"ligne.php?rowid=$objp->rowid\">";
 390              print '<input type="hidden" name="action" value="num_releve">';
 391              print "<input type=\"hidden\" name=\"orig_account\" value=\"".$orig_account."\">";
 392              print '<td colspan="3">';
 393              print $langs->trans("AccountStatement").' <input name="num_rel" class="flat" value="'.$objp->num_releve.'">';
 394              print '</td><td align="center"><input type="submit" class="button" value="'.$langs->trans("Update").'"></td>';
 395              print '</form>';
 396              print '</tr>';
 397          }
 398      
 399          print "</table>";
 400      
 401      }
 402  
 403      $db->free($result);
 404  }
 405  print '</div>';
 406  
 407  
 408  /*
 409   *  Boutons actions
 410   */
 411  /*
 412  print '<div class="tabsAction">';
 413      
 414  if ($orig_account)
 415  {
 416      $acct=new Account($db,$orig_account);
 417      $acct->fetch($orig_account);
 418      print '<a class="tabAction" href="rappro.php?account='.$orig_account.'">'.$langs->trans("BackToConciliate",$acct->label).'</a>';
 419  }
 420  
 421  print '</div>';
 422  */
 423  
 424  // Liste les categories
 425  
 426  print '<br>';
 427  print '<table class="noborder" width="100%">';
 428  
 429  print "<form method=\"post\" action=\"ligne.php?rowid=$rowid&amp;account=$account\">";
 430  print "<input type=\"hidden\" name=\"action\" value=\"class\">";
 431  print "<input type=\"hidden\" name=\"orig_account\" value=\"".$orig_account."\">";
 432  print "<tr class=\"liste_titre\"><td>".$langs->trans("Categories")."</td><td colspan=\"2\">";
 433  print "<select class=\"flat\" name=\"cat1\">$options";
 434  print "</select>&nbsp;";
 435  print '<input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
 436  print "</tr>";
 437  print "</form>";
 438  
 439  $sql = "SELECT c.label, c.rowid";
 440  $sql.= " FROM ".MAIN_DB_PREFIX."bank_class as a, ".MAIN_DB_PREFIX."bank_categ as c";
 441  $sql.= " WHERE a.lineid=".$rowid." AND a.fk_categ = c.rowid";
 442  $sql.= " ORDER BY c.label";
 443  $result = $db->query($sql);
 444  if ($result)
 445  {
 446    $var=True;  
 447    $num = $db->num_rows($result);
 448    $i = 0; $total = 0;
 449    while ($i < $num)
 450      {
 451        $objp = $db->fetch_object($result);
 452  
 453        $var=!$var;
 454        print "<tr $bc[$var]>";
 455        
 456        print "<td>$objp->label</td>";
 457        print "<td align=\"center\"><a href=\"budget.php?bid=$objp->rowid\">".$langs->trans("List")."</a></td>";
 458        print "<td align=\"center\"><a href=\"ligne.php?action=delete_categ&amp;rowid=$rowid&amp;fk_categ=$objp->rowid\">".img_delete($langs->trans("Remove"))."</a></td>";
 459        print "</tr>";
 460  
 461        $i++;
 462      }
 463    $db->free($result);
 464  }
 465  print "</table>";
 466  
 467  
 468  $db->close();
 469  
 470  llxFooter('$Date: 2005/11/10 21:04:46 $ - $Revision: 1.45 $');
 471  ?>


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