Merge branch 'develop' into gli-2241-2

This commit is contained in:
Shreesh Arora
2024-08-29 16:24:46 +05:30
204 changed files with 7042 additions and 5285 deletions

View File

@@ -149,13 +149,16 @@ class AddressCore extends ObjectModel
protected $webserviceParameters = array(
'objectsNodeName' => 'addresses',
'fields' => array(
'id_customer' => array('xlink_resource'=> 'customers'),
'id_customer' => array('xlink_resource'=> 'customers', 'required' => true),
'id_manufacturer' => array('xlink_resource'=> 'manufacturers'),
'id_supplier' => array('xlink_resource'=> 'suppliers'),
'id_warehouse' => array('xlink_resource'=> 'warehouse'),
'id_country' => array('xlink_resource'=> 'countries'),
'id_state' => array('xlink_resource'=> 'states'),
),
'hidden_fields' => array(
'id_hotel'
),
);
/**
@@ -551,4 +554,37 @@ class AddressCore extends ObjectModel
)
');
}
public function validateFields($die = true, $error_return = false)
{
if (isset($this->webservice_validation) && $this->webservice_validation) {
if (!$this->id_customer || !Validate::isLoadedObject(new Customer((int) $this->id_customer))) {
$message = Tools::displayError('Invalid Id customer.');
} elseif (Customer::getCustomerIdAddress($this->id_customer, false) && !$this->id) {
$message = Tools::displayError('A single customer cannot have multiple addresses.');
} elseif (!$this->id_country || !Validate::isLoadedObject($objCountry = new Country($this->id_country))) {
$message = Tools::displayError('Invalid Id country');
} elseif ($objCountry->contains_states
&& (!$this->id_state || !Validate::isLoadedObject($objState = new State((int) $this->id_state)))
) {
$message = Tools::displayError('Invalid Id state');
} elseif (isset($objState) && ($objCountry->id != $objState->id_country)) {
$message = Tools::displayError('The given provided Id state does not belongs to the provided Id country');
} elseif ($objCountry->zip_code_format && !$objCountry->checkZipCode($this->postcode)) {
$message = Tools::displayError('Your Zip/postal code is incorrect');
} elseif (empty($this->postcode) && $objCountry->need_zip_code) {
$message = Tools::displayError('A Zip/postal code is required.');
} elseif ($this->postcode && !Validate::isPostCode($this->postcode)) {
$message = Tools::displayError('The Zip/postal code is invalid.');
}
if (isset($message)) {
if ($die) {
throw new PrestaShopException($message);
}
return $error_return ? $message : false;
}
}
return parent::validateFields($die, $error_return);
}
}

View File

@@ -1078,8 +1078,6 @@ class CartCore extends ObjectModel
if (Context::getContext()->customer->id) {
if ($id_address_delivery == 0 && (int)$this->id_address_delivery) { // The $id_address_delivery is null, use the cart delivery address
$id_address_delivery = $this->id_address_delivery;
} elseif ($id_address_delivery == 0) { // The $id_address_delivery is null, get the default customer address
$id_address_delivery = (int)Address::getFirstCustomerAddressId((int)Context::getContext()->customer->id);
} elseif (!Customer::customerHasAddress(Context::getContext()->customer->id, $id_address_delivery)) { // The $id_address_delivery must be linked with customer
$id_address_delivery = 0;
}
@@ -4109,7 +4107,7 @@ class CartCore extends ObjectModel
$cart->id_shop_group = $this->id_shop_group;
if (!Customer::customerHasAddress((int)$cart->id_customer, (int)$cart->id_address_delivery)) {
$cart->id_address_delivery = (int)Address::getFirstCustomerAddressId((int)$cart->id_customer);
$cart->id_address_delivery = 0;
}
if (!Customer::customerHasAddress((int)$cart->id_customer, (int)$cart->id_address_invoice)) {
@@ -4501,11 +4499,9 @@ class CartCore extends ObjectModel
public function autosetProductAddress()
{
$id_address_delivery = 0;
// Get the main address of the customer
if ((int)$this->id_address_delivery > 0) {
$id_address_delivery = (int)$this->id_address_delivery;
} else {
$id_address_delivery = (int)Address::getFirstCustomerAddressId(Context::getContext()->customer->id);
}
if (!$id_address_delivery) {
@@ -4702,7 +4698,7 @@ class CartCore extends ObjectModel
public function getWsCartBookings()
{
return Db::getInstance()->executeS('
SELECT `id`
SELECT `id`, `date_from`, `date_to`, `id_hotel`, `id_product`
FROM `'._DB_PREFIX_.'htl_cart_booking_data`
WHERE id_cart = '.(int)$this->id.' ORDER BY `id` ASC'
);

View File

@@ -63,6 +63,45 @@ class CartCustomerGuestDetailCore extends ObjectModel
);
}
public static function getCustomerDefaultDetails($email)
{
return Db::getInstance()->getRow(
'SELECT * FROM `'._DB_PREFIX_.'cart_customer_guest_detail`
WHERE `id_cart` = 0 AND `email` = "'.pSQL($email).'"'
);
}
public static function updateCustomerPhoneNumber($email, $phone)
{
if ($customerDetail = self::getCustomerDefaultDetails($email)) {
$objCartCustomerGuestDetail = new CartCustomerGuestDetail($customerDetail['id_customer_guest_detail']);
$objCartCustomerGuestDetail->phone = $phone;
return $objCartCustomerGuestDetail->save();
} else {
$objCustomer = new Customer();
if (Validate::isLoadedObject($customer = $objCustomer->getByEmail($email, null, false))) {
$objCartCustomerGuestDetail = new CartCustomerGuestDetail();
$objCartCustomerGuestDetail->id_cart = 0;
$objCartCustomerGuestDetail->id_gender = $customer->id_gender;
$objCartCustomerGuestDetail->firstname = $customer->firstname;
$objCartCustomerGuestDetail->lastname = $customer->lastname;
$objCartCustomerGuestDetail->email = $customer->email;
$objCartCustomerGuestDetail->phone = $phone;
return $objCartCustomerGuestDetail->save();
}
}
return false;
}
public static function getCustomerPhone($email)
{
return Db::getInstance()->getValue(
'SELECT `phone` FROM `'._DB_PREFIX_.'cart_customer_guest_detail`
WHERE `id_cart` = 0 AND `email` = "'.pSQL($email).'"'
);
}
public function validateGuestInfo()
{
$isValid = true;

View File

@@ -72,6 +72,9 @@ class CartRuleCore extends ObjectModel
public $date_add;
public $date_upd;
const GENERATED_BY_REFUND = 1;
const GENERATED_BY_ORDER_SLIP = 2;
/**
* @see ObjectModel::$definition
*/
@@ -407,6 +410,8 @@ class CartRuleCore extends ObjectModel
}
unset($cart_rule);
Hook::exec('actionCustomerCartRulesModifier', array('cart_rules' => &$result, 'id_customer' => (int)$id_customer));
return $result;
}
@@ -515,6 +520,38 @@ class CartRuleCore extends ObjectModel
return false;
}
/*
* If null is provided, default validation will be processed. Useful if you want your own conditions,
* but also want to retain functionality of the core.
*
* If true is provided, the validation ends here and the rule is VALID, ignoring the rest of core validation.
*
* If false is provided, the validation ends here and the rule is not VALID, ignoring the rest of core validation.
* In this case, it's recommended to properly alter the isValidatedByModulesError error message so the user knows why.
*/
$isValidatedByModules = null;
$isValidatedByModulesError = Tools::displayError('This voucher is not valid.');
Hook::exec(
'actionValidateCartRule',
array(
'cart_rule' => $this,
'context' => $context,
'alreadyInCart' => $alreadyInCart,
'display_error' => $display_error,
'check_carrier' => $check_carrier,
'isValidatedByModules' => &$isValidatedByModules,
'isValidatedByModulesError' => &$isValidatedByModulesError,
)
);
if ($isValidatedByModules === false) {
return (!$display_error) ? false : $isValidatedByModulesError;
}
if ($isValidatedByModules === true) {
return (!$display_error) ? true : null;
}
if (!$this->active) {
return (!$display_error) ? false : Tools::displayError('This voucher is disabled');
}
@@ -909,7 +946,7 @@ class CartRuleCore extends ObjectModel
$reduction_value = 0;
$objHotelAdvancePayment = new HotelAdvancedPayment();
$cache_id = 'getContextualValue_'.(int)$this->id.'_'.(int)$use_tax.'_'.(int)$context->cart->id.'_'.(int)$filter.'_'.(int)$only_advance_payment_products;
$cache_id = 'getContextualValue_'.(int)$this->id.'_'.(int)$use_tax.'_'.(int)$context->cart->id.'_'.(int)$context->currency->id.'_'.(int)$filter.'_'.(int)$only_advance_payment_products;
foreach ($package['products'] as $key => $product) {
if ($only_advance_payment_products) {
if ($advancePaymentInfo = $objHotelAdvancePayment->getIdAdvPaymentByIdProduct($product['id_product'])) {
@@ -1498,4 +1535,25 @@ class CartRuleCore extends ObjectModel
return Db::getInstance()->executeS($sql_base.' AND code LIKE \'%'.pSQL($name).'%\'');
}
}
public static function getGeneratedBy($id)
{
if (!$id) {
return false;
}
$response = array();
$sql = 'SELECT `id_order_slip` FROM '._DB_PREFIX_.'order_slip os
WHERE os.`id_cart_rule` = '.(int)$id;
if ($result = Db::getInstance()->getValue($sql)) {
$response['generated_by'] = self::GENERATED_BY_ORDER_SLIP;
$response['id_generated_by'] = $result;
}
$sql = 'SELECT `id_order_return` FROM '._DB_PREFIX_.'order_return o
WHERE o.`return_type` = '.OrderReturn::RETURN_TYPE_CART_RULE.' AND o.`id_return_type` = '.(int)$id;
if ($result = Db::getInstance()->getValue($sql)) {
$response['generated_by'] = self::GENERATED_BY_REFUND;
$response['id_generated_by'] = $result;
}
return $response;
}
}

View File

@@ -326,8 +326,6 @@ class ContextCore
$this->cart->setDeliveryOption(null);
}
$this->cart->id_customer = (int) $customer->id;
$this->cart->updateAddressId($this->cart->id_address_delivery, (int) Address::getFirstCustomerAddressId((int) ($customer->id)));
$this->cart->id_address_delivery = (int) Address::getFirstCustomerAddressId((int) ($customer->id));
$this->cart->id_address_invoice = (int) Address::getFirstCustomerAddressId((int) ($customer->id));
// update id guest in htl_cart_booking_data for bookings added to the cart as a visitor

View File

@@ -135,6 +135,8 @@ class CustomerCore extends ObjectModel
public $groupBox;
public $phone;
const STATUS_BANNED = 1;
const STATUS_DELETED = 2;
@@ -202,6 +204,10 @@ class CustomerCore extends ObjectModel
{
$this->id_default_group = (int)Configuration::get('PS_CUSTOMER_GROUP');
parent::__construct($id);
if ($this->email) {
$this->phone = CartCustomerGuestDetail::getCustomerPhone($this->email);
}
}
public function add($autodate = true, $null_values = true)
@@ -484,6 +490,18 @@ class CustomerCore extends ObjectModel
return Cache::retrieve($cache_id);
}
public static function getPhone($id_customer)
{
return Db::getInstance()->getValue(
'SELECT cgd.`phone`
FROM `'._DB_PREFIX_.'customer` c
INNER JOIN `'._DB_PREFIX_.'cart_customer_guest_detail` cgd
ON (cgd.`email` = c.`email`)
WHERE `id_cart` = 0 AND c.`id_customer` = '.(int)($id_customer)
);
}
public static function getCustomerIdAddress($id_customer, $use_cache = true)
{
$cache_id = 'Customer::getCustomerIdAddress'.(int)$id_customer;

View File

@@ -141,4 +141,12 @@ class CustomerMessageCore extends ObjectModel
');
}
public function validateFields($die = true, $error_return = false)
{
if (isset($this->webservice_validation) && $this->webservice_validation) {
$this->message = trim($this->message);
}
return parent::validateFields($die, $error_return);
}
}

View File

@@ -173,9 +173,18 @@ class GuestCore extends ObjectModel
public function mergeWithCustomer($idGuest, $idCustomer)
{
// Since the guests are merged, the guest id in the connections table must be changed too
Db::getInstance()->update('connections', [
'id_guest' => (int) $idGuest,
], 'id_guest = ' . (int) $this->id);
// If guest entry is already there in the connection within 30 mins then delete the visitor entry else update it with guest id of the customer
$sql = 'SELECT SQL_NO_CACHE `id_guest` FROM `'._DB_PREFIX_.'connections`
WHERE `id_guest` = '.(int)$idGuest.' AND `date_add` > \''.pSQL(date('Y-m-d H:i:00', time() - 1800)).'\''.
Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).' ORDER BY `date_add` DESC';
if (Db::getInstance()->getRow($sql, false)) {
Db::getInstance()->delete('connections', 'id_guest = ' . (int) $this->id);
} else {
Db::getInstance()->update('connections', [
'id_guest' => (int) $idGuest,
], 'id_guest = ' . (int) $this->id);
}
// Since the guests are merged, the guest id in the cart table must be changed too
Db::getInstance()->update('cart', [
@@ -198,4 +207,21 @@ class GuestCore extends ObjectModel
$guest->save();
$cookie->id_guest = (int)($guest->id);
}
public function validateFields($die = true, $error_return = false)
{
if (isset($this->webservice_validation) && $this->webservice_validation) {
if ((int) $this->id_customer && !Validate::isLoadedObject(new Customer((int) $this->id_customer))) {
$message = Tools::displayError('Invalid Id customer.');
}
if (isset($message)) {
if ($die) {
throw new PrestaShopException($message);
}
return $error_return ? $message : false;
}
}
return parent::validateFields($die, $error_return);
}
}

View File

@@ -1163,16 +1163,6 @@ abstract class PaymentModuleCore extends Module
$this->context->currency,
false
),
'{delivery_block_txt}' => $this->_getFormatedAddress($delivery, "\n"),
'{invoice_block_txt}' => $this->_getFormatedAddress($invoice, "\n"),
'{delivery_block_html}' => $this->_getFormatedAddress($delivery, '<br />', array(
'firstname' => '<span style="font-weight:bold;">%s</span>',
'lastname' => '<span style="font-weight:bold;">%s</span>'
)),
'{invoice_block_html}' => $this->_getFormatedAddress($invoice, '<br />', array(
'firstname' => '<span style="font-weight:bold;">%s</span>',
'lastname' => '<span style="font-weight:bold;">%s</span>'
)),
'{delivery_company}' => $delivery->company,
'{delivery_firstname}' => $delivery->firstname,
'{delivery_lastname}' => $delivery->lastname,
@@ -1650,8 +1640,6 @@ abstract class PaymentModuleCore extends Module
$objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail();
$result['total_extra_demands_te'] = 0;
$result['total_extra_demands_ti'] = 0;
$result['total_additional_services_te'] =0;
$result['total_additional_services_ti'] =0;
$cart_htl_data = array();
if (!empty($products)) {
foreach ($products as $type_key => $type_value) {
@@ -1697,67 +1685,12 @@ abstract class PaymentModuleCore extends Module
$cart_htl_data[$type_key]['date_diff'][$date_join]['amount'] = $roomTypeDateRangePrice['total_price_tax_incl']*$vart_quant;
// extra demands prices
$cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands'] = $objBookingDemand->getRoomTypeBookingExtraDemands(
$order->id,
$type_value['product_id'],
0,
$data_v['date_from'],
$data_v['date_to']
);
$cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands_price_te'] = $objBookingDemand->getRoomTypeBookingExtraDemands(
$order->id,
$type_value['product_id'],
0,
$data_v['date_from'],
$data_v['date_to'],
0,
1,
0
);
$cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'] = $objBookingDemand->getRoomTypeBookingExtraDemands(
$order->id,
$type_value['product_id'],
0,
$data_v['date_from'],
$data_v['date_to'],
0,
1,
1
);
$cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
$order->id,
0,
0,
$type_value['product_id'],
$data_v['date_from'],
$data_v['date_to'],
$data_v['id_room'],
1,
1,
1,
Product::PRICE_ADDITION_TYPE_WITH_ROOM
);
$cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
$order->id,
0,
0,
$type_value['product_id'],
$data_v['date_from'],
$data_v['date_to'],
$data_v['id_room'],
1,
0,
1,
Product::PRICE_ADDITION_TYPE_WITH_ROOM
);
$cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days;
$cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days;
$cart_htl_data[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_incl'] += ($cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] + $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti']);
$cart_htl_data[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_excl'] += ($cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] + $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te']);
$cart_htl_data[$type_key]['date_diff'][$date_join]['amount_tax_incl'] += ($data_v['total_price_tax_incl'] + $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te']);
$cart_htl_data[$type_key]['date_diff'][$date_join]['amount_tax_excl'] += ($data_v['total_price_tax_excl'] + $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te']);
$cart_htl_data[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_incl'] += $cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'];
$cart_htl_data[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_excl'] += $cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'];
$cart_htl_data[$type_key]['date_diff'][$date_join]['amount_tax_incl'] += $data_v['total_price_tax_incl'];
$cart_htl_data[$type_key]['date_diff'][$date_join]['amount_tax_excl'] += $data_v['total_price_tax_excl'];
} else {
$num_days = $obj_htl_bk_dtl->getNumberOfDays($data_v['date_from'], $data_v['date_to']);
@@ -1809,28 +1742,6 @@ abstract class PaymentModuleCore extends Module
$data_v['date_from'],
$data_v['date_to']
);
$cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_ti'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
$order->id,
0,
0,
$type_value['product_id'],
$data_v['date_from'],
$data_v['date_to'],
$data_v['id_room'],
1,
1
);
$cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_te'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
$order->id,
0,
0,
$type_value['product_id'],
$data_v['date_from'],
$data_v['date_to'],
$data_v['id_room'],
1,
0
);
$cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
$order->id,
0,
@@ -1838,7 +1749,7 @@ abstract class PaymentModuleCore extends Module
$type_value['product_id'],
$data_v['date_from'],
$data_v['date_to'],
$data_v['id_room'],
0,
1,
1,
1,
@@ -1851,7 +1762,7 @@ abstract class PaymentModuleCore extends Module
$type_value['product_id'],
$data_v['date_from'],
$data_v['date_to'],
$data_v['id_room'],
0,
1,
0,
1,
@@ -1867,8 +1778,6 @@ abstract class PaymentModuleCore extends Module
$result['total_extra_demands_te'] += $cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands_price_te'];
$result['total_extra_demands_ti'] += $cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'];
$result['total_additional_services_te'] += $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_te'];
$result['total_additional_services_ti'] += $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_ti'];
}
}
// calculate averages now

View File

@@ -373,36 +373,22 @@ class ProductCore extends ObjectModel
protected $webserviceParameters = array(
'objectMethods' => array(
'add' => 'addWs',
'update' => 'updateWs',
'add' => 'addWsRoomType',
'update' => 'updateWsRoomType',
'delete' => 'deleteWs'
),
'objectsNodeName' => 'room_types',
'objectNodeName' => 'room_type',
'retrieveData' => array(
'retrieveMethod' => 'getRoomTypesObjectList'
),
'fields' => array(
'id_hotel' => array(
'getter' => 'getWsHotel',
'setter' => 'setWsHotel',
'xlink_resource' => 'hotels'
),
'adults' => array(
'getter' => 'getWsAdults',
'setter' => 'setWsAdults',
),
'children' => array(
'getter' => 'getWsChildren',
'setter' => 'setWsChildren',
),
'id_manufacturer' => array(
'xlink_resource' => 'manufacturers'
),
'id_supplier' => array(
'xlink_resource' => 'suppliers'
),
'id_category_default' => array(
'xlink_resource' => 'categories'
),
'id_hotel' => array('getter' => 'getWsHotel','setter' => 'setWsHotel', 'xlink_resource' => 'hotels'),
'adults' => array('getter' => 'getWsAdults','setter' => 'setWsAdults'),
'children' => array('getter' => 'getWsChildren','setter' => 'setWsChildren'),
'id_manufacturer' => array('xlink_resource' => 'manufacturers'),
'id_supplier' => array('xlink_resource' => 'suppliers'),
'id_category_default' => array('xlink_resource' => 'categories'),
'new' => array(),
'cache_default_attribute' => array(),
'id_default_image' => array(
@@ -420,36 +406,28 @@ class ProductCore extends ObjectModel
// 'resourceName' => 'combinations'
// )
// ),
'id_tax_rules_group' => array(
'xlink_resource' => array(
'resourceName' => 'tax_rule_groups'
)
),
'position_in_category' => array(
'getter' => 'getWsPositionInCategory',
'setter' => 'setWsPositionInCategory'
),
'id_tax_rules_group' => array('xlink_resource' => array('resourceName' => 'tax_rule_groups')),
'position_in_category' => array('getter' => 'getWsPositionInCategory', 'setter' => 'setWsPositionInCategory'),
// 'manufacturer_name' => array(
// 'getter' => 'getWsManufacturerName',
// 'setter' => false
// ),
'quantity' => array(
'getter' => false,
'setter' => false
),
'type' => array(
'getter' => 'getWsType',
'setter' => 'setWsType',
),
'id_advance_paypent' => array(
'xlink_resource' => array(
'resourceName' => 'advance_payments'
),
'getter' => 'getWsRoomTypeAdvancePayment',
'setter' => false
),
'type' => array('getter' => 'getWsType', 'setter' => 'setWsType'),
),
'associations' => array(
'advance_payments' => array(
'resource' => 'advance_payment',
'getter' => 'getWsAdvancePayments',
'setter' => 'setWsAdvancePayments',
'fields' => array(
'id' => array(),
'payment_type' => array(),
'tax_include' => array(),
'value' => array(),
'active' => array(),
'calculate_from' => array(),
),
),
'categories' => array(
'resource' => 'category',
'fields' => array(
@@ -466,7 +444,8 @@ class ProductCore extends ObjectModel
'id' => array('required' => true),
)
),
'tags' => array('resource' => 'tag',
'tags' => array(
'resource' => 'tag',
'fields' => array(
'id' => array('required' => true),
)
@@ -484,13 +463,78 @@ class ProductCore extends ObjectModel
)
),
'extra_demands' => array(
'setter' => false,
'resource' => 'extra_demand',
'fields' => array(
'id' => array('required' => true),
'id_option' => array(),
'price' => array(),
)
),
'services' => array(
'resource' => 'service',
'fields' => array(
'id' => array('validate' => 'isUnsignedId', 'required' => true),
'price' => array('validate' => 'isPrice', 'required' => true),
'id_tax_rules_group' => array('validate' => 'isUnsignedId')
)
),
),
'hidden_fields' => array(
'booking_product',
'service_product_type'
),
);
protected $webserviceServicesParameters = array(
'objectMethods' => array(
'add' => 'addWsServices',
'update' => 'updateWsServices',
'delete' => 'deleteWs'
),
'objectsNodeName' => 'services',
'objectNodeName' => 'service',
'retrieveData' => array(
'retrieveMethod' => 'getServicesObjectList'
),
'fields' => array(
'id_manufacturer' => array('xlink_resource' => 'manufacturers'),
'id_supplier' => array('xlink_resource' => 'suppliers'),
'id_category_default' => array('xlink_resource' => 'categories'),
'new' => array(),
'cache_default_attribute' => array(),
'id_default_image' => array(
'getter' => 'getCoverWs',
'setter' => 'setCoverWs',
'xlink_resource' => array(
'resourceName' => 'images',
'subResourceName' => 'room_types'
)
),
'id_tax_rules_group' => array('xlink_resource' => array('resourceName' => 'tax_rule_groups')),
'position_in_category' => array('getter' => 'getWsPositionInCategory', 'setter' => 'setWsPositionInCategory'),
// 'manufacturer_name' => array(
// 'getter' => 'getWsManufacturerName',
// 'setter' => false
// ),
'quantity' => array('getter' => false, 'setter' => false),
'type' => array('getter' => 'getWsType', 'setter' => 'setWsType'),
),
'associations' => array(
'categories' => array(
'resource' => 'category',
'fields' => array('id' => array('required' => true))
),
'images' => array('resource' => 'image', 'fields' => array('id' => array())),
'feature_prices' => array(
'setter' => false, 'resource' => 'feature_price',
'fields' => array(
'id' => array('required' => true),
)
),
),
'hidden_fields' => array(
'booking_product',
),
);
const CUSTOMIZE_FILE = 0;
@@ -5709,8 +5753,11 @@ class ProductCore extends ObjectModel
*/
public function getCoverWs()
{
$result = $this->getCover($this->id);
return $result['id_image'];
if ($result = $this->getCover($this->id)) {
return $result['id_image'];
}
return false;
}
/**
@@ -5999,8 +6046,9 @@ class ProductCore extends ObjectModel
return true;
}
public function addWs($autodate = true, $null_values = false)
public function addWsRoomType($autodate = true, $null_values = false)
{
$this->booking_product = 1;
if ($success = $this->add($autodate, $null_values)) {
if (Configuration::get('PS_SEARCH_INDEXATION')) {
Search::indexation(false, $this->id);
@@ -6012,19 +6060,56 @@ class ProductCore extends ObjectModel
return $success;
}
public function updateWs($null_values = false)
public function updateWsRoomType($null_values = false)
{
$success = parent::update($null_values);
if ($success && Configuration::get('PS_SEARCH_INDEXATION')) {
Search::indexation(false, $this->id);
if (self::isBookingProduct($this->id)) {
$this->booking_product = 1; // Since there is nothing set from the API, it might get set as false
$success = parent::update($null_values);
if ($success && Configuration::get('PS_SEARCH_INDEXATION')) {
Search::indexation(false, $this->id);
}
$this->setWsRoomTypeInfo();
Hook::exec('updateProduct', array('id_product' => (int)$this->id));
return $success;
}
$this->setWsRoomTypeInfo();
WebserviceRequest::getInstance()->setError(500, Tools::displayError('Room type not found.'), 134);
return false;
}
public function addWsServices()
{
$this->booking_product = 0;
if ($success = $this->add()) {
if (Configuration::get('PS_SEARCH_INDEXATION')) {
Search::indexation(false, $this->id);
}
}
Hook::exec('updateProduct', array('id_product' => (int)$this->id));
return $success;
}
public function updateWsServices($null_values = false)
{
if (!self::isBookingProduct($this->id)) {
$this->booking_product = 0; // Since there is nothing set from the API.
$success = parent::update($null_values);
if ($success && Configuration::get('PS_SEARCH_INDEXATION')) {
Search::indexation(false, $this->id);
}
Hook::exec('updateProduct', array('id_product' => (int)$this->id));
return $success;
}
WebserviceRequest::getInstance()->setError(500, Tools::displayError('Service not found.'), 134);
return false;
}
/**
* For a given product, returns its real quantity
*
@@ -6384,6 +6469,20 @@ class ProductCore extends ObjectModel
return $cache_id;
}
public function getRoomTypesObjectList($sql_join, $sql_filter, $sql_sort, $sql_limit)
{
$sql_filter .= ' AND main.`booking_product` = 1';
return parent::getWebserviceObjectList($sql_join, $sql_filter, $sql_sort, $sql_limit);
}
public function getServicesObjectList($sql_join, $sql_filter, $sql_sort, $sql_limit)
{
$sql_filter .= ' AND main.`booking_product` = 0';
return parent::getWebserviceObjectList($sql_join, $sql_filter, $sql_sort, $sql_limit);
}
public static function setPackStockType($id_product, $pack_stock_type)
{
return Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'product p
@@ -6408,10 +6507,55 @@ class ProductCore extends ObjectModel
public function getWsAdvancePayments()
{
return Db::getInstance()->executeS(
'SELECT `id` FROM `'._DB_PREFIX_.'htl_advance_payment` WHERE `id_product` = '.(int)$this->id.' ORDER BY `id` ASC'
'SELECT * FROM `'._DB_PREFIX_.'htl_advance_payment` WHERE `id_product` = '.(int)$this->id.' ORDER BY `id` ASC'
);
}
public function setWsAdvancePayments($adv_payment)
{
$obj_adv_pmt = new HotelAdvancedPayment();
if (!$adv_payment) {
if ($adv_pmt_info = $obj_adv_pmt->getIdAdvPaymentByIdProduct($this->id)) {
$obj_adv_pmt = new HotelAdvancedPayment((int) $adv_pmt_info['id']);
}
$obj_adv_pmt->payment_type = '';
$obj_adv_pmt->id_product = $this->id;
$obj_adv_pmt->value = '';
$obj_adv_pmt->id_currency = '';
$obj_adv_pmt->tax_include = '';
$obj_adv_pmt->calculate_from = 0;
$obj_adv_pmt->active = 0;
return $obj_adv_pmt->save();
} else if (is_array($adv_payment) && count($adv_payment) == 1) {
$fields = array_shift($adv_payment);
if (!Validate::isLoadedObject($obj_adv_pmt = new HotelAdvancedPayment($fields['id']))) {
if ($adv_pmt_info = $obj_adv_pmt->getIdAdvPaymentByIdProduct($this->id)) {
$obj_adv_pmt = new HotelAdvancedPayment((int) $adv_pmt_info['id']);
}
}
$obj_adv_pmt->id_product = $this->id;
$obj_adv_pmt->active = 1;
$obj_adv_pmt->payment_type = $fields['payment_type'];
$obj_adv_pmt->value = $fields['value'];
if ($fields['payment_type'] == 2) {
$obj_adv_pmt->id_currency = (int) Configuration::get('PS_CURRENCY_DEFAULT');
} else {
$obj_adv_pmt->id_currency = '';
}
$obj_adv_pmt->tax_include = $fields['tax_include'];
$obj_adv_pmt->calculate_from = $fields['calculate_from'];
return $obj_adv_pmt->save();
}
return false;
}
public function getWsHotel()
{
return Db::getInstance()->getValue(
@@ -6435,8 +6579,41 @@ class ProductCore extends ObjectModel
public function getWsExtraDemands()
{
return Db::getInstance()->getValue(
'SELECT `id_global_demand` as `id` FROM `'._DB_PREFIX_.'htl_room_type_demand` WHERE `id_product` = '.(int)$this->id
$objHotelRoomTypeDemand = new HotelRoomTypeDemand();
$selectedDemands = Db::getInstance()->executeS(
'SELECT `id_global_demand` as `id` FROM `'._DB_PREFIX_.'htl_room_type_demand`
WHERE `id_product` = '.(int)$this->id
);
$res = array();
$demands = $objHotelRoomTypeDemand->getRoomTypeDemands($this->id);
if ($selectedDemands) {
foreach ($selectedDemands as $id_demand => $demand) {
$option['id'] = $demand['id'];
if (isset($demands[$demand['id']]['adv_option']) && count($demands[$demand['id']]['adv_option'])) {
foreach ($demands[$demand['id']]['adv_option'] as $id_option => $adv_option) {
$option['id_option'] = $id_option;
$option['price'] = $adv_option['price_tax_excl'];
$res[] = $option;
}
} else {
$option['id_option'] = false;
$option['price'] = $demand['price_tax_excl'];
$res[] = $option;
}
}
}
return $res;
}
public function getWsServices()
{
return Db::getInstance()->executeS(
'SELECT spp.`price`, spp.`id_tax_rules_group`, sp.`id_product` AS id
FROM `'._DB_PREFIX_.'htl_room_type_service_product` sp
LEFT JOIN `'._DB_PREFIX_.'htl_room_type_service_product_price` spp
ON (spp.`id_product` = sp.`id_product` AND spp.`id_element` = sp.`id_element` AND spp.`element_type` = sp.`element_type`)
WHERE sp.`id_element` = '.(int)$this->id
);
}
@@ -6490,4 +6667,106 @@ class ProductCore extends ObjectModel
{
return $this->delete();
}
public function setWsExtraDemands($demands)
{
Db::getInstance()->execute('
DELETE FROM `'._DB_PREFIX_.'htl_room_type_demand`
WHERE `id_product` = '.(int)$this->id
);
Db::getInstance()->execute('
DELETE FROM `'._DB_PREFIX_.'htl_room_type_demand_price`
WHERE `id_product` = '.(int)$this->id
);
$objAdvOption = new HotelRoomTypeGlobalDemandAdvanceOption();
$savedDemands = array();
foreach ($demands as $globalDemand) {
if (Validate::isLoadedObject($objGlobalDemand = new HotelRoomTypeGlobalDemand($globalDemand['id']))) {
if (!isset($savedDemands[$globalDemand['id']])) {
$objRoomTypeDemand = new HotelRoomTypeDemand();
$objRoomTypeDemand->id_product = $this->id;
$objRoomTypeDemand->id_global_demand = $objGlobalDemand->id;
$objRoomTypeDemand->save();
$savedDemands[$globalDemand['id']] = $objRoomTypeDemand->id;
}
if (isset($globalDemand['price'])) {
if ($objAdvOption->getGlobalDemandAdvanceOptions($objGlobalDemand->id)
&& isset($globalDemand['id_option'])
&& Validate::isLoadedObject($objAdvOption = new HotelRoomTypeGlobalDemandAdvanceOption($globalDemand['id_option']))
) {
if ($globalDemand['price'] != $objAdvOption->price) {
$objRoomTypeDemandPrice = new HotelRoomTypeDemandPrice();
$objRoomTypeDemandPrice->id_product = $this->id;
$objRoomTypeDemandPrice->id_global_demand = $objGlobalDemand->id;
$objRoomTypeDemandPrice->id_option = $objAdvOption->id;
$objRoomTypeDemandPrice->price = $globalDemand['price'];
$objRoomTypeDemandPrice->save();
}
} else {
// save selected demands prices for this room type
if ($objGlobalDemand->price != $globalDemand['price']) {
$objRoomTypeDemandPrice = new HotelRoomTypeDemandPrice();
$objRoomTypeDemandPrice->id_product = $this->id;
$objRoomTypeDemandPrice->id_global_demand = $objGlobalDemand->id;
$objRoomTypeDemandPrice->id_option = 0;
$objRoomTypeDemandPrice->price = $globalDemand['price'];
$objRoomTypeDemandPrice->save();
}
}
}
}
}
return true;
}
public function setWsServices($services)
{
Db::getInstance()->execute('
DELETE FROM `'._DB_PREFIX_.'htl_room_type_service_product`
WHERE `id_element` = '.(int)$this->id
);
Db::getInstance()->execute('
DELETE FROM `'._DB_PREFIX_.'htl_room_type_service_product_price`
WHERE `id_element` = '.(int)$this->id
);
if ($this->booking_product) {
if ($allServiceProducts = $this->getServiceProducts()) {
$formttedServiceProducts = array();
foreach ($allServiceProducts as $product) {
$formttedServiceProducts[$product['id_product']] = $product;
}
$allServiceProducts = $formttedServiceProducts;
foreach ($services as $service) {
if (isset($service['id'])
&& Validate::isLoadedObject($objServiceProduct = new Product($service['id']))
&& !$objServiceProduct->booking_product
&& isset($allServiceProducts[$objServiceProduct->id])
) {
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
$objRoomTypeServiceProduct->addRoomProductLink(
$objServiceProduct->id,
$this->id,
RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE
);
$objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice();
$objRoomTypeServiceProductPrice->id_product = $objServiceProduct->id;
$objRoomTypeServiceProductPrice->id_element = $this->id;
$objRoomTypeServiceProductPrice->element_type = RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE;
$objRoomTypeServiceProductPrice->price = isset($service['price']) ? $service['price'] : $allServiceProducts[$objServiceProduct->id]['price'];
$objRoomTypeServiceProductPrice->id_tax_rules_group = isset($service['id_tax_rules_group']) ? $service['id_tax_rules_group'] : $allServiceProducts[$objServiceProduct->id]['id_tax_rules_group'];
$objRoomTypeServiceProductPrice->save();
}
}
}
} else {
return false;
}
return true;
}
}

View File

@@ -46,7 +46,7 @@ class TranslatedConfigurationCore extends Configuration
'id_shop' => array('type' => self::TYPE_NOTHING, 'validate' => 'isUnsignedId'),
'value' => array('type' => self::TYPE_STRING, 'lang' => true),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'lang' => true),
),
);

View File

@@ -534,7 +534,7 @@ class ValidateCore
*/
public static function isPhoneNumber($number)
{
return preg_match('/^[+0-9. ()-]*$/', $number);
return preg_match('/^\+?[\s\d.()-]*\d+$/', $number);
}
/**

View File

@@ -365,13 +365,13 @@ class FrontControllerCore extends Controller
$cart->update();
}
/* Select an address if not set */
if (isset($cart) && (!isset($cart->id_address_delivery) || $cart->id_address_delivery == 0 ||
!isset($cart->id_address_invoice) || $cart->id_address_invoice == 0) && $this->context->cookie->id_customer) {
if (isset($cart)
&& (!isset($cart->id_address_invoice)
|| $cart->id_address_invoice == 0
)
&& $this->context->cookie->id_customer
) {
$to_update = false;
if (!isset($cart->id_address_delivery) || $cart->id_address_delivery == 0) {
$to_update = true;
$cart->id_address_delivery = (int)Address::getFirstCustomerAddressId($cart->id_customer);
}
if (!isset($cart->id_address_invoice) || $cart->id_address_invoice == 0) {
$to_update = true;
$cart->id_address_invoice = (int)Address::getFirstCustomerAddressId($cart->id_customer);
@@ -391,8 +391,7 @@ class FrontControllerCore extends Controller
$cart->id_shop = $this->context->shop->id;
if ($this->context->cookie->id_customer) {
$cart->id_customer = (int)$this->context->cookie->id_customer;
$cart->id_address_delivery = (int)Address::getFirstCustomerAddressId($cart->id_customer);
$cart->id_address_invoice = (int)$cart->id_address_delivery;
$cart->id_address_invoice = (int)Address::getFirstCustomerAddressId($cart->id_customer);
} else {
$cart->id_address_delivery = 0;
$cart->id_address_invoice = 0;
@@ -1217,6 +1216,7 @@ class FrontControllerCore extends Controller
*/
if ($this->context->language->is_rtl) {
$this->addCSS(_THEME_CSS_DIR_.'rtl.css');
$this->addCSS(_THEME_CSS_DIR_.'rtl_grid.css');
$this->addCSS(_THEME_CSS_DIR_.$this->context->language->iso_code.'.css');
}
}

View File

@@ -0,0 +1,160 @@
<?php
/**
* Since 2010 Webkul.
*
* NOTICE OF LICENSE
*
* All right is reserved,
* Please go through this link for complete license : https://store.webkul.com/license.html
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information.
*
* @author Webkul IN <support@webkul.com>
* @copyright Since 2010 Webkul IN
* @license https://store.webkul.com/license.html
*/
class HelperTreeCore extends TreeCore
{
const DEFAULT_NODE_FOLDER_TEMPLATE = 'tree_node_folder_radio.tpl';
const DEFAULT_NODE_ITEM_TEMPLATE = 'tree_node_item_radio.tpl';
private $_use_search;
private $_use_bulk_actions;
private $_use_checkbox;
private $_show_collapse_expand_button = true;
private $_auto_select_children = false;
private $_max_height = 350;
public function setUseSearch($value)
{
$this->_use_search = (bool)$value;
return $this;
}
public function useSearch()
{
return (isset($this->_use_search) && $this->_use_search);
}
public function setAutoSelectChildren($value)
{
$this->_auto_select_children = (bool)$value;
return $this;
}
public function autoSelectChildren()
{
return (isset($this->_auto_select_children) && $this->_auto_select_children);
}
public function setUseBulkActions($value)
{
$this->_use_bulk_actions = (bool)$value;
return $this;
}
public function useBulkActions()
{
return (isset($this->_use_bulk_actions) && $this->_use_bulk_actions);
}
public function setUseCheckBox($value)
{
$this->_use_checkbox = (bool)$value;
return $this;
}
public function useCheckBox()
{
return (isset($this->_use_checkbox) && $this->_use_checkbox);
}
public function setShowCollapseExpandButton($value)
{
$this->_show_collapse_expand_button = (bool)$value;
return $this;
}
public function setMaxHeight($value)
{
$this->_max_height = (bool)$value;
return $this;
}
public function maxHeight()
{
return $this->_max_height;
}
public function showCollapseExpandButton()
{
return (isset($this->_show_collapse_expand_button) && $this->_show_collapse_expand_button);
}
public function render($data = null)
{
if ($this->useCheckBox()) {
if($this->useBulkActions()) {
$check_all = new TreeToolbarLink(
'Check All',
'#',
'checkAll($(\'#'.$this->getId().'\')); return false;',
'icon-check-sign');
$check_all->setAttribute('id', 'check-all-'.$this->getId());
$uncheck_all = new TreeToolbarLink(
'Uncheck All',
'#',
'uncheckAll($(\'#'.$this->getId().'\')); return false;',
'icon-check-empty');
$uncheck_all->setAttribute('id', 'uncheck-all-'.$this->getId());
$this->addAction($check_all);
$this->addAction($uncheck_all);
}
$this->setNodeFolderTemplate('tree_node_folder_checkbox.tpl');
$this->setNodeItemTemplate('tree_node_item_checkbox.tpl');
$this->setAttribute('use_checkbox', $this->useCheckBox());
}
if ($this->useSearch()) {
$this->addAction(new TreeToolbarSearch(
$this->getId().' search',
$this->getId().'-search')
);
$this->setAttribute('use_search', $this->useSearch());
}
$this->setAttribute('auto_select_children', $this->autoSelectChildren());
if ($this->showCollapseExpandButton()) {
$collapse_all = new TreeToolbarLink(
'Collapse All',
'#',
'$(\'#'.$this->getId().'\').tree(\'collapseAll\');$(\'#collapse-all-'.$this->getId().'\').hide();$(\'#expand-all-'.$this->getId().'\').show(); return false;',
'icon-collapse-alt');
$collapse_all->setAttribute('id', 'collapse-all-'.$this->getId());
$expand_all = new TreeToolbarLink(
'Expand All',
'#',
'$(\'#'.$this->getId().'\').tree(\'expandAll\');$(\'#collapse-all-'.$this->getId().'\').show();$(\'#expand-all-'.$this->getId().'\').hide(); return false;',
'icon-expand-alt');
$expand_all->setAttribute('id', 'expand-all-'.$this->getId());
$this->addAction($collapse_all);
$this->addAction($expand_all);
}
$this->setAttribute('max_height', $this->maxHeight());
$this->setAttribute('root_selectable', $this->rootElementSelectable());
return parent::render($data);
}
}

View File

@@ -32,6 +32,7 @@ class HelperTreeCategoriesCore extends TreeCore
private $_disabled_categories;
private $_input_name;
private $_input_id;
private $_lang;
private $_root_category;
private $_selected_categories;
@@ -69,6 +70,8 @@ class HelperTreeCategoriesCore extends TreeCore
foreach ($categories[$rootCategoryId] as $category) {
$categoryId = (int)$category['id_category'];
$tree[$categoryId] = $category;
$tree[$categoryId]['value'] = $category['id_category'];
$tree[$categoryId]['input_name'] = 'categoryBox';
if (Category::hasChildren($categoryId, $this->getLang(), false, $this->getShop()->id)) {
$categoryChildren = Category::getChildren(
@@ -144,7 +147,8 @@ class HelperTreeCategoriesCore extends TreeCore
}
$tree = Category::getCategoryInformations(array($root_category), $lang);
$tree[$root_category]['value'] = $tree[$root_category]['id_category'];
$tree[$root_category]['input_name'] = 'categoryBox';
$children = $this->fillTree($categories, $root_category);
if (!empty($children)) {
@@ -214,6 +218,21 @@ class HelperTreeCategoriesCore extends TreeCore
return $this->_input_name;
}
public function setInputId($value)
{
$this->_input_id = $value;
return $this;
}
public function getInputId()
{
if (!isset($this->_input_id)) {
$this->setInputId('id_category');
}
return $this->_input_id;
}
public function setLang($value)
{
$this->_lang = $value;
@@ -229,24 +248,6 @@ class HelperTreeCategoriesCore extends TreeCore
return $this->_lang;
}
public function getNodeFolderTemplate()
{
if (!isset($this->_node_folder_template)) {
$this->setNodeFolderTemplate(self::DEFAULT_NODE_FOLDER_TEMPLATE);
}
return $this->_node_folder_template;
}
public function getNodeItemTemplate()
{
if (!isset($this->_node_item_template)) {
$this->setNodeItemTemplate(self::DEFAULT_NODE_ITEM_TEMPLATE);
}
return $this->_node_item_template;
}
public function setRootCategory($value)
{
if (!Validate::isInt($value)) {
@@ -304,15 +305,6 @@ class HelperTreeCategoriesCore extends TreeCore
return $this->_shop;
}
public function getTemplate()
{
if (!isset($this->_template)) {
$this->setTemplate(self::DEFAULT_TEMPLATE);
}
return $this->_template;
}
public function setUseCheckBox($value)
{
$this->_use_checkbox = (bool)$value;
@@ -430,7 +422,7 @@ class HelperTreeCategoriesCore extends TreeCore
}
/* Override */
public function renderNodes($data = null)
public function renderNodes($data = null, $root = false)
{
if (!isset($data)) {
$data = $this->getData();
@@ -449,6 +441,7 @@ class HelperTreeCategoriesCore extends TreeCore
$this->getContext()->smarty
)->assign(array(
'input_name' => $this->getInputName(),
'input_id' => $this->getInputId(),
'children' => $this->renderNodes($item['children']),
'node' => $item
))->fetch();
@@ -458,6 +451,7 @@ class HelperTreeCategoriesCore extends TreeCore
$this->getContext()->smarty
)->assign(array(
'input_name' => $this->getInputName(),
'input_id' => $this->getInputId(),
'node' => $item
))->fetch();
}

View File

@@ -1,485 +0,0 @@
<?php
/*
* 2007-2017 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2017 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class HelperTreeHotelsCore extends TreeCore
{
const DEFAULT_TEMPLATE = 'tree_categories.tpl';
const DEFAULT_NODE_FOLDER_TEMPLATE = 'tree_node_folder_radio.tpl';
const DEFAULT_NODE_ITEM_TEMPLATE = 'tree_node_item_radio.tpl';
private $_disabled_categories;
private $_input_name;
private $_lang;
private $_root_category;
private $_selected_hotels;
private $_selected_room_types;
private $_full_tree = false;
private $_shop;
private $_use_checkbox;
private $_use_bulk_actions = true;
private $_use_search;
private $_use_shop_restriction;
private $_rooms_only = false;
private $_disable_all_categories = false;
private $_accessed_hotels = false;
public function __construct($id, $title = null, $root_category = null,
$lang = null, $use_shop_restriction = true)
{
parent::__construct($id);
if (isset($title)) {
$this->setTitle($title);
}
if (isset($root_category)) {
$this->setRootCategory($root_category);
}
$this->setLang($lang);
$this->setUseShopRestriction($use_shop_restriction);
}
private function fillTree($hotels, $onlyRoomType = false)
{
$tree = array();
$idLang = Context::getContext()->language->id;
$objRoomType = new HotelRoomType();
foreach($hotels as $hotel) {
if (!$onlyRoomType) {
$tree[$hotel['id_hotel']] = array(
'id_hotel' => $hotel['id_hotel'],
'id_category' => $hotel['id_category'],
'name' => $hotel['hotel_name'],
'children' => array()
);
}
if (!empty($roomTypes = $objRoomType->getRoomTypeByHotelId($hotel['id_hotel'], $idLang))) {
if ($onlyRoomType) {
$tree = array_merge($tree, $roomTypes);
} else {
$tree[$hotel['id_hotel']]['children'] = array_merge($tree[$hotel['id_hotel']]['children'], $roomTypes);
}
}
}
return $tree;
}
public function getData()
{
if (!isset($this->_data)) {
$shop = $this->getShop();
$lang = $this->getLang();
$root_category = (int)$this->getRootCategory();
if (($hotels = $this->getAccessedHotels()) === false) {
$objHotelBanch = new HotelBranchInformation();
$hotels = $objHotelBanch->hotelBranchesInfo();
}
$tree = $this->fillTree($hotels, $this->_rooms_only);
if (!empty($children)) {
$tree[$root_category]['children'] = $children;
}
$this->setData($tree);
$this->setDataSearch(Category::getAllCategoriesName($root_category, $lang, false, null, $this->useShopRestriction()));
}
return $this->_data;
}
public function setRoomsOnly($value)
{
$this->_rooms_only = $value;
return $this;
}
public function setFullTree($value)
{
$this->_full_tree = $value;
return $this;
}
public function getFullTree()
{
return $this->_full_tree;
}
public function setDisabledCategories($value)
{
$this->_disabled_categories = $value;
return $this;
}
public function setAccessedHotels($values)
{
$this->_accessed_hotels = $values;
return $this;
}
public function getAccessedHotels()
{
return $this->_accessed_hotels;
}
public function setDisablAllCategories($value)
{
$this->_disable_all_categories = $value;
return $this;
}
public function getDisabledCategories()
{
return $this->_disabled_categories;
}
public function getDisablAllCategories()
{
return $this->_disable_all_categories;
}
public function setInputName($value)
{
$this->_input_name = $value;
return $this;
}
public function getInputName()
{
if (!isset($this->_input_name)) {
$this->setInputName('categoryBox');
}
return $this->_input_name;
}
public function setLang($value)
{
$this->_lang = $value;
return $this;
}
public function getLang()
{
if (!isset($this->_lang)) {
$this->setLang($this->getContext()->employee->id_lang);
}
return $this->_lang;
}
public function getNodeFolderTemplate()
{
if (!isset($this->_node_folder_template)) {
$this->setNodeFolderTemplate(self::DEFAULT_NODE_FOLDER_TEMPLATE);
}
return $this->_node_folder_template;
}
public function getNodeItemTemplate()
{
if (!isset($this->_node_item_template)) {
$this->setNodeItemTemplate(self::DEFAULT_NODE_ITEM_TEMPLATE);
}
return $this->_node_item_template;
}
public function setRootCategory($value)
{
if (!Validate::isInt($value)) {
throw new PrestaShopException('Root category must be an integer value');
}
$this->_root_category = $value;
return $this;
}
public function getRootCategory()
{
return $this->_root_category;
}
public function setSelectedHotels($value)
{
if (!is_array($value)) {
throw new PrestaShopException('Selected categories value must be an array');
}
$this->_selected_hotels = $value;
return $this;
}
public function getSelectedHotels()
{
if (!isset($this->_selected_hotels)) {
$this->_selected_hotels = array();
}
return $this->_selected_hotels;
}
public function setSelectedRoomTypes($value)
{
if (!is_array($value)) {
throw new PrestaShopException('Selected categories value must be an array');
}
$this->_selected_room_types = $value;
return $this;
}
public function getSelectedRoomTypes()
{
if (!isset($this->_selected_room_types)) {
$this->_selected_room_types = array();
}
return $this->_selected_room_types;
}
public function setShop($value)
{
$this->_shop = $value;
return $this;
}
public function getShop()
{
if (!isset($this->_shop)) {
if (Tools::isSubmit('id_shop')) {
$this->setShop(new Shop(Tools::getValue('id_shop')));
} elseif ($this->getContext()->shop->id) {
$this->setShop(new Shop($this->getContext()->shop->id));
} elseif (!Shop::isFeatureActive()) {
$this->setShop(new Shop(Configuration::get('PS_SHOP_DEFAULT')));
} else {
$this->setShop(new Shop(0));
}
}
return $this->_shop;
}
public function getTemplate()
{
if (!isset($this->_template)) {
$this->setTemplate(self::DEFAULT_TEMPLATE);
}
return $this->_template;
}
public function setUseCheckBox($value)
{
$this->_use_checkbox = (bool)$value;
return $this;
}
public function setUseBulkActions($value)
{
$this->_use_bulk_actions = (bool)$value;
return $this;
}
public function setUseSearch($value)
{
$this->_use_search = (bool)$value;
return $this;
}
public function setUseShopRestriction($value)
{
$this->_use_shop_restriction = (bool)$value;
return $this;
}
public function useCheckBox()
{
return (isset($this->_use_checkbox) && $this->_use_checkbox);
}
public function useBulkActions()
{
return (isset($this->_use_bulk_actions) && $this->_use_bulk_actions);
}
public function useSearch()
{
return (isset($this->_use_search) && $this->_use_search);
}
public function useShopRestriction()
{
return (isset($this->_use_shop_restriction) && $this->_use_shop_restriction);
}
public function render($data = null)
{
if (!isset($data)) {
$data = $this->getData();
}
if (isset($this->_disabled_categories)
&& !empty($this->_disabled_categories)) {
$this->_disableCategories($data, $this->getDisabledCategories());
}
if($this->getDisablAllCategories()) {
$this->_disableCategories($data);
}
//Default bootstrap style of search is push-right, so we add this button first
if ($this->useSearch()) {
$this->addAction(new TreeToolbarSearchCategories(
'Find a category:',
$this->getId().'-categories-search')
);
$this->setAttribute('use_search', $this->useSearch());
}
$collapse_all = new TreeToolbarLink(
'Collapse All',
'#',
'$(\'#'.$this->getId().'\').tree(\'collapseAll\');$(\'#collapse-all-'.$this->getId().'\').hide();$(\'#expand-all-'.$this->getId().'\').show(); return false;',
'icon-collapse-alt');
$collapse_all->setAttribute('id', 'collapse-all-'.$this->getId());
$expand_all = new TreeToolbarLink(
'Expand All',
'#',
'$(\'#'.$this->getId().'\').tree(\'expandAll\');$(\'#collapse-all-'.$this->getId().'\').show();$(\'#expand-all-'.$this->getId().'\').hide(); return false;',
'icon-expand-alt');
$expand_all->setAttribute('id', 'expand-all-'.$this->getId());
$this->addAction($collapse_all);
$this->addAction($expand_all);
if ($this->useCheckBox()) {
if ($this->useBulkActions()) {
$check_all = new TreeToolbarLink(
'Check All',
'#',
'checkAllAssociatedHotels($(\'#'.$this->getId().'\'));return false;',
'icon-check-sign');
$check_all->setAttribute('id', 'check-all-'.$this->getId());
$uncheck_all = new TreeToolbarLink(
'Uncheck All',
'#',
'uncheckAllAssociatedHotels($(\'#'.$this->getId().'\'));return false;',
'icon-check-empty');
$uncheck_all->setAttribute('id', 'uncheck-all-'.$this->getId());
$this->addAction($check_all);
$this->addAction($uncheck_all);
}
$this->setNodeFolderTemplate('tree_node_hotel_folder_checkbox.tpl');
$this->setNodeItemTemplate('tree_node_hotel_item_checkbox.tpl');
$this->setAttribute('use_checkbox', $this->useCheckBox());
}
$this->setAttribute('selected_hotels', $this->getSelectedHotels());
$this->setAttribute('selected_roomtypes', $this->getSelectedRoomTypes());
$this->getContext()->smarty->assign('root_category', Configuration::get('PS_ROOT_CATEGORY'));
$this->getContext()->smarty->assign('token', Tools::getAdminTokenLite('AdminProducts'));
return parent::render($data);
}
/* Override */
public function renderNodes($data = null)
{
if (!isset($data)) {
$data = $this->getData();
}
if (!is_array($data) && !$data instanceof Traversable) {
throw new PrestaShopException('Data value must be an traversable array');
}
$html = '';
foreach ($data as $item) {
if (array_key_exists('children', $item)) {
$html .= $this->getContext()->smarty->createTemplate(
$this->getTemplateFile($this->getNodeFolderTemplate()),
$this->getContext()->smarty
)->assign(array(
'input_name' => 'hotelBox',
'children' => $this->renderNodes($item['children']),
'node' => $item
))->fetch();
} else {
$html .= $this->getContext()->smarty->createTemplate(
$this->getTemplateFile($this->getNodeItemTemplate()),
$this->getContext()->smarty
)->assign(array(
'input_name' => 'roomTypeBox',
'node' => $item
))->fetch();
}
}
return $html;
}
private function _disableCategories(&$categories, $disabled_categories = null)
{
foreach ($categories as &$category) {
if (!isset($disabled_categories) || in_array($category['id_category'], $disabled_categories)) {
$category['disabled'] = true;
if (array_key_exists('children', $category) && is_array($category['children'])) {
self::_disableCategories($category['children']);
}
} elseif (array_key_exists('children', $category) && is_array($category['children'])) {
self::_disableCategories($category['children'], $disabled_categories);
}
}
}
private function _getSelectedChildNumbers(&$categories, $selected, &$parent = null)
{
$selected_childs = 0;
foreach ($categories as $key => &$category) {
if (isset($parent) && in_array($category['id_category'], $selected)) {
$selected_childs++;
}
if (isset($category['children']) && !empty($category['children'])) {
$selected_childs += $this->_getSelectedChildNumbers($category['children'], $selected, $category);
}
}
if (!isset($parent['selected_childs'])) {
$parent['selected_childs'] = 0;
}
$parent['selected_childs'] = $selected_childs;
return $selected_childs;
}
}

View File

@@ -68,24 +68,6 @@ class HelperTreeShopsCore extends TreeCore
return $this->_lang;
}
public function getNodeFolderTemplate()
{
if (!isset($this->_node_folder_template)) {
$this->setNodeFolderTemplate(self::DEFAULT_NODE_FOLDER_TEMPLATE);
}
return $this->_node_folder_template;
}
public function getNodeItemTemplate()
{
if (!isset($this->_node_item_template)) {
$this->setNodeItemTemplate(self::DEFAULT_NODE_ITEM_TEMPLATE);
}
return $this->_node_item_template;
}
public function setSelectedShops($value)
{
if (!is_array($value)) {
@@ -105,15 +87,6 @@ class HelperTreeShopsCore extends TreeCore
return $this->_selected_shops;
}
public function getTemplate()
{
if (!isset($this->_template)) {
$this->setTemplate(self::DEFAULT_TEMPLATE);
}
return $this->_template;
}
public function render($data = null, $use_default_actions = true, $use_selected_shop = true)
{
if (!isset($data)) {
@@ -153,7 +126,7 @@ class HelperTreeShopsCore extends TreeCore
return parent::render($data);
}
public function renderNodes($data = null)
public function renderNodes($data = null, $root = false)
{
if (!isset($data)) {
$data = $this->getData();

View File

@@ -1665,17 +1665,9 @@ abstract class ModuleCore
if ($item->type == 'addonsMustHave') {
$item->addons_buy_url = strip_tags((string)$modaddons->url);
$prices = (array)$modaddons->price;
$id_default_currency = Configuration::get('PS_CURRENCY_DEFAULT');
foreach ($prices as $currency => $price) {
if ($id_currency = Currency::getIdByIsoCode($currency)) {
$item->price = (float)$price;
$item->id_currency = (int)$id_currency;
if ($id_default_currency == $id_currency) {
break;
}
}
foreach ($prices as $key => $value) {
$item->{$key} = $value;
}
}

View File

@@ -317,6 +317,8 @@ class OrderHistoryCore extends ObjectModel
// if order is created by API then create a direct object instead of creating an object from module
if ($order->module == 'wsorder') {
$payment_method = new WebserviceOrder();
} else if ($order->module == 'bo_order') {
$payment_method = new BoOrder();
} else {
$payment_method = Module::getInstanceByName($order->module);
}

View File

@@ -206,6 +206,11 @@ class OrderReturnCore extends ObjectModel
$objBookingDemands = new HotelBookingDemands();
$objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail();
$calcServicePriceFirst = false;
if ($objOrder->is_advance_payment && $objOrder->advance_paid_amount <= $objOrder->total_paid_real) {
$calcServicePriceFirst = true;
}
foreach ($returnDetails as $key => &$bookingRow) {
if ($skipReqCompletedNonRefunded) {
$objReturnState = new OrderReturnState($bookingRow['id_return_state']);
@@ -219,24 +224,27 @@ class OrderReturnCore extends ObjectModel
$bookingRow['extra_service_total_paid_amount'] = 0;
$bookingRow['extra_service_total_price_tax_incl'] = 0;
$bookingRow['room_paid_amount'] = 0;
if ($bookingRow['total_price_tax_incl'] > 0) {
if ($objOrder->total_paid_real > 0) {
$bookingRow['room_paid_amount'] = ($objOrder->total_paid_real*$bookingRow['total_price_tax_incl'])/$objOrder->total_paid_tax_incl;
}
}
$roomSelectedDemands = $objBookingDemands->getRoomTypeBookingExtraDemands(
$idOrder,
$bookingRow['id_product'],
$bookingRow['id_room'],
$bookingRow['date_from'],
$bookingRow['date_to'],
0
0,
0,
1,
$bookingRow['id']
);
if (count($roomSelectedDemands)) {
foreach ($roomSelectedDemands as $demand) {
if ($demand['total_price_tax_incl'] > 0) {
if ($objOrder->total_paid_real > 0) {
$bookingRow['extra_service_total_paid_amount'] += ($objOrder->total_paid_real*$demand['total_price_tax_incl'])/$objOrder->total_paid_tax_incl;
if ($calcServicePriceFirst) {
$bookingRow['extra_service_total_paid_amount'] += $demand['total_price_tax_incl'];
} else {
$bookingRow['extra_service_total_paid_amount'] += ($objOrder->total_paid_real*$demand['total_price_tax_incl'])/($objOrder->total_paid_tax_incl + $objOrder->total_discounts_tax_incl);
}
}
$bookingRow['extra_service_total_price_tax_incl'] += $demand['total_price_tax_incl'];
}
@@ -250,13 +258,27 @@ class OrderReturnCore extends ObjectModel
foreach ($roomSelectedServices['additional_services'] as $service) {
if ($service['total_price_tax_incl'] > 0) {
if ($objOrder->total_paid_real > 0) {
$bookingRow['extra_service_total_paid_amount'] += ($objOrder->total_paid_real*$service['total_price_tax_incl'])/$objOrder->total_paid_tax_incl;
if ($calcServicePriceFirst) {
$bookingRow['extra_service_total_paid_amount'] += $service['total_price_tax_incl'];
} else {
$bookingRow['extra_service_total_paid_amount'] += ($objOrder->total_paid_real*$service['total_price_tax_incl'])/($objOrder->total_paid_tax_incl + $objOrder->total_discounts_tax_incl);
}
}
$bookingRow['extra_service_total_price_tax_incl'] += $service['total_price_tax_incl'];
}
}
}
}
if ($bookingRow['total_price_tax_incl'] > 0) {
if ($objOrder->total_paid_real > 0) {
if ($calcServicePriceFirst) {
$totalRoomShare = ($objOrder->total_paid_real*($bookingRow['total_price_tax_incl'] + $bookingRow['extra_service_total_price_tax_incl'])/ ($objOrder->total_paid_tax_incl + $objOrder->total_discounts_tax_incl));
$bookingRow['room_paid_amount'] += $totalRoomShare - $bookingRow['extra_service_total_price_tax_incl'];
} else {
$bookingRow['room_paid_amount'] = ($objOrder->total_paid_real*$bookingRow['total_price_tax_incl'])/ ($objOrder->total_paid_tax_incl + $objOrder->total_discounts_tax_incl);
}
}
}
if ($customerView) {
$dateJoin = $bookingRow['id_product'].'_'.strtotime($bookingRow['date_from']).strtotime($bookingRow['date_to']);
if (isset($returnsCustView[$dateJoin]['num_rooms'])) {

View File

@@ -54,4 +54,30 @@ class OrderReturnDetailCore extends ObjectModel
'refunded_amount' => array('type' => self::TYPE_FLOAT),
),
);
public static function getReturnDetailByIdBookingDetail($idHtlBooking)
{
$idOrderReturnDetail = Db::getInstance()->getValue('
SELECT `id_order_return_detail` FROM `'._DB_PREFIX_.'order_return_detail` ord
WHERE `id_htl_booking` = '.(int)$idHtlBooking
);
if ($idOrderReturnDetail) {
return new OrderReturnDetail($idOrderReturnDetail);
}
return null;
}
public static function deleteReturnDetailByIdBookingDetail($idOrder, $idHtlBooking)
{
if (Validate::isLoadedObject($objOrderReturnDetail = OrderReturnDetail::getReturnDetailByIdBookingDetail($idHtlBooking))) {
if ($objOrderReturnDetail->delete()) {
$objOrderReturn = new OrderReturn();
if (empty($objOrderReturn->getOrderRefundRequestedBookings($idOrder, $objOrderReturnDetail->id_order_return, true))) {
$objOrderReturn = new OrderReturn($objOrderReturnDetail->id_order_return);
$objOrderReturn->delete();
}
}
}
}
}

View File

@@ -372,62 +372,6 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
$cart_htl_data[$type_key]['unit_price_tax_incl'] = $unit_price_tax_incl;
if (isset($cart_htl_data[$type_key]['date_diff'][$date_join])) {
// $cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands'] = $objBookingDemand->getRoomTypeBookingExtraDemands(
// $order_obj->id,
// $type_value['product_id'],
// 0,
// $data_v['date_from'],
// $data_v['date_to']
// );
$cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands_price_te'] = $objBookingDemand->getRoomTypeBookingExtraDemands(
$order_obj->id,
$type_value['product_id'],
0,
$data_v['date_from'],
$data_v['date_to'],
0,
1,
0,
$type_value['id_order_detail']
);
$cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'] = $objBookingDemand->getRoomTypeBookingExtraDemands(
$order_obj->id,
$type_value['product_id'],
0,
$data_v['date_from'],
$data_v['date_to'],
0,
1,
1,
$type_value['id_order_detail']
);
$cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
$order_obj->id,
0,
0,
$data_v['id_product'],
$data_v['date_from'],
$data_v['date_to'],
$data_v['id_room'],
1,
1,
1,
Product::PRICE_ADDITION_TYPE_WITH_ROOM
);
$cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
$order_obj->id,
0,
0,
$data_v['id_product'],
$data_v['date_from'],
$data_v['date_to'],
$data_v['id_room'],
1,
0,
1,
Product::PRICE_ADDITION_TYPE_WITH_ROOM
);
$cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'] += 1;
$cart_htl_data[$type_key]['date_diff'][$date_join]['adults'] += $data_v['adults'];
$cart_htl_data[$type_key]['date_diff'][$date_join]['children'] += $data_v['children'];
@@ -437,20 +381,13 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
$cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days;
$cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_excl']/$num_days;
$cart_htl_data[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_excl'] += ($cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] + $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te']);
$cart_htl_data[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_excl'] += $cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'];
$cart_htl_data[$type_key]['date_diff'][$date_join]['amount'] += ($data_v['total_price_tax_excl'] + $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te']);
$cart_htl_data[$type_key]['date_diff'][$date_join]['amount'] += ($data_v['total_price_tax_excl']);
// For order refund
$cart_htl_data[$type_key]['date_diff'][$date_join]['id_room'] = $data_v['id_room'];
} else {
// $cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands'] = $objBookingDemand->getRoomTypeBookingExtraDemands(
// $order_obj->id,
// $type_value['product_id'],
// 0,
// $data_v['date_from'],
// $data_v['date_to']
// );
$cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands_price_te'] = $objBookingDemand->getRoomTypeBookingExtraDemands(
$order_obj->id,
$type_value['product_id'],
@@ -460,6 +397,7 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
0,
1,
0,
0,
$type_value['id_order_detail']
);
$cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'] = $objBookingDemand->getRoomTypeBookingExtraDemands(
@@ -471,6 +409,7 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
0,
1,
1,
0,
$type_value['id_order_detail']
);
$cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
@@ -513,7 +452,7 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
$data_v['id_product'],
$data_v['date_from'],
$data_v['date_to'],
$data_v['id_room'],
0,
1,
1,
1,
@@ -526,7 +465,7 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
$data_v['id_product'],
$data_v['date_from'],
$data_v['date_to'],
$data_v['id_room'],
0,
1,
0,
1,
@@ -559,7 +498,11 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
$type_value['product_id'],
$data_v['id_room'],
$data_v['date_from'],
$data_v['date_to']
$data_v['date_to'],
1,
0,
1,
$data_v['id']
)) {
$extraDemands = array_shift($extraDemands);
$extraDemands['product_id'] = $type_value['product_id'];
@@ -569,16 +512,12 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
$room_extra_demands[] = $extraDemands;
}
if ($additionalServices = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
$order_obj->id,
if ($additionalServices = $objRoomTypeServiceProductOrderDetail->getSelectedServicesForRoom(
$data_v['id'],
0,
0,
$type_value['product_id'],
$data_v['date_from'],
$data_v['date_to'],
$data_v['id_room']
1,
0
)) {
$additionalServices = array_shift($additionalServices);
$additionalServices['product_id'] = $type_value['product_id'];
$additionalServices['room_type_name'] = $type_value['product_name'];
$additionalServices['date_from'] = $data_v['date_from'];

View File

@@ -42,6 +42,8 @@ class TreeCore
protected $_node_folder_template;
protected $_node_item_template;
protected $_template;
private $_root_element_selectable = true;
/** @var string */
private $_template_directory;
@@ -191,7 +193,7 @@ class TreeCore
public function getHeaderTemplate()
{
if (!isset($this->_headerTemplate)) {
$this->setHeaderTemplate(self::DEFAULT_HEADER_TEMPLATE);
$this->setHeaderTemplate(static::DEFAULT_HEADER_TEMPLATE);
}
return $this->_headerTemplate;
@@ -217,7 +219,7 @@ class TreeCore
public function getNodeFolderTemplate()
{
if (!isset($this->_node_folder_template)) {
$this->setNodeFolderTemplate(self::DEFAULT_NODE_FOLDER_TEMPLATE);
$this->setNodeFolderTemplate(static::DEFAULT_NODE_FOLDER_TEMPLATE);
}
return $this->_node_folder_template;
@@ -232,7 +234,7 @@ class TreeCore
public function getNodeItemTemplate()
{
if (!isset($this->_node_item_template)) {
$this->setNodeItemTemplate(self::DEFAULT_NODE_ITEM_TEMPLATE);
$this->setNodeItemTemplate(static::DEFAULT_NODE_ITEM_TEMPLATE);
}
return $this->_node_item_template;
@@ -247,7 +249,7 @@ class TreeCore
public function getTemplate()
{
if (!isset($this->_template)) {
$this->setTemplate(self::DEFAULT_TEMPLATE);
$this->setTemplate(static::DEFAULT_TEMPLATE);
}
return $this->_template;
@@ -271,7 +273,7 @@ class TreeCore
{
if (!isset($this->_template_directory)) {
$this->_template_directory = $this->_normalizeDirectory(
self::DEFAULT_TEMPLATE_DIRECTORY);
static::DEFAULT_TEMPLATE_DIRECTORY);
}
return $this->_template_directory;
@@ -342,6 +344,17 @@ class TreeCore
return $this;
}
public function setRootElementSelectable($value)
{
$this->_root_element_selectable = (bool)$value;
return $this;
}
public function rootElementSelectable()
{
return (isset($this->_root_element_selectable) && $this->_root_element_selectable);
}
public function getToolbar()
{
if (isset($this->_toolbar)) {
@@ -419,14 +432,14 @@ class TreeCore
//Assign Tree nodes
$template->assign($this->getAttributes())->assign(array(
'id' => $this->getId(),
'nodes' => $this->renderNodes($data),
'nodes' => $this->renderNodes($data, true),
'id_tree' => $this->getIdTree()
));
return (isset($html) ? $html : '').$template->fetch();
}
public function renderNodes($data = null)
public function renderNodes($data = null, $root = false)
{
if (!isset($data)) {
$data = $this->getData();
@@ -446,14 +459,16 @@ class TreeCore
$this->getContext()->smarty
)->assign(array(
'children' => $this->renderNodes($item['children']),
'node' => $item
'node' => $item,
'selectable' => !$root || $this->rootElementSelectable()
))->fetch();
} else {
$html .= $this->getContext()->smarty->createTemplate(
$this->getTemplateFile($this->getNodeItemTemplate()),
$this->getContext()->smarty
)->assign(array(
'node' => $item
'node' => $item,
'selectable' => !$root || $this->rootElementSelectable()
))->fetch();
}
}

View File

@@ -632,6 +632,7 @@ class WebserviceOutputBuilderCore
$value = $object_assoc;
}
if (empty($fields_assoc)) {
$value['id'] = isset($value['id']) ? $value['id'] : '';
$fields_assoc = array(array('id' => $value['id']));
}
$output_details .= $this->renderFlatAssociation($object, $depth, $assoc_name, $association['resource'], $fields_assoc, $value, $parent_details);
@@ -680,7 +681,7 @@ class WebserviceOutputBuilderCore
$field['sqlId'] = 'id';
$field['value'] = isset($object_assoc['id']) ? $object_assoc['id'] : null;
} elseif (!isset($field['sqlId'])) {
$field['sqlId'] = $field_name;
$field['sqlId'] = $field_name ? $field_name : 'id';
$field['value'] = isset($object_assoc[$field_name]) ? $object_assoc[$field_name] : null;
}
@@ -829,4 +830,10 @@ class WebserviceOutputBuilderCore
{
$this->fieldsToDisplay = $fields;
}
public function setWsParameters($class, $parameters)
{
WebserviceOutputBuilder::$_cache_ws_parameters[$class] = $parameters;
}
}

View File

@@ -199,7 +199,7 @@ class WebserviceOutputXMLCore implements WebserviceOutputInterface
if (array_key_exists('setter', $params['associations'][$assoc_name]) && !$params['associations'][$assoc_name]['setter']) {
$more .= ' readOnly="true"';
}
$more .= ' nodeType="'.$params['associations'][$assoc_name]['resource'].'"';
$more .= (isset($params['associations'][$assoc_name]['resource'])? ' nodeType="'.$params['associations'][$assoc_name]['resource'].'"' : ' ');
if (isset($params['associations'][$assoc_name]['virtual_entity']) && $params['associations'][$assoc_name]['virtual_entity']) {
$more .= ' virtualEntity="true"';
} else {

View File

@@ -290,6 +290,7 @@ class WebserviceRequestCore
'room_type_options' => array('description' => 'The product options','class' => 'AttributeGroup'),
'room_type_option_values' => array('description' => 'The product options value','class' => 'Attribute'),
'room_types' => array('description' => 'The room types','class' => 'Product'),
'services' => array('description' => 'Services', 'class' => 'Product', 'parameters_attribute' => 'webserviceServicesParameters'),
'states' => array('description' => 'The available states of countries','class' => 'State'),
'stores' => array('description' => 'The stores', 'class' => 'Store'),
'suppliers' => array('description' => 'The product suppliers','class' => 'Supplier'),
@@ -512,6 +513,8 @@ class WebserviceRequestCore
$object = new $url_resource['class']();
if (isset($this->resourceList[$this->urlSegment[0]]['parameters_attribute'])) {
$this->resourceConfiguration = $object->getWebserviceParameters($this->resourceList[$this->urlSegment[0]]['parameters_attribute']);
// Setting the parameters for the output builder in cache for the resources having parameters_attribute.
$this->objOutput->setWsParameters($url_resource['class'], $this->resourceConfiguration);
} else {
$this->resourceConfiguration = $object->getWebserviceParameters();
}

View File

@@ -51,6 +51,7 @@ class WebserviceSpecificManagementImagesCore implements WebserviceSpecificManage
'room_types' => array(),
'hotels' => array(),
'categories' => array(),
'extra_service' => array(),
// 'manufacturers' => array(),
// 'suppliers' => array(),
// 'stores' => array(),
@@ -286,7 +287,9 @@ class WebserviceSpecificManagementImagesCore implements WebserviceSpecificManage
$this->imageType = $this->wsObject->urlSegment[1];
// if image type requested is room_types then process products images
if ($this->imageType == 'room_types') {
if ($this->imageType == 'room_types'
|| $this->imageType == 'extra_services'
) {
$this->imageType = 'products';
}