Version Notes
Insure Happiness by U-PIC Insurance Services allows you to offer discounted parcel insurance to your customers at checkout through this app. Eliminate all of your customer's perceived risk since U-PIC guarantees: Delivery No pilferage No breakage Or your customer's money back.
Download this release
Release Info
Developer | Ecomitize |
Extension | QS_Fee |
Version | 0.1.7 |
Comparing to | |
See all releases |
Version 0.1.7
- app/code/community/QS/Fee/Block/Adminhtml/Report/Simple.php +13 -0
- app/code/community/QS/Fee/Block/Adminhtml/Report/Simple/Grid.php +109 -0
- app/code/community/QS/Fee/Block/Adminhtml/System/Config/Form/Activate.php +60 -0
- app/code/community/QS/Fee/Block/Adminhtml/Totals.php +44 -0
- app/code/community/QS/Fee/Block/Insurance.php +47 -0
- app/code/community/QS/Fee/Block/Sales/Order/Total.php +65 -0
- app/code/community/QS/Fee/Helper/Data.php +94 -0
- app/code/community/QS/Fee/Model/Fee.php +66 -0
- app/code/community/QS/Fee/Model/Observer.php +130 -0
- app/code/community/QS/Fee/Model/Resource/Report/Simple/Collection.php +40 -0
- app/code/community/QS/Fee/Model/Resource/Tiers.php +11 -0
- app/code/community/QS/Fee/Model/Resource/Tiers/Collection.php +12 -0
- app/code/community/QS/Fee/Model/Sales/Order/Total/Creditmemo/Fee.php +17 -0
- app/code/community/QS/Fee/Model/Sales/Order/Total/Invoice/Fee.php +24 -0
- app/code/community/QS/Fee/Model/Sales/Quote/Address/Total/Fee.php +53 -0
- app/code/community/QS/Fee/Model/Simple.php +10 -0
- app/code/community/QS/Fee/Model/Tiers.php +11 -0
- app/code/community/QS/Fee/Model/Validation/Code.php +13 -0
- app/code/community/QS/Fee/controllers/Adminhtml/FeeController.php +30 -0
- app/code/community/QS/Fee/controllers/Adminhtml/IndexController.php +46 -0
- app/code/community/QS/Fee/controllers/Adminhtml/Report/FeeController.php +35 -0
- app/code/community/QS/Fee/controllers/IndexController.php +69 -0
- app/code/community/QS/Fee/etc/adminhtml.xml +35 -0
- app/code/community/QS/Fee/etc/config.xml +217 -0
- app/code/community/QS/Fee/etc/system.xml +95 -0
- app/code/community/QS/Fee/sql/fee_setup/mysql4-install-0.1.0.php +14 -0
- app/code/community/QS/Fee/sql/fee_setup/mysql4-upgrade-0.1.0-0.1.1.php +14 -0
- app/code/community/QS/Fee/sql/fee_setup/mysql4-upgrade-0.1.1-0.1.2.php +14 -0
- app/code/community/QS/Fee/sql/fee_setup/mysql4-upgrade-0.1.2-0.1.3.php +14 -0
- app/code/community/QS/Fee/sql/fee_setup/mysql4-upgrade-0.1.3-0.1.4.php +17 -0
- app/code/community/QS/Fee/sql/fee_setup/mysql4-upgrade-0.1.4-0.1.5.php +50 -0
- app/code/community/QS/Fee/sql/fee_setup/mysql4-upgrade-0.1.5-0.1.6.php +12 -0
- app/code/community/QS/Fee/sql/fee_setup/mysql4-upgrade-0.1.6-0.1.7.php +53 -0
- app/design/adminhtml/default/default/layout/fee.xml +68 -0
- app/design/adminhtml/default/default/template/fee/sales/order/refunded.phtml +16 -0
- app/design/adminhtml/default/default/template/fee/sales/order/total.phtml +9 -0
- app/design/adminhtml/default/default/template/fee/system/config/activate_link.phtml +96 -0
- app/design/adminhtml/default/default/template/fee/totals.phtml +7 -0
- app/design/frontend/default/default/layout/fee.xml +59 -0
- app/design/frontend/default/default/template/checkout/onepage/shipping_method.phtml +173 -0
- app/design/frontend/default/default/template/checkout/onepage/shipping_method/available.phtml +107 -0
- app/design/frontend/default/default/template/fee/fee.phtml +33 -0
- app/etc/modules/QS_Fee.xml +9 -0
- package.xml +18 -0
app/code/community/QS/Fee/Block/Adminhtml/Report/Simple.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class QS_Fee_Block_Adminhtml_Report_Simple extends Mage_Adminhtml_Block_Widget_Grid_Container
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
$this->_blockGroup = 'fee';
|
8 |
+
$this->_controller = 'adminhtml_report_simple';
|
9 |
+
$this->_headerText = Mage::helper('fee')->__('Order with U-PIC Insurance');
|
10 |
+
parent::__construct();
|
11 |
+
$this->_removeButton('add');
|
12 |
+
}
|
13 |
+
}
|
app/code/community/QS/Fee/Block/Adminhtml/Report/Simple/Grid.php
ADDED
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class QS_Fee_Block_Adminhtml_Report_Simple_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
4 |
+
{
|
5 |
+
|
6 |
+
protected $_countTotals = true;
|
7 |
+
|
8 |
+
public function __construct()
|
9 |
+
{
|
10 |
+
parent::__construct();
|
11 |
+
$this->setId('inshurance_orders_grid');
|
12 |
+
//$this->setDefaultSort('increment_id');
|
13 |
+
// $this->setDefaultDir('DESC');
|
14 |
+
// $this->setSaveParametersInSession(true);
|
15 |
+
$this->setUseAjax(true);
|
16 |
+
}
|
17 |
+
|
18 |
+
public function getTotals()
|
19 |
+
{
|
20 |
+
$totals = new Varien_Object();
|
21 |
+
$fields = array(
|
22 |
+
'fee_amount' => 0, //actual column index, see _prepareColumns()
|
23 |
+
'grand_total' => 0,
|
24 |
+
);
|
25 |
+
foreach ($this->getCollection() as $item) {
|
26 |
+
foreach($fields as $field=>$value){
|
27 |
+
$fields[$field]+=$item->getData($field);
|
28 |
+
}
|
29 |
+
}
|
30 |
+
//First column in the grid
|
31 |
+
$fields['increment_id']='Totals';
|
32 |
+
$totals->setData($fields);
|
33 |
+
return $totals;
|
34 |
+
}
|
35 |
+
|
36 |
+
protected function _prepareCollection()
|
37 |
+
{
|
38 |
+
$collection = Mage::registry('orders');
|
39 |
+
$this->setCollection($collection);
|
40 |
+
return parent::_prepareCollection();
|
41 |
+
}
|
42 |
+
|
43 |
+
protected function _prepareColumns()
|
44 |
+
{
|
45 |
+
$collection = Mage::getResourceModel('sales/order_collection')
|
46 |
+
->addAttributeToFilter('status', array('eq' => Mage_Sales_Model_Order::STATE_COMPLETE))
|
47 |
+
->addAttributeToFilter('fee_amount', array('neq' => 0))
|
48 |
+
->addExpressionFieldToSelect(
|
49 |
+
'fullname',
|
50 |
+
'CONCAT({{customer_firstname}}, \' \', {{customer_lastname}})',
|
51 |
+
array('customer_firstname' => 'main_table.customer_firstname', 'customer_lastname' => 'main_table.customer_lastname'))
|
52 |
+
->addExpressionFieldToSelect(
|
53 |
+
'products',
|
54 |
+
'(SELECT GROUP_CONCAT(\' \', x.name)
|
55 |
+
FROM sales_flat_order_item x
|
56 |
+
WHERE {{entity_id}} = x.order_id
|
57 |
+
AND x.product_type != \'configurable\')',
|
58 |
+
array('entity_id' => 'main_table.entity_id')
|
59 |
+
);
|
60 |
+
Mage::register('orders',$collection);
|
61 |
+
|
62 |
+
$helper = Mage::helper('fee');
|
63 |
+
$currency = (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE);
|
64 |
+
|
65 |
+
$this->addColumn('increment_id', array(
|
66 |
+
'header' => $helper->__('Order #'),
|
67 |
+
'index' => 'increment_id',
|
68 |
+
'filter_index' => 'increment_id',
|
69 |
+
));
|
70 |
+
$this->addColumn('purchased_on', array(
|
71 |
+
'header' => $helper->__('Purchased On'),
|
72 |
+
'type' => 'datetime',
|
73 |
+
'index' => 'created_at'
|
74 |
+
));
|
75 |
+
$this->addColumn('fullname', array(
|
76 |
+
'header' => $helper->__('Customer Name'),
|
77 |
+
'index' => 'fullname',
|
78 |
+
'filter_index' => 'CONCAT(customer_firstname, \' \', customer_lastname)'
|
79 |
+
));
|
80 |
+
$this->addColumn('products', array(
|
81 |
+
'header' => $helper->__('Products Purchased'),
|
82 |
+
'index' => 'products',
|
83 |
+
'filter_index' => '(SELECT GROUP_CONCAT(\' \', x.name) FROM sales_flat_order_item x WHERE main_table.entity_id = x.order_id AND x.product_type != \'configurable\')'
|
84 |
+
));
|
85 |
+
$this->addColumn('shipping_method', array(
|
86 |
+
'header' => $helper->__('Shipping Method'),
|
87 |
+
'index' => 'shipping_description'
|
88 |
+
));
|
89 |
+
$this->addColumn('fee_amount', array(
|
90 |
+
'header' => $helper->__('U-PIC Insurance'),
|
91 |
+
'index' => 'fee_amount',
|
92 |
+
'type' => 'currency',
|
93 |
+
'currency_code' => $currency,
|
94 |
+
));
|
95 |
+
$this->addColumn('grand_total', array(
|
96 |
+
'header' => $helper->__('Grand Total'),
|
97 |
+
'index' => 'grand_total',
|
98 |
+
'type' => 'currency',
|
99 |
+
'currency_code' => $currency,
|
100 |
+
));
|
101 |
+
$this->addExportType('*/*/exportSimpleCsv', Mage::helper('reports')->__('CSV'));
|
102 |
+
return parent::_prepareColumns();
|
103 |
+
}
|
104 |
+
|
105 |
+
public function getGridUrl()
|
106 |
+
{
|
107 |
+
return $this->getUrl('*/*/grid', array('_current'=>true));
|
108 |
+
}
|
109 |
+
}
|
app/code/community/QS/Fee/Block/Adminhtml/System/Config/Form/Activate.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class QS_Fee_Block_Adminhtml_System_Config_Form_Activate extends Mage_Adminhtml_Block_System_Config_Form_Field
|
3 |
+
{
|
4 |
+
/*
|
5 |
+
* Set template
|
6 |
+
*/
|
7 |
+
protected function _construct()
|
8 |
+
{
|
9 |
+
parent::_construct();
|
10 |
+
$this->setTemplate('fee/system/config/activate_link.phtml');
|
11 |
+
}
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Return element html
|
15 |
+
*
|
16 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
17 |
+
* @return string
|
18 |
+
*/
|
19 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
20 |
+
{
|
21 |
+
return $this->_toHtml();
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Return ajax url for button
|
26 |
+
*
|
27 |
+
* @return string
|
28 |
+
*/
|
29 |
+
public function getAjaxCheckUrl()
|
30 |
+
{
|
31 |
+
return Mage::helper('adminhtml')->getUrl('adminhtml/index/sendEmail');
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Generate button html
|
36 |
+
*
|
37 |
+
* @return string
|
38 |
+
*/
|
39 |
+
public function getButtonHtml()
|
40 |
+
{
|
41 |
+
$button = $this->getLayout()->createBlock('adminhtml/widget_button')
|
42 |
+
->setData(array(
|
43 |
+
'id' => 'activate_button',
|
44 |
+
'label' => $this->helper('adminhtml')->__('Send'),
|
45 |
+
'onclick' => 'activatePopup.showPopupBox();'
|
46 |
+
));
|
47 |
+
|
48 |
+
return $button->toHtml();
|
49 |
+
}
|
50 |
+
|
51 |
+
public function getUpicEmailAdress(){
|
52 |
+
$upic_email_adress = Mage::getStoreConfig('upic/general/upic_email_adress');
|
53 |
+
return $upic_email_adress;
|
54 |
+
}
|
55 |
+
|
56 |
+
public function getAdminEmailAdress(){
|
57 |
+
$admin_email_adress = Mage::getStoreConfig('trans_email/ident_general/email');
|
58 |
+
return $admin_email_adress;
|
59 |
+
}
|
60 |
+
}
|
app/code/community/QS/Fee/Block/Adminhtml/Totals.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class QS_Fee_Block_Adminhtml_Totals extends Mage_Adminhtml_Block_Template{
|
4 |
+
|
5 |
+
function getCollection(){
|
6 |
+
|
7 |
+
$fromDate = date('Y-m-d 00:00:00',strtotime('-1 days'));
|
8 |
+
$toDate = date('Y-m-d 23:59:00',strtotime(now()));
|
9 |
+
|
10 |
+
$collection = Mage::getResourceModel('sales/order_collection')
|
11 |
+
->addAttributeToFilter('status', array('eq' => Mage_Sales_Model_Order::STATE_COMPLETE))
|
12 |
+
->addAttributeToFilter('fee_amount', array('neq' => 0))
|
13 |
+
->addAttributeToFilter('created_at', array('from'=>$fromDate, 'to'=>$toDate))
|
14 |
+
->addExpressionFieldToSelect(
|
15 |
+
'fullname',
|
16 |
+
'CONCAT({{customer_firstname}}, \' \', {{customer_lastname}})',
|
17 |
+
array('customer_firstname' => 'main_table.customer_firstname', 'customer_lastname' => 'main_table.customer_lastname'))
|
18 |
+
->addExpressionFieldToSelect(
|
19 |
+
'products',
|
20 |
+
'(SELECT GROUP_CONCAT(\' \', x.name)
|
21 |
+
FROM sales_flat_order_item x
|
22 |
+
WHERE {{entity_id}} = x.order_id
|
23 |
+
AND x.product_type != \'configurable\')',
|
24 |
+
array('entity_id' => 'main_table.entity_id')
|
25 |
+
);
|
26 |
+
return $collection;
|
27 |
+
}
|
28 |
+
|
29 |
+
function getOrdersCount(){
|
30 |
+
$collection = $this->getCollection();
|
31 |
+
return $collection->count();
|
32 |
+
}
|
33 |
+
|
34 |
+
function getTotalInsurance(){
|
35 |
+
$collection = $this->getCollection();
|
36 |
+
$totalAmount = 0;
|
37 |
+
foreach ($collection as $order){
|
38 |
+
$totalAmount += $order->getFeeAmount();
|
39 |
+
}
|
40 |
+
return $totalAmount;
|
41 |
+
}
|
42 |
+
|
43 |
+
}
|
44 |
+
|
app/code/community/QS/Fee/Block/Insurance.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class QS_Fee_Block_Insurance extends Mage_Core_Block_Template{
|
3 |
+
|
4 |
+
public function __construct(){
|
5 |
+
$this->registerInsuranceConfigurationStatus();
|
6 |
+
$this->registerInsuranceDefaultStatus();
|
7 |
+
$this->registerStatusAllowedCountry();
|
8 |
+
parent::__construct();
|
9 |
+
}
|
10 |
+
|
11 |
+
function registerInsuranceConfigurationStatus(){
|
12 |
+
|
13 |
+
$activation_code = Mage::getStoreConfig('upic/general/activation_code');
|
14 |
+
$policy_number = Mage::getStoreConfig('upic/general/policy_number');
|
15 |
+
|
16 |
+
if (($activation_code !='')&&($policy_number !='')){
|
17 |
+
Mage::register('insurance_configuration',1);
|
18 |
+
} else {
|
19 |
+
Mage::register('insurance_configuration',0);
|
20 |
+
}
|
21 |
+
}
|
22 |
+
|
23 |
+
function registerInsuranceDefaultStatus(){
|
24 |
+
$insurance_as_default = Mage::getStoreConfig('upic/general/insurance_as_default');
|
25 |
+
Mage::register('insurance_as_default',$insurance_as_default);
|
26 |
+
}
|
27 |
+
|
28 |
+
function registerStatusAllowedCountry(){
|
29 |
+
|
30 |
+
$quote = Mage::getModel('checkout/session')->getQuote();
|
31 |
+
$adress = $quote->getShippingAddress();
|
32 |
+
$country_id = $adress->getCountryId();
|
33 |
+
|
34 |
+
$excluded_counntries = array('AF','DZ','AO','BY','BA','MM','BI','CG','HR','CU','BA','IR','IQ','JO','LR','LY','MD','NG','KP','PY','RU','RS','SL','SO','LK','SD','SY','TG','YE','ZW');
|
35 |
+
|
36 |
+
$insurance_as_default = Mage::getStoreConfig('upic/general/insurance_as_default');
|
37 |
+
|
38 |
+
if(in_array($country_id,$excluded_counntries)){
|
39 |
+
Mage::register('country_status',0);
|
40 |
+
} else {
|
41 |
+
Mage::register('country_status',1);
|
42 |
+
}
|
43 |
+
|
44 |
+
|
45 |
+
}
|
46 |
+
|
47 |
+
}
|
app/code/community/QS/Fee/Block/Sales/Order/Total.php
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class QS_Fee_Block_Sales_Order_Total extends Mage_Core_Block_Template
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Get label cell tag properties
|
6 |
+
*
|
7 |
+
* @return string
|
8 |
+
*/
|
9 |
+
public function getLabelProperties()
|
10 |
+
{
|
11 |
+
return $this->getParentBlock()->getLabelProperties();
|
12 |
+
}
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Get order store object
|
16 |
+
*
|
17 |
+
* @return Mage_Sales_Model_Order
|
18 |
+
*/
|
19 |
+
public function getOrder()
|
20 |
+
{
|
21 |
+
return $this->getParentBlock()->getOrder();
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Get totals source object
|
26 |
+
*
|
27 |
+
* @return Mage_Sales_Model_Order
|
28 |
+
*/
|
29 |
+
public function getSource()
|
30 |
+
{
|
31 |
+
return $this->getParentBlock()->getSource();
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Get value cell tag properties
|
36 |
+
*
|
37 |
+
* @return string
|
38 |
+
*/
|
39 |
+
public function getValueProperties()
|
40 |
+
{
|
41 |
+
return $this->getParentBlock()->getValueProperties();
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Initialize reward points totals
|
46 |
+
*
|
47 |
+
* @return Enterprise_Reward_Block_Sales_Order_Total
|
48 |
+
*/
|
49 |
+
public function initTotals()
|
50 |
+
{
|
51 |
+
if ((float) $this->getOrder()->getBaseFeeAmount()) {
|
52 |
+
$source = $this->getSource();
|
53 |
+
$value = $source->getFeeAmount();
|
54 |
+
|
55 |
+
$this->getParentBlock()->addTotal(new Varien_Object(array(
|
56 |
+
'code' => 'U-PIC',
|
57 |
+
'strong' => false,
|
58 |
+
'label' => Mage::helper('fee')->formatFee($value),
|
59 |
+
'value' => $source instanceof Mage_Sales_Model_Order_Creditmemo ? - $value : $value
|
60 |
+
)));
|
61 |
+
}
|
62 |
+
|
63 |
+
return $this;
|
64 |
+
}
|
65 |
+
}
|
app/code/community/QS/Fee/Helper/Data.php
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class QS_Fee_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
const SEVERITY_CRITICAL = 1;
|
6 |
+
const SEVERITY_MAJOR = 2;
|
7 |
+
const SEVERITY_MINOR = 3;
|
8 |
+
const SEVERITY_NOTICE = 4;
|
9 |
+
|
10 |
+
public function formatFee(){
|
11 |
+
return Mage::helper('fee')->__('U-PIC Parcel Insurance');
|
12 |
+
}
|
13 |
+
|
14 |
+
public function formatAmount($amount){
|
15 |
+
return '$'.$amount;
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Add new message
|
20 |
+
*
|
21 |
+
* @param int $severity
|
22 |
+
* @param string $title
|
23 |
+
* @param string|array $description
|
24 |
+
* @param string $url
|
25 |
+
* @param bool $isInternal
|
26 |
+
* @return Mage_AdminNotification_Model_Inbox
|
27 |
+
*/
|
28 |
+
public function add($severity, $title, $description, $url = '', $isInternal = true)
|
29 |
+
{
|
30 |
+
if (!$this->getSeverities($severity)) {
|
31 |
+
Mage::throwException($this->__('Wrong message type'));
|
32 |
+
}
|
33 |
+
if (is_array($description)) {
|
34 |
+
$description = '<ul><li>' . implode('</li><li>', $description) . '</li></ul>';
|
35 |
+
}
|
36 |
+
$date = date('Y-m-d H:i:s');
|
37 |
+
Mage::getModel('adminnotification/inbox')->parse(array(array(
|
38 |
+
'severity' => $severity,
|
39 |
+
'date_added' => $date,
|
40 |
+
'title' => $title,
|
41 |
+
'description' => $description,
|
42 |
+
'url' => $url,
|
43 |
+
'internal' => $isInternal
|
44 |
+
)));
|
45 |
+
return $this;
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Add notice
|
50 |
+
*
|
51 |
+
* @param string $title
|
52 |
+
* @param string|array $description
|
53 |
+
* @param string $url
|
54 |
+
* @param bool $isInternal
|
55 |
+
* @return Mage_AdminNotification_Model_Inbox
|
56 |
+
*/
|
57 |
+
public function addNotice($title, $description, $url = '', $isInternal = true)
|
58 |
+
{
|
59 |
+
$this->add(self::SEVERITY_NOTICE, $title, $description, $url, $isInternal);
|
60 |
+
return $this;
|
61 |
+
}
|
62 |
+
|
63 |
+
public function _getNotifier()
|
64 |
+
{
|
65 |
+
return $this;
|
66 |
+
}
|
67 |
+
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Retrieve Severity collection array
|
71 |
+
*
|
72 |
+
* @return array|string
|
73 |
+
*/
|
74 |
+
public function getSeverities($severity = null)
|
75 |
+
{
|
76 |
+
$severities = array(
|
77 |
+
self::SEVERITY_CRITICAL => Mage::helper('adminnotification')->__('critical'),
|
78 |
+
self::SEVERITY_MAJOR => Mage::helper('adminnotification')->__('major'),
|
79 |
+
self::SEVERITY_MINOR => Mage::helper('adminnotification')->__('minor'),
|
80 |
+
self::SEVERITY_NOTICE => Mage::helper('adminnotification')->__('notice'),
|
81 |
+
);
|
82 |
+
|
83 |
+
if (!is_null($severity)) {
|
84 |
+
if (isset($severities[$severity])) {
|
85 |
+
return $severities[$severity];
|
86 |
+
}
|
87 |
+
return null;
|
88 |
+
}
|
89 |
+
|
90 |
+
return $severities;
|
91 |
+
}
|
92 |
+
|
93 |
+
|
94 |
+
}
|
app/code/community/QS/Fee/Model/Fee.php
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class QS_Fee_Model_Fee extends Varien_Object{
|
3 |
+
|
4 |
+
public static function getFee(){
|
5 |
+
|
6 |
+
$activation_code = Mage::getStoreConfig('upic/general/activation_code');
|
7 |
+
|
8 |
+
$tier = Mage::getModel('fee/tiers')->getCollection()->addFieldToFilter('code',$activation_code)->getData();
|
9 |
+
|
10 |
+
$quote = Mage::getModel('checkout/session')->getQuote();
|
11 |
+
|
12 |
+
if($tier){
|
13 |
+
|
14 |
+
$country_id = $quote->getShippingAddress()->getCountryId();
|
15 |
+
|
16 |
+
if (($country_id == 'US')||($country_id == 'CA')){
|
17 |
+
$rate = $tier[0]['domestic_value'];
|
18 |
+
} else {
|
19 |
+
$rate = $tier[0]['international_value'];
|
20 |
+
}
|
21 |
+
|
22 |
+
$totalProductPrice = 0;
|
23 |
+
|
24 |
+
$shippingAmount = $quote->getShippingAddress()->getShippingAmount();
|
25 |
+
$discountAmount = $quote->getShippingAddress()->getDiscountAmount();
|
26 |
+
$discountShippingAmount = $quote->getShippingAddress()->getShippingDiscountAmount();
|
27 |
+
|
28 |
+
foreach ($quote->getAllItems() as $item) {
|
29 |
+
$productPrice = $item->getPriceInclTax();
|
30 |
+
$totalProductPrice = $totalProductPrice + $productPrice * $item->getQty();
|
31 |
+
}
|
32 |
+
|
33 |
+
$totalPrice = $totalProductPrice + $discountAmount + $shippingAmount + $discountShippingAmount;
|
34 |
+
if ($totalPrice < 100){
|
35 |
+
$unitCount = 1;
|
36 |
+
} else {
|
37 |
+
$unitCount = ceil ($totalPrice / 100);
|
38 |
+
}
|
39 |
+
|
40 |
+
$insuranceAmount = $rate * $unitCount;
|
41 |
+
|
42 |
+
return $insuranceAmount;
|
43 |
+
} else {
|
44 |
+
return 0;
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
public static function canApply($address){
|
49 |
+
//put here your business logic to check if fee should be applied or not
|
50 |
+
|
51 |
+
$country_id = $address->getCountryId();
|
52 |
+
|
53 |
+
$excluded_counntries = array('AF','DZ','AO','BY','BA','MM','BI','CG','HR','CU','BA','IR','IQ','JO','LR','LY','MD','NG','KP','PY','RU','RS','SL','SO','LK','SD','SY','TG','YE','ZW');
|
54 |
+
|
55 |
+
$insurance_as_default = Mage::getStoreConfig('upic/general/insurance_as_default');
|
56 |
+
|
57 |
+
if(in_array($country_id,$excluded_counntries)){
|
58 |
+
if($insurance_as_default){
|
59 |
+
return false;
|
60 |
+
}
|
61 |
+
} else {
|
62 |
+
return true;
|
63 |
+
}
|
64 |
+
|
65 |
+
}
|
66 |
+
}
|
app/code/community/QS/Fee/Model/Observer.php
ADDED
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class QS_Fee_Model_Observer{
|
3 |
+
|
4 |
+
public function getOrdersData()
|
5 |
+
{
|
6 |
+
|
7 |
+
$fromDate = date('Y-m-d 00:00:00',strtotime('-1 days'));
|
8 |
+
$toDate = date('Y-m-d 23:59:00',strtotime(now()));
|
9 |
+
|
10 |
+
$orders = Mage::getModel('sales/order')->getCollection()
|
11 |
+
->addAttributeToFilter('created_at', array('from'=>$fromDate, 'to'=>$toDate))
|
12 |
+
->addAttributeToFilter('status', array('eq' => Mage_Sales_Model_Order::STATE_COMPLETE))
|
13 |
+
->addAttributeToFilter('fee_amount', array('neq' => 0));
|
14 |
+
|
15 |
+
$result = array();
|
16 |
+
|
17 |
+
$array_title = array('Policy','Code','ShipDate','InvoiceNumber','DeclaredValue','ConsigneeName','ConsigneeAddress','ConsigneeZip');
|
18 |
+
|
19 |
+
array_push($result,$array_title);
|
20 |
+
|
21 |
+
foreach($orders as $order) {
|
22 |
+
$orderArray = array();
|
23 |
+
|
24 |
+
$policy_number = Mage::getStoreConfig('upic/general/policy_number');
|
25 |
+
$orderArray['Policy number'] = $policy_number;
|
26 |
+
|
27 |
+
$activation_code = Mage::getStoreConfig('upic/general/activation_code');
|
28 |
+
$orderArray['Activation code'] = $activation_code;
|
29 |
+
|
30 |
+
$shipmentCollection = $order->getShipmentsCollection();
|
31 |
+
|
32 |
+
foreach($shipmentCollection as $shipment){
|
33 |
+
$orderArray['ShipDate'] = $shipment->getCreatedAt();
|
34 |
+
}
|
35 |
+
|
36 |
+
$invoiceCollection = $order->getInvoiceCollection();
|
37 |
+
|
38 |
+
foreach ($invoiceCollection as $inv) {
|
39 |
+
$orderArray['InvoiceNumber'] = $inv->getData('increment_id');
|
40 |
+
$orderArray['DeclaredValue'] = $inv->getData('grand_total');
|
41 |
+
}
|
42 |
+
|
43 |
+
$shippingId = $order->getShippingAddress()->getId();
|
44 |
+
|
45 |
+
$address = Mage::getModel('sales/order_address')->load($shippingId);
|
46 |
+
$orderArray['ConsigneeName']= $address->getData('firstname').' '.$address->getData('lastname');
|
47 |
+
$orderArray['ConsigneeAddress']=$address->getData('region').' '.$address->getData('city').' '.$address->getData('street').' '.$address->getData('country_id');
|
48 |
+
$orderArray['ConsigneeZip']= $address->getData('postcode');
|
49 |
+
array_push($result,$orderArray);
|
50 |
+
}
|
51 |
+
return $result;
|
52 |
+
}
|
53 |
+
|
54 |
+
public function createReportFile($orderData){
|
55 |
+
$result = array();
|
56 |
+
$rand = rand();
|
57 |
+
$file_name = $rand.'report.csv';
|
58 |
+
$result['fileName'] = $file_name;
|
59 |
+
$file_path = implode (DS, array (Mage::getBaseDir('media'),$file_name));
|
60 |
+
$result['filePath'] = $file_path;
|
61 |
+
$mage_csv = new Varien_File_Csv();
|
62 |
+
if ($mage_csv->saveData($file_path, $orderData)){
|
63 |
+
Mage::helper('fee')->_getNotifier()->addNotice('U-PIC Insurance','Daily ordered insurance" File was generated successfully');
|
64 |
+
return $result;
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
|
69 |
+
public function load(){
|
70 |
+
|
71 |
+
$ftp_server = Mage::getStoreConfig('upic/general/ftp_server');
|
72 |
+
$ftp_user_name = Mage::getStoreConfig('upic/general/ftp_user_name');
|
73 |
+
$ftp_user_pass = Mage::getStoreConfig('upic/general/ftp_user_pass');
|
74 |
+
|
75 |
+
$activation_code = Mage::getStoreConfig('upic/general/activation_code');
|
76 |
+
$policy_number = Mage::getStoreConfig('upic/general/policy_number');
|
77 |
+
|
78 |
+
if (($activation_code !='')&&($policy_number !='')){
|
79 |
+
|
80 |
+
$orderData = $this->getOrdersData();
|
81 |
+
$file_info = $this->createReportFile($orderData);
|
82 |
+
$file_name = $file_info['fileName'];
|
83 |
+
$file_path = $file_info['filePath'];
|
84 |
+
|
85 |
+
// set up basic connection
|
86 |
+
$conn_id = ftp_connect($ftp_server);
|
87 |
+
|
88 |
+
// login with username and password
|
89 |
+
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
|
90 |
+
if (!$login_result){
|
91 |
+
Mage::log("There was a problem with login on ftp server");
|
92 |
+
} else {
|
93 |
+
// upload a file
|
94 |
+
if (ftp_put($conn_id, $file_name, $file_path, FTP_ASCII)) {
|
95 |
+
Mage::helper('fee')->_getNotifier()->addNotice('U-PIC Insurance','Daily ordered insurance" File uploaded succesfully');
|
96 |
+
} else {
|
97 |
+
Mage::log("There was a problem while uploading $file_path\n");
|
98 |
+
}
|
99 |
+
// close the connection
|
100 |
+
ftp_close($conn_id);
|
101 |
+
}
|
102 |
+
}
|
103 |
+
}
|
104 |
+
|
105 |
+
public function invoiceSaveAfter(Varien_Event_Observer $observer)
|
106 |
+
{
|
107 |
+
$invoice = $observer->getEvent()->getInvoice();
|
108 |
+
if ($invoice->getBaseFeeAmount()) {
|
109 |
+
$order = $invoice->getOrder();
|
110 |
+
$order->setFeeAmountInvoiced($order->getFeeAmountInvoiced() + $invoice->getFeeAmount());
|
111 |
+
$order->setBaseFeeAmountInvoiced($order->getBaseFeeAmountInvoiced() + $invoice->getBaseFeeAmount());
|
112 |
+
}
|
113 |
+
return $this;
|
114 |
+
}
|
115 |
+
public function creditmemoSaveAfter(Varien_Event_Observer $observer)
|
116 |
+
{
|
117 |
+
/* @var $creditmemo Mage_Sales_Model_Order_Creditmemo */
|
118 |
+
$creditmemo = $observer->getEvent()->getCreditmemo();
|
119 |
+
if ($creditmemo->getFeeAmount()) {
|
120 |
+
$order = $creditmemo->getOrder();
|
121 |
+
$order->setFeeAmountRefunded($order->getFeeAmountRefunded() + $creditmemo->getFeeAmount());
|
122 |
+
$order->setBaseFeeAmountRefunded($order->getBaseFeeAmountRefunded() + $creditmemo->getBaseFeeAmount());
|
123 |
+
}
|
124 |
+
return $this;
|
125 |
+
}
|
126 |
+
public function updatePaypalTotal($evt){
|
127 |
+
$cart = $evt->getPaypalCart();
|
128 |
+
$cart->updateTotal(Mage_Paypal_Model_Cart::TOTAL_SUBTOTAL,$cart->getSalesEntity()->getFeeAmount());
|
129 |
+
}
|
130 |
+
}
|
app/code/community/QS/Fee/Model/Resource/Report/Simple/Collection.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class QS_Fee_Model_Resource_Report_Simple_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
protected function _construct()
|
7 |
+
{
|
8 |
+
$this->_init('fee/simple');
|
9 |
+
}
|
10 |
+
|
11 |
+
protected function _joinFields($from = '', $to = '')
|
12 |
+
{
|
13 |
+
$this->addFieldToFilter('period' , array("from" => $from, "to" => $to, "datetime" => true));
|
14 |
+
$this->getSelect()->group('description');
|
15 |
+
$this->getSelect()->columns(array('value' => 'SUM(value)'));
|
16 |
+
|
17 |
+
return $this;
|
18 |
+
}
|
19 |
+
|
20 |
+
public function setDateRange($from, $to)
|
21 |
+
{
|
22 |
+
$this->_reset()
|
23 |
+
->_joinFields($from, $to);
|
24 |
+
return $this;
|
25 |
+
}
|
26 |
+
|
27 |
+
public function load($printQuery = false, $logQuery = false)
|
28 |
+
{
|
29 |
+
if ($this->isLoaded()) {
|
30 |
+
return $this;
|
31 |
+
}
|
32 |
+
parent::load($printQuery, $logQuery);
|
33 |
+
return $this;
|
34 |
+
}
|
35 |
+
|
36 |
+
public function setStoreIds($storeIds)
|
37 |
+
{
|
38 |
+
return $this;
|
39 |
+
}
|
40 |
+
}
|
app/code/community/QS/Fee/Model/Resource/Tiers.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class QS_Fee_Model_Resource_Tiers extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
public function _construct()
|
7 |
+
{
|
8 |
+
$this->_init('fee/table_tiers', 'tiers_id');
|
9 |
+
}
|
10 |
+
|
11 |
+
}
|
app/code/community/QS/Fee/Model/Resource/Tiers/Collection.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class QS_Fee_Model_Resource_Tiers_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
public function _construct()
|
7 |
+
{
|
8 |
+
parent::_construct();
|
9 |
+
$this->_init('fee/tiers');
|
10 |
+
}
|
11 |
+
|
12 |
+
}
|
app/code/community/QS/Fee/Model/Sales/Order/Total/Creditmemo/Fee.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class QS_Fee_Model_Sales_Order_Total_Creditmemo_Fee extends Mage_Sales_Model_Order_Creditmemo_Total_Abstract
|
3 |
+
{
|
4 |
+
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
|
5 |
+
{
|
6 |
+
$order = $creditmemo->getOrder();
|
7 |
+
$feeAmountLeft = $order->getFeeAmountInvoiced() - $order->getFeeAmountRefunded();
|
8 |
+
$basefeeAmountLeft = $order->getBaseFeeAmountInvoiced() - $order->getBaseFeeAmountRefunded();
|
9 |
+
if ($basefeeAmountLeft > 0) {
|
10 |
+
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $feeAmountLeft);
|
11 |
+
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $basefeeAmountLeft);
|
12 |
+
$creditmemo->setFeeAmount($feeAmountLeft);
|
13 |
+
$creditmemo->setBaseFeeAmount($basefeeAmountLeft);
|
14 |
+
}
|
15 |
+
return $this;
|
16 |
+
}
|
17 |
+
}
|
app/code/community/QS/Fee/Model/Sales/Order/Total/Invoice/Fee.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class QS_Fee_Model_Sales_Order_Total_Invoice_Fee extends Mage_Sales_Model_Order_Invoice_Total_Abstract
|
3 |
+
{
|
4 |
+
public function collect(Mage_Sales_Model_Order_Invoice $invoice)
|
5 |
+
{
|
6 |
+
$order = $invoice->getOrder();
|
7 |
+
$feeAmountLeft = $order->getFeeAmount() - $order->getFeeAmountInvoiced();
|
8 |
+
$baseFeeAmountLeft = $order->getBaseFeeAmount() - $order->getBaseFeeAmountInvoiced();
|
9 |
+
if (abs($baseFeeAmountLeft) < $invoice->getBaseGrandTotal()) {
|
10 |
+
$invoice->setGrandTotal($invoice->getGrandTotal() + $feeAmountLeft);
|
11 |
+
$invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $baseFeeAmountLeft);
|
12 |
+
} else {
|
13 |
+
$feeAmountLeft = $invoice->getGrandTotal() * -1;
|
14 |
+
$baseFeeAmountLeft = $invoice->getBaseGrandTotal() * -1;
|
15 |
+
|
16 |
+
$invoice->setGrandTotal(0);
|
17 |
+
$invoice->setBaseGrandTotal(0);
|
18 |
+
}
|
19 |
+
|
20 |
+
$invoice->setFeeAmount($feeAmountLeft);
|
21 |
+
$invoice->setBaseFeeAmount($baseFeeAmountLeft);
|
22 |
+
return $this;
|
23 |
+
}
|
24 |
+
}
|
app/code/community/QS/Fee/Model/Sales/Quote/Address/Total/Fee.php
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class QS_Fee_Model_Sales_Quote_Address_Total_Fee extends Mage_Sales_Model_Quote_Address_Total_Abstract{
|
3 |
+
protected $_code = 'U-PIC';
|
4 |
+
|
5 |
+
public function collect(Mage_Sales_Model_Quote_Address $address)
|
6 |
+
{
|
7 |
+
parent::collect($address);
|
8 |
+
|
9 |
+
$this->_setAmount(0);
|
10 |
+
$this->_setBaseAmount(0);
|
11 |
+
|
12 |
+
$items = $this->_getAddressItems($address);
|
13 |
+
if (!count($items)) {
|
14 |
+
return $this;
|
15 |
+
}
|
16 |
+
|
17 |
+
$quote = $address->getQuote();
|
18 |
+
|
19 |
+
$insurance_as_default = Mage::getStoreConfig('upic/general/insurance_as_default');
|
20 |
+
if($insurance_as_default){
|
21 |
+
$address->setInsuranceStatus(1);
|
22 |
+
}
|
23 |
+
if(QS_Fee_Model_Fee::canApply($address)){
|
24 |
+
$exist_amount = $quote->getFeeAmount();
|
25 |
+
|
26 |
+
$fee = QS_Fee_Model_Fee::getFee();
|
27 |
+
$balance = $fee - $exist_amount;
|
28 |
+
|
29 |
+
if ($address->getInsuranceStatus()){
|
30 |
+
$address->setFeeAmount($balance);
|
31 |
+
$address->setBaseFeeAmount($balance);
|
32 |
+
|
33 |
+
$quote->setFeeAmount($balance);
|
34 |
+
|
35 |
+
$address->setGrandTotal($address->getGrandTotal() + $address->getFeeAmount());
|
36 |
+
$address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getBaseFeeAmount());
|
37 |
+
}
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
public function fetch(Mage_Sales_Model_Quote_Address $address)
|
42 |
+
{
|
43 |
+
$amt = $address->getFeeAmount();
|
44 |
+
if($amt != 0){
|
45 |
+
$address->addTotal(array(
|
46 |
+
'code'=>$this->getCode(),
|
47 |
+
'title'=>Mage::helper('fee')->__('U-PIC Parcel Insurance'),
|
48 |
+
'value'=> $amt
|
49 |
+
));
|
50 |
+
}
|
51 |
+
return $this;
|
52 |
+
}
|
53 |
+
}
|
app/code/community/QS/Fee/Model/Simple.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class QS_Fee_Model_Simple extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
protected function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('fee/simple');
|
9 |
+
}
|
10 |
+
}
|
app/code/community/QS/Fee/Model/Tiers.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class QS_Fee_Model_Tiers extends Mage_Core_Model_Abstract
|
3 |
+
{
|
4 |
+
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('fee/tiers');
|
9 |
+
}
|
10 |
+
|
11 |
+
}
|
app/code/community/QS/Fee/Model/Validation/Code.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class QS_Fee_Model_Validation_Code extends Mage_Core_Model_Config_Data{
|
3 |
+
public function save()
|
4 |
+
{
|
5 |
+
$activation_code = $this->getValue(); //get the value from our config
|
6 |
+
$tier = Mage::getModel('fee/tiers')->getCollection()->addFieldToFilter('code',$activation_code)->getData();
|
7 |
+
if($tier||($activation_code =='')) {
|
8 |
+
return parent::save();
|
9 |
+
} else {
|
10 |
+
Mage::throwException("Activation Code failed!");
|
11 |
+
}
|
12 |
+
}
|
13 |
+
}
|
app/code/community/QS/Fee/controllers/Adminhtml/FeeController.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class QS_Fee_Adminhtml_FeeController extends Mage_Adminhtml_Controller_Action
|
4 |
+
{
|
5 |
+
|
6 |
+
public function indexAction()
|
7 |
+
{
|
8 |
+
$this->loadLayout();
|
9 |
+
$this->_addContent($this->getLayout()->createBlock('fee/adminhtml_report_simple'));
|
10 |
+
$this->renderLayout();
|
11 |
+
}
|
12 |
+
|
13 |
+
public function gridAction()
|
14 |
+
{
|
15 |
+
$this->loadLayout();
|
16 |
+
$this->getResponse()->setBody(
|
17 |
+
$this->getLayout()->createBlock('fee/adminhtml_report_simple_grid')->toHtml()
|
18 |
+
);
|
19 |
+
}
|
20 |
+
|
21 |
+
public function exportSimpleCsvAction()
|
22 |
+
{
|
23 |
+
$fileName = 'simple.csv';
|
24 |
+
$content = $this->getLayout()->createBlock('fee/adminhtml_report_simple_grid')
|
25 |
+
->getCsv();
|
26 |
+
|
27 |
+
$this->_prepareDownloadResponse($fileName, $content);
|
28 |
+
}
|
29 |
+
|
30 |
+
}
|
app/code/community/QS/Fee/controllers/Adminhtml/IndexController.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class QS_Fee_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Return some checking result
|
6 |
+
*
|
7 |
+
* @return void
|
8 |
+
*/
|
9 |
+
public function sendEmailAction()
|
10 |
+
{
|
11 |
+
$fromEmail = $this->getRequest()->getParam("from",0);
|
12 |
+
$toEmail = $this->getRequest()->getParam("to",0);
|
13 |
+
$body = $this->getRequest()->getParam("message",0);
|
14 |
+
|
15 |
+
$fromName = "Alex Stojka"; // sender name
|
16 |
+
$toName = "U-Pic Insurnace"; // recipient name
|
17 |
+
$subject = "Activate Insurance"; // subject text
|
18 |
+
|
19 |
+
$mail = new Zend_Mail();
|
20 |
+
|
21 |
+
$mail->setBodyText($body);
|
22 |
+
|
23 |
+
$mail->setFrom($fromEmail, $fromName);
|
24 |
+
|
25 |
+
$mail->addTo($toEmail, $toName);
|
26 |
+
|
27 |
+
$mail->setSubject($subject);
|
28 |
+
|
29 |
+
try {
|
30 |
+
$mail->send();
|
31 |
+
$response['success'] = true;
|
32 |
+
}
|
33 |
+
catch(Exception $ex) {
|
34 |
+
// I assume you have your custom module.
|
35 |
+
// If not, you may keep 'customer' instead of 'yourmodule'.
|
36 |
+
Mage::getSingleton('core/session')
|
37 |
+
->addError(Mage::helper('fee')
|
38 |
+
->__('Unable to send email.'));
|
39 |
+
$response['success'] = false;
|
40 |
+
$response['message'] = 'Invalid request';
|
41 |
+
}
|
42 |
+
|
43 |
+
$result = $this->getResponse()->setBody(Zend_Json::encode($response));
|
44 |
+
return $result;
|
45 |
+
}
|
46 |
+
}
|
app/code/community/QS/Fee/controllers/Adminhtml/Report/FeeController.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class QS_Fee_Adminhtml_Report_FeeController extends Mage_Adminhtml_Controller_Action
|
4 |
+
{
|
5 |
+
|
6 |
+
public function _initAction()
|
7 |
+
{
|
8 |
+
|
9 |
+
$this->loadLayout()
|
10 |
+
->_addBreadcrumb(Mage::helper('fee')->__('Upic'), Mage::helper('fee')->__('Upic'));
|
11 |
+
return $this;
|
12 |
+
}
|
13 |
+
|
14 |
+
public function simpleAction()
|
15 |
+
{
|
16 |
+
$this->_title($this->__('fee'))->_title($this->__('Reports'))->_title($this->__('Simple Report'));
|
17 |
+
|
18 |
+
$this->_initAction()
|
19 |
+
->_setActiveMenu('fee/report')
|
20 |
+
->_addBreadcrumb(Mage::helper('fee')->__('Simple Example Report'), Mage::helper('fee')->__('Simple Example Report'))
|
21 |
+
->_addContent($this->getLayout()->createBlock('fee/adminhtml_report_simple'))
|
22 |
+
->renderLayout();
|
23 |
+
|
24 |
+
}
|
25 |
+
|
26 |
+
public function exportSimpleCsvAction()
|
27 |
+
{
|
28 |
+
$fileName = 'simple.csv';
|
29 |
+
$content = $this->getLayout()->createBlock('fee/adminhtml_report_simple_grid')
|
30 |
+
->getCsv();
|
31 |
+
|
32 |
+
$this->_prepareDownloadResponse($fileName, $content);
|
33 |
+
}
|
34 |
+
|
35 |
+
}
|
app/code/community/QS/Fee/controllers/IndexController.php
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/** controller for test action */
|
3 |
+
|
4 |
+
class QS_Fee_IndexController extends Mage_Core_Controller_Front_Action
|
5 |
+
{
|
6 |
+
|
7 |
+
public function updateAmountAction(){
|
8 |
+
if (array_key_exists('HTTP_X_REQUESTED_WITH', $_SERVER) && $_SERVER['HTTP_X_REQUESTED_WITH']==='XMLHttpRequest') {
|
9 |
+
$response = array();
|
10 |
+
|
11 |
+
$data = $this->getRequest()->getPost('shipping_method', '');
|
12 |
+
|
13 |
+
try {
|
14 |
+
$quote = Mage::getModel('checkout/session')->getQuote();
|
15 |
+
$adress = $quote->getShippingAddress();
|
16 |
+
|
17 |
+
$rate = $adress->getShippingRateByCode($data)->getData();
|
18 |
+
|
19 |
+
if (!$rate) {
|
20 |
+
return array('error' => -1, 'message' => Mage::helper('checkout')->__('Invalid shipping method.'));
|
21 |
+
}
|
22 |
+
|
23 |
+
$adress->setShippingAmount($rate['price']);
|
24 |
+
|
25 |
+
$adress->save();
|
26 |
+
|
27 |
+
$insurance = Mage::helper('core')->currency(QS_Fee_Model_Fee::getFee(), true, false);
|
28 |
+
$response['success'] = true;
|
29 |
+
$response['html'] = array('content' => $insurance);
|
30 |
+
|
31 |
+
}catch (Exception $e) {
|
32 |
+
$response['success'] = false;
|
33 |
+
$response['message'] = 'Invalid request';
|
34 |
+
}
|
35 |
+
|
36 |
+
$result = $this->getResponse()->setBody(Zend_Json::encode($response));
|
37 |
+
return $result;
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
public function updateStatusAction(){
|
42 |
+
if (array_key_exists('HTTP_X_REQUESTED_WITH', $_SERVER) && $_SERVER['HTTP_X_REQUESTED_WITH']==='XMLHttpRequest') {
|
43 |
+
$response = array();
|
44 |
+
$status = $this->getRequest()->getPost('status');
|
45 |
+
try {
|
46 |
+
$quote = Mage::getModel('checkout/session')->getQuote();
|
47 |
+
|
48 |
+
$adress = $quote->getShippingAddress();
|
49 |
+
|
50 |
+
if($status=='true'){
|
51 |
+
$adress->setInsuranceStatus(1);
|
52 |
+
} else {
|
53 |
+
$adress->setInsuranceStatus(0);
|
54 |
+
}
|
55 |
+
|
56 |
+
$adress->save();
|
57 |
+
|
58 |
+
$response['success'] = true;
|
59 |
+
}catch (Exception $e) {
|
60 |
+
$response['success'] = false;
|
61 |
+
$response['message'] = 'Invalid request';
|
62 |
+
}
|
63 |
+
|
64 |
+
$result = $this->getResponse()->setBody(Zend_Json::encode($response));
|
65 |
+
return $result;
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
}
|
app/code/community/QS/Fee/etc/adminhtml.xml
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<menu>
|
4 |
+
<insurance_report translate="title" module="fee">
|
5 |
+
<title>U-PIC Insurance</title>
|
6 |
+
<sort_order>15</sort_order>
|
7 |
+
<children>
|
8 |
+
<example translate="title" module="fee">
|
9 |
+
<title>Insurance Report</title>
|
10 |
+
<sort_order>1</sort_order>
|
11 |
+
<action>adminhtml/fee/</action>
|
12 |
+
</example>
|
13 |
+
</children>
|
14 |
+
</insurance_report>
|
15 |
+
</menu>
|
16 |
+
<acl>
|
17 |
+
<resources>
|
18 |
+
<admin>
|
19 |
+
<children>
|
20 |
+
<system>
|
21 |
+
<children>
|
22 |
+
<config>
|
23 |
+
<children>
|
24 |
+
<upic>
|
25 |
+
<title>U-PIC Parcel Insurance</title> <!-- Used in resources tree -->
|
26 |
+
</upic>
|
27 |
+
</children>
|
28 |
+
</config>
|
29 |
+
</children>
|
30 |
+
</system>
|
31 |
+
</children>
|
32 |
+
</admin>
|
33 |
+
</resources>
|
34 |
+
</acl>
|
35 |
+
</config>
|
app/code/community/QS/Fee/etc/config.xml
ADDED
@@ -0,0 +1,217 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<QS_Fee>
|
5 |
+
<version>0.1.7</version>
|
6 |
+
</QS_Fee>
|
7 |
+
</modules>
|
8 |
+
<frontend>
|
9 |
+
<routers>
|
10 |
+
<fee>
|
11 |
+
<use>standard</use>
|
12 |
+
<args>
|
13 |
+
<module>QS_Fee</module>
|
14 |
+
<frontName>fee</frontName>
|
15 |
+
</args>
|
16 |
+
</fee>
|
17 |
+
</routers>
|
18 |
+
<layout>
|
19 |
+
<updates>
|
20 |
+
<fee>
|
21 |
+
<file>fee.xml</file>
|
22 |
+
</fee>
|
23 |
+
</updates>
|
24 |
+
</layout>
|
25 |
+
</frontend>
|
26 |
+
<admin>
|
27 |
+
<routers>
|
28 |
+
<fee>
|
29 |
+
<use>admin</use>
|
30 |
+
<args>
|
31 |
+
<module>QS_Fee</module>
|
32 |
+
<frontName>fee</frontName>
|
33 |
+
</args>
|
34 |
+
</fee>
|
35 |
+
<adminhtml>
|
36 |
+
<args>
|
37 |
+
<modules>
|
38 |
+
<fee before="Mage_Adminhtml">QS_Fee_Adminhtml</fee>
|
39 |
+
</modules>
|
40 |
+
</args>
|
41 |
+
</adminhtml>
|
42 |
+
</routers>
|
43 |
+
</admin>
|
44 |
+
<adminhtml>
|
45 |
+
<layout>
|
46 |
+
<updates>
|
47 |
+
<fee>
|
48 |
+
<file>fee.xml</file>
|
49 |
+
</fee>
|
50 |
+
</updates>
|
51 |
+
</layout>
|
52 |
+
<acl>
|
53 |
+
<resources>
|
54 |
+
<admin>
|
55 |
+
<children>
|
56 |
+
<insurance>
|
57 |
+
<title>Insurance Report</title>
|
58 |
+
<children>
|
59 |
+
<example translate="title" module="fee">
|
60 |
+
<title>Example Menu Item</title>
|
61 |
+
</example>
|
62 |
+
</children>
|
63 |
+
</insurance>
|
64 |
+
</children>
|
65 |
+
</admin>
|
66 |
+
</resources>
|
67 |
+
</acl>
|
68 |
+
|
69 |
+
</adminhtml>
|
70 |
+
<global>
|
71 |
+
<sales>
|
72 |
+
<quote>
|
73 |
+
<totals>
|
74 |
+
<fee>
|
75 |
+
<class>fee/sales_quote_address_total_fee</class>
|
76 |
+
</fee>
|
77 |
+
</totals>
|
78 |
+
</quote>
|
79 |
+
<order_invoice>
|
80 |
+
<totals>
|
81 |
+
<fee>
|
82 |
+
<class>fee/sales_order_total_invoice_fee</class>
|
83 |
+
</fee>
|
84 |
+
</totals>
|
85 |
+
</order_invoice>
|
86 |
+
<order_creditmemo>
|
87 |
+
<totals>
|
88 |
+
<fee>
|
89 |
+
<class>fee/sales_order_total_creditmemo_fee</class>
|
90 |
+
</fee>
|
91 |
+
</totals>
|
92 |
+
</order_creditmemo>
|
93 |
+
</sales>
|
94 |
+
<events>
|
95 |
+
<paypal_prepare_line_items>
|
96 |
+
<observers>
|
97 |
+
<paypal_prepare_line_items>
|
98 |
+
<class>fee/observer</class>
|
99 |
+
<method>updatePaypalTotal</method>
|
100 |
+
</paypal_prepare_line_items>
|
101 |
+
</observers>
|
102 |
+
</paypal_prepare_line_items>
|
103 |
+
<sales_order_invoice_save_after>
|
104 |
+
<observers>
|
105 |
+
<sales_order_invoice_save_after>
|
106 |
+
<class>fee/observer</class>
|
107 |
+
<method>invoiceSaveAfter</method>
|
108 |
+
</sales_order_invoice_save_after>
|
109 |
+
</observers>
|
110 |
+
</sales_order_invoice_save_after>
|
111 |
+
<sales_order_creditmemo_save_after>
|
112 |
+
<observers>
|
113 |
+
<sales_order_creditmemo_save_after>
|
114 |
+
<class>fee/observer</class>
|
115 |
+
<method>creditmemoSaveAfter</method>
|
116 |
+
</sales_order_creditmemo_save_after>
|
117 |
+
</observers>
|
118 |
+
</sales_order_creditmemo_save_after>
|
119 |
+
</events>
|
120 |
+
<fieldsets>
|
121 |
+
<sales_convert_quote_address>
|
122 |
+
<fee_amount><to_order>*</to_order></fee_amount>
|
123 |
+
<base_fee_amount><to_order>*</to_order></base_fee_amount>
|
124 |
+
</sales_convert_quote_address>
|
125 |
+
</fieldsets>
|
126 |
+
<pdf>
|
127 |
+
<totals>
|
128 |
+
<fee translate="title">
|
129 |
+
<title>Fee</title>
|
130 |
+
<source_field>fee_amount</source_field>
|
131 |
+
<font_size>7</font_size>
|
132 |
+
<display_zero>0</display_zero>
|
133 |
+
<sort_order>650</sort_order>
|
134 |
+
<amount_prefix>-</amount_prefix>
|
135 |
+
</fee>
|
136 |
+
</totals>
|
137 |
+
</pdf>
|
138 |
+
<models>
|
139 |
+
<fee>
|
140 |
+
<class>QS_Fee_Model</class>
|
141 |
+
<resourceModel>fee_resource</resourceModel>
|
142 |
+
</fee>
|
143 |
+
<fee_resource>
|
144 |
+
<class>QS_Fee_Model_Resource</class>
|
145 |
+
<entities>
|
146 |
+
<table_tiers>
|
147 |
+
<table>fee_tiers</table>
|
148 |
+
</table_tiers>
|
149 |
+
</entities>
|
150 |
+
</fee_resource>
|
151 |
+
</models>
|
152 |
+
<resources>
|
153 |
+
<fee_setup>
|
154 |
+
<setup>
|
155 |
+
<module>QS_Fee</module>
|
156 |
+
</setup>
|
157 |
+
<connection>
|
158 |
+
<use>core_setup</use>
|
159 |
+
</connection>
|
160 |
+
</fee_setup>
|
161 |
+
<fee_write>
|
162 |
+
<connection>
|
163 |
+
<use>core_write</use>
|
164 |
+
</connection>
|
165 |
+
</fee_write>
|
166 |
+
<fee_read>
|
167 |
+
<connection>
|
168 |
+
<use>core_read</use>
|
169 |
+
</connection>
|
170 |
+
</fee_read>
|
171 |
+
</resources>
|
172 |
+
<blocks>
|
173 |
+
<fee>
|
174 |
+
<class>QS_Fee_Block</class>
|
175 |
+
</fee>
|
176 |
+
</blocks>
|
177 |
+
<helpers>
|
178 |
+
<fee>
|
179 |
+
<class>QS_Fee_Helper</class>
|
180 |
+
</fee>
|
181 |
+
</helpers>
|
182 |
+
</global>
|
183 |
+
<default>
|
184 |
+
<sales>
|
185 |
+
<totals_sort>
|
186 |
+
<fee>30</fee>
|
187 |
+
</totals_sort>
|
188 |
+
</sales>
|
189 |
+
<upic>
|
190 |
+
<general>
|
191 |
+
<ftp_server>dev53.quartsoft.com</ftp_server>
|
192 |
+
<ftp_user_name>sas_flame</ftp_user_name>
|
193 |
+
<ftp_user_pass>dgmait072</ftp_user_pass>
|
194 |
+
<upic_email_adress>sales@u-pic.com</upic_email_adress>
|
195 |
+
<insurance_as_default>1</insurance_as_default>
|
196 |
+
</general>
|
197 |
+
</upic>
|
198 |
+
<trans_email>
|
199 |
+
<ident_dropship>
|
200 |
+
<dropship_name>Alex</dropship_name>
|
201 |
+
<dropship_email>sasflame5@gmail.com</dropship_email>
|
202 |
+
</ident_dropship>
|
203 |
+
</trans_email>
|
204 |
+
</default>
|
205 |
+
<crontab>
|
206 |
+
<jobs>
|
207 |
+
<fee>
|
208 |
+
<schedule>
|
209 |
+
<cron_expr>*/15 * * * *</cron_expr>
|
210 |
+
</schedule>
|
211 |
+
<run>
|
212 |
+
<model>fee/observer::load</model>
|
213 |
+
</run>
|
214 |
+
</fee>
|
215 |
+
</jobs>
|
216 |
+
</crontab>
|
217 |
+
</config>
|
app/code/community/QS/Fee/etc/system.xml
ADDED
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<sections>
|
4 |
+
<upic translate="label" module="adminhtml">
|
5 |
+
<label>U-PIC Parcel Insurance</label>
|
6 |
+
<tab>sales</tab>
|
7 |
+
<sort_order>10</sort_order>
|
8 |
+
<show_in_default>1</show_in_default>
|
9 |
+
<show_in_website>1</show_in_website>
|
10 |
+
<show_in_store>1</show_in_store>
|
11 |
+
<groups>
|
12 |
+
<general translate="label comment">
|
13 |
+
<label>Insurance Checkout</label>
|
14 |
+
<sort_order>50</sort_order>
|
15 |
+
<show_in_default>1</show_in_default>
|
16 |
+
<show_in_website>1</show_in_website>
|
17 |
+
<show_in_store>1</show_in_store>
|
18 |
+
<comment><![CDATA[<strong>Help information:</strong><br />For setup acount you must send activation email to company U-Pic and <br /> fills inputs the Policy number and the Activation Code!]]></comment>
|
19 |
+
<fields>
|
20 |
+
<policy_number translate="label comment">
|
21 |
+
<label>Policy number</label>
|
22 |
+
<frontend_type>text</frontend_type>
|
23 |
+
<sort_order>10</sort_order>
|
24 |
+
<show_in_default>1</show_in_default>
|
25 |
+
<show_in_website>1</show_in_website>
|
26 |
+
<show_in_store>1</show_in_store>
|
27 |
+
</policy_number>
|
28 |
+
<activation_code translate="label comment">
|
29 |
+
<backend_model>fee/validation_code</backend_model>
|
30 |
+
<label>Activation Code</label>
|
31 |
+
<frontend_type>text</frontend_type>
|
32 |
+
<sort_order>20</sort_order>
|
33 |
+
<show_in_default>1</show_in_default>
|
34 |
+
<show_in_website>1</show_in_website>
|
35 |
+
<show_in_store>1</show_in_store>
|
36 |
+
</activation_code>
|
37 |
+
<insurance_as_default translate="label comment">
|
38 |
+
<label>Use insurance</label>
|
39 |
+
<comment>Use insurance to order as default</comment>
|
40 |
+
<frontend_type>select</frontend_type>
|
41 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
42 |
+
<sort_order>30</sort_order>
|
43 |
+
<show_in_default>1</show_in_default>
|
44 |
+
<show_in_website>1</show_in_website>
|
45 |
+
<show_in_store>1</show_in_store>
|
46 |
+
</insurance_as_default>
|
47 |
+
<check translate="label">
|
48 |
+
<label>Activate your account</label>
|
49 |
+
<frontend_type>button</frontend_type>
|
50 |
+
<frontend_model>fee/adminhtml_system_config_form_activate</frontend_model>
|
51 |
+
<sort_order>40</sort_order>
|
52 |
+
<show_in_default>1</show_in_default>
|
53 |
+
<show_in_website>1</show_in_website>
|
54 |
+
<show_in_store>1</show_in_store>
|
55 |
+
</check>
|
56 |
+
</fields>
|
57 |
+
</general>
|
58 |
+
</groups>
|
59 |
+
</upic>
|
60 |
+
<trans_email translate="label" module="adminhtml">
|
61 |
+
<groups>
|
62 |
+
<ident_dropship translate="label">
|
63 |
+
<label>Dropship Email Contact</label>
|
64 |
+
<frontend_type>text</frontend_type>
|
65 |
+
<sort_order>10</sort_order>
|
66 |
+
<show_in_default>1</show_in_default>
|
67 |
+
<show_in_website>1</show_in_website>
|
68 |
+
<show_in_store>1</show_in_store>
|
69 |
+
<fields>
|
70 |
+
<dropship_name translate="label">
|
71 |
+
<label>Sender Name</label>
|
72 |
+
<frontend_type>text</frontend_type>
|
73 |
+
<backend_model>adminhtml/system_config_backend_email_sender</backend_model>
|
74 |
+
<validate>validate-emailSender</validate>
|
75 |
+
<sort_order>1</sort_order>
|
76 |
+
<show_in_default>1</show_in_default>
|
77 |
+
<show_in_website>1</show_in_website>
|
78 |
+
<show_in_store>1</show_in_store>
|
79 |
+
</dropship_name>
|
80 |
+
<dropship_email translate="label">
|
81 |
+
<label>Sender Email</label>
|
82 |
+
<frontend_type>text</frontend_type>
|
83 |
+
<validate>validate-email</validate>
|
84 |
+
<backend_model>adminhtml/system_config_backend_email_address</backend_model>
|
85 |
+
<sort_order>2</sort_order>
|
86 |
+
<show_in_default>1</show_in_default>
|
87 |
+
<show_in_website>1</show_in_website>
|
88 |
+
<show_in_store>1</show_in_store>
|
89 |
+
</dropship_email>
|
90 |
+
</fields>
|
91 |
+
</ident_dropship>
|
92 |
+
</groups>
|
93 |
+
</trans_email>
|
94 |
+
</sections>
|
95 |
+
</config>
|
app/code/community/QS/Fee/sql/fee_setup/mysql4-install-0.1.0.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
$installer->startSetup();
|
6 |
+
|
7 |
+
$installer->run("
|
8 |
+
|
9 |
+
ALTER TABLE `".$this->getTable('sales/order')."` ADD `fee_amount` DECIMAL( 10, 2 ) NOT NULL;
|
10 |
+
ALTER TABLE `".$this->getTable('sales/order')."` ADD `base_fee_amount` DECIMAL( 10, 2 ) NOT NULL;
|
11 |
+
|
12 |
+
");
|
13 |
+
|
14 |
+
$installer->endSetup();
|
app/code/community/QS/Fee/sql/fee_setup/mysql4-upgrade-0.1.0-0.1.1.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
$installer->startSetup();
|
6 |
+
|
7 |
+
$installer->run("
|
8 |
+
|
9 |
+
ALTER TABLE `".$this->getTable('sales/quote_address')."` ADD `fee_amount` DECIMAL( 10, 2 ) NOT NULL;
|
10 |
+
ALTER TABLE `".$this->getTable('sales/quote_address')."` ADD `base_fee_amount` DECIMAL( 10, 2 ) NOT NULL;
|
11 |
+
|
12 |
+
");
|
13 |
+
|
14 |
+
$installer->endSetup();
|
app/code/community/QS/Fee/sql/fee_setup/mysql4-upgrade-0.1.1-0.1.2.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
$installer->startSetup();
|
6 |
+
|
7 |
+
$installer->run("
|
8 |
+
|
9 |
+
ALTER TABLE `".$this->getTable('sales/order')."` ADD `fee_amount_invoiced` DECIMAL( 10, 2 ) NOT NULL;
|
10 |
+
ALTER TABLE `".$this->getTable('sales/order')."` ADD `base_fee_amount_invoiced` DECIMAL( 10, 2 ) NOT NULL;
|
11 |
+
|
12 |
+
");
|
13 |
+
|
14 |
+
$installer->endSetup();
|
app/code/community/QS/Fee/sql/fee_setup/mysql4-upgrade-0.1.2-0.1.3.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
$installer->startSetup();
|
6 |
+
|
7 |
+
$installer->run("
|
8 |
+
|
9 |
+
ALTER TABLE `".$this->getTable('sales/invoice')."` ADD `fee_amount` DECIMAL( 10, 2 ) NOT NULL;
|
10 |
+
ALTER TABLE `".$this->getTable('sales/invoice')."` ADD `base_fee_amount` DECIMAL( 10, 2 ) NOT NULL;
|
11 |
+
|
12 |
+
");
|
13 |
+
|
14 |
+
$installer->endSetup();
|
app/code/community/QS/Fee/sql/fee_setup/mysql4-upgrade-0.1.3-0.1.4.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
$installer->startSetup();
|
6 |
+
|
7 |
+
$installer->run("
|
8 |
+
|
9 |
+
ALTER TABLE `".$this->getTable('sales/order')."` ADD `fee_amount_refunded` DECIMAL( 10, 2 ) NOT NULL;
|
10 |
+
ALTER TABLE `".$this->getTable('sales/order')."` ADD `base_fee_amount_refunded` DECIMAL( 10, 2 ) NOT NULL;
|
11 |
+
|
12 |
+
ALTER TABLE `".$this->getTable('sales/creditmemo')."` ADD `fee_amount` DECIMAL( 10, 2 ) NOT NULL;
|
13 |
+
ALTER TABLE `".$this->getTable('sales/creditmemo')."` ADD `base_fee_amount` DECIMAL( 10, 2 ) NOT NULL;
|
14 |
+
|
15 |
+
");
|
16 |
+
|
17 |
+
$installer->endSetup();
|
app/code/community/QS/Fee/sql/fee_setup/mysql4-upgrade-0.1.4-0.1.5.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
$installer->startSetup();
|
6 |
+
|
7 |
+
$tableName = $installer->getTable('fee/table_tiers');
|
8 |
+
|
9 |
+
$table = $installer->getConnection()
|
10 |
+
->newTable($tableName)
|
11 |
+
->addColumn('tiers_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
12 |
+
'identity' => true,
|
13 |
+
'unsigned' => true,
|
14 |
+
'nullable' => false,
|
15 |
+
'primary' => true,
|
16 |
+
), 'Tiers ID')
|
17 |
+
->addColumn('tier_title', Varien_Db_Ddl_Table::TYPE_VARCHAR)
|
18 |
+
->addColumn('domestic_value', Varien_Db_Ddl_Table::TYPE_FLOAT)
|
19 |
+
->addColumn('international_value', Varien_Db_Ddl_Table::TYPE_FLOAT)
|
20 |
+
->addColumn('code', Varien_Db_Ddl_Table::TYPE_VARCHAR);
|
21 |
+
$installer->getConnection()->createTable($table);
|
22 |
+
|
23 |
+
$query = "insert into $tableName (tier_title,domestic_value,international_value,code)
|
24 |
+
values (:tier_title,:domestic_value, :international_value, :code);";
|
25 |
+
|
26 |
+
$binds = array(
|
27 |
+
'tier_title' => "Tier 1",
|
28 |
+
'domestic_value' => "0.69",
|
29 |
+
'international_value' => "1.1",
|
30 |
+
'code' => "upichrm29800",
|
31 |
+
);
|
32 |
+
$installer->getConnection()->query($query,$binds);
|
33 |
+
|
34 |
+
$binds = array(
|
35 |
+
'tier_title' => "Tier 2",
|
36 |
+
'domestic_value' => "0.79",
|
37 |
+
'international_value' => "1.25",
|
38 |
+
'code' => "upicmpv28001",
|
39 |
+
);
|
40 |
+
$installer->getConnection()->query($query,$binds);
|
41 |
+
|
42 |
+
$binds = array(
|
43 |
+
'tier_title' => "Tier 3",
|
44 |
+
'domestic_value' => "0.99",
|
45 |
+
'international_value' => "1.49",
|
46 |
+
'code' => "upicds5703",
|
47 |
+
);
|
48 |
+
$installer->getConnection()->query($query,$binds);
|
49 |
+
|
50 |
+
$installer->endSetup();
|
app/code/community/QS/Fee/sql/fee_setup/mysql4-upgrade-0.1.5-0.1.6.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
$installer->startSetup();
|
6 |
+
|
7 |
+
$installer->run("
|
8 |
+
|
9 |
+
ALTER TABLE `".$this->getTable('sales/quote_address')."` add `insurance_status` BOOLEAN DEFAULT FALSE;
|
10 |
+
");
|
11 |
+
|
12 |
+
$installer->endSetup();
|
app/code/community/QS/Fee/sql/fee_setup/mysql4-upgrade-0.1.6-0.1.7.php
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
$installer->startSetup();
|
6 |
+
|
7 |
+
$inshurance_info_use_content = "
|
8 |
+
<p style='font-size: 18px; font-weight: bold; color: #777; margin-bottom: 20px;'>Why use U-PIC Parcel Insurance?</p>
|
9 |
+
<ul style='list-style-position: inside; font-size: 18px; color: #777; font-weight: bold; '>
|
10 |
+
<li style='display:inline-block; background: url({{skin url='images/li-icon.png'}}) no-repeat 5px 0px; padding-left: 70px; padding-bottom: 20px; width: 70%;'>Guaranteed delivery or your money back.</li>
|
11 |
+
<li style='display:inline-block; background: url({{skin url='images/li-icon.png'}}) no-repeat 5px 0px; padding-left: 70px; padding-bottom: 20px; width: 70%;'>Guaranteed to arrive undamaged or your money back.</li>
|
12 |
+
<li style='display:inline-block; background: url({{skin url='images/li-icon.png'}}) no-repeat 5px 0px; padding-left: 70px; padding-bottom: 20px; width: 70%;'>Guaranteed peace of mind.</li>
|
13 |
+
<li style='display:inline-block; background: url({{skin url='images/li-icon.png'}}) no-repeat 5px 0px; padding-left: 70px; padding-bottom: 20px; width: 70%;'>Guaranteed 100% protection!</li>
|
14 |
+
<p style='font-size: 12px; font-weight: bold; padding-left: 70px; color: #777;'>Insurance provided by an 'A'(Excellent) - A. M. Best and 'A' (Strong) - Standart & Poor's Insurance Company.</p>
|
15 |
+
</ul>";
|
16 |
+
|
17 |
+
$stores = Mage::getModel('core/store')->getCollection()->addFieldToFilter('store_id', array('gt'=>0))->getAllIds();
|
18 |
+
|
19 |
+
foreach ($stores as $store){
|
20 |
+
$block = Mage::getModel('cms/block');
|
21 |
+
$block->setTitle('Inshurance info use');
|
22 |
+
$block->setIdentifier('inshurance_info_use');
|
23 |
+
$block->setStores(array($store));
|
24 |
+
$block->setIsActive(1);
|
25 |
+
$block->setContent($inshurance_info_use_content);
|
26 |
+
$block->save();
|
27 |
+
}
|
28 |
+
|
29 |
+
$inshurance_info_rules_content = "
|
30 |
+
<p style='font-size: 18px; font-weight: bold; color: #777; margin-bottom: 20px;'>Coverage Rules</p>
|
31 |
+
<p style='font-size: 18px; font-weight: bold; color: #777; margin-bottom: 15px;'>U-PIC COVERAGE DOES NOT INSURE THE FOLLOWING</p>
|
32 |
+
<ol style='font-size: 12px; color: #777; font-weight: bold; '>
|
33 |
+
<li style='list-style-type:decimal;padding-left: 32px; padding-bottom: 18px; width: 72%;'>Accounts, bills, bullion, currency, deeds, evidence of debt, furs, original/fine art, computer chips, money, notes, securities, perishable cargo, precious/semi-precious stones, televisions, tickets, laptop computers, cellphones, personal goods, or similar property unless endorsed in writing.</li>
|
34 |
+
<li style='list-style-type:decimal;padding-left: 32px; padding-bottom: 18px; width: 72%;'>Loss, damage, or non-arrival of any parcel which; (a) is addressed, wrapped or packed insufficiently, incorrectly or contrary to the carrier's packaging requirements; or (b) bears a descriptive label or packaging which tends to describe the nature of its contents.</li>
|
35 |
+
<li style='list-style-type:decimal;padding-left: 32px; padding-bottom: 18px; width: 75%;'>Arising out of infidelity, dishonesty, or any overt act on the part of the Insured, associate in interest, and/or any of the Insured’s employees whether occurring during hours of employment or otherwise, nor on the part of custodians (common carriers excepted), or the property insured unless specifically endorsed hereon in writing.</li>
|
36 |
+
<li style='list-style-type:decimal;padding-left: 32px; padding-bottom: 18px; width: 70%;'>Arising out of loss of market, latent defect, inherent vice, delay, loss of use, cleanup costs, decay, changes in temperature or humidity, or other deterioration, any remote or consequential loss, whether or not arising out of a peril insured against.</li>
|
37 |
+
<li style='list-style-type:decimal;padding-left: 32px; padding-bottom: 18px; width: 70%;'>Afghanistan; Algeria; Angola (Cabinda); Belarus; Bosnia; Burma; Burundi; Cote d'Ivoire (Ivory Coast); Croatia; Cuba; Democratic Republic of the Congo; Herzegovina; Iran; Iraq; Jordan; Liberia; Libya, Moldova; Montenegro; Nigeria; North Korea; Paraguay; Republic of the Congo (Zaire); Serbia; Sierra Leone; Somalia; Sri Lanka; Sudan; Syria; Togo; Yemen; Zimbabwe <br>***Or any other country that is or may become embargoed by the United States or United Nations as sanctioned by the Office of Foreign Asset Control (OFAC).</li>
|
38 |
+
</ol>";
|
39 |
+
|
40 |
+
$stores = Mage::getModel('core/store')->getCollection()->addFieldToFilter('store_id', array('gt'=>0))->getAllIds();
|
41 |
+
|
42 |
+
foreach ($stores as $store){
|
43 |
+
$block = Mage::getModel('cms/block');
|
44 |
+
$block->setTitle('Inshurance info rules');
|
45 |
+
$block->setIdentifier('inshurance_info_rules');
|
46 |
+
$block->setStores(array($store));
|
47 |
+
$block->setIsActive(1);
|
48 |
+
$block->setContent($inshurance_info_rules_content);
|
49 |
+
$block->save();
|
50 |
+
}
|
51 |
+
|
52 |
+
$installer->endSetup();
|
53 |
+
|
app/design/adminhtml/default/default/layout/fee.xml
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<default>
|
4 |
+
<reference name="head">
|
5 |
+
<action method="addJs"><script>prototype/popupbox.js</script></action>
|
6 |
+
<action method="addItem"><type>skin_css</type><name>css/popupbox.css</name></action>
|
7 |
+
</reference>
|
8 |
+
</default>
|
9 |
+
<adminhtml_sales_order_view>
|
10 |
+
<reference name="order_totals">
|
11 |
+
<block type="adminhtml/sales_order_totals_item" name="fee" template="fee/sales/order/total.phtml">
|
12 |
+
</block>
|
13 |
+
<block type="adminhtml/sales_order_totals_item" name="fee.refunded" template="fee/sales/order/refunded.phtml">
|
14 |
+
<action method="setDisplayArea"><area>footer</area></action>
|
15 |
+
<action method="setAfterCondition"><condition>last</condition></action>
|
16 |
+
</block>
|
17 |
+
</reference>
|
18 |
+
</adminhtml_sales_order_view>
|
19 |
+
|
20 |
+
<adminhtml_sales_order_invoice_new>
|
21 |
+
<reference name="invoice_totals">
|
22 |
+
<block type="adminhtml/sales_order_totals_item" name="fee" template="fee/sales/order/total.phtml">
|
23 |
+
</block>
|
24 |
+
</reference>
|
25 |
+
</adminhtml_sales_order_invoice_new>
|
26 |
+
|
27 |
+
<adminhtml_sales_order_invoice_updateqty>
|
28 |
+
<reference name="invoice_totals">
|
29 |
+
<block type="adminhtml/sales_order_totals_item" name="fee" template="fee/sales/order/total.phtml">
|
30 |
+
</block>
|
31 |
+
</reference>
|
32 |
+
</adminhtml_sales_order_invoice_updateqty>
|
33 |
+
|
34 |
+
<adminhtml_sales_order_invoice_view>
|
35 |
+
<reference name="invoice_totals">
|
36 |
+
<block type="adminhtml/sales_order_totals_item" name="fee" template="fee/sales/order/total.phtml">
|
37 |
+
</block>
|
38 |
+
</reference>
|
39 |
+
</adminhtml_sales_order_invoice_view>
|
40 |
+
|
41 |
+
<adminhtml_sales_order_creditmemo_new>
|
42 |
+
<reference name="creditmemo_totals">
|
43 |
+
<block type="adminhtml/sales_order_totals_item" name="fee" template="fee/sales/order/total.phtml">
|
44 |
+
</block>
|
45 |
+
</reference>
|
46 |
+
</adminhtml_sales_order_creditmemo_new>
|
47 |
+
|
48 |
+
<adminhtml_sales_order_creditmemo_updateqty>
|
49 |
+
<reference name="creditmemo_totals">
|
50 |
+
<block type="adminhtml/sales_order_totals_item" name="fee" template="fee/sales/order/total.phtml">
|
51 |
+
</block>
|
52 |
+
</reference>
|
53 |
+
</adminhtml_sales_order_creditmemo_updateqty>
|
54 |
+
|
55 |
+
<adminhtml_sales_order_creditmemo_view>
|
56 |
+
<reference name="creditmemo_totals">
|
57 |
+
<block type="adminhtml/sales_order_totals_item" name="fee.refunded" template="fee/sales/order/refunded.phtml">
|
58 |
+
<action method="setDisplayArea"><area>footer</area></action>
|
59 |
+
</block>
|
60 |
+
</reference>
|
61 |
+
</adminhtml_sales_order_creditmemo_view>
|
62 |
+
|
63 |
+
<adminhtml_fee_index>
|
64 |
+
<reference name="content">
|
65 |
+
<block type="fee/adminhtml_totals" name="totals" template="fee/totals.phtml"></block>
|
66 |
+
</reference>
|
67 |
+
</adminhtml_fee_index>
|
68 |
+
</layout>
|
app/design/adminhtml/default/default/template/fee/sales/order/refunded.phtml
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if($this->getSource() instanceof Mage_Sales_Model_Order){ ?>
|
2 |
+
<?php if ((float) $this->getSource()->getFeeAmountRefunded()): ?>
|
3 |
+
<tr>
|
4 |
+
<td class="label"><strong><?php echo Mage::helper('fee')->__('Fee refunded to customer') ?></strong></td>
|
5 |
+
<td><strong><?php echo $this->getSource()->getFeeAmountRefunded(); ?></strong></td>
|
6 |
+
</tr>
|
7 |
+
<?php endif; ?>
|
8 |
+
<?php } else { ?>
|
9 |
+
<?php if ((float) $this->getSource()->getFeeAmount()): ?>
|
10 |
+
<tr>
|
11 |
+
<td class="label"><strong><?php echo Mage::helper('fee')->__('Fee Refunded') ?></strong></td>
|
12 |
+
<td><strong><?php echo $this->getSource()->getFeeAmount(); ?></strong></td>
|
13 |
+
</tr>
|
14 |
+
<?php endif;
|
15 |
+
}?>
|
16 |
+
|
app/design/adminhtml/default/default/template/fee/sales/order/total.phtml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php $this->setPriceDataObject($this->getSource()) ?>
|
2 |
+
<?php if ((float) $this->getSource()->getFeeAmount()): ?>
|
3 |
+
<tr>
|
4 |
+
<td class="label"><?php echo Mage::helper('fee')->formatFee($this->getSource()->getFeeAmount()) ?></td>
|
5 |
+
<td>
|
6 |
+
<?php echo $this->displayPrices($this->getSource()->getBaseFeeAmount(), $this->getSource()->getFeeAmount()); ?>
|
7 |
+
</td>
|
8 |
+
</tr>
|
9 |
+
<?php endif; ?>
|
app/design/adminhtml/default/default/template/fee/system/config/activate_link.phtml
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div id="activate-popup" style="display: none;">
|
2 |
+
<div id="activate-popup-container">
|
3 |
+
<div id="activate-popup-header">
|
4 |
+
<h5>Send activation email to U-PIC company</h5>
|
5 |
+
</div>
|
6 |
+
<form name="activate-form" id="activate-form" method="post">
|
7 |
+
<label for="from">From *</label>
|
8 |
+
|
9 |
+
<input type="text" id="from" name="from" value="<?php echo $this->getAdminEmailAdress();?>" class="required-entry validate-email"/>
|
10 |
+
<br>
|
11 |
+
<br>
|
12 |
+
<label for="to">To *</label>
|
13 |
+
|
14 |
+
<input type="text" id="to" name="to" value="<?php echo $this->getUpicEmailAdress();?>" class="required-entry validate-email" readonly="readonly"/>
|
15 |
+
<br>
|
16 |
+
<br>
|
17 |
+
<label for="message">
|
18 |
+
<?php echo $this->__('Content') ?> <span>*</span></label>
|
19 |
+
<br>
|
20 |
+
<br>
|
21 |
+
<p><textarea id="message" rows="10" cols="86" name="message" class="required-entry">Please send me activation code and policy number for U-PIC Insurance</textarea></p>
|
22 |
+
<input class="form-button" type="submit" id="send" onclick="if(customValidate()){activatePopup.activate()};" value="send"/>
|
23 |
+
</form>
|
24 |
+
</div>
|
25 |
+
</div>
|
26 |
+
|
27 |
+
<a href="" onclick="activatePopup.showPopupBox();return false;">Register</a>
|
28 |
+
|
29 |
+
<div id="upic-logo">
|
30 |
+
<img src="<?php echo $this->getSkinUrl('images/label.png')?>" alt="U-PIC logo"/>
|
31 |
+
</div>
|
32 |
+
|
33 |
+
|
34 |
+
<script type="text/javascript">
|
35 |
+
|
36 |
+
function customValidate(){
|
37 |
+
if(Validation.validate('to') &&Validation.validate('from') && Validation.validate('message')){
|
38 |
+
return true;
|
39 |
+
}else{
|
40 |
+
return false;
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
var activate_Popup = Class.create();
|
45 |
+
activate_Popup.prototype = {
|
46 |
+
initialize: function() {
|
47 |
+
this.action = "<?php echo $this->getUrl('faq/index/help/') ?>";
|
48 |
+
this.currentcategory = 0;
|
49 |
+
this.Popup = new Popupbox('activate-popup', false, 'activate', {
|
50 |
+
overlayColor: '#ffffff',
|
51 |
+
closeText: 'close',
|
52 |
+
overlayOpacity: 0.75,
|
53 |
+
overlayDuration: 0.2,
|
54 |
+
marginTop: '50',
|
55 |
+
width: '481px',
|
56 |
+
showShadow: false
|
57 |
+
});
|
58 |
+
},
|
59 |
+
showPopupBox: function(){
|
60 |
+
if (!$('to').value){
|
61 |
+
alert('Please set E-mail adress U-PIC company in config.xml');
|
62 |
+
}
|
63 |
+
this.Popup.showPopup();
|
64 |
+
},
|
65 |
+
activate: function(){
|
66 |
+
new Ajax.Request('<?php echo $this->getAjaxCheckUrl() ?>', {
|
67 |
+
method: 'post',
|
68 |
+
parameters:'message='+$('message').value+'&'+'from='+ $('from').value+'&'+'to='+$('to').value,
|
69 |
+
onSuccess: function(transport){
|
70 |
+
if (transport.responseText){
|
71 |
+
alert('Email was send successfully!')
|
72 |
+
}
|
73 |
+
},
|
74 |
+
onFailure: function(){
|
75 |
+
alert('Fail!!!');
|
76 |
+
}
|
77 |
+
});
|
78 |
+
}
|
79 |
+
}
|
80 |
+
|
81 |
+
var activatePopup,status;
|
82 |
+
$(document).observe('dom:loaded', function() {
|
83 |
+
|
84 |
+
activatePopup = new activate_Popup();
|
85 |
+
status = <?php if (Mage::getStoreConfig('upic/general/activation_code')!= '' &&
|
86 |
+
Mage::getStoreConfig('upic/general/policy_number')!='' ):?>
|
87 |
+
1;
|
88 |
+
<?php else: ?>
|
89 |
+
0;
|
90 |
+
<?php endif;?>
|
91 |
+
if(!status){
|
92 |
+
activatePopup.showPopupBox();
|
93 |
+
}
|
94 |
+
})
|
95 |
+
|
96 |
+
</script>
|
app/design/adminhtml/default/default/template/fee/totals.phtml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div id="totals-for-day" class="totals-for-day">
|
2 |
+
<h5>Insurance report for day:</h5>
|
3 |
+
<br/>
|
4 |
+
<h5>Totals order count: <?php echo $this->getOrdersCount();?></h5>
|
5 |
+
<br/>
|
6 |
+
<h5>Totals insurance amount: <?php echo Mage::helper('core')->currency($this->getTotalInsurance(), true, false);?></h5>
|
7 |
+
</div>
|
app/design/frontend/default/default/layout/fee.xml
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<default>
|
4 |
+
<reference name="head">
|
5 |
+
<action method="addJs"><script>prototype/popupbox.js</script></action>
|
6 |
+
<action method="addItem"><type>skin_css</type><name>css/popupbox.css</name></action>
|
7 |
+
</reference>
|
8 |
+
</default>
|
9 |
+
<sales_order_view>
|
10 |
+
<reference name="order_totals">
|
11 |
+
<block type="fee/sales_order_total" name="fee.sales.order.total" />
|
12 |
+
</reference>
|
13 |
+
</sales_order_view>
|
14 |
+
<sales_order_print>
|
15 |
+
<reference name="order_totals">
|
16 |
+
<block type="fee/sales_order_total" name="fee.sales.order.total" />
|
17 |
+
</reference>
|
18 |
+
</sales_order_print>
|
19 |
+
<sales_email_order_items>
|
20 |
+
<reference name="order_totals">
|
21 |
+
<block type="fee/sales_order_total" name="fee.sales.order.total" />
|
22 |
+
</reference>
|
23 |
+
</sales_email_order_items>
|
24 |
+
|
25 |
+
<sales_order_invoice>
|
26 |
+
<reference name="invoice_totals">
|
27 |
+
<block type="fee/sales_order_total" name="fee.sales.order.total" />
|
28 |
+
</reference>
|
29 |
+
</sales_order_invoice>
|
30 |
+
<sales_order_printinvoice>
|
31 |
+
<reference name="invoice_totals">
|
32 |
+
<block type="fee/sales_order_total" name="fee.sales.order.total" />
|
33 |
+
</reference>
|
34 |
+
</sales_order_printinvoice>
|
35 |
+
<sales_email_order_invoice_items>
|
36 |
+
<reference name="invoice_totals">
|
37 |
+
<block type="fee/sales_order_total" name="fee.sales.order.total" />
|
38 |
+
</reference>
|
39 |
+
</sales_email_order_invoice_items>
|
40 |
+
|
41 |
+
<sales_order_creditmemo>
|
42 |
+
<reference name="creditmemo_totals">
|
43 |
+
<block type="fee/sales_order_total" name="fee.sales.order.total" />
|
44 |
+
</reference>
|
45 |
+
</sales_order_creditmemo>
|
46 |
+
<sales_order_printcreditmemo>
|
47 |
+
<reference name="creditmemo_totals">
|
48 |
+
<block type="fee/sales_order_total" name="fee.sales.order.total" />
|
49 |
+
</reference>
|
50 |
+
</sales_order_printcreditmemo>
|
51 |
+
<sales_email_order_creditmemo_items>
|
52 |
+
<reference name="creditmemo_totals">
|
53 |
+
<block type="fee/sales_order_total" name="fee.sales.order.total" />
|
54 |
+
</reference>
|
55 |
+
</sales_email_order_creditmemo_items>
|
56 |
+
<checkout_onepage_shippingmethod>
|
57 |
+
<block type="fee/insurance" name="fee.sales.order.total" output="toHtml" template="fee/fee.phtml"/>
|
58 |
+
</checkout_onepage_shippingmethod>
|
59 |
+
</layout>
|
app/design/frontend/default/default/template/checkout/onepage/shipping_method.phtml
ADDED
@@ -0,0 +1,173 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package base_default
|
23 |
+
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<form id="co-shipping-method-form" action="">
|
28 |
+
<div id="checkout-shipping-method-load">
|
29 |
+
<!-- Content loaded dynamically -->
|
30 |
+
</div>
|
31 |
+
<script type="text/javascript">
|
32 |
+
//<![CDATA[
|
33 |
+
var shippingMethod = new ShippingMethod('co-shipping-method-form', "<?php echo $this->getUrl('checkout/onepage/saveShippingMethod') ?>");
|
34 |
+
//]]>
|
35 |
+
</script>
|
36 |
+
<div id="onepage-checkout-shipping-method-additional-load">
|
37 |
+
<?php echo $this->getChildHtml('additional') ?>
|
38 |
+
</div>
|
39 |
+
<div class="buttons-set" id="shipping-method-buttons-container">
|
40 |
+
<p class="back-link"><a href="#" onclick="checkout.back(); return false;"><small>« </small><?php echo $this->__('Back') ?></a></p>
|
41 |
+
<button type="button" class="button" onclick="shippingMethod.save()"><span><span><?php echo $this->__('Continue') ?></span></span></button>
|
42 |
+
<span id="shipping-method-please-wait" class="please-wait" style="display:none;">
|
43 |
+
<img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="<?php echo $this->__('Loading next step...') ?>" title="<?php echo $this->__('Loading next step...') ?>" class="v-middle" /> <?php echo $this->__('Loading next step...') ?>
|
44 |
+
</span>
|
45 |
+
</div>
|
46 |
+
</form>
|
47 |
+
|
48 |
+
<div id="info-use-popup" style="display: none;">
|
49 |
+
<div id="info-use-container">
|
50 |
+
<div id="top-logo"></div>
|
51 |
+
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('inshurance_info_use')->toHtml();?>
|
52 |
+
</div>
|
53 |
+
</div>
|
54 |
+
|
55 |
+
<div id="info-rules-popup" style="display: none;">
|
56 |
+
<div id="info-rules-container">
|
57 |
+
<div id="top-logo"></div>
|
58 |
+
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('inshurance_info_rules')->toHtml();?>
|
59 |
+
</div>
|
60 |
+
</div>
|
61 |
+
|
62 |
+
<script type="text/javascript">
|
63 |
+
var Insurance = Class.create();
|
64 |
+
Insurance.prototype = {
|
65 |
+
initialize: function(form, saveUrl, removeUrl){
|
66 |
+
this.form = form;
|
67 |
+
if ($(this.form)) {
|
68 |
+
$(this.form).observe('submit', function(event){this.save();Event.stop(event);}.bind(this));
|
69 |
+
}
|
70 |
+
this.saveUrl = saveUrl;
|
71 |
+
this.removeUrl = removeUrl;
|
72 |
+
this.validator = new Validation(this.form);
|
73 |
+
},
|
74 |
+
|
75 |
+
updateAmount: function(){
|
76 |
+
if (this.validate()) {
|
77 |
+
var request = new Ajax.Request(
|
78 |
+
this.saveUrl,
|
79 |
+
{
|
80 |
+
method:'post',
|
81 |
+
parameters: Form.serialize(this.form),
|
82 |
+
onLoading:this.processingStart,
|
83 |
+
onComplete: this.onComplete,
|
84 |
+
onSuccess: function(transport){
|
85 |
+
var response = transport.responseText.evalJSON();
|
86 |
+
var content = $('insurance-amount');
|
87 |
+
content.update(response.html['content']);
|
88 |
+
}.bind(this),
|
89 |
+
onFailure: function(){
|
90 |
+
alert('Fail!');
|
91 |
+
}
|
92 |
+
}
|
93 |
+
);
|
94 |
+
}
|
95 |
+
},
|
96 |
+
updateStatus: function(){
|
97 |
+
var request = new Ajax.Request(
|
98 |
+
this.removeUrl,
|
99 |
+
{
|
100 |
+
method:'post',
|
101 |
+
parameters:'status='+$('insurance-status').checked,
|
102 |
+
onFailure: function(){
|
103 |
+
alert('Fail!');
|
104 |
+
}
|
105 |
+
}
|
106 |
+
);
|
107 |
+
},
|
108 |
+
validate: function() {
|
109 |
+
var methods = document.getElementsByName('shipping_method');
|
110 |
+
if (methods.length==0) {
|
111 |
+
alert(Translator.translate('Your order cannot be completed at this time as there is no shipping methods available for it. Please make necessary changes in your shipping address.').stripTags());
|
112 |
+
return false;
|
113 |
+
}
|
114 |
+
|
115 |
+
if(!this.validator.validate()) {
|
116 |
+
return false;
|
117 |
+
}
|
118 |
+
|
119 |
+
for (var i=0; i<methods.length; i++) {
|
120 |
+
if (methods[i].checked) {
|
121 |
+
return true;
|
122 |
+
}
|
123 |
+
}
|
124 |
+
alert(Translator.translate('Please specify shipping method.').stripTags());
|
125 |
+
return false;
|
126 |
+
},
|
127 |
+
processingStart: function(){
|
128 |
+
$('insurance-amount').update("<img src = '<?php echo $this->getSkinUrl('css/images/bx_loader.gif') ?>'/>");
|
129 |
+
}
|
130 |
+
}
|
131 |
+
var info_use_Popup = Class.create();
|
132 |
+
info_use_Popup.prototype = {
|
133 |
+
initialize: function() {
|
134 |
+
this.Popup = new Popupbox('info-use-popup', false, 'info-use', {
|
135 |
+
overlayColor: '#ffffff',
|
136 |
+
closeText: 'close',
|
137 |
+
overlayOpacity: 0.75,
|
138 |
+
overlayDuration: 0,
|
139 |
+
marginTop: '200',
|
140 |
+
width: '490px',
|
141 |
+
showShadow: false
|
142 |
+
});
|
143 |
+
},
|
144 |
+
showPopupBox: function(){
|
145 |
+
this.Popup.showPopup();
|
146 |
+
}
|
147 |
+
}
|
148 |
+
|
149 |
+
var info_rules_Popup = Class.create();
|
150 |
+
info_rules_Popup.prototype = {
|
151 |
+
initialize: function() {
|
152 |
+
this.Popup = new Popupbox('info-rules-popup', false, 'info-rules', {
|
153 |
+
overlayColor: '#ffffff',
|
154 |
+
closeText: 'close',
|
155 |
+
overlayOpacity: 0.75,
|
156 |
+
overlayDuration: 0,
|
157 |
+
marginTop: '200',
|
158 |
+
width: '673px',
|
159 |
+
showShadow: false
|
160 |
+
});
|
161 |
+
},
|
162 |
+
showPopupBox: function(){
|
163 |
+
this.Popup.showPopup();
|
164 |
+
}
|
165 |
+
}
|
166 |
+
var insurance,infoUsePopup,infoRulesPopup;
|
167 |
+
$(document).observe('dom:loaded', function() {
|
168 |
+
insurance = new Insurance('co-shipping-method-form', "<?php echo $this->getUrl('fee/index/updateAmount') ?>","<?php echo $this->getUrl('fee/index/updateStatus') ?>");
|
169 |
+
infoUsePopup = new info_use_Popup();
|
170 |
+
infoRulesPopup = new info_rules_Popup();
|
171 |
+
})
|
172 |
+
</script>
|
173 |
+
|
app/design/frontend/default/default/template/checkout/onepage/shipping_method/available.phtml
ADDED
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package base_default
|
23 |
+
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<?php /** @var $this Mage_Checkout_Block_Onepage_Shipping_Method_Available */ ?>
|
28 |
+
<?php $_shippingRateGroups = $this->getShippingRates(); ?>
|
29 |
+
<?php if (!$_shippingRateGroups): ?>
|
30 |
+
<p><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></p>
|
31 |
+
<?php else: ?>
|
32 |
+
<dl class="sp-methods">
|
33 |
+
<?php $shippingCodePrice = array(); ?>
|
34 |
+
<?php $_sole = count($_shippingRateGroups) == 1; foreach ($_shippingRateGroups as $code => $_rates): ?>
|
35 |
+
<dt><?php echo $this->escapeHtml($this->getCarrierName($code)) ?></dt>
|
36 |
+
<dd>
|
37 |
+
<ul>
|
38 |
+
<?php $_sole = $_sole && count($_rates) == 1; foreach ($_rates as $_rate): ?>
|
39 |
+
<?php $shippingCodePrice[] = "'".$_rate->getCode()."':".(float)$_rate->getPrice(); ?>
|
40 |
+
<li>
|
41 |
+
<?php if ($_rate->getErrorMessage()): ?>
|
42 |
+
<ul class="messages"><li class="error-msg"><ul><li><?php echo $this->escapeHtml($_rate->getErrorMessage()) ?></li></ul></li></ul>
|
43 |
+
<?php else: ?>
|
44 |
+
<?php if ($_sole) : ?>
|
45 |
+
<span class="no-display"><input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>" checked="checked" /></span>
|
46 |
+
<?php else: ?>
|
47 |
+
<input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$this->getAddressShippingMethod()) echo ' checked="checked"' ?> class="radio"/>
|
48 |
+
|
49 |
+
<?php if ($_rate->getCode() === $this->getAddressShippingMethod()): ?>
|
50 |
+
<script type="text/javascript">
|
51 |
+
//<![CDATA[
|
52 |
+
lastPrice = <?php echo (float)$_rate->getPrice(); ?>;
|
53 |
+
//]]>
|
54 |
+
</script>
|
55 |
+
<?php endif; ?>
|
56 |
+
|
57 |
+
<?php endif; ?>
|
58 |
+
<label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $this->escapeHtml($_rate->getMethodTitle()) ?>
|
59 |
+
<?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
|
60 |
+
<?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
|
61 |
+
<?php echo $_excl; ?>
|
62 |
+
<?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
|
63 |
+
(<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
|
64 |
+
<?php endif; ?>
|
65 |
+
</label>
|
66 |
+
<?php endif ?>
|
67 |
+
</li>
|
68 |
+
<?php endforeach; ?>
|
69 |
+
</ul>
|
70 |
+
</dd>
|
71 |
+
<?php endforeach; ?>
|
72 |
+
</dl>
|
73 |
+
<script type="text/javascript">
|
74 |
+
//<![CDATA[
|
75 |
+
<?php if (!empty($shippingCodePrice)): ?>
|
76 |
+
var shippingCodePrice = {<?php echo implode(',',$shippingCodePrice); ?>};
|
77 |
+
<?php endif; ?>
|
78 |
+
|
79 |
+
if ($('insurance-status')){
|
80 |
+
$('insurance-status').observe('click', function(){insurance.updateStatus();}.bind(this));
|
81 |
+
}
|
82 |
+
|
83 |
+
$$('input[type="radio"][name="shipping_method"]').each(function(el){
|
84 |
+
Event.observe(el, 'click', function(){
|
85 |
+
//@todo insurance.updateAmount()
|
86 |
+
insurance.updateAmount();
|
87 |
+
if (el.checked == true) {
|
88 |
+
var getShippingCode = el.getValue();
|
89 |
+
<?php if (!empty($shippingCodePrice)): ?>
|
90 |
+
var newPrice = shippingCodePrice[getShippingCode];
|
91 |
+
if (!lastPrice) {
|
92 |
+
lastPrice = newPrice;
|
93 |
+
quoteBaseGrandTotal += newPrice;
|
94 |
+
}
|
95 |
+
if (newPrice != lastPrice) {
|
96 |
+
quoteBaseGrandTotal += (newPrice-lastPrice);
|
97 |
+
lastPrice = newPrice;
|
98 |
+
}
|
99 |
+
<?php endif; ?>
|
100 |
+
checkQuoteBaseGrandTotal = quoteBaseGrandTotal;
|
101 |
+
return false;
|
102 |
+
}
|
103 |
+
});
|
104 |
+
});
|
105 |
+
//]]>
|
106 |
+
</script>
|
107 |
+
<?php endif; ?>
|
app/design/frontend/default/default/template/fee/fee.phtml
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if (Mage::registry('insurance_configuration')):?>
|
2 |
+
<br>
|
3 |
+
<br>
|
4 |
+
<h4><?php echo $this->__('We recomended U-PIC Parcel Insurance') ?></h4>
|
5 |
+
<?php if(Mage::registry('country_status')):?>
|
6 |
+
<div class="insurance">
|
7 |
+
<strong>100%</strong> protection against loss or damage for only
|
8 |
+
<span id="insurance-amount">
|
9 |
+
<?php
|
10 |
+
echo Mage::helper('core')->currency(QS_Fee_Model_Fee::getFee(), true, false);
|
11 |
+
?>
|
12 |
+
</span>
|
13 |
+
.
|
14 |
+
<a href="" onclick="infoUsePopup.showPopupBox();return false;">Why?</a>
|
15 |
+
</div>
|
16 |
+
<?php
|
17 |
+
if(!Mage::registry('insurance_as_default')):
|
18 |
+
?>
|
19 |
+
<div>
|
20 |
+
<div id="upic-logo"></div>
|
21 |
+
<input type="checkbox" id="insurance-status"/>
|
22 |
+
Yes, I'd like to purchase U-PIC Parcel Insurance and I agree with the
|
23 |
+
<a href="" onclick="infoRulesPopup.showPopupBox();return false;">Coverage Rules</a>
|
24 |
+
</div>
|
25 |
+
<? endif?>
|
26 |
+
<? else: ?>
|
27 |
+
Your country not avalable for insurance. Please choice another country, which not in unavalible list!
|
28 |
+
<? endif?>
|
29 |
+
<? endif?>
|
30 |
+
|
31 |
+
|
32 |
+
|
33 |
+
|
app/etc/modules/QS_Fee.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<QS_Fee>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</QS_Fee>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>QS_Fee</name>
|
4 |
+
<version>0.1.7</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>OSL</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Allows you to offer discounted parcel insurance to your customers </summary>
|
10 |
+
<description>Insure Happiness by U-PIC Insurance Services allows you to offer discounted parcel insurance to your customers at checkout through this app. Eliminate all of your customer's perceived risk since U-PIC guarantees: Delivery No pilferage No breakage Or your customer's money back. Why Package Insurance? Why is parcel insurance important to the e-commerce customer experience? We solve a problem that every e-tailer faces…..how to build customer confidence and security in the last stage of the transaction flow that the e-tailer has the least control over. Insurance builds trust. Trust builds loyalty, repeat business and less cart abandonment. All these make for a happy customer. Where do we fit? Quite simply, we Insure Happiness. Insure Happiness Adds to Your Profits There is no cost to you to Insure Happiness. You fill out a short application, we send you a rate unlock key and policy and you’re ready to go. You offer U-PIC discounted parcel insurance for purchase by your customer in the check- out cart. Our insurance protects against parcel loss, theft or damage, providing your customers the security they want. We guarantee the customer that the package will arrive, completely intact, or their money back. If you send out a replacement product, we reimburse you. Premiums are up to 85% less than rates charged by common carriers, delivering a small price for peace of mind. Not only are your customers happy as a result, but you are happy by earning a referral fee on every insurance transaction through your site. The U-PIC Advantage • Parcel insurance experts for 25 years • Premiums much less than carrier rates • Positioned to offer peace of mind and security as an impulse buy • Minimized risk reduces consumer’s insecurity while shopping • Offering package insurance builds customer trust, less cart abandonment and leads to repeat business • Reduces your clerical time, overhead, product and freight cost to process a claim, refund or replacement since YOU will be reimbursed by U-PIC • Can be positioned that retailer will not be responsible if an item is mishandled or lost by the carrier if insurance is not purchased. • Paperless claims processing by our licensed in-house adjusters • Claims resolved in 7-10 business days with full documentation • Underwritten by Navigators, an A.M. Best “A” rated insurance company • Ship through any carrier About U-PIC Insurance Founded in 1989, U-PIC has been a leader in providing low cost shipping insurance to both individuals and businesses. We are the provider of choice for shipping insurance for leading companies and their clients such as The U.S. Mint, DHL Global Mail and Endicia because of our low package insurance rates, superior technology and fast and easy claims processing. U-PIC Insurance is provided by an A.M. Best “A” rated carrier for your protection.</description>
|
11 |
+
<notes>Insure Happiness by U-PIC Insurance Services allows you to offer discounted parcel insurance to your customers at checkout through this app. Eliminate all of your customer's perceived risk since U-PIC guarantees: Delivery No pilferage No breakage Or your customer's money back.</notes>
|
12 |
+
<authors><author><name>Ecomitize</name><user>Milos</user><email>milosdodic90@gmail.com</email></author></authors>
|
13 |
+
<date>2014-11-14</date>
|
14 |
+
<time>10:24:30</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="QS"><dir name="Fee"><dir name="Block"><dir name="Adminhtml"><dir name="Report"><dir name="Simple"><file name="Grid.php" hash="6092fda13acf7a79fcd4c04860ffad91"/></dir><file name="Simple.php" hash="7d61d5aa80076077645da15d6d0e610b"/></dir><dir name="System"><dir name="Config"><dir name="Form"><file name="Activate.php" hash="b2b4cb2320a18f09b50d0586f1b8bbc5"/></dir></dir></dir><file name="Totals.php" hash="d9aee148047a6d8286206bfeab486e0a"/></dir><file name="Insurance.php" hash="51e9ebda434d1a8091ed43b2b54e4536"/><dir name="Sales"><dir name="Order"><file name="Total.php" hash="d50ff6f5f160337c9e2e64f39b4ae4c4"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="7cce6cdb7ae6a5eca23042a4f2c77613"/></dir><dir name="Model"><file name="Fee.php" hash="f428faf778ef75c7567500ba82110097"/><file name="Observer.php" hash="d9e218d87541f837a29c3448a7e7c89a"/><dir name="Resource"><dir name="Report"><dir name="Simple"><file name="Collection.php" hash="2770fb56a61f33dec8009733eeed6134"/></dir></dir><dir name="Tiers"><file name="Collection.php" hash="77933f00db91cbbfd0dfe8daaae436b0"/></dir><file name="Tiers.php" hash="b950ab196933ae5868f17de28bd01766"/></dir><dir name="Sales"><dir name="Order"><dir name="Total"><dir name="Creditmemo"><file name="Fee.php" hash="8c2efc934c714b3f3ee9cd31ba50b281"/></dir><dir name="Invoice"><file name="Fee.php" hash="599513870cba5f39dafd996ec0903be0"/></dir></dir></dir><dir name="Quote"><dir name="Address"><dir name="Total"><file name="Fee.php" hash="b8954fd293fda123788fb88df3168173"/></dir></dir></dir></dir><file name="Simple.php" hash="9a72683e47296273e500148413c9c687"/><file name="Tiers.php" hash="081f0a73c3e4b9ae09aa5e84744baaf4"/><dir name="Validation"><file name="Code.php" hash="80a916bfd4cbb99feead91655ccdbb84"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="FeeController.php" hash="2082241655738ae4810b71b7fe1d12a1"/><file name="IndexController.php" hash="c02528f70d00c22415f65747aac710d5"/><dir name="Report"><file name="FeeController.php" hash="8c4a33bdc284325f57d5e480e9c47474"/></dir></dir><file name="IndexController.php" hash="c2718531d5b02b228cdb2e13fc05c4ea"/></dir><dir name="etc"><file name="adminhtml.xml" hash="f33457d9b44e84412090fab9981c318b"/><file name="config.xml" hash="7cbf26de64d579fa4fe7702ec21f77dd"/><file name="system.xml" hash="7b618962daeafa15e2424fc906574625"/></dir><dir name="sql"><dir name="fee_setup"><file name="mysql4-install-0.1.0.php" hash="06c93eb69d7a5dbc69c0ad47ae0f4c13"/><file name="mysql4-upgrade-0.1.0-0.1.1.php" hash="ae56cbbeebafaa59a1b561ec3966d825"/><file name="mysql4-upgrade-0.1.1-0.1.2.php" hash="ec92bc06a2ea6434d450e54d417f7cca"/><file name="mysql4-upgrade-0.1.2-0.1.3.php" hash="7e301fe20f4521af1b588457c61177d0"/><file name="mysql4-upgrade-0.1.3-0.1.4.php" hash="4a69f3e7b5650d1aab6e5d38a361fdd5"/><file name="mysql4-upgrade-0.1.4-0.1.5.php" hash="af1fd50c9aa3a422e791d21efa429470"/><file name="mysql4-upgrade-0.1.5-0.1.6.php" hash="fb0cc64b39e5b61c75c43be7d66b4906"/><file name="mysql4-upgrade-0.1.6-0.1.7.php" hash="4f95ecf3f511a9ca355a3fd3bf6aa101"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="fee.xml" hash="24d95cb1f0637925137426f1c70f24d3"/></dir><dir name="template"><dir name="fee"><dir name="sales"><dir name="order"><file name="refunded.phtml" hash="552454be03691f9ce8a8ac63ddae5e7b"/><file name="total.phtml" hash="7aba824040b2faf54c8df069909ed515"/></dir></dir><dir name="system"><dir name="config"><file name="activate_link.phtml" hash="c11dafb51d03ced2177cb6732560facc"/></dir></dir><file name="totals.phtml" hash="eb81b5ec3881badd713e375a35696dbf"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="fee.xml" hash="3fc9eea0354ee08f55a8eba04a4a1bb6"/></dir><dir name="template"><dir name="checkout"><dir name="onepage"><file name="shipping_method.phtml" hash="c65fad24e7636e072006c0bf558abe39"/><dir name="shipping_method"><file name="available.phtml" hash="cdaeb39660b06d96a510ddad49930fcb"/></dir></dir></dir><dir name="fee"><file name="fee.phtml" hash="337535920fc1e022d655e69475e125b3"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="QS_Fee.xml" hash="df554dbd31a11e8f87d2bf8c890a89e7"/></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.2.0</min><max>5.6.0</max></php></required></dependencies>
|
18 |
+
</package>
|