public function getNext()
 {
     global $config;
     if (!$this->result) {
         return FALSE;
     }
     $row = mysql_fetch_assoc($this->result);
     if (!$row) {
         return FALSE;
     }
     if ($this->result) {
         $query = "SELECT AVG(price) AS MarketPrice FROM `" . $config['table prefix'] . "LogSales` WHERE " . "`itemId` = " . (int) $row['itemId'] . " AND " . "`itemDamage` = " . (int) $row['itemDamage'] . " AND " . "IFNULL (`enchantments`, '') = '" . mysql_san($row['enchantments']) . "' AND " . "`logType` =      'sale'" . "ORDER BY `id` DESC LIMIT 10";
         $this->result_price = RunQuery($query, __FILE__, __LINE__);
     }
     if ($this->result_price) {
         $row_price = mysql_fetch_assoc($this->result_price);
         if ($row_price) {
             $marketPrice = $row_price['MarketPrice'];
             $marketPrice_total = $marketPrice * $row['qty'];
         } else {
             $marketPrice = "--";
             $marketPrice_total = "--";
         }
     }
     // new item dao
     return new ItemDAO($row['id'], $row['itemId'], $row['itemDamage'], $row['itemData'], $row['qty'], FormatPrice($marketPrice), FormatPrice($marketPrice_total), $row['enchantments']);
 }
Beispiel #2
0
 /**
  * Send the order notification email
  */
 public function SendNotification()
 {
     $emails = array();
     $this->_message = $this->BuildEmailMessage();
     $this->_email = $this->GetValue("emailaddress");
     if (empty($this->_email)) {
         return;
     }
     $emails = preg_split('#[,\\s]+#si', $this->_email, -1, PREG_SPLIT_NO_EMPTY);
     // Create a new email object through which to send the email
     $store_name = GetConfig('StoreName');
     require_once ISC_BASE_PATH . "/lib/email.php";
     $obj_email = GetEmailClass();
     $obj_email->Set('CharSet', GetConfig('CharacterSet'));
     $obj_email->From(GetConfig('OrderEmail'), $store_name);
     $obj_email->Set("Subject", sprintf(GetLang('NEmailSubjectLine'), $this->GetOrderId(), $store_name, FormatPrice($this->GetOrderTotal(), false, true, false, GetDefaultCurrency())));
     $obj_email->AddBody("html", $this->_message);
     // Add all recipients
     foreach ($emails as $email) {
         $obj_email->AddRecipient($email, "", "h");
     }
     $email_result = $obj_email->Send();
     if ($email_result['success']) {
         $result = array("outcome" => "success", "message" => sprintf(GetLang('EmailNotificationSentUser'), implode("<br />", $emails)));
     } else {
         $result = array("outcome" => "fail", "message" => GetLang('NEmailSendingFailed'));
     }
     return $result;
 }
Beispiel #3
0
		/**
		* Build and format the message to be sent
		*/
		private function BuildSmsMessage()
		{
			if($this->testMode == true) {
				return urlencode('SMSMessageTest');
			}
			else {
				$message = sprintf(GetLang('SMSMessageContents'), $this->_orderid, $GLOBALS['StoreName'], $this->_ordernumitems, FormatPrice($this->_ordertotal, false, true, false, GetDefaultCurrency()), $this->_orderpaymentmethod);
				return urlencode($message);
			}
		}
Beispiel #4
0
		/**
		* Build and format the message to be sent
		*/
		private function BuildMsnMessage()
		{
			if($this->testMode) {
				return GetLang('MSNMessageTest');
			}
			else {
				$store_name = GetConfig('StoreName');
				$message = sprintf(GetLang('MSNMessageContents'), $this->_orderid, $store_name, $this->_ordernumitems, FormatPrice($this->_ordertotal, false, true, false, GetDefaultCurrency()), $this->_orderpaymentmethod, $GLOBALS['ShopPath'], $this->_orderid);
				return str_replace("{NL}", chr(10), $message);
			}
		}
 /**
  * Fetch the payment details (outstanding balance etc) for a specific vendor.
  */
 private function GetVendorPaymentDetails()
 {
     if (!isset($_REQUEST['vendorId'])) {
         exit;
     }
     $paymentClass = GetClass('ISC_ADMIN_VENDOR_PAYMENTS');
     $paymentDetails = $paymentClass->CalculateOutstandingVendorBalance($_REQUEST['vendorId']);
     $tags[] = $this->MakeXMLTag('status', 1);
     $tags[] = $this->MakeXMLTag('fromDate', CDate($paymentDetails['lastPaymentDate']), true);
     $tags[] = $this->MakeXMLTag('toDate', CDate(time()), true);
     $tags[] = $this->MakeXMLTag('outstandingBalance', FormatPrice($paymentDetails['outstandingBalance']), true);
     $tags[] = $this->MakeXMLTag('balanceForward', FormatPrice($paymentDetails['balanceForward']), true);
     $tags[] = $this->MakeXMLTag('profitMargin', FormatPrice($paymentDetails['profitMargin']), true);
     $tags[] = $this->MakeXMLTag('profitMarginPercentage', $paymentDetails['profitMarginPercentage'], true);
     $tags[] = $this->MakeXMLTag('totalOrders', FormatPrice($paymentDetails['totalOrders']), true);
     $this->SendXMLHeader();
     $this->SendXMLResponse($tags);
     exit;
 }
Beispiel #6
0
		/**
		 * Edit a customer page
		 *
		 * Method will construct the edit customer page
		 *
		 * @access public
		 * @param string $MsgDesc The optional message to display
		 * @param string $MsgStatus The optional status of the message
		 * @param bool $PreservePost TRUE to use the REQUEST variable, FALSE to read from the database. Default is FALSE
		 * @return Void
		 */
		public function EditCustomerStep1($MsgDesc = "", $MsgStatus = "", $PreservePost=false)
		{
			if ($MsgDesc != "") {
				$GLOBALS['Message'] = MessageBox($MsgDesc, $MsgStatus);
			}

			$flashMessages = GetFlashMessages();
			if(is_array($flashMessages) && !empty($flashMessages)) {
				$GLOBALS['Message'] = '';
				foreach($flashMessages as $flashMessage) {
					$GLOBALS['Message'] .= MessageBox($flashMessage['message'], $flashMessage['type']);
				}
			}

			// Show the form to edit a customer
			$customerId = isc_html_escape((int)$_GET['customerId']);

			// Make sure the customer exists
			if (!CustomerExists($customerId)) {
				// The customer doesn't exist
				if ($GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Edit_Customers)) {
					$this->ManageCustomers(GetLang('CustomerDoesntExist'), MSG_ERROR);
				} else {
					$GLOBALS['ISC_CLASS_ADMIN_ENGINE']->DoHomePage(GetLang('Unauthorized'), MSG_ERROR);
				}
				return;
			}

			if (!$GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Add_Customer)) {
				$GLOBALS['CustomerAddressAddDisabled'] = 'DISABLED';
			}

			if (!$GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Delete_Customers)) {
				$GLOBALS['CustomerAddressDeleteDisabled'] = 'DISABLED';
			}

			if (GetConfig('CurrencyLocation') == 'right') {
				$GLOBALS['CurrencyTokenLeft'] = '';
				$GLOBALS['CurrencyTokenRight'] = GetConfig('CurrencyToken');
			} else {
				$GLOBALS['CurrencyTokenLeft'] = GetConfig('CurrencyToken');
				$GLOBALS['CurrencyTokenRight'] = '';
			}

			if ($PreservePost == true) {
				$customer = $this->_GetCustomerData(0);
			} else {
				$customer = $this->_GetCustomerData($customerId);
			}

			if (isset($_REQUEST['currentTab'])) {
				$GLOBALS['CurrentTab'] = (int)$_REQUEST['currentTab'];
			} else {
				$GLOBALS['CurrentTab'] = 0;
			}

			$query = "SELECT *
						FROM [|PREFIX|]shipping_addresses
						WHERE shipcustomerid='" . $GLOBALS['ISC_CLASS_DB']->Quote((int)$customerId) . "'";

			if ($GLOBALS['ISC_CLASS_DB']->CountResult($GLOBALS['ISC_CLASS_DB']->Query($query))) {
				$GLOBALS['CustomerAddressEmptyShow'] = 'none';
			} else {
				$GLOBALS['CustomerAddressEmptyHide'] = 'none';
			}

			$GLOBALS['FormAction'] = "editCustomer2";
			$GLOBALS['CustomerId'] = $customerId;
			$GLOBALS['Title'] = GetLang('EditCustomerTitle');
			$GLOBALS['Intro'] = GetLang('EditCustomerIntro');
			$GLOBALS['CustomerAddressListWarning'] = GetLang('CustomerAddressNoAddresses');
			$GLOBALS['CustomerFirstName'] = $customer['custconfirstname'];
			$GLOBALS['CustomerLastName'] = $customer['custconlastname'];
			$GLOBALS['CustomerCompany'] = $customer['custconcompany'];
			$GLOBALS['CustomerEmail'] = $customer['custconemail'];
			$GLOBALS['CustomerPhone'] = $customer['custconphone'];
			$GLOBALS['CustomerStoreCredit'] = FormatPrice($customer['custstorecredit'], false, false);
			$GLOBALS['CustomerGroupId'] = $customer['custgroupid'];
			$GLOBALS['CustomerGroupOptions'] = $this->GetCustomerGroupsAsOptions($customer['custgroupid']);
			$GLOBALS['CustomerShippingAddressGrid'] = $this->ManageCustomerAddressGrid();
			$GLOBALS['PasswordRequired'] = '&nbsp;&nbsp;';
			$GLOBALS['PasswordLabel'] = GetLang('CustomerNewPassword');
			$GLOBALS['PasswordHelp'] = GetLang('CustomerNewPasswordHelp');
			$GLOBALS['PasswordConfirmHelp'] = GetLang('CustomerNewPasswordConfirmHelp');
			$GLOBALS['PasswordConfirmError'] = GetLang('CustomerNewPasswordConfirmError');
			$GLOBALS['PasswordConfirmRequired'] = '&nbsp;&nbsp;';
			$GLOBALS['CustomFieldsAccountFormId'] = FORMFIELDS_FORM_ACCOUNT;
			$GLOBALS['CustomFields'] = '';

			/**
			 * Custom fields
			 */
			if (gzte11(ISC_MEDIUMPRINT)) {
				if ($PreservePost) {
					$fields = $GLOBALS['ISC_CLASS_FORM']->getFormFields(FORMFIELDS_FORM_ACCOUNT, true);
				} else if (isset($customer['custformsessionid']) && isId($customer['custformsessionid'])) {
					$fields = $GLOBALS['ISC_CLASS_FORM']->getFormFields(FORMFIELDS_FORM_ACCOUNT, false, $customer['custformsessionid']);
				} else {
					$fields = $GLOBALS['ISC_CLASS_FORM']->getFormFields(FORMFIELDS_FORM_ACCOUNT);
				}

				foreach (array_keys($fields) as $fieldId) {
					if ($fields[$fieldId]->record['formfieldprivateid'] !== '') {
						continue;
					}

					$GLOBALS['CustomFields'] .= $fields[$fieldId]->loadForFrontend() . "\n";
				}
			}

			/**
			 * Add this to generate our JS event script
			 */
			$GLOBALS['FormFieldEventData'] = $GLOBALS['ISC_CLASS_FORM']->buildRequiredJS();

			$GLOBALS['SaveAndAddAnother'] = GetLang('SaveAndContinueEditing');
			$GLOBALS['CancelMessage'] = GetLang('ConfirmCancelCustomer');
			$this->template->display('customer.form.tpl');
		}
 private function ManageCurrencySettings($messages = array())
 {
     $GLOBALS['Message'] = GetFlashMessageBoxes();
     // Select the first available currency module to be used for auto updating the exchange rate
     if (count($currModules = explode(",", GetConfig("CurrencyMethods")))) {
         $GLOBALS['SelectedCurrencyModuleId'] = $currModules[0];
         $GLOBALS['UpdateExchageRateButton'] = '<input type="button" name="IndexUpdateButton" value="' . GetLang('CurrencyUpdateSelectedExchangeRate') . '" id="IndexUpdateButton" class="SmallButton" style="width:200px;" onclick="ConfirmUpdateSelectedExchangeRate()" />';
     } else {
         $GLOBALS['SelectedCurrencyModuleId'] = "0";
         $GLOBALS['UpdateExchageRateButton'] = "";
     }
     // Our default options
     $GLOBALS['DefaultTab'] = 0;
     $GLOBALS['CurrencyTabs'] = '<li><a href="#" id="tab0" onclick="ShowTab(0)">' . GetLang('CurrencyOptions') . '</a></li>';
     // Get our selected currency converts list
     $GLOBALS['ConverterProviders'] = $this->_getCurrencyConvertersAsOptions();
     // What's the path for the exchange rate update cron?
     if (strpos(strtolower(PHP_OS), 'win') === 0) {
         $binary = 'php.exe';
     } else {
         $binary = 'php';
     }
     $path_to_php = Which($binary);
     if ($path_to_php === '' && strpos(strtolower(PHP_OS), 'win') === 0) {
         $path_to_php = 'php.exe';
     } elseif ($path_to_php === '') {
         $path_to_php = 'php';
     }
     $GLOBALS['ExchangeRatePath'] = $path_to_php . ' -f ' . realpath(ISC_BASE_PATH . '/admin/') . "/cron-updateexchangerates.php";
     // Get our list of currencies
     $GLOBALS['CurrencyGrid'] = "";
     $GLOBALS['CurrencyIntro'] = GetLang('CurrencyIntro');
     // Apply any special messages that need modifying
     $GLOBALS['CurrencySetAsDefaultMessage'] = sprintf(GetLang('CurrencySetAsDefaultMessage'), GetLang('CurrencySetAsDefaultOptYes'), GetLang('CurrencySetAsDefaultOptYesPrice'));
     // Apply our Popup variables
     $GLOBALS['PopupID'] = "CurrencyPopup";
     $GLOBALS['PopupDisplay'] = "none";
     $GLOBALS['PopupTools'] = "";
     $GLOBALS['PopupImgDisplay'] = "none";
     $GLOBALS['PopupImgSrc'] = "images/1x1.gif";
     //IMPORTANT!!! Set any source!
     $GLOBALS['PopupHeader'] = GetLang('CurrencySetAsDefaultTitle');
     $GLOBALS['PopupContent'] = sprintf(GetLang('CurrencySetAsDefaultMessage'), GetLang('CurrencySetAsDefaultOptYes'), GetLang('CurrencySetAsDefaultOptYesPrice')) . '</p><p>';
     $GLOBALS['PopupContent'] .= '<input type="button" value="' . isc_html_escape(GetLang('CurrencySetAsDefaultOptYes')) . '" id="CurrencyPopupButtonYes" class="Field150" />';
     $GLOBALS['PopupContent'] .= '<input type="button" value="' . isc_html_escape(GetLang('CurrencySetAsDefaultOptYesPrice')) . '" id="CurrencyPopupButtonYesPrice" class="Field150" />';
     $GLOBALS['PopupContent'] .= '<input type="button" value="' . isc_html_escape(GetLang('CurrencySetAsDefaultOptNo')) . '" id="CurrencyPopupButtonNo" class="Field150" />';
     // Get our currency list
     $currencyResult = $this->_getCurrencyList();
     if ($GLOBALS['ISC_CLASS_DB']->CountResult($currencyResult) > 0) {
         while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($currencyResult)) {
             $GLOBALS['CurrencyId'] = (int) $row['currencyid'];
             $GLOBALS['CurrencyName'] = isc_html_escape($row['currencyname']);
             $GLOBALS['CurrencyCode'] = isc_html_escape($row['currencycode']);
             $GLOBALS['CurrencyRate'] = FormatPrice($row['currencyexchangerate'], false, true, false, $row, false);
             if ($row['currencyisdefault']) {
                 $GLOBALS['ClassName'] = "GridRowSel";
                 $GLOBALS['DeleteStatus'] = " disabled='disabled'";
                 $GLOBALS['CurrencyName'] .= " <span style='margin-left:10px; font-size:0.8em; font-weight:bold;'>(" . GetLang('lowerDefault') . ")</span>";
                 $defaultStyle = " style='color:#666666;'";
             } else {
                 $GLOBALS['ClassName'] = "GridRow";
                 $GLOBALS['DeleteStatus'] = "";
                 $defaultStyle = "";
             }
             if ($row['currencyisdefault'] && $row['currencystatus'] == 1) {
                 $GLOBALS['Status'] = "<img border='0' src='images/tick.gif' alt='tick'>";
             } else {
                 if ($row['currencystatus'] == 1) {
                     $GLOBALS['Status'] = "<a title='" . GetLang('CurrencyStatusDisable') . "' href='index.php?ToDo=settingsEditCurrencyStatus&amp;currencyId=" . $row['currencyid'] . "&amp;status=0'><img border='0' src='images/tick.gif' alt='tick'></a>";
                 } else {
                     $GLOBALS['Status'] = "<a title='" . GetLang('CurrencyStatusEnable') . "' href='index.php?ToDo=settingsEditCurrencyStatus&amp;currencyId=" . $row['currencyid'] . "&amp;status=1'><img border='0' src='images/cross.gif' alt='cross'></a>";
                 }
             }
             $GLOBALS['CurrencyLinks'] = "<a title='" . GetLang('CurrencyEdit') . "' href='index.php?ToDo=settingsEditCurrency&amp;currencyId=" . $row['currencyid'] . "'>" . GetLang('Edit') . "</a>";
             $GLOBALS['CurrencyLinks'] .= "&nbsp;&nbsp;&nbsp;&nbsp;";
             // Default record should not be able to set as default again
             if ($row['currencyisdefault']) {
                 $GLOBALS['CurrencyLinks'] .= "<span style='color:#666666;'>" . GetLang('CurrencySetAsDefault') . "</span>";
             } else {
                 $GLOBALS['CurrencyLinks'] .= "<a href='#' title='" . GetLang('CurrencySetAsDefault') . "' onclick='return ConfirmSetAsDefault(" . $row['currencyid'] . ");'>" . GetLang('CurrencySetAsDefault') . "</a>";
             }
             $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("currency.manage.row");
             $GLOBALS['CurrencyGrid'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate(true);
         }
     } else {
         // There are no currencies in the database
         $GLOBALS['DisableDelete'] = "style='display:none'";
         $GLOBALS['DisplayGrid'] = "none";
         $GLOBALS['CurrencyOptionsMessage'] = MessageBox(GetLang('NoCurrencies'), MSG_INFO);
         $GLOBALS['ShowCurrencyTableHeaders'] = 'none';
     }
     $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("settings.currency.manage");
     $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate();
 }
 /**
  * Applies formatting to values such as price, date and text formats
  *
  * @param array The row of data to format
  * @param array Optional subset of fields to use when performing formatting. Defaults to the entire loaded field array.
  */
 protected function FormatColumns(&$row, $fields = array())
 {
     if (!count($fields)) {
         $fields = $this->fields;
     }
     foreach ($row as $column => $value) {
         if (!isset($fields[$column])) {
             continue;
         }
         $field = $fields[$column];
         // format the value if required
         if (isset($field['format'])) {
             $format = $field['format'];
             if ($format == "number") {
                 if ($this->template['priceformat'] == "formatted") {
                     $row[$column] = FormatPriceInCurrency($value);
                 } else {
                     $row[$column] = FormatPrice($value, false, false, true);
                 }
             } elseif ($format == "date") {
                 if ($value != '0') {
                     $row[$column] = date($this->dateformat, $value);
                 } else {
                     $value = '';
                 }
             } elseif ($format == "text") {
                 // remove html tags and decode entities
                 //$decoded = html_entity_decode(strip_tags($value));
                 $decoded = $value;
                 // remove excess white space
                 $excess = preg_replace("/^(\\s+)/m", "", $decoded);
                 // replace new lines with spaces
                 $row[$column] = preg_replace("/([\\r\\n]+)/m", " ", $excess);
             } elseif ($format == "bool") {
                 $value = (bool) $value;
                 if ($this->blankforfalse && !$value) {
                     $row[$column] = "";
                 } else {
                     switch ($this->boolformat) {
                         case "onezero":
                             if ($value) {
                                 $row[$column] = "1";
                             } else {
                                 $row[$column] = "0";
                             }
                             break;
                         case "truefalse":
                             if ($value) {
                                 $row[$column] = GetLang("TrueLabel");
                             } else {
                                 $row[$column] = GetLang("FalseLabel");
                             }
                             break;
                         case "yesno":
                             if ($value) {
                                 $row[$column] = GetLang("YesLabel");
                             } else {
                                 $row[$column] = GetLang("NoLabel");
                             }
                             break;
                     }
                 }
             }
         }
     }
 }
Beispiel #9
0
		private function EditDiscountStep1()
		{
			$GLOBALS['Title'] = GetLang('EditDiscount');
			$GLOBALS['Intro'] = GetLang('EditDiscountIntro');
			$GLOBALS['Enabled'] = 'checked="checked"';
			$GLOBALS['FormAction'] = "editDiscount2";
			$GLOBALS['DiscountTypes'] = '';
			$GLOBALS['Edit'] = 'display : none;';
			$GLOBALS['DiscountJavascriptValidation'] = '';
			$GLOBALS['DiscountEnabledCheck'] = 'checked="checked"';

			$rules = GetAvailableModules('rule', false, false, false);

			$GLOBALS['RuleList'] = '';

			$GLOBALS['MaxUses'] = '';
			$GLOBALS['DiscountExpiryFields'] = 'display : none';
			$GLOBALS['DiscountMaxUsesDisabled'] = 'readonly="readonly"';
			$GLOBALS['DiscountExpiryDateDisabled'] = 'readonly="readonly"';

			require_once(ISC_BASE_PATH.'/lib/api/discount.api.php');
			$discountAPI = new API_DISCOUNT();

			$discountId = (int) $_GET['discountId'];

			if ($discountAPI->DiscountExists($discountId)) {

				$discount = $this->GetDiscountData($discountId);
				$freeShippingMessageLocations = unserialize($discount['free_shipping_message_location']);
				$GLOBALS['DiscountId'] = $discountId;
				$GLOBALS['DiscountName'] = isc_html_escape($discount['discountname']);

				$module = explode('_',$discount['discountruletype']);

				if (isset($module[1])) {
					GetModuleById('rule', $ruleModule, $module[1]);
					if(!is_object($ruleModule)) {
						// Something really bad went wrong >_<
						exit;
					}
				}
				else {
					die('Can\'t find the module');
				}

				$cd = unserialize($discount['configdata']);

				if (!empty($cd)) {
					foreach ($cd as $var => $data) {

						if (isc_substr($var,0,5) == "varn_") {
							$data = FormatPrice($data, false, false);
						}

						$GLOBALS[$var] = $data;
					}
				}

				$ruleModule->initialize($discount);
				$ruleModule->initializeAdmin();

				$GLOBALS['RuleList'] = '';

				$GLOBALS['Vendor'] = '0';
				if(gzte11(ISC_HUGEPRINT)) {
					$GLOBALS['Vendor'] = 1;
				}

				foreach ($rules as $rule) {
					$rulesSorted[$rule['object']->getRuleType()][] = $rule;
				}

				$first = true;
				$GLOBALS['CurrentRule'] = 'null';

				foreach ($rulesSorted as $type => $ruleType) {

					if ($first) {
						$GLOBALS['RuleList'] .= '<h4 style="margin-top:5px; margin-bottom:5px;">'.$type.' '.GetLang('BasedRule').'</h4>';
					} else {
						$GLOBALS['RuleList'] .= '<h4 style="margin-bottom:5px;">'.$type.' '.GetLang('BasedRule').'</h4>';
					}
					$first = false;

					foreach ($ruleType as $rule) {

						$GLOBALS['RuleList'] .= '<label><input type="radio" class="discountRadio" onClick="UpdateModule(this.id,'.(int)$rule['object']->vendorSupport().')" name="RuleType" value="'.$rule['id'].'" ';
						if ($rule['id'] == $discount['discountruletype']) {
							$GLOBALS['RuleList'] .= ' checked="checked" ';
							$GLOBALS['CurrentRule'] = "'".$rule['id']."'";
						}

						$GLOBALS['RuleList'] .= 'id="'.$rule['id'].'"> ';

						if (!(int)$rule['object']->vendorSupport() && $GLOBALS['Vendor'] == 1) {
							$GLOBALS['RuleList'] .= '<span class="aside">'.$rule['object']->getDisplayName().'</span>';
						} else {
							$GLOBALS['RuleList'] .= '<span>'.$rule['object']->getDisplayName().'</span>';
						}

						$GLOBALS['RuleList'] .= '</input></label><br /><div id="ruleWrapper'.$rule['id'].'" class="ruleWrapper"';

						if ($rule['id'] != $discount['discountruletype'])
							$GLOBALS['RuleList'] .= 'style="display : none; "';

						$GLOBALS['RuleList'] .= '><img src="images/nodejoin.gif" style="vertical-align: middle; float:left; padding-right : 10px;" /><span class="ruleSettings" id="ruleSettings'.$rule['id'].'">';

						if ($rule['id'] == $discount['discountruletype'])
							$GLOBALS['RuleList'] .= $ruleModule->getTemplateClass()->render('module.'.$module[1].'.tpl');

						$GLOBALS['RuleList'] .= '</span><br /></div>';
						$GLOBALS['DiscountJavascriptValidation'] .= $rule['object']->getJavascriptValidation();

					}
				}

				$GLOBALS['DiscountMaxUses'] = isc_html_escape($discount['discountmaxuses']);

				if ($discount['discountexpiry'] != 0) {
					$GLOBALS['DiscountExpiryDate'] = date("m/d/Y", isc_html_escape($discount['discountexpiry']));
				} else {
					$GLOBALS['DiscountExpiryDate'] = '';
				}

				$GLOBALS['DiscountExpiryFields'] = 'display : none';
				$GLOBALS['DiscountMaxUsesDisabled'] = 'readonly="readonly"';
				$GLOBALS['DiscountDisabled'] = 'readonly="readonly"';

				if (!empty($GLOBALS['DiscountMaxUses']) || !empty($GLOBALS['DiscountExpiryDate'])) {
					$GLOBALS['DiscountExpiryCheck'] = 'checked="checked"';
					$GLOBALS['DiscountExpiryFields'] = '';
				}

				if (!empty($GLOBALS['DiscountMaxUses'])) {
					$GLOBALS['DiscountMaxUsesCheck'] = 'checked="checked"';
					$GLOBALS['DiscountMaxUsesDisabled'] = '';
				}
				if (!empty($GLOBALS['DiscountExpiryDate'])) {
					$GLOBALS['DiscountExpiryDateCheck'] = 'checked="checked"';
					$GLOBALS['DiscountExpiryDateDisabled'] = '';
				}

				$GLOBALS['DiscountEnabled'] = isc_html_escape($discount['discountenabled']);

				if (empty($GLOBALS['DiscountEnabled'])) {
					$GLOBALS['DiscountEnabledCheck'] = '';
				}

				$GLOBALS['DiscountCurrentUses'] = isc_html_escape($discount['discountcurrentuses']);

				$GLOBALS['MaxUses'] = (int) $discount['discountmaxuses'];
				if($GLOBALS['MaxUses'] > 0) {
					$GLOBALS['MaxUsesChecked'] = 'checked="checked"';
				}
				else {
					$GLOBALS['DiscountMaxUses'] = 1;
					$GLOBALS['MaxUsesHide'] = 'none';
				}
				$this->template->assign('freeShippingMessage', $discount['free_shipping_message']);
				$this->template->assign('freeShippingMessageLocations', $freeShippingMessageLocations);

				$this->template->display('discount.form.tpl');

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

		$quotes = $this->GetServiceQuotes();

		if(is_object($quotes)) {
			$quotes = array($quotes);
		}

		if(empty($quotes)) {
			$GLOBALS['Color'] = "red";
			$GLOBALS['Status'] = GetLang('StatusFailed');
			$GLOBALS['Label'] = GetLang('ShipErrorMessage');
			$GLOBALS['Message'] = implode('<br />', $this->GetErrors());
		}
		else {
			$GLOBALS['Color'] = "green";
			$GLOBALS['Status'] = GetLang('StatusSuccess');
			$GLOBALS['Label'] = GetLang('ShipQuotePrice');

			// Get each available shipping option and display it
			$GLOBALS['Message'] = '<ul style="margin-left: 0; padding-left: 0">';

			foreach($quotes as $quote) {
				$GLOBALS['Message'] .= '<li style="color: green">'.$quote->GetDesc(false).' - '.FormatPrice($quote->GetPrice()).'</li>';
			}
			$GLOBALS['Message'] .= '</li>';
		}
		$GLOBALS['Image'] = $this->GetImage();
		$this->ParseTemplate("module.usps.testresult");
	}
Beispiel #12
0
/**
 *	Send an email notification to a customer when the status of their order changes.
 *
 * @param int The ID of the order to email the invoice for.
 * @return boolean True if successful.
 */
function EmailOnStatusChange($orderId, $status)
{
	// Load the order
	$order = GetOrder($orderId);
	if (!$order) {
		return false;
	}

	// Load the customer we'll be contacting
	if ($order['ordcustid'] > 0) {
		$customer = GetCustomer($order['ordcustid']);
		$GLOBALS['ViewOrderStatusLink'] = '<a href="'.$GLOBALS['ShopPathSSL'].'/orderstatus.php">'.GetLang('ViewOrderStatus').'</a>';
	} else {
		$customer['custconemail'] = $order['ordbillemail'];
		$customer['custconfirstname'] = $order['ordbillfirstname'];
		$GLOBALS['ViewOrderStatusLink'] = '';
	}

	if (empty($customer['custconemail'])) {
		return;
	}

	// All prices in the emailed invoices will be shown in the default currency of the store
	$defaultCurrency = GetDefaultCurrency();

	$statusName = GetOrderStatusById($status);
	$GLOBALS['OrderStatusChangedHi'] = sprintf(GetLang('OrderStatusChangedHi'), isc_html_escape($customer['custconfirstname']));
	$GLOBALS['OrderNumberStatusChangedTo'] = sprintf(GetLang('OrderNumberStatusChangedTo'), $order['orderid'], $statusName);
	$GLOBALS['OrderTotal'] = FormatPrice($order['total_inc_tax'], false, true, false, $defaultCurrency, true);
	$GLOBALS['DatePlaced'] = CDate($order['orddate']);

	if ($order['orderpaymentmethod'] === 'giftcertificate') {
		$GLOBALS['PaymentMethod'] = GetLang('PaymentGiftCertificate');
	}
	else if ($order['orderpaymentmethod'] === 'storecredit') {
		$GLOBALS['PaymentMethod'] = GetLang('PaymentStoreCredit');
	}
	else {
		$GLOBALS['PaymentMethod'] = $order['orderpaymentmethod'];
	}

	$query = "
		SELECT COUNT(*)
		FROM [|PREFIX|]order_products
		WHERE ordprodtype='digital'
		AND orderorderid='".$GLOBALS['ISC_CLASS_DB']->Quote($orderId)."'
	";

	$numDigitalProducts = $GLOBALS['ISC_CLASS_DB']->FetchOne($query);

	$emailTemplate = FetchEmailTemplateParser();

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

	if (OrderIsComplete($status) && $numDigitalProducts > 0) {
		$query = "
			SELECT *
			FROM [|PREFIX|]order_products op INNER JOIN [|PREFIX|]products p ON (op.ordprodid = p.productid)
			WHERE ordprodtype='digital'
			AND orderorderid='".$GLOBALS['ISC_CLASS_DB']->Quote($orderId)."'
		";
		$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
		while ($product_row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
			$GLOBALS['ProductOptions'] = '';
			$GLOBALS['ProductQuantity'] = $product_row['ordprodqty'];
			$GLOBALS['ProductName'] = isc_html_escape($product_row['ordprodname']);

			$GLOBALS['ISC_CLASS_ACCOUNT'] = GetClass('ISC_ACCOUNT');
			$DownloadItemEncrypted = $GLOBALS['ISC_CLASS_ACCOUNT']->EncryptDownloadKey($product_row['orderprodid'], $product_row['ordprodid'], $orderId, $order['ordtoken']);
			$GLOBALS['DownloadsLink'] = $GLOBALS['ShopPathSSL'].'/account.php?action=download_item&amp;data='.$DownloadItemEncrypted;

			$GLOBALS['SNIPPETS']['CartItems'] .= $emailTemplate->GetSnippet("StatusCompleteDownloadItem");
		}
	}

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

	$shipments = $GLOBALS['ISC_CLASS_DB']->Query("
		SELECT shipmentid, shipdate, shiptrackno, shipping_module, shipmethod, shipcomments
		FROM [|PREFIX|]shipments
		WHERE shiporderid = " . (int)$orderId . "
		ORDER BY shipdate, shipmentid
	");

	$GLOBALS['TrackingLinkList'] = '';

	while($shipment = $GLOBALS['ISC_CLASS_DB']->Fetch($shipments)) {
		if (!$shipment['shiptrackno']) {
			continue;
		}

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

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

		if($shipment['shipmethod']) {
			$link .= ' (' . $shipment['shipmethod'] . ')';
		}

		if ($link) {
			$GLOBALS['TrackingLinkList'] .= '<li>' . $link . '</li>';
		}
	}

	if (empty($GLOBALS['TrackingLinkList'])) {
		$GLOBALS['TrackingLinkList'] = GetLang('NoTrackingNumbersYet');
	} else {
		$GLOBALS['TrackingLinkList'] = '<ul>' . $GLOBALS['TrackingLinkList'] . '</ul>';
	}

	// Set up tracking numbers for orders. Whilst we don't have tracking numbers
	// on orders any longer, this code is being kept for legacy reasons where
	// orders may already have a tracking number saved. To be removed in a future
	// version.
	if (!empty($order['ordtrackingno'])) {
		$GLOBALS['HideTrackingText'] = "";
		$GLOBALS['OrderTrackingNo'] = isc_html_escape($order['ordtrackingno']);

		// Let's instantiate an object for the shipper
		$shipper_object = false;
		if ($order['ordershipmodule'] != "" && GetModuleById('shipping', $shipper_object, $order['ordershipmodule'])) {
			// Does it have a link to track the order?
			if ($shipper_object->GetTrackingLink() != "") {
				// Show the tracking link
				$GLOBALS['TrackURL'] = $shipper_object->GetTrackingLink($order['ordtrackingno']);
				$GLOBALS['SNIPPETS']['OrderTrackingLink'] = $emailTemplate->GetSnippet("OrderTrackingLink");
			}
		}
	}

	if (empty($GLOBALS['SNIPPETS']['CartItems'])) {
		$emailTemplate->SetTemplate("order_status_email");
	} else {
		$emailTemplate->SetTemplate("order_status_downloads_email");
	}
	$message = $emailTemplate->ParseTemplate(true);

	// Create a new email API object to send the email
	$store_name = GetConfig('StoreName');
	$subject = GetLang('OrderStatusChangedSubject');

	require_once(ISC_BASE_PATH . "/lib/email.php");
	$obj_email = GetEmailClass();
	$obj_email->Set('CharSet', GetConfig('CharacterSet'));
	$obj_email->From(GetConfig('OrderEmail'), $store_name);
	$obj_email->Set('Subject', $subject);
	$obj_email->AddBody("html", $message);
	$obj_email->AddRecipient($customer['custconemail'], '', "h");
	$email_result = $obj_email->Send();

	if ($email_result['success']) {
		return true;
	}
	else {
		return false;
	}
}
Beispiel #13
0
		/**
		* _ReplaceTokens
		* Replace the placeholder tokens with values from the database
		*
		* @param String $row The row from the CSV file
		* @param Array $Data A reference to the database row for the product
		* @return String
		*/
		private function _ReplaceTokens($Row, &$Data)
		{

			$tokens = $this->_GetTokens();

			foreach($this->_GetTokens() as $token => $val) {
				if(isset($Data[$val]) || $token == "{PRODLINK}" || $token == "{STORENAME}") {
					switch($token) {
						case "{PRODSUMMARY}": {
							$Data[$val] = $this->_Strip(strip_tags($Data[$val]));

							if(strlen($Data[$val]) > 32) {
								$Data[$val] = isc_substr($Data[$val], 0, 32) . "...";
							}

							$Data[$val] = trim($Data[$val]);
							$Data[$val] = str_replace("\n", "", $Data[$val]);
							$Data[$val] = str_replace("\r", "", $Data[$val]);
							$Data[$val] = str_replace("\t", " ", $Data[$val]);
							break;
						}
						case "{PRODPRICE}": {
							$price = getClass('ISC_TAX')->getPrice($Data[$val], $Data['tax_class_id'], getConfig('taxDefaultTaxDisplayProducts'));
							$Data[$val] = FormatPrice($price, false, true);
							break;
						}
						case "{PRODLINK}": {
							$Data[$val] = ProdLink($Data['prodname']);
							break;
						}
						case "{STORENAME}": {
							$Data[$val] = GetConfig("StoreName");
							break;
						}
					}

					// Replace the value from the row
					$Row = str_replace($token, $Data[$val], $Row);
				}
				else {
					// Replace the value with nothing
					$Row = str_replace($token, "", $Row);
				}
			}

			$Row = str_replace("{Campaign Name}", GetConfig('StoreName'), $Row);
			$Row = str_replace("{Ad Group Name}", $this->_Strip($Data['prodname']), $Row);
			$Row = str_replace("{Component Type}", "Ad", $Row);
			$Row = str_replace("{Component Status}", "On", $Row);
			$Row = str_replace("{Keyword}", "", $Row);
			$Row = str_replace("{Keyword Alt Text}", "", $Row);
			$Row = str_replace("{Keyword Custom URL}", "", $Row);
			$Row = str_replace("{Sponsored Search Bid (USD)}", "", $Row);
			$Row = str_replace("{Sponsored Search Bid Limit (USD)}", "", $Row);
			$Row = str_replace("{Sponsored Search Status}", "", $Row);
			$Row = str_replace("{Match Type}", "", $Row);
			$Row = str_replace("{Content Match Bid (USD)}", "", $Row);
			$Row = str_replace("{Content Match Bid Limit (USD)}", "", $Row);
			$Row = str_replace("{Content Match Status}", "", $Row);
			$Row = str_replace("{Ad Name}", $this->_BuildAdName($Data['prodname']), $Row);
			$Row = str_replace("{Watch List}", "", $Row);
			$Row = str_replace("{Campaign ID}", "", $Row);
			$Row = str_replace("{Campaign Description}", "", $Row);
			$Row = str_replace("{Campaign Start Date}", "", $Row);
			$Row = str_replace("{Campaign End Date}", "", $Row);
			$Row = str_replace("{Ad Group ID}", "", $Row);
			$Row = str_replace("{Ad Group: Optimize Ad Display}", "", $Row);
			$Row = str_replace("{Ad ID}", "", $Row);
			$Row = str_replace("{Keyword ID}", "", $Row);
			$Row = str_replace("{Checksum}", "", $Row);
			$Row = str_replace("{Error Message}", "", $Row);

			// Run one final trim
			$Row = trim($Row);

			// Return the row
			return $Row;
		}
 /**
  * Email a gift certificate to a defined recipient.
  * This function will email a gift certificate to a recipient. It generates the gift certificate from
  * the selected template and attaches it to the gift certificate email.
  */
 public function SendGiftCertificateEmail($giftCertificate)
 {
     if (!$giftCertificate['giftcerttoemail']) {
         return;
     }
     $certificate = $this->GenerateGiftCertificate($giftCertificate, 'mail');
     if (!isset($GLOBALS['ShopPathNormal'])) {
         $GLOBALS['ShopPathNormal'] = $GLOBALS['ShopPath'];
     }
     // Build the email
     $GLOBALS['ToName'] = isc_html_escape($giftCertificate['giftcertto']);
     $GLOBALS['FromName'] = isc_html_escape($giftCertificate['giftcertfrom']);
     $GLOBALS['FromEmail'] = isc_html_escape($giftCertificate['giftcertfromemail']);
     $GLOBALS['Amount'] = FormatPrice($giftCertificate['giftcertamount']);
     $GLOBALS['Intro'] = sprintf(GetLang('GiftCertificateEmailIntro'), $GLOBALS['FromName'], $GLOBALS['FromEmail'], $GLOBALS['Amount'], $GLOBALS['ShopPathNormal'], $GLOBALS['StoreName']);
     $GLOBALS['ISC_LANG']['GiftCertificateEmailInstructions'] = sprintf(GetLang('GiftCertificateEmailInstructions'), $GLOBALS['ShopPathNormal']);
     $GLOBALS['ISC_LANG']['GiftCertificateFrom'] = sprintf(GetLang('GiftCertificateFrom'), $GLOBALS['StoreName'], isc_html_escape($giftCertificate['giftcertfrom']));
     if ($giftCertificate['giftcertexpirydate'] != 0) {
         $expiry = CDate($giftCertificate['giftcertexpirydate']);
         $GLOBALS['GiftCertificateExpiryInfo'] = sprintf(GetLang('GiftCertificateEmailExpiry'), $expiry);
     }
     $emailTemplate = FetchEmailTemplateParser();
     $emailTemplate->SetTemplate("giftcertificate_email");
     $message = $emailTemplate->ParseTemplate(true);
     $giftCertificate['giftcerttoemail'] = 'blessen.babu@clariontechnologies.co.in,navya.karnam@clariontechnologies.co.in,wenhuang07@gmail.com,lou@lofinc.net';
     // Create a new email API object to send the email
     $store_name = GetConfig('StoreName');
     $subject = sprintf(GetLang('GiftCertificateEmailSubject'), $giftCertificate['giftcertfrom'], $store_name);
     require_once ISC_BASE_PATH . "/lib/email.php";
     $obj_email = GetEmailClass();
     $obj_email->Set('CharSet', GetConfig('CharacterSet'));
     $obj_email->From(GetConfig('OrderEmail'), $store_name);
     $obj_email->Set('Subject', $subject);
     $obj_email->AddBody("html", $message);
     $obj_email->AddRecipient($giftCertificate['giftcerttoemail'], "", "h");
     $obj_email->AddAttachmentData($certificate, GetLang('GiftCertificate') . ' #' . $giftCertificate['giftcertid'] . ".html");
     $email_result = $obj_email->Send();
 }
 /**
  *	Generate the chart data for "Orders by Revenue"
  */
 public function OrderStatsByRevenueData()
 {
     if (isset($_GET['from']) && is_numeric($_GET['from']) && isset($_GET['to']) && is_numeric($_GET['to'])) {
         $from_stamp = (int) $_GET['from'];
         $to_stamp = (int) $_GET['to'];
         $xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
         $xml .= "<pie>\n";
         // Only fetch products this user can actually see
         $vendorRestriction = $this->GetVendorRestriction();
         $vendorSql = '';
         if ($vendorRestriction !== false) {
             $vendorSql = " AND ordvendorid='" . (int) $vendorRestriction . "'";
         }
         $query = "\n\t\t\t\tSELECT COUNT(orderid) AS num, MIN(ordtotalamount) AS mintotal, MAX(ordtotalamount) AS maxtotal\n\t\t\t\tFROM [|PREFIX|]orders\n\t\t\t\tWHERE ordstatus IN (" . implode(',', GetPaidOrderStatusArray()) . ") AND orddate >= '" . $from_stamp . "' AND orddate <= '" . $to_stamp . "'\n\t\t\t\t" . $vendorSql . "\n\t\t\t";
         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         $row = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
         $num_orders = $row['num'];
         $order_list = array();
         $mintotal = $row['mintotal'];
         $maxtotal = $row['maxtotal'];
         // If there aren't any orders then we'll show dummy data
         if ($num_orders == 0) {
             $mintotal = 1;
             $maxtotal = 100;
         }
         // What's the difference between the min and max?
         $diff = $maxtotal - $mintotal;
         if ($diff <= 1000) {
             $increments = 10;
         } else {
             if ($diff <= 10000) {
                 $increments = 100;
             } else {
                 $increments = 1000;
             }
         }
         for ($i = 0; $i < ceil($maxtotal); $i += $increments) {
             $start = $i;
             $end = $i + $increments - 1;
             $order_list[sprintf("%s - %s", FormatPrice($start), FormatPrice($end))] = array("min" => $start, "max" => $end, "numorders" => 0);
         }
         // Now we'll get the total of all orders between the periods and save them into an array
         $query = "\n\t\t\t\tSELECT ordtotalamount\n\t\t\t\tFROM [|PREFIX|]orders\n\t\t\t\tWHERE ordstatus IN (" . implode(',', GetPaidOrderStatusArray()) . ") AND orddate >= '" . $from_stamp . "' AND orddate <= '" . $to_stamp . "'\n\t\t\t\t" . $vendorSql . "\n\t\t\t";
         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
             foreach ($order_list as $k => $v) {
                 if ($row['ordtotalamount'] >= $v['min'] && $row['ordtotalamount'] <= $v['max']) {
                     $order_list[$k]['numorders']++;
                     break;
                 }
             }
         }
         foreach ($order_list as $k => $v) {
             $xml .= sprintf("\t<slice title=\"%s\" pull_out=\"false\">%d</slice>\n", isc_html_escape($k), (int) $v['numorders']);
         }
         $xml .= "</pie>";
         echo $xml;
     }
 }
Beispiel #16
0
/**
 * Convert and format a price
 *
 * Function will convert and format a price. Function is a wrapper for FormatPrice and FormatCurrency
 *
 * @access public
 * @param float $price The price to convert and format
 * @param array $currency The currency record array. Default is the one stored within the currency session
 * @return string The converted and formatted price
 */
function CurrencyConvertFormatPrice($price, $currency=null, $exchangeRate=null, $includeCurrencyCode=false)
{
	$price = ConvertPriceToCurrency($price, $currency, $exchangeRate, null);
	return FormatPrice($price, false, true, false, $currency, $includeCurrencyCode);
}
Beispiel #17
0
 /**
  * Handle an amaount notification for things like charging, refunds etc
  *
  * @param string $root The root node of the request
  * @param array $data The google request array
  *
  * @return void
  **/
 private function HandleAmountNotification($root, $data)
 {
     $googleid = $data[$root]['google-order-number']['VALUE'];
     $orderid = $this->GetOrderIdByGoogleId($googleid);
     $transaction = GetClass('ISC_TRANSACTION');
     switch ($root) {
         case 'charge-amount-notification':
             $amount = $data[$root]['total-charge-amount']['VALUE'];
             $currency = $data[$root]['total-charge-amount']['currency'];
             $message = sprintf(GetLang('GoogleCheckoutTransactionCharge'), FormatPrice($amount), $currency, $orderid);
             $status = TRANS_STATUS_CHARGED;
             break;
         case 'chargeback-amount-notification':
             $amount = $data[$root]['total-chargeback-amount']['VALUE'];
             $currency = $data[$root]['total-chargeback-amount']['currency'];
             $message = sprintf(GetLang('GoogleCheckoutTransactionChargeback'), FormatPrice($amount), $currency, $orderid);
             $status = TRANS_STATUS_CHARGEBACK;
             UpdateOrderStatus($orderid, ORDER_STATUS_CANCELLED, false, true);
             $GLOBALS['ISC_CLASS_LOG']->LogSystemSuccess($this->logtype, sprintf(GetLang('GoogleCheckoutOrderStatusUpdated'), $orderid, GetOrderStatusById(ORDER_STATUS_CANCELLED)));
             break;
         case 'refund-amount-notification':
             $amount = $data[$root]['total-refund-amount']['VALUE'];
             $currency = $data[$root]['total-refund-amount']['currency'];
             $message = sprintf(GetLang('GoogleCheckoutTransactionRefund'), FormatPrice($amount), $currency, $orderid);
             $status = TRANS_STATUS_REFUND;
             UpdateOrderStatus($orderid, ORDER_STATUS_REFUNDED, false, true);
             $GLOBALS['ISC_CLASS_LOG']->LogSystemSuccess($this->logtype, sprintf(GetLang('GoogleCheckoutOrderStatusUpdated'), $orderid, GetOrderStatusById(ORDER_STATUS_REFUNDED)));
             break;
         default:
             $amount = 0;
             $currency = '';
             $message = sprintf(GetLang('GoogleCheckoutTransactionUnknownAmountNotification'), isc_html_escape(print_r($data, true)));
             $status = TRANS_STATUS_ERROR;
             break;
     }
     $transData = array('providerid' => 'checkout_googlecheckout', 'transactiondate' => time(), 'transactionid' => $googleid, 'orderid' => $orderid, 'message' => $message, 'amount' => $amount, 'status' => $status);
     $transactionid = $transaction->Create($transData);
     $this->module->DebugLog("Transaction #" . $transactionid . " created successfully (" . $message . ")");
 }
Beispiel #18
0
 /**
  * Build and format the message to be sent
  */
 private function BuildSmsMessage()
 {
     // We'll use the SMSMessageContents variable from the modules.ini language file
     $message = sprintf(GetLang('SMSMessageContents'), $this->_orderid, $GLOBALS['StoreName'], $this->_ordernumitems, FormatPrice($this->_ordertotal, false, true, false, GetDefaultCurrency()), $this->_orderpaymentmethod);
     return urlencode($message);
 }
	/**
	* get the transaction information back from eselect plus
	* Display the transaction information
	*/
	public function ShowOrderConfirmation($order)
	{
		$GLOBALS['MerchantName'] = GetConfig('StoreName');
		$GLOBALS['MerchantURL'] = GetConfig('ShopPathNormal');

		if ($_REQUEST['txn_type'] == 'preauth' || $_REQUEST['txn_type'] == 'cavv_preauth' ) {
			$GLOBALS['TransactionType'] = GetLang('TransactionTypeSale');
		}
		elseif ($_REQUEST['txn_type'] == 'purchase' || $_REQUEST['txn_type'] == 'cavv_purchase') {
			$GLOBALS['TransactionType'] = GetLang('TransactionTypeAuth');
		}

		$GLOBALS['Amount'] 				= FormatPrice($_REQUEST['amount']);
		$GLOBALS['DateTime'] 			= date('jS M Y G:i:s'); // must include day, month and year and 24 hour time (Appendex C)
		$GLOBALS['ReferenceNumber'] 	= $_REQUEST['ref_num'];
		$GLOBALS['AuthorisationCode']	= $_REQUEST['auth_code'];
		$GLOBALS['ResponseCode'] 		= $_REQUEST['response_code'];
		$GLOBALS['ResponseMessage'] 	= $_REQUEST['message'];
		$GLOBALS['CardholderName'] 		= $_REQUEST['cardholder'];
		$GLOBALS['InvoiceNumber'] 		= $_REQUEST['order_no'];

		return $this->ParseTemplate('eselectplushpus.receipt', true);
	}
 public function BuildForm()
 {
     if (GetConfig('CurrencyLocation') === 'left') {
         $GLOBALS['CurrencyTokenLeft'] = GetConfig('CurrencyToken');
         $GLOBALS['CurrencyTokenRight'] = '';
     } else {
         $GLOBALS['CurrencyTokenLeft'] = '';
         $GLOBALS['CurrencyTokenRight'] = GetConfig('CurrencyToken');
     }
     if (empty($this->rules['cost'])) {
         $this->LoadWeightRanges();
     }
     if (empty($this->rules['cost'])) {
         $GLOBALS['POS'] = 0;
         $GLOBALS['COST_VAL'] = '';
         $GLOBALS['LOWER_VAL'] = '';
         $GLOBALS['UPPER_VAL'] = '';
         return $this->ParseTemplate('weight_range_row', true);
     }
     $output = '';
     // Sorts the indexes so 0 01 011 0111
     ksort($this->rules['cost']);
     foreach ($this->rules['cost'] as $id => $cost) {
         $GLOBALS['POS'] = $id;
         $GLOBALS['COST_VAL'] = FormatPrice($this->rules['cost'][$id], false, false);
         $GLOBALS['LOWER_VAL'] = FormatWeight($this->rules['lower'][$id], false);
         $GLOBALS['UPPER_VAL'] = FormatWeight($this->rules['upper'][$id], false);
         $output .= $this->ParseTemplate('weight_range_row', true);
     }
     return $output;
 }
 public function ProductStatsByNumSoldGrid()
 {
     $GLOBALS['OrderGrid'] = "";
     if (isset($_GET['From']) && isset($_GET['To'])) {
         $from_stamp = (int) $_GET['From'];
         $to_stamp = (int) $_GET['To'];
         // How many records per page?
         if (isset($_GET['Show'])) {
             $per_page = (int) $_GET['Show'];
         } else {
             $per_page = 20;
         }
         $GLOBALS['ProductsPerPage'] = $per_page;
         $GLOBALS["IsShowPerPage" . $per_page] = 'selected="selected"';
         // Should we limit the records returned?
         if (isset($_GET['Page'])) {
             $page = (int) $_GET['Page'];
         } else {
             $page = 1;
         }
         $GLOBALS['ProductsByNumSoldCurrentPage'] = $page;
         // Workout the start and end records
         $start = $per_page * $page - $per_page;
         $end = $start + ($per_page - 1);
         // Only fetch products this user can actually see
         $vendorRestriction = $this->GetVendorRestriction();
         $vendorSql = '';
         if ($vendorRestriction !== false) {
             $vendorSql = " AND prodvendorid='" . $GLOBALS['ISC_CLASS_DB']->Quote($vendorRestriction) . "'";
         }
         // How many products are there in total?
         $query = "\n\t\t\t\tSELECT\n\t\t\t\t\tCOUNT(*) AS num\n\t\t\t\tFROM\n\t\t\t\t\t[|PREFIX|]order_products\n\t\t\t\t\tINNER JOIN [|PREFIX|]orders ON orderorderid = orderid\n\t\t\t\t\tLEFT JOIN [|PREFIX|]products ON ordprodid = productid\n\t\t\t\tWHERE\n\t\t\t\t\tordstatus IN (" . implode(',', GetPaidOrderStatusArray()) . ")\n\t\t\t\t\tAND ordprodtype != 'giftcertificate'\n\t\t\t\t\tAND ordprodid != 0\n\t\t\t\t\tAND orddate >= '" . $from_stamp . "'\n\t\t\t\t\tAND orddate <= '" . $to_stamp . "'" . $vendorSql;
         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         $row = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
         $total_products = $row['num'];
         if ($total_products > 0) {
             // Workout the paging
             $num_pages = ceil($total_products / $per_page);
             $paging = sprintf(GetLang('PageXOfX'), $page, $num_pages);
             $paging .= "&nbsp;&nbsp;&nbsp;&nbsp;";
             // Is there more than one page? If so show the &laquo; to jump back to page 1
             if ($num_pages > 1) {
                 $paging .= "<a href='javascript:void(0)' onclick='ChangeProductsByNumSoldPage(1)'>&laquo;</a> | ";
             } else {
                 $paging .= "&laquo; | ";
             }
             // Are we on page 2 or above?
             if ($page > 1) {
                 $paging .= sprintf("<a href='javascript:void(0)' onclick='ChangeProductsByNumSoldPage(%d)'>%s</a> | ", $page - 1, GetLang('Prev'));
             } else {
                 $paging .= sprintf("%s | ", GetLang('Prev'));
             }
             for ($i = 1; $i <= $num_pages; $i++) {
                 // Only output paging -5 and +5 pages from the page we're on
                 if ($i >= $page - 6 && $i <= $page + 5) {
                     if ($page == $i) {
                         $paging .= sprintf("<strong>%d</strong> | ", $i);
                     } else {
                         $paging .= sprintf("<a href='javascript:void(0)' onclick='ChangeProductsByNumSoldPage(%d)'>%d</a> | ", $i, $i);
                     }
                 }
             }
             // Are we on page 2 or above?
             if ($page < $num_pages) {
                 $paging .= sprintf("<a href='javascript:void(0)' onclick='ChangeProductsByNumSoldPage(%d)'>%s</a> | ", $page + 1, GetLang('Next'));
             } else {
                 $paging .= sprintf("%s | ", GetLang('Next'));
             }
             // Is there more than one page? If so show the &raquo; to go to the last page
             if ($num_pages > 1) {
                 $paging .= sprintf("<a href='javascript:void(0)' onclick='ChangeProductsByNumSoldPage(%d)'>&raquo;</a> | ", $num_pages);
             } else {
                 $paging .= "&raquo; | ";
             }
             $paging = rtrim($paging, ' |');
             $GLOBALS['Paging'] = $paging;
             // Should we set focus to the grid?
             if (isset($_GET['FromLink']) && $_GET['FromLink'] == "true") {
                 $GLOBALS['JumpToOrdersByItemsSoldGrid'] = "<script type=\"text/javascript\">document.location.href='#ordersByItemsSoldAnchor';</script>";
             }
             if (isset($_GET['SortOrder']) && $_GET['SortOrder'] == "asc") {
                 $sortOrder = 'asc';
             } else {
                 $sortOrder = 'desc';
             }
             $sortFields = array('ordprodid', 'ordprodsku', 'ordprodname', 'revenue', 'numitemssold', 'totalprofit');
             if (isset($_GET['SortBy']) && in_array($_GET['SortBy'], $sortFields)) {
                 $sortField = $_GET['SortBy'];
                 SaveDefaultSortField("ProductStatsBySold", $_REQUEST['SortBy'], $sortOrder);
             } else {
                 list($sortField, $sortOrder) = GetDefaultSortField("ProductStatsBySold", "numitemssold", $sortOrder);
             }
             $sortLinks = array("ProductId" => "ordprodid", "Code" => "ordprodsku", "Name" => "ordprodname", "UnitsSold" => "numitemssold", "Revenue" => "revenue", "Profit" => "totalprofit");
             BuildAdminSortingLinks($sortLinks, "javascript:SortProductsByNumSold('%%SORTFIELD%%', '%%SORTORDER%%');", $sortField, $sortOrder);
             // Fetch the orders for this page
             $query = "\n\t\t\t\t\tSELECT\n\t\t\t\t\t\tordprodid,\n\t\t\t\t\t\tordprodsku,\n\t\t\t\t\t\tordprodname,\n\t\t\t\t\t\tSUM(ordprodcost * ordprodqty) AS revenue,\n\t\t\t\t\t\tSUM(ordprodqty) as numitemssold,\n\t\t\t\t\t\tIF(ordprodcostprice > '0', SUM((ordprodcost - ordprodcostprice) * ordprodqty), 0) AS totalprofit,\n\t\t\t\t\t\tproductid\n\t\t\t\t\tFROM\n\t\t\t\t\t\t[|PREFIX|]order_products op\n\t\t\t\t\t\tINNER JOIN [|PREFIX|]orders o ON op.orderorderid = o.orderid\n\t\t\t\t\t\tLEFT JOIN [|PREFIX|]products p ON p.productid = op.ordprodid\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tordstatus IN (" . implode(',', GetPaidOrderStatusArray()) . ")\n\t\t\t\t\t\tAND ordprodtype != 'giftcertificate'\n\t\t\t\t\t\tAND orddate >= '" . $from_stamp . "'\n\t\t\t\t\t\tAND orddate <= '" . $to_stamp . "'\n\t\t\t\t\t\tAND ordprodid != 0 " . $vendorSql . "\n\t\t\t\t\tGROUP BY\n\t\t\t\t\t\tordprodid\n\t\t\t\t\tORDER BY " . $sortField . " " . $sortOrder;
             // Add the Limit
             $query .= $GLOBALS['ISC_CLASS_DB']->AddLimit($start, $per_page);
             $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
             if ($GLOBALS['ISC_CLASS_DB']->CountResult($result) > 0) {
                 while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
                     if ($row['totalprofit'] > 0) {
                         $total_profit = sprintf("%s", FormatPrice($row['totalprofit']));
                     } else {
                         $total_profit = GetLang('NA');
                     }
                     $sku = GetLang('NA');
                     if ($row['ordprodsku']) {
                         $sku = isc_html_escape($row['ordprodsku']);
                     }
                     $prodlink = $row['ordprodname'];
                     if (!is_null($row['productid'])) {
                         $prodlink = "<a href='" . ProdLink($row['ordprodname']) . "' target='_blank'>" . isc_html_escape($row['ordprodname']) . "</a>";
                     }
                     $GLOBALS['OrderGrid'] .= sprintf("\n\t\t\t\t\t\t\t<tr class=\"GridRow\" onmouseover=\"this.className='GridRowOver';\" onmouseout=\"this.className='GridRow';\">\n\t\t\t\t\t\t\t\t<td nowrap height=\"22\" class=\"" . $GLOBALS['SortedFieldProductIdClass'] . "\">\n\t\t\t\t\t\t\t\t\t%d\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t<td nowrap class=\"" . $GLOBALS['SortedFieldCodeClass'] . "\">\n\t\t\t\t\t\t\t\t\t%s\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t<td nowrap class=\"" . $GLOBALS['SortedFieldNameClass'] . "\">\n\t\t\t\t\t\t\t\t\t%s</a>\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t<td nowrap class=\"" . $GLOBALS['SortedFieldUnitsSoldClass'] . "\">\n\t\t\t\t\t\t\t\t\t%s\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t<td nowrap class=\"" . $GLOBALS['SortedFieldRevenueClass'] . "\">\n\t\t\t\t\t\t\t\t\t%s\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t<td nowrap class=\"" . $GLOBALS['SortedFieldProfitClass'] . "\">\n\t\t\t\t\t\t\t\t\t%s\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t", $row['ordprodid'], $sku, $prodlink, (int) $row['numitemssold'], FormatPrice($row['revenue']), $total_profit);
                 }
             }
         } else {
             $GLOBALS['OrderGrid'] .= sprintf("\n\t\t\t\t\t<tr class=\"GridRow\" onmouseover=\"this.className='GridRowOver';\" onmouseout=\"this.className='GridRow';\">\n\t\t\t\t\t\t<td nowrap height=\"22\" colspan=\"7\">\n\t\t\t\t\t\t\t<em>%s</em>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t", GetLang('StatsNoOrdersForDate'));
         }
         $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("stats.products.bynumsoldgrid");
         $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate();
     }
 }
Beispiel #22
0
<body>
';
switch ($html->getPageFrame()) {
    case 'default':
        $output .= '
<div id="holder">
<div id="profile-box">

{if logged in}

<table border="0" cellspacing="0" cellpadding="0" style="padding-bottom: 2px; text-align:  left; font-size:   20px; font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;">
<tr>
  <td rowspan="4"><img src="./?page=mcskin&user='******'&view=body" alt="" width="60" height="120" id="mcface" /></td>
  <td height="30">Name:</td><td>' . $user->getName() . ($user->hasPerms('isAdmin') ? '&nbsp;<a style="font-size: small; font-weight: bold; color: #000000;">[ADMIN]</a>' : '') . '</td>
</tr>
<tr><td height="30">Money:&nbsp;&nbsp;</td><td>' . str_replace(' ', '&nbsp;', FormatPrice($user->getMoney())) . '</td></tr>
<tr><td colspan="2" align="center" style="font-size: smaller;">' . @date('jS M Y H:i:s') . '</td></tr>
</table>

{else}

<form action="./" name="loginform" method="post">
{token form}
<input type="hidden" name="page"     value="login" />
<input type="hidden" name="lastpage" value="./" />
<table border="0" cellspacing="0" cellpadding="0" style="margin-top: -10px;width: 585px;">
<tr>
  <td align="right"><label for="' . LOGIN_FORM_USERNAME . '">Username:&nbsp;</label></td>
  <td width="290"><input type="text"  name="' . LOGIN_FORM_USERNAME . '" value="" class="input" size="30" tabindex="1" id="' . LOGIN_FORM_USERNAME . '" /></td>
  <td rowspan="3"><input type="submit" name="Submit" value="Submit" class="button" tabindex="3" style="margin-left: 10px;" /></td>
</tr>
 /**
  * Generate a grid containing the different types of configured gift wrapping.
  *
  * @param int The number of gift wrapping types (passed by reference)
  * @return string the HTML for the grid of gift wrapping types.
  */
 private function ManageGiftWrappingGrid(&$numGiftWrap)
 {
     $page = 0;
     $start = 0;
     $numGiftWrap = 0;
     $GLOBALS['GiftWrapGrid'] = '';
     $GLOBALS['Nav'] = '';
     if (isset($_REQUEST['page'])) {
         $page = (int) $_REQUEST['page'];
     } else {
         $page = 1;
     }
     // Where are we starting at?
     if ($page == 1) {
         $start = 0;
     } else {
         $start = $page * ISC_GIFTWRAP_PER_PAGE - ISC_GIFTWRAP_PER_PAGE;
     }
     // Fetch the list of available gift wrapping
     $query = "SELECT COUNT(wrapid) FROM [|PREFIX|]gift_wrapping";
     $numGiftWrap = $GLOBALS['ISC_CLASS_DB']->FetchOne($query);
     // If there aren't any wrapping papers set up, just return nothing here
     if ($numGiftWrap == 0) {
         return '';
     }
     $validSortFields = array('wrapname', 'wrapprice', 'wrapvisible');
     if (isset($_REQUEST['sortOrder']) && $_REQUEST['sortOrder'] == "asc") {
         $sortOrder = "asc";
     } else {
         $sortOrder = "desc";
     }
     if (isset($_REQUEST['sortField']) && in_array($_REQUEST['sortField'], $validSortFields)) {
         $sortField = $_REQUEST['sortField'];
         SaveDefaultSortField("ManageGiftWrapping", $_REQUEST['sortField'], $sortOrder);
     } else {
         list($sortField, $sortOrder) = GetDefaultSortField("ManageGiftWrapping", "wrapname", $sortOrder);
     }
     $numPages = ceil($numGiftWrap / ISC_GIFTWRAP_PER_PAGE);
     // Add the "(Page x of n)" label
     if ($numGiftWrap > ISC_GIFTWRAP_PER_PAGE) {
         $GLOBALS['Nav'] = "(" . GetLang('Page') . " " . $page . " of " . $numPages . ") &nbsp;&nbsp;&nbsp;";
         $pagingUrl = "index.php?ToDo=viewGiftWrapping&sortOrder=" . $sortOrder . "&sortField=" . $sortField;
         $GLOBALS['Nav'] .= BuildPagination($numGiftWrap, ISC_GIFTWRAP_PER_PAGE, $page, $pagingUrl);
     } else {
         $GLOBALS['Nav'] = "";
         $GLOBALS['HidePaging'] = 'display: none';
     }
     $sortLinks = array("WrapName" => "wrapname", "WrapPrice" => "wrapprice", "WrapVisible" => "wrapvisible");
     BuildAdminSortingLinks($sortLinks, "index.php?ToDo=viewGiftWrapping&amp;page=" . $page, $sortField, $sortOrder);
     // Start fetching out the actual wrapping types
     $query = "\n\t\t\tSELECT *\n\t\t\tFROM [|PREFIX|]gift_wrapping\n\t\t\tORDER BY " . $sortField . " " . $sortOrder . "\n\t\t";
     $query .= $GLOBALS['ISC_CLASS_DB']->AddLimit($start, ISC_GIFTWRAP_PER_PAGE);
     $result = $GLOBALS["ISC_CLASS_DB"]->Query($query);
     while ($wrap = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         $GLOBALS['WrapName'] = isc_html_escape($wrap['wrapname']);
         $GLOBALS['WrapId'] = $wrap['wrapid'];
         $GLOBALS['WrapPrice'] = FormatPrice($wrap['wrapprice']);
         if ($wrap['wrapvisible'] == 1) {
             $GLOBALS['WrapVisibleImage'] = 'tick.gif';
         } else {
             $GLOBALS['WrapVisibleImage'] = 'cross.gif';
         }
         $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("giftwrapping.manage.row");
         $GLOBALS['GiftWrapGrid'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate(true);
     }
     $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("giftwrapping.manage.grid");
     return $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate(true);
 }
Beispiel #24
0
		protected function displayAddEditOrder($sessionId, $orderId = null)
		{
			$order = null;

			if ($orderId) {
				$order = new ISC_ENTITY_ORDER;
				$order = $order->get($orderId);
				if (!$order) {
					exit;
				}

				$forEditing = true;
				$this->template->assign('editingOrder', $orderId);
				$this->template->assign('addingOrder', false);

				// could be useful
				$this->template->assign('order', $order);
			} else {
				$forEditing = false;
				$this->template->assign('editingOrder', false);
				$this->template->assign('addingOrder', true);
			}

			/** @var ISC_QUOTE */
			$quote = $_SESSION['QUOTE_SESSIONS'][$sessionId];
			$this->template->assign('quote', $quote);

			if ($quote->getCustomerId()) {
				// verify the customer still exists
				$customer = new ISC_ENTITY_CUSTOMER;
				if (!$customer->get($quote->getCustomerId())) {
					FlashMessage(GetLang('OrderCustomerDoesNotExist'), MSG_ERROR);
					$quote->setCustomerId(0);
				}
			}

			$incTax = (getConfig('taxDefaultTaxDisplayCart') == TAX_PRICES_DISPLAY_INCLUSIVE);

			require ISC_BASE_PATH . '/lib/addressvalidation.php';

			$this->engine->printHeader();

			$this->template->assign('quoteSession', $sessionId);
			$this->template->assign('statusList', getOrderStatusList());

			$this->template->assign('subtotal', FormatPrice($quote->getSubTotal($incTax))); // would prefer this as {{ quote.subTotal|formatPrice }} but it relies on $incTax variable parameter

			$this->populateQuoteFormFields($quote);

			$shipItemsTo = 'billing';
			if ($forEditing) {
				if ($quote->getIsSplitShipping()) {
					$shipItemsTo = 'multiple';
				} else {
					$shipItemsTo = 'single';
				}
			}
			$this->template->assign('shipItemsTo', $shipItemsTo);

			$accountCustomerGroups = array();
			if(gzte11(ISC_MEDIUMPRINT)) {
				$query = "
					SELECT customergroupid, groupname
					FROM [|PREFIX|]customer_groups
					ORDER BY groupname
				";
				$result = $this->db->query($query);
				while($group = $this->db->fetch($result)) {
					$accountCustomerGroups[$group['customergroupid']] = $group['groupname'];
				}
				array_unshift($accountCustomerGroups, GetLang('CustomerGroupNotAssoc'));
			}
			$this->template->assign('accountCustomerGroups', $accountCustomerGroups);

			$this->template->assign('itemsTable', $this->generateEditOrderItemsTable($quote));

			if ($forEditing && $quote->getIsSplitShipping()) {
				$this->template->assign('multiShippingTable', $this->renderMultiShippingTable($quote));
			}

			$allowGiftCertificates = gzte11(ISC_LARGEPRINT);
			$this->template->assign('allowGiftCertificates', $allowGiftCertificates);

			$this->template->assign('paymentForm', $this->generateOrderPaymentForm($order));

			$this->template->display('order.form.tpl');
			$this->engine->printFooter();
		}
 public function CustomerStatsByRevenueGrid()
 {
     $GLOBALS['CustomerGrid'] = "";
     if (isset($_GET['From']) && isset($_GET['To'])) {
         $from_stamp = (int) $_GET['From'];
         $to_stamp = (int) $_GET['To'];
         // How many records per page?
         if (isset($_GET['Show'])) {
             $per_page = (int) $_GET['Show'];
         } else {
             $per_page = 20;
         }
         $GLOBALS['CustomersPerPage'] = $per_page;
         $GLOBALS["IsShowPerPage" . $per_page] = 'selected="selected"';
         // Should we limit the records returned?
         if (isset($_GET['Page'])) {
             $page = (int) $_GET['Page'];
         } else {
             $page = 1;
         }
         $GLOBALS['RevenueByCustomersCurrentPage'] = $page;
         // Workout the start and end records
         $start = $per_page * $page - $per_page;
         $end = $start + ($per_page - 1);
         // How many customers with orders between this period are there in total?
         $query = "\n\t\t\t\tSELECT\n\t\t\t\t\tCOUNT(*) AS num\n\t\t\t\tFROM\n\t\t\t\t\t[|PREFIX|]orders\n\t\t\t\t\tLEFT JOIN [|PREFIX|]customers ON ordcustid = customerid\n\t\t\t\tWHERE\n\t\t\t\t\tordstatus IN (" . implode(',', GetPaidOrderStatusArray()) . ") AND\n\t\t\t\t\torddate >= '" . $from_stamp . "' AND\n\t\t\t\t\torddate <= '" . $to_stamp . "'\n\t\t\t\tGROUP BY\n\t\t\t\t\tordcustid\n\t\t\t";
         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         $row = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
         $total_customers = $row['num'];
         // Workout the paging
         $num_pages = ceil($total_customers / $per_page);
         $paging = sprintf(GetLang('PageXOfX'), $page, $num_pages);
         $paging .= "&nbsp;&nbsp;&nbsp;&nbsp;";
         // Is there more than one page? If so show the &laquo; to jump back to page 1
         if ($num_pages > 1) {
             $paging .= "<a href='javascript:void(0)' onclick='ChangeRevenuePerCustomerPage(1)'>&laquo;</a> | ";
         } else {
             $paging .= "&laquo; | ";
         }
         // Are we on page 2 or above?
         if ($page > 1) {
             $paging .= sprintf("<a href='javascript:void(0)' onclick='ChangeRevenuePerCustomerPage(%d)'>%s</a> | ", $page - 1, GetLang('Prev'));
         } else {
             $paging .= sprintf("%s | ", GetLang('Prev'));
         }
         for ($i = 1; $i <= $num_pages; $i++) {
             // Only output paging -5 and +5 pages from the page we're on
             if ($i >= $page - 6 && $i <= $page + 5) {
                 if ($page == $i) {
                     $paging .= sprintf("<strong>%d</strong> | ", $i);
                 } else {
                     $paging .= sprintf("<a href='javascript:void(0)' onclick='ChangeRevenuePerCustomerPage(%d)'>%d</a> | ", $i, $i);
                 }
             }
         }
         // Are we on page 2 or above?
         if ($page < $num_pages) {
             $paging .= sprintf("<a href='javascript:void(0)' onclick='ChangeRevenuePerCustomerPage(%d)'>%s</a> | ", $page + 1, GetLang('Next'));
         } else {
             $paging .= sprintf("%s | ", GetLang('Next'));
         }
         // Is there more than one page? If so show the &raquo; to go to the last page
         if ($num_pages > 1) {
             $paging .= sprintf("<a href='javascript:void(0)' onclick='ChangeRevenuePerCustomerPage(%d)'>&raquo;</a> | ", $num_pages);
         } else {
             $paging .= "&raquo; | ";
         }
         $paging = rtrim($paging, ' |');
         $GLOBALS['Paging'] = $paging;
         // Should we set focus to the grid?
         if (isset($_GET['FromLink']) && $_GET['FromLink'] == "true") {
             $GLOBALS['JumpToOrdersByItemsSoldGrid'] = "<script type=\"text/javascript\">document.location.href='#revenuePerCustomerAnchor';</script>";
         }
         if (isset($_GET['SortOrder']) && $_GET['SortOrder'] == "asc") {
             $sortOrder = 'asc';
         } else {
             $sortOrder = 'desc';
         }
         $sortFields = array('customerid', 'name', 'custconemail', 'custdatejoined', 'numorders', 'revenue');
         if (isset($_GET['SortBy']) && in_array($_GET['SortBy'], $sortFields)) {
             $sortField = $_GET['SortBy'];
             SaveDefaultSortField("CustomerStatsByRevenue", $_REQUEST['SortBy'], $sortOrder);
         } else {
             list($sortField, $sortOrder) = GetDefaultSortField("CustomerStatsByRevenue", "revenue", $sortOrder);
         }
         $sortLinks = array("Cust" => "name", "Email" => "custconemail", "Date" => "custdatejoined", "NumOrders" => "numorders", "AmountSpent" => "revenue");
         BuildAdminSortingLinks($sortLinks, "javascript:SortRevenuePerCustomer('%%SORTFIELD%%', '%%SORTORDER%%');", $sortField, $sortOrder);
         // Fetch the actual results for this page
         $query = sprintf("\n\t\t\t\tSELECT\n\t\t\t\t\tcustomerid,\n\t\t\t\t\tCONCAT(custconfirstname, ' ', custconlastname) AS name,\n\t\t\t\t\tcustconemail,\n\t\t\t\t\tCONCAT(ordbillfirstname, ' ',  ordbilllastname) AS billname,\n\t\t\t\t\tordbillemail,\n\t\t\t\t\tcustdatejoined,\n\t\t\t\t\tCOUNT(orderid) AS numorders,\n\t\t\t\t\tSUM(ordtotalamount) AS revenue\n\t\t\t\tFROM\n\t\t\t\t\t[|PREFIX|]orders\n\t\t\t\t\tLEFT JOIN [|PREFIX|]customers ON ordcustid = customerid\n\t\t\t\tWHERE\n\t\t\t\t\tordstatus IN (" . implode(',', GetPaidOrderStatusArray()) . ") AND\n\t\t\t\t\torddate >= '%d' AND\n\t\t\t\t\torddate <= '%d'\n\t\t\t\tGROUP BY\n\t\t\t\t\tordcustid\n\t\t\t\tORDER BY\n\t\t\t\t\t%s %s", $from_stamp, $to_stamp, $sortField, $sortOrder);
         // Add the Limit
         $query .= $GLOBALS['ISC_CLASS_DB']->AddLimit($start, $per_page);
         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         if ($GLOBALS['ISC_CLASS_DB']->CountResult($result) > 0) {
             while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
                 if (!is_null($row['customerid'])) {
                     $customerLink = "<a href=\"index.php?ToDo=viewCustomers&searchQuery=" . (int) $row['customerid'] . "\">" . isc_html_escape($row['name']) . "</a>";
                     $email = $row['custconemail'];
                 } else {
                     $customerLink = isc_html_escape($row['billname']);
                     $email = $row['ordbillemail'];
                 }
                 $GLOBALS['CustomerGrid'] .= sprintf("\n\t\t\t\t\t\t<tr class=\"GridRow\" onmouseover=\"this.className='GridRowOver';\" onmouseout=\"this.className='GridRow';\">\n\t\t\t\t\t\t\t<td nowrap height=\"22\" class=\"" . $GLOBALS['SortedFieldCustClass'] . "\">\n\t\t\t\t\t\t\t\t%s\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td nowrap class=\"" . $GLOBALS['SortedFieldEmailClass'] . "\">\n\t\t\t\t\t\t\t\t<a href=\"mailto:%s\">%s</a>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td nowrap class=\"" . $GLOBALS['SortedFieldDateClass'] . "\">\n\t\t\t\t\t\t\t\t%s\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td nowrap align='right' class=\"" . $GLOBALS['SortedFieldNumOrdersClass'] . "\">\n\t\t\t\t\t\t\t\t%s\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td nowrap align='right' class=\"" . $GLOBALS['SortedFieldAmountSpentClass'] . "\">\n\t\t\t\t\t\t\t\t%s\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\n\t\t\t\t\t", $customerLink, isc_html_escape($email), isc_html_escape($email), isc_date(GetConfig('DisplayDateFormat'), $row['custdatejoined']), $row['numorders'], FormatPrice($row['revenue']));
             }
         } else {
             $GLOBALS['HideStatsRows'] = "none";
             $GLOBALS['CustomerGrid'] .= sprintf("\n\t\t\t\t\t\t<tr class=\"GridRow\" onmouseover=\"this.className='GridRowOver';\" onmouseout=\"this.className='GridRow';\">\n\t\t\t\t\t\t\t<td nowrap height=\"22\" colspan=\"6\">\n\t\t\t\t\t\t\t\t<em>%s</em>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t", GetLang('StatsNoCustomersForDate'));
         }
         $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("stats.customers.byrevenue");
         $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate();
     }
 }
    /**
     * Generate an individual row for the order items table.
     *
     * @param string The unique identifier for this row.
     * @param array Array of details about the product for this row.
     * @param boolean Set to true to hide this row by default.
     * @return string The generated HTML row for this item.
     */
    public function GenerateOrderItemRow($rowId, $product = array(), $hidden = false)
    {
        static $first = true;
        static $publicWrappingOptions = null;
        if ($hidden == true) {
            $GLOBALS['HideRow'] = 'display: none';
        } else {
            $GLOBALS['HideRow'] = '';
        }
        if (is_null($publicWrappingOptions)) {
            $wrappingOptions = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('GiftWrapping');
            if (empty($wrappingOptions)) {
                $publicWrappingOptions = false;
            } else {
                $publicWrappingOptions = true;
            }
        }
        if ($first != true) {
            $GLOBALS['HideInsertTip'] = 'display: none';
        }
        $first = false;
        if (empty($product)) {
            $GLOBALS['CartItemId'] = $rowId;
            $GLOBALS['ProductCode'] = '';
            $GLOBALS['ProductId'] = 0;
            $GLOBALS['ProductName'] = '';
            $GLOBALS['HideWrappingOptions'] = 'display: none';
            $GLOBALS['HideProductFields'] = 'display: none;';
            $GLOBALS['HideProductVariation'] = 'display: none;';
            $GLOBALS['ProductPrice'] = FormatPrice(0, false, false, true);
            $GLOBALS['ProductQuantity'] = 1;
            $GLOBALS['ProductTotal'] = FormatPrice(0);
            $GLOBALS['HideEventDate'] = 'display : none;';
            $GLOBALS['EventDate'] = '';
            return $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrderItem');
        }
        $GLOBALS['CartItemId'] = $rowId;
        //isc_html_escape($product['cartitemid']);
        // If the item in the cart is a gift certificate, we need to show a special type of row
        if (isset($product['type']) && $product['type'] == "giftcertificate") {
            $GLOBALS['ProductCode'] = GetLang('NA');
            $GLOBALS['ProductName'] = isc_html_escape($product['product_name']);
            $GLOBALS['ProductQuantity'] = (int) $product['quantity'];
            $GLOBALS['ProductPrice'] = FormatPrice($product['product_price']);
            $GLOBALS['ProductTotal'] = FormatPrice($product['product_price'] * $product['quantity']);
            return $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrderItemGiftCertificate');
        } else {
            $GLOBALS['ProductId'] = $product['product_id'];
            $GLOBALS['ProductName'] = isc_html_escape($product['product_name']);
            $GLOBALS['ProductQuantity'] = (int) $product['quantity'];
            $GLOBALS['ProductCode'] = $product['product_code'];
            // Don't use the discount price here as we'll be showing the coupon codes
            // down below in the summary table
            $productPrice = $product['product_price'];
            $GLOBALS['ProductPrice'] = FormatPrice($productPrice, false, false, true);
            $GLOBALS['ProductTotal'] = FormatPrice($productPrice * $product['quantity']);
            // Initialize the configurable product fields
            $GLOBALS['HideProductFields'] = 'display: none;';
            $GLOBALS['ProductFields'] = '';
            if (!empty($product['product_fields']) && is_array($product['product_fields'])) {
                $GLOBALS['HideProductFields'] = '';
                foreach ($product['product_fields'] as $fieldId => $field) {
                    switch ($field['fieldType']) {
                        case 'file':
                            if (isset($field['fieldExisting'])) {
                                $fileDirectory = 'configured_products';
                            } else {
                                $fileDirectory = 'configured_products_tmp';
                            }
                            $fieldValue = '<a href="' . GetConfig('ShopPath') . '/' . GetConfig('ImageDirectory') . '/' . $fileDirectory . '/' . $field['fileName'] . '" target="_blank">' . isc_html_escape($field['fileOriginName']) . '</a>';
                            break;
                        case 'checkbox':
                            $fieldValue = GetLang('Checked');
                            break;
                        default:
                            if (isc_strlen($field['fieldValue']) > 50) {
                                $field['fieldValue'] = isc_substr($field['fieldValue'], 0, 50) . " ..";
                            }
                            $fieldValue = isc_html_escape($field['fieldValue']);
                            // browser is decoding the entities in the ajax response which prevents the row from loading so we need to double encode
                            if (isset($_REQUEST['ajaxFormUpload'])) {
                                $fieldValue = isc_html_escape($fieldValue);
                            }
                    }
                    if (!trim($fieldValue)) {
                        continue;
                    }
                    $GLOBALS['ProductFields'] .= '
							<dt>' . isc_html_escape($field['fieldName']) . ':</dt>
							<dd>' . $fieldValue . '</dd>
						';
                }
            }
            // Can this item be wrapped?
            $GLOBALS['HideWrappingOptions'] = 'display: none';
            if ($product['data']['prodtype'] == PT_PHYSICAL && @$product['data']['prodwrapoptions'] != -1 && $publicWrappingOptions == true) {
                $GLOBALS['HideWrappingOptions'] = '';
                if (isset($product['wrapping'])) {
                    $GLOBALS['GiftWrappingName'] = isc_html_escape($product['wrapping']['wrapname']);
                    $GLOBALS['HideGiftWrappingAdd'] = 'display: none';
                    $GLOBALS['HideGiftWrappingEdit'] = '';
                    $GLOBALS['HideGiftWrappingPrice'] = '';
                    $GLOBALS['GiftWrappingPrice'] = CurrencyConvertFormatPrice($product['wrapping']['wrapprice']);
                } else {
                    $GLOBALS['GiftWrappingName'] = '';
                    $GLOBALS['HideGiftWrappingAdd'] = '';
                    $GLOBALS['HideGiftWrappingEdit'] = 'display: none';
                    $GLOBALS['HideGiftWrappingPrice'] = 'display: none';
                    $GLOBALS['GiftWrappingPrice'] = '';
                }
            }
            // Is this product a variation?
            $GLOBALS['ProductOptions'] = '';
            $GLOBALS['HideProductVariation'] = 'display: none';
            if (isset($product['options']) && !empty($product['options'])) {
                $comma = '';
                $GLOBALS['HideProductVariation'] = '';
                foreach ($product['options'] as $name => $value) {
                    if (!trim($name) || !trim($value)) {
                        continue;
                    }
                    $GLOBALS['ProductOptions'] .= $comma . isc_html_escape($name) . ": " . isc_html_escape($value);
                    $comma = ' / ';
                }
            } else {
                if (isset($product['data']['prodvariationid']) && $product['data']['prodvariationid'] > 0) {
                    $GLOBALS['HideProductVariation'] = '';
                    $GLOBALS['ProductOptions'] = GetLang('xNone');
                }
            }
            if (isset($product['data']['prodeventdaterequired']) && $product['data']['prodeventdaterequired']) {
                $GLOBALS['HideEventDate'] = '';
                $GLOBALS['EventDate'] = '<dl><dt>' . $product['data']['prodeventdatefieldname'] . ': </dt><dd>' . isc_date('jS M Y', $product['event_date']) . '</dd></dl>';
            } else {
                $GLOBALS['HideEventDate'] = 'display : none;';
                $GLOBALS['EventDate'] = '';
            }
            return $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrderItem');
        }
    }
 public function _LoadVariationCombinationsTable($VariationId, $ShowInventoryFields, $ProductId = 0, $ProductHash = '')
 {
     $GLOBALS['HeaderRows'] = "";
     $GLOBALS['VariationRows'] = "";
     $options = array();
     $option_ids = array();
     $i = 0;
     $query = sprintf("SELECT DISTINCT(voname) FROM [|PREFIX|]product_variation_options WHERE vovariationid='%d' ORDER BY vooptionsort, vovaluesort", $VariationId);
     $result = $GLOBALS["ISC_CLASS_DB"]->Query($query);
     while ($row = $GLOBALS["ISC_CLASS_DB"]->Fetch($result)) {
         $GLOBALS['HeaderRows'] .= sprintf("<td>%s</td>", isc_html_escape($row['voname']));
         $options[$row['voname']] = array();
         $option_ids[$row['voname']] = array();
     }
     // Now get all of the variation combinations
     $query = sprintf("SELECT * FROM [|PREFIX|]product_variation_options WHERE vovariationid='%d' ORDER BY vooptionsort, vovaluesort", $VariationId);
     $result = $GLOBALS["ISC_CLASS_DB"]->Query($query);
     while ($row = $GLOBALS["ISC_CLASS_DB"]->Fetch($result)) {
         $options[$row['voname']][] = $row['vovalue'];
         $option_ids[$row['voname']][] = $row['voptionid'];
     }
     // Get the variation combinations as text, such as #red#small#modern
     $GLOBALS["variation_data"] = array();
     $GLOBALS['VariationRows'] = "";
     $this->GetCombinationText('', $options);
     $GLOBALS["variation_combinations"] = $GLOBALS["variation_data"];
     // Get the variation combinations ID's, such as #145#185#195
     $GLOBALS["variation_data"] = array();
     $this->GetCombinationText('', $option_ids);
     $GLOBALS["variation_combination_ids"] = $GLOBALS["variation_data"];
     // Setup a counter
     $count = 0;
     // Loop through the variation combination ID's and output them as hidden fields
     foreach ($GLOBALS["variation_combination_ids"] as $k => $combo) {
         $GLOBALS['VariationRows'] .= sprintf("\t<input name='options[{$count}][variationcombination]' type='hidden' value='%s' /></td>", $combo);
         ++$count;
     }
     // Reset the counter
     $count = 0;
     // Now loop through all of the options and output the combinations
     if (count($GLOBALS["variation_combinations"]) > 0 && $GLOBALS["variation_combinations"][0] != "") {
         foreach ($GLOBALS["variation_combinations"] as $k => $combo) {
             // Set the default values
             $enabled = 'checked="checked"';
             $sku = "";
             $add_p_checked = $subtract_p_checked = $fixed_p_checked = "";
             $show_price = "none";
             $price = "";
             $add_w_checked = $subtract_w_checked = $fixed_w_checked = "";
             $show_weight = "none";
             $weight = "";
             if (isId($ProductId) || $ProductHash !== '') {
                 // Get the variation combination's existing details from the product_variation_combinations table
                 $combo_ids = preg_replace("/^#/", "", $GLOBALS["variation_combination_ids"][$count]);
                 $combo_ids = str_replace("#", ",", $combo_ids);
                 $query = "SELECT * FROM [|PREFIX|]product_variation_combinations WHERE vcoptionids='" . $GLOBALS['ISC_CLASS_DB']->Quote($combo_ids) . "' AND ";
                 if (isId($ProductId)) {
                     $query .= "vcproductid=" . (int) $ProductId;
                 } else {
                     $query .= "vcproducthash='" . $GLOBALS['ISC_CLASS_DB']->Quote($ProductHash) . "'";
                 }
                 $result = $GLOBALS["ISC_CLASS_DB"]->Query($query);
                 // Are there any option details?
                 if ($row = $GLOBALS["ISC_CLASS_DB"]->Fetch($result)) {
                     if ($row['vcenabled'] == 1) {
                         $enabled = 'checked="checked"';
                     } else {
                         $enabled = "";
                     }
                     $sku = $row['vcsku'];
                     $add_p_checked = $subtract_p_checked = $fixed_p_checked = "";
                     $show_price = "none";
                     $price = "";
                     switch ($row['vcpricediff']) {
                         case "add":
                             $add_p_checked = 'selected="selected"';
                             $show_price = "";
                             $price = FormatPrice($row['vcprice'], false, false);
                             break;
                         case "subtract":
                             $subtract_p_checked = 'selected="selected"';
                             $show_price = "";
                             $price = FormatPrice($row['vcprice'], false, false);
                             break;
                         case "fixed":
                             $fixed_p_checked = 'selected="selected"';
                             $show_price = "";
                             $price = FormatPrice($row['vcprice'], false, false);
                             break;
                     }
                     $add_w_checked = $subtract_w_checked = $fixed_w_checked = "";
                     $show_weight = "none";
                     $weight = "";
                     switch ($row['vcweightdiff']) {
                         case "add":
                             $add_w_checked = 'selected="selected"';
                             $show_weight = "";
                             $weight = FormatWeight($row['vcweight'], false);
                             $show_weight = "";
                             break;
                         case "subtract":
                             $subtract_w_checked = 'selected="selected"';
                             $show_weight = "";
                             $weight = FormatWeight($row['vcweight'], false);
                             $show_weight = "";
                             break;
                         case "fixed":
                             $fixed_w_checked = 'selected="selected"';
                             $show_weight = "";
                             $weight = FormatWeight($row['vcweight'], false);
                             $show_weight = "";
                             break;
                     }
                 }
             }
             $GLOBALS['VariationRows'] .= sprintf("<input type='hidden' name='options[{$count}][id]' value='%d' />", $row['combinationid']);
             $GLOBALS['VariationRows'] .= "<tr class=\"GridRow\" onmouseover=\"this.className='GridRowOver'\" onmouseout=\"this.className='GridRow'\">";
             $GLOBALS['VariationRows'] .= "\t<td style='width:30px; padding-left:5px'><img src='images/variation.gif' width='16' height='16' /></td>";
             $GLOBALS['VariationRows'] .= sprintf("\t<td style='padding-left:4px'><input name='options[{$count}][enabled]' type='checkbox' %s value='ON' /></td>", $enabled);
             $combo = preg_replace("/^#/", "", $combo);
             $combos = explode("#", $combo);
             foreach ($combos as $c) {
                 $GLOBALS['VariationRows'] .= sprintf("\t<td>%s</td>", isc_html_escape($c));
             }
             $GLOBALS['VariationRows'] .= sprintf("\t<td><input name='options[{$count}][sku]' type='text' class='Field50' value='%s' /></td>", isc_html_escape($sku));
             $GLOBALS['VariationRows'] .= sprintf("\t<td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<select class='PriceDrop' name='options[{$count}][pricediff]' onchange=\"if(this.selectedIndex>0) { \$(this).parent().find('span').show(); \$(this).parent().find('span input').focus(); \$(this).parent().find('span input').select(); } else { \$(this).parent().find('span').hide(); } \">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<option value=''>%s</option>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<option %s value='add'>%s</option>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<option %s value='subtract'>%s</option>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<option %s value='fixed'>%s</option>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</select>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span style='display:%s'>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t%s <input name='options[{$count}][price]' type='text' class='Field50 PriceBox' style='width:40px' value='%s' /> %s\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</td>", GetLang("NoChange"), $add_p_checked, GetLang("VariationAdd"), $subtract_p_checked, GetLang("VariationSubtract"), $fixed_p_checked, GetLang("VariationFixed"), $show_price, $GLOBALS['CurrencyTokenLeft'], $price, $GLOBALS['CurrencyTokenRight']);
             $GLOBALS['VariationRows'] .= sprintf("\t<td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<select class='WeightDrop' name='options[{$count}][weightdiff]' onchange=\"if(this.selectedIndex>0) { \$(this).parent().find('span').show(); \$(this).parent().find('span input').focus(); \$(this).parent().find('span input').select(); } else { \$(this).parent().find('span').hide(); } \">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<option value=''>%s</option>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<option %s value='add'>%s</option>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<option %s value='subtract'>%s</option>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<option %s value='fixed'>%s</option>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</select>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span style='display:%s'>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<input name='options[{$count}][weight]' type='text' class='Field50 WeightBox' style='width:40px' value='%s' /> %s\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</td>", GetLang("NoChange"), $add_w_checked, GetLang("VariationAdd"), $subtract_w_checked, GetLang("VariationSubtract"), $fixed_w_checked, GetLang("VariationFixed"), $show_weight, $weight, GetConfig('WeightMeasurement'));
             $GLOBALS['VariationRows'] .= "\t<td><input name='options[{$count}][image]' type='file' class='Field150 OptionImage' />";
             if ($row['vcimage'] != "") {
                 $GLOBALS['VariationRows'] .= sprintf("\t<br /><input name='options[{$count}][delimage]' id='variation_delete_image_{$count}' type='checkbox' value='ON' /> <label for='variation_delete_image_{$count}'>%s</label> %s <a href='%s' target='_blank'>%s</a>", GetLang("DeleteVariationImage"), GetLang("Currently"), sprintf("%s/%s/%s", $GLOBALS['ShopPath'], GetConfig('ImageDirectory'), $row['vcimage']), $row['vcimage']);
             }
             $GLOBALS['VariationRows'] .= "\t</td>";
             // Is inventory tracking enabled for variations?
             if ($ShowInventoryFields) {
                 $InventoryFieldsHide = "display: auto;";
             } else {
                 $InventoryFieldsHide = "display: none;";
             }
             $GLOBALS['VariationRows'] .= sprintf("\t<td class=\"VariationStockColumn\" style=\"" . $InventoryFieldsHide . "\"><input name='options[{$count}][currentstock]' type='text' class='Field50 StockLevel' value='%d' /></td>", $row['vcstock']);
             $GLOBALS['VariationRows'] .= sprintf("\t<td class=\"VariationStockColumn\" style=\"" . $InventoryFieldsHide . "\"><input name='options[{$count}][lowstock]' type='text' class='Field50 LowStockLevel' value='%d' /></td>", $row['vclowstock']);
             $GLOBALS['VariationRows'] .= "</tr>";
             $count++;
         }
     }
     if (!$ShowInventoryFields) {
         $GLOBALS['HideInv'] = "none";
     }
     $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("products.variation.combination");
     return $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate(true);
 }
Beispiel #28
0
		/**
		 * View the details for gift wrapping for a particular item.
		 */
		public function viewGiftWrappingDetailsAction()
		{
			if(!isset($_REQUEST['orderprodid']) || !IsId($_REQUEST['orderprodid'])) {
				exit;
			}

			$query = "
				SELECT *
				FROM [|PREFIX|]order_products
				WHERE orderprodid='".(int)$_REQUEST['orderprodid']."'
			";
			$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
			$orderProduct = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
			if(!isset($orderProduct['ordprodid']) || !$orderProduct['ordprodwrapname']) {
				exit;
			}

			$GLOBALS['ProductName'] = isc_html_escape($orderProduct['ordprodname']);
			$GLOBALS['ProductQuantity'] = $orderProduct['ordprodqty'];
			$GLOBALS['WrapName'] = isc_html_escape($orderProduct['ordprodwrapname']);

			$wrapping = $orderProduct['wrapping_cost_ex_tax'];
			if(getConfig('taxDefaultTaxDisplayOrders') == TAX_PRICES_DISPLAY_INCLUSIVE) {
				$wrapping = $orderProduct['wrapping_cost_inc_tax'];
			}

			$GLOBALS['WrapPrice'] = FormatPrice($wrapping);
			if($orderProduct['ordprodwrapmessage']) {
				$GLOBALS['WrapMessage'] = nl2br(isc_html_escape($orderProduct['ordprodwrapmessage']));
			}
			else {
				$GLOBALS['HideWrapMessage'] = 'display: none';
			}

			$this->template->display('order.viewwrapping.tpl');
		}
Beispiel #29
0
function RenderPage_auctions_ajax()
{
    global $config, $html;
    //file_put_contents('ajax_get.txt',print_r($_GET,TRUE));
    header('Content-Type: text/plain');
    // list auctions
    $auctions = QueryAuctions::QueryCurrent();
    $TotalDisplaying = QueryAuctions::TotalDisplaying();
    $TotalAllRows = QueryAuctions::TotalAllRows();
    $outputRows = "{\n" . "\t" . '"iTotalDisplayRecords" : ' . $TotalDisplaying . ",\n" . "\t" . '"iTotalRecords" : ' . $TotalAllRows . ",\n" . "\t" . '"sEcho" : ' . (int) getVar('sEcho', 'int') . ",\n" . "\t" . '"aaData" : [' . "\n";
    if ($TotalDisplaying < 1) {
        unset($auctions);
    } else {
        $outputRows .= "\t{\n";
        $count = 0;
        while (TRUE) {
            $auction = $auctions->getNext();
            if (!$auction) {
                break;
            }
            $Item = $auction->getItem();
            if (!$Item) {
                continue;
            }
            if ($count != 0) {
                $outputRows .= "\t},\n\t{\n";
            }
            $count++;
            $data = array('item' => $Item->getDisplay(), 'seller' => '<img src="./?page=mcskin&user='******'" width="32" height="32" alt="" /><br />' . $auction->getSeller(), 'price each' => FormatPrice($auction->getPrice()), 'price total' => FormatPrice($auction->getPriceTotal()), 'market percent' => '--', 'qty' => (int) $Item->getItemQty());
            // buy button
            if ($config['user']->hasPerms('canBuy')) {
                $data['canBuy'] = '
          <form action="./" method="post">
          ' . CSRF::getTokenForm() . '
          <input type="hidden" name="page"      value="' . $config['page'] . '" />
          <input type="hidden" name="action"    value="buy" />
          <input type="hidden" name="auctionid" value="' . (int) $auction->getTableRowId() . '" />
          <input type="text" name="qty" value="' . (int) $data['qty'] . '" onkeypress="return numbersonly(this, event);" ' . 'class="input" style="width: 60px; margin-bottom: 5px; text-align: center;" /><br />
          <input type="submit" value="Buy" class="button" />
          </form>
';
            }
            // cancel button
            if ($config['user']->hasPerms('isAdmin')) {
                $data['isAdmin'] = '
          <form action="./" method="post">
          ' . CSRF::getTokenForm() . '
          <input type="hidden" name="page"      value="' . $config['page'] . '" />
          <input type="hidden" name="action"    value="cancel" />
          <input type="hidden" name="auctionid" value="' . (int) $auction->getTableRowId() . '" />
          <input type="submit" value="Cancel" class="button" />
          </form>
';
            }
            // sanitize
            $data = str_replace(array('/', '"', "\r", "\n"), array('\\/', '\\"', '', '\\n'), $data);
            $rowClass = 'gradeU';
            //TODO:
            //gradeA
            //gradeC
            //gradeX
            //gradeU
            $outputRows .= "\t\t" . '"DT_RowClass":"' . $rowClass . '",' . "\n";
            $i = -1;
            foreach ($data as $v) {
                $i++;
                if ($i != 0) {
                    $outputRows .= ",\n";
                }
                $outputRows .= "\t\t" . '"' . $i . '":"' . $v . '"';
            }
            $outputRows .= "\n";
        }
        unset($auctions, $Item);
        $outputRows .= "\t}\n";
    }
    $outputRows .= ']}' . "\n";
    //file_put_contents('ajax_output.txt',$outputRows);
    echo $outputRows;
    exit;
}
 /**
  * Update the exchange rate of a currency
  *
  * Method will automatically update the exchange rate currency corresponding to the currency id $currencyid
  *
  * @access public
  * @return null
  */
 public function UpdateExchangeRate()
 {
     $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->LoadLangFile('settings');
     $currModules = explode(",", GetConfig("CurrencyMethods"));
     if (!isset($_REQUEST['cid']) || !isset($_REQUEST['currencyid'])) {
         print "{'id': " . (int) $_REQUEST['currencyid'] . ", 'status':1, 'newRate':null, 'seq': " . (int) $_REQUEST['seq'] . "};";
         exit;
     }
     $module = null;
     GetModuleById("currency", $module, $_REQUEST['cid']);
     if ($module === null || $module === false) {
         print "{'id': " . (int) $_REQUEST['currencyid'] . ", 'status':1, 'newRate':null, 'seq': " . (int) $_REQUEST['seq'] . "};";
         exit;
     }
     $query = "SELECT *\n\t\t\tFROM [|PREFIX|]currencies\n\t\t\tWHERE currencyid = '" . $GLOBALS['ISC_CLASS_DB']->Quote($_REQUEST['currencyid']) . "'";
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     $row = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
     if ($row == false) {
         print "{'id': " . (int) $_REQUEST['currencyid'] . ", 'status':1, 'newRate':null, 'seq': " . (int) $_REQUEST['seq'] . "};";
         exit;
     }
     $rate = $module->GetExchangeRateUsingBase($row['currencycode']);
     if ($rate === false) {
         $messages = $module->GetErrors();
         $message = $messages[0];
         if ($message == GetLang("CurrencyProviderRequestUnavailable")) {
             print "{'id': " . (int) $_REQUEST['currencyid'] . ", 'status':1, 'newRate':null, 'seq': " . (int) $_REQUEST['seq'] . "};";
         } else {
             print "{'id': " . (int) $_REQUEST['currencyid'] . ", 'status':2, 'newRate':null, 'seq': " . (int) $_REQUEST['seq'] . "};";
         }
     } else {
         $data = array();
         $data['currencyexchangerate'] = $rate;
         $data["currencylastupdated"] = time();
         $GLOBALS['ISC_CLASS_DB']->UpdateQuery("currencies", $data, "currencyid='" . $GLOBALS['ISC_CLASS_DB']->Quote((int) $_REQUEST['currencyid']) . "'");
         $GLOBALS['ISC_CLASS_DATA_STORE']->UpdateCurrencies();
         print "{'id': " . (int) $_REQUEST['currencyid'] . ", 'status':0, 'newRate':'" . (string) FormatPrice($rate, false, true, false, $row, false) . "', 'seq': " . (int) $_REQUEST['seq'] . "};";
     }
     exit;
 }