This repository has been 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
/
dpdpoland.pdf.php
executable file
·75 lines (65 loc) · 2.66 KB
/
dpdpoland.pdf.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
<?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('printLabels'))
{
$cookie = new Cookie(_DPDPOLAND_COOKIE_);
if (isset($cookie->dpdpoland_package_id))
{
$package_id = $cookie->dpdpoland_package_id;
$printout_format = $cookie->dpdpoland_printout_format;
unset($cookie->dpdpoland_package_id);
unset($cookie->dpdpoland_printout_format);
$cookie->write();
$package = new DpdPolandPackage((int)$package_id);
$pdf_file_contents = $package->generateLabels('PDF', $printout_format);
ob_end_clean();
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="package_labels_'.(int)Tools::getValue('id_package_ws').'.pdf"');
echo $pdf_file_contents;
exit;
}
$package = new DpdPolandPackage((int)Tools::getValue('id_package_ws'));
if ($pdf_file_contents = $package->generateLabels())
{
$cookie->dpdpoland_package_id = (int)Tools::getValue('id_package_ws');
$printout_format = Tools::getValue('printout_format');
if (!in_array($printout_format, array(DpdPolandConfiguration::PRINTOUT_FORMAT_A4, DpdPolandConfiguration::PRINTOUT_FORMAT_LABEL)))
$printout_format = DpdPolandConfiguration::PRINTOUT_FORMAT_A4;
$cookie->dpdpoland_printout_format = $printout_format;
Tools::redirectAdmin(Tools::getValue('returnOnErrorTo').'&scrollToShipment');
exit;
}
else
{
DpdPoland::addFlashError(reset(DpdPolandPackageWS::$errors));
Tools::redirectAdmin(Tools::getValue('returnOnErrorTo').'&scrollToShipment');
exit;
}
}
if (Tools::isSubmit('downloadModuleCSVSettings'))
{
include_once(_DPDPOLAND_CONTROLLERS_DIR_.'csv.controller.php');
$controller = new DpdPolandCSVController;
$controller->generateCSV();
}