Merge 'origin/develop' into gli-838
This commit is contained in:
@@ -344,12 +344,24 @@ class AdminAddressesControllerCore extends AdminController
|
||||
return parent::renderForm();
|
||||
}
|
||||
|
||||
// public function postProcess()
|
||||
// {
|
||||
|
||||
// $address = new Address();
|
||||
// $this->errors = $address->validateController();
|
||||
|
||||
// return parent::postProcess();
|
||||
// }
|
||||
|
||||
public function processSave()
|
||||
{
|
||||
if (Tools::getValue('submitFormAjax')) {
|
||||
$this->redirect_after = false;
|
||||
}
|
||||
|
||||
$address = new Address();
|
||||
$this->errors = $address->validateController();
|
||||
|
||||
// Transform e-mail in id_customer for parent processing
|
||||
if (Validate::isEmail(Tools::getValue('email'))) {
|
||||
$customer = new Customer();
|
||||
@@ -488,7 +500,7 @@ class AdminAddressesControllerCore extends AdminController
|
||||
$customer = Customer::searchByName($email);
|
||||
if (!empty($customer)) {
|
||||
$customer = $customer['0'];
|
||||
echo json_encode(array('infos' => pSQL($customer['firstname']).'_'.pSQL($customer['lastname']).'_'.pSQL($customer['company'])));
|
||||
echo json_encode(array('infos' => pSQL($customer['firstname']).'_'.pSQL($customer['lastname']).'_'.pSQL($customer['company']).'_'.pSQL($customer['id_customer'])));
|
||||
}
|
||||
}
|
||||
die;
|
||||
|
||||
@@ -43,17 +43,19 @@ class AdminCartsControllerCore extends AdminController
|
||||
$this->_orderWay = 'DESC';
|
||||
$this->context = Context::getContext();
|
||||
|
||||
$this->_select = 'CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) `customer`, a.id_cart total,
|
||||
IF (IFNULL(o.id_order, \''.$this->l('Non ordered').'\') = \''.$this->l('Non ordered').'\', IF(TIME_TO_SEC(TIMEDIFF(\''.pSQL(date('Y-m-d H:i:00', time())).'\', a.`date_add`)) > 86400, \''.$this->l('Abandoned cart').'\', \''.$this->l('Non ordered').'\'), o.id_order) AS status, IF(o.id_order, 1, 0) badge_success, IF(o.id_order, 0, 1) badge_danger, IF(co.id_guest, 1, 0) id_guest';
|
||||
$this->_select = 'CONCAT(c.`firstname`, \' \', c.`lastname`) `customer`, a.id_cart total,
|
||||
TIME_TO_SEC(TIMEDIFF(\''.pSQL(date('Y-m-d H:i:00', time())).'\', a.`date_add`)) AS `time_diff`,
|
||||
IFNULL(GROUP_CONCAT(o.`id_order`), 0) AS `ids_order`,
|
||||
IF (IFNULL(o.id_order, \''.$this->l('Non ordered cart').'\') = \''.$this->l('Non ordered cart').'\', IF(TIME_TO_SEC(TIMEDIFF(\''.pSQL(date('Y-m-d H:i:00', time())).'\', a.`date_add`)) > 86400, \''.$this->l('Abandoned cart').'\', \''.$this->l('Non ordered cart').'\'), GROUP_CONCAT(o.`id_order`)) AS filter_ids_order,
|
||||
IF(o.id_order, 1, 0) badge_success, IF(o.id_order, 0, 1) badge_danger, IF(co.id_guest, 1, 0) id_guest';
|
||||
$this->_join = 'LEFT JOIN '._DB_PREFIX_.'customer c ON (c.id_customer = a.id_customer)
|
||||
LEFT JOIN '._DB_PREFIX_.'currency cu ON (cu.id_currency = a.id_currency)
|
||||
LEFT JOIN '._DB_PREFIX_.'orders o ON (o.id_cart = a.id_cart)
|
||||
LEFT JOIN `'._DB_PREFIX_.'connections` co ON (a.id_guest = co.id_guest AND TIME_TO_SEC(TIMEDIFF(\''.pSQL(date('Y-m-d H:i:00', time())).'\', co.`date_add`)) < 1800)';
|
||||
$this->_group = ' GROUP BY a.`id_cart`';
|
||||
|
||||
if (Tools::getValue('action') && Tools::getValue('action') == 'filterOnlyAbandonedCarts') {
|
||||
$this->_having = 'status = \''.$this->l('Abandoned cart').'\'';
|
||||
} else {
|
||||
$this->_use_found_rows = false;
|
||||
if (Tools::getValue('action') == 'filterAbandonedCarts') {
|
||||
$this->_filterHaving = ' AND `ids_order` = 0 AND `time_diff` > 86400';
|
||||
}
|
||||
|
||||
$this->fields_list = array(
|
||||
@@ -62,11 +64,12 @@ class AdminCartsControllerCore extends AdminController
|
||||
'align' => 'text-center',
|
||||
'class' => 'fixed-width-xs'
|
||||
),
|
||||
'status' => array(
|
||||
'ids_order' => array(
|
||||
'title' => $this->l('Order ID'),
|
||||
'align' => 'text-center',
|
||||
'badge_danger' => true,
|
||||
'havingFilter' => true
|
||||
'havingFilter' => true,
|
||||
'filter_key' => 'filter_ids_order',
|
||||
'callback' => 'getOrderColumn',
|
||||
),
|
||||
'customer' => array(
|
||||
'title' => $this->l('Customer'),
|
||||
@@ -114,6 +117,29 @@ class AdminCartsControllerCore extends AdminController
|
||||
}
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->list_no_link = true;
|
||||
}
|
||||
|
||||
public function getOrderColumn($idsOrder, $tr)
|
||||
{
|
||||
$smartyVars = array();
|
||||
if ($idsOrder) {
|
||||
$idsOrder = explode(',', $idsOrder);
|
||||
$smartyVars['type'] = 'orders';
|
||||
$smartyVars['ids_order'] = $idsOrder;
|
||||
} else {
|
||||
if ($tr['time_diff'] > 86400) {
|
||||
$smartyVars['type'] = 'abandoned';
|
||||
} else {
|
||||
$smartyVars['type'] = 'non_orderd';
|
||||
}
|
||||
}
|
||||
|
||||
$tpl = $this->createTemplate('_orders.tpl');
|
||||
$tpl->assign($smartyVars);
|
||||
|
||||
return $tpl->fetch();
|
||||
}
|
||||
|
||||
public function initPageHeaderToolbar()
|
||||
@@ -200,12 +226,14 @@ class AdminCartsControllerCore extends AdminController
|
||||
Product::addCustomizationPrice($products, $customized_datas);
|
||||
$summary = $cart->getSummaryDetails();
|
||||
|
||||
/* Display order information */
|
||||
$id_order = (int)Order::getOrderByCartId($cart->id);
|
||||
$order = new Order($id_order);
|
||||
if (Validate::isLoadedObject($order)) {
|
||||
$tax_calculation_method = $order->getTaxCalculationMethod();
|
||||
$id_shop = (int)$order->id_shop;
|
||||
/* Display orders information */
|
||||
$cartOrders = Order::getAllOrdersByCartId($cart->id);
|
||||
if ($cartOrders) {
|
||||
$objOrder = new Order($cartOrders[0]['id_order']);
|
||||
if (Validate::isLoadedObject($objOrder)) {
|
||||
$tax_calculation_method = $objOrder->getTaxCalculationMethod();
|
||||
$id_shop = (int)$objOrder->id_shop;
|
||||
}
|
||||
} else {
|
||||
$id_shop = (int)$cart->id_shop;
|
||||
$tax_calculation_method = Group::getPriceDisplayMethod(Group::getCurrent()->id);
|
||||
@@ -286,7 +314,7 @@ class AdminCartsControllerCore extends AdminController
|
||||
'kpi' => $kpi,
|
||||
'products' => $products,
|
||||
'discounts' => $cart->getCartRules(),
|
||||
'order' => $order,
|
||||
'cart_orders' => $cartOrders,
|
||||
'cart' => $cart,
|
||||
'currency' => $currency,
|
||||
'customer' => $customer,
|
||||
@@ -570,12 +598,12 @@ class AdminCartsControllerCore extends AdminController
|
||||
'cart_detail_data' => $cart_detail_data,
|
||||
));
|
||||
|
||||
$tpl_path = 'default/template/controllers/orders/current_cart_details_data.tpl';
|
||||
$tpl_path = 'default/template/controllers/orders/_current_cart_details_data.tpl';
|
||||
$cart_dtl_tpl = $this->context->smarty->fetch(_PS_BO_ALL_THEMES_DIR_.$tpl_path);
|
||||
|
||||
$result = $this->ajaxReturnVars();
|
||||
$result['cart_detail_html'] = $cart_dtl_tpl;//tpl is added to the returned array
|
||||
echo json_encode($result);
|
||||
$this->ajaxDie(json_encode($result));
|
||||
}
|
||||
}
|
||||
public function ajaxProcessUpdateLang()
|
||||
@@ -923,6 +951,76 @@ class AdminCartsControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
// Process to get extra demands of any room while order creation process form.tpl
|
||||
public function ajaxProcessGetRoomTypeCartDemands()
|
||||
{
|
||||
$response = array('status' => false);
|
||||
if ($idProduct = Tools::getValue('id_product')) {
|
||||
if (($dateFrom = Tools::getValue('date_from'))
|
||||
&& ($dateTo = Tools::getValue('date_to'))
|
||||
&& ($idRoom = Tools::getValue('id_room'))
|
||||
&& ($idCart = Tools::getValue('id_cart'))
|
||||
) {
|
||||
$objCartBookingData = new HotelCartBookingData();
|
||||
if ($selectedRoomDemands = $objCartBookingData->getCartExtraDemands(
|
||||
$idCart,
|
||||
$idProduct,
|
||||
$idRoom,
|
||||
$dateFrom,
|
||||
$dateTo
|
||||
)) {
|
||||
// get room type additional demands
|
||||
$objRoomDemands = new HotelRoomTypeDemand();
|
||||
if ($roomTypeDemands = $objRoomDemands->getRoomTypeDemands($idProduct)) {
|
||||
foreach ($roomTypeDemands as &$demand) {
|
||||
// if demand has advance options then set demand price as first advance option price.
|
||||
if (isset($demand['adv_option']) && $demand['adv_option']) {
|
||||
$demand['price'] = current($demand['adv_option'])['price'];
|
||||
}
|
||||
}
|
||||
foreach ($selectedRoomDemands as &$selectedDemand) {
|
||||
$objRoom = new HotelRoomInformation($selectedDemand['id_room']);
|
||||
$selectedDemand['room_num'] = $objRoom->room_num;
|
||||
if (isset($selectedDemand['extra_demands']) && $selectedDemand['extra_demands']) {
|
||||
$extraDmd = array();
|
||||
foreach ($selectedDemand['extra_demands'] as $sDemand) {
|
||||
$selectedDemand['selected_global_demands'][] = $sDemand['id_global_demand'];
|
||||
$extraDmd[$sDemand['id_global_demand'].'-'.$sDemand['id_option']] = $sDemand;
|
||||
}
|
||||
$selectedDemand['extra_demands'] = $extraDmd;
|
||||
}
|
||||
}
|
||||
$this->context->smarty->assign('roomTypeDemands', $roomTypeDemands);
|
||||
$this->context->smarty->assign('selectedRoomDemands', $selectedRoomDemands);
|
||||
$response['status'] = true;
|
||||
$response['html_exta_demands'] = $this->context->smarty->fetch(
|
||||
_PS_ADMIN_DIR_.'/themes/default/template/controllers/orders/_cart_booking_demands.tpl'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->ajaxDie(json_encode($response));
|
||||
}
|
||||
|
||||
// Process when admin changes extra demands of any room while order creation process form.tpl
|
||||
public function ajaxProcessChangeRoomDemands()
|
||||
{
|
||||
$response = array('status' => false);
|
||||
if ($idCartBooking = Tools::getValue('id_cart_booking')) {
|
||||
if (Validate::isLoadedObject($objCartbookingCata = new HotelCartBookingData($idCartBooking))) {
|
||||
$roomDemands = Tools::getValue('room_demands');
|
||||
$roomDemands = json_decode($roomDemands, true);
|
||||
$roomDemands = json_encode($roomDemands);
|
||||
$objCartbookingCata->extra_demands = $roomDemands;
|
||||
if ($objCartbookingCata->save()) {
|
||||
$response['status'] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->ajaxDie(json_encode($response));
|
||||
}
|
||||
|
||||
public static function getOrderTotalUsingTaxCalculationMethod($id_cart)
|
||||
{
|
||||
$context = Context::getContext();
|
||||
@@ -973,7 +1071,7 @@ class AdminCartsControllerCore extends AdminController
|
||||
$skip_list = array();
|
||||
|
||||
foreach ($this->_list as $row) {
|
||||
if (isset($row['id_order']) && is_numeric($row['id_order'])) {
|
||||
if (isset($row['ids_order']) && $row['ids_order'] != '0') {
|
||||
$skip_list[] = $row['id_cart'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ class AdminContactsControllerCore extends AdminController
|
||||
'required' => false,
|
||||
'class' => 't',
|
||||
'is_bool' => true,
|
||||
'hint' => $this->l('If enabled, all messages will be saved in the "Customer Service" page under the "Customer" menu.'),
|
||||
'hint' => $this->l('If enabled, all messages will be saved in the "Customer Service" page under the "Customers" menu.'),
|
||||
'values' => array(
|
||||
array(
|
||||
'id' => 'customer_service_on',
|
||||
|
||||
@@ -513,7 +513,6 @@ class AdminCustomerThreadsControllerCore extends AdminController
|
||||
$helper->id = 'box-pending-messages';
|
||||
$helper->icon = 'icon-envelope';
|
||||
$helper->color = 'color1';
|
||||
$helper->href = $this->context->link->getAdminLink('AdminCustomerThreads');
|
||||
$helper->title = $this->l('Pending Discussion Threads', null, null, false);
|
||||
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=pending_messages';
|
||||
$kpis[] = $helper->generate();
|
||||
|
||||
@@ -26,6 +26,9 @@
|
||||
|
||||
class AdminDashboardControllerCore extends AdminController
|
||||
{
|
||||
|
||||
const DASHBOARD_RECOMMENDATION_CONTENT = '/cache/dashboard_recommendation.html';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->bootstrap = true;
|
||||
@@ -70,13 +73,11 @@ class AdminDashboardControllerCore extends AdminController
|
||||
{
|
||||
$forms = array();
|
||||
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
|
||||
$carriers = Carrier::getCarriers($this->context->language->id, true, false, false, null, 'ALL_CARRIERS');
|
||||
$modules = Module::getModulesOnDisk(true);
|
||||
|
||||
$forms = array(
|
||||
'net_profit' => array('title' => $this->l('Net Profit settings'), 'id' => 'net_profit'),
|
||||
'payment' => array('title' => $this->l('Average bank fees per payment method'), 'id' => 'payment'),
|
||||
'carriers' => array('title' => $this->l('Average shipping fees per shipping method'), 'id' => 'carriers'),
|
||||
'other' => array('title' => $this->l('Other settings'), 'id' => 'other')
|
||||
);
|
||||
foreach ($forms as &$form) {
|
||||
$form['icon'] = 'tab-preferences';
|
||||
@@ -133,32 +134,9 @@ class AdminDashboardControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($carriers as $carrier) {
|
||||
$forms['carriers']['fields']['CONF_'.strtoupper($carrier['id_reference']).'_SHIP'] = array(
|
||||
'title' => $carrier['name'],
|
||||
'desc' => sprintf($this->l('For the carrier named %s, indicate the domestic delivery costs in percentage of the price charged to customers.'), $carrier['name']),
|
||||
'validation' => 'isPercentage',
|
||||
'cast' => 'floatval',
|
||||
'type' => 'text',
|
||||
'defaultValue' => '0',
|
||||
'suffix' => '%'
|
||||
);
|
||||
$forms['carriers']['fields']['CONF_'.strtoupper($carrier['id_reference']).'_SHIP_OVERSEAS'] = array(
|
||||
'title' => $carrier['name'],
|
||||
'desc' => sprintf($this->l('For the carrier named %s, indicate the overseas delivery costs in percentage of the price charged to customers.'), $carrier['name']),
|
||||
'validation' => 'isPercentage',
|
||||
'cast' => 'floatval',
|
||||
'type' => 'text',
|
||||
'defaultValue' => '0',
|
||||
'suffix' => '%'
|
||||
);
|
||||
}
|
||||
|
||||
$forms['carriers']['description'] = $this->l('Method: Indicate the percentage of your carrier margin. For example, if you charge $10 of shipping fees to your customer for each shipment, but you really pay $4 to this carrier, then you should indicate "40" in the percentage field.');
|
||||
|
||||
$forms['other']['fields']['CONF_AVERAGE_PRODUCT_MARGIN'] = array(
|
||||
$forms['net_profit']['fields']['CONF_AVERAGE_PRODUCT_MARGIN'] = array(
|
||||
'title' => $this->l('Average gross margin percentage'),
|
||||
'desc' => $this->l('You should calculate this percentage as follows: ((total sales revenue) - (cost of goods sold)) / (total sales revenue) * 100. This value is only used to calculate the Dashboard approximate gross margin, if you do not specify the wholesale price for each product.'),
|
||||
'desc' => $this->l('You should calculate this percentage as follows: ((total sales revenue) - (total operating cost)) / (total sales revenue) * 100. This value is only used to calculate Dashboard approximate gross margin, if you do not specify operating cost for each room type.'),
|
||||
'validation' => 'isPercentage',
|
||||
'cast' => 'intval',
|
||||
'type' => 'text',
|
||||
@@ -166,7 +144,7 @@ class AdminDashboardControllerCore extends AdminController
|
||||
'suffix' => '%'
|
||||
);
|
||||
|
||||
$forms['other']['fields']['CONF_ORDER_FIXED'] = array(
|
||||
$forms['net_profit']['fields']['CONF_ORDER_FIXED'] = array(
|
||||
'title' => $this->l('Other fees per order'),
|
||||
'desc' => $this->l('You should calculate this value by making the sum of all of your additional costs per order.'),
|
||||
'validation' => 'isPrice',
|
||||
@@ -260,6 +238,11 @@ class AdminDashboardControllerCore extends AdminController
|
||||
$calendar_helper->setCompareDateTo($stats_compare_to);
|
||||
$calendar_helper->setCompareOption(Tools::getValue('compare_date_option', $this->context->employee->stats_compare_option));
|
||||
|
||||
Media::addJsDef(array(
|
||||
'date_subtitle' => $this->l('(from %s to %s)'),
|
||||
'date_format' => $this->context->language->date_format_lite,
|
||||
));
|
||||
|
||||
$params = array(
|
||||
'date_from' => $this->context->employee->stats_date_from,
|
||||
'date_to' => $this->context->employee->stats_date_to,
|
||||
@@ -277,6 +260,15 @@ class AdminDashboardControllerCore extends AdminController
|
||||
'hotel_name' => $objHotelBranchInfo->hotel_name.', '.$hotelAddressInfo['city'],
|
||||
);
|
||||
}
|
||||
|
||||
if (file_exists(_PS_ROOT_DIR_.Upgrader::CACHE_FILE_UPGRADE_AVAILABE)) {
|
||||
$content = Tools::file_get_contents( _PS_ROOT_DIR_.Upgrader::CACHE_FILE_UPGRADE_AVAILABE);
|
||||
$upgradeInfo = simplexml_load_string($content);
|
||||
$this->context->smarty->assign(array(
|
||||
'upgrade_info' => $upgradeInfo
|
||||
));
|
||||
}
|
||||
|
||||
$this->tpl_view_vars = array(
|
||||
'date_from' => $this->context->employee->stats_date_from,
|
||||
'date_to' => $this->context->employee->stats_date_to,
|
||||
@@ -289,13 +281,13 @@ class AdminDashboardControllerCore extends AdminController
|
||||
//'translations' => $translations,
|
||||
'action' => self::$currentIndex.'&token='.$this->token,
|
||||
'warning' => $this->getWarningDomainName(),
|
||||
'new_version_url' => Tools::getCurrentUrlProtocolPrefix()._PS_API_DOMAIN_.'/version/check_version.php?v='._PS_VERSION_.'&lang='.$this->context->language->iso_code.'&autoupgrade='.(int)(Module::isInstalled('autoupgrade') && Module::isEnabled('autoupgrade')).'&hosted_mode='.(int)defined('_PS_HOST_MODE_'),
|
||||
'new_version_url' => Tools::getCurrentUrlProtocolPrefix()._QLO_API_DOMAIN_.'/index.php?version='._QLOAPPS_VERSION_.'&lang='.$this->context->language->iso_code.'&method=check-version&autoupgrade='.(int)(Module::isInstalled('qloautoupgrade') && Module::isEnabled('qloautoupgrade')).'&hosted_mode='.(int)defined('_PS_HOST_MODE_'),
|
||||
'dashboard_use_push' => Configuration::get('PS_DASHBOARD_USE_PUSH'),
|
||||
'calendar' => $calendar_helper->generate(),
|
||||
'PS_DASHBOARD_SIMULATION' => Configuration::get('PS_DASHBOARD_SIMULATION'),
|
||||
'datepickerFrom' => Tools::getValue('datepickerFrom', $this->context->employee->stats_date_from),
|
||||
'datepickerTo' => Tools::getValue('datepickerTo', $this->context->employee->stats_date_to),
|
||||
'preselect_date_range' => Tools::getValue('preselectDateRange', $this->context->employee->preselect_date_range)
|
||||
'preselect_date_range' => Tools::getValue('preselectDateRange', $this->context->employee->preselect_date_range),
|
||||
);
|
||||
return parent::renderView();
|
||||
}
|
||||
@@ -406,7 +398,7 @@ class AdminDashboardControllerCore extends AdminController
|
||||
public function ajaxProcessGetBlogRss()
|
||||
{
|
||||
$return = array('has_errors' => false, 'rss' => array());
|
||||
if (!$this->isFresh('/config/xml/blog-'.$this->context->language->iso_code.'.xml', 86400)) {
|
||||
if (!$this->isFresh('/config/xml/blog-'.$this->context->language->iso_code.'.xml', _TIME_1_DAY_)) {
|
||||
if (!$this->refresh('/config/xml/blog-'.$this->context->language->iso_code.'.xml', _PS_API_URL_.'/rss/blog/blog-'.$this->context->language->iso_code.'.xml')) {
|
||||
$return['has_errors'] = true;
|
||||
}
|
||||
@@ -501,4 +493,25 @@ class AdminDashboardControllerCore extends AdminController
|
||||
|
||||
die(json_encode($return));
|
||||
}
|
||||
|
||||
public function ajaxProcessGetRecommendationContent()
|
||||
{
|
||||
$response = array('success' => false);
|
||||
if ($content = $this->getRecommendationContent()) {
|
||||
$response['success'] = true;
|
||||
$response['content'] = $content;
|
||||
}
|
||||
$this->ajaxDie(json_encode($response));
|
||||
}
|
||||
|
||||
public function getRecommendationContent()
|
||||
{
|
||||
if (!$this->isFresh(self::DASHBOARD_RECOMMENDATION_CONTENT, _TIME_1_DAY_)) {
|
||||
@file_put_contents(_PS_ROOT_DIR_.self::DASHBOARD_RECOMMENDATION_CONTENT, Tools::addonsRequest('dashboard-recommendation'));
|
||||
}
|
||||
if (file_exists(_PS_ROOT_DIR_.self::DASHBOARD_RECOMMENDATION_CONTENT)) {
|
||||
return Tools::file_get_contents(_PS_ROOT_DIR_.self::DASHBOARD_RECOMMENDATION_CONTENT);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,7 +278,6 @@ class AdminEmailsControllerCore extends AdminController
|
||||
$this->initTabModuleList();
|
||||
$this->initToolbar();
|
||||
$this->initPageHeaderToolbar();
|
||||
$this->addToolBarModulesListButton();
|
||||
unset($this->toolbar_btn['save']);
|
||||
$back = $this->context->link->getAdminLink('AdminDashboard');
|
||||
|
||||
|
||||
@@ -52,20 +52,52 @@ class AdminImagesControllerCore extends AdminController
|
||||
);
|
||||
|
||||
$this->fields_list = array(
|
||||
'id_image_type' => array('title' => $this->l('ID'), 'align' => 'center', 'class' => 'fixed-width-xs'),
|
||||
'name' => array('title' => $this->l('Name')),
|
||||
'width' => array('title' => $this->l('Width'), 'suffix' => ' px'),
|
||||
'height' => array('title' => $this->l('Height'), 'suffix' => ' px'),
|
||||
'products' => array('title' => $this->l('Products'), 'align' => 'center', 'type' => 'bool', 'callback' => 'printEntityActiveIcon', 'orderby' => false),
|
||||
'categories' => array('title' => $this->l('Categories'), 'align' => 'center', 'type' => 'bool', 'callback' => 'printEntityActiveIcon', 'orderby' => false),
|
||||
// 'manufacturers' => array('title' => $this->l('Manufacturers'), 'align' => 'center', 'type' => 'bool', 'callback' => 'printEntityActiveIcon', 'orderby' => false),
|
||||
// 'suppliers' => array('title' => $this->l('Suppliers'), 'align' => 'center', 'type' => 'bool', 'callback' => 'printEntityActiveIcon', 'orderby' => false),
|
||||
// 'stores' => array('title' => $this->l('Stores'), 'align' => 'center', 'type' => 'bool', 'callback' => 'printEntityActiveIcon', 'orderby' => false)
|
||||
'id_image_type' => array(
|
||||
'title' => $this->l('ID'),
|
||||
'align' => 'center',
|
||||
'class' => 'fixed-width-xs'
|
||||
),
|
||||
'name' => array(
|
||||
'title' => $this->l('Name'),
|
||||
'align' => 'left'
|
||||
),
|
||||
'width' => array(
|
||||
'title' => $this->l('Width'),
|
||||
'suffix' => ' px'
|
||||
),
|
||||
'height' => array(
|
||||
'title' => $this->l('Height'),
|
||||
'suffix' => ' px'
|
||||
),
|
||||
'products' => array(
|
||||
'title' => $this->l('Room Types/Products'),
|
||||
'align' => 'center',
|
||||
'type' => 'bool',
|
||||
'active' => 'products',
|
||||
'ajax' => true,
|
||||
'orderby' => false
|
||||
),
|
||||
'categories' => array(
|
||||
'title' => $this->l('Categories'),
|
||||
'align' => 'center',
|
||||
'type' => 'bool',
|
||||
'active' => 'categories',
|
||||
'ajax' => true,
|
||||
'orderby' => false
|
||||
),
|
||||
'hotels' => array(
|
||||
'title' => $this->l('Hotels'),
|
||||
'align' => 'center',
|
||||
'type' => 'bool',
|
||||
'active' => 'hotels',
|
||||
'ajax' => true,
|
||||
'orderby' => false
|
||||
),
|
||||
);
|
||||
|
||||
// Scenes tab has been removed by default from the installation, but may still exists in updates
|
||||
if (Tab::getIdFromClassName('AdminScenes')) {
|
||||
$this->fields_list['scenes'] = array('title' => $this->l('Scenes'), 'align' => 'center', 'type' => 'bool', 'callback' => 'printEntityActiveIcon', 'orderby' => false);
|
||||
$this->fields_list['scenes'] = array('title' => $this->l('Scenes'), 'align' => 'center', 'type' => 'bool', 'orderby' => false);
|
||||
}
|
||||
|
||||
// No need to display the old image system migration tool except if product images are in _PS_PROD_IMG_DIR_
|
||||
@@ -228,7 +260,7 @@ class AdminImagesControllerCore extends AdminController
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Products'),
|
||||
'label' => $this->l('Room Types/Products'),
|
||||
'name' => 'products',
|
||||
'required' => false,
|
||||
'is_bool' => true,
|
||||
@@ -267,6 +299,26 @@ class AdminImagesControllerCore extends AdminController
|
||||
),
|
||||
)
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Hotels'),
|
||||
'name' => 'hotels',
|
||||
'required' => false,
|
||||
'is_bool' => true,
|
||||
'hint' => $this->l('This type will be used for Hotel images.'),
|
||||
'values' => array(
|
||||
array(
|
||||
'id' => 'hotels_on',
|
||||
'value' => 1,
|
||||
'label' => $this->l('Enabled')
|
||||
),
|
||||
array(
|
||||
'id' => 'hotels_off',
|
||||
'value' => 0,
|
||||
'label' => $this->l('Disabled')
|
||||
),
|
||||
)
|
||||
),
|
||||
// array(
|
||||
// 'type' => 'switch',
|
||||
// 'label' => $this->l('Manufacturers'),
|
||||
@@ -307,27 +359,27 @@ class AdminImagesControllerCore extends AdminController
|
||||
// ),
|
||||
// )
|
||||
// ),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Scenes'),
|
||||
'name' => 'scenes',
|
||||
'required' => false,
|
||||
'class' => 't',
|
||||
'is_bool' => true,
|
||||
'hint' => $this->l('This type will be used for Scene images.'),
|
||||
'values' => array(
|
||||
array(
|
||||
'id' => 'scenes_on',
|
||||
'value' => 1,
|
||||
'label' => $this->l('Enabled')
|
||||
),
|
||||
array(
|
||||
'id' => 'scenes_off',
|
||||
'value' => 0,
|
||||
'label' => $this->l('Disabled')
|
||||
),
|
||||
)
|
||||
),
|
||||
// array(
|
||||
// 'type' => 'switch',
|
||||
// 'label' => $this->l('Scenes'),
|
||||
// 'name' => 'scenes',
|
||||
// 'required' => false,
|
||||
// 'class' => 't',
|
||||
// 'is_bool' => true,
|
||||
// 'hint' => $this->l('This type will be used for Scene images.'),
|
||||
// 'values' => array(
|
||||
// array(
|
||||
// 'id' => 'scenes_on',
|
||||
// 'value' => 1,
|
||||
// 'label' => $this->l('Enabled')
|
||||
// ),
|
||||
// array(
|
||||
// 'id' => 'scenes_off',
|
||||
// 'value' => 0,
|
||||
// 'label' => $this->l('Disabled')
|
||||
// ),
|
||||
// )
|
||||
// ),
|
||||
// array(
|
||||
// 'type' => 'switch',
|
||||
// 'label' => $this->l('Stores'),
|
||||
@@ -357,6 +409,29 @@ class AdminImagesControllerCore extends AdminController
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function ajaxProcess()
|
||||
{
|
||||
$response = array('success' => false);
|
||||
if ($action = Tools::getValue('action')) {
|
||||
$action = str_replace('image_type', '', $action);
|
||||
$fields = ObjectModel::getDefinition($this->className)['fields'];
|
||||
if (array_key_exists($action, $fields)) {
|
||||
$idImageType = Tools::getValue('id_image_type');
|
||||
if (Validate::isLoadedObject($objImageType = new ImageType($idImageType))) {
|
||||
$objImageType->$action = !$objImageType->$action;
|
||||
if ($objImageType->save()) {
|
||||
$response['success'] = true;
|
||||
$response['text'] = $this->l('Updated successfully.');
|
||||
} else {
|
||||
$response['text'] = $this->l('An error occurred while updating image type for .'.$action);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->ajaxDie(json_encode($response));
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
// When moving images, if duplicate images were found they are moved to a folder named duplicates/
|
||||
@@ -404,11 +479,6 @@ class AdminImagesControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
public static function printEntityActiveIcon($value, $object)
|
||||
{
|
||||
return ($value ? '<span class="list-action-enable action-enabled"><i class="icon-check"></i></span>' : '<span class="list-action-enable action-disabled"><i class="icon-remove"></i></span>');
|
||||
}
|
||||
|
||||
protected function _childValidation()
|
||||
{
|
||||
if (!Tools::getValue('id_image_type') && Validate::isImageTypeName($typeName = Tools::getValue('name')) && ImageType::typeAlreadyExists($typeName)) {
|
||||
@@ -423,11 +493,12 @@ class AdminImagesControllerCore extends AdminController
|
||||
{
|
||||
$types = array(
|
||||
'categories' => $this->l('Categories'),
|
||||
'manufacturers' => $this->l('Manufacturers'),
|
||||
'suppliers' => $this->l('Suppliers'),
|
||||
'scenes' => $this->l('Scenes'),
|
||||
'products' => $this->l('Products'),
|
||||
'stores' => $this->l('Stores')
|
||||
'products' => $this->l('Room Types/Products'),
|
||||
'hotels' => $this->l('Hotels'),
|
||||
// 'manufacturers' => $this->l('Manufacturers'),
|
||||
// 'suppliers' => $this->l('Suppliers'),
|
||||
// 'scenes' => $this->l('Scenes'),
|
||||
// 'stores' => $this->l('Stores')
|
||||
);
|
||||
|
||||
$formats = array();
|
||||
@@ -455,19 +526,6 @@ class AdminImagesControllerCore extends AdminController
|
||||
if (!is_dir($dir)) {
|
||||
return false;
|
||||
}
|
||||
$toDel = scandir($dir);
|
||||
|
||||
foreach ($toDel as $d) {
|
||||
foreach ($type as $imageType) {
|
||||
if (preg_match('/^[0-9]+\-'.($product ? '[0-9]+\-' : '').$imageType['name'].'\.jpg$/', $d)
|
||||
|| (count($type) > 1 && preg_match('/^[0-9]+\-[_a-zA-Z0-9-]*\.jpg$/', $d))
|
||||
|| preg_match('/^([[:lower:]]{2})\-default\-'.$imageType['name'].'\.jpg$/', $d)) {
|
||||
if (file_exists($dir.$d)) {
|
||||
unlink($dir.$d);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// delete product images using new filesystem.
|
||||
if ($product) {
|
||||
@@ -488,6 +546,25 @@ class AdminImagesControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$toDel = scandir($dir);
|
||||
foreach ($toDel as $d) {
|
||||
if ($d === '.' || $d === '..') {
|
||||
continue;
|
||||
}
|
||||
if (is_dir($dir.$d)) {
|
||||
$this->_deleteOldImages($dir.$d.'/', $type, $product);
|
||||
}
|
||||
foreach ($type as $imageType) {
|
||||
if (preg_match('/^[0-9]+\-'.($product ? '[0-9]+\-' : '').$imageType['name'].'\.jpg$/', $d)
|
||||
|| (count($type) > 1 && preg_match('/^[0-9]+\-[_a-zA-Z0-9-]*\.jpg$/', $d))
|
||||
|| preg_match('/^([[:lower:]]{2})\-default\-'.$imageType['name'].'\.jpg$/', $d)) {
|
||||
if (file_exists($dir.$d)) {
|
||||
unlink($dir.$d);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -499,15 +576,67 @@ class AdminImagesControllerCore extends AdminController
|
||||
* @param bool $productsImages
|
||||
* @return bool|string
|
||||
*/
|
||||
protected function _regenerateNewImages($dir, $type, $productsImages = false)
|
||||
protected function _regenerateNewImages($dir, $type, $imageElement = false)
|
||||
{
|
||||
if (!is_dir($dir)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$generate_hight_dpi_images = (bool)Configuration::get('PS_HIGHT_DPI');
|
||||
if ($imageElement == 'products') {
|
||||
foreach (Image::getAllImages() as $image) {
|
||||
$imageObj = new Image($image['id_image']);
|
||||
$existing_img = $dir.$imageObj->getExistingImgPath().'.jpg';
|
||||
if (file_exists($existing_img) && filesize($existing_img)) {
|
||||
foreach ($type as $imageType) {
|
||||
if (!file_exists($dir.$imageObj->getExistingImgPath().'-'.stripslashes($imageType['name']).'.jpg')) {
|
||||
if (!ImageManager::resize($existing_img, $dir.$imageObj->getExistingImgPath().'-'.stripslashes($imageType['name']).'.jpg', (int)$imageType['width'], (int)$imageType['height'])) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Original image is corrupt (%s) for product ID %2$d or bad permission on folder'), $existing_img, (int)$imageObj->id_product);
|
||||
}
|
||||
|
||||
if (!$productsImages) {
|
||||
if ($generate_hight_dpi_images) {
|
||||
if (!ImageManager::resize($existing_img, $dir.$imageObj->getExistingImgPath().'-'.stripslashes($imageType['name']).'2x.jpg', (int)$imageType['width']*2, (int)$imageType['height']*2)) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Original image is corrupt (%s) for product ID %2$d or bad permission on folder'), $existing_img, (int)$imageObj->id_product);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = sprintf(Tools::displayError('Original image is missing or empty (%1$s) for product ID %2$d'), $existing_img, (int)$imageObj->id_product);
|
||||
}
|
||||
if (time() - $this->start_time > $this->max_execution_time - 4) { // stop 4 seconds before the tiemout, just enough time to process the end of the page on a slow server
|
||||
return 'timeout';
|
||||
}
|
||||
}
|
||||
} elseif ($imageElement == 'hotels') {
|
||||
$objHotelImage = new HotelImage();
|
||||
foreach($objHotelImage->getAllImages() as $image) {
|
||||
$objHotelImage = new HotelImage($image['id']);
|
||||
$existing_img = $dir.$objHotelImage->getImagePath().'.jpg';
|
||||
|
||||
if (file_exists($existing_img) && filesize($existing_img)) {
|
||||
foreach ($type as $imageType) {
|
||||
if (!file_exists($dir.$objHotelImage->getImagePath().'-'.stripslashes($imageType['name']).'.jpg')) {
|
||||
if (!ImageManager::resize($existing_img, $dir.$objHotelImage->getImagePath().'-'.stripslashes($imageType['name']).'.jpg', (int)$imageType['width'], (int)$imageType['height'])) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Original image is corrupt (%s) for hotel ID %2$d or bad permission on folder'), $existing_img, (int)$objHotelImage->id_hotel);
|
||||
}
|
||||
|
||||
if ($generate_hight_dpi_images) {
|
||||
if (!ImageManager::resize($existing_img, $dir.$objHotelImage->getImagePath().'-'.stripslashes($imageType['name']).'2x.jpg', (int)$imageType['width']*2, (int)$imageType['height']*2)) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Original image is corrupt (%s) for hotel ID %2$d or bad permission on folder'), $existing_img, (int)$objHotelImage->id_hotel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = sprintf(Tools::displayError('Original image is missing or empty (%1$s) for hotel ID %2$d'), $existing_img, (int)$objHotelImage->id_hotel);
|
||||
}
|
||||
if (time() - $this->start_time > $this->max_execution_time - 4) { // stop 4 seconds before the tiemout, just enough time to process the end of the page on a slow server
|
||||
return 'timeout';
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
$formated_thumb_scene = ImageType::getFormatedName('thumb_scene');
|
||||
$formated_medium = ImageType::getFormatedName('medium');
|
||||
foreach (scandir($dir) as $image) {
|
||||
@@ -546,31 +675,6 @@ class AdminImagesControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach (Image::getAllImages() as $image) {
|
||||
$imageObj = new Image($image['id_image']);
|
||||
$existing_img = $dir.$imageObj->getExistingImgPath().'.jpg';
|
||||
if (file_exists($existing_img) && filesize($existing_img)) {
|
||||
foreach ($type as $imageType) {
|
||||
if (!file_exists($dir.$imageObj->getExistingImgPath().'-'.stripslashes($imageType['name']).'.jpg')) {
|
||||
if (!ImageManager::resize($existing_img, $dir.$imageObj->getExistingImgPath().'-'.stripslashes($imageType['name']).'.jpg', (int)$imageType['width'], (int)$imageType['height'])) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Original image is corrupt (%s) for product ID %2$d or bad permission on folder'), $existing_img, (int)$imageObj->id_product);
|
||||
}
|
||||
|
||||
if ($generate_hight_dpi_images) {
|
||||
if (!ImageManager::resize($existing_img, $dir.$imageObj->getExistingImgPath().'-'.stripslashes($imageType['name']).'2x.jpg', (int)$imageType['width']*2, (int)$imageType['height']*2)) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Original image is corrupt (%s) for product ID %2$d or bad permission on folder'), $existing_img, (int)$imageObj->id_product);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = sprintf(Tools::displayError('Original image is missing or empty (%1$s) for product ID %2$d'), $existing_img, (int)$imageObj->id_product);
|
||||
}
|
||||
if (time() - $this->start_time > $this->max_execution_time - 4) { // stop 4 seconds before the tiemout, just enough time to process the end of the page on a slow server
|
||||
return 'timeout';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (bool)count($this->errors);
|
||||
@@ -649,11 +753,8 @@ class AdminImagesControllerCore extends AdminController
|
||||
|
||||
$process = array(
|
||||
array('type' => 'categories', 'dir' => _PS_CAT_IMG_DIR_),
|
||||
array('type' => 'manufacturers', 'dir' => _PS_MANU_IMG_DIR_),
|
||||
array('type' => 'suppliers', 'dir' => _PS_SUPP_IMG_DIR_),
|
||||
array('type' => 'scenes', 'dir' => _PS_SCENE_IMG_DIR_),
|
||||
array('type' => 'products', 'dir' => _PS_PROD_IMG_DIR_),
|
||||
array('type' => 'stores', 'dir' => _PS_STORE_IMG_DIR_)
|
||||
array('type' => 'hotels', 'dir' => _PS_HOTEL_IMG_DIR_),
|
||||
);
|
||||
|
||||
// Launching generation process
|
||||
@@ -678,7 +779,7 @@ class AdminImagesControllerCore extends AdminController
|
||||
if ($deleteOldImages) {
|
||||
$this->_deleteOldImages($proc['dir'], $formats, ($proc['type'] == 'products' ? true : false));
|
||||
}
|
||||
if (($return = $this->_regenerateNewImages($proc['dir'], $formats, ($proc['type'] == 'products' ? true : false))) === true) {
|
||||
if (($return = $this->_regenerateNewImages($proc['dir'], $formats, $proc['type'])) === true) {
|
||||
if (!count($this->errors)) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Cannot write images for this type: %s. Please check the %s folder\'s writing permissions.'), $proc['type'], $proc['dir']);
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ class AdminLogsControllerCore extends AdminController
|
||||
'fields' => array(
|
||||
'PS_LOGS_BY_EMAIL' => array(
|
||||
'title' => $this->l('Minimum severity level'),
|
||||
'hint' => $this->l('Enter "5" if you do not want to receive any emails.').'<br />'.$this->l('Emails will be sent to the shop owner.'),
|
||||
'hint' => $this->l('Enter "5" if you do not want to receive any emails.').'<br />'.$this->l('Emails will be sent to the website owner.'),
|
||||
'cast' => 'intval',
|
||||
'type' => 'text'
|
||||
)
|
||||
@@ -95,7 +95,7 @@ class AdminLogsControllerCore extends AdminController
|
||||
)
|
||||
);
|
||||
$this->list_no_link = true;
|
||||
$this->_select .= 'CONCAT(LEFT(e.firstname, 1), \'. \', e.lastname) employee';
|
||||
$this->_select .= 'CONCAT(e.firstname, \' \', e.lastname) employee';
|
||||
$this->_join .= ' LEFT JOIN '._DB_PREFIX_.'employee e ON (a.id_employee = e.id_employee)';
|
||||
$this->_use_found_rows = false;
|
||||
parent::__construct();
|
||||
@@ -124,8 +124,8 @@ class AdminLogsControllerCore extends AdminController
|
||||
$template = $this->context->smarty->createTemplate('controllers/logs/employee_field.tpl', $this->context->smarty);
|
||||
$employee = new Employee((int)$tr['id_employee']);
|
||||
$template->assign(array(
|
||||
'employee_image' => $employee->getImage(),
|
||||
'employee_name' => $value
|
||||
'employee_name' => $value,
|
||||
'employee_email' => $employee->email,
|
||||
));
|
||||
return $template->fetch();
|
||||
}
|
||||
|
||||
@@ -48,6 +48,14 @@ class AdminMaintenanceControllerCore extends AdminController
|
||||
'cast' => 'intval',
|
||||
'type' => 'bool'
|
||||
),
|
||||
'PS_ALLOW_EMP' => array(
|
||||
'title' => $this->l('Allow Employees'),
|
||||
'desc' => $this->l('Allow the employees to access the site using email and password.'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'type' => 'bool',
|
||||
'class' => "hello"
|
||||
),
|
||||
'PS_MAINTENANCE_IP' => array(
|
||||
'title' => $this->l('Maintenance IP'),
|
||||
'hint' => $this->l('IP addresses allowed to access the front office even if the site is disabled. Please use a comma to separate them (e.g. 42.24.4.2,127.0.0.1,99.98.97.96)'),
|
||||
@@ -60,4 +68,10 @@ class AdminMaintenanceControllerCore extends AdminController
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
$this->addJS(_PS_JS_DIR_.'maintenance.js');
|
||||
}
|
||||
}
|
||||
|
||||
332
controllers/admin/AdminModulesCatalogController.php
Normal file
332
controllers/admin/AdminModulesCatalogController.php
Normal file
@@ -0,0 +1,332 @@
|
||||
<?php
|
||||
/**
|
||||
* 2010-2020 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 2010-2020 Webkul IN
|
||||
* @license https://store.webkul.com/license.html
|
||||
*/
|
||||
|
||||
class AdminModulesCatalogControllerCore extends AdminController
|
||||
{
|
||||
|
||||
public $modules;
|
||||
|
||||
const CATALOG_RECOMMENDATION_CONTENT = '/cache/catalog_recommendation.html';
|
||||
|
||||
const ELEMENT_TYPE_MODULE = 1;
|
||||
const ELEMENT_TYPE_THEME = 2;
|
||||
|
||||
const MODULES_PER_PAGE = 18;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->bootstrap = true;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
$this->initSuggestedModulesList();
|
||||
}
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
parent::initContent();
|
||||
|
||||
$suggestedModules = Module::getSuggestedModules();
|
||||
|
||||
$modulesToAdd = array();
|
||||
$dirModules = ModuleCore::getModulesOnDisk();
|
||||
$modules_name = array_column($suggestedModules, 'name');
|
||||
foreach ($dirModules as $mod) {
|
||||
if (($id = array_search($mod->name, $modules_name)) !== false) {
|
||||
if ($mod->installed) {
|
||||
unset($suggestedModules[$id]);
|
||||
} else {
|
||||
$suggestedModules[$id]->not_on_disk = false;
|
||||
}
|
||||
} else {
|
||||
if (!$mod->installed) {
|
||||
$modulesToAdd[] = $mod;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$modules = array_merge($suggestedModules, $modulesToAdd);
|
||||
|
||||
$link_admin_modules = $this->context->link->getAdminLink('AdminModules', true);
|
||||
foreach ($modules as $key => $module) {
|
||||
$module->options['install_url'] = $link_admin_modules.'&install='.urlencode($module->name).'&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor='.ucfirst($module->name);
|
||||
$module->element_type = self::ELEMENT_TYPE_MODULE;
|
||||
$module->logo = '../../img/questionmark.png';
|
||||
|
||||
if (@filemtime(_PS_ROOT_DIR_.DIRECTORY_SEPARATOR.basename(_PS_MODULE_DIR_).DIRECTORY_SEPARATOR.$module->name
|
||||
.DIRECTORY_SEPARATOR.'logo.gif')) {
|
||||
$module->logo = 'logo.gif';
|
||||
}
|
||||
if (@filemtime(_PS_ROOT_DIR_.DIRECTORY_SEPARATOR.basename(_PS_MODULE_DIR_).DIRECTORY_SEPARATOR.$module->name
|
||||
.DIRECTORY_SEPARATOR.'logo.png')) {
|
||||
$module->logo = 'logo.png';
|
||||
}
|
||||
|
||||
$modules[$key] = $module;
|
||||
}
|
||||
|
||||
$this->sortList($modules, 'module');
|
||||
$this->modules = $modules;
|
||||
|
||||
$this->themes = $this->getSuggestedThemes();
|
||||
|
||||
$this->assignSortCriteria();
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'modules' => $this->modules,
|
||||
'themes' => $this->themes,
|
||||
'modules_uri' => __PS_BASE_URI__.basename(_PS_MODULE_DIR_),
|
||||
'element_type_module' => self::ELEMENT_TYPE_MODULE,
|
||||
'element_type_theme' => self::ELEMENT_TYPE_THEME,
|
||||
|
||||
));
|
||||
}
|
||||
|
||||
public function initModal()
|
||||
{
|
||||
parent::initModal();
|
||||
|
||||
$modal_content = $this->context->smarty->fetch('controllers/modules/'.(($this->context->mode == Context::MODE_HOST) ? 'modal_not_trusted_blocked.tpl' : 'modal_not_trusted.tpl'));
|
||||
$this->modals[] = array(
|
||||
'modal_id' => 'moduleNotTrusted',
|
||||
'modal_class' => 'modal-lg',
|
||||
'modal_title' => ($this->context->mode == Context::MODE_HOST) ? $this->l('This module cannot be installed') : $this->l('Important Notice'),
|
||||
'modal_content' => $modal_content
|
||||
);
|
||||
}
|
||||
|
||||
public function assignSortCriteria()
|
||||
{
|
||||
$sortCriterta = array(
|
||||
array (
|
||||
'key' => 'popularity',
|
||||
'value' => 'popularity',
|
||||
'title' => $this->l('Popularity')
|
||||
),
|
||||
array (
|
||||
'key' => 'name',
|
||||
'value' => 'name',
|
||||
'title' => $this->l('Name')
|
||||
),
|
||||
array (
|
||||
'key' => 'price_increasing',
|
||||
'value' => 'price_increasing',
|
||||
'title' => $this->l('Price (low to high)')
|
||||
),
|
||||
array (
|
||||
'key' => 'price_decreasing',
|
||||
'value' => 'price_decreasing',
|
||||
'title' => $this->l('Price (high to low)')
|
||||
),
|
||||
);
|
||||
$this->context->smarty->assign(array(
|
||||
'sort_criterta' => $sortCriterta,
|
||||
'module_sort' => Configuration::get('PS_SORT_MODULE_MODULES_CATALOG_'.(int)$this->context->employee->id),
|
||||
'theme_sort' => Configuration::get('PS_SORT_THEME_MODULES_CATALOG_'.(int)$this->context->employee->id),
|
||||
));
|
||||
}
|
||||
|
||||
public function getSuggestedThemes()
|
||||
{
|
||||
$installedThemes = array();
|
||||
$themes = Theme::getAllThemes()->getAll();
|
||||
foreach ($themes as $theme) {
|
||||
$installedThemes[] = Theme::getThemeInfo($theme->id);
|
||||
}
|
||||
$files_list = array(
|
||||
array('type' => 'addonsMustHave', 'file' => _PS_ROOT_DIR_.Module::CACHE_FILE_MUST_HAVE_MODULES_LIST, 'loggedOnAddons' => 0),
|
||||
);
|
||||
|
||||
$theme_list = array();
|
||||
foreach ($files_list as $f) {
|
||||
$file = $f['file'];
|
||||
$content = Tools::file_get_contents($file);
|
||||
$xml = @simplexml_load_string($content, null, LIBXML_NOCDATA);
|
||||
if ($xml && isset($xml->theme)) {
|
||||
foreach ($xml->theme as $modthemes) {
|
||||
foreach ($installedThemes as $theme) {
|
||||
if ($theme['theme_name'] == $modthemes->name)
|
||||
continue;
|
||||
$item = new stdClass();
|
||||
$item->id = 0;
|
||||
$item->warning = '';
|
||||
$item->type = strip_tags((string)$f['type']);
|
||||
$item->element_type = self::ELEMENT_TYPE_THEME;
|
||||
$item->name = strip_tags((string)$modthemes->name);
|
||||
$item->version = strip_tags((string)$modthemes->version);
|
||||
$item->displayName = strip_tags((string)$modthemes->displayName);
|
||||
$item->description = stripslashes(strip_tags((string)$modthemes->description));
|
||||
$item->description_full = stripslashes(strip_tags((string)$modthemes->description_full));
|
||||
$item->author = strip_tags((string)$modthemes->author);
|
||||
$item->limited_countries = array();
|
||||
$item->parent_class = '';
|
||||
$item->onclick_option = false;
|
||||
$item->available_on_addons = 1;
|
||||
$item->active = 0;
|
||||
$item->additional_description = isset($modthemes->additional_description) ? stripslashes($modthemes->additional_description) : null;
|
||||
$item->compatibility = isset($modthemes->compatibility) ? (array)$modthemes->compatibility : null;
|
||||
$item->nb_rates = isset($modthemes->nb_rates) ? (array)$modthemes->nb_rates : null;
|
||||
$item->avg_rate = isset($modthemes->avg_rate) ? (array)$modthemes->avg_rate : null;
|
||||
$item->badges = isset($modthemes->badges) ? (array)$modthemes->badges : null;
|
||||
$item->url = isset($modthemes->url) ? $modthemes->url : null;
|
||||
|
||||
if (isset($modthemes->img)) {
|
||||
if (!file_exists(_PS_TMP_IMG_DIR_.md5((int)$modthemes->id.'-'.$modthemes->name).'.jpg')) {
|
||||
if (!file_put_contents(_PS_TMP_IMG_DIR_.md5((int)$modthemes->id.'-'.$modthemes->name).'.jpg', Tools::file_get_contents($modthemes->img))) {
|
||||
copy(_PS_IMG_DIR_.'404.gif', _PS_TMP_IMG_DIR_.md5((int)$modthemes->id.'-'.$modthemes->name).'.jpg');
|
||||
}
|
||||
}
|
||||
|
||||
if (file_exists(_PS_TMP_IMG_DIR_.md5((int)$modthemes->id.'-'.$modthemes->name).'.jpg')) {
|
||||
$item->image = '../img/tmp/'.md5((int)$modthemes->id.'-'.$modthemes->name).'.jpg';
|
||||
}
|
||||
}
|
||||
|
||||
if ($item->type == 'addonsMustHave') {
|
||||
$item->addons_buy_url = strip_tags((string)$modthemes->url);
|
||||
$prices = (array)$modthemes->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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$theme_list[$modthemes->id.'-'.$item->name] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$theme_list = array_values($theme_list);
|
||||
$this->sortList($theme_list, 'theme');
|
||||
|
||||
return $theme_list;
|
||||
}
|
||||
|
||||
public function initToolbar()
|
||||
{
|
||||
parent::initToolbar();
|
||||
$this->page_header_toolbar_btn['addons'] = array(
|
||||
'href' => 'https://qloapps.com/addons/',
|
||||
'desc' => $this->l('Explore all Addons'),
|
||||
'imgclass' => 'modules-list',
|
||||
'target' => true
|
||||
);
|
||||
}
|
||||
|
||||
public function getRecommendationContent()
|
||||
{
|
||||
if (!$this->isFresh(self::CATALOG_RECOMMENDATION_CONTENT, _TIME_1_DAY_)) {
|
||||
@file_put_contents(_PS_ROOT_DIR_.self::CATALOG_RECOMMENDATION_CONTENT, Tools::addonsRequest('catalog-recommendation'));
|
||||
}
|
||||
if (file_exists(_PS_ROOT_DIR_.self::CATALOG_RECOMMENDATION_CONTENT)) {
|
||||
return Tools::file_get_contents(_PS_ROOT_DIR_.self::CATALOG_RECOMMENDATION_CONTENT);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function sortList(&$list, $type)
|
||||
{
|
||||
|
||||
switch($type) {
|
||||
case 'module':
|
||||
$criteria = Configuration::get('PS_SORT_MODULE_MODULES_CATALOG_'.(int)$this->context->employee->id);
|
||||
break;
|
||||
case 'theme':
|
||||
$criteria = Configuration::get('PS_SORT_THEME_MODULES_CATALOG_'.(int)$this->context->employee->id);
|
||||
break;
|
||||
}
|
||||
if ($criteria != 'popularity') {
|
||||
usort($list, function($a, $b) use($criteria){
|
||||
if ($criteria == 'name') {
|
||||
return strnatcasecmp($a->displayName, $b->displayName);
|
||||
} else if ($criteria == 'price_increasing') {
|
||||
if (isset($a->price) && isset($b->price))
|
||||
return $a->price > $b->price;
|
||||
else if (isset($b->price) && $b->price)
|
||||
return true;
|
||||
} else if ($criteria == 'price_decreasing') {
|
||||
if (isset($a->price) && isset($b->price))
|
||||
return $a->price < $b->price;
|
||||
else if (isset($b->price) && $b->price)
|
||||
return true;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function setSorting($module_sorting, $theme_sorting)
|
||||
{
|
||||
Configuration::updateValue('PS_SORT_MODULE_MODULES_CATALOG_'.(int)$this->context->employee->id, $module_sorting);
|
||||
Configuration::updateValue('PS_SORT_THEME_MODULES_CATALOG_'.(int)$this->context->employee->id, $theme_sorting);
|
||||
}
|
||||
|
||||
|
||||
public function ajaxProcessGetRecommendationContent()
|
||||
{
|
||||
$response = array('success' => false);
|
||||
if ($content = $this->getRecommendationContent()) {
|
||||
$response['success'] = true;
|
||||
$response['content'] = $content;
|
||||
}
|
||||
$this->ajaxDie(json_encode($response));
|
||||
}
|
||||
|
||||
public function ajaxProcessSetSorting()
|
||||
{
|
||||
$this->setSorting(Tools::getValue('module_sorting'), Tools::getValue('theme_sorting'));
|
||||
$this->ajaxDie(json_encode(array(
|
||||
'success' => true
|
||||
)));
|
||||
}
|
||||
|
||||
|
||||
protected function initSuggestedModulesList()
|
||||
{
|
||||
if (!$this->isFresh(Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, _TIME_1_DAY_)) {
|
||||
file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, Tools::addonsRequest('native'));
|
||||
}
|
||||
|
||||
if (!$this->isFresh(Module::CACHE_FILE_MUST_HAVE_MODULES_LIST, _TIME_1_DAY_)) {
|
||||
@file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_MUST_HAVE_MODULES_LIST, Tools::addonsRequest('must-have'));
|
||||
}
|
||||
}
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
$this->addJS(_PS_JS_DIR_.'admin/modules_catalog.js');
|
||||
$this->context->controller->addJS(_PS_JS_DIR_.'/twbs-pagination/jquery.twbsPagination.min.js');
|
||||
Media::addJSdef(array(
|
||||
'num_block_per_page' => self::MODULES_PER_PAGE
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -130,7 +130,9 @@ class AdminModulesControllerCore extends AdminController
|
||||
foreach ($xml_module->children() as $module) {
|
||||
/** @var SimpleXMLElement $module */
|
||||
foreach ($module->attributes() as $key => $value) {
|
||||
if ($xml_module->attributes() == 'native' && $key == 'name') {
|
||||
if (($xml_module->attributes() == 'native' || $xml_module->attributes() == 'disk')
|
||||
&& $key == 'name'
|
||||
) {
|
||||
$this->list_natives_modules[] = (string)$value;
|
||||
}
|
||||
if ($xml_module->attributes() == 'partner' && $key == 'name') {
|
||||
@@ -156,17 +158,22 @@ class AdminModulesControllerCore extends AdminController
|
||||
parent::setMedia();
|
||||
$this->addJqueryPlugin(array('autocomplete', 'fancybox', 'tablefilter'));
|
||||
|
||||
if ($this->context->mode == Context::MODE_HOST && Tools::isSubmit('addnewmodule')) {
|
||||
Media::addjsDef(array(
|
||||
'remove_uploaded_module_txt' => $this->l('Do you want to remove the uploaded/installed module?'),
|
||||
'module_install_error_txt' => $this->l('There was an error while installing module.'),
|
||||
));
|
||||
$this->addJS(_PS_JS_DIR_.'admin/modules.js');
|
||||
|
||||
if ($this->context->mode == Context::MODE_HOST && Tools::isSubmit('addnewmodule')) {
|
||||
$this->addJS(_PS_JS_DIR_.'admin/addons.js');
|
||||
}
|
||||
}
|
||||
|
||||
public function ajaxProcessRefreshModuleList($force_reload_cache = false)
|
||||
{
|
||||
$xml_modules_list = _QLO_API_DOMAIN_.'/xml/'.str_replace('.', '', _QLOAPPS_VERSION_).'.xml';
|
||||
|
||||
// Refresh modules_list.xml every week
|
||||
if (!$this->isFresh(Module::CACHE_FILE_MODULES_LIST, 86400) || $force_reload_cache) {
|
||||
if (!$this->isFresh(Module::CACHE_FILE_MODULES_LIST, _TIME_1_DAY_) || $force_reload_cache) {
|
||||
$xml_modules_list = _QLO_API_DOMAIN_.'/xml/'.str_replace('.', '', _QLOAPPS_VERSION_).'.xml';
|
||||
if ($this->refresh(Module::CACHE_FILE_MODULES_LIST, 'https://'.$xml_modules_list)) {
|
||||
$this->status = 'refresh';
|
||||
} elseif ($this->refresh(Module::CACHE_FILE_MODULES_LIST, 'http://'.$xml_modules_list)) {
|
||||
@@ -180,7 +187,7 @@ class AdminModulesControllerCore extends AdminController
|
||||
|
||||
// If logged to Addons Webservices, refresh default country native modules list every day
|
||||
if ($this->status != 'error') {
|
||||
if (!$this->isFresh(Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, 86400) || $force_reload_cache) {
|
||||
if (!$this->isFresh(Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, _TIME_1_DAY_) || $force_reload_cache) {
|
||||
if (file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, Tools::addonsRequest('native'))) {
|
||||
$this->status = 'refresh';
|
||||
} else {
|
||||
@@ -190,7 +197,17 @@ class AdminModulesControllerCore extends AdminController
|
||||
$this->status = 'cache';
|
||||
}
|
||||
|
||||
if (!$this->isFresh(Module::CACHE_FILE_MUST_HAVE_MODULES_LIST, 86400) || $force_reload_cache) {
|
||||
if (!$this->isFresh(Module::CACHE_FILE_ADDONS_MODULES_LIST, _TIME_1_DAY_) || $force_reload_cache) {
|
||||
if (file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_ADDONS_MODULES_LIST, Tools::addonsRequest('addons-modules'))) {
|
||||
$this->status = 'refresh';
|
||||
} else {
|
||||
$this->status = 'error';
|
||||
}
|
||||
} else {
|
||||
$this->status = 'cache';
|
||||
}
|
||||
|
||||
if (!$this->isFresh(Module::CACHE_FILE_MUST_HAVE_MODULES_LIST, _TIME_1_DAY_) || $force_reload_cache) {
|
||||
if (file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_MUST_HAVE_MODULES_LIST, Tools::addonsRequest('must-have'))) {
|
||||
$this->status = 'refresh';
|
||||
} else {
|
||||
@@ -213,6 +230,7 @@ class AdminModulesControllerCore extends AdminController
|
||||
$this->status = 'cache';
|
||||
}
|
||||
}
|
||||
Module::generateTrustedXml();
|
||||
}
|
||||
|
||||
public function displayAjaxRefreshModuleList()
|
||||
@@ -268,19 +286,29 @@ class AdminModulesControllerCore extends AdminController
|
||||
|
||||
public function ajaxProcessGetTabModulesList()
|
||||
{
|
||||
$tab_modules_list = Tools::getValue('tab_modules_list');
|
||||
// $tab_modules_list = Tools::getValue('tab_modules_list');
|
||||
$conrollerClass = Tools::getValue('controller_class');
|
||||
$controllerId = Tab::getIdFromClassName($conrollerClass);
|
||||
|
||||
if (!Tab::isTabModuleListAvailable()) {
|
||||
$this->ajaxProcessRefreshModuleList();
|
||||
}
|
||||
|
||||
if ($tab_modules_list = Tab::getTabModulesList($controllerId)) {
|
||||
$tab_modules_list = $this->filterTabModuleList($tab_modules_list);
|
||||
}
|
||||
|
||||
$back = Tools::getValue('back_tab_modules_list');
|
||||
if ($back) {
|
||||
$back .= '&tab_modules_open=1';
|
||||
}
|
||||
$modules_list = array('installed' =>array(), 'not_installed' => array());
|
||||
if ($tab_modules_list) {
|
||||
$tab_modules_list = explode(',', $tab_modules_list);
|
||||
$modules_list_unsort = $this->getModulesByInstallation($tab_modules_list);
|
||||
if (count($tab_modules_list['slider_list'])) {
|
||||
$modules_list_unsort = $this->getModulesByInstallation($tab_modules_list['slider_list']);
|
||||
}
|
||||
|
||||
$installed = $uninstalled = array();
|
||||
foreach ($tab_modules_list as $key => $value) {
|
||||
foreach ($tab_modules_list['slider_list'] as $key => $value) {
|
||||
$continue = 0;
|
||||
foreach ($modules_list_unsort['installed'] as $mod_in) {
|
||||
if ($mod_in->name == $value) {
|
||||
@@ -551,7 +579,7 @@ class AdminModulesControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
public function postProcessDownload()
|
||||
public function postProcessDownload($redirect = true)
|
||||
{
|
||||
/* PrestaShop demo mode */
|
||||
if (_PS_MODE_DEMO_ || ($this->context->mode == Context::MODE_HOST)) {
|
||||
@@ -593,7 +621,7 @@ class AdminModulesControllerCore extends AdminController
|
||||
} elseif (!move_uploaded_file($_FILES['file']['tmp_name'], _PS_MODULE_DIR_.$_FILES['file']['name'])) {
|
||||
$this->errors[] = Tools::displayError('An error occurred while copying the archive to the module directory.');
|
||||
} else {
|
||||
$this->extractArchive(_PS_MODULE_DIR_.$_FILES['file']['name']);
|
||||
$this->extractArchive(_PS_MODULE_DIR_.$_FILES['file']['name'], $redirect);
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('You do not have permission to add this.');
|
||||
@@ -709,12 +737,9 @@ class AdminModulesControllerCore extends AdminController
|
||||
return;
|
||||
}
|
||||
|
||||
if ($key == 'check') {
|
||||
$this->ajaxProcessRefreshModuleList(true);
|
||||
} elseif ($key == 'checkAndUpdate') {
|
||||
if ($key == 'checkAndUpdate') {
|
||||
$modules = array();
|
||||
$this->ajaxProcessRefreshModuleList(true);
|
||||
$modules_on_disk = Module::getModulesOnDisk(true, $this->logged_on_addons, $this->id_employee);
|
||||
$modules_on_disk = Module::getModulesOnDisk(true, $this->logged_on_addons, $this->id_employee, true);
|
||||
|
||||
// Browse modules list
|
||||
foreach ($modules_on_disk as $km => $module_on_disk) {
|
||||
@@ -769,6 +794,7 @@ class AdminModulesControllerCore extends AdminController
|
||||
array('type' => 'addonsNative', 'file' => Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, 'loggedOnAddons' => 0),
|
||||
// array('type' => 'addonsBought', 'file' => Module::CACHE_FILE_CUSTOMER_MODULES_LIST, 'loggedOnAddons' => 1),
|
||||
// array('type' => 'addonsMustHave', 'file' => Module::CACHE_FILE_MUST_HAVE_MODULES_LIST, 'loggedOnAddons' => 1),
|
||||
array('type' => 'addonsMustHave', 'file' => Module::CACHE_FILE_ADDONS_MODULES_LIST, 'loggedOnAddons' => 1),
|
||||
);
|
||||
|
||||
foreach ($files_list as $f) {
|
||||
@@ -782,6 +808,9 @@ class AdminModulesControllerCore extends AdminController
|
||||
$module_to_update[$name]['name'] = $modaddons->name;
|
||||
$module_to_update[$name]['displayName'] = $modaddons->displayName;
|
||||
$module_to_update[$name]['need_loggedOnAddons'] = $f['loggedOnAddons'];
|
||||
if ($modaddons->url) {
|
||||
$module_to_update[$name]['url'] = $modaddons->url;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -790,7 +819,8 @@ class AdminModulesControllerCore extends AdminController
|
||||
|
||||
foreach ($module_to_update as $name => $attr) {
|
||||
if ((is_null($attr) && $this->logged_on_addons == 0) || ($attr['need_loggedOnAddons'] == 1 && $this->logged_on_addons == 0)) {
|
||||
$this->errors[] = sprintf(Tools::displayError('You need to be logged in to your PrestaShop Addons account in order to update the %s module. %s'), '<strong>'.$name.'</strong>', '<a href="#" class="addons_connect" data-toggle="modal" data-target="#modal_addons_connect" title="Addons">'.$this->l('Click here to log in.').'</a>');
|
||||
$this->errors[] = sprintf(Tools::displayError('You need to be download this module from store in order to update the %s module. %s'), '<strong>'.$name.'</strong>', '<a href="'.$attr['url'].'" title="Store">'.$this->l('Click here to download.').'</a>');
|
||||
// $this->errors[] = sprintf(Tools::displayError('You need to be logged in to your PrestaShop Addons account in order to update the %s module. %s'), '<strong>'.$name.'</strong>', '<a href="#" class="addons_connect" data-toggle="modal" data-target="#modal_addons_connect" title="Addons">'.$this->l('Click here to log in.').'</a>');
|
||||
} elseif (!is_null($attr['name'])) {
|
||||
$download_ok = false;
|
||||
if ($attr['need_loggedOnAddons'] == 0 && file_put_contents(_PS_MODULE_DIR_.$name.'.zip', Tools::addonsRequest('module', array('module_name' => pSQL($attr['name']))))) {
|
||||
@@ -1041,7 +1071,8 @@ class AdminModulesControllerCore extends AdminController
|
||||
|
||||
protected function getModulesByInstallation($tab_modules_list = null)
|
||||
{
|
||||
$all_modules = Module::getModulesOnDisk(true, $this->logged_on_addons, $this->id_employee);
|
||||
// $all_modules = Module::getModulesOnDisk(true, $this->logged_on_addons, $this->id_employee);
|
||||
$all_modules = Module::getSuggestedModules();
|
||||
$all_unik_modules = array();
|
||||
$modules_list = array('installed' =>array(), 'not_installed' => array());
|
||||
|
||||
@@ -1320,7 +1351,7 @@ class AdminModulesControllerCore extends AdminController
|
||||
$helper->id = 'box-update-modules';
|
||||
$helper->icon = 'icon-refresh';
|
||||
$helper->color = 'color3';
|
||||
$helper->title = $this->l('Modules to update', null, null, false);
|
||||
$helper->title = $this->l('Modules to Update', null, null, false);
|
||||
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=update_modules';
|
||||
$kpis[] = $helper->generate();
|
||||
|
||||
@@ -1426,12 +1457,13 @@ class AdminModulesControllerCore extends AdminController
|
||||
}
|
||||
|
||||
// Retrieve Modules List
|
||||
$modules = Module::getModulesOnDisk(true, $this->logged_on_addons, $this->id_employee);
|
||||
$modules = Module::getInstalledModulesOnDisk(true, $this->logged_on_addons, $this->id_employee);
|
||||
$this->initModulesList($modules);
|
||||
$this->nb_modules_total = count($modules);
|
||||
$module_errors = array();
|
||||
$module_success = array();
|
||||
$upgrade_available = array();
|
||||
$module_alerts = array();
|
||||
$dont_filter = false;
|
||||
|
||||
//Add succes message for one module update
|
||||
@@ -1514,7 +1546,7 @@ class AdminModulesControllerCore extends AdminController
|
||||
$href = Context::getContext()->link->getAdminLink('AdminModules', true).'&module_name='.$module->name.'&tab_module='.$module->tab.'&configure='.$module->name;
|
||||
$this->context->smarty->assign('text', sprintf($this->l('%1$s: %2$s'), $module->displayName, $module->warning));
|
||||
$this->context->smarty->assign('module_link', $href);
|
||||
$this->displayWarning($this->context->smarty->fetch('controllers/modules/warning_module.tpl'));
|
||||
$module_alerts[] = $this->context->smarty->fetch('controllers/modules/warning_module.tpl');
|
||||
}
|
||||
|
||||
// AutoComplete array
|
||||
@@ -1540,7 +1572,7 @@ class AdminModulesControllerCore extends AdminController
|
||||
}
|
||||
unset($object);
|
||||
if ($module->installed && isset($module->version_addons) && $module->version_addons) {
|
||||
$upgrade_available[] = array('anchor' => ucfirst($module->name), 'name' => $module->name, 'displayName' => $module->displayName);
|
||||
$upgrade_available[] = array('anchor' => ucfirst($module->name), 'name' => $module->name, 'displayName' => $module->displayName, 'is_native' => $module->is_native);
|
||||
}
|
||||
|
||||
if (in_array($module->name, $this->list_partners_modules)) {
|
||||
@@ -1578,6 +1610,7 @@ class AdminModulesControllerCore extends AdminController
|
||||
$tpl_vars = array(
|
||||
'token' => $this->token,
|
||||
'upgrade_available' => $upgrade_available,
|
||||
'module_alerts' => $module_alerts,
|
||||
'currentIndex' => self::$currentIndex,
|
||||
'dirNameCurrentIndex' => dirname(self::$currentIndex),
|
||||
'ajaxCurrentIndex' => str_replace('index', 'ajax-tab', self::$currentIndex),
|
||||
@@ -1648,4 +1681,192 @@ class AdminModulesControllerCore extends AdminController
|
||||
));
|
||||
$this->smartyOutputContent('controllers/modules/quickview.tpl');
|
||||
}
|
||||
|
||||
public function ajaxProcessUploadModule()
|
||||
{
|
||||
$response = array('success' => false);
|
||||
$this->postProcessDownload(false);
|
||||
if (!count($this->errors)) {
|
||||
$filename = $_FILES['file']['name'];
|
||||
$filename = explode('.', $filename);
|
||||
if ($module = Module::getInstanceByName($filename[0])) {
|
||||
$response['success'] = true;
|
||||
if (Module::isInstalled($module->name)) {
|
||||
$response['msg'] = $this->l('module already installed, update if available');
|
||||
} else {
|
||||
$response['msg'] = $this->l('module uploaded successfully');
|
||||
}
|
||||
if (@filemtime(_PS_ROOT_DIR_.DIRECTORY_SEPARATOR.basename(_PS_MODULE_DIR_).DIRECTORY_SEPARATOR.$module->name
|
||||
.DIRECTORY_SEPARATOR.'logo.png')) {
|
||||
$module->image = _MODULE_DIR_.DIRECTORY_SEPARATOR.$module->name
|
||||
.DIRECTORY_SEPARATOR.'logo.png';
|
||||
}
|
||||
$response['data']['module'] = array(
|
||||
'module_name' => $module->name,
|
||||
'displayName' => $module->displayName,
|
||||
'installed' => Module::isInstalled($module->name),
|
||||
'author' => $module->author,
|
||||
'image' => $module->image ? $module->image : ''
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$response['errors'] = $this->errors;
|
||||
}
|
||||
$this->logAndResponseAjax($response);
|
||||
}
|
||||
|
||||
public function ajaxProcessCheckModuleTrusted()
|
||||
{
|
||||
$response = array(
|
||||
'success' => false,
|
||||
'data' => array('trusted' => false)
|
||||
);
|
||||
if ($moduleName = Tools::getValue('module_name')) {
|
||||
if ($module = Module::getInstanceByName($moduleName)) {
|
||||
if ($response['data']['trusted'] = Module::isModuleTrusted($moduleName)) {
|
||||
$response['msg'] = $this->l('Module trusted');
|
||||
} else {
|
||||
$response['msg'] = $this->l('Module not trusted');
|
||||
}
|
||||
$response['success'] = true;
|
||||
} else {
|
||||
$this->errors[] = $this->l('Module not found.');
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = $this->l('Invalid module provided');
|
||||
}
|
||||
$response['errors'] = $this->errors;
|
||||
$this->logAndResponseAjax($response);
|
||||
}
|
||||
|
||||
public function ajaxProcessInstallModule()
|
||||
{
|
||||
$response = array(
|
||||
'success' => false,
|
||||
);
|
||||
if ($moduleName = Tools::getValue('module_name')) {
|
||||
if ($module = Module::getInstanceByName($moduleName)) {
|
||||
if (!Module::isInstalled($module->name)) {
|
||||
if ($response['success'] = $module->install()) {
|
||||
$response['msg'] = $this->l('Module installed successfully');
|
||||
$response['data']['redirect'] = $this->context->link->getAdminLink('AdminModules').'&conf=12&anchor='.$module->name;
|
||||
} else {
|
||||
$this->errors[] = $this->l('Cannot install this module.');
|
||||
}
|
||||
} else {
|
||||
$response['success'] = true;
|
||||
$response['msg'] = $this->l('Module already installed');
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = $this->l('Module not found.');
|
||||
}
|
||||
}
|
||||
|
||||
if (count($this->errors)) {
|
||||
$response['data']['callback']['process'] = 'delete';
|
||||
$response['data']['callback']['msg'] = $this->l('There was some error while installing the module, do you want to delete the uploded module');
|
||||
$response['errors'] = $this->errors;
|
||||
}
|
||||
$this->logAndResponseAjax($response);
|
||||
}
|
||||
|
||||
public function ajaxProcessRollbackModuleUpload()
|
||||
{
|
||||
$response = array(
|
||||
'success' => false
|
||||
);
|
||||
$process = Tools::getValue('process');
|
||||
if ($moduleName = Tools::getValue('module_name')) {
|
||||
if($process == 'disable') {
|
||||
if ($module = Module::getInstanceByName($moduleName)) {
|
||||
if (Module::isInstalled($module->name)) {
|
||||
$module->disable();
|
||||
$response['success'] = true;
|
||||
$response['msg'] = $this->l('Module disable successfully');
|
||||
$response['data']['redirect'] = $this->context->link->getAdminLink('AdminModules').'&conf=5';
|
||||
}
|
||||
}
|
||||
} else if($process == 'delete' || $process == 'uninstall') {
|
||||
if ($module = Module::getInstanceByName($moduleName)) {
|
||||
if (Module::isInstalled($module->name)) {
|
||||
if ($module->uninstall()) {
|
||||
if ($process == 'uninstall') {
|
||||
$response['success'] = true;
|
||||
$response['msg'] = $this->l('Module uninstall process completed');
|
||||
$response['data']['redirect'] = $this->context->link->getAdminLink('AdminModules').'&conf=22';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($process == 'delete') {
|
||||
if (is_dir(_PS_MODULE_DIR_.$moduleName)) {
|
||||
$this->recursiveDeleteOnDisk(_PS_MODULE_DIR_.$moduleName);
|
||||
$response['success'] = true;
|
||||
$response['msg'] = $this->l('Module rollback process completed');
|
||||
$response['data']['redirect'] = $this->context->link->getAdminLink('AdminModules').'&conf=22';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$response['errors'] = $this->errors;
|
||||
|
||||
$this->logAndResponseAjax($response);
|
||||
}
|
||||
|
||||
public function ajaxProcessUpdateModule()
|
||||
{
|
||||
$response = array(
|
||||
'success' => false
|
||||
);
|
||||
if ($moduleName = Tools::getValue('module_name')) {
|
||||
if ($module = Module::getInstanceByName($moduleName)) {
|
||||
if ($installed = Module::getModuleInstallVersion($module->name)) {
|
||||
$module->installed = (bool)$installed;
|
||||
$module->database_version = $installed['version'];
|
||||
if (Module::initUpgradeModule($module)) {
|
||||
if (!class_exists($module->name)) {
|
||||
require_once(_PS_MODULE_DIR_.$module->name.'/'.$module->name.'.php');
|
||||
}
|
||||
if ($object = Adapter_ServiceLocator::get($module->name)) {
|
||||
$object->runUpgradeModule();
|
||||
if ((count($errors_module_list = $object->getErrors()))) {
|
||||
$this->errors = array_merge($this->errors, array('name' => $module->displayName, 'message' => $errors_module_list));
|
||||
} elseif ((count($conf_module_list = $object->getConfirmations()))) {
|
||||
$response['data']['upgrade'][] = array('name' => $module->displayName, 'message' => $conf_module_list);
|
||||
$response['success'] = true;
|
||||
$html = $this->generateHtmlMessage($response['data']['upgrade']);
|
||||
$response['msg'] = sprintf($this->l('The following module was upgraded successfully: %s.'), $html);
|
||||
$response['data']['redirect'] = $this->context->link->getAdminLink('AdminModules').'&conf=29&anchor='.$module->name;
|
||||
}
|
||||
unset($object);
|
||||
} else {
|
||||
$this->errors[] = $this->l('Module not found!');
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = $this->l('There was some error while updating the module');
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = $this->l('Module not installed, install module before updating.');
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = $this->l('Module not found!');
|
||||
}
|
||||
}
|
||||
if (count($this->errors)) {
|
||||
$response['data']['callback']['process'] = 'disable';
|
||||
$response['data']['callback']['msg'] = $this->l('There was some error while updating the module, do you want to disable the module');
|
||||
$response['errors'] = $this->errors;
|
||||
}
|
||||
|
||||
$this->logAndResponseAjax($response);
|
||||
}
|
||||
|
||||
public function logAndResponseAjax($response)
|
||||
{
|
||||
if (isset($response['errors']) && count($response['errors'])) {
|
||||
PrestaShopLogger::addLog('Module install/upload error : Resquest => '.json_encode(Tools::getAllValues()).' || Response =>'.(json_encode($response)), 1, null, 'Module', null, true, (int)$this->context->employee->id);
|
||||
}
|
||||
$this->ajaxDie(json_encode($response));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,30 @@ class AdminOrderPreferencesControllerCore extends AdminController
|
||||
);
|
||||
|
||||
$this->fields_options = array(
|
||||
'order_restrict' => array(
|
||||
'title' => $this->l('Order Restrict'),
|
||||
'icon' => 'icon-cogs',
|
||||
'fields' => array(
|
||||
'MAX_GLOBAL_BOOKING_DATE' => array(
|
||||
'title' => $this->l('Maximum Global Date to book a room'),
|
||||
'hint' => $this->l('Maximum date by which rooms of your hotels can be booked.'),
|
||||
'type' => 'text',
|
||||
'id' => 'max_global_book_date',
|
||||
'class' => 'fixed-width-xxl readonly',
|
||||
),
|
||||
'GLOBAL_PREPARATION_TIME' => array(
|
||||
'title' => $this->l('Preparation time'),
|
||||
'hint' => $this->l('Number of days required to prepare a room for stay.'),
|
||||
'desc' => $this->l('Set to 0 to disable this feature.'),
|
||||
'type' => 'text',
|
||||
'class' => 'fixed-width-xl',
|
||||
'suffix' => $this->l('day(s)'),
|
||||
),
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save'),
|
||||
),
|
||||
),
|
||||
'general' => array(
|
||||
'title' => $this->l('General'),
|
||||
'icon' => 'icon-cogs',
|
||||
@@ -75,7 +99,7 @@ class AdminOrderPreferencesControllerCore extends AdminController
|
||||
),*/
|
||||
'PS_GUEST_CHECKOUT_ENABLED' => array(
|
||||
'title' => $this->l('Enable guest checkout'),
|
||||
'hint' => $this->l('Allow guest visitors to place an order without registering.'),
|
||||
'hint' => $this->l('Allow guest visitors to place an order without registration.'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'type' => 'bool'
|
||||
@@ -120,8 +144,8 @@ class AdminOrderPreferencesControllerCore extends AdminController
|
||||
)
|
||||
),
|
||||
'PS_CONDITIONS_CMS_ID' => array(
|
||||
'title' => $this->l('CMS page for the Conditions of use'),
|
||||
'hint' => $this->l('Choose the CMS page which contains your store\'s conditions of use.'),
|
||||
'title' => $this->l('CMS page for Terms and Conditions'),
|
||||
'hint' => $this->l('Choose the CMS page which contains your website\'s Terms and Conditions.'),
|
||||
'validation' => 'isInt',
|
||||
'type' => 'select',
|
||||
'list' => $cms_tab,
|
||||
@@ -157,8 +181,8 @@ class AdminOrderPreferencesControllerCore extends AdminController
|
||||
'type' => 'bool'
|
||||
),
|
||||
'PS_ORDER_CONF_MAIL_TO_EMPLOYEE' => array(
|
||||
'title' => $this->l('Order confirmation mail to employee'),
|
||||
'hint' => $this->l('Enable, if you want to send order confirmation email to the employees with profiles which have permission to manage the hotel.'),
|
||||
'title' => $this->l('Order confirmation mail to employees'),
|
||||
'hint' => $this->l('Enable, if you want to send order confirmation email to employees having permission to manage the hotel.'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'type' => 'bool'
|
||||
@@ -183,9 +207,34 @@ class AdminOrderPreferencesControllerCore extends AdminController
|
||||
public function beforeUpdateOptions()
|
||||
{
|
||||
$sql = 'SELECT `id_cms` FROM `'._DB_PREFIX_.'cms`
|
||||
WHERE id_cms = '.(int)Tools::getValue('PS_CONDITIONS_CMS_ID');
|
||||
WHERE id_cms = '.(int)Tools::getValue('PS_CONDITIONS_CMS_ID');
|
||||
if (Tools::getValue('PS_CONDITIONS') && (Tools::getValue('PS_CONDITIONS_CMS_ID') == 0 || !Db::getInstance()->getValue($sql))) {
|
||||
$this->errors[] = Tools::displayError('Assign a valid CMS page if you want it to be read.');
|
||||
$this->errors[] = Tools::displayError('Please assign a valid CMS page for Terms and Conditions.');
|
||||
}
|
||||
|
||||
$maxGlobalBookingDate = Tools::getValue('MAX_GLOBAL_BOOKING_DATE');
|
||||
$globalPreparationTime = Tools::getValue('GLOBAL_PREPARATION_TIME');
|
||||
$maxGlobalBookingDateFormatted = date('Y-m-d', strtotime($maxGlobalBookingDate));
|
||||
|
||||
if ($maxGlobalBookingDate == '') {
|
||||
$this->errors[] = Tools::displayError('Field \'Maximum Global Date to book a room\' can not be empty.');
|
||||
} elseif (!Validate::isDate($maxGlobalBookingDateFormatted)) {
|
||||
$this->errors[] = Tools::displayError('Field \'Maximum Global Date to book a room\' is invalid.');
|
||||
} elseif (strtotime($maxGlobalBookingDateFormatted) < strtotime(date('Y-m-d'))) {
|
||||
$this->errors[] = Tools::displayError('Field \'Maximum Global Date to book a room\' can not be a past date. Please use a future date.');
|
||||
}
|
||||
|
||||
if ($globalPreparationTime === '') {
|
||||
$this->errors[] = Tools::displayError('Field \'Preparation time\' can not be empty.');
|
||||
} elseif ($globalPreparationTime !== '0' && !Validate::isUnsignedInt($globalPreparationTime)) {
|
||||
$this->errors[] = Tools::displayError('Field \'Preparation time\' is invalid.');
|
||||
}
|
||||
}
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
$this->addCSS(_MODULE_DIR_.'hotelreservationsystem/views/css/HotelReservationAdmin.css');
|
||||
$this->addJS(_MODULE_DIR_.'hotelreservationsystem/views/js/HotelReservationAdmin.js');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,6 +215,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$cart_order_exists = $cart->orderExists();
|
||||
if (!$cart_order_exists) {
|
||||
$this->context->cart = $cart;
|
||||
$this->context->currency = new Currency((int)$cart->id_currency);
|
||||
$cart_detail_data = array();
|
||||
$cart_detail_data_obj = new HotelCartBookingData();
|
||||
if ($cart_detail_data = $cart_detail_data_obj->getCartFormatedBookinInfoByIdCart((int) $id_cart)) {
|
||||
@@ -803,7 +804,11 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$this->errors[] = Tools::displayError('The date is invalid');
|
||||
} else {
|
||||
if (!$order->addOrderPayment($amount, Tools::getValue('payment_method'), Tools::getValue('payment_transaction_id'), $currency, Tools::getValue('payment_date'), $order_invoice)) {
|
||||
$this->errors[] = Tools::displayError('An error occurred during payment.');
|
||||
if (!validate::isPrice($order->total_paid_real)) {
|
||||
$this->errors[] = Tools::displayError('Order total payments cannot be less than 0.');
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('An error occurred during payment.');
|
||||
}
|
||||
} else {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&id_order='.$order->id.'&vieworder&conf=4&token='.$this->token);
|
||||
}
|
||||
@@ -3333,74 +3338,6 @@ class AdminOrdersControllerCore extends AdminController
|
||||
die($extraDemandsTpl);
|
||||
}
|
||||
|
||||
// Process to get extra demands of any room while order creation process form.tpl
|
||||
public function ajaxProcessGetRoomTypeCartDemands()
|
||||
{
|
||||
$extraDemandsTpl = '';
|
||||
if ($idProduct = Tools::getValue('id_product')) {
|
||||
if (($dateFrom = Tools::getValue('date_from'))
|
||||
&& ($dateTo = Tools::getValue('date_to'))
|
||||
&& ($idRoom = Tools::getValue('id_room'))
|
||||
&& ($idCart = Tools::getValue('id_cart'))
|
||||
) {
|
||||
$objCartBookingData = new HotelCartBookingData();
|
||||
if ($selectedRoomDemands = $objCartBookingData->getCartExtraDemands(
|
||||
$idCart,
|
||||
$idProduct,
|
||||
$idRoom,
|
||||
$dateFrom,
|
||||
$dateTo
|
||||
)) {
|
||||
// get room type additional demands
|
||||
$objRoomDemands = new HotelRoomTypeDemand();
|
||||
if ($roomTypeDemands = $objRoomDemands->getRoomTypeDemands($idProduct)) {
|
||||
foreach ($roomTypeDemands as &$demand) {
|
||||
// if demand has advance options then set demand price as first advance option price.
|
||||
if (isset($demand['adv_option']) && $demand['adv_option']) {
|
||||
$demand['price'] = current($demand['adv_option'])['price'];
|
||||
}
|
||||
}
|
||||
foreach ($selectedRoomDemands as &$selectedDemand) {
|
||||
$objRoom = new HotelRoomInformation($selectedDemand['id_room']);
|
||||
$selectedDemand['room_num'] = $objRoom->room_num;
|
||||
if (isset($selectedDemand['extra_demands']) && $selectedDemand['extra_demands']) {
|
||||
$extraDmd = array();
|
||||
foreach ($selectedDemand['extra_demands'] as $sDemand) {
|
||||
$selectedDemand['selected_global_demands'][] = $sDemand['id_global_demand'];
|
||||
$extraDmd[$sDemand['id_global_demand'].'-'.$sDemand['id_option']] = $sDemand;
|
||||
}
|
||||
$selectedDemand['extra_demands'] = $extraDmd;
|
||||
}
|
||||
}
|
||||
$this->context->smarty->assign('roomTypeDemands', $roomTypeDemands);
|
||||
$this->context->smarty->assign('selectedRoomDemands', $selectedRoomDemands);
|
||||
$extraDemandsTpl .= $this->context->smarty->fetch(
|
||||
_PS_ADMIN_DIR_.'/themes/default/template/controllers/orders/_cart_booking_demands.tpl'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
die($extraDemandsTpl);
|
||||
}
|
||||
|
||||
// Process when admin changes extra demands of any room while order creation process form.tpl
|
||||
public function ajaxProcessChangeRoomDemands()
|
||||
{
|
||||
if ($idCartBooking = Tools::getValue('id_cart_booking')) {
|
||||
if (Validate::isLoadedObject($objCartbookingCata = new HotelCartBookingData($idCartBooking))) {
|
||||
$roomDemands = Tools::getValue('room_demands');
|
||||
$roomDemands = json_decode($roomDemands, true);
|
||||
$roomDemands = json_encode($roomDemands);
|
||||
$objCartbookingCata->extra_demands = $roomDemands;
|
||||
if ($objCartbookingCata->save()) {
|
||||
die('1');
|
||||
}
|
||||
}
|
||||
}
|
||||
die('0');
|
||||
}
|
||||
|
||||
// Process when admin edit rooms and edit rooms additional facilities
|
||||
public function ajaxProcessEditRoomExtraDemands()
|
||||
{
|
||||
|
||||
@@ -43,7 +43,7 @@ class AdminPPreferencesControllerCore extends AdminController
|
||||
|
||||
$this->fields_options = array(
|
||||
'products' => array(
|
||||
'title' => $this->l('Products (general)'),
|
||||
'title' => $this->l('Room Types (General)'),
|
||||
'fields' => array(
|
||||
'PS_CATALOG_MODE' => array(
|
||||
'title' => $this->l('Catalog mode'),
|
||||
@@ -62,7 +62,8 @@ class AdminPPreferencesControllerCore extends AdminController
|
||||
// 'type' => 'text'
|
||||
// ),
|
||||
'PS_NB_DAYS_NEW_PRODUCT' => array(
|
||||
'title' => $this->l('Number of days for which the product is considered \'new\''),
|
||||
'title' => $this->l('Number of days for which a room type is considered \'new\''),
|
||||
'hint' => $this->l('The counting of days starts from room type creation date.'),
|
||||
'validation' => 'isUnsignedInt',
|
||||
'cast' => 'intval',
|
||||
'type' => 'text'
|
||||
@@ -82,7 +83,7 @@ class AdminPPreferencesControllerCore extends AdminController
|
||||
),*/
|
||||
'PS_PRODUCT_SHORT_DESC_LIMIT' => array(
|
||||
'title' => $this->l('Max size of short description'),
|
||||
'hint' => $this->l('Set the maximum size of product short description (in characters).'),
|
||||
'hint' => $this->l('Set the maximum size of room type short description (in characters).'),
|
||||
'validation' => 'isInt',
|
||||
'cast' => 'intval',
|
||||
'type' => 'text',
|
||||
@@ -124,31 +125,31 @@ class AdminPPreferencesControllerCore extends AdminController
|
||||
'title' => $this->l('Pagination'),
|
||||
'fields' => array(
|
||||
'PS_PRODUCTS_PER_PAGE' => array(
|
||||
'title' => $this->l('Products per page'),
|
||||
'hint' => $this->l('Number of products displayed per page. Default is 10.'),
|
||||
'title' => $this->l('Room types per page'),
|
||||
'hint' => $this->l('Number of room types displayed per page. Default is 10.'),
|
||||
'validation' => 'isUnsignedInt',
|
||||
'cast' => 'intval',
|
||||
'type' => 'text'
|
||||
),
|
||||
'PS_PRODUCTS_ORDER_BY' => array(
|
||||
'title' => $this->l('Default order by'),
|
||||
'hint' => $this->l('The order in which products are displayed in the product list.'),
|
||||
'hint' => $this->l('The order in which room types are displayed in the room type list.'),
|
||||
'type' => 'select',
|
||||
'list' => array(
|
||||
array('id' => '0', 'name' => $this->l('Product name')),
|
||||
array('id' => '1', 'name' => $this->l('Product price')),
|
||||
array('id' => '2', 'name' => $this->l('Product add date')),
|
||||
array('id' => '3', 'name' => $this->l('Product modified date')),
|
||||
array('id' => '4', 'name' => $this->l('Position inside category')),
|
||||
array('id' => '5', 'name' => $this->l('Manufacturer')),
|
||||
array('id' => '6', 'name' => $this->l('Product quantity')),
|
||||
array('id' => '7', 'name' => $this->l('Product reference'))
|
||||
array('id' => '0', 'name' => $this->l('Room type name')),
|
||||
array('id' => '1', 'name' => $this->l('Room type price')),
|
||||
array('id' => '2', 'name' => $this->l('Room type add date')),
|
||||
array('id' => '3', 'name' => $this->l('Room type modified date')),
|
||||
// array('id' => '4', 'name' => $this->l('Position inside category')),
|
||||
// array('id' => '5', 'name' => $this->l('Manufacturer')),
|
||||
// array('id' => '6', 'name' => $this->l('Product quantity')),
|
||||
// array('id' => '7', 'name' => $this->l('Product reference'))
|
||||
),
|
||||
'identifier' => 'id'
|
||||
),
|
||||
'PS_PRODUCTS_ORDER_WAY' => array(
|
||||
'title' => $this->l('Default order method'),
|
||||
'hint' => $this->l('Default order method for product list.'),
|
||||
'hint' => $this->l('Default order method for room type list.'),
|
||||
'type' => 'select',
|
||||
'list' => array(
|
||||
array(
|
||||
@@ -166,7 +167,7 @@ class AdminPPreferencesControllerCore extends AdminController
|
||||
'submit' => array('title' => $this->l('Save'))
|
||||
),
|
||||
'fo_product_page' => array(
|
||||
'title' => $this->l('Product page'),
|
||||
'title' => $this->l('Room type page'),
|
||||
'fields' => array(
|
||||
/* 'PS_DISPLAY_QTIES' => array(
|
||||
'title' => $this->l('Display available quantities on the product page'),
|
||||
@@ -184,7 +185,7 @@ class AdminPPreferencesControllerCore extends AdminController
|
||||
'type' => 'text'
|
||||
),*/
|
||||
'PS_DISPLAY_JQZOOM' => array(
|
||||
'title' => $this->l('Enable JqZoom instead of Fancybox on the product page'),
|
||||
'title' => $this->l('Enable JqZoom instead of Fancybox on room type page'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'required' => false,
|
||||
|
||||
@@ -92,12 +92,6 @@ class AdminPaymentControllerCore extends AdminController
|
||||
$this->toolbar_title = array_unique($this->breadcrumbs);
|
||||
}
|
||||
|
||||
public function initPageHeaderToolbar()
|
||||
{
|
||||
parent::initPageHeaderToolbar();
|
||||
$this->page_header_toolbar_btn = array();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (Tools::getValue('action') == 'GetModuleQuickView' && Tools::getValue('ajax') == '1') {
|
||||
@@ -274,40 +268,4 @@ class AdminPaymentControllerCore extends AdminController
|
||||
|
||||
return parent::renderView();
|
||||
}
|
||||
|
||||
public function renderModulesList()
|
||||
{
|
||||
if ($this->getModulesList($this->filter_modules_list)) {
|
||||
$active_list = array();
|
||||
foreach ($this->modules_list as $key => $module) {
|
||||
if (in_array($module->name, $this->list_partners_modules)) {
|
||||
$this->modules_list[$key]->type = 'addonsPartner';
|
||||
}
|
||||
if (isset($module->description_full) && trim($module->description_full) != '') {
|
||||
$module->show_quick_view = true;
|
||||
}
|
||||
|
||||
if ($module->active) {
|
||||
$active_list[] = $module;
|
||||
} else {
|
||||
$unactive_list[] = $module;
|
||||
}
|
||||
}
|
||||
|
||||
$helper = new Helper();
|
||||
$fetch = '';
|
||||
|
||||
if (isset($active_list)) {
|
||||
$this->context->smarty->assign('panel_title', $this->l('Active payment'));
|
||||
$fetch = $helper->renderModulesList($active_list);
|
||||
}
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'panel_title' => $this->l('Recommended payment gateways'),
|
||||
'view_all' => true
|
||||
));
|
||||
$fetch .= $helper->renderModulesList($unactive_list);
|
||||
return $fetch;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ class AdminPerformanceControllerCore extends AdminController
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Disable non PrestaShop modules'),
|
||||
'label' => $this->l('Disable non QloApps modules'),
|
||||
'name' => 'native_module',
|
||||
'class' => 't',
|
||||
'is_bool' => true,
|
||||
@@ -167,7 +167,7 @@ class AdminPerformanceControllerCore extends AdminController
|
||||
'label' => $this->l('Disabled')
|
||||
)
|
||||
),
|
||||
'hint' => $this->l('Enable or disable non PrestaShop Modules.')
|
||||
'hint' => $this->l('Enable or disable non QloApps Modules.')
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
|
||||
@@ -113,7 +113,6 @@ class AdminProductsControllerCore extends AdminController
|
||||
'Configuration' => $this->l('Configuration'),
|
||||
'Occupancy' => $this->l('Occupancy'),
|
||||
'LengthOfStay' => $this->l('Length of Stay'),
|
||||
'Booking' => $this->l('Booking Information'),
|
||||
);
|
||||
|
||||
$this->available_tabs = array('Warehouses' => 14);
|
||||
@@ -135,7 +134,6 @@ class AdminProductsControllerCore extends AdminController
|
||||
'Configuration' => 14,
|
||||
'Occupancy' => 15,
|
||||
'LengthOfStay' => 16,
|
||||
'Booking' => 17,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -1625,10 +1623,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
$this->addJS(_PS_JS_DIR_.'jquery/plugins/select2/select2_locale_'.$this->context->language->iso_code.'.js');
|
||||
$this->addJS(_PS_JS_DIR_.'jquery/plugins/validate/localization/messages_'.$this->context->language->iso_code.'.js');
|
||||
|
||||
$this->addCSS(array(
|
||||
_PS_JS_DIR_.'jquery/plugins/timepicker/jquery-ui-timepicker-addon.css',
|
||||
_PS_CSS_DIR_.'ps-hotel-reservation.css',
|
||||
));
|
||||
$this->addCSS(_PS_JS_DIR_.'jquery/plugins/timepicker/jquery-ui-timepicker-addon.css');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2233,9 +2228,6 @@ class AdminProductsControllerCore extends AdminController
|
||||
if ($this->isTabSubmitted('Configuration')) {
|
||||
$this->processConfiguration();
|
||||
}
|
||||
if ($this->isTabSubmitted('Booking')) {
|
||||
$this->processBooking();
|
||||
}
|
||||
|
||||
$this->updatePackItems($object);
|
||||
// Disallow avanced stock management if the product become a pack
|
||||
@@ -2740,7 +2732,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
$helper->id = 'box-8020-sales-catalog';
|
||||
$helper->icon = 'icon-beaker';
|
||||
$helper->color = 'color3';
|
||||
$helper->title = $this->l('Purchased references', null, null, false);
|
||||
$helper->title = $this->l('Purchased References', null, null, false);
|
||||
$helper->subtitle = $this->l('30 days', null, null, false);
|
||||
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=8020_sales_catalog';
|
||||
$helper->tooltip = $this->l('X% of your references have been purchased for the past 30 days.', null, null, false);
|
||||
@@ -3389,7 +3381,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
foreach ($hotelRoomInfo as &$room) {
|
||||
if ($room['id_status'] == HotelRoomInformation::STATUS_TEMPORARY_INACTIVE) {
|
||||
$disabledDates = $objRoomDisableDates->getRoomDisableDates($room['id']);
|
||||
$room['disabled_dates_json'] = json_encode($disabledDates);
|
||||
$room['disable_dates_json'] = json_encode($disabledDates);
|
||||
}
|
||||
}
|
||||
$data->assign('htl_room_info', $hotelRoomInfo);
|
||||
@@ -3401,8 +3393,8 @@ class AdminProductsControllerCore extends AdminController
|
||||
'product' => $obj,
|
||||
'htl_info' => $hotelInfo,
|
||||
'rm_status' => $roomStatus,
|
||||
'datesMissing' => $this->l('Please fill all Date From and Date To'),
|
||||
'datesOverlapping' => $this->l('Some date are conflicting with each other. Please check and reselect the date ranges.'),
|
||||
'datesMissing' => $this->l('Some dates are missing. Please select all the date ranges.'),
|
||||
'datesOverlapping' => $this->l('Some dates are conflicting with each other. Please check and reselect the date ranges.'),
|
||||
)
|
||||
);
|
||||
} else {
|
||||
@@ -3477,7 +3469,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// send information for the length of stay tab
|
||||
public function initFormLengthOfStay($product)
|
||||
{
|
||||
@@ -3613,121 +3605,88 @@ class AdminProductsControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
public function validateDisableDateRanges($disableDates)
|
||||
public function validateDisableDateRanges($disableDates, $index)
|
||||
{
|
||||
if (count($disableDates)) {
|
||||
foreach ($disableDates as $disable_key => $disableDate) {
|
||||
if (!$disableDate['date_to'] && !$disableDate['date_from']) {
|
||||
unset($disableDates[$disable_key]);
|
||||
} elseif (!Validate::isDate($disableDate['date_from']) || !Validate::isDate($disableDate['date_to'])) {
|
||||
$this->errors[] = Tools::displayError('Please fill valid date in disable date fields.');
|
||||
$this->errors[] = sprintf(
|
||||
Tools::displayError('Please add valid disable dates for %s room.'),
|
||||
$index
|
||||
);
|
||||
} elseif (($disableDate['date_from'] && !$disableDate['date_to']) || (!$disableDate['date_from'] && $disableDate['date_to'])) {
|
||||
$this->errors[] = Tools::displayError('Please fill all date from and date to for disable dates fields.');
|
||||
$this->errors[] = sprintf(
|
||||
Tools::displayError('Please fill date from and date to for disable dates for %s room.'),
|
||||
$index
|
||||
);
|
||||
} else {
|
||||
foreach ($disableDates as $key => $disDate) {
|
||||
if ($key != $disable_key) {
|
||||
if ((($disableDate['date_from'] < $disDate['date_from']) && ($disableDate['date_to'] <= $disDate['date_from'])) || (($disableDate['date_from'] > $disDate['date_from']) && ($disableDate['date_from'] >= $disDate['date_to']))) {
|
||||
// continue
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('Some date are conflicting with each other. Please check and reselect the date ranges.');
|
||||
$this->errors[] = sprintf(
|
||||
Tools::displayError('Disable dates are conflicting for %s room. Please add non-conflicting dates.'),
|
||||
$index
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('Please add dates for status temporary inactive.');
|
||||
$this->errors[] = sprintf(Tools::displayError('Please add disable dates for %s room.'), $index);
|
||||
}
|
||||
}
|
||||
|
||||
public function processConfiguration()
|
||||
{
|
||||
/*Check if save of configuration tab is submitted*/
|
||||
// Check if save of configuration tab is submitted
|
||||
if (Tools::getValue('checkConfSubmit')) {
|
||||
// htl_room_type id field use only in edit case
|
||||
$wk_id_room_type = Tools::getValue('wk_id_room_type');
|
||||
|
||||
$id_product = Tools::getValue('id_product'); //room type
|
||||
$id_product = Tools::getValue('id_product');
|
||||
$id_hotel = Tools::getValue('id_hotel');
|
||||
|
||||
if (!$id_product || !Validate::isUnsignedInt($id_product)) {
|
||||
$this->errors[] = Tools::displayError('There is some problem while setting room information');
|
||||
$this->errors[] = Tools::displayError('There is some problem while setting room information.');
|
||||
}
|
||||
if (!$id_hotel || !Validate::isUnsignedInt($id_hotel)) {
|
||||
$this->errors[] = Tools::displayError('Please select a hotel');
|
||||
$this->errors[] = Tools::displayError('Please select a hotel.');
|
||||
}
|
||||
|
||||
$this->validateConfigurationPostData();
|
||||
if (!count($this->errors)) {
|
||||
$room_numbers = Tools::getValue('room_num');
|
||||
if ($room_numbers) {
|
||||
$room_floor = Tools::getValue('room_floor');
|
||||
$room_comment = Tools::getValue('room_comment');
|
||||
$disable_dates = Tools::getValue('disableDatesJSON');
|
||||
$room_status = Tools::getValue('room_status');
|
||||
$roomsInfo = Tools::getValue('rooms_info');
|
||||
if (is_array($roomsInfo) && count($roomsInfo)) {
|
||||
foreach ($roomsInfo as $roomInfo) {
|
||||
$objHotelRoomInfo = null;
|
||||
if (isset($roomInfo['id']) && $roomInfo['id']) {
|
||||
$objHotelRoomInfo = new HotelRoomInformation($roomInfo['id']);
|
||||
} else {
|
||||
$objHotelRoomInfo = new HotelRoomInformation();
|
||||
}
|
||||
$objHotelRoomInfo->id_product = $id_product;
|
||||
$objHotelRoomInfo->id_hotel = $id_hotel;
|
||||
$objHotelRoomInfo->room_num = $roomInfo['room_num'];
|
||||
$objHotelRoomInfo->id_status = $roomInfo['id_status'];
|
||||
$objHotelRoomInfo->floor = $roomInfo['floor'];
|
||||
$objHotelRoomInfo->comment = $roomInfo['comment'];
|
||||
if ($objHotelRoomInfo->save()) {
|
||||
$idRoom = $objHotelRoomInfo->id;
|
||||
if ($roomInfo['id_status'] == HotelRoomInformation::STATUS_TEMPORARY_INACTIVE) {
|
||||
$objHotelRoomDisableDates = new HotelRoomDisableDates();
|
||||
$objHotelRoomDisableDates->deleteRoomDisableDates($idRoom);
|
||||
|
||||
if (count($room_numbers) != count($room_status)) {
|
||||
$this->errors[] = Tools::displayError('There is some problem while setting room information');
|
||||
} else {
|
||||
//validate room number
|
||||
foreach ($room_numbers as $roomNum) {
|
||||
if (!$roomNum || !Validate::isGenericName($roomNum)) {
|
||||
$this->errors[] = Tools::displayError('Invalid room number entered. please enter a valid room number.');
|
||||
}
|
||||
}
|
||||
//validate room status
|
||||
$disableDtsArr = array();
|
||||
foreach ($room_status as $key => $status) {
|
||||
if ($status == HotelRoomInformation::STATUS_TEMPORARY_INACTIVE) {
|
||||
$disableDtsArr[$key] = json_decode($disable_dates[$key], true);
|
||||
$this->validateDisableDateRanges($disableDtsArr[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!count($this->errors)) {
|
||||
if ($wk_id_room_type) {
|
||||
$objRoomType = new HotelRoomType($wk_id_room_type);
|
||||
$id_hotel = $objRoomType->id_hotel;
|
||||
}
|
||||
|
||||
// Associate categories to Room Type
|
||||
$id_room_info = Tools::getValue('id_room_info');
|
||||
$objCartBookingData = new HotelCartBookingData();
|
||||
foreach ($room_numbers as $key => $value) {
|
||||
if ($value) {
|
||||
if ($id_room_info) {
|
||||
if ($key <= (count($id_room_info) - 1)) {
|
||||
$objRoomInfo = new HotelRoomInformation($id_room_info[$key]);
|
||||
} else {
|
||||
//if any new room is added at the time of edit
|
||||
$objRoomInfo = new HotelRoomInformation();
|
||||
$objRoomInfo->id_product = $id_product;
|
||||
$objRoomInfo->id_hotel = $id_hotel;
|
||||
}
|
||||
} else {
|
||||
$objRoomInfo = new HotelRoomInformation();
|
||||
$objRoomInfo->id_product = $id_product;
|
||||
$objRoomInfo->id_hotel = $id_hotel;
|
||||
}
|
||||
$objRoomInfo->room_num = $value;
|
||||
$objRoomInfo->id_status = $room_status[$key];
|
||||
$objRoomInfo->floor = $room_floor[$key];
|
||||
$objRoomInfo->comment = $room_comment[$key];
|
||||
if ($objRoomInfo->save()) {
|
||||
if ($room_status[$key] == HotelRoomInformation::STATUS_TEMPORARY_INACTIVE) {
|
||||
$objDisDts = new HotelRoomDisableDates();
|
||||
$objDisDts->deleteRoomDisableDates($objRoomInfo->id);
|
||||
if (isset($disableDtsArr[$key]) && $disableDtsArr[$key]) {
|
||||
// delete privious save dats
|
||||
foreach ($disableDtsArr[$key] as $disDtRange) {
|
||||
$objDisDts = new HotelRoomDisableDates();
|
||||
$objDisDts->id_room_type = $id_product;
|
||||
$objDisDts->id_room = $objRoomInfo->id;
|
||||
$objDisDts->date_from = $disDtRange['date_from'];
|
||||
$objDisDts->date_to = $disDtRange['date_to'];
|
||||
$objDisDts->reason = $disDtRange['reason'];
|
||||
$objDisDts->add();
|
||||
}
|
||||
}
|
||||
}
|
||||
$disableDates = json_decode($roomInfo['disable_dates_json'], true);
|
||||
foreach ($disableDates as $disableDate) {
|
||||
$objHotelRoomDisableDates = new HotelRoomDisableDates();
|
||||
$objHotelRoomDisableDates->id_room_type = $id_product;
|
||||
$objHotelRoomDisableDates->id_room = $idRoom;
|
||||
$objHotelRoomDisableDates->date_from = $disableDate['date_from'];
|
||||
$objHotelRoomDisableDates->date_to = $disableDate['date_to'];
|
||||
$objHotelRoomDisableDates->reason = $disableDate['reason'];
|
||||
$objHotelRoomDisableDates->add();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3737,6 +3696,49 @@ class AdminProductsControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
public function validateConfigurationPostData()
|
||||
{
|
||||
$roomsInfo = Tools::getValue('rooms_info');
|
||||
if (is_array($roomsInfo) && count($roomsInfo)) {
|
||||
foreach ($roomsInfo as $key => $roomInfo) {
|
||||
if (!$roomInfo['room_num']) {
|
||||
unset($_POST['rooms_info'][$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$roomsInfo = Tools::getValue('rooms_info'); // since $_POST['rooms_info'] has changed
|
||||
if (is_array($roomsInfo) && count($roomsInfo)) {
|
||||
$formatter = new NumberFormatter($this->context->language->language_code, NumberFormatter::ORDINAL);
|
||||
foreach ($roomsInfo as $key => $roomInfo) {
|
||||
$index = $formatter->format($key + 1);
|
||||
|
||||
if ($roomInfo['id_status'] == HotelRoomInformation::STATUS_TEMPORARY_INACTIVE) {
|
||||
if ($roomInfo['disable_dates_json'] === 0) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Please add disable dates for %s room.'), $index);
|
||||
}
|
||||
}
|
||||
|
||||
if ($roomInfo['room_num'] && !Validate::isGenericName($roomInfo['room_num'])) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Invalid room number for %s room.'), $index);
|
||||
}
|
||||
|
||||
if ($roomInfo['floor'] && !Validate::isGenericName($roomInfo['floor'])) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Invalid floor for %s room.'), $index);
|
||||
}
|
||||
|
||||
if ($roomInfo['id_status'] == HotelRoomInformation::STATUS_TEMPORARY_INACTIVE) {
|
||||
$disableDates = json_decode($roomInfo['disable_dates_json'], true);
|
||||
if ($roomInfo['disable_dates_json'] !== 0) {
|
||||
$this->validateDisableDateRanges($disableDates, $index);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('Please add at least one room.');
|
||||
}
|
||||
}
|
||||
|
||||
public function ajaxProcessDeleteHotelRoom()
|
||||
{
|
||||
if ($this->tabAccess['edit'] == 1) {
|
||||
@@ -3749,162 +3751,6 @@ class AdminProductsControllerCore extends AdminController
|
||||
die('0');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Product $obj
|
||||
*
|
||||
* @throws Exception
|
||||
* @throws PrestaShopException
|
||||
* @throws SmartyException
|
||||
*/
|
||||
public function initFormBooking($obj)
|
||||
{
|
||||
$data = $this->createTemplate($this->tpl_form);
|
||||
if ($obj->id) {
|
||||
if ($this->product_exists_in_shop) {
|
||||
$data->assign(array('product' => $obj));
|
||||
|
||||
$date_from = Tools::getValue('date_from');
|
||||
$date_to = Tools::getValue('date_to');
|
||||
|
||||
$obj_rm_type = new HotelRoomType();
|
||||
$obj_booking_dtl = new HotelBookingDetail();
|
||||
|
||||
$rm_info = $obj_rm_type->getRoomTypeInfoByIdProduct($obj->id);
|
||||
if ($rm_info) {
|
||||
if ($date_from && $date_to) {
|
||||
$search_flag = 1;
|
||||
$start_date = $date_from;
|
||||
$last_date = $date_to;
|
||||
} else {
|
||||
$date_from = date('Y-m-d');
|
||||
$date_to = date('Y-m-t');
|
||||
$start_date = date('Y-m-01'); // hard-coded '01' for first day
|
||||
$last_date = date('Y-m-t');
|
||||
}
|
||||
$bookingParams = array();
|
||||
$bookingParams['date_from'] = $date_from;
|
||||
$bookingParams['date_to'] = $date_to;
|
||||
$bookingParams['hotel_id'] = $rm_info['id_hotel'];
|
||||
$bookingParams['room_type'] = $obj->id;
|
||||
$bookingParams['adult'] = $rm_info['adult'];
|
||||
$bookingParams['children'] = $rm_info['children'];
|
||||
$bookingParams['num_rooms'] = 0;
|
||||
|
||||
$bookingParams['only_active_roomtype'] = 0;
|
||||
|
||||
$booking_data = $obj_booking_dtl->getBookingData($bookingParams);
|
||||
|
||||
$bookingParams['for_calendar'] = 1;
|
||||
while ($start_date <= $last_date) {
|
||||
$cal_date_from = $start_date;
|
||||
$cal_date_to = date('Y-m-d', strtotime('+1 day', strtotime($cal_date_from)));
|
||||
$booking_calendar_data[$cal_date_from] = $obj_booking_dtl->getBookingData($bookingParams);
|
||||
|
||||
// if product is inactive then booking_details will be false
|
||||
if (!$booking_calendar_data[$cal_date_from]) {
|
||||
$booking_calendar_data[$cal_date_from]['stats']['num_avail'] = 0;
|
||||
$booking_calendar_data[$cal_date_from]['stats']['num_part_avai'] = 0;
|
||||
$booking_calendar_data[$cal_date_from]['stats']['num_unavail'] = 0;
|
||||
$booking_calendar_data[$cal_date_from]['stats']['num_booked'] = 0;
|
||||
}
|
||||
$start_date = date('Y-m-d', strtotime('+1 day', strtotime($start_date)));
|
||||
}
|
||||
if (isset($search_flag) && $search_flag) {
|
||||
if ($booking_data['stats']['num_avail'] > 0) {
|
||||
$check_css_condition_var = 'available';
|
||||
} elseif ($booking_data['stats']['num_part_avai'] > 0) {
|
||||
$check_css_condition_var = 'part_available';
|
||||
} else {
|
||||
$check_css_condition_var = 'unavailable';
|
||||
}
|
||||
} else {
|
||||
if ($booking_data['stats']['num_avail'] > 0) {
|
||||
$check_css_condition_var = 'default_available';
|
||||
} elseif ($booking_data['stats']['num_part_avai'] > 0) {
|
||||
$check_css_condition_var = 'default_part_available';
|
||||
} else {
|
||||
$check_css_condition_var = 'default_unavailable';
|
||||
}
|
||||
}
|
||||
|
||||
$data->assign(
|
||||
array(
|
||||
'rooms_info' => $rm_info,
|
||||
'check_calendar_var' => 1,
|
||||
'date_from' => $date_from,
|
||||
'date_to' => $date_to,
|
||||
'booking_data' => $booking_data,
|
||||
'booking_calendar_data' => $booking_calendar_data,
|
||||
'htl_config' => 1,
|
||||
'check_css_condition_var' => $check_css_condition_var,
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$this->displayWarning($this->l('First you have to fill Room configuration.'));
|
||||
}
|
||||
} else {
|
||||
$this->displayWarning($this->l('You must save the room type in this shop before managing hotel configuration.'));
|
||||
}
|
||||
} else {
|
||||
$this->displayWarning($this->l('You must save this room type to see the booking information.'));
|
||||
}
|
||||
$this->tpl_form_vars['custom_form'] = $data->fetch();
|
||||
}
|
||||
|
||||
public function processBooking()
|
||||
{
|
||||
if (Tools::isSubmit('submitAddproductAndStay')) {
|
||||
$checkTabClick = Tools::getValue('checkTabClick');
|
||||
$date_from = Tools::getValue('from_date');
|
||||
$date_to = Tools::getValue('to_date');
|
||||
$num_rooms = Tools::getValue('num_rooms');
|
||||
$id_product = Tools::getValue('id_product');
|
||||
|
||||
$link = new Link();
|
||||
if ($checkTabClick) {
|
||||
Tools::redirectAdmin($link->getAdminLink('AdminProducts').'&id_product='.$id_product.'&updateproduct&key_tab=Booking&date_from='.$date_from.'&date_to='.$date_to);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function ajaxProcessProductRoomsBookingDetailsOnMonthChange()
|
||||
{
|
||||
$month = Tools::getValue('month');
|
||||
$year = Tools::getValue('year');
|
||||
$query_date = $year.'-'.$month.'-04';
|
||||
$start_date = date('Y-m-01', strtotime($query_date)); // hard-coded '01' for first day
|
||||
$last_day_this_month = date('Y-m-t', strtotime($query_date));
|
||||
$hotel_id = Tools::getValue('id_hotel');
|
||||
$room_type = Tools::getValue('id_product');
|
||||
$adult = Tools::getValue('num_adults');
|
||||
$children = Tools::getValue('num_children');
|
||||
$num_rooms = 1;
|
||||
|
||||
$obj_booking_dtl = new HotelBookingDetail();
|
||||
$bookingParams = array();
|
||||
$bookingParams['hotel_id'] = $hotel_id;
|
||||
$bookingParams['room_type'] = $room_type;
|
||||
$bookingParams['adult'] = $adult;
|
||||
$bookingParams['children'] = $children;
|
||||
$bookingParams['num_rooms'] = $num_rooms;
|
||||
$bookingParams['for_calendar'] = 1;
|
||||
while ($start_date <= $last_day_this_month) {
|
||||
$cal_date_from = $start_date;
|
||||
$cal_date_to = date('Y-m-d', strtotime($cal_date_from) + 86400);
|
||||
|
||||
$bookingParams['date_from'] = $cal_date_from;
|
||||
$bookingParams['date_to'] = $cal_date_to;
|
||||
$booking_calendar_data[$cal_date_from] = $obj_booking_dtl->getBookingData($bookingParams);
|
||||
$start_date = date('Y-m-d', strtotime($start_date) + 86400);
|
||||
}
|
||||
|
||||
if ($booking_calendar_data) {
|
||||
die(json_encode($booking_calendar_data));
|
||||
} else {
|
||||
die(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Product $obj
|
||||
*
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -41,7 +41,6 @@ abstract class AdminStatsTabControllerCore extends AdminPreferencesControllerCor
|
||||
}
|
||||
|
||||
$this->initTabModuleList();
|
||||
$this->addToolBarModulesListButton();
|
||||
$this->toolbar_title = $this->l('Stats', 'AdminStatsTab');
|
||||
$this->initPageHeaderToolbar();
|
||||
if ($this->display == 'view') {
|
||||
@@ -104,6 +103,7 @@ abstract class AdminStatsTabControllerCore extends AdminPreferencesControllerCor
|
||||
$module = Tools::getValue('module');
|
||||
$action .= ($module ? '&module='.Tools::safeOutput($module) : '');
|
||||
$action .= (($id_product = Tools::getValue('id_product')) ? '&id_product='.Tools::safeOutput($id_product) : '');
|
||||
$action .= (($id_hotel = Tools::getValue('id_hotel')) ? '&id_hotel='.Tools::safeOutput($id_hotel) : '');
|
||||
$tpl->assign(array(
|
||||
'current' => self::$currentIndex,
|
||||
'token' => $token,
|
||||
|
||||
@@ -449,14 +449,14 @@ class AdminStoresControllerCore extends AdminController
|
||||
|
||||
$formFields = array(
|
||||
'PS_SHOP_NAME' => array(
|
||||
'title' => $this->l('Shop name'),
|
||||
'title' => $this->l('Website name'),
|
||||
'hint' => $this->l('Displayed in emails and page titles.'),
|
||||
'validation' => 'isGenericName',
|
||||
'required' => true,
|
||||
'type' => 'text',
|
||||
'no_escape' => true,
|
||||
),
|
||||
'PS_SHOP_EMAIL' => array('title' => $this->l('Shop email'),
|
||||
'PS_SHOP_EMAIL' => array('title' => $this->l('Website email'),
|
||||
'hint' => $this->l('Displayed in emails sent to customers.'),
|
||||
'validation' => 'isEmail',
|
||||
'required' => true,
|
||||
@@ -464,19 +464,19 @@ class AdminStoresControllerCore extends AdminController
|
||||
),
|
||||
'PS_SHOP_DETAILS' => array(
|
||||
'title' => $this->l('Registration number'),
|
||||
'hint' => $this->l('Shop registration information (e.g. SIRET or RCS).'),
|
||||
'hint' => $this->l('Website registration information (e.g. SIRET or RCS).'),
|
||||
'validation' => 'isGenericName',
|
||||
'type' => 'textarea',
|
||||
'cols' => 30,
|
||||
'rows' => 5
|
||||
),
|
||||
'PS_SHOP_ADDR1' => array(
|
||||
'title' => $this->l('Shop address line 1'),
|
||||
'title' => $this->l('Address line 1'),
|
||||
'validation' => 'isAddress',
|
||||
'type' => 'text'
|
||||
),
|
||||
'PS_SHOP_ADDR2' => array(
|
||||
'title' => $this->l('Shop address line 2'),
|
||||
'title' => $this->l('Address line 2'),
|
||||
'validation' => 'isAddress',
|
||||
'type' => 'text'
|
||||
),
|
||||
|
||||
@@ -506,7 +506,7 @@ class AdminThemesControllerCore extends AdminController
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
if (!$this->isFresh(Theme::CACHE_FILE_CUSTOMER_THEMES_LIST, 86400)) {
|
||||
if (!$this->isFresh(Theme::CACHE_FILE_CUSTOMER_THEMES_LIST, _TIME_1_DAY_)) {
|
||||
file_put_contents(_PS_ROOT_DIR_.Theme::CACHE_FILE_CUSTOMER_THEMES_LIST, Tools::addonsRequest('customer_themes'));
|
||||
}
|
||||
|
||||
@@ -2075,6 +2075,15 @@ class AdminThemesControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
foreach ($xml->modules as $row) {
|
||||
if ($row['type'] == 'disk') {
|
||||
foreach ($row->module as $row2) {
|
||||
$natives[] = (string)$row2['name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (count($natives) > 0) {
|
||||
@@ -2111,7 +2120,7 @@ class AdminThemesControllerCore extends AdminController
|
||||
'mailalerts',
|
||||
'newsletter',
|
||||
'pagesnotfound',
|
||||
'productcomments',
|
||||
'qlohotelreview',
|
||||
'referralprogram',
|
||||
'sekeywords',
|
||||
'statsbestcategories',
|
||||
|
||||
@@ -45,9 +45,6 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
/** @var array */
|
||||
protected $modules_translations = array();
|
||||
|
||||
/** @var array : List of folder which must be ignored */
|
||||
protected static $ignore_folder = array('.', '..', '.svn', '.git', '.htaccess', 'index.php');
|
||||
|
||||
/** @var array : List of theme by translation type : FRONT, BACK, ERRORS... */
|
||||
protected $translations_informations = array();
|
||||
|
||||
@@ -295,9 +292,6 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
$thm_name = str_replace('.', '', Tools::getValue('theme'));
|
||||
$kpi_key = substr(strtoupper($thm_name.'_'.Tools::getValue('lang')), 0, 16);
|
||||
|
||||
if ($fd = fopen($file_path, 'w')) {
|
||||
// Get value of button save and stay
|
||||
$save_and_stay = Tools::isSubmit('submitTranslations'.$type.'AndStay');
|
||||
@@ -323,9 +317,6 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
ConfigurationKPI::updateValue('TRANSLATE_TOTAL_'.$kpi_key, count($_POST));
|
||||
ConfigurationKPI::updateValue('TRANSLATE_DONE_'.$kpi_key, count($to_insert));
|
||||
|
||||
// translations array is ordered by key (easy merge)
|
||||
ksort($to_insert);
|
||||
$tab = $translation_informations['var'];
|
||||
@@ -535,7 +526,7 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
|
||||
// Add mails files
|
||||
foreach ($arr_mails_needed as $mail_to_add) {
|
||||
if (!in_array($mail_to_add, self::$ignore_folder)) {
|
||||
if (!in_array($mail_to_add, Translate::$ignore_folder)) {
|
||||
@copy(_PS_MAIL_DIR_.$default_language.'/'.$mail_to_add, _PS_MAIL_DIR_.$iso_code.'/'.$mail_to_add);
|
||||
}
|
||||
}
|
||||
@@ -547,11 +538,11 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
$module_mail_iso_code = array();
|
||||
|
||||
foreach ($modules as $module) {
|
||||
if (!in_array($module, self::$ignore_folder) && Tools::file_exists_cache(_PS_MODULE_DIR_.$module.'/mails/'.$default_language.'/')) {
|
||||
if (!in_array($module, Translate::$ignore_folder) && Tools::file_exists_cache(_PS_MODULE_DIR_.$module.'/mails/'.$default_language.'/')) {
|
||||
$arr_files = scandir(_PS_MODULE_DIR_.$module.'/mails/'.$default_language.'/');
|
||||
|
||||
foreach ($arr_files as $file) {
|
||||
if (!in_array($file, self::$ignore_folder)) {
|
||||
if (!in_array($file, Translate::$ignore_folder)) {
|
||||
if (Tools::file_exists_cache(_PS_MODULE_DIR_.$module.'/mails/'.$default_language.'/'.$file)) {
|
||||
$module_mail_en[] = _PS_MODULE_DIR_.$module.'/mails/ISO_CODE/'.$file;
|
||||
}
|
||||
@@ -962,7 +953,7 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
}
|
||||
|
||||
foreach ($files as $file) {
|
||||
if (preg_match('/^(.*)\.(tpl|php)$/', $file) && Tools::file_exists_cache($dir.$file) && !in_array($file, self::$ignore_folder)) {
|
||||
if (preg_match('/^(.*)\.(tpl|php)$/', $file) && Tools::file_exists_cache($dir.$file) && !in_array($file, Translate::$ignore_folder)) {
|
||||
// Get content for this file
|
||||
$content = file_get_contents($dir.$file);
|
||||
|
||||
@@ -970,7 +961,7 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
$type_file = substr($file, -4) == '.tpl' ? 'tpl' : 'php';
|
||||
|
||||
// Parse this content
|
||||
$matches = $this->userParseFile($content, $this->type_selected, $type_file, $module_name);
|
||||
$matches = Translate::userParseFile($content, $this->type_selected, $type_file, $module_name);
|
||||
|
||||
// Write each translation on its module file
|
||||
$template_name = substr(basename($file), 0, -4);
|
||||
@@ -1065,7 +1056,7 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
$type_file = substr($file, -4) == '.tpl' ? 'tpl' : 'php';
|
||||
|
||||
// Parse this content
|
||||
$matches = $this->userParseFile($content, $this->type_selected, $type_file, $module_name);
|
||||
$matches = Translate::userParseFile($content, $this->type_selected, $type_file, $module_name);
|
||||
|
||||
// Write each translation on its module file
|
||||
$template_name = substr(basename($file), 0, -4);
|
||||
@@ -1088,7 +1079,7 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
$this->modules_translations[$theme_name][$module_name][$template_name][$key]['trad'] = '';
|
||||
$this->missing_translations++;
|
||||
}
|
||||
$this->modules_translations[$theme_name][$module_name][$template_name][$key]['use_sprintf'] = $this->checkIfKeyUseSprintf($key);
|
||||
$this->modules_translations[$theme_name][$module_name][$template_name][$key]['use_sprintf'] = Translate::checkIfKeyUseSprintf($key);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1107,14 +1098,14 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
switch ($this->type_selected) {
|
||||
case 'front':
|
||||
$directories['tpl'] = array(_PS_ALL_THEMES_DIR_ => scandir(_PS_ALL_THEMES_DIR_));
|
||||
self::$ignore_folder[] = 'modules';
|
||||
$directories['tpl'] = array_merge($directories['tpl'], $this->listFiles(_PS_THEME_SELECTED_DIR_));
|
||||
Translate::$ignore_folder[] = 'modules';
|
||||
$directories['tpl'] = array_merge($directories['tpl'], Translate::listFiles(_PS_THEME_SELECTED_DIR_));
|
||||
if (isset($directories['tpl'][_PS_THEME_SELECTED_DIR_.'pdf/'])) {
|
||||
unset($directories['tpl'][_PS_THEME_SELECTED_DIR_.'pdf/']);
|
||||
}
|
||||
|
||||
if (Tools::file_exists_cache(_PS_THEME_OVERRIDE_DIR_)) {
|
||||
$directories['tpl'] = array_merge($directories['tpl'], $this->listFiles(_PS_THEME_OVERRIDE_DIR_));
|
||||
$directories['tpl'] = array_merge($directories['tpl'], Translate::listFiles(_PS_THEME_OVERRIDE_DIR_));
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -1128,7 +1119,7 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
_PS_CLASS_DIR_.'controller/' => array('AdminController.php'),
|
||||
_PS_CLASS_DIR_ => array('PaymentModule.php')
|
||||
),
|
||||
'tpl' => $this->listFiles(_PS_ADMIN_DIR_.DIRECTORY_SEPARATOR.'themes/'),
|
||||
'tpl' => Translate::listFiles(_PS_ADMIN_DIR_.DIRECTORY_SEPARATOR.'themes/'),
|
||||
'specific' => array(
|
||||
_PS_ADMIN_DIR_.DIRECTORY_SEPARATOR => array(
|
||||
'header.inc.php',
|
||||
@@ -1141,7 +1132,7 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
|
||||
// For translate the template which are overridden
|
||||
if (file_exists(_PS_OVERRIDE_DIR_.'controllers'.DIRECTORY_SEPARATOR.'admin'.DIRECTORY_SEPARATOR.'templates')) {
|
||||
$directories['tpl'] = array_merge($directories['tpl'], $this->listFiles(_PS_OVERRIDE_DIR_.'controllers'.DIRECTORY_SEPARATOR.'admin'.DIRECTORY_SEPARATOR.'templates'));
|
||||
$directories['tpl'] = array_merge($directories['tpl'], Translate::listFiles(_PS_OVERRIDE_DIR_.'controllers'.DIRECTORY_SEPARATOR.'admin'.DIRECTORY_SEPARATOR.'templates'));
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -1157,12 +1148,12 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
);
|
||||
|
||||
// Get all files for folders classes/ and override/classes/ recursively
|
||||
$directories['php'] = array_merge($directories['php'], $this->listFiles(_PS_CLASS_DIR_, array(), 'php'));
|
||||
$directories['php'] = array_merge($directories['php'], $this->listFiles(_PS_OVERRIDE_DIR_.'classes/', array(), 'php'));
|
||||
$directories['php'] = array_merge($directories['php'], Translate::listFiles(_PS_CLASS_DIR_, array(), 'php'));
|
||||
$directories['php'] = array_merge($directories['php'], Translate::listFiles(_PS_OVERRIDE_DIR_.'classes/', array(), 'php'));
|
||||
break;
|
||||
|
||||
case 'fields':
|
||||
$directories['php'] = $this->listFiles(_PS_CLASS_DIR_, array(), 'php');
|
||||
$directories['php'] = Translate::listFiles(_PS_CLASS_DIR_, array(), 'php');
|
||||
break;
|
||||
|
||||
case 'pdf':
|
||||
@@ -1192,8 +1183,8 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
);
|
||||
|
||||
// Get all files for folders classes/ and override/classes/ recursively
|
||||
$directories['php'] = array_merge($directories['php'], $this->listFiles(_PS_CLASS_DIR_, array(), 'php'));
|
||||
$directories['php'] = array_merge($directories['php'], $this->listFiles(_PS_OVERRIDE_DIR_.'classes/', array(), 'php'));
|
||||
$directories['php'] = array_merge($directories['php'], Translate::listFiles(_PS_CLASS_DIR_, array(), 'php'));
|
||||
$directories['php'] = array_merge($directories['php'], Translate::listFiles(_PS_OVERRIDE_DIR_.'classes/', array(), 'php'));
|
||||
$directories['php'] = array_merge($directories['php'], $this->getModulesHasMails());
|
||||
break;
|
||||
|
||||
@@ -1202,88 +1193,6 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
return $directories;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method parse a file by type of translation and type file
|
||||
*
|
||||
* @param $content
|
||||
* @param $type_translation : front, back, errors, modules...
|
||||
* @param string|bool $type_file : (tpl|php)
|
||||
* @param string $module_name : name of the module
|
||||
* @return array
|
||||
*/
|
||||
protected function userParseFile($content, $type_translation, $type_file = false, $module_name = '')
|
||||
{
|
||||
switch ($type_translation) {
|
||||
case 'front':
|
||||
// Parsing file in Front office
|
||||
$regex = '/\{l\s*s=([\'\"])'._PS_TRANS_PATTERN_.'\1(\s*sprintf=.*)?(\s*js=1)?\s*\}/U';
|
||||
break;
|
||||
|
||||
case 'back':
|
||||
// Parsing file in Back office
|
||||
if ($type_file == 'php') {
|
||||
$regex = '/this->l\((\')'._PS_TRANS_PATTERN_.'\'[\)|\,]/U';
|
||||
} elseif ($type_file == 'specific') {
|
||||
$regex = '/Translate::getAdminTranslation\((\')'._PS_TRANS_PATTERN_.'\'(?:,.*)*\)/U';
|
||||
} else {
|
||||
$regex = '/\{l\s*s\s*=([\'\"])'._PS_TRANS_PATTERN_.'\1(\s*sprintf=.*)?(\s*js=1)?(\s*slashes=1)?.*\}/U';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'errors':
|
||||
// Parsing file for all errors syntax
|
||||
$regex = '/Tools::displayError\((\')'._PS_TRANS_PATTERN_.'\'(,\s*(.+))?\)/U';
|
||||
break;
|
||||
|
||||
case 'modules':
|
||||
// Parsing modules file
|
||||
if ($type_file == 'php') {
|
||||
$regex = '/->l\((\')'._PS_TRANS_PATTERN_.'\'(, ?\'(.+)\')?(, ?(.+))?\)/U';
|
||||
} else {
|
||||
// In tpl file look for something that should contain mod='module_name' according to the documentation
|
||||
$regex = '/\{l\s*s=([\'\"])'._PS_TRANS_PATTERN_.'\1.*\s+mod=\''.$module_name.'\'.*\}/U';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'pdf':
|
||||
// Parsing PDF file
|
||||
if ($type_file == 'php') {
|
||||
$regex = array(
|
||||
'/HTMLTemplate.*::l\((\')'._PS_TRANS_PATTERN_.'\'[\)|\,]/U',
|
||||
'/->l\((\')'._PS_TRANS_PATTERN_.'\'(, ?\'(.+)\')?(, ?(.+))?\)/U'
|
||||
);
|
||||
} else {
|
||||
$regex = '/\{l\s*s=([\'\"])'._PS_TRANS_PATTERN_.'\1(\s*sprintf=.*)?(\s*js=1)?(\s*pdf=\'true\')?\s*\}/U';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (!is_array($regex)) {
|
||||
$regex = array($regex);
|
||||
}
|
||||
|
||||
$strings = array();
|
||||
foreach ($regex as $regex_row) {
|
||||
$matches = array();
|
||||
$n = preg_match_all($regex_row, $content, $matches);
|
||||
for ($i = 0; $i < $n; $i += 1) {
|
||||
$quote = $matches[1][$i];
|
||||
$string = $matches[2][$i];
|
||||
|
||||
if ($quote === '"') {
|
||||
// Escape single quotes because the core will do it when looking for the translation of this string
|
||||
$string = str_replace('\'', '\\\'', $string);
|
||||
// Unescape double quotes
|
||||
$string = preg_replace('/\\\\+"/', '"', $string);
|
||||
}
|
||||
|
||||
$strings[] = $string;
|
||||
}
|
||||
}
|
||||
|
||||
return array_unique($strings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all translations informations for all type of translations
|
||||
*
|
||||
@@ -1419,22 +1328,25 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
$kpis[] = $helper->generate();
|
||||
|
||||
$helper = new HelperKpi();
|
||||
$helper->id = 'box-country';
|
||||
$helper->icon = 'icon-home';
|
||||
$helper->color = 'color2';
|
||||
$helper->title = $this->l('Main Country', null, null, false);
|
||||
$helper->subtitle = $this->l('30 Days', null, null, false);
|
||||
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=main_country';
|
||||
$kpis[] = $helper->generate();
|
||||
|
||||
$helper = new HelperKpi();
|
||||
$helper->id = 'box-translations';
|
||||
$helper->id = 'box-fo-translations';
|
||||
$helper->icon = 'icon-list';
|
||||
$helper->color = 'color3';
|
||||
$helper->title = $this->l('Front office Translations', null, null, false);
|
||||
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=frontoffice_translations';
|
||||
$kpis[] = $helper->generate();
|
||||
|
||||
$helper = new HelperKpi();
|
||||
$helper->id = 'box-bo-translations';
|
||||
$helper->icon = 'icon-list';
|
||||
$helper->color = 'color4';
|
||||
$helper->title = $this->l('Back office Translations', null, null, false);
|
||||
if (ConfigurationKPI::get('BACKOFFICE_TRANSLATIONS') !== false) {
|
||||
$helper->value = ConfigurationKPI::get('BACKOFFICE_TRANSLATIONS');
|
||||
}
|
||||
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=backoffice_translations';
|
||||
$helper->refresh = (bool)(ConfigurationKPI::get('BACKOFFICE_TRANSLATIONS_EXPIRE') < $time);
|
||||
$kpis[] = $helper->generate();
|
||||
|
||||
$helper = new HelperKpiRow();
|
||||
$helper->kpis = $kpis;
|
||||
return $helper->generate();
|
||||
@@ -1736,20 +1648,6 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find sentence which use %d, %s, %%, %1$d, %1$s...
|
||||
*
|
||||
* @param $key : english sentence
|
||||
* @return array|bool return list of matches
|
||||
*/
|
||||
public function checkIfKeyUseSprintf($key)
|
||||
{
|
||||
if (preg_match_all('#(?:%%|%(?:[0-9]+\$)?[+-]?(?:[ 0]|\'.)?-?[0-9]*(?:\.[0-9]+)?[bcdeufFosxX])#', $key, $matches)) {
|
||||
return implode(', ', $matches[0]);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method generate the form for front translations
|
||||
*/
|
||||
@@ -1783,7 +1681,7 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
$content = file_get_contents($file_path);
|
||||
|
||||
// Parse this content
|
||||
$matches = $this->userParseFile($content, $this->type_selected);
|
||||
$matches = Translate::userParseFile($content, $this->type_selected);
|
||||
|
||||
/* Get string translation */
|
||||
foreach ($matches as $key) {
|
||||
@@ -1804,7 +1702,7 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
}
|
||||
$new_lang[$key]['use_sprintf'] = $this->checkIfKeyUseSprintf($key);
|
||||
$new_lang[$key]['use_sprintf'] = Translate::checkIfKeyUseSprintf($key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1850,7 +1748,7 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
foreach ($files_per_directory['php'] as $dir => $files) {
|
||||
foreach ($files as $file) {
|
||||
// Check if is a PHP file and if the override file exists
|
||||
if (preg_match('/^(.*)\.php$/', $file) && Tools::file_exists_cache($file_path = $dir.$file) && !in_array($file, self::$ignore_folder)) {
|
||||
if (preg_match('/^(.*)\.php$/', $file) && Tools::file_exists_cache($file_path = $dir.$file) && !in_array($file, Translate::$ignore_folder)) {
|
||||
$prefix_key = basename($file);
|
||||
// -4 becomes -14 to remove the ending "Controller.php" from the filename
|
||||
if (strpos($file, 'Controller.php') !== false) {
|
||||
@@ -1871,7 +1769,7 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
$content = file_get_contents($file_path);
|
||||
|
||||
// Parse this content
|
||||
$matches = $this->userParseFile($content, $this->type_selected, 'php');
|
||||
$matches = Translate::userParseFile($content, $this->type_selected, 'php');
|
||||
|
||||
foreach ($matches as $key) {
|
||||
// Caution ! front has underscore between prefix key and md5, back has not
|
||||
@@ -1890,7 +1788,7 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
}
|
||||
$tabs_array[$prefix_key][$key]['use_sprintf'] = $this->checkIfKeyUseSprintf($key);
|
||||
$tabs_array[$prefix_key][$key]['use_sprintf'] = Translate::checkIfKeyUseSprintf($key);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1898,14 +1796,14 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
|
||||
foreach ($files_per_directory['specific'] as $dir => $files) {
|
||||
foreach ($files as $file) {
|
||||
if (Tools::file_exists_cache($file_path = $dir.$file) && !in_array($file, self::$ignore_folder)) {
|
||||
if (Tools::file_exists_cache($file_path = $dir.$file) && !in_array($file, Translate::$ignore_folder)) {
|
||||
$prefix_key = 'index';
|
||||
|
||||
// Get content for this file
|
||||
$content = file_get_contents($file_path);
|
||||
|
||||
// Parse this content
|
||||
$matches = $this->userParseFile($content, $this->type_selected, 'specific');
|
||||
$matches = Translate::userParseFile($content, $this->type_selected, 'specific');
|
||||
|
||||
foreach ($matches as $key) {
|
||||
// Caution ! front has underscore between prefix key and md5, back has not
|
||||
@@ -1924,7 +1822,7 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
}
|
||||
$tabs_array[$prefix_key][$key]['use_sprintf'] = $this->checkIfKeyUseSprintf($key);
|
||||
$tabs_array[$prefix_key][$key]['use_sprintf'] = Translate::checkIfKeyUseSprintf($key);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1976,7 +1874,7 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
$content = file_get_contents($file_path);
|
||||
|
||||
// Parse this content
|
||||
$matches = $this->userParseFile($content, $this->type_selected, 'tpl');
|
||||
$matches = Translate::userParseFile($content, $this->type_selected, 'tpl');
|
||||
|
||||
/* Get string translation for each tpl file */
|
||||
foreach ($matches as $english_string) {
|
||||
@@ -2001,7 +1899,7 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
}
|
||||
$new_lang[$english_string]['use_sprintf'] = $this->checkIfKeyUseSprintf($english_string);
|
||||
$new_lang[$english_string]['use_sprintf'] = Translate::checkIfKeyUseSprintf($english_string);
|
||||
}
|
||||
}
|
||||
if (isset($tabs_array[$prefix_key])) {
|
||||
@@ -2074,15 +1972,15 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
|
||||
if ($modules = $this->getListModules()) {
|
||||
foreach ($modules as $module) {
|
||||
if (is_dir(_PS_MODULE_DIR_.$module) && !in_array($module, self::$ignore_folder)) {
|
||||
$file_by_directory['php'] = array_merge($file_by_directory['php'], $this->listFiles(_PS_MODULE_DIR_.$module.'/', array(), 'php'));
|
||||
if (is_dir(_PS_MODULE_DIR_.$module) && !in_array($module, Translate::$ignore_folder)) {
|
||||
$file_by_directory['php'] = array_merge($file_by_directory['php'], Translate::listFiles(_PS_MODULE_DIR_.$module.'/', array(), 'php'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($file_by_directory['php'] as $dir => $files) {
|
||||
foreach ($files as $file) {
|
||||
if (preg_match('/\.php$/', $file) && Tools::file_exists_cache($file_path = $dir.$file) && !in_array($file, self::$ignore_folder)) {
|
||||
if (preg_match('/\.php$/', $file) && Tools::file_exists_cache($file_path = $dir.$file) && !in_array($file, Translate::$ignore_folder)) {
|
||||
if (!filesize($file_path)) {
|
||||
continue;
|
||||
}
|
||||
@@ -2091,7 +1989,7 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
$content = file_get_contents($file_path);
|
||||
|
||||
// Parse this content
|
||||
$matches = $this->userParseFile($content, $this->type_selected);
|
||||
$matches = Translate::userParseFile($content, $this->type_selected);
|
||||
|
||||
foreach ($matches as $key) {
|
||||
if (array_key_exists(md5($key), $GLOBALS[$name_var])) {
|
||||
@@ -2102,7 +2000,7 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
$count_empty[$key] = 1;
|
||||
}
|
||||
}
|
||||
$string_to_translate[$key]['use_sprintf'] = $this->checkIfKeyUseSprintf($key);
|
||||
$string_to_translate[$key]['use_sprintf'] = Translate::checkIfKeyUseSprintf($key);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2498,7 +2396,7 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
{
|
||||
$arr_modules = array();
|
||||
foreach (scandir($this->translations_informations['modules']['dir']) as $module_dir) {
|
||||
if (!in_array($module_dir, self::$ignore_folder)) {
|
||||
if (!in_array($module_dir, Translate::$ignore_folder)) {
|
||||
$dir = false;
|
||||
if ($this->theme_selected && Tools::file_exists_cache($this->translations_informations['modules']['override']['dir'].$module_dir.'/mails/')) {
|
||||
$dir = $this->translations_informations['modules']['override']['dir'].$module_dir.'/';
|
||||
@@ -2531,7 +2429,7 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
{
|
||||
$arr_modules = array();
|
||||
foreach (scandir($this->translations_informations['modules']['dir']) as $module_dir) {
|
||||
if (!in_array($module_dir, self::$ignore_folder)) {
|
||||
if (!in_array($module_dir, Translate::$ignore_folder)) {
|
||||
$dir = false;
|
||||
if ($classes) {
|
||||
if ($this->theme_selected && Tools::file_exists_cache($this->translations_informations['modules']['override']['dir'].$module_dir.'/classes/')) {
|
||||
@@ -2598,7 +2496,7 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
foreach ($files_by_directiories['php'] as $dir => $files) {
|
||||
foreach ($files as $file) {
|
||||
// If file exist and is not in ignore_folder, in the next step we check if a folder or mail
|
||||
if (Tools::file_exists_cache($dir.$file) && !in_array($file, self::$ignore_folder)) {
|
||||
if (Tools::file_exists_cache($dir.$file) && !in_array($file, Translate::$ignore_folder)) {
|
||||
$subject_mail = $this->getSubjectMail($dir, $file, $subject_mail);
|
||||
}
|
||||
}
|
||||
@@ -2669,7 +2567,7 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
|
||||
foreach ($dir_to_copy_iso as $dir) {
|
||||
foreach (scandir($dir) as $file) {
|
||||
if (!in_array($file, self::$ignore_folder)) {
|
||||
if (!in_array($file, Translate::$ignore_folder)) {
|
||||
$files_to_copy_iso[] = array(
|
||||
"from" => $dir.$file,
|
||||
"to" => str_replace((strpos($dir, _PS_CORE_DIR_) !== false) ? _PS_CORE_DIR_ : _PS_ROOT_DIR_, _PS_ROOT_DIR_.'/themes/'.$current_theme, $dir).$file
|
||||
@@ -2715,7 +2613,7 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
{
|
||||
$dir = rtrim($dir, '/');
|
||||
// If is file and is not in ignore_folder
|
||||
if (is_file($dir.'/'.$file) && !in_array($file, self::$ignore_folder) && preg_match('/\.php$/', $file)) {
|
||||
if (is_file($dir.'/'.$file) && !in_array($file, Translate::$ignore_folder) && preg_match('/\.php$/', $file)) {
|
||||
$content = file_get_contents($dir.'/'.$file);
|
||||
$content = str_replace("\n", ' ', $content);
|
||||
|
||||
@@ -2740,7 +2638,7 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
// Or if is folder, we scan folder for check if found in folder and subfolder
|
||||
elseif (!in_array($file, self::$ignore_folder) && is_dir($dir.'/'.$file)) {
|
||||
elseif (!in_array($file, Translate::$ignore_folder) && is_dir($dir.'/'.$file)) {
|
||||
foreach (scandir($dir.'/'.$file) as $temp) {
|
||||
if ($temp[0] != '.') {
|
||||
$subject_mail = $this->getSubjectMail($dir.'/'.$file, $temp, $subject_mail);
|
||||
@@ -2768,7 +2666,7 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
$subject = str_replace("\\'", "\'", $subject);
|
||||
|
||||
$subject_mail_content[$key]['trad'] = htmlentities($subject, ENT_QUOTES, 'UTF-8');
|
||||
$subject_mail_content[$key]['use_sprintf'] = $this->checkIfKeyUseSprintf($key);
|
||||
$subject_mail_content[$key]['use_sprintf'] = Translate::checkIfKeyUseSprintf($key);
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = sprintf($this->l('Email subject translation file not found in "%s".'), $directory);
|
||||
@@ -2952,7 +2850,7 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
$content = file_get_contents($file_path);
|
||||
|
||||
// Parse this content
|
||||
$matches = $this->userParseFile($content, $this->type_selected, $file_type);
|
||||
$matches = Translate::userParseFile($content, $this->type_selected, $file_type);
|
||||
|
||||
foreach ($matches as $key) {
|
||||
if (stripslashes(array_key_exists($tab.md5(addslashes($key)), $lang_array))) {
|
||||
@@ -2965,7 +2863,7 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
$count_missing[$tab]++;
|
||||
}
|
||||
}
|
||||
$tabs_array[$tab][$key]['use_sprintf'] = $this->checkIfKeyUseSprintf($key);
|
||||
$tabs_array[$tab][$key]['use_sprintf'] = Translate::checkIfKeyUseSprintf($key);
|
||||
}
|
||||
|
||||
return $tabs_array;
|
||||
@@ -3010,14 +2908,14 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
foreach ($files_by_directory as $type => $directories) {
|
||||
foreach ($directories as $dir => $files) {
|
||||
foreach ($files as $file) {
|
||||
if (!in_array($file, self::$ignore_folder) && Tools::file_exists_cache($file_path = $dir.$file)) {
|
||||
if (!in_array($file, Translate::$ignore_folder) && Tools::file_exists_cache($file_path = $dir.$file)) {
|
||||
if ($type == 'tpl') {
|
||||
if (Tools::file_exists_cache($file_path) && is_file($file_path)) {
|
||||
// Get content for this file
|
||||
$content = file_get_contents($file_path);
|
||||
|
||||
// Parse this content
|
||||
$matches = $this->userParseFile($content, $this->type_selected, 'tpl');
|
||||
$matches = Translate::userParseFile($content, $this->type_selected, 'tpl');
|
||||
|
||||
foreach ($matches as $key) {
|
||||
if (isset($GLOBALS[$name_var][$prefix_key.md5($key)])) {
|
||||
@@ -3032,7 +2930,7 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
}
|
||||
$tabs_array[$prefix_key][$key]['use_sprintf'] = $this->checkIfKeyUseSprintf($key);
|
||||
$tabs_array[$prefix_key][$key]['use_sprintf'] = Translate::checkIfKeyUseSprintf($key);
|
||||
}
|
||||
}
|
||||
} elseif (Tools::file_exists_cache($file_path)) {
|
||||
@@ -3057,33 +2955,6 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
return parent::renderView();
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively list files in directory $dir
|
||||
*
|
||||
* @param string $dir
|
||||
* @param array $list
|
||||
* @param string $file_ext
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function listFiles($dir, $list = array(), $file_ext = 'tpl')
|
||||
{
|
||||
$dir = rtrim($dir, '/').DIRECTORY_SEPARATOR;
|
||||
|
||||
$to_parse = scandir($dir);
|
||||
// copied (and kind of) adapted from AdminImages.php
|
||||
foreach ($to_parse as $file) {
|
||||
if (!in_array($file, self::$ignore_folder)) {
|
||||
if (preg_match('#'.preg_quote($file_ext, '#').'$#i', $file)) {
|
||||
$list[$dir][] = $file;
|
||||
} elseif (is_dir($dir.$file)) {
|
||||
$list = $this->listFiles($dir.$file, $list, $file_ext);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if theme exists
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user