check(true);
$g_user->check_dossier($gDossier,true);
$html=var_export($_REQUEST,true);
// For storing extra information , example the HTML elt id to update
// after creating
$extra="";
switch($op2)
{
/* ------------------------------------------------------------ */
/* Remove a attribut */
/* ------------------------------------------------------------ */
case 'rmfa':
if ($g_user->check_action(FICCAT)==0)exit();
ob_start();
if( ! isset($_GET['ad_id']) || isNumber($_GET['ad_id']) ==0)
throw new Exception ( _("Parametre ad_id est invalide"),11);
$ad_id= $_GET['ad_id'];
try
{
$cn->start();
$fa=new Fiche_Attr($cn,$ad_id);
$fa->delete();
$cn->commit();
}
catch (Exception $e)
{
$cn->rollback();
record_log($e->getTraceAsString());
echo $e->getMessage();
}
$html=ob_get_contents();
ob_end_clean();
break;
/* ------------------------------------------------------------ */
/* Display card detail */
/* ------------------------------------------------------------ */
case 'dc':
$f=new Fiche($cn);
/* add title + close */
$html=HtmlInput::title_box(_("Détail fiche"), $ctl,"close","","y");
if ( $qcode != '')
{
$f->get_by_qcode($qcode);
$can_modify=$g_user->check_action(FIC);
if ( isset($ro) )
{
$can_modify=0;
}
if ( $can_modify==1)
$card=$f->Display(false,$ctl);
else
$card=$f->Display(true);
if ( $card == 'FNT' )
{
$html.='
'._('Fiche non trouvée').'
';
}
else
{
if ($can_modify==1)
{
$html.='';
}
}
}
else
{
$html.=''._('Aucune fiche demandée').'
';
}
break;
/* ------------------------------------------------------------ */
/* Blank card */
/* ------------------------------------------------------------ */
case 'bc':
if ( $g_user->check_action(FICADD)==1 || $g_user->check_action(FIC)==1)
{
$r=HtmlInput::title_box(_("Nouvelle fiche"), $ctl);
/* get cat. name */
$cat_name=$cn->get_value('select fd_label from fiche_def where fd_id=$1',
array($fd_id));
$f=new Fiche($cn);
$r.='';
$html=$r;
}
else
{
$html=alert(_('Action interdite'),true);
}
break;
/* ------------------------------------------------------------ */
/* Show Type */
/* Before inserting a new card, the type must be selected */
/* ------------------------------------------------------------ */
case 'st':
$sql="select fd_id,fd_label,fd_description from fiche_def";
/* if we filter thanks the ledger*/
if ( $ledger != -1 )
{
/* we want the card for deb or cred or both of this ledger */
switch( $fil )
{
case -1:
$l=new Acc_Ledger($cn,$ledger);
$where=' where fd_id in ('.$l->get_all_fiche_def().')';
break;
case 'cred':
$l=new Acc_Ledger($cn,$ledger);
$prop=$l->get_propertie();
if ( $prop['jrn_def_fiche_cred']=='')$prop=-1;
$where=' where fd_id in ('.$prop['jrn_def_fiche_cred'].')';
break;
case 'deb':
$l=new Acc_Ledger($cn,$ledger);
$prop=$l->get_propertie();
if ( $prop=='')$prop=-1;
$where=' where fd_id in ('.$prop['jrn_def_fiche_deb'].')';
break;
}
}
else
{
/* we filter thanks a given model of card */
if ( isset($cat))
{
$where=sprintf(' where frd_id in ('.sql_string ($cat).')');
}
else
/* we filter thanks a given list of category of card
*/
if ( isset($fil) && strlen(trim($fil)) > 0 )
{
$where=sprintf(" where fd_id in (%s)",
sql_string($fil));
}
}
if ( strpos($where," in ()") != 0)
{
$html=_("Aucune catégorie de fiche ne correspond à".
" votre demande, le journal pourrait n'avoir accès à aucune fiche");
break;
}
$sql.=" ".$where." order by fd_label";
$array=$cn->get_array($sql);
$list_fiche="";
if ( empty($array))
{
$html=_("Aucune catégorie de fiche ne correspond à votre demande");
if ( DEBUG ) $html.=$sql;
}
else
{
$html=HtmlInput::title_box(_("Choix de la catégorie"), $ctl);
$r='';
$r.='';
$r.='
';
$r.=_("Choisissez la catégorie de fiche à laquelle vous aimeriez ajouter une fiche").'
';
if ( ! isset($eltid)) $eltid="";
$msg=_('Choisissez une catégorie svp');
$r.='
';
$r.=dossier::hidden();
$r.=(isset($ref))?HtmlInput::hidden('ref',1):'';
$r.=_('Cherche').' '.HtmlInput::filter_table("cat_card_table", '0,1', 0);
$r.='
';
$r.=HtmlInput::hidden('fd_id',0);
$r.='
';
$r.=HtmlInput::button('Fermer',_('Fermer')," onclick=\"removeDiv('$ctl')\" ");
$r.='
';
$r.='
';
$html.=$r;
}
$xml=escape_xml($html);
header('Content-type: text/xml; charset=UTF-8');
echo <<
$ctl
$xml
{$list_fiche}
EOF;
return;
break;
/*----------------------------------------------------------------------
* SC save card
* save the new card (insert)
*
----------------------------------------------------------------------*/
case 'sc':
$html=HtmlInput::title_box(_("Choix de la catégorie"), $ctl);
if ( $g_user->check_action(FICADD)==1 )
{
$f=new Fiche($cn);
$status="OK";
try {
$f->insert($fd_id,$_POST);
$f->Get();
$html.=''._('Fiche sauvée').'
';
$html.=$f->Display(true);
$js="";
if ( isset( $_POST['ref'])) $js=create_script(' window.location.reload()');
$html.=$js;
if ( isset ($eltid)) {
// after adding a new card, we update some field
$extra="$eltid".
"{$f->get_quick_code ()}";
}
$extra.=$status;
$html.=HtmlInput::button_close($ctl);
} catch (Exception $exc) {
$html=""._("Erreur sauvegarde")."
";
$html.=$exc->getMessage();
$status="NOK";
$extra=$status;
}
}
else
{
$html.=alert(_('Action interdite'),true);
$html.=HtmlInput::button_close($ctl);
}
break;
/*----------------------------------------------------------------------
* Search a card
*
*----------------------------------------------------------------------*/
case 'fs':
require_once NOALYSS_INCLUDE.'/class/acc_ledger.class.php';
$r=HtmlInput::title_box(_("Détail fiche"), 'search_card');
$r.='