bootstrap = true; $this->table = 'configuration'; $this->className = 'Configuration'; $this->identifier = 'id_configuration'; parent::__construct(); } public function initContent() { $this->display = 'options'; $this->initToolbar(); $this->initPageHeaderToolbar(); parent::initContent(); } public function renderOptions() { $savedJson = Configuration::get(self::CONF_GUEST_REG_CARD_INFO); $selectedInfo = array(); if ($savedJson !== false && $savedJson !== '') { $decoded = Tools::jsonDecode($savedJson, true); if (is_array($decoded)) { $selectedInfo = $decoded; } } $allSelected = empty($selectedInfo); $nodes = array(); foreach ($this->getRegistrationCardInfo() as $sectionId => $section) { $sectionFields = isset($selectedInfo[$sectionId]) ? $selectedInfo[$sectionId] : array(); $fieldNodes = array(); foreach ($section['fields'] as $fieldId => $fieldName) { $fieldSelected = $allSelected || in_array($fieldId, $sectionFields); $fieldNodes[] = array( 'value' => $fieldId, 'name' => $fieldName, 'input_name' => 'grc_field_'.$sectionId, 'selected' => $fieldSelected, ); } $fieldsSelected = $allSelected || !empty(array_filter($fieldNodes, function ($n) { return $n['selected']; })); $nodes[] = array( 'value' => $sectionId, 'name' => $section['name'], 'input_name' => 'grc_section', 'selected' => $fieldsSelected, 'children' => $fieldNodes, ); } $tree = new HelperTree('grc-card-info-tree'); $tree->setData($nodes) ->setUseCheckBox(true) ->setAutoSelectChildren(true) ->setUseBulkActions(true); $this->context->smarty->assign(array( 'guest_reg_card_info_tree' => $tree->render(), 'guest_reg_card_form_action' => self::$currentIndex.'&token='.$this->token, 'guest_reg_card_preview_img_url' => $this->context->link->getBaseLink().'img/admin/guest_registration_preview.jpg', 'guest_reg_card_preview_title' => $this->l('Guest Registration Card Preview'), )); return $this->createTemplate('card_info_form.tpl')->fetch(); } public function initToolbarTitle() { $this->toolbar_title = array($this->l('Guest Registration Card')); } public function initPageHeaderToolbar() { parent::initPageHeaderToolbar(); unset($this->page_header_toolbar_btn['cancel']); } public function postProcess() { if (Tools::isSubmit('submitGrcCardInfo')) { $grcInfo = array(); foreach (array_keys($this->getRegistrationCardInfo()) as $sectionId) { $fields = array_values(array_filter(array_map('intval', (array)Tools::getValue('grc_field_'.$sectionId, array())))); if (!empty($fields)) { $grcInfo[$sectionId] = $fields; } } if (empty($grcInfo)) { $this->errors[] = $this->l('Please select at least one field for the Guest Registration Card.'); return; } Configuration::updateValue(self::CONF_GUEST_REG_CARD_INFO, Tools::jsonEncode($grcInfo)); Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token.'&conf=4'); return; } parent::postProcess(); } /** * Returns all Guest Registration Card sections and their fields. * Modules may add, remove, or reorder sections/fields via the hook. * * @return array sectionId => ['name' => string, 'fields' => [fieldId => string, ...]] */ public function getRegistrationCardInfo() { $guestRegCardInfo = array( self::GRC_SECTION_GUEST_INFO => array( 'name' => $this->l('Guest Information', null, false, false), 'fields' => array( self::GRC_GUEST_TITLE => $this->l('Title', null, false, false), self::GRC_GUEST_FULL_NAME => $this->l('Full Name', null, false, false), self::GRC_GUEST_PHONE => $this->l('Phone / Mobile', null, false, false), self::GRC_GUEST_EMAIL => $this->l('Email', null, false, false), self::GRC_GUEST_DOB => $this->l('Date of Birth', null, false, false), self::GRC_GUEST_NATIONALITY => $this->l('Nationality', null, false, false), self::GRC_GUEST_CITY_COUNTRY => $this->l('City / Country', null, false, false), self::GRC_GUEST_POSTAL_CODE => $this->l('Postal Code', null, false, false), self::GRC_GUEST_ADDRESS => $this->l('Address', null, false, false), ), ), self::GRC_SECTION_TRAVEL_INFO => array( 'name' => $this->l('Travel Information', null, false, false), 'fields' => array( self::GRC_TRAVEL_ARRIVED_FROM => $this->l('Arrived From', null, false, false), self::GRC_TRAVEL_NEXT_DESTINATION => $this->l('Next Destination', null, false, false), self::GRC_TRAVEL_FLIGHT_TRAIN => $this->l('Flight / Train Number', null, false, false), self::GRC_TRAVEL_VEHICLE_REG => $this->l('Vehicle Reg. No.', null, false, false), self::GRC_TRAVEL_PURPOSE_OF_VISIT => $this->l('Purpose of Visit', null, false, false), ), ), self::GRC_SECTION_BOOKING_INFO => array( 'name' => $this->l('Booking Information', null, false, false), 'fields' => array( self::GRC_BOOKING_REFERENCE => $this->l('Booking Reference No.', null, false, false), self::GRC_BOOKING_RATE_PER_NIGHT => $this->l('Rate per Night', null, false, false), self::GRC_BOOKING_ARRIVAL => $this->l('Arrival Date & Time', null, false, false), self::GRC_BOOKING_DEPARTURE => $this->l('Departure Date & Time', null, false, false), self::GRC_BOOKING_ROOM_TYPE => $this->l('Room Type', null, false, false), self::GRC_BOOKING_ROOM_NUMBER => $this->l('Room Number', null, false, false), self::GRC_BOOKING_NUM_GUESTS => $this->l('Number of Guests', null, false, false), ), ), self::GRC_SECTION_IDENTIFICATION => array( 'name' => $this->l('Identification Document', null, false, false), 'fields' => array( self::GRC_ID_IDENTITY_PROOF => $this->l('Identity Proof', null, false, false), self::GRC_ID_NUMBER => $this->l('ID Number', null, false, false), self::GRC_ID_PASSPORT_NO => $this->l('Passport No.', null, false, false), self::GRC_ID_PLACE_OF_ISSUE => $this->l('Place of Issue', null, false, false), self::GRC_ID_DATE_OF_ISSUE => $this->l('Date of Issue', null, false, false), self::GRC_ID_DATE_OF_EXPIRY => $this->l('Date of Expiry', null, false, false), self::GRC_ID_VISA_NUMBER => $this->l('Visa Number', null, false, false), self::GRC_ID_VALID_UNTIL => $this->l('Valid Until', null, false, false), self::GRC_ID_ARRIVAL_DATE_IN_COUNTRY => $this->l('Arrival Date in Country', null, false, false), ), ), self::GRC_SECTION_ADDITIONAL_GUESTS => array( 'name' => $this->l('Additional Guests', null, false, false), 'fields' => array( self::GRC_ADD_GUEST_NAME => $this->l('Guest Name', null, false, false), self::GRC_ADD_GUEST_ID_TYPE => $this->l('ID Type', null, false, false), self::GRC_ADD_GUEST_ID_NUMBER => $this->l('ID Number', null, false, false), self::GRC_ADD_GUEST_NATIONALITY => $this->l('Nationality', null, false, false), ), ), self::GRC_SECTION_BILLING_CORPORATE => array( 'name' => $this->l('Billing & Corporate Details', null, false, false), 'fields' => array( self::GRC_BILLING_COMPANY => $this->l('Company / Agent', null, false, false), self::GRC_BILLING_TAX_ID => $this->l('Tax ID / VAT No.', null, false, false), ), ), self::GRC_SECTION_PAYMENT_DEPOSIT => array( 'name' => $this->l('Payment & Deposit', null, false, false), 'fields' => array( self::GRC_PAYMENT_METHOD => $this->l('Payment Method', null, false, false), self::GRC_PAYMENT_CARD_NUMBER => $this->l('Credit Card Number', null, false, false), self::GRC_PAYMENT_SECURITY_DEPOSIT => $this->l('Security Deposit', null, false, false), ), ), self::GRC_SECTION_GUEST_SIGNATURE => array( 'name' => $this->l('Guest Signature', null, false, false), 'fields' => array( self::GRC_SIG_SIGNATURE => $this->l('Signature', null, false, false), self::GRC_SIG_DATE => $this->l('Date', null, false, false), ), ), self::GRC_SECTION_PROPERTY_REGS => array( 'name' => $this->l('Property Regulations', null, false, false), 'fields' => array( self::GRC_PROP_CHECKIN_CHECKOUT_TIME => $this->l('Check-in / Check-out Time', null, false, false), self::GRC_PROP_HOTEL_POLICIES => $this->l('Hotel Policies', null, false, false), ), ), self::GRC_SECTION_OFFICE_USE_ONLY => array( 'name' => $this->l('For Office Use Only', null, false, false), 'fields' => array( self::GRC_OFFICE_STAFF_NAME => $this->l('Staff Name', null, false, false), self::GRC_OFFICE_CHECKIN_TIME => $this->l('Check-in Time', null, false, false), self::GRC_OFFICE_ID_VERIFIED => $this->l('ID Verified', null, false, false), self::GRC_OFFICE_REG_NO => $this->l('Registration No.', null, false, false), ), ), ); Hook::exec('action'.$this->controller_name.'GuestRegCardInfoModifier', array( 'guest_registration_info' => &$guestRegCardInfo, )); return $guestRegCardInfo; } }