bons.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <?php
  2. /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
  5. * Copyright (C) 2010-2012 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/prelevement/bons.php
  22. * \ingroup prelevement
  23. * \brief Page liste des bons de prelevements
  24. */
  25. require('../../main.inc.php');
  26. require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
  27. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
  28. $langs->load("banks");
  29. $langs->load("categories");
  30. $langs->load("widthdrawals");
  31. // Security check
  32. $socid = GETPOST('socid','int');
  33. if ($user->societe_id) $socid=$user->societe_id;
  34. $result = restrictedArea($user, 'prelevement','','','bons');
  35. $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
  36. $sortfield = GETPOST('sortfield','alpha');
  37. $sortorder = GETPOST('sortorder','alpha');
  38. $page = GETPOST('page','int');
  39. if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
  40. $offset = $limit * $page;
  41. $pageprev = $page - 1;
  42. $pagenext = $page + 1;
  43. if (! $sortorder) $sortorder="DESC";
  44. if (! $sortfield) $sortfield="p.datec";
  45. // Get supervariables
  46. $statut = GETPOST('statut','int');
  47. $search_ref = GETPOST('search_ref','alpha');
  48. /*
  49. * Actions
  50. */
  51. if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers
  52. {
  53. $search_ref="";
  54. }
  55. /*
  56. * View
  57. */
  58. llxHeader('',$langs->trans("WithdrawalsReceipts"));
  59. $bon=new BonPrelevement($db,"");
  60. $sql = "SELECT p.rowid, p.ref, p.amount, p.statut";
  61. $sql.= ", p.datec";
  62. $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
  63. $sql.= " WHERE p.entity = ".$conf->entity;
  64. if ($search_ref) $sql.=natural_search("p.ref", $search_ref);
  65. $sql.= $db->order($sortfield,$sortorder);
  66. // Count total nb of records
  67. $nbtotalofrecords = '';
  68. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
  69. {
  70. $result = $db->query($sql);
  71. $nbtotalofrecords = $db->num_rows($result);
  72. }
  73. $sql.= $db->plimit($limit + 1,$offset);
  74. $result = $db->query($sql);
  75. if ($result)
  76. {
  77. $num = $db->num_rows($result);
  78. $i = 0;
  79. $urladd= "&amp;statut=".$statut;
  80. // Lines of title fields
  81. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
  82. if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  83. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  84. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  85. print '<input type="hidden" name="action" value="list">';
  86. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  87. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  88. print '<input type="hidden" name="page" value="'.$page.'">';
  89. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  90. print_barre_liste($langs->trans("WithdrawalsReceipts"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic', 0, '', '', $limit);
  91. $moreforfilter='';
  92. print '<div class="div-table-responsive">';
  93. print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
  94. print '<tr class="liste_titre">';
  95. print_liste_field_titre($langs->trans("WithdrawalsReceipts"),$_SERVER["PHP_SELF"],"p.ref",'','','class="liste_titre"');
  96. print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"p.datec","","",'class="liste_titre" align="center"');
  97. print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"","","",'align="center"');
  98. print "</tr>\n";
  99. print '<tr class="liste_titre">';
  100. print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_ref" value="'. $db->escape($search_ref).'"></td>';
  101. print '<td class="liste_titre">&nbsp;</td>';
  102. print '<td class="liste_titre" align="right">';
  103. $searchpicto=$form->showFilterAndCheckAddButtons(0);
  104. print $searchpicto;
  105. print '</td>';
  106. print '</tr>';
  107. while ($i < min($num,$limit))
  108. {
  109. $obj = $db->fetch_object($result);
  110. print '<tr class="oddeven"><td>';
  111. print $bon->LibStatut($obj->statut,2);
  112. print "&nbsp;";
  113. print '<a href="card.php?id='.$obj->rowid.'">'.$obj->ref."</a></td>\n";
  114. print '<td align="center">'.dol_print_date($db->jdate($obj->datec),'day')."</td>\n";
  115. print '<td align="right">'.price($obj->amount)."</td>\n";
  116. print "</tr>\n";
  117. $i++;
  118. }
  119. print "</table>";
  120. print '</div>';
  121. print '</form>';
  122. $db->free($result);
  123. }
  124. else
  125. {
  126. dol_print_error($db);
  127. }
  128. llxFooter();
  129. $db->close();