31require 
'../../../main.inc.php';
 
   32require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
 
   33require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
 
   34require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/cheque/class/remisecheque.class.php';
 
   35require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
 
   38$langs->loadLangs(array(
'banks', 
'categories', 
'bills', 
'companies', 
'compta'));
 
   42$action = 
GETPOST(
'action', 
'aZ09');
 
   43$confirm = 
GETPOST(
'confirm', 
'alpha');
 
   52$sortfield = 
GETPOST(
'sortfield', 
'aZ09comma');
 
   53$sortorder = 
GETPOST(
'sortorder', 
'aZ09comma');
 
   54$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) : 
GETPOST(
"page", 
'int');
 
   59  $sortfield = 
"b.dateo,b.rowid";
 
   61if (empty($page) || $page == -1) {
 
   64$limit = 
GETPOST(
'limit', 
'int') ? 
GETPOST(
'limit', 
'int') : $conf->liste_limit;
 
   65$offset = $limit * $page;
 
   67$upload_dir = $conf->bank->multidir_output[$object->entity ? $object->entity : $conf->entity].
"/checkdeposits";
 
   70$search_date_start_day = 
GETPOST(
'search_date_start_day', 
'int');
 
   71$search_date_start_month = 
GETPOST(
'search_date_start_month', 
'int');
 
   72$search_date_start_year = 
GETPOST(
'search_date_start_year', 
'int');
 
   73$search_date_end_day = 
GETPOST(
'search_date_end_day', 
'int');
 
   74$search_date_end_month = 
GETPOST(
'search_date_end_month', 
'int');
 
   75$search_date_end_year = 
GETPOST(
'search_date_end_year', 
'int');
 
   76$search_date_start = 
dol_mktime(0, 0, 0, $search_date_start_month, $search_date_start_day, $search_date_start_year);
 
   77$search_date_end = 
dol_mktime(23, 59, 59, $search_date_end_month, $search_date_end_day, $search_date_end_year);
 
   78$filteraccountid = 
GETPOST(
'accountid', 
'int');
 
   81$fieldname = (!empty($ref) ? 
'ref' : 
'rowid');
 
   83  $socid = $user->socid;
 
   85$result = 
restrictedArea($user, 
'cheque', $id, 
'bordereau_cheque', 
'', 
'fk_user_author', $fieldname);
 
   87$usercanread = $user->rights->banque->cheque;
 
   88$usercancreate = $user->rights->banque->cheque;
 
   89$usercandelete = $user->rights->banque->cheque;
 
   91$permissiontodelete = $user->rights->banque->cheque;
 
   95$arrayofpaymentmodetomanage = explode(
',', 
getDolGlobalString(
'BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT', 
'CHQ'));
 
  102if ($action == 
'setdate' && $user->hasRight(
'banque', 
'cheque')) {
 
  103  $result = $object->fetch(
GETPOST(
'id', 
'int'));
 
  107    $result = $object->set_date($user, $date);
 
  116if ($action == 
'setrefext' && $user->hasRight(
'banque', 
'cheque')) {
 
  117  $result = $object->fetch(
GETPOST(
'id', 
'int'));
 
  121    $result = $object->setValueFrom(
'ref_ext', $ref_ext, 
'', 
null, 
'text', 
'', $user, 
'CHECKDEPOSIT_MODIFY');
 
  130if ($action == 
'setref' && $user->hasRight(
'banque', 
'cheque')) {
 
  131  $result = $object->fetch(
GETPOST(
'id', 
'int'));
 
  135    $result = $object->set_number($user, $ref);
 
  144if ($action == 
'create' && 
GETPOST(
"accountid", 
"int") > 0 && $user->hasRight(
'banque', 
'cheque')) {
 
  146    $object->type = $type;
 
  147    $arrayofid = 
GETPOST(
'toRemise', 
'array:int');
 
  149    $result = $object->create($user, 
GETPOST(
"accountid", 
"int"), 0, $arrayofid);
 
  151      if ($object->statut == 1) {     
 
  152        $object->fetch($object->id); 
 
  154        $outputlangs = $langs;
 
  157          $newlang = 
GETPOST(
'lang_id', 
'aZ09');
 
  160        if (!empty($newlang)) {
 
  162          $outputlangs->setDefaultLang($newlang);
 
  164        $result = $object->generatePdf(
GETPOST(
"model"), $outputlangs);
 
  167      header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$object->id);
 
  178if ($action == 
'remove' && $id > 0 && 
GETPOST(
"lineid", 
'int') > 0 && $user->hasRight(
'banque', 
'cheque')) {
 
  180  $result = $object->removeCheck(
GETPOST(
"lineid", 
"int"));
 
  182    header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$object->id);
 
  189if ($action == 
'confirm_delete' && $confirm == 
'yes' && $user->hasRight(
'banque', 
'cheque')) {
 
  191  $result = $object->delete($user);
 
  193    header(
"Location: index.php");
 
  200if ($action == 
'confirm_validate' && $confirm == 
'yes' && $user->hasRight(
'banque', 
'cheque')) {
 
  201  $result = $object->fetch($id);
 
  202  $result = $object->validate($user);
 
  205    $outputlangs = $langs;
 
  208      $newlang = 
GETPOST(
'lang_id', 
'aZ09');
 
  211    if (!empty($newlang)) {
 
  213      $outputlangs->setDefaultLang($newlang);
 
  215    $result = $object->generatePdf(
GETPOST(
'model'), $outputlangs);
 
  217    header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$object->id);
 
  224if ($action == 
'confirm_reject_check' && $confirm == 
'yes' && $user->hasRight(
'banque', 
'cheque')) {
 
  226  $rejected_check = 
GETPOST(
'bankid', 
'int');
 
  229  $paiement_id = $object->rejectCheck($rejected_check, $reject_date);
 
  230  if ($paiement_id > 0) {
 
  231    setEventMessages($langs->trans(
"CheckRejectedAndInvoicesReopened"), 
null, 
'mesgs');
 
  241if ($action == 
'builddoc' && $user->hasRight(
'banque', 
'cheque')) {
 
  242  $result = $object->fetch($id);
 
  247  $outputlangs = $langs;
 
  250    $newlang = 
GETPOST(
'lang_id', 
'aZ09');
 
  253  if (!empty($newlang)) {
 
  255    $outputlangs->setDefaultLang($newlang);
 
  257  $result = $object->generatePdf(
GETPOST(
"model"), $outputlangs);
 
  262    header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.(!
getDolGlobalString(
'MAIN_JUMP_TAG') ? 
'' : 
'#builddoc'));
 
  265} elseif ($action == 
'remove_file' && $user->hasRight(
'banque', 
'cheque')) {
 
  267  if ($object->fetch($id) > 0) {
 
  268    include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
 
  270    $langs->load(
"other");
 
  272    $filetodelete = 
GETPOST(
'file', 
'alpha');
 
  273    $file = $upload_dir.
'/'.$filetodelete;
 
  291  $search_date_start_day = 
'';
 
  292  $search_date_start_month = 
'';
 
  293  $search_date_start_year = 
'';
 
  294  $search_date_end_day = 
'';
 
  295  $search_date_end_month = 
'';
 
  296  $search_date_end_year = 
'';
 
  297  $search_date_start = 
'';
 
  298  $search_date_end = 
'';
 
  299  $filteraccountid = 0;
 
  302if ($action == 
'new') {
 
  303  $title = $langs->trans(
"NewChequeDeposit");
 
  305  if ($type == 
'CHQ') {
 
  306    $title = $langs->trans(
"Cheques");
 
  308    $title = ($langs->trans(
"PaymentType".$type) != 
"PaymentType".$type ? $langs->trans(
"PaymentType".$type) : $langs->trans(
"PaymentMode").
' '.$type);
 
  315$form = 
new Form($db);
 
  319if ($action == 
'new') {
 
  322  $head[$h][0] = $_SERVER[
"PHP_SELF"].
'?action=new';
 
  323  $head[$h][1] = $langs->trans(
"MenuChequeDeposits");
 
  329  $result = $object->fetch($id, $ref);
 
  336  $head[$h][0] = $_SERVER[
"PHP_SELF"].
'?id='.$object->id;
 
  337  $head[$h][1] = $langs->trans(
"CheckReceipt");
 
  349  if ($action == 
'delete') {
 
  350    print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
"DeleteCheckReceipt"), $langs->trans(
"ConfirmDeleteCheckReceipt"), 
'confirm_delete', 
'', 
'', 1);
 
  356  if ($action == 
'valide') {
 
  357    print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
"ValidateCheckReceipt"), $langs->trans(
"ConfirmValidateCheckReceipt"), 
'confirm_validate', 
'', 
'', 1);
 
  363  if ($action == 
'reject_check') {
 
  364    $formquestion = array(
 
  365      array(
'type' => 
'hidden', 
'name' => 
'bankid', 
'value' => 
GETPOST(
'lineid', 
'int')),
 
  366      array(
'type' => 
'date', 
'name' => 
'rejectdate_', 
'label' => $langs->trans(
"RejectCheckDate"), 
'value' => 
dol_now())
 
  368    print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
"RejectCheck"), $langs->trans(
"ConfirmRejectCheck"), 
'confirm_reject_check', $formquestion, 
'', 1);
 
  374if ($action == 
'new') {
 
  382  $labeltype = ($langs->trans(
"PaymentType".$type) != 
"PaymentType".$type ? $langs->trans(
"PaymentType".$type) : $type);
 
  383  if ($type == 
'CHQ') {
 
  384    print 
'<span class="opacitymedium">'.$langs->trans(
"SelectChequeTransactionAndGenerate").
'</span><br><br>'.
"\n";
 
  386    print 
'<span class="opacitymedium">'.$langs->trans(
"SelectPaymentTransactionAndGenerate", $labeltype).
'</span><br><br>'.
"\n";
 
  389  print 
'<form class="nocellnopadd" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
 
  390  print 
'<input type="hidden" name="token" value="'.newToken().
'">';
 
  391  print 
'<input type="hidden" name="action" value="new">';
 
  395  print 
'<table class="border centpercent">';
 
  397  if (count($arrayofpaymentmodetomanage) > 1) {
 
  398    $arrayoflabels = array();
 
  399    foreach ($arrayofpaymentmodetomanage as $key => $val) {
 
  400      $labelval = ($langs->trans(
"PaymentType".$val) != 
"PaymentType".$val ? $langs->trans(
"PaymentType".$val) : $val);
 
  401      $arrayoflabels[$key] = $labelval;
 
  405    print $langs->trans(
"Type");
 
  407    print $form->selectarray(
'type', $arrayoflabels, $type);
 
  411  print 
'<tr><td class="titlefieldcreate">';
 
  412  if ($type == 
'CHQ') {
 
  413    print $langs->trans(
"DateChequeReceived");
 
  415    print $langs->trans(
"DatePaymentReceived");
 
  419  print 
'<div class="nowrapfordate">';
 
  420  print $form->selectDate($search_date_start, 
'search_date_start_', 0, 0, 1, 
'', 1, 1, 0, 
'', 
'', 
'', 
'', 1, 
'', $langs->trans(
'From'));
 
  422  print 
'<div class="nowrapfordate">';
 
  423  print $form->selectDate($search_date_end, 
'search_date_end_', 0, 0, 1, 
'', 1, 1, 0, 
'', 
'', 
'', 
'', 1, 
'', $langs->trans(
'to'));
 
  426  print 
'<tr><td>'.$langs->trans(
"BankAccount").
'</td><td>';
 
  427  $form->select_comptes($filteraccountid, 
'accountid', 0, 
'courant <> 2', 1);
 
  433  print 
'<div class="center">';
 
  434  print 
'<input type="submit" class="button small" name="filter" value="'.dol_escape_htmltag($langs->trans(
"ToFilter")).
'">';
 
  435  if ($search_date_start || $search_date_end || $filteraccountid > 0) {
 
  437    print 
'<input type="submit" class="button" name="removefilter small" value="'.dol_escape_htmltag($langs->trans(
"RemoveFilter")).
'">';
 
  444  $sql = 
"SELECT ba.rowid as bid, ba.label,";
 
  445  $sql .= 
" b.rowid as transactionid, b.label as transactionlabel, b.datec as datec, b.dateo as date, ";
 
  446  $sql .= 
" b.amount, b.emetteur, b.num_chq, b.banque,";
 
  447  $sql .= 
" p.rowid as paymentid, p.ref as paymentref";
 
  448  $sql .= 
" FROM ".MAIN_DB_PREFIX.
"bank as b";
 
  449  $sql .= 
" LEFT JOIN ".MAIN_DB_PREFIX.
"paiement as p ON p.fk_bank = b.rowid";
 
  450  $sql .= 
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank_account as ba ON (b.fk_account = ba.rowid)";
 
  451  $sql .= 
" WHERE b.fk_type = '".$db->escape($type).
"'";
 
  452  $sql .= 
" AND ba.entity IN (".getEntity(
'bank_account').
")";
 
  453  $sql .= 
" AND b.fk_bordereau = 0";
 
  454  $sql .= 
" AND b.amount > 0";
 
  455  if ($search_date_start) {
 
  456    $sql .= 
" AND b.dateo >= '".$db->idate($search_date_start).
"'";
 
  458  if ($search_date_end) {
 
  459    $sql .= 
" AND b.dateo <= '".$db->idate($search_date_end).
"'";
 
  461  if ($filteraccountid > 0) {
 
  462    $sql .= 
" AND ba.rowid = ".((int) $filteraccountid);
 
  464  $sql .= $db->order(
"b.dateo,b.rowid", 
"ASC");
 
  466  $resql = $db->query($sql);
 
  469    while ($obj = $db->fetch_object($resql)) {
 
  470      $accounts[$obj->bid] = $obj->label;
 
  471      $lines[$obj->bid][$i][
"date"] = $db->jdate($obj->datec);
 
  472      $lines[$obj->bid][$i][
"amount"] = $obj->amount;
 
  473      $lines[$obj->bid][$i][
"emetteur"] = $obj->emetteur;
 
  474      $lines[$obj->bid][$i][
"numero"] = $obj->num_chq;
 
  475      $lines[$obj->bid][$i][
"banque"] = $obj->banque;
 
  476      $lines[$obj->bid][$i][
"id"] = $obj->transactionid;
 
  477      $lines[$obj->bid][$i][
"ref"] = $obj->transactionid;
 
  478      $lines[$obj->bid][$i][
"label"] = $obj->transactionlabel;
 
  479      $lines[$obj->bid][$i][
"paymentid"] = $obj->paymentid;
 
  480      $lines[$obj->bid][$i][
"paymentref"] = $obj->paymentref;
 
  481      $lines[$obj->bid][$i][
"paymentdate"] = $db->jdate($obj->date);
 
  486      if ($type == 
'CHQ') {
 
  487        print 
'<div class="opacitymedium">'.$langs->trans(
"NoWaitingChecks").
'</div><br>';
 
  489        print 
'<div class="opacitymedium">'.$langs->trans(
"NoWaitingPaymentForDeposit", $labeltype).
'</div><br>';
 
  494  foreach ($accounts as $bid => $account_label) {
 
  496        <script type="text/javascript"> 
  497        jQuery(document).ready(function() 
  499            jQuery("#checkall_'.$bid.
'").click(function() 
  501                jQuery(".checkforremise_'.$bid.
'").prop(\'checked\', true); 
  503            jQuery("#checknone_'.$bid.
'").click(function() 
  505                jQuery(".checkforremise_'.$bid.
'").prop(\'checked\', false); 
  511    $num = $db->num_rows($resql);
 
  513    print 
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
 
  514    print 
'<input type="hidden" name="token" value="'.newToken().
'">';
 
  515    print 
'<input type="hidden" name="action" value="create">';
 
  516    print 
'<input type="hidden" name="type" value="'.$type.
'">';
 
  517    print 
'<input type="hidden" name="accountid" value="'.$bid.
'">';
 
  520    print 
'<div class="div-table-responsive-no-min">';
 
  521    print 
'<table class="tagtable liste'.($moreforfilter ? 
" listwithfilterbefore" : 
"").
'">'.
"\n";
 
  523    print 
'<tr class="liste_titre">';
 
  525    if ($type == 
'CHQ') {
 
  526      print $langs->trans(
"DateChequeReceived");
 
  528      print $langs->trans(
"DatePaymentForDepositReceived", $type);
 
  531    print 
'<td>'.$langs->trans(
"ChequeNumber").
"</td>\n";
 
  532    print 
'<td>'.$langs->trans(
"CheckTransmitter").
"</td>\n";
 
  533    print 
'<td>'.$langs->trans(
"Bank").
"</td>\n";
 
  534    print 
'<td class="right">'.$langs->trans(
"Amount").
"</td>\n";
 
  535    print 
'<td class="center">'.$langs->trans(
"Payment").
"</td>\n";
 
  536    print 
'<td class="center">'.$langs->trans(
"LineRecord").
"</td>\n";
 
  537    print 
'<td class="center">'.$langs->trans(
"Select").
"<br>";
 
  538    if ($conf->use_javascript_ajax) {
 
  539      print 
'<a href="#" id="checkall_'.$bid.
'">'.$langs->trans(
"All").
'</a> / <a href="#" id="checknone_'.$bid.
'">'.$langs->trans(
"None").
'</a>';
 
  544    if (count($lines[$bid])) {
 
  545      foreach ($lines[$bid] as $lid => $value) {
 
  546        print 
'<tr class="oddeven">';
 
  547        print 
'<td>'.dol_print_date($value[
"paymentdate"], 
'day').
'</td>';
 
  548        print 
'<td>'.$value[
"numero"].
"</td>\n";
 
  549        print 
'<td>'.$value[
"emetteur"].
"</td>\n";
 
  550        print 
'<td>'.$value[
"banque"].
"</td>\n";
 
  551        print 
'<td class="right"><span class="amount">'.price($value[
"amount"], 0, $langs, 1, -1, -1, $conf->currency).
'</span></td>';
 
  554        print 
'<td class="center">';
 
  555        $paymentstatic->id = $value[
"paymentid"];
 
  556        $paymentstatic->ref = $value[
"paymentref"];
 
  557        $paymentstatic->date = $value[
"paymentdate"];
 
  558        if ($paymentstatic->id) {
 
  559          print $paymentstatic->getNomUrl(1);
 
  565        print 
'<td class="center">';
 
  566        $accountlinestatic->id = $value[
"id"];
 
  567        $accountlinestatic->ref = $value[
"ref"];
 
  568        if ($accountlinestatic->id > 0) {
 
  569          print $accountlinestatic->getNomUrl(1);
 
  575        print 
'<td class="center">';
 
  576        print 
'<input id="'.$value[
"id"].
'" class="flat checkforremise_'.$bid.
'" checked type="checkbox" name="toRemise[]" value="'.$value[
"id"].
'">';
 
  584    print 
'<div class="tabsAction">';
 
  585    if ($user->hasRight(
'banque', 
'cheque')) {
 
  586      print 
'<input type="submit" class="button" value="'.$langs->trans(
'NewCheckDepositOn', $account_label).
'">';
 
  588      print 
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
'NewCheckDepositOn', $account_label).
'</a>';
 
  596  $accountstatic = 
new Account($db);
 
  597  $accountstatic->fetch($object->account_id);
 
  599  $linkback = 
'<a href="'.DOL_URL_ROOT.
'/compta/paiement/cheque/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
 
  603  $moreghtmlright = 
'';
 
  605  $labelval = ($langs->trans(
"PaymentType".$object->type) != 
"PaymentType".$object->type ? $langs->trans(
"PaymentType".$object->type) : $object->type);
 
  606  $morehtmlref = 
'<br><div class="refidno">'.$langs->trans(
"Type").
' : '.$labelval.
'</div>';
 
  608  dol_banner_tab($object, 
'ref', $linkback, 1, 
'ref', 
'ref', $morehtmlref, 
'', 0, $morehtmlleft, 
'', 0, $moreghtmlright);
 
  611  print 
'<div class="fichecenter">';
 
  612  print 
'<div class="underbanner clearboth"></div>';
 
  614  print 
'<table class="border centpercent">';
 
  616  print 
'<tr><td class="titlefield">';
 
  618  print 
'<table class="nobordernopadding centpercent"><tr><td>';
 
  619  print $langs->trans(
'Date');
 
  621  if ($action != 
'editdate') {
 
  622    print 
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editdate&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->trans(
'SetDate'), 1).
'</a></td>';
 
  624  print 
'</tr></table>';
 
  627  if ($action == 
'editdate') {
 
  628    print 
'<form name="setdate" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="post">';
 
  629    print 
'<input type="hidden" name="token" value="'.newToken().
'">';
 
  630    print 
'<input type="hidden" name="action" value="setdate">';
 
  631    print $form->selectDate($object->date_bordereau, 
'datecreate_', 
'', 
'', 
'', 
"setdate");
 
  632    print 
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
 
  635    print $object->date_bordereau ? 
dol_print_date($object->date_bordereau, 
'day') : 
' ';
 
  644    print 
'<table class="nobordernopadding" width="100%"><tr><td>';
 
  645    print $langs->trans(
'RefExt');
 
  647    if ($action != 
'editrefext') {
 
  648      print 
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editrefext&token='.newToken().
'&id='.((int) $object->id).
'">'.
img_edit($langs->trans(
'SetRefExt'), 1).
'</a></td>';
 
  650    print 
'</tr></table>';
 
  652    if ($action == 
'editrefext') {
 
  653      print 
'<form name="setrefext" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="post">';
 
  654      print 
'<input type="hidden" name="token" value="'.newToken().
'">';
 
  655      print 
'<input type="hidden" name="action" value="setrefext">';
 
  656      print 
'<input type="text" name="ref_ext" value="'.$object->ref_ext.
'">';
 
  657      print 
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
 
  660      print $object->ref_ext;
 
  665  print 
'<tr><td>'.$langs->trans(
'Account').
'</td><td>';
 
  666  print $accountstatic->getNomUrl(1);
 
  670  print 
'<tr><td>'.$langs->trans(
'NbOfCheques').
'</td><td>';
 
  671  print $object->nbcheque;
 
  674  print 
'<tr><td>'.$langs->trans(
'Total').
'</td><td>';
 
  675  print 
'<span class="amount">'.price($object->amount).
'</span>';
 
  678  print 
'</table><br>';
 
  684  $sql = 
"SELECT b.rowid, b.rowid as ref, b.label, b.amount, b.num_chq, b.emetteur,";
 
  685  $sql .= 
" b.dateo as date, b.datec as datec, b.banque,";
 
  686  $sql .= 
" p.rowid as pid, p.ref as pref, ba.rowid as bid, p.statut";
 
  687  $sql .= 
" FROM ".MAIN_DB_PREFIX.
"bank_account as ba";
 
  688  $sql .= 
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank as b ON (b.fk_account = ba.rowid)";
 
  689  $sql .= 
" LEFT JOIN ".MAIN_DB_PREFIX.
"paiement as p ON p.fk_bank = b.rowid";
 
  690  $sql .= 
" WHERE ba.entity IN (".getEntity(
'bank_account').
")";
 
  691  $sql .= 
" AND b.fk_type= '".$db->escape($object->type).
"'";
 
  692  $sql .= 
" AND b.fk_bordereau = ".((int) $object->id);
 
  693  $sql .= $db->order($sortfield, $sortorder);
 
  695  $resql = $db->query($sql);
 
  697    $num = $db->num_rows($resql);
 
  699    print 
'<div class="div-table-responsive">';
 
  700    print 
'<table class="noborder centpercent">';
 
  702    $param = 
"&id=".$object->id;
 
  704    print 
'<tr class="liste_titre">';
 
  706    print_liste_field_titre(
"DateChequeReceived", $_SERVER[
"PHP_SELF"], 
"b.dateo,b.rowid", 
"", $param, 
'align="center"', $sortfield, $sortorder);
 
  707    print_liste_field_titre(
"Numero", $_SERVER[
"PHP_SELF"], 
"b.num_chq", 
"", $param, 
'align="center"', $sortfield, $sortorder);
 
  708    print_liste_field_titre(
"CheckTransmitter", $_SERVER[
"PHP_SELF"], 
"b.emetteur", 
"", $param, 
"", $sortfield, $sortorder);
 
  710    print_liste_field_titre(
"Amount", $_SERVER[
"PHP_SELF"], 
"b.amount", 
"", $param, 
'class="right"', $sortfield, $sortorder);
 
  711    print_liste_field_titre(
"Payment", $_SERVER[
"PHP_SELF"], 
"p.rowid", 
"", $param, 
'align="center"', $sortfield, $sortorder);
 
  712    print_liste_field_titre(
"LineRecord", $_SERVER[
"PHP_SELF"], 
"b.rowid", 
"", $param, 
'align="center"', $sortfield, $sortorder);
 
  718      while ($objp = $db->fetch_object($resql)) {
 
  719        $paymentstatic->id = $objp->pid;
 
  720        $paymentstatic->ref = $objp->pref;
 
  722        $accountlinestatic->id = $objp->rowid;
 
  723        $accountlinestatic->ref = $objp->ref;
 
  725        print 
'<tr class="oddeven">';
 
  726        print 
'<td class="center">'.$i.
'</td>';
 
  727        print 
'<td class="center">'.dol_print_date($db->jdate($objp->date), 
'day').
'</td>'; 
 
  728        print 
'<td class="center">'.($objp->num_chq ? $objp->num_chq : 
' ').
'</td>';
 
  729        print 
'<td>'.dol_trunc($objp->emetteur, 24).
'</td>';
 
  730        print 
'<td>'.dol_trunc($objp->banque, 24).
'</td>';
 
  731        print 
'<td class="right"><span class="amount">'.price($objp->amount).
'</span></td>';
 
  733        print 
'<td class="center">';
 
  734        if ($paymentstatic->id) {
 
  735          print $paymentstatic->getNomUrl(1);
 
  741        print 
'<td class="center">';
 
  742        if ($accountlinestatic->id > 0) {
 
  743          print $accountlinestatic->getNomUrl(1);
 
  749        print 
'<td class="right">';
 
  750        if ($object->statut == 0) {
 
  751          print 
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=remove&token='.newToken().
'&lineid='.$objp->rowid.
'">'.
img_delete().
'</a>';
 
  753        if ($object->statut == 1 && $objp->statut != 2) {
 
  754          print 
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=reject_check&token='.newToken().
'&lineid='.$objp->rowid.
'">'.
img_picto($langs->trans(
"RejectCheck"), 
'disable').
'</a>';
 
  756        if ($objp->statut == 2) {
 
  757          print 
'   '.img_picto($langs->trans(
'CheckRejected'), 
'statut8').
'</a>';
 
  765      print 
'<td colspan="9"><span class="opacitymedium">';
 
  766      print $langs->trans(
"None");
 
  767      print 
'</span></td>';
 
  773    if ($num > 0 && $i < ($object->nbcheque + 1)) {
 
  775      $langs->load(
"errors");
 
  776      print 
info_admin($langs->trans(
"WarningSomeBankTransactionByChequeWereRemovedAfter"), 0, 0, 
'warning');
 
  795print 
'<div class="tabsAction">';
 
  797if ($user->socid == 0 && !empty($object->id) && $object->statut == 0 && $user->hasRight(
'banque', 
'cheque')) {
 
  798  print 
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=valide&token='.newToken().
'&sortfield='.$sortfield.
'&sortorder='.$sortorder.
'">'.$langs->trans(
'Validate').
'</a>';
 
  801if ($user->socid == 0 && !empty($object->id) && $user->hasRight(
'banque', 
'cheque')) {
 
  802  print 
dolGetButtonAction($langs->trans(
"Delete"), 
'', 
'delete', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.newToken(), 
'delete', $permissiontodelete);
 
  808if ($action != 
'new') {
 
  809  if ($object->statut == 1) {
 
  812    $filedir = $upload_dir.
'/'.$objref;
 
  813    $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
 
  814    $genallowed = $usercancreate;
 
  815    $delallowed = $usercandelete;
 
  816    print $formfile->showdocuments(
'remisecheque', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, 
'', 
'', 
'', $langs->defaultlang);
 
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
 
Class to manage bank accounts.
 
Class to manage bank transaction lines.
 
Class to manage payments of customer invoices.
 
Class to manage cheque delivery receipts.
 
Class to manage translations.
 
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
 
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
 
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
 
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
 
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
 
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
 
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
 
dol_get_fiche_end($notab=0)
Return tab footer of a card.
 
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
 
GETPOSTISARRAY($paramname, $method=0)
Return true if the parameter $paramname is submit from a POST OR GET as an array.
 
dol_now($mode='auto')
Return date for now.
 
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
 
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
 
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
 
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
 
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
 
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
 
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
 
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
 
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
 
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
 
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.