From 176263110828b1fe22191330d3744585de22a72c Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 22 Mar 2006 17:52:12 +0000 Subject: [PATCH] Ajout du patch Jean concernant OSCommerce --- htdocs/boutique/index.php | 270 ++++++++++++++++++ htdocs/boutique/pre.inc.php | 21 +- htdocs/boutique/produits/index.php | 83 ++++++ htdocs/boutique/produits/osc-liste.php | 91 ++++++ htdocs/boutique/produits/pre.inc.php | 53 ++++ htdocs/includes/menus/barre_top/default.php | 17 ++ .../menus/barre_top/eldy_backoffice.php | 18 ++ htdocs/langs/en_US/shop.lang | 7 + htdocs/langs/fr_FR/shop.lang | 7 + htdocs/pre.inc.php | 2 + 10 files changed, 564 insertions(+), 5 deletions(-) create mode 100644 htdocs/boutique/index.php create mode 100644 htdocs/boutique/produits/index.php create mode 100644 htdocs/boutique/produits/osc-liste.php create mode 100644 htdocs/boutique/produits/pre.inc.php create mode 100644 htdocs/langs/en_US/shop.lang create mode 100644 htdocs/langs/fr_FR/shop.lang diff --git a/htdocs/boutique/index.php b/htdocs/boutique/index.php new file mode 100644 index 00000000000..12cb158eb07 --- /dev/null +++ b/htdocs/boutique/index.php @@ -0,0 +1,270 @@ + + * Copyright (C) 2004 Laurent Destailleur + * + * 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. + * + * $Id$ + * $Source$ + * + */ + +/** + \file htdocs/boutique/index.php + \ingroup boutique + \brief Page accueil zone boutique + \version $Revision$ +*/ + +require("./pre.inc.php"); + +$langs->load("boutique"); + + +llxHeader("",$langs->trans("Orders"),"Commande"); + +print_titre($langs->trans("BoutiqueWeb")); + +print ''; + +print ''; +/* +* Derniers clients qui ont commandé +*/ +$sql = "SELECT o.orders_id, o.customers_name, o.delivery_country, o.date_purchased, t.value, s.orders_status_name as statut"; +$sql .= " FROM ".OSC_DB_NAME.".orders_total as t JOIN ".OSC_DB_NAME.".orders as o on o.orders_id = t.orders_id "; +$sql .= " JOIN ".OSC_DB_NAME.".orders_status as s on o.orders_status = s.orders_status_id and s.language_id = 1"; +$sql .= " WHERE t.class = 'ot_subtotal' order by o.date_purchased desc"; + +if ( $db->query($sql) ) +{ + $langs->load("orders"); + $num = $db->num_rows(); + if ($num > 0) + { + $i = 0; + print '
'; + + +/* +/* Chiffre d'affaire +*/ +//print_barre_liste("Chiffre d'affaire", $page, "ca.php"); + +print_titre($langs->trans("Chiffre d'affaire")); + +print ''; +print ''; +print ''; + +$sql = "SELECT sum(t.value) as value, MONTH(o.date_purchased) as mois"; +$sql .= " FROM ".OSC_DB_NAME.".orders_total as t"; +$sql .= " JOIN ".OSC_DB_NAME.".orders as o ON o.orders_id = t.orders_id"; +$sql .= " WHERE t.class = 'ot_subtotal' AND YEAR(o.date_purchased) = YEAR(now()) "; +$sql .= " GROUP BY mois ORDER BY mois"; + +if ( $db->query($sql) ) +{ + $num = $db->num_rows(); + + $var=True; + $i=0; + if ($num > 0) + { + while ($i < $num) + { + $objp = $db->fetch_object(); + $var=!$var; + print ""; + print ''; + print ''; + + print "\n"; + $i++; + } + } + + $db->free(); +} +else +{ + dolibarr_print_error($db); +} + +/* mensuel + +$sql = "SELECT sum(t.value) as value"; +$sql .= " FROM ".OSC_DB_NAME.".orders_total as t"; +$sql .= " JOIN ".OSC_DB_NAME.".orders as o ON o.orders_id = t.orders_id"; +$sql .= " WHERE t.class = 'ot_subtotal' AND YEAR(o.date_purchased) = YEAR(now()) AND MONTH(o.date_purchased) = MONTH(now())"; + +if ( $db->query($sql) ) +{ + $num = $db->num_rows(); + + $var=True; + if ($num > 0) + { + $objp = $db->fetch_object(); + $var=!$var; + print ""; + print ''; + print ''; + $i++; + } + + $db->free(); +} +else +{ + dolibarr_print_error($db); +} +*/ + +print "
'.$langs->trans("Description").''.$langs->trans("Total").'
'.$objp->mois.''.price($objp->value).'
CA du mois en cours '.price($objp->value).'
"; +print '
'; +print_titre($langs->trans("Commandes")); + +/* + * 5 dernières commandes reçues + select o.orders_id, o.customers_id, o.customers_name, o.date_purchased, o.payement_method, o.status, t.value +from orders_total as t +join orders as o on o.orders_id = t.orders_id where t.class = 'ot_subtotal' order by o.date_purchased desc + */ +$sql = "SELECT o.orders_id, o.customers_name, o.date_purchased, t.value, o.payment_method"; +$sql .= " FROM ".OSC_DB_NAME.".orders_total as t JOIN ".OSC_DB_NAME.".orders as o on o.orders_id = t.orders_id "; +$sql .= " WHERE t.class = 'ot_subtotal' ORDER BY o.date_purchased desc"; + +if ( $db->query($sql) ) +{ + $langs->load("orders"); + $num = $db->num_rows(); + if ($num > 0) + { + $i = 0; + print ''; + print ''; + print ''; + + $num = min($num,OSC_MAXNBCOM); + while ($i < $num) + { + + $obj = $db->fetch_object(); + print ""; + $i++; + } + print "
'.$langs->trans("Dernières commandes").'
$obj->orders_id$obj->customers_name".price($obj->value)."$obj->payment_method

"; + } +} +else +{ + dolibarr_print_error($db); +} + +/* + * 5 dernières commandes en attente +*/ +$sql = "SELECT o.orders_id, o.customers_name, o.date_purchased, t.value, o.payment_method"; +$sql .= " FROM ".OSC_DB_NAME.".orders_total as t JOIN ".OSC_DB_NAME.".orders as o on o.orders_id = t.orders_id "; +$sql .= " WHERE t.class = 'ot_subtotal' and o.orders_status = 5 order by o.date_purchased desc"; + +if ( $db->query($sql) ) +{ + $langs->load("orders"); + $num = $db->num_rows(); + if ($num > 0) + { + $i = 0; + print ''; + print ''; + print ''; + + $num = min($num,OSC_MAXNBCOM); + while ($i < $num) + { + + $obj = $db->fetch_object(); + print ""; + $i++; + } + print "
'.$langs->trans("En Attente").'
$obj->orders_id$obj->customers_name".price($obj->value)."$obj->payment_method

"; + } +} +else +{ + dolibarr_print_error($db); +} + +/* + * Commandes à traiter + */ +$sql = "SELECT o.orders_id, o.customers_name, o.date_purchased, t.value, o.payment_method"; +$sql .= " FROM ".OSC_DB_NAME.".orders_total as t JOIN ".OSC_DB_NAME.".orders as o on o.orders_id = t.orders_id "; +$sql .= " WHERE t.class = 'ot_subtotal' and o.orders_status = 2 order by o.date_purchased desc"; + +if ( $db->query($sql) ) +{ + $langs->load("orders"); + $num = $db->num_rows(); + if ($num > 0) + { + $i = 0; + print ''; + print ''; + print ''; + + $num = min($num,OSC_MAXNBCOM); + while ($i < $num) + { + + $obj = $db->fetch_object(); + print ""; + $i++; + } + print "
'.$langs->trans("Traitement en cours").'
$obj->orders_id$obj->customers_name".price($obj->value)."$obj->payment_method

"; + } +} +else +{ + dolibarr_print_error($db); +} + + +print '
'; + print ''; + print ''; + + $num = min($num,OSC_MAXNBCOM); + while ($i < $num) + { + + $obj = $db->fetch_object(); + print ""; + $i++; + } + print "
'.$langs->trans("Derniers clients").'
$obj->date_purchased$obj->customers_name$obj->delivery_country".price($obj->value)."$obj->payment_method$obj->orders_id$obj->statut

"; + } +} +else +{ + dolibarr_print_error($db); +} +print ''; + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/boutique/pre.inc.php b/htdocs/boutique/pre.inc.php index ee084a94984..00b6cf597e4 100644 --- a/htdocs/boutique/pre.inc.php +++ b/htdocs/boutique/pre.inc.php @@ -20,11 +20,14 @@ * */ require("../main.inc.php"); -require("./livre/livre.class.php"); -require("./editeur/editeur.class.php"); -require("./auteur/auteur.class.php"); +//require("./livre/livre.class.php"); +//require("./editeur/editeur.class.php"); +//require("./auteur/auteur.class.php"); require("../product/categorie/categorie.class.php"); +//affichages dans la page d'accueil +define("OSC_MAXNBCOM", 5); + function llxHeader($head = "", $urlp = "") { global $user, $conf; @@ -36,7 +39,7 @@ function llxHeader($head = "", $urlp = "") top_menu($head); $menu = new Menu(); - +/* $menu->add(DOL_URL_ROOT."/boutique/livre/", "Livres"); $menu->add_submenu(DOL_URL_ROOT."/boutique/livre/fiche.php?&action=create","Nouvel ouvrage"); @@ -50,7 +53,15 @@ function llxHeader($head = "", $urlp = "") $menu->add(DOL_URL_ROOT."/boutique/editeur/", "Editeurs"); $menu->add_submenu(DOL_URL_ROOT."/boutique/editeur/fiche.php?&action=create","Nouvel éditeur"); +*/ + $menu->add(DOL_URL_ROOT."/boutique/produits/osc-liste.php", "Produits"); + + $menu->add(DOL_URL_ROOT."/boutique/commande/", "Commandes"); + + $menu->add(DOL_URL_ROOT."/boutique/client/", "Clients"); + +/* $menu->add(DOL_URL_ROOT."/product/categorie/", "Catégories"); $menu->add(DOL_URL_ROOT."/product/promotion/", "Promotions"); @@ -59,7 +70,7 @@ function llxHeader($head = "", $urlp = "") { $menu->add(DOL_URL_ROOT."/postnuke/articles/", "Editorial"); } - +*/ left_menu($menu->liste); } ?> diff --git a/htdocs/boutique/produits/index.php b/htdocs/boutique/produits/index.php new file mode 100644 index 00000000000..a462421a7ce --- /dev/null +++ b/htdocs/boutique/produits/index.php @@ -0,0 +1,83 @@ + + * Copyright (C) 2004 Laurent Destailleur + * + * 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. + * + * $Id$ + * $Source$ + * + */ + +require("./pre.inc.php"); + +$langs->load("companies"); + +llxHeader(); + +if ($sortfield == "") { + $sortfield="lower(c.customers_lastname)"; +} +if ($sortorder == "") { + $sortorder="ASC"; +} + + +if ($page == -1) { $page = 0 ; } +$limit = $conf->liste_limit; +$offset = $limit * $page ; + +print_barre_liste("Liste des clients", $page, "index.php"); + +$sql = "SELECT c.customers_id, c.customers_lastname, c.customers_firstname, c.customers_email_address, c.customers_newsletter"; +$sql .= " FROM ".DB_NAME_OSC.".customers as c"; +$sql .= " ORDER BY $sortfield $sortorder "; +$sql .= $db->plimit( $limit ,$offset); + +if ( $db->query($sql) ) +{ + $num = $db->num_rows(); + $i = 0; + print ""; + print ""; + print_liste_field_titre($langs->trans("Firstname"),"index.php", "c.customers_firstname"); + print_liste_field_titre($langs->trans("Lastname"),"index.php", "c.customers_lastname"); + print ''; + print "\n"; + $var=True; + while ($i < $num) + { + $objp = $db->fetch_object(); + $var=!$var; + print ""; + print '\n"; + print '\n"; + print "\n"; + print "\n"; + print "\n"; + $i++; + } + print "
'.$langs->trans("EMail").''.$langs->trans("Newsletter").'
'.$objp->customers_firstname."'.$objp->customers_lastname."$objp->customers_email_address$objp->customers_newsletter
"; + $db->free(); +} +else +{ + dolibarr_print_error($db); +} + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/boutique/produits/osc-liste.php b/htdocs/boutique/produits/osc-liste.php new file mode 100644 index 00000000000..d5f4ebe079c --- /dev/null +++ b/htdocs/boutique/produits/osc-liste.php @@ -0,0 +1,91 @@ + + * + * 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. + * + * $Id$ + * $Source$ + * + */ + +require("./pre.inc.php"); + +llxHeader(); + +if ($sortfield == "") { + $sortfield="lower(p.label),p.price"; +} +if ($sortorder == "") { + $sortorder="ASC"; +} + + +if ($page == -1) { $page = 0 ; } +$limit = $conf->liste_limit; +$offset = $limit * $page ; + + +print_barre_liste("Liste des produits oscommerce", $page, "osc-liste.php"); + +$sql = "SELECT p.products_id, p.products_model, p.products_quantity, p.products_status, d.products_name, m.manufacturers_name, m.manufacturers_id"; +$sql .= " FROM ".OSC_DB_NAME.".products as p, ".OSC_DB_NAME.".products_description as d, ".OSC_DB_NAME.".manufacturers as m"; +$sql .= " WHERE p.products_id = d.products_id AND d.language_id =" . OSC_LANGUAGE_ID; +$sql .= " AND p.manufacturers_id=m.manufacturers_id"; +if ($reqstock=='epuise') +{ + $sql .= " AND p.products_quantity <= 0"; +} + +//$sql .= " ORDER BY $sortfield $sortorder "; +$sql .= $db->plimit( $limit ,$offset); + +print "

"; +print ''; +print ""; +print ""; +print ""; +print ""; +print ''; +print ''; + print "\n"; + +if ( $db->query($sql) ) { + $num = $db->num_rows(); + $i = 0; + + $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"; + print "\n"; + $i++; + } + $db->free(); +} + +print "
idRefTitreGroupeStockStatus
$objp->products_id$objp->products_model$objp->products_name$objp->manufacturers_name'.$objp->products_quantity."'.$objp->products_status."
"; + + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/boutique/produits/pre.inc.php b/htdocs/boutique/produits/pre.inc.php new file mode 100644 index 00000000000..8c2382d1b85 --- /dev/null +++ b/htdocs/boutique/produits/pre.inc.php @@ -0,0 +1,53 @@ + + * + * 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. + * + * $Id$ + * $Source$ + * + */ +require("../../main.inc.php"); +require("../../product/categorie/categorie.class.php"); + +function llxHeader($head = "", $urlp = "") +{ + global $user, $conf; + + /* + * + * + */ + top_menu($head); + + $menu = new Menu(); + $menu->add(DOL_URL_ROOT."/boutique/produits/osc-liste.php", "Produits"); + + $menu->add(DOL_URL_ROOT."/boutique/client/", "Clients"); + + $menu->add(DOL_URL_ROOT."/boutique/commande/", "Commandes"); + +/* $menu->add(DOL_URL_ROOT."/product/categorie/", "Catégories"); + + $menu->add(DOL_URL_ROOT."/product/promotion/", "Promotions"); + + if (defined("MAIN_MODULE_POSTNUKE") && MAIN_MODULE_POSTNUKE) + { + $menu->add(DOL_URL_ROOT."/postnuke/articles/", "Editorial"); + } +*/ + left_menu($menu->liste); +} +?> diff --git a/htdocs/includes/menus/barre_top/default.php b/htdocs/includes/menus/barre_top/default.php index 5fd3d90a035..f3df3c22d49 100644 --- a/htdocs/includes/menus/barre_top/default.php +++ b/htdocs/includes/menus/barre_top/default.php @@ -272,6 +272,23 @@ class MenuTop { print 'atarget?" target=$this->atarget":"").'>'.$langs->trans("Energy").''; } + + // Entrée boutique + if ($conf->boutique->enabled) + { + $langs->load("shop"); + $class=""; + if (ereg("^".DOL_URL_ROOT."\/energie\/",$_SERVER["PHP_SELF"])) + { + $class='class="tmenu" id="sel"'; + } + else + { + $class = 'class="tmenu"'; + } + + print 'atarget?" target=$this->atarget":"").'>'.$langs->trans("Shop").''; + } // Entrée webcal if ($conf->webcal->enabled) diff --git a/htdocs/includes/menus/barre_top/eldy_backoffice.php b/htdocs/includes/menus/barre_top/eldy_backoffice.php index 6394cccbdde..8eecf9d360e 100644 --- a/htdocs/includes/menus/barre_top/eldy_backoffice.php +++ b/htdocs/includes/menus/barre_top/eldy_backoffice.php @@ -230,6 +230,24 @@ class MenuTop { print 'atarget?" target=$this->atarget":"").'>'.$langs->trans("Tools").''; } + // Projets + if ($conf->boutique->enabled) + { + $langs->load("shop"); + + $class=""; + if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "shop") + { + $class='class="tmenu" id="sel"'; + } + else + { + $class = 'class="tmenu"'; + } + + print 'atarget?" target=$this->atarget":"").'>'.$langs->trans("Shop").''; + } + // Webcal if ($conf->webcal->enabled) { diff --git a/htdocs/langs/en_US/shop.lang b/htdocs/langs/en_US/shop.lang new file mode 100644 index 00000000000..5acdbac5025 --- /dev/null +++ b/htdocs/langs/en_US/shop.lang @@ -0,0 +1,7 @@ +# Dolibarr language file - en_US - shop +Shop=Shop +ShopWeb=Web Shop +LastOrders=Last orders +OnStandBy=On standby +TreatmentInProgress=Treatment in progress +LastCustomers=Last customers \ No newline at end of file diff --git a/htdocs/langs/fr_FR/shop.lang b/htdocs/langs/fr_FR/shop.lang new file mode 100644 index 00000000000..849d91f161a --- /dev/null +++ b/htdocs/langs/fr_FR/shop.lang @@ -0,0 +1,7 @@ +# Dolibarr language file - fr_FR - shop +Shop=Boutique +ShopWeb=Boutique Web +LastOrders=Dernières commandes +OnStandBy=En attente +TreatmentInProgress=Traitement en cours +LastCustomers=Dernier clients \ No newline at end of file diff --git a/htdocs/pre.inc.php b/htdocs/pre.inc.php index d884e2a461b..a2b34f64a43 100644 --- a/htdocs/pre.inc.php +++ b/htdocs/pre.inc.php @@ -97,6 +97,7 @@ function llxHeader($head = "") { if ($conf->service->enabled) { $chaine.= $langs->trans("Services"); } $menu->add(DOL_URL_ROOT."/product/index.php", "$chaine"); +/* if ($conf->boutique->enabled) { if ($conf->boutique->livre->enabled) @@ -110,6 +111,7 @@ function llxHeader($head = "") { } } } +*/ if ($conf->commande->enabled && $user->rights->commande->lire) {