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