57if ( ! defined(
'ALLOWED')) die (_(
'Accès non autorisé'));
59require_once NOALYSS_INCLUDE.
'/lib/function_javascript.php';
60require_once NOALYSS_INCLUDE.
'/lib/ac_common.php';
62mb_internal_encoding(
"UTF-8");
64$var=array(
'gDossier',
'op2',
'ctl');
71 echo
"$v._(' is not set ')";
91$http=new \HttpInput();
95 require_once
"ajax/ajax_card_attribute.php";
107 $f->id=
$http->get(
"f_id",
"number",
"0");
110 $html.=
'<h2 class="error">'._(
'Aucune fiche demandée').
'</h2>';
122 $safter_save=
$http->request(
"after_save",
"string",
"1");
123 switch ($safter_save)
127 $after_save=
"update_card(this)";
131 $after_save=
"card_update_row(this)";
148 if (
$card ==
'FNT' )
150 $html.=
'<h2 class="error">'._(
'Fiche non trouvée').
'</h2>';
151 $html.=
'<div style="text-align:center">'.HtmlInput::button_close(
$ctl).
'</div>';
158 $html.=
'<form id="form_'.$ctl.
'" method="get" onsubmit="'.$after_save.
';return false;">';
159 $html.=dossier::hidden();
164 $html.=
'<p style="text-align:center">';
179 if ( $can_modify == 1 &&
$f->is_used()==FALSE)
181 $js=str_replace(
'"',
"'",json_encode([
"gDossier"=>
Dossier::id(),
'op'=>
'card',
'op2'=>
"rm_card",
"f_id"=>
$f->id,
'ctl'=>
$ctl]));
193 $html.=
'<h2 class="error">'._(
'Aucune fiche demandée').
'</h2>';
203 $cat_name=
$cn->get_value(
'select fd_label from fiche_def where fd_id=$1',
207 $r.=
'<form id="save_card" method="POST" onsubmit="this.ipopup=\''.$ctl.
'\';save_card(
this);
return false;
" >';
208 $r.=dossier::hidden();
209 $r.=(isset($ref))?HtmlInput::hidden('ref',1):'';
210 $r.=HtmlInput::hidden('fd_id',$fd_id);
211 $r.=HtmlInput::hidden('ctl',$ctl);
212 $r.=$f->blank($fd_id);
213 $r.='<p style="text-
align:center
">';
214 $r.=HtmlInput::submit('sc',_('Sauve'));
215 $r.=HtmlInput::button_close($ctl);
217 if ( isset ($eltid)) {
218 $r.=HtmlInput::hidden("eltid
", $eltid);
220 // Action after save = 0, the card is display one second and fade out
221 $after_save=$http->get("after_save
","number
",0);
222 $r.=HtmlInput::hidden("after_save
",$after_save);
228 $html=alert(_('Action interdite'),true);
231 /* ------------------------------------------------------------ */
233 /* Before inserting a new card, the type must be selected */
234 /* ------------------------------------------------------------ */
236 $sql="select fd_id,fd_label,fd_description
from fiche_def
";
237 /* if we filter thanks the ledger*/
240 /* we want the card for deb or cred or both of this ledger */
244 $l=new Acc_Ledger($cn,$ledger);
245 $array=$l->get_all_fiche_def();
246 $array=(empty($array))?"-1
":$array;
247 $where=' where fd_id in ('.$l->get_all_fiche_def().')';
250 $l=new Acc_Ledger($cn,$ledger);
251 $prop=$l->get_propertie();
252 if ( empty($prop) || empty($prop['jrn_def_fiche_cred']))
256 $where=' where fd_id in ('.$prop['jrn_def_fiche_cred'].')';
260 $l=new Acc_Ledger($cn,$ledger);
261 $prop=$l->get_propertie();
262 if ( empty($prop) || empty($prop['jrn_def_fiche_deb']) ) {
265 $where=' where fd_id in ('.$prop['jrn_def_fiche_deb'].')';
272 /* we filter thanks a given model of card */
273 if ( isset($cat) && ! empty($cat))
275 $where=sprintf(' where frd_id in ('.sql_string ($cat).')');
277 elseif ( isset($fil) && noalyss_strlentrim($fil) > 0 && $fil != -1 )
279 /* we filter thanks a given list of category of card
281 $where=sprintf(" where fd_id in (%s)
",
285 // create any type of cards
289 if ( strpos($where," in ()
") != 0)
291 $html=_("Aucune catégorie de fiche ne correspond à
".
292 " votre demande, le journal pourrait
n'avoir accès à aucune fiche");
295 $sql.=" ".$where." order by fd_label";
296 $array=$cn->get_array($sql);
301 $html=_("Aucune catégorie de fiche ne correspond à votre demande");
302 if ( DEBUGNOALYSS > 0 ) $html.=$sql;
306 $html=HtmlInput::title_box(_("Choix de la catégorie"), $ctl);
310 $r.='<
p style=
"padding-left:2em">
';
311 $r.=_("Choisissez la catégorie de fiche à laquelle vous aimeriez ajouter une fiche").'</
p>
';
312 if ( ! isset($eltid)) $eltid="";
313 $msg=_('Choisissez une catégorie svp
');
314 $r.='<
span id=
"error_cat" class=
"notice"></
span>
';
315 $r.=dossier::hidden();
316 $r.=(isset($ref))?HtmlInput::hidden('ref
',1):'';
317 $r.=_('Cherche
').' '.HtmlInput::filter_table("cat_card_table", '0,1
', 0);
318 $r.='<
table id=
"cat_card_table" class=
"result">
';
319 for ($i=0;$i<count($array);$i++)
321 $nb_count=$cn->get_value("select count(*) from fiche where fd_id=$1",[$array[$i]['fd_id
']]);
322 $list_fiche.=sprintf("<fiche_cat_item>%d</fiche_cat_item>",$array[$i]['fd_id
']);
323 $class=($i%2==0)?' class=
"even" ':' class=
"odd" ';
324 $r.='<
tr '.$class.' id=
"select_cat_row_'.$array[$i]['fd_id'].'">
';
326 $r.='<a href=
"javascript:void(0)" onclick=
"select_cat(\''.$array[$i]['fd_id'].'\','.$gDossier.',\''.$eltid.'\')">
'.h($array[$i]['fd_label
']).'</a>
';
329 $r.='<a href=
"javascript:void(0)" onclick=
"select_cat(\''.$array[$i]['fd_id'].'\','.$gDossier.',\''.$eltid.'\')">
'.h($array[$i]['fd_description
'])."($nb_count)".'</a>
';
336 $r.=HtmlInput::hidden('fd_id
',0);
337 $r.='<
p style=
"text-align:center">
';
338 $r.=HtmlInput::button('Fermer
',_('Fermer
')," onclick=\"removeDiv('$ctl')\" ");
344 $xml=escape_xml($html);
345 header('Content-
type: text/xml; charset=UTF-8
');
347<?xml version="1.0" encoding="UTF-8"?>
351<fiche_cat>{$list_fiche}</fiche_cat>
357 /*----------------------------------------------------------------------
359 * save the new card (insert)
361 ----------------------------------------------------------------------*/
364 if ( $g_user->check_action(FICADD)==1 )
367 $status="<status>OK</status>";
369 $f->insert($fd_id,$_POST);
371 $after_save=$http->post("after_save","number",0);
373 // Action after save = 0, the card is display one second and fade out
375 if ( $after_save == 0 ) {
376 $html=HtmlInput::title_box(_("Choix de la catégorie"), $ctl);
377 $html.='<
h2 class=
"notice">
'._('Fiche sauvée
').'</
h2>
';
378 $html.=$f->Display(true);
380 if ( isset( $_POST['ref
'])) $js=create_script(' window.location.reload()
');
382 if ( isset ($eltid)) {
383 // after adding a new card, we update some field
384 $extra="<eltid>$eltid</eltid>".
385 "<elt_value>{$f->get_quick_code ()}</elt_value>";
390 $extra.="<after_save>0</after_save>";
393 // Action after save = 1 ; after adding a card the table must be updated
396 if ( $after_save == 1 ){
399 $detail=Icon_Action::modify("mod".$f_id, sprintf("modify_card('%s
')",$f_id)).
401 Icon_Action::trash("del".$f_id, sprintf("delete_card_id('%s
')",$f_id));
403 $html .= $f->display_row();
404 $html.=ob_get_contents();
406 $extra="<f_id>".$f_id."</f_id>";
407 $ctl="row_card".$f_id;
408 $extra.="<after_save>1</after_save>";
411 } catch (Exception $exc) {
412 $html="<h2 class=\"error\">"._("Erreur sauvegarde")."</h2>";
413 $html.=$exc->getMessage();
414 $status="<status>NOK</status>";
421 $html.=alert(_('Action interdite
'),true);
422 $html.=HtmlInput::button_close($ctl);
425 /*----------------------------------------------------------------------
428 *----------------------------------------------------------------------*/
430 $r=HtmlInput::title_box(_("Détail fiche"), 'search_card
');
431 $r.='<form method=
"GET" onsubmit=
"this.ctl=\'ipop_card\';search_get_card(this);return false;">
';
432 $q=new IText('query
');
433 $q->value=(isset($query))?$query:'';
435 $r.=_('Fiche contenant
').Icon_Action::infobulle(19);
437 $r.=HtmlInput::submit('fs
',_('Recherche
'),"","smallbutton");
439 $r.=dossier::hidden().HtmlInput::hidden('op
','fs
');
443 $page_card=$http->get("page_card","number",0);
444 $inactive=$http->get("inactive_card","string",0);
445 if ($inactive=="undefined" || $inactive == "") $inactive=0;
446 $is=new InputSwitch("inactive_card",$inactive);
447 $is->value=$inactive;
448 $r.=_("fiches inactives").$is->input();
450 // save previous info
456 $r.=HtmlInput::hidden($i,${$i});
457 $hidden.=HtmlInput::hidden($i,${$i});
458 $sql_array[$i]=${$i};
463 $sql_array["query"]=$query;
464 $sql_array["inactive_card"]=$inactive;
465 /* what is the type of the ledger */
467 if (isset($jrn) && $jrn > 1)
469 $ledger=new Acc_Ledger($cn,$jrn);
470 $type=$ledger->get_type();
472 // if jrn == -10 , the search is called from the detail operation from an action follow-up
473 if ( isset($jrn) && $jrn == -10){
474 $type=$http->request("amount_from_type","string","VEN");
476 $fiche=new Fiche($cn);
477 /* Build the SQL and show result */
478 $sql=$fiche->build_sql($sql_array);
480 if ( strpos($sql," in ()") != 0)
483 $html.=HtmlInput::title_box(_('Recherche de fiche
'), 'search_card
');
484 $html.='<h3
class=
"notice">
';
485 $html.=_("Aucune catégorie de fiche ne correspond à".
486 " votre demande, le journal pourrait n'avoir accès à aucune fiche
");
488 $html.=HtmlInput::button_close("search_card
");
494 if ( $inactive == 0 ) {
495 $sql.=" and f_enable=
'1' ";
498 /* We limit the search to MAX_SEARCH_CARD records */
499 $sql=$sql.' order by vw_name ';
500 $total_card=$cn->get_value("select count(*)
from (
$sql) as c");
502 $record_start=$page_card*MAX_SEARCH_CARD;
503 $sql.=' limit '.MAX_SEARCH_CARD.' offset '.$record_start;
506 $nb_found=count($aFound);
509 $array[
$i][
'quick_code']=$aFound[
$i][
'quick_code'];
511 $array[
$i][
'accounting']=$aFound[
$i][
'accounting'];
512 $array[
$i][
'first_name']=
h($aFound[
$i][
'vw_first_name']);
513 $array[
$i][
'description']=
h($aFound[
$i][
'vw_description']);
514 $array[
$i][
'javascript']=sprintf(
"set_value('%s','%s');",
516 $array[
$i][
'javascript'].=sprintf(
"set_value('%s','%s');",
517 $label,
j(strip_tags($aFound[
$i][
'vw_name'])));
525 $array[
$i][
'javascript'].=sprintf(
"set_value('%s','%s');",
530 $array[
$i][
'javascript'].=sprintf(
"set_value('%s','%s');",
533 $array[
$i][
'javascript'].=sprintf(
"set_value('%s','%s');",
534 $tvaid,$aFound[
$i][
'tva_id']);
535 $array[
$i][
'javascript'].=
"removeDiv('search_card');";
540 require_once NOALYSS_TEMPLATE.
'/card_result.php';
541 $r.=ob_get_contents();
547 case 'action_add_concerned_card':
548 require_once NOALYSS_INCLUDE.
'/ajax/ajax_add_concerned_card.php';
552 case 'link_concerned_card':
553 require NOALYSS_INCLUDE.
'/ajax/ajax_action_save_concerned.php';
556 case 'action_remove_concerned':
557 require NOALYSS_INCLUDE.
'/ajax/ajax_action_remove_concerned.php';
567 $ipopup=str_replace(
'_content',
'',
$ctl);
572 $msg=_(
' de clients');
573 $base=
$cn->get_value(
"select p_value from parm_code where p_code='CUSTOMER'");
576 $msg=_(
' de fournisseurs');
577 $base=
$cn->get_value(
"select p_value from parm_code where p_code='SUPPLIER'");
580 $msg=_(
' d\'administration');
584 $msg=_(
' de contacts');
589 $base=
$cn->get_value(
"select p_value from parm_code where p_code='BANQUE'");
592 $msg=_(
' Employé ou administrateur');
601 $search=
new IPoste(
"class_base");
603 $search->value=
$base;
604 $search->label=_(
"Recherche poste");
606 $search->set_attribute(
'account',$search->name);
607 $search->set_attribute(
'ipopup',
'ipop_account');
609 $nom_mod=
new IText(
"nom_mod");
610 $str_poste=$search->input();
613 require(NOALYSS_TEMPLATE.
'/category_of_card.php');
614 $html.=ob_get_contents();
634 $nom_mod=
$http->get(
"nom_mod");
635 $class_base=
$http->get(
"class_base");
636 $fd_description=
$http->get(
"nom_mod");
641 "class_base"=>$class_base,
642 "fd_description"=>$fd_description);
651 $html.=ob_get_contents();
656 $script=
"alert_box('"._(
'Catégorie existe déjà').
"')";
660 $script=
"alert_box('"._(
'Catégorie sauvée').
"');removeDiv('$ctl')";
667 $script=
"alert_box('"._(
"Le nom ne peut pas être vide").
"')";
694 if (
$cn->get_value(
'select count(*) from fiche where f_id=$1',array(
$_GET[
'f_id'])) ==
'0' )
706 $html.=ob_get_contents();
711 $html.=
'<p style="text-align:center">'.HtmlInput::button_close(
$ctl).
'</p>';
724 if (
$cn->get_value(
'select count(*) from fiche where f_id=$1',array(
$f_id)) ==
'0' )
740 $html.=ob_get_contents();
760 if (
$cn->get_value(
'select count(*) from fiche where f_id=$1',array(
$_GET[
'f_id'])) ==
'0' )
769 if (
$f->is_used()==0){
774 $html=_(
"Fiche non effacée");
783 case 'display_card_option':
785 require_once NOALYSS_INCLUDE.
'/ajax/ajax_display_card_option.php';
792 case 'save_card_option':
793 require_once NOALYSS_INCLUDE.
'/ajax/ajax_save_card_option.php';
800 case 'action_concerned_list':
801 require_once NOALYSS_INCLUDE.
'/ajax/ajax_action_concerned_list.php';
807if (DEBUGNOALYSS > 0 && headers_sent()) {
810header(
'Content-type: text/xml; charset=UTF-8');
812<?xml version=
"1.0" encoding=
"UTF-8"?>
h2($p_string, $p_class="", $raw="")
span($p_string, $p_extra='')
noalyss_strlentrim($p_string)
tr($p_string, $p_extra='')
set_language()
set the lang thanks the _SESSION['g_lang'] var.
td($p_string='', $p_extra='')
surround the string with td
j($p_string)
escape correctly php string to javascript
alert($p_msg, $buffer=false)
alert in javascript
return false Description text align
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
for( $i=0; $i< $nb_row; $i++)
h( $row[ 'oa_description'])
static id()
return the 'gDossier' value after a check
define Class fiche and fiche def, those class are using class attribut
define Class fiche and fiche def, those class are using class attribut. When adding or modifing new c...
show a button, for selecting a account and a input text for manually inserting an account the differe...
static modify($p_id, $p_javascript)
Display the icon to modify a idem.
static trash($p_id, $p_javascript)
Display the icon of a trashbin.
Data & function about connected users.
const FICHE_TYPE_FOURNISSEUR
for($e=0; $e< count($afiche); $e++) exit
create_script($p_string)
create the HTML for adding the script tags around of the script
escape_xml($p_xml)
When data are transfered thanks ajax in a xml document, the xml can not contains some character,...