noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
ajax_card.php
Go to the documentation of this file.
1<?php
2/*
3 * This file is part of NOALYSS.
4 *
5 * NOALYSS is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * NOALYSS is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with NOALYSS; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18*/
19
20// Copyright Author Dany De Bontridder danydb@aevalys.eu
21
22/*!\file
23 * \brief this file respond to an ajax request and return an object with the ctl and the html string
24 * at minimum
25 \verbatim
26 {'ctl':'','html':''}
27\endverbatim
28 * The parameters are
29 * - gDossier
30 * - op
31 - dc Detail of a card
32 parameter : $qcode , optional ro for readonly and nohistory without the history button, nofollowup
33 - bc Blank Card : display form for adding a card
34 parameter fd_id (fiche_def:fd_id)
35 - st Show Type : select type of card
36 parameter fil : possible values of fd_id if empty it means all the fiche cat.
37 - sc Save Card : insert a new card (call first bc)
38 - upc update a card
39 specific parameter qcode
40 - fs Form to search card
41 parameter like
42 - inp : the input text field to update
43 - str : current content of the input text field (inp)
44 - label : the element to put the name of the card
45 - price : the element to put the price of the card (if exists)
46 - tvaid : the element to put the tvaid of the card (if exists)
47 - jrn : the concerned ledger (or all)
48 - typecard : possible values are cred, deb, filter (list of fd_id)
49 - ac Add Category
50 - cat type of cat to add (FICHE_TYPE_CLIENT,...)
51 * - ctl (to return)
52 * - popup
53 * - ref if we want to refresh the window
54 * - acc is accounting is visible or not
55 *\see fiche fiche::Save constant.php
56 */
57if ( ! defined('ALLOWED')) die (_('Accès non autorisé'));
58
59require_once NOALYSS_INCLUDE.'/lib/function_javascript.php';
60require_once NOALYSS_INCLUDE.'/lib/ac_common.php';
61
62mb_internal_encoding("UTF-8");
63
64$var=array('gDossier','op2','ctl');
66/* check if mandatory parameters are given */
67foreach ($var as $v)
68{
69 if ( ! isset ($_REQUEST [$v] ) )
70 {
71 echo "$v._(' is not set ')";
72 $cont=1;
73 }
74}
75extract($_REQUEST, EXTR_SKIP );
76
77if ( $cont != 0 ) exit();
78
80
82$cn=Dossier::connect();
83global $g_user;
85$g_user->check(true);
86$g_user->check_dossier($gDossier,true);
87$html=var_export($_REQUEST,true);
88// For storing extra information , example the HTML elt id to update
89// after creating
91$http=new \HttpInput();
92switch($op2)
93{
94 case 'attribute':
95 require_once "ajax/ajax_card_attribute.php";
96 return ;
97 /* ------------------------------------------------------------ */
98 /* Display card detail */
99 /* ------------------------------------------------------------ */
100
101case 'dc':
102 $f=new Fiche($cn);
103 /* add title + close */
104 $qcode=$http->request("qcode","string",false);
105 // if there is no qcode then try to find it thanks the card id
106 if ( $qcode == false ){
107 $f->id=$http->get("f_id","number","0");
108 if ( $f->id==0) {
109 $html=HtmlInput::title_box(_("Fiche"), $ctl,"close","","y");
110 $html.='<h2 class="error">'._('Aucune fiche demandée').'</h2>';
111 break;
112 }
113 $qcode=$f->get_quick_code();
114 } else {
115 $f->get_by_qcode($qcode);
116
117 }
118 $title=$f->getLabelCategory();
119 $html=HtmlInput::title_box($title, $ctl,"close","","y");
120
121 // after save , we can either show a card in readonly or update a row
122 $safter_save=$http->request("after_save","string","1");
123 switch ($safter_save)
124 {
125 case "1":
126 // show a card it readonly and fade it
127 $after_save="update_card(this)";
128 break;
129 case "2":
130 // update a row in the table X
131 $after_save="card_update_row(this)";
132 break;
133 default:
134 break;
135 }
136
137 if ( $qcode != null)
138 {
139 $can_modify=$g_user->check_action(FIC);
140 if ( isset($ro) )
141 {
142 $can_modify=0;
143 }
144 if ( $can_modify==1)
145 $card=$f->Display(false,$ctl);
146 else
147 $card=$f->Display(true);
148 if ( $card == 'FNT' )
149 {
150 $html.='<h2 class="error">'._('Fiche non trouvée').'</h2>';
151 $html.='<div style="text-align:center">'.HtmlInput::button_close($ctl).'</div>';
152 }
153 else
154 {
155
156 if ($can_modify==1)
157 {
158 $html.='<form id="form_'.$ctl.'" method="get" onsubmit="'.$after_save.';return false;">';
159 $html.=dossier::hidden();
160 $html.=HtmlInput::hidden('f_id',$f->id);
162 }
163 $html.=$card;
164 $html.='<p style="text-align:center">';
166 if ( $can_modify==1)
167 {
168 $html.=HtmlInput::submit('save',_('Sauver'));
169 }
170 if ( ! isset ($nohistory))$html.=HtmlInput::history_card_button($f->id,_('Historique'));
171 if ( ! isset ($nofollowup))$html.=HtmlInput::followup_card_button($f->id,_('Suivi'));
172 $button_pdf=HtmlInput::button_anchor(_("PDF"),"export.php?".http_build_query([
173 "act"=>"PDF:card",
174 "card_id"=>$f->id,
175 "gDossier"=>Dossier::id()
176 ]));
177 $html.=$button_pdf;
178 // Display a remove button if not used and can modify card
179 if ( $can_modify == 1 && $f->is_used()==FALSE)
180 {
181 $js=str_replace('"',"'",json_encode(["gDossier"=>Dossier::id(),'op'=>'card','op2'=>"rm_card","f_id"=>$f->id,'ctl'=>$ctl]));
182 $html.=HtmlInput::button_action(_("Efface"), "delete_card($js)","x","smallbutton");
183 }
184 $html.='</p>';
185 if ($can_modify==1)
186 {
187 $html.='</form>';
188 }
189 }
190 }
191 else
192 {
193 $html.='<h2 class="error">'._('Aucune fiche demandée').'</h2>';
194 }
195 break;
196 /* ------------------------------------------------------------ */
197 /* Blank card */
198 /* ------------------------------------------------------------ */
199case 'bc':
200 if ( $g_user->check_action(FICADD)==1 || $g_user->check_action(FIC)==1)
201 {
202 /* get cat. name */
203 $cat_name=$cn->get_value('select fd_label from fiche_def where fd_id=$1',
204 array($fd_id));
205 $r=HtmlInput::title_box($cat_name, $ctl,p_draggable:true);
206 $f=new Fiche($cn);
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);
216 $r.='</p>';
217 if ( isset ($eltid)) {
218 $r.=HtmlInput::hidden("eltid", $eltid);
219 }
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);
223 $r.='</form>';
224 $html=$r;
225 }
226 else
227 {
228 $html=alert(_('Action interdite'),true);
229 }
230 break;
231 /* ------------------------------------------------------------ */
232 /* Show Type */
233 /* Before inserting a new card, the type must be selected */
234 /* ------------------------------------------------------------ */
235case 'st':
236 $sql="select fd_id,fd_label,fd_description from fiche_def";
237 /* if we filter thanks the ledger*/
238 if ( $ledger != -1 )
239 {
240 /* we want the card for deb or cred or both of this ledger */
241 switch( $fil )
242 {
243 case -1:
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().')';
248 break;
249 case 'cred':
250 $l=new Acc_Ledger($cn,$ledger);
251 $prop=$l->get_propertie();
252 if ( empty($prop) || empty($prop['jrn_def_fiche_cred']))
253 {
254 $where ="";
255 }else {
256 $where=' where fd_id in ('.$prop['jrn_def_fiche_cred'].')';
257 }
258 break;
259 case 'deb':
260 $l=new Acc_Ledger($cn,$ledger);
261 $prop=$l->get_propertie();
262 if ( empty($prop) || empty($prop['jrn_def_fiche_deb']) ) {
263 $where = "" ;
264 } else {
265 $where=' where fd_id in ('.$prop['jrn_def_fiche_deb'].')';
266 }
267 break;
268 }
269 }
270 else
271 {
272 /* we filter thanks a given model of card */
273 if ( isset($cat) && ! empty($cat))
274 {
275 $where=sprintf(' where frd_id in ('.sql_string ($cat).')');
276 }
277 elseif ( isset($fil) && noalyss_strlentrim($fil) > 0 && $fil != -1 )
278 {
279 /* we filter thanks a given list of category of card
280 */
281 $where=sprintf(" where fd_id in (%s)",
282 sql_string($fil));
283 } else
284 {
285 // create any type of cards
286 $where ="";
287 }
288 }
289 if ( strpos($where," in ()") != 0)
290 {
291 $html=_("Aucune catégorie de fiche ne correspond à".
292 " votre demande, le journal pourrait n'avoir accès à aucune fiche");
293 break;
294 }
295 $sql.=" ".$where." order by fd_label";
296 $array=$cn->get_array($sql);
297
298 $list_fiche="";
299 if ( empty($array))
300 {
301 $html=_("Aucune catégorie de fiche ne correspond à votre demande");
302 if ( DEBUGNOALYSS > 0 ) $html.=$sql;
303 }
304 else
305 {
306 $html=HtmlInput::title_box(_("Choix de la catégorie"), $ctl);
307 $r='';
308
309 $r.='<div dd>';
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++)
320 {
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'].'">';
325 $r.='<td >';
326 $r.='<a href="javascript:void(0)" onclick="select_cat(\''.$array[$i]['fd_id'].'\','.$gDossier.',\''.$eltid.'\')">'.h($array[$i]['fd_label']).'</a>';
327 $r.='</td>';
328 $r.='<td>';
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>';
331 $r.='</td>';
332
333 $r.="</tr>";
334 }
335
336 $r.='</table>';
337 $r.=HtmlInput::hidden('fd_id',0);
338 $r.='<p style="text-align:center">';
339 $r.=HtmlInput::button('Fermer',_('Fermer')," onclick=\"removeDiv('$ctl')\" ");
340 $r.='</p>';
341 $r.='</div>';
342 $html.=$r;
343
344 }
345 $xml=escape_xml($html);
346if (!defined("TEST_UNIT")) header('Content-type: text/xml; charset=UTF-8');
347echo <<<EOF
348<?xml version="1.0" encoding="UTF-8"?>
349<data>
350<ctl>$ctl</ctl>
351<code>$xml</code>
352<fiche_cat>{$list_fiche}</fiche_cat>
353</data>
354EOF;
355return;
356
357 break;
358 /*----------------------------------------------------------------------
359 * SC save card
360 * save the new card (insert)
361 *
362 ----------------------------------------------------------------------*/
363case 'sc':
364
365 if ( $g_user->check_action(FICADD)==1 )
366 {
367 $f=new Fiche($cn);
368 $status="<status>OK</status>";
369 try {
370 $f->insert($fd_id,$_POST);
371 $f->Get();
372 $after_save=$http->post("after_save","number",0);
373
374 // Action after save = 0, the card is display one second and fade out
375 //
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);
380 $js="";
381 if ( isset( $_POST['ref'])) $js=create_script(' window.location.reload()');
382 $html.=$js;
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>";
387
388
389 }
390 $extra.=$status;
391 $extra.="<after_save>0</after_save>";
392
393 }
394 // Action after save = 1 ; after adding a card the table must be updated
395 // see fiche.inc.php
396 //
397 if ( $after_save == 1 ){
398 $f_id=$f->id;
399 ob_start();
400 $detail=Icon_Action::modify("mod".$f_id, sprintf("modify_card('%s')",$f_id)).
401 "&nbsp;".
402 Icon_Action::trash("del".$f_id, sprintf("delete_card_id('%s')",$f_id));
403 $html = td($detail);
404 $html .= $f->display_row();
405 $html.=ob_get_contents();
406 ob_clean();
407 $extra="<f_id>".$f_id."</f_id>";
408 $ctl="row_card".$f_id;
409 $extra.="<after_save>1</after_save>";
410
411 }
412 } catch (Exception $exc) {
413 $html="<h2 class=\"error\">"._("Erreur sauvegarde")."</h2>";
414 $html.=$exc->getMessage();
415 $status="<status>NOK</status>";
416 $extra=$status;
417 }
418
419 }
420 else
421 {
422 $html.=alert(_('Action interdite'),true);
423 $html.=HtmlInput::button_close($ctl);
424 }
425 break;
426 /*----------------------------------------------------------------------
427 * Search a card
428 *
429 *----------------------------------------------------------------------*/
430case 'fs':
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:'';
435 $r.='<span style="margin-left:50px">';
436 $r.=_('Fiche contenant').Icon_Action::infobulle(19);
437 $r.=$q->input();
438 $r.=HtmlInput::submit('fs',_('Recherche'),"","smallbutton");
439 $r.='</span>';
440 $r.=dossier::hidden().HtmlInput::hidden('op','fs');
441 $array=array();
442
443 // to navigate
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();
450
451 // save previous info
452 $hidden="";
453 foreach (array('accvis','inp','jrn','label','typecard','price','tvaid','amount_from_type') as $i)
454 {
455 if (isset(${$i}) )
456 {
457 $r.=HtmlInput::hidden($i,${$i});
458 $hidden.=HtmlInput::hidden($i,${$i});
459 $sql_array[$i]=${$i};
460 }
461 }
462 $r.="</form>";
463
464 $sql_array["query"]=$query;
465 $sql_array["inactive_card"]=$inactive;
466 /* what is the type of the ledger */
467 $type="GL";
468 if (isset($jrn) && $jrn > 1)
469 {
470 $ledger=new Acc_Ledger($cn,$jrn);
471 $type=$ledger->get_type();
472 }
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");
476 }
477 $fiche=new Fiche($cn);
478 /* Build the SQL and show result */
479 $sql=$fiche->build_sql($sql_array);
480
481 if ( strpos($sql," in ()") != 0)
482 {
483 $html="";
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");
488 $html.='</h3>';
489 $html.=HtmlInput::button_close("search_card");
490 break;
491 }
492 /**
493 * if inactive == 0 , then only active card
494 */
495 if ( $inactive == 0 ) {
496 $sql.=" and f_enable='1' ";
497 }
498
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");
502
503 $record_start=$page_card*MAX_SEARCH_CARD;
504 $sql.=' limit '.MAX_SEARCH_CARD.' offset '.$record_start;
505
506 $aFound=$cn->get_array($sql);
507 $nb_found=count($aFound);
508 for($i=0;$i<$nb_found;$i++)
509 {
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'])));
519
520 // var $rownb (int) number of the row
521 $rownb=preg_replace('/[^0-9]/','',$label);
522
523
524 /* if it is a ledger of sales we use vw_buy
525 if it is a ledger of purchase we use vw_sell*/
526
527 if ( $type=="ACH" ){
528 $amount=(isNumber($aFound[$i]['vw_buy']) == 1 )?$aFound[$i]['vw_buy']:0;
529 $array[$i]['javascript'].=sprintf("set_value('%s','%s');",
530 $price,$amount);
531 }
532 if ( $type=="VEN" ){
533 $amount=(isNumber($aFound[$i]['vw_sell']) == 1 )?$aFound[$i]['vw_sell']:0;
534 $array[$i]['javascript'].=sprintf("set_value('%s','%s');",
535 $price,$amount);
536 }
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');",
540 $tvaid,$tva_code);
541 $array[$i]['javascript'].="removeDiv('search_card');";
542 $array[$i]['javascript'].=(empty($tva_code))?"":"compute_ledger($rownb);";
543 }//foreach
544
545 ob_start();
546 require_once NOALYSS_TEMPLATE.'/card_result.php';
547 $r.=ob_get_contents();
548 $r.='<ul class="aligned-block ">';
549 $r.='<li>';
550 $r.=HtmlInput::button_close("search_card");
551 $r.='</li>';
552 if ($g_user->check_action(FICADD)==1)
553 {
554 $r.='<li>';
555 $create_card_js='onclick="select_card_type({});"';
556 $r.=HtmlInput::button_anchor(_("Créer fiche"),"javascript:void(0)","",$create_card_js,'smallbutton');
557 $r.='</li>';
558 }
559 $r.='</ul>';
560
561 ob_end_clean();
562 $ctl=$ctl.'_content';
563 $html=$r;
564 break;
565 case 'action_add_concerned_card':
566 require_once NOALYSS_INCLUDE.'/ajax/ajax_add_concerned_card.php';
567 return;
568 break;
569// add several card to an action follow⁻up
570 case 'link_concerned_card':
571 require NOALYSS_INCLUDE.'/ajax/ajax_action_save_concerned.php';
572 return;
573// remove card from an action follow⁻up
574 case 'action_remove_concerned':
575 require NOALYSS_INCLUDE.'/ajax/ajax_action_remove_concerned.php';
576 return;
577case 'ac':
578 if ( $g_user->check_action(FICCAT)==1 )
579 {
580
581 /*----------------------------------------------------------------------
582 * Add a category, display first the form
583 *
584 *----------------------------------------------------------------------*/
585 $ipopup=str_replace('_content','',$ctl);
586 $msg="";$base="";
587 switch($cat)
588 {
589 case FICHE_TYPE_CLIENT:
590 $msg=_(' de clients');
591 $base=$cn->get_value("select p_value from parm_code where p_code='CUSTOMER'");
592 break;
593 case FICHE_TYPE_FOURNISSEUR:
594 $msg=_(' de fournisseurs');
595 $base=$cn->get_value("select p_value from parm_code where p_code='SUPPLIER'");
596 break;
597 case FICHE_TYPE_ADM_TAX:
598 $msg=_(' d\'administration');
599 $base='';
600 break;
601 case FICHE_TYPE_CONTACT:
602 $msg=_(' de contacts');
603 $base='';
604 break;
605 case FICHE_TYPE_FIN:
606 $msg=_(' Banque');
607 $base=$cn->get_value("select p_value from parm_code where p_code='BANQUE'");
608 break;
609 case FICHE_TYPE_EMPL:
610 $msg=_(' Employé ou administrateur');
611 $base='';
612 break;
613
614 }
615
616 $html='';
617 /* show the form */
618
619 $search=new IPoste("class_base");
620 $search->size=40;
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');
626
627 $nom_mod=new IText("nom_mod");
628 $str_poste=$search->input();
629 $submit=HtmlInput::submit('save',_('Sauve'));
630 ob_start();
631 require(NOALYSS_TEMPLATE.'/category_of_card.php');
632 $html.=ob_get_contents();
633 ob_end_clean();
634
635 }
636 else
637 {
638 $html=alert(_('Action interdite'),true);
639 }
640 break;
641case 'scc':
642 /*----------------------------------------------------------------------
643 * Save card Category into the database and return a ok message
644 *
645 *----------------------------------------------------------------------*/
646 $html='';
647 $invalid=0;
648 if ( $g_user->check_action(FICCAT) == 1 )
649 {
650
651 $html="";
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 )
656 {
657 $array=array("FICHE_REF"=>$cat,
658 "nom_mod"=>$nom_mod,
659 "class_base"=>$class_base,
660 "fd_description"=>$fd_description);
661
662 if ( isset ($_POST['create'])) $array['create']="on";
663
664 $catcard=new Fiche_Def($cn);
665
666 ob_start();
667 $result=$catcard->Add($array);
668
669 $html.=ob_get_contents();
670 ob_end_clean();
671
672 if ( $result == 1)
673 {
674 $script="alert_box('"._('Catégorie existe déjà')."')";
675 $invalid=1;
676 }
677 else{
678 $script="alert_box('"._('Catégorie sauvée')."');removeDiv('$ctl')";
679 // add code to update the SELECT in include/template/category_of_card.php
680 $catcard->get();
681
682 $extra = '<code2>'.
683 '<id>'.$catcard->id.'</id>'.
684 '<name>'. escape_xml($catcard->label).'</name>'.
685 '</code2>';
686
687 }
688
689 $html.=create_script($script);
690 }
691 else
692 {
693 $script="alert_box('"._("Le nom ne peut pas être vide")."')";
694 $html.=create_script($script);
695
696 $invalid=1;
697 }
698 }
699 else
700 {
701 $html=alert(_('Action interdite'),true);
702 $invalid=1;
703 }
704 if ($invalid == 1) {
705 $ctl="info_div";
706 }
707 break;
708
709// Update a card and then display the result
710// in a readonly box
711case 'upc':
712 $html=HtmlInput::title_box("Détail fiche", $ctl);
713
714 if ( $g_user->check_action(FICADD)==0 )
715 {
716 $html.=alert(_('Action interdite'),true);
717 }
718 else
719 {
720 if ($cn->get_value('select count(*) from fiche where f_id=$1',array($_GET['f_id'])) == '0' )
721 {
722 $html.=alert(_('Fiche non valide'),true);
723 }
724
725 else
726 {
727 $html=HtmlInput::title_box(_('Détail fiche (sauvée)'),$ctl);
728
729 $f=new Fiche($cn,$_GET['f_id']);
730 ob_start();
731 $f->update($_GET);
732 $html.=ob_get_contents();
733 ob_end_clean();
734 $html.=$f->Display(true);
735 }
736 }
737 $html.='<p style="text-align:center">'.HtmlInput::button_close($ctl).'</p>';
738 break;
739// Update a card and then display the result
740// in the table
741case 'upr':
742 $f_id=$http->get("f_id","number");
743 $html="";
744 if ( $g_user->check_action(FICADD)==0 )
745 {
746 $html.=alert(_('Action interdite'),true);
747 }
748 else
749 {
750 if ($cn->get_value('select count(*) from fiche where f_id=$1',array($f_id)) == '0' )
751 {
752 $html.=alert(_('Fiche non valide'),true);
753 }
754
755 else
756 {
757
758 $f=new Fiche($cn,$f_id );
759 ob_start();
760 $f->update($_GET);
761 $detail=Icon_Action::modify("mod".$f_id, sprintf("modify_card('%s')",$f_id)).
762 "&nbsp;".
763 Icon_Action::trash("del".$f_id, sprintf("delete_card_id('%s')",$f_id));
764 $html.=td($detail);
765 $html.=$f->display_row();
766 $html.=ob_get_contents();
767 ob_end_clean();
768 }
769 }
770 break;
771
772
773
774//------------------------------------------------------------------
775// Unlink a card
776//------------------------------------------------------------------
777 case 'rm_card':
778 $html=HtmlInput::title_box("Détail fiche", $ctl);
779
780 if ( $g_user->check_action(FIC)==0 )
781 {
782 $html.=alert(_('Action interdite'),true);
783 }
784 else
785 {
786 if ($cn->get_value('select count(*) from fiche where f_id=$1',array($_GET['f_id'])) == '0' )
787 {
788 $html.=alert(_('Fiche non valide'),true);
789 }
790
791 else
792 {
793
794 $f=new Fiche($cn,$_GET['f_id']);
795 if ( $f->is_used()==0){
796 $f->delete();
797 $html="OK";
798 } else {
799 $html="";
800 $html=_("Fiche non effacée");
801 }
802
803 }
804 }
805 break;
806 //---------------------------------------------------------------------------------------------------------------
807 // Display option of a contact in an action-followup
808 //---------------------------------------------------------------------------------------------------------------
809 case 'display_card_option':
810
811 require_once NOALYSS_INCLUDE.'/ajax/ajax_display_card_option.php';
812 return;
813 break;
814
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';
820 return;
821
822 break;
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';
828 return ;
829 break;
830
831} // switch
832$xml=escape_xml($html);
833if (DEBUGNOALYSS > 0 && headers_sent()) {
834 echo $html;return;
835}
836header('Content-type: text/xml; charset=UTF-8');
837echo <<<EOF
838<?xml version="1.0" encoding="UTF-8"?>
839<data>
840<ctl>$ctl</ctl>
841<code>$xml</code>
842$extra
843</data>
844EOF;
h2($p_string, $p_class="", $raw="")
Definition ac_common.php:68
span($p_string, $p_extra='')
Definition ac_common.php:43
p($p_string, $p_extra='')
Definition ac_common.php:39
tr($p_string, $p_extra='')
Definition ac_common.php:88
set_language()
set the lang thanks the _SESSION['g_lang'] var.
td($p_string='', $p_extra='')
surround the string with td
Definition ac_common.php:83
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
$cont
Definition ajax_card.php:65
$extra
Definition ajax_card.php:90
$var
Definition ajax_card.php:64
$ret label
$ret javascript
$anc_grandlivre from
$opd_description style
$_REQUEST['ac']
_("actif, passif,charge,...")
$input_from type
define Class fiche and fiche def, those class are using class attribut. When adding or modifing new c...
static followup_card_button($f_id, $p_mesg)
display a div with the history of the card
static history_card_button($f_id, $p_mesg, $p_exercice="")
display a div with the history of the card
static button_close($div_name, $class='smallbutton')
close button for the HTML popup
static button_action($action, $javascript, $id=NULL, $p_class="button", $p_symbole="")
button Html with javascript
static hidden($p_name, $p_value, $p_id="")
static button_anchor($p_label, $p_value, $p_name="", $p_javascript="", $p_class="smallbutton")
create a button with a ref
static title_box($p_name, $p_div, $p_mod="close", $p_js="", $p_draggable="n", $p_enlarge='n', $raw="", $refresh='')
Title for boxes, you can customize the symbol thanks symbol with the mode "custom".
static submit($p_name, $p_value, $p_javascript="", $p_class="smallbutton")
manage the http input (get , post, request) and extract from an array
Data & function about connected users.
$all table
const FICADD
const FIC
$bal jrn
for($e=0; $e< count($afiche); $e++) exit
$fd_id
$icard amount_from_type
vous n