30require
'../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/modules/modPrelevement.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/salaries/class/salary.class.php';
47$langs->loadLangs(array(
'banks',
'categories',
'withdrawals',
'companies'));
53$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'directdebitcredittransferlist';
54$backtopage =
GETPOST(
'backtopage',
'alpha');
55$optioncss =
GETPOST(
'optioncss',
'aZ');
58$sourcetype =
GETPOST(
'sourcetype',
'aZ');
60$search_facture =
GETPOST(
'search_facture',
'alpha');
61$search_societe =
GETPOST(
'search_societe',
'alpha');
65$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
66$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
68if (empty($page) || $page == -1 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') || (empty($toselect) && $massaction ===
'0')) {
71$offset = $limit * $page;
81$massactionbutton =
'';
83$hookmanager->initHooks(array(
'withdrawalstodolist'));
86 $socid = $user->socid;
88if ($type ==
'bank-transfer') {
89 $result =
restrictedArea($user,
'paymentbybanktransfer',
'',
'',
'');
99$parameters = array(
'socid' => $socid,
'limit' => $limit,
'page' => $page,
'offset' => $offset);
100$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
106if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
107 $search_facture =
'';
108 $search_societe =
'';
109 $search_array_options = array();
118$form =
new Form($db);
120if ($type !=
'bank-transfer') {
122 $title = $langs->trans(
"RequestStandingOrderToTreat");
124 $title = $langs->trans(
"RequestStandingOrderTreated");
128 $title = $langs->trans(
"RequestPaymentsByBankTransferToTreat");
130 $title = $langs->trans(
"RequestPaymentsByBankTransferTreated");
136$thirdpartystatic =
new Societe($db);
137if ($type ==
'bank-transfer') {
140 $invoicestatic =
new Facture($db);
144if ($sourcetype !=
'salary') {
145 $sql =
"SELECT f.ref, f.rowid, f.total_ttc,";
146 $sql .=
" s.nom as name, s.rowid as socid,";
147 $sql .=
" pd.date_demande as date_demande, pd.amount, pd.fk_user_demande";
148 if ($type !=
'bank-transfer') {
149 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f,";
151 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f,";
153 $sql .=
" ".MAIN_DB_PREFIX.
"societe as s,";
154 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement_demande as pd";
155 if (!$user->hasRight(
'societe',
'client',
'voir')) {
156 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
158 $sql .=
" WHERE s.rowid = f.fk_soc";
159 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
160 if (!$user->hasRight(
'societe',
'client',
'voir')) {
161 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
164 $sql .=
" AND f.fk_soc = ".((int) $socid);
167 $sql .=
" AND pd.traite = 0";
169 $sql .=
" AND pd.ext_payment_id IS NULL";
171 $sql .=
" AND pd.traite = ".((int) $status);
173 $sql .=
" AND f.total_ttc > 0";
175 $sql .=
" AND f.fk_statut = ".Facture::STATUS_VALIDATED;
177 if ($type !=
'bank-transfer') {
178 $sql .=
" AND pd.fk_facture = f.rowid";
180 $sql .=
" AND pd.fk_facture_fourn = f.rowid";
182 if ($search_facture) {
185 if ($search_societe) {
188 $sql .= $db->order($sortfield, $sortorder);
190 $sql =
"SELECT s.rowid,s.amount as total_ttc, pd.amount,";
191 $sql .=
" s.fk_user, pd.date_demande, pd.fk_salary, CONCAT(u.firstname,' ',u.lastname) as nom";
192 $sql .=
" FROM ".MAIN_DB_PREFIX.
"salary as s, ".MAIN_DB_PREFIX.
"user as u,";
193 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement_demande as pd";
194 $sql .=
" WHERE s.rowid = pd.fk_salary";
195 $sql .=
" AND u.rowid = s.fk_user";
196 $sql .=
" AND s.entity IN (".getEntity(
"salary").
")";
201 $sql .=
" AND pd.traite = 0";
203 $sql .=
" AND pd.ext_payment_id IS NULL";
205 $sql .=
" AND pd.traite = ".((int) $status);
207 $sql .=
" AND s.amount > 0";
208 $sql .=
" AND s.paye = ".Salary::STATUS_UNPAID;
209 if ($search_facture) {
212 if ($search_societe) {
213 $sql .=
natural_search(
"CONCAT(u.firstname,' ',u.lastname)", $search_societe);
218$nbtotalofrecords =
'';
221 $resql = $db->query($sql);
222 $nbtotalofrecords = $db->num_rows($resql);
223 if (($page * $limit) > $nbtotalofrecords) {
229if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) {
230 $num = $nbtotalofrecords;
232 $sql .= $db->plimit($limit + 1, $offset);
234 $resql = $db->query($sql);
240 $num = $db->num_rows($resql);
245$newcardbutton =
'<a class="marginrightonly" href="'.DOL_URL_ROOT.
'/compta/prelevement/index.php">'.$langs->trans(
"Back").
'</a>';
246if ($type ==
'bank-transfer') {
247 $newcardbutton =
'<a class="marginrightonly" href="'.DOL_URL_ROOT.
'/compta/paymentbybanktransfer/index.php">'.$langs->trans(
"Back").
'</a>';
249if ($sourcetype !=
'salary') {
250 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" id="searchFormList" name="searchFormList">';
252 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?status=0&type=bank-transfer&sourcetype='.$sourcetype.
'" method="POST" id="searchFormList" name="searchFormList">';
254if ($optioncss !=
'') {
255 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
257print
'<input type="hidden" name="token" value="'.newToken().
'">';
258print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
259print
'<input type="hidden" name="action" value="list">';
260print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
261print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
262print
'<input type="hidden" name="page" value="'.$page.
'">';
263print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
267$label =
'NewStandingOrder';
269if ($type ==
'bank-transfer') {
270 $label =
'NewPaymentByBankTransfer';
271 $typefilter =
'type='.$type;
273$newcardbutton .=
dolGetButtonTitle($langs->trans($label),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/compta/prelevement/create.php'.($typefilter ?
'?'.$typefilter :
'').($sourcetype ?
'&sourcetype='.$sourcetype :
''));
275print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'generic', 0, $newcardbutton,
'', $limit);
277print
'<div class="div-table-responsive">';
278print
'<table class="liste centpercent">';
280print
'<tr class="liste_titre">';
283 print
'<td class="liste_titre maxwidthsearch">';
284 $searchpicto = $form->showFilterButtons();
288print
'<td class="liste_titre"><input type="text" class="flat maxwidth150" name="search_facture" value="'.dol_escape_htmltag($search_facture).
'"></td>';
289print
'<td class="liste_titre"><input type="text" class="flat maxwidth150" name="search_societe" value="'.dol_escape_htmltag($search_societe).
'"></td>';
290print
'<td class="liste_titre"></td>';
291print
'<td class="liste_titre"></td>';
294 print
'<td class="liste_titre maxwidthsearch">';
295 $searchpicto = $form->showFilterButtons();
301print
'<tr class="liste_titre">';
314$userstatic =
new User($db);
315$salarystatic =
new Salary($db);
318while ($i < min($num, $limit)) {
319 $obj = $db->fetch_object($resql);
323 if ($sourcetype !=
'salary') {
324 $invoicestatic->fetch($obj->rowid);
326 $salarystatic->fetch($obj->fk_salary);
327 $userstatic->fetch($obj->fk_user);
329 print
'<tr class="oddeven">';
333 print
'<td class="right"></td>';
338 if ($sourcetype !=
'salary') {
339 print $invoicestatic->getNomUrl(1,
'withdraw');
341 print $salarystatic->getNomUrl(1,
'withdraw');
346 if ($sourcetype !=
'salary') {
347 $thirdpartystatic->id = $obj->socid;
348 $thirdpartystatic->name = $obj->name;
349 print $thirdpartystatic->getNomUrl(1,
'customer');
351 print $userstatic->getNomUrl(-1,
'accountancy');
355 print
'<td class="right">';
356 print
'<span class="amount">';
357 if ($obj->amount != $obj->total_ttc) {
358 print
price($obj->amount, 1, $langs, 1, -1, -1,
$conf->currency).
' / '.
price($obj->total_ttc, 1, $langs, 1, -1, -1,
$conf->currency);
360 print
price($obj->total_ttc, 1, $langs, 1, -1, -1,
$conf->currency);
365 print
'<td class="center">'.dol_print_date($db->jdate($obj->date_demande),
'day').
'</td>';
369 print
'<td class="right"></td>';
378 print
'<tr><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.