This commit is contained in:
Rodolphe Quiedeville 2002-05-11 18:53:13 +00:00
parent 22778ce71d
commit 5050e3e90c
31 changed files with 2771 additions and 666 deletions

View File

@ -0,0 +1,105 @@
<?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
* 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() . "<br>" . $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) ) {
}
}
}
?>

View File

@ -0,0 +1,53 @@
<?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
* 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();
}
}
}
?>

View File

@ -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);

View File

@ -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 "<p>command : $command<br>";
}
} else {
print "<p><b>Erreur : la facture n'a pas été créée, vérifier le numéro !</b>";
@ -207,6 +200,17 @@ if ($action == 'add') {
print "</TABLE>";
}
if ($facid) {
$sql = "SELECT s.nom,s.idp, f.amount, f.facnumber, f.rowid";

View File

@ -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);

View File

@ -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 "<hr><b>Génération du fax</b><br>";
$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 "<p>Resultat :<p>";
$output = system($command);
print "<p>command : $command<br>";
}
/*
* Send
*

View File

@ -0,0 +1,72 @@
<?PHP
/* Copyright (C) 2001-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
* 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();
}
}
}
?>

View File

@ -0,0 +1,70 @@
<?PHP
/* Copyright (C) 2001-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
* 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 "<TABLE border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">";
print "<TR class=\"liste_titre\">";
print "<td>Label</td><td>Banque</TD>";
print "<td align=\"left\">Numéro</a></TD>";
print "</TR>\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 "<tr><td>$objp->label</td><td>$objp->bank</td><td>$objp->number</td></tr>";
$i++;
}
$db->free();
}
$acc = new Account($db);
print "</table>";
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -0,0 +1,68 @@
<?PHP
/* Copyright (C) 2001-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
* 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$
*/
?>

View File

@ -0,0 +1,73 @@
<?PHP
/* Copyright (C) 2001-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
* 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 "<TABLE border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">";
print "<TR class=\"liste_titre\">";
print "<td>Description</td><td align=\"right\">Montant</TD><td align=\"right\">francs</TD>";
print "</TR>\n";
$var=!$var;
$sql = "SELECT sum(amount) FROM llx_paiement";
$paiem = valeur($sql);
print "<tr $bc[$var]><td>Somme des paiements</td><td align=\"right\">".price($paiem)."</td><td align=\"right\">".francs($paiem)."</td></tr>";
$var=!$var;
$sql = "SELECT sum(amount) FROM llx_bank WHERE amount > 0";
$credits = valeur($sql);
print "<tr $bc[$var]><td>Somme des credits</td><td align=\"right\">".price($credits)."</td><td align=\"right\">".francs($credits)."</td></tr>";
$var=!$var;
$sql = "SELECT sum(amount) FROM llx_bank WHERE amount < 0";
$debits = valeur($sql);
print "<tr $bc[$var]><td>Somme des debits</td><td align=\"right\">".price($debits)."</td><td align=\"right\">".francs($debits)."</td></tr>";
$var=!$var;
$sql = "SELECT sum(amount) FROM llx_bank ";
$solde = valeur($sql);
print "<tr $bc[$var]><td>Solde compte</td><td align=\"right\">".price($solde)."</td><td align=\"right\">".francs($solde)."</td></tr>";
print "</table>";
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -0,0 +1,140 @@
<?PHP
/* Copyright (C) 2001-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
* 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 "<b>Budgets</b>";
print "<TABLE border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">";
print "<TR class=\"liste_titre\">";
echo '<td>Description</TD><td>Nb</td><td colspan=\"2\">Total</td><td>Moyenne</td>';
print "</TR>\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 "<tr $bc[$var]>";
print "<td><a href=\"$PHP_SELF?bid=$objp->rowid\">$objp->label</a></td>";
print "<td>$objp->nombre</td>";
print "<td align=\"right\">".price(abs($objp->somme))."</td>";
print "<td align=\"right\"><small>".francs(abs($objp->somme))."&nbsp;FF</small></td>";
print "<td align=\"right\">".price(abs($objp->somme / $objp->nombre))."</td>";
print "</tr>";
$i++;
$total = $total + abs($objp->somme);
}
$db->free();
print "<tr><td colspan=\"2\" align=\"right\">Total</td><td align=\"right\"><b>".price($total)."</b></td></tr>";
print "<tr><td colspan=\"3\" align=\"right\"><small>soit en francs</td><td align=\"right\"><small>".francs($total)."</td></tr>\n";
} else {
print $db->error();
}
print "</table>";
} 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 "<b>Budget : $budget_name</b>";
print "<TABLE border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">";
print "<TR bgcolor=\"orange\">";
echo '<td align="right">Date</td><td width="60%">Description</td><td align="right">Montant</td><td>&nbsp;</td>';
print "</TR>\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 "<tr $bc[$var]>";
print "<td align=\"right\">".strftime("%d %B %Y",$objp->do)."</TD>\n";
print "<td><a href=\"ligne.php3?rowid=$objp->rowid\">$objp->label</a></td>";
print "<td align=\"right\">".price(abs($objp->amount))."</td>";
print "<td align=\"right\"><small>".francs(abs($objp->amount))."</small></td>";
print "</tr>";
$i++;
$total = $total + $objp->amount;
}
$db->free();
print "<tr><td colspan=\"2\" align=\"right\">Total</td><td align=\"right\"><b>".price(abs($total))."</b></td><td>euros</td></tr>";
print "<tr><td colspan=\"2\" align=\"right\"><small>soit</td><td align=\"right\"><small>".francs(abs($total))."</td><td><small>francs</small></tr>\n";
} else {
print $db->error();
}
print "</table>";
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -0,0 +1,84 @@
<?PHP
/* Copyright (C) 2001-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
* 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 "<p>$sql";
}
}
print "<b>Categorie</b> <a href=\"$PHP_SELF\">reload</a>";
print "<form method=\"post\" action=\"$PHP_SELF\">";
print "<input type=\"hidden\" name=\"action\" value=\"add\">";
print "<TABLE border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">";
print "<TR bgcolor=\"orange\">";
print "<td>Num</td><td colspan=\"2\">Description</TD>";
print "</TR>\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 "<tr $bc[$var]>";
print "<td>$objp->rowid</td>";
print "<td colspan=\"2\">$objp->label</td>";
print "</tr>";
$i++;
}
$db->free();
}
print "<tr>";
print "<td><td><input name=\"label\" type=\"text\" size=45></td>";
print "<td align=\"center\"><input type=\"submit\" value=\"ajouter\"</td></tr>";
print "</table></form>";
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -0,0 +1,85 @@
<?PHP
/* Copyright (C) 2001-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
* 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 "<b>Configuration</b>";
print "<TABLE border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">";
print "<TR bgcolor=\"orange\">";
print "<td>id</td><td>Label</td><td>Description</TD>";
print "<td align=\"left\">Number</a></TD>";
print "</TR>\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 "<tr><td>$objp->rowid</td><td>$objp->label</td><td>$objp->bank</td><td>$objp->number</td></tr>";
$i++;
}
$db->free();
}
print "</table>";
echo '<br><br>';
print "<form method=\"post\" action=\"$PHP_SELF?viewall=$viewall&vline=$vline\">";
print "<input type=\"hidden\" name=\"action\" value=\"add\">";
print "<TABLE border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">";
echo '<tr><td>Label&nbsp;:&nbsp;<input type="text" name="label"></td>';
echo '<td>Bank&nbsp;:&nbsp;<input type="text" name="bank"></td>';
echo '<td>Number&nbsp;:&nbsp;<input type="text" name="number"></td>';
echo '<td><input type="submit" value="ajouter"></td></tr>';
print "</table></form>";
$db->close();
llxFooter(strftime("%H:%M",time()). " - <em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -0,0 +1,485 @@
<?PHP
/* Copyright (C) 2000,2001 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
* 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 "<OPTION VALUE=$obj->id";
if ($refid==$obj->id) {
print " SELECTED";
}
print ">$obj->libelle</OPTION>\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 "<TABLE width=\"100%\" border=\"0\" cellspacing=\"2\"><TR><TD>";
if ( $page ) {
print "<A href=\"$file?page=$page_prev$parm\" class=\"T3\">" . $GLOBALS["_PAGE_PREV"] . "</A>";
}
print "</TD><TD align=\"right\">";
if ( $i > ( $limit - 1 ) ) {
print "<A href=\"$file?page=$page_next$parm\" class=\"T3\">" . $GLOBALS["_PAGE_NEXT"] . "</A>";
}
print "</TD></TR></TABLE>\n";
}
//
//
//
function gljMenu_PrestaLogged() {
print "<DIV align=\"right\">";
print "<A href=\"prestas.php3\" class=\"T3\">Liste</A> |\n";
print "</DIV>";
}
function gljMenu_Stat() {
print "<DIV align=\"right\">";
print "<A href=\"index.php3\" class=\"T3\">" . $GLOBALS["_STAT_HOME"] . "</A> |\n";
print "<A href=\"contrat.php3\" class=\"T3\">" . $GLOBALS["_STAT_CONTRAT"] . "</A> |\n";
print "<A href=\"effectif.php3\" class=\"T3\">" . $GLOBALS["_STAT_EFFECTIF"] . "</A> |\n";
print "<A href=\"poste.php3\" class=\"T3\">" . $GLOBALS["_STAT_POSTE"] . "</A> |\n";
print "<A href=\"region.php3\" class=\"T3\">" . $GLOBALS["_STAT_REGION"] . "</A> |\n";
print "<A href=\"lang.php3\" class=\"T3\">" . $GLOBALS["_STAT_LANG"] . "</A> |\n";
print "<A href=\"secteur.php3\" class=\"T3\">" . $GLOBALS["_STAT_SECTEUR"] . "</A>\n";
print "</DIV>";
}
//
//
//
function gljMenu_Soc() {
print "<div align=\"right\">";
print "<A href=\"./\" class=\"T3\">" . $GLOBALS["_AFIND"] . "</A> |\n";
print "<A href=\"date.php3\" class=\"T3\">" . $GLOBALS["_BYDATE"] . "</A> |\n";
print "<A href=\"stat.php3?t=poste\" class=\"T3\">" . $GLOBALS["_BYPOSTE"] . "</A> |\n";
print "<A href=\"stat.php3?t=region\" class=\"T3\">" . $GLOBALS["_BYREGION"] . "</A> |\n";
print "<A href=\"stat.php3?t=secteur\" class=\"T3\">" . $GLOBALS["_BYSECTEUR"] . "</A> |\n";
print "<A href=\"company.php3\" class=\"T3\">" . $GLOBALS["_BYCOMPANY"] . "</A>\n";
print "</div>";
}
/*
*
*/
function gljMenu_SocLogged() {
print "<div align=\"right\">";
print "<A href=\"/of/fiche.php3\" class=\"T3\">" . $GLOBALS["_COORDENT"] . "</A> | ";
print "<A href=\"/of/desc.php3\" class=\"T3\">" . $GLOBALS["_DESC"] . "</A> | ";
//print "<A href=\"/of/ent.php3\" class=\"T3\">" . $GLOBALS["_ENT"] . "</A> | ";
print "<A href=\"/of/offres.php3\" class=\"T3\">" . $GLOBALS["_OFFRES"] . "</A> | ";
print "<A href=\"/of/abo.php3\" class=\"T3\">" . $GLOBALS["_ABO"] . "</A> | ";
print "<A href=\"/of/stat.php3\" class=\"T3\">" . $GLOBALS["_STAT"] . "</A> | ";
print "<A href=\"/of/pref.php3\" class=\"T3\">" . $GLOBALS["_PREF"] . "</A>";
print "</div><P>";
}
/*
*
*/
function gljMenu_SocSSII() {
print "<div align=\"right\">";
print "<A href=\"/of/ssii/\" class=\"T3\">Accueil SSII</A> | ";
print "<A href=\"/of/ssii/ressources.php3\" class=\"T3\">Ressources</A> | ";
print "<A href=\"/of/ssii/prestas.php3\" class=\"T3\">Prestations</A>";
print "</div><P>";
}
/*
*
*/
function gljMenu_Cv() {
print "<DIV align=\"right\">";
print "<A href=\"./\" class=\"T3\">" . $GLOBALS["_AFIND"] . "</A> |\n";
print "<A href=\"date.php3\" class=\"T3\">" . $GLOBALS["_BYDATE"] . "</A> |\n";
print "<A href=\"stat.php3?t=poste\" class=\"T3\">" . $GLOBALS["_BYPOSTE"] . "</A> |\n";
print "<A href=\"stat.php3?t=region\" class=\"T3\">" . $GLOBALS["_BYREGION"] . "</A> |\n";
print "<A href=\"stat.php3?t=secteur\" class=\"T3\">" . $GLOBALS["_BYSECTEUR"] . "</A> |\n";
print "<A href=\"stat.php3?t=expert\" class=\"T3\">" . $GLOBALS["_BYEXPERT"] . "</A>\n";
print "</DIV>";
}
/*
*
* 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<BR>$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;
}
}
}
?>

View File

@ -0,0 +1,128 @@
<?PHP
/*
* $Id$
* $Source$
*/
require("./pre.inc.php3");
require("./functions.inc.php3");
llxHeader();
$db = new Db();
$bc[0]="bgcolor=\"#90c090\"";
$bc[1]="bgcolor=\"#b0e0b0\"";
if ($action == 'class') {
$author = $GLOBALS["REMOTE_USER"];
$sql = "INSERT INTO llx_bank_class (lineid, fk_categ) VALUES ($rowid, $cat1)";
$result = $db->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 = "<option value=\"0\" SELECTED></option>";
while ($i < $num) {
$obj = $db->fetch_object($i);
$options .= "<option value=\"$obj->rowid\">$obj->label</option>\n"; $i++;
}
$db->free();
}
print "<b>Edition de la ligne</b>";
print "<TABLE border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">";
print "<TR bgcolor=\"orange\">";
print "<td>Date</td><td>Description</TD>";
print "<td align=\"right\"><a href=\"$PHP_SELF?vue=debit\">Debit</a></TD>";
print "<td align=\"right\"><a href=\"$PHP_SELF?vue=credit\">Credit</a></TD>";
print "<td align=\"center\">Releve</TD>";
print "<td align=\"center\">Auteur</TD>";
print "</TR>\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 "<tr $bc[$var]>";
print "<form method=\"post\" action=\"$PHP_SELF\">";
print "<input type=\"hidden\" name=\"action\" value=\"class\">";
print "<input type=\"hidden\" name=\"rowid\" value=\"$objp->rowid\">";
print "<td>".strftime("%d %b %Y",$objp->do)."</TD>\n";
print "<td>$objp->label</td>";
if ($objp->amount < 0) {
print "<td align=\"right\">".price($objp->amount * -1)."</TD><td>&nbsp;</td>\n";
} else {
print "<td>&nbsp;</td><td align=\"right\">".price($objp->amount)."</TD>\n";
}
print "<td align=\"center\"><a href=\"releve.php3?num=$objp->num_releve&ve=1\">$objp->num_releve</a></td>";
print "<td align=\"center\">$objp->author</td>";
print "</tr>";
print "<tr $bc[$var]><td>&nbsp;</td><td colspan=\"5\">";
print "<select name=\"cat1\">$options";
print "</select>&nbsp;";
print "<input type=\"submit\" value=\"add\"></td>";
print "</tr>";
print "</form>";
$i++;
}
$db->free();
}
print "</table>";
print "<p>Classé dans</p>";
print "<TABLE border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">";
print "<TR bgcolor=\"orange\">";
print "<td>Description</TD>";
print "</TR>\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 "<tr $bc[$var]>";
print "<td>$objp->label</td>";
print "<td align=\"center\"><a href=\"budget.php3?bid=$objp->rowid\">voir</a></td>";
print "</tr>";
$i++;
}
$db->free();
}
print "</table>";
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -0,0 +1,74 @@
<?PHP
/* Copyright (C) 2001-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
* 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);
}
?>

View File

@ -0,0 +1,121 @@
<?PHP
/*
* $Id$
* $Source$
*/
require("./pre.inc.php3");
llxHeader();
$db = new Db();
if ($action == 'rappro') {
$author = $GLOBALS["REMOTE_USER"];
if ($num_releve > 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 "<p>$sql";
}
}
}
if ($action == 'del') {
$sql = "DELETE FROM llx_bank WHERE rowid=$rowid";
$result = $db->query($sql);
if (!$result) {
print $db->error();
print "<p>$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 = "<option value=\"0\" SELECTED></option>";
while ($i < $num) {
$obj = $db->fetch_object($i);
$options .= "<option value=\"$obj->rowid\">$obj->label</option>\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 "<b>Rapprochement bancaire</b>";
print "<TABLE border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">";
print "<TR bgcolor=\"orange\">";
print "<td>Date</td><td>Description</TD>";
print "<td align=\"right\"><a href=\"$PHP_SELF?vue=debit\">Debit</a></TD>";
print "<td align=\"right\"><a href=\"$PHP_SELF?vue=credit\">Credit</a></TD>";
print "<td align=\"center\">Releve</TD>";
print "<td align=\"right\">Rappro</td>";
print "</TR>\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 "<tr $bc[$var]>";
print "<form method=\"post\" action=\"$PHP_SELF\">";
print "<input type=\"hidden\" name=\"action\" value=\"rappro\">";
print "<input type=\"hidden\" name=\"rowid\" value=\"$objp->rowid\">";
print "<td>".strftime("%d %b %Y",$objp->do)."</TD>\n";
print "<td>$objp->label</td>";
if ($objp->amount < 0) {
print "<td align=\"right\">".price($objp->amount * -1)."</TD><td>&nbsp;</td>\n";
} else {
print "<td>&nbsp;</td><td align=\"right\">".price($objp->amount)."</TD>\n";
}
print "<td align=\"right\">";
print "<input name=\"num_releve\" type=\"text\" value=\"$last_releve\" size=\"6\" maxlength=\"6\"></td>";
print "<td align=\"center\"><select name=\"rappro\"><option value=\"1\">oui</option><option value=\"0\" selected>non</option></select></td>";
print "<td align=\"center\"><input type=\"submit\" value=\"do\"></td>";
if ($objp->rappro) {
print "<td align=\"center\"><a href=\"releve.php3?num=$objp->num_releve\">$objp->num_releve</a></td>";
} else {
print "<td align=\"center\"><a href=\"$PHP_SELF?action=del&rowid=$objp->rowid\">[Del]</a></td>";
}
print "</tr>";
print "<tr $bc[$var]><td>&nbsp;</td><td colspan=\"7\">";
print "<select name=\"cat1\">$options";
print "</select>";
print "</tr>";
echo '<tr><td colspan="8"><hr></td></tr>';
print "</form>";
$i++;
}
$db->free();
}
print "</table>";
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -0,0 +1,162 @@
<?PHP
/*
* $Id$
* $Source$
*
*
* $num
* $rel
* $ve
*/
require("./pre.inc.php3");
llxHeader();
$db = new Db();
if (! $num) {
print "<b>Releves bancaires</b>";
print "<TABLE border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">";
print "<TR bgcolor=\"orange\">";
print "<td>Date</td><td>Description</TD>";
print "</TR>\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 "<tr $bc[$var]><td><a href=\"$PHP_SELF?num=$objp->numr\">$objp->numr</a></td></tr>\n";
$i++;
}
}
print "</table>";
} 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 "<table border=0 width=100%><tr><td><b>Releve num&eacute;ro $num</b></td>";
print "<td align=right><a href=\"$PHP_SELF?rel=prev&num=$num&ve=$ve\">&lt;- prev</a>";
print "&nbsp;-&nbsp;<a href=\"$PHP_SELF?rel=next&num=$num&ve=$ve\">next -&gt;</a></td></tr></table>";
print "<form method=\"post\" action=\"$PHP_SELF\">";
print "<input type=\"hidden\" name=\"action\" value=\"add\">";
print "<TABLE border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">";
print "<TR bgcolor=\"orange\">";
print "<td>Date</td><td>Description</TD>";
print "<td align=\"right\"><a href=\"$PHP_SELF?vue=debit\">Debit</a></TD>";
print "<td align=\"right\"><a href=\"$PHP_SELF?vue=credit\">Credit</a></TD>";
print "<td align=\"right\">Solde</TD>";
print "<td align=\"right\">Francs</td>";
print "</TR>\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 "<tr><td colspan=\"3\"><a href=\"$PHP_SELF?num=$num&ve=1&rel=$rel\">vue etendue</a></td>";
print "<td align=\"right\">Total :</td><td align=\"right\"><b>".price($total)."</b></td><td align=\"right\"><small>".francs($total)."</small></td></tr>\n";
while ($i < $numrows) {
$objp = $db->fetch_object( $i);
$total = $total + $objp->amount;
$var=!$var;
print "<tr $bc[$var]>";
print "<td>".strftime("%d %b %Y",$objp->do)."</TD>\n";
print "<td>$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 "<br>-&nbsp;<i>$objc->label</i>";
$ii++;
}
} else {
print $dc->error();
}
}
print "</td>";
if ($objp->amount < 0) {
$totald = $totald + abs($objp->amount);
print "<td align=\"right\">".price($objp->amount * -1)."</TD><td>&nbsp;</td>\n";
} else {
$totalc = $totalc + abs($objp->amount);
print "<td>&nbsp;</td><td align=\"right\">".price($objp->amount)."</TD>\n";
}
print "<td align=\"right\">".price($total)."</TD>\n";
print "<td align=\"right\"><small>".francs($objp->amount)."</small></TD>\n";
print "<td align=\"center\">[<a href=\"ligne.php3?rowid=$objp->rowid\">edit</a>]</td>";
print "</tr>";
$i++;
}
$db->free();
}
print "<tr><td align=\"right\" colspan=\"2\">Total :</td><td align=\"right\">".price($totald)."</td><td align=\"right\">".price($totalc)."</td><td colspan=\"3\">&nbsp;</td></tr>";
print "<tr><td align=\"right\" colspan=\"4\"><b>Solde :</b></td><td align=\"right\"><b>".price($total)."</b></td><td align=\"right\"><small>".francs($total)."</small></td></tr>\n";
print "</table></form>";
print "<a href=\"bank/categ.php3\">Edit Categories</a>";
print " <a href=\"bank/categories.php3\">Categories</a>";
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -0,0 +1,106 @@
<?PHP
/*
* $Id$
* $Source$
*
*
* $viewall
*
*/
require("./pre.inc.php3");
require("./bank.lib.php3");
llxHeader();
$db = new Db();
if ($action == 'add') {
$author = $GLOBALS["REMOTE_USER"];
if ($credit > 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 "<p>$sql";
}
}
if ($action == 'del') {
bank_delete_line($db, $rowid);
}
if ($vline) {
$viewline = $vline;
} else {
$viewline = 20;
}
print "<b>Virement</b> - <a href=\"$PHP_SELF\">Reload</a>&nbsp;-";
print "<a href=\"$PHP_SELF?viewall=1\">Voir tout</a>";
print "<form method=\"post\" action=\"$PHP_SELF?viewall=$viewall&vline=$vline&account=$account\">";
print "<input type=\"hidden\" name=\"action\" value=\"add\">";
print "<TABLE border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">";
print "<tr><td>De</td><td>Vers</td><td>Date</td><td>Libelle</td><td>Montant</td></tr>";
print "<tr><td>";
print "<select name=\"from\">";
$sql = "SELECT rowid, label FROM llx_bank_account";
$result = $db->query($sql);
if ($result) {
$var=True;
$num = $db->num_rows();
$i = 0; $total = 0;
while ($i < $num) {
$objp = $db->fetch_object($i);
print "<option value=\"$objp->rowid\">$objp->label</option><br>";
$i++;
}
}
print "</select></td><td>";
print "<select name=\"from\">";
$sql = "SELECT rowid, label FROM llx_bank_account";
$result = $db->query($sql);
if ($result) {
$var=True;
$num = $db->num_rows();
$i = 0; $total = 0;
while ($i < $num) {
$objp = $db->fetch_object($i);
print "<option value=\"$objp->rowid\">$objp->label</option><br>";
$i++;
}
}
print "</select></td>";
print "<td><input name=\"dateo\" type=\"text\" size=8 maxlength=8></td>";
print "<td><input name=\"label\" type=\"text\" size=40></td>";
print "<td><input name=\"debit\" type=\"text\" size=8></td>";
print "<td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"ajouter\"</td>";
print "</tr><tr><td colspan=\"2\">Format : YYYYMMDD - 20010826</td><td colspan=\"2\">0000.00</td></tr>";
print "</table></form>";
print "<a href=\"categ.php3\">Edit Categories</a>";
print " <a href=\"budget.php3\">Budgets</a>";
$db->close();
llxFooter(strftime("%H:%M",time()). " - <em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -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 "<p><TABLE border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
print "<TR class=\"liste_titre\">";
print "<TD>Société</td>";
print "<TD align=\"right\">Montant</TD><td>&nbsp;</td>";
print "<TD align=\"right\">Moyenne</TD>";
print "</TR>\n";
$var=True;
while ($i < $num) {
$objp = $db->fetch_object( $i);
$var=!$var;
print "<TR $bc[$var]>";
print "<TD><a href=\"../comm/index.php3?socid=$objp->idp\">$objp->nom</a></TD>\n";
print "<TD align=\"right\">".price($objp->ca)."</TD><td>&nbsp;</td>\n";
$total = $total + $objp->ca;
print "<TD align=\"right\">".price($total / ($i + 1))."</TD>\n";
print "</TR>\n";
$i++;
}
print "<tr>";
print "<td colspan=\"2\" align=\"right\"><b>Total : ".price($total)."</b></td><td>euros HT</td>";
print "<td align=\"right\"><b>Moyenne : ".price($total/ $i)."</b></td></tr>";
print "</TABLE>";
}
$db->free();
} else {
print $db->error();
}
}
print_barre_liste("Chiffre d'affaire par société", $page, $PHP_SELF);
print "<P>";
liste($db, 0);
print "<P>";
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 "<p><TABLE border=\"0\" width=\"50%\" cellspacing=\"0\" cellpadding=\"4\">";
print "<TR class=\"liste_titre\">";
print "<TD>Société</td>";
print "<TD align=\"right\">Montant</TD><td>&nbsp;</td>";
print "</TR>\n";
$var=True;
while ($i < $num) {
$objp = $db->fetch_object( $i);
$var=!$var;
print "<TR $bc[$var]>";
print "<TD><a href=\"fiche.php3?socid=$objp->idp\">$objp->nom</a></TD>\n";
print "<TD align=\"right\">".price($objp->ca)."</TD><td>&nbsp;</td>\n";
$total = $total + $objp->ca;
print "</TR>\n";
$i++;
}
print "<tr><td colspan=\"2\" align=\"right\"><b>Total : ".price($total)."</b></td><td>euros HT</td></tr>";
print "<tr><td colspan=\"2\" align=\"right\">Moyenne : ".price($total/$i)."</td><td>euros HT</td></tr>";
print "</TABLE>";
}
$db->free();
} else {
print $db->error();
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");

View File

@ -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 "<hr><b>Génération du PDF</b><p>";
// $command = "export DBI_DSN=\"".$GLOBALS["DBI"]."\" ";
// $command .= " ; ../../scripts/facture-tex.pl --facture=$facid --pdf --ps" ;
// $output = system($command);
// print "<p>command : $command<br>";
}
} else {
print "<p><b>Erreur : la facture n'a pas été créée, vérifier le numéro !</b>";
print "<p>Retour à la <a href=\"propal.php3?propalid=$propalid\">propal</a>";
}
$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 "<form action=\"$PHP_SELF\" method=\"post\">";
print "<input name=\"amount\" type=\"hidden\" value=\"".($obj->price - $obj->remise)."\">";
print "<input name=\"total\" type=\"hidden\" value=\"$obj->total\">";
print '<table cellspacing="0" border="1" width="100%">';
print "<tr bgcolor=\"#e0e0e0\"><td>Société :</td><td>$obj->nom</td>";
print "<td rowspan=8>Commentaires :<br>";
print "<textarea name=\"note\" wrap=\"soft\" cols=\"30\" rows=\"15\"></textarea></td></tr>";
print "<tr bgcolor=\"#e0e0e0\"><td>Propal :</td><td>$obj->ref</td></tr>";
print "<tr bgcolor=\"#e0e0e0\"><td>Montant HT :</td><td align=\"right\">".price($obj->price - $obj->remise)."</td></tr>";
print "<tr bgcolor=\"#e0e0e0\"><td>TVA 19.6% :</td><td align=\"right\">".price($obj->tva)."</td></tr>";
print "<tr bgcolor=\"#e0e0e0\"><td>Total TTC :</td><td align=\"right\">".price($obj->total)."</td></tr>";
print "<input type=\"hidden\" name=\"remise\" value=\"$obj->remise\">";
print "<input type=\"hidden\" name=\"tva\" value=\"$obj->tva\">";
print "<input type=\"hidden\" name=\"action\" value=\"add\">";
print "<input type=\"hidden\" name=\"propalid\" value=\"$propalid\">";
print "<input type=\"hidden\" name=\"socid\" value=\"$obj->idp\">";
$strmonth[1] = "Janvier"; $strmonth[2] = "F&eacute;vrier"; $strmonth[3] = "Mars"; $strmonth[4] = "Avril";
$strmonth[5] = "Mai"; $strmonth[6] = "Juin"; $strmonth[7] = "Juillet"; $strmonth[8] = "Ao&ucirc;t";
$strmonth[9] = "Septembre"; $strmonth[10] = "Octobre";
$strmonth[11] = "Novembre"; $strmonth[12] = "D&eacute;cembre";
print "<tr><td>Date :</td><td>";
$cday = date("d", time());
print "<select name=\"pday\">";
for ($day = 1 ; $day < $sday + 32 ; $day++) {
if ($day == $cday) {
print "<option value=\"$day\" SELECTED>$day";
} else {
print "<option value=\"$day\">$day";
}
}
print "</select>";
$cmonth = date("n", time());
print "<select name=\"pmonth\">";
for ($month = 1 ; $month <= 12 ; $month++) {
if ($month == $cmonth) {
print "<option value=\"$month\" SELECTED>" . $strmonth[$month];
} else {
print "<option value=\"$month\">" . $strmonth[$month];
}
}
print "</select>";
print "<select name=\"pyear\">";
$syear = date("Y", time() ) ;
print "<option value=\"".($syear-1)."\">".($syear-1);
print "<option value=\"$syear\" SELECTED>$syear";
for ($year = $syear +1 ; $year < $syear + 5 ; $year++) {
print "<option value=\"$year\">$year";
}
print "</select></td></tr>";
$author = $GLOBALS["REMOTE_USER"];
print "<input type=\"hidden\" name=\"author\" value=\"$author\">";
print "<tr><td>Auteur :</td><td>$author</td></tr>";
print "<tr><td>Numéro :</td><td> <input name=\"facnumber\" type=\"text\" value=\"$numfa\"></td></tr>";
print "<tr><td colspan=\"3\" align=\"center\"><input type=\"submit\" value=\"Enregistrer\"></td></tr>";
print "</form>";
print "</table>";
}
$db->free();
} else {
print $db->error();
}
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=\"index.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=\"../comm/index.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>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>";
print "</table>";
print "</td><td valign=\"top\">";
$_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 "<p><b>Paiements</b>";
echo '<TABLE border="1" width="100%" cellspacing="0" cellpadding="3">';
print "<TR class=\"liste_titre\">";
print "<td>Date</td>";
print "<td>Type</td>";
print "<td align=\"right\">Montant</TD><td>&nbsp;</td>";
print "</TR>\n";
$var=True;
while ($i < $num) {
$objp = $db->fetch_object( $i);
$var=!$var;
print "<TR $bc[$var]>";
print "<TD>".strftime("%d %B %Y",$objp->dp)."</TD>\n";
print "<TD>$objp->paiement_type $objp->num_paiement</TD>\n";
print "<TD align=\"right\">".price($objp->amount)."</TD><td>$_MONNAIE</td>\n";
print "</tr>";
$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";
print "</table>";
$db->free();
} else {
print $db->error();
}
print "</td></tr>";
print "<tr><td>Note : ".nl2br($obj->note)."</td></tr>";
print "</table>";
print "<p><TABLE border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\"><tr>";
if ($obj->statut == 0) {
print "<td align=\"center\" bgcolor=\"#e0e0e0\" width=\"25%\">[<a href=\"$PHP_SELF?facid=$facid&action=delete\">Supprimer</a>]</td>";
} else {
print "<td align=\"center\" width=\"25%\">-</td>";
}
if ($obj->statut == 1 && $resteapayer > 0) {
print "<td align=\"center\" bgcolor=\"#e0e0e0\" width=\"25%\">[<a href=\"paiement.php3?facid=$facid&action=create\">Emettre un paiement</a>]</td>";
} else {
print "<td align=\"center\" width=\"25%\">-</td>";
}
if ($obj->statut == 1 && abs($resteapayer == 0) && $obj->paye == 0) {
print "<td align=\"center\" bgcolor=\"#e0e0e0\" width=\"25%\">[<a href=\"$PHP_SELF?facid=$facid&action=payed\">Classer 'Payée'</a>]</td>";
} else {
print "<td align=\"center\" width=\"25%\">-</td>";
}
if ($obj->statut == 0) {
print "<td align=\"center\" bgcolor=\"#e0e0e0\" width=\"25%\">[<a href=\"$PHP_SELF?facid=$facid&action=valid\">Valider</a>]</td>";
} else {
print "<td align=\"center\" width=\"25%\"><a href=\"facture.php3?facid=$facid&action=pdf\">Générer la facture</a></td>";
}
print "</tr></table><p>";
/*
* Documents générés
*
*/
print "<hr>";
print "<table width=\"100%\" cellspacing=2><tr><td width=\"50%\" valign=\"top\">";
print "<b>Documents générés</b><br>";
print "<table width=\"100%\" cellspacing=0 border=1 cellpadding=3>";
$file = $GLOBALS["GLJ_ROOT"] . "/www-sys/doc/facture/$obj->facnumber/$obj->facnumber.pdf";
if (file_exists($file)) {
print "<tr><td>Propale PDF</a></td><td><a href=\"../../doc/facture/$obj->facnumber/$obj->facnumber.pdf\">$obj->facnumber.pdf</a></td></tr>";
}
$file = $GLOBALS["GLJ_ROOT"] . "/www-sys/doc/facture/$obj->facnumber/$obj->facnumber.ps";
if (file_exists($file)) {
print "<tr><td>Propale Postscript</a></td><td><a href=\"../../doc/facture/$obj->facnumber/$obj->facnumber.ps\">$obj->facnumber.ps</a></td>";
print "</tr>";
}
print "<tr><td colspan=\"2\">(<a href=\"../../doc/facture/$obj->facnumber/\">liste...</a>)</td></tr>";
print "</table>\n</table>";
/*
* Generation de la facture
*
*/
if ($action == 'pdf') {
print "<hr><b>Génération de la facture</b><br>";
$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 "<p>command :<br><small>$command</small><br>";
print "<p>output :<br><small>$output</small><br>";
}
/*
* 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 "<p><b>Proposition(s) commerciale(s) associée(s)</b>";
print '<TABLE border="1" width="100%" cellspacing="0" cellpadding="4">';
print "<TR class=\"liste_titre\">";
print "<td>Num</td>";
print "<td>Date</td>";
print "<td align=\"right\">Prix</TD>";
print "</TR>\n";
$var=True;
while ($i < $num) {
$objp = $db->fetch_object( $i);
$var=!$var;
print "<TR $bc[$var]>";
print "<TD><a href=\"../comm/propal.php3?propalid=$objp->propalid\">$objp->ref</a></TD>\n";
print "<TD>".strftime("%d %B %Y",$objp->dp)."</TD>\n";
print '<TD align="right">'.price($objp->price).'</TD>';
print "</tr>";
$total = $total + $objp->price;
$i++;
}
print "<tr><td align=\"right\" colspan=\"3\">Total : <b>".price($total)."</b> $_MONNAIE HT</td></tr>\n";
print "</table>";
} 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 "<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>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>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>";
print "</table>";
print "</td><td valign=\"top\">";
$_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 "<p><b>Paiements</b>";
echo '<TABLE border="1" width="100%" cellspacing="0" cellpadding="3">';
print "<TR class=\"liste_titre\">";
print "<td>Date</td>";
print "<td>Type</td>";
print "<td align=\"right\">Montant</TD><td>&nbsp;</td>";
print "</TR>\n";
$var=True;
while ($i < $num) {
$objp = $db->fetch_object( $i);
$var=!$var;
print "<TR $bc[$var]>";
print "<TD>".strftime("%d %B %Y",$objp->dp)."</TD>\n";
print "<TD>$objp->paiement_type $objp->num_paiement</TD>\n";
print "<TD align=\"right\">".price($objp->amount)."</TD><td>$_MONNAIE</td>\n";
print "</tr>";
$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";
print "</table>";
$db->free();
} else {
print $db->error();
}
print "</td></tr>";
print "<tr><td>Note : ".nl2br($obj->note)."</td></tr>";
print "</table>";
print "<p><TABLE border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\"><tr>";
if ($obj->statut == 0) {
print "<td align=\"center\" bgcolor=\"#e0e0e0\" width=\"25%\">[<a href=\"$PHP_SELF?facid=$facid&action=delete\">Supprimer</a>]</td>";
} else {
print "<td align=\"center\" width=\"25%\">-</td>";
}
if ($obj->statut == 1 && $resteapayer > 0) {
print "<td align=\"center\" bgcolor=\"#e0e0e0\" width=\"25%\">[<a href=\"paiement.php3?facid=$facid&action=create\">Emettre un paiement</a>]</td>";
} else {
print "<td align=\"center\" width=\"25%\">-</td>";
}
if ($obj->statut == 1 && abs($resteapayer == 0) && $obj->paye == 0) {
print "<td align=\"center\" bgcolor=\"#e0e0e0\" width=\"25%\">[<a href=\"$PHP_SELF?facid=$facid&action=payed\">Classer 'Payée'</a>]</td>";
} else {
print "<td align=\"center\" width=\"25%\">-</td>";
}
if ($obj->statut == 0) {
print "<td align=\"center\" bgcolor=\"#e0e0e0\" width=\"25%\">[<a href=\"$PHP_SELF?facid=$facid&action=valid\">Valider</a>]</td>";
} else {
print "<td align=\"center\" width=\"25%\"><a href=\"facture.php3?facid=$facid&action=pdf\">Générer la facture</a></td>";
}
print "</tr></table><p>";
/*
* Documents générés
*
*/
print "<hr>";
print "<table width=\"100%\" cellspacing=2><tr><td width=\"50%\" valign=\"top\">";
print "<b>Documents générés</b><br>";
print "<table width=\"100%\" cellspacing=0 border=1 cellpadding=3>";
$file = $GLOBALS["GLJ_ROOT"] . "/www-sys/doc/facture/$obj->facnumber/$obj->facnumber.pdf";
if (file_exists($file)) {
print "<tr><td>Propale PDF</a></td><td><a href=\"../../doc/facture/$obj->facnumber/$obj->facnumber.pdf\">$obj->facnumber.pdf</a></td></tr>";
}
$file = $GLOBALS["GLJ_ROOT"] . "/www-sys/doc/facture/$obj->facnumber/$obj->facnumber.ps";
if (file_exists($file)) {
print "<tr><td>Propale Postscript</a></td><td><a href=\"../../doc/facture/$obj->facnumber/$obj->facnumber.ps\">$obj->facnumber.ps</a></td>";
print "</tr>";
}
print "<tr><td colspan=\"2\">(<a href=\"../../doc/facture/$obj->facnumber/\">liste...</a>)</td></tr>";
print "</table>\n</table>";
/*
* Generation de la facture
*
*/
if ($action == 'pdf') {
print "<hr><b>Génération de la facture</b><br>";
$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 "<p>command :<br><small>$command</small><br>";
print "<p>output :<br><small>$output</small><br>";
}
/*
* 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 "<p><b>Proposition(s) commerciale(s) associée(s)</b>";
print '<TABLE border="1" width="100%" cellspacing="0" cellpadding="4">';
print "<TR class=\"liste_titre\">";
print "<td>Num</td>";
print "<td>Date</td>";
print "<td align=\"right\">Prix</TD>";
print "</TR>\n";
$var=True;
while ($i < $num) {
$objp = $db->fetch_object( $i);
$var=!$var;
print "<TR $bc[$var]>";
print "<TD><a href=\"propal.php3?propalid=$objp->propalid\">$objp->ref</a></TD>\n";
print "<TD>".strftime("%d %B %Y",$objp->dp)."</TD>\n";
print '<TD align="right">'.price($objp->price).'</TD>';
print "</tr>";
$total = $total + $objp->price;
$i++;
}
print "<tr><td align=\"right\" colspan=\"3\">Total : <b>".price($total)."</b> $_MONNAIE HT</td></tr>\n";
print "</table>";
} 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 "<TABLE border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
print '<TR class="liste_titre">';
print "<TD>Num&eacute;ro</TD><td>";
print_liste_field_titre("Société",$PHP_SELF,"s.nom");
print "</td><TD align=\"right\">Date</TD><TD align=\"right\">Montant</TD>";
print "<TD align=\"right\">Payé</TD>";
print "</TR>\n";
if ($num > 0) {
$i = 0;
print '<p><TABLE border="1" width="100%" cellspacing="0" cellpadding="4">';
print "<TR bgcolor=\"orange\">";
print "<TD>[<a href=\"$PHP_SELF\">Tous</a>]</td>";
print "<TD><a href=\"$PHP_SELF?sortfield=lower(p.label)&sortorder=ASC\">Societe</a></td>";
print "<TD>Num</TD>";
print "<TD align=\"right\">Date</TD>";
print "<TD align=\"right\">Montant</TD>";
print "<TD align=\"right\">Payé</TD>";
print "<TD align=\"right\">Moyenne</TD>";
print "</TR>\n";
$var=True;
while ($i < $num) {
$objp = $db->fetch_object( $i);
$var=!$var;
if ($objp->paye && !$sep) {
print "<tr><td colspan=\"3\" align=\"right\">";
print "&nbsp;</small></td>";
print "<td align=\"right\">Sous Total :<b> ".price($total)."</b></td><td>euros HT</td></tr>";
print '<TR class="liste_titre">';
print "<TD>Num&eacute;ro</TD><td>";
print_liste_field_titre("Société",$PHP_SELF,"s.nom");
print "</td><TD align=\"right\">Date</TD><TD align=\"right\">Montant</TD>";
print "<TD align=\"right\">Payé</TD></TR>\n";
$sep = 1 ; $j = 0;
$subtotal = 0;
}
print "<TR $bc[$var]>";
print "<TD>[<a href=\"$PHP_SELF?socidp=$objp->idp\">Filtre</a>]</TD>\n";
print "<TD><a href=\"../comm/index.php3?socid=$objp->idp\">$objp->nom</a></TD>\n";
print "<td><a href=\"facture.php3?facid=$objp->facid\">$objp->facnumber</a></TD>\n";
print "<TD><a href=\"fiche.php3?socid=$objp->idp\">$objp->nom</a></TD>\n";
if ($objp->df > 0 ) {
print "<TD align=\"right\">";
$y = strftime("%Y",$objp->df);
$m = strftime("%m",$objp->df);
print strftime("%d",$objp->df)."\n";
print " <a href=\"facture.php3?year=$y&month=$m\">";
print strftime("%B",$objp->df)."</a>\n";
@ -310,32 +457,36 @@ if ($facid > 0) {
} else {
print "<TD align=\"right\"><b>!!!</b></TD>\n";
}
print '<TD align="right">'.price($objp->amount).'</TD>';
print "<TD align=\"right\">".price($objp->amount)."</TD>\n";
$yn[1] = "oui";
$yn[0] = "<b>non</b>";
$total = $total + $objp->amount;
$total = $total + $objp->amount;
$subtotal = $subtotal + $objp->amount;
print "<TD align=\"right\">".$yn[$objp->paye]."</TD>\n";
print "<TD align=\"right\">".round($total / ($i + 1))."</TD>\n";
print "</TR>\n";
$i++;
$j++;
}
print "<tr><td></td><td>$i factures</td><td colspan=\"2\" align=\"right\"><b>Total : ".round($total * 6.55957)." FF</b></td>";
print "<td align=\"right\"><b>Total : $total</b></td><td>$_MONNAIE HT</td>";
print "<td align=\"right\"><b>Moyenne : ".round($total/ $i)."</b></td></tr>";
print "</TABLE>";
}
if ($i == 0) { $i=1; } if ($j == 0) { $j=1; }
print "<tr><td></td><td>$j factures</td><td colspan=\"1\" align=\"right\">&nbsp;</td>";
print "<td align=\"right\">Sous Total :<b> ".price($subtotal)."</b></td><td>euros HT</td></tr>";
print "<tr bgcolor=\"#d0d0d0\"><td></td><td>$i factures</td><td colspan=\"1\" align=\"right\">&nbsp;</td>";
print "<td align=\"right\"><b>Total : ".price($total)."</b></td><td>euros HT</td></tr>";
print "</TABLE>";
$db->free();
} else {
print $db->error();
}
}
print "<P>";
liste($db, 0);
print "<P>";
liste($db, 1);
}

View File

@ -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 "<table width=\"100%\" border=0><tr>\n";
print "<td valign=\"top\">";
print "<table cellspacing=\"0\" border=\"1\" width=\"100%\">";
print "<tr><td>Type</td><td> $objsoc->typent</td><td>Effectif</td><td>$objsoc->effectif</td></tr>";
print "<tr><td>Tel</td><td> $objsoc->tel&nbsp;</td><td>fax</td><td>$objsoc->fax&nbsp;</td></tr>";
print "<tr><td>Tel</td><td> $objsoc->tel&nbsp;</td><td>Fax</td><td>$objsoc->fax&nbsp;</td></tr>";
print "<tr><td>Ville</td><td colspan=\"3\">".nl2br($objsoc->address)."<br>$objsoc->cp $objsoc->ville</td></tr>";
print "<tr><td>siren</td><td><a href=\"http://www.societe.com/cgi-bin/recherche?rncs=$objsoc->siren\">$objsoc->siren</a>&nbsp;</td>";
@ -204,52 +202,21 @@ if ($socid > 0) {
print "</td>\n";
print '<td valign="top" width="50%">';
/*
*
* Propales
*
*/
$var=!$var;
print "<TABLE border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"1\">";
$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 "<tr $bc[$var]><td colspan=\"4\"><a href=\"propal.php3?socidp=$objsoc->idp\">liste des propales ($num)</td></tr>";
}
$i = 0; $now = time(); $lim = 3600 * 24 * 15 ;
while ($i < $num && $i < 2) {
$objp = $db->fetch_object( $i);
$var=!$var;
print "<TR $bc[$var]>";
print "<TD><a href=\"propal.php3?propalid=$objp->propalid\">$objp->ref</a>\n";
if ( ($now - $objp->dp) > $lim && $objp->statutid == 1 ) {
print " <b>&gt; 15 jours</b>";
}
print "</td><TD align=\"right\">".strftime("%d %B %Y",$objp->dp)."</TD>\n";
print "<TD align=\"right\">".price($objp->price - $objp->remise)."</TD>\n";
print "<TD align=\"center\">$objp->statut</TD></tr>\n";
$i++;
}
$db->free();
}
/*
* Factures
*/
$var=!$var;
print "<TABLE border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"1\">";
$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 "<tr $bc[$var]>";
print "<td colspan=\"4\"><a href=\"../compta/index.php3?socidp=$objsoc->idp\">liste des factures ($num)</td></tr>";
print "<td colspan=\"4\"><a href=\"facture.php3?socidp=$objsoc->idp\">liste des factures ($num)</td></tr>";
}
while ($i < $num && $i < 2) {
while ($i < $num && $i < 5) {
$objp = $db->fetch_object( $i);
$var=!$var;
print "<TR $bc[$var]>";

View File

@ -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 '<TABLE border="0" width="100%" cellspacing="0" cellpadding="4">';
print '<tr><td valign="top" width="30%">';
print '<TABLE border="0" cellspacing="0" cellpadding="3" width="100%">';
print "<TR class=\"liste_titre\">";
print "<td colspan=\"2\">Propositions commerciales</td>";
print "</TR>\n";
$sql = "SELECT count(*) FROM llx_propal WHERE fk_statut = 2";
if (valeur($sql)) {
$var=!$var;
print "<tr $bc[$var]><td><a href=\"propal.php3?viewstatut=2\">A facturer</a></td><td align=\"right\">".valeur($sql)."</td></tr>";
}
if ($year > 0) {
$sql .= " AND date_part('year', date(f.datef)) = $year";
print "</table><br>";
print '<TABLE border="0" cellspacing="0" cellpadding="3" width="100%">';
print "<TR class=\"liste_titre\">";
print "<td colspan=\"2\">Factures</td>";
print "</TR>\n";
$sql = "SELECT count(*) FROM llx_facture WHERE paye = 0";
if (valeur($sql)) {
$var=!$var;
print "<tr $bc[$var]><td><a href=\"facture.php3\">Non payées</a></td><td align=\"right\">".valeur($sql)."</td></tr>";
}
$sql .= " ORDER BY f.fk_statut, f.paye, f.datef DESC ";
$result = $db->query($sql);
if ($result) {
print "</table><br>";
/*
*
*
*/
$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 "<TABLE border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
print '<TR class="liste_titre">';
print "<TD>[<a href=\"$PHP_SELF\">Tous</a>]</td>";
print "<TD>Num&eacute;ro</TD><td>";
print_liste_field_titre("Société",$PHP_SELF,"s.nom");
print "</td><TD align=\"right\">Date</TD><TD align=\"right\">Montant</TD>";
print "<TD align=\"right\">Payé</TD>";
print "<TR class=\"liste_titre\">";
print "<TD colspan=\"2\">Bookmark</td>";
print "</TR>\n";
if ($num > 0) {
$var=True;
while ($i < $num) {
$objp = $db->fetch_object( $i);
$var=!$var;
if ($objp->paye && !$sep) {
print "<tr><td></td><td>$i factures</td><td colspan=\"2\" align=\"right\">";
print "&nbsp;</small></td>";
print "<td align=\"right\">Sous Total :<b> ".price($total)."</b></td><td>euros HT</td></tr>";
print '<TR class="liste_titre">';
print "<TD>[<a href=\"$PHP_SELF\">Tous</a>]</td>";
print "<TD>Num&eacute;ro</TD><td>";
print_liste_field_titre("Société",$PHP_SELF,"s.nom");
print "</td><TD align=\"right\">Date</TD><TD align=\"right\">Montant</TD>";
print "<TD align=\"right\">Payé</TD></TR>\n";
$sep = 1 ; $j = 0;
$subtotal = 0;
}
print "<TR $bc[$var]>";
print "<TD>[<a href=\"$PHP_SELF?socidp=$objp->idp\">Filtre</a>]</TD>\n";
print "<td><a href=\"facture.php3?facid=$objp->facid\">$objp->facnumber</a></TD>\n";
print "<TD><a href=\"../comm/index.php3?socid=$objp->idp\">$objp->nom</a></TD>\n";
if ($objp->df > 0 ) {
print "<TD align=\"right\">";
$y = strftime("%Y",$objp->df);
$m = strftime("%m",$objp->df);
print strftime("%d",$objp->df)."\n";
print " <a href=\"facture.php3?year=$y&month=$m\">";
print strftime("%B",$objp->df)."</a>\n";
print " <a href=\"facture.php3?year=$y\">";
print strftime("%Y",$objp->df)."</a></TD>\n";
} else {
print "<TD align=\"right\"><b>!!!</b></TD>\n";
}
print "<TD align=\"right\">".price($objp->amount)."</TD>\n";
$yn[1] = "oui";
$yn[0] = "<b>non</b>";
$total = $total + $objp->amount;
$subtotal = $subtotal + $objp->amount;
print "<TD align=\"right\">".$yn[$objp->paye]."</TD>\n";
print "</TR>\n";
$i++;
$j++;
}
while ($i < $num) {
$obj = $db->fetch_object( $i);
$var = !$var;
print "<tr $bc[$var]>";
print '<td><a href="fiche.php3?socid='.$obj->idp.'">'.$obj->nom.'</a></td>';
print '<td align="right"><a href="index.php3?action=del_bookmark&bid='.$obj->bid.'">';
print '<img src="/theme/'.$conf->theme.'/img/editdelete.png" border="0"></a></td>';
print '</tr>';
$i++;
}
if ($i == 0) { $i=1; } if ($j == 0) { $j=1; }
print "<tr><td></td><td>$j factures</td><td colspan=\"2\" align=\"right\">&nbsp;</td>";
print "<td align=\"right\">Sous Total :<b> ".price($subtotal)."</b></td><td>euros HT</td></tr>";
print '</table>';
}
/*
*
*
*
*/
print '</td><td valign="top" width="70%">';
print "<tr bgcolor=\"#d0d0d0\"><td></td><td>$i factures</td><td colspan=\"2\" align=\"right\">&nbsp;</td>";
print "<td align=\"right\"><b>Total : ".price($total)."</b></td><td>euros HT</td></tr>";
print "</TABLE>";
$result = 0;
if ( $result ) {
print '<TABLE border="0" cellspacing="0" cellpadding="3" width="100%">';
print "<TR class=\"liste_titre\">";
print "<td colspan=\"2\">Actions à faire</td>";
print "</TR>\n";
$i = 0;
while ($i < $db->num_rows() ) {
$obj = $db->fetch_object($i);
$var=!$var;
print "<tr $bc[$var]><td>".strftime("%d %b %Y",$obj->da)."</td><td><a href=\"action/fiche.php3\">$obj->libelle $obj->label</a></td></tr>";
$i++;
}
$db->free();
print "</table><br>";
} else {
print $db->error();
}
print '</td></tr>';
print '</table>';
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -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.'</td></tr>';
/*
*
*/
print "<tr><td>PDF</a></td>";
$file = $conf->propal->outputdir. "/$obj->ref/$obj->ref.pdf";
if (file_exists($file)) {
print '<td colspan="2"><a href="'.$conf->propal->outputurl.'/'.$obj->ref.'/'.$obj->ref.'.pdf">'.$obj->ref.'.pdf</a></td></tr>';
}
print '</tr>';
/*
*
*/
@ -180,42 +188,11 @@ if ($propalid) {
}
print "<table width=\"100%\" cellspacing=2><tr><td valign=\"top\">";
/*
* 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 "<p><b>Produits</b><TABLE border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"3\">";
print "<TR bgcolor=\"orange\">";
print "<td>Réf</td><td>Produit</td>";
print "<td align=\"right\">Prix</TD><td align=\"center\">Qté.</td>";
print "</TR>\n";
$var=True;
while ($i < $num) {
$objp = $db->fetch_object( $i);
$var=!$var;
print "<TR $bc[$var]>";
print "<TD>[$objp->ref]</TD>\n";
print "<TD>$objp->product</TD>\n";
print "<TD align=\"right\">".price($objp->price)."</TD><td align=\"center\">".$objp->qty."</td>\n";
print "</tr>";
$total = $total + $objp->price;
$i++;
}
//print "<tr><td align=\"right\" colspan=\"3\">Total : <b>".price($total)."</b></td><td>Euros HT</td></tr>\n";
print "</table>";
}
print "<table width=\"100%\" cellspacing=2>";
/*
*
*/
print "</td><td valign=\"top\" width=\"50%\">";
print "<td valign=\"top\" width=\"50%\">";
/*
* Factures associees
*/
@ -286,160 +263,16 @@ if ($propalid) {
}
if ($obj->statut == 0) {
print "<td bgcolor=\"#e0e0e0\" align=\"center\" width=\"25%\">[<a href=\"$PHP_SELF?propalid=$propalid&valid=1\">Valider</a>]</td>";
} else {
} elseif ($obj->statut == 2) {
print "<td bgcolor=\"#e0e0e0\" align=\"center\" width=\"25%\">[<a href=\"$PHP_SELF?propalid=$propalid&action=setstatut&statut=4\">Facturée</a>]</td>";
} else {
print "<td align=\"center\" width=\"25%\">-</td>";
}
print "</tr></table>";
/*
*
*/
if ($action == 'fax') {
print "<hr><b>Génération du fax</b><br>";
$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 "<p>Resultat :<p>";
$output = system($command);
print "<p>command : $command<br>";
}
/*
* 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 "<p>envoy&eacute; &agrave; $sendto";
print "<p>envoy&eacute; par ".htmlentities($replyto);
} else {
print "<b>!! 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 "<p>$sql</p>";
}
} else {
print $db->error();
}
}
/*
*
*/
print "<hr>";
print "<table width=\"100%\" cellspacing=2><tr><td width=\"50%\" valign=\"top\">";
print "<b>Documents générés</b><br>";
print "<table width=\"100%\" cellspacing=0 border=1 cellpadding=3>";
$file = $conf->propal->outputdir. "/$obj->ref/$obj->ref.pdf";
if (file_exists($file)) {
print "<tr><td>Propale PDF</a></td>";
print '<td><a href="'.$conf->propal->outputurl.'/'.$obj->ref.'/'.$obj->ref.'.pdf">'.$obj->ref.'.pdf</a></td></tr>';
}
$file = $conf->propal->outputdir . "/$obj->ref/$obj->ref.ps";
if (file_exists($file)) {
print "<tr><td>Propale Postscript</a></td>";
print '<td><a href="'.$conf->propal->outputurl.'/'.$obj->ref.'/'.$obj->ref.'.ps">'.$obj->ref.'.s</a></td></tr>';
print "</tr>";
}
print '<tr><td colspan="2">(<a href="'.$conf->propal->outputurl.'/'.$obj->ref.'">liste...</a>)</td></tr>';
$file = $GLOBALS["GLJ_ROOT"] . "/www-sys/doc/propale/$obj->ref/FAX-$obj->ref.ps";
if (file_exists($file)) {
print "<tr><td><a href=\"../../doc/fax/\">FAX d'entete</a></td></tr>";
}
print "</table>\n";
/*
*
*/
print "</td><td valign=\"top\" width=\"50%\">";
print "<b>Propale envoyée</b><br>";
/*
*
*/
$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 "<TABLE border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"3\">";
print "<tr><td>Date</td><td>Auteur</td></TR>\n";
while ($i < $num) {
$objp = $db->fetch_object( $i);
print "<TR><TD>".strftime("%d %B %Y %H:%M:%S",$objp->da)."</TD>\n";
$authoract = new User($db);
$authoract->id = $objp->fk_user_author;
$authoract->fetch('');
print "<TD>$authoract->code</TD></tr>\n";
print "<tr><td colspan=\"2\">$objp->note</td></tr>";
$i++;
}
print "</table>";
$db->free();
} else {
print $db->error();
}
/*
*
*/
print "</td></tr></table>";
/*
*
*
*/
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 "<form method=\"post\" action=\"$PHP_SELF?propalid=$propalid&action=send\">\n";
print "<input type=\"hidden\" name=\"sendto\" value=\"$sendto\">\n";
print "<input type=\"hidden\" name=\"replytoname\" value=\"$replytoname\">\n";
print "<input type=\"hidden\" name=\"replytomail\" value=\"$replytomail\">\n";
print "<p><b>Envoyer la propale par mail</b>";
print "<table cellspacing=0 border=1 cellpadding=3>";
print "<tr><td>Destinataire</td><td colspan=\"5\">$obj->firstname $obj->name</td>";
print "<td><input size=\"30\" name=\"sendto\" value=\"$obj->email\"></td></tr>";
print "<tr><td>Expediteur</td><td colspan=\"5\">$from_name</td><td>$from_mail</td></tr>";
print "<tr><td>Reply-to</td><td colspan=\"5\">$replytoname</td>";
print "<td>$replytomail</td></tr>";
print "</table>";
print "<input type=\"submit\" value=\"Envoyer\">";
print "</form>";
}
} else {
print "Num rows = " . $db->num_rows();
print "<p><b>$sql";
@ -456,7 +289,7 @@ if ($propalid) {
$cloturor = new User($db, $obj->fk_user_cloture);
$cloturor->fetch('');
print 'Suivi des actions<br>';
print '<p><a href="'.$PHP_SELF.'?propalid='.$propal->id.'">Cacher le suivi des actions </a>';
print '<table cellspacing=0 border=1 cellpadding=3>';
print '<tr><td>&nbsp;</td><td>Nom</td><td>Date</td></tr>';
print '<tr><td>Création</td><td>'.$author->fullname.'</td>';
@ -496,7 +329,8 @@ if ($propalid) {
print "</table>";
$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";

View File

@ -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 '<div class="titre">Liste des fiches d\'intervention</div><p>';
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 "<p><TABLE border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
print "<TR bgcolor=\"orange\">";
print "<TR class=\"liste_titre\">";
print "<TD>Num</TD>";
print "<TD><a href=\"$PHP_SELF?sortfield=lower(p.label)&sortorder=ASC\">Societe</a></td>";
print "<TD>Date</TD>";

109
htdocs/project.class.php3 Normal file
View File

@ -0,0 +1,109 @@
<?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
* 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 '<b>'.$sql.'</b><br>'.$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() . '<br>' .$sql;
}
}
}
?>

222
htdocs/propal.class.php3 Normal file
View File

@ -0,0 +1,222 @@
<?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
* 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 . '<br>' . $this->db->error() .'<br>';
}
}
/*
*
*/
$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() . '<b><br>'.$sql;
}
} else {
print $this->db->error() . '<b><br>'.$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;
}
}
}
?>

View File

@ -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');

View File

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

View File

@ -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;

View File

@ -0,0 +1,38 @@
-- ===================================================================
-- Copyright (C) 2001-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
-- 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
);