PageRenderTime 51ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

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

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