From 32ec57403be25fe6e863f52144eca9cfd0f9a241 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 24 Aug 2015 15:28:15 +0200 Subject: [PATCH 1/6] Bad translation --- htdocs/langs/en_US/compta.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index 8b38758e7373d..4d6703feeac1e 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -63,7 +63,7 @@ MenuSpecialExpenses=Special expenses MenuTaxAndDividends=Taxes and dividends MenuSalaries=Salaries MenuSocialContributions=Social/fiscal taxes -MenuNewSocialContribution=New tax payment +MenuNewSocialContribution=New social/fiscal tax NewSocialContribution=New social/fiscal tax ContributionsToPay=Social/fiscal taxes to pay AccountancyTreasuryArea=Accountancy/Treasury area From aaba18bd5147565707658631675e8cc49ef0e98a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 24 Aug 2015 15:40:33 +0200 Subject: [PATCH 2/6] Fix filter on date --- htdocs/compta/facture/list.php | 1 + htdocs/compta/paiement/list.php | 29 ++++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index faefe63d9af74..b06ea221cf87f 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -129,6 +129,7 @@ $search_montant_ht=''; $search_montant_ttc=''; $search_status=''; + $day=''; $year=''; $month=''; } diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index d284a12863137..c688ca780d419 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -28,6 +28,8 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $langs->load("bills"); $langs->load("compta"); @@ -36,6 +38,10 @@ $facid =GETPOST('facid','int'); $socid =GETPOST('socid','int'); $userid=GETPOST('userid','int'); +$day = GETPOST('day','int'); +$month = GETPOST('month','int'); +$year = GETPOST('year','int'); + if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'facture',$facid,''); @@ -66,6 +72,9 @@ $search_amount=""; $search_paymenttype=""; $search_company=""; + $day=''; + $year=''; + $month=''; } // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array @@ -81,6 +90,7 @@ llxHeader('', $langs->trans('ListPayment')); $form=new Form($db); +$formother=new FormOther($db); if (GETPOST("orphelins")) { @@ -141,6 +151,19 @@ else $sql.= " AND f.fk_user_author = ".$userid; } // Search criteria + if ($month > 0) + { + if ($year > 0 && empty($day)) + $sql.= " AND p.datep BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'"; + else if ($year > 0 && ! empty($day)) + $sql.= " AND p.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'"; + else + $sql.= " AND date_format(p.datep, '%m') = '".$month."'"; + } + else if ($year > 0) + { + $sql.= " AND p.datep BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; + } if ($search_ref > 0) $sql .=" AND p.rowid=".$search_ref; if ($search_account > 0) $sql .=" AND b.fk_account=".$search_account; if ($search_paymenttype != "") $sql .=" AND c.code='".$db->escape($search_paymenttype)."'"; @@ -194,7 +217,11 @@ print ''; print ''; print ''; - print ' '; + print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($year?$year:-1,'year',1, 20, 5); + print ''; print ''; print ''; print ''; From 8061ec90840489d8b2177010be46399e99d2f7c3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 24 Aug 2015 15:59:17 +0200 Subject: [PATCH 3/6] Fix translation --- htdocs/comm/prospect/list.php | 2 +- htdocs/compta/facture/list.php | 2 +- htdocs/core/class/html.form.class.php | 4 ++-- htdocs/core/menus/standard/eldy.lib.php | 2 +- htdocs/fourn/facture/list.php | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/comm/prospect/list.php b/htdocs/comm/prospect/list.php index e6227dad8964d..0422d65cc9ad7 100644 --- a/htdocs/comm/prospect/list.php +++ b/htdocs/comm/prospect/list.php @@ -420,7 +420,7 @@ { $arraystcomm[$val['id']]=$val['label']; } - print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, 1); + print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2); print ''; print ''; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index b06ea221cf87f..d88f72f171e3b 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -351,7 +351,7 @@ print ''; print ''; print ''; - $liststatus=array('0'=>$langs->trans("Draft"), '1'=>$langs->trans("Unpaid"), '2'=>$langs->trans("Paid"), '3'=>$langs->trans("Cancel")); + $liststatus=array('0'=>$langs->trans("BillShortStatusDraft"), '1'=>$langs->trans("BillShortStatusNotPaid"), '2'=>$langs->trans("BillShortStatusPaid"), '3'=>$langs->trans("BillShortStatusCanceled")); print $form->selectarray('search_status', $liststatus, $search_status, 1); print ''; print ''; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 0ab009d995779..bc831baeddfe8 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4406,7 +4406,7 @@ function select_duration($prefix, $iSecond='', $disabled=0, $typehour='select', * @param string $htmlname Name of html select area. Must start with "multi" if this is a multiselect * @param array $array Array with key+value * @param string|string[] $id Preselected key or preselected keys for multiselect - * @param int $show_empty 0 no empty value allowed, 1 to add an empty value into list (value is '' or ' '). + * @param int $show_empty 0 no empty value allowed, 1 to add an empty value into list (value is '' or ' '), <0 to add an empty value with key that is this value. * @param int $key_in_label 1 pour afficher la key dans la valeur "[key] value" * @param int $value_as_key 1 to use value as key * @param string $moreparam Add more parameters onto the select tag @@ -4455,7 +4455,7 @@ static function selectarray($htmlname, $array, $id='', $show_empty=0, $key_in_la { $textforempty=' '; if (! empty($conf->use_javascript_ajax)) $textforempty=' '; // If we use ajaxcombo, we need   here to avoid to have an empty element that is too small. - $out.=''."\n"; // id is -2 because -1 is already "do not contact" + $out.=''."\n"; // id is -2 because -1 is already "do not contact" } if (is_array($array)) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 807f6759c5104..bb632723b0b53 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -789,7 +789,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if (empty($leftmenu) || ($leftmenu == 'suppliers_bills')) { $newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills&search_status=0", $langs->trans("BillShortStatusDraft"),2,$user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills'); - $newmenu->add("/fourn/facture/impayees.php", $langs->trans("BillShortStatusNotPaid"),2,$user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills'); + $newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills&search_status=1", $langs->trans("BillShortStatusNotPaid"),2,$user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills'); $newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills&search_status=2", $langs->trans("BillShortStatusPaid"),2,$user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills'); } diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index d93f1c4beea3c..dc8adddec396d 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -305,7 +305,7 @@ print ''; print ''; print ''; - $liststatus=array('paye:0'=>$langs->trans("Unpaid"), 'paye:1'=>$langs->trans("Paid")); + $liststatus=array('fac.fk_statut:0'=>$langs->trans("Draft"),'fac.fk_statut:1,paye:0'=>$langs->trans("Unpaid"), 'paye:1'=>$langs->trans("Paid")); print $form->selectarray('filtre', $liststatus, $filter, 1); print ''; print ''; From 2cf10ac05d0c5384371df3c40a79fe4b4764d5f6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 24 Aug 2015 16:32:43 +0200 Subject: [PATCH 4/6] Fix filtering --- htdocs/comm/prospect/list.php | 22 +++++++++++++++++++--- htdocs/core/class/extrafields.class.php | 19 ++++++++++--------- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/htdocs/comm/prospect/list.php b/htdocs/comm/prospect/list.php index 0422d65cc9ad7..b15b3aae9db61 100644 --- a/htdocs/comm/prospect/list.php +++ b/htdocs/comm/prospect/list.php @@ -160,6 +160,7 @@ // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('thirdparty'); +$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); // Do we click on purge search criteria ? if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers @@ -174,6 +175,7 @@ $search_datec=""; $search_categ=""; $search_status=""; + $search_array_options=array(); } if ($search_status=='') $search_status=1; // always display active customer first @@ -256,6 +258,18 @@ $sortfield = "s.nom"; $sortorder = "ASC"; } +// Extra fields +if (is_array($extrafields->attribute_list) && count($extrafields->attribute_list)) +{ + foreach($extrafields->attribute_list as $key => $val) + { + $crit=GETPOST('search_options_'.$key); + if ($val && $crit != '') + { + $sql .= natural_search('ef.'.$key, $crit); + } + } +} // Add where from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook @@ -269,6 +283,7 @@ } $sql.= " ORDER BY $sortfield $sortorder, s.nom ASC"; $sql.= $db->plimit($conf->liste_limit+1, $offset); +//print $sql; dol_syslog('comm/prospect/list.php', LOG_DEBUG); $resql = $db->query($sql); @@ -434,9 +449,10 @@ { if ($val) { - print ''; - //print $extrafields->showInputField($key, $array_options[$key], '', '', 'search_', 4); - print ''; + $crit=$search_array_options['search_options_'.$key]; + print ''; + print $extrafields->showInputField($key, $crit, '', '', 'search_', 4); + print ''; } } } diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 5644b3c013740..20a812335a17f 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1425,11 +1425,12 @@ function setOptionalsFromPost($extralabels,&$object,$onlykey='') /** * return array_options array for object by extrafields value (using for data send by forms) * - * @param array $extralabels $array of extrafields - * @param string $keyprefix Prefix string to add into name and id of field (can be used to avoid duplicate names) - * @return int 1 if array_options set / 0 if no value + * @param array $extralabels $array of extrafields + * @param string $keyprefix Prefix string to add into name and id of field (can be used to avoid duplicate names) + * @param string $keysuffix Suffix string to add into name and id of field (can be used to avoid duplicate names) + * @return int 1 if array_options set / 0 if no value */ - function getOptionalsFromPost($extralabels,$keyprefix='') + function getOptionalsFromPost($extralabels,$keyprefix='',$keysuffix='') { global $_POST; @@ -1444,24 +1445,24 @@ function getOptionalsFromPost($extralabels,$keyprefix='') if (in_array($key_type,array('date','datetime'))) { // Clean parameters - $value_key=dol_mktime($_POST["options_".$key.$keyprefix."hour"], $_POST["options_".$key.$keyprefix."min"], 0, $_POST["options_".$key.$keyprefix."month"], $_POST["options_".$key.$keyprefix."day"], $_POST["options_".$key.$keyprefix."year"]); + $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"]); } else if (in_array($key_type,array('checkbox'))) { - $value_arr=GETPOST("options_".$key.$keyprefix); + $value_arr=GETPOST($keysuffix."options_".$key.$keyprefix); $value_key=implode($value_arr,','); } else if (in_array($key_type,array('price','double'))) { - $value_arr=GETPOST("options_".$key.$keyprefix); + $value_arr=GETPOST($keysuffix."options_".$key.$keyprefix); $value_key=price2num($value_arr); } else { - $value_key=GETPOST("options_".$key.$keyprefix); + $value_key=GETPOST($keysuffix."options_".$key.$keyprefix); } - $array_options["options_".$key]=$value_key; // No keyprefix here. keyprefix is used only for read. + $array_options[$keysuffix."options_".$key]=$value_key; // No keyprefix here. keyprefix is used only for read. } return $array_options; From 09355b0c7b9a9cd4594ad2a38fb3f8ee298b5484 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 24 Aug 2015 16:40:43 +0200 Subject: [PATCH 5/6] Fix filtering --- htdocs/core/class/extrafields.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 20a812335a17f..0807bbcec75b1 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1422,6 +1422,7 @@ function setOptionalsFromPost($extralabels,&$object,$onlykey='') return 0; } } + /** * return array_options array for object by extrafields value (using for data send by forms) * From a54589c13c3597ca1db1491d5267dfdcb87ff53f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 24 Aug 2015 17:47:26 +0200 Subject: [PATCH 6/6] Fix filter lost --- htdocs/comm/prospect/list.php | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/htdocs/comm/prospect/list.php b/htdocs/comm/prospect/list.php index b15b3aae9db61..5d795775eb4b8 100644 --- a/htdocs/comm/prospect/list.php +++ b/htdocs/comm/prospect/list.php @@ -259,16 +259,17 @@ $sortorder = "ASC"; } // Extra fields -if (is_array($extrafields->attribute_list) && count($extrafields->attribute_list)) +foreach ($search_array_options as $key => $val) { - foreach($extrafields->attribute_list as $key => $val) - { - $crit=GETPOST('search_options_'.$key); - if ($val && $crit != '') - { - $sql .= natural_search('ef.'.$key, $crit); - } - } + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $typ=$extrafields->attribute_type[$tmpkey]; + $mode=0; + if (in_array($typ, array('int'))) $mode=1; // Search on a numeric + if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) + { + $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); + } } // Add where from hooks $parameters=array(); @@ -317,9 +318,15 @@ } if ($search_level_from != '') $param.='&search_level_from='.$search_level_from; if ($search_level_to != '') $param.='&search_level_to='.$search_level_to; - if ($search_categ != '') $param.='&search_categ='.$search_categ; + if ($search_categ != '') $param.='&search_categ='.urlencode($search_categ); if ($search_sale > 0) $param.='&search_sale='.$search_sale; if ($search_status != '') $param.='&search_status='.$search_status; + foreach ($search_array_options as $key => $val) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $param.='&search_options_'.$tmpkey.'='.urlencode($val); + } // $param and $urladd should have the same value $urladd = $param;