Skip to content

Commit

Permalink
6.15.0 (FINAL RELEASE)
Browse files Browse the repository at this point in the history
  • Loading branch information
m2epro committed Nov 3, 2021
1 parent 5286440 commit ea47e88
Show file tree
Hide file tree
Showing 56 changed files with 1,653 additions and 873 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@ public function __construct()
parent::__construct();

$this->setId('controlPanelInspectionsGrid');

$this->setDefaultSort('state');
$this->setDefaultDir('DESC');
$this->setDefaultFilter(
array(
'state' => self::NOT_SUCCESS_FILTER
)
);
$this->setSaveParametersInSession(true);
$this->setUseAjax(true);
}
Expand All @@ -43,18 +35,16 @@ protected function _prepareCollection()
foreach ($manager->getInspections() as $inspection) {
/** @var Ess_M2ePro_Model_ControlPanel_Inspection_AbstractInspection $inspection */
$row = array(
'id' => $manager->getId($inspection),
'title' => $inspection->getTitle(),
'description' => $inspection->getDescription(),
'execution_speed' => $inspection->getExecutionSpeed(),
'state' => (string)$inspection->getState(),
'need_attention' => (string)(int)($inspection->getState() > Result::STATE_SUCCESS),
'inspection' => $inspection
'id' => $manager->getId($inspection),
'title' => $inspection->getTitle(),
'description' => $inspection->getDescription(),
'inspection' => $inspection
);
$collection->addItem(new Varien_Object($row));
}

$this->setCollection($collection);

return parent::_prepareCollection();
}

Expand All @@ -63,65 +53,62 @@ protected function _prepareColumns()
$this->addColumn(
'title',
array(
'header' => Mage::helper('M2ePro')->__('Title'),
'align' => 'left',
'type' => 'text',
'width' => '20%',
'index' => 'title',
'filter_index' => 'title',
'header' => Mage::helper('M2ePro')->__('Title'),
'align' => 'left',
'type' => 'text',
'width' => '20%',
'index' => 'title',
'filter_index' => 'title',
'filter_condition_callback' => array($this, 'callbackFilterLike'),
'frame_callback' => array($this, 'callbackColumnTitle')
'frame_callback' => array($this, 'callbackColumnTitle')
)
);

$this->addColumn(
'details',
array(
'header' => Mage::helper('M2ePro')->__('Details'),
'align' => 'left',
'type' => 'text',
'width' => '40%',
'filter_index' => false,
'frame_callback' => array($this, 'callbackColumnDetails')
'header' => Mage::helper('M2ePro')->__('Details'),
'align' => 'left',
'type' => 'text',
'column_css_class' => 'details',
'width' => '40%',
'filter_index' => false,
)
);

$this->addColumn(
'state',
'actions',
array(
'header' => Mage::helper('M2ePro')->__('State'),
'align' => 'right',
'width' => '10%',
'index' => 'state',
'type' => 'options',
'options' => array(
self::NOT_SUCCESS_FILTER => Mage::helper('M2ePro')->__('Error | Warning | Notice'),
Result::STATE_ERROR => Mage::helper('M2ePro')->__('Error'),
Result::STATE_WARNING => Mage::helper('M2ePro')->__('Warning'),
Result::STATE_NOTICE => Mage::helper('M2ePro')->__('Notice'),
Result::STATE_SUCCESS => Mage::helper('M2ePro')->__('Success'),
'header' => Mage::helper('M2ePro')->__('Actions'),
'align' => 'left',
'width' => '150px',
'type' => 'action',
'index' => 'actions',
'filter' => false,
'sortable' => false,
'getter' => 'getId',
'renderer' => 'M2ePro/adminhtml_grid_column_renderer_action',
'actions' => array(
'checkAction' => array(
'caption' => Mage::helper('M2ePro')->__('Check'),
'field' => 'id',
'onclick' => 'ControlPanelInspectionObj.checkAction()',
)
),
'filter_index' => 'state',
'filter_condition_callback' => array($this, 'callbackFilterMatch'),
'frame_callback' => array($this, 'callbackColumnState')
)
);

$this->addColumn(
'execution_speed',
'id',
array(
'header' => Mage::helper('M2ePro')->__('Execution Speed'),
'align' => 'right',
'type' => 'options',
'options' => array(
Manager::EXECUTION_SPEED_FAST => Mage::helper('M2ePro')->__('Fast'),
Manager::EXECUTION_SPEED_SLOW => Mage::helper('M2ePro')->__('Slow')
),
'width' => '10%',
'index' => 'execution_speed',
'filter_index' => 'execution_speed',
'filter_condition_callback' => array($this, 'callbackFilterMatch'),
'frame_callback' => array($this, 'callbackColumnSpeed')
'header' => Mage::helper('M2ePro')->__('ID'),
'align' => 'right',
'width' => '100px',
'type' => 'text',
'index' => 'id',
'column_css_class' => 'no-display id',//this sets a css class to the column row item
'header_css_class' => 'no-display',//this sets a css class to the column header

)
);

Expand All @@ -146,7 +133,9 @@ protected function callbackFilterLike($collection, $column)
}

$this->getCollection()->addFilter(
$field, $value, Ess_M2ePro_Model_Collection_Custom::CONDITION_LIKE
$field,
$value,
Ess_M2ePro_Model_Collection_Custom::CONDITION_LIKE
);
}

Expand All @@ -164,7 +153,9 @@ protected function callbackFilterMatch($collection, $column)
}

$this->getCollection()->addFilter(
$field, $value, Ess_M2ePro_Model_Collection_Custom::CONDITION_MATCH
$field,
$value,
Ess_M2ePro_Model_Collection_Custom::CONDITION_MATCH
);
}

Expand Down Expand Up @@ -198,69 +189,23 @@ public function callbackColumnTitle($value, $row, $column, $isExport)
HTML;
}

public function callbackColumnDetails($value, $row, $column, $isExport)
{
/** @var Ess_M2ePro_Model_ControlPanel_Inspection_AbstractInspection $inspection */
$inspection = $row->getData('inspection');

$html = '';
foreach ($inspection->getResults() as $result) {
$html .= '<div>';
$html .= <<<HTML
{$this->getMarkupByResult($result->getState(), $result->getMessage())}
HTML;
if ($result->getMetadata()) {
$html .= <<<HTML
&nbsp;&nbsp;
<a href="javascript://" onclick="ControlPanelInspectionObj.showMetaData(this);">[{$this->__('details')}]</a>
<div class="no-display"><div>{$result->getMetadata()}</div></div>
HTML;
}

$html .= '</div>';
}

return $html;
}

public function callbackColumnState($value, $row, $column, $isExport)
{
return $this->getMarkupByResult($row->getData($column->getIndex()), $value);
}

public function callbackColumnSpeed($value, $row, $column, $isExport)
{
/** @var Ess_M2ePro_Model_ControlPanel_Inspection_AbstractInspection $inspection */
$inspection = $row->getData('inspection');

return <<<HTML
{$value} <span style="color: grey;">[{$inspection->getTimeToExecute()} sec.]</span>
HTML;
}

//########################################

protected function getMarkupByResult($result, $text)
public function _toHtml()
{
switch ($result) {
case Result::STATE_ERROR:
return "<span style='color: red; font-weight: bold;'>{$text}</span>";

case Result::STATE_WARNING:
return "<span style='color: darkorange; font-weight: bold;'>{$text}</span>";
$urls = Mage::helper('M2ePro')->jsonEncode(
array(
'checkInspection' => $this->getUrl('M2ePro/adminhtml_controlPanel_Inspection/checkInspection')
)
);

case Result::STATE_NOTICE:
return "<span style='color: dodgerblue; font-weight: bold;'>{$text}</span>";
$jsUrl = <<<JS
<script type="text/javascript">
case Result::STATE_SUCCESS:
return "<span style='color: green; font-weight: bold;'>{$text}</span>";
}
M2ePro.url.add({$urls});
</script>
JS;

return $text;
}

public function _toHtml()
{
$css = <<<HTML
<style>
.data tr {
Expand All @@ -272,7 +217,7 @@ public function _toHtml()
</style>
HTML;

return $css . parent::_toHtml();
return $jsUrl . $css . parent::_toHtml();
}

//########################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -719,10 +719,8 @@ public function callbackColumnMotorsAttribute($value, $row, $column, $isExport)
$countOfFilters = count($motorsData['filters']);
$countOfGroups = count($motorsData['groups']);

$showAll = false;

if ($countOfItems + $countOfFilters + $countOfGroups === 0) {
$showAll = true;
return Mage::helper('M2ePro')->__('N/A');
}

if (Mage::helper('M2ePro/Component_Ebay_Motors')->isTypeBasedOnEpids($this->getMotorsType())) {
Expand All @@ -736,55 +734,40 @@ public function callbackColumnMotorsAttribute($value, $row, $column, $isExport)
$labelFilters = Mage::helper('M2ePro')->__('Filters');
$labelGroups = Mage::helper('M2ePro')->__('Groups');

if ($showAll || $countOfItems > 0) {
if ($countOfItems > 0) {
$html .= <<<HTML
<span style="text-decoration: underline; font-weight: bold">{$motorsTypeTitle}</span>:
<span>{$countOfItems}</span><br/>
HTML;

if ($countOfItems) {
$html .= <<<HTML
[<a href="javascript:void(0);"
onclick="EbayMotorsObj.openViewItemPopup(
{$row->getData('id')},
EbayListingSettingsGridObj
);">{$label}</a>]<br/>
HTML;
}
}

if ($showAll || $countOfFilters > 0) {
if ($countOfFilters > 0) {
$html .= <<<HTML
<span style="text-decoration: underline; font-weight: bold">{$labelFilters}</span>:
<span>{$countOfFilters}</span><br/>
HTML;

if ($countOfFilters) {
$html .= <<<HTML
[<a href="javascript:void(0);"
onclick="EbayMotorsObj.openViewFilterPopup(
{$row->getData('id')},
EbayListingSettingsGridObj
);">{$label}</a>]<br/>
HTML;
}
}

if ($showAll || $countOfGroups > 0) {
if ($countOfGroups > 0) {
$html .= <<<HTML
<span style="text-decoration: underline; font-weight: bold">{$labelGroups}</span>:
<span>{$countOfGroups}</span><br/>
HTML;

if ($countOfGroups) {
$html .= <<<HTML
[<a href="javascript:void(0);"
onclick="EbayMotorsObj.openViewGroupPopup(
{$row->getData('id')},
EbayListingSettingsGridObj
);">{$label}</a>]
HTML;
}
}

$html .= '</div>';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -719,11 +719,13 @@ protected function callbackFilterStatus($collection, $column)
return;
}

switch ($value) {
case Ess_M2ePro_Model_Ebay_Order::STATUS_CANCELED:
$collection->addFieldToFilter('cancellation_status', 1);
break;
if ($value == Ess_M2ePro_Model_Ebay_Order::STATUS_CANCELED) {
$collection->addFieldToFilter('cancellation_status', 1);
return;
}

$collection->addFieldToFilter('cancellation_status', 0);
switch ($value) {
case Ess_M2ePro_Model_Ebay_Order::STATUS_SHIPPED:
$collection->addFieldToFilter(
'shipping_status',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ protected function _prepareColumns()
'width' => '150px',
'index' => 'so.increment_id',
'sortable' => false,
'frame_callback' => array($this, 'callbackColumnMagentoOrderNumber')
'frame_callback' => array($this, 'callbackColumnMagentoOrderNumber'),
'filter_condition_callback' => array($this, 'callbackFilterMagentoOrderNumber')
)
);

Expand Down Expand Up @@ -265,6 +266,23 @@ public function callbackFilterChannelOrderId($collection, $column)
$collection->addFieldToFilter('main_table.order_id', array('in' => $ordersIds));
}

public function callbackFilterMagentoOrderNumber($collection, $column)
{
$cond = $column->getFilter()->getCondition();

if (empty($cond)) {
return;
}

if ($column->getFilter()->getValue() == 'N/A') {
$collection->addFieldToFilter('mo.magento_order_id', array('null' => true));

return;
}

$collection->addFieldToFilter('mo.magento_order_id', $cond);
}

//########################################

protected function addOrderCreateDateToFilter($collection, $filter)
Expand All @@ -279,6 +297,9 @@ protected function addOrderCreateDateToFilter($collection, $filter)
$field = ($column->getFilterIndex()) ? $column->getFilterIndex() : $column->getIndex();
$cond = $column->getFilter()->getCondition();
if ($field && isset($cond)) {
$date = new Zend_Date;
$date->set(Mage::helper('M2ePro/Order_Notification')->getNotificationDate(), Zend_Date::ISO_8601);
$cond['from'] = $date;
$collection->addFieldToFilter($field, $cond);
}
}
Expand Down
Loading

0 comments on commit ea47e88

Please sign in to comment.