dolibarr/htdocs/admin/facture.php

369 lines
11 KiB
PHP
Raw Normal View History

<?php
2004-07-20 10:31:06 +02:00
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
2005-06-11 13:11:17 +02:00
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 <EFBFBD>ric Seigne <eric.seigne@ryxeo.com>
2003-03-11 16:27:34 +01:00
*
* This program 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.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*/
2005-03-20 02:55:37 +01:00
/**
\file htdocs/admin/facture.php
\ingroup facture
\brief Page d'administration/configuration du module Facture
\version $Revision$
*/
2003-03-11 16:27:34 +01:00
require("./pre.inc.php");
$langs->load("admin");
$langs->load("bills");
if (!$user->admin)
accessforbidden();
2004-07-20 10:31:06 +02:00
$facture_addon_var = FACTURE_ADDON;
$facture_addon_var_pdf = FACTURE_ADDON_PDF;
2003-05-13 21:08:04 +02:00
$facture_rib_number_var = FACTURE_RIB_NUMBER;
$facture_chq_number_var = FACTURE_CHQ_NUMBER;
2004-07-20 10:31:06 +02:00
$facture_tva_option = FACTURE_TVAOPTION;
2003-03-11 16:27:34 +01:00
$typeconst=array('yesno','texte','chaine');
2004-07-20 10:31:06 +02:00
if ($_GET["action"] == 'set')
2003-03-11 16:27:34 +01:00
{
if (dolibarr_set_const($db, "FACTURE_ADDON",$_GET["value"]))
$facture_addon_var = $_GET["value"];
}
2004-07-20 10:31:06 +02:00
if ($_POST["action"] == 'setribchq')
2003-05-13 21:08:04 +02:00
{
2004-07-20 10:31:06 +02:00
if (dolibarr_set_const($db, "FACTURE_RIB_NUMBER",$_POST["rib"])) $facture_rib_number_var = $_POST["rib"];
if (dolibarr_set_const($db, "FACTURE_CHQ_NUMBER",$_POST["chq"])) $facture_chq_number_var = $_POST["chq"];
2003-05-13 21:08:04 +02:00
}
2004-07-20 10:31:06 +02:00
if ($_GET["action"] == 'setpdf')
2003-04-13 16:25:45 +02:00
{
2004-07-20 10:31:06 +02:00
if (dolibarr_set_const($db, "FACTURE_ADDON_PDF",$_GET["value"])) $facture_addon_var_pdf = $_GET["value"];
2003-04-13 16:25:45 +02:00
}
2005-06-19 13:58:07 +02:00
if ($_POST["action"] == 'setforcedate')
{
dolibarr_set_const($db, "FAC_FORCE_DATE_VALIDATION",$_POST["forcedate"]);
Header("Location: facture.php");
exit;
}
2004-07-20 10:31:06 +02:00
if ($_POST["action"] == 'settvaoption')
{
2004-07-20 10:31:06 +02:00
if (dolibarr_set_const($db, "FACTURE_TVAOPTION",$_POST["optiontva"])) $facture_tva_option = $_POST["optiontva"];
}
if ($_POST["action"] == 'update' || $_POST["action"] == 'add')
{
if (! dolibarr_set_const($db, $_POST["constname"],$_POST["constvalue"],$typeconst[$_POST["consttype"]],0,isset($_POST["constnote"])?$_POST["constnote"]:''));
{
print $db->error();
}
}
if ($_GET["action"] == 'delete')
{
if (! dolibarr_del_const($db, $_GET["rowid"]));
{
print $db->error();
}
}
2003-03-11 16:27:34 +01:00
$dir = "../includes/modules/facture/";
2005-04-02 22:15:25 +02:00
2005-06-11 13:11:17 +02:00
llxHeader('',$langs->trans("BillsSetup"),'FactureConfiguration');
2005-04-02 22:15:25 +02:00
print_titre($langs->trans("BillsSetup"));
/*
* Module num<EFBFBD>rotation
*/
print "<br>";
2005-06-11 13:11:17 +02:00
print_titre($langs->trans("BillsNumberingModule"));
2003-03-11 16:27:34 +01:00
2005-06-19 13:58:07 +02:00
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Description").'</td>';
print '<td>'.$langs->trans("Example").'</td>';
2005-06-19 13:58:07 +02:00
print '<td align="center" width="60">'.$langs->trans("Default").'</td>';
print "</tr>\n";
2003-03-11 16:27:34 +01:00
clearstatcache();
$handle=opendir($dir);
$var=True;
2003-03-11 16:27:34 +01:00
while (($file = readdir($handle))!==false)
{
if (is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
2003-03-11 16:27:34 +01:00
{
$var = !$var;
2005-06-19 13:58:07 +02:00
print '<tr '.$bc[$var].'><td width="100">';
2003-03-11 16:27:34 +01:00
echo "$file";
print "</td><td>\n";
$filebis = $file."/".$file.".modules.php";
// Chargement de la classe de num<75>rotation
$classname = "mod_facture_".$file;
require_once($dir.$filebis);
2003-03-11 16:27:34 +01:00
$obj = new $classname($db);
print $obj->info();
2003-03-11 16:27:34 +01:00
print '</td>';
2003-03-11 16:27:34 +01:00
// Affiche example
print '<td>'.$obj->getExample().'</td>';
print '<td align="center">';
2003-03-11 16:27:34 +01:00
if ($facture_addon_var == "$file")
{
2005-03-06 16:39:32 +01:00
print img_tick();
2003-03-11 16:27:34 +01:00
}
else
{
2005-06-19 13:58:07 +02:00
print '<a href="facture.php?action=set&amp;value='.$file.'">'.$langs->trans("Default").'</a>';
2003-03-11 16:27:34 +01:00
}
print "</td></tr>\n";
2003-03-11 16:27:34 +01:00
}
}
closedir($handle);
print '</table>';
2003-04-13 16:25:45 +02:00
/*
* PDF
2003-04-13 16:25:45 +02:00
*/
print '<br>';
2003-04-13 16:25:45 +02:00
print_titre("Mod<EFBFBD>les de facture pdf");
2005-06-19 13:58:07 +02:00
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Description").'</td>';
print '<td align="center" width="60">'.$langs->trans("Activated").'</td>';
2005-06-19 13:58:07 +02:00
print '<td align="center" width="60">'.$langs->trans("Default").'</td>';
print "</tr>\n";
2003-04-13 16:25:45 +02:00
clearstatcache();
$handle=opendir($dir);
$var=True;
2003-04-13 16:25:45 +02:00
while (($file = readdir($handle))!==false)
{
if (substr($file, strlen($file) -12) == '.modules.php' && substr($file,0,4) == 'pdf_')
{
$var = !$var;
2003-04-13 16:25:45 +02:00
$name = substr($file, 4, strlen($file) -16);
$classname = substr($file, 0, strlen($file) -12);
2005-06-19 13:58:07 +02:00
print '<tr '.$bc[$var].'><td width="100">';
2003-04-13 16:25:45 +02:00
echo "$name";
print "</td><td>\n";
require_once($dir.$file);
$obj = new $classname($db);
2003-04-13 16:25:45 +02:00
print $obj->description;
print '</td><td align="center">';
if ($facture_addon_var_pdf == "$name")
2003-04-13 16:25:45 +02:00
{
print '&nbsp;';
2005-06-19 13:58:07 +02:00
print '</td><td align="center">';
print img_tick();
2003-04-13 16:25:45 +02:00
}
else
{
print '&nbsp;';
print '</td><td align="center">';
2005-06-19 13:58:07 +02:00
print '<a href="facture.php?action=setpdf&amp;value='.$name.'">'.$langs->trans("Default").'</a>';
2003-04-13 16:25:45 +02:00
}
print "</td></tr>\n";
2003-04-13 16:25:45 +02:00
}
}
closedir($handle);
print '</table>';
2003-03-11 16:27:34 +01:00
2003-05-13 21:08:04 +02:00
/*
* Modes de r<EFBFBD>glement
2003-05-13 21:08:04 +02:00
*
*/
print '<br>';
print_titre( "Mode de r<>glement <20> afficher sur les factures");
2003-05-13 21:08:04 +02:00
2005-06-19 13:58:07 +02:00
print '<table class="noborder" width="100%">';
$var=True;
2004-07-20 10:31:06 +02:00
print '<form action="facture.php" method="post">';
print '<input type="hidden" name="action" value="setribchq">';
print '<tr class="liste_titre">';
print '<td>Mode r<>glement <20> proposer</td>';
print '<td align="right"><input type="submit" value="'.$langs->trans("Modify").'"></td>';
print "</tr>\n";
$var=!$var;
print '<tr '.$bc[$var].'>';
print "<td>Proposer paiement par RIB sur le compte</td>";
print "<td>";
$sql = "SELECT rowid, label FROM ".MAIN_DB_PREFIX."bank_account where clos = 0";
2003-05-13 21:08:04 +02:00
if ($db->query($sql))
{
2004-07-20 10:31:06 +02:00
$num = $db->num_rows();
$i = 0;
if ($num > 0) {
print "<select name=\"rib\">";
print '<option value="0">Ne pas afficher</option>';
while ($i < $num)
{
$var=!$var;
$row = $db->fetch_row($i);
if ($facture_rib_number_var == $row[0])
{
print '<option value="'.$row[0].'" selected>'.$row[1].'</option>';
}
else
{
print '<option value="'.$row[0].'">'.$row[1].'</option>';
}
$i++;
2004-07-20 10:31:06 +02:00
}
print "</select>";
} else {
print "<i>Aucun compte bancaire actif cr<63><72></i>";
}
2003-05-13 21:08:04 +02:00
}
print "</td></tr>";
$var=!$var;
print '<tr '.$bc[$var].'>';
print "<td>Proposer paiement par ch<63>que <20> l'ordre et adresse du titulaire du compte</td>";
print "<td>";
$sql = "SELECT rowid, label FROM ".MAIN_DB_PREFIX."bank_account where clos = 0";
$var=True;
if ($db->query($sql))
{
$num = $db->num_rows();
$i = 0;
2004-07-20 10:31:06 +02:00
if ($num > 0)
{
print "<select name=\"chq\">";
print '<option value="0">Ne pas afficher</option>';
while ($i < $num)
{
$var=!$var;
$row = $db->fetch_row($i);
2004-07-20 10:31:06 +02:00
if ($facture_chq_number_var == $row[0])
2004-07-20 10:31:06 +02:00
{
print '<option value="'.$row[0].'" selected>'.$row[1].'</option>';
}
else
2004-07-20 10:31:06 +02:00
{
print '<option value="'.$row[0].'">'.$row[1].'</option>';
}
$i++;
}
2004-07-20 10:31:06 +02:00
print "</select>";
} else {
print "<i>Aucun compte bancaire actif cr<63><72></i>";
}
}
print "</td></tr>";
2003-05-13 21:08:04 +02:00
print "</form>";
print "</table>";
2003-06-22 14:16:11 +02:00
/*
* Options fiscale
*/
print '<br>';
print_titre("Options fiscales de facturation de la TVA");
2005-06-19 13:58:07 +02:00
print '<table class="noborder" width="100%">';
2004-07-20 10:31:06 +02:00
print '<form action="facture.php" method="post">';
print '<input type="hidden" name="action" value="settvaoption">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Option").'</td><td>'.$langs->trans("Description").'</td>';
print '<td align="right"><input type="submit" value="'.$langs->trans("Modify").'"></td>';
print "</tr>\n";
$var=True;
$var=!$var;
print "<tr ".$bc[$var]."><td width=\"140\"><label><input type=\"radio\" name=\"optiontva\" value=\"reel\"".($facture_tva_option != "franchise"?" checked":"")."> Option r<>el</label></td>";
2005-06-11 13:11:17 +02:00
print "<td colspan=\"2\">L'option 'r<>el' est la plus courante. Elle est <20> destination des entreprises et professions lib<69>rales.\nChaque produits/service vendu est soumis <20> la TVA (Dolibarr propose le taux standard par d<>faut <20> la cr<63>ation d'une facture). Cette derni<6E>re est r<>cup<75>r<EFBFBD>e l'ann<6E>e suivante suite <20> la d<>claration TVA pour les produits/services achet<65>s et est revers<72>e <20> l'<27>tat pour les produits/services vendus.";
print "</td></tr>\n";
$var=!$var;
print "<tr ".$bc[$var]."><td width=\"140\"><label><input type=\"radio\" name=\"optiontva\" value=\"facturation\"".($facture_tva_option == "facturation"?" checked":"")."> Option facturation</label></td>";
print "<td colspan=\"2\">L'option 'facturation' est utilis<69>e par les entreprises qui payent la TVA <20> facturation (vente de mat<61>riel).</td></tr>\n";
2005-06-11 13:11:17 +02:00
$var=!$var;
print "<tr ".$bc[$var]."><td width=\"140\"><label><input type=\"radio\" name=\"optiontva\" value=\"franchise\"".($facture_tva_option == "franchise"?" checked":"")."> Option franchise</label></td>";
2005-06-11 13:11:17 +02:00
print "<td colspan=\"2\">L'option 'franchise' est utilis<69>e par les particuliers ou professions lib<69>rales <20> titre occasionnel avec de petits chiffres d'affaires.\nChaque produits/service vendu est soumis <20> une TVA de 0 (Dolibarr propose le taux 0 par d<>faut <20> la cr<63>ation d'une facture cliente). Il n'y a pas de d<>claration ou r<>cup<75>ration de TVA, et les factures qui g<>rent l'option affichent la mention obligatoire \"TVA non applicable - art-293B du CGI\".</td></tr>\n";
$var=!$var;
print "</form>";
print "</table>";
2005-06-19 13:58:07 +02:00
2005-03-20 02:55:37 +01:00
print "<br>";
2005-06-19 13:58:07 +02:00
print_titre($langs->trans("OtherOptions"));
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameter").'</td>';
print '<td align="center" width="60">'.$langs->trans("Value").'</td>';
print '<td width="80">&nbsp;</td>';
print "</tr>\n";
$var=false;
print '<form action="facture.php" method="post">';
print '<input type="hidden" name="action" value="setforcedate">';
print '<tr '.$bc[$var].'><td>';
echo "Forcer la d<>finition de la date des factures lors de la validation";
print '</td><td width="60" align="center">';
$forcedate=(defined("FAC_FORCE_DATE_VALIDATION") && FAC_FORCE_DATE_VALIDATION)?1:0;
$html=new Form($db);
print $html->selectyesno("forcedate",$forcedate,1);
print '</td><td align="center">';
print '<input type="submit" value="'.$langs->trans("Modify").'">';
print "</td></tr>\n";
print '</form>';
2005-03-20 02:55:37 +01:00
2005-06-19 13:58:07 +02:00
print '</table>';
print "<br>";
2005-04-02 22:15:25 +02:00
$db->close();
2005-06-11 13:11:17 +02:00
llxFooter('$Date$ - $Revision$');
2003-03-11 16:27:34 +01:00
?>