Each phone number has a number and a type.

Author: CreditCall Communications
Exemplo n.º 1
0
 /**
  * (non-PHPdoc)
  * @see Model::beforeDelete()
  */
 function beforeDelete($cascade = true)
 {
     App::import('Model', 'PhoneNumber');
     $my_model = new PhoneNumber();
     $this->recursive = 1;
     $businessDetail = $this->find('first', array('conditions' => array('BusinessDetail.id' => $this->id)));
     $this->_business_delete_id = $businessDetail['BusinessDetail']['businesses_id'];
     foreach ($businessDetail['PhoneNumber'] as $phone) {
         $my_model->delete($phone['id']);
     }
     return true;
 }
 protected function getPhone($phoneId)
 {
     // Phone
     $phone = 'Privacy';
     $numberId = (int) $phoneId;
     if ($numberId > 0) {
         $phoneNumber = new PhoneNumber();
         $phoneNumber->numberId = $numberId;
         $phoneNumber->populate();
         if ($phoneNumber->type == 'REMINDERS') {
             $phone = $phoneNumber->number;
         }
     }
     return $phone;
 }
Exemplo n.º 3
0
 public function runTest()
 {
     extract($this->_options, EXTR_SKIP);
     $phone = new PhoneNumber($this->fieldValue);
     $phone->defaultAreaCode = $defaultAreaCode;
     list($areaCode, $first3Digits, $last4Digits) = $phone->split();
     // Check to make sure it is a valid phone number.
     if (!$areaCode || !$first3Digits || !$last4Digits) {
         $this->validator->registerInvalid($this->field, $this->formatError($error));
         return false;
     }
     if ($modify) {
         $this->validator->setFieldValue($this->field, $areaCode . '-' . $first3Digits . '-' . $last4Digits);
     }
     return true;
 }
Exemplo n.º 4
0
 function send_message($from, $to, $message)
 {
     $from = PhoneNumber::normalizePhoneNumberToE164($from);
     $to = PhoneNumber::normalizePhoneNumberToE164($to);
     try {
         $account = OpenVBX::getAccount();
         $response = $account->messages->sendMessage($from, $to, $message);
     } catch (Exception $e) {
         throw new VBX_Sms_messageException($e->getMessage());
     }
     if (!in_array($response->status, array('sent', 'queued'))) {
         throw new VBX_Sms_messageException('SMS delivery failed. An unknown error occurred' . ' during delivery.');
     }
 }
Exemplo n.º 5
0
 function send_message($from, $to, $message)
 {
     $from = PhoneNumber::normalizePhoneNumberToE164($from);
     $to = PhoneNumber::normalizePhoneNumberToE164($to);
     $twilio = new TwilioRestClient($this->twilio_sid, $this->twilio_token, $this->twilio_endpoint);
     error_log("Sending sms from {$from} to {$to} with content: {$message}");
     $response = $twilio->request("Accounts/{$this->twilio_sid}/SMS/Messages", 'POST', array("From" => $from, "To" => $to, "Body" => $message));
     $status = isset($response->ResponseXml) ? $response->ResponseXml->SMSMessage->Status : 'failed';
     if ($response->IsError || $status != 'sent' && $status != 'queued') {
         error_log("SMS not sent - Error Occurred");
         error_log($response->ErrorMessage);
         throw new VBX_Sms_messageException($response->ErrorMessage);
     }
 }
Exemplo n.º 6
0
 public function populateHeader(SimpleXMLElement $xml)
 {
     $patientName = array();
     $patientName['given'] = $this->patient->person->firstName;
     $patientName['family'] = $this->patient->person->lastName;
     $patientName['suffix'] = $this->patient->person->suffix;
     $providerName = array();
     $providerName['prefix'] = $this->user->person->prefix;
     $providerName['given'] = $this->user->person->firstName;
     $providerName['family'] = $this->user->person->lastName;
     $building = $this->building;
     $buildingName = $building->displayName;
     $realmCode = $xml->addChild('realmCode');
     $realmCode->addAttribute('code', 'US');
     $typeId = $xml->addChild('typeId');
     $typeId->addAttribute('root', '2.16.840.1.113883.1.3');
     $typeId->addAttribute('extension', 'POCD_HD000040');
     $templateId = $xml->addChild('templateId');
     $templateId->addAttribute('root', '2.16.840.1.113883.3.27.1776');
     $templateId->addAttribute('assigningAuthorityName', 'CDA/R2');
     $templateId = $xml->addChild('templateId');
     $templateId->addAttribute('root', '2.16.840.1.113883.10.20.3');
     $templateId->addAttribute('assigningAuthorityName', 'HL7/CDT Header');
     $templateId = $xml->addChild('templateId');
     $templateId->addAttribute('root', '1.3.6.1.4.1.19376.1.5.3.1.1.1');
     $templateId->addAttribute('assigningAuthorityName', 'IHE/PCC');
     $templateId = $xml->addChild('templateId');
     $templateId->addAttribute('root', '2.16.840.1.113883.3.88.11.32.1');
     $templateId->addAttribute('assigningAuthorityName', 'HITSP/C32');
     $id = $xml->addChild('id');
     $id->addAttribute('root', '2.16.840.1.113883.3.72');
     $id->addAttribute('extension', 'HITSP_C32v2.5');
     $id->addAttribute('assigningAuthorityName', 'ClearHealth');
     $code = $xml->addChild('code');
     $code->addAttribute('code', '34133-9');
     $displayName = 'Summarization of episode note';
     $code->addAttribute('displayName', $displayName);
     $code->addAttribute('codeSystem', '2.16.840.1.113883.6.1');
     $code->addAttribute('codeSystemName', 'LOINC');
     $xml->addChild('title', html_convert_entities($this->_title));
     $effectiveTime = $xml->addChild('effectiveTime');
     $dateEffective = self::formatDate();
     $effectiveTime->addAttribute('value', $dateEffective);
     $confidentialityCode = $xml->addChild('confidentialityCode');
     $confidentialityCode->addAttribute('code', 'N');
     //$confidentialityCode->addAttribute('codeSystem','2.16.840.1.113883.5.25');
     $languageCode = $xml->addChild('languageCode');
     $languageCode->addAttribute('code', 'en-US');
     // RECORD TARGET
     $recordTarget = $xml->addChild('recordTarget');
     $patientRole = $recordTarget->addChild('patientRole');
     $id = $patientRole->addChild('id');
     //$id->addAttribute('root','CLINICID');
     $id->addAttribute('root', 'MRN');
     //$id->addAttribute('extension','PatientID');
     $id->addAttribute('extension', html_convert_entities($this->patient->recordNumber));
     // Address
     $address = new Address();
     $address->personId = $this->_patientId;
     $addressIterator = $address->getIteratorByPersonId();
     foreach ($addressIterator as $address) {
         break;
         // retrieves the top address
     }
     $addr = $patientRole->addChild('addr');
     if ($address->addressId > 0) {
         $addr->addAttribute('use', 'HP');
         $addr->addChild('streetAddressLine', html_convert_entities(strlen($address->line2) > 0 ? $address->line1 . ' ' . $address->line2 : $address->line1));
         $addr->addChild('city', html_convert_entities($address->city));
         $addr->addChild('state', html_convert_entities($address->state));
         $addr->addChild('postalCode', html_convert_entities($address->zipCode));
     }
     // Telecom
     $phone = null;
     $phoneNumber = new PhoneNumber();
     $phoneNumber->personId = $this->_patientId;
     foreach ($phoneNumber->getPhoneNumbers(false) as $phone) {
         break;
         // retrieves the top phone
     }
     $telecom = $patientRole->addChild('telecom');
     if ($phone && strlen($phone['number']) > 0) {
         $telecom->addAttribute('use', 'HP');
         $telecom->addAttribute('value', 'tel:' . html_convert_entities($phone['number']));
     }
     // Patient
     $patient = $patientRole->addChild('patient');
     $name = $patient->addChild('name');
     $name->addChild('given', html_convert_entities($patientName['given']));
     $name->addChild('family', html_convert_entities($patientName['family']));
     $name->addChild('suffix', html_convert_entities($patientName['suffix']));
     $genderCode = $patient->addChild('administrativeGenderCode');
     $genderCode->addAttribute('code', html_convert_entities($this->patient->person->gender));
     $genderCode->addAttribute('displayName', html_convert_entities($this->patient->person->displayGender));
     $genderCode->addAttribute('codeSystem', '2.16.840.1.113883.5.1');
     $genderCode->addAttribute('codeSystemName', 'HL7 AdministrativeGender');
     $birthTime = $patient->addChild('birthTime');
     $birthTime->addAttribute('value', date('Ymd', strtotime($this->patient->person->dateOfBirth)));
     /*$maritalStatusCode = $patient->addChild('maritalStatusCode');
     		$maritalStatusCode->addAttribute('code','');
     		$maritalStatusCode->addAttribute('displayName','');
     		$maritalStatusCode->addAttribute('codeSystem','2.16.840.1.113883.5.2');
     		$maritalStatusCode->addAttribute('codeSystemName','HL7 Marital status');*/
     /*$languageCommunication = $patient->addChild('languageCommunication');
     		$templateId = $languageCommunication->addChild('templateId');
     		$templateId->addAttribute('root','2.16.840.1.113883.3.88.11.83.2');
     		$templateId->addAttribute('assigningAuthorityName','HITSP/C83');
     		$templateId = $languageCommunication->addChild('templateId');
     		$templateId->addAttribute('root','1.3.6.1.4.1.19376.1.5.3.1.2.1');
     		$templateId->addAttribute('assigningAuthorityName','IHE/PCC');
     		$languageCode = $languageCommunication->addChild('languageCode');
     		$languageCode->addAttribute('code','en-US');*/
     // AUTHOR
     $author = $xml->addChild('author');
     $time = $author->addChild('time');
     $timeValue = self::formatDate();
     $time->addAttribute('value', $timeValue);
     $assignedAuthor = $author->addChild('assignedAuthor');
     $id = $assignedAuthor->addChild('id');
     $id->addAttribute('root', '20cf14fb-b65c-4c8c-a54d-b0cca834c18c');
     $addr = $assignedAuthor->addChild('addr');
     $addr->addAttribute('use', 'HP');
     $addr->addChild('streetAddressLine', html_convert_entities(strlen($building->line2) > 0 ? $building->line1 . ' ' . $building->line2 : $building->line1));
     $addr->addChild('city', html_convert_entities($building->city));
     $addr->addChild('state', html_convert_entities($building->state));
     $addr->addChild('postalCode', html_convert_entities($building->zipCode));
     $telecom = $assignedAuthor->addChild('telecom');
     if (strlen($building->phoneNumber) > 0) {
         //$telecom->addAttribute('use','HP');
         $telecom->addAttribute('value', 'tel:' . html_convert_entities($building->phoneNumber));
     }
     $assignedPerson = $assignedAuthor->addChild('assignedPerson');
     $name = $assignedPerson->addChild('name');
     $name->addChild('prefix', html_convert_entities($providerName['prefix']));
     $name->addChild('given', html_convert_entities($providerName['given']));
     $name->addChild('family', html_convert_entities($providerName['family']));
     $representedOrg = $assignedAuthor->addChild('representedOrganization');
     $id = $representedOrg->addChild('id');
     $id->addAttribute('root', '2.16.840.1.113883.19.5');
     $representedOrg->addChild('name', html_convert_entities($buildingName));
     $address = $building->practice->primaryAddress;
     $telecom = $representedOrg->addChild('telecom');
     if (strlen($building->practice->mainPhone->number) > 0) {
         //$telecom->addAttribute('use','HP');
         $telecom->addAttribute('value', 'tel:' . html_convert_entities($building->practice->mainPhone->number));
     }
     $addr = $representedOrg->addChild('addr');
     if ($address->addressId > 0) {
         $addr->addAttribute('use', 'HP');
         $addr->addChild('streetAddressLine', html_convert_entities(strlen($address->line2) > 0 ? $address->line1 . ' ' . $address->line2 : $address->line1));
         $addr->addChild('city', html_convert_entities($address->city));
         $addr->addChild('state', html_convert_entities($address->state));
         $addr->addChild('postalCode', html_convert_entities($address->zipCode));
     }
     // CUSTODIAN
     $custodian = $xml->addChild('custodian');
     $assignedCustodian = $custodian->addChild('assignedCustodian');
     $representedOrg = $assignedCustodian->addChild('representedCustodianOrganization');
     $id = $representedOrg->addChild('id');
     $id->addAttribute('root', '2.16.840.1.113883.19.5');
     $representedOrg->addChild('name', 'NIST Registry');
     $telecom = $representedOrg->addChild('telecom');
     $telecom->addAttribute('value', 'tel:+1-301-975-3251');
     $addr = $representedOrg->addChild('addr');
     $addr->addChild('streetAddressLine', '100 Bureau Drive');
     $addr->addChild('city', 'Gaithersburg');
     $addr->addChild('state', 'MD');
     $addr->addChild('postalCode', '20899');
     // PARTICIPANT
     $participant = $xml->addChild('participant');
     $participant->addAttribute('typeCode', 'IND');
     $associatedEntity = $participant->addChild('associatedEntity');
     $associatedEntity->addAttribute('classCode', 'GUAR');
     $id = $associatedEntity->addChild('id');
     $id->addAttribute('root', '4ff51570-83a9-47b7-91f2-93ba30373141');
     $addr = $associatedEntity->addChild('addr');
     //$addr->addChild('streetAddressLine','17 Daws Rd.');
     //$addr->addChild('city','Blue Bell');
     //$addr->addChild('state','MA');
     //$addr->addChild('postalCode','02368');
     $telecom = $associatedEntity->addChild('telecom');
     //$telecom->addAttribute('value','tel:(888)555-1212');
     $associatedPerson = $associatedEntity->addChild('associatedPerson');
     $name = $associatedPerson->addChild('name');
     //$name->addChild('given','Kenneth');
     //$name->addChild('family','Ross');
     // DOCUMENTATION OF
     $documentationOf = $xml->addChild('documentationOf');
     $serviceEvent = $documentationOf->addChild('serviceEvent');
     $serviceEvent->addAttribute('classCode', 'PCPR');
     $effectiveTime = $serviceEvent->addChild('effectiveTime');
     $low = $effectiveTime->addChild('low');
     $lowValue = date('Ymd');
     $low->addAttribute('value', $lowValue);
     $high = $effectiveTime->addChild('high');
     $highValue = date('Ymd', strtotime('+1 month'));
     $high->addAttribute('value', $highValue);
     // Performer
     foreach ($this->performers as $provider) {
         $performer = $serviceEvent->addChild('performer');
         $performer->addAttribute('typeCode', 'PRF');
         $templateId = $performer->addChild('templateId');
         $templateId->addAttribute('root', '2.16.840.1.113883.3.88.11.83.4');
         $templateId->addAttribute('assigningAuthorityName', 'HITSP C83');
         $templateId = $performer->addChild('templateId');
         $templateId->addAttribute('root', '1.3.6.1.4.1.19376.1.5.3.1.2.3');
         $templateId->addAttribute('assigningAuthorityName', 'IHE PCC');
         $functionCode = $performer->addChild('functionCode');
         $functionCode->addAttribute('code', 'PP');
         $functionCode->addAttribute('displayName', 'Primary Care Provider');
         $functionCode->addAttribute('codeSystem', '2.16.840.1.113883.12.443');
         $functionCode->addAttribute('codeSystemName', 'Provider Role');
         $functionCode->addChild('originalText', 'Primary Care Provider');
         $time = $performer->addChild('time');
         $low = $time->addChild('low');
         $lowValue = date('Y');
         $low->addAttribute('value', $lowValue);
         $high = $time->addChild('high');
         $highValue = date('Ymd', strtotime('+1 month'));
         $high->addAttribute('value', $highValue);
         $assignedEntity = $performer->addChild('assignedEntity');
         $id = $assignedEntity->addChild('id');
         $id->addAttribute('extension', 'PseudoMD-' . $provider->personId);
         $id->addAttribute('root', '2.16.840.1.113883.3.72.5.2');
         $id = $assignedEntity->addChild('id');
         $id->addAttribute('extension', '999999999');
         $id->addAttribute('root', '2.16.840.1.113883.4.6');
         // <code code="200000000X" displayName="Allopathic and Osteopathic Physicians" codeSystemName="Provider Codes" codeSystem="2.16.840.1.113883.6.101"/>
         $addr = $assignedEntity->addChild('addr');
         $address = new Address();
         $address->personId = $provider->personId;
         $addressIterator = $address->getIteratorByPersonId();
         foreach ($addressIterator as $address) {
             break;
             // retrieves the top address
         }
         if ($address->addressId > 0) {
             $addr->addAttribute('use', 'HP');
             $addr->addChild('streetAddressLine', html_convert_entities(strlen($address->line2) > 0 ? $address->line1 . ' ' . $address->line2 : $address->line1));
             $addr->addChild('city', html_convert_entities($address->city));
             $addr->addChild('state', html_convert_entities($address->state));
             $addr->addChild('postalCode', html_convert_entities($address->zipCode));
         }
         $telecom = $assignedEntity->addChild('telecom');
         $phoneNumber = new PhoneNumber();
         $phoneNumber->personId = $provider->personId;
         foreach ($phoneNumber->getPhoneNumbers(false) as $phone) {
             break;
             // retrieves the top phone
         }
         if (strlen($phone['number']) > 0) {
             $telecom->addAttribute('use', 'HP');
             $telecom->addAttribute('value', 'tel:' . html_convert_entities($phone['number']));
         }
         $assignedPerson = $assignedEntity->addChild('assignedPerson');
         $name = $assignedPerson->addChild('name');
         $name->addChild('prefix', html_convert_entities($provider->person->prefix));
         $name->addChild('given', html_convert_entities($provider->person->firstName));
         $name->addChild('family', html_convert_entities($provider->person->lastName));
         $representedOrg = $assignedEntity->addChild('representedOrganization');
         $id = $representedOrg->addChild('id');
         $id->addAttribute('root', '2.16.840.1.113883.3.72.5');
         $representedOrg->addChild('name');
         $telecom = $representedOrg->addChild('telecom');
         $addr = $representedOrg->addChild('addr');
         /*$representedOrg->addChild('name',$buildingName);
         		$telecom = $representedOrg->addChild('telecom');
         		if (strlen($building->practice->mainPhone->number) > 0) {
         			$telecom->addAttribute('use','HP');
         			$telecom->addAttribute('value','tel:'.$building->practice->mainPhone->number);
         		}
         		$addr = $representedOrg->addChild('addr');
         		if ($address->addressId > 0) {
         			$addr->addAttribute('use','HP');
         			$addr->addChild('streetAddressLine',(strlen($address->line2) > 0)?$address->line1.' '.$address->line2:$address->line1);
         			$addr->addChild('city',$address->city);
         			$addr->addChild('state',$address->state);
         			$addr->addChild('postalCode',$address->zipCode);
         		}*/
     }
 }
Exemplo n.º 7
0
 private function fad710e267c002f374f607e125e6219e044710bba()
 {
     $i24931bf8d8dd5bf8b970fbea0e59a47ff06bffa1 = $iea9d992f624fb48911a6ab7dc62eed1a4c5e3706 = "";
     $ib1199182837e705aae8d93f525c88b1184f9395d = $this->f1b1c636527127b1c174f4aa075d5334084c79b0e($this->v82b103019f8b63abe35e23c8982897d7b3b13cd2, $this->v5a4616ba4ac4a7f21e69ba2afe5e994ae9927078);
     if ($this->va917c2d49152f506b70362a47d4a4b689d3e7541 != -1) {
         $ia917c2d49152f506b70362a47d4a4b689d3e7541 = $this->va917c2d49152f506b70362a47d4a4b689d3e7541;
     } elseif (isset($ib1199182837e705aae8d93f525c88b1184f9395d["senderID"]) && PhoneNumber::isPhoneNumber($ib1199182837e705aae8d93f525c88b1184f9395d["senderID"])) {
         $ia917c2d49152f506b70362a47d4a4b689d3e7541 = $ib1199182837e705aae8d93f525c88b1184f9395d["senderID"];
         if ($ib1199182837e705aae8d93f525c88b1184f9395d["senderID"] != "") {
             $iea9d992f624fb48911a6ab7dc62eed1a4c5e3706 = " class=\"hidden\"";
             $i24931bf8d8dd5bf8b970fbea0e59a47ff06bffa1 = "";
         } else {
             $iea9d992f624fb48911a6ab7dc62eed1a4c5e3706 = "";
         }
     } else {
         $ia917c2d49152f506b70362a47d4a4b689d3e7541 = -1;
     }
     if (strlen($this->v24931bf8d8dd5bf8b970fbea0e59a47ff06bffa1) > 0 && $this->va917c2d49152f506b70362a47d4a4b689d3e7541 == -1) {
         $i24931bf8d8dd5bf8b970fbea0e59a47ff06bffa1 = $this->v24931bf8d8dd5bf8b970fbea0e59a47ff06bffa1;
         $ia917c2d49152f506b70362a47d4a4b689d3e7541 = -1;
         $iea9d992f624fb48911a6ab7dc62eed1a4c5e3706 = "";
     }
     if ($this->v19b8b7cad3f484c5fd3981e8d383972bf5b46508) {
         $iea9d992f624fb48911a6ab7dc62eed1a4c5e3706 = " class=\"hidden\"";
         $if7a6d77e9294fd1c231b0e08d721dfa1f192bec6 = " class=\"hidden\"";
         $i011b2a01ee0a992d7ea6a807884909e65aefd0c7 = "";
     } else {
         $if7a6d77e9294fd1c231b0e08d721dfa1f192bec6 = "";
         $i011b2a01ee0a992d7ea6a807884909e65aefd0c7 = " class=\"hidden\"";
     }
     $i02fcabda2448d40bdb76bd10f9e95950039649ee = ' <form action="" method="post"> <table class="formTable profile"> <tbody> <tr' . $if7a6d77e9294fd1c231b0e08d721dfa1f192bec6 . '> <td>' . self::getLabel(v_smswizard_existingown, 'class="bold"') . '</td> <td>' . self::getSelect(array("name" => "ownsenderID", "id" => "selectOwnSender", "onchange" => "ownSender();"), $this->f2e417c6ce6885ef9fd0253ef02610a4fe8446157(), $ia917c2d49152f506b70362a47d4a4b689d3e7541) . ' *</td> </tr> <tr id="newOwnSender"' . $iea9d992f624fb48911a6ab7dc62eed1a4c5e3706 . '> <td>' . self::getLabel(v_smswizard_newownnrid, 'class="bold"') . '</td> <td>' . self::getInput(array("name" => "newownsenderID", "type" => "text", "value" => $i24931bf8d8dd5bf8b970fbea0e59a47ff06bffa1)) . ' * ' . self::getNote(v_smswizard_intformat) . '</td> </tr> <tr id="newOwnSender"' . $i011b2a01ee0a992d7ea6a807884909e65aefd0c7 . '> <td>' . self::getLabel(v_smswizard_smscode, 'class="bold"') . '</td> <td>' . self::getInput(array("name" => "validateCode", "type" => "text", "value" => $this->va673093194bc7ce7672ed2857425609839b3119d)) . ' *</td> </tr> <tr> <td></td> <td>' . self::getInput(array("name" => "submitAddOwnNumberSenderID", "type" => "submit", "value" => v_smswizard_confirm)) . '</td> </tr> </tbody> </table> <div class="small note"><sup>*</sup> ' . v_adminsmsprofile_required . '</div>' . self::getInput(array("name" => "info", "type" => "hidden", "value" => $this->vb2bdeb39d0b431e06e364d808d2f32fddee67ca3)) . self::getInput(array("name" => "country", "type" => "hidden", "value" => $this->v5a4616ba4ac4a7f21e69ba2afe5e994ae9927078)) . self::getInput(array("name" => "type", "type" => "hidden", "value" => $this->v82b103019f8b63abe35e23c8982897d7b3b13cd2)) . self::getInput(array("name" => "action", "type" => "hidden", "value" => $this->vb17553f86a6e6460083956094e21682b0eb19a5b)) . self::getInput(array("name" => "isms", "type" => "hidden", "value" => implode(";", $this->vf261e0e1babe742f7019d4d5742b8f9a0dc76be1))) . self::getInput(array("name" => "sendedCode", "type" => "hidden", "value" => $this->v19b8b7cad3f484c5fd3981e8d383972bf5b46508));
     if (method_exists($this, "addToPostAdapter")) {
         $i02fcabda2448d40bdb76bd10f9e95950039649ee .= $this->addToPostAdapter(true);
     }
     $i02fcabda2448d40bdb76bd10f9e95950039649ee .= '</form>';
     return $i02fcabda2448d40bdb76bd10f9e95950039649ee;
 }
Exemplo n.º 8
0
 /**
  * Search X2Engine for a record.
  *
  * This is the action called by the search bar in the main menu.
  */
 public function actionSearch()
 {
     ini_set('memory_limit', -1);
     $term = isset($_GET['term']) ? $_GET['term'] : "";
     if (empty($term)) {
         $dataProvider = new CArrayDataProvider(array());
         Yii::app()->user->setFlash('error', Yii::t('app', "Search term cannot be empty."));
         $this->render('search', array('dataProvider' => $dataProvider));
     } else {
         if (substr($term, 0, 1) != "#") {
             $modules = Modules::model()->findAllByAttributes(array('searchable' => 1));
             $comparisons = array();
             $other = array();
             foreach ($modules as $module) {
                 $module->name == 'products' ? $type = ucfirst('Product') : ($type = ucfirst($module->name));
                 $module->name == 'quotes' ? $type = ucfirst('Quote') : ($type = $type);
                 $module->name == 'opportunities' ? $type = ucfirst('Opportunity') : ($type = $type);
                 $criteria = new CDbCriteria();
                 $fields = Fields::model()->findAllByAttributes(array('modelName' => $type, 'searchable' => 1));
                 $temp = array();
                 $fieldNames = array();
                 if (count($fields) < 1) {
                     $criteria->compare('id', '<0', true, 'AND');
                 }
                 foreach ($fields as $field) {
                     $temp[] = $field->id;
                     $fieldNames[] = $field->fieldName;
                     $criteria->compare($field->fieldName, $term, true, "OR");
                     if ($field->type == 'phone') {
                         $tempPhone = preg_replace('/\\D/', '', $term);
                         $phoneLookup = PhoneNumber::model()->findByAttributes(array('modelType' => $field->modelName, 'number' => $tempPhone, 'fieldName' => $field->fieldName));
                         if (isset($phoneLookup)) {
                             $criteria->compare('id', $phoneLookup->modelId, true, "OR");
                         }
                     }
                 }
                 if (Yii::app()->user->getName() != 'admin' && X2Model::model($type)->hasAttribute('visibility') && X2Model::model($type)->hasAttribute('assignedTo')) {
                     $condition = 'visibility="1" OR (assignedTo="Anyone" AND visibility!="0")  OR assignedTo="' . Yii::app()->user->getName() . '"';
                     /* x2temp */
                     $groupLinks = Yii::app()->db->createCommand()->select('groupId')->from('x2_group_to_user')->where('userId=' . Yii::app()->user->getId())->queryColumn();
                     if (!empty($groupLinks)) {
                         $condition .= ' OR assignedTo IN (' . implode(',', $groupLinks) . ')';
                     }
                     $condition .= 'OR (visibility=2 AND assignedTo IN
                         (SELECT username FROM x2_group_to_user WHERE groupId IN
                             (SELECT groupId FROM x2_group_to_user WHERE userId=' . Yii::app()->user->getId() . ')))';
                     $criteria->addCondition($condition);
                 }
                 if ($module->name == 'actions') {
                     $criteria->with = array('actionText');
                     $criteria->compare('actionText.text', $term, true, "OR");
                 }
                 if (class_exists($type)) {
                     $arr = X2Model::model($type)->findAll($criteria);
                     $comparisons[$type] = $temp;
                     $other[$type] = $arr;
                 }
             }
             $high = array();
             $medium = array();
             $low = array();
             $userHigh = array();
             $userMedium = array();
             $userLow = array();
             $records = array();
             $userRecords = array();
             $regEx = "/" . preg_quote($term, '/') . "/i";
             foreach ($other as $key => $recordType) {
                 $fieldList = $comparisons[$key];
                 foreach ($recordType as $otherRecord) {
                     if ($key == 'Actions') {
                         if ($otherRecord->hasAttribute('assignedTo') && $otherRecord->assignedTo == Yii::app()->user->getName()) {
                             $userHigh[] = $otherRecord;
                         } else {
                             $high[] = $otherRecord;
                         }
                     } else {
                         foreach ($fieldList as $field) {
                             $fieldRecord = Fields::model()->findByPk($field);
                             $fieldName = $fieldRecord->fieldName;
                             if (preg_match($regEx, $otherRecord->{$fieldName}) > 0) {
                                 switch ($fieldRecord->relevance) {
                                     case "High":
                                         if (!in_array($otherRecord, $high, true) && !in_array($otherRecord, $medium, true) && !in_array($otherRecord, $low, true) && !in_array($otherRecord, $userHigh, true) && !in_array($otherRecord, $userMedium, true) && !in_array($otherRecord, $userLow, true)) {
                                             if ($otherRecord->hasAttribute('assignedTo') && $otherRecord->assignedTo == Yii::app()->user->getName()) {
                                                 $userHigh[] = $otherRecord;
                                             } else {
                                                 $high[] = $otherRecord;
                                             }
                                         }
                                         break;
                                     case "Medium":
                                         if (!in_array($otherRecord, $high, true) && !in_array($otherRecord, $medium, true) && !in_array($otherRecord, $low, true) && !in_array($otherRecord, $userHigh, true) && !in_array($otherRecord, $userMedium, true) && !in_array($otherRecord, $userLow, true)) {
                                             if ($otherRecord->hasAttribute('assignedTo') && $otherRecord->assignedTo == Yii::app()->user->getName()) {
                                                 $userMedium[] = $otherRecord;
                                             } else {
                                                 $medium[] = $otherRecord;
                                             }
                                         }
                                         break;
                                     case "Low":
                                         if (!in_array($otherRecord, $high, true) && !in_array($otherRecord, $medium, true) && !in_array($otherRecord, $low, true) && !in_array($otherRecord, $userHigh, true) && !in_array($otherRecord, $userMedium, true) && !in_array($otherRecord, $userLow, true)) {
                                             if ($otherRecord->hasAttribute('assignedTo') && $otherRecord->assignedTo == Yii::app()->user->getName()) {
                                                 $userLow[] = $otherRecord;
                                             } else {
                                                 $low[] = $otherRecord;
                                             }
                                         }
                                         break;
                                     default:
                                         if ($otherRecord->hasAttribute('assignedTo') && $otherRecord->assignedTo == Yii::app()->user->getName()) {
                                             $userLow[] = $otherRecord;
                                         } else {
                                             $low[] = $otherRecord;
                                         }
                                 }
                             } elseif ($fieldRecord->type == 'phone') {
                                 $tempPhone = preg_replace('/\\D/', '', $term);
                                 if (strlen($tempPhone) == 10) {
                                     $phoneLookup = PhoneNumber::model()->findByAttributes(array('modelType' => $fieldRecord->modelName, 'number' => $tempPhone, 'fieldName' => $fieldName));
                                     if (!in_array($otherRecord, $high, true) && !in_array($otherRecord, $medium, true) && !in_array($otherRecord, $low, true) && !in_array($otherRecord, $userHigh, true) && !in_array($otherRecord, $userMedium, true) && !in_array($otherRecord, $userLow, true)) {
                                         if (isset($phoneLookup) && $otherRecord->id == $phoneLookup->modelId) {
                                             if ($otherRecord->hasAttribute('assignedTo') && $otherRecord->assignedTo == Yii::app()->user->getName()) {
                                                 $userHigh[] = $otherRecord;
                                             } else {
                                                 $high[] = $otherRecord;
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             $records = array_merge($high, $medium);
             $records = array_merge($records, $low);
             $userRecords = array_merge($userHigh, $userMedium);
             $userRecords = array_merge($userRecords, $userLow);
             $records = array_merge($userRecords, $records);
             $records = Record::convert($records, false);
             if (count($records) == 1) {
                 // Only one match, so go straight to it.
                 //
                 // The record's corresponding model class must have
                 // X2LinkableBehavior for this to be possible.
                 if (!empty($records[0]['#recordUrl'])) {
                     $this->redirect($records[0]['#recordUrl']);
                 }
             }
             $dataProvider = new CArrayDataProvider($records, array('id' => 'id', 'pagination' => array('pageSize' => Profile::getResultsPerPage())));
             $this->render('search', array('records' => $records, 'dataProvider' => $dataProvider, 'term' => $term));
         } else {
             Yii::app()->user->setState('vcr-list', $term);
             $_COOKIE['vcr-list'] = $term;
             $tagQuery = "\n                    SELECT * \n                    FROM x2_tags\n                    WHERE tag=:tag\n                    group BY tag, type, itemId";
             $params = array(':tag' => $term);
             // group by type and itemId to prevent display of duplicate tags
             $sql = Yii::app()->db->createCommand($tagQuery);
             $totalItemCount = Yii::app()->db->createCommand("\n                    SELECT count(*)\n                    FROM ({$tagQuery}) as t1;\n                ")->queryScalar($params);
             $results = new CSqlDataProvider($sql, array('totalItemCount' => $totalItemCount, 'sort' => array('defaultOrder' => 'timestamp DESC'), 'pagination' => array('pageSize' => Profile::getResultsPerPage()), 'params' => $params));
             $this->render('searchTags', array('tags' => $results, 'term' => $term));
         }
     }
 }
 /**
  * Gets the expected cost category of a short number (however, nothing is implied about its
  * validity). If the country calling code is unique to a region, this method behaves exactly the
  * same as {@link #getExpectedCostForRegion(String, String)}. However, if the country calling
  * code is shared by multiple regions, then it returns the highest cost in the sequence
  * PREMIUM_RATE, UNKNOWN_COST, STANDARD_RATE, TOLL_FREE. The reason for the position of
  * UNKNOWN_COST in this order is that if a number is UNKNOWN_COST in one region but STANDARD_RATE
  * or TOLL_FREE in another, its expected cost cannot be estimated as one of the latter since it
  * might be a PREMIUM_RATE number.
  *
  * For example, if a number is STANDARD_RATE in the US, but TOLL_FREE in Canada, the expected cost
  * returned by this method will be STANDARD_RATE, since the NANPA countries share the same country
  * calling code.
  *
  * Note: If the region from which the number is dialed is known, it is highly preferable to call
  * {@link #getExpectedCostForRegion(String, String)} instead.
  *
  * @param $number PhoneNumber the short number for which we want to know the expected cost category
  * @return int the highest expected cost category of the short number in the region(s) with the given
  *     country calling code
  */
 public function getExpectedCost(PhoneNumber $number)
 {
     $regionCodes = $this->phoneUtil->getRegionCodesForCountryCode($number->getCountryCode());
     if (count($regionCodes) == 0) {
         return ShortNumberCost::UNKNOWN_COST;
     }
     $shortNumber = $this->phoneUtil->getNationalSignificantNumber($number);
     if (count($regionCodes) == 1) {
         return $this->getExpectedCostForRegion($shortNumber, $regionCodes[0]);
     }
     $cost = ShortNumberCost::TOLL_FREE;
     foreach ($regionCodes as $regionCode) {
         $costForRegion = $this->getExpectedCostForRegion($shortNumber, $regionCode);
         switch ($costForRegion) {
             case ShortNumberCost::PREMIUM_RATE:
                 return ShortNumberCost::PREMIUM_RATE;
             case ShortNumberCost::UNKNOWN_COST:
                 $cost = ShortNumberCost::UNKNOWN_COST;
                 break;
             case ShortNumberCost::STANDARD_RATE:
                 if ($cost != ShortNumberCost::UNKNOWN_COST) {
                     $cost = ShortNumberCost::STANDARD_RATE;
                 }
                 break;
             case ShortNumberCost::TOLL_FREE:
                 // Do nothing
                 break;
         }
     }
     return $cost;
 }
Exemplo n.º 10
0
 /**
  * Records a phone call as a notification.
  *
  * Given a phone number, if a contact matching that phone number exists, a
  * notification assigned to that contact's assignee will be created.
  * Software-based telephony systems such as Asterisk can thus immediately
  * notify sales reps of a phone call by making a cURL request to a url
  * formatted as follows:
  *
  * api/voip/data/[phone number]
  *
  * (Note: the phone number itself must not contain anything but digits, i.e.
  * no periods or dashes.)
  *
  * For Asterisk, one possible integration method is to insert into the
  * dialplan, at the appropriate position, a call to a script that uses
  * {@link http://phpagi.sourceforge.net/ PHPAGI} to extract the phone
  * number. The script can then make the necessary request to this action.
  * @param bool $actionHist If set to 1, create an action history item for the contact.
  */
 public function actionVoip($actionHist = 0)
 {
     if (isset($_GET['data'])) {
         $matches = array();
         if (preg_match('/\\d{10,}/', $_GET['data'], $matches)) {
             $number = ltrim($matches[0], '1');
             $phoneCrit = new CDbCriteria(array('condition' => "modelType='Contacts' AND number LIKE :number", 'params' => array(':number' => "%{$number}%")));
             $phoneCrit->join = 'join x2_contacts on modelId=x2_contacts.id AND ' . Contacts::model()->getHiddenCondition('x2_contacts');
             $phoneNumber = PhoneNumber::model()->find($phoneCrit);
             if (!empty($phoneNumber)) {
                 $contact = X2Model::model('Contacts')->findByPk($phoneNumber->modelId);
                 if (isset($contact)) {
                     $contact->disableBehavior('changelog');
                     $contact->updateLastActivity();
                     $assignees = array($contact->assignedTo);
                     if ($contact->assignedTo == 'Anyone' || $contact->assignedTo == null) {
                         $users = User::model()->findAll();
                         $assignees = array_map(function ($u) {
                             return $u->username;
                         }, $users);
                     }
                     $multiUser = count($assignees) > 1;
                     $usersSuccess = array();
                     $usersFailure = array();
                     // Format the phone number:
                     $formattedNumber = '';
                     $strNumber = (string) $number;
                     $strl = strlen($strNumber);
                     $formattedNumber = substr($strNumber, $strl - 4, $strl);
                     $formattedNumber = substr($strNumber, $strl - 7, 3) . "-{$formattedNumber}";
                     if ($strl >= 10) {
                         $formattedNumber = substr($strNumber, $strl - 10, 3) . "-{$formattedNumber}";
                         if ($strl > 10) {
                             $formattedNumber = substr($strNumber, 0, $strl - 10) . "-{$formattedNumber}";
                         }
                     }
                     $time = time();
                     // Create notifications:
                     foreach ($assignees as $user) {
                         $notif = new Notification();
                         $notif->type = 'voip_call';
                         $notif->user = $user;
                         $notif->modelType = 'Contacts';
                         $notif->modelId = $contact->id;
                         $notif->value = $formattedNumber;
                         $notif->createDate = $time;
                         if ($notif->save()) {
                             $usersSuccess[] = $user;
                         } else {
                             $usersFailure = array();
                         }
                     }
                     if ($actionHist) {
                         // Create an action:
                         $action = new Actions();
                         $action->assignedTo = 'Anyone';
                         $action->visibility = 1;
                         $action->associationId = $contact->id;
                         $action->associationType = 'contacts';
                         $action->associationName = $contact->name;
                         $action->dueDate = $time;
                         $action->createDate = $time;
                         $action->completeDate = $time;
                         $action->lastUpdated = $time;
                         $action->type = 'call';
                         $action->complete = 'Yes';
                         $action->completedBy = 'Anyone';
                         $action->save();
                         $action->actionText = Yii::t('app', 'Phone system reported inbound call from contact.');
                     }
                     $failure = count($usersSuccess) == 0;
                     $partialFailure = count($usersFailure) > 0;
                     if ($failure) {
                         $message = 'Saving notifications failed.';
                     } else {
                         /*X2Flow::trigger('RecordVoipInboundTrigger', array(
                         			'model' => $contact,
                         			'number' => $matches[0]
                         		));*/
                         $message = 'Notifications created for user(s): ' . implode(',', $usersSuccess);
                         if ($partialFailure) {
                             $message .= '; saving notifications failed for users(s): ' . implode(',', $usersFailure);
                         }
                     }
                     // Create an event record for the feed:
                     $event = new Events();
                     $event->type = 'voip_call';
                     $event->associationType = get_class($contact);
                     $event->associationId = $contact->id;
                     $event->save();
                     $this->_sendResponse($failure ? 500 : 200, $message);
                 } else {
                     $this->_sendResponse(404, 'Phone number record refers to a contact that no longer exists.');
                 }
             } else {
                 $this->_sendResponse(404, 'No matching phone number found.');
                 // $notif = new Notification;
                 // $notif->type = 'voip_call';
                 // $notif->user = ?;
                 // $notif->modelType = 'Contacts';
                 // $notif->value = $matches[0];
                 // $notif->createDate = time();
                 // $notif->save();
             }
         } else {
             $this->_sendResponse(400, 'Invalid phone number format.');
         }
     } else {
         $this->_sendResponse(400, 'Phone number required as "data" URL parameter.');
     }
 }
 function populate()
 {
     parent::populate();
     $this->address = Address::factory_address($this->id);
     $this->phone_numbers = PhoneNumber::factory_phone_numbers($this->id);
 }
Exemplo n.º 12
0
 private function generate_extension()
 {
     if (Request::segment(1) == "register") {
         $domain_id = Cookie::get('domain_hash');
     } else {
         $domain_id = Request::segment(2) == "manage" ? Request::segment(3) : Auth::user()->domain_id;
     }
     $extensions = explode(",", str_replace(" ", "", Config::get('settings.reserved_extension')));
     $users = User::where('domain_id', $domain_id)->get();
     foreach ($users as $user) {
         foreach (PhoneNumber::where('user_id', $user['id'])->get() as $phone_number) {
             $extensions[] = $phone_number['extension'];
         }
     }
     $rand_ext = rand(100000, 999999);
     if (in_array($rand_ext, $extensions) && Cookie::get('rndext') == $rand_ext) {
         $this->generate_extension();
     } else {
         return $rand_ext;
     }
 }
 /**
  * Merges the information from another phone number into this phone number.
  *
  * @param PhoneNumber $other The phone number to copy.
  *
  * @return PhoneNumber This PhoneNumber instance, for chaining method calls.
  */
 public function mergeFrom(PhoneNumber $other)
 {
     if ($other->hasCountryCode()) {
         $this->setCountryCode($other->getCountryCode());
     }
     if ($other->hasNationalNumber()) {
         $this->setNationalNumber($other->getNationalNumber());
     }
     if ($other->hasExtension()) {
         $this->setExtension($other->getExtension());
     }
     if ($other->hasItalianLeadingZero()) {
         $this->setItalianLeadingZero($other->isItalianLeadingZero());
     }
     if ($other->hasNumberOfLeadingZeros()) {
         $this->setNumberOfLeadingZeros($other->getNumberOfLeadingZeros());
     }
     if ($other->hasRawInput()) {
         $this->setRawInput($other->getRawInput());
     }
     if ($other->hasCountryCodeSource()) {
         $this->setCountryCodeSource($other->getCountryCodeSource());
     }
     if ($other->hasPreferredDomesticCarrierCode()) {
         $this->setPreferredDomesticCarrierCode($other->getPreferredDomesticCarrierCode());
     }
     return $this;
 }
Exemplo n.º 14
0
 function make_call_path($to, $callerid, $path, $rest_access)
 {
     $twilio = new TwilioRestClient($this->twilio_sid, $this->twilio_token);
     $recording_url = site_url("twiml/redirect/{$path}/{$rest_access}");
     $response = $twilio->request("Accounts/{$this->twilio_sid}/Calls", 'POST', array("Caller" => PhoneNumber::normalizePhoneNumberToE164($callerid), "Called" => PhoneNumber::normalizePhoneNumberToE164($to), "Url" => $recording_url));
     if ($response->IsError) {
         error_log($from);
         error_log(var_export($response, true));
         throw new VBX_CallException($response->ErrorMessage);
     }
 }
Exemplo n.º 15
0
<?php

ob_start();
require_once "includes/functions.php";
$phoneNumber = new PhoneNumber();
if (array_key_exists('delete_phone_numbers', $_POST)) {
    $insert_id = $_POST['insert_id'];
    $phoneNumber->delete();
    header("Location: portfolio.php?insert_id=" . $insert_id);
}
if (array_key_exists('modify_phone_numbers', $_POST)) {
    $phoneNumbers = $phoneNumber->getPhoneNumbersFromPhoneId($_POST);
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <link rel="stylesheet" type="text/css" href="css/main.css"/>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Phone Number Update</title>
</head>

<body>
<div class="container">
    <ul class="nav">
        <li><a href="listcontacts.php">List of All Contacts</a></li>
    </ul>
    <div class="header">
    </div><!-- end .header -->
    <div class="content">
Exemplo n.º 16
0
 /**
  * Runs when a model is saved.
  * Scans attributes for phone numbers and index them in <tt>x2_phone_numbers</tt>.
  * Updates <tt>x2_relationships</tt> table based on link type fields.
  * Fires onAfterSave event.
  */
 public function afterSave()
 {
     if ($this->_runAfterCreate) {
         $this->afterCreate();
     } else {
         $this->afterUpdate();
     }
     $phoneFields = array();
     $linkFields = array();
     // look through fields for phone numbers and relationships
     foreach (self::$_fields[$this->tableName()] as &$_field) {
         if ($_field->type === 'phone') {
             $phoneFields[$_field->fieldName] = $this->getAttribute($_field->fieldName);
         } elseif ($_field->type === 'link') {
             $nameAndId = Fields::nameAndId($this->getAttribute($_field->fieldName));
             $linkFields[$_field->fieldName] = array('id' => $nameAndId[1], 'type' => $_field->linkType);
         }
     }
     // deal with phone numbers
     if (count($phoneFields)) {
         X2Model::model('PhoneNumber')->deleteAllByAttributes(array('modelId' => $this->id, 'modelType' => get_class($this)));
     }
     // clear out old phone numbers
     foreach ($phoneFields as $field => &$number) {
         // create new entries in x2_phone_numbers
         if (!empty($number)) {
             $num = new PhoneNumber();
             $num->number = preg_replace('/\\D/', '', $number);
             // eliminate everything other than digits
             $num->modelId = $this->id;
             $num->modelType = get_class($this);
             $num->fieldName = $field;
             $num->save();
         }
     }
     /////////////// deal with relationships ///////////////
     $oldAttributes = $this->getOldAttributes();
     $relationSql = '(firstType=:type1 AND firstId=:id1 AND secondType=:type2 AND secondId=:id2) OR
          (firstType=:type2 AND firstId=:id2 AND secondType=:type1 AND secondId=:id1)';
     foreach ($linkFields as $fieldName => &$relation) {
         list($oldLinkName, $oldLinkId) = Fields::nameAndId(isset($oldAttributes[$fieldName]) ? $oldAttributes[$fieldName] : '');
         if ($relation['id'] == $oldLinkId) {
             // skip field if it hasn't changed
             continue;
         }
         // forget old relationship (wouldn't it be nice...)
         if (!empty($oldLinkId)) {
             CActiveRecord::model('Relationships')->deleteAll($relationSql, array(':type1' => get_class($this), ':id1' => $this->id, ':type2' => $relation['type'], ':id2' => $oldLinkId));
         }
         // save new relationship
         if (!empty($relation['id']) && ctype_digit((string) $relation['id'])) {
             if (!CActiveRecord::model('Relationships')->exists($relationSql, array(':type1' => get_class($this), ':id1' => $this->id, ':type2' => $relation['type'], ':id2' => $relation['id']))) {
                 $rel = new Relationships();
                 $rel->firstType = get_class($this);
                 $rel->secondType = $relation['type'];
                 $rel->firstId = $this->id;
                 $rel->secondId = $relation['id'];
                 $rel->save();
             }
         }
     }
     parent::afterSave();
     // raise onAfterSave event for behaviors, such as X2ChangeLogBehavior
 }
Exemplo n.º 17
0
 public static function handlerSSSourceData(Audit $audit)
 {
     $data = array();
     if ($audit->objectClass != 'ESignature') {
         return $data;
     }
     $eSignature = new ESignature();
     $eSignature->eSignatureId = $audit->objectId;
     $eSignature->populate();
     if ($eSignature->objectClass != 'Medication') {
         return $data;
     }
     $data['_audit'] = $audit;
     $medication = new Medication();
     $medication->medicationId = (int) $eSignature->objectId;
     $medication->populate();
     $data['PrescriberOrderNumber'] = $medication->medicationId;
     $medData = array();
     $medData['DrugDescription'] = $medication->description;
     $medData['Strength'] = $medication->strength;
     $medData['StrengthUnits'] = $medication->unit;
     $medData['Quantity'] = $medication->quantity;
     $medData['Directions'] = $medication->directions;
     $medData['Refills'] = $medication->refills;
     $medData['Substitutions'] = $medication->substitution;
     $medData['WrittenDate'] = date('Ymd', strtotime($medication->datePrescribed));
     $data['medication'] = $medData;
     $pharmacy = new Pharmacy();
     $pharmacy->pharmacyId = $medication->pharmacyId;
     $pharmacy->populate();
     $pharmacyData = array();
     $pharmacyData['NCPDPID'] = $pharmacy->NCPDPID;
     $pharmacyData['StoreName'] = $pharmacy->StoreName;
     $pharmacyData['AddressLine1'] = $pharmacy->AddressLine1 . ' ' . $pharmacy->AddressLine2;
     $pharmacyData['City'] = $pharmacy->City;
     $pharmacyData['State'] = $pharmacy->State;
     $pharmacyData['ZipCode'] = $pharmacy->Zip;
     $pharmacyData['PhoneNumber'] = $pharmacy->PhonePrimary;
     $data['pharmacy'] = $pharmacyData;
     $provider = new Provider();
     $provider->personId = $medication->prescriberPersonId;
     $provider->populate();
     $prescriberData = array();
     $prescriberData['DEANumber'] = $provider->deaNumber;
     $prescriberData['SPI'] = $provider->sureScriptsSPI;
     $prescriberData['ClinicName'] = '';
     $prescriberData['LastName'] = $provider->person->lastName;
     $prescriberData['FirstName'] = $provider->person->firstName;
     $prescriberData['Suffix'] = '';
     $address = new Address();
     $address->personId = $provider->personId;
     $address->populateWithPersonId();
     $prescriberData['AddressLine1'] = $address->line1 . ' ' . $address->line2;
     $prescriberData['City'] = $address->city;
     $prescriberData['State'] = 'AZ';
     //$address->state;
     $prescriberData['ZipCode'] = $address->postalCode;
     $phoneNumber = new PhoneNumber();
     $phoneNumber->personId = $provider->personId;
     $phoneNumber->populateWithPersonId();
     $prescriberData['PhoneNumber'] = $phoneNumber->number;
     $data['prescriber'] = $prescriberData;
     $patient = new Patient();
     $patient->personId = $medication->personId;
     $patient->populate();
     $patientData = array();
     $patientData['LastName'] = $patient->person->lastName;
     $patientData['FirstName'] = $patient->person->firstName;
     $enumeration = new Enumeration();
     $enumeration->enumerationId = $patient->person->gender;
     $enumeration->populate();
     $gender = $enumeration->key;
     $patientData['Gender'] = $gender;
     $patientData['DateOfBirth'] = date('Ymd', strtotime($patient->person->dateOfBirth));
     $address = new Address();
     $address->personId = $patient->personId;
     $address->populateWithPersonId();
     $patientData['AddressLine1'] = $address->line1 . ' ' . $address->line2;
     $patientData['City'] = $address->city;
     $patientData['State'] = 'AZ';
     //$address->state;
     $patientData['ZipCode'] = $address->postalCode;
     $phoneNumber = new PhoneNumber();
     $phoneNumber->personId = $patient->personId;
     $phoneNumber->populateWithPersonId();
     $patientData['PhoneNumber'] = $phoneNumber->number;
     $data['patient'] = $patientData;
     return $data;
     $ret = array();
     foreach ($data as $type => $row) {
         if (is_array($row)) {
             foreach ($row as $field => $value) {
                 $key = $type . '[' . $field . ']';
                 $ret[$key] = $value;
             }
         } else {
             $ret[$type] = $row;
         }
     }
     return $ret;
 }
Exemplo n.º 18
0
 /**
  * Start an outbound call
  *
  * @param string $from - the user making the call, this is the device that'll be called first
  * @param string $to - the call destination
  * @param string $callerid - the number to use as the caller id
  * @param string $rest_access - token to authenticate the twiml request
  * @return void
  */
 public function make_call($from, $to, $callerid, $rest_access)
 {
     try {
         PhoneNumber::validatePhoneNumber($from);
         // handle being passed an email address for calls to browser clients
         if (!filter_var($to, FILTER_VALIDATE_EMAIL)) {
             PhoneNumber::validatePhoneNumber($to);
         }
     } catch (PhoneNumberException $e) {
         throw new VBX_CallException($e->getMessage());
     }
     // don't normalize email addresses that are used to identify browser clients
     if (!filter_var($to, FILTER_VALIDATE_EMAIL)) {
         $to = PhoneNumber::normalizePhoneNumberToE164($to);
     }
     $callerid = PhoneNumber::normalizePhoneNumberToE164($callerid);
     $from = PhoneNumber::normalizePhoneNumberToE164($from);
     $twiml_url = site_url("twiml/dial") . '?' . http_build_query(compact('callerid', 'to', 'rest_access'));
     try {
         $account = OpenVBX::getAccount();
         $account->calls->create($callerid, $from, $twiml_url);
     } catch (Exception $e) {
         throw new VBX_CallException($e->getMessage());
     }
 }
 /**
  * Appends the formatted extension of a phone number to formattedNumber, if the phone number had
  * an extension specified.
  */
 private function maybeAppendFormattedExtension(PhoneNumber $number, $metadata, $numberFormat, &$formattedNumber)
 {
     if ($number->hasExtension() && strlen($number->getExtension()) > 0) {
         if ($numberFormat == PhoneNumberFormat::RFC3966) {
             $formattedNumber .= self::RFC3966_EXTN_PREFIX . $number->getExtension();
         } else {
             if (!empty($metadata) && $metadata->hasPreferredExtnPrefix()) {
                 $formattedNumber .= $metadata->getPreferredExtnPrefix() . $number->getExtension();
             } else {
                 $formattedNumber .= self::DEFAULT_EXTN_PREFIX . $number->getExtension();
             }
         }
     }
 }
Exemplo n.º 20
0
 public function getPhoneNumbers($autoFix = true)
 {
     $phoneNumber = new PhoneNumber();
     $phoneNumber->personId = $this->person_id;
     return $phoneNumber->getIteratorByPersonId();
 }
Exemplo n.º 21
0
 public function _editAppointment(array $params, $action = 'new')
 {
     $appointmentId = isset($params['appointmentId']) ? (int) $params['appointmentId'] : 0;
     $appointment = new Appointment();
     $appointment->appointmentId = $appointmentId;
     $date = isset($params['date']) ? $params['date'] : '';
     if ($appointmentId > 0 && $appointment->populate()) {
         $filter = $this->getCurrentDisplayFilter();
         $start = explode(' ', date('Y-m-d H:i', strtotime($appointment->start)));
         $date = $start[0];
         $appointment->start = $start[1];
         $appointment->end = date('H:i', strtotime($appointment->end));
         $recordNumber = $appointment->patient->record_number;
         $patientName = $appointment->patient->displayName;
         $this->view->patient = "{$patientName} #{$recordNumber} PID:{$appointment->patient->person_id}";
     } else {
         $start = isset($params['start']) ? $params['start'] : self::FILTER_TIME_START;
         $appointment->start = $start;
         $appointment->end = date('H:i', strtotime('+1 hour', strtotime($start)));
         $appointment->providerId = isset($params['providerId']) ? (int) $params['providerId'] : 0;
         $appointment->roomId = isset($params['roomId']) ? (int) $params['roomId'] : 0;
     }
     $this->view->date = $date;
     $form = new WebVista_Form(array('name' => $action . '-appointment'));
     $form->setAction(Zend_Registry::get('baseUrl') . 'calendar.raw/process-' . $action . '-appointment');
     $form->loadORM($appointment, 'Appointment');
     $form->setWindow('windowAppointmentId');
     $this->view->form = $form;
     $this->view->reasons = PatientNote::listReasons();
     $phones = array();
     $phone = new PhoneNumber();
     $phoneIterator = $phone->getIteratorByPersonId($appointment->patientId);
     foreach ($phoneIterator as $row) {
         $phones[] = $row->number;
     }
     $this->view->phones = $phones;
     $appointmentTemplate = new AppointmentTemplate();
     $this->view->appointmentReasons = $appointmentTemplate->getAppointmentReasons();
     $this->view->appointment = $appointment;
     $this->view->callbackId = $this->_getParam('callbackId', '');
     $this->render('appointment');
 }
Exemplo n.º 22
0
 public function testParseNationalNumber()
 {
     // National prefix attached.
     $this->assertEquals(self::$nzNumber, $this->phoneUtil->parse("033316005", RegionCode::NZ));
     $this->assertEquals(self::$nzNumber, $this->phoneUtil->parse("33316005", RegionCode::NZ));
     // National prefix attached and some formatting present.
     $this->assertEquals(self::$nzNumber, $this->phoneUtil->parse("03-331 6005", RegionCode::NZ));
     $this->assertEquals(self::$nzNumber, $this->phoneUtil->parse("03 331 6005", RegionCode::NZ));
     // Testing international prefixes.
     // Should strip country calling code.
     $this->assertEquals(self::$nzNumber, $this->phoneUtil->parse("0064 3 331 6005", RegionCode::NZ));
     // Try again, but this time we have an international number with Region Code US. It should
     // recognise the country calling code and parse accordingly.
     $this->assertEquals(self::$nzNumber, $this->phoneUtil->parse("01164 3 331 6005", RegionCode::US));
     $this->assertEquals(self::$nzNumber, $this->phoneUtil->parse("+64 3 331 6005", RegionCode::US));
     // We should ignore the leading plus here, since it is not followed by a valid country code but
     // instead is followed by the IDD for the US.
     $this->assertEquals(self::$nzNumber, $this->phoneUtil->parse("+01164 3 331 6005", RegionCode::US));
     $this->assertEquals(self::$nzNumber, $this->phoneUtil->parse("+0064 3 331 6005", RegionCode::NZ));
     $this->assertEquals(self::$nzNumber, $this->phoneUtil->parse("+ 00 64 3 331 6005", RegionCode::NZ));
     $nzNumber = new PhoneNumber();
     $nzNumber->setCountryCode(64)->setNationalNumber(64123456);
     $this->assertEquals($nzNumber, $this->phoneUtil->parse("64(0)64123456", RegionCode::NZ));
     // Check that using a "/" is fine in a phone number.
     $this->assertEquals(self::$deNumber, $this->phoneUtil->parse("301/23456", RegionCode::DE));
     $usNumber = new PhoneNumber();
     // Check it doesn't use the '1' as a country calling code when parsing if the phone number was
     // already possible.
     $usNumber->setCountryCode(1)->setNationalNumber(1234567890);
     $this->assertEquals($usNumber, $this->phoneUtil->parse("123-456-7890", RegionCode::US));
     // Test star numbers. Although this is not strictly valid, we would like to make sure we can
     // parse the output we produce when formatting the number.
     $this->assertEquals(self::$jpStarNumber, $this->phoneUtil->parse("+81 *2345", RegionCode::JP));
     // Test national number bigger than max 32-bit signed integer
     $inNumber = new PhoneNumber();
     $inNumber->setCountryCode(91)->setNationalNumber(9876543210);
     $this->assertEquals($inNumber, $this->phoneUtil->parse("9876543210", RegionCode::IN));
 }
Exemplo n.º 23
0
 function save()
 {
     if (!strlen($this->name)) {
         throw new VBX_DeviceException('Name is empty');
     }
     try {
         PhoneNumber::validatePhoneNumber($this->value);
     } catch (PhoneNumberException $e) {
         throw new VBX_DeviceException($e->getMessage());
     }
     return parent::save();
 }
Exemplo n.º 24
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function getDelete($id)
 {
     $domain = Domain::find($id);
     $domain->delete();
     $user = User::whereDomainId($id)->first();
     if ($user) {
         $user->delete();
         $phone_number = PhoneNumber::whereUserId($user->id)->first();
         $phone_number->delete();
         Event::fire('logger', array(array('phone_number_remove', array('id' => $phone_number->id, 'extension' => $phone_number->extension), 2)));
     }
     Event::fire('logger', array(array('domain_remove', array('id' => $id, 'domain_name' => $domain->domain), 2)));
     return Output::push(array('path' => 'domain', 'messages' => array('success' => _('Domain has been deleted'))));
 }
Exemplo n.º 25
0
 private function f772351b9d0754930a8b7eff64f708a7494ae5492()
 {
     $ia8ae96136aabf34f35206c26b90f1af9088e8044 = $i82ed3493150f3db4982291e587a57d15be62dd4e = "";
     $iced8cbcfca3c880f0f157e119d1cc6f8691e7e89 = $this->f922aad2a422f277c9ae988bc616f180c33de5aa8($this->v7f261894a2f47535041bff3d2f42c3969e819d98, $this->vab6a314decb74f5c532ecb082cfeb1655b9e98bb);
     if ($this->v27c847d6bec864e327cd4686358e7c1e1de59e9d != -1) {
         $i27c847d6bec864e327cd4686358e7c1e1de59e9d = $this->v27c847d6bec864e327cd4686358e7c1e1de59e9d;
     } elseif (isset($iced8cbcfca3c880f0f157e119d1cc6f8691e7e89["senderID"]) && PhoneNumber::isPhoneNumber($iced8cbcfca3c880f0f157e119d1cc6f8691e7e89["senderID"])) {
         $i27c847d6bec864e327cd4686358e7c1e1de59e9d = $iced8cbcfca3c880f0f157e119d1cc6f8691e7e89["senderID"];
         if ($iced8cbcfca3c880f0f157e119d1cc6f8691e7e89["senderID"] != "") {
             $i82ed3493150f3db4982291e587a57d15be62dd4e = " class=\"hidden\"";
             $ia8ae96136aabf34f35206c26b90f1af9088e8044 = "";
         } else {
             $i82ed3493150f3db4982291e587a57d15be62dd4e = "";
         }
     } else {
         $i27c847d6bec864e327cd4686358e7c1e1de59e9d = -1;
     }
     if (strlen($this->va8ae96136aabf34f35206c26b90f1af9088e8044) > 0 && $this->v27c847d6bec864e327cd4686358e7c1e1de59e9d == -1) {
         $ia8ae96136aabf34f35206c26b90f1af9088e8044 = $this->va8ae96136aabf34f35206c26b90f1af9088e8044;
         $i27c847d6bec864e327cd4686358e7c1e1de59e9d = -1;
         $i82ed3493150f3db4982291e587a57d15be62dd4e = "";
     }
     if ($this->ve5aa63528fa84652be7d86b274757e6ca3554317) {
         $i82ed3493150f3db4982291e587a57d15be62dd4e = " class=\"hidden\"";
         $ib30dc1d4ae198c05d813e50a0f7f78c8d966750c = " class=\"hidden\"";
         $ice3aeffb62401a3b61082f8cdfe9d0cc49126032 = "";
     } else {
         $ib30dc1d4ae198c05d813e50a0f7f78c8d966750c = "";
         $ice3aeffb62401a3b61082f8cdfe9d0cc49126032 = " class=\"hidden\"";
     }
     $iae8c74e5273dec25096dbae362493a9f609ecfc8 = ' <form action="" method="post"> <table class="formTable profile"> <tbody> <tr' . $ib30dc1d4ae198c05d813e50a0f7f78c8d966750c . '> <td>' . self::getLabel(v_smswizard_existingown, 'class="bold"') . '</td> <td>' . self::getSelect(array("name" => "ownsenderID", "id" => "selectOwnSender", "onchange" => "ownSender();"), $this->fe6384d66988a761d4c5503e6a331406deb348e73(), $i27c847d6bec864e327cd4686358e7c1e1de59e9d) . ' *</td> </tr> <tr id="newOwnSender"' . $i82ed3493150f3db4982291e587a57d15be62dd4e . '> <td>' . self::getLabel(v_smswizard_newownnrid, 'class="bold"') . '</td> <td>' . self::getInput(array("name" => "newownsenderID", "type" => "text", "value" => $ia8ae96136aabf34f35206c26b90f1af9088e8044)) . ' * ' . self::getNote(v_smswizard_intformat) . '</td> </tr> <tr id="newOwnSender"' . $ice3aeffb62401a3b61082f8cdfe9d0cc49126032 . '> <td>' . self::getLabel(v_smswizard_smscode, 'class="bold"') . '</td> <td>' . self::getInput(array("name" => "validateCode", "type" => "text", "value" => $this->v31f6359ed56e16253e2214540e9a74aa67a79f38)) . ' *</td> </tr> <tr> <td></td> <td>' . self::getInput(array("name" => "submitAddOwnNumberSenderID", "type" => "submit", "value" => v_smswizard_confirm)) . '</td> </tr> </tbody> </table> <div class="small note"><sup>*</sup> ' . v_adminsmsprofile_required . '</div>' . self::getInput(array("name" => "info", "type" => "hidden", "value" => $this->vfb4fc7683b8a345aa04bae018e72487978470e18)) . self::getInput(array("name" => "country", "type" => "hidden", "value" => $this->vab6a314decb74f5c532ecb082cfeb1655b9e98bb)) . self::getInput(array("name" => "type", "type" => "hidden", "value" => $this->v7f261894a2f47535041bff3d2f42c3969e819d98)) . self::getInput(array("name" => "action", "type" => "hidden", "value" => $this->v10362d0b58d010e644ea05e4195fc6f67d72e348)) . self::getInput(array("name" => "isms", "type" => "hidden", "value" => implode(";", $this->v13eb3507bfa321384575c03ba80ea011ee4d3321))) . self::getInput(array("name" => "sendedCode", "type" => "hidden", "value" => $this->ve5aa63528fa84652be7d86b274757e6ca3554317));
     if (method_exists($this, "addToPostAdapter")) {
         $iae8c74e5273dec25096dbae362493a9f609ecfc8 .= $this->addToPostAdapter(true);
     }
     $iae8c74e5273dec25096dbae362493a9f609ecfc8 .= '</form>';
     return $iae8c74e5273dec25096dbae362493a9f609ecfc8;
 }
Exemplo n.º 26
0
 public function getPhoneNumbers()
 {
     $ret = array();
     $phoneNumber = PhoneNumber::autoFixNumber($this->phone_number);
     // TE
     $ret[] = array('number' => $phoneNumber, 'type' => 'TE');
     $fax = PhoneNumber::autoFixNumber($this->fax);
     // FX
     if (strlen($fax) > 0) {
         $ret[] = array('number' => $fax, 'type' => 'FX');
     }
     return $ret;
 }
Exemplo n.º 27
0
 /**
  * Attempts to extract a valid number from a phone number that is too long to be valid, and resets
  * the PhoneNumber object passed in to that valid version. If no valid number could be extracted,
  * the PhoneNumber object passed in will not be modified.
  * @param PhoneNumber $number a PhoneNumber object which contains a number that is too long to be valid.
  * @return boolean true if a valid phone number can be successfully extracted.
  */
 public function truncateTooLongNumber(PhoneNumber $number)
 {
     if ($this->isValidNumber($number)) {
         return true;
     }
     $numberCopy = new PhoneNumber();
     $numberCopy->mergeFrom($number);
     $nationalNumber = $number->getNationalNumber();
     do {
         $nationalNumber = floor($nationalNumber / 10);
         $numberCopy->setNationalNumber($nationalNumber);
         if ($this->isPossibleNumberWithReason($numberCopy) == ValidationResult::TOO_SHORT || $nationalNumber == 0) {
             return false;
         }
     } while (!$this->isValidNumber($numberCopy));
     $number->setNationalNumber($nationalNumber);
     return true;
 }
Exemplo n.º 28
0
 protected function _checkCurrentLocation(Medication $medication)
 {
     $identity = Zend_Auth::getInstance()->getIdentity();
     $personId = (int) $identity->personId;
     $building = Building::getBuildingDefaultLocation($personId);
     $ret = false;
     if ($building->buildingId > 0) {
         $eprescriber = new EPrescriber();
         $eprescriber->populateWithBuildingProvider((int) $building->buildingId, $personId);
         $location = 'for location: ' . $building->practice->name . '->' . $building->name;
         $err = $medication->summary . ' could not be signed because: ';
         if (!strlen($eprescriber->SSID) > 0) {
             $ret = $err . 'Medication will be ePrescribed and you do not have an SPI ' . $location;
         } else {
             $tmp = array();
             $line1Len = strlen($building->line1);
             if (!$line1Len > 0 || $line1Len > 35) {
                 $tmp[] = 'Address line1 field must be supplied and not more than 35 characters';
             }
             $line2Len = strlen($building->line2);
             if ($line2Len > 0 && $line2Len > 35) {
                 $tmp[] = 'Address line2 must not be more than 35 characters';
             }
             $cityLen = strlen($building->city);
             if (!$cityLen > 0 || $cityLen > 35) {
                 $tmp[] = 'Address city field must be supplied and not more than 35 characters';
             }
             if (strlen($building->state) != 2) {
                 $tmp[] = 'Address state field must be supplied and not more than 2 characters';
             }
             $zipCodeLen = strlen($building->zipCode);
             if ($zipCodeLen != 5 && $zipCodeLen != 9) {
                 $tmp[] = 'Address zipcode must be supplied and must be 5 or 9 digit long';
             }
             $phoneNumber = PhoneNumber::autoFixNumber($building->phoneNumber);
             $fax = PhoneNumber::autoFixNumber($building->fax);
             if (strlen($phoneNumber) < 11) {
                 $tmp[] = 'Phone number \'' . $phoneNumber . '\' is invalid';
             }
             $faxLen = strlen($fax);
             if ($faxLen > 0 && $faxLen < 11) {
                 $tmp[] = 'Fax number \'' . $fax . '\' is invalid';
             }
             if (count($tmp) > 0) {
                 $ret = $err . "\n" . implode("\n", $tmp) . ' ' . $location;
             }
         }
     } else {
         $ret = $medication->summary . ' could not be signed because: Medication will be ePrescribed and you do not have a default location.';
     }
     return $ret;
 }
Exemplo n.º 29
0
 /**
  * Runs when a model is saved.
  * Scans attributes for phone numbers and index them in <tt>x2_phone_numbers</tt>.
  * Updates <tt>x2_relationships</tt> table based on link type fields.
  * Fires onAfterSave event.
  */
 public function afterSave()
 {
     if ($this->_runAfterCreate) {
         $this->afterCreate();
     } else {
         $this->afterUpdate();
     }
     $phoneFields = array();
     $linkFields = array();
     // look through fields for phone numbers and relationships
     foreach (self::$_fields[$this->tableName()] as &$_field) {
         if ($_field->type === 'phone') {
             $phoneFields[$_field->fieldName] = $this->getAttribute($_field->fieldName);
         } elseif ($_field->type === 'link') {
             $nameAndId = Fields::nameAndId($this->getAttribute($_field->fieldName));
             $linkFields[$_field->fieldName] = array('id' => $nameAndId[1], 'type' => $_field->linkType);
         }
     }
     // deal with phone numbers
     if (count($phoneFields)) {
         // clear out old phone numbers
         X2Model::model('PhoneNumber')->deleteAllByAttributes(array('modelId' => $this->id, 'modelType' => get_class($this)));
     }
     // create new entries in x2_phone_numbers
     foreach ($phoneFields as $field => &$number) {
         if (!empty($number)) {
             $num = new PhoneNumber();
             // eliminate everything other than digits
             $num->number = preg_replace('/\\D/', '', $number);
             $num->modelId = $this->id;
             $num->modelType = get_class($this);
             $num->fieldName = $field;
             $num->save();
         }
     }
     parent::afterSave();
     // raise onAfterSave event for behaviors, such as X2ChangeLogBehavior
 }
Exemplo n.º 30
0
 public function postProcess($icddcd508600972f2dab78cd14f7612aa4dc19a18 = NULL, $i6b496fee24729ce6f7683ba88d5a87d6130049b5 = NULL, $ifab26c5df1e4ac29b64e0a4796b1f9165fe614a8 = NULL)
 {
     $demo = false;
     if (($demo || defined("SMS_DEMO")) && $icddcd508600972f2dab78cd14f7612aa4dc19a18 != NULL) {
         $this->_errors[] = "Disabled in demo.";
         return self::POST_OK;
     }
     if ($ifab26c5df1e4ac29b64e0a4796b1f9165fe614a8 == NULL) {
         return self::POST_ERROR;
     }
     if (isset($icddcd508600972f2dab78cd14f7612aa4dc19a18["submitAddAdmin"])) {
         $i6b378f203f89073d2d6f4239eef67bf1db322d03 = $this->escapePostVariables("adminnew");
         $i43e73008096636491c57855e1543fbbc5d9c5013 = $this->escapePostVariables("numbernew");
         if (!strlen($i6b378f203f89073d2d6f4239eef67bf1db322d03)) {
             $this->_errors[] = v_adminsmsprofile_invalidname;
             return self::POST_ERROR;
         } elseif (!PhoneNumber::isPhoneNumber($i43e73008096636491c57855e1543fbbc5d9c5013) || $i43e73008096636491c57855e1543fbbc5d9c5013 == null) {
             $this->_errors[] = v_adminsmsprofile_invalidnumber;
             return self::POST_ERROR;
         } else {
             $this->Execute("INSERT INTO " . DB_PREFIX . "sp_admins VALUES (null,'" . $this->escape($i6b378f203f89073d2d6f4239eef67bf1db322d03) . "','" . $this->escape($i43e73008096636491c57855e1543fbbc5d9c5013) . "')");
             $this->displayConfirmation(v_adminsmsprofile_admincreated);
             return self::POST_OK;
         }
     } elseif (isset($icddcd508600972f2dab78cd14f7612aa4dc19a18["submitAddSmsAccount"])) {
         $ic9eb57c0cb4cf9ea36739fa49adc53923c76243d = $this->escapePostVariables("agree");
         $i10c2cab33828d32845523672265b4101741e17a0 = $this->escapePostVariables("email");
         $i340192567d0c13293e7b72e4d7926ab4475be729 = $this->escapePostVariables("companyname");
         $i3ec11992ba35cc28370d20bb83e1e2b71f7a8dac = $this->escapePostVariables("addressstreet");
         $ia434af08201717f3f656c2e722fa792fe7e63b9f = $this->escapePostVariables("addresscity");
         $i9b4a10858d8a76b1778120e31b66f6e699f65aea = $this->escapePostVariables("addresszip");
         $iab6a314decb74f5c532ecb082cfeb1655b9e98bb = $this->escapePostVariables("country0");
         $ia8ffb918a6696fe37f0bbabaf1e1a952607e959d = $this->escapePostVariables("companyid");
         $i3b1c6281aaacad7a20754ff1ce66c0005b0140ca = $this->escapePostVariables("companyvat");
         $i82e7a3b1bd589a54f63d67ca1a06a3d62552719f = $this->escapePostVariables("refererid");
         $i141fd6cf8d25a2156fcef65b7d29affd9b26822b = $this->escapePostVariables("kosoba");
         $i7e23db037952160bf723279bac0aa2285a3ceb6c = $this->escapePostVariables("kprijmeni");
         $i3ec11992ba35cc28370d20bb83e1e2b71f7a8dac = html_entity_decode($i3ec11992ba35cc28370d20bb83e1e2b71f7a8dac, ENT_QUOTES, 'UTF-8');
         $i340192567d0c13293e7b72e4d7926ab4475be729 = html_entity_decode($i340192567d0c13293e7b72e4d7926ab4475be729, ENT_QUOTES, 'UTF-8');
         $ia434af08201717f3f656c2e722fa792fe7e63b9f = html_entity_decode($ia434af08201717f3f656c2e722fa792fe7e63b9f, ENT_QUOTES, 'UTF-8');
         $i141fd6cf8d25a2156fcef65b7d29affd9b26822b = html_entity_decode($i141fd6cf8d25a2156fcef65b7d29affd9b26822b, ENT_QUOTES, 'UTF-8');
         $i7e23db037952160bf723279bac0aa2285a3ceb6c = html_entity_decode($i7e23db037952160bf723279bac0aa2285a3ceb6c, ENT_QUOTES, 'UTF-8');
         if (defined("v_refererID")) {
             $i82e7a3b1bd589a54f63d67ca1a06a3d62552719f = v_refererID;
         }
         if ($icddcd508600972f2dab78cd14f7612aa4dc19a18["type_acc"] == "Person") {
             $i340192567d0c13293e7b72e4d7926ab4475be729 = "";
             $ia8ffb918a6696fe37f0bbabaf1e1a952607e959d = "";
             $i3b1c6281aaacad7a20754ff1ce66c0005b0140ca = "";
         }
         if ($icddcd508600972f2dab78cd14f7612aa4dc19a18["type_acc"] == "Bussiness" && strlen($i340192567d0c13293e7b72e4d7926ab4475be729) < 3) {
             $this->_errors[] = v_registration_company_name;
             return self::POST_ERROR;
         }
         if ($ic9eb57c0cb4cf9ea36739fa49adc53923c76243d != 1) {
             $this->_errors[] = v_adminsmsprofile_agreetext;
             return self::POST_ERROR;
         }
         if (!self::isEmail($i10c2cab33828d32845523672265b4101741e17a0) || !trim($i10c2cab33828d32845523672265b4101741e17a0)) {
             $this->_errors[] = v_adminsmsprofile_invalidemail2;
             return self::POST_ERROR;
         } else {
             $i4367816f1ae76ddc44b3953c9ce6460e181a0a3a = new SmsModel($this->getDb());
             $i4367816f1ae76ddc44b3953c9ce6460e181a0a3a->registerSmsAccount($i10c2cab33828d32845523672265b4101741e17a0, $i340192567d0c13293e7b72e4d7926ab4475be729, $i3ec11992ba35cc28370d20bb83e1e2b71f7a8dac, $ia434af08201717f3f656c2e722fa792fe7e63b9f, $i9b4a10858d8a76b1778120e31b66f6e699f65aea, $iab6a314decb74f5c532ecb082cfeb1655b9e98bb, $ia8ffb918a6696fe37f0bbabaf1e1a952607e959d, $i3b1c6281aaacad7a20754ff1ce66c0005b0140ca, $i82e7a3b1bd589a54f63d67ca1a06a3d62552719f, $i141fd6cf8d25a2156fcef65b7d29affd9b26822b, $i7e23db037952160bf723279bac0aa2285a3ceb6c);
             $i15f0440429ef770fbaf8bd58ae6bab5bcc2e123c = new UserProfile($this->getDb());
             $i4367816f1ae76ddc44b3953c9ce6460e181a0a3a->editOtherSettings(urlencode(DELIVERY_URL), 0, "", "1", 0, 0, 0, $i15f0440429ef770fbaf8bd58ae6bab5bcc2e123c->getUsername(), $i15f0440429ef770fbaf8bd58ae6bab5bcc2e123c->getPassword());
             if ($i4367816f1ae76ddc44b3953c9ce6460e181a0a3a->isError()) {
                 $this->_errors = array_unique($i4367816f1ae76ddc44b3953c9ce6460e181a0a3a->getErrors());
                 return self::POST_ERROR;
             } else {
                 $this->_okMsg = array_unique($i4367816f1ae76ddc44b3953c9ce6460e181a0a3a->getConfirm());
                 return self::POST_OK;
             }
         }
     } elseif (isset($icddcd508600972f2dab78cd14f7612aa4dc19a18["submitLogin"])) {
         $i05cffcc28d5370a291200c83ba5e24a107e83193 = $this->escapePostVariables("username");
         $ie949fe683eb9735ceada53820bfe2c9007ae8bd6 = $this->escapePostVariables("password");
         if (!strlen($i05cffcc28d5370a291200c83ba5e24a107e83193) > 0 || !strlen($ie949fe683eb9735ceada53820bfe2c9007ae8bd6) > 0) {
             $this->_errors[] = v_adminsmsprofile_filluser;
             return self::POST_ERROR;
         } else {
             $i4367816f1ae76ddc44b3953c9ce6460e181a0a3a = new SmsModel($this->getDb());
             $i4367816f1ae76ddc44b3953c9ce6460e181a0a3a->loginAccount($i05cffcc28d5370a291200c83ba5e24a107e83193, $ie949fe683eb9735ceada53820bfe2c9007ae8bd6);
             $i4367816f1ae76ddc44b3953c9ce6460e181a0a3a->editOtherSettings(urlencode(DELIVERY_URL), 0, "", "1", 0, 0, 0, $i05cffcc28d5370a291200c83ba5e24a107e83193, $ie949fe683eb9735ceada53820bfe2c9007ae8bd6);
             if ($i4367816f1ae76ddc44b3953c9ce6460e181a0a3a->isError()) {
                 $this->_errors = array_unique($i4367816f1ae76ddc44b3953c9ce6460e181a0a3a->getErrors());
                 return self::POST_ERROR;
             } else {
                 $this->_okMsg = array_unique($i4367816f1ae76ddc44b3953c9ce6460e181a0a3a->getConfirm());
                 return self::POST_OK;
             }
         }
     } elseif (isset($icddcd508600972f2dab78cd14f7612aa4dc19a18["submitEditAdmin_x"]) || isset($icddcd508600972f2dab78cd14f7612aa4dc19a18["submitEditAdmin"])) {
         $this->edit_id = $this->escapePostVariables("ID");
         $this->edit_admins = true;
     } elseif (isset($icddcd508600972f2dab78cd14f7612aa4dc19a18["submitAdminSettings1"])) {
         $this->deleteDb = $this->escapePostVariables("deletedb");
         $this->simulate = $this->escapePostVariables("simulate");
         $this->deliveryemail = $this->escapePostVariables("deliveryemail");
         $this->pocetkredit = $this->escapePostVariables("pocetkredit");
         $this->URLreports = $this->escapePostVariables("URLreports");
         $this->pref_billing = $this->escapePostVariables("pref_billing");
         if (strlen($this->deliveryemail) > 0 && !self::isEmail($this->deliveryemail)) {
             $this->_errors[] = v_adminsmsprofile_invalidemail;
             return self::POST_ERROR;
         }
         $i4367816f1ae76ddc44b3953c9ce6460e181a0a3a = new SmsModel($this->getDb());
         if ($this->URLreports == 1) {
             $i5ca425460f7dbd64a82fa844eed01062be6a63d4 = urlencode(DELIVERY_URL);
         } else {
             $i5ca425460f7dbd64a82fa844eed01062be6a63d4 = "";
         }
         $i4367816f1ae76ddc44b3953c9ce6460e181a0a3a->editOtherSettings($i5ca425460f7dbd64a82fa844eed01062be6a63d4, $this->pocetkredit, $this->deliveryemail, $this->URLreports, $this->deleteDb, $this->simulate, $this->pref_billing);
         if ($i4367816f1ae76ddc44b3953c9ce6460e181a0a3a->isError()) {
             $this->_errors = array_unique($i4367816f1ae76ddc44b3953c9ce6460e181a0a3a->getErrors());
             return self::POST_ERROR;
         } else {
             $this->_okMsg = array_unique($i4367816f1ae76ddc44b3953c9ce6460e181a0a3a->getConfirm());
             return self::POST_OK;
         }
     } elseif (isset($icddcd508600972f2dab78cd14f7612aa4dc19a18["submitEditAdmin2"])) {
         $i87395dcafb6eb7221410dbcd87e9e8ce0007214a = $this->escapePostVariables("edit");
         $i6b378f203f89073d2d6f4239eef67bf1db322d03 = $this->escapePostVariables("adminnew");
         $i6b378f203f89073d2d6f4239eef67bf1db322d03 = html_entity_decode($i6b378f203f89073d2d6f4239eef67bf1db322d03, ENT_QUOTES, 'UTF-8');
         $i43e73008096636491c57855e1543fbbc5d9c5013 = $this->escapePostVariables("numbernew");
         if (!$i6b378f203f89073d2d6f4239eef67bf1db322d03) {
             $this->_errors[] = v_adminsmsprofile_invalidname;
             $this->edit_admins = true;
             $this->edit_id = $i87395dcafb6eb7221410dbcd87e9e8ce0007214a;
             return self::POST_ERROR;
         } elseif (!PhoneNumber::isPhoneNumber($i43e73008096636491c57855e1543fbbc5d9c5013) || !$i43e73008096636491c57855e1543fbbc5d9c5013) {
             $this->_errors[] = v_adminsmsprofile_invalidnumber;
             $this->edit_admins = true;
             $this->edit_id = $i87395dcafb6eb7221410dbcd87e9e8ce0007214a;
             return self::POST_ERROR;
         } else {
             $this->Execute("UPDATE " . DB_PREFIX . "sp_admins SET name='" . $this->escape($i6b378f203f89073d2d6f4239eef67bf1db322d03) . "', number='" . $this->escape($i43e73008096636491c57855e1543fbbc5d9c5013) . "' WHERE ID=" . $this->escape($i87395dcafb6eb7221410dbcd87e9e8ce0007214a));
             $this->displayConfirmation(v_adminsmsprofile_adminchanged);
             $this->edit_admins = false;
             $this->edit_id = 0;
             return self::POST_OK;
         }
     } elseif (isset($icddcd508600972f2dab78cd14f7612aa4dc19a18["submitDeleteAdmin_x"]) || isset($icddcd508600972f2dab78cd14f7612aa4dc19a18["submitDeleteAdmin"])) {
         $i87395dcafb6eb7221410dbcd87e9e8ce0007214a = $this->escapePostVariables("ID");
         $this->Execute("DELETE FROM " . DB_PREFIX . "sp_admins WHERE ID='" . $this->escape($i87395dcafb6eb7221410dbcd87e9e8ce0007214a) . "'");
         $this->Execute("DELETE FROM " . DB_PREFIX . "sp_hooks_admins_multi WHERE adminIDs LIKE '" . $this->escape($i87395dcafb6eb7221410dbcd87e9e8ce0007214a) . "'");
         $ic6e936002fe51b97bc1b95f337c09606ceb011de = $this->Execute("SELECT * FROM " . DB_PREFIX . "sp_hooks_admins_multi WHERE adminIDs like '" . $this->escape($i87395dcafb6eb7221410dbcd87e9e8ce0007214a) . ";%' OR adminIDs LIKE '%;" . $this->escape($i87395dcafb6eb7221410dbcd87e9e8ce0007214a) . ";%' OR adminIDs LIKE '%;" . $this->escape($i87395dcafb6eb7221410dbcd87e9e8ce0007214a) . "'");
         if ($ic6e936002fe51b97bc1b95f337c09606ceb011de->num_rows) {
             foreach ($ic6e936002fe51b97bc1b95f337c09606ceb011de->rows as $i43ef5aef4168652439ef5de195405ced9f0f7952) {
                 $ie7ba91fafe7c53be0878165bdb30c214e66b70bf = explode(";", $i43ef5aef4168652439ef5de195405ced9f0f7952['adminIDs']);
                 array_splice($ie7ba91fafe7c53be0878165bdb30c214e66b70bf, array_search($i87395dcafb6eb7221410dbcd87e9e8ce0007214a, $ie7ba91fafe7c53be0878165bdb30c214e66b70bf), 1);
                 $this->Execute("UPDATE " . DB_PREFIX . "sp_hooks_admins_multi SET adminIDs='" . implode(";", $ie7ba91fafe7c53be0878165bdb30c214e66b70bf) . "' WHERE name='" . $this->escape($i43ef5aef4168652439ef5de195405ced9f0f7952['name']) . "' AND status='" . $this->escape($i43ef5aef4168652439ef5de195405ced9f0f7952['status']) . "'");
             }
         }
         $this->displayConfirmation(v_adminsmsprofile_admindeleted);
         return self::POST_OK;
     } elseif (isset($icddcd508600972f2dab78cd14f7612aa4dc19a18["EditSmsAccount"])) {
         $i10c2cab33828d32845523672265b4101741e17a0 = $this->escapePostVariables("email");
         $i340192567d0c13293e7b72e4d7926ab4475be729 = $this->escapePostVariables("companyname");
         $i3ec11992ba35cc28370d20bb83e1e2b71f7a8dac = $this->escapePostVariables("addressstreet");
         $ia434af08201717f3f656c2e722fa792fe7e63b9f = $this->escapePostVariables("addresscity");
         $i9b4a10858d8a76b1778120e31b66f6e699f65aea = $this->escapePostVariables("addresszip");
         $iab6a314decb74f5c532ecb082cfeb1655b9e98bb = $this->escapePostVariables("country0");
         $ia8ffb918a6696fe37f0bbabaf1e1a952607e959d = $this->escapePostVariables("companyid");
         $i3b1c6281aaacad7a20754ff1ce66c0005b0140ca = $this->escapePostVariables("companyvat");
         $i141fd6cf8d25a2156fcef65b7d29affd9b26822b = $this->escapePostVariables("kosoba");
         $i7e23db037952160bf723279bac0aa2285a3ceb6c = $this->escapePostVariables("kprijmeni");
         $i3ec11992ba35cc28370d20bb83e1e2b71f7a8dac = html_entity_decode($i3ec11992ba35cc28370d20bb83e1e2b71f7a8dac, ENT_QUOTES, 'UTF-8');
         $i340192567d0c13293e7b72e4d7926ab4475be729 = html_entity_decode($i340192567d0c13293e7b72e4d7926ab4475be729, ENT_QUOTES, 'UTF-8');
         $ia434af08201717f3f656c2e722fa792fe7e63b9f = html_entity_decode($ia434af08201717f3f656c2e722fa792fe7e63b9f, ENT_QUOTES, 'UTF-8');
         $i141fd6cf8d25a2156fcef65b7d29affd9b26822b = html_entity_decode($i141fd6cf8d25a2156fcef65b7d29affd9b26822b, ENT_QUOTES, 'UTF-8');
         $i7e23db037952160bf723279bac0aa2285a3ceb6c = html_entity_decode($i7e23db037952160bf723279bac0aa2285a3ceb6c, ENT_QUOTES, 'UTF-8');
         if ($icddcd508600972f2dab78cd14f7612aa4dc19a18["type_acc"] == "Person") {
             $i340192567d0c13293e7b72e4d7926ab4475be729 = "";
             $ia8ffb918a6696fe37f0bbabaf1e1a952607e959d = "";
             $i3b1c6281aaacad7a20754ff1ce66c0005b0140ca = "";
         }
         if ($icddcd508600972f2dab78cd14f7612aa4dc19a18["type_acc"] == "Bussiness" && strlen($i340192567d0c13293e7b72e4d7926ab4475be729) < 3) {
             $this->_errors[] = v_registration_company_name;
             return self::POST_ERROR;
         }
         if (!self::isEmail($i10c2cab33828d32845523672265b4101741e17a0)) {
             $this->_errors[] = v_adminsmsprofile_invalidemail2;
             return self::POST_ERROR;
         } else {
             $i4367816f1ae76ddc44b3953c9ce6460e181a0a3a = new SmsModel($this->getDb());
             $i4367816f1ae76ddc44b3953c9ce6460e181a0a3a->editAccount($i10c2cab33828d32845523672265b4101741e17a0, $i340192567d0c13293e7b72e4d7926ab4475be729, $i3ec11992ba35cc28370d20bb83e1e2b71f7a8dac, $ia434af08201717f3f656c2e722fa792fe7e63b9f, $i9b4a10858d8a76b1778120e31b66f6e699f65aea, $iab6a314decb74f5c532ecb082cfeb1655b9e98bb, $ia8ffb918a6696fe37f0bbabaf1e1a952607e959d, $i3b1c6281aaacad7a20754ff1ce66c0005b0140ca, $i141fd6cf8d25a2156fcef65b7d29affd9b26822b, $i7e23db037952160bf723279bac0aa2285a3ceb6c);
             if ($i4367816f1ae76ddc44b3953c9ce6460e181a0a3a->isError()) {
                 $this->_errors = array_unique($i4367816f1ae76ddc44b3953c9ce6460e181a0a3a->getErrors());
                 return self::POST_ERROR;
             } else {
                 $this->_okMsg = array_unique($i4367816f1ae76ddc44b3953c9ce6460e181a0a3a->getConfirm());
                 return self::POST_OK;
             }
         }
     }
     return self::POST_ERROR;
 }