PageRenderTime 46ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/htdocs/compta/bank/ligne.php

https://bitbucket.org/speedealing/speedealing
PHP | 631 lines | 499 code | 78 blank | 54 comment | 104 complexity | 9fc60bdce3df531ebb117d93f6b324ee MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1, GPL-3.0, MIT
  1. <?php
  2. /* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2003 Xavier DUTOIT <doli@sydesy.com>
  4. * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
  5. * Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
  6. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. /**
  22. * \file htdocs/compta/bank/ligne.php
  23. * \ingroup compta
  24. * \brief Page to edit a bank transaction record
  25. */
  26. require 'pre.inc.php';
  27. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
  28. $langs->load("banks");
  29. $langs->load("compta");
  30. $langs->load("bills");
  31. $langs->load("categories");
  32. if (! empty($conf->adherent->enabled)) $langs->load("members");
  33. $id = (GETPOST('id','int') ? GETPOST('id','int') : GETPOST('account','int'));
  34. $ref = GETPOST('ref','alpha');
  35. $action=GETPOST('action','alpha');
  36. $confirm=GETPOST('confirm','alpha');
  37. $rowid=GETPOST("rowid",'int');
  38. $orig_account=GETPOST("orig_account");
  39. // Security check
  40. $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref :''));
  41. $fieldtype = (! empty($ref) ? 'ref' :'rowid');
  42. if ($user->societe_id) $socid=$user->societe_id;
  43. $result=restrictedArea($user,'banque',$fieldvalue,'bank_account','','',$fieldtype);
  44. if (! $user->rights->banque->lire && ! $user->rights->banque->consolidate) accessforbidden();
  45. /*
  46. * Actions
  47. */
  48. if ($user->rights->banque->consolidate && $action == 'dvnext')
  49. {
  50. $al = new AccountLine($db);
  51. $al->datev_next($_GET["rowid"]);
  52. }
  53. if ($user->rights->banque->consolidate && $action == 'dvprev')
  54. {
  55. $al = new AccountLine($db);
  56. $al->datev_previous($_GET["rowid"]);
  57. }
  58. if ($action == 'confirm_delete_categ' && $confirm == "yes" && $user->rights->banque->modifier)
  59. {
  60. $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = ".$rowid." AND fk_categ = ".GETPOST("cat1");
  61. if (! $db->query($sql))
  62. {
  63. dol_print_error($db);
  64. }
  65. }
  66. if ($user->rights->banque->modifier && $action == 'class')
  67. {
  68. $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = ".$rowid." AND fk_categ = ".$_POST["cat1"];
  69. if (! $db->query($sql))
  70. {
  71. dol_print_error($db);
  72. }
  73. $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class (lineid, fk_categ) VALUES (".$rowid.", ".$_POST["cat1"].")";
  74. if (! $db->query($sql))
  75. {
  76. dol_print_error($db);
  77. }
  78. }
  79. if ($user->rights->banque->modifier && $action == "update")
  80. {
  81. $error=0;
  82. $ac = new Account($db);
  83. $ac->fetch($id);
  84. if ($ac->courant == 2 && $_POST['value'] != 'LIQ')
  85. {
  86. $mesg = '<div class="error">'.$langs->trans("ErrorCashAccountAcceptsOnlyCashMoney").'</div>';
  87. $error++;
  88. }
  89. if (! $error)
  90. {
  91. // Avant de modifier la date ou le montant, on controle si ce n'est pas encore rapproche
  92. $conciliated=0;
  93. $sql = "SELECT b.rappro FROM ".MAIN_DB_PREFIX."bank as b WHERE rowid=".$rowid;
  94. $result = $db->query($sql);
  95. if ($result)
  96. {
  97. $objp = $db->fetch_object($result);
  98. $conciliated=$objp->rappro;
  99. }
  100. $db->begin();
  101. $amount = price2num($_POST['amount']);
  102. $dateop = dol_mktime(12,0,0,$_POST["dateomonth"],$_POST["dateoday"],$_POST["dateoyear"]);
  103. $dateval= dol_mktime(12,0,0,$_POST["datevmonth"],$_POST["datevday"],$_POST["datevyear"]);
  104. $sql = "UPDATE ".MAIN_DB_PREFIX."bank";
  105. $sql.= " SET ";
  106. // Always opened
  107. if (isset($_POST['value'])) $sql.=" fk_type='".$db->escape($_POST['value'])."',";
  108. if (isset($_POST['num_chq'])) $sql.=" num_chq='".$db->escape($_POST["num_chq"])."',";
  109. if (isset($_POST['banque'])) $sql.=" banque='".$db->escape($_POST["banque"])."',";
  110. if (isset($_POST['emetteur'])) $sql.=" emetteur='".$db->escape($_POST["emetteur"])."',";
  111. // Blocked when conciliated
  112. if (! $conciliated)
  113. {
  114. if (isset($_POST['label'])) $sql.=" label='".$db->escape($_POST["label"])."',";
  115. if (isset($_POST['amount'])) $sql.=" amount='".$amount."',";
  116. if (isset($_POST['dateomonth'])) $sql.=" dateo = '".$db->idate($dateop)."',";
  117. if (isset($_POST['datevmonth'])) $sql.=" datev = '".$db->idate($dateval)."',";
  118. }
  119. $sql.= " fk_account = ".$id;
  120. $sql.= " WHERE rowid = ".$rowid;
  121. $result = $db->query($sql);
  122. if ($result)
  123. {
  124. $mesg=$langs->trans("RecordSaved");
  125. $db->commit();
  126. }
  127. else
  128. {
  129. $db->rollback();
  130. dol_print_error($db);
  131. }
  132. }
  133. }
  134. // Reconcile
  135. if ($user->rights->banque->consolidate && ($action == 'num_releve' || $action == 'setreconcile'))
  136. {
  137. $num_rel=trim($_POST["num_rel"]);
  138. $rappro=$_POST['reconciled']?1:0;
  139. // Check parameters
  140. if ($rappro && empty($num_rel))
  141. {
  142. $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("AccountStatement"));
  143. $error++;
  144. }
  145. if (! $error)
  146. {
  147. $db->begin();
  148. $sql = "UPDATE ".MAIN_DB_PREFIX."bank";
  149. $sql.= " SET num_releve=".($num_rel?"'".$num_rel."'":"null");
  150. if (empty($num_rel)) $sql.= ", rappro = 0";
  151. else $sql.=", rappro = ".$rappro;
  152. $sql.= " WHERE rowid = ".$rowid;
  153. dol_syslog("ligne.php sql=".$sql, LOG_DEBUG);
  154. $result = $db->query($sql);
  155. if ($result)
  156. {
  157. $mesg=$langs->trans("RecordSaved");
  158. $db->commit();
  159. }
  160. else
  161. {
  162. $db->rollback();
  163. dol_print_error($db);
  164. }
  165. }
  166. }
  167. /*
  168. * View
  169. */
  170. $form = new Form($db);
  171. llxHeader();
  172. // On initialise la liste des categories
  173. $sql = "SELECT rowid, label";
  174. $sql.= " FROM ".MAIN_DB_PREFIX."bank_categ";
  175. $sql.= " ORDER BY label";
  176. $result = $db->query($sql);
  177. if ($result)
  178. {
  179. $var=True;
  180. $num = $db->num_rows($result);
  181. $i = 0;
  182. $options = "<option value=\"0\" selected=\"true\">&nbsp;</option>";
  183. while ($i < $num)
  184. {
  185. $obj = $db->fetch_object($result);
  186. $options .= "<option value=\"$obj->rowid\">$obj->label</option>\n";
  187. $i++;
  188. }
  189. $db->free($result);
  190. }
  191. $var=false;
  192. $tabs = array(
  193. array(
  194. DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$rowid,
  195. $langs->trans('Card')
  196. ),
  197. array(
  198. DOL_URL_ROOT.'/compta/bank/info.php?rowid='.$rowid,
  199. $langs->trans('Info')
  200. )
  201. );
  202. dol_fiche_head($tabs, 0, $langs->trans('LineRecord'), 0, 'account');
  203. dol_htmloutput_mesg($mesg);
  204. $sql = "SELECT b.rowid,b.dateo as do,b.datev as dv, b.amount, b.label, b.rappro,";
  205. $sql.= " b.num_releve, b.fk_user_author, b.num_chq, b.fk_type, b.fk_account, b.fk_bordereau as receiptid,";
  206. $sql.= " b.emetteur,b.banque";
  207. $sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
  208. $sql.= " WHERE rowid=".$rowid;
  209. $sql.= " ORDER BY dateo ASC";
  210. $result = $db->query($sql);
  211. if ($result)
  212. {
  213. $i = 0; $total = 0;
  214. if ($db->num_rows($result))
  215. {
  216. $objp = $db->fetch_object($result);
  217. $total = $total + $objp->amount;
  218. $acct=new Account($db);
  219. $acct->fetch($objp->fk_account);
  220. $account = $acct->id;
  221. $bankline = new AccountLine($db);
  222. $bankline->fetch($rowid,$ref);
  223. $links=$acct->get_url($rowid);
  224. $bankline->load_previous_next_ref('','rowid');
  225. // Confirmations
  226. if ($action == 'delete_categ')
  227. {
  228. $ret=$form->form_confirm($_SERVER['PHP_SELF']."?rowid=".$rowid."&cat1=".GETPOST("fk_categ")."&orig_account=".$orig_account, $langs->trans("RemoveFromRubrique"), $langs->trans("RemoveFromRubriqueConfirm"), "confirm_delete_categ", '', 'yes', 1);
  229. if ($ret == 'html') print '<br>';
  230. }
  231. print '<form name="update" method="POST" action="'.$_SERVER['PHP_SELF'].'?rowid='.$rowid.'">';
  232. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  233. print '<input type="hidden" name="action" value="update">';
  234. print '<input type="hidden" name="orig_account" value="'.$orig_account.'">';
  235. print '<input type="hidden" name="id" value="'.$acct->id.'">';
  236. print '<table class="border" width="100%">';
  237. $linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/search.php">'.$langs->trans("BackToList").'</a>';
  238. // Ref
  239. print '<tr><td width="20%">'.$langs->trans("Ref")."</td>";
  240. print '<td colspan="4">';
  241. print $form->showrefnav($bankline, 'rowid', $linkback, 1, 'rowid', 'rowid');
  242. print '</td>';
  243. print '</tr>';
  244. $i++;
  245. // Bank account
  246. print "<tr><td>".$langs->trans("Account")."</td>";
  247. print '<td colspan="4">';
  248. print $acct->getNomUrl(1,'transactions');
  249. print '</td>';
  250. print '</tr>';
  251. // Show links of bank transactions
  252. if (count($links))
  253. {
  254. print "<tr><td>".$langs->trans("Links")."</td>";
  255. print '<td colspan="4">';
  256. foreach($links as $key=>$val)
  257. {
  258. if ($key) print '<br>';
  259. if ($links[$key]['type']=='payment') {
  260. print '<a href="'.DOL_URL_ROOT.'/compta/paiement/fiche.php?id='.$links[$key]['url_id'].'">';
  261. print img_object($langs->trans('ShowPayment'),'payment').' ';
  262. print $langs->trans("Payment");
  263. print '</a>';
  264. }
  265. else if ($links[$key]['type']=='payment_supplier') {
  266. print '<a href="'.DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$links[$key]['url_id'].'">';
  267. print img_object($langs->trans('ShowPayment'),'payment').' ';
  268. print $langs->trans("Payment");
  269. print '</a>';
  270. }
  271. else if ($links[$key]['type']=='company') {
  272. print '<a href="'.DOL_URL_ROOT.'/societe/soc.php?socid='.$links[$key]['url_id'].'">';
  273. print img_object($langs->trans('ShowCompany'),'company').' ';
  274. print $links[$key]['label'];
  275. print '</a>';
  276. }
  277. else if ($links[$key]['type']=='sc') {
  278. print '<a href="'.DOL_URL_ROOT.'/compta/sociales/charges.php?id='.$links[$key]['url_id'].'">';
  279. print img_object($langs->trans('ShowSocialContribution'),'bill').' ';
  280. print $langs->trans("SocialContribution").($links[$key]['label']?' - '.$links[$key]['label']:'');
  281. print '</a>';
  282. }
  283. else if ($links[$key]['type']=='payment_sc') {
  284. print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/fiche.php?id='.$links[$key]['url_id'].'">';
  285. print img_object($langs->trans('ShowPayment'),'payment').' ';
  286. print $langs->trans("SocialContributionPayment");
  287. print '</a>';
  288. }
  289. else if ($links[$key]['type']=='payment_vat') {
  290. print '<a href="'.DOL_URL_ROOT.'/compta/tva/fiche.php?id='.$links[$key]['url_id'].'">';
  291. print img_object($langs->trans('ShowVAT'),'payment').' ';
  292. print $langs->trans("VATPayment");
  293. print '</a>';
  294. }
  295. else if ($links[$key]['type']=='member') {
  296. print '<a href="'.DOL_URL_ROOT.'/adherents/fiche.php?rowid='.$links[$key]['url_id'].'">';
  297. print img_object($langs->trans('ShowMember'),'user').' ';
  298. print $links[$key]['label'];
  299. print '</a>';
  300. }
  301. else if ($links[$key]['type']=='banktransfert') {
  302. print '<a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$links[$key]['url_id'].'">';
  303. print img_object($langs->trans('ShowTransaction'),'payment').' ';
  304. print $langs->trans("TransactionOnTheOtherAccount");
  305. print '</a>';
  306. }
  307. else {
  308. print '<a href="'.$links[$key]['url'].$links[$key]['url_id'].'">';
  309. print img_object('','generic').' ';
  310. print $links[$key]['label'];
  311. print '</a>';
  312. }
  313. }
  314. print '</td></tr>';
  315. }
  316. $rowspan=0;
  317. //$user->rights->banque->modifier=false;
  318. //$user->rights->banque->consolidate=true;
  319. // Type of payment / Number
  320. print "<tr><td>".$langs->trans("Type")." / ".$langs->trans("Numero");
  321. print "</td>";
  322. if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
  323. {
  324. print '<td colspan="3">';
  325. print $form->select_types_paiements($objp->fk_type,"value",'',2);
  326. print '<input type="text" class="flat" name="num_chq" value="'.(empty($objp->num_chq) ? '' : $objp->num_chq).'">';
  327. if ($objp->receiptid)
  328. {
  329. include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
  330. $receipt=new RemiseCheque($db);
  331. $receipt->fetch($objp->receiptid);
  332. print ' &nbsp; &nbsp; '.$langs->trans("CheckReceipt").': '.$receipt->getNomUrl(2);
  333. }
  334. print '</td>';
  335. $rowspan=7;
  336. print '<td align="center" rowspan="'.$rowspan.'" width="20%"><input type="submit" class="button" value="'.$langs->trans("Update").'">';
  337. print '</td>';
  338. }
  339. else
  340. {
  341. print '<td colspan="4">'.$objp->fk_type.' '.$objp->num_chq.'</td>';
  342. }
  343. print "</tr>";
  344. // Bank of cheque
  345. print "<tr><td>".$langs->trans("Bank")."</td>";
  346. if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
  347. {
  348. print '<td colspan="3">';
  349. print '<input type="text" class="flat" size="40" name="banque" value="'.(empty($objp->banque) ? '' : $objp->banque).'">';
  350. print '</td>';
  351. }
  352. else
  353. {
  354. print '<td colspan="'.($rowspan?'3':'4').'">'.$objp->banque.'</td>';
  355. }
  356. print "</tr>";
  357. // Transmitter
  358. print "<tr><td>".$langs->trans("CheckTransmitter")."</td>";
  359. if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
  360. {
  361. print '<td colspan="3">';
  362. print '<input type="text" class="flat" size="40" name="emetteur" value="'.(empty($objp->emetteur) ? '' : stripslashes($objp->emetteur)).'">';
  363. print '</td>';
  364. }
  365. else
  366. {
  367. print '<td colspan="'.($rowspan?'3':'4').'">'.$objp->emetteur.'</td>';
  368. }
  369. print "</tr>";
  370. // Date ope
  371. print '<tr><td>'.$langs->trans("DateOperation").'</td>';
  372. if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
  373. {
  374. print '<td colspan="3">';
  375. print $form->select_date($db->jdate($objp->do),'dateo','','','','update',1,0,1,$objp->rappro);
  376. print '</td>';
  377. }
  378. else
  379. {
  380. print '<td colspan="'.($rowspan?'3':'4').'">';
  381. print dol_print_date($db->jdate($objp->do),"day");
  382. print '</td>';
  383. }
  384. print '</tr>';
  385. // Value date
  386. print "<tr><td>".$langs->trans("DateValue")."</td>";
  387. if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
  388. {
  389. print '<td colspan="3">';
  390. print $form->select_date($db->jdate($objp->dv),'datev','','','','update',1,0,1,$objp->rappro);
  391. if (! $objp->rappro)
  392. {
  393. print ' &nbsp; ';
  394. print '<a href="'.$_SERVER['PHP_SELF'].'?action=dvprev&amp;id='.$id.'&amp;rowid='.$objp->rowid.'">';
  395. print img_edit_remove() . "</a> ";
  396. print '<a href="'.$_SERVER['PHP_SELF'].'?action=dvnext&amp;id='.$id.'&amp;rowid='.$objp->rowid.'">';
  397. print img_edit_add() ."</a>";
  398. }
  399. print '</td>';
  400. }
  401. else
  402. {
  403. print '<td colspan="'.($rowspan?'3':'4').'">';
  404. print dol_print_date($db->jdate($objp->dv),"day");
  405. print '</td>';
  406. }
  407. print "</tr>";
  408. // Description
  409. print "<tr><td>".$langs->trans("Label")."</td>";
  410. if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
  411. {
  412. print '<td colspan="3">';
  413. print '<input name="label" class="flat" '.($objp->rappro?' disabled="disabled"':'').' value="';
  414. if (preg_match('/^\((.*)\)$/i',$objp->label,$reg))
  415. {
  416. // Label generique car entre parentheses. On l'affiche en le traduisant
  417. print $langs->trans($reg[1]);
  418. }
  419. else
  420. {
  421. print $objp->label;
  422. }
  423. print '" size="50">';
  424. print '</td>';
  425. }
  426. else
  427. {
  428. print '<td colspan="'.($rowspan?'3':'4').'">';
  429. if (preg_match('/^\((.*)\)$/i',$objp->label,$reg))
  430. {
  431. // Label generique car entre parentheses. On l'affiche en le traduisant
  432. print $langs->trans($reg[1]);
  433. }
  434. else
  435. {
  436. print $objp->label;
  437. }
  438. print '</td>';
  439. }
  440. print '</tr>';
  441. // Amount
  442. print "<tr><td>".$langs->trans("Amount")."</td>";
  443. if ($user->rights->banque->modifier)
  444. {
  445. print '<td colspan="3">';
  446. print '<input name="amount" class="flat" size="10" '.($objp->rappro?' disabled="disabled"':'').' value="'.price($objp->amount).'"> '.$langs->trans("Currency".$conf->currency);
  447. print '</td>';
  448. }
  449. else
  450. {
  451. print '<td colspan="'.($rowspan?'3':'4').'">';
  452. print price($objp->amount);
  453. print '</td>';
  454. }
  455. print "</tr>";
  456. print "</table>";
  457. print "</form>";
  458. // Releve rappro
  459. if ($acct->canBeConciliated() > 0) // Si compte rapprochable
  460. {
  461. print '<br>'."\n";
  462. print_fiche_titre($langs->trans("Reconciliation"),'','');
  463. print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'?rowid='.$objp->rowid.'">';
  464. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  465. print '<input type="hidden" name="action" value="setreconcile">';
  466. print '<input type="hidden" name="orig_account" value="'.$orig_account.'">';
  467. print '<table class="border" width="100%">';
  468. print '<tr><td width="20%">'.$langs->trans("Conciliation")."</td>";
  469. if ($user->rights->banque->consolidate)
  470. {
  471. print '<td colspan="3">';
  472. if ($objp->rappro)
  473. {
  474. print $langs->trans("AccountStatement").' <input name="num_rel_bis" class="flat" value="'.$objp->num_releve.'"'.($objp->rappro?' disabled="disabled"':'').'>';
  475. print '<input name="num_rel" type="hidden" value="'.$objp->num_releve.'">';
  476. }
  477. else
  478. {
  479. print $langs->trans("AccountStatement").' <input name="num_rel" class="flat" value="'.$objp->num_releve.'"'.($objp->rappro?' disabled="disabled"':'').'>';
  480. }
  481. if ($objp->num_releve) print ' &nbsp; (<a href="'.DOL_URL_ROOT.'/compta/bank/releve.php?num='.$objp->num_releve.'&account='.$acct->id.'">'.$langs->trans("AccountStatement").' '.$objp->num_releve.')</a>';
  482. print '</td><td align="center" rowspan="2" width="20%"><input type="submit" class="button" value="'.$langs->trans("Update").'"></td>';
  483. }
  484. else
  485. {
  486. print '<td colspan="4">'.$objp->num_releve.'&nbsp;</td>';
  487. }
  488. print '</tr>';
  489. print "<tr><td>".$langs->trans("BankLineConciliated")."</td>";
  490. if ($user->rights->banque->consolidate)
  491. {
  492. print '<td colspan="3">';
  493. print '<input type="checkbox" name="reconciled" class="flat" '.(isset($_POST["reconciled"])?($_POST["reconciled"]?' checked="checked"':''):($objp->rappro?' checked="checked"':'')).'">';
  494. print '</td>';
  495. }
  496. else
  497. {
  498. print '<td colspan="4">'.yn($objp->rappro).'</td>';
  499. }
  500. print '</tr>';
  501. print "</table>";
  502. print '</form>';
  503. }
  504. }
  505. $db->free($result);
  506. }
  507. else dol_print_error($db);
  508. print '</div>';
  509. // List of bank categories
  510. print '<br>';
  511. print '<table class="noborder" width="100%">';
  512. print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'?rowid='.$rowid.'&amp;id='.$id.'">';
  513. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  514. print '<input type="hidden" name="action" value="class">';
  515. print '<input type="hidden" name="orig_account" value="'.$orig_account.'">';
  516. print '<tr class="liste_titre"><td>'.$langs->trans("Rubriques").'</td><td colspan="2">';
  517. if ($user->rights->banque->modifier)
  518. {
  519. print '<select class="flat" name="cat1">'.$options.'</select>&nbsp;';
  520. print '<input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
  521. }
  522. print "</tr>";
  523. print "</form>";
  524. $sql = "SELECT c.label, c.rowid";
  525. $sql.= " FROM ".MAIN_DB_PREFIX."bank_class as a, ".MAIN_DB_PREFIX."bank_categ as c";
  526. $sql.= " WHERE a.lineid=".$rowid." AND a.fk_categ = c.rowid";
  527. $sql.= " ORDER BY c.label";
  528. $result = $db->query($sql);
  529. if ($result)
  530. {
  531. $var=True;
  532. $num = $db->num_rows($result);
  533. $i = 0; $total = 0;
  534. while ($i < $num)
  535. {
  536. $objp = $db->fetch_object($result);
  537. $var=!$var;
  538. print "<tr ".$bc[$var].">";
  539. print "<td>".$objp->label."</td>";
  540. print "<td align=\"center\"><a href=\"budget.php?bid=".$objp->rowid."\">".$langs->trans("ListBankTransactions")."</a></td>";
  541. if ($user->rights->banque->modifier)
  542. {
  543. print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=delete_categ&amp;rowid='.$rowid.'&amp;fk_categ='.$objp->rowid.'">'.img_delete($langs->trans("Remove")).'</a></td>';
  544. }
  545. print "</tr>";
  546. $i++;
  547. }
  548. $db->free($result);
  549. }
  550. print "</table>";
  551. llxFooter();
  552. $db->close();
  553. ?>