This commit is contained in:
Rodolphe Quiedeville 2002-07-03 12:46:00 +00:00
parent 89ea444f63
commit 499a662252
9 changed files with 296 additions and 41 deletions

View File

@ -88,7 +88,7 @@ if ($action == 'add') {
llxHeader();
print_titre("Nouvelle proposition commerciale pour <b><a href=\"index.php3?socid=$socidp\">$objsoc->nom</a></b>");
print_titre("Nouvelle proposition commerciale");
/*
@ -132,6 +132,7 @@ if ($action == 'create') {
$smonth = 1;
$syear = date("Y", time());
print '<table border="0">';
print '<tr><td>Société</td><td><a href="index.php3?socid='.$socidp.'">'.$objsoc->nom.'</a></td></tr>';
print "<tr><td>Date</td><td>";
$cday = date("d", time());
print "<select name=\"pday\">";

View File

@ -1,8 +1,5 @@
<?PHP
/* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* $Id$
* $Source$
*
* 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
@ -18,6 +15,9 @@
* 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$
*
*/
require("./pre.inc.php3");
@ -211,29 +211,26 @@ if ($action == 'create') {
} else {
print $db->error();
}
print_titre("Facture : ".$obj->facnumber);
print "<table border=\"0\" cellspacing=\"0\" cellpadding=\"2\" width=\"100%\">";
print "<tr>";
print '<td><div class="titre">Facture : '.$obj->facnumber.'</div></td>';
print "<td align=\"right\"><a href=\"facture.php3?socidp=$obj->socidp\">Autres factures de $obj->socnom</a></td>\n";
print "</tr>";
print "<tr><td width=\"50%\">";
/*
* Facture
*/
print "<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\" width=\"100%\">";
print "<tr><td>Société</td><td colspan=\"2\"><b><a href=\"fiche.php3?socid=$obj->socidp\">$obj->socnom</a></b></td></tr>";
print "<tr><td>Société</td><td colspan=\"3\"><b><a href=\"fiche.php3?socid=$obj->socidp\">$obj->socnom</a></b></td></tr>";
print "<tr><td>date</td><td colspan=\"2\">".strftime("%A %d %B %Y",$obj->df)."</td></tr>\n";
print "<tr><td>Auteur</td><td colspan=\"2\">$obj->author</td>";
print "<tr><td>Statut</td><td align=\"center\" colspan=\"2\">$obj->statut</td>";
print "<tr><td>Paye</td><td align=\"center\" colspan=\"2\" bgcolor=\"#f0f0f0\"><b>".$yn[$obj->paye]."</b></td>";
print "<tr><td>Date</td><td colspan=\"3\">".strftime("%A %d %B %Y",$obj->df)."</td></tr>\n";
print "<tr><td>Auteur</td><td colspan=\"3\">$obj->author</td>";
print "<tr><td>Montant</td><td align=\"right\"><b>".price($obj->amount)."</b></td><td>euros HT</td></tr>";
print "<tr><td>TVA</td><td align=\"right\">".tva($obj->amount)."</td><td>euros</td></tr>";
print "<tr><td>Total</td><td align=\"right\">".price($obj->total)."</td><td>euros TTC</td></tr>";
print '<tr><td>Montant</td><td align="right" colspan="2"><b>'.price($obj->amount).'</b></td><td>euros HT</td></tr>';
print '<tr><td>TVA</td><td align="right" colspan="2">'.tva($obj->amount).'</td><td>euros</td></tr>';
print '<tr><td>Total</td><td align="right" colspan="2">'.price($obj->total).'</td><td>euros TTC</td></tr>';
print "</tr>";
print '<tr><td>Statut</td><td align="center">'.$obj->statut.'</td>';
print "<td>Paye</td><td align=\"center\" bgcolor=\"#f0f0f0\"><b>".$yn[$obj->paye]."</b></td></tr>";
print "</table>";
print "</td><td valign=\"top\">";
@ -251,7 +248,7 @@ if ($action == 'create') {
$num = $db->num_rows();
$i = 0; $total = 0;
print "<p><b>Paiements</b>";
echo '<TABLE border="1" width="100%" cellspacing="0" cellpadding="3">';
echo '<TABLE border="0" width="100%" cellspacing="0" cellpadding="3">';
print "<TR class=\"liste_titre\">";
print "<td>Date</td>";
print "<td>Type</td>";
@ -270,14 +267,16 @@ if ($action == 'create') {
$total = $total + $objp->amount;
$i++;
}
print "<tr><td colspan=\"2\" align=\"right\">Total :</td><td align=\"right\"><b>".price($total)."</b></td><td>$_MONNAIE</td></tr>\n";
print "<tr><td colspan=\"2\" align=\"right\">Facturé :</td><td align=\"right\" bgcolor=\"#d0d0d0\">".price($obj->total)."</td><td bgcolor=\"#d0d0d0\">$_MONNAIE</td></tr>\n";
$resteapayer = $obj->total - $total;
print "<tr><td colspan=\"2\" align=\"right\">Reste a payer :</td>";
print "<td align=\"right\" bgcolor=\"#f0f0f0\"><b>".price($resteapayer)."</b></td><td bgcolor=\"#f0f0f0\">$_MONNAIE</td></tr>\n";
if ($obj->paye == 0) {
print "<tr><td colspan=\"2\" align=\"right\">Total :</td><td align=\"right\"><b>".price($total)."</b></td><td>$_MONNAIE</td></tr>\n";
print "<tr><td colspan=\"2\" align=\"right\">Facturé :</td><td align=\"right\" bgcolor=\"#d0d0d0\">".price($obj->total)."</td><td bgcolor=\"#d0d0d0\">$_MONNAIE</td></tr>\n";
$resteapayer = $obj->total - $total;
print "<tr><td colspan=\"2\" align=\"right\">Reste a payer :</td>";
print "<td align=\"right\" bgcolor=\"#f0f0f0\"><b>".price($resteapayer)."</b></td><td bgcolor=\"#f0f0f0\">$_MONNAIE</td></tr>\n";
}
print "</table>";
$db->free();
} else {

View File

@ -107,7 +107,7 @@ if ($result) {
$var=!$var;
print "<TR $bc[$var]><td>&nbsp</td>";
print "<td>Factures <a href=\"/compta/facture.php3?facid=$objp->facid\">$objp->facnumber</a> $objp->nom</TD>\n";
print "<td>Factures <a href=\"/fourn/facture/\">$objp->nom</a></TD>\n";
print "<TD align=\"right\">".price($objp->amount)."</TD>\n";

View File

@ -0,0 +1,251 @@
#!/usr/bin/perl
# Copyright (C) 2000-2002 Rodolphe Quiedeville
#
# 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.
# or see http://www.gnu.org/
# $Id$
# $Source$
use strict;
use DBI;
use Lolix::Conf;
use Getopt::Long;
Getopt::Long::Configure("bundling");
my $gljroot = $ENV{"GLJROOT"};
my($debug, $verbose, $bgcolor, $idfacture, $do_fax, $do_pdf, $do_ps, $html) = (0,0);
exit unless GetOptions("facture=i" =>\$idfacture,
"gljroot=s" =>\$gljroot,
"fax" =>\$do_fax,
"html" =>\$html,
"ps" =>\$do_ps,
"pdf" =>\$do_pdf,
"v+" =>\$verbose);
unless ($gljroot) { print "Missing ENV var: GLJROOT is not defined\n"; exit 0; }
unless (defined $ENV{"DBI_DSN"}) { print "Missing ENV var: DBI_DSN is not defined\n"; exit 0; }
#
#
#
my $templatesdir = $gljroot . "/scripts/templates/facture";
my $outputdir = $gljroot . "/www-sys/doc/facture/";
my $mdir = "$gljroot/www-sys/doc";
unless (-d $mdir) {
mkdir($mdir,0777) || die "cannot mkdir " . $mdir . ": $!";
}
$mdir = "$outputdir";
unless (-d $mdir) {
mkdir($mdir,0777) || die "cannot mkdir " . $mdir . ": $!";
}
my (%CONF) = Lolix::Conf::GetAllConf($gljroot . "/conf/config", 0);
my @countries = Lolix::Conf::GetCountries($gljroot . "/conf/config", 0);
#
# Fetch datas
#
my ($numpropale, $numfacture, $societe, $remiseht, $date, $destinataire, $ville, $address);
my ($totalht, $francsht,$remise,$tva,$total,$francsttc,$description);
print "Fetch data\n" if $verbose;
print "<br>" if ($verbose && $html);
my $dbh = DBI->connect() || die $DBI::errstr ; # We use env var DBI_DSN to connect to DB
my $sql = "SELECT f.rowid, f.facnumber, s.nom, f.amount, f.remise, f.tva, f.total, f.datef, s.c_nom, s.c_prenom, p.ref as propalref, s.ville, s.cp, s.address";
$sql .= " FROM llx_facture as f, societe as s, llx_propal as p, llx_fa_pr as pf ";
$sql .= " WHERE s.idp = f.fk_soc AND pf.fk_facture = f.rowid AND pf.fk_propal = p.rowid AND f.rowid = $idfacture";
my $sth = $dbh->prepare("$sql") || die $dbh->errstr ;
if ( $sth->execute ) {
while (my $hsr = $sth->fetchrow_hashref ) {
$numfacture = $hsr->{"facnumber"};
$societe = $hsr->{"nom"};
$remiseht = $hsr->{"remise"};
$date = $hsr->{"datef"};
$destinataire = $hsr->{"datep"};
$address = $hsr->{"address"};
$ville = $hsr->{"cp"} . " " . $hsr->{"ville"};
$totalht = sprintf("%.2f", $hsr->{"amount"});
$remise = sprintf("%.2f", $hsr->{"remise"});
$tva = sprintf("%.2f", $hsr->{"tva"});
$total = sprintf("%.2f", $hsr->{"total"});
$francsttc = sprintf("%.2f", ($hsr->{"total"} * 6.55957));
$numpropale = $hsr->{"propalref"};
}
$sth->finish;
} else {
print "db error\n";
}
#
#
#
$outputdir .= $numfacture;
print "outputdir is $outputdir\n" if $verbose ;
print "<br>" if ($verbose && $html);
unless (-d $outputdir) {
print "make $outputdir\n" if $verbose ;
print "<br>" if ($verbose && $html);
unless ( mkdir($outputdir,0777) ) {
print "failed : $!\n" if $verbose ;
}
}
#
#
#
my $headerfilename = "$templatesdir/header.tex";
my $footerfilename = "$templatesdir/footer.tex";
my $bodyfilename = "$templatesdir/body.tex";
open (FC, ">$outputdir/$numfacture.tex") || die "can't write in $outputdir/$numfacture.tex: $!";
##########################################################################################
#
# Header
#
##########################################################################################
open (FH, "<$headerfilename") || die "can't open $headerfilename: $!";
while (<FH>) {
s|\#SOCIETE\#|$societe|g;
s|\#ADDRESS\#|$address|g;
s|\#VILLE\#|$ville|g;
s|\#DESTINATAIRE\#|$destinataire|g;
s|\#NUMFACTURE\#|$numfacture|g;
s|\#DATE\#|$date|g;
print FC $_;
}
close (FH);
##########################################################################################
#
# BODY
#
##########################################################################################
my ($qty, $ref, $pu, $pricep, $label);
#
$sql = "SELECT p.price, pr.ref, pr.label, pr.description";
$sql .= " FROM llx_propaldet as p, llx_product as pr, llx_fa_pr as fp";
$sql .= " WHERE p.fk_propal = fp.fk_propal AND p.fk_product = pr.rowid AND fp.fk_facture = $idfacture";
$sth = $dbh->prepare("$sql") || die $dbh->errstr ;
if ( $sth->execute ) {
while (my $hsr = $sth->fetchrow_hashref ) {
$label = $hsr->{"label"};
$ref = $hsr->{"ref"};
$societe = $hsr->{"nom"};
$qty = 1 ;
$pu = sprintf("%.2f", $hsr->{"price"});
$pricep = sprintf("%.2f", $hsr->{"price"});
open (FB, "<$bodyfilename") || die "can't open $bodyfilename: $!";
while (<FB>) {
s|\#LABEL\#|$hsr->{"description"}|g;
s|\#QTY\#|$qty|g;
s|\#REF\#|$ref|g;
s|\#PU\#|$pu|g;
s|\#PRICE\#|$pricep|g;
print FC $_;
}
close (FB);
}
$sth->finish;
} else {
print "** ERROR\n";
print "<br>" if ( $html);
}
##########################################################################################
#
# Footer
#
##########################################################################################
open (FF, "<$footerfilename") || die "can't open $footerfilename: $!";
while (<FF>) {
s|\#SOCIETE\#|$societe|g;
s|\#DATE\#|$date|g;
s|\#TOTALHT\#|$totalht|g;
s|\#NUMPROPALE\#|$numpropale|g;
s|\#FRANCSHT\#|$francsht|g;
s|\#REMISEHT\#|$remise|g;
s|\#TVA\#|$tva|g;
s|\#TOTALTTC\#|$total|g;
s|\#FRANCS\#|$francsttc|g;
print FC $_;
}
close (FF);
##########################################################################################
#
#
#
##########################################################################################
close (FC);
$dbh->disconnect if $dbh;
#
#
#
print "**\n** Generate dvi file\n**\n";
print "<br>" if ($verbose && $html);
system("cd $outputdir/ ; latex $numfacture.tex ");
#
#exit;
print "<p>Generate pdf file<br>\n";
print "<br>" if ($verbose && $html);
system("cd $outputdir/ ; pdflatex $numfacture.tex > /dev/null");
#
print "\n**\n** Generate ps file\n**\n";
print "<br>" if ($verbose && $html);
system("cd $outputdir/ ; dvips $numfacture.dvi -o $numfacture.ps > /dev/null");
#
# export DBI_DSN="dbi:mysql:dbname=lolixfr:host=espy" ; ../scripts/facture-tex.pl
#

View File

@ -103,7 +103,7 @@ if ($socid > 0) {
*/
print_barre_liste("Liste des factures", $page, $PHP_SELF);
$sql = "SELECT s.idp, s.nom, ".$db->pdate("s.datec")." as datec, ".$db->pdate("s.datea")." as datea, s.prefix_comm, fac.amount, fac.paye, fac.libelle, ".$db->pdate("fac.datef")." as datef, fac.rowid as facid";
$sql = "SELECT s.idp as socid, s.nom, ".$db->pdate("s.datec")." as datec, ".$db->pdate("s.datea")." as datea, s.prefix_comm, fac.amount, fac.paye, fac.libelle, ".$db->pdate("fac.datef")." as datef, fac.rowid as facid";
$sql .= " FROM societe as s, llx_facture_fourn as fac ";
$sql .= " WHERE fac.fk_soc = s.idp";
@ -135,7 +135,7 @@ if ($socid > 0) {
print "<TR $bc[$var]>";
print "<TD><a href=\"fiche.php3?facid=$obj->facid\">$obj->libelle</A></td>\n";
print "<TD><a href=\"fiche.php3?socid=$obj->facid\">$obj->nom</A></td>\n";
print "<TD><a href=\"../fiche.php3?socid=$obj->socid\">$obj->nom</A></td>\n";
print '<TD align="right">'.price($obj->amount).'</TD>';
print "<TD align=\"center\">$obj->prefix_comm&nbsp;</TD>\n";

View File

@ -87,7 +87,7 @@ function top_menu($head) {
print '<a class="menu" href="'.$conf->webcal->url.'">Calendrier</a>';
};
print '&nbsp;</TD>';
print '<TD width="15%" class="menu" align="center">'.strftime(" %d %B %H:%M",time()).'</TD>';
print '<TD width="15%" class="menu" align="center">'.strftime(" %d %B - %H:%M",time()).'</TD>';
print '<TD width="10%" class="menu" align="center">'.$user->code.'</td>';
print '</TR>';

View File

@ -29,6 +29,8 @@ $db = new Db();
*
*/
print_titre("Liste des utilisateurs");
$sql = "SELECT u.rowid, u.name, u.firstname, u.code, u.login, u.module_comm, u.module_compta FROM llx_user as u";
$sql .= " ORDER BY u.name";

View File

@ -129,23 +129,23 @@ values (41,4,'Alix','Victor','01 40 15 03 18','01 40 15 06 18','dev@lafrere.net'
--
delete from llx_product;
insert into llx_product (ref, label, description, price, duration)
values ('CRRJ452M','Câble Réseaux RJ45 2m','Câble Réseaux RJ45 2m',10,'1 mois');
insert into llx_product (ref, label, description, price)
values ('CRRJ452M','Câble Réseaux RJ45 2m','Câble Réseaux RJ45 2m',10);
insert into llx_product (ref, label, description, price, duration)
values ('3COMSW8','Switch Cisco 8 ports 100Mbits','Switch Cisco 8 ports 100Mbits',1000,'1 mois');
insert into llx_product (ref, label, description, price)
values ('3COMSW8','Switch Cisco 8 ports 100Mbits','Switch Cisco 8 ports 100Mbits',1000);
insert into llx_product (ref, label, description, price, duration)
values ('ALPH','Station Alpha Serie 3w','Configuration Alpha',9750,'1 mois');
insert into llx_product (ref, label, description, price)
values ('ALPH','Station Alpha Serie 3w','Configuration Alpha',9750);
insert into llx_product (ref, label, description, price, duration)
values ('HUB8-10','Hub 8 ports 10Mbits','Hub 8 ports',750,'1 mois');
insert into llx_product (ref, label, description, price)
values ('HUB8-10','Hub 8 ports 10Mbits','Hub 8 ports',750);
insert into llx_product (ref, label, description, price, duration)
values ('PB-16','Pan. Brass. 16','Panneau de brassage extensible, incluant 1 barre de 16 prises',650,'1 mois');
insert into llx_product (ref, label, description, price)
values ('PB-16','Pan. Brass. 16','Panneau de brassage extensible, incluant 1 barre de 16 prises',650);
insert into llx_product (ref, label, description, price, duration)
values ('PB-32','Pan. Brass. 32','Panneau de brassage extensible, incluant 2 barres de 16 prises',1200,'1 mois');
insert into llx_product (ref, label, description, price)
values ('PB-32','Pan. Brass. 32','Panneau de brassage extensible, incluant 2 barres de 16 prises',1200);
--
--

View File

@ -21,10 +21,12 @@
create table llx_product
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
datec datetime,
tms timestamp,
ref varchar(15),
label varchar(255),
description text,
price smallint,
duration varchar(32)
fk_user_author integer
);