Fixed: Changed the preview image, change class names, and removed unnecessary function calls
Co-authored-by: Name <sumit201@webkul.in>
This commit is contained in:
@@ -25,6 +25,9 @@
|
||||
<h3><i class="icon-plane"></i> {l s='Purpose of visit'}</h3>
|
||||
{assign var=entity_name value='guest_reg_purpose'}
|
||||
{assign var=entity_rows value=$guest_reg_purpose_rows}
|
||||
{if isset($smarty.post.$entity_name) && is_array($smarty.post.$entity_name)}
|
||||
{assign var=entity_rows value=$smarty.post.$entity_name}
|
||||
{/if}
|
||||
<div class="table-responsive-row clearfix">
|
||||
<table class="table dynamic-reg-table" data-entity="{$entity_name}">
|
||||
<thead>
|
||||
@@ -36,16 +39,16 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{foreach from=$entity_rows item=row}
|
||||
{foreach from=$entity_rows key=rowKey item=row}
|
||||
<tr class="dynamic-row">
|
||||
<td style="display:none;">
|
||||
<input type="hidden" name="{$entity_name}[{$row.form_key|default:$row.id|escape:'html':'UTF-8'}][id]" value="{$row.id|intval}" />
|
||||
<input type="hidden" name="{$entity_name}[{$rowKey|escape:'html':'UTF-8'}][id]" value="{$row.id|intval}" />
|
||||
</td>
|
||||
<td class="dynamic-name-cell">
|
||||
{foreach from=$languages item=language}
|
||||
<div class="translatable-field row lang-{$language.id_lang}" {if $language.id_lang != $default_form_language}style="display:none;"{/if}>
|
||||
<div class="col-lg-{if $languages|count > 1}9{else}12{/if}">
|
||||
<input type="text" class="form-control" name="{$entity_name}[{$row.form_key|default:$row.id|escape:'html':'UTF-8'}][name][{$language.id_lang|intval}]" value="{$row.name[$language.id_lang]|default:''|escape:'html':'UTF-8'}" />
|
||||
<input type="text" class="form-control" name="{$entity_name}[{$rowKey|escape:'html':'UTF-8'}][name][{$language.id_lang|intval}]" value="{$row.name[$language.id_lang]|default:''|escape:'html':'UTF-8'}" />
|
||||
</div>
|
||||
{if $languages|count > 1}
|
||||
<div class="col-lg-2">
|
||||
@@ -63,7 +66,7 @@
|
||||
{/foreach}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<input type="hidden" class="dynamic-active-input" name="{$entity_name}[{$row.form_key|default:$row.id|escape:'html':'UTF-8'}][active]" value="{if $row.active}1{else}0{/if}" />
|
||||
<input type="hidden" class="dynamic-active-input" name="{$entity_name}[{$rowKey|escape:'html':'UTF-8'}][active]" value="{if $row.active}1{else}0{/if}" />
|
||||
<a href="#" class="dynamic-status-toggle list-action-enable {if $row.active}action-enabled{else}action-disabled{/if}" data-active="{if $row.active}1{else}0{/if}" title="{if $row.active}{l s='Enabled'}{else}{l s='Disabled'}{/if}">
|
||||
<i class="icon-check{if !$row.active} hidden{/if}"></i>
|
||||
<i class="icon-remove{if $row.active} hidden{/if}"></i>
|
||||
@@ -119,13 +122,16 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<button type="button" class="btn btn-default add-dynamic-row" data-entity="{$entity_name}"><i class="icon-plus"></i> {l s='Add More'}</button>
|
||||
<button type="button" class="btn btn-default add-dynamic-row" data-entity="{$entity_name}"><i class="icon-plus"></i> {l s='Add New field'}</button>
|
||||
</div>
|
||||
|
||||
<div class="panel">
|
||||
<h3><i class="icon-file-text"></i> {l s='Identity proof'}</h3>
|
||||
{assign var=entity_name value='guest_reg_id_proof'}
|
||||
{assign var=entity_rows value=$guest_reg_id_proof_rows}
|
||||
{if isset($smarty.post.$entity_name) && is_array($smarty.post.$entity_name)}
|
||||
{assign var=entity_rows value=$smarty.post.$entity_name}
|
||||
{/if}
|
||||
<div class="table-responsive-row clearfix">
|
||||
<table class="table dynamic-reg-table" data-entity="{$entity_name}">
|
||||
<thead>
|
||||
@@ -137,16 +143,16 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{foreach from=$entity_rows item=row}
|
||||
{foreach from=$entity_rows key=rowKey item=row}
|
||||
<tr class="dynamic-row">
|
||||
<td style="display:none;">
|
||||
<input type="hidden" name="{$entity_name}[{$row.form_key|default:$row.id|escape:'html':'UTF-8'}][id]" value="{$row.id|intval}" />
|
||||
<input type="hidden" name="{$entity_name}[{$rowKey|escape:'html':'UTF-8'}][id]" value="{$row.id|intval}" />
|
||||
</td>
|
||||
<td class="dynamic-name-cell">
|
||||
{foreach from=$languages item=language}
|
||||
<div class="translatable-field row lang-{$language.id_lang}" {if $language.id_lang != $default_form_language}style="display:none;"{/if}>
|
||||
<div class="col-lg-{if $languages|count > 1}9{else}12{/if}">
|
||||
<input type="text" class="form-control" name="{$entity_name}[{$row.form_key|default:$row.id|escape:'html':'UTF-8'}][name][{$language.id_lang|intval}]" value="{$row.name[$language.id_lang]|default:''|escape:'html':'UTF-8'}" />
|
||||
<input type="text" class="form-control" name="{$entity_name}[{$rowKey|escape:'html':'UTF-8'}][name][{$language.id_lang|intval}]" value="{$row.name[$language.id_lang]|default:''|escape:'html':'UTF-8'}" />
|
||||
</div>
|
||||
{if $languages|count > 1}
|
||||
<div class="col-lg-2">
|
||||
@@ -164,7 +170,7 @@
|
||||
{/foreach}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<input type="hidden" class="dynamic-active-input" name="{$entity_name}[{$row.form_key|default:$row.id|escape:'html':'UTF-8'}][active]" value="{if $row.active}1{else}0{/if}" />
|
||||
<input type="hidden" class="dynamic-active-input" name="{$entity_name}[{$rowKey|escape:'html':'UTF-8'}][active]" value="{if $row.active}1{else}0{/if}" />
|
||||
<a href="#" class="dynamic-status-toggle list-action-enable {if $row.active}action-enabled{else}action-disabled{/if}" data-active="{if $row.active}1{else}0{/if}" title="{if $row.active}{l s='Enabled'}{else}{l s='Disabled'}{/if}">
|
||||
<i class="icon-check{if !$row.active} hidden{/if}"></i>
|
||||
<i class="icon-remove{if $row.active} hidden{/if}"></i>
|
||||
@@ -220,13 +226,16 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<button type="button" class="btn btn-default add-dynamic-row" data-entity="{$entity_name}"><i class="icon-plus"></i> {l s='Add More'}</button>
|
||||
<button type="button" class="btn btn-default add-dynamic-row" data-entity="{$entity_name}"><i class="icon-plus"></i> {l s='Add New field'}</button>
|
||||
</div>
|
||||
|
||||
<div class="panel">
|
||||
<h3><i class="icon-credit-card"></i> {l s='Payment method'}</h3>
|
||||
{assign var=entity_name value='guest_reg_payment_method'}
|
||||
{assign var=entity_rows value=$guest_reg_payment_method_rows}
|
||||
{if isset($smarty.post.$entity_name) && is_array($smarty.post.$entity_name)}
|
||||
{assign var=entity_rows value=$smarty.post.$entity_name}
|
||||
{/if}
|
||||
<div class="table-responsive-row clearfix">
|
||||
<table class="table dynamic-reg-table" data-entity="{$entity_name}">
|
||||
<thead>
|
||||
@@ -238,16 +247,16 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{foreach from=$entity_rows item=row}
|
||||
{foreach from=$entity_rows key=rowKey item=row}
|
||||
<tr class="dynamic-row">
|
||||
<td style="display:none;">
|
||||
<input type="hidden" name="{$entity_name}[{$row.form_key|default:$row.id|escape:'html':'UTF-8'}][id]" value="{$row.id|intval}" />
|
||||
<input type="hidden" name="{$entity_name}[{$rowKey|escape:'html':'UTF-8'}][id]" value="{$row.id|intval}" />
|
||||
</td>
|
||||
<td class="dynamic-name-cell">
|
||||
{foreach from=$languages item=language}
|
||||
<div class="translatable-field row lang-{$language.id_lang}" {if $language.id_lang != $default_form_language}style="display:none;"{/if}>
|
||||
<div class="col-lg-{if $languages|count > 1}9{else}12{/if}">
|
||||
<input type="text" class="form-control" name="{$entity_name}[{$row.form_key|default:$row.id|escape:'html':'UTF-8'}][name][{$language.id_lang|intval}]" value="{$row.name[$language.id_lang]|default:''|escape:'html':'UTF-8'}" />
|
||||
<input type="text" class="form-control" name="{$entity_name}[{$rowKey|escape:'html':'UTF-8'}][name][{$language.id_lang|intval}]" value="{$row.name[$language.id_lang]|default:''|escape:'html':'UTF-8'}" />
|
||||
</div>
|
||||
{if $languages|count > 1}
|
||||
<div class="col-lg-2">
|
||||
@@ -265,7 +274,7 @@
|
||||
{/foreach}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<input type="hidden" class="dynamic-active-input" name="{$entity_name}[{$row.form_key|default:$row.id|escape:'html':'UTF-8'}][active]" value="{if $row.active}1{else}0{/if}" />
|
||||
<input type="hidden" class="dynamic-active-input" name="{$entity_name}[{$rowKey|escape:'html':'UTF-8'}][active]" value="{if $row.active}1{else}0{/if}" />
|
||||
<a href="#" class="dynamic-status-toggle list-action-enable {if $row.active}action-enabled{else}action-disabled{/if}" data-active="{if $row.active}1{else}0{/if}" title="{if $row.active}{l s='Enabled'}{else}{l s='Disabled'}{/if}">
|
||||
<i class="icon-check{if !$row.active} hidden{/if}"></i>
|
||||
<i class="icon-remove{if $row.active} hidden{/if}"></i>
|
||||
@@ -321,7 +330,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<button type="button" class="btn btn-default add-dynamic-row" data-entity="{$entity_name}"><i class="icon-plus"></i> {l s='Add More'}</button>
|
||||
<button type="button" class="btn btn-default add-dynamic-row" data-entity="{$entity_name}"><i class="icon-plus"></i> {l s='Add New field'}</button>
|
||||
</div>
|
||||
|
||||
<div class="panel-footer">
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
* @license https://opensource.org/license/osl-3.0-php Open Software License version 3.0
|
||||
*/
|
||||
|
||||
class GuestRegistrationIdProofCore extends ObjectModel
|
||||
class IdProofCore extends ObjectModel
|
||||
{
|
||||
public $active = 1;
|
||||
public $name;
|
||||
@@ -56,11 +56,6 @@ class HTMLTemplateRegistrationFormCore extends HTMLTemplate
|
||||
return '';
|
||||
}
|
||||
|
||||
public function requestMinimalMargins()
|
||||
{
|
||||
return !(bool)Configuration::get('QLO_GUEST_REG_ENABLE_HEADER');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the template's HTML content
|
||||
*
|
||||
@@ -69,58 +64,23 @@ class HTMLTemplateRegistrationFormCore extends HTMLTemplate
|
||||
public function getContent()
|
||||
{
|
||||
$idLang = (int)$this->order->id_lang;
|
||||
$idHotel = (int)HotelBookingDetail::getIdHotelByIdOrder($this->order->id);
|
||||
$hotelBookingDetail = new HotelBookingDetail((int)$this->id_hotel_booking_detail);
|
||||
$idHotel = Validate::isLoadedObject($hotelBookingDetail) ? (int)$hotelBookingDetail->id_hotel : 0;
|
||||
|
||||
$objHotelBookingDetail = new HotelBookingDetail();
|
||||
$hotelBookingDetails = $objHotelBookingDetail->getBookingDataByOrderId($this->order->id);
|
||||
if ($this->id_hotel_booking_detail) {
|
||||
$hotelBookingDetails = array_filter($hotelBookingDetails, function ($detail) {
|
||||
return $detail['id'] == $this->id_hotel_booking_detail;
|
||||
});
|
||||
}
|
||||
|
||||
// Hotel info from HotelBranchInformation (authoritative)
|
||||
$hotelName = '';
|
||||
$hotelCheckInTime = '';
|
||||
$hotelCheckOutTime = '';
|
||||
$hotelPolicies = '';
|
||||
$hotelCity = '';
|
||||
$objHotelBranchInformation = null;
|
||||
$hotelCountry = '';
|
||||
|
||||
if ($idHotel) {
|
||||
$objHotelBranchInformation = new HotelBranchInformation($idHotel, $idLang);
|
||||
if (Validate::isLoadedObject($objHotelBranchInformation)) {
|
||||
$hotelName = $objHotelBranchInformation->hotel_name;
|
||||
$hotelCity = (string)$objHotelBranchInformation->city;
|
||||
$policies = $objHotelBranchInformation->policies;
|
||||
$hotelPolicies = is_array($policies) ? '' : (string)$policies;
|
||||
|
||||
$checkIn = $objHotelBranchInformation->check_in;
|
||||
$hotelCheckInTime = ($checkIn && $checkIn != '00:00:00') ? date('h:i a', strtotime($checkIn)) : '';
|
||||
|
||||
$checkOut = $objHotelBranchInformation->check_out;
|
||||
$hotelCheckOutTime = ($checkOut && $checkOut != '00:00:00') ? date('h:i a', strtotime($checkOut)) : '';
|
||||
|
||||
if ($objHotelBranchInformation->id_country) {
|
||||
$objCountry = new Country((int)$objHotelBranchInformation->id_country, $idLang);
|
||||
if (Validate::isLoadedObject($objCountry)) {
|
||||
$hotelCountry = (string)$objCountry->name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback to booking detail row for name/city/country if branch info unavailable
|
||||
if ((!$hotelName || !$hotelCity || !$hotelCountry) && !empty($hotelBookingDetails)) {
|
||||
$firstDetail = reset($hotelBookingDetails);
|
||||
if (!$hotelName) {
|
||||
$hotelName = $firstDetail['hotel_name'];
|
||||
}
|
||||
if (!$hotelCity) {
|
||||
$hotelCity = $firstDetail['city'];
|
||||
}
|
||||
if (!$hotelCountry) {
|
||||
$hotelCountry = $firstDetail['country'];
|
||||
} else {
|
||||
$objHotelBranchInformation = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,68 +96,33 @@ class HTMLTemplateRegistrationFormCore extends HTMLTemplate
|
||||
$propertyLogoPath = (string)$this->getLogo();
|
||||
}
|
||||
|
||||
// Stay data: dates, rooms, guests, rate
|
||||
$arrivalDate = '';
|
||||
$departureDate = '';
|
||||
$roomNumbers = array();
|
||||
$roomTypes = array();
|
||||
$adults = 0;
|
||||
$children = 0;
|
||||
$ratePerNight = '';
|
||||
$arrivalDateTime = '';
|
||||
$departureDateTime = '';
|
||||
|
||||
if (!empty($hotelBookingDetails)) {
|
||||
$currency = new Currency((int)$this->order->id_currency);
|
||||
$totalRate = 0;
|
||||
$totalRateCount = 0;
|
||||
foreach ($hotelBookingDetails as $detail) {
|
||||
if (!$arrivalDate || strtotime($detail['date_from']) < strtotime($arrivalDate)) {
|
||||
$arrivalDate = $detail['date_from'];
|
||||
}
|
||||
if (!$departureDate || strtotime($detail['date_to']) > strtotime($departureDate)) {
|
||||
$departureDate = $detail['date_to'];
|
||||
}
|
||||
if (!empty($detail['room_num'])) {
|
||||
$roomNumbers[] = $detail['room_num'];
|
||||
}
|
||||
if (!empty($detail['room_type_name'])) {
|
||||
$roomTypes[] = $detail['room_type_name'];
|
||||
}
|
||||
$adults += (int)$detail['adults'];
|
||||
$children += (int)$detail['children'];
|
||||
$nights = (int)HotelHelper::getNumberOfDays($detail['date_from'], $detail['date_to']);
|
||||
if ($nights > 0) {
|
||||
$totalRate += ((float)$detail['total_price_tax_incl'] / $nights);
|
||||
++$totalRateCount;
|
||||
}
|
||||
if (Validate::isLoadedObject($hotelBookingDetail)) {
|
||||
$nights = (int)HotelHelper::getNumberOfDays($hotelBookingDetail->date_from, $hotelBookingDetail->date_to);
|
||||
if ($nights > 0) {
|
||||
$currency = new Currency((int)$this->order->id_currency);
|
||||
$ratePerNight = Tools::displayPrice((float)$hotelBookingDetail->total_price_tax_incl / $nights, $currency, false);
|
||||
}
|
||||
|
||||
if ($totalRateCount) {
|
||||
$ratePerNight = Tools::displayPrice($totalRate / $totalRateCount, $currency, false);
|
||||
$arrivalDateTime = $hotelBookingDetail->date_from ? Tools::displayDate($hotelBookingDetail->date_from) : '';
|
||||
$departureDateTime = $hotelBookingDetail->date_to ? Tools::displayDate($hotelBookingDetail->date_to) : '';
|
||||
if ($arrivalDateTime && $objHotelBranchInformation && $objHotelBranchInformation->check_in && $objHotelBranchInformation->check_in != '00:00:00') {
|
||||
$arrivalDateTime .= ' '.date('h:i a', strtotime($objHotelBranchInformation->check_in));
|
||||
}
|
||||
|
||||
$arrivalDateTime = $arrivalDate ? Tools::displayDate($arrivalDate) : '';
|
||||
$departureDateTime = $departureDate ? Tools::displayDate($departureDate) : '';
|
||||
if ($arrivalDateTime && $hotelCheckInTime) {
|
||||
$arrivalDateTime .= ' '.$hotelCheckInTime;
|
||||
}
|
||||
if ($departureDateTime && $hotelCheckOutTime) {
|
||||
$departureDateTime .= ' '.$hotelCheckOutTime;
|
||||
if ($departureDateTime && $objHotelBranchInformation && $objHotelBranchInformation->check_out && $objHotelBranchInformation->check_out != '00:00:00') {
|
||||
$departureDateTime .= ' '.date('h:i a', strtotime($objHotelBranchInformation->check_out));
|
||||
}
|
||||
}
|
||||
|
||||
// Additional guests rows based on max_guests of the room type
|
||||
$additionalGuestsRows = 0;
|
||||
if (!empty($hotelBookingDetails)) {
|
||||
$idProducts = array_unique(array_filter(array_map('intval', array_column($hotelBookingDetails, 'id_product'))));
|
||||
if (!empty($idProducts)) {
|
||||
$objHotelRoomType = new HotelRoomType();
|
||||
$roomTypeDetails = $objHotelRoomType->getRoomTypeDetailByRoomTypeIds(implode(',', $idProducts), false);
|
||||
if (!empty($roomTypeDetails) && isset($roomTypeDetails[0]['max_guests'])) {
|
||||
$maxGuests = (int)$roomTypeDetails[0]['max_guests'];
|
||||
$additionalGuestsRows = ($maxGuests > 1) ? ($maxGuests - 1) : 0;
|
||||
}
|
||||
if (Validate::isLoadedObject($hotelBookingDetail) && $hotelBookingDetail->id_product) {
|
||||
$roomTypeDetails = (new HotelRoomType())->getRoomTypeDetailByRoomTypeIds((string)(int)$hotelBookingDetail->id_product, false);
|
||||
if (!empty($roomTypeDetails) && isset($roomTypeDetails[0]['max_guests'])) {
|
||||
$maxGuests = (int)$roomTypeDetails[0]['max_guests'];
|
||||
$additionalGuestsRows = ($maxGuests > 1) ? ($maxGuests - 1) : 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,30 +137,21 @@ class HTMLTemplateRegistrationFormCore extends HTMLTemplate
|
||||
|
||||
$this->smarty->assign(array(
|
||||
'style_tab' => $this->smarty->fetch($this->getTemplate('invoice.style-tab')),
|
||||
// Hotel / property header
|
||||
'hotel_name' => $hotelName,
|
||||
'hotel' => $objHotelBranchInformation,
|
||||
'property_logo_path' => $propertyLogoPath,
|
||||
'property_city_country' => implode(', ', array_filter(array($hotelCity, $hotelCountry))),
|
||||
// Booking stay info
|
||||
'property_city_country' => implode(', ', array_filter(array($objHotelBranchInformation ? (string)$objHotelBranchInformation->city : '', $hotelCountry))),
|
||||
'booking_reference' => $this->order->getUniqReference(),
|
||||
'arrival_date_time' => $arrivalDateTime,
|
||||
'departure_date_time' => $departureDateTime,
|
||||
'room_type' => implode(', ', array_unique($roomTypes)),
|
||||
'room_number' => implode(', ', array_unique($roomNumbers)),
|
||||
'adults' => $adults,
|
||||
'children' => $children,
|
||||
'room_type' => Validate::isLoadedObject($hotelBookingDetail) ? $hotelBookingDetail->room_type_name : '',
|
||||
'room_number' => Validate::isLoadedObject($hotelBookingDetail) ? $hotelBookingDetail->room_num : '',
|
||||
'adults' => Validate::isLoadedObject($hotelBookingDetail) ? (int)$hotelBookingDetail->adults : 0,
|
||||
'children' => Validate::isLoadedObject($hotelBookingDetail) ? (int)$hotelBookingDetail->children : 0,
|
||||
'rate_per_night' => $ratePerNight,
|
||||
// Property regulations section
|
||||
'hotel_check_in_time' => $hotelCheckInTime,
|
||||
'hotel_check_out_time' => $hotelCheckOutTime,
|
||||
'hotel_policies' => $hotelPolicies,
|
||||
// Additional guests table
|
||||
'additional_guests_rows' => $additionalGuestsRows,
|
||||
// Dynamic field options
|
||||
'purpose_of_visit_options' => GuestVisitPurpose::getGuestVisitPurposes(1, $idLang),
|
||||
'identity_proof_options' => GuestRegistrationIdProof::getRegistrationIdProofs(1, $idLang),
|
||||
'identity_proof_options' => IdProof::getRegistrationIdProofs(1, $idLang),
|
||||
'payment_method_options' => GuestRegistrationPaymentMethod::getRegistrationPaymentMethods(1, $idLang),
|
||||
// Optional section visibility flags
|
||||
'show_property_logo' => in_array(1, $selectedSections),
|
||||
'show_additional_guests' => in_array(2, $selectedSections),
|
||||
'show_billing_corporate_details' => in_array(3, $selectedSections),
|
||||
|
||||
@@ -89,9 +89,6 @@ class PDFCore
|
||||
$this->filename = $template->getBulkFilename();
|
||||
}
|
||||
}
|
||||
if (method_exists($template, 'requestMinimalMargins') && $template->requestMinimalMargins()) {
|
||||
$this->pdf_renderer->setMinimalMargins(true);
|
||||
}
|
||||
|
||||
$template->assignHookData($object);
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@ class PDFGeneratorCore extends TCPDF
|
||||
public $pagination;
|
||||
public $content;
|
||||
public $font;
|
||||
protected $force_minimal_margins = false;
|
||||
|
||||
public $font_by_lang = array(
|
||||
'ja' => 'cid0jp',
|
||||
@@ -208,10 +207,6 @@ class PDFGeneratorCore extends TCPDF
|
||||
return $this->output($filename, $output);
|
||||
}
|
||||
|
||||
public function setMinimalMargins($minimal = true)
|
||||
{
|
||||
$this->force_minimal_margins = $minimal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a PDF page
|
||||
@@ -220,12 +215,8 @@ class PDFGeneratorCore extends TCPDF
|
||||
{
|
||||
$this->SetHeaderMargin(5);
|
||||
$this->SetFooterMargin(21);
|
||||
if ($this->force_minimal_margins) {
|
||||
$this->SetAutoPageBreak(true, 25);
|
||||
$this->setPrintHeader(false);
|
||||
$this->setMargins(10, 10, 10); // Reclaim the 40mm space
|
||||
} else {
|
||||
$this->setPrintHeader(true);
|
||||
$this->setMargins(10, 10, 10);
|
||||
if(isset($this->header) && !empty($this->header)) {
|
||||
$this->setMargins(10, 40, 10);
|
||||
}
|
||||
$this->AddPage();
|
||||
|
||||
@@ -71,7 +71,7 @@ class AdminGuestRegistrationControllerCore extends AdminController
|
||||
$this->initPageHeaderToolbar();
|
||||
|
||||
$this->content = $this->renderOptions();
|
||||
$this->content .= $this->renderRegForm();
|
||||
$this->content .= $this->renderRegistrationForm();
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'content' => $this->content,
|
||||
@@ -97,113 +97,75 @@ class AdminGuestRegistrationControllerCore extends AdminController
|
||||
{
|
||||
if (Tools::isSubmit('submitBulkGuestRegistrationValues')) {
|
||||
$languages = Language::getLanguages(false);
|
||||
$regFields = $this->getRegFieldTypes();
|
||||
$idLangDefault = (int)Configuration::get('PS_LANG_DEFAULT');
|
||||
$validatedRows = array();
|
||||
|
||||
// Validate all field types first, collect errors before saving anything
|
||||
foreach ($regFields as $fieldKey => $fieldConfig) {
|
||||
$postedRows = Tools::getValue($fieldConfig['table'], array());
|
||||
if (!is_array($postedRows)) {
|
||||
$postedRows = array();
|
||||
}
|
||||
$guestRegPurposeData = $this->validateRegistrationFieldRows(
|
||||
(array)Tools::getValue('guest_reg_purpose', array()),
|
||||
$languages,
|
||||
$idLangDefault,
|
||||
$this->l('Purpose of visit')
|
||||
);
|
||||
$idProofData = $this->validateRegistrationFieldRows(
|
||||
(array)Tools::getValue('guest_reg_id_proof', array()),
|
||||
$languages,
|
||||
$idLangDefault,
|
||||
$this->l('Identity proof')
|
||||
);
|
||||
$guestRegPaymentMethodData = $this->validateRegistrationFieldRows(
|
||||
(array)Tools::getValue('guest_reg_payment_method', array()),
|
||||
$languages,
|
||||
$idLangDefault,
|
||||
$this->l('Payment method')
|
||||
);
|
||||
|
||||
$rows = array();
|
||||
foreach ($postedRows as $rowKey => $row) {
|
||||
if (!is_array($row)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip blank new rows (no ID and no name in any language)
|
||||
if (empty($row['id'])) {
|
||||
$hasName = false;
|
||||
if (isset($row['name']) && is_array($row['name'])) {
|
||||
foreach ($languages as $language) {
|
||||
if (!empty($row['name'][(int)$language['id_lang']])) {
|
||||
$hasName = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$hasName) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$validRow = array(
|
||||
'id' => !empty($row['id']) ? (int)$row['id'] : 0,
|
||||
'active' => !empty($row['active']) ? 1 : 0,
|
||||
'name' => array(),
|
||||
);
|
||||
|
||||
$defaultName = isset($row['name'][$idLangDefault]) ? trim($row['name'][$idLangDefault]) : '';
|
||||
|
||||
foreach ($languages as $language) {
|
||||
$idLang = (int)$language['id_lang'];
|
||||
$name = isset($row['name'][$idLang]) ? trim($row['name'][$idLang]) : '';
|
||||
|
||||
if ($name === '' && $defaultName !== '') {
|
||||
$name = $defaultName;
|
||||
}
|
||||
|
||||
if ($name === '') {
|
||||
$this->errors[] = sprintf(
|
||||
$this->l('%s: name is required for %s (or for the default language).'),
|
||||
$fieldConfig['title'],
|
||||
$language['name']
|
||||
);
|
||||
} elseif (!Validate::isCatalogName($name)) {
|
||||
$this->errors[] = sprintf(
|
||||
$this->l('%s: name is invalid for %s.'),
|
||||
$fieldConfig['title'],
|
||||
$language['name']
|
||||
);
|
||||
}
|
||||
|
||||
$validRow['name'][$idLang] = $name;
|
||||
}
|
||||
|
||||
$rows[$rowKey] = $validRow;
|
||||
}
|
||||
|
||||
$validatedRows[$fieldKey] = $rows;
|
||||
}
|
||||
|
||||
// Save only when validation passes for all types
|
||||
if (!count($this->errors)) {
|
||||
foreach ($regFields as $fieldKey => $fieldConfig) {
|
||||
$className = $fieldConfig['class'];
|
||||
$idMethod = $fieldConfig['ids_fn'];
|
||||
$existingIds = $className::$idMethod();
|
||||
$savedIds = array();
|
||||
$saveFailed = false;
|
||||
|
||||
foreach ($validatedRows[$fieldKey] as $row) {
|
||||
$object = $row['id'] ? new $className((int)$row['id']) : new $className();
|
||||
$object->active = (int)$row['active'];
|
||||
$object->name = $row['name'];
|
||||
|
||||
if (!$object->save()) {
|
||||
$this->errors[] = sprintf(
|
||||
$this->l('An error occurred while saving %s.'),
|
||||
Tools::strtolower($fieldConfig['title'])
|
||||
);
|
||||
$saveFailed = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
$savedIds[] = (int)$object->id;
|
||||
$savedPurposeIds = array();
|
||||
foreach ($guestRegPurposeData as $row) {
|
||||
$objGuestVisitPurpose = $row['id'] ? new GuestVisitPurpose((int)$row['id']) : new GuestVisitPurpose();
|
||||
$objGuestVisitPurpose->active = $row['active'];
|
||||
$objGuestVisitPurpose->name = $row['name'];
|
||||
if ($objGuestVisitPurpose->save()) {
|
||||
$savedPurposeIds[] = (int)$objGuestVisitPurpose->id;
|
||||
} else {
|
||||
$this->errors[] = $this->l('An error occurred while saving purpose of visit.');
|
||||
}
|
||||
}
|
||||
foreach (array_diff(GuestVisitPurpose::getGuestVisitPurposeIds(), $savedPurposeIds) as $id) {
|
||||
$objGuestVisitPurpose = new GuestVisitPurpose((int)$id);
|
||||
$objGuestVisitPurpose->delete();
|
||||
}
|
||||
|
||||
if (!$saveFailed) {
|
||||
foreach (array_diff($existingIds, $savedIds) as $idToDelete) {
|
||||
$object = new $className((int)$idToDelete);
|
||||
if (Validate::isLoadedObject($object)) {
|
||||
$object->delete();
|
||||
}
|
||||
}
|
||||
$savedIdProofIds = array();
|
||||
foreach ($idProofData as $row) {
|
||||
$objIdProof = $row['id'] ? new IdProof((int)$row['id']) : new IdProof();
|
||||
$objIdProof->active = $row['active'];
|
||||
$objIdProof->name = $row['name'];
|
||||
if ($objIdProof->save()) {
|
||||
$savedIdProofIds[] = (int)$objIdProof->id;
|
||||
} else {
|
||||
$this->errors[] = $this->l('An error occurred while saving identity proof.');
|
||||
}
|
||||
}
|
||||
foreach (array_diff(IdProof::getRegistrationIdProofIds(), $savedIdProofIds) as $id) {
|
||||
$objIdProof = new IdProof((int)$id);
|
||||
$objIdProof->delete();
|
||||
}
|
||||
|
||||
$savedPaymentMethodIds = array();
|
||||
foreach ($guestRegPaymentMethodData as $row) {
|
||||
$objGuestRegistrationPaymentMethod = $row['id'] ? new GuestRegistrationPaymentMethod((int)$row['id']) : new GuestRegistrationPaymentMethod();
|
||||
$objGuestRegistrationPaymentMethod->active = $row['active'];
|
||||
$objGuestRegistrationPaymentMethod->name = $row['name'];
|
||||
if ($objGuestRegistrationPaymentMethod->save()) {
|
||||
$savedPaymentMethodIds[] = (int)$objGuestRegistrationPaymentMethod->id;
|
||||
} else {
|
||||
$this->errors[] = $this->l('An error occurred while saving payment method.');
|
||||
}
|
||||
}
|
||||
foreach (array_diff(GuestRegistrationPaymentMethod::getRegistrationPaymentMethodIds(), $savedPaymentMethodIds) as $id) {
|
||||
$objGuestRegistrationPaymentMethod = new GuestRegistrationPaymentMethod((int)$id);
|
||||
$objGuestRegistrationPaymentMethod->delete();
|
||||
}
|
||||
}
|
||||
|
||||
if (!count($this->errors)) {
|
||||
@@ -243,11 +205,6 @@ class AdminGuestRegistrationControllerCore extends AdminController
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called automatically by AdminController::processUpdateOptions() via
|
||||
* 'updateOption' + Tools::toCamelCase('QLO_GUEST_REG_OPTIONAL_SECTIONS').
|
||||
* Validates and stores the selected optional section IDs.
|
||||
*/
|
||||
protected function updateOptionQloGuestRegOptionalSections($value)
|
||||
{
|
||||
if (!is_array($value)) {
|
||||
@@ -267,106 +224,98 @@ class AdminGuestRegistrationControllerCore extends AdminController
|
||||
Configuration::updateValue(self::CONF_OPTIONAL_SECTIONS, Tools::jsonEncode(array_values(array_unique($selected))));
|
||||
}
|
||||
|
||||
protected function renderRegForm()
|
||||
protected function renderRegistrationForm(): string
|
||||
{
|
||||
$languages = Language::getLanguages(false);
|
||||
$regFields = $this->getRegFieldTypes();
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'languages' => $languages,
|
||||
'default_form_language' => (int)Configuration::get('PS_LANG_DEFAULT'),
|
||||
'dynamic_form_action' => self::$currentIndex.'&token='.$this->token,
|
||||
'guest_reg_purpose_rows' => $this->getRegFieldRows($regFields['purpose'], $languages),
|
||||
'guest_reg_id_proof_rows' => $this->getRegFieldRows($regFields['id_proof'], $languages),
|
||||
'guest_reg_payment_method_rows' => $this->getRegFieldRows($regFields['payment_method'], $languages),
|
||||
'guest_reg_purpose_rows' => GuestVisitPurpose::getGuestVisitPurposeRows(),
|
||||
'guest_reg_id_proof_rows' => IdProof::getRegistrationIdProofRows(),
|
||||
'guest_reg_payment_method_rows' => GuestRegistrationPaymentMethod::getRegistrationPaymentMethodRows(),
|
||||
));
|
||||
|
||||
return $this->createTemplate('dynamic_tables.tpl')->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns display rows for one guest registration field type.
|
||||
* On validation error repopulates from posted data; otherwise fetches from the database.
|
||||
* Called 3× from renderRegForm(), one per field type.
|
||||
* Validates posted rows for one guest registration field type.
|
||||
* Populates $this->errors on failure. Returns array of validated rows.
|
||||
*
|
||||
* @param array $postedRows
|
||||
* @param array $languages
|
||||
* @param int $idLangDefault
|
||||
* @param string $title
|
||||
* @return array
|
||||
*/
|
||||
protected function getRegFieldRows(array $fieldConfig, array $languages): array
|
||||
protected function validateRegistrationFieldRows(array $postedRows, array $languages, int $idLangDefault, string $title): array
|
||||
{
|
||||
if (Tools::isSubmit('submitBulkGuestRegistrationValues') && count($this->errors)) {
|
||||
$postedRows = Tools::getValue($fieldConfig['table'], array());
|
||||
$rows = array();
|
||||
$rows = array();
|
||||
|
||||
if (!is_array($postedRows)) {
|
||||
return $rows;
|
||||
foreach ($postedRows as $row) {
|
||||
if (!is_array($row)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($postedRows as $rowKey => $row) {
|
||||
if (!is_array($row)) {
|
||||
// Skip blank new rows (no ID and no name in any language)
|
||||
if (empty($row['id'])) {
|
||||
$hasName = false;
|
||||
if (isset($row['name']) && is_array($row['name'])) {
|
||||
foreach ($languages as $language) {
|
||||
if (!empty($row['name'][(int)$language['id_lang']])) {
|
||||
$hasName = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$hasName) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$rowKey = (string)$rowKey;
|
||||
$formKey = preg_match('/^[a-zA-Z0-9_-]+$/', $rowKey) ? $rowKey : 'new_'.time();
|
||||
|
||||
$displayRow = array(
|
||||
'id' => !empty($row['id']) ? (int)$row['id'] : 0,
|
||||
'form_key' => $formKey,
|
||||
'active' => !empty($row['active']) ? 1 : 0,
|
||||
'date_add' => '',
|
||||
'name' => array(),
|
||||
);
|
||||
|
||||
foreach ($languages as $language) {
|
||||
$idLang = (int)$language['id_lang'];
|
||||
$displayRow['name'][$idLang] = isset($row['name'][$idLang]) ? (string)$row['name'][$idLang] : '';
|
||||
}
|
||||
|
||||
$rows[] = $displayRow;
|
||||
}
|
||||
|
||||
return $rows;
|
||||
$validRow = array(
|
||||
'id' => !empty($row['id']) ? (int)$row['id'] : 0,
|
||||
'active' => !empty($row['active']) ? 1 : 0,
|
||||
'name' => array(),
|
||||
);
|
||||
|
||||
$defaultName = isset($row['name'][$idLangDefault]) ? trim($row['name'][$idLangDefault]) : '';
|
||||
|
||||
foreach ($languages as $language) {
|
||||
$idLang = (int)$language['id_lang'];
|
||||
$name = isset($row['name'][$idLang]) ? trim($row['name'][$idLang]) : '';
|
||||
|
||||
if ($name === '' && $defaultName !== '') {
|
||||
$name = $defaultName;
|
||||
}
|
||||
|
||||
if ($name === '') {
|
||||
$this->errors[] = sprintf(
|
||||
$this->l('%s: name is required for %s (or for the default language).'),
|
||||
$title,
|
||||
$language['name']
|
||||
);
|
||||
} elseif (!Validate::isCatalogName($name)) {
|
||||
$this->errors[] = sprintf(
|
||||
$this->l('%s: name is invalid for %s.'),
|
||||
$title,
|
||||
$language['name']
|
||||
);
|
||||
}
|
||||
|
||||
$validRow['name'][$idLang] = $name;
|
||||
}
|
||||
|
||||
$rows[] = $validRow;
|
||||
}
|
||||
|
||||
$className = $fieldConfig['class'];
|
||||
$rowsMethod = $fieldConfig['rows_fn'];
|
||||
|
||||
return $className::$rowsMethod();
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array Config for each guest registration field type managed on this page
|
||||
*/
|
||||
protected function getRegFieldTypes(): array
|
||||
{
|
||||
return array(
|
||||
'purpose' => array(
|
||||
'class' => 'GuestVisitPurpose',
|
||||
'table' => 'guest_reg_purpose',
|
||||
'identifier' => 'id_guest_reg_purpose',
|
||||
'title' => $this->l('Purpose of visit'),
|
||||
'rows_fn' => 'getGuestVisitPurposeRows',
|
||||
'ids_fn' => 'getGuestVisitPurposeIds',
|
||||
),
|
||||
'id_proof' => array(
|
||||
'class' => 'GuestRegistrationIdProof',
|
||||
'table' => 'guest_reg_id_proof',
|
||||
'identifier' => 'id_guest_reg_id_proof',
|
||||
'title' => $this->l('Identity proof'),
|
||||
'rows_fn' => 'getRegistrationIdProofRows',
|
||||
'ids_fn' => 'getRegistrationIdProofIds',
|
||||
),
|
||||
'payment_method' => array(
|
||||
'class' => 'GuestRegistrationPaymentMethod',
|
||||
'table' => 'guest_reg_payment_method',
|
||||
'identifier' => 'id_guest_reg_payment_method',
|
||||
'title' => $this->l('Payment method'),
|
||||
'rows_fn' => 'getRegistrationPaymentMethodRows',
|
||||
'ids_fn' => 'getRegistrationPaymentMethodIds',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array Section ID → label for the optional-sections checkbox group
|
||||
* @return array Section ID => label for the optional-sections checkbox group
|
||||
*/
|
||||
protected function getOptionalSectionChoices(): array
|
||||
{
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 535 KiB After Width: | Height: | Size: 508 KiB |
@@ -41,7 +41,7 @@
|
||||
{/if}
|
||||
<tr>
|
||||
<td width="100%" class="center" style="font-size: 12pt; font-weight: bold;">
|
||||
{$hotel_name|escape:'html':'UTF-8'}
|
||||
{if $hotel}{$hotel->hotel_name|escape:'html':'UTF-8'}{/if}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -134,7 +134,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="25%" class="bold">{l s='Purpose of Visit:' pdf='true'}</td>
|
||||
<td width="75%" colspan="3" class="white">{if $purpose_of_visit_options|@count}{foreach from=$purpose_of_visit_options item=item name=purposeOfVisit}{if !$smarty.foreach.purposeOfVisit.first} {/if}<span style="font-family: freeserif; white-space: nowrap;">□ {$item.name|escape:'html':'UTF-8'|replace:' ':' '}</span>{/foreach}{else}________________________{/if}</td>
|
||||
<td width="75%" colspan="3" class="white">{if $purpose_of_visit_options|@count}{foreach from=$purpose_of_visit_options item=item name=purposeOfVisit}{if !$smarty.foreach.purposeOfVisit.first} {/if}<span style="font-family: freeserif; white-space: nowrap;">□ {$item.name|escape:'html':'UTF-8'|replace:' ':' '}</span>{/foreach}{else}________________________{/if}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
@@ -227,7 +227,7 @@
|
||||
<tr>
|
||||
<td width="25%" class="bold">{l s='Identity Proof:' pdf='true'}</td>
|
||||
{if $identity_proof_options|@count}
|
||||
<td width="75%" class="white">{foreach from=$identity_proof_options item=item name=identityProof}{if !$smarty.foreach.identityProof.first} {/if}<span style="font-family: freeserif; white-space: nowrap;">□ {$item.name|escape:'html':'UTF-8'|replace:' ':' '}</span>{/foreach}</td>
|
||||
<td width="75%" class="white">{foreach from=$identity_proof_options item=item name=identityProof}{if !$smarty.foreach.identityProof.first} {/if}<span style="font-family: freeserif; white-space: nowrap;">□ {$item.name|escape:'html':'UTF-8'|replace:' ':' '}</span>{/foreach}</td>
|
||||
{else}
|
||||
<td width="75%" class="white">________________________________</td>
|
||||
{/if}
|
||||
@@ -371,7 +371,7 @@
|
||||
<table width="100%" cellpadding="4" cellspacing="0">
|
||||
<tr>
|
||||
<td width="25%" class="bold">{l s='Payment Method:' pdf='true'}</td>
|
||||
<td width="75%" class="white">{if $payment_method_options|@count}{foreach from=$payment_method_options item=item name=paymentMethod}{if !$smarty.foreach.paymentMethod.first} {/if}<span style="font-family: freeserif; white-space: nowrap;">□ {$item.name|escape:'html':'UTF-8'|replace:' ':' '}</span>{/foreach}{else}________________________________{/if}</td>
|
||||
<td width="75%" class="white">{if $payment_method_options|@count}{foreach from=$payment_method_options item=item name=paymentMethod}{if !$smarty.foreach.paymentMethod.first} {/if}<span style="font-family: freeserif; white-space: nowrap;">□ {$item.name|escape:'html':'UTF-8'|replace:' ':' '}</span>{/foreach}{else}________________________________{/if}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="25%" class="bold">{l s='Credit Card Number:' pdf='true'}</td>
|
||||
@@ -403,17 +403,17 @@
|
||||
<tr>
|
||||
<td class="white">
|
||||
<strong> {l s='Check-in Time:' pdf='true'}</strong>
|
||||
{if $hotel_check_in_time}{$hotel_check_in_time|escape:'html':'UTF-8'}{else}__________{/if}
|
||||
{if $hotel && $hotel->check_in && $hotel->check_in != '00:00:00'}{$hotel->check_in|escape:'html':'UTF-8'}{else}__________{/if}
|
||||
|
||||
<strong>{l s='Check-out Time:' pdf='true'}</strong>
|
||||
{if $hotel_check_out_time}{$hotel_check_out_time|escape:'html':'UTF-8'}{else}__________{/if}
|
||||
{if $hotel && $hotel->check_out && $hotel->check_out != '00:00:00'}{$hotel->check_out|escape:'html':'UTF-8'}{else}__________{/if}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="white">
|
||||
<strong> {l s='Hotel Policies:' pdf='true'}</strong>
|
||||
{if $hotel_policies}
|
||||
{$hotel_policies}
|
||||
{if $hotel && $hotel->policies && !($hotel->policies|@is_array)}
|
||||
{$hotel->policies}
|
||||
{else}
|
||||
______________________________<br />
|
||||
______________________________<br />
|
||||
|
||||
Reference in New Issue
Block a user