index.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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.houssin@inodbox.com>
  5. * Copyright (C) 2016 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 <https://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \file htdocs/compta/paiement/cheque/index.php
  22. * \ingroup compta
  23. * \brief Home page for cheque receipts
  24. */
  25. // Load Dolibarr environment
  26. require '../../../main.inc.php';
  27. require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
  28. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
  29. // Load translation files required by the page
  30. $langs->loadLangs(array('banks', 'categories', 'compta', 'bills'));
  31. $checkdepositstatic = new RemiseCheque($db);
  32. $accountstatic = new Account($db);
  33. // Security check
  34. if ($user->socid) {
  35. $socid = $user->socid;
  36. }
  37. $result = restrictedArea($user, 'banque', '', '');
  38. $usercancreate = $user->hasRight('banque', 'cheque');
  39. // List of payment mode to support
  40. // Example: BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT = 'CHQ','TRA'
  41. $arrayofpaymentmodetomanage = explode(',', getDolGlobalString('BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT', 'CHQ'));
  42. /*
  43. * Actions
  44. */
  45. // None
  46. /*
  47. * View
  48. */
  49. if (getDolGlobalString('BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT', 'CHQ') == 'CHQ') {
  50. $title = $langs->trans("ChequesArea");
  51. } else {
  52. $title = $langs->trans("DocumentsDepositArea");
  53. }
  54. llxHeader('', $title);
  55. $newcardbutton = '';
  56. if ($usercancreate) {
  57. $newcardbutton .= dolGetButtonTitle($langs->trans('NewDeposit'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/paiement/cheque/card.php?action=new');
  58. }
  59. print load_fiche_titre($title, $newcardbutton, $checkdepositstatic->picto);
  60. print '<div class="fichecenter"><div class="fichethirdleft">';
  61. print '<div class="div-table-responsive-no-min">';
  62. print '<table class="noborder centpercent">';
  63. print '<tr class="liste_titre">';
  64. print '<th colspan="2">'.$langs->trans("DocumentsForDeposit")."</th>\n";
  65. print "</tr>\n";
  66. foreach ($arrayofpaymentmodetomanage as $val) {
  67. $sql = "SELECT count(b.rowid) as nb";
  68. $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
  69. $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
  70. $sql .= " WHERE ba.rowid = b.fk_account";
  71. $sql .= " AND ba.entity IN (".getEntity('bank_account').")";
  72. $sql .= " AND b.fk_type = '".$db->escape($val)."'";
  73. $sql .= " AND b.fk_bordereau = 0";
  74. $sql .= " AND b.amount > 0";
  75. $resql = $db->query($sql);
  76. if ($resql) {
  77. $num = '';
  78. if ($obj = $db->fetch_object($resql)) {
  79. $num = $obj->nb;
  80. }
  81. print '<tr class="oddeven">';
  82. print '<td>';
  83. if ($val == 'CHQ') {
  84. print $langs->trans("BankChecks");
  85. } else {
  86. print ($langs->trans("PaymentType".$val) != "PaymentType".$val ? $langs->trans("PaymentType".$val) : $langs->trans("PaymentMode").' '.$val);
  87. }
  88. print '</td>';
  89. print '<td class="right">';
  90. print '<a class="badge badge-info" href="'.DOL_URL_ROOT.'/compta/paiement/cheque/card.php?leftmenu=customers_bills_checks&action=new&type='.urlencode($val).'">'.dol_escape_htmltag($num).'</a>';
  91. print '</td></tr>';
  92. } else {
  93. dol_print_error($db);
  94. }
  95. }
  96. print "</table></div>\n";
  97. print '</div><div class="fichetwothirdright">';
  98. $max = 10;
  99. foreach ($arrayofpaymentmodetomanage as $val) {
  100. $sql = "SELECT bc.rowid, bc.date_bordereau as db, bc.amount, bc.ref as ref,";
  101. $sql .= " bc.statut as status, bc.nbcheque, bc.type,";
  102. $sql .= " ba.ref as bref, ba.label, ba.rowid as bid, ba.number, ba.currency_code, ba.account_number, ba.fk_accountancy_journal,";
  103. $sql .= " aj.code";
  104. $sql .= " FROM ".MAIN_DB_PREFIX."bordereau_cheque as bc, ".MAIN_DB_PREFIX."bank_account as ba";
  105. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_journal as aj ON aj.rowid = ba.fk_accountancy_journal";
  106. $sql .= " WHERE ba.rowid = bc.fk_bank_account";
  107. $sql .= " AND bc.entity = ".((int) $conf->entity);
  108. $sql .= " AND bc.type = '".$db->escape($val)."'";
  109. $sql .= " ORDER BY bc.date_bordereau DESC, rowid DESC";
  110. $sql .= $db->plimit($max);
  111. $resql = $db->query($sql);
  112. if ($resql) {
  113. print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
  114. print '<table class="noborder centpercent">';
  115. print '<tr class="liste_titre">';
  116. print '<th>';
  117. if ($val == 'CHQ') {
  118. print $langs->trans("LastCheckReceiptShort", $max);
  119. } else {
  120. $labelpaymentmode = ($langs->trans("PaymentType".$val) != "PaymentType".$val ? $langs->trans("PaymentType".$val) : $val);
  121. print $langs->trans("LastPaymentForDepositShort", $max, $labelpaymentmode);
  122. }
  123. print '</th>';
  124. print '<th>'.$langs->trans("Date")."</th>";
  125. print '<th>'.$langs->trans("Account").'</th>';
  126. print '<th class="right">'.$langs->trans("NbOfCheques").'</th>';
  127. print '<th class="right">'.$langs->trans("Amount").'</th>';
  128. print '<th class="right">'.$langs->trans("Status").'</th>';
  129. print "</tr>\n";
  130. $i = 0;
  131. while ($objp = $db->fetch_object($resql)) {
  132. $i++;
  133. $checkdepositstatic->id = $objp->rowid;
  134. $checkdepositstatic->ref = ($objp->ref ? $objp->ref : $objp->rowid);
  135. $checkdepositstatic->statut = $objp->status;
  136. $checkdepositstatic->status = $objp->status;
  137. $accountstatic->id = $objp->bid;
  138. $accountstatic->ref = $objp->bref;
  139. $accountstatic->label = $objp->label;
  140. $accountstatic->number = $objp->number;
  141. $accountstatic->currency_code = $objp->currency_code;
  142. $accountstatic->account_number = $objp->account_number;
  143. $accountstatic->accountancy_journal = $objp->code;
  144. $accountstatic->fk_accountancy_journal = $objp->fk_accountancy_journal;
  145. print '<tr class="oddeven">'."\n";
  146. print '<td class="nowraponall">'.$checkdepositstatic->getNomUrl(1).'</td>';
  147. print '<td>'.dol_print_date($db->jdate($objp->db), 'day').'</td>';
  148. print '<td class="nowraponall">'.$accountstatic->getNomUrl(1).'</td>';
  149. print '<td class="right">'.$objp->nbcheque.'</td>';
  150. print '<td class="right"><span class="amount">'.price($objp->amount).'</span></td>';
  151. print '<td class="right">'.$checkdepositstatic->LibStatut($objp->status, 3).'</td>';
  152. print '</tr>';
  153. }
  154. if ($i == 0) {
  155. print '<tr><td colspan="6"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
  156. }
  157. print "</table>";
  158. print '</div>';
  159. $db->free($resql);
  160. } else {
  161. dol_print_error($db);
  162. }
  163. }
  164. print '</div></div>';
  165. // End of page
  166. llxFooter();
  167. $db->close();