Example #1
0
/**
 * Given some details, generate a printable packing slip.
 *
 * @param string $title Title of the packing slip.
 * @param array $details Array of details about the packing slip.
 * @param array $products Array of products for the packing slip.
 * @return string Generated HTML packing slip.
 */
function generatePrintablePackingSlip($title, $details, $products)
{
	$db = $GLOBALS['ISC_CLASS_DB'];

	$template = new TEMPLATE('ISC_LANG');
	$template->frontEnd();
	$template->setTemplateBase(ISC_BASE_PATH . "/templates");
	$template->panelPHPDir = ISC_BASE_PATH . "/includes/display/";
	$template->templateExt = "html";
	$template->setTemplate(getConfig("template"));

	$template->assign('PackingSlipTitle', $title);
	$template->assign('OrderId', $details['shiporderid']);
	$template->assign('OrderDate', cdate($details['shiporderdate']));

	if(!empty($details['shipmethod'])) {
		$template->assign('ShippingMethod', isc_html_escape($details['shipmethod']));
	}
	else {
		$template->assign('HideShippingMethod', 'display: none');
	}

	if(!empty($details['shiptrackno'])) {
		$template->assign('TrackingNo', isc_html_escape($details['shiptrackno']));
	}
	else {
		$template->assign('HideTrackingNo', 'display: none');
	}

	if(!empty($details['shipcomments'])) {
		$template->assign('Comments', nl2br(isc_html_escape($details['shipcomments'])));
		$template->assign('HideComments', '');
	}
	else {
		$template->assign('Comments', '');
		$template->assign('HideComments', 'display: none');
	}

	if(!empty($details['shipdate'])) {
		$template->assign('DateShipped', cDate($details['shipdate']));
	}
	else {
		$template->assign('HideShippingDate', 'display: none');
	}

	if(empty($products)) {
		return false;
	}

	$query = "
		SELECT customerid, CONCAT(custconfirstname, ' ', custconlastname) AS ordcustname, custconemail AS ordcustemail, custconphone AS ordcustphone
		FROM [|PREFIX|]customers
		WHERE customerid = '".$db->Quote($details['shipcustid'])."'
	";
	$query .= $db->AddLimit(0, 1);
	$result = $db->Query($query);

	$template->assign('CustomerName', '');
	$template->assign('CustomerEmail', '');
	$template->assign('CustomerPhone', '');

	if($customer = $db->Fetch($result)) {
		// Format the customer details
		$template->assign('CustomerName', isc_html_escape($customer['ordcustname']));
		$template->assign('CustomerEmail', isc_html_escape($customer['ordcustemail']));
		$template->assign('CuastomerPhone', isc_html_escape($customer['ordcustphone']));
		$template->assign('CustomerId', $customer['customerid']);
	}
	else {
		$template->assign('HideCustomerDetails', 'display: none');
	}

	$template->assign('StoreAddressFormatted', nl2br(GetConfig('StoreAddress')));

	$addressDetails = array(
		'shipfirstname'	=> $details['shipbillfirstname'],
		'shiplastname'	=> $details['shipbilllastname'],
		'shipcompany'	=> $details['shipbillcompany'],
		'shipaddress1'	=> $details['shipbillstreet1'],
		'shipaddress2'	=> $details['shipbillstreet2'],
		'shipcity'		=> $details['shipbillsuburb'],
		'shipstate'		=> $details['shipbillstate'],
		'shipzip'		=> $details['shipbillzip'],
		'shipcountry'	=> $details['shipbillcountry'],
		'countrycode'	=> $details['shipbillcountrycode'],
	);
	$template->assign('BillingAddress', ISC_ADMIN_ORDERS::buildOrderAddressDetails($addressDetails, false));
	$template->assign('BillingPhone', isc_html_escape($details['shipbillphone']));
	if(!$details['shipbillphone']) {
		$template->assign('HideBillingPhone', 'display: none');
	}
	$template->assign('BillingEmail', isc_html_escape($details['shipbillemail']));
	if(!$details['shipbillemail']) {
		$template->assign('HideBillingEmail', 'display: none');
	}

	$addressDetails = array(
		'shipfirstname'	=> $details['shipshipfirstname'],
		'shiplastname'	=> $details['shipshiplastname'],
		'shipcompany'	=> $details['shipshipcompany'],
		'shipaddress1'	=> $details['shipshipstreet1'],
		'shipaddress2'	=> $details['shipshipstreet2'],
		'shipcity'		=> $details['shipshipsuburb'],
		'shipstate'		=> $details['shipshipstate'],
		'shipzip'		=> $details['shipshipzip'],
		'shipcountry'	=> $details['shipshipcountry'],
		'countrycode'	=> $details['shipshipcountrycode'],
	);
	$template->assign('ShippingAddress', ISC_ADMIN_ORDERS::buildOrderAddressDetails($addressDetails, false));
	$template->assign('ShippingPhone', isc_html_escape($details['shipshipphone']));
	if(!$details['shipshipphone']) {
		$template->assign('HideShippingPhone', 'display: none');
	}
	$template->assign('ShippingEmail', isc_html_escape($details['shipshipemail']));
	if(!$details['shipshipemail']) {
		$template->assign('HideShippingEmail', 'display: none');
	}

	$fieldsArray = array();
	$query = "
		SELECT o.*
		FROM [|PREFIX|]order_configurable_fields o
		JOIN [|PREFIX|]product_configurable_fields p ON o.fieldid = p.productfieldid
		WHERE o.orderid=".(int)$details['shiporderid']."
		ORDER BY p.fieldsortorder ASC
	";
	$result = $db->Query($query);
	$fields = array();
	while ($row = $db->Fetch($result)) {
		$fieldsArray[$row['ordprodid']][] = $row;
	}

	// Build the list of products that are being shipped
	$productsTable = '';
	foreach($products as $product) {
		$template->assign('ProductName', isc_html_escape($product['prodname']));
		if($product['prodcode']) {
			$template->assign('ProductSku', isc_html_escape($product['prodcode']));
		}
		else {
			$template->assign('ProductSku', getLang('NA'));
		}
		$template->assign('ProductQuantity', $product['prodqty']);

		$pOptions = '';
		if($product['prodoptions'] != '') {
			$options = @unserialize($product['prodoptions']);
			if(!empty($options)) {
				foreach($options as $name => $value) {
					$template->assign('FieldName', isc_html_escape($name));
					$template->assign('FieldValue', isc_html_escape($value));
					$pOptions .= $template->GetSnippet('PrintableInvoiceItemConfigurableField');
				}
			}
		}

		if($pOptions) {
			$template->assign('ProductOptions', $pOptions);
			$template->assign('HideVariationOptions', '');
		}
		else {
			$template->assign('HideVariationOptions', 'display: none');
		}

		$productFields = '';
		if(!empty($fieldsArray[$product['prodordprodid']])) {
			$fields = $fieldsArray[$product['prodordprodid']];
			foreach($fields as $field) {
				if(empty($field['textcontents']) && empty($field['filename'])) {
					continue;
				}

				$fieldValue = '-';
				$template->assign('FieldName', isc_html_escape($field['fieldname']));

				if($field['fieldtype'] == 'file') {
					$fieldValue = '<a href="'.GetConfig('ShopPath').'/'.GetConfig('ImageDirectory').'/configured_products/'.urlencode($field['originalfilename']).'">'.isc_html_escape($field['originalfilename']).'</a>';
				}
				else {
					$fieldValue = isc_html_escape($field['textcontents']);
				}

				$template->assign('FieldValue', $fieldValue);
				$productFields .= $template->getSnippet('PrintableInvoiceItemConfigurableField');
			}
		}
		$template->assign('ProductConfigurableFields', $productFields);
		if(!$productFields) {
			$template->assign('HideConfigurableFields', 'display: none');
		}
		else {
			$template->assign('HideConfigurableFields', '');
		}

		if($product['prodeventdatename']) {
			$template->assign('FieldName', isc_html_escape($product['prodeventdatename']));
			$template->assign('FieldValue', isc_date('dS M Y', $product['prodeventdate']));
			$template->assign('ProductEventDate', $template->getSnippet('PrintableInvoiceItemConfigurableField'));
			$template->assign('HideEventDate', '');
		}
		else {
			$template->assign('ProductEventDate', '');
			$template->assign('HideEventDate', 'display: none');
		}

		$productsTable .= $template->GetSnippet('PrintablePackingSlipItem');
	}
	$template->assign('ProductsTable', $productsTable);
	$template->setTemplate('packing_slip_print');
	return $template->parseTemplate(true);
}
 /**
  * Display the quick view for an order
  *
  * @return void
  **/
 public function GetOrderQuickView()
 {
     $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->LoadLangFile('orders');
     // Output a quick view for this order to be used on the manage orders page
     $orderId = (int) $_REQUEST['o'];
     $GLOBALS["OrderId"] = $orderId;
     // Get the details for this order from the database
     $query = "\n\t\t\t\tSELECT o.*, CONCAT(custconfirstname, ' ', custconlastname) AS custname, custconemail, custconphone, s.zonename AS shippingzonename,\n\t\t\t\t(SELECT COUNT(messageid) FROM [|PREFIX|]order_messages WHERE messageorderid=orderid AND messagestatus='unread') AS numunreadmessages\n\t\t\t\tFROM [|PREFIX|]orders o\n\t\t\t\tLEFT JOIN [|PREFIX|]customers c ON (c.customerid=o.ordcustid)\n\t\t\t\tLEFT JOIN [|PREFIX|]shipping_zones s ON (s.zoneid=o.ordshippingzoneid)\n\t\t\t\tWHERE o.orderid='" . $GLOBALS['ISC_CLASS_DB']->Quote($orderId) . "'\n\t\t\t";
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     if ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         // If this user is a vendor, do they have permission to acess this order?
         if ($GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId() && $row['ordvendorid'] != $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId()) {
             exit;
         }
         $GLOBALS['OrderDate'] = isc_date("d M Y H:i:s", $row['orddate']);
         $GLOBALS['ISC_CLASS_ADMIN_ORDERS'] = GetClass('ISC_ADMIN_ORDERS');
         $GLOBALS['OrderStatusOptions'] = $GLOBALS['ISC_CLASS_ADMIN_ORDERS']->GetOrderStatusOptions($row['ordstatus']);
         $GLOBALS['TrackingNo'] = $row['ordtrackingno'];
         $GLOBALS['NumMessages'] = $row['numunreadmessages'];
         if ($row["numunreadmessages"] == 0) {
             $GLOBALS["HideMessages"] = "none";
         }
         if (!gzte11(ISC_LARGEPRINT)) {
             $GLOBALS["HideMessageItems"] = "none";
         }
         $row['custname'] = isc_html_escape(trim($row['custname']));
         $addressDetails = array('shipfirstname' => $row['ordbillfirstname'], 'shiplastname' => $row['ordbilllastname'], 'shipcompany' => $row['ordbillcompany'], 'shipaddress1' => $row['ordbillstreet1'], 'shipaddress2' => $row['ordbillstreet2'], 'shipcity' => $row['ordbillsuburb'], 'shipstate' => $row['ordbillstate'], 'shipzip' => $row['ordbillzip'], 'shipcountry' => $row['ordbillcountry'], 'countrycode' => $row['ordbillcountrycode']);
         $GLOBALS['BillingAddress'] = ISC_ADMIN_ORDERS::BuildOrderAddressDetails($addressDetails);
         $GLOBALS['BillingEmail'] = '';
         $GLOBALS['BillingPhone'] = '';
         $GLOBALS['ShippingEmail'] = '';
         $GLOBALS['ShippingPhone'] = '';
         // For the iPhone's "Map This" feature
         $GLOBALS['OneLineBillingAddress'] = trim(isc_html_escape($row['ordbillstreet1'] . ' ' . $row['ordbillstreet2'] . ' ' . $row['ordbillsuburb'] . ' ' . $row['ordbillstate'] . ' ' . $row['ordbillzip'] . ' ' . $row['ordbillcountry']));
         $GLOBALS['OneLineShippingAddress'] = trim(isc_html_escape($row['ordshipstreet1'] . ' ' . $row['ordshipstreet2'] . ' ' . $row['ordshipsuburb'] . ' ' . $row['ordshipstate'] . ' ' . $row['ordshipzip'] . ' ' . $row['ordshipcountry']));
         // This customer still exists, use their most recent email address and phone number
         if ($row['custname'] != '') {
             $GLOBALS['BillingEmail'] = sprintf('<a href="mailto:%s" target="_blank">%s</a>', urlencode($row['custconemail']), isc_html_escape($row['custconemail']));
             $GLOBALS['ShippingEmail'] = sprintf('<a href="mailto:%s" target="_blank">%s</a>', urlencode($row['custconemail']), isc_html_escape($row['custconemail']));
             if ($row['ordbillphone'] != '') {
                 $GLOBALS['BillingPhone'] = isc_html_escape($row['ordbillphone']);
             } else {
                 $GLOBALS['BillingPhone'] = isc_html_escape($row['custconphone']);
             }
             if ($row['ordshipphone'] != '') {
                 $GLOBALS['ShippingPhone'] = isc_html_escape($row['ordshipphone']);
             } else {
                 $GLOBALS['ShippingPhone'] = isc_html_escape($row['custconphone']);
             }
         } else {
             if ($row['ordbillphone'] != '' || $row['ordbillemail'] != '' || $row['ordshipphone'] != '' || $row['ordshipemail'] != '') {
                 $GLOBALS['BillingEmail'] = sprintf('<a href="mailto:%s" target="_blank">%s</a>', $row['ordbillemail'], $row['ordbillemail']);
                 $GLOBALS['BillingPhone'] = isc_html_escape($row['ordbillphone']);
                 $GLOBALS['ShippingEmail'] = sprintf('<a href="mailto:%s" target="_blank">%s</a>', $row['ordshipemail'], $row['ordshipemail']);
                 $GLOBALS['ShippingPhone'] = isc_html_escape($row['ordshipphone']);
             }
         }
         if ($GLOBALS['BillingPhone'] === '') {
             $GLOBALS['BillingPhone'] = GetLang('NA');
         }
         if ($GLOBALS['BillingEmail'] === '') {
             $GLOBALS['BillingEmail'] = GetLang('NA');
         }
         if ($GLOBALS['ShippingPhone'] === '') {
             $GLOBALS['ShippingPhone'] = GetLang('NA');
         }
         if ($GLOBALS['ShippingEmail'] === '') {
             $GLOBALS['ShippingEmail'] = GetLang('NA');
         }
         $GLOBALS['PaymentMethod'] = array();
         if ($row['orderpaymentmethod'] == '') {
             $row['orderpaymentmethod'] = "N/A";
         }
         if ($row['orderpaymentmethod'] != "storecredit" && $row['orderpaymentmethod'] != "giftcertificate") {
             if ($row['ordgatewayamount']) {
                 $row['orderpaymentmethod'] .= " (" . FormatPriceInCurrency($row['ordgatewayamount'], $row['orddefaultcurrencyid']) . ")";
             } else {
                 $row['orderpaymentmethod'] .= " (" . FormatPriceInCurrency($row['ordtotalamount'], $row['orddefaultcurrencyid']) . ")";
             }
             // Does the payment method have any extra info to show?
             $provider = null;
             $GLOBALS['ExtraInfo'] = '';
             if (GetModuleById('checkout', $provider, $row['orderpaymentmodule'])) {
                 if (method_exists($provider, "DisplayPaymentDetails")) {
                     $GLOBALS['ExtraInfo'] = $provider->DisplayPaymentDetails($row);
                 }
             }
             $GLOBALS['PaymentMethod'][] = $row['orderpaymentmethod'];
         }
         if ($row['ordstorecreditamount'] > 0) {
             $GLOBALS['PaymentMethod'][] = GetLang('PaymentStoreCredit') . " (" . FormatPriceInCurrency($row['ordstorecreditamount'], $row['orddefaultcurrencyid']) . ")";
         }
         if ($row['ordgiftcertificateamount'] > 0 && gzte11(ISC_LARGEPRINT)) {
             $GLOBALS['PaymentMethod'][] = sprintf(GetLang('PaymentGiftCertificates'), $row['orderid']) . " (" . FormatPriceInCurrency($row['ordgiftcertificateamount'], $row['orddefaultcurrencyid']) . ")";
         }
         $GLOBALS['IPAddress'] = $row['ordipaddress'];
         $GLOBALS['PaymentMethod'] = implode("<br />", $GLOBALS['PaymentMethod']);
         $GLOBALS['HideShippingZone'] = 'display: none';
         if ($row['ordpayproviderid'] != '') {
             $GLOBALS['TransactionId'] = $row['ordpayproviderid'];
         } else {
             $GLOBALS['TransactionId'] = GetLang('NA');
             $GLOBALS['HideTransactionId'] = 'display: none';
         }
         $extraArray = @unserialize($row['extrainfo']);
         $paymentMessage = '';
         if (isset($extraArray['payment_message']) && $extraArray['payment_message'] != '') {
             $paymentMessage = "<br />" . isc_html_escape($extraArray['payment_message']);
         }
         if (isset($row['ordpaymentstatus']) && $row['ordpaymentstatus'] != '') {
             $GLOBALS['PaymentStatus'] = ucfirst($row['ordpaymentstatus']) . $paymentMessage;
         } else {
             $GLOBALS['PaymentStatus'] = GetLang('NA');
             if ($paymentMessage) {
                 $GLOBALS['PaymentStatus'] .= $paymentMessage;
             } else {
                 $GLOBALS['HidePaymentStatus'] = 'display: none';
             }
         }
         $GLOBALS['CouponsUsed'] = '';
         $GLOBALS['HideCouponsUsed'] = 'display: none';
         // Get the products in the order
         $query = "SELECT o.*\n\t\t\t\t\tFROM [|PREFIX|]order_coupons o\n\t\t\t\t\tWHERE ordcouporderid='" . $orderId . "'";
         $coupons = $GLOBALS['ISC_CLASS_DB']->Query($query);
         while ($coupon = $GLOBALS['ISC_CLASS_DB']->Fetch($coupons)) {
             $GLOBALS['CouponsUsed'] .= $coupon['ordcouponcode'] . ',';
             $GLOBALS['HideCouponsUsed'] = '';
         }
         // If it's a digital order then we don't need to show the shipping details
         if ($row['ordisdigital'] == 0) {
             $addressDetails = array('shipfirstname' => $row['ordshipfirstname'], 'shiplastname' => $row['ordshiplastname'], 'shipcompany' => $row['ordshipcompany'], 'shipaddress1' => $row['ordshipstreet1'], 'shipaddress2' => $row['ordshipstreet2'], 'shipcity' => $row['ordshipsuburb'], 'shipstate' => $row['ordshipstate'], 'shipzip' => $row['ordshipzip'], 'shipcountry' => $row['ordshipcountry'], 'countrycode' => $row['ordshipcountrycode']);
             $GLOBALS['ShippingAddress'] = ISC_ADMIN_ORDERS::BuildOrderAddressDetails($addressDetails);
             if ($row['ordshipmethod'] != "") {
                 $GLOBALS['ShippingMethod'] = isc_html_escape($row['ordshipmethod']);
             } else {
                 $GLOBALS['ShippingMethod'] = GetLang('NA');
             }
             if ($row['ordshippingzoneid'] != 0) {
                 $GLOBALS['HideShippingZone'] = '';
                 if ($row['shippingzonename']) {
                     $GLOBALS['ShippingZone'] = "<a href=\"index.php?ToDo=editShippingZone&amp;zoneId=" . $row['ordshippingzoneid'] . "\">" . isc_html_escape($row['shippingzonename']) . "</a>";
                     $GLOBALS['ShippingZoneNoLink'] = isc_html_escape($row['shippingzonename']);
                 } else {
                     $GLOBALS['ShippingZone'] = isc_html_escape($row['shippingzonename']);
                 }
             }
             $GLOBALS['ShippingCost'] = FormatPriceInCurrency($row['ordshipcost'], $row['orddefaultcurrencyid']);
         } else {
             $GLOBALS['HideShippingPanel'] = "none";
         }
         $GLOBALS['HideVendor'] = 'display: none';
         if (gzte11(ISC_HUGEPRINT) && $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId() == 0 && $row['ordvendorid'] > 0) {
             $GLOBALS['HideVendor'] = '';
             $vendorCache = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('Vendors');
             if (isset($vendorCache[$row['ordvendorid']])) {
                 $vendor = $vendorCache[$row['ordvendorid']];
                 $GLOBALS['VendorName'] = isc_html_escape($vendor['vendorname']);
                 $GLOBALS['VendorId'] = $vendor['vendorid'];
                 $GLOBALS['HideVendor'] = '';
             }
         }
         $prodFieldsArray = $GLOBALS['ISC_CLASS_ADMIN_ORDERS']->GetOrderProductFieldsData($orderId);
         // Get the products in the order
         $query = "\n\t\t\t\t\tSELECT o.*, p.prodname\n\t\t\t\t\tFROM [|PREFIX|]order_products o\n\t\t\t\t\tLEFT JOIN [|PREFIX|]products p ON (p.productid=o.ordprodid)\n\t\t\t\t\tWHERE orderorderid='" . $orderId . "'\n\t\t\t\t\tORDER BY ordprodname";
         $pResult = $GLOBALS['ISC_CLASS_DB']->Query($query);
         $GLOBALS['ProductsTable'] = "<table width=\"95%\" align=\"center\" border=\"0\" cellspacing=0 cellpadding=0>";
         // Add a notice about the order containing only digitally downloadable products
         if ($row['ordisdigital'] == 1) {
             $GLOBALS['ProductsTable'] .= sprintf("\n\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td style=\"padding:5px; background-color:lightyellow\" width=\"100%%\" class=\"text\" colspan=\"2\">\n\t\t\t\t\t\t\t\t%s\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td colspan=\"2\">&nbsp;</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t", GetLang('DigitalOrderNotice'));
         }
         $wrappingTotal = 0;
         while ($pRow = $GLOBALS['ISC_CLASS_DB']->Fetch($pResult)) {
             $sku = "";
             if ($pRow['ordprodsku'] != "") {
                 $sku = "<br /><em>" . isc_html_escape($pRow['ordprodsku']) . "</em>";
             }
             $sStart = $sEnd = '';
             $refunded = '';
             $shippedLabel = '';
             if ($pRow['ordprodqtyshipped'] > 0) {
                 $shippedLabel = '<div class="Shipped">' . sprintf(GetLang('OrderProductsShippedX'), $pRow['ordprodqtyshipped']) . '</div>';
             }
             if ($pRow['ordprodrefunded'] > 0) {
                 if ($pRow['ordprodrefunded'] == $pRow['ordprodqty']) {
                     $sStart = "<del>";
                     $sEnd = "</del>";
                     $refunded = '<div class="Refunded">' . GetLang('OrderProductRefunded') . '</span>';
                 } else {
                     $refunded = '<div class="Refunded">' . sprintf(GetLang('OrderProductsRefundedX'), $pRow['ordprodrefunded']) . '</div>';
                 }
                 $cost = $pRow['ordprodcost'] * ($pRow['ordprodqty'] - $pRow['ordprodrefunded']);
             } else {
                 $cost = $pRow['ordprodcost'] * $pRow['ordprodqty'];
             }
             if ($pRow['prodname']) {
                 $pRow['ordprodname'] = "<a href='" . ProdLink($pRow['prodname']) . "' target='_blank'>" . isc_html_escape($pRow['ordprodname']) . "</a>";
             }
             $pOptions = '';
             if ($pRow['ordprodoptions'] != '') {
                 $options = @unserialize($pRow['ordprodoptions']);
                 if (!empty($options)) {
                     $pOptions = "<blockquote style=\"padding-left: 10px; margin: 0;\">";
                     $comma = '';
                     foreach ($options as $name => $value) {
                         $pOptions .= $comma . isc_html_escape($name) . ": " . isc_html_escape($value);
                         $comma = '<br />';
                     }
                     $pOptions .= "</blockquote>";
                 }
             }
             if ($pRow['ordprodwrapcost'] > 0) {
                 $wrappingTotal += $pRow['ordprodwrapcost'] * $pRow['ordprodqty'];
             }
             $giftOptions = '';
             if ($pRow['ordprodwrapname']) {
                 $giftOptions .= "<tr><td height='18' class='QuickGiftWrapping text' colspan='2'><div>";
                 $giftOptions .= GetLang('GiftWrapping') . ": " . isc_html_escape($pRow['ordprodwrapname']);
                 $giftOptions .= " [<a href='#' onclick=\"\$.iModal({type: 'ajax', url: 'remote.php?remoteSection=orders&w=viewGiftWrappingDetails&orderprodid=" . $pRow['orderprodid'] . "'}); return false;\">" . GetLang('ViewDetails') . "</a>]";
                 $giftOptions .= "</div></td></tr>";
             }
             $prodFields = '';
             if (isset($prodFieldsArray[$pRow['orderprodid']])) {
                 $prodFields = $this->GetOrderProductsFieldsRow($prodFieldsArray[$pRow['orderprodid']]);
             }
             $eventDate = '';
             if ($pRow['ordprodeventdate'] != null) {
                 $eventDate = '<tr><td style="padding:5px 0px 5px 15px;">' . $pRow['ordprodeventname'] . ': ' . isc_date('jS M Y', $pRow['ordprodeventdate']) . '</tr>';
             }
             $itemDetails = '';
             if ($shippedLabel || $refunded) {
                 $itemDetails = "<tr><td class='text' colspan='2' style='padding-left: 20px;'>";
                 $itemDetails .= $shippedLabel . $refunded;
                 $itemDetails .= '</td></tr>';
             }
             $GLOBALS['ProductsTable'] .= "\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td style=\"padding-left:12px; padding-top:5px\" width=\"70%\" class=\"text\">" . $sStart . $pRow['ordprodqty'] . " x " . $pRow['ordprodname'] . $sEnd . $sku . $pOptions . "</td>\n\t\t\t\t\t\t\t<td class=\"text\" width=\"30%%\" align=\"right\">" . FormatPriceInCurrency($cost, $row['orddefaultcurrencyid']) . "</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t" . $giftOptions . $eventDate . $prodFields . $itemDetails . "\n\t\t\t\t\t";
         }
         $GLOBALS['ProductsTable'] .= "<tr><td colspan='2'><hr noshade size='1'></td></tr>";
         $GLOBALS['ProductsTable'] .= sprintf("<tr><td height='18' class='text' align='right'>%s:</td><td class='text' align='right'>%s</td></tr>", GetLang('SubTotal'), FormatPriceInCurrency($row['ordsubtotal'], $row['orddefaultcurrencyid']));
         if ($wrappingTotal > 0) {
             $GLOBALS['ProductsTable'] .= sprintf("<tr><td height='18' class='text' align='right'>%s:</td><td class='text' align='right'>%s</td></tr>", GetLang('GiftWrapping'), FormatPriceInCurrency($wrappingTotal, $row['orddefaultcurrencyid']));
         }
         // Do we need to show a shipping cost?
         if ($row['ordshipmethod'] != "" && $row['ordshipcost'] > 0) {
             $GLOBALS['ProductsTable'] .= sprintf("<tr><td height='18' class='text' align='right'>%s:</td><td class='text' align='right'>%s</td></tr>", GetLang('Shipping'), FormatPriceInCurrency($row['ordshipcost'], $row['orddefaultcurrencyid']));
         }
         // Do we need to show a handling fee?
         if ($row['ordhandlingcost'] > 0) {
             $GLOBALS['ProductsTable'] .= sprintf("<tr><td height='18' class='text' align='right'>%s:</td><td class='text' align='right'>%s</td></tr>", GetLang('Handling'), FormatPriceInCurrency($row['ordhandlingcost'], $row['orddefaultcurrencyid']));
         }
         if ($row['orddateshipped'] > 0) {
             $GLOBALS['ShippingDate'] = isc_date(GetConfig('DisplayDateFormat'), $row['orddateshipped']);
         } else {
             $GLOBALS['ShippingDate'] = GetLang('NA');
         }
         // Do we need to show sales tax?
         if ($row['ordtaxtotal'] > 0 && $row['ordtotalincludestax'] == 0) {
             if ($row['ordtaxname']) {
                 $taxName = isc_html_escape($row['ordtaxname']);
             } else {
                 $taxName = GetLang('SalesTax');
             }
             $GLOBALS['ProductsTable'] .= sprintf("<tr><td height='18' class='text' align='right'>%s:</td><td class='text' align='right'>%s</td></tr>", $taxName, FormatPriceInCurrency($row['ordtaxtotal'], $row['orddefaultcurrencyid']));
         }
         $GLOBALS['ProductsTable'] .= sprintf("<tr><td height='18' class='QuickTotal text' align='right'>%s:</td><td class='QuickTotal text' align='right'>%s</td></tr>", GetLang('Total'), FormatPriceInCurrency($row['ordtotalamount'], $row['orddefaultcurrencyid']));
         // Do we need to show sales tax that was already included in the totals? We show it after the order total
         if ($row['ordtaxtotal'] > 0 && $row['ordtotalincludestax'] == 1) {
             if ($row['ordtaxname']) {
                 $taxName = isc_html_escape($row['ordtaxname']);
             } else {
                 $taxName = GetLang('SalesTax');
             }
             $taxName .= ' ' . GetLang('IncludedInTotal');
             $GLOBALS['ProductsTable'] .= sprintf("<tr><td height='18' class='text' align='right'>%s:</td><td class='text' align='right'>%s</td></tr>", $taxName, FormatPrice($row['ordtaxtotal']));
         }
         if (isset($row['ordpaymentstatus'])) {
             if ($row['ordpaymentstatus'] == 'refunded' || $row['ordpaymentstatus'] == 'partially refunded') {
                 $GLOBALS['ProductsTable'] .= '<tr><td class="text" align="right" height="18">' . GetLang('Refunded') . ':</td><td class="text" align="right">' . FormatPriceInCurrency($row['ordrefundedamount'], $row['orddefaultcurrencyid']) . '</td></tr>';
             }
         }
         $GLOBALS['ProductsTable'] .= "</table>";
         $GLOBALS['OrderComments'] = '';
         if (trim($row['ordcustmessage']) != '') {
             $GLOBALS['OrderComments'] = nl2br(isc_html_escape($row['ordcustmessage']));
         } else {
             $GLOBALS['HideOrderComments'] = 'display: none';
         }
         /**
          * Order form field
          */
         $GLOBALS['HideBillingFormFields'] = '';
         $GLOBALS['HideShippingFormFields'] = '';
         $GLOBALS['BillingFormFields'] = '';
         $GLOBALS['ShippingFormFields'] = '';
         $billingFields = array();
         $shippingFields = array();
         if (gzte11(ISC_MEDIUMPRINT) && isId($row['ordformsessionid'])) {
             $billingFields = $GLOBALS['ISC_CLASS_FORM']->getSavedSessionData($row['ordformsessionid'], array(), FORMFIELDS_FORM_BILLING, true);
             $shippingFields = $GLOBALS['ISC_CLASS_FORM']->getSavedSessionData($row['ordformsessionid'], array(), FORMFIELDS_FORM_SHIPPING, true);
         }
         /**
          * Do we have the correct version?
          */
         if (!gzte11(ISC_MEDIUMPRINT)) {
             $GLOBALS['HideBillingFormFields'] = 'none';
             $GLOBALS['HideShippingFormFields'] = 'none';
             /**
              * OK, we're allow to
              */
         } else {
             /**
              * Lets do the billing first. Do we have any?
              */
             if (empty($billingFields)) {
                 $GLOBALS['HideBillingFormFields'] = 'none';
             } else {
                 $GLOBALS['BillingFormFields'] = $this->buildOrderFormFields($billingFields);
             }
             /**
              * Now the shipping
              */
             if (empty($billingFields)) {
                 $GLOBALS['HideShippingFormFields'] = 'none';
             } else {
                 $GLOBALS['ShippingFormFields'] = $this->buildOrderFormFields($shippingFields);
             }
         }
         $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("order.quickview");
         $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate();
     } else {
         echo GetLang('OrderDetailsNotFound');
     }
 }
Example #3
0
 /**
  * Generate the 'Quick View' for a particular shipment.
  *
  * @param int The shipment ID.
  * @return string The generated quick view for the shipment.
  */
 public function GetShipmentQuickView($shipmentId)
 {
     $shipment = $this->GetShipmentById($shipmentId);
     // Invalid shipment, just return
     if (!isset($shipment['shipmentid'])) {
         return GetLang('ShipmentNotFound');
     }
     // If this user is a vendor, do they have permission to acess this shipment?
     if ($GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId() && $row['shipvendorid'] != $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId()) {
         exit;
     }
     $GLOBALS['ShipmentId'] = $shipment['shipmentid'];
     $GLOBALS['ShipmentDate'] = isc_date("d M Y H:i:s", $shipment['shipdate']);
     $GLOBALS['OrderId'] = $shipment['shiporderid'];
     $GLOBALS['OrderDate'] = isc_date("d M Y H:i:s", $shipment['shiporderdate']);
     $GLOBALS['TrackingNo'] = isc_html_escape($shipment['shiptrackno']);
     if (!$GLOBALS['TrackingNo']) {
         $GLOBALS['TrackingNo'] = GetLang('NA');
     }
     $GLOBALS['ShippingMethod'] = isc_html_escape($shipment['shipmethod']);
     // Build the billing address that was sent with this shipment
     $addressDetails = array('shipfirstname' => $shipment['shipbillfirstname'], 'shiplastname' => $shipment['shipbilllastname'], 'shipcompany' => $shipment['shipbillcompany'], 'shipaddress1' => $shipment['shipbillstreet1'], 'shipaddress2' => $shipment['shipbillstreet2'], 'shipcity' => $shipment['shipbillsuburb'], 'shipstate' => $shipment['shipbillstate'], 'shipzip' => $shipment['shipbillzip'], 'shipcountry' => $shipment['shipbillcountry'], 'countrycode' => $shipment['shipbillcountrycode']);
     $GLOBALS['BillingAddress'] = ISC_ADMIN_ORDERS::BuildOrderAddressDetails($addressDetails);
     $GLOBALS['BillingEmail'] = GetLang('NA');
     if ($shipment['shipbillemail']) {
         $GLOBALS['BillingEmail'] = '<a href="mailto:' . urlencode($shipment['shipbillemail']) . '">' . isc_html_escape($shipment['shipbillemail']) . '</a>';
     }
     $GLOBALS['BillingPhone'] = GetLang('NA');
     if ($shipment['shipbillphone']) {
         $GLOBALS['BillingPhone'] = isc_html_escape($shipment['shipbillphone']);
     }
     $addressDetails = array('shipfirstname' => $shipment['shipshipfirstname'], 'shiplastname' => $shipment['shipshiplastname'], 'shipcompany' => $shipment['shipshipcompany'], 'shipaddress1' => $shipment['shipshipstreet1'], 'shipaddress2' => $shipment['shipshipstreet2'], 'shipcity' => $shipment['shipshipsuburb'], 'shipstate' => $shipment['shipshipstate'], 'shipzip' => $shipment['shipshipzip'], 'shipcountry' => $shipment['shipshipcountry'], 'countrycode' => $shipment['shipshipcountrycode']);
     $GLOBALS['ShippingAddress'] = ISC_ADMIN_ORDERS::BuildOrderAddressDetails($addressDetails);
     $GLOBALS['ShippingEmail'] = GetLang('NA');
     if ($shipment['shipshipemail']) {
         $GLOBALS['ShippingEmail'] = '<a href="mailto:' . urlencode($shipment['shipshipemail']) . '">' . isc_html_escape($shipment['shipshipemail']) . '</a>';
     }
     $GLOBALS['ShippingPhone'] = GetLang('NA');
     if ($shipment['shipshipphone']) {
         $GLOBALS['ShippingPhone'] = isc_html_escape($shipment['shipshipphone']);
     }
     $GLOBALS['HideVendor'] = 'display: none';
     if (gzte11(ISC_HUGEPRINT) && $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId() == 0 && $shipment['shipvendorid'] > 0) {
         $GLOBALS['HideVendor'] = '';
         $vendorCache = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('Vendors');
         if (isset($vendorCache[$shipment['shipvendorid']])) {
             $vendor = $vendorCache[$shipment['shipvendorid']];
             $GLOBALS['VendorName'] = isc_html_escape($vendor['vendorname']);
             $GLOBALS['VendorId'] = $vendor['vendorid'];
             $GLOBALS['HideVendor'] = '';
         }
     }
     // Grab all of the products in the shipment
     $GLOBALS['ProductsTable'] = "<table width=\"95%\" align=\"center\" border=\"0\" cellspacing=0 cellpadding=0>";
     $query = "\n\t\t\tSELECT s.*, p.prodname\n\t\t\tFROM [|PREFIX|]shipment_items s\n\t\t\tLEFT JOIN [|PREFIX|]products p ON (p.productid=s.itemprodid)\n\t\t\tWHERE shipid='" . (int) $shipment['shipmentid'] . "'\n\t\t\tORDER BY itemprodname\n\t\t";
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     while ($product = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         $GLOBALS['ProductSKU'] = '';
         if ($product['itemprodsku']) {
             $GLOBALS['ProductSKU'] = "<br /><em>" . isc_html_escape($product['itemprodsku']) . "</em>";
         }
         if ($product['prodname']) {
             $product['itemprodname'] = "<a href='" . ProdLink($product['prodname']) . "' target='_blank'>" . isc_html_escape($product['itemprodname']) . "</a>";
         } else {
             $product['itemprodname'] = isc_html_escape($product['itemprodname']);
         }
         $GLOBALS['ProductName'] = $product['itemprodname'];
         $GLOBALS['ProductOptions'] = '';
         if ($product['itemprodoptions'] != '') {
             $options = @unserialize($product['itemprodoptions']);
             if (!empty($options)) {
                 $GLOBALS['ProductOptions'] = "<blockquote style=\"padding-left: 10px; margin: 0;\">";
                 $comma = '';
                 foreach ($options as $name => $value) {
                     $GLOBALS['ProductOptions'] .= $comma . isc_html_escape($name) . ": " . isc_html_escape($value);
                     $comma = '<br />';
                 }
                 $GLOBALS['ProductOptions'] .= "</blockquote>";
             }
         }
         $GLOBALS['EventDate'] = '';
         if ($product['itemprodeventdate'] != null) {
             $GLOBALS['EventDate'] = '<tr><td style="padding:5px 0px 5px 15px; font-style:italic">(' . $product['itemprodeventname'] . ': ' . isc_date('jS M Y', $product['itemprodeventdate']) . ')</tr>';
         }
         $GLOBALS['ProductQty'] = $product['itemqty'];
         $GLOBALS['ProductsTable'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('ShipmentQuickViewItem');
     }
     $GLOBALS['ShipmentComments'] = '';
     if (trim($shipment['shipcomments']) != '') {
         $GLOBALS['ShipmentComments'] = nl2br(isc_html_escape($shipment['shipcomments']));
     } else {
         $GLOBALS['HideShipmentComments'] = 'display: none';
     }
     $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate('shipments.quickview');
     return $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate(true);
 }