-
Notifications
You must be signed in to change notification settings - Fork 515
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #516 from sumitwebkul/gli-1106
Added: Channel manager connector module to QloApps
- Loading branch information
Showing
37 changed files
with
1,660 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
125 changes: 125 additions & 0 deletions
125
modules/qlochannelmanagerconnector/CustomizationPolicy.txt
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
## Channel Manager Connector |
60 changes: 60 additions & 0 deletions
60
modules/qlochannelmanagerconnector/classes/QcmcChannelManagerBooking.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
/** | ||
* 2010-2023 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 <[email protected]> | ||
* @copyright 2010-2023 Webkul IN | ||
* @license https://store.webkul.com/license.html | ||
*/ | ||
|
||
class QcmcChannelManagerBooking extends ObjectModel | ||
{ | ||
public $id_order; | ||
public $date_add; | ||
|
||
public static $definition = array( | ||
'table' => 'qcmc_channel_manager_booking', | ||
'primary' => 'id_channel_manager_booking', | ||
'fields' => array( | ||
'id_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), | ||
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false), | ||
), | ||
); | ||
|
||
/** | ||
* Returns bookings created by api by channel manager | ||
* @param integer $idOrder : send id_order if you want booking of a particular order | ||
* @param string $orderWay : Send order way (DESC|ASC) sorted by date_add | ||
* @return [array of bookings | false] | ||
*/ | ||
public static function getChannelManagerBookings($idOrder = 0, $orderWay = 'ASC') | ||
{ | ||
$sql = 'SELECT * FROM `'._DB_PREFIX_.'qcmc_channel_manager_booking` WHERE 1'; | ||
|
||
if ($idOrder) { | ||
$sql .= ' AND `id_order` = '.(int)$idOrder; | ||
} | ||
|
||
$sql .= ' ORDER BY `date_add` '.$orderWay; | ||
|
||
if ($result = Db::getInstance()->executeS($sql)) { | ||
if ($idOrder) { | ||
// if needs only one order row then send only one row from the array | ||
$result = $result[0]; | ||
} | ||
} | ||
|
||
return $result; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
modules/qlochannelmanagerconnector/classes/QcmcChannelManagerConnectorDb.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
/** | ||
* 2010-2023 Webkul. | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* All right is reserved, | ||
* Please go through LICENSE.txt file inside our module | ||
* | ||
* 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 CustomizationPolicy.txt file inside our module for more information. | ||
* | ||
* @author Webkul IN | ||
* @copyright 2010-2023 Webkul IN | ||
* @license LICENSE.txt | ||
*/ | ||
|
||
class QcmcChannelManagerConnectorDb | ||
{ | ||
public function createTables() | ||
{ | ||
$sql = 'CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'qcmc_channel_manager_booking` ( | ||
`id_channel_manager_booking` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, | ||
`id_order` INT(11) UNSIGNED NOT NULL, | ||
`date_add` DATETIME NOT NULL, | ||
PRIMARY KEY (`id_channel_manager_booking`) | ||
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8'; | ||
|
||
if (!Db::getInstance()->execute(trim($sql))) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
public function dropTables() | ||
{ | ||
return Db::getInstance()->execute('DROP TABLE IF EXISTS '._DB_PREFIX_.'qcmc_channel_manager_booking'); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
modules/qlochannelmanagerconnector/classes/QcmcClassInclude.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
/** | ||
* 2010-2023 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 <[email protected]> | ||
* @copyright 2010-2023 Webkul IN | ||
* @license https://store.webkul.com/license.html | ||
*/ | ||
|
||
require_once _PS_MODULE_DIR_.'qlochannelmanagerconnector/classes/QcmcChannelManagerConnectorDb.php'; | ||
require_once _PS_MODULE_DIR_.'qlochannelmanagerconnector/classes/QcmcChannelManagerBooking.php'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
/** | ||
* 2010-2023 Webkul. | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* All right is reserved, | ||
* Please go through LICENSE.txt file inside our module | ||
* | ||
* 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 CustomizationPolicy.txt file inside our module for more information. | ||
* | ||
* @author Webkul IN | ||
* @copyright 2010-2023 Webkul IN | ||
* @license LICENSE.txt | ||
*/ | ||
|
||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); | ||
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); | ||
|
||
header('Cache-Control: no-store, no-cache, must-revalidate'); | ||
header('Cache-Control: post-check=0, pre-check=0', false); | ||
header('Pragma: no-cache'); | ||
|
||
header('Location: ../../../'); | ||
exit; |
155 changes: 155 additions & 0 deletions
155
...annelmanagerconnector/controllers/admin/AdminQloappsChannelManagerConnectorController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
<?php | ||
/** | ||
* 2010-2023 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 <[email protected]> | ||
* @copyright 2010-2023 Webkul IN | ||
* @license https://store.webkul.com/license.html | ||
*/ | ||
|
||
class AdminQloappsChannelManagerConnectorController extends ModuleAdminController | ||
{ | ||
public function __construct() | ||
{ | ||
$this->table = 'qcmc_channel_manager_booking'; | ||
$this->className = 'QcmcChannelManagerBooking'; | ||
$this->bootstrap = true; | ||
$this->toolbar_title = $this->l('Channel Manager Bookings'); | ||
$this->context = Context::getContext(); | ||
$this->identifier = 'id_channel_manager_booking'; | ||
|
||
parent::__construct(); | ||
|
||
$this->_join .= ' INNER JOIN `'._DB_PREFIX_.'orders` ord ON (a.id_order = ord.`id_order`)'; | ||
|
||
$this->_select .= ' ord.`source`, ord.`total_paid`, ord.`total_paid_real`, IF(a.id_order, 1, 0) badge_success'; | ||
|
||
$this->_orderWay = 'DESC'; | ||
|
||
$this->fields_list = array( | ||
'id_order' => array( | ||
'title' => $this->l('Id order'), | ||
'align' => 'center', | ||
'havingFilter' => true, | ||
'callback' => 'getOrderLink', | ||
), | ||
'source' => array( | ||
'title' => $this->l('Channel'), | ||
'align' => 'center', | ||
), | ||
'total_paid' => array( | ||
'title' => $this->l('Order total'), | ||
'align' => 'center', | ||
'callback' => 'setPriceCurrency', | ||
'badge_success' => true, | ||
), | ||
'total_paid_real' => array( | ||
'title' => $this->l('Recieved amount'), | ||
'align' => 'center', | ||
'callback' => 'setPriceCurrencyWithBadge', | ||
), | ||
'date_add' => array( | ||
'title' => $this->l('Created on'), | ||
'align' => 'center', | ||
), | ||
); | ||
|
||
$this->list_no_link = true; | ||
} | ||
|
||
public function getOrderLink($id_order, $row) | ||
{ | ||
$displayData = ''; | ||
if ($id_order) { | ||
$displayData .= '#'.$id_order; | ||
// $displayData .= '<a target="_blank" href="'.$this->context->link->getAdminLink('AdminOrders').'&id_order='.$id_order. | ||
// '&vieworder">#'.$id_order.'</a>'; | ||
} | ||
return $displayData; | ||
} | ||
|
||
public function setPriceCurrency($value, $row) | ||
{ | ||
if (Validate::isLoadedObject($objOrder = new Order($row['id_order']))) { | ||
return Tools::displayPrice($value, (int)$objOrder->id_currency); | ||
} | ||
} | ||
|
||
public function setPriceCurrencyWithBadge($value, $row) | ||
{ | ||
$displayData = ''; | ||
if (Validate::isLoadedObject($objOrder = new Order($row['id_order']))) { | ||
$displayData .= '<span class="badge '.(($row['total_paid'] == $row['total_paid_real']) ? 'badge-success' : 'badge-danger').'">'; | ||
$displayData .= Tools::displayPrice($value, (int)$objOrder->id_currency); | ||
$displayData .= '</span>'; | ||
} | ||
|
||
return $displayData; | ||
} | ||
|
||
public function displayViewLink($token, $idRow, $name = null) | ||
{ | ||
if (Validate::isLoadedObject($objChannelManagerBooking = new QcmcChannelManagerBooking($idRow))) { | ||
return '<a class="btn btn-default" href="'.$this->context->link->getAdminLink('AdminOrders').'&id_order='.$objChannelManagerBooking->id_order. | ||
'&vieworder" title="'.$this->l('view details').'"><i class="icon-search-plus"></i> '.$this->l('View Order Detail').'</a>'; | ||
} | ||
} | ||
|
||
public function renderList() | ||
{ | ||
if ($channelManagerBookings = QcmcChannelManagerBooking::getChannelManagerBookings(0, 'DESC')) { | ||
$this->context->smarty->assign( | ||
array ( | ||
'icon' => 'icon-list', | ||
'toolbar_title' => 'icon-list', | ||
// As we get the bookings in descending order according to the date_add. So in the 0 index last booking will be found | ||
'last_booking_datetime' => Tools::displayDate($channelManagerBookings[0]['date_add'], null, true), | ||
) | ||
); | ||
|
||
// because in helper list tpl_vars is given priority and we need different List title than list title | ||
// In HelperList.php assigned: 'title' => array_key_exists('title', $this->tpl_vars) ? $this->tpl_vars['title'] : $this->title | ||
$this->tpl_list_vars['title'] = $this->l('Below is the list of all the bookings created by channel manager.'); | ||
|
||
unset($this->toolbar_btn['new']); | ||
|
||
$this->addRowAction('view'); | ||
|
||
return parent::renderList(); | ||
} else { | ||
$this->context->smarty->assign( | ||
array ( | ||
'module_dir' => _MODULE_DIR_, | ||
'current_datetime' => Tools::displayDate(date('Y-m-d H:i:s'), null, true), | ||
) | ||
); | ||
$this->content .= $this->context->smarty->fetch( | ||
_PS_MODULE_DIR_. | ||
'qlochannelmanagerconnector/views/templates/admin/qloapps_channel_manager_connector/channel_manager_connect_info.tpl' | ||
); | ||
} | ||
} | ||
|
||
public function setMedia() | ||
{ | ||
parent::setMedia(); | ||
|
||
if (QcmcChannelManagerBooking::getChannelManagerBookings()) { | ||
$this->addCSS(_MODULE_DIR_.'qlochannelmanagerconnector/views/css/admin/wk_cm_booking_list.css'); | ||
$this->addJS(_MODULE_DIR_.'qlochannelmanagerconnector/views/js/admin/wk_cm_booking_list.js'); | ||
} else { | ||
$this->addCSS(_MODULE_DIR_.'qlochannelmanagerconnector/views/css/admin/wk_cm_info.css'); | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
modules/qlochannelmanagerconnector/controllers/admin/index.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
/** | ||
* 2010-2023 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 <[email protected]> | ||
* @copyright 2010-2023 Webkul IN | ||
* @license https://store.webkul.com/license.html | ||
*/ | ||
|
||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); | ||
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); | ||
|
||
header('Cache-Control: no-store, no-cache, must-revalidate'); | ||
header('Cache-Control: post-check=0, pre-check=0', false); | ||
header('Pragma: no-cache'); | ||
|
||
header('Location: ../../../'); | ||
exit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
/** | ||
* 2010-2023 Webkul. | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* All right is reserved, | ||
* Please go through LICENSE.txt file inside our module | ||
* | ||
* 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 CustomizationPolicy.txt file inside our module for more information. | ||
* | ||
* @author Webkul IN | ||
* @copyright 2010-2023 Webkul IN | ||
* @license LICENSE.txt | ||
*/ | ||
|
||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); | ||
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); | ||
|
||
header('Cache-Control: no-store, no-cache, must-revalidate'); | ||
header('Cache-Control: post-check=0, pre-check=0', false); | ||
header('Pragma: no-cache'); | ||
|
||
header('Location: ../../../'); | ||
exit; |
Oops, something went wrong.