From 41ec00f3284281d26c646af7df58acb9fac67085 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Tue, 30 Apr 2002 15:36:13 +0000 Subject: [PATCH] . --- htdocs/comm/pre.inc.php3 | 9 +- htdocs/comm/projet/fiche.php3 | 48 +++++---- htdocs/comm/projet/pre.inc.php3 | 10 +- htdocs/compta/pre.inc.php3 | 5 +- htdocs/main.inc.php3 | 11 ++ htdocs/pre.inc.php3 | 11 +- htdocs/product/pre.inc.php3 | 27 +---- htdocs/service.class.php3 | 174 ++++++++++++++++++++++++++++++++ htdocs/service/fiche.php3 | 123 +++++++++++++++++++++- htdocs/service/index.php3 | 148 ++++++++++++--------------- htdocs/service/pre.inc.php3 | 29 ++---- mysql/data/data_dev.sql | 46 +++++++++ mysql/tables/llx_product.sql | 18 ++++ mysql/tables/llx_service.sql | 6 +- 14 files changed, 484 insertions(+), 181 deletions(-) create mode 100644 htdocs/service.class.php3 create mode 100644 mysql/data/data_dev.sql diff --git a/htdocs/comm/pre.inc.php3 b/htdocs/comm/pre.inc.php3 index 2db8c8c7d4e..62c954c2d4d 100644 --- a/htdocs/comm/pre.inc.php3 +++ b/htdocs/comm/pre.inc.php3 @@ -79,6 +79,7 @@ function llxHeader($head = "", $urlp = "") { */ print ""; print '
Produits
'; + print '
Services
'; print ""; /* * @@ -121,14 +122,6 @@ function llxHeader($head = "", $urlp = "") { print "\n"; } -function llxFooter($foot='') { - print ""; - /* - * - */ - print "\n"; - print "$foot"; -} /* * $Id$ * $Source$ diff --git a/htdocs/comm/projet/fiche.php3 b/htdocs/comm/projet/fiche.php3 index e678c72b6ec..b84f7ec347a 100644 --- a/htdocs/comm/projet/fiche.php3 +++ b/htdocs/comm/projet/fiche.php3 @@ -21,7 +21,7 @@ */ require("./pre.inc.php3"); -require("../../lib/functions.inc.php3"); +require("../../societe.class.php3"); require("./project.class.php3"); require("../propal.class.php3"); @@ -54,25 +54,38 @@ $pagenext = $page + 1; if ($action == 'create') { -?> -
- - - -'; -?> - - - -
Société -'; ?> -
Créateur'.$user->fullname.'
Ref
Titre
-
-'; + ?> + + + + + + '; + ?> + + + +
Société +get_nom($socidp); + print $societe->nom; + + ?> +
Créateur'.$user->fullname.'
Référence
Titre
+ + fetch($db, $id); @@ -119,7 +132,6 @@ print 'Cr print 'Soit : '.francs($total).' FF HT'; print 'Total : '.price($total).''; print 'Euros HT'; - print ""; diff --git a/htdocs/comm/projet/pre.inc.php3 b/htdocs/comm/projet/pre.inc.php3 index 6cf468cb122..9261aef1ed9 100644 --- a/htdocs/comm/projet/pre.inc.php3 +++ b/htdocs/comm/projet/pre.inc.php3 @@ -63,7 +63,7 @@ function llxHeader($head = "", $urlp = "") { print "Factures
\n"; - print "Produits
\n"; + print "Produits
\n"; print ""; @@ -99,14 +99,6 @@ function llxHeader($head = "", $urlp = "") { print "\n"; } -function llxFooter($foot='') { - print ""; - /* - * - */ - print "\n"; - print "$foot"; -} /* * $Id$ * $Source$ diff --git a/htdocs/compta/pre.inc.php3 b/htdocs/compta/pre.inc.php3 index ff1d152cb16..fcccfda8340 100644 --- a/htdocs/compta/pre.inc.php3 +++ b/htdocs/compta/pre.inc.php3 @@ -101,10 +101,7 @@ function llxHeader($head = "") { /* * */ -function llxFooter($foot='') { - print "\n"; - print "$foot"; -} + // $Id$ // $Source$ ?> diff --git a/htdocs/main.inc.php3 b/htdocs/main.inc.php3 index dbcc78efd37..3a7cff077ee 100644 --- a/htdocs/main.inc.php3 +++ b/htdocs/main.inc.php3 @@ -33,6 +33,17 @@ $db = new Db(); $user = new User($db); $user->fetch($GLOBALS["REMOTE_USER"]); +function llxFooter($foot='') { + print ""; + /* + * + */ + print "\n"; + print "$foot
"; + print '[Bug report] '; + print '[Source Code] '; + print ""; +} ?> diff --git a/htdocs/pre.inc.php3 b/htdocs/pre.inc.php3 index 69502382951..da947b8e7b5 100644 --- a/htdocs/pre.inc.php3 +++ b/htdocs/pre.inc.php3 @@ -63,6 +63,7 @@ function llxHeader($head = "") { print "Dictionnaires\n"; print ''; + print ""; print "
Propal
\n"; print ''; @@ -73,6 +74,8 @@ function llxHeader($head = "") { print ""; print "
Produits
\n"; + + print "
Services
\n"; print ''; print ""; @@ -86,13 +89,5 @@ function llxHeader($head = "") { */ print "\n\n"; - - } - -function llxFooter($foot='') { - print "\n"; - print "$foot"; -} - ?> diff --git a/htdocs/product/pre.inc.php3 b/htdocs/product/pre.inc.php3 index 72d92ee99af..a7ecd688031 100644 --- a/htdocs/product/pre.inc.php3 +++ b/htdocs/product/pre.inc.php3 @@ -57,9 +57,6 @@ function llxHeader($head = "", $urlp = "") { print ""; print "
Actions
\n"; - print "Factures
\n"; - print "Propal FE
\n"; - print "Clôture

\n"; print ""; /* * @@ -73,12 +70,6 @@ function llxHeader($head = "", $urlp = "") { print ""; print '

Factures
'; print ""; - /* - * - */ - print ""; - print '
Produits
'; - print ""; /* * */ @@ -86,14 +77,9 @@ function llxHeader($head = "", $urlp = "") { print "Projets
\n"; print ""; - print ""; - print "Stats
\n"; - print ""; - - print ""; - print "
Societes
\n"; - print "
"; + print "
Societes
\n"; + print ""; print ''; print ''; print ' '; @@ -123,14 +109,7 @@ function llxHeader($head = "", $urlp = "") { print "\n"; } -function llxFooter($foot='') { - print ""; - /* - * - */ - print "\n"; - print "$foot"; -} + /* * $Id$ * $Source$ diff --git a/htdocs/service.class.php3 b/htdocs/service.class.php3 new file mode 100644 index 00000000000..dc7992beffd --- /dev/null +++ b/htdocs/service.class.php3 @@ -0,0 +1,174 @@ + + * + * $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 Service { + var $db; + + var $id; + var $libelle; + var $price; + var $tms; + var $debut; + var $fin; + + var $debut_epoch; + var $fin_epoch; + + + Function Service($DB, $id=0) { + $this->db = $DB; + $this->id = $id; + + return 1; + } + /* + * + * + * + */ + Function create($userid) { + + $sql = "INSERT INTO llx_service (datec, fk_user_author) VALUES (now(), $userid)"; + + if ($this->db->query($sql) ) { + $id = $this->db->last_insert_id(); + + if ( $this->update($id, $userid) ) { + return $id; + } + } else { + print $this->db->error() . ' in ' . $sql; + } + } + /* + * + * + * + */ + Function update($id, $userid) { + + $sql = "UPDATE llx_service "; + $sql .= " SET label = '" . trim($this->libelle) ."'"; + $sql .= ",ref = '" . trim($this->ref) ."'"; + $sql .= ",price = " . $this->price ; + $sql .= ",fk_user_modif = " . $userid ; + + $sql .= " WHERE rowid = " . $id; + + if ( $this->db->query($sql) ) { + return 1; + } else { + print $this->db->error() . ' in ' . $sql; + } + } + /* + * + * + * + */ + Function start_comm($id, $userid, $datedeb=0) { + + $sql = "UPDATE llx_service "; + if ($datedeb) { + $sql .= " SET debut_comm = '$datedeb'"; + } else { + $sql .= " SET debut_comm = now()"; + } + $sql .= ",fk_user_modif = " . $userid ; + + $sql .= " WHERE rowid = " . $id; + + if ( $this->db->query($sql) ) { + return 1; + } else { + print $this->db->error() . ' in ' . $sql; + } + } + /* + * + * + * + */ + Function stop_comm($id, $userid, $datefin=0) { + + $sql = "UPDATE llx_service "; + if ($datefin) { + $sql .= " SET fin_comm = '$datefin'"; + } else { + $sql .= " SET fin_comm = now()"; + } + $sql .= ",fk_user_modif = " . $userid ; + + $sql .= " WHERE rowid = " . $id; + + if ( $this->db->query($sql) ) { + return 1; + } else { + print $this->db->error() . ' in ' . $sql; + } + } + /* + * + * + * + */ + Function fetch($id) { + + $sql = "SELECT s.ref,s.label,s.price,s.tms,s.debut_comm,s.fin_comm,"; + $sql .= $this->db->pdate("s.debut_comm") . ' as debut_epoch,'; + $sql .= $this->db->pdate("s.fin_comm") . ' as fin_epoch'; + $sql .= " FROM llx_service as s"; + $sql .= " WHERE s.rowid = $id"; + + $result = $this->db->query($sql); + + if ($result) { + if ($this->db->num_rows()) { + $obj = $this->db->fetch_object($result , 0); + + $this->id = $obj->rowid; + $this->ref = $obj->ref; + $this->libelle = $obj->label; + $this->price = $obj->price; + $this->tms = $obj->tms; + + $this->debut = $obj->debut_comm; + $this->fin = $obj->fin_comm; + + $this->debut_epoch = $obj->debut_epoch; + $this->fin_epoch = $obj->fin_epoch; + + } + $this->db->free(); + + } else { + print $this->db->error(); + } + } + + +} +/* + * $Id$ + * $Source$ + */ +?> diff --git a/htdocs/service/fiche.php3 b/htdocs/service/fiche.php3 index 24558d459df..6eb025371ce 100644 --- a/htdocs/service/fiche.php3 +++ b/htdocs/service/fiche.php3 @@ -21,21 +21,46 @@ */ require("./pre.inc.php3"); +require("../service.class.php3"); llxHeader(); - $db = new Db(); -if ($action == "create") { +if ($action == 'add') { + $service = new Service($db); + + $service->ref = $ref; + $service->libelle = $label; + $service->price = $price; + $service->description = $desc; + + $id = $service->create($user->id); + + if ($comm_now && $id) { + $service->start_comm($id, $user->id); + } + +} + +if ($action == 'set_datedeb') { + $service = new Service($db); + $service->start_comm($id, $user->id, $datedeb); +} +if ($action == 'set_datefin') { + $service = new Service($db); + $service->stop_comm($id, $user->id, $datefin); +} + +if ($action == 'create') { print "Nouveau service
"; - print "\n"; - print ""; + print ''; + print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; @@ -46,11 +71,99 @@ if ($action == "create") { print '"; + + print ''; + print ''; + print ''; print ''; print '
Référence
Libelle
Description'; print "
Commercialisé
'; +} else { + + if ($id) { + + print "\n"; + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print '
Liste[Date de debut] [Date de fin]

'; + + + $service = new Service($db); + $service->fetch($id); + + print ''; + + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + + print ''; + + if ($service->fin_epoch < time()) { + print ''; + } else { + print ''; + } + + print '"; + print '
Référence'.$service->ref.'Créé le'.$service->tms.'
Libelle'.$service->libelle.'Début comm'.$service->debut.'
Prix'.price($service->price).'Fin comm'.$service->fin.' 
'.$service->fin.' 
Description'; + print "
'; + + /* + * + * + * + */ + if ($action == 'datedeb') { + print '

Affectation de la date de début de commercialisation

'; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
Date de debut de commercialisation

'; + } + /* + * + * + * + */ + if ($action == 'datefin') { + print '

Affectation de la date de fin de commercialisation

'; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
Date de fin de commercialisation

'; + } + + } + } + + $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); diff --git a/htdocs/service/index.php3 b/htdocs/service/index.php3 index 59c273e506d..bfef5090e14 100644 --- a/htdocs/service/index.php3 +++ b/htdocs/service/index.php3 @@ -35,14 +35,6 @@ if ($sortorder == "") { $sortorder="ASC"; } -if ($action == 'update') { - $sql = "UPDATE llx_product SET description='$desc' where rowid = $rowid"; - $db->query($sql); -} - -$yn["t"] = "oui"; -$yn["f"] = "non"; - if ($page == -1) { $page = 0 ; } $limit = 26; $offset = $limit * $page ; @@ -57,89 +49,81 @@ print "Liste"; print "[Nouveau service]"; print ''; -/* - * Fiche - * - */ -if ($rowid) { - - $sql = "SELECT p.rowid, p.label, p.price, p.description, p.duration,p.ref FROM llx_product as p"; - $sql .= " WHERE p.rowid = $rowid;"; - - - if ( $db->query($sql) ) { - $num = $db->num_rows(); - $i = 0; - print "

"; - print ""; - print ""; - print ""; - print "\n"; - $var=True; - if ( $num ) { - $objp = $db->fetch_object(0); - $var=!$var; - print ""; - print "\n"; - print "\n"; - print "\n"; - print "\n"; - - print ""; - $i++; - } - print "
RéfNom
rowid\">$objp->ref$objp->label
prix$objp->price
duree$objp->duration
desc".nl2br($objp->description)."
"; - $db->free(); - - print "


\n"; - print ""; - print "
"; - print ""; - print "
"; - } - /* * * Liste * */ -} else { +$now = strftime ("%Y-%m-%d %H:%M", time()); - $sql = "SELECT p.rowid, p.label, p.price, p.duration,p.ref FROM llx_product as p"; - - $sql .= " ORDER BY $sortfield $sortorder "; - $sql .= $db->plimit( $limit ,$offset); +$sql = "SELECT p.rowid, p.label, p.price, p.duration,p.ref FROM llx_service as p"; +$sql .= " WHERE p.fin_comm >= '$now'"; +$sql .= " ORDER BY $sortfield $sortorder "; +$sql .= $db->plimit( $limit ,$offset); - if ( $db->query($sql) ) { - $num = $db->num_rows(); - $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 ''; - print "\n"; - print "\n"; - $i++; - } - print "
RéfNomPrixDurée
rowid\">$objp->ref$objp->label'.price($objp->price).'$objp->duration
"; - $db->free(); - } - +if ( $db->query($sql) ) { + $num = $db->num_rows(); + $i = 0; + print "

"; + print ""; + print ""; + print ""; + print ""; + print "\n"; + $var=True; + while ($i < $num) { + $objp = $db->fetch_object( $i); + $var=!$var; + print ""; + print "\n"; + print "\n"; + print ''; + print "\n"; + $i++; + } + print "
RéfNomPrix
rowid\">$objp->ref$objp->label'.price($objp->price).'
"; + $db->free(); +} else { + print $this->db->error() . ' in ' . $sql; } + + +$sql = "SELECT p.rowid, p.label, p.fin_comm, p.price, p.duration,p.ref FROM llx_service as p"; +$sql .= " WHERE p.fin_comm < '$now'"; +$sql .= " ORDER BY $sortfield $sortorder "; +$sql .= $db->plimit( $limit ,$offset); + +if ( $db->query($sql) ) { + $num = $db->num_rows(); + $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 ''; + print "\n"; + print "\n"; + $i++; + } + print "
RéfNomPrixFin
rowid\">$objp->ref$objp->label'.price($objp->price).'$objp->fin_comm
"; + $db->free(); +} else { + print $this->db->error() . ' in ' . $sql; +} + + + $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); diff --git a/htdocs/service/pre.inc.php3 b/htdocs/service/pre.inc.php3 index d146ea3ce35..66adfbffe2e 100644 --- a/htdocs/service/pre.inc.php3 +++ b/htdocs/service/pre.inc.php3 @@ -50,7 +50,7 @@ function llxHeader($head = "", $urlp = "") { print ""; print ""; - print "

Societe
\n"; + print "
Societe
\n"; print "Contact
\n"; print ""; @@ -62,20 +62,13 @@ function llxHeader($head = "", $urlp = "") { * */ print ""; - print '
Propal
'; + print "
Produits
\n"; print ""; - /* - * - */ - print ""; - print '
Factures
'; - print ""; - /* - * - */ - print ""; - print "Projets
\n"; - print ""; + + print ''; + print '
Services

'; + print 'Nouveau service'; + print ''; print ""; print "
Societes
\n"; @@ -109,14 +102,6 @@ function llxHeader($head = "", $urlp = "") { print "\n"; } -function llxFooter($foot='') { - print ""; - /* - * - */ - print "\n"; - print "$foot"; -} /* * $Id$ * $Source$ diff --git a/mysql/data/data_dev.sql b/mysql/data/data_dev.sql new file mode 100644 index 00000000000..bf5c36e0354 --- /dev/null +++ b/mysql/data/data_dev.sql @@ -0,0 +1,46 @@ +-- +-- Copyright (C) 2001-2002 Rodolphe Quiedeville +-- +-- $Id$ +-- $Source$ +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +-- +-- +-- Valeurs pour les bases de langues francaises +-- + +delete from llx_user; +insert into llx_user (name,firstname,code,login,pass,module_comm,module_compta) +values ('Quiedeville','Rodolphe','RQ','rodo','rodo',1,1); + +insert into llx_user (name,firstname,code,login,pass,module_comm,module_compta) +values ('demo','demo','demo','demo','demo',1,1); + +delete from societe; +insert into societe (nom,datec,cp,ville,tel,fax, client) +values ('Lolix',now(),'75001','Paris','01 40 15 03 18','01 40 15 06 18',1); + +insert into societe (nom,cp,ville,tel,fax,client) +values ('Easter-Eggs','75013','Paris','01 55 55 03 18','01 55 55 55 55',1); + +insert into societe (nom,cp,ville,tel,fax,fournisseur) +values ('JPG','75013','Paris','01 55 55 03 18','01 55 55 55 55',1); + +insert into llx_product (ref, label, description, price, duration) +values ('CC-2M','Compilo','Compilateur GCC',10,'1 mois'); + +insert into llx_product (ref, label, description, price, duration) +values ('CC-2M','Config Alpha','Configurations a base de proc alpha',1000,'1 mois'); \ No newline at end of file diff --git a/mysql/tables/llx_product.sql b/mysql/tables/llx_product.sql index a87ed961e98..a5cdae5351f 100644 --- a/mysql/tables/llx_product.sql +++ b/mysql/tables/llx_product.sql @@ -1,6 +1,24 @@ -- =================================================================== -- $Id$ -- $Source$ +-- +-- $Id$ +-- $Source$ +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +-- -- =================================================================== create table llx_product diff --git a/mysql/tables/llx_service.sql b/mysql/tables/llx_service.sql index 724630e6f58..a072ad98c3f 100644 --- a/mysql/tables/llx_service.sql +++ b/mysql/tables/llx_service.sql @@ -32,6 +32,10 @@ create table llx_service price smallint, duration varchar(32), debut_comm datetime, - fin_comm datetime + fin_comm datetime, + fk_user_auhtor integer, + fk_user_modif integer, + + UNIQUE INDEX(ref) );