28require
'../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/modules/modPrelevement.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
36$langs->loadLangs(array(
'banks',
'categories',
'withdrawals',
'companies'));
39$socid =
GETPOST(
'socid',
'int');
40$status =
GETPOST(
'status',
'int');
42$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'directdebitcredittransferlist';
43$backtopage =
GETPOST(
'backtopage',
'alpha');
44$optioncss =
GETPOST(
'optioncss',
'aZ');
48$search_facture =
GETPOST(
'search_facture',
'alpha');
49$search_societe =
GETPOST(
'search_societe',
'alpha');
52$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
53$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
54$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
55$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
56if (empty($page) || $page == -1 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') || (empty($toselect) && $massaction ===
'0')) {
59$offset = $limit * $page;
69$massactionbutton =
'';
71$hookmanager->initHooks(array(
'withdrawalstodolist'));
74 $socid = $user->socid;
76if ($type ==
'bank-transfer') {
77 $result =
restrictedArea($user,
'paymentbybanktransfer',
'',
'',
'');
87$parameters = array(
'socid' => $socid,
'limit' => $limit,
'page' => $page,
'offset' => $offset);
88$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
94if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
97 $search_array_options = array();
106if ($type !=
'bank-transfer') {
108 $title = $langs->trans(
"RequestStandingOrderToTreat");
110 $title = $langs->trans(
"RequestStandingOrderTreated");
114 $title = $langs->trans(
"RequestPaymentsByBankTransferToTreat");
116 $title = $langs->trans(
"RequestPaymentsByBankTransferTreated");
122$thirdpartystatic =
new Societe($db);
123if ($type ==
'bank-transfer') {
126 $invoicestatic =
new Facture($db);
131$sql =
"SELECT f.ref, f.rowid, f.total_ttc,";
132$sql .=
" s.nom as name, s.rowid as socid,";
133$sql .=
" pfd.date_demande as date_demande, pfd.amount, pfd.fk_user_demande";
134if ($type !=
'bank-transfer') {
135 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f,";
137 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f,";
139$sql .=
" ".MAIN_DB_PREFIX.
"societe as s,";
140$sql .=
" ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
141if (empty($user->rights->societe->client->voir) && !$socid) {
142 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
144$sql .=
" WHERE s.rowid = f.fk_soc";
145$sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
146if (empty($user->rights->societe->client->voir) && !$socid) {
147 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
150 $sql .=
" AND f.fk_soc = ".((int) $socid);
153 $sql .=
" AND pfd.traite = 0";
155$sql .=
" AND pfd.ext_payment_id IS NULL";
157 $sql .=
" AND pfd.traite = ".((int) $status);
159$sql .=
" AND f.total_ttc > 0";
160if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) {
161 $sql .=
" AND f.fk_statut = ".Facture::STATUS_VALIDATED;
163if ($type !=
'bank-transfer') {
164 $sql .=
" AND pfd.fk_facture = f.rowid";
166 $sql .=
" AND pfd.fk_facture_fourn = f.rowid";
168if ($search_facture) {
171if ($search_societe) {
174$sql .= $db->order($sortfield, $sortorder);
177$nbtotalofrecords =
'';
179 $resql = $db->query($sql);
180 $nbtotalofrecords = $db->num_rows($resql);
181 if (($page * $limit) > $nbtotalofrecords) {
187if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) {
188 $num = $nbtotalofrecords;
190 $sql .= $db->plimit($limit + 1, $offset);
192 $resql = $db->query($sql);
198 $num = $db->num_rows($resql);
203$newcardbutton =
'<a class="marginrightonly" href="'.DOL_URL_ROOT.
'/compta/prelevement/index.php">'.$langs->trans(
"Back").
'</a>';
204if ($type ==
'bank-transfer') {
205 $newcardbutton =
'<a class="marginrightonly" href="'.DOL_URL_ROOT.
'/compta/paymentbybanktransfer/index.php">'.$langs->trans(
"Back").
'</a>';
208print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" id="searchFormList" name="searchFormList">';
209if ($optioncss !=
'') {
210 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
212print
'<input type="hidden" name="token" value="'.newToken().
'">';
213print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
214print
'<input type="hidden" name="action" value="list">';
215print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
216print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
217print
'<input type="hidden" name="page" value="'.$page.
'">';
218print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
222$label =
'NewStandingOrder';
224if ($type ==
'bank-transfer') {
225 $label =
'NewPaymentByBankTransfer';
226 $typefilter =
'type='.$type;
228$newcardbutton .=
dolGetButtonTitle($langs->trans($label),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/compta/prelevement/create.php'.($typefilter ?
'?'.$typefilter :
''));
230print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'generic', 0, $newcardbutton,
'', $limit);
232print
'<table class="liste centpercent">';
234print
'<tr class="liste_titre">';
242print
'<tr class="liste_titre">';
243print
'<td class="liste_titre"><input type="text" class="flat maxwidth150" name="search_facture" value="'.dol_escape_htmltag($search_facture).
'"></td>';
244print
'<td class="liste_titre"><input type="text" class="flat maxwidth150" name="search_societe" value="'.dol_escape_htmltag($search_societe).
'"></td>';
245print
'<td class="liste_titre"></td>';
246print
'<td class="liste_titre"></td>';
248print
'<td class="liste_titre maxwidthsearch">';
249$searchpicto = $form->showFilterButtons();
255while ($i < min($num, $limit)) {
256 $obj = $db->fetch_object($resql);
261 $invoicestatic->fetch($obj->rowid);
263 print
'<tr class="oddeven">';
267 print $invoicestatic->getNomUrl(1,
'withdraw');
271 $thirdpartystatic->id = $obj->socid;
272 $thirdpartystatic->name = $obj->name;
273 print $thirdpartystatic->getNomUrl(1,
'customer');
276 print
'<td class="right">';
277 print
'<span class="amount">';
278 print
price($obj->amount, 1, $langs, 1, -1, -1, $conf->currency).
' / '.
price($obj->total_ttc, 1, $langs, 1, -1, -1, $conf->currency);
282 print
'<td class="center">'.dol_print_date($db->jdate($obj->date_demande),
'day').
'</td>';
284 print
'<td class="right"></td>';
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage suppliers invoices.
Class to manage invoices.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
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.