From 8afffc87627f1236d1355080c835a1dfc840dd76 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 14 Jun 2019 18:28:01 +0200 Subject: [PATCH 01/27] FIX: #11335 --- htdocs/fourn/facture/card.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 3956684d9b2..bca9cb8ad4e 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -4,7 +4,7 @@ * Copyright (C) 2004 Christophe Combelles * Copyright (C) 2005 Marc Barilley * Copyright (C) 2005-2013 Regis Houssin - * Copyright (C) 2010-2014 Juanjo Menent + * Copyright (C) 2010-2019 Juanjo Menent * Copyright (C) 2013-2015 Philippe Grand * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2016 Marcos García @@ -831,6 +831,8 @@ if (empty($reshook)) // Auto calculation of date due if not filled by user if(empty($object->date_echeance)) $object->date_echeance = $object->calculate_date_lim_reglement(); + $object->fetch_thirdparty(); + // If creation from another object of another module if (! $error && $_POST['origin'] && $_POST['originid']) { From a73ae49c4d623b3e9aabb31230187c4b5d264b04 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 14 Jun 2019 18:56:30 +0200 Subject: [PATCH 02/27] FIX: #11296 --- htdocs/projet/class/project.class.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 549865c63cd..5abf7e76d33 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -5,6 +5,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2017 Marcos García * Copyright (C) 2017 Ferran Marcet + * Copyright (C) 2019 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -695,6 +696,27 @@ class Project extends CommonObject $ret = $this->deleteTasks($user); if ($ret < 0) $error++; + + // Delete all child tables + if (! $error) { + $elements = array('categorie_project'); // elements to delete. TODO Make goodway to delete + foreach($elements as $table) + { + if (! $error) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$table; + $sql.= " WHERE fk_project = ".$this->id; + + $result = $this->db->query($sql); + if (! $result) { + $error++; + $this->errors[] = $this->db->lasterror(); + } + } + } + } + + + // Delete project if (! $error) { From c0a30d1ff5484471a9bb9aa8ab4f6c1dad0472c4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 16 Jun 2019 22:17:04 +0200 Subject: [PATCH 03/27] FIX #11325 FIX #5249 Conflicts: htdocs/projet/tasks/time.php --- htdocs/projet/tasks/time.php | 61 +++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 48167edcc1d..e69f4fcd899 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -317,7 +317,8 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $object->project = clone $projectstatic; } - $userWrite = $projectstatic->restrictedProjectArea($user,'write'); + $userRead = $projectstatic->restrictedProjectArea($user, 'read'); + $linktocreatetime = ''; if ($projectstatic->id > 0) { @@ -427,33 +428,30 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print '
'; // Link to create time - //if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) - //{ - if ($user->rights->projet->all->creer || $user->rights->projet->creer) - { - if ($projectstatic->public || $userWrite > 0) - { - if (! empty($projectidforalltimes)) // We are on tab 'Time Spent' of project - { - $backtourl = $_SERVER['PHP_SELF'].'?projectid='.$projectstatic->id.($withproject?'&withproject=1':''); - $linktocreatetime = ''.$langs->trans('AddTimeSpent').''; - } - else // We are on tab 'Time Spent' of task - { - $backtourl = $_SERVER['PHP_SELF'].'?id='.$object->id.($withproject?'&withproject=1':''); - $linktocreatetime = ''.$langs->trans('AddTimeSpent').''; - } - } - else - { - $linktocreatetime = ''.$langs->trans('AddTime').''; - } - } - else - { - $linktocreatetime = ''.$langs->trans('AddTime').''; - } - //} + if ($user->rights->projet->all->lire || $user->rights->projet->lire)) // To enter time, read permission is enough + { + if ($projectstatic->public || $userRead > 0) + { + if (! empty($projectidforalltimes)) // We are on tab 'Time Spent' of project + { + $backtourl = $_SERVER['PHP_SELF'].'?projectid='.$projectstatic->id.($withproject?'&withproject=1':''); + $linktocreatetime = ''.$langs->trans('AddTimeSpent').''; + } + else // We are on tab 'Time Spent' of task + { + $backtourl = $_SERVER['PHP_SELF'].'?id='.$object->id.($withproject?'&withproject=1':''); + $linktocreatetime = ''.$langs->trans('AddTimeSpent').''; + } + } + else + { + $linktocreatetime = ''.$langs->trans('AddTime').''; + } + } + else + { + $linktocreatetime = ''.$langs->trans('AddTime').''; + } } } @@ -803,7 +801,12 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) // Duration - Time spent print ''; - print $form->select_duration('timespent_duration', ($_POST['timespent_duration']?$_POST['timespent_duration']:''), 0, 'text'); + $durationtouse = ($_POST['timespent_duration']?$_POST['timespent_duration']:''); + if (GETPOSTISSET('timespent_durationhour') || GETPOSTISSET('timespent_durationmin')) + { + $durationtouse = (GETPOST('timespent_durationhour') * 3600 + GETPOST('timespent_durationmin') * 60); + } + print $form->select_duration('timespent_duration', $durationtouse, 0, 'text'); print ''; // Progress declared From 8330078de18ddd00c322398e94c5bf560161f5b5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 17 Jun 2019 12:33:09 +0200 Subject: [PATCH 04/27] Fix default value --- htdocs/core/class/html.formcompany.class.php | 4 ++-- htdocs/societe/card.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index d2fb93000a9..d1366cb8511 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -908,7 +908,7 @@ class FormCompany $out = ''; - } - } - $object = new stdClass(); - // Other attributes - $parameters=array('objectsrc' => null, 'colspan' => ' colspan="3"'); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook)) - { - print $object->showOptionals($extrafields, 'edit'); - } - }*/ +// Export is for current company only ! if (! empty($conf->multicompany->enabled) && is_object($mc)) { - print '   -   '.$langs->trans("Entity").' : '; + print '('.$langs->trans("Entity").' : '; $mc->dao->getEntities(); $mc->dao->fetch($conf->entity); print $mc->dao->label; - print "
\n"; + print ")
\n"; } print ''."\n"; @@ -376,10 +356,10 @@ if (!empty($date_start) && !empty($date_stop)) print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; print ''; - print_liste_field_titre($arrayfields['date']['label'], $_SERVER["PHP_SELF"], "date", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); + print_liste_field_titre($arrayfields['date']['label'], $_SERVER["PHP_SELF"], "date", "", $param, 'class="nowrap"', $sortfield, $sortorder); print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -402,12 +382,10 @@ if (!empty($date_start) && !empty($date_stop)) // Balance calculation $balance = 0; foreach($TData as &$data1) { - if ($data1['item']!='Invoice'&& $data1['item']!='Donation' ){ + if ($data1['item']!='Invoice' && $data1['item']!='Donation') + { $data1['amount']=-$data1['amount']; } - if ($data1['amount']>0){ - }else{ - } $balance += $data1['amount']; $data1['balance'] = $balance; } @@ -419,14 +397,19 @@ if (!empty($date_start) && !empty($date_stop)) //if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture']; //elseif (!empty($data['fk_paiement'])) $html_class = 'payid-'.$data['fk_paiement']; print ''; - print "\n"; print ''; print ''; // File link - print '\n"; + print '\n"; print ''; print '\n"; diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 3a4ec85ec58..c7b2c8a69a7 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -281,6 +281,8 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2430__+MAX_llx_menu__, 'accountancy', 'bookkeeping', 2400__+MAX_llx_menu__, '/accountancy/bookkeeping/list.php?mainmenu=accountancy&leftmenu=accountancy_bookeeping', 'Bookkeeping', 1, 'accountancy', '$user->rights->accounting->mouvements->lire', '', 0, 15, __ENTITY__); -- Balance insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2435__+MAX_llx_menu__, 'accountancy', 'balance', 2400__+MAX_llx_menu__, '/accountancy/bookkeeping/balance.php?mainmenu=accountancy&leftmenu=accountancy_balance', 'AccountBalance', 1, 'accountancy', '$user->rights->accounting->mouvements->lire', '', 0, 16, __ENTITY__); + -- Export accounting documents + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2436__+MAX_llx_menu__, 'accountancy', 'accountancy_files', 2400__+MAX_llx_menu__, '/compta/compta-files.php?mainmenu=accountancy&leftmenu=accountancy_files', 'AccountantFiles', 1, 'accountancy', '$user->rights->accounting->mouvements->lire', '', 0, 17, __ENTITY__); -- Reports insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2440__+MAX_llx_menu__, 'accountancy', 'accountancy_report', 2400__+MAX_llx_menu__, '/compta/resultat/index.php?mainmenu=accountancy&leftmenu=accountancy_report', 'Reportings', 1, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 17, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_report"', __HANDLER__, 'left', 2441__+MAX_llx_menu__, 'accountancy', 'accountancy_report', 2440__+MAX_llx_menu__, '/compta/resultat/index.php?mainmenu=accountancy&leftmenu=accountancy_report', 'MenuReportInOut', 2, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 18, __ENTITY__); From 08d5ca4ddbc47fcbcddf94a471657dda1e81cb9e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 17 Jun 2019 17:53:43 +0200 Subject: [PATCH 08/27] Debug page to export accounting documents --- htdocs/admin/delais.php | 1 - htdocs/admin/mails_emailing.php | 3 +- htdocs/admin/menus/edit.php | 1 - htdocs/admin/sms.php | 2 +- htdocs/cashdesk/css/style.css | 2 +- ...{compta-files.php => accounting-files.php} | 292 ++++++++++-------- htdocs/core/menus/standard/eldy.lib.php | 8 +- htdocs/expensereport/list.php | 2 +- htdocs/fourn/facture/card.php | 2 +- htdocs/holiday/card.php | 5 +- htdocs/holiday/list.php | 3 +- .../modulebuilder/template/myobject_card.php | 1 + htdocs/opensurvey/results.php | 2 +- htdocs/opensurvey/wizard/choix_date.php | 10 +- htdocs/opensurvey/wizard/create_survey.php | 2 +- htdocs/product/admin/product_tools.php | 3 +- htdocs/theme/eldy/btn.inc.php | 2 +- htdocs/theme/eldy/global.inc.php | 2 +- htdocs/theme/md/style.css.php | 4 +- 19 files changed, 188 insertions(+), 159 deletions(-) rename htdocs/compta/{compta-files.php => accounting-files.php} (60%) diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php index 1d05d5e0afe..6b46468b916 100644 --- a/htdocs/admin/delais.php +++ b/htdocs/admin/delais.php @@ -418,7 +418,6 @@ if($action == 'edit') { print '
'; } else { - // Boutons d'action print '
'; } diff --git a/htdocs/admin/mails_emailing.php b/htdocs/admin/mails_emailing.php index 1e54fdea3dd..12076a00579 100644 --- a/htdocs/admin/mails_emailing.php +++ b/htdocs/admin/mails_emailing.php @@ -493,7 +493,8 @@ else } - // Boutons actions + // Buttons for actions + print '
'; print ''.$langs->trans("Modify").''; diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php index b4f5fbd3355..cf42f294d03 100644 --- a/htdocs/admin/menus/edit.php +++ b/htdocs/admin/menus/edit.php @@ -415,7 +415,6 @@ if ($action == 'create') dol_fiche_end(); - // Boutons print '
'; print ''; print '     '; diff --git a/htdocs/admin/sms.php b/htdocs/admin/sms.php index 2fb1e5a8a29..d6f2ee170d8 100644 --- a/htdocs/admin/sms.php +++ b/htdocs/admin/sms.php @@ -243,7 +243,7 @@ else print '
'.$langs->trans("Type").''.$langs->trans("Ref").''.$langs->trans("Link").''.$langs->trans("Document").''.$langs->trans("Paid").''.$langs->trans("Debit").''.$langs->trans("Credit").'
"; + print ""; print dol_print_date($data['date'], 'day'); print "'.$langs->trans($data['item']).''.$data['ref'].'".$data['name']."'; + if ($data['link']) + { + print ''.($data['name'] ? $data['name'] : $data['ref']).''; + } + print "'.$data['paid'].''.(($data['amount'] > 0) ? price(abs($data['amount'])) : '')."
'; - // Boutons actions + // Buttons for actions print '
'; diff --git a/htdocs/cashdesk/css/style.css b/htdocs/cashdesk/css/style.css index dc579711aa3..9d9be27f3ce 100644 --- a/htdocs/cashdesk/css/style.css +++ b/htdocs/cashdesk/css/style.css @@ -320,7 +320,7 @@ p.titre { padding: 2px 2px; } -/* -------------- Boutons --------------------- */ +/* -------------- Buttons for SimplePOS --------------------- */ .bouton_ajout_article { margin-top: 10px; width: 60%; diff --git a/htdocs/compta/compta-files.php b/htdocs/compta/accounting-files.php similarity index 60% rename from htdocs/compta/compta-files.php rename to htdocs/compta/accounting-files.php index 656824298fe..5a3097f6aa8 100644 --- a/htdocs/compta/compta-files.php +++ b/htdocs/compta/accounting-files.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2018 Laurent Destailleur + * Copyright (C) 2004-2019 Laurent Destailleur * Copyright (C) 2017 Pierre-Henry Favre * * This program is free software; you can redistribute it and/or modify @@ -16,11 +16,13 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -/** - * \file htdocs/compta/compta-files.php + + /** + * \file htdocs/compta/accounting-files.php * \ingroup compta * \brief Page to show portoflio and files of a thirdparty and download it */ + require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -89,149 +91,165 @@ $entity = GETPOST('entity', 'int')?GETPOST('entity', 'int'):$conf->entity; $filesarray=array(); $result=false; -if(($action=="searchfiles" || $action=="dl" ) && $date_start && $date_stop) { - $wheretail=" '".$db->idate($date_start)."' AND '".$db->idate($date_stop)."'"; - $sql="SELECT rowid as id, ref as ref, paye as paid, total_ttc, fk_soc, datef as date, 'Invoice' as item FROM ".MAIN_DB_PREFIX."facture"; - $sql.=" WHERE datef between ".$wheretail; - $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')'; - $sql.=" AND fk_statut <> ".Facture::STATUS_DRAFT; - $sql.=" UNION ALL"; - $sql.=" SELECT rowid as id, ref, paye as paid, total_ttc, fk_soc, datef as date, 'SupplierInvoice' as item FROM ".MAIN_DB_PREFIX."facture_fourn"; - $sql.=" WHERE datef between ".$wheretail; - $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')'; - $sql.=" AND fk_statut <> ".FactureFournisseur::STATUS_DRAFT; - $sql.=" UNION ALL"; - $sql.=" SELECT rowid as id, ref, paid, total_ttc, fk_user_author as fk_soc, date_fin as date, 'ExpenseReport' as item FROM ".MAIN_DB_PREFIX."expensereport"; - $sql.=" WHERE date_fin between ".$wheretail; - $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')'; - $sql.=" AND fk_statut <> ".ExpenseReport::STATUS_DRAFT; - $sql.=" UNION ALL"; - $sql.=" SELECT rowid as id, ref, paid, amount as total_ttc, '0' as fk_soc, datedon as date, 'Donation' as item FROM ".MAIN_DB_PREFIX."don"; - $sql.=" WHERE datedon between ".$wheretail; - $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')'; - $sql.=" AND fk_statut <> ".Don::STATUS_DRAFT; - $sql.=" UNION ALL"; - $sql.=" SELECT rowid as id, label as ref, 1 as paid, amount as total_ttc, fk_user as fk_soc,datep as date, 'SalaryPayment' as item FROM ".MAIN_DB_PREFIX."payment_salary"; - $sql.=" WHERE datep between ".$wheretail; - $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')'; - //$sql.=" AND fk_statut <> ".PaymentSalary::STATUS_DRAFT; - $sql.=" UNION ALL"; - $sql.=" SELECT rowid as id, libelle as ref, paye as paid, amount as total_ttc, 0 as fk_soc, date_creation as date, 'SocialContributions' as item FROM ".MAIN_DB_PREFIX."chargesociales"; - $sql.=" WHERE date_creation between ".$wheretail; - $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')'; - //$sql.=" AND fk_statut <> ".ChargeSociales::STATUS_DRAFT; - $sql.= $db->order($sortfield, $sortorder); +if (($action=="searchfiles" || $action=="dl" )) { - $resd = $db->query($sql); - $files=array(); - $link=''; + if (empty($date_start)) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateStart")), null, 'errors'); + $error++; + } + if (empty($date_stop)) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateEnd")), null, 'errors'); + $error++; + } - if ($resd) - { - $numd = $db->num_rows($resd); + if (! $error) + { + $wheretail=" '".$db->idate($date_start)."' AND '".$db->idate($date_stop)."'"; - $tmpinvoice=new Facture($db); - $tmpinvoicesupplier=new FactureFournisseur($db); - $tmpdonation=new Don($db); + $sql="SELECT rowid as id, ref as ref, paye as paid, total_ttc, fk_soc, datef as date, 'Invoice' as item FROM ".MAIN_DB_PREFIX."facture"; + $sql.=" WHERE datef between ".$wheretail; + $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')'; + $sql.=" AND fk_statut <> ".Facture::STATUS_DRAFT; + $sql.=" UNION ALL"; + $sql.=" SELECT rowid as id, ref, paye as paid, total_ttc, fk_soc, datef as date, 'SupplierInvoice' as item FROM ".MAIN_DB_PREFIX."facture_fourn"; + $sql.=" WHERE datef between ".$wheretail; + $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')'; + $sql.=" AND fk_statut <> ".FactureFournisseur::STATUS_DRAFT; + $sql.=" UNION ALL"; + $sql.=" SELECT rowid as id, ref, paid, total_ttc, fk_user_author as fk_soc, date_fin as date, 'ExpenseReport' as item FROM ".MAIN_DB_PREFIX."expensereport"; + $sql.=" WHERE date_fin between ".$wheretail; + $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')'; + $sql.=" AND fk_statut <> ".ExpenseReport::STATUS_DRAFT; + $sql.=" UNION ALL"; + $sql.=" SELECT rowid as id, ref, paid, amount as total_ttc, '0' as fk_soc, datedon as date, 'Donation' as item FROM ".MAIN_DB_PREFIX."don"; + $sql.=" WHERE datedon between ".$wheretail; + $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')'; + $sql.=" AND fk_statut <> ".Don::STATUS_DRAFT; + $sql.=" UNION ALL"; + $sql.=" SELECT rowid as id, label as ref, 1 as paid, amount as total_ttc, fk_user as fk_soc,datep as date, 'SalaryPayment' as item FROM ".MAIN_DB_PREFIX."payment_salary"; + $sql.=" WHERE datep between ".$wheretail; + $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')'; + //$sql.=" AND fk_statut <> ".PaymentSalary::STATUS_DRAFT; + $sql.=" UNION ALL"; + $sql.=" SELECT rowid as id, libelle as ref, paye as paid, amount as total_ttc, 0 as fk_soc, date_creation as date, 'SocialContributions' as item FROM ".MAIN_DB_PREFIX."chargesociales"; + $sql.=" WHERE date_creation between ".$wheretail; + $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')'; + //$sql.=" AND fk_statut <> ".ChargeSociales::STATUS_DRAFT; + $sql.= $db->order($sortfield, $sortorder); - $upload_dir =''; - $i=0; - while ($i < $numd) - { - $objd = $db->fetch_object($resd); + $resd = $db->query($sql); + $files=array(); + $link=''; - 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'; - 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'; - 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'; - 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'; - 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'; - 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'; - break; - default: - $subdir = ''; - $upload_dir = ''; - $link = ''; - break; - } + if ($resd) + { + $numd = $db->num_rows($resd); - if (!empty($upload_dir)) - { - $result=true; + $tmpinvoice=new Facture($db); + $tmpinvoicesupplier=new FactureFournisseur($db); + $tmpdonation=new Don($db); - $files=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview\.png)$', '', SORT_ASC, 1); + $upload_dir =''; + $i=0; + while ($i < $numd) + { + $objd = $db->fetch_object($resd); - if (count($files) < 1) - { - $nofile['id']=$objd->id; - $nofile['date']=$db->idate($objd->date); - $nofile['paid']=$objd->paid; - $nofile['amount']=$objd->total_ttc; - $nofile['ref']=($objd->ref ? $objd->ref : $objd->id); - $nofile['fk']=$objd->fk_soc; - $nofile['item']=$objd->item; + 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'; + 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'; + 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'; + 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'; + 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'; + 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'; + break; + default: + $subdir = ''; + $upload_dir = ''; + $link = ''; + break; + } - $filesarray[]=$nofile; - } - else - { - foreach ($files as $key => $file) - { - $file['id']=$objd->id; - $file['date']=$db->idate($objd->date); - $file['paid']=$objd->paid; - $file['amount']=$objd->total_ttc; - $file['ref']=($objd->ref ? $objd->ref : $objd->id); - $file['fk']=$objd->fk_soc; - $file['item']=$objd->item; - $file['link']=$link.$file['name']; - $file['relpathnamelang'] = $langs->trans($file['item']).'/'.$file['name']; + if (!empty($upload_dir)) + { + $result=true; - $filesarray[]=$file; - } - } - } - $i++; - } - } - else - { - dol_print_error($db); - } + $files=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview\.png)$', '', SORT_ASC, 1); - $db->free($resd); + if (count($files) < 1) + { + $nofile['id']=$objd->id; + $nofile['date']=$db->idate($objd->date); + $nofile['paid']=$objd->paid; + $nofile['amount']=$objd->total_ttc; + $nofile['ref']=($objd->ref ? $objd->ref : $objd->id); + $nofile['fk']=$objd->fk_soc; + $nofile['item']=$objd->item; + + $filesarray[]=$nofile; + } + else + { + foreach ($files as $key => $file) + { + $file['id']=$objd->id; + $file['date']=$db->idate($objd->date); + $file['paid']=$objd->paid; + $file['amount']=$objd->total_ttc; + $file['ref']=($objd->ref ? $objd->ref : $objd->id); + $file['fk']=$objd->fk_soc; + $file['item']=$objd->item; + $file['link']=$link.$file['name']; + $file['relpathnamelang'] = $langs->trans($file['item']).'/'.$file['name']; + + $filesarray[]=$file; + } + } + } + $i++; + } + } + else + { + dol_print_error($db); + } + + $db->free($resd); + } } /* @@ -318,7 +336,9 @@ if (! empty($conf->multicompany->enabled) && is_object($mc)) print ")\n"; } -print ''."\n"; +print ''; + +print ''."\n"; dol_fiche_end(); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 3576f35642e..7518093bf77 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1287,7 +1287,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // Files if (! empty($conf->global->MAIN_FEATURES_LEVEL) && $conf->global->MAIN_FEATURES_LEVEL >= 1) { - $newmenu->add("/compta/compta-files.php?mainmenu=accountancy&leftmenu=accountancy_files", $langs->trans("AccountantFiles"), 1, $user->rights->accounting->mouvements->lire); + $newmenu->add("/compta/accounting-files.php?mainmenu=accountancy&leftmenu=accountancy_files", $langs->trans("AccountantFiles"), 1, $user->rights->accounting->mouvements->lire); } // Reports @@ -1329,6 +1329,12 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // Accountancy (simple) if (! empty($conf->comptabilite->enabled)) { + // Files + if (! empty($conf->global->MAIN_FEATURES_LEVEL) && $conf->global->MAIN_FEATURES_LEVEL >= 1) + { + $newmenu->add("/compta/accounting-files.php?mainmenu=accountancy&leftmenu=accountancy_files", $langs->trans("AccountantFiles"), 0, $user->rights->compta->resultat->lire, '', $mainmenu, 'files'); + } + // Bilan, resultats $newmenu->add("/compta/resultat/index.php?leftmenu=report&mainmenu=accountancy", $langs->trans("Reportings"), 0, $user->rights->compta->resultat->lire, '', $mainmenu, 'ca'); diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index 94033912a69..34cbdfe89bd 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -434,7 +434,7 @@ if ($resql) $canedit=((in_array($user_id, $childids) && $user->rights->expensereport->creer) || ($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->expensereport->writeall_advance)); - // Boutons d'actions + // Buttons for actions if ($canedit) { print ''.$langs->trans("AddTrip").''; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 2cd27d6d688..1eb38cec66c 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -3021,7 +3021,7 @@ else if ($action != 'presend') { /* - * Boutons actions + * Buttons actions */ print '
'; diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 6c4cb05a17e..c67daf8f92b 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -1391,9 +1391,10 @@ else if (! $edit) { - print '
'; + // Buttons for actions + + print '
'; - // Boutons d'actions if ($cancreate && $object->statut == Holiday::STATUS_DRAFT) { print ''.$langs->trans("EditCP").''; diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 84e7b36c239..ce038709fcf 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -319,11 +319,12 @@ if ($id > 0) // For user tab dol_fiche_end(); + // Buttons for actions + print '
'; $canedit=(($user->id == $user_id && $user->rights->holiday->write) || ($user->id != $user_id && $user->rights->holiday->write_all)); - // Boutons d'actions if ($canedit) { print ''.$langs->trans("AddCP").''; diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index da6f3c5a466..cc2eb5062cb 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -421,6 +421,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Buttons for actions + if ($action != 'presend' && $action != 'editline') { print '
'."\n"; $parameters=array(); diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php index 076461043b8..c648b15664e 100644 --- a/htdocs/opensurvey/results.php +++ b/htdocs/opensurvey/results.php @@ -619,7 +619,7 @@ print ''."\n"; print ''."\n"; print ''."\n"; -//boucle pour l'affichage des boutons de suppression de colonne +// loop to show the delete link if ($user->rights->opensurvey->write) { for ($i = 0; isset($toutsujet[$i]); $i++) { diff --git a/htdocs/opensurvey/wizard/choix_date.php b/htdocs/opensurvey/wizard/choix_date.php index 8840da3f3e7..76f390c470b 100644 --- a/htdocs/opensurvey/wizard/choix_date.php +++ b/htdocs/opensurvey/wizard/choix_date.php @@ -471,7 +471,7 @@ for ($i = 0; $i < $nbrejourmois + $premierjourmois; $i++) { { $nbofchoice=count($_SESSION["totalchoixjour"]); for ($j = 0; $j < $nbofchoice; $j++) { - //affichage des boutons ROUGES + // show red buttons if (date("j", $_SESSION["totalchoixjour"][$j]) == $numerojour && date("n", $_SESSION["totalchoixjour"][$j]) == $_SESSION["mois"] && date("Y", $_SESSION["totalchoixjour"][$j]) == $_SESSION["annee"]) { print ''."\n"; $dejafait = $numerojour; @@ -479,13 +479,13 @@ for ($i = 0; $i < $nbrejourmois + $premierjourmois; $i++) { } } - //Si pas de bouton ROUGE alors on affiche un bouton VERT ou GRIS avec le numéro du jour dessus + // If no red button, we show green or grey button with number of day if (isset($dejafait) === false || $dejafait != $numerojour){ - //bouton vert + // green button if (($numerojour >= $jourAJ && $_SESSION["mois"] == $moisAJ && $_SESSION["annee"] == $anneeAJ) || ($_SESSION["mois"] > $moisAJ && $_SESSION["annee"] == $anneeAJ) || $_SESSION["annee"] > $anneeAJ) { print ''."\n"; } else { - //bouton gris + // grey button print ''.$numerojour.''."\n"; } } @@ -547,7 +547,7 @@ if (issetAndNoEmpty('totalchoixjour', $_SESSION) || $erreur) print ''."\n"; - //affichage des boutons de formulaire pour annuler, effacer les jours ou créer le sondage + // show buttons to cancel, delete days or create survey print ''."\n"; print ''."\n"; print ''."\n"; diff --git a/htdocs/opensurvey/wizard/create_survey.php b/htdocs/opensurvey/wizard/create_survey.php index 0c746fcf8b2..c2e6db1a709 100644 --- a/htdocs/opensurvey/wizard/create_survey.php +++ b/htdocs/opensurvey/wizard/create_survey.php @@ -194,7 +194,7 @@ if (GETPOST('choix_sondage')) } else { - // affichage des boutons pour choisir sondage date ou autre + // Show image to selecte between date survey or other survey print '
'."\n"; print ' '."\n"; print ''."\n"; diff --git a/htdocs/product/admin/product_tools.php b/htdocs/product/admin/product_tools.php index e76c6884b7f..cfbedbcb7f1 100644 --- a/htdocs/product/admin/product_tools.php +++ b/htdocs/product/admin/product_tools.php @@ -333,7 +333,8 @@ else print '
'; - // Boutons actions + // Buttons for actions + print '
'; print ''; print '
'; diff --git a/htdocs/theme/eldy/btn.inc.php b/htdocs/theme/eldy/btn.inc.php index c0cd029126d..1d00718401b 100644 --- a/htdocs/theme/eldy/btn.inc.php +++ b/htdocs/theme/eldy/btn.inc.php @@ -5,7 +5,7 @@ if (! defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> /* ============================================================================== */ -/* Boutons actions */ +/* Buttons for actions */ /* ============================================================================== */ div.divButAction { diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index e5e68e59c48..9061595dd1d 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -2362,7 +2362,7 @@ span.tabspan { } /* ============================================================================== */ -/* Boutons actions */ +/* Buttons for actions */ /* ============================================================================== */ diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 752f60541d1..8020a490181 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -2400,7 +2400,7 @@ div.tabBar table.tableforservicepart2:last-child { } /* ============================================================================== */ -/* Boutons actions */ +/* Buttons for actions */ /* ============================================================================== */ div.divButAction { @@ -2503,7 +2503,7 @@ span.tabspan { } /* ============================================================================== */ -/* Boutons actions */ +/* Buttons for actions */ /* ============================================================================== */ div.divButAction { From f6f66f2a77ed56e5dc2798fc92792d29d59c11b8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 17 Jun 2019 18:11:38 +0200 Subject: [PATCH 09/27] Fix syntax error --- htdocs/projet/tasks/time.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index e69f4fcd899..f98c9c4ace5 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -428,7 +428,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print '
'; // Link to create time - if ($user->rights->projet->all->lire || $user->rights->projet->lire)) // To enter time, read permission is enough + if ($user->rights->projet->all->lire || $user->rights->projet->lire) // To enter time, read permission is enough { if ($projectstatic->public || $userRead > 0) { From f6f86927113f99e52343b10db1438a4f666cd3db Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 17 Jun 2019 18:12:28 +0200 Subject: [PATCH 10/27] Fix phpcs --- htdocs/bom/bom_card.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index c2ed2ca6705..d788be5354a 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -173,7 +173,6 @@ if (empty($reshook)) $action = ''; } } - } From bde49e05e7aca32b0da06eff0ed0b0235720134e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 17 Jun 2019 18:23:38 +0200 Subject: [PATCH 11/27] Fix doc --- htdocs/societe/class/societeaccount.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/societeaccount.class.php b/htdocs/societe/class/societeaccount.class.php index 3fc7b225c77..a82ad69091b 100644 --- a/htdocs/societe/class/societeaccount.class.php +++ b/htdocs/societe/class/societeaccount.class.php @@ -320,7 +320,7 @@ class SocieteAccount extends CommonObject * @param string $id Id of customer in external system (example: 'cu_xxxxxxxxxxxxx', ...) * @param string $site Site (example: 'stripe', '...') * @param int $status Status (0=test, 1=live) - * @return string Id of third party + * @return int Id of third party * @see getCustomerAccount() */ public function getThirdPartyID($id, $site, $status = 0) From a6d4475afff68f0ce1c0e808aec631a553d97f6a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 17 Jun 2019 18:24:45 +0200 Subject: [PATCH 12/27] Fix scrutinizer --- htdocs/stripe/class/stripe.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index dd66c7607e5..d754b8d3962 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -247,6 +247,8 @@ class Stripe extends CommonObject */ public function getPaymentMethodStripe($paymentmethod, $key = '', $status = 0) { + $stripepaymentmethod = null; + try { // Force to use the correct API key global $stripearrayofkeysbyenv; @@ -261,6 +263,7 @@ class Stripe extends CommonObject { $this->error = $e->getMessage(); } + return $stripepaymentmethod; } From 42e58d9ea59f6231dc08836f0e719fb7a83253bb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 17 Jun 2019 18:38:14 +0200 Subject: [PATCH 13/27] Fix preview of interventions --- htdocs/core/lib/functions.lib.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 4bbd030b1eb..7341bc0c2cb 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1330,10 +1330,10 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi $nophoto=''; $morehtmlleft.='
'; } - //elseif ($conf->browser->layout != 'phone') { // Show no photo link + else { // Show no photo link $nophoto='/public/theme/common/nophoto.png'; $morehtmlleft.='
No photo
'; - //} + } } } elseif ($object->element == 'ticket') @@ -1349,10 +1349,10 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi $nophoto=''; $morehtmlleft.='
'; } - //elseif ($conf->browser->layout != 'phone') { // Show no photo link - $nophoto='/public/theme/common/nophoto.png'; - $morehtmlleft.='
No photo
'; - //} + else { // Show no photo link + $nophoto='/public/theme/common/nophoto.png'; + $morehtmlleft.='
No photo
'; + } } } else @@ -5260,7 +5260,7 @@ function get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart) // Here, object->id, object->ref and modulepart are required. //var_dump($modulepart); if (in_array($modulepart, array('thirdparty','contact','member','propal','proposal','commande','order','facture','invoice', - 'supplier_order','supplier_proposal','shipment','contract','expensereport'))) + 'supplier_order','supplier_proposal','shipment','contract','expensereport','ficheinter'))) { $path=($object->ref?$object->ref:$object->id); } From 0123a18ff86c89272404e57ae6cb65ccfd3c4566 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 17 Jun 2019 18:44:08 +0200 Subject: [PATCH 14/27] Look and feel v10 --- htdocs/core/tpl/resource_view.tpl.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/tpl/resource_view.tpl.php b/htdocs/core/tpl/resource_view.tpl.php index d2e0441b60b..014560e0299 100644 --- a/htdocs/core/tpl/resource_view.tpl.php +++ b/htdocs/core/tpl/resource_view.tpl.php @@ -53,11 +53,11 @@ if( (array) $linked_resources && count($linked_resources) > 0) } else { - $style=''; + $class=''; if ($linked_resource['rowid'] == GETPOST('lineid')) - $style='style="background: orange;"'; + $class='highlight'; - print '
'; + print '
'; print '
'; print $object_resource->getNomUrl(1); @@ -81,7 +81,7 @@ if( (array) $linked_resources && count($linked_resources) > 0) print ''; print ' '; print ''; - print img_delete(); + print img_picto($langs->trans("Unlink"), 'unlink'); print ''; print '
'; From 8835b49f3fccc90cbe52d2a83c61d61323017f2e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Jun 2019 14:30:13 +0200 Subject: [PATCH 15/27] Debug the accounting-file tool --- htdocs/compta/accounting-files.php | 278 +++++++++++------- .../install/mysql/migration/9.0.0-10.0.0.sql | 2 + htdocs/install/mysql/migration/repair.sql | 1 + htdocs/user/param_ihm.php | 2 +- 4 files changed, 177 insertions(+), 106 deletions(-) diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index 5a3097f6aa8..c663a179d6d 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -16,13 +16,11 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - - /** +/** * \file htdocs/compta/accounting-files.php * \ingroup compta * \brief Page to show portoflio and files of a thirdparty and download it */ - require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -34,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; -$langs->loadLangs(array("accountancy", "bills", "companies")); +$langs->loadLangs(array("accountancy", "bills", "companies", "salaries")); $date_start =GETPOST('date_start', 'alpha'); $date_startDay= GETPOST('date_startday', 'int'); @@ -46,11 +44,11 @@ $date_stopDay= GETPOST('date_stopday', 'int'); $date_stopMonth= GETPOST('date_stopmonth', 'int'); $date_stopYear= GETPOST('date_stopyear', 'int'); //FIXME doldate -$date_stop=($date_stopDay)?dol_mktime(0, 0, 0, $date_stopMonth, $date_stopDay, $date_stopYear):strtotime($date_stop); +$date_stop=($date_stopDay)?dol_mktime(23, 59, 59, $date_stopMonth, $date_stopDay, $date_stopYear):strtotime($date_stop); $action =GETPOST('action', 'alpha'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('comptafileslist', 'globallist')); +$hookmanager->initHooks(array('comptafileslist','globallist')); // Load variable for pagination $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; @@ -66,6 +64,7 @@ if (! $sortorder) $sortorder="DESC"; $arrayfields=array( + 'type'=>array('label'=>"Type", 'checked'=>1), 'date'=>array('label'=>"Date", 'checked'=>1), //... ); @@ -83,7 +82,7 @@ if ($user->societe_id > 0) * Actions */ -$entity = GETPOST('entity', 'int')?GETPOST('entity', 'int'):$conf->entity; +$entity = GETPOST('entity','int')?GETPOST('entity','int'):$conf->entity; //$parameters = array('socid' => $id); //$reshook = $hookmanager->executeHooks('doActions', $parameters, $object); // Note that $object may have been modified by some hooks @@ -106,38 +105,45 @@ if (($action=="searchfiles" || $action=="dl" )) { if (! $error) { - $wheretail=" '".$db->idate($date_start)."' AND '".$db->idate($date_stop)."'"; + $wheretail=" '".$db->idate($date_start)."' AND '".$db->idate($date_stop)."'"; - $sql="SELECT rowid as id, ref as ref, paye as paid, total_ttc, fk_soc, datef as date, 'Invoice' as item FROM ".MAIN_DB_PREFIX."facture"; + $sql="SELECT t.rowid as id, t.ref, t.paye as paid, total as total_ht, total_ttc, tva as total_vat, fk_soc, t.datef as date, 'Invoice' as item, s.nom as thirdparty_name, s.code_client as thirdparty_code, c.code as country_code, s.tva_intra as vatnum"; + $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 entity IN (".($entity==1?'0,1':$entity).')'; - $sql.=" AND fk_statut <> ".Facture::STATUS_DRAFT; + $sql.=" AND t.entity IN (".($entity==1?'0,1':$entity).')'; + $sql.=" AND t.fk_statut <> ".Facture::STATUS_DRAFT; $sql.=" UNION ALL"; - $sql.=" SELECT rowid as id, ref, paye as paid, total_ttc, fk_soc, datef as date, 'SupplierInvoice' as item FROM ".MAIN_DB_PREFIX."facture_fourn"; + $sql.=" SELECT t.rowid as id, t.ref, paye as paid, total_ht, total_ttc, total_tva as total_vat, fk_soc, datef as date, 'SupplierInvoice' as item, s.nom as thirdparty_name, s.code_fournisseur as thirdparty_code, c.code as country_code, s.tva_intra as vatnum"; + $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 entity IN (".($entity==1?'0,1':$entity).')'; - $sql.=" AND fk_statut <> ".FactureFournisseur::STATUS_DRAFT; + $sql.=" AND t.entity IN (".($entity==1?'0,1':$entity).')'; + $sql.=" AND t.fk_statut <> ".FactureFournisseur::STATUS_DRAFT; $sql.=" UNION ALL"; - $sql.=" SELECT rowid as id, ref, paid, total_ttc, fk_user_author as fk_soc, date_fin as date, 'ExpenseReport' as item FROM ".MAIN_DB_PREFIX."expensereport"; + $sql.=" SELECT t.rowid as id, t.ref, paid, total_ht, total_ttc, total_tva as total_vat, fk_user_author as fk_soc, date_fin as date, 'ExpenseReport' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; + $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 entity IN (".($entity==1?'0,1':$entity).')'; - $sql.=" AND fk_statut <> ".ExpenseReport::STATUS_DRAFT; + $sql.=" AND t.entity IN (".($entity==1?'0,1':$entity).')'; + $sql.=" AND t.fk_statut <> ".ExpenseReport::STATUS_DRAFT; $sql.=" UNION ALL"; - $sql.=" SELECT rowid as id, ref, paid, amount as total_ttc, '0' as fk_soc, datedon as date, 'Donation' as item FROM ".MAIN_DB_PREFIX."don"; + $sql.=" SELECT t.rowid as id, t.ref, paid, amount as total_ht, amount as total_ttc, 0 as total_vat, 0 as fk_soc, datedon as date, 'Donation' as item, t.societe as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; + $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 entity IN (".($entity==1?'0,1':$entity).')'; - $sql.=" AND fk_statut <> ".Don::STATUS_DRAFT; + $sql.=" AND t.entity IN (".($entity==1?'0,1':$entity).')'; + $sql.=" AND t.fk_statut <> ".Don::STATUS_DRAFT; $sql.=" UNION ALL"; - $sql.=" SELECT rowid as id, label as ref, 1 as paid, amount as total_ttc, fk_user as fk_soc,datep as date, 'SalaryPayment' as item FROM ".MAIN_DB_PREFIX."payment_salary"; + $sql.=" SELECT t.rowid as id, 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, datep as date, 'SalaryPayment' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; + $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 entity IN (".($entity==1?'0,1':$entity).')'; + $sql.=" AND t.entity IN (".($entity==1?'0,1':$entity).')'; //$sql.=" AND fk_statut <> ".PaymentSalary::STATUS_DRAFT; $sql.=" UNION ALL"; - $sql.=" SELECT rowid as id, libelle as ref, paye as paid, amount as total_ttc, 0 as fk_soc, date_creation as date, 'SocialContributions' as item FROM ".MAIN_DB_PREFIX."chargesociales"; + $sql.=" SELECT t.rowid as id, t.libelle as ref, paye as paid, amount as total_ht, amount as total_ttc, 0 as total_tva, 0 as fk_soc, date_creation as date, 'SocialContributions' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum"; + $sql.=" FROM ".MAIN_DB_PREFIX."chargesociales as t"; $sql.=" WHERE date_creation between ".$wheretail; - $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')'; + $sql.=" AND t.entity IN (".($entity==1?'0,1':$entity).')'; //$sql.=" AND fk_statut <> ".ChargeSociales::STATUS_DRAFT; $sql.= $db->order($sortfield, $sortorder); + //print $sql; $resd = $db->query($sql); $files=array(); @@ -162,63 +168,68 @@ if (($action=="searchfiles" || $action=="dl" )) { 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'; - break; + $upload_dir = $conf->facture->dir_output.'/'.$subdir; + $link="document.php?modulepart=facture&file=".str_replace('/', '%2F', $subdir).'%2F'; + 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'; - break; + $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'; + 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'; - break; + $upload_dir = $conf->expensereport->dir_output.'/'.$subdir; + $link="document.php?modulepart=expensereport&file=".str_replace('/', '%2F', $subdir).'%2F'; + 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'; - break; + $upload_dir = $conf->salaries->dir_output.'/'.$subdir; + $link="document.php?modulepart=salaries&file=".str_replace('/', '%2F', $subdir).'%2F'; + 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'; - break; + $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'; + 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'; - break; + $upload_dir = $conf->tax->dir_output . '/' . $subdir; + $link="document.php?modulepart=tax&file=".str_replace('/', '%2F', $subdir).'%2F'; + break; default: - $subdir = ''; - $upload_dir = ''; - $link = ''; + $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); if (count($files) < 1) { - $nofile['id']=$objd->id; - $nofile['date']=$db->idate($objd->date); + $nofile['id']=$objd->id; + $nofile['date']=$db->idate($objd->date); $nofile['paid']=$objd->paid; - $nofile['amount']=$objd->total_ttc; + $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; $filesarray[]=$nofile; } @@ -226,13 +237,21 @@ if (($action=="searchfiles" || $action=="dl" )) { { foreach ($files as $key => $file) { - $file['id']=$objd->id; - $file['date']=$db->idate($objd->date); + $file['id']=$objd->id; + $file['date']=$db->idate($objd->date); $file['paid']=$objd->paid; - $file['amount']=$objd->total_ttc; + $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['link']=$link.$file['name']; $file['relpathnamelang'] = $langs->trans($file['item']).'/'.$file['name']; @@ -252,27 +271,30 @@ if (($action=="searchfiles" || $action=="dl" )) { } } -/* - * cleanup of old ZIP - */ -//FIXME + /* *ZIP creation */ -if ($result && $action == "dl") +$dirfortmpfile = ($conf->accounting->dir_temp ? $conf->accounting->dir_temp : $conf->comptabilite->dir_temp); +if (empty($dirfortmpfile)) { - if (! extension_loaded('zip')) - { - setEventMessages('PHPZIPExtentionNotLoaded', null, 'errors'); - exit; - } + setEventMessages($langs->trans("ErrorNoAccountingModuleEnabled"), null, 'errors'); + $error++; +} - $dirfortmpfile = ($conf->accounting->dir_temp ? $conf->accounting->dir_temp : $conf->compta->dir_temp); + +if ($result && $action == "dl" && ! $error) +{ + if (! extension_loaded('zip')) + { + setEventMessages('PHPZIPExtentionNotLoaded', null, 'errors'); + exit; + } dol_mkdir($dirfortmpfile); - $log='date,type,ref,total,paid,filename,item_id'."\n"; + $log=$langs->transnoentitiesnoconv("Type").','.$langs->transnoentitiesnoconv("Date").','.$langs->transnoentitiesnoconv("Ref").','.$langs->transnoentitiesnoconv("TotalHT").','.$langs->transnoentitiesnoconv("TotalTTC").','.$langs->transnoentitiesnoconv("TotalVAT").','.$langs->transnoentitiesnoconv("Paid").',filename,item_id,'.$langs->trans("ThirdParty").','.$langs->trans("Code").','.$langs->trans("Country").','.$langs->trans("VATIntra")."\n"; $zipname = $dirfortmpfile.'/'.dol_print_date($date_start, 'dayrfc')."-".dol_print_date($date_stop, 'dayrfc').'_export.zip'; dol_delete_file($zipname); @@ -281,10 +303,10 @@ if ($result && $action == "dl") $res = $zip->open($zipname, ZipArchive::OVERWRITE|ZipArchive::CREATE); if ($res) { - foreach ($filesarray as $key=> $file) + foreach ($filesarray as $key => $file) { if (file_exists($file["fullname"])) $zip->addFile($file["fullname"], $file["relpathnamelang"]); // - $log.=dol_print_date($file['date'], 'dayrfc').','.$file['item'].','.$file['ref'].','.$file['amount'].','.$file['paid'].','.$file["name"].','.$file['fk']."\n"; + $log.=$file['item'].','.dol_print_date($file['date'], 'dayrfc').','.$file['ref'].','.$file['amount_ht'].','.$file['amount_ttc'].','.$file['amount_vat'].','.$file['paid'].','.$file["name"].','.$file['fk'].','.$file['thirdparty_name'].','.$file['thirdparty_code'].','.$file['country_code'].',"'.$file['vatnum'].'"'."\n"; } $zip->addFromString('transactions.csv', $log); $zip->close(); @@ -299,6 +321,10 @@ if ($result && $action == "dl") exit(); } + else + { + setEventMessages($langs->trans("FailedToOpenFile", $zipname), null, 'errors'); + } } @@ -329,11 +355,11 @@ print ' - '.$form->selectDate($date_stop, 'date_stop', 0, 0, 0, "", 1, 1, 0)."\n // Export is for current company only ! if (! empty($conf->multicompany->enabled) && is_object($mc)) { - print '('.$langs->trans("Entity").' : '; - $mc->dao->getEntities(); - $mc->dao->fetch($conf->entity); - print $mc->dao->label; - print ")\n"; + print '('.$langs->trans("Entity").' : '; + $mc->dao->getEntities(); + $mc->dao->fetch($conf->entity); + print $mc->dao->label; + print ")\n"; } print ''; @@ -376,14 +402,18 @@ if (!empty($date_start) && !empty($date_stop)) print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print '
'. $langs->trans("CreateSurveyDate") .'
'; print ''; - print_liste_field_titre($arrayfields['date']['label'], $_SERVER["PHP_SELF"], "date", "", $param, 'class="nowrap"', $sortfield, $sortorder); - print ''; + print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], "type", "", $param, '', $sortfield, $sortorder, 'nowrap '); + print_liste_field_titre($arrayfields['date']['label'], $_SERVER["PHP_SELF"], "date", "", $param, '', $sortfield, $sortorder, 'center nowrap '); print ''; print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print ''; if ($result) { @@ -397,18 +427,11 @@ if (!empty($date_start) && !empty($date_stop)) { // Sort array by date ASC to calculate balance + $totalET = 0; + $totalIT = 0; + $totalVAT = 0; $totalDebit = 0; $totalCredit = 0; - // Balance calculation - $balance = 0; - foreach($TData as &$data1) { - if ($data1['item']!='Invoice' && $data1['item']!='Donation') - { - $data1['amount']=-$data1['amount']; - } - $balance += $data1['amount']; - $data1['balance'] = $balance; - } // Display array foreach($TData as $data) @@ -417,11 +440,17 @@ if (!empty($date_start) && !empty($date_stop)) //if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture']; //elseif (!empty($data['fk_paiement'])) $html_class = 'payid-'.$data['fk_paiement']; print ''; - print "'; + + // Date + print '\n"; - print ''; - print ''; + + // Ref + print ''; // File link print '\n"; + print "\n"; + + // Paid + print ''; + + // Total ET + print '\n"; + // Total IT + print '\n"; + // Total VAT + print '\n"; + + print '\n"; + + print '\n"; + + print '\n"; + + print '\n"; + + // Debit + //print '\n"; + // Credit + //print '\n"; + + $totalET += $data['amount_ht']; + $totalIT += $data['amount_ttc']; + $totalVAT += $data['amount_vat']; + + $totalDebit += ($data['amount_ttc'] > 0) ? abs($data['amount_ttc']) : 0; + $totalCredit += ($data['amount_ttc'] > 0) ? 0 : abs($data['amount_ttc']); - print ''; - print '\n"; - $totalDebit += ($data['amount'] > 0) ? abs($data['amount']) : 0; - print '\n"; - $totalCredit += ($data['amount'] > 0) ? 0 : abs($data['amount']); // Balance - print '\n"; + //print '\n"; + print "\n"; } print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + /*print ''; + print ''; + print ''; + */ print "\n"; } } @@ -453,5 +520,6 @@ if (!empty($date_start) && !empty($date_stop)) print ''; } + llxFooter(); $db->close(); diff --git a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql index 40f7da3fa95..1270b8b279a 100644 --- a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql +++ b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql @@ -60,6 +60,8 @@ CREATE TABLE llx_pos_cash_fence( -- For 10.0 +UPDATE llx_chargesociales SET date_creation = tms WHERE date_creation IS NULL; + DROP TABLE llx_cotisation; ALTER TABLE llx_accounting_bookkeeping DROP COLUMN validated; ALTER TABLE llx_accounting_bookkeeping_tmp DROP COLUMN validated; diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 387f8e159ec..37d3f984824 100755 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -400,6 +400,7 @@ ALTER TABLE llx_accounting_account ADD UNIQUE INDEX uk_accounting_account (accou -- p.tva_tx = 0 -- where price = 17.5 +UPDATE llx_chargesociales SET date_creation = tms WHERE date_creation IS NULL; -- VMYSQL4.1 SET sql_mode = 'ALLOW_INVALID_DATES'; -- VMYSQL4.1 update llx_accounting_account set tms = datec where DATE(STR_TO_DATE(tms, '%Y-%m-%d')) IS NULL; diff --git a/htdocs/user/param_ihm.php b/htdocs/user/param_ihm.php index 2ded2013601..90228aa952e 100644 --- a/htdocs/user/param_ihm.php +++ b/htdocs/user/param_ihm.php @@ -173,7 +173,7 @@ if (! empty($conf->projet->enabled)) $tmparray['projet/index.php?mainmenu=projec if (! empty($conf->holiday->enabled) || ! empty($conf->expensereport->enabled)) $tmparray['hrm/index.php?mainmenu=hrm&leftmenu=']='HRMArea'; // TODO Complete list with first level of menus if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) $tmparray['product/index.php?mainmenu=products&leftmenu=']='ProductsAndServicesArea'; if (! empty($conf->propal->enabled) || ! empty($conf->commande->enabled) || ! empty($conf->ficheinter->enabled) || ! empty($conf->contrat->enabled)) $tmparray['comm/index.php?mainmenu=commercial&leftmenu=']='CommercialArea'; -if (! empty($conf->compta->enabled) || ! empty($conf->accounting->enabled)) $tmparray['compta/index.php?mainmenu=compta&leftmenu=']='AccountancyTreasuryArea'; +if (! empty($conf->comptabilite->enabled) || ! empty($conf->accounting->enabled)) $tmparray['compta/index.php?mainmenu=compta&leftmenu=']='AccountancyTreasuryArea'; if (! empty($conf->adherent->enabled)) $tmparray['adherents/index.php?mainmenu=members&leftmenu=']='MembersArea'; if (! empty($conf->agenda->enabled)) $tmparray['comm/action/index.php?mainmenu=agenda&leftmenu=']='Agenda'; From ad20a5158c2abe0a04efa3b4fa74a265b5071ead Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Jun 2019 14:32:28 +0200 Subject: [PATCH 16/27] Fix columns in csv --- htdocs/compta/accounting-files.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index c663a179d6d..0954a194b73 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -294,7 +294,7 @@ if ($result && $action == "dl" && ! $error) dol_mkdir($dirfortmpfile); - $log=$langs->transnoentitiesnoconv("Type").','.$langs->transnoentitiesnoconv("Date").','.$langs->transnoentitiesnoconv("Ref").','.$langs->transnoentitiesnoconv("TotalHT").','.$langs->transnoentitiesnoconv("TotalTTC").','.$langs->transnoentitiesnoconv("TotalVAT").','.$langs->transnoentitiesnoconv("Paid").',filename,item_id,'.$langs->trans("ThirdParty").','.$langs->trans("Code").','.$langs->trans("Country").','.$langs->trans("VATIntra")."\n"; + $log=$langs->transnoentitiesnoconv("Type").','.$langs->transnoentitiesnoconv("Date").','.$langs->transnoentitiesnoconv("Ref").','.$langs->transnoentitiesnoconv("TotalHT").','.$langs->transnoentitiesnoconv("TotalTTC").','.$langs->transnoentitiesnoconv("TotalVAT").','.$langs->transnoentitiesnoconv("Paid").',filename,item_id,'.$langs->transnoentitiesnoconv("ThirdParty").','.$langs->transnoentitiesnoconv("Code").','.$langs->transnoentitiesnoconv("Country").','.$langs->transnoentitiesnoconv("VATIntra")."\n"; $zipname = $dirfortmpfile.'/'.dol_print_date($date_start, 'dayrfc')."-".dol_print_date($date_stop, 'dayrfc').'_export.zip'; dol_delete_file($zipname); From 27f52dd0bd73fdb2faa9c121ec95fb7fb512839c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Jun 2019 14:32:35 +0200 Subject: [PATCH 17/27] Fix columns in csv --- htdocs/compta/compta-files.php | 474 +++++++++++++++++++-------------- 1 file changed, 276 insertions(+), 198 deletions(-) diff --git a/htdocs/compta/compta-files.php b/htdocs/compta/compta-files.php index be08e264a02..e28df61e658 100644 --- a/htdocs/compta/compta-files.php +++ b/htdocs/compta/compta-files.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2018 Laurent Destailleur + * Copyright (C) 2004-2019 Laurent Destailleur * Copyright (C) 2017 Pierre-Henry Favre * * This program is free software; you can redistribute it and/or modify @@ -17,7 +17,7 @@ * along with this program. If not, see . */ /** - * \file htdocs/compta/compta-files.php + * \file htdocs/compta/accounting-files.php * \ingroup compta * \brief Page to show portoflio and files of a thirdparty and download it */ @@ -25,15 +25,14 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; -require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; -$langs->loadLangs(array("accountancy","bills")); +$langs->loadLangs(array("accountancy", "bills", "companies", "salaries")); $date_start =GETPOST('date_start', 'alpha'); $date_startDay= GETPOST('date_startday', 'int'); @@ -45,7 +44,7 @@ $date_stopDay= GETPOST('date_stopday', 'int'); $date_stopMonth= GETPOST('date_stopmonth', 'int'); $date_stopYear= GETPOST('date_stopyear', 'int'); //FIXME doldate -$date_stop=($date_stopDay)?dol_mktime(0, 0, 0, $date_stopMonth, $date_stopDay, $date_stopYear):strtotime($date_stop); +$date_stop=($date_stopDay)?dol_mktime(23, 59, 59, $date_stopMonth, $date_stopDay, $date_stopYear):strtotime($date_stop); $action =GETPOST('action', 'alpha'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -65,6 +64,7 @@ if (! $sortorder) $sortorder="DESC"; $arrayfields=array( + 'type'=>array('label'=>"Type", 'checked'=>1), 'date'=>array('label'=>"Date", 'checked'=>1), //... ); @@ -74,8 +74,9 @@ if (empty($conf->comptabilite->enabled) && empty($conf->accounting->enabled)) { accessforbidden(); } if ($user->societe_id > 0) +{ accessforbidden(); - +} /* @@ -90,157 +91,211 @@ $entity = GETPOST('entity','int')?GETPOST('entity','int'):$conf->entity; $filesarray=array(); $result=false; -if(($action=="searchfiles"||$action=="dl" ) && $date_start && $date_stop){ - $wheretail=" '".$db->idate($date_start)."' AND '".$db->idate($date_stop)."'"; - $sql="SELECT rowid as id, facnumber as ref,paye as paid, total_ttc, fk_soc, datef as date, 'Invoice' as item FROM ".MAIN_DB_PREFIX."facture"; - $sql.=" WHERE datef between ".$wheretail; - $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')'; - $sql.=" AND fk_statut <> ".Facture::STATUS_DRAFT; - $sql.=" UNION ALL"; - $sql.=" SELECT rowid as id, ref, paye as paid, total_ttc, fk_soc, datef as date, 'SupplierInvoice' as item FROM ".MAIN_DB_PREFIX."facture_fourn"; - $sql.=" WHERE datef between ".$wheretail; - $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')'; - $sql.=" AND fk_statut <> ".FactureFournisseur::STATUS_DRAFT; - $sql.=" UNION ALL"; - $sql.=" SELECT rowid as id, ref, paid, total_ttc, fk_user_author as fk_soc, date_fin as date,'ExpenseReport' as item FROM ".MAIN_DB_PREFIX."expensereport"; - $sql.=" WHERE date_fin between ".$wheretail; - $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')'; - $sql.=" AND fk_statut <> ".ExpenseReport::STATUS_DRAFT; - $sql.=" UNION ALL"; - $sql.=" SELECT rowid as id, ref,paid,amount as total_ttc, '0' as fk_soc, datedon as date,'Donation' as item FROM ".MAIN_DB_PREFIX."don"; - $sql.=" WHERE datedon between ".$wheretail; - $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')'; - $sql.=" AND fk_statut <> ".Don::STATUS_DRAFT; - $sql.=" UNION ALL"; - $sql.=" SELECT rowid as id, label as ref, 1 as paid, amount as total_ttc, fk_user as fk_soc,datep as date,'SalaryPayment' as item FROM ".MAIN_DB_PREFIX."payment_salary"; - $sql.=" WHERE datep between ".$wheretail; - $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')'; - //$sql.=" AND fk_statut <> ".PaymentSalary::STATUS_DRAFT; - $sql.=" UNION ALL"; - $sql.=" SELECT rowid as id, libelle as ref, paye as paid, amount as total_ttc, 0 as fk_soc, date_creation as date, 'SocialContributions' as item FROM ".MAIN_DB_PREFIX."chargesociales"; - $sql.=" WHERE date_creation between ".$wheretail; - $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')'; - //$sql.=" AND fk_statut <> ".ChargeSociales::STATUS_DRAFT; - $sql.= $db->order($sortfield, $sortorder); +if (($action=="searchfiles" || $action=="dl" )) { - $resd = $db->query($sql); - $files=array(); - $link=''; - - if ($resd) + if (empty($date_start)) { - $numd = $db->num_rows($resd); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateStart")), null, 'errors'); + $error++; + } + if (empty($date_stop)) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateEnd")), null, 'errors'); + $error++; + } - $tmpinvoice=new Facture($db); - $tmpinvoicesupplier=new FactureFournisseur($db); - $tmpdonation=new Don($db); + if (! $error) + { + $wheretail=" '".$db->idate($date_start)."' AND '".$db->idate($date_stop)."'"; - $upload_dir =''; - $i=0; - while ($i < $numd) + $sql="SELECT t.rowid as id, t.facnumber as ref, t.paye as paid, total as total_ht, total_ttc, tva as total_vat, fk_soc, t.datef as date, 'Invoice' as item, s.nom as thirdparty_name, s.code_client as thirdparty_code, c.code as country_code, s.tva_intra as vatnum"; + $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; + $sql.=" UNION ALL"; + $sql.=" SELECT t.rowid as id, t.ref, paye as paid, total_ht, total_ttc, total_tva as total_vat, fk_soc, datef as date, 'SupplierInvoice' as item, s.nom as thirdparty_name, s.code_fournisseur as thirdparty_code, c.code as country_code, s.tva_intra as vatnum"; + $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; + $sql.=" UNION ALL"; + $sql.=" SELECT t.rowid as id, t.ref, paid, total_ht, total_ttc, total_tva as total_vat, fk_user_author as fk_soc, date_fin as date, 'ExpenseReport' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; + $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; + $sql.=" UNION ALL"; + $sql.=" SELECT t.rowid as id, t.ref, paid, amount as total_ht, amount as total_ttc, 0 as total_vat, 0 as fk_soc, datedon as date, 'Donation' as item, t.societe as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; + $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; + $sql.=" UNION ALL"; + $sql.=" SELECT t.rowid as id, 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, datep as date, 'SalaryPayment' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; + $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; + $sql.=" UNION ALL"; + $sql.=" SELECT t.rowid as id, t.libelle as ref, paye as paid, amount as total_ht, amount as total_ttc, 0 as total_tva, 0 as fk_soc, date_creation as date, 'SocialContributions' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum"; + $sql.=" FROM ".MAIN_DB_PREFIX."chargesociales as t"; + $sql.=" WHERE date_creation between ".$wheretail; + $sql.=" AND t.entity IN (".($entity==1?'0,1':$entity).')'; + //$sql.=" AND fk_statut <> ".ChargeSociales::STATUS_DRAFT; + $sql.= $db->order($sortfield, $sortorder); + //print $sql; + + $resd = $db->query($sql); + $files=array(); + $link=''; + + if ($resd) { - $objd = $db->fetch_object($resd); + $numd = $db->num_rows($resd); - switch($objd->item) - { - case "Invoice": - $subdir=dol_sanitizeFileName($objd->ref); - $upload_dir = $conf->facture->dir_output.'/'.$subdir; - $link="document.php?modulepart=facture&file=".str_replace('/', '%2F', $subdir).'%2F'; - break; - case "SupplierInvoice": - $tmpinvoicesupplier->fetch($objd->id); - $subdir=get_exdir($tmpinvoicesupplier->id, 2, 0, 0, $tmpinvoicesupplier, 'invoice_supplier').'/'.dol_sanitizeFileName($objd->ref); - $upload_dir = $conf->fournisseur->facture->dir_output.'/'.$subdir; - $link="document.php?modulepart=facture_fournisseur&file=".str_replace('/', '%2F', $subdir).'%2F'; - break; - case "ExpenseReport": - $subdir=dol_sanitizeFileName($objd->ref); - $upload_dir = $conf->expensereport->dir_output.'/'.$subdir; - $link="document.php?modulepart=expensereport&file=".str_replace('/', '%2F', $subdir).'%2F'; - break; - case "SalaryPayment": - $subdir=dol_sanitizeFileName($objd->id); - $upload_dir = $conf->salaries->dir_output.'/'.$subdir; - $link="document.php?modulepart=salaries&file=".str_replace('/', '%2F', $subdir).'%2F'; - break; - case "Donation": - $tmpdonation->fetch($objp->id); - $subdir=get_exdir(0, 0, 0, 1, $tmpdonation, 'donation'). '/'. dol_sanitizeFileName($objd->id); - $upload_dir = $conf->don->dir_output . '/' . $subdir; - $link="document.php?modulepart=don&file=".str_replace('/', '%2F', $subdir).'%2F'; - break; - case "SocialContributions": - $subdir=dol_sanitizeFileName($objd->id); - $upload_dir = $conf->tax->dir_output . '/' . $subdir; - $link="document.php?modulepart=tax&file=".str_replace('/', '%2F', $subdir).'%2F'; - break; - default: - $subdir=''; - $upload_dir=''; - $link=''; - break; - } + $tmpinvoice=new Facture($db); + $tmpinvoicesupplier=new FactureFournisseur($db); + $tmpdonation=new Don($db); - if (!empty($upload_dir)) + $upload_dir =''; + $i=0; + while ($i < $numd) { - $result=true; - $files=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview\.png)$', '', SORT_ASC, 1); - //var_dump($upload_dir); - if (count($files) < 1) + $objd = $db->fetch_object($resd); + + switch($objd->item) { - $nofile['date']=$db->idate($objd->date); - $nofile['paid']=$objd->paid; - $nofile['amount']=$objd->total_ttc; - $nofile['ref']=$objd->ref; - $nofile['fk']=$objd->fk_soc; - $nofile['item']=$objd->item; - - $filesarray[]=$nofile; + 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'; + 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'; + 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'; + 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'; + 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'; + 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'; + break; + default: + $subdir=''; + $upload_dir=''; + $link=''; + break; } - else - { - foreach ($files as $key => $file) - { - $file['date']=$db->idate($objd->date); - $file['paid']=$objd->paid; - $file['amount']=$objd->total_ttc; - $file['ref']=$objd->ref; - $file['fk']=$objd->fk_soc; - $file['item']=$objd->item; - $file['link']=$link.$file['name']; - $file['relpathnamelang'] = $langs->trans($file['item']).'/'.$file['name']; - $filesarray[]=$file; + if (!empty($upload_dir)) + { + $result=true; + $files=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview\.png)$', '', SORT_ASC, 1); + //var_dump($upload_dir); + if (count($files) < 1) + { + $nofile['id']=$objd->id; + $nofile['date']=$db->idate($objd->date); + $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; + + $filesarray[]=$nofile; + } + else + { + foreach ($files as $key => $file) + { + $file['id']=$objd->id; + $file['date']=$db->idate($objd->date); + $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['link']=$link.$file['name']; + $file['relpathnamelang'] = $langs->trans($file['item']).'/'.$file['name']; + + $filesarray[]=$file; + } } } + $i++; } - $i++; } - } - else - { - dol_print_error($db); - } + else + { + dol_print_error($db); + } - $db->free($resd); + $db->free($resd); + } } -/* - * cleanup of old ZIP - */ -//FIXME + /* *ZIP creation */ -if ($result && $action == "dl") +$dirfortmpfile = ($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->compta->dir_temp); + setEventMessages($langs->trans("ErrorNoAccountingModuleEnabled"), null, 'errors'); + $error++; +} + + +if ($result && $action == "dl" && ! $error) +{ + if (! extension_loaded('zip')) + { + setEventMessages('PHPZIPExtentionNotLoaded', null, 'errors'); + exit; + } dol_mkdir($dirfortmpfile); - $log='date,type,ref,total,paid,filename,item_id'."\n"; + $log=$langs->transnoentitiesnoconv("Type").','.$langs->transnoentitiesnoconv("Date").','.$langs->transnoentitiesnoconv("Ref").','.$langs->transnoentitiesnoconv("TotalHT").','.$langs->transnoentitiesnoconv("TotalTTC").','.$langs->transnoentitiesnoconv("TotalVAT").','.$langs->transnoentitiesnoconv("Paid").',filename,item_id,'.$langs->transnoentitiesnoconv("ThirdParty").','.$langs->transnoentitiesnoconv("Code").','.$langs->transnoentitiesnoconv("Country").','.$langs->transnoentitiesnoconv("VATIntra")."\n"; $zipname = $dirfortmpfile.'/'.dol_print_date($date_start, 'dayrfc')."-".dol_print_date($date_stop, 'dayrfc').'_export.zip'; dol_delete_file($zipname); @@ -249,10 +304,10 @@ if ($result && $action == "dl") $res = $zip->open($zipname, ZipArchive::OVERWRITE|ZipArchive::CREATE); if ($res) { - foreach ($filesarray as $key=> $file) + foreach ($filesarray as $key => $file) { if (file_exists($file["fullname"])) $zip->addFile($file["fullname"], $file["relpathnamelang"]); // - $log.=dol_print_date($file['date'], 'dayrfc').','.$file['item'].','.$file['ref'].','.$file['amount'].','.$file['paid'].','.$file["name"].','.$file['fk']."\n"; + $log.=$file['item'].','.dol_print_date($file['date'], 'dayrfc').','.$file['ref'].','.$file['amount_ht'].','.$file['amount_ttc'].','.$file['amount_vat'].','.$file['paid'].','.$file["name"].','.$file['fk'].','.$file['thirdparty_name'].','.$file['thirdparty_code'].','.$file['country_code'].',"'.$file['vatnum'].'"'."\n"; } $zip->addFromString('transactions.csv', $log); $zip->close(); @@ -267,6 +322,10 @@ if ($result && $action == "dl") exit(); } + else + { + setEventMessages($langs->trans("FailedToOpenFile", $zipname), null, 'errors'); + } } @@ -283,7 +342,7 @@ llxHeader('', $title, $help_url); $h=0; $head[$h][0] = $_SERVER["PHP_SELF"].$varlink; -$head[$h][1] = $langs->trans("AccountancyFiles"); +$head[$h][1] = $langs->trans("AccountantFiles"); $head[$h][2] = 'AccountancyFiles'; dol_fiche_head($head, 'AccountancyFiles'); @@ -293,45 +352,20 @@ print '
'; 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"; -// Multicompany -/*if (! empty($conf->multicompany->enabled) && is_object($mc)) - { - print '
'; - // This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module - if (method_exists($mc, 'formObjectOptions')) - { - if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) // condition must be same for create and edit mode - { - print "
".''; - print "\n"; - } - else - { - print ''; - } - } - $object = new stdClass(); - // Other attributes - $parameters=array('objectsrc' => null, 'colspan' => ' colspan="3"'); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook)) - { - print $object->showOptionals($extrafields, 'edit'); - } - }*/ +// Export is for current company only ! if (! empty($conf->multicompany->enabled) && is_object($mc)) { - print '   -   '.$langs->trans("Entity").' : '; + print '('.$langs->trans("Entity").' : '; $mc->dao->getEntities(); $mc->dao->fetch($conf->entity); print $mc->dao->label; - print "
\n"; + print ")
\n"; } -print ''."\n"; +print ''; + +print ''."\n"; dol_fiche_end(); @@ -369,14 +403,18 @@ if (!empty($date_start) && !empty($date_stop)) print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print '
'.$langs->trans("Type").''.$langs->trans("Ref").''.$langs->trans("Document").''.$langs->trans("Paid").''.$langs->trans("Debit").''.$langs->trans("Credit").''.$langs->trans("Balance").''.$langs->trans("TotalHT").''.$langs->trans("TotalTTC").''.$langs->trans("TotalVAT").''.$langs->trans("ThirdParty").''.$langs->trans("Code").''.$langs->trans("Country").''.$langs->trans("VATIntra").'
"; + + // Type + print ''.$langs->trans($data['item']).''; print dol_print_date($data['date'], 'day'); print "'.$langs->trans($data['item']).''.$data['ref'].''.$data['ref'].''; @@ -429,23 +458,61 @@ if (!empty($date_start) && !empty($date_stop)) { print ''.($data['name'] ? $data['name'] : $data['ref']).''; } - print "'.$data['paid'].''.price($data['amount_ht'])."'.price($data['amount_ttc'])."'.price($data['amount_vat'])."'.$data['thirdparty_name']."'.$data['thirdparty_code']."'.$data['country_code']."'.$data['vatnum']."'.(($data['amount_ttc'] > 0) ? price(abs($data['amount_ttc'])) : '')."'.(($data['amount_ttc'] > 0) ? '' : price(abs($data['amount_ttc'])))."'.$data['paid'].''.(($data['amount'] > 0) ? price(abs($data['amount'])) : '')."'.(($data['amount'] > 0) ? '' : price(abs($data['amount'])))."'.price($data['balance'])."'.price($data['balance'])."
 '.price($totalDebit).''.price($totalCredit).''.price(price2num($totalDebit - $totalCredit, 'MT')).''.price($totalET).''.price($totalIT).''.price($totalVAT).''.price($totalDebit).''.price($totalCredit).''.price(price2num($totalDebit - $totalCredit, 'MT')).'
'.$langs->trans("Entity").'".$mc->select_entities($entity); - print "
'; print ''; - print_liste_field_titre($arrayfields['date']['label'], $_SERVER["PHP_SELF"], "date", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); - print ''; + print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], "type", "", $param, '', $sortfield, $sortorder, 'nowrap '); + print_liste_field_titre($arrayfields['date']['label'], $_SERVER["PHP_SELF"], "date", "", $param, '', $sortfield, $sortorder, 'center nowrap '); print ''; - print ''; + print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print ''; if ($result) { @@ -390,20 +428,11 @@ if (!empty($date_start) && !empty($date_stop)) { // Sort array by date ASC to calculate balance + $totalET = 0; + $totalIT = 0; + $totalVAT = 0; $totalDebit = 0; $totalCredit = 0; - // Balance calculation - $balance = 0; - foreach($TData as &$data1) { - if ($data1['item']!='Invoice'&& $data1['item']!='Donation' ){ - $data1['amount']=-$data1['amount']; - } - if ($data1['amount']>0){ - }else{ - } - $balance += $data1['amount']; - $data1['balance'] = $balance; - } // Display array foreach($TData as $data) @@ -412,30 +441,79 @@ if (!empty($date_start) && !empty($date_stop)) //if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture']; //elseif (!empty($data['fk_paiement'])) $html_class = 'payid-'.$data['fk_paiement']; print ''; - print "'; + + // Date + print '\n"; - print ''; + + // Ref print ''; // File link - print '\n"; + print '\n"; + // Paid print ''; - print '\n"; - $totalDebit += ($data['amount'] > 0) ? abs($data['amount']) : 0; - print '\n"; - $totalCredit += ($data['amount'] > 0) ? 0 : abs($data['amount']); + + // Total ET + print '\n"; + // Total IT + print '\n"; + // Total VAT + print '\n"; + + print '\n"; + + print '\n"; + + print '\n"; + + print '\n"; + + // Debit + //print '\n"; + // Credit + //print '\n"; + + $totalET += $data['amount_ht']; + $totalIT += $data['amount_ttc']; + $totalVAT += $data['amount_vat']; + + $totalDebit += ($data['amount_ttc'] > 0) ? abs($data['amount_ttc']) : 0; + $totalCredit += ($data['amount_ttc'] > 0) ? 0 : abs($data['amount_ttc']); + // Balance - print '\n"; + //print '\n"; + print "\n"; } print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + /*print ''; + print ''; + print ''; + */ print "\n"; } } From 6bda130835a347b075ae79f4132a0969c418e426 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Jun 2019 14:51:57 +0200 Subject: [PATCH 18/27] Protect from dir scan --- htdocs/bom/admin/index.html | 0 htdocs/bom/class/index.html | 0 htdocs/bom/index.html | 0 htdocs/bom/lib/index.html | 0 htdocs/datapolicy/admin/index.html | 0 htdocs/datapolicy/class/index.html | 0 htdocs/datapolicy/index.html | 0 htdocs/datapolicy/lib/index.html | 0 htdocs/debugbar/index.html | 0 htdocs/website/class/index.html | 0 htdocs/website/lib/index.html | 0 11 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 htdocs/bom/admin/index.html create mode 100644 htdocs/bom/class/index.html create mode 100644 htdocs/bom/index.html create mode 100644 htdocs/bom/lib/index.html create mode 100644 htdocs/datapolicy/admin/index.html create mode 100644 htdocs/datapolicy/class/index.html create mode 100644 htdocs/datapolicy/index.html create mode 100644 htdocs/datapolicy/lib/index.html create mode 100644 htdocs/debugbar/index.html create mode 100644 htdocs/website/class/index.html create mode 100644 htdocs/website/lib/index.html diff --git a/htdocs/bom/admin/index.html b/htdocs/bom/admin/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/bom/class/index.html b/htdocs/bom/class/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/bom/index.html b/htdocs/bom/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/bom/lib/index.html b/htdocs/bom/lib/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/datapolicy/admin/index.html b/htdocs/datapolicy/admin/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/datapolicy/class/index.html b/htdocs/datapolicy/class/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/datapolicy/index.html b/htdocs/datapolicy/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/datapolicy/lib/index.html b/htdocs/datapolicy/lib/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/debugbar/index.html b/htdocs/debugbar/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/website/class/index.html b/htdocs/website/class/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/website/lib/index.html b/htdocs/website/lib/index.html new file mode 100644 index 00000000000..e69de29bb2d From 6afda6a47a8db60cf16e11d3475862c41c435016 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Jun 2019 15:57:22 +0200 Subject: [PATCH 19/27] FIX invalid link on user.fk_user --- htdocs/install/mysql/migration/repair.sql | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 22409441eac..dc9fcc86df6 100755 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -199,6 +199,15 @@ delete from llx_element_element where sourcetype='commande' and fk_source not in DELETE FROM llx_actioncomm_resources WHERE fk_actioncomm not in (select id from llx_actioncomm); +-- Fix link on parent that were removed +DROP table tmp_user; +CREATE TABLE tmp_user as (select * from llx_user); +UPDATE llx_user SET fk_user = NULL where fk_user NOT IN (select rowid from tmp_user); + + +update llx_user set fk_user = null where fk_user not in (select rowid from llx_user); + + UPDATE llx_product SET canvas = NULL where canvas = 'default@product'; UPDATE llx_product SET canvas = NULL where canvas = 'service@product'; From 6e9874b95ad50d6011fbd5677442cc9d69944804 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Jun 2019 16:01:24 +0200 Subject: [PATCH 20/27] FIX A user may read holiday and expense report without permissions --- htdocs/expensereport/list.php | 16 +++++++++++++++- htdocs/holiday/list.php | 12 ++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index 3b153bcf843..8b5ef11f128 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -46,10 +46,25 @@ $confirm=GETPOST('confirm','alpha'); $toselect = GETPOST('toselect', 'array'); $contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'expensereportlist'; +$childids = $user->getAllChildIds(1); + // Security check $socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'expensereport','',''); +$id = GETPOST('id', 'int'); +// If we are on the view of a specific user +if ($id > 0) +{ + $canread=0; + if ($id == $user->id) $canread=1; + if (! empty($user->rights->holiday->read_all)) $canread=1; + if (! empty($user->rights->holiday->read) && in_array($id, $childids)) $canread=1; + if (! $canread) + { + accessforbidden(); + } +} $diroutputmassaction=$conf->expensereport->dir_output . '/temp/massgeneration/'.$user->id; @@ -66,7 +81,6 @@ $pagenext = $page + 1; if (!$sortorder) $sortorder="DESC"; if (!$sortfield) $sortfield="d.date_debut"; -$id = GETPOST('id', 'int'); $sall = trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); $search_ref = GETPOST('search_ref', 'alpha'); diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 5df3fdb314b..d07ec98ca4c 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -60,6 +60,18 @@ if ($user->societe_id > 0) // Protection if external user } $result = restrictedArea($user, 'holiday', $id, ''); $id = GETPOST('id','int'); +// If we are on the view of a specific user +if ($id > 0) +{ + $canread=0; + if ($id == $user->id) $canread=1; + if (! empty($user->rights->holiday->read_all)) $canread=1; + if (! empty($user->rights->holiday->read) && in_array($id, $childids)) $canread=1; + if (! $canread) + { + accessforbidden(); + } +} // Load variable for pagination $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; From 81bca34a08186b79909c41f87ea95c087530c219 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Jun 2019 16:04:25 +0200 Subject: [PATCH 21/27] FIX A user may read holiday and expense report without permissions --- htdocs/expensereport/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index 8b5ef11f128..0014cb7999c 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -58,8 +58,8 @@ if ($id > 0) { $canread=0; if ($id == $user->id) $canread=1; - if (! empty($user->rights->holiday->read_all)) $canread=1; - if (! empty($user->rights->holiday->read) && in_array($id, $childids)) $canread=1; + if (! empty($user->rights->expensereport->readall)) $canread=1; + if (! empty($user->rights->expensereport->lire) && in_array($id, $childids)) $canread=1; if (! $canread) { accessforbidden(); From 13abfc3140298227cbaaa02aef53503efe2b0db3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Jun 2019 16:46:12 +0200 Subject: [PATCH 22/27] Code comment --- htdocs/install/mysql/tables/llx_societe.sql | 34 ++++++++++----------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/htdocs/install/mysql/tables/llx_societe.sql b/htdocs/install/mysql/tables/llx_societe.sql index ed4919c3fc5..e7a948d67c2 100644 --- a/htdocs/install/mysql/tables/llx_societe.sql +++ b/htdocs/install/mysql/tables/llx_societe.sql @@ -65,34 +65,34 @@ create table llx_societe fk_typent integer DEFAULT 0, -- fk_forme_juridique integer DEFAULT 0, -- juridical status fk_currency varchar(3), -- default currency - siren varchar(128), -- IDProf1: siren or RCS for france, ... - siret varchar(128), -- IDProf2: siret for france, ... - ape varchar(128), -- IDProf3: code ape for france, ... - idprof4 varchar(128), -- IDProf4: nu for france - idprof5 varchar(128), -- IDProf5: nu for france - idprof6 varchar(128), -- IDProf6: nu for france - tva_intra varchar(20), -- tva - capital double(24,8) DEFAULT NULL, -- capital de la societe - fk_stcomm integer DEFAULT 0 NOT NULL, -- commercial statut + siren varchar(128), -- IDProf1: depends on country (example: siren or RCS for france, ...) + siret varchar(128), -- IDProf2: depends on country (example: siret for france, ...) + ape varchar(128), -- IDProf3: depends on country (example: code ape for france, ...) + idprof4 varchar(128), -- IDProf4: depends on country (example: nu for france, ...) + idprof5 varchar(128), -- IDProf5: depends on country (example: nu for france, ...) + idprof6 varchar(128), -- IDProf6: depends on country (example: nu for france, ... + tva_intra varchar(20), -- vat numero + capital double(24,8) DEFAULT NULL, -- capital of company + fk_stcomm integer DEFAULT 0 NOT NULL, -- commercial status note_private text, -- note_public text, -- model_pdf varchar(255), - prefix_comm varchar(5), -- prefix commercial + prefix_comm varchar(5), -- prefix commercial (deprecated) client tinyint DEFAULT 0, -- client 0/1/2 fournisseur tinyint DEFAULT 0, -- fournisseur 0/1 - supplier_account varchar(32), -- compte client chez un fournisseur + supplier_account varchar(32), -- Id of our customer account known by the supplier fk_prospectlevel varchar(12), -- prospect level (in llx_c_prospectlevel) fk_incoterms integer, -- for incoterms location_incoterms varchar(255), -- for incoterms customer_bad tinyint DEFAULT 0, -- mauvais payeur 0/1 customer_rate real DEFAULT 0, -- taux fiabilite client (0 a 1) supplier_rate real DEFAULT 0, -- taux fiabilite fournisseur (0 a 1) - remise_client real DEFAULT 0, -- remise systematique pour le client - remise_supplier real DEFAULT 0, -- remise systematique auprès du fournisseur - mode_reglement tinyint, -- mode de reglement - cond_reglement tinyint, -- condition de reglement - mode_reglement_supplier tinyint, -- mode de reglement fournisseur - cond_reglement_supplier tinyint, -- condition de reglement fournisseur + remise_client real DEFAULT 0, -- discount by default granted to this customer + remise_supplier real DEFAULT 0, -- discount by default granted by this supplier + mode_reglement tinyint, -- payment mode customer + cond_reglement tinyint, -- payment term customer + mode_reglement_supplier tinyint, -- payment mode supplier + cond_reglement_supplier tinyint, -- payment term supplier fk_shipping_method integer, -- preferred shipping method id tva_assuj tinyint DEFAULT 1, -- assujeti ou non a la TVA localtax1_assuj tinyint DEFAULT 0, -- assujeti ou non a local tax 1 From 2e1eb29ca06dfa7273a7b8a15621e711c61a487e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Jun 2019 17:42:45 +0200 Subject: [PATCH 23/27] Fix rendering of amount --- htdocs/compta/facture/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index d12fc90fd77..b6beba5e12e 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -959,11 +959,11 @@ if ($resql) $totalcreditnotes = $facturestatic->getSumCreditNotesUsed(); $totaldeposits = $facturestatic->getSumDepositsUsed(); $totalpay = $paiement + $totalcreditnotes + $totaldeposits; - $remaintopay = $facturestatic->total_ttc - $totalpay; + $remaintopay = price2num($facturestatic->total_ttc - $totalpay); if ($facturestatic->type == Facture::TYPE_CREDIT_NOTE && $obj->paye == 1) { $remaincreditnote = $discount->getAvailableDiscounts($obj->fk_soc, '', 'rc.fk_facture_source='.$facturestatic->id); $remaintopay = -$remaincreditnote; - $totalpay = $facturestatic->total_ttc - $remaintopay; + $totalpay = price2num($facturestatic->total_ttc - $remaintopay); } print ' Date: Tue, 18 Jun 2019 18:07:47 +0200 Subject: [PATCH 24/27] Fix phpcs --- htdocs/compta/accounting-files.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index 0954a194b73..9069045c8b3 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -73,16 +73,17 @@ $arrayfields=array( if (empty($conf->comptabilite->enabled) && empty($conf->accounting->enabled)) { accessforbidden(); } -if ($user->societe_id > 0) +if ($user->societe_id > 0) { accessforbidden(); +} +$entity = GETPOST('entity', 'int')?GETPOST('entity', 'int'):$conf->entity; /* * Actions */ -$entity = GETPOST('entity','int')?GETPOST('entity','int'):$conf->entity; //$parameters = array('socid' => $id); //$reshook = $hookmanager->executeHooks('doActions', $parameters, $object); // Note that $object may have been modified by some hooks From 525598f6aa925b0aeb8f7c02ebdd0edaeb065bde Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Jun 2019 20:01:28 +0200 Subject: [PATCH 25/27] Fix scrutinizer warnings --- htdocs/adherents/class/adherent.class.php | 8 ++++---- htdocs/contact/class/contact.class.php | 2 +- htdocs/user/class/user.class.php | 1 - htdocs/user/class/usergroup.class.php | 3 +-- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 3119e044be0..1856de6182f 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -183,14 +183,14 @@ class Adherent extends CommonObject * @var integer */ public $datec; - + /** * Date modification record (tms) * * @var integer */ public $datem; - + public $datevalid; public $gender; @@ -1268,7 +1268,7 @@ class Adherent extends CommonObject $this->ref = $obj->rowid; $this->id = $obj->rowid; $this->ref_ext = $obj->ref_ext; - + $this->civility_id = $obj->civility_code; // Bad. Kept for backard compatibility $this->civility_code = $obj->civility_code; $this->civility = $obj->civility_code?($langs->trans("Civility".$obj->civility_code) != ("Civility".$obj->civility_code) ? $langs->trans("Civility".$obj->civility_code) : $obj->civility_code):''; @@ -2465,7 +2465,7 @@ class Adherent extends CommonObject * * @return array Tableau info des attributs */ - private function _load_ldap_info() + public function _load_ldap_info() { // phpcs:enable global $conf,$langs; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index dfefb8060fe..5c4df6ab3f9 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -525,7 +525,7 @@ class Contact extends CommonObject * * @return array Tableau info des attributs */ - private function _load_ldap_info() + public function _load_ldap_info() { // phpcs:enable global $conf, $langs; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 34651304b95..c5ac20e8cc7 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2300,7 +2300,6 @@ class User extends CommonObject if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) $withpictoimg=0; $result=''; $label=''; - $link=''; $linkstart=''; $linkend=''; if (! empty($this->photo)) { diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index c3fe000292c..9fb6e600a3b 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -867,7 +867,6 @@ class UserGroup extends CommonObject if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpicto) $withpicto=0; $result=''; $label=''; - $link=''; $linkstart=''; $linkend=''; $label.= '
'; $label.= '' . $langs->trans("Group") . '
'; @@ -957,7 +956,7 @@ class UserGroup extends CommonObject public function _load_ldap_info() { // phpcs:enable - global $conf,$langs; + global $conf; $info=array(); From 663998bab11a371b4162c89c2f5893a8075b352d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Jun 2019 20:15:04 +0200 Subject: [PATCH 26/27] Fix scrutinizer errors --- htdocs/includes/odtphp/odf.php | 2 +- htdocs/opensurvey/results.php | 4 ++-- htdocs/product/price.php | 2 +- htdocs/user/class/user.class.php | 12 ++++++------ htdocs/user/class/usergroup.class.php | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/htdocs/includes/odtphp/odf.php b/htdocs/includes/odtphp/odf.php index 6b3a6400bc3..21e9b56b4bb 100644 --- a/htdocs/includes/odtphp/odf.php +++ b/htdocs/includes/odtphp/odf.php @@ -745,7 +745,7 @@ IMG; private function _rrmdir($dir) { if ($handle = opendir($dir)) { - while (false !== ($file = readdir($handle))) { + while (($file = readdir($handle)) !== false) { if ($file != '.' && $file != '..') { if (is_dir($dir . '/' . $file)) { $this->_rrmdir($dir . '/' . $file); diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php index c648b15664e..1b3034bb82c 100644 --- a/htdocs/opensurvey/results.php +++ b/htdocs/opensurvey/results.php @@ -249,8 +249,8 @@ if (isset($_POST["ajoutercolonne"]) && $object->format == "D") $dateinsertion = substr("$dateinsertion", 1); - //mise a jour avec les nouveaux sujets dans la base - if (isset($erreur_ajout_date) && !$erreur_ajout_date) + // update with new topics into database + if (isset($erreur_ajout_date) && empty($erreur_ajout_date)) { $sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_sondage"; $sql.= " SET sujet = '".$db->escape($dateinsertion)."'"; diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 5b5b9ad48fa..26970f1dd13 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -153,7 +153,7 @@ if (empty($reshook)) $db->begin(); $resql = $object->update($object->id, $user); - if (! $resql || $resql < 0) + if ($resql <= 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index c5ac20e8cc7..a151fdb5574 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -774,7 +774,7 @@ class User extends CommonObject dol_syslog(get_class($this)."::clearrights reset user->rights"); $this->rights=''; $this->nb_rights=0; - $this->all_permissions_are_loaded=false; + $this->all_permissions_are_loaded=0; $this->_tab_loaded=array(); } @@ -799,16 +799,16 @@ class User extends CommonObject return; } - if ($this->all_permissions_are_loaded) + if (! empty($this->all_permissions_are_loaded)) { // We already loaded all rights for this user, so we leave return; } } - // Recuperation des droits utilisateurs + recuperation des droits groupes + // Get permission of users + Get permissions of groups - // D'abord les droits utilisateurs + // First user permissions $sql = "SELECT DISTINCT r.module, r.perms, r.subperms"; $sql.= " FROM ".MAIN_DB_PREFIX."user_rights as ur"; $sql.= ", ".MAIN_DB_PREFIX."rights_def as r"; @@ -862,7 +862,7 @@ class User extends CommonObject $this->db->free($resql); } - // Maintenant les droits groupes + // Now permissions of groups $sql = "SELECT DISTINCT r.module, r.perms, r.subperms"; $sql.= " FROM ".MAIN_DB_PREFIX."usergroup_rights as gr,"; $sql.= " ".MAIN_DB_PREFIX."usergroup_user as gu,"; @@ -933,7 +933,7 @@ class User extends CommonObject } else { - // Si module defini, on le marque comme charge en cache + // If module defined, we flag it as loaded into cache $this->_tab_loaded[$moduletag]=1; } } diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index 9fb6e600a3b..d51d82c8d13 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -552,13 +552,13 @@ class UserGroup extends CommonObject if ($moduletag && isset($this->_tab_loaded[$moduletag]) && $this->_tab_loaded[$moduletag]) { - // Le fichier de ce module est deja charge + // Rights for this module are already loaded, so we leave return; } if (! empty($this->all_permissions_are_loaded)) { - // Si les permissions ont deja ete chargees, on quitte + // We already loaded all rights for this group, so we leave return; } @@ -618,7 +618,7 @@ class UserGroup extends CommonObject } else { - // Si module defini, on le marque comme charge en cache + // If module defined, we flag it as loaded into cache $this->_tab_loaded[$moduletag]=1; } From 53923a8581e5a710a46f289b0df61769df1b4f56 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Jun 2019 20:21:22 +0200 Subject: [PATCH 27/27] Fix scrutinizer warnings --- htdocs/core/db/sqlite3.class.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/htdocs/core/db/sqlite3.class.php b/htdocs/core/db/sqlite3.class.php index b7d06870ff5..360b72f80d9 100644 --- a/htdocs/core/db/sqlite3.class.php +++ b/htdocs/core/db/sqlite3.class.php @@ -403,9 +403,13 @@ class DoliDBSqlite3 extends DoliDB */ public function query($query, $usesavepoint = 0, $type = 'auto') { + global $conf; + $ret=null; + $query = trim($query); - $this->error = 0; + + $this->error = ''; // Convert MySQL syntax to SQLite syntax if (preg_match('/ALTER\s+TABLE\s*(.*)\s*ADD\s+CONSTRAINT\s+(.*)\s*FOREIGN\s+KEY\s*\(([\w,\s]+)\)\s*REFERENCES\s+(\w+)\s*\(([\w,\s]+)\)/i', $query, $reg)) { @@ -449,7 +453,8 @@ class DoliDBSqlite3 extends DoliDB } //print "After convertSQLFromMysql:\n".$query."
\n"; - dol_syslog('sql='.$query, LOG_DEBUG); + if (! in_array($query, array('BEGIN','COMMIT','ROLLBACK'))) dol_syslog('sql='.$query, LOG_DEBUG); + if (empty($query)) return false; // Return false = error if empty request // Ordre SQL ne necessitant pas de connexion a une base (exemple: CREATE DATABASE) try { @@ -481,7 +486,8 @@ class DoliDBSqlite3 extends DoliDB $errormsg .= ' ('.$this->lasterrno.')'; } - dol_syslog($errormsg, LOG_ERR); + if ($conf->global->SYSLOG_LEVEL < LOG_DEBUG) dol_syslog(get_class($this)."::query SQL Error query: ".$query, LOG_ERR); // Log of request was not yet done previously + dol_syslog(get_class($this)."::query SQL Error message: ".$errormsg, LOG_ERR); } $this->lastquery=$query; $this->_results = $ret;
'.$langs->trans("Type").''.$langs->trans("Ref").''.$langs->trans("Link").''.$langs->trans("Document").''.$langs->trans("Paid").''.$langs->trans("Debit").''.$langs->trans("Credit").''.$langs->trans("Balance").''.$langs->trans("TotalHT").''.$langs->trans("TotalTTC").''.$langs->trans("TotalVAT").''.$langs->trans("ThirdParty").''.$langs->trans("Code").''.$langs->trans("Country").''.$langs->trans("VATIntra").'
"; + + // Type + print ''.$langs->trans($data['item']).''; print dol_print_date($data['date'], 'day'); print "'.$langs->trans($data['item']).''.$data['ref'].'".$data['name']."'; + if ($data['link']) + { + print ''.($data['name'] ? $data['name'] : $data['ref']).''; + } + print "'.$data['paid'].''.(($data['amount'] > 0) ? price(abs($data['amount'])) : '')."'.(($data['amount'] > 0) ? '' : price(abs($data['amount'])))."'.price($data['amount_ht'])."'.price($data['amount_ttc'])."'.price($data['amount_vat'])."'.$data['thirdparty_name']."'.$data['thirdparty_code']."'.$data['country_code']."'.$data['vatnum']."'.(($data['amount_ttc'] > 0) ? price(abs($data['amount_ttc'])) : '')."'.(($data['amount_ttc'] > 0) ? '' : price(abs($data['amount_ttc'])))."'.price($data['balance'])."'.price($data['balance'])."
 '.price($totalDebit).''.price($totalCredit).''.price(price2num($totalDebit - $totalCredit, 'MT')).''.price($totalET).''.price($totalIT).''.price($totalVAT).''.price($totalDebit).''.price($totalCredit).''.price(price2num($totalDebit - $totalCredit, 'MT')).'