Ydral_Yupick - Version 0.3.0

Version Notes

Yupick!

Download this release

Release Info

Developer Ydral
Extension Ydral_Yupick
Version 0.3.0
Comparing to
See all releases


Version 0.3.0

Files changed (31) hide show
  1. app/code/local/Ydral/Yupick/Block/Checkout/Onepage/Shipping/Method/Available.php +25 -0
  2. app/code/local/Ydral/Yupick/Block/Yupick.php +11 -0
  3. app/code/local/Ydral/Yupick/Helper/Data.php +77 -0
  4. app/code/local/Ydral/Yupick/Model/Mysql4/Boyaca/Collection.php +9 -0
  5. app/code/local/Ydral/Yupick/Model/Mysql4/Yupick.php +9 -0
  6. app/code/local/Ydral/Yupick/Model/Observer.php +21 -0
  7. app/code/local/Ydral/Yupick/Model/Type/Onepage.php +52 -0
  8. app/code/local/Ydral/Yupick/Model/Ydral/Recogeroficina.php +365 -0
  9. app/code/local/Ydral/Yupick/Model/Ydral/Shipment.php +160 -0
  10. app/code/local/Ydral/Yupick/Model/Ydral/Source/Method.php +40 -0
  11. app/code/local/Ydral/Yupick/Model/Yupick.php +9 -0
  12. app/code/local/Ydral/Yupick/controllers/IndexController.php +32 -0
  13. app/code/local/Ydral/Yupick/etc/config.xml +181 -0
  14. app/code/local/Ydral/Yupick/etc/system.xml +240 -0
  15. app/code/local/Ydral/Yupick/sql/yupick_setup/mysql4-install-0.1.0.php +22 -0
  16. app/code/local/Ydral/Yupick/sql/yupick_setup/mysql4-upgrade-0.1.0-0.2.0.php +2 -0
  17. app/code/local/Ydral/Yupick/sql/yupick_setup/mysql4-upgrade-0.2.0-0.3.0.php +2 -0
  18. app/design/adminhtml/default/default/layout/yupick.xml +10 -0
  19. app/design/adminhtml/default/default/template/yupick/tab_info.phtml +180 -0
  20. app/design/frontend/base/default/layout/yupick.xml +20 -0
  21. app/design/frontend/base/default/template/yupick/info.phtml +137 -0
  22. app/design/frontend/base/default/template/yupick/shipping.phtml +191 -0
  23. app/etc/modules/Ydral_Yupick.xml +9 -0
  24. package.xml +18 -0
  25. skin/frontend/default/default/css/yupick.css +22 -0
  26. skin/frontend/default/default/images/yupick/globo.png +0 -0
  27. skin/frontend/default/default/images/yupick/globosombra.png +0 -0
  28. skin/frontend/default/default/images/yupick/logo.gif +0 -0
  29. skin/frontend/default/default/images/yupick/logo_small.gif +0 -0
  30. skin/frontend/default/default/images/yupick/opc-ajax-loader.gif +0 -0
  31. skin/frontend/default/default/js/yupick.js +142 -0
app/code/local/Ydral/Yupick/Block/Checkout/Onepage/Shipping/Method/Available.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ydral_Yupick_Block_Checkout_Onepage_Shipping_Method_Available extends Mage_Checkout_Block_Onepage_Shipping_Method_Available
4
+ {
5
+ public function verOficinas()
6
+ {
7
+ $codigoPostal = $this->getQuote()->getShippingAddress()->getPostcode();
8
+
9
+ Mage::log($codigoPostal);
10
+
11
+ $_htmlOficinas = Mage::getModel('yupick/ydral_recogeroficina')->getHtmlOficinas($codigoPostal);
12
+
13
+ if ($_htmlOficinas == false)
14
+ {
15
+ echo "<script type=\"text/javascript\">$('s_method_yupick_yupick').toggle();</script>";
16
+ echo $this->__('No hay oficinas disponibles para mostrar');
17
+ return false;
18
+ } else {
19
+ echo $_htmlOficinas;
20
+ }
21
+
22
+ }
23
+
24
+
25
+ }
app/code/local/Ydral/Yupick/Block/Yupick.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ydral_Yupick_Block_Yupick extends Mage_Core_Block_Template
4
+ {
5
+ protected function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->setTemplate('ydral/yupick/yupick.phtml');
9
+ }
10
+
11
+ }
app/code/local/Ydral/Yupick/Helper/Data.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ydral_Yupick_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ /**
7
+ *
8
+ */
9
+ public function setOficinaYupickRecogida($observer)
10
+ {
11
+
12
+ $idQuote = Mage::getSingleton('checkout/session')->getQuoteId();
13
+ $idSelector = trim(strip_tags($this->_getRequest()->getPost('oficinas_yupick')));
14
+ $nombrePunto = $this->_getRequest()->getPost('oficinas_yupick_data');
15
+
16
+ $_tipoAviso = $this->_getRequest()->getPost('yupick_type_alert');
17
+ $_tipoAvisoSms = $this->_getRequest()->getPost('yupick_type_alert_phone');
18
+ $_tipoAvisoEmail = $this->_getRequest()->getPost('yupick_type_alert_email');
19
+
20
+ if (!empty($idSelector))
21
+ {
22
+ $observer->getEvent()->getQuote()->setPuntoRecogida(trim(strip_tags($idSelector)));
23
+ $observer->getEvent()->getQuote()->setPuntoOficina(trim(strip_tags($nombrePunto)))->save();
24
+
25
+ Mage::getModel('yupick/ydral_recogeroficina')->saveCheckoutData('quote', $idQuote, $idSelector, $nombrePunto, $_tipoAviso, $_tipoAvisoSms, $_tipoAvisoEmail);
26
+
27
+ return $this;
28
+ }
29
+
30
+
31
+ }
32
+
33
+
34
+ public function setOficinaYupickRecogidaOrder($observer)
35
+ {
36
+
37
+ $idQuote = Mage::getSingleton('checkout/session')->getLastQuoteId();
38
+ $idOrder = Mage::getSingleton('checkout/session')->getLastRealOrderId();
39
+
40
+ $_checkoutData = Mage::getModel('yupick/ydral_recogeroficina')->readCheckoutData('quote', $idQuote);
41
+
42
+ if ($_checkoutData)
43
+ {
44
+ Mage::getModel('yupick/ydral_recogeroficina')->saveOrderData($idQuote, $idOrder);
45
+ }
46
+
47
+ }
48
+
49
+
50
+ public function getUrlRequest($section)
51
+ {
52
+ if (!Mage::getStoreConfig('yupick/general/entorno_produccion'))
53
+ {
54
+ // pre-produccion
55
+ return Mage::getStoreConfig('yupick/general/'.$section.'_pre');
56
+
57
+ } else {
58
+ // produccion
59
+ return Mage::getStoreConfig('yupick/general/'.$section);
60
+ }
61
+
62
+ }
63
+ public function getUrlRequestCarrier()
64
+ {
65
+ if (!Mage::getStoreConfig('yupick/general/entorno_produccion'))
66
+ {
67
+ // pre-produccion
68
+ return Mage::getStoreConfig('carriers/yupick/gateway_url_pre');
69
+
70
+ } else {
71
+ // produccion
72
+ return Mage::getStoreConfig('carriers/yupick/gateway_url');
73
+ }
74
+
75
+ }
76
+
77
+ }
app/code/local/Ydral/Yupick/Model/Mysql4/Boyaca/Collection.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ydral_Yupick_Model_Mysql4_Yupick_Collection extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ protected function _construct()
6
+ {
7
+ $this->_init('yupick/yupick');
8
+ }
9
+ }
app/code/local/Ydral/Yupick/Model/Mysql4/Yupick.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ydral_Yupick_Model_Mysql4_Yupick extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ protected function _construct()
6
+ {
7
+ $this->_init('yupick/yupick', 'yupick_id');
8
+ }
9
+ }
app/code/local/Ydral/Yupick/Model/Observer.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ydral_Yupick_Model_Observer
3
+ {
4
+
5
+ public function checkout_controller_onepage_save_shipping_method($observer)
6
+ {
7
+
8
+ $request = $observer->getEvent()->getRequest();
9
+ $quote = $observer->getEvent()->getQuote();
10
+
11
+ $oficinaRecogida = $request->getPost('oficinas_yupick', '');
12
+
13
+ Mage::log("Oficina: " . $oficinaRecogida);
14
+
15
+ $quote->setYupickRecogida($oficinaRecogida);
16
+ $quote->save();
17
+
18
+ return $this;
19
+ }
20
+
21
+ }
app/code/local/Ydral/Yupick/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_Yupick_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
+ $_cp = Mage::app()->getRequest()->getPost('oficinas_yupick_data');
42
+
43
+ if ( ($shippingMethod == 'yupick_yupick') && (empty($_cp)) )
44
+ {
45
+ return array('error' => -1, 'message' => $this->_helper->__('No se ha especificado un punto de recogida.'));
46
+ }
47
+
48
+ return parent::saveShippingMethod($shippingMethod);
49
+
50
+ }
51
+
52
+ }
app/code/local/Ydral/Yupick/Model/Ydral/Recogeroficina.php ADDED
@@ -0,0 +1,365 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ydral_Yupick_Model_Ydral_Recogeroficina extends Mage_Shipping_Model_Carrier_Abstract
3
+ {
4
+
5
+ protected $_code = 'yupick';
6
+ public $_codigoPostal = '';
7
+
8
+
9
+ /**
10
+ * + visualizacion en checkout
11
+ */
12
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request)
13
+ {
14
+
15
+ if (!$this->getConfigFlag('active'))
16
+ {
17
+ return false;
18
+ }
19
+
20
+ $err = null;
21
+ $envio = array();
22
+
23
+
24
+ /**
25
+ *
26
+ */
27
+ if (!$request->getOrig()) {
28
+ $request->setCountryId(Mage::getStoreConfig('shipping/origin/country_id', $request->getStore()))
29
+ ->setPostcode(Mage::getStoreConfig('shipping/origin/postcode', $request->getStore()));
30
+ }
31
+
32
+
33
+ /**
34
+ *
35
+ */
36
+ $_datosEnvio['origen'] = Mage::getStoreConfig('shipping/origin/postcode', $request->getStore());
37
+
38
+ $_datosEnvio['destino'] = $request->getDestPostcode();
39
+ $_datosEnvio['peso'] = $request->getPackageWeight();
40
+ $_datosEnvio["bultos"] = 1;
41
+ $_datosEnvio["precioProducto"] = $request->getPackageValue();
42
+
43
+
44
+ $result = Mage::getModel('shipping/rate_result');
45
+
46
+
47
+ $rate = Mage::getModel('shipping/rate_result_method');
48
+ $rate->setCarrier($this->_code);
49
+ $rate->setCarrierTitle($this->getConfigData('title'));
50
+ $rate->setMethod('yupick');
51
+
52
+
53
+ $rate->setMethodTitle('Recogida en punto de conveniencia: ');
54
+
55
+ $this->setCodigoPostal($request->getDestPostcode());
56
+
57
+ $rate->setPrice($this->getConfigData('price_shipping'));
58
+ $result->append($rate);
59
+
60
+
61
+
62
+ return $result;
63
+ }
64
+
65
+ public function setCodigoPostal($codPostal)
66
+ {
67
+ $this->_codigoPostal = $codPostal;
68
+ }
69
+
70
+ public function getCodigoPostal()
71
+ {
72
+ return $this->_codigoPostal;
73
+ }
74
+
75
+ public function isTrackingAvailable()
76
+ {
77
+ return true;
78
+ }
79
+
80
+ public function getTrackingInfo($tracking_number)
81
+ {
82
+ $tracking_result = $this->getTracking($tracking_number);
83
+ if ($tracking_result instanceof Mage_Shipping_Model_Tracking_Result) {
84
+ $trackings = $tracking_result->getAllTrackings();
85
+ if ($trackings){ return $trackings[0]; }
86
+ }
87
+ elseif (is_string($tracking_result) && !empty($tracking_result)){
88
+ return $tracking_result;
89
+ }
90
+ else return false;
91
+ }
92
+
93
+
94
+ /**
95
+ * prepara el selector de oficinas
96
+ */
97
+ public function getHtmlOficinas ($data)
98
+ {
99
+
100
+ if (!$_oficinas = $this->pedirOficinas($data))
101
+ {
102
+ return false;
103
+ } else {
104
+
105
+ $_oficinas = $this->objectToArray($_oficinas);
106
+
107
+ if (!isset($_oficinas['puntoentrega'][0]))
108
+ {
109
+ $_tmpPunto = $_oficinas['puntoentrega'];
110
+ unset($_oficinas['puntoentrega']);
111
+ $_oficinas['puntoentrega'][0] = $_tmpPunto;
112
+ }
113
+
114
+ // convertimos toda la informacion a json
115
+ $_returnJson = json_encode($_oficinas);
116
+
117
+ return $_returnJson;
118
+
119
+ }
120
+
121
+ }
122
+
123
+
124
+ /**
125
+ *
126
+ */
127
+ public function objectToArray( $object )
128
+ {
129
+ if( !is_object( $object ) && !is_array( $object ) )
130
+ {
131
+ return $object;
132
+ }
133
+ if( is_object( $object ) )
134
+ {
135
+ $object = get_object_vars( $object );
136
+ }
137
+ return array_map( array($this, 'objectToArray'), $object );
138
+ }
139
+
140
+
141
+
142
+ /**
143
+ *
144
+ */
145
+ public function dataPunto($codOficina, $codPostal)
146
+ {
147
+
148
+ $_oficinas = $this->pedirOficinas($codPostal);
149
+
150
+ if (!is_array($_oficinas))
151
+ {
152
+ return false;
153
+ } else {
154
+ while(list(,$_oficina) = each($_oficinas))
155
+ {
156
+ if ($_oficina->unidad == $codOficina)
157
+ {
158
+ return $_oficina;
159
+ }
160
+ }
161
+ return false;
162
+ }
163
+
164
+ }
165
+
166
+
167
+ /**
168
+ * llama a yupick para comprobar las oficinas relativas al codigo postal
169
+ *
170
+ */
171
+ protected function pedirOficinas ($data)
172
+ {
173
+
174
+ if (!is_array($data)) { return false; }
175
+ if (!Mage::getStoreConfig('yupick/general/active')) return false;
176
+ if (!Mage::getStoreConfig('yupick/general/etiquetador')) return false;
177
+
178
+
179
+ $URL=Mage::helper('yupick')->getUrlRequestCarrier();
180
+ $client = new SoapClient($URL);
181
+
182
+ // Realizamos la peticion
183
+ $result = $client->getBuscarPuntos(Mage::getStoreConfig('yupick/general/etiquetador'),$data['codigoPostal'],'',$data['option_parking'],$data['option_wifi'],$data['option_alimentacion'],$data['option_prensa'],$data['option_tarjeta'],$data['option_mas20'],$data['option_sabados'],$data['option_domingos']);
184
+
185
+
186
+ // reparamos los datos para sacar un xml bien formado
187
+ $result = str_replace("<?xml version='1.0' encoding='ISO-8859-1'?><puntoentrega>", "<?xml version='1.0' encoding='ISO-8859-1'?><puntos><puntoentrega>", $result . '</puntos>');
188
+ //$result = iconv("UTF-8", "ISO-8859-1//IGNORE", utf8_decode(trim($result)));
189
+ $result = preg_replace('/<tarjetacredito>([A-Za-z]*)<tarjetacredito>/e', "'<tarjetacredito>'.strtolower('\\1').'</tarjetacredito>'",$result);
190
+ $result = preg_replace('/<poslongitud>([A-Za-z0-9\.-]*)<poslongitud>/e', "'<poslongitud>' . strtolower('\\1') . '</poslongitud>'",$result);
191
+ $result = str_replace('</puntos>', '', $result);
192
+
193
+
194
+ if ($this->is_valid_xml($result))
195
+ {
196
+ $dataXml = simplexml_load_string($result, 'SimpleXMLElement', LIBXML_NOCDATA);
197
+ } else {
198
+ return false;
199
+ }
200
+
201
+ return $dataXml;
202
+
203
+ }
204
+
205
+
206
+ /**
207
+ * comprueba que el xml sea correcto
208
+ */
209
+ function is_valid_xml ($xml)
210
+ {
211
+ libxml_use_internal_errors(true);
212
+ $doc = new DOMDocument('1.0', 'utf-8');
213
+ $doc->loadXML($xml);
214
+
215
+ $errors = libxml_get_errors();
216
+
217
+ return empty($errors);
218
+ }
219
+
220
+
221
+ /**
222
+ *
223
+ */
224
+ public function saveCheckoutData($entityType, $idQuote, $idSelector, $nombrePunto, $_tipoAviso, $_tipoAvisoSms, $_tipoAvisoEmail, $order_id = '')
225
+ {
226
+
227
+ $tablePrefix = (string)Mage::getConfig()->getTablePrefix();
228
+
229
+ $sqlQuery = 'SELECT id FROM '.$tablePrefix.'yupick_recoger WHERE entity_type = "' . $entityType . '" AND '.$entityType.'_id = "' . $idQuote . '" LIMIT 1';
230
+ $dbRead = Mage::getSingleton('core/resource')->getConnection('core_read');
231
+
232
+ $row = $dbRead->fetchAll($sqlQuery);
233
+
234
+ if (!$row)
235
+ {
236
+ $sqlQuery = 'INSERT INTO '.$tablePrefix.'yupick_recoger values (\'\', ?, ?, ?, ?, ?, ?, ?, ?, \'\')';
237
+ $dbWrite = Mage::getSingleton('core/resource')->getConnection('core_write');
238
+
239
+ $dbWrite->query($sqlQuery, array($entityType, $idQuote, $order_id, addslashes($idSelector), addslashes($_tipoAviso), addslashes($_tipoAvisoSms), addslashes($_tipoAvisoEmail), addslashes($nombrePunto)));
240
+
241
+ } else {
242
+
243
+ $sqlQuery = 'UPDATE '.$tablePrefix.'yupick_recoger SET ' .
244
+ 'oficina_recogida = "' . $idSelector . '", ' .
245
+ 'tipo_aviso = "' . $_tipoAviso . '", ' .
246
+ 'movil = "' . $_tipoAvisoSms . '", ' .
247
+ 'correo = "' . $_tipoAvisoEmail . '", ' .
248
+ 'info_oficina = "' . $nombrePunto . '" ' .
249
+ ' WHERE quote_id = "' . $idQuote . '" ' .
250
+ ' AND entity_type = "' . $entityType . '" LIMIT 1';
251
+
252
+
253
+ $dbWrite = Mage::getSingleton('core/resource')->getConnection('core_write');
254
+ $dbWrite->query($sqlQuery);
255
+
256
+ }
257
+ }
258
+
259
+
260
+ /**
261
+ *
262
+ */
263
+ public function saveOrderData($idQuote, $idOrder = '')
264
+ {
265
+
266
+ $tablePrefix = (string)Mage::getConfig()->getTablePrefix();
267
+
268
+ $sqlQuery = 'UPDATE '.$tablePrefix.'yupick_recoger SET ' .
269
+ 'order_id = "' . $idOrder . '", ' .
270
+ ' entity_type = "order" ' .
271
+ ' WHERE quote_id = "' . $idQuote . '" ' .
272
+ ' AND entity_type = "quote" LIMIT 1';
273
+
274
+
275
+ $dbWrite = Mage::getSingleton('core/resource')->getConnection('core_write');
276
+ $dbWrite->query($sqlQuery);
277
+ }
278
+
279
+
280
+ /**
281
+ *
282
+ */
283
+ public function readCheckoutData ($entityType, $checkoutId)
284
+ {
285
+
286
+ $tablePrefix = (string)Mage::getConfig()->getTablePrefix();
287
+ $sqlQuery = 'SELECT * FROM '.$tablePrefix.'yupick_recoger WHERE '.$entityType.'_id = "'.$checkoutId.'" AND entity_type = "'.$entityType.'" ORDER BY id DESC LIMIT 1';
288
+ $dbRead = Mage::getSingleton('core/resource')->getConnection('core_read');
289
+
290
+ $row = $dbRead->fetchAll($sqlQuery);
291
+
292
+ if (!$row)
293
+ {
294
+ return false;
295
+ } else {
296
+ return $row[0];
297
+ }
298
+
299
+ }
300
+
301
+
302
+ /**
303
+ *
304
+ */
305
+ public function readUltimoEstado($order, $yupickId)
306
+ {
307
+
308
+ if (!Mage::getStoreConfig('yupick/general/active')) return false;
309
+ if (!Mage::getStoreConfig('yupick/general/etiquetador')) return false;
310
+
311
+
312
+ $URL=Mage::helper('yupick')->getUrlRequest('situacion_url');
313
+ $client = new SoapClient($URL);
314
+
315
+ // Realizamos la peticion
316
+ //$result = $client->getSituacionActual(Mage::getStoreConfig('yupick/general/etiquetador'),$order,$yupickId);
317
+ $result = $client->getSituacionActual(Mage::getStoreConfig('yupick/general/etiquetador'),'',$yupickId);
318
+
319
+
320
+ return $result;
321
+
322
+ }
323
+
324
+
325
+
326
+ /**
327
+ *
328
+ */
329
+ public function readEstadoPedido($order, $yupickId)
330
+ {
331
+
332
+ if (!Mage::getStoreConfig('yupick/general/active')) return false;
333
+ if (!Mage::getStoreConfig('yupick/general/etiquetador')) return false;
334
+
335
+
336
+ $URL=Mage::helper('yupick')->getUrlRequest('trazabilidad_url');
337
+ $client = new SoapClient($URL);
338
+
339
+ // Realizamos la peticion
340
+ $result = $client->getTrazabilidad(Mage::getStoreConfig('yupick/general/etiquetador'),$order,$yupickId);
341
+
342
+
343
+ if ($this->is_valid_xml($result))
344
+ {
345
+ $dataXml = simplexml_load_string($result);
346
+ $dataXml = $this->objectToArray($dataXml);
347
+
348
+ if (!isset($dataXml['accion'][0]))
349
+ {
350
+ $_tmpData = $dataXml['accion'];
351
+ unset($dataXml);
352
+ $dataXml['accion'][0] = $_tmpData;
353
+ }
354
+
355
+ } else {
356
+
357
+
358
+ return false;
359
+ }
360
+
361
+ return $dataXml;
362
+
363
+ }
364
+
365
+ }
app/code/local/Ydral/Yupick/Model/Ydral/Shipment.php ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ydral_Yupick_Model_Ydral_Shipment extends Mage_Sales_Model_Order_Shipment
3
+ {
4
+
5
+ /**
6
+ *
7
+ */
8
+ protected function _beforeSave()
9
+ {
10
+
11
+ $envio = array();
12
+ $_order = $this->getOrder();
13
+
14
+
15
+ /**
16
+ * solo para yupick!, otros metodos siguen igual
17
+ */
18
+ if ($_order->getShippingMethod() != 'yupick_yupick')
19
+ {
20
+ return parent::_beforeSave();
21
+ }
22
+
23
+
24
+ $_dataRecogida = Mage::getModel('yupick/ydral_recogeroficina')->readCheckoutData('order', $_order->getRealOrderId());
25
+
26
+ if (!$_dataRecogida)
27
+ {
28
+ return false;
29
+ } else {
30
+ if (!Mage::getStoreConfig('yupick/general/active')) return false;
31
+ if (!Mage::getStoreConfig('yupick/general/etiquetador')) return false;
32
+ }
33
+
34
+
35
+ $URL=Mage::helper('yupick')->getUrlRequest('entrega_url');
36
+
37
+ if ($_dataRecogida['tipo_aviso'] == '')
38
+ {
39
+ $_tipoNotificacion = 'Email';
40
+ } else {
41
+ $_tipoNotificacion = $_dataRecogida['tipo_aviso'];
42
+ }
43
+
44
+ $_direccionEmail = '';
45
+ $_numMovil = '';
46
+ switch ($_tipoNotificacion)
47
+ {
48
+ case 'Email':
49
+ if (empty($_dataRecogida['correo']))
50
+ {
51
+ $_direccionEmail = $_order->getShippingAddress()->getEmail();
52
+ } else {
53
+ $_direccionEmail = $_dataRecogida['correo'];
54
+ }
55
+ break;
56
+
57
+ case 'SMS':
58
+ if (empty($_dataRecogida['movil']))
59
+ {
60
+ $_numMovil = $_order->getShippingAddress()->getTelephone();
61
+ } else {
62
+ $_numMovil = $_dataRecogida['movil'];
63
+ }
64
+ break;
65
+
66
+ }
67
+
68
+
69
+ $_idCliente = $_order->getCustomerId();
70
+ $_nombreCliente = $_order->getShippingAddress()->getFirstname() . " " . $_order->getShippingAddress()->getLastname();
71
+ $_numTelefono = $_order->getShippingAddress()->getTelephone();
72
+ $_numBultos = 1;
73
+ $_pesoPaquete = $_order->getWeight();
74
+ $_precioCobrar = '';
75
+ $_fechaPedido = date('Y-m-d', strtotime($_order->getCreatedAt()));
76
+ if (Mage::getStoreConfig('yupick/configuracion/seguro'))
77
+ {
78
+ $_importeSeguro = Mage::getStoreConfig('yupick/configuracion/valorseguro');
79
+ } else {
80
+ $_importeSeguro = '';
81
+ }
82
+ $_idPuntoEntrega = $_dataRecogida['oficina_recogida'];
83
+ $_idPedido = $_order->getRealOrderId();
84
+
85
+ // peticion
86
+ try {
87
+
88
+ $client = new SoapClient($URL);
89
+ $result = $client->InsertarEntrega(Mage::getStoreConfig('yupick/general/etiquetador'),
90
+ $_nombreCliente,
91
+ $_numTelefono,
92
+ $_numMovil,
93
+ $_direccionEmail,
94
+ $_numBultos,
95
+ $_pesoPaquete,
96
+ $_precioCobrar,
97
+ $_fechaPedido,
98
+ $_tipoNotificacion,
99
+ $_importeSeguro,
100
+ $_idPuntoEntrega,
101
+ $_idPedido
102
+ );
103
+
104
+ } catch (Exception $e) {
105
+ Mage::throwException(
106
+ Mage::helper('sales')->__('Error: ' . $e->getMessage())
107
+ );
108
+ return false;
109
+ }
110
+
111
+
112
+ list($_statusEnvio, $_statusInfo) = explode("-", $result);
113
+
114
+ if (trim(strtolower($_statusEnvio)) == 'ok')
115
+ {
116
+
117
+ Mage::getSingleton('adminhtml/session')->addNotice('El pedido ha quedado registrado en el servicio de Yupick!.');
118
+ Mage::getSingleton('adminhtml/session')->addNotice('Identificador de la entrega: ' . trim($_statusInfo));
119
+
120
+ $track = Mage::getModel('sales/order_shipment_track')
121
+ ->setNumber(trim($_statusInfo))
122
+ ->setCarrierCode('Yupick')
123
+ ->setTitle('Seguimiento Yupick');
124
+
125
+ $this->addTrack($track);
126
+
127
+ $this->preregistroYupick($_idPedido, trim($_statusInfo));
128
+
129
+ } else {
130
+
131
+ Mage::throwException(
132
+ Mage::helper('sales')->__('Error: ' . trim($_statusInfo))
133
+ );
134
+ return false;
135
+
136
+ }
137
+
138
+ $canSave = parent::_beforeSave();
139
+ return $canSave;
140
+
141
+
142
+ }
143
+
144
+ protected function preregistroYupick($idOrder, $idYupick)
145
+ {
146
+
147
+ $tablePrefix = (string)Mage::getConfig()->getTablePrefix();
148
+
149
+ $sqlQuery = 'UPDATE '.$tablePrefix.'yupick_recoger SET ' .
150
+ 'id_registro_yupick = "' . $idYupick . '" ' .
151
+ ' WHERE order_id = "' . $idOrder . '" ' .
152
+ ' AND entity_type = "order" LIMIT 1';
153
+
154
+
155
+ $dbWrite = Mage::getSingleton('core/resource')->getConnection('core_write');
156
+ $dbWrite->query($sqlQuery);
157
+
158
+ }
159
+
160
+ }
app/code/local/Ydral/Yupick/Model/Ydral/Source/Method.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ydral_Yupick_Model_Ydral_Source_Method
3
+ {
4
+
5
+ protected $_options = array();
6
+
7
+ public function toOptionArray()
8
+ {
9
+ if(!count($this->_options))
10
+ {
11
+
12
+ $this->_options[1] = array('value' => 'etiquetador',
13
+ 'label' => 'Etiquetador');
14
+ $this->_options[2] = array('value' => 'cliente',
15
+ 'label' => 'Cliente');
16
+ array_unshift($this->_options, array('value'=>'','label'=> ''));
17
+ }
18
+
19
+ return $this->_options;
20
+ }
21
+
22
+
23
+ public function getMethod($shippingMethod)
24
+ {
25
+
26
+ die("HOLA");
27
+
28
+ $mte= explode("_",$shippingMethod);
29
+ if ($mte[0]=="Yupick")
30
+ {
31
+ $label=$mte[1];
32
+ foreach($this->toOptionArray() as $mta)
33
+ {
34
+ if ($mta["label"]==$label) $metodo=$mta;
35
+ }
36
+ }
37
+ return $metodo;
38
+ }
39
+
40
+ }
app/code/local/Ydral/Yupick/Model/Yupick.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ydral_Yupick_Model_Yupick extends Mage_Core_Model_Abstract
4
+ {
5
+ protected function _construct()
6
+ {
7
+ $this->_init('yupick/yupick');
8
+ }
9
+ }
app/code/local/Ydral/Yupick/controllers/IndexController.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ydral_Yupick_IndexController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ public function getdataAction()
6
+ {
7
+
8
+ if ($this->getRequest()->isPost())
9
+ {
10
+
11
+ $data['codigoPostal'] = $this->getRequest()->getPost('codigoPostal');
12
+
13
+ $data['option_parking'] = $this->getRequest()->getPost('option_parking');
14
+ $data['option_wifi'] = $this->getRequest()->getPost('option_wifi');
15
+ $data['option_alimentacion'] = $this->getRequest()->getPost('option_alimentacion');
16
+ $data['option_prensa'] = $this->getRequest()->getPost('option_prensa');
17
+ $data['option_tarjeta'] = $this->getRequest()->getPost('option_tarjeta');
18
+ $data['option_mas20'] = $this->getRequest()->getPost('option_mas20');
19
+ $data['option_sabados'] = $this->getRequest()->getPost('option_sabados');
20
+ $data['option_domingos'] = $this->getRequest()->getPost('option_domingos');
21
+
22
+ }
23
+
24
+ //$data['codigoPostal'] = '48005';
25
+ //$data['option_parking'] = $data['option_wifi'] = $data['option_alimentacion'] = $data['option_prensa'] = $data['option_tarjeta'] = $data['option_mas20'] = $data['option_sabados'] = $data['option_domingos'] = '';
26
+ //print_r($data); die();
27
+ $_htmlOficinas = Mage::getModel('yupick/ydral_recogeroficina')->getHtmlOficinas($data);
28
+ $this->getResponse()->setBody($_htmlOficinas);
29
+
30
+ }
31
+
32
+ }
app/code/local/Ydral/Yupick/etc/config.xml ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <modules>
5
+ <Ydral_Yupick>
6
+ <version>0.3.0</version>
7
+ </Ydral_Yupick>
8
+ </modules>
9
+ <global>
10
+
11
+ <blocks>
12
+ <yupick>
13
+ <class>Ydral_Yupick_Block</class>
14
+ </yupick>
15
+ <checkout>
16
+ <rewrite>
17
+ <onepage_shipping_method_available>Ydral_Yupick_Block_Checkout_Onepage_Shipping_Method_Available</onepage_shipping_method_available>
18
+ </rewrite>
19
+ </checkout>
20
+ </blocks>
21
+
22
+ <helpers>
23
+ <!-- Mage::helper('yupick') -->
24
+ <yupick>
25
+ <class>Ydral_Yupick_Helper</class>
26
+ </yupick>
27
+ </helpers>
28
+
29
+ <models>
30
+ <!-- Mage::getModel('yupick/yupick') -->
31
+ <yupick>
32
+ <class>Ydral_Yupick_Model</class>
33
+ </yupick>
34
+ <sales>
35
+ <rewrite>
36
+ <order_shipment>Ydral_Yupick_Model_Ydral_Shipment</order_shipment>
37
+ </rewrite>
38
+ </sales>
39
+
40
+ <checkout>
41
+ <rewrite>
42
+ <type_onepage>Ydral_Yupick_Model_Type_Onepage</type_onepage>
43
+ </rewrite>
44
+ </checkout>
45
+
46
+ </models>
47
+
48
+ <resources>
49
+ <!-- Mage::getResourceModel('yupick/yupick') or Mage::getResourceSingleton('yupick/yupick') -->
50
+ <yupick_setup>
51
+ <setup>
52
+ <module>Ydral_Yupick</module>
53
+ </setup>
54
+ <connection>
55
+ <use>core_setup</use>
56
+ </connection>
57
+ </yupick_setup>
58
+ <yupick_read>
59
+ <connection>
60
+ <use>core_read</use>
61
+ </connection>
62
+ </yupick_read>
63
+ <yupick_write>
64
+ <connection>
65
+ <use>core_write</use>
66
+ </connection>
67
+ </yupick_write>
68
+ </resources>
69
+
70
+ </global>
71
+
72
+ <frontend>
73
+ <routers>
74
+ <yupick>
75
+ <use>standard</use>
76
+ <args>
77
+ <module>Ydral_Yupick</module>
78
+ <frontName>yupick</frontName>
79
+ </args>
80
+ </yupick>
81
+ </routers>
82
+ <layout>
83
+ <updates>
84
+ <Yupick>
85
+ <file>yupick.xml</file>
86
+ </Yupick>
87
+ </updates>
88
+ </layout>
89
+ <events>
90
+ <checkout_controller_onepage_save_shipping_method>
91
+ <observers>
92
+ <ydral_yupick_shipping_observer>
93
+ <type>model</type>
94
+ <class>Ydral_Yupick_Helper_Data</class>
95
+ <method>setOficinaYupickRecogida</method>
96
+ </ydral_yupick_shipping_observer>
97
+ </observers>
98
+ </checkout_controller_onepage_save_shipping_method>
99
+ <checkout_onepage_controller_success_action>
100
+ <observers>
101
+ <ydral_yupick_order_observer>
102
+ <type>model</type>
103
+ <class>Ydral_Yupick_Helper_Data</class>
104
+ <method>setOficinaYupickRecogidaOrder</method>
105
+ </ydral_yupick_order_observer>
106
+ </observers>
107
+ </checkout_onepage_controller_success_action>
108
+ </events>
109
+ </frontend>
110
+ <adminhtml>
111
+ <layout>
112
+ <updates>
113
+ <yupick>
114
+ <file>yupick.xml</file>
115
+ </yupick>
116
+ </updates>
117
+ </layout>
118
+ <acl>
119
+ <resources>
120
+ <admin>
121
+ <children>
122
+ <system>
123
+ <children>
124
+ <config>
125
+ <children>
126
+ <yupick translate="title" module="yupick">
127
+ <title><![CDATA[Yupick Configuraci&oacute;n]]></title>
128
+ </yupick>
129
+ </children>
130
+ </config>
131
+ </children>
132
+ </system>
133
+ </children>
134
+ </admin>
135
+ </resources>
136
+ </acl>
137
+ </adminhtml>
138
+ <admin>
139
+ <routers>
140
+ <yupick>
141
+ <use>admin</use>
142
+ <args>
143
+ <module>Ydral_Yupick</module>
144
+ <frontName>yupick</frontName>
145
+ </args>
146
+ </yupick>
147
+ <adminhtml>
148
+ <args>
149
+ <modules>
150
+ <ydral_yupick before="Mage_Adminhtml">Ydral_Yupick_Registro</ydral_yupick>
151
+ </modules>
152
+ </args>
153
+ </adminhtml>
154
+ </routers>
155
+ </admin>
156
+ <default>
157
+ <yupick>
158
+ <general>
159
+ <active>0</active>
160
+ <etiquetador>76Hv8rzPr9tm8x78vsHkfd3hu</etiquetador>
161
+ <entrega_url>http://www.yupick.es/yupick.clientes/webservice/WSEntregas.php?wsdl</entrega_url>
162
+ <etiqueta_url>http://www.yupick.es/yupick.clientes/webservice/etiquetaslaser.php</etiqueta_url>
163
+ <situacion_url>http://www.yupick.es/yupick.clientes/webservice/WSsituacionactual.php?wsdl</situacion_url>
164
+ <trazabilidad_url>http://www.yupick.es/yupick.clientes/webservice/WStrazabilidad.php?wsdl</trazabilidad_url>
165
+ <entrega_url_pre>http://82.223.239.219/yupick.clientes/webservice/WSEntregas.php?wsdl</entrega_url_pre>
166
+ <etiqueta_url_pre>http://82.223.239.219/yupick.clientes/webservice/etiquetaslaser.php</etiqueta_url_pre>
167
+ <situacion_url_pre>http://82.223.239.219/yupick.clientes/webservice/WSsituacionactual.php?wsdl</situacion_url_pre>
168
+ <trazabilidad_url_pre>http://82.223.239.219/yupick.clientes/webservice/WStrazabilidad.php?wsdl</trazabilidad_url_pre>
169
+ </general>
170
+ </yupick>
171
+ <carriers>
172
+ <yupick>
173
+ <active>0</active>
174
+ <title><![CDATA[Recoger paquete en tu punto Yupick! m&aacute;s cercana a su direcci&oacute;n de env&iacute;o]]></title>
175
+ <model>yupick/ydral_recogeroficina</model>
176
+ <gateway_url>http://www.yupick.es/yupick.clientes/webservice/WSpuntoentrega.php?wsdl</gateway_url>
177
+ <gateway_url_pre>http://82.223.239.219/yupick.clientes/webservice/WSpuntoentrega.php?wsdl</gateway_url_pre>
178
+ </yupick>
179
+ </carriers>
180
+ </default>
181
+ </config>
app/code/local/Ydral/Yupick/etc/system.xml ADDED
@@ -0,0 +1,240 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <yupick translate="label" module="yupick">
5
+ <label><![CDATA[Yupick 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>yupick-section</class>
12
+ <header_css>yupick-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>Activar</label>
24
+ <frontend_type>select</frontend_type>
25
+ <source_model>adminhtml/system_config_source_yesno</source_model>
26
+ <sort_order>10</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[Clave de usuario]]></label>
33
+ <frontend_type>text</frontend_type>
34
+ <sort_order>20</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
+ <entorno_produccion translate="label">
40
+ <label><![CDATA[Activar entorno de producci&oacute;n]]></label>
41
+ <frontend_type>select</frontend_type>
42
+ <source_model>adminhtml/system_config_source_yesno</source_model>
43
+ <sort_order>40</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
+ </entorno_produccion>
48
+
49
+ <entrega_url translate="label comment">
50
+ <label><![CDATA[Url registro de env&iacute;o - Producci&oacute;n]]></label>
51
+ <frontend_type>text</frontend_type>
52
+ <sort_order>50</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
+ </entrega_url>
57
+ <entrega_url_pre translate="label comment">
58
+ <label><![CDATA[Url registro de env&iacute;o - Pre-Producci&oacute;n]]></label>
59
+ <frontend_type>text</frontend_type>
60
+ <sort_order>60</sort_order>
61
+ <show_in_default>1</show_in_default>
62
+ <show_in_website>1</show_in_website>
63
+ <show_in_store>1</show_in_store>
64
+ </entrega_url_pre>
65
+ <situacion_url translate="label comment">
66
+ <label><![CDATA[URL para situaci&oacute;n - Producci&oacute;n]]></label>
67
+ <frontend_type>text</frontend_type>
68
+ <sort_order>70</sort_order>
69
+ <show_in_default>1</show_in_default>
70
+ <show_in_website>1</show_in_website>
71
+ <show_in_store>1</show_in_store>
72
+ </situacion_url>
73
+ <situacion_url_pre translate="label comment">
74
+ <label><![CDATA[URL para situaci&oacute;n - Pre-Producci&oacute;n]]></label>
75
+ <frontend_type>text</frontend_type>
76
+ <sort_order>80</sort_order>
77
+ <show_in_default>1</show_in_default>
78
+ <show_in_website>1</show_in_website>
79
+ <show_in_store>1</show_in_store>
80
+ </situacion_url_pre>
81
+ <trazabilidad_url translate="label comment">
82
+ <label><![CDATA[URL para seguimiento - Producci&oacute;n]]></label>
83
+ <frontend_type>text</frontend_type>
84
+ <sort_order>90</sort_order>
85
+ <show_in_default>1</show_in_default>
86
+ <show_in_website>1</show_in_website>
87
+ <show_in_store>1</show_in_store>
88
+ </trazabilidad_url>
89
+ <trazabilidad_url_pre translate="label comment">
90
+ <label><![CDATA[URL para seguimiento - Pre-Producci&oacute;n]]></label>
91
+ <frontend_type>text</frontend_type>
92
+ <sort_order>100</sort_order>
93
+ <show_in_default>1</show_in_default>
94
+ <show_in_website>1</show_in_website>
95
+ <show_in_store>1</show_in_store>
96
+ </trazabilidad_url_pre>
97
+
98
+ <etiqueta_url translate="label comment">
99
+ <label><![CDATA[URL para etiquetado - Producci&oacute;n]]></label>
100
+ <frontend_type>text</frontend_type>
101
+ <sort_order>110</sort_order>
102
+ <show_in_default>1</show_in_default>
103
+ <show_in_website>1</show_in_website>
104
+ <show_in_store>1</show_in_store>
105
+ </etiqueta_url>
106
+ <etiqueta_url_pre translate="label comment">
107
+ <label><![CDATA[URL para etiquetado - Pre-Producci&oacute;n]]></label>
108
+ <frontend_type>text</frontend_type>
109
+ <sort_order>120</sort_order>
110
+ <show_in_default>1</show_in_default>
111
+ <show_in_website>1</show_in_website>
112
+ <show_in_store>1</show_in_store>
113
+ </etiqueta_url_pre>
114
+
115
+ </fields>
116
+ </general>
117
+ <configuracion translate="label">
118
+ <label>Datos para el paquete</label>
119
+ <frontend_type>text</frontend_type>
120
+ <sort_order>20</sort_order>
121
+ <show_in_default>1</show_in_default>
122
+ <show_in_website>1</show_in_website>
123
+ <show_in_store>1</show_in_store>
124
+ <fields>
125
+ <seguro translate="label">
126
+ <label>Seguro del paquete</label>
127
+ <frontend_type>select</frontend_type>
128
+ <source_model>adminhtml/system_config_source_yesno</source_model>
129
+ <sort_order>10</sort_order>
130
+ <show_in_default>1</show_in_default>
131
+ <show_in_website>1</show_in_website>
132
+ <show_in_store>1</show_in_store>
133
+ </seguro>
134
+ <valorseguro translate="label comment">
135
+ <label><![CDATA[Valor asegurado]]></label>
136
+ <frontend_type>text</frontend_type>
137
+ <sort_order>20</sort_order>
138
+ <show_in_default>1</show_in_default>
139
+ <show_in_website>1</show_in_website>
140
+ <show_in_store>1</show_in_store>
141
+ </valorseguro>
142
+ </fields>
143
+ </configuracion>
144
+ </groups>
145
+ </yupick>
146
+ <carriers>
147
+ <groups>
148
+ <yupick translate="label" module="shipping">
149
+ <label><![CDATA[Yupick - Recoger en oficina]]></label>
150
+ <frontend_type>text</frontend_type>
151
+ <sort_order>30</sort_order>
152
+ <show_in_default>1</show_in_default>
153
+ <show_in_website>1</show_in_website>
154
+ <show_in_store>1</show_in_store>
155
+ <fields>
156
+ <active translate="label">
157
+ <label>Activar</label>
158
+ <frontend_type>select</frontend_type>
159
+ <source_model>adminhtml/system_config_source_yesno</source_model>
160
+ <sort_order>10</sort_order>
161
+ <show_in_default>1</show_in_default>
162
+ <show_in_website>1</show_in_website>
163
+ <show_in_store>1</show_in_store>
164
+ </active>
165
+ <title translate="label">
166
+ <label>Title</label>
167
+ <frontend_type>text</frontend_type>
168
+ <sort_order>20</sort_order>
169
+ <show_in_default>1</show_in_default>
170
+ <show_in_website>1</show_in_website>
171
+ <show_in_store>1</show_in_store>
172
+ </title>
173
+ <price_shipping translate="label">
174
+ <label>Precio</label>
175
+ <frontend_type>text</frontend_type>
176
+ <sort_order>30</sort_order>
177
+ <show_in_default>1</show_in_default>
178
+ <show_in_website>1</show_in_website>
179
+ <show_in_store>1</show_in_store>
180
+ </price_shipping>
181
+ <showmethod translate="label">
182
+ <label>Show method if not applicable</label>
183
+ <frontend_type>select</frontend_type>
184
+ <sort_order>40</sort_order>
185
+ <source_model>adminhtml/system_config_source_yesno</source_model>
186
+ <show_in_default>1</show_in_default>
187
+ <show_in_website>1</show_in_website>
188
+ <show_in_store>1</show_in_store>
189
+ </showmethod>
190
+ <sallowspecific translate="label">
191
+ <label>Ship to Applicable Countries</label>
192
+ <frontend_type>select</frontend_type>
193
+ <sort_order>44</sort_order>
194
+ <frontend_class>shipping-applicable-country</frontend_class>
195
+ <source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>
196
+ <show_in_default>1</show_in_default>
197
+ <show_in_website>1</show_in_website>
198
+ <show_in_store>1</show_in_store>
199
+ </sallowspecific>
200
+ <specificcountry translate="label">
201
+ <label>Ship to Specific Countries</label>
202
+ <frontend_type>multiselect</frontend_type>
203
+ <sort_order>45</sort_order>
204
+ <source_model>adminhtml/system_config_source_country</source_model>
205
+ <show_in_default>1</show_in_default>
206
+ <show_in_website>1</show_in_website>
207
+ <show_in_store>0</show_in_store>
208
+ <can_be_empty>1</can_be_empty>
209
+ </specificcountry>
210
+ <gateway_url translate="label comment">
211
+ <label><![CDATA[URL para punto de recogida - Producci&oacute;n]]></label>
212
+ <frontend_type>text</frontend_type>
213
+ <sort_order>50</sort_order>
214
+ <show_in_default>1</show_in_default>
215
+ <show_in_website>1</show_in_website>
216
+ <show_in_store>1</show_in_store>
217
+ </gateway_url>
218
+ <gateway_url_pre translate="label comment">
219
+ <label><![CDATA[URL para punto de recogida - Pre-Producci&oacute;n]]></label>
220
+ <frontend_type>text</frontend_type>
221
+ <sort_order>60</sort_order>
222
+ <show_in_default>1</show_in_default>
223
+ <show_in_website>1</show_in_website>
224
+ <show_in_store>1</show_in_store>
225
+ </gateway_url_pre>
226
+ <sort_order translate="label">
227
+ <label>Sort Order</label>
228
+ <frontend_type>text</frontend_type>
229
+ <sort_order>500</sort_order>
230
+ <show_in_default>1</show_in_default>
231
+ <show_in_website>1</show_in_website>
232
+ <show_in_store>1</show_in_store>
233
+ </sort_order>
234
+ </fields>
235
+ </yupick>
236
+
237
+ </groups>
238
+ </carriers>
239
+ </sections>
240
+ </config>
app/code/local/Ydral/Yupick/sql/yupick_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+
4
+ $installer->startSetup();
5
+
6
+ $installer->run("
7
+ CREATE TABLE IF NOT EXISTS {$this->getTable('yupick_recoger')} (
8
+ `id` int(5) NOT NULL AUTO_INCREMENT,
9
+ `entity_type` varchar(50) NOT NULL,
10
+ `quote_id` int(12) NOT NULL,
11
+ `order_id` int(12) NOT NULL,
12
+ `oficina_recogida` varchar(10) NOT NULL,
13
+ `tipo_aviso` varchar(20) NOT NULL,
14
+ `movil` varchar(255) NOT NULL,
15
+ `correo` varchar(255) NOT NULL,
16
+ `info_oficina` text NOT NULL,
17
+ `id_registro_yupick` int(12) NOT NULL,
18
+ PRIMARY KEY (`id`),
19
+ KEY `checkout_id` (`quote_id`)
20
+ ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
21
+ ");
22
+ $installer->endSetup();
app/code/local/Ydral/Yupick/sql/yupick_setup/mysql4-upgrade-0.1.0-0.2.0.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ $installer = $this;
app/code/local/Ydral/Yupick/sql/yupick_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/yupick.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <adminhtml_sales_order_view>
4
+ <reference name="order_tab_info">
5
+ <action method="setTemplate" ifconfig="carriers/yupick/active">
6
+ <template>yupick/tab_info.phtml</template>
7
+ </action>
8
+ </reference>
9
+ </adminhtml_sales_order_view>
10
+ </layout>
app/design/adminhtml/default/default/template/yupick/tab_info.phtml ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ <div>
29
+ <div id="order-messages">
30
+ <?php echo $this->getChildHtml('order_messages') ?>
31
+ </div>
32
+ <?php echo $this->getChildHtml('order_info') ?>
33
+ <input type="hidden" name="order_id" value="<?php echo $_order->getId() ?>"/>
34
+ <?php if ($_order->getIsVirtual()): ?>
35
+ <div class="box-right">
36
+ <?php else: ?>
37
+ <div class="box-left">
38
+ <?php endif; ?>
39
+ <!--Payment Method-->
40
+ <div class="entry-edit">
41
+ <div class="entry-edit-head">
42
+ <h4 class="icon-head head-payment-method"><?php echo Mage::helper('sales')->__('Payment Information') ?></h4>
43
+ </div>
44
+ <fieldset>
45
+ <?php echo $this->getPaymentHtml() ?>
46
+ <div><?php echo Mage::helper('sales')->__('Order was placed using %s', $_order->getOrderCurrencyCode()) ?></div>
47
+ </fieldset>
48
+ </div>
49
+ </div>
50
+ <?php if (!$_order->getIsVirtual()): ?>
51
+ <div class="box-right">
52
+ <!--Shipping Method-->
53
+ <div class="entry-edit">
54
+ <div class="entry-edit-head">
55
+ <h4 class="icon-head head-shipping-method"><?php echo Mage::helper('sales')->__('Shipping &amp; Handling Information') ?></h4>
56
+ </div>
57
+ <fieldset>
58
+ <?php if ($_order->getTracksCollection()->count()) : ?>
59
+ <?php if (version_compare(Mage::getVersion(), '1.4.0', '<=')): ?>
60
+ <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>
61
+ <?php else: ?>
62
+ <a href="#" id="linkId" onclick="popWin('<?php echo $this->helper('shipping')->getTrackingPopupUrlByOrderId($_order) ?>','trackorder','width=800,height=600,resizable=yes,scrollbars=yes')" title="<?php echo $this->__('Track Order') ?>"><?php echo $this->__('Track Order') ?></a>
63
+ <?php endif; ?>
64
+ <br/>
65
+ <?php endif; ?>
66
+ <?php if ($_order->getShippingDescription()): ?>
67
+ <strong><?php echo $_order->getShippingDescription() ?></strong>
68
+
69
+
70
+ <?php
71
+ /* YUPICK START */
72
+ if ($_order->getShippingMethod() == 'yupick_yupick'):
73
+
74
+ $_dataRecogida = Mage::getModel('yupick/ydral_recogeroficina')->readCheckoutData('order', $_order->getRealOrderId());
75
+ if ($_dataRecogida)
76
+ {
77
+ echo '<br />'.$_dataRecogida['info_oficina'];
78
+ }
79
+ ?>
80
+ <br />
81
+ <?php echo $this->__('Gastos de env&iacute;o: ') ?>
82
+
83
+ <?php
84
+ endif;
85
+ /* YUPICK END */
86
+ ?>
87
+
88
+
89
+ <?php if ($this->helper('tax')->displayShippingPriceIncludingTax()): ?>
90
+ <?php $_excl = $this->displayShippingPriceInclTax($_order); ?>
91
+ <?php else: ?>
92
+ <?php $_excl = $this->displayPriceAttribute('shipping_amount', false, ' '); ?>
93
+ <?php endif; ?>
94
+ <?php $_incl = $this->displayShippingPriceInclTax($_order); ?>
95
+
96
+ <?php echo $_excl; ?>
97
+ <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
98
+ (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
99
+ <?php endif; ?>
100
+
101
+ <?php
102
+ /* YUPICK START */
103
+ if ($_order->getShippingMethod() == 'yupick_yupick'):
104
+
105
+ $tracks = $_order->getTracksCollection();
106
+ foreach ($tracks as $track):
107
+ $trackingInfo = $track->getNumberDetail();
108
+ ?>
109
+ <br />
110
+ <a href="<?php echo Mage::helper('yupick')->getUrlRequest('etiqueta_url'); ?>?clave=<?php echo htmlentities(Mage::getStoreConfig('yupick/general/etiquetador'));?>&id=<?php echo $trackingInfo['number']; ?>">Imprimir Etiqueta</a>
111
+
112
+ <br /><br />
113
+
114
+ <b><?php echo $this->__('Estado del env&iacute;o:') ?></b> <?php echo Mage::getModel('yupick/ydral_recogeroficina')->readUltimoEstado($_order->getRealOrderId(), $trackingInfo['number']); ?>
115
+ <?php endforeach; ?>
116
+
117
+ <?php else: ?>
118
+ <?php echo $this->helper('sales')->__('No shipping information available'); ?>
119
+ <?php endif; ?>
120
+
121
+ <?php
122
+ endif;
123
+ /* YUPICK END */
124
+ ?>
125
+ </fieldset>
126
+ </div>
127
+ </div>
128
+ <?php endif; ?>
129
+ <div class="clear"></div>
130
+ <?php echo $this->getGiftOptionsHtml() ?>
131
+ <div class="clear"></div>
132
+ <div class="entry-edit">
133
+ <div class="entry-edit-head">
134
+ <h4 class="icon-head head-products"><?php echo Mage::helper('sales')->__('Items Ordered') ?></h4>
135
+ </div>
136
+ </div>
137
+ <?php echo $this->getItemsHtml() ?>
138
+ <div class="clear"></div>
139
+
140
+ <div class="box-left">
141
+ <div class="entry-edit">
142
+ <div class="entry-edit-head">
143
+ <h4><?php echo Mage::helper('sales')->__('Comments History') ?></h4>
144
+ </div>
145
+ <fieldset><?php echo $this->getChildHtml('order_history') ?></fieldset>
146
+ </div>
147
+ </div>
148
+ <div class="box-right entry-edit">
149
+ <div class="entry-edit-head"><h4><?php echo Mage::helper('sales')->__('Order Totals') ?></h4></div>
150
+ <div class="order-totals"><?php echo $this->getChildHtml('order_totals') ?></div>
151
+ </div>
152
+ <div class="clear"></div>
153
+ </div>
154
+
155
+ <?php echo $this->getChildHtml('popup_window');?>
156
+ <script type="text/javascript">
157
+ //<![CDATA[
158
+ /**
159
+ * Retrieve gift options tooltip content
160
+ */
161
+ function getGiftOptionsTooltipContent(itemId) {
162
+ var contentLines = [];
163
+ var headerLine = null;
164
+ var contentLine = null;
165
+
166
+ $$('#gift_options_data_' + itemId + ' .gift-options-tooltip-content').each(function (element) {
167
+ if (element.down(0)) {
168
+ headerLine = element.down(0).innerHTML;
169
+ contentLine = element.down(0).next().innerHTML;
170
+ if (contentLine.length > 30) {
171
+ contentLine = contentLine.slice(0,30) + '...';
172
+ }
173
+ contentLines.push(headerLine + ' ' + contentLine);
174
+ }
175
+ });
176
+ return contentLines.join('<br/>');
177
+ }
178
+ giftOptionsTooltip.setTooltipContentLoaderFunction(getGiftOptionsTooltipContent);
179
+ //]]>
180
+ </script>
app/design/frontend/base/default/layout/yupick.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <checkout_onepage_index>
4
+ <reference name="head" ifconfig="carriers/yupick/active">
5
+ <action method="addCss"><stylesheet>css/yupick.css</stylesheet></action>
6
+ <action method="addItem"><type>skin_js</type><name>js/yupick.js</name></action>
7
+ <block type="core/text" name="gmap.api.js"><action method="setText"><text><![CDATA[<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>]]></text></action></block>
8
+ </reference>
9
+ </checkout_onepage_index>
10
+ <checkout_onepage_shippingmethod>
11
+ <reference name="root">
12
+ <action method="setTemplate" ifconfig="carriers/yupick/active"><template>yupick/shipping.phtml</template></action>
13
+ </reference>
14
+ </checkout_onepage_shippingmethod>
15
+ <sales_order_view>
16
+ <reference name="sales.order.info">
17
+ <action method="setTemplate" ifconfig="yupick/general/active"><template>yupick/info.phtml</template></action>
18
+ </reference>
19
+ </sales_order_view>
20
+ </layout>
app/design/frontend/base/default/template/yupick/info.phtml ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
72
+ <?php
73
+ /* YUPICK START */
74
+ if ($_order->getShippingMethod() == 'yupick_yupick'):
75
+
76
+ $_dataRecogida = Mage::getModel('yupick/ydral_recogeroficina')->readCheckoutData('order', $_order->getRealOrderId());
77
+ if ($_dataRecogida)
78
+ {
79
+ echo '<br />'.$_dataRecogida['info_oficina'];
80
+ }
81
+
82
+ $tracks = $_order->getTracksCollection();
83
+
84
+ if ( count($tracks) != 0 ):
85
+ foreach ($tracks as $track):
86
+
87
+ $trackingInfo = $track->getNumberDetail();
88
+ ?>
89
+ <br /><br />
90
+
91
+ <b><?php echo $this->__('Estado del env&iacute;o:') ?></b> <?php echo Mage::getModel('yupick/ydral_recogeroficina')->readUltimoEstado($_order->getRealOrderId(), $trackingInfo['number']); ?>
92
+ <?php
93
+ endforeach;
94
+ else:
95
+ ?>
96
+ <br /><br />
97
+ <b><?php echo $this->__('Estado del env&iacute;o:') ?></b> <?php echo $this->__('Sin informaci&oacute;n.') ?>
98
+ <?php
99
+ endif;
100
+ ?>
101
+
102
+ <?php
103
+ endif;
104
+ /* YUPICK END */
105
+ ?>
106
+
107
+
108
+ <?php else: ?>
109
+ <p><?php echo $this->helper('sales')->__('No shipping information available'); ?></p>
110
+ <?php endif; ?>
111
+ </div>
112
+ </div>
113
+ </div>
114
+ </div>
115
+ <?php endif; ?>
116
+ <div class="col2-set order-info-box">
117
+ <div class="col-1">
118
+ <div class="box">
119
+ <div class="box-title">
120
+ <h2><?php echo $this->__('Billing Address') ?></h2>
121
+ </div>
122
+ <div class="box-content">
123
+ <address><?php echo $_order->getBillingAddress()->format('html') ?></address>
124
+ </div>
125
+ </div>
126
+ </div>
127
+ <div class="col-2">
128
+ <div class="box box-payment">
129
+ <div class="box-title">
130
+ <h2><?php echo $this->__('Payment Method') ?></h2>
131
+ </div>
132
+ <div class="box-content">
133
+ <?php echo $this->getPaymentInfoHtml() ?>
134
+ </div>
135
+ </div>
136
+ </div>
137
+ </div>
app/design/frontend/base/default/template/yupick/shipping.phtml ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 if (!($_shippingRateGroups = $this->getShippingRates())): ?>
28
+ <p><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></p>
29
+ <?php else: ?>
30
+ <dl class="sp-methods">
31
+ <?php $shippingCodePrice = array(); ?>
32
+ <?php $_sole = count($_shippingRateGroups) == 1; foreach ($_shippingRateGroups as $code => $_rates): ?>
33
+ <dt>
34
+ <?php echo $this->getCarrierName($code) ?>
35
+ </dt>
36
+ <dd>
37
+ <ul>
38
+ <?php $_sole = $_sole && count($_rates) == 1; foreach ($_rates as $_rate): ?>
39
+ <?php $shippingCodePrice[] = "'".$_rate->getCode()."':".(float)$_rate->getPrice(); ?>
40
+ <li>
41
+ <?php if ($_rate->getErrorMessage()): ?>
42
+ <ul class="messages"><li class="error-msg"><ul><li><?php echo $_rate->getErrorMessage() ?></li></ul></li></ul>
43
+ <?php else: ?>
44
+
45
+ <?php if ($_sole) : ?>
46
+ <span class="no-display"><input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>" checked="checked" /></span>
47
+ <?php else: ?>
48
+ <input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$this->getAddressShippingMethod()) echo ' checked="checked"' ?> class="radio"/>
49
+
50
+ <?php if ($_rate->getCode() === $this->getAddressShippingMethod()): ?>
51
+ <script type="text/javascript">
52
+ //<![CDATA[
53
+ lastPrice = <?php echo (float)$_rate->getPrice(); ?>;
54
+ //]]>
55
+ </script>
56
+ <?php endif; ?>
57
+
58
+ <?php endif; ?>
59
+ <label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?>
60
+ <?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
61
+ <?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
62
+ <?php echo $_excl; ?>
63
+ <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
64
+ (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
65
+ <?php endif; ?>
66
+ <?php /* Yupick! */ ?>
67
+ <?php if ($_rate->getCode() === 'yupick_yupick'): ?>
68
+ <!--
69
+ <div>
70
+ <img src="<?php echo($this->getSkinUrl('images/yupick/logo_small.gif')) ?>" alt="Yupick!" />
71
+ </div>
72
+ -->
73
+ <img src="<?php echo($this->getSkinUrl('images/yupick/logo_small.gif')) ?>" alt="<?php echo Mage::helper('yupick')->__('Yupick') ?>" class="yupick-icon-checkout v-middle" />&nbsp;
74
+ <a href="http://www.yupick.es/quees.html" target="_blank"><?php echo Mage::helper('yupick')->__('&iquest;Qu&eacute; es Yupick!?') ?></a>
75
+ <?php endif; ?>
76
+ <?php /* End Yupick! */ ?>
77
+ </label>
78
+
79
+
80
+ <?php
81
+ /**
82
+ * Opciones:
83
+ * + Parking
84
+ * + Wi-Fi
85
+ * + Alimentacion
86
+ * + Prensa/Revistas
87
+ * + Tarjeta de Credito
88
+ * + Abierto mas de las 20h
89
+ * + Abierto sabados tarde
90
+ * + Abierto domingos
91
+ */
92
+ if ($_rate->getCode() === 'yupick_yupick'):
93
+ ?>
94
+ <br />
95
+ <?php /* <form id="yupick_options" name="yupick_options" action=""> */ ?>
96
+ <input type="hidden" id="codigoPostal" name="codigoPostal" value="<?php echo $this->getQuote()->getShippingAddress()->getPostcode(); ?>" />
97
+ <input type="hidden" id="checkUrl" name="checkUrl" value="<?php echo Mage::getUrl("yupick/index/getdata"); ?>" />
98
+ <input type="hidden" id="skinPath" name="skinPath" value="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN); ?>" />
99
+
100
+ <div id="yupick_carrier_principal" class="yupick_carrier_principal" style="display: none; ">
101
+ <input id="option_mas20" name="option_mas20" type="checkbox" value="1" />&nbsp;<label><?php echo $this->__('Est&aacute; abierto m&aacute;s de las 20h.'); ?></label>
102
+ <input id="option_sabados" name="option_sabados" type="checkbox" value="1" />&nbsp;<label><?php echo $this->__('Abierto los s&aacute;bados tarde.'); ?></label>
103
+ <input id="option_domingos" name="option_domingos" type="checkbox" value="1" />&nbsp;<label><?php echo $this->__('Abierto los domingos.'); ?></label>
104
+ </div>
105
+ <div id="yupick_carrier_secundario" class="yupick_carrier_secundario" style="display: none; ">
106
+ <input id="option_parking" name="option_parking" type="checkbox" value="1" />&nbsp;<label><?php echo $this->__('Parking.'); ?></label>
107
+ <input id="option_wifi" name="option_wifi" type="checkbox" value="1" />&nbsp;<label><?php echo $this->__('Wi-Fi.'); ?></label>
108
+ <input id="option_alimentacion" name="option_alimentacion" type="checkbox" value="1" />&nbsp;<label><?php echo $this->__('Alimentaci&oacute;n.'); ?></label>
109
+ <input id="option_prensa" name="option_prensa" type="checkbox" value="1" />&nbsp;<label><?php echo $this->__('Prensa / Revistas.'); ?></label>
110
+ <input id="option_tarjeta" name="option_tarjeta" type="checkbox" value="1" />&nbsp;<label><?php echo $this->__('Pagar con tarjeta de cr&eacute;dito.'); ?></label>
111
+ </div>
112
+
113
+ <div class="yupick_actions">
114
+ <div class="yupick_button_search">
115
+ <input type="button" value="Buscar" onclick="PuntosYupick.getPuntosYupick(); return false; " />
116
+ </div>
117
+ <div class="yupick_control_options">
118
+ <a href="#" onclick="PuntosYupick.changeYupickOptions();"><span id="yupick_options_text"><?php echo $this->__('M&aacute;s opciones de b&uacute;squeda') ?></span></a>
119
+ </div>
120
+ </div>
121
+
122
+ <?php /* </form> */ ?>
123
+ <br />
124
+ <div id="oficinas_yupick_content" style="display: none; ">
125
+ <select id="oficinas_yupick" name="oficinas_yupick" onchange="PuntosYupick.yupickInfo();"></select>
126
+ <input type="hidden" id="oficinas_yupick_data" name="oficinas_yupick_data" value="" />
127
+ </div>
128
+
129
+ <div class="yclear"></div>
130
+ <div id="yupick_info_map" style="display: none; "></div>
131
+ <div id="yupick_info_time" style="display: none; "></div>
132
+ <div class="yclear"></div>
133
+ <div id="yupick_info_user" style="display: none; ">
134
+ <p><?php echo $this->__('&iquest;C&oacute;mo prefiere ser informado de cuando puede recoger su compra?') ?></p>
135
+ <div class="yupick_info_user_col">
136
+ <label><?php echo $this->__('E-mail') ?></label>
137
+ <input type="radio" name="yupick_type_alert" id="yupick_type_alert" value="Email" checked="checked" />
138
+ <input type="text" name="yupick_type_alert_email" id="yupick_type_alert_email" value="<?php echo $this->getQuote()->getShippingAddress()->getEmail(); ?>" style="width: 200px; " />
139
+ </div>
140
+ <div class="yupick_info_user_col">
141
+ <label><?php echo $this->__('Tel&eacute;fono') ?></label>
142
+ <input type="radio" name="yupick_type_alert" id="yupick_type_alert" value="SMS" />
143
+ <input type="text" name="yupick_type_alert_phone" id="yupick_type_alert_phone" value="<?php echo $this->getQuote()->getShippingAddress()->getTelephone(); ?>" />
144
+ </div>
145
+ </div>
146
+ <div class="yclear"><br /></div>
147
+
148
+ <div id="loadingmask" style="display: none;">
149
+ <div class="loader" id="loading-mask-loader"><img src="<?php echo($this->getSkinUrl('images/yupick/opc-ajax-loader.gif')) ?>" alt="<?php echo $this->__('Loading...') ?>" /> <?php echo $this->__('Loading...') ?></div>
150
+ <div id="loading-mask"></div>
151
+ </div>
152
+
153
+ <?php endif; ?>
154
+
155
+ <?php endif ?>
156
+ </li>
157
+ <?php endforeach; ?>
158
+ </ul>
159
+ </dd>
160
+ <?php endforeach; ?>
161
+ </dl>
162
+ <script type="text/javascript">
163
+ //<![CDATA[
164
+ <?php if (!empty($shippingCodePrice)): ?>
165
+ var shippingCodePrice = {<?php echo implode(',',$shippingCodePrice); ?>};
166
+ <?php endif; ?>
167
+
168
+ $$('input[type="radio"][name="shipping_method"]').each(function(el){
169
+ Event.observe(el, 'click', function(){
170
+ if (el.checked == true) {
171
+ var getShippingCode = el.getValue();
172
+ <?php if (!empty($shippingCodePrice)): ?>
173
+ var newPrice = shippingCodePrice[getShippingCode];
174
+ if (!lastPrice) {
175
+ lastPrice = newPrice;
176
+ quoteBaseGrandTotal += newPrice;
177
+ }
178
+ if (newPrice != lastPrice) {
179
+ quoteBaseGrandTotal += (newPrice-lastPrice);
180
+ lastPrice = newPrice;
181
+ }
182
+ <?php endif; ?>
183
+ checkQuoteBaseGrandTotal = quoteBaseGrandTotal;
184
+ return false;
185
+ }
186
+ });
187
+ });
188
+
189
+ //]]>
190
+ </script>
191
+ <?php endif; ?>
app/etc/modules/Ydral_Yupick.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Ydral_Yupick>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Ydral_Yupick>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Ydral_Yupick</name>
4
+ <version>0.3.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>M&#xF3;dulo para Magento para integrar los puntos de recogida de Yupick!</summary>
10
+ <description>M&#xF3;dulo para Magento para integrar los puntos de recogida de Yupick!</description>
11
+ <notes>Yupick!</notes>
12
+ <authors><author><name>Ydral</name><user>Ydral</user><email>webmaster@ydral.com</email></author></authors>
13
+ <date>2012-06-26</date>
14
+ <time>22:10:55</time>
15
+ <contents><target name="magelocal"><dir name="Ydral"><dir name="Yupick"><dir><dir name="Block"><dir name="Checkout"><dir name="Onepage"><dir name="Shipping"><dir name="Method"><file name="Available.php" hash="5d18425846fe38cbb6a89689f5028bc5"/></dir></dir></dir></dir><file name="Yupick.php" hash="9b339fe97818ccf1754dd673839c5132"/></dir><dir name="Helper"><file name="Data.php" hash="d161e76c5b5bc5509c29ea72c8018c9c"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Boyaca"><file name="Collection.php" hash="546fd69029d924657d7ce322dbd588c5"/></dir><file name="Yupick.php" hash="dea1b719163896ff47442cd02f3309b9"/></dir><file name="Observer.php" hash="881fb29024fee91bc6bf3ba800b1eeaf"/><dir name="Type"><file name="Onepage.php" hash="cd0009f236027e74c474d54f37429c97"/></dir><dir name="Ydral"><file name="Recogeroficina.php" hash="2ef6611d396f6938cab8b497607d1577"/><file name="Shipment.php" hash="59e8d255241f2261d65df8e6545b06ba"/><dir name="Source"><file name="Method.php" hash="99a702161e108c27f731626d8d1a32db"/></dir></dir><file name="Yupick.php" hash="72505d4ec8c0bf8b663e3e0a870bbc3f"/></dir><dir name="controllers"><file name="IndexController.php" hash="17c0df44b6c59f7dae750bcb7066080e"/></dir><dir name="etc"><file name="config.xml" hash="8fb23e615e4e7d2e6f1fc8e9b4c1340b"/><file name="system.xml" hash="52213ea9b1f0ea4f1ee1ac09ecda0965"/></dir><dir name="sql"><dir name="yupick_setup"><file name="mysql4-install-0.1.0.php" hash="ad2f5cd741181e0cd71fbab193a80094"/><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></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Ydral_Yupick.xml" hash="f420cc41a8935a25faa4c0df7ef4c1db"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="css"><file name="yupick.css" hash="8b41ae7949b8bde7ab6f0b0b31e48d13"/></dir><dir name="js"><file name="yupick.js" hash="74fabdd3553f4d4eab94484141c8e306"/></dir><dir name="images"><dir name="yupick"><file name="globo.png" hash="d8880a99065ebb3ab173df27613abf93"/><file name="globosombra.png" hash="1a50fd383f17fe25cc74da661ddd6b5a"/><file name="logo.gif" hash="21a6ab44b6300a61ac978284c7bb09ad"/><file name="logo_small.gif" hash="1ea5b75df0babbde827d4761c942a746"/><file name="opc-ajax-loader.gif" hash="e805ea7eca1f34c75ba0f93780d32d38"/></dir></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="yupick.xml" hash="6cd118000269da3ef390d0c31ddea36d"/></dir><dir name="template"><dir name="yupick"><file name="tab_info.phtml" hash="494f48c9cf084fd08e2b7020513b88b5"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="yupick.xml" hash="198605392165576de98d5734ca777f60"/></dir><dir name="template"><dir name="yupick"><file name="info.phtml" hash="e0eb4891c623f2042a16ac2b3d0666d2"/><file name="shipping.phtml" hash="c7dc809f3d441faae942441807998de7"/></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/frontend/default/default/css/yupick.css ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #yupick_options .yupick_carrier_principal { margin-top: 10px; }
2
+ #yupick_options .yupick_carrier_secundario { margin-bottom: 10px; }
3
+ #yupick_options input { margin-right: 5px; }
4
+ #yupick_options label { margin-right: 8px; }
5
+ #oficinas_yupick_content { margin: 10px 0; }
6
+ #oficinas_yupick_content select { min-width: 450px; }
7
+ .yupick_actions { margin-top: 10px; }
8
+ .yupick_button_search { float: left; }
9
+ .yupick_control_options { float: left; margin-left: 15px; font-size: 12px; font-weight; bold; }
10
+ #loadingmask { clear: both; }
11
+ #yupick_info_map { float: left; border: 1px solid #ccc; width: 350px; height: 180px; margin-right: 10px; }
12
+ #yupick_info_time { float: left; width: 250px; height: 180px; }
13
+ #yupick_info_time table { width: 100%; }
14
+ #yupick_info_time table td,
15
+ #yupick_info_time table th { border-bottom: 2px solid #ccc; }
16
+ #yupick_info_time table th { font-weight: bold; }
17
+ .yclear { clear: both; }
18
+ #yupick_info_user { margin-left: 30px; margin-bottom: 20px; }
19
+ #yupick_info_user p { font-weight: bold; margin: 5px 0; }
20
+ #yupick_info_user .yupick_info_user_col { float: left; margin-right: 15px; }
21
+ #yupick_info_user .yupick_info_user_col label { display: block; margin-left: 15px; }
22
+ .yupick-icon-checkout { margin: 0 10px; }
skin/frontend/default/default/images/yupick/globo.png ADDED
Binary file
skin/frontend/default/default/images/yupick/globosombra.png ADDED
Binary file
skin/frontend/default/default/images/yupick/logo.gif ADDED
Binary file
skin/frontend/default/default/images/yupick/logo_small.gif ADDED
Binary file
skin/frontend/default/default/images/yupick/opc-ajax-loader.gif ADDED
Binary file
skin/frontend/default/default/js/yupick.js ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ PuntosYupick = Class.create();
3
+ PuntosYupick.prototype = {
4
+
5
+ initialize: function()
6
+ {
7
+ this.yupickResultados = '';
8
+
9
+ Event.observe(window, 'load', function()
10
+ {
11
+
12
+ $$('.main').invoke('observe', 'click', function(e)
13
+ {
14
+ var element = e.element();
15
+ if (element.getValue())
16
+ {
17
+ if (element.getValue() == 'yupick_yupick')
18
+ {
19
+ PuntosYupick.getPuntosYupick();
20
+ }
21
+ }
22
+ });
23
+ });
24
+
25
+ },
26
+
27
+ getPuntosYupick:function()
28
+ {
29
+
30
+ this.reloadurl = $('checkUrl').value;
31
+ Element.show('loadingmask');
32
+ new Ajax.Request(this.reloadurl, {
33
+ method: 'post',
34
+ parameters: {codigoPostal: $('codigoPostal').value, option_parking: $('option_parking').value, option_wifi: $('option_wifi').value, option_alimentacion: $('option_alimentacion').value, option_prensa: $('option_prensa').value, option_tarjeta: $('option_tarjeta').value, option_mas20: $('option_mas20').value, option_sabados: $('option_sabados').value, option_domingos: $('option_domingos').value},
35
+ onComplete: this.reloadChildren.bind(this)
36
+ });
37
+
38
+ },
39
+
40
+ reloadChildren: function(transport){
41
+ Element.hide('loadingmask');
42
+ $('oficinas_yupick_content').setStyle({display: 'block'});
43
+ var jsonResponse=transport.responseText.evalJSON(true);
44
+ this.yupickResultados = jsonResponse;
45
+
46
+ this.fillDropDownYupick ($('oficinas_yupick'), this.yupickResultados.puntoentrega);
47
+ },
48
+
49
+ fillDropDownYupick:function (field, data)
50
+ {
51
+
52
+ for(i=field.options.length-1;i>=0;i--) { field.remove(i); }
53
+
54
+ data.each(
55
+ function(e) {
56
+ field.options.add(new Option(e.nombre+' - '+e.direccion+" - "+e.localidad+' ('+e.provincia+')',e.id));
57
+ }
58
+ );
59
+
60
+ this.yupickInfo()
61
+
62
+ },
63
+
64
+ changeYupickOptions:function ()
65
+ {
66
+ $('yupick_carrier_principal').toggle();
67
+ $('yupick_carrier_secundario').toggle();
68
+ if ($('yupick_carrier_secundario').visible())
69
+ {
70
+ $('yupick_options_text').replace('<span id="yupick_options_text">Menos opciones de b&uacute;squeda</span>');
71
+ } else {
72
+ $('yupick_options_text').replace('<span id="yupick_options_text">M&aacute;s opciones de b&uacute;squeda</span>');
73
+ }
74
+ },
75
+
76
+ yupickInfo:function()
77
+ {
78
+
79
+ var puntoActual = $('oficinas_yupick').value;
80
+ this.yupickResultados.puntoentrega.each(
81
+ function(e) {
82
+ if (e.id == puntoActual)
83
+ {
84
+ $('yupick_info_map').setStyle({display: 'block'});
85
+ $('yupick_info_time').setStyle({display: 'block'});
86
+ $('yupick_info_user').setStyle({display: 'block'});
87
+
88
+ $('oficinas_yupick_data').value = e.nombre+' - '+e.direccion+" - "+e.localidad+' ('+e.provincia+')';
89
+
90
+ // info del punto
91
+ this.infoGoogleMaps(e);
92
+ this.infoHorarios(e);
93
+
94
+ }
95
+ }.bind(this));
96
+
97
+ },
98
+
99
+ infoGoogleMaps:function(e)
100
+ {
101
+ var latlng = new google.maps.LatLng(e.poslatitud, e.poslongitud);
102
+ var myOptions = {
103
+ zoom: 16,
104
+ center: latlng,
105
+ mapTypeId: google.maps.MapTypeId.ROADMAP
106
+ };
107
+
108
+ var imagen = new google.maps.MarkerImage($('skinPath').value + 'frontend/default/default/images/yupick/globo.png', new google.maps.Size(100,47), new google.maps.Point(0,0), new google.maps.Point(50,47));
109
+ var sombra = new google.maps.MarkerImage($('skinPath').value + 'frontend/default/default/images/yupick/globosombra.png', new google.maps.Size(100,19), new google.maps.Point(0,0), new google.maps.Point(31,19));
110
+
111
+ var map = new google.maps.Map(document.getElementById("yupick_info_map"), myOptions);
112
+
113
+ var beachMarker = new google.maps.Marker({
114
+ position: latlng,
115
+ map: map,
116
+ icon: imagen,
117
+ shadow: sombra
118
+ });
119
+
120
+ },
121
+
122
+
123
+ infoHorarios: function (e)
124
+ {
125
+
126
+ var tablaHorarios = '<table><tr><th>&nbsp;</th><th>Ma&ntilde;ana</th><th>Tarde</td></tr>';
127
+ tablaHorarios += '<tr class="odd"><td>Lunes</td><td>'+e.horario.lunes.manana+'</td><td>'+e.horario.lunes.tarde+'</td></tr>';
128
+ tablaHorarios += '<tr class="even"><td>Martes</td><td>'+e.horario.martes.manana+'</td><td>'+e.horario.martes.tarde+'</td></tr>';
129
+ tablaHorarios += '<tr class="odd"><td>Mi&eacute;rcoles</td><td>'+e.horario.miercoles.manana+'</td><td>'+e.horario.miercoles.tarde+'</td></tr>';
130
+ tablaHorarios += '<tr class="even"><td>Jueves</td><td>'+e.horario.jueves.manana+'</td><td>'+e.horario.jueves.tarde+'</td></tr>';
131
+ tablaHorarios += '<tr class="odd"><td>Viernes</td><td>'+e.horario.viernes.manana+'</td><td>'+e.horario.viernes.tarde+'</td></tr>';
132
+ tablaHorarios += '<tr class="even"><td>S&aacute;bado</td><td>'+e.horario.sabado.manana+'</td><td>'+e.horario.sabado.tarde+'</td></tr>';
133
+ tablaHorarios += '<tr class="odd"><td>Domingo</td><td>'+e.horario.domingo.manana+'</td><td>'+e.horario.domingo.tarde+'</td></tr>';
134
+ tablaHorarios += '</table>';
135
+
136
+ $('yupick_info_time').update(tablaHorarios);
137
+
138
+ }
139
+
140
+ }
141
+
142
+ var PuntosYupick = new PuntosYupick();