Next4Me
 All Classes Files Functions Variables
CmplxContactAndDetail.php
Go to the documentation of this file.
1 <?php
17 class Application_Model_CmplxContactAndDetail extends Zend_Db_Table
18 {
19  //==== Start getContactAndDetail =========================================================================
26  function getContactAndDetail($entity){
27  $this->Contact = new Application_Model_Contact();
28  $this->Email = new Application_Model_Email();
29  $this->Phone = new Application_Model_Phone();
30  $this->Address = new Application_Model_Address();
31  $commit=1;
32  $contactRowset=$this->Contact->getContact($entity);
33  if($contactRowset['resultId']=="0"){
34  foreach($contactRowset['resultCode']['entity'] as $contact)
35  {
36  $data=array("IdAddress"=>"0", "IdContact"=>$contact['IdContact'], "IdUserAccount"=>$entity['IdUserAccount'],"UserAccountType"=>$entity['UserAccountType']);
37  $addressRowset=$this->Address->getAddress($data);
38  if($addressRowset['resultId']=="0"){
39  foreach($addressRowset['resultCode']['entity'] as $address)
40  {
41  $_Address[]=array("IdAddress"=>$address['IdAddress'],
42  "Type"=>$address['Type'],
43  "IdRegion"=>$address['IdRegion'],
44  "Street"=>$address['Street'],
45  "Number"=>$address['Number'],
46  "Building"=>$address['Building'],
47  "Floor"=>$address['Floor'],
48  "Appartment"=>$address['Appartment'],
49  "Lat"=>$address['Lat'],
50  "Long"=>$address['Long'],
51  "IdContact"=>$address['IdContact']);
52  }
53  }else{
54  $_Address="";
55  }
56  $data=array("IdEmail"=>"0", "IdContact"=>$contact['IdContact'], "IdUserAccount"=>$entity['IdUserAccount'],"UserAccountType"=>$entity['UserAccountType']);
57  $emailRowset=$this->Email->getEmail($data);
58  if($emailRowset['resultId']=="0"){
59  foreach($emailRowset['resultCode']['entity'] as $email)
60  {
61  $_Email[]=array("IdEmail"=>$email['IdEmail'],
62  "Value"=>$email['Value'],
63  "Type"=>$email['Type'],
64  "IdContact"=>$email['IdContact']);
65 
66  }
67  }else{
68  $_Email="";
69  }
70  $data=array("IdPhone"=>"0", "IdContact"=>$contact['IdContact'], "IdUserAccount"=>$entity['IdUserAccount'],"UserAccountType"=>$entity['UserAccountType']);
71  $phoneRowset=$this->Phone->getPhone($data);
72  if($phoneRowset['resultId']=="0"){
73  foreach($phoneRowset['resultCode']['entity'] as $phone)
74  {
75  $_Phone[]=array("IdPhone"=>$phone['IdPhone'],
76  "Value"=>$phone['Value'],
77  "Type"=>$phone['Type'],
78  "IdContact"=>$phone['IdContact']);
79 
80  }
81  }else{
82  $_Phone="";
83 
84  }
85 
86  $_CmplxContact[]=array("IdContact"=>$contact['IdContact'],
87  "Name"=>$contact['Name'],
88  "Surname"=>$contact['Surname'],
89  "Company"=>$contact['Company'],
90  "Birthday"=>$contact['Birthday'],
91  "Gender"=>$contact['Gender'],"Address"=>$_Address, "Phone"=>$_Phone, "Email"=>$_Email);
92  }
93  $result=array("resultId"=>$contactRowset['resultId'], "resultCode"=>$_CmplxContact);
94  }else{
95  $result=array("resultId"=>$contactRowset['resultId'], "resultCode"=>$contactRowset['resultCode']);
96  }
97 
98  return array("commit"=>"1","entity"=>$result);
99 
100  }
101  //==== End getUserAccountAndDetail =======================================================================
102 
103 
104 
105 }