Example #1
0
 /**
  * Actually track a visitor.
  */
 function TrackVisitor()
 {
     $today_stamp = mktime(0, 0, 0, isc_date("m"), isc_date("d"), isc_date("Y"));
     if (!isset($_COOKIE['STORE_VISITOR'])) {
         // We have a new visitor, let's track that.
         $query = sprintf("SELECT COUNT(uniqueid) AS num FROM [|PREFIX|]unique_visitors WHERE datestamp='%d'", $GLOBALS['ISC_CLASS_DB']->Quote($today_stamp));
         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         $row = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
         if ($row['num'] == 0) {
             // This person is the first to visit the site today, so track it
             $new_visitor = array("datestamp" => $today_stamp, "numuniques" => 1);
             $GLOBALS['ISC_CLASS_DB']->InsertQuery("unique_visitors", $new_visitor);
         } else {
             // At least one person has visited the site today, just update the record
             $query = sprintf("UPDATE [|PREFIX|]unique_visitors SET numuniques=numuniques+1 WHERE datestamp='%d'", $today_stamp);
             // Run the query to update the number of unique visitors
             $GLOBALS['ISC_CLASS_DB']->Query($query);
         }
         // Set the tracking cookie for another 24 hours
         ISC_SetCookie("STORE_VISITOR", true, time() + 86400);
     }
     header("Content-type: image/gif");
     echo base64_decode('R0lGODlhAQABALMAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A/wD//wBiZCH5BAEAAA8ALAAAAAABAAEAAAQC8EUAOw==');
     exit;
 }
Example #2
0
	/**
	* Display the store-wide GWO tests list
	*
	*/
	private function manageOptimizer()
	{
		$Tests = GetAvailableModules('optimizer');
		$Output = "";
		$EnabledModules = array();

		$GLOBALS['Message'] = GetFlashMessageBoxes();

		$EnabledModules = GetConfig('OptimizerMethods');

		$GLOBALS['OptimizerRow'] = '';
		foreach ($Tests as $Test) {
			$GLOBALS['ModuleName'] = isc_html_escape($Test['name']);
			$GLOBALS['ModuleId'] = $Test['id'];
			$GLOBALS['ConfiguredIcon'] = 'cross';
			$GLOBALS['ConfiguredDate'] = 'N/A';
			$GLOBALS['ActiveReset'] = 'inactive';

			if($Test['enabled']) {
				$GLOBALS['ActiveReset'] = 'active';
				$GLOBALS['ConfiguredIcon'] = 'tick';
				if(isset($EnabledModules[$Test['id']]) && $EnabledModules[$Test['id']] != '') {
					$GLOBALS['ConfiguredDate'] = isc_date('jS M Y',$EnabledModules[$Test['id']]);
				}
			}
			$GLOBALS['OptimizerRow'] .= $this->template->render('Snippets/OptimizerRow.html');

		}

		$this->template->display('optimizer.manage.tpl');
	}
 /**
  * Save an item to the data store.
  *
  * @param string The name of the item to save.
  * @param mixed The data to be saved in the data store.
  * @return boolean True if the data was saved successfully, false if not.
  */
 public function Save($name, $data)
 {
     $contents = "<" . "?php\n\n/** Interspire Shopping Cart Data Store File **\n  *\n";
     $contents .= "  * Generated: " . isc_date('r') . "\n  *\n  * DO NOT EDIT THIS FILE MANUALLY\n  *\n*/\n\n";
     $contents .= "\$cacheData = " . var_export($data, true) . ";\n\n?" . ">";
     if (file_put_contents($this->baseDir . '/' . $name . '.php', $contents)) {
         return true;
     } else {
         return false;
     }
 }
 /**
  * Creates a file and exports the data from the file type
  *
  * @return string The name of the file.
  */
 public function Export()
 {
     //zcs=>
     $is_photo = $this->filetype instanceof ISC_ADMIN_EXPORTFILETYPE_PHOTOS;
     $sys_tmp = sys_get_temp_dir();
     //<=zcs
     // create a temporary file
     $output = "";
     //zcs=add (judgement)
     $this->file = $is_photo ? $sys_tmp . "/photos_" . isc_date("Y-m-d") . "." . $this->method_extension : tempnam($sys_tmp, "export_");
     $this->handle = fopen($this->file, "wb");
     // write any header data if necessary
     $this->WriteHeader();
     // Export the rows  3 sepperate fuctions added by blessen
     $image_files = array();
     //zcs=
     if ($_GET['t'] == "customers" || $_GET['t'] == "orders") {
         $this->filetype->ExportRows_Orders_Customer();
     } else {
         $image_files = $this->filetype->ExportRows();
     }
     // write any footer/closing data
     $this->WriteFooter();
     // close the file
     fclose($this->handle);
     //zcs=>For photos, add this result file to specify zip file(where created from ISC_ADMIN_EXPORTFILETYPE_PHOTOS-ExportRows()).
     if ($is_photo) {
         /*--old
         		$zip_handle = new ZipArchive;
         		if($zip_handle->open($this->filetype->zip_file) !== TRUE){
         			throw new Exception(sprintf(GetLang('OpenZipError'), $this->filetype->zip_file));
         		}
         		$zip_handle->addFile($this->file, 'photo_list'.'.'.$this->method_extension);
         		$zip_handle->close();
         		*/
         $image_files[] = $this->file;
         $zip_file = tempnam($sys_tmp, 'exportzip_');
         $zip_handle = new PclZip($zip_file);
         $zip_rs = $zip_handle->create($image_files, PCLZIP_OPT_REMOVE_ALL_PATH);
         if ($zip_rs == 0) {
             throw new Exception(sprintf(GetLang("CreateZipError"), $zip_handle->errorInfo(true)));
         }
         unlink($this->file);
         //delete temporary file
         $this->file = $zip_file;
         //zcs=change file for downloading
         $this->method_extension = 'zip';
         //zcs= change extension for downloading
     }
     //<=zcs
     return $this->GetFile();
 }
Example #5
0
	/**
	 * Filter for formatting dates in templates that wraps around isc_date. Will use
	 * getConfig('DisplayDateFormat') if no format is supplied.
	 *
	 * @param DateTime|int $timestamp Instance of a DateTime object, or unix timestamp.
	 * @param string $format Format for time. Can either be a getConfig() value or actual date format.
	 * @return string Formatted date.
	 */
	public function dateFormat($timestamp, $format = '')
	{
		if($format == '') {
			$format = getConfig('DisplayDateFormat');
		}
		else if(getConfig($format)) {
			$format = getConfig($format);
		}

		if($timestamp instanceof DateTime) {
			return $timestamp->format($format);
		}

		return isc_date($format, $timestamp);
	}
Example #6
0
	public function fromSubscriptionToProvider(Interspire_EmailIntegration_Field $field, $value)
	{
		if ($field instanceof Interspire_EmailIntegration_Field_Date) {
			// for dates, the value /should/ be convertable to a timestamp, so we can date() it and send it through as mailchimp requires
			// note: if I sent a date formatted using isc_date_tz to mailchimp, they would convert it to local time (so 2010-04-28 became 2010-04-27) *even if the mailchimp account was set to +10* - so, I'm sending it through without a tz indicator and it seems to make more sense -ge
			return isc_date('Y-m-d H:i:s', $field->valueToNumber($value));
		}

		if ($field instanceof Interspire_EmailIntegration_Field_StringInterface) {
			// for other string-compatible fields, try sending that through and let mailchimp sort it out
			return $field->valueToString($value);
		}

		// other field types that won't map
		return '';
	}
Example #7
0
 function ShowNews()
 {
     if ($this->_newsid > 0) {
         $GLOBALS['NewsTitle'] = $this->_newstitle;
         $GLOBALS['NewsContent'] = $this->_newscontent;
         if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') {
             $GLOBALS['NewsContent'] = str_replace($GLOBALS['ShopPathNormal'], $GLOBALS['ShopPathSSL'], $GLOBALS['NewsContent']);
         }
         $GLOBALS['NewsDate'] = isc_date(GetConfig('ExtendedDisplayDateFormat'), $this->_newsdate);
         $GLOBALS['ISC_CLASS_TEMPLATE']->SetPageTitle($this->_newstitle);
         $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("news");
         $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate();
     } else {
         ob_end_clean();
         header("Location: " . $GLOBALS['ShopPath']);
         die;
     }
 }
Example #8
0
/**
 * Calculate and return a friendly displayable date such as "less than a minute ago"
 * "x minutes ago", "Today at 6:00 PM" etc.
 *
 * @param string The UNIX timestamp to format.
 * @param boolean True to include the time details, false if not.
 * @return string The formatted date.
 */
function NiceDate($timestamp, $includeTime = false)
{
    $now = time();
    $difference = $now - $timestamp;
    $time = isc_date('h:i A', $timestamp);
    $timeDate = isc_date('Ymd', $timestamp);
    $todaysDate = isc_date('Ymd', $now);
    $yesterdaysDate = isc_date('Ymd', $now - 86400);
    if ($difference < 60) {
        return GetLang('LessThanAMinuteAgo');
    } else {
        if ($difference < 3600) {
            $minutes = ceil($difference / 60);
            if ($minutes == 1) {
                return GetLang('OneMinuteAgo');
            } else {
                return sprintf(GetLang('XMinutesAgo'), $minutes);
            }
        } else {
            if ($difference < 43200) {
                $hours = ceil($difference / 3600);
                if ($hours == 1) {
                    return GetLang('OneHourAgo');
                } else {
                    return sprintf(GetLang('XHoursAgo'), $hours);
                }
            } else {
                if ($timeDate == $todaysDate) {
                    if ($includeTime == true) {
                        return sprintf(GetLang('TodayAt'), $time);
                    } else {
                        return GetLang('Today');
                    }
                } else {
                    if ($timeDate == $yesterdaysDate) {
                        if ($includeTime == true) {
                            return sprintf(GetLang('YesterdayAt'), $time);
                        } else {
                            return GetLang('Yesterday');
                        }
                    } else {
                        $date = CDate($timestamp);
                        if ($includeTime == true) {
                            return sprintf(GetLang('OnDateAtTime'), $date, $time);
                        } else {
                            return sprintf(GetLang('OnDate'), $date);
                        }
                    }
                }
            }
        }
    }
}
 public function BuildWhereFromVars($array)
 {
     $queryWhere = "";
     if (isset($array['searchQuery']) && $array['searchQuery'] != "") {
         // PostgreSQL is case sensitive for likes, so all matches are done in lower case
         $search_query = $GLOBALS['ISC_CLASS_DB']->Quote(trim(isc_strtolower($array['searchQuery'])));
         $queryWhere .= "\n\t\t\t\t\tAND (\n\t\t\t\t\t\tcustomerid = '" . $search_query . "' OR\n\t\t\t\t\t\tLOWER(custconfirstname) LIKE '%" . $search_query . "%' OR\n\t\t\t\t\t\tLOWER(custconlastname) LIKE '%" . $search_query . "%' OR\n\t\t\t\t\t\tLOWER(custconemail) LIKE '%" . $search_query . "%' OR\n\t\t\t\t\t\tLOWER(CONCAT(custconfirstname, ' ', custconlastname)) LIKE '%" . $search_query . "%' OR\n\t\t\t\t\t\tLOWER(custconcompany) LIKE '%" . $search_query . "%'\n\t\t\t\t\t)";
     }
     if (isset($array['letter']) && $array['letter'] != '') {
         $letter = chr(ord($array['letter']));
         if ($array['letter'] == '0-9') {
             $queryWhere .= " AND custconlastname NOT REGEXP('^[a-zA-Z]')";
         } else {
             if (isc_strlen($letter) == 1) {
                 $queryWhere .= " AND custconlastname LIKE '" . $GLOBALS['ISC_CLASS_DB']->Quote($letter) . "%'";
             }
         }
     }
     if (isset($array['phone']) && $array['phone'] != "") {
         $phone = $GLOBALS['ISC_CLASS_DB']->Quote(trim($array['phone']));
         $queryWhere .= sprintf(" AND custconphone LIKE '%%%s%%'", $phone);
     }
     if (isset($array['idFrom']) && $array['idFrom'] != "") {
         $id_from = $GLOBALS['ISC_CLASS_DB']->Quote((int) $array['idFrom']);
         $queryWhere .= sprintf(" AND customerid >= '%d'", $id_from);
     }
     if (isset($array['idTo']) && $array['idTo']) {
         $id_to = $GLOBALS['ISC_CLASS_DB']->Quote((int) $array['idTo']);
         $queryWhere .= sprintf(" AND customerid <= '%d'", $id_to);
     }
     if (isset($array['storeCreditFrom']) && $array['storeCreditFrom'] != "") {
         $credit_from = $GLOBALS['ISC_CLASS_DB']->Quote((int) $array['storeCreditFrom']);
         $queryWhere .= sprintf(" AND custstorecredit >= '%d'", $credit_from);
     }
     if (isset($array['storeCreditTo']) && $array['storeCreditTo'] != "") {
         $credit_to = $GLOBALS['ISC_CLASS_DB']->Quote((int) $array['storeCreditTo']);
         $queryWhere .= sprintf(" AND custstorecredit <= '%d'", $credit_to);
     }
     // Limit results to a particular join date range
     if (isset($array['dateRange']) && $array['dateRange'] != "") {
         $range = $array['dateRange'];
         switch ($range) {
             // Registrations within the last day
             case "today":
                 $from_stamp = mktime(0, 0, 0, isc_date("m"), isc_date("d"), isc_date("Y"));
                 break;
                 // Registrations received in the last 2 days
             // Registrations received in the last 2 days
             case "yesterday":
                 $from_stamp = mktime(0, 0, 0, isc_date("m"), date("d") - 1, isc_date("Y"));
                 $to_stamp = mktime(0, 0, 0, isc_date("m"), isc_date("d") - 1, isc_date("Y"));
                 break;
                 // Registrations received in the last 24 hours
             // Registrations received in the last 24 hours
             case "day":
                 $from_stamp = time() - 60 * 60 * 24;
                 break;
                 // Registrations received in the last 7 days
             // Registrations received in the last 7 days
             case "week":
                 $from_stamp = time() - 60 * 60 * 24 * 7;
                 break;
                 // Registrations received in the last 30 days
             // Registrations received in the last 30 days
             case "month":
                 $from_stamp = time() - 60 * 60 * 24 * 30;
                 break;
                 // Registrations received this month
             // Registrations received this month
             case "this_month":
                 $from_stamp = mktime(0, 0, 0, isc_date("m"), 1, isc_date("Y"));
                 break;
                 // Orders received this year
             // Orders received this year
             case "this_year":
                 $from_stamp = mktime(0, 0, 0, 1, 1, isc_date("Y"));
                 break;
                 // Custom date
             // Custom date
             default:
                 if (isset($array['fromDate']) && $array['fromDate'] != "") {
                     $from_date = $array['fromDate'];
                     $from_data = explode("/", $from_date);
                     $from_stamp = mktime(0, 0, 0, $from_data[0], $from_data[1], $from_data[2]);
                 }
                 if (isset($array['toDate']) && $array['toDate'] != "") {
                     $to_date = $array['toDate'];
                     $to_data = explode("/", $to_date);
                     $to_stamp = mktime(0, 0, 0, $to_data[0], $to_data[1], $to_data[2]);
                 }
         }
         if (isset($from_stamp)) {
             $queryWhere .= sprintf(" AND custdatejoined >= '%d'", $from_stamp);
         }
         if (isset($to_stamp)) {
             $queryWhere .= sprintf(" AND custdatejoined <= '%d'", $to_stamp);
         }
     }
     if (isset($array['custGroupId']) && is_numeric($array['custGroupId'])) {
         $custGroupId = (int) $array['custGroupId'];
         $queryWhere .= sprintf(" AND custgroupid='%d' ", $custGroupId);
     }
     $joinQuery = '';
     // Search for users with a particular shipping country & state
     if (isset($array['country']) && $array['country'] != "") {
         $country = $GLOBALS['ISC_CLASS_DB']->Quote((int) $array['country']);
         $joinQuery = sprintf(" LEFT JOIN [|PREFIX|]shipping_addresses ON (shipcustomerid=customerid)");
         $queryWhere .= sprintf(" AND shipcountryid='%s'", $country);
         $state = '';
         if (isset($array['state']) && $array['state'] != "") {
             $state = GetStateById($array['state']);
         } else {
             if (isset($array['state_1']) && $array['state_1'] != "") {
                 $state = $array['state_1'];
             }
         }
         // Searching by state too
         if ($state != '') {
             $queryWhere .= " AND LOWER(shipstate)='" . $GLOBALS['ISC_CLASS_DB']->Quote(isc_strtolower($state)) . "'";
         }
     }
     return array("query" => $queryWhere, "join" => $joinQuery);
 }
 public function CopyProductStep1($MsgDesc = "", $MsgStatus = "", $PreservePost = false, $OriginalProductID = 0)
 {
     if ($MsgDesc != "") {
         $GLOBALS['Message'] = MessageBox($MsgDesc, $MsgStatus);
     }
     // Show the form to edit a product
     if (isset($_REQUEST['productId']) && isId($_REQUEST['productId'])) {
         $OriginalProductID = $_REQUEST['productId'];
     }
     $prodId = $OriginalProductID;
     $z = 0;
     $arrData = array();
     $arrImages = array();
     $arrCustomFields = array();
     if (GetConfig('CurrencyLocation') == 'right') {
         $GLOBALS['CurrencyTokenLeft'] = '';
         $GLOBALS['CurrencyTokenRight'] = GetConfig('CurrencyToken');
     } else {
         $GLOBALS['CurrencyTokenLeft'] = GetConfig('CurrencyToken');
         $GLOBALS['CurrencyTokenRight'] = '';
     }
     $GLOBALS['ServerFiles'] = $this->_GetImportFilesOptions();
     $GLOBALS['ISC_CLASS_ADMIN_CATEGORY'] = GetClass('ISC_ADMIN_CATEGORY');
     // Make sure the product exists
     if (ProductExists($prodId)) {
         if ($PreservePost == true) {
             $this->_GetProductData(0, $arrData);
             $this->_GetCustomFieldData(0, $arrCustomFields);
             $GLOBALS['ProductFields'] = $this->_GetProductFieldsLayout(0, true);
             // Restore the hash
             $GLOBALS['ProductHash'] = $arrData['prodhash'];
         } else {
             $this->_GetProductData($prodId, $arrData);
             $this->_GetCustomFieldData($prodId, $arrCustomFields);
             $GLOBALS['ProductFields'] = $this->_GetProductFieldsLayout($prodId, true);
             // Generate the hash
             $GLOBALS['ProductHash'] = md5(time() . uniqid(rand(), true));
             // We'll need to duplicate (copy) the thumbnail, images and download files here
             $this->_CopyProductImages($prodId, 0, $GLOBALS['ProductHash']);
             $this->_CopyDownloads($prodId, 0, $GLOBALS['ProductHash']);
             $arrData['prodname'] = GetLang('CopyOf') . $arrData['prodname'];
         }
         // Does this user have permission to edit this product?
         if ($GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId() && $arrData['prodvendorid'] != $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId()) {
             FlashMessage(GetLang('Unauthorized'), MSG_ERROR, 'index.php?ToDo=viewProducts');
         }
         $arrImages = $this->_GetImageData(0, $GLOBALS['ProductHash']);
         if (isset($_POST['currentTab'])) {
             $GLOBALS['CurrentTab'] = (int) $_POST['currentTab'];
         } else {
             $GLOBALS['CurrentTab'] = 0;
         }
         $GLOBALS['FormAction'] = 'copyProduct2';
         $GLOBALS['Title'] = GetLang('CopyProductTitle');
         $GLOBALS['Intro'] = GetLang('CopyProductIntro');
         $GLOBALS["ProdType_" . $arrData['prodtype']] = 'checked="checked"';
         $GLOBALS['ProdType'] = $arrData['prodtype'] - 1;
         $GLOBALS['ProdCode'] = isc_html_escape($arrData['prodcode']);
         $GLOBALS['ProdName'] = isc_html_escape($arrData['prodname']);
         $GLOBALS['OriginalProductId'] = $OriginalProductID;
         $visibleCategories = array();
         if ($GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId()) {
             $vendorData = $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendor();
             if ($vendorData['vendoraccesscats']) {
                 $visibleCategories = explode(',', $vendorData['vendoraccesscats']);
             }
         }
         //				$GLOBALS['CategoryOptions'] = $GLOBALS['ISC_CLASS_ADMIN_CATEGORY']->GetCategoryOptions($arrData['prodcats'], "<option %s value='%d'>%s</option>", "selected='selected'", "", false, '', $visibleCategories);
         $GLOBALS['CategoryOptions'] = $GLOBALS['ISC_CLASS_ADMIN_CATEGORY']->GetCategoryOptionsProduct($arrData['prodcats'], "<option %s value='%d' id='category_old%d'>%s</option>", "selected='selected'", "", false, '', $visibleCategories);
         $GLOBALS['RelatedCategoryOptions'] = $GLOBALS['ISC_CLASS_ADMIN_CATEGORY']->GetCategoryOptions(0, "<option %s value='%d'>%s</option>", "selected='selected'", "- ", false);
         //blessen
         $wysiwygOptions = array('id' => 'wysiwyg', 'width' => '60%', 'height' => '350px', 'value' => $arrData['proddesc']);
         $wysiwygOptions1 = array('id' => 'wysiwyg1', 'width' => '60%', 'height' => '350px', 'value' => $arrData['prodmfg']);
         $wysiwygOptions2 = array('id' => 'wysiwyg2', 'width' => '60%', 'height' => '350px', 'value' => $arrData['prodwarranty']);
         $GLOBALS['WYSIWYG'] = GetClass('ISC_ADMIN_EDITOR')->GetWysiwygEditor($wysiwygOptions);
         $GLOBALS['WYSIWYG1'] = GetClass('ISC_ADMIN_EDITOR')->GetWysiwygEditor1($wysiwygOptions1);
         $GLOBALS['WYSIWYG2'] = GetClass('ISC_ADMIN_EDITOR')->GetWysiwygEditor1($wysiwygOptions2);
         $GLOBALS['ProdSearchKeywords'] = isc_html_escape($arrData['prodsearchkeywords']);
         $GLOBALS['ProdAvailability'] = isc_html_escape($arrData['prodavailability']);
         $GLOBALS['ProdPrice'] = number_format($arrData['prodprice'], GetConfig('DecimalPlaces'), GetConfig('DecimalToken'), "");
         if (CFloat($arrData['prodcostprice']) > 0) {
             $GLOBALS['ProdCostPrice'] = number_format($arrData['prodcostprice'], GetConfig('DecimalPlaces'), GetConfig('DecimalToken'), "");
         }
         if (CFloat($arrData['prodretailprice']) > 0) {
             $GLOBALS['ProdRetailPrice'] = number_format($arrData['prodretailprice'], GetConfig('DecimalPlaces'), GetConfig('DecimalToken'), "");
         }
         if (CFloat($arrData['prodsaleprice']) > 0) {
             $GLOBALS['ProdSalePrice'] = number_format($arrData['prodsaleprice'], GetConfig('DecimalPlaces'), GetConfig('DecimalToken'), "");
         }
         $GLOBALS['ProdSortOrder'] = $arrData['prodsortorder'];
         if ($arrData['prodvisible'] == 1) {
             $GLOBALS['ProdVisible'] = "checked";
         }
         if ($arrData['prodfeatured'] == 1) {
             $GLOBALS['ProdFeatured'] = "checked";
         }
         if ($GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId()) {
             $GLOBALS['HideStoreFeatured'] = 'display: none';
         } else {
             if (!gzte11(ISC_HUGEPRINT) || !$arrData['prodvendorid']) {
                 $GLOBALS['HideVendorFeatured'] = 'display: none';
             }
         }
         if ($arrData['prodvendorfeatured'] == 1) {
             $GLOBALS['ProdVendorFeatured'] = 'checked="checked"';
         }
         if ($arrData['prodistaxable'] == 1) {
             $GLOBALS['ProdIsTaxable'] = 'checked';
         }
         if ($arrData['prodallowpurchases'] == 1) {
             $GLOBALS['ProdAllowPurchases'] = 'checked="checked"';
         } else {
             if ($arrData['prodhideprice'] == 1) {
                 $GLOBALS['ProdHidePrice'] = 'checked="checked"';
             }
             $GLOBALS['ProdCallForPricingLabel'] = isc_html_escape($arrData['prodcallforpricinglabel']);
         }
         $GLOBALS['MoreImages'] = "MoreImages();";
         for ($i = 1; $i <= $arrImages['numImages']; $i++) {
             $image = sprintf("../%s/%s", GetConfig('ImageDirectory'), $arrImages["image" . $i]);
             if ($i == 1) {
                 $GLOBALS["ImageMessage" . $i] = sprintf(GetLang('EditImageDesc'), $image, $arrImages["image" . $i]);
             } else {
                 $GLOBALS["ImageMessage" . $i] = sprintf(GetLang('EditImageDesc2'), $arrImages["id" . $i], $arrImages["id" . $i], $arrImages["id" . $i], $image, $arrImages["image" . $i], $arrImages["id" . $i]);
             }
         }
         if (isset($arrImages['thumb'])) {
             $thumb = sprintf("../%s/%s", GetConfig('ImageDirectory'), $arrImages['thumb']);
             $GLOBALS['ThumbMessage'] = sprintf(GetLang('EditImageDesc'), $thumb, $arrImages['thumb']);
         }
         //blessen
         //$GLOBALS['ProdWarranty'] = $arrData['prodwarranty'];
         //$GLOBALS['prod_instruction'] = $arrData['prod_instruction'];
         //$GLOBALS['prod_article'] = $arrData['prod_article'];
         $GLOBALS['ProdWeight'] = number_format($arrData['prodweight'], GetConfig('DecimalPlaces'), GetConfig('DecimalToken'), "");
         if (CFloat($arrData['prodwidth']) > 0) {
             $GLOBALS['ProdWidth'] = number_format($arrData['prodwidth'], GetConfig('DecimalPlaces'), GetConfig('DecimalToken'), "");
         }
         if (CFloat($arrData['prodheight']) > 0) {
             $GLOBALS['ProdHeight'] = number_format($arrData['prodheight'], GetConfig('DecimalPlaces'), GetConfig('DecimalToken'), "");
         }
         if (CFloat($arrData['proddepth']) > 0) {
             $GLOBALS['ProdDepth'] = number_format($arrData['proddepth'], GetConfig('DecimalPlaces'), GetConfig('DecimalToken'), "");
         }
         if (CFloat($arrData['prodfixedshippingcost']) > 0) {
             $GLOBALS['ProdFixedShippingCost'] = number_format($arrData['prodfixedshippingcost'], GetConfig('DecimalPlaces'), GetConfig('DecimalToken'), "");
         }
         if ($arrData['prodfreeshipping'] == 1) {
             $GLOBALS['FreeShipping'] = 'checked="checked"';
         }
         if ($arrData['prodrelatedproducts'] == -1) {
             $GLOBALS['IsProdRelatedAuto'] = 'checked="checked"';
         } else {
             if (isset($arrData['prodrelated'])) {
                 $GLOBALS['RelatedProductOptions'] = "";
                 foreach ($arrData['prodrelated'] as $r) {
                     $GLOBALS['RelatedProductOptions'] .= sprintf("<option value='%d'>%s</option>", (int) $r[0], isc_html_escape($r[1]));
                 }
             }
         }
         $GLOBALS['ProdTags'] = $arrData['prodtags'];
         $GLOBALS['CurrentStockLevel'] = $arrData['prodcurrentinv'];
         $GLOBALS['LowStockLevel'] = $arrData['prodlowinv'];
         $GLOBALS["InvTrack_" . $arrData['prodinvtrack']] = 'checked="checked"';
         $GLOBALS['WrappingOptions'] = $this->BuildGiftWrappingSelect(explode(',', $arrData['prodwrapoptions']));
         $GLOBALS['HideGiftWrappingOptions'] = 'display: none';
         if ($arrData['prodwrapoptions'] == 0) {
             $GLOBALS['WrappingOptionsDefaultChecked'] = 'checked="checked"';
         } else {
             if ($arrData['prodwrapoptions'] == -1) {
                 $GLOBALS['WrappingOptionsNoneChecked'] = 'checked="checked"';
             } else {
                 $GLOBALS['HideGiftWrappingOptions'] = '';
                 $GLOBALS['WrappingOptionsCustomChecked'] = 'checked="checked"';
             }
         }
         if ($arrData['prodinvtrack'] == 1) {
             $GLOBALS['OptionButtons'] = "ToggleProductInventoryOptions(true);";
         } else {
             $GLOBALS['OptionButtons'] = "ToggleProductInventoryOptions(false);";
         }
         if ($arrData['prodoptionsrequired'] == 1) {
             $GLOBALS['OptionsRequired'] = 'checked="checked"';
         }
         if ($arrData['prodtype'] == 1) {
             $GLOBALS['HideProductInventoryOptions'] = "none";
         }
         $GLOBALS['EnterOptionPrice'] = sprintf(GetLang('EnterOptionPrice'), GetConfig('CurrencyToken'), GetConfig('CurrencyToken'));
         $GLOBALS['EnterOptionWeight'] = sprintf(GetLang('EnterOptionWeight'), GetConfig('WeightMeasurement'));
         $GLOBALS['HideCustomFieldLink'] = "none";
         if (GetConfig('PricesIncludeTax')) {
             $GLOBALS['PriceMsg'] = GetLang('IncTax');
         } else {
             $GLOBALS['PriceMsg'] = GetLang('ExTax');
         }
         $GLOBALS['CustomFields'] = '';
         $GLOBALS['CustomFieldKey'] = 0;
         if (!empty($arrCustomFields)) {
             foreach ($arrCustomFields as $f) {
                 $GLOBALS['CustomFieldName'] = isc_html_escape($f['name']);
                 $GLOBALS['CustomFieldValue'] = isc_html_escape($f['value']);
                 $GLOBALS['CustomFieldLabel'] = $this->GetFieldLabel($GLOBALS['CustomFieldKey'] + 1, GetLang('CustomField'));
                 if (!$GLOBALS['CustomFieldKey']) {
                     $GLOBALS['HideCustomFieldDelete'] = 'none';
                 } else {
                     $GLOBALS['HideCustomFieldDelete'] = '';
                 }
                 $GLOBALS['CustomFields'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('CustomFields');
                 $GLOBALS['CustomFieldKey']++;
             }
         }
         // Add one more custom field
         $GLOBALS['CustomFieldName'] = '';
         $GLOBALS['CustomFieldValue'] = '';
         $GLOBALS['CustomFieldLabel'] = $this->GetFieldLabel($GLOBALS['CustomFieldKey'] + 1, GetLang('CustomField'));
         if (!$GLOBALS['CustomFieldKey']) {
             $GLOBALS['HideCustomFieldDelete'] = 'none';
         } else {
             $GLOBALS['HideCustomFieldDelete'] = '';
         }
         $GLOBALS['CustomFields'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('CustomFields');
         if ($this->HasGD()) {
             $GLOBALS['ShowGDThumb'] = "";
             $GLOBALS['ShowNoGDThumb'] = "none";
         } else {
             $GLOBALS['ShowGDThumb'] = "none";
             $GLOBALS['ShowNoGDThumb'] = "";
         }
         // Get a list of any downloads associated with this product
         $GLOBALS['DownloadsGrid'] = $this->GetDownloadsGrid(0, $GLOBALS['ProductHash']);
         $GLOBALS['ISC_LANG']['MaxUploadSize'] = sprintf(GetLang('MaxUploadSize'), GetMaxUploadSize());
         if ($GLOBALS['DownloadsGrid'] == '') {
             $GLOBALS['DisplayDownloaadGrid'] = "none";
         }
         // Get the brands as select options
         $GLOBALS['ISC_CLASS_ADMIN_BRANDS'] = GetClass('ISC_ADMIN_BRANDS');
         $GLOBALS['BrandNameOptions'] = $GLOBALS['ISC_CLASS_ADMIN_BRANDS']->GetBrandsAsOptions($arrData['prodbrandid']);
         $GLOBALS['SaveAndAddAnother'] = GetLang('SaveAndAddAnother');
         // Get a list of all layout files
         $layoutFile = 'product.html';
         if ($arrData['prodlayoutfile'] != '') {
             $layoutFile = $arrData['prodlayoutfile'];
         }
         $GLOBALS['LayoutFiles'] = GetCustomLayoutFilesAsOptions("product.html", $layoutFile);
         $GLOBALS['ProdPageTitle'] = isc_html_escape($arrData['prodpagetitle']);
         $GLOBALS['ProdMetaKeywords'] = isc_html_escape($arrData['prodmetakeywords']);
         $GLOBALS['ProdMetaDesc'] = isc_html_escape($arrData['prodmetadesc']);
         $GLOBALS['SaveAndAddAnother'] = GetLang('SaveAndAddAnother');
         if (!gzte11(ISC_MEDIUMPRINT)) {
             $GLOBALS['HideInventoryOptions'] = "none";
         } else {
             $GLOBALS['HideInventoryOptions'] = '';
         }
         // Does this product have a variation assigned to it?
         $GLOBALS['ProductVariationExisting'] = $arrData['prodvariationid'];
         if ($arrData['prodvariationid'] > 0) {
             $GLOBALS['IsYesVariation'] = 'checked="checked"';
         } else {
             $GLOBALS['IsNoVariation'] = 'checked="checked"';
             $GLOBALS['HideVariationList'] = "none";
             $GLOBALS['HideVariationCombinationList'] = "none";
         }
         // If there are no variations then disable the option to choose one
         $numVariations = 0;
         $GLOBALS['VariationOptions'] = $this->GetVariationsAsOptions($numVariations, $arrData['prodvariationid']);
         if ($numVariations == 0) {
             $GLOBALS['VariationDisabled'] = "DISABLED";
             $GLOBALS['VariationColor'] = "#CACACA";
             $GLOBALS['IsNoVariation'] = 'checked="checked"';
             $GLOBALS['IsYesVariation'] = "";
             $GLOBALS['HideVariationCombinationList'] = "none";
         } else {
             // Load the variation combinations
             if ($arrData['prodinvtrack'] == 2) {
                 $show_inv_fields = true;
             } else {
                 $show_inv_fields = false;
             }
             /**
              * We'll need to duplicate the variation combinations here if we are NOT preserving the post
              */
             if (!$PreservePost) {
                 $this->_CopyVariationData($arrData['productid'], 0, $GLOBALS['ProductHash']);
             }
             $GLOBALS['VariationCombinationList'] = $this->_LoadVariationCombinationsTable($arrData['prodvariationid'], $show_inv_fields, 0, $GLOBALS['ProductHash']);
         }
         if (!gzte11(ISC_HUGEPRINT)) {
             $GLOBALS['HideVendorOption'] = 'display: none';
         } else {
             $vendorData = $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendor();
             if (isset($vendorData['vendorid'])) {
                 $GLOBALS['HideVendorSelect'] = 'display: none';
                 $GLOBALS['CurrentVendor'] = isc_html_escape($vendorData['vendorname']);
             } else {
                 $GLOBALS['HideVendorLabel'] = 'display: none';
                 $GLOBALS['VendorList'] = $this->BuildVendorSelect($arrData['prodvendorid']);
             }
         }
         // Display the discount rules
         if ($PreservePost == true) {
             $GLOBALS['DiscountRules'] = $this->GetDiscountRules($prodId);
         } else {
             $GLOBALS['DiscountRules'] = $this->GetDiscountRules(0);
         }
         // Hide if we are not enabled
         if (!GetConfig('BulkDiscountEnabled')) {
             $GLOBALS['HideDiscountRulesWarningBox'] = '';
             $GLOBALS['DiscountRulesWarningText'] = GetLang('DiscountRulesNotEnabledWarning');
             $GLOBALS['DiscountRulesWithWarning'] = 'none';
             // Also hide it if this product has variations
         } else {
             if (isset($arrData['prodvariationid']) && isId($arrData['prodvariationid'])) {
                 $GLOBALS['HideDiscountRulesWarningBox'] = '';
                 $GLOBALS['DiscountRulesWarningText'] = GetLang('DiscountRulesVariationWarning');
                 $GLOBALS['DiscountRulesWithWarning'] = 'none';
             } else {
                 $GLOBALS['HideDiscountRulesWarningBox'] = 'none';
                 $GLOBALS['DiscountRulesWithWarning'] = '';
             }
         }
         $GLOBALS['DiscountRulesEnabled'] = (int) GetConfig('BulkDiscountEnabled');
         $GLOBALS['EventDateFieldName'] = $arrData['prodeventdatefieldname'];
         if ($GLOBALS['EventDateFieldName'] == null) {
             $GLOBALS['EventDateFieldName'] = GetLang('EventDateDefault');
         }
         if ($arrData['prodeventdaterequired'] == 1) {
             $GLOBALS['EventDateRequired'] = 'checked="checked"';
             $from_stamp = $arrData['prodeventdatelimitedstartdate'];
             $to_stamp = $arrData['prodeventdatelimitedenddate'];
         } else {
             $from_stamp = isc_gmmktime(0, 0, 0, isc_date("m"), isc_date("d"), isc_date("Y"));
             $to_stamp = isc_gmmktime(0, 0, 0, isc_date("m") + 1, isc_date("d"), isc_date("Y"));
         }
         if ($arrData['prodeventdatelimited'] == 1) {
             $GLOBALS['LimitDates'] = 'checked="checked"';
         }
         $GLOBALS['LimitDateOption1'] = '';
         $GLOBALS['LimitDateOption2'] = '';
         $GLOBALS['LimitDateOption3'] = '';
         switch ($arrData['prodeventdatelimitedtype']) {
             case 1:
                 $GLOBALS['LimitDateOption1'] = 'selected="selected"';
                 break;
             case 2:
                 $GLOBALS['LimitDateOption2'] = 'selected="selected"';
                 break;
             case 3:
                 $GLOBALS['LimitDateOption3'] = 'selected="selected"';
                 break;
         }
         // Set the global variables for the select boxes
         $from_day = isc_date("d", $from_stamp);
         $from_month = isc_date("m", $from_stamp);
         $from_year = isc_date("Y", $from_stamp);
         $to_day = isc_date("d", $to_stamp);
         $to_month = isc_date("m", $to_stamp);
         $to_year = isc_date("Y", $to_stamp);
         $GLOBALS['OverviewFromDays'] = $this->_GetDayOptions($from_day);
         $GLOBALS['OverviewFromMonths'] = $this->_GetMonthOptions($from_month);
         $GLOBALS['OverviewFromYears'] = $this->_GetYearOptions($from_year);
         $GLOBALS['OverviewToDays'] = $this->_GetDayOptions($to_day);
         $GLOBALS['OverviewToMonths'] = $this->_GetMonthOptions($to_month);
         $GLOBALS['OverviewToYears'] = $this->_GetYearOptions($to_year);
         if (!$GLOBALS['ISC_CLASS_ADMIN_AUTH']->HasPermission(AUTH_Create_Category)) {
             $GLOBALS['HideCategoryCreation'] = 'display: none';
         }
         $GLOBALS['SaveAndAddAnother'] = GetLang('SaveAndAddAnother');
         $GLOBALS["ISC_CLASS_TEMPLATE"]->SetTemplate("product.form");
         $GLOBALS["ISC_CLASS_TEMPLATE"]->ParseTemplate();
     } else {
         // The product doesn't exist
         if ($GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Manage_Products)) {
             $this->ManageProducts(GetLang('ProductDoesntExist'), MSG_ERROR);
         } else {
             $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->DoHomePage(GetLang('Unauthorized'), MSG_ERROR);
         }
     }
 }
    /**
     * Generate the payment form to collect payment details and pass them back
     * to the payment provider.
     *
     * @return string The generated payment form.
     */
    public function ShowPaymentForm()
    {
        // Authorize.net needs HTTPS, so if it's not on then stop
        if (!strtolower($_SERVER['HTTPS']) == "on") {
            ob_end_clean();
            ?>
					<script type="text/javascript">
						alert("<?php 
            echo GetLang('AuthorizeNetNoSSLError');
            ?>
");
						document.location.href="<?php 
            echo $GLOBALS['ShopPath'];
            ?>
/checkout.php?action=confirm_order";
					</script>
				<?php 
            die;
        }
        $GLOBALS['AuthorizeNetMonths'] = "";
        $GLOBALS['AuthorizeNetYears'] = "";
        for ($i = 1; $i <= 12; $i++) {
            $stamp = mktime(0, 0, 0, $i, 15, isc_date("Y"));
            $i = str_pad($i, 2, "0", STR_PAD_LEFT);
            if (@$_POST['AuthorizeNet_ccexpm'] == $i) {
                $sel = 'selected="selected"';
            } else {
                $sel = "";
            }
            $GLOBALS['AuthorizeNetMonths'] .= sprintf("<option %s value='%s'>%s</option>", $sel, $i, isc_date("M", $stamp));
        }
        for ($i = isc_date("Y"); $i < isc_date("Y") + 10; $i++) {
            if (@$_POST['AuthorizeNet_ccexpy'] == substr($i, 2, 2)) {
                $sel = 'selected="selected"';
            } else {
                $sel = "";
            }
            $GLOBALS['AuthorizeNetYears'] .= sprintf("<option %s value='%s'>%s</option>", $sel, substr($i, 2, 2), $i);
        }
        $require_cvv2 = $this->GetValue("requirecvv2");
        if ($require_cvv2 == "YES") {
            if (isset($_POST['AuthorizeNet_cccode'])) {
                $GLOBALS['AuthorizeNetCCV2'] = (int) $_POST['AuthorizeNet_cccode'];
            }
            $GLOBALS['AuthorizeNetHideCVV2'] = '';
        } else {
            $GLOBALS['AuthorizeNetHideCVV2'] = 'none';
        }
        // Grab the billing details for the order
        $billingDetails = $this->GetBillingDetails();
        $GLOBALS['AuthorizeNetName'] = isc_html_escape($billingDetails['ordbillfirstname'] . ' ' . $billingDetails['ordbilllastname']);
        $GLOBALS['AuthorizeNetBillingAddress'] = isc_html_escape($billingDetails['ordbillstreet1']);
        if ($billingDetails['ordbillstreet2'] != "") {
            $GLOBALS['AuthorizeNetBillingAddress'] .= " " . isc_html_escape($billingDetails['ordbillstreet2']);
        }
        $GLOBALS['AuthorizeNetCity'] = isc_html_escape($billingDetails['ordbillsuburb']);
        if ($billingDetails['ordbillstateid'] != 0 && GetStateISO2ById($billingDetails['ordbillstateid'])) {
            $GLOBALS['AuthorizeNetState'] = GetStateISO2ById($billingDetails['ordbillstateid']);
        } else {
            $GLOBALS['AuthorizeNetState'] = isc_html_escape($billingDetails['ordbillstate']);
        }
        $GLOBALS['AuthorizeNetBillingZip'] = isc_html_escape($billingDetails['ordbillzip']);
        // Format the amount that's going to be going through the gateway
        $GLOBALS['OrderAmount'] = CurrencyConvertFormatPrice($this->GetGatewayAmount());
        // Was there an error validating the payment? If so, pre-fill the form fields with the already-submitted values
        if ($this->HasErrors()) {
            $GLOBALS['AuthorizeNetName'] = isc_html_escape($_POST['AuthorizeNet_name']);
            $GLOBALS['AuthorizeNetNum'] = isc_html_escape($_POST['AuthorizeNet_ccno']);
            $GLOBALS['AuthorizeNetBillingAddress'] = isc_html_escape($_POST['AuthorizeNet_ccaddress']);
            $GLOBALS['AuthorizeNetCity'] = isc_html_escape($_POST['AuthorizeNet_cccity']);
            $GLOBALS['AuthorizeNetState'] = isc_html_escape($_POST['AuthorizeNet_ccstate']);
            $GLOBALS['AuthorizeNetBillingZip'] = isc_html_escape($_POST['AuthorizeNet_zip']);
            $GLOBALS['AuthorizeNetErrorMessage'] = implode("<br />", $this->GetErrors());
        } else {
            // Hide the error message box
            $GLOBALS['HideAuthorizeNetError'] = "none";
        }
        // Collect their details to send through to Authorize.NET
        $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("authorizenet");
        return $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate(true);
    }
Example #12
0
		/**
		*	Show the details of an order and allow them to print an invoice
		*/
		private function ViewOrderDetails()
		{
			$GLOBALS['SNIPPETS']['AccountOrderItemRow'] = "";
			$count = 0;

			if (!isset($_GET['order_id']) || !is_numeric($_GET['order_id'])) {
				redirect('account.php?action=view_orders');
			}

			$GLOBALS['FlassMessage'] = GetFlashMessageBoxes();

			// Retrieve the completed order that matches the customers user id
			$orderId = (int)$_GET['order_id'];
			$GLOBALS['OrderId'] = $orderId;

			$customerId = getClass('ISC_CUSTOMER')->getcustomerId();
			$query = "
				SELECT *, (
						SELECT CONCAT(custconfirstname, ' ', custconlastname)
						FROM [|PREFIX|]customers
						WHERE customerid=ordcustid
					) AS custname, (
						SELECT statusdesc
						FROM [|PREFIX|]order_status
						WHERE statusid=ordstatus
					) AS ordstatustext
				FROM [|PREFIX|]orders
				WHERE ordcustid='".(int)$customerId."' AND orderid='".(int)$orderId."' AND deleted = 0
			";
			$result = $GLOBALS['ISC_CLASS_DB']->query($query);
			$row = $GLOBALS['ISC_CLASS_DB']->fetch($result);
			if(!$row) {
				redirect('account.php?action=view_orders');
			}

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

			$order = $row;

			// Fetch the shipping addresses for this order
			$addresses = array();
			$query = "
				SELECT *
				FROM [|PREFIX|]order_addresses
				WHERE order_id='".$order['orderid']."'
			";
			$result = $GLOBALS['ISC_CLASS_DB']->query($query);
			while($address = $GLOBALS['ISC_CLASS_DB']->fetch($result)) {
				$addresses[$address['id']] = $address;
			}

			// Fetch the shipping details for the order
			$query = "
				SELECT *
				FROM [|PREFIX|]order_shipping
				WHERE order_id=".$order['orderid'];
			$result = $GLOBALS['ISC_CLASS_DB']->query($query);
			while($shipping = $GLOBALS['ISC_CLASS_DB']->fetch($result)) {
				$addresses[$shipping['order_address_id']]['shipping'] = $shipping;
			}

			$GLOBALS['OrderComments'] = '';
			if($row['ordcustmessage'] != '') {
				$GLOBALS['OrderComments'] = nl2br(isc_html_escape($row['ordcustmessage']));
			}
			else {
				$GLOBALS['HideOrderComments'] = 'display: none';
			}

			if(OrderIsComplete($row['ordstatus'])) {
				if (!gzte11(ISC_LARGEPRINT)) {
					$GLOBALS['DisableReturnButton'] = "none";
				}

				if ($row['ordstatus'] == 4 || GetConfig('EnableReturns') == 0) {
					$GLOBALS['DisableReturnButton'] = "none";
				}

				$GLOBALS['HideOrderStatus'] = "none";
				$orderComplete = true;
			}
			else {
				$GLOBALS['HideOrderStatus'] = '';
				$GLOBALS['OrderStatus'] = $row['ordstatustext'];
				$GLOBALS['DisableReturnButton'] = "none";
				$orderComplete = false;
			}

			// Hide print order invoive if it's a incomplete order
			$GLOBALS['ShowOrderActions'] = '';
			if(!$row['ordstatus']) {
				$GLOBALS['ShowOrderActions'] = 'display:none';
			}

			$GLOBALS['OrderDate'] = isc_date(GetConfig('ExtendedDisplayDateFormat'), $row['orddate']);

			$GLOBALS['OrderTotal'] = CurrencyConvertFormatPrice($row['total_inc_tax'], $row['ordcurrencyid'], $row['ordcurrencyexchangerate'], true);

			// Format the billing address
			$GLOBALS['ShipFullName'] = isc_html_escape($row['ordbillfirstname'].' '.$row['ordbilllastname']);
			$GLOBALS['ShipCompany'] = '';
			if($row['ordbillcompany']) {
				$GLOBALS['ShipCompany'] = '<br />'.isc_html_escape($row['ordbillcompany']);
			}

			$GLOBALS['ShipAddressLines'] = isc_html_escape($row['ordbillstreet1']);

			if ($row['ordbillstreet2'] != "") {
				$GLOBALS['ShipAddressLines'] .= '<br />' . isc_html_escape($row['ordbillstreet2']);
			}

			$GLOBALS['ShipSuburb'] = isc_html_escape($row['ordbillsuburb']);
			$GLOBALS['ShipState'] = isc_html_escape($row['ordbillstate']);
			$GLOBALS['ShipZip'] = isc_html_escape($row['ordbillzip']);
			$GLOBALS['ShipCountry'] = isc_html_escape($row['ordbillcountry']);
			$GLOBALS['ShipPhone'] = "";
			$GLOBALS['BillingAddress'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("AddressLabel");

			// Is there a shipping address, or is it a digital download?
			if ($order['ordisdigital']) {
				$GLOBALS['HideSingleShippingAddress'] = 'display: none';
			}
			else if ($order['shipping_address_count'] > 1) {
				$GLOBALS['ShippingAddress'] = GetLang('OrderWillBeShippedToMultipleAddresses');
				$GLOBALS['HideItemDetailsHeader'] = 'display:none;';
			}
			else {
				$shippingAddress = current($addresses);
				$GLOBALS['ShipFullName'] = isc_html_escape($shippingAddress['first_name'].' '.$shippingAddress['last_name']);

				$GLOBALS['ShipCompany'] = '';
				if($shippingAddress['company']) {
					$GLOBALS['ShipCompany'] = '<br />'.isc_html_escape($shippingAddress['company']);
				}

				$GLOBALS['ShipAddressLines'] = isc_html_escape($shippingAddress['address_1']);

				if ($shippingAddress['address_2'] != "") {
					$GLOBALS['ShipAddressLines'] .= '<br />' . isc_html_escape($shippingAddress['address_2']);
				}

				$GLOBALS['ShipSuburb'] = isc_html_escape($shippingAddress['city']);
				$GLOBALS['ShipState'] = isc_html_escape($shippingAddress['state']);
				$GLOBALS['ShipZip'] = isc_html_escape($shippingAddress['zip']);
				$GLOBALS['ShipCountry'] = isc_html_escape($shippingAddress['country']);

				$GLOBALS['ShipPhone'] = "";
				$GLOBALS['ShippingAddress'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("AddressLabel");
			}

			$itemTotalColumn = 'total_ex_tax';
			if(getConfig('taxDefaultTaxDisplayOrders') == TAX_PRICES_DISPLAY_INCLUSIVE) {
				$itemTotalColumn = 'total_inc_tax';
			}

			$GLOBALS['OrderTotalRows'] = '';
			$totalRows = getOrderTotalRows($order);
			foreach($totalRows as $id => $totalRow) {
				$GLOBALS['ISC_CLASS_TEMPLATE']->assign('label', $totalRow['label']);
				$GLOBALS['ISC_CLASS_TEMPLATE']->assign('classNameAppend', ucfirst($id));
				$value = currencyConvertFormatPrice(
					$totalRow['value'],
					$row['ordcurrencyid'],
					$row['ordcurrencyexchangerate']
				);
				$GLOBALS['ISC_CLASS_TEMPLATE']->assign('value', $value);
				$GLOBALS['OrderTotalRows'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->getSnippet('AccountOrderTotalRow');
			}

			$OrderProducts = array();
			$ProductIds = array();
			// Load up the items in this order
			$query = "
				SELECT
					o.*,
					op.*,
					oa.address_1,
					oa.address_2,
					oa.city,
					oa.zip,
					oa.country,
					oa.state,
					p.productid,
					p.prodpreorder,
					p.prodreleasedate,
					p.prodpreordermessage
				FROM
					[|PREFIX|]orders o
					LEFT JOIN [|PREFIX|]order_products op ON op.orderorderid
					LEFT JOIN [|PREFIX|]products p ON p.productid = op.ordprodid
					LEFT JOIN [|PREFIX|]order_addresses oa ON oa.`id` = op.order_address_id
				WHERE
					orderorderid = " . (int)$order['orderid'] ."
				ORDER BY
					op.order_address_id";
			$result = $GLOBALS['ISC_CLASS_DB']->Query($query);

			//check if products are reorderable
			while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
				$OrderProducts[$row['orderprodid']] = $row;
				$ProductIds[] = $row['ordprodid'];
			}

			$UnreorderableProducts = $this->GetUnreorderableProducts($OrderProducts, $ProductIds);

			// for grouping of shipping addresses in template output
			$previousAddressId = null;
			$destinationCounter = 0;

			foreach ($OrderProducts as $row) {
				if ($count++ % 2 != 0) {
					$GLOBALS['ItemClass'] = "OrderItem2";
				} else {
					$GLOBALS['ItemClass'] = "OrderItem1";
				}

				$GLOBALS['OrderProductId'] = $row['orderprodid'];
				$GLOBALS['DisableReorder'] = '';

				$GLOBALS['ReorderMessage'] = "";
				$GLOBALS['HideItemMessage'] = 'display:none;';
				if(isset($UnreorderableProducts[$row['orderprodid']])) {
					$GLOBALS['DisableReorder'] = 'Disabled';
					$GLOBALS['ReorderMessage'] = $UnreorderableProducts[$row['orderprodid']];
					if(isset($_REQUEST['reorder']) && $_REQUEST['reorder']==1) {
						$GLOBALS['HideItemMessage'] = '';
					}
				}

				$GLOBALS['Qty'] = (int) $row['ordprodqty'];
				$GLOBALS['Name'] = isc_html_escape($row['ordprodname']);
				$GLOBALS['EventDate'] = '';

				if ($row['ordprodeventdate'] != 0) {
					$GLOBALS['EventDate'] = $row['ordprodeventname'] . ': '. isc_date('M jS Y', $row['ordprodeventdate']);
				}

				// Does the product still exist or has it been deleted?
				$prod_name = GetProdNameById($row['ordprodid']);

				if ($prod_name == "" && $row['ordprodtype'] == 'giftcertificate') {
					$GLOBALS['Link'] = "javascript:product_giftcertificate()";
					$GLOBALS['Target'] = "";
				}else if ($prod_name == "") {
					$GLOBALS['Link'] = "javascript:product_removed()";
					$GLOBALS['Target'] = "";
				}
				else {
					$GLOBALS['Link'] = ProdLink(GetProdNameById($row['ordprodid']));
					$GLOBALS['Target'] = "_blank";
				}

				$GLOBALS['DownloadsLink'] = '';
				if ($row['ordprodtype'] == "digital" && $orderComplete) {
					$GLOBALS['DownloadItemEncrypted'] = $this->EncryptDownloadKey($row['orderprodid'], $row['ordprodid'], $row['orderorderid'], $row['ordtoken']);
					$GLOBALS['DownloadsLink'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("AccountOrderItemDownloadLink");
				}

				$GLOBALS['Refunded'] = '';
				$GLOBALS['StrikeEnd'] = '';
				$GLOBALS['StrikeStart'] = '';

				if ($row['ordprodrefunded'] > 0) {
					if ($row['ordprodrefunded'] == $row['ordprodqty']) {
						$GLOBALS['StrikeStart'] = "<s>";
						$GLOBALS['StrikeEnd'] = "</s>";
						$GLOBALS['Refunded'] = '<span class="Refunded">'.GetLang('OrderProductRefunded').'</span>';
					}
					else {
						$GLOBALS['Refunded'] = '<span class="Refunded">'.sprintf(GetLang('OrderProductsRefundedX'), $row['ordprodrefunded']).'</span>';
					}
				}

				$GLOBALS['Price'] = CurrencyConvertFormatPrice(
					$row[$itemTotalColumn],
					$order['ordcurrencyid'],
					$order['ordcurrencyexchangerate']
				);

				// Were there one or more options selected?
				$GLOBALS['ProductOptions'] = '';
				if($row['ordprodoptions'] != '') {
					$options = @unserialize($row['ordprodoptions']);
					if(!empty($options)) {
						$GLOBALS['ProductOptions'] = "<br /><small class='OrderItemOptions'>(";
						$comma = '';
						foreach($options as $name => $value) {
							$GLOBALS['ProductOptions'] .= $comma.isc_html_escape($name).": ".isc_html_escape($value);
							$comma = ', ';
						}
						$GLOBALS['ProductOptions'] .= ")</small>";
					}
				}

				if($row['ordprodwrapname']) {
					$GLOBALS['GiftWrappingName'] = isc_html_escape($row['ordprodwrapname']);
					$GLOBALS['HideWrappingOptions'] = '';
				}
				else {
					$GLOBALS['GiftWrappingName'] = '';
					$GLOBALS['HideWrappingOptions'] = 'display: none';
				}

				$GLOBALS['HideExpectedReleaseDate'] = 'display:none;';
				$GLOBALS['ExpectedReleaseDate'] = '';

				if ($row['prodpreorder']) {
					if ($row['prodreleasedate']) {
						$message = $row['prodpreordermessage'];
						if (!$message) {
							$message = GetConfig('DefaultPreOrderMessage');
						}
						$GLOBALS['ExpectedReleaseDate'] = '(' . str_replace('%%DATE%%', isc_date(GetConfig('DisplayDateFormat'), $row['prodreleasedate']), $message) . ')';
					} else {
						$GLOBALS['ExpectedReleaseDate'] = '(' . GetLang('PreOrderProduct') . ')';
					}
					$GLOBALS['HideExpectedReleaseDate'] = '';
				}

				$GLOBALS['ItemShippingRow'] = '';
				if ($order['shipping_address_count'] > 1 && ($previousAddressId != $row['order_address_id'])) {
					$destinationCounter++;

					$GLOBALS['Destination_Number'] = GetLang('Destination_Number', array('number' => $destinationCounter));

					$addressLine = array_filter(array(
						$row['address_1'],
						$row['address_2'],
						$row['city'],
						$row['state'],
						$row['zip'],
						$row['country'],
					));

					$GLOBALS['ItemShippingRow_AddressLine'] = Store_String::rightTruncate(implode(', ', $addressLine), 60);

					$GLOBALS['ItemShippingRow'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('AccountOrderItemShippingRow');
				}

				$GLOBALS['SNIPPETS']['AccountOrderItemRow'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("AccountOrderItemRow");
				$previousAddressId = $row['order_address_id'];
			}

			$GLOBALS['ISC_CLASS_TEMPLATE']->SetPageTitle(sprintf("%s - %s%d", GetConfig('StoreName'), GetLang('OrderIdHash'), $orderId));
			$GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("account_order");
			$GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate();
		}
Example #13
0
 public function SetPanelSettings()
 {
     $_SESSION['you_save'] = 0;
     //blessen
     $GLOBALS['SNIPPETS']['CartItems'] = "";
     $count = 0;
     $subtotal = 0;
     $_SESSION['CHECKOUT'] = array();
     // Get a list of all products in the cart
     $GLOBALS['ISC_CLASS_CART'] = GetClass('ISC_CART');
     $product_array = $GLOBALS['ISC_CLASS_CART']->api->GetProductsInCart();
     /* $cprint = print_r($product_array, true);     
        $q      = "INSERT INTO isc_orderlogs (`ordervalue`) VALUES ('$cprint')";
        $r      = $GLOBALS["ISC_CLASS_DB"]->Query($q); */
     $GLOBALS['AdditionalCheckoutButtons'] = '';
     // Go through all the checkout modules looking for one with a GetSidePanelCheckoutButton function defined
     $ShowCheckoutButton = false;
     if (!empty($product_array)) {
         foreach (GetAvailableModules('checkout', true, true) as $module) {
             if (isset($module['object']->_showBothButtons) && $module['object']->_showBothButtons) {
                 $ShowCheckoutButton = true;
                 $GLOBALS['AdditionalCheckoutButtons'] .= $module['object']->GetCheckoutButton();
             } elseif (method_exists($module['object'], 'GetCheckoutButton')) {
                 $GLOBALS['AdditionalCheckoutButtons'] .= $module['object']->GetCheckoutButton();
             } else {
                 $ShowCheckoutButton = true;
             }
         }
     }
     $GLOBALS['HideMultipleAddressShipping'] = 'display: none';
     if (gzte11(ISC_MEDIUMPRINT) && $GLOBALS['ISC_CLASS_CART']->api->GetNumPhysicalProducts() > 1 && $ShowCheckoutButton && GetConfig("MultipleShippingAddresses")) {
         $GLOBALS['HideMultipleAddressShipping'] = '';
     }
     $GLOBALS['HideCheckoutButton'] = '';
     if (!$ShowCheckoutButton) {
         $GLOBALS['HideCheckoutButton'] = 'display: none';
         $GLOBALS['HideMultipleAddressShippingOr'] = 'display: none';
     }
     $wrappingOptions = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('GiftWrapping');
     if (empty($wrappingOptions)) {
         $publicWrappingOptions = false;
     } else {
         $publicWrappingOptions = true;
     }
     if (!GetConfig('ShowThumbsInCart')) {
         $GLOBALS['HideThumbColumn'] = 'display: none';
         $GLOBALS['ProductNameSpan'] = 2;
     } else {
         $GLOBALS['HideThumbColumn'] = '';
         $GLOBALS['ProductNameSpan'] = 1;
     }
     $wrappingAdjustment = 0;
     $itemTotal = 0;
     $comptotal = 0;
     # To get all the complementary product total -- Baskaran
     $compprice = 0;
     foreach ($product_array as $k => $product) {
         $GLOBALS['CartItemId'] = (int) $product['cartitemid'];
         // If the item in the cart is a gift certificate, we need to show a special type of row
         if (isset($product['type']) && $product['type'] == "giftcertificate") {
             $GLOBALS['GiftCertificateName'] = isc_html_escape($product['data']['prodname']);
             $GLOBALS['GiftCertificateAmount'] = CurrencyConvertFormatPrice($product['giftamount']);
             $GLOBALS['GiftCertificateTo'] = isc_html_escape($product['certificate']['to_name']);
             $GLOBALS["Quantity" . $product['quantity']] = 'selected="selected"';
             $GLOBALS['ProductPrice'] = CurrencyConvertFormatPrice($product['giftamount']);
             $GLOBALS['ProductTotal'] = CurrencyConvertFormatPrice($product['giftamount'] * $product['quantity']);
             $itemTotal += $product['giftamount'] * $product['quantity'];
             $GLOBALS['SNIPPETS']['CartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItemGiftCertificate");
         } else {
             $GLOBALS['ProductLink'] = ProdLink($product['data']['prodname']);
             $GLOBALS['ProductAvailability'] = isc_html_escape($product['data']['prodavailability']);
             $GLOBALS['ItemId'] = (int) $product['data']['productid'];
             $GLOBALS['VariationId'] = (int) $product['variation_id'];
             $GLOBALS['ProductQuantity'] = (int) $product['quantity'];
             //blessen
             $GLOBALS['prodretailprice'] = CurrencyConvertFormatPrice($product['data']['prodretailprice']);
             if ($product['data']['prodretailprice'] > $product['data']['prodcalculatedprice']) {
                 $_SESSION['you_save'] += ($product['data']['prodretailprice'] - $product['data']['prodcalculatedprice']) * $product['quantity'];
             }
             //$GLOBALS['saveprice'] =  CurrencyConvertFormatPrice($product['data']['prodretailprice'] - $product['data']['prodcalculatedprice']);
             //blessen
             // Should we show thumbnails in the cart?
             if (GetConfig('ShowThumbsInCart')) {
                 $GLOBALS['ProductImage'] = ImageThumb($product['data']['imagefile'], ProdLink($product['data']['prodname']));
             }
             $GLOBALS['UpdateCartQtyJs'] = "Cart.UpdateQuantity(this.options[this.selectedIndex].value);";
             $GLOBALS['HideCartProductFields'] = 'display:none;';
             $GLOBALS['CartProductFields'] = '';
             $this->GetProductFieldDetails($product['product_fields'], $k);
             $GLOBALS['EventDate'] = '';
             if (isset($product['event_date'])) {
                 $GLOBALS['EventDate'] = '<div style="font-style: italic; font-size:10px; color:gray">(' . $product['event_name'] . ': ' . isc_date('M jS Y', $product['event_date']) . ')</div>';
             }
             // Can this product be wrapped?
             $GLOBALS['GiftWrappingName'] = '';
             $GLOBALS['HideGiftWrappingAdd'] = '';
             $GLOBALS['HideGiftWrappingEdit'] = 'display: none';
             $GLOBALS['HideGiftWrappingPrice'] = 'display: none';
             $GLOBALS['GiftWrappingPrice'] = '';
             $GLOBALS['GiftMessagePreview'] = '';
             $GLOBALS['HideGiftMessagePreview'] = 'display: none';
             $GLOBALS['HideWrappingOptions'] = 'display: none';
             if ($product['data']['prodtype'] == PT_PHYSICAL && $product['data']['prodwrapoptions'] != -1 && $publicWrappingOptions == true) {
                 $GLOBALS['HideWrappingOptions'] = '';
                 if (isset($product['wrapping'])) {
                     $GLOBALS['GiftWrappingName'] = isc_html_escape($product['wrapping']['wrapname']);
                     $GLOBALS['HideGiftWrappingAdd'] = 'display: none';
                     $GLOBALS['HideGiftWrappingEdit'] = '';
                     $GLOBALS['HideGiftWrappingPrice'] = '';
                     $wrappingAdjustment += $product['wrapping']['wrapprice'] * $product['quantity'];
                     $GLOBALS['GiftWrappingPrice'] = CurrencyConvertFormatPrice($product['wrapping']['wrapprice']);
                     if (isset($product['wrapping']['wrapmessage'])) {
                         if (isc_strlen($product['wrapping']['wrapmessage']) > 30) {
                             $product['wrapping']['wrapmessage'] = substr($product['wrapping']['wrapmessage'], 0, 27) . '...';
                         }
                         $GLOBALS['GiftMessagePreview'] = isc_html_escape($product['wrapping']['wrapmessage']);
                         if ($product['wrapping']['wrapmessage']) {
                             $GLOBALS['HideGiftMessagePreview'] = '';
                         }
                     }
                 }
             }
             $subtotalPrice = 0;
             if (isset($product['discount_price'])) {
                 $subtotalPrice = $product['discount_price'];
             } else {
                 $subtotalPrice = $product['product_price'];
             }
             $GLOBALS['ShowOnSaleImage'] = '';
             if (isset($product['discount_price']) && $product['discount_price'] != $product['original_price'] && GetConfig('ShowOnSale')) {
                 $GLOBALS['ProductPrice'] = sprintf("<s class='CartStrike'>%s</s> %s", CurrencyConvertFormatPrice($product['original_price']), CurrencyConvertFormatPrice($subtotalPrice));
                 if (isset($product['discount']) && isset($product['couponcode'])) {
                     $GLOBALS['ShowOnSaleImage'] = "Coupon Applied";
                 } else {
                     $GLOBALS['ShowOnSaleImage'] = '<img id="OnSale" src="' . GetConfig('ShopPath') . '/templates/default/images/onsale.gif" alt="">';
                 }
             } else {
                 $GLOBALS['ProductPrice'] = CurrencyConvertFormatPrice($subtotalPrice);
             }
             $GLOBALS['ProductTotal'] = CurrencyConvertFormatPrice($subtotalPrice * $product['quantity']);
             $itemTotal += $subtotalPrice * $product['quantity'];
             // If we're using a cart quantity drop down, load that
             if (GetConfig('TagCartQuantityBoxes') == 'dropdown') {
                 $GLOBALS["Quantity" . $product['quantity']] = "selected=\"selected\"";
                 if (isset($GLOBALS["Quantity0"])) {
                     $GLOBALS['QtyOptionZero'] = "<option " . $GLOBALS["Quantity0"] . " value='0'>0</option>";
                 } else {
                     $GLOBALS['QtyOptionZero'] = "<option value='0'>0</option>";
                 }
                 // Fixes products being displayed with '0' quantity when the quantity is greater than 30 (hard coded limit in snippet)
                 if ($product['quantity'] > 30) {
                     $GLOBALS["QtyOptionSelected"] = "<option " . $GLOBALS["Quantity" . $product['quantity']] . " value='" . $product['quantity'] . "'>" . $product['quantity'] . "</option>";
                 }
                 $GLOBALS['CartItemQty'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItemQtySelect");
             } else {
                 $GLOBALS['CartItemQty'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItemQtyText");
             }
             // Is this product a variation?
             $GLOBALS['ProductOptions'] = '';
             if (isset($product['options']) && !empty($product['options'])) {
                 $GLOBALS['ProductOptions'] .= "<br /><small>(";
                 $comma = '';
                 foreach ($product['options'] as $name => $value) {
                     if (!trim($name) || !trim($value)) {
                         continue;
                     }
                     $GLOBALS['ProductOptions'] .= $comma . isc_html_escape($name) . ": " . isc_html_escape($value);
                     $comma = ', ';
                 }
                 $GLOBALS['ProductOptions'] .= ")</small>";
             }
             //temp script to shortern the product name
             $pid = $product['data']['productid'];
             $pcode = $product['data']['prodcode'];
             $querytemp = "SELECT prodbrandid FROM  [|PREFIX|]products where productid = " . $pid . "  ";
             $resulttemp = $GLOBALS['ISC_CLASS_DB']->Query($querytemp);
             $brand = $GLOBALS['ISC_CLASS_DB']->Fetch($resulttemp);
             if ($brand['prodbrandid'] == 37) {
                 $querytemp1 = "SELECT c.catname, c.catcombine FROM [|PREFIX|]categories \tc left join [|PREFIX|]categoryassociations ca on c.categoryid = ca.categoryid  left join [|PREFIX|]products p on ca.productid = p.productid where p.productid =  '" . $pid . "' ";
                 $resulttemp1 = $GLOBALS['ISC_CLASS_DB']->Query($querytemp1);
                 $cat = $GLOBALS['ISC_CLASS_DB']->Fetch($resulttemp1);
                 if ($cat['catcombine'] != "") {
                     $GLOBALS['ProductName'] = $cat['catcombine'] . " Part Number " . $pcode;
                 } else {
                     $GLOBALS['ProductName'] = $cat['catname'] . " Part Number " . $pcode;
                 }
             } else {
                 $GLOBALS['ProductName'] = isc_html_escape($product['data']['prodname']);
             }
             //temp script to shortern the product name
             //temp script to shortern the product name
             $GLOBALS['complementaryrow'] = '';
             $compitem = $product['compitem'];
             if ($compitem == 1) {
                 for ($y = 0; $y < count($product['complementary']); $y++) {
                     /* Added for to display the complementary product in the cart -- Baskaran */
                     $compproductid = $product['complementary'][$y]['comp_productid'];
                     $compmainproductid = $product['complementary'][$y]['comp_mainproductid'];
                     $mainproductid = $product['product_id'];
                     $GLOBALS['CompCartItemId'] = $y;
                     if ($mainproductid == $compmainproductid) {
                         $GLOBALS['CompProdName'] = $compprodname = isc_html_escape($product['complementary'][$y]['comp_product_name']);
                         $compsku = isc_html_escape($product['complementary'][$y]['comp_product_code']);
                         $compprice = $product['complementary'][$y]['comp_original_price'];
                         $GLOBALS['CompProductPrice'] = $comppriceformat = CurrencyConvertFormatPrice($product['complementary'][$y]['comp_original_price']);
                         $query = $GLOBALS["ISC_CLASS_DB"]->Query("SELECT imagefile FROM [|PREFIX|]products p LEFT JOIN [|PREFIX|]product_images i ON p.productid = i.imageprodid AND i.imageisthumb = '1' where p.productid = '{$compproductid}' AND p.prodvisible = '1' ");
                         $path = '';
                         if ($row = $GLOBALS["ISC_CLASS_DB"]->Fetch($query)) {
                             $path = $row['imagefile'];
                         }
                         if ($path != '') {
                             $GLOBALS['ProdImage'] = GetConfig('ShopPath') . "/product_images/{$path}";
                         } else {
                             $GLOBALS['ProdImage'] = GetConfig('ShopPath') . "/templates/CongoWorld/images/ProductDefault.gif";
                         }
                         //Added for complementary products - By Simha..
                         // If we're using a cart quantity drop down, load that
                         if (GetConfig('TagCartQuantityBoxes') == 'dropdown') {
                             $GLOBALS["CompQuantity" . $product['complementary'][$y]['quantity']] = "selected=\"selected\"";
                             if (isset($GLOBALS["Quantity0"])) {
                                 $GLOBALS['CompCartQtyOptionZero'] = "<option " . $GLOBALS["Quantity0"] . " value='0'>0</option>";
                             } else {
                                 $GLOBALS['CompCartQtyOptionZero'] = "<option value='0'>0</option>";
                             }
                             // Fixes products being displayed with '0' quantity when the quantity is greater than 30 (hard coded limit in snippet)
                             if ($product['quantity'] > 30) {
                                 //Needed to be changed for the complementary
                                 $GLOBALS["CompCartQtyOptionSelected"] = "<option " . $GLOBALS["Quantity" . $product['complementary'][$y]['quantity']] . " value='" . $product['complementary'][$y]['quantity'] . "'>" . $product['complementary'][$y]['quantity'] . "</option>";
                             }
                             $GLOBALS['CompCartItemQty'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CompItemQtySelect");
                         } else {
                             $GLOBALS['CompCartItemQty'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CompItemQtyText");
                         }
                         //Added for complementary products Ends - By Simha..
                         $GLOBALS['CompProductTotal'] = CurrencyConvertFormatPrice($compprice * $product['complementary'][$y]['quantity']);
                         $GLOBALS['complementaryrow'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ComplementaryItem");
                         $comptotal += $compprice * $product['complementary'][$y]['quantity'];
                     }
                     $GLOBALS["CompQuantity" . $product['complementary'][$y]['quantity']] = "";
                 }
             }
             /* Code Ends */
             //$GLOBALS['ProductName'] = isc_html_escape($product['data']['prodname']);
             //blessen
             $withoutdollar = str_replace("\$", "", $GLOBALS['prodretailprice']);
             if (intval($withoutdollar) <= 0) {
                 $GLOBALS['SNIPPETS']['CartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItem");
             } else {
                 $GLOBALS['SNIPPETS']['CartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItem1");
             }
             //blessen
             // original $GLOBALS['SNIPPETS']['CartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItem");
         }
         $GLOBALS["Quantity" . $product['quantity']] = "";
     }
     if ($wrappingAdjustment > 0) {
         $GLOBALS['GiftWrappingTotal'] = CurrencyConvertFormatPrice($wrappingAdjustment);
     } else {
         $GLOBALS['HideGiftWrappingTotal'] = 'display: none';
     }
     $GLOBALS['HideAdjustedTotal'] = "none";
     $GLOBALS['AdjustedCartSubTotal'] = $GLOBALS['CartSubTotal'] - $GLOBALS['CartSubTotalDiscount'];
     $itemTotal += $comptotal;
     # Baskaran
     $GLOBALS['CartItemTotal'] = CurrencyConvertFormatPrice($itemTotal);
     $GLOBALS['SNIPPETS']['Coupons'] = '';
     $coupons = $GLOBALS['ISC_CLASS_CART']->api->GetAppliedCouponCodes();
     if (count($coupons)) {
         foreach ($coupons as $coupon) {
             $GLOBALS['CouponId'] = $coupon['couponid'];
             $GLOBALS['CouponCode'] = $coupon['couponcode'];
             // percent coupon
             if ($coupon['coupontype'] == 1) {
                 $discount = $coupon['discount'] . "%";
             } else {
                 $discount = CurrencyConvertFormatPrice($coupon['discount']);
             }
             $GLOBALS['CouponDiscount'] = $discount;
             $GLOBALS['SNIPPETS']['Coupons'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartCoupon");
         }
     }
     $GLOBALS['SNIPPETS']['GiftCertificates'] = '';
     // Has the customer chosen one or more gift certificates to apply to this order? We need to show them
     if (isset($_SESSION['CART']['GIFTCERTIFICATES']) && is_array($_SESSION['CART']['GIFTCERTIFICATES'])) {
         $certificates = $_SESSION['CART']['GIFTCERTIFICATES'];
         uasort($certificates, "GiftCertificateSort");
         foreach ($certificates as $certificate) {
             $GLOBALS['GiftCertificateCode'] = isc_html_escape($certificate['giftcertcode']);
             $GLOBALS['GiftCertificateId'] = $certificate['giftcertid'];
             $GLOBALS['GiftCertificateBalance'] = $certificate['giftcertbalance'];
             if ($GLOBALS['GiftCertificateBalance'] > $GLOBALS['AdjustedCartSubTotal']) {
                 $GLOBALS['GiftCertificateRemaining'] = $certificate['giftcertbalance'] - $GLOBALS['AdjustedCartSubTotal'];
                 $GLOBALS['CertificateAmountUsed'] = $certificate['giftcertbalance'] - $GLOBALS['GiftCertificateRemaining'];
             } else {
                 $GLOBALS['CertificateAmountUsed'] = $certificate['giftcertbalance'];
                 $GLOBALS['GiftCertificateRemaining'] = 0;
             }
             // Subtract this amount from the adjusted total
             $GLOBALS['AdjustedCartSubTotal'] -= $GLOBALS['GiftCertificateBalance'];
             if ($GLOBALS['AdjustedCartSubTotal'] <= 0) {
                 $GLOBALS['AdjustedCartSubTotal'] = 0;
             }
             $GLOBALS['GiftCertificateBalance'] = CurrencyConvertFormatPrice($GLOBALS['GiftCertificateBalance']);
             $GLOBALS['GiftCertificateRemaining'] = CurrencyConvertFormatPrice($GLOBALS['GiftCertificateRemaining']);
             $GLOBALS['CertificateAmountUsed'] = CurrencyConvertFormatPrice($GLOBALS['CertificateAmountUsed']);
             $GLOBALS['SNIPPETS']['GiftCertificates'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartGiftCertificate");
         }
         if ($GLOBALS['SNIPPETS']['GiftCertificates']) {
             $GLOBALS['HideAdjustedTotal'] = '';
             if ($GLOBALS['AdjustedCartSubTotal'] == 0) {
                 $GLOBALS['HidePanels'][] = "SideGiftCertificateCodeBox";
             }
         }
     }
     if ($GLOBALS['AdjustedCartSubTotal'] != $GLOBALS['CartSubTotal']) {
         $GLOBALS['HideAdjustedTotal'] = "";
         $GLOBALS['AdjustedCartSubTotal'] = CurrencyConvertFormatPrice($GLOBALS['AdjustedCartSubTotal']);
     }
     //            $GLOBALS['CartSubTotal'] = CurrencyConvertFormatPrice($GLOBALS['CartSubTotal']);
     $GLOBALS['CartSubTotal'] = CurrencyConvertFormatPrice($GLOBALS['CartSubTotal'] + $comptotal);
     # To add the subtotal in the cart -- Baskaran
     $GLOBALS['CartSaveTotal'] = CurrencyConvertFormatPrice($_SESSION['you_save']);
     //blessen
     if (!gzte11(ISC_LARGEPRINT)) {
         $GLOBALS['HidePanels'][] = "SideGiftCertificateCodeBox";
     }
     // Are there any products in the cart?
     if ($GLOBALS['ISC_CLASS_CART']->api->GetNumProductsInCart() == 0) {
         $GLOBALS['HideShoppingCartGrid'] = "none";
     } else {
         $GLOBALS['HideShoppingCartEmptyMessage'] = "none";
     }
 }
		protected function _Validate($data = array())
		{
			if(empty($data)) {
				//if this is a control panel manual payment
				if(isset($_POST['paymentField'][$this->GetId()])) {
					$data=$_POST['paymentField'][$this->GetId()];
				//store front normal checkout
				} else {
					$data=$_POST;
				}
			}
			$validatedVariables = array();

			// Check for HTTPS if its required
			if(!strtolower($_SERVER['HTTPS']) == "on") {
				ob_end_clean();
				?>
					<script type="text/javascript">
						alert("<?php echo GetLang($this->_languagePrefix.'NoSSLError'); ?>");
						document.location.href="<?php echo $GLOBALS['ShopPath']; ?>/checkout.php?action=confirm_order";
					</script>
				<?php
				die();
			}

			//basic required credit card fields
			$requiredFields = array(
				"creditcard_cctype"		=> GetLang('CreditCardSelectCardType'),
				"creditcard_name"		=> GetLang('CreditCardEnterName'),
				"creditcard_ccno"		=> GetLang('CreditCardEnterCardNumber'),
				"creditcard_ccexpm"		=> GetLang('CreditCardEnterCreditCardMonth'),
				"creditcard_ccexpy"		=> GetLang('CreditCardEnterCreditCardYear'),
			);
			foreach($requiredFields as $field => $message) {
				if(!isset($data[$field]) || trim($data[$field]) == '') {
					$this->SetError($message);
					return false;
				}
			}

			//if CVV2 is required
			if($this->CardTypeRequiresCVV2($data['creditcard_cctype'])) {
				if(!isset($data['creditcard_cccvd']) || trim($data['creditcard_cccvd']) == '') {
					$this->SetError(GetLang('CreditCardEnterCardCode'));
					return false;
				}
			}

			//if issue date/number is required
			if($this->CardTypeRequiresIssueNoOrDate($data['creditcard_cctype'])) {
				//if issue number is invalid
				if((!isset($data['creditcard_issueno']) || !is_numeric($data['creditcard_issueno']))) {
					// and if issue date is invalid
					if(!isset($data['creditcard_issuedatem']) || !is_numeric($data['creditcard_issuedatem']) || !isset($data['creditcard_issuedatey']) || !is_numeric($data['creditcard_issuedatey'])) {

						$this->SetError(GetLang('CreditCardEnterIssueNoOrDate'));
						return false;
					}
				}
			}



			//if issue date is required
			if($this->CardTypeHasIssueDate($data['creditcard_cctype']) && $this->CardTypeRequiresIssueDate($_POST['creditcard_cctype'])) {
				if(!isset($data['creditcard_issuedatey']) || trim($data['creditcard_issuedatey']) == '') {
					$this->SetError(GetLang('CreditCardSelectCreditCardIssueYear'));
					return false;
				}
				if(!isset($data['creditcard_issuedatem']) || trim($data['creditcard_issuedatem']) == '') {
					$this->SetError(GetLang('CreditCardSelectCreditCardIssueMonth'));
					return false;
				}
			}

			//if issue No is required
			if($this->CardTypeHasIssueNo($data['creditcard_issueno']) && $this->CardTypeRequiresIssueNo($data['creditcard_cctype'])) {
				if(!isset($data['creditcard_issueno']) || trim($data['creditcard_issueno']) == '') {
					$this->SetError(GetLang('CreditCardSelectCreditCardIssueNo'));
					return false;
				}
			}

			//check if credit card expired.
			$currentMY = isc_mktime(0, 0, 0, isc_date('m')+1, 0, isc_date('y'));
			$cardMY = isc_mktime(0, 0, 0, $data['creditcard_ccexpm']+1, 0, $data['creditcard_ccexpy']);
			if ($currentMY > $cardMY) {
				$this->SetError(GetLang('CreditCardExpired'));
				return false;
			}

			$validatedVariables['cctype'] = $data['creditcard_cctype'];
			$validatedVariables['name'] = $data['creditcard_name'];
			$validatedVariables['ccno'] = $data['creditcard_ccno'];
			$validatedVariables['ccissueno'] = $data['creditcard_issueno'];
			$validatedVariables['ccissuedatem'] = $data['creditcard_issuedatem'];
			$validatedVariables['ccissuedatey'] = $data['creditcard_issuedatey'];
			$validatedVariables['cccvd'] = $data['creditcard_cccvd'];
			$validatedVariables['ccexpm'] = $data['creditcard_ccexpm'];
			$validatedVariables['ccexpy'] = $data['creditcard_ccexpy'];

			return $validatedVariables;
		}
	private function loadProductComments($productId)
	{
		$GLOBALS['ProductId'] = $productId;

		// Are there any reviews for this product? If so, load them
		if ($GLOBALS['ISC_CLASS_PRODUCT']->GetNumReviews() == 0) {
			$GLOBALS['NoReviews'] = GetLang('NoReviews');
		}
		else {
			// Setup paging data
			$reviewsTotal = $GLOBALS['ISC_CLASS_PRODUCT']->GetNumReviews();
			$reviewsPerPage = GetConfig('ProductReviewsPerPage');
			$pages = ceil($reviewsTotal / $reviewsPerPage);

			$revpage = 1;
			$start = 0;

			if (isset($_GET['revpage'])) {
				$revpage = (int)$_GET['revpage'];
			}

			if ($revpage < 1) {
				$revpage = 1;
			}
			elseif ($revpage > $pages) {
				$revpage = $pages;
			}

			$start = ($revpage - 1) * $reviewsPerPage;

			$GLOBALS['ProductNumReviews'] = $reviewsTotal;
			$GLOBALS['ReviewStart'] = $start + 1;
			$GLOBALS['ReviewEnd'] = $start + $reviewsPerPage;

			// do we need to show paging?
			if ($pages > 1) {
				// Form the previous and next links
				$reviewLink = ProdLink($GLOBALS['ISC_CLASS_PRODUCT']->GetProductName());
				if($GLOBALS['EnableSEOUrls'] == 1) {
					$reviewLink .= '?revpage=';
				}
				else {
					$reviewLink .= '&revpage=';
				}

				if ($GLOBALS['ReviewEnd'] > $reviewsTotal) {
					$GLOBALS['ReviewEnd'] = $reviewsTotal;
				}

				// show a previous link
				if ($revpage > 1) {
					$GLOBALS["ReviewLink"] = $reviewLink . ($revpage - 1);
					$GLOBALS["PrevRevLink"] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductReviewPreviousLink");
				}

				// show a next link
				if ($revpage < $pages) {
					$GLOBALS["ReviewLink"] = $reviewLink . ($revpage + 1);
					$GLOBALS["NextRevLink"] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductReviewNextLink");
				}

				$GLOBALS['ProductReviewPaging'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductReviewPaging");
			}

			// Load all reviews for this product
			$query = "
				SELECT *
				FROM [|PREFIX|]reviews
				WHERE revproductid='".(int)$GLOBALS['ISC_CLASS_PRODUCT']->GetProductId()."' AND revstatus='1'
				ORDER BY revdate DESC
			";
			$query .= $GLOBALS['ISC_CLASS_DB']->AddLimit($start, $reviewsPerPage);
			$result = $GLOBALS['ISC_CLASS_DB']->Query($query);

			$GLOBALS['ProductReviews'] = "";

			$GLOBALS['AlternateReviewClass'] = '';
			$GLOBALS['ReviewNumber'] = $GLOBALS['ReviewStart'];
			while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
				$GLOBALS['ReviewRating'] = (int) $row['revrating'];
				$GLOBALS['ReviewTitle'] = isc_html_escape($row['revtitle']);
				$GLOBALS['ReviewDate'] = isc_date(GetConfig('DisplayDateFormat'), $row['revdate']);

				if ($row['revfromname'] != "") {
					$GLOBALS['ReviewName'] = isc_html_escape($row['revfromname']);
				} else {
					$GLOBALS['ReviewName'] = GetLang('Unknown');
				}

				$GLOBALS['ReviewText'] = nl2br(isc_html_escape($row['revtext']));

				$GLOBALS['ProductReviews'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductReviewItem");
				++$GLOBALS['ReviewNumber'];
				if($GLOBALS['AlternateReviewClass']) {
					$GLOBALS['AlternateReviewClass'] = '';
				}
				else {
					$GLOBALS['AlternateReviewClass'] = 'Alt';
				}
			}

			$GLOBALS['ProductReviewList'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductReviewList");
		}

		// Is captcha enabled?
		if (GetConfig('CaptchaEnabled') == false) {
			$GLOBALS['HideReviewCaptcha'] = "none";
		}
		else {
			// Generate the captcha image
			$GLOBALS['ISC_CLASS_CAPTCHA'] = GetClass('ISC_CAPTCHA');
			$GLOBALS['ISC_CLASS_CAPTCHA']->CreateSecret();
			$GLOBALS['CaptchaImage'] = $GLOBALS['ISC_CLASS_CAPTCHA']->ShowCaptcha();
		}

		$GLOBALS['ProductReviewFlashMessages'] = GetFlashMessageBoxes('reviews');

		// If we've got review data in the session then we need to show the review form
		if(!empty($_SESSION['productReviewData']['product_id'])) {
			// But only if it's for the current product
			 if($_SESSION['productReviewData']['product_id'] == $productId) {
				$GLOBALS['AutoShowReviewForm'] = 1;

				$reviewFields = array(
					'RevTitle' => 'revtitle',
					'RevText' => 'revtext',
					'RevFromName' => 'revfromname',
				);

				foreach($reviewFields as $templateVar => $field) {
					if(!empty($_SESSION['productReviewData'])) {
						$GLOBALS[$templateVar] = isc_html_escape($_SESSION['productReviewData'][$field]);
					}
				}

				if(isset($_SESSION['productReviewData']['revrating'])) {
					$GLOBALS['ReviewRating'.(int)$_SESSION['productReviewData']['revrating']] = 'selected="selected"';
				}
			}

			// Make sure we remove any review data
			unset($_SESSION['productReviewData']);
		}

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

		$GLOBALS['SNIPPETS']['CartItems'] = "";

		$items = $this->quote->getItems();
		foreach($items as $item) {
			$name = $item->getName();
			$quantity = $item->getQuantity();

			$GLOBALS['CartItemId'] = $item->getId();

			if($item instanceof ISC_QUOTE_ITEM_GIFTCERTIFICATE) {
				$GLOBALS['GiftCertificateName'] = isc_html_escape($name);
				$GLOBALS['GiftCertificateAmount'] = CurrencyConvertFormatPrice($item->getPrice());
				$GLOBALS['GiftCertificateTo'] = isc_html_escape($item->getRecipientName());
				$GLOBALS["Quantity" . $quantity] = 'selected="selected"';
				$GLOBALS['ProductPrice'] = CurrencyConvertFormatPrice($item->getPrice());
				$GLOBALS['ProductTotal'] = CurrencyConvertFormatPrice($item->getTotal());
				$GLOBALS['SNIPPETS']['CartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItemGiftCertificate");
				continue;
			}

			$GLOBALS['ProductName'] = isc_html_escape($name);
			$GLOBALS['ProductLink'] = prodLink($name);
			$GLOBALS['ProductAvailability'] = $item->getAvailability();
			$GLOBALS['ItemId'] = $item->getProductId();
			$GLOBALS['VariationId'] = $item->getVariationId();
			$GLOBALS['ProductQuantity'] = $quantity;

			if(getConfig('ShowThumbsInCart')) {
				$GLOBALS['ProductImage'] = imageThumb($item->getThumbnail(), prodLink($name));
			}

			$GLOBALS['UpdateCartQtyJs'] = "Cart.UpdateQuantity(this.options[this.selectedIndex].value);";
			$GLOBALS['HideCartProductFields'] = 'display:none;';
			$GLOBALS['CartProductFields'] = '';
			$this->GetProductFieldDetails($item->getConfiguration(), $item->getId());

			$GLOBALS['EventDate'] = '';
			$eventDate = $item->getEventDate(true);
			if(!empty($eventDate)) {
				$GLOBALS['EventDate'] = '
					<div style="font-style: italic; font-size:10px; color:gray">(' .
						$item->getEventName() . ': ' . isc_date('M jS Y', $eventDate) .
					')</div>';
			}

			$GLOBALS['GiftWrappingName'] = '';
			$GLOBALS['HideGiftWrappingAdd'] = '';
			$GLOBALS['HideGiftWrappingEdit'] = 'display: none';
			$GLOBALS['HideGiftWrappingPrice'] = 'display: none';
			$GLOBALS['GiftWrappingPrice'] = '';
			$GLOBALS['GiftMessagePreview'] = '';
			$GLOBALS['HideGiftMessagePreview'] = 'display: none';
			$GLOBALS['HideWrappingOptions'] = 'display: none';

			if($item->allowsGiftWrapping()) {
				$wrapping = $item->getGiftWrapping();
				$GLOBALS['HideWrappingOptions'] = '';
				if(!empty($wrapping)) {
					$GLOBALS['GiftWrappingName'] = isc_html_escape($wrapping['wrapname']);
					$GLOBALS['HideGiftWrappingAdd'] = 'display: none';
					$GLOBALS['HideGiftWrappingEdit'] = '';
					$GLOBALS['HideGiftWrappingPrice'] = '';
					$GLOBALS['GiftWrappingPrice'] = CurrencyConvertFormatPrice($wrapping['wrapprice']);
					if(!empty($wrapping['wrapmessage'])) {
						if(isc_strlen($wrapping['wrapmessage']) > 30) {
							$wrapping['wrapmessage'] = substr($wrapping['wrapmessage'], 0, 27).'...';
						}
						$GLOBALS['GiftMessagePreview'] = isc_html_escape($wrapping['wrapmessage']);
						$GLOBALS['HideGiftMessagePreview'] = '';
					}
				}
				else {
					$GLOBALS['HideGiftWrappingAdd'] = '';
				}
			}

			$price = $item->getPrice($this->displayIncludingTax);
			$total = $item->getTotal($this->displayIncludingTax);

			$GLOBALS['ProductPrice'] = currencyConvertFormatPrice($price);
			$GLOBALS['ProductTotal'] = currencyConvertFormatPrice($total);

			// Don't allow the quantity of free items/parent restricted items to be changed
			$GLOBALS['HideCartItemRemove'] = '';
			if($item->getParentId()) {
				$GLOBALS['CartItemQty'] = number_format($item->getQuantity());
				$GLOBALS['HideCartItemRemove'] = 'display: none';
			}
			// If we're using a cart quantity drop down, load that
			else if (GetConfig('TagCartQuantityBoxes') == 'dropdown') {
				$GLOBALS["Quantity" . $quantity] = "selected=\"selected\"";
				if($quantity == 0) {
					$GLOBALS['QtyOptionZero'] = "<option ".$GLOBALS["Quantity0"]." value='0'>0</option>";
				}
				else {
					$GLOBALS['QtyOptionZero'] = "<option value='0'>0</option>";
				}

				// Fixes products being displayed with '0' quantity when the quantity is greater than 30 (hard coded limit in snippet)
				if ($quantity > 30) {
					$GLOBALS["QtyOptionSelected"] = "<option ".$GLOBALS["Quantity" . $quantity]." value='" . $quantity . "'>" . $quantity . "</option>";
				}
				$GLOBALS['CartItemQty'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItemQtySelect");
			}
			// Otherwise, load the textbox
			else {
				$GLOBALS['CartItemQty'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItemQtyText");
			}

			// Is this product a variation?
			$GLOBALS['ProductOptions'] = '';
			$options = $item->getVariationOptions();
			if(!empty($options)) {
				$GLOBALS['ProductOptions'] .= "<br /><small>(";
				$comma = '';
				foreach($options as $name => $value) {
					if(!trim($name) || !trim($value)) {
						continue;
					}
					$GLOBALS['ProductOptions'] .= $comma.isc_html_escape($name).": ".isc_html_escape($value);
					$comma = ', ';
				}
				$GLOBALS['ProductOptions'] .= ")</small>";
			}

			$GLOBALS['HideExpectedReleaseDate'] = 'display: none;';
			if($item->isPreOrder()) {
				$GLOBALS['ProductExpectedReleaseDate'] = $item->getPreOrderMessage();
				$GLOBALS['HideExpectedReleaseDate'] = '';
			}

			$GLOBALS['SNIPPETS']['CartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItem");
			$GLOBALS["Quantity" . $quantity] = "";
		}

		$GLOBALS['CartItemTotal'] = currencyConvertFormatPrice($this->quote->getSubTotal($this->displayIncludingTax));
		$GLOBALS['CartTotal'] = currencyConvertFormatPrice($this->quote->getGrandTotal());

		if($this->quote->getWrappingCost() > 0) {
			$GLOBALS['GiftWrappingTotal'] = currencyConvertFormatPrice($this->quote->getWrappingCost());
		}
		else {
			$GLOBALS['HideGiftWrappingTotal'] = 'display: none';
		}
		$script = "
			$('.quantityInput').live('change', function() {
				Cart.UpdateQuantity($(this).val());
			});
		";
		$GLOBALS['ISC_CLASS_TEMPLATE']->clientScript->registerScript($script,'ready');

	}
 public function SetPanelSettings()
 {
     $_SESSION['you_save'] = 0;
     //blessen
     $GLOBALS['SNIPPETS']['CartItems'] = "";
     $count = 0;
     $subtotal = 0;
     $_SESSION['CHECKOUT'] = array();
     // Get a list of all products in the cart
     $GLOBALS['ISC_CLASS_CART'] = GetClass('ISC_CART');
     $product_array = $GLOBALS['ISC_CLASS_CART']->api->GetProductsInCart();
     $GLOBALS['AdditionalCheckoutButtons'] = '';
     // Go through all the checkout modules looking for one with a GetSidePanelCheckoutButton function defined
     $ShowCheckoutButton = false;
     if (!empty($product_array)) {
         foreach (GetAvailableModules('checkout', true, true) as $module) {
             if (isset($module['object']->_showBothButtons) && $module['object']->_showBothButtons) {
                 $ShowCheckoutButton = true;
                 $GLOBALS['AdditionalCheckoutButtons'] .= $module['object']->GetCheckoutButton();
             } elseif (method_exists($module['object'], 'GetCheckoutButton')) {
                 $GLOBALS['AdditionalCheckoutButtons'] .= $module['object']->GetCheckoutButton();
             } else {
                 $ShowCheckoutButton = true;
             }
         }
     }
     $GLOBALS['HideMultipleAddressShipping'] = 'display: none';
     if (gzte11(ISC_MEDIUMPRINT) && $GLOBALS['ISC_CLASS_CART']->api->GetNumPhysicalProducts() > 1 && $ShowCheckoutButton && GetConfig("MultipleShippingAddresses")) {
         $GLOBALS['HideMultipleAddressShipping'] = '';
     }
     $GLOBALS['HideCheckoutButton'] = '';
     if (!$ShowCheckoutButton) {
         $GLOBALS['HideCheckoutButton'] = 'display: none';
         $GLOBALS['HideMultipleAddressShippingOr'] = 'display: none';
     }
     $wrappingOptions = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('GiftWrapping');
     if (empty($wrappingOptions)) {
         $publicWrappingOptions = false;
     } else {
         $publicWrappingOptions = true;
     }
     if (!GetConfig('ShowThumbsInCart')) {
         $GLOBALS['HideThumbColumn'] = 'display: none';
         $GLOBALS['ProductNameSpan'] = 2;
     } else {
         $GLOBALS['HideThumbColumn'] = '';
         $GLOBALS['ProductNameSpan'] = 1;
     }
     $wrappingAdjustment = 0;
     $itemTotal = 0;
     foreach ($product_array as $k => $product) {
         $GLOBALS['CartItemId'] = (int) $product['cartitemid'];
         // If the item in the cart is a gift certificate, we need to show a special type of row
         if (isset($product['type']) && $product['type'] == "giftcertificate") {
             $GLOBALS['GiftCertificateName'] = isc_html_escape($product['data']['prodname']);
             $GLOBALS['GiftCertificateAmount'] = CurrencyConvertFormatPrice($product['giftamount']);
             $GLOBALS['GiftCertificateTo'] = isc_html_escape($product['certificate']['to_name']);
             $GLOBALS["Quantity" . $product['quantity']] = 'selected="selected"';
             $GLOBALS['ProductPrice'] = CurrencyConvertFormatPrice($product['giftamount']);
             $GLOBALS['ProductTotal'] = CurrencyConvertFormatPrice($product['giftamount'] * $product['quantity']);
             $itemTotal += $product['giftamount'] * $product['quantity'];
             $GLOBALS['SNIPPETS']['CartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItemGiftCertificate");
         } else {
             $GLOBALS['ProductLink'] = ProdLink($product['data']['prodname']);
             $GLOBALS['ProductAvailability'] = isc_html_escape($product['data']['prodavailability']);
             $GLOBALS['ItemId'] = (int) $product['data']['productid'];
             $GLOBALS['VariationId'] = (int) $product['variation_id'];
             $GLOBALS['ProductQuantity'] = (int) $product['quantity'];
             //blessen
             $GLOBALS['prodretailprice'] = CurrencyConvertFormatPrice($product['data']['prodretailprice']);
             if ($product['data']['prodretailprice'] > $product['data']['prodcalculatedprice']) {
                 $_SESSION['you_save'] += ($product['data']['prodretailprice'] - $product['data']['prodcalculatedprice']) * $product['quantity'];
             }
             //$GLOBALS['saveprice'] =  CurrencyConvertFormatPrice($product['data']['prodretailprice'] - $product['data']['prodcalculatedprice']);
             //blessen
             // Should we show thumbnails in the cart?
             if (GetConfig('ShowThumbsInCart')) {
                 $GLOBALS['ProductImage'] = ImageThumb($product['data']['imagefile'], ProdLink($product['data']['prodname']));
             }
             $GLOBALS['UpdateCartQtyJs'] = "Cart.UpdateQuantity(this.options[this.selectedIndex].value);";
             $GLOBALS['HideCartProductFields'] = 'display:none;';
             $GLOBALS['CartProductFields'] = '';
             $this->GetProductFieldDetails($product['product_fields'], $k);
             $GLOBALS['EventDate'] = '';
             if (isset($product['event_date'])) {
                 $GLOBALS['EventDate'] = '<div style="font-style: italic; font-size:10px; color:gray">(' . $product['event_name'] . ': ' . isc_date('M jS Y', $product['event_date']) . ')</div>';
             }
             // Can this product be wrapped?
             $GLOBALS['GiftWrappingName'] = '';
             $GLOBALS['HideGiftWrappingAdd'] = '';
             $GLOBALS['HideGiftWrappingEdit'] = 'display: none';
             $GLOBALS['HideGiftWrappingPrice'] = 'display: none';
             $GLOBALS['GiftWrappingPrice'] = '';
             $GLOBALS['GiftMessagePreview'] = '';
             $GLOBALS['HideGiftMessagePreview'] = 'display: none';
             $GLOBALS['HideWrappingOptions'] = 'display: none';
             if ($product['data']['prodtype'] == PT_PHYSICAL && $product['data']['prodwrapoptions'] != -1 && $publicWrappingOptions == true) {
                 $GLOBALS['HideWrappingOptions'] = '';
                 if (isset($product['wrapping'])) {
                     $GLOBALS['GiftWrappingName'] = isc_html_escape($product['wrapping']['wrapname']);
                     $GLOBALS['HideGiftWrappingAdd'] = 'display: none';
                     $GLOBALS['HideGiftWrappingEdit'] = '';
                     $GLOBALS['HideGiftWrappingPrice'] = '';
                     $wrappingAdjustment += $product['wrapping']['wrapprice'] * $product['quantity'];
                     $GLOBALS['GiftWrappingPrice'] = CurrencyConvertFormatPrice($product['wrapping']['wrapprice']);
                     if (isset($product['wrapping']['wrapmessage'])) {
                         if (isc_strlen($product['wrapping']['wrapmessage']) > 30) {
                             $product['wrapping']['wrapmessage'] = substr($product['wrapping']['wrapmessage'], 0, 27) . '...';
                         }
                         $GLOBALS['GiftMessagePreview'] = isc_html_escape($product['wrapping']['wrapmessage']);
                         if ($product['wrapping']['wrapmessage']) {
                             $GLOBALS['HideGiftMessagePreview'] = '';
                         }
                     }
                 }
             }
             $subtotalPrice = 0;
             if (isset($product['discount_price'])) {
                 $subtotalPrice = $product['discount_price'];
             } else {
                 $subtotalPrice = $product['product_price'];
             }
             if (isset($product['discount_price']) && $product['discount_price'] != $product['original_price']) {
                 $GLOBALS['ProductPrice'] = sprintf("<s class='CartStrike'>%s</s> %s", CurrencyConvertFormatPrice($product['original_price']), CurrencyConvertFormatPrice($subtotalPrice));
             } else {
                 $GLOBALS['ProductPrice'] = CurrencyConvertFormatPrice($subtotalPrice);
             }
             $GLOBALS['ProductTotal'] = CurrencyConvertFormatPrice($subtotalPrice * $product['quantity']);
             $itemTotal += $subtotalPrice * $product['quantity'];
             // If we're using a cart quantity drop down, load that
             if (GetConfig('TagCartQuantityBoxes') == 'dropdown') {
                 $GLOBALS["Quantity" . $product['quantity']] = "selected=\"selected\"";
                 if (isset($GLOBALS["Quantity0"])) {
                     $GLOBALS['QtyOptionZero'] = "<option " . $GLOBALS["Quantity0"] . " value='0'>0</option>";
                 } else {
                     $GLOBALS['QtyOptionZero'] = "<option value='0'>0</option>";
                 }
                 // Fixes products being displayed with '0' quantity when the quantity is greater than 30 (hard coded limit in snippet)
                 if ($product['quantity'] > 30) {
                     $GLOBALS["QtyOptionSelected"] = "<option " . $GLOBALS["Quantity" . $product['quantity']] . " value='" . $product['quantity'] . "'>" . $product['quantity'] . "</option>";
                 }
                 $GLOBALS['CartItemQty'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItemQtySelect");
             } else {
                 $GLOBALS['CartItemQty'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItemQtyText");
             }
             // Is this product a variation?
             $GLOBALS['ProductOptions'] = '';
             if (isset($product['options']) && !empty($product['options'])) {
                 $GLOBALS['ProductOptions'] .= "<br /><small>(";
                 $comma = '';
                 foreach ($product['options'] as $name => $value) {
                     if (!trim($name) || !trim($value)) {
                         continue;
                     }
                     $GLOBALS['ProductOptions'] .= $comma . isc_html_escape($name) . ": " . isc_html_escape($value);
                     $comma = ', ';
                 }
                 $GLOBALS['ProductOptions'] .= ")</small>";
             }
             $GLOBALS['ProductName'] = isc_html_escape($product['data']['prodname']);
             //blessen
             $withoutdollar = str_replace("\$", "", $GLOBALS['prodretailprice']);
             if (intval($withoutdollar) <= 0) {
                 $GLOBALS['SNIPPETS']['CartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItem");
             } else {
                 $GLOBALS['SNIPPETS']['CartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItem1");
             }
             //blessen
             // original $GLOBALS['SNIPPETS']['CartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItem");
         }
         $GLOBALS["Quantity" . $product['quantity']] = "";
     }
     if ($wrappingAdjustment > 0) {
         $GLOBALS['GiftWrappingTotal'] = CurrencyConvertFormatPrice($wrappingAdjustment);
     } else {
         $GLOBALS['HideGiftWrappingTotal'] = 'display: none';
     }
     $GLOBALS['HideAdjustedTotal'] = "none";
     $GLOBALS['AdjustedCartSubTotal'] = $GLOBALS['CartSubTotal'] - $GLOBALS['CartSubTotalDiscount'];
     $GLOBALS['CartItemTotal'] = CurrencyConvertFormatPrice($itemTotal);
     $GLOBALS['SNIPPETS']['Coupons'] = '';
     $coupons = $GLOBALS['ISC_CLASS_CART']->api->GetAppliedCouponCodes();
     if (count($coupons)) {
         foreach ($coupons as $coupon) {
             $GLOBALS['CouponId'] = $coupon['couponid'];
             $GLOBALS['CouponCode'] = $coupon['couponcode'];
             // percent coupon
             if ($coupon['coupontype'] == 1) {
                 $discount = $coupon['discount'] . "%";
             } else {
                 $discount = CurrencyConvertFormatPrice($coupon['discount']);
             }
             $GLOBALS['CouponDiscount'] = $discount;
             $GLOBALS['SNIPPETS']['Coupons'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartCoupon");
         }
     }
     $GLOBALS['SNIPPETS']['GiftCertificates'] = '';
     // Has the customer chosen one or more gift certificates to apply to this order? We need to show them
     if (isset($_SESSION['CART']['GIFTCERTIFICATES']) && is_array($_SESSION['CART']['GIFTCERTIFICATES'])) {
         $certificates = $_SESSION['CART']['GIFTCERTIFICATES'];
         uasort($certificates, "GiftCertificateSort");
         foreach ($certificates as $certificate) {
             $GLOBALS['GiftCertificateCode'] = isc_html_escape($certificate['giftcertcode']);
             $GLOBALS['GiftCertificateId'] = $certificate['giftcertid'];
             $GLOBALS['GiftCertificateBalance'] = $certificate['giftcertbalance'];
             if ($GLOBALS['GiftCertificateBalance'] > $GLOBALS['AdjustedCartSubTotal']) {
                 $GLOBALS['GiftCertificateRemaining'] = $certificate['giftcertbalance'] - $GLOBALS['AdjustedCartSubTotal'];
                 $GLOBALS['CertificateAmountUsed'] = $certificate['giftcertbalance'] - $GLOBALS['GiftCertificateRemaining'];
             } else {
                 $GLOBALS['CertificateAmountUsed'] = $certificate['giftcertbalance'];
                 $GLOBALS['GiftCertificateRemaining'] = 0;
             }
             // Subtract this amount from the adjusted total
             $GLOBALS['AdjustedCartSubTotal'] -= $GLOBALS['GiftCertificateBalance'];
             if ($GLOBALS['AdjustedCartSubTotal'] <= 0) {
                 $GLOBALS['AdjustedCartSubTotal'] = 0;
             }
             $GLOBALS['GiftCertificateBalance'] = CurrencyConvertFormatPrice($GLOBALS['GiftCertificateBalance']);
             $GLOBALS['GiftCertificateRemaining'] = CurrencyConvertFormatPrice($GLOBALS['GiftCertificateRemaining']);
             $GLOBALS['CertificateAmountUsed'] = CurrencyConvertFormatPrice($GLOBALS['CertificateAmountUsed']);
             $GLOBALS['SNIPPETS']['GiftCertificates'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartGiftCertificate");
         }
         if ($GLOBALS['SNIPPETS']['GiftCertificates']) {
             $GLOBALS['HideAdjustedTotal'] = '';
             if ($GLOBALS['AdjustedCartSubTotal'] == 0) {
                 $GLOBALS['HidePanels'][] = "SideGiftCertificateCodeBox";
             }
         }
     }
     if ($GLOBALS['AdjustedCartSubTotal'] != $GLOBALS['CartSubTotal']) {
         $GLOBALS['HideAdjustedTotal'] = "";
         $GLOBALS['AdjustedCartSubTotal'] = CurrencyConvertFormatPrice($GLOBALS['AdjustedCartSubTotal']);
     }
     $GLOBALS['CartSubTotal'] = CurrencyConvertFormatPrice($GLOBALS['CartSubTotal']);
     $GLOBALS['CartSaveTotal'] = CurrencyConvertFormatPrice($_SESSION['you_save']);
     //blessen
     if (!gzte11(ISC_LARGEPRINT)) {
         $GLOBALS['HidePanels'][] = "SideGiftCertificateCodeBox";
     }
     // Are there any products in the cart?
     if ($GLOBALS['ISC_CLASS_CART']->api->GetNumProductsInCart() == 0) {
         $GLOBALS['HideShoppingCartGrid'] = "none";
     } else {
         $GLOBALS['HideShoppingCartEmptyMessage'] = "none";
     }
 }
 public function CustomerStatsByRevenueGrid()
 {
     $GLOBALS['CustomerGrid'] = "";
     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;
         }
         $GLOBALS['CustomersPerPage'] = $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['RevenueByCustomersCurrentPage'] = $page;
         // Workout the start and end records
         $start = $per_page * $page - $per_page;
         $end = $start + ($per_page - 1);
         // How many customers with orders between this period are there in total?
         $query = "\n\t\t\t\tSELECT\n\t\t\t\t\tCOUNT(*) AS num\n\t\t\t\tFROM\n\t\t\t\t\t[|PREFIX|]orders\n\t\t\t\t\tLEFT JOIN [|PREFIX|]customers ON ordcustid = customerid\n\t\t\t\tWHERE\n\t\t\t\t\tordstatus IN (" . implode(',', GetPaidOrderStatusArray()) . ") AND\n\t\t\t\t\torddate >= '" . $from_stamp . "' AND\n\t\t\t\t\torddate <= '" . $to_stamp . "'\n\t\t\t\tGROUP BY\n\t\t\t\t\tordcustid\n\t\t\t";
         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         $row = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
         $total_customers = $row['num'];
         // Workout the paging
         $num_pages = ceil($total_customers / $per_page);
         $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='ChangeRevenuePerCustomerPage(1)'>&laquo;</a> | ";
         } else {
             $paging .= "&laquo; | ";
         }
         // Are we on page 2 or above?
         if ($page > 1) {
             $paging .= sprintf("<a href='javascript:void(0)' onclick='ChangeRevenuePerCustomerPage(%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='ChangeRevenuePerCustomerPage(%d)'>%d</a> | ", $i, $i);
                 }
             }
         }
         // Are we on page 2 or above?
         if ($page < $num_pages) {
             $paging .= sprintf("<a href='javascript:void(0)' onclick='ChangeRevenuePerCustomerPage(%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='ChangeRevenuePerCustomerPage(%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='#revenuePerCustomerAnchor';</script>";
         }
         if (isset($_GET['SortOrder']) && $_GET['SortOrder'] == "asc") {
             $sortOrder = 'asc';
         } else {
             $sortOrder = 'desc';
         }
         $sortFields = array('customerid', 'name', 'custconemail', 'custdatejoined', 'numorders', 'revenue');
         if (isset($_GET['SortBy']) && in_array($_GET['SortBy'], $sortFields)) {
             $sortField = $_GET['SortBy'];
             SaveDefaultSortField("CustomerStatsByRevenue", $_REQUEST['SortBy'], $sortOrder);
         } else {
             list($sortField, $sortOrder) = GetDefaultSortField("CustomerStatsByRevenue", "revenue", $sortOrder);
         }
         $sortLinks = array("Cust" => "name", "Email" => "custconemail", "Date" => "custdatejoined", "NumOrders" => "numorders", "AmountSpent" => "revenue");
         BuildAdminSortingLinks($sortLinks, "javascript:SortRevenuePerCustomer('%%SORTFIELD%%', '%%SORTORDER%%');", $sortField, $sortOrder);
         // Fetch the actual results for this page
         $query = sprintf("\n\t\t\t\tSELECT\n\t\t\t\t\tcustomerid,\n\t\t\t\t\tCONCAT(custconfirstname, ' ', custconlastname) AS name,\n\t\t\t\t\tcustconemail,\n\t\t\t\t\tCONCAT(ordbillfirstname, ' ',  ordbilllastname) AS billname,\n\t\t\t\t\tordbillemail,\n\t\t\t\t\tcustdatejoined,\n\t\t\t\t\tCOUNT(orderid) AS numorders,\n\t\t\t\t\tSUM(ordtotalamount) AS revenue\n\t\t\t\tFROM\n\t\t\t\t\t[|PREFIX|]orders\n\t\t\t\t\tLEFT JOIN [|PREFIX|]customers ON ordcustid = customerid\n\t\t\t\tWHERE\n\t\t\t\t\tordstatus IN (" . implode(',', GetPaidOrderStatusArray()) . ") AND\n\t\t\t\t\torddate >= '%d' AND\n\t\t\t\t\torddate <= '%d'\n\t\t\t\tGROUP BY\n\t\t\t\t\tordcustid\n\t\t\t\tORDER BY\n\t\t\t\t\t%s %s", $from_stamp, $to_stamp, $sortField, $sortOrder);
         // Add the Limit
         $query .= $GLOBALS['ISC_CLASS_DB']->AddLimit($start, $per_page);
         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         if ($GLOBALS['ISC_CLASS_DB']->CountResult($result) > 0) {
             while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
                 if (!is_null($row['customerid'])) {
                     $customerLink = "<a href=\"index.php?ToDo=viewCustomers&searchQuery=" . (int) $row['customerid'] . "\">" . isc_html_escape($row['name']) . "</a>";
                     $email = $row['custconemail'];
                 } else {
                     $customerLink = isc_html_escape($row['billname']);
                     $email = $row['ordbillemail'];
                 }
                 $GLOBALS['CustomerGrid'] .= sprintf("\n\t\t\t\t\t\t<tr class=\"GridRow\" onmouseover=\"this.className='GridRowOver';\" onmouseout=\"this.className='GridRow';\">\n\t\t\t\t\t\t\t<td nowrap height=\"22\" class=\"" . $GLOBALS['SortedFieldCustClass'] . "\">\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\t<td nowrap class=\"" . $GLOBALS['SortedFieldEmailClass'] . "\">\n\t\t\t\t\t\t\t\t<a href=\"mailto:%s\">%s</a>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td nowrap class=\"" . $GLOBALS['SortedFieldDateClass'] . "\">\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\t<td nowrap align='right' class=\"" . $GLOBALS['SortedFieldNumOrdersClass'] . "\">\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\t<td nowrap align='right' class=\"" . $GLOBALS['SortedFieldAmountSpentClass'] . "\">\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\n\t\t\t\t\t", $customerLink, isc_html_escape($email), isc_html_escape($email), isc_date(GetConfig('DisplayDateFormat'), $row['custdatejoined']), $row['numorders'], FormatPrice($row['revenue']));
             }
         } else {
             $GLOBALS['HideStatsRows'] = "none";
             $GLOBALS['CustomerGrid'] .= sprintf("\n\t\t\t\t\t\t<tr class=\"GridRow\" onmouseover=\"this.className='GridRowOver';\" onmouseout=\"this.className='GridRow';\">\n\t\t\t\t\t\t\t<td nowrap height=\"22\" colspan=\"6\">\n\t\t\t\t\t\t\t\t<em>%s</em>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t", GetLang('StatsNoCustomersForDate'));
         }
         $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("stats.customers.byrevenue");
         $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate();
     }
 }
 function GenerateItem($item)
 {
     $item['date'] = isc_date("D, d M Y H:i:s O", $item['date']);
     $xml = "\t\t<item>\n";
     $xml .= sprintf("\t\t\t<title><![CDATA[%s]]></title>\n", $this->_SanitizeCDATA($item['title']));
     $xml .= sprintf("\t\t\t<link>%s</link>\n", $this->_SanitizeData($item['link']));
     $xml .= sprintf("\t\t\t<pubDate>%s</pubDate>\n", $item['date']);
     if (isset($item['author'])) {
         $xml .= sprintf("\t\t\t<dc:creator>%s</dc:creator>\n", $this->_SanitizeData($item['author']));
     }
     $xml .= sprintf("\t\t\t<guid isPermaLink=\"false\">%s</guid>\n", $this->_SanitizeData($item['link']));
     $xml .= sprintf("\t\t\t<description><![CDATA[%s]]></description>\n", $this->_SanitizeCDATA($item['description']));
     $xml .= sprintf("\t\t\t<content:encoded><![CDATA[%s]]></content:encoded>\n", $this->_SanitizeCDATA($item['description']));
     $xml .= "\t\t</item>\n";
     return $xml;
 }
 public function CommitSettings(&$messages = array())
 {
     // If the shop path has changed normalize it and set the app path too
     if (isset($GLOBALS['ISC_NEW_CFG']['ShopPath'])) {
         $shop_path_parts = parse_url($GLOBALS['ISC_NEW_CFG']['ShopPath']);
         if (!isset($shop_path_parts['scheme'])) {
             $shop_path_parts['scheme'] = 'http';
         }
         if (!isset($shop_path_parts['path'])) {
             $shop_path_parts['path'] = '';
         }
         $shop_path_parts['path'] = rtrim($shop_path_parts['path'], '/');
         // Workout the Shop Path
         $GLOBALS['ISC_NEW_CFG']['ShopPath'] = $shop_path_parts['scheme'] . '://' . $shop_path_parts['host'];
         if (isset($shop_path_parts['port']) && $shop_path_parts['port'] != '80') {
             $GLOBALS['ISC_NEW_CFG']['ShopPath'] .= ':' . $shop_path_parts['port'];
         }
         $GLOBALS['ISC_NEW_CFG']['ShopPath'] .= $shop_path_parts['path'];
         // Work out the AppPath automatically
         $GLOBALS['ISC_NEW_CFG']['AppPath'] = $shop_path_parts['path'];
     }
     if (!isset($GLOBALS['ISC_NEW_CFG'])) {
         $GLOBALS['ISC_NEW_CFG'] = array();
     }
     $directories = array('ImageDirectory' => 'product_images', 'InstallImageDirectory' => 'install_images', 'VideoDirectory' => 'product_videos', 'InstallVideoDirectory' => 'install_videos', 'DownloadDirectory' => 'product_downloads');
     //New directories of index 1,2,3 added by Simha
     foreach ($directories as $directory => $default) {
         if (isset($GLOBALS['ISC_NEW_CFG'][$directory])) {
             $newDirectory = ISC_BASE_PATH . '/' . $GLOBALS['ISC_NEW_CFG'][$directory];
             if (!$GLOBALS['ISC_NEW_CFG'][$directory] || !is_dir($newDirectory)) {
                 $GLOBALS['ISC_NEW_CFG'][$directory] = $default;
             }
         }
     }
     if (!isset($GLOBALS['ISC_NEW_CFG']['ShopPath'])) {
         $GLOBALS['ISC_CFG']['ShopPath'] = GetConfig('ShopPathNormal');
     }
     $GLOBALS['ISC_SAVE_CFG'] = array_merge($GLOBALS['ISC_CFG'], $GLOBALS['ISC_NEW_CFG']);
     // Save the var_exported vars in the globals array temporarily for saving
     foreach ($this->all_vars as $var) {
         if (!array_key_exists($var, $GLOBALS['ISC_SAVE_CFG'])) {
             $GLOBALS[$var] = "null";
         } else {
             $GLOBALS[$var] = var_export($GLOBALS['ISC_SAVE_CFG'][$var], true);
         }
     }
     $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("config.file");
     $config_data = $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate(true);
     $setting_string = "<" . "?php\n\n";
     $setting_string .= "\t// Last Updated: " . isc_date("jS M Y @ g:i A") . "\n";
     $setting_string .= $config_data;
     $setting_string .= "?" . ">";
     if (!defined("ISC_CONFIG_FILE") || !defined("ISC_CONFIG_BACKUP_FILE")) {
         die("Config sanity check failed");
     }
     // Try to copy the current config file to a backup file
     if (!@copy(ISC_CONFIG_FILE, ISC_CONFIG_BACKUP_FILE)) {
         isc_chmod(ISC_CONFIG_BACKUP_FILE, ISC_WRITEABLE_FILE_PERM);
         $messages = array(GetLang('CouldntBackupConfig') => MSG_INFO);
     }
     // Try to write to the config file
     if (is_writable(ISC_CONFIG_FILE)) {
         if ($fp = @fopen(ISC_CONFIG_FILE, "wb+")) {
             if (@fwrite($fp, $setting_string)) {
                 $prevCatListDepth = GetConfig('CategoryListDepth');
                 // Include the config file again to initialize the new values
                 include ISC_CONFIG_FILE;
                 if (isset($GLOBALS['ISC_NEW_CFG']['CategoryListDepth']) && $GLOBALS['ISC_NEW_CFG']['CategoryListDepth'] != $prevCatListDepth) {
                     $GLOBALS['ISC_CLASS_DATA_STORE']->UpdateRootCategories();
                 }
                 return true;
             } else {
                 $this->error = GetLang('CouldntSaveConfig');
                 return false;
             }
         } else {
             $this->error = GetLang('CouldntSaveConfig');
             return false;
         }
     } else {
         $this->error = GetLang('CouldntSaveConfig');
         return false;
     }
 }
Example #22
0
	public function setProductGlobals($row)
	{
		if($GLOBALS['AlternateClass'] == 'Odd') {
			$GLOBALS['AlternateClass'] = 'Even';
		}
		else {
			$GLOBALS['AlternateClass'] = 'Odd';
		}

		$GLOBALS['ProductCartQuantity'] = '';
		if(isset($GLOBALS['CartQuantity'.$row['productid']])) {
			$GLOBALS['ProductCartQuantity'] = (int)$GLOBALS['CartQuantity'.$row['productid']];
		}

		$GLOBALS['ProductId'] = (int)$row['productid'];
		$GLOBALS['ProductName'] = isc_html_escape($row['prodname']);
		$GLOBALS['ProductLink'] = ProdLink($row['prodname']);
		$GLOBALS['ProductRating'] = (int)$row['prodavgrating'];

		// Determine the price of this product
		$GLOBALS['ProductPrice'] = '';
		if (GetConfig('ShowProductPrice') && !$row['prodhideprice']) {
			$GLOBALS['ProductPrice'] = formatProductCatalogPrice($row);
		}

		// Workout the product description
		$desc = strip_tags($row['proddesc']);

		if (isc_strlen($desc) < 120) {
			$GLOBALS['ProductSummary'] = $desc;
		} else {
			$GLOBALS['ProductSummary'] = isc_substr($desc, 0, 120) . "...";
		}

		$GLOBALS['ProductThumb'] = ImageThumb($row, ProdLink($row['prodname']));
		$GLOBALS['ProductDate'] = isc_date(GetConfig('DisplayDateFormat'), $row['proddateadded']);

		$GLOBALS['ProductPreOrder'] = false;
		$GLOBALS['ProductReleaseDate'] = '';
		$GLOBALS['HideProductReleaseDate'] = 'display:none';

		if ($row['prodpreorder']) {
			$GLOBALS['ProductPreOrder'] = true;
			if ($row['prodreleasedate'] && $row['prodreleasedateremove'] && time() >= (int)$row['prodreleasedate']) {
				$GLOBALS['ProductPreOrder'] = false;
			} else if ($row['prodreleasedate']) {
				$GLOBALS['ProductReleaseDate'] = GetLang('ProductListReleaseDate', array('releasedate' => isc_date(GetConfig('DisplayDateFormat'), (int)$row['prodreleasedate'])));
				$GLOBALS['HideProductReleaseDate'] = '';
			}
		}

		if (isId($row['prodvariationid']) || trim($row['prodconfigfields'])!='' || $row['prodeventdaterequired'] == 1) {
			$GLOBALS['ProductURL'] = ProdLink($row['prodname']);
			$GLOBALS['ProductAddText'] = GetLang('ProductChooseOptionLink');
		} else {
			$GLOBALS['ProductURL'] = CartLink($row['productid']);
			if ($GLOBALS['ProductPreOrder']) {
				$GLOBALS['ProductAddText'] = GetLang('ProductPreOrderCartLink');
			} else {
				$GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink');
			}
		}

		if (CanAddToCart($row) && GetConfig('ShowAddToCartLink')) {
			$GLOBALS['HideActionAdd'] = '';
		} else {
			$GLOBALS['HideActionAdd'] = 'none';
		}


		$GLOBALS['HideProductVendorName'] = 'display: none';
		$GLOBALS['ProductVendor'] = '';
		if(GetConfig('ShowProductVendorNames') && $row['prodvendorid'] > 0) {
			$vendorCache = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('Vendors');
			if(isset($vendorCache[$row['prodvendorid']])) {
				$GLOBALS['ProductVendor'] = '<a href="'.VendorLink($vendorCache[$row['prodvendorid']]).'">'.isc_html_escape($vendorCache[$row['prodvendorid']]['vendorname']).'</a>';
				$GLOBALS['HideProductVendorName'] = '';
			}
		}
	}
Example #23
0
 private function RunExport()
 {
     try {
         // check for a selected template
         if (!isset($_POST["template"]) || !$_POST["template"]) {
             throw new Exception(GetLang("NoTemplateSelected"));
         }
         if (!isset($_POST['format'])) {
             throw new Exception(GetLang("NoMethodSelected"));
         }
         $templateid = $_POST["template"];
         // check template exists
         $template = $this->templates->GetTemplate($templateid);
         // check the file type is available for this template
         if (!in_array($this->type, explode(",", $template['usedtypes']))) {
             throw new Exception(sprintf(GetLang("TypeNotAvailable"), $this->type));
         }
         $where = "";
         // get the custom search fields
         if (isset($_POST['ids'])) {
             $ids = explode(',', $_POST['ids']);
             $ids = implode(', ', array_map(array($GLOBALS['ISC_CLASS_DB'], "Quote"), $ids));
             $details = $this->filetype->GetTypeDetails();
             $where = $details['idfield'] . " IN (" . $_POST["ids"] . ")";
         } elseif (isset($_POST['searchId'])) {
             // get the where statement for this search
             $ret = $this->filetype->GetWhereFromSearch($_POST['searchId']);
             $where = $ret['where'];
         } elseif (isset($_POST['params'])) {
             $params = $this->GetParams($_POST['params']);
             $where = $this->filetype->GetWhereFromParams($params);
         }
         //$_SESSION['mywhere'] = $where; // this variable used in the function  ExportRows() by blessen
         // get the export method the user has chosen
         $method = ISC_ADMIN_EXPORTMETHOD_FACTORY::GetExportMethod($_POST['format']);
         // Initialise the export
         $method->Init($this->filetype, $templateid, $where, $this->vendorid);
         $details = $this->filetype->GetTypeDetails();
         if ($_POST['format'] == "CSV" && $details['name'] == "customers" && $method->settings['AltCustomers']) {
             // hackery to use alternate customers class
             $this->filetype = ISC_ADMIN_EXPORTFILETYPE_FACTORY::GetExportFileType("customersalt");
             // reinitialise the method with alternate file type
             $method->Init($this->filetype, $templateid, $where, $this->vendorid);
         }
         // run the export
         $file = $method->Export();
         $method_details = $method->GetMethodDetails();
         // log the export
         $GLOBALS['ISC_CLASS_LOG']->LogAdminAction($this->type_title, $template['exporttemplatename'], $method_details['name']);
         // send the file to the user
         DownloadFile($file, $this->type . "-" . isc_date("Y-m-d") . "." . $method_details['extension']);
         exit;
     } catch (Exception $ex) {
         FlashMessage($ex->getMessage(), MSG_ERROR);
         $this->StartExport();
     }
 }
Example #24
0
	protected function GetExportFileName()
	{
		$details = $this->filetype->GetTypeDetails();

		return $details['name'] . "-" . isc_date("Y-m-d") . "." . $this->method_extension;
	}
Example #25
0
	/**
	* NiceTime
	*
	* Returns a formatted timestamp
	* @return string The formatted string
	* @param int The unix timestamp to format
	*/
	public static function niceTime($UnixTimestamp)
	{
		return isc_date('jS F Y H:i:s', $UnixTimestamp);
	}
Example #26
0
    /**
     * Generate an individual row for the order items table.
     *
     * @param string The unique identifier for this row.
     * @param array Array of details about the product for this row.
     * @param boolean Set to true to hide this row by default.
     * @return string The generated HTML row for this item.
     */
    public function GenerateOrderItemRow($rowId, $product = array(), $hidden = false, $resetPrices = false)
    {
        static $first = true;
        static $publicWrappingOptions = null;
        if ($hidden == true) {
            $GLOBALS['HideRow'] = 'display: none';
        } else {
            $GLOBALS['HideRow'] = '';
        }
        //2011-9-13 alandy add shipping data show.
        $GLOBALS['ShippingdataRow'] = '';
        if (is_null($publicWrappingOptions)) {
            $wrappingOptions = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('GiftWrapping');
            if (empty($wrappingOptions)) {
                $publicWrappingOptions = false;
            } else {
                $publicWrappingOptions = true;
            }
        }
        if ($first != true) {
            $GLOBALS['HideInsertTip'] = 'display: none';
        }
        $first = false;
        if (empty($product)) {
            $GLOBALS['CartItemId'] = $rowId;
            $GLOBALS['ProductCode'] = '';
            $GLOBALS['vendorprefix'] = '';
            $GLOBALS['shippingDate'] = '';
            $GLOBALS['isshippingDate'] = '';
            $GLOBALS['trackingNumber'] = '';
            $GLOBALS['ProductId'] = 0;
            $GLOBALS['ProductName'] = '';
            $GLOBALS['HideWrappingOptions'] = 'display: none';
            $GLOBALS['HideProductFields'] = 'display: none;';
            $GLOBALS['HideProductVariation'] = 'display: none;';
            $GLOBALS['ProductPrice'] = FormatPrice(0, false, false, true);
            $GLOBALS['ProductQuantity'] = 1;
            $GLOBALS['ProductTotal'] = FormatPrice(0);
            $GLOBALS['HideEventDate'] = 'display : none;';
            $GLOBALS['EventDate'] = '';
            $GLOBALS['ShippingdataRow'] = '';
            $GLOBALS['ResetPrice'] = $GLOBALS['ISC_CLASS_ADMIN_AUTH']->HasPermission(AUTH_Reset_Price) ? "<input {$GLOBALS['ResetChecked']} value=\"{$GLOBALS['ResetStatus']}\" type='checkbox' name='cartItem[{$rowId}][resetPrice]' onclick='ResetPrice(this)'/>&nbsp;reset price" : '';
            return $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrderItem');
        }
        $GLOBALS['CartItemId'] = $rowId;
        //isc_html_escape($product['cartitemid']);
        // If the item in the cart is a gift certificate, we need to show a special type of row
        if (isset($product['type']) && $product['type'] == "giftcertificate") {
            $GLOBALS['ProductCode'] = GetLang('NA');
            $GLOBALS['ProductName'] = isc_html_escape($product['product_name']);
            $GLOBALS['ProductQuantity'] = (int) $product['quantity'];
            $GLOBALS['ProductPrice'] = FormatPrice($product['product_price']);
            $GLOBALS['ProductTotal'] = FormatPrice($product['product_price'] * $product['quantity']);
            return $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrderItemGiftCertificate');
        } else {
            require_once ISC_BASE_PATH . '/lib/discountcalcs.php';
            /**********************************************************************
            				Code altered by Mayank Jaitly on 05 July 2010
            			/**********************************************************************/
            $GLOBALS['YMMYearTemp'] = $product['year'];
            $GLOBALS['YMMMakeTemp'] = $product['make'];
            $GLOBALS['YMMModelTemp'] = $product['model'];
            $GLOBALS['YMMbedsizeTemp'] = $product['bedsize'];
            $GLOBALS['YMMcabsizeTemp'] = $product['cabsize'];
            $GLOBALS['ProductId'] = $product['product_id'];
            $GLOBALS['ProductName'] = isc_html_escape($product['product_name']);
            $GLOBALS['ProductQuantity'] = (int) $product['quantity'];
            $GLOBALS['ProductCode'] = $product['product_code'];
            $GLOBALS['vendorprefix'] = $product['vendorprefix'] . '-';
            $GLOBALS['shippingDate'] = $product['shippingDate'];
            $GLOBALS['isshippingDate'] = $product['isshippingDate'];
            $GLOBALS['trackingNumber'] = $product['trackingNumber'];
            //alandy 2011-9-13 modify shipping date.
            if (isset($GLOBALS['isshippingDate']) && $GLOBALS['isshippingDate'] != '01/01/1900' && !empty($GLOBALS['shippingDate'])) {
                $GLOBALS['ShippingdataRow'] = "<div><div style='float:left; width:180px;'>" . $GLOBALS['shippingDate'] . "</div><div style='float:left; width:400px; word-break:break-all; word-wrap:break-word;'>" . $GLOBALS['trackingNumber'] . "</div></div>";
            }
            // Don't use the discount price here as we'll be showing the coupon codes
            // down below in the summary table
            $productPrice = isset($product['discount_price']) && $product['discount_price'] < $product['product_price'] ? $product['discount_price'] : $product['product_price'];
            //20110503 alandy add resetprice.
            if ($resetPrices) {
                $GLOBALS['PriceReadonly'] = '';
                $GLOBALS['ResetChecked'] = 'checked';
                $GLOBALS['ResetStatus'] = '1';
            } else {
                $GLOBALS['PriceReadonly'] = 'readonly class="Field50 ItemPrice ReadonlyText"';
                $GLOBALS['ResetChecked'] = '';
                $GLOBALS['ResetStatus'] = '0';
            }
            $GLOBALS['ProductPrice'] = FormatPrice($productPrice, false, false, true);
            $GLOBALS['ProductTotal'] = FormatPrice($productPrice * $product['quantity']);
            // Initialize the configurable product fields
            $GLOBALS['HideProductFields'] = 'display: none;';
            $GLOBALS['ProductFields'] = '';
            if (!empty($product['product_fields']) && is_array($product['product_fields'])) {
                $GLOBALS['HideProductFields'] = '';
                foreach ($product['product_fields'] as $fieldId => $field) {
                    switch ($field['fieldType']) {
                        case 'file':
                            if (isset($field['fieldExisting'])) {
                                $fileDirectory = 'configured_products';
                            } else {
                                $fileDirectory = 'configured_products_tmp';
                            }
                            $fieldValue = '<a href="' . GetConfig('ShopPath') . '/' . GetConfig('ImageDirectory') . '/' . $fileDirectory . '/' . $field['fileName'] . '" target="_blank">' . isc_html_escape($field['fileOriginName']) . '</a>';
                            break;
                        case 'checkbox':
                            $fieldValue = GetLang('Checked');
                            break;
                        default:
                            if (isc_strlen($field['fieldValue']) > 50) {
                                $field['fieldValue'] = isc_substr($field['fieldValue'], 0, 50) . " ..";
                            }
                            $fieldValue = isc_html_escape($field['fieldValue']);
                            // browser is decoding the entities in the ajax response which prevents the row from loading so we need to double encode
                            if (isset($_REQUEST['ajaxFormUpload'])) {
                                $fieldValue = isc_html_escape($fieldValue);
                            }
                    }
                    if (!trim($fieldValue)) {
                        continue;
                    }
                    $GLOBALS['ProductFields'] .= '
							<dt>' . isc_html_escape($field['fieldName']) . ':</dt>
							<dd>' . $fieldValue . '</dd>
						';
                }
            }
            // Can this item be wrapped?
            $GLOBALS['HideWrappingOptions'] = 'display: none';
            if ($product['data']['prodtype'] == PT_PHYSICAL && @$product['data']['prodwrapoptions'] != -1 && $publicWrappingOptions == true) {
                $GLOBALS['HideWrappingOptions'] = '';
                if (isset($product['wrapping'])) {
                    $GLOBALS['GiftWrappingName'] = isc_html_escape($product['wrapping']['wrapname']);
                    $GLOBALS['HideGiftWrappingAdd'] = 'display: none';
                    $GLOBALS['HideGiftWrappingEdit'] = '';
                    $GLOBALS['HideGiftWrappingPrice'] = '';
                    $GLOBALS['GiftWrappingPrice'] = CurrencyConvertFormatPrice($product['wrapping']['wrapprice']);
                } else {
                    $GLOBALS['GiftWrappingName'] = '';
                    $GLOBALS['HideGiftWrappingAdd'] = '';
                    $GLOBALS['HideGiftWrappingEdit'] = 'display: none';
                    $GLOBALS['HideGiftWrappingPrice'] = 'display: none';
                    $GLOBALS['GiftWrappingPrice'] = '';
                }
            }
            // Is this product a variation?
            $GLOBALS['ProductOptions'] = '';
            $GLOBALS['HideProductVariation'] = 'display: none';
            if (isset($product['options']) && !empty($product['options'])) {
                $comma = '';
                $GLOBALS['HideProductVariation'] = '';
                foreach ($product['options'] as $name => $value) {
                    if (!trim($name) || !trim($value)) {
                        continue;
                    }
                    $GLOBALS['ProductOptions'] .= $comma . isc_html_escape($name) . ": " . isc_html_escape($value);
                    $comma = ' / ';
                }
            } else {
                if (isset($product['data']['prodvariationid']) && $product['data']['prodvariationid'] > 0) {
                    $GLOBALS['HideProductVariation'] = '';
                    $GLOBALS['ProductOptions'] = GetLang('xNone');
                }
            }
            if (isset($product['data']['prodeventdaterequired']) && $product['data']['prodeventdaterequired']) {
                $GLOBALS['HideEventDate'] = '';
                $GLOBALS['EventDate'] = '<dl><dt>' . $product['data']['prodeventdatefieldname'] . ': </dt><dd>' . isc_date('jS M Y', $product['event_date']) . '</dd></dl>';
            } else {
                $GLOBALS['HideEventDate'] = 'display : none;';
                $GLOBALS['EventDate'] = '';
            }
            $GLOBALS['ResetPrice'] = $GLOBALS['ISC_CLASS_ADMIN_AUTH']->HasPermission(AUTH_Reset_Price) ? "<input {$GLOBALS['ResetChecked']} value=\"{$GLOBALS['ResetStatus']}\" type='checkbox' name='cartItem[{$GLOBALS['CartItemId']}][resetPrice]' onclick='ResetPrice(this)'/>&nbsp;reset price" : '';
            $this->setOtherinfo($product['data'], true);
            return $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrderItem');
        }
    }
Example #27
0
		public function BuildWhereFromVars($array)
		{
			$queryWhere = "";
			$queryJoin = "";
			$queryHaving = "";

			// Is this a custom search?
			if(!empty($array['searchId'])) {
				$this->_customSearch = $GLOBALS['ISC_CLASS_ADMIN_CUSTOMSEARCH']->LoadSearch($array['searchId']);
				$array = array_merge($array, (array)$this->_customSearch['searchvars']);
			}

			if (isset($array['searchQuery']) && $array['searchQuery'] != "") {
				// PostgreSQL is case sensitive for likes, so all matches are done in lower case
				$search_query = $GLOBALS['ISC_CLASS_DB']->Quote(trim($array['searchQuery']));
				$queryWhere .= "
					AND (
						customerid = '" . $search_query . "' OR
						custconfirstname LIKE '%" . $search_query . "%' OR
						custconlastname LIKE '%" . $search_query . "%' OR
						custconemail LIKE '%" . $search_query . "%' OR
						CONCAT(custconfirstname, ' ', custconlastname) LIKE '%" . $search_query . "%' OR
						custconcompany LIKE '%" . $search_query . "%'
					)";
			}

			if (isset($array['letter']) && $array['letter'] != '') {
				$letter = chr(ord($array['letter']));
				if ($array['letter'] == '0-9') {
					$queryWhere .= " AND custconlastname NOT REGEXP('^[a-zA-Z]')";
				}
				else if (isc_strlen($letter) == 1) {
					$queryWhere .= " AND custconlastname LIKE '".$GLOBALS['ISC_CLASS_DB']->Quote($letter)."%'";
				}
			}

			if (isset($array['phone']) && $array['phone'] != "") {
				$phone = $GLOBALS['ISC_CLASS_DB']->Quote(trim($array['phone']));
				$queryWhere .= sprintf(" AND custconphone LIKE '%%%s%%'", $phone);
			}

			if (isset($array['idFrom']) && $array['idFrom'] != "") {
				$id_from = $GLOBALS['ISC_CLASS_DB']->Quote((int)$array['idFrom']);
				$queryWhere .= sprintf(" AND customerid >= '%d'", $id_from);
			}
			if (isset($array['idTo']) && $array['idTo']) {
				$id_to = $GLOBALS['ISC_CLASS_DB']->Quote((int)$array['idTo']);
				$queryWhere .= sprintf(" AND customerid <= '%d'", $id_to);
			}

			// limit by number of orders
			if (!empty($array['ordersFrom'])) {
				$orders_from = $GLOBALS['ISC_CLASS_DB']->Quote((int)$array['ordersFrom']);
				$queryHaving .= sprintf(" AND numorders >= '%d'", $orders_from);
			}

			if (!empty($array['ordersTo'])) {
				$orders_to = $GLOBALS['ISC_CLASS_DB']->Quote((int)$array['ordersTo']);
				$queryHaving .= sprintf(" AND numorders <= '%d'", $orders_to);
			}

			if (isset($array['storeCreditFrom']) && $array['storeCreditFrom'] != "") {
				$credit_from = $GLOBALS['ISC_CLASS_DB']->Quote((int)$array['storeCreditFrom']);
				$queryWhere .= sprintf(" AND custstorecredit >= '%d'", $credit_from);
			}

			if (isset($array['storeCreditTo']) && $array['storeCreditTo'] != "") {
				$credit_to = $GLOBALS['ISC_CLASS_DB']->Quote((int)$array['storeCreditTo']);
				$queryWhere .= sprintf(" AND custstorecredit <= '%d'", $credit_to);
			}

			// Limit results to a particular join date range
			if (isset($array['dateRange']) && $array['dateRange'] != "") {
				$range = $array['dateRange'];
				switch($range) {
					// Registrations within the last day
					case "today":
						$from_stamp = mktime(0, 0, 0, isc_date("m"), isc_date("d"), isc_date("Y"));
						break;
					// Registrations received in the last 2 days
					case "yesterday":
						$from_stamp = mktime(0, 0, 0, isc_date("m"), date("d")-1, isc_date("Y"));
						$to_stamp = mktime(0, 0, 0, isc_date("m"), isc_date("d")-1, isc_date("Y"));
						break;
					// Registrations received in the last 24 hours
					case "day":
						$from_stamp = time()-60*60*24;
						break;
					// Registrations received in the last 7 days
					case "week":
						$from_stamp = time()-60*60*24*7;
						break;
					// Registrations received in the last 30 days
					case "month":
						$from_stamp = time()-60*60*24*30;
						break;
					// Registrations received this month
					case "this_month":
						$from_stamp = mktime(0, 0, 0, isc_date("m"), 1, isc_date("Y"));
						break;
					// Orders received this year
					case "this_year":
						$from_stamp = mktime(0, 0, 0, 1, 1, isc_date("Y"));
						break;
					// Custom date
					default:
						if (isset($array['fromDate']) && $array['fromDate'] != "") {
							$from_date = $array['fromDate'];
							$from_data = explode("/", $from_date);
							$from_stamp = mktime(0, 0, 0, $from_data[0], $from_data[1], $from_data[2]);
						}
						if (isset($array['toDate']) && $array['toDate'] != "") {
							$to_date = $array['toDate'];
							$to_data = explode("/", $to_date);
							$to_stamp = mktime(0, 0, 0, $to_data[0], $to_data[1], $to_data[2]);
						}
				}

				if (isset($from_stamp)) {
					$queryWhere .= sprintf(" AND custdatejoined >= '%d'", $from_stamp);
				}
				if (isset($to_stamp)) {
					$queryWhere .= sprintf(" AND custdatejoined <= '%d'", $to_stamp);
				}
			}

			if (isset($array['custGroupId']) && is_numeric($array['custGroupId'])) {
				$custGroupId = (int)$array['custGroupId'];

				// is this group the default group? we should then search for customers with a groupid of 0 as well
				$groupQuery = 'SELECT * FROM [|PREFIX|]customer_groups WHERE customergroupid = ' . $custGroupId . ' AND isdefault = 1';
				$groupRes = $this->db->Query($groupQuery);
				if ($this->db->CountResult($groupRes)) {
					$queryWhere .= ' AND (custgroupid = ' . $custGroupId . ' OR custgroupid = 0)';
				}
				else {
					$queryWhere .= ' AND custgroupid = ' . $custGroupId;
				}
			}

			// Search for users with a particular shipping country & state
			if (isset($array['country']) && $array['country'] != "") {
				$country = $GLOBALS['ISC_CLASS_DB']->Quote((int)$array['country']);

				$queryJoin .= " LEFT JOIN [|PREFIX|]shipping_addresses ON shipcustomerid = customerid";
				$queryWhere .= sprintf(" AND shipcountryid='%s'", $country);

				$state = '';
				if (isset($array['state']) && $array['state'] != "") {
					$state = GetStateById($array['state']);
				}
				else if (isset($array['state_1']) && $array['state_1'] != "") {
					$state = $array['state_1'];
				}

				// Searching by state too
				if ($state != '') {
					$queryWhere .= " AND shipstate='".$GLOBALS['ISC_CLASS_DB']->Quote($state)."'";
				}
			}

			return array("query" => $queryWhere, "join" => $queryJoin, "having" => $queryHaving);
		}
 /**
  *	Show statistics for products
  */
 public function ProductStats()
 {
     if (isset($_POST['Calendar'])) {
         $cal = $this->CalculateCalendarRestrictions($_POST['Calendar']);
         $GLOBALS['CurrentDate'] = $_POST['Calendar']['DateType'];
     } else {
         $cal = $this->CalculateCalendarRestrictions();
         $GLOBALS['CurrentDate'] = "Last30Days";
     }
     $GLOBALS['CalendarDateTypeOptions'] = $this->_GetCalendarDateTypesAsOptions($GLOBALS['CurrentDate']);
     if (isset($_POST['currentTab'])) {
         $GLOBALS['CurrentTab'] = (int) $_POST['currentTab'];
     } else {
         $GLOBALS['CurrentTab'] = 0;
     }
     // Set the global variables for the select boxes
     $from_stamp = $cal['start'];
     $to_stamp = $cal['end'];
     $from_day = isc_date("d", $from_stamp);
     $from_month = isc_date("m", $from_stamp);
     $from_year = isc_date("Y", $from_stamp);
     $to_day = isc_date("d", $to_stamp);
     $to_month = isc_date("m", $to_stamp);
     $to_year = isc_date("Y", $to_stamp);
     $GLOBALS['OverviewFromDays'] = $this->_GetDayOptions($from_day);
     $GLOBALS['OverviewFromMonths'] = $this->_GetMonthOptions($from_month);
     $GLOBALS['OverviewFromYears'] = $this->_GetYearOptions($from_year);
     $GLOBALS['OverviewToDays'] = $this->_GetDayOptions($to_day);
     $GLOBALS['OverviewToMonths'] = $this->_GetMonthOptions($to_month);
     $GLOBALS['OverviewToYears'] = $this->_GetYearOptions($to_year);
     $GLOBALS['FromStamp'] = $from_stamp;
     $GLOBALS['ToStamp'] = $to_stamp;
     $vendorRestriction = $this->GetVendorRestriction();
     if ($vendorRestriction !== false) {
         $GLOBALS['VendorId'] = (int) $vendorRestriction;
     } else {
         $GLOBALS['VendorId'] = '';
     }
     // If we can, get a list of the available vendors
     $GLOBALS['HideVendorList'] = 'display: none';
     if ($GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId() == 0 && gzte11(ISC_HUGEPRINT)) {
         $GLOBALS['VendorSelect'] = '';
         // All vendors option
         $sel = '';
         if (!isset($_REQUEST['vendorId']) || $_REQUEST['vendorId'] == "") {
             $sel = 'selected="selected"';
         }
         $GLOBALS['VendorSelect'] .= "<option value='' " . $sel . ">" . GetLang('AllVendors') . "</option>";
         // No vendor option
         $sel = '';
         if (isset($_REQUEST['vendorId']) && $_REQUEST['vendorId'] == "0") {
             $sel = 'selected="selected"';
         }
         $GLOBALS['VendorSelect'] .= "<option value='0' " . $sel . ">" . GetLang('NoSelVendor') . "</option>";
         $query = "\n\t\t\t\tSELECT vendorid, vendorname\n\t\t\t\tFROM [|PREFIX|]vendors\n\t\t\t\tORDER BY vendorname ASC\n\t\t\t";
         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         $hasVendors = false;
         while ($vendor = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
             $hasVendors = true;
             $sel = '';
             if (isset($_REQUEST['vendorId']) && $_REQUEST['vendorId'] == $vendor['vendorid']) {
                 $sel = 'selected="selected"';
             }
             $GLOBALS['VendorSelect'] .= "<option value='" . $vendor['vendorid'] . "' " . $sel . ">" . isc_html_escape($vendor['vendorname']) . "</option>";
         }
         if ($hasVendors) {
             $GLOBALS['HideVendorList'] = '';
         }
     }
     /**
      * Hide the inventory screen if we are starter
      */
     if (!gzte11(ISC_MEDIUMPRINT)) {
         $GLOBALS['HideInventoryTab'] = 'none';
         $GLOBALS['ShowInventoryGrid'] = '0';
     } else {
         $GLOBALS['HideInventoryTab'] = '';
         $GLOBALS['ShowInventoryGrid'] = '1';
     }
     $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("stats.products");
     $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate();
 }
Example #29
0
	if(file_exists(ISC_BASE_PATH.'/custom/config.php')) {
		require ISC_BASE_PATH.'/custom/config.php';
	}

	if (GetConfig('HostingId')) {
		// forced config settings for BigCommerce
		$GLOBALS['ISC_CFG']['DeletedOrdersAction'] = 'delete';
		$GLOBALS['ISC_CFG']['GiftCertificateCustomDirectory'] = '__custom/GiftThemes';
		$GLOBALS['ISC_CFG']['GiftCertificateMasterDirectory'] = '__master/__gift_themes';
	}

	require(ISC_BASE_PATH . '/lib/database/mysql.php');
	// Set the character encoding to use

	$GLOBALS['Year'] = isc_date('Y');

	header("Content-Type: text/html; charset=" . GetConfig('CharacterSet'));
	STSSetEncoding(GetConfig('CharacterSet'));

	// Connect to the database - MySQL or PostgreSQL
	if (GetConfig('isSetup')) {
		NormalizeSSLSettings();

		// Are they accessing the store via an alternate URL?
		if(!empty($_SERVER['HTTP_HOST'])) {
			$protocol = 'http';
			if($_SERVER['HTTPS'] == 'on') {
				$protocol = 'https';
			}
			$currentLocation = $protocol.'://'.$_SERVER['HTTP_HOST'].'/'.trim(GetCurrentLocation(), '/').'/';
Example #30
0
	public function setPanelSettings()
	{
		if (!isset($GLOBALS['OrderId']) || !isId($GLOBALS['OrderId'])) {
			$this->DontDisplay = true;
			return;
		}

		$orderId = $GLOBALS['OrderId'];

		// Fetch the shipments for the order (not bothering to select address details here since we're viewing in the context of the order where addresses should already show)
		$shipments = array();
		$query = "
			SELECT shipmentid, shipdate, shiptrackno, shipping_module, shipmethod, shipcomments, shipshipcountryid
			FROM [|PREFIX|]shipments
			WHERE shiporderid = " . $orderId . "
			ORDER BY shipdate, shipmentid
		";
		$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
		while ($shipment = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
			$shipments[] = $shipment;
		}

		if (empty($shipments)) {
			$this->DontDisplay = true;
			return;
		}

		$GLOBALS['LNG_OrderShipments'] = GetLang('ShipmentsForOrder', array(
			'order' => $orderId,
		));

		$GLOBALS['SNIPPETS']['AccountOrderShipmentRow'] = '';

		foreach ($shipments as $shipment) {
			GetModuleById('shipping', /** @var ISC_SHIPPING */$module, $shipment['shipping_module']);

			$GLOBALS['DateShipped'] = isc_date(GetConfig('DisplayDateFormat'), $shipment['shipdate']);

			if ($module) {
				$GLOBALS['ShippingProvider'] = $module->GetName();
				$module->SetDestinationCountry($shipment['shipshipcountryid']);
			} else {
				$GLOBALS['ShippingProvider'] = $shipment['shipping_module'];
			}

			$GLOBALS['ShippingMethod'] = $shipment['shipmethod'];
			if (empty($GLOBALS['ShippingMethod']) || $GLOBALS['ShippingMethod'] == $GLOBALS['ShippingProvider']) {
				$GLOBALS['HideShippingMethod'] = 'display:none';
			} else {
				$GLOBALS['HideShippingMethod'] = '';
			}

			$GLOBALS['TrackingLink'] = isc_html_escape($shipment['shiptrackno']);
			if ($module) {
				$link = $module->GetTrackingLink($shipment['shiptrackno']);
				if ($link) {
					$GLOBALS['TrackingLink'] = '<a href="' . isc_html_escape($link) . '" target="_blank">' . $GLOBALS['TrackingLink'] . '</a>';
				}
			}

			$GLOBALS['SNIPPETS']['AccountOrderShipmentRow'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('AccountOrderShipmentRow');
		}
	}