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'));
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');
55$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
56$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
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();
108$form =
new Form($db);
110if ($type !=
'bank-transfer') {
112 $title = $langs->trans(
"RequestStandingOrderToTreat");
114 $title = $langs->trans(
"RequestStandingOrderTreated");
118 $title = $langs->trans(
"RequestPaymentsByBankTransferToTreat");
120 $title = $langs->trans(
"RequestPaymentsByBankTransferTreated");
126$thirdpartystatic =
new Societe($db);
127if ($type ==
'bank-transfer') {
130 $invoicestatic =
new Facture($db);
134if ($sourcetype !=
'salary') {
135 $sql =
"SELECT f.ref, f.rowid, f.total_ttc,";
136 $sql .=
" s.nom as name, s.rowid as socid,";
137 $sql .=
" pd.date_demande as date_demande, pd.amount, pd.fk_user_demande";
138 if ($type !=
'bank-transfer') {
139 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f,";
141 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f,";
143 $sql .=
" ".MAIN_DB_PREFIX.
"societe as s,";
144 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement_demande as pd";
145 if (!$user->hasRight(
'societe',
'client',
'voir')) {
146 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
148 $sql .=
" WHERE s.rowid = f.fk_soc";
149 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
150 if (!$user->hasRight(
'societe',
'client',
'voir')) {
151 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
154 $sql .=
" AND f.fk_soc = ".((int) $socid);
157 $sql .=
" AND pd.traite = 0";
159 $sql .=
" AND pd.ext_payment_id IS NULL";
161 $sql .=
" AND pd.traite = ".((int) $status);
163 $sql .=
" AND f.total_ttc > 0";
165 $sql .=
" AND f.fk_statut = ".Facture::STATUS_VALIDATED;
167 if ($type !=
'bank-transfer') {
168 $sql .=
" AND pd.fk_facture = f.rowid";
170 $sql .=
" AND pd.fk_facture_fourn = f.rowid";
172 if ($search_facture) {
175 if ($search_societe) {
178 $sql .= $db->order($sortfield, $sortorder);
180 $sql =
"SELECT s.rowid,s.amount as total_ttc, pd.amount,";
181 $sql .=
" s.fk_user, pd.date_demande, pd.fk_salary, CONCAT(u.firstname,' ',u.lastname) as nom";
182 $sql .=
" FROM ".MAIN_DB_PREFIX.
"salary as s, ".MAIN_DB_PREFIX.
"user as u,";
183 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement_demande as pd";
184 $sql .=
" WHERE s.rowid = pd.fk_salary";
185 $sql .=
" AND u.rowid = s.fk_user";
186 $sql .=
" AND s.entity IN (".getEntity(
"salary").
")";
191 $sql .=
" AND pd.traite = 0";
193 $sql .=
" AND pd.ext_payment_id IS NULL";
195 $sql .=
" AND pd.traite = ".((int) $status);
197 $sql .=
" AND s.amount > 0";
198 $sql .=
" AND s.paye = ".Salary::STATUS_UNPAID;
199 if ($search_facture) {
202 if ($search_societe) {
203 $sql .=
natural_search(
"CONCAT(u.firstname,' ',u.lastname)", $search_societe);
208$nbtotalofrecords =
'';
210 $resql = $db->query($sql);
211 $nbtotalofrecords = $db->num_rows($resql);
212 if (($page * $limit) > $nbtotalofrecords) {
218if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) {
219 $num = $nbtotalofrecords;
221 $sql .= $db->plimit($limit + 1, $offset);
223 $resql = $db->query($sql);
229 $num = $db->num_rows($resql);
234$newcardbutton =
'<a class="marginrightonly" href="'.DOL_URL_ROOT.
'/compta/prelevement/index.php">'.$langs->trans(
"Back").
'</a>';
235if ($type ==
'bank-transfer') {
236 $newcardbutton =
'<a class="marginrightonly" href="'.DOL_URL_ROOT.
'/compta/paymentbybanktransfer/index.php">'.$langs->trans(
"Back").
'</a>';
238if ($sourcetype !=
'salary') {
239 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" id="searchFormList" name="searchFormList">';
241 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?status=0&type=bank-transfer&sourcetype='.$sourcetype.
'" method="POST" id="searchFormList" name="searchFormList">';
243if ($optioncss !=
'') {
244 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
246print
'<input type="hidden" name="token" value="'.newToken().
'">';
247print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
248print
'<input type="hidden" name="action" value="list">';
249print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
250print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
251print
'<input type="hidden" name="page" value="'.$page.
'">';
252print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
256$label =
'NewStandingOrder';
258if ($type ==
'bank-transfer') {
259 $label =
'NewPaymentByBankTransfer';
260 $typefilter =
'type='.$type;
262$newcardbutton .=
dolGetButtonTitle($langs->trans($label),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/compta/prelevement/create.php'.($typefilter ?
'?'.$typefilter :
'').($sourcetype ?
'&sourcetype='.$sourcetype :
''));
264print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'generic', 0, $newcardbutton,
'', $limit);
266print
'<div class="div-table-responsive">';
267print
'<table class="liste centpercent">';
269print
'<tr class="liste_titre">';
272 print
'<td class="liste_titre maxwidthsearch">';
273 $searchpicto = $form->showFilterButtons();
277print
'<td class="liste_titre"><input type="text" class="flat maxwidth150" name="search_facture" value="'.dol_escape_htmltag($search_facture).
'"></td>';
278print
'<td class="liste_titre"><input type="text" class="flat maxwidth150" name="search_societe" value="'.dol_escape_htmltag($search_societe).
'"></td>';
279print
'<td class="liste_titre"></td>';
280print
'<td class="liste_titre"></td>';
283 print
'<td class="liste_titre maxwidthsearch">';
284 $searchpicto = $form->showFilterButtons();
290print
'<tr class="liste_titre">';
303$userstatic =
new User($db);
304$salarystatic =
new Salary($db);
307while ($i < min($num, $limit)) {
308 $obj = $db->fetch_object($resql);
312 if ($sourcetype !=
'salary') {
313 $invoicestatic->fetch($obj->rowid);
315 $salarystatic->fetch($obj->fk_salary);
316 $userstatic->fetch($obj->fk_user);
318 print
'<tr class="oddeven">';
322 print
'<td class="right"></td>';
327 if ($sourcetype !=
'salary') {
328 print $invoicestatic->getNomUrl(1,
'withdraw');
330 print $salarystatic->getNomUrl(1,
'withdraw');
335 if ($sourcetype !=
'salary') {
336 $thirdpartystatic->id = $obj->socid;
337 $thirdpartystatic->name = $obj->name;
338 print $thirdpartystatic->getNomUrl(1,
'customer');
340 print $userstatic->getNomUrl(-1,
'accountancy');
344 print
'<td class="right">';
345 print
'<span class="amount">';
346 print
price($obj->amount, 1, $langs, 1, -1, -1, $conf->currency).
' / '.
price($obj->total_ttc, 1, $langs, 1, -1, -1, $conf->currency);
350 print
'<td class="center">'.dol_print_date($db->jdate($obj->date_demande),
'day').
'</td>';
354 print
'<td class="right"></td>';
363 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()
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.
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.
print_barre_liste($title, $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.
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.
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 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.