--- /tmp/dsg/dolibarr/htdocs/compta/paiement/github_card.php +++ /tmp/dsg/dolibarr/htdocs/compta/paiement/client_card.php @@ -39,24 +39,16 @@ $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); -$object = new Paiement($db); - -// Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. - -$result = restrictedArea($user, $object->element, $object->id, 'paiement', ''); - // Security check if ($user->socid) $socid = $user->socid; -// Now check also permission on thirdparty of invoices of payments. Thirdparty were loaded by the fetch_object before based on first invoice. -// It should be enough because all payments are done on invoices of the same thirdparty. -if ($socid && $socid != $object->thirdparty->id) { - accessforbidden(); -} +// TODO ajouter regle pour restreindre acces paiement +//$result = restrictedArea($user, 'facture', $id,''); + +$object = new Paiement($db); /* @@ -65,48 +57,57 @@ if ($action == 'setnote' && $user->rights->facture->paiement) { + $db->begin(); + + $object->fetch($id); + $result = $object->update_note(GETPOST('note', 'none')); + if ($result > 0) + { + $db->commit(); + $action = ''; + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + $db->rollback(); + } +} + +if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture->paiement) +{ $db->begin(); - $result = $object->update_note(GETPOST('note', 'restricthtml')); - if ($result > 0) - { - $db->commit(); - $action = ''; - } else { - setEventMessages($object->error, $object->errors, 'errors'); - $db->rollback(); - } -} - -if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture->paiement) -{ - $db->begin(); - + $object->fetch($id); $result = $object->delete(); if ($result > 0) { - $db->commit(); - - if ($backtopage) - { - header("Location: ".$backtopage); - exit; - } else { - header("Location: list.php"); - exit; - } - } else { - $langs->load("errors"); + $db->commit(); + + if ($backtopage) + { + header("Location: ".$backtopage); + exit; + } + else + { + header("Location: list.php"); + exit; + } + } + else + { + $langs->load("errors"); setEventMessages($object->error, $object->errors, 'errors'); - $db->rollback(); - } -} - -if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->facture->paiement) + $db->rollback(); + } +} + +if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->facture->paiement) { $db->begin(); - if ($object->validate($user) > 0) + $object->fetch($id); + if ($object->valide($user) > 0) { $db->commit(); @@ -130,8 +131,10 @@ header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); exit; - } else { - $langs->load("errors"); + } + else + { + $langs->load("errors"); setEventMessages($object->error, $object->errors, 'errors'); $db->rollback(); } @@ -139,23 +142,29 @@ if ($action == 'setnum_paiement' && !empty($_POST['num_paiement'])) { - $res = $object->update_num($_POST['num_paiement']); + $object->fetch($id); + $res = $object->update_num($_POST['num_paiement']); if ($res === 0) { setEventMessages($langs->trans('PaymentNumberUpdateSucceeded'), null, 'mesgs'); - } else { + } + else + { setEventMessages($langs->trans('PaymentNumberUpdateFailed'), null, 'errors'); } } if ($action == 'setdatep' && !empty($_POST['datepday'])) { + $object->fetch($id); $datepaye = dol_mktime(GETPOST('datephour', 'int'), GETPOST('datepmin', 'int'), GETPOST('datepsec', 'int'), GETPOST('datepmonth', 'int'), GETPOST('datepday', 'int'), GETPOST('datepyear', 'int')); $res = $object->update_date($datepaye); if ($res === 0) { setEventMessages($langs->trans('PaymentDateUpdateSucceeded'), null, 'mesgs'); - } else { + } + else + { setEventMessages($langs->trans('PaymentDateUpdateFailed'), null, 'errors'); } } @@ -180,19 +189,19 @@ $head = payment_prepare_head($object); -print dol_get_fiche_head($head, 'payment', $langs->trans("PaymentCustomerInvoice"), -1, 'payment'); - -// Confirmation of payment delete +dol_fiche_head($head, 'payment', $langs->trans("PaymentCustomerInvoice"), -1, 'payment'); + +// Confirmation de la suppression du paiement if ($action == 'delete') { print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete', '', 0, 2); } -// Confirmation of payment validation +// Confirmation de la validation du paiement if ($action == 'valide') { $facid = $_GET['facid']; - print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_validate', '', 0, 2); + print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide', '', 0, 2); } $linkback = ''.$langs->trans("BackToList").''; @@ -268,8 +277,10 @@ // Bank account if (!empty($conf->banque->enabled)) { - if ($object->fk_account > 0) { - if ($object->type_code == 'CHQ' && $bankline->fk_bordereau > 0) { + if ($object->fk_account > 0) + { + if ($object->type_code == 'CHQ' && $bankline->fk_bordereau > 0) + { dol_include_once('/compta/paiement/cheque/class/remisecheque.class.php'); $bordereau = new RemiseCheque($db); $bordereau->fetch($bankline->fk_bordereau); @@ -286,12 +297,7 @@ print ''; print ''.$langs->trans('BankTransactionLine').''; print ''; - if ($object->fk_account > 0) { - print $bankline->getNomUrl(1, 0, 'showconciliatedandaccounted'); - } else { - $langs->load("admin"); - print ''.$langs->trans("NoRecordFoundIBankcAccount", $langs->transnoentitiesnoconv("Module85Name")).''; - } + print $bankline->getNomUrl(1, 0, 'showconciliatedandaccounted'); print ''; print ''; } @@ -305,14 +311,14 @@ print ''; -print dol_get_fiche_end(); +dol_fiche_end(); /* * List of invoices */ -$sql = 'SELECT f.rowid as facid, f.ref, f.type, f.total_ttc, f.paye, f.entity, f.fk_statut, pf.amount, s.nom as name, s.rowid as socid'; +$sql = 'SELECT f.rowid as facid, f.ref, f.type, f.total_ttc, f.paye, f.fk_statut, pf.amount, s.nom as name, s.rowid as socid'; $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf,'.MAIN_DB_PREFIX.'facture as f,'.MAIN_DB_PREFIX.'societe as s'; $sql .= ' WHERE pf.fk_facture = f.rowid'; $sql .= ' AND f.fk_soc = s.rowid'; @@ -338,9 +344,9 @@ print ''.$langs->trans('Company').''; if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED)) print ''.$langs->trans('Entity').''; print ''.$langs->trans('ExpectedToPay').''; - print ''.$langs->trans('PayedByThisPayment').''; - print ''.$langs->trans('RemainderToPay').''; - print ''.$langs->trans('Status').''; + print ''.$langs->trans('PayedByThisPayment').''; + print ''.$langs->trans('RemainderToPay').''; + print ''.$langs->trans('Status').''; print "\n"; if ($num > 0) @@ -362,7 +368,7 @@ print ''; - // Invoice + // Invoice print ''; print $invoice->getNomUrl(1); print "\n"; @@ -382,11 +388,11 @@ // Expected to pay print ''.price($objp->total_ttc).''; - // Amount payed - print ''.price($objp->amount).''; - - // Remain to pay - print ''.price($remaintopay).''; + // Amount payed + print ''.price($objp->amount).''; + + // Remain to pay + print ''.price($remaintopay).''; // Status print ''.$invoice->getLibStatut(5, $alreadypayed).''; @@ -407,14 +413,16 @@ print ''; $db->free($resql); -} else { +} +else +{ dol_print_error($db); } /* - * Actions Buttons + * Boutons Actions */ print '
'; @@ -437,7 +445,9 @@ if (!$disable_delete) { print ''.$langs->trans('Delete').''; - } else { + } + else + { print ''.$langs->trans('Delete').''; } } --- /tmp/dsg/dolibarr/htdocs/compta/paiement/github_info.php +++ /tmp/dsg/dolibarr/htdocs/compta/paiement/client_info.php @@ -33,25 +33,8 @@ $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); - -$object = new Paiement($db); - -// Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. - -$result = restrictedArea($user, $object->element, $object->id, 'paiement', ''); - -// Security check -if ($user->socid) $socid = $user->socid; -// Now check also permission on thirdparty of invoices of payments. Thirdparty were loaded by the fetch_object before based on first invoice. -// It should be enough because all payments are done on invoices of the same thirdparty. -if ($socid && $socid != $object->thirdparty->id) { - accessforbidden(); -} - - /* * Actions @@ -66,11 +49,13 @@ llxHeader('', $langs->trans("Payment")); +$object = new Paiement($db); +$object->fetch($id, $ref); $object->info($object->id); $head = payment_prepare_head($object); -print dol_get_fiche_head($head, 'info', $langs->trans("PaymentCustomerInvoice"), -1, 'payment'); +dol_fiche_head($head, 'info', $langs->trans("PaymentCustomerInvoice"), -1, 'payment'); $linkback = ''.$langs->trans("BackToList").''; @@ -89,7 +74,7 @@ print '
'; -print dol_get_fiche_end(); +dol_fiche_end(); // End of page llxFooter(); --- /tmp/dsg/dolibarr/htdocs/compta/paiement/github_list.php +++ /tmp/dsg/dolibarr/htdocs/compta/paiement/client_list.php @@ -1,14 +1,13 @@ - * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2013 Cédric Salvador - * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2015 Juanjo Menent - * Copyright (C) 2017 Alexandre Spangaro - * Copyright (C) 2018 Ferran Marcet - * Copyright (C) 2018 Charlene Benke - * Copyright (C) 2020 Tobias Sekan +/* Copyright (C) 2001-2006 Rodolphe Quiedeville + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2013 Cédric Salvador + * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2015 Juanjo Menent + * Copyright (C) 2017 Alexandre Spangaro + * Copyright (C) 2018 Ferran Marcet + * Copyright (C) 2018 Charlene Benke * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,11 +30,6 @@ */ require '../../main.inc.php'; - -// Security check -if ($user->socid) $socid = $user->socid; -$result = restrictedArea($user, 'facture', $facid, ''); - require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; @@ -45,169 +39,138 @@ // Load translation files required by the page $langs->loadLangs(array('bills', 'banks', 'compta', 'companies')); -$action = GETPOST('action', 'alpha'); -$massaction = GETPOST('massaction', 'alpha'); -$confirm = GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'paymentlist'; - -$facid = GETPOST('facid', 'int'); -$socid = GETPOST('socid', 'int'); + +$facid = GETPOST('facid', 'int'); +$socid = GETPOST('socid', 'int'); $userid = GETPOST('userid', 'int'); $day = GETPOST('day', 'int'); -$month = GETPOST('month', 'int'); +$month = GETPOST('month', 'int'); $year = GETPOST('year', 'int'); +// Security check +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'facture', $facid, ''); + +$paymentstatic = new Paiement($db); +$accountstatic = new Account($db); +$companystatic = new Societe($db); + $search_ref = GETPOST("search_ref", "alpha"); -$search_company = GETPOST("search_company", 'alpha'); -$search_paymenttype = GETPOST("search_paymenttype"); -$search_account = GETPOST("search_account", "int"); -$search_payment_num = GETPOST('search_payment_num', 'alpha'); +$search_account = GETPOST("search_account", "int"); +$search_paymenttype = GETPOST("search_paymenttype"); $search_amount = GETPOST("search_amount", 'alpha'); // alpha because we must be able to search on "< x" - -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$search_company = GETPOST("search_company", 'alpha'); +$search_payment_num = GETPOST('search_payment_num', 'alpha'); + +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); - -if (empty($page) || $page == -1) $page = 0; // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; - if (!$sortorder) $sortorder = "DESC"; -if (!$sortfield) $sortfield = "p.ref"; - -$search_all = trim(GETPOSTISSET("search_all") ? GETPOST("search_all", 'alpha') : GETPOST('sall')); - -// List of fields to search into when doing a "search in all" -$fieldstosearchall = array( - 'p.ref'=>"RefPayment", - 's.nom'=>"ThirdParty", - 'p.num_paiement'=>"Numero", - 'p.amount'=>"Amount", -); - -$arrayfields = array( - 'p.ref' => array('label'=>"RefPayment", 'checked'=>1, 'position'=>10), - 'p.datep' => array('label'=>"Date", 'checked'=>1, 'position'=>20), - 's.nom' => array('label'=>"ThirdParty", 'checked'=>1, 'position'=>30), - 'c.libelle' => array('label'=>"Type", 'checked'=>1, 'position'=>40), - 'transaction' => array('label'=>"BankTransactionLine", 'checked'=>1, 'position'=>50, 'enabled'=>(!empty($conf->banque->enabled))), - 'ba.label' => array('label'=>"Account", 'checked'=>1, 'position'=>60, 'enabled'=>(!empty($conf->banque->enabled))), - 'p.num_paiement' => array('label'=>"Numero", 'checked'=>1, 'position'=>70, 'tooltip'=>"ChequeOrTransferNumber"), - 'p.amount' => array('label'=>"Amount", 'checked'=>1, 'position'=>80), - 'p.statut' => array('label'=>"Status", 'checked'=>1, 'position'=>90, 'enabled'=>(!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))), -); -$arrayfields = dol_sort_array($arrayfields, 'position'); +if (!$sortfield) $sortfield = "p.rowid"; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('paymentlist')); -$object = new Paiement($db); +$extrafields = new ExtraFields($db); + +$arrayfields = array(); + /* * Actions */ -$parameters = array('socid'=>$socid); -$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - - -if (empty($reshook)) { - include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - - // All tests are required to be compatible with all browsers - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { - $search_ref = ''; - $search_account = ''; - $search_amount = ''; - $search_paymenttype = ''; - $search_payment_num = ''; - $search_company = ''; - $day = ''; - $year = ''; - $month = ''; - $option = ''; - $toselect = ''; - $search_array_options = array(); - } -} +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers +{ + $search_ref = ""; + $search_account = ""; + $search_amount = ""; + $search_paymenttype = ""; + $search_payment_num = ""; + $search_company = ""; + $day = ''; + $year = ''; + $month = ''; + $search_array_options = array(); +} + /* - * View + * View */ $form = new Form($db); $formother = new FormOther($db); -$accountstatic = new Account($db); -$companystatic = new Societe($db); -$bankline = new AccountLine($db); llxHeader('', $langs->trans('ListPayment')); -if (GETPOST("orphelins", "alpha")) { - // Payments not linked to an invoice. Should not happend. For debug only. - $sql = "SELECT p.rowid, p.ref, p.datep, p.amount, p.statut, p.num_paiement"; - $sql .= ", c.code as paiement_code"; - +if (GETPOST("orphelins", "alpha")) +{ + // Payments not linked to an invoice. Should not happend. For debug only. + $sql = "SELECT p.rowid, p.ref, p.datep as dp, p.amount,"; + $sql .= " p.statut, p.num_paiement as num_payment,"; + $sql .= " c.code as paiement_code"; // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; - $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement"; - $sql .= " WHERE p.entity IN (".getEntity('invoice').")"; - $sql .= " AND pf.fk_facture IS NULL"; - + $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement"; + $sql .= " WHERE p.entity IN (".getEntity('invoice').")"; + $sql .= " AND pf.fk_facture IS NULL"; // Add where from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -} else { - // DISTINCT is to avoid duplicate when there is a link to sales representatives - $sql = "SELECT DISTINCT p.rowid, p.ref, p.datep, p.fk_bank, p.amount, p.statut, p.num_paiement"; - $sql .= ", c.code as paiement_code"; - $sql .= ", ba.rowid as bid, ba.ref as bref, ba.label as blabel, ba.number, ba.account_number as account_number, ba.fk_accountancy_journal as accountancy_journal"; - $sql .= ", s.rowid as socid, s.nom as name, s.email"; - +} +else +{ + $sql = "SELECT DISTINCT p.rowid, p.ref, p.datep as dp, p.amount,"; // DISTINCT is to avoid duplicate when there is a link to sales representatives + $sql .= " p.statut, p.num_paiement as num_payment,"; + $sql .= " c.code as paiement_code,"; + $sql .= " ba.rowid as bid, ba.ref as bref, ba.label as blabel, ba.number, ba.account_number as account_number, ba.fk_accountancy_journal as accountancy_journal,"; + $sql .= " s.rowid as socid, s.nom as name, s.email"; // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; - $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON p.fk_bank = b.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON pf.fk_facture = f.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$socid) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; - } - $sql .= " WHERE p.entity IN (".getEntity('invoice').")"; - if (!$user->rights->societe->client->voir && !$socid) { - $sql .= " AND sc.fk_user = ".$user->id; - } - if ($socid > 0) { - $sql .= " AND f.fk_soc = ".$socid; - } - if ($userid) { - if ($userid == -1) $sql .= " AND f.fk_user_author IS NULL"; - else $sql .= " AND f.fk_user_author = ".$userid; - } - - // Search criteria - $sql .= dolSqlDateFilter("p.datep", $day, $month, $year); - if ($search_ref) $sql .= natural_search('p.ref', $search_ref); - if ($search_account > 0) $sql .= " AND b.fk_account=".$search_account; - if ($search_paymenttype != '') $sql .= " AND c.code='".$db->escape($search_paymenttype)."'"; - if ($search_payment_num != '') $sql .= natural_search('p.num_paiement', $search_payment_num); - if ($search_amount) $sql .= natural_search('p.amount', $search_amount, 1); - if ($search_company) $sql .= natural_search('s.nom', $search_company); - - if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); - + $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON p.fk_bank = b.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON pf.fk_facture = f.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid"; + if (!$user->rights->societe->client->voir && !$socid) + { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; + } + $sql .= " WHERE p.entity IN (".getEntity('invoice').")"; + if (!$user->rights->societe->client->voir && !$socid) + { + $sql .= " AND sc.fk_user = ".$user->id; + } + if ($socid > 0) $sql .= " AND f.fk_soc = ".$socid; + if ($userid) + { + if ($userid == -1) $sql .= " AND f.fk_user_author IS NULL"; + else $sql .= " AND f.fk_user_author = ".$userid; + } + // Search criteria + $sql .= dolSqlDateFilter("p.datep", $day, $month, $year); + if ($search_ref) $sql .= natural_search('p.ref', $search_ref); + if ($search_account > 0) $sql .= " AND b.fk_account=".$search_account; + if ($search_paymenttype != "") $sql .= " AND c.code='".$db->escape($search_paymenttype)."'"; + if ($search_payment_num != '') $sql .= natural_search('p.num_paiement', $search_payment_num); + if ($search_amount) $sql .= natural_search('p.amount', $search_amount, 1); + if ($search_company) $sql .= natural_search('s.nom', $search_company); // Add where from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook @@ -216,298 +179,210 @@ $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); - - // if total resultset is smaller then paging size (filtering), goto and load page 0 - if (($page * $limit) > $nbtotalofrecords) { + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { $page = 0; $offset = 0; } } $sql .= $db->plimit($limit + 1, $offset); +//print "$sql"; $resql = $db->query($sql); -if (!$resql) { - dol_print_error($db); - llxFooter(); - $db->close(); - exit; -} - -$num = $db->num_rows($resql); - -$param = ''; -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); -$param .= (GETPOST("orphelins") ? "&orphelins=1" : ''); -$param .= ($search_ref ? "&search_ref=".urlencode($search_ref) : ''); -$param .= ($search_company ? "&search_company=".urlencode($search_company) : ''); -$param .= ($search_amount ? "&search_amount=".urlencode($search_amount) : ''); -$param .= ($search_payment_num ? "&search_payment_num=".urlencode($search_payment_num) : ''); -if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); - -print '
'; -if ($optioncss != '') print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; - -print_barre_liste($langs->trans("ReceivedCustomersPayments"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit, 0, 0, 1); - -if ($search_all) -{ - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'; -} - -$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); - -print '
'; -print ''; - -print ''; - -// Filters: Lines (placeholder) -print ''; -if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { - print ''; + + $i++; + } + + // Show total line + include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; + + + print "
'; +if ($resql) +{ + $num = $db->num_rows($resql); + + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + $param .= (GETPOST("orphelins") ? "&orphelins=1" : ""); + $param .= ($search_ref ? "&search_ref=".urlencode($search_ref) : ""); + $param .= ($search_company ? "&search_company=".urlencode($search_company) : ""); + $param .= ($search_amount ? "&search_amount=".urlencode($search_amount) : ""); + $param .= ($search_payment_num ? "&search_payment_num=".urlencode($search_payment_num) : ""); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); + + print ''; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print_barre_liste($langs->trans("ReceivedCustomersPayments"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit, 0, 0, 1); + + print '
'; + print ''."\n"; + + // Lines for filters fields + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if (!empty($conf->banque->enabled)) + { + print ''; + } + print ''; -} - -// Filter: Ref -if (!empty($arrayfields['p.ref']['checked'])) { - print ''; -} - -// Filter: Date -if (!empty($arrayfields['p.datep']['checked'])) { - print ''; -} - -// Filter: Thirdparty -if (!empty($arrayfields['s.nom']['checked'])) { - print ''; -} - -// Filter: Payment type -if (!empty($arrayfields['c.libelle']['checked'])) { - print ''; -} - -// Filter: Bank transaction number -if (!empty($arrayfields['transaction']['checked'])) { - print ''; -} - -// Filter: Cheque number (fund transfer) -if (!empty($arrayfields['p.num_paiement']['checked'])) { - print ''; -} - -// Filter: Bank account -if (!empty($arrayfields['ba.label']['checked'])) { - print ''; -} - -// Filter: Amount -if (!empty($arrayfields['p.amount']['checked'])) { - print ''; -} - -// Filter: Status (only placeholder) -if (!empty($arrayfields['p.statut']['checked'])) { - print ''; -} - -// Fields from hook -$parameters = array('arrayfields'=>$arrayfields); -$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook -print $hookmanager->resPrint; - -print ''; - -print ""; - -print ''; -if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", '', $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['p.datep']['checked'])) print_liste_field_titre($arrayfields['p.datep']['label'], $_SERVER["PHP_SELF"], "p.datep", '', $param, '', $sortfield, $sortorder, 'center '); -if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", '', $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['c.libelle']['checked'])) print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], "c.libelle", '', $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['p.num_paiement']['checked'])) print_liste_field_titre($arrayfields['p.num_paiement']['label'], $_SERVER["PHP_SELF"], "p.num_paiement", '', $param, '', $sortfield, $sortorder, '', $arrayfields['p.num_paiement']['tooltip']); -if (!empty($arrayfields['transaction']['checked'])) print_liste_field_titre($arrayfields['transaction']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['ba.label']['checked'])) print_liste_field_titre($arrayfields['ba.label']['label'], $_SERVER["PHP_SELF"], "ba.label", '', $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['p.amount']['checked'])) print_liste_field_titre($arrayfields['p.amount']['label'], $_SERVER["PHP_SELF"], "p.amount", '', $param, 'class="right"', $sortfield, $sortorder); -if (!empty($arrayfields['p.statut']['checked'])) print_liste_field_titre($arrayfields['p.statut']['label'], $_SERVER["PHP_SELF"], "p.statut", '', $param, 'class="right"', $sortfield, $sortorder); - -// Hook fields -$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); -$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook -print $hookmanager->resPrint; - -print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); -print ""; - -$checkedCount = 0; -foreach ($arrayfields as $column) { - if ($column['checked']) { - $checkedCount++; - } -} - -$i = 0; -$totalarray = array(); -while ($i < min($num, $limit)) { - $objp = $db->fetch_object($resql); - - $object->id = $objp->rowid; - $object->ref = ($objp->ref ? $objp->ref : $objp->rowid); - - $companystatic->id = $objp->socid; - $companystatic->name = $objp->name; - $companystatic->email = $objp->email; - - print ''; - - // No - if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { - print ''; + print ''; + if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) + { + print ''; + } + print "\n"; + + print ''; + print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "p.rowid", "", $param, "", $sortfield, $sortorder); + print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "dp", "", $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder); + print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "c.libelle", "", $param, "", $sortfield, $sortorder); + print_liste_field_titre("Numero", $_SERVER["PHP_SELF"], "p.num_paiement", "", $param, "", $sortfield, $sortorder); + if (!empty($conf->banque->enabled)) + { + print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); + } + print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "p.amount", "", $param, 'class="right"', $sortfield, $sortorder); + //print_liste_field_titre("Invoices"),"","","",$param,'class="left"',$sortfield,$sortorder); + + $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "p.statut", "", $param, 'class="right"', $sortfield, $sortorder); + print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); + print "\n"; + + $i = 0; + $totalarray = array(); + while ($i < min($num, $limit)) + { + $objp = $db->fetch_object($resql); + + $paymentstatic->id = $objp->rowid; + $paymentstatic->ref = $objp->ref; + + $companystatic->id = $objp->socid; + $companystatic->name = $objp->name; + $companystatic->email = $objp->email; + + print ''; + + print ''; + if (!$i) $totalarray['nbfield']++; + + // Date + $dateformatforpayment = 'day'; + if (!empty($conf->global->INVOICE_USE_HOURS_FOR_PAYMENT)) $dateformatforpayment = 'dayhour'; + print ''; + if (!$i) $totalarray['nbfield']++; + + // Thirdparty + print ''; + if (!$i) $totalarray['nbfield']++; + + // Type + print ''; + if (!$i) $totalarray['nbfield']++; + + // Payment number + print ''; + if (!$i) $totalarray['nbfield']++; + + // Account + if (!empty($conf->banque->enabled)) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Amount + print ''; + if (!$i) $totalarray['nbfield']++; + $totalarray['pos'][7] = 'amount'; + $totalarray['val']['amount'] += $objp->amount; + + if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + + print ''; if (!$i) $totalarray['nbfield']++; - } - - // Ref - if (!empty($arrayfields['p.ref']['checked'])) { - print ''; - if (!$i) $totalarray['nbfield']++; - } - - // Date - if (!empty($arrayfields['p.datep']['checked'])) { - $dateformatforpayment = 'day'; - if (!empty($conf->global->INVOICE_USE_HOURS_FOR_PAYMENT)) $dateformatforpayment = 'dayhour'; - print ''; - if (!$i) $totalarray['nbfield']++; - } - - // Thirdparty - if (!empty($arrayfields['s.nom']['checked'])) { - print ''; - if (!$i) $totalarray['nbfield']++; - } - - // Payment type - if (!empty($arrayfields['c.libelle']['checked'])) { - print ''; - if (!$i) $totalarray['nbfield']++; - } - - // Filter: Cheque number (fund transfer) - if (!empty($arrayfields['p.num_paiement']['checked'])) { - print ''; - if (!$i) $totalarray['nbfield']++; - } - - // Bank transaction - if (!empty($arrayfields['transaction']['checked'])) { - $bankline->fetch($objp->fk_bank); - print ''; - if (!$i) $totalarray['nbfield']++; - } - - // Bank account - if (!empty($arrayfields['ba.label']['checked'])) { - print ''; - if (!$i) $totalarray['nbfield']++; - } - - // Amount - if (!empty($arrayfields['p.amount']['checked'])) { - print ''; - if (!$i) $totalarray['nbfield']++; - $totalarray['pos'][$checkedCount] = 'amount'; - $totalarray['val']['amount'] += $objp->amount; - } - - // Status - if (!empty($arrayfields['p.statut']['checked'])) { - print ''; - if (!$i) $totalarray['nbfield']++; - } - - // Buttons - print ''; - if (!$i) $totalarray['nbfield']++; - - print ''; - - $i++; -} - -// Show total line -include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; - -// If no record found -if ($num == 0) -{ - $colspan = 1; - foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } - print ''; -} - -print "
'; + print ''; + print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($year ? $year : -1, 'year', 1, 20, 5); + print ''; + print ''; + print ''; + $form->select_types_paiements($search_paymenttype, 'search_paymenttype', '', 2, 1, 1); + print ''; + print ''; + print ''; + $form->select_comptes($search_account, 'search_account', 0, '', 1); + print ''; + print ''; print ''; - print ''; - print ''; - if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; - $formother->select_year($year ? $year : -1, 'year', 1, 20, 5); - print ''; - print ''; - print ''; - $form->select_types_paiements($search_paymenttype, 'search_paymenttype', '', 2, 1, 1); - print ''; - print ''; - print ''; - print ''; - $form->select_comptes($search_account, 'search_account', 0, '', 1); - print ''; - print ''; - print ''; - print ''; -print $form->showFilterAndCheckAddButtons(0); -print '
'.(($offset * $limit) + $i).''; + $searchpicto = $form->showFilterAndCheckAddButtons(0); + print $searchpicto; + print ''; + print '
'; + print $paymentstatic->getNomUrl(1); + print ''.dol_print_date($db->jdate($objp->dp), $dateformatforpayment).''; + if ($objp->socid > 0) + { + print $companystatic->getNomUrl(1, '', 24); + } + print ''.$langs->trans("PaymentTypeShort".$objp->paiement_code).''.$objp->num_payment.''; + if ($objp->bid > 0) + { + $accountstatic->id = $objp->bid; + $accountstatic->ref = $objp->bref; + $accountstatic->label = $objp->blabel; + $accountstatic->number = $objp->number; + $accountstatic->account_number = $objp->account_number; + + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch($objp->accountancy_journal); + $accountstatic->accountancy_journal = $accountingjournal->code; + + print $accountstatic->getNomUrl(1); + } + print ''.price($objp->amount).''; + if ($objp->statut == 0) print ''; + print $paymentstatic->LibStatut($objp->statut, 5); + if ($objp->statut == 0) print ''; + print ''.$object->getNomUrl(1).''.dol_print_date($db->jdate($objp->datep), $dateformatforpayment).''; - if ($objp->socid > 0) { - print $companystatic->getNomUrl(1, '', 24); - } - print ''.$langs->trans("PaymentTypeShort".$objp->paiement_code).''.$objp->num_paiement.''.$bankline->getNomUrl(1, 0).''; - if ($objp->bid > 0) { - $accountstatic->id = $objp->bid; - $accountstatic->ref = $objp->bref; - $accountstatic->label = $objp->blabel; - $accountstatic->number = $objp->number; - $accountstatic->account_number = $objp->account_number; - - $accountingjournal = new AccountingJournal($db); - $accountingjournal->fetch($objp->accountancy_journal); - $accountstatic->accountancy_journal = $accountingjournal->code; - - print $accountstatic->getNomUrl(1); - } - print ''.price($objp->amount).''; - if ($objp->statut == 0) print ''; - print $object->LibStatut($objp->statut, 5); - if ($objp->statut == 0) print ''; - print '
'.$langs->trans("NoRecordFound").'
"; -print "
"; -print ""; + + print '
\n"; + print "
"; + print "\n"; +} +else +{ + dol_print_error($db); +} // End of page llxFooter(); --- /tmp/dsg/dolibarr/htdocs/compta/paiement/github_rapport.php +++ /tmp/dsg/dolibarr/htdocs/compta/paiement/client_rapport.php @@ -2,7 +2,6 @@ /* Copyright (C) 2003-2006 Rodolphe Quiedeville * Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2020 Maxime DEMAREST * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,16 +26,18 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/rapport/pdf_paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; + +// Security check +if (!$user->rights->facture->lire) accessforbidden(); $action = GETPOST('action', 'aZ09'); $socid = 0; if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; + $action = ''; + $socid = $user->socid; } $dir = $conf->facture->dir_output.'/payments'; @@ -45,9 +46,6 @@ $year = GETPOST('year', 'int'); if (!$year) { $year = date("Y"); } -// Security check -if (empty($user->rights->facture->lire)) accessforbidden(); - /* * Actions @@ -55,27 +53,29 @@ if ($action == 'builddoc') { - $rap = new pdf_paiement($db); + $rap = new pdf_paiement($db); - $outputlangs = $langs; - if (GETPOST('lang_id', 'aZ09')) - { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang(GETPOST('lang_id', 'aZ09')); - } + $outputlangs = $langs; + if (GETPOST('lang_id', 'aZ09')) + { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang(GETPOST('lang_id', 'aZ09')); + } - // We save charset_output to restore it because write_file can change it if needed for - // output format that does not support UTF8. - $sav_charset_output = $outputlangs->charset_output; - if ($rap->write_file($dir, $_POST["remonth"], $_POST["reyear"], $outputlangs) > 0) - { - $outputlangs->charset_output = $sav_charset_output; - } else { - $outputlangs->charset_output = $sav_charset_output; - dol_print_error($db, $obj->error); - } + // We save charset_output to restore it because write_file can change it if needed for + // output format that does not support UTF8. + $sav_charset_output = $outputlangs->charset_output; + if ($rap->write_file($dir, $_POST["remonth"], $_POST["reyear"], $outputlangs) > 0) + { + $outputlangs->charset_output = $sav_charset_output; + } + else + { + $outputlangs->charset_output = $sav_charset_output; + dol_print_error($db, $obj->error); + } - $year = $_POST["reyear"]; + $year = $_POST["reyear"]; } @@ -84,7 +84,6 @@ */ $formother = new FormOther($db); -$formfile = new FormFile($db); llxHeader(); @@ -113,59 +112,59 @@ $found = 0; if (is_dir($dir)) { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (is_dir($dir.'/'.$file) && !preg_match('/^\./', $file) && is_numeric($file)) - { - $found = 1; - $linkforyear[] = $file; - } - } - } + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (is_dir($dir.'/'.$file) && !preg_match('/^\./', $file) && is_numeric($file)) + { + $found = 1; + $linkforyear[] = $file; + } + } + } } asort($linkforyear); foreach ($linkforyear as $cursoryear) { - print ''.$cursoryear.'  '; + print ''.$cursoryear.'  '; } if ($year) { - if (is_dir($dir.'/'.$year)) - { - $handle = opendir($dir.'/'.$year); + if (is_dir($dir.'/'.$year)) + { + $handle = opendir($dir.'/'.$year); - if ($found) print '
'; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + if ($found) print '
'; + print '
'; + print '
'.$langs->trans("Reporting").''.$langs->trans("Size").''.$langs->trans("Date").'
'; + print ''; + print ''; + print ''; + print ''; + print ''; - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (preg_match('/^payment/i', $file)) - { - $tfile = $dir.'/'.$year.'/'.$file; - $relativepath = $year.'/'.$file; - print ''; - print ''; - print ''; - print ''; - print ''; - } - } - closedir($handle); - } - print '
'.$langs->trans("Reporting").''.$langs->trans("Size").''.$langs->trans("Date").'
'.img_pdf().' '.$file.''.$formfile->showPreview($file, 'facture_paiement', $relativepath, 0).''.dol_print_size(dol_filesize($tfile)).''.dol_print_date(dol_filemtime($tfile), "dayhour").'
'; - } + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (preg_match('/^payment/i', $file)) + { + $tfile = $dir.'/'.$year.'/'.$file; + $relativepath = $year.'/'.$file; + print ''; + print ''.img_pdf().' '.$file.''; + print ''.dol_print_size(dol_filesize($tfile)).''; + print ''.dol_print_date(dol_filemtime($tfile), "dayhour").''; + print ''; + } + } + closedir($handle); + } + print ''; + } } // End of page --- /tmp/dsg/dolibarr/htdocs/compta/paiement/github_tovalidate.php +++ /tmp/dsg/dolibarr/htdocs/compta/paiement/client_tovalidate.php @@ -27,17 +27,21 @@ // Load translation files required by the page $langs->load("bills"); +// Security check +if (!$user->rights->facture->lire) + accessforbidden(); + $socid = 0; if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; + $action = ''; + $socid = $user->socid; } $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; @@ -45,9 +49,6 @@ $pagenext = $page + 1; if (!$sortorder) $sortorder = "DESC"; if (!$sortfield) $sortfield = "p.rowid"; - -// Security check -if (empty($user->rights->facture->lire)) accessforbidden(); /* @@ -67,13 +68,13 @@ $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id"; if ($socid) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON pf.fk_facture = f.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON pf.fk_facture = f.rowid"; } $sql .= " WHERE p.entity IN (".getEntity('invoice').')'; if ($socid) { - $sql .= " AND f.fk_soc = ".$socid; + $sql .= " AND f.fk_soc = ".$socid; } $sql .= " AND p.statut = 0"; @@ -83,13 +84,13 @@ $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { - $page = 0; - $offset = 0; - } + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); @@ -97,43 +98,45 @@ $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); - $i = 0; + $num = $db->num_rows($resql); + $i = 0; - print_barre_liste($langs->trans("ReceivedCustomersPaymentsToValid"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num); + print_barre_liste($langs->trans("ReceivedCustomersPaymentsToValid"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num); - print ''; - print ''; - print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.rowid", "", "", 'width="60"', $sortfield, $sortorder); - print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "dp", "", "", 'width="80" align="center"', $sortfield, $sortorder); - print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "c.libelle", "", "", "", $sortfield, $sortorder); - print_liste_field_titre("AmountTTC", $_SERVER["PHP_SELF"], "c.libelle", "", "", 'class="right"', $sortfield, $sortorder); - print_liste_field_titre(''); - print "\n"; + print '
'; + print ''; + print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.rowid", "", "", 'width="60"', $sortfield, $sortorder); + print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "dp", "", "", 'width="80" align="center"', $sortfield, $sortorder); + print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "c.libelle", "", "", "", $sortfield, $sortorder); + print_liste_field_titre("AmountTTC", $_SERVER["PHP_SELF"], "c.libelle", "", "", 'class="right"', $sortfield, $sortorder); + print_liste_field_titre(''); + print "\n"; - while ($i < min($num, $limit)) - { - $objp = $db->fetch_object($resql); + while ($i < min($num, $limit)) + { + $objp = $db->fetch_object($resql); - print ''; - print ''; - print '\n"; - print "\n"; - print ''; - print ''; + print ''; + print '\n"; + print "\n"; + print ''; + print ''; - print ""; - $i++; - } - print "
'.img_object($langs->trans("ShowPayment"), "payment").' '.$objp->rowid.''.dol_print_date($db->jdate($objp->dp), 'day')."$objp->paiement_type $objp->num_payment'.price($objp->amount).''; + print '
'.img_object($langs->trans("ShowPayment"), "payment").' '.$objp->rowid.''.dol_print_date($db->jdate($objp->dp), 'day')."$objp->paiement_type $objp->num_payment'.price($objp->amount).''; - if ($objp->statut == 0) - { - print ''.$langs->trans("PaymentStatusToValidShort").''; - } else { - print "-"; - } + if ($objp->statut == 0) + { + print ''.$langs->trans("PaymentStatusToValidShort").''; + } + else + { + print "-"; + } - print '
"; + print ''; + print ""; + $i++; + } + print ""; } // End of page