/** * Grab PDF of Manifest or Label Content put to file and return path to file * @param $type (string) - 'label' | 'manifest' who need to get * @param $parameters (array) - Some parameters id_order is request * @return mix */ public function getPdfFile($type, $parameters = array(), $action = 'join') { if (!is_string($type)) { self::log('getPdfFile -> $type variable type is not correct, available (string) given: ' . gettype($type)); return false; } switch ($type) { case 'label': return DpdLabelRender::getLabel(array('id_orders' => $parameters), $action); case 'manifest': return DpdManifestRender::getManifest(array('id_orders' => $parameters)); default: self::log('getPdfFile -> Type not found I got: ' . $type); return false; } }
/** * Function of Bulk Action to Print DPD Manifest * @return Mix */ public function processBulkPrintDpdManifest() { $manifest = Module::getInstanceByName('dynamicparceldistribution'); $pathToFile = $manifest->getPdfFile('manifest', Tools::getValue('orderBox')); foreach (DpdManifestRender::getWarningMessage() as $message) { $this->displayWarning($this->l($message)); } if ($pathToFile === false) { foreach (DpdManifestRender::getErrorMessage() as $message) { $this->errors[] = $this->l($message); } } else { $manifest->download($pathToFile, 'manifest.pdf', 'application/pdf'); } }