This repository has been archived by the owner on Mar 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
zeleriscarrier.php
1317 lines (1149 loc) · 57.4 KB
/
zeleriscarrier.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author Línea Gráfica E.C.E. S.L.- https://www.lineagrafica.es/ <soporte@lineagrafica.es>
* @copyright 2007-2015 TELEFONICA SERVICIOS INTEGRALES DE DISTRIBUCIÓN S.A.U.
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of TELEFONICA SERVICIOS INTEGRALES DE DISTRIBUCIÓN S.A.U.
*/
if (!defined('_PS_VERSION_'))
exit;
require_once(_PS_MODULE_DIR_.'zeleriscarrier/lib/zelerislog.php');
class ZelerisCarrier extends CarrierModule
{
public $id_carrier;
private $_html = '';
private $_postErrors = array();
private $_moduleName = 'zeleriscarrier';
public function __construct()
{
$this->id_carrier = '';
$this->name = 'zeleriscarrier';
$this->tab = 'shipping_logistics';
$this->version = '1.3.0';
$this->author = 'Línea Gráfica';
parent::__construct();
$this->displayName = $this->l('Zeleris carrier');
$this->description = $this->l('Integrates sending zeleris');
if (Module::isInstalled($this->name))
{
/*************** Get Carriers ***************/
$cookie = $this->context->cookie;
$carriers = Carrier::getCarriers($cookie->id_lang, true, false, false, null, Carrier::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
/*************** check if isset id carrier ***************/
$warning = array();
if (!Configuration::get('ZELERIS_URL'))
$warning[] = $this->l('"URL Gateway"').' ';
if (!Configuration::get('ZELERIS_GUID'))
$warning[] = $this->l('"Customer`s identificator (GUID)"').' ';
if (!Configuration::get('ZELERIS_MERCHANDISE_DESCRIPTION'))
$warning[] = $this->l('"Merchandise description"').' ';
if (count($warning))
$this->warning .= implode(' , ', $warning).$this->l('You must configure before use.').' ';
}
}
public function tablesRollback()
{
}
public function install()
{
if (!extension_loaded('soap'))
{
ZelerisLog::error($this->l('Not soap extension loaded, can\' install module '));
$this->errors[] = $this->l('Can\'t install module because the Soap Extension is not loaded');
return false;
}
$query = 'CREATE TABLE IF NOT EXISTS '._DB_PREFIX_.'zeleris_orders (
id_zeleris_orders int(11) NOT NULL AUTO_INCREMENT,
id_order int(11) NOT NULL,
send_code varchar(50) NOT NULL,
url_track varchar(255) NOT NULL,
date datetime NOT NULL,
packages int(11) NOT NULL,
PRIMARY KEY (`id_zeleris_orders`)
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8 ';
if (!Db::getInstance()->execute($query))
{
ZelerisLog::error($this->l('Unable to create table ')._DB_PREFIX_.'zeleris_orders '.$this->l('Using ENGINE =')._MYSQL_ENGINE_);
$this->tablesRollback();
return false;
}
$query = 'CREATE TABLE IF NOT EXISTS '._DB_PREFIX_.'zeleris_email (
id int(11) NOT NULL AUTO_INCREMENT,
title varchar(128),
message text,
PRIMARY KEY (`id`)
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8 ';
if (!Db::getInstance()->execute($query))
{
ZelerisLog::error($this->l('Unable to create table ')._DB_PREFIX_.'zeleris_email '.$this->l('Using ENGINE =')._MYSQL_ENGINE_);
$this->tablesRollback();
return false;
}
$query = 'INSERT INTO '._DB_PREFIX_.'zeleris_email (title,message) VALUES ("example","Write your message here...")';
if (!Db::getInstance()->execute($query))
{
ZelerisLog::error($this->l('Unable to create table ')._DB_PREFIX_.'zeleris_email '.$this->l('Using ENGINE =')._MYSQL_ENGINE_);
$this->tablesRollback();
return false;
}
$carrierConfig = array(
0 => array('name' => 'eCommerce',
'id_tax_rules_group' => 0,
'active' => true,
'deleted' => 0,
'shipping_handling' => false,
'range_behavior' => 0,
'delay' => array(Language::getIsoById(Configuration::get('PS_LANG_DEFAULT')) => $this->l('Next day delivery')),
'id_zone' => 1,
'is_module' => true,
'shipping_external' => true,
'external_module_name' => $this->name,
'need_range' => true
),);
$id_carrier1 = $this->installExternalCarrier($carrierConfig[0]);
Configuration::updateValue('ZELERIS_CARRIER_ID', (int)$id_carrier1);
if (!parent::install() || !$this->registerHook('updateCarrier'))
return false;
// Create Tab
$tab = new Tab();
$tab->class_name = 'AdminZeleris';
$tab->id_parent = 10;
$tab->module = $this->name;
$tab->name[(int)(Configuration::get('PS_LANG_DEFAULT'))] = 'Zeleris';
if (!$tab->add())
{
$this->tablesRollback();
return false;
}
return true;
}
public function uninstall()
{
if (!parent::uninstall() || !$this->unregisterHook('updateCarrier'))
return false;
/*************** Delete Carrier ***************/
$Carrier1 = new Carrier((int)(Configuration::get('ZELERIS_CARRIER_ID')));
if (Configuration::get('PS_CARRIER_DEFAULT') == (int)($Carrier1->id))
{
$cookie = $this->context->cookie;
$carriersD = Carrier::getCarriers($cookie->id_lang, true, false, false, null, PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
foreach ($carriersD as $carrierD)
if ($carrierD['active'] && !$carrierD['deleted'] && ($carrierD['name'] != $this->_config['name']))
Configuration::updateValue('PS_CARRIER_DEFAULT', $carrierD['id_carrier']);
}
$Carrier1->deleted = 1;
if (!$Carrier1->update())
return false;
/*************** Detele Tab and tables ***************/
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'tab WHERE module = "'.$this->_moduleName.'"');
Db::getInstance()->execute('DROP TABLE '._DB_PREFIX_.'zeleris_orders');
Db::getInstance()->execute('DROP TABLE '._DB_PREFIX_.'zeleris_email');
return true;
}
public static function installExternalCarrier($config)
{
$carrier = new Carrier();
$carrier->name = $config['name'];
$carrier->id_tax_rules_group = $config['id_tax_rules_group'];
$carrier->id_zone = $config['id_zone'];
$carrier->active = $config['active'];
$carrier->deleted = $config['deleted'];
$carrier->delay = $config['delay'];
$carrier->shipping_handling = $config['shipping_handling'];
$carrier->range_behavior = $config['range_behavior'];
$carrier->is_module = $config['is_module'];
$carrier->shipping_external = $config['shipping_external'];
$carrier->external_module_name = $config['external_module_name'];
$carrier->need_range = $config['need_range'];
$languages = Language::getLanguages(true);
foreach ($languages as $language)
{
if ($language['iso_code'] == 'fr')
$carrier->delay[(int)$language['id_lang']] = $config['delay'][$language['iso_code']];
if ($language['iso_code'] == 'en')
$carrier->delay[(int)$language['id_lang']] = $config['delay'][$language['iso_code']];
if ($language['iso_code'] == Language::getIsoById(Configuration::get('PS_LANG_DEFAULT')))
$carrier->delay[(int)$language['id_lang']] = $config['delay'][$language['iso_code']];
}
if ($carrier->add())
{
$groups = Group::getGroups(true);
foreach ($groups as $group)
Db::getInstance()->autoExecute(_DB_PREFIX_.'carrier_group', array('id_carrier' => (int)($carrier->id), 'id_group' => (int)($group['id_group'])), 'INSERT');
$rangePrice = new RangePrice();
$rangePrice->id_carrier = $carrier->id;
$rangePrice->delimiter1 = '0';
$rangePrice->delimiter2 = '1000000000';
$rangePrice->add();
$rangeWeight = new RangeWeight();
$rangeWeight->id_carrier = $carrier->id;
$rangeWeight->delimiter1 = '0';
$rangeWeight->delimiter2 = '1000000000';
$rangeWeight->add();
$zones = Zone::getZones(true);
foreach ($zones as $zone)
$carrier->addZone($zone['id_zone']);
if ($config['name'] == 'ZELERIS-24H')
{
if (!Tools::copy(dirname(__FILE__).'/zeleris_ecomm_24_pshop.jpg', _PS_SHIP_IMG_DIR_.'/'.(int)$carrier->id.'.jpg'))
return false;
}
/*************** Return carrier id ***************/
return (int)($carrier->id);
}
return false;
}
public function getContent()
{
if (!Configuration::get('ZELERIS_URL') || Configuration::get('ZELERIS_URL') == '' || !Configuration::get('ZELERIS_GUID') || Configuration::get('ZELERIS_GUID') == '')
$this->context->controller->addJS(_MODULE_DIR_.$this->name.'/views/js/landing.js');
else
$this->context->controller->addJS(_MODULE_DIR_.$this->name.'/views/js/tablist.js');
$this->context->controller->addCSS(_MODULE_DIR_.$this->name.'/views/css/admin.css');
$this->context->controller->addJS(_MODULE_DIR_.$this->name.'/views/js/admin.js');
$this->_displayLanding();
$this->_displayForm();
return $this->_html;
}
private function _displayLanding()
{
$this->_html .= '
<div id="landing" style="display:none">
<div class="title" style=><img src="/modules/zeleriscarrier/views/img/logo.png" alt="" /><span>'.$this->l('Logistics solutions for your online business').'</span></div>
<div class="landing_content">
<div class="bloque" id="bloque1" style="">
<div id="content1" style="">
<div >
<img src="/modules/zeleriscarrier/views/img/entrega.png" alt="" style="float:left;padding-right: 10px;" />'.$this->l('The Zeleris ecommerce service is designed to meet the logistics and transport companies that market their products through Internet needs.').'</br></br>'.$this->l('Trust the logistics of your online store to one of the leading companies in delivery to individuals and with the support of Telefonica Group.').'<br/><br/>'.$this->l('This module allows quick and easy integration of the online store with the transport system Zeleris.').'
</div>
<div class="mt20 partner">
<div class="title_c">'.$this->l('Features of this module:').'</div>
<ul>
<li>'.$this->l('- Flexible Parameterization of standard and express services.').'</li>
<li>'.$this->l('- National and international services.').'</li>
<li>'.$this->l('- Configuration of shipping prices.').'</li>
<li>'.$this->l('- Allocation of costs manipulated.').'</li>
<li>'.$this->l('- Fixing purchase amounts from which transportation is free.').'</li>
<li>'.$this->l('- Management of COD payments.').'</li>
<li>'.$this->l('- Integration with pickup service').'</li>
</ul>
</div>
<div class="botones">
<div id="boton_info">'.$this->l('I want to be customer').'</div>
<div id="boton_conf">'.$this->l('I am a customer').'</div>
</div>
</div>
</div>
<div class="bloque" id="bloque2">
<div class="mt30 transporte">
<div class="title_t">'.$this->l('National transport').'</div>
<ul>
<li>'.$this->l('- Notice and coordination of deliveries (SMS, call, email)').'</li>
<li>'.$this->l('- Online troubleshooting').'</li>
<li>'.$this->l('- Delivery to return for exchange of product').'</li>
<li>'.$this->l('- Choice of delivery collection point').'</li>
</ul>
</div>
<div class="mt30 transporte">
<div class="title_t">'.$this->l('International transport').'</div>
<ul>
<li>'.$this->l('- International Air Service').'</li>
<li>'.$this->l('- Ground Service International').'</li>
</ul>
</div>
<div class="mt30 transporte">
<div class="title_t">'.$this->l('Logistics').'</div>
<ul>
<li>'.$this->l('- Storage').'</li>
<li>'.$this->l('- Picking').'</li>
<li>'.$this->l('- Dropshipping').'</li>
<li>'.$this->l('- Integration with shuttle').'</li>
</ul>
</div>
<div class="enlace">'.$this->l('More information at:').' <a href="http://www.zeleris.com" target="_blank">www.zeleris.com</a></div>
</div>
<div class="clear"></div>
</div>
</div>
';
}
private function _displayForm()
{
$this->_html .= '<div id="capa_layer" style="display:none">
<div class="clear"> </div>
<fieldset style="border: 0px;"> ';
$this->_html .= '<h2>'.$this->l('Zeleris').'</h2>';
if (!empty($_POST) && Tools::isSubmit('submitContact'))
$this->contact();
$this->_html .= '<div id="tabs">
';
if (!Configuration::get('ZELERIS_URL') || Configuration::get('ZELERIS_URL') == '' || !Configuration::get('ZELERIS_GUID') || Configuration::get('ZELERIS_GUID') == '')
$this->_html .= '<div class="butoon_volver">'.$this->l('Back').'</div>';
$this->_html .= '
<div id="tabform" style="display:none">
<form action="index.php?tab='.Tools::safeOutput(Tools::getValue('tab')).'&configure='.Tools::safeOutput(Tools::getValue('configure')).'&token='.Tools::safeOutput(Tools::getValue('token')).'&tab_module='.Tools::safeOutput(Tools::getValue('tab_module')).'&module_name='.Tools::safeOutput(Tools::getValue('module_name')).'&id_tab=2§ion=request" method="post" class="form" id="requestForm">
<h2 style="font-family: Verdana;">'.$this->l('Request commercial visit').'</h2>
<table cellspacing="4" class="table">
<tbody>
<tr>
<td class="label">* '.$this->l('Company name').'</td>
<td>
<input name="txtEmpresa" type="text" maxlength="80" id="txtEmpresa" class="textbox" style="width:221px;">
</td>
</tr>
<tr>
<td class="label">'.$this->l('NIF').'</td>
<td>
<input name="txtNIF" type="text" maxlength="20" id="txtNIF" class="textbox" style="width:221px;">
</td>
</tr>
<tr>
<td class="label">* '.$this->l('Address').'</td>
<td>
<input name="txtDireccion" type="text" maxlength="80" id="txtDireccion" class="textbox" style="width:221px;">
</td>
</tr>
<tr>
<td class="label">* '.$this->l('State').'</td>
<td>
<select name="cmbProvincia" id="cmbProvincia" class="select" style="width: 231px;">
<option selected="selected" value=""></option>
<option value="Alava">Alava</option>
<option value="Albacete">Albacete</option>
<option value="Alicante">Alicante</option>
<option value="Almeria">Almeria</option>
<option value="Asturias">Asturias</option>
<option value="Avila">Avila</option>
<option value="Badajoz">Badajoz</option>
<option value="Baleares">Baleares</option>
<option value="Barcelona">Barcelona</option>
<option value="Burgos">Burgos</option>
<option value="Caceres">Caceres</option>
<option value="Cadiz">Cadiz</option>
<option value="Cantabria">Cantabria</option>
<option value="Castellon">Castellon</option>
<option value="Ceuta">Ceuta</option>
<option value="Ciudad Real">Ciudad Real</option>
<option value="Cordoba">Cordoba</option>
<option value="Cuenca">Cuenca</option>
<option value="Girona">Girona</option>
<option value="Granada">Granada</option>
<option value="Guadalajara">Guadalajara</option>
<option value="Guipuzcoa">Guipuzcoa</option>
<option value="Huelva">Huelva</option>
<option value="Huesca">Huesca</option>
<option value="Jaen">Jaen</option>
<option value="La Coruña">La Coruña</option>
<option value="La Rioja">La Rioja</option>
<option value="Las Palmas">Las Palmas</option>
<option value="Leon">Leon</option>
<option value="Lleida">Lleida</option>
<option value="Lugo">Lugo</option>
<option value="Madrid">Madrid</option>
<option value="Malaga">Malaga</option>
<option value="Melilla">Melilla</option>
<option value="Murcia">Murcia</option>
<option value="Navarra">Navarra</option>
<option value="Ourense">Ourense</option>
<option value="Palencia">Palencia</option>
<option value="Pontevedra">Pontevedra</option>
<option value="Salamanca">Salamanca</option>
<option value="Santa Cruz de Tenerife">Santa Cruz de Tenerife</option>
<option value="Segovia">Segovia</option>
<option value="Sevilla">Sevilla</option>
<option value="Soria">Soria</option>
<option value="Tarragona">Tarragona</option>
<option value="Teruel">Teruel</option>
<option value="Toledo">Toledo</option>
<option value="Valencia">Valencia</option>
<option value="Valladolid">Valladolid</option>
<option value="Vizcaya">Vizcaya</option>
<option value="Zamora">Zamora</option>
<option value="Zaragoza">Zaragoza</option>
</select>
</td>
</tr>
<tr>
<td class="label">'.$this->l('Contact Person').'</td>
<td>
<input name="txtContacto" type="text" maxlength="40" id="txtContacto" class="textbox" style="width:221px;">
</td>
</tr>
<tr>
<td class="label">* '.$this->l('Phone').'</td>
<td>
<input name="txtTelefono" type="text" maxlength="15" id="txtTelefono" class="textbox" style="width:221px;">
</td>
</tr>
<tr>
<td class="label">'.$this->l('Email').'</td>
<td>
<input name="txtEMail" type="text" maxlength="60" id="txtEMail" class="textbox" style="width:221px;">
</td>
</tr>
<tr>
<td class="label">'.$this->l('Services of interest').'</td>
<td>
<table id="chkServicios" class="checkbox" border="0">
<tbody>
<tr>
<td><input id="chkServicios_0" type="checkbox" name="chkServicios[]" value="'.$this->l('Carrier').'"><label for="chkServicios_0">'.$this->l('Carrier').'</label></td>
</tr>
<tr>
<td><input id="chkServicios_1" type="checkbox" name="chkServicios[]" value="'.$this->l('Logistic').'"><label for="chkServicios_1">'.$this->l('Logistic').'</label></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="label">'.$this->l('Current number of weekly shipments').'</td>
<td>
<input name="txtEnviosActual" type="text" maxlength="5" id="txtEnviosActual" class="textbox" style="width:60px;">
</td>
</tr>
<tr>
<td class="label">'.$this->l('Expected number of weekly shipments').'</td>
<td>
<input name="txtEnviosPrevisto" type="text" maxlength="5" id="txtEnviosPrevisto" class="textbox" style="width:60px;">
</td>
</tr>
<tr>
<td class="label">'.$this->l('Comments').'</td>
<td>
<textarea name="txtObservaciones" rows="2" cols="20" id="txtObservaciones" class="textarea" style="width:221px;"></textarea>
</td>
</tr>
<tr>
<td colspan="2"></td>
</tr>
<tr>
<td>
<input type="hidden" name="source_page" id="source_page">
<input type="hidden" name="id_procedencia" id="id_procedencia">
</td>
<td>
<div class="boton">
<div class="izq"></div>
<input type="submit" value="'.$this->l('Send').'" name="submitContact" id="sendcontact"/>
<div class="der"></div>
</div>
</td>
</tr>
</tbody></table>
</form>
</div>
<div id="tabList" style="display:none">';
$this->_html .= '<fieldset><legend><img src="'.$this->_path.'views/img/logotipo.png" alt="" /> '.$this->l('Status Zeleris carrier module for PrestaShop:').'</legend>';
$alert = array();
if (!Configuration::get('ZELERIS_URL') || Configuration::get('ZELERIS_URL') == '')
$alert['zeleris_url'] = 1;
if (!Configuration::get('ZELERIS_GUID') || Configuration::get('ZELERIS_GUID') == '')
$alert['zeleris_guid'] = 1;
if (!Configuration::get('ZELERIS_MERCHANDISE_DESCRIPTION') || Configuration::get('ZELERIS_MERCHANDISE_DESCRIPTION') == '')
{
Configuration::updateValue('ZELERIS_MERCHANDISE_DESCRIPTION', $this->l('Not indicated'));
$alert['ZELERIS_MERCHANDISE_DESCRIPTION'] = $this->l('Not indicated');
}
if (!count($alert))
$this->_html .= '<img src="'._PS_IMG_.'admin/module_install.png" /><strong>'.$this->l('ZELERIS is configured and online!').'</strong>';
else
{
$this->_html .= '<img src="'._PS_IMG_.'admin/warn2.png" /><strong>'.$this->l('ZELERIS is not yet configured. Please correct the errors indicated:').'</strong>';
$this->_html .= '<br />'.((isset($alert['zeleris_url'])) ? '<img src="'._PS_IMG_.'admin/warn2.png" />' : '<img src="'._PS_IMG_.'admin/module_install.png" />').' 1- '.$this->l('Configuring the Gateway URL.');
$this->_html .= '<br />'.((isset($alert['zeleris_guid'])) ? '<img src="'._PS_IMG_.'admin/warn2.png" />' : '<img src="'._PS_IMG_.'admin/module_install.png" />').' 2- '.$this->l('Configuring the client identifier (GUID).');
$this->_html .= '<br />'.((isset($alert['ZELERIS_MERCHANDISE_DESCRIPTION'])) ? '<img src="'._PS_IMG_.'admin/warn2.png" />' : '<img src="'._PS_IMG_.'admin/module_install.png" />').' 3- '.$this->l('Configuring the merchandise description.');
}
if (!empty($_POST) && Tools::isSubmit('submitSave'))
{
$this->_html .= '<script>$(document).ready(function(){$("#landing").hide(); $("#capa_layer, #tabList").show()})</script>';
$this->_postValidation();
if (!count($this->_postErrors))
$this->_postProcess();
else
foreach ($this->_postErrors as $err)
$this->_html .= '<div class="alert error"><img src="'._PS_IMG_.'admin/forbbiden.gif" alt="nok" /> '.$err.'</div>';
}
$zeleris_manipulation_fixed = '';
$zeleris_manipulation_percentage = '';
if (Tools::getValue('zeleris_manipulation', Configuration::get('ZELERIS_MANIPULATION')) == 'F')
$zeleris_manipulation_fixed = 'selected="selected"';
if (Tools::getValue('zeleris_manipulation', Configuration::get('ZELERIS_MANIPULATION')) == 'P')
$zeleris_manipulation_percentage = 'selected="selected"';
$free_shipping_no = '';
$free_shipping_yes = '';
if (Tools::getValue('zeleris_free_shipping', Configuration::get('ZELERIS_FREE_SHIPPING')) == '0')
$free_shipping_no = 'checked="checked"';
if (Tools::getValue('zeleris_free_shipping', Configuration::get('ZELERIS_FREE_SHIPPING')) == '1')
$free_shipping_yes = 'checked="checked"';
$free_shipping_international_no = '';
$free_shipping_international_yes = '';
if (Tools::getValue('zeleris_free_shipping_internacional', Configuration::get('ZELERIS_FREE_SHIPPING_INTERNACI')) == '0')
$free_shipping_international_no = 'checked="checked"';
if (Tools::getValue('zeleris_free_shipping_internacional', Configuration::get('ZELERIS_FREE_SHIPPING_INTERNACI')) == '1')
$free_shipping_international_yes = 'checked="checked"';
$show_services_error_no = '';
$show_services_error_yes = '';
if (Tools::getValue('zeleris_show_services_error', Configuration::get('ZELERIS_SHOW_SERVICES_ERROR')) == '0')
$show_services_error_no = 'checked="checked"';
if (Tools::getValue('zeleris_show_services_error', Configuration::get('ZELERIS_SHOW_SERVICES_ERROR')) == '1')
$show_services_error_yes = 'checked="checked"';
$this->_html .= '</fieldset>
<div class="tabItem">
<form action="index.php?tab='.Tools::safeOutput(Tools::getValue('tab')).'&configure='.Tools::safeOutput(Tools::getValue('configure')).'&token='.Tools::safeOutput(Tools::getValue('token')).'&tab_module='.Tools::safeOutput(Tools::getValue('tab_module')).'&module_name='.Tools::safeOutput(Tools::getValue('module_name')).'&id_tab=1§ion=general" method="post" class="form" id="configForm">
<h4>'.$this->l('Configuration data carrier module for PrestaShop Zeleris').' :</h4>
<table style="border: 0px;">
<tr>
<td class="columna1">'.$this->l('Version').' : </td>
<td class="columna2">
<p>PT-1.3</p>
<p class="tip"></p>
</td>
</tr>
<tr>
<td class="columna1">'.$this->l('URL Gateway').' : </td>
<td class="columna2">
<input type="text" size="99" name="zeleris_url" value="'.Tools::safeOutput(Tools::getValue('zeleris_url', Configuration::get('ZELERIS_URL'))).'" />
<p class="tip">'.$this->l('Zeleris data connection. No change except Zeleris indication.').'</p>
</td>
</tr>
<tr>
<td class="columna1">'.$this->l('Client identifier (GUID)').' : </td>
<td class="columna2">
<input type="text" size="50" name="zeleris_guid" value="'.Tools::safeOutput(Tools::getValue('zeleris_guid', Configuration::get('ZELERIS_GUID'))).'" />
<p class="tip">'.$this->l('Data provided by Zeleris. No change except Zeleris indication.').'</p>
</td>
</tr>
<tr>
<td class="columna1">'.$this->l('Merchandise description').' : </td>
<td class="columna2">
<input type="text" size="99" name="zeleris_merchandise_decription" value="'.Tools::safeOutput(Tools::getValue('zeleris_merchandise_decription', Configuration::get('ZELERIS_MERCHANDISE_DESCRIPTION'))).'" />
<p class="tip">'.$this->l('Generic description merchandise on shipments requiring customs clearance. (max. 20 characters)').'</p>
</td>
</tr>
<tr>
<td colspan="2"><hr/></td>
</tr>
<tr>
<td class="columna1">'.$this->l('Type handling cost').' : </td>
<td class="columna2">
<select name="zeleris_manipulation">
<option '.Tools::safeOutput($zeleris_manipulation_fixed).' value="F">'.$this->l('Fixed').'</option>
<option '.Tools::safeOutput($zeleris_manipulation_percentage).' value="P">'.$this->l('Percentage').'</option>
</select>
<p class="tip">'.$this->l('Define a fixed cost or variable cost ').'</p>
</td>
</tr>
<tr>
<td class="columna1">'.$this->l('Fixed cost or percentage of manipulated').' : </td>
<td class="columna2">
<input type="text" size="15" name="zeleris_manipulation_cost" value="'.Tools::safeOutput(Tools::getValue('zeleris_manipulation_cost', Configuration::get('ZELERIS_MANIPULATION_COST'))).'" />
<p class="tip">'.$this->l('Specifies the fixed cost or a percentage of the taxable amount of your order to charge the buyer for expenses handling. The percentage is calculated on the taxable amount of the purchase, not shipping.').'</p>
</td>
</tr>
<tr>
<td colspan="2"><hr/></td>
</tr>
<tr>
<td class="columna1">'.$this->l('Free National shipping').' :</td>
<td class="columna2">
<input type="radio" name="zeleris_free_shipping" value="0" '.Tools::safeOutput($free_shipping_no).'/>'.$this->l('No').'
<input type="radio" name="zeleris_free_shipping" value="1" '.Tools::safeOutput($free_shipping_yes).'/>'.$this->l('Yes').'
<p class="tip">'.$this->l('Select "Yes" to enable the free shippingin on national purchases that meet or exceed the amount specified in "Threshold for Free national shipping" Select "No" if the customer should always pay the cost of transportation across national purchase, whatever the amount of the same.').'</p>
</td>
</tr>
<tr>
<td class="columna1">'.$this->l('Max price for free shipping ').' : </td>
<td class="columna2">
<input type="text" size="6" name="zeleris_min_amount_free" value="'.Tools::safeOutput(Tools::getValue('zeleris_min_amount_free', Configuration::get('ZELERIS_MIN_AMOUNT_FREE'))).'" />
<p class="tip">'.$this->l('Order Amount of national purchases, excluding tax, from which transport becomes free for the buyer, provided that the "Free national shipping" option is set to "Yes".').'</p>
</td>
</tr>
<tr>
<td colspan="2"><hr/></td>
</tr>
<tr>
<td class="columna1">'.$this->l('Free International shipping').' :</td>
<td class="columna2">
<input type="radio" name="zeleris_free_shipping_internacional" value="0" '.Tools::safeOutput($free_shipping_international_no).'/>'.$this->l('No').'
<input type="radio" name="zeleris_free_shipping_internacional" value="1" '.Tools::safeOutput($free_shipping_international_yes).'/>'.$this->l('Yes').'
<p class="tip">'.$this->l('Select "Yes" to enable the free shipping on international purchases that meet or exceed the amount specified in "Threshold for free international shipping." Select "No" if the customer should always pay the cost of transportation across international purchase, whatever the amount of the same.').'</p>
</td>
</tr>
<tr>
<td class="columna1">'.$this->l('Max price for free shipping ').' :</td>
<td class="columna2">
<input type="text" size="6" name="zeleris_min_amount_free_int" value="'.Tools::safeOutput(Tools::getValue('zeleris_min_amount_free_int', Configuration::get('ZELERIS_MIN_AMOUNT_FREE_INT'))).'" />
<p class="tip">'.$this->l('Order Amount international shopping, no taxes, from which transport becomes free for the buyer, provided that the "Free International Shipping" option is set to "Yes".').'</p>
</td>
</tr>
<tr>
<td colspan="2"><hr/></td>
</tr>
<tr>
<td class="columna1">'.$this->l('Show services in case of error').' :</td>
<td class="columna2">
<input type="radio" name="zeleris_show_services_error" value="0" '.Tools::safeOutput($show_services_error_no).'/>No
<input type="radio" name="zeleris_show_services_error" value="1" '.Tools::safeOutput($show_services_error_yes).'/>Si
<p class="tip">'.$this->l('Indicates whether or not the services show the buyer should not be available for the selected destination or not having money, etc.').'</p>
</td>
</tr>
<tr>
<td class="columna1">'.$this->l('Error message').' : </td>
<td class="columna2">
<input type="text" size="99" name="zeleris_error_message" value="'.Tools::safeOutput(Tools::getValue('zeleris_error_message', Configuration::get('ZELERIS_ERROR_MESSAGE'))).'" />
<p class="tip">'.$this->l('Text displayed to the purchaser, in case of failure of communications when see prices').'</p>
</td>
</tr>
<tr>
<td colspan="2"><hr/></td>
</tr>
<tr>
<td class="columna1">'.$this->l('Fixed Shipping Cost').' : </td>
<td class="columna2">
<input type="text" size="5" name="zeleris_fixed_cost_shipping" value="'.Tools::safeOutput(Tools::getValue('zeleris_fixed_cost_shipping', Configuration::get('ZELERIS_FIXED_COST_SHIPPING'))).'" />
<p class="tip">'.$this->l('Fixed price for shipping. If greater than zero, is not taken into account neither the price nor the transportation cost plus shipping. In this case, it will be taxable transportation. If it is zero, the taxable amount is the cost of transport plus the cost plus shipping.').'</p>
</td>
</tr>
<tr>
<td class="columna1">'.$this->l('Margin on shipping cost').' : </td>
<td class="columna2">
<input type="text" size="15" name="zeleris_margin_shipping_cost" value="'.Tools::safeOutput(Tools::getValue('zeleris_margin_shipping_cost', Configuration::get('ZELERIS_MARGIN_SHIPPING_COST'))).'" />
<p class="tip">'.$this->l('Margin rate increase on shipping cost. This amount will be added to the transport.').'</p>
</td>
</tr>
</table>
<br /><br />
<div class="margin-form"><input class="button" name="submitSave" type="submit" value="Save"></div>
</form>
</div>
</div>
</div>
</fieldset>';
$this->_html .= '</div>';
}
private function _postValidation()
{
if (Tools::getValue('zeleris_customer_code', '') == '' && Tools::getValue('zeleris_customer_pass', '') == '' && Tools::getValue('zeleris_url', '') == '')
$this->_postErrors[] = $this->l('You need to configure correctly: URL Gateway, Client Identifier (GUID) and merchandise description');
}
private function _postProcess()
{
if (Configuration::updateValue('ZELERIS_URL', Tools::getValue('zeleris_url')) && Configuration::updateValue('ZELERIS_GUID', Tools::getValue('zeleris_guid')) && Configuration::updateValue('ZELERIS_MERCHANDISE_DESCRIPTION', Tools::getValue('zeleris_merchandise_decription')) && Configuration::updateValue('ZELERIS_MODE', Tools::getValue('zeleris_mode')) && Configuration::updateValue('ZELERIS_MANIPULATION', Tools::getValue('zeleris_manipulation')) && Configuration::updateValue('ZELERIS_MANIPULATION_COST', Tools::getValue('zeleris_manipulation_cost')) && Configuration::updateValue('ZELERIS_FREE_SHIPPING', Tools::getValue('zeleris_free_shipping')) && Configuration::updateValue('ZELERIS_MIN_AMOUNT_FREE', Tools::getValue('zeleris_min_amount_free')) && Configuration::updateValue('ZELERIS_FREE_SHIPPING_INTERNACI', Tools::getValue('zeleris_min_amount_free_int')) && Configuration::updateValue('ZELERIS_MIN_AMOUNT_FREE_INT', Tools::getValue('zeleris_min_amount_free_int')) && Configuration::updateValue('ZELERIS_SHOW_SERVICES_ERROR', Tools::getValue('zeleris_show_services_error')) && Configuration::updateValue('ZELERIS_ERROR_MESSAGE', Tools::getValue('zeleris_error_message')) && Configuration::updateValue('ZELERIS_FIXED_COST_SHIPPING', Tools::getValue('zeleris_fixed_cost_shipping')) && Configuration::updateValue('ZELERIS_MARGIN_SHIPPING_COST', Tools::getValue('zeleris_margin_shipping_cost')))
$this->_html .= $this->displayConfirmation($this->l('The configuration has been successfully updated.'));
else
$this->_html .= $this->displayErrors($this->l('ERROR. The configuration has not been updated.'));
}
public function getOrderShippingCost($params, $shipping_cost)
{
$country_user = 'es';
$cp_user = '-';
$total = $params->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING);
$weight = $params->getTotalWeight();
if ($weight == 0)
$weight = 1;
$address_user_id = $params->id_address_delivery;
$query = 'SELECT * FROM '._DB_PREFIX_.'address where id_address = "'.(int)$address_user_id.'"';
$data_user = Db::getInstance()->executeS($query);
if (count($data_user) > 0)
{
$query = 'SELECT iso_code FROM '._DB_PREFIX_.'country where id_country = "'.(int)$data_user[0]['id_country'].'"';
$country_user_id = Db::getInstance()->executeS($query);
$country_user = $country_user_id[0]['iso_code'];
$cp_user = $data_user[0]['postcode'];
}
$manipulation_cost = 0;
if (Configuration::get('ZELERIS_FIXED_COST_SHIPPING'))
$shipping_cost_fixed = (float)(Configuration::get('ZELERIS_FIXED_COST_SHIPPING'));
if (Configuration::get('ZELERIS_MANIPULACION') == 'F')
$manipulation_cost = (float)(Configuration::get('ZELERIS_MANIPULATION_COST'));
if (Configuration::get('ZELERIS_MANIPULACION') == 'V')
$manipulation_cost = (float)($total * (Configuration::get('ZELERIS_MANIPULATION_COST') / 100));
/*************** Calculate shipping ***************/
/*************** National and free ***************/
if ($country_user == 'ES' && Configuration::get('ZELERIS_FREE_SHIPPING') && $total >= Configuration::get('ZELERIS_MIN_AMOUNT_FREE'))
return 0;
/*************** International and free ***************/
if ($country_user !== 'ES' && Configuration::get('ZELERIS_FREE_SHIPPING_INTERNACI') && $total >= Configuration::get('ZELERIS_MIN_AMOUNT_FREE_INT'))
return 0;
/*************** Shipping isn´t free ***************/
if (Configuration::get('ZELERIS_FIXED_COST_SHIPPING'))
{
/*************** fixed cost ***************/
$shipping_cost = $shipping_cost_fixed;
$amount = (float)($shipping_cost + $manipulation_cost);
}
else
{
/*************** Variable cost ***************/
$send = array();
$send['uidCliente'] = Tools::substr(trim($this->clean(Configuration::get('ZELERIS_GUID'))), 0, 32);
$send['codPaisDst'] = Tools::substr(trim($this->clean($country_user)), 0, 2);
$send['cpDst'] = Tools::substr(trim($this->clean($cp_user)), 0, 7);
$send['bultos'] = 1;
$send['weight'] = $weight;
if ($country_user == 'ES')
{
// no decimals national shippings
$send['weight'] = Tools::substr(trim($this->clean(ceil($send['weight']))), 0, 6);
}
else
$send['weight'] = Tools::substr(trim($this->clean(round($send['weight'], 2))), 0, 6);
$send['servicio'] = '0';
$send['URL'] = trim(Configuration::get('ZELERIS_URL'));
$shipping_cost = $this->givePrice($send);
/*************** Call web service to get shipping ***************/
$shipping_cost = $shipping_cost + (float)(Configuration::get('ZELERIS_MARGIN_SHIPPING_COST'));
$amount = (float)($shipping_cost + $manipulation_cost);
if ($amount == 0)
return false;
}
$amount = number_format($amount, (int)Configuration::get('PS_PRICE_DISPLAY_PRECISION'), '.', '');
return (float)$amount;
}
public function getOrderShippingCostExternal($params)
{
}
public function ordersTable()
{
$cookie = $this->context->cookie;
$smarty = $this->smarty;
$this->initZelerisSend();
$smarty->assign('tokenOrder', Tools::getAdminToken('AdminOrders'.(int)Tab::getIdFromClassName('AdminOrders').(int)$cookie->id_employee));
$countQuery = Db::getInstance()->executeS('SELECT COUNT(o.id_order) AS allCmd
FROM '._DB_PREFIX_.'orders o
JOIN '._DB_PREFIX_.'carrier c ON c.id_carrier = o.id_carrier
WHERE LOWER(c.external_module_name) = "zeleriscarrier"');
$perPage = 20;
$allReg = $countQuery[0]['allCmd'];
$p = Tools::getValue('p');
if ($p != '')
{
if (is_nan($p))
$p = 1;
}
else
$p = 1;
require_once(_PS_MODULE_DIR_.'zeleriscarrier/lib/Pager.php');
$pager = new Pager(array('before' => 5, 'after' => 5, 'all' => $allReg, 'page' => $p, 'perPage' => $perPage));
$start = ((int)$p - 1) * $perPage;
$smarty->assign('pager', $pager->setPages());
$smarty->assign('page', (int)$p);
$orders = Db::getInstance()->executeS('SELECT
o.id_order, o.module, o.total_paid_real, o.valid, o.date_add, c.name, e.*,
u.firstname,u.lastname
FROM '._DB_PREFIX_.'orders o
JOIN '._DB_PREFIX_.'carrier c ON c.id_carrier = o.id_carrier
JOIN '._DB_PREFIX_.'zeleris_orders e ON e.id_order = o.id_order
JOIN '._DB_PREFIX_.'customer u ON u.id_customer = o.id_customer
WHERE c.external_module_name = "zeleriscarrier"
ORDER BY o.id_order DESC
LIMIT '.(int)$start.', '.(int)$perPage);
$i = 0;
foreach ($orders as $order)
{
if ($order['valid'])
{
$orders[$i]['link_etiqueta'] = 'index.php?tab=AdminZeleris&id_order_envio='.(int)$order['id_order'].'&option=etiqueta&token='.Tools::getValue('token');
if ($order['send_code'])
{
$orders[$i]['link_cancelar'] = 'index.php?tab=AdminZeleris&id_order_envio='.(int)$order['id_order'].'&option=cancelar&token='.Tools::getValue('token');
$orders[$i]['link_envio_mail'] = 'index.php?tab=AdminZeleris&id_order_envio='.(int)$order['id_order'].'&option=envio&token='.Tools::getValue('token');
}
else
{
$orders[$i]['link_cancelar'] = '';
$orders[$i]['link_envio_mail'] = '';
}
}
else
{
$orders[$i]['link_etiqueta'] = '';
$orders[$i]['link_cancelar'] = '';
}
$orders[$i]['num_pedido'] = sprintf('%06d', (int)$order['id_order']);
$i++;
}
$smarty->assign('path_img_logo', $this->_path.'views/img/logotipo.png');
$smarty->assign('path_img_track', $this->_path.'views/img/track.png');
$smarty->assign('path_img_email', $this->_path.'views/img/email.jpg');
$smarty->assign('path_img_cod_barras', $this->_path.'views/img/cod_barras.png');
$smarty->assign('path_img_cancelar', $this->_path.'views/img/cancelar.gif');
$smarty->assign('token', Tools::getValue('token'));
$smarty->assign('pedidos', $orders);
$smarty->assign('pagerTemplate', _PS_MODULE_DIR_.'zeleriscarrier/views/templates/admin/pager_template.tpl');
return $this->display(__FILE__, 'views/templates/admin/pedidos.tpl');
}
public function printLabels($id_order = 0, $packages = 1)
{
$smarty = $this->smarty;
$errores = false;
if ($id_order)
{
$result = Db::getInstance()->executeS('SELECT send_code
FROM '._DB_PREFIX_.'zeleris_orders
WHERE id_order = "'.(int)$id_order.'"');
$id_track = $result[0]['send_code'];
}
else
Tools::redirectAdmin($this->context->link->getAdminLink('AdminModules', true).'&configure=zeleriscarrier&tab_module=shipping_logistics&module_name=zeleriscarrier');
if ($id_track == '')
{
$data = Db::getInstance()->executeS('SELECT
o.id_order, o.module, o.total_paid_real,
c.name, u.email,
a.firstname, a.lastname, a.address1, a.address2,
a.other, a.postcode, a.city,
a.phone, a.phone_mobile, z.iso_code
FROM '._DB_PREFIX_.'orders AS o
JOIN '._DB_PREFIX_.'carrier AS c ON c.id_carrier = o.id_carrier
JOIN '._DB_PREFIX_.'customer AS u ON u.id_customer = o.id_customer
JOIN '._DB_PREFIX_.'address a ON a.id_address = o.id_address_delivery
JOIN '._DB_PREFIX_.'country AS z ON z.id_country = a.id_country
WHERE
o.id_order = "'.(int)$id_order.'"');
$products = Db::getInstance()->executeS('SELECT product_quantity, product_weight, product_reference
FROM '._DB_PREFIX_.'order_detail
WHERE id_order = "'.(int)$id_order.'"');
$country_zeleris = $data[0]['iso_code'];
$send = array();
$expedition_weight = 0;
$send['detalle'] = '';
foreach ($products as $product)
{
$unitweight = $product['product_weight'];
$units = $product['product_quantity'];
$expedition_weight += $unitweight * $units;
if ($country_zeleris == 'ES')
$unitweight = ceil($unitweight);
else
$unitweight = round($unitweight, 2);
for ($i = 1; $i <= $units; $i++)
{
$send['detalle'] .= '<InfoBulto';
$send['detalle'] .= ' Referencia="'.$product['product_reference'];
$send['detalle'] .= '" Bulto="1';
$send['detalle'] .= '" Kilos="'.$unitweight;
$send['detalle'] .= '" Volumen= "0"';
$send['detalle'] .= '/>';
}
}
if ($country_zeleris == 'ES')
{
if ($expedition_weight < 1)
$expedition_weight = 1;
}
else
{
if ($expedition_weight == 0)
$expedition_weight = 1;
}
$payment_method = $data[0]['module'];
if ($payment_method == 'cashondelivery')
$zeleris_reembolso = (float)($data[0]['total_paid_real']);
else
$zeleris_reembolso = 0;
$send['URL'] = trim(Configuration::get('ZELERIS_URL'));
$send['uidCliente'] = Tools::substr(trim($this->clean(Configuration::get('ZELERIS_GUID'))), 0, 32);
$send['nombreDst'] = Tools::substr(trim($this->clean($data[0]['firstname'])).' '.trim($this->clean($data[0]['lastname'])), 0, 40);
$send['direccionDst'] = Tools::substr(trim($this->clean($data[0]['address1'])).' '.trim($this->clean($data[0]['address2'])), 0, 80);
$send['cpDst'] = Tools::substr(trim($this->clean($data[0]['postcode'])), 0, 7);
$send['poblacionDst'] = Tools::substr(trim($this->clean($data[0]['city'])), 0, 40);
$send['codPaisDst'] = Tools::substr(trim($this->clean($country_zeleris)), 0, 2);
$send['telefono1Dst'] = Tools::substr(trim($this->clean($data[0]['phone'])), 0, 15);
$send['telefono2Dst'] = Tools::substr(trim($this->clean($data[0]['phone_mobile'])), 0, 15);
$send['faxDst'] = '';
$send['emailDst'] = Tools::substr(trim($this->clean($data[0]['email'])), 0, 60);
$send['RefC'] = Tools::substr(sprintf('%06d', trim($this->clean($data[0]['id_order']))), 0, 20);
$send['bultos'] = $packages;
$send['servicio'] = '0';
$send['importeReembolso'] = Tools::substr($zeleris_reembolso, 0, 13);
$send['nombreProducto'] = Tools::substr(trim($this->clean(Configuration::get('ZELERIS_MERCHANDISE_DESCRIPTION'))), 0, 20);