From 5050e3e90c02a67f29367a23aee8b71f4e83b6ae Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Sat, 11 May 2002 18:53:13 +0000 Subject: [PATCH] . --- htdocs/actioncomm.class.php3 | 105 +++++ htdocs/cactioncomm.class.php3 | 53 +++ htdocs/comm/addpropal.php3 | 2 +- htdocs/comm/facture.php3 | 18 +- htdocs/comm/propal-tex.pl | 1 - htdocs/comm/propal.php3 | 16 +- htdocs/compta/bank/account.class.php3 | 72 +++ htdocs/compta/bank/account.php3 | 70 +++ htdocs/compta/bank/bank.class.php3 | 68 +++ htdocs/compta/bank/bilan.php3 | 73 +++ htdocs/compta/bank/budget.php3 | 140 ++++++ htdocs/compta/bank/categ.php3 | 84 ++++ htdocs/compta/bank/config.php3 | 85 ++++ htdocs/compta/bank/functions.lib.php3 | 485 ++++++++++++++++++++ htdocs/compta/bank/ligne.php3 | 128 ++++++ htdocs/compta/bank/pre.inc.php3 | 74 ++++ htdocs/compta/bank/rappro.php3 | 121 +++++ htdocs/compta/bank/releve.php3 | 162 +++++++ htdocs/compta/bank/virement.php3 | 106 +++++ htdocs/compta/casoc.php3 | 109 ++--- htdocs/compta/facture.php3 | 615 ++++++++++++++++---------- htdocs/compta/fiche.php3 | 47 +- htdocs/compta/index.php3 | 211 ++++----- htdocs/compta/propal.php3 | 208 +-------- htdocs/fichinter/index.php3 | 11 +- htdocs/project.class.php3 | 109 +++++ htdocs/propal.class.php3 | 222 ++++++++++ mysql/data/data.sql | 1 + mysql/tables/Makefile | 1 - mysql/tables/drop.sql | 2 - mysql/tables/llx_voyage_reduc.sql | 38 ++ 31 files changed, 2771 insertions(+), 666 deletions(-) create mode 100644 htdocs/actioncomm.class.php3 create mode 100644 htdocs/cactioncomm.class.php3 create mode 100644 htdocs/compta/bank/account.class.php3 create mode 100644 htdocs/compta/bank/account.php3 create mode 100644 htdocs/compta/bank/bank.class.php3 create mode 100644 htdocs/compta/bank/bilan.php3 create mode 100644 htdocs/compta/bank/budget.php3 create mode 100644 htdocs/compta/bank/categ.php3 create mode 100644 htdocs/compta/bank/config.php3 create mode 100644 htdocs/compta/bank/functions.lib.php3 create mode 100644 htdocs/compta/bank/ligne.php3 create mode 100644 htdocs/compta/bank/pre.inc.php3 create mode 100644 htdocs/compta/bank/rappro.php3 create mode 100644 htdocs/compta/bank/releve.php3 create mode 100644 htdocs/compta/bank/virement.php3 create mode 100644 htdocs/project.class.php3 create mode 100644 htdocs/propal.class.php3 create mode 100644 mysql/tables/llx_voyage_reduc.sql diff --git a/htdocs/actioncomm.class.php3 b/htdocs/actioncomm.class.php3 new file mode 100644 index 00000000000..1b7f3f07460 --- /dev/null +++ b/htdocs/actioncomm.class.php3 @@ -0,0 +1,105 @@ + + * + * $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 + * 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. + * + */ + +class ActionComm { + var $id; + var $db; + + var $date; + var $type; + + var $priority; + + var $user; + var $author; + + var $societe; + var $contact; + var $note; + + var $percent; + + + Function ActionComm($db) { + $this->db = $db; + $this->societe = new Societe($db); + + } + /* + * + * + * + */ + Function add($author) { + $sql = "INSERT INTO actioncomm (datea, fk_action, fk_soc, fk_user_author, fk_user_action, fk_contact, percent, note,priority) "; + $sql .= " VALUES ('$this->date',$this->type,$this->societe, $author->id,"; + $sql .= $this->user->id . ", $this->contact, $this->percent, '$this->note', $this->priority);"; + + if ($this->db->query($sql) ) { + + + } else { + print $this->db->error() . "
" . $sql; + } + } + /* + * + * + * + */ + Function fetch($id) { + + $sql = "SELECT ".$this->db->pdate("a.datea")." as da, a.note,c.libelle, fk_soc "; + $sql .= "FROM actioncomm as a, c_actioncomm as c WHERE a.id=$id AND a.fk_action=c.id;"; + + if ($this->db->query($sql) ) { + if ($this->db->num_rows()) { + $obj = $this->db->fetch_object(0); + + $this->id = $id; + $this->type = $obj->libelle; + $this->date = $obj->da; + $this->note =$obj->note; + + $this->societe->id = $obj->fk_soc; + + $this->db->free(); + } + } else { + print $this->db->error(); + } + } + /* + * + * + * + */ + Function delete($id) { + + $sql = "DELETE FROM actioncomm WHERE id=$id;"; + + if ($this->db->query($sql) ) { + + } + } +} +?> diff --git a/htdocs/cactioncomm.class.php3 b/htdocs/cactioncomm.class.php3 new file mode 100644 index 00000000000..5cb8517e37e --- /dev/null +++ b/htdocs/cactioncomm.class.php3 @@ -0,0 +1,53 @@ + + * + * $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 + * 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. + * + */ + +class CActioncomm { + var $id; + var $libelle; + + Function CActioncomm() { + + } + /* + * + * + * + */ + Function fetch($db, $id) { + + $sql = "SELECT libelle FROM c_actioncomm WHERE id=$id;"; + + if ($db->query($sql) ) { + if ($db->num_rows()) { + $obj = $db->fetch_object(0); + + $this->id = $id; + $this->libelle = $obj->libelle; + + $db->free(); + } + } else { + print $db->error(); + } + } +} +?> diff --git a/htdocs/comm/addpropal.php3 b/htdocs/comm/addpropal.php3 index a5e879acd46..b467e94ac01 100644 --- a/htdocs/comm/addpropal.php3 +++ b/htdocs/comm/addpropal.php3 @@ -71,7 +71,7 @@ if ($action == 'add') { $gljroot = "/home/www/dolibarr/dolibarr/htdocs"; $command = "export DBI_DSN=\"dbi:mysql:dbname=".$conf->db->name.":host=localhost\" "; - $command .= " ; ./propal-tex.pl --propal=".$id ." --pdf --output=".$conf->propal->outputdir; + $command .= " ; ./propal-tex.pl --propal=".$id ." --pdf --ps --output=".$conf->propal->outputdir; $command .= " --templates=".$conf->propal->templatesdir; $output = system($command); diff --git a/htdocs/comm/facture.php3 b/htdocs/comm/facture.php3 index 0a512463579..5f047ae628d 100644 --- a/htdocs/comm/facture.php3 +++ b/htdocs/comm/facture.php3 @@ -24,10 +24,6 @@ require("./pre.inc.php3"); llxHeader(); $db = new Db(); -$author = $GLOBALS["REMOTE_USER"]; -$bc[0]="bgcolor=\"#90c090\""; -$bc[1]="bgcolor=\"#b0e0b0\""; - if ($action == 'add') { $datefacture = $db->idate(mktime(12, 0 , 0, $pmonth, $pday, $pyear)); @@ -63,9 +59,6 @@ if ($action == 'add') { $output = system($command); print "

command : $command
"; - - - } } else { print "

Erreur : la facture n'a pas été créée, vérifier le numéro !"; @@ -207,6 +200,17 @@ if ($action == 'add') { print ""; } + + + + + + + + + + + if ($facid) { $sql = "SELECT s.nom,s.idp, f.amount, f.facnumber, f.rowid"; diff --git a/htdocs/comm/propal-tex.pl b/htdocs/comm/propal-tex.pl index 1c185a2aed4..dfa94e90367 100755 --- a/htdocs/comm/propal-tex.pl +++ b/htdocs/comm/propal-tex.pl @@ -31,7 +31,6 @@ Sys::Syslog::setlogsock('unix'); Sys::Syslog::openlog($0, 'pid', 'daemon'); - my($debug, $verbose, $bgcolor, $idpropal, $do_fax, $do_pdf, $do_ps, $templatesdir, $outputdir) = (0,0); diff --git a/htdocs/comm/propal.php3 b/htdocs/comm/propal.php3 index 069d6e8dda5..61dc7fa8d1c 100644 --- a/htdocs/comm/propal.php3 +++ b/htdocs/comm/propal.php3 @@ -25,9 +25,9 @@ require("../lib/CMailFile.class.php3"); /* * Modules optionnels */ -require("projet/project.class.php3"); -require("./propal.class.php3"); -require("./actioncomm.class.php3"); +require("../project.class.php3"); +require("../propal.class.php3"); +require("../actioncomm.class.php3"); /* * */ @@ -255,17 +255,7 @@ if ($propalid) { /* * */ - if ($action == 'fax') { - print "


Génération du fax
"; - $command = "export DBI_DSN=\"dbi:mysql:dbname=lolixfr:host=espy:user=rodo\" "; - $command .= " ; ../../scripts/propal-tex.pl --propal=$propalid --pdf --gljroot=" . $GLOBALS["GLJ_ROOT"] ; - //$command .= " ; ../../scripts/fax-tex.pl --propal=$propalid --gljroot=" . $GLOBALS["GLJ_ROOT"] ; - print "

Resultat :

"; - - $output = system($command); - print "

command : $command
"; - } /* * Send * diff --git a/htdocs/compta/bank/account.class.php3 b/htdocs/compta/bank/account.class.php3 new file mode 100644 index 00000000000..9e0831247c9 --- /dev/null +++ b/htdocs/compta/bank/account.class.php3 @@ -0,0 +1,72 @@ + + * + * $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 + * 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. + * + */ + +class Account { + var $rowid; + var $bank; + var $label; + var $name; + + Function Account($DB, $rowid=0) { + global $config; + + $this->db = $DB; + $this->rowid = $rowid; + + return 1; + } + + Function fetch() { + $sql = "SELECT s.idp, s.nom,".$this->db->pdate("s.datec"); + $sql .= " AND s.idp = ".$this->id; + + $result = $this->db->query($sql); + + if ($result) { + if ($this->db->num_rows()) { + $obj = $this->db->fetch_object($result , 0); + + $this->nom = $obj->nom; + } + $this->db->free(); + } + } + + Function solde() { + $sql = "SELECT sum(amount) FROM llx_bank WHERE rowid=$this->id"; + + $result = $this->db->query($sql); + + if ($result) { + if ($this->db->num_rows()) { + $solde = $this->db->fetch_result(0,0); + + return $solde; + } + $this->db->free(); + } + } + + +} + +?> diff --git a/htdocs/compta/bank/account.php3 b/htdocs/compta/bank/account.php3 new file mode 100644 index 00000000000..cee0a8e031e --- /dev/null +++ b/htdocs/compta/bank/account.php3 @@ -0,0 +1,70 @@ + + * + * $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 + * 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. + * + */ + +require("./pre.inc.php3"); +require("./bank.lib.php3"); + +llxHeader(); +$db = new Db(); + + +print_titre ("Comptes bancaires"); + +print ""; +print ""; +print ""; +print ""; +print "\n"; + +$sql = "SELECT rowid, label,number,bank FROM llx_bank_account"; + +$result = $db->query($sql); +if ($result) { + $var=True; + $num = $db->num_rows(); + $i = 0; $total = 0; + + $sep = 0; + + while ($i < $num) { + $objp = $db->fetch_object( $i); + + + print ""; + + + $i++; + } + $db->free(); +} + + +$acc = new Account($db); + +print "
LabelBanqueNuméro
$objp->label$objp->bank$objp->number
"; + + + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/compta/bank/bank.class.php3 b/htdocs/compta/bank/bank.class.php3 new file mode 100644 index 00000000000..14addc8f1ee --- /dev/null +++ b/htdocs/compta/bank/bank.class.php3 @@ -0,0 +1,68 @@ + + * + * $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 + * 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. + * + */ + +class Account { + var $rowid; + var $bank; + var $label; + var $name; + + Function Account($DB, $rowid=0) { + global $config; + + $this->db = $DB; + $this->rowid = $rowid; + + return 1; + } + + Function fetch() { + + $sql = "SELECT s.idp, s.nom,".$this->db->pdate("s.datec"); + + $sql .= " AND s.idp = ".$this->id; + + + $result = $this->db->query($sql); + + if ($result) { + if ($this->db->num_rows()) { + $obj = $this->db->fetch_object($result , 0); + + $this->nom = $obj->nom; + } + $this->db->free(); + } + } + + Function create() { + $sql = "INSERT INTO llx_bank_account (label, bank, name) "; + $sql .= " VALUES ('$this->label', '$this->bank', '$this->name')"; + + $this->db->query($sql); + +} +/* + * $Id$ + * $Source$ + */ +?> diff --git a/htdocs/compta/bank/bilan.php3 b/htdocs/compta/bank/bilan.php3 new file mode 100644 index 00000000000..f85fda425fc --- /dev/null +++ b/htdocs/compta/bank/bilan.php3 @@ -0,0 +1,73 @@ + + * + * $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 + * 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. + * + */ + +require("./pre.inc.php3"); + +llxHeader(); +$db = new Db(); + +function valeur($sql) { + global $db; + if ( $db->query($sql) ) { + if ( $db->num_rows() ) { + $valeur = $db->result(0,0); + } + $db->free(); + } + return $valeur; +} + + +print_titre("Bilan"); + +print ""; +print ""; +print ""; +print "\n"; + +$var=!$var; +$sql = "SELECT sum(amount) FROM llx_paiement"; +$paiem = valeur($sql); +print ""; + +$var=!$var; +$sql = "SELECT sum(amount) FROM llx_bank WHERE amount > 0"; +$credits = valeur($sql); +print ""; + +$var=!$var; +$sql = "SELECT sum(amount) FROM llx_bank WHERE amount < 0"; +$debits = valeur($sql); +print ""; + +$var=!$var; +$sql = "SELECT sum(amount) FROM llx_bank "; +$solde = valeur($sql); +print ""; + + +print "
DescriptionMontantfrancs
Somme des paiements".price($paiem)."".francs($paiem)."
Somme des credits".price($credits)."".francs($credits)."
Somme des debits".price($debits)."".francs($debits)."
Solde compte".price($solde)."".francs($solde)."
"; + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/compta/bank/budget.php3 b/htdocs/compta/bank/budget.php3 new file mode 100644 index 00000000000..4e996aa46c1 --- /dev/null +++ b/htdocs/compta/bank/budget.php3 @@ -0,0 +1,140 @@ + + * + * $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 + * 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. + * + */ + +require("./pre.inc.php3"); + +llxHeader(); +$db = new Db(); + +/* + * + * + * TODO attention des sommes positives sont a consideres + * + * + * exemple remboursement de frais de gestion par la banque + * + * + * + * + */ + +if ($bid == 0) { + /* + * Liste + */ + print "Budgets"; + + print ""; + print ""; + echo ''; + print "\n"; + + $sql = "SELECT sum(d.amount) as somme, count(*) as nombre, c.label, c.rowid "; + $sql .= " FROM llx_bank_categ as c, llx_bank_class as l, llx_bank as d"; + $sql .= " WHERE d.rowid=l.lineid AND c.rowid = l.fk_categ GROUP BY c.label, c.rowid ORDER BY c.label"; + + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows(); + $i = 0; $total = 0; + + $var=True; + while ($i < $num) { + $objp = $db->fetch_object( $i); + $var=!$var; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + $i++; + $total = $total + abs($objp->somme); + } + $db->free(); + print ""; + print "\n"; + } else { + print $db->error(); + } + print "
DescriptionNbTotalMoyenne
rowid\">$objp->label$objp->nombre".price(abs($objp->somme))."".francs(abs($objp->somme))." FF".price(abs($objp->somme / $objp->nombre))."
Total".price($total)."
soit en francs".francs($total)."
"; + +} else { + /* + * Vue + */ + $sql = "SELECT label FROM llx_bank_categ WHERE rowid=$bid"; + if ( $db->query($sql) ) { + if ( $db->num_rows() ) { + $budget_name = $db->result(0,0); + } + $db->free(); + } + + print "Budget : $budget_name"; + + print ""; + print ""; + echo ''; + print "\n"; + + $sql = "SELECT d.amount, d.label, ".$db->pdate("d.dateo")." as do, d.rowid"; + $sql .= " FROM llx_bank_class as l, llx_bank as d"; + $sql .= " WHERE d.rowid=l.lineid AND l.fk_categ=$bid ORDER by d.dateo DESC"; + + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows(); + $i = 0; $total = 0; + + $var=True; + while ($i < $num) { + $objp = $db->fetch_object( $i); + $var=!$var; + print ""; + print "\n"; + + print ""; + print ""; + print ""; + + print ""; + $i++; + $total = $total + $objp->amount; + } + $db->free(); + print ""; + print "\n"; + } else { + print $db->error(); + } + print "
DateDescriptionMontant 
".strftime("%d %B %Y",$objp->do)."rowid\">$objp->label".price(abs($objp->amount))."".francs(abs($objp->amount))."
Total".price(abs($total))."euros
soit".francs(abs($total))."francs
"; + +} + + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/compta/bank/categ.php3 b/htdocs/compta/bank/categ.php3 new file mode 100644 index 00000000000..46217dbeb08 --- /dev/null +++ b/htdocs/compta/bank/categ.php3 @@ -0,0 +1,84 @@ + + * + * $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 + * 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. + * + */ + +require("./pre.inc.php3"); + +llxHeader(); +$db = new Db(); + + +if ($action == 'add') { + $author = $GLOBALS["REMOTE_USER"]; + + if ($credit > 0) { + $amount = $credit ; + } else { + $amount = - $debit ; + } + + $sql = "INSERT INTO llx_bank_categ (label) VALUES ('$label')"; + $result = $db->query($sql); + if (!$result) { + print $db->error(); + print "

$sql"; + } +} + +print "Categorie reload"; +print "

"; +print ""; +print ""; +print ""; +print ""; +print "\n"; + + +$sql = "SELECT rowid, label FROM llx_bank_categ ORDER BY label"; + +$result = $db->query($sql); +if ($result) { + $num = $db->num_rows(); + $i = 0; $total = 0; + + $var=True; + while ($i < $num) { + $objp = $db->fetch_object( $i); + $var=!$var; + print ""; + print ""; + print ""; + print ""; + $i++; + } + $db->free(); +} +print ""; +print ""; +print ""; +print "
NumDescription
$objp->rowid$objp->label
"; + + + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/compta/bank/config.php3 b/htdocs/compta/bank/config.php3 new file mode 100644 index 00000000000..a3b3758a342 --- /dev/null +++ b/htdocs/compta/bank/config.php3 @@ -0,0 +1,85 @@ + + * + * $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 + * 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. + * + */ + +require("./pre.inc.php3"); +require("./bank.lib.php3"); + +llxHeader(); +$db = new Db(); + +if ($action == 'add') { + $author = $GLOBALS["REMOTE_USER"]; + + $sql = "INSERT INTO llx_bank_account (label, number, bank) VALUES ('$label','$number','$bank')"; + $result = $db->query($sql); +} +if ($action == 'del') { + bank_delete_line($db, $rowid); +} + + +print "Configuration"; + +print ""; +print ""; +print ""; +print ""; +print "\n"; + +$sql = "SELECT rowid, label,number,bank from llx_bank_account"; + +$result = $db->query($sql); +if ($result) { + $var=True; + $num = $db->num_rows(); + $i = 0; $total = 0; + + $sep = 0; + + while ($i < $num) { + $objp = $db->fetch_object( $i); + + + print ""; + + + $i++; + } + $db->free(); +} +print "
idLabelDescriptionNumber
$objp->rowid$objp->label$objp->bank$objp->number
"; +echo '

'; +print "
"; +print ""; +print ""; +echo ''; +echo ''; +echo ''; +echo ''; + +print "
Label : Bank : Number : 
"; + + +$db->close(); + +llxFooter(strftime("%H:%M",time()). " - Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/compta/bank/functions.lib.php3 b/htdocs/compta/bank/functions.lib.php3 new file mode 100644 index 00000000000..6b6618697ab --- /dev/null +++ b/htdocs/compta/bank/functions.lib.php3 @@ -0,0 +1,485 @@ + + * + * $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 + * 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/ + */ + +function gljDbConnect() { + return pg_Connect($GLOBALS["DB_HOST"], + $GLOBALS["DB_PORT"], + $GLOBALS["DB_OPTIONS"], + $GLOBALS["DB_TTY"], + $GLOBALS["DB_NAME"]); +} + +function gljPrintSelect($db, $refid) { + $num = $db->num_rows(); + $i = 0; + while ($i < $num) { + $obj = $db->fetch_object( $i); + print "\n"; + $i++; + } +} +/* + * Copy company def from one base to another + */ + +function gljCopy_Soc($idsoc, $dbfrom, $dbto) { + global $dbhost, $dbport, $dboptions, $dbtty, $DB_LOGIN_NAME, $dbname, $DB_NAME; + + // Add login info into login table + + $connfrom = pg_Connect($dbhost, $dbport, $dboptions, $dbtty, $DB_NAME["$dbfrom"]); + $connto = pg_Connect($dbhost, $dbport, $dboptions, $dbtty, $DB_NAME["$dbto"]); + $connlogin = pg_Connect($DB_LOGIN_HOST, $DB_LOGIN_PORT , $dboptions, $dbtty ,$DB_LOGIN_NAME); + + $madate = time(); + + if ($connfrom) { + if ($connto) { + if ($connlogin) { + $sql = "SELECT nom, fk_effectif FROM societe WHERE id = '$idsoc'"; + $result = pg_Exec($connfrom, $sql); + if ( $result ) { + if (pg_NumRows($result) ) { + $obj = pg_Fetch_Object($result, 0); + + $sql = "INSERT INTO societe (id, nom, datec, fk_effectif) "; + $sql .= "VALUES ('$idsoc', '$obj->nom', $madate, $obj->fk_effectif)"; + + $result = pg_Exec($connto, $sql); + if ( $result ) { + $sql = "UPDATE login SET pays = pays || ':$dbto' WHERE id = '$idsoc'"; + $result = pg_Exec($connlogin, $sql); + if ( $result ) { + // ALL success + return 0; + } + } + } else { + // this login exists + return 2; + } + } + pg_close($connlogin); + } + pg_close($connto); + } + pg_close($connfrom); + } +} +/* + * Envoie le login lors de la premiere connexion au compte + */ +function gljMailLogin ($db, $address, $id, $dbname) { + + $sql = "SELECT login, clearpass FROM login where id='$id' "; + + if ($db->query($sql)) { + if ($db->num_rows() > 0) { + $obj = $db->fetch_object(0); + $db->free(); + + $subject = "Confirmation"; + $mess = "Vous venez de déposer votre CV sur http://".$GLOBALS["GLJ_NORMAL_HOST"]."\n"; + $mess .= "\n\n"; + $mess .= "login : $obj->login\n"; + $mess .= "pass : $obj->clearpass\n"; + $mess .= "\n-----------------------------\n"; + $mess .= "contact : " . $GLOBALS["WEBMASTER"]; + $mess .= "\n-----------------------------\n"; + + $return = mail("$address","$subject","$mess","From: " . $GLOBALS["WEBMASTER"]); + } + } +} +// +// +// +function gljFooter_Cursor ($file, $page, $limit, $i, $parm="") { + $page_prev = $page - 1; + $page_next = $page + 1; + + print "
"; + + if ( $page ) { + print "" . $GLOBALS["_PAGE_PREV"] . ""; + } + + print ""; + + if ( $i > ( $limit - 1 ) ) { + print "" . $GLOBALS["_PAGE_NEXT"] . ""; + } + + print "
\n"; +} +// +// +// +function gljMenu_PrestaLogged() { + print "
"; + print "Liste |\n"; + + print "
"; +} + + +function gljMenu_Stat() { + print "
"; + print "" . $GLOBALS["_STAT_HOME"] . " |\n"; + print "" . $GLOBALS["_STAT_CONTRAT"] . " |\n"; + print "" . $GLOBALS["_STAT_EFFECTIF"] . " |\n"; + print "" . $GLOBALS["_STAT_POSTE"] . " |\n"; + print "" . $GLOBALS["_STAT_REGION"] . " |\n"; + print "" . $GLOBALS["_STAT_LANG"] . " |\n"; + print "" . $GLOBALS["_STAT_SECTEUR"] . "\n"; + print "
"; +} +// +// +// +function gljMenu_Soc() { + print "
"; + print "" . $GLOBALS["_AFIND"] . " |\n"; + print "" . $GLOBALS["_BYDATE"] . " |\n"; + print "" . $GLOBALS["_BYPOSTE"] . " |\n"; + print "" . $GLOBALS["_BYREGION"] . " |\n"; + print "" . $GLOBALS["_BYSECTEUR"] . " |\n"; + print "" . $GLOBALS["_BYCOMPANY"] . "\n"; + print "
"; +} +/* + * + */ +function gljMenu_SocLogged() { + print "
"; + print "" . $GLOBALS["_COORDENT"] . " | "; + print "" . $GLOBALS["_DESC"] . " | "; + //print "" . $GLOBALS["_ENT"] . " | "; + print "" . $GLOBALS["_OFFRES"] . " | "; + print "" . $GLOBALS["_ABO"] . " | "; + print "" . $GLOBALS["_STAT"] . " | "; + print "" . $GLOBALS["_PREF"] . ""; + print "

"; +} +/* + * + */ +function gljMenu_SocSSII() { + print "

"; + print "Accueil SSII | "; + print "Ressources | "; + print "Prestations"; + print "

"; +} +/* + * + */ +function gljMenu_Cv() { + print "

"; + print "" . $GLOBALS["_AFIND"] . " |\n"; + print "" . $GLOBALS["_BYDATE"] . " |\n"; + print "" . $GLOBALS["_BYPOSTE"] . " |\n"; + print "" . $GLOBALS["_BYREGION"] . " |\n"; + print "" . $GLOBALS["_BYSECTEUR"] . " |\n"; + print "" . $GLOBALS["_BYEXPERT"] . "\n"; + print "
"; +} +/* + * + * Verif info + * + */ +function gljVerif_NewLogin($login, $pass, $pass2) { + if (! strlen($login) ) { + return 3; + exit; + } + if ( $pass <> $pass2 ) { + return 1; + exit; + } + if (! strlen($pass) ) { + return 5; + exit; + } + return 0; +} +// +// Create new candidat login +// +function gljCreate_Login_Cand($db, $login, $pass, $pass2) { + global $dbhost, $dbport, $dboptions, $dbtty, $DB_LOGIN_NAME, $dbname; + + // Check validity + $return = gljVerif_NewLogin($login, $pass, $pass2); + if ( $return ) { + return $return; + exit; + } + // Add login info into login table + + $madate = $db->idate(time()); + $passmd5 = md5($pass); + $token = uniqid("CAN"); + + $sql = "SELECT login FROM login WHERE login = '$login'"; + + if ( $db->query($sql) ) { + if (! $db->num_rows() ) { + $sql = "INSERT INTO login VALUES ('$token','$login', '$passmd5','$pass', $madate, 'c','" . $GLOBALS["PREFIX"] . "')"; + if ( $db->query($sql) ) { + // + // Create data base in candidat + // + + $sql = "INSERT INTO candidat (id, datec,datel, sent, fk_anexpe, reminder, intern, cjn) VALUES ('$token',$madate,$madate, -1, 0, 1, 1, 1)"; + if ( $db->query($sql) ) { + return 0; + } + } + } else { + // this login exists + return 2; + } + } +} +/* + * + * + * Create new company login + * + * + */ +Function gljCreateCompany($db, $company_name, $address, $cp, $ville, $fkpays, $phone, $fax, $url, + $fksecteur, $fkeffectif, $fktypent, $c_nom, $c_prenom, $c_phone, $c_mail, $siren, + $parentidp=0, $setid=0, &$numerror) { + /* + * Create a new company + * - insert data in table societe + * - return company's idp + */ + + // Check validity + $return = gljVerifCompany($company_name, $address, $cp, $ville, $fkpays, $phone, $fax, $url, + $fksecteur,$fkeffectif, $c_nom, $c_prenom, $c_phone, $c_mail, $numerror); + if ( $return ) { + $sql = "INSERT INTO societe (datec,nom,address,cp,ville,tel,fax,url,fk_secteur,fk_effectif,fk_typent"; + $sql .= ",c_nom,c_prenom,c_tel,c_mail,karma,view_res_coord,siren,parent"; + if ($setid > 0 ) { + $sql .= ",id"; + } + $sql .= ")"; + + $sql .= "VALUES (now(),'$company_name',$address,$cp,$ville,$phone,$fax,$url,$fksecteur,$fkeffectif,$fktypent"; + $sql .= ",$c_nom,$c_prenom,$c_phone,'$c_mail', 0, 0,'$siren',$parentidp"; + + if ($setid > 0 ) { + if ($setid == 2 ) { + $token = uniqid("-OC"); + } else { + $token = uniqid("SOC"); + } + $sql .= ",'$token'"; + } + $sql .= ");"; + + if ( $db->query($sql) ) { + $sql = "SELECT idp FROM societe WHERE id= '$token';"; + if ( $db->query($sql) ) { + if ( $db->num_rows() ) { + $obj = $db->fetch_object(0); + return $obj->idp; + $db->free(); + + $sql = "INSERT INTO socpeople (datec, name, firstname, fk_soc, phone, fax, email)"; + $sql .= "VALUES (now(),'$c_nom','$c_prenom', $obj->idp, $phone, $fax,$url, '$c_mail')"; + if ( $db->query($sql) ) { + + } + } + } else { + print $db->error(); + } + } else { + print $db->error(); + return 0; + } + return 1; + } else { + /* + * Verification Failed + */ + return 0; + } +} +/* + * + * + */ +Function gljVerifCompany(&$company_name, &$address, &$cp, &$ville, &$fkpays, &$phone, &$fax, &$url, &$fksecteur,&$fkeffectif, &$c_nom, &$c_prenom, &$c_phone, &$c_mail, &$numerror) { + $numerror = 0; + + if (!strlen(trim($company_name))) { $numerror = 4; } + if (!gljValidEmail($c_mail)) { $numerror = 8; } + if (!strlen(trim($c_mail))) { $numerror = 7; } + + if (strlen(trim($address))) { $address = "'$address'"; } else { $address = "NULL"; } + if (strlen(trim($cp))) { $cp = "'".trim($cp) ."'"; } else { $cp = "NULL"; } + if (strlen(trim($ville))) { $ville = "'".trim($ville)."'"; } else { $ville = "NULL"; } + if (strlen(trim($phone))) { $phone = "'".trim($phone)."'"; } else { $phone = "NULL"; } + if (strlen(trim($fax))) { $fax = "'".trim($fax) ."'"; } else { $fax = "NULL"; } + if (strlen(trim($url))) { $url = "'".trim($url) ."'"; } else { $url = "NULL"; } + if (strlen(trim($c_nom))) { $c_nom = "'".trim($c_nom)."'"; } else { $c_nom = "NULL"; } + if (strlen(trim($c_prenom))) { $c_prenom = "'$c_prenom'"; } else { $c_prenom = "NULL"; } + if (strlen(trim($c_phone))) { $c_phone = "'$c_phone'"; } else { $c_phone = "NULL"; } + + if ($numerror) { + return 0; + } else { + return 1; + } +} +function gljCreateCompanyMail($to, $subject, $message) { + $return = mail($to, $subject, $message, "From: " . $GLOBALS["WEBMASTER"]); +} +// +// +function gljValidEmail($email) { + if (eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@([0-9a-z][0-9a-z-]*[0-9a-z]\.)+[a-z]{2}[mtgvu]?$", $email) ) { + return 1; + } else { + return 0; + } +} +// +// Create new company login REPLACE by function gljCreate_Company +// +function gljCreate_Login_Soc($login, $pass, $pass2, $company_name) { + global $dbhost, $dbport, $dboptions, $dbtty, $DB_LOGIN_NAME, $dbname; + + // Check validity + $return = gljVerif_NewLogin($login, $pass, $pass2); + if ( $return ) { + return $return; + exit; + } + if (! strlen(trim($company_name))) { + return 4; + exit; + } + // Add login info into login table + $dbconn = pg_Connect("$dbhost","$dbport","$dboptions","$dbtty",$DB_LOGIN_NAME); + $dbconn2 = gljDbConnect(); + + $madate = time(); + $passmd5 = md5($pass); + $token = uniqid(""); + + if ($dbconn) { + if ($dbconn2) { + $sql = "SELECT login FROM login WHERE login = '$login'"; + + $result = pg_Exec($dbconn, $sql); + if ( $result ) { + if (! pg_NumRows($result) ) { + $sql = "SELECT nom FROM societe WHERE nom = '$company_name'"; + + $result = pg_Exec($dbconn2, $sql); + if ( $result ) { + if (! pg_NumRows($result) ) { + + $sql = "INSERT INTO login VALUES ('$token','$login', '$passmd5','$pass', $madate, 's','" . $GLOBALS["PREFIX"] . "')"; + $result = pg_Exec($dbconn, $sql); + if( $result ) { + $sql2 = "INSERT INTO societe (id, datec, nom, fk_effectif, tchoozeid, viewed, cjn, intern) VALUES ('$token', $madate, '$company_name',0,0,0, 1, 1)"; + + $result = pg_Exec($dbconn2, $sql2); + return 0; + } + } else { + return 6; + } + } + } else { + // this login exists + return 2; + } + } + } + } +} +// +// Ajoute un outil +// +function ins_outil ($db, $idp, $outil, $contrib, $niveau, $table, $champ, $fkanexpe=0) { + + $sql = "DELETE FROM $table WHERE $champ=$idp AND fk_outil=$outil;"; + if ( $db->query( $sql ) ) { + $sql = "INSERT INTO $table ($champ, fk_outil, fk_contrib, fk_niveau, fk_anexpe)"; + $sql .= " VALUES ($idp, $outil, $contrib, $niveau, $fkanexpe)" ; + + $result = $db->query( $sql ); + if (!$result) { + print "Erreur INSERT\n
$sql"; + } + } +} +// +// +// +function ins_lang ($db, $idp, $lang, $niveau, $table='lang', $champ='fk_cand') { + + $sql = "DELETE FROM $table WHERE $champ=$idp AND fk_lang=$lang;"; + if ( $db->query( $sql ) ) { + $sql = "INSERT INTO $table ($champ, fk_lang, fk_niv) VALUES ($idp, $lang, $niveau)" ; + + $result = $db->query($sql); + if (!$result) { + echo "Erreur INSERT\n$sql"; + } + } +} +// +// +// +function get_ofid_by_idp ($db, $ofidp) { + $sql = "SELECT id from OFFRE where idp = $ofidp"; + + $result = $db->query( $sql ); + + if (!$result) { + return 0; + } else { + if ($db->num_rows() > 0) { + $row = 0; + while($data = $db->fetch_object( $row)) { + $id = $data->id ; + } + return $id; + } + } +} +?> diff --git a/htdocs/compta/bank/ligne.php3 b/htdocs/compta/bank/ligne.php3 new file mode 100644 index 00000000000..10d91385092 --- /dev/null +++ b/htdocs/compta/bank/ligne.php3 @@ -0,0 +1,128 @@ +query($sql); + +} + +$sql = "SELECT rowid, label FROM llx_bank_categ;"; +$result = $db->query($sql); +if ($result) { + $var=True; + $num = $db->num_rows(); + $i = 0; + $options = ""; + while ($i < $num) { + $obj = $db->fetch_object($i); + $options .= "\n"; $i++; + } + $db->free(); +} + +print "Edition de la ligne"; +print ""; +print ""; +print ""; +print ""; +print ""; +print ""; +print ""; + +print "\n"; + +$sql = "SELECT b.rowid,".$db->pdate("b.dateo")." as do, b.amount, b.label, b.rappro, b.num_releve, b.author"; +$sql .= " FROM llx_bank as b WHERE rowid=$rowid"; +$sql .= " ORDER BY dateo ASC"; +$result = $db->query($sql); +if ($result) { + $var=True; + $num = $db->num_rows(); + $i = 0; $total = 0; + while ($i < $num) { + $objp = $db->fetch_object( $i); + $total = $total + $objp->amount; + + $var=!$var; + print ""; + print ""; + print ""; + print "rowid\">"; + + print "\n"; + print ""; + if ($objp->amount < 0) { + print "\n"; + } else { + print "\n"; + } + + print ""; + print ""; + + print ""; + print ""; + print ""; + + print ""; + $i++; + } + $db->free(); +} +print "
DateDescriptionDebitCreditReleveAuteur
".strftime("%d %b %Y",$objp->do)."$objp->label".price($objp->amount * -1)."  ".price($objp->amount)."num_releve&ve=1\">$objp->num_releve$objp->author
 "; + print " "; + print "
"; + +print "

Classé dans

"; + +print ""; +print ""; +print ""; +print "\n"; + +$sql = "SELECT c.label, c.rowid"; +$sql .= " FROM llx_bank_class as a, llx_bank_categ as c WHERE a.lineid=$rowid AND a.fk_categ = c.rowid "; +$sql .= " ORDER BY c.label"; +$result = $db->query($sql); +if ($result) { + $var=True; + $num = $db->num_rows(); + $i = 0; $total = 0; + while ($i < $num) { + $objp = $db->fetch_object( $i); + + $var=!$var; + print ""; + + print ""; + print ""; + print ""; + + $i++; + } + $db->free(); +} +print "
Description
$objp->labelrowid\">voir
"; + + + + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/compta/bank/pre.inc.php3 b/htdocs/compta/bank/pre.inc.php3 new file mode 100644 index 00000000000..6bf9fa2f662 --- /dev/null +++ b/htdocs/compta/bank/pre.inc.php3 @@ -0,0 +1,74 @@ + + * + * $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 + * 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. + * + */ + +require("../../main.inc.php3"); +require("./account.class.php3"); +function llxHeader($head = "") { + global $user, $conf; + + /* + * + * + */ + top_menu($head); + + $menu = new Menu(); + + $menu->add("account.php3","Comptes"); + + $db = new Db(); + $sql = "SELECT rowid, label FROM llx_bank_account"; + $result = $db->query($sql); + if ($result) { + + $num = $db->num_rows(); + $i = 0; + + while ($i < $num) { + $objp = $db->fetch_object($i); + $menu->add_submenu("index.php3?account=" . $objp->rowid, $objp->label); + + $i++; + } + } + $db->close; + + $menu->add("index.php3","Bank"); + + $menu->add_submenu("rappro.php3","Rappro"); + $menu->add_submenu("budget.php3","Budgets"); + $menu->add_submenu("bilan.php3","Bilan"); + $menu->add_submenu("virement.php3","Virement"); + + $menu->add_submenu("releve.php3","Relevés"); + $menu->add_submenu("config.php3","Config"); + + $menu->add("/compta/facture.php3","Factures"); + + $menu->add("/compta/ca.php3","Chiffres d'affaires"); + + left_menu($menu->liste); + +} + + +?> diff --git a/htdocs/compta/bank/rappro.php3 b/htdocs/compta/bank/rappro.php3 new file mode 100644 index 00000000000..ea81a76c559 --- /dev/null +++ b/htdocs/compta/bank/rappro.php3 @@ -0,0 +1,121 @@ + 0) { + $sql = "UPDATE llx_bank set rappro=$rappro, num_releve=$num_releve WHERE rowid=$rowid"; + $result = $db->query($sql); + if ($result) { + if ($cat1 && $rappro) { + $sql = "INSERT INTO llx_bank_class (lineid, fk_categ) VALUES ($rowid, $cat1)"; + $result = $db->query($sql); + } + } else { + print $db->error(); + print "

$sql"; + } + } +} +if ($action == 'del') { + $sql = "DELETE FROM llx_bank WHERE rowid=$rowid"; + $result = $db->query($sql); + if (!$result) { + print $db->error(); + print "

$sql"; + } +} +$sql = "SELECT rowid, label FROM llx_bank_categ ORDER BY label;"; +$result = $db->query($sql); +if ($result) { + $var=True; + $num = $db->num_rows(); + $i = 0; + $options = ""; + while ($i < $num) { + $obj = $db->fetch_object($i); + $options .= "\n"; $i++; + } + $db->free(); +} + +$sql = "SELECT max(num_releve) FROM llx_bank"; +if ( $db->query($sql) ) { + if ( $db->num_rows() ) { + $last_releve = $db->result(0, 0); + } + $db->free(); +} else { print $db->error(); } + +print "Rapprochement bancaire"; +print ""; +print ""; +print ""; +print ""; +print ""; +print ""; +print ""; +print "\n"; + +$sql = "SELECT b.rowid,".$db->pdate("b.dateo")." as do, b.amount, b.label, b.rappro, b.num_releve"; +$sql .= " FROM llx_bank as b WHERE rappro=0"; +$sql .= " ORDER BY dateo ASC"; +$result = $db->query($sql); +if ($result) { + $var=True; + $num = $db->num_rows(); + $i = 0; $total = 0; + while ($i < $num) { + $objp = $db->fetch_object( $i); + $total = $total + $objp->amount; + + $var=!$var; + print ""; + print ""; + print ""; + print "rowid\">"; + + print "\n"; + print ""; + if ($objp->amount < 0) { + print "\n"; + } else { + print "\n"; + } + + print ""; + print ""; + print ""; + + if ($objp->rappro) { + print ""; + } else { + print ""; + } + print ""; + print ""; + echo ''; + print ""; + $i++; + } + $db->free(); +} +print "
DateDescriptionDebitCreditReleveRappro
".strftime("%d %b %Y",$objp->do)."$objp->label".price($objp->amount * -1)."  ".price($objp->amount).""; + print "num_releve\">$objp->num_releverowid\">[Del]
 "; + print ""; + print "

"; + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/compta/bank/releve.php3 b/htdocs/compta/bank/releve.php3 new file mode 100644 index 00000000000..29969dbde55 --- /dev/null +++ b/htdocs/compta/bank/releve.php3 @@ -0,0 +1,162 @@ +Releves bancaires"; + + print ""; + print ""; + print ""; + + print "\n"; + + $sql = "SELECT distinct(b.num_releve) as numr"; + $sql .= " FROM llx_bank as b ORDER BY numr DESC"; + $result = $db->query($sql); + if ($result) { + $var=True; + $numrows = $db->num_rows(); + $i = 0; + + while ($i < $numrows) { + $objp = $db->fetch_object( $i); + $var=!$var; + print "\n"; + $i++; + } + } + print "
DateDescription
numr\">$objp->numr
"; + +} else { + if ($rel == 'prev') { + $sql = "SELECT distinct(num_releve) FROM llx_bank WHERE num_releve < $num ORDER BY num_releve DESC"; + $result = $db->query($sql); + if ($result) { + $var=True; + $numrows = $db->num_rows(); + $i = 0; + if ($numrows > 0) { + $row = $db->fetch_row(0); + $num = $row[0]; + } + } + } elseif ($rel == 'next') { + $sql = "SELECT distinct(num_releve) FROM llx_bank WHERE num_releve > $num ORDER BY num_releve ASC"; + $result = $db->query($sql); + if ($result) { + $var=True; + $numrows = $db->num_rows(); + $i = 0; + if ($numrows > 0) { + $row = $db->fetch_row(0); + $num = $row[0]; + } + } + } + + + print ""; + print "
Releve numéro $num<- prev"; + print " - next ->
"; + print "

"; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print "\n"; + + + $sql = "SELECT sum(amount) FROM llx_bank WHERE num_releve < $num"; + if ( $db->query($sql) ) { + $total = $db->result (0, 0); + $db->free(); + } + + + $sql = "SELECT b.rowid,".$db->pdate("b.dateo")." as do, b.amount, b.label, b.rappro, b.num_releve"; + $sql .= " FROM llx_bank as b WHERE num_releve=$num"; + $sql .= " ORDER BY dateo ASC"; + $result = $db->query($sql); + if ($result) { + $var=True; + $numrows = $db->num_rows(); + $i = 0; + print ""; + print "\n"; + while ($i < $numrows) { + $objp = $db->fetch_object( $i); + $total = $total + $objp->amount; + + $var=!$var; + print ""; + + print "\n"; + print ""; + + if ($objp->amount < 0) { + $totald = $totald + abs($objp->amount); + print "\n"; + } else { + $totalc = $totalc + abs($objp->amount); + print "\n"; + } + + print "\n"; + print "\n"; + + print ""; + + print ""; + $i++; + } + $db->free(); + } + print ""; + print "\n"; + print "
DateDescriptionDebitCreditSoldeFrancs
vue etendueTotal :".price($total)."".francs($total)."
".strftime("%d %b %Y",$objp->do)."$objp->label"; + + if ($ve) { + $dc = $db->clone(); + $sql = "SELECT label FROM llx_bank_categ as ct, llx_bank_class as cl WHERE ct.rowid=cl.fk_categ AND cl.lineid=$objp->rowid"; + $resc = $dc->query($sql); + if ($resc) { + $numc = $dc->num_rows(); + $ii = 0; + while ($ii < $numc) { + $objc = $dc->fetch_object($ii); + print "
$objc->label"; + $ii++; + } + } else { + print $dc->error(); + } + } + + print "
".price($objp->amount * -1)."  ".price($objp->amount)."".price($total)."".francs($objp->amount)."[rowid\">edit]
Total :".price($totald)."".price($totalc)." 
Solde :".price($total)."".francs($total)."
"; + + print "Edit Categories"; + print " Categories"; +} +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/compta/bank/virement.php3 b/htdocs/compta/bank/virement.php3 new file mode 100644 index 00000000000..577000d09c5 --- /dev/null +++ b/htdocs/compta/bank/virement.php3 @@ -0,0 +1,106 @@ + 0) { + $amount = $credit ; + } else { + $amount = - $debit ; + } + + if ($num_chq) { + $sql = "INSERT INTO llx_bank (datec, dateo, label, amount, author, num_chq,fk_account)"; + $sql .= " VALUES (now(), $dateo, '$label', $amount,'$author',$num_chq,$account)"; + } else { + $sql = "INSERT INTO llx_bank (datec, dateo, label, amount, author,fk_account)"; + $sql .= " VALUES (now(), $dateo, '$label', $amount,'$author',$account)"; + } + + $result = $db->query($sql); + if (!$result) { + print $db->error(); + print "

$sql"; + } +} +if ($action == 'del') { + bank_delete_line($db, $rowid); +} + +if ($vline) { + $viewline = $vline; +} else { + $viewline = 20; +} + +print "Virement - Reload -"; +print "Voir tout"; + +print "

"; + +print ""; + +print ""; +print ""; +print ""; + +print ""; +print ""; +print ""; +print ""; + + +print "
DeVersDateLibelleMontant
"; +print ""; + +print ""; +print "
Format : YYYYMMDD - 200108260000.00
"; + +print "Edit Categories"; +print " Budgets"; + +$db->close(); + +llxFooter(strftime("%H:%M",time()). " - Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/compta/casoc.php3 b/htdocs/compta/casoc.php3 index cfef43e9d3b..67e8c952976 100644 --- a/htdocs/compta/casoc.php3 +++ b/htdocs/compta/casoc.php3 @@ -25,84 +25,45 @@ llxHeader(); $db = new Db(); -if ($sortfield == "") { - $sortfield="lower(p.label)"; -} -if ($sortorder == "") { - $sortorder="ASC"; -} - -$yn["t"] = "oui"; -$yn["f"] = "non"; - -if ($page == -1) { $page = 0 ; } -$limit = 26; -$offset = $limit * $page ; -$pageprev = $page - 1; -$pagenext = $page + 1; - -function liste($db, $paye) { - global $bc, $year, $month, $socidp; - $sql = "SELECT s.nom, s.idp, sum(f.amount) as ca"; - $sql .= " FROM societe as s,llx_facture as f WHERE f.fk_soc = s.idp AND f.paye = $paye GROUP BY s.nom, s.idp"; - - if ($socidp) { - $sql .= " AND s.idp = $socidp"; - } - if ($month > 0) { - $sql .= " AND date_part('month', date(f.datef)) = $month"; - } - if ($year > 0) { - $sql .= " AND date_part('year', date(f.datef)) = $year"; - } - - $sql .= " ORDER BY f.datef DESC "; - - $result = $db->query($sql); - if ($result) { - $num = $db->num_rows(); - if ($num > 0) { - $i = 0; - print "

"; - print ""; - print ""; - print ""; - print ""; - print "\n"; - $var=True; - while ($i < $num) { - $objp = $db->fetch_object( $i); - $var=!$var; - print ""; - - print "\n"; - print "\n"; - - $total = $total + $objp->ca; - - print "\n"; - print "\n"; - $i++; - } - print ""; - print ""; - print ""; - print "
SociétéMontant Moyenne
idp\">$objp->nom".price($objp->ca)." ".price($total / ($i + 1))."
Total : ".price($total)."euros HTMoyenne : ".price($total/ $i)."
"; - } - $db->free(); - } else { - print $db->error(); - } -} - print_barre_liste("Chiffre d'affaire par société", $page, $PHP_SELF); -print "

"; -liste($db, 0); -print "

"; -liste($db, 1); +$sql = "SELECT s.nom, s.idp, sum(f.amount) as ca"; +$sql .= " FROM societe as s,llx_facture as f WHERE f.fk_soc = s.idp GROUP BY s.nom, s.idp ORDER BY ca DESC"; + +$result = $db->query($sql); +if ($result) { + $num = $db->num_rows(); + if ($num > 0) { + $i = 0; + print "

"; + print ""; + print ""; + print ""; + print "\n"; + $var=True; + while ($i < $num) { + $objp = $db->fetch_object( $i); + $var=!$var; + print ""; + + print "\n"; + print "\n"; + + $total = $total + $objp->ca; + print "\n"; + $i++; + } + print ""; + print ""; + print "
SociétéMontant 
idp\">$objp->nom".price($objp->ca)." 
Total : ".price($total)."euros HT
Moyenne : ".price($total/$i)."euros HT
"; + } + $db->free(); +} else { + print $db->error(); +} + $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); diff --git a/htdocs/compta/facture.php3 b/htdocs/compta/facture.php3 index 4f499b03d16..87fcc2bbce6 100644 --- a/htdocs/compta/facture.php3 +++ b/htdocs/compta/facture.php3 @@ -22,15 +22,9 @@ require("./pre.inc.php3"); llxHeader(); -$_MONNAIE = $GLOBALS["_MONNAIE"]; -$db = new Db(); -if ($sortorder == "") { - $sortfield="lower(s.nom)"; - $sortorder="ASC"; -} -$yn["1"] = "oui"; -$yn["0"] = "non"; +$db = new Db(); + if ($action == 'valid') { $sql = "UPDATE llx_facture set fk_statut = 1 WHERE rowid = $facid ;"; @@ -56,252 +50,405 @@ if ($action == 'delete') { } -if ($facid > 0) { - $sql = "SELECT s.nom as socnom, s.idp as socidp, f.facnumber, f.amount, f.total, ".$db->pdate("f.datef")." as df, f.paye, f.fk_statut as statut, f.author, f.note"; - $sql .= " FROM societe as s,llx_facture as f WHERE f.fk_soc = s.idp AND f.rowid = $facid"; +if ($action == 'add') { + $datefacture = $db->idate(mktime(12, 0 , 0, $pmonth, $pday, $pyear)); + + $sql = "INSERT INTO llx_facture (facnumber, fk_soc, datec, datef, note, amount, remise, tva, total, author) "; + $sql .= " VALUES ('$facnumber', $socid, now(), $datefacture,'$note', $amount, $remise, $tva, $total, '$author');"; + $result = $db->query($sql); - $result = $db->query( $sql); - if ($result) { + $sql = "SELECT rowid, facnumber FROM llx_facture WHERE facnumber='$facnumber';"; + $result = $db->query($sql); + if ($result) { + $objfac = $db->fetch_object( 0); + $facid = $objfac->rowid; + $facnumber = $objfac->facnumber; + $action = ''; + + $sql = "INSERT INTO llx_fa_pr (fk_facture,fk_propal) VALUES ($facid, $propalid);"; + $result = $db->query($sql); + + + /* + * + * Génération du PDF + * + */ + + // print "


Génération du PDF

"; + + // $command = "export DBI_DSN=\"".$GLOBALS["DBI"]."\" "; + // $command .= " ; ../../scripts/facture-tex.pl --facture=$facid --pdf --ps" ; + + // $output = system($command); + // print "

command : $command
"; + + } + } else { + print "

Erreur : la facture n'a pas été créée, vérifier le numéro !"; + print "

Retour à la propal"; + } + $facid = $facid; + $action = ''; + +} +/* + * + * Mode creation + * + * + * + */ + +if ($action == 'create') { + print_titre("Emettre une facture"); + + + $sql = "SELECT s.nom, s.prefix_comm, s.idp, p.price, p.remise, p.tva, p.total, p.ref, ".$db->pdate("p.datep")." as dp, c.id as statut, c.label as lst"; + $sql .= " FROM societe as s, llx_propal as p, c_propalst as c WHERE p.fk_soc = s.idp AND p.fk_statut = c.id"; + + $sql .= " AND p.rowid = $propalid"; + + if ( $db->query($sql) ) { $num = $db->num_rows(); if ($num) { - $obj = $db->fetch_object( $i); + $obj = $db->fetch_object( 0); + + $numfa = "F-" . $obj->prefix_comm . "-" . strftime("%y%m%d", time()); + + + print "

"; + print "price - $obj->remise)."\">"; + print "total\">"; + print ''; + print ""; + print ""; + + + print ""; + print ""; + print ""; + print ""; + + print "remise\">"; + print "tva\">"; + + print ""; + print ""; + print "idp\">"; + + $strmonth[1] = "Janvier"; $strmonth[2] = "Février"; $strmonth[3] = "Mars"; $strmonth[4] = "Avril"; + $strmonth[5] = "Mai"; $strmonth[6] = "Juin"; $strmonth[7] = "Juillet"; $strmonth[8] = "Août"; + $strmonth[9] = "Septembre"; $strmonth[10] = "Octobre"; + $strmonth[11] = "Novembre"; $strmonth[12] = "Décembre"; + + print ""; + $author = $GLOBALS["REMOTE_USER"]; + print ""; + + print ""; + print ""; + print ""; + print ""; + print "
Société :$obj->nomCommentaires :
"; + print "
Propal :$obj->ref
Montant HT :".price($obj->price - $obj->remise)."
TVA 19.6% :".price($obj->tva)."
Total TTC :".price($obj->total)."
Date :"; + $cday = date("d", time()); + print ""; + $cmonth = date("n", time()); + print ""; + + print "
Auteur :$author
Numéro :
"; + } - $db->free(); - } else { - print $db->error(); - } - - print ""; - print ""; - print ''; - print "\n"; - print ""; - print ""; - print ""; - print "
Facture : '.$obj->facnumber.'
socidp\">Autres factures de $obj->socnom
"; - /* - * Facture - */ - print ""; - print ""; - - print "\n"; - print ""; - print ""; - print ""; - - print ""; - print ""; - print ""; - - print ""; - print "
Sociétésocidp\">$obj->socnom
date".strftime("%A %d %B %Y",$obj->df)."
Auteur$obj->author
Statut$obj->statut
Paye".$yn[$obj->paye]."
Montant".price($obj->amount)."euros HT
TVA".tva($obj->amount)."euros
Total".price($obj->total)."euros TTC
"; - - print "
"; - - $_MONNAIE="euros"; - - /* - * Paiements - */ - $sql = "SELECT ".$db->pdate("datep")." as dp, p.amount, c.libelle as paiement_type, p.num_paiement, p.rowid"; - $sql .= " FROM llx_paiement as p, c_paiement as c WHERE p.fk_facture = $facid AND p.fk_paiement = c.id"; - - $result = $db->query($sql); - if ($result) { - $num = $db->num_rows(); - $i = 0; $total = 0; - print "

Paiements"; - echo ''; - print ""; - print ""; - print ""; - print ""; - print "\n"; - - $var=True; - while ($i < $num) { - $objp = $db->fetch_object( $i); - $var=!$var; - print ""; - print "\n"; - print "\n"; - print "\n"; - print ""; - $total = $total + $objp->amount; - $i++; - } - print "\n"; - print "\n"; - - $resteapayer = $obj->total - $total; - - print ""; - print "\n"; - - print "
DateTypeMontant 
".strftime("%d %B %Y",$objp->dp)."$objp->paiement_type $objp->num_paiement".price($objp->amount)."$_MONNAIE
Total :".price($total)."$_MONNAIE
Facturé :".price($obj->total)."$_MONNAIE
Reste a payer :".price($resteapayer)."$_MONNAIE
"; - $db->free(); } else { print $db->error(); } - print "

Note : ".nl2br($obj->note)."
"; - - print "

"; - - if ($obj->statut == 0) { - print ""; - } else { - print ""; - } - if ($obj->statut == 1 && $resteapayer > 0) { - print ""; - } else { - print ""; - } - if ($obj->statut == 1 && abs($resteapayer == 0) && $obj->paye == 0) { - print ""; - } else { - print ""; - } - if ($obj->statut == 0) { - print ""; - } else { - print ""; - } - print "
[Supprimer]-[Emettre un paiement]-[Classer 'Payée']-[Valider]Générer la facture

"; - - /* - * Documents générés - * - */ - print "


"; - print "
"; - print "Documents générés
"; - print ""; - - $file = $GLOBALS["GLJ_ROOT"] . "/www-sys/doc/facture/$obj->facnumber/$obj->facnumber.pdf"; - if (file_exists($file)) { - print ""; - } - $file = $GLOBALS["GLJ_ROOT"] . "/www-sys/doc/facture/$obj->facnumber/$obj->facnumber.ps"; - if (file_exists($file)) { - print ""; - print ""; - } - print ""; - - print "
Propale PDFfacnumber/$obj->facnumber.pdf\">$obj->facnumber.pdf
Propale Postscriptfacnumber/$obj->facnumber.ps\">$obj->facnumber.ps
(facnumber/\">liste...)
\n
"; - - /* - * Generation de la facture - * - */ - if ($action == 'pdf') { - print "
Génération de la facture
"; - $command = "export DBI_DSN=\"dbi:mysql:dbname=lolixfr\" "; - $command .= " ; ../../scripts/facture-tex.pl --html -vv --facture=$facid --pdf --gljroot=" . $GLOBALS["GLJ_ROOT"] ; - - $output = system($command); - print "

command :
$command
"; - print "

output :
$output
"; - } - - - /* - * Propales - */ - - $sql = "SELECT ".$db->pdate("p.datep")." as dp, p.price, p.ref, p.rowid as propalid"; - $sql .= " FROM llx_propal as p, llx_fa_pr as fp WHERE fp.fk_propal = p.rowid AND fp.fk_facture = $facid"; - - $result = $db->query($sql); - if ($result) { - $num = $db->num_rows(); - $i = 0; $total = 0; - print "

Proposition(s) commerciale(s) associée(s)"; - print ''; - print ""; - print ""; - print ""; - print ""; - print "\n"; - - $var=True; - while ($i < $num) { - $objp = $db->fetch_object( $i); - $var=!$var; - print ""; - print "\n"; - print "\n"; - print ''; - print ""; - $total = $total + $objp->price; - $i++; - } - print "\n"; - print "
NumDatePrix
propalid\">$objp->ref".strftime("%d %B %Y",$objp->dp)."'.price($objp->price).'
Total : ".price($total)." $_MONNAIE HT
"; - } else { - print $db->error(); - } } else { - /* - * Liste - * - */ - function liste($db, $paye) { - global $bc, $year, $month; - $sql = "SELECT s.nom, s.idp, f.facnumber, f.amount,".$db->pdate("f.datef")." as df, f.paye, f.rowid as facid "; - $sql .= " FROM societe as s,llx_facture as f WHERE f.fk_soc = s.idp AND f.paye = $paye"; + if ($facid > 0) { + + $sql = "SELECT s.nom as socnom, s.idp as socidp, f.facnumber, f.amount, f.total, ".$db->pdate("f.datef")." as df, f.paye, f.fk_statut as statut, f.author, f.note"; + $sql .= " FROM societe as s,llx_facture as f WHERE f.fk_soc = s.idp AND f.rowid = $facid"; + + $result = $db->query( $sql); + + if ($result) { + $num = $db->num_rows(); + if ($num) { + $obj = $db->fetch_object( $i); + } + $db->free(); + } else { + print $db->error(); + } + + print ""; + print ""; + print ''; + print "\n"; + print ""; + print ""; + print ""; + print "
Facture : '.$obj->facnumber.'
socidp\">Autres factures de $obj->socnom
"; + /* + * Facture + */ + print ""; + print ""; + + print "\n"; + print ""; + print ""; + print ""; + + print ""; + print ""; + print ""; + + print ""; + print "
Sociétésocidp\">$obj->socnom
date".strftime("%A %d %B %Y",$obj->df)."
Auteur$obj->author
Statut$obj->statut
Paye".$yn[$obj->paye]."
Montant".price($obj->amount)."euros HT
TVA".tva($obj->amount)."euros
Total".price($obj->total)."euros TTC
"; + + print "
"; + + $_MONNAIE="euros"; + + /* + * Paiements + */ + $sql = "SELECT ".$db->pdate("datep")." as dp, p.amount, c.libelle as paiement_type, p.num_paiement, p.rowid"; + $sql .= " FROM llx_paiement as p, c_paiement as c WHERE p.fk_facture = $facid AND p.fk_paiement = c.id"; + + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows(); + $i = 0; $total = 0; + print "

Paiements"; + echo ''; + print ""; + print ""; + print ""; + print ""; + print "\n"; + + $var=True; + while ($i < $num) { + $objp = $db->fetch_object( $i); + $var=!$var; + print ""; + print "\n"; + print "\n"; + print "\n"; + print ""; + $total = $total + $objp->amount; + $i++; + } + print "\n"; + print "\n"; + + $resteapayer = $obj->total - $total; + + print ""; + print "\n"; + + print "
DateTypeMontant 
".strftime("%d %B %Y",$objp->dp)."$objp->paiement_type $objp->num_paiement".price($objp->amount)."$_MONNAIE
Total :".price($total)."$_MONNAIE
Facturé :".price($obj->total)."$_MONNAIE
Reste a payer :".price($resteapayer)."$_MONNAIE
"; + $db->free(); + } else { + print $db->error(); + } + + print "

Note : ".nl2br($obj->note)."
"; + + print "

"; + + if ($obj->statut == 0) { + print ""; + } else { + print ""; + } + if ($obj->statut == 1 && $resteapayer > 0) { + print ""; + } else { + print ""; + } + if ($obj->statut == 1 && abs($resteapayer == 0) && $obj->paye == 0) { + print ""; + } else { + print ""; + } + if ($obj->statut == 0) { + print ""; + } else { + print ""; + } + print "
[Supprimer]-[Emettre un paiement]-[Classer 'Payée']-[Valider]Générer la facture

"; + + /* + * Documents générés + * + */ + print "


"; + print "
"; + print "Documents générés
"; + print ""; + + $file = $GLOBALS["GLJ_ROOT"] . "/www-sys/doc/facture/$obj->facnumber/$obj->facnumber.pdf"; + if (file_exists($file)) { + print ""; + } + $file = $GLOBALS["GLJ_ROOT"] . "/www-sys/doc/facture/$obj->facnumber/$obj->facnumber.ps"; + if (file_exists($file)) { + print ""; + print ""; + } + print ""; + + print "
Propale PDFfacnumber/$obj->facnumber.pdf\">$obj->facnumber.pdf
Propale Postscriptfacnumber/$obj->facnumber.ps\">$obj->facnumber.ps
(facnumber/\">liste...)
\n
"; + + /* + * Generation de la facture + * + */ + if ($action == 'pdf') { + print "
Génération de la facture
"; + $command = "export DBI_DSN=\"dbi:mysql:dbname=lolixfr\" "; + $command .= " ; ../../scripts/facture-tex.pl --html -vv --facture=$facid --pdf --gljroot=" . $GLOBALS["GLJ_ROOT"] ; + + $output = system($command); + print "

command :
$command
"; + print "

output :
$output
"; + } + + + /* + * Propales + */ + + $sql = "SELECT ".$db->pdate("p.datep")." as dp, p.price, p.ref, p.rowid as propalid"; + $sql .= " FROM llx_propal as p, llx_fa_pr as fp WHERE fp.fk_propal = p.rowid AND fp.fk_facture = $facid"; + + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows(); + $i = 0; $total = 0; + print "

Proposition(s) commerciale(s) associée(s)"; + print ''; + print ""; + print ""; + print ""; + print ""; + print "\n"; + + $var=True; + while ($i < $num) { + $objp = $db->fetch_object( $i); + $var=!$var; + print ""; + print "\n"; + print "\n"; + print ''; + print ""; + $total = $total + $objp->price; + $i++; + } + print "\n"; + print "
NumDatePrix
propalid\">$objp->ref".strftime("%d %B %Y",$objp->dp)."'.price($objp->price).'
Total : ".price($total)." $_MONNAIE HT
"; + } else { + print $db->error(); + } + + } else { + /* + * Liste + * + */ + print_barre_liste("Factures",$page,$PHP_SELF); + + $sql = "SELECT s.nom,s.idp,f.facnumber,f.amount,".$db->pdate("f.datef")." as df,f.paye,f.rowid as facid"; + $sql .= " FROM societe as s,llx_facture as f WHERE f.fk_soc = s.idp"; if ($socidp) { $sql .= " AND s.idp = $socidp"; } - + if ($month > 0) { - $sql .= " AND date_part('month', date(f.datef)) = $month"; + $sql .= " AND date_format(f.datef, '%m') = $month"; } if ($year > 0) { $sql .= " AND date_format(f.datef, '%Y') = $year"; } - - $sql .= " ORDER BY f.datef DESC "; - + + $sql .= " ORDER BY f.fk_statut, f.paye, f.datef DESC "; + $result = $db->query($sql); if ($result) { $num = $db->num_rows(); + + $i = 0; + print ""; + print ''; + print ""; + print ""; + print "\n"; + if ($num > 0) { - $i = 0; - print '

Numéro"; + print_liste_field_titre("Société",$PHP_SELF,"s.nom"); + print "DateMontantPayé
'; - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - print "\n"; $var=True; while ($i < $num) { $objp = $db->fetch_object( $i); $var=!$var; + + if ($objp->paye && !$sep) { + print ""; + print ""; + + print ''; + print ""; + print "\n"; + $sep = 1 ; $j = 0; + $subtotal = 0; + } + print ""; - print "\n"; - print "\n"; - - print "\n"; - + print "\n"; + if ($objp->df > 0 ) { print "\n"; } - - print ''; - + + print "\n"; + $yn[1] = "oui"; $yn[0] = "non"; - - $total = $total + $objp->amount; + + $total = $total + $objp->amount; + $subtotal = $subtotal + $objp->amount; print "\n"; - print "\n"; + print "\n"; $i++; + $j++; + } - print ""; - print ""; - print ""; - print "
[Tous]SocieteNumDateMontantPayéMoyenne
"; + print " Sous Total : ".price($total)."euros HT
Numéro"; + print_liste_field_titre("Société",$PHP_SELF,"s.nom"); + print "DateMontantPayé
[idp\">Filtre]idp\">$objp->nomfacid\">$objp->facnumberidp\">$objp->nom"; $y = strftime("%Y",$objp->df); $m = strftime("%m",$objp->df); - + print strftime("%d",$objp->df)."\n"; print " "; print strftime("%B",$objp->df)."\n"; @@ -310,32 +457,36 @@ if ($facid > 0) { } else { print "!!!'.price($objp->amount).'".price($objp->amount)."".$yn[$objp->paye]."".round($total / ($i + 1))."
$i facturesTotal : ".round($total * 6.55957)." FFTotal : $total$_MONNAIE HTMoyenne : ".round($total/ $i)."
"; } + if ($i == 0) { $i=1; } if ($j == 0) { $j=1; } + print "$j factures "; + print "Sous Total : ".price($subtotal)."euros HT"; + + print "$i factures "; + print "Total : ".price($total)."euros HT"; + + print ""; $db->free(); } else { print $db->error(); } + } - print "

"; - liste($db, 0); - print "

"; - liste($db, 1); } diff --git a/htdocs/compta/fiche.php3 b/htdocs/compta/fiche.php3 index a0bb8d60db3..74124e1304a 100644 --- a/htdocs/compta/fiche.php3 +++ b/htdocs/compta/fiche.php3 @@ -22,8 +22,8 @@ require("./pre.inc.php3"); require("../contact.class.php3"); require("../lib/webcal.class.php3"); -require("cactioncomm.class.php3"); -require("actioncomm.class.php3"); +require("../cactioncomm.class.php3"); +require("../actioncomm.class.php3"); llxHeader(); @@ -179,9 +179,7 @@ if ($socid > 0) { print "\n"; print "'; - + /* + * + */ + print ""; + $file = $conf->propal->outputdir. "/$obj->ref/$obj->ref.pdf"; + if (file_exists($file)) { + print ''; + } + print ''; /* * */ @@ -180,42 +188,11 @@ if ($propalid) { } - print "
"; print ""; - - print ""; - print ""; + print ""; print ""; print ""; @@ -204,52 +202,21 @@ if ($socid > 0) { print "\n"; print ''; + +print '
Type $objsoc->typentEffectif$objsoc->effectif
Tel $objsoc->tel fax$objsoc->fax 
Tel $objsoc->tel Fax$objsoc->fax 
Ville".nl2br($objsoc->address)."
$objsoc->cp $objsoc->ville
sirensiren\">$objsoc->siren '; - /* - * - * Propales - * - */ - $var=!$var; - print ""; - $sql = "SELECT s.nom, s.idp, p.rowid as propalid, p.price, p.ref, p.remise, ".$db->pdate("p.datep")." as dp, c.label as statut, c.id as statutid"; - $sql .= " FROM societe as s, llx_propal as p, c_propalst as c WHERE p.fk_soc = s.idp AND p.fk_statut = c.id"; - $sql .= " AND s.idp = $objsoc->idp ORDER BY p.datep DESC"; - - if ( $db->query($sql) ) { - $num = $db->num_rows(); - if ($num >0 ) { - print ""; - } - $i = 0; $now = time(); $lim = 3600 * 24 * 15 ; - while ($i < $num && $i < 2) { - $objp = $db->fetch_object( $i); - $var=!$var; - print ""; - print "\n"; - print "\n"; - print "\n"; - $i++; - } - $db->free(); - } /* * Factures */ - $var=!$var; + print "
idp\">liste des propales ($num)
propalid\">$objp->ref\n"; - if ( ($now - $objp->dp) > $lim && $objp->statutid == 1 ) { - print " > 15 jours"; - } - print "".strftime("%d %B %Y",$objp->dp)."".price($objp->price - $objp->remise)."$objp->statut
"; + $var=!$var; $sql = "SELECT s.nom, s.idp, f.facnumber, f.amount, ".$db->pdate("f.datef")." as df, f.paye, f.rowid as facid "; $sql .= " FROM societe as s,llx_facture as f WHERE f.fk_soc = s.idp AND s.idp = $objsoc->idp ORDER BY f.datef DESC"; if ( $db->query($sql) ) { $num = $db->num_rows(); $i = 0; if ($num > 0) { print ""; - print ""; + print ""; } - while ($i < $num && $i < 2) { + while ($i < $num && $i < 5) { $objp = $db->fetch_object( $i); $var=!$var; print ""; diff --git a/htdocs/compta/index.php3 b/htdocs/compta/index.php3 index 2122460ca0b..884a4db8f65 100644 --- a/htdocs/compta/index.php3 +++ b/htdocs/compta/index.php3 @@ -23,129 +23,138 @@ require("./pre.inc.php3"); llxHeader(); - $db = new Db(); -if ($sortfield == "") { - $sortfield="lower(p.label)"; + +function valeur($sql) { + global $db; + if ( $db->query($sql) ) { + if ( $db->num_rows() ) { + $valeur = $db->result(0,0); + } + $db->free(); + } + return $valeur; } -if ($sortorder == "") { - $sortorder="ASC"; +/* + * + */ +$db = new Db(); + + +if ($action == 'add_bookmark') { + $sql = "INSERT INTO llx_bookmark (fk_soc, dateb, fk_user) VALUES ($socidp, now(),".$user->id.");"; + if (! $db->query($sql) ) { + print $db->error(); + } } -$yn["t"] = "oui"; -$yn["f"] = "non"; - -if ($page == -1) { $page = 0 ; } -$limit = $conf->limit_liste; -$offset = $limit * $page ; -$pageprev = $page - 1; -$pagenext = $page + 1; - -print_barre_liste("Factures",$page,$PHP_SELF); - -$sep = 0; -$sept = 0; - -$sql = "SELECT s.nom,s.idp,f.facnumber,f.amount,".$db->pdate("f.datef")." as df,f.paye,f.rowid as facid"; -$sql .= " FROM societe as s,llx_facture as f WHERE f.fk_soc = s.idp"; - -if ($socidp) { - $sql .= " AND s.idp = $socidp"; +if ($action == 'del_bookmark') { + $sql = "DELETE FROM llx_bookmark WHERE rowid=$bid"; + $result = $db->query($sql); } - -if ($month > 0) { - $sql .= " AND date_part('month', date(f.datef)) = $month"; + +print_titre("Espace compta"); + +print '
idp\">liste des factures ($num)
idp\">liste des factures ($num)
'; + +print '"; - print ""; - print "
'; + + +print ''; +print ""; +print ""; +print "\n"; + +$sql = "SELECT count(*) FROM llx_propal WHERE fk_statut = 2"; +if (valeur($sql)) { + $var=!$var; + print ""; } -if ($year > 0) { - $sql .= " AND date_part('year', date(f.datef)) = $year"; + +print "
Propositions commerciales
A facturer".valeur($sql)."

"; + + +print ''; +print ""; +print ""; +print "\n"; + +$sql = "SELECT count(*) FROM llx_facture WHERE paye = 0"; +if (valeur($sql)) { + $var=!$var; + print ""; } - -$sql .= " ORDER BY f.fk_statut, f.paye, f.datef DESC "; - -$result = $db->query($sql); -if ($result) { + +print "
Factures
Non payées".valeur($sql)."

"; + + +/* + * + * + */ + +$sql = "SELECT s.idp, s.nom,b.rowid as bid"; +$sql .= " FROM societe as s, llx_bookmark as b"; +$sql .= " WHERE b.fk_soc = s.idp AND b.fk_user = ".$user->id; +$sql .= " ORDER BY lower(s.nom) ASC"; + +if ( $db->query($sql) ) { $num = $db->num_rows(); - $i = 0; + print ""; - print ''; - print ""; - print ""; - print ""; + print ""; + print ""; print "\n"; - if ($num > 0) { - $var=True; - while ($i < $num) { - $objp = $db->fetch_object( $i); - $var=!$var; - - if ($objp->paye && !$sep) { - print ""; - print ""; - - print ''; - print ""; - print ""; - print "\n"; - $sep = 1 ; $j = 0; - $subtotal = 0; - } - - print ""; - print "\n"; - print "\n"; - print "\n"; - - if ($objp->df > 0 ) { - print "\n"; - } else { - print "\n"; - } - - print "\n"; - - $yn[1] = "oui"; - $yn[0] = "non"; - - $total = $total + $objp->amount; - $subtotal = $subtotal + $objp->amount; - print "\n"; - - print "\n"; - $i++; - $j++; - - } + while ($i < $num) { + $obj = $db->fetch_object( $i); + $var = !$var; + print ""; + print ''; + print ''; + print ''; + $i++; } - if ($i == 0) { $i=1; } if ($j == 0) { $j=1; } - print ""; - print ""; + print '
[Tous]Numéro"; - print_liste_field_titre("Société",$PHP_SELF,"s.nom"); - print "DateMontantPayé
Bookmark
$i factures"; - print " Sous Total : ".price($total)."euros HT
[Tous]Numéro"; - print_liste_field_titre("Société",$PHP_SELF,"s.nom"); - print "DateMontantPayé
[idp\">Filtre]facid\">$objp->facnumberidp\">$objp->nom"; - $y = strftime("%Y",$objp->df); - $m = strftime("%m",$objp->df); - - print strftime("%d",$objp->df)."\n"; - print " "; - print strftime("%B",$objp->df)."\n"; - print " "; - print strftime("%Y",$objp->df)."!!!".price($objp->amount)."".$yn[$objp->paye]."
'.$obj->nom.''; + print '
$j factures Sous Total : ".price($subtotal)."euros HT
'; +} +/* + * + * + * + */ +print '
'; - print "
$i factures Total : ".price($total)."euros HT
"; +$result = 0; +if ( $result ) { + + print ''; + print ""; + print ""; + print "\n"; + + $i = 0; + while ($i < $db->num_rows() ) { + $obj = $db->fetch_object($i); + $var=!$var; + + print ""; + $i++; + } $db->free(); + print "
Actions à faire
".strftime("%d %b %Y",$obj->da)."$obj->libelle $obj->label

"; } else { print $db->error(); } +print '
'; $db->close(); + llxFooter("Dernière modification $Date$ révision $Revision$"); ?> diff --git a/htdocs/compta/propal.php3 b/htdocs/compta/propal.php3 index 1bc73161d37..9cd918fc157 100644 --- a/htdocs/compta/propal.php3 +++ b/htdocs/compta/propal.php3 @@ -25,9 +25,9 @@ require("../lib/CMailFile.class.php3"); /* * Modules optionnels */ -require("projet/project.class.php3"); -require("./propal.class.php3"); -require("./actioncomm.class.php3"); +require("../project.class.php3"); +require("../propal.class.php3"); +require("../actioncomm.class.php3"); /* * */ @@ -155,7 +155,15 @@ if ($propalid) { $author = new User($db, $obj->fk_user_author); $author->fetch(''); print $author->fullname.'
PDF'.$obj->ref.'.pdf
"; - /* - * Produits - */ - $sql = "SELECT p.label as product, p.ref, pt.price, pt.qty"; - $sql .= " FROM llx_propaldet as pt, llx_product as p WHERE pt.fk_product = p.rowid AND pt.fk_propal = $propalid"; - - $result = $db->query($sql); - if ($result) { - $num = $db->num_rows(); - $i = 0; $total = 0; - print "

Produits"; - print ""; - print ""; - print ""; - print "\n"; - - $var=True; - while ($i < $num) { - $objp = $db->fetch_object( $i); - $var=!$var; - print ""; - print "\n"; - print "\n"; - print "\n"; - print ""; - $total = $total + $objp->price; - $i++; - } - //print "\n"; - print "
RéfProduitPrixQté.
[$objp->ref]$objp->product".price($objp->price)."".$objp->qty."
Total : ".price($total)."Euros HT
"; - } + print ""; /* * */ - print ""; - } else { + } elseif ($obj->statut == 2) { + print ""; + } else { print ""; } print "
"; + print ""; /* * Factures associees */ @@ -286,160 +263,16 @@ if ($propalid) { } if ($obj->statut == 0) { print "[Valider][Facturée]-
"; /* * */ - if ($action == 'fax') { - print "


Génération du fax
"; - $command = "export DBI_DSN=\"dbi:mysql:dbname=lolixfr:host=espy:user=rodo\" "; - $command .= " ; ../../scripts/propal-tex.pl --propal=$propalid --pdf --gljroot=" . $GLOBALS["GLJ_ROOT"] ; - //$command .= " ; ../../scripts/fax-tex.pl --propal=$propalid --gljroot=" . $GLOBALS["GLJ_ROOT"] ; - - print "

Resultat :

"; - - $output = system($command); - print "

command : $command
"; - } - /* - * Send - * - */ - if ($action == 'send') { - $file = $GLOBALS["GLJ_ROOT"] . "/www-sys/doc/propal/$obj->ref/$obj->ref.pdf"; - if (file_exists($file)) { - - $subject = "Notre proposition commerciale $obj->ref"; - $message = "Veuillez trouver ci-joint notre proposition commerciale $obj->ref\n\nCordialement\n\n"; - $filepath = $file ; - $filename = "$obj->ref.pdf"; - $mimetype = "application/pdf"; - - $replyto = "$replytoname <$replytomail>"; - - $mailfile = new CMailFile($subject,$sendto,$replyto,$message,$filepath,$mimetype, $filename); - - if ( $mailfile->sendfile() ) { - - print "

envoyé à $sendto"; - print "

envoyé par ".htmlentities($replyto); - } else { - print "!! erreur d'envoi"; - } - } - /* - * Enregistre l'action - * - * Ne fonctionne pas, a corriger ! - */ - - if ( $db->query($sql) ) { - $sql = "INSERT INTO actioncomm (datea,fk_action,fk_soc, propalrowid,note, fk_user_author) "; - $sql .= " VALUES (now(), 3, $obj->idp, $propalid, 'Envoyée à $sendto',$user->id);"; - if (! $db->query($sql) ) { - print $db->error(); - print "

$sql

"; - } - } else { - print $db->error(); - } - } - /* - * - */ - print "
"; - print "
"; - print "Documents générés
"; - print ""; - - $file = $conf->propal->outputdir. "/$obj->ref/$obj->ref.pdf"; - if (file_exists($file)) { - print ""; - print ''; - } - $file = $conf->propal->outputdir . "/$obj->ref/$obj->ref.ps"; - if (file_exists($file)) { - print ""; - print ''; - print ""; - } - print ''; - - $file = $GLOBALS["GLJ_ROOT"] . "/www-sys/doc/propale/$obj->ref/FAX-$obj->ref.ps"; - if (file_exists($file)) { - print ""; - } - print "
Propale PDF'.$obj->ref.'.pdf
Propale Postscript'.$obj->ref.'.s
(liste...)
FAX d'entete
\n"; - /* - * - */ - print "
"; - print "Propale envoyée
"; - /* - * - */ - $sql = "SELECT ".$db->pdate("a.datea"). " as da, note, fk_user_author" ; - $sql .= " FROM actioncomm as a WHERE a.fk_soc = $obj->idp AND a.propalrowid = $propalid "; - - if ( $db->query($sql) ) { - $num = $db->num_rows(); - $i = 0; $total = 0; - print ""; - print "\n"; - - while ($i < $num) { - $objp = $db->fetch_object( $i); - print "\n"; - $authoract = new User($db); - $authoract->id = $objp->fk_user_author; - $authoract->fetch(''); - print "\n"; - print ""; - $i++; - } - print "
DateAuteur
".strftime("%d %B %Y %H:%M:%S",$objp->da)."$authoract->code
$objp->note
"; - $db->free(); - } else { - print $db->error(); - } - /* - * - */ - print "
"; - /* - * - * - */ - if ($action == 'presend') { - $sendto = "rq@lolix.org"; - - $replytoname = $conf->propal->replytoname; - $replytomail = $conf->propal->replytomail; - - $from_name = $user->fullname ; //$conf->propal->fromtoname; - $from_mail = $user->email; //conf->propal->fromtomail; - - print "
\n"; - print "\n"; - print "\n"; - print "\n"; - - print "

Envoyer la propale par mail"; - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - - print "
Destinataire$obj->firstname $obj->nameemail\">
Expediteur$from_name$from_mail
Reply-to$replytoname$replytomail
"; - print ""; - print "

"; - } - + } else { print "Num rows = " . $db->num_rows(); print "

$sql"; @@ -456,7 +289,7 @@ if ($propalid) { $cloturor = new User($db, $obj->fk_user_cloture); $cloturor->fetch(''); - print 'Suivi des actions
'; + print '

Cacher le suivi des actions '; print ''; print ''; print ''; @@ -496,7 +329,8 @@ if ($propalid) { print "
 NomDate
Création'.$author->fullname.'
"; $sql = "SELECT s.nom, s.idp, p.rowid as propalid, p.price - p.remise as price, p.ref,".$db->pdate("p.datep")." as dp, c.label as statut, c.id as statutid"; - $sql .= " FROM societe as s, llx_propal as p, c_propalst as c WHERE p.fk_soc = s.idp AND p.fk_statut = c.id"; + $sql .= " FROM societe as s, llx_propal as p, c_propalst as c "; + $sql .= " WHERE p.fk_soc = s.idp AND p.fk_statut = c.id AND p.fk_statut in(2,4)"; if ($socidp) { $sql .= " AND s.idp = $socidp"; diff --git a/htdocs/fichinter/index.php3 b/htdocs/fichinter/index.php3 index 75498fe010d..b3836cfaced 100644 --- a/htdocs/fichinter/index.php3 +++ b/htdocs/fichinter/index.php3 @@ -21,7 +21,7 @@ */ require("./pre.inc.php3"); require("../contact.class.php3"); -require("../societe.class.php3"); + llxHeader(); $db = new Db(); @@ -31,12 +31,9 @@ if ($sortorder == "") { if ($sortfield == "") { $sortfield="nom"; } -$bc[0]="bgcolor=\"#c0f0c0\""; -$bc[1]="bgcolor=\"#b0e0b0\""; -$bc2[0]="bgcolor=\"#c9f000\""; -$bc2[1]="bgcolor=\"#b9e000\""; -print '

Liste des fiches d\'intervention

'; + +print_titre("Liste des fiches d'intervention"); $sql = "SELECT s.nom,s.idp, f.ref,".$db->pdate("f.datei")." as dp, f.rowid as fichid, f.fk_statut"; $sql .= " FROM societe as s, llx_fichinter as f "; @@ -47,7 +44,7 @@ if ( $db->query($sql) ) { $num = $db->num_rows(); $i = 0; print "

"; - print ""; + print ""; print ""; print ""; print ""; diff --git a/htdocs/project.class.php3 b/htdocs/project.class.php3 new file mode 100644 index 00000000000..ff8fe3fb8dd --- /dev/null +++ b/htdocs/project.class.php3 @@ -0,0 +1,109 @@ + + * + * $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 + * 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. + * + */ + + +class Project { + var $id; + var $db; + var $ref; + var $title; + var $socidp; + + Function Project($DB) { + $this->db = $DB; + } + /* + * + * + * + */ + + Function create($creatorid) { + + $sql = "INSERT INTO llx_projet (ref, title, fk_soc, fk_user_creat) "; + $sql .= " VALUES ('$this->ref', '$this->title', $this->socidp, $creatorid) ;"; + + if (!$this->db->query($sql) ) + { + print ''.$sql.'
'.$this->db->error(); + + } + + } + /* + * + * + * + */ + + Function fetch($rowid) { + + $sql = "SELECT title, ref FROM llx_projet WHERE rowid=$rowid;"; + + if ($this->db->query($sql) ) { + if ($this->db->num_rows()) { + $obj = $this->db->fetch_object(0); + + $this->id = $rowid; + $this->ref = $obj->ref; + $this->title = $obj->title; + + $this->db->free(); + } + } else { + print $this->db->error(); + } + } + /* + * + * + * + */ + Function get_propal_list() { + $propales = array(); + $sql = "SELECT rowid FROM llx_propal WHERE fk_projet=$this->id;"; + + if ($this->db->query($sql) ) { + $nump = $this->db->num_rows(); + if ($nump) { + $i = 0; + while ($i < $nump) { + $obj = $this->db->fetch_object($i); + + $propales[$i] = $obj->rowid; + + $i++; + } + $this->db->free(); + /* + * Retourne un tableau contenant la liste des propales associees + */ + return $propales; + } + } else { + print $this->db->error() . '
' .$sql; + } + + + } +} +?> diff --git a/htdocs/propal.class.php3 b/htdocs/propal.class.php3 new file mode 100644 index 00000000000..67e00daf1c6 --- /dev/null +++ b/htdocs/propal.class.php3 @@ -0,0 +1,222 @@ + + * + * $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 + * 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. + * + */ + +class Propal { + var $id; + var $db; + var $socidp; + var $contactid; + var $projetidp; + var $author; + var $ref; + var $datep; + var $remise; + var $products; + var $products_qty; + var $note; + + var $price; + + Function Propal($DB, $soc_idp="") { + $this->db = $DB ; + $this->socidp = $soc_idp; + $this->products = array(); + } + /* + * + * + * + */ + Function add_product($idproduct, $qty) { + if ($idproduct > 0) { + $i = sizeof($this->products); + $this->products[$i] = $idproduct; + if (!$qty) { + $qty = 1 ; + } + $this->products_qty[$i] = $qty; + } + } + /* + * + * + * + */ + Function create() { + /* + * Insertion dans la base + */ + $sql = "INSERT INTO llx_propal (fk_soc, fk_soc_contact, price, remise, tva, total, datep, datec, ref, fk_user_author, note) "; + $sql .= " VALUES ($this->socidp, $this->contactid, 0, $this->remise, 0,0, $this->datep, now(), '$this->ref', $this->author, '$this->note')"; + $sqlok = 0; + + if ( $this->db->query($sql) ) { + + $this->id = $this->db->last_insert_id(); + + $sql = "SELECT rowid FROM llx_propal WHERE ref='$this->ref';"; + if ( $this->db->query($sql) ) { + /* + * Insertion du detail des produits dans la base + */ + if ( $this->db->num_rows() ) { + $propalid = $this->db->result( 0, 0); + $this->db->free(); + + for ($i = 0 ; $i < sizeof($this->products) ; $i++) { + $prod = new Product($this->db, $this->products[$i]); + $prod->fetch($this->products[$i]); + + $sql = "INSERT INTO llx_propaldet (fk_propal, fk_product, qty, price) VALUES "; + $sql .= " ($propalid,". $this->products[$i].",". $this->products_qty[$i].", $prod->price) ; "; + + if (! $this->db->query($sql) ) { + print $sql . '
' . $this->db->error() .'
'; + } + } + /* + * + */ + $this->update_price($this->id); + /* + * Affectation au projet + */ + if ($this->projetidp) { + $sql = "UPDATE llx_propal SET fk_projet=$this->projetidp WHERE ref='$this->ref';"; + $this->db->query($sql); + } + } + } else { + print $this->db->error() . '
'.$sql; + } + } else { + print $this->db->error() . '
'.$sql; + } + return $this->id; + } + /* + * + * + */ + Function update_price($rowid) { + /* + * Remise + */ + $sql = "SELECT remise FROM llx_propal WHERE rowid = $rowid"; + if ( $this->db->query($sql) ) { + $remise = $this->db->result(0, 0); + $this->db->free(); + + + /* + * Total des produits a ajouter + */ + $sql = "SELECT sum(price * qty) FROM llx_propaldet WHERE fk_propal = $rowid"; + if ( $this->db->query($sql) ) { + $cprice = $this->db->result(0, 0); + $this->db->free(); + + /* + * Calcul TVA, Remise + */ + $totalht = $cprice - $this->remise; + $tva = tva($totalht); + $total = $totalht + $tva; + /* + * + */ + $sql = "UPDATE llx_propal set price=$cprice, tva=$tva, total=$total WHERE rowid = $rowid"; + if ( $this->db->query($sql) ) { + + } + } + } + + } + + /* + * + * + * + */ + Function fetch($rowid) { + + $sql = "SELECT ref,price,remise,".$this->db->pdate(datep)."as dp FROM llx_propal WHERE rowid=$rowid;"; + + if ($this->db->query($sql) ) { + if ($this->db->num_rows()) { + $obj = $this->db->fetch_object(0); + + $this->id = $rowid; + $this->datep = $obj->dp; + $this->ref = $obj->ref; + $this->price = $obj->price; + $this->remise = $obj->remise; + + $this->db->free(); + } + } else { + print $this->db->error(); + } + } + /* + * + * + * + */ + Function valid($userid) { + $sql = "UPDATE llx_propal SET fk_statut = 1, date_valid=now(), fk_user_valid=$userid"; + $sql .= " WHERE rowid = $this->id AND fk_statut = 0 ;"; + + if ($this->db->query($sql) ) { + return 1; + } else { + print $this->db->error() . ' in ' . $sql; + } + } + /* + * + * + * + */ + Function cloture($userid, $statut, $note) { + $sql = "UPDATE llx_propal SET fk_statut = $statut, note = '$note', date_cloture=now(), fk_user_cloture=$userid"; + + $sql .= " WHERE rowid = $this->id;"; + + if ($this->db->query($sql) ) { + return 1; + } else { + print $this->db->error() . ' in ' . $sql; + } + } + + + + + + + + +} +?> + diff --git a/mysql/data/data.sql b/mysql/data/data.sql index b22eba3b3e4..384fc7712c9 100644 --- a/mysql/data/data.sql +++ b/mysql/data/data.sql @@ -93,3 +93,4 @@ insert into c_propalst (id,label) values (0, 'Brouillon'); insert into c_propalst (id,label) values (1, 'Ouverte'); insert into c_propalst (id,label) values (2, 'Signée'); insert into c_propalst (id,label) values (3, 'Non Signée'); +insert into c_propalst (id,label) values (4, 'Facturée'); diff --git a/mysql/tables/Makefile b/mysql/tables/Makefile index 22c42f3d3cb..ea1d0c720da 100644 --- a/mysql/tables/Makefile +++ b/mysql/tables/Makefile @@ -49,7 +49,6 @@ create: $(MYSQL) $(BASE) < llx_propaldet.sql $(MYSQL) $(BASE) < llx_service.sql $(MYSQL) $(BASE) < llx_soc_recontact.sql - $(MYSQL) $(BASE) < llx_train.sql $(MYSQL) $(BASE) < llx_user.sql $(MYSQL) $(BASE) < llx_ventes.sql $(MYSQL) $(BASE) < llx_voyage.sql diff --git a/mysql/tables/drop.sql b/mysql/tables/drop.sql index 4afc079f467..d0bf84f1023 100644 --- a/mysql/tables/drop.sql +++ b/mysql/tables/drop.sql @@ -101,8 +101,6 @@ drop table if exists llx_service; drop table if exists llx_soc_recontact; -drop table if exists llx_train; - drop table if exists llx_user; drop table if exists llx_ventes; diff --git a/mysql/tables/llx_voyage_reduc.sql b/mysql/tables/llx_voyage_reduc.sql new file mode 100644 index 00000000000..ae7ec81fc18 --- /dev/null +++ b/mysql/tables/llx_voyage_reduc.sql @@ -0,0 +1,38 @@ +-- =================================================================== +-- Copyright (C) 2001-2002 Rodolphe Quiedeville +-- +-- $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 +-- 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. +-- +-- =================================================================== + + +create table llx_voyage_reduc +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + datec datetime, + datev date, -- date de valeur + + date_debut date, -- date operation + date_fin date, + amount real NOT NULL default 0, + label varchar(255), + numero varchar(255), + fk_type smallint, -- Train, Avion, Bateaux + + note text +);
NumSocieteDate