2012-08-22 23:27:53 +02:00
< ? php
2018-09-09 09:36:12 +02:00
/* Copyright ( C ) 2005 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
* Copyright ( C ) 2005 - 2010 Laurent Destailleur < eldy @ users . sourceforge . net >
* Copyright ( C ) 2010 - 2016 Juanjo Menent < jmenent @ 2 byte . es >
2021-01-13 16:52:32 +01:00
* Copyright ( C ) 2018 - 2021 Frédéric France < frederic . france @ netlogic . fr >
2005-01-07 16:26:30 +01:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2005-01-07 16:26:30 +01:00
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2005-01-07 16:26:30 +01:00
*/
2009-03-28 20:59:12 +01:00
2005-01-21 23:59:48 +01:00
/**
2014-09-18 21:18:25 +02:00
* \file htdocs / compta / prelevement / card . php
2009-03-28 20:59:12 +01:00
* \ingroup prelevement
2017-09-15 16:40:52 +02:00
* \brief Card of a direct debit
2009-03-28 20:59:12 +01:00
*/
2005-01-21 23:59:48 +01:00
2018-07-26 11:57:25 +02:00
require '../../main.inc.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/prelevement.lib.php' ;
2015-06-21 17:05:49 +02:00
require_once DOL_DOCUMENT_ROOT . '/compta/prelevement/class/ligneprelevement.class.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/compta/prelevement/class/bonprelevement.class.php' ;
2013-06-05 16:24:32 +02:00
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php' ;
2018-05-27 09:27:09 +02:00
// Load translation files required by the page
2020-07-27 19:33:24 +02:00
$langs -> loadLangs ( array ( 'banks' , 'categories' , 'bills' , 'companies' , 'withdrawals' ));
2005-08-03 18:05:00 +02:00
2011-05-06 15:49:34 +02:00
// Get supervariables
2020-09-16 19:39:50 +02:00
$action = GETPOST ( 'action' , 'aZ09' );
2019-01-27 11:55:16 +01:00
$id = GETPOST ( 'id' , 'int' );
2017-09-15 18:39:10 +02:00
$ref = GETPOST ( 'ref' , 'alpha' );
2019-01-27 11:55:16 +01:00
$socid = GETPOST ( 'socid' , 'int' );
2020-05-27 20:14:11 +02:00
$type = GETPOST ( 'type' , 'aZ09' );
2017-09-15 16:40:52 +02:00
// Load variable for pagination
2019-11-08 10:53:31 +01:00
$limit = GETPOST ( 'limit' , 'int' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
2020-09-18 17:13:01 +02:00
$sortfield = GETPOST ( 'sortfield' , 'aZ09comma' );
2020-09-17 14:31:25 +02:00
$sortorder = GETPOST ( 'sortorder' , 'aZ09comma' );
2020-03-13 13:07:11 +01:00
$page = GETPOSTISSET ( 'pageplusone' ) ? ( GETPOST ( 'pageplusone' ) - 1 ) : GETPOST ( " page " , 'int' );
2021-02-23 21:09:01 +01:00
if ( empty ( $page ) || $page == - 1 ) {
$page = 0 ;
} // If $page is not defined, or '' or -1
2017-02-21 13:16:28 +01:00
$offset = $limit * $page ;
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
2017-09-15 16:40:52 +02:00
2021-02-23 21:09:01 +01:00
if ( ! $sortfield ) {
$sortfield = 'pl.fk_soc' ;
}
if ( ! $sortorder ) {
$sortorder = 'DESC' ;
}
2015-06-21 17:05:49 +02:00
2020-05-07 12:14:45 +02:00
$object = new BonPrelevement ( $db );
2017-09-15 16:40:52 +02:00
2017-12-15 17:05:01 +01:00
// Load object
2019-11-08 10:53:31 +01:00
include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php' ; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
2017-12-15 17:05:01 +01:00
2020-01-23 16:49:06 +01:00
$hookmanager -> initHooks ( array ( 'directdebitprevcard' , 'globalcard' , 'directdebitprevlist' ));
2012-12-01 15:45:05 +01:00
2021-10-04 04:36:58 +02:00
$type = $object -> type ;
2021-12-09 12:54:08 +01:00
2021-10-04 04:36:58 +02:00
if ( $type == 'bank-transfer' ) {
$result = restrictedArea ( $user , 'paymentbybanktransfer' , '' , '' , '' );
} else {
$result = restrictedArea ( $user , 'prelevement' , '' , '' , 'bons' );
2020-07-27 19:33:24 +02:00
}
2020-05-17 13:34:16 +02:00
2008-11-05 23:34:14 +01:00
/*
* Actions
*/
2017-02-21 13:16:28 +01:00
2019-07-19 11:26:21 +02:00
$parameters = array ( 'socid' => $socid );
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2021-02-23 21:09:01 +01:00
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
}
2008-11-05 23:34:14 +01:00
2021-02-23 21:09:01 +01:00
if ( empty ( $reshook )) {
if ( $action == 'confirm_delete' ) {
2021-12-09 12:54:08 +01:00
$savtype = $object -> type ;
2020-09-07 10:18:17 +02:00
$res = $object -> delete ( $user );
2021-02-23 21:09:01 +01:00
if ( $res > 0 ) {
2021-12-09 12:54:08 +01:00
if ( $savtype == 'bank-transfer' ) {
2020-09-07 10:18:17 +02:00
header ( " Location: " . DOL_URL_ROOT . '/compta/paymentbybanktransfer/index.php' );
} else {
header ( " Location: " . DOL_URL_ROOT . '/compta/prelevement/index.php' );
}
exit ;
}
}
2019-07-19 11:26:21 +02:00
2021-12-28 18:25:15 +01:00
if ( $action == 'infotrans' && (( $user -> rights -> prelevement -> bons -> send && $object -> type != 'bank-transfer' ) || ( $user -> rights -> paymentbybanktransfer -> send && $object -> type == 'bank-transfer' ))) {
2020-09-07 10:18:17 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
2019-07-19 11:26:21 +02:00
2019-07-22 19:11:27 +02:00
$dt = dol_mktime ( 12 , 0 , 0 , GETPOST ( 'remonth' , 'int' ), GETPOST ( 'reday' , 'int' ), GETPOST ( 'reyear' , 'int' ));
2019-07-19 11:26:21 +02:00
2020-09-07 10:18:17 +02:00
/*
2021-02-23 21:09:01 +01:00
if ( $_FILES [ 'userfile' ][ 'name' ] && basename ( $_FILES [ 'userfile' ][ 'name' ], " .ps " ) == $object -> ref )
{
$dir = $conf -> prelevement -> dir_output . '/receipts' ;
2019-07-19 11:26:21 +02:00
2021-02-23 21:09:01 +01:00
if ( dol_move_uploaded_file ( $_FILES [ 'userfile' ][ 'tmp_name' ], $dir . " / " . dol_unescapefile ( $_FILES [ 'userfile' ][ 'name' ]), 1 ) > 0 )
{
$object -> set_infotrans ( $user , $dt , GETPOST ( 'methode' , 'alpha' ));
}
2019-07-19 11:26:21 +02:00
2021-02-23 21:09:01 +01:00
header ( " Location: card.php?id= " . $id );
exit ;
}
else
2020-09-07 10:18:17 +02:00
{
2021-02-23 21:09:01 +01:00
dol_syslog ( " Fichier invalide " , LOG_WARNING );
$mesg = 'BadFile' ;
} */
$error = $object -> set_infotrans ( $user , $dt , GETPOST ( 'methode' , 'alpha' ));
if ( $error ) {
2020-09-07 10:18:17 +02:00
header ( " Location: card.php?id= " . $id . " &error= $error " );
exit ;
}
}
2019-07-19 11:26:21 +02:00
2019-07-22 19:11:27 +02:00
// Set direct debit order to credited, create payment and close invoices
2021-12-28 18:25:15 +01:00
if ( $action == 'infocredit' && (( $user -> rights -> prelevement -> bons -> credit && $object -> type != 'bank-transfer' ) || ( $user -> rights -> paymentbybanktransfer -> debit && $object -> type == 'bank-transfer' ))) {
2019-07-22 19:11:27 +02:00
$dt = dol_mktime ( 12 , 0 , 0 , GETPOST ( 'remonth' , 'int' ), GETPOST ( 'reday' , 'int' ), GETPOST ( 'reyear' , 'int' ));
2005-01-07 16:26:30 +01:00
2021-12-28 18:32:02 +01:00
if (( $object -> type != 'bank-transfer' && $object -> statut == BonPrelevement :: STATUS_CREDITED ) || ( $object -> type == 'bank-transfer' && $object -> statut == BonPrelevement :: STATUS_DEBITED )) {
2021-02-05 11:34:39 +01:00
$error = 1 ;
setEventMessages ( 'WithdrawalCantBeCreditedTwice' , array (), 'errors' );
} else {
$error = $object -> set_infocredit ( $user , $dt );
}
2021-02-23 21:09:01 +01:00
if ( $error ) {
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2020-09-07 10:18:17 +02:00
}
}
2005-01-21 14:57:02 +01:00
}
2005-01-18 16:45:30 +01:00
2010-09-05 15:24:59 +02:00
2017-09-15 16:40:52 +02:00
2009-03-28 20:59:12 +01:00
/*
* View
*/
2012-12-01 15:45:05 +01:00
$form = new Form ( $db );
2019-01-27 11:55:16 +01:00
llxHeader ( '' , $langs -> trans ( " WithdrawalsReceipts " ));
2005-01-18 16:45:30 +01:00
2021-02-23 21:09:01 +01:00
if ( $id > 0 || $ref ) {
2017-09-15 16:40:52 +02:00
$head = prelevement_prepare_head ( $object );
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( $head , 'prelevement' , $langs -> trans ( " WithdrawalsReceipts " ), - 1 , 'payment' );
2005-01-18 16:45:30 +01:00
2021-02-23 21:09:01 +01:00
if ( GETPOST ( 'error' , 'alpha' ) != '' ) {
2019-01-27 11:55:16 +01:00
print '<div class="error">' . $object -> getErrorString ( GETPOST ( 'error' , 'alpha' )) . '</div>' ;
2012-12-01 15:45:05 +01:00
}
2009-03-28 20:59:12 +01:00
2020-09-25 10:05:59 +02:00
$linkback = '<a href="' . DOL_URL_ROOT . '/compta/prelevement/orders_list.php?restore_lastsearch_values=1' . ( $object -> type != 'bank-transfer' ? '' : '&type=bank-transfer' ) . '">' . $langs -> trans ( " BackToList " ) . '</a>' ;
2017-12-15 17:24:36 +01:00
dol_banner_tab ( $object , 'ref' , $linkback , 1 , 'ref' , 'ref' );
2017-09-15 16:40:52 +02:00
print '<div class="fichecenter">' ;
print '<div class="underbanner clearboth"></div>' ;
2019-11-12 17:37:05 +01:00
print '<table class="border centpercent tableforfield">' ;
2009-03-28 20:59:12 +01:00
2021-09-27 22:12:08 +02:00
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " Date " ) . '</td><td>' . dol_print_date ( $object -> datec , 'day' ) . '</td></tr>' ;
2021-08-09 16:48:36 +02:00
print '<tr><td>' . $langs -> trans ( " Amount " ) . '</td><td><span class="amount">' . price ( $object -> amount ) . '</span></td></tr>' ;
2012-12-01 15:45:05 +01:00
// Status
2017-09-15 16:40:52 +02:00
/*
2017-02-21 13:16:28 +01:00
print '<tr><td>' . $langs -> trans ( 'Status' ) . '</td>' ;
2017-09-15 16:40:52 +02:00
print '<td>' . $object -> getLibStatut ( 1 ) . '</td>' ;
2012-12-01 15:45:05 +01:00
print '</tr>' ;
2017-09-15 16:40:52 +02:00
*/
2012-12-01 15:45:05 +01:00
2022-06-10 16:46:09 +02:00
if ( ! empty ( $object -> date_trans )) {
2012-12-01 15:45:05 +01:00
$muser = new User ( $db );
2017-09-15 16:40:52 +02:00
$muser -> fetch ( $object -> user_trans );
2012-12-01 15:45:05 +01:00
2017-02-21 13:16:28 +01:00
print '<tr><td>' . $langs -> trans ( " TransData " ) . '</td><td>' ;
2019-01-27 11:55:16 +01:00
print dol_print_date ( $object -> date_trans , 'day' );
2022-06-10 16:46:09 +02:00
print ' <span class="opacitymedium">' . $langs -> trans ( " By " ) . '</span> ' . $muser -> getNomUrl ( - 1 ) . '</td></tr>' ;
2017-02-21 13:16:28 +01:00
print '<tr><td>' . $langs -> trans ( " TransMetod " ) . '</td><td>' ;
2017-09-15 16:40:52 +02:00
print $object -> methodes_trans [ $object -> method_trans ];
2012-12-01 15:45:05 +01:00
print '</td></tr>' ;
}
2022-06-10 16:46:09 +02:00
if ( ! empty ( $object -> date_credit )) {
2017-02-21 13:16:28 +01:00
print '<tr><td>' . $langs -> trans ( 'CreditDate' ) . '</td><td>' ;
2019-01-27 11:55:16 +01:00
print dol_print_date ( $object -> date_credit , 'day' );
2012-12-01 15:45:05 +01:00
print '</td></tr>' ;
}
2009-03-28 20:59:12 +01:00
2012-12-01 15:45:05 +01:00
print '</table>' ;
2009-03-28 20:59:12 +01:00
2012-12-01 15:45:05 +01:00
print '<br>' ;
2009-03-28 20:59:12 +01:00
2017-09-15 16:40:52 +02:00
print '<div class="underbanner clearboth"></div>' ;
2019-11-12 17:37:05 +01:00
print '<table class="border centpercent tableforfield">' ;
2017-09-15 16:40:52 +02:00
$acc = new Account ( $db );
2020-10-20 12:15:06 +02:00
$result = $acc -> fetch (( $object -> type == 'bank-transfer' ? $conf -> global -> PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf -> global -> PRELEVEMENT_ID_BANKACCOUNT ));
2017-09-15 16:40:52 +02:00
2021-09-27 22:12:08 +02:00
print '<tr><td class="titlefieldcreate">' ;
2020-07-27 19:33:24 +02:00
$labelofbankfield = " BankToReceiveWithdraw " ;
2021-02-23 21:09:01 +01:00
if ( $object -> type == 'bank-transfer' ) {
$labelofbankfield = 'BankToPayCreditTransfer' ;
}
2020-07-27 19:33:24 +02:00
print $langs -> trans ( $labelofbankfield );
2017-09-15 16:40:52 +02:00
print '</td>' ;
print '<td>' ;
2021-02-23 21:09:01 +01:00
if ( $acc -> id > 0 ) {
2017-09-15 16:40:52 +02:00
print $acc -> getNomUrl ( 1 );
2021-02-23 21:09:01 +01:00
}
2017-09-15 16:40:52 +02:00
print '</td>' ;
print '</tr>' ;
2021-09-27 22:12:08 +02:00
print '<tr><td class="titlefieldcreate">' ;
2020-07-27 19:33:24 +02:00
$labelfororderfield = 'WithdrawalFile' ;
2021-02-23 21:09:01 +01:00
if ( $object -> type == 'bank-transfer' ) {
$labelfororderfield = 'CreditTransferFile' ;
}
2020-07-27 19:33:24 +02:00
print $langs -> trans ( $labelfororderfield ) . '</td><td>' ;
2017-09-15 16:40:52 +02:00
$relativepath = 'receipts/' . $object -> ref . '.xml' ;
2020-07-27 19:33:24 +02:00
$modulepart = 'prelevement' ;
2021-02-23 21:09:01 +01:00
if ( $object -> type == 'bank-transfer' ) {
$modulepart = 'paymentbybanktransfer' ;
}
2022-03-31 11:47:18 +02:00
print '<a data-ajax="false" href="' . DOL_URL_ROOT . '/document.php?type=text/plain&modulepart=' . $modulepart . '&file=' . urlencode ( $relativepath ) . '">' . $relativepath ;
print img_picto ( '' , 'download' , 'class="paddingleft"' );
print '</a>' ;
2022-02-18 08:23:12 +01:00
print '</td></tr>' ;
// Other attributes
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'formObjectOptions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
print '</table>' ;
2012-12-01 15:45:05 +01:00
2017-09-15 16:40:52 +02:00
print '</div>' ;
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2009-03-28 20:59:12 +01:00
2019-09-06 14:24:33 +02:00
$formconfirm = '' ;
// Confirmation to delete
2021-02-23 21:09:01 +01:00
if ( $action == 'delete' ) {
2019-11-08 10:53:31 +01:00
$formconfirm = $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id , $langs -> trans ( 'Delete' ), $langs -> trans ( 'ConfirmDeleteObject' ), 'confirm_delete' , '' , 0 , 1 );
2019-09-06 14:24:33 +02:00
}
// Call Hook formConfirm
2020-01-28 12:00:27 +01:00
/* $parameters = array ( 'formConfirm' => $formconfirm );
2019-09-06 14:24:33 +02:00
$reshook = $hookmanager -> executeHooks ( 'formConfirm' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
if ( empty ( $reshook )) $formconfirm .= $hookmanager -> resPrint ;
elseif ( $reshook > 0 ) $formconfirm = $hookmanager -> resPrint ; */
// Print form confirm
print $formconfirm ;
2012-05-30 12:43:23 +02:00
2021-02-23 21:09:01 +01:00
if ( empty ( $object -> date_trans ) && $user -> rights -> prelevement -> bons -> send && $action == 'settransmitted' ) {
2017-09-15 16:40:52 +02:00
print '<form method="post" name="userfile" action="card.php?id=' . $object -> id . '" enctype="multipart/form-data">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2012-12-01 15:45:05 +01:00
print '<input type="hidden" name="action" value="infotrans">' ;
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">' ;
2012-12-01 15:45:05 +01:00
print '<tr class="liste_titre">' ;
print '<td colspan="3">' . $langs -> trans ( " NotifyTransmision " ) . '</td></tr>' ;
2018-01-18 18:40:01 +01:00
print '<tr class="oddeven"><td>' . $langs -> trans ( " TransData " ) . '</td><td>' ;
2018-09-09 09:36:12 +02:00
print $form -> selectDate ( '' , '' , '' , '' , '' , " userfile " , 1 , 1 );
2012-12-01 15:45:05 +01:00
print '</td></tr>' ;
2018-01-18 18:40:01 +01:00
print '<tr class="oddeven"><td>' . $langs -> trans ( " TransMetod " ) . '</td><td>' ;
2019-01-27 11:55:16 +01:00
print $form -> selectarray ( " methode " , $object -> methodes_trans );
2012-12-01 15:45:05 +01:00
print '</td></tr>' ;
print '</table><br>' ;
2014-11-25 20:13:43 +01:00
print '<div class="center"><input type="submit" class="button" value="' . dol_escape_htmltag ( $langs -> trans ( " SetToStatusSent " )) . '"></div>' ;
2012-12-01 15:45:05 +01:00
print '</form>' ;
2018-01-18 18:40:01 +01:00
print '<br>' ;
2012-12-01 15:45:05 +01:00
}
2022-06-10 16:46:09 +02:00
if ( ! empty ( $object -> date_trans ) && empty ( $object -> date_credit ) && $user -> rights -> prelevement -> bons -> credit && $action == 'setcredited' ) {
2021-12-28 18:32:02 +01:00
$btnLabel = ( $object -> type == 'bank-transfer' ) ? $langs -> trans ( " ClassDebited " ) : $langs -> trans ( " ClassCredited " );
2017-09-15 16:40:52 +02:00
print '<form name="infocredit" method="post" action="card.php?id=' . $object -> id . '">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2012-12-01 15:45:05 +01:00
print '<input type="hidden" name="action" value="infocredit">' ;
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">' ;
2012-12-01 15:45:05 +01:00
print '<tr class="liste_titre">' ;
print '<td colspan="3">' . $langs -> trans ( " NotifyCredit " ) . '</td></tr>' ;
2018-01-18 18:40:01 +01:00
print '<tr class="oddeven"><td>' . $langs -> trans ( 'CreditDate' ) . '</td><td>' ;
2022-02-10 13:06:51 +01:00
print $form -> selectDate ( - 1 , '' , '' , '' , '' , " infocredit " , 1 , 1 );
2012-12-01 15:45:05 +01:00
print '</td></tr>' ;
2011-01-09 00:21:27 +01:00
print '</table>' ;
2020-06-08 11:43:20 +02:00
print '<br><div class="center"><span class="opacitymedium">' . $langs -> trans ( " ThisWillAlsoAddPaymentOnInvoice " ) . '</span></div>' ;
2021-12-28 18:32:02 +01:00
print '<div class="center"><input type="submit" class="button" value="' . dol_escape_htmltag ( $btnLabel ) . '"></div>' ;
2012-12-01 15:45:05 +01:00
print '</form>' ;
2018-01-18 18:40:01 +01:00
print '<br>' ;
2012-12-01 15:45:05 +01:00
}
2009-03-28 20:59:12 +01:00
2012-12-01 15:45:05 +01:00
// Actions
2021-02-23 21:09:01 +01:00
if ( $action != 'settransmitted' && $action != 'setcredited' ) {
2021-08-04 13:18:03 +02:00
print " \n " . '<div class="tabsAction">' . " \n " ;
2022-03-21 15:43:37 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'addMoreActionsButtons' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
if ( empty ( $reshook )) {
if ( empty ( $object -> date_trans )) {
if ( $object -> type == 'bank-transfer' ) print dolGetButtonAction ( $langs -> trans ( " SetToStatusSent " ), '' , 'default' , 'card.php?action=settransmitted&token=' . newToken () . '&id=' . $object -> id , '' , $user -> rights -> paymentbybanktransfer -> send );
else print dolGetButtonAction ( $langs -> trans ( " SetToStatusSent " ), '' , 'default' , 'card.php?action=settransmitted&token=' . newToken () . '&id=' . $object -> id , '' , $user -> rights -> prelevement -> bons -> send );
}
2022-06-10 16:46:09 +02:00
if ( ! empty ( $object -> date_trans ) && empty ( $object -> date_credit )) {
2022-03-21 15:43:37 +01:00
if ( $object -> type == 'bank-transfer' ) print dolGetButtonAction ( $langs -> trans ( " ClassDebited " ), '' , 'default' , 'card.php?action=setcredited&token=' . newToken () . '&id=' . $object -> id , '' , $user -> rights -> paymentbybanktransfer -> debit );
else print dolGetButtonAction ( $langs -> trans ( " ClassCredited " ), '' , 'default' , 'card.php?action=setcredited&token=' . newToken () . '&id=' . $object -> id , '' , $user -> rights -> prelevement -> bons -> credit );
}
2005-01-11 15:40:08 +01:00
2022-03-21 15:43:37 +01:00
if ( $object -> type == 'bank-transfer' ) print dolGetButtonAction ( $langs -> trans ( " Delete " ), '' , 'delete' , 'card.php?action=delete&token=' . newToken () . '&id=' . $object -> id , '' , $user -> rights -> paymentbybanktransfer -> create );
else print dolGetButtonAction ( $langs -> trans ( " Delete " ), '' , 'delete' , 'card.php?action=delete&token=' . newToken () . '&id=' . $object -> id , '' , $user -> rights -> prelevement -> bons -> creer );
}
2021-08-04 13:18:03 +02:00
print '</div>' ;
2012-12-01 15:45:05 +01:00
}
2015-06-21 17:05:49 +02:00
2020-05-07 12:14:45 +02:00
$ligne = new LignePrelevement ( $db );
2015-06-21 17:05:49 +02:00
/*
* Lines into withdraw request
*/
2017-02-21 13:16:28 +01:00
$sql = " SELECT pl.rowid, pl.statut, pl.amount, " ;
2019-11-08 10:53:31 +01:00
$sql .= " s.rowid as socid, s.nom as name " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " prelevement_lignes as pl " ;
$sql .= " , " . MAIN_DB_PREFIX . " prelevement_bons as pb " ;
$sql .= " , " . MAIN_DB_PREFIX . " societe as s " ;
2021-03-22 13:31:06 +01:00
$sql .= " WHERE pl.fk_prelevement_bons = " . (( int ) $id );
2019-11-08 10:53:31 +01:00
$sql .= " AND pl.fk_prelevement_bons = pb.rowid " ;
$sql .= " AND pb.entity = " . $conf -> entity ;
$sql .= " AND pl.fk_soc = s.rowid " ;
2021-02-23 21:09:01 +01:00
if ( $socid ) {
2021-03-22 13:31:06 +01:00
$sql .= " AND s.rowid = " . (( int ) $socid );
2021-02-23 21:09:01 +01:00
}
2019-11-08 10:53:31 +01:00
$sql .= $db -> order ( $sortfield , $sortorder );
2017-09-15 16:40:52 +02:00
// Count total nb of records
$nbtotalofrecords = '' ;
2021-02-23 21:09:01 +01:00
if ( empty ( $conf -> global -> MAIN_DISABLE_FULL_SCANLIST )) {
2017-09-15 16:40:52 +02:00
$result = $db -> query ( $sql );
$nbtotalofrecords = $db -> num_rows ( $result );
2021-01-13 16:52:32 +01:00
if (( $page * $limit ) > $nbtotalofrecords ) {
// if total resultset is smaller then paging size (filtering), goto and load page 0
2018-04-24 11:37:57 +02:00
$page = 0 ;
$offset = 0 ;
}
2017-09-15 16:40:52 +02:00
}
2019-11-08 10:53:31 +01:00
$sql .= $db -> plimit ( $limit + 1 , $offset );
2015-06-21 17:05:49 +02:00
$result = $db -> query ( $sql );
2021-02-23 21:09:01 +01:00
if ( $result ) {
2015-06-21 17:05:49 +02:00
$num = $db -> num_rows ( $result );
$i = 0 ;
2021-04-25 15:55:36 +02:00
$urladd = " &id= " . urlencode ( $id );
2021-12-09 11:24:03 +01:00
if ( $limit > 0 && $limit != $conf -> liste_limit ) {
2021-12-09 11:25:58 +01:00
$urladd .= '&limit=' . urlencode ( $limit );
2021-12-09 11:24:03 +01:00
}
2015-06-21 17:05:49 +02:00
2020-01-30 01:48:28 +01:00
print '<form method="get" action="' . $_SERVER [ 'PHP_SELF' ] . '" name="search_form">' . " \n " ;
print '<input type="hidden" name="id" value="' . $id . '"/>' ;
print '<input type="hidden" name="socid" value="' . $socid . '"/>' ;
if ( ! empty ( $page )) {
print '<input type="hidden" name="page" value="' . $page . '"/>' ;
2020-01-23 16:49:06 +01:00
}
2020-01-30 01:48:28 +01:00
if ( ! empty ( $limit )) {
print '<input type="hidden" name="limit" value="' . $limit . '"/>' ;
2020-01-23 16:49:06 +01:00
}
2021-12-09 11:24:03 +01:00
if ( ! empty ( $sortfield )) {
print '<input type="hidden" name="sortfield" value="' . $sortfield . '"/>' ;
}
if ( ! empty ( $sortorder )) {
print '<input type="hidden" name="sortorder" value="' . $sortorder . '"/>' ;
}
2020-01-23 16:49:06 +01:00
print_barre_liste ( $langs -> trans ( " Lines " ), $page , $_SERVER [ " PHP_SELF " ], $urladd , $sortfield , $sortorder , '' , $num , $nbtotalofrecords , '' , 0 , '' , '' , $limit );
2017-09-15 16:40:52 +02:00
2019-11-08 10:53:31 +01:00
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
2021-04-30 15:22:17 +02:00
print '<table class="noborder liste" width="100%" cellpadding="4">' ;
2015-06-21 17:05:49 +02:00
print '<tr class="liste_titre">' ;
2019-01-27 11:55:16 +01:00
print_liste_field_titre ( " Lines " , $_SERVER [ " PHP_SELF " ], " pl.rowid " , '' , $urladd );
print_liste_field_titre ( " ThirdParty " , $_SERVER [ " PHP_SELF " ], " s.nom " , '' , $urladd );
2019-02-10 16:00:59 +01:00
print_liste_field_titre ( " Amount " , $_SERVER [ " PHP_SELF " ], " pl.amount " , " " , $urladd , 'class="right"' );
2015-06-21 17:05:49 +02:00
print_liste_field_titre ( '' );
2015-06-27 02:31:26 +02:00
print " </tr> \n " ;
2015-06-21 17:05:49 +02:00
$total = 0 ;
2021-02-23 21:09:01 +01:00
while ( $i < min ( $num , $limit )) {
2015-06-21 17:05:49 +02:00
$obj = $db -> fetch_object ( $result );
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2015-06-21 17:05:49 +02:00
2017-02-21 13:16:28 +01:00
// Status of line
2015-06-21 17:05:49 +02:00
print " <td> " ;
2021-09-27 22:12:08 +02:00
print '<a class="valignmiddle" href="' . DOL_URL_ROOT . '/compta/prelevement/line.php?id=' . $obj -> rowid . '&type=' . $object -> type . '&token=' . newToken () . '">' ;
2021-09-28 00:26:58 +02:00
print $ligne -> LibStatut ( $obj -> statut , 2 );
print '<span class="paddingleft">' . $obj -> rowid . '</span>' ;
2015-06-21 17:05:49 +02:00
print '</a></td>' ;
2019-11-08 10:53:31 +01:00
$thirdparty = new Societe ( $db );
2015-06-21 17:05:49 +02:00
$thirdparty -> fetch ( $obj -> socid );
print '<td>' ;
print $thirdparty -> getNomUrl ( 1 );
print " </td> \n " ;
2021-03-29 13:00:17 +02:00
print '<td class="right"><span class="amount">' . price ( $obj -> amount ) . " </span></td> \n " ;
2015-06-21 17:05:49 +02:00
2020-06-08 11:43:20 +02:00
print '<td class="right">' ;
2015-06-21 17:05:49 +02:00
2021-02-23 21:09:01 +01:00
if ( $obj -> statut == 3 ) {
print '<b>' . $langs -> trans ( " StatusRefused " ) . '</b>' ;
2020-05-21 15:05:19 +02:00
} else {
2021-02-23 21:09:01 +01:00
if ( $object -> statut == BonPrelevement :: STATUS_CREDITED ) {
2020-06-08 11:43:20 +02:00
if ( $obj -> statut == 2 ) {
2021-02-23 21:09:01 +01:00
if ( $user -> rights -> prelevement -> bons -> credit ) {
2020-06-08 11:43:20 +02:00
//print '<a class="butActionDelete" href="line.php?action=rejet&id='.$obj->rowid.'">'.$langs->trans("StandingOrderReject").'</a>';
2021-09-18 22:09:55 +02:00
print '<a href="line.php?action=rejet&type=' . $object -> type . '&id=' . $obj -> rowid . '&token=' . newToken () . '">' . $langs -> trans ( " StandingOrderReject " ) . '</a>' ;
2020-06-11 13:03:21 +02:00
} else {
2020-06-08 11:43:20 +02:00
//print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans("StandingOrderReject").'</a>';
}
}
2020-06-11 13:58:12 +02:00
} else {
2020-06-08 11:43:20 +02:00
//print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotPossibleForThisStatusOfWithdrawReceiptORLine").'">'.$langs->trans("StandingOrderReject").'</a>';
}
2015-06-21 17:05:49 +02:00
}
print '</td></tr>' ;
2017-02-21 13:16:28 +01:00
$total += $obj -> amount ;
2017-08-02 13:31:53 +02:00
2015-06-21 17:05:49 +02:00
$i ++ ;
}
2021-01-13 16:52:32 +01:00
if ( $num > 0 ) {
2022-01-11 01:30:24 +01:00
$total = price2num ( $total , 'MT' );
2017-02-21 13:16:28 +01:00
print '<tr class="liste_total">' ;
2015-06-21 17:05:49 +02:00
print '<td>' . $langs -> trans ( " Total " ) . '</td>' ;
print '<td> </td>' ;
2019-02-10 16:00:59 +01:00
print '<td class="right">' ;
2021-01-13 16:52:32 +01:00
if ( empty ( $offset ) && $num <= $limit ) {
// If we have all record on same page, then the following test/warning can be done
2021-02-23 21:09:01 +01:00
if ( $total != $object -> amount ) {
print img_warning ( $langs -> trans ( " TotalAmountOfdirectDebitOrderDiffersFromSumOfLines " ));
}
2019-09-06 13:02:52 +02:00
}
2017-09-15 18:39:10 +02:00
print price ( $total );
print " </td> \n " ;
2015-06-21 17:05:49 +02:00
print '<td> </td>' ;
print " </tr> \n " ;
}
print " </table> " ;
2017-09-15 16:40:52 +02:00
print '</div>' ;
2020-01-23 16:49:06 +01:00
print '</form>' ;
2017-09-15 16:40:52 +02:00
2015-06-21 17:05:49 +02:00
$db -> free ( $result );
2020-05-21 15:05:19 +02:00
} else {
2015-06-21 17:05:49 +02:00
dol_print_error ( $db );
}
2011-01-09 00:21:27 +01:00
}
2005-01-07 16:26:30 +01:00
2018-08-08 12:29:36 +02:00
// End of page
2011-08-27 16:24:16 +02:00
llxFooter ();
2012-12-01 15:45:05 +01:00
$db -> close ();