PageRenderTime 62ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/htdocs/compta/paiement/cheque/fiche.php

https://github.com/asterix14/dolibarr
PHP | 622 lines | 475 code | 88 blank | 59 comment | 106 complexity | 4e8870699ec8ff2382582fec896c4aa1 MD5 | raw file
Possible License(s): LGPL-2.0
  1. <?php
  2. /* Copyright (C) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2007-2011 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2009 Regis Houssin <regis@dolibarr.fr>
  5. * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
  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, see <http://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \file htdocs/compta/paiement/cheque/fiche.php
  22. * \ingroup bank, invoice
  23. * \brief Page for cheque deposits
  24. */
  25. require("./pre.inc.php"); // We use pre.inc.php to have a dynamic menu
  26. require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
  27. require_once(DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php');
  28. require_once(DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php');
  29. require_once(DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php');
  30. $langs->load('bills');
  31. $langs->load('banks');
  32. $langs->load('companies');
  33. $langs->load('compta');
  34. $id =GETPOST("id");
  35. $ref=GETPOST("ref");
  36. $action=GETPOST('action');
  37. // Security check
  38. $fieldid = isset($_GET["ref"])?'number':'rowid';
  39. if ($user->societe_id) $socid=$user->societe_id;
  40. $result = restrictedArea($user, 'cheque', $id, 'bordereau_cheque','','',$fieldid);
  41. $mesg='';
  42. $sortfield=GETPOST("sortfield");
  43. $sortorder=GETPOST("sortorder");
  44. $page=$_GET["page"];
  45. if (! $sortorder) $sortorder="ASC";
  46. if (! $sortfield) $sortfield="b.dateo,b.rowid";
  47. if ($page < 0) { $page = 0 ; }
  48. $limit = $conf->liste_limit;
  49. $offset = $limit * $page ;
  50. $dir=$conf->banque->dir_output.'/bordereau/';
  51. $filterdate=dol_mktime(0,0,0,$_POST['fdmonth'],$_POST['fdday'],$_POST['fdyear']);
  52. $filteraccountid=GETPOST('accountid');
  53. //var_dump($_POST);
  54. /*
  55. * Actions
  56. */
  57. if ($action == 'setdate' && $user->rights->banque->cheque)
  58. {
  59. $remisecheque = new RemiseCheque($db);
  60. $result = $remisecheque->fetch(GETPOST('id'));
  61. if ($result > 0)
  62. {
  63. //print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year'];
  64. $date=dol_mktime(0, 0, 0, $_POST['datecreate_month'], $_POST['datecreate_day'], $_POST['datecreate_year']);
  65. $result=$remisecheque->set_date($user,$date);
  66. if ($result < 0)
  67. {
  68. $mesg='<div class="error">'.$remisecheque->error.'</div>';
  69. }
  70. }
  71. else
  72. {
  73. $mesg='<div class="error">'.$remisecheque->error.'</div>';
  74. }
  75. }
  76. if ($action == 'create' && $_POST["accountid"] > 0 && $user->rights->banque->cheque)
  77. {
  78. if (is_array($_POST['toRemise']))
  79. {
  80. $remisecheque = new RemiseCheque($db);
  81. $result = $remisecheque->create($user, $_POST["accountid"], 0, $_POST['toRemise']);
  82. if ($result > 0)
  83. {
  84. if ($remisecheque->statut == 1) // If statut is validated, we build doc
  85. {
  86. $remisecheque->fetch($remisecheque->id); // To force to reload all properties in correct property name
  87. // Define output language
  88. $outputlangs = $langs;
  89. $newlang='';
  90. if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
  91. //if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
  92. if (! empty($newlang))
  93. {
  94. $outputlangs = new Translate("",$conf);
  95. $outputlangs->setDefaultLang($newlang);
  96. }
  97. $result = $remisecheque->generatePdf($_POST["model"], $outputlangs);
  98. }
  99. Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$remisecheque->id);
  100. exit;
  101. }
  102. else
  103. {
  104. $mesg='<div class="error">'.$remisecheque->error.'</div>';
  105. }
  106. }
  107. else
  108. {
  109. $mesg=$langs->trans("ErrorSelectAtLeastOne");
  110. $action='new';
  111. }
  112. }
  113. if ($action == 'remove' && $_GET["id"] > 0 && $_GET["lineid"] > 0 && $user->rights->banque->cheque)
  114. {
  115. $remisecheque = new RemiseCheque($db);
  116. $remisecheque->id = $_GET["id"];
  117. $result = $remisecheque->removeCheck($_GET["lineid"]);
  118. if ($result === 0)
  119. {
  120. Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$remisecheque->id);
  121. exit;
  122. }
  123. else
  124. {
  125. $mesg='<div class="error">'.$paiement->error.'</div>';
  126. }
  127. }
  128. if ($action == 'confirm_delete' && $_REQUEST['confirm'] == 'yes' && $user->rights->banque->cheque)
  129. {
  130. $remisecheque = new RemiseCheque($db);
  131. $remisecheque->id = $_GET["id"];
  132. $result = $remisecheque->delete();
  133. if ($result == 0)
  134. {
  135. Header("Location: index.php");
  136. exit;
  137. }
  138. else
  139. {
  140. $mesg='<div class="error">'.$paiement->error.'</div>';
  141. }
  142. }
  143. if ($action == 'confirm_valide' && $_REQUEST['confirm'] == 'yes' && $user->rights->banque->cheque)
  144. {
  145. $remisecheque = new RemiseCheque($db);
  146. $result = $remisecheque->fetch($_GET["id"]);
  147. $result = $remisecheque->validate($user);
  148. if ($result >= 0)
  149. {
  150. // Define output language
  151. $outputlangs = $langs;
  152. $newlang='';
  153. if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
  154. //if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
  155. if (! empty($newlang))
  156. {
  157. $outputlangs = new Translate("",$conf);
  158. $outputlangs->setDefaultLang($newlang);
  159. }
  160. $result = $remisecheque->generatePdf($_POST["model"], $outputlangs);
  161. Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$remisecheque->id);
  162. exit;
  163. }
  164. else
  165. {
  166. $mesg='<div class="error">'.$paiement->error.'</div>';
  167. }
  168. }
  169. if ($action == 'builddoc' && $user->rights->banque->cheque)
  170. {
  171. $remisecheque = new RemiseCheque($db);
  172. $result = $remisecheque->fetch($_GET["id"]);
  173. /*if ($_REQUEST['model'])
  174. {
  175. $remisecheque->setDocModel($user, $_REQUEST['model']);
  176. }*/
  177. $outputlangs = $langs;
  178. $newlang='';
  179. if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
  180. //if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
  181. if (! empty($newlang))
  182. {
  183. $outputlangs = new Translate("",$conf);
  184. $outputlangs->setDefaultLang($newlang);
  185. }
  186. $result = $remisecheque->generatePdf($_POST["model"], $outputlangs);
  187. if ($result <= 0)
  188. {
  189. dol_print_error($db,$remisecheque->error);
  190. exit;
  191. }
  192. else
  193. {
  194. Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$remisecheque->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc'));
  195. exit;
  196. }
  197. }
  198. /*
  199. * View
  200. */
  201. if (GETPOST('removefilter'))
  202. {
  203. $filterdate='';
  204. $filteraccountid=0;
  205. }
  206. llxHeader();
  207. $form = new Form($db);
  208. $formfile = new FormFile($db);
  209. if ($action == 'new')
  210. {
  211. $h=0;
  212. $head[$h][0] = $_SERVER["PHP_SELF"].'?action=new';
  213. $head[$h][1] = $langs->trans("MenuChequeDeposits");
  214. $hselected = $h;
  215. $h++;
  216. print_fiche_titre($langs->trans("Cheques"));
  217. }
  218. else
  219. {
  220. $remisecheque = new RemiseCheque($db);
  221. $result = $remisecheque->fetch($_REQUEST["id"],$_REQUEST["ref"]);
  222. if ($result < 0)
  223. {
  224. dol_print_error($db,$remisecheque->error);
  225. exit;
  226. }
  227. $h=0;
  228. $head[$h][0] = $_SERVER["PHP_SELF"].'?id='.$remisecheque->id;
  229. $head[$h][1] = $langs->trans("CheckReceipt");
  230. $hselected = $h;
  231. $h++;
  232. // $head[$h][0] = DOL_URL_ROOT.'/compta/paiement/cheque/info.php?id='.$remisecheque->id;
  233. // $head[$h][1] = $langs->trans("Info");
  234. // $h++;
  235. dol_fiche_head($head, $hselected, $langs->trans("Cheques"),0,'payment');
  236. /*
  237. * Confirmation de la suppression du bordereau
  238. */
  239. if ($action == 'delete')
  240. {
  241. $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$remisecheque->id, $langs->trans("DeleteCheckReceipt"), $langs->trans("ConfirmDeleteCheckReceipt"), 'confirm_delete','','',1);
  242. if ($ret == 'html') print '<br>';
  243. }
  244. /*
  245. * Confirmation de la validation du bordereau
  246. */
  247. if ($action == 'valide')
  248. {
  249. $facid = $_GET['facid'];
  250. $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$remisecheque->id, $langs->trans("ValidateCheckReceipt"), $langs->trans("ConfirmValidateCheckReceipt"), 'confirm_valide','','',1);
  251. if ($ret == 'html') print '<br>';
  252. }
  253. }
  254. dol_htmloutput_errors($mesg);
  255. if ($action == 'new')
  256. {
  257. $accounts = array();
  258. $lines = array();
  259. $now=dol_now();
  260. print $langs->trans("SelectChequeTransactionAndGenerate").'<br><br>'."\n";
  261. print '<form class="nocellnopadd" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  262. print '<input type="hidden" name="action" value="new">';
  263. //print '<fieldset><legend>aaa</legend>';
  264. print '<table class="border" width="100%">';
  265. //print '<tr><td width="30%">'.$langs->trans('Date').'</td><td width="70%">'.dol_print_date($now,'day').'</td></tr>';
  266. // Filter
  267. print '<tr><td width="200">'.$langs->trans("DateChequeReceived").'</td><td>';
  268. print $form->select_date($filterdate,'fd',0,0,1,'',1,1);
  269. print '</td></tr>';
  270. print '<tr><td>'.$langs->trans("BankAccount").'</td><td>';
  271. print $form->select_comptes($filteraccountid,'accountid',0,'courant <> 2',1);
  272. print '</td></tr>';
  273. print '</table>';
  274. print '<center>';
  275. print '<input type="submit" class="button" name="filter" value="'.dol_escape_htmltag($langs->trans("ToFilter")).'">';
  276. if ($filterdate || $filteraccountid > 0)
  277. {
  278. print ' &nbsp; ';
  279. print '<input type="submit" class="button" name="removefilter" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
  280. }
  281. print '</center>';
  282. //print '</fieldset>';
  283. print '</form>';
  284. print '<br>';
  285. $sql = "SELECT ba.rowid as bid, b.datec as datec, b.dateo as date, b.rowid as chqid, ";
  286. $sql.= " b.amount, ba.label, b.emetteur, b.num_chq, b.banque";
  287. $sql.= " FROM ".MAIN_DB_PREFIX."bank as b,";
  288. $sql.= " ".MAIN_DB_PREFIX."bank_account as ba";
  289. $sql.= " WHERE b.fk_type = 'CHQ'";
  290. $sql.= " AND b.fk_account = ba.rowid";
  291. $sql.= " AND ba.entity = ".$conf->entity;
  292. $sql.= " AND b.fk_bordereau = 0";
  293. $sql.= " AND b.amount > 0";
  294. if ($filterdate) $sql.=" AND b.dateo = '".$db->idate($filterdate)."'";
  295. if ($filteraccountid) $sql.=" AND ba.rowid= '".$filteraccountid."'";
  296. $sql.= $db->order("b.dateo,b.rowid","ASC");
  297. $resql = $db->query($sql);
  298. if ($resql)
  299. {
  300. $i = 0;
  301. while ( $obj = $db->fetch_object($resql) )
  302. {
  303. $accounts[$obj->bid] = $obj->label;
  304. $lines[$obj->bid][$i]["date"] = $db->jdate($obj->date);
  305. $lines[$obj->bid][$i]["amount"] = $obj->amount;
  306. $lines[$obj->bid][$i]["emetteur"] = $obj->emetteur;
  307. $lines[$obj->bid][$i]["numero"] = $obj->num_chq;
  308. $lines[$obj->bid][$i]["banque"] = $obj->banque;
  309. $lines[$obj->bid][$i]["id"] = $obj->chqid;
  310. $i++;
  311. }
  312. if ($i == 0)
  313. {
  314. print '<b>'.$langs->trans("NoWaitingChecks").'</b><br>';
  315. }
  316. }
  317. foreach ($accounts as $bid => $account_label)
  318. {
  319. print '
  320. <script language="javascript" type="text/javascript">
  321. jQuery(document).ready(function()
  322. {
  323. jQuery("#checkall_'.$bid.'").click(function()
  324. {
  325. jQuery(".checkforremise_'.$bid.'").attr(\'checked\', true);
  326. });
  327. jQuery("#checknone_'.$bid.'").click(function()
  328. {
  329. jQuery(".checkforremise_'.$bid.'").attr(\'checked\', false);
  330. });
  331. });
  332. </script>
  333. ';
  334. $num = $db->num_rows($resql);
  335. print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  336. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  337. print '<input type="hidden" name="action" value="create">';
  338. print '<input type="hidden" name="accountid" value="'.$bid.'">';
  339. print '<table class="noborder" width="100%">';
  340. print '<tr class="liste_titre">';
  341. print '<td style="min-width: 120px">'.$langs->trans("DateChequeReceived").' ';
  342. print "</td>\n";
  343. print '<td style="min-width: 120px">'.$langs->trans("ChequeNumber")."</td>\n";
  344. print '<td style="min-width: 200px">'.$langs->trans("CheckTransmitter")."</td>\n";
  345. print '<td style="min-width: 200px">'.$langs->trans("Bank")."</td>\n";
  346. print '<td align="right" width="100px">'.$langs->trans("Amount")."</td>\n";
  347. print '<td align="center" width="100px">'.$langs->trans("Select")."<br>";
  348. if ($conf->use_javascript_ajax) print '<a href="#" id="checkall_'.$bid.'">'.$langs->trans("All").'</a> / <a href="#" id="checknone_'.$bid.'">'.$langs->trans("None").'</a>';
  349. print '</td>';
  350. print "</tr>\n";
  351. $var=true;
  352. foreach ($lines[$bid] as $lid => $value)
  353. {
  354. $var=!$var;
  355. $account_id = $objp->bid;
  356. $accounts[$objp->bid] += 1;
  357. print "<tr ".$bc[$var].">";
  358. print '<td>'.dol_print_date($value["date"],'day').'</td>';
  359. print '<td>'.$value["numero"]."</td>\n";
  360. print '<td>'.$value["emetteur"]."</td>\n";
  361. print '<td>'.$value["banque"]."</td>\n";
  362. print '<td align="right">'.price($value["amount"]).'</td>';
  363. print '<td align="center">';
  364. print '<input id="'.$value["id"].'" class="flat checkforremise_'.$bid.'" checked="checked" type="checkbox" name="toRemise[]" value="'.$value["id"].'">';
  365. print '</td>' ;
  366. print '</tr>';
  367. $i++;
  368. }
  369. print "</table>";
  370. print '<div class="tabsAction">';
  371. if ($user->rights->banque->cheque)
  372. {
  373. print '<input type="submit" class="button" value="'.$langs->trans('NewCheckDepositOn',$account_label).'">';
  374. }
  375. else
  376. {
  377. print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('NewCheckDepositOn',$account_label).'</a>';
  378. }
  379. print '</div><br>';
  380. print '</form>';
  381. }
  382. }
  383. else
  384. {
  385. $object=$remisecheque;
  386. $linkback='<a href="'.$_SERVER["PHP_SELF"].'?leftmenu=customers_bills_checks&action=new">'.$langs->trans("BackToList").'</a>';
  387. $paymentstatic=new Paiement($db);
  388. $accountlinestatic=new AccountLine($db);
  389. $accountstatic=new Account($db);
  390. $accountstatic->id=$remisecheque->account_id;
  391. $accountstatic->label=$remisecheque->account_label;
  392. print '<table class="border" width="100%">';
  393. print '<tr><td width="20%">'.$langs->trans('Ref').'</td><td colspan="2" >';
  394. print $form->showrefnav($remisecheque,'ref',$linkback, 1, 'number');
  395. print "</td>";
  396. print "</tr>\n";
  397. print '<tr><td>';
  398. print '<table class="nobordernopadding" width="100%"><tr><td>';
  399. print $langs->trans('Date');
  400. print '</td>';
  401. if ($action != 'editdate') print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdate&amp;id='.$object->id.'">'.img_edit($langs->trans('SetDate'),1).'</a></td>';
  402. print '</tr></table>';
  403. print '</td><td colspan="2">';
  404. if ($action == 'editdate')
  405. {
  406. print '<form name="setdate" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
  407. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  408. print '<input type="hidden" name="action" value="setdate">';
  409. $form->select_date($object->date_bordereau,'datecreate_','','','',"setdate");
  410. print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
  411. print '</form>';
  412. }
  413. else
  414. {
  415. print $object->date_bordereau ? dol_print_date($object->date_bordereau,'day') : '&nbsp;';
  416. }
  417. print '</td>';
  418. print '</tr>';
  419. print '<tr><td>'.$langs->trans('Account').'</td><td colspan="2">';
  420. print $accountstatic->getNomUrl(1);
  421. print '</td></tr>';
  422. // Nb of cheques
  423. print '<tr><td>'.$langs->trans('NbOfCheques').'</td><td colspan="2">';
  424. print $remisecheque->nbcheque;
  425. print '</td></tr>';
  426. print '<tr><td>'.$langs->trans('Total').'</td><td colspan="2">';
  427. print price($remisecheque->amount);
  428. print '</td></tr>';
  429. print '<tr><td>'.$langs->trans('Status').'</td><td colspan="2">';
  430. print $remisecheque->getLibStatut(4);
  431. print '</td></tr>';
  432. print '</table><br>';
  433. // Liste des cheques
  434. $sql = "SELECT b.rowid, b.amount, b.num_chq, b.emetteur,";
  435. $sql.= " b.dateo as date, b.datec as datec, b.banque,";
  436. $sql.= " p.rowid as pid";
  437. $sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba";
  438. $sql.= ", ".MAIN_DB_PREFIX."bank as b";
  439. $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.fk_bank = b.rowid";
  440. $sql.= " WHERE ba.rowid = b.fk_account";
  441. $sql.= " AND ba.entity = ".$conf->entity;
  442. $sql.= " AND b.fk_type= 'CHQ'";
  443. $sql.= " AND b.fk_bordereau = ".$remisecheque->id;
  444. $sql.= " ORDER BY $sortfield $sortorder";
  445. dol_syslog("sql=".$sql);
  446. $resql = $db->query($sql);
  447. if ($resql)
  448. {
  449. $num = $db->num_rows($resql);
  450. print '<table class="noborder" width="100%">';
  451. $param="&amp;id=".$remisecheque->id;
  452. print '<tr class="liste_titre">';
  453. print_liste_field_titre($langs->trans("Cheque"),'','','','','width="30"');
  454. print_liste_field_titre($langs->trans("DateChequeReceived"),$_SERVER["PHP_SELF"],"b.dateo,b.rowid", "",$param,'align="center"',$sortfield,$sortorder);
  455. print_liste_field_titre($langs->trans("Numero"),$_SERVER["PHP_SELF"],"b.num_chq", "",$param,'align="center"',$sortfield,$sortorder);
  456. print_liste_field_titre($langs->trans("CheckTransmitter"),$_SERVER["PHP_SELF"],"b.emetteur", "",$param,"",$sortfield,$sortorder);
  457. print_liste_field_titre($langs->trans("Bank"),$_SERVER["PHP_SELF"],"b.banque", "",$param,"",$sortfield,$sortorder);
  458. print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"b.amount", "",$param,'align="right"',$sortfield,$sortorder);
  459. print_liste_field_titre($langs->trans("LineRecord"),$_SERVER["PHP_SELF"],"b.rowid", "",$param,'align="center"',$sortfield,$sortorder);
  460. print_liste_field_titre('','','');
  461. print "</tr>\n";
  462. $i=1;
  463. $var=false;
  464. while ( $objp = $db->fetch_object($resql) )
  465. {
  466. $account_id = $objp->bid;
  467. $accounts[$objp->bid] += 1;
  468. print "<tr $bc[$var]>";
  469. print '<td align="center">'.$i.'</td>';
  470. print '<td align="center">'.dol_print_date($db->jdate($objp->date),'day').'</td>'; // Date operation
  471. print '<td align="center">'.($objp->num_chq?$objp->num_chq:'&nbsp;').'</td>';
  472. print '<td>'.dol_trunc($objp->emetteur,24).'</td>';
  473. print '<td>'.dol_trunc($objp->banque,24).'</td>';
  474. print '<td align="right">'.price($objp->amount).'</td>';
  475. print '<td align="center">';
  476. $accountlinestatic->rowid=$objp->rowid;
  477. if ($accountlinestatic->rowid)
  478. {
  479. print $accountlinestatic->getNomUrl(1);
  480. }
  481. else
  482. {
  483. print '&nbsp;';
  484. }
  485. print '</td>';
  486. if($remisecheque->statut == 0)
  487. {
  488. print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?id='.$remisecheque->id.'&amp;action=remove&amp;lineid='.$objp->rowid.'">'.img_delete().'</a></td>';
  489. }
  490. else
  491. {
  492. print '<td>&nbsp;</td>';
  493. }
  494. print '</tr>';
  495. $var=!$var;
  496. $i++;
  497. }
  498. print "</table>";
  499. }
  500. else
  501. {
  502. dol_print_error($db);
  503. }
  504. dol_fiche_end();
  505. }
  506. /*
  507. * Boutons Actions
  508. */
  509. print '<div class="tabsAction">';
  510. if ($user->societe_id == 0 && count($accounts) == 1 && $action == 'new' && $user->rights->banque->cheque)
  511. {
  512. print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=create&amp;accountid='.$account_id.'">'.$langs->trans('NewCheckReceipt').'</a>';
  513. }
  514. if ($user->societe_id == 0 && $remisecheque->statut == 0 && $remisecheque->id && $user->rights->banque->cheque)
  515. {
  516. print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$remisecheque->id.'&amp;action=valide&amp;sortfield='.$sortfield.'&amp;sortorder='.$sortorder.'">'.$langs->trans('Valid').'</a>';
  517. }
  518. if ($user->societe_id == 0 && $remisecheque->id && $user->rights->banque->cheque)
  519. {
  520. print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$remisecheque->id.'&amp;action=delete&amp;sortfield='.$sortfield.'&amp;sortorder='.$sortorder.'">'.$langs->trans('Delete').'</a>';
  521. }
  522. print '</div>';
  523. if ($action != 'new')
  524. {
  525. if ($remisecheque->statut == 1)
  526. {
  527. $dirchequereceipts = $dir.get_exdir($remisecheque->number,2,1).$remisecheque->ref;
  528. $formfile->show_documents("remisecheque",$remisecheque->ref,$dirchequereceipts,$_SERVER["PHP_SELF"].'?id='.$remisecheque->id,1,1);
  529. print '<br>';
  530. }
  531. }
  532. $db->close();
  533. llxFooter();
  534. ?>