Beispiel #1
0
 /**
  * The run() function is called from Web Store to actually do the calculation. It returns an array of the service
  * levels and prices available to the customer (as keys and values in the array, respectively).
  * @return array
  */
 public function run()
 {
     if (!isset($this->config['offerservices'])) {
         return false;
     }
     $weight = $this->objCart->Weight;
     if (_xls_get_conf('WEIGHT_UNIT', 'lb') != 'lb') {
         // one KG is 2.2 pounds
         $weight = $weight * 2.2;
     }
     //USPS wants a full country name
     $objCountry = Country::Load($this->CheckoutForm->shippingCountry);
     if ($objCountry instanceof Country) {
         $country = $objCountry->country;
     } else {
         $country = "US";
     }
     if (empty($this->config['username']) || empty($this->config['originpostcode'])) {
         return false;
     }
     $this->init_vars($this->config['username'], $this->config['originpostcode'], $this->CheckoutForm->shippingPostal, $country, $this->config['markup']);
     $this->addItem(intval($weight), round(($weight - intval($weight)) * 16, 0), $this->objCart->total);
     $rates = $this->getRate();
     if ($rates === FALSE || count($rates) == 0) {
         Yii::log("USPS: Could not get rates. " . print_r($this, true), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
         return false;
     }
     return $this->convertRetToDisplay($rates);
 }
 /**
  * Validates that the state that the customer enters either
  * in the shipping form or billing form respects the format
  * for the countries we want to validate it upon.
  *
  * @param CModel $model
  * @param string $attribute
  * @return void
  */
 public function validateAttribute($model, $attribute)
 {
     switch ($attribute) {
         case 'shippingState':
             $objCountry = Country::Load($model->shippingCountry);
             break;
         case 'billingState':
             $objCountry = Country::Load($model->billingCountry);
             break;
         default:
             // Cannot validate any other attributes.
             return;
     }
     if ($objCountry === null) {
         // Country isn't valid, can't validate the state!
         return;
     }
     $countriesToValidateState = array(self::USA, self::CANADA, self::AUSTRALIA);
     if (in_array($objCountry->id, $countriesToValidateState) === false) {
         // Do not attempt to validate the state.
         return;
     }
     if (empty($model->{$attribute}) === true) {
         $this->addError($model, $attribute, Yii::t('yii', '{attributeName} cannot be blank.', array('{attributeName}' => $model->getattributeLabel($attribute))));
     } else {
         $objState = State::Load($model->{$attribute});
         if ($objState === null) {
             $this->addError($model, $attribute, Yii::t('yii', '{attributeName} is invalid.', array('{attributeName}' => $model->getattributeLabel($attribute))));
         }
     }
 }
 protected function SetupCountry()
 {
     // Lookup Object PK information from Query String (if applicable)
     // Set mode to Edit or New depending on what's found
     $intCountryId = QApplication::QueryString('intCountryId');
     if ($intCountryId) {
         $this->objCountry = Country::Load($intCountryId);
         if (!$this->objCountry) {
             throw new Exception('Could not find a Country object with PK arguments: ' . $intCountryId);
         }
         $this->strTitleVerb = QApplication::Translate('Edit');
         $this->blnEditMode = true;
     } else {
         $this->objCountry = new Country();
         $this->strTitleVerb = QApplication::Translate('Create');
         $this->blnEditMode = false;
     }
 }
 public function holidayToEvent($holiday)
 {
     $event = array();
     $event['id'] = "hd_" . $holiday->id;
     if ($holiday->status == "Full Day") {
         $event['title'] = $holiday->name;
     } else {
         $event['title'] = $holiday->name . " (" . $holiday->status . ")";
     }
     if (!empty($holiday->country)) {
         $country = new Country();
         $country->Load("id = ?", array($holiday->country));
         $event['title'] .= " / " . $country->name . " only";
     }
     $event['start'] = $holiday->dateh;
     $event['end'] = $holiday->dateh;
     $eventBackgroundColor = "#3c8dbc";
     $event['color'] = $eventBackgroundColor;
     $event['backgroundColor'] = $eventBackgroundColor;
     $event['textColor'] = "#FFF";
     return $event;
 }
 public function getLeaveDays($req)
 {
     //Find Current leave period
     $leaveCounts = array();
     $currentLeavePeriodResp = $this->getCurrentLeavePeriod($req->start_date, $req->end_date);
     if ($currentLeavePeriodResp->getStatus() != IceResponse::SUCCESS) {
         return new IceResponse(IceResponse::ERROR, $currentLeavePeriodResp->getData());
     } else {
         $currentLeavePeriod = $currentLeavePeriodResp->getData();
     }
     $employee = $this->baseService->getElement('Employee', $this->getCurrentProfileId(), null, true);
     $rule = $this->getLeaveRule($employee, $req->leave_type, $currentLeavePeriod);
     if ($this->user->user_level == 'Admin' && $this->getCurrentProfileId() != $this->user->employee) {
         //Admin is updating information for an employee
         if ($rule->supervisor_leave_assign == "No") {
             return new IceResponse(IceResponse::ERROR, "You are not allowed to assign this type of leaves as admin");
         }
     } else {
         if ($rule->employee_can_apply == "No") {
             return new IceResponse(IceResponse::ERROR, "You are not allowed to apply for this type of leaves");
         }
     }
     $leaveMatrix = $this->getAvailableLeaveMatrixForEmployeeLeaveType($employee, $currentLeavePeriod, $req->leave_type);
     $leaves = array();
     $leaves['totalLeaves'] = floatval($leaveMatrix[0]);
     $leaves['pendingLeaves'] = floatval($leaveMatrix[1]);
     $leaves['approvedLeaves'] = floatval($leaveMatrix[2]);
     $leaves['rejectedLeaves'] = floatval($leaveMatrix[3]);
     $leaves['cancelRequestedLeaves'] = floatval($leaveMatrix[5]);
     $leaves['availableLeaves'] = $leaves['totalLeaves'] - $leaves['pendingLeaves'] - $leaves['approvedLeaves'] - $leaves['cancelRequestedLeaves'];
     //=== Resolve Employee Country
     $employeeCountry = NULL;
     if (!empty($employee->country)) {
         $country = new Country();
         $country->Load("code = ?", array($employee->country));
         $employeeCountry = $country->id;
     }
     //============================
     $startDate = $req->start_date;
     $endDate = $req->end_date;
     $days = array();
     $days = $this->getDays($startDate, $endDate);
     $dayMap = array();
     foreach ($days as $day) {
         $dayMap[$day] = $this->getDayWorkTime($day, $employeeCountry);
     }
     return new IceResponse(IceResponse::SUCCESS, array($dayMap, $leaves, $rule));
 }
 /**
  * Static Helper Method to Create using PK arguments
  * You must pass in the PK arguments on an object to load, or leave it blank to create a new one.
  * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo
  * static helper methods.  Finally, specify a CreateType to define whether or not we are only allowed to 
  * edit, or if we are also allowed to create a new one, etc.
  * 
  * @param mixed $objParentObject QForm or QPanel which will be using this CountryMetaControl
  * @param integer $intCountryId primary key value
  * @param QMetaControlCreateType $intCreateType rules governing Country object creation - defaults to CreateOrEdit
  * @return CountryMetaControl
  */
 public static function Create($objParentObject, $intCountryId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit)
 {
     // Attempt to Load from PK Arguments
     if (strlen($intCountryId)) {
         $objCountry = Country::Load($intCountryId);
         // Country was found -- return it!
         if ($objCountry) {
             return new CountryMetaControl($objParentObject, $objCountry);
         } else {
             if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) {
                 throw new QCallerException('Could not find a Country object with PK arguments: ' . $intCountryId);
             }
         }
         // If EditOnly is specified, throw an exception
     } else {
         if ($intCreateType == QMetaControlCreateType::EditOnly) {
             throw new QCallerException('No PK arguments specified');
         }
     }
     // If we are here, then we need to create a new record
     return new CountryMetaControl($objParentObject, new Country());
 }
Beispiel #7
0
 /**
  * Override method to perform a property "Get"
  * This will get the value of $strName
  *
  * @param string $strName Name of the property to get
  * @return mixed
  */
 public function __get($strName)
 {
     switch ($strName) {
         ///////////////////
         // Member Variables
         ///////////////////
         case 'AddressId':
             /**
              * Gets the value for intAddressId (Read-Only PK)
              * @return integer
              */
             return $this->intAddressId;
         case 'CompanyId':
             /**
              * Gets the value for intCompanyId (Not Null)
              * @return integer
              */
             return $this->intCompanyId;
         case 'ShortDescription':
             /**
              * Gets the value for strShortDescription (Not Null)
              * @return string
              */
             return $this->strShortDescription;
         case 'CountryId':
             /**
              * Gets the value for intCountryId (Not Null)
              * @return integer
              */
             return $this->intCountryId;
         case 'Address1':
             /**
              * Gets the value for strAddress1 (Not Null)
              * @return string
              */
             return $this->strAddress1;
         case 'Address2':
             /**
              * Gets the value for strAddress2 
              * @return string
              */
             return $this->strAddress2;
         case 'City':
             /**
              * Gets the value for strCity (Not Null)
              * @return string
              */
             return $this->strCity;
         case 'StateProvinceId':
             /**
              * Gets the value for intStateProvinceId 
              * @return integer
              */
             return $this->intStateProvinceId;
         case 'PostalCode':
             /**
              * Gets the value for strPostalCode (Not Null)
              * @return string
              */
             return $this->strPostalCode;
         case 'CreatedBy':
             /**
              * Gets the value for intCreatedBy 
              * @return integer
              */
             return $this->intCreatedBy;
         case 'CreationDate':
             /**
              * Gets the value for dttCreationDate 
              * @return QDateTime
              */
             return $this->dttCreationDate;
         case 'ModifiedBy':
             /**
              * Gets the value for intModifiedBy 
              * @return integer
              */
             return $this->intModifiedBy;
         case 'ModifiedDate':
             /**
              * Gets the value for strModifiedDate (Read-Only Timestamp)
              * @return string
              */
             return $this->strModifiedDate;
             ///////////////////
             // Member Objects
             ///////////////////
         ///////////////////
         // Member Objects
         ///////////////////
         case 'Company':
             /**
              * Gets the value for the Company object referenced by intCompanyId (Not Null)
              * @return Company
              */
             try {
                 if (!$this->objCompany && !is_null($this->intCompanyId)) {
                     $this->objCompany = Company::Load($this->intCompanyId);
                 }
                 return $this->objCompany;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'Country':
             /**
              * Gets the value for the Country object referenced by intCountryId (Not Null)
              * @return Country
              */
             try {
                 if (!$this->objCountry && !is_null($this->intCountryId)) {
                     $this->objCountry = Country::Load($this->intCountryId);
                 }
                 return $this->objCountry;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'StateProvince':
             /**
              * Gets the value for the StateProvince object referenced by intStateProvinceId 
              * @return StateProvince
              */
             try {
                 if (!$this->objStateProvince && !is_null($this->intStateProvinceId)) {
                     $this->objStateProvince = StateProvince::Load($this->intStateProvinceId);
                 }
                 return $this->objStateProvince;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'CreatedByObject':
             /**
              * Gets the value for the UserAccount object referenced by intCreatedBy 
              * @return UserAccount
              */
             try {
                 if (!$this->objCreatedByObject && !is_null($this->intCreatedBy)) {
                     $this->objCreatedByObject = UserAccount::Load($this->intCreatedBy);
                 }
                 return $this->objCreatedByObject;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'ModifiedByObject':
             /**
              * Gets the value for the UserAccount object referenced by intModifiedBy 
              * @return UserAccount
              */
             try {
                 if (!$this->objModifiedByObject && !is_null($this->intModifiedBy)) {
                     $this->objModifiedByObject = UserAccount::Load($this->intModifiedBy);
                 }
                 return $this->objModifiedByObject;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
             ////////////////////////////
             // Virtual Object References (Many to Many and Reverse References)
             // (If restored via a "Many-to" expansion)
             ////////////////////////////
         ////////////////////////////
         // Virtual Object References (Many to Many and Reverse References)
         // (If restored via a "Many-to" expansion)
         ////////////////////////////
         case '_Company':
             /**
              * Gets the value for the private _objCompany (Read-Only)
              * if set due to an expansion on the company.address_id reverse relationship
              * @return Company
              */
             return $this->_objCompany;
         case '_CompanyArray':
             /**
              * Gets the value for the private _objCompanyArray (Read-Only)
              * if set due to an ExpandAsArray on the company.address_id reverse relationship
              * @return Company[]
              */
             return (array) $this->_objCompanyArray;
         case '_Contact':
             /**
              * Gets the value for the private _objContact (Read-Only)
              * if set due to an expansion on the contact.address_id reverse relationship
              * @return Contact
              */
             return $this->_objContact;
         case '_ContactArray':
             /**
              * Gets the value for the private _objContactArray (Read-Only)
              * if set due to an ExpandAsArray on the contact.address_id reverse relationship
              * @return Contact[]
              */
             return (array) $this->_objContactArray;
         case '_ReceiptAsTo':
             /**
              * Gets the value for the private _objReceiptAsTo (Read-Only)
              * if set due to an expansion on the receipt.to_address_id reverse relationship
              * @return Receipt
              */
             return $this->_objReceiptAsTo;
         case '_ReceiptAsToArray':
             /**
              * Gets the value for the private _objReceiptAsToArray (Read-Only)
              * if set due to an ExpandAsArray on the receipt.to_address_id reverse relationship
              * @return Receipt[]
              */
             return (array) $this->_objReceiptAsToArray;
         case '_ShipmentAsFrom':
             /**
              * Gets the value for the private _objShipmentAsFrom (Read-Only)
              * if set due to an expansion on the shipment.from_address_id reverse relationship
              * @return Shipment
              */
             return $this->_objShipmentAsFrom;
         case '_ShipmentAsFromArray':
             /**
              * Gets the value for the private _objShipmentAsFromArray (Read-Only)
              * if set due to an ExpandAsArray on the shipment.from_address_id reverse relationship
              * @return Shipment[]
              */
             return (array) $this->_objShipmentAsFromArray;
         case '_ShipmentAsTo':
             /**
              * Gets the value for the private _objShipmentAsTo (Read-Only)
              * if set due to an expansion on the shipment.to_address_id reverse relationship
              * @return Shipment
              */
             return $this->_objShipmentAsTo;
         case '_ShipmentAsToArray':
             /**
              * Gets the value for the private _objShipmentAsToArray (Read-Only)
              * if set due to an ExpandAsArray on the shipment.to_address_id reverse relationship
              * @return Shipment[]
              */
             return (array) $this->_objShipmentAsToArray;
         default:
             try {
                 return parent::__get($strName);
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
     }
 }
Beispiel #8
0
 /**
  * Reload this Country from the database.
  * @return void
  */
 public function Reload()
 {
     // Make sure we are actually Restored from the database
     if (!$this->__blnRestored) {
         throw new QCallerException('Cannot call Reload() on a new, unsaved Country object.');
     }
     // Reload the Object
     $objReloaded = Country::Load($this->intId);
     // Update $this's local variables to match
     $this->strName = $objReloaded->strName;
     $this->strAbbreviation = $objReloaded->strAbbreviation;
 }
 /**
  * Override method to perform a property "Get"
  * This will get the value of $strName
  *
  * @param string $strName Name of the property to get
  * @return mixed
  */
 public function __get($strName)
 {
     switch ($strName) {
         ///////////////////
         // Member Variables
         ///////////////////
         case 'Id':
             // Gets the value for intId (Read-Only PK)
             // @return integer
             return $this->intId;
         case 'PersonTypeId':
             // Gets the value for intPersonTypeId (Not Null)
             // @return integer
             return $this->intPersonTypeId;
         case 'Username':
             // Gets the value for strUsername (Unique)
             // @return string
             return $this->strUsername;
         case 'Password':
             // Gets the value for strPassword
             // @return string
             return $this->strPassword;
         case 'FirstName':
             // Gets the value for strFirstName (Not Null)
             // @return string
             return $this->strFirstName;
         case 'LastName':
             // Gets the value for strLastName (Not Null)
             // @return string
             return $this->strLastName;
         case 'Email':
             // Gets the value for strEmail (Unique)
             // @return string
             return $this->strEmail;
         case 'DisplayName':
             // Gets the value for strDisplayName
             // @return string
             return $this->strDisplayName;
         case 'PasswordResetFlag':
             // Gets the value for blnPasswordResetFlag
             // @return boolean
             return $this->blnPasswordResetFlag;
         case 'DisplayRealNameFlag':
             // Gets the value for blnDisplayRealNameFlag
             // @return boolean
             return $this->blnDisplayRealNameFlag;
         case 'DisplayEmailFlag':
             // Gets the value for blnDisplayEmailFlag
             // @return boolean
             return $this->blnDisplayEmailFlag;
         case 'OptInFlag':
             // Gets the value for blnOptInFlag
             // @return boolean
             return $this->blnOptInFlag;
         case 'DonatedFlag':
             // Gets the value for blnDonatedFlag
             // @return boolean
             return $this->blnDonatedFlag;
         case 'Location':
             // Gets the value for strLocation
             // @return string
             return $this->strLocation;
         case 'CountryId':
             // Gets the value for intCountryId
             // @return integer
             return $this->intCountryId;
         case 'Url':
             // Gets the value for strUrl
             // @return string
             return $this->strUrl;
         case 'TimezoneId':
             // Gets the value for intTimezoneId
             // @return integer
             return $this->intTimezoneId;
         case 'RegistrationDate':
             // Gets the value for dttRegistrationDate (Not Null)
             // @return QDateTime
             return $this->dttRegistrationDate;
             ///////////////////
             // Member Objects
             ///////////////////
         ///////////////////
         // Member Objects
         ///////////////////
         case 'Country':
             // Gets the value for the Country object referenced by intCountryId
             // @return Country
             try {
                 if (!$this->objCountry && !is_null($this->intCountryId)) {
                     $this->objCountry = Country::Load($this->intCountryId);
                 }
                 return $this->objCountry;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'Timezone':
             // Gets the value for the Timezone object referenced by intTimezoneId
             // @return Timezone
             try {
                 if (!$this->objTimezone && !is_null($this->intTimezoneId)) {
                     $this->objTimezone = Timezone::Load($this->intTimezoneId);
                 }
                 return $this->objTimezone;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
             ////////////////////////////
             // Virtual Object References (Many to Many and Reverse References)
             // (If restored via a "Many-to" expansion)
             ////////////////////////////
         ////////////////////////////
         // Virtual Object References (Many to Many and Reverse References)
         // (If restored via a "Many-to" expansion)
         ////////////////////////////
         case '_TopicAsEmail':
             // Gets the value for the private _objTopicAsEmail (Read-Only)
             // if set due to an expansion on the email_topic_person_assn association table
             // @return Topic
             return $this->_objTopicAsEmail;
         case '_TopicAsEmailArray':
             // Gets the value for the private _objTopicAsEmailArray (Read-Only)
             // if set due to an ExpandAsArray on the email_topic_person_assn association table
             // @return Topic[]
             return (array) $this->_objTopicAsEmailArray;
         case '_TopicAsReadOnce':
             // Gets the value for the private _objTopicAsReadOnce (Read-Only)
             // if set due to an expansion on the read_once_topic_person_assn association table
             // @return Topic
             return $this->_objTopicAsReadOnce;
         case '_TopicAsReadOnceArray':
             // Gets the value for the private _objTopicAsReadOnceArray (Read-Only)
             // if set due to an ExpandAsArray on the read_once_topic_person_assn association table
             // @return Topic[]
             return (array) $this->_objTopicAsReadOnceArray;
         case '_TopicAsRead':
             // Gets the value for the private _objTopicAsRead (Read-Only)
             // if set due to an expansion on the read_topic_person_assn association table
             // @return Topic
             return $this->_objTopicAsRead;
         case '_TopicAsReadArray':
             // Gets the value for the private _objTopicAsReadArray (Read-Only)
             // if set due to an ExpandAsArray on the read_topic_person_assn association table
             // @return Topic[]
             return (array) $this->_objTopicAsReadArray;
         case '_IssueAsPostedBy':
             // Gets the value for the private _objIssueAsPostedBy (Read-Only)
             // if set due to an expansion on the issue.posted_by_person_id reverse relationship
             // @return Issue
             return $this->_objIssueAsPostedBy;
         case '_IssueAsPostedByArray':
             // Gets the value for the private _objIssueAsPostedByArray (Read-Only)
             // if set due to an ExpandAsArray on the issue.posted_by_person_id reverse relationship
             // @return Issue[]
             return (array) $this->_objIssueAsPostedByArray;
         case '_IssueAsAssignedTo':
             // Gets the value for the private _objIssueAsAssignedTo (Read-Only)
             // if set due to an expansion on the issue.assigned_to_person_id reverse relationship
             // @return Issue
             return $this->_objIssueAsAssignedTo;
         case '_IssueAsAssignedToArray':
             // Gets the value for the private _objIssueAsAssignedToArray (Read-Only)
             // if set due to an ExpandAsArray on the issue.assigned_to_person_id reverse relationship
             // @return Issue[]
             return (array) $this->_objIssueAsAssignedToArray;
         case '_IssueVote':
             // Gets the value for the private _objIssueVote (Read-Only)
             // if set due to an expansion on the issue_vote.person_id reverse relationship
             // @return IssueVote
             return $this->_objIssueVote;
         case '_IssueVoteArray':
             // Gets the value for the private _objIssueVoteArray (Read-Only)
             // if set due to an ExpandAsArray on the issue_vote.person_id reverse relationship
             // @return IssueVote[]
             return (array) $this->_objIssueVoteArray;
         case '_LoginTicket':
             // Gets the value for the private _objLoginTicket (Read-Only)
             // if set due to an expansion on the login_ticket.person_id reverse relationship
             // @return LoginTicket
             return $this->_objLoginTicket;
         case '_LoginTicketArray':
             // Gets the value for the private _objLoginTicketArray (Read-Only)
             // if set due to an ExpandAsArray on the login_ticket.person_id reverse relationship
             // @return LoginTicket[]
             return (array) $this->_objLoginTicketArray;
         case '_Message':
             // Gets the value for the private _objMessage (Read-Only)
             // if set due to an expansion on the message.person_id reverse relationship
             // @return Message
             return $this->_objMessage;
         case '_MessageArray':
             // Gets the value for the private _objMessageArray (Read-Only)
             // if set due to an ExpandAsArray on the message.person_id reverse relationship
             // @return Message[]
             return (array) $this->_objMessageArray;
         case '_PackageAsLastPostedBy':
             // Gets the value for the private _objPackageAsLastPostedBy (Read-Only)
             // if set due to an expansion on the package.last_posted_by_person_id reverse relationship
             // @return Package
             return $this->_objPackageAsLastPostedBy;
         case '_PackageAsLastPostedByArray':
             // Gets the value for the private _objPackageAsLastPostedByArray (Read-Only)
             // if set due to an ExpandAsArray on the package.last_posted_by_person_id reverse relationship
             // @return Package[]
             return (array) $this->_objPackageAsLastPostedByArray;
         case '_PackageContribution':
             // Gets the value for the private _objPackageContribution (Read-Only)
             // if set due to an expansion on the package_contribution.person_id reverse relationship
             // @return PackageContribution
             return $this->_objPackageContribution;
         case '_PackageContributionArray':
             // Gets the value for the private _objPackageContributionArray (Read-Only)
             // if set due to an ExpandAsArray on the package_contribution.person_id reverse relationship
             // @return PackageContribution[]
             return (array) $this->_objPackageContributionArray;
         case '_ShowcaseItem':
             // Gets the value for the private _objShowcaseItem (Read-Only)
             // if set due to an expansion on the showcase_item.person_id reverse relationship
             // @return ShowcaseItem
             return $this->_objShowcaseItem;
         case '_ShowcaseItemArray':
             // Gets the value for the private _objShowcaseItemArray (Read-Only)
             // if set due to an ExpandAsArray on the showcase_item.person_id reverse relationship
             // @return ShowcaseItem[]
             return (array) $this->_objShowcaseItemArray;
         case '_Topic':
             // Gets the value for the private _objTopic (Read-Only)
             // if set due to an expansion on the topic.person_id reverse relationship
             // @return Topic
             return $this->_objTopic;
         case '_TopicArray':
             // Gets the value for the private _objTopicArray (Read-Only)
             // if set due to an ExpandAsArray on the topic.person_id reverse relationship
             // @return Topic[]
             return (array) $this->_objTopicArray;
         case '_WikiItemAsCurrentPostedBy':
             // Gets the value for the private _objWikiItemAsCurrentPostedBy (Read-Only)
             // if set due to an expansion on the wiki_item.current_posted_by_person_id reverse relationship
             // @return WikiItem
             return $this->_objWikiItemAsCurrentPostedBy;
         case '_WikiItemAsCurrentPostedByArray':
             // Gets the value for the private _objWikiItemAsCurrentPostedByArray (Read-Only)
             // if set due to an ExpandAsArray on the wiki_item.current_posted_by_person_id reverse relationship
             // @return WikiItem[]
             return (array) $this->_objWikiItemAsCurrentPostedByArray;
         case '_WikiVersionAsPostedBy':
             // Gets the value for the private _objWikiVersionAsPostedBy (Read-Only)
             // if set due to an expansion on the wiki_version.posted_by_person_id reverse relationship
             // @return WikiVersion
             return $this->_objWikiVersionAsPostedBy;
         case '_WikiVersionAsPostedByArray':
             // Gets the value for the private _objWikiVersionAsPostedByArray (Read-Only)
             // if set due to an ExpandAsArray on the wiki_version.posted_by_person_id reverse relationship
             // @return WikiVersion[]
             return (array) $this->_objWikiVersionAsPostedByArray;
         case '__Restored':
             return $this->__blnRestored;
         default:
             try {
                 return parent::__get($strName);
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
     }
 }
 public function btnEdit_Click($strFormId, $strControlId, $strParameter)
 {
     $strParameterArray = explode(',', $strParameter);
     $objCountry = Country::Load($strParameterArray[0]);
     $objEditPanel = new CountryEditPanel($this, $this->strCloseEditPanelMethod, $objCountry);
     $strMethodName = $this->strSetEditPanelMethod;
     $this->objForm->{$strMethodName}($objEditPanel);
 }
 /**
  * Override method to perform a property "Get"
  * This will get the value of $strName
  *
  * @param string $strName Name of the property to get
  * @return mixed
  */
 public function __get($strName)
 {
     switch ($strName) {
         ///////////////////
         // Member Variables
         ///////////////////
         case 'StateProvinceId':
             // Gets the value for intStateProvinceId (Read-Only PK)
             // @return integer
             return $this->intStateProvinceId;
         case 'CountryId':
             // Gets the value for intCountryId
             // @return integer
             return $this->intCountryId;
         case 'ShortDescription':
             // Gets the value for strShortDescription
             // @return string
             return $this->strShortDescription;
         case 'Abbreviation':
             // Gets the value for strAbbreviation
             // @return string
             return $this->strAbbreviation;
             ///////////////////
             // Member Objects
             ///////////////////
         ///////////////////
         // Member Objects
         ///////////////////
         case 'Country':
             // Gets the value for the Country object referenced by intCountryId
             // @return Country
             try {
                 if (!$this->objCountry && !is_null($this->intCountryId)) {
                     $this->objCountry = Country::Load($this->intCountryId);
                 }
                 return $this->objCountry;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
             ////////////////////////////
             // Virtual Object References (Many to Many and Reverse References)
             // (If restored via a "Many-to" expansion)
             ////////////////////////////
         ////////////////////////////
         // Virtual Object References (Many to Many and Reverse References)
         // (If restored via a "Many-to" expansion)
         ////////////////////////////
         case '_Address':
             // Gets the value for the private _objAddress (Read-Only)
             // if set due to an expansion on the address.state_province_id reverse relationship
             // @return Address
             return $this->_objAddress;
         case '_AddressArray':
             // Gets the value for the private _objAddressArray (Read-Only)
             // if set due to an ExpandAsArray on the address.state_province_id reverse relationship
             // @return Address[]
             return (array) $this->_objAddressArray;
         case '__Restored':
             return $this->__blnRestored;
         default:
             try {
                 return parent::__get($strName);
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
     }
 }
 /**
  * Override method to perform a property "Get"
  * This will get the value of $strName
  *
  * @param string $strName Name of the property to get
  * @return mixed
  */
 public function __get($strName)
 {
     switch ($strName) {
         ///////////////////
         // Member Variables
         ///////////////////
         case 'StateProvinceId':
             /**
              * Gets the value for intStateProvinceId (Read-Only PK)
              * @return integer
              */
             return $this->intStateProvinceId;
         case 'CountryId':
             /**
              * Gets the value for intCountryId 
              * @return integer
              */
             return $this->intCountryId;
         case 'ShortDescription':
             /**
              * Gets the value for strShortDescription 
              * @return string
              */
             return $this->strShortDescription;
         case 'Abbreviation':
             /**
              * Gets the value for strAbbreviation 
              * @return string
              */
             return $this->strAbbreviation;
             ///////////////////
             // Member Objects
             ///////////////////
         ///////////////////
         // Member Objects
         ///////////////////
         case 'Country':
             /**
              * Gets the value for the Country object referenced by intCountryId 
              * @return Country
              */
             try {
                 if (!$this->objCountry && !is_null($this->intCountryId)) {
                     $this->objCountry = Country::Load($this->intCountryId);
                 }
                 return $this->objCountry;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
             ////////////////////////////
             // Virtual Object References (Many to Many and Reverse References)
             // (If restored via a "Many-to" expansion)
             ////////////////////////////
         ////////////////////////////
         // Virtual Object References (Many to Many and Reverse References)
         // (If restored via a "Many-to" expansion)
         ////////////////////////////
         case '_Address':
             /**
              * Gets the value for the private _objAddress (Read-Only)
              * if set due to an expansion on the address.state_province_id reverse relationship
              * @return Address
              */
             return $this->_objAddress;
         case '_AddressArray':
             /**
              * Gets the value for the private _objAddressArray (Read-Only)
              * if set due to an ExpandAsArray on the address.state_province_id reverse relationship
              * @return Address[]
              */
             return (array) $this->_objAddressArray;
         case '_FedexShipmentAsHoldAtLocationState':
             /**
              * Gets the value for the private _objFedexShipmentAsHoldAtLocationState (Read-Only)
              * if set due to an expansion on the fedex_shipment.hold_at_location_state reverse relationship
              * @return FedexShipment
              */
             return $this->_objFedexShipmentAsHoldAtLocationState;
         case '_FedexShipmentAsHoldAtLocationStateArray':
             /**
              * Gets the value for the private _objFedexShipmentAsHoldAtLocationStateArray (Read-Only)
              * if set due to an ExpandAsArray on the fedex_shipment.hold_at_location_state reverse relationship
              * @return FedexShipment[]
              */
             return (array) $this->_objFedexShipmentAsHoldAtLocationStateArray;
         default:
             try {
                 return parent::__get($strName);
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
     }
 }
Beispiel #13
0
 /**
  * Override method to perform a property "Get"
  * This will get the value of $strName
  *
  * @param string $strName Name of the property to get
  * @return mixed
  */
 public function __get($strName)
 {
     switch ($strName) {
         ///////////////////
         // Member Variables
         ///////////////////
         case 'AddressId':
             // Gets the value for intAddressId (Read-Only PK)
             // @return integer
             return $this->intAddressId;
         case 'CompanyId':
             // Gets the value for intCompanyId (Not Null)
             // @return integer
             return $this->intCompanyId;
         case 'ShortDescription':
             // Gets the value for strShortDescription (Not Null)
             // @return string
             return $this->strShortDescription;
         case 'CountryId':
             // Gets the value for intCountryId (Not Null)
             // @return integer
             return $this->intCountryId;
         case 'Address1':
             // Gets the value for strAddress1 (Not Null)
             // @return string
             return $this->strAddress1;
         case 'Address2':
             // Gets the value for strAddress2
             // @return string
             return $this->strAddress2;
         case 'City':
             // Gets the value for strCity (Not Null)
             // @return string
             return $this->strCity;
         case 'StateProvinceId':
             // Gets the value for intStateProvinceId
             // @return integer
             return $this->intStateProvinceId;
         case 'PostalCode':
             // Gets the value for strPostalCode (Not Null)
             // @return string
             return $this->strPostalCode;
         case 'CreatedBy':
             // Gets the value for intCreatedBy
             // @return integer
             return $this->intCreatedBy;
         case 'CreationDate':
             // Gets the value for dttCreationDate
             // @return QDateTime
             return $this->dttCreationDate;
         case 'ModifiedBy':
             // Gets the value for intModifiedBy
             // @return integer
             return $this->intModifiedBy;
         case 'ModifiedDate':
             // Gets the value for strModifiedDate (Read-Only Timestamp)
             // @return string
             return $this->strModifiedDate;
             ///////////////////
             // Member Objects
             ///////////////////
         ///////////////////
         // Member Objects
         ///////////////////
         case 'Company':
             // Gets the value for the Company object referenced by intCompanyId (Not Null)
             // @return Company
             try {
                 if (!$this->objCompany && !is_null($this->intCompanyId)) {
                     $this->objCompany = Company::Load($this->intCompanyId);
                 }
                 return $this->objCompany;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'Country':
             // Gets the value for the Country object referenced by intCountryId (Not Null)
             // @return Country
             try {
                 if (!$this->objCountry && !is_null($this->intCountryId)) {
                     $this->objCountry = Country::Load($this->intCountryId);
                 }
                 return $this->objCountry;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'StateProvince':
             // Gets the value for the StateProvince object referenced by intStateProvinceId
             // @return StateProvince
             try {
                 if (!$this->objStateProvince && !is_null($this->intStateProvinceId)) {
                     $this->objStateProvince = StateProvince::Load($this->intStateProvinceId);
                 }
                 return $this->objStateProvince;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'CreatedByObject':
             // Gets the value for the UserAccount object referenced by intCreatedBy
             // @return UserAccount
             try {
                 if (!$this->objCreatedByObject && !is_null($this->intCreatedBy)) {
                     $this->objCreatedByObject = UserAccount::Load($this->intCreatedBy);
                 }
                 return $this->objCreatedByObject;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'ModifiedByObject':
             // Gets the value for the UserAccount object referenced by intModifiedBy
             // @return UserAccount
             try {
                 if (!$this->objModifiedByObject && !is_null($this->intModifiedBy)) {
                     $this->objModifiedByObject = UserAccount::Load($this->intModifiedBy);
                 }
                 return $this->objModifiedByObject;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'AddressCustomFieldHelper':
             // Gets the value for the AddressCustomFieldHelper object that uniquely references this Address
             // by objAddressCustomFieldHelper (Unique)
             // @return AddressCustomFieldHelper
             try {
                 if ($this->objAddressCustomFieldHelper === false) {
                     // We've attempted early binding -- and the reverse reference object does not exist
                     return null;
                 }
                 if (!$this->objAddressCustomFieldHelper) {
                     $this->objAddressCustomFieldHelper = AddressCustomFieldHelper::LoadByAddressId($this->intAddressId);
                 }
                 return $this->objAddressCustomFieldHelper;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
             ////////////////////////////
             // Virtual Object References (Many to Many and Reverse References)
             // (If restored via a "Many-to" expansion)
             ////////////////////////////
         ////////////////////////////
         // Virtual Object References (Many to Many and Reverse References)
         // (If restored via a "Many-to" expansion)
         ////////////////////////////
         case '_Company':
             // Gets the value for the private _objCompany (Read-Only)
             // if set due to an expansion on the company.address_id reverse relationship
             // @return Company
             return $this->_objCompany;
         case '_CompanyArray':
             // Gets the value for the private _objCompanyArray (Read-Only)
             // if set due to an ExpandAsArray on the company.address_id reverse relationship
             // @return Company[]
             return (array) $this->_objCompanyArray;
         case '_Contact':
             // Gets the value for the private _objContact (Read-Only)
             // if set due to an expansion on the contact.address_id reverse relationship
             // @return Contact
             return $this->_objContact;
         case '_ContactArray':
             // Gets the value for the private _objContactArray (Read-Only)
             // if set due to an ExpandAsArray on the contact.address_id reverse relationship
             // @return Contact[]
             return (array) $this->_objContactArray;
         case '_ReceiptAsTo':
             // Gets the value for the private _objReceiptAsTo (Read-Only)
             // if set due to an expansion on the receipt.to_address_id reverse relationship
             // @return Receipt
             return $this->_objReceiptAsTo;
         case '_ReceiptAsToArray':
             // Gets the value for the private _objReceiptAsToArray (Read-Only)
             // if set due to an ExpandAsArray on the receipt.to_address_id reverse relationship
             // @return Receipt[]
             return (array) $this->_objReceiptAsToArray;
         case '_ShipmentAsFrom':
             // Gets the value for the private _objShipmentAsFrom (Read-Only)
             // if set due to an expansion on the shipment.from_address_id reverse relationship
             // @return Shipment
             return $this->_objShipmentAsFrom;
         case '_ShipmentAsFromArray':
             // Gets the value for the private _objShipmentAsFromArray (Read-Only)
             // if set due to an ExpandAsArray on the shipment.from_address_id reverse relationship
             // @return Shipment[]
             return (array) $this->_objShipmentAsFromArray;
         case '_ShipmentAsTo':
             // Gets the value for the private _objShipmentAsTo (Read-Only)
             // if set due to an expansion on the shipment.to_address_id reverse relationship
             // @return Shipment
             return $this->_objShipmentAsTo;
         case '_ShipmentAsToArray':
             // Gets the value for the private _objShipmentAsToArray (Read-Only)
             // if set due to an ExpandAsArray on the shipment.to_address_id reverse relationship
             // @return Shipment[]
             return (array) $this->_objShipmentAsToArray;
         case '__Restored':
             return $this->__blnRestored;
         default:
             try {
                 return parent::__get($strName);
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
     }
 }
Beispiel #14
0
function _xls_country()
{
    $objCountry = Country::Load(_xls_get_conf('DEFAULT_COUNTRY', 39));
    return $objCountry->code;
}
 /**
  * Perform validation on the zip/postal code and populate model
  * with error if necessary
  *
  * @param $attribute
  * @return void
  */
 protected function postValidatePostal($attribute, $country)
 {
     if (is_numeric($country) === true) {
         $objCountry = Country::Load($country);
     } else {
         $objCountry = Country::LoadByCode($country);
     }
     if ($objCountry instanceof Country === false) {
         Yii::log(sprintf('Shipping Country: %s is not a valid country', $this->shippingCountry), 'error', 'application.' . __CLASS__ . '.' . __FUNCTION__);
         $this->addError($attribute, Yii::t('yii', '{attribute} is invalid.', array('{attribute}' => $this->getAttributeLabel('shippingCountry'))));
     } else {
         if ($this->{$attribute} == '') {
             $this->addError($attribute, Yii::t('yii', '{attribute} cannot be blank.', array('{attribute}' => $this->getAttributeLabel($attribute))));
         } elseif (is_null($objCountry->zip_validate_preg) === false && _xls_validate_zip($this->{$attribute}, $objCountry->zip_validate_preg) === false) {
             $this->addError($attribute, Yii::t('yii', '{attribute} format is incorrect for this country.', array('{attribute}' => $this->getAttributeLabel($attribute))));
         }
     }
 }
Beispiel #16
0
 protected function lstCountry_Select()
 {
     // Save the currently selected StateProvince
     $intStateProvinceId = $this->lstStateProvince->SelectedValue;
     // Clear out the items from lstAddress
     $this->lstStateProvince->RemoveAllItems();
     if ($this->lstCountry->SelectedValue) {
         // Load the selected country
         $objCountry = Country::Load($this->lstCountry->SelectedValue);
         // Get all available state/provinces for that company
         $objStateProvinceArray = $objCountry->GetStateProvinceArray();
     } else {
         // Or load all addresses for all companies
         $objStateProvinceArray = StateProvince::LoadAll();
     }
     $this->lstStateProvince->AddItem('- Select One -', null);
     if ($objStateProvinceArray) {
         foreach ($objStateProvinceArray as $objStateProvince) {
             // Create a new ListItem Object
             $objListItem = new QListItem($objStateProvince->__toString(), $objStateProvince->StateProvinceId);
             // If this State/Province is the one previously selected, make it selected again
             if ($intStateProvinceId == $objStateProvince->StateProvinceId) {
                 $objListItem->Selected = true;
             }
             // Add the ListItem object
             $this->lstStateProvince->AddItem($objListItem);
             // Enable the input
             $this->lstStateProvince->Enabled = true;
         }
     } else {
         $this->lstStateProvince->Enabled = false;
     }
 }
Beispiel #17
0
 protected function lstCountry_Select($strFormId, $strControlId, $strParameter)
 {
     // Save the currently selected StateProvince
     $intStateProvinceId = $this->lstStateProvince->SelectedValue;
     // Clear out the items from lstAddress
     $this->lstStateProvince->RemoveAllItems();
     if ($this->lstCountry->SelectedValue) {
         // Load the selected country
         $objCountry = Country::Load($this->lstCountry->SelectedValue);
         // Get all available state/provinces for that company
         $objStateProvinceArray = $objCountry->GetStateProvinceArray();
     } else {
         // Or load all addresses for all companies
         $objStateProvinceArray = StateProvince::LoadAll();
     }
     $this->lstStateProvince->AddItem('- Select One -', null);
     if ($objStateProvinceArray) {
         foreach ($objStateProvinceArray as $objStateProvince) {
             $objListItem = new QListItem($objStateProvince->__toString(), $objStateProvince->StateProvinceId);
             if ($intStateProvinceId == $objStateProvince->StateProvinceId) {
                 $objListItem->Selected = true;
             }
             $this->lstStateProvince->AddItem($objListItem);
             $this->lstStateProvince->Enabled = true;
         }
     } else {
         $this->lstStateProvince->Enabled = false;
     }
 }
 /**
  * Set the cart tax code based on an address.
  * The country_id parameter is required, state_id and postal are optional.
  */
 public function actionSetTaxByAddress()
 {
     $intCountryId = Yii::app()->getRequest()->getParam('country_id');
     $intStateId = Yii::app()->getRequest()->getParam('state_id', '');
     $strPostal = Yii::app()->getRequest()->getParam('postal', '');
     $objCountry = Country::Load($intCountryId);
     if ($objCountry === null) {
         throw new CHttpException(400, Yii::t('application errors', 'Invalid country_id.'));
     }
     $strStateCode = null;
     if ($intStateId !== '') {
         $objState = State::Load($intStateId);
         if ($objState === null) {
             throw new CHttpException(400, Yii::t('application errors', 'Invalid state_id.'));
         }
         // Validate the state/country combination.
         $arrShippingStates = Country::getCountryShippingStates($intCountryId);
         if (array_key_exists($intStateId, $arrShippingStates) === false) {
             throw new CHttpException(400, Yii::t('application errors', 'The state_id is not valid for the country_id.'));
         }
         $strStateCode = $objState->code;
     }
     Yii::app()->shoppingcart->setTaxCodeByAddress($objCountry->code, $strStateCode, $strPostal);
     $arrReturn['cartitems'] = $this->renderPartial('/cart/_cartitems', null, true);
     if (Yii::app()->session->get('ship.prices.cache', null) !== null) {
         $arrReturn['action'] = 'triggerCalc';
     }
     return $this->renderJSON($arrReturn);
 }