Exemple #1
0
 public function __construct($name = null, $datas, $options, $type)
 {
     /**
      * @var \DDD\Domain\Geolocation\Details $data
      */
     parent::__construct($name);
     $name = $this->getName();
     if (null === $name) {
         $this->setName('location');
     }
     $this->add(['name' => 'name', 'options' => ['label' => ''], 'attributes' => ['type' => 'text', 'class' => 'form-control', 'id' => 'name', 'maxlength' => 150]]);
     $this->add(['name' => 'slug', 'options' => ['label' => ''], 'attributes' => ['type' => 'text', 'class' => 'form-control', 'id' => 'name', 'maxlength' => 255]]);
     if (isset($datas) || $type == LocationService::LOCATION_TYPE_CITY) {
         $timeZoneOptions = Objects::getTimezoneOptions();
         $this->add(['name' => 'timezone', 'type' => 'Zend\\Form\\Element\\Select', 'options' => ['label' => false, 'value_options' => $timeZoneOptions], 'attributes' => ['class' => 'form-control', 'id' => 'timezone']]);
     }
     $this->add(['name' => 'autocomplete_txt', 'options' => ['label' => ''], 'attributes' => ['type' => 'text', 'class' => 'form-control', 'id' => 'autocomplete_txt', 'maxlength' => 150]]);
     $this->add(['name' => 'latitude', 'options' => ['label' => 'LONGITUDE'], 'attributes' => ['type' => 'hidden', 'class' => 'form-control', 'id' => 'latitude']]);
     $this->add(['name' => 'longitude', 'options' => ['label' => 'LONGITUDE'], 'attributes' => ['type' => 'hidden', 'class' => 'form-control', 'id' => 'longitude']]);
     $this->add(['name' => 'information', 'options' => ['label' => ''], 'attributes' => ['type' => 'textarea', 'class' => 'tinymce', 'rows' => '15', 'id' => 'information']]);
     $this->add(['name' => 'cover_image', 'options' => ['label' => ''], 'attributes' => ['type' => 'file', 'id' => 'img1', 'class' => 'hidden-file-input invisible']]);
     $this->add(['name' => 'thumbnail', 'options' => ['label' => ''], 'attributes' => ['type' => 'file', 'id' => 'img2', 'class' => 'hidden-file-input invisible']]);
     /**
      * Selling
      */
     $is_salling = ['id' => 'is_selling', 'use_hidden_element' => false, 'checked_value' => 1, 'unchecked_value' => 0];
     if (is_array($datas)) {
         $data = $datas['details'];
     } else {
         $data = '';
     }
     if (is_object($data) && $data->getIs_selling() > 0) {
         $is_salling['checked'] = 'checked';
     }
     $this->add(['name' => 'is_selling', 'options' => ['label' => ''], 'type' => 'Zend\\Form\\Element\\Checkbox', 'attributes' => $is_salling]);
     /**********Country**********/
     $this->add(['name' => 'iso', 'options' => ['label' => ''], 'attributes' => ['type' => 'text', 'class' => 'form-control', 'id' => 'iso', 'maxlength' => 10]]);
     $this->add(['name' => 'currency', 'type' => 'Zend\\Form\\Element\\Select', 'options' => ['label' => false, 'value_options' => $options['currency_list']], 'attributes' => ['class' => 'form-control', 'id' => 'currency']]);
     $this->add(['name' => 'required_postal_code', 'type' => 'Zend\\Form\\Element\\Select', 'options' => ['label' => false, 'value_options' => \DDD\Service\Location::getRequiredPostalCodes()], 'attributes' => ['class' => 'form-control', 'id' => 'required_postal_code']]);
     $this->add(['name' => 'contact_phone', 'type' => 'Zend\\Form\\Element\\Text', 'options' => ['label' => 'Contact Phone'], 'attributes' => ['class' => 'form-control', 'id' => 'contact_phone']]);
     /************City**************/
     $is_searchable = ['id' => 'is_searchable', 'use_hidden_element' => false, 'checked_value' => 1, 'unchecked_value' => 0];
     if (is_object($data) && $data->getIs_searchable() > 0) {
         $is_searchable['checked'] = 'checked';
     }
     $this->add(['name' => 'is_searchable', 'options' => ['label' => 'Searchable'], 'type' => 'Zend\\Form\\Element\\Checkbox', 'attributes' => $is_searchable]);
     $taxIncludedOptions = [LocationService::TAX_INCLUDED => 'Included', LocationService::TAX_EXCLUDED => 'Excluded'];
     $totIncluded = ['id' => 'tot_included', 'class' => 'form-control'];
     $vatIncluded = ['id' => 'vat_included', 'class' => 'form-control'];
     $cityTaxIncluded = ['id' => 'city_tax_included', 'class' => 'form-control'];
     $salesTaxIncluded = ['id' => 'city_tax_included', 'class' => 'form-control'];
     $this->add(['name' => 'tot', 'attributes' => ['type' => 'text', 'class' => 'form-control tax-value', 'id' => 'tot', 'placeholder' => 'Pure']]);
     $this->add(['name' => 'tot_additional', 'attributes' => ['type' => 'text', 'class' => 'form-control tax-value', 'id' => 'tot', 'placeholder' => 'Additional']]);
     $this->add(['name' => 'tot_type', 'type' => 'Zend\\Form\\Element\\Select', 'options' => ['label' => false, 'value_options' => Taxes::getTaxesType()], 'attributes' => ['class' => 'form-control tax-type', 'id' => 'tot_type']]);
     $this->add(['name' => 'tot_included', 'options' => ['label' => 'TOT Included', 'value_options' => $taxIncludedOptions], 'type' => 'Zend\\Form\\Element\\Select', 'attributes' => $totIncluded]);
     $this->add(['name' => 'tot_max_duration', 'attributes' => ['type' => 'text', 'placeholder' => 'Max. Duration', 'class' => 'form-control tax-duration', 'id' => 'tot-max-duration']]);
     $this->add(['name' => 'vat', 'attributes' => ['type' => 'text', 'class' => 'form-control tax-value', 'id' => 'vat', 'placeholder' => 'Pure']]);
     $this->add(['name' => 'vat_additional', 'attributes' => ['type' => 'text', 'class' => 'form-control tax-value', 'id' => 'vat', 'placeholder' => 'Additional']]);
     $this->add(['name' => 'vat_type', 'type' => 'Zend\\Form\\Element\\Select', 'options' => ['label' => false, 'value_options' => Taxes::getTaxesType()], 'attributes' => ['class' => 'form-control tax-type', 'id' => 'vat_type']]);
     $this->add(['name' => 'vat_included', 'options' => ['label' => 'VAT Included', 'value_options' => $taxIncludedOptions], 'type' => 'Zend\\Form\\Element\\Select', 'attributes' => $vatIncluded]);
     $this->add(['name' => 'vat_max_duration', 'attributes' => ['type' => 'text', 'placeholder' => 'Max. Duration', 'class' => 'form-control tax-duration', 'id' => 'vat-max-duration']]);
     $this->add(['name' => 'sales_tax', 'attributes' => ['type' => 'text', 'class' => 'form-control tax-value', 'id' => 'sales_tax', 'placeholder' => 'Pure']]);
     $this->add(['name' => 'sales_tax_additional', 'attributes' => ['type' => 'text', 'class' => 'form-control tax-value', 'id' => 'sales_tax', 'placeholder' => 'Additional']]);
     $this->add(['name' => 'sales_tax_type', 'type' => 'Zend\\Form\\Element\\Select', 'options' => ['label' => false, 'value_options' => Taxes::getTaxesType()], 'attributes' => ['class' => 'form-control tax-type', 'id' => 'sales_tax_type']]);
     $this->add(['name' => 'sales_tax_included', 'options' => ['label' => 'Sales Tax Included', 'value_options' => $taxIncludedOptions], 'type' => 'Zend\\Form\\Element\\Select', 'attributes' => $salesTaxIncluded]);
     $this->add(['name' => 'sales_tax_max_duration', 'attributes' => ['type' => 'text', 'placeholder' => 'Max. Duration', 'class' => 'form-control tax-duration', 'id' => 'sales-tax-max-duration']]);
     $this->add(['name' => 'city_tax', 'attributes' => ['type' => 'text', 'class' => 'form-control tax-value', 'id' => 'city_tax', 'placeholder' => 'Pure']]);
     $this->add(['name' => 'city_tax_additional', 'attributes' => ['type' => 'text', 'class' => 'form-control tax-value', 'id' => 'city_tax', 'placeholder' => 'Additional']]);
     $this->add(['name' => 'city_tax_type', 'type' => 'Zend\\Form\\Element\\Select', 'options' => ['label' => false, 'value_options' => Taxes::getTaxesType(true)], 'attributes' => ['class' => 'form-control tax-type', 'id' => 'city_tax_type']]);
     $this->add(['name' => 'city_tax_included', 'options' => ['label' => 'City Tax Included', 'value_options' => $taxIncludedOptions], 'type' => 'Zend\\Form\\Element\\Select', 'attributes' => $cityTaxIncluded]);
     $this->add(['name' => 'city_tax_max_duration', 'attributes' => ['type' => 'text', 'placeholder' => 'Max. Duration', 'class' => 'form-control tax-duration', 'id' => 'city-tax-max-duration']]);
     /**********POI**********/
     $poi_type = [];
     if (isset($options['poi_types'])) {
         foreach ($options['poi_types'] as $row) {
             $poi_type[$row->getId()] = $row->getName();
         }
     }
     $this->add(['name' => 'poi_type', 'options' => ['label' => 'POI Type', 'value_options' => $poi_type], 'type' => 'Zend\\Form\\Element\\Select', 'attributes' => ['id' => 'poi_type', 'class' => 'form-control']]);
     $this->add(['name' => 'ws_show_right_column', 'type' => 'Zend\\Form\\Element\\Checkbox', 'options' => ['label' => 'Show Right Column', 'for' => "ws_show_right_column"], 'attributes' => ['id' => 'ws_show_right_column']]);
     $buttons_save = 'Create New Location';
     if (is_object($data)) {
         $buttons_save = 'Save Changes';
     }
     $this->add(['name' => 'save_button', 'options' => ['label' => $buttons_save], 'attributes' => ['type' => 'button', 'class' => 'btn btn-primary pull-right col-sm-2 col-xs-12 margin-left-10', 'data-loading-text' => 'Saving...', 'id' => 'save_button', 'value' => 'Save']]);
     $this->add(['name' => 'edit_id', 'attributes' => ['type' => 'hidden', 'id' => 'edit_id']]);
     $this->add(['name' => 'type_location', 'attributes' => ['type' => 'hidden', 'id' => 'type_location']]);
     $this->add(['name' => 'cover_image_post', 'attributes' => ['type' => 'hidden', 'id' => 'img1_post']]);
     $this->add(['name' => 'thumbnail_post', 'attributes' => ['type' => 'hidden', 'id' => 'img2_post']]);
     $this->add(['name' => 'autocomplete_id', 'attributes' => ['type' => 'hidden', 'id' => 'autocomplete_id']]);
     $this->add(['name' => 'edit_name', 'attributes' => ['type' => 'hidden', 'id' => 'edit_name']]);
     $this->add(['name' => 'edit_location_id', 'attributes' => ['type' => 'hidden', 'id' => 'edit_location_id']]);
     $this->add(['name' => 'poi_type_chaneg', 'attributes' => ['type' => 'hidden', 'id' => 'poi_type_chaneg']]);
     $this->add(['name' => 'province_short_name', 'attributes' => ['type' => 'text', 'class' => 'form-control', 'maxlength' => 150, 'id' => 'province_short_name']]);
     if (is_object($data)) {
         $this->add(['name' => 'delete_button', 'options' => ['label' => 'Delete'], 'attributes' => ['type' => 'button', 'class' => 'btn btn-danger pull-right col-sm-2 col-xs-12 margin-left-10', 'data-loading-text' => 'Deleteing...', 'id' => 'delete_button', 'value' => 'Delete']]);
     }
     if (is_object($data)) {
         $objectData = new \ArrayObject();
         $objectData['name'] = $data->getName();
         $objectData['edit_name'] = $data->getName();
         $objectData['latitude'] = $data->getLatitude();
         $objectData['longitude'] = $data->getLongitude();
         $objectData['information'] = $data->getInformation_text();
         $objectData['edit_id'] = $data->getId();
         $objectData['type_location'] = $type;
         $objectData['cover_image_post'] = '';
         $objectData['thumbnail_post'] = '';
         if ($data->getCover_image()) {
             $objectData['cover_image_post'] = '/locations/' . $data->getId() . '/' . $data->getCover_image();
         }
         if ($data->getThumbnail()) {
             $objectData['thumbnail_post'] = '/locations/' . $data->getId() . '/' . $data->getThumbnail();
         }
         if ($type == LocationService::LOCATION_TYPE_COUNTRY) {
             $objectData['iso'] = $data->getIso();
             $objectData['currency'] = isset($datas['currency']) ? $datas['currency'] : 0;
             $objectData['required_postal_code'] = isset($datas['required_postal_code']) ? $datas['required_postal_code'] : 0;
             $objectData['contact_phone'] = isset($datas['contactPhone']) ? $datas['contactPhone'] : 0;
         }
         if ($type == LocationService::LOCATION_TYPE_PROVINCE) {
             $objectData['province_short_name'] = $datas['province_short_name'];
         }
         if ($type == LocationService::LOCATION_TYPE_CITY) {
             if ($data->getTotType()) {
                 $objectData['tot_type'] = $data->getTotType();
                 $objectData['tot'] = $data->getTot() ? $data->getTot() : '';
                 $objectData['tot_additional'] = $data->getTotAdditional() ? $data->getTotAdditional() : '';
                 $objectData['tot_included'] = $data->getTotIncluded();
                 $objectData['tot_max_duration'] = $data->getTotMaxDuration() ? $data->getTotMaxDuration() : '';
             }
             if ($data->getVatType()) {
                 $objectData['vat_type'] = $data->getVatType();
                 $objectData['vat'] = $data->getVat() ? $data->getVat() : '';
                 $objectData['vat_additional'] = $data->getVatAdditional() ? $data->getVatAdditional() : '';
                 $objectData['vat_included'] = $data->getVatIncluded();
                 $objectData['vat_max_duration'] = $data->getVatMaxDuration() ? $data->getVatMaxDuration() : '';
             }
             if ($data->getSalesTaxType()) {
                 $objectData['sales_tax_type'] = $data->getSalesTaxType();
                 $objectData['sales_tax'] = $data->getSales_tax() ? $data->getSales_tax() : '';
                 $objectData['sales_tax_additional'] = $data->getSalesTaxAdditional();
                 $objectData['sales_tax_included'] = $data->getSalesTaxIncluded();
                 $objectData['sales_tax_max_duration'] = $data->getSalesTaxMaxDuration() ? $data->getSalesTaxMaxDuration() : '';
             }
             if ($data->getCityTaxType()) {
                 $objectData['city_tax_type'] = $data->getCityTaxType();
                 $objectData['city_tax'] = $data->getCity_tax() ? $data->getCity_tax() : '';
                 $objectData['city_tax_additional'] = $data->getCityTaxAdditional() ? $data->getCityTaxAdditional() : '';
                 $objectData['city_tax_included'] = $data->getCityTaxIncluded();
                 $objectData['city_tax_max_duration'] = $data->getCityTaxMaxDuration() ? $data->getCityTaxMaxDuration() : '';
             }
             $objectData['timezone'] = isset($datas['timezone']) ? $datas['timezone'] : '';
         }
         if ($type == LocationService::LOCATION_TYPE_POI) {
             $poitype = $datas['poitype'];
             $objectData['poi_type'] = $poitype->getType_id();
             $objectData['poi_type_chaneg'] = $poitype->getType_id();
             $objectData['ws_show_right_column'] = $poitype->getWsShowRightColumn();
         }
         $this->bind($objectData);
     }
 }
Exemple #2
0
 /**
  *
  * @return array
  */
 private function getTimeZoneList()
 {
     return ['' => '-- Choose Timezone --'] + Objects::getTimezoneOptions();
 }
Exemple #3
0
 public function __construct($name, $data, $options, $global, $isDirector, $alreadyAttachedApartments = [])
 {
     parent::__construct($name);
     $this->setName($name);
     $name_attr = ['type' => 'text', 'class' => 'form-control', 'id' => 'name', 'maxlength' => 50];
     $desc_attr = ['type' => 'text', 'class' => 'form-control', 'id' => 'description', 'maxlength' => 255];
     $members_attr = ['id' => 'members', 'class' => 'form-control', 'multiple' => true];
     $officersAttr = ['id' => 'officers', 'class' => 'form-control', 'multiple' => true];
     $managers_attr = ['class' => 'form-control selectize', 'id' => 'managers', 'multiple' => true];
     $isDirectorAttr = ['class' => 'form-control', 'id' => 'director'];
     $company_department = ['id' => 'usage_department', 'use_hidden_element' => false, 'checked_value' => 1, 'unchecked_value' => 0];
     $comment_notifiable = ['id' => 'usage_notifiable', 'use_hidden_element' => false, 'checked_value' => 1, 'unchecked_value' => 0];
     $isFrontier = ['id' => 'usage_frontier', 'use_hidden_element' => true, 'checked_value' => 1, 'unchecked_value' => 0];
     $isSecurity = ['id' => 'usage_security', 'use_hidden_element' => false, 'checked_value' => 1, 'unchecked_value' => 0];
     $usageHiring = ['id' => 'usage_hiring', 'use_hidden_element' => false, 'checked_value' => 1, 'unchecked_value' => 0];
     $usageStorage = ['id' => 'usage_storage', 'use_hidden_element' => false, 'checked_value' => 1, 'unchecked_value' => 0];
     $isTaskable = ['id' => 'usage_taskable', 'use_hidden_element' => false, 'checked_value' => 1, 'unchecked_value' => 0];
     $frontierApartmentsAttr = ['id' => 'frontier-apartments', 'class' => 'form-control', 'multiple' => true];
     $frontierBuildingsAttr = ['id' => 'frontier-buildings', 'class' => 'form-control selectize', 'multiple' => true];
     if (!$global) {
         $name_attr['disabled'] = true;
         $desc_attr['disabled'] = true;
         $isDirectorAttr['disabled'] = true;
     }
     if (!$global && !$isDirector) {
         $managers_attr['disabled'] = true;
         $company_department['disabled'] = true;
         $isFrontier['disabled'] = true;
         $isSecurity['disabled'] = true;
         $isTaskable['disabled'] = true;
         $comment_notifiable['disabled'] = true;
         $frontierApartmentsAttr['disabled'] = true;
         $frontierBuildingsAttr['disabled'] = true;
     }
     $this->add(['name' => 'name', 'attributes' => $name_attr]);
     $this->add(['name' => 'description', 'attributes' => $desc_attr]);
     $memberList = [0 => '-- Choose --'];
     $memberRawList = $options->get('ginosiksList');
     if ($memberRawList->count()) {
         foreach ($memberRawList as $member) {
             $memberList[$member['id']] = $member['firstname'] . ' ' . $member['lastname'];
         }
     }
     $this->add(array('name' => 'director', 'type' => 'Zend\\Form\\Element\\Select', 'options' => ['value_options' => $memberList], 'attributes' => $isDirectorAttr));
     unset($memberList[0]);
     $this->add(array('name' => 'members', 'type' => 'Zend\\Form\\Element\\Select', 'options' => ['value_options' => $memberList], 'attributes' => $members_attr));
     $this->add(array('name' => 'officers', 'type' => 'Zend\\Form\\Element\\Select', 'options' => ['value_options' => $memberList], 'attributes' => $officersAttr));
     $this->add(array('name' => 'managers', 'type' => 'Zend\\Form\\Element\\Select', 'options' => ['value_options' => $memberList], 'attributes' => $managers_attr));
     if (is_object($data)) {
         if ($data->get('general')->getIsDepartment()) {
             $company_department['checked'] = 'checked';
         }
         if ($data->get('general')->getUsageSecurity()) {
             $isSecurity['checked'] = 'checked';
         }
         if ($data->get('general')->getUsageHiring()) {
             $usageHiring['checked'] = 'checked';
         }
         if ($data->get('general')->getUsageStorage()) {
             $usageStorage['checked'] = 'checked';
         }
         if ($data->get('general')->isCommentNotifiable()) {
             $comment_notifiable['checked'] = 'checked';
         }
         if ($data->get('general')->isFrontier()) {
             $isFrontier['checked'] = 'checked';
         }
         if ($data->get('general')->isTaskable()) {
             $isTaskable['checked'] = 'checked';
         }
     }
     $this->add(['name' => 'usage_department', 'type' => 'Zend\\Form\\Element\\Checkbox', 'attributes' => $company_department]);
     $this->add(['name' => 'usage_security', 'type' => 'Zend\\Form\\Element\\Checkbox', 'attributes' => $isSecurity]);
     $this->add(['name' => 'usage_hiring', 'type' => 'Zend\\Form\\Element\\Checkbox', 'attributes' => $usageHiring]);
     $this->add(['name' => 'usage_storage', 'type' => 'Zend\\Form\\Element\\Checkbox', 'attributes' => $usageStorage]);
     $this->add(['name' => 'usage_taskable', 'type' => 'Zend\\Form\\Element\\Checkbox', 'attributes' => $isTaskable]);
     $this->add(['name' => 'usage_notifiable', 'type' => 'Zend\\Form\\Element\\Checkbox', 'attributes' => $comment_notifiable]);
     $this->add(['name' => 'usage_frontier', 'type' => 'Zend\\Form\\Element\\Checkbox', 'attributes' => $isFrontier]);
     foreach ($options->get('accommodationList') as $row) {
         $name = $row->getName();
         if (array_key_exists($row->getId(), $alreadyAttachedApartments)) {
             continue;
         }
         $accommodations[$row->getId()] = $name;
     }
     $this->add(array('name' => 'frontier_apartments', 'type' => 'Zend\\Form\\Element\\Select', 'options' => ['value_options' => $accommodations], 'attributes' => $frontierApartmentsAttr));
     $this->add(array('name' => 'frontier_buildings', 'type' => 'Zend\\Form\\Element\\Select', 'options' => ['value_options' => $options->get('apartmentGroups')], 'attributes' => $frontierBuildingsAttr));
     $this->add(['name' => 'extra_inspection', 'type' => 'Zend\\Form\\Element\\Checkbox', 'attributes' => ['id' => 'extra_inspection', 'use_hidden_element' => false, 'checked_value' => 1, 'unchecked_value' => 0]]);
     $this->add(['name' => 'timezone', 'options' => ['label' => '', 'value_options' => ['' => '-- Choose Timezone --'] + Objects::getTimezoneOptions()], 'type' => 'Zend\\Form\\Element\\Select', 'attributes' => ['id' => 'timezone', 'class' => 'form-control']]);
     $buttons_save = 'Create Team';
     if (is_object($data)) {
         $buttons_save = 'Save';
     }
     $this->add(['name' => 'save_button', 'options' => ['label' => $buttons_save], 'attributes' => ['type' => 'button', 'class' => 'btn btn-primary state col-sm-2 ' . 'col-xs-12 margin-left-10 pull-right', 'data-loading-text' => 'Saving...', 'id' => 'save_button', 'value' => 'Save']]);
     if ($global) {
         $this->add(['name' => 'group_delete_button', 'options' => ['label' => 'Delete Group'], 'attributes' => ['type' => 'button', 'class' => 'btn btn-danger btn-large ' . 'pull-right helper-margin-left-04em state', 'data-loading-text' => 'Deleteing...', 'id' => 'group_delete_button', 'value' => 'Delete Group']]);
     }
     if (is_object($data)) {
         $objectData = new \ArrayObject();
         $teamManagers = $data->get('teamManagers');
         $teamOfficers = $data->get('teamOfficers');
         $teamMembers = $data->get('teamMembers');
         $allUsers = $data->get('allUsers');
         $members = [];
         $memberListNew = $memberList;
         if (!empty($teamMembers)) {
             foreach ($teamMembers as $row) {
                 $members[] = $row->getUserId();
                 if (!isset($memberListNew[$row->getUserId()])) {
                     $memberListNew[$row->getUserId()] = $allUsers[$row->getUserId()];
                 }
             }
         }
         if ($memberListNew != $memberList) {
             $this->get('members')->setOptions(['value_options' => $memberListNew]);
         }
         $managers = [];
         $managerListNew = $memberList;
         if (!empty($teamManagers)) {
             foreach ($teamManagers as $row) {
                 $managers[] = $row->getUserId();
                 if (!isset($managerListNew[$row->getUserId()])) {
                     $managerListNew[$row->getUserId()] = $allUsers[$row->getUserId()];
                 }
             }
         }
         if ($managerListNew != $memberList) {
             $this->get('managers')->setOptions(['value_options' => $managerListNew]);
         }
         $officers = [];
         $officerListNew = $memberList;
         if (!empty($teamOfficers)) {
             foreach ($teamOfficers as $row) {
                 $officers[] = $row->getUserId();
                 if (!isset($officerListNew[$row->getUserId()])) {
                     $officerListNew[$row->getUserId()] = $allUsers[$row->getUserId()];
                 }
             }
         }
         if ($officerListNew != $memberList) {
             $this->get('officers')->setOptions(['value_options' => $officerListNew]);
         }
         $apartments = [];
         if ($data->get('frontierApartments')) {
             foreach ($data->get('frontierApartments') as $row) {
                 $apartments[] = $row->getApartmentId();
             }
         }
         $buildings = [];
         if ($data->get('frontierBuildings')) {
             foreach ($data->get('frontierBuildings') as $row) {
                 $buildings[] = $row->getBuildingId();
             }
         }
         $objectData['members'] = $members;
         $objectData['officers'] = $officers;
         $objectData['frontier_buildings'] = $buildings;
         $objectData['frontier_apartments'] = $apartments;
         $objectData['managers'] = $managers;
         if ($data->get('director')) {
             $objectData['director'] = $data->get('director')->getUserId();
         }
         $objectData['name'] = $data->get('general')->getName();
         $objectData['description'] = $data->get('general')->getDescription();
         $objectData['extra_inspection'] = $data->get('general')->getExtraInspection();
         $objectData['timezone'] = $data->get('general')->getTimezone();
         $this->bind($objectData);
     }
 }
Exemple #4
0
 public function __construct($name = null, $data, $options)
 {
     parent::__construct($name);
     $name = $this->getName();
     if (null === $name) {
         $this->setName('user');
     }
     $email_attr = array('type' => 'Zend\\Form\\Element\\Email', 'class' => 'form-control', 'id' => 'email', 'maxlength' => 40);
     $this->add(array('name' => 'email', 'options' => array('label' => ''), 'attributes' => $email_attr));
     $this->add(array('name' => 'alt_email', 'options' => array('label' => ''), 'attributes' => array('type' => 'Zend\\Form\\Element\\Email', 'class' => 'form-control', 'id' => 'alt_email', 'maxlength' => 40)));
     $this->add(array('name' => 'password', 'options' => array('label' => ''), 'attributes' => array('class' => 'form-control', 'type' => 'password', 'id' => 'password', 'maxlength' => 20)));
     $this->add(array('name' => 'firstname', 'options' => array('label' => ''), 'attributes' => array('type' => 'text', 'class' => 'form-control', 'id' => 'firstname', 'maxlength' => 35)));
     $this->add(array('name' => 'lastname', 'options' => array('label' => ''), 'attributes' => array('type' => 'text', 'class' => 'form-control', 'id' => 'lastname', 'maxlength' => 35)));
     $this->add(array('name' => 'birthday', 'options' => array('label' => ''), 'attributes' => array('type' => 'text', 'class' => 'form-control datepicker', 'id' => 'birthday')));
     $this->add(array('name' => 'living_city', 'options' => array('label' => ''), 'attributes' => array('type' => 'text', 'class' => 'form-control', 'id' => 'living_city', 'maxlength' => 200)));
     $this->add(['name' => 'external', 'type' => 'Zend\\Form\\Element\\Checkbox', 'attributes' => ['id' => 'external'], 'options' => []]);
     $managers = [0 => '-- Choose Manager --'];
     foreach ($options->get('managers') as $row) {
         $managers[$row->getId()] = $row->getFirstName() . ' ' . $row->getLastName();
     }
     $this->add(array('name' => 'manager', 'options' => array('label' => '', 'value_options' => $managers), 'type' => 'Zend\\Form\\Element\\Select', 'attributes' => array('id' => 'manager', 'class' => 'form-control')));
     $countries = array('0' => '-- Choose Countries --');
     foreach ($options->get('countries') as $row) {
         $countries[$row->getId()] = $row->getName();
     }
     $cities = $options->get('cities');
     $this->add(array('name' => 'country', 'options' => array('label' => '', 'value_options' => $countries), 'type' => 'Zend\\Form\\Element\\Select', 'attributes' => array('id' => 'country', 'class' => 'form-control')));
     $this->add(array('name' => 'city', 'options' => array('label' => '', 'value_options' => $cities), 'type' => 'Zend\\Form\\Element\\Select', 'attributes' => array('id' => 'city', 'class' => 'form-control')));
     $this->add(array('name' => 'timezone', 'options' => array('label' => '', 'value_options' => Objects::getTimezoneOptions()), 'type' => 'Zend\\Form\\Element\\Select', 'attributes' => array('id' => 'timezone', 'class' => 'form-control')));
     $this->add(array('name' => 'last_login', 'options' => array('label' => ''), 'type' => 'Text', 'attributes' => array('id' => 'last_login', 'class' => 'form-control', 'disabled' => true)));
     $this->add(array('name' => 'internal_number', 'options' => array('label' => '', 'required' => false), 'type' => 'Number', 'attributes' => array('id' => 'internal_number', 'class' => 'form-control', 'min' => 0, 'value' => 0)));
     $this->add(array('name' => 'startdate', 'options' => array('label' => ''), 'attributes' => array('type' => 'text', 'class' => 'form-control datepicker', 'id' => 'startdate')));
     $this->add(array('name' => 'end_date', 'options' => array('label' => ''), 'attributes' => array('type' => 'text', 'class' => 'form-control datepicker', 'id' => 'startdate')));
     $this->add(array('name' => 'vacationdays', 'options' => array('label' => ''), 'attributes' => array('type' => 'Float', 'class' => 'form-control', 'id' => 'vacationdays', 'max' => 365, 'min' => -365, 'maxlength' => 16)));
     $this->add(array('name' => 'vacation_days_per_year', 'options' => array('label' => ''), 'attributes' => array('type' => 'text', 'class' => 'form-control', 'id' => 'vacation_days_per_year', 'max' => 365, 'min' => 0, 'maxlength' => 6)));
     $this->add(array('name' => 'personalphone', 'options' => array('label' => ''), 'attributes' => array('type' => 'text', 'class' => 'form-control', 'id' => 'personalphone', 'maxlength' => 15)));
     $this->add(array('name' => 'businessphone', 'options' => array('label' => ''), 'attributes' => array('type' => 'text', 'class' => 'form-control', 'id' => 'businessphone', 'maxlength' => 15)));
     $this->add(array('name' => 'emergencyphone', 'options' => array('label' => ''), 'attributes' => array('type' => 'text', 'class' => 'form-control', 'id' => 'emergencyphone', 'maxlength' => 15)));
     $this->add(array('name' => 'housephone', 'options' => array('label' => ''), 'attributes' => array('type' => 'text', 'class' => 'form-control', 'id' => 'housephone', 'maxlength' => 15)));
     $this->add(array('name' => 'asana_id', 'options' => array('label' => ''), 'attributes' => array('type' => 'text', 'class' => 'form-control', 'id' => 'asana_id', 'maxlength' => 25)));
     $this->add(array('name' => 'address_permanent', 'options' => array('label' => ''), 'type' => 'Zend\\Form\\Element\\Textarea', 'attributes' => array('class' => 'form-control', 'rows' => 3, 'id' => 'address_permanent', 'maxlength' => 250)));
     $this->add(array('name' => 'address_residence', 'options' => array('label' => ''), 'type' => 'Zend\\Form\\Element\\Textarea', 'attributes' => array('class' => 'form-control', 'rows' => 3, 'id' => 'address_residence', 'maxlength' => 250)));
     $dashboards = array();
     foreach ($options->get('dashboards') as $dashboard) {
         $dashboards[$dashboard->getId()] = $dashboard->getName();
     }
     $this->add(array('name' => 'dashboards', 'options' => array('label' => '', 'value_options' => $dashboards), 'type' => 'Zend\\Form\\Element\\Select', 'attributes' => array('id' => 'dashboards', 'class' => 'selectize form-control', 'multiple' => 'multiple')));
     $this->add(array('name' => 'system', 'type' => 'Zend\\Form\\Element\\Checkbox', 'options' => array('label' => 'System User', 'use_hidden_element' => true, 'checked_value' => 1, 'unchecked_value' => 0), 'attributes' => ['class' => 'margin-top-10', 'id' => 'system']));
     $user_concierge_array = [];
     if (!is_null($data)) {
         $obj_user_concierge = $data->get('user_conciergegroups');
         foreach ($obj_user_concierge as $row) {
             $user_concierge_array[] = $row->getApartmentGroupId();
         }
     }
     $conciergegroups = [];
     foreach ($options->get('concierges') as $row) {
         $conciergegroups[$row->getId()] = $row->getName();
     }
     $this->add(array('name' => 'conciergegroups', 'options' => array('label' => '', 'value_options' => $conciergegroups), 'type' => 'Zend\\Form\\Element\\Select', 'attributes' => array('id' => 'conciergegroups', 'class' => 'selectize form-control', 'multiple' => 'multiple')));
     $submitLable = 'Save Changes';
     if (is_null($data)) {
         $submitLable = 'Create User';
     }
     $this->add(array('name' => 'user_button', 'options' => array('label' => $submitLable), 'attributes' => array('type' => 'button', 'class' => 'btn btn-primary personal-tab-btn administration-tab-btn permission-tab-btn pull-right margin-left-10 col-sm-2 col-xs-12', 'data-loading-text' => 'Saving...', 'id' => 'user_button', 'value' => $submitLable)));
     $officeRawList = $options->get('office');
     $offices = ['-1' => '-- Choose Office --'];
     if (count($officeRawList)) {
         foreach ($officeRawList as $key => $office) {
             $offices[$key] = $office;
         }
     }
     if (is_object($data)) {
         $userOffice = $data->get('userOffice');
         if (!is_null($userOffice)) {
             $offices += $userOffice;
         }
     }
     $this->add(array('name' => 'reporting_office_id', 'options' => array('label' => '', 'value_options' => $offices), 'type' => 'Zend\\Form\\Element\\Select', 'attributes' => array('id' => 'reporting_office_id', 'class' => 'form-control')));
     $departments = $options->get('departments');
     $this->add(array('name' => 'department', 'options' => array('label' => '', 'value_options' => $departments), 'type' => 'Zend\\Form\\Element\\Select', 'attributes' => array('id' => 'department', 'class' => 'form-control')));
     $this->add(array('name' => 'position', 'options' => array('label' => ''), 'attributes' => array('type' => 'text', 'class' => 'form-control', 'id' => 'position', 'maxlength' => 50)));
     $this->add(array('name' => 'city_hidden_id', 'attributes' => array('type' => 'hidden', 'id' => 'city_hidden_id')));
     $this->add(array('name' => 'period_of_evaluation', 'options' => array('label' => '', 'value_options' => Evaluations::getEvaluationPeriodOptions()), 'type' => 'Zend\\Form\\Element\\Select', 'attributes' => array('id' => 'period_of_evaluation', 'class' => 'form-control')));
     $this->add(array('name' => 'user_hidden_id', 'attributes' => array('type' => 'hidden', 'id' => 'user_hidden_id')));
     $this->add(array('name' => 'disabled', 'attributes' => array('type' => 'hidden', 'id' => 'disabled')));
     $this->add(array('name' => 'employment', 'type' => 'Zend\\Form\\Element\\Select', 'options' => array('label' => 'Employment (%)', 'value_options' => $this->getSelectPercentValues(), 'required' => true), 'attributes' => array('class' => 'form-control', 'id' => 'employment')));
     $this->add(array('name' => 'sick_days', 'options' => array('label' => ''), 'attributes' => array('type' => 'int', 'class' => 'form-control', 'id' => 'sick_days', 'max' => 3, 'min' => -1, 'maxlength' => 2, 'class' => 'form-control')));
     if (is_object($data)) {
         $objectData = new \ArrayObject();
         $obj = $data->get('user_main');
         $objectData['firstname'] = $obj->getFirstName();
         $objectData['lastname'] = $obj->getLastName();
         $objectData['birthday'] = \Library\Utility\DateLocal::convertDateFromYMD($obj->getBirthDay());
         $objectData['email'] = $obj->geteMail();
         $objectData['internal_number'] = $obj->getInternalNumber();
         $objectData['alt_email'] = $obj->getAlt_email();
         $objectData['manager'] = $obj->getManager_id();
         $objectData['country'] = $obj->getCountry_id();
         $objectData['city'] = $obj->getCity_id();
         $objectData['living_city'] = $obj->getLivingCity();
         $objectData['city_hidden_id'] = $obj->getCity_id();
         $objectData['user_hidden_id'] = $obj->getId();
         $objectData['startdate'] = (int) $obj->getStart_date() ? date('d M Y', strtotime($obj->getStart_date())) : '';
         $objectData['end_date'] = (int) $obj->getEndDate() ? date('d M Y', strtotime($obj->getEndDate())) : '';
         $objectData['vacationdays'] = $obj->getVacation_days() ? $obj->getVacation_days() : '';
         $objectData['vacation_days_per_year'] = $obj->getVacation_days_per_year() ? $obj->getVacation_days_per_year() : '';
         $objectData['personalphone'] = $obj->getPersonal_phone() ? $obj->getPersonal_phone() : '';
         $objectData['businessphone'] = $obj->getBusiness_phone() ? $obj->getBusiness_phone() : '';
         $objectData['emergencyphone'] = $obj->getEmergency_phone() ? $obj->getEmergency_phone() : '';
         $objectData['housephone'] = $obj->getHouse_phone() ? $obj->getHouse_phone() : '';
         $objectData['address_permanent'] = $obj->getAddressPermanent();
         $objectData['address_residence'] = $obj->getAddressResidence();
         $objectData['timezone'] = $obj->getTimezone();
         $objectData['shift'] = $obj->getShift();
         $objectData['department'] = $data->get('userDepId');
         $objectData['position'] = $obj->getPosition();
         $objectData['period_of_evaluation'] = $obj->getPeriodOfEvaluation();
         $objectData['system'] = $obj->getSystem();
         $objectData['disabled'] = $obj->getDisabled();
         $objectData['reporting_office_id'] = $obj->getReportingOfficeId();
         $objectData['asana_id'] = $obj->getAsanaId();
         $objectData['employment'] = $obj->getEmployment();
         $objectData['sick_days'] = $obj->getSickDays();
         $objectData['external'] = $obj->isExternal();
         $objectData['last_login'] = $obj->getLastLogin() == '0000-00-00 00:00:00' ? 'Unknown' : date(Constants::GLOBAL_DATE_FORMAT . ' \\a\\t H:i', strtotime($obj->getLastLogin())) . " (Amsterdam time)";
         $dashboardsArray = array();
         $obj_user_dashboards = $data->get('user_dashboards');
         foreach ($obj_user_dashboards as $row) {
             $dashboardsArray[] = $row->getDashboardID();
         }
         $objectData['dashboards'] = $dashboardsArray;
         $objectData['conciergegroups'] = $user_concierge_array;
         $this->bind($objectData);
     }
 }