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';
34require_once DOL_DOCUMENT_ROOT.
'/salaries/class/salary.class.php';
37$langs->loadLangs(array(
'banks',
'categories',
'withdrawals',
'companies'));
40$socid =
GETPOST(
'socid',
'int');
41$status =
GETPOST(
'status',
'int');
43$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'directdebitcredittransferlist';
44$backtopage =
GETPOST(
'backtopage',
'alpha');
45$optioncss =
GETPOST(
'optioncss',
'aZ');
48$sourcetype =
GETPOST(
'sourcetype',
'aZ');
50$search_facture =
GETPOST(
'search_facture',
'alpha');
51$search_societe =
GETPOST(
'search_societe',
'alpha');
54$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
55$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
56$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
57$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
58if (empty($page) || $page == -1 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') || (empty($toselect) && $massaction ===
'0')) {
61$offset = $limit * $page;
71$massactionbutton =
'';
73$hookmanager->initHooks(array(
'withdrawalstodolist'));
76 $socid = $user->socid;
78if ($type ==
'bank-transfer') {
79 $result =
restrictedArea($user,
'paymentbybanktransfer',
'',
'',
'');
89$parameters = array(
'socid' => $socid,
'limit' => $limit,
'page' => $page,
'offset' => $offset);
90$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
96if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
99 $search_array_options = array();
108if ($type !=
'bank-transfer') {
110 $title = $langs->trans(
"RequestStandingOrderToTreat");
112 $title = $langs->trans(
"RequestStandingOrderTreated");
116 $title = $langs->trans(
"RequestPaymentsByBankTransferToTreat");
118 $title = $langs->trans(
"RequestPaymentsByBankTransferTreated");
124$thirdpartystatic =
new Societe($db);
125if ($type ==
'bank-transfer') {
128 $invoicestatic =
new Facture($db);
132if ($sourcetype !=
'salary') {
133 $sql =
"SELECT f.ref, f.rowid, f.total_ttc,";
134 $sql .=
" s.nom as name, s.rowid as socid,";
135 $sql .=
" pd.date_demande as date_demande, pd.amount, pd.fk_user_demande";
136 if ($type !=
'bank-transfer') {
137 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f,";
139 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f,";
141 $sql .=
" ".MAIN_DB_PREFIX.
"societe as s,";
142 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement_demande as pd";
143 if (!$user->hasRight(
'societe',
'client',
'voir') && !$socid) {
144 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
146 $sql .=
" WHERE s.rowid = f.fk_soc";
147 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
148 if (!$user->hasRight(
'societe',
'client',
'voir') && !$socid) {
149 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
152 $sql .=
" AND f.fk_soc = ".((int) $socid);
155 $sql .=
" AND pd.traite = 0";
157 $sql .=
" AND pd.ext_payment_id IS NULL";
159 $sql .=
" AND pd.traite = ".((int) $status);
161 $sql .=
" AND f.total_ttc > 0";
163 $sql .=
" AND f.fk_statut = ".Facture::STATUS_VALIDATED;
165 if ($type !=
'bank-transfer') {
166 $sql .=
" AND pd.fk_facture = f.rowid";
168 $sql .=
" AND pd.fk_facture_fourn = f.rowid";
170 if ($search_facture) {
173 if ($search_societe) {
176 $sql .= $db->order($sortfield, $sortorder);
178 $sql =
"SELECT s.rowid,s.amount as total_ttc, pd.amount,";
179 $sql .=
" s.fk_user, pd.date_demande, pd.fk_salary, CONCAT(u.firstname,' ',u.lastname) as nom";
180 $sql .=
" FROM ".MAIN_DB_PREFIX.
"salary as s, ".MAIN_DB_PREFIX.
"user as u,";
181 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement_demande as pd";
182 $sql .=
" WHERE s.rowid = pd.fk_salary";
183 $sql .=
" AND u.rowid = s.fk_user";
184 $sql .=
" AND s.entity IN (".getEntity(
"salary").
")";
189 $sql .=
" AND pd.traite = 0";
191 $sql .=
" AND pd.ext_payment_id IS NULL";
193 $sql .=
" AND pd.traite = ".((int) $status);
195 $sql .=
" AND s.amount > 0";
196 $sql .=
" AND s.paye = ".Salary::STATUS_UNPAID;
197 if ($search_facture) {
200 if ($search_societe) {
201 $sql .=
natural_search(
"CONCAT(u.firstname,' ',u.lastname)", $search_societe);
206$nbtotalofrecords =
'';
208 $resql = $db->query($sql);
209 $nbtotalofrecords = $db->num_rows($resql);
210 if (($page * $limit) > $nbtotalofrecords) {
216if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) {
217 $num = $nbtotalofrecords;
219 $sql .= $db->plimit($limit + 1, $offset);
221 $resql = $db->query($sql);
227 $num = $db->num_rows($resql);
232$newcardbutton =
'<a class="marginrightonly" href="'.DOL_URL_ROOT.
'/compta/prelevement/index.php">'.$langs->trans(
"Back").
'</a>';
233if ($type ==
'bank-transfer') {
234 $newcardbutton =
'<a class="marginrightonly" href="'.DOL_URL_ROOT.
'/compta/paymentbybanktransfer/index.php">'.$langs->trans(
"Back").
'</a>';
236if ($sourcetype !=
'salary') {
237 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" id="searchFormList" name="searchFormList">';
239 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?status=0&type=bank-transfer&sourcetype='.$sourcetype.
'" method="POST" id="searchFormList" name="searchFormList">';
241if ($optioncss !=
'') {
242 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
244print
'<input type="hidden" name="token" value="'.newToken().
'">';
245print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
246print
'<input type="hidden" name="action" value="list">';
247print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
248print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
249print
'<input type="hidden" name="page" value="'.$page.
'">';
250print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
254$label =
'NewStandingOrder';
256if ($type ==
'bank-transfer') {
257 $label =
'NewPaymentByBankTransfer';
258 $typefilter =
'type='.$type;
260$newcardbutton .=
dolGetButtonTitle($langs->trans($label),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/compta/prelevement/create.php'.($typefilter ?
'?'.$typefilter :
'').($sourcetype ?
'&sourcetype='.$sourcetype :
''));
262print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'generic', 0, $newcardbutton,
'', $limit);
264print
'<div class="div-table-responsive">';
265print
'<table class="liste centpercent">';
267print
'<tr class="liste_titre">';
270 print
'<td class="liste_titre maxwidthsearch">';
271 $searchpicto = $form->showFilterButtons();
275print
'<td class="liste_titre"><input type="text" class="flat maxwidth150" name="search_facture" value="'.dol_escape_htmltag($search_facture).
'"></td>';
276print
'<td class="liste_titre"><input type="text" class="flat maxwidth150" name="search_societe" value="'.dol_escape_htmltag($search_societe).
'"></td>';
277print
'<td class="liste_titre"></td>';
278print
'<td class="liste_titre"></td>';
281 print
'<td class="liste_titre maxwidthsearch">';
282 $searchpicto = $form->showFilterButtons();
288print
'<tr class="liste_titre">';
301$userstatic =
new User($db);
302$salarystatic =
new Salary($db);
305while ($i < min($num, $limit)) {
306 $obj = $db->fetch_object($resql);
310 if ($sourcetype !=
'salary') {
311 $invoicestatic->fetch($obj->rowid);
313 $salarystatic->fetch($obj->fk_salary);
314 $userstatic->fetch($obj->fk_user);
316 print
'<tr class="oddeven">';
320 print
'<td class="right"></td>';
325 if ($sourcetype !=
'salary') {
326 print $invoicestatic->getNomUrl(1,
'withdraw');
328 print $salarystatic->getNomUrl(1,
'withdraw');
333 if ($sourcetype !=
'salary') {
334 $thirdpartystatic->id = $obj->socid;
335 $thirdpartystatic->name = $obj->name;
336 print $thirdpartystatic->getNomUrl(1,
'customer');
338 print $userstatic->getNomUrl(-1,
'accountancy');
342 print
'<td class="right">';
343 print
'<span class="amount">';
344 print
price($obj->amount, 1, $langs, 1, -1, -1, $conf->currency).
' / '.
price($obj->total_ttc, 1, $langs, 1, -1, -1, $conf->currency);
348 print
'<td class="center">'.dol_print_date($db->jdate($obj->date_demande),
'day').
'</td>';
352 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 salary payments.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
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 a 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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.