Merge branch 'develop' into gli-758
This commit is contained in:
@@ -159,7 +159,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
'remove_onclick' => true
|
||||
)
|
||||
));
|
||||
|
||||
|
||||
$this->shopLinkType = 'shop';
|
||||
$this->shopShareDatas = Shop::SHARE_ORDER;
|
||||
|
||||
@@ -321,7 +321,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
|
||||
$this->addJqueryUI('ui.datepicker');
|
||||
$this->addJS(_PS_JS_DIR_.'vendor/d3.v3.min.js');
|
||||
|
||||
|
||||
if ($this->tabAccess['edit'] == 1 && $this->display == 'view') {
|
||||
$this->addJS(_PS_JS_DIR_.'admin/orders.js');
|
||||
$this->addJS(_PS_JS_DIR_.'tools.js');
|
||||
@@ -872,7 +872,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
unset($_COOKIE['wk_id_guest']);
|
||||
*/
|
||||
if ($payment_module->currentOrder) {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&id_order='.$payment_module->currentOrder.'&vieworder'.'&token='.$this->token);
|
||||
Tools::redirectAdmin(self::$currentIndex.'&id_order='.$payment_module->currentOrder.'&vieworder'.'&token='.$this->token.'&conf=3');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -1589,78 +1589,85 @@ class AdminOrdersControllerCore extends AdminController
|
||||
{
|
||||
Context::getContext()->customer = new Customer((int)Tools::getValue('id_customer'));
|
||||
$currency = new Currency((int)Tools::getValue('id_currency'));
|
||||
if ($products = Product::searchByName((int)$this->context->language->id, pSQL(Tools::getValue('product_search')))) {
|
||||
foreach ($products as &$product) {
|
||||
// Formatted price
|
||||
$product['formatted_price'] = Tools::displayPrice(Tools::convertPrice($product['price_tax_incl'], $currency), $currency);
|
||||
// Concret price
|
||||
$product['price_tax_incl'] = Tools::ps_round(Tools::convertPrice($product['price_tax_incl'], $currency), 2);
|
||||
$product['price_tax_excl'] = Tools::ps_round(Tools::convertPrice($product['price_tax_excl'], $currency), 2);
|
||||
$productObj = new Product((int)$product['id_product'], false, (int)$this->context->language->id);
|
||||
$combinations = array();
|
||||
$attributes = $productObj->getAttributesGroups((int)$this->context->language->id);
|
||||
$to_return = array('found' => false);
|
||||
if (Validate::isLoadedObject($order = new Order(Tools::getValue('id_order')))) {
|
||||
$objBookingDetail = new HotelBookingDetail();
|
||||
$hotelBookingDetail = $objBookingDetail->getOrderCurrentDataByOrderId($order->id);
|
||||
if (count($hotelBookingDetail)) {
|
||||
$idHotel = reset($hotelBookingDetail)['id_hotel'];
|
||||
} else {
|
||||
$idHotel = false;
|
||||
}
|
||||
|
||||
// Tax rate for this customer
|
||||
if (Tools::isSubmit('id_address')) {
|
||||
$product['tax_rate'] = $productObj->getTaxesRate(new Address(Tools::getValue('id_address')));
|
||||
}
|
||||
if ($products = Product::searchByName((int)$this->context->language->id, pSQL(Tools::getValue('product_search')), null, $idHotel)) {
|
||||
foreach ($products as &$product) {
|
||||
// Formatted price
|
||||
$product['formatted_price'] = Tools::displayPrice(Tools::convertPrice($product['price_tax_incl'], $currency), $currency);
|
||||
// Concret price
|
||||
$product['price_tax_incl'] = Tools::ps_round(Tools::convertPrice($product['price_tax_incl'], $currency), 2);
|
||||
$product['price_tax_excl'] = Tools::ps_round(Tools::convertPrice($product['price_tax_excl'], $currency), 2);
|
||||
$productObj = new Product((int)$product['id_product'], false, (int)$this->context->language->id);
|
||||
$combinations = array();
|
||||
$attributes = $productObj->getAttributesGroups((int)$this->context->language->id);
|
||||
|
||||
$product['warehouse_list'] = array();
|
||||
|
||||
foreach ($attributes as $attribute) {
|
||||
if (!isset($combinations[$attribute['id_product_attribute']]['attributes'])) {
|
||||
$combinations[$attribute['id_product_attribute']]['attributes'] = '';
|
||||
// Tax rate for this customer
|
||||
if (Tools::isSubmit('id_address')) {
|
||||
$product['tax_rate'] = $productObj->getTaxesRate(new Address(Tools::getValue('id_address')));
|
||||
}
|
||||
$combinations[$attribute['id_product_attribute']]['attributes'] .= $attribute['attribute_name'].' - ';
|
||||
$combinations[$attribute['id_product_attribute']]['id_product_attribute'] = $attribute['id_product_attribute'];
|
||||
$combinations[$attribute['id_product_attribute']]['default_on'] = $attribute['default_on'];
|
||||
if (!isset($combinations[$attribute['id_product_attribute']]['price'])) {
|
||||
$price_tax_incl = Product::getPriceStatic((int)$product['id_product'], true, $attribute['id_product_attribute']);
|
||||
$price_tax_excl = Product::getPriceStatic((int)$product['id_product'], false, $attribute['id_product_attribute']);
|
||||
$combinations[$attribute['id_product_attribute']]['price_tax_incl'] = Tools::ps_round(Tools::convertPrice($price_tax_incl, $currency), 2);
|
||||
$combinations[$attribute['id_product_attribute']]['price_tax_excl'] = Tools::ps_round(Tools::convertPrice($price_tax_excl, $currency), 2);
|
||||
$combinations[$attribute['id_product_attribute']]['formatted_price'] = Tools::displayPrice(Tools::convertPrice($price_tax_excl, $currency), $currency);
|
||||
}
|
||||
if (!isset($combinations[$attribute['id_product_attribute']]['qty_in_stock'])) {
|
||||
$combinations[$attribute['id_product_attribute']]['qty_in_stock'] = StockAvailable::getQuantityAvailableByProduct((int)$product['id_product'], $attribute['id_product_attribute'], (int)$this->context->shop->id);
|
||||
|
||||
$product['warehouse_list'] = array();
|
||||
|
||||
foreach ($attributes as $attribute) {
|
||||
if (!isset($combinations[$attribute['id_product_attribute']]['attributes'])) {
|
||||
$combinations[$attribute['id_product_attribute']]['attributes'] = '';
|
||||
}
|
||||
$combinations[$attribute['id_product_attribute']]['attributes'] .= $attribute['attribute_name'].' - ';
|
||||
$combinations[$attribute['id_product_attribute']]['id_product_attribute'] = $attribute['id_product_attribute'];
|
||||
$combinations[$attribute['id_product_attribute']]['default_on'] = $attribute['default_on'];
|
||||
if (!isset($combinations[$attribute['id_product_attribute']]['price'])) {
|
||||
$price_tax_incl = Product::getPriceStatic((int)$product['id_product'], true, $attribute['id_product_attribute']);
|
||||
$price_tax_excl = Product::getPriceStatic((int)$product['id_product'], false, $attribute['id_product_attribute']);
|
||||
$combinations[$attribute['id_product_attribute']]['price_tax_incl'] = Tools::ps_round(Tools::convertPrice($price_tax_incl, $currency), 2);
|
||||
$combinations[$attribute['id_product_attribute']]['price_tax_excl'] = Tools::ps_round(Tools::convertPrice($price_tax_excl, $currency), 2);
|
||||
$combinations[$attribute['id_product_attribute']]['formatted_price'] = Tools::displayPrice(Tools::convertPrice($price_tax_excl, $currency), $currency);
|
||||
}
|
||||
if (!isset($combinations[$attribute['id_product_attribute']]['qty_in_stock'])) {
|
||||
$combinations[$attribute['id_product_attribute']]['qty_in_stock'] = StockAvailable::getQuantityAvailableByProduct((int)$product['id_product'], $attribute['id_product_attribute'], (int)$this->context->shop->id);
|
||||
}
|
||||
|
||||
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && (int)$product['advanced_stock_management'] == 1) {
|
||||
$product['warehouse_list'][$attribute['id_product_attribute']] = Warehouse::getProductWarehouseList($product['id_product'], $attribute['id_product_attribute']);
|
||||
} else {
|
||||
$product['warehouse_list'][$attribute['id_product_attribute']] = array();
|
||||
}
|
||||
|
||||
$product['stock'][$attribute['id_product_attribute']] = Product::getRealQuantity($product['id_product'], $attribute['id_product_attribute']);
|
||||
}
|
||||
|
||||
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && (int)$product['advanced_stock_management'] == 1) {
|
||||
$product['warehouse_list'][$attribute['id_product_attribute']] = Warehouse::getProductWarehouseList($product['id_product'], $attribute['id_product_attribute']);
|
||||
$product['warehouse_list'][0] = Warehouse::getProductWarehouseList($product['id_product']);
|
||||
} else {
|
||||
$product['warehouse_list'][$attribute['id_product_attribute']] = array();
|
||||
$product['warehouse_list'][0] = array();
|
||||
}
|
||||
|
||||
$product['stock'][$attribute['id_product_attribute']] = Product::getRealQuantity($product['id_product'], $attribute['id_product_attribute']);
|
||||
}
|
||||
$product['stock'][0] = StockAvailable::getQuantityAvailableByProduct((int)$product['id_product'], 0, (int)$this->context->shop->id);
|
||||
|
||||
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && (int)$product['advanced_stock_management'] == 1) {
|
||||
$product['warehouse_list'][0] = Warehouse::getProductWarehouseList($product['id_product']);
|
||||
} else {
|
||||
$product['warehouse_list'][0] = array();
|
||||
}
|
||||
foreach ($combinations as &$combination) {
|
||||
$combination['attributes'] = rtrim($combination['attributes'], ' - ');
|
||||
}
|
||||
$product['combinations'] = $combinations;
|
||||
|
||||
$product['stock'][0] = StockAvailable::getQuantityAvailableByProduct((int)$product['id_product'], 0, (int)$this->context->shop->id);
|
||||
|
||||
foreach ($combinations as &$combination) {
|
||||
$combination['attributes'] = rtrim($combination['attributes'], ' - ');
|
||||
}
|
||||
$product['combinations'] = $combinations;
|
||||
|
||||
if ($product['customizable']) {
|
||||
$product_instance = new Product((int)$product['id_product']);
|
||||
$product['customization_fields'] = $product_instance->getCustomizationFields($this->context->language->id);
|
||||
if ($product['customizable']) {
|
||||
$product_instance = new Product((int)$product['id_product']);
|
||||
$product['customization_fields'] = $product_instance->getCustomizationFields($this->context->language->id);
|
||||
}
|
||||
}
|
||||
$to_return = array(
|
||||
'products' => $products,
|
||||
'found' => true
|
||||
);
|
||||
}
|
||||
|
||||
$to_return = array(
|
||||
'products' => $products,
|
||||
'found' => true
|
||||
);
|
||||
} else {
|
||||
$to_return = array('found' => false);
|
||||
}
|
||||
|
||||
$this->content = json_encode($to_return);
|
||||
}
|
||||
|
||||
@@ -1890,7 +1897,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
false,
|
||||
$order->id_customer,
|
||||
$cart->id,
|
||||
$order->{Configuration::get('PS_TAX_ADDRESS_TYPE', null, null, $order->id_shop)}
|
||||
$order->id_address_tax
|
||||
);
|
||||
|
||||
// Creating specific price if needed
|
||||
@@ -2194,12 +2201,13 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$obj_cart_bk_data->id_hotel,
|
||||
$idLang
|
||||
))) {
|
||||
$addressInfo = $objHotelBranch->getAddress($obj_cart_bk_data->id_hotel);
|
||||
$objHtlBkDtl->hotel_name = $objHotelBranch->hotel_name;
|
||||
$objHtlBkDtl->city = $objHotelBranch->city;
|
||||
$objHtlBkDtl->state = State::getNameById($objHotelBranch->state_id);
|
||||
$objHtlBkDtl->country = Country::getNameById($idLang, $objHotelBranch->country_id);
|
||||
$objHtlBkDtl->zipcode = $objHotelBranch->zipcode;
|
||||
$objHtlBkDtl->phone = $objHotelBranch->phone;
|
||||
$objHtlBkDtl->city = $addressInfo['city'];
|
||||
$objHtlBkDtl->state = State::getNameById($addressInfo['id_state']);
|
||||
$objHtlBkDtl->country = Country::getNameById($idLang, $addressInfo['id_country']);
|
||||
$objHtlBkDtl->zipcode = $addressInfo['postcode'];;
|
||||
$objHtlBkDtl->phone = $addressInfo['phone'];
|
||||
$objHtlBkDtl->email = $objHotelBranch->email;
|
||||
$objHtlBkDtl->check_in_time = $objHotelBranch->check_in;
|
||||
$objHtlBkDtl->check_out_time = $objHotelBranch->check_out;
|
||||
@@ -2301,6 +2309,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$product_quantity = (int) $obj_booking_detail->getNumberOfDays($new_date_from, $new_date_to);
|
||||
$old_product_quantity = (int) $obj_booking_detail->getNumberOfDays($old_date_from, $old_date_to);
|
||||
$qty_diff = $product_quantity - $old_product_quantity;
|
||||
|
||||
/*By webkul to validate fields before deleting the cart and order data form the tables*/
|
||||
if ($id_hotel == '') {
|
||||
die(json_encode(array(
|
||||
@@ -2584,6 +2593,19 @@ class AdminOrdersControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($order_invoice)) {
|
||||
// Apply changes on OrderInvoice
|
||||
$order_invoice->total_paid_tax_excl = $objOrder->total_paid_tax_excl;
|
||||
$order_invoice->total_paid_tax_incl = $objOrder->total_paid_tax_incl;
|
||||
}
|
||||
|
||||
|
||||
// Save order invoice
|
||||
if (isset($order_invoice)) {
|
||||
$res &= $order_invoice->update();
|
||||
}
|
||||
|
||||
// change order total save
|
||||
$objOrder->save();
|
||||
}
|
||||
@@ -3258,7 +3280,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$roomDemands = Tools::getValue('room_demands');
|
||||
if ($roomDemands = json_decode($roomDemands, true)) {
|
||||
$order = new Order($objBookingDetail->id_order);
|
||||
$vatAddress = new Address((int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
|
||||
$vatAddress = new Address((int)$order->id_address_tax);
|
||||
$idLang = (int)$order->id_lang;
|
||||
$idProduct = $objBookingDetail->id_product;
|
||||
$objHtlBkDtl = new HotelBookingDetail();
|
||||
@@ -3301,6 +3323,16 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$objBookingDemand->total_price_tax_excl = $objBookingDemand->unit_price_tax_excl * $qty;
|
||||
$objBookingDemand->total_price_tax_incl = $objBookingDemand->unit_price_tax_incl * $qty;
|
||||
|
||||
$order_detail = new OrderDetail($objBookingDetail->id_order_detail);
|
||||
// Update OrderInvoice of this OrderDetail
|
||||
if ($order_detail->id_order_invoice != 0) {
|
||||
// values changes as values are calculated accoding to the quantity of the product by webkul
|
||||
$order_invoice = new OrderInvoice($order_detail->id_order_invoice);
|
||||
$order_invoice->total_paid_tax_excl += $objBookingDemand->total_price_tax_excl;
|
||||
$order_invoice->total_paid_tax_incl += $objBookingDemand->total_price_tax_incl;
|
||||
$res &= $order_invoice->update();
|
||||
}
|
||||
|
||||
// change order total
|
||||
$order->total_paid_tax_excl += $objBookingDemand->total_price_tax_excl;
|
||||
$order->total_paid_tax_incl += $objBookingDemand->total_price_tax_incl;
|
||||
@@ -3345,6 +3377,16 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$order->total_paid_tax_incl -= $objBookingDemand->total_price_tax_incl;
|
||||
$order->total_paid -= $objBookingDemand->total_price_tax_incl;
|
||||
$order->save();
|
||||
|
||||
$order_detail = new OrderDetail($objBookingDetail->id_order_detail);
|
||||
// Update OrderInvoice of this OrderDetail
|
||||
if ($order_detail->id_order_invoice != 0) {
|
||||
// values changes as values are calculated accoding to the quantity of the product by webkul
|
||||
$order_invoice = new OrderInvoice($order_detail->id_order_invoice);
|
||||
$order_invoice->total_paid_tax_excl -= $objBookingDemand->total_price_tax_excl;
|
||||
$order_invoice->total_paid_tax_incl -= $objBookingDemand->total_price_tax_incl;
|
||||
$res &= $order_invoice->update();
|
||||
}
|
||||
}
|
||||
die('1');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user