0002405: CARD : Fiche affiche toutes les fiches ou seulement actives
This commit is contained in:
parent
b2159d0c2e
commit
a08c0bfb80
7 changed files with 135 additions and 38 deletions
|
|
@ -25,8 +25,8 @@ BODY {
|
|||
color:darkblue !important;
|
||||
background-color:#FCFDFD;
|
||||
--hover : rgba(108, 130, 208, 0.9);
|
||||
--border-size:8px;
|
||||
--accent-color:lightblue;
|
||||
--border-size:6px;
|
||||
--accent-color:lightblue;
|
||||
--input-color:#4b4b91;
|
||||
--color-red:Crimson;
|
||||
--color-blue2: cornflowerblue;
|
||||
|
|
|
|||
|
|
@ -1560,26 +1560,40 @@ class Fiche
|
|||
else
|
||||
return 1;
|
||||
}
|
||||
/*!\brief get all the card from a categorie
|
||||
/*!
|
||||
* \brief get all the card from a categorie
|
||||
*\param $p_cn database connx
|
||||
*\param $pFd_id is the category id
|
||||
*\param $card_category_id is the category id
|
||||
*\param $p_order for the sort, possible values is name_asc,name_desc or nothing
|
||||
* \param $inactive int possible values : 1 = inactive included, 0 = only active ones (default 1)
|
||||
*\return an array of card, but only the fiche->id is set
|
||||
*/
|
||||
static function get_fiche_def($p_cn,$pFd_id,$p_order='')
|
||||
static function get_fiche_def($p_cn,$card_category_id,$p_order='',$inactive=1)
|
||||
{
|
||||
// var $cond_active string SQL cond for filtering active or not
|
||||
$cond_active=($inactive == 1)?"":" and f_enable='1' ";
|
||||
|
||||
switch ($p_order)
|
||||
{
|
||||
case 'name_asc':
|
||||
$sql='select f_id,ad_value from fiche join fiche_detail using (f_id) where ad_id=1 and fd_id=$1 order by 2 asc';
|
||||
$sql="select f_id,ad_value from fiche join fiche_detail using (f_id)
|
||||
where
|
||||
ad_id=1
|
||||
and fd_id=$1
|
||||
$cond_active
|
||||
order by 2 asc";
|
||||
break;
|
||||
case 'name_desc':
|
||||
$sql='select f_id,ad_value from fiche join fiche_detail using (f_id) where ad_id=1 and fd_id=$1 order by 2 desc';
|
||||
$sql="select f_id,ad_value from fiche join fiche_detail using (f_id)
|
||||
where ad_id=1
|
||||
and fd_id=$1
|
||||
$cond_active
|
||||
order by 2 desc";
|
||||
break;
|
||||
default:
|
||||
$sql='select f_id from fiche where fd_id=$1 ';
|
||||
$sql="select f_id from fiche where fd_id=$1 $cond_active ";
|
||||
}
|
||||
$array=$p_cn->get_array($sql,array($pFd_id));
|
||||
$array=$p_cn->get_array($sql,array($card_category_id));
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -337,16 +337,18 @@ $order
|
|||
* \brief Get all the card where the fiche_def.fd_id is given in parameter
|
||||
* \param $step = 0 we don't use the offset, page_size,...
|
||||
* $step = 1 we use the jnr_bar_nav
|
||||
*
|
||||
* \param $inactive int possible values : 1 = inactive included, 0 = only active ones (default 1)
|
||||
* \return array ('f_id'=>..,'ad_value'=>..)
|
||||
*\see fiche
|
||||
*/
|
||||
function get_by_type($step=0)
|
||||
function get_by_type($step=0,$inactive=1)
|
||||
{
|
||||
// var $cond_active string SQL cond for filtering active or not
|
||||
$cond_active=($inactive == 1)?"":" and f_enable='1' ";
|
||||
$sql="select f_id,ad_value
|
||||
from
|
||||
fiche join fiche_detail using(f_id)
|
||||
where ad_id=1 and fd_id=$1 order by 2";
|
||||
where ad_id=1 and fd_id=$1 $cond_active order by 2";
|
||||
|
||||
// we use navigation_bar
|
||||
if ($step == 1 && $_SESSION[SESSION_KEY.'g_pagesize'] != -1 )
|
||||
|
|
@ -361,18 +363,24 @@ $order
|
|||
return $Ret;
|
||||
}
|
||||
/*!
|
||||
* \brief Get all the card where the fiche_def.frd_id is given in parameter
|
||||
* \return array of fiche or null is nothing is found
|
||||
* \brief Get all the card where the fiche_def.frd_id is given in parameter, it is the template for category
|
||||
*\param $inactive int possible values : 1 = inactive included, 0 = only active ones (default 1)
|
||||
* \param $template_category int FICHE_DEF_REF.FRD_ID
|
||||
* \return array of Fiche or null is nothing is found
|
||||
*
|
||||
*/
|
||||
function get_by_category($p_cat)
|
||||
function get_by_category($template_category,$inactive=1)
|
||||
{
|
||||
// var $cond_active string SQL cond for filtering active or not
|
||||
$cond_active=($inactive == 1)?"":" and f_enable='1' ";
|
||||
$sql="select f_id,ad_value
|
||||
from
|
||||
fiche join fiche_def using(fd_id)
|
||||
join fiche_detail using(f_id)
|
||||
where ad_id=1 and frd_id=$1 order by 2 ";
|
||||
where ad_id=1 and frd_id=$1 $cond_active
|
||||
order by 2 ";
|
||||
|
||||
$Ret=$this->cn->exec_sql($sql,array($p_cat));
|
||||
$Ret=$this->cn->exec_sql($sql,array($template_category));
|
||||
if ( ($Max=Database::num_row($Ret)) == 0 )
|
||||
return null;
|
||||
$all[0]=new Fiche($this->cn);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ if ( isset ($_GET['fd_id']))
|
|||
{
|
||||
$fiche_def=new Fiche_Def($cn,$http->get('fd_id',"number"));
|
||||
$fiche=new Fiche($cn);
|
||||
$e=$fiche_def->get_by_type();
|
||||
$e=$fiche_def->get_by_type(inactive: $http->request('inactive'));
|
||||
$o=0;
|
||||
// Heading
|
||||
$fiche_def->GetAttribut();
|
||||
|
|
|
|||
|
|
@ -33,30 +33,46 @@ global $g_user, $g_failed;
|
|||
/**
|
||||
* Show first the form
|
||||
*/
|
||||
/* category */
|
||||
/* var categorie ISelect select card category */
|
||||
$categorie = new ISelect('cat');
|
||||
$categorie->value = $cn->make_array("select fd_id,fd_label||' ('||(select count(*) from fiche where fiche.fd_id=fiche_def.fd_id)::text||')' from fiche_def order by fd_label");
|
||||
$categorie->selected = $http->get('cat','number',0);
|
||||
|
||||
// var $str_categorie string
|
||||
$str_categorie = $categorie->input();
|
||||
$ac = $http->request('ac');
|
||||
|
||||
// var $icall ICheckBox : all card or only the current category
|
||||
$icall = new ICheckBox("allcard", 1);
|
||||
$icall->selected = (isset($_GET['allcard'])) ? 1 : 0;
|
||||
// var $str_icall string
|
||||
$str_icall = $icall->input();
|
||||
/* periode */
|
||||
|
||||
/* var $exercice string current exercice (depending of user's period preferences) */
|
||||
$exercice = $g_user->get_exercice();
|
||||
$iperiode = new Periode($cn);
|
||||
list ($first, $last) = $iperiode->get_limit($exercice);
|
||||
|
||||
/*
|
||||
* var $periode_start IDate start date
|
||||
* var $periode_end IDate end date
|
||||
*/
|
||||
$periode_start = new IDate('start');
|
||||
$periode_end = new IDate('end');
|
||||
|
||||
$periode_start->value = $http->get('start',"date",$first->first_day());
|
||||
$periode_end->value = $http->get('end','date', $last->last_day());
|
||||
|
||||
/*
|
||||
* var $str_start string date dd.mm.yyyy
|
||||
* var $str_end string date dd.mm.yyyy
|
||||
*/
|
||||
$str_start = $periode_start->input();
|
||||
$str_end = $periode_end->input();
|
||||
|
||||
/* histo ou summary */
|
||||
|
||||
|
||||
/* var $histo ISelect choice */
|
||||
$histo = new ISelect('histo');
|
||||
$histo->value = array(
|
||||
array('value' => -1, 'label' => _('Liste')),
|
||||
|
|
@ -76,6 +92,11 @@ $histo->javascript = 'onchange="if (this.value==3 || this.value==-1) {
|
|||
|
||||
$histo->selected = $http->get('histo',"number", -1);
|
||||
$str_histo = $histo->input();
|
||||
|
||||
// $inactive checkbox include inactive cards
|
||||
$inactive = new ICheckbox ('inactive',1);
|
||||
$inactive->selected=$http->request('inactive','string',0);
|
||||
$str_inactive=$inactive->input();
|
||||
?>
|
||||
<div class="content">
|
||||
|
||||
|
|
@ -103,7 +124,6 @@ if (!isset($_GET['cat_display']))
|
|||
|
||||
$fd_id =$categorie->selected ;
|
||||
|
||||
$array = Fiche::get_fiche_def($cn,$categorie->selected , 'name_asc');
|
||||
|
||||
$h_add_card_b = new IButton('add_card');
|
||||
$h_add_card_b->label = _('Créer une nouvelle fiche');
|
||||
|
|
@ -121,6 +141,8 @@ if ( $allcard == 0 ){
|
|||
echo h1($fiche_def->label,"");
|
||||
echo h2($fiche_def->fd_description,"");
|
||||
}
|
||||
$array = Fiche::get_fiche_def($cn,$categorie->selected , 'name_asc');
|
||||
|
||||
// if no card found , stop here
|
||||
if ($array == null && $allcard == 0 && $histo->selected != 3 )
|
||||
{
|
||||
|
|
@ -138,7 +160,9 @@ echo '<div class="content">';
|
|||
* ***************************************************************************************************************/
|
||||
if ($histo->selected == -1)
|
||||
{
|
||||
$write = $g_user->check_action(FICADD);
|
||||
$array = Fiche::get_fiche_def($cn,$categorie->selected , 'name_asc',inactive: $inactive->selected);
|
||||
|
||||
$write = $g_user->check_action(FICADD);
|
||||
/**
|
||||
* If ask for move or delete
|
||||
*/
|
||||
|
|
@ -152,7 +176,7 @@ if ($histo->selected == -1)
|
|||
*/
|
||||
if (isset($_POST['move'])&& $_POST['move'] == 1)
|
||||
{
|
||||
$move_to=$http->post("move_to","number");
|
||||
$move_to=$http->post("move_to","number");
|
||||
for ($i = 0; $i < count($ack); $i++)
|
||||
{
|
||||
$fiche = new Fiche($cn, $ack[$i]);
|
||||
|
|
@ -188,15 +212,29 @@ if ($histo->selected == -1)
|
|||
}
|
||||
}
|
||||
$sql = "select f_id from fiche ";
|
||||
if ($allcard == 1)
|
||||
|
||||
// build SQL : all cards or only the selected category , with inactive cards included or only active
|
||||
if ($allcard == 1 && $inactive->selected == 1)
|
||||
{
|
||||
// all categories , including inactive cards
|
||||
$cond = "";
|
||||
}
|
||||
else
|
||||
}elseif ($allcard == 1 && $inactive->selected== 0)
|
||||
{
|
||||
// all categories and only active cards
|
||||
$cond = " where f.f_enable = '1' ";
|
||||
}
|
||||
elseif ($allcard == 0 && $inactive->selected == 1)
|
||||
{
|
||||
// one categorie , including inactive cards
|
||||
$p_cat=$http->get("cat","number");
|
||||
$cond = " where f.fd_id = " . sql_string($p_cat);
|
||||
}
|
||||
}elseif ($allcard == 0 && $inactive->selected == 0) {
|
||||
// one categorie , without inactive cards
|
||||
$p_cat=$http->get("cat","number");
|
||||
$cond = " where f.fd_id = " . sql_string($p_cat);
|
||||
$cond .= " and f.f_enable='1'";
|
||||
}
|
||||
|
||||
// Create nav bar
|
||||
$max = $cn->get_value("select count(*) from fiche as f " . $cond);
|
||||
|
||||
|
|
@ -226,17 +264,19 @@ if ($histo->selected == -1)
|
|||
* ******************************************************************************************************************************** */
|
||||
if ($histo->selected == 3)
|
||||
{
|
||||
$cat_card = new Fiche_Def($cn);
|
||||
$array = Fiche::get_fiche_def($cn,$categorie->selected , 'name_asc',inactive: $inactive->selected);
|
||||
|
||||
$cat_card = new Fiche_Def($cn);
|
||||
$cat_card->id =$http->get('cat','number');
|
||||
$aHeading = $cat_card->getAttribut();
|
||||
$str_add_card="";
|
||||
if ( $allcard == 0 ) {
|
||||
$h_add_card_b = new IButton('add_card');
|
||||
$h_add_card_b->label = _('Créer une nouvelle fiche');
|
||||
$h_add_card_b->javascript = "dis_blank_card({gDossier:$gDossier,fd_id:$fd_id,after_save:1,ref:2})";
|
||||
$str_add_card=$h_add_card_b->input();
|
||||
}
|
||||
echo $str_add_card;
|
||||
$str_add_card="";
|
||||
if ( $allcard == 0 ) {
|
||||
$h_add_card_b = new IButton('add_card');
|
||||
$h_add_card_b->label = _('Créer une nouvelle fiche');
|
||||
$h_add_card_b->javascript = "dis_blank_card({gDossier:$gDossier,fd_id:$fd_id,after_save:1,ref:2})";
|
||||
$str_add_card=$h_add_card_b->input();
|
||||
}
|
||||
echo $str_add_card;
|
||||
require_once NOALYSS_TEMPLATE.'/result_cat_card_summary.php';
|
||||
|
||||
$hid = new IHidden();
|
||||
|
|
@ -245,13 +285,16 @@ if ($histo->selected == 3)
|
|||
echo
|
||||
HtmlInput::submit('bt_csv', _("Export CSV")) .
|
||||
HtmlInput::hidden('act', "CSV:fiche") .
|
||||
HtmlInput::hidden('inactive', $inactive->selected) .
|
||||
$hid->input("type", "fiche") .
|
||||
$hid->input("ac", $http->request('ac')) .
|
||||
$hid->input("fd_id", $http->request('cat',"number"));
|
||||
|
||||
echo "</form>";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$cat=$http->get("cat","number");
|
||||
$phisto=$http->get("histo","number");
|
||||
|
||||
|
|
@ -329,7 +372,7 @@ if ( $histo->selected == 8)
|
|||
if ( $histo->selected == 7)
|
||||
{
|
||||
$bal=new Balance_Age($cn);
|
||||
|
||||
|
||||
$cat=$http->get("cat","number");
|
||||
$export_csv = '<FORM METHOD="get" ACTION="export.php" style="display:inline">';
|
||||
$export_csv .=HtmlInput::request_to_hidden(array('gDossier','ac','p_let','p_date_start'));
|
||||
|
|
|
|||
|
|
@ -21,5 +21,18 @@
|
|||
<td><?php echo _('Pour toutes les catégories')?></td>
|
||||
<td><?php echo $str_icall?></td>
|
||||
</tr>
|
||||
<tr id="inactive_card">
|
||||
<td><?=_('Inclure les fiches inactives')?></td>
|
||||
<td><?=$str_inactive?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<script>
|
||||
id$('histo').addEventListener('click',function(evt) {
|
||||
let val = id$('histo').value;
|
||||
if ( val == -1 || val == 3) {
|
||||
id$('inactive_card').show();
|
||||
} else {
|
||||
id$('inactive_card').hide();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
@ -830,4 +830,23 @@ where
|
|||
$this->g_connection->exec_sql('delete from tmp_pcmn where pcm_val=$1',['600TESTALPHA']);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox test Fiche::get_fiche_def
|
||||
* @covers Fiche::get_fiche_def
|
||||
* @return void
|
||||
*/
|
||||
public function testGetFicheDef()
|
||||
{
|
||||
$res=Fiche::get_fiche_def($this->g_connection, 5);
|
||||
$this->assertEquals(7,count($res),"number of all cards incorrect ");
|
||||
$this->g_connection->exec_sql ('update fiche set f_enable=$1 where f_id = $2 or f_id=$3',[0,34,35]);
|
||||
$res=Fiche::get_fiche_def($this->g_connection, 5);
|
||||
$this->assertEquals(7,count($res),"number of all cards incorrect ");
|
||||
$res=Fiche::get_fiche_def($this->g_connection, 5,inactive:0);
|
||||
$this->assertEquals(5,count($res),"number of all cards incorrect ");
|
||||
|
||||
|
||||
$this->g_connection->exec_sql ('update fiche set f_enable=$1 where f_id = $2 or f_id=$3',[1,34,35]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue