index.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. /*
  40. * Actions
  41. */
  42. // None
  43. /*
  44. * View
  45. */
  46. llxHeader('', $langs->trans("ChequesArea"));
  47. $newcardbutton = '';
  48. if ($usercancreate) {
  49. $newcardbutton .= dolGetButtonTitle($langs->trans('NewDeposit'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/paiement/cheque/card.php?action=new');
  50. }
  51. print load_fiche_titre($langs->trans("ChequesArea"), $newcardbutton, $checkdepositstatic->picto);
  52. print '<div class="fichecenter"><div class="fichethirdleft">';
  53. $sql = "SELECT count(b.rowid) as nb";
  54. $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
  55. $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
  56. $sql .= " WHERE ba.rowid = b.fk_account";
  57. $sql .= " AND ba.entity IN (".getEntity('bank_account').")";
  58. $sql .= " AND b.fk_type = 'CHQ'";
  59. $sql .= " AND b.fk_bordereau = 0";
  60. $sql .= " AND b.amount > 0";
  61. $resql = $db->query($sql);
  62. print '<div class="div-table-responsive-no-min">';
  63. print '<table class="noborder centpercent">';
  64. print '<tr class="liste_titre">';
  65. print '<th colspan="2">'.$langs->trans("BankChecks")."</th>\n";
  66. print "</tr>\n";
  67. if ($resql) {
  68. $num = '';
  69. if ($obj = $db->fetch_object($resql)) {
  70. $num = $obj->nb;
  71. }
  72. print '<tr class="oddeven">';
  73. print '<td>'.$langs->trans("BankChecksToReceipt").'</td>';
  74. print '<td class="right">';
  75. print '<a class="badge badge-info" href="'.DOL_URL_ROOT.'/compta/paiement/cheque/card.php?leftmenu=customers_bills_checks&action=new">'.$num.'</a>';
  76. print '</td></tr>';
  77. } else {
  78. dol_print_error($db);
  79. }
  80. print "</table></div>\n";
  81. print '</div><div class="fichetwothirdright">';
  82. $max = 10;
  83. $sql = "SELECT bc.rowid, bc.date_bordereau as db, bc.amount, bc.ref as ref,";
  84. $sql .= " bc.statut, bc.nbcheque,";
  85. $sql .= " ba.ref as bref, ba.label, ba.rowid as bid, ba.number, ba.currency_code, ba.account_number, ba.fk_accountancy_journal,";
  86. $sql .= " aj.code";
  87. $sql .= " FROM ".MAIN_DB_PREFIX."bordereau_cheque as bc, ".MAIN_DB_PREFIX."bank_account as ba";
  88. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_journal as aj ON aj.rowid = ba.fk_accountancy_journal";
  89. $sql .= " WHERE ba.rowid = bc.fk_bank_account";
  90. $sql .= " AND bc.entity = ".$conf->entity;
  91. $sql .= " ORDER BY bc.date_bordereau DESC, rowid DESC";
  92. $sql .= $db->plimit($max);
  93. $resql = $db->query($sql);
  94. if ($resql) {
  95. 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
  96. print '<table class="noborder centpercent">';
  97. print '<tr class="liste_titre">';
  98. print '<th>'.$langs->trans("LastCheckReceiptShort", $max).'</th>';
  99. print '<th>'.$langs->trans("Date")."</th>";
  100. print '<th>'.$langs->trans("Account").'</th>';
  101. print '<th class="right">'.$langs->trans("NbOfCheques").'</th>';
  102. print '<th class="right">'.$langs->trans("Amount").'</th>';
  103. print '<th class="right">'.$langs->trans("Status").'</th>';
  104. print "</tr>\n";
  105. while ($objp = $db->fetch_object($resql)) {
  106. $checkdepositstatic->id = $objp->rowid;
  107. $checkdepositstatic->ref = ($objp->ref ? $objp->ref : $objp->rowid);
  108. $checkdepositstatic->statut = $objp->statut;
  109. $accountstatic->id = $objp->bid;
  110. $accountstatic->ref = $objp->bref;
  111. $accountstatic->label = $objp->label;
  112. $accountstatic->number = $objp->number;
  113. $accountstatic->currency_code = $objp->currency_code;
  114. $accountstatic->account_number = $objp->account_number;
  115. $accountstatic->accountancy_journal = $objp->code;
  116. $accountstatic->fk_accountancy_journal = $objp->fk_accountancy_journal;
  117. print '<tr class="oddeven">'."\n";
  118. print '<td class="nowraponall">'.$checkdepositstatic->getNomUrl(1).'</td>';
  119. print '<td>'.dol_print_date($db->jdate($objp->db), 'day').'</td>';
  120. print '<td class="nowraponall">'.$accountstatic->getNomUrl(1).'</td>';
  121. print '<td class="right">'.$objp->nbcheque.'</td>';
  122. print '<td class="right"><span class="amount">'.price($objp->amount).'</span></td>';
  123. print '<td class="right">'.$checkdepositstatic->LibStatut($objp->statut, 3).'</td>';
  124. print '</tr>';
  125. }
  126. print "</table>";
  127. print '</div>';
  128. $db->free($resql);
  129. } else {
  130. dol_print_error($db);
  131. }
  132. print '</div></div>';
  133. // End of page
  134. llxFooter();
  135. $db->close();