From 1bb91c7860aa17799546d402b06dfb23ae7e7940 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sun, 24 Jun 2018 16:20:27 +0200 Subject: [PATCH 1/5] update and clean code --- htdocs/core/ajax/ajaxdirtree.php | 2 -- htdocs/don/tpl/linkedobjectblock.tpl.php | 3 +-- htdocs/fichinter/card.php | 1 - htdocs/fichinter/index.php | 7 ------- htdocs/fichinter/stats/index.php | 5 ++--- htdocs/fichinter/tpl/linkedobjectblock.tpl.php | 3 +-- htdocs/fourn/commande/list.php | 2 -- htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php | 3 +-- htdocs/fourn/facture/list.php | 9 +++------ htdocs/fourn/facture/rapport.php | 4 +--- htdocs/fourn/recap-fourn.php | 6 ++---- 11 files changed, 11 insertions(+), 34 deletions(-) diff --git a/htdocs/core/ajax/ajaxdirtree.php b/htdocs/core/ajax/ajaxdirtree.php index 59fe3385c61..907a3cea79e 100644 --- a/htdocs/core/ajax/ajaxdirtree.php +++ b/htdocs/core/ajax/ajaxdirtree.php @@ -321,10 +321,8 @@ if (empty($conf->use_javascript_ajax) || ! empty($conf->global->MAIN_ECM_DISABLE $nbofentries=0; $oldvallevel=0; - $var=true; foreach($sqltree as $key => $val) { - $var=false; $ecmdirstatic->id=$val['id']; $ecmdirstatic->ref=$val['label']; diff --git a/htdocs/don/tpl/linkedobjectblock.tpl.php b/htdocs/don/tpl/linkedobjectblock.tpl.php index fdf6ae71c2f..d7ad6587845 100644 --- a/htdocs/don/tpl/linkedobjectblock.tpl.php +++ b/htdocs/don/tpl/linkedobjectblock.tpl.php @@ -33,12 +33,11 @@ $linkedObjectBlock = $GLOBALS['linkedObjectBlock']; $langs->load("donations"); $total=0; $ilink=0; -$var=true; foreach($linkedObjectBlock as $key => $objectlink) { $ilink++; - $trclass=($var?'pair':'impair'); + $trclass='oddeven'; if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; ?> diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index b0d085838a8..15b75495c38 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -1403,7 +1403,6 @@ else if ($id > 0 || ! empty($ref)) print ' '; print "\n"; } - $var=true; while ($i < $num) { $objp = $db->fetch_object($resql); diff --git a/htdocs/fichinter/index.php b/htdocs/fichinter/index.php index 474c6774f26..6b8ce71bfb5 100644 --- a/htdocs/fichinter/index.php +++ b/htdocs/fichinter/index.php @@ -143,7 +143,6 @@ if ($resql) print ''; } - $var=true; $bool=false; foreach ($listofstatus as $status) { @@ -198,10 +197,8 @@ if (! empty($conf->ficheinter->enabled)) if ($num) { $i = 0; - $var = true; while ($i < $num) { - $obj = $db->fetch_object($resql); print ''; print ''; @@ -248,10 +245,8 @@ if ($resql) if ($num) { $i = 0; - $var = true; while ($i < $num) { - $obj = $db->fetch_object($resql); print ''; @@ -319,10 +314,8 @@ if (! empty($conf->ficheinter->enabled)) if ($num) { $i = 0; - $var = true; while ($i < $num) { - $obj = $db->fetch_object($resql); print ''; print ''; diff --git a/htdocs/fichinter/stats/index.php b/htdocs/fichinter/stats/index.php index b00b1391003..7a68bef34ec 100644 --- a/htdocs/fichinter/stats/index.php +++ b/htdocs/fichinter/stats/index.php @@ -285,7 +285,6 @@ print '%'; print ''; $oldyear=0; -$var=true; foreach ($data as $val) { $year = $val['year']; @@ -293,7 +292,7 @@ foreach ($data as $val) { // If we have empty year $oldyear--; - print ''; + print ''; print '0?'&userid='.$userid:'').'">'.$oldyear.''; print '0'; @@ -306,7 +305,7 @@ foreach ($data as $val) } - print ''; + print ''; print '0?'&userid='.$userid:'').'">'.$year.''; print ''.$val['nb'].''; print ''.round($val['nb_diff']).''; diff --git a/htdocs/fichinter/tpl/linkedobjectblock.tpl.php b/htdocs/fichinter/tpl/linkedobjectblock.tpl.php index dca78609c61..8bed3f28fe2 100644 --- a/htdocs/fichinter/tpl/linkedobjectblock.tpl.php +++ b/htdocs/fichinter/tpl/linkedobjectblock.tpl.php @@ -36,12 +36,11 @@ $linkedObjectBlock = $GLOBALS['linkedObjectBlock']; $langs->load("interventions"); $ilink=0; -$var=true; foreach($linkedObjectBlock as $key => $objectlink) { $ilink++; - $trclass=($var?'pair':'impair'); + $trclass='oddeven'; if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; ?> diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 773e9da06c0..971f99717f4 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -935,13 +935,11 @@ if ($resql) $projectstatic=new Project($db); $i=0; - $var=true; $totalarray=array(); while ($i < min($num,$limit)) { $obj = $db->fetch_object($resql); - $objectstatic->id=$obj->rowid; $objectstatic->ref=$obj->ref; $objectstatic->ref_supplier = $obj->ref_supplier; diff --git a/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php b/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php index bdcfb3fdca8..4ce44845bf6 100644 --- a/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php +++ b/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php @@ -38,12 +38,11 @@ $linkedObjectBlock = $GLOBALS['linkedObjectBlock']; $langs->load("orders"); $total=0; $ilink=0; -$var=true; foreach($linkedObjectBlock as $key => $objectlink) { $ilink++; - $trclass=($var?'pair':'impair'); + $trclass='oddeven'; if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; ?> diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 7f96bab0b09..c5c726eec81 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -2,7 +2,7 @@ /* Copyright (C) 2002-2006 Rodolphe Quiedeville * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005-2013 Regis Houssin - * Copyright (C) 2013 Philippe Grand + * Copyright (C) 2013-2018 Philippe Grand * Copyright (C) 2013 Florian Henry * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2015 Marcos García @@ -44,10 +44,8 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; if (!$user->rights->fournisseur->facture->lire) accessforbidden(); -$langs->load("bills"); -$langs->load("companies"); -$langs->load('products'); -$langs->load('projects'); +// Load translation files required by the page +$langs->loadLangs(array('products', 'bills', 'companies', 'projects')); $action=GETPOST('action','alpha'); $massaction=GETPOST('massaction','alpha'); @@ -823,7 +821,6 @@ if ($resql) { $i=0; - $var=true; $totalarray=array(); while ($i < min($num,$limit)) { diff --git a/htdocs/fourn/facture/rapport.php b/htdocs/fourn/facture/rapport.php index ee7f5f99769..c20b26b1263 100644 --- a/htdocs/fourn/facture/rapport.php +++ b/htdocs/fourn/facture/rapport.php @@ -146,17 +146,15 @@ if ($year) print ''.$langs->trans("Size").''; print ''.$langs->trans("Date").''; print ''; - $var=true; if (is_resource($handle)) { while (($file = readdir($handle))!==false) { if (preg_match('/^supplier_payment/i',$file)) { - $tfile = $dir . '/'.$year.'/'.$file; $relativepath = $year.'/'.$file; - print "".''.img_pdf().' '.$file.''; + print ''.''.img_pdf().' '.$file.''; print ''.dol_print_size(dol_filesize($tfile)).''; print ''.dol_print_date(dol_filemtime($tfile),"dayhour").''; } diff --git a/htdocs/fourn/recap-fourn.php b/htdocs/fourn/recap-fourn.php index fc5821b96f8..e680c18074e 100644 --- a/htdocs/fourn/recap-fourn.php +++ b/htdocs/fourn/recap-fourn.php @@ -26,8 +26,8 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; -$langs->load("companies"); -$langs->load("bills"); +// Load translation files required by the page +$langs->loadLangs(array('bills', 'companies')); // Security check $socid = GETPOST("socid",'int'); @@ -82,7 +82,6 @@ if ($socid > 0) $resql=$db->query($sql); if ($resql) { - $var=true; $num = $db->num_rows($resql); print ''; @@ -116,7 +115,6 @@ if ($socid > 0) } $totalpaye = $fac->getSommePaiement(); - print ''; print "".dol_print_date($fac->date)."\n"; From a6729b0bd125324759c9f5c0c8479e234f5703ee Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 25 Jun 2018 09:10:24 +0200 Subject: [PATCH 2/5] Fix: change field name and remove obsolete data --- htdocs/admin/dict.php | 10 +-- htdocs/core/class/html.formother.class.php | 4 +- htdocs/install/mysql/data/llx_c_ecotaxe.sql | 75 ------------------- .../install/mysql/migration/7.0.0-8.0.0.sql | 2 + htdocs/install/mysql/tables/llx_c_ecotaxe.sql | 18 ++--- 5 files changed, 18 insertions(+), 91 deletions(-) delete mode 100644 htdocs/install/mysql/data/llx_c_ecotaxe.sql diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 65ceb912ea9..696f8a0131f 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -183,7 +183,7 @@ $tabsql[10]= "SELECT t.rowid, t.code, t.taux, t.localtax1_type, t.localtax1, t.l $tabsql[11]= "SELECT t.rowid as rowid, t.element, t.source, t.code, t.libelle, t.position, t.active FROM ".MAIN_DB_PREFIX."c_type_contact AS t"; $tabsql[12]= "SELECT c.rowid as rowid, c.code, c.libelle, c.libelle_facture, c.nbjour, c.type_cdr, c.decalage, c.active, c.sortorder, c.entity FROM ".MAIN_DB_PREFIX."c_payment_term AS c WHERE c.entity = " . getEntity($tabname[12]); $tabsql[13]= "SELECT c.id as rowid, c.code, c.libelle, c.type, c.active, c.entity FROM ".MAIN_DB_PREFIX."c_paiement AS c WHERE c.entity = " . getEntity($tabname[13]); -$tabsql[14]= "SELECT e.rowid as rowid, e.code as code, e.libelle, e.price, e.organization, e.fk_pays as country_id, c.code as country_code, c.label as country, e.active FROM ".MAIN_DB_PREFIX."c_ecotaxe AS e, ".MAIN_DB_PREFIX."c_country as c WHERE e.fk_pays=c.rowid and c.active=1"; +$tabsql[14]= "SELECT e.rowid as rowid, e.code as code, e.label, e.price, e.organization, e.fk_pays as country_id, c.code as country_code, c.label as country, e.active FROM ".MAIN_DB_PREFIX."c_ecotaxe AS e, ".MAIN_DB_PREFIX."c_country as c WHERE e.fk_pays=c.rowid and c.active=1"; $tabsql[15]= "SELECT rowid as rowid, code, label as libelle, width, height, unit, active FROM ".MAIN_DB_PREFIX."c_paper_format"; $tabsql[16]= "SELECT code, label as libelle, sortorder, active FROM ".MAIN_DB_PREFIX."c_prospectlevel"; $tabsql[17]= "SELECT id as rowid, code, label, accountancy_code, active FROM ".MAIN_DB_PREFIX."c_type_fees"; @@ -261,7 +261,7 @@ $tabfield[10]= "country_id,country,code,taux,localtax1_type,localtax1,localtax2_ $tabfield[11]= "element,source,code,libelle,position"; $tabfield[12]= "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder,entity"; $tabfield[13]= "code,libelle,type,entity"; -$tabfield[14]= "code,libelle,price,organization,country_id,country"; +$tabfield[14]= "code,label,price,organization,country_id,country"; $tabfield[15]= "code,libelle,width,height,unit"; $tabfield[16]= "code,libelle,sortorder"; $tabfield[17]= "code,label,accountancy_code"; @@ -300,7 +300,7 @@ $tabfieldvalue[10]= "country,code,taux,localtax1_type,localtax1,localtax2_type,l $tabfieldvalue[11]= "element,source,code,libelle,position"; $tabfieldvalue[12]= "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder"; $tabfieldvalue[13]= "code,libelle,type"; -$tabfieldvalue[14]= "code,libelle,price,organization,country"; +$tabfieldvalue[14]= "code,label,price,organization,country"; $tabfieldvalue[15]= "code,libelle,width,height,unit"; $tabfieldvalue[16]= "code,libelle,sortorder"; $tabfieldvalue[17]= "code,label,accountancy_code"; @@ -339,7 +339,7 @@ $tabfieldinsert[10]= "fk_pays,code,taux,localtax1_type,localtax1,localtax2_type, $tabfieldinsert[11]= "element,source,code,libelle,position"; $tabfieldinsert[12]= "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder,entity"; $tabfieldinsert[13]= "code,libelle,type,entity"; -$tabfieldinsert[14]= "code,libelle,price,organization,fk_pays"; +$tabfieldinsert[14]= "code,label,price,organization,fk_pays"; $tabfieldinsert[15]= "code,label,width,height,unit"; $tabfieldinsert[16]= "code,label,sortorder"; $tabfieldinsert[17]= "code,label,accountancy_code"; @@ -419,7 +419,7 @@ $tabcond[10]= true; $tabcond[11]= (! empty($conf->societe->enabled)); $tabcond[12]= (! empty($conf->commande->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->facture->enabled) || ! empty($conf->fournisseur->enabled)); $tabcond[13]= (! empty($conf->commande->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->facture->enabled) || ! empty($conf->fournisseur->enabled)); -$tabcond[14]= (! empty($conf->product->enabled) && ! empty($conf->ecotax->enabled)); +$tabcond[14]= (! empty($conf->product->enabled) && ! empty($conf->global->MAIN_SHOW_ECOTAX_DICTIONNARY)); $tabcond[15]= true; $tabcond[16]= (! empty($conf->societe->enabled) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)); $tabcond[17]= (! empty($conf->deplacement->enabled) || ! empty($conf->expensereport->enabled)); diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 4eb59a1c1ce..098b75a81b6 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -165,7 +165,7 @@ class FormOther { global $langs; - $sql = "SELECT e.rowid, e.code, e.libelle, e.price, e.organization,"; + $sql = "SELECT e.rowid, e.code, e.label, e.price, e.organization,"; $sql.= " c.label as country"; $sql.= " FROM ".MAIN_DB_PREFIX."c_ecotaxe as e,".MAIN_DB_PREFIX."c_country as c"; $sql.= " WHERE e.active = 1 AND e.fk_pays = c.rowid"; @@ -191,7 +191,7 @@ class FormOther else { print '