Example #1
0
	public function __construct($customerId = null)
	{
		// use the same settings as orders by default
		$this->setDoubleOptIn(GetConfig('EmailIntegrationOrderDoubleOptin'));
		$this->setSendWelcome(GetConfig('EmailIntegrationOrderSendWelcome'));

		if (!$customerId) {
			return;
		}

		$entity = new ISC_ENTITY_CUSTOMER();

		$data = $entity->get($customerId);
		if (!$data) {
			throw new Interspire_EmailIntegration_Subscription_Exception();
		}

		unset($data['custpassword']);

		$this->_data = $data;
		unset($data);

		$this->setSubscriptionIP($this->_data['custregipaddress']);

		// customer custom form fields

		/** @var ISC_FORM */
		$form = $GLOBALS["ISC_CLASS_FORM"];

		// populate empty form fields as a starting point -- this makes exports of imported customers work OK because they may not have a custformsessionid, or this ensures that export data is current with configured form fields even if the stored form fields are out of date
		$formFields = $form->getFormFields(FORMFIELDS_FORM_ACCOUNT);
		foreach ($formFields as /** @var ISC_FORMFIELD_BASE */$formField) {
			if ($formField->getFieldPrivateId()) {
				continue;
			}
			$this->_data[$formField->getFieldId()] = '';
		}

		// load saved data for this customer
		if (isId($this->_data['custformsessionid'])) {
			$customFields = $form->getSavedSessionData($this->_data['custformsessionid']);
			foreach ($customFields as $fieldId => $value) {
				$this->_data['FormField_' . $fieldId] = $value;
			}
		}

		// for email integration purposes, money values must be stored in an array as both numeric and formatted to allow for translation to both number fields and text fields, while maintaining currency information
		SetupCurrency();
		$moneyFields = array('custstorecredit');
		foreach ($moneyFields as $moneyFieldId) {
			$this->_data[$moneyFieldId] = array(
				'numeric' => $this->_data[$moneyFieldId],
				'formatted' => FormatPriceInCurrency($this->_data[$moneyFieldId]),
			);
		}

		unset($this->_data['addresses']); // the addresses provided by entity class are mixed billing/shipping addresses, can't be sure so discard them
		// find last used _billing_ address for this customer by non-deleted orders
		$order = $GLOBALS['ISC_CLASS_DB']->FetchRow("SELECT ordformsessionid, ordbillstreet1, ordbillstreet2, ordbillsuburb, ordbillstate, ordbillzip, ordbillcountryid FROM `[|PREFIX|]orders` WHERE ordcustid = " . (int)$customerId . " AND deleted = 0 ORDER BY orddate DESC LIMIT 1");
		if (is_array($order)) {
			// create fields specifically for email integration based on customer data

			if (isId($order['ordformsessionid'])) {
				$customFields = $form->getSavedSessionData($order['ordformsessionid']);
				foreach ($customFields as $fieldId => $value) {
					$this->_data['CustomerSubscription_Address_FormField_' . $fieldId] = $value;
				}
			}

			$this->_data['CustomerSubscription_Address'] = array(
				'addr1' => $order['ordbillstreet1'],
				'addr2' => $order['ordbillstreet2'],
				'city' => $order['ordbillsuburb'],
				'state' => $order['ordbillstate'],
				'zip' => $order['ordbillzip'],
				'country' => GetCountryById($order['ordbillcountryid']),
				'countryiso2' => GetCountryISO2ById($order['ordbillcountryid']),
				'countryiso3' => GetCountryISO3ById($order['ordbillcountryid']),
			);

			$this->_data['CustomerSubscription_Address_address1'] = $this->_data['CustomerSubscription_Address']['addr1'];
			$this->_data['CustomerSubscription_Address_address2'] = $this->_data['CustomerSubscription_Address']['addr2'];
			$this->_data['CustomerSubscription_Address_city'] = $this->_data['CustomerSubscription_Address']['city'];
			$this->_data['CustomerSubscription_Address_state'] = $this->_data['CustomerSubscription_Address']['state'];
			$this->_data['CustomerSubscription_Address_zip'] = $this->_data['CustomerSubscription_Address']['zip'];
			$this->_data['CustomerSubscription_Address_country'] = $this->_data['CustomerSubscription_Address']['country'];
			$this->_data['CustomerSubscription_Address_countryiso2'] = $this->_data['CustomerSubscription_Address']['countryiso2'];
			$this->_data['CustomerSubscription_Address_countryiso3'] = $this->_data['CustomerSubscription_Address']['countryiso3'];
		}

		// transform customer group data if available
		if ($this->_data['customergroup']) {
			$this->_data['customergroupid'] = $this->_data['customergroup']['customergroupid'];
			$this->_data['groupname'] = $this->_data['customergroup']['groupname'];
		}
		else
		{
			$this->_data['customergroupid'] = '';
			$this->_data['groupname'] = '';
		}
		unset($this->_data['customergroup']);
	}
 /**
  * Applies formatting to values such as price, date and text formats
  *
  * @param array The row of data to format
  * @param array Optional subset of fields to use when performing formatting. Defaults to the entire loaded field array.
  */
 protected function FormatColumns(&$row, $fields = array())
 {
     if (!count($fields)) {
         $fields = $this->fields;
     }
     foreach ($row as $column => $value) {
         if (!isset($fields[$column])) {
             continue;
         }
         $field = $fields[$column];
         // format the value if required
         if (isset($field['format'])) {
             $format = $field['format'];
             if ($format == "number") {
                 if ($this->template['priceformat'] == "formatted") {
                     $row[$column] = FormatPriceInCurrency($value);
                 } else {
                     $row[$column] = FormatPrice($value, false, false, true);
                 }
             } elseif ($format == "date") {
                 if ($value != '0') {
                     $row[$column] = date($this->dateformat, $value);
                 } else {
                     $value = '';
                 }
             } elseif ($format == "text") {
                 // remove html tags and decode entities
                 //$decoded = html_entity_decode(strip_tags($value));
                 $decoded = $value;
                 // remove excess white space
                 $excess = preg_replace("/^(\\s+)/m", "", $decoded);
                 // replace new lines with spaces
                 $row[$column] = preg_replace("/([\\r\\n]+)/m", " ", $excess);
             } elseif ($format == "bool") {
                 $value = (bool) $value;
                 if ($this->blankforfalse && !$value) {
                     $row[$column] = "";
                 } else {
                     switch ($this->boolformat) {
                         case "onezero":
                             if ($value) {
                                 $row[$column] = "1";
                             } else {
                                 $row[$column] = "0";
                             }
                             break;
                         case "truefalse":
                             if ($value) {
                                 $row[$column] = GetLang("TrueLabel");
                             } else {
                                 $row[$column] = GetLang("FalseLabel");
                             }
                             break;
                         case "yesno":
                             if ($value) {
                                 $row[$column] = GetLang("YesLabel");
                             } else {
                                 $row[$column] = GetLang("NoLabel");
                             }
                             break;
                     }
                 }
             }
         }
     }
 }
 private function GetPriceFormats()
 {
     SetupCurrency();
     $currency = GetDefaultCurrency();
     $price = number_format(1543.987, $currency['currencydecimalplace'], $currency['currencydecimalstring'], '');
     $formats = array("number" => $price, "formatted" => FormatPriceInCurrency(1543.987));
     return $formats;
 }
 /**
  * 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 #5
0
 private function ManageOrdersGrid(&$numOrders)
 {
     // Show a list of products in a table
     $page = 0;
     $start = 0;
     $numPages = 0;
     $GLOBALS['OrderGrid'] = "";
     $GLOBALS['Nav'] = "";
     $GLOBALS['SmallNav'] = "";
     $catList = "";
     $max = 0;
     // Is this a custom search?
     if (isset($_GET['searchId'])) {
         $this->_customSearch = $GLOBALS['ISC_CLASS_ADMIN_CUSTOMSEARCH']->LoadSearch($_GET['searchId']);
         $_REQUEST = array_merge($_REQUEST, (array) $this->_customSearch['searchvars']);
         // Override custom search sort fields if we have a requested field
         if (isset($_GET['sortField'])) {
             $_REQUEST['sortField'] = $_GET['sortField'];
         }
         if (isset($_GET['sortOrder'])) {
             $_REQUEST['sortOrder'] = $_GET['sortOrder'];
         }
     } else {
         if (isset($_GET['searchQuery'])) {
             $GLOBALS['Query'] = $_GET['searchQuery'];
         }
     }
     if (isset($_REQUEST['sortOrder']) && $_REQUEST['sortOrder'] == "asc") {
         $sortOrder = "asc";
     } else {
         $sortOrder = "desc";
     }
     $validSortFields = array('orderid', 'custname', 'orddate', 'ordstatus', 'newmessages', 'ordtotalamount', 'ordoverview');
     if (isset($_REQUEST['sortField']) && in_array($_REQUEST['sortField'], $validSortFields)) {
         $sortField = $_REQUEST['sortField'];
         SaveDefaultSortField("ManageOrders", $_REQUEST['sortField'], $sortOrder);
     } else {
         list($sortField, $sortOrder) = GetDefaultSortField("ManageOrders", "orderid", $sortOrder);
     }
     if (isset($_GET['page'])) {
         $page = (int) $_GET['page'];
     } else {
         $page = 1;
     }
     // Build the pagination and sort URL
     $searchURL = '';
     foreach ($_GET as $k => $v) {
         if ($k == "sortField" || $k == "sortOrder" || $k == "page" || $k == "new" || $k == "ToDo" || $k == "SubmitButton1" || !$v) {
             continue;
         }
         $searchURL .= sprintf("&%s=%s", $k, urlencode($v));
     }
     $sortURL = sprintf("%s&amp;sortField=%s&amp;sortOrder=%s", $searchURL, $sortField, $sortOrder);
     $GLOBALS['SortURL'] = $sortURL;
     // Limit the number of orders returned
     if ($page == 1) {
         $start = 1;
     } else {
         $start = $page * ISC_ORDERS_PER_PAGE - (ISC_ORDERS_PER_PAGE - 1);
     }
     $start = $start - 1;
     // Get the results for the query
     $orderResult = $this->_GetOrderList($start, $sortField, $sortOrder, $numOrders);
     $numPages = ceil($numOrders / ISC_ORDERS_PER_PAGE);
     // Add the "(Page x of n)" label
     if ($numOrders > ISC_ORDERS_PER_PAGE) {
         $GLOBALS['Nav'] = sprintf("(%s %d of %d) &nbsp;&nbsp;&nbsp;", GetLang('Page'), $page, $numPages);
         //alandy_2012-3-28 add.
         if (isset($_REQUEST['orderOwner']) && $_REQUEST['orderOwner'] != '') {
             $GLOBALS['Nav'] .= BuildPagination($numOrders, ISC_ORDERS_PER_PAGE, $page, sprintf("index.php?ToDo=viewOrders%s&orderOwner=%s", $sortURL, $_REQUEST['orderOwner']));
         } else {
             $GLOBALS['Nav'] .= BuildPagination($numOrders, ISC_ORDERS_PER_PAGE, $page, sprintf("index.php?ToDo=viewOrders%s", $sortURL));
         }
     } else {
         $GLOBALS['Nav'] = "";
     }
     if (isset($_GET['searchQuery'])) {
         $query = $_GET['searchQuery'];
     } else {
         $query = "";
     }
     $GLOBALS['Nav'] = rtrim($GLOBALS['Nav'], ' |');
     $GLOBALS['SmallNav'] = rtrim($GLOBALS['SmallNav'], ' |');
     $GLOBALS['SearchQuery'] = $query;
     $GLOBALS['SortField'] = $sortField;
     $GLOBALS['SortOrder'] = $sortOrder;
     $sortLinks = array("Id" => "orderid", "Cust" => "custname", "Date" => "orddate", "Status" => "ordstatus", "Message" => "newmessages", "Total" => "ordtotalamount", "Review" => "ordoverview");
     BuildAdminSortingLinks($sortLinks, "index.php?ToDo=viewOrders&amp;" . $searchURL . "&amp;page=" . $page, $sortField, $sortOrder);
     // Workout the maximum size of the array
     $max = $start + ISC_ORDERS_PER_PAGE;
     if ($max > count($orderResult)) {
         $max = count($orderResult);
     }
     if (!gzte11(ISC_LARGEPRINT)) {
         $GLOBALS['HideOrderMessages'] = "none";
         $GLOBALS['CustomerNameSpan'] = 2;
     }
     // Display the orders
     while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($orderResult)) {
         $GLOBALS['OrderId'] = $row['orderid'];
         $GLOBALS['CustomerId'] = $row['ordcustid'];
         $GLOBALS['OrderId1'] = $row['orderid'];
         $GLOBALS['Customer'] = isc_html_escape($row['custname']);
         $GLOBALS['Date'] = isc_date(GetConfig('DisplayDateFormat'), $row['orddate']);
         $GLOBALS['OrderStatusOptions'] = $this->GetOrderStatusOptions($row['ordstatus']);
         $GLOBALS['Total'] = FormatPriceInCurrency($row['ordtotalamount'], $row['orddefaultcurrencyid'], null, true);
         $GLOBALS['GatewayTotal'] = FormatPriceInCurrency($row['ordgatewayamount'], $row['orddefaultcurrencyid'], null, true);
         $GLOBALS['TrackingNo'] = isc_html_escape($row['ordtrackingno']);
         $orderreview = '';
         switch ($row['ordoverview']) {
             case 0:
                 $orderreview = GetLang('OviewRequestNo');
                 break;
             case 1:
                 $orderreview = GetLang('OviewRequestYes');
                 break;
             case 2:
                 $orderreview = GetLang('OviewRequestSure');
                 break;
             default:
                 $orderreview = GetLang('OviewRequestNo');
                 break;
         }
         $GLOBALS['Review'] = $orderreview;
         // Look up the country for the IP address of this order
         if (gzte11(ISC_LARGEPRINT)) {
             $suspiciousOrder = false;
             $GLOBALS['FlagCellClass'] = $GLOBALS['FlagCellTitle'] = '';
             if ($row['ordgeoipcountrycode'] != '') {
                 $flag = strtolower($row['ordgeoipcountrycode']);
                 // If the GeoIP based country code and the billing country code don't match, we flag this order as a different colour
                 if (strtolower($row['ordgeoipcountrycode']) != strtolower($row['ordbillcountrycode'])) {
                     $GLOBALS['FlagCellClass'] = "Suspicious";
                     $suspiciousOrder = true;
                 }
                 $countryName = $row['ordgeoipcountry'];
             } else {
                 $flag = strtolower($row['ordbillcountrycode']);
                 $countryName = $row['ordbillcountry'];
                 $GLOBALS['FlagCellTitle'] = $row['ordbillcountry'];
             }
             // Do we have a country flag to show?
             if (file_exists(ISC_BASE_PATH . "/lib/flags/" . $flag . ".gif")) {
                 $flag = GetConfig('AppPath') . "/lib/flags/" . $flag . ".gif";
                 if ($suspiciousOrder == true) {
                     $title = sprintf(GetLang('OrderCountriesDontMatch'), $row['ordbillcountry'], $row['ordgeoipcountry']);
                     $GLOBALS['OrderCountryFlag'] = "<span onmouseout=\"HideQuickHelp(this);\" onmouseover=\"ShowQuickHelp(this, '" . GetLang('PossibleFraudulentOrder') . "', '" . $title . "');\"><img src=\"" . $flag . "\" alt='' /></span>";
                 } else {
                     $GLOBALS['OrderCountryFlag'] = "<img src=\"" . $flag . "\" alt='' title=\"" . $countryName . "\" />";
                 }
             } else {
                 $GLOBALS['OrderCountryFlag'] = '';
             }
         } else {
             $GLOBALS['HideCountry'] = "none";
         }
         // Workout the message link -- do they have permission to view order messages?
         $GLOBALS["HideMessages"] = "none";
         if ($GLOBALS['ISC_CLASS_ADMIN_AUTH']->HasPermission(AUTH_Order_Messages) && $row['ordcustid'] > 0) {
             $numMessages = GetLang('Messages');
             if ($row['nummessages'] == 1) {
                 $numMessages = GetLang('OrderMessage');
             }
             $newMessages = '0 ' . GetLang('NewText');
             if ($row['newmessages'] > 0) {
                 $newMessages = "<strong>" . $row['newmessages'] . " " . GetLang('NewText') . "</strong>";
             }
             $GLOBALS['MessageLink'] = sprintf("<a title='%s' class='Action' href='index.php?ToDo=viewOrderMessages&amp;ord\n\t\t\t\t\terId=%d'>%s %s</a><br />(%s)", GetLang('MessageOrder'), $row['orderid'], $row['nummessages'], $numMessages, $newMessages);
             if ($row["numunreadmessages"] > 0 && gzte11(ISC_LARGEPRINT)) {
                 $GLOBALS["HideMessages"] = "";
                 $GLOBALS["NumMessages"] = $row['numunreadmessages'];
             }
         } else {
             $GLOBALS['MessageLink'] = sprintf("<a class='Action' disabled>%s (0)</a>", GetLang('Messages'));
         }
         if (!gzte11(ISC_LARGEPRINT)) {
             $GLOBALS["HideMessages"] = "none";
         }
         // If the customer still exists, link to the customer page
         if (trim($row['custname']) != '') {
             $GLOBALS['CustomerLink'] = "<a href='index.php?ToDo=viewCustomers&amp;idFrom=" . $GLOBALS['CustomerId'] . "&idTo=" . $GLOBALS['CustomerId'] . "'>" . $GLOBALS['Customer'] . "</a>";
         } else {
             $GLOBALS['CustomerLink'] = $row['ordbillfirstname'] . ' ' . $row['ordbilllastname'];
         }
         if ($row['ordcustid'] == 0) {
             $GLOBALS['CustomerLink'] .= " <span style=\"color: gray;\">" . GetLang('GuestCheckoutCustomer') . "</span>";
         }
         // If the order has any notes, flag it
         if ($row['ordnotes'] != '') {
             $GLOBALS['HasNotesClass'] = 'HasNotes';
         } else {
             $GLOBALS['HasNotesClass'] = '';
         }
         // If the order has any shipable items, show the link to ship items
         $GLOBALS['ShipItemsLink'] = '';
         if (isset($row['ordtotalshipped']) && isset($row['ordtotalqty'])) {
             if ($row['ordisdigital'] == 0 && $row['ordtotalqty'] - $row['ordtotalshipped'] > 0) {
                 $GLOBALS['ShipItemsLink'] = '<option id="ShipItemsLink' . $row['orderid'] . '"  value="shipItems">' . GetLang('ShipItems') . '</option>';
             }
         }
         //Show payment status blow order status
         $GLOBALS['PaymentStatus'] = '';
         $GLOBALS['HidePaymentStatus'] = 'display:none;';
         $GLOBALS['PaymentStatusColor'] = '';
         if ($row['ordpaymentstatus'] != '') {
             $GLOBALS['HidePaymentStatus'] = '';
             $GLOBALS['PaymentStatusColor'] = '';
             switch ($row['ordpaymentstatus']) {
                 case 'authorized':
                     $GLOBALS['PaymentStatusColor'] = 'PaymentAuthorized';
                     break;
                 case 'captured':
                     $GLOBALS['PaymentStatus'] = GetLang('Payment') . " " . ucfirst($row['ordpaymentstatus']);
                     $GLOBALS['PaymentStatusColor'] = 'PaymentCaptured';
                     break;
                 case 'refunded':
                 case 'partially refunded':
                 case 'voided':
                     $GLOBALS['PaymentStatus'] = GetLang('Payment') . " " . ucwords($row['ordpaymentstatus']);
                     $GLOBALS['PaymentStatusColor'] = 'PaymentRefunded';
                     break;
             }
         }
         // If the allow payment delayed capture, show the link to Delayed capture
         $GLOBALS['DelayedCaptureLink'] = '';
         $GLOBALS['VoidLink'] = '';
         $GLOBALS['RefundLink'] = '';
         $transactionId = trim($row['ordpayproviderid']);
         //if orginal transaction id exist and payment provider is currently enabled
         if ($transactionId != '' && GetModuleById('checkout', $provider, $row['orderpaymentmodule']) && $provider->IsEnabled() && !gzte11(ISC_HUGEPRINT)) {
             //if the payment module allow delayed capture and the current payment status is authorized
             //display delay capture option
             if (method_exists($provider, "DelayedCapture") && $row['ordpaymentstatus'] == 'authorized') {
                 $GLOBALS['DelayedCaptureLink'] = '<option value="delayedCapture">' . GetLang('CaptureFunds') . '</option>';
                 $GLOBALS['PaymentStatus'] .= '<a onclick="Order.DelayedCapture(' . $row['orderid'] . '); return false;" href="#">' . GetLang('CaptureFunds') . '</a>';
             }
             //if the payment module allow void transaction and the current payment status is authorized
             //display void option
             if (method_exists($provider, "DoVoid") && $row['ordpaymentstatus'] == 'authorized') {
                 $GLOBALS['VoidLink'] = '<option value="voidTransaction">' . GetLang('VoidTransaction') . '</option>';
             }
             //if the payment module allow refund and the current payment status is authorized
             //display refund option
             if (method_exists($provider, "DoRefund") && ($row['ordpaymentstatus'] == 'captured' || $row['ordpaymentstatus'] == 'partially refunded')) {
                 $GLOBALS['RefundLink'] = '<option value="refundOrder">' . GetLang('Refund') . '</option>';
             }
         }
         $GLOBALS["OrderStatusText"] = GetOrderStatusById($row['ordstatus']);
         $GLOBALS['OrderStatusId'] = $row['ordstatus'];
         $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("order.manage.row");
         $GLOBALS['OrderGrid'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate(true);
     }
     // Close the GeoIP database if we used it
     if (isset($gi)) {
         geoip_close($gi);
     }
     // Hide the message box in templates/iphone/MessageBox.html if we're not searching
     if (!isset($_REQUEST["searchQuery"]) && isset($_REQUEST["page"])) {
         $GLOBALS["HideYellowMessage"] = "none";
     }
     $GLOBALS['CurrentPage'] = $page;
     $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("orders.manage.grid");
     return $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate(true);
 }
Example #6
0
 public function GetListRow($row)
 {
     $new_row['ID'] = $row['orderid'];
     $new_row['Customer'] = $row['custname'];
     $new_row['Date'] = isc_date(GetConfig('DisplayDateFormat'), $row['orddate']);
     if ($row['ordstatus'] == 0) {
         $new_row['Status'] = GetLang('Incomplete');
     } else {
         $new_row['Status'] = $row['ordstatustext'];
     }
     $new_row['Tracking No.'] = $row['ordtrackingno'];
     $new_row['Total'] = FormatPriceInCurrency($row['ordtotalamount'], $row['orddefaultcurrencyid'], null, true);
     return $new_row;
 }
Example #7
0
		protected function ManageOrdersGrid(&$numOrders, &$numDeletedOrders = 0)
		{
			// Show a list of products in a table
			$page = 0;
			$start = 0;
			$GLOBALS['OrderGrid'] = "";
			$catList = "";
			$max = 0;

			// Is this a custom search?
			if(isset($_GET['searchId'])) {
				// Override custom search sort fields if we have a requested field
				if(isset($_GET['sortField'])) {
					$_REQUEST['sortField'] = $_GET['sortField'];
				}
				if(isset($_GET['sortOrder'])) {
					$_REQUEST['sortOrder'] = $_GET['sortOrder'];
				}
			}

			if(isset($_GET['searchQuery'])) {
				$GLOBALS['QueryEscaped'] = isc_html_escape($_GET['searchQuery']);
			}

			if(isset($_REQUEST['sortOrder']) && $_REQUEST['sortOrder'] == "asc") {
				$sortOrder = "asc";
			}
			else {
				$sortOrder = "desc";
			}

			$validSortFields = array('orderid', 'custname', 'orddate', 'ordstatus', 'newmessages', 'total_inc_tax');
			if(isset($_REQUEST['sortField']) && in_array($_REQUEST['sortField'], $validSortFields)) {
				$sortField = $_REQUEST['sortField'];
				SaveDefaultSortField("ManageOrders", $_REQUEST['sortField'], $sortOrder);
			}
			else {
				list($sortField, $sortOrder) = GetDefaultSortField("ManageOrders", "orderid", $sortOrder);
			}

			if (isset($_GET['page'])) {
				$page = (int)$_GET['page'];
			} else {
				$page = 1;
			}

			if (isset($_GET['perpage'])) {
				$perPage = (int)$_GET['perpage'];
				SaveDefaultPerPage("ManageOrders", $perPage);
			}
			else {
				$perPage = GetDefaultPerPage("ManageOrders", ISC_ORDERS_PER_PAGE);
			}

			// Build the pagination and sort URL
			$searchURL = $_GET;
			unset($searchURL['sortField'], $searchURL['sortOrder'], $searchURL['page'], $searchURL['new'], $searchURL['ToDo'], $searchURL['SubmitButton1'], $searchURL['SearchButton_x'], $searchURL['SearchButton_y']);
			$searchURL['sortField'] = $sortField;
			$searchURL['sortOrder'] = $sortOrder;
			$this->template->assign('searchURL', $searchURL);

			$sortURL = $searchURL;
			unset($sortURL['sortField'], $sortURL['sortOrder']);

			// Limit the number of orders returned
			if ($page == 1) {
				$start = 1;
			} else {
				$start = ($page * $perPage) - ($perPage-1);
			}

			$start = $start-1;

			// Get the results for the query
			$orderResult = $this->_GetOrderList($start, $sortField, $sortOrder, $numOrders, $perPage, $numDeletedOrders);

			$GLOBALS['perPage'] = $perPage;
			$GLOBALS['numOrders'] = $numOrders;
			$GLOBALS['pageURL'] = "index.php?ToDo=viewOrders&" . http_build_query($searchURL);
			$GLOBALS['currentPage'] = $page;

			$this->template->assign('numDeletedOrders', $numDeletedOrders);

			if ($numOrders && $numDeletedOrders) {
				$searchGet = $_GET;
				if (isset($searchGet['searchId']) && $searchGet['searchId'] == 0) {
					unset($searchGet['searchId']);
				}

				if (count($searchGet) > 1) {
					$deletedUrl = $searchGet;
					$deletedUrl['searchDeletedOrders'] = 'only';
					$deletedUrl = 'index.php?' . http_build_query($deletedUrl);
					$this->template->assign('viewDeletedOrdersUrl', $deletedUrl);
					unset($deletedUrl);
				}
				unset($searchGet);
			}

			if(isset($_GET['searchQuery'])) {
				$query = $_GET['searchQuery'];
			} else {
				$query = "";
			}

			$GLOBALS['SearchQuery'] = $query;
			$GLOBALS['SortField'] = $sortField;
			$GLOBALS['SortOrder'] = $sortOrder;

			$sortLinks = array(
				"Id" => "orderid",
				"Cust" => "custname",
				"Date" => "orddate",
				"Status" => "ordstatus",
				"Message" => "newmessages",
				"Total" => "total_inc_tax"
			);
			BuildAdminSortingLinks($sortLinks, "index.php?ToDo=viewOrders&amp;".http_build_query($sortURL)."&amp;page=".$page, $sortField, $sortOrder);

			// Workout the maximum size of the array
			$max = $start + $perPage;

			if ($max > count($orderResult)) {
				$max = count($orderResult);
			}

			if(!gzte11(ISC_LARGEPRINT)) {
				$GLOBALS['HideOrderMessages'] = "none";
				$GLOBALS['CustomerNameSpan'] = 2;
			}

			// Display the orders
			while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($orderResult)) {
				$this->template->assign('order', $row);
				$GLOBALS['OrderId'] = $row['orderid'];
				$GLOBALS['CustomerId'] = $row['ordcustid'];
				$GLOBALS['OrderId1'] = $row['orderid'];
				$GLOBALS['Customer'] = isc_html_escape($row['custname']);

				$GLOBALS['Date'] = isc_date(GetConfig('DisplayDateFormat'), $row['orddate']);
				$GLOBALS['OrderStatusOptions'] = $this->GetOrderStatusOptions($row['ordstatus']);

				$GLOBALS['Total'] = FormatPriceInCurrency($row['total_inc_tax'], $row['orddefaultcurrencyid'], null, true);

				$GLOBALS['NotesIcon'] = "";
				$GLOBALS['CommentsIcon'] = "";

				// Look up the country for the IP address of this order
				if(gzte11(ISC_LARGEPRINT)) {
					$suspiciousOrder = false;
					$GLOBALS['FlagCellClass'] = $GLOBALS['FlagCellTitle'] = '';
					if($row['ordgeoipcountrycode'] != '') {
						$flag = strtolower($row['ordgeoipcountrycode']);
						// If the GeoIP based country code and the billing country code don't match, we flag this order as a different colour
						if(strtolower($row['ordgeoipcountrycode']) != strtolower($row['ordbillcountrycode'])) {
							$GLOBALS['FlagCellClass'] = "Suspicious";
							$suspiciousOrder = true;

						}
						$countryName = $row['ordgeoipcountry'];
					}
					else {
						$flag = strtolower($row['ordbillcountrycode']);
						$countryName = $row['ordbillcountry'];
						$GLOBALS['FlagCellTitle'] = $row['ordbillcountry'];
					}
					// Do we have a country flag to show?
					if(file_exists(ISC_BASE_PATH."/lib/flags/".$flag.".gif")) {
						$flag = GetConfig('AppPath')."/lib/flags/".$flag.".gif";
						if($suspiciousOrder == true) {
							$title = sprintf(GetLang('OrderCountriesDontMatch'), $row['ordbillcountry'], $row['ordgeoipcountry']);
							$GLOBALS['OrderCountryFlag'] = "<span onmouseout=\"HideQuickHelp(this);\" onmouseover=\"ShowQuickHelp(this, '".GetLang('PossibleFraudulentOrder')."', '".$title."');\"><img src=\"".$flag."\" alt='' /></span>";
						}
						else {
							$GLOBALS['OrderCountryFlag'] = "<img src=\"".$flag."\" alt='' title=\"".$countryName."\" />";
						}
					}
					else {
						$GLOBALS['OrderCountryFlag'] = '';
					}
				}
				else {
					$GLOBALS['HideCountry'] = "none";
				}

				// If this is ebay item, we will have the icon as eBay icon
				$GLOBALS['OrderIcon'] = 'order.gif';
				if ($row['ebay_order_id'] != '0') {
					$GLOBALS['OrderIcon'] = 'ebay.gif';
				}

				// Workout the message link -- do they have permission to view order messages?
				$GLOBALS["HideMessages"] = "none";

				if($GLOBALS['ISC_CLASS_ADMIN_AUTH']->HasPermission(AUTH_Order_Messages) && $row['ordcustid'] > 0) {
					$numMessages = GetLang('Messages');
					if($row['nummessages'] == 1) {
						$numMessages = GetLang('OrderMessage');
					}
					$newMessages = '0 '.GetLang('NewText');
					if($row['newmessages'] > 0) {
						$newMessages = "<strong>" . $row['newmessages'] . " " . GetLang('NewText') . "</strong>";
					}
					$GLOBALS['MessageLink'] = sprintf("<a title='%s' class='Action' href='index.php?ToDo=viewOrderMessages&amp;ord
					erId=%d'>%s %s</a><br />(%s)",
						GetLang('MessageOrder'),
						$row['orderid'],
						$row['nummessages'],
						$numMessages,
						$newMessages
					);

					if($row["numunreadmessages"] > 0 && gzte11(ISC_LARGEPRINT)) {
						$GLOBALS["HideMessages"] = "";
						$GLOBALS["NumMessages"] = $row['numunreadmessages'];
					}
				}
				else {
					$GLOBALS['MessageLink'] = sprintf("<a class='Action' disabled>%s (0)</a>", GetLang('Messages'));
				}

				if(!gzte11(ISC_LARGEPRINT)) {
					$GLOBALS["HideMessages"] = "none";
				}

				// If the customer still exists, link to the customer page
				if(trim($row['custname']) != '') {
					$GLOBALS['CustomerLink'] = "<a href='index.php?ToDo=viewCustomers&amp;idFrom=".$GLOBALS['CustomerId']."&idTo=".$GLOBALS['CustomerId']."'>".$GLOBALS['Customer']."</a>";
				}
				else {
					$GLOBALS['CustomerLink'] = $row['ordbillfirstname'].' '.$row['ordbilllastname'];
				}

				if($row['ordcustid'] == 0) {
					$GLOBALS['CustomerLink'] .= " <span style=\"color: gray;\">".GetLang('GuestCheckoutCustomer')."</span>";
				}

				// If the order has any notes, flag it
				if($row['ordnotes'] != '') {
					$GLOBALS['NotesIcon'] = '<a href="#" onclick="Order.HandleAction(' . $row['orderid'] . ', \'orderNotes\');"><img src="images/note.png" alt="" title="' . GetLang('OrderHasNotes') . '" style="border-style: none;" /></a>';
					$GLOBALS['HasNotesClass'] = 'HasNotes';
				}
				else {
					$GLOBALS['HasNotesClass'] = '';
				}

				// does the order have a customer message?
				if (!empty($row['ordcustmessage'])) {
					$GLOBALS['CommentsIcon'] = '<a href="#" onclick="Order.HandleAction(' . $row['orderid'] . ', \'orderNotes\');"><img src="images/user_comment.png" alt="" title="' . GetLang('OrderHasComments') . '" style="border-style: none;" /></a>';
				}

				// If the order has any shipable items, show the link to ship items
				$GLOBALS['ShipItemsLink'] = '';
				if (!$row['deleted'] && isset($row['ordtotalshipped']) && isset($row['ordtotalqty'])) {
					if($row['ordisdigital'] == 0 && ($row['ordtotalqty']-$row['ordtotalshipped']) > 0) {
						$addClass = '';
						if($row['shipping_address_count'] > 1) {
							$addClass = 'MultipleAddresses';
						}
						$GLOBALS['ShipItemsLink'] = '<option id="ShipItemsLink'.$row['orderid'].'"  value="shipItems'.$addClass.'">'.GetLang('ShipItems').'</option>';
					}
				}

				//Show payment status blow order status
				$GLOBALS['PaymentStatus'] = '';
				$GLOBALS['HidePaymentStatus'] = 'display:none;';
				$GLOBALS['PaymentStatusColor'] = '';
				if($row['ordpaymentstatus'] != '') {
					$GLOBALS['HidePaymentStatus'] = '';
					$GLOBALS['PaymentStatusColor'] = '';
					switch($row['ordpaymentstatus']) {
						case 'authorized':
							$GLOBALS['PaymentStatusColor'] = 'PaymentAuthorized';
							break;
						case 'captured':
							$GLOBALS['PaymentStatus'] = GetLang('Payment')." ".ucfirst($row['ordpaymentstatus']);
							$GLOBALS['PaymentStatusColor'] = 'PaymentCaptured';
							break;
						case 'refunded':
						case 'partially refunded':
						case 'voided':
							$GLOBALS['PaymentStatus'] = GetLang('Payment')." ".ucwords($row['ordpaymentstatus']);
							$GLOBALS['PaymentStatusColor'] = 'PaymentRefunded';
							break;
					}
				}


				// If the allow payment delayed capture, show the link to Delayed capture
				$GLOBALS['DelayedCaptureLink'] = '';
				$GLOBALS['VoidLink'] = '';
				$GLOBALS['RefundLink'] ='';
				$transactionId = trim($row['ordpayproviderid']);

				//if orginal transaction id exist and payment provider is currently enabled
				if($transactionId != '' && GetModuleById('checkout', $provider, $row['orderpaymentmodule']) && $provider->IsEnabled() && !gzte11(ISC_HUGEPRINT)) {
					//if the payment module allow delayed capture and the current payment status is authorized
					//display delay capture option
					if(method_exists($provider, "DelayedCapture") && $row['ordpaymentstatus'] == 'authorized') {
						$GLOBALS['DelayedCaptureLink'] = '<option value="delayedCapture">'.GetLang('CaptureFunds').'</option>';

						$GLOBALS['PaymentStatus'] .= '<a onclick="Order.DelayedCapture('.$row['orderid'].'); return false;" href="#">'.GetLang('CaptureFunds').'</a>';
					}

					//if the payment module allow void transaction and the current payment status is authorized
					//display void option
					if(method_exists($provider, "DoVoid") && $row['ordpaymentstatus'] == 'authorized') {
						$GLOBALS['VoidLink'] = '<option value="voidTransaction">'.GetLang('VoidTransaction').'</option>';
					}

					//if the payment module allow refund and the current payment status is authorized
					//display refund option
					if(method_exists($provider, "DoRefund") && ($row['ordpaymentstatus'] == 'captured' || $row['ordpaymentstatus'] == 'partially refunded')) {
						$GLOBALS['RefundLink'] = '<option value="refundOrder">'.GetLang('Refund').'</option>';
					}
				}

				$GLOBALS["OrderStatusText"] = GetOrderStatusById($row['ordstatus']);
				$GLOBALS['OrderStatusId'] = $row['ordstatus'];
				$GLOBALS['OrderGrid'] .= $this->template->render('order.manage.row.tpl');
			}

			// Close the GeoIP database if we used it
			if(isset($gi)) {
				geoip_close($gi);
			}

			// Hide the message box in templates/iphone/MessageBox.html if we're not searching
			if(!isset($_REQUEST["searchQuery"]) && isset($_REQUEST["page"])) {
				$GLOBALS["HideYellowMessage"] = "none";
			}

			$GLOBALS['CurrentPage'] = $page;

			return $this->template->render('orders.manage.grid.tpl');
		}
Example #8
0
 public function GetListRow($row)
 {
     $new_row['ID'] = $row['productid'];
     $new_row['SKU'] = $row['prodcode'];
     $new_row['Name'] = $row['prodname'];
     $new_row['Price'] = FormatPriceInCurrency($row['prodprice']);
     if ($row['prodvisible']) {
         $new_row['Visible'] = '<img src="images/tick.gif" alt="tick"/>';
     } else {
         $new_row['Visible'] = '<img src="images/cross.gif" alt="cross"/>';
     }
     if ($row['prodfeatured']) {
         $new_row['Featured'] = '<img src="images/tick.gif" alt="tick"/>';
     } else {
         $new_row['Featured'] = '<img src="images/cross.gif" alt="cross"/>';
     }
     return $new_row;
 }
Example #9
0
 /**
  *    Show how many times each product has been viewed
  */
 public function SalesStatsByNumViewsGrid()
 {
     $GLOBALS['OrderGrid'] = "";
     if (isset($_GET['From']) && isset($_GET['To'])) {
         $from_stamp = (int) $_GET['From'];
         $to_stamp = (int) $_GET['To'];
         // How many records per page?
         if (isset($_GET['Show'])) {
             $per_page = (int) $_GET['Show'];
         } else {
             $per_page = 20;
         }
         $cursortfield = '';
         if (isset($_GET['vendorId']) && $_GET['vendorId'] != '-1') {
             $cursortfield = " AND (orderowner='" . $_GET['vendorId'] . "')";
         }
         $GLOBALS['ProductsPerPage'] = $per_page;
         $GLOBALS["IsShowPerPage" . $per_page] = 'selected="selected"';
         // Should we limit the records returned?
         if (isset($_GET['Page'])) {
             $page = (int) $_GET['Page'];
         } else {
             $page = 1;
         }
         $GLOBALS['salesByNumViewsCurrentPage'] = $page;
         // Workout the start and end records
         $start = $per_page * $page - $per_page;
         $end = $start + ($per_page - 1);
         // How many products are there in total?
         $CountQuery = "\n        SELECT \n            count(*) AS num\n                FROM [|PREFIX|]orders o\n                    LEFT JOIN [|PREFIX|]customers c ON (o.ordcustid=c.customerid)\n                    LEFT JOIN [|PREFIX|]order_status s ON (s.statusid=o.ordstatus)\n                WHERE\n                    o.ordstatus > 0 \n                    AND o.orddate >= '" . $from_stamp . "'\n                    AND o.orddate <= '" . $to_stamp . "'" . $cursortfield;
         $result = $GLOBALS['ISC_CLASS_DB']->Query($CountQuery);
         $row = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
         $total_products = $row['num'];
         if ($total_products > 0) {
             //Sorting code goes by Simha
             if (isset($_GET['SortOrder']) && $_GET['SortOrder'] == "asc") {
                 $sortOrder = 'asc';
             } else {
                 $sortOrder = 'desc';
             }
             //changed field name and commented
             $sortFields = array('orderid', 'custname', 'orddate', 'ordstatus', 'ordtotalamount');
             //changed field name
             if (isset($_GET['SortBy']) && in_array($_GET['SortBy'], $sortFields)) {
                 $sortField = $_GET['SortBy'];
                 SaveDefaultSortField("ProductStatsByViews", $_REQUEST['SortBy'], $sortOrder);
             } else {
                 list($sortField, $sortOrder) = GetDefaultSortField("ProductStatsByViews", "o.orderid", $sortOrder);
             }
             $sortLinks = array("OrderId" => "orderid", "Cusname" => "custname", "OrdDate" => "orddate", "Status" => "ordstatus", "Total" => "ordtotalamount");
             //Above comment and new addition belowby Simha
             //$sortLinks = array();
             $numSoldCounter = '921124412848294';
             BuildAdminSortingLinks($sortLinks, "javascript:SortSalesByNumViews('%%SORTFIELD%%', '%%SORTORDER%%');", $sortField, $sortOrder);
             //Sorting code goes ends by Simha
             // Workout the paging
             $num_pages = ceil($total_products / $per_page);
             // Should we limit the records returned?
             if (isset($_GET['Page']) && (int) $_GET['Page'] <= $num_pages) {
                 $page = (int) $_GET['Page'];
             } else {
                 $page = 1;
             }
             // Workout the start and end records
             $start = $per_page * $page - $per_page;
             $end = $start + ($per_page - 1);
             $paging = sprintf(GetLang('PageXOfX'), $page, $num_pages);
             $paging .= "&nbsp;&nbsp;&nbsp;&nbsp;";
             // Is there more than one page? If so show the &laquo; to jump back to page 1
             if ($num_pages > 1) {
                 $paging .= "<a href='javascript:void(0)' onclick='ChangeSalesViewsPage(1)'>&laquo;</a> | ";
             } else {
                 $paging .= "&laquo; | ";
             }
             // Are we on page 2 or above?
             if ($page > 1) {
                 $paging .= sprintf("<a href='javascript:void(0)' onclick='ChangeSalesViewsPage(%d)'>%s</a> | ", $page - 1, GetLang('Prev'));
             } else {
                 $paging .= sprintf("%s | ", GetLang('Prev'));
             }
             for ($i = 1; $i <= $num_pages; $i++) {
                 // Only output paging -5 and +5 pages from the page we're on
                 if ($i >= $page - 6 && $i <= $page + 5) {
                     if ($page == $i) {
                         $paging .= sprintf("<strong>%d</strong> | ", $i);
                     } else {
                         $paging .= sprintf("<a href='javascript:void(0)' onclick='ChangeSalesViewsPage(%d)'>%d</a> | ", $i, $i);
                     }
                 }
             }
             // Are we on page 2 or above?
             if ($page < $num_pages) {
                 $paging .= sprintf("<a href='javascript:void(0)' onclick='ChangeSalesViewsPage(%d)'>%s</a> | ", $page + 1, GetLang('Next'));
             } else {
                 $paging .= sprintf("%s | ", GetLang('Next'));
             }
             // Is there more than one page? If so show the &raquo; to go to the last page
             if ($num_pages > 1) {
                 $paging .= sprintf("<a href='javascript:void(0)' onclick='ChangeSalesViewsPage(%d)'>&raquo;</a> | ", $num_pages);
             } else {
                 $paging .= "&raquo; | ";
             }
             $paging = rtrim($paging, ' |');
             $GLOBALS['Paging'] = $paging;
             // Should we set focus to the grid?
             if (isset($_GET['FromLink']) && $_GET['FromLink'] == "true") {
                 $GLOBALS['JumpToOrdersByItemsSoldGrid'] = "<script type=\"text/javascript\">document.location.href='#ordersByItemsSoldAnchor';</script>";
             }
             //Sorting code moved to the topof this loop
             //Code here has been moved to the fucntion GetQueries
             // Add the Limit
             $mainQuery = "SELECT o.*, c.*,us.username, s.statusdesc AS ordstatustext, CONCAT(custconfirstname, ' ', custconlastname) AS custname\n                    \n                FROM [|PREFIX|]orders o\n                    LEFT JOIN [|PREFIX|]customers c ON (o.ordcustid=c.customerid)\n                    LEFT JOIN [|PREFIX|]order_status s ON (s.statusid=o.ordstatus)\n                    LEFT JOIN [|PREFIX|]users us ON us.`pk_userid` = o.orderowner \n                WHERE\n                    o.ordstatus > 0 \n                    AND o.orddate >= '" . $from_stamp . "'\n                    AND o.orddate <= '" . $to_stamp . "' {$cursortfield}   \n                ORDER BY " . $sortField . " " . $sortOrder;
             $mainQuery .= $GLOBALS['ISC_CLASS_DB']->AddLimit($start, $per_page);
             $result = $GLOBALS['ISC_CLASS_DB']->Query($mainQuery);
             if ($GLOBALS['ISC_CLASS_DB']->CountResult($result) > 0) {
                 while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
                     $GLOBALS['OrderId'] = $row['orderid'];
                     $GLOBALS['CustomerId'] = $row['ordcustid'];
                     $GLOBALS['OrderId1'] = $row['orderid'];
                     $GLOBALS['Customer'] = isc_html_escape($row['custname']);
                     $GLOBALS['Date'] = isc_date(GetConfig('DisplayDateFormat'), $row['orddate']);
                     $GLOBALS['OrderStatusOptions'] = $this->GetOrderStatusOptions($row['ordstatus']);
                     $GLOBALS['Total'] = FormatPriceInCurrency($row['ordtotalamount'], $row['orddefaultcurrencyid'], null, true);
                     $GLOBALS['TrackingNo'] = isc_html_escape($row['ordtrackingno']);
                     $GLOBALS['username'] = isc_html_escape($row['username']);
                     switch ($row['requeststatus']) {
                         case 0:
                             $orderreview = GetLang('OviewRequestNo');
                             break;
                         case 1:
                             $orderreview = GetLang('OviewRequestYes');
                             break;
                         case 2:
                             $orderreview = GetLang('OviewRequestSure');
                             break;
                         default:
                             $orderreview = GetLang('OviewRequestNo');
                             break;
                     }
                     $GLOBALS['Review'] = $orderreview;
                     //Show payment status blow order status
                     $GLOBALS['PaymentStatus'] = '';
                     $GLOBALS['HidePaymentStatus'] = 'display:none;';
                     $GLOBALS['PaymentStatusColor'] = '';
                     if ($row['ordpaymentstatus'] != '') {
                         $GLOBALS['HidePaymentStatus'] = '';
                         $GLOBALS['PaymentStatusColor'] = '';
                         switch ($row['ordpaymentstatus']) {
                             case 'authorized':
                                 $GLOBALS['PaymentStatusColor'] = 'PaymentAuthorized';
                                 break;
                             case 'captured':
                                 $GLOBALS['PaymentStatus'] = GetLang('Payment') . " " . ucfirst($row['ordpaymentstatus']);
                                 $GLOBALS['PaymentStatusColor'] = 'PaymentCaptured';
                                 break;
                             case 'refunded':
                             case 'partially refunded':
                             case 'voided':
                                 $GLOBALS['PaymentStatus'] = GetLang('Payment') . " " . ucwords($row['ordpaymentstatus']);
                                 $GLOBALS['PaymentStatusColor'] = 'PaymentRefunded';
                                 break;
                         }
                     }
                     // If the allow payment delayed capture, show the link to Delayed capture
                     $GLOBALS['DelayedCaptureLink'] = '';
                     $GLOBALS['VoidLink'] = '';
                     $GLOBALS['RefundLink'] = '';
                     $transactionId = trim($row['ordpayproviderid']);
                     //if orginal transaction id exist and payment provider is currently enabled
                     if ($transactionId != '' && GetModuleById('checkout', $provider, $row['orderpaymentmodule']) && $provider->IsEnabled() && !gzte11(ISC_HUGEPRINT)) {
                         //if the payment module allow delayed capture and the current payment status is authorized
                         //display delay capture option
                         if (method_exists($provider, "DelayedCapture") && $row['ordpaymentstatus'] == 'authorized') {
                             $GLOBALS['DelayedCaptureLink'] = '<option value="delayedCapture">' . GetLang('CaptureFunds') . '</option>';
                             $GLOBALS['PaymentStatus'] .= '<a onclick="Order.DelayedCapture(' . $row['orderid'] . '); return false;" href="#">' . GetLang('CaptureFunds') . '</a>';
                         }
                         //if the payment module allow void transaction and the current payment status is authorized
                         //display void option
                         if (method_exists($provider, "DoVoid") && $row['ordpaymentstatus'] == 'authorized') {
                             $GLOBALS['VoidLink'] = '<option value="voidTransaction">' . GetLang('VoidTransaction') . '</option>';
                         }
                         //if the payment module allow refund and the current payment status is authorized
                         //display refund option
                         if (method_exists($provider, "DoRefund") && ($row['ordpaymentstatus'] == 'captured' || $row['ordpaymentstatus'] == 'partially refunded')) {
                             $GLOBALS['RefundLink'] = '<option value="refundOrder">' . GetLang('Refund') . '</option>';
                         }
                     }
                     $GLOBALS["OrderStatusText"] = GetOrderStatusById($row['ordstatus']);
                     $GLOBALS['OrderStatusId'] = $row['ordstatus'];
                     $CustomerLink = '';
                     $CustomerId = $row['ordcustid'];
                     $custname = isc_html_escape($row['custname']);
                     if (trim($row['ordcustid']) != '0') {
                         $GLOBALS['CustomerLink'] = "<a href='index.php?ToDo=viewCustomers&amp;idFrom={$CustomerId}&idTo={$CustomerId}' target='_blank'>" . $custname . "</a>";
                     } else {
                         $GLOBALS['CustomerLink'] = $row['ordbillfirstname'] . ' ' . $row['ordbilllastname'];
                     }
                     $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("sales.manage.row");
                     $GLOBALS['OrderGrid'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate(true);
                     $GLOBALS['Quickview'] = "\n                        <tr id=\"trQ{$OrderId}\" style=\"display:none\">\n                            <td></td>\n                            <td colspan=\"12\" id=\"tdQ{$OrderId}\" class=\"QuickView\"></td>\n                        </tr> ";
                 }
             }
         } else {
             $GLOBALS['OrderGrid'] .= sprintf("\n                <tr class=\"GridRow\" onmouseover=\"this.className='GridRowOver';\" onmouseout=\"this.className='GridRow';\">\n                    <td nowrap height=\"22\" colspan=\"5\">\n                        <em>%s</em>\n                    </td>\n                </tr>\n            ", GetLang('StatsNoProducts'));
         }
         $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("sales.manage.grid");
         $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate();
     }
 }
Example #10
0
	/**
	 * This function get all the available eBay live listing for the user and return a string of the managing template html.
	 * @return string Return the html of the eBay live listing page
	 */
	public function ManageEbayLiveListingGrid()
	{
		// Show a list of ebay item in a table
		$page = 0;
		$start = 0;
		$numListing = 0;
		$numPages = 0;
		$GLOBALS['EbayListingGrid'] = "";
		$GLOBALS['Nav'] = "";
		$max = 0;
		$searchURL = '';

		if (isset($_GET['searchQueryListing']) && isset($_GET['listingType']) && isset($_GET['listingStatus'])) {
			$GLOBALS['ListingQuery'] = $query['searchQueryListing'] = $_GET['searchQueryListing'];
			$GLOBALS['ListingType'] = $query['listingType'] = $_GET['listingType'];
			$GLOBALS['ListingStatus'] = $query['listingStatus'] = $_GET['listingStatus'];
			$searchURL = '&amp;searchQueryListing='.$query;
			foreach ($query as $k => $v) {
				$searchURL .= "&amp;$k=$v";
			}
		} else {
			$query = "";
			$GLOBALS['Query'] = "";
		}

		if (isset($_GET['sortOrder']) && $_GET['sortOrder'] == 'asc') {
			$sortOrder = 'asc';
		} else {
			$sortOrder = "desc";
		}

		$sortLinks = array(
			"Item" => "ei.title",
			"DateListed" => "ei.datetime_listed",
			"Type" => "ei.listing_type",
			"Status" => "ei.listing_status",
			"BidCount" => "ei.bid_count",
			"QuantityRemaining" => "ei.quantity_remaining",
			"CurrentPrice" => "ei.current_price",
			"BinPrice" => "ei.buyitnow_price",
			"OrderNumber" => "order_no",
		);


		if (isset($_GET['sortField']) && in_array($_GET['sortField'], $sortLinks)) {
			$sortField = $_GET['sortField'];
			SaveDefaultSortField("ManageEbayListing", $_REQUEST['sortField'], $sortOrder);
		}
		else {
			$sortField = "ei.datetime_listed";
			list($sortField, $sortOrder) = GetDefaultSortField("ManageEbayListing", $sortField, $sortOrder);
		}

		if (isset($_GET['page'])) {
			$page = (int)$_GET['page'];
		} else {
			$page = 1;
		}

		$sortURL = sprintf("&sortField=%s&sortOrder=%s", $sortField, $sortOrder);
		$GLOBALS['SortURL'] = $sortURL;

		// Limit the number of questions returned
		if ($page == 1) {
			$start = 1;
		} else {
			$start = ($page * ISC_EBAY_LISTING_PER_PAGE) - (ISC_EBAY_LISTING_PER_PAGE-1);
		}

		$start = $start-1;

		// Get the results for the query
		$listingResult = $this->_GetEbayListingList($query, $start, $sortField, $sortOrder, $numListing);
		$numPages = ceil($numListing / ISC_EBAY_LISTING_PER_PAGE);

		// Add the "(Page x of n)" label
		if($numListing > ISC_EBAY_LISTING_PER_PAGE) {
			$GLOBALS['Nav'] = sprintf("(%s %d of %d) &nbsp;&nbsp;&nbsp;", GetLang('Page'), $page, $numPages);
			$GLOBALS['Nav'] .= BuildPagination($numListing, ISC_EBAY_LISTING_PER_PAGE, $page, sprintf("index.php?ToDo=viewEbay&currentTab=0%s", $sortURL));
		}
		else {
			$GLOBALS['Nav'] = "";
		}

		$GLOBALS['Nav'] = rtrim($GLOBALS['Nav'], ' |');
		$GLOBALS['SearchQueryListing'] = $query;
		$GLOBALS['SortField'] = $sortField;
		$GLOBALS['SortOrder'] = $sortOrder;

		BuildAdminSortingLinks($sortLinks, "index.php?ToDo=viewEbay&amp;currentTab=0&amp;".$searchURL."&amp;page=".$page, $sortField, $sortOrder);

		// Workout the maximum size of the array
		$max = $start + ISC_EBAY_LISTING_PER_PAGE;

		if ($max > count($listingResult)) {
			$max = count($listingResult);
		}
		if($numListing > 0) {
			$GLOBALS['ManageEbayLiveListingIntro'] = sprintf(GetLang('ManageEbayLiveListingIntro'), $numListing);

			// Display the live listing
			while ($row = $GLOBALS["ISC_CLASS_DB"]->Fetch($listingResult))
			{
				$GLOBALS['Item'] = isc_html_escape($row['title']);
				if (trim($row['ebay_item_link'])) {
					$GLOBALS['Item'] = '<a target="_blank" href="'.$row['ebay_item_link'].'">' .$GLOBALS['Item']. '</a>';
				}
				$GLOBALS['DateListed'] = CDate($row['datetime_listed']);
				$GLOBALS['Type'] = GetLang(isc_html_escape($row['listing_type']));
				$GLOBALS['Status'] = GetLang(isc_html_escape(ucfirst($row['listing_status'])));
				$GLOBALS['BidCount'] = GetLang('NA');
				if (!empty ($row['bid_count'])) {
					$GLOBALS['BidCount'] = $row['bid_count'];
				}
				$GLOBALS['QuantityRemaining'] = GetLang('NA');
				if (!empty ($row['quantity_remaining'])) {
					$GLOBALS['QuantityRemaining'] = $row['quantity_remaining'];
				}
				$currentPriceCurrency = GetCurrencyByCode($row['current_price_currency']);
				$GLOBALS['CurrentPrice'] = FormatPriceInCurrency($row['current_price'], $currentPriceCurrency['currencyid']);
				$binPriceCurrency = GetCurrencyByCode($row['buyitnow_price_currency']);
				$GLOBALS['BinPrice'] = FormatPriceInCurrency($row['buyitnow_price'], $binPriceCurrency['currencyid']);
				$GLOBALS['OrderNumber'] = $row['order_no'];
				if ($row['order_no'] == '') {
					$GLOBALS['OrderNumber'] = '';
				}
				$GLOBALS['EbayItemId'] = $row['ebay_item_id'];
				if ($row['listing_type'] == 'FixedPriceItem') {
					$GLOBALS['BinPrice'] = $GLOBALS['CurrentPrice'];
					$GLOBALS['CurrentPrice'] = GetLang('NA');
				}

				$GLOBALS['EbayListingGrid'] .= $this->template->render('ebay.listing.manage.row.tpl');
			}

			return $this->template->render('ebay.listing.manage.grid.tpl');
		}
		$GLOBALS['ShowListingOptions'] = 'display:none;';
		return '';
	}
Example #11
0
	public function __construct($orderId = null)
	{
		$this->setDoubleOptIn(GetConfig('EmailIntegrationOrderDoubleOptin'));
		$this->setSendWelcome(GetConfig('EmailIntegrationOrderSendWelcome'));
		$this->setSubscriptionIP(GetIP());

		if (!$orderId) {
			return;
		}

		$entity = new ISC_ENTITY_ORDER;

		$data = $entity->get($orderId);
		if (!$data) {
			throw new Interspire_EmailIntegration_Subscription_Exception;
		}
		$this->_data = $data;
		unset($data);

		// copy any form fields associated with the order + associated customer and place into local subscription data

		if (isId($this->_data['ordformsessionid'])) {
			/** @var ISC_FORM */
			$form = $GLOBALS["ISC_CLASS_FORM"];

			$customFields = array();

			$formData = $form->getSavedSessionData($this->_data['customer']['custformsessionid']);
			if ($formData && !empty($formData)) {
				$customFields += $formData;
			}

			$formData = $form->getSavedSessionData($this->_data['ordformsessionid']);
			if ($formData && !empty($formData)) {
				$customFields += $formData;
			}

			foreach ($customFields as $fieldId => $value) {
				$this->_data['FormField_' . $fieldId] = $value;
			}
		}

		// generate fields specifically for email integration based on order data (ones that aren't covered by simple order data or by Form Fields)

		// get the first shipping address record because IEM had shipping method as mappable field
		$this->_data['shipping_method'] = '';
		$shippingMethod = $GLOBALS['ISC_CLASS_DB']->FetchOne("SELECT `method` FROM [|PREFIX|]order_shipping WHERE order_id = " . (int)$orderId . " LIMIT 1", 'method');
		if ($shippingMethod) {
			$this->_data['shipping_method'] = $shippingMethod;
		}

		// pre-formated 'full address' mappable field to pass to providers like mailchimp
		$this->_data['OrderSubscription_BillingAddress'] = array(
			'addr1' => $this->_data['ordbillstreet1'],
			'addr2' => $this->_data['ordbillstreet2'],
			'city' => $this->_data['ordbillsuburb'],
			'state' => $this->_data['ordbillstate'],
			'zip' => $this->_data['ordbillzip'],
			'country' => $this->_data['ordbillcountrycode'],
		);

		// country-code specific fields to pass to providers like MailChimp or IEM that support (or require in IEM's case) country codes
		$this->_data['OrderSubscription_BillingAddress_countryiso2'] = $this->_data['ordbillcountrycode'];
		$this->_data['OrderSubscription_BillingAddress_countryiso3'] = GetCountryISO3ById($this->_data['ordbillcountryid']);

		// for email integration, we prefer sending the value of an order as the total amount rather than the stored (charged) total - which could be less than the value due to store credit or gift certificates
		// so, generate some columns which are internal to this subscription data and map to those instead of total_ex and total_inc
		$this->_data['total_ex_tax'] = $this->_data['subtotal_ex_tax'] + $this->_data['shipping_cost_ex_tax'] + $this->_data['handling_cost_ex_tax'] + $this->_data['wrapping_cost_ex_tax'];
		$this->_data['total_inc_tax'] = $this->_data['subtotal_inc_tax'] + $this->_data['shipping_cost_inc_tax'] + $this->_data['handling_cost_inc_tax'] + $this->_data['wrapping_cost_inc_tax'];

		// generated fields: end

		// currency values must be stored in the subscription data as both numeric and formatted so that, when translated to the mail provider, it can be sent as either a number or string depending on the destination field
		$moneyFields = array(
			'subtotal_ex_tax',
			'subtotal_inc_tax',
			'subtotal_tax',
			'total_ex_tax',
			'total_inc_tax',
			'total_tax',
			'shipping_cost_ex_tax',
			'shipping_cost_inc_tax',
			'shipping_cost_tax',
			'handling_cost_ex_tax',
			'handling_cost_inc_tax',
			'handling_cost_tax',
			'wrapping_cost_ex_tax',
			'wrapping_cost_inc_tax',
			'wrapping_cost_tax',
			'ordrefundedamount',
			'ordstorecreditamount',
			'ordgiftcertificateamount',
			'orddiscountamount',
			'coupon_discount',
		);

		foreach ($moneyFields as $moneyFieldId) {
			$this->_data[$moneyFieldId] = array(
				'numeric' => $this->_data[$moneyFieldId],
				'formatted' => FormatPriceInCurrency($this->_data[$moneyFieldId], $this->_data['orddefaultcurrencyid']),
			);
		}

		$set = new ISC_NESTEDSET_CATEGORIES;

		// instead of storing full product information, just store the data pertinent to integration rules
		foreach ($this->_data['products'] as $product) {
			$this->_products[] = $product['productid'];
			$this->_brands[] = $product['prodbrandid'];

			if ($product['prodcatids']) {
				foreach (explode(',', $product['prodcatids']) as $categoryId) {
					$this->_categories[] = $categoryId;

					// also include parent categories to trigger rules related to them
					$parents = $set->getParentPath(array('categoryid'), (int)$categoryId);
					foreach ($parents as $parentCategory) {
						$this->_categories[] = $parentCategory['categoryid'];
					}
				}
			}
		}

		$this->_products = array_unique($this->_products);
		$this->_brands = array_unique($this->_brands);
		$this->_categories = array_unique($this->_categories);

		sort($this->_products);
		sort($this->_brands);
		sort($this->_categories);

		// for now, don't need to store these - may need to store products when this is changed to supply ecommerce info
		unset($this->_data['customer']);
		unset($this->_data['products']);
	}
 public function GetOrderDetail($orderId, $type = "review")
 {
     $GLOBALS['RequestLogs'] = "";
     /*if($type == "review")
     		{
     			$GLOBALS['RequestLogs'] = "yes";
     		}*/
     $GLOBALS['HideRequestLogs'] = "display: none";
     $logQuery = "\n\t\t\tSELECT * \n\t\t    FROM [|PREFIX|]request_log rl\n\t\t  \tLEFT JOIN [|PREFIX|]requests r ON (r.requestid=rl.requestid)\n\t\t    WHERE r.orderid='" . $orderId . "' \n\t\t  \tORDER BY logdate ASC\n\t\t";
     $logResult = $GLOBALS['ISC_CLASS_DB']->Query($logQuery);
     while ($log = $GLOBALS['ISC_CLASS_DB']->Fetch($logResult)) {
         $GLOBALS['RequestLogs'] .= "<p>At [" . $log['logdate'] . "]: " . $log['logdesc'] . "</p>";
     }
     // should hide request logs
     /*if($GLOBALS['RequestLogs']!=""){
     			$GLOBALS['HideRequestLogs'] = "";
     		}*/
     $GLOBALS['OrderReviewLink'] = GetConfig('ShopPath') . "/order/review/" . $orderId;
     $query = "\n\t\t\tSELECT o.*, CONCAT(custconfirstname, ' ', custconlastname) AS custname, custconemail, custconphone, s.zonename AS shippingzonename,\n\t\t\t(SELECT COUNT(messageid) FROM [|PREFIX|]order_messages WHERE messageorderid=orderid AND messagestatus='unread') AS numunreadmessages\n\t\t\tFROM [|PREFIX|]orders o\n\t\t\tLEFT JOIN [|PREFIX|]customers c ON (c.customerid=o.ordcustid)\n\t\t\tLEFT JOIN [|PREFIX|]shipping_zones s ON (s.zoneid=o.ordshippingzoneid)\n\t\t\tWHERE o.orderid='" . $GLOBALS['ISC_CLASS_DB']->Quote($orderId) . "'\n\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'];
         $GLOBALS['contactEmail'] = $row['custconemail'];
         if ($row["numunreadmessages"] == 0) {
             $GLOBALS["HideMessages"] = "none";
         }
         if (!gzte11(ISC_LARGEPRINT)) {
             $GLOBALS["HideMessageItems"] = "none";
         }
         $row['custname'] = isc_html_escape(trim($row['custname']));
         $GLOBALS['CustomerName'] = $row['custname'];
         $GLOBALS['CouponsUsed'] = '';
         $GLOBALS['HideCouponsUsed'] = 'display: none';
         // Get the products in the order
         $query = "SELECT o.*\n\t\t\t\tFROM [|PREFIX|]order_coupons o\n\t\t\t\tWHERE ordcouporderid='" . $orderId . "'";
         $coupons = $GLOBALS['ISC_CLASS_DB']->Query($query);
         $allcoupons = array();
         $couponcode = '';
         $GLOBALS['CouponsUsedDetails'] = '';
         while ($coupon = $GLOBALS['ISC_CLASS_DB']->Fetch($coupons)) {
             $allcoupons[] = $coupon;
             if ($couponcode != $coupon['ordcouponcode']) {
                 $couponcode = $coupon['ordcouponcode'];
                 $GLOBALS['CouponsUsed'] .= $coupon['ordcouponcode'] . ',';
                 $GLOBALS['HideCouponsUsed'] = '';
                 $CoupDetails = "Coupon Code : " . $coupon['ordcouponcode'] . "<br />";
                 if ($coupon['ordcoupontype'] == 0) {
                     $CoupDetails .= "Coupon Amount : " . FormatPriceInCurrency($coupon['ordcouponamount'], $row['orddefaultcurrencyid']) . "<br />";
                 } else {
                     $CoupDetails .= "Coupon Amount : " . $coupon['ordcouponamount'] . "%<br />";
                 }
                 //$CoupDetails .= "Coupon Name : ".$coupon['ordcouponcode'];
                 $GLOBALS['CouponsUsedDetails'] .= $CoupDetails;
             }
         }
         $prodFieldsArray = $GLOBALS['ISC_CLASS_ADMIN_ORDERS']->GetOrderProductFieldsData($orderId);
         // Get the products in the order
         $query = "\n\t\t\t\tSELECT o.*, p.prodname\n\t\t\t\tFROM [|PREFIX|]order_products o\n\t\t\t\tLEFT JOIN [|PREFIX|]products p ON (p.productid=o.ordprodid)\n\t\t\t\tWHERE orderorderid='" . $orderId . "'\n\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<tr>\n\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%s\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td colspan=\"2\">&nbsp;</td>\n\t\t\t\t\t</tr>\n\t\t\t\t", GetLang('DigitalOrderNotice'));
         }
         $wrappingTotal = 0;
         $originaltotal = 0;
         //blessen
         $originaltotal_temp = 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>";
                 }
             }
             $prodYMMInfo = '';
             if ($pRow['ordyear'] != '' || $pRow['ordmake'] != '' || $pRow['ordmodel'] != '') {
                 $prodYMMInfo = "<blockquote style=\"padding-left: 0px; margin: 0;\">";
                 $prodYMMInfo .= $pRow['ordyear'] . "&nbsp;" . $pRow['ordmake'] . "&nbsp;" . $pRow['ordmodel'];
                 $prodYMMInfo .= "</blockquote>";
             }
             $origPrice = $pRow['ordprodcost'] * $pRow['ordprodqty'];
             // initializing to zero
             if (count($allcoupons)) {
                 //$pRow['ordoriginalprice'] < $pRow['ordprodcost']
                 if ($pRow['ordoriginalprice'] > $pRow['ordprodcost']) {
                     $prodYMMInfo .= "<blockquote style=\"padding-left: 0px; margin: 0;\">";
                     $origPrice = $pRow['ordoriginalprice'] * $pRow['ordprodqty'];
                     $prodYMMInfo .= '<u>Original Price : ' . FormatPriceInCurrency($origPrice, $row['orddefaultcurrencyid']) . "<br />";
                     $DiscountAmt = number_format($pRow['ordoriginalprice'] - $pRow['ordprodcost'], 2);
                     $prodYMMInfo .= 'Discount : ' . FormatPriceInCurrency($DiscountAmt, $row['orddefaultcurrencyid']) . "</u>";
                     $prodYMMInfo .= "</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<tr>\n\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 . $prodYMMInfo . "</td>\n\t\t\t\t\t\t<td class=\"text\" width=\"30%%\" align=\"right\">" . FormatPriceInCurrency($cost, $row['orddefaultcurrencyid']) . "</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t" . $giftOptions . $eventDate . $prodFields . $itemDetails . "\n\t\t\t\t";
             $originaltotal = $originaltotal + $origPrice;
             $originaltotal_temp = $originaltotal_temp + $cost;
         }
         if ($originaltotal == 0) {
             $originaltotal = $originaltotal_temp;
         }
         $GLOBALS['ProductsTable'] .= sprintf("<tr><td height='18' class='text' align='right'>%s:</td><td class='text' align='right'>%s</td></tr>", 'Original Total', FormatPriceInCurrency($originaltotal, $row['orddefaultcurrencyid']));
         $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';
         }
         $GLOBALS['OrderDetails'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("OrderDetail");
     } else {
         //echo GetLang('OrderDetailsNotFound');
     }
 }