PageRenderTime 446ms CodeModel.GetById 262ms app.highlight 16ms RepoModel.GetById 165ms app.codeStats 0ms

/ext/php_xmlrpc/base/blub.php

http://mp-rechnungs-und-kundenverwaltung.googlecode.com/
PHP | 266 lines | 196 code | 33 blank | 37 comment | 15 complexity | 8332290da0d73c5e6e0c0f0c08399417 MD5 | raw file
  1<?php
  2include 'dbconnector.php';
  3/**
  4 * alle eigenschaften eines webshopabgleichs
  5 */
  6class Webshop extends DbConnector {
  7
  8    private $operator = array('<','>','=');
  9
 10    public function __construct() {
 11    //$operator = array('<','>','=');//$this->operator;
 12    }
 13    /**
 14     *
 15     * @param int $ID
 16     * @param array $operator
 17     * @return array of Contacts
 18     */
 19    public function getCustomerContactOutput($operand,$ID) {
 20        $gesamteContacts = array();
 21        $i; //pos. memo
 22        try {
 23            $pdo = new DbConnector();
 24            $newContacts = $pdo->prepare("SELECT * FROM customers_info LEFT JOIN
 25                            ( customers, address_book, countries ) ON ( customers_info.customers_info_id =
 26                              customers.customers_id AND customers.customers_id = address_book_id AND
 27                              address_book.entry_country_id = countries.countries_id ) WHERE
 28                              customers_info_id ? ?");
 29            $newContacts->execute(array($operand,$ID));
 30            $tmp = $newContacts->fetchAll();
 31
 32            foreach ($tmp as $row) {
 33                if($row['customers_gender'] == 'm') {
 34                    $gender = true;
 35                }else $gender = false;
 36
 37                if($row['customers_vat_id_status'] != null && $row['customers_vat_id_status'] == 1) {
 38                    $iscompany = true;
 39                    $vatid = $row['customers_vat_id'];
 40                }else {
 41                    $iscompany = false;
 42                    $vatid = '';
 43                }
 44
 45                $gesamteContacts[] =    new xmlrpcval(array(
 46                    'id' => new xmlrpcval($i, 'int'),
 47                    'key' => new xmlrpcval('ids', 'string'),
 48                    'value' => new xmlrpcval($row['customers_id'], 'int')), 'struct');
 49
 50                $gesamteContacts[] =    new xmlrpcval(array(
 51                    'id' => new xmlrpcval($i, 'int'),
 52                    'key' => new xmlrpcval('cname', 'string'),
 53                    'value' => new xmlrpcval($row['customers_lastname'], 'string')), 'struct');
 54
 55                $gesamteContacts[] =    new xmlrpcval(array(
 56                    'id' => new xmlrpcval($i, 'int'),
 57                    'key' => new xmlrpcval('taxnumber', 'string'),
 58                    'value' => new xmlrpcval($vatid, 'int')), 'struct');
 59                $gesamteContacts[] =    new xmlrpcval(array(
 60                    'id' => new xmlrpcval($i, 'int'),
 61                    'key' => new xmlrpcval('prename', 'string'),
 62                    'value' => new xmlrpcval($row['customers_firstname'], 'string')), 'struct');
 63                $gesamteContacts[] =    new xmlrpcval(array(
 64                    'id' => new xmlrpcval($i, 'int'),
 65                    'key' => new xmlrpcval('street', 'string'),
 66                    'value' => new xmlrpcval($row['entry_street_address'], 'string')), 'struct');
 67                $gesamteContacts[] =    new xmlrpcval(array(
 68                    'id' => new xmlrpcval($i, 'int'),
 69                    'key' => new xmlrpcval('zip', 'string'),
 70                    'value' => new xmlrpcval($row['entry_postcode'], 'int')), 'struct');
 71                $gesamteContacts[] =    new xmlrpcval(array(
 72                    'id' => new xmlrpcval($i, 'int'),
 73                    'key' => new xmlrpcval('city', 'string'),
 74                    'value' => new xmlrpcval($row['entry_city'], 'string')), 'struct');
 75                $gesamteContacts[] =    new xmlrpcval(array(
 76                    'id' => new xmlrpcval($i, 'int'),
 77                    'key' => new xmlrpcval('mainphone', 'string'),
 78                    'value' => new xmlrpcval($row['customers_telephone'], 'int')), 'struct');
 79                $gesamteContacts[] =    new xmlrpcval(array(
 80                    'id' => new xmlrpcval($i, 'int'),
 81                    'key' => new xmlrpcval('fax', 'string'),
 82                    'value' => new xmlrpcval($row['customers_fax'], 'int')), 'struct');
 83                $gesamteContacts[] =    new xmlrpcval(array(
 84                    'id' => new xmlrpcval($i, 'int'),
 85                    'key' => new xmlrpcval('mailaddress', 'string'),
 86                    'value' => new xmlrpcval($row['customers_email_address'], 'string')), 'struct');
 87                $gesamteContacts[] =    new xmlrpcval(array(
 88                    'id' => new xmlrpcval($i, 'int'),
 89                    'key' => new xmlrpcval('company', 'string'),
 90                    'value' => new xmlrpcval($row['entry_company'], 'string')), 'struct');
 91                $gesamteContacts[] =    new xmlrpcval(array(
 92                    'id' => new xmlrpcval($i, 'int'),
 93                    'key' => new xmlrpcval('country', 'string'),
 94                    'value' => new xmlrpcval($row['countries_name'], 'string')), 'struct');
 95                $gesamteContacts[] =    new xmlrpcval(array(
 96                    'id' => new xmlrpcval($i, 'int'),
 97                    'key' => new xmlrpcval('ismale', 'string'),
 98                    'value' => new xmlrpcval($gender, 'boolean')), 'struct');
 99                $gesamteContacts[] =    new xmlrpcval(array(
100                    'id' => new xmlrpcval($i, 'int'),
101                    'key' => new xmlrpcval('iscompany', 'string'),
102                    'value' => new xmlrpcval($iscompany, 'boolean')), 'struct');
103
104                $i++;
105            }
106            return $gesamteContacts;
107
108        } catch (PDOException $e)  {
109            throw new exception($e->getMessage());
110        }
111
112    }
113
114    /**
115     * Gibt die neuen Kontakte im Array zur?ck
116     * @param $lastContactID
117     * @return Array
118     */
119    public function getNewContacts($lastContactID){
120        $this->getCustomerContactOutput($lastContactID, $this->operator[0]);
121    }
122
123    public function getContact($cID,$CorG) {
124		/*
125		 * $CorG Customer or Guest
126		 * Wenn $CorG true, dann New Customer
127		 * sonst Guest == orderID
128		 */
129        if ($CorG == true) { // New Customer
130            /*
131             * wenn aktuelle Customeranzahl kleiner dann bei getCustomerConactOutput =
132             */
133            if($this->getactualCustomerCount() >= $cID) {
134
135                //abruf existierender Customer
136                $sqlstatement = 'SELECT * FROM customers_info LEFT JOIN
137                            ( customers, address_book, countries ) ON ( customers_info.customers_info_id =
138                              customers.customers_id AND customers.customers_id = address_book_id AND
139                              address_book.entry_country_id = countries.countries_id ) WHERE
140                              customers_info_id > ?';
141                $this->getCustomerContactOutput($cID, $sqlstatement);
142            }
143        }else {
144            //New Guest
145            $this->getNewGuestContact($cID);
146        }
147    }
148
149
150
151    /**
152     * all Subfunctions are protected
153     */
154        /**
155         *  gibt die aktuelle Anzahl der Customers zur?ck
156         * @return int or null
157         */
158
159     	public function getactualCustomerCount(){
160			try{
161			$pdo = new DbConnector();
162			$tmp = $pdo->prepare("SELECT COUNT(*) FROM customers");
163			$tmp->execute();
164			return $tmp->fetchColumn();
165		} catch (PDOException $e) {
166			throw new exception($e->getMessage());
167		}
168	}
169
170    /**
171     *
172     * @param int $ID
173     * @return array
174     */
175	protected function getNewGuestContact($ID){
176
177            try{
178			$pdo = new DbConnector();
179			$newGuestContact = $pdo->prepare("SELECT * FROM `orders` where orders_id = ?");
180			$newGuestContact->execute(array($ID));
181                        $tmp = $newGuestContact->fetchAll();
182                        var_dump($tmp);
183            foreach ($tmp as $row) {
184                if($row['customers_gender'] == 'm') {
185                    $gender = true;
186                }else $gender = false;
187
188                if($row['customers_vat_id_status'] != null && $row['customers_vat_id_status'] == 1) {
189                    $iscompany = true;
190                    $vatid = $row['customers_vat_id'];
191                    $company = $row['customers_company'];
192                }else {
193                    $iscompany = false;
194                    $vatid = '';
195                    $company = '';
196                }
197
198                $gesamteContacts[] =    new xmlrpcval(array(
199                    'id' => new xmlrpcval($i, 'int'),
200                    'key' => new xmlrpcval('ids', 'string'),
201                    'value' => new xmlrpcval($row['customers_id'], 'int')), 'struct');
202
203
204                $gesamteContacts[] =    new xmlrpcval(array(
205                    'id' => new xmlrpcval($i, 'int'),
206                    'key' => new xmlrpcval('cname', 'string'),
207                    'value' => new xmlrpcval($row['customers_name'], 'string')), 'struct');
208
209                $gesamteContacts[] =    new xmlrpcval(array(
210                    'id' => new xmlrpcval($i, 'int'),
211                    'key' => new xmlrpcval('taxnumber', 'string'),
212                    'value' => new xmlrpcval($vatid, 'int')), 'struct');
213
214                $gesamteContacts[] =    new xmlrpcval(array(
215                    'id' => new xmlrpcval($i, 'int'),
216                    'key' => new xmlrpcval('street', 'string'),
217                    'value' => new xmlrpcval($row['customers_street_address'], 'string')), 'struct');
218                $gesamteContacts[] =    new xmlrpcval(array(
219                    'id' => new xmlrpcval($i, 'int'),
220                    'key' => new xmlrpcval('zip', 'string'),
221                    'value' => new xmlrpcval($row['customers_postcode'], 'int')), 'struct');
222                $gesamteContacts[] =    new xmlrpcval(array(
223                    'id' => new xmlrpcval($i, 'int'),
224                    'key' => new xmlrpcval('city', 'string'),
225                    'value' => new xmlrpcval($row['customers_city'], 'string')), 'struct');
226                $gesamteContacts[] =    new xmlrpcval(array(
227                    'id' => new xmlrpcval($i, 'int'),
228                    'key' => new xmlrpcval('mainphone', 'string'),
229                    'value' => new xmlrpcval($row['customers_telephone'], 'int')), 'struct');
230
231                $gesamteContacts[] =    new xmlrpcval(array(
232                    'id' => new xmlrpcval($i, 'int'),
233                    'key' => new xmlrpcval('mailaddress', 'string'),
234                    'value' => new xmlrpcval($row['customers_email_address'], 'string')), 'struct');
235                $gesamteContacts[] =    new xmlrpcval(array(
236                    'id' => new xmlrpcval($i, 'int'),
237                    'key' => new xmlrpcval('company', 'string'),
238                    'value' => new xmlrpcval($company, 'string')), 'struct');
239                $gesamteContacts[] =    new xmlrpcval(array(
240                    'id' => new xmlrpcval($i, 'int'),
241                    'key' => new xmlrpcval('country', 'string'),
242                    'value' => new xmlrpcval($row['customers_country'], 'string')), 'struct');
243                $gesamteContacts[] =    new xmlrpcval(array(
244                    'id' => new xmlrpcval($i, 'int'),
245                    'key' => new xmlrpcval('ismale', 'string'),
246                    'value' => new xmlrpcval($gender, 'boolean')), 'struct');
247                $gesamteContacts[] =    new xmlrpcval(array(
248                    'id' => new xmlrpcval($i, 'int'),
249                    'key' => new xmlrpcval('iscompany', 'string'),
250                    'value' => new xmlrpcval($iscompany, 'boolean')), 'struct');
251
252                $i++;
253            }
254            return $gesamteContacts;
255
256
257
258
259
260
261		} catch (PDOException $e) {
262			throw new exception($e->getMessage());
263		}
264	}
265}
266?>