public function GetClients($fileNumbers, $properties, $WebsiteSource = null) { $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'); // ## if they don't request this, request it anyway. if (!in_array('completed_steps_bitwise', $properties)) { array_push($properties, 'completed_steps_bitwise'); } if (!in_array('cart_status', $properties)) { array_push($properties, 'cart_status'); } if (!in_array('cart_items', $properties)) { array_push($properties, 'cart_items'); } if (!in_array('cart_id', $properties)) { array_push($properties, 'cart_id'); } if (!in_array('cart_steps_required', $properties)) { array_push($properties, 'cart_steps_required'); } if (!in_array('cart_order_time', $properties)) { array_push($properties, 'cart_order_time'); } if (!in_array('products_already_purchased', $properties)) { array_push($properties, 'products_already_purchased'); } if (!in_array('WebsiteSource', $properties)) { array_push($properties, 'WebsiteSource'); } // prepare the properties $clientProperties = array(); $i = 0; foreach ($properties as $propertyName) { $clientProperties[$i] = new SoapVar($propertyName, XSD_STRING, null, null, 'ns1:string'); $i++; } $parms[] = new SoapVar($clientProperties, SOAP_ENC_OBJECT, NULL, NULL, 'ns1:propertyNameList'); $fileNumberList = array(); $i = 0; if (!is_array($fileNumbers)) { $fileNumbers = array($fileNumbers); } foreach ($fileNumbers as $fileNumber) { $fileNumberList[$i] = new SoapVar($fileNumber, XSD_STRING, null, null, 'ns1:string'); $i++; } $parms[] = new SoapVar($fileNumberList, SOAP_ENC_OBJECT, NULL, NULL, 'ns1:fileNumberList'); $soap = new SoapClient($soap_url, $this->GetSoapOptions()); try { $call = $soap->GetClients(new SoapVar($parms, SOAP_ENC_OBJECT)); if (isset($call->GetClientsResult) && isset($call->GetClientsResult->Client)) { $clients = $call->GetClientsResult->Client; if (!is_array($clients)) { $clients = array($clients); } // foreach clients as client foreach ($clients as $client_i => $client) { $Properties = @$client->Properties->ClientProperty; if (!is_array($Properties)) { $Properties = array($Properties); } $client->TProperties = new stdClass(); foreach ($Properties as $prop) { if (isset($prop->Name) && isset($prop->Value)) { if (!$prop->Name) { continue; } $client->TProperties->{$prop->Name} = @$prop->Value; } } $client->TStatus = new stdClass(); $clientStatus = $client->CurrentStatus->ClientStatus; if (!is_array($clientStatus)) { $clientStatus = array($client->CurrentStatus->ClientStatus); } foreach ($clientStatus as $csi) { $client->TStatus->{$csi->WorkflowName} = new stdClass(); $client->TStatus->{$csi->WorkflowName}->status = $csi->Name; $client->TStatus->{$csi->WorkflowName}->updated = $csi->UpdatedOn; } // tDates $client->TDates = new stdClass(); $CreatedOn = new DateTime($client->CreatedOn, new DateTimeZone('America/Los_Angeles')); $client->TDates->CreatedOn = $CreatedOn->format('m/d/Y h:ia'); $UpdatedOn = new DateTime($client->UpdatedOn, new DateTimeZone('America/Los_Angeles')); $UpdatedOn->setTimezone(new DateTimeZone('America/New_York')); $client->TDates->UpdatedOn = $UpdatedOn->format('m/d/Y h:ia T'); $fromNow = Carbon::instance($UpdatedOn)->diffInMinutes(); $client->TDates->UpdatedMinutesAgo = $fromNow; if (!isset($client->TProperties->completed_steps_bitwise)) { $client->TProperties->completed_steps_bitwise = 0; } $client->TProperties->completed_steps_bitwise = intval($client->TProperties->completed_steps_bitwise); //our defaults $client->CompletedStep = 0; $client->NextStep = 1; for ($stepnumber = 1; $stepnumber <= 7; $stepnumber++) { $constant = 'step' . $stepnumber; if (defined($constant)) { $constant_value = constant($constant); if ($client->TProperties->completed_steps_bitwise & $constant_value) { $client->CompletedStep = $stepnumber; $client->NextStep = $stepnumber + 1; $client->{'Completed_Step_' . $stepnumber} = true; } else { $client->{'Completed_Step_' . $stepnumber} = false; } } } $client->Generated_UTIME = time(); $client->Generated_DATETIME = date('c'); $this->SetupClientDetailsFromCache($client); if (isset($WebsiteSource) && $WebsiteSource) { if (strtolower($client->TProperties->WebsiteSource) == strtolower($WebsiteSource)) { $clients[$client_i] = $client; } } else { $clients[$client_i] = $client; } } if (!count($clients)) { return false; } usort($clients, function ($a, $b) { return $a->TDates->UpdatedMinutesAgo < $b->TDates->UpdatedMinutesAgo ? -1 : ($a->TDates->UpdatedMinutesAgo > $b->TDates->UpdatedMinutesAgo ? 1 : 0); }); return $clients; } return array(); } catch (SoapFault $fault) { return false; } }