0) { $inpostapi = new ShipX(Configuration::get('INPOSTSHIP_API_KEY'), (bool)Configuration::get('INPOSTSHIP_SANDBOX')); $pack = InpostPack::getInpostShipByIdPack((int)$label_id); $format = Configuration::get('INPOSTSHIP_PRINT_FORMAT'); $inpost = $inpostapi->getLabel($pack['packcode'], $format, Configuration::get('INPOSTSHIP_PRINT_TYPE')); $file_name = $pack['reference_number']; if ($format == 'PDF') { $file_type = 'pdf'; header('Content-Type: application/pdf'); } else { $file_type = 'epl'; header('Content-Type: application/octet-stream'); } if ($print == 1) { $file = __DIR__ . '/../../files/' . $file_name . '.' . $file_type; file_put_contents($file, $inpost); $printer = (int)Configuration::get('INPOSTSHIP_PRINTNODE_PRINTER'); if ($printer > 0) { $ssl = 'http' . (isset($_SERVER['HTTPS']) ? 's' : '') . '://'; $apiKey = Configuration::get('INPOSTSHIP_PRINTNODE_API'); if (file_exists($file)) { $printNode = new PrintNodeApi($apiKey); $url = $ssl . $this->context->shop->domain . $this->context->shop->physical_uri . 'modules/inpostship/files/' . $file_name . '.' . $file_type; $job = $printNode->printJob($printer, $url, 'Wydruk etykiety ' . $file_name); if ((int)$job > 0) { $ret = '&success=95'; } else { $error = json_decode($job); $ret = '&error='.base64_encode('Wystąpił błąd! '.$error->code.': '.$error->message); } } else { $ret = '&error=94'; } } else { $ret = '&error=93'; } Tools::redirect($_SERVER['HTTP_REFERER'].$ret); } else { header("Content-Disposition: attachment; filename=\"$file_name.$file_type\""); exit($inpost); } } } }