noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
tva.inc.php
Go to the documentation of this file.
00001 <?php
00002 /*
00003  *   This file is part of NOALYSS.
00004  *
00005  *   NOALYSS is free software; you can redistribute it and/or modify
00006  *   it under the terms of the GNU General Public License as published by
00007  *   the Free Software Foundation; either version 2 of the License, or
00008  *   (at your option) any later version.
00009  *
00010  *   NOALYSS is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with NOALYSS; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018  */
00019 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00020 /** \file
00021  * \brief included file for customizing with the vat (account,rate...)
00022  */
00023 if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
00024 require_once('class_own.php');
00025 require_once('class_html_input.php');
00026 require_once('class_ihidden.php');
00027 require_once('class_itextarea.php');
00028 echo '<div class="content">';
00029 // Confirm remove
00030 if (isset($_POST['confirm_rm']))
00031 {
00032     if ($cn->count_sql('select * from tva_rate') > 1)
00033         $cn->exec_sql('select tva_delete($1)', array($_POST['tva_id']));
00034     else
00035         echo '<p class="notice">Vous ne pouvez pas effacer tous taux' .
00036         ' Si votre soci&eacute;t&eacute; n\'utilise pas la TVA, changer dans le menu soci&eacute;t&eacute</p>';
00037 }
00038 $both_side=(isset($_REQUEST['both']))?1:0;
00039 //-----------------------------------------------------
00040 // Record Change
00041 if (isset($_POST['confirm_mod'])
00042         || isset($_POST['confirm_add']))
00043 {
00044     extract($_POST);
00045     // remove space
00046     $tva_poste = str_replace(" ", "", $tva_poste);
00047     $err = 0; // Error code
00048 
00049     if (isNumber($tva_rate) == 0)
00050     {
00051         $err = 2;
00052     }
00053 
00054         if ($err == 0)
00055     {
00056         if (isset($_POST['confirm_add']))
00057         {
00058             $sql = "select tva_insert($1,$2,$3,$4,$5)";
00059 
00060             $res = $cn->exec_sql(
00061                     $sql, array($tva_label,
00062                 $tva_rate,
00063                 $tva_comment,
00064                 $tva_poste,
00065                         $both_side)
00066             );
00067             $err = Database::fetch_result($res);
00068         }
00069         if (isset($_POST['confirm_mod']))
00070         {
00071             $Res = $cn->exec_sql(
00072                     "select tva_modify($1,$2,$3,$4,$5,$6)", array($tva_id, $tva_label, $tva_rate, $tva_comment, $tva_poste,$both_side)
00073             );
00074             $err = Database::fetch_result($Res);
00075         }
00076     }
00077     if ($err != 0)
00078     {
00079         $err_code = array(1 => "Tva id n\'est pas un nombre",
00080             2 => "Taux tva invalide",
00081             3 => "Label ne peut être vide",
00082             4 => "Poste invalide",
00083             5 => "Tva id doit être unique");
00084         $str_err = $err_code[$err];
00085         echo "<script>alert ('$str_err'); </script>";
00086         ;
00087     }
00088 }
00089 // If company not use VAT
00090 $own = new Own($cn);
00091 if ($own->MY_TVA_USE == 'N')
00092 {
00093     echo '<h2 class="error"> Vous n\'êtes pas assujetti à la TVA</h2>';
00094     exit();
00095 }
00096 //-----------------------------------------------------
00097 // Display
00098 $sql = "select tva_id,tva_label,tva_rate,tva_comment,tva_poste,tva_both_side from tva_rate order by tva_label";
00099 $Res = $cn->exec_sql($sql);
00100 ?>
00101 <TABLE>
00102     <TR>
00103         <th>Id</th>
00104         <th>Label</TH>
00105         <th>Taux</th>
00106         <th>Commentaire</th>
00107         <th>Poste</th>
00108         <th>Utilisé en même temps au crédit et au débit</th>
00109     </tr>
00110 <?php
00111 $val = Database::fetch_all($Res);
00112 foreach ($val as $row)
00113 {
00114     // load value into an array
00115     $index = $row['tva_id'];
00116     $tva_array[$index] = array(
00117         'tva_label' => $row['tva_label'],
00118         'tva_rate' => $row['tva_rate'],
00119         'tva_comment' => $row['tva_comment'],
00120         'tva_poste' => $row['tva_poste'],
00121         'tva_both_side' => $row['tva_both_side']
00122     );
00123 
00124     echo "<TR>";
00125     echo '<FORM METHOD="POST">';
00126 
00127     echo '<td>';
00128     echo $row['tva_id'];
00129     echo '</td>';
00130 
00131     echo "<TD>";
00132     echo HtmlInput::hidden('tva_id', $row['tva_id']);
00133     echo h($row['tva_label']);
00134     echo "</TD>";
00135 
00136     echo "<TD>";
00137     echo $row['tva_rate'];
00138     echo "</TD>";
00139 
00140     echo "<TD>";
00141     echo h($row['tva_comment']);
00142     echo "</TD>";
00143 
00144     echo "<TD>";
00145     echo $row['tva_poste'];
00146     echo "</TD>";
00147 
00148     echo "<TD>";
00149     $str_msg=( $row['tva_both_side']==1)?'Employé au crédit et débit':'normal' ;
00150     echo $str_msg;
00151     echo "</TD>";
00152 
00153     echo "<TD>";
00154     echo HtmlInput::submit("rm", "Efface");
00155     echo HtmlInput::submit("mod", "Modifie");
00156     $w = new IHidden();
00157     $w->name = "tva_id";
00158     $w->value = $row['tva_id'];
00159     echo $w->input();
00160     $w = new IHidden();
00161     $w->name = "p_action";
00162     $w->value = "divers";
00163     echo $w->input();
00164     $w = new IHidden();
00165     $w->name = "sa";
00166     $w->value = "tva";
00167     echo $w->input();
00168 
00169     echo "</TD>";
00170 
00171     echo '</FORM>';
00172     echo "</TR>";
00173 }
00174 ?>
00175 </TABLE>
00176     <?php
00177     // if we add / remove or modify a vat we don't show this button
00178     if (!isset($_POST['add'])
00179             && !isset($_POST['mod'])
00180             && !isset($_POST['rm'])
00181     )
00182     {
00183         ?>
00184     <form method="post">
00185         <input type="submit" class="button" name="add" value="Ajouter un taux de tva">
00186         <input type="hidden" name="p_action" value="divers">
00187         <input type="hidden" name="sa" value="tva">
00188     </form>
00189     <?php
00190 }
00191 
00192 
00193 //-----------------------------------------------------
00194 // remove
00195 if (isset($_REQUEST['rm']))
00196 {
00197     echo "Voulez-vous vraiment effacer ce taux ? ";
00198     $index = $_POST['tva_id'];
00199     ?>
00200     <table>
00201         <TR>
00202         <th>Label</TH>
00203         <th>Taux</th>
00204         <th>Commentaire</th>
00205         <th>Poste</th>
00206         <th>Double côté</th>
00207         </tr>
00208         <tr>
00209         <td> <?php echo $tva_array[$index]['tva_label'];?></td>
00210         <td> <?php echo $tva_array[$index]['tva_rate'];?></td>
00211         <td> <?php echo $tva_array[$index]['tva_comment'];?></td>
00212         <td> <?php echo $tva_array[$index]['tva_poste'];?></td>
00213         <td> <?php echo $tva_array[$index]['tva_both_side'];?></td>
00214         </Tr>
00215     </table>
00216                 <?php
00217                 echo '<FORM method="post">';
00218                 echo '<input type="hidden" name="tva_id" value="' . $index . '">';
00219                 echo HtmlInput::submit("confirm_rm", "Confirme");
00220                 echo HtmlInput::submit("Cancel", "no");
00221                 echo "</form>";
00222             }
00223             //-----------------------------------------------------
00224             // add
00225             if (isset($_REQUEST['add']))
00226             {
00227                 echo "<fieldset><legend>Ajout d'un taux de tva </legend>";
00228                 echo '<FORM method="post">';
00229                 ?>
00230     <table >
00231         <tr> <td align="right"> Label (ce que vous verrez dans les journaux)</td>
00232         <td> <?php
00233     $w = new IText();
00234     $w->size = 20;
00235     echo $w->input('tva_label', '')
00236                 ?></td>
00237         </tr>
00238         <tr><td  align="right"> Taux de tva </td>
00239         <td> <?php
00240     $w = new IText();
00241     $w->size = 5;
00242     echo $w->input('tva_rate', '')
00243     ?></td>
00244         </tr>
00245         <tr>
00246         <td  align="right"> Commentaire </td>
00247         <td> <?php
00248     $w = new ITextarea;
00249     $w->heigh = 5;
00250     $w->width = 50;
00251     echo $w->input('tva_comment', '')
00252                 ?></td>
00253         </tr>
00254         <tr>
00255         <td  align="right">Poste comptable utilisés format :debit,credit</td>
00256         <td> <?php
00257             $w = new IText();
00258             $w->size = 20;
00259             echo $w->input('tva_poste', '')
00260             ?></td>
00261         </Tr>
00262         <tr>
00263         <td  align="right">Utilisé au débit et au crédit afin d'annuler cette tva </td>
00264         <td> <?php
00265             $w = new ICheckBox("both", 1);
00266             $w->size = 20;
00267             echo $w->input('both', '')
00268             ?></td>
00269         </Tr>
00270     </table>
00271     <input type="submit" class="button" value="Confirme" name="confirm_add">
00272     <input type="submit" class="button" value="Cancel" name="no">
00273 
00274     </FORM>
00275     </fieldset>
00276     <?php
00277 }
00278 
00279 //-----------------------------------------------------
00280 // mod
00281 if (isset($_REQUEST['mod']))
00282 {
00283 
00284     echo "Tva à modifier";
00285     $index = $_POST['tva_id'];
00286     echo "<fieldset><legend>Modification d'un taux de tva </legend>";
00287     echo '<FORM method="post">';
00288     echo '<input type="hidden" name="tva_id" value="' . $index . '">';
00289     ?>
00290     <table>
00291         <tr> <td align="right"> Label (ce que vous verrez dans les journaux)</td>
00292         <td> <?php
00293     $w = new Itext();
00294     $w->size = 20;
00295     echo $w->input('tva_label', $tva_array[$index]['tva_label'])
00296     ?></td>
00297         </tr>
00298         <tr><td  align="right"> Taux de tva </td>
00299 
00300         <td> <?php
00301     $w = new Itext();
00302     $w->size = 5;
00303     echo $w->input('tva_rate', $tva_array[$index]['tva_rate'])
00304     ?></td>
00305         </tr>
00306         <tr>
00307         <td  align="right"> Commentaire </td>
00308         <td> <?php
00309             $w = new ITextarea();
00310             $w->heigh = 5;
00311             $w->width = 50;
00312             echo $w->input('tva_comment', $tva_array[$index]['tva_comment'])
00313             ?></td>
00314         </tr>
00315         <tr>
00316         <td  align="right">Poste comptable utilisés format :debit,credit</td>
00317 
00318         <td> <?php
00319             $w = new IText();
00320             $w->size = 20;
00321             echo $w->input('tva_poste', $tva_array[$index]['tva_poste'])
00322             ?></td>
00323         </Tr>
00324         <tr>
00325         <td  align="right">Utilisé au débit et au crédit afin d'annuler cette tva </td>
00326         <td> <?php
00327             $w = new ICheckBox("both",$tva_array[$index]['tva_both_side'] );
00328             $w->selected=$tva_array[$index]['tva_both_side'];
00329             $w->size = 20;
00330             echo $w->input('both', '')
00331             ?></td>
00332         </Tr>
00333     </table>
00334     <input type="submit" class="button" value="Confirme" name="confirm_mod">
00335     <input type="submit" class="button" value="Cancel" name="no">
00336     </FORM>
00337     </fieldset>
00338     <?php
00339 }
00340 echo '</div>';
00341 ?>
 All Data Structures Namespaces Files Functions Variables Enumerations