From 6c4baadf7a34a716fd3062ddff7c95d23397ff16 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Tue, 30 Apr 2002 10:44:42 +0000 Subject: [PATCH] Massive update --- htdocs/comm/actioncomm.php3 | 2 +- htdocs/comm/addpropal.php3 | 325 ++++++++++++++++ htdocs/comm/analyse.php3 | 122 ++++++ htdocs/comm/bookmark.php3 | 128 +++++++ htdocs/comm/index.php3 | 372 ++++--------------- htdocs/comm/people.php3 | 249 +++++++++++++ htdocs/comm/pre.inc.php3 | 51 +-- htdocs/comm/projet/index.php3 | 1 - htdocs/comm/propal.class.php3 | 145 ++++++++ htdocs/comm/propal.php3 | 570 +++++++++++++++++++++++++++++ htdocs/comm/recontact.php3 | 114 ++++++ htdocs/comm/relance.php3 | 130 +++++++ htdocs/comm/socnote.php3 | 228 ++++++++++++ htdocs/compta/bank/bilan.php3 | 59 +++ htdocs/compta/bank/budget.php3 | 125 +++++++ htdocs/compta/bank/categ.php3 | 69 ++++ htdocs/compta/bank/index.php3 | 195 ++++++++++ htdocs/compta/bank/ligne.php3 | 128 +++++++ htdocs/compta/bank/pre.inc.php3 | 80 ++++ htdocs/compta/bank/rappro.php3 | 123 +++++++ htdocs/compta/bank/releve.php3 | 163 +++++++++ htdocs/compta/casoc.php3 | 112 ++++++ htdocs/compta/comp.php3 | 371 +++++++++++++++++++ htdocs/compta/fac.php3 | 135 +++++++ htdocs/compta/facture.php3 | 346 +++++++++++++++++ htdocs/compta/genfac.php3 | 221 +++++++++++ htdocs/compta/index.php3 | 156 ++++++++ htdocs/compta/pmt.php3 | 147 ++++++++ htdocs/compta/pointmort.php3 | 190 ++++++++++ htdocs/compta/pre.inc.php3 | 110 ++++++ htdocs/compta/prev.php3 | 119 ++++++ htdocs/compta/tva.php3 | 104 ++++++ htdocs/conf/.cvsignore | 1 + htdocs/conf/conf.class.php3.sample | 49 +++ htdocs/index.php3 | 28 +- htdocs/lib/CMailFile.class.php3 | 121 ++++++ htdocs/lib/functions.inc.php3 | 245 +++++++++++++ htdocs/lib/mysql.lib.php3 | 129 +++++++ httpd.conf | 2 +- mysql/Makefile | 7 + mysql/data/data.sql | 4 - mysql/tables/Makefile | 4 +- mysql/tables/c_actioncomm.sql | 20 +- mysql/tables/c_effectif.sql | 22 +- mysql/tables/c_paiement.sql | 24 +- mysql/tables/c_pays.sql | 26 +- mysql/tables/c_stcomm.sql | 22 +- mysql/tables/c_typent.sql | 20 +- mysql/tables/drop.sql | 8 + mysql/tables/llx_user.sql | 22 +- mysql/tables/soc_events.sql | 30 +- mysql/tables/societe.sql | 112 +++--- mysql/tables/socstatutlog.sql | 26 +- 53 files changed, 5804 insertions(+), 508 deletions(-) create mode 100644 htdocs/comm/addpropal.php3 create mode 100644 htdocs/comm/analyse.php3 create mode 100644 htdocs/comm/bookmark.php3 create mode 100644 htdocs/comm/people.php3 create mode 100644 htdocs/comm/propal.class.php3 create mode 100644 htdocs/comm/propal.php3 create mode 100644 htdocs/comm/recontact.php3 create mode 100644 htdocs/comm/relance.php3 create mode 100644 htdocs/comm/socnote.php3 create mode 100644 htdocs/compta/bank/bilan.php3 create mode 100644 htdocs/compta/bank/budget.php3 create mode 100644 htdocs/compta/bank/categ.php3 create mode 100644 htdocs/compta/bank/index.php3 create mode 100644 htdocs/compta/bank/ligne.php3 create mode 100644 htdocs/compta/bank/pre.inc.php3 create mode 100644 htdocs/compta/bank/rappro.php3 create mode 100644 htdocs/compta/bank/releve.php3 create mode 100644 htdocs/compta/casoc.php3 create mode 100644 htdocs/compta/comp.php3 create mode 100644 htdocs/compta/fac.php3 create mode 100644 htdocs/compta/facture.php3 create mode 100644 htdocs/compta/genfac.php3 create mode 100644 htdocs/compta/index.php3 create mode 100644 htdocs/compta/pmt.php3 create mode 100644 htdocs/compta/pointmort.php3 create mode 100644 htdocs/compta/pre.inc.php3 create mode 100644 htdocs/compta/prev.php3 create mode 100644 htdocs/compta/tva.php3 create mode 100644 htdocs/conf/.cvsignore create mode 100644 htdocs/conf/conf.class.php3.sample create mode 100644 htdocs/lib/CMailFile.class.php3 create mode 100644 htdocs/lib/functions.inc.php3 create mode 100644 htdocs/lib/mysql.lib.php3 diff --git a/htdocs/comm/actioncomm.php3 b/htdocs/comm/actioncomm.php3 index 8303e7091e0..3ec46d0ecf7 100644 --- a/htdocs/comm/actioncomm.php3 +++ b/htdocs/comm/actioncomm.php3 @@ -20,7 +20,7 @@ * */ require("./pre.inc.php3"); -require("../lib/functions.inc.php3"); + require("../societe.class.php3"); require("../contact.class.php3"); require("cactioncomm.class.php3"); diff --git a/htdocs/comm/addpropal.php3 b/htdocs/comm/addpropal.php3 new file mode 100644 index 00000000000..b9f9f2a34a4 --- /dev/null +++ b/htdocs/comm/addpropal.php3 @@ -0,0 +1,325 @@ + + * + * $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 ""; +print ""; +print ""; +print "
Propositions commerciales pour $objsoc->nom
"; + +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 "
Génération du PDF

"; + + $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 "

command : $command
"; + + } 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 "

"; + print '
'; + + $strmonth[1] = "Janvier"; + $strmonth[2] = "Février"; + $strmonth[3] = "Mars"; + $strmonth[4] = "Avril"; + $strmonth[5] = "Mai"; + $strmonth[6] = "Juin"; + $strmonth[7] = "Juillet"; + $strmonth[8] = "Août"; + $strmonth[9] = "Septembre"; + $strmonth[10] = "Octobre"; + $strmonth[11] = "Novembre"; + $strmonth[12] = "Décembre"; + + $smonth = 1; + $syear = date("Y", time()); + print ''; + print ""; + + print ""; + $author = $GLOBALS["REMOTE_USER"]; + print ""; + print "\n"; + /* + * + * Destinataire de la propale + * + */ + print "'; + /* + * + * Projet associé + * + */ + print ''; + + print "
Date"; + $cday = date("d", time()); + print ""; + $cmonth = date("n", time()); + print ""; + + print "
Auteur$author
Num
Contact'; + if ($numdest==0) { + print '
Cette societe n\'a pas de contact, veuillez en creer un avant de faire de propale
'; + print 'Ajouter un contact'; + } + print '
Projet'; + if ($numprojet==0) { + print '
Cette societe n\'a pas de projet.
'; + print 'Créer un projet'; + } + print '
"; + /* + * + * 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 = ""; + if ($result) { + $num = $db->num_rows(); $i = 0; + while ($i < $num) { + $objp = $db->fetch_object( $i); + $opt .= "\n"; + $i++; + } + } + $db->free(); + } else { + print $db->error(); + } + + print ""; + + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "
Service/Produits
Remise :
"; + /* + * Si il n'y a pas de contact pour la societe on ne permet pas la creation de propale + */ + if ($numdest > 0) { + print ""; + } + print "
"; + print "Commentaires :
"; + print ""; + + print "
"; + + print "
"; + + print "
"; + } 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 "

"; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print "\n"; + $var=True; + while ($i < $num) { + $objp = $db->fetch_object( $i); + $var=!$var; + print ""; + print "\n"; + print "\n"; + print "\n"; + + print "\n"; + print "\n"; + print "\n"; + + $total = $total + $objp->price; + + $i++; + } + print ""; + print "
SocieteNumStatutDatePrix 
idp\">$objp->nompropalid\">$objp->ref$objp->lst".strftime("%d %B %Y",$objp->dp)."".price($objp->price)." 
Total : ".francs($total)." FFTotal : ".price($total)."euros
"; + $db->free(); +} else { + print $db->error(); + print "

$sql"; +} +$db->close(); +llxFooter(); +?> diff --git a/htdocs/comm/analyse.php3 b/htdocs/comm/analyse.php3 new file mode 100644 index 00000000000..86978915111 --- /dev/null +++ b/htdocs/comm/analyse.php3 @@ -0,0 +1,122 @@ + + * + * $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 ""; +print ""; +print ""; +print ""; +print ""; +print "
Propositions commercialesListeCA PrévisionnelPropal Signées
"; + +$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 "

"; +echo ''; + +$po = calc(1); +$ps = calc(2); +$pns = calc(3); + +print ""; +print ""; +print ""; +print ""; +print ""; +print "
Propales
Propales ouvertes".price($po)."
Propales signées".price($ps)."
Total".price($ps + $po )."
Propales non signées".price($pns)."
Total".price($ps + $po + $pns)."
"; + + +print "

"; +echo ''; + +$fnp = calcf(0); +$fp = calcf(1); +print ""; +print ""; +print ""; + +print "
Factures
Factures non payées".price($fnp)."
Factures payées".price($fp)."
Total".price($fnp + $fp )."
"; + + +$db->close(); +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/comm/bookmark.php3 b/htdocs/comm/bookmark.php3 new file mode 100644 index 00000000000..015b8d7a09e --- /dev/null +++ b/htdocs/comm/bookmark.php3 @@ -0,0 +1,128 @@ + + * + * $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

"; + +$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 "

"; + print ""; + print ""; + print ""; + print ""; + + print ""; + print ""; + print ""; + + print ""; + print "\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 ""; + print ""; + print ""; + print "\n"; + + print "\n"; + print "\n"; + print ""; + print "\n"; + print "\n"; + $i++; + } + print "
 IdSocieteStatutAuteurDate 
" . ($i + 1 + ($limit * $page)) . "$obj->idpidp\">$obj->nom$obj->stcomm$obj->author".strftime("%d %b %Y %H:%M", $obj->dateb) ."[bid\">Delete]
"; + $db->free(); +} else { + print $db->error(); +} + +$db->close(); + +?> +

+Seul l'auteur d'un bookmark peut le supprimer. + + diff --git a/htdocs/comm/index.php3 b/htdocs/comm/index.php3 index 752decd7070..2ee0ecbf65e 100644 --- a/htdocs/comm/index.php3 +++ b/htdocs/comm/index.php3 @@ -20,8 +20,8 @@ * */ require("./pre.inc.php3"); -require("../lib/functions.inc.php3"); -require("../lib/company.lib.php3"); +require("../contact.class.php3"); + llxHeader(); $db = new Db(); if ($sortorder == "") { @@ -34,17 +34,7 @@ $bc[0]="bgcolor=\"#c0f0c0\""; $bc[1]="bgcolor=\"#b0e0b0\""; $bc2[0]="bgcolor=\"#c9f000\""; $bc2[1]="bgcolor=\"#b9e000\""; -$active["1"] = "Offres en ligne"; -$active["-1"] = "Moderation"; -$active["-2"] = "Refusées"; -$active["0"] = "Rédaction"; -$active["-3"] = "Désactivées"; -$active["-4"] = "Supprimées"; -$cr["t"] = "Cab. Recrut."; -$cr["f"] = "-"; -$cr[""] = "????"; -$cr["1"] = "Cab. Recrut."; -$cr["0"] = "-"; + $yn["t"] = "oui"; $yn["f"] = "non"; @@ -58,12 +48,6 @@ if ($action == 'attribute_prefix') { $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') { $dr = mktime(0, 0, 0, $remonth, $reday, $reyear); $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) { - $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); if (!$result) { @@ -167,7 +151,7 @@ if ($mode == 'search') */ 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"; if ($to == 'next') { @@ -231,9 +215,7 @@ if ($socid > 0) { * */ print "\n"; - /* - * - */ + print ""; print ""; print ""; @@ -243,9 +225,11 @@ if ($socid > 0) { print ""; print ""; print "
N° $objsoc->idp - $objsoc->nom - [$objsoc->stcomm]idp&action=add\">[Bookmark]idp&action=create\">[Projet]idp\">Fiche Technique[idp&action=edit\">Editer]
"; - if ($objsoc->parent > 0) { - print "


Société rattaché au cabinet parent\">$objsoc->parent"; - } + /* + * + * + */ + print "
"; print "\n"; print ""; - print ""; - print ""; print "
"; @@ -267,118 +251,58 @@ if ($socid > 0) { print "
Siteurl\">$objsoc->url 
Contact $objsoc->c_nom $objsoc->c_prenom 
tel$objsoc->c_tel email : $objsoc->c_mail 
"; /* * */ print "\n"; - print ""; - if ($objsoc->dl > 0) { - $datel = strftime("%d %b %Y %H:%M", $objsoc->dl); - } else { - $datel = "Pas d'infos"; - } - print ""; + print ''; + /* + * + */ + print '
Dernière connexion$datel
'; + print ''; print ""; - //print ""; - print "" ; - print "" ; - print "" ; - if ($objsoc->cabrecrut == 1) { - print ""; - } elseif ($objsoc->cabrecrut == 0) { - print ""; - } else { - print ""; - } - print ""; - - print ""; - //print "" ; - //print ""; - - print "\n"; + print "
Créée le" . strftime("%d %b %Y %H:%M", $objsoc->dc) . "
Dernière modif le" . strftime("%d %b %Y %H:%M", $objsoc->dm) . "
Fiche Entreprise".$yn[$objsoc->fplus]."
Coordonnees CV".$yn["$objsoc->view_res_coord"]." 
Contacts CV".$yn["$objsoc->services"]." 
Cab. Recrut. : Oui
Cab. Recrut. : Non
Cab. Recrut. : ???idp&action=changevalue&type=cabrecrut\">changer
"; - //print "
Cojonet".$yn["$objsoc->cjn"]."
Consult Fiche$objsoc->viewed
"; - print "
"; - - print ""; - print ""; - print ""; - print ""; - - $sql = "SELECT count(idp) as cc, active FROM offre WHERE fk_soc = $objsoc->idp GROUP by active ORDER BY active DESC"; + print ''; + print '"; - - print ""; - - print "
Karma:$objsoc->karma
Nb d'acceptation:$objsoc->off_acc
Nb de refus:$objsoc->off_ref

Statut commercial
'; + /* + * + * Liste des statuts commerciaux + * + */ + $limliste = 5 ; + print "\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(); - while ($i < $num) { + $i = 0 ; $num = $db->num_rows(); $tag = True; + while ($i < $num && $i < $limliste) { $obj = $db->fetch_object( $i); - print ""; + if ($tag) { + print ""; + } else { + print ""; + } + print ""; + print ""; + print ""; + print "\n"; $i++; + $tag = !$tag; } $db->free(); + if ($num > $limliste) { + print ""; + } } else { print $db->error(); } - print "
".$active["$obj->active"] . ":$obj->cc
". strftime("%d %b %Y %H:%M", $obj->da) ."$obj->libelle$obj->author
suite ...

"; - print ""; - print ""; - $sql = "SELECT week1 + week2 + week3 + week4 as t, week1, week2, week3, week4 FROM soc_resviewed_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 ""; - $i++; - } - $db->free(); - } else { - print $db->error(); - } - print ""; - print ""; - $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 ""; - $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 ""; - $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 ""; - $i++; - } - $db->free(); - } else { - print $db->error(); - } - print "
CV consultés: $obj->t ( $obj->week1 - $obj->week2 - $obj->week3 - $obj->week4 )
Contacts: $obj->t ( $obj->week1 - $obj->week2 - $obj->week3 - $obj->week4 )
Abonnements: $obj->cc
Cand. suivis: $obj->cc
\n"; - print "
"; + print '
'; + print ''; /* * */ @@ -575,55 +499,25 @@ if ($socid > 0) { } print ""; - print "\n
\n"; /* * */ - print "\n"; print ""; @@ -80,30 +66,29 @@ function llxHeader($head = "", $urlp = "") { * */ print ""; /* * */ - print ""; + /* + * + */ + print ""; - + /* + * + */ print ""; - - - print ""; - + /* + * + */ print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print "
\n"; - /* - * - * Liste des statuts commerciaux - * - */ - $limliste = 5 ; - print "\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 ""; - } else { - print ""; - } - print ""; - print ""; - print ""; - print "\n"; - $i++; - $tag = !$tag; - } - $db->free(); - if ($num > $limliste) { - print ""; - } - } else { - print $db->error(); - } - print "
". strftime("%d %b %Y %H:%M", $obj->da) ."$obj->libelle$obj->author
suite ...
"; - - print "
"; + print ''; + print ''; + print '"; print ""; print ""; - print ""; + print ""; print "\n"; $var=True; while ($i < $num) { @@ -892,12 +683,11 @@ if ($socid > 0) { print ""; print ""; print "\n"; - print "\n"; - print "\n"; + print "\n"; + print "\n"; print "\n"; print "\n"; print "\n"; - print "\n"; print "\n"; $i++; } @@ -909,5 +699,5 @@ if ($socid > 0) { } $db->close(); -llxFooter(); +llxFooter("Dernière modification $Date$ révision $Revision$"); ?> diff --git a/htdocs/comm/people.php3 b/htdocs/comm/people.php3 new file mode 100644 index 00000000000..8dab13dc0fd --- /dev/null +++ b/htdocs/comm/people.php3 @@ -0,0 +1,249 @@ + + * + * $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ées"; +$active["0"] = "Rédaction"; +$active["-3"] = "Désactivées"; +$active["-4"] = "Supprimé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 "
"; + print "<-Prev\n| "; + for ($i = 65 ; $i < 91; $i++) { + print "" . chr($i) . " | "; + } + print " idp&to=next\">Next->\n"; + print "
"; + + $dac = strftime("%Y-%m-%d %H:%M", time()); + if ($errmesg) { + print "$errmesg
"; + } + /* + * + * + */ + print "
'; /* * * Listes des actions * */ - $sql = "SELECT a.id, ".$db->pdate("a.datea")." as da, c.libelle, a.author, a.propalrowid "; - $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 = "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, 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) ) { print "\n"; print ''; @@ -643,7 +537,20 @@ if ($socid > 0) { } else { print ""; } - print ""; + /* + * Contact pour cette action + * + */ + if ($obj->fk_contact) { + $contact = new Contact($db); + $contact->fetch($obj->fk_contact); + print ''; + } else { + print ''; + } + /* + */ + print ''; print "\n"; $i++; $tag = !$tag; @@ -656,89 +563,13 @@ if ($socid > 0) { } print "
Actions
$obj->libelle$obj->author'.$contact->fullname.' '.$obj->code.'
"; /* - * Note sur la societe + * + * Notes sur la societe + * */ - print ''; print ""; print "
".nl2br($objsoc->note)."
"; - - /* - * - * 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 "

"; - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - print "\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 ""; - print ""; - print ""; - print ""; - if ($objo->active == 1) { - print ""; - } else { - print ""; - } - print "\n"; - print ""; - print ""; - if ($objo->active <> -2) { - print ""; - } else { - print ""; - } - if ($objo->active == -3) { - print ""; - } else { - print ""; - } - - print "\n"; - $i++; - } - print "
$numIDPSiteStatutTitreCrééeActivéeDatedMeth
" . ($i + 1 + ($limit * $page)) . "$objo->idp$objo->site" . $active["$objo->active"] ."" . $active["$objo->active"] ."idp\">$objo->titre" . strftime("%d %b %Y", $objo->dc) . "" . strftime("%d %b %Y", $objo->da) . "" . strftime("%d %b %Y", $objo->dd) . " ".$deacmeth[$objo->deacmeth]." 
"; - } /* * * @@ -790,43 +621,11 @@ if ($socid > 0) { print "\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 "
"; - print "Contacts
"; - print ""; - - while ($i < $num) { - $obj = $db->fetch_object( $i); - if ($tag) { - print ""; - } else { - print ""; - } - print ""; - print ""; - print "\n"; - $i++; - $tag = !$tag; - } - print "
dateCandidat
". strftime("%d %b %Y %H:%M", $obj->da) ."$obj->fk_cand
"; - print "
"; - print "Description de la société
$objsoc->description"; - print "
"; - - } } + } else { + print $db->error() . "
" . $sql; } } else { /* @@ -839,7 +638,7 @@ if ($socid > 0) { $bc[1]="bgcolor=\"#90c090\""; $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)) { $sql .= " AND s.fk_stcomm=$stcomm"; @@ -849,14 +648,6 @@ if ($socid > 0) { $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) { $sql .= " AND lower(s.nom) like '%".strtolower($socname)."%'"; $sortfield = "lower(s.nom)"; @@ -881,7 +672,7 @@ if ($socid > 0) { print "

SocieteContactemailStatut   Statut  
$obj->idpidp\">$obj->nom$obj->c_nom $obj->c_prenom$obj->c_mail  $obj->stcomm$obj->prefix_comm idp&action=create\">[Propal]idp&action=add\">[Ventes]
\n"; + print ""; + print ""; + + print ""; + print '
N° $objsoc->idp - idp\">$objsoc->nom - [$objsoc->stcomm] Notes[Ajouter un contact]
'; + + print "
"; + print "\n"; + print "\n"; + print "\n"; + print "
"; + print "tel : $objsoc->tel
"; + print "fax : $objsoc->fax
"; + print "$objsoc->cp $objsoc->ville
"; + if ($objsoc->url) { + print "url\">$objsoc->url
"; + } + print "
Contact :
$objsoc->c_nom $objsoc->c_prenom"; + print "
tel : $objsoc->c_tel"; + print "
email : $objsoc->c_mail"; + + + print "
"; + print ""; + print ""; + print "" ; + print ""; + + print "\n"; + print ""; + + print "
Créée le" . strftime("%d %b %Y %H:%M", $objsoc->dc) . "
Dernière modif le" . strftime("%d %b %Y %H:%M", $objsoc->dm) . "
Fiche société".$yn[$objsoc->fplus]."
"; + + print "
"; + print ""; + + print "

"; + print ""; + + print "
"; + + print "
"; + /* + * + */ + + + print ""; + print ""; + print "
".nl2br($objsoc->note)."
"; + + $bc1="bgcolor=\"#c0f0c0\""; + $bc3="bgcolor=\"#90c090\""; + $bc2="bgcolor=\"#b0e0b0\""; + } else { + print $db->error(); + } + + print "

"; + + print ""; + print ""; + print ""; + + $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 ""; + } else { + print ""; + } + print ""; + print ""; + print ""; + print ""; + print ""; + print "\n"; + $i++; + $tag = !$tag; + } + print "
Prénom NomPosteTelFaxEmail
$obj->firstname $obj->name$obj->poste $obj->phone $obj->fax email\">$obj->email 
"; + + + if ($action == 'addcontact') { + print "

"; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print "
NomPrenom
Poste
TelFax
Email
"; + print ""; + print "
"; + } + /* + * + * 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 "
"; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ''; + print "
Numéro$obj->idp
Nomname\">Prenomfirstname\">
Posteposte\">
Telphone\">Faxfax\">
Emailemail\">
Note
"; + print ""; + print "
"; + } + + +} else { + print "Error"; +} +$db->free(); +$db->close(); + +llxFooter(); +?> diff --git a/htdocs/comm/pre.inc.php3 b/htdocs/comm/pre.inc.php3 index cb245ef8835..2db8c8c7d4e 100644 --- a/htdocs/comm/pre.inc.php3 +++ b/htdocs/comm/pre.inc.php3 @@ -19,11 +19,6 @@ * 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"); function llxHeader($head = "", $urlp = "") { @@ -55,18 +50,9 @@ function llxHeader($head = "", $urlp = "") { print "
"; - print "
Societe
\n"; - print "A contacter
\n"; - print "Jamais contactée
\n"; - print "Ne pas contacter
\n"; - print "Contact en cours
\n"; - print "Contactée

\n"; - print "A relancer
\n"; - print "A recontacter
\n"; - print "A classer

\n"; - - print "Gourmands
\n"; - print "Contact
\n"; + print "

Sociétés
\n"; + print "Nouvelle société
\n"; + print "Contacts
\n"; print "
"; - print "\n"; - print "Recap
\n"; + print ''; print "
"; - - print "Factures
\n"; - print "
Ventes
\n"; - print "Par sociétés
\n"; - print "Produits
\n"; - + print "
"; + print ''; + print "
"; + print ''; print "
"; print "Projets
\n"; print "
"; - print "Stats
\n"; - print "
"; print "
Societes
\n"; print "
"; diff --git a/htdocs/comm/projet/index.php3 b/htdocs/comm/projet/index.php3 index b635dd6c444..ad16942bb25 100644 --- a/htdocs/comm/projet/index.php3 +++ b/htdocs/comm/projet/index.php3 @@ -5,7 +5,6 @@ * $Source$ */ require("./pre.inc.php3"); -require("../../lib/functions.inc.php3"); require("./project.class.php3"); diff --git a/htdocs/comm/propal.class.php3 b/htdocs/comm/propal.class.php3 new file mode 100644 index 00000000000..1dc0f0e4cee --- /dev/null +++ b/htdocs/comm/propal.class.php3 @@ -0,0 +1,145 @@ + + * + * $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 . '
' . $db->error() .'
'; + } + } + /* + * 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() . '
'.$sql; + } + } else { + print $db->error() . '
'.$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(); + } + } +} +?> + diff --git a/htdocs/comm/propal.php3 b/htdocs/comm/propal.php3 new file mode 100644 index 00000000000..21d89836ca6 --- /dev/null +++ b/htdocs/comm/propal.php3 @@ -0,0 +1,570 @@ + + * + * $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 ""; +print ""; +if ($socidp) { +print ""; +} +print ""; +print ""; +print ""; +print "
Propositions commercialesNouvelle PropalListeCA PrévisionnelPropal Signées
"; + +$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 "Propal supprimée"; + } else { + print $db->error(); + print "

$sql"; + } + } else { + print $db->error(); + print "

$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 ""; + + print ""; + print ""; + // + if ($obj->fk_projet) { + $projet = new Project(); + $projet->fetch($db,$obj->fk_projet); + print ''; + } + print ""; + /* + * + */ + print ""; + print ""; + print ""; + /* + * + */ + print "\n"; + print ""; + print ""; + + /* + * + */ + print ""; + + $totalht = $obj->price - $obj->remise ; + + print ""; + /* + * + */ + print ""; + + print ""; + print ""; + + print ""; + print ""; + print ""; + print ""; + /* + * + */ + print ""; + if ($obj->statut == 0) { + print ""; + } elseif ($obj->statut == 1) { + print ""; + } else { + print ""; + } + + print "
Sociétéidp\">$obj->nomidp\">Autres propalesNote :
". nl2br($obj->note)."
Projet'; + print ''; + print $projet->title.'
Destinataire$obj->firstname $obj->name <$obj->email>
Numéro$obj->refMontant HT".price($obj->price)."euros
date".strftime("%A %d %B %Y",$obj->dp)."Remise".price($obj->remise)."euros
Auteur$obj->authorTotal HT".price($totalht)."euros "; + print "soit ".francs($totalht)." francs
 TVA".price($obj->tva)."euros
 Total TTC".price($obj->total)."euros "; + print "soit ".francs($obj->total)." francs
Statut :$obj->lst[Valider][Changer] 
"; + + if ($action == 'statut') { + print ""; + print ""; + print "'; + print '

'; + print "

"; + } + + + print "
"; + /* + * 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 "

Produits"; + print ""; + print ""; + print ""; + print "\n"; + + $var=True; + while ($i < $num) { + $objp = $db->fetch_object( $i); + $var=!$var; + print ""; + print "\n"; + print "\n"; + print "\n"; + print ""; + $total = $total + $objp->price; + $i++; + } + //print "\n"; + print "
RéfProduitPrix 
[$objp->ref]$objp->product".price($objp->price)."euros
Total : ".price($total)."Euros HT
"; + } + /* + * + */ + print "

"; + /* + * 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 "

Facture(s) associée(s)"; + print ""; + print ""; + print ""; + print ""; + print ""; + print "\n"; + + $var=True; + while ($i < $num) { + $objp = $db->fetch_object( $i); + $var=!$var; + print ""; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print ""; + $total = $total + $objp->amount; + $i++; + } + print "\n"; + print "
NumDateAuteurPrix
facid\">$objp->facnumber"; + if ($objp->paye) { print " (payée)"; } + print "".strftime("%d %B %Y",$objp->df)."$objp->author$objp->amount
Total : $total Euros HT
"; + $db->free(); + } + print "

"; + /* + * Actions + */ + print "

"; + + if ($obj->statut == 0) { + print ""; + } else { + print ""; + } + if ($obj->statut == 2) { + print ""; + } else { + print ""; + } + if ($obj->statut == 1) { + $file = $GLOBALS["GLJ_ROOT"] . "/www-sys/doc/propal/$obj->ref/$obj->ref.pdf"; + if (file_exists($file)) { + print ""; + } else { + print ""; + } + } else { + print ""; + } + if ($obj->statut == 0) { + print ""; + } else { + print ""; + } + print "
[Supprimer]-Emettre une facture-"; + print "[Envoyer la propale par mail]! Propale non generee !-[Valider]-
"; + /* + * + */ + if ($action == 'fax') { + print "


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

Resultat :

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

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

envoyé à $sendto"; + print "

envoyé par ".htmlentities($replyto); + } else { + print "!! erreur d'envoi"; + } + } + + if ( $db->query($sql) ) { + $sql = "INSERT INTO actioncomm (datea,fk_action,fk_soc,author,propalrowid,note) VALUES (now(), 3, $obj->idp,'$author', $propalid, 'Envoyée à $sendto');"; + if (! $db->query($sql) ) { + print $db->error(); + print "

$sql

"; + } + } else { + print $db->error(); + } + } + /* + * + */ + print "
"; + print "
"; + print "Documents générés
"; + print ""; + + $file = $GLOBALS["GLJ_ROOT"] . "/www-sys/doc/propal/$obj->ref/$obj->ref.pdf"; + if (file_exists($file)) { + print ""; + } + $file = $GLOBALS["GLJ_ROOT"] . "/www-sys/doc/propal/$obj->ref/$obj->ref.ps"; + if (file_exists($file)) { + print ""; + print ""; + } + print ""; + + $file = $GLOBALS["GLJ_ROOT"] . "/www-sys/doc/propale/$obj->ref/FAX-$obj->ref.ps"; + if (file_exists($file)) { + print ""; + } + print "
Propale PDFref/$obj->ref.pdf\">$obj->ref.pdf
Propale Postscriptref/$obj->ref.ps\">$obj->ref.ps
(ref/\">liste...)
FAX d'entete
\n"; + /* + * + */ + print "
"; + print "Propale envoyée
"; + /* + * + */ + $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 ""; + print "\n"; + + while ($i < $num) { + $objp = $db->fetch_object( $i); + print "\n"; + print "\n"; + print ""; + $i++; + } + print "
DateAuteur
".strftime("%d %B %Y %H:%M:%S",$objp->da)."$objp->author
$objp->note
"; + $db->free(); + } else { + print $db->error(); + } + /* + * + */ + print "
"; + /* + * + * + */ + if ($action == 'presend') { + $sendto = "rq@lolix.org"; + $replytoname = "Service commercial Lolix"; $ from_name = $replytoname; + $replytomail = "commercial@lolix.org"; $from_mail = $replytomail; + + print "
\n"; + print "\n"; + print "\n"; + print "\n"; + + print "

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

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

$sql"; + } + + } else { + print $db->error(); + print "

$sql"; + } + + + /* + * + * + * + */ +} else { + /* + * + * + * Liste des propals + * + * + */ + + print "

"; + $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 "

"; + + $oldstatut = -1; + $subtotal = 0; + while ($i < $num) { + $objp = $db->fetch_object( $i); + + if ($objp->statut <> $oldstatut ) { + $oldstatut = $objp->statut; + + if ($i > 0) { + print "\n"; + print "\n"; + } + $subtotal = 0; + + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print "\n"; + $var=True; + } + + $var=!$var; + print ""; + print "\n"; + print "\n"; + print "\n"; + + $now = time(); + $lim = 3600 * 24 * 15 ; + + if ( ($now - $objp->dp) > $lim && $objp->statutid == 1 ) { + print ""; + } else { + print ""; + } + + print "\n"; + + //print "\n"; + + print "\n"; + print "\n"; + print "\n"; + + $total = $total + $objp->price; + $subtotal = $subtotal + $objp->price; + + $i++; + } + print "\n"; + print "\n"; + + + print ""; + print ""; + print ""; + print "
Total : ".price($subtotal)."Euros HT
[Tous]RéfSocieteDatePrixStatut [statutid\">Filtre]
[idp\">Filtre]propalid\">$objp->refidp\">$objp->nom > 15 jours "; + $y = strftime("%Y",$objp->dp); + $m = strftime("%m",$objp->dp); + + print strftime("%d",$objp->dp)."\n"; + print " "; + print strftime("%B",$objp->dp)."\n"; + print " "; + print strftime("%Y",$objp->dp)."".strftime("%d %B %Y",$objp->dp)."".price($objp->price)."$objp->statut
Total : ".price($subtotal)."Euros HT
$i propalesSoit : ".francs($total)." FF HTTotal : ".price($total)."Euros HT
"; + $db->free(); + } else { + print $db->error(); + } +} +$db->close(); +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/comm/recontact.php3 b/htdocs/comm/recontact.php3 new file mode 100644 index 00000000000..1e091b43877 --- /dev/null +++ b/htdocs/comm/recontact.php3 @@ -0,0 +1,114 @@ + + * + * $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ées"; +$active["0"] = "Rédaction"; +$active["-3"] = "Désactivées"; +$active["-4"] = "Supprimé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 "

"; +print "< Prev\n| "; +for ($i = 65 ; $i < 91; $i++) { + print ""; + print chr($i) ; + print " | "; +} +print " Next >\n"; +print "

"; + +$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 "

"; + print ""; + print ""; + print ""; + print ""; + print "\n"; + $var=True; + while ($i < $num) { + $obj = $db->fetch_object( $i); + + $var=!$var; + print ""; + print ""; + print "\n"; + + print "\n"; + print "\n"; + print "\n"; + + print "\n"; + print "\n"; + print "\n"; + $j++; + + $objold = $obj; + + $i++; + } + print "
 SocieteA recontacter leAuteur
" . ($j + 1 + ($limit * $page)) . "socidp\">$obj->societe" .strftime("%d",$obj->datere)."" .strftime("%B",$obj->datere)."" .strftime("%Y",$obj->datere)."$obj->authorrowid\">Supprimer ce rappel
"; +} + + +$db->free(); +$db->close(); + +llxFooter(); +?> diff --git a/htdocs/comm/relance.php3 b/htdocs/comm/relance.php3 new file mode 100644 index 00000000000..2b8889c7407 --- /dev/null +++ b/htdocs/comm/relance.php3 @@ -0,0 +1,130 @@ + + * + * $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ées"; +$active["0"] = "Rédaction"; +$active["-3"] = "Désactivées"; +$active["-4"] = "Supprimé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 "

"; +print "< Prev\n| "; +for ($i = 65 ; $i < 91; $i++) { + print ""; + + if ($begin == chr($i) ) { + print "->" . chr($i) . "<-" ; + } else { + print chr($i) ; + } + print " | "; +} +print " Next >\n"; +print "

"; + +$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 "

"; +print ""; +print ""; +print ""; +print ""; +print ""; +print "\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 ""; + print ""; + print "\n"; + + print "\n"; + + print "\n"; + print "\n"; + print "\n"; + print "\n"; + $j++; + } + $objold = $obj; + + $i++; +} +if ( $objold->fk_action <> 11) { + $var=!$var; + + print ""; + print ""; + print "\n"; + + print "\n"; + + print "\n"; + print "\n"; + print "\n"; + print "\n"; +} +print "
 SocieteDateDernière actionAuteur
" . ($j + 1 + ($limit * $page)) . "socidp\">$objold->societe" .gljftime("%d %b %Y %H:%M",$objold->datea)."$objold->libelle$objold->author$objold->stcomm
" . ($j + 1 + ($limit * $page)) . "socidp\">$objold->societe" .gljftime("%d %b %Y %H:%M",$objold->datea)."$objold->libelle$objold->author$objold->stcomm
"; + +$db->free(); +$db->close(); + +llxFooter(); +?> diff --git a/htdocs/comm/socnote.php3 b/htdocs/comm/socnote.php3 new file mode 100644 index 00000000000..8df43c9a6e4 --- /dev/null +++ b/htdocs/comm/socnote.php3 @@ -0,0 +1,228 @@ + + * + * $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ées"; +$active["0"] = "Rédaction"; +$active["-3"] = "Désactivées"; +$active["-4"] = "Supprimé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 "\n"; + + print "" ; + + print ""; + + print "\n"; + print "\n"; + print "
N° $objsoc->idp - $soc->nom - [$soc->stcomm]
"; + print "tel : $soc->tel
"; + print "fax : $soc->fax
"; + print "$soc->cp $soc->ville
"; + if ($objsoc->url) { + print "url\">$soc->url
"; + } + print "
Contact :
$soc->c_nom $soc->c_prenom"; + print "
tel : $soc->c_tel"; + print "
email : $soc->c_mail"; + + + print "
"; + print ""; + print ""; + print "" ; + print "" ; + print ""; + print ""; + + print "\n"; + print ""; + + print "
Créée le" . strftime("%d %b %Y %H:%M", $objsoc->dc) . "
Dernière modif le" . strftime("%d %b %Y %H:%M", $objsoc->dm) . "
Fiche société".$yn[$objsoc->fplus]."
Cojonet".$yn["$objsoc->cjn"]."
Consult Fiche$objsoc->viewed
Offres"; + + print "
"; + $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 ""; + $i++; + } + print "
".$active["$obj->active"] . ":$obj->cc
Divers
"; + print ""; + $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 ""; + $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 ""; + $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 ""; + $i++; + } + + print "
Abonnements :$obj->cc
Cand. suivis :$obj->cc
Contacts :$obj->cc
"; + + print "


"; + /* + * + * + */ + print ""; + /* + * + * + */ + print "
"; + print ""; + + $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 ""; + } else { + print ""; + } + print ""; + print ""; + print ""; + print "\n"; + $i++; + $tag = !$tag; + } + print "
". strftime("%d %b %Y %H:%M", $obj->da) ."$obj->libelle$obj->author
"; + + print "
"; + + print ""; + + $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 ""; + } else { + print ""; + } + print ""; + print ""; + print ""; + print "\n"; + $i++; + $tag = !$tag; + } + print "
". strftime("%d %b %Y %H:%M", $obj->da) ."$obj->libelle$obj->author
"; + + + print "
"; + + + print ""; + print ""; + print ""; + print "
"; + print "
"; + print ""; + print "
"; + print ""; + print "
".nl2br($objsoc->note)."
"; + + } else { + print $db->error(); + } +} +$db->free(); +$db->close(); + +llxFooter(); +?> diff --git a/htdocs/compta/bank/bilan.php3 b/htdocs/compta/bank/bilan.php3 new file mode 100644 index 00000000000..ccaec46f51f --- /dev/null +++ b/htdocs/compta/bank/bilan.php3 @@ -0,0 +1,59 @@ +query($sql) ) { + if ( $db->num_rows() ) { + $valeur = $db->result(0,0); + } + $db->free(); + } + return $valeur; +} + + +print "Bilan"; + +print ""; +print ""; +print ""; +print "\n"; + +$var=!$var; +$sql = "SELECT sum(amount) FROM llx_paiement"; +$paiem = valeur($sql); +print ""; + +$var=!$var; +$sql = "SELECT sum(amount) FROM llx_bank WHERE amount > 0"; +$credits = valeur($sql); +print ""; + +$var=!$var; +$sql = "SELECT sum(amount) FROM llx_bank WHERE amount < 0"; +$debits = valeur($sql); +print ""; + +$var=!$var; +$sql = "SELECT sum(amount) FROM llx_bank "; +$solde = valeur($sql); +print ""; + + +print "
DescriptionMontantfrancs
Somme des paiements".price($paiem)."".francs($paiem)."
Somme des credits".price($credits)."".francs($credits)."
Somme des debits".price($debits)."".francs($debits)."
Solde compte".price($solde)."".francs($solde)."
"; + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/compta/bank/budget.php3 b/htdocs/compta/bank/budget.php3 new file mode 100644 index 00000000000..023cc54e2ad --- /dev/null +++ b/htdocs/compta/bank/budget.php3 @@ -0,0 +1,125 @@ +Budgets
"; + + print ""; + print ""; + echo ''; + print "\n"; + + $sql = "SELECT sum(d.amount) as somme, count(*) as nombre, c.label, c.rowid "; + $sql .= " FROM llx_bank_categ as c, llx_bank_class as l, llx_bank as d"; + $sql .= " WHERE d.rowid=l.lineid AND c.rowid = l.fk_categ GROUP BY c.label, c.rowid ORDER BY c.label"; + + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows(); + $i = 0; $total = 0; + + $var=True; + while ($i < $num) { + $objp = $db->fetch_object( $i); + $var=!$var; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + $i++; + $total = $total + abs($objp->somme); + } + $db->free(); + print ""; + print "\n"; + } else { + print $db->error(); + } + print "
DescriptionNbTotal
rowid\">$objp->label$objp->nombre".price(abs($objp->somme))."".francs(abs($objp->somme))."
Total".price($total)."
soit en francs".francs($total)."
"; + +} else { + /* + * Vue + */ + $sql = "SELECT label FROM llx_bank_categ WHERE rowid=$bid"; + if ( $db->query($sql) ) { + if ( $db->num_rows() ) { + $budget_name = $db->result(0,0); + } + $db->free(); + } + + print "Budget : $budget_name"; + + print ""; + print ""; + echo ''; + print "\n"; + + $sql = "SELECT d.amount, d.label, ".$db->pdate("d.dateo")." as do, d.rowid"; + $sql .= " FROM llx_bank_class as l, llx_bank as d"; + $sql .= " WHERE d.rowid=l.lineid AND l.fk_categ=$bid ORDER by d.dateo DESC"; + + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows(); + $i = 0; $total = 0; + + $var=True; + while ($i < $num) { + $objp = $db->fetch_object( $i); + $var=!$var; + print ""; + print "\n"; + + print ""; + print ""; + print ""; + + print ""; + $i++; + $total = $total + $objp->amount; + } + $db->free(); + print ""; + print "\n"; + } else { + print $db->error(); + } + print "
DateDescriptionMontant 
".strftime("%d %B %Y",$objp->do)."rowid\">$objp->label".price(abs($objp->amount))."".francs(abs($objp->amount))."
Total".price(abs($total))."euros
soit".francs(abs($total))."francs
"; + +} + + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/compta/bank/categ.php3 b/htdocs/compta/bank/categ.php3 new file mode 100644 index 00000000000..8397225eace --- /dev/null +++ b/htdocs/compta/bank/categ.php3 @@ -0,0 +1,69 @@ + 0) { + $amount = $credit ; + } else { + $amount = - $debit ; + } + + $sql = "INSERT INTO llx_bank_categ (label) VALUES ('$label')"; + $result = $db->query($sql); + if (!$result) { + print $db->error(); + print "

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

"; +print ""; +print ""; +print ""; +print ""; +print "\n"; + + +$sql = "SELECT rowid, label FROM llx_bank_categ"; + +$result = $db->query($sql); +if ($result) { + $num = $db->num_rows(); + $i = 0; $total = 0; + + $var=True; + while ($i < $num) { + $objp = $db->fetch_object( $i); + $var=!$var; + print ""; + print ""; + print ""; + print ""; + $i++; + } + $db->free(); +} +print ""; +print ""; +print ""; +print "
NumDescription
$objp->rowid$objp->label
"; + + + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/compta/bank/index.php3 b/htdocs/compta/bank/index.php3 new file mode 100644 index 00000000000..fcb562046d0 --- /dev/null +++ b/htdocs/compta/bank/index.php3 @@ -0,0 +1,195 @@ + 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 "

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

"; +print ""; +print ""; +print ""; +print ""; +print ""; +print ""; +print ""; +print ""; +print "\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 "\n"; + $psol = 1; + + } else { + $var=!$var; + + if ($objp->do > $time && !$sep) { + $sep = 1 ; + print ""; + print "\n"; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + } + + print ""; + print "\n"; + + if ($objp->num_chq) { + print ""; + } else { + print ""; + } + + if ($objp->amount < 0) { + print "\n"; + } else { + print "\n"; + } + + if ($total > 0) { + print "\n"; + } else { + print "\n"; + } + + if ($objp->rappro) { + print ""; + } else { + print ""; + } + + print "\n"; + print ""; + + } + } + + + $i++; + } + $db->free(); +} + +if ($sep) { + print ""; + print "\n"; +} else { + + print ""; + print "\n"; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; +} + +print "
DateDescriptionDebitCreditSoldeFrancs
 ".price($total)."".francs($total)."
Total :".price($total - $objp->amount)."".francs($total - $objp->amount)."
CHQ -"; + print ""; + print "
Format : YYYYMMDD - 200108260000.00
".strftime("%d %b %y",$objp->do)."CHQ $objp->num_chq - $objp->label$objp->label".price($objp->amount * -1)."  ".price($objp->amount)."".price($total)."".price($total)."num_releve\">$objp->num_releverowid\">[Del]".francs($objp->amount)."
Total :".price($total)."".francs($total)."
Total :".price($total)."".francs($total)."
CHQ -"; + print ""; + print "
Format : YYYYMMDD - 200108260000.00
"; + +print "Edit Categories"; +print " Budgets"; + +$db->close(); + +llxFooter(strftime("%H:%M",time()). " - Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/compta/bank/ligne.php3 b/htdocs/compta/bank/ligne.php3 new file mode 100644 index 00000000000..2a4b9e4020e --- /dev/null +++ b/htdocs/compta/bank/ligne.php3 @@ -0,0 +1,128 @@ +query($sql); + +} + +$sql = "SELECT rowid, label FROM llx_bank_categ;"; +$result = $db->query($sql); +if ($result) { + $var=True; + $num = $db->num_rows(); + $i = 0; + $options = ""; + while ($i < $num) { + $obj = $db->fetch_object($i); + $options .= "\n"; $i++; + } + $db->free(); +} + +print "Edition de la ligne"; +print ""; +print ""; +print ""; +print ""; +print ""; +print ""; +print ""; + +print "\n"; + +$sql = "SELECT b.rowid,".$db->pdate("b.dateo")." as do, b.amount, b.label, b.rappro, b.num_releve, b.author"; +$sql .= " FROM llx_bank as b WHERE rowid=$rowid"; +$sql .= " ORDER BY dateo ASC"; +$result = $db->query($sql); +if ($result) { + $var=True; + $num = $db->num_rows(); + $i = 0; $total = 0; + while ($i < $num) { + $objp = $db->fetch_object( $i); + $total = $total + $objp->amount; + + $var=!$var; + print ""; + print ""; + print ""; + print "rowid\">"; + + print "\n"; + print ""; + if ($objp->amount < 0) { + print "\n"; + } else { + print "\n"; + } + + print ""; + print ""; + + print ""; + print ""; + print ""; + + print ""; + $i++; + } + $db->free(); +} +print "
DateDescriptionDebitCreditReleveAuteur
".strftime("%d %b %Y",$objp->do)."$objp->label".price($objp->amount * -1)."  ".price($objp->amount)."num_releve\">$objp->num_releve$objp->author
 "; + print " "; + print "
"; + +print "

Classé dans

"; + +print ""; +print ""; +print ""; +print "\n"; + +$sql = "SELECT c.label, c.rowid"; +$sql .= " FROM llx_bank_class as a, llx_bank_categ as c WHERE a.lineid=$rowid AND a.fk_categ = c.rowid "; +$sql .= " ORDER BY c.label"; +$result = $db->query($sql); +if ($result) { + $var=True; + $num = $db->num_rows(); + $i = 0; $total = 0; + while ($i < $num) { + $objp = $db->fetch_object( $i); + + $var=!$var; + print ""; + + print ""; + print ""; + print ""; + + $i++; + } + $db->free(); +} +print "
Description
$objp->labelrowid\">voir
"; + + + + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/compta/bank/pre.inc.php3 b/htdocs/compta/bank/pre.inc.php3 new file mode 100644 index 00000000000..a1651b97000 --- /dev/null +++ b/htdocs/compta/bank/pre.inc.php3 @@ -0,0 +1,80 @@ +\n$head\n\n"; + ?> + + \n"; + print "
" . $GLOBALS["MAIN_TITLE"] . "TechniqueCommercialComptaStats
\n"; + + print ""; + print "\n
"; + + print ""; + print ""; + + print ""; + + print ""; + print ""; + + print ""; + + + + + print "
"; + + print "
" . $GLOBALS["dbname"] . " - " . $GLOBALS["REMOTE_USER"] ."
"; + print "Accueil"; + + print "
"; + print "Bank
\n"; + print "Rappro

\n"; + print "Budgets
\n"; + print "Bilan

\n"; + print 'Relevés bancaires'; + print "

"; + print "
Factures

\n"; + print "Paiements
\n"; + + print "

"; + + print "
Chiffres d'affaires

\n"; + print "Réalisé
\n"; + print "Prévisionnel
\n"; + print "Comparatif\n"; + + print "
"; + print "Propal
\n"; + print "
"; + + + print "
\n"; +} +/* + * + */ +function llxFooter($foot='') { + print "
\n"; + print "$foot"; +} +// $Id$ +// $Source$ +?> diff --git a/htdocs/compta/bank/rappro.php3 b/htdocs/compta/bank/rappro.php3 new file mode 100644 index 00000000000..284a9ac5aa3 --- /dev/null +++ b/htdocs/compta/bank/rappro.php3 @@ -0,0 +1,123 @@ + 0) { + $sql = "UPDATE llx_bank set rappro=$rappro, num_releve=$num_releve WHERE rowid=$rowid"; + $result = $db->query($sql); + if ($result) { + if ($cat1 && $rappro) { + $sql = "INSERT INTO llx_bank_class (lineid, fk_categ) VALUES ($rowid, $cat1)"; + $result = $db->query($sql); + } + } else { + print $db->error(); + print "

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

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

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

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

"; + print ""; + print ""; + print ""; + print ""; + print ""; + print "\n"; + $var=True; + while ($i < $num) { + $objp = $db->fetch_object( $i); + $var=!$var; + print ""; + print "\n"; + print "\n"; + print "\n"; + + $total = $total + $objp->ca; + + print "\n"; + print "\n"; + $i++; + } + print ""; + print ""; + print ""; + print "
[Tous]SocieteMontant Moyenne
[idp\">Filtre]idp\">$objp->nom".price($objp->ca)." ".price($total / ($i + 1))."
Total : ".francs($total)." FFTotal : ".price($total)."euros HTMoyenne : ".price($total/ $i)."
"; + } + $db->free(); + } else { + print $db->error(); + } +} + +print "

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

"; +liste($db, 1); + + + +$db->close(); +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/compta/comp.php3 b/htdocs/compta/comp.php3 new file mode 100644 index 00000000000..56ba883fb82 --- /dev/null +++ b/htdocs/compta/comp.php3 @@ -0,0 +1,371 @@ + + * $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 "

"; + print ""; + + $oldstatut = -1; + $subtotal = 0; + while ($i < $num) { + $objp = $db->fetch_object( $i); + + if ($objp->statut <> $oldstatut ) { + $oldstatut = $objp->statut; + + if ($i > 0) { + print "\n"; + print "\n"; + } + $subtotal = 0; + + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print "\n"; + $var=True; + } + + $var=!$var; + print ""; + + print "\n"; + + print "\n"; + + print "\n"; + + print "\n"; + print "\n"; + print "\n"; + + $total = $total + $objp->price; + $subtotal = $subtotal + $objp->price; + + $i++; + } + print "\n"; + print "\n"; + print ""; + print ""; + print ""; + print "
Propal
Total : $subtotalEuros HT
SocieteRéfDatePrixStatut
idp\">$objp->nompropalid\">$objp->ref".strftime("%d %B %Y",$objp->dp)."$objp->price$objp->statut
Total : $subtotalEuros HT
Total ~ ".round($total * 6.55957)." FF HTTotal : $totalEuros HT
"; + $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 "

"; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print "\n"; + $var=True; + while ($i < $num) { + $objp = $db->fetch_object( $i); + $var=!$var; + print ""; + print "\n"; + print "\n"; + if ($objp->df > 0 ) { + print "\n"; + } else { + print "\n"; + } + + print "\n"; + + $payes[1] = "oui"; + $payes[0] = "non"; + + + print "\n"; + print "\n"; + + $total = $total + $objp->amount; + + $i++; + } + print ""; + print ""; + print "
Factures
SocieteNumDateMontantPayé
idp\">$objp->nomfacid\">$objp->facnumber".strftime("%d %B %Y",$objp->df)."!!!$objp->amount".$payes[$objp->paye]."
Total ~ ".round($total * 6.55957)." FF HTTotal : $total
"; + $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 "

"; + print ""; + print ""; + print "\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 ""; + print "\n"; + print "\n"; + print "\n"; + $var=!$var; + $ca[$b] = 0; + } + } + if ($obj->sum > 0) { + print ""; + print "\n"; + print "\n"; + + print "\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 ""; + print "\n"; + print "\n"; + print "\n"; + $ca[$b] = 0; + } + } + + print ""; + print "
MoisMontant
".strftime("%B",mktime(12,0,0,$b, 1, $year))."0
dm\">"; + print strftime("%B",mktime(12,0,0,$obj->dm, 1, $year))."$obj->sum
".strftime("%B",mktime(12,0,0,$b, 1, $year))."0
Total :$total
"; + + $db->free(); + return $ca; + } +} + +function ppt ($db, $year, $socidp) { + + print ""; + + print ""; + print ""; + + print "
"; + print "CA Prévisionnel basé sur les propal $year"; + + print "CA Réalisé $yearDelta $year
"; + + $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 ""; + + $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 ""; + + print "

"; + print ""; + print ""; + print ""; + print "\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 ""; + print "\n"; + print "\n"; + print "\n"; + } + + $ayear = $year - 1; + $acat = get_ca($db, $ayear, $socidp) - get_ca_propal($db, $ayear, $socidp); + + + print ""; + print ""; + print ""; + + print "
MoisMontant
".strftime("%B",mktime(12,0,0,$b, 1, $year))."".$delta."
Total :$deltat
Rappel $ayear :$acat
Soit :".($acat+$deltat)."
"; + print "

"; + +} + + +/* + * + */ + +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 "

"; + ppt($db, 2000, $socidp); + +} + + +if ($details == 1) { + print "
"; + factures ($db, $year, $month, 1); + print ""; + propals ($db, $year, $month); + print "
"; +} +$db->close(); + + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/compta/fac.php3 b/htdocs/compta/fac.php3 new file mode 100644 index 00000000000..07d42056a85 --- /dev/null +++ b/htdocs/compta/fac.php3 @@ -0,0 +1,135 @@ + + * $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 "

"; + +$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 ""; + print ""; + + print ""; + print ""; + print ""; + print ""; + print "\n"; + $var=True; + while ($i < $num) { + $objp = $db->fetch_object( $i); + $var=!$var; + + print ""; + + print "\n"; + print "\n"; + + if ($objp->df > 0 ) { + print ""; + } else { + print "\n"; + } + + print "\n"; + print "\n"; + print "\n"; + print "\n"; + + + $total = $total + $objp->amount; + $subtotal = $subtotal + $objp->amount; + + print "\n"; + print "\n"; + $i++; + $j++; + + } + } + if ($i == 0) { $i=1; } if ($j == 0) { $j=1; } + print ""; + print ""; + print ""; + + print ""; + print ""; + print ""; + + print "
NuméroSocieteDateMontantRemiseTVA
facid\">$objp->facnumberidp\">$objp->nom"; + $y = strftime("%Y",$objp->df); + $m = strftime("%m",$objp->df); + + print strftime("%d/%b/%Y",$objp->df)."!!!".price($objp->amount)."".price($objp->remise)."".price($objp->tva)."".price($objp->total)."".price($subtotal / ($j + 1))."
$j factures"; + print "Total : ".francs($subtotal)." FFSous Total : ".price($subtotal)."euros HTMoyenne : ".price($subtotal/ $j)."
$i factures"; + print "Total : ".francs($total)." FFTotal : ".price($total)."euros HTMoyenne : ".price($total/ $i)."
"; + $db->free(); +} else { + print $db->error(); +} + +$db->close(); +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/compta/facture.php3 b/htdocs/compta/facture.php3 new file mode 100644 index 00000000000..3c7fa6642a3 --- /dev/null +++ b/htdocs/compta/facture.php3 @@ -0,0 +1,346 @@ + + * + * $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 ""; + print ""; + print ""; + print "\n"; + print ""; + print ""; + print ""; + print "
Facture $facid [reload]socidp\">Autres factures de $obj->socnom
"; + /* + * Facture + */ + print ""; + print ""; + print ""; + print "\n"; + print ""; + print ""; + print ""; + + print ""; + print ""; + print ""; + print ""; + print ""; + print "
Sociétésocidp\">$obj->socnom
Numéro$obj->facnumber
date".strftime("%A %d %B %Y",$obj->df)."
Auteur$obj->author
Statut$obj->statut
Paye".$yn[$obj->paye]."
Montant".price($obj->amount)."euros HT
TVA".tva($obj->amount)."euros
Total".price($obj->total)."euros TTC
soit".francs(inctva($obj->amount))."francs
"; + + print "
"; + + $_MONNAIE="euros"; + + /* + * Paiements + */ + $sql = "SELECT ".$db->pdate("datep")." as dp, p.amount, c.libelle as paiement_type, p.num_paiement, p.rowid"; + $sql .= " FROM llx_paiement as p, c_paiement as c WHERE p.fk_facture = $facid AND p.fk_paiement = c.id"; + + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows(); + $i = 0; $total = 0; + print "

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

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

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

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


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

command :
$command
"; + print "

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

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

"; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print "\n"; + $var=True; + while ($i < $num) { + $objp = $db->fetch_object( $i); + $var=!$var; + print ""; + print "\n"; + print "\n"; + + + print "\n"; + + if ($objp->df > 0 ) { + print "\n"; + } else { + print "\n"; + } + + print ''; + + $yn[1] = "oui"; + $yn[0] = "non"; + + $total = $total + $objp->amount; + print "\n"; + print "\n"; + print "\n"; + $i++; + } + print ""; + print ""; + print ""; + print "
[Tous]SocieteNumDateMontantPayéMoyenne
[idp\">Filtre]idp\">$objp->nomfacid\">$objp->facnumber"; + $y = strftime("%Y",$objp->df); + $m = strftime("%m",$objp->df); + + print strftime("%d",$objp->df)."\n"; + print " "; + print strftime("%B",$objp->df)."\n"; + print " "; + print strftime("%Y",$objp->df)."!!!'.price($objp->amount).'".$yn[$objp->paye]."".round($total / ($i + 1))."
$i facturesTotal : ".round($total * 6.55957)." FFTotal : $total$_MONNAIE HTMoyenne : ".round($total/ $i)."
"; + } + $db->free(); + } else { + print $db->error(); + } + } + print "

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

"; + liste($db, 1); + +} + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/compta/genfac.php3 b/htdocs/compta/genfac.php3 new file mode 100644 index 00000000000..5d10525a98a --- /dev/null +++ b/htdocs/compta/genfac.php3 @@ -0,0 +1,221 @@ + + * + * $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

"; + + $outp = `cd /tmp ; pdflatex $filename`; + + print "

$outp

"; + + +} 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 "

"; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print "\n"; + $var=True; + while ($i < $num) { + $objp = $db->fetch_object( $i); + $var=!$var; + print ""; + print "\n"; + print "\n"; + + + print "\n"; + + if ($objp->df > 0 ) { + print "\n"; + } else { + print "\n"; + } + + print "\n"; + + $yn[1] = "oui"; + $yn[0] = "non"; + + $total = $total + $objp->amount; + print "\n"; + print "\n"; + print "\n"; + + + + $i++; + } + print ""; + print ""; + print ""; + print "
[Tous]SocieteNumDateMontantPayéMoyenne
[idp\">Filtre]idp\">$objp->nomfacid\">$objp->facnumber"; + $y = strftime("%Y",$objp->df); + $m = strftime("%m",$objp->df); + + print strftime("%d",$objp->df)."\n"; + print " "; + print strftime("%B",$objp->df)."\n"; + print " "; + print strftime("%Y",$objp->df)."!!!$objp->amount".$yn[$objp->paye]."".round($total / ($i + 1))."
$i facturesTotal : ".round($total * 6.55957)." FFTotal : $totaleuros HTMoyenne : ".round($total/ $i)."
"; + $db->free(); + } + } + } + print "

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

"; + liste($db, 1); + +} + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/compta/index.php3 b/htdocs/compta/index.php3 new file mode 100644 index 00000000000..ae81937b8df --- /dev/null +++ b/htdocs/compta/index.php3 @@ -0,0 +1,156 @@ + + * + * $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 é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 "

"; + +$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 ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print "\n"; + $var=True; + while ($i < $num) { + $objp = $db->fetch_object( $i); + $var=!$var; + + if ($objp->paye && !$sep) { + print ""; + print ""; + print ""; + + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print "\n"; + $sep = 1 ; $j = 0; + $subtotal = 0; + } + + print ""; + print "\n"; + print "\n"; + print "\n"; + + if ($objp->df > 0 ) { + print "\n"; + } else { + print "\n"; + } + + print "\n"; + + $yn[1] = "oui"; + $yn[0] = "non"; + + $total = $total + $objp->amount; + $subtotal = $subtotal + $objp->amount; + print "\n"; + print "\n"; + print "\n"; + $i++; + $j++; + + } + } + if ($i == 0) { $i=1; } if ($j == 0) { $j=1; } + print ""; + print ""; + print ""; + + print ""; + print ""; + print ""; + + print "
[Tous]NuméroSocieteDateMontantPayéMoyenne
$i factures"; + print "Total : ".francs($total)." FFSous Total : ".price($total)."euros HTMoyenne : ".price($total / ($i+1))."
[Tous]NuméroSocieteDateMontantPayéMoyenne
[idp\">Filtre]facid\">$objp->facnumberidp\">$objp->nom"; + $y = strftime("%Y",$objp->df); + $m = strftime("%m",$objp->df); + + print strftime("%d",$objp->df)."\n"; + print " "; + print strftime("%B",$objp->df)."\n"; + print " "; + print strftime("%Y",$objp->df)."!!!".price($objp->amount)."".$yn[$objp->paye]."".price($subtotal / ($j + 1))."
$j factures"; + print "Total : ".francs($subtotal)." FFSous Total : ".price($subtotal)."euros HTMoyenne : ".price($subtotal/ $j)."
$i factures"; + print "Total : ".francs($total)." FFTotal : ".price($total)."euros HTMoyenne : ".price($total/ $i)."
"; + $db->free(); +} else { + print $db->error(); +} + +$db->close(); +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/compta/pmt.php3 b/htdocs/compta/pmt.php3 new file mode 100644 index 00000000000..ff6ea96208f --- /dev/null +++ b/htdocs/compta/pmt.php3 @@ -0,0 +1,147 @@ + + * + * $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 ""; +print "
"; + +$sql = "SELECT amount, int(month) as dm FROM llx_pointmort ORDER BY month DESC"; + +$result = $db->query($sql); + +if ($result) { + + + + print "

"; + print ""; + print ""; + print ""; + print "\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 ""; + + print "\n"; + print "\n"; + + + print "\n"; + + + $i++; + } + + print "
MoisMontant
".strftime("%Y %B",$obj->dm)."$obj->amount
"; +} + +print "

"; + +print "
"; +print ""; + + +$strmonth[1] = "Janvier"; +$strmonth[2] = "Février"; +$strmonth[3] = "Mars"; +$strmonth[4] = "Avril"; +$strmonth[5] = "Mai"; +$strmonth[6] = "Juin"; +$strmonth[7] = "Juillet"; +$strmonth[8] = "Août"; +$strmonth[9] = "Septembre"; +$strmonth[10] = "Octobre"; +$strmonth[11] = "Novembre"; +$strmonth[12] = "Décembre"; + + + +print "Date :"; +$cmonth = date("n", time()); +print ""; + +print "
"; + +print "Valeur :
"; +print ""; +print "
"; + + + + +print "
"; + +$db->close(); + + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/compta/pointmort.php3 b/htdocs/compta/pointmort.php3 new file mode 100644 index 00000000000..f155de7ded0 --- /dev/null +++ b/htdocs/compta/pointmort.php3 @@ -0,0 +1,190 @@ + + * + * $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 ."
"; + + $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 "

"; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print "\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 ''; + print ''; + } + + $var=!$var; + + print ""; + print "\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 "\n"; + } else { + print "\n"; + } + + print "\n"; + if ($pm > 0) { + print "\n"; + } else { + print "\n"; + } + print "\n"; + print "\n"; + + $pmbymonth = round($pmt/$i); + + print "\n"; + + $pmbymdelta = ($pmbymonth - $pmbymontha); + + if ( $pmbymdelta > 0 ) { + print "\n"; + } else { + print "\n"; + } + + $pmbymontha = $pmbymonth; + + print "\n"; + + $xdate = mktime(0, 0, 0, date("m", $xdate + (33 * 24 * 3600)), 1 , date("Y", $xdate + (33 * 24 * 3600))) ; + $i++; + } + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print "
 MoisCAPoint mortDeltaSommeSomme par anSomme / nb moisEcart
 '.$oldyear.' 
$i".strftime("%Y %B", $xdate)."".$ca[$b]."0".$ptmt[$b]."+$pm$pm$pmt$subpmt$pmbymonth +$pmbymdelta$pmbymdelta
Totaux en euros :$totalca$totalpm$pmt 
Totaux en francs :".francs($totalca)."".francs($totalpm)."".francs($pmt)." 
"; +} + + +/* + * + */ + +llxHeader(); + +print "Point mort"; + +$db = new Db(); + +ppt($db, 0); + + +print "


"; +print ""; +print "
Paramétrer le point mort
"; + + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/compta/pre.inc.php3 b/htdocs/compta/pre.inc.php3 new file mode 100644 index 00000000000..ff1d152cb16 --- /dev/null +++ b/htdocs/compta/pre.inc.php3 @@ -0,0 +1,110 @@ + + * + * $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 "\n$head\n\n"; + ?> + + \n"; + print "

" . $GLOBALS["MAIN_TITLE"] . "TechniqueCommercialComptaStats
\n"; + + print ""; + print "\n
"; + + print ""; + print ""; + print ""; + print ""; + + print ""; + + print ""; + + print ""; + + + print ""; + + print "
"; + + print "
" . $GLOBALS["dbname"] . " - " . $GLOBALS["REMOTE_USER"] ."
"; + print "Accueil"; + + print "
"; + + print "
Factures

\n"; + print "Paiements
\n"; + print "admin fac
\n"; + + print "

"; + + print "
Chiffres d'affaires

\n"; + print "Réalisé
\n"; + print "Prévisionnel
\n"; + print "Comparatif\n"; + + print "
"; + print "
Analyses

\n"; + print "CA par societe
\n"; + print "Point mort
\n"; + print "TVA
\n"; + print "
"; + print "Propal
\n"; + print "
"; + print "Bank
\n"; + print "
"; + print "Societes\n"; + print "
"; + print ""; + print ""; + print "
"; + + print "
"; + print ""; + print ""; + print "
"; + print "
"; + + + print "
\n"; +} +/* + * + */ +function llxFooter($foot='') { + print "
\n"; + print "$foot"; +} +// $Id$ +// $Source$ +?> diff --git a/htdocs/compta/prev.php3 b/htdocs/compta/prev.php3 new file mode 100644 index 00000000000..202370f6e3c --- /dev/null +++ b/htdocs/compta/prev.php3 @@ -0,0 +1,119 @@ + + * + * $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 '

'; + print ""; + print ""; + print ""; + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows(); + $i = 0; $total = 0 ; + + print "\n"; + $var=True; + while ($i < $num) + { + $obj = $db->fetch_object( $i); + $var=!$var; + print ''; + print ''; + print ''; + + print "\n"; + $total = $total + $obj->amount; + $i++; + } + print ""; + + $db->free(); + } + else + { + print ""; + + } + print "
$titleMontant
'.$obj->dm.''.price($obj->amount).'
Total : ".price($total)." euros HT
".$db->error() . "
"; + +} +/* + * + */ + +llxHeader(); + + +$db = new Db(); +if ($sortfield == "") { + $sortfield="lower(p.label)"; +} +if ($sortorder == "") { + $sortorder="ASC"; +} + +$in = "(1,2)"; +//$in = "(3)"; + +print "

CA Prévisionnel basé sur les propal ouvertes et signées"; + +print ''; + +print '
'; + +$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 ''; + +$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ée"); + +print "

"; + +$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és"); + +print "

"; + +$db->close(); + + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/compta/tva.php3 b/htdocs/compta/tva.php3 new file mode 100644 index 00000000000..e549696df15 --- /dev/null +++ b/htdocs/compta/tva.php3 @@ -0,0 +1,104 @@ + + * $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 "

"; + print ""; + print ""; + print ""; + print "\n"; + print "\n"; + $var=True; + while ($i < $num) { + $obj = $db->fetch_object( $i); + $var=!$var; + print ""; + print "\n"; + print "\n"; + print "\n"; + + $total = $total + $obj->amount; + + $i++; + } + print ""; + + print "
$dateMontant 
$obj->dm".price($obj->amount)." 
Total :".price($total)."euros HT
"; + $db->free(); + } +} + +/* + * + */ + +llxHeader(); + +$db = new Db(); + +$yearc = strftime("%Y",time()); + + +echo '
'; + +print "TVA collectée"; + +for ($y = $yearc ; $y >= $conf->years ; $y=$y-1 ) { + + print ""; + print "
"; + + $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ée $y"); + + print "
"; +} + +echo '
'; +echo 'Tva Payée
'; +echo '
'; + + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/conf/.cvsignore b/htdocs/conf/.cvsignore new file mode 100644 index 00000000000..5413c3125ba --- /dev/null +++ b/htdocs/conf/.cvsignore @@ -0,0 +1 @@ +conf.class.php3 diff --git a/htdocs/conf/conf.class.php3.sample b/htdocs/conf/conf.class.php3.sample new file mode 100644 index 00000000000..a31e5a27b9e --- /dev/null +++ b/htdocs/conf/conf.class.php3.sample @@ -0,0 +1,49 @@ + + * + * $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"; + } +} +?> diff --git a/htdocs/index.php3 b/htdocs/index.php3 index 7583915354b..37ddbea712b 100644 --- a/htdocs/index.php3 +++ b/htdocs/index.php3 @@ -34,7 +34,7 @@ print "

  • Commercial"; print "
  • Compta"; print "
  • Stats"; -print ""; + function valeur($sql) { global $db; @@ -61,18 +61,22 @@ if ($db->ok) { print "DescriptionValeur"; print "\n"; - $var=!$var; - $sql = "SELECT count(*) FROM llx_propal WHERE fk_statut = 0"; - print "Propales brouillons".valeur($sql).""; - - $var=!$var; - $sql = "SELECT count(*) FROM llx_propal WHERE fk_statut = 1"; - print "Propales ouvertes".valeur($sql).""; - - $var=!$var; - $sql = "SELECT count(*) FROM llx_facture WHERE paye=0"; - print "Factures en attente de paiement".valeur($sql).""; + if (valeur($sql)) { + $var=!$var; + $sql = "SELECT count(*) FROM llx_propal WHERE fk_statut = 0"; + print "Propales brouillons".valeur($sql).""; + } + if (valeur($sql)) { + $var=!$var; + $sql = "SELECT count(*) FROM llx_propal WHERE fk_statut = 1"; + print "Propales ouvertes".valeur($sql).""; + } + if (valeur($sql)) { + $var=!$var; + $sql = "SELECT count(*) FROM llx_facture WHERE paye=0"; + print "Factures en attente de paiement".valeur($sql).""; + } print "
    "; diff --git a/htdocs/lib/CMailFile.class.php3 b/htdocs/lib/CMailFile.class.php3 new file mode 100644 index 00000000000..987a94abd41 --- /dev/null +++ b/htdocs/lib/CMailFile.class.php3 @@ -0,0 +1,121 @@ +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 +?> diff --git a/htdocs/lib/functions.inc.php3 b/htdocs/lib/functions.inc.php3 new file mode 100644 index 00000000000..1f44d4561e3 --- /dev/null +++ b/htdocs/lib/functions.inc.php3 @@ -0,0 +1,245 @@ + + * + * $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 ""; + + if ($ispage) { + + print ""; + print "\n"; + print "
    "; + print "$title$basec Page $pagenext"; + print "
    "; + if ($page > 0) { + print "<- ".$GLOBALS["_PAGE_PREV"].""; + } + print "$_PAGE_NEXT ->\n"; + } + + print "
    "; +}; + +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

    $sql


    "; + return 1; + } + + print ""; + print ""; + print ""; + print ""; + + $num = $db->num_rows(); + $i = 0; + + $tag = 1; + while ( $i < $num) { + $obj = $db->fetch_object( $i); + + $tag = !$tag; + + print "\n"; + print "\n"; + $i++; + } + print "
    base $basenamelibelle
    $obj->date$obj->libelle$obj->nb
    "; + $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

    $sql


    "; + return 1; + } + print "
    "; + + print ""; + print ""; + print ""; + print ""; + $nbcv = $db->result( $i, "nbcv"); + + print "\n"; + print "\n"; + print "\n"; + $db->free(); + + $sql="SELECT count(*) AS nbcv from offre WHERE active=1"; + + $result = $db->query($sql); + if (!$result) { + print "Erreur SELECT

    $sql


    "; + } + $nbcv = $db->result( $i, "nbcv"); + + print ""; + print ""; + print ""; + + $db->free(); + + + $sql="SELECT count(*) AS nbcv from candidat WHERE active=0"; + + $result = $db->query($sql); + if (!$result) { + print "Erreur SELECT

    $sql


    "; + } + + $nbcv = $db->result( $i, "nbcv"); + + print "\n"; + print ""; + print ""; + + $db->free(); + + + $sql="SELECT count(*) AS nbcv from offre WHERE active=0"; + + $result = $db->query($sql); + if (!$result) { + print "Erreur SELECT

    $sql


    "; + } + + $nbcv = $db->result( $i, "nbcv"); + + print "\n"; + print "\n"; + print "\n"; + + $db->free(); + + + $sql="SELECT count(*) AS nbsoc from logsoc"; + + $result = $db->query($sql); + if (!$result) { + print "Erreur SELECT

    $sql


    "; + } + + $nbsoc = $db->result( $i, "nbsoc"); + + print "\n"; + print ""; + print ""; + + print "
    base $basenamelibelle
    $ftc Nombre de CV$ftc $nbcv
    $ftc Nombre d'offre$ftc $nbcv
    $ftc Nombre de CV inactifs$ftc $nbcv
    $ftc Nombre d'offres inactives$ftc $nbcv
    $ftc Nombre de logins societes$ftc $nbsoc
    "; + + $db->close(); + +} +?> diff --git a/htdocs/lib/mysql.lib.php3 b/htdocs/lib/mysql.lib.php3 new file mode 100644 index 00000000000..cdea6897e94 --- /dev/null +++ b/htdocs/lib/mysql.lib.php3 @@ -0,0 +1,129 @@ + + * Copyright (C) 2002 Rodolphe Quiedeville + * + * $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é
    \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(); + } +} + +?> diff --git a/httpd.conf b/httpd.conf index 5f9b36bd0c9..d3be9875e82 100644 --- a/httpd.conf +++ b/httpd.conf @@ -20,7 +20,7 @@ AuthType Basic Auth_MySQL_Authoritative on - Auth_MySQL_DB lolixfr + Auth_MySQL_DB dolibarr Auth_MySQL_Password_Table llx_user Auth_MySQL_Username_Field login Auth_MySQL_Password_Field pass diff --git a/mysql/Makefile b/mysql/Makefile index 00e987d364a..901992ff8b6 100644 --- a/mysql/Makefile +++ b/mysql/Makefile @@ -36,6 +36,13 @@ table: cd tables \ && make create +data: + cd data \ + && make load + +dev: + $(MYSQL) $(BASE) < data/data-dev.sql + droptable: cd tables \ && make drop diff --git a/mysql/data/data.sql b/mysql/data/data.sql index 1dddfe42e6f..02243375635 100644 --- a/mysql/data/data.sql +++ b/mysql/data/data.sql @@ -87,10 +87,6 @@ delete from c_paiement; insert into c_paiement (id,libelle) values (0, 'Cheque'); 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égie'); -insert into c_prestatype (id,libelle) values (2, 'Forfait'); delete from c_propalst; insert into c_propalst (id,label) values (0, '---'); diff --git a/mysql/tables/Makefile b/mysql/tables/Makefile index d880894a8c3..87fd3e50654 100644 --- a/mysql/tables/Makefile +++ b/mysql/tables/Makefile @@ -29,7 +29,7 @@ create: $(MYSQL) $(BASE) < c_effectif.sql $(MYSQL) $(BASE) < c_paiement.sql $(MYSQL) $(BASE) < c_pays.sql - $(MYSQL) $(BASE) < c_prestatype.sql + $(MYSQL) $(BASE) < c_propalst.sql $(MYSQL) $(BASE) < c_stcomm.sql $(MYSQL) $(BASE) < c_typent.sql @@ -43,6 +43,7 @@ create: $(MYSQL) $(BASE) < llx_paiement.sql $(MYSQL) $(BASE) < llx_pointmort.sql $(MYSQL) $(BASE) < llx_product.sql + $(MYSQL) $(BASE) < llx_projet.sql $(MYSQL) $(BASE) < llx_propal.sql $(MYSQL) $(BASE) < llx_propaldet.sql $(MYSQL) $(BASE) < llx_soc_recontact.sql @@ -50,6 +51,7 @@ create: $(MYSQL) $(BASE) < llx_ventes.sql $(MYSQL) $(BASE) < societe.sql $(MYSQL) $(BASE) < socpeople.sql + $(MYSQL) $(BASE) < socstatutlog.sql drop: $(MYSQL) $(BASE) < drop.sql diff --git a/mysql/tables/c_actioncomm.sql b/mysql/tables/c_actioncomm.sql index de9c67e3f27..462f32b9747 100644 --- a/mysql/tables/c_actioncomm.sql +++ b/mysql/tables/c_actioncomm.sql @@ -1,10 +1,10 @@ --- ======================================================================== --- $Id$ --- $Source$ --- ======================================================================== - -create table c_actioncomm -( - id integer PRIMARY KEY, - libelle varchar(30) -); +-- ======================================================================== +-- $Id$ +-- $Source$ +-- ======================================================================== + +create table c_actioncomm +( + id integer PRIMARY KEY, + libelle varchar(30) +); diff --git a/mysql/tables/c_effectif.sql b/mysql/tables/c_effectif.sql index a4594c569a6..c34a0c2c80a 100644 --- a/mysql/tables/c_effectif.sql +++ b/mysql/tables/c_effectif.sql @@ -1,11 +1,11 @@ --- ======================================================================== --- $Id$ --- $Source$ --- ======================================================================== - -create table c_effectif -( - id integer PRIMARY KEY, - libelle varchar(30) -); - +-- ======================================================================== +-- $Id$ +-- $Source$ +-- ======================================================================== + +create table c_effectif +( + id integer PRIMARY KEY, + libelle varchar(30) +); + diff --git a/mysql/tables/c_paiement.sql b/mysql/tables/c_paiement.sql index 3127353908a..05725badb74 100644 --- a/mysql/tables/c_paiement.sql +++ b/mysql/tables/c_paiement.sql @@ -1,12 +1,12 @@ --- ======================================================================== --- $Id$ --- $Source$ --- ======================================================================== -create table c_paiement -( - id integer PRIMARY KEY, - libelle varchar(30) -); - - - +-- ======================================================================== +-- $Id$ +-- $Source$ +-- ======================================================================== +create table c_paiement +( + id integer PRIMARY KEY, + libelle varchar(30) +); + + + diff --git a/mysql/tables/c_pays.sql b/mysql/tables/c_pays.sql index 710f3dd6f9a..5783378fa71 100644 --- a/mysql/tables/c_pays.sql +++ b/mysql/tables/c_pays.sql @@ -1,13 +1,13 @@ --- ======================================================================== --- $Id$ --- $Source$ --- ======================================================================== - -create table c_pays -( - id integer PRIMARY KEY, - libelle varchar(25), - code char(2) NOT NULL -); - - +-- ======================================================================== +-- $Id$ +-- $Source$ +-- ======================================================================== + +create table c_pays +( + id integer PRIMARY KEY, + libelle varchar(25), + code char(2) NOT NULL +); + + diff --git a/mysql/tables/c_stcomm.sql b/mysql/tables/c_stcomm.sql index f2fcb8380a0..01b6d4be459 100644 --- a/mysql/tables/c_stcomm.sql +++ b/mysql/tables/c_stcomm.sql @@ -1,11 +1,11 @@ --- ======================================================================== --- $Id$ --- $Source$ --- ======================================================================== - -create table c_stcomm -( - id integer PRIMARY KEY, - libelle varchar(30) -); - +-- ======================================================================== +-- $Id$ +-- $Source$ +-- ======================================================================== + +create table c_stcomm +( + id integer PRIMARY KEY, + libelle varchar(30) +); + diff --git a/mysql/tables/c_typent.sql b/mysql/tables/c_typent.sql index ad8f3fb7091..7d6ee53a188 100644 --- a/mysql/tables/c_typent.sql +++ b/mysql/tables/c_typent.sql @@ -1,10 +1,10 @@ --- ======================================================================== --- $Id$ --- $Source$ --- ======================================================================== - -create table c_typent -( - id integer PRIMARY KEY, - libelle varchar(30) -); +-- ======================================================================== +-- $Id$ +-- $Source$ +-- ======================================================================== + +create table c_typent +( + id integer PRIMARY KEY, + libelle varchar(30) +); diff --git a/mysql/tables/drop.sql b/mysql/tables/drop.sql index 256d6329468..512ee49beb9 100644 --- a/mysql/tables/drop.sql +++ b/mysql/tables/drop.sql @@ -104,7 +104,11 @@ drop table if exists lang ; drop table if exists langoffre ; 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_class; 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_projet; + drop table if exists llx_propal; drop table if exists llx_propaldet; drop table if exists llx_soc_recontact; +drop table if exists llx_user; + drop table if exists llx_ventes; drop table if exists login ; diff --git a/mysql/tables/llx_user.sql b/mysql/tables/llx_user.sql index 261398bc2b1..c873b56e3cc 100644 --- a/mysql/tables/llx_user.sql +++ b/mysql/tables/llx_user.sql @@ -22,16 +22,18 @@ create table llx_user ( - rowid integer AUTO_INCREMENT PRIMARY KEY, - datec datetime, - tms timestamp, - login varchar(8), - pass varchar(8), - name varchar(50), - firstname varchar(50), - code varchar(4), - email varchar(255), - note text, + rowid integer AUTO_INCREMENT PRIMARY KEY, + datec datetime, + tms timestamp, + login varchar(8), + pass varchar(8), + name varchar(50), + firstname varchar(50), + code varchar(4), + email varchar(255), + module_comm smallint default 1, + module_compta smallint default 1, + note text, UNIQUE INDEX(code) ); diff --git a/mysql/tables/soc_events.sql b/mysql/tables/soc_events.sql index d3c9eb22bb2..cbc0fdbe46b 100644 --- a/mysql/tables/soc_events.sql +++ b/mysql/tables/soc_events.sql @@ -1,15 +1,15 @@ --- ======================================================================== --- $Id$ --- $Source$ --- ======================================================================== - -create table soc_events -( - rowid integer AUTO_INCREMENT PRIMARY KEY, -- public id - fk_soc int NOT NULL, -- - dateb datetime NOT NULL, -- begin date - datee datetime NOT NULL, -- end date - title varchar(100) NOT NULL, - url varchar(255), - description text -); +-- ======================================================================== +-- $Id$ +-- $Source$ +-- ======================================================================== + +create table soc_events +( + rowid integer AUTO_INCREMENT PRIMARY KEY, -- public id + fk_soc int NOT NULL, -- + dateb datetime NOT NULL, -- begin date + datee datetime NOT NULL, -- end date + title varchar(100) NOT NULL, + url varchar(255), + description text +); diff --git a/mysql/tables/societe.sql b/mysql/tables/societe.sql index c9deda0c247..604dc331b56 100644 --- a/mysql/tables/societe.sql +++ b/mysql/tables/societe.sql @@ -1,59 +1,53 @@ --- ======================================================================== --- Copyright (C) 2000-2002 Rodolphe Quiedeville --- SGBD : Mysql 3.23 --- --- $Id$ --- $Source$ --- ======================================================================== -create table societe -( - idp integer AUTO_INCREMENT PRIMARY KEY, - id varchar(32), -- private id - active smallint default 0, -- - parent integer default 0, -- - intern bool default 1 NOT NULL, -- is an intern company - cjn bool default 1 NOT NULL, -- is allowed to export to cjn - ssii bool default 0 NOT NULL, -- - datec datetime, -- creation date - datem datetime, -- modification date - datea datetime, -- activation date - datel datetime, -- last login date - nom varchar(60), -- company name - address varchar(255), -- company adresse - cp varchar(10), -- zipcode - ville varchar(50), -- town - fk_pays integer default 0, -- - tel varchar(20), -- phone number - fax varchar(20), -- fax number - url varchar(255), -- - fk_secteur integer default 0, -- - fk_effectif integer default 0, -- - fk_typent integer default 0, -- - 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, -- - 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 - 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, -- - reminder integer default 1, -- - prefix_comm varchar(5), -- prefix commercial - - UNIQUE INDEX(prefix_comm) -); +-- ======================================================================== +-- Copyright (C) 2000-2002 Rodolphe Quiedeville +-- SGBD : Mysql 3.23 +-- +-- $Id$ +-- $Source$ +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +-- +-- ======================================================================== +create table societe +( + idp integer AUTO_INCREMENT PRIMARY KEY, + id varchar(32), -- private id + active smallint default 0, -- + parent integer default 0, -- + tms timestamp, + datec datetime, -- creation date + datea datetime, -- activation date + nom varchar(60), -- company name + address varchar(255), -- company adresse + cp varchar(10), -- zipcode + ville varchar(50), -- town + fk_pays integer default 0, -- + tel varchar(20), -- phone number + fax varchar(20), -- fax number + url varchar(255), -- + fk_secteur integer default 0, -- + fk_effectif integer default 0, -- + fk_typent integer default 0, -- + siren varchar(9), -- + description text, -- + fk_stcomm smallint default 0, -- commercial statut + note text, -- + services integer default 0, -- + prefix_comm varchar(5), -- prefix commercial + client smallint default 0, -- client oui/non + fournisseur smallint default 0, -- fournisseur oui/non + + UNIQUE INDEX(prefix_comm) +); diff --git a/mysql/tables/socstatutlog.sql b/mysql/tables/socstatutlog.sql index 942be25efed..68df444af76 100644 --- a/mysql/tables/socstatutlog.sql +++ b/mysql/tables/socstatutlog.sql @@ -1,13 +1,13 @@ --- ======================================================================== --- SGBD : PostgreSQL 6.5.3 --- $Id$ --- $Source$ --- ======================================================================== -create table socstatutlog -( - id serial, - datel datetime, - fk_soc integer, - fk_statut integer, - author varchar(30) -); +-- ======================================================================== +-- SGBD : PostgreSQL 6.5.3 +-- $Id$ +-- $Source$ +-- ======================================================================== +create table socstatutlog +( + id integer AUTO_INCREMENT PRIMARY KEY, + datel datetime, + fk_soc integer, + fk_statut integer, + author varchar(30) +);