From c362e7cf2dc6c104213469446737480faaca09a5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 27 Nov 2016 17:10:07 +0100 Subject: [PATCH 01/13] FIX #6043 - Payment mode not visible on supplier invoice list --- htdocs/fourn/facture/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 47841195c83..89dfb083ea0 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -247,9 +247,9 @@ llxHeader('',$langs->trans("SuppliersInvoices"),'EN:Suppliers_Invoices|FR:Factur $sql = "SELECT"; if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; -$sql.= " f.rowid as facid, f.ref, f.ref_supplier, f.datef, f.date_lim_reglement as datelimite,"; +$sql.= " f.rowid as facid, f.ref, f.ref_supplier, f.datef, f.date_lim_reglement as datelimite, f.fk_mode_reglement,"; $sql.= " f.total_ht, f.total_ttc, f.total_tva as total_vat, f.paye as paye, f.fk_statut as fk_statut, f.libelle as label,"; -$sql.= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, '; +$sql.= " s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client,"; $sql.= " typent.code as typent_code,"; $sql.= " state.code_departement as state_code, state.nom as state_name,"; $sql.= " p.rowid as project_id, p.ref as project_ref"; From 8b569f9dfe7550844be487fe17f6f7de4b75266a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 27 Nov 2016 17:17:29 +0100 Subject: [PATCH 02/13] Try a fix for #6024 --- htdocs/fourn/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 2acb57665a6..2a1f1dab8bc 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1765,7 +1765,7 @@ else print ''; $paymentstatic->id=$objp->rowid; $paymentstatic->datepaye=$db->jdate($objp->dp); - $paymentstatic->ref=$objp->ref; + $paymentstatic->ref=($objp->ref ? $objp->ref : $objp->rowid); $paymentstatic->num_paiement=$objp->num_paiement; $paymentstatic->payment_code=$objp->payment_code; print $paymentstatic->getNomUrl(1); From b2ed3f30535871b0f313d7b51b2051845f8ac772 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Nov 2016 16:32:14 +0100 Subject: [PATCH 03/13] Fix translation --- htdocs/langs/en_US/bills.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index f89e4f1121e..65a93b573e3 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -41,7 +41,7 @@ ConsumedBy=Consumed by NotConsumed=Not consumed NoReplacableInvoice=No replacable invoices NoInvoiceToCorrect=No invoice to correct -InvoiceHasAvoir=Corrected by one or several invoices +InvoiceHasAvoir=Was source of one or several credit notes CardBill=Invoice card PredefinedInvoices=Predefined Invoices Invoice=Invoice From 196428edf5dbb1d6a21e5abc3446d263a1a04dee Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Nov 2016 16:34:38 +0100 Subject: [PATCH 04/13] FIX #6051 --- htdocs/societe/consumption.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index ea2cb899893..c31b4513ef5 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -250,6 +250,7 @@ if ($type_element == 'supplier_invoice') $tables_from = MAIN_DB_PREFIX."facture_fourn as f,".MAIN_DB_PREFIX."facture_fourn_det as d"; $where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".$socid; $where.= " AND d.fk_facture_fourn = f.rowid"; + $where.= " AND f.entity = ".$conf->entity; $dateprint = 'f.datef'; $doc_number='f.ref'; $thirdTypeSelect='supplier'; @@ -262,6 +263,7 @@ if ($type_element == 'supplier_order') $tables_from = MAIN_DB_PREFIX."commande_fournisseur as c,".MAIN_DB_PREFIX."commande_fournisseurdet as d"; $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid; $where.= " AND d.fk_commande = c.rowid"; + $where.= " AND c.entity = ".$conf->entity; $dateprint = 'c.date_valid'; $doc_number='c.ref'; $thirdTypeSelect='supplier'; @@ -275,6 +277,7 @@ if ($type_element == 'contract') $tables_from = MAIN_DB_PREFIX."contrat as c,".MAIN_DB_PREFIX."contratdet as d"; $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid; $where.= " AND d.fk_contrat = c.rowid"; + $where.= " AND c.entity = ".$conf->entity; $dateprint = 'c.date_valid'; $doc_number='c.ref'; $thirdTypeSelect='customer'; From 6e439109324dd66cc1add4ee608d9e6bdd0e3a15 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Nov 2016 18:38:48 +0100 Subject: [PATCH 05/13] FIX Filter was wrong or lost during navigation --- htdocs/compta/resultat/clientfourn.php | 164 +++++++++++++++++-------- 1 file changed, 110 insertions(+), 54 deletions(-) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 95ea2bfe46c..63071794caa 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -52,6 +52,17 @@ if ($user->societe_id > 0) $socid = $user->societe_id; if (! empty($conf->comptabilite->enabled)) $result=restrictedArea($user,'compta','','','resultat'); if (! empty($conf->accounting->enabled)) $result=restrictedArea($user,'accounting','','','comptarapport'); +$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$sortfield = GETPOST("sortfield",'alpha'); +$sortorder = GETPOST("sortorder",'alpha'); +$page = GETPOST("page",'int'); +if ($page == -1) { $page = 0; } +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortfield) $sortfield='s.nom, s.rowid'; +if (! $sortorder) $sortorder='ASC'; + // Date range $year=GETPOST("year"); if (empty($year)) @@ -150,12 +161,23 @@ $hselected = 'report'; report_header($name,$nomlink,$period,$periodlink,$description,$builddate,$exportlink,array('modecompta'=>$modecompta),$calcmode); // Show report array +$param='&modecompta='.$modecompta; +if ($date_startday) $param.='&date_startday='.$date_startday; +if ($date_startmonth) $param.='&date_startmonth='.$date_startmonth; +if ($date_startyear) $param.='&date_startyear='.$date_startyear; +if ($date_endday) $param.='&date_endday='.$date_endday; +if ($date_endmonth) $param.='&date_endmonth='.$date_endmonth; +if ($date_endyear) $param.='&date_endyear='.$date_startyear; + print ''; print ''; -print ''; +print_liste_field_titre(''); +print_liste_field_titre($langs->trans("Name"), $_SERVER["PHP_SELF"],'s.nom, s.rowid','',$param,'',$sortfield,$sortorder); if ($modecompta == 'CREANCES-DETTES') - print ""; -print ""; +{ + print_liste_field_titre($langs->trans("AmountHT"), $_SERVER["PHP_SELF"],'amount_ht','',$param,'align="right"',$sortfield,$sortorder); +} +print_liste_field_titre($langs->trans("AmountTTC"), $_SERVER["PHP_SELF"],'amount_ttc','',$param,'align="right"',$sortfield,$sortorder); print "\n"; /* @@ -197,7 +219,7 @@ else $sql.= " AND f.entity = ".$conf->entity; if ($socid) $sql.= " AND f.fk_soc = ".$socid; $sql.= " GROUP BY s.nom, s.rowid"; -$sql.= " ORDER BY s.nom, s.rowid"; +$sql.= $db->order($sortfield, $sortorder); dol_syslog("get customer invoices", LOG_DEBUG); $result = $db->query($sql); @@ -323,7 +345,7 @@ else $sql.= " AND f.entity = ".$conf->entity; if ($socid) $sql.= " AND f.fk_soc = ".$socid; $sql .= " GROUP BY s.nom, s.rowid"; -$sql .= " ORDER BY s.nom, s.rowid"; +$sql.= $db->order($sortfield, $sortorder); print ''; @@ -408,7 +430,11 @@ else } $sql.= " AND cs.entity = ".$conf->entity; $sql.= " GROUP BY c.libelle, c.id"; -$sql.= " ORDER BY c.libelle, c.id"; +$newsortfield = $sortfield; +if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'c.libelle, c.id'; +if ($newsortfield == 'amount_ht') $newsortfield = 'amount'; +if ($newsortfield == 'amount_ttc') $newsortfield = 'amount'; +$sql.= $db->order($newsortfield, $sortorder); dol_syslog("get social contributions deductible=0", LOG_DEBUG); $result=$db->query($sql); @@ -468,8 +494,6 @@ if ($modecompta == 'CREANCES-DETTES') if (! empty($date_start) && ! empty($date_end)) $sql.= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'"; $sql.= " AND cs.entity = ".$conf->entity; - $sql.= " GROUP BY c.libelle, c.id"; - $sql.= " ORDER BY c.libelle, c.id"; } else { @@ -483,9 +507,13 @@ else if (! empty($date_start) && ! empty($date_end)) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; $sql.= " AND cs.entity = ".$conf->entity; - $sql.= " GROUP BY c.libelle, c.id"; - $sql.= " ORDER BY c.libelle, c.id"; } +$sql.= " GROUP BY c.libelle, c.id"; +$newsortfield = $sortfield; +if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'c.libelle, c.id'; +if ($newsortfield == 'amount_ht') $newsortfield = 'amount'; +if ($newsortfield == 'amount_ttc') $newsortfield = 'amount'; +$sql.= $db->order($newsortfield, $sortorder); dol_syslog("get social contributions deductible=1", LOG_DEBUG); $result=$db->query($sql); @@ -569,8 +597,12 @@ if (! empty($conf->salaries->enabled)) $sql.= " AND $column >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'"; $sql.= " GROUP BY u.rowid, u.firstname, u.lastname, p.fk_user, p.label, dm"; - $sql.= " ORDER BY u.firstname"; - + $newsortfield = $sortfield; + if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'u.firstname, u.lastname'; + if ($newsortfield == 'amount_ht') $newsortfield = 'amount'; + if ($newsortfield == 'amount_ttc') $newsortfield = 'amount'; + $sql.= $db->order($newsortfield, $sortorder); + dol_syslog("get payment salaries"); $result=$db->query($sql); $subtotal_ht = 0; @@ -638,7 +670,7 @@ if (! empty($conf->expensereport->enabled)) $column='p.date_valid'; } else { - $sql = "SELECT p.rowid, p.ref, u.rowid as userid, u.firstname, u.lastname, date_format(pe.datep,'%Y-%m') as dm, sum(p.total_ht) as amount_ht,sum(p.total_ttc) as amount_ttc"; + $sql = "SELECT p.rowid, p.ref, u.rowid as userid, u.firstname, u.lastname, date_format(pe.datep,'%Y-%m') as dm, sum(p.total_ht) as amount_ht, sum(p.total_ttc) as amount_ttc"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_expensereport as pe ON pe.fk_expensereport = p.rowid"; @@ -652,55 +684,59 @@ if (! empty($conf->expensereport->enabled)) print ''; if (! empty($date_start) && ! empty($date_end)) + { $sql.= " AND $column >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'"; + } + + $sql.= " GROUP BY u.rowid, p.rowid, p.ref, u.firstname, u.lastname, dm"; + $newsortfield = $sortfield; + if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'p.ref'; + $sql.= $db->order($newsortfield, $sortorder); - $sql.= " GROUP BY u.rowid, p.rowid, p.ref, u.firstname, u.lastname, dm"; - $sql.= " ORDER BY p.ref"; - - dol_syslog("get expense report outcome"); - $result=$db->query($sql); - $subtotal_ht = 0; - $subtotal_ttc = 0; - if ($result) + dol_syslog("get expense report outcome"); + $result=$db->query($sql); + $subtotal_ht = 0; + $subtotal_ttc = 0; + if ($result) + { + $num = $db->num_rows($result); + $var=true; + if ($num) { - $num = $db->num_rows($result); - $var=true; - if ($num) + while ($obj = $db->fetch_object($result)) { - while ($obj = $db->fetch_object($result)) - { - $total_ht -= $obj->amount_ht; - $total_ttc -= $obj->amount_ttc; - $subtotal_ht += $obj->amount_ht; - $subtotal_ttc += $obj->amount_ttc; + $total_ht -= $obj->amount_ht; + $total_ttc -= $obj->amount_ttc; + $subtotal_ht += $obj->amount_ht; + $subtotal_ttc += $obj->amount_ttc; - $var = !$var; - print ""; - - print "\n"; - - if ($modecompta == 'CREANCES-DETTES') print ''; - print ''; - print ''; - } - } - else - { $var = !$var; print ""; - print ''; + + print "\n"; + + if ($modecompta == 'CREANCES-DETTES') print ''; + print ''; print ''; } } else { - dol_print_error($db); - } - print ''; - if ($modecompta == 'CREANCES-DETTES') - print ''; - print ''; + $var = !$var; + print ""; + print ''; print ''; + } + } + else + { + dol_print_error($db); + } + print ''; + if ($modecompta == 'CREANCES-DETTES') + print ''; + print ''; + print ''; } /* @@ -720,7 +756,11 @@ if (! empty($conf->don->enabled)) if (! empty($date_start) && ! empty($date_end)) $sql.= " AND p.datedon >= '".$db->idate($date_start)."' AND p.datedon <= '".$db->idate($date_end)."'"; $sql.= " GROUP BY p.societe, p.firstname, p.lastname, dm"; - $sql.= " ORDER BY p.societe, p.firstname, p.lastname, dm"; + $newsortfield = $sortfield; + if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'p.societe, p.firstname, p.lastname, dm'; + if ($newsortfield == 'amount_ht') $newsortfield = 'amount'; + if ($newsortfield == 'amount_ttc') $newsortfield = 'amount'; + $sql.= $db->order($newsortfield, $sortorder); dol_syslog("get dunning"); $result=$db->query($sql); @@ -795,7 +835,11 @@ if ($modecompta == 'CREANCES-DETTES') $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $sql.= " AND f.entity = ".$conf->entity; $sql.= " GROUP BY dm"; - $sql.= " ORDER BY dm"; + $newsortfield = $sortfield; + if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'dm'; + if ($newsortfield == 'amount_ht') $newsortfield = 'amount'; + if ($newsortfield == 'amount_ttc') $newsortfield = 'amount'; + $sql.= $db->order($newsortfield, $sortorder); dol_syslog("get vat to pay", LOG_DEBUG); $result=$db->query($sql); @@ -840,7 +884,11 @@ if ($modecompta == 'CREANCES-DETTES') $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $sql.= " AND f.entity = ".$conf->entity; $sql.= " GROUP BY dm"; - $sql.= " ORDER BY dm"; + $newsortfield = $sortfield; + if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'dm'; + if ($newsortfield == 'amount_ht') $newsortfield = 'amount'; + if ($newsortfield == 'amount_ttc') $newsortfield = 'amount'; + $sql.= $db->order($newsortfield, $sortorder); dol_syslog("get vat received back", LOG_DEBUG); $result=$db->query($sql); @@ -884,7 +932,11 @@ else $sql.= " AND t.datev >= '".$db->idate($date_start)."' AND t.datev <= '".$db->idate($date_end)."'"; $sql.= " AND t.entity = ".$conf->entity; $sql.= " GROUP BY dm"; - $sql.= " ORDER BY dm"; + $newsortfield = $sortfield; + if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'dm'; + if ($newsortfield == 'amount_ht') $newsortfield = 'amount'; + if ($newsortfield == 'amount_ttc') $newsortfield = 'amount'; + $sql.= $db->order($newsortfield, $sortorder); dol_syslog("get vat really paid", LOG_DEBUG); $result=$db->query($sql); @@ -925,7 +977,11 @@ else $sql.= " AND t.datev >= '".$db->idate($date_start)."' AND t.datev <= '".$db->idate($date_end)."'"; $sql.= " AND t.entity = ".$conf->entity; $sql.= " GROUP BY dm"; - $sql.= " ORDER BY dm"; + $newsortfield = $sortfield; + if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'dm'; + if ($newsortfield == 'amount_ht') $newsortfield = 'amount'; + if ($newsortfield == 'amount_ttc') $newsortfield = 'amount'; + $sql.= $db->order($newsortfield, $sortorder); dol_syslog("get vat really received back", LOG_DEBUG); $result=$db->query($sql); From f6734be1a17d3be5875138701fc1c5cb2831cf7c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 29 Nov 2016 17:08:44 +0100 Subject: [PATCH 06/13] Fix security hole. Add quick and fast hack to fix it --- htdocs/cron/admin/cron.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/htdocs/cron/admin/cron.php b/htdocs/cron/admin/cron.php index 697b24fcc1e..5b517857c7c 100644 --- a/htdocs/cron/admin/cron.php +++ b/htdocs/cron/admin/cron.php @@ -88,9 +88,20 @@ print ""; print ''; print ''; -print ''; print ''; print ''; From 711961ed1825407064125ad918a341f527e773ad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 29 Nov 2016 17:24:40 +0100 Subject: [PATCH 07/13] Fix missing translation --- htdocs/admin/ihm.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index 3147538c8fe..1a9ad5f317a 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -38,6 +38,7 @@ $langs->load("products"); $langs->load("members"); $langs->load("projects"); $langs->load("hrm"); +$langs->load("agenda"); if (! $user->admin) accessforbidden(); From e846d746549b3244c6ecf17c3313b56615f61d38 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 30 Nov 2016 15:19:16 +0100 Subject: [PATCH 08/13] Fix sort on invlice list --- htdocs/compta/facture/list.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 79342baf293..d9e5ae8ce23 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -130,7 +130,7 @@ $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search $fieldstosearchall = array( 'f.facnumber'=>'Ref', 'f.ref_client'=>'RefCustomer', - 'fd.description'=>'Description', + 'pd.description'=>'Description', 's.nom'=>"ThirdParty", 'f.note_public'=>'NotePublic', ); @@ -152,7 +152,7 @@ $arrayfields=array( 'f.total_ht'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1), 'f.total_vat'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>0), 'f.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>0), - 'am'=>array('label'=>$langs->trans("Received"), 'checked'=>0), + 'dynamount_payed'=>array('label'=>$langs->trans("Received"), 'checked'=>0), 'rtp'=>array('label'=>$langs->trans("Rest"), 'checked'=>0), 'f.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), 'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), @@ -648,7 +648,9 @@ $sql.= ' f.datec as date_creation, f.tms as date_update,'; $sql.= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, '; $sql.= " typent.code as typent_code,"; $sql.= " state.code_departement as state_code, state.nom as state_name"; -if (! $sall) $sql.= ', SUM(pf.amount) as am'; // To be able to sort on status +// We need dynamount_payed to be able to sort on status (value is surely wrong because we can count several lines several times due to other left join or link with contacts. But what we need is just 0 or > 0) +// TODO Better solution to be able to sort on already payed or remain to pay is to store amount_payed in a denormalized field. +if (! $sall) $sql.= ', SUM(pf.amount) as dynamount_payed'; // Add fields from extrafields foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); // Add fields from hooks @@ -662,7 +664,6 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s $sql.= ', '.MAIN_DB_PREFIX.'facture as f'; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture_extrafields as ef on (f.rowid = ef.fk_object)"; if (! $sall) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid'; -else $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facturedet as fd ON fd.fk_facture = f.rowid'; if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facturedet as pd ON f.rowid=pd.fk_facture'; if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; // We'll need this table joined to the select in order to filter by sale @@ -1018,8 +1019,8 @@ if ($resql) if (! empty($arrayfields['f.total_ht']['checked'])) print_liste_field_titre($arrayfields['f.total_ht']['label'],$_SERVER['PHP_SELF'],'f.total','',$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['f.total_vat']['checked'])) print_liste_field_titre($arrayfields['f.total_vat']['label'],$_SERVER['PHP_SELF'],'f.tva','',$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'],$_SERVER['PHP_SELF'],'f.total_ttc','',$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['am']['checked'])) print_liste_field_titre($arrayfields['am']['label'],$_SERVER['PHP_SELF'],'am','',$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['rtp']['checked'])) print_liste_field_titre($arrayfields['rtp']['label'],$_SERVER['PHP_SELF'],'rtp','',$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['dynamount_payed']['checked'])) print_liste_field_titre($arrayfields['dynamount_payed']['label'],$_SERVER['PHP_SELF'],'','',$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['rtp']['checked'])) print_liste_field_titre($arrayfields['rtp']['label'],$_SERVER['PHP_SELF'],'','',$param,'align="right"',$sortfield,$sortorder); // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { @@ -1038,7 +1039,7 @@ if ($resql) print $hookmanager->resPrint; if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'],$_SERVER["PHP_SELF"],"f.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'],$_SERVER["PHP_SELF"],"f.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); - if (! empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($arrayfields['f.fk_statut']['label'],$_SERVER["PHP_SELF"],"fk_statut,paye,am","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($arrayfields['f.fk_statut']['label'],$_SERVER["PHP_SELF"],"fk_statut,paye,type,dynamount_payed","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; @@ -1135,7 +1136,7 @@ if ($resql) print ''; print ''; } - if (! empty($arrayfields['am']['checked'])) + if (! empty($arrayfields['dynamount_payed']['checked'])) { print ''; @@ -1369,9 +1370,9 @@ if ($resql) $totalarray['totalttc'] += $obj->total_ttc; } - if (! empty($arrayfields['am']['checked'])) + if (! empty($arrayfields['dynamount_payed']['checked'])) { - print ''; + print ''; // TODO Use a denormalized field if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['totalamfield']=$totalarray['nbfield']; $totalarray['totalam'] += $paiement; @@ -1379,7 +1380,7 @@ if ($resql) if (! empty($arrayfields['rtp']['checked'])) { - print ''; + print ''; // TODO Use a denormalized field if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['totalrtpfield']=$totalarray['nbfield']; $totalarray['totalrtp'] += $remaintopay; From c17d354367937f9b9271cdc4807ab9ac1a6c350a Mon Sep 17 00:00:00 2001 From: arnaud Date: Wed, 30 Nov 2016 16:48:27 +0100 Subject: [PATCH 09/13] Fix propal updateline oldcopy extrafields --- htdocs/comm/propal/class/propal.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 6c5fdcbbec4..d94932d10c8 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -651,6 +651,7 @@ class Propal extends CommonObject //Fetch current line from the database and then clone the object and set it in $oldline property $line = new PropaleLigne($this->db); $line->fetch($rowid); + $line->fetch_optionals(); // Fetch extrafields for oldcopy $staticline = clone $line; From 411e82b7a3b528072438143e88cd4c309fa95f38 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Dec 2016 14:52:38 +0100 Subject: [PATCH 10/13] Fix button set to paid not always visible when it should. --- htdocs/expensereport/card.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index d3b25d2277f..9112f8ee99b 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1999,7 +1999,8 @@ if ($action != 'create' && $action != 'edit') // If bank module is not used if (($user->rights->expensereport->to_paid || empty($conf->banque->enabled)) && $object->fk_statut == 5) { - if ((round($remaintopay) == 0 || empty($conf->banque->enabled)) && $object->paid == 0) + //if ((round($remaintopay) == 0 || empty($conf->banque->enabled)) && $object->paid == 0) + if ($object->paid == 0) { print '"; } From a75577516d1bf37c69418258b2dc5e9beec821ba Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Dec 2016 15:13:04 +0100 Subject: [PATCH 11/13] Fix pb with multicompany on expense report --- htdocs/expensereport/export_csv.php | 1 + htdocs/expensereport/index.php | 2 +- htdocs/expensereport/list.php | 2 +- htdocs/expensereport/payment/card.php | 2 +- htdocs/expensereport/payment/payment.php | 5 +++-- htdocs/expensereport/synchro_compta.php | 1 + 6 files changed, 8 insertions(+), 5 deletions(-) diff --git a/htdocs/expensereport/export_csv.php b/htdocs/expensereport/export_csv.php index 3cf520c6739..d55e262e2e4 100644 --- a/htdocs/expensereport/export_csv.php +++ b/htdocs/expensereport/export_csv.php @@ -128,6 +128,7 @@ if (isset($_POST['action'])) $sql = "SELECT d.rowid, d.ref, d.total_ht, d.total_tva, d.total_ttc"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d"; + $sql.= ' AND d.entity IN ('.getEntity('expensereport', 1).')'; $sql.= " ORDER BY d.rowid"; $result = $db->query($sql); diff --git a/htdocs/expensereport/index.php b/htdocs/expensereport/index.php index 117ecc5e3c4..83e45d2a1b7 100644 --- a/htdocs/expensereport/index.php +++ b/htdocs/expensereport/index.php @@ -147,7 +147,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d, ".MAIN_DB_PREFIX."user as u" if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE u.rowid = d.fk_user_author"; if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) $sql.=' AND d.fk_user_author IN ('.join(',',$childids).')'; -//$sql.= " AND d.entity = ".$conf->entity; +$sql.= ' AND d.entity IN ('.getEntity('expensereport', 1).')'; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND d.fk_user_author = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND d.fk_user_author = ".$socid; $sql.= $db->order($sortfield,$sortorder); diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index b857b9c92d4..476ef2224f5 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -133,7 +133,7 @@ $sql.= " d.date_debut, d.date_fin, d.date_valid,"; $sql.= " u.rowid as id_user, u.firstname, u.lastname"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON d.fk_user_author = u.rowid"; -$sql.= " WHERE d.entity = ".$conf->entity; +$sql.= ' WHERE d.entity IN ('.getEntity('expensereport', 1).')'; // Search all if (!empty($sall)) { diff --git a/htdocs/expensereport/payment/card.php b/htdocs/expensereport/payment/card.php index 19d5b3206f7..f9ba5af3dc0 100644 --- a/htdocs/expensereport/payment/card.php +++ b/htdocs/expensereport/payment/card.php @@ -199,7 +199,7 @@ $disable_delete = 0; $sql = 'SELECT er.rowid as did, er.paid, er.total_ttc, per.amount'; $sql.= ' FROM '.MAIN_DB_PREFIX.'payment_expensereport as per,'.MAIN_DB_PREFIX.'expensereport as er'; $sql.= ' WHERE per.fk_expensereport = er.rowid'; -$sql.= ' AND er.entity = '.$conf->entity; +$sql.= ' AND er.entity IN ('.getEntity('expensereport', 1).')'; $sql.= ' AND per.rowid = '.$id; dol_syslog("expensereport/payment/card.php", LOG_DEBUG); diff --git a/htdocs/expensereport/payment/payment.php b/htdocs/expensereport/payment/payment.php index c4351e4d038..e361a9954c0 100644 --- a/htdocs/expensereport/payment/payment.php +++ b/htdocs/expensereport/payment/payment.php @@ -193,8 +193,9 @@ if (GETPOST("action") == 'create') print ''; $sql = "SELECT sum(p.amount) as total"; - $sql.= " FROM ".MAIN_DB_PREFIX."payment_expensereport as p"; - $sql.= " WHERE p.fk_expensereport = ".$chid; + $sql.= " FROM ".MAIN_DB_PREFIX."payment_expensereport as p, ".MAIN_DB_PREFIX."expensereport as e"; + $sql.= " WHERE p.fk_expensereport = e.rowid AND p.fk_expensereport = ".$chid; + $sql.= ' AND e.entity IN ('.getEntity('expensereport', 1).')'; $resql = $db->query($sql); if ($resql) { diff --git a/htdocs/expensereport/synchro_compta.php b/htdocs/expensereport/synchro_compta.php index 31c2d985840..eba616d2620 100644 --- a/htdocs/expensereport/synchro_compta.php +++ b/htdocs/expensereport/synchro_compta.php @@ -139,6 +139,7 @@ else: $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON d.fk_user_author = u.rowid"; $sql.= " WHERE d.fk_statut = 6"; + $sql.= ' AND d.entity IN ('.getEntity('expensereport', 1).')'; $sql.= " ORDER BY d.date_valid DESC"; $resql=$db->query($sql); From 7a3b3090139e9300504d4f3ad4cd43911523a361 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Dec 2016 15:22:26 +0100 Subject: [PATCH 12/13] Fix width --- htdocs/compta/paiement/cheque/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php index ebfd598ee0b..9ea4d6eb1e0 100644 --- a/htdocs/compta/paiement/cheque/list.php +++ b/htdocs/compta/paiement/cheque/list.php @@ -160,7 +160,7 @@ if ($resql) print ''; print ''; print ''; print ''; print '"; // Num ref cheque - print ''; } @@ -847,20 +853,33 @@ foreach ($listofreferent as $key => $value) // Amount inc tax if (empty($value['disableamount'])) { + $total_ttc_by_line=null; if ($tablename == 'don') $total_ttc_by_line=$element->amount; elseif ($tablename == 'projet_task') { - $defaultvat = get_default_tva($mysoc, $mysoc); - $total_ttc_by_line = price2num($total_ht_by_line * (1 + ($defaultvat / 100)),'MT'); + if (! empty($conf->salaries->enabled)) + { + // TODO Permission to read daily rate + $defaultvat = get_default_tva($mysoc, $mysoc); + $total_ttc_by_line = price2num($total_ht_by_line * (1 + ($defaultvat / 100)),'MT'); + } + else + { + $othermessage=$form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("ModuleSalaryToDefineHourlyRateMustBeEnabled")); + } } else { $total_ttc_by_line=$element->total_ttc; } print ''; } @@ -923,15 +942,25 @@ foreach ($listofreferent as $key => $value) if ($breakline) print $breakline; + // Total print ''; //if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print ''; //elseif (empty($value['disableamount']) && in_array($tablename, array('projet_task'))) print ''; - if (empty($value['disableamount'])) print ''; - else print ''; + print ''; //if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print ''; //elseif (empty($value['disableamount']) && in_array($tablename, array('projet_task'))) print ''; - if (empty($value['disableamount'])) print ''; - else print ''; + print ''; print ''; print ''; }
  ".$langs->trans("AmountHT")."".$langs->trans("AmountTTC")."
'.$langs->trans("SuppliersInvoices").'
'.$langs->trans("ExpenseReport").'
 ".$langs->trans("ExpenseReport")." userid."\">".$obj->firstname." ".$obj->lastname."'.price(-$obj->amount_ht).''.price(-$obj->amount_ttc).'
 '.$langs->trans("None").'".$langs->trans("ExpenseReport")." userid."\">".$obj->firstname." ".$obj->lastname."'.price(-$obj->amount_ht).''.price(-$obj->amount_ttc).'
'.price(-$subtotal_ht).''.price(-$subtotal_ttc).'
 '.$langs->trans("None").'
'.price(-$subtotal_ht).''.price(-$subtotal_ttc).'
'.$langs->trans("KeyForCronAccess").''; -if (! empty($conf->use_javascript_ajax)) - print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"'); +$disabled=''; +if (! empty($conf->global->CRON_DISABLE_KEY_CHANGE)) $disabled=' disabled="disabled"'; +print ''; +if (empty($conf->global->CRON_DISABLE_KEY_CHANGE)) +{ + print ''; + if (! empty($conf->use_javascript_ajax)) + print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"'); +} +else +{ + print (! empty($conf->global->CRON_KEY)?$conf->global->CRON_KEY:''); + print ''; +} print ' 
'; print ''.(! empty($paiement)?price($paiement,0,$langs):' ').''.(! empty($paiement)?price($paiement,0,$langs):' ').''.(! empty($remaintopay)?price($remaintopay,0,$langs):' ').''.(! empty($remaintopay)?price($remaintopay,0,$langs):' ').'
'.$langs->trans("Amount").''.price($expensereport->total_ttc,0,$outputlangs,1,-1,-1,$conf->currency).'
 '; - print ''; + print ''; print ''; @@ -179,7 +179,7 @@ if ($resql) print "
'; + print ''; $checkdepositstatic->id=$objp->rowid; $checkdepositstatic->ref=($objp->ref?$objp->ref:$objp->rowid); $checkdepositstatic->statut=$objp->statut; From 69b5baebc53450ce9a3fb6c12c3a5da60903266d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Dec 2016 15:54:06 +0100 Subject: [PATCH 13/13] FIX rendering of output of estimated amount on project overview page. --- htdocs/projet/element.php | 55 ++++++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index cbd22856e4c..1d9ffd61a99 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -812,6 +812,8 @@ foreach ($listofreferent as $key => $value) $warning=''; if (empty($value['disableamount'])) { + $total_ht_by_line=null; + $othermessage=''; if ($tablename == 'don') $total_ht_by_line=$element->amount; elseif ($tablename == 'projet_task') { @@ -828,7 +830,7 @@ foreach ($listofreferent as $key => $value) } else { - print $langs->trans("ModuleDisabled"); + $othermessage=$form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("ModuleSalaryToDefineHourlyRateMustBeEnabled")); } } else @@ -836,9 +838,13 @@ foreach ($listofreferent as $key => $value) $total_ht_by_line=$element->total_ht; } print ''; - if (! $qualifiedfortotal) print ''; - print (isset($total_ht_by_line)?price($total_ht_by_line):' '); - if (! $qualifiedfortotal) print ''; + if ($othermessage) print $othermessage; + if (isset($total_ht_by_line)) + { + if (! $qualifiedfortotal) print ''; + print price($total_ht_by_line); + if (! $qualifiedfortotal) print ''; + } if ($warning) print ' '.img_warning($warning); print ''; - if (! $qualifiedfortotal) print ''; - print (isset($total_ttc_by_line)?price($total_ttc_by_line):' '); - if (! $qualifiedfortotal) print ''; + if ($othermessage) print $othermessage; + if (isset($total_ttc_by_line)) + { + if (! $qualifiedfortotal) print ''; + print price($total_ttc_by_line); + if (! $qualifiedfortotal) print ''; + } if ($warning) print ' '.img_warning($warning); print '
'.$langs->trans("Number").': '.$i.''.$langs->trans("TotalHT").' : '.price($total_ht).''.$langs->trans("Total").' : '.price($total_ht).''.$langs->trans("TotalHT").' : '.price($total_ht).''; + if (empty($value['disableamount'])) + { + if (! empty($conf->salaries->enabled)) print ''.$langs->trans("TotalHT").' : '.price($total_ht); + } + print ''.$langs->trans("TotalTTC").' : '.price($total_ttc).''.$langs->trans("TotalTTC").' : '.price($total_ttc).''; + if (empty($value['disableamount'])) + { + + if (! empty($conf->salaries->enabled)) print $langs->trans("TotalTTC").' : '.price($total_ttc); + } + print '