2 * This file is part of NOALYSS.
4 * NOALYSS is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * NOALYSS is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with NOALYSS; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20// Copyright Author Dany De Bontridder danydb@aevalys.eu
24 * javascript for searching a card
28 * search a card an display the result into a inner box
30function boxsearch_card(p_dossier)
35 removeDiv('boxsearch_card_div');
36 var queryString="gDossier="+p_dossier+"&op=cardsearch"+"&card="+encodeURI(id$("card_search").value);
37 var action = new Ajax.Request(
40 method:'get', parameters:queryString,
41 onFailure:ajax_misc_failure,
42 onSuccess:function(req){
44 if (req.responseText == 'NOCONX') {
49 var div_style="position:absolute;"+";top:"+y+"px;z-index:"+get_next_layer();
50 add_div({id:'boxsearch_card_div',cssclass:'inner_box',html:loading(),style:div_style,drag:true});
51 id$('boxsearch_card_div').innerHTML=req.responseText;
52 sorttable.makeSortable(id$('tb_fiche'));
62 * show the ipopup with the form to search a card
65 * @param {int} obj.jrn for the ledger
66 * @param {int} obj.fs route to the action
67 * @param {string} obj.price for the price of the card (field to update)
68 * @param {string} obj.tvaid for the tvaid of the card (field to update)
69 * @param {string} obj.inp input text to update with the quickcode
70 * @param {string} obj.label field to update with the name
71 * @param {string} obj.ctl the id to fill with the HTML answer (ending with _content)
72 * @param {int} obj.acc 1 if accounting are visible
74function search_card(obj)
78 var gDossier=id$('gDossier').value;
80 var string_to_search=id$(inp).value;
82 var typecard=obj.typecard;
87 if ( obj.inactive_card) {inactive_card=obj.inactive_card.value;}
88 var amount_from_type=0;
89 if ( obj.amount_from_type) {
90 amount_from_type=obj.amount_from_type;
95 if ( document.getElementById('p_jrn')) {
96 jrn=id$('p_jrn').value;
102 var accvis=obj.accvis;
103 if ( accvis == undefined ) {
108 var query=encodeJSON({'gDossier':gDossier,
109 'inp':inp,'label':label,'price':price,'tvaid':tvaid,
110 'ctl':'search_card','op2':'fs','jrn':jrn,
111 'typecard':typecard,'query':string_to_search,'op':'card',
113 'amount_from_type':amount_from_type,
114 'inactive_card':inactive_card
116 if ( document.getElementById('search_card') ) {
117 removeDiv('search_card');
124 var action=new Ajax.Request ( 'ajax_misc.php',
129 onSuccess:result_card_search
135 alert_box('search_card failed'+e.message);
139 * Display found card and let you select several to link them to an action-followup
140 * @param {obj} obj form object
141 * @param {obj} obj form object
143function action_concerned_save_card(obj)
147 // get all data from FORM
148 var query = obj.serialize();
149 new Ajax.Request("ajax_misc.php", {
152 onSuccess: function (req) {
153 remove_waiting_box();
154 var answer = req.responseXML;
155 var a = answer.getElementsByTagName('ctl');
158 var rec = req.responseText;
159 alert_box('erreur :' + rec);
161 var html = answer.getElementsByTagName('code');
162 var namectl = a[0].firstChild.nodeValue;
163 var nodeXml = html[0];
164 var code_html = getNodeText(nodeXml);
165 code_html = unescape_xml(code_html);
166 id$(namectl).update(code_html);
167 removeDiv('search_card');
168 /* if dialog box exist with list other card, then refresh it */
169 if ( document.getElementById("action_concerned_list_dv") ) {
170 action_concerned_list({ag_id:obj.ag_id.value,dossier:obj.gDossier.value});
178 alert_box('action_concerned_save_card' + e.message);
184 * Display the list of other card from a followup action
185 * @returns {undefined}
187function action_concerned_list(p_obj) {
189 var action = new Ajax.Request('ajax_misc.php',
192 parameters: {gDossier: p_obj.dossier, op: 'card', 'op2': "action_concerned_list", "ag_id": p_obj.ag_id
193 ,"ctl":'action_concerned_list_dv'},
195 onSuccess: function (req, txt)
201 sx = window.scrollY + 40;
204 sx = document.body.scrollTop + 60;
206 var div_style = "top:" + sx + "px;z-index:"+get_next_layer();
207 add_div({id: 'action_concerned_list_dv', cssclass: 'inner_box', html: "",
208 style: div_style, drag: true});
209 remove_waiting_box();
210 var answer = req.responseXML;
211 var a = answer.getElementsByTagName('ctl');
214 var rec = req.responseText;
215 alert_box('erreur :' + rec);
217 var html = answer.getElementsByTagName('code');
218 var namectl = a[0].firstChild.nodeValue;
219 var nodeXml = html[0];
220 var code_html = getNodeText(nodeXml);
221 code_html = unescape_xml(code_html);
224 id$('action_concerned_list_dv').innerHTML = code_html;
226 alert_box(e.message);
232 alert_box("action_concerned_list" + e.message);
236 * Display form for searching cards to add to action-follow-up
237 *@see ajax_add_concerned_card.php
238 *@param {object} obj form object
239 *@param obj.elements.ag_id id of the action (elements)
240 *@param obj.elements.gDossier folder id
241 *@param obj.elements.query
243function action_concerned_search_card(obj)
255 dossier = obj.dossier; /* From the button */
262 if (obj.elements['gDossier'])
264 dossier = obj.elements['gDossier'].value;
267 if (obj.elements['query']) {
268 inp = obj.elements['query'].value;
271 if (obj.elements['ag_id']) {
272 ag_id = obj.elements['ag_id'].value;
274 if (obj.elements['search_in']) {
275 search_in = obj.elements['search_in'].value;
277 if ( obj.elements['inactive_card']) {
278 inactive_card=obj.elements['inactive_card'].value;
280 if ( obj.elements['search_cat']) {
281 search_cat=obj.elements['search_cat'].value;
285 throw "obj.dossier not found";
288 throw "obj.ag_id not found";
290 var query = encodeJSON({
292 'op2': 'action_add_concerned_card',
298 'search_in':search_in,
299 'inactive_card':inactive_card,
300 'search_cat':search_cat
306 var action = new Ajax.Request('ajax_misc.php',
311 onSuccess: function (req, txt)
314 remove_waiting_box();
315 var answer = req.responseXML;
316 var a = answer.getElementsByTagName('ctl');
319 var rec = req.responseText;
320 alert_box('erreur :' + rec);
322 var html = answer.getElementsByTagName('code');
323 var namectl = a[0].firstChild.nodeValue;
324 var nodeXml = html[0];
325 var code_html = getNodeText(nodeXml);
326 code_html = unescape_xml(code_html);
331 sx = window.scrollY + 40;
335 sx = document.body.scrollTop + 60;
337 var div_style = "top:" + sx + "px;height:52rem;z-index:"+get_next_layer();
338 if ( ! document.getElementById('search_card')) { add_div({id: 'search_card', cssclass: 'inner_box', html: "", style: div_style, drag: true}); }
339 id$('search_card').innerHTML = code_html;
340 id$('query').focus();
341 activate_checkbox_range('select_card_ck');
343 alert_box(e.message);
351 alert_box('search_card failed' + e.message);
358 * when you submit the form for searching a card
360 *@note the same as search_card, except it answer to a FORM and not
364function search_get_card(obj)
366 var dossier=id$('gDossier').value;
368 var queryString="gDossier="+dossier;
369 queryString+="&op2=fs&op=card";
371 if ( obj.elements['inp'] )
373 queryString+="&inp="+$F('inp');
375 if ( obj.elements['typecard'] )
377 queryString+="&typecard="+$F('typecard');
379 if ( obj.elements['jrn'] )
381 queryString+="&jrn="+$F('jrn');
383 if ( obj.elements['label'])
385 queryString+="&label="+$F('label');
387 if ( obj.elements['price'])
389 queryString+="&price="+$F('price');
391 if ( obj.elements['tvaid'])
393 queryString+="&tvaid="+$F('tvaid');
395 if( obj.elements['query'])
397 queryString+="&query="+$F('query');
401 queryString+="&ctl="+obj.ctl;
403 if ( obj.elements['accvis'] )
405 queryString+="&accvis="+$F('accvis');
407 queryString+="&accvis=0";
409 if ( obj.elements['amount_from_type']) {
410 queryString+="&amount_from_type="+obj.elements['amount_from_type'].value;
412 if (obj.elements['page_card']) {
413 queryString+="&page_card="+obj.elements["page_card"].value;
415 if ( obj.elements["inactive_card"]) {
416 queryString+="&inactive_card="+obj.elements["inactive_card"].value;
419 queryString=encodeURI(queryString);
420 id$('asearch').innerHTML=loading();
422 var action=new Ajax.Request ( 'ajax_misc.php',
425 parameters:queryString,
427 onSuccess:result_card_search
432 * show the answer of ajax request
433 * @see search_get_card
434 *@param answer in XML
436function result_card_search(req)
441 remove_waiting_box();
442 if ( req.responseText == 'NOCONX') { reconnect();return;}
443 var answer=req.responseXML;
444 var a=answer.getElementsByTagName('ctl');
447 var rec=req.responseText;
448 alert_box ('erreur :'+rec);
450 var html=answer.getElementsByTagName('code');
452 var name_ctl=a[0].firstChild.nodeValue;
454 var code_html=getNodeText(nodeXml);
455 code_html=unescape_xml(code_html);
460 sx=window.scrollY+40;
464 sx=document.body.scrollTop+60;
467 var div_style="top:"+sx+"px;min-height:80%;height:auto;z-index:"+get_next_layer();;
468 add_div({id:'search_card',cssclass:'inner_box',html:"",style:div_style,drag:false,effect:'blinddown'});
470 id$('search_card').innerHTML=code_html;
472 if (document.getElementById('query')) { id$('query').focus();}
476 alert_box(e.message);
480 code_html.evalScripts();
484 alert_box(content[53]+"\n"+e.message);
492 * Set the value of 2 input fields
494* Set the quick code in the first ctrl and the label of the quickcode in the second one. This function is a variant of SetData for
495* some specific need. This function is called if the caller is searchcardCtrl
497*@param p_ctrl the input with the name of the quick code
498*@param p_quickcode the found quick_code
499*@param p_ctrlname the name of the input field with the label
500*@param p_label the label of the quickcode
502function setCtrl(p_ctrl,p_quickcode,p_ctrlname,p_label)
504 var ctrl=id$(p_ctrl);
507 ctrl.value=p_quickcode;
509 var ctrl_name=id$(p_ctrlname);
512 ctrl_name.value=p_label;
519function errorFid(request,json)
521 alert_box(content[53]);
523function update_value(text,li)
528 * is called when something change in ICard
529 *@param the input field
532function fill_data_onchange(ctl)
538 * is called when something change in ICard
539 *@param the input field
542function fill_data(text,li)
548 * is called when something change in ICard
549 *@param the input field
552function fill_fin_data_onchange(ctl)
558 * is called when something change in ICard
559 *@param the input field
562function fill_fin_data(text,li)
565 ajax_saldo(id$(text.id));
568 * show the ipopup window and display the details of a card,
569 * to work some attribute must be set
570 *@param obj.qcode is the qcode, obj.nohistory if you don't want to display
571 * the history button, obj.ro is the popin is readonly
572 *@note you must the gDossier as hidden in the calling page
576function fill_ipopcard(obj)
579 var card_layer=get_next_layer();
581 var content='card_'+card_layer;
582 var nTop=170+card_layer;
586 var str_top="top:"+calcy(nTop)+"px";
588 var str_style=str_top+";height:auto;position:absolute;z-index:"+get_next_layer();
590 var popup={'id': content,'cssclass':'inner_box2','style':str_style,'html':"",'drag':false};
593 var dossier=id$('gDossier').value;
595 if ( obj.qcode != undefined )
601 qcode=id$(obj).value;
605 var queryString='gDossier='+dossier;
606 queryString+='&qcode='+qcode;
607 queryString+='&ctl='+content;
608 queryString+='&op2=dc'; // dc for detail card
609 queryString+='&op=card'; // dc for detail card
610 if ( obj.readonly != undefined) {
614 if ( obj.nohistory != undefined) {
615 queryString+='&nohistory';
617 if ( obj.nofollowup != undefined) {
618 queryString+='&nofollowup';
620 queryString=encodeURI(queryString);
621 var action=new Ajax.Request ( 'ajax_misc.php',
624 parameters:queryString,
632 * @param request : object request
633 * @param json : json answer
635function successFill_ipopcard(req,json)
639 if (req.responseText=='NOCONX') { reconnect();return; }
640 var answer=req.responseXML;
641 var a=answer.getElementsByTagName('ctl');
642 var html=answer.getElementsByTagName('code');
646 var rec=req.responseText;
647 alert_box ('erreur :'+rec);
649 var name_ctl=a[0].firstChild.nodeValue;
650 var code_html=getNodeText(html[0]);
651 code_html=unescape_xml(code_html);
653 id$(name_ctl).innerHTML=code_html;
657 alert_box(e.message);
661 code_html.evalScripts();
665 alert_box(content[53]+"\n"+e.message);
669 * show the ipopup for selecting a card type, it is a needed step before adding
671 *@param input field (obj) it must have the attribute ipopup
672 * possible attribute :
673 * - filter possible values are deb, cred, fd_id list, -1 means there is no filter
674 * - ref if we want to refresh the window after adding a card
675 * - type type of card (supplier, customer...)
678function select_card_type(obj)
680 var dossier=id$('gDossier').value;
682 // give a filter, -1 if not
683 var filter=id$(obj).filter;
684 if ( filter==undefined)
688 var content="select_card_div";
689 if ( document.getElementById(content)){removeDiv(content);}
693 var str_style="top:"+sx+"px;height:auto;z-index:"+get_next_layer();
695 var popup={'id': content,'cssclass':'inner_box','style':str_style,'html':"",'drag':false};
699 var queryString='gDossier='+dossier;
700 queryString+='&ctl='+content;
701 queryString+='&op2=st'; // st for selecting type
702 queryString+='&op=card'; // st for selecting type
703 if ( id$(obj).win_refresh!=undefined)
707 /* if an element id must be updated after creating a new card */
708 if ( id$(obj).elementId) {
709 var elementId=id$(obj).elementId;
710 queryString+="&eltid="+elementId;
712 queryString+='&fil='+filter;
713 // filter on the ledger, -1 if not
714 var oledger=id$(obj).jrn;
715 if (oledger==undefined)
724 queryString+='&ledger='+ledger;
728 queryString+='&cat='+obj.type_cat;
731 var action=new Ajax.Request ( 'ajax_misc.php',
734 parameters:queryString,
736 onSuccess:function(req) {
737 if (req.responseText=='NOCONX') { reconnect(); return;}
739 // Get all the category,
740 var answer=req.responseXML.getElementsByTagName("fiche_cat_item");
741 if (answer.length == 0) {
743 remove_waiting_box();
744 alert_box(getNodeText(req.responseXML.getElementsByTagName("code")[0]));
747 if ( answer.length == 1) {
748 // There is only one category of card
749 dis_blank_card({"ctl":"div_new_card","fd_id":answer[0].firstChild.nodeValue,"op2":"bc","op":"card",gDossier:dossier,"elementId":elementId});
751 remove_waiting_box();
755 id$('lk_cat_card_table').focus();
762 *@param obj Form object (obj)
763 * possible attribute :
764 * - filter is the filter but with a fd_id list, -1 means there is no filter
765 * - ref : reload the window after adding card
766 * - content : name of the div
767 *@note dis_blank_card({gDossier:15,fd_id:12,ref:1});
770function dis_blank_card(obj)
772 // first we have to take the form elt we need
773 if ( obj.fd_id.value != undefined )
774 { var fd_id=$F('fd_id'); }
775 else {fd_id=obj.fd_id;}
778 if ( obj.elements && obj.elements['ref'] )
782 var content='div_new_card';
785 var str_style="top:"+nTop+"px;right:"+nLeft+"px;height:auto;width:45rem;z-index:"+get_next_layer();
787 var popup={'id': content,'cssclass':'inner_box','style':str_style,'html':loading(),'drag':false};
791 if ( obj.gDossier.value != undefined ) {
792 var dossier=id$('gDossier').value;
794 var dossier=obj.gDossier;
796 var queryString='gDossier='+dossier;
797 queryString+='&ctl='+content;
798 queryString+='&fd_id='+fd_id;
800 queryString+='&op2=bc'; // bc for blank card
801 queryString+='&op=card'; // bc for blank card
802 if (obj.after_save) {
803 queryString+='&after_save='+obj.after_save;
806 if ( obj.elementId) queryString+="&eltid="+obj.elementId;
807 var action=new Ajax.Request ( 'ajax_misc.php',
810 parameters:queryString,
812 onSuccess: function (req,json) {
815 successFill_ipopcard(req,json);
820function form_blank_card(obj)
822 // first we have to take the form elt we need
824 var content='div_new_card';
827 var str_style="top:"+nTop+"px;left:"+nLeft+"px;width:60em;height:auto;z-index:"+get_next_layer();
829 var popup={'id': content,'cssclass':'inner_box','style':str_style,'html':loading(),'drag':true};
830 if ( document.getElementById(content)) {removeDiv(content);}
834 var dossier=id$('gDossier').value;
836 var queryString='gDossier='+dossier;
837 queryString+='&ctl='+content;
838 queryString+='&fd_id='+fd_id;
839 queryString+='&op2=bc'; // bc for blank card
840 queryString+='&op=card'; // bc for blank card
842 var action=new Ajax.Request ( 'ajax_misc.php',
845 parameters:queryString,
847 onSuccess:successFill_ipopcard
853 * save the data contained into the form 'save_card'
854 *@param input field (obj) it must have the attribute ipopup
855 * possible attribute :
858function save_card(obj)
860 var content=id$(obj).ipopup;
861 var accounting= id$(obj)['av_text5'];
862 if ( accounting && accounting.value.length > 40 ) {
863 smoke.alert('Poste comptable trop grand');
867 // Data must be taken here
869 var data=id$('save_card').serialize(false);
871 var dossier=id$('gDossier').value;
872 var queryString='gDossier='+dossier;
873 queryString+='&ctl='+content;
875 queryString+='&op2=sc'; // sc for save card
876 queryString+='&op=card'; // sc for save card
878 var action=new Ajax.Request ( 'ajax_misc.php',
881 parameters:queryString,
883 onSuccess:function (req,json) {
884 var elt=req.responseXML.getElementsByTagName("eltid");
885 var status=req.responseXML.getElementsByTagName("status");
886 var status_value='OK';
887 var after_savetag=req.responseXML.getElementsByTagName("after_save");
889 if ( status.length !=0) {
890 status_value=getNodeText(status[0]);
892 if ( after_savetag.length !=0 ) {
893 after_save=getNodeText(after_savetag[0]);
895 // if status == OK and after_save == 0
896 // then update the box
897 if ( status_value == 'OK' && after_save == 0) {
901 // if status == OK and after_save == 1
902 // then add a row to the table
903 if ( status_value == 'OK' && after_save == 1) {
904 var table_card=id$('fiche_tb_id');
905 f_id=getNodeText(req.responseXML.getElementsByTagName("f_id")[0]);
906 var row=new Element('tr');
907 row.id="row_card"+f_id;
908 row.innerHTML=getNodeText(req.responseXML.getElementsByTagName("code")[0]);
909 table_card.tBodies[0].appendChild(row);
910 new Effect.Highlight(row.id ,{startcolor: '#FAD4D4',endcolor: '#F78082' });
912 if ( table_card.tBodies[0].rows.length % 2 == 0 ) {
913 row.addClassName("odd");
915 row.addClassName("even");
920 remove_waiting_box();
921 if ( elt.length != 0) {
922 var eltid=getNodeText(elt[0]);
924 var eltvalue=req.responseXML.getElementsByTagName("elt_value");
925 id$(eltid).value=getNodeText(eltvalue[0]);
926 fill_data_onchange(eltid);
930 if (status_value == "OK") {
931 Effect.SlideUp(content, { duration: 1.0 });
933 if ( status_value == 'NOK') {
934 var xml_message=req.responseXML.getElementsByTagName("code");
935 var message=getNodeText(xml_message[0]);
936 smoke.alert(message);
945 * add a category of card,
946 *@param obj with the attribute
947 * - ipopup the ipopup to show
948 * - type_cat the category of card we want to add
950function add_category(obj)
955 sx=window.scrollY+120;
959 sx=document.body.scrollTop+120;
962 var div_style="top:"+sx+"px;width:60%;height:80%;z-index:"+get_next_layer();
964 var div={id:obj.ipopup,
965 cssclass:"inner_box",drag:1,style:div_style};
966 if ( document.getElementById(div) ) {
971 var dossier=id$('gDossier').value;
972 var queryString='gDossier='+dossier;
973 queryString+='&op2=ac';
974 queryString+='&op=card';
975 queryString+='&ctl='+obj.ipopup;
978 queryString+='&cat='+obj.type_cat;
980 var action=new Ajax.Request ( 'ajax_misc.php',
983 parameters:queryString,
991 * save the form and add a new category of card
992 * @param obj if the form object
994function save_card_category(obj)
996 if ( ! $(obj).ipopup)
998 alert_box('Erreur pas d\' attribut ipopup '+obj.id);
1002 // Data must be taken here
1003 data=id$('newcat').serialize(false);
1004 var dossier=id$('gDossier').value;
1005 var queryString='ctl='+obj.ipopup+'&';
1007 queryString+='&op2=scc'; // sc for save card
1008 queryString+='&op=card'; // sc for save card
1010 var action=new Ajax.Request ( 'ajax_misc.php',
1013 parameters:queryString,
1015 onSuccess:function (req)
1019 var answer = req.responseXML;
1020 var a = answer.getElementsByTagName('id');
1021 var b = answer.getElementsByTagName('name');
1022 if ( a.length == 1 && b.length == 1) {
1023 let option=new Element('option');
1024 option.value=getNodeText(a[0]);
1025 option.text=getNodeText(b[0]);
1026 id$('cat').add(option);
1034 alert_box(e.message);
1040 * Remove a definition of an attribut
1041 *@param attr_def.ad_id
1043 *@param table_id to rm the row
1044 *@param special this pointer of the row
1047function removeCardAttribut(ad_id,gDossier,table_id,row)
1049 var queryString='gDossier='+gDossier;
1050 queryString+='&op=card';
1051 queryString+='&op2=rmfa';
1052 queryString+='&ctl=debug'; // debug id
1053 queryString+='&ad_id='+ad_id;
1054 var action=new Ajax.Request ( 'ajax_misc.php',
1057 parameters:queryString,
1062 deleteRowRec(table_id,row);
1067* update a card in ajax
1069function update_card(obj)
1074 var qs=Form.serialize(name)+'&op2=upc&op=card';
1075 var action=new Ajax.Request ( 'ajax_misc.php',
1080 onSuccess:successFill_ipopcard
1084 alert_box(e.message);
1089 * In Follow-up, update, it is possible to add several card as concerned person or company
1090 * this function save it into the database, display the result and remove the search_card div
1091 * @param {type} p_dossier dossier
1092 * @param {type} p_fiche_id fiche.f_id
1093 * @param {type} p_action_id action_gestion.ag_id
1094 * @returns {undefined} nothing
1096function action_save_concerned(p_form_id) {
1097 var query = encodeJSON({'gDossier': p_dossier, 'f_id': p_fiche_id, 'ag_id': p_action_id,'op':'card','op2':'action_save_concerned','ctl':'unused'});
1098 var a=new Ajax.Request('ajax_misc.php',
1102 onFailure: errorFid,
1103 onSuccess: function (req, txt)
1106 remove_waiting_box();
1107 var answer = req.responseXML;
1108 var a = answer.getElementsByTagName('ctl');
1111 var rec = req.responseText;
1112 alert_box('erreur :' + rec);
1114 var html = answer.getElementsByTagName('code');
1115 var namectl = a[0].firstChild.nodeValue;
1116 var nodeXml=html[0];
1117 var code_html = getNodeText(nodeXml);
1118 code_html = unescape_xml(code_html);
1119 removeDiv('search_card');
1120 id$('concerned_card_td').innerHTML = code_html;
1128function action_remove_concerned(p_dossier,p_fiche_id,p_action_id)
1130 var query = encodeJSON({'gDossier': p_dossier, 'f_id': p_fiche_id, 'ag_id': p_action_id,'op':'card','op2':'action_remove_concerned','ctl':'unused'});
1131 var a=new Ajax.Request('ajax_misc.php',
1135 onFailure: errorFid,
1136 onSuccess: function (req, txt)
1139 remove_waiting_box();
1140 var answer = req.responseXML;
1141 var a = answer.getElementsByTagName('ctl');
1144 var rec = req.responseText;
1145 alert_box('erreur :' + rec);
1147 var html = answer.getElementsByTagName('code');
1148 var namectl = a[0].firstChild.nodeValue;
1149 var nodeXml=html[0];
1150 var code_html = getNodeText(nodeXml);
1151 code_html = unescape_xml(code_html);
1152 id$('concerned_card_td').innerHTML = code_html;
1153 removeDiv('search_card');
1155 id$(namectl).remove();
1158 if ( console) { console.log('Erreur ') + e.message;}
1159 alert_box('action_remove_concerned '+e.message);
1166 * Remove a card after checking it is not used
1167 * @param obj {json} = gDossier,op,op2:rm_card,ctl,f_id
1169function delete_card(obj) {
1170 smoke.confirm("Confirmez ? ", function (e) {
1173 new Ajax.Request("ajax_misc.php", {
1176 onSuccess: function (req) {
1177 remove_waiting_box();
1178 var answer = req.responseXML;
1179 var a = answer.getElementsByTagName('ctl');
1182 var rec = req.responseText;
1183 alert_box('erreur :' + rec);
1185 var html = answer.getElementsByTagName('code');
1186 var namectl = a[0].firstChild.nodeValue;
1187 var nodeXml = html[0];
1188 var code_html = getNodeText(nodeXml);
1189 code_html = unescape_xml(code_html);
1190 if ( code_html == "OK") {
1191 Effect.Fade(obj['ctl'], { duration: 1.5 });
1193 smoke.alert(code_html);
1202 * Display a card , modify it , redraw the row
1203 * before calling this function , it it neeed to have in the web page a hidden card_gdossier with the dossier id
1204 * @param {type} p_fiche_id
1205 * @returns {undefined}
1207function modify_card(p_fiche_id)
1209 /* window with result */
1210 var card_layer=get_next_layer();
1212 var content = 'card_' + card_layer;
1213 var nTop = 170 + card_layer;
1217 var str_top = fixed_position(250, nTop)
1218 var str_style = str_top + ";width:45em;height:auto;position:absolute";
1220 var popup = {'id': content, 'cssclass': 'inner_box', 'style': str_style, 'html': loading(), 'drag': false};
1225 if ( ! document.getElementById("card_gdossier")) {
1227 console.error("card_gdossier error");
1228 throw ("card_gdossier not set");
1230 var dossier = id$('card_gdossier').value;
1233 var action = new Ajax.Request('ajax_misc.php',
1236 parameters: {'gDossier':dossier,"op":'card',"op2":"dc","f_id":p_fiche_id,'ctl':content,after_save:2} ,
1237 onFailure: errorFid,
1238 onSuccess: function (respTxt) {
1245 * Delete a card and remove the row
1246 * before calling this function , it it neeed to have in the web page a hidden card_gdossier with the dossier id
1247 * @param {type} p_fiche_id
1248 * @returns {undefined}
1250function delete_card_id(p_fiche_id)
1252 var row="row_card"+p_fiche_id;
1253 if ( ! document.getElementById("card_gdossier")) {
1255 console.error("card_gdossier error");
1256 throw ("card_gdossier not set");
1258 id$(row).addClassName("background-selected");
1259 var dossier = id$('card_gdossier').value;
1260 smoke.confirm(content[47], function (e) {
1263 new Ajax.Request("ajax_misc.php", {
1265 parameters: {'gDossier':dossier,"op":'card',"op2":"rm_card","f_id":p_fiche_id,'ctl':row} ,
1266 onSuccess: function (req) {
1267 remove_waiting_box();
1268 var table_card=id$('fiche_tb_id');
1269 var answer = req.responseXML;
1270 var a = answer.getElementsByTagName('ctl');
1273 var rec = req.responseText;
1274 alert_box('erreur :' + rec);
1276 var html = answer.getElementsByTagName('code');
1277 var namectl = a[0].firstChild.nodeValue;
1278 var nodeXml = html[0];
1279 var code_html = getNodeText(nodeXml);
1280 code_html = unescape_xml(code_html);
1282 if ((code_html) == "OK") {
1283 Effect.Fade(row, {duration: 0.1});
1284 table_card.tBodies[0].removeChild(id$(row));
1285 alternate_row_color("fiche_tb_id");
1287 smoke.alert(code_html);
1294 id$(row).removeClassName("background-selected");
1302* update a card in ajax , and update a row
1305function card_update_row(obj)
1310 var qs = Form.serialize(name) + '&op2=upr&op=card';
1311 var action = new Ajax.Request('ajax_misc.php',
1315 onFailure: errorFid,
1316 onSuccess: function (req) {
1319 remove_waiting_box();
1321 var answer = req.responseXML;
1322 var a = answer.getElementsByTagName('ctl');
1323 var html = answer.getElementsByTagName('code');
1324 if (a.length === 0) {
1325 var rec = req.responseText;
1326 alert_box('erreur :' + rec);
1328 var name_ctl = "row_card" + obj.f_id.value;
1329 var code_html = getNodeText(html[0]); // Firefox ne prend que les 4096 car.
1330 code_html = unescape_xml(code_html);
1332 if ( document.getElementById(name_ctl)) {
1334 id$(name_ctl).innerHTML = code_html;
1335 new Effect.Highlight(name_ctl ,{startcolor: '#FAD4D4',endcolor: '#F78082' });
1338 id$(a[0].firstChild.nodeValue).remove();
1342 alert_box(e.message);
1345 console.error("log answer = " + req.responseText);
1349 code_html.evalScripts();
1353 console.error("log answer = " + req.responseText);
1355 alert_box(content[53] + "\n" + e.message);
1363 alert_box(e.message);
1368 * Display the option of a contact linked in a action-followup
1369 * @param {int} p_action_person_id action_person.ap_id
1370 * @param {int} p_dossier current folder
1372function linked_card_option(p_action_person_id,p_dossier) {
1375 new Ajax.Request("ajax_misc.php",{
1378 ap_id:p_action_person_id,
1381 op2:"display_card_option",
1384 onSuccess:function(req) {
1385 remove_waiting_box();
1386 add_div({ "id":"d_linked_card_option",cssclass:"inner_box",style:"position:fixed;top:30%;min-width:20rem;width:auto;",drag:0});
1387 id$("d_linked_card_option").update(req.responseText);
1392 console.error(e.message);
1396 * Save option for the contact
1397 * @param {object} obj form
1398 * @see card_multiple_display_option.php
1399 * @returns {undefined}
1401function save_linked_card_option(obj)
1404 new Ajax.Request("ajax_misc.php",{
1406 parameters:obj.serialize(),
1407 onSuccess:function(req) {
1408 remove_waiting_box();
1409 removeDiv("d_linked_card_option");
1410 id$("other_"+obj.action_person_id.value).update(req.responseText);
1411 new Effect.Highlight("other_"+obj.action_person_id.value,{startcolor: '#FAD4D4',endcolor: '#F78082' });
1419 * Manage adding, removing and ordering attributs of a card template (FICHE_DEF), used in the module CCARD
1420 * @param dossier_id {int} Folder
1421 * @param fiche_def_id {int} SQL : FICHE_DEF.FD_ID
1423var CategoryCardDefinition = function (dossier_id, fiche_def_id) {
1424 this.dossier_id = dossier_id;
1425 this.fiche_def_id = fiche_def_id;
1426 this.available_list = 'avail_attribut_id';
1427 this.existing_list = 'attribut_card';
1428 this.op = 'category_card_definition';
1431 * save the order + new attributes, remove old ones
1433CategoryCardDefinition.prototype.save = function () {
1437 var aAttribut=Sortable.serialize(this.existing_list);
1439 gDossier: this.dossier_id,
1440 fiche_def_id: this.fiche_def_id,
1445 var action = new Ajax.Request(
1449 parameters: queryString,
1450 onFailure: ajax_misc_failure,
1451 onSuccess: function (req) {
1452 if (req.responseText == 'NOCONX') {
1456 if ( req.responseText == 'OK') {
1457 smoke.signal('Sauvé',function(e){},{duration:500});
1465 alert_box("CategoryCardDefinition.save" + e.message);
1469 * add an attribut from the DOM Element avail_attribut_id , do add an element in attribut_card and remove from avail_attribut_id
1470 * @param attribut_id {int} attr_def.ad_id , ad_id of attribute
1472CategoryCardDefinition.prototype.add_attribut = function (attribut_id) {
1478 gDossier: this.dossier_id,
1479 fiche_def_id: this.fiche_def_id,
1484 var action = new Ajax.Request(
1488 parameters: queryString,
1489 onFailure: ajax_misc_failure,
1490 onSuccess: function (req) {
1491 if (req.responseText == 'NOCONX') {
1496 // if successfull add id on existing_list and remove from available_list
1498 // remove from available_list
1499 id$('avail_attr_' + attribut_id).remove();
1500 var parser = new DOMParser();
1501 var element = parser.parseFromString(req.responseText, 'text/html');
1502 id$(here.existing_list).appendChild(element.body.firstChild);
1503 new Effect.Highlight('existing_attr_' + attribut_id, {
1504 startcolor: '#FAD4D4',
1507 Sortable.create('attribut_card', {tag: 'li'});
1508 alternate_row_color_list(here.available_list);
1513 alert_box("CategoryCardDefinition.add_attribut" + e.message);
1517 * remove an attribut from the DOM Element attribut_card , do add an element in avail_attribut_id and remove from attribut_card
1518 * @param attribut_id {int} attr_def.ad_id , ad_id of attribute
1520CategoryCardDefinition.prototype.remove_attribut = function (attribut_id) {
1526 gDossier: this.dossier_id,
1527 fiche_def_id: this.fiche_def_id,
1532 var action = new Ajax.Request(
1536 parameters: queryString,
1537 onFailure: ajax_misc_failure,
1538 onSuccess: function (req) {
1539 if (req.responseText == 'NOCONX') {
1544 // if successfull add id on existing_list and remove from available_list
1546 // remove from available_list
1547 id$('existing_attr_' + attribut_id).remove();
1548 var parser = new DOMParser();
1549 var element = parser.parseFromString(req.responseText, 'text/html');
1550 id$(here.available_list).appendChild(element.body.firstChild);
1552 alternate_row_color_list(here.available_list);
1553 Sortable.create('attribut_card', {tag: 'li', hoverclass: inner_box});
1558 alert_box("CategoryCardDefinition.remove_attribut" + e.message);