[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 207/219: Task #1381 Change esthetic Search Fi
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 207/219: Task #1381 Change esthetic Search Filter |
Date: |
Mon, 18 Dec 2017 13:23:03 -0500 (EST) |
sparkyx pushed a commit to branch master
in repository noalyss.
commit f5c6fd70509927ddce0545519e666c9859532181
Author: Dany De Bontridder <address@hidden>
Date: Fri Dec 15 21:34:01 2017 +0100
Task #1381 Change esthetic Search Filter
---
html/js/acc_ledger.js | 22 ++++++++++------
html/js/scripts.js | 2 +-
include/ajax/ajax_search_filter.php | 23 +++++++++++++++--
include/class/acc_ledger_search.class.php | 43 +++++++++++++++++++------------
include/template/ledger_search.php | 10 ++-----
5 files changed, 65 insertions(+), 35 deletions(-)
diff --git a/html/js/acc_ledger.js b/html/js/acc_ledger.js
index 661ec5f..533f6d2 100644
--- a/html/js/acc_ledger.js
+++ b/html/js/acc_ledger.js
@@ -1257,6 +1257,9 @@ function save_filter(p_div,p_dossier) {
eltValue[idx]=$(p_div+elt[i]).value;
}
+ if (eltValue['amount_min']=="") eltValue["amount_min"]=0;
+ if (eltValue['amount_max']=="") eltValue["amount_max"]=0;
+
//ledger's list r_jrn
if (eltValue['nb_jrn'] > 0) {
eltValue['r_jrn']=[];
@@ -1275,17 +1278,17 @@ function save_filter(p_div,p_dossier) {
try {
var answer=req.responseJSON;
if ( answer.status == 'OK') {
- /*Add the new list to the selection
- * not needed
- * var new_item=document.createElement('li');
+ /*Add the new list to the selection */
+ var new_item=document.createElement('li');
new_item.innerHTML=answer.filter_name;
- $(p_div+'button_list').appendChild(new_item);*/
+
new_item.setAttribute("id","li"+p_div+"_"+answer.filter_id);
+ $('manage'+p_div).appendChild(new_item);
$(p_div+"filter_new").value="";
} else {
throw answer.message;
}
} catch (e) {
- smoke.alert(e.message);
+ smoke.alert(e);
}
}
});
@@ -1363,7 +1366,6 @@ function delete_filter (p_div,p_dossier,p_filter_id) {
var answer=req.evalJSON;
var child=$("manageli"+p_div+"_"+p_filter_id);
- console.log(child)
if ( child ) {$("manage"+p_div).removeChild(child); }
}catch (e) {
console.log(e.message)
@@ -1382,10 +1384,14 @@ function reset_filter(p_div) {
var
elt=['date_start','date_end','date_paid_start','date_paid_end','desc','amount_min','amount_max','qcode','accounting'];
for (var i=0;i<elt.length;i++) {
var idx=elt[i];
- console.log("idx = "+p_div+idx);
$(p_div+idx).value="";
}
-
+ if ( $(p_div+"date_start_hidden")) {
+ $(p_div+"date_start").value=$(p_div+"date_start_hidden").value;
+ }
+ if ( $(p_div+"date_end_hidden")) {
+ $(p_div+"date_end").value=$(p_div+"date_end_hidden").value;
+ }
// clean all the selected ledger
var eltLedgerId=$("ledger_id"+p_div);
eltLedgerId.innerHTML="";
diff --git a/html/js/scripts.js b/html/js/scripts.js
index 0b27788..284ae72 100644
--- a/html/js/scripts.js
+++ b/html/js/scripts.js
@@ -164,7 +164,7 @@ function encodeJSON(obj)
{
var str = '';
var e = 0;
- for (i in obj)
+ for (var i in obj)
{
if (e !== 0)
{
diff --git a/include/ajax/ajax_search_filter.php
b/include/ajax/ajax_search_filter.php
index 0382912..30489b5 100644
--- a/include/ajax/ajax_search_filter.php
+++ b/include/ajax/ajax_search_filter.php
@@ -23,6 +23,7 @@ if (!defined('ALLOWED'))
die('Appel direct ne sont pas permis');
require NOALYSS_INCLUDE.'/database/user_filter_sql.class.php';
+require NOALYSS_INCLUDE.'/class/acc_ledger_search.class.php';
$cn=Dossier::connect();
$dossier_id=Dossier::id();
global $g_user;
@@ -72,7 +73,11 @@ if ($op=='save_filter')
throw new Exception(_("Nom ne peut être vide"));
}
$new->save();
- $answer['filter_name']=sprintf("<a
onclick=\"load_filter('%s','%s','%s')\">%s</a>",
+ $rmAction=sprintf("delete_filter('%s','%s','%s')",
trim($http->post('div')), $dossier_id,
+ $new->getp('id'));
+ $answer['filter_name']=sprintf('<a class="tinybutton"
style="display:inline" id="" onclick="'.$rmAction.'">'.SMALLX.'</a>'
+ );
+ $answer['filter_name'].=sprintf("<a style=\"display:inline\"
onclick=\"load_filter('%s','%s','%s')\">%s</a>",
trim($http->post('div')), $dossier_id, $new->getp('id'),
$new->getp("filter_name"));
$answer['filter_id']=$new->getp("id");
@@ -119,8 +124,11 @@ if ($op=="display_search_filter")
{
$p_div=$http->get("div");
$ledger_type=$http->get("ledger_type");
-
+
echo HtmlInput::title_box(_("Filtre"), "boxfilter".$p_div);
+
+
+
// Make a list of all search filters with the same ledger_type of the
current
// user
$result=$cn->get_array("
@@ -133,6 +141,17 @@ if ($op=="display_search_filter")
", [$g_user->login, $ledger_type]);
$nb_result=count($result);
printf('<ul class="select_table" id="manage%s">', $p_div);
+ $search_filter=new Acc_Ledger_Search($ledger_type,1,$p_div);
+ // Button add filter
+ echo "<li>";
+ echo $search_filter->build_name_filter();
+ echo "</li>";
+
+ echo "<li>";
+ echo HtmlInput::anchor(_("Remise à zéro"), "",
"onclick=\"reset_filter('$p_div');removeDiv('boxfilter{$p_div}')\"");
+ echo "</li>";
+
+ // Link reset
for ($i=0; $i<$nb_result; $i++)
{
printf(' <li id="manageli%s_%d">', $p_div, $result[$i]["id"]);
diff --git a/include/class/acc_ledger_search.class.php
b/include/class/acc_ledger_search.class.php
index d786a56..c739bba 100644
--- a/include/class/acc_ledger_search.class.php
+++ b/include/class/acc_ledger_search.class.php
@@ -126,14 +126,16 @@ class Acc_Ledger_Search
{
$hid_jrn=HtmlInput::hidden($this->div.'nb_jrn', 0);
}
- /* Compute date for exercice */
+ /* Compute default date for exercice */
$period=$g_user->get_periode();
$per=new Periode($this->cn, $period);
$exercice=$per->get_exercice();
list($per_start, $per_end)=$per->get_limit($exercice);
$date_end=$per_end->last_day();
$date_start=$per_start->first_day();
-
+
+ $date_start_hidden=HtmlInput::hidden("{$this->div}date_start_hidden",
$date_start);
+ $date_end_hidden=HtmlInput::hidden("{$this->div}date_end_hidden",
$date_end);
/* widget for date_start */
$f_date_start=new IDate('date_start', '', $this->div."date_start");
/* all periode or only the selected one */
@@ -224,7 +226,6 @@ class Acc_Ledger_Search
$r.=HtmlInput::hidden('ac', $_REQUEST['ac']);
ob_start();
$search_filter=$this->build_search_filter();
- $save_filter=$this->build_name_filter();
require_once NOALYSS_TEMPLATE.'/ledger_search.php';
$r.=ob_get_contents();
ob_end_clean();
@@ -252,12 +253,15 @@ class Acc_Ledger_Search
/**
* Build the button for saving the filter for search
*/
- private function build_name_filter()
+ function build_name_filter()
{
$name=new IText($this->div."filter_new");
$name->placeholder=_("Nom du filtre");
-
$name->javascript=sprintf("save_filter('%s','%s')",$this->div,Dossier::id());
- return $name;
+ $r=$name->input();
+ $bt=new IButton($this->div."save_ok",_("Ajout"));
+
$bt->javascript=sprintf("save_filter('%s','%s')",$this->div,Dossier::id());
+ $r.=$bt->input();
+ return $r;
}
/**
@@ -352,8 +356,11 @@ class Acc_Ledger_Search
if (!empty($p_array))
extract($p_array, EXTR_SKIP);
- if (isset($op))
- $r_jrn=(isset(${$op."r_jrn"}))?${$op."r_jrn"}:-1;
+ $op=$this->div;
+ if (isset($p_array[$op."r_jrn"]))
+ {
+ $r_jrn=$p_array[$op."r_jrn"];
+ }
else
{
$r_jrn=(isset($r_jrn))?$r_jrn:-1;
@@ -367,9 +374,7 @@ class Acc_Ledger_Search
$amount_max=0;
$desc='';
- $qcode=(isset($qcode))?$qcode:"";
- if (isset($qcodesearch_op))
- $qcode=$qcodesearch_op;
+
$qcode=(isset($p_array[$this->div."qcode"]))?$p_array[$this->div."qcode"]:"";
$accounting=(isset($accounting))?$accounting:"";
$periode=new Periode($this->cn);
$g_user=new User($this->cn);
@@ -512,9 +517,8 @@ class Acc_Ledger_Search
$and=" and ";
}
// Quick Code
- if (isset($qcodesearch_op))
- $qcode=$qcodesearch_op;
- if (isset($qcode)&&$qcode!=null)
+
$qcode=(isset($p_array[$this->div."qcode"]))?$p_array[$this->div."qcode"]:"";
+ if ($qcode!="")
{
$fil_qcode=$and." jr_grpt_id in ( select j_grpt from
jrnx where trim(j_qcode) =
upper(trim('".sql_string($qcode)."')))";
@@ -560,7 +564,15 @@ class Acc_Ledger_Search
$r.=h2('Recherche', 'class="title"');
$r.='<FORM METHOD="GET">';
$r.=$this->search_form();
+
$r.=HtmlInput::submit('search', _('Rechercher'));
+
+ $button_search=new IButton("{$this->div}button", _('Filtre'));
+ $button_search->javascript=$this->build_search_filter();
+ $r.=$button_search->input();
+
+
+
$r.=HtmlInput::hidden('ac', $_REQUEST['ac']);
/* when called from commercial.php some hidden values are needed */
@@ -577,9 +589,8 @@ class Acc_Ledger_Search
$r.='</div>';
$button=new IButton('tfs');
- $button->label=_("Filtrer");
+ $button->label=_("Chercher");
$button->javascript="toggleHideShow('search_form','tfs');";
-
$r.=$button->input();
return $r;
}
diff --git a/include/template/ledger_search.php
b/include/template/ledger_search.php
index fe75e6f..2e29663 100644
--- a/include/template/ledger_search.php
+++ b/include/template/ledger_search.php
@@ -1,7 +1,6 @@
<?php
//This file is part of NOALYSS and is under GPL
//see licence.txt
-require_once NOALYSS_INCLUDE.'/lib/select_box.class.php';
?>
<table id="<?=$this->div?>table_search">
@@ -25,6 +24,7 @@ require_once NOALYSS_INCLUDE.'/lib/select_box.class.php';
</td>
<td>
<?php echo $f_date_start->input(); ?> <?php echo _('et')?> <?php echo
$f_date_end->input(); ?>
+
</td>
</tr>
<tr>
@@ -33,6 +33,7 @@ require_once NOALYSS_INCLUDE.'/lib/select_box.class.php';
</td>
<td>
<?php echo $f_date_paid_start->input(); ?> <?php echo _('et')?> <?php echo
$f_date_paid_end->input(); ?>
+<?php echo $date_start_hidden,$date_end_hidden;?>
</td>
</tr>
@@ -82,10 +83,3 @@ require_once NOALYSS_INCLUDE.'/lib/select_box.class.php';
</tr>
</table>
-<?php
-$box=new Select_Box("{$this->div}button","Filtre");
-$box->add_input(_('Ajout'), $save_filter);
-$box->add_javascript(_('Gestion Filtre'), $search_filter);
-$box->add_javascript(_('Remise à zéro'), "reset_filter('{$this->div}')");
-echo $box->input();
-?>
- [Noalyss-commit] [noalyss] 104/219: Réécriture de CFGPCMN pour utiliser ManageTable pas de delete proposé si compte utilisé, (continued)
- [Noalyss-commit] [noalyss] 104/219: Réécriture de CFGPCMN pour utiliser ManageTable pas de delete proposé si compte utilisé, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 14/219: Infobulle : warning : esthetic, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 44/219: fix minor bug + doc, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 46/219: Manage_Table : Improve Javascript for adding / removing row of table, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 27/219: Task #0001443: opérations rapprochées : bug quand on utilise des tva avec autoliquidation Check with the view v_quant_detail and take into account the negative VAT, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 33/219: Task #0001324: Afficher la date (période) dans FSALDO, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 198/219: Task #001381 : reinitialize the search_form, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 154/219: Task #1440 CA - opération diverses inaccessibles Task #1370 les OD en comptabilité analytique - problème., Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 209/219: Merge branch 'master' of ns3:/srv/git/noalyss, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 186/219: Protect queryString with encodeURI, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 207/219: Task #1381 Change esthetic Search Filter,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 208/219: Fix search for reconcile, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 157/219: Fix issue with open_basedir, sometime set in the server config, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 196/219: Task #001381 : favori de filtre , table pour sauvegarder, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 109/219: Add button to pin the box, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 134/219: #0001414: LETTRAGE - montants différents non indiqués Apparation d'une bulle d'info avec la différence, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 147/219: ANC : ANC_TABLE replace PGPLSQL procedure by Php functions : Anc_Table:create_temp_account Anc_Table:create_temp_card, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 20/219: Add new theme and modify tmp_pcmn, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 180/219: Fix ID problem, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 89/219: Cosmetic : cache certaines colonnes pour petit écran, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 22/219: Esthetic change icon edit, Dany De Bontridder, 2017/12/18