Quick Search:

View

Revision:

Diff

Diff from 1 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/osCommerce/trunk/oscommerce/includes/classes/customer.php

Annotated File View

hpdl
1
1 <?php
2 /*
3   $Id: customer.php,v 1.3 2004/05/17 01:03:28 hpdl Exp $
4
5   osCommerce, Open Source E-Commerce Solutions
6   http://www.oscommerce.com
7
8   Copyright (c) 2004 osCommerce
9
10   Released under the GNU General Public License
11 */
12
13   class osC_Customer {
14     var $is_logged_on,
15         $id,
16         $gender,
17         $first_name,
18         $last_name,
19         $full_name,
20         $email_address,
21         $default_address_id,
22         $country_id,
23         $zone_id;
24
25 // class constructor
26     function osC_Customer() {
27       $this->setIsLoggedOn(false);
28     }
29
30 // class methods
31     function setCustomerData($customer_id = -1) {
32       if (is_numeric($customer_id) && ($customer_id > 0)) {
33         global $osC_Database;
34
35         $Qcustomer = $osC_Database->query('select customers_gender, customers_firstname, customers_lastname, customers_email_address, customers_default_address_id from :table_customers where customers_id = :customers_id');
36         $Qcustomer->bindRaw(':table_customers', TABLE_CUSTOMERS);
37         $Qcustomer->bindInt(':customers_id', $customer_id);
38         $Qcustomer->execute();
39
40         if ($Qcustomer->numberOfRows() === 1) {
41           $this->setIsLoggedOn(true);
42           $this->setID($customer_id);
43           $this->setGender($Qcustomer->value('customers_gender'));
44           $this->setFirstName($Qcustomer->value('customers_firstname'));
45           $this->setLastName($Qcustomer->value('customers_lastname'));
46           $this->setFullName();
47           $this->setEmailAddress($Qcustomer->value('customers_email_address'));
48
49           if (is_numeric($Qcustomer->value('customers_default_address_id')) && ($Qcustomer->value('customers_default_address_id') > 0)) {
50             $Qab = $osC_Database->query('select entry_country_id, entry_zone_id from :table_address_book where address_book_id = :address_book_id and customers_id = :customers_id');
51             $Qab->bindRaw(':table_address_book', TABLE_ADDRESS_BOOK);
52             $Qab->bindInt(':address_book_id', $Qcustomer->value('customers_default_address_id'));
53             $Qab->bindInt(':customers_id', $customer_id);
54             $Qab->execute();
55
56             if ($Qab->numberOfRows() === 1) {
57               $this->setCountryID($Qab->value('entry_country_id'));
58               $this->setZoneID($Qab->value('entry_zone_id'));
59               $this->setDefaultAddressID($Qcustomer->value('customers_default_address_id'));
60
61               $Qab->freeResult();
62             }
63           }
64         }
65
66         $Qcustomer->freeResult();
67       }
68     }
69
70     function setIsLoggedOn($state) {
71       if ($state === true) {
72         $this->is_logged_on = true;
73       } else {
74         $this->is_logged_on = false;
75       }
76     }
77
78     function isLoggedOn() {
79       if ($this->is_logged_on === true) {
80         return true;
81       }
82
83       return false;
84     }
85
86     function isGuest() {
87       return !$this->isLoggedOn();
88     }
89
90     function setID($id) {
91       $this->id = $id;
92     }
93
94     function setDefaultAddressID($id) {
95       $this->default_address_id = $id;
96     }
97
98     function hasDefaultAddress() {
99       if (is_numeric($this->default_address_id) && ($this->default_address_id > 0)) {
100         return true;
101       } else {
102         return false;
103       }
104     }
105
106     function setGender($gender) {
107       $this->gender = $gender;
108     }
109
110     function setFirstName($firstname) {
111       $this->first_name = $firstname;
112     }
113
114     function setLastName($lastname) {
115       $this->last_name = $lastname;
116     }
117
118     function setFullName($fullname = '') {
119       if (empty($fullname)) {
120         $this->full_name = $this->first_name . ' ' . $this->last_name;
121       } else {
122         $this->full_name = $fullname;
123       }
124     }
125
126     function setEmailAddress($email_address) {
127       $this->email_address = $email_address;
128     }
129
130     function setCountryID($id) {
131       $this->country_id = $id;
132     }
133
134     function setZoneID($id) {
135       $this->zone_id = $id;
136     }
137   }
138 ?>