From 17f28189f9a1a77a2f38d19589e1f53fc8618847 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 24 Jan 2020 14:51:45 +0100 Subject: [PATCH 01/19] Virtual stock must include Manufacturing Orders --- htdocs/langs/en_US/mrp.lang | 2 + htdocs/product/class/product.class.php | 95 +++++++++++++++++++++++++- htdocs/product/stock/product.php | 8 +++ 3 files changed, 103 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang index e4034426e9a..11c6915a25c 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -64,3 +64,5 @@ ConfirmProductionDesc=By clicking on '%s', you will validate the consumption and ProductionForRef=Production of %s AutoCloseMO=Close automatically the Manufacturing Order if quantities to consume and to produce are reached NoStockChangeOnServices=No stock change on services +ProductQtyToConsumeByMO=Product quantity still to consume by open MO +ProductQtyToProduceByMO=Product quentity still to produce by open MO diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 3e92772738f..5eb8ab904cc 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -318,6 +318,9 @@ class Product extends CommonObject public $stats_contrat = array(); public $stats_facture = array(); public $stats_commande_fournisseur = array(); + public $stats_reception = array(); + public $stats_mrptoconsume = array(); + public $stats_mrptoproduce = array(); public $multilangs = array(); @@ -2806,6 +2809,93 @@ class Product extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Charge tableau des stats commande client pour le produit/service + * + * @param int $socid Id societe pour filtrer sur une societe + * @param string $filtrestatut Id statut pour filtrer sur un statut + * @param int $forVirtualStock Ignore rights filter for virtual stock calculation. + * @return integer Array of stats in $this->stats_commande (nb=nb of order, qty=qty ordered), <0 if ko or >0 if ok + */ + public function load_stats_inproduction($socid = 0, $filtrestatut = '', $forVirtualStock = 0) + { + // phpcs:enable + global $conf, $user; + + $sql = "SELECT COUNT(DISTINCT m.fk_soc) as nb_customers, COUNT(DISTINCT m.rowid) as nb,"; + $sql .= " COUNT(mp.rowid) as nb_rows, SUM(mp.qty) as qty, role"; + $sql .= " FROM ".MAIN_DB_PREFIX."mrp_production as mp"; + $sql .= ", ".MAIN_DB_PREFIX."mrp_mo as m"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = m.fk_soc"; + if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } + $sql .= " WHERE m.rowid = mp.fk_mo"; + $sql .= " AND m.entity IN (".getEntity('mrp').")"; + $sql .= " AND mp.fk_product = ".$this->id; + if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) { + $sql .= " AND m.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; + } + if ($socid > 0) { + $sql .= " AND m.fk_soc = ".$socid; + } + if ($filtrestatut <> '') { + $sql .= " AND m.status in (".$filtrestatut.")"; + } + $sql .= " GROUP BY role"; + + $this->stats_mrptoconsume['customers'] = 0; + $this->stats_mrptoconsume['nb'] = 0; + $this->stats_mrptoconsume['rows'] = 0; + $this->stats_mrptoconsume['qty'] = 0; + $this->stats_mrptoproduce['customers'] = 0; + $this->stats_mrptoproduce['nb'] = 0; + $this->stats_mrptoproduce['rows'] = 0; + $this->stats_mrptoproduce['qty'] = 0; + + $result = $this->db->query($sql); + if ($result) { + while ($obj = $this->db->fetch_object($result)) { + if ($obj->role == 'toconsume') { + $this->stats_mrptoconsume['customers'] += $obj->nb_customers; + $this->stats_mrptoconsume['nb'] += $obj->nb; + $this->stats_mrptoconsume['rows'] += $obj->nb_rows; + $this->stats_mrptoconsume['qty'] += ($obj->qty ? $obj->qty : 0); + } + if ($obj->role == 'consumed') { + //$this->stats_mrptoconsume['customers'] += $obj->nb_customers; + //$this->stats_mrptoconsume['nb'] += $obj->nb; + //$this->stats_mrptoconsume['rows'] += $obj->nb_rows; + $this->stats_mrptoconsume['qty'] -= ($obj->qty ? $obj->qty : 0); + } + if ($obj->role == 'toproduce') { + $this->stats_mrptoproduce['customers'] += $obj->nb_customers; + $this->stats_mrptoproduce['nb'] += $obj->nb; + $this->stats_mrptoproduce['rows'] += $obj->nb_rows; + $this->stats_mrptoproduce['qty'] += ($obj->qty ? $obj->qty : 0); + } + if ($obj->role == 'produced') { + //$this->stats_mrptoproduce['customers'] += $obj->nb_customers; + //$this->stats_mrptoproduce['nb'] += $obj->nb; + //$this->stats_mrptoproduce['rows'] += $obj->nb_rows; + $this->stats_mrptoproduce['qty'] -= ($obj->qty ? $obj->qty : 0); + } + } + + // Clean data + if ($this->stats_mrptoconsume['qty'] < 0) $this->stats_mrptoconsume['qty'] = 0; + if ($this->stats_mrptoproduce['qty'] < 0) $this->stats_mrptoproduce['qty'] = 0; + + return 1; + } + else + { + $this->error = $this->db->error(); + return -1; + } + } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge tableau des stats contrat pour le produit/service @@ -4717,8 +4807,9 @@ class Product extends CommonObject } if (!empty($conf->mrp->enabled)) { - // TODO - $stock_inproduction = 0; + $result = $this->load_stats_inproduction(0, '1,2', 1); + if ($result < 0) dol_print_error($this->db, $this->error); + $stock_inproduction = $this->stats_mrptoproduce['qty'] - $this->stats_mrptoconsume['qty']; } $this->stock_theorique = $this->stock_reel + $stock_inproduction; diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 889084aa4be..5929a46edb8 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -689,6 +689,14 @@ if ($id > 0 || $ref) $helpondiff .= $langs->trans("ProductQtyInSuppliersShipmentAlreadyRecevied").': '.$object->stats_reception['qty']; } + // Number of product in production + if (!empty($conf->mrp->enabled)) { + if ($found) $helpondiff .= '
'; else $found = 1; + $helpondiff .= $langs->trans("ProductQtyToConsumeByMO").': '.$object->stats_mrptoconsume['qty'].'
'; + $helpondiff .= $langs->trans("ProductQtyToProduceByMO").': '.$object->stats_mrptoproduce['qty']; + } + + // Calculating a theorical value print ''; print $form->textwithpicto($langs->trans("VirtualStock"), $langs->trans("VirtualStockDesc")); From 779cd94b0ec5598a84256fef5c2db094ea81d82b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 24 Jan 2020 15:26:18 +0100 Subject: [PATCH 02/19] Debug cashfence feature --- .../compta/cashcontrol/cashcontrol_card.php | 5 ++-- htdocs/compta/cashcontrol/report.php | 25 ++++++++++++++----- htdocs/core/class/html.formfile.class.php | 4 +-- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index 0a7e2fa2d17..d98142a30b3 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -551,7 +551,9 @@ if (empty($action) || $action == "view") print ''; print $langs->trans("Period"); print ''; - print $object->year_close."-".$object->month_close."-".$object->day_close; + print $object->year_close; + print ($object->month_close ? "-" : "").$object->month_close; + print ($object->day_close ? "-" : "").$object->day_close; print ''; print ''; @@ -570,7 +572,6 @@ if (empty($action) || $action == "view") print ''.$langs->trans("InitialBankBalance").' - '.$langs->trans("Cash").''; print price($object->opening, 0, $langs, 1, -1, -1, $conf->currency); print ""; - foreach ($arrayofpaymentmode as $key => $val) { print ''.$langs->trans($val).''; diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php index 2a2477fce5e..26023d47701 100644 --- a/htdocs/compta/cashcontrol/report.php +++ b/htdocs/compta/cashcontrol/report.php @@ -33,11 +33,11 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php'; $id = GETPOST('id', 'int'); $_GET['optioncss']="print"; -include_once 'class/cashcontrol.class.php'; $cashcontrol= new CashControl($db); $cashcontrol->fetch($id); @@ -243,12 +243,25 @@ if ($resql) print ""; - $cash=$cash+$cashcontrol->opening; + $cash = $cash + $cashcontrol->opening; print "

"; - print $langs->trans("Cash").": ".price($cash)."

"; - print $langs->trans("PaymentTypeCB").": ".price($bank)."

"; - print $langs->trans("PaymentTypeCHQ").": ".price($cheque)."

"; - if ($other) print $langs->trans("Other").": ".price($other)."

"; + print $langs->trans("Cash").": ".price($cash); + if ($cash != $object->cash) { + print ' <> '.$langs->trans("Declared").': '.price($cashcontrol->cash).''; + } + print "

"; + print '
'; + print $langs->trans("PaymentTypeCHQ").": ".price($cheque); + if ($cash != $object->cheque) { + print ' <> '.$langs->trans("Declared").': '.price($cashcontrol->cheque).''; + } + print "

"; + print '
'; + print $langs->trans("PaymentTypeCB").": ".price($bank); + print "

"; + if ($other) { + print '
'.$langs->trans("Other").": ".price($other)."

"; + } print "

"; //save totals to DB diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index c78fe06693b..a3d73b627b7 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1712,8 +1712,8 @@ class FormFile if (count($filearray) == 0) { print ''; - if (empty($textifempty)) print $langs->trans("NoFileFound"); - else print $textifempty; + if (empty($textifempty)) print ''.$langs->trans("NoFileFound").''; + else print ''.$textifempty.''; print ''; } print ""; From 923e315daef17669d0f388a29f7290c6e8d5f642 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 24 Jan 2020 15:59:36 +0100 Subject: [PATCH 03/19] Debug cashfence feature --- htdocs/compta/cashcontrol/report.php | 75 +++++++++++++++++++--------- 1 file changed, 52 insertions(+), 23 deletions(-) diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php index 26023d47701..e8aea86681c 100644 --- a/htdocs/compta/cashcontrol/report.php +++ b/htdocs/compta/cashcontrol/report.php @@ -35,6 +35,8 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php'; +$langs->load("bills"); + $id = GETPOST('id', 'int'); $_GET['optioncss']="print"; @@ -50,7 +52,8 @@ $arrayfields=array( 'b.dateo'=>array('label'=>$langs->trans("DateOperationShort"), 'checked'=>1), 'b.num_chq'=>array('label'=>$langs->trans("Number"), 'checked'=>1), 'ba.ref'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>1), - 'b.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1, 'position'=>600), + 'cp.code'=>array('label'=>$langs->trans("PaymentMode"), 'checked'=>1), + 'b.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1, 'position'=>600), 'b.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1, 'position'=>605), ); @@ -128,7 +131,6 @@ if ($resql) $invoicetmp = new Facture($db); - print "

"; print $langs->trans("InitialBankBalance").' - '.$langs->trans("Cash")." : ".price($cashcontrol->opening); print "

"; @@ -136,13 +138,16 @@ if ($resql) print '
'; print ''."\n"; + $param = ''; + // Fields title print ''; print_liste_field_titre($arrayfields['b.rowid']['label'], $_SERVER['PHP_SELF'], 'b.rowid', '', $param, '', $sortfield, $sortorder); - print_liste_field_titre($arrayfields['b.dateo']['label'], $_SERVER['PHP_SELF'], 'b.dateo', '', $param, 'class="left"', $sortfield, $sortorder); - print_liste_field_titre($arrayfields['ba.ref']['label'], $_SERVER['PHP_SELF'], 'ba.ref', '', $param, 'class="right"', $sortfield, $sortorder); - print_liste_field_titre($arrayfields['b.debit']['label'], $_SERVER['PHP_SELF'], 'b.amount', '', $param, 'class="right"', $sortfield, $sortorder); - print_liste_field_titre($arrayfields['b.credit']['label'], $_SERVER['PHP_SELF'], 'b.amount', '', $param, 'class="right"', $sortfield, $sortorder); + print_liste_field_titre($arrayfields['b.dateo']['label'], $_SERVER['PHP_SELF'], 'b.dateo', '', $param, '"', $sortfield, $sortorder, 'center '); + print_liste_field_titre($arrayfields['ba.ref']['label'], $_SERVER['PHP_SELF'], 'ba.ref', '', $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre($arrayfields['cp.code']['label'], $_SERVER['PHP_SELF'], 'cp.code', '', $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre($arrayfields['b.debit']['label'], $_SERVER['PHP_SELF'], 'b.amount', '', $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre($arrayfields['b.credit']['label'], $_SERVER['PHP_SELF'], 'b.amount', '', $param, '', $sortfield, $sortorder, 'right '); print "\n"; $posconciliatecol = 0; @@ -151,7 +156,9 @@ if ($resql) $sign = 1; $cash=$bank=$cheque=$other=0; - $totalarray=array(); + $totalarray = array(); + $cachebankaccount = array(); + $amountpertype = array(); while ($i < $num) { $objp = $db->fetch_object($resql); @@ -168,7 +175,9 @@ if ($resql) $bankaccount = $cachebankaccount[$objp->bankid]; } - /*if ($first == "yes") + $invoicetmp->fetch($objp->facid); + + /*if ($first == "yes") { print ''; print ''; @@ -181,12 +190,10 @@ if ($resql) // Ref print ''; if (! $i) $totalarray['nbfield']++; - // Date ope print '\n"; if (! $i) $totalarray['nbfield']++; - // Debit + // Type + print '\n"; + if (! $i) $totalarray['nbfield']++; + + // Debit print '\n"; if (! $i) $totalarray['nbfield']++; @@ -228,6 +247,7 @@ if ($resql) { print price($objp->amount); $totalarray['val']['totalcredfield'] += $objp->amount; + $amountpertype[$objp->code] -= $objp->amount; } print "\n"; if (! $i) $totalarray['nbfield']++; @@ -243,22 +263,31 @@ if ($resql) print "
'.$langs->trans("InitialBankBalance").' - '.$langs->trans("Cash").''; - $invoicetmp->fetch($objp->facid); print $invoicetmp->getNomUrl(1); print ''; print ''.dol_print_date($db->jdate($objp->do), "day").""; @@ -197,26 +204,38 @@ if ($resql) print ''; print $bankaccount->getNomUrl(1); if ($cashcontrol->posmodule=="takepos"){ - if ($conf->global->{'CASHDESK_ID_BANKACCOUNT_CASH'.$cashcontrol->posnumber}==$bankaccount->id) $cash+=$objp->amount; - elseif ($conf->global->{'CASHDESK_ID_BANKACCOUNT_CB'.$cashcontrol->posnumber}==$bankaccount->id) $bank+=$objp->amount; - elseif ($conf->global->{'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$cashcontrol->posnumber}==$bankaccount->id) $cheque+=$objp->amount; - else $other+=$objp->amount; + $var1 = 'CASHDESK_ID_BANKACCOUNT_CASH'.$cashcontrol->posnumber; } else{ - if ($conf->global->CASHDESK_ID_BANKACCOUNT_CASH==$bankaccount->id) $cash+=$objp->amount; - elseif ($conf->global->CASHDESK_ID_BANKACCOUNT_CB==$bankaccount->id) $bank+=$objp->amount; - elseif ($conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE==$bankaccount->id) $cheque+=$objp->amount; - else $other+=$objp->amount; + $var1 = 'CASHDESK_ID_BANKACCOUNT_CASH'; + } + if ($objp->code == 'CHQ') { + $cheque += $objp->amount; + } elseif ($objp->code == 'CB') { + $bank += $objp->amount; + } else { + if ($conf->global->$var1 == $bankaccount->id) $cash += $objp->amount; + //elseif ($conf->global->$var2 == $bankaccount->id) $bank+=$objp->amount; + //elseif ($conf->global->$var3 == $bankaccount->id) $cheque+=$objp->amount; + else $other += $objp->amount; } print "'; + print $objp->code; + if (empty($amountpertype[$objp->code])) $amountpertype[$objp->code] = 0; + print "'; if ($objp->amount < 0) { print price($objp->amount * -1); $totalarray['val']['totaldebfield'] += $objp->amount; + $amountpertype[$objp->code] += $objp->amount; } print "
"; + //$cash = $amountpertype['LIQ'] + $cashcontrol->opening; $cash = $cash + $cashcontrol->opening; + print "

"; print $langs->trans("Cash").": ".price($cash); - if ($cash != $object->cash) { + if ($cash != $cashcontrol->cash) { print ' <> '.$langs->trans("Declared").': '.price($cashcontrol->cash).''; } print "

"; - print '
'; + + //print '
'; print $langs->trans("PaymentTypeCHQ").": ".price($cheque); - if ($cash != $object->cheque) { + if ($cheque != $cashcontrol->cheque) { print ' <> '.$langs->trans("Declared").': '.price($cashcontrol->cheque).''; } print "

"; - print '
'; + + //print '
'; print $langs->trans("PaymentTypeCB").": ".price($bank); + if ($bank != $cashcontrol->card) { + print ' <> '.$langs->trans("Declared").': '.price($cashcontrol->card).''; + } print "

"; + + // print '
'; if ($other) { print '
'.$langs->trans("Other").": ".price($other)."

"; } From 209ebfbe2f7ecefac26288434d5a875fe3f23ae1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 24 Jan 2020 16:14:52 +0100 Subject: [PATCH 04/19] Fix trans --- htdocs/compta/cashcontrol/cashcontrol_card.php | 2 +- htdocs/compta/cashcontrol/class/cashcontrol.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index d98142a30b3..7958d107ec8 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -544,7 +544,7 @@ if (empty($action) || $action == "view") print $object->posmodule; print ""; - print ''.$langs->trans("CashDesk").' ID'; + print ''.$langs->trans("Terminal").''; print $object->posnumber; print ""; diff --git a/htdocs/compta/cashcontrol/class/cashcontrol.class.php b/htdocs/compta/cashcontrol/class/cashcontrol.class.php index ad792db0826..32f7533b6c3 100644 --- a/htdocs/compta/cashcontrol/class/cashcontrol.class.php +++ b/htdocs/compta/cashcontrol/class/cashcontrol.class.php @@ -59,7 +59,7 @@ class CashControl extends CommonObject 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>15), 'ref' =>array('type'=>'varchar(64)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>18), 'posmodule' =>array('type'=>'varchar(30)', 'label'=>'Module', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>19), - 'posnumber' =>array('type'=>'varchar(30)', 'label'=>'CashDesk', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>20), + 'posnumber' =>array('type'=>'varchar(30)', 'label'=>'Terminal', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>20, 'css'=>'center'), 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>0, 'position'=>24), 'opening' =>array('type'=>'price', 'label'=>'Opening', 'enabled'=>1, 'visible'=>1, 'position'=>25), 'cash' =>array('type'=>'price', 'label'=>'Cash', 'enabled'=>1, 'visible'=>1, 'position'=>30), From de4183ea6552e917ac33f8416f784340966f2a8d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 24 Jan 2020 17:30:46 +0100 Subject: [PATCH 05/19] Update logos --- htdocs/core/lib/security2.lib.php | 2 +- htdocs/langs/en_US/other.lang | 2 +- htdocs/main.inc.php | 2 +- htdocs/public/payment/newpayment.php | 61 +++++++++++------- htdocs/theme/common/dolibarr_logo_bw.png | Bin 791 -> 0 bytes .../{common => }/dolibarr_logo_256x256.png | Bin htdocs/theme/dolibarr_logo_bw.png | Bin 0 -> 646 bytes htdocs/theme/eldy/global.inc.php | 11 ++++ htdocs/theme/eldy/manifest.json.php | 2 +- 9 files changed, 51 insertions(+), 29 deletions(-) delete mode 100644 htdocs/theme/common/dolibarr_logo_bw.png rename htdocs/theme/{common => }/dolibarr_logo_256x256.png (100%) create mode 100644 htdocs/theme/dolibarr_logo_bw.png diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index c81ea9d98d7..26e97499482 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -283,7 +283,7 @@ if (! function_exists('dol_loginfunction')) // Set jquery theme $dol_loginmesg = (! empty($_SESSION["dol_loginmesg"])?$_SESSION["dol_loginmesg"]:''); - $favicon = DOL_URL_ROOT.'/theme/common/dolibarr_logo_256x256.png'; + $favicon = DOL_URL_ROOT.'/theme/dolibarr_logo_256x256.png'; if (! empty($mysoc->logo_squarred_mini)) $favicon = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_squarred_mini); if (! empty($conf->global->MAIN_FAVICON_URL)) $favicon=$conf->global->MAIN_FAVICON_URL; diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index 640199588ab..46424590f31 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -24,7 +24,7 @@ MessageOK=Message on the return page for a validated payment MessageKO=Message on the return page for a canceled payment ContentOfDirectoryIsNotEmpty=Content of this directory is not empty. DeleteAlsoContentRecursively=Check to delete all content recursively - +PoweredBy=Powered by YearOfInvoice=Year of invoice date PreviousYearOfInvoice=Previous year of invoice date NextYearOfInvoice=Following year of invoice date diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index c9def11e910..a6de7819237 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1224,7 +1224,7 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr print ''."\n"; // Favicon - $favicon = DOL_URL_ROOT.'/theme/common/dolibarr_logo_256x256.png'; + $favicon = DOL_URL_ROOT.'/theme/dolibarr_logo_256x256.png'; if (!empty($mysoc->logo_squarred_mini)) $favicon = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_squarred_mini); if (!empty($conf->global->MAIN_FAVICON_URL)) $favicon = $conf->global->MAIN_FAVICON_URL; if (empty($conf->dol_use_jmobile)) print ''."\n"; // Not required into an Android webview diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index c580fa2a6d3..80ed910ac70 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -717,7 +717,8 @@ if (!empty($conf->global->ONLINE_PAYMENT_CSS_URL)) $head = 'dol_hide_leftmenu) ? '
' : '').'
'; +llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea); // Check link validity if ($source && in_array($ref, array('member_ref', 'contractline_ref', 'invoice_ref', 'order_ref', ''))) @@ -753,27 +754,7 @@ print ''; print ''; print "\n"; -print ''."\n"; -print ''."\n"; -// Additionnal information for each payment system -if (!empty($conf->paypal->enabled)) -{ - print ''."\n"; - print ''."\n"; -} -if (!empty($conf->paybox->enabled)) -{ - print ''."\n"; -} -if (!empty($conf->stripe->enabled)) -{ - print ''."\n"; -} -print ''."\n"; -print ''."\n"; -print "\n"; -print ''."\n"; // Show logo (search order: logo defined by PAYMENT_LOGO_suffix, then PAYMENT_LOGO, then small company logo, large company logo, theme logo, common logo) $width = 0; @@ -803,13 +784,43 @@ elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$log // Output html code for logo if ($urllogo) { - print ''; - print ''; - print ''."\n"; + print '>'; + print ''; + if (empty($conf->global->MAIN_HIDE_POWERED_BY)) { + print ''; + } + print ''; } + + + +print ''."\n"; +print ''."\n"; +// Additionnal information for each payment system +if (!empty($conf->paypal->enabled)) +{ + print ''."\n"; + print ''."\n"; +} +if (!empty($conf->paybox->enabled)) +{ + print ''."\n"; +} +if (!empty($conf->stripe->enabled)) +{ + print ''."\n"; +} +print ''."\n"; +print ''."\n"; +print "\n"; + +print '
'; + print '
'; + print '
'."\n"; + // Output introduction text $text = ''; if (!empty($conf->global->PAYMENT_NEWFORM_TEXT)) diff --git a/htdocs/theme/common/dolibarr_logo_bw.png b/htdocs/theme/common/dolibarr_logo_bw.png deleted file mode 100644 index 238a1899c00d9e74878a57a3efa53a1209315a24..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 791 zcmV+y1L*vTP)b2wb(kXB6erg z0EW2v#`*AKfyxMB!>sWElRY2!&P1(_ShX0i=TrrZB__8IgVVfcykYkIZN{{O-6Gau zw;i_`+kLoW9P+Fy>~>6>`Y>nB6$V{}{eH}~%~uUGru(T{sH25NM-0L3#qJgx{{)s# zcVYhwPNS&7Do+Wg@RVO_oGw+Wj4Y^(Xv2X@d3Nb&#Z1PvR~2StP9|q0Mnw{A)BWY* zTkO(}<<=$)RRvZg;o=N#v6o3rOS51Kj3nW5kP4H`x)@3gHj?lL+q|)PD3%yktbv9Tv7zEo1%i*ZXb2=_-*n9w+gkcS{=xXlZ@kzK;9(s5 zk=uLfb9(~}FFgE`<8kK?U%nLhrNnRCKb816j+f92jRy`h{$Ao=;q%LcFA0B+?+p{? z$(=%P2$PJx8HfH+Mi%&#mvpM|*9u?bPq2*qG~;7l(lOzmOZXChgNHP-z%ianf!FXg z{pKIj$O6M_nsu0Wi#cQcI6Z{Dj=!tN3hoc1JXQ?vO`dNb)7!rq`GH1x_}~6v`wK+| Vh4s`po4Wu2002ovPDHLkV1gedW?BFM diff --git a/htdocs/theme/common/dolibarr_logo_256x256.png b/htdocs/theme/dolibarr_logo_256x256.png similarity index 100% rename from htdocs/theme/common/dolibarr_logo_256x256.png rename to htdocs/theme/dolibarr_logo_256x256.png diff --git a/htdocs/theme/dolibarr_logo_bw.png b/htdocs/theme/dolibarr_logo_bw.png new file mode 100644 index 0000000000000000000000000000000000000000..50b1608847c3d5d0001b4e9334610b49ef41cf16 GIT binary patch literal 646 zcmV;10(t$3P)o7!U;rhDLhx0005`Nkl@nynh(h+!fv(uMfkQcQwoLgw5{jP0earlD{#-F2^CTUNIEzFyyM(LpiB|Rn0RW{Kzea zTopSg*Py|Wt6~e~5&?!>6;DvEAYBf=f)yJm7Z^BKTQQFdjd42g_R+~MEHKP?ImfBU gGlRx{;eYu20@~ literal 0 HcmV?d00001 diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 4b731808d2e..fb63a6d5a3b 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -3663,6 +3663,17 @@ table.table-fiche-title { margin-bottom: 5px; } + +div.backgreypublicpayment { background-color: #f0f0f0; padding: 20px; border-bottom: 1px solid #ddd; } +.backgreypublicpayment a { color: #222 !important; } +.poweredbypublicpayment { + float: right; + top: 20px; + right: 20px; + position: absolute; + font-size: 0.8em; + color: #222; +} #dolpaymenttable { min-width: 320px; font-size: 16px; } /* Width must have min to make stripe input area visible. Lower than 320 makes input area crazy for credit card that need zip code */ #tablepublicpayment { border: 1px solid #CCCCCC !important; width: 100%; padding: 20px; } #tablepublicpayment .CTableRow1 { background-color: #F0F0F0 !important; } diff --git a/htdocs/theme/eldy/manifest.json.php b/htdocs/theme/eldy/manifest.json.php index 889b406ab3f..545f39b7896 100644 --- a/htdocs/theme/eldy/manifest.json.php +++ b/htdocs/theme/eldy/manifest.json.php @@ -46,7 +46,7 @@ if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $appli=$conf->global->MAIN_AP "name": "", "icons": [ { - "src": "", + "src": "", "sizes": "256x256", "type": "image/png" } From 5d7fa5575996e387c028377d6ee96e677c1180c1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 24 Jan 2020 17:48:24 +0100 Subject: [PATCH 06/19] css --- htdocs/public/payment/newpayment.php | 2 +- htdocs/theme/eldy/global.inc.php | 5 +++-- htdocs/theme/eldy/theme_vars.inc.php | 2 +- htdocs/theme/md/style.css.php | 14 ++++++++++++++ 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 80ed910ac70..2e160139dec 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -791,7 +791,7 @@ if ($urllogo) print '>'; print ''; if (empty($conf->global->MAIN_HIDE_POWERED_BY)) { - print ''; + print ''; } print ''; } diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index fb63a6d5a3b..e2414e8ad85 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -3668,11 +3668,12 @@ div.backgreypublicpayment { background-color: #f0f0f0; padding: 20px; border-bot .backgreypublicpayment a { color: #222 !important; } .poweredbypublicpayment { float: right; - top: 20px; - right: 20px; + top: 8px; + right: 8px; position: absolute; font-size: 0.8em; color: #222; + opacity: 0.3; } #dolpaymenttable { min-width: 320px; font-size: 16px; } /* Width must have min to make stripe input area visible. Lower than 320 makes input area crazy for credit card that need zip code */ #tablepublicpayment { border: 1px solid #CCCCCC !important; width: 100%; padding: 20px; } diff --git a/htdocs/theme/eldy/theme_vars.inc.php b/htdocs/theme/eldy/theme_vars.inc.php index 2f8b7ac08e4..ccaac4471a9 100644 --- a/htdocs/theme/eldy/theme_vars.inc.php +++ b/htdocs/theme/eldy/theme_vars.inc.php @@ -53,7 +53,7 @@ $theme_bgcolor = array(hexdec('F4'), hexdec('F4'), hexdec('F4')); $theme_bgcoloronglet = array(hexdec('DE'), hexdec('E7'), hexdec('EC')); // Colors -$colorbackhmenu1 = '60,70,100'; // topmenu +$colorbackhmenu1 = '68,68,90'; // topmenu $colorbackvmenu1 = '250,250,250'; // vmenu $colortopbordertitle1 = '200,200,200'; // top border of title $colorbacktitle1 = '233,234,237'; // title of tables,list diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 98a6af8259f..b20982ccb67 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -3780,6 +3780,20 @@ table.table-fiche-title .col-title div.titre{ line-height: 40px; } +div.backgreypublicpayment { background-color: #f0f0f0; padding: 20px; border-bottom: 1px solid #ddd; } +.backgreypublicpayment a { color: #222 !important; } +.poweredbypublicpayment { + float: right; + top: 8px; + right: 8px; + position: absolute; + font-size: 0.8em; + color: #222; + opacity: 0.3; +} +span.buttonpaymentsmall { + text-shadow: none; +} #dolpaymenttable { min-width: 320px; font-size: 16px; } /* Width must have min to make stripe input area visible. Lower than 320 makes input area crazy for credit card that need zip code */ #tablepublicpayment { border: 1px solid #CCCCCC !important; width: 100%; padding: 20px; } #tablepublicpayment .CTableRow1 { background-color: #F0F0F0 !important; } From 3a7c0b63f198de4ffe223c5db80e4aa4ae4f5dd6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 24 Jan 2020 17:56:41 +0100 Subject: [PATCH 07/19] css --- htdocs/theme/eldy/dropdown.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/theme/eldy/dropdown.inc.php b/htdocs/theme/eldy/dropdown.inc.php index 1258418b3ff..fb8856d4687 100644 --- a/htdocs/theme/eldy/dropdown.inc.php +++ b/htdocs/theme/eldy/dropdown.inc.php @@ -100,7 +100,7 @@ if (! defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> } .side-nav-vert .user-menu .dropdown-menu > .user-header { - min-height: 175px; + min-height: 100px; padding: 10px; text-align: center; white-space: normal; From d5f2a793c0ad6ad41f87990ed64bd4ac5da057ca Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 24 Jan 2020 19:36:17 +0100 Subject: [PATCH 08/19] CSS --- htdocs/theme/eldy/info-box.inc.php | 2 +- htdocs/theme/md/info-box.inc.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/theme/eldy/info-box.inc.php b/htdocs/theme/eldy/info-box.inc.php index 2ceaa70911a..268f1885327 100644 --- a/htdocs/theme/eldy/info-box.inc.php +++ b/htdocs/theme/eldy/info-box.inc.php @@ -153,7 +153,7 @@ a.info-box-text{ text-decoration: none;} include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $prefix=''; -$prefix = 'background-'; +//$prefix = 'background-'; if (! empty($conf->global->THEME_INFOBOX_COLOR_ON_BACKGROUND)) $prefix = 'background-'; if (! isset($conf->global->THEME_AGRESSIVENESS_RATIO) && $prefix) $conf->global->THEME_AGRESSIVENESS_RATIO=-50; diff --git a/htdocs/theme/md/info-box.inc.php b/htdocs/theme/md/info-box.inc.php index 8effe7d62d6..fb011e63e69 100644 --- a/htdocs/theme/md/info-box.inc.php +++ b/htdocs/theme/md/info-box.inc.php @@ -98,7 +98,7 @@ a.info-box-text{ text-decoration: none;} -/* ICONS */ +/* ICONS INFO BOX */ .info-box-icon { color: #000 !important; } From 8f3f34e1c0e4eaaa4a3c77f30c0d69297b9eed6b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 24 Jan 2020 20:11:07 +0100 Subject: [PATCH 09/19] Fix css --- htdocs/core/lib/functions.lib.php | 2 +- htdocs/theme/eldy/global.inc.php | 3 +++ htdocs/theme/md/style.css.php | 5 +++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c5e4dfb0d6d..2e86e88460d 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1140,7 +1140,7 @@ function dol_get_fiche_head($links = array(), $active = '', $title = '', $notab { $limittitle = 30; $out .= ''; - if ($picto) $out .= img_picto($title, ($pictoisfullpath ? '' : 'object_').$picto, '', $pictoisfullpath).' '; + if ($picto) $out .= img_picto($title, ($pictoisfullpath ? '' : 'object_').$picto, '', $pictoisfullpath, 0, 0, '', 'imgTabTitle').' '; $out .= ''.dol_trunc($title, $limittitle).''; $out .= ''; } diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index e2414e8ad85..bc00125301e 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -2462,6 +2462,9 @@ a.tabTitle { text-decoration: none; white-space: nowrap; } +.imgTabTitle { + max-height: 14px; +} a.tabunactive { color: rgb() !important; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index b20982ccb67..0806cb47d1e 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -2637,8 +2637,6 @@ div.popuptab { } a.tabTitle { -/* background: #657090; - color: white;*/ color:rgba(0,0,0,.5); margin-: 10px; text-shadow:1px 1px 1px #ffffff; @@ -2649,6 +2647,9 @@ a.tabTitle { text-decoration: none; white-space: nowrap; } +.imgTabTitle { + max-height: 14px; +} a.tab:link, a.tab:visited, a.tab:hover, a.tab#active { font-family: ; From c494e3029be3d0509fd55d96090a76fec2486a90 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 24 Jan 2020 20:14:01 +0100 Subject: [PATCH 10/19] Trans --- htdocs/langs/en_US/main.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index bfc702426a2..43331220bd0 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1014,3 +1014,4 @@ ContactDefault_ticketsup=Ticket ContactAddedAutomatically=Contact added from contact thirdparty roles More=More ShowDetails=Show details +CustomReports=Custom reports \ No newline at end of file From cc6b9269f9bb5f8f8b2aea44e8e61a09f31fbcd4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 25 Jan 2020 11:50:16 +0100 Subject: [PATCH 11/19] Fix look and feel v11 --- htdocs/cron/class/cronjob.class.php | 14 ++++++++++---- htdocs/cron/list.php | 3 ++- htdocs/theme/eldy/global.inc.php | 2 +- htdocs/theme/eldy/theme_vars.inc.php | 2 +- htdocs/theme/md/theme_vars.inc.php | 2 +- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index b70707f1464..5cde792bbb5 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -1287,12 +1287,12 @@ class Cronjob extends CommonObject /** * Return label of status of user (active, inactive) * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label of status */ public function getLibStatut($mode = 0) { - return $this->LibStatut($this->status, $mode, $this->processing); + return $this->LibStatut($this->status, $mode, $this->processing, $this->lastresult); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -1300,13 +1300,17 @@ class Cronjob extends CommonObject * Renvoi le libelle d'un statut donne * * @param int $status Id statut - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @param int $processing 0=Not running, 1=Running + * @param int $lastresult Value of last result (0=no error, error otherwise) * @return string Label of status */ - public function LibStatut($status, $mode = 0, $processing = 0) + public function LibStatut($status, $mode = 0, $processing = 0, $lastresult = 0) { // phpcs:enable + $this->labelStatus = array(); // Force reset o array because label depends on other fields + $this->labelStatusShort = array(); + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { global $langs; @@ -1314,6 +1318,7 @@ class Cronjob extends CommonObject $moretext = ''; if ($processing) $moretext = ' ('.$langs->trans("Running").')'; + elseif ($lastresult) $moretext .= ' ('.$langs->trans("Error").')'; $this->labelStatus[self::STATUS_DISABLED] = $langs->trans('Draft').$moretext; $this->labelStatus[self::STATUS_ENABLED] = $langs->trans('Enabled').$moretext; @@ -1324,6 +1329,7 @@ class Cronjob extends CommonObject $statusType = 'status4'; if ($status == 1 && $processing) $statusType = 'status1'; if ($status == 0) $statusType = 'status5'; + if ($this->lastresult) $statusType = 'status8'; return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index dd70d6d6913..ac9f178b163 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -425,6 +425,7 @@ if ($num > 0) $object->status = $obj->status; $object->priority = $obj->priority; $object->processing = $obj->processing; + $object->lastresult = $obj->lastresult; $datelastrun = $db->jdate($obj->datelastrun); $datelastresult = $db->jdate($obj->datelastresult); @@ -541,7 +542,7 @@ if ($num > 0) // Status print ''; print ''; // Year -print '
'; - print $object->getLibStatut(3); + print $object->getLibStatut(5); print ''; diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index bc00125301e..0f96bb15d62 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -3499,7 +3499,7 @@ img.boxhandle, img.boxclose { .ok { color: #114466; } .warning { color: #887711 !important; } -.error { color: #550000 !important; font-weight: bold; } +.error { color: #660000 !important; font-weight: bold; } .green { color: #118822; } div.ok { diff --git a/htdocs/theme/eldy/theme_vars.inc.php b/htdocs/theme/eldy/theme_vars.inc.php index ccaac4471a9..e80347e9895 100644 --- a/htdocs/theme/eldy/theme_vars.inc.php +++ b/htdocs/theme/eldy/theme_vars.inc.php @@ -112,7 +112,7 @@ $badgeStatus4 = '#55a580'; // Color ok $badgeStatus5 = '#cad2d2'; $badgeStatus6 = '#cad2d2'; $badgeStatus7 = '#baa32b'; -$badgeStatus8 = '#be3013'; +$badgeStatus8 = '#993013'; $badgeStatus9 = '#e7f0f0'; // status color ajustement for color blind diff --git a/htdocs/theme/md/theme_vars.inc.php b/htdocs/theme/md/theme_vars.inc.php index 5f0d1868481..106a4b5b854 100644 --- a/htdocs/theme/md/theme_vars.inc.php +++ b/htdocs/theme/md/theme_vars.inc.php @@ -99,5 +99,5 @@ $badgeStatus4 = '#277d1e'; $badgeStatus5 = '#cad2d2'; $badgeStatus6 = '#cad2d2'; $badgeStatus7 = '#baa32b'; -$badgeStatus8 = '#be3013'; +$badgeStatus8 = '#993013'; $badgeStatus9 = '#e7f0f0'; From be70232bfe5e7727f508ee5d224364d8726f4972 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 25 Jan 2020 12:10:00 +0100 Subject: [PATCH 12/19] Clean code --- .../class/expensereportstats.class.php | 19 +++++++++++-------- htdocs/expensereport/stats/index.php | 4 +++- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/htdocs/expensereport/class/expensereportstats.class.php b/htdocs/expensereport/class/expensereportstats.class.php index 9345e3e42ef..9c614e4953c 100644 --- a/htdocs/expensereport/class/expensereportstats.class.php +++ b/htdocs/expensereport/class/expensereportstats.class.php @@ -42,6 +42,9 @@ class ExpenseReportStats extends Stats public $field; public $where; + private $datetouse = 'date_valid'; + + /** * Constructor * @@ -91,7 +94,7 @@ class ExpenseReportStats extends Stats */ public function getNbByYear() { - $sql = "SELECT YEAR(".$this->db->ifsql('e.date_valid IS NULL', 'e.date_create', 'e.date_valid').") as dm, count(*)"; + $sql = "SELECT YEAR(".$this->db->ifsql('e.'.$this->datetouse.' IS NULL', 'e.date_create', 'e.'.$this->datetouse).") as dm, count(*)"; $sql.= " FROM ".$this->from; $sql.= " GROUP BY dm DESC"; $sql.= " WHERE ".$this->where; @@ -109,9 +112,9 @@ class ExpenseReportStats extends Stats */ public function getNbByMonth($year, $format = 0) { - $sql = "SELECT MONTH(".$this->db->ifsql('e.date_valid IS NULL', 'e.date_create', 'e.date_valid').") as dm, count(*)"; + $sql = "SELECT MONTH(".$this->db->ifsql('e.'.$this->datetouse.' IS NULL', 'e.date_create', 'e.'.$this->datetouse).") as dm, count(*)"; $sql.= " FROM ".$this->from; - $sql.= " WHERE YEAR(e.date_valid) = ".$year; + $sql.= " WHERE YEAR(e.".$this->datetouse.") = ".$year; $sql.= " AND ".$this->where; $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm', 'DESC'); @@ -131,9 +134,9 @@ class ExpenseReportStats extends Stats */ public function getAmountByMonth($year, $format = 0) { - $sql = "SELECT date_format(".$this->db->ifsql('e.date_valid IS NULL', 'e.date_create', 'e.date_valid').",'%m') as dm, sum(".$this->field.")"; + $sql = "SELECT date_format(".$this->db->ifsql('e.'.$this->datetouse.' IS NULL', 'e.date_create', 'e.'.$this->datetouse).",'%m') as dm, sum(".$this->field.")"; $sql.= " FROM ".$this->from; - $sql.= " WHERE date_format(".$this->db->ifsql('e.date_valid IS NULL', 'e.date_create', 'e.date_valid').",'%Y') = '".$year."'"; + $sql.= " WHERE date_format(".$this->db->ifsql('e.'.$this->datetouse.' IS NULL', 'e.date_create', 'e.'.$this->datetouse).",'%Y') = '".$year."'"; $sql.= " AND ".$this->where; $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm', 'DESC'); @@ -151,9 +154,9 @@ class ExpenseReportStats extends Stats */ public function getAverageByMonth($year) { - $sql = "SELECT date_format(".$this->db->ifsql('e.date_valid IS NULL', 'e.date_create', 'e.date_valid').",'%m') as dm, avg(".$this->field.")"; + $sql = "SELECT date_format(".$this->db->ifsql('e.'.$this->datetouse.' IS NULL', 'e.date_create', 'e.'.$this->datetouse).",'%m') as dm, avg(".$this->field.")"; $sql.= " FROM ".$this->from; - $sql.= " WHERE date_format(".$this->db->ifsql('e.date_valid IS NULL', 'e.date_create', 'e.date_valid').",'%Y') = '".$year."'"; + $sql.= " WHERE date_format(".$this->db->ifsql('e.'.$this->datetouse.' IS NULL', 'e.date_create', 'e.'.$this->datetouse).",'%Y') = '".$year."'"; $sql.= " AND ".$this->where; $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm', 'DESC'); @@ -168,7 +171,7 @@ class ExpenseReportStats extends Stats */ public function getAllByYear() { - $sql = "SELECT date_format(".$this->db->ifsql('e.date_valid IS NULL', 'e.date_create', 'e.date_valid').",'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; + $sql = "SELECT date_format(".$this->db->ifsql('e.'.$this->datetouse.' IS NULL', 'e.date_create', 'e.'.$this->datetouse).",'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; $sql.= " FROM ".$this->from; $sql.= " WHERE ".$this->where; $sql.= " GROUP BY year"; diff --git a/htdocs/expensereport/stats/index.php b/htdocs/expensereport/stats/index.php index 12959e7946f..60ab9001972 100644 --- a/htdocs/expensereport/stats/index.php +++ b/htdocs/expensereport/stats/index.php @@ -232,7 +232,9 @@ $liststatus = $tmpexpensereport->statuts; print $form->selectarray('object_status', $liststatus, GETPOST('object_status', 'int'), -4, 0, 0, '', 1); print '
'.$langs->trans("Year").''; +print '
'; +print $form->textwithpicto($langs->trans("Year"), $langs->trans("DateValidation")); +print ''; if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year; arsort($arrayyears); print $form->selectarray('year', $arrayyears, $year, 0); From 09e707b8187db017b0c444d55ad154174f2ca436 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 25 Jan 2020 13:05:40 +0100 Subject: [PATCH 13/19] trans --- htdocs/core/tpl/objectline_edit.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 095ddebdad6..7c76a5c0e07 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -105,7 +105,7 @@ $coldisplay++; // Do not allow editing during a situation cycle if ($line->fk_prev_id == null) { - // editeur wysiwyg + // editor wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $nbrows = ROWS_2; if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows = $conf->global->MAIN_INPUT_DESC_HEIGHT; From de6b30be8c0a1b693d2ff2e5a95bbad7720e7c49 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 25 Jan 2020 13:06:10 +0100 Subject: [PATCH 14/19] Look and feel v11 --- htdocs/admin/order_extrafields.php | 1 - htdocs/admin/orderdet_extrafields.php | 1 - 2 files changed, 2 deletions(-) diff --git a/htdocs/admin/order_extrafields.php b/htdocs/admin/order_extrafields.php index f81b3cc1e69..eba9fd76ff6 100644 --- a/htdocs/admin/order_extrafields.php +++ b/htdocs/admin/order_extrafields.php @@ -70,7 +70,6 @@ llxHeader('', $langs->trans("OrdersSetup")); $linkback=''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("OrdersSetup"), $linkback, 'title_setup'); -print "
\n"; $head = order_admin_prepare_head(); diff --git a/htdocs/admin/orderdet_extrafields.php b/htdocs/admin/orderdet_extrafields.php index 2b239de0932..9204bbc251c 100644 --- a/htdocs/admin/orderdet_extrafields.php +++ b/htdocs/admin/orderdet_extrafields.php @@ -71,7 +71,6 @@ llxHeader('', $langs->trans("OrdersSetup")); $linkback=''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("OrdersSetup"), $linkback, 'title_setup'); -print "
\n"; $head = order_admin_prepare_head(); From 09f809f347df80160aed14af2ee9362dbb6025e4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 25 Jan 2020 14:03:24 +0100 Subject: [PATCH 15/19] FIX #12913 --- htdocs/comm/propal/class/propal.class.php | 8 +++-- htdocs/commande/class/commande.class.php | 6 +++- htdocs/compta/facture/class/facture.class.php | 6 +++- htdocs/contrat/card.php | 28 ++++++---------- htdocs/contrat/class/contrat.class.php | 10 ++++-- htdocs/core/class/commonobject.class.php | 2 -- htdocs/core/class/extrafields.class.php | 8 +++-- .../class/fournisseur.commande.class.php | 7 +++- .../fourn/class/fournisseur.facture.class.php | 20 ++++++++--- .../class/supplier_proposal.class.php | 33 +++++++++++-------- 10 files changed, 81 insertions(+), 47 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 791c4872794..778f00fbf31 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -722,6 +722,7 @@ class Propal extends CommonObject $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); // Clean vat code + $reg = array(); $vat_src_code = ''; if (preg_match('/\((.*)\)/', $txtva, $reg)) { @@ -757,7 +758,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 + $line->fetch_optionals(); $staticline = clone $line; @@ -808,7 +809,10 @@ class Propal extends CommonObject $this->line->remise = $remise; if (is_array($array_options) && count($array_options) > 0) { - $this->line->array_options = $array_options; + // We replace values in this->line->array_options only for entries defined into $array_options + foreach($array_options as $key => $value) { + $this->line->array_options[$key] = $array_options[$key]; + } } // Multicurrency diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 337a6696b3c..1d8c5bb0f30 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3074,6 +3074,7 @@ class Commande extends CommonOrder //Fetch current line from the database and then clone the object and set it in $oldline property $line = new OrderLine($this->db); $line->fetch($rowid); + $line->fetch_optionals(); if (!empty($line->fk_product)) { @@ -3146,7 +3147,10 @@ class Commande extends CommonOrder $this->line->remise = $remise; if (is_array($array_options) && count($array_options) > 0) { - $this->line->array_options = $array_options; + // We replace values in this->line->array_options only for entries defined into $array_options + foreach($array_options as $key => $value) { + $this->line->array_options[$key] = $array_options[$key]; + } } $result = $this->line->update($user, $notrigger); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 83f9706bcee..4cea8dcad9d 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3105,6 +3105,7 @@ class Facture extends CommonInvoice //Fetch current line from the database and then clone the object and set it in $oldline property $line = new FactureLigne($this->db); $line->fetch($rowid); + $line->fetch_optionals(); if (!empty($line->fk_product)) { @@ -3173,7 +3174,10 @@ class Facture extends CommonInvoice $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; if (is_array($array_options) && count($array_options) > 0) { - $this->line->array_options = $array_options; + // We replace values in this->line->array_options only for entries defined into $array_options + foreach($array_options as $key => $value) { + $this->line->array_options[$key] = $array_options[$key]; + } } $result = $this->line->update($user, $notrigger); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index bc7e7dc87a9..fccae47fd89 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -155,23 +155,7 @@ if (empty($reshook)) } } - // Si ajout champ produit libre - if (GETPOST('mode') == 'libre') - { - $date_start_sl = ''; - $date_end_sl = ''; - if (GETPOST('date_start_slmonth') && GETPOST('date_start_slday') && GETPOST('date_start_slyear')) - { - $date_start_sl = dol_mktime(GETPOST('date_start_slhour'), GETPOST('date_start_slmin'), 0, GETPOST('date_start_slmonth'), GETPOST('date_start_slday'), GETPOST('date_start_slyear')); - } - if (GETPOST('date_end_slmonth') && GETPOST('date_end_slday') && GETPOST('date_end_slyear')) - { - $date_end_sl = dol_mktime(GETPOST('date_end_slhour'), GETPOST('date_end_slmin'), 0, GETPOST('date_end_slmonth'), GETPOST('date_end_slday'), GETPOST('date_end_slyear')); - } - } - // Param dates - $date_contrat = ''; $date_start_update = ''; $date_end_update = ''; $date_start_real_update = ''; @@ -665,11 +649,12 @@ if (empty($reshook)) if (!$error) { $objectline = new ContratLigne($db); - if ($objectline->fetch(GETPOST('elrowid')) < 0) + if ($objectline->fetch(GETPOST('elrowid', 'int')) < 0) { setEventMessages($objectline->error, $objectline->errors, 'errors'); $error++; } + $objectline->fetch_optionals(); } $db->begin(); @@ -693,6 +678,7 @@ if (empty($reshook)) $txtva = $vat_rate; // Clean vat code + $reg = array(); $vat_src_code = ''; if (preg_match('/\((.*)\)/', $txtva, $reg)) { @@ -735,7 +721,13 @@ if (empty($reshook)) // Extrafields $extralabelsline = $extrafields->fetch_name_optionals_label($objectline->table_element); $array_options = $extrafields->getOptionalsFromPost($object->table_element_line, $predef); - $objectline->array_options = $array_options; + + if (is_array($array_options) && count($array_options) > 0) { + // We replace values in this->line->array_options only for entries defined into $array_options + foreach($array_options as $key => $value) { + $objectline->array_options[$key] = $array_options[$key]; + } + } // TODO verifier price_min si fk_product et multiprix diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 7434d886072..98d6a5bc5cc 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1739,8 +1739,14 @@ class Contrat extends CommonObject if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) // For avoid conflicts if trigger used { $contractline = new ContratLigne($this->db); - $contractline->array_options = $array_options; - $contractline->id = $rowid; + $contractline->fetch($rowid); + $contractline->fetch_optionals(); + + // We replace values in $contractline->array_options only for entries defined into $array_options + foreach($array_options as $key => $value) { + $contractline->array_options[$key] = $array_options[$key]; + } + $result = $contractline->insertExtraFields(); if ($result < 0) { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 623cc6e14ba..14433ff79db 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5187,7 +5187,6 @@ abstract class CommonObject $attributeRequired = $extrafields->attributes[$this->table_element]['required'][$attributeKey]; $attrfieldcomputed = $extrafields->attributes[$this->table_element]['computed'][$attributeKey]; - if ($attributeRequired) { $mandatorypb = false; @@ -5218,7 +5217,6 @@ abstract class CommonObject } } - switch ($attributeType) { case 'int': diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 8479db591d9..ef5f5d4e74c 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -2147,23 +2147,27 @@ class ExtraFields if (in_array($key_type, array('date', 'datetime'))) { + if (! GETPOSTISSET($keysuffix."options_".$key.$keyprefix)."year") continue; // Value was not provided, we should not set it. // Clean parameters - $value_key = dol_mktime($_POST[$keysuffix."options_".$key.$keyprefix."hour"], $_POST[$keysuffix."options_".$key.$keyprefix."min"], 0, $_POST[$keysuffix."options_".$key.$keyprefix."month"], $_POST[$keysuffix."options_".$key.$keyprefix."day"], $_POST[$keysuffix."options_".$key.$keyprefix."year"]); + $value_key = dol_mktime(GETPOST($keysuffix."options_".$key.$keyprefix."hour", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."min", 'int'), 0, GETPOST($keysuffix."options_".$key.$keyprefix."month", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."day", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."year", 'int')); } elseif (in_array($key_type, array('checkbox', 'chkbxlst'))) { + if (! GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) continue; // Value was not provided, we should not set it. $value_arr = GETPOST($keysuffix."options_".$key.$keyprefix); // Make sure we get an array even if there's only one checkbox $value_arr = (array) $value_arr; $value_key = implode(',', $value_arr); } - elseif (in_array($key_type, array('price', 'double'))) + elseif (in_array($key_type, array('price', 'double', 'int'))) { + if (! GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) continue; // Value was not provided, we should not set it. $value_arr = GETPOST($keysuffix."options_".$key.$keyprefix); $value_key = price2num($value_arr); } else { + if (! GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) continue; // Value was not provided, we should not set it. $value_key = GETPOST($keysuffix."options_".$key.$keyprefix); } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 3183b66dc2c..3b2833fee76 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2572,6 +2572,8 @@ class CommandeFournisseur extends CommonOrder //Fetch current line from the database and then clone the object and set it in $oldline property $this->line = new CommandeFournisseurLigne($this->db); $this->line->fetch($rowid); + $this->line->fetch_optionals(); + $oldline = clone $this->line; $this->line->oldline = $oldline; @@ -2620,7 +2622,10 @@ class CommandeFournisseur extends CommonOrder $this->line->remise_percent = $remise_percent; if (is_array($array_options) && count($array_options) > 0) { - $this->line->array_options = $array_options; + // We replace values in this->line->array_options only for entries defined into $array_options + foreach($array_options as $key => $value) { + $this->line->array_options[$key] = $array_options[$key]; + } } $result = $this->line->update($notrigger); diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index f3d61c95b8b..e6562dbf928 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1913,11 +1913,15 @@ class FactureFournisseur extends CommonInvoice $product_type = $type; } + //Fetch current line from the database and then clone the object and set it in $oldline property $line = new SupplierInvoiceLine($this->db); + $line->fetch($id); + $line->fetch_optionals(); - if ($line->fetch($id) < 1) { - return -1; - } + $staticline = clone $line; + + $line->oldline = $staticline; + $line->context = $this->context; $line->description = $desc; $line->subprice = $pu_ht; @@ -1945,9 +1949,15 @@ class FactureFournisseur extends CommonInvoice $line->product_type = $product_type; $line->info_bits = $info_bits; $line->fk_unit = $fk_unit; - $line->array_options = $array_options; - // Multicurrency + if (is_array($array_options) && count($array_options) > 0) { + // We replace values in this->line->array_options only for entries defined into $array_options + foreach($array_options as $key => $value) { + $this->line->array_options[$key] = $array_options[$key]; + } + } + + // Multicurrency $line->multicurrency_subprice = $pu_ht_devise; $line->multicurrency_total_ht = $multicurrency_total_ht; $line->multicurrency_total_tva = $multicurrency_total_tva; diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 5825b2ff9b7..e881eeb3b78 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -391,7 +391,7 @@ class SupplierProposal extends CommonObject * @param int $fk_fournprice Id supplier price. If 0, we will take best price. If -1 we keep it empty. * @param int $pa_ht Buying price without tax * @param string $label ??? - * @param array $array_option extrafields array + * @param array $array_options extrafields array * @param string $ref_supplier Supplier price reference * @param int $fk_unit Id of the unit to use. * @param string $origin 'order', 'supplier_proposal', ... @@ -403,7 +403,7 @@ class SupplierProposal extends CommonObject * * @see add_product() */ - public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $pu_ttc = 0, $info_bits = 0, $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $array_option = 0, $ref_supplier = '', $fk_unit = '', $origin = '', $origin_id = 0, $pu_ht_devise = 0, $date_start = 0, $date_end = 0) + public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $pu_ttc = 0, $info_bits = 0, $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $array_options = 0, $ref_supplier = '', $fk_unit = '', $origin = '', $origin_id = 0, $pu_ht_devise = 0, $date_start = 0, $date_end = 0) { global $mysoc, $conf, $langs; @@ -605,8 +605,8 @@ class SupplierProposal extends CommonObject // Mise en option de la ligne if (empty($qty) && empty($special_code)) $this->line->special_code=3; - if (is_array($array_option) && count($array_option)>0) { - $this->line->array_options=$array_option; + if (is_array($array_options) && count($array_options)>0) { + $this->line->array_options=$array_options; } $result=$this->line->insert(); @@ -664,13 +664,13 @@ class SupplierProposal extends CommonObject * @param int $pa_ht Price (without tax) of product when it was bought * @param string $label ??? * @param int $type 0/1=Product/service - * @param array $array_option extrafields array + * @param array $array_options extrafields array * @param string $ref_supplier Supplier price reference * @param int $fk_unit Id of the unit to use. * @param double $pu_ht_devise Unit price in currency * @return int 0 if OK, <0 if KO */ - public function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $desc = '', $price_base_type = 'HT', $info_bits = 0, $special_code = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $type = 0, $array_option = 0, $ref_supplier = '', $fk_unit = '', $pu_ht_devise = 0) + public function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $desc = '', $price_base_type = 'HT', $info_bits = 0, $special_code = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $type = 0, $array_options = 0, $ref_supplier = '', $fk_unit = '', $pu_ht_devise = 0) { global $conf,$user,$langs, $mysoc; @@ -720,13 +720,17 @@ class SupplierProposal extends CommonObject $multicurrency_total_tva = $tabprice[17]; $multicurrency_total_ttc = $tabprice[18]; - // Update line - $this->line=new SupplierProposalLine($this->db); + //Fetch current line from the database and then clone the object and set it in $oldline property + $line = new SupplierProposalLine($this->db); + $line->fetch($rowid); + $line->fetch_optionals(); // Stock previous line records - $staticline=new SupplierProposalLine($this->db); - $staticline->fetch($rowid); - $this->line->oldline = $staticline; + $staticline = clone $line; + + $line->oldline = $staticline; + $this->line = $line; + $this->line->context = $this->context; // Reorder if fk_parent_line change if (! empty($fk_parent_line) && ! empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line) @@ -773,8 +777,11 @@ class SupplierProposal extends CommonObject } $this->line->pa_ht = $pa_ht; - if (is_array($array_option) && count($array_option)>0) { - $this->line->array_options=$array_option; + if (is_array($array_options) && count($array_options)>0) { + // We replace values in this->line->array_options only for entries defined into $array_options + foreach($array_options as $key => $value) { + $this->line->array_options[$key] = $array_options[$key]; + } } // Multicurrency From f2771b33658ec0cd85974cfbc5501171e787068e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 25 Jan 2020 14:23:23 +0100 Subject: [PATCH 16/19] FIX #12896 --- htdocs/compta/cashcontrol/cashcontrol_card.php | 6 +++--- htdocs/compta/cashcontrol/cashcontrol_list.php | 4 ++-- htdocs/core/menus/standard/eldy.lib.php | 2 +- htdocs/core/modules/modCashDesk.class.php | 6 +++--- htdocs/core/modules/modTakePos.class.php | 6 +++--- htdocs/takepos/takepos.php | 3 +++ 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index 7958d107ec8..4c60434619a 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -56,7 +56,7 @@ if (!$sortfield) $sortfield = 'rowid'; if (!$sortorder) $sortorder = 'ASC'; // Security check -if (!$user->rights->cashdesk->use && !$user->rights->takepos->use) +if (!$user->rights->cashdesk->run && !$user->rights->takepos->run) { accessforbidden(); } @@ -82,8 +82,8 @@ $hookmanager->initHooks(array('cashcontrolcard', 'globalcard')); * Actions */ -$permissiontoadd = ($user->rights->cashdesk->use || $user->rights->takepos->use); -$permissiontodelete = ($user->rights->cashdesk->use || $user->rights->takepos->use) || ($permissiontoadd && $object->status == 0); +$permissiontoadd = ($user->rights->cashdesk->run || $user->rights->takepos->run); +$permissiontodelete = ($user->rights->cashdesk->run || $user->rights->takepos->run) || ($permissiontoadd && $object->status == 0); if (empty($backtopage)) $backtopage = dol_buildpath('/compta/cashcontrol/cashcontrol_card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); $backurlforlist = dol_buildpath('/compta/cashcontrol/cashcontrol_list.php', 1); $triggermodname = 'CACHCONTROL_MODIFY'; // Name of trigger action code to execute when we modify record diff --git a/htdocs/compta/cashcontrol/cashcontrol_list.php b/htdocs/compta/cashcontrol/cashcontrol_list.php index 5bf48189c4a..6c59276d600 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_list.php +++ b/htdocs/compta/cashcontrol/cashcontrol_list.php @@ -168,8 +168,8 @@ if (empty($reshook)) // Mass actions $objectclass = 'CashControl'; $objectlabel = 'CashControl'; - $permissiontoread = ($user->rights->cashdesk->use || $user->rights->takepos->use); - $permissiontodelete = ($user->rights->cashdesk->use || $user->rights->takepos->use); + $permissiontoread = ($user->rights->cashdesk->run || $user->rights->takepos->run); + $permissiontodelete = ($user->rights->cashdesk->run || $user->rights->takepos->run); //$uploaddir = ''; //include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 253b745e25f..5a5a2c5628d 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1474,7 +1474,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // Cash Control if (!empty($conf->takepos->enabled) || !empty($conf->cashdesk->enabled)) { - $permtomakecashfence = ($user->rights->cashdesk->use || $user->rights->takepos->use); + $permtomakecashfence = ($user->rights->cashdesk->run || $user->rights->takepos->run); $newmenu->add("/compta/cashcontrol/cashcontrol_list.php?action=list", $langs->trans("POS"), 0, $permtomakecashfence, '', $mainmenu, 'cashcontrol'); $newmenu->add("/compta/cashcontrol/cashcontrol_card.php?action=create", $langs->trans("NewCashFence"), 1, $permtomakecashfence); $newmenu->add("/compta/cashcontrol/cashcontrol_list.php?action=list", $langs->trans("List"), 1, $permtomakecashfence); diff --git a/htdocs/core/modules/modCashDesk.class.php b/htdocs/core/modules/modCashDesk.class.php index 83495ca1af6..afb5185fb51 100644 --- a/htdocs/core/modules/modCashDesk.class.php +++ b/htdocs/core/modules/modCashDesk.class.php @@ -85,10 +85,10 @@ class modCashDesk extends DolibarrModules $r++; $this->rights[$r][0] = 50101; - $this->rights[$r][1] = 'Use point of sale'; + $this->rights[$r][1] = 'Use Point of sale'; $this->rights[$r][2] = 'a'; $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'use'; + $this->rights[$r][4] = 'run'; // Main menu entries $this->menus = array(); // List of menus to add @@ -103,7 +103,7 @@ class modCashDesk extends DolibarrModules 'langs'=>'cashdesk', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>900, 'enabled'=>'$conf->cashdesk->enabled', - 'perms'=>'$user->rights->cashdesk->use', // Use 'perms'=>'1' if you want your menu with no permission rules + 'perms'=>'$user->rights->cashdesk->run', // Use 'perms'=>'1' if you want your menu with no permission rules 'target'=>'pointofsale', 'user'=>0); // 0=Menu for internal users, 1=external users, 2=both diff --git a/htdocs/core/modules/modTakePos.class.php b/htdocs/core/modules/modTakePos.class.php index b5f79f79d8d..515f18cf690 100644 --- a/htdocs/core/modules/modTakePos.class.php +++ b/htdocs/core/modules/modTakePos.class.php @@ -199,10 +199,10 @@ class modTakePos extends DolibarrModules $r++; $this->rights[$r][0] = 50151; - $this->rights[$r][1] = 'Use point of sale'; + $this->rights[$r][1] = 'Use Point Of Sale'; $this->rights[$r][2] = 'a'; $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'use'; + $this->rights[$r][4] = 'run'; // Main menu entries @@ -221,7 +221,7 @@ class modTakePos extends DolibarrModules 'langs'=>'cashdesk', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>1000+$r, 'enabled'=>'$conf->takepos->enabled', // Define condition to show or hide menu entry. Use '$conf->takepos->enabled' if entry must be visible if module is enabled. - 'perms'=>'1', // Use 'perms'=>'$user->rights->takepos->level1->level2' if you want your menu with a permission rules + 'perms'=>'$user->rights->takepos->run', // Use 'perms'=>'$user->rights->takepos->level1->level2' if you want your menu with a permission rules 'target'=>'takepos', 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index 78ead8ff9c5..a7fb413e5f4 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -78,6 +78,9 @@ if ($invoice->socid > 0) $soc->fetch($invoice->socid); else $soc->fetch($conf->global->$constforcompanyid); */ +// Security check +$result = restrictedArea($user, 'takepos', 0, ''); + /* * View From 9ecf6127c627b5850853720c98b4725713df4edb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 25 Jan 2020 19:02:36 +0100 Subject: [PATCH 17/19] Add array fields for contracts --- htdocs/contrat/class/contrat.class.php | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 98d6a5bc5cc..4be939236c5 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -189,6 +189,36 @@ class Contrat extends CommonObject protected $lines_id_index_mapper = array(); + public $fields=array( + 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), + 'ref' =>array('type'=>'varchar(50)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-1, 'showoncombobox'=>1, 'position'=>15), + 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'Ref ext', 'enabled'=>1, 'visible'=>0, 'position'=>20), + 'ref_supplier' =>array('type'=>'varchar(50)', 'label'=>'Ref supplier', 'enabled'=>1, 'visible'=>-1, 'position'=>25), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>30, 'index'=>1), + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>35), + 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>40), + 'date_contrat' =>array('type'=>'datetime', 'label'=>'Date contrat', 'enabled'=>1, 'visible'=>-1, 'position'=>45), + 'statut' =>array('type'=>'smallint(6)', 'label'=>'Statut', 'enabled'=>1, 'visible'=>-1, 'position'=>500), + 'mise_en_service' =>array('type'=>'datetime', 'label'=>'Mise en service', 'enabled'=>1, 'visible'=>-1, 'position'=>55), + 'fin_validite' =>array('type'=>'datetime', 'label'=>'Fin validite', 'enabled'=>1, 'visible'=>-1, 'position'=>60), + 'date_cloture' =>array('type'=>'datetime', 'label'=>'Date cloture', 'enabled'=>1, 'visible'=>-1, 'position'=>65), + 'fk_soc' =>array('type'=>'integer', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>70), + 'fk_projet' =>array('type'=>'integer', 'label'=>'Fk projet', 'enabled'=>1, 'visible'=>-1, 'position'=>75), + 'fk_commercial_signature' =>array('type'=>'integer', 'label'=>'Fk commercial signature', 'enabled'=>1, 'visible'=>-1, 'position'=>80), + 'fk_commercial_suivi' =>array('type'=>'integer', 'label'=>'Fk commercial suivi', 'enabled'=>1, 'visible'=>-1, 'position'=>85), + 'fk_user_author' =>array('type'=>'integer', 'label'=>'Fk user author', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>90), + 'fk_user_mise_en_service' =>array('type'=>'integer', 'label'=>'Fk user mise en service', 'enabled'=>1, 'visible'=>-1, 'position'=>95), + 'fk_user_cloture' =>array('type'=>'integer', 'label'=>'Fk user cloture', 'enabled'=>1, 'visible'=>-1, 'position'=>100), + 'note_private' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>105), + 'note_public' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>110), + 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'position'=>115), + 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>120), + 'extraparams' =>array('type'=>'varchar(255)', 'label'=>'Extraparams', 'enabled'=>1, 'visible'=>-1, 'position'=>125), + 'ref_customer' =>array('type'=>'varchar(128)', 'label'=>'Ref customer', 'enabled'=>1, 'visible'=>-1, 'position'=>130), + 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>135), + 'last_main_doc' =>array('type'=>'varchar(255)', 'label'=>'Last main doc', 'enabled'=>1, 'visible'=>-1, 'position'=>140), + ); + const STATUS_DRAFT = 0; const STATUS_VALIDATED = 1; const STATUS_CLOSED = 2; From 12556aa83536e5c51ee9196c2d56175e091129b1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 25 Jan 2020 19:21:37 +0100 Subject: [PATCH 18/19] Fix modulebuilder --- htdocs/contrat/class/contrat.class.php | 18 +++++++++--------- htdocs/modulebuilder/index.php | 8 +++++++- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 4be939236c5..bb506884cab 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -202,20 +202,20 @@ class Contrat extends CommonObject 'mise_en_service' =>array('type'=>'datetime', 'label'=>'Mise en service', 'enabled'=>1, 'visible'=>-1, 'position'=>55), 'fin_validite' =>array('type'=>'datetime', 'label'=>'Fin validite', 'enabled'=>1, 'visible'=>-1, 'position'=>60), 'date_cloture' =>array('type'=>'datetime', 'label'=>'Date cloture', 'enabled'=>1, 'visible'=>-1, 'position'=>65), - 'fk_soc' =>array('type'=>'integer', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>70), - 'fk_projet' =>array('type'=>'integer', 'label'=>'Fk projet', 'enabled'=>1, 'visible'=>-1, 'position'=>75), - 'fk_commercial_signature' =>array('type'=>'integer', 'label'=>'Fk commercial signature', 'enabled'=>1, 'visible'=>-1, 'position'=>80), - 'fk_commercial_suivi' =>array('type'=>'integer', 'label'=>'Fk commercial suivi', 'enabled'=>1, 'visible'=>-1, 'position'=>85), - 'fk_user_author' =>array('type'=>'integer', 'label'=>'Fk user author', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>90), - 'fk_user_mise_en_service' =>array('type'=>'integer', 'label'=>'Fk user mise en service', 'enabled'=>1, 'visible'=>-1, 'position'=>95), - 'fk_user_cloture' =>array('type'=>'integer', 'label'=>'Fk user cloture', 'enabled'=>1, 'visible'=>-1, 'position'=>100), + 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>70), + 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Fk projet', 'enabled'=>1, 'visible'=>-1, 'position'=>75), + 'fk_commercial_signature' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fk commercial signature', 'enabled'=>1, 'visible'=>-1, 'position'=>80), + 'fk_commercial_suivi' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fk commercial suivi', 'enabled'=>1, 'visible'=>-1, 'position'=>85), + 'fk_user_author' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fk user author', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>90), + 'fk_user_mise_en_service' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fk user mise en service', 'enabled'=>1, 'visible'=>-1, 'position'=>95), + 'fk_user_cloture' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fk user cloture', 'enabled'=>1, 'visible'=>-1, 'position'=>100), 'note_private' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>105), 'note_public' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>110), 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'position'=>115), 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>120), 'extraparams' =>array('type'=>'varchar(255)', 'label'=>'Extraparams', 'enabled'=>1, 'visible'=>-1, 'position'=>125), - 'ref_customer' =>array('type'=>'varchar(128)', 'label'=>'Ref customer', 'enabled'=>1, 'visible'=>-1, 'position'=>130), - 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>135), + 'ref_customer' =>array('type'=>'varchar(50)', 'label'=>'Ref customer', 'enabled'=>1, 'visible'=>-1, 'position'=>130), + 'fk_user_modif' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>135), 'last_main_doc' =>array('type'=>'varchar(255)', 'label'=>'Last main doc', 'enabled'=>1, 'visible'=>-1, 'position'=>140), ); diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 9476f87a342..51e35ab050a 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -692,7 +692,7 @@ if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray', 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth200', 'help'=>'Help text'), 'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text'), - 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>'LinkToThirparty'), + 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>'LinkToThirparty'), 'description' =>array('type'=>'text', 'label'=>'Descrption', 'enabled'=>1, 'visible'=>0, 'position'=>60), 'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61), 'note_private' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62), @@ -716,6 +716,12 @@ if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray', // type $type = $obj->Type; if ($type == 'int(11)') $type='integer'; + if ($obj->Field == 'fk_soc') $type = 'integer:Societe:societe/class/societe.class.php'; + if (preg_match('/^fk_proj/', $obj->Field)) $type = 'integer:Project:projet/class/project.class.php:1:fk_statut=1'; + if (preg_match('/^fk_prod/', $obj->Field)) $type = 'integer:Product:product/class/product.class.php:1'; + if ($obj->Field == 'fk_warehouse') $type = 'integer:Entrepot:product/stock/class/entrepot.class.php'; + if (preg_match('/^(fk_user|fk_commercial)/', $obj->Field)) $type = 'integer:User:user/class/user.class.php'; + // notnull $notnull = ($obj->Null == 'YES'?0:1); if ($fieldname == 'fk_user_modif') $notnull = -1; From 4510ef488ee17c1342e976e8292308d73b4a81a1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 25 Jan 2020 22:43:56 +0100 Subject: [PATCH 19/19] doc modulebuilder --- htdocs/bom/class/bom.class.php | 2 +- htdocs/modulebuilder/template/class/myobject.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 8fcd6ce1274..0183ffb004a 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -47,7 +47,7 @@ class BOM extends CommonObject public $ismultientitymanaged = 1; /** - * @var int Does bom support extrafields ? 0=No, 1=Yes + * @var int Does object support extrafields ? 0=No, 1=Yes */ public $isextrafieldmanaged = 1; diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 7209738fa60..596e47e12c0 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -48,7 +48,7 @@ class MyObject extends CommonObject public $ismultientitymanaged = 0; /** - * @var int Does myobject support extrafields ? 0=No, 1=Yes + * @var int Does object support extrafields ? 0=No, 1=Yes */ public $isextrafieldmanaged = 1;