ligne.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702
  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-2017 Laurent Destailleur <eldy@users.sourceforge.net>
  5. * Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
  6. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
  7. * Copyright (C) 2015-2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
  8. * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
  9. * Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
  10. * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 3 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. */
  25. /**
  26. * \file htdocs/compta/bank/ligne.php
  27. * \ingroup bank
  28. * \brief Page to edit a bank transaction record
  29. */
  30. require '../../main.inc.php';
  31. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
  32. require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  33. // Load translation files required by the page
  34. $langs->loadLangs(array('banks', 'categories', 'compta', 'bills', 'other'));
  35. if (! empty($conf->adherent->enabled)) $langs->load("members");
  36. if (! empty($conf->don->enabled)) $langs->load("donations");
  37. if (! empty($conf->loan->enabled)) $langs->load("loan");
  38. if (! empty($conf->salaries->enabled)) $langs->load("salaries");
  39. $id = (GETPOST('id','int') ? GETPOST('id','int') : GETPOST('account','int'));
  40. $ref = GETPOST('ref','alpha');
  41. $action=GETPOST('action','alpha');
  42. $confirm=GETPOST('confirm','alpha');
  43. $rowid=GETPOST("rowid",'int');
  44. $orig_account=GETPOST("orig_account");
  45. $backtopage=GETPOST('backtopage','alpha');
  46. $cancel=GETPOST('cancel','alpha');
  47. // Security check
  48. $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref :''));
  49. $fieldtype = (! empty($ref) ? 'ref' :'rowid');
  50. if ($user->societe_id) $socid=$user->societe_id;
  51. $result=restrictedArea($user,'banque',$fieldvalue,'bank_account','','',$fieldtype);
  52. if (! $user->rights->banque->lire && ! $user->rights->banque->consolidate) accessforbidden();
  53. /*
  54. * Actions
  55. */
  56. if ($cancel)
  57. {
  58. if ($backtopage)
  59. {
  60. header("Location: ".$backtopage);
  61. exit;
  62. }
  63. }
  64. if ($user->rights->banque->consolidate && $action == 'donext')
  65. {
  66. $al = new AccountLine($db);
  67. $al->dateo_next($_GET["rowid"]);
  68. }elseif ($user->rights->banque->consolidate && $action == 'doprev')
  69. {
  70. $al = new AccountLine($db);
  71. $al->dateo_previous($_GET["rowid"]);
  72. }elseif ($user->rights->banque->consolidate && $action == 'dvnext')
  73. {
  74. $al = new AccountLine($db);
  75. $al->datev_next($_GET["rowid"]);
  76. }elseif ($user->rights->banque->consolidate && $action == 'dvprev')
  77. {
  78. $al = new AccountLine($db);
  79. $al->datev_previous($_GET["rowid"]);
  80. }
  81. if ($action == 'confirm_delete_categ' && $confirm == "yes" && $user->rights->banque->modifier)
  82. {
  83. $cat1=GETPOST("cat1",'int');
  84. if (!empty($rowid) && !empty($cat1)) {
  85. $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = ".$rowid." AND fk_categ = ".$cat1;
  86. if (! $db->query($sql))
  87. {
  88. dol_print_error($db);
  89. }
  90. }
  91. else
  92. {
  93. setEventMessages($langs->trans("MissingIds"), null, 'errors');
  94. }
  95. }
  96. if ($user->rights->banque->modifier && $action == "update")
  97. {
  98. $error=0;
  99. $acline = new AccountLine($db);
  100. $acline->fetch($rowid);
  101. $acsource = new Account($db);
  102. $acsource->fetch($id);
  103. $actarget = new Account($db);
  104. if (GETPOST('accountid','int') > 0 && ! $acline->rappro && ! $acline->getVentilExportCompta()) // We ask to change bank account
  105. {
  106. $actarget->fetch(GETPOST('accountid','int'));
  107. }
  108. else
  109. {
  110. $actarget->fetch($id);
  111. }
  112. if ($actarget->courant == Account::TYPE_CASH && GETPOST('value','alpha') != 'LIQ')
  113. {
  114. setEventMessages($langs->trans("ErrorCashAccountAcceptsOnlyCashMoney"), null, 'errors');
  115. $error++;
  116. }
  117. if (! $error)
  118. {
  119. $db->begin();
  120. $amount = price2num($_POST['amount']);
  121. $dateop = dol_mktime(12,0,0,$_POST["dateomonth"],$_POST["dateoday"],$_POST["dateoyear"]);
  122. $dateval= dol_mktime(12,0,0,$_POST["datevmonth"],$_POST["datevday"],$_POST["datevyear"]);
  123. $sql = "UPDATE ".MAIN_DB_PREFIX."bank";
  124. $sql.= " SET ";
  125. // Always opened
  126. if (isset($_POST['value'])) $sql.=" fk_type='".$db->escape($_POST['value'])."',";
  127. if (isset($_POST['num_chq'])) $sql.=" num_chq='".$db->escape($_POST["num_chq"])."',";
  128. if (isset($_POST['banque'])) $sql.=" banque='".$db->escape($_POST["banque"])."',";
  129. if (isset($_POST['emetteur'])) $sql.=" emetteur='".$db->escape($_POST["emetteur"])."',";
  130. // Blocked when conciliated
  131. if (! $acline->rappro)
  132. {
  133. if (isset($_POST['label'])) $sql.=" label='".$db->escape($_POST["label"])."',";
  134. if (isset($_POST['amount'])) $sql.=" amount='".$amount."',";
  135. if (isset($_POST['dateomonth'])) $sql.=" dateo = '".$db->idate($dateop)."',";
  136. if (isset($_POST['datevmonth'])) $sql.=" datev = '".$db->idate($dateval)."',";
  137. }
  138. $sql.= " fk_account = ".$actarget->id;
  139. $sql.= " WHERE rowid = ".$acline->id;
  140. $result = $db->query($sql);
  141. if (! $result)
  142. {
  143. $error++;
  144. }
  145. if (! $error)
  146. {
  147. $arrayofcategs=GETPOST('custcats', 'array');
  148. $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = ".$rowid;
  149. if (! $db->query($sql))
  150. {
  151. $error++;
  152. dol_print_error($db);
  153. }
  154. if (count($arrayofcategs))
  155. {
  156. foreach($arrayofcategs as $val)
  157. {
  158. $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class (lineid, fk_categ) VALUES (".$rowid.", ".$val.")";
  159. if (! $db->query($sql))
  160. {
  161. $error++;
  162. dol_print_error($db);
  163. }
  164. }
  165. // $arrayselected will be loaded after in page output
  166. }
  167. }
  168. if (! $error)
  169. {
  170. setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
  171. $db->commit();
  172. }
  173. else
  174. {
  175. $db->rollback();
  176. dol_print_error($db);
  177. }
  178. }
  179. }
  180. // Reconcile
  181. if ($user->rights->banque->consolidate && ($action == 'num_releve' || $action == 'setreconcile'))
  182. {
  183. $num_rel=trim($_POST["num_rel"]);
  184. $rappro=$_POST['reconciled']?1:0;
  185. // Check parameters
  186. if ($rappro && empty($num_rel))
  187. {
  188. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountStatement")), null, 'errors');
  189. $error++;
  190. }
  191. if (! $error)
  192. {
  193. $db->begin();
  194. $sql = "UPDATE ".MAIN_DB_PREFIX."bank";
  195. $sql.= " SET num_releve=".($num_rel?"'".$num_rel."'":"null");
  196. if (empty($num_rel)) $sql.= ", rappro = 0";
  197. else $sql.=", rappro = ".$rappro;
  198. $sql.= " WHERE rowid = ".$rowid;
  199. dol_syslog("ligne.php", LOG_DEBUG);
  200. $result = $db->query($sql);
  201. if ($result)
  202. {
  203. setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
  204. $db->commit();
  205. }
  206. else
  207. {
  208. $db->rollback();
  209. dol_print_error($db);
  210. }
  211. }
  212. }
  213. /*
  214. * View
  215. */
  216. $form = new Form($db);
  217. llxHeader('', $langs->trans("BankTransaction"));
  218. $c = new Categorie($db);
  219. $cats = $c->containing($rowid, Categorie::TYPE_BANK_LINE);
  220. foreach ($cats as $cat) {
  221. $arrayselected[] = $cat->id;
  222. }
  223. $tabs = array(
  224. array(
  225. DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$rowid,
  226. $langs->trans('Card')
  227. ),
  228. array(
  229. DOL_URL_ROOT.'/compta/bank/info.php?rowid='.$rowid,
  230. $langs->trans('Info')
  231. )
  232. );
  233. $sql = "SELECT b.rowid,b.dateo as do,b.datev as dv, b.amount, b.label, b.rappro,";
  234. $sql.= " b.num_releve, b.fk_user_author, b.num_chq, b.fk_type, b.fk_account, b.fk_bordereau as receiptid,";
  235. $sql.= " b.emetteur,b.banque";
  236. $sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
  237. $sql.= " WHERE rowid=".$rowid;
  238. $sql.= " ORDER BY dateo ASC";
  239. $result = $db->query($sql);
  240. if ($result)
  241. {
  242. $i = 0; $total = 0;
  243. if ($db->num_rows($result))
  244. {
  245. $objp = $db->fetch_object($result);
  246. $total = $total + $objp->amount;
  247. $acct=new Account($db);
  248. $acct->fetch($objp->fk_account);
  249. $account = $acct->id;
  250. $bankline = new AccountLine($db);
  251. $bankline->fetch($rowid, $ref);
  252. $links=$acct->get_url($rowid);
  253. $bankline->load_previous_next_ref('','rowid');
  254. // Confirmations
  255. if ($action == 'delete_categ')
  256. {
  257. print $form->formconfirm($_SERVER['PHP_SELF']."?rowid=".$rowid."&cat1=".GETPOST("fk_categ")."&orig_account=".$orig_account, $langs->trans("RemoveFromRubrique"), $langs->trans("RemoveFromRubriqueConfirm"), "confirm_delete_categ", '', 'yes', 1);
  258. }
  259. print '<form name="update" method="POST" action="'.$_SERVER['PHP_SELF'].'?rowid='.$rowid.'">';
  260. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  261. print '<input type="hidden" name="action" value="update">';
  262. print '<input type="hidden" name="orig_account" value="'.$orig_account.'">';
  263. print '<input type="hidden" name="id" value="'.$acct->id.'">';
  264. dol_fiche_head($tabs, 0, $langs->trans('LineRecord'), -1, 'account', 0);
  265. $linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries_list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  266. dol_banner_tab($bankline, 'rowid', $linkback);
  267. print '<div class="fichecenter">';
  268. print '<div class="underbanner clearboth"></div>';
  269. print '<table class="border" width="100%">';
  270. $i++;
  271. // Bank account
  272. print '<tr><td class="titlefield">'.$langs->trans("Account").'</td>';
  273. print '<td>';
  274. if (! $objp->rappro && ! $bankline->getVentilExportCompta())
  275. {
  276. print $form->select_comptes($acct->id, 'accountid', 0, '', 0);
  277. }
  278. else
  279. {
  280. print $acct->getNomUrl(1,'transactions','reflabel');
  281. }
  282. print '</td>';
  283. print '</tr>';
  284. // Show links of bank transactions
  285. if (count($links))
  286. {
  287. print '<tr><td class="tdtop">'.$langs->trans("Links").'</td>';
  288. print '<td>';
  289. foreach($links as $key=>$val)
  290. {
  291. if ($key) print '<br>';
  292. if ($links[$key]['type']=='payment') {
  293. require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
  294. $paymenttmp=new Paiement($db);
  295. $paymenttmp->fetch($links[$key]['url_id']);
  296. $paymenttmp->ref = $langs->trans("Payment").' '.$paymenttmp->ref;
  297. /*print '<a href="'.DOL_URL_ROOT.'/compta/paiement/card.php?id='.$links[$key]['url_id'].'">';
  298. print img_object($langs->trans('ShowPayment'),'payment').' ';
  299. print $langs->trans("Payment");
  300. print '</a>';*/
  301. print $paymenttmp->getNomUrl(1);
  302. }
  303. elseif ($links[$key]['type']=='payment_supplier') {
  304. require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
  305. $paymenttmp=new PaiementFourn($db);
  306. $paymenttmp->fetch($links[$key]['url_id']);
  307. $paymenttmp->ref = $langs->trans("Payment").' '.$paymenttmp->ref;
  308. /*print '<a href="'.DOL_URL_ROOT.'/fourn/paiement/card.php?id='.$links[$key]['url_id'].'">';
  309. print img_object($langs->trans('ShowPayment'),'payment').' ';
  310. print $langs->trans("Payment");
  311. print '</a>';*/
  312. print $paymenttmp->getNomUrl(1);
  313. }
  314. elseif ($links[$key]['type']=='company') {
  315. $societe=new Societe($db);
  316. $societe->fetch($links[$key]['url_id']);
  317. print $societe->getNomUrl(1);
  318. }
  319. elseif ($links[$key]['type']=='sc') {
  320. print '<a href="'.DOL_URL_ROOT.'/compta/sociales/card.php?id='.$links[$key]['url_id'].'">';
  321. print img_object($langs->trans('ShowSocialContribution'),'bill').' ';
  322. print $langs->trans("SocialContribution").($links[$key]['label']?' - '.$links[$key]['label']:'');
  323. print '</a>';
  324. }
  325. elseif ($links[$key]['type']=='payment_sc') {
  326. print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$links[$key]['url_id'].'">';
  327. print img_object($langs->trans('ShowPayment'),'payment').' ';
  328. print $langs->trans("SocialContributionPayment");
  329. print '</a>';
  330. }
  331. elseif ($links[$key]['type']=='payment_vat') {
  332. print '<a href="'.DOL_URL_ROOT.'/compta/tva/card.php?id='.$links[$key]['url_id'].'">';
  333. print img_object($langs->trans('ShowVAT'),'payment').' ';
  334. print $langs->trans("VATPayment");
  335. print '</a>';
  336. }
  337. elseif ($links[$key]['type']=='payment_salary') {
  338. print '<a href="'.DOL_URL_ROOT.'/compta/salaries/card.php?id='.$links[$key]['url_id'].'">';
  339. print img_object($langs->trans('ShowPaymentSalary'),'payment').' ';
  340. print $langs->trans("SalaryPayment");
  341. print '</a>';
  342. }
  343. elseif ($links[$key]['type']=='payment_loan') {
  344. print '<a href="'.DOL_URL_ROOT.'/loan/payment/card.php?id='.$links[$key]['url_id'].'">';
  345. print img_object($langs->trans('ShowLoanPayment'),'payment').' ';
  346. print $langs->trans("PaymentLoan");
  347. print '</a>';
  348. }
  349. elseif ($links[$key]['type']=='loan') {
  350. print '<a href="'.DOL_URL_ROOT.'/loan/card.php?id='.$links[$key]['url_id'].'">';
  351. print img_object($langs->trans('ShowLoan'),'bill').' ';
  352. print $langs->trans("Loan");
  353. print '</a>';
  354. }
  355. elseif ($links[$key]['type']=='member') {
  356. print '<a href="'.DOL_URL_ROOT.'/adherents/card.php?rowid='.$links[$key]['url_id'].'">';
  357. print img_object($langs->trans('ShowMember'),'user').' ';
  358. print $links[$key]['label'];
  359. print '</a>';
  360. }
  361. elseif ($links[$key]['type']=='payment_donation') {
  362. print '<a href="'.DOL_URL_ROOT.'/don/payment/card.php?id='.$links[$key]['url_id'].'">';
  363. print img_object($langs->trans('ShowDonation'),'payment').' ';
  364. print $langs->trans("DonationPayment");
  365. print '</a>';
  366. }
  367. elseif ($links[$key]['type']=='banktransfert') {
  368. print '<a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$links[$key]['url_id'].'">';
  369. print img_object($langs->trans('ShowTransaction'),'payment').' ';
  370. print $langs->trans("TransactionOnTheOtherAccount");
  371. print '</a>';
  372. }
  373. elseif ($links[$key]['type']=='user') {
  374. print '<a href="'.DOL_URL_ROOT.'/user/card.php?id='.$links[$key]['url_id'].'">';
  375. print img_object($langs->trans('ShowUser'),'user').' ';
  376. print $langs->trans("User");
  377. print '</a>';
  378. }
  379. elseif ($links[$key]['type']=='payment_various') {
  380. print '<a href="'.DOL_URL_ROOT.'/compta/bank/various_payment/card.php?id='.$links[$key]['url_id'].'">';
  381. print img_object($langs->trans('ShowVariousPayment'),'payment').' ';
  382. print $langs->trans("VariousPayment");
  383. print '</a>';
  384. }
  385. else {
  386. print '<a href="'.$links[$key]['url'].$links[$key]['url_id'].'">';
  387. print img_object('','generic').' ';
  388. print $links[$key]['label'];
  389. print '</a>';
  390. }
  391. }
  392. print '</td></tr>';
  393. }
  394. //$user->rights->banque->modifier=false;
  395. //$user->rights->banque->consolidate=true;
  396. // Type of payment / Number
  397. print "<tr><td>".$langs->trans("Type")." / ".$langs->trans("Numero");
  398. print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
  399. print "</td>";
  400. if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
  401. {
  402. print '<td>';
  403. $form->select_types_paiements($objp->fk_type,"value",'',2);
  404. print '<input type="text" class="flat" name="num_chq" value="'.(empty($objp->num_chq) ? '' : $objp->num_chq).'">';
  405. if ($objp->receiptid)
  406. {
  407. include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
  408. $receipt=new RemiseCheque($db);
  409. $receipt->fetch($objp->receiptid);
  410. print ' &nbsp; &nbsp; '.$langs->trans("CheckReceipt").': '.$receipt->getNomUrl(2);
  411. }
  412. print '</td>';
  413. }
  414. else
  415. {
  416. print '<td>'.$objp->fk_type.' '.$objp->num_chq.'</td>';
  417. }
  418. print "</tr>";
  419. // Transmitter
  420. print "<tr><td>".$langs->trans("CheckTransmitter");
  421. print ' <em>('.$langs->trans("ChequeMaker").')</em>';
  422. print "</td>";
  423. if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
  424. {
  425. print '<td>';
  426. print '<input type="text" class="flat minwidth200" name="emetteur" value="'.(empty($objp->emetteur) ? '' : stripslashes($objp->emetteur)).'">';
  427. print '</td>';
  428. }
  429. else
  430. {
  431. print '<td>'.$objp->emetteur.'</td>';
  432. }
  433. print "</tr>";
  434. // Bank of cheque
  435. print "<tr><td>".$langs->trans("Bank");
  436. print ' <em>('.$langs->trans("ChequeBank").')</em>';
  437. print "</td>";
  438. if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
  439. {
  440. print '<td>';
  441. print '<input type="text" class="flat minwidth200" name="banque" value="'.(empty($objp->banque) ? '' : $objp->banque).'">';
  442. print '</td>';
  443. }
  444. else
  445. {
  446. print '<td>'.$objp->banque.'</td>';
  447. }
  448. print "</tr>";
  449. // Date ope
  450. print '<tr><td>'.$langs->trans("DateOperation").'</td>';
  451. if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
  452. {
  453. print '<td>';
  454. print $form->selectDate($db->jdate($objp->do), 'dateo', '', '', '', 'update', 1, 0, $objp->rappro);
  455. if (! $objp->rappro)
  456. {
  457. print ' &nbsp; ';
  458. print '<a href="'.$_SERVER['PHP_SELF'].'?action=doprev&amp;id='.$id.'&amp;rowid='.$objp->rowid.'">';
  459. print img_edit_remove() . "</a> ";
  460. print '<a href="'.$_SERVER['PHP_SELF'].'?action=donext&amp;id='.$id.'&amp;rowid='.$objp->rowid.'">';
  461. print img_edit_add() ."</a>";
  462. }
  463. print '</td>';
  464. }
  465. else
  466. {
  467. print '<td>';
  468. print dol_print_date($db->jdate($objp->do),"day");
  469. print '</td>';
  470. }
  471. print '</tr>';
  472. // Value date
  473. print "<tr><td>".$langs->trans("DateValue")."</td>";
  474. if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
  475. {
  476. print '<td>';
  477. print $form->selectDate($db->jdate($objp->dv), 'datev', '', '', '', 'update', 1, 0, $objp->rappro);
  478. if (! $objp->rappro)
  479. {
  480. print ' &nbsp; ';
  481. print '<a href="'.$_SERVER['PHP_SELF'].'?action=dvprev&amp;id='.$id.'&amp;rowid='.$objp->rowid.'">';
  482. print img_edit_remove() . "</a> ";
  483. print '<a href="'.$_SERVER['PHP_SELF'].'?action=dvnext&amp;id='.$id.'&amp;rowid='.$objp->rowid.'">';
  484. print img_edit_add() ."</a>";
  485. }
  486. print '</td>';
  487. }
  488. else
  489. {
  490. print '<td>';
  491. print dol_print_date($db->jdate($objp->dv),"day");
  492. print '</td>';
  493. }
  494. print "</tr>";
  495. // Description
  496. print "<tr><td>".$langs->trans("Label")."</td>";
  497. if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
  498. {
  499. print '<td>';
  500. print '<input name="label" class="flat minwidth300" '.($objp->rappro?' disabled':'').' value="';
  501. if (preg_match('/^\((.*)\)$/i',$objp->label,$reg))
  502. {
  503. // Label generique car entre parentheses. On l'affiche en le traduisant
  504. print $langs->trans($reg[1]);
  505. }
  506. else
  507. {
  508. print $objp->label;
  509. }
  510. print '">';
  511. print '</td>';
  512. }
  513. else
  514. {
  515. print '<td>';
  516. if (preg_match('/^\((.*)\)$/i',$objp->label,$reg))
  517. {
  518. // Label generique car entre parentheses. On l'affiche en le traduisant
  519. print $langs->trans($reg[1]);
  520. }
  521. else
  522. {
  523. print $objp->label;
  524. }
  525. print '</td>';
  526. }
  527. print '</tr>';
  528. // Amount
  529. print "<tr><td>".$langs->trans("Amount")."</td>";
  530. if ($user->rights->banque->modifier)
  531. {
  532. print '<td>';
  533. print '<input name="amount" class="flat maxwidth100" '.($objp->rappro?' disabled':'').' value="'.price($objp->amount).'"> '.$langs->trans("Currency".$acct->currency_code);
  534. print '</td>';
  535. }
  536. else
  537. {
  538. print '<td>';
  539. print price($objp->amount);
  540. print '</td>';
  541. }
  542. print "</tr>";
  543. // Categories
  544. if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire))
  545. {
  546. $langs->load('categories');
  547. // Bank line
  548. print '<tr><td class="toptd">' . $form->editfieldkey('RubriquesTransactions', 'custcats', '', $object, 0) . '</td><td>';
  549. $cate_arbo = $form->select_all_categories(Categorie::TYPE_BANK_LINE, null, 'parent', null, null, 1);
  550. print $form->multiselectarray('custcats', $cate_arbo, $arrayselected, null, null, null, null, "90%");
  551. print "</td></tr>";
  552. }
  553. print "</table>";
  554. print '</div>';
  555. dol_fiche_end();
  556. print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Update").'"></div><br>';
  557. print "</form>";
  558. // Releve rappro
  559. if ($acct->canBeConciliated() > 0) // Si compte rapprochable
  560. {
  561. print load_fiche_titre($langs->trans("Reconciliation"), '', 'title_bank.png');
  562. print '<hr>'."\n";
  563. print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'?rowid='.$objp->rowid.'">';
  564. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  565. print '<input type="hidden" name="action" value="setreconcile">';
  566. print '<input type="hidden" name="orig_account" value="'.$orig_account.'">';
  567. print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
  568. print '<div class="fichecenter">';
  569. print '<table class="border" width="100%">';
  570. print '<tr><td class="titlefield">'.$langs->trans("Conciliation")."</td>";
  571. if ($user->rights->banque->consolidate)
  572. {
  573. print '<td>';
  574. if ($objp->rappro)
  575. {
  576. print $langs->trans("AccountStatement").' <input name="num_rel_bis" class="flat" value="'.$objp->num_releve.'"'.($objp->rappro?' disabled':'').'>';
  577. print '<input name="num_rel" type="hidden" value="'.$objp->num_releve.'">';
  578. }
  579. else
  580. {
  581. print $langs->trans("AccountStatement").' <input name="num_rel" class="flat" value="'.$objp->num_releve.'"'.($objp->rappro?' disabled':'').'>';
  582. }
  583. 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>';
  584. print '</td>';
  585. }
  586. else
  587. {
  588. print '<td>'.$objp->num_releve.'&nbsp;</td>';
  589. }
  590. print '</tr>';
  591. print "<tr><td>".$langs->trans("BankLineConciliated")."</td>";
  592. if ($user->rights->banque->consolidate)
  593. {
  594. print '<td>';
  595. print '<input type="checkbox" name="reconciled" class="flat" '.(isset($_POST["reconciled"])?($_POST["reconciled"]?' checked="checked"':''):($objp->rappro?' checked="checked"':'')).'">';
  596. print '</td>';
  597. }
  598. else
  599. {
  600. print '<td>'.yn($objp->rappro).'</td>';
  601. }
  602. print '</tr>';
  603. print '</table>';
  604. print '</div>';
  605. print '<div class="center">';
  606. print '<input type="submit" class="button" value="'.$langs->trans("Update").'">';
  607. if ($backtopage)
  608. {
  609. print ' &nbsp; ';
  610. print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">';
  611. }
  612. print '</div>';
  613. print '</form>';
  614. }
  615. }
  616. $db->free($result);
  617. }
  618. else dol_print_error($db);
  619. // End of page
  620. llxFooter();
  621. $db->close();