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');
68$toselect =
GETPOST(
'toselect',
'array:int');
69$massaction =
GETPOST(
'massaction',
'alpha');
71if (empty($page) || $page == -1 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') || (empty($toselect) && $massaction ===
'0')) {
74$offset = $limit * $page;
84$massactionbutton =
'';
86$hookmanager->initHooks(array(
'withdrawalstodolist'));
89 $socid = $user->socid;
91if ($type ==
'bank-transfer') {
92 $result =
restrictedArea($user,
'paymentbybanktransfer',
'',
'',
'');
102$parameters = array(
'socid' => $socid,
'limit' => $limit,
'page' => $page,
'offset' => $offset);
103$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
109if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
110 $search_facture =
'';
111 $search_societe =
'';
112 $search_array_options = array();
123if ($type !=
'bank-transfer') {
125 $title = $langs->trans(
"RequestStandingOrderToTreat");
127 $title = $langs->trans(
"RequestStandingOrderTreated");
131 $title = $langs->trans(
"RequestPaymentsByBankTransferToTreat");
133 $title = $langs->trans(
"RequestPaymentsByBankTransferTreated");
140if ($type ==
'bank-transfer') {
147if ($sourcetype !=
'salary') {
148 $sql =
"SELECT f.ref, f.rowid, f.total_ttc,";
149 $sql .=
" s.nom as name, s.rowid as socid,";
150 $sql .=
" pd.date_demande as date_demande, pd.amount, pd.fk_user_demande";
151 if ($type !=
'bank-transfer') {
152 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f,";
154 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f,";
156 $sql .=
" ".MAIN_DB_PREFIX.
"societe as s,";
157 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement_demande as pd";
158 if (!$user->hasRight(
'societe',
'client',
'voir')) {
159 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
161 $sql .=
" WHERE s.rowid = f.fk_soc";
162 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
163 if (!$user->hasRight(
'societe',
'client',
'voir')) {
164 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
167 $sql .=
" AND f.fk_soc = ".((int) $socid);
170 $sql .=
" AND pd.traite = 0";
172 $sql .=
" AND pd.ext_payment_id IS NULL";
174 $sql .=
" AND pd.traite = ".((int) $status);
176 $sql .=
" AND f.total_ttc > 0";
178 $sql .=
" AND f.fk_statut = ".Facture::STATUS_VALIDATED;
180 if ($type !=
'bank-transfer') {
181 $sql .=
" AND pd.fk_facture = f.rowid";
183 $sql .=
" AND pd.fk_facture_fourn = f.rowid";
185 if ($search_facture) {
188 if ($search_societe) {
191 $sql .=
$db->order($sortfield, $sortorder);
193 $sql =
"SELECT s.rowid,s.amount as total_ttc, pd.amount,";
194 $sql .=
" s.fk_user, pd.date_demande, pd.fk_salary, CONCAT(u.firstname,' ',u.lastname) as nom";
195 $sql .=
" FROM ".MAIN_DB_PREFIX.
"salary as s, ".MAIN_DB_PREFIX.
"user as u,";
196 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement_demande as pd";
197 $sql .=
" WHERE s.rowid = pd.fk_salary";
198 $sql .=
" AND u.rowid = s.fk_user";
199 $sql .=
" AND s.entity IN (".getEntity(
"salary").
")";
204 $sql .=
" AND pd.traite = 0";
206 $sql .=
" AND pd.ext_payment_id IS NULL";
208 $sql .=
" AND pd.traite = ".((int) $status);
210 $sql .=
" AND s.amount > 0";
211 $sql .=
" AND s.paye = ".Salary::STATUS_UNPAID;
212 if ($search_facture) {
215 if ($search_societe) {
216 $sql .=
natural_search(
"CONCAT(u.firstname,' ',u.lastname)", $search_societe);
221$nbtotalofrecords =
'';
224 $resql =
$db->query($sql);
225 $nbtotalofrecords =
$db->num_rows($resql);
226 if (($page * $limit) > (
int) $nbtotalofrecords) {
232if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) {
233 $num = $nbtotalofrecords;
235 $sql .=
$db->plimit($limit + 1, $offset);
237 $resql =
$db->query($sql);
243 $num =
$db->num_rows($resql);
248$newcardbutton =
'<a class="marginrightonly" href="'.DOL_URL_ROOT.
'/compta/prelevement/index.php">'.$langs->trans(
"GoBack").
'</a>';
249if ($type ==
'bank-transfer') {
250 $newcardbutton =
'<a class="marginrightonly" href="'.DOL_URL_ROOT.
'/compta/paymentbybanktransfer/index.php">'.$langs->trans(
"GoBack").
'</a>';
252if ($sourcetype !=
'salary') {
253 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" id="searchFormList" name="searchFormList">';
255 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?status=0&type=bank-transfer&sourcetype='.$sourcetype.
'" method="POST" id="searchFormList" name="searchFormList">';
257if ($optioncss !=
'') {
258 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
260print
'<input type="hidden" name="token" value="'.newToken().
'">';
261print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
262print
'<input type="hidden" name="action" value="list">';
263print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
264print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
265print
'<input type="hidden" name="page" value="'.$page.
'">';
266print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
270$label =
'NewStandingOrder';
272if ($type ==
'bank-transfer') {
273 $label =
'NewPaymentByBankTransfer';
274 $typefilter =
'type='.$type;
276$newcardbutton .= dolGetButtonTitle($langs->trans($label),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/compta/prelevement/create.php'.($typefilter ?
'?'.$typefilter :
'').($sourcetype ?
'&sourcetype='.$sourcetype :
''));
278print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'generic', 0, $newcardbutton,
'', $limit);
280print
'<div class="div-table-responsive">';
281print
'<table class="liste centpercent">';
283print
'<tr class="liste_titre">';
285if (
$conf->main_checkbox_left_column) {
286 print
'<td class="liste_titre maxwidthsearch">';
287 $searchpicto = $form->showFilterButtons();
291print
'<td class="liste_titre"><input type="text" class="flat maxwidth150" name="search_facture" value="'.dol_escape_htmltag($search_facture).
'"></td>';
292print
'<td class="liste_titre"><input type="text" class="flat maxwidth150" name="search_societe" value="'.dol_escape_htmltag($search_societe).
'"></td>';
293print
'<td class="liste_titre"></td>';
294print
'<td class="liste_titre"></td>';
296if (!
$conf->main_checkbox_left_column) {
297 print
'<td class="liste_titre maxwidthsearch">';
298 $searchpicto = $form->showFilterButtons();
304print
'<tr class="liste_titre">';
305if (
$conf->main_checkbox_left_column) {
312if (!
$conf->main_checkbox_left_column) {
321while ($i < min($num, $limit) && $resql !==
null) {
322 $obj =
$db->fetch_object($resql);
326 if ($sourcetype !=
'salary') {
327 $invoicestatic->fetch($obj->rowid);
329 $salarystatic->fetch($obj->fk_salary);
330 $userstatic->fetch($obj->fk_user);
332 print
'<tr class="oddeven">';
335 if (
$conf->main_checkbox_left_column) {
336 print
'<td class="right"></td>';
340 print
'<td class="tdoverflowmax125">';
341 if ($sourcetype !=
'salary') {
342 print $invoicestatic->getNomUrl(1,
'withdraw');
344 print $salarystatic->getNomUrl(1,
'withdraw');
348 print
'<td class="tdoverflowmax150">';
349 if ($sourcetype !=
'salary') {
350 $thirdpartystatic->id = $obj->socid;
351 $thirdpartystatic->name = $obj->name;
352 print $thirdpartystatic->getNomUrl(1,
'customer');
354 print $userstatic->getNomUrl(-1,
'accountancy');
358 print
'<td class="right">';
359 print
'<span class="amount">';
360 if ($obj->amount != $obj->total_ttc) {
361 print
price($obj->amount, 1, $langs, 1, -1, -1,
$conf->currency).
' / '.
price($obj->total_ttc, 1, $langs, 1, -1, -1,
$conf->currency);
363 print
price($obj->total_ttc, 1, $langs, 1, -1, -1,
$conf->currency);
368 print
'<td class="center">'.dol_print_date(
$db->jdate($obj->date_demande),
'day').
'</td>';
371 if (!
$conf->main_checkbox_left_column) {
372 print
'<td class="right"></td>';
381 print
'<tr><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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.
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.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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.
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.