Periode : change with exercice
This commit is contained in:
parent
4efeffcabd
commit
a73bac9084
3 changed files with 71 additions and 3 deletions
|
|
@ -245,6 +245,47 @@ if (array_key_exists($op, $path)) {
|
|||
}
|
||||
switch ($op)
|
||||
{
|
||||
case "periode_change":
|
||||
$field=$http->get("field");
|
||||
$type=$http->get("type");
|
||||
$exercice=$http->get("exercice","number");
|
||||
$last=$http->get("last","number");
|
||||
|
||||
// if last == 1 then show first and last periode of the
|
||||
// exercice
|
||||
$periode_start=0;
|
||||
$periode_end=0;
|
||||
if ( $last==1) {
|
||||
$t_periode=new Periode($cn);
|
||||
list($per_max,$per_min)=$t_periode->get_limit($exercice);
|
||||
$periode_start=$per_max->p_id;
|
||||
$periode_end=$per_min->p_id;
|
||||
}
|
||||
|
||||
$iperiod = new IPeriod($field);
|
||||
$iperiod->id=$field;
|
||||
$iperiod->user = $g_user;
|
||||
$iperiod->cn = $cn;
|
||||
$iperiod->filter_year = true;
|
||||
$iperiod->exercice=$exercice;
|
||||
if ( $type=="from")
|
||||
{
|
||||
$iperiod->show_end_date=FALSE;
|
||||
$iperiod->value=$periode_start;
|
||||
} elseif ($type=="to"){
|
||||
$iperiod->show_start_date=FALSE;
|
||||
$iperiod->value=$periode_end;
|
||||
|
||||
} else {
|
||||
throw new Exception(_("Invalide type"));
|
||||
}
|
||||
|
||||
$iperiod->type = ALL;
|
||||
echo $iperiod->input();
|
||||
|
||||
return;
|
||||
|
||||
break;
|
||||
case "pref_exercice":
|
||||
$iperiod = new IPeriod("period");
|
||||
$iperiod->id="setting_period";
|
||||
|
|
|
|||
|
|
@ -3485,6 +3485,24 @@ function progress_bar_check(p_idx, p_taskid)
|
|||
*/
|
||||
function updatePeriodePreference(p_dossier)
|
||||
{
|
||||
waiting_box();
|
||||
var exercice=$('exercice_setting').value;
|
||||
new Ajax.Updater('setting_period',"ajax_misc.php",{method:"get",parameters:{ "op":"pref_exercice","gDossier":p_dossier,"exercice":exercice}});
|
||||
}
|
||||
remove_waiting_box();
|
||||
}
|
||||
/**
|
||||
* Update the from and to periode list when changing the exercice
|
||||
* @param {int} p_dossier
|
||||
* @param {string} p_exercice id of the exercice
|
||||
* @param {type} p_periode_from id of the starting periode
|
||||
* @param {type} p_periode_to id of the ending periode
|
||||
* @param {type} p_last possible value = 1 to show last periode or 0 the first
|
||||
*/
|
||||
function updatePeriode(p_dossier,p_exercice,p_periode_from,p_periode_to,p_last)
|
||||
{
|
||||
waiting_box();
|
||||
var exercice=$(p_exercice).value;
|
||||
new Ajax.Updater(p_periode_from,"ajax_misc.php",{method:"get",parameters:{op:"periode_change","gDossier":p_dossier,"exercice":exercice,field:p_periode_from,"type":"from","last":p_last}});
|
||||
new Ajax.Updater(p_periode_to,"ajax_misc.php",{method:"get",parameters:{op:"periode_change","gDossier":p_dossier,"exercice":exercice,field:p_periode_to,"type":"to","last":p_last}});
|
||||
remove_waiting_box();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,13 @@ require_once NOALYSS_INCLUDE.'/class/periode.class.php';
|
|||
require_once NOALYSS_INCLUDE.'/class/exercice.class.php';
|
||||
global $g_user, $http;
|
||||
$gDossier=dossier::id();
|
||||
$exercice=(isset($_GET['exercice']))?$_GET['exercice']:$g_user->get_exercice();
|
||||
|
||||
// Get the exercice
|
||||
$exercice=$http->get("exercice","number",0);
|
||||
if ($exercice == 0 ){
|
||||
$exercice=$g_user->get_exercice();
|
||||
}
|
||||
|
||||
bcscale(2);
|
||||
|
||||
echo '<div class="content">';
|
||||
|
|
@ -46,7 +52,8 @@ echo '<fieldset class="noprint"><legend>'._('Exercice').'</legend>';;
|
|||
echo '<form method="GET">';
|
||||
echo _('Choisissez un autre exercice')." : ";
|
||||
$ex=new Exercice($cn);
|
||||
$wex=$ex->select('exercice',$exercice,' onchange="submit(this)"');
|
||||
$js=sprintf("updatePeriode(%d,'%s','%s','%s',1)",Dossier::id(),'exercice','from_periode','to_periode');
|
||||
$wex=$ex->select('exercice',$exercice,' onchange="'.$js.'"');
|
||||
echo $wex->input();
|
||||
echo dossier::hidden();
|
||||
echo HtmlInput::get_to_hidden(array('ac','type'));
|
||||
|
|
@ -66,6 +73,7 @@ echo dossier::hidden();
|
|||
// filter on the current year
|
||||
$from=$http->get("from_periode", "number",0);
|
||||
$input_from=new IPeriod("from_periode",$from,$exercice);
|
||||
$input_from->id="from_periode";
|
||||
$input_from->show_end_date=false;
|
||||
$input_from->type=ALL;
|
||||
$input_from->cn=$cn;
|
||||
|
|
@ -83,6 +91,7 @@ if( $to == 0) {
|
|||
$to=$per_min->p_id;
|
||||
}
|
||||
$input_to=new IPeriod("to_periode",$to,$exercice);
|
||||
$input_to->id="to_periode";
|
||||
$input_to->show_start_date=false;
|
||||
$input_to->filter_year=true;
|
||||
$input_to->type=ALL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue