Eadesigndev_Urgent - Version 1.0.1

Version Notes

The first stable version.

Download this release

Release Info

Developer EaDesign
Extension Eadesigndev_Urgent
Version 1.0.1
Comparing to
See all releases


Version 1.0.1

app/code/local/Eadesigndev/Urgent/Block/Adminhtml/Block/System/Update.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Eadesigndev_Urgent_Block_Adminhtml_Block_System_Update extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
6
+ {
7
+ $this->setElement($element);
8
+ $url = Mage::helper('adminhtml')->getUrl('urgentadmin/adminhtml_index/update');
9
+
10
+ $html = $this->getLayout()->createBlock('adminhtml/widget_button')
11
+ ->setType('button')
12
+ ->setClass('scalable')
13
+ ->setLabel('Update lista orase!')
14
+ ->setOnClick("setLocation('$url')")
15
+ ->toHtml();
16
+
17
+ return $html;
18
+ }
19
+ }
app/code/local/Eadesigndev/Urgent/Helper/Data.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Eadesigndev_Urgent_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+ public function isLei($object)
6
+ {
7
+
8
+ $code = $object->getData('currency_code');
9
+ $baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
10
+
11
+ if ($baseCurrencyCode == 'RON') {
12
+ return 1;
13
+ }
14
+
15
+ if ($code == 'RON') {
16
+ $allowedCurrencies = Mage::getModel('directory/currency')->getConfigAllowCurrencies();
17
+ $rates = Mage::getModel('directory/currency')->getCurrencyRates($baseCurrencyCode, array_values($allowedCurrencies));
18
+
19
+ return $rates['RON'];
20
+ }
21
+
22
+ return false;
23
+ }
24
+
25
+ public function getRegionIdByCode($regionCode, $countryCode)
26
+ {
27
+ $regionModel = Mage::getModel('directory/region')->loadByCode($regionCode, $countryCode);
28
+ $regionId = $regionModel->getId();
29
+
30
+ return $regionId;
31
+ }
32
+
33
+ public function getCities($countryId, $regionId)
34
+ {
35
+ $cityCollection = Mage::getModel('urgent/urgent')->getCollection();
36
+ $cityCollection->addFieldToSelect('cityname')
37
+ ->addFieldToFilter('country_id', $countryId)
38
+ ->addFieldToFilter('region_id', $regionId);
39
+
40
+ $count = $count($cityCollection->getData());
41
+
42
+ if($count < 2){
43
+ return false;
44
+ }
45
+
46
+ foreach ($cityCollection as $citiesData) {
47
+ $cites[] = $citiesData->getData('cityname');
48
+ }
49
+
50
+ return $cites;
51
+ }
52
+
53
+ public function getFromCity()
54
+ {
55
+ return Mage::getStoreConfig('carriers/eadesignurgent/punctridicare');
56
+ }
57
+
58
+ public function getParcelsEnvelopes()
59
+ {
60
+ return Mage::getStoreConfig('carriers/eadesignurgent/pachet');
61
+ }
62
+
63
+ public function getPlanTarifar()
64
+ {
65
+ return Mage::getStoreConfig('carriers/eadesignurgent/plantarifar');
66
+ }
67
+
68
+ public function getDeschide()
69
+ {
70
+ if (Mage::getStoreConfig('carriers/eadesignurgent/deschide')) {
71
+ return true;
72
+ }
73
+ return false;
74
+ }
75
+
76
+ public function getAsigurare()
77
+ {
78
+ return Mage::getStoreConfig('carriers/eadesignurgent/asigurare');
79
+ }
80
+
81
+ public function getAfisare()
82
+ {
83
+ return Mage::getStoreConfig('carriers/eadesignurgent/afisare');
84
+ }
85
+
86
+ public function getTitle()
87
+ {
88
+ return Mage::getStoreConfig('carriers/eadesignurgent/title');
89
+ }
90
+
91
+ public function getName()
92
+ {
93
+ return Mage::getStoreConfig('carriers/eadesignurgent/name');
94
+ }
95
+
96
+ public function getClosest($input, $words)
97
+ {
98
+
99
+ $shortest = -1;
100
+
101
+ foreach ($words as $word) {
102
+
103
+ $lev = levenshtein($input, $word);
104
+
105
+ if ($lev == 0) {
106
+
107
+ $closest = $word;
108
+ $shortest = 0;
109
+
110
+ break;
111
+ }
112
+
113
+ if ($lev <= $shortest || $shortest < 0) {
114
+ $closest = $word;
115
+ $shortest = $lev;
116
+ }
117
+ }
118
+ return $closest;
119
+ }
120
+
121
+ }
app/code/local/Eadesigndev/Urgent/Helper/Update.php ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Eadesigndev_Urgent_Helper_Update extends Mage_Core_Helper_Abstract
3
+ {
4
+ public function getDataCity()
5
+ {
6
+ $token = Mage::helper('urgent/urgent')->getToken(true);
7
+
8
+ $fields = array(
9
+ 'Token' => $token,
10
+ 'CountyId' => null,
11
+ 'CountyName' => '',
12
+ 'CountryId' => null,
13
+ 'CountryName' => 'Romania'
14
+ );
15
+
16
+ $localities = Mage::helper('urgent/urgent')->getUrgent('GetLocalities', $fields);
17
+
18
+ return $localities;
19
+ }
20
+
21
+ public function getDataCounty()
22
+ {
23
+ $token = Mage::helper('urgent/urgent')->getToken(true);
24
+
25
+ $fields = array(
26
+ 'Token' => $token,
27
+ 'CountryId' => null,
28
+ 'CountryName' => 'Romania'
29
+ );
30
+
31
+ return Mage::helper('urgent/urgent')->getUrgent('GetCounties', $fields);
32
+ }
33
+
34
+
35
+ public function getCity()
36
+ {
37
+ $cities = $this->getDataCity();
38
+
39
+ return $cities;
40
+ }
41
+
42
+ public function getCounty()
43
+ {
44
+ $counties = $this->getDataCounty();
45
+
46
+ return $counties;
47
+ }
48
+
49
+ public function processData()
50
+ {
51
+ $collection = Mage::getModel('directory/region')->getResourceCollection()
52
+ ->addCountryFilter('RO')
53
+ ->load();
54
+
55
+ $regionNew = array();
56
+ foreach ($collection as $region) {
57
+ $regionNew[$region->getData('code')] = $region->getData('region_id');
58
+ }
59
+
60
+ $orase = $this->getCity();
61
+ $judete = $this->getCounty();
62
+
63
+ $listaJudeteNoua = array();
64
+
65
+ foreach ($judete as $judet) {
66
+ $listaJudeteNoua[$judet->CountyId] = $judet->Abbreviation;
67
+ }
68
+
69
+ $listaOraseNoua = array();
70
+
71
+ foreach ($orase as $oras) {
72
+ $judetNumeric = $oras->CountyId;
73
+ $judetCod = $listaJudeteNoua[$judetNumeric];
74
+ $judetId = $regionNew[$judetCod];
75
+
76
+ $listaOraseNoua[] = array(
77
+ 'RO',
78
+ $oras->Name,
79
+ $judetId
80
+ );
81
+ }
82
+
83
+ return $listaOraseNoua;
84
+
85
+ }
86
+
87
+ public function getUrgentCollection()
88
+ {
89
+ $collection = Mage::getModel('urgent/urgent')->getResourceCollection()
90
+ ->load();
91
+
92
+ foreach ($collection as $individualObject) {
93
+ $individualObject->delete();
94
+ }
95
+
96
+ foreach ($this->processData() as $oras) {
97
+ $individualOras = Mage::getModel('urgent/urgent');
98
+ $individualOras->setData('country_id', $oras[0]);
99
+ $individualOras->setData('region_id', $oras[2]);
100
+ $individualOras->setData('cityname', $oras[1]);
101
+ try {
102
+ $individualOras->save();
103
+ } catch (Exception $e) {
104
+ $messege = $e->getMessege();
105
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('urgent')->__('A avut loc o eroare ' . $messege));
106
+ }
107
+ }
108
+
109
+ $individualuc = Mage::getModel('urgent/urgent')
110
+ ->setData('country_id', 'RO')
111
+ ->setData('region_id', '287')
112
+ ->setData('cityname', 'Bucuresti');
113
+
114
+ try {
115
+ $individualuc->save();
116
+ } catch (Exception $e) {
117
+ $messege1 = $e->getMessege();
118
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('urgent')->__('A avut loc o eroare ' . $messege1));
119
+ }
120
+
121
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('urgent')->__('A fost facut update-ul'));
122
+ }
123
+ }
app/code/local/Eadesigndev/Urgent/Helper/Urgent.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Eadesigndev_Urgent_Helper_Urgent extends Mage_Core_Helper_Abstract
3
+ {
4
+ private $ServiceUrl;
5
+ private $Curl;
6
+
7
+ public function __construct()
8
+ {
9
+ $this->ServiceUrl = 'http://urgentcargus.cloudapp.net/IntegrationService.asmx';
10
+ $this->Curl = curl_init();
11
+ curl_setopt($this->Curl, CURLOPT_CUSTOMREQUEST, 'POST');
12
+ curl_setopt($this->Curl, CURLOPT_RETURNTRANSFER, true);
13
+ }
14
+
15
+ private function getUrgentData($MethodName, $Parameters = null)
16
+ {
17
+ if ($Parameters != null) {
18
+ $Parameters = json_encode($Parameters);
19
+ curl_setopt($this->Curl, CURLOPT_POSTFIELDS, $Parameters);
20
+ }
21
+ curl_setopt($this->Curl, CURLOPT_URL, $this->ServiceUrl . '/' . $MethodName);
22
+ curl_setopt($this->Curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($Parameters)));
23
+ $data = json_decode(curl_exec($this->Curl));
24
+ if (isset($data->d)) {
25
+ if (strstr($MethodName, 'Print')) {
26
+ return implode(array_map('chr', $data->d));
27
+ } else {
28
+ return $data->d;
29
+ }
30
+ } else {
31
+ return array('error' => isset($data->Message) ? $data->Message : 'unknown');
32
+ }
33
+ }
34
+
35
+ public function getToken($simple = false)
36
+ {
37
+ $credentials = array(
38
+ 'Username' => Mage::getStoreConfig('carriers/eadesignurgent/username'),
39
+ 'Password' => Mage::getStoreConfig('carriers/eadesignurgent/password')
40
+ );
41
+
42
+ $token = $this->getUrgentData('LoginUser', $credentials);
43
+
44
+ //exit(print_r($credentials));
45
+
46
+ if (is_array($token)) {
47
+ if (isset($token['error'])) {
48
+ Mage::getSingleton('core/session')->addError($token['error']);
49
+ return;
50
+ }
51
+ }
52
+
53
+ if ($simple) {
54
+ $fields = $token;
55
+ } else {
56
+ $fields = array(
57
+ 'Token' => $token
58
+ );
59
+ }
60
+
61
+ return $fields;
62
+
63
+ }
64
+
65
+ public function getPunctRidicare()
66
+ {
67
+ if ($this->getToken()) {
68
+ return $this->getUrgentData('GetPickupLocations', $this->getToken());
69
+ }
70
+ return false;
71
+ }
72
+
73
+ public function getPunctToOptonArray()
74
+ {
75
+ if ($this->getToken()) {
76
+ return $this->toOptionArray($this->getPunctRidicare(), 'LocationId', 'Name');
77
+ }
78
+ return false;
79
+ }
80
+
81
+ public function toOptionArray($array, $key, $value)
82
+ {
83
+ $return = array();
84
+
85
+ if($array['error']){
86
+ return $return;
87
+ }
88
+
89
+ foreach ($array as $element) {
90
+ $return[$element->$key] = $element->$value;
91
+ }
92
+ return $return;
93
+ }
94
+
95
+ public function getPricePlans()
96
+ {
97
+ $planTarifar = $this->getUrgentData('GetPriceTables', $this->getToken());
98
+ return $this->toOptionArray($planTarifar, 'PriceTableId', 'Name');
99
+ }
100
+
101
+ public function getUrgent($method, $params = null)
102
+ {
103
+ return $this->getUrgentData($method,$params);
104
+ }
105
+ }
app/code/local/Eadesigndev/Urgent/Model/Carrier/Urgent.php ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Eadesigndev_Urgent_Model_Carrier_Urgent extends Mage_Shipping_Model_Carrier_Abstract implements Mage_Shipping_Model_Carrier_Interface
4
+ {
5
+ protected $_code = 'urgentcurrier';
6
+
7
+ public function isTrackingAvailable()
8
+ {
9
+ return true;
10
+ }
11
+
12
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request)
13
+ {
14
+
15
+
16
+ if (!Mage::getStoreConfig('carriers/' . $this->_code . '/active')) {
17
+ return false;
18
+ }
19
+
20
+ $lei = Mage::helper('urgent')->isLei($request->getData('package_currency'));
21
+
22
+ if (!$lei) {
23
+ return false;
24
+ }
25
+
26
+ $helper = Mage::helper('urgent');
27
+
28
+ if ($request->getAllItems()) {
29
+ foreach ($request->getAllItems() as $item) {
30
+ if ($item->getParentItem()) {
31
+ continue;
32
+ }
33
+ if ($item->getHasChildren() && $item->isShipSeparately()) {
34
+ foreach ($item->getChildren() as $child) {
35
+ if ($child->getProduct()->isVirtual()) {
36
+ $request->setPackageValue($request->getPackageValue() - $child->getBaseRowTotal());
37
+ }
38
+ }
39
+ } elseif ($item->getProduct()->isVirtual()) {
40
+ $request->setPackageValue($request->getPackageValue() - $item->getBaseRowTotal());
41
+ }
42
+ }
43
+ }
44
+
45
+ $valuare = $request->getPackageValue() * $lei;
46
+
47
+ if ($helper->getAfisare() == 2) {
48
+
49
+ $methodUrgent = $this->_calculateTotal($request, $valuare, true);
50
+ $result = Mage::getModel('shipping/rate_result');
51
+ $result->append($methodUrgent);
52
+
53
+ return $result;
54
+
55
+ } else {
56
+
57
+ $methodUrgent = $this->_calculateTotal($request, $valuare, false);
58
+ $result = Mage::getModel('shipping/rate_result');
59
+ $result->append($methodUrgent);
60
+
61
+ return $result;
62
+ }
63
+
64
+ }
65
+
66
+ private function _calculateTotal($request, $valuare, $afisare)
67
+ {
68
+
69
+ $helper = Mage::helper('urgent');
70
+
71
+ $regionid = $helper->getRegionIdByCode($request->getDestRegionCode(), 'RO');
72
+
73
+ $list = $helper->getCities('RO', $regionid);
74
+
75
+ $city = $request->getDestCity();
76
+ $match = $helper->getClosest($city, $list);
77
+
78
+ if (!$list) {
79
+ $match = $city;
80
+ }
81
+
82
+ $lei = Mage::helper('urgent')->isLei($request->getData('package_currency'));
83
+
84
+ $declaredValue = 0;
85
+ if ($helper->getAsigurare()) {
86
+ $declaredValue = $valuare;
87
+ }
88
+
89
+ $cashRepayment = $valuare;
90
+ $bankRepayment = 0;
91
+
92
+ if ($afisare) {
93
+ $cashRepayment = 0;
94
+ $bankRepayment = $valuare;
95
+ }
96
+
97
+ $parcel = 0;
98
+ $envelopes = 1;
99
+ if ($helper->getParcelsEnvelopes()) {
100
+ $parcel = 1;
101
+ $envelopes = 0;
102
+ }
103
+
104
+ $fields = array(
105
+ 'Token' => Mage::helper('urgent/urgent')->getToken(true),
106
+ 'FromLocalityId' => $helper->getFromCity(),
107
+ 'FromCountyName' => '',
108
+ 'FromLocalityName' => '',
109
+ 'ToLocalityId' => null,
110
+ 'ToCountyName' => $request->getDestRegionCode(),
111
+ 'ToLocalityName' => $match,
112
+ 'Parcels' => $parcel,
113
+ 'Envelopes' => $envelopes,
114
+ 'TotalWeight' => round($request->getPackageWeight()),
115
+ 'DeclaredValue' => $declaredValue,
116
+ 'CashRepayment' => $cashRepayment,
117
+ 'BankRepayment' => $bankRepayment,
118
+ 'OtherRepayment' => '',
119
+ 'OpenPackage' => ($helper->getDeschide()),
120
+ 'PriceTableId' => $helper->getPlanTarifar()
121
+ );
122
+
123
+ $calculate = Mage::helper('urgent/urgent')->getUrgent('CalculateShipping', $fields);
124
+
125
+ if (is_array($calculate)) {
126
+ if (isset($calculate['error'])) {
127
+ return false;
128
+ }
129
+ }
130
+
131
+ $total = round(($calculate->GrandTotal / $lei), 2);
132
+
133
+ $methodUrgent = Mage::getModel('shipping/rate_result_method');
134
+ $methodUrgent->setCarrier($this->_code);
135
+ $methodUrgent->setCarrierTitle($helper->getTitle());
136
+ $methodUrgent->setMethod('urgent');
137
+ $methodUrgent->setMethodTitle($helper->getName());
138
+
139
+ $methodUrgent->setPrice($total);
140
+ $methodUrgent->setCost($total);
141
+ // echo '<pre>';
142
+ // print_r($methodUrgent);
143
+ // exit();
144
+ return $methodUrgent;
145
+ }
146
+
147
+ public function getAllowedMethods()
148
+ {
149
+
150
+ }
151
+ }
app/code/local/Eadesigndev/Urgent/Model/Mysql4/Urgent.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * To change this template, choose Tools | Templates
5
+ * and open the template in the editor.
6
+ */
7
+
8
+ /**
9
+ * Description of PdfGenerator
10
+ *
11
+ * @author Ea Design
12
+ *
13
+ *
14
+ */
15
+ class Eadesigndev_Urgent_Model_Mysql4_Urgent extends Mage_Core_Model_Mysql4_Abstract
16
+ {
17
+ /**
18
+ * Intitialize the collection
19
+ */
20
+ public function _construct()
21
+ {
22
+ $this->_init('urgent/urgent', 'city_id');
23
+ }
24
+ }
app/code/local/Eadesigndev/Urgent/Model/Mysql4/Urgent/Collection.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * To change this template, choose Tools | Templates
5
+ * and open the template in the editor.
6
+ */
7
+
8
+ /**
9
+ * Description of Collection
10
+ *
11
+ * @author Ea Design
12
+ */
13
+ class Eadesigndev_Urgent_Model_Mysql4_Urgent_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
14
+ {
15
+ /**
16
+ * Retrive the product collection.
17
+ */
18
+ public function _construct()
19
+ {
20
+ $this->_init('urgent/urgent');
21
+ }
22
+ }
app/code/local/Eadesigndev/Urgent/Model/System/Abstract.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Eadesigndev_Urgent_Model_System_Abstract
4
+ {
5
+ public $helper;
6
+
7
+ public function __construct()
8
+ {
9
+ $this->helper = Mage::helper('urgent/urgent');
10
+ }
11
+
12
+ public function getHelper()
13
+ {
14
+ return $this->helper;
15
+ }
16
+
17
+ public function getError(){
18
+ return array(
19
+ array('value' => '', 'label' => Mage::helper('urgent')->__('Trebuie sa ai un user si parola valide'))
20
+ );
21
+ }
22
+
23
+ }
app/code/local/Eadesigndev/Urgent/Model/System/Pachet.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Eadesigndev_Urgent_Model_System_Pachet extends Eadesigndev_Urgent_Model_System_Abstract
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ return array(
8
+ array('value' => '0', 'label' => Mage::helper('urgent')->__('Colet')),
9
+ array('value' => '1', 'label' => Mage::helper('urgent')->__('Plic')),
10
+ );
11
+ }
12
+ }
app/code/local/Eadesigndev/Urgent/Model/System/Plantarifar.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Eadesigndev_Urgent_Model_System_Plantarifar extends Eadesigndev_Urgent_Model_System_Abstract
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ $helper = $this->getHelper();
8
+ $plans = $helper->getPricePlans();
9
+
10
+ if(empty($plans)){
11
+ return $this->getError();
12
+ }
13
+
14
+ return $plans;
15
+ }
16
+ }
app/code/local/Eadesigndev/Urgent/Model/System/Punctridicare.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Eadesigndev_Urgent_Model_System_Punctridicare extends Eadesigndev_Urgent_Model_System_Abstract
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ $helper = $this->getHelper();
8
+ $punct = $helper->getPunctToOptonArray();
9
+
10
+ if(empty($punct)){
11
+ return $this->getError();
12
+ }
13
+
14
+ return $punct;
15
+ }
16
+ }
app/code/local/Eadesigndev/Urgent/Model/System/Tarifeafisate.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Eadesigndev_Urgent_Model_System_Tarifeafisate extends Eadesigndev_Urgent_Model_System_Abstract
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ return array(
8
+ array('value' => '', 'label' => Mage::helper('urgent')->__('Select')),
9
+ array('value' => '1', 'label' => Mage::helper('urgent')->__('Ramburs')),
10
+ array('value' => '2', 'label' => Mage::helper('urgent')->__('Cont colector')),
11
+ );
12
+ }
13
+ }
app/code/local/Eadesigndev/Urgent/Model/Urgent.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Description of PdfGenerator
5
+ *
6
+ * @author Ea Design
7
+ */
8
+ class Eadesigndev_Urgent_Model_Urgent extends Mage_Core_Model_Abstract
9
+ {
10
+
11
+ public function _construct()
12
+ {
13
+ $this->_init('urgent/urgent');
14
+ }
15
+ }
app/code/local/Eadesigndev/Urgent/controllers/Adminhtml/IndexController.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * @author Ea Design
6
+ */
7
+ class Eadesigndev_Urgent_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action
8
+ {
9
+ public function updateAction()
10
+ {
11
+ Mage::helper('urgent/update')->getUrgentCollection();
12
+ $this->_redirectReferer();
13
+ }
14
+ }
app/code/local/Eadesigndev/Urgent/etc/config.xml ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Eadesigndev_Urgent>
5
+ <version>1.0.1</version>
6
+ </Eadesigndev_Urgent>
7
+ </modules>
8
+ <global>
9
+ <blocks>
10
+ <urgent>
11
+ <class>Eadesigndev_Urgent_Block</class>
12
+ </urgent>
13
+ </blocks>
14
+ <models>
15
+ <urgent>
16
+ <class>Eadesigndev_Urgent_Model</class>
17
+ <resourceModel>urgent_mysql4</resourceModel>
18
+ </urgent>
19
+ <urgent_mysql4>
20
+ <class>Eadesigndev_Urgent_Model_Mysql4</class>
21
+ <entities>
22
+ <urgent>
23
+ <table>directory_country_region_city</table>
24
+ </urgent>
25
+ </entities>
26
+ </urgent_mysql4>
27
+ </models>
28
+ <resources>
29
+ <eadsign_urgent_setup>
30
+ <setup>
31
+ <module>Eadesigndev_Urgent</module>
32
+ <class>Mage_Customer_Model_Entity_Setup</class>
33
+ </setup>
34
+ </eadsign_urgent_setup>
35
+ <urgent_write>
36
+ <connection>
37
+ <use>core_write</use>
38
+ </connection>
39
+ </urgent_write>
40
+ <urgent_read>
41
+ <connection>
42
+ <use>core_read</use>
43
+ </connection>
44
+ </urgent_read>
45
+ </resources>
46
+ <helpers>
47
+ <urgent>
48
+ <class>Eadesigndev_Urgent_Helper</class>
49
+ </urgent>
50
+ </helpers>
51
+ </global>
52
+ <default>
53
+ <carriers>
54
+ <urgentcurrier>
55
+ <title>Urgent courier</title>
56
+ <showmethod>1</showmethod>
57
+ <active>1</active>
58
+ <model>urgent/carrier_urgent</model>
59
+ </urgentcurrier>
60
+ </carriers>
61
+ </default>
62
+ <admin>
63
+ <routers>
64
+ <urgentadmin>
65
+ <use>admin</use>
66
+ <args>
67
+ <module>Eadesigndev_Urgent</module>
68
+ <frontName>urgentadmin</frontName>
69
+ </args>
70
+ </urgentadmin>
71
+ </routers>
72
+ </admin>
73
+ </config>
app/code/local/Eadesigndev/Urgent/etc/system.xml ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <sections>
4
+ <carriers>
5
+ <groups>
6
+ <eadesignurgent tranlate="label" module="urgent">
7
+ <label>Eadesign Urgent Courier</label>
8
+ <frontend_type>text</frontend_type>
9
+ <sort_order>1</sort_order>
10
+ <show_in_default>1</show_in_default>
11
+ <show_in_website>1</show_in_website>
12
+ <show_in_store>1</show_in_store>
13
+ <fields>
14
+ <active translate="label">
15
+ <label>Activat</label>
16
+ <frontend_type>select</frontend_type>
17
+ <source_model>adminhtml/system_config_source_yesno</source_model>
18
+ <sort_order>1</sort_order>
19
+ <show_in_default>1</show_in_default>
20
+ <show_in_website>1</show_in_website>
21
+ <show_in_store>0</show_in_store>
22
+ </active>
23
+ <username translate="label">
24
+ <label>Cont utilizator</label>
25
+ <frontend_type>text</frontend_type>
26
+ <sort_order>2</sort_order>
27
+ <show_in_default>1</show_in_default>
28
+ <show_in_website>1</show_in_website>
29
+ <show_in_store>1</show_in_store>
30
+ </username>
31
+ <password translate="label">
32
+ <label>Parola</label>
33
+ <frontend_type>password</frontend_type>
34
+ <sort_order>3</sort_order>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>1</show_in_website>
37
+ <show_in_store>1</show_in_store>
38
+ </password>
39
+ <name translate="label">
40
+ <label>Nume</label>
41
+ <frontend_type>text</frontend_type>
42
+ <sort_order>4</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
+ </name>
47
+ <title translate="label">
48
+ <label>Titlul</label>
49
+ <frontend_type>text</frontend_type>
50
+ <sort_order>4</sort_order>
51
+ <show_in_default>1</show_in_default>
52
+ <show_in_website>1</show_in_website>
53
+ <show_in_store>1</show_in_store>
54
+ </title>
55
+ <error translate="label">
56
+ <label>Mesaj eroare</label>
57
+ <frontend_type>textarea</frontend_type>
58
+ <sort_order>4</sort_order>
59
+ <show_in_default>1</show_in_default>
60
+ <show_in_website>1</show_in_website>
61
+ <show_in_store>1</show_in_store>
62
+ </error>
63
+ <sort_order translate="label">
64
+ <label>Sort order</label>
65
+ <frontend_type>text</frontend_type>
66
+ <sort_order>4</sort_order>
67
+ <show_in_default>1</show_in_default>
68
+ <show_in_website>1</show_in_website>
69
+ <show_in_store>1</show_in_store>
70
+ </sort_order>
71
+ <plantarifar translate="label" module="core">
72
+ <label>Plan tarifar</label>
73
+ <frontend_type>select</frontend_type>
74
+ <source_model>urgent/system_plantarifar</source_model>
75
+ <sort_order>4</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
+ </plantarifar>
80
+ <punctridicare translate="label" module="core">
81
+ <label>Punct ridicare</label>
82
+ <frontend_type>select</frontend_type>
83
+ <source_model>urgent/system_punctridicare</source_model>
84
+ <sort_order>5</sort_order>
85
+ <show_in_default>1</show_in_default>
86
+ <show_in_website>1</show_in_website>
87
+ <show_in_store>1</show_in_store>
88
+ </punctridicare>
89
+ <afisare translate="label" module="core">
90
+ <label>Afisare metode</label>
91
+ <frontend_type>select</frontend_type>
92
+ <source_model>urgent/system_tarifeafisate</source_model>
93
+ <sort_order>5</sort_order>
94
+ <show_in_default>1</show_in_default>
95
+ <show_in_website>1</show_in_website>
96
+ <show_in_store>1</show_in_store>
97
+ <validate>required-entry</validate>
98
+ </afisare>
99
+ <dechide translate="label">
100
+ <label>Deschidere colet</label>
101
+ <frontend_type>select</frontend_type>
102
+ <source_model>adminhtml/system_config_source_yesno</source_model>
103
+ <sort_order>6</sort_order>
104
+ <show_in_default>1</show_in_default>
105
+ <show_in_website>1</show_in_website>
106
+ <show_in_store>0</show_in_store>
107
+ </dechide>
108
+ <asigurare translate="label">
109
+ <label>Asigurare</label>
110
+ <frontend_type>select</frontend_type>
111
+ <source_model>adminhtml/system_config_source_yesno</source_model>
112
+ <sort_order>7</sort_order>
113
+ <show_in_default>1</show_in_default>
114
+ <show_in_website>1</show_in_website>
115
+ <show_in_store>0</show_in_store>
116
+ </asigurare>
117
+ <sambata translate="label">
118
+ <label>Livrare sambata</label>
119
+ <frontend_type>select</frontend_type>
120
+ <source_model>adminhtml/system_config_source_yesno</source_model>
121
+ <sort_order>8</sort_order>
122
+ <show_in_default>1</show_in_default>
123
+ <show_in_website>1</show_in_website>
124
+ <show_in_store>0</show_in_store>
125
+ </sambata>
126
+ <pachet translate="label" module="core">
127
+ <label>Afisare metode</label>
128
+ <frontend_type>select</frontend_type>
129
+ <source_model>urgent/system_pachet</source_model>
130
+ <sort_order>9</sort_order>
131
+ <show_in_default>1</show_in_default>
132
+ <show_in_website>1</show_in_website>
133
+ <show_in_store>1</show_in_store>
134
+ <validate>required-entry</validate>
135
+ </pachet>
136
+ <update translate="label" module="core">
137
+ <label>Update Orase</label>
138
+ <frontend_type>button</frontend_type>
139
+ <frontend_model>urgent/adminhtml_block_system_update</frontend_model>
140
+ <sort_order>10</sort_order>
141
+ <show_in_default>1</show_in_default>
142
+ <show_in_website>1</show_in_website>
143
+ <show_in_store>1</show_in_store>
144
+ <validate>required-entry</validate>
145
+ </update>
146
+ </fields>
147
+ </eadesignurgent>
148
+ </groups>
149
+ </carriers>
150
+ </sections>
151
+ </config>
app/code/local/Eadesigndev/Urgent/sql/eadsign_urgent_setup/mysql4-install-1.0.1.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * To change this template, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+
7
+ /**
8
+ * Description of mysql4-install-1
9
+ *
10
+ * @author Ea Design
11
+ */
12
+ $installer = $this;
13
+
14
+ $installer->startSetup();
15
+
16
+ $installer->run("
17
+ CREATE TABLE IF NOT EXISTS {$this->getTable('urgent/urgent')} (
18
+ `city_id` mediumint(8) unsigned NOT NULL auto_increment,
19
+ `country_id` varchar(4) NOT NULL default '0',
20
+ `region_id` varchar(4) NOT NULL default '0',
21
+ `cityname` varchar(255) default NULL,
22
+ PRIMARY KEY (`city_id`),
23
+ KEY `FK_CITY_REGION` (`region_id`))
24
+ ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Region Cities';
25
+ ");
26
+
27
+ $installer->endSetup();
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Eadesigndev_Urgent</name>
4
+ <version>1.0.1</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">Extension license name (OSL v3.0)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>This extension integrates Magento with Urgent-Cargus Courier Romania.</summary>
10
+ <description>The extension uses the url from Urgent-Cargus Courier Romania to get the estimated cost in Magetno for the regions and cities from Romania.</description>
11
+ <notes>The first stable version.</notes>
12
+ <authors><author><name>EaDesign</name><user>eadesign</user><email>office@eadesign.ro</email></author></authors>
13
+ <date>2015-09-11</date>
14
+ <time>10:27:53</time>
15
+ <contents><target name="magelocal"><dir name="Eadesigndev"><dir name="Urgent"><dir name="Block"><dir name="Adminhtml"><dir name="Block"><dir name="System"><file name="Update.php" hash="69066f7fb83dca619580c7ba774c36ad"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="d625f291dbd7a6ae1ba854d7865aba7e"/><file name="Update.php" hash="405bd6a31e96aeb8509060df8a56dfc4"/><file name="Urgent.php" hash="11b1c466c9de87f716b5caebb4928d5d"/></dir><dir name="Model"><dir name="Carrier"><file name="Urgent.php" hash="36102a10365e5d9ea97786a6486ea5b3"/></dir><dir name="Mysql4"><dir name="Urgent"><file name="Collection.php" hash="fbc97b9f454181770129c2278e673cc6"/></dir><file name="Urgent.php" hash="733cedf99d593149a5dbf7d5378e4579"/></dir><dir name="System"><file name="Abstract.php" hash="28da5ccd4466fc334a6688d7a847c766"/><file name="Pachet.php" hash="ae9b264de1373882e22012f01411291f"/><file name="Plantarifar.php" hash="ee1985ec225f0a2fa74a117fb0aabf53"/><file name="Punctridicare.php" hash="3b46b40bebf020b68f13cc5843c9088c"/><file name="Tarifeafisate.php" hash="913bd9302763f350a610ea0a5457c930"/></dir><file name="Urgent.php" hash="e32e91b5e2f1cbf0b08c045862bea4bd"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="IndexController.php" hash="d5d788bd1a94d444951a8f7437ff6501"/></dir></dir><dir name="etc"><file name="config.xml" hash="e3cd66af85a212a31ce4ad5d9c853950"/><file name="system.xml" hash="08545a878542a973e0e60257f55f7907"/></dir><dir name="sql"><dir name="eadsign_urgent_setup"><file name="mysql4-install-1.0.1.php" hash="1b52c65cdfbf67fd1e1aaf96404f8c0a"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="."><file name="Eadesigndev_Urgent.xml" hash=""/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>5.6.3</max></php></required></dependencies>
18
+ </package>