28 require
'../../main.inc.php';
31 $socid =
GETPOST(
'socid',
'int');
32 if ($user->socid) $socid = $user->socid;
35 require_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/tva.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
42 $langs->loadLangs(array(
'compta',
'bills'));
44 $action =
GETPOST(
'action',
'alpha');
45 $massaction =
GETPOST(
'massaction',
'alpha');
46 $confirm =
GETPOST(
'confirm',
'alpha');
47 $optioncss =
GETPOST(
'optioncss',
'alpha');
48 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'salestaxeslist';
50 $search_ref =
GETPOST(
'search_ref',
'alpha');
51 $search_label =
GETPOST(
'search_label',
'alpha');
52 $search_dateend_start =
dol_mktime(0, 0, 0,
GETPOST(
'search_dateend_startmonth',
'int'),
GETPOST(
'search_dateend_startday',
'int'),
GETPOST(
'search_dateend_startyear',
'int'));
53 $search_dateend_end =
dol_mktime(23, 59, 59,
GETPOST(
'search_dateend_endmonth',
'int'),
GETPOST(
'search_dateend_endday',
'int'),
GETPOST(
'search_dateend_endyear',
'int'));
54 $search_datepayment_start =
dol_mktime(0, 0, 0,
GETPOST(
'search_datepayment_startmonth',
'int'),
GETPOST(
'search_datepayment_startday',
'int'),
GETPOST(
'search_datepayment_startyear',
'int'));
55 $search_datepayment_end =
dol_mktime(23, 59, 59,
GETPOST(
'search_datepayment_endmonth',
'int'),
GETPOST(
'search_datepayment_endday',
'int'),
GETPOST(
'search_datepayment_endyear',
'int'));
56 $search_type =
GETPOST(
'search_type',
'int');
57 $search_cheque =
GETPOST(
'search_cheque',
'alpha');
58 $search_account =
GETPOST(
'search_account',
'int');
59 $search_amount =
GETPOST(
'search_amount',
'alpha');
61 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
62 $sortfield =
GETPOST(
'sortfield',
'alpha');
63 $sortorder =
GETPOST(
'sortorder',
'alpha');
66 if (empty($page) || $page == -1) $page = 0;
67 $offset = $limit * $page;
68 $pageprev = $page - 1;
69 $pagenext = $page + 1;
71 if (!$sortfield) $sortfield =
't.datev';
72 if (!$sortorder) $sortorder =
'DESC';
75 't.rowid' =>array(
'checked'=>1,
'position'=>10,
'label'=>
"Ref",),
76 't.label' =>array(
'checked'=>1,
'position'=>20,
'label'=>
"Label"),
77 't.datev' =>array(
'checked'=>1,
'position'=>30,
'label'=>
"PeriodEndDate"),
78 't.datep' =>array(
'checked'=>1,
'position'=>40,
'label'=>
"DatePayment"),
79 't.fk_typepayment' =>array(
'checked'=>1,
'position'=>50,
'label'=>
"Type"),
80 't.num_payment' =>array(
'checked'=>1,
'position'=>60,
'label'=>
"Numero",
'tooltip'=>
"ChequeOrTransferNumber"),
81 'transaction' =>array(
'checked'=>1,
'position'=>70,
'label'=>
"BankTransactionLine",
'enabled'=>(!empty($conf->banque->enabled))),
82 'ba.label' =>array(
'checked'=>1,
'position'=>80,
'label'=>
"Account",
'enable'=>(!empty($conf->banque->enabled))),
83 't.amount' =>array(
'checked'=>1,
'position'=>90,
'label'=>
"PayedByThisPayment"),
88 $hookmanager->initHooks(array(
'salestaxeslist'));
89 $object =
new Tva($db);
96 $parameters = array(
'socid'=>$socid);
97 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
98 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
101 if (empty($reshook)) {
102 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
104 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha'))
108 $search_dateend_start =
'';
109 $search_dateend_end =
'';
110 $search_datepayment_start =
'';
111 $search_datepayment_end =
'';
114 $search_account =
'';
124 $form =
new Form($db);
126 $tva_static =
new Tva($db);
127 $bankstatic =
new Account($db);
131 llxHeader(
'', $langs->trans(
"VATPayments"));
133 $sql =
'SELECT t.rowid, t.amount, t.label, t.datev, t.datep, t.fk_typepayment as type, t.num_payment, t.fk_bank';
134 $sql .=
', ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel';
135 $sql .=
', pst.code as payment_code';
136 $sql .=
' FROM '.MAIN_DB_PREFIX.
'tva as t';
137 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as pst ON t.fk_typepayment = pst.id';
138 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON t.fk_bank = b.rowid';
139 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
140 $sql .=
' WHERE t.entity IN ('.getEntity($object->element).
')';
142 if (!empty($search_ref)) $sql .=
natural_search(
't.rowid', $search_ref);
143 if (!empty($search_label)) $sql .=
natural_search(
't.label', $search_label);
144 if (!empty($search_dateend_start)) $sql .=
' AND t.datev >= "'.$db->idate($search_dateend_start).
'"';
145 if (!empty($search_dateend_end)) $sql .=
' AND t.datev <= "'.$db->idate($search_dateend_end).
'"';
146 if (!empty($search_datepayment_start)) $sql .=
' AND t.datep >= "'.$db->idate($search_datepayment_start).
'"';
147 if (!empty($search_datepayment_end)) $sql .=
' AND t.datep <= "'.$db->idate($search_datepayment_end).
'"';
148 if (!empty($search_type) && $search_type > 0) $sql .=
' AND t.fk_typepayment='.$search_type;
149 if (!empty($search_cheque)) $sql .=
natural_search(
't.num_payment', $search_cheque);
150 if (!empty($search_account) && $search_account > 0) $sql .=
' AND b.fk_account='.$search_account;
153 $sql .= $db->order($sortfield, $sortorder);
155 $nbtotalofrecords =
'';
156 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
157 $result = $db->query($sql);
158 $nbtotalofrecords = $db->num_rows($result);
161 if (($page * $limit) > $nbtotalofrecords) {
167 $sql .= $db->plimit($limit + 1, $offset);
169 $result = $db->query($sql);
178 $num = $db->num_rows($result);
181 if (!empty($contextpage) && $contextpage !=
$_SERVER[
'PHP_SELF']) $param .=
'&contextpage='.$contextpage;
182 if ($limit > 0 && $limit != $conf->liste_limit) $param .=
'&limit='.$limit;
183 if ($optioncss !=
'') $param .=
'&optioncss='.urlencode($optioncss);
185 if (!empty($search_ref)) $param .=
'&search_ref="'.$search_ref.
'"';
186 if (!empty($search_label)) $param .=
'&search_label="'.$search_label.
'"';
187 if (!empty($search_dateend_start)) $param .=
'&search_dateend_startyear='.GETPOST(
'search_dateend_startyear',
'int');
188 if (!empty($search_dateend_start)) $param .=
'&search_dateend_startmonth='.GETPOST(
'search_dateend_startmonth',
'int');
189 if (!empty($search_dateend_start)) $param .=
'&search_dateend_startday='.GETPOST(
'search_dateend_startday',
'int');
190 if (!empty($search_dateend_end)) $param .=
'&search_dateend_endyear='.GETPOST(
'search_dateend_endyear',
'int');
191 if (!empty($search_dateend_end)) $param .=
'&search_dateend_endmonth='.GETPOST(
'search_dateend_endmonth',
'int');
192 if (!empty($search_dateend_end)) $param .=
'&search_dateend_endday='.GETPOST(
'search_dateend_endday',
'int');
193 if (!empty($search_datepayment_start)) $param .=
'&search_datepayment_startyear='.GETPOST(
'search_datepayment_startyear',
'int');
194 if (!empty($search_datepayment_start)) $param .=
'&search_datepayment_startmonth='.GETPOST(
'search_datepayment_startmonth',
'int');
195 if (!empty($search_datepayment_start)) $param .=
'&search_datepayment_startday='.GETPOST(
'search_datepayment_startday',
'int');
196 if (!empty($search_datepayment_end)) $param .=
'&search_datepayment_endyear='.GETPOST(
'search_datepayment_endyear',
'int');
197 if (!empty($search_datepayment_end)) $param .=
'&search_datepayment_endmonth='.GETPOST(
'search_datepayment_endmonth',
'int');
198 if (!empty($search_datepayment_end)) $param .=
'&search_datepayment_endday='.GETPOST(
'search_datepayment_endday',
'int');
199 if (!empty($search_type) && $search_type > 0) $param .=
'&search_type='.$search_type;
200 if (!empty($search_cheque)) $param .=
'&search_cheque="'.$search_cheque.
'"';
201 if (!empty($search_account) && $search_account > 0) $param .=
'&search_account='.$search_account;
202 if (!empty($search_amount)) $param .=
'&search_amount="'.$search_amount.
'"';
204 print '<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
205 if ($optioncss !=
'')
print '<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
206 print '<input type="hidden" name="token" value="'.newToken().
'">';
207 print '<input type="hidden" name="action" value="list">';
208 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
209 print '<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
210 print '<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
211 print '<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
213 $url = DOL_URL_ROOT.
'/compta/tva/card.php?action=create';
214 if (!empty($socid)) $url .=
'&socid='.$socid;
215 $newcardbutton =
dolGetButtonTitle($langs->trans(
'NewVATPayment', ($ltt + 1)),
'',
'fa fa-plus-circle', $url,
'', $user->rights->tax->charges->creer);
216 print_barre_liste($langs->trans(
"VATPayments"), $page,
$_SERVER[
'PHP_SELF'], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'title_accountancy', 0, $newcardbutton,
'', $limit, 0, 0, 1);
218 $varpage = empty($contextpage) ? $_SERVER[
'PHP_SELF'] : $contextpage;
219 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
220 if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons(
'checkforselect', 1);
222 print '<div class="div-table-responsive">';
223 print '<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
'').
'">';
225 print '<tr class="liste_titre_filter">';
228 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
229 print
'<td class="liste_titre">';
234 if (!empty($arrayfields[
't.rowid'][
'checked'])) {
235 print
'<td class="liste_titre">';
236 print
'<input type="text" class="flat" size="4" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
241 if (!empty($arrayfields[
't.label'][
'checked'])) {
242 print
'<td class="liste_titre">';
243 print
'<input type="text" class="flat" size="10" name="search_label" value="'.dol_escape_htmltag($search_label).
'">';
248 if (!empty($arrayfields[
't.datev'][
'checked'])) {
249 print
'<td class="liste_titre center">';
250 print
'<div class="nowrap">';
251 print $form->selectDate($search_dateend_start ? $search_dateend_start : -1,
'search_dateend_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
253 print
'<div class="nowrap">';
254 print $form->selectDate($search_dateend_end ? $search_dateend_end : -1,
'search_dateend_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
260 if (!empty($arrayfields[
't.datep'][
'checked'])) {
261 print
'<td class="liste_titre center">';
262 print
'<div class="nowrap">';
263 print $form->selectDate($search_datepayment_start ? $search_datepayment_start : -1,
'search_datepayment_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
265 print
'<div class="nowrap">';
266 print $form->selectDate($search_datepayment_end ? $search_datepayment_end : -1,
'search_datepayment_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
272 if (!empty($arrayfields[
't.fk_typepayment'][
'checked'])) {
273 print
'<td class="liste_titre left">';
274 $form->select_types_paiements($search_type,
'search_type',
'', 0, 1, 1, 16);
279 if (!empty($arrayfields[
't.num_payment'][
'checked'])) {
280 print
'<td class="liste_titre left">';
281 print
'<input name="search_cheque" class="flat" type="text" size="8" value="'.$search_cheque.
'">';
286 if (!empty($arrayfields[
'transaction'][
'checked'])) {
287 print
'<td class="liste_titre">';
292 if (!empty($arrayfields[
'ba.label'][
'checked'])) {
293 print
'<td class="liste_titre">';
294 $form->select_comptes($search_account,
'search_account', 0,
'', 1);
299 if (!empty($arrayfields[
't.amount'][
'checked'])) {
300 print
'<td class="liste_titre right">';
301 print
'<input name="search_amount" class="flat" type="text" size="8" value="'.$search_amount.
'">';
306 $parameters = array(
'arrayfields'=>$arrayfields);
307 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
308 print $hookmanager->resPrint;
311 print
'<td class="liste_titre maxwidthsearch">';
312 print $form->showFilterAndCheckAddButtons(0);
317 print
'<tr class="liste_titre">';
318 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST))
print_liste_field_titre(
'#', $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder);
319 if (!empty($arrayfields[
't.rowid'][
'checked']))
print_liste_field_titre($arrayfields[
't.rowid'][
'label'], $_SERVER[
'PHP_SELF'],
't.rowid',
'', $param,
'', $sortfield, $sortorder);
320 if (!empty($arrayfields[
't.label'][
'checked']))
print_liste_field_titre($arrayfields[
't.label'][
'label'], $_SERVER[
'PHP_SELF'],
't.label',
'', $param,
'align="left"', $sortfield, $sortorder);
321 if (!empty($arrayfields[
't.datev'][
'checked']))
print_liste_field_titre($arrayfields[
't.datev'][
'label'], $_SERVER[
'PHP_SELF'],
't.datev',
'', $param,
'align="center"', $sortfield, $sortorder);
322 if (!empty($arrayfields[
't.datep'][
'checked']))
print_liste_field_titre($arrayfields[
't.datep'][
'label'], $_SERVER[
'PHP_SELF'],
't.datep',
'', $param,
'align="center"', $sortfield, $sortorder);
323 if (!empty($arrayfields[
't.fk_typepayment'][
'checked']))
print_liste_field_titre($arrayfields[
't.fk_typepayment'][
'label'], $_SERVER[
'PHP_SELF'],
't.fk_typepayment',
'', $param,
'', $sortfield, $sortorder,
'left ');
324 if (!empty($arrayfields[
't.num_payment'][
'checked']))
print_liste_field_titre($arrayfields[
't.num_payment'][
'label'], $_SERVER[
'PHP_SELF'],
't.num_payment',
'', $param,
'', $sortfield, $sortorder,
'', $arrayfields[
't.num_payment'][
'tooltip']);
325 if (!empty($arrayfields[
'transaction'][
'checked']))
print_liste_field_titre($arrayfields[
'transaction'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder);
326 if (!empty($arrayfields[
'ba.label'][
'checked']))
print_liste_field_titre($arrayfields[
'ba.label'][
'label'], $_SERVER[
'PHP_SELF'],
'ba.label',
'', $param,
'', $sortfield, $sortorder,
'left ');
327 if (!empty($arrayfields[
't.amount'][
'checked']))
print_liste_field_titre($arrayfields[
't.amount'][
'label'], $_SERVER[
'PHP_SELF'],
't.amount',
'', $param,
'', $sortfield, $sortorder,
'right ');
330 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
331 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
332 print $hookmanager->resPrint;
334 print_liste_field_titre($selectedfields, $_SERVER[
'PHP_SELF'],
'',
'',
'',
'align="center"', $sortfield, $sortorder,
'maxwidthsearch ');
338 $totalarray = array();
339 while ($i < min($num, $limit)) {
340 $obj = $db->fetch_object($result);
342 $tva_static->id = $obj->rowid;
343 $tva_static->ref = $obj->rowid;
345 print
'<tr class="oddeven">';
348 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
349 print
'<td>'.(($offset * $limit) + $i).
'</td>';
350 if (!$i) $totalarray[
'nbfield']++;
354 if (!empty($arrayfields[
't.rowid'][
'checked'])) {
355 print
'<td>'.$tva_static->getNomUrl(1).
'</td>';
356 if (!$i) $totalarray[
'nbfield']++;
360 if (!empty($arrayfields[
't.label'][
'checked'])) {
361 print
'<td>'.dol_trunc($obj->label, 40).
'</td>';
362 if (!$i) $totalarray[
'nbfield']++;
366 if (!empty($arrayfields[
't.datev'][
'checked'])) {
367 print
'<td class="center">'.dol_print_date($db->jdate($obj->datev),
'day').
'</td>';
368 if (!$i) $totalarray[
'nbfield']++;
372 if (!empty($arrayfields[
't.datep'][
'checked'])) {
373 print
'<td class="center">'.dol_print_date($db->jdate($obj->datep),
'day').
'</td>';
374 if (!$i) $totalarray[
'nbfield']++;
378 if (!empty($arrayfields[
't.fk_typepayment'][
'checked']))
380 print
'<td>'.$langs->trans(
"PaymentTypeShort".$obj->payment_code).
'</td>';
381 if (!$i) $totalarray[
'nbfield']++;
385 if (!empty($arrayfields[
't.num_payment'][
'checked'])) {
386 print
'<td>'.$obj->num_payment.
'</td>';
387 if (!$i) $totalarray[
'nbfield']++;
391 if (!empty($arrayfields[
'transaction'][
'checked'])) {
392 $bankline->fetch($obj->fk_bank);
393 print
'<td>'.$bankline->getNomUrl(1, 0).
'</td>';
394 if (!$i) $totalarray[
'nbfield']++;
398 if (!empty($arrayfields[
'ba.label'][
'checked'])) {
400 if ($obj->fk_bank > 0) {
401 $bankstatic->id = $obj->bid;
402 $bankstatic->ref = $obj->bref;
403 $bankstatic->number = $obj->bnumber;
404 $bankstatic->account_number = $obj->account_number;
406 $accountingjournal->fetch($obj->fk_accountancy_journal);
407 $bankstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
409 $bankstatic->label = $obj->blabel;
410 print $bankstatic->getNomUrl(1);
413 if (!$i) $totalarray[
'nbfield']++;
417 $total = $total + $obj->amount;
418 print
'<td class="nowrap right">'.price($obj->amount).
'</td>';
419 if (!$i) $totalarray[
'nbfield']++;
420 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'amount';
421 $totalarray[
'val'][
'amount'] += $objp->amount;
432 $totalarray[
'nbfield']++;
435 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
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.
Class to manage bank transaction lines.
Class to manage bank accounts.
Put here description of your class.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
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...
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_sort_array(&$array, $index, $order= 'asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
print
Draft customers invoices.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Class to manage accounting accounts.