phpcompta-dev
[Top][All Lists]
Advanced

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

[Phpcompta-dev] r689 - in trunk/transform: . include include/template sq


From: phpcompta-dev
Subject: [Phpcompta-dev] r689 - in trunk/transform: . include include/template sql
Date: Wed, 5 Feb 2014 20:54:22 +0100 (CET)

Author: danydb
Date: 2014-02-05 20:54:22 +0100 (Wed, 05 Feb 2014)
New Revision: 689

Added:
   trunk/transform/ajax.php
   trunk/transform/ajax_modify_intervat_assujetti.php
   trunk/transform/ajax_save_intervat_assujetti.php
   trunk/transform/transform_javascript.js
Modified:
   trunk/transform/include/class_transform_client.php
   trunk/transform/include/class_transform_declarant.php
   trunk/transform/include/class_transform_representative.php
   trunk/transform/include/class_transform_sql.php
   trunk/transform/include/intervat_listing_assujetti_step_1.inc.php
   trunk/transform/include/intervat_listing_assujetti_step_2.inc.php
   trunk/transform/include/template/listing_client_display.php
   trunk/transform/index.php
   trunk/transform/sql/install.sql
Log:

new : can correct listing
new : comment per row
new : verify for representative and declarant


Added: trunk/transform/ajax.php
===================================================================
--- trunk/transform/ajax.php                            (rev 0)
+++ trunk/transform/ajax.php    2014-02-05 19:54:22 UTC (rev 689)
@@ -0,0 +1,25 @@
+<?php
+/*
+ *   This file is part of NOALYSS.
+ *
+ *   NOALYSS is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   NOALYSS is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with NOALYSS; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+// Copyright Author Dany De Bontridder address@hidden
+
+$file=HtmlInput::default_value_get('act',null);
+if ($file==null) die(_('No action'));
+require_once 'ajax_'.$file.'.php';        
+?>        
\ No newline at end of file

Added: trunk/transform/ajax_modify_intervat_assujetti.php
===================================================================
--- trunk/transform/ajax_modify_intervat_assujetti.php                          
(rev 0)
+++ trunk/transform/ajax_modify_intervat_assujetti.php  2014-02-05 19:54:22 UTC 
(rev 689)
@@ -0,0 +1,83 @@
+<?php
+/*
+ *   This file is part of NOALYSS.
+ *
+ *   NOALYSS is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   NOALYSS is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with NOALYSS; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+// Copyright Author Dany De Bontridder address@hidden
+
+require_once 'include/class_transform_client.php';
+
+echo HtmlInput::title_box(_('Client'),'modify_intervat_assujetti_div');
+$id=HtmlInput::default_value_get('c_id',null);
+if ($id==null || isNumber($id)==0) {
+    throw new Exception(_('Aucun client'));
+}
+$client=new Transform_Client($id);
+$name=new IText('c_name',$client->c_name);
+$vatnumber=new IText('c_vatnumber',$client->c_vatnumber);
+$c_amount_novat=new INum('c_amount_novat',$client->c_amount_novat);
+$c_amount_vat=new INum('c_amount_vat',$client->c_amount_vat);
+?>        
+<form method="get" id="save_intervat_assujetti_frm" onsubmit="return 
save_intervat_assujetti();return false;">
+    <table>
+        <tr>
+            <td>
+                <?php echo _('Nom')?>
+            </td>
+            <td>
+                <?php echo $name->input();?>
+            </td>
+        </tr>
+        <tr>
+            <td>
+                <?php echo _('TVA')?>
+            </td>
+            <td>
+                <?php echo $vatnumber->input();?>
+            </td>
+        </tr>
+        <tr>
+            <td>
+                <?php echo _('Montant')?>
+            </td>
+            <td>
+                <?php echo $c_amount_novat->input();?>
+            </td>
+        </tr>
+        <tr>
+            <td>
+                <?php echo _('TVA')?>
+            </td>
+            <td>
+                <?php echo $c_amount_vat->input();?>
+            </td>
+        </tr>
+        <tr>
+            <td>
+                <?php echo _('Commentaire'); ?>
+            </td>
+            <td id="modify_intervat_assujetti_div_comment">
+                <?php echo $client->c_comment; ?>
+            </td>
+        </tr>
+    </table>
+    <input type="checkbox" id="remove_intervat_assujetti" value="5" 
name="remove_intervat_assujetti"><?php echo _('Cochez pour effacer cette 
fiche')?>
+    <?php
+    echo 
HtmlInput::request_to_hidden(array('c_id','ac','act','gDossier','plugin_code'));
+    echo HtmlInput::submit('save_intervat_assujetti_sb',_('Valider'));
+    ?>
+</form>
\ No newline at end of file

Added: trunk/transform/ajax_save_intervat_assujetti.php
===================================================================
--- trunk/transform/ajax_save_intervat_assujetti.php                            
(rev 0)
+++ trunk/transform/ajax_save_intervat_assujetti.php    2014-02-05 19:54:22 UTC 
(rev 689)
@@ -0,0 +1,87 @@
+<?php
+/*
+ *   This file is part of NOALYSS.
+ *
+ *   NOALYSS is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   NOALYSS is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with NOALYSS; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+// Copyright Author Dany De Bontridder address@hidden
+// require_once '.php';
+require_once 'include/class_transform_client.php';
+$id = HtmlInput::default_value_request('c_id', null);
+$act = HtmlInput::default_value_request('remove_intervat_assujetti', 0);
+ob_start();
+if ($id == null)
+    echo _('Client incorrect');
+else
+{
+    $client = new Transform_Client($id);
+    if ($act == 0)
+    {
+        $action = "UPD";
+        $client->c_amount_novat = 
HtmlInput::default_value_get('c_amount_novat', $client->c_amount_novat);
+        $client->c_name = HtmlInput::default_value_get('c_name', 
$client->c_name);
+        $client->c_vatnumber = HtmlInput::default_value_get('c_vatnumber', 
$client->c_vatnumber);
+        $client->c_amount_vat = HtmlInput::default_value_get('c_amount_vat', 
$client->c_amount_vat);
+        $client->set_comment();
+        $client->save();
+        $js = 
sprintf('modify_intervat_assujetti(\'%s\',\'%s\',\'%s\',\'%s\')', 
$_REQUEST['gDossier'], $_REQUEST['ac'], $_REQUEST['plugin_code'], 
$client->c_id);
+        $code = ($client->c_comment == "") ? "ok" : "nok";
+        if ($code == "ok"):
+            ?>
+            <td>
+            <?php echo h($client->c_name) ?>
+            </td>
+            <td>
+            <?php echo h($client->c_vatnumber) ?>
+            </td>
+            <td>
+            <?php echo h($client->c_amount_novat) ?>
+            </td>
+            <td>
+            <?php echo h($client->c_amount_vat) ?>
+            </td>
+            <td>
+            <?php echo h($client->c_comment) ?>
+            </td>
+            <td>
+                <a class="line" href="javascript:void(0)" onclick="<?php echo 
$js; ?>"><?php echo _('Modifier') ?></a>
+            </td>
+            <?php
+            else:
+                echo $client->c_comment;
+        endif;
+    } else
+    {
+        $action = "EFF";
+        $client->delete();
+        $code="ok";
+        echo _('Effacer');
+    }
+}
+$response = ob_get_clean();
+ob_end_clean();
+$html = escape_xml($response);
+header('Content-type: text/xml; charset=UTF-8');
+echo <<<EOF
+<?xml version="1.0" encoding="UTF-8"?>
+<data>
+<code>$code</code>
+<action>$action</action>
+<rowid>$id</rowid>
+<html>$html</html>
+</data>
+EOF;
+?>        
\ No newline at end of file

Modified: trunk/transform/include/class_transform_client.php
===================================================================
--- trunk/transform/include/class_transform_client.php  2014-02-04 22:54:09 UTC 
(rev 688)
+++ trunk/transform/include/class_transform_client.php  2014-02-05 19:54:22 UTC 
(rev 689)
@@ -22,7 +22,9 @@
 /**
  * @brief manage the table intervat_client
  */
-class Transform_Client
+require_once 'class_transform_sql.php';
+
+class Transform_Client extends Intervat_Client_SQL
 {
 
     /**
@@ -68,7 +70,22 @@
         $cn->exec_sql("update transform.intervat_client set 
c_amount_vat=replace(c_amount_vat,',','.'),
             c_amount_novat=replace(c_amount_novat,',','.') where 
d_id=$1",array($p_declarant));
     }
-
+    function set_comment()
+    {
+        $this->c_comment="";
+        if ( ! preg_match('/^[0-9]{10}/', $this->c_vatnumber))
+        {
+            $this->c_comment=_('Numéro de tva incorrect');
+        }
+        if ( ! preg_match('/^[0-9]+\.[0-9]*/', $this->c_amount_novat))
+        {
+            $this->c_comment.=_('Montant incorrect');
+        }
+        if ( ! preg_match('/^[0-9]+\.[0-9]*/', $this->c_amount_vat))
+        {
+            $this->c_comment.=_('Montant TVA incorrect');
+        }
+    }
 }
 
 ?>

Modified: trunk/transform/include/class_transform_declarant.php
===================================================================
--- trunk/transform/include/class_transform_declarant.php       2014-02-04 
22:54:09 UTC (rev 688)
+++ trunk/transform/include/class_transform_declarant.php       2014-02-05 
19:54:22 UTC (rev 689)
@@ -121,6 +121,7 @@
 
     function insert()
     {
+        $this->verify();
         $this->data->d_name=$this->name;
         $this->data->d_street=$this->street;
         $this->data->d_postcode=$this->postcode;
@@ -154,7 +155,24 @@
         $this->readOnly=true;
         $this->input();
     }
-
+    function verify()
+    {
+        /* -- email must be valide */
+        if (!preg_match( 
'/^[_a-z0-9-]+(\.[_a-z0-9-]+)address@hidden(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/',$this->email))
+        {
+            throw new Exception(_('Email incorrect'),20);
+        }
+        if ($this->countrycode != 'BE') {
+            throw new Exception(_('Code Pays incorrect'),21);
+        }
+        
+        if ( ! preg_match('/^[0-9]+/',$this->phone)) {
+            throw new Exception(_('Numéro de téléphone incorrect'),22);
+        }
+        if ( ! preg_match('/^[0-9]+/',$this->vatnumber)) {
+            throw new Exception(_('Numéro de TVA incorrect'),23);
+        }
+    }
 }
 
 ?>

Modified: trunk/transform/include/class_transform_representative.php
===================================================================
--- trunk/transform/include/class_transform_representative.php  2014-02-04 
22:54:09 UTC (rev 688)
+++ trunk/transform/include/class_transform_representative.php  2014-02-05 
19:54:22 UTC (rev 689)
@@ -152,6 +152,7 @@
 
     function insert()
     {
+        $this->verify();
         $this->data->rp_listing_id = $this->id;
         $this->data->rp_issued = $this->issued;
         $this->data->rp_type = $this->type;
@@ -186,5 +187,20 @@
         $this->email = $this->data->rp_email;
         $this->phone = $this->data->rp_phone;
     }
+    function verify()
+    {
+        /* -- email must be valide */
+        if (!preg_match( 
'/^[_a-z0-9-]+(\.[_a-z0-9-]+)address@hidden(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/',$this->email))
+        {
+            throw new Exception(_('Email incorrect'),20);
+        }
+        if ($this->countrycode != 'BE') {
+            throw new Exception(_('Code Pays incorrect'),21);
+        }
+        
+        if ( ! preg_match('/^[0-9]+/',$this->phone)) {
+            throw new Exception(_('Numéro de téléphone incorrect'),22);
+        }
+    }
 
 }

Modified: trunk/transform/include/class_transform_sql.php
===================================================================
--- trunk/transform/include/class_transform_sql.php     2014-02-04 22:54:09 UTC 
(rev 688)
+++ trunk/transform/include/class_transform_sql.php     2014-02-05 19:54:22 UTC 
(rev 689)
@@ -266,6 +266,7 @@
             , "c_amount_vat" => "c_amount_vat"
             , "c_amount_novat" => "c_amount_novat"
             , "c_issuedby" => "c_issuedby"
+            ,'c_comment'=>'c_comment'
         );
 
         $this->type = array(
@@ -276,6 +277,7 @@
             , "c_amount_vat" => "text"
             , "c_amount_novat" => "text"
             , "c_issuedby" => "text"
+            , "c_comment" => "text"
         );
 
         $this->default = array(

Modified: trunk/transform/include/intervat_listing_assujetti_step_1.inc.php
===================================================================
--- trunk/transform/include/intervat_listing_assujetti_step_1.inc.php   
2014-02-04 22:54:09 UTC (rev 688)
+++ trunk/transform/include/intervat_listing_assujetti_step_1.inc.php   
2014-02-05 19:54:22 UTC (rev 689)
@@ -28,6 +28,7 @@
 $radio = new IRadio('p_inputtype');
 $h_tva = new ICheckBox('h_tva[]');
 $h_year = new INum('p_year');
+$h_year->value=HtmlInput::default_value_post('p_year',$declarant->year);
 $h_year->prec = 0;
 $h_tva_compute_date = new ISelect('p_compute_date');
 $h_tva_compute_date->value = array(

Modified: trunk/transform/include/intervat_listing_assujetti_step_2.inc.php
===================================================================
--- trunk/transform/include/intervat_listing_assujetti_step_2.inc.php   
2014-02-04 22:54:09 UTC (rev 688)
+++ trunk/transform/include/intervat_listing_assujetti_step_2.inc.php   
2014-02-05 19:54:22 UTC (rev 689)
@@ -26,6 +26,7 @@
 require_once 'class_transform_sql.php';
 require_once 'class_transform_representative.php';
 require_once 'class_transform_declarant.php';
+require_once 'class_transform_client.php';
 
 $inputtype = HtmlInput::default_value_post('p_inputtype', null);
 $year = HtmlInput::default_value_post('p_year', NULL);
@@ -132,13 +133,14 @@
                 /*
                  * insert into transform.intervat_client
                  */
-                $o_data[$i] = new Intervat_Client_SQL();
+                $o_data[$i] = new Transform_Client();
                 $o_data[$i]->d_id = $declarant->data->d_id;
                 $o_data[$i]->c_name = $data[0];
                 $o_data[$i]->c_issuedby = "BE";
                 $o_data[$i]->c_vatnumber = $data[1];
                 $o_data[$i]->c_amount_vat = $data[2];
                 $o_data[$i]->c_amount_novat = $data[3];
+                $o_data[$i]->set_comment();
                 $o_data[$i]->insert();
             }
             $cn->commit();
@@ -238,13 +240,14 @@
             /*
              * insert into transform.intervat_client
              */
-            $o_data[$i] = new Intervat_Client_SQL();
+            $o_data[$i] = new Transform_Client();
             $o_data[$i]->d_id = $declarant->data->d_id;
             $o_data[$i]->c_name = $a_listing[$i]['name'];
             $o_data[$i]->c_issuedby = "BE";
             $o_data[$i]->c_vatnumber = $a_listing[$i]['tvanumb'];
             $o_data[$i]->c_amount_vat = $a_listing[$i]['vat_amount'];
             $o_data[$i]->c_amount_novat = $a_listing[$i]['amount'];
+            $o_data[$i]->set_comment();
             $o_data[$i]->insert();
         }
         $cn->commit();

Modified: trunk/transform/include/template/listing_client_display.php
===================================================================
--- trunk/transform/include/template/listing_client_display.php 2014-02-04 
22:54:09 UTC (rev 688)
+++ trunk/transform/include/template/listing_client_display.php 2014-02-05 
19:54:22 UTC (rev 689)
@@ -41,14 +41,19 @@
             <?php echo _('TVA'); ?>
         </th>
         <th>
-            Action
+            <?php echo _('Commentaire'); ?>
         </th>
+        <th>
+            
+        </th>
     </tr>
-<?php    
+<?php
     for ($i=0;$i<$nb;$i++):
         $data=$a_listing->next($ret,$i);
+        $js=sprintf('modify_intervat_assujetti(\'%s\',\'%s\',\'%s\',\'%s\')',
+                
$_REQUEST['gDossier'],$_REQUEST['ac'],$_REQUEST['plugin_code'],$data->c_id);
 ?>
-    <tr>
+    <tr id="tr_<?php echo $data->c_id?>">
         <td>
             <?php 
             echo h($data->c_name);
@@ -70,8 +75,13 @@
             ?>
         </td>
         <td>
-            Modifier / enlever
+            <?php 
+            echo h($data->c_comment);
+            ?>
         </td>
+        <td>
+            <a class="line" href="javascript:void(0)" onclick="<?php echo $js; 
?>"><?php echo _('Modifier')?></a>
+        </td>
     </tr>
     <?php 
     endfor;

Modified: trunk/transform/index.php
===================================================================
--- trunk/transform/index.php   2014-02-04 22:54:09 UTC (rev 688)
+++ trunk/transform/index.php   2014-02-05 19:54:22 UTC (rev 689)
@@ -23,6 +23,14 @@
 Extension::check_version(4400);
 $cn=new Database(dossier::id());
 $transform_version=0;
+/*
+ * load javascript
+ */
+ob_start();
+require_once('transform_javascript.js');
+$j = ob_get_contents();
+ob_end_clean();
+echo create_script($j);
 
 if ( $cn->exist_schema('transform') == false)
   {

Modified: trunk/transform/sql/install.sql
===================================================================
--- trunk/transform/sql/install.sql     2014-02-04 22:54:09 UTC (rev 688)
+++ trunk/transform/sql/install.sql     2014-02-05 19:54:22 UTC (rev 689)
@@ -51,5 +51,6 @@
 alter table transform.request add         r_type text ;
 ALTER TABLE transform.request ADD COLUMN r_start_date date;
 ALTER TABLE transform.request ADD COLUMN r_end_date date;
+alter table transform.intervat_client add column c_comment text;
 
 

Added: trunk/transform/transform_javascript.js
===================================================================
--- trunk/transform/transform_javascript.js                             (rev 0)
+++ trunk/transform/transform_javascript.js     2014-02-05 19:54:22 UTC (rev 
689)
@@ -0,0 +1,116 @@
+/*
+ *   This file is part of NOALYSS.
+ *
+ *   NOALYSS is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   NOALYSS is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with NOALYSS; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+// Copyright Author Dany De Bontridder address@hidden
+function modify_intervat_assujetti(p_dossier, p_ac, p_plugin_code, c_id)
+{
+    try
+    {
+        var querystring = 'plugin_code=' + p_plugin_code + '&ac=' + p_ac + 
'&gDossier=' + p_dossier + '&act=modify_intervat_assujetti' + '&c_id=' + c_id;
+        waiting_box();
+        var action = new Ajax.Request(
+                "ajax.php",
+                {
+                    method: 'get',
+                    parameters: querystring,
+                    onFailure: error_get_predef,
+                    onSuccess: function(req) {
+                        remove_waiting_box();
+                        var answer = req.responseText;
+                        var position = fixed_position(451, 217);
+                        add_div({'id': 'modify_intervat_assujetti_div',
+                            'cssclass': 'inner_box', 'drag': 1, 'style': 
position});
+
+                        $('modify_intervat_assujetti_div').innerHTML = answer;
+                        answer.evalScripts();
+                    }
+                }
+        );
+
+    } catch (e)
+    {
+        alert(e.message);
+    }
+}
+function save_intervat_assujetti()
+{
+    try
+    {
+        var qs = $("save_intervat_assujetti_frm").serialize() + 
'&act=save_intervat_assujetti';
+        waiting_box();
+        var action = new Ajax.Request(
+                "ajax.php",
+                {
+                    method: 'get',
+                    parameters: qs,
+                    onFailure: error_get_predef,
+                    onSuccess: function(req, json) {
+                        try {
+                            remove_waiting_box();
+                            var answer = req.responseXML;
+                            var acode = answer.getElementsByTagName('code');
+                            var action = answer.getElementsByTagName('action');
+                            var html = answer.getElementsByTagName('html');
+                            var rowid = answer.getElementsByTagName('rowid');
+
+                            if (acode.length == 0) {
+                                var rec = req.responseText;
+                                alert('erreur :' + rec);
+                            }
+                            var code = acode[0].firstChild.nodeValue;
+                            var code_xml = getNodeText(html[0]);
+                            var code_html = unescape_xml(code_xml);
+                            var str_action = action[0].firstChild.nodeValue;
+                            var str_rowid = rowid[0].firstChild.nodeValue;
+
+                            if (code == 'ok')
+                            {
+                                removeDiv('modify_intervat_assujetti_div');
+                                var row = $('tr_' + str_rowid);
+                                if (str_action == 'EFF') {
+                                    row.cells[row.cells.length - 1].innerHTML 
= "";
+                                    row.style.textDecoration = 'line-through';
+                                } else {
+                                    row.innerHTML = code_html;
+                                }
+
+                            }
+                            if (code == 'nok')
+                            {
+                                // montre erreur
+                                
$('modify_intervat_assujetti_div_comment').innerHTML = code_html;
+                            }
+                        }
+                        catch (e) {
+                            alert("modify_intervat_assujetti_div " + 
e.message);
+                            return false;
+                        }
+
+                    }
+                }
+        );
+    }
+    catch (e)
+    {
+        alert(e.message);
+        return false;
+    }
+
+    return false;
+}
+



---
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]