/**
  * Initialises this file type for exporting. Queries for the data and stores the result.
  *
  * @param ISC_ADMIN_EXPORTMETHOD The export method exporting this type
  * @param int The template to use in conjunction with this type
  * @param string A WHERE clause to filter the data being exported
  * @param int The vendor to restrict queried data for
  */
 public function Init(ISC_ADMIN_EXPORTMETHOD $exportmethod, $templateid, $where, $vendorid)
 {
     $this->exportmethod = $exportmethod;
     $this->templateid = $templateid;
     $this->where = $where;
     SetupCurrency();
     // load the export template
     $this->exporttemplates = GetClass("ISC_ADMIN_EXPORTTEMPLATES");
     $this->template = $this->exporttemplates->GetTemplate($templateid);
     $formats = $this->exporttemplates->GetDateFormats();
     $this->dateformat = $formats[$this->template['dateformat']]["format"];
     $this->boolformat = $this->template['boolformat'];
     $this->blankforfalse = (bool) $this->template['blankforfalse'];
     $this->fields = $this->LoadFields($this->templateid);
     // perform any custom work on the fields
     $this->PostFieldLoad();
     // execute the query
 }
Example #2
0
	/**
	* Initialises this file type for exporting. Queries for the data and stores the result.
	*
	* @param ISC_ADMIN_EXPORTMETHOD The export method exporting this type
	* @param int The template to use in conjunction with this type
	* @param string A WHERE clause to filter the data being exported
	* @param string Optional HAVING clause
	*/
	public function Init(ISC_ADMIN_EXPORTMETHOD $exportmethod, $templateid, $where, $having)
	{
		$this->exportmethod = $exportmethod;
		$this->templateid = $templateid;

		SetupCurrency();

		// load the export template
		$this->SetTemplate($templateid);

		$this->fields = $this->LoadFields($this->templateid);

		// perform any custom work on the fields
		$this->PostFieldLoad();

		// execute the query
		$this->query = $this->GetQuery($this->ConstructFieldList(), $where, $having);
		$this->countquery = $this->GetListCountQuery($where, $having);
	}
Example #3
0
	public function __construct($customerId = null)
	{
		// use the same settings as orders by default
		$this->setDoubleOptIn(GetConfig('EmailIntegrationOrderDoubleOptin'));
		$this->setSendWelcome(GetConfig('EmailIntegrationOrderSendWelcome'));

		if (!$customerId) {
			return;
		}

		$entity = new ISC_ENTITY_CUSTOMER();

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

		unset($data['custpassword']);

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

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

		// customer custom form fields

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

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

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

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

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

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

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

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

		// transform customer group data if available
		if ($this->_data['customergroup']) {
			$this->_data['customergroupid'] = $this->_data['customergroup']['customergroupid'];
			$this->_data['groupname'] = $this->_data['customergroup']['groupname'];
		}
		else
		{
			$this->_data['customergroupid'] = '';
			$this->_data['groupname'] = '';
		}
		unset($this->_data['customergroup']);
	}
Example #4
0
    $GLOBALS['HidePurchasingOptions'] = "none";
}
// Are prices disabled in the store?
if (!GetConfig("ShowProductPrice")) {
    $GLOBALS['HideCartOptions'] = "none";
}
// Is the wishlist disabled in the store?
if (!GetConfig("EnableWishlist")) {
    $GLOBALS['HideWishlist'] = "none";
}
// Is account creation disabled in the store?
if (!GetConfig("EnableAccountCreation")) {
    $GLOBALS['HideAccountOptions'] = "none";
}
// Setup our currency. If we don't have one in our session then get/set our currency based on our geoIP location
SetupCurrency();
// Do we need to show the cart contents side box at all?
if (!isset($_SESSION['CART']['ITEMS']) || count($_SESSION['CART']['ITEMS']) == 0) {
    $GLOBALS['HidePanels'][] = "SideCartContents";
}
// Include the template's config file
require_once ISC_BASE_PATH . "/templates/" . GetConfig('template') . "/config.php";
$GLOBALS['TPL_PATH'] = GetConfig("ShopPath") . "/" . "templates" . "/" . GetConfig("template");
$GLOBALS['ISC_CLASS_TEMPLATE'] = new TEMPLATE("ISC_LANG");
$GLOBALS['ISC_CLASS_TEMPLATE']->FrontEnd();
$GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplateBase(ISC_BASE_PATH . "/templates");
$GLOBALS['ISC_CLASS_TEMPLATE']->panelPHPDir = ISC_BASE_PATH . "/includes/display/";
$GLOBALS['ISC_CLASS_TEMPLATE']->templateExt = "html";
$GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate(GetConfig("template"));
$GLOBALS['ISC_CLASS_VISITOR'] = GetClass('ISC_VISITOR');
if (isset($GLOBALS['ShowStoreUnavailable'])) {
 private function GetPriceFormats()
 {
     SetupCurrency();
     $currency = GetDefaultCurrency();
     $price = number_format(1543.987, $currency['currencydecimalplace'], $currency['currencydecimalstring'], '');
     $formats = array("number" => $price, "formatted" => FormatPriceInCurrency(1543.987));
     return $formats;
 }
Example #6
0
 public function GetListQuery($where, $vendorid, $sortField, $sortOrder)
 {
     SetupCurrency();
     if ($vendorid) {
         if ($where) {
             $where .= " AND ";
         }
         $where .= "p.prodvendorid = '" . $vendorid . "'";
     }
     if ($where) {
         $where = "WHERE " . $where;
     }
     $query = "\n\t\t\t\tSELECT\n\t\t\t\t\tp.productid,\n\t\t\t\t\tp.prodcode,\n\t\t\t\t\tp.prodname,\n\t\t\t\t\tp.prodprice,\n\t\t\t\t\tp.prodvisible,\n\t\t\t\t\tp.prodfeatured\n\t\t\t\tFROM\n\t\t\t\t\t(\n\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\tDISTINCT ca.productid\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t[|PREFIX|]categoryassociations ca\n\t\t\t\t\t\t\tINNER JOIN [|PREFIX|]products p ON p.productid = ca.productid\n\t\t\t\t\t\t\tINNER JOIN [|PREFIX|]product_search ps ON p.productid = ps.productid\n\t\t\t\t\t\t\tLEFT JOIN [|PREFIX|]brands b ON b.brandid = p.prodbrandid\n\t\t\t\t\t\t\t" . $where . "\n\t\t\t\t\t\tORDER BY\n\t\t\t\t\t\t\t" . $sortField . " " . $sortOrder . "\n\t\t\t\t\t) AS ca\n\t\t\t\t\tINNER JOIN [|PREFIX|]products p ON p.productid = ca.productid\n\t\t\t\t";
     return $query;
 }
Example #7
0
	public function GetListQuery($where, $having, $sortField, $sortOrder)
	{
		SetupCurrency();

		if ($where) {
			$where = "WHERE " . $where;
		}

		$query = "
				SELECT
					p.productid,
					p.prodcode,
					p.prodname,
					p.prodprice,
					p.prodvisible,
					p.prodfeatured
				FROM
					(
						SELECT
							DISTINCT ca.productid
						FROM
							[|PREFIX|]categoryassociations ca
							INNER JOIN [|PREFIX|]products p ON p.productid = ca.productid
							INNER JOIN [|PREFIX|]product_search ps ON p.productid = ps.productid
							LEFT JOIN [|PREFIX|]brands b ON b.brandid = p.prodbrandid
							" . $where . "
						ORDER BY
							" . $sortField . " " . $sortOrder . "
					) AS ca
					INNER JOIN [|PREFIX|]products p ON p.productid = ca.productid
				";

		return $query;
	}