protected function _mapToModel(array $data, $usePreset = true) { $data = parent::_mapToModel($data, $usePreset); if (isset($data['billingCycleStart']) && !is_array($data['billingCycleStart'])) { $regex = '/^\\-\\-\\-(?P<dayOfMonth>\\d{2,2})(?P<timezone>.*)$/'; if (preg_match($regex, $data['billingCycleStart'], $matches)) { $tz = App_Util_Date::getTimezoneValue($matches['timezone']); $matches['dayOfMonth'] = intval($matches['dayOfMonth']); $enumService = Application\Service\EnumeratedService::getInstance(); $timezones = $enumService->getEnum(Application\Service\EnumeratedService::TIME_ZONE_ENUM_NAME); foreach ($timezones as $exmpl) { if ($exmpl['offset'] == $matches['timezone']) { $tz = $exmpl['id']; break; } } $matches['timezone'] = $tz; $data['billingCycleStart'] = $matches; } else { $data['billingCycleStart'] = array(); } } if (isset($data['defaultBillingAccount']['contact'])) { $data['defaultBillingAccount']['contactIsPrimaryContact'] = false; } if (isset($data['defaultBillingAccount']['address'])) { $data['defaultBillingAccount']['addressIsCompanyAddress'] = false; } if (isset($data['shippingAddress'])) { $data['shippingAddressIsCompanyAddress'] = false; } if (isset($data['billingContact'])) { $data['billingContactIsPrimaryContact'] = false; } if (isset($data['billingContactAddress'])) { $data['billingContactAddressIsCompanyAddress'] = false; } if (isset($data['primaryContactAddress'])) { $data['primaryContactAddressIsCompanyAddress'] = false; } if ($usePreset && !isset($data['parentId'])) { $data['parentId'] = \App::getOrgUserLogged()->getId(); } return $data; }
public function init() { $this->srv = SupplServicesService::getInstance(); $this->enumSrv = Application\Service\EnumeratedService::getInstance(); }