noalyss-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Noalyss-commit] [noalyss] 30/73: Historic : search on currency


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 30/73: Historic : search on currency
Date: Fri, 28 May 2021 05:26:28 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit c9c6a6ea7d65f846d179b55478d10df99e828b0a
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Sun Apr 18 17:00:13 2021 +0200

    Historic : search on currency
---
 html/js/acc_ledger.js                      |  5 +++--
 include/ajax/ajax_search_filter.php        |  2 ++
 include/class/acc_ledger_search.class.php  | 25 +++++++++++++++++++++++--
 include/constant.php                       |  2 +-
 include/database/user_filter_sql.class.php |  2 ++
 include/export/export_histo_csv.php        |  5 +++++
 include/history_operation.inc.php          |  3 ++-
 include/sql/patch/upgrade157.sql           |  7 +++++++
 8 files changed, 45 insertions(+), 6 deletions(-)

diff --git a/html/js/acc_ledger.js b/html/js/acc_ledger.js
index f5e7201..0c68c4e 100644
--- a/html/js/acc_ledger.js
+++ b/html/js/acc_ledger.js
@@ -1328,7 +1328,7 @@ function manage_search_filter(p_obj) {
 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',
-        'operation_filter','tag_option'];
+        'operation_filter','tag_option','p_currency_code'];
     var eltValue={};
     var i =0;
     eltValue['gDossier']=p_dossier;
@@ -1397,7 +1397,8 @@ function load_filter(p_div,p_dossier,p_filter_id) {
                 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','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++) {
                     var idx=elt[i];
                     $(p_div+idx).value=answer[elt[i]];
diff --git a/include/ajax/ajax_search_filter.php 
b/include/ajax/ajax_search_filter.php
index dbf0109..3051422 100644
--- a/include/ajax/ajax_search_filter.php
+++ b/include/ajax/ajax_search_filter.php
@@ -63,6 +63,7 @@ if ($op=='save_filter')
         $new->setp("ledger_type", $http->post("ledger_type", 'string'));
         $new->setp("operation_filter", $http->post("operation_filter", 
'string', NULL));
         $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",'');
         
         if (is_array($tag) ) 
@@ -118,6 +119,7 @@ if ($op=="load_filter")
     $record['r_jrn']=explode(",", $record['r_jrn']);
     $record['tag']=explode(",",$record['uf_tag']);
     $record['tag_option']=$record["uf_tag_option"];
+    $record['p_currency_code']=$record['uf_currency_code'];
     $result=array_merge($answer, $record);
 
 
diff --git a/include/class/acc_ledger_search.class.php 
b/include/class/acc_ledger_search.class.php
index 81527a6..b59a5fe 100644
--- a/include/class/acc_ledger_search.class.php
+++ b/include/class/acc_ledger_search.class.php
@@ -229,6 +229,17 @@ class Acc_Ledger_Search
         if (isset($_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();
         $search_filter=$this->build_search_filter();
         require_once NOALYSS_TEMPLATE.'/ledger_search.php';
@@ -404,7 +415,10 @@ class Acc_Ledger_Search
                end as total_invoice,
             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
              jrn as X 
              left join jrn_note using(jr_id)
@@ -458,6 +472,7 @@ class Acc_Ledger_Search
         $fil_date_paid='';
         $fil_hide_operation='';
         $fil_tag='';
+        $fil_currency="";
 
         $and='';
         $g_user=new User($this->cn);
@@ -641,9 +656,15 @@ class Acc_Ledger_Search
                     " from user_sec_jrn where ".
                     " 
uj_login='".sql_string($_SESSION[SESSION_KEY.'g_user'])."'".
                     " 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.
-            
$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;
         
         // Q?? Why do we return where if it is included in SQL ?
diff --git a/include/constant.php b/include/constant.php
index 1f88757..58197ae 100644
--- a/include/constant.php
+++ b/include/constant.php
@@ -113,7 +113,7 @@ if ( !defined ("NOALYSS_PACKAGE_REPOSITORY")) {
 if ( ! defined ("SYSINFO_DISPLAY")) {
     define ("SYSINFO_DISPLAY",TRUE);
 }
-define ("DBVERSION",157);
+define ("DBVERSION",158);
 define ("MONO_DATABASE",25);
 define ("DBVERSIONREPO",19);
 define ('NOTFOUND','--not found--');
diff --git a/include/database/user_filter_sql.class.php 
b/include/database/user_filter_sql.class.php
index 3a1557d..d43e3c5 100644
--- a/include/database/user_filter_sql.class.php
+++ b/include/database/user_filter_sql.class.php
@@ -58,6 +58,7 @@ class User_filter_SQL extends Noalyss_SQL
             ,'filter_name'=>"filter_name"
             ,'uf_tag'=>'uf_tag'
             ,'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"
             ,'uf_tag'=>'text'
             ,'uf_tag_option'=>'numeric'
+            ,'uf_currency_code'=>'numeric'
         );
 
 
diff --git a/include/export/export_histo_csv.php 
b/include/export/export_histo_csv.php
index 251fe0f..6b80266 100644
--- a/include/export/export_histo_csv.php
+++ b/include/export/export_histo_csv.php
@@ -47,6 +47,8 @@ $title[]=_("Tiers");
 $title[]=_("Description");
 $title[]=_("Note");
 $title[]=_("Montant opération");
+$title[]=_("Code Devise");
+$title[]=_("Taux");
 $export=new Noalyss_Csv("histo");
 $export->send_header();
 $export->write_header($title);
@@ -74,6 +76,9 @@ for ($i=0;$i<count($res);$i++)
                if ( $positive !='' ) $amount=$positive;
       }
     $export->add($amount,"number");
+    $export->add($res[$i]['cr_code_iso']);
+    $export->add($res[$i]['currency_rate'],"number");
+    
 
     $export->write();
 
diff --git a/include/history_operation.inc.php 
b/include/history_operation.inc.php
index 69a0359..7874d2e 100644
--- a/include/history_operation.inc.php
+++ b/include/history_operation.inc.php
@@ -175,7 +175,8 @@ echo '</form>';
  */
 $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',
-                                   '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']))
 {
     foreach ($a_search_opr_jrn as $k => $v)
diff --git a/include/sql/patch/upgrade157.sql b/include/sql/patch/upgrade157.sql
new file mode 100644
index 0000000..12d2110
--- /dev/null
+++ b/include/sql/patch/upgrade157.sql
@@ -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 ;
\ No newline at end of file



reply via email to

[Prev in Thread] Current Thread [Next in Thread]