/** * Actually track a visitor. */ public function TrackVisitor() { $today_stamp = isc_gmmktime(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; }
function __construct() { if (isset($_GET['FromDate'])) { $this->from_date = (int) $_GET['FromDate']; } else { $this->from_date = isc_gmmktime(0, 0, 0, isc_date("m"), isc_date("d") - 30, isc_date("Y")); } if (isset($_GET['ToDate'])) { $this->to_date = (int) $_GET['ToDate']; } else { $this->to_date = time(); } if (isset($_GET['Search_Type'])) { $this->stype = strtolower($_GET['Search_Type']); if (strtolower($_GET['Search_Type']) === strtolower('SearchStatsBestPerformanceGrid')) { $this->clickwhere = 1; } if (strtolower($_GET['Search_Type']) === strtolower('SearchStatsWorstPerformanceGrid')) { $this->clickwhere = 0; } } else { $this->stype = strtolower('KeywordWithResults'); } }
/** * Load up the customers and organize them based on the date when they registered. * The "from" and "to" timestamps are passed in to determine between which dates * we will retrieve the customers. */ public function CustomerStatsByDateData() { if(isset($_GET['from']) && is_numeric($_GET['from']) && isset($_GET['to']) && is_numeric($_GET['to'])) { $customers = array(); $conversions = array(); $from = (int)$_GET['from']; $to = (int)$_GET['to']; $x_counter = 0; $visitor_xml = ""; $visitor_dates = array(); $visitor_rows = array(); $conversion_xml = ""; // Create the first components of the XML block $xml = '<?xml version="1.0" encoding="UTF-8"?>'."\n"; $xml .= "<chart>\n"; $xml .= " <xaxis>\n"; // Start by building the axis' on the chart based on the selected date range // Convert the from and to dates into days then substract "to" from "from" to // workout the number of days worth of data we need to chart $from_days = $from / 86400; $to_days = $to / 86400; $num_days = floor($to_days - $from_days)+1; // How many days do we have to show data for? We will break up the data as follows: // 0-1 days (shown as hours on x axis) // 1-60 days (shown as days on x axis) // 61-182 days (shown as weeks on x axis) // 182-730 days (shown as months on x axis) // 730+ days (shown as years on x axis) $day_format = "g:00 A (jS M Y)"; $week_format = "\W\e\e\k W"; $month_format = "M Y"; $year_format = "Y"; if($num_days <= 1) { // Get customers and show them for each hour $num_val = $num_days; if($num_val == 0) { $num_val = 1; } for($i = 0; $i < $num_val*25; $i++) { $xml .= sprintf(" <value xid=\"%s\">%s</value>\n", isc_date($day_format, $from + (3600 * $i)), isc_date($day_format, $from + (3600 * $i))); $customers[isc_date($day_format, $from + (3600 * $i))] = 0; } } else if($num_days > 1 && $num_days <= 60) { // Get customers and show them for each day for($i = 0; $i < $num_days; $i++) { $xml .= sprintf(" <value xid=\"%s\">%s</value>\n", isc_date(GetConfig('DisplayDateFormat'), $from + (86400 * $i)), isc_date(GetConfig('DisplayDateFormat'), $from + (86400 * $i))); $customers[isc_date(GetConfig('DisplayDateFormat'), $from + (86400 * $i))] = 0; $visitor_dates[] = array("format" => isc_date(GetConfig('DisplayDateFormat'), $from + (86400 * $i)), "stamp" => $from + (86400 * $i) ); // Track the conversion rate $conversions[isc_date(GetConfig('DisplayDateFormat'), $from + (86400 * $i))] = 0; } } else if($num_days > 60 && $num_days <= 182) { // Get customers and show them for each week $num_weeks = ceil($num_days / 7); for($i = 0; $i < $num_weeks+1; $i++) { $extended_stamp = sprintf("%s -\n %s", isc_date(GetConfig('DisplayDateFormat'), $from + (604800 * $i)), isc_date(GetConfig('DisplayDateFormat'), $from + (604800 * $i + (86400*7)))); $xml .= sprintf(" <value xid=\"%s\">%s</value>\n", isc_date($week_format, $from + (604800 * $i)), $extended_stamp); $customers[isc_date($week_format, $from + (604800 * $i))] = 0; $visitor_dates[] = array("format" => isc_date(GetConfig('DisplayDateFormat'), $from + (604800 * $i)), "stamp" => $from + (604800 * $i) ); // Track the conversion rate $conversions[isc_date(GetConfig('DisplayDateFormat'), $from + (604800 * $i))] = 0; } } else if($num_days > 182 && $num_days <= 730) { // Get customers and show them for each month $num_months = ceil($num_days / 31)+1; $from_month = isc_date("m", $from); $from_year = isc_date("Y", $from); for($i = 0; $i < $num_months+1; $i++) { // Workout the timestamp for the first day of the month $first_day_stamp = isc_mktime(0, 0, 0, $from_month+$i, 1, $from_year); $output_format = isc_date($month_format, $first_day_stamp); $xml .= sprintf(" <value xid=\"%s\">%s</value>\n", $output_format, $output_format); $customers[$output_format] = 0; $visitor_dates[] = array("format" => $output_format, "stamp" => $first_day_stamp ); // Track the conversion rate $conversions[$output_format] = 0; } } else if($num_days > 730) { // Get customers and show them for each year $num_years = ceil($num_days / 365)+1; $from_year = isc_date("Y", $from); for($i = 0; $i < $num_years+1; $i++) { // Workout the timestamp for the first day of the year $first_day_stamp = isc_mktime(0, 0, 0, 1, 1, $from_year+$i); $output_format = isc_date($year_format, $first_day_stamp); $xml .= sprintf(" <value xid=\"%s\">%s</value>\n", $output_format, $output_format); $customers[isc_date($year_format, $from + (31536000 * $i))] = 0; $visitor_dates[] = array("format" => isc_date($year_format, $from + (31536000 * $i)), "stamp" => $from + (31536000 * $i) ); // Track the conversion rate $conversions[isc_date($year_format, $from + (31536000 * $i))] = 0; } } $xml .= " </xaxis>\n"; $xml .= " <graphs>\n"; $xml .= " <graph gid=\"1\">\n"; // Start the graph that shows number of customers if($num_days <= 1) { // Get customers and show them for each hour $query = sprintf("select custdatejoined from [|PREFIX|]customers where custdatejoined >= '%s' and custdatejoined <= '%s'", $from, $to); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); // Split the customers based on the day they came in while($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { if(isset($customers[isc_date($day_format, $row['custdatejoined'])])) { $customers[isc_date($day_format, $row['custdatejoined'])]++; } } // We now have the customers in an array based on the date they joined, // so we can loop through them to create the first graph on the chart $x_counter = 0; foreach($customers as $join_date=>$join_count) { $xml .= sprintf(" <value xid=\"%s\">%d</value>\n", $join_date, $join_count); } } else if($num_days > 1 && $num_days <= 60) { // Get customers and show them for each day $query = sprintf("select custdatejoined from [|PREFIX|]customers where custdatejoined >= '%s' and custdatejoined <= '%s'", $from, $to); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); // Split the customers based on the day they came in while($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { @$customers[isc_date(GetConfig('DisplayDateFormat'), $row['custdatejoined'])]++; } // We now have the customers in an array based on the date they joined, // so we can loop through them to create the first graph on the chart $x_counter = 0; foreach($customers as $join_date=>$join_count) { $xml .= sprintf(" <value xid=\"%s\">%d</value>\n", $join_date, $join_count); $conversions[$join_date] = array("customers" => $join_count, "visitors" => 0 ); } // Build the XML for number of unique visitors $query = sprintf("select datestamp, numuniques from [|PREFIX|]unique_visitors where datestamp >= '%d' and datestamp <= '%d'", $from, $to); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); while($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $visitor_rows[$row['datestamp']] = $row['numuniques']; } for($i = 0; $i < count($visitor_dates); $i++) { $date_format = $visitor_dates[$i]['format']; $date_stamp = isc_gmmktime(0, 0, 0, isc_date("m", $visitor_dates[$i]['stamp']), isc_date("d", $visitor_dates[$i]['stamp']), isc_date("Y", $visitor_dates[$i]['stamp'])); // Were there any visitors for this day? if(isset($visitor_rows[$date_stamp])) { $uniques = $visitor_rows[$date_stamp]; } else { $uniques = 0; } $visitor_xml .= sprintf(" <value xid=\"%s\">%d</value>\n", $date_format, $uniques); // Update the conversion array $conversions[$date_format]['visitors'] = $uniques; // Workout the conversion rate and add it to the XML if($conversions[$date_format]['visitors'] > 0) { $conversion_rate = number_format((($conversions[$date_format]['customers'] / $conversions[$date_format]['visitors'])*100), 2); } else { // Avoid a divide by zero error $conversion_rate = 0; } $conversion_xml .= sprintf(" <value xid=\"%s\">%.2f</value>\n", $date_format, $conversion_rate); } } else if($num_days > 60 && $num_days <= 182) { // Get customers and show them for each week $query = sprintf("select custdatejoined from [|PREFIX|]customers where custdatejoined >= '%s' and custdatejoined <= '%s'", $from, $to); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); // Split the customers based on the week they came in while($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $customers[isc_date($week_format, $row['custdatejoined'])]++; } // We now have the customers in an array based on the date t, // so we can loop through them to create the first graph on the chart $x_counter = 0; foreach($customers as $join_date=>$join_count) { $xml .= sprintf(" <value xid=\"%s\">%d</value>\n", $join_date, $join_count); $conversions[$join_date] = array("customers" => $join_count, "visitors" => 0 ); } // Loop through each week and calculate the number of visitors during that week foreach($visitor_dates as $visit_week) { $week_starts = $visit_week['stamp']; $week_ends = $week_starts + (3600*7); $query = sprintf("select sum(numuniques) as total from [|PREFIX|]unique_visitors where datestamp >= '%d' and datestamp <= '%d'", $week_starts, $week_ends); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $row = $GLOBALS['ISC_CLASS_DB']->Fetch($result); $visitor_xml .= sprintf(" <value xid=\"%s\">%d</value>\n", isc_date($week_format, $week_starts), $row['total']); // Update the conversion array $conversions[isc_date($week_format, $week_starts)]['visitors'] = $row['total']; // Workout the conversion rate and add it to the XML if($conversions[isc_date($week_format, $week_starts)]['visitors'] > 0) { $conversion_rate = number_format((($conversions[isc_date($week_format, $week_starts)]['customers'] / $conversions[isc_date($week_format, $week_starts)]['visitors'])*100), 2); } else { // Avoid a divide by zero error $conversion_rate = 0; } $conversion_xml .= sprintf(" <value xid=\"%s\">%.2f</value>\n", isc_date($week_format, $week_starts), $conversion_rate); } } else if($num_days > 182 && $num_days <= 730) { // Get customers and show them for each month $query = sprintf("select custdatejoined from [|PREFIX|]customers where custdatejoined >= '%s' and custdatejoined<= '%s'", $from, $to); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); // Split the customers based on the week they came in while($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $customers[isc_date($month_format, $row['custdatejoined'])]++; } // We now have the customers in an array based on the date they joined, // so we can loop through them to create the first graph on the chart $x_counter = 0; foreach($customers as $join_date=>$join_count) { $xml .= sprintf(" <value xid=\"%s\">%d</value>\n", $join_date, $join_count); $conversions[$join_date] = array("customers" => $join_count, "visitors" => 0 ); } // Loop through each month and calculate the number of visitors during that month foreach($visitor_dates as $visit_month) { $month_starts = $visit_month['stamp']; $month_ends = $month_starts + 2592000; $query = sprintf("select sum(numuniques) as total from [|PREFIX|]unique_visitors where datestamp >= '%d' and datestamp <= '%d'", $month_starts, $month_ends); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $row = $GLOBALS['ISC_CLASS_DB']->Fetch($result); $visitor_xml .= sprintf(" <value xid=\"%s\">%d</value>\n", isc_date($month_format, $month_starts), $row['total']); // Update the conversion array $conversions[isc_date($month_format, $month_starts)]['visitors'] = $row['total']; // Workout the conversion rate and add it to the XML if($conversions[isc_date($month_format, $month_starts)]['visitors'] > 0) { $conversion_rate = number_format((($conversions[isc_date($month_format, $month_starts)]['customers'] / $conversions[isc_date($month_format, $month_starts)]['visitors'])*100), 2); } else { // Avoid a divide by zero error $conversion_rate = 0; } $conversion_xml .= sprintf(" <value xid=\"%s\">%.2f</value>\n", isc_date($month_format, $month_starts), $conversion_rate); } } else if($num_days > 730) { // Get customers and show them for each month $query = sprintf("select custdatejoined from [|PREFIX|]customers where custdatejoined >= '%s' and custdatejoined <= '%s'", $from, $to); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); // Split the customers based on the week they came in while($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $customers[isc_date($year_format, $row['custdatejoined'])]++; } // We now have the customers in an array based on the date they registered // so we can loop through them to create the first graph on the chart $x_counter = 0; foreach($customers as $join_date=>$join_count) { $xml .= sprintf(" <value xid=\"%s\">%d</value>\n", $join_date, $join_count); $conversions[$join_date] = array("customers" => $join_count, "visitors" => 0 ); } // Loop through each year and calculate the number of visitors during that year foreach($visitor_dates as $visit_year) { $year_starts = $visit_year['stamp']; $year_ends = $year_starts + 31536000; $query = sprintf("select sum(numuniques) as total from [|PREFIX|]unique_visitors where datestamp >= '%d' and datestamp <= '%d'", $year_starts, $year_ends); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $row = $GLOBALS['ISC_CLASS_DB']->Fetch($result); $visitor_xml .= sprintf(" <value xid=\"%s\">%d</value>\n", isc_date($year_format, $year_starts), $row['total']); // Update the conversion array $conversions[isc_date($year_format, $year_starts)]['visitors'] = $row['total']; // Workout the conversion rate and add it to the XML if($conversions[isc_date($year_format, $year_starts)]['visitors'] > 0) { $conversion_rate = number_format((($conversions[isc_date($year_format, $year_starts)]['customers'] / $conversions[isc_date($year_format, $year_starts)]['visitors'])*100), 2); } else { // Avoid a divide by zero error $conversion_rate = 0; } $conversion_xml .= sprintf(" <value xid=\"%s\">%.2f</value>\n", isc_date($year_format, $year_starts), $conversion_rate); } } $xml .= " </graph>\n"; // Only show visitor data if we're reporting on 2 or more days if($num_days > 1) { $xml .= " <graph gid=\"2\">\n"; $xml .= $visitor_xml; $xml .= " </graph>\n"; $xml .= " <graph gid=\"3\">\n"; $xml .= $conversion_xml; $xml .= " </graph>\n"; } $xml .= " </graphs>\n"; $xml .= "</chart>"; // Send the XML back to the browser echo $xml; } }
/** * Add a product to the order that's being created/edited. */ private function OrderAddProduct() { if (!isset($_REQUEST['cartItemId']) && !isset($_REQUEST['productId']) || !isset($_REQUEST['orderSession'])) { exit; } $cartOptions = array('updateQtyIfExists' => false); if (isset($_REQUEST['EventDate'])) { $cartOptions['EventDate'] = isc_gmmktime(0, 0, 0, $_REQUEST['EventDate']['Mth'], $_REQUEST['EventDate']['Day'], $_REQUEST['EventDate']['Yr']); } if (isset($_REQUEST['ordcustid']) && $_REQUEST['ordcustid'] != 0) { $customerClass = GetClass('ISC_CUSTOMER'); $customer = $customerClass->GetCustomerInfo($_REQUEST['ordcustid']); if (isset($customer['custgroupid'])) { $cartOptions['customerGroup'] = $customer['custgroupid']; } } else { if (isset($_REQUEST['custgroupid']) && $_REQUEST['custgroupid'] != 0) { $cartOptions['customerGroup'] = (int) $_REQUEST['custgroupid']; } } if (isset($_REQUEST['variationId'])) { $variationId = $_REQUEST['variationId']; } else { $variationId = 0; } if (isset($_REQUEST['customerGroup'])) { $orderDetails['customerGroup'] = (int) $_REQUEST['customerGroup']; } $productFields = $this->BuildProductConfigurableFieldData(); $orderClass = GetClass('ISC_ADMIN_ORDERS'); $rowId = $orderClass->GetCartApi($_REQUEST['orderSession'])->AddItem($_REQUEST['productId'], $_REQUEST['quantity'], $variationId, $productFields, $_REQUEST['cartItemId'], $cartOptions); if ($rowId === false) { $errors = implode("\n", $orderClass->GetCartApi()->GetErrors()); if (!$errors) { $errors = GetLang('ErrorAddingProductToOrder'); } $response = array('error' => $errors); } else { $product = $orderClass->GetCartApi()->GetProductInCart($rowId); $response = array('productRow' => $orderClass->GenerateOrderItemRow($rowId, $product), 'orderSummary' => $orderClass->GenerateOrderSummaryTable(), 'productRowId' => $rowId); if ($_REQUEST['cartItemId'] != $rowId) { $response['removeRow'] = (string) $_REQUEST['cartItemId']; } } if (isset($_REQUEST['ajaxFormUpload'])) { echo '<textarea>' . isc_json_encode($response) . '</textarea>'; exit; } echo isc_json_encode($response); exit; }
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(); $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->_CopyDownloads($prodId, 0, $GLOBALS['ProductHash']); $productImages = ISC_PRODUCT_IMAGE::copyImagesToProductHash($prodId, $GLOBALS['ProductHash']); $this->setupProductImageGlobals($productImages); $arrData['prodname'] = GetLang('CopyOf') . $arrData['prodname']; } $this->template->assign('product', $arrData); // 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'); } 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['RelatedCategoryOptions'] = $GLOBALS['ISC_CLASS_ADMIN_CATEGORY']->GetCategoryOptions(0, "<option %s value='%d'>%s</option>", "selected='selected'", "- ", false); $wysiwygOptions = array( 'id' => 'wysiwyg', 'width' => '100%', 'height' => '500px', 'value' => $arrData['proddesc'] ); $GLOBALS['WYSIWYG'] = GetClass('ISC_ADMIN_EDITOR')->GetWysiwygEditor($wysiwygOptions); $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['prodallowpurchases'] == 1) { $GLOBALS['ProdAllowPurchases'] = 'checked="checked"'; } else { if($arrData['prodhideprice'] == 1) { $GLOBALS['ProdHidePrice'] = 'checked="checked"'; } $GLOBALS['ProdCallForPricingLabel'] = isc_html_escape($arrData['prodcallforpricinglabel']); } $GLOBALS['ProdWarranty'] = $arrData['prodwarranty']; $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('taxEnteredWithPrices') == TAX_PRICES_ENTERED_INCLUSIVE) { $this->template->assign('enterPricesWithTax', true); } $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'] .= $this->template->render('Snippets/CustomFields.html'); $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'] .= $this->template->render('Snippets/CustomFields.html'); // 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"; } // Get the list of tax classes and assign them $this->template->assign('taxClasses', array( 0 => getLang('DefaultTaxClass') ) + getClass('ISC_TAX')->getTaxClasses()); // 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(0); } else { $GLOBALS['DiscountRules'] = $this->GetDiscountRules($prodId); } // 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'; } //Google website optimizer $GLOBALS['HideOptimizerConfigForm'] = 'display:none;'; $GLOBALS['CheckEnableOptimizer'] = ''; $GLOBALS['SkipConfirmMsg'] = 'false'; $GLOBALS['GoogleWebsiteOptimizerIntro'] = GetLang('ProdGoogleWebsiteOptimizerIntro'); $enabledOptimizers = GetConfig('OptimizerMethods'); if(!empty($enabledOptimizers)) { foreach ($enabledOptimizers as $id => $date) { GetModuleById('optimizer', $optimizerModule, $id); if ($optimizerModule->_testPage == 'products' || $optimizerModule->_testPage == 'all') { $GLOBALS['SkipConfirmMsg'] = 'false'; break; } } } if($arrData['product_enable_optimizer'] == '1') { $GLOBALS['HideOptimizerConfigForm'] = ''; $GLOBALS['CheckEnableOptimizer'] = 'Checked'; } $this->template->assign('prodminqty', $arrData['prodminqty']); $this->template->assign('prodmaxqty', $arrData['prodmaxqty']); $optimizer = getClass('ISC_ADMIN_OPTIMIZER'); $GLOBALS['OptimizerConfigForm'] = $optimizer->showPerItemConfigForm('product', $arrData['productid'],prodLink($arrData['prodname'])); if ($arrData['prodpreorder'] && $arrData['prodreleasedateremove'] && time() >= $arrData['prodreleasedate']) { // pre-order release date has passed and remove is ticked, remove it now for the copy form at least - saving it will commit it to the db $arrData['prodpreorder'] = 0; $arrData['prodreleasedate'] = 0; $arrData['prodreleasedateremove'] = 0; } // note: prodpreorder is a database column does not map directly to a form field, it'll be set to 1 if _prodorderable is 'pre', along with prodallowpurchases to 1 // note: _prodorderable is a form field that does not map to a database column if (!$arrData['prodallowpurchases']) { $this->template->assign('_prodorderable', 'no'); } else if ($arrData['prodpreorder']) { $this->template->assign('_prodorderable', 'pre'); } else { $this->template->assign('_prodorderable', 'yes'); } $this->template->assign('prodreleasedateremove', $arrData['prodreleasedateremove']); if (isset($arrData['prodpreordermessage']) && $arrData['prodpreordermessage']) { $this->template->assign('prodpreordermessage', $arrData['prodpreordermessage']); } else { $this->template->assign('prodpreordermessage', GetConfig('DefaultPreOrderMessage')); } if ($arrData['prodreleasedate']) { $this->template->assign('prodreleasedate', isc_date('d/m/Y', $arrData['prodreleasedate'])); } $GLOBALS['ProdCondition' . $arrData['prodcondition'] . 'Selected'] = 'selected="selected"'; if ($arrData['prodshowcondition']) { $GLOBALS['ProdShowCondition'] = 'checked="checked"'; } // Open Graph Settings $this->template->assign('openGraphTypes', ISC_OPENGRAPH::getObjectTypes(true)); $this->template->assign('openGraphSelectedType', $arrData['opengraph_type']); $this->template->assign('openGraphUseProductName', (bool)$arrData['opengraph_use_product_name']); $this->template->assign('openGraphTitle', $arrData['opengraph_title']); $this->template->assign('openGraphUseMetaDescription', (bool)$arrData['opengraph_use_meta_description']); $this->template->assign('openGraphDescription', $arrData['opengraph_description']); $this->template->assign('openGraphUseImage', (bool)$arrData['opengraph_use_image']); // UPC $this->template->assign('ProdUPC', $arrData['upc']); // Google Checkout $this->template->assign('ProdDisableGoogleCheckout', $arrData['disable_google_checkout']); $GLOBALS['SaveAndAddAnother'] = GetLang('SaveAndAddAnother'); $this->setupProductLanguageString(); $this->template->display('product.form.tpl'); } 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); } } }
public function set_install_date() { if (GetConfig('InstallDate') > 0) { return true; } // determine the install date based off the first order $query = "SELECT orddate FROM [|PREFIX|]orders ORDER BY orderid LIMIT 1"; $res = $GLOBALS['ISC_CLASS_DB']->Query($query); if ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($res)) { $installDate = $row['orddate']; } else { // no orders? set it to the current time $installDate = isc_gmmktime(isc_date("H"), isc_date("i"), isc_date("s"), isc_date("m"), isc_date("d"), isc_date("Y")); } $GLOBALS['ISC_NEW_CFG']['InstallDate'] = $installDate; GetClass('ISC_ADMIN_SETTINGS')->CommitSettings(); return true; }
/** * Builds a where statement for order listing based on values in an array * * @param mixed $array * @return mixed */ public function BuildWhereFromVars($array) { $queryWhere = ""; $countQuery = ""; if (isset($array['fromDate'])) { $array['fromDate'] = urldecode(urldecode(urldecode($array['fromDate']))); } if (isset($array['fromDate'])) { $array['toDate'] = urldecode(urldecode(urldecode($array['toDate']))); } if (isset($array['orderId']) && $array['orderId'] != '') { $queryWhere .= " AND o.orderid='" . (int) $array['orderId'] . "'"; return array("query" => $queryWhere, "count" => $countQuery); } if (isset($array['customerId']) && $array['customerId'] != '') { $queryWhere .= " AND ordcustid='" . (int) $array['customerId'] . "'"; return array("query" => $queryWhere, "count" => $countQuery); } if (isset($array['searchQuery']) && $array['searchQuery'] != "") { $search_query = $GLOBALS['ISC_CLASS_DB']->QuoteEx($array['searchQuery']); //zcs=Fix BUG,escape additional characters $queryWhere .= " AND (\n\t\t\t\t\to.orderid='" . (int) $search_query . "'\n\t\t\t\t\tOR ordtrackingno='" . $search_query . "'\n\t\t\t\t\tOR ordpayproviderid='" . $search_query . "'\n\t\t\t\t\tOR CONCAT(custconfirstname, ' ', custconlastname) LIKE '%" . $search_query . "%'\n\t\t\t\t\tOR CONCAT(ordbillfirstname, ' ', ordbilllastname) LIKE '%" . $search_query . "%'\n\t\t\t\t\tOR CONCAT(ordshipfirstname, ' ', ordshiplastname) LIKE '%" . $search_query . "%'\n\t\t\t\t\tOR custconemail LIKE '%" . $search_query . "%'\n\t\t\t\t\tOR ordbillstreet1 LIKE '%" . $search_query . "%'\n\t\t\t\t\tOR ordbillstreet2 LIKE '%" . $search_query . "%'\n\t\t\t\t\tOR ordbillsuburb LIKE '%" . $search_query . "%'\n\t\t\t\t\tOR ordbillstate LIKE '%" . $search_query . "%'\n\t\t\t\t\tOR ordbillzip LIKE '%" . $search_query . "%'\n\t\t\t\t\tOR ordbillcountry LIKE '%" . $search_query . "%'\n\t\t\t\t\tOR ordshipstreet1 LIKE '%" . $search_query . "%'\n\t\t\t\t\tOR ordshipstreet2 LIKE '%" . $search_query . "%'\n\t\t\t\t\tOR ordshipsuburb LIKE '%" . $search_query . "%'\n\t\t\t\t\tOR ordshipstate LIKE '%" . $search_query . "%'\n\t\t\t\t\tOR ordshipzip LIKE '%" . $search_query . "%'\n\t\t\t\t\tOR ordshipcountry LIKE '%" . $search_query . "%'\n\t\t\t\t) "; $countQuery .= " LEFT JOIN [|PREFIX|]customers c ON (o.ordcustid=c.customerid)"; } //alandy_2012-3-28 add. if (isset($array['orderOwner']) && $array['orderOwner'] != '') { $queryWhere .= sprintf(" AND orderOwner='%d'", $array['orderOwner']); } if (isset($array['orderStatus']) && $array['orderStatus'] != "") { $order_status = $GLOBALS['ISC_CLASS_DB']->Quote((int) $array['orderStatus']); $queryWhere .= sprintf(" AND ordstatus='%d'", $order_status); } else { $queryWhere .= " AND ordstatus > 0"; } if (isset($array['paymentMethod']) && $array['paymentMethod'] != "") { $payment_method = $GLOBALS['ISC_CLASS_DB']->Quote($array['paymentMethod']); $queryWhere .= sprintf(" AND orderpaymentmodule='%s'", $payment_method); } if (isset($_REQUEST['shippingMethod']) && $_REQUEST['shippingMethod'] != "") { $shipping_method = $GLOBALS['ISC_CLASS_DB']->Quote($_REQUEST['shippingMethod']); $queryWhere .= sprintf(" AND ordershipmodule='%s'", $shipping_method); } if (isset($array['orderFrom']) && isset($array['orderTo']) && $array['orderFrom'] != "" && $array['orderTo'] != "") { $order_from = (int) $array['orderFrom']; $order_to = (int) $array['orderTo']; $queryWhere .= sprintf(" AND (o.orderid >= '%d' and o.orderid <= '%d')", $GLOBALS['ISC_CLASS_DB']->Quote($order_from), $GLOBALS['ISC_CLASS_DB']->Quote($order_to)); } else { if (isset($array['orderFrom']) && $array['orderFrom'] != "") { $order_from = (int) $array['orderFrom']; $queryWhere .= sprintf(" AND o.orderid >= '%d'", $order_from); } else { if (isset($array['orderTo']) && $array['orderTo'] != "") { $order_to = (int) $array['orderTo']; $queryWhere .= sprintf(" AND o.orderid <= '%d'", $order_to); } } } if (isset($array['totalFrom']) && $array['totalFrom'] != "" && isset($array['totalTo']) && $array['totalTo'] != "") { $from_total = $array['totalFrom']; $to_total = $array['totalTo']; $queryWhere .= sprintf(" AND ordtotalamount >= '%s' and ordtotalamount <= '%s'", $GLOBALS['ISC_CLASS_DB']->Quote($from_total), $GLOBALS['ISC_CLASS_DB']->Quote($to_total)); } else { if (isset($array['totalFrom']) && $array['totalFrom'] != "") { $from_total = $array['totalFrom']; $queryWhere .= sprintf(" AND ordtotalamount >= '%s'", $GLOBALS['ISC_CLASS_DB']->Quote($from_total)); } else { if (isset($array['totalTo']) && $array['totalTo'] != "") { $to_total = $array['totalTo']; $queryWhere .= sprintf(" AND ordtotalamount <= '%s'", $GLOBALS['ISC_CLASS_DB']->Quote($to_total)); } } } // Limit results to a particular date range if (isset($array['dateRange']) && $array['dateRange'] != "") { $range = $array['dateRange']; switch ($range) { // Orders within the last day case "today": $from_stamp = isc_gmmktime(0, 0, 0, isc_date("m"), isc_date("d"), isc_date("Y")); break; // Orders received in the last 2 days // Orders received in the last 2 days case "yesterday": $from_stamp = isc_gmmktime(0, 0, 0, isc_date("m"), isc_date("d") - 1, isc_date("Y")); $to_stamp = isc_gmmktime(0, 0, 0, isc_date("m"), isc_date("d"), isc_date("Y")); break; // Orders received in the last 24 hours // Orders received in the last 24 hours case "day": $from_stamp = time() - 60 * 60 * 24; break; // Orders received in the last 7 days // Orders received in the last 7 days case "week": $from_stamp = time() - 60 * 60 * 24 * 7; break; // Orders received in the last 30 days // Orders received in the last 30 days case "month": $from_stamp = time() - 60 * 60 * 24 * 30; break; // Orders received this month // Orders received this month case "this_month": $from_stamp = isc_gmmktime(0, 0, 0, isc_date("m"), 1, isc_date("Y")); break; // Orders received this year // Orders received this year case "this_year": $from_stamp = isc_gmmktime(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 = isc_gmmktime(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 = isc_gmmktime(0, 0, 0, $to_data[0], $to_data[1], $to_data[2]); } } if (!isset($array['SearchByDate']) || $array['SearchByDate'] == 0) { if (isset($from_stamp)) { $queryWhere .= " AND orddate >= '" . (int) $from_stamp . "'"; } if (isset($to_stamp)) { $queryWhere .= "AND orddate <='" . (int) $to_stamp . "'"; } } else { if ($array['SearchByDate'] == 1) { if (isset($from_stamp)) { $queryWhere .= " AND (\n\t\t\t\t\t\t\tSELECT opf.orderprodid\n\t\t\t\t\t\t\tFROM [|PREFIX|]order_products opf\n\t\t\t\t\t\t\tWHERE o.orderid=opf.orderorderid AND opf.ordprodeventdate >='" . (int) $from_stamp . "'\n\t\t\t\t\t\t)"; } if (isset($to_stamp)) { $queryWhere .= " AND (\n\t\t\t\t\t\t\tSELECT opt.orderprodid\n\t\t\t\t\t\t\tFROM [|PREFIX|]order_products opt\n\t\t\t\t\t\t\tWHERE o.orderid=opt.orderorderid AND opt.ordprodeventdate <='" . (int) $to_stamp . "'\n\t\t\t\t\t\t)"; } } else { if ($array['SearchByDate'] == 2) { if (isset($from_stamp)) { $queryWhere .= " AND (orddate >= '" . (int) $from_stamp . "' OR (\n\t\t\t\t\t\t\tSELECT opf.orderprodid\n\t\t\t\t\t\t\tFROM [|PREFIX|]order_products opf\n\t\t\t\t\t\t\tWHERE o.orderid=opf.orderorderid AND opf.ordprodeventdate >='" . (int) $from_stamp . "'\n\t\t\t\t\t\t))"; } if (isset($to_stamp)) { $queryWhere .= " AND (orddate <= '" . (int) $to_stamp . "' OR (\n\t\t\t\t\t\t\tSELECT opt.orderprodid\n\t\t\t\t\t\t\tFROM [|PREFIX|]order_products opt\n\t\t\t\t\t\t\tWHERE o.orderid=opt.orderorderid AND opt.ordprodeventdate <='" . (int) $to_stamp . "'\n\t\t\t\t\t\t))"; } if (isset($to_stamp)) { $queryWhere .= "AND orddate <='" . (int) $from_stamp . "'"; } } } } } // Orders which contain a particular product? if (isset($array['productId'])) { $queryWhere .= " AND (\n\t\t\t\t\tSELECT sp.orderprodid\n\t\t\t\t\tFROM [|PREFIX|]order_products sp\n\t\t\t\t\tWHERE sp.ordprodid='" . (int) $array['productId'] . "' AND sp.orderorderid=o.orderid\n\t\t\t\t\tLIMIT 1\n\t\t\t\t)"; } // Orders by product name if (isset($array['productName'])) { $queryWhere .= " AND (\n\t\t\t\t\tSELECT sp.orderprodid\n\t\t\t\t\tFROM [|PREFIX|]order_products sp\n\t\t\t\t\tWHERE sp.ordprodname LIKE '%" . $GLOBALS['ISC_CLASS_DB']->Quote($array['productName']) . "%' AND sp.orderorderid=o.orderid\n\t\t\t\t\tLIMIT 1\n\t\t\t\t)"; } return array("query" => $queryWhere, "count" => $countQuery); }
/** * Builds a where statement for order listing based on values in an array * * @param mixed $array * @return mixed */ public function BuildWhereFromVars($array) { $queryWhere = ""; $countQuery = ""; // 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['orderId']) && $array['orderId'] != '') { // this should search deleted orders $queryWhere .= " AND orderid='".(int)$array['orderId']."'"; return array("query" => $queryWhere, "count" => $countQuery); } if(isset($array['customerId']) && $array['customerId'] != '') { // hide deleted orders when viewing orders for a customer $queryWhere .= " AND ordcustid='".(int)$array['customerId']."' AND deleted = 0 "; return array("query" => $queryWhere, "count" => $countQuery); } // defaults for un/deleted searching $searchUndeletedOrders = true; $searchDeletedOrders = false; if (isset($array['searchDeletedOrders'])) { switch (strtolower($array['searchDeletedOrders'])) { case 'both': $searchDeletedOrders = true; break; case 'only': $searchUndeletedOrders = false; $searchDeletedOrders = true; break; } } if(isset($array['orderStatus']) && $array['orderStatus'] != "") { $order_status = $GLOBALS['ISC_CLASS_DB']->Quote((int)$array['orderStatus']); $queryWhere .= sprintf(" AND ordstatus='%d'", $order_status); } // Otherwise, only fetch complete orders else { $queryWhere .= " AND ordstatus > 0"; } if(isset($array['searchQuery']) && $array['searchQuery'] != "") { $search_query = $GLOBALS['ISC_CLASS_DB']->Quote($array['searchQuery']); // only limit results to un/deleted if the search query is not numeric - otherwise it should search for order ids regardless if (!is_numeric($search_query)) { if (!$searchDeletedOrders) { $queryWhere .= " AND deleted = 0"; } else if (!$searchUndeletedOrders) { $queryWhere .= " AND deleted = 1"; } } $queryWhere .= " AND ( orderid='".(int)$search_query."' OR ordpayproviderid='".$search_query."' OR CONCAT(custconfirstname, ' ', custconlastname) LIKE '%".$search_query."%' OR CONCAT(ordbillfirstname, ' ', ordbilllastname) LIKE '%".$search_query."%' OR custconemail LIKE '%".$search_query."%' OR ordbillstreet1 LIKE '%".$search_query."%' OR ordbillstreet2 LIKE '%".$search_query."%' OR ordbillsuburb LIKE '%".$search_query."%' OR ordbillstate LIKE '%".$search_query."%' OR ordbillzip LIKE '%".$search_query."%' OR ordbillcountry LIKE '%".$search_query."%' ) "; $countQuery .= " LEFT JOIN [|PREFIX|]customers c ON (o.ordcustid=c.customerid)"; } else { // no search query specified, show/hide deleted orders by default as specified by orderDeleted parameter above if (!$searchDeletedOrders) { $queryWhere .= " AND deleted = 0"; } else if (!$searchUndeletedOrders) { $queryWhere .= " AND deleted = 1"; } } if(isset($array['paymentMethod']) && $array['paymentMethod'] != "") { $payment_method = $GLOBALS['ISC_CLASS_DB']->Quote($array['paymentMethod']); $queryWhere .= sprintf(" AND orderpaymentmodule='%s'", $payment_method); } if(isset($_REQUEST['shippingMethod']) && $_REQUEST['shippingMethod'] != "") { $shipping_method = $GLOBALS['ISC_CLASS_DB']->Quote($_REQUEST['shippingMethod']); $queryWhere .= sprintf(" AND ( SELECT order_id FROM [|PREFIX|]order_shipping WHERE module='%s' LIMIT 1 )", $shipping_method); } if(isset($array['ebayOrderId'])) { if ($array['ebayOrderId'] == -1) { $queryWhere .= " AND o.ebay_order_id != 0"; } else { $queryWhere .= " AND o.ebay_order_id = " . (int)$array['ebayOrderId']; } } if(isset($array['ebayItemId'])) { $ebayItemId = $GLOBALS['ISC_CLASS_DB']->Quote($array['ebayItemId']); $queryWhere .= " AND ( SELECT opf.orderprodid FROM [|PREFIX|]order_products opf WHERE o.orderid=opf.orderorderid AND opf.ebay_item_id ='".$ebayItemId."' )"; } if(isset($array['orderFrom']) && isset($array['orderTo']) && $array['orderFrom'] != "" && $array['orderTo'] != "") { $order_from = (int)$array['orderFrom']; $order_to = (int)$array['orderTo']; $queryWhere .= sprintf(" AND (orderid >= '%d' and orderid <= '%d')", $GLOBALS['ISC_CLASS_DB']->Quote($order_from), $GLOBALS['ISC_CLASS_DB']->Quote($order_to)); } else if(isset($array['orderFrom']) && $array['orderFrom'] != "") { $order_from = (int)$array['orderFrom']; $queryWhere .= sprintf(" AND orderid >= '%d'", $order_from); } else if(isset($array['orderTo']) && $array['orderTo'] != "") { $order_to = (int)$array['orderTo']; $queryWhere .= sprintf(" AND orderid <= '%d'", $order_to); } if(isset($array['totalFrom']) && $array['totalFrom'] != "" && isset($array['totalTo']) && $array['totalTo'] != "") { $from_total = $array['totalFrom']; $to_total = $array['totalTo']; $queryWhere .= sprintf(" AND total_inc_tax >= '%s' and total_inc_tax <= '%s'", $GLOBALS['ISC_CLASS_DB']->Quote($from_total), $GLOBALS['ISC_CLASS_DB']->Quote($to_total)); } else if(isset($array['totalFrom']) && $array['totalFrom'] != "") { $from_total = $array['totalFrom']; $queryWhere .= sprintf(" AND total_inc_tax >= '%s'", $GLOBALS['ISC_CLASS_DB']->Quote($from_total)); } else if(isset($array['totalTo']) && $array['totalTo'] != "") { $to_total = $array['totalTo']; $queryWhere .= sprintf(" AND total_inc_tax <= '%s'", $GLOBALS['ISC_CLASS_DB']->Quote($to_total)); } // Limit results to a particular date range if(isset($array['dateRange']) && $array['dateRange'] != "") { $range = $array['dateRange']; switch($range) { // Orders within the last day case "today": $from_stamp = isc_gmmktime(0, 0, 0, isc_date("m"), isc_date("d"), isc_date("Y")); break; // Orders received in the last 2 days case "yesterday": $from_stamp = isc_gmmktime(0, 0, 0, isc_date("m"), isc_date("d")-1, isc_date("Y")); $to_stamp = isc_gmmktime(0, 0, 0, isc_date("m"), isc_date("d"), isc_date("Y")); break; // Orders received in the last 24 hours case "day": $from_stamp = time()-60*60*24; break; // Orders received in the last 7 days case "week": $from_stamp = time()-60*60*24*7; break; // Orders received in the last 30 days case "month": $from_stamp = time()-60*60*24*30; break; // Orders received this month case "this_month": $from_stamp = isc_gmmktime(0, 0, 0, isc_date("m"), 1, isc_date("Y")); break; // Orders received this year case "this_year": $from_stamp = isc_gmmktime(0, 0, 0, 1, 1, isc_date("Y")); break; // Custom date default: if(isset($array['fromDate']) && $array['fromDate'] != "") { $from_date = urldecode($array['fromDate']); $from_data = explode("/", $from_date); $from_stamp = isc_gmmktime(0, 0, 0, $from_data[0], $from_data[1], $from_data[2]); } if(isset($array['toDate']) && $array['toDate'] != "") { $to_date = urldecode($array['toDate']); $to_data = explode("/", $to_date); $to_stamp = isc_gmmktime(23, 59, 59, $to_data[0], $to_data[1], $to_data[2]); } } if (!isset($array['SearchByDate']) || $array['SearchByDate'] == 0) { if(isset($from_stamp)) { $queryWhere .= " AND orddate >= '".(int)$from_stamp."'"; } if(isset($to_stamp)) { $queryWhere .= " AND orddate <='".(int)$to_stamp."'"; } } else if ($array['SearchByDate'] == 1) { if(isset($from_stamp)) { $queryWhere .= " AND ( SELECT opf.orderprodid FROM [|PREFIX|]order_products opf WHERE o.orderid=opf.orderorderid AND opf.ordprodeventdate >='".(int)$from_stamp."' )"; } if(isset($to_stamp)) { $queryWhere .= " AND ( SELECT opt.orderprodid FROM [|PREFIX|]order_products opt WHERE o.orderid=opt.orderorderid AND opt.ordprodeventdate <='".(int)$to_stamp."' )"; } } else if ($array['SearchByDate'] == 2) { if(isset($from_stamp)) { $queryWhere .= " AND (orddate >= '".(int)$from_stamp."' OR ( SELECT opf.orderprodid FROM [|PREFIX|]order_products opf WHERE o.orderid=opf.orderorderid AND opf.ordprodeventdate >='".(int)$from_stamp."' ))"; } if(isset($to_stamp)) { $queryWhere .= " AND (orddate <= '".(int)$to_stamp."' OR ( SELECT opt.orderprodid FROM [|PREFIX|]order_products opt WHERE o.orderid=opt.orderorderid AND opt.ordprodeventdate <='".(int)$to_stamp."' ))"; } if(isset($to_stamp)) { $queryWhere .= " AND orddate <='".(int)$from_stamp."'"; } } } // Orders which contain a particular product? if(isset($array['productId'])) { $queryWhere .= " AND ( SELECT sp.orderprodid FROM [|PREFIX|]order_products sp WHERE sp.ordprodid='".(int)$array['productId']."' AND sp.orderorderid=o.orderid LIMIT 1 )"; } // Orders by product name if(isset($array['productName'])) { $queryWhere .= " AND ( SELECT sp.orderprodid FROM [|PREFIX|]order_products sp WHERE sp.ordprodname LIKE '%".$GLOBALS['ISC_CLASS_DB']->Quote($array['productName'])."%' AND sp.orderorderid=o.orderid LIMIT 1 )"; } // orders that do or do not contain pre-order products if (isset($_REQUEST['preorders']) && !(in_array('0', $_REQUEST['preorders']) && in_array('1', $_REQUEST['preorders']))) { // preorders is set but not set to show both - filter accordingly (if it is not set or it is set to show both no filtering is necessary) $queryWhere .= " AND ( SELECT COUNT(*) FROM [|PREFIX|]order_products sop, [|PREFIX|]products sp WHERE sop.orderorderid = o.orderid AND sp.productid = sop.ordprodid AND sp.prodpreorder = 1 ) "; if (in_array('1', $_REQUEST['preorders'])) { $queryWhere .= " > 0"; } else { $queryWhere .= " = 0"; } } return array("query" => $queryWhere, "count" => $countQuery); }
private function AddToCart() { if (!isset($_REQUEST['product_id'])) { ob_end_clean(); header(sprintf("Location: %s/makeaoffer.php", GetConfig('ShopPath'))); die; } // First get the list of existing products in the cart $product_id = (int) $_REQUEST['product_id']; $GLOBALS['ProductJustAdded'] = $product_id; $query = "\n\t\t\t\tSELECT p.*, " . GetProdCustomerGroupPriceSQL() . "\n\t\t\t\tFROM [|PREFIX|]products p\n\t\t\t\tWHERE p.productid='" . (int) $product_id . "'\n\t\t\t"; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $product = $GLOBALS['ISC_CLASS_DB']->Fetch($result); $GLOBALS['Product'] =& $product; // Check that the customer has permisison to view this product $canView = false; $productCategories = explode(',', $product['prodcatids']); foreach ($productCategories as $categoryId) { // Do we have permission to access this category? if (CustomerGroupHasAccessToCategory($categoryId)) { $canView = true; } } if ($canView == false) { $noPermissionsPage = GetClass('ISC_403'); $noPermissionsPage->HandlePage(); exit; } $variation = 0; if (isset($_REQUEST['variation_id']) && $_REQUEST['variation_id'] != 0) { $variation = (int) $_REQUEST['variation_id']; } else { if (isset($_REQUEST['variation']) && is_array($_REQUEST['variation']) && $_REQUEST['variation'][1] != 0) { $variation = $_REQUEST['variation']; } } $qty = 1; if (isset($_REQUEST['qty'])) { if (is_array($_REQUEST['qty'])) { $qty = (int) array_pop($_REQUEST['qty']); } else { if ($_REQUEST['qty'] > 0) { $qty = (int) $_REQUEST['qty']; } } } $configurableFields = null; if (isset($_REQUEST['ProductFields']) || isset($_FILES['ProductFields'])) { $configurableFields = $this->BuildProductConfigurableFieldData(); } $options = array(); if (isset($_REQUEST['EventDate']['Day'])) { $result = true; $eventDate = isc_gmmktime(0, 0, 0, $_REQUEST['EventDate']['Mth'], $_REQUEST['EventDate']['Day'], $_REQUEST['EventDate']['Yr']); $eventName = $product['prodeventdatefieldname']; if ($product['prodeventdatelimitedtype'] == 1) { if ($eventDate < $product['prodeventdatelimitedstartdate'] || $eventDate > $product['prodeventdatelimitedenddate']) { $result = false; } } else { if ($product['prodeventdatelimitedtype'] == 2) { if ($eventDate < $product['prodeventdatelimitedstartdate']) { $result = false; } } else { if ($product['prodeventdatelimitedtype'] == 3) { if ($eventDate > $product['prodeventdatelimitedenddate']) { $result = false; } } } } if ($result == false) { $this->ShowRegularCart(); return; } $options['EventDate'] = $eventDate; $options['EventName'] = $eventName; } // Actually add the product to the cart $cartItemId = $this->api->AddItem($product_id, $qty, $variation, $configurableFields, null, $options); $this->newCartItem = $cartItemId; if ($cartItemId === false) { $this->cartErrorMessage = implode('<br />', $this->api->GetErrors()); if (!$this->cartErrorMessage) { $this->cartErrorMessage = GetLang('ProductUnavailableForPruchase'); } if ($this->api->productLevelError == true) { $query = "\n\t\t\t\t\t\tSELECT prodname\n\t\t\t\t\t\tFROM [|PREFIX|]products\n\t\t\t\t\t\tWHERE productid='" . (int) $product_id . "'\n\t\t\t\t\t"; $productName = $GLOBALS['ISC_CLASS_DB']->FetchOne($query); $_SESSION['ProductErrorMessage'] = $this->cartErrorMessage; ob_end_clean(); header("Location: " . ProdLink($productName)); exit; } $this->ShowRegularCart(); return; } $this->api->ReapplyCouponsFromCart(); //Added by Simha temp fix to avoid having multiple times coupon for same item $GLOBALS['ISC_CLASS_MAKEAOFFER']->api->UpdateCartInformation(); $_SESSION['JustAddedProduct'] = $product_id; // Are we redirecting to a specific location? if (isset($_REQUEST['returnUrl'])) { $redirectLocation = urldecode($_REQUEST['returnUrl']); $urlPieces = @parse_url($redirectLocation); $storeUrlPieces = @parse_url(GetConfig('ShopPath')); if (is_array($urlPieces) && isset($urlPieces['host'])) { $urlHost = str_replace('www.', '', isc_strtolower($urlPieces['host'])); $storeHost = str_replace('www.', '', isc_strtolower($storeUrlPieces['host'])); if ($urlHost == $storeHost) { if (strpos($redirectLocation, '?') === false) { $redirectLocation .= '?'; } else { $redirectLocation .= '&'; } $redirectLocation .= 'justAddedProduct=' . $product_id; ob_end_clean(); header("Location: " . $redirectLocation); exit; } } } // Redirect the user to the regular cart page ob_end_clean(); header(sprintf("Location: %s/makeaoffer.php", $GLOBALS['ShopPath'])); die; }
/** * Generate select options for selecting a delivery date month. * * @return string HTML string containing option tags for available months. */ private function GetMonthOptions() { $output = '<option value=\'-1\'>---</option>'; for($i = 1; $i <= 12; $i++) { $stamp = isc_gmmktime(0, 0, 0, $i, 1, 2000); $month = isc_date("M", $stamp); $output .= sprintf("<option value='%d'>%s</option>", $i, $month); } return $output; }
function ConvertDateToTime($Stamp) { $vals = explode("/", $Stamp); return isc_gmmktime(0, 0, 0, $vals[0], $vals[1], $vals[2]); }
/** * Imports an tracking numbers in to the database. * * @param array Array of record data */ protected function _ImportRecord($record) { if(trim($record['ordernumber']) == "") { $this->ImportSession['Results']['Failures'][] = implode(",", $record['original_record'])." ".GetLang('ImportMissingOrderNumber'); return; } $record['ordertrackingnumber'] = trim($record['ordertrackingnumber']); if($record['ordertrackingnumber'] == "") { $this->ImportSession['Results']['Failures'][] = implode(",", $record['original_record'])." ".GetLang('ImportMissingTrackingNumber'); return; } if(isc_strlen($record['ordertrackingnumber']) > 50) { $this->ImportSession['Results']['Failures'][] = implode(",", $record['original_record'])." ".GetLang('ImportTrackingNumberTooLong'); return; } // Does the order number exist in the database? $query = "SELECT orderid FROM [|PREFIX|]orders WHERE orderid='".(int)$record['ordernumber']."' AND ordisdigital = 0 AND deleted = 0"; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $order = $GLOBALS['ISC_CLASS_DB']->Fetch($result); if(!$order['orderid']) { $this->ImportSession['Results']['Failures'][] = implode(",", $record['original_record'])." ".GetLang('ImportInvalidOrderNumber'); return; } // Order exists and has physical items // Tracking numbers are now on shipments, not orders, so are there any un-shipped items in this order? $unshippedProducts = array(); $query = " SELECT op.orderprodid, op.order_address_id, op.ordprodqty, op.ordprodqtyshipped, os.method, os.module FROM [|PREFIX|]order_products op, [|PREFIX|]order_shipping os WHERE op.orderorderid = " . $order['orderid'] . " AND op.ordprodtype = 'physical' AND op.ordprodqty > op.ordprodqtyshipped AND os.order_address_id = op.order_address_id ORDER BY op.order_address_id, op.orderprodid "; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); while ($product = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $unshippedProducts[] = $product; } if (empty($unshippedProducts) && (!isset($this->ImportSession['OverrideDuplicates']) || $this->ImportSession['OverrideDuplicates'] != 1)) { // cannot apply tracking number to order with all items shipped unless override duplicates is set $this->ImportSession['Results']['Duplicates'][] = $record['ordernumber']." ".$record['ordertrackingnumber']; return; } // the import format only allows for one tracking number per order so this tracking number gets applied to all shipments $existingSuccess = true; if (isset($this->ImportSession['OverrideDuplicates']) && $this->ImportSession['OverrideDuplicates'] == 1) { $query = " UPDATE [|PREFIX|]shipments SET shiptrackno = '" . $GLOBALS['ISC_CLASS_DB']->Quote($record['ordertrackingnumber']) . "' WHERE shiporderid = " . $order['orderid'] . " "; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); if (!$result) { $existingSuccess = false; $this->ImportSession['Results']['Failures'][] = implode(",", $record['original_record'])." ".GetLang('ImportUpdateShipmentsFailed'); } } /** @var ISC_ADMIN_SHIPMENTS */ $shipments = GetClass('ISC_ADMIN_SHIPMENTS'); // create shipments for unshipped products $totalShipments = 0; $totalSuccess = 0; $totalFail = 0; $quantity = array(); reset($unshippedProducts); while ($product = current($unshippedProducts)) { next($unshippedProducts); $nextProduct = current($unshippedProducts); // add product=>qty to shipment $quantity[$product['orderprodid']] = $product['ordprodqty'] - $product['ordprodqtyshipped']; if ($nextProduct && $nextProduct['order_address_id'] == $product['order_address_id']) { // next product is for the same address, skip shipment creation for now continue; } // next product is a different shipment so commit this one before proceeding $shipment = array( 'orderId' => $order['orderid'], 'shiptrackno' => $record['ordertrackingnumber'], 'addressId' => $product['order_address_id'], 'shipping_module' => $product['module'], 'shipmethod' => $product['method'], 'shipcomments' => '', 'quantity' => $quantity, ); if (isset($this->ImportSession['updateOrderStatus']) && $this->ImportSession['updateOrderStatus']!=0) { $shipment['ordstatus'] = (int)$this->ImportSession['updateOrderStatus']; } $totalShipments++; if ($shipments->CommitShipment($shipment)) { // commit success $this->ImportSession['Results']['Updates'][] = $record['ordernumber']." ".$record['ordertrackingnumber']; $totalSuccess++; } else { // fail $this->ImportSession['Results']['Failures'][] = implode(",", $record['original_record'])." ".GetLang('ImportCreateShipmentFailed'); $totalFail++; } // reset $quantity = array(); } if ($existingSuccess && $totalSuccess == $totalShipments) { // all success or no new shipments were needed $orderData = array( "orddateshipped" => isc_gmmktime(), ); $GLOBALS['ISC_CLASS_DB']->UpdateQuery("orders", $orderData, "orderid='".$order['orderid']."'"); ++$this->ImportSession['Results']['SuccessCount']; } else { // total or partial failure $this->ImportSession['Results']['Failures'][] = implode(",", $record['original_record'])." ".GetLang('ImportInvalidOrderNumber'); return; } }
/** * Add a product to the order that's being created/edited. */ private function OrderAddProduct() { if (!isset($_REQUEST['cartItemId']) && !isset($_REQUEST['productId']) || !isset($_REQUEST['orderSession'])) { exit; } $cartOptions = array('updateQtyIfExists' => false); if (isset($_REQUEST['EventDate'])) { $cartOptions['EventDate'] = isc_gmmktime(0, 0, 0, $_REQUEST['EventDate']['Mth'], $_REQUEST['EventDate']['Day'], $_REQUEST['EventDate']['Yr']); } if (isset($_REQUEST['ordcustid']) && $_REQUEST['ordcustid'] != 0) { $customerClass = GetClass('ISC_CUSTOMER'); $customer = $customerClass->GetCustomerInfo($_REQUEST['ordcustid']); if (isset($customer['custgroupid'])) { $cartOptions['customerGroup'] = $customer['custgroupid']; } } else { if (isset($_REQUEST['custgroupid']) && $_REQUEST['custgroupid'] != 0) { $cartOptions['customerGroup'] = (int) $_REQUEST['custgroupid']; } } if (isset($_REQUEST['variationId'])) { $variationId = $_REQUEST['variationId']; } else { $variationId = 0; } if (isset($_REQUEST['customerGroup'])) { $orderDetails['customerGroup'] = (int) $_REQUEST['customerGroup']; } /* -- Added below condition to check if YMM values coming from dropdown, then need to decode - starts */ if (isset($_REQUEST['ymmID']) && $_REQUEST['ymmID'] == 0) { if (isset($_REQUEST['ymmmake'])) { $_REQUEST['ymmmake'] = MakeURLNormal($_REQUEST['ymmmake']); } if (isset($_REQUEST['ymmmodel'])) { $_REQUEST['ymmmodel'] = MakeURLNormal($_REQUEST['ymmmodel']); } } /* -- ends -- */ $productFields = $this->BuildProductConfigurableFieldData(); $orderClass = GetClass('ISC_ADMIN_ORDERS'); $rowId = $orderClass->GetCartApi($_REQUEST['orderSession'])->AddItem($_REQUEST['productId'], $_REQUEST['quantity'], $variationId, $productFields, $_REQUEST['cartItemId'], $cartOptions); if ($rowId === false) { $errors = implode("\n", $orderClass->GetCartApi()->GetErrors()); if (!$errors) { $errors = GetLang('ErrorAddingProductToOrder'); } $response = array('error' => $errors); } else { $product = $orderClass->GetCartApi()->GetProductInCart($rowId); $catquery = " SELECT DISTINCT c.categoryid, p.brandseriesid\n FROM isc_categories c \n LEFT JOIN isc_categoryassociations ca ON c.categoryid = ca.categoryid \n LEFT JOIN isc_products p ON ca.productid = p.productid AND p.prodvisible='1'\n WHERE p.productid= " . $product['product_id'] . ""; $relcats = array(); $brandseries = 0; $catresult = $GLOBALS['ISC_CLASS_DB']->Query($catquery); while ($catrow = $GLOBALS['ISC_CLASS_DB']->Fetch($catresult)) { $relcats[] = $catrow['categoryid']; $brandseries = $catrow['brandseriesid']; } if ($product['data']['prodsaleprice'] > 0 && $product['data']['prodsaleprice'] < $product['product_price']) { $product['product_price'] = $product['data']['prodsaleprice']; } else { $product['discount_price'] = CalculateDiscountPrice($product['product_price'], $product['product_price'], $relcats[0], $brandseries); $orderClass->GetCartApi()->SetItemValue($rowId, 'discount_price', $product['discount_price']); // $product['product_price'] = CalculateDiscountPrice($product['product_price'], $product['product_price'], $relcats[0], $brandseries); } $product['vendorprefix'] = $orderClass->GetProductVendorprefix($product['product_id']); $orderClass->GetCartApi()->SetItemValue($rowId, 'product_price', $product['product_price']); $response = array('productRow' => $orderClass->GenerateOrderItemRow($rowId, $product), 'orderSummary' => $orderClass->GenerateOrderSummaryTable(), 'productRowId' => $rowId); if ($_REQUEST['cartItemId'] != $rowId) { $response['removeRow'] = (string) $_REQUEST['cartItemId']; } } if (isset($_REQUEST['ajaxFormUpload'])) { echo '<textarea>' . isc_json_encode($response) . '</textarea>'; exit; } echo isc_json_encode($response); exit; }
public function BuildWhereFromFields($search_fields) { if (empty($search_fields['From'])) { $from_stamp = GetConfig('InstallDate'); } else { $from_stamp = (int)$search_fields['From']; } if (empty($search_fields['To'])) { $to_stamp = isc_gmmktime(isc_date("H"), isc_date("i"), isc_date("s"), isc_date("m"), isc_date("d"), isc_date("Y")); } else { $to_stamp = (int)$search_fields['To']; } // Calculate the number of seconds from GMT +0 that we are in. We'll be adjusting // the orddate in the query below so that it becomes timezone specific (remember, MySQL thinks we're +0) $timezoneAdjustment = GetConfig('StoreTimeZone'); if(GetConfig('StoreDSTCorrection')) { ++$timezoneAdjustment; } $timezoneAdjustment *= 3600; if (empty($search_fields['TaxListBy'])) { $groupBy = 'Day'; } else { $groupBy = $search_fields['TaxListBy']; } $fieldSQL = ''; switch ($groupBy) { case 'Day': $fieldSQL = "DATE_FORMAT(FROM_UNIXTIME(orddate+".$timezoneAdjustment."), '%Y-%m-%d')"; $this->addDay = 1; $this->taxDateFormat = GetConfig('ExportDateFormat'); break; case 'Month': $fieldSQL = "DATE_FORMAT(FROM_UNIXTIME(orddate+".$timezoneAdjustment."), '%Y-%m-1')"; $this->addMonth = 1; $this->taxDateFormat = 'F Y'; break; case 'Year': $fieldSQL = "DATE_FORMAT(FROM_UNIXTIME(orddate+".$timezoneAdjustment."), '%Y')"; $this->taxDateFormat = 'Y'; $this->addYear = 1; break; } $this->startStamp = $from_stamp; $this->lastStamp = $from_stamp; $this->endStamp = $to_stamp; $this->dateField = $fieldSQL; $where = " orddate >= '" . $from_stamp . "' AND orddate <= '" . $to_stamp . "' "; return $where; }
/** * Generate the KPI table for orders, visitors, conversion rate etc. * Will use the time period from the request if one exists (GET or COOKIE) * or falls back to the last week. * * @return string The generated HTML for the performance indicators table. */ public function GeneratePerformanceIndicatorsTable() { if (!$this->auth->HasPermission(AUTH_Statistics_Overview)) { return false; } // If we don't have a period coming in via the URL, use the default if (!isset($_GET['period'])) { // Is it set in a cookie? if (isset($_COOKIE['DashboardPerformanceIndicatorsPeriod'])) { $period = $_COOKIE['DashboardPerformanceIndicatorsPeriod']; } else { $period = 'week'; } } else { $period = $_GET['period']; } // Determine for which dates we need to fetch the statistics switch ($period) { case 'week': $lastPeriodFrom = isc_gmmktime(0, 0, 0, isc_date('m'), isc_date('d') - 13, isc_date('y')); $thisPeriodFrom = isc_gmmktime(0, 0, 0, isc_date('m'), isc_date('d') - 6, isc_date('y')); break; case 'month': $lastPeriodFrom = isc_gmmktime(0, 0, 0, isc_date('m') - 2, isc_date('d'), isc_date('y')); $thisPeriodFrom = isc_gmmktime(0, 0, 0, isc_date('m') - 1, isc_date('d'), isc_date('y')); break; case 'year': $lastPeriodFrom = isc_gmmktime(0, 0, 0, isc_date('m'), isc_date('d'), isc_date('y') - 2); $thisPeriodFrom = isc_gmmktime(0, 0, 0, isc_date('m'), isc_date('d'), isc_date('y') - 1); break; default: $period = 'day'; $lastPeriodFrom = isc_gmmktime(0, 0, 0, isc_date('m'), isc_date('d') - 1, isc_date('y')); $thisPeriodFrom = isc_gmmktime(0, 0, 0, isc_date('m'), isc_date('d'), isc_date('y')); } $this->template->Assign('LastPeriodHeader', GetLang('Last' . ucfirst($period))); $this->template->Assign('ThisPeriodHeader', GetLang('This' . ucfirst($period))); // Run up until 1 second before the current period. Subtracting 1 second allows us to generate displayable dates for the period. $lastPeriodTo = $thisPeriodFrom - 1; if ($period != 'day') { $this->template->Assign('LastPeriodDateRange', CDate($lastPeriodFrom) . ' - ' . CDate($lastPeriodTo)); $this->template->Assign('ThisPeriodDateRange', CDate($thisPeriodFrom) . ' - ' . CDate(time())); } else { $this->template->Assign('LastPeriodDateRange', CDate($lastPeriodFrom)); $this->template->Assign('ThisPeriodDateRange', CDate($thisPeriodFrom)); } // Calculate the number of orders and the total revenue $vendorAdd = ''; if ($this->auth->GetVendorId()) { $vendorAdd .= " AND ordvendorid='" . $this->auth->GetVendorId() . "'"; } $query = "\n\t\t\tSELECT SUM(ordtotalamount) AS totalrevenue, COUNT(orderid) AS numorders\n\t\t\tFROM [|PREFIX|]orders\n\t\t\tWHERE ordstatus IN (" . implode(',', GetPaidOrderStatusArray()) . ") AND orddate >= '" . $lastPeriodFrom . "' AND orddate <= '" . $lastPeriodTo . "' " . $vendorAdd . "\n\t\t"; $result = $this->db->Query($query); $lastPeriodOrderStats = $this->db->Fetch($result); $query = "\n\t\t\tSELECT SUM(ordtotalamount) AS totalrevenue, COUNT(orderid) AS numorders\n\t\t\tFROM [|PREFIX|]orders\n\t\t\tWHERE ordstatus IN (" . implode(',', GetPaidOrderStatusArray()) . ") AND orddate >= '" . $thisPeriodFrom . "' " . $vendorAdd . "\n\t\t"; $result = $this->db->Query($query); $thisPeriodOrderStats = $this->db->Fetch($result); // Calculate the number of visitors if (!$this->auth->GetVendorId()) { $query = "\n\t\t\t\tSELECT SUM(numuniques)\n\t\t\t\tFROM [|PREFIX|]unique_visitors\n\t\t\t\tWHERE datestamp >= '" . $lastPeriodFrom . "' AND datestamp <= '" . $lastPeriodTo . "'\n\t\t\t"; $lastPeriodVisitorStats = $this->db->FetchOne($query); $query = "\n\t\t\t\tSELECT SUM(numuniques)\n\t\t\t\tFROM [|PREFIX|]unique_visitors\n\t\t\t\tWHERE datestamp >= '" . $thisPeriodFrom . "'\n\t\t\t"; $thisPeriodVisitorStats = $this->db->FetchOne($query); // Calculate the percentage change in visitors between the last period and the current period $visitorChange = $thisPeriodVisitorStats - $lastPeriodVisitorStats; $prefix = ''; if ($visitorChange == 0) { $visitorChangePercent = 0; } else { if ($lastPeriodVisitorStats > 0) { $visitorChangePercent = round($visitorChange / $lastPeriodVisitorStats * 100, 2); } else { $visitorChangePercent = 100; } } if ($visitorChangePercent > 0) { $prefix = '+'; $this->template->Assign('NumVisitorsChangeClass', 'Positive'); } else { if ($visitorChangePercent < 0) { $this->template->Assign('NumVisitorsChangeClass', 'Negative'); } } $visitorChangePercent = $prefix . number_format($visitorChangePercent, 2) . '%'; $this->template->Assign('LastPeriodNumVisitors', number_format($lastPeriodVisitorStats)); $this->template->Assign('ThisPeriodNumVisitors', number_format($thisPeriodVisitorStats)); $this->template->Assign('NumVisitorsChange', $visitorChangePercent); $lastConversion = 0; if ($lastPeriodVisitorStats > 0) { $lastConversion = $lastPeriodOrderStats['numorders'] / $lastPeriodVisitorStats * 100; } $this->template->Assign('LastPeriodConversionRate', number_format(round($lastConversion, 2), 2)); $thisConversion = 0; if ($thisPeriodVisitorStats > 0) { $thisConversion = $thisPeriodOrderStats['numorders'] / $thisPeriodVisitorStats * 100; } $this->template->Assign('ThisPeriodConversionRate', number_format(round($thisConversion, 2), 2)); // Calculate the difference between the two conversion dates to get the change $conversionChangePercent = $thisConversion - $lastConversion; $prefix = ''; if ($conversionChangePercent > 0) { $prefix = '+'; $this->template->Assign('ConversionChangeClass', 'Positive'); } else { if ($conversionChangePercent < 0) { $this->template->Assign('ConversionChangeClass', 'Negative'); } } $conversionChangePercent = $prefix . number_format($conversionChangePercent, 2) . '%'; $this->template->Assign('ConversionChange', $conversionChangePercent); } else { $this->template->Assign('HideConversionRate', 'display: none'); $this->template->Assign('HideVisitorStats', 'display: none'); } // Calculate the percentage change in revenue between the last period and the current period $revenueChange = $thisPeriodOrderStats['totalrevenue'] - $lastPeriodOrderStats['totalrevenue']; $prefix = ''; if ($revenueChange == 0) { $revenueChangePercent = 0; } else { if ($lastPeriodOrderStats['totalrevenue'] > 0) { $revenueChangePercent = round($revenueChange / $lastPeriodOrderStats['totalrevenue'] * 100, 2); } else { $revenueChangePercent = 100; } } if ($revenueChangePercent > 0) { $prefix = '+'; $this->template->Assign('TotalRevenueChangeClass', 'Positive'); } else { if ($revenueChangePercent < 0) { $this->template->Assign('TotalRevenueChangeClass', 'Negative'); } } $revenueChangePercent = $prefix . number_format($revenueChangePercent, 2) . '%'; // Calculate the percentage change in the number of orders in the last period and the current period $numOrdersChange = $thisPeriodOrderStats['numorders'] - $lastPeriodOrderStats['numorders']; $prefix = ''; if ($numOrdersChange == 0) { $numOrdersChangePercent = 0; } else { if ($lastPeriodOrderStats['numorders'] > 0) { $numOrdersChangePercent = round($numOrdersChange / $lastPeriodOrderStats['numorders'] * 100, 2); } else { $numOrdersChangePercent = 100; } } if ($numOrdersChangePercent > 0) { $prefix = '+'; $this->template->Assign('NumOrdersChangeClass', 'Positive'); } else { if ($numOrdersChangePercent < 0) { $this->template->Assign('NumOrdersChangeClass', 'Negative'); } } $numOrdersChangePercent = $prefix . number_format($numOrdersChangePercent, 2) . '%'; $this->template->Assign('LastPeriodRevenue', FormatPrice($lastPeriodOrderStats['totalrevenue'])); $this->template->Assign('LastPeriodNumOrders', number_format($lastPeriodOrderStats['numorders'])); $this->template->Assign('ThisPeriodRevenue', FormatPrice($thisPeriodOrderStats['totalrevenue'])); $this->template->Assign('ThisPeriodNumOrders', number_format($thisPeriodOrderStats['numorders'])); $this->template->Assign('TotalRevenueChange', $revenueChangePercent); $this->template->Assign('NumOrdersChange', $numOrdersChangePercent); // If they've just changed periods, store it in a cookie if (isset($_GET['period'])) { isc_setcookie('DashboardPerformanceIndicatorsPeriod', $period); } return $this->template->GetSnippet('DashboardPerformanceIndicators'); }
/** * Return a fromdate and todate between which to show stats */ protected function CalculateCalendarRestrictions($calendarinfo = array()) { $rightnow = time(); $today = isc_gmmktime(0, 0, 0, isc_date("m"), isc_date("d"), isc_date("Y")); $yesterday = isc_gmmktime(0, 0, 0, isc_date("m"), isc_date("d") - 1, isc_date("Y")); if (isset($calendarinfo['DateType'])) { switch (isc_strtolower($calendarinfo['DateType'])) { case "today": $startdate = $today; $enddate = $rightnow; break; case "yesterday": $startdate = $yesterday; $enddate = $today - 1; break; case "last24hours": $startdate = $rightnow - 86400; $enddate = $rightnow; break; case "last7days": $startdate = isc_gmmktime(0, 0, 0, isc_date("m"), isc_date("d") - 7, isc_date("Y")); $enddate = $rightnow; break; case "last30days": $startdate = isc_gmmktime(0, 0, 0, isc_date("m"), isc_date("d") - 30, isc_date("Y")); $enddate = $rightnow; break; case "thismonth": $startdate = isc_gmmktime(0, 0, 0, isc_date("m"), 1, isc_date("Y")); $enddate = $rightnow; break; case "lastmonth": $startdate = isc_gmmktime(0, 0, 0, isc_date("m") - 1, 1, isc_date("Y")); $enddate = isc_gmmktime(0, 0, 0, isc_date("m"), 1, isc_date("Y")); break; case "alltime": $startdate = 0; $enddate = $rightnow; break; case "custom": $startdate = isc_gmmktime(0, 0, 0, $calendarinfo['From']['Mth'], $calendarinfo['From']['Day'], $calendarinfo['From']['Yr']); $enddate = isc_gmmktime(23, 59, 59, $calendarinfo['To']['Mth'], $calendarinfo['To']['Day'], $calendarinfo['To']['Yr']); break; } } else { // Default to last 30 days $startdate = isc_gmmktime(0, 0, 0, isc_date("m"), isc_date("d") - 30, isc_date("Y")); $enddate = $rightnow; } return array("start" => $startdate, "end" => $enddate); }
private function GetQuote() { $shipperAddress = array( 'CountryCode' => $this->_origin_country['country_iso'], 'PostalCode' => $this->_origin_zip ); // United States or Canada require state/province if ($this->_origin_country['country_iso'] == 'US' || $this->_origin_country['country_iso'] == 'CA') { $shipperAddress['StateOrProvinceCode'] = $this->_origin_state['state_iso']; } $recipientAddress = array( 'CountryCode' => $this->_destcountry, 'PostalCode' => $this->_destzip, 'Residential' => ($this->GetValue('destinationtype') == 'residential'), ); // United States or Canada require state/province if ($this->_destcountry == 'US' || $this->_destcountry == "CA") { $recipientAddress['StateOrProvinceCode'] = $this->_deststate; } $weight = number_format(max(ConvertWeight($this->_weight, 'lbs'), 0.1), 1, '.', ''); // if today is on the weekend, set the date to the next monday $shipTime = isc_gmmktime(); $day = date('l', $shipTime); if ($day == 'Saturday') { $shipTime += 172800; } elseif ($day == 'Sunday') { $shipTime += 86400; } // create the shipment $shipDate = date('c', $shipTime); $xml = array( 'WebAuthenticationDetail' => array ( 'UserCredential' => array( 'Key' => $this->GetValue('key'), 'Password' => $this->GetValue('password') ) ), 'ClientDetail' => array( 'AccountNumber' => $this->GetValue('accountno'), 'MeterNumber' => $this->GetValue('meterno') ), 'Version' => array( 'ServiceId' => 'crs', 'Major' => '7', 'Intermediate' => '0', 'Minor' => '0' ), 'ReturnTransitAndCommit' => true, 'RequestedShipment' => array( 'Shipper' => array( 'Address' => $shipperAddress ), 'Recipient' => array( 'Address' => $recipientAddress ), 'ShippingChargesPayment' => array( 'PaymentType' => 'SENDER' ), 'RateRequestTypes' => $this->GetValue('ratetype'), 'PackageCount' => 1, 'PackageDetail' => 'INDIVIDUAL_PACKAGES', 'PackagingType' => $this->GetValue('packagingtype'), 'DropoffType' => $this->GetValue('dropofftype'), 'ShipTimestamp' => $shipDate, 'RequestedPackageLineItems' => array( 'Weight' => array( 'Units' => 'LB', 'Value' => $weight ) ), ) ); if (!empty($this->_service)) { $xml['RequestedShipment']['ServiceType'] = $this->_service; $services = array($this->_service); } else { $services = $this->GetValue("service"); if(!is_array($services) && $services != "") { $services = array($services); } } $new_xml['RateRequest'] = $xml; require_once(dirname(__FILE__) . "/../../../lib/nusoap/nusoap.php"); if ($this->GetValue('testmode') == "NO") { $wsdl = "RateService_v7.wsdl"; } else { $wsdl = "RateService_v7_dev.wsdl"; } $client = new nusoap_client(dirname(__FILE__) . "/" . $wsdl, 'wsdl'); $result = $client->call('getRates', $new_xml); if ($result['HighestSeverity'] == 'FAILURE' || $result['HighestSeverity'] == 'ERROR' || !isset($result['RateReplyDetails'])) { if (isset($result['Notifications'])) { $notifications = $result['Notifications']; if (key($notifications) != '0') { $notifications = array($notifications); } foreach ($notifications as $notification) { $this->SetError($notification['Severity'] . ' - ' . $notification['Message']); } } else { $this->SetError(GetLang('FedExBadResponse')); } return false; } if ($this->GetValue('ratetype') == 'LIST') { $responseRateTypes = array('RATED_LIST', 'PAYOR_LIST'); $preferredRateType = 'RATED_LIST'; } else { $responseRateTypes = array('RATED_ACCOUNT', 'PAYOR_ACCOUNT'); $preferredRateType = 'RATED_ACCOUNT'; } $currency = GetDefaultCurrency(); $quotes = array(); $rateReplyDetails = $result['RateReplyDetails']; if (key($rateReplyDetails) != '0') { $rateReplyDetails = array($rateReplyDetails); } $serviceQuotes = array(); $serviceRateTypes = array(); foreach ($rateReplyDetails as $rate) { // skip if this service hasn't been enabled if (!in_array($rate['ServiceType'], $services)) { continue; } $shipmentDetails = $rate['RatedShipmentDetails']; if (key($shipmentDetails) != '0') { $shipmentDetails = array($shipmentDetails); } foreach ($shipmentDetails as $shipmentRate) { $rateDetail = $shipmentRate['ShipmentRateDetail']; // ensure we have the correct rate type response if (!in_array($rateDetail['RateType'], $responseRateTypes)) { continue; } // multiple rate types for the same service can be returned, we preferabbly want the 'RATED' rate type if (isset($serviceRateTypes[$rate['ServiceType']]) && $serviceRateTypes[$rate['ServiceType']] == $preferredRateType) { continue; } // ensure the amount is in the currency of the store $totalNetCharge = $rateDetail['TotalNetCharge']; if ($totalNetCharge['Currency'] != $currency['currencycode']) { $this->SetError(GetLang('FedExUnexpectedCurrency', array('quoteCurrency' => $totalNetCharge['Currency'], 'storeCurrency' => $currency['currencycode']))); return false; } // build a new shipping quote $serviceQuotes[$rate['ServiceType']] = new ISC_SHIPPING_QUOTE( $this->GetId(), $this->GetDisplayName(), (float)$totalNetCharge['Amount'], $this->_servicetypes[$rate['ServiceType']] ); // store the type of rate for this service $serviceRateTypes[$rate['ServiceType']] = $rateDetail['RateType']; } $quotes = array_values($serviceQuotes); } return $quotes; }
private function generateCustomizeItemForm(array $item) { $defaultItem = array( 'name' => '', 'quantity' => 1, 'price' => '', 'productId' => '', 'variationOptions' => array(), 'variationId' => 0, 'configuration' => '', 'wrapping' => '', 'itemId' => '', 'quoteSession' => '', 'eventDate' => array(), 'eventName' => '', 'sku' => '', ); $item = array_merge($defaultItem, $item); $this->template->assign('item', $item); if($item['productId']) { $productClass = new ISC_PRODUCT($item['productId']); if(!$productClass->getProductId()) { $this->sendEditOrderResponse(array( 'errors' => array( getLang('InvalidProduct') ) )); } $this->template->assign('product', $productClass->getProduct()); $this->template->assign('variationOptions', $productClass->GetProductVariationOptions()); $this->template->assign('variationValues', $productClass->GetProductVariationOptionValues()); $configurableFields = $productClass->GetProductFields($item['productId']); foreach($configurableFields as &$field) { if($field['type'] == 'select') { $options = explode(',', $field['selectOptions']); $field['selectOptions'] = array_map('trim', $options); } } $this->template->assign('configurableFields', $configurableFields); // Event date if($productClass->getEventDateRequired()) { $eventDateFromStamp = $productClass->getEventDateLimitedStartDate(); $eventDateToStamp = $productClass->getEventDateLimitedEndDate(); $eventDate = array( 'fromStamp' => $eventDateFromStamp, 'toStamp' => $eventDateToStamp, 'yearFrom' => isc_date('Y', $eventDateFromStamp), 'yearTo' => isc_date('Y', $eventDateToStamp) ); // Generate a list of month options $eventDate['monthOptions'] = array(); for($i = 1; $i <= 12; ++$i) { $stamp = isc_gmmktime(0, 0, 0, $i, 1, 2000); $month = isc_date("M", $stamp); $eventDate['monthOptions'][$i] = $month; } $eventDateLimit = $productClass->getEventDateLimited(); if(empty($eventDateLimit)) { $eventDate['yearFrom'] = isc_date('Y'); $eventDate['yearTo'] = $eventDate['yearFrom'] + 5; } else { $eventDate['limitationType'] = $productClass->getEventDateLimitedType(); if($eventDate['limitationType'] == 1) { $eventDate['compDate'] = isc_date('Y/m/d', $eventDateFromStamp); $eventDate['compDateEnd'] = isc_date('Y/m/d', $eventDateToStamp); } else if($eventDate['limitationType'] == 2) { $eventDate['yearTo'] = $eventDate['yearFrom'] + 5; $eventDate['compDate'] = isc_date('Y/m/d', $eventDateFromStamp); } else if($eventDate['limitationType'] == 3) { $eventDate['yearFrom'] = isc_date('Y'); $eventDate['compDate'] = isc_date('Y/m/d', $eventDateToStamp); } } $this->template->assign('eventDate', $eventDate); } } if(!empty($item['quoteItem'])) { $allowableWrappingOptions = $item['quoteItem']->getGiftWrappingOptions(); } // Product still exists - get the gift wrapping options on the product if(isset($productClass)) { $product = $productClass->getProduct(); $allowableWrappingOptions = explode(',', $product['prodwrapoptions']); } if(!empty($allowableWrappingOptions)) { if(empty($allowableWrappingOptions) || in_array(0, $allowableWrappingOptions)) { $giftWrapWhere = "wrapvisible='1'"; } else { $wrappingOptions = implode(',', array_map('intval', $allowableWrappingOptions)); $giftWrapWhere = "wrapid IN (".$wrappingOptions.")"; } $query = " SELECT * FROM [|PREFIX|]gift_wrapping WHERE ".$giftWrapWhere." ORDER BY wrapname ASC "; $giftWrappingOptions = array(); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); while($wrap = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $giftWrappingOptions[$wrap['wrapid']] = $wrap; } $this->template->assign('giftWrappingOptions', $giftWrappingOptions); } return array( 'data' => $this->template->render('order.form.customizeitem.tpl'), 'width' => 600, 'height' => 500, ); }
public function getEventDate($timestamp = false) { if (empty($this->eventDate)) { return false; } if ($timestamp == false) { return $this->eventDate; } return isc_gmmktime(0, 0, 0, $this->eventDate['month'], $this->eventDate['day'], $this->eventDate['year']); }
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); } } }
private function AddToCart() { $error = false; $product = false; $product_id = false; $isFastCart = GetConfig('FastCartAction') == 'popup' && isset($_REQUEST['fastcart']) && GetConfig('ShowCartSuggestions'); if(isset($_REQUEST['product_id']) && (bool)GetConfig('AllowPurchasing')) { $product_id = (int)$_REQUEST['product_id']; $query = " SELECT p.*, ".GetProdCustomerGroupPriceSQL()." FROM [|PREFIX|]products p WHERE p.productid='".$product_id."' "; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $product = $GLOBALS['ISC_CLASS_DB']->Fetch($result); if (!$product) { $error = true; } else { $GLOBALS['ProductJustAdded'] = $product_id; $GLOBALS['Product'] = &$product; } } else { $error = true; } if ($error) { flashMessage(getLang('ProductUnavailableForPruchase'), MSG_ERROR); if ($isFastCart) { // dont show fast cart pop up if an error occurs GetClass('ISC_404')->HandlePage(); return; } else { redirect('cart.php'); } } // Check that the customer has permisison to view this product $canView = false; $productCategories = explode(',', $product['prodcatids']); foreach($productCategories as $categoryId) { // Do we have permission to access this category? if(CustomerGroupHasAccessToCategory($categoryId)) { $canView = true; } } if($canView == false) { $noPermissionsPage = GetClass('ISC_403'); $noPermissionsPage->HandlePage(); exit; } $variation = 0; if(isset($_REQUEST['variation_id']) && $_REQUEST['variation_id'] != 0) { $variation = (int)$_REQUEST['variation_id']; } // User added a variation but had javascript disabled else if(isset($_REQUEST['variation']) && is_array($_REQUEST['variation']) && $_REQUEST['variation'][1] != 0) { $variation = $_REQUEST['variation']; } $qty = 1; if(isset($_REQUEST['qty'])) { if(is_array($_REQUEST['qty'])) { $qty = (int)array_pop($_REQUEST['qty']); } else if($_REQUEST['qty'] > 0) { $qty = (int)$_REQUEST['qty']; } } $configurableFields = null; if(isset($_REQUEST['ProductFields']) || isset($_FILES['ProductFields'])) { $configurableFields = $this->BuildProductConfigurableFieldData(); } if (isset($_REQUEST['EventDate']['Day'])) { $result = true; $eventDate = isc_gmmktime(0, 0, 0, $_REQUEST['EventDate']['Mth'],$_REQUEST['EventDate']['Day'],$_REQUEST['EventDate']['Yr']); $eventName = $product['prodeventdatefieldname']; if ($product['prodeventdatelimitedtype'] == 1) { if ($eventDate < $product['prodeventdatelimitedstartdate'] || $eventDate > $product['prodeventdatelimitedenddate']) { $result = false; } } else if ($product['prodeventdatelimitedtype'] == 2) { if ($eventDate < $product['prodeventdatelimitedstartdate']) { $result = false; } } else if ($product['prodeventdatelimitedtype'] == 3) { if ($eventDate > $product['prodeventdatelimitedenddate']) { $result = false; } } if ($result == false) { if ($isFastCart) { GetClass('ISC_404')->HandlePage(); return; } else { redirect('cart.php'); } } } $showMinQuantityAdjustment = false; if($product['prodminqty'] && $qty < $product['prodminqty']) { $qty = $product['prodminqty']; $showMinQuantityAdjustment = true; } try { $item = new ISC_QUOTE_ITEM; $item ->setQuote($this->getQuote()) ->setProductId($product_id) ->setQuantity($qty) ->setVariation($variation) ->applyConfiguration($configurableFields); if(!empty($_REQUEST['EventDate'])) { $item ->setEventDate( $_REQUEST['EventDate']['Mth'], $_REQUEST['EventDate']['Day'], $_REQUEST['EventDate']['Yr']) ->setEventName($eventName); } $this->getQuote()->addItem($item); } catch(ISC_QUOTE_EXCEPTION $e) { if ($isFastCart) { GetClass('ISC_404')->HandlePage(); return; } if($e->getCode() == ISC_QUOTE_EXCEPTION::ERROR_NO_STOCK && $showMinQuantityAdjustment) { flashMessage(getLang('CannotAddMinQuantityToCart', array( 'minqty' => $qty, 'product' => $product['prodname'] )), MSG_ERROR, prodLink($product['prodname'])); } else { flashMessage($e->getMessage(), MSG_ERROR, prodLink($product['prodname'])); } } if($showMinQuantityAdjustment) { flashMessage(getLang('AddToCartMinimumQuantityNotice', array( 'product' => $product['prodname'], 'qty' => $product['prodminqty'])), MSG_INFO); } $_SESSION['JustAddedProduct'] = $product_id; // Are we redirecting to a specific location? if(isset($_REQUEST['returnUrl'])) { $redirectLocation = urldecode($_REQUEST['returnUrl']); $urlPieces = @parse_url($redirectLocation); $storeUrlPieces = @parse_url(GetConfig('ShopPath')); if(is_array($urlPieces) && isset($urlPieces['host'])) { $urlHost = str_replace('www.', '', isc_strtolower($urlPieces['host'])); $storeHost = str_replace('www.', '', isc_strtolower($storeUrlPieces['host'])); if($urlHost == $storeHost) { if(strpos($redirectLocation, '?') === false) { $redirectLocation .= '?'; } else { $redirectLocation .= '&'; } $redirectLocation .= 'justAddedProduct='.$product_id; redirect($redirectLocation); } } } // Show the new contents of the cart $url = 'cart.php'; if (GetConfig('ShowCartSuggestions')) { $url .= '?suggest='.$item->getId(); } if ($isFastCart) { $this->_setupFastCartData($this->getQuote(), $item); echo $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('FastCartThickBoxContent'); } else { redirect($url); } }