diff --git a/controllers/admin/AdminCustomersController.php b/controllers/admin/AdminCustomersController.php index 38d0d82c9..ebfef0125 100644 --- a/controllers/admin/AdminCustomersController.php +++ b/controllers/admin/AdminCustomersController.php @@ -80,6 +80,7 @@ class AdminCustomersControllerCore extends AdminController $this->_join = 'LEFT JOIN '._DB_PREFIX_.'gender_lang gl ON (a.id_gender = gl.id_gender AND gl.id_lang = '.(int)$this->context->language->id.')'; $this->_join .= ' LEFT JOIN '._DB_PREFIX_.'group_lang grl ON (a.id_default_group = grl.id_group AND grl.id_lang = '.(int)$this->context->language->id.')'; $this->_join .= ' LEFT JOIN '._DB_PREFIX_.'orders o ON (a.id_customer = o.id_customer)'; + $this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'cart_customer_guest_detail` cgd ON cgd.`email` = a.`email` AND cgd.`id_cart` = 0 '; $this->_group = 'GROUP BY a.`id_customer`'; $this->fields_list = array( @@ -97,13 +98,16 @@ class AdminCustomersControllerCore extends AdminController 'order_key' => 'gl!name' ), 'firstname' => array( - 'title' => $this->l('First name') + 'title' => $this->l('First name'), + 'filter_key' => 'a!firstname' ), 'lastname' => array( - 'title' => $this->l('Last name') + 'title' => $this->l('Last name'), + 'filter_key' => 'a!lastname' ), 'email' => array( - 'title' => $this->l('Email address') + 'title' => $this->l('Email address'), + 'filter_key' => 'a!email' ), ); @@ -141,6 +145,12 @@ class AdminCustomersControllerCore extends AdminController 'align' => 'text-right', 'badge_success' => true ), + 'phone' => array( + 'title' => $this->l('Phone'), + 'filter_key' => 'cgd!phone', + 'optional' => true, + 'visible_default' => false, + ), 'active' => array( 'title' => $this->l('Enabled'), 'align' => 'text-center', @@ -179,6 +189,7 @@ class AdminCustomersControllerCore extends AdminController 'title' => $this->l('Banned'), 'type' => 'bool', 'displayed' => false, + 'callback' => 'getCustomerStatusLabel', ), 'order_date' => array( 'title' => $this->l('Order date'), @@ -194,6 +205,7 @@ class AdminCustomersControllerCore extends AdminController $this->_select = ' a.date_add, gl.name as title, grl.name as default_group_name, COUNT(o.`id_order`) as total_orders, + cgd.`phone`, o.`date_add` as order_date, SUM(total_paid_real / conversion_rate) as total_spent, ( SELECT c.date_add FROM '._DB_PREFIX_.'guest g LEFT JOIN '._DB_PREFIX_.'connections c ON c.id_guest = g.id_guest @@ -230,6 +242,17 @@ class AdminCustomersControllerCore extends AdminController } } + public function getCustomerStatusLabel($deleted, $tr) + { + if ($deleted == Customer::STATUS_DELETED) { + return $this->l('Deleted'); + } else if ($deleted == Customer::STATUS_BANNED) { + return $this->l('Banned'); + } + + return; + } + public function initContent() { if ($this->action == 'select_delete') { @@ -263,8 +286,11 @@ class AdminCustomersControllerCore extends AdminController public function getList($id_lang, $orderBy = null, $orderWay = null, $start = 0, $limit = null, $id_lang_shop = null) { - parent::getList($id_lang, $orderBy, $orderWay, $start, $limit, $id_lang_shop); + if ($this->action == 'export') { + $this->deleted = false; + } + parent::getList($id_lang, $orderBy, $orderWay, $start, $limit, $id_lang_shop); if ($this->_list) { foreach ($this->_list as &$row) { $row['badge_success'] = $row['total_spent'] > 0; diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 6dfcdaced..d0abec297 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -79,8 +79,7 @@ class AdminOrdersControllerCore extends AdminController LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (os.`id_order_state` = a.`current_state`) LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.(int) $this->context->language->id.') LEFT JOIN `'._DB_PREFIX_.'htl_booking_detail` hbd ON (hbd.`id_order` = a.`id_order`) - LEFT JOIN `'._DB_PREFIX_.'htl_branch_info_lang` hbil ON (hbil.`id` = hbd.`id_hotel`)'; - + LEFT JOIN `'._DB_PREFIX_.'htl_branch_info_lang` hbil ON (hbil.`id` = hbd.`id_hotel` AND osl.`id_lang` = hbil.`id_lang`)'; $this->_orderBy = 'id_order'; $this->_orderWay = 'DESC'; @@ -1189,6 +1188,123 @@ class AdminOrdersControllerCore extends AdminController return parent::renderList(); } + public function getList( + $id_lang, + $order_by = null, + $order_way = null, + $start = 0, + $limit = null, + $id_lang_shop = false + ){ + if ($this->action == 'export' && empty($this->_listsql)) { + $this->_select .= ', c.`email`, cgd.`phone`, a.`total_paid_real`, + orf.`cancellation_date`, orf.`cancellation_fee`, + cy.`iso_code` AS country, st.`iso_code` as state, ad.`city`, + CONCAT(ad.`address1`, \', \', ad.`postcode`) AS `cus_address`, + GROUP_CONCAT( + CASE + WHEN hbd.`id_status`='.HotelBookingDetail::STATUS_ALLOTED.' THEN \''.$this->l('Alloted').'\' + WHEN hbd.`id_status`='.HotelBookingDetail::STATUS_CHECKED_IN.' THEN \''.$this->l('Checked in').'\' + WHEN hbd.`id_status`='.HotelBookingDetail::STATUS_CHECKED_OUT.' THEN \''.$this->l('Checked out').'\' + ELSE \''.$this->l('Invalid status').'\' + END + ) AS `room_status`, + GROUP_CONCAT(DISTINCT(hbd.`room_type_name`)) AS `room_types`, + GROUP_CONCAT(hbd.`date_from`) AS `date_from`, + GROUP_CONCAT(hbd.`date_to`) AS `date_to`, + GROUP_CONCAT(hbd.`room_num`) AS `rooms`, + GROUP_CONCAT(hbd.`check_in`) AS `check_in_dates`, + GROUP_CONCAT(hbd.`check_out`) AS `check_out_dates`'; + + $this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'cart_customer_guest_detail` cgd ON cgd.`email` = c.`email` AND cgd.`id_cart` = 0 + LEFT JOIN `'._DB_PREFIX_.'address` ad ON a.`id_customer`= ad.`id_customer` AND ad.`id_customer`!=0 + LEFT JOIN `'._DB_PREFIX_.'country` cy ON cy.`id_country`= ad.`id_country` + LEFT JOIN `'._DB_PREFIX_.'state` st ON st.`id_state`= ad.`id_state` + LEFT JOIN ( + SELECT ref.`id_order`, IF(refst.refunded = 1, GROUP_CONCAT(ref.`date_upd`), NULL) AS `cancellation_date`, + IF(refst.refunded = 1, SUM(ref.`refunded_amount`), NULL) AS `cancellation_fee` + FROM `'._DB_PREFIX_.'order_return` ref + LEFT JOIN `'._DB_PREFIX_.'order_return_state` refst + ON refst.`id_order_return_state` = ref.`state` AND refst.`refunded` = 1 + GROUP BY ref.`id_order` + ) AS orf ON orf.`id_order` = a.`id_order`'; + + $this->fields_list = array_merge($this->fields_list, array( + 'email' => array( + 'title' => $this->l('Email') + ), + 'phone' => array( + 'title' => $this->l('Phone') + ), + 'room_types' => array( + 'title' => $this->l('Room Types') + ), + 'rooms' => array( + 'title' => $this->l('Rooms') + ), + 'currency' => array( + 'title' => $this->l('Currency') + ), + 'total_paid_real' => array( + 'title' => $this->l('Amount Paid') + ), + 'check_in_dates' => array( + 'title' => $this->l('Check In') + ), + 'check_out_dates' => array( + 'title' => $this->l('Check Out') + ), + 'date_from' => array( + 'title' => $this->l('Date From'), + 'filter_key' => 'hbd!date_from', + ), + 'date_to' => array( + 'title' => $this->l('Date To'), + 'filter_key' => 'hbd!date_to', + ), + 'date_add' => array( + 'title' => $this->l('Reservation Date'), + 'filter_key' => 'a!date_add', + ), + 'room_status' => array( + 'title' => $this->l('Room Status'), + ), + 'country' => array( + 'title' => $this->l('Country'), + ), + 'state' => array( + 'title' => $this->l('State'), + ), + 'city' => array( + 'title' => $this->l('City'), + ), + 'cus_address' => array( + 'title' => $this->l('Address'), + ), + 'cancellation_date' => array( + 'title' => $this->l('Cancellation date'), + ), + 'cancellation_fee' => array( + 'title' => $this->l('Cancellation fee'), + ), + )); + + unset($this->fields_list['id_status']); + unset($this->fields_list['id_room_information']); + unset($this->fields_list['room_type_name']); + unset($this->fields_list['id_currency']); + } + + parent::getList( + $id_lang, + $order_by, + $order_way, + $start, + $limit, + $id_lang_shop + ); + } + public function postProcess() { // Process reallocation of rooms diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index 80ac896f9..8473c0bca 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -201,7 +201,13 @@ class AdminProductsControllerCore extends AdminController LEFT JOIN `'._DB_PREFIX_.'address` aa ON (aa.`id_hotel` = hb.`id`) LEFT JOIN `'._DB_PREFIX_.'feature_product` fp ON (fp.`id_product` = a.`id_product`) LEFT JOIN `'._DB_PREFIX_.'htl_room_type_demand` hrtd ON (hrtd.`id_product` = a.`id_product`) - LEFT JOIN `'._DB_PREFIX_.'htl_room_type_service_product` hrtsp ON ((hrtsp.`element_type` = '.(int) RoomTypeServiceProduct::WK_ELEMENT_TYPE_HOTEL.' AND hrtsp.`id_element` = hrt.`id_hotel`) OR (hrtsp.`element_type` = '.(int) RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE.' AND hrtsp.`id_element` = a.`id_product`)) + LEFT JOIN ( + SELECT rsp.*, GROUP_CONCAT(pl.`name`) AS service_products + FROM `'._DB_PREFIX_.'htl_room_type_service_product` rsp + LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = rsp.`id_product`) + WHERE pl.`id_lang`='.$this->context->language->id.' + GROUP BY rsp.`id_element`) + AS hrtsp ON ((hrtsp.`element_type` = '.(int) RoomTypeServiceProduct::WK_ELEMENT_TYPE_HOTEL.' AND hrtsp.`id_element` = hrt.`id_hotel`) OR (hrtsp.`element_type` = '.(int) RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE.' AND hrtsp.`id_element` = a.`id_product`)) LEFT JOIN `'._DB_PREFIX_.'htl_advance_payment` hap ON (hap.`id_product` = a.`id_product`)'; $this->_select .= ' a.`show_at_front`, (SELECT COUNT(hri.`id`) FROM `'._DB_PREFIX_.'htl_room_information` hri WHERE hri.`id_product` = a.`id_product`) as num_rooms, '; @@ -290,7 +296,7 @@ class AdminProductsControllerCore extends AdminController 'validation' => 'isFloat', 'align' => 'text-left', 'filter_key' => 'a!price', - 'callback' => 'displayBasePrice', + 'callback' => 'displayPrice', ); $this->fields_list['price_final'] = array( 'title' => $this->l('Final price'), @@ -298,7 +304,8 @@ class AdminProductsControllerCore extends AdminController 'align' => 'text-left', 'havingFilter' => true, 'orderby' => false, - 'search' => false + 'search' => false, + 'callback' => 'displayPrice', ); $this->fields_list['active'] = array( @@ -326,6 +333,7 @@ class AdminProductsControllerCore extends AdminController 'align' => 'text-center', 'type' => 'bool', 'active' => 'show_at_front', + 'callback' => 'formatStatusAsLabel', 'optional' => true, 'havingFilter' => true, 'visible_default' => true, @@ -335,7 +343,7 @@ class AdminProductsControllerCore extends AdminController if (Configuration::get('WK_ALLOW_ADVANCED_PAYMENT')) { $this->fields_list['advance_payment'] = array( 'title' => $this->l('Advance Payment'), - 'callback' => 'getAdvancePaymentStatus', + 'callback' => 'formatStatusAsLabel', 'badge_success' => true, 'badge_danger' => true, 'align' => 'text-center', @@ -445,8 +453,7 @@ class AdminProductsControllerCore extends AdminController ); } } - - public function getAdvancePaymentStatus($val, $row) + public function formatStatusAsLabel($val, $row) { if ($val) { $str_return = $this->l('Yes'); @@ -470,7 +477,7 @@ class AdminProductsControllerCore extends AdminController } } - public static function displayBasePrice($basePrice, $tr) + public static function displayPrice($basePrice, $tr) { return Tools::displayPrice($basePrice, (int) Configuration::get('PS_CURRENCY_DEFAULT')); } @@ -629,6 +636,43 @@ class AdminProductsControllerCore extends AdminController $orderBy = 'id_'.$this->table; $orderWay = 'ASC'; } + if ($this->action == 'export' && empty($this->_listsql)) { + $this->_select .= ' , trg.`name` AS `id_tax_rules_group`, GROUP_CONCAT(fpl.`name`) AS `features`, hrtdl.`global_demands`'; + $this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'tax_rules_group` trg + ON trg.`id_tax_rules_group` = a.`id_tax_rules_group` + LEFT JOIN `'._DB_PREFIX_.'feature_lang` fpl + ON (fp.`id_feature` = fpl.`id_feature` AND fpl.`id_lang`='.(int) $this->context->language->id.')'; + + $this->_join .= ' LEFT JOIN (SELECT + `id_global_demand`, `id_lang`, + GROUP_CONCAT(`name`) AS `global_demands`, + GROUP_CONCAT(`id_global_demand`) + FROM `'._DB_PREFIX_.'htl_room_type_global_demand_lang` + WHERE `id_lang`='.(int) $this->context->language->id.' + GROUP BY `id_global_demand` + ) AS hrtdl ON (hrtdl.`id_global_demand` = hrtd.`id_global_demand` AND hrtdl.`id_lang`= b.`id_lang` )'; + + $this->fields_list = array_merge($this->fields_list, array( + 'id_tax_rules_group' => array( + 'title' => $this->l('Id Tax Rules group'), + 'filter_key' => 'a!id_tax_rules_group', + ), + 'features' => array( + 'title' => $this->l('Features'), + ), + 'service_products' => array( + 'title' => $this->l('Services Products'), + ), + 'global_demands' => array( + 'title' => $this->l('Additional Facilities'), + ) + ) + ); + + unset($this->fields_list['id_global_demand']); + unset($this->fields_list['id_feature']); + unset($this->fields_list['id_service_product']); + } parent::getList($id_lang, $orderBy, $orderWay, $start, $limit, $this->context->shop->id); /* update product quantity with attributes ...*/