diff --git a/htdocs/boutique/client/class/client.class.php b/htdocs/boutique/client/class/client.class.php index 5f85cef7601..5c00b14295d 100644 --- a/htdocs/boutique/client/class/client.class.php +++ b/htdocs/boutique/client/class/client.class.php @@ -27,18 +27,18 @@ */ /** - * \class Client + * \class BoutiqueClient * \brief Classe permettant de gerer des clients de la boutique online */ -class Client +class BoutiqueClient { var $db ; var $id ; var $nom; - function Client($DB, $id=0) + function BoutiqueClient($DB, $id=0) { $this->db = $DB; $this->id = $id ; @@ -52,25 +52,24 @@ class Client { global $conf; - $sql = "SELECT customers_id, customers_lastname, customers_firstname FROM ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."customers WHERE customers_id = $id"; + $sql = "SELECT customers_id, customers_lastname, customers_firstname FROM ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."customers WHERE customers_id = ".$id; - $result = $this->db->query($sql) ; - - if ( $result ) + $resql = $this->db->query($sql) ; + if ( $resql ) { - $result = $this->db->fetch_array(); + $result = $this->db->fetch_array($resql); $this->id = $result["customers_id"]; - $this->name = stripslashes($result["customers_firstname"]) . " " . stripslashes($result["customers_lastname"]); + $this->name = $result["customers_firstname"] . " " . $result["customers_lastname"]; - $this->db->free(); + $this->db->free($resql); + return 1; } else { print $this->db->error(); + return -1; } - - return $result; } } diff --git a/htdocs/boutique/client/fiche.php b/htdocs/boutique/client/fiche.php index b7ccd21111c..869a062bd84 100644 --- a/htdocs/boutique/client/fiche.php +++ b/htdocs/boutique/client/fiche.php @@ -1,7 +1,7 @@ - * Copyright (C) 2003-2005 �ric Seigne - * Copyright (C) 2006 Laurent Destailleur + * Copyright (C) 2003-2005 Eric Seigne + * Copyright (C) 2006-2010 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 @@ -21,94 +21,99 @@ */ /** - \file htdocs/boutique/client/fiche.php - \ingroup boutique - \brief Page fiche client OSCommerce - \version $Revision$ -*/ + * \file htdocs/boutique/client/fiche.php + * \ingroup boutique + * \brief Page fiche client OSCommerce + * \version $Revision$ + */ require("../../main.inc.php"); +include_once(DOL_DOCUMENT_ROOT.'/boutique/client/client.class.php'); +/* + * Actions + */ + +if ($action == 'update' && !$cancel) +{ + $client = new BoutiqueClient($dbosc); + $client->nom = $nom; + $client->update($id, $user); +} + + + +/* + * View + */ llxHeader(); -if ($action == 'update' && !$cancel) { - $client = new Client($dbosc); - $client->nom = $nom; - $client->update($id, $user); -} - -/* - * - * - */ if ($_GET['id']) { - - $client = new Client($dbosc); - $result = $client->fetch($_GET['id']); - if ( $result ) - { - print '
Fiche Client : '.$client->name.'

'; - - print ''; - print ""; - print ''; - print "
Nom'.$client->name.'
"; - - - /* - * Commandes - * - */ - $sql = "SELECT o.orders_id, o.customers_id,".$dbosc->pdate("date_purchased")." as date_purchased, t.value as total"; - $sql .= " FROM ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."orders as o, ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."orders_total as t"; - $sql .= " WHERE o.customers_id = " . $_GET['id']; - $sql .= " AND o.orders_id = t.orders_id AND t.class = 'ot_total'"; - //echo $sql; - if ( $dbosc->query($sql) ) + $client = new BoutiqueClient($dbosc); + $result = $client->fetch($_GET['id']); + if ( $result ) { - $num = $dbosc->num_rows(); - $i = 0; - print ''; - print ""; - print "\n"; - $var=True; - while ($i < $num) { - $objp = $dbosc->fetch_object(); - $var=!$var; - print ""; + print '
'.$langs->trans("CustomerCard").': '.$client->name.'

'; - print '\n"; - print "\n"; - $i++; - } - print "
Commandes
Fiche '; + print ''; + print ""; + print ''; + print "
Nom'.$client->name.'
"; + + + /* + * Commandes + */ + $sql = "SELECT o.orders_id, o.customers_id,".$dbosc->pdate("date_purchased")." as date_purchased, t.value as total"; + $sql .= " FROM ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."orders as o, ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."orders_total as t"; + $sql .= " WHERE o.customers_id = " . $_GET['id']; + $sql .= " AND o.orders_id = t.orders_id AND t.class = 'ot_total'"; + //echo $sql; + $resql=$dbosc->query($sql); + if ($resql) + { + $num = $dbosc->num_rows($resql); + $i = 0; + print ''; + print ""; + print "\n"; + $var=True; + while ($i < $num) + { + $objp = $dbosc->fetch_object($resql); + $var=!$var; + print ""; + + print '\n"; + print "\n"; + $i++; + } + print "
Commandes
Fiche '; + + print dol_print_date($objp->date_purchased,'dayhour')."\n"; + print $objp->total . "
"; + $dbosc->free($resql); + } + else + { + print "

ERROR 1

\n"; + dol_print_error($dbosc); + } - print dol_print_date($objp->date_purchased,'dayhour')."
\n"; - print $objp->total . "
"; - $dbosc->free(); } - else + else { - print "

ERROR 1

\n"; - dol_print_error($dbosc); + print "

ERROR 1

\n"; + dol_print_error($dbosc); } - - } - else - { - print "

ERROR 1

\n"; - dol_print_error($dbosc); - } - - } else { - print "

ERROR 1

\n"; - print "Error"; + print "

ERROR 1

\n"; + print "Error"; }