request("sa", "string", "anc_menu");
//---------------------------------------------------------------------------
// action
// Compute the redcontent div
//---------------------------------------------------------------------------
// show the form for adding a pa
if ($sa=="add_pa")
{
$new=new Anc_Plan($cn);
if ($new->isAppend()==true)
{
$ret.= '
';
$ret.=HtmlInput::title_box(_('Nouveau plan'), 'anc_div_add', 'hide');
$ret.= '';
$ret.= '
';
}
else
{
$ret.= ''.
'
'.
_("Maximum de plan analytique est atteint").
"
";
}
$sa="anc_menu";
}
// Add
if ($sa=="pa_write")
{
$new=new Anc_Plan($cn);
if ($new->isAppend()==false)
{
$ret.= ''.
_("Maximum de plan analytique est atteint").
"
";
}
else
{
$new=new Anc_Plan($cn);
$new->name=$http->post("pa_name");
$new->description=$http->post("pa_description");
$new->add();
}
$sa="anc_menu";
}
/* delete pa */
if ($sa=="pa_delete")
{
$pa_id=$http->get("pa_id","number");
$delete=new Anc_Plan($cn, $pa_id);
$delete->delete();
$sa="anc_menu";
}
//--------------------------------------------------------------------------------------------------
// show the detail of an analytic axis (=plan)
//
//--------------------------------------------------------------------------------------------------
if ($sa=="pa_detail")
{
$pa_id=$http->get("pa_id","number");
$new=new Anc_Plan($cn, $pa_id);
$new->get();
$ret.= '';
$ret.= $new->form();
// Export in CSV
$ret.='';
$ret.=HtmlInput::button_anchor(_('Efface ce plan'), '', 'remove_analytic_plan',
'onclick="return confirm_box(\'remove_analytic_plan\',\'Effacer ?\',function () {window.location=\'do.php?ac='.$_REQUEST['ac'].'&pa_id='.$_GET['pa_id'].'&sa=pa_delete&'.$str_dossier.'\';})"',
'smallbutton');
$ret.='
';
//---------------------------------------------------------------------
// Detail now
// Use Manage_Table
//---------------------------------------------------------------------
$count=0;
$new=new Anc_Plan($cn, $pa_id);
$new->get();
$ret.='';
$anc=new Poste_analytique_SQL($cn);
$anc->pa_id=$pa_id;
$accounting=new Anc_Account_Table($anc);
$accounting->set_callback("ajax_misc.php");
$accounting->add_json_param("op", "anc_accounting");
$accounting->add_json_param("pa_id", $pa_id);
$accounting->set_sort_column("po_name");
ob_start();
$accounting->create_js_script();
$accounting->display_table(" where pa_id = $1 order by po_name ",array($pa_id));
$ret.=ob_get_clean();
$ret.= '
';
}
//---------------------------------------------------------------------------
// Show lmenu
//
//---------------------------------------------------------------------------
if ($sa=='anc_menu')
{
$obj=new Anc_Plan($cn);
$list=$obj->get_list();
$ac=$http->request("ac");
if (empty($list))
{
$url=http_build_query(array("sa"=>"add_pa","ac"=>$ac,
"gDossier"=>Dossier::id()));
echo '';
if (!isset($_REQUEST['sa']))
echo ''.
_("Aucun plan analytique n'est défini").
'
';
}
else
{
$url=http_build_query(array("sa"=>"add_pa","ac"=>$ac,
"gDossier"=>Dossier::id()));
echo '';
}
}
//---------------------------------------------------------------------------
// show the content part
//
//
//---------------------------------------------------------------------------
echo $ret;