phpcompta-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpcompta-dev] r363 - trunk/tva


From: phpcompta-dev
Subject: [Phpcompta-dev] r363 - trunk/tva
Date: Sat, 26 May 2012 21:17:14 +0200 (CEST)

Author: danydb
Date: 2012-05-26 21:17:14 +0200 (Sat, 26 May 2012)
New Revision: 363

Modified:
   trunk/tva/ajax.php
   trunk/tva/form_parameter.php
   trunk/tva/js_scripts.js
   trunk/tva/tva_param.inc.php
Log:
Save modify and delete parameter_tva

Modified: trunk/tva/ajax.php
===================================================================
--- trunk/tva/ajax.php  2012-05-25 23:12:20 UTC (rev 362)
+++ trunk/tva/ajax.php  2012-05-26 19:17:14 UTC (rev 363)
@@ -184,6 +184,37 @@
   $r.=HtmlInput::button_close($ctl);
   $html=escape_xml($r);
   break;
+case 'add_param':
+       $ctl="paramadd_id";
+       $r=HtmlInput::title_box("Ajout paramètre",$ctl);
+       $r.='<h3>'._('Pour la grille ').$pcode.'</h3>';
+       // TVA input
+       $text = new ITva_Popup('tva_id');
+       $text->add_label('tva_label');
+       $text->js = 'onchange="set_tva_label(this);"';
+       $text->with_button(true);
+
+       // Accounting
+       $iposte=new IPoste('paccount');
+       $iposte->set_attribute('gDossier',Dossier::id());
+       $iposte->set_attribute('jrn',0);
+       $iposte->set_attribute('account','paccount');
+       $iposte->set_attribute('label','paccount_label');
+
+
+       $r.='<form method="POST" id="faddparm"onsubmit="return confirm(\'Vous 
confirmez ?\');" style="margin-left:15px">';
+       
$r.=HtmlInput::request_to_hidden(array("gDossier","plugin_code","ac","pcode"));
+       $r.=_(" Code TVA ");
+       $r.=$text->input();
+       $r.='<span id="tva_label" style="display:block"></span>';
+       $r.=" Poste comptable";
+       $r.=$iposte->input();
+       $r.='<span id="paccount_label" style="display:inline"></span>';
+       $r.='<span style="display:block"></span>';
+       $r.=HtmlInput::submit("save_addparam","Sauver");
+       $r.=HtmlInput::button_close($ctl);
+       $r.='</form>';
+       break;
 default:
   $r=var_export($_REQUEST,true);
 }

Modified: trunk/tva/form_parameter.php
===================================================================
--- trunk/tva/form_parameter.php        2012-05-25 23:12:20 UTC (rev 362)
+++ trunk/tva/form_parameter.php        2012-05-26 19:17:14 UTC (rev 363)
@@ -3,6 +3,8 @@
 function show($p_code,$p_desc) {
        global $cn;
        echo "<h2>".h($p_code)." ".$p_desc."</h2>";
+       $plugin_code=$_REQUEST['plugin_code'];
+       $dossier=Dossier::id();
        $a_code=$cn->get_array("
                        select pi_id, pc.tva_id,tva_label,tva_comment,tva_rate, 
pcm_val
                        from tva_belge.parameter_chld as pc
@@ -11,7 +13,8 @@
                        array($p_code));
        if (sizeof($a_code) == 0) {
                echo '<span class="notice" style="display:block">Aucun 
paramètre donné </span>';
-               echo HtmlInput::button("Ajout paramètre","Ajout paramètre");
+
+               echo HtmlInput::button("add_param","Ajout 
paramètre","onclick=\"show_addparam('$p_code','$plugin_code','$dossier');\"");
                return;
        }
        $n_max=sizeof($a_code);
@@ -31,12 +34,16 @@
                echo td($a_code[$i]['tva_comment']);
                echo td($a_code[$i]['tva_rate']);
                echo td("Poste comptable :".$a_code[$i]['pcm_val']);
-               echo td("Effacer");
-               echo td("modifier");
+               echo '<td>';
+               echo '<form id="f'.$a_code[$i]['pi_id'].'" method="POST">';
+               echo HtmlInput::hidden("pi_id",$a_code[$i]['pi_id']);
+               echo HtmlInput::anchor("Effacer","","onclick=\"if ( 
confirm('Vous confirmez?')) { $('f".$a_code[$i]['pi_id']."').submit(this);} 
else {return false;}\"");
+               echo "</form>";
+               echo '</td>';
                echo "</tr>";
        }
        echo "</table>";
-       echo HtmlInput::button("Ajout paramètre","Ajout paramètre");
+       echo HtmlInput::button("add_param","Ajout 
paramètre","onclick=\"show_addparam('$p_code','$plugin_code','$dossier');\"");
 }
 ?>
 <h1><?=_("Opération à la sortie");?></h1>
@@ -76,6 +83,8 @@
 
 <fieldset>
 <legend><?=_('Divers')?></legend>
+<form method="POST">
+
 <TABLE class="result">
 <TR>
        <TH><?=_('Poste comptable')?></TH>
@@ -139,52 +148,9 @@
 </tr>
 
 </TABLE>
+       <?=HtmlInput::submit("save_misc","Sauver")?>
+</form>
 </fieldset>
-<fieldset><legend><?=_('Aide')?></legend>
-<span class="notice">
-<?=_('Vous pouvez mettre plusieurs postes comptables séparées par une virgule 
dans une grille')?>
-<?=_("Vous devez ajouter dans paramètre->tva les codes TVA nécessaires pour 
les cocontractants, les opérations à l'export, les opérations 
intracommunautaire... Ainsi que les postes comptables dans les paramètres->plan 
comptable")?>
-<br>
-<?=_('Exemple')?>
-<table>
-<tr>
-<th>code</th>
-<Th>
-Label  </Th><th>Taux</th><th>  Commentaire     </th><th>Poste</th>
-</tr>
-<tr>
-<td>4</td>
-<TD>
-0%     </TD><td>0.0000 </TD><td>Aucune tva n'est applicable    
</TD><td>4114,4514      </td></tr>
-<tr>
-<td>2</td>
-<TD>
-
-12%    </TD><td>0.1200 </TD><td>Tva    </TD><td>4112,4512      </td></tr>
-<tr>
-<td>1</td>
-<TD>
-21%    </TD><td>0.2100 </TD><td>Tva applicable à tout ce qui bien et service 
divers    </TD><td>4111,4511</td></tr>
-<tr>
-<td>3</td>
-<TD>
-6%     </TD><td>0.0600 </TD><td>Tva applicable aux journaux et livres  
</TD><td>4113,4513      </td></tr>
-<tr>
-<td> ??? </td>
-<TD>
-ART44  </TD><td>0.0000 </TD><td>Opérations pour les opérations avec des 
assujettis à l\'art 44 Code TVA        </TD><td>41143,45143    </td></tr>
-<tr>
-<td> ??? </td>
-<TD>
-COC    </TD><td>0.0000 </TD><td>Opérations avec des cocontractants     
</TD><td>41144,45144    </td></tr>
-<tr>
-<td>6</td>
-<TD>
-EXPORT </TD><td>0.0000 </TD><td>Tva pour les exportations      
</TD><td>41141,45144</td></tr>
-<tr>
-<td>5</td>
-<TD>
-INTRA  </TD><td>0.0000 </TD><td>Tva pour les livraisons / acquisition intra 
communautaires     </TD><td>41142,45142</td></tr>
-</table>
-</span>
-</fieldset>
+<fieldset><legend>Listing intracommunautaires</legend>
+<?=show("CLINTRA",_("Code TVA pour clients  Intracommunataire"))?>
+</fieldset>
\ No newline at end of file

Modified: trunk/tva/js_scripts.js
===================================================================
--- trunk/tva/js_scripts.js     2012-05-25 23:12:20 UTC (rev 362)
+++ trunk/tva/js_scripts.js     2012-05-26 19:17:14 UTC (rev 363)
@@ -3,7 +3,7 @@
        $('detail').innerHTML='<image src="image/loading.gif" border="0" 
alt="Chargement...">';
        $('detail').show();
        $('main').hide();
-       var gDossier=$('gDossier').value; var code=$('plugin_code').value;
+       var gDossier=$('gDossier').value;var code=$('plugin_code').value;
        var queryString='act=dsp_decl&gDossier='+gDossier+'&plugin_code='+code;
        queryString+='&type='+p_type+'&id='+p_id;
        var action=new Ajax.Request ( 'ajax.php',
@@ -14,19 +14,19 @@
                                 onSuccess:success_show_declaration
                               }
                               );
-    } catch(e) { alert('show_declaration '+e.message);}
+    } catch(e) {alert('show_declaration '+e.message);}
 }
 function success_show_declaration(answer) {
     try {
        var xml=answer.responseXML;
        var html=xml.getElementsByTagName('code');
-       if ( html.length == 0 ) { var rec=answer.responseText;alert ('erreur 
:'+rec);}
+       if ( html.length == 0 ) {var rec=answer.responseText;alert ('erreur 
:'+rec);}
        var code_html=getNodeText(html[0]);
        code_html=unescape_xml(code_html);
        $('detail').innerHTML=code_html;
        code_html.evalScripts();
 
-    } catch(e) { alert('success_show_declaration '+e.message);}
+    } catch(e) {alert('success_show_declaration '+e.message);}
 }
 function error_show_declaration() {
     alert('error_show_declaration : ajax not supported');
@@ -51,7 +51,7 @@
        var answer=req.responseXML;
        var a=answer.getElementsByTagName('ctl');
        var html=answer.getElementsByTagName('code');
-       if ( a.length == 0 ) { var rec=req.responseText;alert ('erreur :'+rec);}
+       if ( a.length == 0 ) {var rec=req.responseText;alert ('erreur :'+rec);}
        var name_ctl=a[0].firstChild.nodeValue;
        var code_html=getNodeText(html[0]);
 
@@ -82,7 +82,7 @@
        var answer=req.responseXML;
        var a=answer.getElementsByTagName('ctl');
        var html=answer.getElementsByTagName('code');
-       if ( a.length == 0 ) { var rec=req.responseText;alert ('erreur :'+rec);}
+       if ( a.length == 0 ) {var rec=req.responseText;alert ('erreur :'+rec);}
        var name_ctl=a[0].firstChild.nodeValue;
        var code_html=getNodeText(html[0]);
 
@@ -95,4 +95,57 @@
        code_html.evalScripts();}
     catch(e){
        alert("answer_box Impossible executer script de la 
reponse\n"+e.message);}
+}
+function show_addparam(pcode,plugin_code,dossier)
+{
+       try {
+               waiting_box();
+                var action=new Ajax.Request ( 'ajax.php',
+                                 {
+                                     method:'get',
+                                     
parameters:"act=add_param&pcode="+pcode+"&gDossier="+dossier+"&plugin_code="+plugin_code,
+                                     onFailure:null,
+                                     onSuccess:success_showaddparam
+                                 });
+       }catch (e){
+               alert(e.message);
+       }
+}
+
+function success_showaddparam(req) {
+  try{
+               remove_waiting_box();
+               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%";
+               removeDiv("paramadd_id");
+               add_div({
+                       "id":'paramadd_id',
+                       "drag":"1",
+                       "cssclass":"inner_box",
+                       "style":div_style
+               });
+               var answer=req.responseXML;
+               var html=answer.getElementsByTagName('code');
+               var code_html=getNodeText(html[0]);
+               code_html=unescape_xml(code_html);
+               g("paramadd_id").innerHTML=code_html;
+       }
+       catch (e) {
+               alert("success_box "+e.message);
+       }
+       try{
+               code_html.evalScripts();
+       }
+       catch(e){
+               alert("answer_box Impossible executer script de la 
reponse\n"+e.message);
+       }
 }
\ No newline at end of file

Modified: trunk/tva/tva_param.inc.php
===================================================================
--- trunk/tva/tva_param.inc.php 2012-05-25 23:12:20 UTC (rev 362)
+++ trunk/tva/tva_param.inc.php 2012-05-26 19:17:14 UTC (rev 363)
@@ -24,26 +24,38 @@
  * \brief set up the parameters
  */
 require_once('class_tva_parameter.php');
+$cn=new Database(dossier::id());
 
 // save all the parameters
-if ( isset ($_REQUEST['RECORD']))  {
-  $aCode=$_POST['tvacode'];
-  $aValue=$_POST['value'];
-  $aAccount=$_POST['account'];
-  for ($i=0;$i<count($aCode);$i++) {
-    $code=new Tva_Parameter($cn);
-    $code->set_parameter('code',$aCode[$i]);
-    $code->set_parameter('value',$aValue[$i]);
-    if ( isset($aAccount[$i]))
-      $code->set_parameter('account',$aAccount[$i]);
-    else
-      $code->set_parameter('account','');
-    $code->update();
-  }
+if ( isset ($_POST['save_misc']))  {
+       extract($_POST);
+
+       foreach ( array('CRTVA','ATVA','DTTVA') as $i){
+               $value=${$i};
+               if ( trim(${$i})=='') $value=null;
+               $cn->exec_sql("update tva_belge.parameter_chld set 
pcm_val=$1::account_type where pcode=$2",
+                               array($value,$i));
+       }
+
+       unset($_POST['save_misc']);
 }
 
+if ( isset ($_POST['save_addparam'])){
+       extract ($_POST);
+       try {
+               if ( trim($tva_id)=="")                 throw new 
Exception("TVA n'existe pas");
+               if ( trim($paccount)=="")                       throw new 
Exception("Poste comptable vide");
+               if ( $cn->get_value("select count(tva_id) from tva_rate where 
tva_id=$1",array($tva_id))==0) throw new Exception("TVA $tva_id n'existe pas");
+               $cn->exec_sql("insert into 
tva_belge.parameter_chld(pcode,tva_id,pcm_val) values ($1,$2,$3::account_type)",
+               array($pcode,$tva_id,$paccount));
+       } catch(Exception $e) {
+               alert("Ne peut sauver : ".$e->getMessage());
+       }
+}
+if ( isset ($_POST['pi_id'])){
+       $cn->exec_sql("delete from tva_belge.parameter_chld where 
pi_id=$1",array($_POST['pi_id']));
+}
 /* show all the possible parameters */
-$cn=new Database(dossier::id());
 $tvap=new Tva_Parameter($cn);
 require_once('class_itva_popup.php');
 $a=new IPopup('popup_tva');



---
PhpCompta est un logiciel de comptabilité libre en ligne (full web)
Projet opensource http://www.phpcompta.eu



reply via email to

[Prev in Thread] Current Thread [Next in Thread]