Historic : search on currency

This commit is contained in:
sparkyx 2021-04-18 17:00:13 +02:00
parent 8708c63b71
commit c9c6a6ea7d
8 changed files with 45 additions and 6 deletions

View file

@ -1328,7 +1328,7 @@ function manage_search_filter(p_obj) {
function save_filter(p_div,p_dossier) { function save_filter(p_div,p_dossier) {
var elt=['ledger_type','nb_jrn','date_start','date_end', var elt=['ledger_type','nb_jrn','date_start','date_end',
'date_paid_start','date_paid_end','desc','amount_min','amount_max','qcode','accounting', 'date_paid_start','date_paid_end','desc','amount_min','amount_max','qcode','accounting',
'operation_filter','tag_option']; 'operation_filter','tag_option','p_currency_code'];
var eltValue={}; var eltValue={};
var i =0; var i =0;
eltValue['gDossier']=p_dossier; eltValue['gDossier']=p_dossier;
@ -1397,7 +1397,8 @@ function load_filter(p_div,p_dossier,p_filter_id) {
var answer=req.responseJSON; var answer=req.responseJSON;
console.log(answer); console.log(answer);
var elt=['ledger_type','date_start','date_end','date_paid_start','date_paid_end', var elt=['ledger_type','date_start','date_end','date_paid_start','date_paid_end',
'desc','amount_min','amount_max','qcode','accounting','operation_filter','tag_option']; 'desc','amount_min','amount_max','qcode','accounting','operation_filter','tag_option'
,'p_currency_code'];
for (var i=0;i<elt.length;i++) { for (var i=0;i<elt.length;i++) {
var idx=elt[i]; var idx=elt[i];
$(p_div+idx).value=answer[elt[i]]; $(p_div+idx).value=answer[elt[i]];

View file

@ -63,6 +63,7 @@ if ($op=='save_filter')
$new->setp("ledger_type", $http->post("ledger_type", 'string')); $new->setp("ledger_type", $http->post("ledger_type", 'string'));
$new->setp("operation_filter", $http->post("operation_filter", 'string', NULL)); $new->setp("operation_filter", $http->post("operation_filter", 'string', NULL));
$new->setp("filter_name", h($http->post("filter_name", 'string'))); $new->setp("filter_name", h($http->post("filter_name", 'string')));
$new->setp("uf_currency_code", h($http->post("p_currency_code", 'number',-1)));
$tag=$http->post("tag","string",''); $tag=$http->post("tag","string",'');
if (is_array($tag) ) if (is_array($tag) )
@ -118,6 +119,7 @@ if ($op=="load_filter")
$record['r_jrn']=explode(",", $record['r_jrn']); $record['r_jrn']=explode(",", $record['r_jrn']);
$record['tag']=explode(",",$record['uf_tag']); $record['tag']=explode(",",$record['uf_tag']);
$record['tag_option']=$record["uf_tag_option"]; $record['tag_option']=$record["uf_tag_option"];
$record['p_currency_code']=$record['uf_currency_code'];
$result=array_merge($answer, $record); $result=array_merge($answer, $record);

View file

@ -229,6 +229,17 @@ class Acc_Ledger_Search
if (isset($_REQUEST['single_operation'])) if (isset($_REQUEST['single_operation']))
$r.=HtmlInput::hidden("single_operation", $http->request('single_operation')); $r.=HtmlInput::hidden("single_operation", $http->request('single_operation'));
//------
// Devise
///-------
$currency_id=$http->request("p_currency_code","string",-1);
$acc_currency=new Acc_Currency($this->cn);
$sCurrency=$acc_currency->select_currency();
$sCurrency->id=$this->div."p_currency_code";
$sCurrency->value[]=array("label"=>_("Toutes"),"value"=>-1);
$sCurrency->selected=$currency_id;
ob_start(); ob_start();
$search_filter=$this->build_search_filter(); $search_filter=$this->build_search_filter();
require_once NOALYSS_TEMPLATE.'/ledger_search.php'; require_once NOALYSS_TEMPLATE.'/ledger_search.php';
@ -404,7 +415,10 @@ class Acc_Ledger_Search
end as total_invoice, end as total_invoice,
jr_date_paid, jr_date_paid,
to_char(jr_date_paid,'DD.MM.YY') as str_jr_date_paid, to_char(jr_date_paid,'DD.MM.YY') as str_jr_date_paid,
cas.jr_id as analytic_op cas.jr_id as analytic_op,
x.currency_id,
(select cr_code_iso from currency c where c.id=x.currency_id) cr_code_iso,
x.currency_rate
from from
jrn as X jrn as X
left join jrn_note using(jr_id) left join jrn_note using(jr_id)
@ -458,6 +472,7 @@ class Acc_Ledger_Search
$fil_date_paid=''; $fil_date_paid='';
$fil_hide_operation=''; $fil_hide_operation='';
$fil_tag=''; $fil_tag='';
$fil_currency="";
$and=''; $and='';
$g_user=new User($this->cn); $g_user=new User($this->cn);
@ -641,9 +656,15 @@ class Acc_Ledger_Search
" from user_sec_jrn where ". " from user_sec_jrn where ".
" uj_login='".sql_string($_SESSION[SESSION_KEY.'g_user'])."'". " uj_login='".sql_string($_SESSION[SESSION_KEY.'g_user'])."'".
" and uj_priv in ('R','W'))"; " and uj_priv in ('R','W'))";
$and=" and ";
}
if ( isset($p_currency_code) && $p_currency_code !=-1) {
$fil_currency=$and." x.currency_id = ".sql_string($p_currency_code);
$and=" and ";
} }
$where=$fil_ledger.$fil_amount.$fil_date.$fil_desc.$fil_sec.$fil_amount. $where=$fil_ledger.$fil_amount.$fil_date.$fil_desc.$fil_sec.$fil_amount.
$fil_qcode.$fil_paid.$fil_account.$fil_date_paid.$fil_hide_operation.$fil_tag; $fil_qcode.$fil_paid.$fil_account.$fil_date_paid.$fil_hide_operation.$fil_tag.$fil_currency;
$sql.=" where ".$where; $sql.=" where ".$where;
// Q?? Why do we return where if it is included in SQL ? // Q?? Why do we return where if it is included in SQL ?

View file

@ -113,7 +113,7 @@ if ( !defined ("NOALYSS_PACKAGE_REPOSITORY")) {
if ( ! defined ("SYSINFO_DISPLAY")) { if ( ! defined ("SYSINFO_DISPLAY")) {
define ("SYSINFO_DISPLAY",TRUE); define ("SYSINFO_DISPLAY",TRUE);
} }
define ("DBVERSION",157); define ("DBVERSION",158);
define ("MONO_DATABASE",25); define ("MONO_DATABASE",25);
define ("DBVERSIONREPO",19); define ("DBVERSIONREPO",19);
define ('NOTFOUND','--not found--'); define ('NOTFOUND','--not found--');

View file

@ -58,6 +58,7 @@ class User_filter_SQL extends Noalyss_SQL
,'filter_name'=>"filter_name" ,'filter_name'=>"filter_name"
,'uf_tag'=>'uf_tag' ,'uf_tag'=>'uf_tag'
,'uf_tag_option'=>'uf_tag_option' ,'uf_tag_option'=>'uf_tag_option'
,'uf_currency_code'=>'uf_currency_code'
); );
/* /*
@ -83,6 +84,7 @@ class User_filter_SQL extends Noalyss_SQL
,"filter_name"=>"text" ,"filter_name"=>"text"
,'uf_tag'=>'text' ,'uf_tag'=>'text'
,'uf_tag_option'=>'numeric' ,'uf_tag_option'=>'numeric'
,'uf_currency_code'=>'numeric'
); );

View file

@ -47,6 +47,8 @@ $title[]=_("Tiers");
$title[]=_("Description"); $title[]=_("Description");
$title[]=_("Note"); $title[]=_("Note");
$title[]=_("Montant opération"); $title[]=_("Montant opération");
$title[]=_("Code Devise");
$title[]=_("Taux");
$export=new Noalyss_Csv("histo"); $export=new Noalyss_Csv("histo");
$export->send_header(); $export->send_header();
$export->write_header($title); $export->write_header($title);
@ -74,6 +76,9 @@ for ($i=0;$i<count($res);$i++)
if ( $positive !='' ) $amount=$positive; if ( $positive !='' ) $amount=$positive;
} }
$export->add($amount,"number"); $export->add($amount,"number");
$export->add($res[$i]['cr_code_iso']);
$export->add($res[$i]['currency_rate'],"number");
$export->write(); $export->write();

View file

@ -175,7 +175,8 @@ echo '</form>';
*/ */
$r = HtmlInput::get_to_hidden(array('l', 'date_paid_start','date_paid_end', $r = HtmlInput::get_to_hidden(array('l', 'date_paid_start','date_paid_end',
'date_start', 'date_end', 'desc', 'amount_min', 'amount_max', 'qcode','operation_filter', 'date_start', 'date_end', 'desc', 'amount_min', 'amount_max', 'qcode','operation_filter',
'accounting', 'unpaid', 'gDossier', 'ledger_type', 'p_action','search_optag_option')); 'accounting', 'unpaid', 'gDossier', 'ledger_type',
'p_action','search_optag_option','p_currency_code'));
if (isset($_GET['search_opr_jrn'])) if (isset($_GET['search_opr_jrn']))
{ {
foreach ($a_search_opr_jrn as $k => $v) foreach ($a_search_opr_jrn as $k => $v)

View file

@ -0,0 +1,7 @@
begin;
alter table user_filter add column uf_currency_code int;
comment on column user_filter.uf_currency_code is 'correspond to currency.id';
insert into version (val,v_description) values (158,'Filter Currency search');
commit ;