Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V1.1.19 #5

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/**
* Author : Ebizmarts <info@ebizmarts.com>
* Date : 5/7/13
* Time : 11:52 PM
* File : Abandonedmails.php
* Module : Ebizmarts_Magemonkey
*/
class Ebizmarts_AbandonedCart_Block_Adminhtml_Abandonedmails extends Mage_Adminhtml_Block_Widget_Grid_Container
{
public function __construct()
{
// The blockGroup must match the first half of how we call the block, and controller matches the second half
// ie. foo_bar/adminhtml_baz
$this->_blockGroup = 'ebizmarts_abandonedcart';
$this->_controller = 'adminhtml_abandonedmails';
$this->_headerText = $this->__('Mails sent from autoresponders and abandoned carts');

parent::__construct();
$this->removeButton('add');

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?php
/**
* Author : Ebizmarts <info@ebizmarts.com>
* Date : 5/7/13
* Time : 11:08 PM
* File : Grid.php
* Module : Ebizmarts_Magemonkey
*/
class Ebizmarts_AbandonedCart_Block_Adminhtml_Abandonedmails_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
public function __construct()
{
parent::__construct();
$this->setDefaultSort('id');
$this->setId('ebizmarts_abandonedcart_abandonedmails_grid');
$this->setUseAjax(true);
$this->setDefaultSort('created_at');
$this->setDefaultDir('DESC');
$this->setSaveParametersInSession(true);
}

protected function _getCollectionClass()
{
return 'ebizmarts_abandonedcart/mailssent_collection';
}

protected function _prepareCollection()
{
$collection = Mage::getResourceModel($this->_getCollectionClass());
$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function _prepareColumns()
{

$this->addColumn('store', array(
'header' => Mage::helper('ebizmarts_abandonedcart')->__('Store'),
'type' => 'store',
'index' => 'store_id'
));

$this->addColumn('sent_at', array(
'header' => Mage::helper('ebizmarts_abandonedcart')->__('Sent At'),
'index' => 'sent_at',
'filter_index' => 'sent_at',
'type' => 'datetime',
'width' => '100px',
));

$this->addColumn('customer_email', array(
'header' => Mage::helper('ebizmarts_abandonedcart')->__('Customer Email'),
'index' => 'customer_email',
));

$this->addColumn('customer_name', array(
'header' => Mage::helper('ebizmarts_abandonedcart')->__('Customer Name'),
'index' => 'customer_name',
));

$this->addColumn('mail_type', array(
'header' => Mage::helper('ebizmarts_abandonedcart')->__('Mail Type'),
'index' => 'mail_type',
'type' => 'options',
'options' => $this->getMailTypeOptions(),
));
$this->addColumn('coupon', array(
'header' => Mage::helper('ebizmarts_abandonedcart')->__('Coupon #'),
'index' => 'coupon_number',
));
$this->addColumn('coupon_type', array(
'header' => Mage::helper('ebizmarts_abandonedcart')->__('Coupon type'),
'type' => 'options',
'index' => 'coupon_type',
'options' => Mage::getModel('Ebizmarts_AbandonedCart_Model_System_Config_Discounttype')->options(),
));
$this->addColumn('coupon_amount', array(
'header' => Mage::helper('ebizmarts_abandonedcart')->__('Coupon amount'),
'index' => 'coupon_amount',
));

$this->addExportType('*/*/exportCsv', Mage::helper('sales')->__('CSV'));
$this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel XML'));

return parent::_prepareColumns();
}

public function getGridUrl()
{
return $this->getUrl('*/*/grid', array('_current'=>true));
}

protected function getMailTypeOptions()
{
return array('abandoned cart'=>'abandoned cart','happy birthday'=>'happy birthday','new order'=>'new order', 'related products'=>'related products', 'product review'=>'product review', 'no activity'=>'no activity', 'wishlist'=>'wishlist');
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ protected function _prepareCollection()
{
$collection = Mage::getResourceModel($this->_getCollectionClass());
$this->setCollection($collection);
$collection->getSelect()->join('sales_flat_quote' , 'main_table.increment_id = sales_flat_quote.reserved_order_id', 'ebizmarts_abandonedcart_flag');
$collection->addFieldToFilter('sales_flat_quote.ebizmarts_abandonedcart_flag',array('eq' => 1));
$sales_flat_order_table = Mage::getSingleton('core/resource')->getTableName('sales_flat_order');
$collection->getSelect()->join($sales_flat_order_table , 'main_table.increment_id = '.$sales_flat_order_table.'.increment_id', 'ebizmarts_abandonedcart_flag');
$collection->addFieldToFilter($sales_flat_order_table.'.ebizmarts_abandonedcart_flag',array('eq' => 1));
return parent::_prepareCollection();
}

Expand All @@ -59,6 +60,7 @@ protected function _prepareColumns()
$this->addColumn('store_id', array(
'header' => Mage::helper('sales')->__('Purchased From (Store)'),
'index' => 'store_id',
'filter_index' => 'main_table.store_id',
'type' => 'store',
'store_view'=> true,
'display_deleted' => true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ protected function _prepareLayout()

$collection = Mage::getResourceModel('ebizmarts_abandonedcart/order_collection')
->calculateSales($isFilter);
$collection->getSelect()->join('sales_flat_quote' , 'main_table.increment_id = sales_flat_quote.reserved_order_id', 'ebizmarts_abandonedcart_flag');
$collection->addFieldToFilter('sales_flat_quote.ebizmarts_abandonedcart_flag',array('eq' => 1));

// $collection->getSelect()->join('sales_flat_quote' , 'main_table.increment_id = sales_flat_quote.reserved_order_id', 'ebizmarts_abandonedcart_flag');
$collection->addFieldToFilter('main_table.ebizmarts_abandonedcart_flag',array('eq' => 1));


if ($this->getRequest()->getParam('store')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ protected function _prepareLayout()
$collection = Mage::getResourceModel('ebizmarts_abandonedcart/order_collection')
->addCreateAtPeriodFilter($period)
->calculateTotals($isFilter);
$collection->getSelect()->join('sales_flat_quote' , 'main_table.increment_id = sales_flat_quote.reserved_order_id', 'ebizmarts_abandonedcart_flag');
$collection->addFieldToFilter('sales_flat_quote.ebizmarts_abandonedcart_flag',array('eq' => 1));
// $collection->getSelect()->join('sales_flat_quote' , 'main_table.increment_id = sales_flat_quote.reserved_order_id', 'ebizmarts_abandonedcart_flag');
$collection->addFieldToFilter('main_table.ebizmarts_abandonedcart_flag',array('eq' => 1));



Expand Down Expand Up @@ -111,14 +111,44 @@ protected function _prepareLayout()
}
// add totals for emails
if($particular) {
$aux = $particular['sent'] - $particular['hard_bounces']; // - $particular['soft_bounces'];
$received = sprintf('%d (%2.2f%%)',$aux,$aux/$particular['sent']*100);
$this->addTotal($this->__('Emails Sent'),$particular['sent'],true);
$this->addTotal($this->__('Emails Received'),$received,true);
$opens = sprintf('%d (%2.2f%%)',$particular['unique_opens'],$particular['unique_opens']/$particular['sent']*100);

$_sent = $particular['sent'];
$_hard_bounces = $particular['hard_bounces'];
$_unique_opens = $particular['unique_opens'];
$_unique_clicks = $particular['unique_clicks'];


//Emails Sent and Received
$aux = $_sent - $_hard_bounces; // - $particular['soft_bounces'];
if($aux > 0) {
$aux2 = $aux/ $_sent*100;
}else{
$aux2 = 0;
}
$received = sprintf('%d (%2.2f%%)', $aux, $aux2);

$this->addTotal($this->__('Emails Sent'), $_sent,true);
$this->addTotal($this->__('Emails Received'), $received,true);

//Emails Opened
if($_unique_opens > 0) {
$emailsOpened = $_unique_opens / $_sent*100;
}else{
$emailsOpened = 0;
}

$opens = sprintf('%d (%2.2f%%)', $_unique_opens, $emailsOpened);
$this->addTotal($this->__('Emails Opened'),$opens,true);
$clicks = sprintf('%d (%2.2f%%)',$particular['unique_clicks'],$particular['unique_clicks']/$particular['unique_opens']*100);
$this->addTotal($this->__('Emails Clicked'),$clicks,true);

//Emails Clicked
if($_unique_clicks > 0){
$emailsClicked = $_unique_clicks / $_unique_opens*100;
}else{
$emailsClicked = 0;
}

$clicks = sprintf('%d (%2.2f%%)', $_unique_clicks, $emailsClicked);
$this->addTotal($this->__('Emails Clicked'), $clicks,true);
}
}
}
Expand All @@ -132,8 +162,8 @@ private function __getMandrillStatistics($period,$store)
{
$mandrill = Mage::helper('mandrill')->api();
$mandrill->setApiKey(Mage::helper('mandrill')->getApiKey($store));

$tags = $mandrill->tagsInfo('AbandonedCart');
$mandrillTag = Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::MANDRILL_TAG, $store)."_$store";
$tags = $mandrill->tagsInfo($mandrillTag);
if(!$tags) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/**
* Created by Ebizmarts
* User: gonzalo@ebizmarts.com
* Date: 3/11/13
* Time: 3:03 PM
*/
class Ebizmarts_AbandonedCart_Block_Adminhtml_System_Config_Date extends Mage_Adminhtml_Block_System_Config_Form_Field
{
public function render(Varien_Data_Form_Element_Abstract $element)
{
$element->setFormat(Varien_Date::DATE_INTERNAL_FORMAT);
$element->setImage($this->getSkinUrl('images/grid-cal.gif'));
return parent::render($element);
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

class Ebizmarts_AbandonedCart_Block_Email_Order_Items extends Mage_Sales_Block_Items_Abstract
{
public function _construct()
{
$this->setTemplate('ebizmarts_abandonedcart/email_order_items.phtml');
}

public function getTax($_item)
{
if (Mage::helper('tax')->displayCartPriceInclTax()){
$subtotal = Mage::helper('tax')->__('Incl. Tax') . ' : ' .Mage::helper('checkout')->formatPrice($_item['row_total_incl_tax']);
} elseif(Mage::helper('tax')->displayCartBothPrices()) {
$subtotal = Mage::helper('tax')->__('Excl. Tax') . ' : ' . Mage::helper('checkout')->formatPrice($_item['row_total']) . '<br>'. Mage::helper('tax')->__('Incl. Tax') . ' : ' . Mage::helper('checkout')->formatPrice($_item['row_total_incl_tax']);
} else {
$subtotal = Mage::helper('tax')->__('Excl. Tax') . ' : ' . Mage::helper('checkout')->formatPrice($_item['row_total']);
}
return $subtotal;
}

}
Loading