Exemple #1
0
 /**
  * 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);
 }
Exemple #2
0
 /**
  * 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);
 }
 /**
  * Generate order review interface and return it as HTML string
  * @param boolean
  * @return string
  */
 protected function getOrderReviewInterface($blnReview = false)
 {
     if ($blnReview) {
         return;
     }
     $objTemplate = new IsotopeTemplate('iso_checkout_order_review');
     $objTemplate->headline = $GLOBALS['TL_LANG']['ISO']['order_review'];
     $objTemplate->message = $GLOBALS['TL_LANG']['ISO']['order_review_message'];
     $objTemplate->summary = $GLOBALS['ISO_LANG']['MSC']['cartSummary'];
     // Surcharges must be initialized before getProducts() to apply tax_id to each product
     $arrSurcharges = $this->Isotope->Cart->getSurcharges();
     $arrProductData = array();
     $arrProducts = $this->Isotope->Cart->getProducts();
     foreach ($arrProducts as $objProduct) {
         $arrProductData[] = array_merge($objProduct->getAttributes(), array('id' => $objProduct->id, 'image' => $objProduct->images->main_image, 'link' => $objProduct->href_reader, 'price' => $this->Isotope->formatPriceWithCurrency($objProduct->price), 'total_price' => $this->Isotope->formatPriceWithCurrency($objProduct->total_price), 'quantity' => $objProduct->quantity_requested, 'tax_id' => $objProduct->tax_id, 'product_options' => $objProduct->getOptions()));
     }
     $objTemplate->info = $this->getCheckoutInfo();
     $objTemplate->products = IsotopeFrontend::generateRowClass($arrProductData, 'row', 'rowClass', 0, ISO_CLASS_COUNT | ISO_CLASS_FIRSTLAST | ISO_CLASS_EVENODD);
     $objTemplate->surcharges = IsotopeFrontend::formatSurcharges($arrSurcharges);
     $objTemplate->edit_info = $GLOBALS['TL_LANG']['ISO']['changeCheckoutInfo'];
     $objTemplate->subTotalLabel = $GLOBALS['TL_LANG']['MSC']['subTotalLabel'];
     $objTemplate->grandTotalLabel = $GLOBALS['TL_LANG']['MSC']['grandTotalLabel'];
     $objTemplate->subTotalPrice = $this->Isotope->formatPriceWithCurrency($this->Isotope->Cart->subTotal);
     $objTemplate->grandTotalPrice = $this->Isotope->formatPriceWithCurrency($this->Isotope->Cart->grandTotal);
     return $objTemplate->parse();
 }
 /**
  * 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();
 }
 public function getShippingOptions(&$objModule)
 {
     $arrOptions = deserialize($this->upgrade_options, true);
     if (count($arrOptions)) {
         $objTemplate = new IsotopeTemplate('iso_checkout_shipping_options');
         $objTemplate->module_id = $this->id;
         $objTemplate->options = $arrOptions;
         return $objTemplate->parse();
     }
     return '';
 }
 /**
  * Fetch products from database
  * @param string
  * @param boolean
  * @return array
  */
 public function getProducts($strTemplate = '', $blnNoCache = false)
 {
     if (!is_array($this->arrProducts) || $blnNoCache) {
         $this->arrProducts = array();
         $this->arrCache['lastAdded'] = 0;
         $lastAdded = 0;
         $objItems = $this->Database->prepare("SELECT * FROM " . $this->ctable . " WHERE pid=?")->executeUncached($this->id);
         while ($objItems->next()) {
             $objProductData = $this->Database->execute("SELECT *, (SELECT class FROM tl_iso_producttypes WHERE tl_iso_products.type=tl_iso_producttypes.id) AS product_class FROM tl_iso_products WHERE id={$objItems->product_id}");
             $strClass = $GLOBALS['ISO_PRODUCT'][$objProductData->product_class]['class'];
             if ($objProductData->numRows && $strClass != '') {
                 try {
                     $arrData = $this->blnLocked ? array_merge($objProductData->row(), array('sku' => $objItems->product_sku, 'name' => $objItems->product_name, 'price' => $objItems->price)) : $objProductData->row();
                     $objProduct = new $strClass($arrData, deserialize($objItems->product_options), $this->blnLocked);
                 } catch (Exception $e) {
                     $objProduct = new IsotopeProduct(array('id' => $objItems->product_id, 'sku' => $objItems->product_sku, 'name' => $objItems->product_name, 'price' => $objItems->price), deserialize($objItems->product_options), $this->blnLocked);
                 }
             } else {
                 $objProduct = new IsotopeProduct(array('id' => $objItems->product_id, 'sku' => $objItems->product_sku, 'name' => $objItems->product_name, 'price' => $objItems->price), deserialize($objItems->product_options), $this->blnLocked);
             }
             // Remove product from collection if it is no longer available
             if (!$objProduct->available) {
                 $objProduct->cart_id = $objItems->id;
                 $this->deleteProduct($objProduct);
                 continue;
             }
             $objProduct->quantity_requested = $objItems->product_quantity;
             $objProduct->cart_id = $objItems->id;
             $objProduct->tax_id = $objItems->tax_id;
             $objProduct->reader_jumpTo_Override = $objItems->href_reader;
             if ($objItems->tstamp > $lastAdded) {
                 $this->arrCache['lastAdded'] = $objItems->id;
                 $lastAdded = $objItems->tstamp;
             }
             $this->arrProducts[] = $objProduct;
         }
     }
     if (strlen($strTemplate)) {
         $this->import('Isotope');
         $objTemplate = new IsotopeTemplate($strTemplate);
         $objTemplate->products = $this->arrProducts;
         $objTemplate->surcharges = IsotopeFrontend::formatSurcharges($this->getSurcharges());
         $objTemplate->subTotalLabel = $GLOBALS['TL_LANG']['MSC']['subTotalLabel'];
         $objTemplate->subTotalPrice = $this->Isotope->formatPriceWithCurrency($this->subTotal, false);
         $objTemplate->grandTotalLabel = $GLOBALS['TL_LANG']['MSC']['grandTotalLabel'];
         $objTemplate->grandTotalPrice = $this->Isotope->formatPriceWithCurrency($this->grandTotal, false);
         return $objTemplate->parse();
     }
     return $this->arrProducts;
 }
 /**
  * Compile content for printing a shipping label
  *
  * @access protected
  * @param array
  * @param string
  * @return string
  */
 protected function printShippingLabel($strImagePath, $strTitle, $blnOutput = true)
 {
     $objTemplate = new IsotopeTemplate('be_iso_upslabel');
     $objTemplate->label = $this->Environment->base . '/' . $strImagePath;
     $objTemplate->title = $strTitle;
     $this->generatePDF($strTitle, $objTemplate->parse(), true);
 }