Fix: Avoid class name conflict

This commit is contained in:
Laurent Destailleur 2010-04-27 08:17:40 +00:00
parent 009b251d52
commit 630d932d5b
2 changed files with 88 additions and 84 deletions

View File

@ -27,18 +27,18 @@
*/ */
/** /**
* \class Client * \class BoutiqueClient
* \brief Classe permettant de gerer des clients de la boutique online * \brief Classe permettant de gerer des clients de la boutique online
*/ */
class Client class BoutiqueClient
{ {
var $db ; var $db ;
var $id ; var $id ;
var $nom; var $nom;
function Client($DB, $id=0) function BoutiqueClient($DB, $id=0)
{ {
$this->db = $DB; $this->db = $DB;
$this->id = $id ; $this->id = $id ;
@ -52,25 +52,24 @@ class Client
{ {
global $conf; 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) ; $resql = $this->db->query($sql) ;
if ( $resql )
if ( $result )
{ {
$result = $this->db->fetch_array(); $result = $this->db->fetch_array($resql);
$this->id = $result["customers_id"]; $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 else
{ {
print $this->db->error(); print $this->db->error();
return -1;
} }
return $result;
} }
} }

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003-2005 <EFBFBD>ric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2003-2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2006-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -21,36 +21,42 @@
*/ */
/** /**
\file htdocs/boutique/client/fiche.php * \file htdocs/boutique/client/fiche.php
\ingroup boutique * \ingroup boutique
\brief Page fiche client OSCommerce * \brief Page fiche client OSCommerce
\version $Revision$ * \version $Revision$
*/ */
require("../../main.inc.php"); require("../../main.inc.php");
include_once(DOL_DOCUMENT_ROOT.'/boutique/client/client.class.php');
/*
* Actions
*/
llxHeader(); if ($action == 'update' && !$cancel)
{
if ($action == 'update' && !$cancel) { $client = new BoutiqueClient($dbosc);
$client = new Client($dbosc);
$client->nom = $nom; $client->nom = $nom;
$client->update($id, $user); $client->update($id, $user);
} }
/* /*
* * View
*
*/ */
llxHeader();
if ($_GET['id']) if ($_GET['id'])
{ {
$client = new BoutiqueClient($dbosc);
$client = new Client($dbosc);
$result = $client->fetch($_GET['id']); $result = $client->fetch($_GET['id']);
if ( $result ) if ( $result )
{ {
print '<div class="titre">Fiche Client : '.$client->name.'</div><br>'; print '<div class="titre">'.$langs->trans("CustomerCard").': '.$client->name.'</div><br>';
print '<table border="1" width="100%" cellspacing="0" cellpadding="4">'; print '<table border="1" width="100%" cellspacing="0" cellpadding="4">';
print "<tr>"; print "<tr>";
@ -60,23 +66,24 @@ if ($_GET['id'])
/* /*
* Commandes * Commandes
*
*/ */
$sql = "SELECT o.orders_id, o.customers_id,".$dbosc->pdate("date_purchased")." as date_purchased, t.value as total"; $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 .= " 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 .= " WHERE o.customers_id = " . $_GET['id'];
$sql .= " AND o.orders_id = t.orders_id AND t.class = 'ot_total'"; $sql .= " AND o.orders_id = t.orders_id AND t.class = 'ot_total'";
//echo $sql; //echo $sql;
if ( $dbosc->query($sql) ) $resql=$dbosc->query($sql);
if ($resql)
{ {
$num = $dbosc->num_rows(); $num = $dbosc->num_rows($resql);
$i = 0; $i = 0;
print '<table class="noborder" width="50%">'; print '<table class="noborder" width="50%">';
print "<tr class=\"liste_titre\"><td>Commandes</td>"; print "<tr class=\"liste_titre\"><td>Commandes</td>";
print "</tr>\n"; print "</tr>\n";
$var=True; $var=True;
while ($i < $num) { while ($i < $num)
$objp = $dbosc->fetch_object(); {
$objp = $dbosc->fetch_object($resql);
$var=!$var; $var=!$var;
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
@ -88,7 +95,7 @@ if ($_GET['id'])
$i++; $i++;
} }
print "</table>"; print "</table>";
$dbosc->free(); $dbosc->free($resql);
} }
else else
{ {
@ -102,8 +109,6 @@ if ($_GET['id'])
print "<p>ERROR 1</p>\n"; print "<p>ERROR 1</p>\n";
dol_print_error($dbosc); dol_print_error($dbosc);
} }
} }
else else
{ {