Massive update

This commit is contained in:
Rodolphe Quiedeville
2002-04-30 10:44:42 +00:00
parent 85d60740ca
commit 6c4baadf7a
53 changed files with 5804 additions and 508 deletions

View File

@@ -20,7 +20,7 @@
* *
*/ */
require("./pre.inc.php3"); require("./pre.inc.php3");
require("../lib/functions.inc.php3");
require("../societe.class.php3"); require("../societe.class.php3");
require("../contact.class.php3"); require("../contact.class.php3");
require("cactioncomm.class.php3"); require("cactioncomm.class.php3");

325
htdocs/comm/addpropal.php3 Normal file
View File

@@ -0,0 +1,325 @@
<?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("../lib/functions.inc.php3");
require("../lib/Product.class.php3");
require("./propal.class.php3");
$db = new Db();
$sql = "SELECT s.nom, s.idp, s.prefix_comm FROM societe as s WHERE s.idp = $socidp;";
$result = $db->query($sql);
if ($result) {
if ( $db->num_rows() ) {
$objsoc = $db->fetch_object(0);
}
$db->free();
}
$bc[0]="bgcolor=\"#90c090\"";
$bc[1]="bgcolor=\"#b0e0b0\"";
$yn["t"] = "oui";
$yn["f"] = "non";
llxHeader();
print "<table width=\"100%\">";
print "<tr><td>Propositions commerciales pour <b><a href=\"index.php3?socid=$socidp\">$objsoc->nom</a></b></td>";
print "</tr>";
print "</table>";
if ($action == 'add') {
$propal = new Propal($socidp);
$propal->remise = $remise;
$propal->datep = $db->idate(mktime(12, 1 , 1, $pmonth, $pday, $pyear));
$propal->contactid = $contactidp;
$propal->projetidp = $projetidp;
$propal->author = $user->id;
$propal->note = $note;
$propal->ref = $ref;
$propal->add_product($idprod1);
$propal->add_product($idprod2);
$propal->add_product($idprod3);
$propal->add_product($idprod4);
$sqlok = $propal->create($db);
/*
*
* Generation
*
*/
if ($sqlok) {
print "<hr><b>G<EFBFBD>n<EFBFBD>ration du PDF</b><p>";
$command = "export DBI_DSN=\"".$GLOBALS["DBI"]."\" ";
$command .= " ; ../../scripts/propal-tex.pl --propal=$propalid --pdf --gljroot=" . $GLOBALS["GLJ_ROOT"] ;
//$command .= " ; ../../scripts/fax-tex.pl --propal=$propalid --gljroot=" . $GLOBALS["GLJ_ROOT"] ;
$output = system($command);
print "<p>command : $command<br>";
} else {
print $db->error();
}
}
/*
*
* Creation d'une nouvelle propale
*
*/
if ($action == 'create') {
if ( $objsoc->prefix_comm ) {
$numpr = "PR-" . $objsoc->prefix_comm . "-" . strftime("%y%m%d", time());
$sql = "SELECT count(*) FROM llx_propal WHERE ref like '$numpr%'";
if ( $db->query($sql) ) {
$num = $db->result(0, 0);
$db->free();
if ($num > 0) {
$numpr .= "." . ($num + 1);
}
}
print "<form action=\"$PHP_SELF?socidp=$socidp\" method=\"post\">";
print '<table border="0" cellspacing="3"><tr><td valign="top">';
$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";
$smonth = 1;
$syear = date("Y", time());
print '<table border="0">';
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 = $smonth ; $month < $smonth + 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\">";
for ($year = $syear ; $year < $syear + 5 ; $year++) {
print "<option value=\"$year\">$year";
}
print "</select></td></tr>";
print "<input type=\"hidden\" name=\"action\" value=\"add\">";
$author = $GLOBALS["REMOTE_USER"];
print "<tr><td>Auteur</td><td><input type=\"hidden\" name=\"author\" value=\"$author\">$author</td></tr>";
print "<tr><td>Num</td><td><input name=\"ref\" value=\"$numpr\"></td></tr>\n";
/*
*
* Destinataire de la propale
*
*/
print "<tr><td>Contact</td><td><select name=\"contactidp\">\n";
$sql = "SELECT p.idp, p.name, p.firstname, p.poste, p.phone, p.fax, p.email FROM socpeople as p WHERE p.fk_soc = $socidp";
if ( $db->query($sql) ) {
$i = 0 ;
$numdest = $db->num_rows();
while ($i < $numdest) {
$contact = $db->fetch_object( $i);
print '<option value="'.$contact->idp.'"';
if ($contact->idp == $setcontact) {
print ' SELECTED';
}
print '>'.$contact->firstname.' '.$contact->name.' ['.$contact->email.']</option>';
$i++;
}
$db->free();
} else {
print $db->error();
}
print '</select>';
if ($numdest==0) {
print '<br><b>Cette societe n\'a pas de contact, veuillez en creer un avant de faire de propale</b><br>';
print '<a href=people.php3?socid='.$socidp.'&action=addcontact>Ajouter un contact</a>';
}
print '</td></tr>';
/*
*
* Projet associ<63>
*
*/
print '<tr><td valign="top">Projet</td><td><select name="projetidp">';
print '<option value="0"></option>';
$sql = "SELECT p.rowid, p.title FROM llx_projet as p WHERE p.fk_soc = $socidp";
if ( $db->query($sql) ) {
$i = 0 ;
$numprojet = $db->num_rows();
while ($i < $numprojet) {
$projet = $db->fetch_object($i);
print "<option value=\"$projet->rowid\">$projet->title</option>";
$i++;
}
$db->free();
} else {
print $db->error();
}
print '</select>';
if ($numprojet==0) {
print '<br>Cette societe n\'a pas de projet.<br>';
print '<a href=projet/fiche.php3?socidp='.$socidp.'&action=create>Cr<43>er un projet</a>';
}
print '</td></tr>';
print "</table>";
/*
*
* Liste des elements
*
*/
$sql = "SELECT p.rowid,p.label,p.ref,p.price FROM llx_product as p ORDER BY p.ref";
if ( $db->query($sql) ) {
$opt = "<option value=\"0\" SELECTED></option>";
if ($result) {
$num = $db->num_rows(); $i = 0;
while ($i < $num) {
$objp = $db->fetch_object( $i);
$opt .= "<option value=\"$objp->rowid\">[$objp->ref] $objp->label : $objp->price</option>\n";
$i++;
}
}
$db->free();
} else {
print $db->error();
}
print "<table border=1 cellspacing=0>";
print "<tr><td>Service/Produits</td></tr>\n";
print "<tr><td><select name=\"idprod1\">$opt</select></td></tr>\n";
print "<tr><td><select name=\"idprod2\">$opt</select></td></tr>\n";
print "<tr><td><select name=\"idprod3\">$opt</select></td></tr>\n";
print "<tr><td><select name=\"idprod4\">$opt</select></td></tr>\n";
print "<tr><td align=\"right\">Remise : <input size=\"6\" name=\"remise\" value=\"0\"></td></tr>\n";
print "</table>";
/*
* Si il n'y a pas de contact pour la societe on ne permet pas la creation de propale
*/
if ($numdest > 0) {
print "<input type=\"submit\" value=\"Enregistrer\">";
}
print "</td><td valign=\"top\">";
print "Commentaires :<br>";
print "<textarea name=\"note\" wrap=\"soft\" cols=\"30\" rows=\"15\"></textarea>";
print "</td></tr></table>";
print "</form>";
print "<hr noshade>";
} else {
print "Vous devez d'abord associer un prefixe commercial a cette societe" ;
}
}
/*
*
* Liste des propales
*
*/
$sql = "SELECT s.nom,s.idp, p.price, p.ref,".$db->pdate("p.datep")." as dp, p.rowid as propalid, c.id as statut, c.label as lst";
$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";
if ($socidp) {
$sql .= " AND s.idp = $socidp";
}
$sql .= " ORDER BY p.datec DESC ;";
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 "<TD><a href=\"$PHP_SELF?sortfield=lower(p.label)&sortorder=ASC\">Societe</a></td>";
print "<TD>Num</TD>";
print "<TD>Statut</TD>";
print "<TD align=\"right\">Date</TD>";
print "<TD align=\"right\">Prix</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=\"index.php3?socid=$objp->idp\">$objp->nom</a></TD>\n";
print "<TD><a href=\"propal.php3?propalid=$objp->propalid\">$objp->ref</a></TD>\n";
print "<TD>$objp->lst</TD>\n";
print "<TD align=\"right\">".strftime("%d %B %Y",$objp->dp)."</TD>\n";
print "<TD align=\"right\">".price($objp->price)."</TD><td>&nbsp;</td>\n";
print "</TR>\n";
$total = $total + $objp->price;
$i++;
}
print "<tr><td colspan=\"2\" align=\"right\"><b>Total : ".francs($total)." FF</b></td><td colspan=\"3\" align=\"right\"><b>Total : ".price($total)."</b></td><td>euros</td></tr>";
print "</TABLE>";
$db->free();
} else {
print $db->error();
print "<p>$sql";
}
$db->close();
llxFooter();
?>

122
htdocs/comm/analyse.php3 Normal file
View File

@@ -0,0 +1,122 @@
<?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("../lib/functions.inc.php3");
require("$GLJ_WWW_ROOT/../www/lib/CMailFile.class.php3");
$author = $GLOBALS["REMOTE_USER"];
llxHeader();
print "<table width=\"100%\">";
print "<tr><td>Propositions commerciales</td>";
print "<td align=\"right\"><a href=\"propal.php3\">Liste</a></td>";
print "<td align=\"right\"><a href=\"/compta/prev.php3\">CA Pr<50>visionnel</a></td>";
print "<td align=\"right\"><a href=\"$PHP_SELF?viewstatut=2\">Propal Sign<67>es</a></td></tr>";
print "</table>";
$bc[0]="bgcolor=\"#90c090\"";
$bc[1]="bgcolor=\"#b0e0b0\"";
$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 calc($st) {
global $db;
$sum = 0;
$sql = "SELECT sum(price-remise) as sum FROM llx_propal WHERE fk_statut = $st";
if ( $db->query($sql) ) {
if ($db->num_rows()) {
$arr = $db->fetch_array(0);
$sum = $arr[0];
}
}
return $sum ;
}
function calcf($st) {
global $db;
$sum = 0;
$sql = "SELECT sum(amount) as sum FROM llx_facture WHERE fk_statut = 1 and paye = $st";
if ( $db->query($sql) ) {
if ($db->num_rows()) {
$arr = $db->fetch_array(0);
$sum = $arr[0];
}
}
return $sum ;
}
/*
*
*
* Liste des propals
*
*
*/
print "<p><TABLE border=\"1\" cellspacing=\"0\" cellpadding=\"2\">";
echo '<tr><td colspan="2">Propales</td></tr>';
$po = calc(1);
$ps = calc(2);
$pns = calc(3);
print "<tr><td>Propales ouvertes</td><td align=\"right\">".price($po)."</td></tr>";
print "<tr><td>Propales sign<67>es</td><td align=\"right\">".price($ps)."</td></tr>";
print "<tr><td>Total</td><td align=\"right\">".price($ps + $po )."</td></tr>";
print "<tr><td>Propales non sign<67>es</td><td align=\"right\">".price($pns)."</td></tr>";
print "<tr><td>Total</td><td align=\"right\">".price($ps + $po + $pns)."</td></tr>";
print "</table>";
print "<p><TABLE border=\"1\" cellspacing=\"0\" cellpadding=\"2\">";
echo '<tr><td colspan="2">Factures</td></tr>';
$fnp = calcf(0);
$fp = calcf(1);
print "<tr><td>Factures non pay<61>es</td><td align=\"right\">".price($fnp)."</td></tr>";
print "<tr><td>Factures pay<61>es</td><td align=\"right\">".price($fp)."</td></tr>";
print "<tr><td>Total</td><td align=\"right\">".price($fnp + $fp )."</td></tr>";
print "</table>";
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

128
htdocs/comm/bookmark.php3 Normal file
View File

@@ -0,0 +1,128 @@
<?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 ($sortorder == "") {
$sortorder="DESC";
}
if ($sortfield == "") {
$sortfield="idp";
}
$cr["t"] = "Cab. Recrut.";
$cr["f"] = "-";
$cr[""] = "????";
$yn["t"] = "oui";
$yn["f"] = "non";
$ynn["1"] = "oui";
$ynn["0"] = "non";
if ($action == 'add') {
$sql = "INSERT INTO llx_bookmark (fk_soc, dateb, author) VALUES ($socidp, now(),'". $GLOBALS["REMOTE_USER"]."');";
if (! $db->query($sql) ) {
print $db->error();
}
}
if ($action == 'delete') {
$sql = "DELETE FROM llx_bookmark WHERE rowid=$bid AND author = '". $GLOBALS["REMOTE_USER"]."'";
$result = $db->query($sql);
}
if ($page == -1) { $page = 0 ; }
$limit = 26;
$offset = $limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
print "Bookmark<p>";
$sql = "SELECT s.idp, s.nom, cabrecrut,".$db->pdate("b.dateb")." as dateb, s.c_nom,s.c_prenom, s.cjn,st.libelle as stcomm, b.rowid as bid, b.author";
$sql .= " FROM societe as s, c_stcomm as st, llx_bookmark as b";
$sql .= " WHERE b.fk_soc = s.idp AND s.fk_stcomm = st.id AND s.datea is not null";
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit( $limit, $offset);
if ( $db->query($sql) ) {
$num = $db->num_rows();
$i = 0;
if ($sortorder == "DESC") {
$sortorder="ASC";
} else {
$sortorder="DESC";
}
print "<p><TABLE border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
print "<TR bgcolor=\"orange\">";
print "<TD>&nbsp;</TD>";
print "<TD align=\"center\"><a href=\"index.php3?sortfield=idp&sortorder=$sortorder&begin=$begin\">Id</a></TD>";
print "<TD><a href=\"index.php3?sortfield=lower(s.nom)&sortorder=$sortorder&begin=$begin\">Societe</a></td>";
print "<TD align=\"center\">Statut</TD>";
print "<TD>Auteur</TD>";
print "<TD>Date</TD>";
print "<TD>&nbsp;</TD>";
print "</TR>\n";
$var=True;
while ($i < $num) {
$obj = $db->fetch_object( $i);
$var=!$var;
$bc1="bgcolor=\"#90c090\"";
$bc2="bgcolor=\"#b0e0b0\"";
if (!$var) {
$bc=$bc1;
} else {
$bc=$bc2;
}
print "<TR $bc>";
print "<TD>" . ($i + 1 + ($limit * $page)) . "</TD>";
print "<TD align=\"center\"><b>$obj->idp</b></TD>";
print "<TD><a href=\"index.php3?socid=$obj->idp\">$obj->nom</A></TD>\n";
print "<TD align=\"center\">$obj->stcomm</TD>\n";
print "<TD>$obj->author</TD>\n";
print "<td>".strftime("%d %b %Y %H:%M", $obj->dateb) ."</td>";
print "<TD>[<a href=\"$PHP_SELF?action=delete&bid=$obj->bid\">Delete</A>]</TD>\n";
print "</TR>\n";
$i++;
}
print "</TABLE>";
$db->free();
} else {
print $db->error();
}
$db->close();
?>
<p>
Seul l'auteur d'un bookmark peut le supprimer.
<?PHP
llxFooter();
?>

View File

@@ -20,8 +20,8 @@
* *
*/ */
require("./pre.inc.php3"); require("./pre.inc.php3");
require("../lib/functions.inc.php3"); require("../contact.class.php3");
require("../lib/company.lib.php3");
llxHeader(); llxHeader();
$db = new Db(); $db = new Db();
if ($sortorder == "") { if ($sortorder == "") {
@@ -34,17 +34,7 @@ $bc[0]="bgcolor=\"#c0f0c0\"";
$bc[1]="bgcolor=\"#b0e0b0\""; $bc[1]="bgcolor=\"#b0e0b0\"";
$bc2[0]="bgcolor=\"#c9f000\""; $bc2[0]="bgcolor=\"#c9f000\"";
$bc2[1]="bgcolor=\"#b9e000\""; $bc2[1]="bgcolor=\"#b9e000\"";
$active["1"] = "Offres en ligne";
$active["-1"] = "Moderation";
$active["-2"] = "Refus<EFBFBD>es";
$active["0"] = "R<EFBFBD>daction";
$active["-3"] = "D<EFBFBD>sactiv<EFBFBD>es";
$active["-4"] = "Supprim<EFBFBD>es";
$cr["t"] = "Cab. Recrut.";
$cr["f"] = "-";
$cr[""] = "????";
$cr["1"] = "Cab. Recrut.";
$cr["0"] = "-";
$yn["t"] = "oui"; $yn["t"] = "oui";
$yn["f"] = "non"; $yn["f"] = "non";
@@ -58,12 +48,6 @@ if ($action == 'attribute_prefix') {
$prefix_attrib = soc_attribute_prefix($db, $socid); $prefix_attrib = soc_attribute_prefix($db, $socid);
} }
if ($action == 'cabrecrut') {
if ($selectvalue) {
$sql = "UPDATE societe SET cabrecrut='$selectvalue' WHERE idp=$socid";
$result = $db->query($sql);
}
}
if ($action == 'recontact') { if ($action == 'recontact') {
$dr = mktime(0, 0, 0, $remonth, $reday, $reyear); $dr = mktime(0, 0, 0, $remonth, $reday, $reyear);
$sql = "INSERT INTO llx_soc_recontact (fk_soc, datere, author) VALUES ($socid, $dr,'". $GLOBALS["REMOTE_USER"]."')"; $sql = "INSERT INTO llx_soc_recontact (fk_soc, datere, author) VALUES ($socid, $dr,'". $GLOBALS["REMOTE_USER"]."')";
@@ -90,7 +74,7 @@ if ($action == 'stcomm') {
} }
if ($actioncommid) { if ($actioncommid) {
$sql = "INSERT INTO actioncomm (datea, fk_action, fk_soc, author) VALUES ('$dateaction',$actioncommid,$socid,'" . $GLOBALS["REMOTE_USER"] . "')"; $sql = "INSERT INTO actioncomm (datea, fk_action, fk_soc, fk_user_author) VALUES ('$dateaction',$actioncommid,$socid,'" . $user->id . "')";
$result = @$db->query($sql); $result = @$db->query($sql);
if (!$result) { if (!$result) {
@@ -167,7 +151,7 @@ if ($mode == 'search')
*/ */
if ($socid > 0) { if ($socid > 0) {
$sql = "SELECT s.idp, s.nom, ".$db->pdate("s.datec")." as dc,".$db->pdate("s.datel")." as dl,".$db->pdate("s.datem")." as dm, ".$db->pdate("s.datea")." as da, s.intern, s.cjn, s.c_nom, s.c_prenom, s.c_tel, s.c_mail, s.tel, s.fax, s.fplus, s.cjn, s.viewed, st.libelle as stcomm, s.fk_stcomm, s.url,s.address,s.cp,s.ville, s.note,s.karma,s.off_acc, s.off_ref,s.view_res_coord, t.libelle as typent, s.cabrecrut, e.libelle as effectif, s.siren, s.prefix_comm, s.services,s.parent, s.description FROM societe as s, c_stcomm as st, c_typent as t, c_effectif as e "; $sql = "SELECT s.idp, s.nom, ".$db->pdate("s.datec")." as dc, s.tel, s.fax, st.libelle as stcomm, s.fk_stcomm, s.url,s.address,s.cp,s.ville, s.note, t.libelle as typent, e.libelle as effectif, s.siren, s.prefix_comm, s.services,s.parent, s.description FROM societe as s, c_stcomm as st, c_typent as t, c_effectif as e ";
$sql .= " WHERE s.fk_stcomm=st.id AND s.fk_typent = t.id AND s.fk_effectif = e.id"; $sql .= " WHERE s.fk_stcomm=st.id AND s.fk_typent = t.id AND s.fk_effectif = e.id";
if ($to == 'next') { if ($to == 'next') {
@@ -231,9 +215,7 @@ if ($socid > 0) {
* *
*/ */
print "<table width=\"100%\" border=\"0\" cellspacing=\"1\">\n"; print "<table width=\"100%\" border=\"0\" cellspacing=\"1\">\n";
/*
*
*/
print "<tr><td><big>N<> $objsoc->idp - $objsoc->nom - [$objsoc->stcomm]</big></td>"; print "<tr><td><big>N<> $objsoc->idp - $objsoc->nom - [$objsoc->stcomm]</big></td>";
print "<td bgcolor=\"#e0E0E0\" align=\"center\"><a href=\"bookmark.php3?socidp=$objsoc->idp&action=add\">[Bookmark]</a></td>"; print "<td bgcolor=\"#e0E0E0\" align=\"center\"><a href=\"bookmark.php3?socidp=$objsoc->idp&action=add\">[Bookmark]</a></td>";
print "<td bgcolor=\"#e0E0E0\" align=\"center\"><a href=\"projet/fiche.php3?socidp=$objsoc->idp&action=create\">[Projet]</a></td>"; print "<td bgcolor=\"#e0E0E0\" align=\"center\"><a href=\"projet/fiche.php3?socidp=$objsoc->idp&action=create\">[Projet]</a></td>";
@@ -243,9 +225,11 @@ if ($socid > 0) {
print "<td><a href=\"../tech/soc/soc.php3?socid=$objsoc->idp\">Fiche Technique</a></td>"; print "<td><a href=\"../tech/soc/soc.php3?socid=$objsoc->idp\">Fiche Technique</a></td>";
print "<td bgcolor=\"#e0E0E0\" align=\"center\">[<a href=\"../soc.php3?socid=$objsoc->idp&action=edit\">Editer</a>]</td>"; print "<td bgcolor=\"#e0E0E0\" align=\"center\">[<a href=\"../soc.php3?socid=$objsoc->idp&action=edit\">Editer</a>]</td>";
print "</tr></table>"; print "</tr></table>";
if ($objsoc->parent > 0) { /*
print "<hr>Soci<63>t<EFBFBD> rattach<63> au cabinet <a href=\"$PHP_SELF?socid=$objsoc->parent\">$objsoc->parent</a>"; *
} *
*/
print "<hr>"; print "<hr>";
print "<table width=\"100%\" border=0><tr>\n"; print "<table width=\"100%\" border=0><tr>\n";
print "<td valign=\"top\">"; print "<td valign=\"top\">";
@@ -267,118 +251,58 @@ if ($socid > 0) {
print "<tr><td>Site</td><td colspan=\"3\"><a href=\"http://$objsoc->url\">$objsoc->url</a>&nbsp;</td></tr>"; print "<tr><td>Site</td><td colspan=\"3\"><a href=\"http://$objsoc->url\">$objsoc->url</a>&nbsp;</td></tr>";
print "<tr><td>Contact </td><td colspan=\"3\"><b>$objsoc->c_nom $objsoc->c_prenom</b>&nbsp;</td></tr>";
print "<tr><td>tel</td><td><b>$objsoc->c_tel</b>&nbsp;</td><td colspan=\"2\">email : <b>$objsoc->c_mail</b>&nbsp;</td></tr>";
print "</table>"; print "</table>";
/* /*
* *
*/ */
print "</td>\n"; print "</td>\n";
print "<td valign=\"top\"><table border=0 width=\"100%\" cellspacing=0 bgcolor=#e0e0e0>"; print '<td valign="top" width="50%">';
if ($objsoc->dl > 0) { print '<table border=0 width="100%" cellspacing=0 bgcolor=#e0e0e0>';
$datel = strftime("%d %b %Y %H:%M", $objsoc->dl);
} else {
$datel = "Pas d'infos";
}
print "<tr><td>Derni<6E>re connexion</td><td align=center><b>$datel</b></td></tr>";
print "<tr><td>Cr<EFBFBD><EFBFBD>e le</td><td align=center><b>" . strftime("%d %b %Y %H:%M", $objsoc->dc) . "</b></td></tr>"; print "<tr><td>Cr<EFBFBD><EFBFBD>e le</td><td align=center><b>" . strftime("%d %b %Y %H:%M", $objsoc->dc) . "</b></td></tr>";
//print "<tr><td>Derni<6E>re modif le</td><td align=center><b>" . strftime("%d %b %Y %H:%M", $objsoc->dm) . "</b></td></tr>";
print "<tr><td>Fiche Entreprise</td><td align=center><b>".$yn[$objsoc->fplus]."</b></td></tr>" ;
print "<tr bgcolor=\"#d0d0d0\"><td>Coordonnees CV</td><td align=center><b>".$yn["$objsoc->view_res_coord"]."</b>&nbsp;</td></tr>" ;
print "<tr bgcolor=\"#d0d0d0\"><td><b>Contacts CV</b></td><td align=center><b>".$yn["$objsoc->services"]."</b>&nbsp;</td></tr>" ;
if ($objsoc->cabrecrut == 1) { print '<tr><td colspan="2"><hr>Statut commercial</td></tr>';
print "<tr bgcolor=\"white\"><td><b>Cab. Recrut.</b> : Oui</td>"; print '<tr><td colspan="2">';
} elseif ($objsoc->cabrecrut == 0) { /*
print "<tr><td>Cab. Recrut. : Non</td>"; *
} else { * Liste des statuts commerciaux
print "<tr><td>Cab. Recrut. : ???</td>"; *
} */
print "<td><a href=\"$PHP_SELF?socid=$objsoc->idp&action=changevalue&type=cabrecrut\">changer</a></td></tr>"; $limliste = 5 ;
print "<table width=\"100%\" cellspacing=0 border=0 cellpadding=2>\n";
print "<tr><td colspan=\"2\">"; $sql = "SELECT a.id, ".$db->pdate("a.datel")." as da, c.libelle, a.author ";
//print "<hr noshade size=1></td></tr>"; $sql .= " FROM socstatutlog as a, c_stcomm as c WHERE a.fk_soc = $objsoc->idp AND c.id=a.fk_statut ORDER by a.datel DESC";
//print "<tr><td>Cojonet</td><td align=center><b>".$yn["$objsoc->cjn"]."</b></td></tr>" ;
//print "<tr><td>Consult Fiche</td><td align=center><b>$objsoc->viewed</b></td></tr>";
print "<tr><td valign=\"top\">";
print "<hr noshade size=1>";
print "<table border=0 cellspacing=0>";
print "<tr><td><b>Karma</b></td><td>:</td><td align=center><b>$objsoc->karma</b></td></tr>";
print "<tr><td><b>Nb d'acceptation</b></td><td>:</td><td align=center><b>$objsoc->off_acc</b></td></tr>";
print "<tr><td><b>Nb de refus</b></td><td>:</td><td align=center><b>$objsoc->off_ref</b></td></tr>";
$sql = "SELECT count(idp) as cc, active FROM offre WHERE fk_soc = $objsoc->idp GROUP by active ORDER BY active DESC";
if ( $db->query($sql) ) { if ( $db->query($sql) ) {
$i = 0 ; $num = $db->num_rows(); $tag = True;
$i = 0 ; $num = $db->num_rows(); while ($i < $num && $i < $limliste) {
while ($i < $num) {
$obj = $db->fetch_object( $i); $obj = $db->fetch_object( $i);
print "<tr><td>".$active["$obj->active"] . "</td><td>:</td><td>$obj->cc</tr>"; if ($tag) {
print "<tr bgcolor=\"e0e0e0\">";
} else {
print "<tr>";
}
print "<td>". strftime("%d %b %Y %H:%M", $obj->da) ."</td>";
print "<td>$obj->libelle</td>";
print "<td>$obj->author</td>";
print "</tr>\n";
$i++; $i++;
$tag = !$tag;
} }
$db->free(); $db->free();
if ($num > $limliste) {
print "<tr><td>suite ...</td></tr>";
}
} else { } else {
print $db->error(); print $db->error();
} }
print "</table></td>"; print "</table>";
print '</td></tr>';
print "<td valign=\"top\"><hr noshade size=1>"; /*
print "<table cellspacing=0 border=0>"; *
print "<tr><td><b>CV consult<6C>s</b></td>"; */
$sql = "SELECT week1 + week2 + week3 + week4 as t, week1, week2, week3, week4 FROM soc_resviewed_byweek WHERE fk_soc = $objsoc->idp"; print '</table>';
if ( $db->query($sql) ) { print '</td></tr>';
$i = 0 ; $num = $db->num_rows();
while ($i < $num) {
$obj = $db->fetch_object( $i);
print "<td>: $obj->t ( $obj->week1 - $obj->week2 - $obj->week3 - $obj->week4 )</td></tr>";
$i++;
}
$db->free();
} else {
print $db->error();
}
print "</tr>";
print "<tr><td><b>Contacts</b></td>";
$sql = "SELECT week1 + week2 + week3 + week4 as t, week1, week2, week3, week4 FROM soc_rescontact_byweek WHERE fk_soc = $objsoc->idp";
if ( $db->query($sql) ) {
$i = 0 ; $num = $db->num_rows();
while ($i < $num) {
$obj = $db->fetch_object( $i);
print "<td>: $obj->t ( $obj->week1 - $obj->week2 - $obj->week3 - $obj->week4 )</td></tr>";
$i++;
}
$db->free();
} else {
print $db->error();
}
$sql = "SELECT count(idp) as cc FROM abo_soc WHERE fksoc = $objsoc->idp GROUP by active";
$result = $db->query($sql);
$i = 0 ; $num = $db->num_rows();
while ($i < $num) {
$obj = $db->fetch_object( $i);
print "<tr><td>Abonnements</td><td>: $obj->cc</td></tr>";
$i++;
}
$sql = "SELECT count(idp) as cc FROM socfollowresume WHERE fk_soc = $objsoc->idp";
if ( $db->query($sql) ) {
$i = 0 ; $num = $db->num_rows();
while ($i < $num) {
$obj = $db->fetch_object( $i);
print "<tr><td>Cand. suivis</td><td>: $obj->cc</td></tr>";
$i++;
}
$db->free();
} else {
print $db->error();
}
print "</table>\n";
print "</td></tr>";
print "</table></td></tr>\n";
/* /*
* *
*/ */
@@ -575,55 +499,25 @@ if ($socid > 0) {
} }
print "</table>"; print "</table>";
print "\n<hr noshade size=1>\n"; print "\n<hr noshade size=1>\n";
/* /*
* *
*/ */
print "<table width=\"100%\" cellspacing=0 border=0 cellpadding=2>\n<tr><td valign=\"top\">\n"; print '<table width="100%" cellspacing=0 border=0 cellpadding=2>';
/* print '<tr>';
* print '<td valign="top">';
* Liste des statuts commerciaux
*
*/
$limliste = 5 ;
print "<table width=\"100%\" cellspacing=0 border=0 cellpadding=2>\n";
$sql = "SELECT a.id, ".$db->pdate("a.datel")." as da, c.libelle, a.author ";
$sql .= " FROM socstatutlog as a, c_stcomm as c WHERE a.fk_soc = $objsoc->idp AND c.id=a.fk_statut ORDER by a.datel DESC";
if ( $db->query($sql) ) {
$i = 0 ; $num = $db->num_rows(); $tag = True;
while ($i < $num && $i < $limliste) {
$obj = $db->fetch_object( $i);
if ($tag) {
print "<tr bgcolor=\"e0e0e0\">";
} else {
print "<tr>";
}
print "<td>". strftime("%d %b %Y %H:%M", $obj->da) ."</td>";
print "<td>$obj->libelle</td>";
print "<td>$obj->author</td>";
print "</tr>\n";
$i++;
$tag = !$tag;
}
$db->free();
if ($num > $limliste) {
print "<tr><td>suite ...</td></tr>";
}
} else {
print $db->error();
}
print "</table>";
print "</td><td valign=\"top\">";
/* /*
* *
* Listes des actions * Listes des actions
* *
*/ */
$sql = "SELECT a.id, ".$db->pdate("a.datea")." as da, c.libelle, a.author, a.propalrowid "; $sql = "SELECT a.id, ".$db->pdate("a.datea")." as da, c.libelle, u.code, a.propalrowid, a.fk_user_author, fk_contact, u.rowid ";
$sql .= " FROM actioncomm as a, c_actioncomm as c WHERE a.fk_soc = $objsoc->idp AND c.id=a.fk_action ORDER BY a.datea DESC, a.id DESC"; $sql .= " FROM actioncomm as a, c_actioncomm as c, llx_user as u ";
$sql .= " WHERE a.fk_soc = $objsoc->idp ";
$sql .= " AND u.rowid = a.fk_user_author";
$sql .= " AND c.id=a.fk_action ";
$sql .= " ORDER BY a.datea DESC, a.id DESC";
if ( $db->query($sql) ) { if ( $db->query($sql) ) {
print "<table width=\"100%\" cellspacing=0 border=0 cellpadding=2>\n"; print "<table width=\"100%\" cellspacing=0 border=0 cellpadding=2>\n";
print '<tr><td><a href="actioncomm.php3?socid='.$objsoc->idp.'">Actions</a></td></tr>'; print '<tr><td><a href="actioncomm.php3?socid='.$objsoc->idp.'">Actions</a></td></tr>';
@@ -643,7 +537,20 @@ if ($socid > 0) {
} else { } else {
print "<td>$obj->libelle</td>"; print "<td>$obj->libelle</td>";
} }
print "<td>$obj->author</td>"; /*
* Contact pour cette action
*
*/
if ($obj->fk_contact) {
$contact = new Contact($db);
$contact->fetch($obj->fk_contact);
print '<td><a href="people.php3?socid='.$objsoc->idp.'&contactid='.$contact->id.'">'.$contact->fullname.'</a></td>';
} else {
print '<td>&nbsp;</td>';
}
/*
*/
print '<td><a href="../user.php3">'.$obj->code.'</a></td>';
print "</tr>\n"; print "</tr>\n";
$i++; $i++;
$tag = !$tag; $tag = !$tag;
@@ -656,89 +563,13 @@ if ($socid > 0) {
} }
print "</td></tr></table>"; print "</td></tr></table>";
/* /*
* Note sur la societe *
* Notes sur la societe
*
*/ */
print '<table border="1" width="100%" cellspacing="0" bgcolor="#e0e0e0">'; print '<table border="1" width="100%" cellspacing="0" bgcolor="#e0e0e0">';
print "<tr><td>".nl2br($objsoc->note)."</td></tr>"; print "<tr><td>".nl2br($objsoc->note)."</td></tr>";
print "</table>"; print "</table>";
/*
*
* Offres
*
*/
$sql = "SELECT o.idp, o.titre, ";
$sql .= $db->pdate("o.datea")." as da, ".$db->pdate("o.dated")." as dd,";
$sql .= $db->pdate("o.datec")." as dc,o.active,o.deacmeth, o.site FROM offre as o";
$sql .= " WHERE o.fk_soc = $objsoc->idp AND o.created =1";
$sql .= " ORDER BY o.datea DESC";
$result = $db->query($sql);
$num = $db->num_rows();
$i = 0;
if ($num > 0)
{
$bc1="bgcolor=\"#c0f0c0\"";
$bc3="bgcolor=\"#90c090\"";
$bc2="bgcolor=\"#b0e0b0\"";
print "<p><TABLE border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
print "<TR bgcolor=\"orange\">";
print "<TD>$num</td>";
print "<TD><a href=\"index.php3?sortfield=s.idp&sortorder=$sortorder\">IDP</a></TD>";
print "<TD>Site</TD>";
print "<TD>Statut</TD>";
print "<TD><a href=\"index.php3?sortfield=s.nom&sortorder=$sortorder\">Titre</a></td>";
print "<TD align=\"center\">Cr&eacute;&eacute;e</TD>";
print "<TD align=\"center\">Activ&eacute;e</TD>";
print "<TD align=\"center\"><a href=\"index.php3?sortfield=s.datea&sortorder=$sortorder\">Dated</a></TD>";
print "<TD align=\"center\">Meth</TD>";
print "</TR>\n";
$var=True;
while ($i < $num) {
$objo = $db->fetch_object( $i);
$var=!$var;
if (!$var) {
$bc=$bc1;
} else {
$bc=$bc2;
}
if ($objo->active < -2) {
$bc = $bc3;
}
print "<TR $bc>";
print "<TD>" . ($i + 1 + ($limit * $page)) . "</TD>";
print "<TD>$objo->idp</TD>";
print "<TD align=\"center\">$objo->site</TD>";
if ($objo->active == 1) {
print "<TD><b>" . $active["$objo->active"] ."</b></TD>";
} else {
print "<TD>" . $active["$objo->active"] ."</TD>";
}
print "<TD><a href=\"../prod/offre.php3?id=$objo->idp\">$objo->titre</A></TD>\n";
print "<TD align=\"center\">" . strftime("%d %b %Y", $objo->dc) . "</TD>";
print "<TD align=\"center\">" . strftime("%d %b %Y", $objo->da) . "</TD>";
if ($objo->active <> -2) {
print "<TD align=\"center\">" . strftime("%d %b %Y", $objo->dd) . "</TD>";
} else {
print "<TD align=\"center\">&nbsp;</TD>";
}
if ($objo->active == -3) {
print "<TD>".$deacmeth[$objo->deacmeth]."</TD>";
} else {
print "<TD align=\"center\">&nbsp;</TD>";
}
print "</TR>\n";
$i++;
}
print "</TABLE>";
}
/* /*
* *
* *
@@ -790,43 +621,11 @@ if ($socid > 0) {
print "</form>\n"; print "</form>\n";
/* /*
*
* Listes des actions
* *
*/ */
$sql = "SELECT ".$db->pdate("sc.datec")." as da, sc.fk_cand "; }
$sql .= " FROM soccontact as sc WHERE sc.fk_soc = $objsoc->idp ORDER BY sc.datec DESC";
$result = $db->query($sql);
$num = $db->num_rows();
if ($num > 0)
{
$tag = True;
$i = 0 ;
print "<table width=100%><tr><td valign=top width=50%>";
print "Contacts<hr noshade><table cellspacing=0 border=0 cellpadding=2>";
print "<tr><td>date</td><td>Candidat</td></tr>";
while ($i < $num) {
$obj = $db->fetch_object( $i);
if ($tag) {
print "<tr bgcolor=\"e0e0e0\">";
} else { } else {
print "<tr>"; print $db->error() . "<br>" . $sql;
}
print "<td>". strftime("%d %b %Y %H:%M", $obj->da) ."</td>";
print "<td align=\"center\">$obj->fk_cand</td>";
print "</tr>\n";
$i++;
$tag = !$tag;
}
print "</table>";
print "</td><td valign=top width=50%>";
print "Description de la soci<63>t<EFBFBD><hr noshade>$objsoc->description";
print "</td></tr></table>";
}
}
} }
} else { } else {
/* /*
@@ -839,7 +638,7 @@ if ($socid > 0) {
$bc[1]="bgcolor=\"#90c090\""; $bc[1]="bgcolor=\"#90c090\"";
$bc[0]="bgcolor=\"#b0e0b0\""; $bc[0]="bgcolor=\"#b0e0b0\"";
$sql = "SELECT s.idp, s.nom, cabrecrut,".$db->pdate("s.datec")." as datec, ".$db->pdate("s.datea")." as datea, s.c_nom,s.c_prenom,s.c_tel,s.c_mail, s.cjn,st.libelle as stcomm, s.prefix_comm FROM societe as s, c_stcomm as st WHERE s.fk_stcomm = st.id AND s.datea IS NOT NULL"; $sql = "SELECT s.idp, s.nom, ".$db->pdate("s.datec")." as datec, ".$db->pdate("s.datea")." as datea, st.libelle as stcomm, s.prefix_comm FROM societe as s, c_stcomm as st WHERE s.fk_stcomm = st.id AND s.client=1";
if (strlen($stcomm)) { if (strlen($stcomm)) {
$sql .= " AND s.fk_stcomm=$stcomm"; $sql .= " AND s.fk_stcomm=$stcomm";
@@ -849,14 +648,6 @@ if ($socid > 0) {
$sql .= " AND upper(s.nom) like '$begin%'"; $sql .= " AND upper(s.nom) like '$begin%'";
} }
if ($aclasser==1) {
$sql .= " AND cabrecrut is null";
}
if ($coord == 1) {
$sql .= " AND view_res_coord=1";
}
if ($socname) { if ($socname) {
$sql .= " AND lower(s.nom) like '%".strtolower($socname)."%'"; $sql .= " AND lower(s.nom) like '%".strtolower($socname)."%'";
$sortfield = "lower(s.nom)"; $sortfield = "lower(s.nom)";
@@ -881,7 +672,7 @@ if ($socid > 0) {
print "<TD><a href=\"index.php3?sortfield=lower(s.nom)&sortorder=$sortorder&begin=$begin\">Societe</a></td>"; print "<TD><a href=\"index.php3?sortfield=lower(s.nom)&sortorder=$sortorder&begin=$begin\">Societe</a></td>";
print "<TD>Contact</TD>"; print "<TD>Contact</TD>";
print "<TD>email</TD>"; print "<TD>email</TD>";
print "<TD align=\"center\">Statut</TD><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>"; print "<TD align=\"center\">Statut</TD><td>&nbsp;</td><td>&nbsp;</td>";
print "</TR>\n"; print "</TR>\n";
$var=True; $var=True;
while ($i < $num) { while ($i < $num) {
@@ -892,12 +683,11 @@ if ($socid > 0) {
print "<TR $bc[$var]>"; print "<TR $bc[$var]>";
print "<TD align=\"center\"><b>$obj->idp</b></TD>"; print "<TD align=\"center\"><b>$obj->idp</b></TD>";
print "<TD><a href=\"index.php3?socid=$obj->idp\">$obj->nom</A></td>\n"; print "<TD><a href=\"index.php3?socid=$obj->idp\">$obj->nom</A></td>\n";
print "<TD>$obj->c_nom $obj->c_prenom</TD>\n"; print "<TD>&nbsp;</TD>\n";
print "<TD>$obj->c_mail</TD>\n"; print "<TD>&nbsp;</TD>\n";
print "<TD align=\"center\">$obj->stcomm</TD>\n"; print "<TD align=\"center\">$obj->stcomm</TD>\n";
print "<TD align=\"center\">$obj->prefix_comm&nbsp;</TD>\n"; print "<TD align=\"center\">$obj->prefix_comm&nbsp;</TD>\n";
print "<TD><a href=\"addpropal.php3?socidp=$obj->idp&action=create\">[Propal]</A></td>\n"; print "<TD><a href=\"addpropal.php3?socidp=$obj->idp&action=create\">[Propal]</A></td>\n";
print "<TD><a href=\"ventes.php3?socid=$obj->idp&action=add\">[Ventes]</A></TD>\n";
print "</TR>\n"; print "</TR>\n";
$i++; $i++;
} }
@@ -909,5 +699,5 @@ if ($socid > 0) {
} }
$db->close(); $db->close();
llxFooter(); llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?> ?>

249
htdocs/comm/people.php3 Normal file
View File

@@ -0,0 +1,249 @@
<?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");
$db = new Db();
if ($sortorder == "") {
$sortfield="lower(s.nom)";
$sortorder="ASC";
}
$active["1"] = "Offres en ligne";
$active["-1"] = "Moderation";
$active["-2"] = "Refus<EFBFBD>es";
$active["0"] = "R<EFBFBD>daction";
$active["-3"] = "D<EFBFBD>sactiv<EFBFBD>es";
$active["-4"] = "Supprim<EFBFBD>es";
$yn["t"] = "oui";
$yn["f"] = "non";
$deacmeth["b"] = "robots";
if ($action == 'add') {
$email = trim($email);
if (strlen(trim($name)) + strlen(trim($firstname)) > 0) {
$sql = "INSERT INTO socpeople (datec, fk_soc,name, firstname, poste, phone,fax,email) ";
$sql .= " VALUES (now(),$socid,'$name','$firstname','$poste','$phone','$fax','$email')";
$result = $db->query($sql);
if ($result) {
Header("Location: index.php3?socid=$socid");
}
}
}
if ($action == 'update') {
if (strlen(trim($name)) + strlen(trim($firstname)) > 0) {
$email = trim($email);
$sql = "UPDATE socpeople set name='$name', firstname='$firstname', poste='$poste', phone='$phone',fax='$fax',email='$email', note='$note'";
$sql .= " WHERE idp=$contactid";
$result = $db->query($sql);
if ($result) {
Header("Location: index.php3?socid=$socid");
}
}
}
llxHeader();
if ($page == -1) { $page = 0 ; }
$limit = 26;
$offset = $limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
if ($socid > 0) {
$sql = "SELECT s.idp, s.nom, ".$db->pdate("s.datec")." as dc, s.tel, s.fax, st.libelle as stcomm, s.fk_stcomm, s.url,s.cp,s.ville, s.note FROM societe as s, c_stcomm as st ";
$sql .= " WHERE s.fk_stcomm=st.id";
if ($to == 'next') {
$sql .= " AND s.idp > $socid ORDER BY idp ASC LIMIT 1";
} else {
$sql .= " AND s.idp = $socid";
}
$result = $db->query($sql);
if ($result) {
$objsoc = $db->fetch_object( 0);
print "<DIV align=\"center\">";
print "<A href=\"$PHP_SELF?page=$pageprev\">&lt;-Prev</A>\n| ";
for ($i = 65 ; $i < 91; $i++) {
print "<A href=\"index.php3?begin=" . chr($i) . "\" class=\"T3\">" . chr($i) . "</A> | ";
}
print " <A href=\"$PHP_SELF?socid=$objsoc->idp&to=next\">Next-&gt;</A>\n";
print "</DIV>";
$dac = strftime("%Y-%m-%d %H:%M", time());
if ($errmesg) {
print "<b>$errmesg</b><br>";
}
/*
*
*
*/
print "<br><table width=\"100%\" border=\"0\" cellspacing=\"1\">\n";
print "<tr><td><big>N<> $objsoc->idp - <a href=\"index.php3?socid=$objsoc->idp\">$objsoc->nom</a> - [$objsoc->stcomm] </td>";
print "<td align=\"center\"><a href=\"socnote.php3?socid=$socid\">Notes</a></big></td>";
print "<td bgcolor=\"#e0E0E0\" align=\"center\">[<a href=\"people.php3?socid=$socid&action=addcontact\">Ajouter un contact</a>]</td>";
print '</td></tr></table>';
print "<hr>";
print "<table width=\"100%\" border=0><tr>\n";
print "<td valign=\"top\">";
print "tel : $objsoc->tel<br>";
print "fax : $objsoc->fax<br>";
print "$objsoc->cp $objsoc->ville<br>";
if ($objsoc->url) {
print "<a href=\"http://$objsoc->url\">$objsoc->url</a><br>";
}
print "<br>Contact : <br><b>$objsoc->c_nom $objsoc->c_prenom</b>";
print "<br>tel : <b>$objsoc->c_tel</b>";
print "<br>email : <b>$objsoc->c_mail</b>";
print "</td>\n";
print "<td valign=\"top\"><table border=0 width=\"100%\" cellspacing=0 bgcolor=#e0e0e0>";
print "<tr><td>Cr<43><72>e le</td><td align=center><b>" . strftime("%d %b %Y %H:%M", $objsoc->dc) . "</b></td></tr>";
print "<tr><td>Derni<6E>re modif le</td><td align=center><b>" . strftime("%d %b %Y %H:%M", $objsoc->dm) . "</b></td></tr>";
print "<tr><td>Fiche soci<63>t<EFBFBD></td><td align=center><b>".$yn[$objsoc->fplus]."</b></td></tr>" ;
print "<tr><td valign=\"top\">";
print "<hr noshade size=1>";
print "<table border=0 cellspacing=0>";
print "</table></td>";
print "<td valign=\"top\"><hr noshade size=1>";
print "<table cellspacing=0 border=0>";
print "</table></td>\n";
print "</tr>";
print "</table></td></tr>\n";
print "</table>";
print "<hr noshade size=1>";
/*
*
*/
print "<table border=0 width=\"100%\" cellspacing=0 bgcolor=#e0e0e0>";
print "<tr><td>".nl2br($objsoc->note)."</td></tr>";
print "</table>";
$bc1="bgcolor=\"#c0f0c0\"";
$bc3="bgcolor=\"#90c090\"";
$bc2="bgcolor=\"#b0e0b0\"";
} else {
print $db->error();
}
print "<P><table width=\"100%\" cellspacing=0 border=1 cellpadding=2>";
print "<tr><td><b>Pr<50>nom Nom</b></td>";
print "<td><b>Poste</b></td><td><b>Tel</b></td>";
print "<td><b>Fax</b></td><td><b>Email</b></td>";
$sql = "SELECT p.name, p.firstname, p.poste, p.phone, p.fax, p.email FROM socpeople as p WHERE p.fk_soc = $objsoc->idp ORDER by p.datec";
$result = $db->query($sql);
$i = 0 ; $num = $db->num_rows(); $tag = True;
while ($i < $num) {
$obj = $db->fetch_object( $i);
if ($tag) {
print "<tr bgcolor=\"e0e0e0\">";
} else {
print "<tr>";
}
print "<td>$obj->firstname $obj->name</td>";
print "<td>$obj->poste&nbsp;</td>";
print "<td>$obj->phone&nbsp;</td>";
print "<td>$obj->fax&nbsp;</td>";
print "<td><a href=\"mailto:$obj->email\">$obj->email</a>&nbsp;</td>";
print "</tr>\n";
$i++;
$tag = !$tag;
}
print "</table>";
if ($action == 'addcontact') {
print "<form method=\"post\" action=\"people.php3?socid=$socid\">";
print "<input type=\"hidden\" name=\"action\" value=\"add\">";
print "<table border=0>";
print "<tr><td>Nom</td><td><input name=\"name\" type=\"text\" size=\"20\" maxlength=\"80\"></td>";
print "<td>Prenom</td><td><input name=\"firstname\" type=\"text\" size=\"15\" maxlength=\"80\"></td></tr>";
print "<tr><td>Poste</td><td colspan=\"3\"><input name=\"poste\" type=\"text\" size=\"50\" maxlength=\"80\"></td></tr>";
print "<tr><td>Tel</td><td><input name=\"phone\" type=\"text\" size=\"18\" maxlength=\"80\"></td>";
print "<td>Fax</td><td><input name=\"fax\" type=\"text\" size=\"18\" maxlength=\"80\"></td></tr>";
print "<tr><td>Email</td><td colspan=\"3\"><input name=\"email\" type=\"text\" size=\"50\" maxlength=\"80\"></td></tr>";
print "</table>";
print "<input type=\"submit\" value=\"Ajouter\">";
print "</form>";
}
/*
*
* Edition du contact
*
*/
if ($action == 'editcontact') {
$sql = "SELECT p.idp, p.name, p.firstname, p.poste, p.phone, p.fax, p.email, p.note";
$sql .= " FROM socpeople as p WHERE p.idp = $contactid";
$result = $db->query($sql);
$num = $db->num_rows();
if ( $num >0 ) {
$obj = $db->fetch_object( 0);
}
print "<form method=\"post\" action=\"people.php3?socid=$socid\">";
print "<input type=\"hidden\" name=\"action\" value=\"update\">";
print "<input type=\"hidden\" name=\"contactid\" value=\"$contactid\">";
print "<table border=0>";
print "<tr><td>Num<EFBFBD>ro</td><td>$obj->idp</td>";
print "<tr><td>Nom</td><td><input name=\"name\" type=\"text\" size=\"20\" maxlength=\"80\" value=\"$obj->name\"></td>";
print "<td>Prenom</td><td><input name=\"firstname\" type=\"text\" size=\"15\" maxlength=\"80\" value=\"$obj->firstname\"></td></tr>";
print "<tr><td>Poste</td><td colspan=\"3\"><input name=\"poste\" type=\"text\" size=\"50\" maxlength=\"80\" value=\"$obj->poste\"></td></tr>";
print "<tr><td>Tel</td><td><input name=\"phone\" type=\"text\" size=\"18\" maxlength=\"80\" value=\"$obj->phone\"></td>";
print "<td>Fax</td><td><input name=\"fax\" type=\"text\" size=\"18\" maxlength=\"80\" value=\"$obj->fax\"></td></tr>";
print "<tr><td>Email</td><td colspan=\"3\"><input name=\"email\" type=\"text\" size=\"50\" maxlength=\"80\" value=\"$obj->email\"></td></tr>";
print '<tr><td valign="top">Note</td><td colspan="3"><textarea wrap="soft" cols="40" rows="10" name="note">'.$obj->note.'</textarea></td></tr>';
print "</table>";
print "<input type=\"submit\" value=\"Modifier\">";
print "</form>";
}
} else {
print "Error";
}
$db->free();
$db->close();
llxFooter();
?>

View File

@@ -19,11 +19,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* *
*/ */
$root = "/$PREFIX";
require ("/$GLJ_WWW_ROOT/conf/$GLJ_PREFIX.$GLJ_COUNTRY.inc.php3");
require ("/$GLJ_WWW_ROOT/../www/lib/db.lib.php3");
require("../main.inc.php3"); require("../main.inc.php3");
function llxHeader($head = "", $urlp = "") { function llxHeader($head = "", $urlp = "") {
@@ -55,18 +50,9 @@ function llxHeader($head = "", $urlp = "") {
print "</td></tr>"; print "</td></tr>";
print "<tr><td valign=\"top\" align=\"right\">"; print "<tr><td valign=\"top\" align=\"right\">";
print "<CENTER><A href=\"".$urlp."index.php3\">Societe</A></CENTER>\n"; print "<CENTER><A href=\"".$urlp."index.php3\">Soci<EFBFBD>t<EFBFBD>s</A></CENTER>\n";
print "<A href=\"".$urlp."index.php3?stcomm=1\">A contacter</A><BR>\n"; print "<A href=\"".$urlp."../soc.php3?&action=create\">Nouvelle soci<63>t<EFBFBD></A><BR>\n";
print "<A href=\"".$urlp."index.php3?stcomm=0\">Jamais contact<EFBFBD>e</A><BR>\n"; print "<A href=\"".$urlp."contact.php3\">Contacts</A><BR>\n";
print "<A href=\"".$urlp."index.php3?stcomm=-1\">Ne pas contacter</A><BR>\n";
print "<A href=\"".$urlp."index.php3?stcomm=2\">Contact en cours</A><BR>\n";
print "<A href=\"".$urlp."index.php3?stcomm=3\">Contact<63>e</A><p>\n";
print "<A href=\"".$urlp."relance.php3\">A relancer</A><BR>\n";
print "<A href=\"".$urlp."recontact.php3\">A recontacter</A><BR>\n";
print "<A href=\"".$urlp."index.php3?aclasser=1\">A classer</A><p>\n";
print "<A href=\"".$urlp."topcontact.php3\">Gourmands</A><BR>\n";
print "<A href=\"".$urlp."contact.php3\">Contact</A><BR>\n";
print "</TD></TR>"; print "</TD></TR>";
@@ -80,30 +66,29 @@ function llxHeader($head = "", $urlp = "") {
* *
*/ */
print "<TR><TD valign=\"top\" align=\"right\">"; print "<TR><TD valign=\"top\" align=\"right\">";
print "<div align=\"center\"><A href=\"".$urlp."propal.php3\">Propal</A></div>\n"; print '<div align="center"><A href="'.$urlp.'propal.php3">Propal</A></div>';
print "<A href=\"".$urlp."analyse.php3\">Recap</A><br>\n";
print "</TD></TR>"; print "</TD></TR>";
/* /*
* *
*/ */
print "<TR><TD valign=\"top\" align=\"right\" bgcolor=\"#e0e0e0\">"; print "<TR><TD valign=\"top\" align=\"right\">";
print '<div align="center"><A href="'.$urlp.'../compta/">Factures</A></div>';
print "<A href=\"".$urlp."../compta/\">Factures</A><BR>\n"; print "</TD></TR>";
print "<center><A href=\"".$urlp."ventes.php3\">Ventes</A></center>\n"; /*
print "<A href=\"".$urlp."ventes_soc.php3\">Par soci<63>t<EFBFBD>s</A><BR>\n"; *
print "<A href=\"".$urlp."product.php3\">Produits</A><BR>\n"; */
print "<TR><TD valign=\"top\" align=\"right\">";
print '<div align="center"><A href="'.$urlp.'../product/">Produits</A></div>';
print "</td></tr>"; print "</td></tr>";
/*
*
*/
print "<tr><td align=\"right\" valign=\"top\">"; print "<tr><td align=\"right\" valign=\"top\">";
print "<A href=\"projet/\">Projets</A><BR>\n"; print "<A href=\"projet/\">Projets</A><BR>\n";
print "</td></tr>"; print "</td></tr>";
/*
*
print "<tr><td align=\"right\" valign=\"top\">"; */
print "<A href=\"".$urlp."stats/\">Stats</A><BR>\n";
print "</td></tr>";
print "<tr><td align=\"right\" valign=\"top\">"; print "<tr><td align=\"right\" valign=\"top\">";
print "<CENTER><A href=\"".$urlp."index.php3\">Societes</A></CENTER>\n"; print "<CENTER><A href=\"".$urlp."index.php3\">Societes</A></CENTER>\n";
print "<form action=\"index.php3\">"; print "<form action=\"index.php3\">";

View File

@@ -5,7 +5,6 @@
* $Source$ * $Source$
*/ */
require("./pre.inc.php3"); require("./pre.inc.php3");
require("../../lib/functions.inc.php3");
require("./project.class.php3"); require("./project.class.php3");

View File

@@ -0,0 +1,145 @@
<?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 $socidp;
var $contactid;
var $projetidp;
var $author;
var $ref;
var $datep;
var $remise;
var $products;
var $note;
var $price;
Function Propal($soc_idp="") {
$this->socidp = $soc_idp;
$this->products = array();
}
Function add_product($idproduct) {
if ($idproduct > 0) {
$i = sizeof($this->products);
$this->products[$i] = $idproduct;
}
}
/*
*
*
*
*/
Function create($db) {
/*
* Total des produits a ajouter
*/
$sql = "SELECT sum(price) FROM llx_product ";
$sql .= " WHERE rowid in (";
for ($i = 0 ; $i < sizeof($this->products) ; $i++) {
$sql .= $this->products[$i] . ",";
}
$sql = substr($sql, 0, strlen($sql)-1) . ");";
if ( $db->query($sql) ) {
$cprice = $db->result(0, 0);
$db->free();
}
/*
* Calcul TVA, Remise
*/
$totalht = $cprice - $remise;
$tva = tva($totalht);
$total = $totalht + $tva;
/*
* 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, $cprice, $this->remise, $tva, $total, $this->datep, now(), '$this->ref', $this->author, '$this->note')";
$sqlok = 0;
if ( $db->query($sql) ) {
$sql = "SELECT rowid FROM llx_propal WHERE ref='$this->ref';";
if ( $db->query($sql) ) {
/*
* Insertion du detail des produits dans la base
*/
if ( $db->num_rows() ) {
$propalid = $db->result( 0, 0);
$db->free();
for ($i = 0 ; $i < sizeof($this->products) ; $i++) {
$prod = new Product($db, $this->products[$i]);
$prod->fetch();
$sql = "INSERT INTO llx_propaldet (fk_propal, fk_product, price) VALUES ";
$sql .= " ($propalid,". $this->products[$i].", $prod->price) ; ";
if (! $db->query($sql) ) {
print $sql . '<br>' . $db->error() .'<br>';
}
}
/*
* Affectation au projet
*/
if ($this->projetidp) {
$sql = "UPDATE llx_propal SET fk_projet=$this->projetidp WHERE ref='$this->ref';";
$db->query($sql);
}
}
} else {
print $db->error() . '<b><br>'.$sql;
}
} else {
print $db->error() . '<b><br>'.$sql;
}
return 1;
}
/*
*
*
*
*/
Function fetch($db, $rowid) {
$sql = "SELECT ref,price,".$db->pdate(datep)."as dp FROM llx_propal WHERE rowid=$rowid;";
if ($db->query($sql) ) {
if ($db->num_rows()) {
$obj = $db->fetch_object(0);
$this->id = $rowid;
$this->datep = $obj->dp;
$this->ref = $obj->ref;
$this->price = $obj->price;
$db->free();
}
} else {
print $db->error();
}
}
}
?>

570
htdocs/comm/propal.php3 Normal file
View File

@@ -0,0 +1,570 @@
<?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("../lib/CMailFile.class.php3");
/*
* Modules optionnels
*/
require("projet/project.class.php3");
/*
*
*/
$author = $GLOBALS["REMOTE_USER"];
llxHeader();
print "<table width=\"100%\">";
print "<tr><td>Propositions commerciales</td>";
if ($socidp) {
print "<td align=\"right\"><a href=\"addpropal.php3?socidp=$socidp&action=create\">Nouvelle Propal</a></td>";
}
print "<td align=\"right\"><a href=\"propal.php3\">Liste</a></td>";
print "<td align=\"right\"><a href=\"/compta/prev.php3\">CA Pr<50>visionnel</a></td>";
print "<td align=\"right\"><a href=\"$PHP_SELF?viewstatut=2\">Propal Sign<67>es</a></td></tr>";
print "</table>";
$bc[0]="bgcolor=\"#90c090\"";
$bc[1]="bgcolor=\"#b0e0b0\"";
$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;
if ($action == 'setstatut') {
$sql = "UPDATE llx_propal SET fk_statut = $statut, note = '$note' WHERE rowid = $propalid";
$result = $db->query($sql);
} elseif ( $action == 'delete' ) {
$sql = "DELETE FROM llx_propal WHERE rowid = $propalid;";
if ( $db->query($sql) ) {
$sql = "DELETE FROM llx_propaldet WHERE fk_propal = $propalid ;";
if ( $db->query($sql) ) {
print "<b><font color=\"red\">Propal supprim<69>e</font></b>";
} else {
print $db->error();
print "<p>$sql";
}
} else {
print $db->error();
print "<p>$sql";
}
$propalid = 0;
$brouillon = 1;
}
if ($propalid) {
if ($valid == 1) {
$sql = "SELECT p.fk_soc, p.fk_projet,p.price, p.ref,".$db->pdate("p.datep")." as dp, p.author";
$sql .= " FROM llx_propal as p WHERE p.rowid = $propalid";
if ( $db->query($sql) ) {
$obj = $db->fetch_object( 0 );
$sql = "UPDATE llx_propal SET fk_statut = 1 WHERE rowid = $propalid;";
if (! $db->query($sql) ) {
print $db->error();
}
} else {
print $db->error();
}
}
/*
*
*/
$sql = "SELECT s.nom, s.idp, p.price, p.fk_projet,p.remise, p.tva, p.total, p.ref,".$db->pdate("p.datep")." as dp, c.id as statut, c.label as lst, p.author, p.note, x.firstname, x.name, x.fax, x.phone, x.email";
$sql .= " FROM societe as s, llx_propal as p, c_propalst as c, socpeople as x";
$sql .= " WHERE p.fk_soc = s.idp AND p.fk_statut = c.id AND x.idp = p.fk_soc_contact AND p.rowid = $propalid";
/* $sql = "SELECT s.nom, 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, p.author, p.note, x.firstname, x.name, x.fax, x.phone, x.email";
* $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.rowid = $propalid";
*/
$result = $db->query($sql);
if ( $result ) {
$obj = $db->fetch_object( 0 );
if ($db->num_rows()) {
$color1 = "#e0e0e0";
print "<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\">";
print "<tr><td>Soci<63>t<EFBFBD></td><td colspan=\"4\"><a href=\"index.php3?socid=$obj->idp\">$obj->nom</a></td><td align=\"right\"><a href=\"propal.php3?socidp=$obj->idp\">Autres propales</a></td>";
print "<td valign=\"top\" rowspan=\"8\">Note :<br>". nl2br($obj->note)."</td></tr>";
//
if ($obj->fk_projet) {
$projet = new Project();
$projet->fetch($db,$obj->fk_projet);
print '<tr><td>Projet</td><td colspan="5">';
print '<a href="projet/fiche.php3?id='.$projet->id.'">';
print $projet->title.'</a></td></tr>';
}
print "<tr><td>Destinataire</td><td colspan=\"5\">$obj->firstname $obj->name &lt;$obj->email&gt;</td></tr>";
/*
*
*/
print "<tr><td>Num<75>ro</td><td colspan=\"2\">$obj->ref</td>";
print "<td bgcolor=\"$color1\">Montant HT</td><td bgcolor=\"$color1\" align=\"right\">".price($obj->price)."</td>";
print "<td bgcolor=\"$color1\">euros</td></tr>";
/*
*
*/
print "<tr><td>date</td><td colspan=\"2\" align=\"right\">".strftime("%A %d %B %Y",$obj->dp)."</td>\n";
print "<td bgcolor=\"$color1\">Remise</td><td bgcolor=\"$color1\" align=\"right\">".price($obj->remise)."</td>";
print "<td bgcolor=\"$color1\">euros</td></tr>";
/*
*
*/
print "<tr><td>Auteur</td><td colspan=\"2\">$obj->author</td>";
$totalht = $obj->price - $obj->remise ;
print "<td bgcolor=\"$color1\">Total HT</td><td bgcolor=\"$color1\" align=\"right\"><b>".price($totalht)."</b></td><td bgcolor=\"$color1\">euros ";
print "<small>soit ".francs($totalht)." francs</small></td></tr>";
/*
*
*/
print "<tr>";
print "<td colspan=3>&nbsp;</td>";
print "<td bgcolor=\"$color1\">TVA</td><td bgcolor=\"$color1\" align=\"right\">".price($obj->tva)."</td><td bgcolor=\"$color1\">euros</td></tr>";
print "</tr>";
print "<tr><td colspan=3>&nbsp;</td>";
print "<td bgcolor=\"$color1\">Total TTC</td><td bgcolor=\"$color1\" align=\"right\">".price($obj->total)."</td><td bgcolor=\"$color1\">euros ";
print "<small>soit ".francs($obj->total)." francs</small></td></tr>";
print "</tr>";
/*
*
*/
print "<tr bgcolor=\"#f0f0f0\"><td>Statut :</td><td colspan=2 align=center><b>$obj->lst</b></td>";
if ($obj->statut == 0) {
print "<td colspan=3 align=center>[<a href=\"$PHP_SELF?propalid=$propalid&valid=1\">Valider</a>]</td>";
} elseif ($obj->statut == 1) {
print "<td colspan=3 align=center>[<a href=\"$PHP_SELF?propalid=$propalid&action=statut\">Changer</a>]</td>";
} else {
print "<td colspan=3>&nbsp;</td>";
}
print "</table>";
if ($action == 'statut') {
print "<form action=\"$PHP_SELF?propalid=$propalid\" method=\"post\">";
print "<input type=\"hidden\" name=\"action\" value=\"setstatut\">";
print "<select name=\"statut\">";
print "<option value=\"2\">Sign<67>e";
print "<option value=\"3\">Non Sign<67>e";
print '</select>';
print '<br><textarea cols="60" rows="6" wrap="soft" name="note">';
print $obj->note . "\n--------------------------\n";
print '</textarea><br><input type="submit" value="Valider">';
print "</form>";
}
print "<table width=\"100%\" cellspacing=2><tr><td valign=\"top\">";
/*
* Produits
*/
$sql = "SELECT p.label as product, p.ref, pt.price";
$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>&nbsp;</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>euros</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 "</td><td valign=\"top\" width=\"50%\">";
/*
* Factures associees
*/
$sql = "SELECT f.facnumber, f.amount,".$db->pdate("f.datef")." as df, f.rowid as facid, f.author, f.paye";
$sql .= " FROM llx_facture as f, llx_fa_pr as fp WHERE fp.fk_facture = f.rowid AND fp.fk_propal = $propalid";
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows();
$i = 0; $total = 0;
print "<p><b>Facture(s) associ<63>e(s)</b><TABLE border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"3\">";
print "<tr>";
print "<td>Num</td>";
print "<td>Date</td>";
print "<td>Auteur</td>";
print "<td align=\"right\">Prix</TD>";
print "</TR>\n";
$var=True;
while ($i < $num) {
$objp = $db->fetch_object( $i);
$var=!$var;
print "<TR bgcolor=\"#e0e0e0\">";
print "<TD><a href=\"../compta/facture.php3?facid=$objp->facid\">$objp->facnumber</a>";
if ($objp->paye) { print " (<b>pay&eacute;e</b>)"; }
print "</TD>\n";
print "<TD>".strftime("%d %B %Y",$objp->df)."</TD>\n";
print "<TD>$objp->author</TD>\n";
print "<TD align=\"right\">$objp->amount</TD>\n";
print "</tr>";
$total = $total + $objp->amount;
$i++;
}
print "<tr><td align=\"right\" colspan=\"4\">Total : <b>$total</b> Euros HT</td></tr>\n";
print "</table>";
$db->free();
}
print "</table>";
/*
* Actions
*/
print "<p><TABLE border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\"><tr>";
if ($obj->statut == 0) {
print "<td bgcolor=\"#e0e0e0\" align=\"center\" width=\"25%\">[<a href=\"$PHP_SELF?propalid=$propalid&action=delete\">Supprimer</a>]</td>";
} else {
print "<td align=\"center\" width=\"25%\">-</td>";
}
if ($obj->statut == 2) {
print "<td bgcolor=\"#e0e0e0\" align=\"center\" width=\"25%\"><a href=\"facture.php3?propalid=$propalid&action=create\">Emettre une facture</td>";
} else {
print "<td align=\"center\" width=\"25%\">-</td>";
}
if ($obj->statut == 1) {
$file = $GLOBALS["GLJ_ROOT"] . "/www-sys/doc/propal/$obj->ref/$obj->ref.pdf";
if (file_exists($file)) {
print "<td bgcolor=\"#e0e0e0\" align=\"center\" width=\"25%\">";
print "[<a href=\"$PHP_SELF?propalid=$propalid&action=presend\">Envoyer la propale par mail</a>]</td>";
} else {
print "<td bgcolor=\"#e0e0e0\" align=\"center\" width=\"25%\">! Propale non generee !</td>";
}
} else {
print "<td align=\"center\" width=\"25%\">-</td>";
}
if ($obj->statut == 0) {
print "<td bgcolor=\"#e0e0e0\" align=\"center\" width=\"25%\">[<a href=\"$PHP_SELF?propalid=$propalid&valid=1\">Valider</a>]</td>";
} else {
print "<td align=\"center\" width=\"25%\">-</td>";
}
print "</tr></table>";
/*
*
*/
if ($action == 'fax') {
print "<hr><b>G<>n<EFBFBD>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";
}
}
if ( $db->query($sql) ) {
$sql = "INSERT INTO actioncomm (datea,fk_action,fk_soc,author,propalrowid,note) VALUES (now(), 3, $obj->idp,'$author', $propalid, 'Envoy<6F>e <20> $sendto');";
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<EFBFBD>r<EFBFBD>s</b><br>";
print "<table width=\"100%\" cellspacing=0 border=1 cellpadding=3>";
$file = $GLOBALS["GLJ_ROOT"] . "/www-sys/doc/propal/$obj->ref/$obj->ref.pdf";
if (file_exists($file)) {
print "<tr><td>Propale PDF</a></td><td><a href=\"../../doc/propal/$obj->ref/$obj->ref.pdf\">$obj->ref.pdf</a></td></tr>";
}
$file = $GLOBALS["GLJ_ROOT"] . "/www-sys/doc/propal/$obj->ref/$obj->ref.ps";
if (file_exists($file)) {
print "<tr><td>Propale Postscript</a></td><td><a href=\"../../doc/propal/$obj->ref/$obj->ref.ps\">$obj->ref.ps</a></td>";
print "</tr>";
}
print "<tr><td colspan=\"2\">(<a href=\"../../doc/propal/$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<6F>e</b><br>";
/*
*
*/
$sql = "SELECT ".$db->pdate("a.datea"). " as da, author, note" ;
$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";
print "<TD>$objp->author</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 = "Service commercial Lolix"; $ from_name = $replytoname;
$replytomail = "commercial@lolix.org"; $from_mail = $replytomail;
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";
}
} else {
print $db->error();
print "<p><b>$sql";
}
/*
*
*
*
*/
} else {
/*
*
*
* Liste des propals
*
*
*/
print "<P>";
$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";
if ($socidp) { $sql .= " AND s.idp = $socidp"; }
if ($viewstatut) { $sql .= " AND c.id = $viewstatut"; }
if ($month > 0) {
// $sql .= " AND date_part('month', date(p.datep)) = $month";
$sql .= " AND date_format(p.datep, '%Y-%m') = '$year-$month'";
}
if ($year > 0) {
// $sql .= " AND date_part('year', date(p.datep)) = $year";
$sql .= " AND date_format(p.datep, '%Y') = $year";
}
$sql .= " ORDER BY p.fk_statut, datep DESC";
if ( $db->query($sql) ) {
$num = $db->num_rows();
$i = 0;
print "<p><TABLE border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
$oldstatut = -1;
$subtotal = 0;
while ($i < $num) {
$objp = $db->fetch_object( $i);
if ($objp->statut <> $oldstatut ) {
$oldstatut = $objp->statut;
if ($i > 0) {
print "<tr><td align=\"right\" colspan=\"6\">Total : <b>".price($subtotal)."</b></td>\n";
print "<td align=\"left\">Euros HT</td></tr>\n";
}
$subtotal = 0;
print "<TR bgcolor=\"#e0e0e0\">";
print "<TD>[<a href=\"$PHP_SELF\">Tous</a>]</td>";
print "<TD>R<EFBFBD>f</TD>";
print "<TD><a href=\"$PHP_SELF?sortfield=lower(p.label)&sortorder=ASC\">Societe</a></td>";
print "<TD align=\"right\" colspan=\"2\">Date</TD>";
print "<TD align=\"right\">Prix</TD>";
print "<TD align=\"center\">Statut [<a href=\"$PHP_SELF?viewstatut=$objp->statutid\">Filtre</a>]</TD>";
print "</TR>\n";
$var=True;
}
$var=!$var;
print "<TR $bc[$var]>";
print "<TD>[<a href=\"$PHP_SELF?socidp=$objp->idp\">Filtre</a>]</TD>\n";
print "<TD><a href=\"$PHP_SELF?propalid=$objp->propalid\">$objp->ref</a></TD>\n";
print "<TD><a href=\"index.php3?socid=$objp->idp\">$objp->nom</a></TD>\n";
$now = time();
$lim = 3600 * 24 * 15 ;
if ( ($now - $objp->dp) > $lim && $objp->statutid == 1 ) {
print "<td><b> &gt; 15 jours</b></td>";
} else {
print "<td>&nbsp;</td>";
}
print "<TD align=\"right\">";
$y = strftime("%Y",$objp->dp);
$m = strftime("%m",$objp->dp);
print strftime("%d",$objp->dp)."\n";
print " <a href=\"propal.php3?year=$y&month=$m\">";
print strftime("%B",$objp->dp)."</a>\n";
print " <a href=\"propal.php3?year=$y\">";
print strftime("%Y",$objp->dp)."</a></TD>\n";
//print "<TD align=\"right\">".strftime("%d %B %Y",$objp->dp)."</TD>\n";
print "<TD align=\"right\">".price($objp->price)."</TD>\n";
print "<TD align=\"center\">$objp->statut</TD>\n";
print "</TR>\n";
$total = $total + $objp->price;
$subtotal = $subtotal + $objp->price;
$i++;
}
print "<tr><td align=\"right\" colspan=\"6\">Total : <b>".price($subtotal)."</b></td>\n";
print "<td align=\"left\">Euros HT</td></tr>\n";
print "<tr><td></td><td>$i propales</td><td align=\"right\"><small>Soit : ".francs($total)." FF HT</small></td>";
print "<td colspan=\"3\" align=\"right\"><b>Total : ".price($total)."</b></td>";
print "<td align=\"left\"><b>Euros HT</b></td></tr>";
print "</TABLE>";
$db->free();
} else {
print $db->error();
}
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

114
htdocs/comm/recontact.php3 Normal file
View File

@@ -0,0 +1,114 @@
<?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("../lib/functions.inc.php3");
llxHeader();
$db = new Db();
if ($sortfield == "") {
$sortfield="a.datea";
}
if ($sortorder == "") {
$sortorder="DESC";
}
if ($action == 'del') {
$sql = "DELETE FROM llx_soc_recontact WHERE rowid=$rowid";
$result = $db->query( $sql);
}
$active["1"] = "Offres en ligne";
$active["-1"] = "Moderation";
$active["-2"] = "Refus<EFBFBD>es";
$active["0"] = "R<EFBFBD>daction";
$active["-3"] = "D<EFBFBD>sactiv<EFBFBD>es";
$active["-4"] = "Supprim<EFBFBD>es";
$yn["t"] = "oui";
$yn["f"] = "non";
$deacmeth["b"] = "robots";
if ($page == -1) { $page = 0 ; }
$limit = 26;
$offset = $limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
print "<DIV align=\"center\">";
print "<A href=\"$PHP_SELF?page=$pageprev&begin=$begin&stcomm=$stcomm\">< Prev</A>\n| ";
for ($i = 65 ; $i < 91; $i++) {
print "<A href=\"$PHP_SELF?begin=" . chr($i) . "&stcomm=$stcomm\" class=\"T3\">";
print chr($i) ;
print "</A> | ";
}
print " <A href=\"$PHP_SELF?page=$pagenext&begin=$begin&stcomm=$stcomm\">Next ></A>\n";
print "</DIV><P>";
$bc[0]="bgcolor=\"#90c090\"";
$bc[1]="bgcolor=\"#b0e0b0\"";
$sql = "SELECT s.nom as societe, s.idp as socidp,".$db->pdate("re.datere")." as datere, re.rowid, re.author";
$sql .= " FROM societe as s, llx_soc_recontact as re";
$sql .= " WHERE re.fk_soc = s.idp";
$sql .= " ORDER BY re.datere ASC ";
$sql .= $db->plimit( $limit, $offset);
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows();
$i = 0; $j = 0 ;
print "<p><TABLE border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
print "<TR bgcolor=\"orange\"><td>&nbsp;</td>";
print "<TD><a href=\"$PHP_SELF?sortfield=lower(s.nom)&sortorder=ASC\">Societe</a></td>";
print "<TD colspan=\"3\">A recontacter le</TD>";
print "<TD>Auteur</TD>";
print "</TR>\n";
$var=True;
while ($i < $num) {
$obj = $db->fetch_object( $i);
$var=!$var;
print "<TR $bc[$var]>";
print "<TD>" . ($j + 1 + ($limit * $page)) . "</TD>";
print "<TD><a href=\"index.php3?socid=$obj->socidp\">$obj->societe</A></TD>\n";
print "<TD>" .strftime("%d",$obj->datere)."</TD>\n";
print "<TD>" .strftime("%B",$obj->datere)."</TD>\n";
print "<TD>" .strftime("%Y",$obj->datere)."</TD>\n";
print "<TD>$obj->author</TD>\n";
print "<TD align=\"right\"><a href=\"$PHP_SELF?action=del&rowid=$obj->rowid\">Supprimer ce rappel</A></TD>\n";
print "</TR>\n";
$j++;
$objold = $obj;
$i++;
}
print "</table>";
}
$db->free();
$db->close();
llxFooter();
?>

130
htdocs/comm/relance.php3 Normal file
View File

@@ -0,0 +1,130 @@
<?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("../lib/functions.inc.php3");
llxHeader();
$db = new Db();
if ($sortfield == "") {
$sortfield="a.datea";
}
if ($sortorder == "") {
$sortorder="DESC";
}
$active["1"] = "Offres en ligne";
$active["-1"] = "Moderation";
$active["-2"] = "Refus<EFBFBD>es";
$active["0"] = "R<EFBFBD>daction";
$active["-3"] = "D<EFBFBD>sactiv<EFBFBD>es";
$active["-4"] = "Supprim<EFBFBD>es";
$yn["t"] = "oui";
$yn["f"] = "non";
$deacmeth["b"] = "robots";
if ($page == -1) { $page = 0 ; }
$limit = 26;
$offset = $limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
print "<DIV align=\"center\">";
print "<A href=\"$PHP_SELF?page=$pageprev&begin=$begin&stcomm=$stcomm\">< Prev</A>\n| ";
for ($i = 65 ; $i < 91; $i++) {
print "<A href=\"$PHP_SELF?begin=" . chr($i) . "&stcomm=$stcomm\" class=\"T3\">";
if ($begin == chr($i) ) {
print "<b>-&gt;" . chr($i) . "&lt;-</b>" ;
} else {
print chr($i) ;
}
print "</A> | ";
}
print " <A href=\"$PHP_SELF?page=$pagenext&begin=$begin&stcomm=$stcomm\">Next ></A>\n";
print "</DIV><P>";
$bc[0]="bgcolor=\"#90c090\"";
$bc[1]="bgcolor=\"#b0e0b0\"";
$sql = "SELECT a.fk_action, s.nom as societe, s.idp as socidp,a.id, int(a.datea) as da, a.datea, c.libelle, a.author FROM actioncomm as a, c_actioncomm as c, societe as s WHERE a.fk_soc = s.idp AND c.id=a.fk_action";
$sql .= " ORDER BY a.fk_soc ASC, a.datea ASC ";
$sql .= " LIMIT $limit OFFSET $offset";
$result = $db->query($sql);
$num = $db->num_rows();
$i = 0; $j = 0 ;
print "<p><TABLE border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
print "<TR bgcolor=\"orange\"><td>&nbsp;</td>";
print "<TD><a href=\"$PHP_SELF?sortfield=lower(s.nom)&sortorder=ASC\">Societe</a></td>";
print "<TD>Date</TD>";
print "<TD>Derni&egrave;re action</TD>";
print "<TD>Auteur</TD>";
print "</TR>\n";
$var=True;
while ($i < $num) {
$obj = $db->fetch_object( $i);
if ($i == 0) {
$objold = $obj;
}
if (($objold->socidp <> $obj->socidp) && $objold->fk_action <> 11) {
$var=!$var;
print "<TR $bc[$var]>";
print "<TD>" . ($j + 1 + ($limit * $page)) . "</TD>";
print "<TD><a href=\"index.php3?socid=$objold->socidp\">$objold->societe</A></TD>\n";
print "<TD>" .gljftime("%d %b %Y %H:%M",$objold->datea)."</TD>\n";
print "<TD>$objold->libelle</TD>\n";
print "<TD>$objold->author</TD>\n";
print "<TD align=\"center\">$objold->stcomm</TD>\n";
print "</TR>\n";
$j++;
}
$objold = $obj;
$i++;
}
if ( $objold->fk_action <> 11) {
$var=!$var;
print "<TR $bc[$var]>";
print "<TD>" . ($j + 1 + ($limit * $page)) . "</TD>";
print "<TD><a href=\"index.php3?socid=$objold->socidp\">$objold->societe</A></TD>\n";
print "<TD>" .gljftime("%d %b %Y %H:%M",$objold->datea)."</TD>\n";
print "<TD>$objold->libelle</TD>\n";
print "<TD>$objold->author</TD>\n";
print "<TD align=\"center\">$objold->stcomm</TD>\n";
print "</TR>\n";
}
print "</TABLE>";
$db->free();
$db->close();
llxFooter();
?>

228
htdocs/comm/socnote.php3 Normal file
View File

@@ -0,0 +1,228 @@
<?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("../lib/functions.inc.php3");
require("../../www/lib/company.class.php3");
/*
*
*/
llxHeader();
$db = new Db();
if ($sortorder == "") {
$sortfield="lower(s.nom)";
$sortorder="ASC";
}
$active["1"] = "Offres en ligne";
$active["-1"] = "Moderation";
$active["-2"] = "Refus<EFBFBD>es";
$active["0"] = "R<EFBFBD>daction";
$active["-3"] = "D<EFBFBD>sactiv<EFBFBD>es";
$active["-4"] = "Supprim<EFBFBD>es";
$yn["t"] = "oui";
$yn["f"] = "non";
if ($action == 'stcomm') {
$sql = "UPDATE societe SET fk_stcomm=$stcommid WHERE idp=$socid";
$result = $db->query($sql);
$sql = "INSERT INTO socstatutlog (datel, fk_soc, fk_statut, author) VALUES (now(),$socid,$stcommid,'" . $GLOBALS["REMOTE_USER"] . "')";
$result = $db->query($sql);
if ($actioncommid) {
$sql = "INSERT INTO actioncomm (datea, fk_action, fk_soc) VALUES (now(),$actioncommid,$socid)";
$result = $db->query($sql);
}
}
if ($socid > 0) {
$soc = new Company($db, $socid);
$soc->fetch();
/*
*
*/
$sql = "SELECT s.idp, s.nom,".$db->pdate("s.datec")." as dc,".$db->pdate("s.datem")." as dm,".$db->pdate("s.datea")." as da, s.intern, s.cjn, s.c_nom, s.c_prenom, s.c_tel, s.c_mail, s.tel, s.fax, s.fplus, s.cjn, s.viewed, st.libelle as stcomm, s.fk_stcomm, s.url,s.cp,s.ville, s.note FROM societe as s, c_stcomm as st ";
$sql .= " WHERE s.fk_stcomm=st.id";
$sql .= " AND s.idp = $socid";
$result = $db->query($sql);
if ($result) {
$objsoc = $db->fetch_object($result , 0);
print "<table width=\"100%\" border=0><tr>\n";
print "<td bgcolor=\"white\" colspan=\"2\"><big>N<> $objsoc->idp - $soc->nom - [$soc->stcomm]</big></td></tr>" ;
print "<tr>";
print "<td valign=\"top\">";
print "tel : $soc->tel<br>";
print "fax : $soc->fax<br>";
print "$soc->cp $soc->ville<br>";
if ($objsoc->url) {
print "<a href=\"http://$soc->url\">$soc->url</a><br>";
}
print "<br>Contact : <br><b>$soc->c_nom $soc->c_prenom</b>";
print "<br>tel : <b>$soc->c_tel</b>";
print "<br>email : <b>$soc->c_mail</b>";
print "</td>\n";
print "<td valign=\"top\"><table border=0 width=\"100%\" cellspacing=0 bgcolor=#e0e0e0>";
print "<tr><td>Cr<43><72>e le</td><td align=center><b>" . strftime("%d %b %Y %H:%M", $objsoc->dc) . "</b></td></tr>";
print "<tr><td>Derni<6E>re modif le</td><td align=center><b>" . strftime("%d %b %Y %H:%M", $objsoc->dm) . "</b></td></tr>";
print "<tr><td>Fiche soci<63>t<EFBFBD></td><td align=center><b>".$yn[$objsoc->fplus]."</b></td></tr>" ;
print "<tr><td>Cojonet</td><td align=center><b>".$yn["$objsoc->cjn"]."</b></td></tr>" ;
print "<tr><td>Consult Fiche</td><td align=center><b>$objsoc->viewed</b></td></tr>";
print "<tr><td valign=\"top\"><b>Offres</b>";
print "<hr noshade size=1><table border=0 cellspacing=0>";
$sql = "SELECT count(idp) as cc, active FROM offre WHERE fk_soc = $objsoc->idp GROUP by active ORDER BY active DESC";
$result = $db->query($sql);
$i = 0 ; $num = $db->num_rows();
while ($i < $num) {
$obj = $db->fetch_object( $i);
print "<tr><td>".$active["$obj->active"] . "</td><td>:</td><td>$obj->cc</tr>";
$i++;
}
print "</table></td>";
print "<td valign=\"top\"><b>Divers</b><hr noshade size=1>";
print "<table cellspacing=0 border=0>";
$sql = "SELECT count(idp) as cc FROM abo_soc WHERE fksoc = $objsoc->idp GROUP by active";
$result = $db->query($sql);
$i = 0 ; $num = $db->num_rows();
while ($i < $num) {
$obj = $db->fetch_object( $i);
print "<tr><td>Abonnements :</td><td>$obj->cc</td></tr>";
$i++;
}
$sql = "SELECT count(idp) as cc FROM socfollowresume WHERE fk_soc = $objsoc->idp";
$result = $db->query($sql);
$i = 0 ; $num = $db->num_rows();
while ($i < $num) {
$obj = $db->fetch_object( $i);
print "<tr><td>Cand. suivis :</td><td>$obj->cc</td></tr>";
$i++;
}
$sql = "SELECT count(idp) as cc FROM soccontact WHERE fk_soc = $objsoc->idp";
$result = $db->query($sql);
$i = 0 ; $num = $db->num_rows();
while ($i < $num) {
$obj = $db->fetch_object( $i);
print "<tr><td>Contacts :</td><td>$obj->cc</td></tr>";
$i++;
}
print "</table></td>\n";
print "</tr>";
print "</table></td></tr>\n";
print "</table>";
print "<hr noshade size=1>";
/*
*
*
*/
print "<table width=\"100%\" cellspacing=0 border=0 cellpadding=2><tr><td valign=\"top\">";
print "<table width=\"100%\" cellspacing=0 border=0 cellpadding=2>";
$sql = "SELECT a.id,".$db->pdate("a.datel")." as da, c.libelle, a.author FROM socstatutlog as a, c_stcomm as c WHERE a.fk_soc = $objsoc->idp AND c.id=a.fk_statut ORDER by a.datel DESC";
$result = $db->query($sql);
$i = 0 ; $num = $db->num_rows(); $tag = True;
while ($i < $num) {
$obj = $db->fetch_object( $i);
if ($tag) {
print "<tr bgcolor=\"e0e0e0\">";
} else {
print "<tr>";
}
print "<td>". strftime("%d %b %Y %H:%M", $obj->da) ."</td>";
print "<td>$obj->libelle</td>";
print "<td>$obj->author</td>";
print "</tr>\n";
$i++;
$tag = !$tag;
}
print "</table>";
print "</td>";
/*
*
*
*/
print "<td valign=\"top\">";
print "<table width=\"100%\" cellspacing=0 border=0 cellpadding=2>";
$sql = "SELECT a.id,".$db->pdate("a.datea")." as da, c.libelle, a.author FROM actioncomm as a, c_actioncomm as c WHERE a.fk_soc = $objsoc->idp AND c.id=a.fk_action ORDER by a.datea DESC";
$result = $db->query($sql);
$i = 0 ; $num = $db->num_rows(); $tag = True;
while ($i < $num) {
$obj = $db->fetch_object( $i);
if ($tag) {
print "<tr bgcolor=\"e0e0e0\">";
} else {
print "<tr>";
}
print "<td>". strftime("%d %b %Y %H:%M", $obj->da) ."</td>";
print "<td>$obj->libelle</td>";
print "<td>$obj->author</td>";
print "</tr>\n";
$i++;
$tag = !$tag;
}
print "</table>";
print "</td></tr></table>";
print "<table border=0 width=\"100%\" cellspacing=2 bgcolor=#e0e0e0>";
print "<tr><td>";
print "<form method=\"post\" action=\"index.php3?socid=$socid\">";
print "<input type=\"hidden\" name=\"action\" value=\"note\">";
print "<textarea name=\"note\" cols=\"60\" rows=\"10\">$objsoc->note</textarea><br>";
print "<input type=\"submit\">";
print "</form></td></tr>";
print "<tr><td>".nl2br($objsoc->note)."</td></tr>";
print "</table>";
} else {
print $db->error();
}
}
$db->free();
$db->close();
llxFooter();
?>

View File

@@ -0,0 +1,59 @@
<?PHP
/*
* $Id$
* $Source$
*/
require("./pre.inc.php3");
require("../../lib/functions.inc.php3");
llxHeader();
$db = new Db();
$bc[0]="bgcolor=\"#90c090\"";
$bc[1]="bgcolor=\"#b0e0b0\"";
function valeur($sql) {
global $db;
if ( $db->query($sql) ) {
if ( $db->num_rows() ) {
$valeur = $db->result(0,0);
}
$db->free();
}
return $valeur;
}
print "<b>Bilan</b>";
print "<TABLE border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">";
print "<TR bgcolor=\"orange\">";
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,125 @@
<?PHP
/*
* $Id$
* $Source$
*/
require("./pre.inc.php3");
require("../../lib/functions.inc.php3");
llxHeader();
$db = new Db();
$bc[0]="bgcolor=\"#90c090\"";
$bc[1]="bgcolor=\"#b0e0b0\"";
/*
*
*
* 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 bgcolor=\"orange\">";
echo '<td>Description</TD><td>Nb</td><td colspan="2">Total</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))."</small></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,69 @@
<?PHP
/*
* $Id$
* $Source$
*/
require("pre.inc.php3");
require("../../lib/functions.inc.php3");
llxHeader();
$db = new Db();
$bc[0]="bgcolor=\"#90c090\"";
$bc[1]="bgcolor=\"#b0e0b0\"";
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";
$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,195 @@
<?PHP
/*
* $Id$
* $Source$
*
*
* $viewall
*
*/
require("./pre.inc.php3");
require("../../lib/functions.inc.php3");
require("../../lib/bank.lib.php3");
llxHeader();
$db = new Db();
$bc[0]="bgcolor=\"#b0cba0\"";
$bc[1]="bgcolor=\"#b0e0b0\"";
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)";
$sql .= " VALUES (now(), $dateo, '$label', $amount,'$author',$num_chq)";
} else {
$sql = "INSERT INTO llx_bank (datec, dateo, label, amount, author)";
$sql .= " VALUES (now(), $dateo, '$label', $amount,'$author')";
}
$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>Bank</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\">";
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 count(*) FROM llx_bank";
if ( $db->query($sql) ) {
$nbline = $db->result (0, 0);
$db->free();
if ($nbline > $viewline ) {
$limit = $nbline - $viewline ;
} else {
$limit = $viewline;
}
}
if ($viewall) { $nbline=0; }
/* Another solution
* create temporary table solde type=heap select amount from llx_bank limit 100 ;
* select sum(amount) from solde ;
*/
$sql = "SELECT b.rowid,".$db->pdate("b.dateo")." as do, b.amount, b.label, b.rappro, b.num_releve, b.num_chq";
$sql .= " FROM llx_bank as b";
if ($vue) {
if ($vue == 'credit') {
$sql .= " WHERE b.amount >= 0 ";
} else {
$sql .= " WHERE b.amount < 0 ";
}
}
$sql .= " ORDER BY b.dateo ASC";
$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);
$total = $total + $objp->amount;
$time = time();
if ($i > ($nbline - $viewline)) {
if (!$psol) {
print "<tr $bc[$var]><td colspan=\"4\">&nbsp;</td><td align=\"right\">".price($total)."</b></td><td align=\"right\">".francs($total)."</td></tr>\n";
$psol = 1;
} else {
$var=!$var;
if ($objp->do > $time && !$sep) {
$sep = 1 ;
print "<tr><td align=\"right\" colspan=\"4\">Total :</td>";
print "<td align=\"right\"><b>".price($total - $objp->amount)."</b></td><td align=\"right\">".francs($total - $objp->amount)."</td></tr>\n";
print "<tr>";
print "<td><input name=\"dateo\" type=\"text\" size=8 maxlength=8></td>";
print "<td>CHQ<input name=\"num_chq\" type=\"text\" size=4>&nbsp;-";
print "<input name=\"label\" type=\"text\" size=40></td>";
print "<td><input name=\"debit\" type=\"text\" size=8></td>";
print "<td><input name=\"credit\" 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 "<tr $bc[$var]>";
print "<td>".strftime("%d %b %y",$objp->do)."</TD>\n";
if ($objp->num_chq) {
print "<td>CHQ $objp->num_chq - $objp->label</td>";
} else {
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";
}
if ($total > 0) {
print "<td align=\"right\">".price($total)."</TD>\n";
} else {
print "<td align=\"right\"><b>".price($total)."</b></TD>\n";
}
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 "<td align=\"right\"><small>".francs($objp->amount)."</small></TD>\n";
print "</tr>";
}
}
$i++;
}
$db->free();
}
if ($sep) {
print "<tr><td align=\"right\" colspan=\"4\">Total :</td>";
print "<td align=\"right\"><b>".price($total)."</b></td><td align=\"right\">".francs($total)."</td></tr>\n";
} else {
print "<tr><td align=\"right\" colspan=\"4\">Total :</td>";
print "<td align=\"right\"><b>".price($total)."</b></td><td align=\"right\">".francs($total)."</td></tr>\n";
print "<tr>";
print "<td><input name=\"dateo\" type=\"text\" size=8 maxlength=8></td>";
print "<td>CHQ<input name=\"num_chq\" type=\"text\" size=4>&nbsp;-";
print "<input name=\"label\" type=\"text\" size=40></td>";
print "<td><input name=\"debit\" type=\"text\" size=8></td>";
print "<td><input name=\"credit\" 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

@@ -0,0 +1,128 @@
<?PHP
/*
* $Id$
* $Source$
*/
require("./pre.inc.php3");
require("../../lib/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\">$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<73> 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,80 @@
<?PHP
// $Id$
$root = "/$PREFIX";
require ("/$GLJ_WWW_ROOT/conf/$GLJ_PREFIX.$GLJ_COUNTRY.inc.php3");
require ("/$GLJ_WWW_ROOT/../www/lib/db.lib.php3");
function llxHeader($head = "") {
global $PREFIX;
print "<HTML>\n<HEAD>$head\n</HEAD>\n";
?>
<BODY BGCOLOR="#c0c0c0" TOPMARGIN="0" BOTTOMMARGIN="0" LEFTMARGIN="0" RIGHTMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0">
<?PHP
print "<TABLE border=\"0\" width=\"100%\">\n";
print "<TR bgcolor=\"".$GLOBALS["TOPBAR_BGCOLOR"]."\">";
print "<TD width=\"20%\" bgcolor=\"#e0e0e0\"><B>" . $GLOBALS["MAIN_TITLE"] . "</B></TD>";
print "<TD width=\"20%\" bgcolor=\"#e0e0e0\" align=\"center\"><A href=\"../../tech/\">Technique</A></TD>";
print "<TD width=\"20%\" bgcolor=\"#e0e0e0\" align=\"center\"><A href=\"../../comm/\">Commercial</A></TD>";
print "<TD width=\"20%\" align=\"center\"><A href=\"../\">Compta</A></TD>";
print "<TD width=\"20%\" bgcolor=\"#e0e0e0\" align=\"center\"><A href=\"../../stats/\">Stats</A></TD>";
print "</TR></TABLE>\n";
print "<TABLE border=\"1\" width=\"100%\">";
print "<TR><TD valign=\"top\" align=\"right\">";
print "<TABLE border=\"1\" cellspacing=\"0\" width=\"100%\" cellpadding=\"3\">";
print "<TR><TD valign=\"top\" align=\"right\">";
print "<center><b>" . $GLOBALS["dbname"] . " - " . $GLOBALS["REMOTE_USER"] ."</B></center>";
print "<A href=\"/\">Accueil</A>";
print "</td></tr>";
print "<TR><TD valign=\"top\" align=\"right\"><center>";
print "<A href=\"index.php3\">Bank</A></center>\n";
print "<A href=\"rappro.php3\">Rappro</A><p>\n";
print "<A href=\"budget.php3\">Budgets</A><BR>\n";
print "<A href=\"bilan.php3\">Bilan</A><p>\n";
print '<a href="releve.php3">Relev<65>s bancaires</a>';
print "</td></tr>";
print "<tr><td valign=\"top\" align=\"right\">";
print "<center><a href=\"../index.php3\">Factures</a></center><p>\n";
print "<a href=\"../paiement.php3\">Paiements</A><BR>\n";
print "</td></tr>";
print "<TR><TD valign=\"top\" align=\"right\">";
print "<CENTER>Chiffres d'affaires</CENTER><br>\n";
print "<A href=\"../ca.php3\">R<>alis<69></A><BR>\n";
print "<A href=\"../prev.php3\">Pr<50>visionnel</A><BR>\n";
print "<A href=\"../comp.php3\">Comparatif</A>\n";
print "</td></tr>";
print "<TR><TD valign=\"top\" align=\"center\">";
print "<A href=\"../../comm/propal.php3\">Propal</A><BR>\n";
print "</td></tr>";
print "</table>";
print "</TD>\n<TD valign=\"top\" width=\"85%\">\n";
}
/*
*
*/
function llxFooter($foot='') {
print "</TD></TR></TABLE>\n";
print "$foot</BODY></HTML>";
}
// $Id$
// $Source$
?>

View File

@@ -0,0 +1,123 @@
<?PHP
/*
* $Id$
* $Source$
*/
require("./pre.inc.php3");
require("../../lib/functions.inc.php3");
llxHeader();
$db = new Db();
$bc[0]="bgcolor=\"#90c090\"";
$bc[1]="bgcolor=\"#b0e0b0\"";
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;";
$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,163 @@
<?PHP
/*
* $Id$
* $Source$
*
*
* $num
* $rel
* $ve
*/
require("./pre.inc.php3");
require("../../lib/functions.inc.php3");
llxHeader();
$db = new Db();
$bc[0]="bgcolor=\"#90c090\"";
$bc[1]="bgcolor=\"#b0e0b0\"";
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>");
?>

112
htdocs/compta/casoc.php3 Normal file
View File

@@ -0,0 +1,112 @@
<?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();
print "Chiffres d'affaire par soci<63>t<EFBFBD>";
$bc[0]="bgcolor=\"#90c090\"";
$bc[1]="bgcolor=\"#b0e0b0\"";
$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 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 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=\"$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 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><td></td><td align=\"right\"><b>Total : ".francs($total)." FF</b></td>";
print "<td 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 "<P>";
liste($db, 0);
print "<P>";
liste($db, 1);
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

371
htdocs/compta/comp.php3 Normal file
View File

@@ -0,0 +1,371 @@
<?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("../lib/functions.inc.php3");
$bc[0]="bgcolor=\"#90c090\"";
$bc[1]="bgcolor=\"#b0e0b0\"";
$a = setlocale("LC_TIME", "FRENCH");
function get_ca_propal ($db, $year, $socidp) {
$sql = "SELECT sum(f.price) FROM llx_propal as f WHERE fk_statut in (1,2) AND date_part('year', date(f.datep)) = $year ";
if ($socidp) {
$sql .= " AND f.fk_soc = $socidp";
}
$result = $db->query($sql);
if ($result) {
return $db->result (0, 0);
} else {
return 0;
}
}
function get_ca ($db, $year, $socidp) {
$sql = "SELECT sum(f.amount) FROM llx_facture as f WHERE f.paye = 1 AND date_part('year', date(f.datef)) = $year ";
if ($socidp) {
$sql .= " AND f.fk_soc = $socidp";
}
$result = $db->query($sql);
if ($result) {
return $db->result ( 0, 0);
} else {
return 0;
}
}
function propals ($db, $year, $month) {
global $bc;
$sql = "SELECT s.nom, s.idp, p.rowid as propalid, p.price, p.ref, int(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 c.id in (1,2)";
$sql .= " AND date_part('year', date(p.datep)) = $year ";
$sql .= " AND date_part('month', date(p.datep)) = $month ";
$sql .= " ORDER BY p.fk_statut";
$result = $db->query($sql);
$num = $db->num_rows();
$i = 0;
print "<p><TABLE border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
print "<TR bgcolor=\"#e0e0e0\"><td colspan=\"3\"><b>Propal</b></td></tr>";
$oldstatut = -1;
$subtotal = 0;
while ($i < $num) {
$objp = $db->fetch_object( $i);
if ($objp->statut <> $oldstatut ) {
$oldstatut = $objp->statut;
if ($i > 0) {
print "<tr><td align=\"right\" colspan=\"4\">Total : <b>$subtotal</b></td>\n";
print "<td align=\"left\">Euros HT</td></tr>\n";
}
$subtotal = 0;
print "<TR bgcolor=\"#e0e0e0\">";
print "<TD>Societe</td>";
print "<TD>R<>f</TD>";
print "<TD align=\"right\">Date</TD>";
print "<TD align=\"right\">Prix</TD>";
print "<TD align=\"center\">Statut</TD>";
print "</TR>\n";
$var=True;
}
$var=!$var;
print "<TR $bc[$var]>";
print "<TD><a href=\"comp.php3?socidp=$objp->idp\">$objp->nom</a></TD>\n";
print "<TD><a href=\"../comm/propal.php3?propalid=$objp->propalid\">$objp->ref</a></TD>\n";
print "<TD align=\"right\">".strftime("%d %B %Y",$objp->dp)."</TD>\n";
print "<TD align=\"right\">$objp->price</TD>\n";
print "<TD align=\"center\">$objp->statut</TD>\n";
print "</TR>\n";
$total = $total + $objp->price;
$subtotal = $subtotal + $objp->price;
$i++;
}
print "<tr><td align=\"right\" colspan=\"4\">Total : <b>$subtotal</b></td>\n";
print "<td align=\"left\">Euros HT</td></tr>\n";
print "<tr><td colspan=\"2\" align=\"right\"><b>Total ~ ".round($total * 6.55957)." FF HT</b></td>";
print "<td colspan=\"2\" align=\"right\"><b>Total : $total</b></td>";
print "<td align=\"left\"><b>Euros HT</b></td></tr>";
print "</TABLE>";
$db->free();
}
function factures ($db, $year, $month, $paye) {
$bc[0]="bgcolor=\"#90c090\"";
$bc[1]="bgcolor=\"#b0e0b0\"";
$sql = "SELECT s.nom, s.idp, f.facnumber, f.amount, int(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";
$sql .= " AND date_part('year', date(f.datef)) = $year ";
$sql .= " AND date_part('month', date(f.datef)) = $month ";
$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=\"3\">";
print "<TR bgcolor=\"orange\"><td colspan=\"3\"><b>Factures</b></td></tr>";
print "<TR bgcolor=\"orange\">";
print "<TD>Societe</td>";
print "<TD>Num</TD>";
print "<TD align=\"right\">Date</TD>";
print "<TD align=\"right\">Montant</TD>";
print "<TD align=\"right\">Pay<61></TD>";
print "</TR>\n";
$var=True;
while ($i < $num) {
$objp = $db->fetch_object( $i);
$var=!$var;
print "<TR $bc[$var]>";
print "<TD><a href=\"comp.php3?socidp=$objp->idp\">$objp->nom</a></TD>\n";
print "<TD><a href=\"facture.php3?facid=$objp->facid\">$objp->facnumber</a></TD>\n";
if ($objp->df > 0 ) {
print "<TD align=\"right\">".strftime("%d %B %Y",$objp->df)."</TD>\n";
} else {
print "<TD align=\"right\"><b>!!!</b></TD>\n";
}
print "<TD align=\"right\">$objp->amount</TD>\n";
$payes[1] = "oui";
$payes[0] = "<b>non</b>";
print "<TD align=\"right\">".$payes[$objp->paye]."</TD>\n";
print "</TR>\n";
$total = $total + $objp->amount;
$i++;
}
print "<tr><td colspan=\"3\" align=\"right\"><b>Total ~ ".round($total * 6.55957)." FF HT</b></td>";
print "<td align=\"right\"><b>Total : $total</b></td><td></td></tr>";
print "</TABLE>";
$db->free();
}
}
}
function pt ($db, $sql, $year) {
$bc[0]="bgcolor=\"#90c090\"";
$bc[1]="bgcolor=\"#b0e0b0\"";
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows();
$i = 0; $total = 0 ;
print "<p><TABLE border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"3\">";
print "<TR bgcolor=\"orange\">";
print "<TD>Mois</TD>";
print "<td align=\"right\">Montant</td></tr>\n";
$var=True;
$month = 1 ;
while ($i < $num) {
$obj = $db->fetch_object( $i);
$var=!$var;
if ($obj->dm > $month ) {
for ($b = $month ; $b < $obj->dm ; $b++) {
print "<TR $bc[$var]>";
print "<TD>".strftime("%B",mktime(12,0,0,$b, 1, $year))."</TD>\n";
print "<TD align=\"right\">0</TD>\n";
print "</TR>\n";
$var=!$var;
$ca[$b] = 0;
}
}
if ($obj->sum > 0) {
print "<TR $bc[$var]>";
print "<td><a href=\"comp.php3?details=1&year=$year&month=$obj->dm\">";
print strftime("%B",mktime(12,0,0,$obj->dm, 1, $year))."</TD>\n";
print "<TD align=\"right\">$obj->sum</TD>\n";
print "</TR>\n";
$month = $obj->dm + 1;
$ca[$obj->dm] = $obj->sum;
$total = $total + $obj->sum;
}
$i++;
}
if ($num) {
$beg = $obj->dm;
} else {
$beg = 1 ;
}
if ($beg <= 12 ) {
for ($b = $beg + 1 ; $b < 13 ; $b++) {
$var=!$var;
print "<TR $bc[$var]>";
print "<TD>".strftime("%B",mktime(12,0,0,$b, 1, $year))."</TD>\n";
print "<TD align=\"right\">0</TD>\n";
print "</TR>\n";
$ca[$b] = 0;
}
}
print "<tr><td align=\"right\">Total :</td><td align=\"right\"><b>$total</b></td></tr>";
print "</table>";
$db->free();
return $ca;
}
}
function ppt ($db, $year, $socidp) {
print "<table width=\"100%\">";
print "<tr><td valign=\"top\" width=\"30%\">";
print "CA Pr<50>visionnel bas<61> sur les propal $year";
print "</td><td valign=\"top\">CA R<>alis<69> $year</td>";
print "<td valign=\"top\">Delta $year</td></tr>";
print "<tr><td valign=\"top\" width=\"30%\">";
$sql = "SELECT sum(f.price), date_part('month', date(f.datep)) as dm";
$sql .= " FROM llx_propal as f WHERE fk_statut in (1,2) AND date_part('year', date(f.datep)) = $year ";
if ($socidp) {
$sql .= " AND f.fk_soc = $socidp";
}
$sql .= " GROUP BY dm";
$prev = pt($db, $sql, $year);
print "</td><td valign=\"top\" width=\"30%\">";
$sql = "SELECT sum(f.amount), date_part('month', date(f.datef)) as dm";
$sql .= " FROM llx_facture as f WHERE f.paye = 1 AND date_part('year', date(f.datef)) = $year ";
if ($socidp) {
$sql .= " AND f.fk_soc = $socidp";
}
$sql .= " GROUP BY dm";
$ca = pt($db, $sql, $year);
print "</td><td valign=\"top\" width=\"30%\">";
print "<p><TABLE border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"3\">";
print "<TR bgcolor=\"orange\">";
print "<TD>Mois</TD>";
print "<TD align=\"right\">Montant</TD>";
print "</TR>\n";
$bc[0]="bgcolor=\"#90c090\"";
$bc[1]="bgcolor=\"#b0e0b0\"";
$var = 1 ;
for ($b = 1 ; $b <= 12 ; $b++) {
$var=!$var;
$delta = $ca[$b] - $prev[$b];
$deltat = $deltat + $delta ;
print "<TR $bc[$var]>";
print "<TD>".strftime("%B",mktime(12,0,0,$b, 1, $year))."</TD>\n";
print "<TD align=\"right\">".$delta."</TD>\n";
print "</TR>\n";
}
$ayear = $year - 1;
$acat = get_ca($db, $ayear, $socidp) - get_ca_propal($db, $ayear, $socidp);
print "<tr><td align=\"right\">Total :</td><td align=\"right\">$deltat</td></tr>";
print "<tr><td align=\"right\">Rappel $ayear :</td><td align=\"right\">$acat</td></tr>";
print "<tr><td align=\"right\">Soit :</td><td align=\"right\"><b>".($acat+$deltat)."</b></td></tr>";
print "</table>";
print "</td></tr></table>";
}
/*
*
*/
llxHeader();
$db = new Db();
if ($sortfield == "") {
$sortfield="lower(p.label)";
}
if ($sortorder == "") {
$sortorder="ASC";
}
if ($year == 2001) {
ppt($db, 2001, $socidp);
} elseif ($year == 2000) {
ppt($db, 2000, $socidp);
} else {
ppt($db, 2001, $socidp);
print "<p>";
ppt($db, 2000, $socidp);
}
if ($details == 1) {
print "<TABLE border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\"><tr><td valign=\"top\" width=\"50%\">";
factures ($db, $year, $month, 1);
print "</td><td valign=\"top\" width=\"50%\">";
propals ($db, $year, $month);
print "</td></tr></table>";
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

135
htdocs/compta/fac.php3 Normal file
View File

@@ -0,0 +1,135 @@
<?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("../lib/functions.inc.php3");
llxHeader();
print "Factures";
$bc[0]="bgcolor=\"#90c090\"";
$bc[1]="bgcolor=\"#b0e0b0\"";
$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;
print "<P>";
$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, f.tva, f.remise, f.total ";
$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";
}
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 "<TABLE border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
print "<TR bgcolor=\"orange\">";
print "<TD>Num&eacute;ro</TD>";
print "<TD><a href=\"$PHP_SELF?sortfield=lower(p.label)&sortorder=ASC\">Societe</a></td>";
print "<TD align=\"right\">Date</TD><TD align=\"right\">Montant</TD>";
print "<TD align=\"right\">Remise</TD><TD align=\"right\">TVA</TD>";
print "</TR>\n";
$var=True;
while ($i < $num) {
$objp = $db->fetch_object( $i);
$var=!$var;
print "<TR $bc[$var]>";
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/%b/%Y",$objp->df)."</td>";
} else {
print "<TD align=\"right\"><b>!!!</b></TD>\n";
}
print "<TD align=\"right\">".price($objp->amount)."</TD>\n";
print "<TD align=\"right\">".price($objp->remise)."</TD>\n";
print "<TD align=\"right\">".price($objp->tva)."</TD>\n";
print "<TD align=\"right\">".price($objp->total)."</TD>\n";
$total = $total + $objp->amount;
$subtotal = $subtotal + $objp->amount;
print "<TD align=\"right\">".price($subtotal / ($j + 1))."</TD>\n";
print "</TR>\n";
$i++;
$j++;
}
}
if ($i == 0) { $i=1; } if ($j == 0) { $j=1; }
print "<tr><td></td><td>$j factures</td><td colspan=\"2\" align=\"right\">";
print "<small>Total : ".francs($subtotal)." FF</small></td>";
print "<td align=\"right\">Sous Total :<b> ".price($subtotal)."</b></td><td>euros HT</td>";
print "<td align=\"right\">Moyenne :<b> ".price($subtotal/ $j)."</b></td></tr>";
print "<tr bgcolor=\"#d0d0d0\"><td></td><td>$i factures</td><td colspan=\"2\" align=\"right\">";
print "<small>Total : ".francs($total)." FF</small></td>";
print "<td 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();
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

346
htdocs/compta/facture.php3 Normal file
View File

@@ -0,0 +1,346 @@
<?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.
*
*/
require("./pre.inc.php3");
llxHeader();
$_MONNAIE = $GLOBALS["_MONNAIE"];
$db = new Db();
if ($sortorder == "") {
$sortfield="lower(s.nom)";
$sortorder="ASC";
}
$bc[0]="bgcolor=\"#90c090\"";
$bc[1]="bgcolor=\"#b0e0b0\"";
$yn["1"] = "oui";
$yn["0"] = "non";
if ($action == 'valid') {
$sql = "UPDATE llx_facture set fk_statut = 1 WHERE rowid = $facid ;";
$result = $db->query( $sql);
}
if ($action == 'payed') {
$sql = "UPDATE llx_facture set paye = 1 WHERE rowid = $facid ;";
$result = $db->query( $sql);
}
if ($action == 'delete') {
$sql = "DELETE FROM llx_facture WHERE rowid = $facid;";
if ( $db->query( $sql) ) {
$sql = "DELETE FROM llx_fa_pr WHERE fk_facture = $facid;";
if (! $db->query( $sql) ) {
print $db->error();
}
} else {
print $db->error();
}
$facid = 0 ;
}
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><b>Facture $facid</b>&nbsp;[<a href=\"facture.php3?facid=$facid\">reload</a>]</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<63>t<EFBFBD></td><td colspan=\"2\"><b><a href=\"../comm/index.php3?socid=$obj->socidp\">$obj->socnom</a></b></td></tr>";
print "<tr><td>Num<EFBFBD>ro</td><td colspan=\"2\"><b>$obj->facnumber</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><td><small>soit</small></td><td align=\"right\"><small>".francs(inctva($obj->amount))."</small></td><td><small>francs</small></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 bgcolor=\"orange\">";
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<75> :</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%\">[<a href=\"../comm/ventes.php3?socid=$obj->socidp&facid=$facid&action=add\">Emettre une vente</a>]</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 && $resteapayer == 0 && $obj->paye == 0) {
print "<td align=\"center\" bgcolor=\"#e0e0e0\" width=\"25%\">[<a href=\"$PHP_SELF?facid=$facid&action=payed\">Classer 'Pay<61>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<EFBFBD>rer la facture</a></td>";
}
print "</tr></table><p>";
/*
* Documents g<>n<EFBFBD>r<EFBFBD>s
*
*/
print "<hr>";
print "<table width=\"100%\" cellspacing=2><tr><td width=\"50%\" valign=\"top\">";
print "<b>Documents g<>n<EFBFBD>r<EFBFBD>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";
/*
* Generation de la facture
*
*/
if ($action == 'pdf') {
print "<hr><b>G<>n<EFBFBD>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 commerciale associ<63>e</b><TABLE border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
print "<TR bgcolor=\"orange\">";
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 ($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 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<61></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=\"$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";
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>';
$yn[1] = "oui";
$yn[0] = "<b>non</b>";
$total = $total + $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++;
}
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>";
}
$db->free();
} else {
print $db->error();
}
}
print "<P>";
liste($db, 0);
print "<P>";
liste($db, 1);
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

221
htdocs/compta/genfac.php3 Normal file
View File

@@ -0,0 +1,221 @@
<?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("../lib/functions.inc.php3");
llxHeader();
$db = new Db();
if ($sortorder == "") {
$sortfield="lower(s.nom)";
$sortorder="ASC";
}
$bc[0]="bgcolor=\"#90c090\"";
$bc[1]="bgcolor=\"#b0e0b0\"";
$yn["1"] = "oui";
$yn["0"] = "non";
if ($action == 'valid') {
$sql = "UPDATE llx_facture set fk_statut = 1 WHERE rowid = $facid ;";
$result = $db->query( $sql);
}
if ($action == 'payed') {
$sql = "UPDATE llx_facture set paye = 1 WHERE rowid = $facid ;";
$result = $db->query( $sql);
}
if ($action == 'delete') {
$sql = "DELETE FROM llx_facture WHERE rowid = $facid ; DELETE FROM llx_fa_pr WHERE fk_facture = $facid";
$result = $db->query( $sql);
$facid = 0 ;
}
if ($facid > 0) {
$sql = "SELECT s.nom as socnom, s.idp as socidp, f.facnumber, f.amount, int(f.datef) as df, f.paye, f.fk_statut as statut, f.author ";
$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();
}
$factex = "\documentclass[a4paper,11pt]{article}
\usepackage[francais]{babel}
\usepackage[dvips]{graphics}
\usepackage{fancyhdr}
%
%
\\newcommand{\aquatre}{
\setlength{\oddsidemargin}{0.5cm}
\setlength{\evensidemargin}{0.5cm}
\setlength{\\textwidth}{16cm}
%\setlength{\\topmargin}{0.5cm}
%\setlength{\\textheight}{24cm}
%\setlength{\headheight}{0cm}
%\setlength{\headsep}{0cm}
\setlength{\parindent}{0.5cm}
\setlength{\parskip}{0.2cm}
}
%
% Debut du document
%
\aquatre
\\title{Conseil d'administration du 30 juin 2001}
\fancyhead{}
\fancyhead[RO,LE]{Conseil d'administration du 30 juin 2001}
\fancyfoot[C]{Page \\thepage}
\pagestyle{fancy}
\begin{document}
toto
\end{document}";
$filename = "/tmp/fac.tex";
$fp = fopen($filename, "w");
fwrite($fp, $factex);
fclose($fp);
print "latex $filename<p>";
$outp = `cd /tmp ; pdflatex $filename`;
print "<p>$outp<p>";
} else {
/*
* Liste
*
*/
function liste($db, $paye) {
global $bc, $year, $month;
$sql = "SELECT s.nom, s.idp, f.facnumber, f.amount, int(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 ($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 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<61></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=\"$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";
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\">$objp->amount</TD>\n";
$yn[1] = "oui";
$yn[0] = "<b>non</b>";
$total = $total + $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++;
}
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>euros HT</td>";
print "<td align=\"right\"><b>Moyenne : ".round($total/ $i)."</b></td></tr>";
print "</TABLE>";
$db->free();
}
}
}
print "<P>";
liste($db, 0);
print "<P>";
liste($db, 1);
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

156
htdocs/compta/index.php3 Normal file
View File

@@ -0,0 +1,156 @@
<?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();
print "Factures <20>mises";
$bc[0]="bgcolor=\"#90c090\"";
$bc[1]="bgcolor=\"#b0e0b0\"";
$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;
print "<P>";
$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 ($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.paye, f.datef DESC ";
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows();
if ($num > 0) {
$i = 0;
print "<TABLE border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
print "<TR bgcolor=\"orange\">";
print "<TD>[<a href=\"$PHP_SELF\">Tous</a>]</td>";
print "<TD>Num&eacute;ro</TD>";
print "<TD><a href=\"$PHP_SELF?sortfield=lower(p.label)&sortorder=ASC\">Societe</a></td>";
print "<TD align=\"right\">Date</TD><TD align=\"right\">Montant</TD>";
print "<TD align=\"right\">Pay<61></TD><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></td><td>$i factures</td><td colspan=\"2\" align=\"right\">";
print "<small>Total : ".francs($total)." FF</small></td>";
print "<td align=\"right\">Sous Total :<b> ".price($total)."</b></td><td>euros HT</td>";
print "<td align=\"right\">Moyenne :<b> ".price($total / ($i+1))."</b></td></tr>";
print "<TR bgcolor=\"orange\">";
print "<TD>[<a href=\"$PHP_SELF\">Tous</a>]</td>";
print "<TD>Num&eacute;ro</TD>";
print "<TD><a href=\"$PHP_SELF?sortfield=lower(p.label)&sortorder=ASC\">Societe</a></td>";
print "<TD align=\"right\">Date</TD><TD align=\"right\">Montant</TD>";
print "<TD align=\"right\">Pay<61></TD><TD align=\"right\">Moyenne</TD>";
print "</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 "<TD align=\"right\">".price($subtotal / ($j + 1))."</TD>\n";
print "</TR>\n";
$i++;
$j++;
}
}
if ($i == 0) { $i=1; } if ($j == 0) { $j=1; }
print "<tr><td></td><td>$j factures</td><td colspan=\"2\" align=\"right\">";
print "<small>Total : ".francs($subtotal)." FF</small></td>";
print "<td align=\"right\">Sous Total :<b> ".price($subtotal)."</b></td><td>euros HT</td>";
print "<td align=\"right\">Moyenne :<b> ".price($subtotal/ $j)."</b></td></tr>";
print "<tr bgcolor=\"#d0d0d0\"><td></td><td>$i factures</td><td colspan=\"2\" align=\"right\">";
print "<small>Total : ".francs($total)." FF</small></td>";
print "<td 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();
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

147
htdocs/compta/pmt.php3 Normal file
View File

@@ -0,0 +1,147 @@
<?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");
$bc[0]="bgcolor=\"#90c090\"";
$bc[1]="bgcolor=\"#b0e0b0\"";
$a = setlocale("LC_TIME", "FRENCH");
/*
*
*/
llxHeader();
print "Point mort";
$db = new Db();
if ($action == 'update') {
$datepm = mktime(12, 0 , 0, $pmonth, 1, $pyear);
$sql = "DELETE FROM llx_pointmort WHERE int(month) = $datepm ;";
$sql .= "INSERT INTO llx_pointmort VALUES ($datepm, $pm)";
$result = $db->query($sql);
}
print "<TABLE border=\"0\" cellspacing=\"0\" cellpadding=\"4\">";
print "<tr><td valign=\"top\">";
$sql = "SELECT amount, int(month) as dm FROM llx_pointmort ORDER BY month DESC";
$result = $db->query($sql);
if ($result) {
print "<p><TABLE border=\"0\" cellspacing=\"0\" cellpadding=\"4\">";
print "<TR bgcolor=\"orange\">";
print "<TD>Mois</TD>";
print "<TD align=\"right\">Montant</TD>";
print "</TR>\n";
$bc[0]="bgcolor=\"#90c090\"";
$bc[1]="bgcolor=\"#b0e0b0\"";
$var = 1 ;
$i = 0;
$num = $db->num_rows();
while ($i < $num) {
$obj = $db->fetch_object( $i);
$var=!$var;
print "<TR $bc[$var]>";
print "<TD>".strftime("%Y %B",$obj->dm)."</TD>\n";
print "<TD align=\"right\">$obj->amount</TD>\n";
print "</TR>\n";
$i++;
}
print "</table>";
}
print "</td><td valign=\"top\">";
print "<form action=\"$PHP_SELF\" method=\"post\">";
print "<input type=\"hidden\" name=\"action\" value=\"update\">";
$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 "Date :";
$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><br>";
print "Valeur : <input type=\"text\" name=\"pm\"><br>";
print "<input type=\"submit\" value=\"Mettre a jour\">";
print "</form>";
print "</td></tr></table>";
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@@ -0,0 +1,190 @@
<?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");
$bc[0]="bgcolor=\"#90c090\"";
$bc[1]="bgcolor=\"#b0e0b0\"";
$a = setlocale("LC_TIME", "FRENCH");
function pt ($db, $sql) {
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows();
$i = 0;
$total = 0 ;
$month = 1 ;
while ($i < $num) {
$obj = $db->fetch_object( $i);
$ca[$obj->dm] = $obj->sum;
$i++;
}
$db->free();
return $ca;
}
}
function pm ($db) {
$sql = "SELECT amount, date_format('%Y%m',month) as dm FROM llx_pointmort";
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows();
$i = 0; $total = 0 ;
$month = 1 ;
while ($i < $num) {
$obj = $db->fetch_object( $i);
$ca[$obj->dm] = $obj->amount;
print $obj->dm ."=". $obj->amount ."<br>";
$i++;
}
$db->free();
return $ca;
}
}
function ppt ($db) {
$sql = "SELECT sum(f.amount), date_format(f.datef,'%Y%m') as dm";
$sql .= " FROM llx_facture as f WHERE f.paye = 1";
$sql .= " GROUP BY dm";
$ca = pt($db, $sql);
$ptmt = pm($db);
print "<p><TABLE border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"3\">";
print "<TR bgcolor=\"orange\">";
print "<TD>&nbsp;</TD>";
print "<TD>Mois</TD>";
print "<TD align=\"right\">CA</TD>";
print "<TD align=\"right\">Point mort</TD>";
print "<TD align=\"right\">Delta</TD>";
print "<TD align=\"right\">Somme</TD>";
print "<TD align=\"right\">Somme par an</TD>";
print "<TD align=\"right\">Somme / nb mois</TD>";
print "<TD align=\"right\">Ecart</TD>";
print "</TR>\n";
$bc[0]="bgcolor=\"#90c090\"";
$bc[1]="bgcolor=\"#b0e0b0\"";
$var = 1 ;
$pmt = 0 ;
$subpmt = 0 ; $totalca = 0 ;
$totalpm = 0;
$xdate = mktime(0, 0, 0, 7 , 1, 2000);
$oldyear = 0;
$i = 1;
while ($xdate < time()) {
if ($oldyear <> date("Y",$xdate)) {
$oldyear = date("Y",$xdate);
$subpmt = 0 ;
print '<TR><td>&nbsp;</td><td>'.$oldyear.'</td>';
print '<td colspan="7" align="center">&nbsp;</td></tr>';
}
$var=!$var;
print "<TR $bc[$var]><td>$i</td>";
print "<TD>".strftime("%Y %B", $xdate)."</TD>\n";
$b = strftime("%Y", $xdate) . strftime("%m", $xdate);
$totalca = $ca[$b] + $totalca;
$totalpm = $ptmt[$b] + $totalpm;
$pm = $ca[$b] - $ptmt[$b];
$pmt = $pmt + $pm;
$subpmt = $subpmt + $pm;
if ($ca[$b]) {
print "<TD align=\"right\">".$ca[$b]."</TD>\n";
} else {
print "<TD align=\"right\">0</TD>\n";
}
print "<TD align=\"right\">".$ptmt[$b]."</TD>\n";
if ($pm > 0) {
print "<TD align=\"right\"><b>+$pm</b></TD>\n";
} else {
print "<TD align=\"right\">$pm</TD>\n";
}
print "<TD align=\"right\">$pmt</TD>\n";
print "<TD align=\"right\">$subpmt</TD>\n";
$pmbymonth = round($pmt/$i);
print "<TD align=\"right\">$pmbymonth</TD>\n";
$pmbymdelta = ($pmbymonth - $pmbymontha);
if ( $pmbymdelta > 0 ) {
print "<TD align=\"right\"><b> +$pmbymdelta</b></TD>\n";
} else {
print "<TD align=\"right\">$pmbymdelta</TD>\n";
}
$pmbymontha = $pmbymonth;
print "</TR>\n";
$xdate = mktime(0, 0, 0, date("m", $xdate + (33 * 24 * 3600)), 1 , date("Y", $xdate + (33 * 24 * 3600))) ;
$i++;
}
print "<tr><td colspan=\"2\" align=\"right\">Totaux en euros :</td><td align=\"right\">$totalca</td>";
print "<td align=\"right\">$totalpm</td><td align=\"right\" bgcolor=\"#f0f0f0\">$pmt</td>";
print "<td colspan=\"4\">&nbsp;</td></tr>";
print "<tr><td colspan=\"2\" align=\"right\">Totaux en francs :</td><td align=\"right\">".francs($totalca)."</td>";
print "<td align=\"right\">".francs($totalpm)."</td>";
print "<td align=\"right\">".francs($pmt)."</td>";
print "<td colspan=\"4\">&nbsp;</td></tr>";
print "</table>";
}
/*
*
*/
llxHeader();
print "<b>Point mort</b>";
$db = new Db();
ppt($db, 0);
print "<br><br><br><table cellspacing=0 border=1 cellpadding=3>";
print "<tr><td bgcolor=\"#e0e0e0\"><a href=\"pmt.php3\">Param<61>trer le point mort</a></td></tr>";
print "</table>";
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

110
htdocs/compta/pre.inc.php3 Normal file
View File

@@ -0,0 +1,110 @@
<?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");
function llxHeader($head = "") {
global $PREFIX;
print "<HTML>\n<HEAD>$head\n</HEAD>\n";
?>
<BODY BGCOLOR="#c0c0c0" TOPMARGIN="0" BOTTOMMARGIN="0" LEFTMARGIN="0" RIGHTMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0">
<?PHP
print "<TABLE border=\"0\" width=\"100%\">\n";
print "<TR bgcolor=\"".$GLOBALS["TOPBAR_BGCOLOR"]."\">";
print "<TD width=\"20%\" bgcolor=\"#e0e0e0\"><B>" . $GLOBALS["MAIN_TITLE"] . "</B></TD>";
print "<TD width=\"20%\" bgcolor=\"#e0e0e0\" align=\"center\"><A href=\"../tech/\">Technique</A></TD>";
print "<TD width=\"20%\" bgcolor=\"#e0e0e0\" align=\"center\"><A href=\"../comm/\">Commercial</A></TD>";
print "<TD width=\"20%\" align=\"center\"><A href=\"../compta/\">Compta</A></TD>";
print "<TD width=\"20%\" bgcolor=\"#e0e0e0\" align=\"center\"><A href=\"../stats/\">Stats</A></TD>";
print "</TR></TABLE>\n";
print "<TABLE border=\"1\" width=\"100%\">";
print "<TR><TD valign=\"top\" align=\"right\">";
print "<TABLE border=\"1\" cellspacing=\"0\" width=\"100%\" cellpadding=\"3\">";
print "<TR><TD valign=\"top\" align=\"right\">";
print "<center><b>" . $GLOBALS["dbname"] . " - " . $GLOBALS["REMOTE_USER"] ."</B></center>";
print "<A href=\"/\">Accueil</A>";
print "</td></tr>";
print "<TR><TD valign=\"top\" align=\"right\">";
print "<CENTER><A href=\"/compta/index.php3\">Factures</A></CENTER><p>\n";
print "<A href=\"paiement.php3\">Paiements</A><BR>\n";
print "<A href=\"fac.php3\">admin fac</A><BR>\n";
print "</td></tr>";
print "<TR><TD valign=\"top\" align=\"right\">";
print "<CENTER>Chiffres d'affaires</CENTER><br>\n";
print "<A href=\"ca.php3\">R<>alis<69></A><BR>\n";
print "<A href=\"prev.php3\">Pr<50>visionnel</A><BR>\n";
print "<A href=\"comp.php3\">Comparatif</A>\n";
print "</td></tr>";
print "<TR><TD valign=\"top\" align=\"right\">";
print "<CENTER>Analyses</CENTER><br>\n";
print "<A href=\"casoc.php3\">CA par societe</A><BR>\n";
print "<A href=\"pointmort.php3\">Point mort</A><BR>\n";
print "<A href=\"tva.php3\">TVA</A><BR>\n";
print "</td></tr>";
print "<TR><TD valign=\"top\" align=\"center\">";
print "<A href=\"/comm/propal.php3\">Propal</A><BR>\n";
print "</td></tr>";
print "<TR><TD valign=\"top\" align=\"center\">";
print "<A href=\"bank/index.php3\">Bank</A><BR>\n";
print "</td></tr>";
print "<TR><TD valign=\"top\" align=\"center\">";
print "<A href=\"/comm/index.php3\">Societes</A>\n";
print "<form action=\"/comm/index.php3\">";
print "<input type=\"text\" name=\"socname\" size=\"8\">";
print "<input type=\"submit\" value=\"nom\">";
print "</form>";
print "<form action=\"/comm/index.php3\">";
print "<input type=\"text\" name=\"socid\" size=\"5\">";
print "<input type=\"submit\" value=\"id\">";
print "</form>";
print "</td></tr>";
print "</table>";
print "</TD>\n<TD valign=\"top\" width=\"85%\">\n";
}
/*
*
*/
function llxFooter($foot='') {
print "</TD></TR></TABLE>\n";
print "$foot</BODY></HTML>";
}
// $Id$
// $Source$
?>

119
htdocs/compta/prev.php3 Normal file
View File

@@ -0,0 +1,119 @@
<?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("../lib/functions.inc.php3");
function pt ($db, $sql, $title)
{
$bc[0]='bgcolor="#90c090"';
$bc[1]='bgcolor="#b0e0b0"';
print '<p><TABLE border="1" width="100%" cellspacing="0" cellpadding="4">';
print "<TR bgcolor=\"orange\">";
print "<TD>$title</TD>";
print "<TD align=\"right\">Montant</TD>";
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows();
$i = 0; $total = 0 ;
print "</TR>\n";
$var=True;
while ($i < $num)
{
$obj = $db->fetch_object( $i);
$var=!$var;
print '<TR '.$bc[$var].'>';
print '<TD>'.$obj->dm.'</TD>';
print '<TD align="right">'.price($obj->amount).'</TD>';
print "</TR>\n";
$total = $total + $obj->amount;
$i++;
}
print "<tr><td colspan=\"2\" align=\"right\"><b>Total : ".price($total)."</b> euros HT</td></tr>";
$db->free();
}
else
{
print "<tr><td>".$db->error() . "</td></tr>";
}
print "</TABLE>";
}
/*
*
*/
llxHeader();
$db = new Db();
if ($sortfield == "") {
$sortfield="lower(p.label)";
}
if ($sortorder == "") {
$sortorder="ASC";
}
$in = "(1,2)";
//$in = "(3)";
print "<P>CA Pr<50>visionnel bas<61> sur les propal <b>ouvertes</b> et <b>sign<67>es</b>";
print '<table width="100%">';
print '<tr><td valign="top">';
$sql = "SELECT sum(f.price) as amount, date_format(f.datep,'%Y-%m') as dm";
$sql .= " FROM llx_propal as f WHERE fk_statut in $in";
$sql .= " GROUP BY dm DESC";
pt($db, $sql, "Mois");
print '</td><td valign="top">';
$sql = "SELECT sum(f.price) as amount, year(f.datep) as dm";
$sql .= " FROM llx_propal as f WHERE fk_statut in $in";
$sql .= " GROUP BY dm DESC";
pt($db, $sql, "Ann<EFBFBD>e");
print "<P>";
$sql = "SELECT sum(f.price) as amount, month(f.datep) as dm";
$sql .= " FROM llx_propal as f WHERE fk_statut in $in";
$sql .= " GROUP BY dm";
pt($db, $sql, "Mois cumul<75>s");
print "</td></tr></table>";
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

104
htdocs/compta/tva.php3 Normal file
View File

@@ -0,0 +1,104 @@
<?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");
$bc[0]="bgcolor=\"#90c090\"";
$bc[1]="bgcolor=\"#b0e0b0\"";
$a = setlocale("LC_TIME", "FRENCH");
/*
*
*
*/
function pt ($db, $sql, $date) {
$bc[0]="bgcolor=\"#90c090\"";
$bc[1]="bgcolor=\"#b0e0b0\"";
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows();
$i = 0; $total = 0 ;
print "<p><TABLE border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
print "<TR bgcolor=\"orange\">";
print "<TD width=\"60%\">$date</TD>";
print "<TD align=\"right\">Montant</TD>";
print "<td>&nbsp;</td>\n";
print "</TR>\n";
$var=True;
while ($i < $num) {
$obj = $db->fetch_object( $i);
$var=!$var;
print "<TR $bc[$var]>";
print "<TD>$obj->dm</TD>\n";
print "<TD align=\"right\">".price($obj->amount)."</TD><td>&nbsp;</td>\n";
print "</TR>\n";
$total = $total + $obj->amount;
$i++;
}
print "<tr><td align=\"right\">Total :</td><td align=\"right\"><b>".price($total)."</b></td><td>euros&nbsp;HT</td></tr>";
print "</TABLE>";
$db->free();
}
}
/*
*
*/
llxHeader();
$db = new Db();
$yearc = strftime("%Y",time());
echo '<table width="100%"><tr><td width="50%" valign="top">';
print "<b>TVA collect<63>e</b>";
for ($y = $yearc ; $y >= $conf->years ; $y=$y-1 ) {
print "<table width=\"100%\">";
print "<tr><td valign=\"top\">";
$sql = "SELECT sum(f.tva) as amount , date_format(f.datef,'%Y-%m') as dm";
$sql .= " FROM llx_facture as f WHERE f.paye = 1 AND f.datef >= '$y-01-01' AND f.datef <= '$y-12-31' ";
$sql .= " GROUP BY dm DESC";
pt($db, $sql,"Ann<EFBFBD>e $y");
print "</td></tr></table>";
}
echo '</td><td valign="top" width="50%">';
echo 'Tva Pay<61>e<br>';
echo '</td></tr></table>';
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

1
htdocs/conf/.cvsignore Normal file
View File

@@ -0,0 +1 @@
conf.class.php3

View File

@@ -0,0 +1,49 @@
<?PHP
/* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* $Id$
* $Source$
*
* Classe de configuration
*
* 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 Conf {
var $readonly;
var $dbi;
Function Conf() {
$this->db = new DbConf();
$this->readonly = 0;
$this->years = 2001;
$this->mode = 1 ;
}
}
class DbConf {
Function DbConf() {
$this->host = "localhost";
$this->user = "";
$this->pass = "";
$this->name = "dolibarr";
}
}
?>

View File

@@ -34,7 +34,7 @@ print "<li><A href=\"../comm/\">Commercial</A>";
print "<li><A href=\"../compta/\">Compta</A>"; print "<li><A href=\"../compta/\">Compta</A>";
print "<li><A href=\"../stats/\">Stats</A></ul>"; print "<li><A href=\"../stats/\">Stats</A></ul>";
print "<ul><li><A href=\"doc/\">Documents</A></ul>";
function valeur($sql) { function valeur($sql) {
global $db; global $db;
@@ -61,18 +61,22 @@ if ($db->ok) {
print "<td>Description</td><td>Valeur</TD>"; print "<td>Description</td><td>Valeur</TD>";
print "</TR>\n"; print "</TR>\n";
if (valeur($sql)) {
$var=!$var; $var=!$var;
$sql = "SELECT count(*) FROM llx_propal WHERE fk_statut = 0"; $sql = "SELECT count(*) FROM llx_propal WHERE fk_statut = 0";
print "<tr $bc[$var]><td><a href=\"comm/propal.php3?viewstatut=0\">Propales brouillons</a></td><td align=\"right\">".valeur($sql)."</td></tr>"; print "<tr $bc[$var]><td><a href=\"comm/propal.php3?viewstatut=0\">Propales brouillons</a></td><td align=\"right\">".valeur($sql)."</td></tr>";
}
if (valeur($sql)) {
$var=!$var; $var=!$var;
$sql = "SELECT count(*) FROM llx_propal WHERE fk_statut = 1"; $sql = "SELECT count(*) FROM llx_propal WHERE fk_statut = 1";
print "<tr $bc[$var]><td><a href=\"comm/propal.php3?viewstatut=1\">Propales ouvertes</a></td><td align=\"right\">".valeur($sql)."</td></tr>"; print "<tr $bc[$var]><td><a href=\"comm/propal.php3?viewstatut=1\">Propales ouvertes</a></td><td align=\"right\">".valeur($sql)."</td></tr>";
}
if (valeur($sql)) {
$var=!$var; $var=!$var;
$sql = "SELECT count(*) FROM llx_facture WHERE paye=0"; $sql = "SELECT count(*) FROM llx_facture WHERE paye=0";
print "<tr $bc[$var]><td><a href=\"compta/index.php3\">Factures en attente de paiement</a></td><td align=\"right\">".valeur($sql)."</td></tr>"; print "<tr $bc[$var]><td><a href=\"compta/index.php3\">Factures en attente de paiement</a></td><td align=\"right\">".valeur($sql)."</td></tr>";
}
print "</table><br>"; print "</table><br>";

View File

@@ -0,0 +1,121 @@
<?php
/* notes from Dan Potter:
Sure. I changed a few other things in here too though. One is that I let
you specify what the destination filename is (i.e., what is shows up as in
the attachment). This is useful since in a web submission you often can't
tell what the filename was supposed to be from the submission itself. I
also added my own version of chunk_split because our production version of
PHP doesn't have it. You can change that back or whatever though =).
Finally, I added an extra "\n" before the message text gets added into the
MIME output because otherwise the message text wasn't showing up.
/*
note: someone mentioned a command-line utility called 'mutt' that
can mail attachments.
*/
/*
If chunk_split works on your system, change the call to my_chunk_split
to chunk_split
*/
/* Note: if you don't have base64_encode on your sytem it will not work */
// simple class that encapsulates mail() with addition of mime file attachment.
class CMailFile {
var $subject;
var $addr_to;
var $text_body;
var $text_encoded;
var $mime_headers;
var $mime_boundary = "--==================_846811060==_";
var $smtp_headers;
function CMailFile($subject,$to,$from,$msg,$filename,$mimetype = "application/octet-stream", $mime_filename = false) {
$this->subject = $subject;
$this->addr_to = $to;
$this->smtp_headers = $this->write_smtpheaders($from);
$this->text_body = $this->write_body($msg);
$this->text_encoded = $this->attach_file($filename,$mimetype,$mime_filename);
$this->mime_headers = $this->write_mimeheaders($filename, $mime_filename);
}
function attach_file($filename,$mimetype,$mime_filename) {
$encoded = $this->encode_file($filename);
if ($mime_filename) $filename = $mime_filename;
$out = "--" . $this->mime_boundary . "\n";
$out = $out . "Content-type: " . $mimetype . "; name=\"$filename\";\n";
$out = $out . "Content-Transfer-Encoding: base64\n";
$out = $out . "Content-disposition: attachment; filename=\"$filename\"\n\n";
$out = $out . $encoded . "\n";
$out = $out . "--" . $this->mime_boundary . "--" . "\n";
return $out;
// added -- to notify email client attachment is done
}
function encode_file($sourcefile) {
if (is_readable($sourcefile)) {
$fd = fopen($sourcefile, "r");
$contents = fread($fd, filesize($sourcefile));
$encoded = my_chunk_split(base64_encode($contents));
fclose($fd);
}
return $encoded;
}
function sendfile() {
$headers = $this->smtp_headers . $this->mime_headers;
$message = $this->text_body . $this->text_encoded;
return mail($this->addr_to,$this->subject,$message,$headers);
}
function write_body($msgtext) {
$out = "--" . $this->mime_boundary . "\n";
$out = $out . "Content-Type: text/plain; charset=\"us-ascii\"\n\n";
$out = $out . $msgtext . "\n";
return $out;
}
function write_mimeheaders($filename, $mime_filename) {
if ($mime_filename) $filename = $mime_filename;
$out = "MIME-version: 1.0\n";
$out = $out . "Content-type: multipart/mixed; ";
$out = $out . "boundary=\"$this->mime_boundary\"\n";
$out = $out . "Content-transfer-encoding: 7BIT\n";
$out = $out . "X-attachments: $filename;\n\n";
return $out;
}
function write_smtpheaders($addr_from) {
$out = "From: $addr_from\n";
$out = $out . "Reply-To: $addr_from\n";
$out = $out . "X-Mailer: PHP3\n";
$out = $out . "X-Sender: $addr_from\n";
return $out;
}
}
// usage - mimetype example "image/gif"
// $mailfile = new CMailFile($subject,$sendto,$replyto,$message,$filename,$mimetype);
// $mailfile->sendfile();
// Splits a string by RFC2045 semantics (76 chars per line, end with \r\n).
// This is not in all PHP versions so I define one here manuall.
function my_chunk_split($str)
{
$stmp = $str;
$len = strlen($stmp);
$out = "";
while ($len > 0) {
if ($len >= 76) {
$out = $out . substr($stmp, 0, 76) . "\r\n";
$stmp = substr($stmp, 76);
$len = $len - 76;
}
else {
$out = $out . $stmp . "\r\n";
$stmp = ""; $len = 0;
}
}
return $out;
}
// end script
?>

View File

@@ -0,0 +1,245 @@
<?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/
*/
/*
* $Id$
* $Source$
*
*/
function price($amount) {
return number_format($amount, 2, '.', ' ');
//return sprintf("%.2f", $amount);
}
function francs($euros) {
return price($euros * 6.55957);
}
function tva($euros) {
return sprintf("%01.2f",($euros * 0.196));
}
function inctva($euros) {
return sprintf("%01.2f",($euros * 1.196));
}
function gljftime($format,$timestamp) {
$hour = substr($timestamp,11,2);
$min = substr($timestamp,14,2);
$sec = substr($timestamp,17,2);
$month = substr($timestamp,5,2);
$day = substr($timestamp,8,2);
$year = substr($timestamp,0,4);
$ftime = mktime($hour,$min,$sec,$month,$day,$year);
return strftime($format,$ftime);
}
function gljPrintTitle($title, $ispage, $page=0, $parm=0) {
$pageprev = $page - 1;
$pagenext = $page + 1;
print "<table width=\"100%\" cellspacing=\"0\"><tr><td>";
print "<b>$title</b></td><td align=\"right\">$basec <b>Page $pagenext</b>";
print "</td>";
if ($ispage) {
print "</tr>";
print "<tr><td>";
if ($page > 0) {
print "<A href=\"".$GLOBALS["PHP_SELF"]."?page=$pageprev&$parm\"><- ".$GLOBALS["_PAGE_PREV"]."</A>";
}
print "</td>\n";
print "<td align=\"right\"><A href=\"".$GLOBALS["PHP_SELF"]."?&page=$pagenext&$parm\">$_PAGE_NEXT -></A>\n";
}
print "</tr></table>";
};
function gljActiveSoc($db, $socidp) {
if ($db) {
$sql = "UPDATE societe set datea = " . time() . " WHERE idp= " . $socidp ;
$result = $db->query($sql);
if (!$result) {
return 1;
}
return 0;
}
}
function gljChangeSocAlias($db, $socidp, $alias) {
if ($db) {
$alias = strtolower(trim($alias));
$sql = "UPDATE societe set alias = '$alias' WHERE idp=$socidp" ;
$result = $db->query($sql);
if (!$result) {
return 1;
}
return 0;
}
}
function stat_print($basename,$bc1,$bc2,$ftc, $jour) {
$db = pg_Connect("","","","","$basename");
if (!$db) {
echo "Pas de connexion a la base\n";
exit ;
}
$offset = $jour * 9;
$sql="SELECT s.date, s.nb, l.libelle FROM stat_base as s, stat_cat as l WHERE s.cat = l.id ORDER by s.date DESC, s.cat ASC LIMIT 9 OFFSET $offset";
$result = $db->query($sql);
if (!$result) {
print "Erreur SELECT<br><h1>$sql</h1><br>";
return 1;
}
print "<table border=1 cellspacing=0 cellpadding=2>";
print "<tr><td><font color=\"white\">base <b>$basename</b></font></td>";
print "<td><font color=\"white\">libelle</font></td>";
print "</tr>";
$num = $db->num_rows();
$i = 0;
$tag = 1;
while ( $i < $num) {
$obj = $db->fetch_object( $i);
$tag = !$tag;
print "<TR><TD>$obj->date</TD><TD>$obj->libelle</TD>\n";
print "<TD align=\"center\">$obj->nb</TD></TR>\n";
$i++;
}
print "</TABLE>";
$db->free();
$db->close();
}
function tab_count($basename,$bc1,$bc2,$ftc) {
$db = pg_Connect("","","","","$basename");
if (!$db) {
echo "Pas de connexion a la base\n";
exit ;
}
$sql="SELECT count(*) AS nbcv from candidat WHERE active=1";
$result = $db->query($sql);
if (!$result) {
print "Erreur SELECT<br><h1>$sql</h1><br>";
return 1;
}
print "<table border=0 bgcolor=black cellspacing=0 cellpadding=0><tr><td>";
print "<table border=0 cellspacing=1 cellpadding=1>";
print "<tr><td><font color=\"white\">base <b>$basename</b></font></td>";
print "<td><font color=\"white\">libelle</font></td>";
print "</tr>";
$nbcv = $db->result( $i, "nbcv");
print "<tr $bc1><td><b>$ftc Nombre de CV</font></b></td>\n";
print "<td align=\"center\">$ftc $nbcv</td>\n";
print "</tr>\n";
$db->free();
$sql="SELECT count(*) AS nbcv from offre WHERE active=1";
$result = $db->query($sql);
if (!$result) {
print "Erreur SELECT<br><h1>$sql</h1><br>";
}
$nbcv = $db->result( $i, "nbcv");
print "<tr $bc2><td><b>$ftc Nombre d'offre</font></b></td>";
print "<td align=\"center\">$ftc $nbcv</td>";
print "</tr>";
$db->free();
$sql="SELECT count(*) AS nbcv from candidat WHERE active=0";
$result = $db->query($sql);
if (!$result) {
print "Erreur SELECT<br><h1>$sql</h1><br>";
}
$nbcv = $db->result( $i, "nbcv");
print "<tr $bc1><td><b>$ftc Nombre de CV inactifs</font></b></td>\n";
print "<td align=\"center\">$ftc $nbcv</td>";
print "</tr>";
$db->free();
$sql="SELECT count(*) AS nbcv from offre WHERE active=0";
$result = $db->query($sql);
if (!$result) {
print "Erreur SELECT<br><h1>$sql</h1><br>";
}
$nbcv = $db->result( $i, "nbcv");
print "<tr $bc2><td><b>$ftc Nombre d'offres inactives</font></b></td>\n";
print "<td align=\"center\">$ftc $nbcv</td>\n";
print "</tr>\n";
$db->free();
$sql="SELECT count(*) AS nbsoc from logsoc";
$result = $db->query($sql);
if (!$result) {
print "Erreur SELECT<br><h1>$sql</h1><br>";
}
$nbsoc = $db->result( $i, "nbsoc");
print "<tr $bc1><td><b>$ftc Nombre de logins societes</font></b></td>\n";
print "<td align=\"center\">$ftc $nbsoc</td>";
print "</tr>";
print "</td></tr></table></td></tr></table>";
$db->close();
}
?>

129
htdocs/lib/mysql.lib.php3 Normal file
View File

@@ -0,0 +1,129 @@
<?PHP
/* Copyright (C) 2001 Fabien Seisen <seisen@linuxfr.org>
* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* $Id$
* $Source$
*
* Classe Db
*
* 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 Db {
var $db, $results, $ok;
Function Db() {
global $conf;
$this->db = $this->connect($conf->db->host, $conf->db->user, $conf->db->pass);
if (! $this->db) {
print "Db->Db() rat<61><br>\n";
$this->ok = 0;
return 0;
}
$ret = $this->select_db($conf->db->name, $this->db);
$this->ok = 1;
return $ret;
}
Function select_db($database) {
return mysql_select_db($database, $this->db);
}
Function clone() {
$db2 = new Db("", "", "", "", "");
$db2->db = $this->db;
return $db2;
}
Function connect($host, $login, $passwd) {
$this->db = mysql_connect($host, $login, $passwd);
return $this->db;
}
Function pconnect($host, $login, $passwd) {
$this->db = mysql_pconnect($host, $login, $passwd);
return $this->db;
}
Function close() {
$this->ret = mysql_close($this->db);
return $this->ret;
}
Function query($query, $limit="", $offset="") {
$query = trim($query);
$this->results = mysql_query($query, $this->db);
return $this->results;
}
Function result($nb, $fieldname) {
return mysql_result($this->results, $nb, $fieldname);
}
Function free() {
return mysql_free_result($this->results);
}
Function fetch_object() {
return mysql_fetch_object($this->results);
}
Function plimit($limit=0,$offset=0) {
if ($offset > 0) {
return " LIMIT $offset,$limit ";
} else {
return " LIMIT $limit ";
}
}
Function pdate($fname) {
return "unix_timestamp($fname)";
}
Function idate($fname) {
return strftime("%Y%m%d%H%M%S",$fname);
}
Function fetch_array() {
return mysql_fetch_array($this->results);
}
Function fetch_row() {
return mysql_fetch_row($this->results);
}
Function fetch_field() {
return mysql_fetch_field($this->results);
}
Function num_rows() {
return mysql_num_rows($this->results);
}
Function num_fields() {
return mysql_num_fields($this->results);
}
Function error() {
return mysql_error($this->db);
}
Function last_insert_id() {
return mysql_insert_id();
}
Function affected_rows() {
return mysql_affected_rows();
}
}
?>

View File

@@ -20,7 +20,7 @@
AuthType Basic AuthType Basic
Auth_MySQL_Authoritative on Auth_MySQL_Authoritative on
Auth_MySQL_DB lolixfr Auth_MySQL_DB dolibarr
Auth_MySQL_Password_Table llx_user Auth_MySQL_Password_Table llx_user
Auth_MySQL_Username_Field login Auth_MySQL_Username_Field login
Auth_MySQL_Password_Field pass Auth_MySQL_Password_Field pass

View File

@@ -36,6 +36,13 @@ table:
cd tables \ cd tables \
&& make create && make create
data:
cd data \
&& make load
dev:
$(MYSQL) $(BASE) < data/data-dev.sql
droptable: droptable:
cd tables \ cd tables \
&& make drop && make drop

View File

@@ -87,10 +87,6 @@ delete from c_paiement;
insert into c_paiement (id,libelle) values (0, 'Cheque'); insert into c_paiement (id,libelle) values (0, 'Cheque');
insert into c_paiement (id,libelle) values (1, 'Virement'); insert into c_paiement (id,libelle) values (1, 'Virement');
delete from c_prestatype;
insert into c_prestatype (id,libelle) values (0, '---');
insert into c_prestatype (id,libelle) values (1, 'R<EFBFBD>gie');
insert into c_prestatype (id,libelle) values (2, 'Forfait');
delete from c_propalst; delete from c_propalst;
insert into c_propalst (id,label) values (0, '---'); insert into c_propalst (id,label) values (0, '---');

View File

@@ -29,7 +29,7 @@ create:
$(MYSQL) $(BASE) < c_effectif.sql $(MYSQL) $(BASE) < c_effectif.sql
$(MYSQL) $(BASE) < c_paiement.sql $(MYSQL) $(BASE) < c_paiement.sql
$(MYSQL) $(BASE) < c_pays.sql $(MYSQL) $(BASE) < c_pays.sql
$(MYSQL) $(BASE) < c_prestatype.sql
$(MYSQL) $(BASE) < c_propalst.sql $(MYSQL) $(BASE) < c_propalst.sql
$(MYSQL) $(BASE) < c_stcomm.sql $(MYSQL) $(BASE) < c_stcomm.sql
$(MYSQL) $(BASE) < c_typent.sql $(MYSQL) $(BASE) < c_typent.sql
@@ -43,6 +43,7 @@ create:
$(MYSQL) $(BASE) < llx_paiement.sql $(MYSQL) $(BASE) < llx_paiement.sql
$(MYSQL) $(BASE) < llx_pointmort.sql $(MYSQL) $(BASE) < llx_pointmort.sql
$(MYSQL) $(BASE) < llx_product.sql $(MYSQL) $(BASE) < llx_product.sql
$(MYSQL) $(BASE) < llx_projet.sql
$(MYSQL) $(BASE) < llx_propal.sql $(MYSQL) $(BASE) < llx_propal.sql
$(MYSQL) $(BASE) < llx_propaldet.sql $(MYSQL) $(BASE) < llx_propaldet.sql
$(MYSQL) $(BASE) < llx_soc_recontact.sql $(MYSQL) $(BASE) < llx_soc_recontact.sql
@@ -50,6 +51,7 @@ create:
$(MYSQL) $(BASE) < llx_ventes.sql $(MYSQL) $(BASE) < llx_ventes.sql
$(MYSQL) $(BASE) < societe.sql $(MYSQL) $(BASE) < societe.sql
$(MYSQL) $(BASE) < socpeople.sql $(MYSQL) $(BASE) < socpeople.sql
$(MYSQL) $(BASE) < socstatutlog.sql
drop: drop:
$(MYSQL) $(BASE) < drop.sql $(MYSQL) $(BASE) < drop.sql

View File

@@ -104,7 +104,11 @@ drop table if exists lang ;
drop table if exists langoffre ; drop table if exists langoffre ;
drop table if exists llx_bank; drop table if exists llx_bank;
drop table if exists llx_bank_account;
drop table if exists llx_bank_categ; drop table if exists llx_bank_categ;
drop table if exists llx_bank_class; drop table if exists llx_bank_class;
drop table if exists llx_bookmark; drop table if exists llx_bookmark;
@@ -119,12 +123,16 @@ drop table if exists llx_pointmort;
drop table if exists llx_product; drop table if exists llx_product;
drop table if exists llx_projet;
drop table if exists llx_propal; drop table if exists llx_propal;
drop table if exists llx_propaldet; drop table if exists llx_propaldet;
drop table if exists llx_soc_recontact; drop table if exists llx_soc_recontact;
drop table if exists llx_user;
drop table if exists llx_ventes; drop table if exists llx_ventes;
drop table if exists login ; drop table if exists login ;

View File

@@ -31,6 +31,8 @@ create table llx_user
firstname varchar(50), firstname varchar(50),
code varchar(4), code varchar(4),
email varchar(255), email varchar(255),
module_comm smallint default 1,
module_compta smallint default 1,
note text, note text,
UNIQUE INDEX(code) UNIQUE INDEX(code)

View File

@@ -4,6 +4,21 @@
-- --
-- $Id$ -- $Id$
-- $Source$ -- $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 societe create table societe
( (
@@ -11,13 +26,9 @@ create table societe
id varchar(32), -- private id id varchar(32), -- private id
active smallint default 0, -- active smallint default 0, --
parent integer default 0, -- parent integer default 0, --
intern bool default 1 NOT NULL, -- is an intern company tms timestamp,
cjn bool default 1 NOT NULL, -- is allowed to export to cjn
ssii bool default 0 NOT NULL, --
datec datetime, -- creation date datec datetime, -- creation date
datem datetime, -- modification date
datea datetime, -- activation date datea datetime, -- activation date
datel datetime, -- last login date
nom varchar(60), -- company name nom varchar(60), -- company name
address varchar(255), -- company adresse address varchar(255), -- company adresse
cp varchar(10), -- zipcode cp varchar(10), -- zipcode
@@ -30,30 +41,13 @@ create table societe
fk_effectif integer default 0, -- fk_effectif integer default 0, --
fk_typent integer default 0, -- fk_typent integer default 0, --
siren varchar(9), -- siren varchar(9), --
tchoozeid integer default 0, --
c_nom varchar(40), --
c_prenom varchar(40), --
c_tel varchar(20), --
c_mail varchar(80), --
description text, -- description text, --
viewed integer default 0, --
formatcv varchar(50), --
alias varchar(50), -- alias unix name for rewrite
fplus bool default 0 NOT NULL , -- flag fiche plus
logo varchar(255), --
pubkey varchar(32), --
caddie integer default 0, --
karma integer default 0, --
off_acc smallint default 0, -- offers accepted
off_ref smallint default 0, -- offers refused
fk_stcomm smallint default 0, -- commercial statut fk_stcomm smallint default 0, -- commercial statut
note text, -- note text, --
newsletter bool default 1, -- newsletter on or off
view_res_coord bool default 0, -- view resume personnal info
cabrecrut bool default 0, -- Cabinet de recrutement
services integer default 0, -- services integer default 0, --
reminder integer default 1, --
prefix_comm varchar(5), -- prefix commercial prefix_comm varchar(5), -- prefix commercial
client smallint default 0, -- client oui/non
fournisseur smallint default 0, -- fournisseur oui/non
UNIQUE INDEX(prefix_comm) UNIQUE INDEX(prefix_comm)
); );

View File

@@ -5,7 +5,7 @@
-- ======================================================================== -- ========================================================================
create table socstatutlog create table socstatutlog
( (
id serial, id integer AUTO_INCREMENT PRIMARY KEY,
datel datetime, datel datetime,
fk_soc integer, fk_soc integer,
fk_statut integer, fk_statut integer,