diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index 159c834ea9e..c8fc4a917f2 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -83,17 +83,29 @@ class box_graph_invoices_permonth extends ModeleBoxes if ($user->rights->facture->lire) { - $param_year='DOLUSERCOOKIE_param'.$this->boxcode.'year'; - $param_shownb='DOLUSERCOOKIE_param'.$this->boxcode.'shownb'; - $param_showtot='DOLUSERCOOKIE_param'.$this->boxcode.'showtot'; + $param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; + $param_shownb='DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; + $param_showtot='DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php'; - $shownb=GETPOST($param_shownb,'alpha',4); - $showtot=GETPOST($param_showtot,'alpha',4); + if (GETPOST('DOL_AUTOSET_COOKIE')) + { + $endyear=GETPOST($param_year,'int'); + $shownb=GETPOST($param_shownb,'alpha'); + $showtot=GETPOST($param_showtot,'alpha'); + } + else + { + include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php'; + $tmparray=dol_json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode],true); + $endyear=$tmparray['year']; + $shownb=$tmparray['shownb']; + $showtot=$tmparray['showtot']; + } if (empty($shownb) && empty($showtot)) $showtot=1; $nowarray=dol_getdate(dol_now(),true); - $endyear=(GETPOST($param_year,'',4)?GETPOST($param_year,'int',4):$nowarray['year']); + if (empty($endyear)) $endyear=$nowarray['year']; $startyear=$endyear-1; $mode='customer'; $userid=0; @@ -191,7 +203,7 @@ class box_graph_invoices_permonth extends ModeleBoxes $stringtoshow.='
'; // hideobject is to start hidden $stringtoshow.='
'; $stringtoshow.=''; - $stringtoshow.=''; + $stringtoshow.=''; $stringtoshow.=' '.$langs->trans("NumberOfBillsByMonth"); $stringtoshow.='   '; $stringtoshow.=' '.$langs->trans("AmountOfBillsByMonthHT"); diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php index 6c4c18824d6..45f3be02933 100644 --- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php @@ -82,17 +82,29 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes if ($user->rights->fournisseur->facture->lire) { - $param_year='DOLUSERCOOKIE_param'.$this->boxcode.'year'; - $param_shownb='DOLUSERCOOKIE_param'.$this->boxcode.'shownb'; - $param_showtot='DOLUSERCOOKIE_param'.$this->boxcode.'showtot'; + $param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; + $param_shownb='DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; + $param_showtot='DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php'; - $shownb=GETPOST($param_shownb,'alpha',4); - $showtot=GETPOST($param_showtot,'alpha',4); + if (GETPOST('DOL_AUTOSET_COOKIE')) + { + $endyear=GETPOST($param_year,'int'); + $shownb=GETPOST($param_shownb,'alpha'); + $showtot=GETPOST($param_showtot,'alpha'); + } + else + { + include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php'; + $tmparray=dol_json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode],true); + $endyear=$tmparray['year']; + $shownb=$tmparray['shownb']; + $showtot=$tmparray['showtot']; + } if (empty($shownb) && empty($showtot)) $showtot=1; $nowarray=dol_getdate(dol_now(),true); - $endyear=(GETPOST($param_year,'',4)?GETPOST($param_year,'int',4):$nowarray['year']); + if (empty($endyear)) $endyear=$nowarray['year']; $startyear=$endyear-1; $mode='supplier'; $userid=0; @@ -190,7 +202,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $stringtoshow.='
'; // hideobject is to start hidden $stringtoshow.=''; $stringtoshow.=''; - $stringtoshow.=''; + $stringtoshow.=''; $stringtoshow.=' '.$langs->trans("NumberOfBillsByMonth"); $stringtoshow.='   '; $stringtoshow.=' '.$langs->trans("AmountOfBillsByMonthHT"); diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php index 8c33c138623..17fc0215fef 100644 --- a/htdocs/core/boxes/box_graph_orders_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_permonth.php @@ -83,17 +83,29 @@ class box_graph_orders_permonth extends ModeleBoxes if ($user->rights->commande->lire) { - $param_year='DOLUSERCOOKIE_param'.$this->boxcode.'year'; - $param_shownb='DOLUSERCOOKIE_param'.$this->boxcode.'shownb'; - $param_showtot='DOLUSERCOOKIE_param'.$this->boxcode.'showtot'; + $param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; + $param_shownb='DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; + $param_showtot='DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; include_once DOL_DOCUMENT_ROOT.'/commande/class/commandestats.class.php'; - $shownb=GETPOST($param_shownb,'alpha',4); - $showtot=GETPOST($param_showtot,'alpha',4); + if (GETPOST('DOL_AUTOSET_COOKIE')) + { + $endyear=GETPOST($param_year,'int'); + $shownb=GETPOST($param_shownb,'alpha'); + $showtot=GETPOST($param_showtot,'alpha'); + } + else + { + include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php'; + $tmparray=dol_json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode],true); + $endyear=$tmparray['year']; + $shownb=$tmparray['shownb']; + $showtot=$tmparray['showtot']; + } if (empty($shownb) && empty($showtot)) $showtot=1; $nowarray=dol_getdate(dol_now(),true); - $endyear=(GETPOST($param_year,'',4)?GETPOST($param_year,'int',4):$nowarray['year']); + if (empty($endyear)) $endyear=$nowarray['year']; $startyear=$endyear-1; $mode='customer'; $userid=0; @@ -191,7 +203,7 @@ class box_graph_orders_permonth extends ModeleBoxes $stringtoshow.='
'; // hideobject is to start hidden $stringtoshow.=''; $stringtoshow.=''; - $stringtoshow.=''; + $stringtoshow.=''; $stringtoshow.=' '.$langs->trans("NumberOfOrdersByMonth"); $stringtoshow.='   '; $stringtoshow.=' '.$langs->trans("AmountOfOrdersByMonthHT"); diff --git a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php index d85b0f7a09c..61cc4f8fe87 100644 --- a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php @@ -82,17 +82,29 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes if ($user->rights->fournisseur->commande->lire) { - $param_year='DOLUSERCOOKIE_param'.$this->boxcode.'year'; - $param_shownb='DOLUSERCOOKIE_param'.$this->boxcode.'shownb'; - $param_showtot='DOLUSERCOOKIE_param'.$this->boxcode.'showtot'; + $param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; + $param_shownb='DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; + $param_showtot='DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; include_once DOL_DOCUMENT_ROOT.'/commande/class/commandestats.class.php'; - $shownb=GETPOST($param_shownb,'alpha',4); - $showtot=GETPOST($param_showtot,'alpha',4); + if (GETPOST('DOL_AUTOSET_COOKIE')) + { + $endyear=GETPOST($param_year,'int'); + $shownb=GETPOST($param_shownb,'alpha'); + $showtot=GETPOST($param_showtot,'alpha'); + } + else + { + include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php'; + $tmparray=dol_json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode],true); + $endyear=$tmparray['year']; + $shownb=$tmparray['shownb']; + $showtot=$tmparray['showtot']; + } if (empty($shownb) && empty($showtot)) $showtot=1; $nowarray=dol_getdate(dol_now(),true); - $endyear=(GETPOST($param_year,'',4)?GETPOST($param_year,'int',4):$nowarray['year']); + if (empty($endyear)) $endyear=$nowarray['year']; $startyear=$endyear-1; $mode='supplier'; $userid=0; @@ -190,7 +202,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes $stringtoshow.='
'; // hideobject is to start hidden $stringtoshow.=''; $stringtoshow.=''; - $stringtoshow.=''; + $stringtoshow.=''; $stringtoshow.=' '.$langs->trans("NumberOfOrdersByMonth"); $stringtoshow.='   '; $stringtoshow.=' '.$langs->trans("AmountOfOrdersByMonthHT"); diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index e2b6dfe907c..a39b0acf1cb 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -82,20 +82,33 @@ class box_graph_product_distribution extends ModeleBoxes 'target'=>'none' // Set '' to get target="_blank" ); - $param_year='DOLUSERCOOKIE_param'.$this->boxcode.'year'; - $param_showinvoicenb='DOLUSERCOOKIE_param'.$this->boxcode.'showinvoicenb'; - $param_showpropalnb='DOLUSERCOOKIE_param'.$this->boxcode.'showpropalnb'; - $param_showordernb='DOLUSERCOOKIE_param'.$this->boxcode.'showordernb'; - $showinvoicenb=GETPOST($param_showinvoicenb,'alpha',4); - $showpropalnb=GETPOST($param_showpropalnb,'alpha',4); - $showordernb=GETPOST($param_showordernb,'alpha',4); + $param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; + $param_showinvoicenb='DOLUSERCOOKIE_box_'.$this->boxcode.'_showinvoicenb'; + $param_showpropalnb='DOLUSERCOOKIE_box_'.$this->boxcode.'_showpropalnb'; + $param_showordernb='DOLUSERCOOKIE_box_'.$this->boxcode.'_showordernb'; + if (GETPOST('DOL_AUTOSET_COOKIE')) + { + $year=GETPOST($param_year,'int'); + $showinvoicenb=GETPOST($param_showinvoicenb,'alpha'); + $showpropalnb=GETPOST($param_showpropalnb,'alpha'); + $showordernb=GETPOST($param_showordernb,'alpha'); + } + else + { + include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php'; + $tmparray=dol_json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode],true); + $year=$tmparray['year']; + $showinvoicenb=$tmparray['showinvoicenb']; + $showpropalnb=$tmparray['showpropalnb']; + $showordernb=$tmparray['showordernb']; + } if (empty($showinvoicenb) && empty($showpropalnb) && empty($showordernb)) { $showpropalnb=1; $showinvoicenb=1; $showordernb=1; } if (empty($conf->facture->enabled) || empty($user->rights->facture->lire)) $showinvoicenb=0; if (empty($conf->propal->enabled) || empty($user->rights->propal->lire)) $showpropalnb=0; if (empty($conf->commande->enabled) || empty($user->rights->commande->lire)) $showordernb=0; $nowarray=dol_getdate(dol_now(),true); - $year=(GETPOST($param_year,'',4)?GETPOST($param_year,'int',4):$nowarray['year']); + if (empty($year)) $year=$nowarray['year']; $nbofgraph=0; if ($showinvoicenb) $nbofgraph++; @@ -300,7 +313,7 @@ class box_graph_product_distribution extends ModeleBoxes $stringtoshow.='
'; // hideobject is to start hidden $stringtoshow.=''; $stringtoshow.=''; - $stringtoshow.=''; + $stringtoshow.=''; if (! empty($conf->facture->enabled) || ! empty($user->rights->facture->lire)) { $stringtoshow.=' '.$langs->trans("ForCustomersInvoices"); diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index e09b19b45ad..8fd42d525fd 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.php @@ -83,17 +83,29 @@ class box_graph_propales_permonth extends ModeleBoxes if ($user->rights->propal->lire) { - $param_year='DOLUSERCOOKIE_param'.$this->boxcode.'year'; - $param_shownb='DOLUSERCOOKIE_param'.$this->boxcode.'shownb'; - $param_showtot='DOLUSERCOOKIE_param'.$this->boxcode.'showtot'; + $param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; + $param_shownb='DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; + $param_showtot='DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propalestats.class.php'; - $shownb=GETPOST($param_shownb,'alpha',4); - $showtot=GETPOST($param_showtot,'alpha',4); + if (GETPOST('DOL_AUTOSET_COOKIE')) + { + $endyear=GETPOST($param_year,'int'); + $shownb=GETPOST($param_shownb,'alpha'); + $showtot=GETPOST($param_showtot,'alpha'); + } + else + { + include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php'; + $tmparray=dol_json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode],true); + $endyear=$tmparray['year']; + $shownb=$tmparray['shownb']; + $showtot=$tmparray['showtot']; + } if (empty($shownb) && empty($showtot)) $showtot=1; $nowarray=dol_getdate(dol_now(),true); - $endyear=(GETPOST($param_year,'',4)?GETPOST($param_year,'int',4):$nowarray['year']); + if (empty($endyear)) $endyear=$nowarray['year']; $startyear=$endyear-1; $mode='customer'; $userid=0; @@ -196,7 +208,7 @@ class box_graph_propales_permonth extends ModeleBoxes $stringtoshow.='
'; // hideobject is to start hidden $stringtoshow.=''; $stringtoshow.=''; - $stringtoshow.=''; + $stringtoshow.=''; $stringtoshow.=' '.$langs->trans("NumberOfProposalsByMonth"); $stringtoshow.='   '; $stringtoshow.=' '.$langs->trans("AmountOfProposalsByMonthHT"); diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 5deef696da0..59974316021 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -165,13 +165,21 @@ require_once 'filefunc.inc.php'; // If there is a POST parameter to tell to save automatically some POST params into a cookies, we do it if (! empty($_POST["DOL_AUTOSET_COOKIE"])) { - $tmplist=explode(',',$_POST["DOL_AUTOSET_COOKIE"]); - foreach ($tmplist as $value) + require_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php'; + $tmpautoset=explode(':',$_POST["DOL_AUTOSET_COOKIE"],2); + $tmplist=explode(',',$tmpautoset[1]); + $cookiearrayvalue=''; + foreach ($tmplist as $tmpkey) { - //var_dump('setcookie key='.$value.' value='.$_POST[$value]); - setcookie($value, empty($_POST[$value])?'':$_POST[$value], empty($_POST[$value])?0:(time()+(86400*354)), '/'); // keep cookie 1 year - if (empty($_POST[$value])) unset($_COOKIE[$value]); + $postkey=$tmpautoset[0].'_'.$tmpkey; + //var_dump('tmpkey='.$tmpkey.' postkey='.$postkey.' value='.$_POST[$postkey]); + if (! empty($_POST[$postkey])) $cookiearrayvalue[$tmpkey]=$_POST[$postkey]; } + $cookiename=$tmpautoset[0]; + $cookievalue=dol_json_encode($cookiearrayvalue); + //var_dump('setcookie cookiename='.$cookiename.' cookievalue='.$cookievalue); + setcookie($cookiename, empty($cookievalue)?'':$cookievalue, empty($cookievalue)?0:(time()+(86400*354)), '/'); // keep cookie 1 year + if (empty($cookievalue)) unset($_COOKIE[$cookiename]); } // Init session. Name of session is specific to Dolibarr instance.