/** * Generate gallery and return it as HTML string * @param string * @param integer * @param boolean * @return string */ public function generateGallery($strType = 'gallery', $intSkip = 0, $blnForce = false) { // Do not render gallery if there are no additional image $total = count($this->arrFiles); if (($total == 1 || $total <= $intSkip) && !$blnForce) { return $this->generateAttribute($this->name . '_gallery', ' ', $strType); } $strGallery = ''; foreach ($this->arrFiles as $i => $arrFile) { if ($i < $intSkip) { continue; } $objTemplate = new IsotopeTemplate($this->strTemplate); $objTemplate->setData($arrFile); $objTemplate->id = $i; $objTemplate->mode = 'gallery'; $objTemplate->type = $strType; $objTemplate->name = $this->name; $objTemplate->product_id = $this->product_id; $objTemplate->href_reader = $this->href_reader; list($objTemplate->link, $objTemplate->rel) = explode('|', $arrFile['link']); if ($i == 0) { $objTemplate->class = 'active'; } $strGallery .= $objTemplate->parse(); } return $this->generateAttribute($this->name . '_gallery', $strGallery, $strType); }
/** * Generate gallery and return it as HTML string * @param string * @param integer * @return string */ public function generateGallery($strType = 'gallery', $intSkip = 1) { $strGallery = ''; foreach ($this->arrFiles as $i => $arrFile) { if ($i < $intSkip) { continue; } $objTemplate = new IsotopeTemplate($this->strTemplate); $objTemplate->setData($arrFile); $objTemplate->id = $i; $objTemplate->mode = 'gallery'; $objTemplate->type = $strType; $objTemplate->name = $this->name; $objTemplate->product_id = $this->product_id; $objTemplate->href_reader = $this->href_reader; list($objTemplate->link, $objTemplate->rel) = explode('|', $arrFile['link']); $strGallery .= $objTemplate->parse(); } $this->injectAjax(); return $this->generateAttribute($this->name . '_gallery', $strGallery, $strType); }
/** * Button Callback for the MultipleShipping backend interface for label generation * * @access public * @param int * @return string */ public function backendInterfaceMultiple($intOrderId, $intPackageId = 0) { $objOrder = IsotopeOrder::findByPk($intOrderId); $strFormId = 'fedex_backend_interface'; //Check for valid order if ($objOrder === null) { \System::log('Invalid order id.', __METHOD__, TL_ERROR); $this->redirect('contao/main.php?act=error'); } //Get the order's products $arrProducts = array(); $arrItems = (array) $objOrder->getItems(); foreach ($arrItems as $objItem) { $arrProducts[] = $objItem->getProduct(); } //Get the package data $objPackage = \Database::getInstance()->execute("SELECT * FROM tl_iso_packages WHERE id={$intPackageId}"); if (!$objPackage->numRows) { return '<p class="tl_gerror">' . $GLOBALS['TL_LANG']['ISO']['backendShippingNotFound'] . '</p>'; } //Build the initial compiled package data array $arrPackage = array('id' => $objPackage->id, 'address' => deserialize($objPackage->order_address, true), 'formattedaddress' => $objOrder->getShippingAddress()->generateText(), 'status' => $GLOBALS['TL_LANG']['ISO']['multipleshipping'][$objPackage->status], 'formid' => $strFormId . '_' . $objPackage->id); //Check for an existing label thumbnail and create one if it has not been created if ($objPackage->fedex_label) { //Set a cache name $strCacheName = 'system/tmp/fedex_label_' . $objOrder->document_number . '_' . $objPackage->id . substr(md5($arrPackage['formattedaddress']), 0, 8) . '.gif'; $arrPackage['label'] = $this->getShippingLabelImage($objPackage->fedex_label, $strCacheName, 75, 75, 'exact'); $arrPackage['labelLink'] = \Environment::get('request') . '&printLabel=' . $arrPackage['formid']; //Now that we have the label created check for request to output to PDF if (\Input::get('printLabel') == $arrPackage['formid']) { $this->printShippingLabel($strCacheName, 'order_' . $objOrder->document_number . '_' . $intPackageId, true); } } //Add tracking number if (strlen($objPackage->fedex_tracking_number)) { $arrPackage['tracking'] = $objPackage->fedex_tracking_number; } //Add package products $arrShipmentProducts = \Database::getInstance()->execute("SELECT product_id FROM tl_iso_product_collection_item WHERE package_id={$objPackage->id}")->fetchEach('product_id'); foreach ($arrProducts as $objProduct) { if (in_array($objProduct->id, $arrShipmentProducts)) { $arrPackage['products'][] = $objProduct; } } //Data has been submitted. Send request for tracking numbers and label if (\Input::post('FORM_SUBMIT') == $arrPackage['formid']) { $this->Shipment = $arrPackage; list($arrOrigin, $arrDestination, $arrShipment) = $this->buildShipment(); $objFEDEXAPI = new FedExAPIShipping($arrShipment, $arrOrigin, $arrOrigin, $arrDestination); $xmlShip = $objFEDEXAPI->buildRequest(); $arrResponse = $objFEDEXAPI->sendRequest($xmlShip); //Request was successful - add the new data to the package if ((int) $arrResponse['ShipmentAcceptResponse']['Response']['ResponseStatusCode'] == 1) { $objOrder->fedex_tracking_number = $arrResponse['ShipmentAcceptResponse']['ShipmentResults']['ShipmentIdentificationNumber']; $objOrder->fedex_label = $arrResponse['ShipmentAcceptResponse']['ShipmentResults']['PackageResults']['LabelImage']['GraphicImage']; $objOrder->save(); if (\Database::getInstance()->tableExists('tl_iso_packages') && $arrPackage['formid'] != $strFormId . '_' . 'order') { \Database::getInstance()->prepare("UPDATE tl_iso_packages SET fedex_tracking_number=?, fedex_label=?, status='shipped' WHERE id=?")->execute($objOrder->fedex_tracking_number, $objOrder->fedex_label, $arrPackage['id']); } $strCacheName = 'system/tmp/fedex_label_' . $objOrder->document_number . '_' . $objPackage->id . substr(md5($arrPackage['formattedaddress']), 0, 8) . '.gif'; $arrPackage['label'] = $this->getShippingLabelImage($objOrder->fedex_label, $strCacheName); $arrPackage['tracking'] = $objOrder->fedex_tracking_number; } else { //Request returned an error $strDescription = $arrResponse['ShipmentAcceptResponse']["Response"]["ResponseStatusDescription"]; $strError = $arrResponse['ShipmentAcceptResponse']["Response"]["Error"]["ErrorDescription"]; $_SESSION['TL_ERROR'][] = $strDescription . ' - ' . $strError; \System::log(sprintf('Error in shipping digest: %s - %s', $strDescription, $strError), __METHOD__, TL_ERROR); $this->redirect('contao/main.php?act=error'); } } //Set template data $objTemplate = new IsotopeTemplate('be_iso_fedex'); $objTemplate->setData($arrPackage); $objTemplate->labelHeader = $GLOBALS['TL_LANG']['MSC']['labelLabel']; $objTemplate->trackingHeader = $GLOBALS['TL_LANG']['MSC']['trackingNumberLabel']; $objTemplate->addressHeader = $GLOBALS['TL_LANG']['MSC']['shippingAddress']; $objTemplate->statusHeader = $GLOBALS['TL_LANG']['MSC']['shippingStatus']; $objTemplate->submitLabel = $objPackage->status != 'not_shipped' ? $GLOBALS['TL_LANG']['MSC']['re-ship'] : $GLOBALS['TL_LANG']['MSC']['ship']; return $objTemplate->parse(); }