Hide inactive ledgers

This commit is contained in:
sparkyx 2025-01-27 15:36:36 +01:00
parent ba773b09d0
commit 1bb428f2f2
6 changed files with 24 additions and 17 deletions

View file

@ -1240,22 +1240,21 @@ class Acc_Ledger_Search
return array($count, $r);
}
/**
* return the html code to create an hidden div and a button
* @brief return the html code to create an hidden div and a button
* to show this DIV. This contains all the available ledgers
* for the user in READ or RW
*@param $p_selected is an array of checkbox
*@param $p_div div suffix for the list of ledgers
*@param $p_div div suffix for the list of ledgers, base for building the DOMID of elements from the DIV
*@note the choosen ledger are stored in the array r_jrn (_GET)
*/
function select_ledger($p_selected,$p_div)
{
global $g_user;
$r = '';
/* security : filter ledger on user */
$p_array = $g_user->get_ledger($this->type, 3,FALSE);
$r = '';
/* security : filter ledger on user */
$p_array = $g_user->get_ledger($this->type, 3,false);
ob_start();
/* create a hidden div for the ledger */
echo '<div id="div_jrn'.$p_div.'" >';
@ -1290,7 +1289,7 @@ class Acc_Ledger_Search
for ($e=0;$e<$nb_array;$e++)
{
$row=$p_array[$e];
// if ( $row['jrn_enable']==0) continue;
$r=new ICheckBox($p_div.'r_jrn'.$e,$row['jrn_def_id']);
$r->set_attribute("ledger_type", $row['jrn_def_type']);
$idx=$row['jrn_def_id'];

View file

@ -583,7 +583,7 @@ class Noalyss_User
[uj_priv]
@endverbatim
*/
function get_ledger($p_type='ALL', $p_access=3, $disable=TRUE)
function get_ledger($p_type='ALL', $p_access=3, $all=TRUE)
{
$p_type=strtoupper($p_type);
if (!in_array($p_type, ["FIN", "ALL", "ODS", "VEN", 'ACH']))
@ -591,7 +591,7 @@ class Noalyss_User
record_log(sprintf("UGL1, p_type %s", $p_type));
throw new Exception("UGL1"._("Type incorrecte"));
}
if ($disable==TRUE)
if ($all==TRUE)
{
$sql_enable="";
}

View file

@ -39,6 +39,7 @@ class Package_Repository
*/
function __construct()
{
if ( DEBUGNOALYSS > 1) self::$time_cache_second=1;
// Check we can resolve the name
$host=parse_url(NOALYSS_PACKAGE_REPOSITORY,PHP_URL_HOST);
$file=$_ENV['TMP']."/web.xml";

View file

@ -38,14 +38,14 @@ $exercice =$http->get("exercice","string",$user_exercice);
if ($g_user->Admin() == 0 && $g_user->is_local_admin() == 0 && $g_user->get_status_security_ledger()==1)
{
$sql = "select jrn_def_id,jrn_def_name
from jrn_def join jrn_type on jrn_def_type=jrn_type_id
from jrn_def a join jrn_type on jrn_def_type=jrn_type_id
join user_sec_jrn on uj_jrn_id=jrn_def_id
where
uj_login=$1
and uj_priv in ('R','W')
and ( jrn_enable=1
or
exists (select 1 from jrn where jr_tech_per in (select p_id from parm_periode where p_exercice=$2)))
exists (select 1 from jrn where jr_tech_per in (select p_id from parm_periode where p_exercice=$2 ) and jr_def_id=a.jrn_def_id))
order by jrn_def_name
";
$ret = $cn->make_array($sql,0,array($g_user->login,$exercice));
@ -53,9 +53,14 @@ if ($g_user->Admin() == 0 && $g_user->is_local_admin() == 0 && $g_user->get_sta
else
{
$ret = $cn->make_array("select jrn_def_id,jrn_def_name
from jrn_def join jrn_type on jrn_def_type=jrn_type_id
from jrn_def a
join jrn_type on jrn_def_type=jrn_type_id
where
jrn_enable=1 or exists(select 1 from jrn where jr_tech_per in (select p_id from parm_periode where p_exercice=$1))
jrn_enable=1 or exists(select 1
from jrn
where
jr_tech_per in (select p_id from parm_periode where p_exercice=$1)
and jr_def_id=a.jrn_def_id)
order by jrn_def_name
",0,[$exercice]);
}

View file

@ -44,7 +44,9 @@ class IText extends HtmlInput
$this->require=false;
$this->css_size="";
}
/*!\brief show the html input of the widget*/
/*!
\brief show the html input of the widget
*/
public function input($p_name=null,$p_value=null)
{
$this->name=($p_name==null)?$this->name:$p_name;

View file

@ -52,8 +52,8 @@ $idateend->value = $http->get('to', 'date', $a_limit[1]);
<?= $ivatnumber->input(); ?>
<label for="p_jrn">Journal</label>
<?php
$a_ledger_purchase=$g_user->get_ledger('ACH',3);
$a_ledger_sale=$g_user->get_ledger('VEN',3);
$a_ledger_purchase=$g_user->get_ledger('ACH',3,all:false);
$a_ledger_sale=$g_user->get_ledger('VEN',3,all:false);
$a_ledger=array_merge($a_ledger_sale??[],$a_ledger_purchase??[]);
if ( DEBUGNOALYSS > 1 ) echo \Noalyss\Dbg::hidden_info("a_ledger",$a_ledger);
$select_value=array();