noalyss Version-9
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" 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($array[$i]['fd_description'])."($nb_count)".'</a>';
330 $r.='</td>';
331
332 $r.="</tr>";
333 }
334
335 $r.='</table>';
336 $r.=HtmlInput::hidden('fd_id',0);
337 $r.='<p style="text-align:center">';
338 $r.=HtmlInput::button('Fermer',_('Fermer')," onclick=\"removeDiv('$ctl')\" ");
339 $r.='</p>';
340 $r.='</div>';
341 $html.=$r;
342
343 }
344 $xml=escape_xml($html);
345 header('Content-type: text/xml; charset=UTF-8');
346echo <<<EOF
347<?xml version="1.0" encoding="UTF-8"?>
348<data>
349<ctl>$ctl</ctl>
350<code>$xml</code>
351<fiche_cat>{$list_fiche}</fiche_cat>
352</data>
353EOF;
354return;
355
356 break;
357 /*----------------------------------------------------------------------
358 * SC save card
359 * save the new card (insert)
360 *
361 ----------------------------------------------------------------------*/
362case 'sc':
363
364 if ( $g_user->check_action(FICADD)==1 )
365 {
366 $f=new Fiche($cn);
367 $status="<status>OK</status>";
368 try {
369 $f->insert($fd_id,$_POST);
370 $f->Get();
371 $after_save=$http->post("after_save","number",0);
372
373 // Action after save = 0, the card is display one second and fade out
374 //
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);
379 $js="";
380 if ( isset( $_POST['ref'])) $js=create_script(' window.location.reload()');
381 $html.=$js;
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>";
386
387
388 }
389 $extra.=$status;
390 $extra.="<after_save>0</after_save>";
391
392 }
393 // Action after save = 1 ; after adding a card the table must be updated
394 // see fiche.inc.php
395 //
396 if ( $after_save == 1 ){
397 $f_id=$f->id;
398 ob_start();
399 $detail=Icon_Action::modify("mod".$f_id, sprintf("modify_card('%s')",$f_id)).
400 "&nbsp;".
401 Icon_Action::trash("del".$f_id, sprintf("delete_card_id('%s')",$f_id));
402 $html = td($detail);
403 $html .= $f->display_row();
404 $html.=ob_get_contents();
405 ob_clean();
406 $extra="<f_id>".$f_id."</f_id>";
407 $ctl="row_card".$f_id;
408 $extra.="<after_save>1</after_save>";
409
410 }
411 } catch (Exception $exc) {
412 $html="<h2 class=\"error\">"._("Erreur sauvegarde")."</h2>";
413 $html.=$exc->getMessage();
414 $status="<status>NOK</status>";
415 $extra=$status;
416 }
417
418 }
419 else
420 {
421 $html.=alert(_('Action interdite'),true);
422 $html.=HtmlInput::button_close($ctl);
423 }
424 break;
425 /*----------------------------------------------------------------------
426 * Search a card
427 *
428 *----------------------------------------------------------------------*/
429case 'fs':
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:'';
434 $r.='<span style="margin-left:50px">';
435 $r.=_('Fiche contenant').Icon_Action::infobulle(19);
436 $r.=$q->input();
437 $r.=HtmlInput::submit('fs',_('Recherche'),"","smallbutton");
438 $r.='</span>';
439 $r.=dossier::hidden().HtmlInput::hidden('op','fs');
440 $array=array();
441
442 // to navigate
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();
449
450 // save previous info
451 $hidden="";
452 foreach (array('accvis','inp','jrn','label','typecard','price','tvaid','amount_from_type') as $i)
453 {
454 if (isset(${$i}) )
455 {
456 $r.=HtmlInput::hidden($i,${$i});
457 $hidden.=HtmlInput::hidden($i,${$i});
458 $sql_array[$i]=${$i};
459 }
460 }
461 $r.="</form>";
462
463 $sql_array["query"]=$query;
464 $sql_array["inactive_card"]=$inactive;
465 /* what is the type of the ledger */
466 $type="GL";
467 if (isset($jrn) && $jrn > 1)
468 {
469 $ledger=new Acc_Ledger($cn,$jrn);
470 $type=$ledger->get_type();
471 }
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");
475 }
476 $fiche=new Fiche($cn);
477 /* Build the SQL and show result */
478 $sql=$fiche->build_sql($sql_array);
479
480 if ( strpos($sql," in ()") != 0)
481 {
482 $html="";
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");
487 $html.='</h3>';
488 $html.=HtmlInput::button_close("search_card");
489 break;
490 }
491 /**
492 * if inactive == 0 , then only active card
493 */
494 if ( $inactive == 0 ) {
495 $sql.=" and f_enable='1' ";
496 }
497
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");
501
502 $record_start=$page_card*MAX_SEARCH_CARD;
503 $sql.=' limit '.MAX_SEARCH_CARD.' offset '.$record_start;
504
505 $aFound=$cn->get_array($sql);
506 $nb_found=count($aFound);
507 for($i=0;$i<$nb_found;$i++)
508 {
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'])));
518
519
520 /* if it is a ledger of sales we use vw_buy
521 if it is a ledger of purchase we use vw_sell*/
522
523 if ( $type=="ACH" ){
524 $amount=(isNumber($aFound[$i]['vw_buy']) == 1 )?$aFound[$i]['vw_buy']:0;
525 $array[$i]['javascript'].=sprintf("set_value('%s','%s');",
526 $price,$amount);
527 }
528 if ( $type=="VEN" ){
529 $amount=(isNumber($aFound[$i]['vw_sell']) == 1 )?$aFound[$i]['vw_sell']:0;
530 $array[$i]['javascript'].=sprintf("set_value('%s','%s');",
531 $price,$amount);
532 }
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');",
536 $tvaid,$tva_code);
537 $array[$i]['javascript'].="removeDiv('search_card');";
538
539 }//foreach
540
541 ob_start();
542 require_once NOALYSS_TEMPLATE.'/card_result.php';
543 $r.=ob_get_contents();
544 $r.=HtmlInput::button_close("search_card");
545 ob_end_clean();
546 $ctl=$ctl.'_content';
547 $html=$r;
548 break;
549 case 'action_add_concerned_card':
550 require_once NOALYSS_INCLUDE.'/ajax/ajax_add_concerned_card.php';
551 return;
552 break;
553// add several card to an action follow⁻up
554 case 'link_concerned_card':
555 require NOALYSS_INCLUDE.'/ajax/ajax_action_save_concerned.php';
556 return;
557// remove card from an action follow⁻up
558 case 'action_remove_concerned':
559 require NOALYSS_INCLUDE.'/ajax/ajax_action_remove_concerned.php';
560 return;
561case 'ac':
562 if ( $g_user->check_action(FICCAT)==1 )
563 {
564
565 /*----------------------------------------------------------------------
566 * Add a category, display first the form
567 *
568 *----------------------------------------------------------------------*/
569 $ipopup=str_replace('_content','',$ctl);
570 $msg="";$base="";
571 switch($cat)
572 {
573 case FICHE_TYPE_CLIENT:
574 $msg=_(' de clients');
575 $base=$cn->get_value("select p_value from parm_code where p_code='CUSTOMER'");
576 break;
577 case FICHE_TYPE_FOURNISSEUR:
578 $msg=_(' de fournisseurs');
579 $base=$cn->get_value("select p_value from parm_code where p_code='SUPPLIER'");
580 break;
581 case FICHE_TYPE_ADM_TAX:
582 $msg=_(' d\'administration');
583 $base='';
584 break;
585 case FICHE_TYPE_CONTACT:
586 $msg=_(' de contacts');
587 $base='';
588 break;
589 case FICHE_TYPE_FIN:
590 $msg=_(' Banque');
591 $base=$cn->get_value("select p_value from parm_code where p_code='BANQUE'");
592 break;
593 case FICHE_TYPE_EMPL:
594 $msg=_(' Employé ou administrateur');
595 $base='';
596 break;
597
598 }
599
600 $html='';
601 /* show the form */
602
603 $search=new IPoste("class_base");
604 $search->size=40;
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');
610
611 $nom_mod=new IText("nom_mod");
612 $str_poste=$search->input();
613 $submit=HtmlInput::submit('save',_('Sauve'));
614 ob_start();
615 require(NOALYSS_TEMPLATE.'/category_of_card.php');
616 $html.=ob_get_contents();
617 ob_end_clean();
618
619 }
620 else
621 {
622 $html=alert(_('Action interdite'),true);
623 }
624 break;
625case 'scc':
626 /*----------------------------------------------------------------------
627 * Save card Category into the database and return a ok message
628 *
629 *----------------------------------------------------------------------*/
630 $html='';
631 $invalid=0;
632 if ( $g_user->check_action(FICCAT) == 1 )
633 {
634
635 $html="";
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 )
640 {
641 $array=array("FICHE_REF"=>$cat,
642 "nom_mod"=>$nom_mod,
643 "class_base"=>$class_base,
644 "fd_description"=>$fd_description);
645
646 if ( isset ($_POST['create'])) $array['create']=1;
647
648 $catcard=new Fiche_Def($cn);
649
650 ob_start();
651 $result=$catcard->Add($array);
652
653 $html.=ob_get_contents();
654 ob_end_clean();
655
656 if ( $result == 1)
657 {
658 $script="alert_box('"._('Catégorie existe déjà')."')";
659 $invalid=1;
660 }
661 else{
662 $script="alert_box('"._('Catégorie sauvée')."');removeDiv('$ctl')";
663 }
664
665 $html.=create_script($script);
666 }
667 else
668 {
669 $script="alert_box('"._("Le nom ne peut pas être vide")."')";
670 $html.=create_script($script);
671
672 $invalid=1;
673 }
674 }
675 else
676 {
677 $html=alert(_('Action interdite'),true);
678 $invalid=1;
679 }
680 if ($invalid == 1) {
681 $ctl="info_div";
682 }
683 break;
684
685// Update a card and then display the result
686// in a readonly box
687case 'upc':
688 $html=HtmlInput::title_box("Détail fiche", $ctl);
689
690 if ( $g_user->check_action(FICADD)==0 )
691 {
692 $html.=alert(_('Action interdite'),true);
693 }
694 else
695 {
696 if ($cn->get_value('select count(*) from fiche where f_id=$1',array($_GET['f_id'])) == '0' )
697 {
698 $html.=alert(_('Fiche non valide'),true);
699 }
700
701 else
702 {
703 $html=HtmlInput::title_box(_('Détail fiche (sauvée)'),$ctl);
704
705 $f=new Fiche($cn,$_GET['f_id']);
706 ob_start();
707 $f->update($_GET);
708 $html.=ob_get_contents();
709 ob_end_clean();
710 $html.=$f->Display(true);
711 }
712 }
713 $html.='<p style="text-align:center">'.HtmlInput::button_close($ctl).'</p>';
714 break;
715// Update a card and then display the result
716// in the table
717case 'upr':
718 $f_id=$http->get("f_id","number");
719 $html="";
720 if ( $g_user->check_action(FICADD)==0 )
721 {
722 $html.=alert(_('Action interdite'),true);
723 }
724 else
725 {
726 if ($cn->get_value('select count(*) from fiche where f_id=$1',array($f_id)) == '0' )
727 {
728 $html.=alert(_('Fiche non valide'),true);
729 }
730
731 else
732 {
733
734 $f=new Fiche($cn,$f_id );
735 ob_start();
736 $f->update($_GET);
737 $detail=Icon_Action::modify("mod".$f_id, sprintf("modify_card('%s')",$f_id)).
738 "&nbsp;".
739 Icon_Action::trash("del".$f_id, sprintf("delete_card_id('%s')",$f_id));
740 $html.=td($detail);
741 $html.=$f->display_row();
742 $html.=ob_get_contents();
743 ob_end_clean();
744 }
745 }
746 break;
747
748
749
750//------------------------------------------------------------------
751// Unlink a card
752//------------------------------------------------------------------
753 case 'rm_card':
754 $html=HtmlInput::title_box("Détail fiche", $ctl);
755
756 if ( $g_user->check_action(FIC)==0 )
757 {
758 $html.=alert(_('Action interdite'),true);
759 }
760 else
761 {
762 if ($cn->get_value('select count(*) from fiche where f_id=$1',array($_GET['f_id'])) == '0' )
763 {
764 $html.=alert(_('Fiche non valide'),true);
765 }
766
767 else
768 {
769
770 $f=new Fiche($cn,$_GET['f_id']);
771 if ( $f->is_used()==0){
772 $f->delete();
773 $html="OK";
774 } else {
775 $html="";
776 $html=_("Fiche non effacée");
777 }
778
779 }
780 }
781 break;
782 //---------------------------------------------------------------------------------------------------------------
783 // Display option of a contact in an action-followup
784 //---------------------------------------------------------------------------------------------------------------
785 case 'display_card_option':
786
787 require_once NOALYSS_INCLUDE.'/ajax/ajax_display_card_option.php';
788 return;
789 break;
790
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';
796 return;
797
798 break;
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';
804 return ;
805 break;
806
807} // switch
808$xml=escape_xml($html);
809if (DEBUGNOALYSS > 0 && headers_sent()) {
810 echo $html;return;
811}
812header('Content-type: text/xml; charset=UTF-8');
813echo <<<EOF
814<?xml version="1.0" encoding="UTF-8"?>
815<data>
816<ctl>$ctl</ctl>
817<code>$xml</code>
818$extra
819</data>
820EOF;
h2($p_string, $p_class="", $raw="")
Definition ac_common.php:68
span($p_string, $p_extra='')
Definition ac_common.php:43
tr($p_string, $p_extra='')
Definition ac_common.php:88
p($p_string)
Definition ac_common.php:39
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
$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="")
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