--- /tmp/dsg/dolibarr/htdocs/compta/github_19.0.3_accounting-files.php +++ /tmp/dsg/dolibarr/htdocs/compta/client_accounting-files.php @@ -2,6 +2,4 @@ -/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org> - * Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net> - * Copyright (C) 2017 Pierre-Henry Favre <support@atm-consulting.fr> - * Copyright (C) 2020 Maxime DEMAREST <maxime@indelog.fr> - * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr> - * Copyright (C) 2022-2024 Alexandre Spangaro <aspangaro@easya.solutions> +/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org> + * Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net> + * Copyright (C) 2017 Pierre-Henry Favre <support@atm-consulting.fr> + * Copyright (C) 2020 Maxime DEMAREST <maxime@indelog.fr> @@ -23 +21 @@ -/** + /** @@ -30,6 +28,3 @@ - if (!defined('NOTOKENRENEWAL')) { - define('NOTOKENRENEWAL', '1'); - } -} - -// Load Dolibarr environment + if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); +} + @@ -39 +33,0 @@ -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -52,5 +45,0 @@ -if (isModEnabled('project')) { - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; -} - @@ -67 +56 @@ -$date_start = dol_mktime(0, 0, 0, $date_startMonth, $date_startDay, $date_startYear, 'tzuserrel'); +$date_start = ($date_startDay) ?dol_mktime(0, 0, 0, $date_startMonth, $date_startDay, $date_startYear) : strtotime($date_start); @@ -72,3 +61,3 @@ -$date_stop = dol_mktime(23, 59, 59, $date_stopMonth, $date_stopDay, $date_stopYear, 'tzuserrel'); -$action = GETPOST('action', 'aZ09'); -$projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : 0); +//FIXME doldate +$date_stop = ($date_stopDay) ?dol_mktime(23, 59, 59, $date_stopMonth, $date_stopDay, $date_stopYear) : strtotime($date_stop); +$action = GETPOST('action', 'alpha'); @@ -80,3 +69,3 @@ -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); @@ -84,3 +73 @@ -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 @@ -90,6 +77,2 @@ -if (!$sortfield) { - $sortfield = "date,item"; // Set here default search field -} -if (!$sortorder) { - $sortorder = "DESC"; -} +if (!$sortfield) $sortfield = "date,item"; // Set here default search field +if (!$sortorder) $sortorder = "DESC"; @@ -99,2 +82,2 @@ - 'type'=>array('label'=>"Type", 'checked'=>1), - 'date'=>array('label'=>"Date", 'checked'=>1), + 'type'=>array('label'=>"Type", 'checked'=>1), + 'date'=>array('label'=>"Date", 'checked'=>1), @@ -112,2 +95,2 @@ -if (!isModEnabled('comptabilite') && !isModEnabled('accounting')) { - accessforbidden(); +if (empty($conf->comptabilite->enabled) && empty($conf->accounting->enabled)) { + accessforbidden(); @@ -116 +99 @@ - accessforbidden(); + accessforbidden(); @@ -121 +104 @@ -if (isModEnabled('multicompany') && is_object($mc)) { +if (!empty($conf->multicompany->enabled) && is_object($mc)) { @@ -126,2 +109,2 @@ -if (isModEnabled('multicompany') && is_object($mc)) { - if (empty($entity) && getDolGlobalString('MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES')) { +if (!empty($conf->multicompany->enabled) && is_object($mc)) { + if (empty($entity) && !empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES)) { @@ -131,3 +114 @@ -if (empty($entity)) { - $entity = $conf->entity; -} +if (empty($entity)) $entity = $conf->entity; @@ -136,11 +116,0 @@ - -$listofchoices = array( - 'selectinvoices'=>array('label'=>'Invoices', 'picto'=>'bill', 'lang'=>'bills', 'enabled' => isModEnabled('facture'), 'perms' => $user->hasRight('facture', 'lire')), - 'selectsupplierinvoices'=>array('label'=>'BillsSuppliers', 'picto'=>'supplier_invoice', 'lang'=>'bills', 'enabled' => isModEnabled('supplier_invoice'), 'perms' => !empty($user->rights->fournisseur->facture->lire)), - 'selectexpensereports'=>array('label'=>'ExpenseReports', 'picto'=>'expensereport', 'lang'=>'trips', 'enabled' => isModEnabled('expensereport'), 'perms' => !empty($user->rights->expensereport->lire)), - 'selectdonations'=>array('label'=>'Donations', 'picto'=>'donation', 'lang'=>'donation', 'enabled' => isModEnabled('don'), 'perms' => !empty($user->rights->don->lire)), - 'selectsocialcontributions'=>array('label'=>'SocialContributions', 'picto'=>'bill', 'enabled' => isModEnabled('tax'), 'perms' => !empty($user->rights->tax->charges->lire)), - 'selectpaymentsofsalaries'=>array('label'=>'SalariesPayments', 'picto'=>'salary', 'lang'=>'salaries', 'enabled' => isModEnabled('salaries'), 'perms' => !empty($user->rights->salaries->read)), - 'selectvariouspayment'=>array('label'=>'VariousPayment', 'picto'=>'payment', 'enabled' => isModEnabled('banque'), 'perms' => !empty($user->rights->banque->lire)), - 'selectloanspayment'=>array('label'=>'PaymentLoan','picto'=>'loan', 'enabled' => isModEnabled('don'), 'perms' => !empty($user->rights->loan->read)), -); @@ -162 +132,2 @@ - if (empty($date_start)) { + if (empty($date_start)) + { @@ -166 +137,2 @@ - if (empty($date_stop)) { + if (empty($date_stop)) + { @@ -171 +143,2 @@ - if (!$error) { + if (!$error) + { @@ -177,118 +150,68 @@ - if (GETPOST('selectinvoices') && !empty($listofchoices['selectinvoices']['perms'])) { - if (!empty($sql)) { - $sql .= " UNION ALL"; - } - $sql .= "SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total_ht, t.total_ttc, t.total_tva as total_vat,"; - $sql .= " t.localtax1, t.localtax2, t.revenuestamp,"; - $sql .= " t.multicurrency_code as currency, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'Invoice' as item, s.nom as thirdparty_name, s.code_client as thirdparty_code, c.code as country_code, s.tva_intra as vatnum, ".PAY_CREDIT." as sens"; - $sql .= " FROM ".MAIN_DB_PREFIX."facture as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; - $sql .= " WHERE datef between ".$wheretail; - $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')'; - $sql .= " AND t.fk_statut <> ".Facture::STATUS_DRAFT; - if (!empty($projectid)) { - $sql .= " AND fk_projet = ".((int) $projectid); - } - } - // Vendor invoices - if (GETPOST('selectsupplierinvoices') && !empty($listofchoices['selectsupplierinvoices']['perms'])) { - if (!empty($sql)) { - $sql .= " UNION ALL"; - } - $sql .= " SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total_ht, t.total_ttc, t.total_tva as total_vat,"; - $sql .= " t.localtax1, t.localtax2, 0 as revenuestamp,"; - $sql .= " t.multicurrency_code as currency, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'SupplierInvoice' as item, s.nom as thirdparty_name, s.code_fournisseur as thirdparty_code, c.code as country_code, s.tva_intra as vatnum, ".PAY_DEBIT." as sens"; - $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; - $sql .= " WHERE datef between ".$wheretail; - $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')'; - $sql .= " AND t.fk_statut <> ".FactureFournisseur::STATUS_DRAFT; - if (!empty($projectid)) { - $sql .= " AND fk_projet = ".((int) $projectid); - } - } - // Expense reports - if (GETPOST('selectexpensereports') && !empty($listofchoices['selectexpensereports']['perms']) && empty($projectid)) { - if (!empty($sql)) { - $sql .= " UNION ALL"; - } - $sql .= " SELECT t.rowid as id, t.entity, t.ref, t.paid, t.total_ht, t.total_ttc, t.total_tva as total_vat,"; - $sql .= " 0 as localtax1, 0 as localtax2, 0 as revenuestamp,"; - $sql .= " t.multicurrency_code as currency, t.fk_user_author as fk_soc, t.date_fin as date, t.date_fin as date_due, 'ExpenseReport' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_DEBIT." as sens"; - $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user_author LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; - $sql .= " WHERE date_fin between ".$wheretail; - $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')'; - $sql .= " AND t.fk_statut <> ".ExpenseReport::STATUS_DRAFT; - } - // Donations - if (GETPOST('selectdonations') && !empty($listofchoices['selectdonations']['perms'])) { - if (!empty($sql)) { - $sql .= " UNION ALL"; - } - $sql .= " SELECT t.rowid as id, t.entity, t.ref, paid, amount as total_ht, amount as total_ttc, 0 as total_vat,"; - $sql .= " 0 as localtax1, 0 as localtax2, 0 as revenuestamp,"; - $sql .= " '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.datedon as date, t.datedon as date_due, 'Donation' as item, t.societe as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_CREDIT." as sens"; - $sql .= " FROM ".MAIN_DB_PREFIX."don as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = t.fk_country"; - $sql .= " WHERE datedon between ".$wheretail; - $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')'; - $sql .= " AND t.fk_statut <> ".Don::STATUS_DRAFT; - if (!empty($projectid)) { - $sql .= " AND fk_projet = ".((int) $projectid); - } - } - // Payments of salaries - if (GETPOST('selectpaymentsofsalaries') && !empty($listofchoices['selectpaymentsofsalaries']['perms'])) { - if (!empty($sql)) { - $sql .= " UNION ALL"; - } - $sql .= " SELECT t.rowid as id, t.entity, t.label as ref, 1 as paid, amount as total_ht, amount as total_ttc, 0 as total_vat,"; - $sql .= " 0 as localtax1, 0 as localtax2, 0 as revenuestamp,"; - $sql .= " '".$db->escape($conf->currency)."' as currency, t.fk_user as fk_soc, t.datep as date, t.dateep as date_due, 'SalaryPayment' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_DEBIT." as sens"; - $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; - $sql .= " WHERE datep between ".$wheretail; - $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')'; - //$sql.=" AND fk_statut <> ".PaymentSalary::STATUS_DRAFT; - if (!empty($projectid)) { - $sql .= " AND fk_projet = ".((int) $projectid); - } - } - // Social contributions - if (GETPOST('selectsocialcontributions') && !empty($listofchoices['selectsocialcontributions']['perms'])) { - if (!empty($sql)) { - $sql .= " UNION ALL"; - } - $sql .= " SELECT t.rowid as id, t.entity, t.libelle as ref, t.paye as paid, t.amount as total_ht, t.amount as total_ttc, 0 as total_vat,"; - $sql .= " 0 as localtax1, 0 as localtax2, 0 as revenuestamp,"; - $sql .= " '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.date_ech as date, t.periode as date_due, 'SocialContributions' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, ".PAY_DEBIT." as sens"; - $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as t"; - $sql .= " WHERE t.date_ech between ".$wheretail; - $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')'; - //$sql.=" AND fk_statut <> ".ChargeSociales::STATUS_DRAFT; - if (!empty($projectid)) { - $sql .= " AND fk_projet = ".((int) $projectid); - } - } - // Various payments - if (GETPOST('selectvariouspayment') && !empty($listofchoices['selectvariouspayment']['perms'])) { - if (!empty($sql)) { - $sql .= " UNION ALL"; - } - $sql .= " SELECT t.rowid as id, t.entity, t.ref, 1 as paid, t.amount as total_ht, t.amount as total_ttc, 0 as total_vat,"; - $sql .= " 0 as localtax1, 0 as localtax2, 0 as revenuestamp,"; - $sql .= " '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.datep as date, t.datep as date_due, 'VariousPayment' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, sens"; - $sql .= " FROM ".MAIN_DB_PREFIX."payment_various as t"; - $sql .= " WHERE datep between ".$wheretail; - $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')'; - if (!empty($projectid)) { - $sql .= " AND fk_projet = ".((int) $projectid); - } - } - // Loan payments - if (GETPOST('selectloanspayment') && !empty($listofchoices['selectloanspayment']['perms']) && empty($projectid)) { - if (!empty($sql)) { - $sql .= " UNION ALL"; - } - $sql .= " SELECT t.rowid as id, l.entity, l.label as ref, 1 as paid, (t.amount_capital+t.amount_insurance+t.amount_interest) as total_ht, (t.amount_capital+t.amount_insurance+t.amount_interest) as total_ttc, 0 as total_vat,"; - $sql .= " 0 as localtax1, 0 as localtax2, 0 as revenuestamp,"; - $sql .= " '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.datep as date, t.datep as date_due, 'LoanPayment' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, ".PAY_DEBIT." as sens"; - $sql .= " FROM ".MAIN_DB_PREFIX."payment_loan as t LEFT JOIN ".MAIN_DB_PREFIX."loan as l ON l.rowid = t.fk_loan"; - $sql .= " WHERE datep between ".$wheretail; - $sql .= " AND l.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')'; + if (GETPOST('selectinvoices')) { + if (!empty($sql)) $sql .= " UNION ALL"; + $sql .= "SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total as total_ht, t.total_ttc, t.tva as total_vat, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'Invoice' as item, s.nom as thirdparty_name, s.code_client as thirdparty_code, c.code as country_code, s.tva_intra as vatnum, ".PAY_CREDIT." as sens"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; + $sql .= " WHERE datef between ".$wheretail; + $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; + $sql .= " AND t.fk_statut <> ".Facture::STATUS_DRAFT; + } + // Vendor invoices + if (GETPOST('selectsupplierinvoices')) { + if (!empty($sql)) $sql .= " UNION ALL"; + $sql .= " SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total_ht, t.total_ttc, t.total_tva as total_vat, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'SupplierInvoice' as item, s.nom as thirdparty_name, s.code_fournisseur as thirdparty_code, c.code as country_code, s.tva_intra as vatnum, ".PAY_DEBIT." as sens"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; + $sql .= " WHERE datef between ".$wheretail; + $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; + $sql .= " AND t.fk_statut <> ".FactureFournisseur::STATUS_DRAFT; + } + // Expense reports + if (GETPOST('selectexpensereports')) { + if (!empty($sql)) $sql .= " UNION ALL"; + $sql .= " SELECT t.rowid as id, t.entity, t.ref, t.paid, t.total_ht, t.total_ttc, t.total_tva as total_vat, t.fk_user_author as fk_soc, t.date_fin as date, t.date_fin as date_due, 'ExpenseReport' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_DEBIT." as sens"; + $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user_author LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; + $sql .= " WHERE date_fin between ".$wheretail; + $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; + $sql .= " AND t.fk_statut <> ".ExpenseReport::STATUS_DRAFT; + } + // Donations + if (GETPOST('selectdonations')) { + if (!empty($sql)) $sql .= " UNION ALL"; + $sql .= " SELECT t.rowid as id, t.entity, t.ref, paid, amount as total_ht, amount as total_ttc, 0 as total_vat, 0 as fk_soc, t.datedon as date, t.datedon as date_due, 'Donation' as item, t.societe as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_CREDIT." as sens"; + $sql .= " FROM ".MAIN_DB_PREFIX."don as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = t.fk_country"; + $sql .= " WHERE datedon between ".$wheretail; + $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; + $sql .= " AND t.fk_statut <> ".Don::STATUS_DRAFT; + } + // Paiements of salaries + if (GETPOST('selectpaymentsofsalaries')) { + if (!empty($sql)) $sql .= " UNION ALL"; + $sql .= " SELECT t.rowid as id, t.entity, t.label as ref, 1 as paid, amount as total_ht, amount as total_ttc, 0 as total_vat, t.fk_user as fk_soc, t.datep as date, t.dateep as date_due, 'SalaryPayment' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_DEBIT." as sens"; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; + $sql .= " WHERE datep between ".$wheretail; + $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; + //$sql.=" AND fk_statut <> ".PaymentSalary::STATUS_DRAFT; + } + // Social contributions + if (GETPOST('selectsocialcontributions')) { + if (!empty($sql)) $sql .= " UNION ALL"; + $sql .= " SELECT t.rowid as id, t.entity, t.libelle as ref, t.paye as paid, t.amount as total_ht, t.amount as total_ttc, 0 as total_tva, 0 as fk_soc, t.date_ech as date, t.periode as date_due, 'SocialContributions' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, ".PAY_DEBIT." as sens"; + $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as t"; + $sql .= " WHERE t.date_ech between ".$wheretail; + $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; + //$sql.=" AND fk_statut <> ".ChargeSociales::STATUS_DRAFT; + } + // Various payments + if (GETPOST('selectvariouspayment')) { + if (!empty($sql)) $sql .= " UNION ALL"; + $sql .= " SELECT t.rowid as id, t.entity, t.label as ref, 1 as paid, t.amount as total_ht, t.amount as total_ttc, 0 as total_tva, 0 as fk_soc, t.datep as date, t.datep as date_due, 'VariousPayment' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, sens"; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_various as t"; + $sql .= " WHERE datep between ".$wheretail; + $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; + } + // Loan payments + if (GETPOST('selectloanspayment')) { + if (!empty($sql)) $sql .= " UNION ALL"; + $sql .= " SELECT t.rowid as id, l.entity, l.label as ref, 1 as paid, (t.amount_capital+t.amount_insurance+t.amount_interest) as total_ht, (t.amount_capital+t.amount_insurance+t.amount_interest) as total_ttc, 0 as total_tva, 0 as fk_soc, t.datep as date, t.datep as date_due, 'LoanPayment' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, ".PAY_DEBIT." as sens"; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_loan as t LEFT JOIN ".MAIN_DB_PREFIX."loan as l ON l.rowid = t.fk_loan"; + $sql .= " WHERE datep between ".$wheretail; + $sql .= " AND l.entity IN (".($entity == 1 ? '0,1' : $entity).')'; @@ -298 +221 @@ - $sql .= $db->order($sortfield, $sortorder); + $sql .= $db->order($sortfield, $sortorder); @@ -301,171 +224,171 @@ - $resd = $db->query($sql); - $files = array(); - $link = ''; - - if ($resd) { - $numd = $db->num_rows($resd); - - $tmpinvoice = new Facture($db); - $tmpinvoicesupplier = new FactureFournisseur($db); - $tmpdonation = new Don($db); - - $upload_dir = ''; - $i = 0; - while ($i < $numd) { - $objd = $db->fetch_object($resd); - - switch ($objd->item) { - case "Invoice": - $subdir = ''; - $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref); - $upload_dir = $conf->facture->dir_output.'/'.$subdir; - $link = "document.php?modulepart=facture&file=".str_replace('/', '%2F', $subdir).'%2F'; - $modulepart = "facture"; - break; - case "SupplierInvoice": - $tmpinvoicesupplier->fetch($objd->id); - $subdir = get_exdir($tmpinvoicesupplier->id, 2, 0, 1, $tmpinvoicesupplier, 'invoice_supplier'); // TODO Use first file - $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref); - $upload_dir = $conf->fournisseur->facture->dir_output.'/'.$subdir; - $link = "document.php?modulepart=facture_fournisseur&file=".str_replace('/', '%2F', $subdir).'%2F'; - $modulepart = "facture_fournisseur"; - break; - case "ExpenseReport": - $subdir = ''; - $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref); - $upload_dir = $conf->expensereport->dir_output.'/'.$subdir; - $link = "document.php?modulepart=expensereport&file=".str_replace('/', '%2F', $subdir).'%2F'; - $modulepart = "expensereport"; - break; - case "SalaryPayment": - $subdir = ''; - $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id); - $upload_dir = $conf->salaries->dir_output.'/'.$subdir; - $link = "document.php?modulepart=salaries&file=".str_replace('/', '%2F', $subdir).'%2F'; - $modulepart = "salaries"; - break; - case "Donation": - $tmpdonation->fetch($objp->id); - $subdir = get_exdir(0, 0, 0, 0, $tmpdonation, 'donation'); - $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id); - $upload_dir = $conf->don->dir_output.'/'.$subdir; - $link = "document.php?modulepart=don&file=".str_replace('/', '%2F', $subdir).'%2F'; - $modulepart = "don"; - break; - case "SocialContributions": - $subdir = ''; - $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id); - $upload_dir = $conf->tax->dir_output.'/'.$subdir; - $link = "document.php?modulepart=tax&file=".str_replace('/', '%2F', $subdir).'%2F'; - $modulepart = "tax"; - break; - case "VariousPayment": - $subdir = ''; - $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id); - $upload_dir = $conf->bank->dir_output.'/'.$subdir; - $link = "document.php?modulepart=banque&file=".str_replace('/', '%2F', $subdir).'%2F'; - $modulepart = "banque"; - break; - case "LoanPayment": - // Loan payment has no linked file - $subdir = ''; - $upload_dir = $conf->loan->dir_output.'/'.$subdir; - $link = ""; - $modulepart = ""; - break; - default: - $subdir = ''; - $upload_dir = ''; - $link = ''; - break; - } - - if (!empty($upload_dir)) { - $result = true; - - $files = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', '', SORT_ASC, 1); - //var_dump($upload_dir); - //var_dump($files); - if (count($files) < 1) { - $nofile = array(); - $nofile['id'] = $objd->id; - $nofile['entity'] = $objd->entity; - $nofile['date'] = $db->jdate($objd->date); - $nofile['date_due'] = $db->jdate($objd->date_due); - $nofile['paid'] = $objd->paid; - $nofile['amount_ht'] = $objd->total_ht; - $nofile['amount_ttc'] = $objd->total_ttc; - $nofile['amount_vat'] = $objd->total_vat; - $nofile['amount_localtax1'] = $objd->localtax1; - $nofile['amount_localtax2'] = $objd->localtax2; - $nofile['amount_revenuestamp'] = $objd->revenuestamp; - $nofile['ref'] = ($objd->ref ? $objd->ref : $objd->id); - $nofile['fk'] = $objd->fk_soc; - $nofile['item'] = $objd->item; - $nofile['thirdparty_name'] = $objd->thirdparty_name; - $nofile['thirdparty_code'] = $objd->thirdparty_code; - $nofile['country_code'] = $objd->country_code; - $nofile['vatnum'] = $objd->vatnum; - $nofile['sens'] = $objd->sens; - $nofile['currency'] = $objd->currency; - $nofile['link'] = ''; - $nofile['name'] = ''; - - $filesarray[$nofile['item'].'_'.$nofile['id']] = $nofile; - } else { - foreach ($files as $key => $file) { - $file['id'] = $objd->id; - $file['entity'] = $objd->entity; - $file['date'] = $db->jdate($objd->date); - $file['date_due'] = $db->jdate($objd->date_due); - $file['paid'] = $objd->paid; - $file['amount_ht'] = $objd->total_ht; - $file['amount_ttc'] = $objd->total_ttc; - $file['amount_vat'] = $objd->total_vat; - $file['amount_localtax1'] = $objd->localtax1; - $file['amount_localtax2'] = $objd->localtax2; - $file['amount_revenuestamp'] = $objd->revenuestamp; - $file['ref'] = ($objd->ref ? $objd->ref : $objd->id); - $file['fk'] = $objd->fk_soc; - $file['item'] = $objd->item; - $file['thirdparty_name'] = $objd->thirdparty_name; - $file['thirdparty_code'] = $objd->thirdparty_code; - $file['country_code'] = $objd->country_code; - $file['vatnum'] = $objd->vatnum; - $file['sens'] = $objd->sens; - $file['currency'] = $objd->currency; - - // Save record into array (only the first time it is found) - if (empty($filesarray[$file['item'].'_'.$file['id']])) { - $filesarray[$file['item'].'_'.$file['id']] = $file; - } - - // Add or concat file - if (empty($filesarray[$file['item'].'_'.$file['id']]['files'])) { - $filesarray[$file['item'].'_'.$file['id']]['files'] = array(); - } - $filesarray[$file['item'].'_'.$file['id']]['files'][] = array( - 'link' => $link.urlencode($file['name']), - 'name'=>$file['name'], - 'ref'=>$file['ref'], - 'fullname' => $file['fullname'], - 'relpath' => '/'.$file['name'], - 'relpathnamelang' => $langs->trans($file['item']).'/'.$file['name'], - 'modulepart' => $modulepart, - 'subdir' => $subdir, - 'currency' => $file['currency'] - ); - //var_dump($file['item'].'_'.$file['id']); - //var_dump($filesarray[$file['item'].'_'.$file['id']]['files']); - } - } - } - - $i++; - } - } else { - dol_print_error($db); - } - - $db->free($resd); - } else { + $resd = $db->query($sql); + $files = array(); + $link = ''; + + if ($resd) + { + $numd = $db->num_rows($resd); + + $tmpinvoice = new Facture($db); + $tmpinvoicesupplier = new FactureFournisseur($db); + $tmpdonation = new Don($db); + + $upload_dir = ''; + $i = 0; + while ($i < $numd) + { + $objd = $db->fetch_object($resd); + + switch ($objd->item) + { + case "Invoice": + $subdir = ''; + $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref); + $upload_dir = $conf->facture->dir_output.'/'.$subdir; + $link = "document.php?modulepart=facture&file=".str_replace('/', '%2F', $subdir).'%2F'; + $modulepart = "facture"; + break; + case "SupplierInvoice": + $tmpinvoicesupplier->fetch($objd->id); + $subdir = get_exdir($tmpinvoicesupplier->id, 2, 0, 1, $tmpinvoicesupplier, 'invoice_supplier'); // TODO Use first file + $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref); + $upload_dir = $conf->fournisseur->facture->dir_output.'/'.$subdir; + $link = "document.php?modulepart=facture_fournisseur&file=".str_replace('/', '%2F', $subdir).'%2F'; + $modulepart = "facture_fournisseur"; + break; + case "ExpenseReport": + $subdir = ''; + $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref); + $upload_dir = $conf->expensereport->dir_output.'/'.$subdir; + $link = "document.php?modulepart=expensereport&file=".str_replace('/', '%2F', $subdir).'%2F'; + $modulepart = "expensereport"; + break; + case "SalaryPayment": + $subdir = ''; + $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id); + $upload_dir = $conf->salaries->dir_output.'/'.$subdir; + $link = "document.php?modulepart=salaries&file=".str_replace('/', '%2F', $subdir).'%2F'; + $modulepart = "salaries"; + break; + case "Donation": + $tmpdonation->fetch($objp->id); + $subdir = get_exdir(0, 0, 0, 0, $tmpdonation, 'donation'); + $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id); + $upload_dir = $conf->don->dir_output.'/'.$subdir; + $link = "document.php?modulepart=don&file=".str_replace('/', '%2F', $subdir).'%2F'; + $modulepart = "don"; + break; + case "SocialContributions": + $subdir = ''; + $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id); + $upload_dir = $conf->tax->dir_output.'/'.$subdir; + $link = "document.php?modulepart=tax&file=".str_replace('/', '%2F', $subdir).'%2F'; + $modulepart = "tax"; + break; + case "VariousPayment": + $subdir = ''; + $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id); + $upload_dir = $conf->bank->dir_output.'/'.$subdir; + $link = "document.php?modulepart=banque&file=".str_replace('/', '%2F', $subdir).'%2F'; + $modulepart = "banque"; + break; + case "LoanPayment": + // Loan payment has no linked file + $subdir = ''; + $upload_dir = $conf->loan->dir_output.'/'.$subdir; + $link = ""; + $modulepart = ""; + break; + default: + $subdir = ''; + $upload_dir = ''; + $link = ''; + break; + } + + if (!empty($upload_dir)) + { + $result = true; + + $files = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', '', SORT_ASC, 1); + //var_dump($upload_dir); + //var_dump($files); + if (count($files) < 1) + { + $nofile = array(); + $nofile['id'] = $objd->id; + $nofile['entity'] = $objd->entity; + $nofile['date'] = $db->idate($objd->date); + $nofile['date_due'] = $db->idate($objd->date_due); + $nofile['paid'] = $objd->paid; + $nofile['amount_ht'] = $objd->total_ht; + $nofile['amount_ttc'] = $objd->total_ttc; + $nofile['amount_vat'] = $objd->total_vat; + $nofile['ref'] = ($objd->ref ? $objd->ref : $objd->id); + $nofile['fk'] = $objd->fk_soc; + $nofile['item'] = $objd->item; + $nofile['thirdparty_name'] = $objd->thirdparty_name; + $nofile['thirdparty_code'] = $objd->thirdparty_code; + $nofile['country_code'] = $objd->country_code; + $nofile['vatnum'] = $objd->vatnum; + $nofile['sens'] = $objd->sens; + + $filesarray[$nofile['item'].'_'.$nofile['id']] = $nofile; + } + else + { + foreach ($files as $key => $file) + { + $file['id'] = $objd->id; + $file['entity'] = $objd->entity; + $file['date'] = $db->idate($objd->date); + $file['date_due'] = $db->idate($objd->date_due); + $file['paid'] = $objd->paid; + $file['amount_ht'] = $objd->total_ht; + $file['amount_ttc'] = $objd->total_ttc; + $file['amount_vat'] = $objd->total_vat; + $file['ref'] = ($objd->ref ? $objd->ref : $objd->id); + $file['fk'] = $objd->fk_soc; + $file['item'] = $objd->item; + $file['thirdparty_name'] = $objd->thirdparty_name; + $file['thirdparty_code'] = $objd->thirdparty_code; + $file['country_code'] = $objd->country_code; + $file['vatnum'] = $objd->vatnum; + $file['sens'] = $objd->sens; + + // Save record into array (only the first time it is found) + if (empty($filesarray[$file['item'].'_'.$file['id']])) { + $filesarray[$file['item'].'_'.$file['id']] = $file; + } + + // Add or concat file + if (empty($filesarray[$file['item'].'_'.$file['id']]['files'])) { + $filesarray[$file['item'].'_'.$file['id']]['files'] = array(); + } + $filesarray[$file['item'].'_'.$file['id']]['files'][] = array( + 'link' => $link.urlencode($file['name']), + 'name'=>$file['name'], + 'ref'=>$file['ref'], + 'fullname' => $file['fullname'], + 'relpath' => '/'.$file['name'], + 'relpathnamelang' => $langs->trans($file['item']).'/'.$file['name'], + 'modulepart' => $modulepart, + 'subdir' => $subdir, + ); + //var_dump($file['item'].'_'.$file['id']); + //var_dump($filesarray[$file['item'].'_'.$file['id']]['files']); + } + } + } + + $i++; + } + } + else + { + dol_print_error($db); + } + + $db->free($resd); + } + else { @@ -483,2 +406,3 @@ -$dirfortmpfile = (!empty($conf->accounting->dir_temp) ? $conf->accounting->dir_temp : $conf->comptabilite->dir_temp); -if (empty($dirfortmpfile)) { +$dirfortmpfile = ($conf->accounting->dir_temp ? $conf->accounting->dir_temp : $conf->comptabilite->dir_temp); +if (empty($dirfortmpfile)) +{ @@ -490,2 +414,4 @@ -if ($result && $action == "dl" && !$error) { - if (!extension_loaded('zip')) { +if ($result && $action == "dl" && !$error) +{ + if (!extension_loaded('zip')) + { @@ -493,86 +419 @@ - } else { - dol_mkdir($dirfortmpfile); - - $log = $langs->transnoentitiesnoconv("Type"); - if (isModEnabled('multicompany') && is_object($mc)) { - $log .= ','.$langs->transnoentitiesnoconv("Entity"); - } - $log .= ','.$langs->transnoentitiesnoconv("Date"); - $log .= ','.$langs->transnoentitiesnoconv("DateDue"); - $log .= ','.$langs->transnoentitiesnoconv("Ref"); - $log .= ','.$langs->transnoentitiesnoconv("TotalHT"); - $log .= ','.$langs->transnoentitiesnoconv("TotalTTC"); - $log .= ','.$langs->transnoentitiesnoconv("TotalVAT"); - $log .= ','.$langs->transcountrynoentities("TotalLT1", $mysoc->country_code); - $log .= ','.$langs->transcountrynoentities("TotalLT2", $mysoc->country_code); - $log .= ','.$langs->transnoentitiesnoconv("RevenueStamp"); - $log .= ','.$langs->transnoentitiesnoconv("Paid"); - $log .= ','.$langs->transnoentitiesnoconv("Document"); - $log .= ','.$langs->transnoentitiesnoconv("ItemID"); - $log .= ','.$langs->transnoentitiesnoconv("ThirdParty"); - $log .= ','.$langs->transnoentitiesnoconv("Code"); - $log .= ','.$langs->transnoentitiesnoconv("Country"); - $log .= ','.$langs->transnoentitiesnoconv("VATIntra"); - $log .= ','.$langs->transnoentitiesnoconv("Sens")."\n"; - $zipname = $dirfortmpfile.'/'.dol_print_date($date_start, 'dayrfc', 'tzuserrel')."-".dol_print_date($date_stop, 'dayrfc', 'tzuserrel'); - if (!empty($projectid)) { - $project = new Project($db); - $project->fetch($projectid); - if ($project->ref) { - $zipname .= '_'.$project->ref; - } - } - $zipname .='_export.zip'; - - dol_delete_file($zipname); - - $zip = new ZipArchive(); - $res = $zip->open($zipname, ZipArchive::OVERWRITE | ZipArchive::CREATE); - if ($res) { - foreach ($filesarray as $key => $file) { - if (!empty($file['files'])) { - foreach ($file['files'] as $filecursor) { - if (file_exists($filecursor["fullname"])) { - $zip->addFile($filecursor["fullname"], $filecursor["relpathnamelang"]); - } - } - } - - $log .= '"'.$langs->transnoentitiesnoconv($file['item']).'"'; - if (isModEnabled('multicompany') && is_object($mc)) { - $log .= ',"'.(empty($arrayofentities[$file['entity']]) ? $file['entity'] : $arrayofentities[$file['entity']]).'"'; - } - $log .= ','.dol_print_date($file['date'], 'dayrfc'); - $log .= ','.dol_print_date($file['date_due'], 'dayrfc'); - $log .= ',"'.$file['ref'].'"'; - $log .= ','.$file['amount_ht']; - $log .= ','.$file['amount_ttc']; - $log .= ','.$file['amount_vat']; - $log .= ','.$file['amount_localtax1']; - $log .= ','.$file['amount_localtax2']; - $log .= ','.$file['amount_revenuestamp']; - $log .= ','.$file['paid']; - $log .= ',"'.$file["name"].'"'; - $log .= ','.$file['fk']; - $log .= ',"'.$file['thirdparty_name'].'"'; - $log .= ',"'.$file['thirdparty_code'].'"'; - $log .= ',"'.$file['country_code'].'"'; - $log .= ',"'.$file['vatnum'].'"'; - $log .= ',"'.$file['sens'].'"'; - $log .= "\n"; - } - $zip->addFromString('transactions.csv', $log); - $zip->close(); - - // Then download the zipped file. - header('Content-Type: application/zip'); - header('Content-disposition: attachment; filename='.basename($zipname)); - header('Content-Length: '.filesize($zipname)); - readfile($zipname); - - dol_delete_file($zipname); - - exit(); - } else { - setEventMessages($langs->trans("FailedToOpenFile", $zipname), null, 'errors'); - } + exit; @@ -579,0 +421,78 @@ + + dol_mkdir($dirfortmpfile); + + $log = $langs->transnoentitiesnoconv("Type"); + if (!empty($conf->multicompany->enabled) && is_object($mc)) + { + $log .= ','.$langs->transnoentitiesnoconv("Entity"); + } + $log .= ','.$langs->transnoentitiesnoconv("Date"); + $log .= ','.$langs->transnoentitiesnoconv("DateDue"); + $log .= ','.$langs->transnoentitiesnoconv("Ref"); + $log .= ','.$langs->transnoentitiesnoconv("TotalHT"); + $log .= ','.$langs->transnoentitiesnoconv("TotalTTC"); + $log .= ','.$langs->transnoentitiesnoconv("TotalVAT"); + $log .= ','.$langs->transnoentitiesnoconv("Paid"); + $log .= ','.$langs->transnoentitiesnoconv("Document"); + $log .= ','.$langs->transnoentitiesnoconv("ItemID"); + $log .= ','.$langs->transnoentitiesnoconv("ThirdParty"); + $log .= ','.$langs->transnoentitiesnoconv("Code"); + $log .= ','.$langs->transnoentitiesnoconv("Country"); + $log .= ','.$langs->transnoentitiesnoconv("VATIntra"); + $log .= ','.$langs->transnoentitiesnoconv("Sens")."\n"; + $zipname = $dirfortmpfile.'/'.dol_print_date($date_start, 'dayrfc')."-".dol_print_date($date_stop, 'dayrfc').'_export.zip'; + + dol_delete_file($zipname); + + $zip = new ZipArchive; + $res = $zip->open($zipname, ZipArchive::OVERWRITE | ZipArchive::CREATE); + if ($res) + { + foreach ($filesarray as $key => $file) + { + if (!empty($file['files'])) { + foreach ($file['files'] as $filecursor) { + if (file_exists($filecursor["fullname"])) { + $zip->addFile($filecursor["fullname"], $filecursor["relpathnamelang"]); + } + } + } + + $log .= '"'.$langs->trans($file['item']).'"'; + if (!empty($conf->multicompany->enabled) && is_object($mc)) + { + $log .= ',"'.(empty($arrayofentities[$file['entity']]) ? $file['entity'] : $arrayofentities[$file['entity']]).'"'; + } + $log .= ','.dol_print_date($file['date'], 'dayrfc'); + $log .= ','.dol_print_date($file['date_due'], 'dayrfc'); + $log .= ',"'.$file['ref'].'"'; + $log .= ','.$file['amount_ht']; + $log .= ','.$file['amount_ttc']; + $log .= ','.$file['amount_vat']; + $log .= ','.$file['paid']; + $log .= ',"'.$file["name"].'"'; + $log .= ','.$file['fk']; + $log .= ',"'.$file['thirdparty_name'].'"'; + $log .= ',"'.$file['thirdparty_code'].'"'; + $log .= ',"'.$file['country_code'].'"'; + $log .= ',"'.$file['vatnum'].'"'; + $log .= ',"'.$file['sens'].'"'; + $log .= "\n"; + } + $zip->addFromString('transactions.csv', $log); + $zip->close(); + + ///Then download the zipped file. + header('Content-Type: application/zip'); + header('Content-disposition: attachment; filename='.basename($zipname)); + header('Content-Length: '.filesize($zipname)); + readfile($zipname); + + dol_delete_file($zipname); + + exit(); + } + else + { + setEventMessages($langs->trans("FailedToOpenFile", $zipname), null, 'errors'); + } @@ -587 +506 @@ -$form = new Form($db); +$form = new form($db); @@ -610 +529 @@ -print dol_get_fiche_head($head, 'AccountancyFiles'); +dol_fiche_head($head, 'AccountancyFiles'); @@ -616,12 +535,2 @@ -print '<span class="opacitymedium">'.$langs->trans("ExportAccountingSourceDocHelp"); -if (isModEnabled('accounting')) { - print ' '.$langs->trans("ExportAccountingSourceDocHelp2", $langs->transnoentitiesnoconv("Accounting"), $langs->transnoentitiesnoconv("Journals")); -} -print '</span><br>'; -print '<br>'; - -print $langs->trans("ReportPeriod").': '; -print $form->selectDate($date_start, 'date_start', 0, 0, 0, "", 1, 1, 0, '', '', '', '', 1, '', '', 'tzuserrel'); -print ' - '; -print $form->selectDate($date_stop, 'date_stop', 0, 0, 0, "", 1, 1, 0, '', '', '', '', 1, '', '', 'tzuserrel'); -print "\n"; +print $langs->trans("ReportPeriod").': '.$form->selectDate($date_start, 'date_start', 0, 0, 0, "", 1, 1, 0); +print ' - '.$form->selectDate($date_stop, 'date_stop', 0, 0, 0, "", 1, 1, 0)."\n</a>"; @@ -630,2 +539,2 @@ -$socid = 0; -if (isModEnabled('multicompany') && is_object($mc)) { +if (!empty($conf->multicompany->enabled) && is_object($mc)) +{ @@ -633,3 +542,3 @@ - print ' <span class="marginleftonly marginrightonly'.(!getDolGlobalString('MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES') ? ' opacitymedium' : '').'">'.$langs->trans("Entity").' : '; - if (getDolGlobalString('MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES')) { - $socid = $mc->id; + print '<span class="marginleftonly marginrightonly'.(empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES) ? ' opacitymedium' : '').'">('.$langs->trans("Entity").' : '; + print "<td>"; + if (!empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES)) { @@ -640 +549,2 @@ - print "</span>\n"; + print "</td>"; + print ")</span>\n"; @@ -645,11 +555,10 @@ -// Project filter -if (isModEnabled('projet')) { - $formproject = new FormProjets($db); - $langs->load('projects'); - print '<span class="marginrightonly">'.$langs->trans('Project').":</span>"; - print img_picto('', 'project').$formproject->select_projects(($socid > 0 ? $socid : -1), $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 1, 0, ''); - print '<span class="classfortooltip" style="padding: 0px; padding: 0px; padding-right: 3px !important;" title="'.$langs->trans('ExportAccountingProjectHelp').'"><span class="fas fa-info-circle em088 opacityhigh" style=" vertical-align: middle; cursor: help"></span></span>'; - print '<br>'; -} - -$i = 0; +$listofchoices = array( + 'selectinvoices'=>array('label'=>'Invoices', 'lang'=>'bills'), + 'selectsupplierinvoices'=>array('label'=>'BillsSuppliers', 'lang'=>'bills'), + 'selectexpensereports'=>array('label'=>'ExpenseReports', 'lang'=>'trips'), + 'selectdonations'=>array('label'=>'Donations', 'lang'=>'donation'), + 'selectpaymentsofsalaries'=>array('label'=>'SalariesPayments', 'lang'=>'salaries'), + 'selectsocialcontributions'=>array('label'=>'SocialContributions'), + 'selectvariouspayment'=>array('label'=>'VariousPayment'), + 'selectloanspayment'=>array('label'=>'PaymentLoan'), +); @@ -657,7 +565,0 @@ - if (empty($val['enabled'])) { - continue; // list not qualified - } - $disabled = ''; - if (empty($val['perms'])) { - $disabled = ' disabled'; - } @@ -665,7 +567,4 @@ - print '<div class="'.($i > 0 ? 'paddingleft marginleftonly' : '').' inline-block marginrightonly paddingright"><input type="checkbox" id="'.$choice.'" name="'.$choice.'" value="1"'.$checked.$disabled.'><label for="'.$choice.'"> '; - print img_picto($langs->trans($val['label']), $val['picto'], 'class=""').' '.$langs->trans($val['label']); - print '</label></div>'; - $i++; -} - -print '<input type="submit" class="button small" name="search" value="'.$langs->trans("Search").'">'; + print '<div class="paddingleft inline-block marginrightonly"><input type="checkbox" name="'.$choice.'" value="1"'.$checked.'> '.$langs->trans($val['label']).'</div>'; +} + +print '<input class="button" type="submit" name="search" value="'.$langs->trans("Search").'">'; @@ -675,182 +574,124 @@ -print dol_get_fiche_end(); - -$param = ''; -if (!empty($date_start) && !empty($date_stop)) { - $param .= '&date_startday='.GETPOST('date_startday', 'int'); - $param .= '&date_startmonth='.GETPOST('date_startmonth', 'int'); - $param .= '&date_startyear='.GETPOST('date_startyear', 'int'); - $param .= '&date_stopday='.GETPOST('date_stopday', 'int'); - $param .= '&date_stopmonth='.GETPOST('date_stopmonth', 'int'); - $param .= '&date_stopyear='.GETPOST('date_stopyear', 'int'); - foreach ($listofchoices as $choice => $val) { - if (GETPOST($choice, 'int')) { - $param .= '&'.$choice.'=1'; - } - } - - $TData = dol_sort_array($filesarray, $sortfield, $sortorder); - - - $filename = dol_print_date($date_start, 'dayrfc', 'tzuserrel')."-".dol_print_date($date_stop, 'dayrfc', 'tzuserrel').'_export.zip'; - - echo dol_print_date($date_start, 'day', 'tzuserrel')." - ".dol_print_date($date_stop, 'day', 'tzuserrel'); - - print '<a class="marginleftonly small'.(empty($TData) ? ' butActionRefused' : ' butAction').'" href="'.$_SERVER["PHP_SELF"].'?action=dl&token='.currentToken().'&projectid='.$projectid.'&output=file&file='.urlencode($filename).$param.'"'; - if (empty($TData)) { - print " disabled"; - } - print '>'."\n"; - print $langs->trans("Download"); - print '</a><br>'; - - $param .= '&action=searchfiles'; - - /* - print '<input type="hidden" name="token" value="'.currentToken().'">'; - print '<input type="hidden" name="date_startday" value="'.GETPOST('date_startday', 'int').'" />'; - print '<input type="hidden" name="date_startmonth" value="'.GETPOST('date_startmonth', 'int').'" />'; - print '<input type="hidden" name="date_startyear" value="'.GETPOST('date_startyear', 'int').'" />'; - print '<input type="hidden" name="date_stopday" value="'.GETPOST('date_stopday', 'int').'" />'; - print '<input type="hidden" name="date_stopmonth" value="'.GETPOST('date_stopmonth', 'int').'" />'; - print '<input type="hidden" name="date_stopyear" value="'.GETPOST('date_stopyear', 'int').'" />'; - foreach ($listofchoices as $choice => $val) { - print '<input type="hidden" name="'.$choice.'" value="'.GETPOST($choice).'">'; - } - - print '<input class="butAction butDownload small marginleftonly" type="submit" value="'.$langs->trans("Download").'"'; - if (empty($TData)) { - print " disabled"; - } - print '/>'; - print '</form>'."\n"; - */ - - print '<br>'; - - print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table - print '<table class="noborder centpercent">'; - print '<tr class="liste_titre">'; - print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], "item", "", $param, '', $sortfield, $sortorder, 'nowrap '); - print_liste_field_titre($arrayfields['date']['label'], $_SERVER["PHP_SELF"], "date", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - print_liste_field_titre($arrayfields['date_due']['label'], $_SERVER["PHP_SELF"], "date_due", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - print_liste_field_titre($arrayfields['ref']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'nowraponall '); - print '<th>'.$langs->trans("Document").'</th>'; - print '<th>'.$langs->trans("Paid").'</th>'; - print '<th class="right">'.$langs->trans("TotalHT").(isModEnabled('multicurrency') ? ' ('.$langs->getCurrencySymbol($conf->currency).')' : '').'</th>'; - print '<th class="right">'.$langs->trans("TotalTTC").(isModEnabled('multicurrency') ? ' ('.$langs->getCurrencySymbol($conf->currency).')' : '').'</th>'; - print '<th class="right">'.$langs->trans("TotalVAT").(isModEnabled('multicurrency') ? ' ('.$langs->getCurrencySymbol($conf->currency).')' : '').'</th>'; - - print '<th>'.$langs->trans("ThirdParty").'</th>'; - print '<th class="center">'.$langs->trans("Code").'</th>'; - print '<th class="center">'.$langs->trans("Country").'</th>'; - print '<th class="center">'.$langs->trans("VATIntra").'</th>'; - if (isModEnabled('multicurrency')) { - print '<th class="center">'.$langs->trans("Currency").'</th>'; - } - print '</tr>'; - - if (empty($TData)) { - print '<tr class="oddeven"><td colspan="13"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td>'; - if (isModEnabled('multicurrency')) { - print '<td></td>'; - } - print '</tr>'; - } else { - // Sort array by date ASC to calculate balance - - $totalET_debit = 0; - $totalIT_debit = 0; - $totalVAT_debit = 0; - $totalET_credit = 0; - $totalIT_credit = 0; - $totalVAT_credit = 0; - - // Display array - foreach ($TData as $data) { - $html_class = ''; - //if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture']; - //elseif (!empty($data['fk_paiement'])) $html_class = 'payid-'.$data['fk_paiement']; - print '<tr class="oddeven '.$html_class.'">'; - - // Type - print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($langs->trans($data['item'])).'">'.$langs->trans($data['item']).'</td>'; - - // Date - print '<td class="center">'; - print dol_print_date($data['date'], 'day'); - print "</td>\n"; - - // Date due - print '<td class="center">'; - print dol_print_date($data['date_due'], 'day'); - print "</td>\n"; - - // Ref - print '<td class="nowraponall tdoverflowmax150">'; - - if ($data['item'] == 'Invoice') { - $invoice->id = $data['id']; - $invoice->ref = $data['ref']; - $invoice->total_ht = $data['amount_ht']; - $invoice->total_ttc = $data['amount_ttc']; - $invoice->total_tva = $data['amount_vat']; - $invoice->total_localtax1 = $data['amount_localtax1']; - $invoice->total_localtax2 = $data['amount_localtax2']; - $invoice->revenuestamp = $data['amount_revenuestamp']; - $invoice->multicurrency_code = $data['currency']; - print $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0); - } elseif ($data['item'] == 'SupplierInvoice') { - $supplier_invoice->id = $data['id']; - $supplier_invoice->ref = $data['ref']; - $supplier_invoice->total_ht = $data['amount_ht']; - $supplier_invoice->total_ttc = $data['amount_ttc']; - $supplier_invoice->total_tva = $data['amount_vat']; - $supplier_invoice->total_localtax1 = $data['amount_localtax1']; - $supplier_invoice->total_localtax2 = $data['amount_localtax2']; - $supplier_invoice->revenuestamp = $data['amount_revenuestamp']; - $supplier_invoice->multicurrency_code = $data['currency']; - print $supplier_invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0); - } elseif ($data['item'] == 'ExpenseReport') { - $expensereport->id = $data['id']; - $expensereport->ref = $data['ref']; - print $expensereport->getNomUrl(1, 0, 0, '', 0, 0); - } elseif ($data['item'] == 'SalaryPayment') { - $salary_payment->id = $data['id']; - $salary_payment->ref = $data['ref']; - print $salary_payment->getNomUrl(1); - } elseif ($data['item'] == 'Donation') { - $don->id = $data['id']; - $don->ref = $data['ref']; - print $don->getNomUrl(1, 0, '', 0); - } elseif ($data['item'] == 'SocialContributions') { - $charge_sociales->id = $data['id']; - $charge_sociales->ref = $data['ref']; - print $charge_sociales->getNomUrl(1, 0, 0, 0, 0); - } elseif ($data['item'] == 'VariousPayment') { - $various_payment->id = $data['id']; - $various_payment->ref = $data['ref']; - print $various_payment->getNomUrl(1, '', 0, 0); - } elseif ($data['item'] == 'LoanPayment') { - $payment_loan->id = $data['id']; - $payment_loan->ref = $data['ref']; - print $payment_loan->getNomUrl(1, 0, 0, '', 0); - } else { - print $data['ref']; - } - print '</td>'; - - // File link - print '<td class="tdoverflowmax150">'; - if (!empty($data['files'])) { - foreach ($data['files'] as $id => $filecursor) { - $tmppreview = $formfile->showPreview($filecursor, $filecursor['modulepart'], $filecursor['subdir'].'/'.$filecursor['name'], 0); - if ($tmppreview) { - print $tmppreview; - } - $filename = ($filecursor['name'] ? $filecursor['name'] : $filecursor['ref']); - print '<a href='.DOL_URL_ROOT.'/'.$filecursor['link'].' target="_blank" rel="noopener noreferrer" title="'.dol_escape_htmltag($filename).'">'; - if (empty($tmppreview)) { - print img_picto('', 'generic', '', false, 0, 0, '', 'pictonopreview pictofixedwidth paddingright'); - } - print $filename; - print '</a><br>'; +dol_fiche_end(); + +if (!empty($date_start) && !empty($date_stop)) +{ + $param = 'action=searchfiles'; + $param .= '&date_startday='.GETPOST('date_startday', 'int'); + $param .= '&date_startmonth='.GETPOST('date_startmonth', 'int'); + $param .= '&date_startyear='.GETPOST('date_startyear', 'int'); + $param .= '&date_stopday='.GETPOST('date_stopday', 'int'); + $param .= '&date_stopmonth='.GETPOST('date_stopmonth', 'int'); + $param .= '&date_stopyear='.GETPOST('date_stopyear', 'int'); + foreach ($listofchoices as $choice => $val) { + $param .= '&'.$choice.'='.(GETPOST($choice, 'int') ? 1 : 0); + } + print '<form name="dl" action="?action=dl" method="POST" >'."\n"; + print '<input type="hidden" name="token" value="'.currentToken().'">'; + + echo dol_print_date($date_start, 'day')." - ".dol_print_date($date_stop, 'day'); + + print '<input type="hidden" name="date_start" value="'.dol_print_date($date_start, 'dayxcard').'" />'; + print '<input type="hidden" name="date_stop" value="'.dol_print_date($date_stop, 'dayxcard').'" />'; + foreach ($listofchoices as $choice => $val) { + print '<input type="hidden" name="'.$choice.'" value="'.GETPOST($choice).'">'; + } + + print '<input class="butAction" type="submit" value="'.$langs->trans("Download").'" />'; + print '</form>'."\n"; + + print '<br>'; + + print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '<table class="noborder centpercent">'; + print '<tr class="liste_titre">'; + print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], "item", "", $param, '', $sortfield, $sortorder, 'nowrap '); + print_liste_field_titre($arrayfields['date']['label'], $_SERVER["PHP_SELF"], "date", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + print_liste_field_titre($arrayfields['date_due']['label'], $_SERVER["PHP_SELF"], "date_due", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + print_liste_field_titre($arrayfields['ref']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'nowraponall '); + print '<td>'.$langs->trans("Document").'</td>'; + print '<td>'.$langs->trans("Paid").'</td>'; + print '<td align="right">'.$langs->trans("TotalHT").'</td>'; + print '<td align="right">'.$langs->trans("TotalTTC").'</td>'; + print '<td align="right">'.$langs->trans("TotalVAT").'</td>'; + print '<td>'.$langs->trans("ThirdParty").'</td>'; + print '<td class="center">'.$langs->trans("Code").'</td>'; + print '<td class="center">'.$langs->trans("Country").'</td>'; + print '<td class="center">'.$langs->trans("VATIntra").'</td>'; + print '</tr>'; + if ($result) + { + $TData = dol_sort_array($filesarray, $sortfield, $sortorder); + + if (empty($TData)) + { + print '<tr class="oddeven"><td colspan="7">'.$langs->trans("NoItem").'</td></tr>'; + } + else + { + // Sort array by date ASC to calculate balance + + $totalET_debit = 0; + $totalIT_debit = 0; + $totalVAT_debit = 0; + $totalET_credit = 0; + $totalIT_credit = 0; + $totalVAT_credit = 0; + + // Display array + foreach ($TData as $data) + { + $html_class = ''; + //if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture']; + //elseif (!empty($data['fk_paiement'])) $html_class = 'payid-'.$data['fk_paiement']; + print '<tr class="oddeven '.$html_class.'">'; + + // Type + print '<td>'.$langs->trans($data['item']).'</td>'; + + // Date + print '<td class="center">'; + print dol_print_date($data['date'], 'day'); + print "</td>\n"; + + // Date + print '<td class="center">'; + print dol_print_date($data['date_due'], 'day'); + print "</td>\n"; + + // Ref + print '<td class="nowraponall">'; + + if ($data['item'] == 'Invoice') { + $invoice->id = $data['id']; + $invoice->ref = $data['ref']; + print $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0); + } elseif ($data['item'] == 'SupplierInvoice') { + $supplier_invoice->id = $data['id']; + $supplier_invoice->ref = $data['ref']; + print $supplier_invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0); + } elseif ($data['item'] == 'ExpenseReport') { + $expensereport->id = $data['id']; + $expensereport->ref = $data['ref']; + print $expensereport->getNomUrl(1, 0, 0, '', 0, 0); + } elseif ($data['item'] == 'SalaryPayment') { + $salary_payment->id = $data['id']; + $salary_payment->ref = $data['ref']; + print $salary_payment->getNomUrl(1, '', 0, '', 0); + } elseif ($data['item'] == 'Donation') { + $don->id = $data['id']; + $don->ref = $data['ref']; + print $don->getNomUrl(1, 0, '', 0); + } elseif ($data['item'] == 'SocialContributions') { + $charge_sociales->id = $data['id']; + $charge_sociales->ref = $data['ref']; + print $charge_sociales->getNomUrl(1, 0, 0, 0, 0); + } elseif ($data['item'] == 'VariousPayment') { + $various_payment->id = $data['id']; + $various_payment->ref = $data['ref']; + print $various_payment->getNomUrl(1, '', 0, 0); + } elseif ($data['item'] == 'LoanPayment') { + $payment_loan->id = $data['id']; + $payment_loan->ref = $data['ref']; + print $payment_loan->getNomUrl(1, 0, 0, '', 0); + } else { + print $data['ref']; @@ -858,88 +699,71 @@ - } - print "</td>\n"; - - // Paid - print '<td class="center">'.($data['paid'] ? yn($data['paid']) : '').'</td>'; - - // Total WOT - print '<td class="right"><span class="amount">'.price(price2num($data['sens'] ? $data['amount_ht'] : -$data['amount_ht'], 'MT'))."</span></td>\n"; - // Total INCT - print '<td class="right"><span class="amount">'; - $tooltip = $langs->trans("TotalVAT").' : '.price(price2num($data['sens'] ? $data['amount_vat'] : -$data['amount_vat'], 'MT')); - if (!empty($data['amount_localtax1'])) { - $tooltip .= '<br>'.$langs->transcountrynoentities("TotalLT1", $mysoc->country_code).' : '.price(price2num($data['sens'] ? $data['amount_localtax1'] : -$data['amount_localtax1'], 'MT')); - } - if (!empty($data['amount_localtax2'])) { - $tooltip .= '<br>'.$langs->transcountrynoentities("TotalLT2", $mysoc->country_code).' : '.price(price2num($data['sens'] ? $data['amount_localtax2'] : -$data['amount_localtax2'], 'MT')); - } - if (!empty($data['amount_revenuestamp'])) { - $tooltip .= '<br>'.$langs->trans("RevenueStamp").' : '.price(price2num($data['sens'] ? $data['amount_revenuestamp'] : -$data['amount_revenuestamp'], 'MT')); - } - print '<span class="classfortooltip" title="'.dol_escape_htmltag($tooltip).'">'.price(price2num($data['sens'] ? $data['amount_ttc'] : -$data['amount_ttc'], 'MT')).'</span>'; - print "</span></td>\n"; - // Total VAT - print '<td class="right"><span class="amount">'.price(price2num($data['sens'] ? $data['amount_vat'] : -$data['amount_vat'], 'MT'))."</span></td>\n"; - - print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($data['thirdparty_name']).'">'.dol_escape_htmltag($data['thirdparty_name'])."</td>\n"; - - print '<td class="center">'.$data['thirdparty_code']."</td>\n"; - - print '<td class="center">'.$data['country_code']."</td>\n"; - - // VAT number - print '<td class="tdoverflowmax150 right" title="'.dol_escape_htmltag($data['vatnum']).'">'.dol_escape_htmltag($data['vatnum'])."</td>\n"; - - if ($data['sens']) { - $totalET_credit += $data['amount_ht']; - $totalIT_credit += $data['amount_ttc']; - $totalVAT_credit += $data['amount_vat']; - } else { - $totalET_debit -= $data['amount_ht']; - $totalIT_debit -= $data['amount_ttc']; - $totalVAT_debit -= $data['amount_vat']; - } - - if (isModEnabled('multicurrency')) { - print '<td class="center">'.$data['currency']."</td>\n"; - } - - print "</tr>\n"; - } - - // Total credits - print '<tr class="liste_total">'; - print '<td colspan="6" class="right">'.$langs->trans('Total').' '.$langs->trans('Income').'</td>'; - print '<td class="right">'.price(price2num($totalET_credit, 'MT')).'</td>'; - print '<td class="right">'.price(price2num($totalIT_credit, 'MT')).'</td>'; - print '<td class="right">'.price(price2num($totalVAT_credit, 'MT')).'</td>'; - print '<td colspan="4"></td>'; - if (isModEnabled('multicurrency')) { - print '<td></td>'; - } - print "</tr>\n"; - // Total debits - print '<tr class="liste_total">'; - print '<td colspan="6" class="right">'.$langs->trans('Total').' '.$langs->trans('Outcome').'</td>'; - print '<td class="right">'.price(price2num($totalET_debit, 'MT')).'</td>'; - print '<td class="right">'.price(price2num($totalIT_debit, 'MT')).'</td>'; - print '<td class="right">'.price(price2num($totalVAT_debit, 'MT')).'</td>'; - print '<td colspan="4"></td>'; - if (isModEnabled('multicurrency')) { - print '<td></td>'; - } - print "</tr>\n"; - // Balance - print '<tr class="liste_total">'; - print '<td colspan="6" class="right">'.$langs->trans('Total').'</td>'; - print '<td class="right">'.price(price2num($totalET_credit + $totalET_debit, 'MT')).'</td>'; - print '<td class="right">'.price(price2num($totalIT_credit + $totalIT_debit, 'MT')).'</td>'; - print '<td class="right">'.price(price2num($totalVAT_credit + $totalVAT_debit, 'MT')).'</td>'; - print '<td colspan="4"></td>'; - if (isModEnabled('multicurrency')) { - print '<td></td>'; - } - print "</tr>\n"; - } - - print "</table>"; - print '</div>'; + print '</td>'; + + // File link + print '<td>'; + if (!empty($data['files'])) + { + foreach ($data['files'] as $id=>$filecursor) { + print '<a href='.DOL_URL_ROOT.'/'.$filecursor['link'].' target="_blank">'.($filecursor['name'] ? $filecursor['name'] : $filecursor['ref']).'</a> '.$formfile->showPreview($filecursor, $filecursor['modulepart'], $filecursor['subdir'].'/'.$filecursor['name']).'<br>'; + } + } + print "</td>\n"; + + // Paid + print '<td aling="left">'.$data['paid'].'</td>'; + + // Total ET + print '<td align="right">'.price($data['sens']?$data['amount_ht']:-$data['amount_ht'])."</td>\n"; + // Total IT + print '<td align="right">'.price($data['sens']?$data['amount_ttc']:-$data['amount_ttc'])."</td>\n"; + // Total VAT + print '<td align="right">'.price($data['sens']?$data['amount_vat']:-$data['amount_vat'])."</td>\n"; + + print '<td>'.$data['thirdparty_name']."</td>\n"; + + print '<td class="center">'.$data['thirdparty_code']."</td>\n"; + + print '<td class="center">'.$data['country_code']."</td>\n"; + + print '<td align="right">'.$data['vatnum']."</td>\n"; + + if ($data['sens']) { + $totalET_credit += $data['amount_ht']; + $totalIT_credit += $data['amount_ttc']; + $totalVAT_credit += $data['amount_vat']; + } else { + $totalET_debit -= $data['amount_ht']; + $totalIT_debit -= $data['amount_ttc']; + $totalVAT_debit -= $data['amount_vat']; + } + + print "</tr>\n"; + } + + // Total credits + print '<tr class="liste_total">'; + print '<td colspan="6" class="right">'.$langs->trans('Total').' '.$langs->trans('Income').'</td>'; + print '<td align="right">'.price(price2num($totalET_credit, 'MT')).'</td>'; + print '<td align="right">'.price(price2num($totalIT_credit, 'MT')).'</td>'; + print '<td align="right">'.price(price2num($totalVAT_credit, 'MT')).'</td>'; + print '<td colspan="4"></td>'; + print "</tr>\n"; + // Total debits + print '<tr class="liste_total">'; + print '<td colspan="6" class="right">'.$langs->trans('Total').' '.$langs->trans('Outcome').'</td>'; + print '<td align="right">'.price(price2num($totalET_debit, 'MT')).'</td>'; + print '<td align="right">'.price(price2num($totalIT_debit, 'MT')).'</td>'; + print '<td align="right">'.price(price2num($totalVAT_debit, 'MT')).'</td>'; + print '<td colspan="4"></td>'; + print "</tr>\n"; + // Balance + print '<tr class="liste_total">'; + print '<td colspan="6" class="right">'.$langs->trans('Total').'</td>'; + print '<td align="right">'.price(price2num($totalET_credit+$totalET_debit, 'MT')).'</td>'; + print '<td align="right">'.price(price2num($totalIT_credit+$totalIT_debit, 'MT')).'</td>'; + print '<td align="right">'.price(price2num($totalVAT_credit+$totalVAT_debit, 'MT')).'</td>'; + print '<td colspan="4"></td>'; + print "</tr>\n"; + } + } + print "</table>"; + print '</div>'; --- /tmp/dsg/dolibarr/htdocs/compta/github_19.0.3_ajaxpayment.php +++ /tmp/dsg/dolibarr/htdocs/compta/client_ajaxpayment.php @@ -23,12 +23,5 @@ -if (!defined('NOREQUIRESOC')) { - define('NOREQUIRESOC', '1'); -} -if (!defined('NOTOKENRENEWAL')) { - define('NOTOKENRENEWAL', '1'); -} -if (!defined('NOREQUIREMENU')) { - define('NOREQUIREMENU', '1'); // If there is no menu to show -} -if (!defined('NOREQUIREHTML')) { - define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php -} +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no menu to show +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php @@ -36 +28,0 @@ -// Load Dolibarr environment @@ -40,2 +31,0 @@ - -// No permission check. This is just a formatting data service. @@ -50,4 +40,4 @@ -$amountPayment = GETPOST('amountPayment'); -$amounts = GETPOST('amounts'); // from text inputs : invoice amount payment (check required) -$remains = GETPOST('remains'); // from dolibarr's object (no need to check) -$currentInvId = GETPOST('imgClicked'); // from DOM elements : imgId (equals invoice id) +$amountPayment = $_POST['amountPayment']; +$amounts = $_POST['amounts']; // from text inputs : invoice amount payment (check required) +$remains = $_POST['remains']; // from dolibarr's object (no need to check) +$currentInvId = $_POST['imgClicked']; // from DOM elements : imgId (equals invoice id) @@ -59,8 +49,5 @@ -if (is_array($amounts)) { - foreach ($amounts as $key => $value) { - $value = price2num($value); - $amounts[$key] = $value; - if (empty($value)) { - unset($amounts[$key]); - } - } +foreach ($amounts as $key => $value) +{ + $value = price2num($value); + $amounts[$key] = $value; + if (empty($value)) unset($amounts[$key]); @@ -69,12 +56,5 @@ -if (is_array($remains)) { - foreach ($remains as $key => $value) { - $value = price2num($value); - $remains[$key] = (($invoice_type) == 2 ? -1 : 1) * $value; - if (empty($value)) { - unset($remains[$key]); - } - } -} elseif ($remains) { - $remains = array(price2num($remains)); -} else { - $remains = array(); +foreach ($remains as $key => $value) +{ + $value = price2num($value); + $remains[$key] = (($invoice_type) == 2 ?-1 : 1) * $value; + if (empty($value)) unset($remains[$key]); @@ -88 +68,2 @@ -if ($currentInvId) { // Here to breakdown +if ($currentInvId) // Here to breakdown +{ @@ -94 +75,2 @@ - if ($amountPayment == '') { + if ($amountPayment == '') + { @@ -97 +79,2 @@ - if ($amountExists) { + if ($amountExists) + { @@ -101 +84,2 @@ - } else { + } else + { @@ -105 +89,2 @@ - } else { + } else + { @@ -110 +95,2 @@ - if ($result >= 0) { // then we need to calculate the amount to breakdown + if ($result >= 0) // then we need to calculate the amount to breakdown + { @@ -118 +104 @@ - $toJsonArray['amount_'.$currentInvId] = price2num($currentAmount); // Param will exist only if an img has been clicked + $toJsonArray['amount_'.$currentInvId] = price2num($currentAmount).""; // Param will exist only if an img has been clicked --- /tmp/dsg/dolibarr/htdocs/compta/github_19.0.3_clients.php +++ /tmp/dsg/dolibarr/htdocs/compta/client_clients.php @@ -26 +25,0 @@ -// Load Dolibarr environment @@ -34 +33,2 @@ -if ($user->socid > 0) { +if ($user->socid > 0) +{ @@ -39,3 +39,2 @@ -if (!$user->hasRight('facture', 'lire')) { - accessforbidden(); -} +if (!$user->rights->facture->lire) +accessforbidden(); @@ -49,2 +48,2 @@ -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); @@ -52,3 +51 @@ -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 @@ -58,6 +55,2 @@ -if (!$sortorder) { - $sortorder = "ASC"; -} -if (!$sortfield) { - $sortfield = "nom"; -} +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "nom"; @@ -74,2 +67,3 @@ -if ($action == 'note') { - $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET note='".$db->escape($note)."' WHERE rowid=".((int) $socid); +if ($action == 'note') +{ + $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET note='".$note."' WHERE rowid=".$socid; @@ -79 +73,2 @@ -if ($mode == 'search') { +if ($mode == 'search') +{ @@ -98,3 +93 @@ -if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= ", sc.fk_soc, sc.fk_user "; -} +if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; @@ -102,3 +95 @@ -if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -} +if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -107,7 +98,13 @@ -if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); -} -if (dol_strlen($stcomm)) { - $sql .= " AND s.fk_stcomm=".((int) $stcomm); -} -if (GETPOST("search_nom")) { +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +if (dol_strlen($stcomm)) +{ + $sql .= " AND s.fk_stcomm=".$stcomm; +} +if ($socname) +{ + $sql .= natural_search("s.nom", $socname); + $sortfield = "s.nom"; + $sortorder = "ASC"; +} +if ($_GET["search_nom"]) +{ @@ -116 +113,2 @@ -if (GETPOST("search_compta")) { +if ($_GET["search_compta"]) +{ @@ -119 +117,2 @@ -if (GETPOST("search_code_client")) { +if ($_GET["search_code_client"]) +{ @@ -122,4 +121,9 @@ -if ($socid) { - $sql .= " AND s.rowid = ".((int) $socid); -} -$sql .= " ORDER BY $sortfield $sortorder"; +if (dol_strlen($begin)) +{ + $sql .= natural_search("s.nom", $begin); +} +if ($socid) +{ + $sql .= " AND s.rowid = ".$socid; +} +$sql .= " ORDER BY $sortfield $sortorder "; @@ -130 +134,2 @@ -if ($resql) { +if ($resql) +{ @@ -136 +141 @@ - print_barre_liste($langs->trans("Customers"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num); + print_barre_liste($langs->trans("ListOfCustomers"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num); @@ -171 +176,2 @@ - while ($i < min($num, $conf->liste_limit)) { + while ($i < min($num, $conf->liste_limit)) + { @@ -193 +199,3 @@ -} else { +} +else +{ --- /tmp/dsg/dolibarr/htdocs/compta/github_19.0.3_index.php +++ /tmp/dsg/dolibarr/htdocs/compta/client_index.php @@ -3 +3 @@ - * Copyright (C) 2004-2022 Laurent Destailleur <eldy@users.sourceforge.net> + * Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net> @@ -5 +5 @@ - * Copyright (C) 2015-2020 Juanjo Menent <jmenent@2byte.es> + * Copyright (C) 2015-2016 Juanjo Menent <jmenent@2byte.es> @@ -10,3 +9,0 @@ - * Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com> - * Copyright (C) 2020 Josep LluÃÂs Amador <joseplluis@lliuretic.cat> - * Copyright (C) 2021-2023 Frédéric France <frederic.france@netlogic.fr> @@ -34,2 +30,0 @@ - -// Load Dolibarr environment @@ -40,5 +35,6 @@ -require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; +if (!empty($conf->commande->enabled)) + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +if (!empty($conf->commande->enabled)) + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; +if (!empty($conf->tax->enabled)) + require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; @@ -55 +51 @@ -if (isModEnabled('commande')) { +if (!empty($conf->commande->enabled)) @@ -57,4 +53,2 @@ -} - -// Get parameters -$action = GETPOST('action', 'aZ09'); + +$action = GETPOST('action', 'alpha'); @@ -65 +59,2 @@ -if ($user->socid > 0) { +if ($user->socid > 0) +{ @@ -70,6 +65 @@ -$max = getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT'); - -// Maximum elements of the tables -$maxDraftCount = !getDolGlobalString('MAIN_MAXLIST_OVERLOAD') ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD; -$maxLatestEditCount = 5; -$maxOpenCount = !getDolGlobalString('MAIN_MAXLIST_OVERLOAD') ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD; +$max = 3; @@ -79,4 +68,0 @@ - - -$maxofloop = (!getDolGlobalString('MAIN_MAXLIST_OVERLOAD') ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD); - @@ -88,2 +73,0 @@ -// None - @@ -96,0 +81,3 @@ +$facturestatic = new Facture($db); +$facturesupplierstatic = new FactureFournisseur($db); + @@ -101,3 +88,3 @@ -llxHeader("", $langs->trans("InvoicesArea")); - -print load_fiche_titre($langs->trans("InvoicesArea"), '', 'bill'); +llxHeader("", $langs->trans("AccountancyTreasuryArea")); + +print load_fiche_titre($langs->trans("AccountancyTreasuryArea"), '', 'bill'); @@ -108,21 +95,226 @@ -if (isModEnabled('facture')) { - print getNumberInvoicesPieChart('customers'); - print '<br>'; -} - -if (isModEnabled('fournisseur') || isModEnabled('supplier_invoice')) { - print getNumberInvoicesPieChart('suppliers'); - print '<br>'; -} - -if (isModEnabled('facture')) { - print getCustomerInvoiceDraftTable($max, $socid); - print '<br>'; -} - -if (isModEnabled('fournisseur') || isModEnabled('supplier_invoice')) { - print getDraftSupplierTable($max, $socid); - print '<br>'; -} - -print '</div><div class="fichetwothirdright">'; + +if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo +{ + // Search customer invoices + if (!empty($conf->facture->enabled) && $user->rights->facture->lire) + { + $listofsearchfields['search_invoice'] = array('text'=>'CustomerInvoice'); + } + // Search supplier invoices + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->lire) + { + $listofsearchfields['search_supplier_invoice'] = array('text'=>'SupplierInvoice'); + } + if (!empty($conf->don->enabled) && $user->rights->don->lire) + { + $langs->load("donations"); + $listofsearchfields['search_donation'] = array('text'=>'Donation'); + } + + if (count($listofsearchfields)) + { + print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">'; + print '<input type="hidden" name="token" value="'.newToken().'">'; + print '<div class="div-table-responsive-no-min">'; + print '<table class="noborder nohover centpercent">'; + $i = 0; + foreach ($listofsearchfields as $key => $value) + { + if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>'; + print '<tr '.$bc[false].'>'; + print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label></td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'"></td>'; + if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>'; + print '</tr>'; + $i++; + } + print '</table>'; + print '</div>'; + print '</form>'; + print '<br>'; + } +} + + +/** + * Draft customers invoices + */ +if (!empty($conf->facture->enabled) && $user->rights->facture->lire) +{ + $sql = "SELECT f.rowid, f.ref, f.datef as date, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.ref_client"; + $sql .= ", f.type"; + $sql .= ", s.nom as name"; + $sql .= ", s.rowid as socid, s.email"; + $sql .= ", s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE s.rowid = f.fk_soc AND f.fk_statut = 0"; + $sql .= " AND f.entity IN (".getEntity('invoice').")"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + + if ($socid) + { + $sql .= " AND f.fk_soc = $socid"; + } + // Add where from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListWhereCustomerDraft', $parameters); + $sql .= $hookmanager->resPrint; + + $resql = $db->query($sql); + + if ($resql) + { + $num = $db->num_rows($resql); + + print '<div class="div-table-responsive-no-min">'; + print '<table class="noborder centpercent">'; + print '<tr class="liste_titre">'; + print '<th colspan="3">'.$langs->trans("CustomersDraftInvoices").($num ? '<span class="badge marginleftonlyshort">'.$num.'</span>' : '').'</th></tr>'; + if ($num) + { + $companystatic = new Societe($db); + + $i = 0; + $tot_ttc = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + + $facturestatic->id = $obj->rowid; + $facturestatic->ref = $obj->ref; + $facturestatic->date = $db->jdate($obj->date); + $facturestatic->type = $obj->type; + $facturestatic->total_ht = $obj->total_ht; + $facturestatic->total_tva = $obj->total_tva; + $facturestatic->total_ttc = $obj->total_ttc; + $facturestatic->ref_client = $obj->ref_client; + + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->email = $obj->email; + $companystatic->client = 1; + $companystatic->code_client = $obj->code_client; + $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->code_compta = $obj->code_compta; + $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur; + + print '<tr class="oddeven"><td class="nowrap">'; + print $facturestatic->getNomUrl(1, ''); + print '</td>'; + print '<td class="nowrap">'; + print $companystatic->getNomUrl(1, 'customer', 16); + print '</td>'; + print '<td class="nowrap right">'.price($obj->total_ttc).'</td>'; + print '</tr>'; + $tot_ttc += $obj->total_ttc; + $i++; + } + + print '<tr class="liste_total"><td class="left">'.$langs->trans("Total").'</td>'; + print '<td colspan="2" class="right">'.price($tot_ttc).'</td>'; + print '</tr>'; + } + else + { + print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("NoInvoice").'</td></tr>'; + } + print "</table></div><br>"; + $db->free($resql); + } + else + { + dol_print_error($db); + } +} + +/** + * Draft suppliers invoices + */ +if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) +{ + $sql = "SELECT f.ref, f.rowid, f.total_ht, f.total_tva, f.total_ttc, f.type, f.ref_supplier"; + $sql .= ", s.nom as name"; + $sql .= ", s.rowid as socid, s.email"; + $sql .= ", s.code_fournisseur, s.code_compta_fournisseur"; + $sql .= ", cc.rowid as country_id, cc.code as country_code"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE s.rowid = f.fk_soc AND f.fk_statut = 0"; + $sql .= " AND f.entity IN (".getEntity('invoice').')'; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND f.fk_soc = ".$socid; + // Add where from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListWhereSupplierDraft', $parameters); + $sql .= $hookmanager->resPrint; + $resql = $db->query($sql); + + if ($resql) + { + $num = $db->num_rows($resql); + + print '<div class="div-table-responsive-no-min">'; + print '<table class="noborder centpercent">'; + print '<tr class="liste_titre">'; + print '<th colspan="3">'.$langs->trans("SuppliersDraftInvoices").($num ? '<span class="badge marginleftonlyshort">'.$num.'</span>' : '').'</th></tr>'; + if ($num) + { + $companystatic = new Societe($db); + + $i = 0; + $tot_ttc = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + + $facturesupplierstatic->ref = $obj->ref; + $facturesupplierstatic->id = $obj->rowid; + $facturesupplierstatic->total_ht = $obj->total_ht; + $facturesupplierstatic->total_tva = $obj->total_tva; + $facturesupplierstatic->total_ttc = $obj->total_ttc; + $facturesupplierstatic->ref_supplier = $obj->ref_supplier; + $facturesupplierstatic->type = $obj->type; + + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->email = $obj->email; + $companystatic->country_id = $obj->country_id; + $companystatic->country_code = $obj->country_code; + $companystatic->fournisseur = 1; + $companystatic->code_client = $obj->code_client; + $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->code_compta = $obj->code_compta; + $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur; + + print '<tr class="oddeven"><td class="nowrap">'; + print $facturesupplierstatic->getNomUrl(1, '', 16); + print '</td>'; + print '<td>'; + print $companystatic->getNomUrl(1, 'supplier', 16); + print '</td>'; + print '<td class="right">'.price($obj->total_ttc).'</td>'; + print '</tr>'; + $tot_ttc += $obj->total_ttc; + $i++; + } + + print '<tr class="liste_total"><td class="left">'.$langs->trans("Total").'</td>'; + print '<td colspan="2" class="right">'.price($tot_ttc).'</td>'; + print '</tr>'; + } + else + { + print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("NoInvoice").'</td></tr>'; + } + print "</table></div><br>"; + $db->free($resql); + } + else + { + dol_print_error($db); + } +} + + +print '</div><div class="fichetwothirdright"><div class="ficheaddleft">'; @@ -132 +324,2 @@ -if (isModEnabled('facture') && $user->hasRight('facture', 'lire')) { +if (!empty($conf->facture->enabled) && $user->rights->facture->lire) +{ @@ -134,3 +327,3 @@ - $tmpinvoice = new Facture($db); - - $sql = "SELECT f.rowid, f.ref, f.fk_statut as status, f.type, f.total_ht, f.total_tva, f.total_ttc, f.paye, f.tms"; + $facstatic = new Facture($db); + + $sql = "SELECT f.rowid, f.ref, f.fk_statut, f.type, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.paye, f.tms"; @@ -139,4 +332,4 @@ - $sql .= ", s.rowid as socid"; - $sql .= ", s.code_client, s.code_compta, s.email"; - $sql .= ", cc.rowid as country_id, cc.code as country_code"; - $sql .= ", sum(pf.amount) as am"; + $sql .= ", s.rowid as socid"; + $sql .= ", s.code_client, s.code_compta, s.email"; + $sql .= ", cc.rowid as country_id, cc.code as country_code"; + $sql .= ", sum(pf.amount) as am"; @@ -145,3 +338 @@ - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - } + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -150,6 +341,2 @@ - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); - } - if ($socid) { - $sql .= " AND f.fk_soc = ".((int) $socid); - } + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND f.fk_soc = ".$socid; @@ -161 +348 @@ - $sql .= " GROUP BY f.rowid, f.ref, f.fk_statut, f.type, f.total_ht, f.total_tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement,"; + $sql .= " GROUP BY f.rowid, f.ref, f.fk_statut, f.type, f.total, f.tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement,"; @@ -168 +355,2 @@ - if ($resql) { + if ($resql) + { @@ -171,3 +359,2 @@ - $othernb = 0; - - print '<div class="div-table-responsive-no-min">'; + + print '<div class="div-table-responsive-no-min">'; @@ -176,3 +363 @@ - if (getDolGlobalString('MAIN_SHOW_HT_ON_SUMMARY')) { - print '<th class="right">'.$langs->trans("AmountHT").'</th>'; - } + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<th class="right">'.$langs->trans("AmountHT").'</th>'; @@ -183,3 +368,5 @@ - if ($num) { - $total_ttc = $totalam = $total_ht = 0; - while ($i < $num && $i < $conf->liste_limit) { + if ($num) + { + $total_ttc = $totalam = $total = 0; + while ($i < $num && $i < $conf->liste_limit) + { @@ -188,17 +375,8 @@ - if ($i >= $max) { - $othernb += 1; - $i++; - $total_ht += $obj->total_ht; - $total_ttc += $obj->total_ttc; - continue; - } - - $tmpinvoice->ref = $obj->ref; - $tmpinvoice->id = $obj->rowid; - $tmpinvoice->total_ht = $obj->total_ht; - $tmpinvoice->total_tva = $obj->total_tva; - $tmpinvoice->total_ttc = $obj->total_ttc; - $tmpinvoice->statut = $obj->status; - $tmpinvoice->paye = $obj->paye; - $tmpinvoice->date_lim_reglement = $db->jdate($obj->datelimite); - $tmpinvoice->type = $obj->type; + $facturestatic->ref = $obj->ref; + $facturestatic->id = $obj->rowid; + $facturestatic->total_ht = $obj->total_ht; + $facturestatic->total_tva = $obj->total_tva; + $facturestatic->total_ttc = $obj->total_ttc; + $facturestatic->statut = $obj->fk_statut; + $facturestatic->date_lim_reglement = $db->jdate($obj->datelimite); + $facturestatic->type = $obj->type; @@ -222 +399,0 @@ - @@ -224,4 +401,4 @@ - print $tmpinvoice->getNomUrl(1, ''); - print '</td>'; - if ($tmpinvoice->hasDelay()) { - print '<td width="20" class="nobordernopadding nowrap">'; + print $facturestatic->getNomUrl(1, ''); + print '</td>'; + print '<td width="20" class="nobordernopadding nowrap">'; + if ($facturestatic->hasDelay()) { @@ -229 +405,0 @@ - print '</td>'; @@ -230,0 +407 @@ + print '</td>'; @@ -235 +412 @@ - print $formfile->getDocumentsLink($tmpinvoice->element, $filename, $filedir); + print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir); @@ -239,13 +416,7 @@ - - print '<td class="tdoverflowmax150">'; - print $thirdpartystatic->getNomUrl(1, 'customer', 44); - print '</td>'; - if (getDolGlobalString('MAIN_SHOW_HT_ON_SUMMARY')) { - print '<td class="nowrap right"><span class="amount">'.price($obj->total_ht).'</span></td>'; - } - print '<td class="nowrap right"><span class="amount">'.price($obj->total_ttc).'</span></td>'; - - print '<td class="right" title="'.dol_escape_htmltag($langs->trans("DateModificationShort").' : '.dol_print_date($db->jdate($obj->tms), 'dayhour', 'tzuserrel')).'">'.dol_print_date($db->jdate($obj->tms), 'day', 'tzuserrel').'</td>'; - - print '<td>'.$tmpinvoice->getLibStatut(3, $obj->am).'</td>'; - + print '<td class="left">'; + print $thirdpartystatic->getNomUrl(1, 'customer', 44); + print '</td>'; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td class="nowrap right">'.price($obj->total_ht).'</td>'; + print '<td class="nowrap right">'.price($obj->total_ttc).'</td>'; + print '<td class="right">'.dol_print_date($db->jdate($obj->tms), 'day').'</td>'; + print '<td>'.$facstatic->LibStatut($obj->paye, $obj->fk_statut, 3, $obj->am).'</td>'; @@ -255 +426 @@ - $total_ht += $obj->total_ht; + $total += $obj->total_ht; @@ -260,9 +431,3 @@ - - if ($othernb) { - print '<tr class="oddeven">'; - print '<td class="nowrap" colspan="5">'; - print '<span class="opacitymedium">'.$langs->trans("More").'... ('.$othernb.')</span>'; - print '</td>'; - print "</tr>\n"; - } - } else { + } + else + { @@ -270,4 +435,2 @@ - if (getDolGlobalString('MAIN_SHOW_HT_ON_SUMMARY')) { - $colspan++; - } - print '<tr class="oddeven"><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoInvoice").'</span></td></tr>'; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++; + print '<tr class="oddeven"><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoInvoice").'</td></tr>'; @@ -277 +440,3 @@ - } else { + } + else + { @@ -282,0 +448 @@ + @@ -284 +450,2 @@ -if ((isModEnabled('fournisseur') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire")) || (isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) { +if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) +{ @@ -288 +455 @@ - $sql = "SELECT ff.rowid, ff.ref, ff.fk_statut as status, ff.type, ff.libelle, ff.total_ht, ff.total_tva, ff.total_ttc, ff.tms, ff.paye, ff.ref_supplier"; + $sql = "SELECT ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.total_tva, ff.total_ttc, ff.tms, ff.paye"; @@ -290,2 +457,2 @@ - $sql .= ", s.rowid as socid"; - $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.email"; + $sql .= ", s.rowid as socid"; + $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.email"; @@ -295,3 +462 @@ - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - } + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -300,6 +465,2 @@ - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); - } - if ($socid) { - $sql .= " AND ff.fk_soc = ".((int) $socid); - } + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND ff.fk_soc = ".$socid; @@ -311,2 +472,2 @@ - $sql .= " GROUP BY ff.rowid, ff.ref, ff.fk_statut, ff.type, ff.libelle, ff.total_ht, ff.tva, ff.total_tva, ff.total_ttc, ff.tms, ff.paye, ff.ref_supplier,"; - $sql .= " s.nom, s.rowid, s.code_fournisseur, s.code_compta_fournisseur, s.email"; + $sql .= " GROUP BY ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.tva, ff.total_tva, ff.total_ttc, ff.tms, ff.paye,"; + $sql .= " s.nom, s.rowid, s.code_fournisseur, s.code_compta_fournisseur"; @@ -317 +478,2 @@ - if ($resql) { + if ($resql) + { @@ -320 +482 @@ - print '<div class="div-table-responsive-no-min">'; + print '<div class="div-table-responsive-no-min">'; @@ -323,3 +485 @@ - if (getDolGlobalString('MAIN_SHOW_HT_ON_SUMMARY')) { - print '<th class="right">'.$langs->trans("AmountHT").'</th>'; - } + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<th class="right">'.$langs->trans("AmountHT").'</th>'; @@ -330 +490,2 @@ - if ($num) { + if ($num) + { @@ -332,4 +493,3 @@ - $total_ht = $total_ttc = $totalam = 0; - $othernb = 0; - - while ($i < $num) { + $total = $total_ttc = $totalam = 0; + while ($i < $num) + { @@ -337,8 +496,0 @@ - - if ($i >= $max) { - $othernb += 1; - $i++; - $total_ht += $obj->total_ht; - $total_ttc += $obj->total_ttc; - continue; - } @@ -351,4 +502,0 @@ - $facstatic->statut = $obj->status; - $facstatic->paye = $obj->paye; - $facstatic->type = $obj->type; - $facstatic->ref_supplier = $obj->ref_supplier; @@ -368 +516 @@ - print '<tr class="oddeven nowraponall tdoverflowmax100"><td>'; + print '<tr class="oddeven nowraponall"><td>'; @@ -371,10 +519,7 @@ - print '<td class="nowrap tdoverflowmax100">'; - print $thirdpartystatic->getNomUrl(1, 'supplier'); - print '</td>'; - if (getDolGlobalString('MAIN_SHOW_HT_ON_SUMMARY')) { - print '<td class="right"><span class="amount">'.price($obj->total_ht).'</span></td>'; - } - print '<td class="nowrap right"><span class="amount">'.price($obj->total_ttc).'</span></td>'; - print '<td class="right" title="'.dol_escape_htmltag($langs->trans("DateModificationShort").' : '.dol_print_date($db->jdate($obj->tms), 'dayhour', 'tzuserrel')).'">'.dol_print_date($db->jdate($obj->tms), 'day', 'tzuserrel').'</td>'; - $alreadypaid = $facstatic->getSommePaiement(); - print '<td>'.$facstatic->getLibStatut(3, $alreadypaid).'</td>'; + print '<td>'; + print $thirdpartystatic->getNomUrl(1, 'supplier', 44); + print '</td>'; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td class="right">'.price($obj->total_ht).'</td>'; + print '<td class="nowrap right">'.price($obj->total_ttc).'</td>'; + print '<td class="right">'.dol_print_date($db->jdate($obj->tms), 'day').'</td>'; + print '<td>'.$facstatic->LibStatut($obj->paye, $obj->fk_statut, 3).'</td>'; @@ -382 +527 @@ - $total_ht += $obj->total_ht; + $total += $obj->total_ht; @@ -387,9 +532,3 @@ - - if ($othernb) { - print '<tr class="oddeven">'; - print '<td class="nowrap" colspan="5">'; - print '<span class="opacitymedium">'.$langs->trans("More").'... ('.$othernb.')</span>'; - print '</td>'; - print "</tr>\n"; - } - } else { + } + else + { @@ -397,4 +536,2 @@ - if (getDolGlobalString('MAIN_SHOW_HT_ON_SUMMARY')) { - $colspan++; - } - print '<tr class="oddeven"><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoInvoice").'</span></td></tr>'; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++; + print '<tr class="oddeven"><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoInvoice").'</td></tr>'; @@ -403 +540,3 @@ - } else { + } + else + { @@ -411 +550,2 @@ -if (isModEnabled('don') && $user->hasRight('don', 'lire')) { +if (!empty($conf->don->enabled) && $user->rights->don->lire) +{ @@ -415,3 +555,3 @@ - $donationstatic = new Don($db); - - $sql = "SELECT d.rowid, d.lastname, d.firstname, d.societe, d.datedon as date, d.tms as dm, d.amount, d.fk_statut as status"; + $donationstatic = new Don($db); + + $sql = "SELECT d.rowid, d.lastname, d.firstname, d.societe, d.datedon as date, d.tms as dm, d.amount, d.fk_statut"; @@ -429 +569,3 @@ - if ($result) { + if ($result) + { + $var = false; @@ -433,3 +575,2 @@ - $othernb = 0; - - print '<div class="div-table-responsive-no-min">'; + + print '<div class="div-table-responsive-no-min">'; @@ -439,4 +580,4 @@ - print '<th></th>'; - print '<th class="right">'.$langs->trans("AmountTTC").'</th>'; - print '<th class="right">'.$langs->trans("DateModificationShort").'</th>'; - print '<th width="16"> </th>'; + print '<th></th>'; + print '<th class="right">'.$langs->trans("AmountTTC").'</th>'; + print '<th class="right">'.$langs->trans("DateModificationShort").'</th>'; + print '<th width="16"> </th>'; @@ -444,22 +585,12 @@ - - if ($num) { - $total_ttc = $totalam = $total_ht = 0; - - while ($i < $num && $i < $max) { - $obj = $db->fetch_object($result); - - if ($i >= $max) { - $othernb += 1; - $i++; - $total_ht += $obj->total_ht; - $total_ttc += $obj->total_ttc; - continue; - } - - $donationstatic->id = $obj->rowid; - $donationstatic->ref = $obj->rowid; - $donationstatic->lastname = $obj->lastname; - $donationstatic->firstname = $obj->firstname; - $donationstatic->date = $db->jdate($obj->date); - $donationstatic->statut = $obj->status; - $donationstatic->status = $obj->status; + if ($num) + { + $total_ttc = $totalam = $total = 0; + + while ($i < $num && $i < $max) + { + $objp = $db->fetch_object($result); + + $donationstatic->id = $objp->rowid; + $donationstatic->ref = $objp->rowid; + $donationstatic->lastname = $objp->lastname; + $donationstatic->firstname = $objp->firstname; @@ -468,5 +599,3 @@ - if ($obj->societe) { - $label .= ($label ? ' - ' : '').$obj->societe; - } - - print '<tr class="oddeven tdoverflowmax100">'; + if ($objp->societe) $label .= ($label ? ' - ' : '').$objp->societe; + + print '<tr class="oddeven">'; @@ -475,3 +604,3 @@ - print '<td class="nowrap right"><span class="amount">'.price($obj->amount).'</span></td>'; - print '<td class="right" title="'.dol_escape_htmltag($langs->trans("DateModificationShort").' : '.dol_print_date($db->jdate($obj->dm), 'dayhour', 'tzuserrel')).'">'.dol_print_date($db->jdate($obj->dm), 'day', 'tzuserrel').'</td>'; - print '<td>'.$donationstatic->getLibStatut(3).'</td>'; + print '<td class="nowrap right">'.price($objp->amount).'</td>'; + print '<td class="right">'.dol_print_date($db->jdate($objp->dm), 'day').'</td>'; + print '<td>'.$donationstatic->LibStatut($objp->fk_statut, 3).'</td>'; @@ -482,10 +611,4 @@ - - if ($othernb) { - print '<tr class="oddeven">'; - print '<td class="nowrap" colspan="5">'; - print '<span class="opacitymedium">'.$langs->trans("More").'... ('.$othernb.')</span>'; - print '</td>'; - print "</tr>\n"; - } - } else { - print '<tr class="oddeven"><td colspan="5"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>'; + } + else + { + print '<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans("None").'</td></tr>'; @@ -494,3 +617,2 @@ - } else { - dol_print_error($db); - } + } + else dol_print_error($db); @@ -502,2 +624,4 @@ -if (isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) { - if (!$socid) { +if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) +{ + if (!$socid) + { @@ -522 +646,2 @@ - if ($resql) { + if ($resql) + { @@ -525 +650 @@ - print '<div class="div-table-responsive-no-min">'; + print '<div class="div-table-responsive-no-min">'; @@ -534 +659,2 @@ - if ($num) { + if ($num) + { @@ -537,3 +663,2 @@ - $othernb = 0; - - while ($i < $num) { + while ($i < $num) + { @@ -541,7 +665,0 @@ - - if ($i >= $max) { - $othernb += 1; - $tot_ttc += $obj->amount; - $i++; - continue; - } @@ -553 +670,0 @@ - $chargestatic->status = $obj->paye; @@ -556 +673 @@ - print '<td class="nowraponall">'.$chargestatic->getNomUrl(1).'</td>'; + print '<td>'.$chargestatic->getNomUrl(1).'</td>'; @@ -558,2 +675,2 @@ - print '<td class="nowrap right"><span class="amount">'.price($obj->amount).'</span></td>'; - print '<td class="nowrap right"><span class="amount">'.price($obj->sumpaid).'</span></td>'; + print '<td class="nowrap right">'.price($obj->amount).'</td>'; + print '<td class="nowrap right">'.price($obj->sumpaid).'</td>'; @@ -565,8 +681,0 @@ - } - - if ($othernb) { - print '<tr class="oddeven">'; - print '<td class="nowrap" colspan="5">'; - print '<span class="opacitymedium">'.$langs->trans("More").'... ('.$othernb.')</span>'; - print '</td>'; - print "</tr>\n"; @@ -580,2 +689,4 @@ - } else { - print '<tr class="oddeven"><td colspan="5"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>'; + } + else + { + print '<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans("None").'</td></tr>'; @@ -585 +696,3 @@ - } else { + } + else + { @@ -594 +707,2 @@ -if (isModEnabled('facture') && isModEnabled('commande') && $user->hasRight("commande", "lire") && !getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) { +if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user->rights->commande->lire && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) +{ @@ -598 +712 @@ - $sql = "SELECT sum(f.total_ht) as tot_fht, sum(f.total_ttc) as tot_fttc"; + $sql = "SELECT sum(f.total) as tot_fht, sum(f.total_ttc) as tot_fttc"; @@ -600,3 +714,3 @@ - $sql .= ", s.rowid as socid"; - $sql .= ", s.code_client, s.code_compta"; - $sql .= ", c.rowid, c.ref, c.facture, c.fk_statut as status, c.total_ht, c.total_tva, c.total_ttc,"; + $sql .= ", s.rowid as socid"; + $sql .= ", s.code_client, s.code_compta"; + $sql .= ", c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.tva as total_tva, c.total_ttc,"; @@ -605,3 +719 @@ - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - } + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -613,7 +725,3 @@ - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); - } - if ($socid) { - $sql .= " AND c.fk_soc = ".((int) $socid); - } - $sql .= " AND c.fk_statut = ".Commande::STATUS_CLOSED; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND c.fk_soc = ".$socid; + $sql .= " AND c.fk_statut = 3"; @@ -626 +734 @@ - $sql .= " GROUP BY s.nom, s.email, s.rowid, s.code_client, s.code_compta, c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.total_tva, c.total_ttc, cc.rowid, cc.code"; + $sql .= " GROUP BY s.nom, s.email, s.rowid, s.code_client, s.code_compta, c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.tva, c.total_ttc, cc.rowid, cc.code"; @@ -629 +737,2 @@ - if ($resql) { + if ($resql) + { @@ -632 +741,2 @@ - if ($num) { + if ($num) + { @@ -634,3 +744,2 @@ - $othernb = 0; - - print '<div class="div-table-responsive-no-min">'; + + print '<div class="div-table-responsive-no-min">'; @@ -638 +746,0 @@ - @@ -640,10 +748,2 @@ - print '<th colspan="2">'; - print $langs->trans("OrdersDeliveredToBill").' '; - print '<a href="'.DOL_URL_ROOT.'/commande/list.php?search_status='.Commande::STATUS_CLOSED.'&billed=0">'; - print '<span class="badge">'.$num.'</span>'; - print '</a>'; - print '</th>'; - - if (getDolGlobalString('MAIN_SHOW_HT_ON_SUMMARY')) { - print '<th class="right">'.$langs->trans("AmountHT").'</th>'; - } + print '<th colspan="2">'.$langs->trans("OrdersDeliveredToBill").' <a href="'.DOL_URL_ROOT.'/commande/list.php?search_status=3&billed=0"><span class="badge">'.$num.'</span></a></th>'; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<th class="right">'.$langs->trans("AmountHT").'</th>'; @@ -657 +757,2 @@ - while ($i < $num) { + while ($i < $num) + { @@ -659,8 +759,0 @@ - - if ($i >= $max) { - $othernb += 1; - $i++; - $total_ht += $obj->total_ht; - $total_ttc += $obj->total_ttc; - continue; - } @@ -681,2 +773,0 @@ - $commandestatic->statut = $obj->status; - $commandestatic->billed = $obj->facture; @@ -688 +779 @@ - print '<td class="nobordernopadding nowrap">'; + print '<td width="110" class="nobordernopadding nowrap">'; @@ -703,9 +794,7 @@ - print '<td class="nowrap tdoverflowmax100">'; - print $societestatic->getNomUrl(1, 'customer'); - print '</td>'; - if (getDolGlobalString('MAIN_SHOW_HT_ON_SUMMARY')) { - print '<td class="right"><span class="amount">'.price($obj->total_ht).'</span></td>'; - } - print '<td class="nowrap right"><span class="amount">'.price($obj->total_ttc).'</span></td>'; - print '<td class="nowrap right"><span class="amount">'.price($obj->total_ttc - $obj->tot_fttc).'</span></td>'; - print '<td>'.$commandestatic->getLibStatut(3).'</td>'; + print '<td class="left">'; + print $societestatic->getNomUrl(1, 'customer', 44); + print '</td>'; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td class="right">'.price($obj->total_ht).'</td>'; + print '<td class="nowrap right">'.price($obj->total_ttc).'</td>'; + print '<td class="nowrap right">'.price($obj->total_ttc - $obj->tot_fttc).'</td>'; + print '<td>'.$commandestatic->LibStatut($obj->fk_statut, $obj->facture, 3).'</td>'; @@ -720,12 +809,2 @@ - if ($othernb) { - print '<tr class="oddeven">'; - print '<td class="nowrap" colspan="5">'; - print '<span class="opacitymedium">'.$langs->trans("More").'... ('.$othernb.')</span>'; - print '</td>'; - print "</tr>\n"; - } - - print '<tr class="liste_total"><td colspan="2">'.$langs->trans("Total").' <span style="font-weight: normal">('.$langs->trans("RemainderToBill").': '.price($tot_tobill).')</span> </td>'; - if (getDolGlobalString('MAIN_SHOW_HT_ON_SUMMARY')) { - print '<td class="right">'.price($tot_ht).'</td>'; - } + print '<tr class="liste_total"><td colspan="2">'.$langs->trans("Total").' <font style="font-weight: normal">('.$langs->trans("RemainderToBill").': '.price($tot_tobill).')</font> </td>'; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td class="right">'.price($tot_ht).'</td>'; @@ -739 +818,3 @@ - } else { + } + else + { @@ -743,0 +825,243 @@ +/* + * Unpaid customers invoices + */ +if (!empty($conf->facture->enabled) && $user->rights->facture->lire) +{ + $facstatic = new Facture($db); + + $sql = "SELECT f.rowid, f.ref, f.fk_statut, f.datef, f.type, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.paye, f.tms"; + $sql .= ", f.date_lim_reglement as datelimite"; + $sql .= ", s.nom as name"; + $sql .= ", s.rowid as socid, s.email"; + $sql .= ", s.code_client, s.code_compta"; + $sql .= ", cc.rowid as country_id, cc.code as country_code"; + $sql .= ", sum(pf.amount) as am"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays,".MAIN_DB_PREFIX."facture as f"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE s.rowid = f.fk_soc AND f.paye = 0 AND f.fk_statut = 1"; + $sql .= " AND f.entity IN (".getEntity('invoice').')'; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND f.fk_soc = ".$socid; + // Add where from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListWhereCustomerUnpaid', $parameters); + $sql .= $hookmanager->resPrint; + + $sql .= " GROUP BY f.rowid, f.ref, f.fk_statut, f.datef, f.type, f.total, f.tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement,"; + $sql .= " s.nom, s.rowid, s.email, s.code_client, s.code_compta, cc.rowid, cc.code"; + $sql .= " ORDER BY f.datef ASC, f.ref ASC"; + + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + + print '<div class="div-table-responsive-no-min">'; + print '<table class="noborder centpercent">'; + print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("BillsCustomersUnpaid", $num).' <a href="'.DOL_URL_ROOT.'/compta/facture/list.php?search_status=1"><span class="badge">'.$num.'</span></a></th>'; + print '<th class="right">'.$langs->trans("DateDue").'</th>'; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<th class="right">'.$langs->trans("AmountHT").'</th>'; + print '<th class="right">'.$langs->trans("AmountTTC").'</th>'; + print '<th class="right">'.$langs->trans("Received").'</th>'; + print '<th width="16"> </th>'; + print '</tr>'; + if ($num) + { + $societestatic = new Societe($db); + $total_ttc = $totalam = $total = 0; + while ($i < $num && $i < $conf->liste_limit) + { + $obj = $db->fetch_object($resql); + + $facturestatic->ref = $obj->ref; + $facturestatic->id = $obj->rowid; + $facturestatic->total_ht = $obj->total_ht; + $facturestatic->total_tva = $obj->total_tva; + $facturestatic->total_ttc = $obj->total_ttc; + $facturestatic->type = $obj->type; + $facturestatic->statut = $obj->fk_statut; + $facturestatic->date_lim_reglement = $db->jdate($obj->datelimite); + + $societestatic->id = $obj->socid; + $societestatic->name = $obj->name; + $societestatic->email = $obj->email; + $societestatic->country_id = $obj->country_id; + $societestatic->country_code = $obj->country_code; + $societestatic->client = 1; + $societestatic->code_client = $obj->code_client; + $societestatic->code_fournisseur = $obj->code_fournisseur; + $societestatic->code_compta = $obj->code_compta; + $societestatic->code_compta_fournisseur = $obj->code_compta_fournisseur; + + print '<tr class="oddeven">'; + print '<td class="nowrap">'; + + print '<table class="nobordernopadding"><tr class="nocellnopadd">'; + print '<td width="110" class="nobordernopadding nowrap">'; + print $facturestatic->getNomUrl(1, ''); + print '</td>'; + print '<td width="20" class="nobordernopadding nowrap">'; + if ($facturestatic->hasDelay()) { + print img_warning($langs->trans("Late")); + } + print '</td>'; + print '<td width="16" class="nobordernopadding hideonsmartphone right">'; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?facid='.$obj->rowid; + print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir); + print '</td></tr></table>'; + + print '</td>'; + print '<td class="left">'; + print $societestatic->getNomUrl(1, 'customer', 44); + print '</td>'; + print '<td class="right">'.dol_print_date($db->jdate($obj->datelimite), 'day').'</td>'; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td class="right">'.price($obj->total_ht).'</td>'; + print '<td class="nowrap right">'.price($obj->total_ttc).'</td>'; + print '<td class="nowrap right">'.price($obj->am).'</td>'; + print '<td>'.$facstatic->LibStatut($obj->paye, $obj->fk_statut, 3, $obj->am).'</td>'; + print '</tr>'; + + $total_ttc += $obj->total_ttc; + $total += $obj->total_ht; + $totalam += $obj->am; + + $i++; + } + + print '<tr class="liste_total"><td colspan="2">'.$langs->trans("Total").' <font style="font-weight: normal">('.$langs->trans("RemainderToTake").': '.price($total_ttc - $totalam).')</font> </td>'; + print '<td> </td>'; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td class="right">'.price($total).'</td>'; + print '<td class="nowrap right">'.price($total_ttc).'</td>'; + print '<td class="nowrap right">'.price($totalam).'</td>'; + print '<td> </td>'; + print '</tr>'; + } + else + { + $colspan = 6; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++; + print '<tr class="oddeven"><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoInvoice").'</td></tr>'; + } + print '</table></div><br>'; + $db->free($resql); + } + else + { + dol_print_error($db); + } +} + +/* + * Unpayed supplier invoices + */ +if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) +{ + $facstatic = new FactureFournisseur($db); + + $sql = "SELECT ff.rowid, ff.ref, ff.fk_statut, ff.libelle as label, ff.total_ht, ff.total_tva, ff.total_ttc, ff.paye"; + $sql .= ", ff.date_lim_reglement"; + $sql .= ", s.nom as name"; + $sql .= ", s.rowid as socid, s.email"; + $sql .= ", s.code_client, s.code_compta"; + $sql .= ", s.code_fournisseur, s.code_compta_fournisseur"; + $sql .= ", sum(pf.amount) as am"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as ff"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE s.rowid = ff.fk_soc"; + $sql .= " AND ff.entity = ".$conf->entity; + $sql .= " AND ff.paye = 0"; + $sql .= " AND ff.fk_statut = 1"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND ff.fk_soc = ".$socid; + // Add where from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListWhereSupplierUnpaid', $parameters); + $sql .= $hookmanager->resPrint; + + $sql .= " GROUP BY ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.tva, ff.total_tva, ff.total_ttc, ff.paye, ff.date_lim_reglement,"; + $sql .= " s.nom, s.rowid, s.email, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur"; + $sql .= " ORDER BY ff.date_lim_reglement ASC"; + + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + + print '<div class="div-table-responsive-no-min">'; + print '<table class="noborder centpercent">'; + print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("BillsSuppliersUnpaid", $num).' <a href="'.DOL_URL_ROOT.'/fourn/facture/impayees.php"><span class="badge">'.$num.'</span></a></th>'; + print '<th class="right">'.$langs->trans("DateDue").'</th>'; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<th class="right">'.$langs->trans("AmountHT").'</th>'; + print '<th class="right">'.$langs->trans("AmountTTC").'</th>'; + print '<th class="right">'.$langs->trans("Paid").'</th>'; + print '<th width="16"> </th>'; + print "</tr>\n"; + $societestatic = new Societe($db); + if ($num) + { + $i = 0; + $total = $total_ttc = $totalam = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + + $facstatic->ref = $obj->ref; + $facstatic->id = $obj->rowid; + $facstatic->total_ht = $obj->total_ht; + $facstatic->total_tva = $obj->total_tva; + $facstatic->total_ttc = $obj->total_ttc; + + $societestatic->id = $obj->socid; + $societestatic->name = $obj->name; + $societestatic->email = $obj->email; + $societestatic->client = 0; + $societestatic->fournisseur = 1; + $societestatic->code_client = $obj->code_client; + $societestatic->code_fournisseur = $obj->code_fournisseur; + $societestatic->code_compta = $obj->code_compta; + $societestatic->code_compta_fournisseur = $obj->code_compta_fournisseur; + + print '<tr class="oddeven"><td>'; + print $facstatic->getNomUrl(1, ''); + print '</td>'; + print '<td>'.$societestatic->getNomUrl(1, 'supplier', 44).'</td>'; + print '<td class="right">'.dol_print_date($db->jdate($obj->date_lim_reglement), 'day').'</td>'; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td class="right">'.price($obj->total_ht).'</td>'; + print '<td class="nowrap right">'.price($obj->total_ttc).'</td>'; + print '<td class="nowrap right">'.price($obj->am).'</td>'; + print '<td>'.$facstatic->LibStatut($obj->paye, $obj->fk_statut, 3).'</td>'; + print '</tr>'; + $total += $obj->total_ht; + $total_ttc += $obj->total_ttc; + $totalam += $obj->am; + $i++; + } + + print '<tr class="liste_total"><td colspan="2">'.$langs->trans("Total").' <font style="font-weight: normal">('.$langs->trans("RemainderToPay").': '.price($total_ttc - $totalam).')</font> </td>'; + print '<td> </td>'; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td class="right">'.price($total).'</td>'; + print '<td class="nowrap right">'.price($total_ttc).'</td>'; + print '<td class="nowrap right">'.price($totalam).'</td>'; + print '<td> </td>'; + print '</tr>'; + } + else + { + $colspan = 6; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++; + print '<tr class="oddeven"><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoInvoice").'</td></tr>'; + } + print '</table></div><br>'; + } + else + { + dol_print_error($db); + } +} + + @@ -746,3 +1070,4 @@ -$sql = ''; -if ($sql) { - print '<div class="div-table-responsive-no-min">'; +$resql = 0; +if ($resql) +{ + print '<div class="div-table-responsive-no-min">'; @@ -753,12 +1078,9 @@ - $resql = $db->query($sql); - if ($resql) { - $num_rows = $db->num_rows($resql); - while ($i < $num_rows) { - $obj = $db->fetch_object($resql); - - print '<tr class="oddeven"><td>'.dol_print_date($db->jdate($obj->da), "day").'</td>'; - print '<td><a href="action/card.php">'.$obj->label.'</a></td></tr>'; - $i++; - } - $db->free($resql); - } + while ($i < $db->num_rows($resql)) + { + $obj = $db->fetch_object($resql); + + print '<tr class="oddeven"><td>'.dol_print_date($db->jdate($obj->da), "day").'</td>'; + print '<td><a href="action/card.php">'.$obj->label.'</a></td></tr>'; + $i++; + } + $db->free($resql); @@ -769 +1091 @@ -print '</div></div>'; +print '</div></div></div>'; --- /tmp/dsg/dolibarr/htdocs/compta/github_19.0.3_paiement.php +++ /tmp/dsg/dolibarr/htdocs/compta/client_paiement.php @@ -11,4 +11 @@ - * Copyright (C) 2018-2021 Frédéric France <frederic.france@netlogic.fr> - * Copyright (C) 2023 Lenin Rivas <lenin.rivas777@gmail.com> - * Copyright (C) 2023 Sylvain Legrand <technique@infras.fr> - * Copyright (C) 2023 William Mead <william.mead@manchenumerique.fr> + * Copyright (C) 2018-2019 Frédéric France <frederic.france@netlogic.fr> @@ -36 +32,0 @@ -// Load Dolibarr environment @@ -54,2 +50,2 @@ -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); @@ -66,2 +62,3 @@ -if ($user->socid > 0) { - $socid = $user->socid; +if ($user->socid > 0) +{ + $socid = $user->socid; @@ -73 +70,2 @@ -if ($facid > 0) { +if ($facid > 0) +{ @@ -81,6 +78,0 @@ - -$usercanissuepayment = $user->hasRight('facture', 'paiement'); - -$fieldid = 'rowid'; -$isdraft = (($object->statut == Facture::STATUS_DRAFT) ? 1 : 0); -$result = restrictedArea($user, 'facture', $object->id, '', '', 'fk_soc', $fieldid, $isdraft); @@ -95,11 +87,11 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -if (empty($reshook)) { - if (($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm == 'yes')) && $usercanissuepayment) { - $error = 0; - - $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - $paiement_id = 0; - $totalpayment = 0; +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm == 'yes')) + { + $error = 0; + + $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); + $paiement_id = 0; + $totalpayment = 0; @@ -107 +99 @@ - $atleastonepaymentnotnull = 0; + $atleastonepaymentnotnull = 0; @@ -111,31 +103,34 @@ - // Generate payment array and check if there is payment higher than invoice and payment date before invoice date - $tmpinvoice = new Facture($db); - foreach ($_POST as $key => $value) { - if (substr($key, 0, 7) == 'amount_' && GETPOST($key) != '') { - $cursorfacid = substr($key, 7); - $amounts[$cursorfacid] = price2num(GETPOST($key)); - $totalpayment = $totalpayment + $amounts[$cursorfacid]; - if (!empty($amounts[$cursorfacid])) { - $atleastonepaymentnotnull++; - } - $result = $tmpinvoice->fetch($cursorfacid); - if ($result <= 0) { - dol_print_error($db); - } - $amountsresttopay[$cursorfacid] = price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement()); - if ($amounts[$cursorfacid]) { - // Check amount - if ($amounts[$cursorfacid] && (abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid]))) { - $addwarning = 1; - $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay"); - } - // Check date - if ($datepaye && ($datepaye < $tmpinvoice->date)) { - $langs->load("errors"); - //$error++; - setEventMessages($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye, 'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), null, 'warnings'); - } - } - - $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => GETPOST($key)); - } elseif (substr($key, 0, 21) == 'multicurrency_amount_') { + // Generate payment array and check if there is payment higher than invoice and payment date before invoice date + $tmpinvoice = new Facture($db); + foreach ($_POST as $key => $value) + { + if (substr($key, 0, 7) == 'amount_' && GETPOST($key) != '') + { + $cursorfacid = substr($key, 7); + $amounts[$cursorfacid] = price2num(trim(GETPOST($key))); + $totalpayment = $totalpayment + $amounts[$cursorfacid]; + if (!empty($amounts[$cursorfacid])) $atleastonepaymentnotnull++; + $result = $tmpinvoice->fetch($cursorfacid); + if ($result <= 0) dol_print_error($db); + $amountsresttopay[$cursorfacid] = price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement()); + if ($amounts[$cursorfacid]) + { + // Check amount + if ($amounts[$cursorfacid] && (abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid]))) + { + $addwarning = 1; + $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay"); + } + // Check date + if ($datepaye && ($datepaye < $tmpinvoice->date)) + { + $langs->load("errors"); + //$error++; + setEventMessages($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye, 'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), null, 'warnings'); + } + } + + $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => $_POST[$key]); + } + elseif (substr($key, 0, 21) == 'multicurrency_amount_') + { @@ -143,25 +138,24 @@ - $multicurrency_amounts[$cursorfacid] = price2num(GETPOST($key)); - $multicurrency_totalpayment += (float) $multicurrency_amounts[$cursorfacid]; - if (!empty($multicurrency_amounts[$cursorfacid])) { - $atleastonepaymentnotnull++; - } - $result = $tmpinvoice->fetch($cursorfacid); - if ($result <= 0) { - dol_print_error($db); - } - $multicurrency_amountsresttopay[$cursorfacid] = price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1)); - if ($multicurrency_amounts[$cursorfacid]) { - // Check amount - if ($multicurrency_amounts[$cursorfacid] && (abs($multicurrency_amounts[$cursorfacid]) > abs($multicurrency_amountsresttopay[$cursorfacid]))) { - $addwarning = 1; - $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay"); - } - // Check date - if ($datepaye && ($datepaye < $tmpinvoice->date)) { - $langs->load("errors"); - //$error++; - setEventMessages($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye, 'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), null, 'warnings'); - } - } - - $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => GETPOST($key, 'int')); + $multicurrency_amounts[$cursorfacid] = price2num(trim(GETPOST($key))); + $multicurrency_totalpayment += $multicurrency_amounts[$cursorfacid]; + if (!empty($multicurrency_amounts[$cursorfacid])) $atleastonepaymentnotnull++; + $result = $tmpinvoice->fetch($cursorfacid); + if ($result <= 0) dol_print_error($db); + $multicurrency_amountsresttopay[$cursorfacid] = price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1)); + if ($multicurrency_amounts[$cursorfacid]) + { + // Check amount + if ($multicurrency_amounts[$cursorfacid] && (abs($multicurrency_amounts[$cursorfacid]) > abs($multicurrency_amountsresttopay[$cursorfacid]))) + { + $addwarning = 1; + $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay"); + } + // Check date + if ($datepaye && ($datepaye < $tmpinvoice->date)) + { + $langs->load("errors"); + //$error++; + setEventMessages($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye, 'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), null, 'warnings'); + } + } + + $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => GETPOST($key, 'int')); @@ -169,25 +163,30 @@ - } - - // Check parameters - if (!GETPOST('paiementcode')) { - setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('PaymentMode')), null, 'errors'); - $error++; - } - - if (isModEnabled("banque")) { - // If bank module is on, account is required to enter a payment - if (GETPOST('accountid') <= 0) { - setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('AccountToCredit')), null, 'errors'); - $error++; - } - } - - if (empty($totalpayment) && empty($multicurrency_totalpayment) && empty($atleastonepaymentnotnull)) { - setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->trans('PaymentAmount')), null, 'errors'); - $error++; - } - - if (empty($datepaye)) { - setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('Date')), null, 'errors'); - $error++; - } + } + + // Check parameters + if (!GETPOST('paiementcode')) + { + setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('PaymentMode')), null, 'errors'); + $error++; + } + + if (!empty($conf->banque->enabled)) + { + // If bank module is on, account is required to enter a payment + if (GETPOST('accountid') <= 0) + { + setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('AccountToCredit')), null, 'errors'); + $error++; + } + } + + if (empty($totalpayment) && empty($multicurrency_totalpayment) && empty($atleastonepaymentnotnull)) + { + setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->trans('PaymentAmount')), null, 'errors'); + $error++; + } + + if (empty($datepaye)) + { + setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('Date')), null, 'errors'); + $error++; + } @@ -196,2 +195,2 @@ - if ($totalpayment > 0 && $multicurrency_totalpayment > 0) { - $langs->load("errors"); + if ($totalpayment > 0 && $multicurrency_totalpayment > 0) + { @@ -199 +198 @@ - $error++; + $error++; @@ -206,5 +205,7 @@ - if ($action == 'add_paiement') { - if ($error) { - $action = 'create'; - } - // The next of this action is displayed at the page's bottom. + if ($action == 'add_paiement') + { + if ($error) + { + $action = 'create'; + } + // Le reste propre a cette action s'affiche en bas de page. @@ -216,106 +217,103 @@ - if ($action == 'confirm_paiement' && $confirm == 'yes' && $usercanissuepayment) { - $error = 0; - - $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'), 'tzuser'); - - $db->begin(); - - $thirdparty = new Societe($db); - if ($socid > 0) { - $thirdparty->fetch($socid); - } - - $multicurrency_code = array(); - $multicurrency_tx = array(); - - // Clean parameters amount if payment is for a credit note - foreach ($amounts as $key => $value) { // How payment is dispatched - $tmpinvoice = new Facture($db); - $tmpinvoice->fetch($key); - if ($tmpinvoice->type == Facture::TYPE_CREDIT_NOTE) { - $newvalue = price2num($value, 'MT'); - $amounts[$key] = - abs($newvalue); - } - $multicurrency_code[$key] = $tmpinvoice->multicurrency_code; - $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx; - } - - foreach ($multicurrency_amounts as $key => $value) { // How payment is dispatched - $tmpinvoice = new Facture($db); - $tmpinvoice->fetch($key); - if ($tmpinvoice->type == Facture::TYPE_CREDIT_NOTE) { - $newvalue = price2num($value, 'MT'); - $multicurrency_amounts[$key] = - abs($newvalue); - } - $multicurrency_code[$key] = $tmpinvoice->multicurrency_code; - $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx; - } - - if (isModEnabled("banque")) { - // If the bank module is active, an account is required to input a payment - if (GETPOST('accountid', 'int') <= 0) { - setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('AccountToCredit')), null, 'errors'); - $error++; - } - } - - // Creation of payment line - $paiement = new Paiement($db); - $paiement->datepaye = $datepaye; - $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id - $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching - $paiement->multicurrency_code = $multicurrency_code; // Array with all currency of payments dispatching - $paiement->multicurrency_tx = $multicurrency_tx; // Array with all currency tx of payments dispatching - $paiement->paiementid = dol_getIdFromCode($db, GETPOST('paiementcode'), 'c_paiement', 'code', 'id', 1); - $paiement->num_payment = GETPOST('num_paiement', 'alpha'); - $paiement->note_private = GETPOST('comment', 'alpha'); - $paiement->fk_account = GETPOST('accountid', 'int'); - - if (!$error) { - // Create payment and update this->multicurrency_amounts if this->amounts filled or - // this->amounts if this->multicurrency_amounts filled. - // This also set ->amount and ->multicurrency_amount - $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices') == 'on' ? 1 : 0), $thirdparty); // This include closing invoices and regenerating documents - if ($paiement_id < 0) { - setEventMessages($paiement->error, $paiement->errors, 'errors'); - $error++; - } - } - - if (!$error) { - $label = '(CustomerInvoicePayment)'; - if (GETPOST('type') == Facture::TYPE_CREDIT_NOTE) { - $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note - } - $result = $paiement->addPaymentToBank($user, 'payment', $label, GETPOST('accountid', 'int'), GETPOST('chqemetteur'), GETPOST('chqbank')); - if ($result < 0) { - setEventMessages($paiement->error, $paiement->errors, 'errors'); - $error++; - } - } - - if (!$error) { - $db->commit(); - - // If payment dispatching on more than one invoice, we stay on summary page, otherwise jump on invoice card - $invoiceid = 0; - foreach ($paiement->amounts as $key => $amount) { - $facid = $key; - if (is_numeric($amount) && $amount != 0) { - if ($invoiceid != 0) { - $invoiceid = -1; // There is more than one invoice payed by this payment - } else { - $invoiceid = $facid; - } - } - } - if ($invoiceid > 0) { - $loc = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$invoiceid; - } else { - $loc = DOL_URL_ROOT.'/compta/paiement/card.php?id='.$paiement_id; - } - header('Location: '.$loc); - exit; - } else { - $db->rollback(); - } + if ($action == 'confirm_paiement' && $confirm == 'yes') + { + $error = 0; + + $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); + + $db->begin(); + + $thirdparty = new Societe($db); + if ($socid > 0) $thirdparty->fetch($socid); + + // Clean parameters amount if payment is for a credit note + foreach ($amounts as $key => $value) // How payment is dispatched + { + $tmpinvoice = new Facture($db); + $tmpinvoice->fetch($key); + if ($tmpinvoice->type == Facture::TYPE_CREDIT_NOTE) + { + $newvalue = price2num($value, 'MT'); + $amounts[$key] = - abs($newvalue); + } + } + + foreach ($multicurrency_amounts as $key => $value) // How payment is dispatched + { + $tmpinvoice = new Facture($db); + $tmpinvoice->fetch($key); + if ($tmpinvoice->type == Facture::TYPE_CREDIT_NOTE) + { + $newvalue = price2num($value, 'MT'); + $multicurrency_amounts[$key] = - abs($newvalue); + } + } + + if (!empty($conf->banque->enabled)) + { + // Si module bank actif, un compte est obligatoire lors de la saisie d'un paiement + if (GETPOST('accountid', 'int') <= 0) + { + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('AccountToCredit')), null, 'errors'); + $error++; + } + } + + // Creation of payment line + $paiement = new Paiement($db); + $paiement->datepaye = $datepaye; + $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id + $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching + $paiement->paiementid = dol_getIdFromCode($db, GETPOST('paiementcode'), 'c_paiement', 'code', 'id', 1); + $paiement->num_payment = GETPOST('num_paiement', 'alpha'); + $paiement->note_private = GETPOST('comment', 'alpha'); + $paiement->num_paiement = $paiement->num_payment; // For bacward compatibility + $paiement->note = $paiement->note_private; // For bacward compatibility + + if (!$error) + { + // Create payment and update this->multicurrency_amounts if this->amounts filled or + // this->amounts if this->multicurrency_amounts filled. + $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices') == 'on' ? 1 : 0), $thirdparty); // This include closing invoices and regenerating documents + if ($paiement_id < 0) + { + setEventMessages($paiement->error, $paiement->errors, 'errors'); + $error++; + } + } + + if (!$error) + { + $label = '(CustomerInvoicePayment)'; + if (GETPOST('type') == Facture::TYPE_CREDIT_NOTE) $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note + $result = $paiement->addPaymentToBank($user, 'payment', $label, GETPOST('accountid'), GETPOST('chqemetteur'), GETPOST('chqbank')); + if ($result < 0) + { + setEventMessages($paiement->error, $paiement->errors, 'errors'); + $error++; + } + } + + if (!$error) + { + $db->commit(); + + // If payment dispatching on more than one invoice, we stay on summary page, otherwise jump on invoice card + $invoiceid = 0; + foreach ($paiement->amounts as $key => $amount) + { + $facid = $key; + if (is_numeric($amount) && $amount <> 0) + { + if ($invoiceid != 0) $invoiceid = -1; // There is more than one invoice payed by this payment + else $invoiceid = $facid; + } + } + if ($invoiceid > 0) $loc = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$invoiceid; + else $loc = DOL_URL_ROOT.'/compta/paiement/card.php?id='.$paiement_id; + header('Location: '.$loc); + exit; + } + else + { + $db->rollback(); + } @@ -337 +335,2 @@ -if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paiement') { +if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paiement') +{ @@ -341 +340,2 @@ - if ($result >= 0) { + if ($result >= 0) + { @@ -345,6 +345,2 @@ - if ($facture->type != Facture::TYPE_CREDIT_NOTE) { - $title .= $langs->trans("EnterPaymentReceivedFromCustomer"); - } - if ($facture->type == Facture::TYPE_CREDIT_NOTE) { - $title .= $langs->trans("EnterPaymentDueToCustomer"); - } + if ($facture->type != Facture::TYPE_CREDIT_NOTE) $title .= $langs->trans("EnterPaymentReceivedFromCustomer"); + if ($facture->type == Facture::TYPE_CREDIT_NOTE) $title .= $langs->trans("EnterPaymentDueToCustomer"); @@ -354 +350,2 @@ - if ($action == 'add_paiement') { + if ($action == 'add_paiement') + { @@ -364,4 +361,3 @@ - if (isModEnabled('paypalplus') && $conf->global->PAYPAL_ENABLE_TRANSACTION_MANAGEMENT && !empty($facture->ref_ext)) { - if (getDolGlobalString('PAYPAL_BANK_ACCOUNT')) { - $accountid = $conf->global->PAYPAL_BANK_ACCOUNT; - } + if (!empty($conf->paypalplus->enabled) && $conf->global->PAYPAL_ENABLE_TRANSACTION_MANAGEMENT && !empty($facture->ref_ext)) + { + if (!empty($conf->global->PAYPAL_BANK_ACCOUNT)) $accountid = $conf->global->PAYPAL_BANK_ACCOUNT; @@ -372,2 +368,3 @@ - if (!empty($conf->use_javascript_ajax)) { - print "\n".'<script type="text/javascript">'; + if (!empty($conf->use_javascript_ajax)) + { + print "\n".'<script type="text/javascript" language="javascript">'; @@ -384 +380,0 @@ - console.log("setPaiementCode code="+code); @@ -394 +390 @@ - var emetteur = ('.$facture->type.' == '.Facture::TYPE_CREDIT_NOTE.') ? \''.dol_escape_js(dol_escape_htmltag(getDolGlobalString('MAIN_INFO_SOCIETE_NOM'))).'\' : jQuery(\'#thirdpartylabel\').val(); + var emetteur = ('.$facture->type.' == '.Facture::TYPE_CREDIT_NOTE.') ? \''.dol_escape_js(dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_NOM)).'\' : jQuery(\'#thirdpartylabel\').val(); @@ -424 +420 @@ - json["token"] = "'.currentToken().'"; + @@ -480,3 +476,2 @@ - print '<input type="hidden" name="page_y" value="">'; - - print dol_get_fiche_head(); + + dol_fiche_head(); @@ -486,52 +481,49 @@ - // Third party - print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans('Company').'</span></td><td>'.$facture->thirdparty->getNomUrl(4)."</td></tr>\n"; - - // Date payment - print '<tr><td><span class="fieldrequired">'.$langs->trans('Date').'</span></td><td>'; - $datepayment = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - $datepayment = ($datepayment == '' ? (!getDolGlobalString('MAIN_AUTOFILL_DATE') ? -1 : '') : $datepayment); - print $form->selectDate($datepayment, '', '', '', 0, "add_paiement", 1, 1, 0, '', '', $facture->date); - print '</td></tr>'; - - // Payment mode - print '<tr><td><span class="fieldrequired">'.$langs->trans('PaymentMode').'</span></td><td>'; - $form->select_types_paiements((GETPOST('paiementcode') ? GETPOST('paiementcode') : $facture->mode_reglement_code), 'paiementcode', '', 2); - print "</td>\n"; - print '</tr>'; - - // Bank account - print '<tr>'; - if (isModEnabled("banque")) { - if ($facture->type != 2) { - print '<td><span class="fieldrequired">'.$langs->trans('AccountToCredit').'</span></td>'; - } - if ($facture->type == 2) { - print '<td><span class="fieldrequired">'.$langs->trans('AccountToDebit').'</span></td>'; - } - - print '<td>'; - print img_picto('', 'bank_account'); - print $form->select_comptes($accountid, 'accountid', 0, '', 2, '', 0, 'widthcentpercentminusx maxwidth500', 1); - print '</td>'; - } else { - print '<td> </td>'; - } - print "</tr>\n"; - - // Bank check number - print '<tr><td>'.$langs->trans('Numero'); - print ' <em class="opacitymedium">('.$langs->trans("ChequeOrTransferNumber").')</em>'; - print '</td>'; - print '<td><input name="num_paiement" type="text" class="maxwidth200" value="'.$paymentnum.'"></td></tr>'; - - // Check transmitter - print '<tr><td class="'.(GETPOST('paiementcode') == 'CHQ' ? 'fieldrequired ' : '').'fieldrequireddyn">'.$langs->trans('CheckTransmitter'); - print ' <em class="opacitymedium">('.$langs->trans("ChequeMaker").')</em>'; - print '</td>'; - print '<td><input id="fieldchqemetteur" class="maxwidth300" name="chqemetteur" type="text" value="'.GETPOST('chqemetteur', 'alphanohtml').'"></td></tr>'; - - // Bank name - print '<tr><td>'.$langs->trans('Bank'); - print ' <em class="opacitymedium">('.$langs->trans("ChequeBank").')</em>'; - print '</td>'; - print '<td><input name="chqbank" class="maxwidth300" type="text" value="'.GETPOST('chqbank', 'alphanohtml').'"></td></tr>'; + // Third party + print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans('Company').'</span></td><td>'.$facture->thirdparty->getNomUrl(4)."</td></tr>\n"; + + // Date payment + print '<tr><td><span class="fieldrequired">'.$langs->trans('Date').'</span></td><td>'; + $datepayment = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + $datepayment = ($datepayment == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $datepayment); + print $form->selectDate($datepayment, '', '', '', 0, "add_paiement", 1, 1, 0, '', '', $facture->date); + print '</td></tr>'; + + // Payment mode + print '<tr><td><span class="fieldrequired">'.$langs->trans('PaymentMode').'</span></td><td>'; + $form->select_types_paiements((GETPOST('paiementcode') ?GETPOST('paiementcode') : $facture->mode_reglement_code), 'paiementcode', '', 2); + print "</td>\n"; + print '</tr>'; + + // Bank account + print '<tr>'; + if (!empty($conf->banque->enabled)) + { + if ($facture->type != 2) print '<td><span class="fieldrequired">'.$langs->trans('AccountToCredit').'</span></td>'; + if ($facture->type == 2) print '<td><span class="fieldrequired">'.$langs->trans('AccountToDebit').'</span></td>'; + print '<td>'; + $form->select_comptes($accountid, 'accountid', 0, '', 2); + print '</td>'; + } + else + { + print '<td> </td>'; + } + print "</tr>\n"; + + // Cheque number + print '<tr><td>'.$langs->trans('Numero'); + print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>'; + print '</td>'; + print '<td><input name="num_paiement" type="text" value="'.$paymentnum.'"></td></tr>'; + + // Check transmitter + print '<tr><td class="'.(GETPOST('paiementcode') == 'CHQ' ? 'fieldrequired ' : '').'fieldrequireddyn">'.$langs->trans('CheckTransmitter'); + print ' <em>('.$langs->trans("ChequeMaker").')</em>'; + print '</td>'; + print '<td><input id="fieldchqemetteur" name="chqemetteur" size="30" type="text" value="'.GETPOST('chqemetteur', 'alphanohtml').'"></td></tr>'; + + // Bank name + print '<tr><td>'.$langs->trans('Bank'); + print ' <em>('.$langs->trans("ChequeBank").')</em>'; + print '</td>'; + print '<td><input name="chqbank" size="30" type="text" value="'.GETPOST('chqbank', 'alphanohtml').'"></td></tr>'; @@ -542,23 +534,14 @@ - print '<textarea name="comment" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.'">'.GETPOST('comment', 'restricthtml').'</textarea>'; - print '</td></tr>'; - - // Go Source Invoice (useful when there are many invoices) - if ($action != 'add_paiement' && getDolGlobalString('FACTURE_PAYMENTS_SHOW_LINK_TO_INPUT_ORIGIN_IS_MORE_THAN')) { - print '<tr><td></td>'; - print '<td class="tdtop right">'; - print '<a class="right" href="#amount_'.$facid.'">'.$langs->trans("GoSourceInvoice").'</a>'; - print '</td></tr>'; - } - - print '</table>'; - - print dol_get_fiche_end(); - - - /* - * List of unpaid invoices - */ - - $sql = 'SELECT f.rowid as facid, f.ref, f.total_ht, f.total_tva, f.total_ttc, f.multicurrency_code, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc, f.type,'; - $sql .= ' f.datef as df, f.fk_soc as socid, f.date_lim_reglement as dlr'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'facture as f'; + print '<textarea name="comment" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.'">'.GETPOST('comment', 'none').'</textarea></td></tr>'; + + print '</table>'; + + dol_fiche_end(); + + + /* + * List of unpaid invoices + */ + + $sql = 'SELECT f.rowid as facid, f.ref, f.total_ttc, f.multicurrency_code, f.multicurrency_total_ttc, f.type,'; + $sql .= ' f.datef as df, f.fk_soc as socid, f.date_lim_reglement as dlr'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'facture as f'; @@ -566 +549 @@ - $sql .= ' AND (f.fk_soc = '.((int) $facture->socid); + $sql .= ' AND (f.fk_soc = '.$facture->socid; @@ -568,2 +551,2 @@ - if (getDolGlobalString('FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS') && !empty($facture->thirdparty->parent)) { - $sql .= ' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'societe WHERE parent = '.((int) $facture->thirdparty->parent).')'; + if (!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS) && !empty($facture->thirdparty->parent)) { + $sql .= ' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'societe WHERE parent = '.$facture->thirdparty->parent.')'; @@ -572,2 +555,2 @@ - if (getDolGlobalString('FACTURE_PAYMENTS_ON_SUBSIDIARY_COMPANIES')) { - $sql .= ' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'societe WHERE parent = '.((int) $facture->thirdparty->id).')'; + if (!empty($conf->global->FACTURE_PAYMENTS_ON_SUBSIDIARY_COMPANIES)) { + $sql .= ' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'societe WHERE parent = '.$facture->thirdparty->id.')'; @@ -575,14 +558,19 @@ - $sql .= ') AND f.paye = 0'; - $sql .= ' AND f.fk_statut = 1'; // Statut=0 => not validated, Statut=2 => canceled - if ($facture->type != Facture::TYPE_CREDIT_NOTE) { - $sql .= ' AND type IN (0,1,3,5)'; // Standard invoice, replacement, deposit, situation - } else { - $sql .= ' AND type = 2'; // If paying back a credit note, we show all credit notes - } - // Sort invoices by date and serial number: the older one comes first - $sql .= ' ORDER BY f.datef ASC, f.ref ASC'; - - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); - if ($num > 0) { + $sql .= ') AND f.paye = 0'; + $sql .= ' AND f.fk_statut = 1'; // Statut=0 => not validated, Statut=2 => canceled + if ($facture->type != Facture::TYPE_CREDIT_NOTE) + { + $sql .= ' AND type IN (0,1,3,5)'; // Standard invoice, replacement, deposit, situation + } + else + { + $sql .= ' AND type = 2'; // If paying back a credit note, we show all credit notes + } + // Sort invoices by date and serial number: the older one comes first + $sql .= ' ORDER BY f.datef ASC, f.ref ASC'; + + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + if ($num > 0) + { @@ -590,3 +578 @@ - if ($facture->type == 2) { - $arraytitle = $langs->trans("CreditNotes"); - } + if ($facture->type == 2) $arraytitle = $langs->trans("CreditNotes"); @@ -595,4 +581 @@ - if ($facture->type == 2) { - $alreadypayedlabel = $langs->trans("PaidBack"); - $multicurrencyalreadypayedlabel = $langs->trans("MulticurrencyPaidBack"); - } + if ($facture->type == 2) { $alreadypayedlabel = $langs->trans("PaidBack"); $multicurrencyalreadypayedlabel = $langs->trans("MulticurrencyPaidBack"); } @@ -601,46 +584,40 @@ - if ($facture->type == 2) { - $remaindertopay = $langs->trans("RemainderToPayBack"); - $multicurrencyremaindertopay = $langs->trans("MulticurrencyRemainderToPayBack"); - } - - $i = 0; - //print '<tr><td colspan="3">'; - print '<br>'; - - print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table - print '<table class="noborder centpercent">'; - - print '<tr class="liste_titre">'; - print '<td>'.$arraytitle.'</td>'; - print '<td class="center">'.$langs->trans('Date').'</td>'; - print '<td class="center">'.$langs->trans('DateMaxPayment').'</td>'; - if (isModEnabled('multicurrency')) { - print '<td>'.$langs->trans('Currency').'</td>'; - print '<td class="right">'.$langs->trans('MulticurrencyAmountTTC').'</td>'; - print '<td class="right">'.$multicurrencyalreadypayedlabel.'</td>'; - print '<td class="right">'.$multicurrencyremaindertopay.'</td>'; - print '<td class="right">'.$langs->trans('MulticurrencyPaymentAmount').'</td>'; - } - print '<td class="right">'.$langs->trans('AmountTTC').'</td>'; - print '<td class="right">'.$alreadypayedlabel.'</td>'; - print '<td class="right">'.$remaindertopay.'</td>'; - print '<td class="right">'.$langs->trans('PaymentAmount').'</td>'; - - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $facture, $action); // Note that $action and $object may have been modified by hook - - print '<td align="right"> </td>'; - print "</tr>\n"; - - $total_ttc = 0; - $totalrecu = 0; - $totalrecucreditnote = 0; - $totalrecudeposits = 0; - - while ($i < $num) { - $objp = $db->fetch_object($resql); - - $sign = 1; - if ($facture->type == Facture::TYPE_CREDIT_NOTE) { - $sign = -1; - } + if ($facture->type == 2) { $remaindertopay = $langs->trans("RemainderToPayBack"); $multicurrencyremaindertopay = $langs->trans("MulticurrencyRemainderToPayBack"); } + + $i = 0; + //print '<tr><td colspan="3">'; + print '<br>'; + print '<table class="noborder centpercent">'; + + print '<tr class="liste_titre">'; + print '<td>'.$arraytitle.'</td>'; + print '<td class="center">'.$langs->trans('Date').'</td>'; + print '<td class="center">'.$langs->trans('DateMaxPayment').'</td>'; + if (!empty($conf->multicurrency->enabled)) { + print '<td>'.$langs->trans('Currency').'</td>'; + print '<td class="right">'.$langs->trans('MulticurrencyAmountTTC').'</td>'; + print '<td class="right">'.$multicurrencyalreadypayedlabel.'</td>'; + print '<td class="right">'.$multicurrencyremaindertopay.'</td>'; + print '<td class="right">'.$langs->trans('MulticurrencyPaymentAmount').'</td>'; + } + print '<td class="right">'.$langs->trans('AmountTTC').'</td>'; + print '<td class="right">'.$alreadypayedlabel.'</td>'; + print '<td class="right">'.$remaindertopay.'</td>'; + print '<td class="right">'.$langs->trans('PaymentAmount').'</td>'; + + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $facture, $action); // Note that $action and $object may have been modified by hook + + print '<td align="right"> </td>'; + print "</tr>\n"; + + $total = 0; + $totalrecu = 0; + $totalrecucreditnote = 0; + $totalrecudeposits = 0; + + while ($i < $num) + { + $objp = $db->fetch_object($resql); + + $sign = 1; + if ($facture->type == Facture::TYPE_CREDIT_NOTE) $sign = -1; @@ -651,7 +628,7 @@ - $invoice = new Facture($db); - $invoice->fetch($objp->facid); - $paiement = $invoice->getSommePaiement(); - $creditnotes = $invoice->getSumCreditNotesUsed(); - $deposits = $invoice->getSumDepositsUsed(); - $alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT'); - $remaintopay = price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT'); + $invoice = new Facture($db); + $invoice->fetch($objp->facid); + $paiement = $invoice->getSommePaiement(); + $creditnotes = $invoice->getSumCreditNotesUsed(); + $deposits = $invoice->getSumDepositsUsed(); + $alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT'); + $remaintopay = price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT'); @@ -660 +637 @@ - if (isModEnabled('multicurrency')) { + if (!empty($conf->multicurrency->enabled)) { @@ -665,5 +642 @@ - $multicurrency_remaintopay = price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits, 'MT'); - // Multicurrency full amount tooltip - $tootltiponmulticurrencyfullamount = $langs->trans('AmountHT') . ": " . price($objp->multicurrency_total_ht, 0, $langs, 0, -1, -1, $objp->multicurrency_code) . "<br>"; - $tootltiponmulticurrencyfullamount .= $langs->trans('AmountVAT') . ": " . price($objp->multicurrency_total_tva, 0, $langs, 0, -1, -1, $objp->multicurrency_code) . "<br>"; - $tootltiponmulticurrencyfullamount .= $langs->trans('AmountTTC') . ": " . price($objp->multicurrency_total_ttc, 0, $langs, 0, -1, -1, $objp->multicurrency_code) . "<br>"; + $multicurrency_remaintopay = price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits, 'MT'); @@ -672,4 +644,0 @@ - // Full amount tooltip - $tootltiponfullamount = $langs->trans('AmountHT') . ": " . price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency) . "<br>"; - $tootltiponfullamount .= $langs->trans('AmountVAT') . ": " . price($objp->total_tva, 0, $langs, 0, -1, -1, $conf->currency) . "<br>"; - $tootltiponfullamount .= $langs->trans('AmountTTC') . ": " . price($objp->total_ttc, 0, $langs, 0, -1, -1, $conf->currency) . "<br>"; @@ -680,3 +649,72 @@ - print $invoice->getNomUrl(1, ''); - if ($objp->socid != $facture->thirdparty->id) { - print ' - '.$soc->getNomUrl(1).' '; + print $invoice->getNomUrl(1, ''); + if ($objp->socid != $facture->thirdparty->id) print ' - '.$soc->getNomUrl(1).' '; + print "</td>\n"; + + // Date + print '<td class="center">'.dol_print_date($db->jdate($objp->df), 'day')."</td>\n"; + + // Due date + if ($objp->dlr > 0) + { + print '<td class="nowraponall center">'; + print dol_print_date($db->jdate($objp->dlr), 'day'); + + if ($invoice->hasDelay()) + { + print img_warning($langs->trans('Late')); + } + + print '</td>'; + } + else + { + print '<td align="center"></td>'; + } + + // Currency + if (!empty($conf->multicurrency->enabled)) print '<td class="center">'.$objp->multicurrency_code."</td>\n"; + + // Multicurrency Price + if (!empty($conf->multicurrency->enabled)) + { + print '<td class="right">'; + if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) print price($sign * $objp->multicurrency_total_ttc); + print '</td>'; + + // Multicurrency Price + print '<td class="right">'; + if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) + { + print price($sign * $multicurrency_payment); + if ($multicurrency_creditnotes) print '+'.price($multicurrency_creditnotes); + if ($multicurrency_deposits) print '+'.price($multicurrency_deposits); + } + print '</td>'; + + // Multicurrency remain to pay + print '<td class="right">'; + if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) print price($sign * $multicurrency_remaintopay); + print '</td>'; + + print '<td class="right nowraponall">'; + + // Add remind multicurrency amount + $namef = 'multicurrency_amount_'.$objp->facid; + $nameRemain = 'multicurrency_remain_'.$objp->facid; + + if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) + { + if ($action != 'add_paiement') + { + if (!empty($conf->use_javascript_ajax)) + print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $multicurrency_remaintopay)."'"); + print '<input type="text" class="maxwidth75 multicurrency_amount" name="'.$namef.'" value="'.$_POST[$namef].'">'; + print '<input type="hidden" class="multicurrency_remain" name="'.$nameRemain.'" value="'.$multicurrency_remaintopay.'">'; + } + else + { + print '<input type="text" class="maxwidth75" name="'.$namef.'_disabled" value="'.$_POST[$namef].'" disabled>'; + print '<input type="hidden" name="'.$namef.'" value="'.$_POST[$namef].'">'; + } + } + print "</td>"; @@ -684,123 +722,24 @@ - print "</td>\n"; - - // Date - print '<td class="center">'.dol_print_date($db->jdate($objp->df), 'day')."</td>\n"; - - // Due date - if ($objp->dlr > 0) { - print '<td class="nowraponall center">'; - print dol_print_date($db->jdate($objp->dlr), 'day'); - - if ($invoice->hasDelay()) { - print img_warning($langs->trans('Late')); - } - - print '</td>'; - } else { - print '<td align="center"></td>'; - } - - // Currency - if (isModEnabled('multicurrency')) { - print '<td class="center">'.$objp->multicurrency_code."</td>\n"; - } - - // Multicurrency full amount - if (isModEnabled('multicurrency')) { - print '<td class="right">'; - if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) { - print '<span class="amount classfortooltip" title="'.$tootltiponmulticurrencyfullamount.'">' . price($sign * $objp->multicurrency_total_ttc); - } - print '</span></td>'; - - // Multicurrency Price - print '<td class="right">'; - if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) { - print price($sign * $multicurrency_payment); - if ($multicurrency_creditnotes) { - print '+'.price($multicurrency_creditnotes); - } - if ($multicurrency_deposits) { - print '+'.price($multicurrency_deposits); - } - } - print '</td>'; - - // Multicurrency remain to pay - print '<td class="right">'; - if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) { - print price($sign * $multicurrency_remaintopay); - } - print '</td>'; - - print '<td class="right nowraponall">'; - - // Add remind multicurrency amount - $namef = 'multicurrency_amount_'.$objp->facid; - $nameRemain = 'multicurrency_remain_'.$objp->facid; - - if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) { - if ($action != 'add_paiement') { - if (!empty($conf->use_javascript_ajax)) { - print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $multicurrency_remaintopay)."'"); - } - print '<input type="text" class="maxwidth75 multicurrency_amount" name="'.$namef.'" value="'.GETPOST($namef).'">'; - print '<input type="hidden" class="multicurrency_remain" name="'.$nameRemain.'" value="'.$multicurrency_remaintopay.'">'; - } else { - print '<input type="text" class="maxwidth75" name="'.$namef.'_disabled" value="'.GETPOST($namef).'" disabled>'; - print '<input type="hidden" name="'.$namef.'" value="'.GETPOST($namef).'">'; - } - } - print "</td>"; - } - - // Full amount - print '<td class="right"><span class="amount classfortooltip" title="'.$tootltiponfullamount.'">'.price($sign * $objp->total_ttc).'</span></td>'; - - // Received + already paid - print '<td class="right"><span class="amount">'.price($sign * $paiement); - if ($creditnotes) { - print '<span class="opacitymedium">+'.price($creditnotes).'</span>'; - } - if ($deposits) { - print '<span class="opacitymedium">+'.price($deposits).'</span>'; - } - print '</span></td>'; - - // Remain to take or to pay back - print '<td class="right">'; - print price($sign * $remaintopay); - if (isModEnabled('prelevement')) { - $numdirectdebitopen = 0; - $totaldirectdebit = 0; - $sql = "SELECT COUNT(pfd.rowid) as nb, SUM(pfd.amount) as amount"; - $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd"; - $sql .= " WHERE fk_facture = ".((int) $objp->facid); - $sql .= " AND pfd.traite = 0"; - $sql .= " AND pfd.ext_payment_id IS NULL"; - - $result_sql = $db->query($sql); - if ($result_sql) { - $obj = $db->fetch_object($result_sql); - $numdirectdebitopen = $obj->nb; - $totaldirectdebit = $obj->amount; - } else { - dol_print_error($db); - } - if ($numdirectdebitopen) { - $langs->load("withdrawals"); - print img_warning($langs->trans("WarningSomeDirectDebitOrdersAlreadyExists", $numdirectdebitopen, price(price2num($totaldirectdebit, 'MT'), 0, $langs, 1, -1, -1, $conf->currency)), '', 'classfortooltip'); - } - } - print '</td>'; - //$test= price(price2num($objp->total_ttc - $paiement - $creditnotes - $deposits)); - - // Amount - print '<td class="right nowraponall">'; - - // Add remind amount - $namef = 'amount_'.$objp->facid; - $nameRemain = 'remain_'.$objp->facid; - - if ($action != 'add_paiement') { - if (!empty($conf->use_javascript_ajax)) { + + // Price + print '<td class="right">'.price($sign * $objp->total_ttc).'</td>'; + + // Received or paid back + print '<td class="right">'.price($sign * $paiement); + if ($creditnotes) print '+'.price($creditnotes); + if ($deposits) print '+'.price($deposits); + print '</td>'; + + // Remain to take or to pay back + print '<td class="right">'.price($sign * $remaintopay).'</td>'; + //$test= price(price2num($objp->total_ttc - $paiement - $creditnotes - $deposits)); + + // Amount + print '<td class="right nowraponall">'; + + // Add remind amount + $namef = 'amount_'.$objp->facid; + $nameRemain = 'remain_'.$objp->facid; + + if ($action != 'add_paiement') + { + if (!empty($conf->use_javascript_ajax)) @@ -808,41 +747,45 @@ - } - print '<input type="text" class="maxwidth75 amount" id="'.$namef.'" name="'.$namef.'" value="'.dol_escape_htmltag(GETPOST($namef)).'">'; - print '<input type="hidden" class="remain" name="'.$nameRemain.'" value="'.$remaintopay.'">'; - } else { - print '<input type="text" class="maxwidth75" name="'.$namef.'_disabled" value="'.dol_escape_htmltag(GETPOST($namef)).'" disabled>'; - print '<input type="hidden" name="'.$namef.'" value="'.dol_escape_htmltag(GETPOST($namef)).'">'; - } - print "</td>"; - - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook - - // Warning - print '<td align="center" width="16">'; - //print "xx".$amounts[$invoice->id]."-".$amountsresttopay[$invoice->id]."<br>"; - if (!empty($amounts[$invoice->id]) && (abs($amounts[$invoice->id]) > abs($amountsresttopay[$invoice->id])) - || !empty($multicurrency_amounts[$invoice->id]) && (abs($multicurrency_amounts[$invoice->id]) > abs($multicurrency_amountsresttopay[$invoice->id]))) { - print ' '.img_warning($langs->trans("PaymentHigherThanReminderToPay")); - } - print '</td>'; - - print "</tr>\n"; - - $total_ttc += $objp->total_ttc; - $totalrecu += $paiement; - $totalrecucreditnote += $creditnotes; - $totalrecudeposits += $deposits; - $i++; - } - - if ($i > 1) { - // Print total - print '<tr class="liste_total">'; - print '<td colspan="3" class="left">'.$langs->trans('TotalTTC').'</td>'; - if (isModEnabled('multicurrency')) { - print '<td></td>'; - print '<td></td>'; - print '<td></td>'; - print '<td></td>'; - print '<td class="right" id="multicurrency_result" style="font-weight: bold;"></td>'; - } + print '<input type="text" class="maxwidth75 amount" name="'.$namef.'" value="'.dol_escape_htmltag(GETPOST($namef)).'">'; + print '<input type="hidden" class="remain" name="'.$nameRemain.'" value="'.$remaintopay.'">'; + } + else + { + print '<input type="text" class="maxwidth75" name="'.$namef.'_disabled" value="'.dol_escape_htmltag(GETPOST($namef)).'" disabled>'; + print '<input type="hidden" name="'.$namef.'" value="'.dol_escape_htmltag(GETPOST($namef)).'">'; + } + print "</td>"; + + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook + + // Warning + print '<td align="center" width="16">'; + //print "xx".$amounts[$invoice->id]."-".$amountsresttopay[$invoice->id]."<br>"; + if ($amounts[$invoice->id] && (abs($amounts[$invoice->id]) > abs($amountsresttopay[$invoice->id])) + || $multicurrency_amounts[$invoice->id] && (abs($multicurrency_amounts[$invoice->id]) > abs($multicurrency_amountsresttopay[$invoice->id]))) + { + print ' '.img_warning($langs->trans("PaymentHigherThanReminderToPay")); + } + print '</td>'; + + print "</tr>\n"; + + $total += $objp->total; + $total_ttc += $objp->total_ttc; + $totalrecu += $paiement; + $totalrecucreditnote += $creditnotes; + $totalrecudeposits += $deposits; + $i++; + } + + if ($i > 1) + { + // Print total + print '<tr class="liste_total">'; + print '<td colspan="3" class="left">'.$langs->trans('TotalTTC').'</td>'; + if (!empty($conf->multicurrency->enabled)) { + print '<td></td>'; + print '<td></td>'; + print '<td></td>'; + print '<td></td>'; + print '<td class="right" id="multicurrency_result" style="font-weight: bold;"></td>'; + } @@ -850,15 +793,49 @@ - print '<td class="right"><b>'.price($sign * $totalrecu); - if ($totalrecucreditnote) { - print '+'.price($totalrecucreditnote); - } - if ($totalrecudeposits) { - print '+'.price($totalrecudeposits); - } - print '</b></td>'; - print '<td class="right"><b>'.price($sign * price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits, 'MT')).'</b></td>'; - print '<td class="right" id="result" style="font-weight: bold;"></td>'; // Autofilled - print '<td align="center"> </td>'; - print "</tr>\n"; - } - print "</table>"; - print "</div>\n"; + print '<td class="right"><b>'.price($sign * $totalrecu); + if ($totalrecucreditnote) print '+'.price($totalrecucreditnote); + if ($totalrecudeposits) print '+'.price($totalrecudeposits); + print '</b></td>'; + print '<td class="right"><b>'.price($sign * price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits, 'MT')).'</b></td>'; + print '<td class="right" id="result" style="font-weight: bold;"></td>'; // Autofilled + print '<td align="center"> </td>'; + print "</tr>\n"; + } + print "</table>"; + //print "</td></tr>\n"; + } + $db->free($resql); + } + else + { + dol_print_error($db); + } + + + // Bouton Enregistrer + if ($action != 'add_paiement') + { + $checkboxlabel = $langs->trans("ClosePaidInvoicesAutomatically"); + if ($facture->type == Facture::TYPE_CREDIT_NOTE) $checkboxlabel = $langs->trans("ClosePaidCreditNotesAutomatically"); + $buttontitle = $langs->trans('ToMakePayment'); + if ($facture->type == Facture::TYPE_CREDIT_NOTE) $buttontitle = $langs->trans('ToMakePaymentBack'); + + print '<br><div class="center">'; + print '<input type="checkbox" checked name="closepaidinvoices"> '.$checkboxlabel; + /*if (! empty($conf->prelevement->enabled)) + { + $langs->load("withdrawals"); + if (! empty($conf->global->WITHDRAW_DISABLE_AUTOCREATE_ONPAYMENTS)) print '<br>'.$langs->trans("IfInvoiceNeedOnWithdrawPaymentWontBeClosed"); + }*/ + print '<br><input type="submit" class="button" value="'.dol_escape_htmltag($buttontitle).'"><br><br>'; + print '</div>'; + } + + // Form to confirm payment + if ($action == 'add_paiement') + { + $preselectedchoice = $addwarning ? 'no' : 'yes'; + + print '<br>'; + if (!empty($totalpayment)) $text = $langs->trans('ConfirmCustomerPayment', $totalpayment, $langs->trans("Currency".$conf->currency)); + if (!empty($multicurrency_totalpayment)) + { + $text .= '<br>'.$langs->trans('ConfirmCustomerPayment', $multicurrency_totalpayment, $langs->trans("paymentInInvoiceCurrency")); @@ -866,60 +843,10 @@ - $db->free($resql); - } else { - dol_print_error($db); - } - - $formconfirm = ''; - - // Save button - if ($action != 'add_paiement') { - $checkboxlabel = $langs->trans("ClosePaidInvoicesAutomatically"); - if ($facture->type == Facture::TYPE_CREDIT_NOTE) { - $checkboxlabel = $langs->trans("ClosePaidCreditNotesAutomatically"); - } - $buttontitle = $langs->trans('ToMakePayment'); - if ($facture->type == Facture::TYPE_CREDIT_NOTE) { - $buttontitle = $langs->trans('ToMakePaymentBack'); - } - - print '<br><div class="center">'; - print '<input type="checkbox" checked name="closepaidinvoices"> '.$checkboxlabel; - /*if (isModEnabled('prelevement')) { - $langs->load("withdrawals"); - if (!empty($conf->global->WITHDRAW_DISABLE_AUTOCREATE_ONPAYMENTS)) print '<br>'.$langs->trans("IfInvoiceNeedOnWithdrawPaymentWontBeClosed"); - }*/ - print '<br><input type="submit" class="button reposition" value="'.dol_escape_htmltag($buttontitle).'"><br><br>'; - print '</div>'; - } - - // Form to confirm payment - if ($action == 'add_paiement') { - $preselectedchoice = $addwarning ? 'no' : 'yes'; - - print '<br>'; - if (!empty($totalpayment)) { - $text = $langs->trans('ConfirmCustomerPayment', $totalpayment, $langs->transnoentitiesnoconv("Currency".$conf->currency)); - } - if (!empty($multicurrency_totalpayment)) { - $text .= '<br>'.$langs->trans('ConfirmCustomerPayment', $multicurrency_totalpayment, $langs->transnoentitiesnoconv("paymentInInvoiceCurrency")); - } - if (GETPOST('closepaidinvoices')) { - $text .= '<br>'.$langs->trans("AllCompletelyPayedInvoiceWillBeClosed"); - print '<input type="hidden" name="closepaidinvoices" value="'.GETPOST('closepaidinvoices').'">'; - } - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$facture->id.'&socid='.$facture->socid.'&type='.$facture->type, $langs->trans('ReceivedCustomersPayments'), $text, 'confirm_paiement', $formquestion, $preselectedchoice); - } - - // Call Hook formConfirm - $parameters = array('formConfirm' => $formconfirm); - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) { - $formconfirm .= $hookmanager->resPrint; - } elseif ($reshook > 0) { - $formconfirm = $hookmanager->resPrint; - } - - // Print form confirm - print $formconfirm; - - print "</form>\n"; - } + if (GETPOST('closepaidinvoices')) + { + $text .= '<br>'.$langs->trans("AllCompletelyPayedInvoiceWillBeClosed"); + print '<input type="hidden" name="closepaidinvoices" value="'.GETPOST('closepaidinvoices').'">'; + } + print $form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$facture->id.'&socid='.$facture->socid.'&type='.$facture->type, $langs->trans('ReceivedCustomersPayments'), $text, 'confirm_paiement', $formquestion, $preselectedchoice); + } + + print "</form>\n"; + } @@ -932,39 +859,36 @@ -if (!GETPOST('action', 'aZ09')) { - if (empty($page) || $page == -1) { - $page = 0; - } - $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; - $offset = $limit * $page; - - if (!$sortorder) { - $sortorder = 'DESC'; - } - if (!$sortfield) { - $sortfield = 'p.datep'; - } - - $sql = 'SELECT p.datep as dp, p.amount, f.total_ttc as fa_amount, f.ref'; - $sql .= ', f.rowid as facid, c.libelle as paiement_type, p.num_paiement as num_payment'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement as p LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; - $sql .= ', '.MAIN_DB_PREFIX.'facture as f'; - $sql .= ' WHERE p.fk_facture = f.rowid'; - $sql .= ' AND f.entity IN ('.getEntity('invoice').')'; - if ($socid) { - $sql .= ' AND f.fk_soc = '.((int) $socid); - } - - $sql .= $db->order($sortfield, $sortorder); - $sql .= $db->plimit($limit + 1, $offset); - $resql = $db->query($sql); - - if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - - print_barre_liste($langs->trans('Payments'), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', $num); - print '<table class="noborder centpercent">'; - print '<tr class="liste_titre">'; - print_liste_field_titre('Invoice', $_SERVER["PHP_SELF"], 'f.ref', '', '', '', $sortfield, $sortorder); - print_liste_field_titre('Date', $_SERVER["PHP_SELF"], 'p.datep', '', '', '', $sortfield, $sortorder); - print_liste_field_titre('Type', $_SERVER["PHP_SELF"], 'c.libelle', '', '', '', $sortfield, $sortorder); - print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], 'p.amount', '', '', '', $sortfield, $sortorder, 'right '); +if (!GETPOST('action', 'aZ09')) +{ + if (empty($page) || $page == -1) $page = 0; + $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; + $offset = $limit * $page; + + if (!$sortorder) $sortorder = 'DESC'; + if (!$sortfield) $sortfield = 'p.datep'; + + $sql = 'SELECT p.datep as dp, p.amount, f.total_ttc as fa_amount, f.ref'; + $sql .= ', f.rowid as facid, c.libelle as paiement_type, p.num_paiement'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement as p LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; + $sql .= ', '.MAIN_DB_PREFIX.'facture as f'; + $sql .= ' WHERE p.fk_facture = f.rowid'; + $sql .= ' AND f.entity IN ('.getEntity('invoice').')'; + if ($socid) + { + $sql .= ' AND f.fk_soc = '.$socid; + } + + $sql .= ' ORDER BY '.$sortfield.' '.$sortorder; + $sql .= $db->plimit($limit + 1, $offset); + $resql = $db->query($sql); + + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + + print_barre_liste($langs->trans('Payments'), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', $num); + print '<table class="noborder centpercent">'; + print '<tr class="liste_titre">'; + print_liste_field_titre('Invoice', $_SERVER["PHP_SELF"], 'f.ref', '', '', '', $sortfield, $sortorder); + print_liste_field_titre('Date', $_SERVER["PHP_SELF"], 'p.datep', '', '', '', $sortfield, $sortorder); + print_liste_field_titre('Type', $_SERVER["PHP_SELF"], 'c.libelle', '', '', '', $sortfield, $sortorder); + print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], 'p.amount', '', '', '', $sortfield, $sortorder, 'right '); @@ -972,20 +896,21 @@ - print "</tr>\n"; - - while ($i < min($num, $limit)) { - $objp = $db->fetch_object($resql); - - print '<tr class="oddeven">'; - print '<td><a href="'.DOL_URL_ROOT.'/compta/facture/card.php?facid='.$objp->facid.'">'.$objp->ref."</a></td>\n"; - print '<td>'.dol_print_date($db->jdate($objp->dp))."</td>\n"; - print '<td>'.$objp->paiement_type.' '.$objp->num_payment."</td>\n"; - print '<td class="right"><span class="amount">'.price($objp->amount).'</span></td>'; - print '<td> </td>'; - print '</tr>'; - - $parameters = array(); - $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook - - $i++; - } - print '</table>'; - } + print "</tr>\n"; + + while ($i < min($num, $limit)) + { + $objp = $db->fetch_object($resql); + + print '<tr class="oddeven">'; + print '<td><a href="'.DOL_URL_ROOT.'/compta/facture/card.php?facid='.$objp->facid.'">'.$objp->ref."</a></td>\n"; + print '<td>'.dol_print_date($db->jdate($objp->dp))."</td>\n"; + print '<td>'.$objp->paiement_type.' '.$objp->num_paiement."</td>\n"; + print '<td class="right">'.price($objp->amount).'</td>'; + print '<td> </td>'; + print '</tr>'; + + $parameters = array(); + $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook + + $i++; + } + print '</table>'; + } --- /tmp/dsg/dolibarr/htdocs/compta/github_19.0.3_paiement_charge.php +++ /tmp/dsg/dolibarr/htdocs/compta/client_paiement_charge.php @@ -4 +3,0 @@ - * Copyright (C) 2022 Alexandre Spangaro <aspangaro@open-dsi.fr> @@ -26 +24,0 @@ -// Load Dolibarr environment @@ -33 +31 @@ -$langs->loadLangs(array("banks", "bills", "compta")); +$langs->load("bills"); @@ -36,3 +34 @@ -$action = GETPOST('action', 'aZ09'); -$cancel = GETPOST('cancel'); - +$action = GETPOST('action', 'alpha'); @@ -43 +39,2 @@ -if ($user->socid > 0) { +if ($user->socid > 0) +{ @@ -46,2 +42,0 @@ - -$charge = new ChargeSociales($db); @@ -54 +49,2 @@ -if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm == 'yes')) { +if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm == 'yes')) +{ @@ -57 +53,2 @@ - if ($cancel) { + if ($_POST["cancel"]) + { @@ -63,3 +60,4 @@ - $datepaye = dol_mktime(12, 0, 0, GETPOST("remonth", "int"), GETPOST("reday", "int"), GETPOST("reyear", "int")); - - if (!(GETPOST("paiementtype") > 0)) { + $datepaye = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + + if (!$_POST["paiementtype"] > 0) + { @@ -68,3 +66,4 @@ - $action = 'create'; - } - if ($datepaye == '') { + $action = 'create'; + } + if ($datepaye == '') + { @@ -73,9 +72,11 @@ - $action = 'create'; - } - if (isModEnabled("banque") && !(GETPOST("accountid") > 0)) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToCredit")), null, 'errors'); - $error++; - $action = 'create'; - } - - if (!$error) { + $action = 'create'; + } + if (!empty($conf->banque->enabled) && !($_POST["accountid"] > 0)) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToCredit")), null, 'errors'); + $error++; + $action = 'create'; + } + + if (!$error) + { @@ -85,2 +86,4 @@ - foreach ($_POST as $key => $value) { - if (substr($key, 0, 7) == 'amount_') { + foreach ($_POST as $key => $value) + { + if (substr($key, 0, 7) == 'amount_') + { @@ -88 +91 @@ - $amounts[$other_chid] = price2num(GETPOST($key)); + $amounts[$other_chid] = price2num($_POST[$key]); @@ -92,46 +95,55 @@ - if (count($amounts) <= 0) { - $error++; - setEventMessages($langs->trans("ErrorNoPaymentDefined"), null, 'errors'); - $action = 'create'; - } - - if (!$error) { - $db->begin(); - - // Create a line of payments - $paiement = new PaymentSocialContribution($db); - $paiement->chid = $chid; - $paiement->datepaye = $datepaye; - $paiement->amounts = $amounts; // Amount list - $paiement->paiementtype = GETPOST("paiementtype", 'alphanohtml'); - $paiement->num_payment = GETPOST("num_payment", 'alphanohtml'); - $paiement->note = GETPOST("note", 'restricthtml'); - $paiement->note_private = GETPOST("note", 'restricthtml'); - - if (!$error) { - $paymentid = $paiement->create($user, (GETPOST('closepaidcontrib') == 'on' ? 1 : 0)); - if ($paymentid < 0) { - $error++; - setEventMessages($paiement->error, null, 'errors'); - $action = 'create'; - } - } - - if (!$error) { - $result = $paiement->addPaymentToBank($user, 'payment_sc', '(SocialContributionPayment)', GETPOST('accountid', 'int'), '', ''); - if (!($result > 0)) { - $error++; - setEventMessages($paiement->error, null, 'errors'); - $action = 'create'; - } - } - - if (!$error) { - $db->commit(); - $loc = DOL_URL_ROOT.'/compta/sociales/card.php?id='.$chid; - header('Location: '.$loc); - exit; - } else { - $db->rollback(); - } - } + if (count($amounts) <= 0) + { + $error++; + setEventMessages($langs->trans("ErrorNoPaymentDefined"), null, 'errors'); + $action = 'create'; + } + + if (!$error) + { + $db->begin(); + + // Create a line of payments + $paiement = new PaymentSocialContribution($db); + $paiement->chid = $chid; + $paiement->datepaye = $datepaye; + $paiement->amounts = $amounts; // Tableau de montant + $paiement->paiementtype = GETPOST("paiementtype", 'alphanohtml'); + $paiement->num_payment = GETPOST("num_payment", 'alphanohtml'); + $paiement->note = GETPOST("note", 'none'); + $paiement->note_private = GETPOST("note", 'none'); + + if (!$error) + { + $paymentid = $paiement->create($user, (GETPOST('closepaidcontrib') == 'on' ? 1 : 0)); + if ($paymentid < 0) + { + $error++; + setEventMessages($paiement->error, null, 'errors'); + $action = 'create'; + } + } + + if (!$error) + { + $result = $paiement->addPaymentToBank($user, 'payment_sc', '(SocialContributionPayment)', GETPOST('accountid', 'int'), '', ''); + if (!($result > 0)) + { + $error++; + setEventMessages($paiement->error, null, 'errors'); + $action = 'create'; + } + } + + if (!$error) + { + $db->commit(); + $loc = DOL_URL_ROOT.'/compta/sociales/card.php?id='.$chid; + header('Location: '.$loc); + exit; + } + else + { + $db->rollback(); + } + } @@ -151,2 +163,4 @@ -// Form of charge payment creation -if ($action == 'create') { +// Formulaire de creation d'un paiement de charge +if ($action == 'create') +{ + $charge = new ChargeSociales($db); @@ -154,2 +168,2 @@ - $charge->accountid = $charge->fk_account ? $charge->fk_account : $charge->accountid; - $charge->paiementtype = $charge->mode_reglement_id ? $charge->mode_reglement_id : $charge->paiementtype; + $charge->accountid = $charge->fk_account ? $charge->fk_account : $charge->accountid; + $charge->paiementtype = $charge->mode_reglement_id ? $charge->mode_reglement_id : $charge->paiementtype; @@ -158,2 +172,3 @@ - if (!empty($conf->use_javascript_ajax)) { - print "\n".'<script type="text/javascript">'; + if (!empty($conf->use_javascript_ajax)) + { + print "\n".'<script type="text/javascript" language="javascript">'; @@ -163,2 +178 @@ - print ' $(".AutoFillAmount").on(\'click touchstart\', function() { - console.log("Click on .AutoFillAmount"); + print ' $(".AutoFillAmount").on(\'click touchstart\', function(){ @@ -174,2 +188,8 @@ - - print '<form name="add_payment" action="'.$_SERVER['PHP_SELF'].'" method="POST">'; + print "<br>\n"; + + if ($mesg) + { + print "<div class=\"error\">$mesg</div>"; + } + + print '<form name="add_payment" action="'.$_SERVER['PHP_SELF'].'" method="post">'; @@ -181 +201 @@ - print dol_get_fiche_head('', ''); + dol_fiche_head('', ''); @@ -186 +205,0 @@ - print '<tr><td>'.$langs->trans("Label").'</td><td>'.$charge->label."</td></tr>\n"; @@ -188,0 +208 @@ + print '<tr><td>'.$langs->trans("Label").'</td><td>'.$charge->label."</td></tr>\n"; @@ -194 +214 @@ - $sql .= " WHERE p.fk_charge = ".((int) $chid); + $sql .= " WHERE p.fk_charge = ".$chid; @@ -196 +216,2 @@ - if ($resql) { + if ($resql) + { @@ -199 +220 @@ - $db->free($resql); + $db->free(); @@ -205,3 +226,3 @@ - $datepaye = dol_mktime(12, 0, 0, GETPOST("remonth", 'int'), GETPOST("reday", 'int'), GETPOST("reyear", 'int')); - $datepayment = !getDolGlobalString('MAIN_AUTOFILL_DATE') ? (GETPOSTISSET("remonth") ? $datepaye : -1) : ''; - print $form->selectDate($datepayment, '', '', '', 0, "add_payment", 1, 1, 0, '', '', $charge->date_ech, '', 1, $langs->trans("DateOfSocialContribution")); + $datepaye = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + $datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ? (empty($_POST["remonth"]) ?-1 : $datepaye) : 0; + print $form->selectDate($datepayment, '', '', '', '', "add_payment", 1, 1); @@ -212,2 +233 @@ - print img_picto('', 'bank', 'class="pictofixedwidth"'); - print $form->select_types_paiements(GETPOSTISSET("paiementtype") ? GETPOST("paiementtype") : $charge->paiementtype, "paiementtype", '', 0, 1, 0, 0, 1, 'maxwidth500 widthcentpercentminusxx', 1); + $form->select_types_paiements(isset($_POST["paiementtype"]) ? $_POST["paiementtype"] : $charge->paiementtype, "paiementtype"); @@ -220,2 +240 @@ - print img_picto('', 'bank_account', 'class="pictofixedwidth"'); - print $form->select_comptes(GETPOSTISSET("accountid") ? GETPOST("accountid", 'int') : $charge->accountid, "accountid", 0, '', 2, '', 0, 'maxwidth500 widthcentpercentminusx', 1); // Show opend bank account list + $form->select_comptes(isset($_POST["accountid"]) ? $_POST["accountid"] : $charge->accountid, "accountid", 0, '', 1); // Show opend bank account list @@ -226,3 +245 @@ - if (empty($conf->dol_optimize_smallscreen)) { - print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>'; - } + print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>'; @@ -230 +247 @@ - print '<td><input name="num_payment" class="width100" type="text" value="'.GETPOST('num_payment', 'alphanohtml').'"></td></tr>'."\n"; + print '<td><input name="num_payment" type="text" value="'.GETPOST('num_payment', 'alphanohtml').'"></td></tr>'."\n"; @@ -234 +251 @@ - print '<td class="tdtop"><textarea class="quatrevingpercent" name="note" wrap="soft" rows="'.ROWS_3.'">'.GETPOST('note', 'alphanohtml').'</textarea></td>'; + print '<td class="tdtop"><textarea name="note" wrap="soft" cols="60" rows="'.ROWS_3.'"></textarea></td>'; @@ -239 +256 @@ - print dol_get_fiche_end(); + dol_fiche_end(); @@ -242 +259 @@ - * Other unpaid charges + * Autres charges impayees @@ -247 +263,0 @@ - print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table @@ -259 +274,0 @@ - $total_ttc = 0; @@ -262 +277,2 @@ - while ($i < $num) { + while ($i < $num) + { @@ -267 +283,2 @@ - if ($objp->date_ech > 0) { + if ($objp->date_ech > 0) + { @@ -269 +286,3 @@ - } else { + } + else + { @@ -273,8 +292,9 @@ - print '<td class="right nowraponall"><span class="amount">'.price($objp->amount)."</span></td>"; - - print '<td class="right nowraponall"><span class="amount">'.price($sumpaid)."</span></td>"; - - print '<td class="right nowraponall"><span class="amount">'.price($objp->amount - $sumpaid)."</span></td>"; - - print '<td class="center nowraponall">'; - if ($sumpaid < $objp->amount) { + print '<td class="right">'.price($objp->amount)."</td>"; + + print '<td class="right">'.price($sumpaid)."</td>"; + + print '<td class="right">'.price($objp->amount - $sumpaid)."</td>"; + + print '<td class="center">'; + if ($sumpaid < $objp->amount) + { @@ -283,3 +303,2 @@ - if (!empty($conf->use_javascript_ajax)) { - print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmount' data-rowid='".$namef."' data-value='".($objp->amount - $sumpaid)."'"); - } + if (!empty($conf->use_javascript_ajax)) + print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmount' data-rowid='".$namef."' data-value='".($objp->amount - $sumpaid)."'"); @@ -288,2 +307,4 @@ - print '<input type="text" size="8" name="'.$namef.'" id="'.$namef.'" value="'.GETPOST('amount_'.$objp->id, 'alpha').'">'; - } else { + print '<input type="text" size="8" name="'.$namef.'" id="'.$namef.'">'; + } + else + { @@ -297 +318 @@ - $totalrecu += $objp->amount; + $totalrecu += $objp->am; @@ -300 +321,2 @@ - if ($i > 1) { + if ($i > 1) + { @@ -312,3 +334,2 @@ - print '</div>'; - - // Save payment button + + // Bouton Save payment @@ -318 +339 @@ - print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">'; + print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; --- /tmp/dsg/dolibarr/htdocs/compta/github_19.0.3_recap-compta.php +++ /tmp/dsg/dolibarr/htdocs/compta/client_recap-compta.php @@ -26 +25,0 @@ -// Load Dolibarr environment @@ -34,5 +33,3 @@ -if (isModEnabled('facture')) { - $langs->load("bills"); -} - -$id = GETPOST('id') ? GETPOST('id', 'int') : GETPOST('socid', 'int'); +if (!empty($conf->facture->enabled)) $langs->load("bills"); + +$id = GETPOST('id') ?GETPOST('id', 'int') : GETPOST('socid', 'int'); @@ -41,3 +38 @@ -if ($user->socid) { - $id = $user->socid; -} +if ($user->socid) $id = $user->socid; @@ -47,3 +42 @@ -if ($id > 0) { - $object->fetch($id); -} +if ($id > 0) $object->fetch($id); @@ -55,3 +48,3 @@ -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); @@ -59,3 +52 @@ -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 @@ -65,6 +56,2 @@ -if (!$sortfield) { - $sortfield = "f.datef,f.rowid"; // Set here default search field -} -if (!$sortorder) { - $sortorder = "DESC"; -} +if (!$sortfield) $sortfield = "f.datef,f.rowid"; // Set here default search field +if (!$sortorder) $sortorder = "DESC"; @@ -74,2 +61,2 @@ - 'f.datef'=>array('label'=>"Date", 'checked'=>1), - //... + 'f.datef'=>array('label'=>"Date", 'checked'=>1), + //... @@ -86,3 +73 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -101,3 +86 @@ -if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { - $title = $object->name.' - '.$langs->trans("Summary"); -} +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name.' - '.$langs->trans("Summary"); @@ -108,9 +91,8 @@ -if ($id > 0) { - $param = ''; - if ($id > 0) { - $param .= '&socid='.$id; - } - - $head = societe_prepare_head($object); - - print dol_get_fiche_head($head, 'customer', $langs->trans("ThirdParty"), 0, 'company'); +if ($id > 0) +{ + $param = ''; + if ($id > 0) $param .= '&socid='.$id; + + $head = societe_prepare_head($object); + + dol_fiche_head($head, 'customer', $langs->trans("ThirdParty"), 0, 'company'); @@ -118,3 +100,4 @@ - print dol_get_fiche_end(); - - if (isModEnabled('facture') && $user->hasRight('facture', 'lire')) { + dol_fiche_end(); + + if (!empty($conf->facture->enabled) && $user->rights->facture->lire) + { @@ -126,3 +109 @@ - if (!empty($arrayfields['f.datef']['checked'])) { - print_liste_field_titre($arrayfields['f.datef']['label'], $_SERVER["PHP_SELF"], "f.datef", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); - } + if (!empty($arrayfields['f.datef']['checked'])) print_liste_field_titre($arrayfields['f.datef']['label'], $_SERVER["PHP_SELF"], "f.datef", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); @@ -143 +124 @@ - $sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".((int) $object->id); + $sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$object->id; @@ -149 +130,2 @@ - if ($resql) { + if ($resql) + { @@ -153 +135,2 @@ - for ($i = 0; $i < $num; $i++) { + for ($i = 0; $i < $num; $i++) + { @@ -158 +141,2 @@ - if ($ret < 0) { + if ($ret < 0) + { @@ -162 +146 @@ - $totalpaid = $fac->getSommePaiement(); + $totalpaye = $fac->getSommePaiement(); @@ -172 +156 @@ - 'status' => $fac->getLibStatut(2, $totalpaid), + 'status' => $fac->getLibStatut(2, $totalpaye), @@ -179,3 +163 @@ - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -193 +175 @@ - $sql .= " AND pf.fk_facture = ".((int) $fac->id); + $sql .= " AND pf.fk_facture = ".$fac->id; @@ -197 +179,2 @@ - if ($resqlp) { + if ($resqlp) + { @@ -201 +184,2 @@ - while ($j < $nump) { + while ($j < $nump) + { @@ -222,3 +206 @@ - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -232 +214,3 @@ - } else { + } + else + { @@ -236 +220,3 @@ - } else { + } + else + { @@ -250,3 +235,0 @@ - if (!isset($data1['balance'])) { - $data1['balance'] = 0; - } @@ -265,5 +248,2 @@ - if (!empty($data['fk_facture'])) { - $html_class = 'facid-'.$data['fk_facture']; - } elseif (!empty($data['fk_paiement'])) { - $html_class = 'payid-'.$data['fk_paiement']; - } + if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture']; + elseif (!empty($data['fk_paiement'])) $html_class = 'payid-'.$data['fk_paiement']; @@ -273,6 +253,3 @@ - $datedetail = dol_print_date($data['date'], 'dayhour'); - if (!empty($data['fk_facture'])) { - $datedetail = dol_print_date($data['date'], 'day'); - } - print '<td class="center" title="'.dol_escape_htmltag($datedetail).'">'; - print dol_print_date($data['date'], 'day'); + print "<td class=\"center\">"; + if (!empty($data['fk_facture'])) print dol_print_date($data['date'], 'day'); + elseif (!empty($data['fk_paiement'])) print dol_print_date($data['date'], 'dayhour'); @@ -293 +270 @@ - print '<td class="right"><span class="amount">'.price($data['balance'])."</span></td>\n"; + print '<td class="right">'.price($data['balance'])."</td>\n"; @@ -314 +291,3 @@ -} else { +} +else +{