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
23 * \brief 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($("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";
50 add_div({id:'boxsearch_card_div',cssclass:'inner_box',html:loading(),style:div_style,drag:true});
51 $('boxsearch_card_div').innerHTML=req.responseText;
52 sorttable.makeSortable($('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=$('gDossier').value;
80 var string_to_search=$(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;
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 ( $('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 $(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;";
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 $('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";
338 if ( ! $('search_card')) { add_div({id: 'search_card', cssclass: 'inner_box', html: "", style: div_style, drag: true}); }
339 $('search_card').innerHTML = code_html;
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
363function search_get_card(obj)
365 var dossier=$('gDossier').value;
367 var queryString="gDossier="+dossier;
368 queryString+="&op2=fs&op=card";
370 if ( obj.elements['inp'] )
372 queryString+="&inp="+$F('inp');
374 if ( obj.elements['typecard'] )
376 queryString+="&typecard="+$F('typecard');
378 if ( obj.elements['jrn'] )
380 queryString+="&jrn="+$F('jrn');
382 if ( obj.elements['label'])
384 queryString+="&label="+$F('label');
386 if ( obj.elements['price'])
388 queryString+="&price="+$F('price');
390 if ( obj.elements['tvaid'])
392 queryString+="&tvaid="+$F('tvaid');
394 if( obj.elements['query'])
396 queryString+="&query="+$F('query');
400 queryString+="&ctl="+obj.ctl;
402 if ( obj.elements['accvis'] )
404 queryString+="&accvis="+$F('accvis');
406 queryString+="&accvis=0";
408 if ( obj.elements['amount_from_type']) {
409 queryString+="&amount_from_type="+obj.elements['amount_from_type'].value;
411 if (obj.elements['page_card']) {
412 queryString+="&page_card="+obj.elements["page_card"].value;
414 if ( obj.elements["inactive_card"]) {
415 queryString+="&inactive_card="+obj.elements["inactive_card"].value;
418 queryString=encodeURI(queryString);
419 $('asearch').innerHTML=loading();
421 var action=new Ajax.Request ( 'ajax_misc.php',
424 parameters:queryString,
426 onSuccess:result_card_search
431 * show the answer of ajax request
432 *@param answer in XML
434function result_card_search(req)
439 remove_waiting_box();
440 if ( req.responseText == 'NOCONX') { reconnect();return;}
441 var answer=req.responseXML;
442 var a=answer.getElementsByTagName('ctl');
445 var rec=req.responseText;
446 alert_box ('erreur :'+rec);
448 var html=answer.getElementsByTagName('code');
450 var name_ctl=a[0].firstChild.nodeValue;
452 var code_html=getNodeText(nodeXml);
453 code_html=unescape_xml(code_html);
458 sx=window.scrollY+40;
462 sx=document.body.scrollTop+60;
465 var div_style="top:"+sx+"px;min-height:80%;height:auto";
466 add_div({id:'search_card',cssclass:'inner_box',html:"",style:div_style,drag:false,effect:'blinddown'});
468 $('search_card').innerHTML=code_html;
470 if ($('query')) { $('query').focus();}
474 alert_box(e.message);
478 code_html.evalScripts();
482 alert_box(content[53]+"\n"+e.message);
490 * Set the value of 2 input fields
492* 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
493* some specific need. This function is called if the caller is searchcardCtrl
495*@param p_ctrl the input with the name of the quick code
496*@param p_quickcode the found quick_code
497*@param p_ctrlname the name of the input field with the label
498*@param p_label the label of the quickcode
500function setCtrl(p_ctrl,p_quickcode,p_ctrlname,p_label)
505 ctrl.value=p_quickcode;
507 var ctrl_name=g(p_ctrlname);
510 ctrl_name.value=p_label;
517 * clean the row (the label, price and vat)
518 * @param p_ctl the calling ctrl
520function clean_Fid(p_ctl)
522 nSell=p_ctl+"_price";
524 nTva_id=p_ctl+"_tva_id";
535 $(nTva_id).value="-1";
539function errorFid(request,json)
541 alert_box(content[53]);
543function update_value(text,li)
548 * is called when something change in ICard
549 *@param the input field
552function fill_data_onchange(ctl)
558 * is called when something change in ICard
559 *@param the input field
562function fill_data(text,li)
568 * is called when something change in ICard
569 *@param the input field
572function fill_fin_data_onchange(ctl)
578 * is called when something change in ICard
579 *@param the input field
582function fill_fin_data(text,li)
585 ajax_saldo($(text.id));
588 * show the ipopup window and display the details of a card,
589 * to work some attribute must be set
590 *@param obj.qcode is the qcode, obj.nohistory if you don't want to display
591 * the history button, obj.ro is the popin is readonly
592 *@note you must the gDossier as hidden in the calling page
596function fill_ipopcard(obj)
601 var content='card_'+card_layer;
602 var nTop=170+card_layer;
606 var str_top="top:"+calcy(nTop)+"px";
608 var str_style=str_top+";width:45em;height:auto;position:absolute";
610 var popup={'id': content,'cssclass':'inner_box','style':str_style,'html':"",'drag':false};
613 var dossier=$('gDossier').value;
615 if ( $(obj).qcode != undefined )
625 var queryString='gDossier='+dossier;
626 queryString+='&qcode='+qcode;
627 queryString+='&ctl='+content;
628 queryString+='&op2=dc'; // dc for detail card
629 queryString+='&op=card'; // dc for detail card
630 if ( obj.readonly != undefined) {
634 if ( obj.nohistory != undefined) {
635 queryString+='&nohistory';
637 if ( obj.nofollowup != undefined) {
638 queryString+='&nofollowup';
640 queryString=encodeURI(queryString);
641 var action=new Ajax.Request ( 'ajax_misc.php',
644 parameters:queryString,
652 * @param request : object request
653 * @param json : json answer
655function successFill_ipopcard(req,json)
659 if (req.responseText=='NOCONX') { reconnect();return; }
660 var answer=req.responseXML;
661 var a=answer.getElementsByTagName('ctl');
662 var html=answer.getElementsByTagName('code');
666 var rec=req.responseText;
667 alert_box ('erreur :'+rec);
669 var name_ctl=a[0].firstChild.nodeValue;
670 var code_html=getNodeText(html[0]);
671 code_html=unescape_xml(code_html);
673 $(name_ctl).innerHTML=code_html;
677 alert_box(e.message);
681 code_html.evalScripts();
685 alert_box(content[53]+"\n"+e.message);
689 * show the ipopup for selecting a card type, it is a needed step before adding
691 *@param input field (obj) it must have the attribute ipopup
692 * possible attribute :
693 * - filter possible values are deb, cred, fd_id list, -1 means there is no filter
694 * - ref if we want to refresh the window after adding a card
695 * - type type of card (supplier, customer...)
698function select_card_type(obj)
700 var dossier=$('gDossier').value;
702 // give a filter, -1 if not
703 var filter=$(obj).filter;
704 if ( filter==undefined)
708 var content="select_card_div";
709 if ( $(content)){removeDiv(content);}
713 var str_style="top:"+sx+"px;height:auto";
715 var popup={'id': content,'cssclass':'inner_box','style':str_style,'html':"",'drag':false};
719 var queryString='gDossier='+dossier;
720 queryString+='&ctl='+content;
721 queryString+='&op2=st'; // st for selecting type
722 queryString+='&op=card'; // st for selecting type
723 if ( $(obj).win_refresh!=undefined)
727 /* if an element id must be updated after creating a new card */
728 if ( $(obj).elementId) {
729 var elementId=$(obj).elementId;
730 queryString+="&eltid="+elementId;
732 queryString+='&fil='+filter;
733 // filter on the ledger, -1 if not
734 var oledger=$(obj).jrn;
735 if (oledger==undefined)
744 queryString+='&ledger='+ledger;
748 queryString+='&cat='+obj.type_cat;
751 var action=new Ajax.Request ( 'ajax_misc.php',
754 parameters:queryString,
756 onSuccess:function(req) {
757 if (req.responseText=='NOCONX') { reconnect(); return;}
759 // Get all the category,
760 var answer=req.responseXML.getElementsByTagName("fiche_cat_item");
761 if (answer.length == 0) {
763 remove_waiting_box();
764 alert_box(getNodeText(req.responseXML.getElementsByTagName("code")[0]));
767 if ( answer.length == 1) {
768 // There is only one category of card
769 dis_blank_card({"ctl":"div_new_card","fd_id":answer[0].firstChild.nodeValue,"op2":"bc","op":"card",gDossier:dossier,"elementId":elementId});
771 remove_waiting_box();
775 $('lk_cat_card_table').focus();
782 *@param obj Form object (obj)
783 * possible attribute :
784 * - filter is the filter but with a fd_id list, -1 means there is no filter
785 * - ref : reload the window after adding card
786 * - content : name of the div
787 *@note dis_blank_card({gDossier:15,fd_id:12,ref:1});
790function dis_blank_card(obj)
792 // first we have to take the form elt we need
793 if ( obj.fd_id.value != undefined )
794 { var fd_id=$F('fd_id'); }
795 else {fd_id=obj.fd_id;}
798 if ( obj.elements && obj.elements['ref'] )
802 var content='div_new_card';
805 var str_style="top:"+nTop+"px;right:"+nLeft+"px;height:auto";
807 var popup={'id': content,'cssclass':'inner_box','style':str_style,'html':loading(),'drag':false};
811 if ( obj.gDossier.value != undefined ) {
812 var dossier=$('gDossier').value;
814 var dossier=obj.gDossier;
816 var queryString='gDossier='+dossier;
817 queryString+='&ctl='+content;
818 queryString+='&fd_id='+fd_id;
820 queryString+='&op2=bc'; // bc for blank card
821 queryString+='&op=card'; // bc for blank card
822 if (obj.after_save) {
823 queryString+='&after_save='+obj.after_save;
826 if ( obj.elementId) queryString+="&eltid="+obj.elementId;
827 var action=new Ajax.Request ( 'ajax_misc.php',
830 parameters:queryString,
832 onSuccess: function (req,json) {
835 successFill_ipopcard(req,json);
840function form_blank_card(obj)
842 // first we have to take the form elt we need
844 var content='div_new_card';
847 var str_style="top:"+nTop+"px;left:"+nLeft+"px;width:60em;height:auto";
849 var popup={'id': content,'cssclass':'inner_box','style':str_style,'html':loading(),'drag':true};
850 if ( $(content)) {removeDiv(content);}
854 var dossier=$('gDossier').value;
856 var queryString='gDossier='+dossier;
857 queryString+='&ctl='+content;
858 queryString+='&fd_id='+fd_id;
859 queryString+='&op2=bc'; // bc for blank card
860 queryString+='&op=card'; // bc for blank card
862 var action=new Ajax.Request ( 'ajax_misc.php',
865 parameters:queryString,
867 onSuccess:successFill_ipopcard
873 * save the data contained into the form 'save_card'
874 *@param input field (obj) it must have the attribute ipopup
875 * possible attribute :
878function save_card(obj)
880 var content=$(obj).ipopup;
881 var accounting= $(obj)['av_text5'];
882 if ( accounting && accounting.value.length > 40 ) {
883 smoke.alert('Poste comptable trop grand');
887 // Data must be taken here
889 var data=$('save_card').serialize(false);
891 var dossier=$('gDossier').value;
892 var queryString='gDossier='+dossier;
893 queryString+='&ctl='+content;
895 queryString+='&op2=sc'; // sc for save card
896 queryString+='&op=card'; // sc for save card
898 var action=new Ajax.Request ( 'ajax_misc.php',
901 parameters:queryString,
903 onSuccess:function (req,json) {
904 var elt=req.responseXML.getElementsByTagName("eltid");
905 var status=req.responseXML.getElementsByTagName("status");
906 var status_value='OK';
907 var after_savetag=req.responseXML.getElementsByTagName("after_save");
909 if ( status.length !=0) {
910 status_value=getNodeText(status[0]);
912 if ( after_savetag.length !=0 ) {
913 after_save=getNodeText(after_savetag[0]);
915 // if status == OK and after_save == 0
916 // then update the box
917 if ( status_value == 'OK' && after_save == 0) {
921 // if status == OK and after_save == 1
922 // then add a row to the table
923 if ( status_value == 'OK' && after_save == 1) {
924 var table_card=$('fiche_tb_id');
925 f_id=getNodeText(req.responseXML.getElementsByTagName("f_id")[0]);
926 var row=new Element('tr');
927 row.id="row_card"+f_id;
928 row.innerHTML=getNodeText(req.responseXML.getElementsByTagName("code")[0]);
929 table_card.tBodies[0].appendChild(row);
930 new Effect.Highlight(row.id ,{startcolor: '#FAD4D4',endcolor: '#F78082' });
932 if ( table_card.tBodies[0].rows.length % 2 == 0 ) {
933 row.addClassName("odd");
935 row.addClassName("even");
940 remove_waiting_box();
941 if ( elt.length != 0) {
942 var eltid=getNodeText(elt[0]);
944 var eltvalue=req.responseXML.getElementsByTagName("elt_value");
945 $(eltid).value=getNodeText(eltvalue[0]);
946 fill_data_onchange(eltid);
950 if (status_value == "OK") {
951 Effect.SlideUp(content, { duration: 1.0 });
953 if ( status_value == 'NOK') {
954 var xml_message=req.responseXML.getElementsByTagName("code");
955 var message=getNodeText(xml_message[0]);
956 smoke.alert(message);
965 * add a category of card,
966 *@param obj with the attribute
967 * - ipopup the ipopup to show
968 * - type_cat the category of card we want to add
970function add_category(obj)
975 sx=window.scrollY+120;
979 sx=document.body.scrollTop+120;
982 var div_style="top:"+sx+"px;width:60%;height:80%";
984 var div={id:obj.ipopup,
985 cssclass:"inner_box",drag:1,style:div_style};
991 var dossier=$('gDossier').value;
992 var queryString='gDossier='+dossier;
993 queryString+='&op2=ac';
994 queryString+='&op=card';
995 queryString+='&ctl='+obj.ipopup;
998 queryString+='&cat='+obj.type_cat;
1000 var action=new Ajax.Request ( 'ajax_misc.php',
1003 parameters:queryString,
1011 * save the form and add a new category of card
1012 * @param obj if the form object
1014function save_card_category(obj)
1016 if ( ! $(obj).ipopup)
1018 alert_box('Erreur pas d\' attribut ipopup '+obj.id);
1022 // Data must be taken here
1023 data=$('newcat').serialize(false);
1024 var dossier=$('gDossier').value;
1025 var queryString='ctl='+obj.ipopup+'&';
1027 queryString+='&op2=scc'; // sc for save card
1028 queryString+='&op=card'; // sc for save card
1030 var action=new Ajax.Request ( 'ajax_misc.php',
1033 parameters:queryString,
1040 alert_box(e.message);
1046 * Remove a definition of an attribut
1047 *@param attr_def.ad_id
1049 *@param table_id to rm the row
1050 *@param special this pointer of the row
1053function removeCardAttribut(ad_id,gDossier,table_id,row)
1055 var queryString='gDossier='+gDossier;
1056 queryString+='&op=card';
1057 queryString+='&op2=rmfa';
1058 queryString+='&ctl=debug'; // debug id
1059 queryString+='&ad_id='+ad_id;
1060 var action=new Ajax.Request ( 'ajax_misc.php',
1063 parameters:queryString,
1068 deleteRowRec(table_id,row);
1073* update a card in ajax
1075function update_card(obj)
1080 var qs=Form.serialize(name)+'&op2=upc&op=card';
1081 var action=new Ajax.Request ( 'ajax_misc.php',
1086 onSuccess:successFill_ipopcard
1090 alert_box(e.message);
1095 * In Follow-up, update, it is possible to add several card as concerned person or company
1096 * this function save it into the database, display the result and remove the search_card div
1097 * @param {type} p_dossier dossier
1098 * @param {type} p_fiche_id fiche.f_id
1099 * @param {type} p_action_id action_gestion.ag_id
1100 * @returns {undefined} nothing
1102function action_save_concerned(p_form_id) {
1103 var query = encodeJSON({'gDossier': p_dossier, 'f_id': p_fiche_id, 'ag_id': p_action_id,'op':'card','op2':'action_save_concerned','ctl':'unused'});
1104 var a=new Ajax.Request('ajax_misc.php',
1108 onFailure: errorFid,
1109 onSuccess: function (req, txt)
1112 remove_waiting_box();
1113 var answer = req.responseXML;
1114 var a = answer.getElementsByTagName('ctl');
1117 var rec = req.responseText;
1118 alert_box('erreur :' + rec);
1120 var html = answer.getElementsByTagName('code');
1121 var namectl = a[0].firstChild.nodeValue;
1122 var nodeXml=html[0];
1123 var code_html = getNodeText(nodeXml);
1124 code_html = unescape_xml(code_html);
1125 removeDiv('search_card');
1126 $('concerned_card_td').innerHTML = code_html;
1134function action_remove_concerned(p_dossier,p_fiche_id,p_action_id)
1136 var query = encodeJSON({'gDossier': p_dossier, 'f_id': p_fiche_id, 'ag_id': p_action_id,'op':'card','op2':'action_remove_concerned','ctl':'unused'});
1137 var a=new Ajax.Request('ajax_misc.php',
1141 onFailure: errorFid,
1142 onSuccess: function (req, txt)
1145 remove_waiting_box();
1146 var answer = req.responseXML;
1147 var a = answer.getElementsByTagName('ctl');
1150 var rec = req.responseText;
1151 alert_box('erreur :' + rec);
1153 var html = answer.getElementsByTagName('code');
1154 var namectl = a[0].firstChild.nodeValue;
1155 var nodeXml=html[0];
1156 var code_html = getNodeText(nodeXml);
1157 code_html = unescape_xml(code_html);
1158 $('concerned_card_td').innerHTML = code_html;
1159 removeDiv('search_card');
1161 $(namectl).remove();
1164 if ( console) { console.log('Erreur ') + e.message;}
1165 alert_box('action_remove_concerned '+e.message);
1172 * Remove a card after checking it is not used
1173 * @param object obj {gDossier,op,op2:rm_card,ctl,f_id}
1175function delete_card(obj) {
1176 smoke.confirm("Confirmez ? ", function (e) {
1179 new Ajax.Request("ajax_misc.php", {
1182 onSuccess: function (req) {
1183 remove_waiting_box();
1184 var answer = req.responseXML;
1185 var a = answer.getElementsByTagName('ctl');
1188 var rec = req.responseText;
1189 alert_box('erreur :' + rec);
1191 var html = answer.getElementsByTagName('code');
1192 var namectl = a[0].firstChild.nodeValue;
1193 var nodeXml = html[0];
1194 var code_html = getNodeText(nodeXml);
1195 code_html = unescape_xml(code_html);
1196 if ( code_html == "OK") {
1197 Effect.Fade(obj['ctl'], { duration: 1.5 });
1199 smoke.alert(code_html);
1208 * Display a card , modify it , redraw the row
1209 * before calling this function , it it neeed to have in the web page a hidden card_gdossier with the dossier id
1210 * @param {type} p_fiche_id
1211 * @returns {undefined}
1213function modify_card(p_fiche_id)
1215 /* window with result */
1218 var content = 'card_' + card_layer;
1219 var nTop = 170 + card_layer;
1223 var str_top = fixed_position(250, nTop)
1224 var str_style = str_top + ";width:45em;height:auto;position:absolute";
1226 var popup = {'id': content, 'cssclass': 'inner_box', 'style': str_style, 'html': loading(), 'drag': false};
1231 if ( ! document.getElementById("card_gdossier")) {
1233 console.error("card_gdossier error");
1234 throw ("card_gdossier not set");
1236 var dossier = $('card_gdossier').value;
1239 var action = new Ajax.Request('ajax_misc.php',
1242 parameters: {'gDossier':dossier,"op":'card',"op2":"dc","f_id":p_fiche_id,'ctl':content,after_save:2} ,
1243 onFailure: errorFid,
1244 onSuccess: function (respTxt) {
1251 * Delete a card and remove the row
1252 * before calling this function , it it neeed to have in the web page a hidden card_gdossier with the dossier id
1253 * @param {type} p_fiche_id
1254 * @returns {undefined}
1256function delete_card_id(p_fiche_id)
1258 var row="row_card"+p_fiche_id;
1259 if ( ! document.getElementById("card_gdossier")) {
1261 console.error("card_gdossier error");
1262 throw ("card_gdossier not set");
1264 $(row).addClassName("background-selected");
1265 var dossier = $('card_gdossier').value;
1266 smoke.confirm(content[47], function (e) {
1269 new Ajax.Request("ajax_misc.php", {
1271 parameters: {'gDossier':dossier,"op":'card',"op2":"rm_card","f_id":p_fiche_id,'ctl':row} ,
1272 onSuccess: function (req) {
1273 remove_waiting_box();
1274 var table_card=$('fiche_tb_id');
1275 var answer = req.responseXML;
1276 var a = answer.getElementsByTagName('ctl');
1279 var rec = req.responseText;
1280 alert_box('erreur :' + rec);
1282 var html = answer.getElementsByTagName('code');
1283 var namectl = a[0].firstChild.nodeValue;
1284 var nodeXml = html[0];
1285 var code_html = getNodeText(nodeXml);
1286 code_html = unescape_xml(code_html);
1288 if ((code_html) == "OK") {
1289 Effect.Fade(row, {duration: 0.1});
1290 table_card.tBodies[0].removeChild($(row));
1291 alternate_row_color("fiche_tb_id");
1293 smoke.alert(code_html);
1300 $(row).removeClassName("background-selected");
1308* update a card in ajax , and update a row
1311function card_update_row(obj)
1316 var qs = Form.serialize(name) + '&op2=upr&op=card';
1317 var action = new Ajax.Request('ajax_misc.php',
1321 onFailure: errorFid,
1322 onSuccess: function (req) {
1325 remove_waiting_box();
1327 var answer = req.responseXML;
1328 var a = answer.getElementsByTagName('ctl');
1329 var html = answer.getElementsByTagName('code');
1330 if (a.length === 0) {
1331 var rec = req.responseText;
1332 alert_box('erreur :' + rec);
1334 var name_ctl = "row_card" + obj.f_id.value;
1335 var code_html = getNodeText(html[0]); // Firefox ne prend que les 4096 car.
1336 code_html = unescape_xml(code_html);
1338 if ( document.getElementById(name_ctl)) {
1340 $(name_ctl).innerHTML = code_html;
1341 new Effect.Highlight(name_ctl ,{startcolor: '#FAD4D4',endcolor: '#F78082' });
1344 $(a[0].firstChild.nodeValue).remove();
1348 alert_box(e.message);
1351 console.error("log answer = " + req.responseText);
1355 code_html.evalScripts();
1359 console.error("log answer = " + req.responseText);
1361 alert_box(content[53] + "\n" + e.message);
1369 alert_box(e.message);
1374 * Display the option of a contact linked in a action-followup
1375 * @param {int} p_action_person_id action_person.ap_id
1376 * @param {int} p_dossier current folder
1378function linked_card_option(p_action_person_id,p_dossier) {
1381 new Ajax.Request("ajax_misc.php",{
1384 ap_id:p_action_person_id,
1387 op2:"display_card_option",
1390 onSuccess:function(req) {
1391 remove_waiting_box();
1392 add_div({ "id":"d_linked_card_option",cssclass:"inner_box",style:"position:fixed;top:30%;min-width:20rem;width:auto;",drag:0});
1393 $("d_linked_card_option").update(req.responseText);
1398 console.error(e.message);
1402 * Save option for the contact
1403 * @param {object} obj form
1404 * @see card_multiple_display_option.php
1405 * @returns {undefined}
1407function save_linked_card_option(obj)
1410 new Ajax.Request("ajax_misc.php",{
1412 parameters:obj.serialize(),
1413 onSuccess:function(req) {
1414 remove_waiting_box();
1415 removeDiv("d_linked_card_option");
1416 $("other_"+obj.action_person_id.value).update(req.responseText);
1417 new Effect.Highlight("other_"+obj.action_person_id.value,{startcolor: '#FAD4D4',endcolor: '#F78082' });