diff --git a/html/js/acc_ledger.js b/html/js/acc_ledger.js index 2c7315e1b..d6b288252 100644 --- a/html/js/acc_ledger.js +++ b/html/js/acc_ledger.js @@ -1298,7 +1298,9 @@ function manage_search_filter(p_obj) { * @see Acc_Ledger_Search */ function save_filter(p_div,p_dossier) { - var elt=['ledger_type','nb_jrn','date_start','date_end','date_paid_start','date_paid_end','desc','amount_min','amount_max','qcode','accounting']; + var elt=['ledger_type','nb_jrn','date_start','date_end', + 'date_paid_start','date_paid_end','desc','amount_min','amount_max','qcode','accounting', + 'operation_filter']; var eltValue={}; eltValue['gDossier']=p_dossier; eltValue['op']="save_filter"; @@ -1322,8 +1324,6 @@ function save_filter(p_div,p_dossier) { } } - //unpaid - eltValue['unpaid']=$(p_div+"unpaid").checked; new Ajax.Request('ajax_misc.php', { method:"POST", parameters:eltValue, @@ -1361,7 +1361,8 @@ function load_filter(p_div,p_dossier,p_filter_id) { try { var answer=req.responseJSON; console.log(answer); - var elt=['ledger_type','date_start','date_end','date_paid_start','date_paid_end','desc','amount_min','amount_max','qcode','accounting']; + var elt=['ledger_type','date_start','date_end','date_paid_start','date_paid_end', + 'desc','amount_min','amount_max','qcode','accounting','operation_filter']; for (var i=0;ipost("date_paid_start", 'string', NULL)); $new->setp("date_paid_end", $http->post("date_paid_end", 'string', NULL)); $new->setp("ledger_type", $http->post("ledger_type", 'string')); - $new->setp("unpaid", $http->post("unpaid", 'string', NULL)); + $new->setp("operation_filter", $http->post("operation_filter", 'string', NULL)); $new->setp("filter_name", h($http->post("filter_name", 'string'))); $aJrn=[]; $max=$http->post("nb_jrn"); diff --git a/include/class/acc_ledger_search.class.php b/include/class/acc_ledger_search.class.php index f9891a153..9ffc29292 100644 --- a/include/class/acc_ledger_search.class.php +++ b/include/class/acc_ledger_search.class.php @@ -204,15 +204,23 @@ class Acc_Ledger_Search $f_accounting->set_attribute('account', $this->div.'accounting'); $info=Icon_Action::infobulle(13); - $f_paid=new ICheckbox('unpaid', null, $this->div.'unpaid'); - $f_paid->selected=(isset($_REQUEST['unpaid']))?true:false; + // Status of the operation : paid, unpaid or all + $f_paid=new ISelect('operation_filter', null, $this->div.'operation_filter'); + $f_paid->value=array(["value"=>'all',"label"=>_("Toutes")], + ["value"=>'unpaid',"label"=>_("Non payées")], + ["value"=>'paid',"label"=>_("Payées")] + ); + $f_paid->selected=$http->request("operation_filter","string","all"); $r.=dossier::hidden(); $r.=HtmlInput::hidden('ledger_type', $this->type, $this->div."ledger_type"); - $r.=HtmlInput::hidden('ac', $_REQUEST['ac']); + $r.=HtmlInput::hidden('ac', $http->request('ac')); + + // to avoid to find a given operation if (isset($_REQUEST['hide_operation'])) - $r.=HtmlInput::hidden("hide_operation", $_REQUEST['hide_operation']); + $r.=HtmlInput::hidden("hide_operation", $http->request('hide_operation')); + ob_start(); $search_filter=$this->build_search_filter(); require_once NOALYSS_TEMPLATE.'/ledger_search.php'; @@ -526,12 +534,26 @@ class Acc_Ledger_Search $and=" and "; } - // Only the unpaid - if (isset($unpaid)) - { - $fil_paid=$and.SQL_LIST_UNPAID_INVOICE; - $and=" and "; + // Only the unpaid, paid or all + if ( isset($operation_filter)) { + switch ($operation_filter) { + case "unpaid": + $fil_paid=$and."(jr_rapt is null or jr_rapt = '') and jr_valid = true "; + $and=" and "; + break; + case "all": + $fil_paid=""; + break; + case "paid": + $fil_paid=$and."(jr_rapt is not null or jr_rapt = 'paid') and jr_valid = true "; + $and=" and "; + break; + default: + throw new Exception(_("ALS01 Etat inconnu"),10); + + } } + // Operations which must not be seen in the result if ( isset ($hide_operation) && trim($hide_operation) !="") { $fil_hide_operation=$and.sprintf( ' jr_id not in (%s)',sql_string($hide_operation)); diff --git a/include/constant.php b/include/constant.php index 5f5dc71a4..e0330010b 100644 --- a/include/constant.php +++ b/include/constant.php @@ -108,7 +108,7 @@ if ( !defined ("NOALYSS_PACKAGE_REPOSITORY")) { if ( ! defined ("SYSINFO_DISPLAY")) { define ("SYSINFO_DISPLAY",TRUE); } -define ("DBVERSION",140); +define ("DBVERSION",141); define ("MONO_DATABASE",25); define ("DBVERSIONREPO",18); define ('NOTFOUND','--not found--'); diff --git a/include/database/user_filter_sql.class.php b/include/database/user_filter_sql.class.php index 4f5e56959..72ebb83c9 100644 --- a/include/database/user_filter_sql.class.php +++ b/include/database/user_filter_sql.class.php @@ -54,7 +54,7 @@ class User_filter_SQL extends Noalyss_SQL , "date_paid_end"=>"date_paid_end" , "ledger_type"=>"ledger_type" , "all_ledger"=>"all_ledger" - ,"unpaid"=>"unpaid" + ,"operation_filter"=>"operation_filter" ,'filter_name'=>"filter_name" ); /* @@ -76,7 +76,7 @@ class User_filter_SQL extends Noalyss_SQL , "date_paid_end"=>"text" , "ledger_type"=>"text" , "all_ledger"=>"numeric" - ,"unpaid"=>"text" + ,"operation_filter"=>"text" ,"filter_name"=>"text" ); diff --git a/include/template/ledger_search.php b/include/template/ledger_search.php index 8d7b827d2..c22dd2086 100644 --- a/include/template/ledger_search.php +++ b/include/template/ledger_search.php @@ -80,7 +80,7 @@ echo $f_accounting->input(); ?> - +