diff --git a/html/js/card.js b/html/js/card.js index 7662c8e97..98102b9a0 100644 --- a/html/js/card.js +++ b/html/js/card.js @@ -549,7 +549,7 @@ function select_card_type(obj) { var dossier=$('gDossier').value; - + var elementId=""; // give a filter, -1 if not var filter=$(obj).filter; if ( filter==undefined) @@ -582,6 +582,11 @@ function select_card_type(obj) { queryString+='&ref'; } + /* if an element id must be updated after creating a new card */ + if ( $(obj).elementId) { + var elementId=$(obj).elementId; + queryString+="&eltid="+elementId; + } queryString+='&fil='+filter; // filter on the ledger, -1 if not var oledger=$(obj).jrn; @@ -615,7 +620,7 @@ function select_card_type(obj) } if ( answer.length == 1) { // There is only one category of card - dis_blank_card({"ctl":"div_new_card","fd_id":answer[0].firstChild.nodeValue,"op2":"bc","op":"card",gDossier:dossier}); + dis_blank_card({"ctl":"div_new_card","fd_id":answer[0].firstChild.nodeValue,"op2":"bc","op":"card",gDossier:dossier,"elementId":elementId}); removeDiv(content); remove_waiting_box(); return; @@ -654,13 +659,14 @@ function dis_blank_card(obj) var str_style="top:"+nTop+"px;right:"+nLeft+"px;height:auto"; var popup={'id': content,'cssclass':'inner_box','style':str_style,'html':loading(),'drag':true}; - if ( $(content)) {removeDiv(content);} + add_div(popup); - if ( obj.gDossier.value != undefined ) { - var dossier=$('gDossier').value;} else { + if ( obj.gDossier.value != undefined ) { + var dossier=$('gDossier').value; + } else { var dossier=obj.gDossier; - } + } var queryString='gDossier='+dossier; queryString+='&ctl='+content; @@ -668,15 +674,19 @@ function dis_blank_card(obj) queryString+=ref; queryString+='&op2=bc'; // bc for blank card queryString+='&op=card'; // bc for blank card - + if ( obj.elementId) queryString+="&eltid="+obj.elementId; var action=new Ajax.Request ( 'ajax_misc.php', { method:'get', parameters:queryString, onFailure:errorFid, - onSuccess:successFill_ipopcard + onSuccess: function (req,json) { + + + successFill_ipopcard(req,json); } - ); + } + ); } function form_blank_card(obj) { @@ -688,7 +698,7 @@ function form_blank_card(obj) var str_style="top:"+nTop+"px;left:"+nLeft+"px;width:60em;height:auto"; var popup={'id': content,'cssclass':'inner_box','style':str_style,'html':loading(),'drag':true}; - if ( $(content)) {removeDiv(content);} + if ( $(content)) {removeDiv(content);} add_div(popup); @@ -721,8 +731,7 @@ function save_card(obj) var content=$(obj).ipopup; // Data must be taken here data=$('save_card').serialize(false); - $(content).innerHTML=loading(); - + waiting_box(); var dossier=$('gDossier').value; var queryString='gDossier='+dossier; queryString+='&ctl='+content; @@ -735,9 +744,24 @@ function save_card(obj) method:'post', parameters:queryString, onFailure:errorFid, - onSuccess:fill_box + onSuccess:function (req,json) { + fill_box(req,json); + var elt=req.responseXML.getElementsByTagName("eltid"); + remove_waiting_box(); + if ( elt.length != 0) { + var eltid=getNodeText(elt[0]); + if ( eltid !="") { + var eltvalue=req.responseXML.getElementsByTagName("elt_value"); + $(eltid).value=getNodeText(eltvalue[0]); + fill_data_onchange(eltid); + $(eltid).focus(); + } + //$(content).fade({duration:2.0}); + Effect.SlideUp(content, { duration: 1.0 });} + } - ); + } + ); } /** *@brief add a category of card, diff --git a/html/js/scripts.js b/html/js/scripts.js index 88ba2b997..9cf49fbae 100644 --- a/html/js/scripts.js +++ b/html/js/scripts.js @@ -2764,9 +2764,9 @@ function show_description(p_id) * @param pn_fiche_card_id : fiche_def.fd_id * @param pn_dossier_id */ -function select_cat(pn_fiche_card_id,pn_dossier_id) +function select_cat(pn_fiche_card_id,pn_dossier_id,ps_element_id) { - dis_blank_card({"ctl":"div_new_card","fd_id":pn_fiche_card_id,"op2":"bc","op":"card",gDossier:pn_dossier_id}); + dis_blank_card({"ctl":"div_new_card","fd_id":pn_fiche_card_id,"op2":"bc","op":"card",gDossier:pn_dossier_id,"elementId":ps_element_id}); removeDiv('select_card_div'); } /** diff --git a/include/ajax/ajax_card.php b/include/ajax/ajax_card.php index ff85a922a..1162dabae 100644 --- a/include/ajax/ajax_card.php +++ b/include/ajax/ajax_card.php @@ -93,7 +93,9 @@ $g_user=new User($cn); $g_user->check(true); $g_user->check_dossier($gDossier,true); $html=var_export($_REQUEST,true); - +// For storing extra information , example the HTML elt id to update +// after creating +$extra=""; switch($op2) { /* ------------------------------------------------------------ */ @@ -194,6 +196,9 @@ case 'bc': $r.='

'; $r.=HtmlInput::submit('sc',_('Sauve')); $r.='

'; + if ( isset ($eltid)) { + $r.=HtmlInput::hidden("eltid", $eltid); + } $r.=''; $html=$r; } @@ -265,9 +270,8 @@ case 'st': if ( empty($array)) { - $html.=_("Aucune catégorie de fiche ne correspond à". - " votre demande"); - if ( DEBUG ) $html.=$sql; + $html.=_("Aucune catégorie de fiche ne correspond à votre demande"); + if ( DEBUG ) $html.=$sql; } else { @@ -277,7 +281,7 @@ case 'st': $r.='
'; $r.='

'; $r.=_("Choisissez la catégorie de fiche à laquelle vous aimeriez ajouter une fiche").'

'; - + if ( ! isset($eltid)) $eltid=""; $msg=_('Choisissez une catégorie svp'); $r.=''; $r.=dossier::hidden(); @@ -290,10 +294,10 @@ case 'st': $class=($i%2==0)?' class="even" ':' class="odd" '; $r.=''; $r.=''; - $r.=''.h($array[$i]['fd_label']).''; + $r.=''.h($array[$i]['fd_label']).''; $r.=''; $r.=''; - $r.=''.h($array[$i]['fd_description']).''; + $r.=''.h($array[$i]['fd_description']).''; $r.=''; $r.=""; @@ -338,6 +342,12 @@ case 'sc': $js=""; if ( isset( $_POST['ref'])) $js=create_script(' window.location.reload()'); $html.=$js; + if ( isset ($eltid)) { + // after adding a new card, we update some field + $extra="$eltid". + "{$f->get_quick_code ()}"; + + } } else { @@ -575,5 +585,6 @@ echo << $ctl $xml +$extra EOF; diff --git a/include/ajax/ajax_update_predef.php b/include/ajax/ajax_update_predef.php index 541f7ae8a..7979d603a 100644 --- a/include/ajax/ajax_update_predef.php +++ b/include/ajax/ajax_update_predef.php @@ -52,7 +52,7 @@ $op->set('direct',$d); $url=http_build_query(array('action'=>'use_opd','p_jrn_predef'=>$l,'ac'=>$_GET['ac'],'gDossier'=>dossier::id())); $html=""; -$html.=HtmlInput::title_box(_("Modèle d'opérations"), 'modele_op_div', 'hide'); +$html.=HtmlInput::title_box(_("Modèle d'opérations"), 'modele_op_div', 'hide',"","n"); $html.=$op->show_button('do.php?'.$url); $html.='

'. HtmlInput::button_hide('modele_op_div'). diff --git a/include/class/acc_ledger.class.php b/include/class/acc_ledger.class.php index 25b2bb249..55db55044 100644 --- a/include/class/acc_ledger.class.php +++ b/include/class/acc_ledger.class.php @@ -1610,8 +1610,7 @@ class Acc_Ledger extends jrn_def_sql if ($g_user->check_action(FICADD) == 1) { // Button for adding customer - $js_deb="this.filter='-1';this.jrn=\$('p_jrn').value; select_card_type(this);"; - $str_add_button= HtmlInput::button_image($js_deb,"xx",'class="smallbutton image_search"',"image/bouton-plus.png"); + $add_card=TRUE; } $wLedger = $this->select_ledger('ODS', 2); if ($wLedger == null) @@ -1786,7 +1785,7 @@ class Acc_Ledger extends jrn_def_sql $deb->selected = (isset(${'ck' . $i})) ? true : false; $deb->readonly = $p_readonly; $deb->javascript = ' onChange="checkTotalDirect()"'; - + $str_add_button=($add_card==TRUE)?$this->add_card("-1", $quick_code->id):""; $ret.=''; $ret.='' . $quick_code->input() . $quick_code->search() .$str_add_button. ''; $ret.='' . $poste->input() . @@ -1805,7 +1804,7 @@ class Acc_Ledger extends jrn_def_sql $w = $oRapt->widget(); $w->name = 'jrn_concerned'; $w->value = (isset($jrn_concerned)) ? $jrn_concerned : ""; - $ret.="Réconciliation/rapprochements : " . $w->input(); + $ret.=sprintf(_("Réconciliation/rapprochements : %s"), $w->input()); } $ret.= create_script("$('".$wDate->id."').focus()"); return $ret; @@ -4018,5 +4017,15 @@ class Acc_Ledger extends jrn_def_sql echo ''; } + /** + * Return a button to create new card, depending of the ledger + * @param $p_filter string : filter for adding : deb, cred or -1 for filter depending of the ledger + * @param $p_id_update string + */ + function add_card($p_filter,$p_id_update) { + $js_script="this.filter='{$p_filter}';this.elementId='{$p_id_update}';this.jrn=\$('p_jrn').value; select_card_type(this);"; + $str_add_button = HtmlInput::button_image($js_script, uniqid(),'class="smallbutton image_search"',"image/bouton-plus.png"); + return $str_add_button; + } } ?> diff --git a/include/class/acc_ledger_fin.class.php b/include/class/acc_ledger_fin.class.php index ed41b7fc3..6541bb962 100644 --- a/include/class/acc_ledger_fin.class.php +++ b/include/class/acc_ledger_fin.class.php @@ -248,11 +248,10 @@ class Acc_Ledger_Fin extends Acc_Ledger $min_article=$this->get_min_row(); - $str_add_button = ""; - if ( $g_user->check_action(FICADD) == 1) { - // Button for adding new tiers - $js_deb="this.filter='deb';this.jrn=\$('p_jrn').value; select_card_type(this);"; - $str_add_button = HtmlInput::button_image($js_deb,"xx",'class="smallbutton image_search"',"image/bouton-plus.png"); + $str_add_button_tiers = ""; + $add_card=FALSE; + if ($g_user->check_action(FICADD) == 1) { + $add_card=TRUE; } // The first day of the periode @@ -399,7 +398,7 @@ class Acc_Ledger_Fin extends Acc_Ledger $W1->readonly = $pview_only; $array[$i]['qcode'] = $W1->input(); $array[$i]['search'] = $W1->search(); - + $array[$i]['card_add']=($add_card==TRUE)?$this->add_card("deb", $W1->id):""; // Card name // $card_name = ""; diff --git a/include/class/acc_ledger_purchase.class.php b/include/class/acc_ledger_purchase.class.php index 7211c40c2..af66acf64 100644 --- a/include/class/acc_ledger_purchase.class.php +++ b/include/class/acc_ledger_purchase.class.php @@ -965,19 +965,13 @@ class Acc_Ledger_Purchase extends Acc_Ledger if ( $p_array != null ) extract($p_array, EXTR_SKIP); $flag_tva=$g_parameter->MY_TVA_USE; + /* Add button */ - $str_add_button_tiers = ""; - $str_add_button_item = ""; + $add_card=FALSE; if ($g_user->check_action(FICADD) == 1) { - $js_deb="this.filter='deb';this.jrn=\$('p_jrn').value; select_card_type(this);"; - $js_cred="this.filter='cred';this.jrn=\$('p_jrn').value; select_card_type(this);"; - - // Button for adding customer - $str_add_button_tiers = HtmlInput::button_image($js_cred,"xx",'class="smallbutton image_search"',"image/bouton-plus.png"); - - // Button for adding services or items to sale - $str_add_button_item = HtmlInput::button_image($js_deb,"xx",'class="smallbutton image_search"',"image/bouton-plus.png"); + $add_card=TRUE; + $str_add_button_tiers = $this->add_card("cred", "e_client"); } // The first day of the periode $oPeriode=new Periode($this->db); @@ -1137,6 +1131,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger $W1->name); $f_client_qcode=$W1->input(); $client_label=new ISpan(); + $client_label->style="vertical-align:top"; $client_label->table=0; $f_client=$client_label->input("e_client_label",$e_client_label); $f_client_bt=$W1->search(); @@ -1149,7 +1144,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger $p_article=($p_article < $this->get_min_row())?$this->get_min_row():$p_article; $Hid=new IHidden(); - $r.=$Hid->input("nb_item",$p_article); + $r.=$Hid->input("nb_item",$p_article); // For each article //-- @@ -1209,6 +1204,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger $W1->readonly=false; $array[$i]['quick_code']=$W1->input(); $array[$i]['bt']=$W1->search(); + $array[$i]['card_add']=($add_card==TRUE)?$this->add_card("deb", $W1->id):""; $array[$i]['hidden']=''; // For computing we need some hidden field for holding the value diff --git a/include/class/acc_ledger_sold.class.php b/include/class/acc_ledger_sold.class.php index 9d148fb6a..c18bbb8d9 100644 --- a/include/class/acc_ledger_sold.class.php +++ b/include/class/acc_ledger_sold.class.php @@ -1017,16 +1017,12 @@ EOF; /* Add button */ $str_add_button_tiers = ""; - $str_add_button_item = ""; + $add_card=FALSE; if ($g_user->check_action(FICADD) == 1) { - // Button for adding customer - $js_deb="this.filter='deb';this.jrn=\$('p_jrn').value; select_card_type(this);"; - $str_add_button_tiers = HtmlInput::button_image($js_deb,"xx",'class="smallbutton image_search"',"image/bouton-plus.png"); - - // Button for adding services or items to sale - $js_cred="this.filter='cred';this.jrn=\$('p_jrn').value; select_card_type(this);"; - $str_add_button_item = HtmlInput::button_image($js_cred,"xx",'class="smallbutton image_search"',"image/bouton-plus.png"); + $add_card=TRUE; + $str_add_button_tiers = $this->add_card("deb", "e_client"); } + // The first day of the periode $oPeriode = new Periode($this->db); list ($l_date_start, $l_date_end) = $oPeriode->get_date_limit($g_user->get_periode()); @@ -1160,6 +1156,7 @@ EOF; $W1->javascript = sprintf(' onchange="fill_data_onchange(\'%s\');" ', $W1->name); $f_client_qcode = $W1->input(); $client_label = new ISpan(); + $client_label->style="vertical-align:top"; $client_label->table = 0; $f_client = $client_label->input("e_client_label", $e_client_label); $f_client_bt = $W1->search(); @@ -1224,6 +1221,7 @@ EOF; $array[$i]['quick_code'] = $W1->input(); $array[$i]['bt'] = $W1->search(); + $array[$i]['card_add']=($add_card==TRUE)?$this->add_card("cred", $W1->id):""; // For computing we need some hidden field for holding the value $array[$i]['hidden'] = ''; if ($flag_tva == 'Y') diff --git a/include/class/pre_operation.class.php b/include/class/pre_operation.class.php index 637ff22d7..d0d98d99d 100644 --- a/include/class/pre_operation.class.php +++ b/include/class/pre_operation.class.php @@ -246,7 +246,7 @@ class Pre_operation_detail { $r=HtmlInput::button_action(_("Modèle d'opérations"), ' $(\'modele_op_div\').style.display=\'block\';$(\'lk_modele_op_tab\').focus();'); $r.='

'; - $r.=HtmlInput::title_box(_("Modèle d'opérations"), 'modele_op_div', 'hide'); + $r.=HtmlInput::title_box(_("Modèle d'opérations"), 'modele_op_div', 'hide',"","n"); $hid=new IHidden(); $r.=$hid->input("action","use_opd"); $r.=$hid->input("jrn_type",$this->get("ledger_type")); diff --git a/include/lib/html_input.class.php b/include/lib/html_input.class.php index eebb6b369..9f9f49734 100755 --- a/include/lib/html_input.class.php +++ b/include/lib/html_input.class.php @@ -569,8 +569,8 @@ class HtmlInput static function anchor_hide($action,$javascript) { $r=''; - $r.='
'; - $r.= ''.$action.''; + $r.='
'; + $r.= ''.$action.''; $r.='
'; return $r; } @@ -853,7 +853,7 @@ class HtmlInput die (__FILE__.":".__LINE__._('Paramètre invaide')); if ( $p_draggable=="y") { - $drag=sprintf('', + $drag=sprintf('', $p_div, $p_div); $r.=$drag; diff --git a/include/template/form_ledger_detail.php b/include/template/form_ledger_detail.php index 52dab921d..862970079 100644 --- a/include/template/form_ledger_detail.php +++ b/include/template/form_ledger_detail.php @@ -85,7 +85,7 @@ echo ''; // echo ""; echo $item['quick_code']; // echo ""; -echo ''.$item['bt'].$str_add_button_item.''; +echo ''.$item['bt'].$item['card_add'].''; ?> '; // echo td($item['dateop']); echo td($item['dateop'],' style="display:none" id="tdchdate'.$i.'"'); -echo td($item['qcode'].$item['search'].$str_add_button); +echo td($item['qcode'].$item['search'].$item['card_add']); echo td($item['cname']); echo td($item['comment'],' class="visible_gt800 visible_gt1155" '); echo td($item['amount']);