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 ')";
82$cn=Dossier::connect();
91$http=new \HttpInput();
95 require_once
"ajax/ajax_card_attribute.php";
107 $f->id=
$http->get(
"f_id",
"number",
"0");
109 $html=HtmlInput::title_box(
_(
"Fiche"),
$ctl,
"close",
"",
"y");
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">';
175 "gDossier"=>Dossier::id()
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;
505 $aFound=$cn->get_array($sql);
506 $nb_found=count($aFound);
507 for($i=0;$i<$nb_found;$i++)
509 $array[$i]['quick_code']=$aFound[$i]['quick_code'];
510 $array[$i]['name']=h($aFound[$i]['vw_name']);
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');
",
515 $inp,$array[$i]['quick_code']);
516 $array[$i]['javascript'].=sprintf("set_value('%s
','%s');
",
517 $label,j(noalyss_strip_tags($aFound[$i]['vw_name'])));
520 /* if it is a ledger of sales we use vw_buy
521 if it is a ledger of purchase we use vw_sell*/
524 $amount=(isNumber($aFound[$i]['vw_buy']) == 1 )?$aFound[$i]['vw_buy']:0;
525 $array[$i]['javascript'].=sprintf("set_value('%s
','%s');
",
529 $amount=(isNumber($aFound[$i]['vw_sell']) == 1 )?$aFound[$i]['vw_sell']:0;
530 $array[$i]['javascript'].=sprintf("set_value('%s
','%s');
",
533 // if there is no TVA_ID in the view, it is possible we have a TVA_CODE
534 $tva_code=(empty($aFound[$i]['tva_id']))?$aFound[$i]['tva_code']:$aFound[$i]['tva_id'];
535 $array[$i]['javascript'].=sprintf("set_value('%s
','%s');
",
537 $array[$i]['javascript'].="removeDiv('search_card');
";
542 require_once NOALYSS_TEMPLATE.'/card_result.php';
543 $r.=ob_get_contents();
544 $r.=HtmlInput::button_close("search_card
");
546 $ctl=$ctl.'_content';
549 case 'action_add_concerned_card':
550 require_once NOALYSS_INCLUDE.'/ajax/ajax_add_concerned_card.php';
553// add several card to an action follow⁻up
554 case 'link_concerned_card':
555 require NOALYSS_INCLUDE.'/ajax/ajax_action_save_concerned.php';
557// remove card from an action follow⁻up
558 case 'action_remove_concerned':
559 require NOALYSS_INCLUDE.'/ajax/ajax_action_remove_concerned.php';
562 if ( $g_user->check_action(FICCAT)==1 )
565 /*----------------------------------------------------------------------
566 * Add a category, display first the form
568 *----------------------------------------------------------------------*/
569 $ipopup=str_replace('_content','',$ctl);
573 case FICHE_TYPE_CLIENT:
574 $msg=_(' de clients');
575 $base=$cn->get_value("select p_value
from parm_code where p_code='CUSTOMER'
");
577 case FICHE_TYPE_FOURNISSEUR:
578 $msg=_(' de fournisseurs');
579 $base=$cn->get_value("select p_value
from parm_code where p_code='SUPPLIER'
");
581 case FICHE_TYPE_ADM_TAX:
582 $msg=_(' d\'administration');
585 case FICHE_TYPE_CONTACT:
586 $msg=_(' de contacts');
591 $base=$cn->get_value("select p_value
from parm_code where p_code='BANQUE'
");
593 case FICHE_TYPE_EMPL:
594 $msg=_(' Employé ou administrateur');
603 $search=new IPoste("class_base
");
605 $search->value=$base;
606 $search->label=_("Recherche poste
");
607 $search->set_attribute('gDossier',dossier::id());
608 $search->set_attribute('account',$search->name);
609 $search->set_attribute('ipopup','ipop_account');
611 $nom_mod=new IText("nom_mod
");
612 $str_poste=$search->input();
613 $submit=HtmlInput::submit('save',_('Sauve'));
615 require(NOALYSS_TEMPLATE.'/category_of_card.php');
616 $html.=ob_get_contents();
622 $html=alert(_('Action interdite'),true);
626 /*----------------------------------------------------------------------
627 * Save card Category into the database and return a ok message
629 *----------------------------------------------------------------------*/
632 if ( $g_user->check_action(FICCAT) == 1 )
636 $nom_mod=$http->get("nom_mod
");
637 $class_base=$http->get("class_base
");
638 $fd_description=$http->get("nom_mod
");
639 if ( noalyss_strlentrim($nom_mod) != 0 )
641 $array=array("FICHE_REF
"=>$cat,
643 "class_base
"=>$class_base,
644 "fd_description
"=>$fd_description);
646 if ( isset ($_POST['create'])) $array['create']=1;
648 $catcard=new Fiche_Def($cn);
651 $result=$catcard->Add($array);
653 $html.=ob_get_contents();
658 $script="alert_box('
"._('Catégorie existe déjà')."')
";
662 $script="alert_box('
"._('Catégorie sauvée')."');removeDiv('
$ctl')
";
665 $html.=create_script($script);
669 $script="alert_box('
"._("Le nom ne peut pas être vide
")."')
";
670 $html.=create_script($script);
677 $html=alert(_('Action interdite'),true);
685// Update a card and then display the result
688 $html=HtmlInput::title_box("Détail fiche
", $ctl);
690 if ( $g_user->check_action(FICADD)==0 )
692 $html.=alert(_('Action interdite'),true);
696 if ($cn->get_value('select count(*) from fiche where f_id=$1',array($_GET['f_id'])) == '0' )
698 $html.=alert(_('Fiche non valide'),true);
703 $html=HtmlInput::title_box(_('Détail fiche (sauvée)'),$ctl);
705 $f=new Fiche($cn,$_GET['f_id']);
708 $html.=ob_get_contents();
710 $html.=$f->Display(true);
713 $html.='<p style="text-align:center
">'.HtmlInput::button_close($ctl).'</p>';
715// Update a card and then display the result
718 $f_id=$http->get("f_id
","number
");
720 if ( $g_user->check_action(FICADD)==0 )
722 $html.=alert(_('Action interdite'),true);
726 if ($cn->get_value('select count(*) from fiche where f_id=$1',array($f_id)) == '0' )
728 $html.=alert(_('Fiche non valide'),true);
734 $f=new Fiche($cn,$f_id );
737 $detail=Icon_Action::modify("mod
".$f_id, sprintf("modify_card('%s')
",$f_id)).
739 Icon_Action::trash("del
".$f_id, sprintf("delete_card_id('%s')
",$f_id));
741 $html.=$f->display_row();
742 $html.=ob_get_contents();
750//------------------------------------------------------------------
752//------------------------------------------------------------------
754 $html=HtmlInput::title_box("Détail fiche
", $ctl);
756 if ( $g_user->check_action(FIC)==0 )
758 $html.=alert(_('Action interdite'),true);
762 if ($cn->get_value('select count(*) from fiche where f_id=$1',array($_GET['f_id'])) == '0' )
764 $html.=alert(_('Fiche non valide'),true);
770 $f=new Fiche($cn,$_GET['f_id']);
771 if ( $f->is_used()==0){
776 $html=_("Fiche non effacée
");
782 //---------------------------------------------------------------------------------------------------------------
783 // Display option of a contact in an action-followup
784 //---------------------------------------------------------------------------------------------------------------
785 case 'display_card_option':
787 require_once NOALYSS_INCLUDE.'/ajax/ajax_display_card_option.php';
791 //---------------------------------------------------------------------------------------------------------------
792 // Save option of a contact in an action-followup
793 //---------------------------------------------------------------------------------------------------------------
794 case 'save_card_option':
795 require_once NOALYSS_INCLUDE.'/ajax/ajax_save_card_option.php';
799 // ----------------------------------------------------------------------------------------------------------------
800 // Display a list of other card linked to the event / followup
801 // ----------------------------------------------------------------------------------------------------------------
802 case 'action_concerned_list':
803 require_once NOALYSS_INCLUDE.'/ajax/ajax_action_concerned_list.php';
808$xml=escape_xml($html);
809if (DEBUGNOALYSS > 0 && headers_sent()) {
812header('Content-type: text/xml; charset=UTF-8');
814<?xml version="1.0
" encoding="UTF-8
"?>
h2($p_string, $p_class="", $raw="")
span($p_string, $p_extra='')
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
global $g_user
if no group available , then stop
if(headers_sent() &&DEBUGNOALYSS > 0) $html
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
_("actif, passif,charge,...")
define Class fiche and fiche def, those class are using class attribut. When adding or modifing new c...
Data & function about connected users.
for($e=0; $e< count($afiche); $e++) exit