Example #1
0
 /**
  * Search for a client by the City. It'll then validate that there Last Name matches what is on file for a little added security.
  *
  * @param string $city
  * @return Clients File ID if found (or false)
  */
 public function FindClientsByCity($city)
 {
     //remove any dashes from the $ssn
     $soap_url = $this->GetClientWSDL();
     $parms = array();
     $parms[] = new SoapVar($this->userName, XSD_STRING, null, null, 'ns1:userName');
     $parms[] = new SoapVar($this->password, XSD_STRING, null, null, 'ns1:password');
     $parms[] = new SoapVar("client_region", XSD_STRING, null, null, 'ns1:propertyName');
     $parms[] = new SoapVar($city, XSD_STRING, null, null, 'ns1:propertyValue');
     $soap = new SoapClient($soap_url, $this->GetSoapOptions());
     try {
         $call = $soap->SearchByProperty(new SoapVar($parms, SOAP_ENC_OBJECT));
         if (isset($call->SearchByPropertyResult)) {
             //check if we have any result here? what if it is an array?
             if (isset($call->SearchByPropertyResult->string)) {
                 /**
                  * @todo Handle if there is more than one (there should never be!)
                  */
                 if (is_array($call->SearchByPropertyResult->string)) {
                     $fileids = array();
                     foreach ($call->SearchByPropertyResult->string as $fileid) {
                         $fileids[] = $fileid;
                     }
                 } else {
                     $fileids = array($call->SearchByPropertyResult->string);
                 }
                 //alright we have the client file id, lets check that there last name matches.
                 $clients = $this->GetClients($fileids, array('FirstName', 'LastName', 'client_city', 'client_region', 'client_zipcode'));
                 return $clients;
             }
         }
         return false;
     } catch (SoapFault $fault) {
         return false;
         //error
     }
 }