Ydral_Correos - Version 1.0.0

Version Notes

Correos

Download this release

Release Info

Developer Ydral
Extension Ydral_Correos
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (54) hide show
  1. app/code/local/Ydral/Correos/Block/Correos.php +11 -0
  2. app/code/local/Ydral/Correos/Block/Onepage/Shipping/Method/Available.php +46 -0
  3. app/code/local/Ydral/Correos/Block/Order/Info.php +13 -0
  4. app/code/local/Ydral/Correos/Block/Order/Shipment.php +13 -0
  5. app/code/local/Ydral/Correos/Block/Order/View.php +13 -0
  6. app/code/local/Ydral/Correos/Block/System/Export/Envio.php +23 -0
  7. app/code/local/Ydral/Correos/Block/System/Export/Recoger.php +23 -0
  8. app/code/local/Ydral/Correos/Block/Tracking/Popup.php +68 -0
  9. app/code/local/Ydral/Correos/Helper/Data.php +189 -0
  10. app/code/local/Ydral/Correos/Helper/Onestepcheckout.php +19 -0
  11. app/code/local/Ydral/Correos/Model/Correos.php +9 -0
  12. app/code/local/Ydral/Correos/Model/Mysql4/Carrier/Correos.php +336 -0
  13. app/code/local/Ydral/Correos/Model/Mysql4/Carrier/Correos/Collection.php +49 -0
  14. app/code/local/Ydral/Correos/Model/Mysql4/Correos.php +9 -0
  15. app/code/local/Ydral/Correos/Model/Mysql4/Correos/Collection.php +9 -0
  16. app/code/local/Ydral/Correos/Model/Pesos.php +12 -0
  17. app/code/local/Ydral/Correos/Model/Quote/Address/Total/Shipping.php +145 -0
  18. app/code/local/Ydral/Correos/Model/System/Config/Backend/Shipping/Correos.php +8 -0
  19. app/code/local/Ydral/Correos/Model/System/Config/Backend/Shipping/Recoger.php +8 -0
  20. app/code/local/Ydral/Correos/Model/Type/Onepage.php +52 -0
  21. app/code/local/Ydral/Correos/Model/Ydral/Correos.php +181 -0
  22. app/code/local/Ydral/Correos/Model/Ydral/Recogeroficina.php +403 -0
  23. app/code/local/Ydral/Correos/Model/Ydral/Shipment.php +600 -0
  24. app/code/local/Ydral/Correos/controllers/IndexController.php +44 -0
  25. app/code/local/Ydral/Correos/controllers/Sales/Order/ShipmentController.php +57 -0
  26. app/code/local/Ydral/Correos/controllers/TrackingController.php +19 -0
  27. app/code/local/Ydral/Correos/etc/config.xml +211 -0
  28. app/code/local/Ydral/Correos/etc/system.xml +488 -0
  29. app/code/local/Ydral/Correos/log.txt +13 -0
  30. app/code/local/Ydral/Correos/sql/correos_setup/mysql4-install-0.1.0.php +33 -0
  31. app/code/local/Ydral/Correos/sql/correos_setup/mysql4-upgrade-0.1.0-0.2.0.php +2 -0
  32. app/code/local/Ydral/Correos/sql/correos_setup/mysql4-upgrade-0.2.0-0.3.0.php +2 -0
  33. app/design/adminhtml/default/default/layout/correos.xml +17 -0
  34. app/design/adminhtml/default/default/template/correos/tab_info.phtml +205 -0
  35. app/design/frontend/base/default/layout/correos.xml +46 -0
  36. app/design/frontend/base/default/template/correos/order_info.phtml +125 -0
  37. app/design/frontend/base/default/template/correos/order_shipment.phtml +63 -0
  38. app/design/frontend/base/default/template/correos/order_shipment_items.phtml +83 -0
  39. app/design/frontend/base/default/template/correos/order_view.phtml +92 -0
  40. app/design/frontend/base/default/template/correos/popup.phtml +273 -0
  41. app/etc/modules/Ydral_Correos.xml +10 -0
  42. package.xml +18 -0
  43. skin/adminhtml/default/default/correos.css +5 -0
  44. skin/adminhtml/default/default/images/correos-section.png +0 -0
  45. skin/frontend/base/default/css/correos.css +3 -0
  46. skin/frontend/base/default/images/correos_4872.png +0 -0
  47. skin/frontend/base/default/images/logo_entregadomicilio.jpg +0 -0
  48. skin/frontend/base/default/images/logo_recogeroficina.jpg +0 -0
  49. skin/frontend/base/default/js/correos.js +161 -0
  50. skin/frontend/default/default/css/correos.css +3 -0
  51. skin/frontend/default/default/images/correos_4872.png +0 -0
  52. skin/frontend/default/default/images/logo_entregadomicilio.jpg +0 -0
  53. skin/frontend/default/default/images/logo_recogeroficina.jpg +0 -0
  54. skin/frontend/default/default/js/correos.js +161 -0
app/code/local/Ydral/Correos/Block/Correos.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ydral_Correos_Block_Correos extends Mage_Core_Block_Template
4
+ {
5
+ protected function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->setTemplate('ydral/correos/correos.phtml');
9
+ }
10
+
11
+ }
app/code/local/Ydral/Correos/Block/Onepage/Shipping/Method/Available.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-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 Mage
22
+ * @package Mage_Checkout
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * One page checkout status
29
+ *
30
+ * @category Mage
31
+ * @category Mage
32
+ * @package Mage_Checkout
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Ydral_Correos_Block_Onepage_Shipping_Method_Available extends Mage_Checkout_Block_Onepage_Shipping_Method_Available
36
+ {
37
+
38
+ public function escapeHtml($data, $allowedTags = null)
39
+ {
40
+ if (version_compare(Mage::getVersion(), '1.7.0', '>=')) {
41
+ return $data;
42
+ } else {
43
+ return parent::escapeHtml($data, $allowedTags);
44
+ }
45
+ }
46
+ }
app/code/local/Ydral/Correos/Block/Order/Info.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ydral_Correos_Block_Order_Info extends Mage_Sales_Block_Order_Info
4
+ {
5
+ protected function _construct()
6
+ {
7
+ parent::_construct();
8
+ if (($this->getOrder()->getShippingMethod() == 'recogeroficina_recogeroficina') || ($this->getOrder()->getShippingMethod() == 'envio4872_envio4872'))
9
+ {
10
+ $this->setTemplate('correos/order_info.phtml');
11
+ }
12
+ }
13
+ }
app/code/local/Ydral/Correos/Block/Order/Shipment.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ydral_Correos_Block_Order_Shipment extends Mage_Sales_Block_Order_Shipment
4
+ {
5
+ protected function _construct()
6
+ {
7
+ parent::_construct();
8
+ if (($this->getOrder()->getShippingMethod() == 'recogeroficina_recogeroficina') || ($this->getOrder()->getShippingMethod() == 'envio4872_envio4872'))
9
+ {
10
+ $this->setTemplate('correos/order_shipment.phtml');
11
+ }
12
+ }
13
+ }
app/code/local/Ydral/Correos/Block/Order/View.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ydral_Correos_Block_Order_View extends Mage_Sales_Block_Order_View
4
+ {
5
+ protected function _construct()
6
+ {
7
+ parent::_construct();
8
+ if (($this->getOrder()->getShippingMethod() == 'recogeroficina_recogeroficina') || ($this->getOrder()->getShippingMethod() == 'envio4872_envio4872'))
9
+ {
10
+ $this->setTemplate('correos/order_view.phtml');
11
+ }
12
+ }
13
+ }
app/code/local/Ydral/Correos/Block/System/Export/Envio.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ydral_Correos_Block_System_Export_Envio extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+
6
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
7
+ {
8
+ $this->setElement($element);
9
+
10
+ $url = $this->getUrl('catalog/product'); //
11
+
12
+ $html = $this->getLayout()->createBlock('adminhtml/widget_button')
13
+ ->setType('button')
14
+ ->setClass('scalable')
15
+ ->setLabel('Exportar CSV')
16
+ ->setOnClick("setLocation('$url')")
17
+ ->setOnClick('setLocation(\''.Mage::helper('adminhtml')->getUrl("*/*/exportTablerates", $params) . 'conditionName/\' + $(\'carriers_envio4872_condition_name\').value + \'/tablerates.csv\' )')
18
+ ->toHtml();
19
+
20
+ return $html;
21
+ }
22
+
23
+ }
app/code/local/Ydral/Correos/Block/System/Export/Recoger.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ydral_Correos_Block_System_Export_Recoger extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+
6
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
7
+ {
8
+ $this->setElement($element);
9
+
10
+ $url = $this->getUrl('catalog/product'); //
11
+
12
+ $html = $this->getLayout()->createBlock('adminhtml/widget_button')
13
+ ->setType('button')
14
+ ->setClass('scalable')
15
+ ->setLabel('Exportar CSV')
16
+ ->setOnClick("setLocation('$url')")
17
+ ->setOnClick('setLocation(\''.Mage::helper('adminhtml')->getUrl("*/*/exportTablerates", $params) . 'conditionName/\' + $(\'carriers_recogeroficina_condition_name\').value + \'/tablerates.csv\' )')
18
+ ->toHtml();
19
+
20
+ return $html;
21
+ }
22
+
23
+ }
app/code/local/Ydral/Correos/Block/Tracking/Popup.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ydral_Correos_Block_Tracking_Popup extends Mage_Core_Block_Template
4
+ {
5
+
6
+ /**
7
+ * Retrieve array of tracking info
8
+ *
9
+ * @return array
10
+ */
11
+ public function getTrackingInfo()
12
+ {
13
+ /* @var $info Mage_Shipping_Model_Info */
14
+ $info = Mage::registry('current_shipping_info');
15
+
16
+ return $info->getTrackingInfo();
17
+ }
18
+
19
+
20
+ /**
21
+ * Format given date and time in current locale without changing timezone
22
+ *
23
+ * @param string $date
24
+ * @param string $time
25
+ * @return string
26
+ */
27
+ public function formatDeliveryDateTime($date, $time)
28
+ {
29
+ return $this->formatDeliveryDate($date) . ' ' . $this->formatDeliveryTime($time);
30
+ }
31
+
32
+ /**
33
+ * Format given date in current locale without changing timezone
34
+ *
35
+ * @param string $date
36
+ * @return string
37
+ */
38
+ public function formatDeliveryDate($date)
39
+ {
40
+ /* @var $locale Mage_Core_Model_Locale */
41
+ $locale = Mage::app()->getLocale();
42
+ $format = $locale->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
43
+ return $locale->date(strtotime($date), Zend_Date::TIMESTAMP, null, false)
44
+ ->toString($format);
45
+ }
46
+
47
+ /**
48
+ * Format given time [+ date] in current locale without changing timezone
49
+ *
50
+ * @param string $time
51
+ * @param string $date
52
+ * @return string
53
+ */
54
+ public function formatDeliveryTime($time, $date = null)
55
+ {
56
+ if (!empty($date)) {
57
+ $time = $date . ' ' . $time;
58
+ }
59
+
60
+ /* @var $locale Mage_Core_Model_Locale */
61
+ $locale = Mage::app()->getLocale();
62
+
63
+ $format = $locale->getTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
64
+ return $locale->date(strtotime($time), Zend_Date::TIMESTAMP, null, false)
65
+ ->toString($format);
66
+ }
67
+
68
+ }
app/code/local/Ydral/Correos/Helper/Data.php ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ydral_Correos_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ public function setOficinaCorreosRecogida($observer)
7
+ {
8
+
9
+ $idQuote = Mage::getSingleton('checkout/session')->getQuoteId();
10
+ $idSelector = trim(strip_tags($this->_getRequest()->getPost('oficinas_correos_content_select')));
11
+ $cpField = trim(strip_tags($this->_getRequest()->getPost('cp_search')));
12
+
13
+ if (!empty($idSelector))
14
+ {
15
+
16
+ Mage::getModel('correos/ydral_recogeroficina')->saveCheckoutData('quote', $idQuote, $idSelector, $cpField);
17
+ return $this;
18
+
19
+ }
20
+
21
+ }
22
+
23
+
24
+ public function setOficinaCorreosRecogidaOrder($observer)
25
+ {
26
+
27
+ $idQuote = Mage::getSingleton('checkout/session')->getLastQuoteId();
28
+ $idOrder = Mage::getSingleton('checkout/session')->getLastRealOrderId();
29
+
30
+ $_checkoutData = Mage::getModel('correos/ydral_recogeroficina')->readCheckoutData('quote', $idQuote);
31
+
32
+ if ($_checkoutData)
33
+ {
34
+ Mage::getModel('correos/ydral_recogeroficina')->saveCheckoutData('order', $idOrder, $_checkoutData['correos_recogida'], $_checkoutData['correos_oficina']);
35
+ } else {
36
+
37
+ $idSelector = trim(strip_tags($this->_getRequest()->getPost('oficinas_correos_content_select')));
38
+ $cpField = trim(strip_tags($this->_getRequest()->getPost('cp_search')));
39
+
40
+ if (!empty($idSelector))
41
+ {
42
+
43
+ Mage::getModel('correos/ydral_recogeroficina')->saveCheckoutData('quote', $idQuote, $idSelector, $cpField);
44
+ $_checkoutData = Mage::getModel('correos/ydral_recogeroficina')->readCheckoutData('quote', $idQuote);
45
+ if ($_checkoutData)
46
+ {
47
+ Mage::getModel('correos/ydral_recogeroficina')->saveCheckoutData('order', $idOrder, $_checkoutData['correos_recogida'], $_checkoutData['correos_oficina']);
48
+ }
49
+ }
50
+
51
+ }
52
+ }
53
+
54
+
55
+ public function getCorreosError ($errorCode)
56
+ {
57
+
58
+ $_errorCodes = array (
59
+ '1' => 'El CP del destino no es v�lido',
60
+ '2' => 'El cliente/contrato/anexo/tipo de franqueo no es v�lido',
61
+ '3' => 'El producto no est� permitido para el pa�s indicado',
62
+ '4' => 'No est� permitido el seguro',
63
+ '5' => 'El seguro no puede ser 0',
64
+ '6' => 'El importe del seguro no es correcto',
65
+ '7' => 'No est� permitido el reembolso',
66
+ '8' => 'El reembolso no puede ser 0',
67
+ '9' => 'El importe del reembolso no es correcto',
68
+ '10' => 'El N� de cuenta no es v�lido para un Reembolso en Cuenta',
69
+ '11' => 'El CP del remitente no es v�lido',
70
+ '12' => 'El NIF del remitente no es v�lido',
71
+ '13' => 'El NIF del destinatario no es v�lido',
72
+ '14' => 'Faltan datos para el peso volum�trico',
73
+ '15' => 'La suma de las dimensiones del paquete es mayor de 200 cm',
74
+ '16' => 'El peso volum�trico indicado no es acorde con las dimensiones del paquete',
75
+ '17' => 'La entrega exclusiva al destinatario no est� permitida',
76
+ '18' => 'Es necesaria una descripci�n de la mercanc�a para este tipo de env�o',
77
+ '19' => 'El valor declarado de la mercanc�a no puede ser 0',
78
+ '20' => 'La oficina de destino no es v�lida',
79
+ '21' => 'La direcci�n del remitente es obligatoria',
80
+ '22' => 'No se ha podido recuperar la tarifa para este env�o',
81
+ '23' => 'No existe la m�quina de franquear',
82
+ '24' => 'La m�quina de franquear no pertenece a la misma Jefatura Pronvincial que la oficina',
83
+ '25' => 'Insuficiencia de franqueo',
84
+ '26' => 'El tipo de reembolso no puede estar vac�o',
85
+ '27' => 'El N� de cuenta no es v�lido para un Reembolso en Cuenta',
86
+ '28' => 'El tipo de env�o es obligatorio',
87
+ '29' => 'Para este env�o debe introducir el n�mero de m�vil del destinatario',
88
+ '30' => 'El Tel�fono del destinatario debe ser un m�vil v�lido',
89
+ '31' => 'El tipo de franqueo no es v�lido',
90
+ '32' => 'No se ha informado del CPI destino',
91
+ '33' => 'El contrato/cliente no tiene anexo para este producto',
92
+ '34' => 'No est� permitido el acuse de recibo',
93
+ '35' => 'El peso no es v�lido',
94
+ '36' => 'La direcci�n del destinatario es obligatoria',
95
+ '37' => 'El c�digo de env�o ya est� pre-registrado en la aplicaci�n',
96
+ '38' => 'El c�digo de env�o ya est� registrado en la aplicaci�n',
97
+ '39' => 'El c�digo de env�o est� vac�o',
98
+ '40' => 'Los �mbitos no coinciden',
99
+ '41' => 'El nombre del destinatario est� vac�o',
100
+ '42' => 'El nombre del remitente est� vac�o',
101
+ '43' => 'Los apellidos del remitente est�n vac�os',
102
+ '44' => 'Los apellidos del destinatario est�n vac�os',
103
+ '45' => 'Error de formato en el mensaje',
104
+ '46' => 'Error en IRIS6',
105
+ '47' => 'Error en IRIS6',
106
+ '50' => 'Error en el pre-registro',
107
+ '51' => 'La versi�n del fichero no es v�lida',
108
+ '52' => 'c�digo de certificado duplicado',
109
+ '53' => 'El tipo de franqueo no es v�lido',
110
+ '54' => 'No hay nombre ni empresa destinataria',
111
+ '55' => 'Es obligatorio indicar la localidad de destino',
112
+ '56' => 'El nombre del remitente o la empresa remitente es obligatorio',
113
+ '57' => 'Es necesario indicar el tipo de reembolso',
114
+ '58' => 'S�lo se permite un cliente detallable por fichero',
115
+ '59' => 'Producto no v�lido',
116
+ '60' => 'El c�digo de cliente no coincide con el del c�digo de producto',
117
+ '61' => 'El c�digo de ceritificado no permite valores a�adidos (salvo acuse de recibo f�sico)',
118
+ '62' => 'El d�gito de Control del c�digo de certificado es err�neo',
119
+ '63' => 'Certificado duplicado en el propio fichero',
120
+ '64' => 'El env�o ha sido anulado correctamente',
121
+ '65' => 'El env�o ya est� dado de alta',
122
+ '66' => 'El env�o ya est� dado de baja',
123
+ '67' => 'El env�o no est� pre-registrado',
124
+ '68' => 'El c�digo de est�do del env�o no es correcto',
125
+ '69' => 'Un env�o prepagado no puede llevar VA',
126
+ '70' => 'No se ha informado del importe del env�o',
127
+ '71' => 'No se ha informado del importe de las promociones del env�o',
128
+ '72' => 'La localidad del remitente es obligatoria',
129
+ '73' => 'El c�digo etiquetador no es v�lido',
130
+ '74' => 'El n�mero de manifiesto es obligatorio',
131
+ '75' => 'Es necesario especificar una persona de contacto en la empresa destino',
132
+ '76' => 'Es necesario especificar una persona de contacto en la empresa remitente',
133
+ '77' => 'Lista de env�os vacia o no se han podido traducir los env�os',
134
+ '78' => 'Faltan datos obligatorios',
135
+ '79' => 'El producto y la modalidad de entrega son incompatibles',
136
+ '80' => 'Es obligatorio informar del cliente/contrato',
137
+ '81' => 'Es obligatorio informar del c�digo etiquedaror',
138
+ '82' => 'Es obligatorio indicar la cantidad del primer art�culo contenido en el env�o',
139
+ '83' => 'El c�digo etiquetador no existe en bbdd',
140
+ '84' => 'Existe mas de un c�digo etiquetador en bbdd',
141
+ '85' => 'Error al validar el c�digo etiquetador',
142
+ '86' => 'Es obligatorio indicar si el env�o lleva asociada una factura superior a 500 euros',
143
+ '87' => 'Es obligatorio indicar si desea que el DUA de exportaci�n sea tramitado por Correos',
144
+ '88' => 'Es obligatorio informar del nombre o la empresa destinataria',
145
+ '89' => 'Es obligatorio informar del nombre o la empresa remitente',
146
+ '90' => 'El c�digo de certificado debe tener 13 o 23 caracteres',
147
+ '91' => '�mbito no encontrado',
148
+ '92' => 'El tipo de reembolso no es v�lido',
149
+ '93' => 'La direcci�n del destinatario es incompleta',
150
+ '94' => 'La direcci�n del remitente es incompleta',
151
+ '95' => 'No se ha informado del importe antes de promociones',
152
+ '96' => 'No se ha informado del impuesto antes de promociones',
153
+ '97' => 'No se ha informado del importe despu�s de promociones',
154
+ '98' => 'No se ha informado del impuesto despu�s de promociones',
155
+ '99' => 'Falta informaci�n obligatoria para la admisi�n de un Reembolso en Apartado',
156
+ '100' => 'El importe de Franqueo M�quina es insuficiente',
157
+ '101' => 'Peso neto no informado',
158
+ '102' => 'El c�digo de certificado de un env�o internacional debe tener 13 caracteres',
159
+ '103' => 'El env�o se encuentra caducado y no puede ser admitido',
160
+ '104' => 'El c�digo de certificado no es v�lido para ese tipo de producto',
161
+ '105' => 'El n�mero de apartado no existe para la oficina indicada',
162
+ '106' => 'Se debe indicar que hacer con el paquete en caso de no hacer la entrega',
163
+ '107' => 'Se debe indicar una persona de contacto en la empresa del remitente',
164
+ '108' => 'Se debe indicar la direcci�n de correo del destinatario',
165
+ '109' => 'Faltan datos obligatorios para el paso de aduana',
166
+ '110' => 'La suma de las dimensiones del paquete es mayor de 210 cm',
167
+ '111' => 'Error al generar el c�digo de certificado con los datos recibidos',
168
+ '112' => 'El cliente no est� autorizado a pre-registrar este env�o'
169
+ );
170
+
171
+ return $_errorCodes[$errorCode];
172
+
173
+ }
174
+
175
+
176
+ public function getTrackingPopupUrlBySalesModel($model)
177
+ {
178
+
179
+ $param = array(
180
+ 'hash' => Mage::helper('core')->urlEncode("order_id:{$model->getId()}:{$model->getProtectCode()}")
181
+ );
182
+
183
+ $storeId = is_object($model) ? $model->getStoreId() : null;
184
+ $storeModel = Mage::app()->getStore($storeId);
185
+ return $storeModel->getUrl('correos/tracking/popup', $param);
186
+
187
+ }
188
+
189
+ }
app/code/local/Ydral/Correos/Helper/Onestepcheckout.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ydral_Correos_Helper_Onestepcheckout extends Idev_OneStepCheckout_Helper_Checkout
4
+ {
5
+
6
+ public function saveShippingMethod($shippingMethod)
7
+ {
8
+
9
+ $_cp = Mage::app()->getRequest()->getPost('oficinas_correos_content_select');
10
+ if ( ($shippingMethod == 'recogeroficina_recogeroficina') && (empty($_cp)) )
11
+ {
12
+ return array('error' => -1, 'message' => Mage::helper('correos')->__('No se ha especificado una oficina de recogida.'));
13
+ }
14
+
15
+ return parent::saveShippingMethod($shippingMethod);
16
+
17
+ }
18
+
19
+ }
app/code/local/Ydral/Correos/Model/Correos.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ydral_Correos_Model_Correos extends Mage_Core_Model_Abstract
4
+ {
5
+ protected function _construct()
6
+ {
7
+ $this->_init('correos/correos');
8
+ }
9
+ }
app/code/local/Ydral/Correos/Model/Mysql4/Carrier/Correos.php ADDED
@@ -0,0 +1,336 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ydral_Correos_Model_Mysql4_Carrier_Correos extends Mage_Core_Model_Mysql4_Abstract
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->_init('shipping/correos', 'pk');
7
+ }
8
+
9
+ public function getRate(Mage_Shipping_Model_Rate_Request $request)
10
+ {
11
+ $read = $this->_getReadAdapter();
12
+
13
+ $table = Mage::getSingleton('core/resource')->getTableName('correos_shipping/correos');
14
+
15
+ $select = $read->select()->from($table);
16
+
17
+ $select->where(
18
+ $read->quoteInto(" (dest_country_id=? ", $request->getDestCountryId()).
19
+ $read->quoteInto(" AND dest_region_id=? ", $request->getDestRegionId()).
20
+ $read->quoteInto(" AND dest_zip=?) ", $request->getDestPostcode()).
21
+
22
+ $read->quoteInto(" OR (dest_country_id=? ", $request->getDestCountryId()).
23
+ $read->quoteInto(" AND dest_region_id=? AND dest_zip='') ", $request->getDestRegionId()).
24
+
25
+ $read->quoteInto(" OR (dest_country_id=? AND dest_region_id='0' AND dest_zip='') ", $request->getDestCountryId()).
26
+
27
+ $read->quoteInto(" OR (dest_country_id=? AND dest_region_id='0' ", $request->getDestCountryId()).
28
+ $read->quoteInto(" AND dest_zip=?) ", $request->getDestPostcode()).
29
+
30
+ " OR (dest_country_id='0' AND dest_region_id='0' AND dest_zip='')"
31
+ );
32
+
33
+ if (is_array($request->getConditionName()))
34
+ {
35
+ $i = 0;
36
+
37
+ foreach ($request->getConditionName() as $conditionName)
38
+ {
39
+ if ($i == 0)
40
+ {
41
+ $select->where('condition_name=?', $conditionName);
42
+ }
43
+ else
44
+ {
45
+ $select->orWhere('condition_name=?', $conditionName);
46
+ }
47
+
48
+ $select->where('condition_value<=?', $request->getData($conditionName));
49
+ $i++;
50
+ }
51
+ }
52
+ else
53
+ {
54
+ $select->where('condition_name=?', $request->getConditionName());
55
+ $select->where('condition_value<=?', $request->getData($request->getConditionName()));
56
+ $select->where('method_code=?', $request->getMethodCode());
57
+ }
58
+
59
+ $select->where('website_id=?', $request->getWebsiteId());
60
+
61
+ //$select->group('dest_zip');
62
+ //$select->group('dest_region_id');
63
+ //$select->group('dest_country_id');
64
+
65
+ $select->order('dest_zip DESC');
66
+ $select->order('dest_region_id DESC');
67
+ $select->order('dest_country_id DESC');
68
+
69
+ $select->order('condition_value DESC');
70
+ $select->limit(1);
71
+ #Mage::log($select->__toString());
72
+
73
+ $rows = $read->fetchRow($select);
74
+
75
+
76
+ return $rows;
77
+ }
78
+
79
+
80
+ /**
81
+ *
82
+ */
83
+ public function uploadAndImport(Varien_Object $object, $methodCode)
84
+ {
85
+
86
+ $csvFile = $_FILES["groups"]["tmp_name"][$methodCode]["fields"]["import"]["value"];
87
+
88
+
89
+ if (!empty($csvFile))
90
+ {
91
+ $csv = trim(file_get_contents($csvFile));
92
+
93
+ $table = Mage::getSingleton('core/resource')->getTableName('correos_shipping/correos');
94
+
95
+ $websiteId = $object->getScopeId();
96
+
97
+
98
+ /**
99
+ * 0.2.0
100
+ */
101
+ if ($object->getData('groups/'.$methodCode.'/fields/condition_name/inherit') == '1') {
102
+ $conditionName = (string)Mage::getConfig()->getNode('default/carriers/'.$methodCode.'/condition_name');
103
+ } else {
104
+ $conditionName = $object->getData('groups/'.$methodCode.'/fields/condition_name/value');
105
+ }
106
+
107
+ $conditionFullName = Mage::getModel('correos_shipping/ydral_correos')->getCode('condition_name_short', $conditionName);
108
+
109
+ if (!empty($csv))
110
+ {
111
+ $exceptions = array();
112
+ $csvLines = explode("\n", $csv);
113
+ $csvLine = array_shift($csvLines);
114
+ $csvLine = $this->_getCsvValues($csvLine);
115
+
116
+ if (count($csvLine) < 5)
117
+ {
118
+ $exceptions[0] = Mage::helper('shipping')->__('Invalid Table Rates File Format');
119
+ }
120
+
121
+ $countryCodes = array();
122
+ $regionCodes = array();
123
+
124
+ foreach ($csvLines as $k => $csvLine)
125
+ {
126
+ $csvLine = $this->_getCsvValues($csvLine);
127
+
128
+ if (count($csvLine) > 0 && count($csvLine) < 5)
129
+ {
130
+ $exceptions[0] = Mage::helper('shipping')->__('Invalid Table Rates File Format');
131
+ }
132
+ else
133
+ {
134
+ $countryCodes[] = $csvLine[0];
135
+ $regionCodes[] = $csvLine[1];
136
+ }
137
+ }
138
+
139
+ if (empty($exceptions))
140
+ {
141
+ $data = array();
142
+ $countryCodesToIds = array();
143
+ $regionCodesToIds = array();
144
+ $countryCodesIso2 = array();
145
+
146
+ $countryCollection = Mage::getResourceModel('directory/country_collection')->addCountryCodeFilter($countryCodes)->load();
147
+
148
+ foreach ($countryCollection->getItems() as $country)
149
+ {
150
+ $countryCodesToIds[$country->getData('iso3_code')] = $country->getData('country_id');
151
+ $countryCodesToIds[$country->getData('iso2_code')] = $country->getData('country_id');
152
+ $countryCodesIso2[] = $country->getData('iso2_code');
153
+ }
154
+
155
+ $regionCollection = Mage::getResourceModel('directory/region_collection')
156
+ ->addRegionCodeFilter($regionCodes)
157
+ ->addCountryFilter($countryCodesIso2)
158
+ ->load();
159
+
160
+ foreach ($regionCollection->getItems() as $region)
161
+ {
162
+ $regionCodesToIds[$countryCodesToIds[$region->getData('country_id')]][$region->getData('code')] = $region->getData('region_id');
163
+ }
164
+
165
+ foreach ($csvLines as $k => $csvLine)
166
+ {
167
+
168
+ $csvLine = $this->_getCsvValues($csvLine);
169
+
170
+ /*
171
+ * Column 1 - Country
172
+ */
173
+ if (empty($countryCodesToIds) || !array_key_exists($csvLine[0], $countryCodesToIds))
174
+ {
175
+ $countryId = '0';
176
+
177
+ if ($csvLine[0] != '*' && $csvLine[0] != '')
178
+ {
179
+ $exceptions[] = Mage::helper('shipping')->__('Invalid Country "%s" in the Row #%s', $csvLine[0], ($k+1));
180
+ }
181
+ }
182
+ else
183
+ {
184
+ $countryId = $countryCodesToIds[$csvLine[0]];
185
+ }
186
+
187
+
188
+ /*
189
+ * Column 2 - Region/State
190
+ */
191
+ if ($countryId == '0')
192
+ {
193
+ $regionId = '0';
194
+ }
195
+ else
196
+ {
197
+ if (empty($regionCodesToIds[$countryCodesToIds[$csvLine[0]]]) || !array_key_exists($csvLine[1], $regionCodesToIds[$countryCodesToIds[$csvLine[0]]]))
198
+ {
199
+ $regionId = '0';
200
+
201
+ if ($csvLine[1] != '*' && $csvLine[1] != '')
202
+ {
203
+ $exceptions[] = Mage::helper('shipping')->__('Invalid Region/State "%s" in the Row #%s', $csvLine[1], ($k+1));
204
+ }
205
+ }
206
+ else
207
+ {
208
+ $regionId = $regionCodesToIds[$countryCodesToIds[$csvLine[0]]][$csvLine[1]];
209
+ }
210
+ }
211
+ /*
212
+ * Column 3 - Zip/Postal Code
213
+ */
214
+ if ($csvLine[2] == '*' || $csvLine[2] == '')
215
+ {
216
+ $zip = '';
217
+ }
218
+ else
219
+ {
220
+ $zip = $csvLine[2];
221
+ }
222
+
223
+ /*
224
+ * Column 4 - Order Subtotal
225
+ */
226
+ if (!$this->_isPositiveDecimalNumber($csvLine[3]) || $csvLine[3] == '*' || $csvLine[3] == '')
227
+ {
228
+ $exceptions[] = Mage::helper('shipping')->__('Invalid %s "%s" in the Row #%s', $conditionFullName, $csvLine[3], ($k+1));
229
+ }
230
+ else
231
+ {
232
+ $csvLine[3] = (float)$csvLine[3];
233
+ }
234
+
235
+ /*
236
+ * Column 5 - Shipping Price
237
+ */
238
+ if (!$this->_isPositiveDecimalNumber($csvLine[4]))
239
+ {
240
+ $exceptions[] = Mage::helper('shipping')->__('Invalid Shipping Price "%s" in the Row #%s', $csvLine[4], ($k+1));
241
+ }
242
+ else
243
+ {
244
+ $csvLine[4] = (float)$csvLine[4];
245
+ }
246
+
247
+
248
+ $data[] = array(
249
+ 'website_id' => $websiteId,
250
+ 'dest_country_id' => $countryId,
251
+ 'dest_region_id' => $regionId,
252
+ 'dest_zip' => $zip,
253
+ 'condition_name' => $conditionName,
254
+ 'condition_value' => $csvLine[3],
255
+ 'price' => $csvLine[4],
256
+ 'method_code' => $methodCode,
257
+ );
258
+ }
259
+ }
260
+
261
+
262
+
263
+ if (empty($exceptions))
264
+ {
265
+ $connection = $this->_getWriteAdapter();
266
+
267
+ $condition = array(
268
+ $connection->quoteInto('website_id = ?', $websiteId),
269
+ $connection->quoteInto('condition_name = ?', $conditionName),
270
+ $connection->quoteInto('method_code = ?', $methodCode),
271
+ );
272
+
273
+ $connection->delete($table, $condition);
274
+
275
+ foreach($data as $k=>$dataLine)
276
+ {
277
+ try
278
+ {
279
+ $connection->insert($table, $dataLine);
280
+ }
281
+ catch (Exception $e)
282
+ {
283
+ // This should probably show the exception message too.
284
+ $exceptions[] = Mage::helper('shipping')->__('Import error: ' . $e->getMessage());
285
+ }
286
+ }
287
+ }
288
+
289
+ if (!empty($exceptions))
290
+ {
291
+ throw new Exception( "\n" . implode("\n", $exceptions) );
292
+ }
293
+ }
294
+ }
295
+ }
296
+
297
+ protected function _getCsvValues($string, $separator=",")
298
+ {
299
+ $elements = explode($separator, trim($string));
300
+
301
+ for ($i = 0; $i < count($elements); $i++)
302
+ {
303
+ $nquotes = substr_count($elements[$i], '"');
304
+
305
+ if ($nquotes %2 == 1)
306
+ {
307
+ for ($j = $i+1; $j < count($elements); $j++)
308
+ {
309
+ if (substr_count($elements[$j], '"') > 0)
310
+ {
311
+ // Put the quoted string's pieces back together again
312
+ array_splice($elements, $i, $j-$i+1, implode($separator, array_slice($elements, $i, $j-$i+1)));
313
+ break;
314
+ }
315
+ }
316
+ }
317
+
318
+ if ($nquotes > 0)
319
+ {
320
+ // Remove first and last quotes, then merge pairs of quotes
321
+ $qstr =& $elements[$i];
322
+ $qstr = substr_replace($qstr, '', strpos($qstr, '"'), 1);
323
+ $qstr = substr_replace($qstr, '', strrpos($qstr, '"'), 1);
324
+ $qstr = str_replace('""', '"', $qstr);
325
+ }
326
+ $elements[$i] = trim($elements[$i]);
327
+ }
328
+ return $elements;
329
+ }
330
+
331
+ protected function _isPositiveDecimalNumber($n)
332
+ {
333
+ return preg_match ("/^[0-9]+(\.[0-9]*)?$/", $n);
334
+ }
335
+
336
+ }
app/code/local/Ydral/Correos/Model/Mysql4/Carrier/Correos/Collection.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ydral_Correos_Model_Mysql4_Carrier_Correos_Collection extends Varien_Data_Collection_Db
4
+ {
5
+ protected $_shipTable;
6
+ protected $_countryTable;
7
+ protected $_regionTable;
8
+
9
+ public function __construct()
10
+ {
11
+ parent::__construct(Mage::getSingleton('core/resource')->getConnection('shipping_read'));
12
+
13
+ $this->_shipTable = Mage::getSingleton('core/resource')->getTableName('correos_shipping/multipletablerates');
14
+
15
+ $this->_countryTable = Mage::getSingleton('core/resource')->getTableName('directory/country');
16
+
17
+ $this->_regionTable = Mage::getSingleton('core/resource')->getTableName('directory/country_region');
18
+
19
+ $this->_select->from(array("s" => $this->_shipTable))
20
+ ->joinLeft(array("c" => $this->_countryTable), 'c.country_id = s.dest_country_id', 'iso3_code AS dest_country')
21
+ ->joinLeft(array("r" => $this->_regionTable), 'r.region_id = s.dest_region_id', 'code AS dest_region')
22
+ ->order(array("dest_country", "dest_region", "dest_zip"));
23
+
24
+ $this->_setIdFieldName('pk');
25
+
26
+ return $this;
27
+ }
28
+
29
+ public function setWebsiteFilter($websiteId)
30
+ {
31
+ $this->_select->where("website_id = ?", $websiteId);
32
+
33
+ return $this;
34
+ }
35
+
36
+ public function setConditionFilter($conditionName)
37
+ {
38
+ $this->_select->where("condition_name = ?", $conditionName);
39
+
40
+ return $this;
41
+ }
42
+
43
+ public function setCountryFilter($countryId)
44
+ {
45
+ $this->_select->where("dest_country_id = ?", $countryId);
46
+
47
+ return $this;
48
+ }
49
+ }
app/code/local/Ydral/Correos/Model/Mysql4/Correos.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ydral_Correos_Model_Mysql4_Correos extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ protected function _construct()
6
+ {
7
+ $this->_init('correos/correos', 'correos_id');
8
+ }
9
+ }
app/code/local/Ydral/Correos/Model/Mysql4/Correos/Collection.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ydral_Correos_Model_Mysql4_Correos_Collection extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ protected function _construct()
6
+ {
7
+ $this->_init('correos/correos');
8
+ }
9
+ }
app/code/local/Ydral/Correos/Model/Pesos.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ydral_Correos_Model_Pesos
3
+ {
4
+ public function toOptionArray()
5
+ {
6
+ return array(
7
+ array('value'=>'gramos', 'label'=>Mage::helper('correos')->__('Gramos')),
8
+ array('value'=>'kilos', 'label'=>Mage::helper('correos')->__('Kilos')),
9
+ );
10
+ }
11
+
12
+ }
app/code/local/Ydral/Correos/Model/Quote/Address/Total/Shipping.php ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ydral_Correos_Model_Quote_Address_Total_Shipping extends Mage_Sales_Model_Quote_Address_Total_Shipping
4
+ {
5
+
6
+ public function collect(Mage_Sales_Model_Quote_Address $address)
7
+ {
8
+
9
+ parent::collect($address);
10
+
11
+ $oldWeight = $address->getWeight();
12
+ $address->setWeight(0);
13
+ $address->setFreeMethodWeight(0);
14
+ $this->_setAmount(0)
15
+ ->_setBaseAmount(0);
16
+
17
+ $items = $this->_getAddressItems($address);
18
+ if (!count($items)) {
19
+ return $this;
20
+ }
21
+
22
+ $method = $address->getShippingMethod();
23
+ $freeAddress= $address->getFreeShipping();
24
+
25
+ $addressWeight = $address->getWeight();
26
+ $freeMethodWeight = $address->getFreeMethodWeight();
27
+
28
+ $addressQty = 0;
29
+
30
+ foreach ($items as $item) {
31
+ /**
32
+ * Skip if this item is virtual
33
+ */
34
+ if ($item->getProduct()->isVirtual()) {
35
+ continue;
36
+ }
37
+
38
+ /**
39
+ * Children weight we calculate for parent
40
+ */
41
+ if ($item->getParentItem()) {
42
+ continue;
43
+ }
44
+
45
+ if ($item->getHasChildren() && $item->isShipSeparately()) {
46
+ foreach ($item->getChildren() as $child) {
47
+ if ($child->getProduct()->isVirtual()) {
48
+ continue;
49
+ }
50
+ $addressQty += $child->getTotalQty();
51
+
52
+ if (!$item->getProduct()->getWeightType()) {
53
+ $itemWeight = $child->getWeight();
54
+ $itemQty = $child->getTotalQty();
55
+ $rowWeight = $itemWeight*$itemQty;
56
+ $addressWeight += $rowWeight;
57
+ if ($freeAddress || $child->getFreeShipping()===true) {
58
+ $rowWeight = 0;
59
+ } elseif (is_numeric($child->getFreeShipping())) {
60
+ $freeQty = $child->getFreeShipping();
61
+ if ($itemQty>$freeQty) {
62
+ $rowWeight = $itemWeight*($itemQty-$freeQty);
63
+ }
64
+ else {
65
+ $rowWeight = 0;
66
+ }
67
+ }
68
+ $freeMethodWeight += $rowWeight;
69
+ $item->setRowWeight($rowWeight);
70
+ }
71
+ }
72
+ if ($item->getProduct()->getWeightType()) {
73
+ $itemWeight = $item->getWeight();
74
+ $rowWeight = $itemWeight*$item->getQty();
75
+ $addressWeight+= $rowWeight;
76
+ if ($freeAddress || $item->getFreeShipping()===true) {
77
+ $rowWeight = 0;
78
+ } elseif (is_numeric($item->getFreeShipping())) {
79
+ $freeQty = $item->getFreeShipping();
80
+ if ($item->getQty()>$freeQty) {
81
+ $rowWeight = $itemWeight*($item->getQty()-$freeQty);
82
+ }
83
+ else {
84
+ $rowWeight = 0;
85
+ }
86
+ }
87
+ $freeMethodWeight+= $rowWeight;
88
+ $item->setRowWeight($rowWeight);
89
+ }
90
+ }
91
+ else {
92
+ if (!$item->getProduct()->isVirtual()) {
93
+ $addressQty += $item->getQty();
94
+ }
95
+ $itemWeight = $item->getWeight();
96
+ $rowWeight = $itemWeight*$item->getQty();
97
+ $addressWeight+= $rowWeight;
98
+ if ($freeAddress || $item->getFreeShipping()===true) {
99
+ $rowWeight = 0;
100
+ } elseif (is_numeric($item->getFreeShipping())) {
101
+ $freeQty = $item->getFreeShipping();
102
+ if ($item->getQty()>$freeQty) {
103
+ $rowWeight = $itemWeight*($item->getQty()-$freeQty);
104
+ }
105
+ else {
106
+ $rowWeight = 0;
107
+ }
108
+ }
109
+ $freeMethodWeight+= $rowWeight;
110
+ $item->setRowWeight($rowWeight);
111
+ }
112
+ }
113
+
114
+ if (isset($addressQty)) {
115
+ $address->setItemQty($addressQty);
116
+ }
117
+
118
+ $address->setWeight($addressWeight);
119
+ $address->setFreeMethodWeight($freeMethodWeight);
120
+
121
+ $address->collectShippingRates();
122
+
123
+ $this->_setAmount(0)
124
+ ->_setBaseAmount(0);
125
+
126
+ $method = $address->getShippingMethod();
127
+
128
+ if ($method) {
129
+ foreach ($address->getAllShippingRates() as $rate) {
130
+ if ($rate->getCode()==$method) {
131
+ $amountPrice = $address->getQuote()->getStore()->convertPrice($rate->getPrice(), false);
132
+ $this->_setAmount($amountPrice);
133
+ $this->_setBaseAmount($rate->getPrice());
134
+ $shippingDescription = $rate->getCarrierTitle() . ' - ' . strip_tags($rate->getMethodTitle());
135
+ $address->setShippingDescription(trim($shippingDescription, ' -'));
136
+ break;
137
+ }
138
+ }
139
+ }
140
+
141
+ return $this;
142
+ }
143
+
144
+
145
+ }
app/code/local/Ydral/Correos/Model/System/Config/Backend/Shipping/Correos.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ydral_Correos_Model_System_Config_Backend_Shipping_Correos extends Mage_Core_Model_Config_Data
3
+ {
4
+ public function _afterSave()
5
+ {
6
+ Mage::getResourceModel('correos_shipping/carrier_correos')->uploadAndImport($this, 'envio4872');
7
+ }
8
+ }
app/code/local/Ydral/Correos/Model/System/Config/Backend/Shipping/Recoger.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ydral_Correos_Model_System_Config_Backend_Shipping_Recoger extends Mage_Core_Model_Config_Data
3
+ {
4
+ public function _afterSave()
5
+ {
6
+ Mage::getResourceModel('correos_shipping/carrier_correos')->uploadAndImport($this, 'recogeroficina');
7
+ }
8
+ }
app/code/local/Ydral/Correos/Model/Type/Onepage.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-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 Mage
22
+ * @package Mage_Checkout
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * One page checkout processing model
29
+ */
30
+ class Ydral_Correos_Model_Type_Onepage extends Mage_Checkout_Model_Type_Onepage
31
+ {
32
+
33
+ /**
34
+ * Specify quote shipping method
35
+ *
36
+ * @param string $shippingMethod
37
+ * @return array
38
+ */
39
+ public function saveShippingMethod($shippingMethod)
40
+ {
41
+
42
+ $_cp = Mage::app()->getRequest()->getPost('oficinas_correos_content_select');
43
+ if ( ($shippingMethod == 'recogeroficina_recogeroficina') && (empty($_cp)) )
44
+ {
45
+ return array('error' => -1, 'message' => $this->_helper->__('No se ha especificado una oficina de recogida.'));
46
+ }
47
+
48
+ return parent::saveShippingMethod($shippingMethod);
49
+
50
+ }
51
+
52
+ }
app/code/local/Ydral/Correos/Model/Ydral/Correos.php ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ydral_Correos_Model_Ydral_Correos extends Mage_Shipping_Model_Carrier_Abstract
3
+ {
4
+
5
+ protected $_code = 'envio4872';
6
+ protected $_default_condition_name = 'package_weight';
7
+
8
+
9
+ protected $_conditionNames = array();
10
+
11
+ public function __construct()
12
+ {
13
+ parent::__construct();
14
+ foreach ($this->getCode('condition_name') as $k=>$v) {
15
+ $this->_conditionNames[] = $k;
16
+ }
17
+ }
18
+
19
+
20
+ /**
21
+ * + visualizacion en checkout
22
+ */
23
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request)
24
+ {
25
+
26
+ if (!$this->getConfigFlag('active'))
27
+ {
28
+ return false;
29
+ }
30
+
31
+
32
+ $err = null;
33
+ $envio = array();
34
+
35
+
36
+ /**
37
+ * Free Shipping por cantidad 0.2.0
38
+ */
39
+ $freeQty = 0;
40
+ if ($request->getAllItems()) {
41
+ foreach ($request->getAllItems() as $item) {
42
+ if ($item->getProduct()->isVirtual() || $item->getParentItem()) {
43
+ continue;
44
+ }
45
+
46
+ if ($item->getHasChildren() && $item->isShipSeparately()) {
47
+ foreach ($item->getChildren() as $child) {
48
+ if ($child->getFreeShipping() && !$child->getProduct()->isVirtual()) {
49
+ $freeQty += $item->getQty() * ($child->getQty() - (is_numeric($child->getFreeShipping()) ? $child->getFreeShipping() : 0));
50
+ }
51
+ }
52
+ } elseif ($item->getFreeShipping()) {
53
+ $freeQty += ($item->getQty() - (is_numeric($item->getFreeShipping()) ? $item->getFreeShipping() : 0));
54
+ }
55
+ }
56
+ }
57
+
58
+
59
+ /**
60
+ * 0.2.0
61
+ */
62
+ if (!$request->getConditionName()) {
63
+ $request->setConditionName($this->getConfigData('condition_name') ? $this->getConfigData('condition_name') : $this->_default_condition_name);
64
+ }
65
+
66
+
67
+ // Package weight and qty free shipping
68
+ $oldWeight = $request->getPackageWeight();
69
+ $oldQty = $request->getPackageQty();
70
+
71
+
72
+ $request->setPackageWeight($request->getFreeMethodWeight());
73
+ $request->setPackageQty($oldQty - $freeQty);
74
+ $request->setMethodCode('envio4872');
75
+
76
+ $result = Mage::getModel('shipping/rate_result');
77
+ $rates = $this->getRate($request);
78
+ $rate = $rates;
79
+ //$rate = $this->getRate($request);
80
+
81
+ $request->setPackageWeight($oldWeight);
82
+ $request->setPackageQty($oldQty);
83
+
84
+
85
+
86
+ /**
87
+ *
88
+ */
89
+ if (!$request->getOrig()) {
90
+ $request->setCountryId(Mage::getStoreConfig('shipping/origin/country_id', $request->getStore()))
91
+ ->setPostcode(Mage::getStoreConfig('shipping/origin/postcode', $request->getStore()));
92
+ }
93
+
94
+
95
+
96
+ /**
97
+ *
98
+ */
99
+ $_datosEnvio['origen'] = Mage::getStoreConfig('shipping/origin/postcode', $request->getStore());
100
+
101
+ $_datosEnvio['destino'] = $request->getDestPostcode();
102
+ $_datosEnvio['peso'] = $request->getPackageWeight();
103
+ $_datosEnvio["bultos"] = 1;
104
+ $_datosEnvio["precioProducto"] = $request->getPackageValue();
105
+
106
+
107
+
108
+ if (!empty($rate) && $rate['price'] >= 0)
109
+ {
110
+ $method = Mage::getModel('shipping/rate_result_method');
111
+
112
+ $method->setCarrier($this->_code);
113
+ $method->setCarrierTitle($this->getConfigData('title'));
114
+
115
+ $method->setMethod($this->_code);
116
+ $method->setMethodTitle('<img src="'.Mage::getModel('core/design_package')->getSkinUrl('images/logo_entregadomicilio.jpg').'" alt="" title="" /><span class="title_correos_method">&nbsp;Entrega en domicilio</span>');
117
+
118
+
119
+ /**
120
+ * 0.2.0
121
+ */
122
+ if ($request->getFreeShipping() === true) {
123
+ $shippingPrice = 0;
124
+ } else {
125
+ $shippingPrice = $rate['price'];
126
+ }
127
+
128
+ $method->setPrice($shippingPrice);
129
+ $method->setCost($this->getConfigData('envio4872cost'));
130
+
131
+ $result->append($method);
132
+ }
133
+
134
+ return $result;
135
+ }
136
+
137
+ public function isTrackingAvailable()
138
+ {
139
+ return true;
140
+ }
141
+
142
+ public function getRate(Mage_Shipping_Model_Rate_Request $request)
143
+ {
144
+ return Mage::getResourceModel('correos_shipping/carrier_correos')->getRate($request);
145
+ }
146
+
147
+ public function getCode($type, $code='')
148
+ {
149
+
150
+ $codes = array(
151
+
152
+ 'condition_name'=>array(
153
+ 'package_weight' => Mage::helper('shipping')->__('Weight vs. Destination'),
154
+ 'package_value' => Mage::helper('shipping')->__('Price vs. Destination'),
155
+ 'package_qty' => Mage::helper('shipping')->__('# of Items vs. Destination'),
156
+ ),
157
+
158
+ 'condition_name_short'=>array(
159
+ 'package_weight' => Mage::helper('shipping')->__('Weight (and above)'),
160
+ 'package_value' => Mage::helper('shipping')->__('Order Subtotal (and above)'),
161
+ 'package_qty' => Mage::helper('shipping')->__('# of Items (and above)'),
162
+ ),
163
+
164
+ );
165
+
166
+ if (!isset($codes[$type])) {
167
+ throw Mage::exception('Mage_Shipping', Mage::helper('shipping')->__('Invalid Tablerate Rate code type: %s', $type));
168
+ }
169
+
170
+ if (''===$code) {
171
+ return $codes[$type];
172
+ }
173
+
174
+ if (!isset($codes[$type][$code])) {
175
+ throw Mage::exception('Mage_Shipping', Mage::helper('shipping')->__('Invalid Tablerate Rate code for type %s: %s', $type, $code));
176
+ }
177
+
178
+ return $codes[$type][$code];
179
+ }
180
+
181
+ }
app/code/local/Ydral/Correos/Model/Ydral/Recogeroficina.php ADDED
@@ -0,0 +1,403 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ydral_Correos_Model_Ydral_Recogeroficina extends Mage_Shipping_Model_Carrier_Abstract
3
+ {
4
+
5
+ protected $_code = 'recogeroficina';
6
+ public $_codigoPostal = '';
7
+
8
+ protected $_default_condition_name = 'package_weight';
9
+
10
+
11
+ protected $_conditionNames = array();
12
+
13
+ public function __construct()
14
+ {
15
+ parent::__construct();
16
+ foreach ($this->getCode('condition_name') as $k=>$v) {
17
+ $this->_conditionNames[] = $k;
18
+ }
19
+ }
20
+
21
+
22
+ /**
23
+ * + visualizacion en checkout
24
+ */
25
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request)
26
+ {
27
+
28
+ if (!$this->getConfigFlag('active'))
29
+ {
30
+ return false;
31
+ }
32
+
33
+
34
+ $err = null;
35
+ $envio = array();
36
+
37
+
38
+ /**
39
+ * Free Shipping por cantidad 0.2.0
40
+ */
41
+ $freeQty = 0;
42
+ if ($request->getAllItems()) {
43
+ foreach ($request->getAllItems() as $item) {
44
+ if ($item->getProduct()->isVirtual() || $item->getParentItem()) {
45
+ continue;
46
+ }
47
+
48
+ if ($item->getHasChildren() && $item->isShipSeparately()) {
49
+ foreach ($item->getChildren() as $child) {
50
+ if ($child->getFreeShipping() && !$child->getProduct()->isVirtual()) {
51
+ $freeQty += $item->getQty() * ($child->getQty() - (is_numeric($child->getFreeShipping()) ? $child->getFreeShipping() : 0));
52
+ }
53
+ }
54
+ } elseif ($item->getFreeShipping()) {
55
+ $freeQty += ($item->getQty() - (is_numeric($item->getFreeShipping()) ? $item->getFreeShipping() : 0));
56
+ }
57
+ }
58
+ }
59
+
60
+
61
+ /**
62
+ * 0.2.0
63
+ */
64
+ if (!$request->getConditionName()) {
65
+ $request->setConditionName($this->getConfigData('condition_name') ? $this->getConfigData('condition_name') : $this->_default_condition_name);
66
+ }
67
+
68
+
69
+ // Package weight and qty free shipping
70
+ $oldWeight = $request->getPackageWeight();
71
+ $oldQty = $request->getPackageQty();
72
+
73
+
74
+ $request->setPackageWeight($request->getFreeMethodWeight());
75
+ $request->setPackageQty($oldQty - $freeQty);
76
+ $request->setMethodCode('recogeroficina');
77
+
78
+ $result = Mage::getModel('shipping/rate_result');
79
+ $rates = $this->getRate($request);
80
+ $rate = $rates;
81
+ //$rate = $this->getRate($request);
82
+
83
+ $request->setPackageWeight($oldWeight);
84
+ $request->setPackageQty($oldQty);
85
+
86
+
87
+ /**
88
+ *
89
+ */
90
+ if (!$request->getOrig()) {
91
+ $request->setCountryId(Mage::getStoreConfig('shipping/origin/country_id', $request->getStore()))
92
+ ->setPostcode(Mage::getStoreConfig('shipping/origin/postcode', $request->getStore()));
93
+ }
94
+
95
+
96
+ /**
97
+ *
98
+ */
99
+ $_datosEnvio['origen'] = Mage::getStoreConfig('shipping/origin/postcode', $request->getStore());
100
+
101
+ $_datosEnvio['destino'] = $request->getDestPostcode();
102
+ $_datosEnvio['peso'] = $request->getPackageWeight();
103
+ $_datosEnvio["bultos"] = 1;
104
+ $_datosEnvio["precioProducto"] = $request->getPackageValue();
105
+
106
+
107
+
108
+ if (!empty($rate) && $rate['price'] >= 0)
109
+ {
110
+ $method = Mage::getModel('shipping/rate_result_method');
111
+
112
+ $method->setCarrier($this->_code);
113
+ $method->setCarrierTitle($this->getConfigData('title'));
114
+
115
+ $method->setMethod($this->_code);
116
+ $method->setMethodTitle('<img src="'.Mage::getModel('core/design_package')->getSkinUrl('images/logo_recogeroficina.jpg').'" alt="" title="" /><span class="title_correos_method">&nbsp;Entrega en oficina elegida</span>');
117
+
118
+ /**
119
+ * 0.2.0
120
+ */
121
+ if ($request->getFreeShipping() === true) {
122
+ $shippingPrice = 0;
123
+ } else {
124
+ $shippingPrice = $rate['price'];
125
+ }
126
+
127
+ $method->setPrice($shippingPrice);
128
+ $method->setCost($this->getConfigData('recogeroficinacost'));
129
+
130
+ $result->append($method);
131
+ }
132
+
133
+ $this->setCodigoPostal($request->getDestPostcode());
134
+
135
+
136
+ return $result;
137
+ }
138
+
139
+ public function setCodigoPostal($codPostal)
140
+ {
141
+ $this->_codigoPostal = $codPostal;
142
+ }
143
+
144
+ public function getCodigoPostal()
145
+ {
146
+ return $this->_codigoPostal;
147
+ }
148
+
149
+ public function isTrackingAvailable()
150
+ {
151
+ return true;
152
+ }
153
+
154
+ public function getRate(Mage_Shipping_Model_Rate_Request $request)
155
+ {
156
+ return Mage::getResourceModel('correos_shipping/carrier_correos')->getRate($request);
157
+ }
158
+
159
+
160
+ /**
161
+ * prepara el selector de oficinas en el checkout
162
+ */
163
+ public function getHtmlOficinas ($codpostal)
164
+ {
165
+
166
+ if (!$_oficinas = $this->pedirOficinas($codpostal))
167
+ {
168
+ return false;
169
+ } else {
170
+
171
+ $indice = 0;
172
+ $data = array();
173
+ foreach($_oficinas as $_data)
174
+ {
175
+
176
+ $unidad = $_data->xpath('//item/ns-980841924:unidad');
177
+ $nombre = $_data->xpath('//item/ns-980841924:nombre');
178
+ $direccion = $_data->xpath('//item/ns-980841924:direccion');
179
+ $localidad = $_data->xpath('//item/ns-980841924:descLocalidad');
180
+ $cp = $_data->xpath('//item/ns-980841924:cp');
181
+
182
+ $horariolv = $_data->xpath('//item/ns-980841924:horarioLV');
183
+ $horarios = $_data->xpath('//item/ns-980841924:horarioS');
184
+ $horariof = $_data->xpath('//item/ns-980841924:horarioF');
185
+
186
+ for ($i=0; $i < count($_oficinas); $i++)
187
+ {
188
+
189
+ $data[$i]['unidad'] = (string) $unidad[$i][0];
190
+ $data[$i]['nombre'] = (string) $nombre[$i][0];
191
+ $data[$i]['direccion'] = (string) $direccion[$i][0];
192
+ $data[$i]['localidad'] = (string) $localidad[$i][0];
193
+ $data[$i]['cp'] = (string) $cp[$i][0];
194
+ $data[$i]['horariolv'] = (string) $horariolv[$i][0];
195
+ $data[$i]['horarios'] = (string) $horarios[$i][0];
196
+ $data[$i]['horariof'] = (string) $horariof[$i][0];
197
+
198
+ }
199
+
200
+ }
201
+
202
+ $_returnJson = json_encode($data);
203
+
204
+ return $_returnJson;
205
+
206
+ }
207
+ }
208
+
209
+
210
+
211
+ /**
212
+ * devuelve los datos de la oficina cuando se pide por codigo de oficina interno
213
+ */
214
+ public function dataOficinas($codOficina, $codPostal)
215
+ {
216
+
217
+ $_oficinas = $this->pedirOficinas($codPostal);
218
+
219
+ if (!$_oficinas)
220
+ {
221
+ return false;
222
+ } else {
223
+
224
+ foreach($_oficinas as $_data)
225
+ {
226
+
227
+ $unidad = $_data->xpath('//item/ns-980841924:unidad');
228
+ $nombre = $_data->xpath('//item/ns-980841924:nombre');
229
+ $direccion = $_data->xpath('//item/ns-980841924:direccion');
230
+ $localidad = $_data->xpath('//item/ns-980841924:descLocalidad');
231
+ $cp = $_data->xpath('//item/ns-980841924:cp');
232
+
233
+ }
234
+
235
+ for ($i=0; $i < count($_oficinas); $i++)
236
+ {
237
+
238
+ $_unidad = (string) $unidad[$i];
239
+ $_nombre = (string) $nombre[$i][0];
240
+ $_direccion = (string) $direccion[$i][0];
241
+ $_localidad = (string) $localidad[$i][0];
242
+ $_cp = (string) $cp[$i][0];
243
+
244
+ if ($_unidad == $codOficina)
245
+ {
246
+ return '<strong>'.$_nombre.'</strong> - '.$_direccion.'-'.$_localidad.' ('.$_cp.')';
247
+ }
248
+
249
+ }
250
+
251
+ return "Oficina: " . $codOficina;
252
+ }
253
+
254
+ }
255
+
256
+
257
+ /**
258
+ * llama a correos para comprobar las oficinas relativas al codigo postal
259
+ *
260
+ */
261
+ protected function pedirOficinas ($codpostal)
262
+ {
263
+
264
+ if (!is_numeric($codpostal)) { return false; }
265
+ if (!Mage::getStoreConfig('correos/general/active')) return false;
266
+
267
+ $xml = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ejb="http://ejb.mauo.correos.es"><soapenv:Header/><soapenv:Body><ejb:localizadorConsulta><ejb:codigoPostal>'.$codpostal.'</ejb:codigoPostal></ejb:localizadorConsulta></soapenv:Body></soapenv:Envelope>';
268
+
269
+ $urlPeticion = Mage::getStoreConfig('carriers/recogeroficina/gateway_recoger');
270
+
271
+
272
+
273
+ // peticion curl
274
+ $ch = curl_init();
275
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
276
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
277
+ curl_setopt($ch, CURLOPT_HEADER, FALSE);
278
+ curl_setopt($ch, CURLOPT_FORBID_REUSE, TRUE);
279
+ curl_setopt($ch, CURLOPT_FRESH_CONNECT, TRUE);
280
+ curl_setopt($ch, CURLOPT_URL, $urlPeticion );
281
+ curl_setopt($ch, CURLOPT_TIMEOUT, 8);
282
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $xml );
283
+ curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
284
+ $data = curl_exec($ch);
285
+
286
+ if (curl_errno($ch)) { print curl_error($ch); return false; }
287
+ curl_close ($ch);
288
+
289
+
290
+ if ($this->is_valid_xml($data))
291
+ {
292
+ $dataXml = simplexml_load_string($data, NULL, NULL, "http://schemas.xmlsoap.org/soap/envelope/");
293
+ $dataXml->registerXPathNamespace('ns-980841924', 'http://ejb.mauo.correos.es');
294
+ return $dataXml->xpath('//item');
295
+ } else {
296
+ return false;
297
+ }
298
+
299
+ }
300
+
301
+
302
+ /**
303
+ * comprueba que el xml sea correcto
304
+ */
305
+ function is_valid_xml ($xml)
306
+ {
307
+ libxml_use_internal_errors(true);
308
+ $doc = new DOMDocument('1.0', 'utf-8');
309
+ $doc->loadXML($xml);
310
+
311
+ $errors = libxml_get_errors();
312
+
313
+ return empty($errors);
314
+ }
315
+
316
+
317
+ public function saveCheckoutData($entityType, $checkoutId, $correosRecogida, $correosOficina)
318
+ {
319
+
320
+ $tablePrefix = (string)Mage::getConfig()->getTablePrefix();
321
+
322
+ $sqlQuery = 'SELECT id FROM '.$tablePrefix.'correos_recoger_oficina WHERE entity_type = "' . $entityType . '" AND checkout_id = "' . $checkoutId . '" LIMIT 1';
323
+ $dbRead = Mage::getSingleton('core/resource')->getConnection('core_read');
324
+
325
+ $row = $dbRead->fetchAll($sqlQuery);
326
+
327
+ if (!$row)
328
+ {
329
+ $sqlQuery = 'INSERT INTO '.$tablePrefix.'correos_recoger_oficina values (\'\', ?, ?, ?, ?)';
330
+ $dbWrite = Mage::getSingleton('core/resource')->getConnection('core_write');
331
+
332
+ $dbWrite->query($sqlQuery, array($entityType, $checkoutId, $correosRecogida, addslashes($correosOficina)));
333
+
334
+ } else {
335
+
336
+ $sqlQuery = 'UPDATE '.$tablePrefix.'correos_recoger_oficina SET ' .
337
+ 'correos_recogida = "' . $correosRecogida . '", ' .
338
+ 'correos_oficina = "' . $correosOficina . '" ' .
339
+ ' WHERE checkout_id = "' . $checkoutId . '" ' .
340
+ ' AND entity_type = "' . $entityType . '" LIMIT 1';
341
+
342
+
343
+ $dbWrite = Mage::getSingleton('core/resource')->getConnection('core_write');
344
+ $dbWrite->query($sqlQuery);
345
+
346
+ }
347
+
348
+ }
349
+
350
+
351
+ public function readCheckoutData ($entityType, $checkoutId)
352
+ {
353
+
354
+ $tablePrefix = (string)Mage::getConfig()->getTablePrefix();
355
+ $sqlQuery = 'SELECT * FROM '.$tablePrefix.'correos_recoger_oficina WHERE checkout_id = "'.$checkoutId.'" AND entity_type = "'.$entityType.'" ORDER BY id DESC LIMIT 1';
356
+ $dbRead = Mage::getSingleton('core/resource')->getConnection('core_read');
357
+
358
+ $row = $dbRead->fetchAll($sqlQuery);
359
+
360
+ if (!$row)
361
+ {
362
+ return false;
363
+ } else {
364
+ return $row[0];
365
+ }
366
+
367
+ }
368
+
369
+
370
+ public function getCode($type, $code='')
371
+ {
372
+ $codes = array(
373
+
374
+ 'condition_name'=>array(
375
+ 'package_weight' => Mage::helper('shipping')->__('Weight vs. Destination'),
376
+ 'package_value' => Mage::helper('shipping')->__('Price vs. Destination'),
377
+ 'package_qty' => Mage::helper('shipping')->__('# of Items vs. Destination'),
378
+ ),
379
+
380
+ 'condition_name_short'=>array(
381
+ 'package_weight' => Mage::helper('shipping')->__('Weight (and above)'),
382
+ 'package_value' => Mage::helper('shipping')->__('Order Subtotal (and above)'),
383
+ 'package_qty' => Mage::helper('shipping')->__('# of Items (and above)'),
384
+ ),
385
+
386
+ );
387
+
388
+ if (!isset($codes[$type])) {
389
+ throw Mage::exception('Mage_Shipping', Mage::helper('shipping')->__('Invalid Table Rate code type: %s', $type));
390
+ }
391
+
392
+ if (''===$code) {
393
+ return $codes[$type];
394
+ }
395
+
396
+ if (!isset($codes[$type][$code])) {
397
+ throw Mage::exception('Mage_Shipping', Mage::helper('shipping')->__('Invalid Table Rate code for type %s: %s', $type, $code));
398
+ }
399
+
400
+ return $codes[$type][$code];
401
+ }
402
+
403
+ }
app/code/local/Ydral/Correos/Model/Ydral/Shipment.php ADDED
@@ -0,0 +1,600 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ydral_Correos_Model_Ydral_Shipment extends Mage_Sales_Model_Order_Shipment
3
+ {
4
+
5
+
6
+ protected function preregistroCorreos($xmlSend)
7
+ {
8
+
9
+ $URL=Mage::getStoreConfig('correos/general/gateway_preregistro');
10
+
11
+ $datosAcceso = Mage::getStoreConfig('correos/general/usercorreos').":".Mage::getStoreConfig('correos/general/pwdcorreos');
12
+
13
+ $ch = curl_init();
14
+ curl_setopt($ch, CURLOPT_URL, $URL);
15
+ curl_setopt($ch, CURLOPT_USERPWD, $datosAcceso);
16
+ curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
17
+
18
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
19
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
20
+
21
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
22
+ curl_setopt($ch, CURLOPT_TIMEOUT, 10);
23
+ curl_setopt($ch, CURLOPT_HEADER, FALSE);
24
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlSend);
25
+
26
+ curl_setopt($ch, CURLOPT_FORBID_REUSE, TRUE);
27
+ curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml", "SOAPAction: \"Preregistro\""));
28
+ curl_setopt($ch, CURLOPT_FRESH_CONNECT, TRUE);
29
+
30
+
31
+ $data = curl_exec($ch);
32
+
33
+ if (curl_errno($ch)) {
34
+ Mage::throwException(
35
+ Mage::helper('sales')->__('No se ha podido contactar con el servidor de Correos. Error: ' . curl_errno($ch))
36
+ );
37
+ return false;
38
+ }
39
+
40
+ curl_close($ch);
41
+
42
+ return $data;
43
+
44
+ }
45
+
46
+
47
+ public function getOficinaFromOrder ($order_id)
48
+ {
49
+
50
+ }
51
+
52
+
53
+
54
+ /**
55
+ * solicitud de peticion de datos previa a la generacion de envio
56
+ */
57
+ protected function _beforeSave()
58
+ {
59
+
60
+ $envio = array();
61
+ $_order = $this->getOrder();
62
+
63
+ /**
64
+ * solo para correos, otros metodos siguen igual
65
+ */
66
+ $number = Mage::getSingleton('core/app')->getRequest()->getPost('number');
67
+ $carrier = Mage::getSingleton('core/app')->getRequest()->getPost('carrier');
68
+
69
+ if (
70
+ ( ($_order->getShippingMethod() != 'recogeroficina_recogeroficina') && ($_order->getShippingMethod() != 'envio4872_envio4872') ) ||
71
+ ( (!empty($number)) && (!empty($carrier)) )
72
+ )
73
+ {
74
+ return parent::_beforeSave();
75
+ }
76
+
77
+
78
+ /**
79
+ * informacin de recogida
80
+ */
81
+ $_dataRecogida = Mage::getModel('correos/ydral_recogeroficina')->readCheckoutData('order', $_order->getRealOrderId());
82
+
83
+
84
+ /*
85
+ if (!$_dataRecogida)
86
+ {
87
+ return false;
88
+ }
89
+ */
90
+
91
+ $_fechaOperacion = date('d-m-Y H:i:s', strtotime($_order->getCreatedAt()));
92
+
93
+ $_remitenteNombre = substr(Mage::getStoreConfig('correos/remitente/nombre'), 0, 50);
94
+ $_remitenteApellidos = substr(Mage::getStoreConfig('correos/remitente/apellidos'), 0, 50);
95
+ $_remitenteNif = substr(Mage::getStoreConfig('correos/remitente/nif'), 0, 15);
96
+ $_remitenteEmpresa = substr(Mage::getStoreConfig('correos/remitente/empresa'), 0, 50);
97
+ $_remitentePersonacontacto = substr(Mage::getStoreConfig('correos/remitente/personacontacto'), 0, 50);
98
+ $_remitenteDireccion = substr(Mage::getStoreConfig('correos/remitente/direccion'), 0, 50);
99
+ $_remitenteLocalidad = substr(Mage::getStoreConfig('correos/remitente/localidad'), 0, 25);
100
+ $_remitenteProvincia = substr(Mage::getStoreConfig('correos/remitente/provincia'), 0, 40);
101
+ $_remitenteSms = substr(Mage::getStoreConfig('correos/remitente/telefonosms'), 0, 12);
102
+ $_remitenteCodpostal = substr(Mage::getStoreConfig('correos/remitente/codpostal'), 0, 5);
103
+ $_remitenteTelefono = substr(Mage::getStoreConfig('correos/remitente/telefono'), 0, 12);
104
+ $_remitenteEmail = substr(Mage::getStoreConfig('correos/remitente/email'), 0, 50);
105
+
106
+
107
+ if ($_remitenteNombre == '' && $_remitenteEmpresa != '')
108
+ {
109
+ $_remitenteNombre = $_remitenteEmpresa;
110
+ }
111
+
112
+ if ($this->getOrder()->getShippingMethod() == 'recogeroficina_recogeroficina')
113
+ {
114
+ $_codProductoCorreos = 'S0133';
115
+ $_modalidadEntrega = 'LS';
116
+ $_correosRecogida = "<OficinaElegida>".$_dataRecogida['correos_recogida']."</OficinaElegida>";
117
+ } elseif ($this->getOrder()->getShippingMethod() == 'envio4872_envio4872')
118
+ {
119
+ $_codProductoCorreos = 'S0132';
120
+ $_modalidadEntrega = 'ST';
121
+ $_correosRecogida = '';
122
+ }
123
+
124
+ if (Mage::getStoreConfig('correos/general/etiquetador') != '')
125
+ {
126
+ $_dataAuth = '<CodEtiquetador>'.trim(Mage::getStoreConfig('correos/general/etiquetador')).'</CodEtiquetador>';
127
+ } elseif ( (Mage::getStoreConfig('correos/general/contrato') != '') && (Mage::getStoreConfig('correos/general/numcliente') != '') ) {
128
+ $_dataAuth = '<NumContrato>'.trim(Mage::getStoreConfig('correos/general/contrato')).'</NumContrato><NumCliente>'.trim(Mage::getStoreConfig('correos/general/numcliente')).'</NumCliente>';
129
+ } else {
130
+ Mage::throwException(
131
+ Mage::helper('sales')->__('No se han definido los datos de etiquetador o usuario/password del servicio. Error.')
132
+ );
133
+ return false;
134
+ }
135
+
136
+ if (Mage::getStoreConfig('correos/paquete/seguro'))
137
+ {
138
+ $_seguroPaquete = "<ImporteSeguro>".(Mage::getStoreConfig('correos/paquete/importeseguro')*100)."</ImporteSeguro>";
139
+ } else {
140
+ $_seguroPaquete = '';
141
+ }
142
+
143
+ /**
144
+ * calculo del peso
145
+ */
146
+ $peso = 0;
147
+ foreach ($this->getAllItems() as $item) {
148
+ $peso+= $item->getOrderItem()->getWeight() * $item->getOrderItem()->getQtyShipped();
149
+ }
150
+ if (Mage::getStoreConfig('correos/paquete/peso') == 'kilos') { $peso = $peso*1000; }
151
+ $peso = intval($peso);
152
+ if ($peso == 0) { $peso = 1; } // peso minimo
153
+
154
+
155
+
156
+ /**
157
+ * validacion de datos para adaptarlos al requerido por correos
158
+ */
159
+ $_destinatarioNombre = substr($_order->getShippingAddress()->getFirstname(), 0, 50); // se coge por el tamano max de correos
160
+ $_destinatarioApellidos = substr($_order->getShippingAddress()->getLastname(), 0, 50);
161
+ $_destinatarioDireccion = substr($_order->getShippingAddress()->getStreetFull(), 0, 50);
162
+ $_destinatarioLocalidad = substr($_order->getShippingAddress()->getCity(), 0, 25);
163
+ $_destinatarioProvincia = substr($_order->getShippingAddress()->getRegion(), 0, 40);
164
+ $_destinatarioCodpostal = substr($_order->getShippingAddress()->getPostcode(), 0, 5);
165
+ $_destinatarioTelefono = substr($_order->getShippingAddress()->getTelephone(), 0, 12);
166
+ $_destinatarioEmail = substr($_order->getShippingAddress()->getEmail(), 0, 50);
167
+ $_destinatarioTelefono = substr($_order->getShippingAddress()->getTelephone(), 0, 12);
168
+ $_destinatarioSMS = substr($_order->getShippingAddress()->getTelephone(), -9); // las ultimas 9 por si pone +,0...
169
+
170
+
171
+ if (
172
+ (strlen(trim($_destinatarioSMS)) == 0) ||
173
+ ( (substr($_destinatarioSMS, 0, 1) != 6) && (substr($_destinatarioSMS, 0, 1) != 7) )
174
+ )
175
+ {
176
+ Mage::throwException(
177
+ Mage::helper('sales')->__('No se puede registrar un pedido con el n&uacute;mero de tel&eacute;fono aportado, porque no se podr&aacute; notificar a este n&uacute;mero: ' . $_destinatarioSMS)
178
+ );
179
+ return false;
180
+ }
181
+
182
+
183
+
184
+ /**
185
+ * xml de peticion
186
+ */
187
+ $xmlSend = <<<XML
188
+ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://www.correos.es/iris6/services/preregistroetiquetas">
189
+ <soapenv:Header/>
190
+ <soapenv:Body>
191
+ <PreregistroEnvio>
192
+ <fechaOperacion>{$_fechaOperacion}</fechaOperacion>
193
+ {$_dataAuth}
194
+ <ModDevEtiqueta>2</ModDevEtiqueta>
195
+ <Care>000000</Care>
196
+ <TotalBultos>1</TotalBultos>
197
+ <Remitente>
198
+ <Identificacion>
199
+ <Nombre><![CDATA[{$_remitenteNombre}]]></Nombre>
200
+ <Apellido1><![CDATA[{$_remitenteApellidos}]]></Apellido1>
201
+ <Apellido2></Apellido2>
202
+ <Nif><![CDATA[{$_remitenteNif}]]></Nif>
203
+ </Identificacion>
204
+ <DatosDireccion>
205
+ <Direccion><![CDATA[{$_remitenteDireccion}]]></Direccion>
206
+ <Numero></Numero>
207
+ <Piso></Piso>
208
+ <Puerta></Puerta>
209
+ <Localidad><![CDATA[{$_remitenteLocalidad}]]></Localidad>
210
+ <Provincia><![CDATA[{$_remitenteProvincia}]]></Provincia>
211
+ </DatosDireccion>
212
+ <CP><![CDATA[{$_remitenteCodpostal}]]></CP>
213
+ <Telefonocontacto><![CDATA[{$_remitenteTelefono}]]></Telefonocontacto>
214
+ <Email><![CDATA[{$_remitenteEmail}]]></Email>
215
+ <DatosSMS>
216
+ <NumeroSMS><![CDATA[{$_remitenteSms}]]></NumeroSMS>
217
+ <Idioma>1</Idioma>
218
+ </DatosSMS>
219
+ </Remitente>
220
+ <Destinatario>
221
+ <Identificacion>
222
+ <Nombre><![CDATA[{$_destinatarioNombre}]]></Nombre>
223
+ <Apellido1><![CDATA[{$_destinatarioApellidos}]]></Apellido1>
224
+ <Apellido2></Apellido2>
225
+ </Identificacion>
226
+ <DatosDireccion>
227
+ <Direccion><![CDATA[{$_destinatarioDireccion}]]></Direccion>
228
+ <Numero></Numero>
229
+ <Piso></Piso>
230
+ <Puerta></Puerta>
231
+ <Localidad><![CDATA[{$_destinatarioLocalidad}]]></Localidad>
232
+ <Provincia><![CDATA[{$_destinatarioProvincia}]]></Provincia>
233
+ </DatosDireccion>
234
+ <CP><![CDATA[{$_destinatarioCodpostal}]]></CP>
235
+ <Telefonocontacto><![CDATA[{$_destinatarioTelefono}]]></Telefonocontacto>
236
+ <Email><![CDATA[{$_destinatarioEmail}]]></Email>
237
+ <DatosSMS>
238
+ <NumeroSMS><![CDATA[{$_destinatarioSMS}]]></NumeroSMS>
239
+ <Idioma>1</Idioma>
240
+ </DatosSMS>
241
+ </Destinatario>
242
+ <Envio>
243
+ <CodProducto>{$_codProductoCorreos}</CodProducto>
244
+ <ReferenciaCliente>{$_order->getIncrementId()}</ReferenciaCliente>
245
+ <TipoFranqueo>FP</TipoFranqueo>
246
+ <ModalidadEntrega>{$_modalidadEntrega}</ModalidadEntrega>
247
+ {$_correosRecogida}
248
+ <Pesos>
249
+ <Peso>
250
+ <TipoPeso>R</TipoPeso>
251
+ <Valor>{$peso}</Valor>
252
+ </Peso>
253
+ </Pesos>
254
+ <Largo>0</Largo>
255
+ <Alto>0</Alto>
256
+ <Ancho>0</Ancho>
257
+ <ValoresAnadidos>
258
+ {$_seguroPaquete}
259
+ </ValoresAnadidos>
260
+ <Aduana>
261
+ <TipoEnvio>2</TipoEnvio>
262
+ </Aduana>
263
+ </Envio>
264
+ </PreregistroEnvio>
265
+ </soapenv:Body>
266
+ </soapenv:Envelope>
267
+ XML;
268
+
269
+
270
+ // peticion
271
+ $peticionCorreos = $this->preregistroCorreos($xmlSend);
272
+
273
+ try
274
+ {
275
+
276
+ if ($peticionCorreos == '')
277
+ {
278
+ Mage::throwException(
279
+ Mage::helper('sales')->__('No se ha podido contacto con el servidor de Correos. Respuesta vac&iacute;a.')
280
+ );
281
+ return false;
282
+ }
283
+
284
+
285
+
286
+ $dataXml = simplexml_load_string($peticionCorreos);
287
+
288
+
289
+ if (!$dataXml->registerXPathNamespace('respuesta', 'http://www.correos.es/iris6/services/preregistroetiquetas'))
290
+ {
291
+ // ha devuelto un error;
292
+ Mage::throwException(
293
+ Mage::helper('sales')->__('Error en los datos devueltos por Correos.')
294
+ );
295
+ return false;
296
+ }
297
+
298
+ $_codExpedicion = $dataXml->xpath('//respuesta:CodExpedicion');
299
+ $_codEnvio = $dataXml->xpath('//respuesta:Bulto');
300
+ $_codError = $dataXml->xpath('//respuesta:Resultado');
301
+
302
+
303
+
304
+ if ($_codError[0] == '0')
305
+ {
306
+ // correcto
307
+ $_datosBulto = $dataXml->xpath('//respuesta:Bulto');
308
+ Mage::getSingleton('adminhtml/session')->addNotice('Se ha creado la etiqueta de env&iacute;o para Correos.');
309
+ Mage::getSingleton('adminhtml/session')->addNotice('C&oacute;digo de expedici&oacute;n: ' . $_codExpedicion[0]);
310
+ Mage::getSingleton('adminhtml/session')->addNotice('C&oacute;digo de env&iacute;o: ' . $_codEnvio[0]->CodEnvio);
311
+
312
+ $track = Mage::getModel('sales/order_shipment_track')
313
+ ->setNumber($_codEnvio[0]->CodEnvio)
314
+ ->setCarrierCode($_order->getShippingCarrier()->getCarrierCode())
315
+ ->setTitle('Seguimiento Correos');
316
+
317
+ $this->addTrack($track);
318
+
319
+ } else {
320
+
321
+ $_msjError = $dataXml->xpath('//respuesta:DescError');
322
+
323
+ // error
324
+ Mage::throwException(
325
+ Mage::helper('sales')->__('Error en la creaci&oacute;n de la operaci&oacute;n de preregistro: ' . $_msjError[0])
326
+ );
327
+ return false;
328
+
329
+ }
330
+
331
+
332
+ $canSave = parent::_beforeSave();
333
+ return $canSave;
334
+
335
+
336
+ } catch (Exception $e) {
337
+ if (!$e->getMessage())
338
+ {
339
+ Mage::throwException(
340
+ Mage::helper('sales')->__('No se ha podido contactar con el servidor de Correos.')
341
+ );
342
+ } else {
343
+ Mage::throwException($e->getMessage());
344
+ }
345
+ }
346
+
347
+
348
+
349
+
350
+
351
+ }
352
+
353
+
354
+ private function getConfigData ($indice, $mandatory = false)
355
+ {
356
+
357
+ if ( (Mage::getStoreConfig($indice) == '') && $mandatory)
358
+ {
359
+ return false;
360
+ } else {
361
+ return Mage::getStoreConfig($indice);
362
+ }
363
+
364
+ }
365
+
366
+
367
+ public function getEtiquetaRemote ($order_id, $codEnvio)
368
+ {
369
+
370
+ $_order = Mage::getModel('sales/order')->load($order_id);
371
+
372
+ $_fechaOperacion = date('d-m-Y H:i:s', strtotime($_order->getCreatedAt()));
373
+
374
+ if (Mage::getStoreConfig('correos/general/etiquetador') != '')
375
+ {
376
+ $_dataAuth = '<CodEtiquetador>'.trim(Mage::getStoreConfig('correos/general/etiquetador')).'</CodEtiquetador>';
377
+ } elseif ( (Mage::getStoreConfig('correos/general/contrato') != '') && (Mage::getStoreConfig('correos/general/numcliente') != '') ) {
378
+ $_dataAuth = '<NumContrato>'.trim(Mage::getStoreConfig('correos/general/contrato')).'</NumContrato><NumCliente>'.trim(Mage::getStoreConfig('correos/general/numcliente')).'</NumCliente>';
379
+ } else {
380
+ Mage::throwException(
381
+ Mage::helper('sales')->__('No se han definido los datos de etiquetador o usuario/password del servicio. Error.')
382
+ );
383
+ return false;
384
+ }
385
+
386
+ $xmlSend = <<<XML
387
+ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://www.correos.es/iris6/services/preregistroetiquetas">
388
+ <soapenv:Header/>
389
+ <soapenv:Body>
390
+ <SolicitudEtiqueta>
391
+ <fechaOperacion>{$_fechaOperacion}</fechaOperacion>
392
+ {$_dataAuth}
393
+ <CodEnvio>{$codEnvio}</CodEnvio>
394
+ <Care>000000</Care>
395
+ <ModDevEtiqueta>2</ModDevEtiqueta>
396
+ </SolicitudEtiqueta>
397
+ </soapenv:Body>
398
+ </soapenv:Envelope>
399
+ XML;
400
+
401
+
402
+ $URL=Mage::getStoreConfig('correos/general/gateway_preregistro');
403
+
404
+ $datosAcceso = Mage::getStoreConfig('correos/general/usercorreos').":".Mage::getStoreConfig('correos/general/pwdcorreos');
405
+
406
+ $ch = curl_init();
407
+ curl_setopt($ch, CURLOPT_URL, $URL);
408
+ curl_setopt($ch, CURLOPT_USERPWD, $datosAcceso);
409
+ curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
410
+
411
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
412
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
413
+
414
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
415
+ curl_setopt($ch, CURLOPT_TIMEOUT, 10);
416
+ curl_setopt($ch, CURLOPT_HEADER, FALSE);
417
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlSend);
418
+
419
+ curl_setopt($ch, CURLOPT_FORBID_REUSE, TRUE);
420
+ curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml", "SOAPAction: \"SolicitudEtiquetaOp\""));
421
+ curl_setopt($ch, CURLOPT_FRESH_CONNECT, TRUE);
422
+
423
+
424
+
425
+ $data = curl_exec($ch);
426
+
427
+ if (curl_errno($ch)) {
428
+ Mage::throwException(
429
+ Mage::helper('sales')->__('No se ha podido contacto con el servidor de Correos. Error: ' . curl_errno($ch))
430
+ );
431
+ return false;
432
+ //echo curl_errno($ch);
433
+ }
434
+
435
+ curl_close($ch);
436
+
437
+
438
+ $dataXml = simplexml_load_string($data);
439
+ $dataXml->registerXPathNamespace('respuesta', 'http://www.correos.es/iris6/services/preregistroetiquetas');
440
+
441
+ $_codExpedicion = $dataXml->xpath('//respuesta:CodExpedicion');
442
+ $_codError = $dataXml->xpath('//respuesta:Resultado');
443
+
444
+ if ($_codError[0] == '0')
445
+ {
446
+ // correcto
447
+ $_datosBulto = $dataXml->xpath('//respuesta:Bulto');
448
+ return $_datosBulto;
449
+
450
+ } else {
451
+ // error
452
+ return false;
453
+ }
454
+
455
+
456
+ }
457
+
458
+
459
+ /**
460
+ *
461
+ */
462
+ public function localizarEnvioUltimo ($codEnvio)
463
+ {
464
+
465
+ $xml = '<?xml version="1.0" encoding="utf-8" ?><ConsultaXMLin Idioma="1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><Consulta><Codigo>'.$codEnvio.'</Codigo></Consulta></ConsultaXMLin>';
466
+
467
+
468
+ $xmlSend = <<<XML
469
+ <?xml version="1.0" encoding="utf-8"?>
470
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
471
+ <soap:Body>
472
+ <ConsultaLocalizacionEnviosFasesMasivo xmlns="ServiciosWebLocalizacionMI/">
473
+ <XMLin><![CDATA[{$xml}]]></XMLin>
474
+ </ConsultaLocalizacionEnviosFasesMasivo>
475
+ </soap:Body>
476
+ </soap:Envelope>
477
+ XML;
478
+
479
+ $ch = curl_init();
480
+ curl_setopt($ch, CURLOPT_URL, Mage::getStoreConfig('correos/general/gateway_localizacion'));
481
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
482
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
483
+
484
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
485
+ curl_setopt($ch, CURLOPT_TIMEOUT, 10);
486
+ curl_setopt($ch, CURLOPT_HEADER, FALSE);
487
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlSend);
488
+ curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml", "SOAPAction: ServiciosWebLocalizacionMI/ConsultaLocalizacionEnviosFasesMasivo"));
489
+ curl_setopt($ch, CURLOPT_FORBID_REUSE, TRUE);
490
+ curl_setopt($ch, CURLOPT_FRESH_CONNECT, TRUE);
491
+
492
+
493
+ try
494
+ {
495
+ $data = curl_exec($ch);
496
+
497
+ if (curl_errno($ch)) {
498
+ Mage::throwException(
499
+ Mage::helper('sales')->__('No se ha podido contactar con el servidor de Correos. Error: ' . curl_errno($ch))
500
+ );
501
+ return false;
502
+ }
503
+
504
+ $dataXml = simplexml_load_string($data);
505
+ $dataXml->registerXPathNamespace('respuesta', 'ServiciosWebLocalizacionMI/');
506
+ $_respuesta = $dataXml->xpath('//respuesta:ConsultaLocalizacionEnviosFasesMasivoResult');
507
+
508
+
509
+ $_respuestaXml = simplexml_load_string($_respuesta[0]);
510
+ $respuesta = $_respuestaXml->xpath('//Respuestas/DatosIdiomas/DatosEnvios/Datos');
511
+
512
+ $_estado = (string) $respuesta[0]->Estado;
513
+ $_fecha = (string) $respuesta[0]->Fecha;
514
+
515
+ } catch (Exception $e) {
516
+ /*
517
+ Mage::throwException(
518
+ Mage::helper('sales')->__('No se ha podido contactar con el servidor de localizaci&oacute;n de Correos.')
519
+ );
520
+ return false;
521
+ */
522
+ return "Datos no disponibles temporalmente.";
523
+ }
524
+
525
+ return utf8_decode($_estado . " [" . $_fecha . "]");
526
+
527
+ }
528
+
529
+
530
+ /**
531
+ *
532
+ */
533
+ public function localizarEnvioFases ($codEnvio)
534
+ {
535
+
536
+ $xml = '<?xml version="1.0" encoding="utf-8" ?><ConsultaXMLin Idioma="1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><Consulta><Codigo>'.$codEnvio.'</Codigo></Consulta></ConsultaXMLin>';
537
+
538
+
539
+ $xmlSend = <<<XML
540
+ <?xml version="1.0" encoding="utf-8"?>
541
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
542
+ <soap:Body>
543
+ <ConsultaLocalizacionEnviosFases xmlns="ServiciosWebLocalizacionMI/">
544
+ <XMLin><![CDATA[{$xml}]]></XMLin>
545
+ </ConsultaLocalizacionEnviosFases>
546
+ </soap:Body>
547
+ </soap:Envelope>
548
+ XML;
549
+
550
+ $ch = curl_init();
551
+ curl_setopt($ch, CURLOPT_URL, Mage::getStoreConfig('correos/general/gateway_localizacion'));
552
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
553
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
554
+
555
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
556
+ curl_setopt($ch, CURLOPT_TIMEOUT, 10);
557
+ curl_setopt($ch, CURLOPT_HEADER, FALSE);
558
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlSend);
559
+ curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml", "SOAPAction: ServiciosWebLocalizacionMI/ConsultaLocalizacionEnviosFases"));
560
+ curl_setopt($ch, CURLOPT_FORBID_REUSE, TRUE);
561
+ curl_setopt($ch, CURLOPT_FRESH_CONNECT, TRUE);
562
+
563
+
564
+ try
565
+ {
566
+ $data = curl_exec($ch);
567
+
568
+ if (curl_errno($ch)) {
569
+ Mage::throwException(
570
+ Mage::helper('sales')->__('No se ha podido contactar con el servidor de Correos. Error: ' . curl_errno($ch))
571
+ );
572
+ return false;
573
+ }
574
+
575
+ $dataXml = simplexml_load_string($data);
576
+ $dataXml->registerXPathNamespace('respuesta', 'ServiciosWebLocalizacionMI/');
577
+ $_respuesta = $dataXml->xpath('//respuesta:ConsultaLocalizacionEnviosFasesResult');
578
+
579
+
580
+ $_respuestaXml = simplexml_load_string($_respuesta[0]);
581
+ $respuesta = $_respuestaXml->xpath('//Respuestas/DatosIdiomas/DatosEnvios/Datos');
582
+
583
+ } catch (Exception $e) {
584
+ /*
585
+ Mage::throwException(
586
+ Mage::helper('sales')->__('No se ha podido contactar con el servidor de Correos para el seguimiento del pedido.')
587
+ );
588
+ return false;
589
+ */
590
+ return "Datos no disponibles temporalmente.";
591
+ }
592
+
593
+
594
+ return $respuesta;
595
+
596
+ }
597
+
598
+
599
+
600
+ }
app/code/local/Ydral/Correos/controllers/IndexController.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ydral_Correos_IndexController extends Mage_Core_Controller_Front_Action
4
+ {
5
+
6
+ public function getdataAction()
7
+ {
8
+
9
+ if ($this->getRequest()->isPost())
10
+ {
11
+
12
+ if ($this->getRequest()->getPost('codigoPostal') == '')
13
+ {
14
+ $codigoPostal = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getPostcode();
15
+ } else {
16
+ $codigoPostal = $this->getRequest()->getPost('codigoPostal');
17
+ }
18
+
19
+ if (!empty($codigoPostal))
20
+ {
21
+ $_htmlOficinas = Mage::getModel('correos/ydral_recogeroficina')->getHtmlOficinas($codigoPostal);
22
+ $this->getResponse()->setBody($_htmlOficinas);
23
+ }
24
+
25
+ }
26
+
27
+ }
28
+
29
+
30
+ public function downloadEtiquetaAction()
31
+ {
32
+
33
+ $etiquetaId = $this->getRequest()->getParam('etiqueta', false);
34
+ $orderId = $this->getRequest()->getParam('order', false);
35
+
36
+
37
+ if ($etiquetaId && $orderId)
38
+ {
39
+ $dataPdf = Mage::getModel('correos/ydral_shipment')->getEtiquetaRemote($orderId, $etiquetaId);
40
+ $this->_prepareDownloadResponse($dataPdf[0]->Etiqueta->Etiqueta_pdf->NombreF, base64_decode($dataPdf[0]->Etiqueta->Etiqueta_pdf->Fichero), 'application/pdf');
41
+ }
42
+
43
+ }
44
+ }
app/code/local/Ydral/Correos/controllers/Sales/Order/ShipmentController.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once 'Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php';
4
+
5
+ class Ydral_Correos_Sales_Order_ShipmentController extends Mage_Adminhtml_Sales_Order_ShipmentController
6
+ {
7
+
8
+ public function addTrackAction()
9
+ {
10
+
11
+ try {
12
+
13
+ $carrier = $this->getRequest()->getPost('carrier');
14
+ $number = $this->getRequest()->getPost('number');
15
+ $title = $this->getRequest()->getPost('title');
16
+ if (empty($carrier)) {
17
+ Mage::throwException($this->__('The carrier needs to be specified.'));
18
+ }
19
+ if (empty($number)) {
20
+ Mage::throwException($this->__('Tracking number cannot be empty.'));
21
+ }
22
+ $shipment = $this->_initShipment();
23
+
24
+ if ($shipment) {
25
+ $track = Mage::getModel('sales/order_shipment_track')
26
+ ->setNumber($number)
27
+ ->setCarrierCode($carrier)
28
+ ->setTitle($title);
29
+ $shipment->addTrack($track)
30
+ ->save();
31
+
32
+ $this->loadLayout();
33
+ $response = $this->getLayout()->getBlock('shipment_tracking')->toHtml();
34
+ } else {
35
+ $response = array(
36
+ 'error' => true,
37
+ 'message' => $this->__('Cannot initialize shipment for adding tracking number.'),
38
+ );
39
+ }
40
+ } catch (Mage_Core_Exception $e) {
41
+ $response = array(
42
+ 'error' => true,
43
+ 'message' => $e->getMessage(),
44
+ );
45
+ } catch (Exception $e) {
46
+ $response = array(
47
+ 'error' => true,
48
+ 'message' => $this->__('Cannot add tracking number.'),
49
+ );
50
+ }
51
+ if (is_array($response)) {
52
+ $response = Mage::helper('core')->jsonEncode($response);
53
+ }
54
+ $this->getResponse()->setBody($response);
55
+ }
56
+
57
+ }
app/code/local/Ydral/Correos/controllers/TrackingController.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ydral_Correos_TrackingController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ /**
6
+ *
7
+ */
8
+ public function popupAction()
9
+ {
10
+ $shippingInfoModel = Mage::getModel('shipping/info')->loadByHash($this->getRequest()->getParam('hash'));
11
+ Mage::register('current_shipping_info', $shippingInfoModel);
12
+ if (count($shippingInfoModel->getTrackingInfo()) == 0) {
13
+ $this->norouteAction();
14
+ return;
15
+ }
16
+ $this->loadLayout();
17
+ $this->renderLayout();
18
+ }
19
+ }
app/code/local/Ydral/Correos/etc/config.xml ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <modules>
5
+ <Ydral_Correos>
6
+ <version>0.4.0</version>
7
+ </Ydral_Correos>
8
+ </modules>
9
+ <global>
10
+
11
+ <blocks>
12
+ <correos>
13
+ <class>Ydral_Correos_Block</class>
14
+ </correos>
15
+ <sales>
16
+ <rewrite>
17
+ <order_info>Ydral_Correos_Block_Order_Info</order_info>
18
+ <order_view>Ydral_Correos_Block_Order_View</order_view>
19
+ <order_shipment>Ydral_Correos_Block_Order_Shipment</order_shipment>
20
+ </rewrite>
21
+ </sales>
22
+ <checkout>
23
+ <rewrite>
24
+ <onepage_shipping_method_available>Ydral_Correos_Block_Onepage_Shipping_Method_Available</onepage_shipping_method_available>
25
+ </rewrite>
26
+ </checkout>
27
+ </blocks>
28
+
29
+ <helpers>
30
+ <!-- Mage::helper('correos') -->
31
+ <correos>
32
+ <class>Ydral_Correos_Helper</class>
33
+ </correos>
34
+ <onestepcheckout>
35
+ <rewrite>
36
+ <checkout>Ydral_Correos_Helper_Onestepcheckout</checkout>
37
+ </rewrite>
38
+ </onestepcheckout>
39
+ </helpers>
40
+
41
+ <models>
42
+ <!-- Mage::getModel('correos/correos') -->
43
+ <correos>
44
+ <class>Ydral_Correos_Model</class>
45
+ </correos>
46
+ <sales>
47
+ <rewrite>
48
+ <order_shipment>Ydral_Correos_Model_Ydral_Shipment</order_shipment>
49
+ <quote_address_total_shipping>Ydral_Correos_Model_Quote_Address_Total_Shipping</quote_address_total_shipping>
50
+ </rewrite>
51
+ </sales>
52
+
53
+ <checkout>
54
+ <rewrite>
55
+ <type_onepage>Ydral_Correos_Model_Type_Onepage</type_onepage>
56
+ </rewrite>
57
+ </checkout>
58
+
59
+ <correos_shipping>
60
+ <class>Ydral_Correos_Model</class>
61
+ <resourceModel>correos_mysql4</resourceModel>
62
+ </correos_shipping>
63
+
64
+ <correos_mysql4>
65
+ <class>Ydral_Correos_Model_Mysql4</class>
66
+ <entities>
67
+ <correos>
68
+ <table>correos_shipping</table>
69
+ </correos>
70
+ <recoger>
71
+ <table>correos_recoger</table>
72
+ </recoger>
73
+ </entities>
74
+ </correos_mysql4>
75
+
76
+ </models>
77
+
78
+ <resources>
79
+ <!-- Mage::getResourceModel('correos/correos') or Mage::getResourceSingleton('correos/correos') -->
80
+ <correos_setup>
81
+ <setup>
82
+ <module>Ydral_Correos</module>
83
+ </setup>
84
+ <connection>
85
+ <use>core_setup</use>
86
+ </connection>
87
+ </correos_setup>
88
+ <correos_read>
89
+ <connection>
90
+ <use>core_read</use>
91
+ </connection>
92
+ </correos_read>
93
+ <correos_write>
94
+ <connection>
95
+ <use>core_write</use>
96
+ </connection>
97
+ </correos_write>
98
+ </resources>
99
+
100
+
101
+
102
+ </global>
103
+
104
+ <frontend>
105
+ <routers>
106
+ <correos>
107
+ <use>standard</use>
108
+ <args>
109
+ <module>Ydral_Correos</module>
110
+ <frontName>correos</frontName>
111
+ </args>
112
+ </correos>
113
+ </routers>
114
+ <layout>
115
+ <updates>
116
+ <Correos>
117
+ <file>correos.xml</file>
118
+ </Correos>
119
+ </updates>
120
+ </layout>
121
+ <events>
122
+ <checkout_controller_onepage_save_shipping_method>
123
+ <observers>
124
+ <ydral_correos_shipping_observer>
125
+ <type>model</type>
126
+ <class>Ydral_Correos_Helper_Data</class>
127
+ <method>setOficinaCorreosRecogida</method>
128
+ </ydral_correos_shipping_observer>
129
+ </observers>
130
+ </checkout_controller_onepage_save_shipping_method>
131
+ <checkout_onepage_controller_success_action>
132
+ <observers>
133
+ <ydral_correos_order_observer>
134
+ <type>model</type>
135
+ <class>Ydral_Correos_Helper_Data</class>
136
+ <method>setOficinaCorreosRecogidaOrder</method>
137
+ </ydral_correos_order_observer>
138
+ </observers>
139
+ </checkout_onepage_controller_success_action>
140
+ </events>
141
+ </frontend>
142
+ <adminhtml>
143
+ <layout>
144
+ <updates>
145
+ <correos>
146
+ <file>correos.xml</file>
147
+ </correos>
148
+ </updates>
149
+ </layout>
150
+ <acl>
151
+ <resources>
152
+ <admin>
153
+ <children>
154
+ <system>
155
+ <children>
156
+ <config>
157
+ <children>
158
+ <correos translate="title" module="correos">
159
+ <title><![CDATA[Correos Configuraci&oacute;n]]></title>
160
+ </correos>
161
+ </children>
162
+ </config>
163
+ </children>
164
+ </system>
165
+ </children>
166
+ </admin>
167
+ </resources>
168
+ </acl>
169
+ </adminhtml>
170
+ <admin>
171
+ <routers>
172
+ <correos>
173
+ <use>admin</use>
174
+ <args>
175
+ <module>Ydral_Correos</module>
176
+ <frontName>correos</frontName>
177
+ </args>
178
+ </correos>
179
+ <adminhtml>
180
+ <args>
181
+ <modules>
182
+ <!-- <ydral_correos before="Mage_Adminhtml">Ydral_Correos_Registro</ydral_correos> -->
183
+ <ydral_correos before="Mage_Adminhtml">Ydral_Correos</ydral_correos>
184
+ </modules>
185
+ </args>
186
+ </adminhtml>
187
+ </routers>
188
+ </admin>
189
+ <default>
190
+ <correos>
191
+ <general>
192
+ <active>0</active>
193
+ <gateway_preregistro>https://preregistroenvios.correos.es/preregistroenvios</gateway_preregistro>
194
+ <gateway_localizacion>https://online.correos.es/servicioswebLocalizacionMI/localizacionMI.asmx</gateway_localizacion>
195
+ </general>
196
+ </correos>
197
+ <carriers>
198
+ <envio4872>
199
+ <active>0</active>
200
+ <title><![CDATA[Entrega en su domicilio en 2-3 d&iacute;as]]></title>
201
+ <model>correos/ydral_correos</model>
202
+ </envio4872>
203
+ <recogeroficina>
204
+ <active>0</active>
205
+ <title><![CDATA[Recogida en la Oficina de Correos que vd. elija en 2-3 d&iacute;as]]></title>
206
+ <model>correos/ydral_recogeroficina</model>
207
+ <gateway_recoger>http://localizadoroficinas.correos.es/localizadoroficinas</gateway_recoger>
208
+ </recogeroficina>
209
+ </carriers>
210
+ </default>
211
+ </config>
app/code/local/Ydral/Correos/etc/system.xml ADDED
@@ -0,0 +1,488 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <correos translate="label" module="correos">
5
+ <label><![CDATA[Correos Configuraci&oacute;n]]></label>
6
+ <tab>sales</tab>
7
+ <sort_order>330</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
+ <class>correos-section</class>
12
+ <header_css>correos-header</header_css>
13
+ <groups>
14
+ <general translate="label">
15
+ <label>General</label>
16
+ <frontend_type>text</frontend_type>
17
+ <sort_order>10</sort_order>
18
+ <show_in_default>1</show_in_default>
19
+ <show_in_website>1</show_in_website>
20
+ <show_in_store>1</show_in_store>
21
+ <fields>
22
+ <active translate="label">
23
+ <label>Enabled</label>
24
+ <frontend_type>select</frontend_type>
25
+ <source_model>adminhtml/system_config_source_yesno</source_model>
26
+ <sort_order>1</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
+ </active>
31
+ <etiquetador translate="label comment">
32
+ <label><![CDATA[C&oacute;digo de etiquetador]]></label>
33
+ <frontend_type>text</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
+ </etiquetador>
39
+ <contrato translate="label comment">
40
+ <label><![CDATA[N&uacute;mero de contrato]]></label>
41
+ <frontend_type>text</frontend_type>
42
+ <comment><![CDATA[Obligatorio si no dispone de c&oacute;digo de etiquetador]]></comment>
43
+ <sort_order>4</sort_order>
44
+ <show_in_default>1</show_in_default>
45
+ <show_in_website>1</show_in_website>
46
+ <show_in_store>1</show_in_store>
47
+ </contrato>
48
+ <numcliente translate="label comment">
49
+ <label><![CDATA[N&uacute;mero de cliente]]></label>
50
+ <comment><![CDATA[Obligatorio si no dispone de c&oacute;digo de etiquetador]]></comment>
51
+ <frontend_type>text</frontend_type>
52
+ <sort_order>5</sort_order>
53
+ <show_in_default>1</show_in_default>
54
+ <show_in_website>1</show_in_website>
55
+ <show_in_store>1</show_in_store>
56
+ </numcliente>
57
+ <usercorreos translate="label comment">
58
+ <label><![CDATA[Usuario de Correos]]></label>
59
+ <comment><![CDATA[Usuario para la pasarela]]></comment>
60
+ <frontend_type>text</frontend_type>
61
+ <sort_order>6</sort_order>
62
+ <show_in_default>1</show_in_default>
63
+ <show_in_website>1</show_in_website>
64
+ <show_in_store>1</show_in_store>
65
+ </usercorreos>
66
+ <pwdcorreos translate="label comment">
67
+ <label><![CDATA[Password de Correos]]></label>
68
+ <frontend_type>text</frontend_type>
69
+ <comment><![CDATA[Password para la pasarela]]></comment>
70
+ <sort_order>7</sort_order>
71
+ <show_in_default>1</show_in_default>
72
+ <show_in_website>1</show_in_website>
73
+ <show_in_store>1</show_in_store>
74
+ </pwdcorreos>
75
+ <gateway_preregistro translate="label">
76
+ <label>URL datos</label>
77
+ <default></default>
78
+ <frontend_type>text</frontend_type>
79
+ <sort_order>60</sort_order>
80
+ <show_in_default>1</show_in_default>
81
+ <show_in_website>1</show_in_website>
82
+ <show_in_store>1</show_in_store>
83
+ <comment><![CDATA[Solo modificar si Correos lo indica]]></comment>
84
+ </gateway_preregistro>
85
+ <gateway_localizacion translate="label">
86
+ <label><![CDATA[URL localizaci&oacute;n]]></label>
87
+ <default></default>
88
+ <frontend_type>text</frontend_type>
89
+ <sort_order>70</sort_order>
90
+ <show_in_default>1</show_in_default>
91
+ <show_in_website>1</show_in_website>
92
+ <show_in_store>1</show_in_store>
93
+ <comment><![CDATA[Solo modificar si Correos lo indica]]></comment>
94
+ </gateway_localizacion>
95
+ </fields>
96
+ </general>
97
+ <remitente translate="label">
98
+ <label>Datos del remitente</label>
99
+ <frontend_type>text</frontend_type>
100
+ <sort_order>20</sort_order>
101
+ <show_in_default>1</show_in_default>
102
+ <show_in_website>1</show_in_website>
103
+ <show_in_store>1</show_in_store>
104
+ <fields>
105
+ <nombre translate="label">
106
+ <label>Nombre del remitente</label>
107
+ <frontend_type>text</frontend_type>
108
+ <sort_order>1</sort_order>
109
+ <show_in_default>1</show_in_default>
110
+ <show_in_website>1</show_in_website>
111
+ <show_in_store>1</show_in_store>
112
+ </nombre>
113
+ <apellidos translate="label">
114
+ <label>Apellidos del remitente</label>
115
+ <frontend_type>text</frontend_type>
116
+ <sort_order>2</sort_order>
117
+ <show_in_default>1</show_in_default>
118
+ <show_in_website>1</show_in_website>
119
+ <show_in_store>1</show_in_store>
120
+ </apellidos>
121
+ <nif translate="label">
122
+ <label>DNI/NIF</label>
123
+ <frontend_type>text</frontend_type>
124
+ <sort_order>3</sort_order>
125
+ <show_in_default>1</show_in_default>
126
+ <show_in_website>1</show_in_website>
127
+ <show_in_store>1</show_in_store>
128
+ </nif>
129
+ <empresa translate="label">
130
+ <label>Empresa</label>
131
+ <frontend_type>text</frontend_type>
132
+ <sort_order>4</sort_order>
133
+ <show_in_default>1</show_in_default>
134
+ <show_in_website>1</show_in_website>
135
+ <show_in_store>1</show_in_store>
136
+ </empresa>
137
+ <personacontacto translate="label">
138
+ <label>Persona de contacto</label>
139
+ <frontend_type>text</frontend_type>
140
+ <sort_order>5</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
+ </personacontacto>
145
+ <direccion translate="label">
146
+ <label><![CDATA[Direcci&oacute;n]]></label>
147
+ <frontend_type>text</frontend_type>
148
+ <sort_order>6</sort_order>
149
+ <show_in_default>1</show_in_default>
150
+ <show_in_website>1</show_in_website>
151
+ <show_in_store>1</show_in_store>
152
+ </direccion>
153
+ <localidad translate="label">
154
+ <label>Localidad</label>
155
+ <frontend_type>text</frontend_type>
156
+ <sort_order>7</sort_order>
157
+ <show_in_default>1</show_in_default>
158
+ <show_in_website>1</show_in_website>
159
+ <show_in_store>1</show_in_store>
160
+ </localidad>
161
+ <codpostal translate="label">
162
+ <label><![CDATA[C&oacute;digo Postal]]></label>
163
+ <frontend_type>text</frontend_type>
164
+ <sort_order>8</sort_order>
165
+ <show_in_default>1</show_in_default>
166
+ <show_in_website>1</show_in_website>
167
+ <show_in_store>1</show_in_store>
168
+ </codpostal>
169
+ <provincia translate="label">
170
+ <label>Provincia</label>
171
+ <frontend_type>text</frontend_type>
172
+ <sort_order>9</sort_order>
173
+ <show_in_default>1</show_in_default>
174
+ <show_in_website>1</show_in_website>
175
+ <show_in_store>1</show_in_store>
176
+ </provincia>
177
+ <telefono translate="label">
178
+ <label><![CDATA[Tel&eacute;fono]]></label>
179
+ <frontend_type>text</frontend_type>
180
+ <sort_order>10</sort_order>
181
+ <show_in_default>1</show_in_default>
182
+ <show_in_website>1</show_in_website>
183
+ <show_in_store>1</show_in_store>
184
+ </telefono>
185
+ <email translate="label">
186
+ <label>E-mail</label>
187
+ <frontend_type>text</frontend_type>
188
+ <sort_order>11</sort_order>
189
+ <show_in_default>1</show_in_default>
190
+ <show_in_website>1</show_in_website>
191
+ <show_in_store>1</show_in_store>
192
+ </email>
193
+ <telefonosms translate="label">
194
+ <label><![CDATA[Tel&eacute;fono env&iacute;o de SMS]]></label>
195
+ <frontend_type>text</frontend_type>
196
+ <sort_order>12</sort_order>
197
+ <show_in_default>1</show_in_default>
198
+ <show_in_website>1</show_in_website>
199
+ <show_in_store>1</show_in_store>
200
+ </telefonosms>
201
+ </fields>
202
+ </remitente>
203
+ <paquete translate="label">
204
+ <label><![CDATA[Configuraci&oacute;n del paquete]]></label>
205
+ <frontend_type>text</frontend_type>
206
+ <sort_order>30</sort_order>
207
+ <show_in_default>1</show_in_default>
208
+ <show_in_website>1</show_in_website>
209
+ <show_in_store>1</show_in_store>
210
+ <fields>
211
+ <seguro translate="label">
212
+ <label>Seguro de los paquetes</label>
213
+ <frontend_type>select</frontend_type>
214
+ <source_model>adminhtml/system_config_source_yesno</source_model>
215
+ <sort_order>1</sort_order>
216
+ <show_in_default>1</show_in_default>
217
+ <show_in_website>1</show_in_website>
218
+ <show_in_store>1</show_in_store>
219
+ </seguro>
220
+ <importeseguro translate="label">
221
+ <label><![CDATA[Valor asegurado (hasta)]]></label>
222
+ <frontend_type>text</frontend_type>
223
+ <sort_order>2</sort_order>
224
+ <show_in_default>1</show_in_default>
225
+ <show_in_website>1</show_in_website>
226
+ <show_in_store>1</show_in_store>
227
+ </importeseguro>
228
+ <peso translate="label">
229
+ <label><![CDATA[Configuraci&oacute;n del peso en el cat&aacute;logo]]></label>
230
+ <frontend_type>select</frontend_type>
231
+ <source_model>correos/pesos</source_model>
232
+ <sort_order>3</sort_order>
233
+ <show_in_default>1</show_in_default>
234
+ <show_in_website>1</show_in_website>
235
+ <show_in_store>1</show_in_store>
236
+ <comment><![CDATA[Indicar la unidad en la que se han a&ntilde;adido el peso en los productos del cat&aacute;logo]]></comment>
237
+ </peso>
238
+ </fields>
239
+ </paquete>
240
+ </groups>
241
+ </correos>
242
+
243
+
244
+
245
+
246
+
247
+ <carriers>
248
+ <groups>
249
+
250
+ <envio4872 translate="label" module="shipping">
251
+ <label><![CDATA[Correos - Env&iacute;o 48/72]]></label>
252
+ <frontend_type>text</frontend_type>
253
+ <sort_order>20</sort_order>
254
+ <show_in_default>1</show_in_default>
255
+ <show_in_website>1</show_in_website>
256
+ <show_in_store>1</show_in_store>
257
+ <fields>
258
+ <active translate="label">
259
+ <label>Activar</label>
260
+ <frontend_type>select</frontend_type>
261
+ <source_model>adminhtml/system_config_source_yesno</source_model>
262
+ <sort_order>10</sort_order>
263
+ <show_in_default>1</show_in_default>
264
+ <show_in_website>1</show_in_website>
265
+ <show_in_store>1</show_in_store>
266
+ </active>
267
+ <title translate="label">
268
+ <label><![CDATA[T&iacute;tulo]]></label>
269
+ <frontend_type>text</frontend_type>
270
+ <sort_order>20</sort_order>
271
+ <show_in_default>1</show_in_default>
272
+ <show_in_website>1</show_in_website>
273
+ <show_in_store>1</show_in_store>
274
+ </title>
275
+ <condition_name translate="label">
276
+ <label><![CDATA[Tipo de condici&oacute;n]]></label>
277
+ <frontend_type>select</frontend_type>
278
+ <source_model>adminhtml/system_config_source_shipping_tablerate</source_model>
279
+ <sort_order>25</sort_order>
280
+ <show_in_default>1</show_in_default>
281
+ <show_in_website>1</show_in_website>
282
+ <show_in_store>0</show_in_store>
283
+ </condition_name>
284
+ <!--
285
+ <export translate="label">
286
+ <label>Exportar</label>
287
+ <frontend_type>export</frontend_type>
288
+ <sort_order>32</sort_order>
289
+ <show_in_default>0</show_in_default>
290
+ <show_in_website>1</show_in_website>
291
+ <show_in_store>0</show_in_store>
292
+ </export>
293
+ -->
294
+ <export translate="label">
295
+ <label>Exportar</label>
296
+ <frontend_type>button</frontend_type>
297
+ <frontend_model>correos/system_export_envio</frontend_model>
298
+ <sort_order>32</sort_order>
299
+ <show_in_default>0</show_in_default>
300
+ <show_in_website>1</show_in_website>
301
+ <show_in_store>0</show_in_store>
302
+ </export>
303
+ <import translate="label">
304
+ <label>Importar</label>
305
+ <frontend_type>import</frontend_type>
306
+ <backend_model>correos/system_config_backend_shipping_correos</backend_model>
307
+ <sort_order>33</sort_order>
308
+ <show_in_default>0</show_in_default>
309
+ <show_in_website>1</show_in_website>
310
+ <show_in_store>0</show_in_store>
311
+ </import>
312
+ <envio4872cost translate="label">
313
+ <label><![CDATA[Costo del env&iacute;o]]></label>
314
+ <frontend_type>text</frontend_type>
315
+ <sort_order>40</sort_order>
316
+ <show_in_default>1</show_in_default>
317
+ <show_in_website>1</show_in_website>
318
+ <show_in_store>1</show_in_store>
319
+ </envio4872cost>
320
+ <sallowspecific translate="label">
321
+ <label><![CDATA[Env&iacute;o a pa&iacute;ses]]></label>
322
+ <frontend_type>select</frontend_type>
323
+ <sort_order>90</sort_order>
324
+ <frontend_class>shipping-applicable-country</frontend_class>
325
+ <source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>
326
+ <show_in_default>1</show_in_default>
327
+ <show_in_website>1</show_in_website>
328
+ <show_in_store>0</show_in_store>
329
+ </sallowspecific>
330
+ <specificcountry translate="label">
331
+ <label><![CDATA[Pa&iacute;ses de env&iacute;o]]></label>
332
+ <frontend_type>multiselect</frontend_type>
333
+ <sort_order>91</sort_order>
334
+ <source_model>adminhtml/system_config_source_country</source_model>
335
+ <show_in_default>1</show_in_default>
336
+ <show_in_website>1</show_in_website>
337
+ <show_in_store>0</show_in_store>
338
+ <can_be_empty>1</can_be_empty>
339
+ </specificcountry>
340
+ <envio4872showmethod translate="label">
341
+ <label><![CDATA[Mostrar m&eacute;todo aunque no este disponible]]></label>
342
+ <frontend_type>select</frontend_type>
343
+ <sort_order>92</sort_order>
344
+ <source_model>adminhtml/system_config_source_yesno</source_model>
345
+ <show_in_default>1</show_in_default>
346
+ <show_in_website>1</show_in_website>
347
+ <show_in_store>0</show_in_store>
348
+ </envio4872showmethod>
349
+
350
+ <sort_order translate="label">
351
+ <label>Orden</label>
352
+ <frontend_type>text</frontend_type>
353
+ <sort_order>150</sort_order>
354
+ <show_in_default>1</show_in_default>
355
+ <show_in_website>1</show_in_website>
356
+ <show_in_store>1</show_in_store>
357
+ </sort_order>
358
+
359
+ </fields>
360
+ </envio4872>
361
+
362
+ <recogeroficina translate="label" module="shipping">
363
+ <label><![CDATA[Correos - Recoger en oficina m&aacute;s cercana]]></label>
364
+ <frontend_type>text</frontend_type>
365
+ <sort_order>30</sort_order>
366
+ <show_in_default>1</show_in_default>
367
+ <show_in_website>1</show_in_website>
368
+ <show_in_store>1</show_in_store>
369
+ <fields>
370
+ <active translate="label">
371
+ <label>Activar</label>
372
+ <frontend_type>select</frontend_type>
373
+ <source_model>adminhtml/system_config_source_yesno</source_model>
374
+ <sort_order>10</sort_order>
375
+ <show_in_default>1</show_in_default>
376
+ <show_in_website>1</show_in_website>
377
+ <show_in_store>1</show_in_store>
378
+ </active>
379
+ <title translate="label">
380
+ <label><![CDATA[T&iacute;tulo]]></label>
381
+ <frontend_type>text</frontend_type>
382
+ <sort_order>20</sort_order>
383
+ <show_in_default>1</show_in_default>
384
+ <show_in_website>1</show_in_website>
385
+ <show_in_store>1</show_in_store>
386
+ </title>
387
+ <condition_name translate="label">
388
+ <label><![CDATA[Tipo de condici&oacute;n]]></label>
389
+ <frontend_type>select</frontend_type>
390
+ <source_model>adminhtml/system_config_source_shipping_tablerate</source_model>
391
+ <sort_order>25</sort_order>
392
+ <show_in_default>1</show_in_default>
393
+ <show_in_website>1</show_in_website>
394
+ <show_in_store>0</show_in_store>
395
+ </condition_name>
396
+ <!--
397
+ <export translate="label">
398
+ <label>Exportar</label>
399
+ <frontend_type>export</frontend_type>
400
+ <sort_order>32</sort_order>
401
+ <show_in_default>0</show_in_default>
402
+ <show_in_website>1</show_in_website>
403
+ <show_in_store>0</show_in_store>
404
+ </export>
405
+ -->
406
+ <export translate="label">
407
+ <label>Exportar</label>
408
+ <frontend_type>button</frontend_type>
409
+ <frontend_model>correos/system_export_recoger</frontend_model>
410
+ <sort_order>32</sort_order>
411
+ <show_in_default>0</show_in_default>
412
+ <show_in_website>1</show_in_website>
413
+ <show_in_store>0</show_in_store>
414
+ </export>
415
+ <import translate="label">
416
+ <label>Importar</label>
417
+ <frontend_type>import</frontend_type>
418
+ <backend_model>correos/system_config_backend_shipping_recoger</backend_model>
419
+ <sort_order>33</sort_order>
420
+ <show_in_default>0</show_in_default>
421
+ <show_in_website>1</show_in_website>
422
+ <show_in_store>0</show_in_store>
423
+ </import>
424
+ <recogeroficinacost translate="label">
425
+ <label><![CDATA[Costo del env&iacute;o]]></label>
426
+ <frontend_type>text</frontend_type>
427
+ <sort_order>40</sort_order>
428
+ <show_in_default>1</show_in_default>
429
+ <show_in_website>1</show_in_website>
430
+ <show_in_store>1</show_in_store>
431
+ </recogeroficinacost>
432
+ <sallowspecific translate="label">
433
+ <label><![CDATA[Env&iacute;o a pa&iacute;ses]]></label>
434
+ <frontend_type>select</frontend_type>
435
+ <sort_order>90</sort_order>
436
+ <frontend_class>shipping-applicable-country</frontend_class>
437
+ <source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>
438
+ <show_in_default>1</show_in_default>
439
+ <show_in_website>1</show_in_website>
440
+ <show_in_store>0</show_in_store>
441
+ </sallowspecific>
442
+ <specificcountry translate="label">
443
+ <label><![CDATA[Pa&iacute;ses de env&iacute;o]]></label>
444
+ <frontend_type>multiselect</frontend_type>
445
+ <sort_order>91</sort_order>
446
+ <source_model>adminhtml/system_config_source_country</source_model>
447
+ <show_in_default>1</show_in_default>
448
+ <show_in_website>1</show_in_website>
449
+ <show_in_store>0</show_in_store>
450
+ <can_be_empty>1</can_be_empty>
451
+ </specificcountry>
452
+ <recogeroficinashowmethod translate="label">
453
+ <label><![CDATA[Mostrar m&eacute;todo aunque no este disponible]]></label>
454
+ <frontend_type>select</frontend_type>
455
+ <sort_order>92</sort_order>
456
+ <source_model>adminhtml/system_config_source_yesno</source_model>
457
+ <show_in_default>1</show_in_default>
458
+ <show_in_website>1</show_in_website>
459
+ <show_in_store>0</show_in_store>
460
+ </recogeroficinashowmethod>
461
+
462
+ <gateway_recoger translate="label">
463
+ <label>URL datos</label>
464
+ <default></default>
465
+ <frontend_type>text</frontend_type>
466
+ <sort_order>60</sort_order>
467
+ <show_in_default>1</show_in_default>
468
+ <show_in_website>1</show_in_website>
469
+ <show_in_store>1</show_in_store>
470
+ <comment><![CDATA[Solo modificar si Correos lo indica]]></comment>
471
+ </gateway_recoger>
472
+
473
+ <sort_order translate="label">
474
+ <label>Orden</label>
475
+ <frontend_type>text</frontend_type>
476
+ <sort_order>150</sort_order>
477
+ <show_in_default>1</show_in_default>
478
+ <show_in_website>1</show_in_website>
479
+ <show_in_store>1</show_in_store>
480
+ </sort_order>
481
+
482
+ </fields>
483
+ </recogeroficina>
484
+
485
+ </groups>
486
+ </carriers>
487
+ </sections>
488
+ </config>
app/code/local/Ydral/Correos/log.txt ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ v0.1.0
3
+ -----------------------------------
4
+ - Versi�n inicial.
5
+
6
+ v0.2.0
7
+ -----------------------------------
8
+ - Se a�ade la posibilidad de tablas con diferentes tipos de selecci�n.
9
+ - Se solucionan problemas varios.
10
+
11
+ v0.3.0
12
+ -----------------------------------
13
+ - Se solucionan problemas varios.
app/code/local/Ydral/Correos/sql/correos_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+
4
+ $installer->startSetup();
5
+
6
+ $installer->run("
7
+ CREATE TABLE IF NOT EXISTS {$this->getTable('correos_recoger_oficina')} (
8
+ `id` int(5) NOT NULL AUTO_INCREMENT,
9
+ `entity_type` varchar(50) NOT NULL,
10
+ `checkout_id` int(12) NOT NULL,
11
+ `correos_recogida` varchar(10) NOT NULL,
12
+ `correos_oficina` varchar(255) NOT NULL,
13
+ PRIMARY KEY (`id`),
14
+ KEY `checkout_id` (`checkout_id`)
15
+ ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
16
+
17
+ CREATE TABLE IF NOT EXISTS {$this->getTable('correos_shipping')} (
18
+ `pk` int(10) unsigned NOT NULL auto_increment,
19
+ `website_id` int(11) NOT NULL default '0',
20
+ `dest_country_id` varchar(4) NOT NULL default '0',
21
+ `dest_region_id` int(10) NOT NULL default '0',
22
+ `dest_zip` varchar(10) NOT NULL default '',
23
+ `condition_name` varchar(20) NOT NULL default '',
24
+ `condition_value` decimal(12,4) NOT NULL default '0.0000',
25
+ `price` decimal(12,4) NOT NULL default '0.0000',
26
+ `cost` decimal(12,4) NOT NULL default '0.0000',
27
+ `method_code` varchar(64) NOT NULL,
28
+ PRIMARY KEY (`pk`),
29
+ UNIQUE KEY `dest_country` (`website_id`,`dest_country_id`,`dest_region_id`,`dest_zip`,`condition_name`,`condition_value`,`method_code`)
30
+ ) DEFAULT CHARSET=utf8;
31
+
32
+ ");
33
+ $installer->endSetup();
app/code/local/Ydral/Correos/sql/correos_setup/mysql4-upgrade-0.1.0-0.2.0.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ $installer = $this;
app/code/local/Ydral/Correos/sql/correos_setup/mysql4-upgrade-0.2.0-0.3.0.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ $installer = $this;
app/design/adminhtml/default/default/layout/correos.xml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <adminhtml_system_config_edit>
4
+ <reference name="head">
5
+ <action method="addCss"><stylesheet>correos.css</stylesheet></action>
6
+ </reference>
7
+ </adminhtml_system_config_edit>
8
+
9
+ <adminhtml_sales_order_view>
10
+ <reference name="order_tab_info">
11
+ <action method="setTemplate" ifconfig="carriers/recogeroficina/active">
12
+ <template>correos/tab_info.phtml</template>
13
+ </action>
14
+ </reference>
15
+ </adminhtml_sales_order_view>
16
+
17
+ </layout>
app/design/adminhtml/default/default/template/correos/tab_info.phtml ADDED
@@ -0,0 +1,205 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 default_default
23
+ * @copyright Copyright (c) 2011 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 $_order = $this->getOrder() ?>
28
+ <?php
29
+ /* CORREOS START */
30
+ /*
31
+ envio4872_envio4872
32
+ recogeroficina_recogeroficina
33
+ */
34
+ $_envioCorreos = false;
35
+ if (($_order->getShippingMethod() == 'recogeroficina_recogeroficina') || ($_order->getShippingMethod() == 'envio4872_envio4872'))
36
+ {
37
+ $_envioCorreos = true;
38
+ }
39
+ /* CORREOS END */
40
+ ?>
41
+ <div>
42
+ <div id="order-messages">
43
+ <?php echo $this->getChildHtml('order_messages') ?>
44
+ </div>
45
+ <?php echo $this->getChildHtml('order_info') ?>
46
+ <input type="hidden" name="order_id" value="<?php echo $_order->getId() ?>"/>
47
+ <?php if ($_order->getIsVirtual()): ?>
48
+ <div class="box-right">
49
+ <?php else: ?>
50
+ <div class="box-left">
51
+ <?php endif; ?>
52
+ <!--Payment Method-->
53
+ <div class="entry-edit">
54
+ <div class="entry-edit-head">
55
+ <h4 class="icon-head head-payment-method"><?php echo Mage::helper('sales')->__('Payment Information') ?></h4>
56
+ </div>
57
+ <fieldset>
58
+ <?php echo $this->getPaymentHtml() ?>
59
+ <div><?php echo Mage::helper('sales')->__('Order was placed using %s', $_order->getOrderCurrencyCode()) ?></div>
60
+ </fieldset>
61
+ </div>
62
+ </div>
63
+ <?php if (!$_order->getIsVirtual()): ?>
64
+ <div class="box-right">
65
+ <!--Shipping Method-->
66
+ <div class="entry-edit">
67
+ <div class="entry-edit-head">
68
+ <h4 class="icon-head head-shipping-method"><?php echo Mage::helper('sales')->__('Shipping &amp; Handling Information') ?></h4>
69
+ </div>
70
+ <fieldset>
71
+ <?php if ($_order->getTracksCollection()->count()) : ?>
72
+ <?php if ($_envioCorreos): ?>
73
+ <a href="#" id="linkId" onclick="popWin('<?php echo $this->helper('correos')->getTrackingPopupUrlBySalesModel($_order) ?>','trackorder','width=800,height=600,resizable=yes,scrollbars=yes')" title="<?php echo $this->__('Track Order') ?>"><?php echo $this->__('Track Order') ?></a>
74
+ <?php else: ?>
75
+ <a href="#" id="linkId" onclick="popWin('<?php echo $this->helper('shipping')->getTrackingPopupUrlBySalesModel($_order) ?>','trackorder','width=800,height=600,resizable=yes,scrollbars=yes')" title="<?php echo $this->__('Track Order') ?>"><?php echo $this->__('Track Order') ?></a>
76
+ <?php endif; ?>
77
+ <br/>
78
+ <?php endif; ?>
79
+ <?php if ($_order->getShippingDescription()): ?>
80
+ <strong><?php echo $_order->getShippingDescription() ?></strong>
81
+
82
+
83
+ <?php
84
+ /* CORREOS START */
85
+ if ($_order->getShippingMethod() == 'recogeroficina_recogeroficina'):
86
+ ?>
87
+ <?php
88
+ $_dataRecogida = Mage::getModel('correos/ydral_recogeroficina')->readCheckoutData('order', $_order->getRealOrderId());
89
+ if ($_dataRecogida['correos_oficina'] == '')
90
+ {
91
+ $codPostalRecogida = $_order->getShippingAddress()->getPostcode();
92
+ } else {
93
+ $codPostalRecogida = $_dataRecogida['correos_oficina'];
94
+ }
95
+ if ($_dataRecogida):
96
+ $_dataOficina = Mage::getModel('correos/ydral_recogeroficina')->dataOficinas($_dataRecogida['correos_recogida'], $codPostalRecogida);
97
+
98
+ if ($_dataOficina):
99
+ ?>
100
+ <br />
101
+ <?php echo $_dataOficina; ?>
102
+ <?php endif; ?>
103
+
104
+ <?php endif; ?>
105
+
106
+
107
+ <br />
108
+ <?php echo $this->__('Gastos de env&iacute;o: ') ?>
109
+
110
+ <?php
111
+ endif;
112
+ /* CORREOS END */
113
+ ?>
114
+
115
+
116
+ <?php if ($this->helper('tax')->displayShippingPriceIncludingTax()): ?>
117
+ <?php $_excl = $this->displayShippingPriceInclTax($_order); ?>
118
+ <?php else: ?>
119
+ <?php $_excl = $this->displayPriceAttribute('shipping_amount', false, ' '); ?>
120
+ <?php endif; ?>
121
+ <?php $_incl = $this->displayShippingPriceInclTax($_order); ?>
122
+
123
+ <?php echo $_excl; ?>
124
+ <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
125
+ (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
126
+ <?php endif; ?>
127
+
128
+ <?php
129
+ $tracks = $_order->getTracksCollection();
130
+ $tracksValidos = array ('Correos', 'envio4872', 'recogeroficina');
131
+ foreach ($tracks as $track):
132
+
133
+ if (in_array($track->getCarrierCode(), $tracksValidos)):
134
+ ?>
135
+ <?php if ($_envioCorreos): ?>
136
+ <br />
137
+ <?php echo $this->__('<a href="/correos/index/downloadEtiqueta/order/%s/etiqueta/%s/">Imprimir etiqueta de env&iacute;o.</a>', $_order->getId(), $track['number']); ?>
138
+
139
+ <br />
140
+
141
+ <b><?php echo $this->__('Estado del env&iacute;o:') ?></b> <?php echo Mage::getModel('correos/ydral_shipment')->localizarEnvioUltimo($track['number']); ?>
142
+ <?php endif; ?>
143
+ <?php endif; ?>
144
+
145
+ <?php endforeach; ?>
146
+
147
+ <?php else: ?>
148
+ <?php echo $this->helper('sales')->__('No shipping information available'); ?>
149
+ <?php endif; ?>
150
+ </fieldset>
151
+ </div>
152
+ </div>
153
+ <?php endif; ?>
154
+ <div class="clear"></div>
155
+ <?php echo $this->getGiftOptionsHtml() ?>
156
+ <div class="clear"></div>
157
+ <div class="entry-edit">
158
+ <div class="entry-edit-head">
159
+ <h4 class="icon-head head-products"><?php echo Mage::helper('sales')->__('Items Ordered') ?></h4>
160
+ </div>
161
+ </div>
162
+ <?php echo $this->getItemsHtml() ?>
163
+ <div class="clear"></div>
164
+
165
+ <div class="box-left">
166
+ <div class="entry-edit">
167
+ <div class="entry-edit-head">
168
+ <h4><?php echo Mage::helper('sales')->__('Comments History') ?></h4>
169
+ </div>
170
+ <fieldset><?php echo $this->getChildHtml('order_history') ?></fieldset>
171
+ </div>
172
+ </div>
173
+ <div class="box-right entry-edit">
174
+ <div class="entry-edit-head"><h4><?php echo Mage::helper('sales')->__('Order Totals') ?></h4></div>
175
+ <div class="order-totals"><?php echo $this->getChildHtml('order_totals') ?></div>
176
+ </div>
177
+ <div class="clear"></div>
178
+ </div>
179
+
180
+ <?php echo $this->getChildHtml('popup_window');?>
181
+ <script type="text/javascript">
182
+ //<![CDATA[
183
+ /**
184
+ * Retrieve gift options tooltip content
185
+ */
186
+ function getGiftOptionsTooltipContent(itemId) {
187
+ var contentLines = [];
188
+ var headerLine = null;
189
+ var contentLine = null;
190
+
191
+ $$('#gift_options_data_' + itemId + ' .gift-options-tooltip-content').each(function (element) {
192
+ if (element.down(0)) {
193
+ headerLine = element.down(0).innerHTML;
194
+ contentLine = element.down(0).next().innerHTML;
195
+ if (contentLine.length > 30) {
196
+ contentLine = contentLine.slice(0,30) + '...';
197
+ }
198
+ contentLines.push(headerLine + ' ' + contentLine);
199
+ }
200
+ });
201
+ return contentLines.join('<br/>');
202
+ }
203
+ giftOptionsTooltip.setTooltipContentLoaderFunction(getGiftOptionsTooltipContent);
204
+ //]]>
205
+ </script>
app/design/frontend/base/default/layout/correos.xml ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+
4
+ <!-- <checkout_onepage_index> -->
5
+ <default>
6
+ <reference name="head" ifconfig="carriers/recogeroficina/active">
7
+ <action method="addItem"><type>skin_js</type><name>js/correos.js</name></action>
8
+ <action method="addCss"><stylesheet>css/correos.css</stylesheet></action>
9
+ </reference>
10
+ </default>
11
+ <!-- </checkout_onepage_index> -->
12
+
13
+ <correos_tracking_popup translate="label">
14
+ <label>Shipment Tracking Popup</label>
15
+ <reference name="root">
16
+ <action method="setTemplate"><template>page/popup.phtml</template></action>
17
+ </reference>
18
+ <reference name="content">
19
+ <block type="shipping/tracking_popup" name="shipping.tracking.popup" template="correos/popup.phtml" />
20
+ </reference>
21
+ </correos_tracking_popup>
22
+
23
+ <sales_order_shipment>
24
+ <reference name="my.account.wrapper">
25
+ <block type="sales/order_shipment" name="sales.order.shipment">
26
+ <block type="sales/order_shipment_items" name="shipment_items_correos" template="correos/order_shipment_items.phtml">
27
+ <action method="addItemRender"><type>default</type><block>sales/order_item_renderer_default</block><template>sales/order/shipment/items/renderer/default.phtml</template></action>
28
+ <block type="sales/order_comments" name="shipment_comments" template="sales/order/comments.phtml" />
29
+ </block>
30
+ </block>
31
+ </reference>
32
+ </sales_order_shipment>
33
+
34
+ <sales_guest_shipment>
35
+ <reference name="my.account.wrapper">
36
+ <block type="sales/order_shipment" name="sales.order.shipment">
37
+ <block type="sales/order_shipment_items" name="shipment_items_correos" template="correos/order_shipment_items.phtml">
38
+ <action method="addItemRender"><type>default</type><block>sales/order_item_renderer_default</block><template>sales/order/shipment/items/renderer/default.phtml</template></action>
39
+ <block type="sales/order_comments" name="shipment_comments" template="sales/order/comments.phtml" />
40
+ </block>
41
+ </block>
42
+ </reference>
43
+ </sales_guest_shipment>
44
+
45
+
46
+ </layout>
app/design/frontend/base/default/template/correos/order_info.phtml ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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) 2011 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 $_order = $this->getOrder() ?>
28
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
29
+ <div class="page-title title-buttons">
30
+ <h1><?php echo $this->__('Order #%s - %s', $_order->getRealOrderId(), $_order->getStatusLabel()) ?></h1>
31
+ <?php echo $this->getChildHtml('buttons') ?>
32
+ </div>
33
+ <?php echo $this->getStatusHistoryRssUrl($_order) ?>
34
+ <dl class="order-info">
35
+ <dt><?php echo $this->__('About This Order:') ?></dt>
36
+ <dd>
37
+ <?php $_links = $this->getLinks(); ?>
38
+ <ul id="order-info-tabs">
39
+ <?php foreach ($_links as $_link): ?>
40
+ <?php if($_link->getUrl()): ?>
41
+ <li><a href="<?php echo $_link->getUrl() ?>"><?php echo $_link->getLabel() ?></a></li>
42
+ <?php else: ?>
43
+ <li class="current"><?php echo $_link->getLabel() ?></li>
44
+ <?php endif; ?>
45
+ <?php endforeach; ?>
46
+ </ul>
47
+ <script type="text/javascript">decorateGeneric($('order-info-tabs').select('LI'),['first','last']);</script>
48
+ </dd>
49
+ </dl>
50
+ <p class="order-date"><?php echo $this->__('Order Date: %s', $this->formatDate($_order->getCreatedAtStoreDate(), 'long')) ?></p>
51
+ <?php if (!$_order->getIsVirtual()): ?>
52
+ <div class="col2-set order-info-box">
53
+ <div class="col-1">
54
+ <div class="box">
55
+ <div class="box-title">
56
+ <h2><?php echo $this->__('Shipping Address') ?></h2>
57
+ </div>
58
+ <div class="box-content">
59
+ <address><?php echo $_order->getShippingAddress()->format('html') ?></address>
60
+ </div>
61
+ </div>
62
+ </div>
63
+ <div class="col-2">
64
+ <div class="box">
65
+ <div class="box-title">
66
+ <h2><?php echo $this->__('Shipping Method') ?><?php /* | <a href="#"><?php echo $this->__('Track Order') ?></a>*/ ?></h2>
67
+ </div>
68
+ <div class="box-content">
69
+ <?php if ($_order->getShippingDescription()): ?>
70
+ <?php echo $_order->getShippingDescription() ?>
71
+ <?php
72
+ /* CORREOS START */
73
+ ?>
74
+ <?php
75
+ $_dataRecogida = Mage::getModel('correos/ydral_recogeroficina')->readCheckoutData('order', $_order->getRealOrderId());
76
+ if ($_dataRecogida['correos_oficina'] == '')
77
+ {
78
+ $codPostalRecogida = $_order->getShippingAddress()->getPostcode();
79
+ } else {
80
+ $codPostalRecogida = $_dataRecogida['correos_oficina'];
81
+ }
82
+ if ($_dataRecogida):
83
+ $_dataOficina = Mage::getModel('correos/ydral_recogeroficina')->dataOficinas($_dataRecogida['correos_recogida'], $codPostalRecogida);
84
+
85
+ if ($_dataOficina):
86
+ ?>
87
+ <br />
88
+ <?php echo $_dataOficina; ?>
89
+ <?php endif; ?>
90
+
91
+ <?php endif; ?>
92
+
93
+ <?php
94
+ /* CORREOS END */
95
+ ?>
96
+ <?php else: ?>
97
+ <p><?php echo $this->helper('sales')->__('No shipping information available'); ?></p>
98
+ <?php endif; ?>
99
+ </div>
100
+ </div>
101
+ </div>
102
+ </div>
103
+ <?php endif; ?>
104
+ <div class="col2-set order-info-box">
105
+ <div class="col-1">
106
+ <div class="box">
107
+ <div class="box-title">
108
+ <h2><?php echo $this->__('Billing Address') ?></h2>
109
+ </div>
110
+ <div class="box-content">
111
+ <address><?php echo $_order->getBillingAddress()->format('html') ?></address>
112
+ </div>
113
+ </div>
114
+ </div>
115
+ <div class="col-2">
116
+ <div class="box box-payment">
117
+ <div class="box-title">
118
+ <h2><?php echo $this->__('Payment Method') ?></h2>
119
+ </div>
120
+ <div class="box-content">
121
+ <?php echo $this->getPaymentInfoHtml() ?>
122
+ </div>
123
+ </div>
124
+ </div>
125
+ </div>
app/design/frontend/base/default/template/correos/order_shipment.phtml ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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) 2011 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
+ <div class="order-items order-details">
28
+ <?php if($this->helper('giftmessage/message')->getIsMessagesAvailable('order', $this->getOrder())): ?>
29
+ <script type="text/javascript">
30
+ //<![CDATA[
31
+ function giftMessageToogle(giftMessageIdentifier)
32
+ {
33
+ var link = $('order-item-gift-message-link-'+giftMessageIdentifier);
34
+ var container = $('order-item-gift-message-'+giftMessageIdentifier);
35
+ var row = $('order-item-row-'+giftMessageIdentifier);
36
+
37
+
38
+ if(link.expanded) {
39
+ link.expanded = false;
40
+ link.removeClassName('expanded');
41
+ if(container.hasClassName('last')) {
42
+ row.addClassName('last');
43
+ }
44
+ container.hide();
45
+ } else {
46
+ link.expanded = true;
47
+ link.addClassName('expanded');
48
+ if(container.hasClassName('last')) {
49
+ row.removeClassName('last');
50
+ }
51
+ container.show();
52
+ }
53
+
54
+ return false;
55
+ }
56
+ //]]>
57
+ </script>
58
+ <?php endif; ?>
59
+ <?php echo $this->getChildHtml('shipment_items_correos') ?>
60
+ <div class="buttons-set">
61
+ <p class="back-link"><a href="<?php echo $this->getBackUrl() ?>"><small>&laquo; </small><?php echo $this->getBackTitle() ?></a></p>
62
+ </div>
63
+ </div>
app/design/frontend/base/default/template/correos/order_shipment_items.phtml ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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) 2011 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 $_order = $this->getOrder() ?>
28
+ <?php foreach ($_order->getShipmentsCollection() as $_shipment): ?>
29
+ <h2 class="sub-title"><?php echo $this->__('Shipment #') ?><?php echo $_shipment->getIncrementId(); ?> <span class="separator">|</span> <a href="<?php echo $this->getPrintShipmentUrl($_shipment) ?>" onclick="this.target='_blank'" class="link-print"><?php echo $this->__('Print Shipment') ?></a></h2>
30
+ <?php $tracks = $_shipment->getTracksCollection(); ?>
31
+ <?php if ($tracks->count()): ?>
32
+ <table class="data-table tracking-table" id="my-tracking-table-<?php echo $_shipment->getId(); ?>">
33
+ <tbody>
34
+ <tr>
35
+ <td colspan="2">
36
+ <a href="#" onclick="popWin('<?php echo $this->helper('correos')->getTrackingPopupUrlBySalesModel($_order) ?>','trackshipment','width=800,height=600,top=0,left=0,resizable=yes,scrollbars=yes'); return false;" title="<?php echo $this->__('Track this shipment') ?>"><?php echo $this->__('Track this shipment') ?></a>
37
+ </td>
38
+ </tr>
39
+ <tr>
40
+ <th class="label"><?php echo $this->__('Tracking Number(s):') ?></th>
41
+ <td>&nbsp;
42
+ <?php
43
+ $i = 1;
44
+ $_size = $tracks->count();
45
+ foreach($tracks as $track): ?>
46
+ <?php if($track->isCustom()): ?>
47
+ <?php echo $this->escapeHtml($track->getNumber()) ?>
48
+ <?php else: ?>
49
+ <a href="#" onclick="popWin('<?php echo $this->helper('correos')->getTrackingPopupUrlBySalesModel($_order) ?>','trackorder','width=800,height=600,left=0,top=0,resizable=yes,scrollbars=yes')" ><?php echo $this->escapeHtml($track->getNumber()) ?></a>
50
+ <?php endif; ?>
51
+ <?php if($i!=$_size): ?>, <?php endif; ?>
52
+ <?php $i++;
53
+ endforeach; ?>
54
+ </td>
55
+ </tr>
56
+ </tbody>
57
+ </table>
58
+ <script type="text/javascript">decorateTable('my-tracking-table-<?php echo $_shipment->getId(); ?>')</script>
59
+ <?php endif; ?>
60
+ <h3 class="table-caption"><?php echo $this->__('Items Shipped') ?></h3>
61
+ <table class="data-table" id="my-shipment-table-<?php echo $_shipment->getId(); ?>">
62
+ <col />
63
+ <col width="1" />
64
+ <col width="1" />
65
+ <thead>
66
+ <tr>
67
+ <th><?php echo $this->__('Product Name') ?></th>
68
+ <th><?php echo $this->__('SKU') ?></th>
69
+ <th class="a-center"><span class="nobr"><?php echo $this->__('Qty Shipped') ?></span></th>
70
+ </tr>
71
+ </thead>
72
+ <?php $_items = $_shipment->getAllItems(); ?>
73
+ <?php $_count = count($_items) ?>
74
+ <?php foreach ($_items as $_item): ?>
75
+ <?php if ($_item->getOrderItem()->getParentItem()) continue; ?>
76
+ <tbody>
77
+ <?php echo $this->getItemHtml($_item) ?>
78
+ </tbody>
79
+ <?php endforeach; ?>
80
+ </table>
81
+ <script type="text/javascript">decorateTable('my-shipment-table-<?php echo $_shipment->getId(); ?>', {'tbody' : ['odd', 'even'], 'tbody tr' : ['first', 'last']})</script>
82
+ <?php echo $this->getCommentsHtml($_shipment)?>
83
+ <?php endforeach; ?>
app/design/frontend/base/default/template/correos/order_view.phtml ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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) 2011 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
+ <div class="order-items order-details">
28
+ <?php if ($this->helper('giftmessage/message')->getIsMessagesAvailable('items', $this->getOrder())): ?>
29
+ <script type="text/javascript">
30
+ //<![CDATA[
31
+ function giftMessageToogle(giftMessageIdentifier)
32
+ {
33
+ var link = $('order-item-gift-message-link-'+giftMessageIdentifier);
34
+ var container = $('order-item-gift-message-'+giftMessageIdentifier);
35
+ var row = $('order-item-row-'+giftMessageIdentifier);
36
+ if(link.expanded) {
37
+ link.expanded = false;
38
+ link.removeClassName('expanded');
39
+ if(container.hasClassName('last')) {
40
+ row.addClassName('last');
41
+ }
42
+ container.hide();
43
+ } else {
44
+ link.expanded = true;
45
+ link.addClassName('expanded');
46
+ if(container.hasClassName('last')) {
47
+ row.removeClassName('last');
48
+ }
49
+ container.show();
50
+ }
51
+
52
+ return false;
53
+ }
54
+ //]]>
55
+ </script>
56
+ <?php endif; ?>
57
+ <?php $_order = $this->getOrder() ?>
58
+ <h2 class="table-caption"><?php echo $this->__('Items Ordered') ?>
59
+ <?php if ($_order->getTracksCollection()->count()) : ?>
60
+ <span class="separator">|</span> <a href="#" onclick="popWin('<?php echo $this->helper('correos')->getTrackingPopupUrlBySalesModel($_order) ?>','trackorder','top=0,left=0,width=800,height=600,resizable=yes,scrollbars=yes'); return false;" title="<?php echo $this->__('Track your order') ?>"><?php echo $this->__('Track your order') ?></a>
61
+ <?php endif; ?>
62
+ </h2>
63
+
64
+ <?php echo $this->getChildHtml('order_items') ?>
65
+
66
+ <?php if($this->helper('giftmessage/message')->getIsMessagesAvailable('order', $_order) && $_order->getGiftMessageId()): ?>
67
+ <div class="order-additional order-gift-message">
68
+ <h2 class="sub-title"><?php echo $this->__('Gift Message for This Order') ?></h2>
69
+ <?php $_giftMessage=$this->helper('giftmessage/message')->getGiftMessageForEntity($_order); ?>
70
+ <dl class="gift-message">
71
+ <dt><strong><?php echo $this->__('From:') ?></strong> <?php echo $this->htmlEscape($_giftMessage->getSender()) ?></dt>
72
+ <dt><strong><?php echo $this->__('To:') ?></strong> <?php echo $this->htmlEscape($_giftMessage->getRecipient()) ?></dt>
73
+ <dd><?php echo $this->helper('giftmessage/message')->getEscapedGiftMessage($_order) ?></dd>
74
+ </dl>
75
+ </div>
76
+ <?php endif; ?>
77
+ <?php $_history = $this->getOrder()->getVisibleStatusHistory() ?>
78
+ <?php if (count($_history)): ?>
79
+ <div class="order-additional order-comments">
80
+ <h2 class="sub-title"><?php echo $this->__('About Your Order') ?></h2>
81
+ <dl class="order-about">
82
+ <?php foreach ($_history as $_historyItem): ?>
83
+ <dt><?php echo $this->formatDate($_historyItem->getCreatedAtStoreDate(), 'medium', true) ?></dt>
84
+ <dd><?php echo $this->escapeHtml($_historyItem->getComment()) ?></dd>
85
+ <?php endforeach; ?>
86
+ </dl>
87
+ </div>
88
+ <?php endif; ?>
89
+ <div class="buttons-set">
90
+ <p class="back-link"><a href="<?php echo $this->getBackUrl() ?>"><small>&laquo; </small><?php echo $this->getBackTitle() ?></a></p>
91
+ </div>
92
+ </div>
app/design/frontend/base/default/template/correos/popup.phtml ADDED
@@ -0,0 +1,273 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ /* @var $this Mage_Shipping_Block_Tracking_Popup */
27
+ ?>
28
+ <?php
29
+
30
+
31
+ $_results = $this->getTrackingInfo();
32
+ $tracksValidos = array ('Correos', 'envio4872', 'recogeroficina');
33
+
34
+
35
+ ?>
36
+ <div class="page-title title-buttons">
37
+ <h1><?php echo $this->__('Tracking Information'); ?></h1>
38
+ <button class="button" onclick="window.close(); window.opener.focus();"><span><span><?php echo $this->__('Close Window') ?></span></span></button>
39
+ </div>
40
+
41
+ <?php if(sizeof($_results)>0): ?>
42
+
43
+ <?php foreach($_results as $shipid => $_result): ?>
44
+
45
+ <?php if($shipid): ?>
46
+ <h2 class="sub-title"><?php echo $this->__('Shipment #').$shipid; ?></h2>
47
+ <?php endif; ?>
48
+
49
+
50
+ <?php if(sizeof($_result)>0): ?>
51
+
52
+
53
+ <?php $rowCount = sizeof($_result); $counter = 1; ?>
54
+ <?php $_id = 0; foreach($_result as $track): ?>
55
+
56
+ <?php if (!is_array($track)): ?>
57
+
58
+ <?php
59
+
60
+ $info = Mage::registry('current_shipping_info');
61
+ $_order = Mage::getModel('sales/order')->load($info->getOrderId());
62
+
63
+ $tracks = $_order->getTracksCollection();
64
+ foreach ($tracks as $track):
65
+ ?>
66
+ <table class="tracking-table-popup data-table" id="tracking-table-popup-<?php echo $_id ?>">
67
+ <col width="15%" />
68
+ <col />
69
+ <tbody>
70
+ <tr>
71
+ <th class="label"><?php echo ($track['title'] ? $this->escapeHtml($track['title']) : $this->__('N/A')); ?>:</th>
72
+ <td class="value"><?php echo (isset($track['number']) ? $this->escapeHtml($track['number']) : ''); ?></td>
73
+ </tr>
74
+ </tbody>
75
+ </table>
76
+
77
+
78
+ <?php
79
+
80
+ $_trackCorreos = Mage::getModel('correos/ydral_shipment')->localizarEnvioFases($track['number']);
81
+
82
+ if ($_trackCorreos):
83
+ ?>
84
+
85
+ <table class="data-table" id="track-history-table-<?php echo $track['number']; ?>">
86
+ <col width="1" />
87
+ <col />
88
+ <thead>
89
+ <tr>
90
+ <th><?php echo $this->__('Fecha') ?></th>
91
+ <th><?php echo $this->__('Comentario') ?></th>
92
+ </tr>
93
+ </thead>
94
+ <tbody>
95
+
96
+ <?php
97
+ foreach ($_trackCorreos as $track):
98
+ ?>
99
+
100
+ <tr>
101
+ <td><?php echo $track->Fecha; ?></td>
102
+ <td><span class="nobr"><?php echo utf8_decode($track->Estado); ?></span></td>
103
+ </tr>
104
+
105
+ <?php
106
+ endforeach;
107
+ ?>
108
+
109
+ </tbody>
110
+ </table>
111
+ <script type="text/javascript">decorateTable('track-history-table-<?php echo $track['number']; ?>');</script>
112
+ <?php
113
+ endif;
114
+ ?>
115
+ <div class="divider"></div>
116
+
117
+
118
+
119
+
120
+
121
+ <?php endforeach; ?>
122
+
123
+
124
+ <?php else: ?>
125
+
126
+
127
+ <table class="tracking-table-popup data-table" id="tracking-table-popup-<?php echo $_id ?>">
128
+ <col width="15%" />
129
+ <col />
130
+ <tbody>
131
+ <?php if(is_object($track)): ?>
132
+ <tr>
133
+ <th class="label"><?php echo $this->__('Tracking Number:'); ?></th>
134
+ <td class="value"><?php echo $track->getTracking(); ?></td>
135
+ </tr>
136
+ <?php if ($track->getCarrierTitle()): ?>
137
+ <tr>
138
+ <th class="label"><?php echo $this->__('Carrier:'); ?></th>
139
+ <td class="value"><?php echo $track->getCarrierTitle(); ?></td>
140
+ </tr>
141
+ <?php endif; ?>
142
+ <?php if($track->getErrorMessage()): ?>
143
+ <tr>
144
+ <th class="label"><?php echo $this->__('Error:'); ?></th>
145
+ <td class="error"><?php echo $this->__('Tracking information is currently not available. Please '); if ($this->getContactUsEnabled()) : ?><a href="<?php echo $this->getContactUs() ?>" title="<?php echo $this->__('contact us') ?>" onclick="this.target='_blank'"><?php echo $this->__('contact us') ?></a><?php echo $this->__(' for more information or '); endif; echo $this->__('email us at '); ?><a href="mailto:<?php echo $this->getStoreSupportEmail() ?>"><?php echo $this->getStoreSupportEmail() ?></a></td>
146
+ </tr>
147
+ <?php elseif($track->getTrackSummary()): ?>
148
+ <tr>
149
+ <th class="label"><?php echo $this->__('Info:'); ?></th>
150
+ <td class="value"><?php echo $track->getTrackSummary(); ?></td>
151
+ </tr>
152
+ <?php elseif($track->getUrl()): ?>
153
+ <tr>
154
+ <th class="label"><?php echo $this->__('Track:'); ?></th>
155
+ <td class="value"><a href="<?php echo $track->getUrl(); ?>" onclick="this.target='_blank'"><?php echo $track->getUrl(); ?></a></td>
156
+ </tr>
157
+ <?php else: ?>
158
+ <?php if ($track->getStatus()): ?>
159
+ <tr>
160
+ <th class="label"><?php echo $this->__('Status:'); ?></th>
161
+ <td class="value"><?php echo $track->getStatus(); ?></td>
162
+ </tr>
163
+ <?php endif; ?>
164
+
165
+ <?php if ($track->getDeliverydate()): ?>
166
+ <tr>
167
+ <th class="label"><?php echo $this->__('Delivered on:'); ?></th>
168
+ <td class="value"><?php echo $this->formatDeliveryDateTime($track->getDeliverydate(),$track->getDeliverytime()); ?></td>
169
+ </tr>
170
+ <?php endif; ?>
171
+
172
+ <?php if ($track->getSignedby()): ?>
173
+ <tr>
174
+ <th class="label"><?php echo $this->__('Signed by:'); ?></th>
175
+ <td class="value"><?php echo $track->getSignedby(); ?></td>
176
+ </tr>
177
+ <?php endif; ?>
178
+
179
+ <?php if ($track->getDeliveryLocation()): ?>
180
+ <tr>
181
+ <th class="label"><?php echo $this->__('Delivered to:'); ?></th>
182
+ <td class="value"><?php echo $track->getDeliveryLocation(); ?></td>
183
+ </tr>
184
+ <?php endif; ?>
185
+
186
+ <?php if ($track->getShippedDate()): ?>
187
+ <tr>
188
+ <th class="label"><?php echo $this->__('Shipped or billed on:'); ?></th>
189
+ <td class="value"><?php echo $track->getShippedDate(); ?></td>
190
+ </tr>
191
+ <?php endif; ?>
192
+
193
+ <?php if ($track->getService()): ?>
194
+ <tr>
195
+ <th class="label"><?php echo $this->__('Service Type:'); ?></th>
196
+ <td class="value"><?php echo $track->getService(); ?></td>
197
+ </tr>
198
+ <?php endif; ?>
199
+
200
+ <?php if ($track->getWeight()): ?>
201
+ <tr>
202
+ <th class="label"><?php echo $this->__('Weight:'); ?></th>
203
+ <td class="value"><?php echo $track->getWeight(); ?></td>
204
+ </tr>
205
+ <?php endif; ?>
206
+ <?php endif; ?>
207
+ <?php elseif(isset($track['title']) && isset($track['number']) && $track['number']): ?>
208
+ <!--if the tracking is custom value-->
209
+ <tr>
210
+ <th class="label"><?php echo ($track['title'] ? $this->escapeHtml($track['title']) : $this->__('N/A')); ?>:</th>
211
+ <td class="value"><?php echo (isset($track['number']) ? $this->escapeHtml($track['number']) : ''); ?></td>
212
+ </tr>
213
+ <?php endif; ?>
214
+ </tbody>
215
+ </table>
216
+ <script type="text/javascript">decorateTable('tracking-table-popup-<?php echo $_id++ ?>');</script>
217
+
218
+ <?php
219
+
220
+ $_trackCorreos = Mage::getModel('correos/ydral_shipment')->localizarEnvioFases($track['number']);
221
+
222
+ if ($_trackCorreos):
223
+ ?>
224
+
225
+ <table class="data-table" id="track-history-table-<?php echo $track['number']; ?>">
226
+ <col width="1" />
227
+ <col />
228
+ <thead>
229
+ <tr>
230
+ <th><?php echo $this->__('Fecha') ?></th>
231
+ <th><?php echo $this->__('Comentario') ?></th>
232
+ </tr>
233
+ </thead>
234
+ <tbody>
235
+
236
+ <?php
237
+ foreach ($_trackCorreos as $track):
238
+ ?>
239
+
240
+ <tr>
241
+ <td><?php echo $track->Fecha; ?></td>
242
+ <td><span class="nobr"><?php echo utf8_decode($track->Estado); ?></span></td>
243
+ </tr>
244
+
245
+ <?php
246
+ endforeach;
247
+ ?>
248
+
249
+ </tbody>
250
+ </table>
251
+ <script type="text/javascript">decorateTable('track-history-table-<?php echo $track['number']; ?>');</script>
252
+ <?php
253
+ endif;
254
+ ?>
255
+ <div class="divider"></div>
256
+ <?php $counter++; ?>
257
+
258
+ <?php endif; ?>
259
+
260
+ <!--end for each tracking information-->
261
+ <?php endforeach; ?>
262
+ <?php else: ?>
263
+ <p><?php echo $this->__('There is no tracking available for this shipment.'); ?></p>
264
+ <?php endif; ?>
265
+
266
+ <?php endforeach; ?>
267
+
268
+ <?php else: ?>
269
+ <p><?php echo $this->__('There is no tracking available.'); ?></p>
270
+ <?php endif; ?>
271
+ <div class="buttons-set">
272
+ <button type="button" title="<?php echo $this->__('Close Window') ?>" class="button" onclick="window.close(); window.opener.focus();"><span><span><?php echo $this->__('Close Window') ?></span></span></button>
273
+ </div>
app/etc/modules/Ydral_Correos.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <modules>
5
+ <Ydral_Correos>
6
+ <active>false</active>
7
+ <codePool>local</codePool>
8
+ </Ydral_Correos>
9
+ </modules>
10
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Ydral_Correos</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL 3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Modulo para Magento para integrar Correos.</summary>
10
+ <description>Modulo para Magento para integrar Correos.</description>
11
+ <notes>Correos</notes>
12
+ <authors><author><name>Ydral</name><user>Ydral</user><email>webmaster@ydral.com</email></author></authors>
13
+ <date>2012-11-22</date>
14
+ <time>16:24:19</time>
15
+ <contents><target name="magelocal"><dir name="Ydral"><dir name="Correos"><dir><dir name="Block"><file name="Correos.php" hash="1b0b7449fe4fc1a490beb2731d808833"/><dir name="Onepage"><dir name="Shipping"><dir name="Method"><file name="Available.php" hash="f3eee1d370e15385a7ad0660388318e8"/></dir></dir></dir><dir name="Order"><file name="Info.php" hash="e91c0bbf5f12c5417aaa7cb9a016d53e"/><file name="Shipment.php" hash="92af0ea6e466b5c3ba3e03d87099676b"/><file name="View.php" hash="2ba78931ba3627861a4c3a0b313eeeea"/></dir><dir name="System"><dir name="Export"><file name="Envio.php" hash="bcbf6fd994d10dd15252e8e0cd1137d9"/><file name="Recoger.php" hash="8ab14c0214077967088913a050eac011"/></dir></dir><dir name="Tracking"><file name="Popup.php" hash="90ad75e9c0f8d59093f6c0f10c2c403d"/></dir></dir><dir name="Helper"><file name="Data.php" hash="d5142bf6837fcee9fa6b95363397af3f"/><file name="Onestepcheckout.php" hash="73c35d649ba8a1982059049b2069d37c"/></dir><dir name="Model"><file name="Correos.php" hash="7d7329d6e15391e58d01eb68b1cc1f34"/><dir name="Mysql4"><dir name="Carrier"><dir name="Correos"><file name="Collection.php" hash="8acd4f14cbbfa3266672f80df90dd8eb"/></dir><file name="Correos.php" hash="67a8a823c9f9164780e50e4592b4113f"/></dir><dir name="Correos"><file name="Collection.php" hash="5d3d9c496b804a813aba6d4b8ada21b4"/></dir><file name="Correos.php" hash="2a7507d51e478a42404dc3da39caec0f"/></dir><file name="Pesos.php" hash="5a0eb95ca645de30602fa2ab96bd468b"/><dir name="Quote"><dir name="Address"><dir name="Total"><file name="Shipping.php" hash="d9e5185a891d850f6d8aaa56a6f89c06"/></dir></dir></dir><dir name="System"><dir name="Config"><dir name="Backend"><dir name="Shipping"><file name="Correos.php" hash="19b624f09bde0493ff1da9c8d7032756"/><file name="Recoger.php" hash="7fa2ecf29152181778df237c377adaa5"/></dir></dir></dir></dir><dir name="Type"><file name="Onepage.php" hash="bccdfd5d4fcedaf4f6564a31634ad8f6"/></dir><dir name="Ydral"><file name="Correos.php" hash="32b9596c9903b43c2571e411a791b83f"/><file name="Recogeroficina.php" hash="143959a68ec994587d9d4fa1684b456d"/><file name="Shipment.php" hash="003fb5d141d986b640056c8e856c8c06"/></dir></dir><dir name="controllers"><file name="IndexController.php" hash="45abd73fe238454c2426460d39afefed"/><dir name="Sales"><dir name="Order"><file name="ShipmentController.php" hash="e3b714b819b870a931d037b2b5668dcb"/></dir></dir><file name="TrackingController.php" hash="ec71e387dc85055ba34c19a07c4aad78"/></dir><dir name="etc"><file name="config.xml" hash="f2ebc69266a0a30ef11888b60b937959"/><file name="system.xml" hash="7ccbf79ef19675932c0b0352c575aba4"/></dir><dir name="sql"><dir name="correos_setup"><file name="mysql4-install-0.1.0.php" hash="4e95daa44dbacf3ba1d02bb73018786e"/><file name="mysql4-upgrade-0.1.0-0.2.0.php" hash="a91ac4d35130ff6d11d876c711f810e2"/><file name="mysql4-upgrade-0.2.0-0.3.0.php" hash="a91ac4d35130ff6d11d876c711f810e2"/></dir></dir></dir><file name="log.txt" hash="fa236e6e523e9d696a222fb7f5f51ae1"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Ydral_Correos.xml" hash="f86293a775f6572f85cffd72c4d8e70e"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="css"><file name="correos.css" hash="d6fde38ba7d7f768dea0b161b190d5ab"/></dir><dir name="js"><file name="correos.js" hash="437470394526c567639e29d16244cd75"/></dir><dir name="images"><file name="correos_4872.png" hash="06096525a173118a8f3199c402688c48"/><file name="logo_entregadomicilio.jpg" hash="0d2b9aa305b92a7ea53bd2d6f2daa9e3"/><file name="logo_recogeroficina.jpg" hash="50a6906d1a4ef364e21f838a0cd5ade6"/></dir></dir></dir><dir name="base"><dir name="default"><dir name="css"><file name="correos.css" hash="d6fde38ba7d7f768dea0b161b190d5ab"/></dir><dir name="js"><file name="correos.js" hash="437470394526c567639e29d16244cd75"/></dir><dir name="images"><file name="logo_entregadomicilio.jpg" hash="0d2b9aa305b92a7ea53bd2d6f2daa9e3"/><file name="logo_recogeroficina.jpg" hash="50a6906d1a4ef364e21f838a0cd5ade6"/><file name="correos_4872.png" hash="06096525a173118a8f3199c402688c48"/></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><file name="correos-section.png" hash="6715309b92e7dc1599cc043975272624"/></dir><file name="correos.css" hash="e27bc86c5ea27d00c13e5c2589fd89e4"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="correos.xml" hash="c1d4ca19d9c9d3eee7c8f8367113d1b4"/></dir><dir name="template"><dir name="correos"><file name="tab_info.phtml" hash="fc7ba70d82c60497fe5c01068fdb2a3c"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="correos.xml" hash="67aa5520799d6212cd757724849b67a2"/></dir><dir name="template"><dir name="correos"><file name="order_info.phtml" hash="ca29af9d43da164b17e7c59cb7d5c577"/><file name="order_shipment.phtml" hash="ddef55d58d33c172d7b497efb24cceef"/><file name="order_shipment_items.phtml" hash="d250b704263f57791e5d1dd30f53f9a8"/><file name="order_view.phtml" hash="74d03f2e4e9479d2fd46b8ebd8edec68"/><file name="popup.phtml" hash="98621c39582463a00292c871b6d37d82"/></dir></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>
skin/adminhtml/default/default/correos.css ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ ul.tabs a.correos-section,
2
+ ul.tabs a.correos-section:hover { background-color: #FDD116; padding:0.5em 0.5em 0.28em 1.5em; }
3
+ ul.tabs a.correos-section:hover { background-color:#FDD116; }
4
+ ul.tabs a.correos-section span,
5
+ ul.tabs a.correos-section:hover span { background:url(images/correos-section.png) no-repeat 0 0; height:0; overflow:hidden; padding:14px 0 0; width:103px; }
skin/adminhtml/default/default/images/correos-section.png ADDED
Binary file
skin/frontend/base/default/css/correos.css ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ label[for=s_method_recogeroficina_recogeroficina] { line-height: 40px; }
2
+ label[for=s_method_envio4872_envio4872] { line-height: 40px; }
3
+ .title_correos_method { display: none; }
skin/frontend/base/default/images/correos_4872.png ADDED
Binary file
skin/frontend/base/default/images/logo_entregadomicilio.jpg ADDED
Binary file
skin/frontend/base/default/images/logo_recogeroficina.jpg ADDED
Binary file
skin/frontend/base/default/js/correos.js ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ var clicked = false;
3
+
4
+ PuntosCorreos = Class.create();
5
+ PuntosCorreos.prototype = {
6
+
7
+ initialize: function()
8
+ {
9
+ this.correosResultados = '';
10
+ this.codigoPostalVal = '';
11
+
12
+ Event.observe(window, 'load', function()
13
+ {
14
+
15
+
16
+ $$('.main').invoke('observe', 'click', function(e)
17
+ {
18
+
19
+ var element = e.element();
20
+ if (element.getValue())
21
+ {
22
+ if (element.getValue() == 'recogeroficina_recogeroficina')
23
+ {
24
+ if (!clicked)
25
+ {
26
+ clicked = true;
27
+ PuntosCorreos.getPuntosCorreos();
28
+ }
29
+ }
30
+ }
31
+ });
32
+ });
33
+
34
+ },
35
+
36
+ validaRadio:function()
37
+ {
38
+ var radioValue = Form.getInputs('co-shipping-method-form','radio','shipping_method').find(function(radio) { return radio.checked; }).value;
39
+ if (radioValue == 'recogeroficina_recogeroficina')
40
+ {
41
+ this.getPuntosCorreos();
42
+ }
43
+ },
44
+
45
+ getPuntosCorreos:function()
46
+ {
47
+
48
+ var codPostal = '';
49
+
50
+ if ($('cp_oficina_correos') != undefined)
51
+ {
52
+ codPostal = $('cp_oficina_correos').value;
53
+ this.codigoPostalVal = codPostal;
54
+ //$('cp_search').value = codPostal;
55
+ }
56
+
57
+ if ($('content_puntos_correos') != undefined)
58
+ {
59
+ $('content_puntos_correos').remove();
60
+ }
61
+
62
+
63
+ if ($('shipping-method-please-wait'))
64
+ {
65
+ Element.show('shipping-method-please-wait');
66
+ }
67
+
68
+ this.reloadurl = '/correos/index/getdata/';
69
+ new Ajax.Request(this.reloadurl, {
70
+ method: 'post',
71
+ parameters: {codigoPostal: codPostal},
72
+ onComplete: this.reloadChildren.bind(this)
73
+ });
74
+
75
+ },
76
+
77
+ reloadChildren: function(transport)
78
+ {
79
+ if ($('shipping-method-please-wait'))
80
+ {
81
+ Element.hide('shipping-method-please-wait');
82
+ }
83
+ clicked = false;
84
+ var htmlInicial = '<div id="content_puntos_correos" style="margin-left: 15px; clear: both; "><b>Introduce el c&oacute;digo postal para buscar oficina: </b><input type="text" name="cp_oficina_correos" id="cp_oficina_correos" value="" /><input type="hidden" name="cp_search" value="'+this.codigoPostalVal+'" id="cp_search" /><input type="button" value="Buscar" onClick="PuntosCorreos.getPuntosCorreos(); return false; " /><br />La oficina de Correos te avisar&aacute; cuando el paquete est&eacute; listo en sus oficinas:<br /><div id="oficinas_correos_content"><select id="oficinas_correos_content_select" name="oficinas_correos_content_select" onchange="PuntosCorreos.correosInfo();"></select></div><div id="correos_info_time" style="display: none; "></div></div>';
85
+
86
+ $('s_method_recogeroficina_recogeroficina').next().insert({after: htmlInicial})
87
+
88
+ var jsonResponse = transport.responseText.evalJSON(true);
89
+ this.correosResultados = jsonResponse;
90
+
91
+
92
+ this.fillDropDownCorreos ($('oficinas_correos_content_select'), this.correosResultados);
93
+
94
+ },
95
+
96
+ fillDropDownCorreos:function (field, data)
97
+ {
98
+ /*
99
+ var htmlRadio = '';
100
+ data.each(
101
+ function(e) {
102
+ htmlRadio+= '<input type="radio" value="'+e.unidad+'" name="oficinas_correos" />&nbsp;<label>'+e.nombre+' - '+e.direccion+" - "+e.cp+' '+e.cp+'</label><br />';
103
+ }
104
+ );
105
+
106
+ $(field).update(htmlRadio);
107
+ */
108
+
109
+
110
+ for(i=field.options.length-1;i>=0;i--) { field.remove(i); }
111
+
112
+ data.each(
113
+ function(e) {
114
+ //field.options.add(new Option(e.nombre+' - ('+e.direccion+") - ("+e.cp+') ('+e.localidad+')',e.unidad));
115
+ field.options.add(new Option(e.direccion+" - "+e.cp+' - '+e.localidad,e.unidad));
116
+ }
117
+ );
118
+
119
+ this.correosInfo()
120
+
121
+
122
+ },
123
+
124
+ correosInfo:function()
125
+ {
126
+
127
+ var puntoActual = $('oficinas_correos_content_select').value;
128
+ this.correosResultados.each(
129
+ function(e) {
130
+ if (e.unidad == puntoActual)
131
+ {
132
+ $('correos_info_time').setStyle({display: 'block'});
133
+
134
+ // info del punto
135
+ this.infoHorarios(e);
136
+
137
+ }
138
+ }.bind(this));
139
+
140
+ },
141
+
142
+ infoHorarios: function (e)
143
+ {
144
+
145
+ var tablaHorarios = '<ol>';
146
+ tablaHorarios += '<li><strong>Oficina</strong></li>';
147
+ tablaHorarios += '<li>'+e.nombre+'<li>';
148
+ tablaHorarios += '<li><strong>Horarios</strong></li>';
149
+ tablaHorarios += '<li>Horario de Lunes a Viernes: '+e.horariolv+'</li>';
150
+ tablaHorarios += '<li>Horario de S&aacute;bados: '+e.horarios+'</li>';
151
+ tablaHorarios += '<li>Horario de Festivos: '+e.horariof+'</li>';
152
+ tablaHorarios += '</ol>';
153
+
154
+ $('correos_info_time').update(tablaHorarios);
155
+
156
+ }
157
+
158
+ }
159
+
160
+ var PuntosCorreos = new PuntosCorreos();
161
+
skin/frontend/default/default/css/correos.css ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ label[for=s_method_recogeroficina_recogeroficina] { line-height: 40px; }
2
+ label[for=s_method_envio4872_envio4872] { line-height: 40px; }
3
+ .title_correos_method { display: none; }
skin/frontend/default/default/images/correos_4872.png ADDED
Binary file
skin/frontend/default/default/images/logo_entregadomicilio.jpg ADDED
Binary file
skin/frontend/default/default/images/logo_recogeroficina.jpg ADDED
Binary file
skin/frontend/default/default/js/correos.js ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ var clicked = false;
3
+
4
+ PuntosCorreos = Class.create();
5
+ PuntosCorreos.prototype = {
6
+
7
+ initialize: function()
8
+ {
9
+ this.correosResultados = '';
10
+ this.codigoPostalVal = '';
11
+
12
+ Event.observe(window, 'load', function()
13
+ {
14
+
15
+
16
+ $$('.main').invoke('observe', 'click', function(e)
17
+ {
18
+
19
+ var element = e.element();
20
+ if (element.getValue())
21
+ {
22
+ if (element.getValue() == 'recogeroficina_recogeroficina')
23
+ {
24
+ if (!clicked)
25
+ {
26
+ clicked = true;
27
+ PuntosCorreos.getPuntosCorreos();
28
+ }
29
+ }
30
+ }
31
+ });
32
+ });
33
+
34
+ },
35
+
36
+ validaRadio:function()
37
+ {
38
+ var radioValue = Form.getInputs('co-shipping-method-form','radio','shipping_method').find(function(radio) { return radio.checked; }).value;
39
+ if (radioValue == 'recogeroficina_recogeroficina')
40
+ {
41
+ this.getPuntosCorreos();
42
+ }
43
+ },
44
+
45
+ getPuntosCorreos:function()
46
+ {
47
+
48
+ var codPostal = '';
49
+
50
+ if ($('cp_oficina_correos') != undefined)
51
+ {
52
+ codPostal = $('cp_oficina_correos').value;
53
+ this.codigoPostalVal = codPostal;
54
+ //$('cp_search').value = codPostal;
55
+ }
56
+
57
+ if ($('content_puntos_correos') != undefined)
58
+ {
59
+ $('content_puntos_correos').remove();
60
+ }
61
+
62
+
63
+ if ($('shipping-method-please-wait'))
64
+ {
65
+ Element.show('shipping-method-please-wait');
66
+ }
67
+
68
+ this.reloadurl = '/correos/index/getdata/';
69
+ new Ajax.Request(this.reloadurl, {
70
+ method: 'post',
71
+ parameters: {codigoPostal: codPostal},
72
+ onComplete: this.reloadChildren.bind(this)
73
+ });
74
+
75
+ },
76
+
77
+ reloadChildren: function(transport)
78
+ {
79
+ if ($('shipping-method-please-wait'))
80
+ {
81
+ Element.hide('shipping-method-please-wait');
82
+ }
83
+ clicked = false;
84
+ var htmlInicial = '<div id="content_puntos_correos" style="margin-left: 15px; clear: both; "><b>Introduce el c&oacute;digo postal para buscar oficina: </b><input type="text" name="cp_oficina_correos" id="cp_oficina_correos" value="" /><input type="hidden" name="cp_search" value="'+this.codigoPostalVal+'" id="cp_search" /><input type="button" value="Buscar" onClick="PuntosCorreos.getPuntosCorreos(); return false; " /><br />La oficina de Correos te avisar&aacute; cuando el paquete est&eacute; listo en sus oficinas:<br /><div id="oficinas_correos_content"><select id="oficinas_correos_content_select" name="oficinas_correos_content_select" onchange="PuntosCorreos.correosInfo();"></select></div><div id="correos_info_time" style="display: none; "></div></div>';
85
+
86
+ $('s_method_recogeroficina_recogeroficina').next().insert({after: htmlInicial})
87
+
88
+ var jsonResponse = transport.responseText.evalJSON(true);
89
+ this.correosResultados = jsonResponse;
90
+
91
+
92
+ this.fillDropDownCorreos ($('oficinas_correos_content_select'), this.correosResultados);
93
+
94
+ },
95
+
96
+ fillDropDownCorreos:function (field, data)
97
+ {
98
+ /*
99
+ var htmlRadio = '';
100
+ data.each(
101
+ function(e) {
102
+ htmlRadio+= '<input type="radio" value="'+e.unidad+'" name="oficinas_correos" />&nbsp;<label>'+e.nombre+' - '+e.direccion+" - "+e.cp+' '+e.cp+'</label><br />';
103
+ }
104
+ );
105
+
106
+ $(field).update(htmlRadio);
107
+ */
108
+
109
+
110
+ for(i=field.options.length-1;i>=0;i--) { field.remove(i); }
111
+
112
+ data.each(
113
+ function(e) {
114
+ //field.options.add(new Option(e.nombre+' - ('+e.direccion+") - ("+e.cp+') ('+e.localidad+')',e.unidad));
115
+ field.options.add(new Option(e.direccion+" - "+e.cp+' - '+e.localidad,e.unidad));
116
+ }
117
+ );
118
+
119
+ this.correosInfo()
120
+
121
+
122
+ },
123
+
124
+ correosInfo:function()
125
+ {
126
+
127
+ var puntoActual = $('oficinas_correos_content_select').value;
128
+ this.correosResultados.each(
129
+ function(e) {
130
+ if (e.unidad == puntoActual)
131
+ {
132
+ $('correos_info_time').setStyle({display: 'block'});
133
+
134
+ // info del punto
135
+ this.infoHorarios(e);
136
+
137
+ }
138
+ }.bind(this));
139
+
140
+ },
141
+
142
+ infoHorarios: function (e)
143
+ {
144
+
145
+ var tablaHorarios = '<ol>';
146
+ tablaHorarios += '<li><strong>Oficina</strong></li>';
147
+ tablaHorarios += '<li>'+e.nombre+'<li>';
148
+ tablaHorarios += '<li><strong>Horarios</strong></li>';
149
+ tablaHorarios += '<li>Horario de Lunes a Viernes: '+e.horariolv+'</li>';
150
+ tablaHorarios += '<li>Horario de S&aacute;bados: '+e.horarios+'</li>';
151
+ tablaHorarios += '<li>Horario de Festivos: '+e.horariof+'</li>';
152
+ tablaHorarios += '</ol>';
153
+
154
+ $('correos_info_time').update(tablaHorarios);
155
+
156
+ }
157
+
158
+ }
159
+
160
+ var PuntosCorreos = new PuntosCorreos();
161
+