noalyss Version-9
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
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);
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(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 $array[$i]['javascript'].=sprintf("set_value('%s','%s');",
534 $tvaid,$aFound[$i]['tva_id']);
535 $array[$i]['javascript'].="removeDiv('search_card');";
536
537 }//foreach
538
539 ob_start();
540 require_once NOALYSS_TEMPLATE.'/card_result.php';
541 $r.=ob_get_contents();
542 $r.=HtmlInput::button_close("search_card");
543 ob_end_clean();
544 $ctl=$ctl.'_content';
545 $html=$r;
546 break;
547 case 'action_add_concerned_card':
548 require_once NOALYSS_INCLUDE.'/ajax/ajax_add_concerned_card.php';
549 return;
550 break;
551// add several card to an action follow⁻up
552 case 'link_concerned_card':
553 require NOALYSS_INCLUDE.'/ajax/ajax_action_save_concerned.php';
554 return;
555// remove card from an action follow⁻up
556 case 'action_remove_concerned':
557 require NOALYSS_INCLUDE.'/ajax/ajax_action_remove_concerned.php';
558 return;
559case 'ac':
560 if ( $g_user->check_action(FICCAT)==1 )
561 {
562
563 /*----------------------------------------------------------------------
564 * Add a category, display first the form
565 *
566 *----------------------------------------------------------------------*/
567 $ipopup=str_replace('_content','',$ctl);
568 $msg="";$base="";
569 switch($cat)
570 {
572 $msg=_(' de clients');
573 $base=$cn->get_value("select p_value from parm_code where p_code='CUSTOMER'");
574 break;
576 $msg=_(' de fournisseurs');
577 $base=$cn->get_value("select p_value from parm_code where p_code='SUPPLIER'");
578 break;
580 $msg=_(' d\'administration');
581 $base='';
582 break;
584 $msg=_(' de contacts');
585 $base='';
586 break;
587 case FICHE_TYPE_FIN:
588 $msg=_(' Banque');
589 $base=$cn->get_value("select p_value from parm_code where p_code='BANQUE'");
590 break;
591 case FICHE_TYPE_EMPL:
592 $msg=_(' Employé ou administrateur');
593 $base='';
594 break;
595
596 }
597
598 $html='';
599 /* show the form */
600
601 $search=new IPoste("class_base");
602 $search->size=40;
603 $search->value=$base;
604 $search->label=_("Recherche poste");
605 $search->set_attribute('gDossier',dossier::id());
606 $search->set_attribute('account',$search->name);
607 $search->set_attribute('ipopup','ipop_account');
608
609 $nom_mod=new IText("nom_mod");
610 $str_poste=$search->input();
611 $submit=HtmlInput::submit('save',_('Sauve'));
612 ob_start();
613 require(NOALYSS_TEMPLATE.'/category_of_card.php');
614 $html.=ob_get_contents();
615 ob_end_clean();
616
617 }
618 else
619 {
620 $html=alert(_('Action interdite'),true);
621 }
622 break;
623case 'scc':
624 /*----------------------------------------------------------------------
625 * Save card Category into the database and return a ok message
626 *
627 *----------------------------------------------------------------------*/
628 $html='';
629 $invalid=0;
630 if ( $g_user->check_action(FICCAT) == 1 )
631 {
632
633 $html="";
634 $nom_mod=$http->get("nom_mod");
635 $class_base=$http->get("class_base");
636 $fd_description=$http->get("nom_mod");
637 if ( noalyss_strlentrim($nom_mod) != 0 )
638 {
639 $array=array("FICHE_REF"=>$cat,
640 "nom_mod"=>$nom_mod,
641 "class_base"=>$class_base,
642 "fd_description"=>$fd_description);
643
644 if ( isset ($_POST['create'])) $array['create']=1;
645
646 $catcard=new Fiche_Def($cn);
647
648 ob_start();
649 $result=$catcard->Add($array);
650
651 $html.=ob_get_contents();
652 ob_end_clean();
653
654 if ( $result == 1)
655 {
656 $script="alert_box('"._('Catégorie existe déjà')."')";
657 $invalid=1;
658 }
659 else{
660 $script="alert_box('"._('Catégorie sauvée')."');removeDiv('$ctl')";
661 }
662
664 }
665 else
666 {
667 $script="alert_box('"._("Le nom ne peut pas être vide")."')";
669
670 $invalid=1;
671 }
672 }
673 else
674 {
675 $html=alert(_('Action interdite'),true);
676 $invalid=1;
677 }
678 if ($invalid == 1) {
679 $ctl="info_div";
680 }
681 break;
682
683// Update a card and then display the result
684// in a readonly box
685case 'upc':
686 $html=HtmlInput::title_box("Détail fiche", $ctl);
687
688 if ( $g_user->check_action(FICADD)==0 )
689 {
690 $html.=alert(_('Action interdite'),true);
691 }
692 else
693 {
694 if ($cn->get_value('select count(*) from fiche where f_id=$1',array($_GET['f_id'])) == '0' )
695 {
696 $html.=alert(_('Fiche non valide'),true);
697 }
698
699 else
700 {
701 $html=HtmlInput::title_box(_('Détail fiche (sauvée)'),$ctl);
702
703 $f=new Fiche($cn,$_GET['f_id']);
704 ob_start();
705 $f->update($_GET);
706 $html.=ob_get_contents();
707 ob_end_clean();
708 $html.=$f->Display(true);
709 }
710 }
711 $html.='<p style="text-align:center">'.HtmlInput::button_close($ctl).'</p>';
712 break;
713// Update a card and then display the result
714// in the table
715case 'upr':
716 $f_id=$http->get("f_id","number");
717 $html="";
718 if ( $g_user->check_action(FICADD)==0 )
719 {
720 $html.=alert(_('Action interdite'),true);
721 }
722 else
723 {
724 if ($cn->get_value('select count(*) from fiche where f_id=$1',array($f_id)) == '0' )
725 {
726 $html.=alert(_('Fiche non valide'),true);
727 }
728
729 else
730 {
731
732 $f=new Fiche($cn,$f_id );
733 ob_start();
734 $f->update($_GET);
735 $detail=Icon_Action::modify("mod".$f_id, sprintf("modify_card('%s')",$f_id)).
736 "&nbsp;".
737 Icon_Action::trash("del".$f_id, sprintf("delete_card_id('%s')",$f_id));
738 $html.=td($detail);
739 $html.=$f->display_row();
740 $html.=ob_get_contents();
741 ob_end_clean();
742 }
743 }
744 break;
745
746
747
748//------------------------------------------------------------------
749// Unlink a card
750//------------------------------------------------------------------
751 case 'rm_card':
752 $html=HtmlInput::title_box("Détail fiche", $ctl);
753
754 if ( $g_user->check_action(FIC)==0 )
755 {
756 $html.=alert(_('Action interdite'),true);
757 }
758 else
759 {
760 if ($cn->get_value('select count(*) from fiche where f_id=$1',array($_GET['f_id'])) == '0' )
761 {
762 $html.=alert(_('Fiche non valide'),true);
763 }
764
765 else
766 {
767
768 $f=new Fiche($cn,$_GET['f_id']);
769 if ( $f->is_used()==0){
770 $f->delete();
771 $html="OK";
772 } else {
773 $html="";
774 $html=_("Fiche non effacée");
775 }
776
777 }
778 }
779 break;
780 //---------------------------------------------------------------------------------------------------------------
781 // Display option of a contact in an action-followup
782 //---------------------------------------------------------------------------------------------------------------
783 case 'display_card_option':
784
785 require_once NOALYSS_INCLUDE.'/ajax/ajax_display_card_option.php';
786 return;
787 break;
788
789 //---------------------------------------------------------------------------------------------------------------
790 // Save option of a contact in an action-followup
791 //---------------------------------------------------------------------------------------------------------------
792 case 'save_card_option':
793 require_once NOALYSS_INCLUDE.'/ajax/ajax_save_card_option.php';
794 return;
795
796 break;
797 // ----------------------------------------------------------------------------------------------------------------
798 // Display a list of other card linked to the event / followup
799 // ----------------------------------------------------------------------------------------------------------------
800 case 'action_concerned_list':
801 require_once NOALYSS_INCLUDE.'/ajax/ajax_action_concerned_list.php';
802 return ;
803 break;
804
805} // switch
807if (DEBUGNOALYSS > 0 && headers_sent()) {
808 echo $html;return;
809}
810header('Content-type: text/xml; charset=UTF-8');
811echo <<<EOF
812<?xml version="1.0" encoding="UTF-8"?>
813<data>
814<ctl>$ctl</ctl>
815<code>$xml</code>
816$extra
817</data>
818EOF;
h2($p_string, $p_class="", $raw="")
Definition: ac_common.php:68
isNumber($p_int)
Definition: ac_common.php:215
span($p_string, $p_extra='')
Definition: ac_common.php:43
noalyss_strlentrim($p_string)
Definition: ac_common.php:1549
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.
Definition: ac_common.php:754
td($p_string='', $p_extra='')
surround the string with td
Definition: ac_common.php:83
j($p_string)
escape correctly php string to javascript
Definition: ac_common.php:96
alert($p_msg, $buffer=false)
alert in javascript
Definition: ac_common.php:738
$base
Definition: action.inc.php:56
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'])
$cn
Definition: ajax_card.php:82
$cont
Definition: ajax_card.php:65
$extra
Definition: ajax_card.php:90
$html
Definition: ajax_card.php:87
$http
Definition: ajax_card.php:81
global $g_user
Definition: ajax_card.php:83
$var
Definition: ajax_card.php:64
switch($op2) $xml
Definition: ajax_card.php:806
$ret label
$anc_grandlivre from
$opd_description style
$_REQUEST['ac']
$input_from id
Definition: balance.inc.php:63
$input_from type
Definition: balance.inc.php:65
$_GET['qcode']
static id()
return the 'gDossier' value after a check
static connect()
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...
Definition: fiche.class.php:38
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 title_box($p_name, $p_div, $p_mod="close", $p_js="", $p_draggable="n", $p_enlarge='n')
Title for boxes, you can customize the symbol thanks symbol with the mode "custom".
static button_anchor($p_label, $p_value, $p_name="", $p_javascript="", $p_class="smallbutton")
create a button with a ref
static submit($p_name, $p_value, $p_javascript="", $p_class="smallbutton")
manage the http input (get , post, request) and extract from an array
show a button, for selecting a account and a input text for manually inserting an account the differe...
Html Input.
Definition: itext.class.php:30
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.
$all table
const FICHE_TYPE_ADM_TAX
Definition: constant.php:253
const FICHE_TYPE_FIN
Definition: constant.php:250
const FICHE_TYPE_CONTACT
Definition: constant.php:251
const FICHE_TYPE_CLIENT
Definition: constant.php:247
const FICHE_TYPE_EMPL
Definition: constant.php:252
const FICHE_TYPE_FOURNISSEUR
Definition: constant.php:249
const FICCAT
const FICADD
const FIC
$_POST['ac']
Definition: do.php:310
$bal jrn
for($e=0; $e< count($afiche); $e++) exit
$fd_id
Definition: fiche.inc.php:104
$icard amount_from_type
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,...
vous n
Definition: modele.inc.php:398
$script
Definition: popup.php:125