Tak #1522 : Journaux peuvent être inactif

This commit is contained in:
Dany De Bontridder 2018-01-10 18:42:49 +01:00
parent 1e7bb6e6a4
commit 5b9362c903
7 changed files with 50 additions and 16 deletions

View file

@ -78,7 +78,9 @@ if ($action_frm == 'delete' )
$ledger->delete_ledger();
$sa="";
echo '<div id="jrn_name_div">';
echo '<h2 id="jrn_name">'.h($name). " est effacé"."</h2>";
echo '<h2 id="jrn_name">';
printf(_(" %s est effacé"),h($name));
echo "</h2>";
echo '</div>';
$show_menu=1;
}

View file

@ -2705,6 +2705,12 @@ class Acc_Ledger extends jrn_def_sql
$new=0;
$cn=$this->db;
echo $hidden;
$actif=new ISelect("jrn_enable");
$actif->value=[
["label"=>_("Activé"),"value"=>1],
["label"=>_("Désactivé"),"value"=>0]
];
$actif->selected=$this->jrn_enable;
require_once NOALYSS_TEMPLATE.'/param_jrn.php';
}
@ -2784,6 +2790,7 @@ class Acc_Ledger extends jrn_def_sql
$this->jrn_def_pj_pref=$jrn_def_pj_pref;
$this->jrn_deb_max_line=($min_row<1)?1:$min_row;
$this->jrn_def_description=$p_description;
$this->jrn_enable=$jrn_enable;
switch ($this->jrn_def_type)
{
case 'ACH':
@ -3239,6 +3246,13 @@ class Acc_Ledger extends jrn_def_sql
"image/bouton-plus.png");
return $str_add_button;
}
/**
* Check if a ledger is enabled , 1 for yes and 0 if disabled
*/
function is_enable()
{
return $this->db->get_value("select jrn_enable from jrn_def where jrn_def_id=$1",[$this->id]);
}
}

View file

@ -1094,6 +1094,7 @@ class Acc_Ledger_Search
for ($e=0;$e<count($p_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

@ -317,10 +317,10 @@ class User
switch ($p_access)
{
case 3:
$sql_access = " and uj_priv!= 'X'";
$sql_access = " and uj_priv!= 'X' ";
break;
case 2:
$sql_access = " and uj_priv = 'W'";
$sql_access = " and uj_priv = 'W' and jrn_enable=1 ";
break;
case 1:
@ -332,7 +332,7 @@ class User
jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_type_id,jrn_desc,uj_priv,
jrn_deb_max_line,jrn_cred_max_line,jrn_def_description
from jrn_def join jrn_type on jrn_def_type=jrn_type_id
join user_sec_jrn on uj_jrn_id=jrn_def_id
join user_sec_jrn on uj_jrn_id=jrn_def_id,jrn_enable
where
uj_login='" . $this->login . "'" .
$sql_type . $sql_access .
@ -340,9 +340,9 @@ class User
}
else
{
$sql_type = ($p_type == 'ALL') ? '' : "where jrn_def_type=upper('" . sql_string($p_type) . "')";
$sql_type = ($p_type == 'ALL') ? ' ' : "where jrn_def_type=upper('" . sql_string($p_type) . "') ";
$sql = "select jrn_def_id,jrn_def_type,jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_deb_max_line,jrn_cred_max_line,
jrn_type_id,jrn_desc,'W' as uj_priv,jrn_def_description
jrn_type_id,jrn_desc,'W' as uj_priv,jrn_def_description,jrn_enable
from jrn_def join jrn_type on jrn_def_type=jrn_type_id
$sql_type
order by jrn_Def_name";

View file

@ -266,7 +266,8 @@ class Jrn_Def_sql
,jrn_def_bank
,jrn_def_num_op
,jrn_def_id
,jrn_def_description) values ($1
,jrn_def_description,
jrn_enable) values ($1
,$2
,$3
,$4
@ -282,6 +283,7 @@ class Jrn_Def_sql
,$14
,$15
,$16
,1
) returning jrn_def_id";
$this->jrn_def_id = $this->db->get_value(
@ -325,6 +327,7 @@ class Jrn_Def_sql
,jrn_def_bank = $13
,jrn_def_num_op = $14
,jrn_def_description = $15
,jrn_enable=$17
where jrn_def_id= $16";
$res = $this->db->exec_sql(
$sql, array($this->jrn_def_name
@ -342,7 +345,9 @@ class Jrn_Def_sql
, $this->jrn_def_bank
, $this->jrn_def_num_op
, strip_tags($this->jrn_def_description)
, $this->jrn_def_id)
, $this->jrn_def_id
, $this->jrn_enable
)
);
}
@ -368,6 +373,7 @@ class Jrn_Def_sql
,jrn_def_bank
,jrn_def_num_op
,jrn_def_description
,jrn_enable
from public.jrn_def where jrn_def_id=$1";
/* please adapt */
$res = $this->db->get_array(

View file

@ -73,7 +73,14 @@ echo $str_add_button;
</tr>
<tr><td><INPUT TYPE="hidden" id="p_ech_lib" NAME="p_ech_lib" VALUE="echeance"></td>
</tr>
<tr>
<td style="width: 200px">
<?php echo _('Description') ?>
</TD>
<td style="width: 500px">
<?php echo $str_description; ?>
</td>
</tr>
<TR>
<TD><?php echo _('Type de journal')?> </TD>
<TD>
@ -113,15 +120,15 @@ echo $str_add_button;
</TD>
</tr>
<?php endif; ?>
<tr>
<td style="width: 200px">
<?php echo _('Description') ?>
</TD>
<td style="width: 500px">
<?php echo $str_description; ?>
<td>
<?=_("Journal actif")?>
</td>
</tr>
<td>
<?=$actif->input()?>
</td>
<?php endif; ?>
</TABLE>
<hr>
<?php

View file

@ -86,3 +86,7 @@ ALTER TABLE public.user_active_security ADD CONSTRAINT user_active_security_acti
insert into user_active_security (us_login,us_ledger,us_action) select user_name,'Y','Y' from profile_user;
alter table jrn_def add jrn_enable int;
alter table jrn_def alter jrn_enable set default 1;
update jrn_def set jrn_enable=1;
comment on column jrn_def.jrn_enable is 'Set to 1 if the ledger is enable ';