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" style=
"display:none" 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
330 ($array[$i]['fd_description
'])."($nb_count)".'</a>
';
337 $r.=HtmlInput::hidden('fd_id
',0);
338 $r.='<
p style=
"text-align:center">
';
339 $r.=HtmlInput::button('Fermer
',_('Fermer
')," onclick=\"removeDiv('$ctl')\" ");
345 $xml=escape_xml($html);
346if (!defined("TEST_UNIT")) header('Content-
type: text/xml; charset=UTF-8
');
348<?xml version="1.0" encoding="UTF-8"?>
352<fiche_cat>{$list_fiche}</fiche_cat>
358 /*----------------------------------------------------------------------
360 * save the new card (insert)
362 ----------------------------------------------------------------------*/
365 if ( $g_user->check_action(FICADD)==1 )
368 $status="<status>OK</status>";
370 $f->insert($fd_id,$_POST);
372 $after_save=$http->post("after_save","number",0);
374 // Action after save = 0, the card is display one second and fade out
376 if ( $after_save == 0 ) {
377 $html=HtmlInput::title_box(_("Choix de la catégorie"), $ctl);
378 $html.='<
h2 class=
"notice">
'._('Fiche sauvée
').'</
h2>
';
379 $html.=$f->Display(true);
381 if ( isset( $_POST['ref
'])) $js=create_script(' window.location.reload()
');
383 if ( isset ($eltid)) {
384 // after adding a new card, we update some field
385 $extra="<eltid>$eltid</eltid>".
386 "<elt_value>{$f->get_quick_code ()}</elt_value>";
391 $extra.="<after_save>0</after_save>";
394 // Action after save = 1 ; after adding a card the table must be updated
397 if ( $after_save == 1 ){
400 $detail=Icon_Action::modify("mod".$f_id, sprintf("modify_card('%s
')",$f_id)).
402 Icon_Action::trash("del".$f_id, sprintf("delete_card_id('%s
')",$f_id));
404 $html .= $f->display_row();
405 $html.=ob_get_contents();
407 $extra="<f_id>".$f_id."</f_id>";
408 $ctl="row_card".$f_id;
409 $extra.="<after_save>1</after_save>";
412 } catch (Exception $exc) {
413 $html="<h2 class=\"error\">"._("Erreur sauvegarde")."</h2>";
414 $html.=$exc->getMessage();
415 $status="<status>NOK</status>";
422 $html.=alert(_('Action interdite
'),true);
423 $html.=HtmlInput::button_close($ctl);
426 /*----------------------------------------------------------------------
429 *----------------------------------------------------------------------*/
431 $r=HtmlInput::title_box(_("Détail fiche"), 'search_card
');
432 $r.='<form method=
"GET" onsubmit=
"this.ctl=\'ipop_card\';search_get_card(this);return false;">
';
433 $q=new IText('query
');
434 $q->value=(isset($query))?$query:'';
436 $r.=_('Fiche contenant
').Icon_Action::infobulle(19);
438 $r.=HtmlInput::submit('fs
',_('Recherche
'),"","smallbutton");
440 $r.=dossier::hidden().HtmlInput::hidden('op
','fs
');
444 $page_card=$http->get("page_card","number",0);
445 $inactive=$http->get("inactive_card","string",0);
446 if ($inactive=="undefined" || $inactive == "") $inactive=0;
447 $is=new InputSwitch("inactive_card",$inactive);
448 $is->value=$inactive;
449 $r.=_("fiches inactives").$is->input();
451 // save previous info
457 $r.=HtmlInput::hidden($i,${$i});
458 $hidden.=HtmlInput::hidden($i,${$i});
459 $sql_array[$i]=${$i};
464 $sql_array["query"]=$query;
465 $sql_array["inactive_card"]=$inactive;
466 /* what is the type of the ledger */
468 if (isset($jrn) && $jrn > 1)
470 $ledger=new Acc_Ledger($cn,$jrn);
471 $type=$ledger->get_type();
473 // if jrn == -10 , the search is called from the detail operation from an action follow-up
474 if ( isset($jrn) && $jrn == -10){
475 $type=$http->request("amount_from_type","string","VEN");
477 $fiche=new Fiche($cn);
478 /* Build the SQL and show result */
479 $sql=$fiche->build_sql($sql_array);
481 if ( strpos($sql," in ()") != 0)
484 $html.=HtmlInput::title_box(_('Recherche de fiches
'), 'search_card
');
485 $html.='<h3
class=
"notice">
';
486 $html.=_("Aucune catégorie de fiche ne correspond à".
487 " votre demande, le journal pourrait n'avoir accès à aucune fiche
");
489 $html.=HtmlInput::button_close("search_card
");
495 if ( $inactive == 0 ) {
496 $sql.=" and f_enable=
'1' ";
499 /* We limit the search to MAX_SEARCH_CARD records */
500 $sql=$sql.' order by vw_name ';
501 $total_card=$cn->get_value("select count(*)
from (
$sql) as c
");
503 $record_start=$page_card*MAX_SEARCH_CARD;
504 $sql.=' limit '.MAX_SEARCH_CARD.' offset '.$record_start;
506 $aFound=$cn->get_array($sql);
507 $nb_found=count($aFound);
508 for($i=0;$i<$nb_found;$i++)
510 $array[$i]['quick_code']=$aFound[$i]['quick_code'];
511 $array[$i]['name']=h($aFound[$i]['vw_name']);
512 $array[$i]['accounting']=$aFound[$i]['accounting'];
513 $array[$i]['first_name']=h($aFound[$i]['vw_first_name']);
514 $array[$i]['description']=h($aFound[$i]['vw_description']);
515 $array[$i]['javascript']=sprintf("set_value('%s
','%s');
",
516 $inp,$array[$i]['quick_code']);
517 $array[$i]['javascript'].=sprintf("set_value('%s
','%s');
",
518 $label,j(noalyss_strip_tags($aFound[$i]['vw_name'])));
520 // var $rownb (int) number of the row
521 $rownb=preg_replace('/[^0-9]/','',$label);
524 /* if it is a ledger of sales we use vw_buy
525 if it is a ledger of purchase we use vw_sell*/
528 $amount=(isNumber($aFound[$i]['vw_buy']) == 1 )?$aFound[$i]['vw_buy']:0;
529 $array[$i]['javascript'].=sprintf("set_value('%s
','%s');
",
533 $amount=(isNumber($aFound[$i]['vw_sell']) == 1 )?$aFound[$i]['vw_sell']:0;
534 $array[$i]['javascript'].=sprintf("set_value('%s
','%s');
",
537 // if there is no TVA_ID in the view, it is possible we have a TVA_CODE
538 $tva_code=(empty($aFound[$i]['tva_id']))?$aFound[$i]['tva_code']:$aFound[$i]['tva_id'];
539 $array[$i]['javascript'].=sprintf("set_value('%s
','%s');
",
541 $array[$i]['javascript'].="removeDiv('search_card');
";
542 $array[$i]['javascript'].=(empty($tva_code))?"":"compute_ledger($rownb);
";
546 require_once NOALYSS_TEMPLATE.'/card_result.php';
547 $r.=ob_get_contents();
548 $r.='<ul class="aligned-block
">';
550 $r.=HtmlInput::button_close("search_card
");
552 if ($g_user->check_action(FICADD)==1)
555 $create_card_js='onclick="select_card_type({});
"';
556 $r.=HtmlInput::button_anchor(_("Créer fiche
"),"javascript:void(0)
","",$create_card_js,'smallbutton');
562 $ctl=$ctl.'_content';
565 case 'action_add_concerned_card':
566 require_once NOALYSS_INCLUDE.'/ajax/ajax_add_concerned_card.php';
569// add several card to an action follow⁻up
570 case 'link_concerned_card':
571 require NOALYSS_INCLUDE.'/ajax/ajax_action_save_concerned.php';
573// remove card from an action follow⁻up
574 case 'action_remove_concerned':
575 require NOALYSS_INCLUDE.'/ajax/ajax_action_remove_concerned.php';
578 if ( $g_user->check_action(FICCAT)==1 )
581 /*----------------------------------------------------------------------
582 * Add a category, display first the form
584 *----------------------------------------------------------------------*/
585 $ipopup=str_replace('_content','',$ctl);
589 case FICHE_TYPE_CLIENT:
590 $msg=_(' de clients');
591 $base=$cn->get_value("select p_value
from parm_code where p_code=
'CUSTOMER'");
593 case FICHE_TYPE_FOURNISSEUR:
594 $msg=_(' de fournisseurs');
595 $base=$cn->get_value("select p_value
from parm_code where p_code=
'SUPPLIER'");
597 case FICHE_TYPE_ADM_TAX:
598 $msg=_(' d\'administration');
601 case FICHE_TYPE_CONTACT:
602 $msg=_(' de contacts');
607 $base=$cn->get_value("select p_value
from parm_code where p_code=
'BANQUE'");
609 case FICHE_TYPE_EMPL:
610 $msg=_(' Employé ou administrateur');
619 $search=new IPoste("class_base
");
621 $search->value=$base;
622 $search->label=_("Recherche poste
");
623 $search->set_attribute('gDossier',dossier::id());
624 $search->set_attribute('account',$search->name);
625 $search->set_attribute('ipopup','ipop_account');
627 $nom_mod=new IText("nom_mod
");
628 $str_poste=$search->input();
629 $submit=HtmlInput::submit('save',_('Sauve'));
631 require(NOALYSS_TEMPLATE.'/category_of_card.php');
632 $html.=ob_get_contents();
638 $html=alert(_('Action interdite'),true);
642 /*----------------------------------------------------------------------
643 * Save card Category into the database and return a ok message
645 *----------------------------------------------------------------------*/
648 if ( $g_user->check_action(FICCAT) == 1 )
652 $nom_mod=$http->post("nom_mod
");
653 $class_base=$http->post("class_base
");
654 $fd_description=$http->post("fd_description
","string","");
655 if ( noalyss_strlentrim($nom_mod) != 0 )
657 $array=array("FICHE_REF
"=>$cat,
659 "class_base
"=>$class_base,
660 "fd_description
"=>$fd_description);
662 if ( isset ($_POST['create'])) $array['create']="on
";
664 $catcard=new Fiche_Def($cn);
667 $result=$catcard->Add($array);
669 $html.=ob_get_contents();
674 $script="alert_box(
'"._('Catégorie existe déjà
')."')
";
678 $script="alert_box(
'"._('Catégorie sauvée
')."');removeDiv(
'$ctl')
";
679 // add code to update the SELECT in include/template/category_of_card.php
683 '<id>'.$catcard->id.'</id>'.
684 '<name>'. escape_xml($catcard->label).'</name>'.
689 $html.=create_script($script);
693 $script="alert_box(
'"._("Le nom ne peut pas être vide")."')
";
694 $html.=create_script($script);
701 $html=alert(_('Action interdite'),true);
709// Update a card and then display the result
712 $html=HtmlInput::title_box("Détail fiche
", $ctl);
714 if ( $g_user->check_action(FICADD)==0 )
716 $html.=alert(_('Action interdite'),true);
720 if ($cn->get_value('select count(*) from fiche where f_id=$1',array($_GET['f_id'])) == '0' )
722 $html.=alert(_('Fiche non valide'),true);
727 $html=HtmlInput::title_box(_('Détail fiche (sauvée)'),$ctl);
729 $f=new Fiche($cn,$_GET['f_id']);
732 $html.=ob_get_contents();
734 $html.=$f->Display(true);
737 $html.='<p style="text-align:center
">'.HtmlInput::button_close($ctl).'</p>';
739// Update a card and then display the result
742 $f_id=$http->get("f_id
","number
");
744 if ( $g_user->check_action(FICADD)==0 )
746 $html.=alert(_('Action interdite'),true);
750 if ($cn->get_value('select count(*) from fiche where f_id=$1',array($f_id)) == '0' )
752 $html.=alert(_('Fiche non valide'),true);
758 $f=new Fiche($cn,$f_id );
761 $detail=Icon_Action::modify("mod
".$f_id, sprintf("modify_card(
'%s')
",$f_id)).
763 Icon_Action::trash("del
".$f_id, sprintf("delete_card_id(
'%s')
",$f_id));
765 $html.=$f->display_row();
766 $html.=ob_get_contents();
774//------------------------------------------------------------------
776//------------------------------------------------------------------
778 $html=HtmlInput::title_box("Détail fiche
", $ctl);
780 if ( $g_user->check_action(FIC)==0 )
782 $html.=alert(_('Action interdite'),true);
786 if ($cn->get_value('select count(*) from fiche where f_id=$1',array($_GET['f_id'])) == '0' )
788 $html.=alert(_('Fiche non valide'),true);
794 $f=new Fiche($cn,$_GET['f_id']);
795 if ( $f->is_used()==0){
800 $html=_("Fiche non effacée
");
806 //---------------------------------------------------------------------------------------------------------------
807 // Display option of a contact in an action-followup
808 //---------------------------------------------------------------------------------------------------------------
809 case 'display_card_option':
811 require_once NOALYSS_INCLUDE.'/ajax/ajax_display_card_option.php';
815 //---------------------------------------------------------------------------------------------------------------
816 // Save option of a contact in an action-followup
817 //---------------------------------------------------------------------------------------------------------------
818 case 'save_card_option':
819 require_once NOALYSS_INCLUDE.'/ajax/ajax_save_card_option.php';
823 // ----------------------------------------------------------------------------------------------------------------
824 // Display a list of other card linked to the event / followup
825 // ----------------------------------------------------------------------------------------------------------------
826 case 'action_concerned_list':
827 require_once NOALYSS_INCLUDE.'/ajax/ajax_action_concerned_list.php';
832$xml=escape_xml($html);
833if (DEBUGNOALYSS > 0 && headers_sent()) {
836header('Content-type: text/xml; charset=UTF-8');
838<?xml version="1.0
" encoding="UTF-8
"?>
h2($p_string, $p_class="", $raw="")
span($p_string, $p_extra='')
p($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