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.=dossier::hidden(); $ret.= $new->form_new(); $ret.= HtmlInput::hidden("sa", "pa_write"); $ret.=HtmlInput::submit("submit", _("Enregistre")); $ret.=HtmlInput::button_hide("anc_div_add"); $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=$_POST['pa_name']; $new->description=$_POST['pa_description']; $new->add(); } $sa="anc_menu"; } // Update the PA if ($sa=="pa_update") { $pa_id=$http->get("pa_id","number"); $new=new Anc_Plan($cn, $pa_id); $new->name=$_POST['pa_name']; $new->description=$_POST['pa_description']; $new->update(); $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); $wSa=HtmlInput::hidden("sa", "pa_update"); $new->get(); $ret.= '
'; $ret.= $new->form(); $ret.= $wSa; $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->display_table(" where pa_id = $1 order by po_name ",array($pa_id)); $accounting->create_js_script(); $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 '
'; echo ''; echo ''; echo '
'; echo ''._("Ajout d'un plan comptable").''; echo '
'; 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 '
'; echo ''; if ($obj->isAppend()==true) { echo ''; } foreach ($list as $line) { $url=http_build_query(array("sa"=>"pa_detail","ac"=>$ac,"pa_id"=>$line['id'], "gDossier"=>Dossier::id())); echo ''; echo '"; echo "\n"; } echo '
'; echo ''._("Ajout d'un plan comptable").''; echo '
'. ''. h($line['name']); echo " "; echo h($line['description']).""; echo "
'; echo '
'; } } //--------------------------------------------------------------------------- // show the content part // // //--------------------------------------------------------------------------- echo $ret;