コード例 #1
0
ファイル: common.php プロジェクト: hungnv0789/vhtm
/**
 * Count the number of items in the database
 *
 * Method to return a count of items in the database (orders, products, customers, etc.)
 *
 * @access public
 * @return string the count.
 */
function StoneEdgeCount($table,$whereCond = '')
{
	if($table == 'products') {
		$query = StoneEdgeProductQueryCount();
		$count = (int)$GLOBALS['ISC_CLASS_DB']->FetchOne($query);

	} else {
		$query = $GLOBALS['ISC_CLASS_DB']->Query("SELECT COUNT(*) FROM [|PREFIX|]$table " .  $whereCond);
		$count = (int)$GLOBALS['ISC_CLASS_DB']->FetchOne($query);
	}
	//it's ok to return zero.
	return $count;
}
コード例 #2
0
ファイル: products.php プロジェクト: hungnv0789/vhtm
	/**
	 * Download product quantity data from the database to SEOM
	 *
	 * Method will process the posted data and create XML to be displayed.
	 *
	 * @access public
	 * @return string XML response to display on the page for product quantities on hand requested. Requires SKU so won't return any products without SKU's
	 */

	public function DownloadQuantities()
	{
		$xml = new SimpleXMLElement('<?xml version="1.0"?><SETIProducts />');

		// set our default queries
		$query = StoneEdgeProductQuery();
		$CountQuery = StoneEdgeProductQueryCount();

		if (isset($_REQUEST['startnum']) && (int)$_REQUEST['startnum'] > 0 && isset($_REQUEST['batchsize']) && (int)$_REQUEST['batchsize'] > 0) {
			$start = (int)$_REQUEST['startnum'] - 1;
			$numresults = (int)$_REQUEST['batchsize'];

			if ($start >= 0 && $numresults > 0) {
				$query = StoneEdgeProductQuery('LIMIT ' . $start . ', ' .$numresults);
			//	$CountQuery = StoneEdgeProductQueryCount('LIMIT ' . $start . ', ' .$numresults);
			}
		}

		if ($GLOBALS['ISC_CLASS_DB']->FetchOne($CountQuery) > $start) {
			//then there are products available for download, display header
			$responseNode = $xml->addChild('Response');
			$responseNode->addChild('ResponseCode', 1);
			$responseNode->addChild('ResponseDescription', 'Success');

			$products = $GLOBALS['ISC_CLASS_DB']->Query($query);

			//content
			while ($product = $GLOBALS['ISC_CLASS_DB']->Fetch($products)) {
				$productNode = $xml->addChild('Product');
				if ($product['prodvariationid'] == 0) {
					// no variations, just send the product as is
					if(isset($product['prodcode']) && $product['prodcode'] != ''){
						$productNode->addChild('Code', htmlentities($product['prodcode']));
					}else{
						$productNode->addChild('Code', htmlentities($product['prodname']));
					}
					$productNode->addChild('WebID', $product['productid']);
					$productNode->addChild('QOH', $product['prodcurrentinv']);

				} else {
					// product has variation, we need to send each variation as a different product
					$variationValue =  implode(', ', $variationValues);

					if(isset($product['prodcode']) && $product['prodcode'] != ''){
						$productNode->addChild('Code', htmlentities($product['prodcode']));
					}else{
						$productNode->addChild('Code', htmlentities($product['prodname']) . ' [VARID:' . $product['combinationid'] . ']');
					}
					$productNode->addChild('WebID', $product['productid'] . "-" .  $product['combinationid']);
					$productNode->addChild('QOH', $product['vcstock']);

				} // end if this product has a variation
			}

		} else {
			//no products, return the "none available" message.
			$responseNode = $xml->addChild('Response');
			$responseNode->addChild('ResponseCode', 2);
			$responseNode->addChild('ResponseDescription', 'Success');

		}
		return $xml->asXML();
	}