From f7ee929a1b0f42370d3d95478ecd7e149793be6d Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Fri, 4 Nov 2011 23:42:31 +0000 Subject: [PATCH] Improve Cat. of customer, adm... --- html/ajax_card.php | 38 +++++++++------------- html/js/card.js | 45 ++++++++++++++++++++------- html/js/scripts.js | 41 ------------------------ include/adm.inc.php | 7 +++-- include/client.inc.php | 17 +++------- include/template/category_of_card.php | 23 ++++++++++++-- 6 files changed, 77 insertions(+), 94 deletions(-) diff --git a/html/ajax_card.php b/html/ajax_card.php index 46526de6c..6b8f7fc4c 100644 --- a/html/ajax_card.php +++ b/html/ajax_card.php @@ -398,13 +398,8 @@ case 'ac': } $html=''; - $html.="

"._("Ajout d'une catégorie")." ".$msg."

"; /* show the form */ - $html.= '
'; - $html.=$ctl; - $html.= '
'; - $html.= dossier::hidden(); - $html.=HtmlInput::hidden('cat',$cat); + $search=new IPoste("class_base"); $search->size=40; $search->value=$base; @@ -413,17 +408,14 @@ case 'ac': $search->set_attribute('account',$search->name); $search->set_attribute('ipopup','ipop_account'); + $nom_mod=new IText("nom_mod"); $str_poste=$search->input(); + $submit=HtmlInput::submit('save',_('Sauve')); ob_start(); require('template/category_of_card.php'); $html.=ob_get_contents(); ob_clean(); - $submit=HtmlInput::submit('save',_('Sauve')); - $html.= '

'; - $html.= $submit; - $html.= '

'; - $html.= '
'; - $html.= '
'; + } else { @@ -438,29 +430,29 @@ case 'scc': $html=''; if ( $user->check_action(FICCAT) == 1 ) { - if ( strlen(trim($_POST['nom_mod'])) != 0 && - strlen(trim($_POST['class_base'])) != 0 ) + $script=create_script("removeDiv('$ctl')"); + $html.=$script; + if ( strlen(trim($_GET['nom_mod'])) != 0 && + strlen(trim($_GET['class_base'])) != 0 ) { $array=array("FICHE_REF"=>$cat, - "nom_mod"=>$_POST['nom_mod'], - "class_base"=>$_POST['class_base']); + "nom_mod"=>$_GET['nom_mod'], + "class_base"=>$_GET['class_base']); if ( isset ($_POST['create'])) $array['create']=1; $catcard=new Fiche_Def($cn); if ( $catcard->Add($array) == -1) - $html.="alert('"._('Catégorie existe déjà')."')"; + $script="alert('"._('Catégorie existe déjà')."')"; else - $html.="alert('"._('Catégorie sauvée')."')"; - $html.=create_script($html); + $script="alert('"._('Catégorie sauvée')."')"; + $html.=create_script($script); } else { - $html.="alert('"._("Le nom et la classe base ne peuvent être vide")."')"; - $html.=create_script($html); + $script="alert('"._("Le nom et la classe base ne peuvent être vide")."')"; + $html.=create_script($script); $invalid=1; } - $ipop=str_replace('_content','',$ctl); - $html.=create_script('hideIPopup(\''.$ipop.'\');'); } else { diff --git a/html/js/card.js b/html/js/card.js index 14e93f437..6809ac6b6 100644 --- a/html/js/card.js +++ b/html/js/card.js @@ -397,7 +397,7 @@ function select_card_type(obj) filter=-1; } var content="select_card_div"; - if ( $(content)){ removeDiv(content);} + if ( $(content)){removeDiv(content);} var sx=0; if ( window.scrollY) { @@ -529,12 +529,29 @@ function save_card(obj) */ function add_category(obj) { + var sx=0; + if ( window.scrollY) + { + sx=window.scrollY+120; + } + else + { + sx=document.body.scrollTop+120; + } + + var div_style="top:"+sx+";width:60%;heigth:80%"; // show ipopup - showIPopup(obj.ipopup); + var div={id:obj.ipopup, + cssclass:"op_detail",drag:1,style:div_style}; + if ( $(div) ) { + removeDiv(div); + } + add_div(div); + waiting_box(); var dossier=$('gDossier').value; var queryString='gDossier='+dossier; queryString+='&op=ac'; - queryString+='&ctl='+obj.ipopup+'_content'; + queryString+='&ctl='+obj.ipopup; if ( obj.type_cat) { queryString+='&cat='+obj.type_cat; @@ -544,7 +561,7 @@ function add_category(obj) method:'get', parameters:queryString, onFailure:errorFid, - onSuccess:successFill_ipopcard + onSuccess:fill_box } ); @@ -560,25 +577,29 @@ function save_card_category(obj) alert('Erreur pas d\' attribut ipopup '+obj.id); return; }; - var content=$(obj).ipopup+'_content'; - // Data must be taken here + try { + // Data must be taken here + data=$('newcat').serialize(false); - $(content).innerHTML=loading(); - showIPopup($(obj).ipopup); var dossier=$('gDossier').value; - var queryString='?'; - queryString+='&ctl='+content+'&'; + queryString='ctl='+obj.ipopup+'&'; queryString+=data; queryString+='&op=scc'; // sc for save card var action=new Ajax.Request ( 'ajax_card.php', { - method:'post', + method:'get', parameters:queryString, onFailure:errorFid, - onSuccess:successFill_ipopcard + onSuccess:fill_box } ); + } catch(e) + { + alert(e.message); + return false; + } + return false; } /** *@brief Remove a definition of an attribut diff --git a/html/js/scripts.js b/html/js/scripts.js index 98404cc3f..a2c3b6321 100644 --- a/html/js/scripts.js +++ b/html/js/scripts.js @@ -292,47 +292,6 @@ function popup_recherche() var w=window.open("recherche.php?gDossier="+p_dossier+"&ac=SEARCH",'','statusbar=no,scrollbars=yes,toolbar=no'); w.focus(); } -/** - *@brief show the popup. The top property is adapted if you've scrolled the window - *@param name of the object PHP IPopup - */ -function showIPopup(p_name) -{ - var sx=0; - if ( window.scrollY) - { - sx=window.scrollY+40; - } - else - { - sx=document.body.scrollTop+40; - } - $(p_name+'_border').style.top=sx; - if ( g(p_name+'_fond') ) - { - show(p_name+'_fond'); - } - show(p_name+'_border'); - show(p_name+'_content'); -} -/** - *@brief hide the popup - *@param name of the object PHP IPopup - */ -function hideIPopup(p_name) -{ - g(p_name+'_content').innerHTML=loading(); - if (g(p_name+'_fond')) - { - hide(p_name+'_fond'); - } - if (g(p_name+'_border')) - { - hide(p_name+'_border'); - } - hide(p_name+'_content'); - -} /** *@brief replace the special characters (><'") by their HTML representation *@return a string without the offending char. diff --git a/include/adm.inc.php b/include/adm.inc.php index d7e1de478..eeaf79066 100644 --- a/include/adm.inc.php +++ b/include/adm.inc.php @@ -80,9 +80,10 @@ if ( $low_action == "list" ) $a=(isset($_GET['query']))?$_GET['query']:""; printf (_('Recherche').' ', $a); + echo HtmlInput::request_to_hidden(array('ac')); $sel_card=new ISelect('cat'); $sel_card->value=$cn->make_array('select fd_id, fd_label from fiche_def '. - ' where frd_id='.FICHE_TYPE_ADM_TAX. + ' where frd_id='.FICHE_TYPE_ADM_TAX.' or frd_id ='.FICHE_TYPE_FIN. ' order by fd_label ',1); $sel_card->selected=(isset($_GET['cat']))?$_GET['cat']:-1; $sel_card->javascript=' onchange="submit(this);"'; @@ -90,7 +91,7 @@ if ( $low_action == "list" ) ?> - + title = _('Ajout d\'une catégorie'); -$ip_cat->value = ''; -echo $ip_cat->input(); -echo IPoste::ipopup('ipop_account'); -$search_card = new IPopup('ipop_card'); -$search_card->title = _('Recherche de fiche'); -$search_card->value = ''; -echo $search_card->input(); -echo ICard::ipopup('ipopcard'); + $low_action = (isset($_REQUEST['sb'])) ? $_REQUEST['sb'] : "list"; /* ! \file @@ -134,14 +124,15 @@ if ($low_action == "list") $f_cat_button->label=_('Ajout d\'une catégorie'); $f_cat_button->javascript='add_category(this)'; echo $f_cat_button->input(); - echo ''; + + echo ''; echo ''; } /*---------------------------------------------------------------------- * Detail for a card, Suivi, Contact, Operation,... * - * cc stands for customer card + * cc stands for customer card *----------------------------------------------------------------------*/ if ( $low_action == 'detail') { diff --git a/include/template/category_of_card.php b/include/template/category_of_card.php index 6e8793a56..382f4dc5e 100644 --- a/include/template/category_of_card.php +++ b/include/template/category_of_card.php @@ -1,7 +1,20 @@ - +
+Fermer'; +?> +
+ + +
+
+ + +
- + @@ -23,3 +36,9 @@

+ +

+ +

+ + \ No newline at end of file
input()?>