From ba87549124c4579b4fd6736655d4abd5720ab0aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garc=C3=ADa?= Date: Mon, 19 Jun 2017 18:07:43 +0200 Subject: [PATCH 01/85] FIX #5640 Prices of a predefined product/service were incorrect under certain circumstances --- htdocs/core/tpl/objectline_create.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index d9b5b37d8f3..5e9786f2ba4 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -725,7 +725,7 @@ function setforpredef() { jQuery("#select_type").val(-1); jQuery("#prod_entry_mode_free").prop('checked',false); jQuery("#prod_entry_mode_predef").prop('checked',true); - jQuery("#price_ht").hide(); + jQuery("#price_ht").val('').hide(); jQuery("#multicurrency_price_ht").hide(); jQuery("#price_ttc").hide(); // May no exists jQuery("#tva_tx").hide(); From eaaee59f92abba096890ee867d968c0dfe20e3fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garc=C3=ADa?= Date: Mon, 19 Jun 2017 19:23:00 +0200 Subject: [PATCH 02/85] FIX #6541 since 4.0.4 to 5.0.0 autofill zip/town not working --- htdocs/core/class/conf.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index dc06bfe9ffa..203d41571a9 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -489,8 +489,8 @@ class Conf // By default, we propagate contacts if (! isset($this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN)) $this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN='*'; // Can be also '*' or '^(BILLING|SHIPPING|CUSTOMER|.*)$' (regex not yet implemented) - // By default, we use the zip town autofill - if (! isset($this->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) $this->global->MAIN_USE_ZIPTOWN_DICTIONNARY=1; + // By default, we do not use the zip town autofill + if (! isset($this->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) $this->global->MAIN_USE_ZIPTOWN_DICTIONNARY=0; // Define list of limited modules (value must be key found for "name" property of module, so for example 'supplierproposal' for Module "Supplier Proposal" if (! isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) $this->global->MAIN_MODULES_FOR_EXTERNAL='user,societe,propal,commande,facture,categorie,supplierproposal,fournisseur,contact,projet,contrat,ficheinter,expedition,agenda,resource,adherent'; // '' means 'all'. Note that contact is added here as it should be a module later. From c381c213a50af78bcf7f6b877e81493bdee2adfd Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 20 Jun 2017 06:52:41 +0200 Subject: [PATCH 03/85] Fix : Accountancy --- htdocs/accountancy/admin/accountmodel.php | 1 - htdocs/accountancy/admin/defaultaccounts.php | 16 +- htdocs/accountancy/bookkeeping/card.php | 3 +- htdocs/accountancy/bookkeeping/list.php | 1 - htdocs/accountancy/customer/index.php | 232 +++++++++---------- htdocs/accountancy/expensereport/index.php | 3 - htdocs/langs/en_US/salaries.lang | 3 +- 7 files changed, 125 insertions(+), 134 deletions(-) diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index ff908d6d066..e57354f8566 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -1148,7 +1148,6 @@ else * Show list of dictionary to show */ - $var=true; $lastlineisempty=false; print ''; print ''; diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index 227949a3c1c..9cf4d2977fd 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -1,11 +1,11 @@ - * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2016 Alexandre Spangaro - * Copyright (C) 2014-2015 Ari Elbaz (elarifr) +/* Copyright (C) 2013-2014 Olivier Geffroy + * Copyright (C) 2013-2014 Florian Henry + * Copyright (C) 2013-2017 Alexandre Spangaro + * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2014 Marcos García - * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2015 Jean-François Ferry * * 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 @@ -23,7 +23,7 @@ */ /** - * \file htdocs/accountancy/admin/index.php + * \file htdocs/accountancy/admin/defaultaccounts.php * \ingroup Advanced accountancy * \brief Setup page to configure accounting expert module */ @@ -53,10 +53,10 @@ $action = GETPOST('action', 'alpha'); $list_account_main = array ( 'ACCOUNTING_ACCOUNT_CUSTOMER', 'ACCOUNTING_ACCOUNT_SUPPLIER', + 'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT', ); $list_account = array ( - 'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT', 'ACCOUNTING_PRODUCT_BUY_ACCOUNT', 'ACCOUNTING_PRODUCT_SOLD_ACCOUNT', 'ACCOUNTING_SERVICE_BUY_ACCOUNT', diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 3c6d2faec94..28b7b177860 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -500,8 +500,7 @@ if ($action == 'create') { print "\n"; foreach ( $book->linesmvt as $line ) { - $var = ! $var; - print ''; + print ''; $total_debit += $line->debit; $total_credit += $line->credit; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 1062fd50d87..16d27df15fd 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -438,7 +438,6 @@ $total_debit = 0; $total_credit = 0; foreach ($object->lines as $line ) { - $var = ! $var; $total_debit += $line->debit; $total_credit += $line->credit; diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 24e066917bc..10322c68077 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -1,9 +1,9 @@ +/* Copyright (C) 2013 Olivier Geffroy * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2013-2016 Alexandre Spangaro * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2015 Jean-François Ferry * * 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 @@ -40,7 +40,7 @@ $langs->load("accountancy"); // Security check if (empty($conf->accounting->enabled)) { - accessforbidden(); + accessforbidden(); } if ($user->societe_id > 0) accessforbidden(); @@ -187,7 +187,7 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { } else { $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; } -$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy +$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy dol_syslog("htdocs/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG); $result = $db->query($sql); @@ -203,10 +203,6 @@ $buttonbind = '' . $langs->trans("CleanHistory", $year_current) . ''; - - -$var = true; - print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, ''); print '
'; @@ -269,14 +265,14 @@ print '
'; print ''; print ''; for($i = 1; $i <= 12; $i ++) { - print ''; + print ''; } print ''; $sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.account_number') . " AS codecomptable,"; $sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.label') . " AS intitule,"; for($i = 1; $i <= 12; $i ++) { - $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; + $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; } $sql .= " SUM(fd.total_ht) as total"; $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; @@ -296,22 +292,22 @@ $sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label"; dol_syslog("htdocs/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG); $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); + $num = $db->num_rows($resql); - while ( $row = $db->fetch_row($resql)) { + while ( $row = $db->fetch_row($resql)) { - print ''; - print ''; - for($i = 2; $i <= 12; $i ++) { - print ''; - } - print ''; - print ''; - print ''; - } - $db->free($resql); + print ''; + print ''; + for($i = 2; $i <= 12; $i ++) { + print ''; + } + print ''; + print ''; + print ''; + } + $db->free($resql); } else { - print $db->lasterror(); // Show last sql error + print $db->lasterror(); // Show last sql error } print "
' . $langs->trans("Account") . '' . $langs->trans("Label") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . length_accountg($row[0]) . '' . $row[1] . '' . price($row[$i]) . '' . price($row[13]) . '' . price($row[14]) . '
' . length_accountg($row[0]) . '' . $row[1] . '' . price($row[$i]) . '' . price($row[13]) . '' . price($row[14]) . '
\n"; @@ -319,101 +315,101 @@ print "\n"; if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report that should rely on result of this step ? { - print '
'; - print '
'; - - print_fiche_titre($langs->trans("OtherInfo"), '', ''); - - print "
\n"; - print ''; - print ''; - for($i = 1; $i <= 12; $i ++) { - print ''; - } - print ''; - - $sql = "SELECT '" . $langs->trans("TotalVente") . "' AS total,"; - for($i = 1; $i <= 12; $i ++) { - $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; - } - $sql .= " SUM(fd.total_ht) as total"; - $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; - $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; - $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; - $sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; - } else { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; - } - - dol_syslog('htdocs/accountancy/customer/index.php'); - $resql = $db->query($sql); - if ($resql) { - $i = 0; - $num = $db->num_rows($resql); - - while ($row = $db->fetch_row($resql)) { - print ''; - for($i = 1; $i <= 12; $i ++) { - print ''; - } - print ''; - print ''; - $i ++; - } - $db->free($resql); - } else { - print $db->lasterror(); // Show last sql error - } - print "
' . $langs->trans("TotalVente") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . $row[0] . '' . price($row[$i]) . '' . price($row[13]) . '
\n"; - - if (! empty($conf->margin->enabled)) { - print "
\n"; - print ''; - print ''; - for($i = 1; $i <= 12; $i ++) { - print ''; - } - print ''; - - $sql = "SELECT '" . $langs->trans("Vide") . "' AS marge,"; - for($i = 1; $i <= 12; $i ++) { - $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; - } - $sql .= " SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as total"; - $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; - $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; - $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; - $sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; - } else { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; - } - - dol_syslog('htdocs/accountancy/customer/index.php:: $sql=' . $sql); - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); - - while ($row = $db->fetch_row($resql)) { - - print ''; - for($i = 1; $i <= 12; $i ++) { - print ''; - } - print ''; - print ''; - } - $db->free($resql); - } else { - print $db->lasterror(); // Show last sql error - } - print "
' . $langs->trans("TotalMarge") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . $row[0] . '' . price(price2num($row[$i])) . '' . price(price2num($row[13])) . '
\n"; - } + print '
'; + print '
'; + + print_fiche_titre($langs->trans("OtherInfo"), '', ''); + + print "
\n"; + print ''; + print ''; + for($i = 1; $i <= 12; $i ++) { + print ''; + } + print ''; + + $sql = "SELECT '" . $langs->trans("TotalVente") . "' AS total,"; + for($i = 1; $i <= 12; $i ++) { + $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; + } + $sql .= " SUM(fd.total_ht) as total"; + $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; + $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; + $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; + $sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; + } else { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; + } + + dol_syslog('htdocs/accountancy/customer/index.php'); + $resql = $db->query($sql); + if ($resql) { + $i = 0; + $num = $db->num_rows($resql); + + while ($row = $db->fetch_row($resql)) { + print ''; + for($i = 1; $i <= 12; $i ++) { + print ''; + } + print ''; + print ''; + $i ++; + } + $db->free($resql); + } else { + print $db->lasterror(); // Show last sql error + } + print "
' . $langs->trans("TotalVente") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . $row[0] . '' . price($row[$i]) . '' . price($row[13]) . '
\n"; + + if (! empty($conf->margin->enabled)) { + print "
\n"; + print ''; + print ''; + for($i = 1; $i <= 12; $i ++) { + print ''; + } + print ''; + + $sql = "SELECT '" . $langs->trans("Vide") . "' AS marge,"; + for($i = 1; $i <= 12; $i ++) { + $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; + } + $sql .= " SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as total"; + $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; + $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; + $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; + $sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; + } else { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; + } + + dol_syslog('htdocs/accountancy/customer/index.php:: $sql=' . $sql); + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + + while ($row = $db->fetch_row($resql)) { + + print ''; + for($i = 1; $i <= 12; $i ++) { + print ''; + } + print ''; + print ''; + } + $db->free($resql); + } else { + print $db->lasterror(); // Show last sql error + } + print "
' . $langs->trans("TotalMarge") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . $row[0] . '' . price(price2num($row[$i])) . '' . price(price2num($row[13])) . '
\n"; + } } diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index e9ce1b2e729..fdbf4d1ce4b 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -178,9 +178,6 @@ $buttonreset = ' Date: Tue, 20 Jun 2017 10:24:54 +0200 Subject: [PATCH 04/85] FIX #7040 --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index d98625db1cc..2d52a7ee2d1 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1469,7 +1469,7 @@ abstract class CommonObject $fieldname = 'multicurrency_code'; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET '.$fieldname.' = "'.$this->db->escape($code).'"'; + $sql .= ' SET '.$fieldname." = '".$this->db->escape($code)."'"; $sql .= ' WHERE rowid='.$this->id; if ($this->db->query($sql)) From 6d42922839c41bf205f985b69b7cc83cab167be4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Jun 2017 10:37:42 +0200 Subject: [PATCH 05/85] FIX #7012 --- htdocs/supplier_proposal/card.php | 68 +++++++++++++++---------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 55da718cebc..a336a96b5e0 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -510,7 +510,7 @@ if (empty($reshook)) } // Add a product line - if ($action == 'addline' && $user->rights->supplier_proposal->creer) + if ($action == 'addline' && $user->rights->supplier_proposal->creer) { $langs->load('errors'); $error = 0; @@ -520,7 +520,7 @@ if (empty($reshook)) $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); $date_start=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); $date_end=dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); - + if (GETPOST('prod_entry_mode') == 'free') { $idprod=0; @@ -577,7 +577,7 @@ if (empty($reshook)) if ((GETPOST('prod_entry_mode') != 'free') && empty($error)) // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or '' { $productsupplier = new ProductFournisseur($db); - + if (empty($conf->global->SUPPLIER_PROPOSAL_WITH_NOPRICEDEFINED)) { $idprod=0; @@ -597,7 +597,7 @@ if (empty($reshook)) $idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice'), -1); // We force qty to -1 to be sure to find if a supplier price exist $res=$productsupplier->fetch($idprod); } - + if ($idprod > 0) { $pu_ht = $productsupplier->fourn_pu; @@ -606,7 +606,7 @@ if (empty($reshook)) $label = $productsupplier->label; $desc = $productsupplier->description; if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc); - + $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice')); $tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice')); if (empty($tva_tx)) $tva_npr=0; @@ -664,13 +664,13 @@ if (empty($reshook)) $type = GETPOST('type'); $fk_unit= GETPOST('units', 'alpha'); - + $tva_tx = price2num($tva_tx); // When vat is text input field - + // Local Taxes $localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); $localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); - + if (GETPOST('price_ht')!=='') { $price_base_type = 'HT'; @@ -683,13 +683,13 @@ if (empty($reshook)) $ht = $ttc / (1 + ($tva_tx / 100)); $price_base_type = 'HT'; } - + $result = $object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $ref_fourn, $fk_unit); //$result = $object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, $ttc, $type,'','', $date_start, $date_end, $array_options, $fk_unit); } - if (! $error && $result > 0) + if (! $error && $result > 0) { $db->commit(); @@ -706,7 +706,7 @@ if (empty($reshook)) } $model=$object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - + $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) dol_print_error($db,$result); } @@ -716,7 +716,7 @@ if (empty($reshook)) unset($_POST['qty']); unset($_POST['type']); unset($_POST['remise_percent']); - unset($_POST['pu']); + unset($_POST['pu']); unset($_POST['price_ht']); unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); @@ -747,8 +747,8 @@ if (empty($reshook)) unset($_POST['date_endday']); unset($_POST['date_endmonth']); unset($_POST['date_endyear']); - } - else + } + else { $db->rollback(); @@ -1367,11 +1367,11 @@ if ($action == 'create') // Print form confirm print $formconfirm; - + // Supplier proposal card $linkback = '' . $langs->trans("BackToList") . ''; - - + + $morehtmlref='
'; // Ref supplier //$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', 0, 1); @@ -1392,7 +1392,7 @@ if ($action == 'create') $morehtmlref.='
'; $morehtmlref.=''; $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=$formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$object->socid:-1), $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); $morehtmlref.=''; $morehtmlref.='
'; } else { @@ -1411,15 +1411,15 @@ if ($action == 'create') } } $morehtmlref.='
'; - - + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - + + print '
'; print '
'; print '
'; - + print ''; // Payment term @@ -1562,14 +1562,14 @@ if ($action == 'create') include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; print '
'; - + print '
'; print '
'; print '
'; print '
'; - + print ''; - + if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) { // Multicurrency Amount HT @@ -1587,7 +1587,7 @@ if ($action == 'create') print ''; print ''; } - + // Amount HT print ''; print ''; @@ -1618,18 +1618,18 @@ if ($action == 'create') print ''; print '
' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . $langs->trans('AmountHT') . '' . price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency) . '
'; - + // Margin Infos /*if (! empty($conf->margin->enabled)) { $formmargin->displayMarginInfos($object); - }*/ + }*/ print '
'; print '
'; print '
'; - + print '

'; - + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $blocname = 'contacts'; $title = $langs->trans('ContactsAddresses'); @@ -1666,7 +1666,7 @@ if ($action == 'create') // Add free products/services form global $forceall, $senderissupplier, $dateSelector; $forceall=1; $senderissupplier=2; $dateSelector=0; // $senderissupplier=2 is same than 1 but disable test on minimum qty. - + if (! empty($object->lines)) $ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, 1); @@ -1814,12 +1814,12 @@ if ($action == 'create') print $formfile->showdocuments('supplier_proposal', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang); - + // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, array('supplier_proposal')); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - + print '
'; // List of actions on element From d572bd4f34e6ab85718a035d0300ea48dfe53cef Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Jun 2017 10:45:20 +0200 Subject: [PATCH 06/85] FIX #7003 --- htdocs/projet/ganttchart.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/ganttchart.inc.php b/htdocs/projet/ganttchart.inc.php index f60ada41bb1..8ac203500b3 100644 --- a/htdocs/projet/ganttchart.inc.php +++ b/htdocs/projet/ganttchart.inc.php @@ -141,7 +141,7 @@ else function constructGanttLine($tarr,$task,$project_dependencies,$level=0,$project_id=null) { global $dateformatinput2; - + $start_date = $task["task_start_date"]; $end_date = $task["task_end_date"]; if (!$end_date) $end_date = $start_date; @@ -206,7 +206,7 @@ function constructGanttLine($tarr,$task,$project_dependencies,$level=0,$project_ $s = "\n// Add taks id=".$task["task_id"]." level = ".$level."\n"; // $s.= "g.AddTaskItem(new JSGantt.TaskItem(".$task['task_id'].",'".dol_escape_js($name)."','".$start_date."', '".$end_date."', '".$task['task_color']."', '".$link."', ".$task['task_milestone'].", '".$resources."', ".($percent >= 0 ? $percent : 0).", ".($task["task_is_group"]>0?1:0).", '".$parent."', 1, '".($depend?$depend:"")."', '".$note."'));"; // For JSGanttImproved - $s.= "g.AddTaskItem(new JSGantt.TaskItem(".$task['task_id'].",'".dol_escape_js(trim($name))."','".$start_date."', '".$end_date."', '".$task['task_css']."', '".$link."', ".$task['task_milestone'].", '".$resources."', ".($percent >= 0 ? $percent : 0).", ".($task["task_is_group"]).", '".$parent."', 1, '".($depend?$depend:$parent."SS")."', '".($percent >= 0 ? $percent.'%' : '0%')."','".$task['note']."'));"; + $s.= "g.AddTaskItem(new JSGantt.TaskItem(".$task['task_id'].",'".dol_escape_js(trim($name))."','".$start_date."', '".$end_date."', '".$task['task_css']."', '".$link."', ".$task['task_milestone'].", '".$resources."', ".($percent >= 0 ? $percent : 0).", ".($task["task_is_group"]).", '".$parent."', 1, '".($depend?$depend:$parent."SS")."', '".($percent >= 0 ? $percent.'%' : '0%')."','".dol_escape_js($task['note'])."'));"; echo $s; From 3ec0e6f7efc965da8991a17541e20e1c28cf6b0d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Jun 2017 12:31:08 +0200 Subject: [PATCH 07/85] FIX #6885 --- htdocs/core/ajax/ajaxdirpreview.php | 16 ++----- htdocs/core/class/html.formfile.class.php | 56 +++++++++++------------ 2 files changed, 33 insertions(+), 39 deletions(-) diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index bbc7647c802..f6077bf6261 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -162,21 +162,13 @@ if ($type == 'directory') // Auto area for suppliers invoices else if ($module == 'invoice') $upload_dir = $conf->facture->dir_output; // Auto area for suppliers invoices - else if ($module == 'invoice_supplier') - { - $relativepath='facture'; - $upload_dir = $conf->fournisseur->dir_output.'/'.$relativepath; - } + else if ($module == 'invoice_supplier') $upload_dir = $conf->fournisseur->facture->dir_output; // Auto area for customers orders else if ($module == 'propal') $upload_dir = $conf->propal->dir_output; // Auto area for customers orders else if ($module == 'order') $upload_dir = $conf->commande->dir_output; // Auto area for suppliers orders - else if ($module == 'order_supplier') - { - $relativepath='commande'; - $upload_dir = $conf->fournisseur->dir_output.'/'.$relativepath; - } + else if ($module == 'order_supplier') $upload_dir = $conf->fournisseur->commande->dir_output; // Auto area for suppliers invoices else if ($module == 'contract') $upload_dir = $conf->contrat->dir_output; // Auto area for products @@ -197,10 +189,12 @@ if ($type == 'directory') $param.='&module='.$module; $textifempty=($section?$langs->trans("NoFileFound"):($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("NoFileFound"))); + if ($module == 'company') $excludefiles[]='^contact$'; // The subdir 'contact' contains files of contacts with no id of thirdparty. + $filearray=dol_dir_list($upload_dir,"files",1,'', $excludefiles, $sortfield, $sorting,1); $formfile->list_of_autoecmfiles($upload_dir,$filearray,$module,$param,1,'',$user->rights->ecm->upload,1,$textifempty,$maxlengthname,$url); } - //Manual area + // Manual area else { $relativepath=$ecmdir->getRelativePath(); diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 6e46efe3fdf..05c5982dc00 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -331,11 +331,11 @@ class FormFile jQuery(\'#togglemassfilesarea\').text("('.dol_escape_js($langs->trans("Hide")).')"); } return false; - }); + }); }); '; - } - + } + $titletoshow=$langs->trans("Documents"); if (! empty($title)) $titletoshow=$title; @@ -556,7 +556,7 @@ class FormFile if (empty($noform)) $out.= '
'; $out.= ''; $out.= ''; - + $out.= load_fiche_titre($titletoshow, '', ''); $out.= ''; @@ -644,9 +644,9 @@ class FormFile $sortfield = $sortorder = null; $res = $link->fetchAll($link_list, $object->element, $object->id, $sortfield, $sortorder); } - + $out.= ''."\n"; - + // Show title of array if not already shown if ((! empty($file_list) || ! empty($link_list) || preg_match('/^massfilesarea/', $modulepart)) && ! $headershown) { @@ -671,7 +671,7 @@ class FormFile $documenturl = DOL_URL_ROOT.'/document.php'; if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) $documenturl=$conf->global->DOL_URL_ROOT_DOCUMENT_PHP; - + // Show file name with link to download $out.= ''; @@ -799,7 +799,7 @@ class FormFile $this->infofiles=array('nboffiles'=>0,'extensions'=>array(),'files'=>array()); if (! empty($conf->dol_use_jmobile)) return ''; - + $file_list=dol_dir_list($filedir, 'files', 0, preg_quote(basename($modulesubdir),'/').'[^\-]+', '\.meta$|\.png$'); // Get list of files starting with name of ref (but not followed by "-" to discard uploaded files) // For ajax treatment @@ -919,7 +919,7 @@ class FormFile if ($user->rights->service->creer && $object->type == Product::TYPE_SERVICE) $permtoeditline=1; } } - if (empty($conf->global->MAIN_UPLOAD_DOC)) + if (empty($conf->global->MAIN_UPLOAD_DOC)) { $permtoeditline=0; $permonobject=0; @@ -928,7 +928,7 @@ class FormFile // Show list of existing files if (empty($useinecm)) print load_fiche_titre($title?$title:$langs->trans("AttachedFiles")); if (empty($url)) $url=$_SERVER["PHP_SELF"]; - + print ''."\n"; if (GETPOST('action') == 'editfile' && $permtoeditline) { @@ -938,7 +938,7 @@ class FormFile print ''; } print '
'; $out.= '"; $out.=''; $out.=''; @@ -756,7 +756,7 @@ class FormFile } $this->numoffiles++; } - + if (count($file_list) == 0 && count($link_list) == 0 && $headershown) { $out.='
'.$langs->trans("None").'
'."\n"; - + print ''; print_liste_field_titre($langs->trans("Documents2"),$url,"name","",$param,'align="left"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Size"),$url,"size","",$param,'align="right"',$sortfield,$sortorder); @@ -971,13 +971,13 @@ class FormFile $relativepath=preg_replace('/^.*\/produit\//','',$file['path']).'/'; } $var=!$var; - + $editline=0; - + print ''."\n"; print ''; print '"; @@ -1103,7 +1103,7 @@ class FormFile { print ''; } - + return $nboffiles; } } @@ -1489,11 +1489,11 @@ class FormFile return $nboflinks; } - - + + /** * Show detail icon with link for preview - * + * * @param array $file File * @param string $modulepart propal, facture, facture_fourn, ... * @param string $relativepath Relative path of docs From ce8a024d4484c5f42d141e5889f6d62b0eebf51e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 21 Jun 2017 00:34:56 +0200 Subject: [PATCH 08/85] Fix limit on margin pages --- htdocs/margin/agentMargins.php | 22 ++++++++++++---------- htdocs/margin/customerMargins.php | 18 ++++++++++++------ htdocs/margin/productMargins.php | 28 ++++++++++++++-------------- 3 files changed, 38 insertions(+), 30 deletions(-) diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index f474b7af340..e00eb4ae18b 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -44,8 +44,15 @@ if ($user->rights->margins->read->all) { $mesg = ''; -$sortfield = GETPOST("sortfield",'alpha'); -$sortorder = GETPOST("sortorder",'alpha'); +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; if (! $sortorder) $sortorder="ASC"; if (! $sortfield) { @@ -54,11 +61,6 @@ if (! $sortfield) else $sortfield="u.lastname"; } -$page = GETPOST("page",'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $conf->liste_limit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; $startdate=$enddate=''; @@ -170,13 +172,13 @@ if ($result) $num = $db->num_rows($result); print '
'; - print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',$num,$num,''); + print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num, $num, '', 0, '', '', 0, 1); if ($conf->global->MARGIN_TYPE == "1") $labelcostprice=$langs->trans('BuyingPrice'); else // value is 'costprice' or 'pmp' $labelcostprice=$langs->trans('CostPrice'); - + $i = 0; print "
'; - + //print "XX".$file['name']; //$file['name'] must be utf8 print '\n"; @@ -1038,7 +1038,7 @@ class FormFile // Delete or view link // ($param must start with &) print ''; - if ($useinecm) + if ($useinecm) { print ''.img_view('default', 0, 'class="paddingrightonly"').''; } @@ -1046,10 +1046,10 @@ class FormFile { $newmodulepart=$modulepart; if (in_array($modulepart, array('product','produit','service'))) $newmodulepart='produit|service'; - - $disablecrop=1; + + $disablecrop=1; if (in_array($modulepart, array('product','produit','service','holiday','project'))) $disablecrop=0; - + if (! $disablecrop && image_format_supported($file['name']) > 0) { if ($permtoeditline) @@ -1058,7 +1058,7 @@ class FormFile print ''.img_picto($langs->trans("Resize"),DOL_URL_ROOT.'/theme/common/transform-crop-and-resize','class="paddingrightonly"',1).''; } } - + if ($permtoeditline) { print ''.img_edit('default',0,'class="paddingrightonly"').''; @@ -1076,7 +1076,7 @@ class FormFile if (! empty($conf->dol_use_jmobile)) $useajax=0; if (empty($conf->use_javascript_ajax)) $useajax=0; if (! empty($conf->global->MAIN_ECM_DISABLE_JS)) $useajax=0; - + print ''.img_delete().''; } print "
"; @@ -220,7 +222,7 @@ if ($result) $markRate = ($pv != 0)?(100 * $marge / $pv):'' ; } - + print ''; if ($agentid > 0) { diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index 64b0dd82ff2..ed76cde223c 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -41,11 +41,17 @@ $result = restrictedArea($user, 'societe','',''); $mesg = ''; -$page = GETPOST("page",'int'); +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $conf->liste_limit * $page; +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; +if (! $sortfield) $sortfield="s.nom"; // Set here default search field +if (! $sortorder) $sortorder="ASC"; $startdate=$enddate=''; @@ -206,13 +212,13 @@ if ($result) $num = $db->num_rows($result); print '
'; - print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',$num,$num,''); + print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num, $num, '', 0, '', '', 0, 1); if ($conf->global->MARGIN_TYPE == "1") $labelcostprice=$langs->trans('BuyingPrice'); else // value is 'costprice' or 'pmp' $labelcostprice=$langs->trans('CostPrice'); - + $i = 0; print "
"; @@ -260,7 +266,7 @@ if ($result) $markRate = ($pv != 0)?(100 * $marge / $pv):'' ; } - + print ''; if ($client) { @@ -295,7 +301,7 @@ if ($result) } // affichage totaux marges - + $totalMargin = $cumul_vente - $cumul_achat; /*if ($totalMargin < 0) { diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index f1ed5afe573..43a9ef0f22e 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -46,9 +46,15 @@ $result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','', $mesg = ''; -$sortfield = GETPOST("sortfield",'alpha'); -$sortorder = GETPOST("sortorder",'alpha'); -if (! $sortorder) $sortorder="ASC"; +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; if (! $sortfield) { if ($id > 0) @@ -63,12 +69,6 @@ if (! $sortfield) } } -$page = GETPOST("page",'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $conf->liste_limit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; - $startdate=$enddate=''; if (!empty($_POST['startdatemonth'])) @@ -202,16 +202,16 @@ if ($result) $num = $db->num_rows($result); print '
'; - print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&id=".$id,$sortfield,$sortorder,'',$num,$num,''); + print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], "&id=".$id, $sortfield, $sortorder, '', $num, $num, '', 0, '', '', 0, 1); //var_dump($conf->global->MARGIN_TYPE); if ($conf->global->MARGIN_TYPE == "1") $labelcostprice=$langs->trans('BuyingPrice'); else // value is 'costprice' or 'pmp' $labelcostprice=$langs->trans('CostPrice'); - + $moreforfilter=''; - + $i = 0; print '
'; print '
'."\n"; @@ -260,7 +260,7 @@ if ($result) $markRate = ($pv != 0)?(100 * $marge / $pv):'' ; } - + print ''; if ($id > 0) { @@ -308,7 +308,7 @@ if ($result) } // affichage totaux marges - + $totalMargin = $cumul_vente - $cumul_achat; $marginRate = ($cumul_achat != 0)?(100 * $totalMargin / $cumul_achat):''; From 9ec792975396b708dd1e90fd535bcae94df26a9e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 21 Jun 2017 10:57:15 +0200 Subject: [PATCH 09/85] Look and feel v6 --- htdocs/margin/agentMargins.php | 25 +++- htdocs/margin/checkMargins.php | 237 +++++++++++++++--------------- htdocs/margin/customerMargins.php | 1 + htdocs/margin/productMargins.php | 1 + htdocs/theme/eldy/style.css.php | 5 +- htdocs/theme/md/style.css.php | 5 +- 6 files changed, 143 insertions(+), 131 deletions(-) diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index e00eb4ae18b..6c3a246ad0d 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -34,14 +34,6 @@ $langs->load("bills"); $langs->load("products"); $langs->load("margins"); -// Security check - -if ($user->rights->margins->read->all) { - $agentid = GETPOST('agentid', 'int'); -} else { - $agentid = $user->id; -} - $mesg = ''; // Load variable for pagination @@ -69,6 +61,23 @@ if (!empty($_POST['startdatemonth'])) if (!empty($_POST['enddatemonth'])) $enddate = dol_mktime(23, 59, 59, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear']); +// Security check +if ($user->rights->margins->read->all) { + $agentid = GETPOST('agentid', 'int'); +} else { + $agentid = $user->id; +} +$result=restrictedArea($user,'margins'); + + +/* + * Actions + */ + +// None + + + /* * View */ diff --git a/htdocs/margin/checkMargins.php b/htdocs/margin/checkMargins.php index c576b3ce4a6..ab6394eb74c 100644 --- a/htdocs/margin/checkMargins.php +++ b/htdocs/margin/checkMargins.php @@ -34,72 +34,35 @@ $langs->load("bills"); $langs->load("products"); $langs->load("margins"); -// Security check - -if ($user->rights->margins->creer) { - $agentid = $user->id; -} else { - accessforbidden(); -} - -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); -if (! $sortorder) - $sortorder = "DESC"; -if (! $sortfield) { - $sortfield = 'f.facnumber'; -} -$page = GETPOST("page", 'int'); -if ($page == - 1) { - $page = 0; -} -$offset = $conf->liste_limit * $page; +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; - -// Both test are required to be compatible with all browsers -if (GETPOST("button_search_x") || GETPOST("button_search")) { - $action = 'search'; -} elseif (GETPOST("button_updatemagins_x") || GETPOST("button_updatemagins")) { - $action = 'update'; -} - -if ($action == 'update') { - $datapost = $_POST; - - foreach ( $datapost as $key => $value ) { - if (strpos($key, 'buyingprice_') !== false) { - $tmp_array = explode('_', $key); - if (count($tmp_array) > 0) { - $invoicedet_id = $tmp_array[1]; - if (! empty($invoicedet_id)) { - $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facturedet'; - $sql .= ' SET buy_price_ht=\'' . price2num($value) . '\''; - $sql .= ' WHERE rowid=' . $invoicedet_id; - $result = $db->query($sql); - if (!$result) { - setEventMessages($db->lasterror, null, 'errors'); - } - } - } - } - } -} +if (! $sortorder) $sortorder = "DESC"; +if (! $sortfield) $sortfield = 'f.facnumber'; $startdate = $enddate = ''; $startdate = dol_mktime(0, 0, 0, GETPOST('startdatemonth', 'int'), GETPOST('startdateday', 'int'), GETPOST('startdateyear', 'int')); $enddate = dol_mktime(23, 59, 59, GETPOST('enddatemonth', 'int'), GETPOST('enddateday', 'int'), GETPOST('enddateyear', 'int')); -if (! empty($startdate)) { - $options .= '&startdatemonth=' . GETPOST('startdatemonth', 'int') . '&startdateday=' . GETPOST('startdateday', 'int') . '&startdateyear=' . GETPOST('startdateyear', 'int'); -} -if (! empty($enddate)) { - $options .= '&enddatemonth=' . GETPOST('enddatemonth', 'int') . '&enddateday=' . GETPOST('enddateday', 'int') . '&enddateyear=' . GETPOST('enddateyear', 'int'); -} - $search_ref = GETPOST('search_ref','alpha'); +// Security check +$result=restrictedArea($user,'margins'); + +// Both test are required to be compatible with all browsers +if (GETPOST("button_search_x") || GETPOST("button_search")) { + $action = 'search'; +} elseif (GETPOST("button_updatemagins_x") || GETPOST("button_updatemagins")) { + $action = 'update'; +} + /* * Actions @@ -117,6 +80,28 @@ if (empty($reshook)) // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + if ($action == 'update') { + $datapost = $_POST; + + foreach ( $datapost as $key => $value ) { + if (strpos($key, 'buyingprice_') !== false) { + $tmp_array = explode('_', $key); + if (count($tmp_array) > 0) { + $invoicedet_id = $tmp_array[1]; + if (! empty($invoicedet_id)) { + $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facturedet'; + $sql .= ' SET buy_price_ht=\'' . price2num($value) . '\''; + $sql .= ' WHERE rowid=' . $invoicedet_id; + $result = $db->query($sql); + if (!$result) { + setEventMessages($db->lasterror, null, 'errors'); + } + } + } + } + } + } + // Purge search criteria if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers { @@ -155,6 +140,17 @@ llxHeader('', $title); // print_fiche_titre($text); +$param=''; +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; +if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; +if (! empty($startdate)) { + $param .= '&startdatemonth=' . GETPOST('startdatemonth', 'int') . '&startdateday=' . GETPOST('startdateday', 'int') . '&startdateyear=' . GETPOST('startdateyear', 'int'); +} +if (! empty($enddate)) { + $param .= '&enddatemonth=' . GETPOST('enddatemonth', 'int') . '&enddateday=' . GETPOST('enddateday', 'int') . '&enddateyear=' . GETPOST('enddateyear', 'int'); +} +if ($optioncss != '') $param.='&optioncss='.$optioncss; + // Show tabs $head = marges_prepare_head($user); $picto = 'margin'; @@ -202,7 +198,7 @@ $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - + dol_syslog(__FILE__, LOG_DEBUG); $result = $db->query($sql); if ($result) { @@ -212,31 +208,30 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { } } -$sql .= $db->plimit($conf->liste_limit + 1, $offset); +$sql .= $db->plimit($limit+1, $offset); -dol_syslog(__FILE__, LOG_DEBUG); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); - + print '
'; - print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num, $nbtotalofrecords, ''); - + print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '', 0, '', '', $limit); + if ($conf->global->MARGIN_TYPE == "1") $labelcostprice=$langs->trans('BuyingPrice'); else // value is 'costprice' or 'pmp' $labelcostprice=$langs->trans('CostPrice'); - + $moreforfilter=''; - + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; //$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields //if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); $selectedfields=''; - + print '
'; print '
'."\n"; - + print ''; print ''; print ''; @@ -249,66 +244,66 @@ if ($result) { print $searchpitco; print ''; print "\n"; - + print ''; - print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "f.facnumber", "", $options, '', $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "", "", $options, 'width=20%', $sortfield, $sortorder); - print_liste_field_titre($langs->trans("UnitPriceHT"), $_SERVER["PHP_SELF"], "d.subprice", "", $options, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "d.buy_price_ht", "", $options, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Qty"), $_SERVER["PHP_SELF"], "d.qty", "", $options, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre($langs->trans("AmountTTC"), $_SERVER["PHP_SELF"], "d.total_ht", "", $options, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); + print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "f.facnumber", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "", "", $param, 'width=20%', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("UnitPriceHT"), $_SERVER["PHP_SELF"], "d.subprice", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "d.buy_price_ht", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Qty"), $_SERVER["PHP_SELF"], "d.qty", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("AmountTTC"), $_SERVER["PHP_SELF"], "d.total_ht", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'',$param,'align="center"',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; - - if ($num > 0) { - while ($objp = $db->fetch_object($result)) - { - $var = ! $var; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print "\n"; - - $i ++; + + $i=0; + while ($i < min($num, $limit)) + { + $objp = $db->fetch_object($result); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print "\n"; + + $i ++; } + print "
'; - $result_inner = $invoicestatic->fetch($objp->invoiceid); - if ($result_inner < 0) { - setEventMessages($invoicestatic->error, null, 'errors'); - } else { - print $invoicestatic->getNomUrl(1); - } - print ''; - if (! empty($objp->fk_product)) { - $result_inner = $productstatic->fetch($objp->fk_product); - if ($result_inner < 0) { - setEventMessages($productstatic->error, null, 'errors'); - } else { - print $productstatic->getNomUrl(1); - } - } else { - print $objp->label; - print ' '; - print $objp->description; - } - print ''; - print price($objp->subprice); - print ''; - print ''; - print ''; - print $objp->qty; - print ''; - print price($objp->total_ht); - print '
'; + $result_inner = $invoicestatic->fetch($objp->invoiceid); + if ($result_inner < 0) { + setEventMessages($invoicestatic->error, null, 'errors'); + } else { + print $invoicestatic->getNomUrl(1); } + print ''; + if (! empty($objp->fk_product)) { + $result_inner = $productstatic->fetch($objp->fk_product); + if ($result_inner < 0) { + setEventMessages($productstatic->error, null, 'errors'); + } else { + print $productstatic->getNomUrl(1); + } + } else { + print $objp->label; + print ' '; + print $objp->description; + } + print ''; + print price($objp->subprice); + print ''; + print ''; + print ''; + print $objp->qty; + print ''; + print price($objp->total_ht); + print '
"; - + print "
"; } else { dol_print_error($db); diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index ed76cde223c..643fdcb4704 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -37,6 +37,7 @@ $langs->load("margins"); $socid = GETPOST('socid','int'); if (! empty($user->societe_id)) $socid=$user->societe_id; $result = restrictedArea($user, 'societe','',''); +$result = restrictedArea($user,'margins'); $mesg = ''; diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index 43a9ef0f22e..77f7e23c84f 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -43,6 +43,7 @@ $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); $fieldtype = (! empty($ref) ? 'ref' : 'rowid'); if (! empty($user->societe_id)) $socid=$user->societe_id; $result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype); +$result=restrictedArea($user,'margins'); $mesg = ''; diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index c3bfa8b05cb..3f05f66c82b 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -4043,12 +4043,15 @@ a span.select2-chosen .css-searchselectcombo ul.select2-results { max-height: none; } -.select2-container-multi.select2-container-disabled .select2-choices { +.select2-container.select2-container-disabled .select2-choice, .select2-container-multi.select2-container-disabled .select2-choices { background-color: #FFFFFF; background-image: none; border: none; cursor: default; } +.select2-container-disabled .select2-choice .select2-arrow b { + opacity: 0.5; +} .select2-container-multi .select2-choices .select2-search-choice { margin-bottom: 3px; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index e96fa032538..802eb46f6af 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -4128,12 +4128,15 @@ a span.select2-chosen .css-searchselectcombo ul.select2-results { max-height: none; } -.select2-container-multi.select2-container-disabled .select2-choices { +.select2-container.select2-container-disabled .select2-choice, .select2-container-multi.select2-container-disabled .select2-choices { background-color: #FFFFFF; background-image: none; border: none; cursor: default; } +.select2-container-disabled .select2-choice .select2-arrow b { + opacity: 0.5; +} .select2-container-multi .select2-choices .select2-search-choice { margin-bottom: 3px; } From 4102403482156add2e1342d7d8b02f8604678b6e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 21 Jun 2017 11:37:34 +0200 Subject: [PATCH 10/85] Look and feel v6 --- htdocs/categories/card.php | 11 +++++------ htdocs/comm/propal/card.php | 2 +- htdocs/commande/card.php | 2 +- htdocs/core/class/html.form.class.php | 4 ++-- htdocs/core/lib/ajax.lib.php | 20 ++++++++++---------- htdocs/core/lib/functions.lib.php | 4 ++-- htdocs/fichinter/card.php | 2 +- htdocs/fourn/commande/card.php | 2 +- htdocs/fourn/facture/card.php | 2 +- htdocs/product/card.php | 4 +++- htdocs/product/stock/card.php | 4 +++- htdocs/societe/ajax/company.php | 5 +++-- htdocs/supplier_proposal/card.php | 2 +- htdocs/theme/eldy/style.css.php | 2 +- 14 files changed, 35 insertions(+), 31 deletions(-) diff --git a/htdocs/categories/card.php b/htdocs/categories/card.php index 55bf400ea3a..9f49e42f060 100644 --- a/htdocs/categories/card.php +++ b/htdocs/categories/card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2006-2015 Laurent Destailleur + * Copyright (C) 2006-2017 Laurent Destailleur * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2007 Patrick Raguin * Copyright (C) 2013 Florian Henry @@ -221,9 +221,7 @@ llxHeader("",$langs->trans("Categories"),$helpurl); if ($user->rights->categorie->creer) { - /* - * Fiche en mode creation - */ + // Create or add if ($action == 'create' || $_POST["addcat"] == 'addcat') { dol_set_focus('#label'); @@ -246,7 +244,7 @@ if ($user->rights->categorie->creer) // Ref print ''; - print ''.$langs->trans("Ref").''; + print ''.$langs->trans("Ref").''; print''; // Description @@ -263,7 +261,8 @@ if ($user->rights->categorie->creer) // Parent category print ''.$langs->trans("AddIn").''; - print $form->select_all_categories($type, $catorigin); + print $form->select_all_categories($type, $catorigin, 'parent'); + print ajax_combobox('parent'); print ''; $parameters=array(); diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 67dbca101f8..0c9d97fc299 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1360,7 +1360,7 @@ if ($action == 'create') } } else { print ''; - print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1', 'SelectThirdParty'); + print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); // reload page to retrieve customer informations if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE)) { diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index f837119730c..a10de641ea1 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1477,7 +1477,7 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; } else { print ''; - print $form->select_company('', 'socid', 's.client = 1 OR s.client = 3', 'SelectThirdParty'); + print $form->select_company('', 'socid', 's.client = 1 OR s.client = 3', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); // reload page to retrieve customer informations if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE)) { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 7c8efcc8328..1a19d0da776 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -995,7 +995,7 @@ class Form unset($societetmp); } // mode 1 - $urloption='htmlname='.$htmlname.'&outjson=1&filter='.$filter; + $urloption='htmlname='.$htmlname.'&outjson=1&filter='.$filter.($showtype?'&showtype='.$showtype:''); $out.= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/societe/ajax/company.php', $urloption, $conf->global->COMPANY_USE_SEARCH_TO_SELECT, 0, $ajaxoptions); $out.='