list.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <?php
  2. /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2005-2016 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/list.php
  22. * \ingroup prelevement
  23. * \brief Page liste des 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/prelevement/class/ligneprelevement.class.php';
  28. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
  29. $langs->load("banks");
  30. $langs->load("withdrawals");
  31. $langs->load("companies");
  32. $langs->load("categories");
  33. // Security check
  34. $socid = GETPOST('socid','int');
  35. if ($user->societe_id) $socid=$user->societe_id;
  36. $result = restrictedArea($user, 'prelevement','','','bons');
  37. $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
  38. $sortfield = GETPOST('sortfield','alpha');
  39. $sortorder = GETPOST('sortorder','alpha');
  40. $page = GETPOST('page','int');
  41. if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
  42. $offset = $limit * $page;
  43. $pageprev = $page - 1;
  44. $pagenext = $page + 1;
  45. if (! $sortorder) $sortorder="DESC";
  46. if (! $sortfield) $sortfield="p.datec";
  47. $search_line = GETPOST('search_line','alpha');
  48. $search_bon = GETPOST('search_bon','alpha');
  49. $search_code = GETPOST('search_code','alpha');
  50. $search_company = GETPOST('search_company','alpha');
  51. $statut = GETPOST('statut','int');
  52. $bon=new BonPrelevement($db,"");
  53. $ligne=new LignePrelevement($db,$user);
  54. /*
  55. * Actions
  56. */
  57. if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers
  58. {
  59. $search_line="";
  60. $search_bon="";
  61. $search_code="";
  62. $search_company="";
  63. $statut="";
  64. }
  65. /*
  66. * View
  67. */
  68. $form=new Form($db);
  69. llxHeader('',$langs->trans("WithdrawalsLines"));
  70. $sql = "SELECT p.rowid, p.ref, p.statut, p.datec";
  71. $sql.= " ,f.rowid as facid, f.facnumber, f.total_ttc";
  72. $sql.= " , s.rowid as socid, s.nom as name, s.code_client";
  73. $sql.= " , pl.amount, pl.statut as statut_ligne, pl.rowid as rowid_ligne";
  74. $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
  75. $sql.= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl";
  76. $sql.= " , ".MAIN_DB_PREFIX."prelevement_facture as pf";
  77. $sql.= " , ".MAIN_DB_PREFIX."facture as f";
  78. $sql.= " , ".MAIN_DB_PREFIX."societe as s";
  79. $sql.= " WHERE pl.fk_prelevement_bons = p.rowid";
  80. $sql.= " AND pf.fk_prelevement_lignes = pl.rowid";
  81. $sql.= " AND pf.fk_facture = f.rowid";
  82. $sql.= " AND f.fk_soc = s.rowid";
  83. $sql.= " AND f.entity = ".$conf->entity;
  84. if ($socid) $sql.= " AND s.rowid = ".$socid;
  85. if ($search_line) $sql.= " AND pl.rowid = '".$db->escape($search_line)."'";
  86. if ($search_bon) $sql.= natural_search("p.ref", $search_bon);
  87. if ($search_code) $sql.= natural_search("s.code_client", $search_code);
  88. if ($search_company) natural_search("s.nom", $search_company);
  89. $sql.= $db->order($sortfield,$sortorder);
  90. // Count total nb of records
  91. $nbtotalofrecords = '';
  92. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
  93. {
  94. $result = $db->query($sql);
  95. $nbtotalofrecords = $db->num_rows($result);
  96. }
  97. $sql.= $db->plimit($limit + 1,$offset);
  98. $result = $db->query($sql);
  99. if ($result)
  100. {
  101. $num = $db->num_rows($result);
  102. $i = 0;
  103. $urladd = "&amp;statut=".$statut;
  104. $urladd .= "&amp;search_bon=".$search_bon;
  105. print_barre_liste($langs->trans("WithdrawalsLines"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic', 0, '', '', $limit);
  106. print"\n<!-- debut table -->\n";
  107. print '<form action="'.$_SERVER["PHP_SELF"].'" method="GET">';
  108. $moreforfilter='';
  109. print '<div class="div-table-responsive">';
  110. print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
  111. print '<tr class="liste_titre">';
  112. print_liste_field_titre($langs->trans("Line"),$_SERVER["PHP_SELF"]);
  113. print_liste_field_titre($langs->trans("WithdrawalsReceipts"),$_SERVER["PHP_SELF"],"p.ref");
  114. print_liste_field_titre($langs->trans("Bill"),$_SERVER["PHP_SELF"],"f.facnumber",'',$urladd);
  115. print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom");
  116. print_liste_field_titre($langs->trans("CustomerCode"),$_SERVER["PHP_SELF"],"s.code_client",'','','align="center"');
  117. print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"p.datec","","",'align="center"');
  118. print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"pl.amount","","",'align="right"');
  119. print_liste_field_titre('');
  120. print "</tr>\n";
  121. print '<tr class="liste_titre">';
  122. print '<td class="liste_titre"><input type="text" class="flat" name="search_line" value="'. dol_escape_htmltag($search_line).'" size="6"></td>';
  123. print '<td class="liste_titre"><input type="text" class="flat" name="search_bon" value="'. dol_escape_htmltag($search_bon).'" size="6"></td>';
  124. print '<td class="liste_titre">&nbsp;</td>';
  125. print '<td class="liste_titre"><input type="text" class="flat" name="search_company" value="'. dol_escape_htmltag($search_company).'" size="6"></td>';
  126. print '<td class="liste_titre" align="center"><input type="text" class="flat" name="search_code" value="'. dol_escape_htmltag($search_code).'" size="6"></td>';
  127. print '<td class="liste_titre">&nbsp;</td>';
  128. print '<td class="liste_titre">&nbsp;</td>';
  129. print '<td class="liste_titre" align="right">';
  130. $searchpicto=$form->showFilterAndCheckAddButtons(0);
  131. print $searchpicto;
  132. print '</td>';
  133. print '</tr>';
  134. while ($i < min($num,$limit))
  135. {
  136. $obj = $db->fetch_object($result);
  137. print '<tr class="oddeven"><td>';
  138. print $ligne->LibStatut($obj->statut_ligne,2);
  139. print "&nbsp;";
  140. print '<a href="'.DOL_URL_ROOT.'/compta/prelevement/ligne.php?id='.$obj->rowid_ligne.'">';
  141. print substr('000000'.$obj->rowid_ligne, -6);
  142. print '</a></td>';
  143. print '<td>';
  144. print $bon->LibStatut($obj->statut,2);
  145. print "&nbsp;";
  146. print '<a href="card.php?id='.$obj->rowid.'">'.$obj->ref."</a></td>\n";
  147. print '<td><a href="'.DOL_URL_ROOT.'/compta/facture/card.php?facid='.$obj->facid.'">';
  148. print img_object($langs->trans("ShowBill"),"bill");
  149. print '&nbsp;<a href="'.DOL_URL_ROOT.'/compta/facture/card.php?facid='.$obj->facid.'">'.$obj->facnumber."</a></td>\n";
  150. print '</a></td>';
  151. print '<td><a href="card.php?id='.$obj->rowid.'">'.$obj->name."</a></td>\n";
  152. print '<td align="center"><a href="card.php?id='.$obj->rowid.'">'.$obj->code_client."</a></td>\n";
  153. print '<td align="center">'.dol_print_date($db->jdate($obj->datec),'day')."</td>\n";
  154. print '<td align="right">'.price($obj->amount)."</td>\n";
  155. print '<td>&nbsp;</td>';
  156. print "</tr>\n";
  157. $i++;
  158. }
  159. print "</table>";
  160. print '</div>';
  161. print '</form>';
  162. $db->free($result);
  163. }
  164. else
  165. {
  166. dol_print_error($db);
  167. }
  168. llxFooter();
  169. $db->close();