diff --git a/html/ajax_misc.php b/html/ajax_misc.php index e52131033..8fc311ea7 100644 --- a/html/ajax_misc.php +++ b/html/ajax_misc.php @@ -113,5 +113,43 @@ echo <<exec_sql("select * from tva_rate order by tva_rate desc"); + $Max=Database::num_row($Res); + $r=""; + $r='
'; + $r= ""; + $r.=th(''); + $r.=th(_('code')); + $r.=th(_('Taux')); + $r.=th(_('Symbole')); + $r.=th(_('Explication')); + for ($i=0;$i<$Max;$i++) { + $row=Database::fetch_array($Res,$i); + $script="onclick=\"$('$ctl').value='".$row['tva_id']."';hideIPopup('".$popup."');\""; + $set= ''; + $r.=''; + $r.=td($set); + $r.=td($row['tva_id']); + $r.=td($row['tva_rate']); + $r.=td($row['tva_label']); + $r.=td($row['tva_comment']); + $r.=''; + } + $r.='
'; + $r.='
'; + $html=escape_xml($r); + +header('Content-type: text/xml; charset=UTF-8'); +echo << + +$html +$popup + +EOF; + + break; } diff --git a/html/compute.php b/html/compute.php index 695d2290e..2bb2b8afc 100644 --- a/html/compute.php +++ b/html/compute.php @@ -50,10 +50,18 @@ $cn=new Database(dossier::id()); $User=new User($cn); $User->Check(); +/** + *@todo check with my_own if the vat must be computed instead of + *a special value + */ // Retrieve the rate of vat, it $t == -1 it means no VAT if ( $t != -1 ){ $tva_rate=new Acc_Tva($cn); $tva_rate->set_parameter('id',$t); + /** + *@todo if the tva_rate->load failed we have to return an + *error message "invalid tva" + */ $tva_rate->load(); } diff --git a/html/js/acc_ledger.js b/html/js/acc_ledger.js index 6a51bd000..c152ea9f5 100644 --- a/html/js/acc_ledger.js +++ b/html/js/acc_ledger.js @@ -184,6 +184,9 @@ function compute_ledger(p_ctl_nb) { var qcode=g("e_march"+p_ctl_nb).value; if ( qcode.length == 0 ) { clean_ledger(p_ctl_nb);refresh_ledger();return;} + /** + *@todo if tva_id is empty send a value of -1 + */ var tva_id=-1; if ( g('e_march'+p_ctl_nb+'_tva_id') ) { tva_id=g('e_march'+p_ctl_nb+'_tva_id').value; @@ -223,12 +226,16 @@ function refresh_ledger() { if (g('tvac')) g('tvac').innerHTML=Math.round(tvac*100)/100; } /** - * @brief update the field htva, tva_id and tvac, callback function for compute_sold + *@brief update the field htva, tva_id and tvac, callback function for compute_sold * it the field TVA in the answer contains NA it means that VAT is appliable and then do not * update the VAT field except htva_martc */ function success_compute_ledger(request,json) { - + /** + *@todo add a control + * - 0 everything is ok + * - 1 tva id is invalid + */ var answer=request.responseText.evalJSON(true); var ctl=answer.ctl; var rtva=answer.tva; diff --git a/html/js/scripts.js b/html/js/scripts.js index 1d54b88a4..b976b9363 100644 --- a/html/js/scripts.js +++ b/html/js/scripts.js @@ -276,4 +276,40 @@ function success_cat_doc_remove(req) { $('X'+row_id).style.display='none'; } catch (e) { alert(e.message);} +} +/** + *@brief display the popup with vat and explanation + *@param obj with 4 attributes gdossier, ctl,popup and phpsessid + */ +function popup_select_tva(obj) { + try { + showIPopup(obj.popup); + var queryString="PHPSESSID="+obj.phpsessid+"&gDossier="+obj.gDossier+"&op=dsp_tva"+"&ctl="+obj.ctl+'&popup='+obj.popup; + var action = new Ajax.Request( + "ajax_misc.php" , + { method:'get', + parameters:queryString, + onFailure:ajax_misc_failure, + onSuccess:success_popup_select_tva + } + ); + } catch (e) {alert(e.message);} +} +/** + *@brief display the popup with vat and explanations + */ +function success_popup_select_tva(req) { + try { + var answer=req.responseXML; + var popup=answer.getElementsByTagName('popup'); + if ( popup.length == 0 ) { var rec=req.responseText;alert ('erreur :'+rec);} + var html=answer.getElementsByTagName('code'); + + var name_ctl=popup[0].firstChild.nodeValue+'_content'; + var nodeXml=html[0]; + var code_html=getNodeText(nodeXml); + code_html=unescape_xml(code_html); + $(name_ctl).innerHTML=code_html; + } catch (e) {alert(e.message);} + } \ No newline at end of file diff --git a/html/style.css b/html/style.css index c9a7d2e21..a1934a110 100644 --- a/html/style.css +++ b/html/style.css @@ -564,7 +564,7 @@ div.popup_border_title { /*background:lightgrey;*/ z-index:10; /*border:dotted 1px black;*/ - border: 3px groove black; + border: 3px groove lightblue; background-color:#879ED4; font-size: 110% ; font-family: arial,sans-serif; diff --git a/html/test.php b/html/test.php index adede11c0..cfc37d6f8 100644 --- a/html/test.php +++ b/html/test.php @@ -64,7 +64,8 @@ $array=array( array(25,'Search Ledger'), array(26,'Gettext'), array(27,'Card (class_fiche)'), - array(28,'Extension') + array(28,'Extension'), + array(29,'ITVA popup') ); $r='
'; $r.=''; + $r=sprintf($str,$this->name,$this->value,$this->name,$this->js); + + return $r; + + } + /** + *@brief show a button, if it is pushed show a popup to select the need vat + *@note + * - a ipopup must be created before with the name popup_tva + * - the javascript scripts.js must be loaded + *@return string with html code + */ + function dbutton() { + if( trim($this->name)=='') throw new Exception (_('Le nom ne peut être vide')); + // button + $bt=new IButton('bt_'.$this->name); + $bt->label=_('tva'); + $bt->set_attribute('gDossier',dossier::id()); + $bt->set_attribute('ctl',$this->name); + $bt->set_attribute('popup','popup_tva'); + $bt->javascript='popup_select_tva(this)'; + return $bt->input(); + } + /*!\brief print in html the readonly value of the widget*/ + public function display() + { + $r=''; + $res=sprinf($r,$this->name,$this->value,$this->name); + return $res; + } + static public function test_me() + { + $a=new IPopup('popup_tva'); + $a->set_title('Choix de la tva'); + echo $a->input(); + $tva=new ITva_Popup("tva1"); + echo $tva->input(); + echo $tva->dbutton(); + } +} diff --git a/include/class_periode.php b/include/class_periode.php index 08ac85988..b56a1dbdc 100644 --- a/include/class_periode.php +++ b/include/class_periode.php @@ -336,13 +336,22 @@ $ret['p_end']=>'31.01.2009' } /*!\brief return the first day of periode -*the this->p_id must be said -*\return a string with the date (DD.MM.YYYY) -*/ + *the this->p_id must be set + *\return a string with the date (DD.MM.YYYY) + */ public function first_day() { list($p_start,$p_end)=$this->get_date_limit($this->p_id); return $p_start; } + /*!\brief return the last day of periode + *the this->p_id must be set + *\return a string with the date (DD.MM.YYYY) + */ + public function last_day() { + list($p_start,$p_end)=$this->get_date_limit($this->p_id); + return $p_end; + } + function get_exercice($p_id=0) { if ( $p_id == 0 ) $p_id=$this->p_id; $sql="select p_exercice from parm_periode where p_id=".$p_id; diff --git a/include/tva.inc.php b/include/tva.inc.php index 03bb96c40..0620e1b33 100644 --- a/include/tva.inc.php +++ b/include/tva.inc.php @@ -42,12 +42,8 @@ echo '
'; || isset ($_POST['confirm_add'])) { extract($_POST); - $tva_label=FormatString($tva_label); - $tva_rate=FormatString($tva_rate); - $tva_comment=FormatString($tva_comment); - $tva_poste=FormatString($tva_poste); - // remove space - $tva_poste=str_replace (" ","",$tva_poste); + // remove space + $tva_poste=str_replace (" ","",$tva_poste); $err=0; // Error code if ( isNumber($tva_rate) == 0 ) { @@ -74,6 +70,10 @@ echo '
'; $Res=$cn->exec_sql( "select tva_modify($tva_id,'$tva_label', '$tva_rate','$tva_comment','$tva_poste')"); + $Res=$cn->exec_sql( + "select tva_modify($1,$2,$3,$4,$5)", + array($tva_id,$tva_label,$tva_rate,$tva_comment,$tva_poste) + ); $err=Database::fetch_result($Res); } @@ -231,11 +231,11 @@ if ( ! isset ($_POST['add']) Commentaire - heigh=2;$w->width=20;echo $w->input('tva_comment','') ?> + heigh=5;$w->width=50;echo $w->input('tva_comment','') ?> Poste comptable utilisés format :debit,credit - size=10;echo $w->input('tva_poste','') ?> + size=20;echo $w->input('tva_poste','') ?> @@ -267,13 +267,13 @@ if ( ! isset ($_POST['add']) Commentaire - heigh=2;$w->width=20; + heigh=5;$w->width=50; echo $w->input('tva_comment',$tva_array[$index]['tva_comment']) ?> Poste comptable utilisés format :debit,credit - size=5; echo $w->input('tva_poste',$tva_array[$index]['tva_poste']) ?> + size=20; echo $w->input('tva_poste',$tva_array[$index]['tva_poste']) ?>