hallo,

Ik hoop dat jullie mij kunnen helpen.
Ik maak voor een goede vriend een website. Echter krijg ik een ding niet aan de praat.
Het gaat om een boekingsformulier. Hierin moeten de klanten een aanbetaling doen.
Nu gebruikt de plug-in (joomla met jomres) een percentage van het totaal bedrag. In mijn geval 20%. Echter wil ik ook een minimum hebben van 100 euro. Volgens mij moet ik hier iets aanpassen, maar ik zou niet weten waar.


<?php
/**
* Calculates how much deposit should be charged.
*/
public function calcDeposit()
{
$mrConfig = $this->mrConfig;
$datesTilBooking = $this->findDateRangeForDates($this->today, $this->arrivalDate);
$this->setErrorLog('calcDeposit::Use variable deposits : '.$mrConfig[ 'use_variable_deposits' ]);
$this->setErrorLog('calcDeposit::Variable deposit threashold : '.(int) $mrConfig[ 'variable_deposit_threashold' ]);
$this->setErrorLog('calcDeposit::Days til booking : '.count($datesTilBooking));
if ($mrConfig[ 'depositIsOneNight' ] == '1') {
if ($this->stayDays == 1) {
$depositValue = $this->billing_grandtotal;
} else {
$depositValue = $this->rate_pernight;
// This line can be modified, if we want the deposit to be first night X number of rooms you'd change the above line to
// $depositValue = $this->rate_pernight*count ($this->requestedRoom);

$basic_property_details = jomres_singleton_abstract::getInstance('basic_property_details');

$depositValue = $basic_property_details->get_gross_accommodation_price($depositValue, $this->property_uid);
}
} else {
if ($mrConfig[ 'use_variable_deposits' ] == '1' && count($datesTilBooking) <= (int) $mrConfig[ 'variable_deposit_threashold' ]) {
$depositValue = $this->contract_total;
} else {
// Calculate deposit
$depositValue = 0;
// Depreciating this next if, but leaving the stuff inside on. This is because a few folks are setting the show deposit to No, but still sending the deposit value to
// paypal/gateway. Commenting out this if will mean that the deposit is still calculated.
//if ($this->cfg_chargeDepositYesNo=="1")
//	{
$depositValue = $this->cfg_depositValue;
$totalBooking = $this->contract_total;
if ($this->cfg_depAmount == '1') {
$depositValue = $this->contract_total;
} else {
if ($this->cfg_depositIsPercentage == '1') {
if ($this->cfg_roundupDepositYesNo == '1') {
$depositValue = ceil(($totalBooking / 100) * $depositValue);
} else {
$depositValue = ($totalBooking / 100) * $depositValue;
}
} else {
if ($this->cfg_roundupDepositYesNo == '1') {
$depositValue = ceil($depositValue);
} else {
$depositValue = $depositValue;
}
}
}
//}
?>


Weet iemand van jullie hoe het moet?
Dit is niet de hele functie / methode (bovenstaande code is incompleet), ook wordt er in het bovenstaande geen waarde (uitkomst) geretourneerd.

Mijn eerste ingeving zou zijn:
kijk of hier een instelling voor is.

Mijn tweede ingeving:
Neem contact op met de makers van deze code.

Als laatste optie / redmiddel zou je kunnen proberen de code aan te passen, na het maken van een backup van de huidige code.

Ik zou verwachten (natte vingerwerk) dat er aan het einde zoiets staat als:
return $depositValue;


Je zou hier direct het volgende voor kunnen zetten (aanname: $depositValue is in euro's):
// minimal deposit: 100 euros
$depositValue = max($depositValue, 100);
Klopt ik dacht dat dat genoeg was. Dit is de volledige code:

[code]
<?php
/**
* Core file.
*
* @author Vince Wooll <[email protected]>
*
* @version Jomres 9.8.24
*
* @copyright 2005-2016 Vince Wooll
* Jomres (tm) PHP, CSS & Javascript files are released under both MIT and GPL2 licenses. This means that you can choose the license that best suits your project, and use it accordingly
**/

// ################################################################
defined('_JOMRES_INITCHECK') or die('');
// ################################################################

/**
* This file is the main code block that manages the booking engine.
#
*
#
* It is not designed to be implemented or called directly. Instead it is called by the j05000bookingobject.class.php file which inherits from this file.
*/
class dobooking
{
/**
* Constructor for the jomres_booking object, sets a bunch of variables, finds configuration settings & gets the current state of the booking from the tmpbooking table.
*/
public function __construct()
{
$siteConfig = jomres_getSingleton('jomres_config_site_singleton');
$jrConfig = $siteConfig->get();

$this->jrConfig = $jrConfig; // Importing the site config settings

$this->suppress_output = true;
if (get_showtime('task') == 'handlereq' || get_showtime('task') == 'dobooking') {
$this->suppress_output = false;
}

$this->requestedRoom = array();
$this->rate_pernight = 0.00;
$this->rate_pernight_nodiscount = 0.00;
$this->room_total_nodiscount = 0.00;
$this->discounts = array();
$this->total_in_party = 0;
$this->variancetypes = array();
$this->varianceuids = array();
$this->varianceqty = array();
$this->variancevals = array();
$this->variancevals_nodiscount = array();
//$this->coupon_id = "";
//$this->coupon = "";
$this->lastminute_id = '';
$this->arrivalDate = '';
$this->departureDate = '';
$this->stayDays = 1;
$this->dateRangeString = '';
$this->guests_uid = '';
$this->property_uid = '';
$this->rates_uid = '';
$this->tag = '';
$this->resource = '';
$this->rate_rules = 0.00;
$this->single_person_suppliment = 0.00;
$this->deposit_required = 0.00;
$this->contract_total = 0.00;

$this->extrasvalue = 0.00;
$this->tax = 0.00;
$this->extras = '';
$this->third_party_extras = array();
$this->third_party_extras_private_data = array();
$this->total_discount = 0.00;
$this->depositpaidsuccessfully = false;
$this->booker_class = '000';
$this->ok_to_book = false;
$this->referrer = '';
$this->error_log = '';
$this->total_in_party = 0;
$this->mininterval = 1;
$this->unixArrivalDate = null;
$this->unixDepartureDate = null;
$this->beds_available = 0;
$this->monitoringMessages = array();
$this->room_feature_filter = array();
$this->vt = '';
$this->vu = '';
$this->vq = '';
$this->vv = '';
$this->rr = '';

$this->existing_id = '';
$this->mos_userid = 0;
$this->firstname = '';
$this->surname = '';
$this->house = '';
$this->street = '';
$this->town = '';
$this->region = '';
$this->postcode = '';
$this->tel_landline = '';
$this->tel_mobile = '';
$this->email = '';
$this->guest_specific_discount = 0;
$this->additional_line_items = array();

//$this->today = date("Y/m/d");
// Should be better at detecting today's date subject DST
$this->today = date('Y/m/d', mktime(0, 0, 0, date('m'), date('d'), date('Y')));

$this->error = '';
$this->error_code = '';
$this->billing_roomtotal = 0.00;
//$this->customTextArray = array();
$this->resetPricingOutput = false;
$this->roomImageHTML = '';
$this->allPropertyRooms = array();
$this->allPropertyRoomUids = array();
$this->allPropertyTariffs = array();
$this->allFeatureDetails = array();
$this->allFeatureIds = array();
$this->allRoomClasses = array();
$this->allRoomClassIds = array();
$this->allBookings = array();
$this->rebuildIgnoreList = array();
$this->currentField = '';
$this->singlePersonSupplimentCalculated = false;
$this->email_address_can_be_used = true;

$bookingDeets = $this->getTmpBookingData();

$this->setErrorLog('Queried session data for existing booking');
if (count($bookingDeets) > 0) {
if (!isset($bookingDeets[ 'email_address_can_be_used' ])) {
$bookingDeets[ 'email_address_can_be_used' ] = true;
}
$this->email_address_can_be_used = $bookingDeets[ 'email_address_can_be_used' ];
$this->rr = $bookingDeets[ 'requestedRoom' ];
$this->rate_pernight = $bookingDeets[ 'rate_pernight' ];
$this->vt = $bookingDeets[ 'variancetypes' ];
$this->vu = $bookingDeets[ 'varianceuids' ];
$this->vq = $bookingDeets[ 'varianceqty' ];
$this->vv = $bookingDeets[ 'variancevals' ];
$this->vv_nodiscount = $bookingDeets[ 'variancevals_nodiscount' ];
//$this->coupon_id = $bookingDeets['coupon_id'];
//$this->coupon = $bookingDeets['coupon'];
$this->lastminute_id = $bookingDeets[ 'lastminute_id' ];
if (!isset($bookingDeets[ 'arrivalDate' ])) {
$bookingDeets[ 'arrivalDate' ] = '';
$bookingDeets[ 'departureDate' ] = '';
}
$this->arrivalDate = $bookingDeets[ 'arrivalDate' ];
$this->departureDate = $bookingDeets[ 'departureDate' ];
$this->stayDays = $bookingDeets[ 'stayDays' ];
$this->dateRangeString = $bookingDeets[ 'dateRangeString' ];
$this->guests_uid = $bookingDeets[ 'guests_uid' ];
$this->property_uid = (int) $bookingDeets[ 'property_uid' ];
$this->rates_uid = $bookingDeets[ 'rates_uid' ];
$this->resource = $bookingDeets[ 'resource' ];
$this->single_person_suppliment = $bookingDeets[ 'single_person_suppliment' ];
$this->deposit_required = $bookingDeets[ 'deposit_required' ];
$this->contract_total = $bookingDeets[ 'contract_total' ];
$this->extrasvalue = $bookingDeets[ 'extrasvalue' ];

$this->extrasvalues_items = unserialize($bookingDeets[ 'extrasvalues_items' ]);
$this->third_party_extras = unserialize($bookingDeets[ 'third_party_extras' ]);
$this->third_party_extras_private_data = unserialize($bookingDeets[ 'third_party_extras_private_data' ]);
$this->room_allocations = unserialize($bookingDeets[ 'room_allocations' ]);
$this->room_allocations_note = $bookingDeets[ 'room_allocations_note' ];
$this->property_currencycode = $bookingDeets[ 'property_currencycode' ];

$this->tax = $bookingDeets[ 'tax' ];
$this->extras = $bookingDeets[ 'extras' ];
$this->extrasquantities = $bookingDeets[ 'extrasquantities' ];
$this->total_discount = $bookingDeets[ 'total_discount' ];
$this->depositpaidsuccessfully = $bookingDeets[ 'depositpaidsuccessfully' ];
$this->booker_class = $bookingDeets[ 'booker_class' ];
$this->ok_to_book = $bookingDeets[ 'ok_to_book' ];
$this->beds_available = $bookingDeets[ 'beds_available' ];
$this->referrer = $bookingDeets[ 'referrer' ];
$this->error = $bookingDeets[ 'error_log' ];
$this->room_total = $bookingDeets[ 'room_total' ];
$this->room_total_nodiscount = $bookingDeets[ 'room_total_nodiscount' ];
//$this->discounts = $bookingDeets[ 'discounts' ];
$this->total_in_party = $bookingDeets[ 'total_in_party' ];
//if ($this->booker_class == "100")
// $this->mininterval = 1;
//else
// $this->mininterval = $bookingDeets['mininterval'];
// if ($this->mininterval == 0)
// $this->mininterval = 1;
$this->amend_contract = false;
if (isset($bookingDeets[ 'amend_contract' ])) {
$this->amend_contract = $bookingDeets[ 'amend_contract' ];
}
$this->coupon_id = $bookingDeets[ 'coupon_id' ];
$this->coupon_code = $bookingDeets[ 'coupon_code' ];
$this->coupon_details = $bookingDeets[ 'coupon_details' ];
$this->coupon_discount_value = $bookingDeets[ 'coupon_discount_value' ];
$this->booking_notes = $bookingDeets[ 'booking_notes' ];
$this->additional_line_items = unserialize($bookingDeets[ 'additional_line_items' ]);
$this->room_feature_filter = unserialize($bookingDeets[ 'room_feature_filter' ]);
$this->override_room_total = $bookingDeets[ 'override_room_total' ];
$this->override_deposit = $bookingDeets[ 'override_deposit' ];
if (isset($bookingDeets[ 'thirdparty_vars' ])) {
$this->thirdparty_vars = $bookingDeets[ 'thirdparty_vars' ];
}
}

$dbdata = serialize($bookingDeets);
$dbdata = str_replace(';', ' ', $dbdata);
$this->setErrorLog("<font color='grey'>Constructor::Data pulled from Session variables ".$dbdata.'</font>');

if (!empty($this->rr)) {
$this->requestedRoom = explode(',', $this->rr);
}
$this->variancetypes = explode(',', $this->vt);
$this->varianceuids = explode(',', $this->vu);
$this->varianceqty = explode(',', $this->vq);
$this->variancevals = explode(',', $this->vv);
$this->variancevals_nodiscount = explode(',', $this->vv_nodiscount);

foreach ($this->varianceuids as $key => $variance_uid) {
if ((int) $variance_uid == 0 || !$this->checkGuestVariantIdAndQty($variance_uid, 1)) {
$this->setErrorLog('init::Unsetting variances with key '.$key);
unset($this->variancetypes[ $key ]);
unset($this->varianceuids[ $key ]);
unset($this->varianceqty[ $key ]);
unset($this->variancevals[ $key ]);
unset($this->variancevals_nodiscount[ $key ]);
}
}

$userDeets = $this->getTmpGuestData();

//$this->errorLog( "Set booking variables " );
$this->mos_userid = $userDeets[ 'mos_userid' ];
$this->existing_id = $userDeets[ 'existing_id' ];
$this->firstname = $userDeets[ 'firstname' ];
$this->surname = $userDeets[ 'surname' ];
$this->house = $userDeets[ 'house' ];
$this->street = $userDeets[ 'street' ];
$this->town = $userDeets[ 'town' ];
$this->region = $userDeets[ 'region' ];
$this->country = $userDeets[ 'country' ];
$this->postcode = $userDeets[ 'postcode' ];
$this->tel_landline = $userDeets[ 'tel_landline' ];
$this->tel_mobile = $userDeets[ 'tel_mobile' ];
$this->email = $userDeets[ 'email' ];
$this->guest_specific_discount = $userDeets[ 'discount' ];

$mrConfig = getPropertySpecificSettings($this->property_uid);

$this->mrConfig = $mrConfig;
if (isset($mrConfig[ 'margin' ]) && !empty($mrConfig[ 'margin' ])) {
$this->margin = $mrConfig[ 'margin' ];
} else {
$this->margin = '0.00';
}
$this->tariffModel = $mrConfig[ 'newTariffModels' ];
if ($this->tariffModel != '1' && $this->tariffModel != '2') {
$this->tariffModel = '1';
}
if (!isset($mrConfig[ 'cal_input' ])) {
echo "Error: Configuration settings don't appear to be set. There are ".count($mrConfig).' elements in the mrConfig var and '.count($jrConfig).' in the jrConfig var. If you have just installed Jomres you should log into the frontend as a property manager. This will set up sufficient data so that you can proceed.';
exit;
}
$this->cfg_tariffmode = $mrConfig[ 'tariffmode' ];
$this->cfg_errorChecking = $mrConfig[ 'errorChecking' ];
$this->cfg_singlePersonSuppliment = $mrConfig[ 'singlePersonSuppliment' ];
$this->cfg_supplimentChargeIsPercentage = $mrConfig[ 'supplimentChargeIsPercentage' ];
$this->cfg_singlePersonSupplimentCost = $mrConfig[ 'singlePersonSupplimentCost' ];
$this->cfg_perPersonPerNight = $mrConfig[ 'perPersonPerNight' ];
$this->cfg_depositIsPercentage = $mrConfig[ 'depositIsPercentage' ];
$this->cfg_depositValue = $mrConfig[ 'depositValue' ];
$this->cfg_visitorscanbookonline = $mrConfig[ 'visitorscanbookonline' ];
$this->cfg_fixedPeriodBookings = $mrConfig[ 'fixedPeriodBookings' ];
$this->cfg_fixedPeriodBookingsNumberOfDays = $mrConfig[ 'fixedPeriodBookingsNumberOfDays' ];
$this->cfg_numberofFixedPeriods = $mrConfig[ 'numberofFixedPeriods' ];
$this->cfg_fixedArrivalDateYesNo = $mrConfig[ 'fixedArrivalDateYesNo' ];
$this->cfg_fixedArrivalDay = $mrConfig[ 'fixedArrivalDay' ];
$this->cfg_fixedPeriodBookingsShortYesNo = $mrConfig[ 'fixedPeriodBookingsShortYesNo' ];
$this->cfg_fixedPeriodBookingsShortNumberOfDays = $mrConfig[ 'fixedPeriodBookingsShortNumberOfDays' ];
$this->cfg_singleRoomProperty = $mrConfig[ 'singleRoomProperty' ];
$this->cfg_cal_output = $mrConfig[ 'cal_output' ];
$this->cfg_cal_input = $jrConfig[ 'cal_input' ];

$this->cfg_templatePack = 'basic';
$this->cfg_limitAdvanceBookingsYesNo = $mrConfig[ 'limitAdvanceBookingsYesNo' ];
$this->cfg_advanceBookingsLimit = $mrConfig[ 'advanceBookingsLimit' ];
$this->cfg_roomTaxYesNo = $mrConfig[ 'roomTaxYesNo' ];
$this->cfg_roomTaxFixed = $mrConfig[ 'roomTaxFixed' ];
$this->cfg_roomTaxPercentage = $mrConfig[ 'roomTaxPercentage' ];
$this->cfg_euroTaxYesNo = $mrConfig[ 'euroTaxYesNo' ];
$this->cfg_euroTaxPercentage = $mrConfig[ 'euroTaxPercentage' ];
$this->cfg_depAmount = $mrConfig[ 'depAmount' ];
$this->cfg_showdepartureinput = $mrConfig[ 'showdepartureinput' ];
$this->cfg_ratemultiplier = $mrConfig[ 'ratemultiplier' ];
$this->cfg_dateFormatStyle = $mrConfig[ 'dateFormatStyle' ];

$this->cfg_inputBoxErrorBackground = $mrConfig[ 'inputBoxErrorBackground' ];

$tmpBookingHandler = jomres_getSingleton('jomres_temp_booking_handler');

if (!isset($mrConfig[ 'auto_detect_country_for_booking_form' ])) {
$mrConfig[ 'auto_detect_country_for_booking_form' ] = '1';
}

if ($mrConfig[ 'auto_detect_country_for_booking_form' ] == '1' && isset($tmpBookingHandler->user_settings[ 'geolocated_country' ])) {
$this->cfg_defaultcountry = $tmpBookingHandler->user_settings[ 'geolocated_country' ];
} else {
$this->cfg_defaultcountry = $mrConfig[ 'defaultcountry' ];
}

//if ($this->booker_class == "100")
// $this->cfg_minimuminterval = 1;
//else
$this->cfg_minimuminterval = $mrConfig[ 'minimuminterval' ];
$this->cfg_showDeposit = $mrConfig[ 'chargeDepositYesNo' ];
$this->cfg_showRoomImageInBookingFormOverlib = $mrConfig[ 'showRoomImageInBookingFormOverlib' ];

if ($this->booker_class == '100') {
$this->cfg_mindaysbeforearrival = 0;
} else {
$this->cfg_mindaysbeforearrival = $mrConfig[ 'mindaysbeforearrival' ];
}

$this->cfg_defaultNumberOfFirstGuesttype = $mrConfig[ 'defaultNumberOfFirstGuesttype' ];
$this->cfg_roundupDepositYesNo = $mrConfig[ 'roundupDepositYesNo' ];
$this->cfg_chargeDepositYesNo = $mrConfig[ 'chargeDepositYesNo' ];
$this->cfg_tariffChargesStoredWeeklyYesNo = $mrConfig[ 'tariffChargesStoredWeeklyYesNo' ];
$this->cfg_fixedArrivalDatesRecurring = $mrConfig[ 'fixedArrivalDatesRecurring' ];
$this->cfg_returnRoomsLimit = $mrConfig[ 'returnRoomsLimit' ];
if (!isset($mrConfig[ 'cfg_weekenddays' ])) {
$mrConfig[ 'cfg_weekenddays' ] = '5,6';
}
$this->cfg_weekenddays = explode(',', $mrConfig[ 'weekenddays' ]);
$this->cfg_bookingform_roomlist_showroomno = $mrConfig[ 'bookingform_roomlist_showroomno' ];
$this->cfg_bookingform_roomlist_showroomname = $mrConfig[ 'bookingform_roomlist_showroomname' ];

$this->cfg_bookingform_roomlist_showdisabled = $mrConfig[ 'bookingform_roomlist_showdisabled' ];
$this->cfg_bookingform_roomlist_showmaxpeople = $mrConfig[ 'bookingform_roomlist_showmaxpeople' ];

$this->cfg_bookingform_requiredfields_name = $mrConfig[ 'bookingform_requiredfields_name' ];
$this->cfg_bookingform_requiredfields_surname = $mrConfig[ 'bookingform_requiredfields_surname' ];
$this->cfg_bookingform_requiredfields_houseno = $mrConfig[ 'bookingform_requiredfields_houseno' ];
$this->cfg_bookingform_requiredfields_street = $mrConfig[ 'bookingform_requiredfields_street' ];
$this->cfg_bookingform_requiredfields_town = $mrConfig[ 'bookingform_requiredfields_town' ];
$this->cfg_bookingform_requiredfields_postcode = $mrConfig[ 'bookingform_requiredfields_postcode' ];
$this->cfg_bookingform_requiredfields_region = $mrConfig[ 'bookingform_requiredfields_region' ];
$this->cfg_bookingform_requiredfields_country = $mrConfig[ 'bookingform_requiredfields_country' ];
$this->cfg_bookingform_requiredfields_tel = $mrConfig[ 'bookingform_requiredfields_tel' ];
$this->cfg_bookingform_requiredfields_mobile = $mrConfig[ 'bookingform_requiredfields_mobile' ];
$this->cfg_bookingform_requiredfields_email = $mrConfig[ 'bookingform_requiredfields_email' ];

$this->property_currencycode = $mrConfig[ 'property_currencycode' ];

if (!isset($mrConfig[ 'booking_form_rooms_list_style' ])) {
$mrConfig[ 'booking_form_rooms_list_style' ] = '1';
}

if (!isset($mrConfig[ 'booking_form_daily_weekly_monthly' ])) {
$mrConfig[ 'booking_form_daily_weekly_monthly' ] = 'D';
}
$this->cfg_booking_form_daily_weekly_monthly = $mrConfig[ 'booking_form_daily_weekly_monthly' ];

$amend_contract = $tmpBookingHandler->getBookingFieldVal('amend_contract');

if ($amend_contract) {
$mrConfig[ 'booking_form_rooms_list_style' ] = '1';
}

$this->cfg_booking_form_rooms_list_style = $mrConfig[ 'booking_form_rooms_list_style' ];

$mrConfig = $this->mrConfig;
$this->accommodation_tax_rate = 0.0;
if (isset($mrConfig[ 'accommodation_tax_code' ]) && (int) $mrConfig[ 'accommodation_tax_code' ] > 0) {
$jrportal_taxrate = jomres_singleton_abstract::getInstance('jrportal_taxrate');
$cfgcode = $mrConfig[ 'accommodation_tax_code' ];
$this->accommodation_tax_rate = (float) $jrportal_taxrate->taxrates[ $cfgcode ][ 'rate' ];
}

// Let's get the room, tariff, room type (class) and room feature information for this property

if (get_showtime('include_room_booking_functionality')) {
$this->getAllRoomsData();
$this->getAllTariffsData();
$this->getAllRoomFeatureDetails();
$this->getAllRoomClasses();
$this->getAllRoomFeatures();
$this->getAllBookings();
$this->getAllTaxRates();
$this->get_all_tariff_types();

$this->checkAllGuestsAllocatedToRooms();
}

$this->checkAllGuestsAllocatedToRooms();

return true;
}

/**
*Queries the database for the temporary booking data.
*/
public function getTmpBookingData()
{
$tmpBookingHandler = jomres_getSingleton('jomres_temp_booking_handler');
$bookingDeets = $tmpBookingHandler->getBookingData();
if (!isset($bookingDeets[ 'show_extras' ])) {
$bookingDeets[ 'show_extras' ] = '1';
}

$this->cfg_showExtras = $bookingDeets[ 'show_extras' ];

return $bookingDeets;
}

/**
*Queries the database for the temporary booking data.
*/
public function getTmpGuestData()
{
$tmpBookingHandler = jomres_getSingleton('jomres_temp_booking_handler');
$userDeets = $tmpBookingHandler->getGuestData();

return $userDeets;
}

/**
* Save the details of the booking object.
*/
public function storeBookingDetails()
{
$tmpBookingHandler = jomres_getSingleton('jomres_temp_booking_handler');
$this->writeToLogfile("<font color='grey'>".serialize($tmpBookingHandler->tmpguest).'</font>');

$tmpBookingHandler->tmpguest[ 'mos_userid' ] = $this->mos_userid;
$tmpBookingHandler->tmpguest[ 'existing_id' ] = getEscaped($this->existing_id);
$tmpBookingHandler->tmpguest[ 'firstname' ] = getEscaped($this->firstname);
$tmpBookingHandler->tmpguest[ 'surname' ] = getEscaped($this->surname);
$tmpBookingHandler->tmpguest[ 'house' ] = getEscaped($this->house);
$tmpBookingHandler->tmpguest[ 'street' ] = getEscaped($this->street);
$tmpBookingHandler->tmpguest[ 'town' ] = getEscaped($this->town);
$tmpBookingHandler->tmpguest[ 'region' ] = getEscaped($this->region);
$tmpBookingHandler->tmpguest[ 'country' ] = getEscaped($this->country);
$tmpBookingHandler->tmpguest[ 'postcode' ] = getEscaped($this->postcode);
$tmpBookingHandler->tmpguest[ 'tel_landline' ] = getEscaped($this->tel_landline);
$tmpBookingHandler->tmpguest[ 'tel_mobile' ] = getEscaped($this->tel_mobile);
$tmpBookingHandler->tmpguest[ 'email' ] = getEscaped($this->email);
$tmpBookingHandler->tmpguest[ 'discount' ] = getEscaped($this->guest_specific_discount);

$tmpBookingHandler->saveGuestData();

$rr = implode(',', $this->requestedRoom);
$this->implodeVariances();

$this->writeToLogfile($this->error);
$this->error = '';

$tmpBookingHandler->tmpbooking[ 'requestedRoom' ] = $rr;
$tmpBookingHandler->tmpbooking[ 'rate_pernight' ] = $this->rate_pernight;
$tmpBookingHandler->tmpbooking[ 'variancetypes' ] = $this->vt;
$tmpBookingHandler->tmpbooking[ 'varianceuids' ] = $this->vu;
$tmpBookingHandler->tmpbooking[ 'varianceqty' ] = $this->vq;
$tmpBookingHandler->tmpbooking[ 'variancevals' ] = $this->vv;
$tmpBookingHandler->tmpbooking[ 'variancevals_nodiscount' ] = $this->vv_nodiscount;
//$tmpBookingHandler->tmpbooking["coupon_id"] = $this->coupon_id;
//$tmpBookingHandler->tmpbooking["coupon"] = $this->coupon;
$tmpBookingHandler->tmpbooking[ 'lastminute_id' ] = $this->lastminute_id;
$tmpBookingHandler->tmpbooking[ 'arrivalDate' ] = $this->arrivalDate;
$tmpBookingHandler->tmpbooking[ 'departureDate' ] = $this->departureDate;
$tmpBookingHandler->tmpbooking[ 'stayDays' ] = $this->stayDays;
$tmpBookingHandler->tmpbooking[ 'dateRangeString' ] = $this->dateRangeString;
$tmpBookingHandler->tmpbooking[ 'guests_uid' ] = $this->guests_uid;
$tmpBookingHandler->tmpbooking[ 'property_uid' ] = $this->property_uid;
$tmpBookingHandler->tmpbooking[ 'rates_uid' ] = $this->rates_uid;
$tmpBookingHandler->tmpbooking[ 'resource' ] = $this->resource;
$tmpBookingHandler->tmpbooking[ 'single_person_suppliment' ] = $this->single_person_suppliment;
$tmpBookingHandler->tmpbooking[ 'deposit_required' ] = $this->deposit_required;
$tmpBookingHandler->tmpbooking[ 'contract_total' ] = $this->contract_total;
$tmpBookingHandler->tmpbooking[ 'extrasvalue' ] = $this->extrasvalue;
$tmpBookingHandler->tmpbooking[ 'extrasvalues_items' ] = serialize($this->extrasvalues_items);
$tmpBookingHandler->tmpbooking[ 'extras' ] = $this->extras;
$tmpBookingHandler->tmpbooking[ 'extrasquantities' ] = $this->extrasquantities;
$tmpBookingHandler->tmpbooking[ 'third_party_extras' ] = serialize($this->third_party_extras);
$tmpBookingHandler->tmpbooking[ 'third_party_extras_private_data' ] = serialize($this->third_party_extras_private_data);

$tmpBookingHandler->tmpbooking[ 'room_allocations' ] = serialize($this->room_allocations);
$tmpBookingHandler->tmpbooking[ 'room_allocations_note' ] = serialize($this->room_allocations_note);

$tmpBookingHandler->tmpbooking[ 'total_discount' ] = $this->total_discount;
$tmpBookingHandler->tmpbooking[ 'depositpaidsuccessfully' ] = $this->depositpaidsuccessfully;
$tmpBookingHandler->tmpbooking[ 'tax' ] = $this->tax;
$tmpBookingHandler->tmpbooking[ 'booker_class' ] = $this->booker_class;
$tmpBookingHandler->tmpbooking[ 'ok_to_book' ] = $this->ok_to_book;
$tmpBookingHandler->tmpbooking[ 'beds_available' ] = $this->beds_available;
$tmpBookingHandler->tmpbooking[ 'referrer' ] = $this->referrer;
$tmpBookingHandler->tmpbooking[ 'error_log' ] = $this->error;
$tmpBookingHandler->tmpbooking[ 'total_in_party' ] = $this->total_in_party;
$tmpBookingHandler->tmpbooking[ 'room_total' ] = $this->room_total;
$tmpBookingHandler->tmpbooking[ 'room_total_nodiscount' ] = $this->room_total_nodiscount;
$tmpBookingHandler->tmpbooking[ 'discounts' ] = $this->discounts;
$tmpBookingHandler->tmpbooking[ 'timestamp' ] = date('Y-m-d H:i:s');
$tmpBookingHandler->tmpbooking[ 'mininterval' ] = $this->mininterval;
$tmpBookingHandler->tmpbooking[ 'coupon_id' ] = $this->coupon_id;
$tmpBookingHandler->tmpbooking[ 'coupon_code' ] = $this->coupon_code;
$tmpBookingHandler->tmpbooking[ 'coupon_details' ] = $this->coupon_details;
$tmpBookingHandler->tmpbooking[ 'coupon_discount_value' ] = $this->coupon_discount_value;
$tmpBookingHandler->tmpbooking[ 'booking_notes' ] = $this->booking_notes;
$tmpBookingHandler->tmpbooking[ 'additional_line_items' ] = serialize($this->additional_line_items);
$tmpBookingHandler->tmpbooking[ 'room_feature_filter' ] = serialize($this->room_feature_filter);
$tmpBookingHandler->tmpbooking[ 'override_room_total' ] = $this->override_room_total;
$tmpBookingHandler->tmpbooking[ 'override_deposit' ] = $this->override_deposit;

$tmpBookingHandler->tmpbooking[ 'show_extras' ] = $this->cfg_showExtras;
$tmpBookingHandler->tmpbooking[ 'property_currencycode' ] = $this->property_currencycode;
$tmpBookingHandler->tmpbooking[ 'email_address_can_be_used' ] = $this->email_address_can_be_used;

if (isset($this->thirdparty_vars)) {
$tmpBookingHandler->tmpbooking[ 'thirdparty_vars' ] = $this->thirdparty_vars;
}

//store the new search dates
$tmpBookingHandler->tmpsearch_data[ 'jomsearch_availability' ] = $this->arrivalDate;
$tmpBookingHandler->tmpsearch_data[ 'jomsearch_availability_departure' ] = $this->departureDate;

$tmpBookingHandler->saveBookingData();
}

public function getAllRoomsData()
{
$basic_room_details = jomres_singleton_abstract::getInstance('basic_room_details');
$basic_room_details->get_all_rooms($this->property_uid);

$jomres_media_centre_images = jomres_singleton_abstract::getInstance('jomres_media_centre_images');
$images = $jomres_media_centre_images->get_images($this->property_uid, array('rooms')); // Gets the rooms images

$room_images = $images [ 'rooms' ];

foreach ($basic_room_details->rooms as $r) {
$this->allPropertyRooms[ $r['room_uid'] ] = array(
'room_uid' => $r['room_uid'],
'room_classes_uid' => $r['room_classes_uid'],
'propertys_uid' => $r['propertys_uid'],
'room_features_uid' => $r['room_features_uid'],
'room_name' => $r['room_name'],
'room_number' => $r['room_number'],
'room_floor' => $r['room_floor'],
'max_people' => $r['max_people'],
'singleperson_suppliment' => $r['singleperson_suppliment'],
'small_room_image' => $room_images [ $r['room_uid'] ] [0] ['small'],
'medium_room_image' => $room_images [ $r['room_uid'] ] [0] ['medium'],
);

$this->allPropertyRoomUids[ ] = $r['room_uid'];

if (!in_array($r['room_classes_uid'], $this->allRoomClassIds)) {
$this->allRoomClassIds[ ] = $r['room_classes_uid'];
}
}

if (count($basic_room_details->all_room_features) > 0) {
$this->allFeatureIds = array_keys($basic_room_details->all_room_features);
}
}

public function getAllTariffsData()
{
$query = "SELECT `rates_uid`,`rate_title`,`rate_description`,`validfrom`,`validto`,
`roomrateperday`,`mindays`,`maxdays`,`minpeople`,`maxpeople`,`roomclass_uid`,
`ignore_pppn`,`allow_ph`,`allow_we`,`weekendonly`,`dayofweek`,`minrooms_alreadyselected`,`maxrooms_alreadyselected`
FROM #__jomres_rates WHERE property_uid = '$this->property_uid'
AND DATE_FORMAT(`validto`, '%Y/%m/%d') >= DATE_FORMAT('".$this->today."', '%Y/%m/%d')
";

$tariffs = doSelectSql($query);

//$this->setErrorLog("getAllTariffsData:: ".$query );
//$this->setErrorLog("Finding tariffs");
//$this->setErrorLog($query);
//$this->setErrorLog(serialize($tariffs) );

$interval = new DateInterval('P1D');
foreach ($tariffs as $t) {
$roomrate = $this->get_nett_price($t->roomrateperday, $this->accommodation_tax_rate);
$dates = $this->get_periods($t->validfrom, $t->validto.' 23:59:59', $interval);
$this->allPropertyTariffs[ $t->rates_uid ] = array(
'rates_uid' => $t->rates_uid,
'rate_title' => $t->rate_title,
'rate_description' => $t->rate_description,
'validfrom' => $t->validfrom,
'validto' => $t->validto,
'roomrateperday' => $roomrate,
'mindays' => $t->mindays,
'maxdays' => $t->maxdays,
'minpeople' => $t->minpeople,
'maxpeople' => $t->maxpeople,
'roomclass_uid' => $t->roomclass_uid,
'ignore_pppn' => $t->ignore_pppn,
'allow_ph' => $t->allow_ph,
'allow_we' => $t->allow_we,
'weekendonly' => $t->weekendonly,
'dayofweek' => $t->dayofweek,
'minrooms_alreadyselected' => $t->minrooms_alreadyselected,
'maxrooms_alreadyselected' => $t->maxrooms_alreadyselected,
'tariff_dates' => $dates,
);
}
}

public function getAllRoomFeatureDetails()
{
$jomres_media_centre_images = jomres_singleton_abstract::getInstance('jomres_media_centre_images');
$jomres_media_centre_images->get_images($this->property_uid, array('room_features'));

$basic_room_details = jomres_singleton_abstract::getInstance('basic_room_details');
$basic_room_details->get_all_rooms($this->property_uid);

foreach ($basic_room_details->all_room_features as $f) {
$this->allFeatureDetails[ $f['room_features_uid'] ] = array('room_features_uid' => $f['room_features_uid'], 'feature_description' => $f['feature_description'], 'image' => $f['image'], 'tooltip' => $f['tooltip']);
}
}

public function getAllRoomClasses()
{
$query = 'SELECT room_classes_uid,room_class_abbv,room_class_full_desc,image FROM #__jomres_room_classes WHERE room_classes_uid IN ('.jomres_implode($this->allRoomClassIds).') ';
$roomClasses = doSelectSql($query);
foreach ($roomClasses as $c) {
$roomtype_abbv = jr_gettext('_JOMRES_CUSTOMTEXT_ROOMTYPES_ABBV'.(int) $c->room_classes_uid, stripslashes($c->room_class_abbv), false, false);
$roomtype_desc = jr_gettext('_JOMRES_CUSTOMTEXT_ROOMTYPES_DESC'.(int) $c->room_classes_uid, stripslashes($c->room_class_full_desc), false, false);

$this->allRoomClasses[ $c->room_classes_uid ] = array('room_class_abbv' => $roomtype_abbv, 'room_class_full_desc' => $roomtype_desc, 'image' => $c->image);
}
}

public function getAllRoomFeatures()
{
$basic_room_details = jomres_singleton_abstract::getInstance('basic_room_details');
$basic_room_details->get_all_rooms($this->property_uid);

if (count($basic_room_details->all_room_features) > 0) {
foreach ($basic_room_details->all_room_features as $f) {
$this->allRoomFeatures[ $f['room_features_uid'] ] = $f['feature_description'];
}
}
}

public function getAllBookings()
{
$tmpBookingHandler = jomres_getSingleton('jomres_temp_booking_handler');
$amend_contract = $tmpBookingHandler->getBookingFieldVal('amend_contract');
$amend_contractuid = $tmpBookingHandler->getBookingFieldVal('amend_contractuid');
if (!$amend_contract) {
$query = "SELECT room_uid,date FROM #__jomres_room_bookings WHERE property_uid = '$this->property_uid' AND room_uid IN (".jomres_implode($this->allPropertyRoomUids).') ';
} else {
$query = "SELECT room_uid,date FROM #__jomres_room_bookings WHERE property_uid = '$this->property_uid' AND contract_uid != '$amend_contractuid' AND room_uid IN (".jomres_implode($this->allPropertyRoomUids).') ';
}
$bookings = doSelectSql($query);
foreach ($bookings as $c) {
//$date=str_replace("/","",$c->date);
$this->allBookings[ $c->date ][ $c->room_uid ] = array('room_uid' => $c->room_uid);
}
if (count($this->allBookings) > 0) {
ksort($this->allBookings);
}
}

public function get_all_tariff_types()
{
$mrConfig = $this->mrConfig;
$this->all_tariff_types_to_tariff_id_xref = array();
$this->all_tariff_id_to_tariff_type_xref = array();
if ($mrConfig[ 'tariffmode' ] == '2') {
$query = "SELECT tarifftype_id,tariff_id FROM #__jomcomp_tarifftype_rate_xref WHERE property_uid = '$this->property_uid'";
$tariff_type_list = doSelectSql($query);
if (count($tariff_type_list) > 0) {
foreach ($tariff_type_list as $type) {
$this->all_tariff_types_to_tariff_id_xref[ $type->tarifftype_id ][ ] = $type->tariff_id;
$this->all_tariff_id_to_tariff_type_xref[ $type->tariff_id ][ ] = $type->tarifftype_id;
}
}
}
}

public function getAllTaxRates()
{
$jrportal_taxrate = jomres_singleton_abstract::getInstance('jrportal_taxrate');
$this->taxrates = $jrportal_taxrate->taxrates;
//$this->setErrorLog( "Init found tax rates " . serialize( $this->taxrates ) );
}

public function sanitise_for_eval($string)
{
$string = str_replace('"', '\"', $string);
$string = str_replace("'", "\'", $string);
$string = trim(preg_replace('/\s+/', ' ', $string)); // strips carriage returns from strings generated through templates
return $string;
}

public function get_fullybooked_dates()
{
$fully_booked_dates = array();
$MiniComponents = jomres_getSingleton('mcHandler');
if ($MiniComponents->eventFileExistsCheck('05060')) {
$result = $MiniComponents->triggerEvent('05060', $this);
if (isset($result[ 'plugin_manages_fully_booked_dates' ]) && $result[ 'plugin_manages_fully_booked_dates' ]) {
$booked_dates = $result[ 'fully_booked_dates' ];
foreach ($booked_dates as $date) {
$tmpdate = date('Y-n-j', strtotime($date));
$fully_booked_dates[ ] = $tmpdate;
}
}
}
if (!isset($result[ 'plugin_manages_fully_booked_dates' ])) {
$total_number_of_rooms = count($this->allPropertyRooms);

foreach ($this->allBookings as $date => $bookings) {
$number_of_bookings_this_date = count($bookings);
if ($number_of_bookings_this_date == $total_number_of_rooms) {
$tmpdate = date('Y-n-j', strtotime($date));
$fully_booked_dates[ ] = $tmpdate;
}
}
$all_tariffs_are_specific_days_of_week = true;
foreach ($this->allPropertyTariffs as $tariff) {
if ($tariff[ 'dayofweek' ] == 7) {
$all_tariffs_are_specific_days_of_week = false;
}
}
if ($all_tariffs_are_specific_days_of_week) {
$days_of_week_allowed = array();
foreach ($this->allPropertyTariffs as $tariff) {
$days_of_week_allowed[ ] = $tariff[ 'dayofweek' ];
}
$days_of_week_allowed = array_unique($days_of_week_allowed);
$start = date('Y/m/d');
$end = date('Y/m/d', strtotime('+4 years'));
$dates = $this->findDateRangeForDates($start, $end);
$count = count($dates);
for ($i = 0; $i <= $count; ++$i) {
$date = $dates[ $i ];
$day_of_week_of_date = $this->getDayOfWeek($date);
if (in_array($day_of_week_of_date, $days_of_week_allowed)) {
unset($dates[ $i ]);
}
}
foreach ($dates as $d) {
$tmpdate = date('Y-n-j', strtotime($d));
$fully_booked_dates[ ] = $tmpdate;
}
}
}

return $fully_booked_dates;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Generic variant handling

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
*Sanitises the input from the ajax query.
*/
public function sanitiseInput($type, $value)
{
switch ($type) {
case 'int':
$value = (int) $value;
break;
case 'string':
$value = $this->makeStringSafe($value);
break;
case 'date':
$tmpDate = explode('/', $value);
if (count($tmpDate) != 3) {
$value = null;
}
break;
default:
$value = null;
break;
}

return $value;
}

/**
* Sanitises the output before it's sent to the form. As the third phase of the form is generated from evaluated javascript queries any ' characters etc have to be stripped out before they're returned to the booking form.
*/
public function sanitiseOutput($data)
{
//$this->error($data);
//$data=str_replace("&#39;","\&#39;",$data); // These two lines commented out for 4.7.8 as they were removing ' from translated/editing mode stuff such as extras.
//$data=str_replace("'","\'",$data);
//$data=htmlentities($data);
return $data;
}

/**
* Make the string escaped.
*/
public function makeStringSafe($data)
{
$data = filter_var($data, FILTER_SANITIZE_SPECIAL_CHARS);

return $data;
}

/**
* Resets the requested room array to nuthin. When the currently available rooms list is re-generated the available rooms list is completely re-calculated.
*/
public function resetRequestedRoom()
{
jr_import('jomres_roomlocks');
$room_locker = new jomres_roomlocks();
$room_locker->unlock_all_rooms_for_session();
$this->requestedRoom = array();
}

/**
* Returns whether or not error checking flag is on or off.
*/
public function errorChecking()
{
if ($this->cfg_errorChecking == '1') {
return true;
} else {
return false;
}
}

/**
* Receives debugging messages and stores them in an array $this->error.
*/
public function setErrorLog($errorText)
{
$this->error .= $errorText.' <br/> ';
}

public function setErrorLogFirst($title)
{
$this->error = '<b>'.$title.'</b><br/>'.$this->error;
}

/**
* Returns the contents of $this->error.
*/
public function getErrorLog()
{
$errorString = '';
$errorString .= htmlentities($this->error);

return $this->error;
}

public function writeToLogfile($text)
{
logging::log_message($text, 'Dobooking', 'DEBUG');
}

public function getGrowlMessages()
{
$messages = ';';
if ($this->jrConfig[ 'useJomresMessaging' ] == '1') {
if (isset($this->growlmessages[ 'messages' ]) && count($this->growlmessages[ 'messages' ]) > 0) {
foreach ($this->growlmessages[ 'messages' ] as $message) {
if ($message != '') {
$messages .= 'jomresJquery.jGrowl(\''.$message.'\', { life: 20000,sticky:true });';
}
}
}
if (isset($this->growlmessages[ 'guest_feedback' ]) && count($this->growlmessages[ 'guest_feedback' ]) > 0) {
$messages .= 'jomresJquery.jGrowl(\''.$this->growlmessages[ 'guest_feedback' ].'\', { life: 10000 });';
}
$messages = substr($messages, 0, -1);

return $messages;
} elseif (isset($this->growlmessages[ 'messages' ]) && count($this->growlmessages[ 'messages' ]) > 0) { // normal messages are useful when developing the booking engine, so even if popups are disabled by default, we still want to see messages coded by the developer.
foreach ($this->growlmessages[ 'messages' ] as $message) {
if ($message != '') {
$messages .= 'jomresJquery.jGrowl(\''.$message.'\', { life: 20000,sticky:true });';
}
}

return $messages;
}
}

public function setPopupMessage($message)
{
$msg = $this->sanitiseOutput($message);
if ($_REQUEST[ 'field' ] != 'property_uid_check') {
$this->growlmessages[ 'messages' ][ ] = $msg;
}
}

public function setGuestPopupMessage($message)
{
$msg = $this->sanitiseOutput($message);
if (isset($_REQUEST[ 'field' ]) && $_REQUEST[ 'field' ] != 'property_uid_check') {
$this->growlmessages[ 'guest_feedback' ] = $msg;
}
}

public function echo_populate_div($message)
{
if (!$this->suppress_output) {
echo $message;
}
}

/**
* Returns true if this property is an SRP.
*/
public function getSingleRoomPropertyStatus()
{
if ($this->cfg_singleRoomProperty == '1') {
return true;
} else {
return false;
}
}

/**
* Make the Optional Extras.
*/
public function makeExtras($selectedProperty)
{
$jomres_media_centre_images = jomres_singleton_abstract::getInstance('jomres_media_centre_images');
$jomres_media_centre_images->get_images($this->property_uid, array('extras'));

$mrConfig = $this->mrConfig;
$extra_details = array();

if ($mrConfig[ 'showExtras' ] == '1') {
$query = "SELECT `uid`,`name`,`desc`,`maxquantity`,`price`,`auto_select`,`tax_rate`,`chargabledaily`,`property_uid`,`published`,`validfrom`,`validto`,`limited_to_room_type` FROM `#__jomres_extras` where property_uid = '$selectedProperty' AND published = '1' ORDER BY name";
$exList = doSelectSql($query);

$selected_rooms_room_types = array();
if (count($this->requestedRoom) > 0) {
foreach ($this->requestedRoom as $rm) {
$room = explode('^', $rm);
$tariff_id = $room[ 1 ];
$booking_room_type_id = $this->allPropertyTariffs[ $tariff_id ] ['roomclass_uid'];
$selected_rooms_room_types [] = $booking_room_type_id;
}
}

foreach ($exList as $ex) {
$show_extra = true;

$arrival_ts = strtotime(str_replace('/', '-', $this->arrivalDate));
$validfrom_ts = strtotime($ex->validfrom);
$validto_ts = strtotime($ex->validto);

if ($ex->validfrom > '1970-01-01 00:00:01' && !is_null($ex->validfrom) && $ex->validfrom != '1999-11-30 00:00:00') { // takes into account older optional extras
if (!(($arrival_ts >= $validfrom_ts) && ($arrival_ts <= $validto_ts))) {
$show_extra = false;
}
}

// add checks for room types

if ((int) $ex->limited_to_room_type > 0 && count($selected_rooms_room_types) > 0) {
if (!in_array((int) $ex->limited_to_room_type, $selected_rooms_room_types)) {
$show_extra = false;
}
}

if (!$show_extra) {
$this->removeExtra($ex->uid);
} else {
$extra_deets[ 'UID' ] = $ex->uid;
$query = "SELECT `force`,`model` FROM #__jomcomp_extrasmodels_models WHERE extra_id = '$ex->uid'";
$model = doSelectSql($query, 2);

switch ($model[ 'model' ]) {
case '1': // Per week
$model_text = $this->sanitiseOutput(jr_gettext('_JOMRES_CUSTOMTEXT_EXTRAMODEL_PERWEEK', '_JOMRES_CUSTOMTEXT_EXTRAMODEL_PERWEEK'));
break;
case '2': // per days
$model_text = $this->sanitiseOutput(jr_gettext('_JOMRES_CUSTOMTEXT_EXTRAMODEL_PERDAYS', '_JOMRES_CUSTOMTEXT_EXTRAMODEL_PERDAYS'));
break;
case '3': // per booking
$model_text = $this->sanitiseOutput(jr_gettext('_JOMRES_CUSTOMTEXT_EXTRAMODEL_PERBOOKING', '_JOMRES_CUSTOMTEXT_EXTRAMODEL_PERBOOKING'));
break;
case '4': // per person per booking
$model_text = $this->sanitiseOutput(jr_gettext('_JOMRES_CUSTOMTEXT_EXTRAMODEL_PERPERSONPERBOOKING', '_JOMRES_CUSTOMTEXT_EXTRAMODEL_PERPERSONPERBOOKING'));
break;
case '5': // per person per day
$model_text = $this->sanitiseOutput(jr_gettext('_JOMRES_CUSTOMTEXT_EXTRAMODEL_PERPERSONPERDAY', '_JOMRES_CUSTOMTEXT_EXTRAMODEL_PERPERSONPERDAY'));
break;
case '6': // per person per week
$model_text = $this->sanitiseOutput(jr_gettext('_JOMRES_CUSTOMTEXT_EXTRAMODEL_PERPERSONPERWEEK', '_JOMRES_CUSTOMTEXT_EXTRAMODEL_PERPERSONPERWEEK'));
break;
case '7': // per person per days min days
$model_text = $this->sanitiseOutput(jr_gettext('_JOMRES_CUSTOMTEXT_EXTRAMODEL_PERDAYSMINDAYS', '_JOMRES_CUSTOMTEXT_EXTRAMODEL_PERDAYSMINDAYS'));
break;
case '8': // per days per room
$model_text = $this->sanitiseOutput(jr_gettext('_JOMRES_CUSTOMTEXT_EXTRAMODEL_PERDAYSPERROOM', '_JOMRES_CUSTOMTEXT_EXTRAMODEL_PERDAYSPERROOM'));
break;
case '9': // per room
$model_text = $this->sanitiseOutput(jr_gettext('_JOMRES_CUSTOMTEXT_EXTRAMODEL_PERROOMPERBOOKING', '_JOMRES_CUSTOMTEXT_EXTRAMODEL_PERROOMPERBOOKING'));
break;
case '100': // commission
$model_text = $this->sanitiseOutput(jr_gettext('_JOMRES_COMMISSION', '_JOMRES_COMMISSION'));
break;
}

$rate = (float) $this->taxrates[ $ex->tax_rate ][ 'rate' ];
if ($model[ 'model' ] != '100') { // Model 10 is commission, so it's a percentage.
$price = $ex->price;

if ($mrConfig[ 'prices_inclusive' ] == 1) {
$divisor = ($rate / 100) + 1;
$price = $price / $divisor;
}
$tax = ($price / 100) * $rate;
$inc_price = $price + $tax;
} else {
$inc_price = ($this->room_total / 100) * $ex->price;
$commission_rate = $ex->price;
}

$tax_output = '';
if ($rate > 0) {
$tax_output = ' ('.$rate.'%)';
}
$extra_deets[ 'NAME' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_CUSTOMTEXT_EXTRANAME'.$ex->uid, jomres_decode($ex->name)));
$extra_deets[ 'MODELTEXT' ] = $tax_output.' ( '.$model_text.' )';
if ($model[ 'model' ] != '100') {
$extra_deets[ 'PRICE' ] = output_price($inc_price);
} else {
$extra_deets[ 'PRICE' ] = output_price($inc_price).' ('.$commission_rate.'%)';
}

$extra_deets[ 'EXTRA_IMAGE' ] = $jomres_media_centre_images->multi_query_images['noimage-small'];
if (isset($jomres_media_centre_images->images['extras'][$ex->uid][0]['small'])) {
$extra_deets[ 'EXTRA_IMAGE' ] = $jomres_media_centre_images->images['extras'][$ex->uid][0]['small'];
}

if ($mrConfig[ 'wholeday_booking' ] == '1') {
if ($ex->chargabledaily == '1') {
$extra_deets[ 'PERNIGHT' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_FRONT_TARIFFS_PN_DAY_WHOLEDAY', '_JOMRES_FRONT_TARIFFS_PN_DAY_WHOLEDAY', false, true));
} else {
$extra_deets[ 'PERNIGHT' ] = '';
}
} else {
if ($ex->chargabledaily == '1') {
$extra_deets[ 'PERNIGHT' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_COM_PERDAY', '_JOMRES_COM_PERDAY', false, true));
} else {
$extra_deets[ 'PERNIGHT' ] = '';
}
}
$extra_deets[ 'DESCRIPTION' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_CUSTOMTEXT_EXTRADESC'.$ex->uid, jomres_decode($ex->desc)));

$descriptionForOverlib = jr_gettext('_JOMRES_CUSTOMTEXT_EXTRADESC'.$ex->uid, jomres_decode($ex->desc), false, true);

$extra_deets[ 'OVERLIB_DESCRIPTION' ] = $descriptionForOverlib;

$checked = '';
if ($this->extraAlreadySelected($ex->uid) || (int) $ex->auto_select == 1) {
$checked = ' checked ';
$this->setExtras($ex->uid);
$extraDefaultQuantity = $this->extrasquantities[ $ex->uid ];
} else {
$extraDefaultQuantity = 1;
}
$inputId = preg_replace('/[^A-Za-z0-9_-]+/', '', $ex->name);
if (strlen($inputId) == 0) {
$inputId = generateJomresRandomString(10);
}
$firstChar = $inputId[ 0 ]; // We'll add a simple test here to change the first char to X if the first character's actually a number, otherwise the getResponse_extras will not work.
if ($firstChar == '0' || $firstChar == '1' || $firstChar == '2' || $firstChar == '3' || $firstChar == '4' || $firstChar == '5' || $firstChar == '6' || $firstChar == '7' || $firstChar == '8' || $firstChar == '9') {
$inputId = 'X'.$inputId;
}

$clickUnlock = '';
if ($model[ 'force' ] != '1') {
$extra_deets[ 'INPUTBOX' ] = '<input id="extras_'.$ex->uid.'" type="checkbox" name="extras['.$ex->uid.']" value="'.$ex->uid.'" '.$checked.' autocomplete="off" onClick="'.$clickUnlock.'getResponse_extras(\'extras\',this.value,'.$ex->uid.');" />';
} else {
$this->forcedExtras[ ] = $ex->uid;
$this->setExtras($ex->uid);
$extra_deets[ 'INPUTBOX' ] = '<input id="extras_'.$ex->uid.'" type="checkbox" checked disabled=" " name="extras['.$ex->uid.']" value="'.$ex->uid.'" />';
}
$extra_deets[ 'FIELDNAME' ] = 'extras['.$ex->uid.']';

$extra_quantity_dropdown_disabled = ' disabled=" " ';
if ($this->extraAlreadySelected($ex->uid)) {
$extra_quantity_dropdown_disabled = ' ';
}

if ($ex->maxquantity > 1) {
$extra_deets[ 'INPUTBOX' ] =
$extra_deets[ 'INPUTBOX' ].'&nbsp;&nbsp;'.
jomresHTML::integerSelectList(01, $ex->maxquantity, 1, 'quantity'.$ex->uid, 'size="1" class="input-mini" autocomplete="off" '.$extra_quantity_dropdown_disabled.' onchange="getResponse_extrasquantity(\'extrasquantity\',this.value,'.$ex->uid.');"', $extraDefaultQuantity, '%02d', $use_bootstrap_radios = false);
}

$extra_deets[ 'AJAXFORM_EXTRAS' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_AJAXFORM_EXTRAS', '_JOMRES_AJAXFORM_EXTRAS'));
$extra_deets[ 'AJAXFORM_EXTRAS_DESC' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_AJAXFORM_EXTRAS_DESC', '_JOMRES_AJAXFORM_EXTRAS_DESC', false));
$extra_deets[ 'EXTRAS_TOTAL' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_AJAXFORM_EXTRAS_TOTAL', '_JOMRES_AJAXFORM_EXTRAS_TOTAL'));

$extra_details[ ] = $extra_deets;
}
}
}

if (count($extra_details) > 0) {
$tmpl = new patTemplate();
$tmpl->setRoot(JOMRES_TEMPLATEPATH_FRONTEND);
$tmpl->addRows('extras', $extra_details);
$tmpl->readTemplatesFromInput('dobooking_extras.html');
$extras_template = $tmpl->getParsedTemplate();
} else {
$extras_template = $this->sanitiseOutput(jr_gettext('_JOMRES_EXTRAS_NOEXTRAS', '_JOMRES_EXTRAS_NOEXTRAS'));
}

return array('core_extras' => $extras_template);
}

public function makeThirdPartyExtras($selectedProperty)
{
$third_party_extras = array();

$MiniComponents = jomres_getSingleton('mcHandler');
if ($MiniComponents->eventFileExistsCheck('05030')) {
$MiniComponents->triggerEvent('05030', $this);

$mcOutput = $MiniComponents->getAllEventPointsData('05030');

if (count($mcOutput) > 0) {
foreach ($mcOutput as $key => $val) {
$tpe = array();
$tpe[ 'THIRD_PARTY_EXTRA' ] = $val;
$third_party_extras[ ] = $tpe;
}
}
}

return array('third_party_extras' => $third_party_extras);
}

/**
* Make the Output text, put them into an array for patTemplate and return the array.
*/
public function makeOutputText()
{
$mrConfig = $this->mrConfig;

$thisJRUser = jomres_getSingleton('jr_user');

$tax_output = '';
if ($this->accommodation_tax_rate > 0) {
$tax_output = ' ('.$this->accommodation_tax_rate.'%)';
}

$output = array();
if ($mrConfig[ 'wholeday_booking' ] == '1') {
$output[ 'HARRIVALDATE' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_COM_MR_VIEWBOOKINGS_ARRIVAL_WHOLEDAY', '_JOMRES_COM_MR_VIEWBOOKINGS_ARRIVAL_WHOLEDAY'));
} else {
$output[ 'HARRIVALDATE' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_COM_MR_VIEWBOOKINGS_ARRIVAL', '_JOMRES_COM_MR_VIEWBOOKINGS_ARRIVAL'));
}
if ($mrConfig[ 'showdepartureinput' ] == '1') {
if ($mrConfig[ 'fixedPeriodBookings' ] == '1') {
$output[ 'HDEPARTUREDATE' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_FRONT_MR_FIXEDPRIOD1', '_JOMRES_FRONT_MR_FIXEDPRIOD1'));
} else {
if ($mrConfig[ 'wholeday_booking' ] == '1') {
$output[ 'HDEPARTUREDATE' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_COM_MR_VIEWBOOKINGS_DEPARTURE_WHOLEDAY', '_JOMRES_COM_MR_VIEWBOOKINGS_DEPARTURE_WHOLEDAY'));
} else {
$output[ 'HDEPARTUREDATE' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_COM_MR_VIEWBOOKINGS_DEPARTURE', '_JOMRES_COM_MR_VIEWBOOKINGS_DEPARTURE'));
}
}
} else {
$output[ 'HDEPARTUREDATE' ] = '&nbsp;';
}

$output[ 'BOOKINGHEADER' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_COM_MR_QUICKRESDESC', '_JOMRES_COM_MR_QUICKRESDESC'));
$output[ 'ADDRESSHEADER' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_COM_MR_PROPERTIESLISTING_THISPROPERTYADDRESS', '_JOMRES_COM_MR_PROPERTIESLISTING_THISPROPERTYADDRESS'));
$output[ 'HEXTITLE' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_FRONT_MR_BOOKING_EXTRAS_HELP', '_JOMRES_FRONT_MR_BOOKING_EXTRAS_HELP'));

$output[ 'REQUIREDTEXT' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_JAVASCRIPT_', '_JOMRES_JAVASCRIPT_'));
if ($mrConfig[ 'tariffChargesStoredWeeklyYesNo' ] == '0') {
if ($mrConfig[ 'wholeday_booking' ] == '1') {
$output[ 'BILLING_ROOM' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_FRONT_TARIFFS_PN_DAY_WHOLEDAY', '_JOMRES_FRONT_TARIFFS_PN_DAY_WHOLEDAY'));
} else {
$output[ 'BILLING_ROOM' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_AJAXFORM_BILLING_ROOM', '_JOMRES_AJAXFORM_BILLING_ROOM'));
}
}
$output[ 'BILLING_ROOMTOTAL' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_AJAXFORM_BILLING_ROOM_TOTAL', '_JOMRES_AJAXFORM_BILLING_ROOM_TOTAL'));
if ($mrConfig[ 'showExtras' ] == '1') {
$output[ 'BILLING_EXTRAS' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_AJAXFORM_BILLING_EXTRAS', '_JOMRES_AJAXFORM_BILLING_EXTRAS'));
}
if (get_showtime('include_room_booking_functionality')) {
$output[ 'BILLING_TAX' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_AJAXFORM_BILLING_TAX', '_JOMRES_AJAXFORM_BILLING_TAX'));
}

$output[ 'BILLING_DISCOUNT' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_AJAXFORM_BILLING_DISCOUNT', '_JOMRES_AJAXFORM_BILLING_DISCOUNT'));

$output[ 'BILLING_TOTAL' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_AJAXFORM_BILLING_TOTAL', '_JOMRES_AJAXFORM_BILLING_TOTAL'));
if ($mrConfig[ 'chargeDepositYesNo' ] == '1') {
$output[ 'DEPOSIT' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_COM_MR_EB_PAYM_DEPOSITREQUIRED', '_JOMRES_COM_MR_EB_PAYM_DEPOSITREQUIRED'));
}
//$output['CURRENCY_SYMBOL'] =$mrConfig['currency'];
$output[ 'BILLING_TOTALINPARTY' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_AJAXFORM_BILLING_TOTALINPARTY', '_JOMRES_AJAXFORM_BILLING_TOTALINPARTY'));
$output[ 'AJAXFORM_PARTICULARS' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_AJAXFORM_PARTICULARS', '_JOMRES_AJAXFORM_PARTICULARS'));
$output[ 'AJAXFORM_PARTICULARS_DESC' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_AJAXFORM_PARTICULARS_DESC', '_JOMRES_AJAXFORM_PARTICULARS_DESC'));
$output[ 'AJAXFORM_AVAILABLE' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_AJAXFORM_AVAILABLE', '_JOMRES_AJAXFORM_AVAILABLE'));
if ($thisJRUser->is_partner) {
$output[ 'AJAXFORM_ADDRESS' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_PARTNERS_GUEST_ADDRESS', '_JOMRES_PARTNERS_GUEST_ADDRESS'));
} else {
$output[ 'AJAXFORM_ADDRESS' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_AJAXFORM_ADDRESS', '_JOMRES_AJAXFORM_ADDRESS'));
}
$output[ 'AJAXFORM_ADDRESS_DESC' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_AJAXFORM_ADDRESS_DESC', '_JOMRES_AJAXFORM_ADDRESS_DESC', false));
$output[ 'AJAXFORM_AVAILABLEROOMS' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_AJAXFORM_AVAILABLEROOMS', '_JOMRES_AJAXFORM_AVAILABLEROOMS'));
$output[ 'AJAXFORM_SELECTEDROOMS' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_AJAXFORM_SELECTEDROOMS', '_JOMRES_AJAXFORM_SELECTEDROOMS', false));

if ($mrConfig[ 'singleRoomProperty' ] == '0') {
$output[ 'AJAXFORM_AVAILABLEROOMS' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_AJAXFORM_AVAILABLEROOMS', '_JOMRES_AJAXFORM_AVAILABLEROOMS'));
$output[ 'AJAXFORM_SELECTEDROOMS' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_AJAXFORM_SELECTEDROOMS', '_JOMRES_AJAXFORM_SELECTEDROOMS', false));
$output[ 'AJAXFORM_AVAILABLE_DESC' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_AJAXFORM_AVAILABLE_DESC', '_JOMRES_AJAXFORM_AVAILABLE_DESC', false));
$output[ 'AJAXFORM_INSTRUCTIONS' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_AJAXFORM_INSTRUCTIONS', '_JOMRES_AJAXFORM_INSTRUCTIONS'));
} else {
$output[ 'AJAXFORM_AVAILABLEROOMS' ] = '';
$output[ 'AJAXFORM_SELECTEDROOMS' ] = '';
$output[ 'AJAXFORM_AVAILABLE_DESC' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_AJAXFORM_AVAILABLE_DESC_SRP', '_JOMRES_AJAXFORM_AVAILABLE_DESC_SRP', false));
$output[ 'AJAXFORM_INSTRUCTIONS' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_AJAXFORM_INSTRUCTIONS_SRP', '_JOMRES_AJAXFORM_INSTRUCTIONS_SRP'));
}

$output[ 'ACCOMMODATION_TOTAL' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_AJAXFORM_ACCOMMODATION_TOTAL', '_JOMRES_AJAXFORM_ACCOMMODATION_TOTAL')).$tax_output;

switch ($this->cfg_booking_form_daily_weekly_monthly) {
case 'D':
if ($mrConfig[ 'wholeday_booking' ] == '1') {
$output[ 'ACCOMMODATION_NIGHTS' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_AJAXFORM_ACCOMMODATION_NIGHTS_WHOLEDAY', '_JOMRES_AJAXFORM_ACCOMMODATION_NIGHTS_WHOLEDAY'));
} else {
$output[ 'ACCOMMODATION_NIGHTS' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_AJAXFORM_ACCOMMODATION_NIGHTS', '_JOMRES_AJAXFORM_ACCOMMODATION_NIGHTS'));
}
break;
case 'W':
$output[ 'ACCOMMODATION_NIGHTS' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_AJAXFORM_ACCOMMODATION_WEEKS', '_JOMRES_AJAXFORM_ACCOMMODATION_WEEKS'));
break;
case 'M':
$output[ 'ACCOMMODATION_NIGHTS' ] = $this->sanitiseOutput(jr_gettext('_JOMRES_AJAXFORM_ACCOMMODATION_MONTHS', '_JOMRES_AJAXFORM_ACCOMMODATION_MONTHS'));
brea
Bovenstaande lap code bevat niet de publieke functie / methode calcDeposit en is dus niet relevant voor wat je wilt/probeert te doen.
Oeps. Methode 'calcDeposit' zit niet in de geplakt 1249 regels.

Verder: "It is not designed to be implemented or called directly. Instead it is called by the j05000bookingobject.class.php file which inherits from this file."

Zo, subclass 'dobooking' en override 'calcDeposit'.

Reageren