This repository was archived by the owner on Mar 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdpdpoland.ajax.php
executable file
·104 lines (87 loc) · 3.23 KB
/
dpdpoland.ajax.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
<?php
/**
* 2014 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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
* [email protected] so we can send you a copy immediately.
*
* @author JSC INVERTUS www.invertus.lt <[email protected]>
* @copyright 2014 DPD Polska Sp. z o.o.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
*/
include_once(dirname(__FILE__).'/../../config/config.inc.php');
include_once(dirname(__FILE__).'/../../init.php');
$module_instance = Module::getInstanceByName('dpdpoland');
if (!Tools::isSubmit('token') || (Tools::isSubmit('token')) && Tools::getValue('token') != sha1(_COOKIE_KEY_.$module_instance->name)) exit;
if (Tools::isSubmit('getFormatedAddressHTML'))
{
$id_address = (int)Tools::getValue('id_address');
echo $module_instance->getFormatedAddressHTML($id_address);
exit;
}
if (Tools::isSubmit('getProducts'))
{
echo Tools::jsonEncode($module_instance->searchProducts(Tools::getValue('q')));
exit;
}
if (Tools::isSubmit('savePackagePrintLabels'))
{
if (!$id_package_ws = $module_instance->savePackageFromPost())
{
die(Tools::jsonEncode(array(
'error' => reset(DpdPoland::$errors)
)));
}
$printout_format = Tools::getValue('dpdpoland_printout_format');
if ($printout_format != DpdPolandConfiguration::PRINTOUT_FORMAT_LABEL && $printout_format != DpdPolandConfiguration::PRINTOUT_FORMAT_A4)
$printout_format = DpdPolandConfiguration::PRINTOUT_FORMAT_LABEL;
die(Tools::jsonEncode(array(
'error' => false,
'id_package_ws' => (int)$id_package_ws,
'link_to_labels_pdf' => '?printLabels&id_package_ws='.(int)$id_package_ws.'&printout_format='.$printout_format.'&token='.Tools::getValue('token')
)));
}
if (Tools::isSubmit('printLabels'))
{
$printout_format = Tools::getValue('dpdpoland_printout_format');
if ($printout_format != DpdPolandConfiguration::PRINTOUT_FORMAT_LABEL && $printout_format != DpdPolandConfiguration::PRINTOUT_FORMAT_A4)
$printout_format = DpdPolandConfiguration::PRINTOUT_FORMAT_LABEL;
die(Tools::jsonEncode(array(
'error' => false,
'link_to_labels_pdf' => '?printLabels&id_package_ws='.(int)Tools::getValue('id_package_ws').
'&printout_format='.$printout_format.'&token='.Tools::getValue('token')
)));
}
if (Tools::getValue('addDPDClientNumber'))
{
$result = $module_instance->addDPDClientNumber();
die(Tools::jsonEncode($result));
}
if (Tools::getValue('deleteDPDClientNumber'))
{
$result = $module_instance->deleteDPDClientNumber();
die(Tools::jsonEncode($result));
}
if (Tools::getValue('getPayerNumbersTableHTML'))
{
$html = $module_instance->getPayerNumbersTableHTML();
die(Tools::jsonEncode($html));
}
if (Tools::getValue('calculateTimeLeft'))
{
$time_left = $module_instance->calculateTimeLeft();
die(Tools::jsonEncode($time_left));
}
if (Tools::getValue('getTimeFrames'))
{
$html = $module_instance->getTimeFrames();
die(Tools::jsonEncode($html));
}