$manu = $_pgR['manu']; $properties = $_pgR['property']; $filterProperty = ''; foreach ($properties as $key => $info) { //echo $key; if ($info) { $filterProperty .= '(GROUP_CONCAT(\'&&\',propertyid, propertyvalue,\'&&\') LIKE \'%&&' . $key . $info . '&&%\') And '; } } if ($filterProperty) { $filterProperty = global_common::cutLast($filterProperty, 4); $filterProperty = '1=1 GROUP BY productid HAVING ' . $filterProperty; //echo $filterProperty; $productProperties = $objProductProperty->getAllProductProperty(0, global_mapping::ProductID, $filterProperty); $productIDs = global_common::getArrayColumn($productProperties, global_mapping::ProductID); $productInIDs = global_common::convertToQueryIN($productIDs); } $search = ''; $_arrCategories = $objArticleType->getAllArticleType(0, null, '`ParentID`=0', 'Level'); //echo $catID; $cat = $objArticleType->getArticleTypeByID($catID); //print_r($cat); $_currentParentCatID = $catID; if ($cat) { $_currentParentCatID = $cat[global_mapping::ParentID]; $search = '`' . global_mapping::CatalogueID . '` = ' . $catID . ' '; } if ($city) { if ($search) { $search = 'ProductID IN( select ProductID where CityID =`' . global_mapping::CityID . '` = ' . $city . ') '; } else {
public function getTopPropertyValue($catID, $sizeProperty, $sizeValue) { $whereClause = 'WHERE ' . global_mapping::ArticleTypeID . ' = \'' . $catID . '\' '; $strSQL = global_common::prepareQuery(global_common::SQL_SELECT_FREE, array('*', Model_PropertyGroup::TBL_SL_PROPERTY_GROUP, $whereClause)); $propertyGroups = $this->_objConnection->selectCommand($strSQL); //print_r($propertyGroups); $arrPropertyGroupIDs = global_common::getArrayColumn($propertyGroups, global_mapping::PropertyGroupID); $strQueryIN = global_mapping::PropertyGroupID . ' IN(' . global_common::convertToQueryIN($arrPropertyGroupIDs) . ')'; //echo $strQueryIN; $objProperty = new Model_Property($this->_objConnection); $allProperties = $objProperty->getAllProperty(0, '*', $strQueryIN, '`Order`'); $arrPropertyIDs = global_common::getArrayColumn($allProperties, global_mapping::PropertyID); //print_r($allProperties); $strQueryIN = global_mapping::PropertyID . ' IN(' . global_common::convertToQueryIN($arrPropertyIDs) . ')'; $temp = array(); foreach ($allProperties as $key => $info) { $temp[$info[global_mapping::PropertyID]] = $info; unset($allProperties[$key]); } $allProperties = $temp; //print_r($allProperties); //get top properties used $strQueryIN = global_mapping::PropertyID . ' IN(' . global_common::convertToQueryIN($arrPropertyIDs) . ')'; $strSQL = global_common::prepareQuery(global_common::SQL_SELECT_FREE, array(PropertyID, self::TBL_SL_PRODUCT_PROPERTY, 'WHERE ' . $strQueryIN . ' GROUP BY PropertyID ORDER BY COUNT(*) DESC LIMIT 0,' . $sizeProperty . '')); //echo '<br>SQL:'.$strSQL; $arrTopPropertyIDs = $this->_objConnection->selectCommand($strSQL); if (!$arrTopPropertyIDs || count($arrTopPropertyIDs) <= 0) { return; } //print_r($arrTopPropertyIDs); $arrTopPropertyIDs = global_common::getArrayColumn($arrTopPropertyIDs, global_mapping::PropertyID); $strQueryIN = 'WHERE ' . global_mapping::PropertyID . ' IN(' . global_common::convertToQueryIN($arrTopPropertyIDs) . ')'; $strQueryIN .= ' Group By ' . global_mapping::PropertyID . ',' . global_mapping::PropertyValue; $strQueryIN .= ' Order By ' . global_mapping::PropertyID . ',COUNT(' . global_mapping::PropertyValue . ') DESC'; $strSQL = global_common::prepareQuery(global_common::SQL_SELECT_FREE, array('distinct ' . global_mapping::PropertyID . ',' . global_mapping::PropertyValue, self::TBL_SL_PRODUCT_PROPERTY, $strQueryIN)); //echo '<br>SQL:'.$strSQL; $arrTopProperties = $this->_objConnection->selectCommand($strSQL); //print_r($arrTopProperties); $arrResult = array(); foreach ($arrTopPropertyIDs as $item) { //echo $item; $arrResult[$item] = $allProperties[$item]; $arrValue = array(); $limit = $sizeValue; //print_r($arrTopProperties); //echo ' PropID:'.$item; foreach ($arrTopProperties as $value) { if ($value[global_mapping::PropertyID] == $item && $limit > 0) { //echo $value[global_mapping::PropertyValue]; //echo $value[global_mapping::PropertyValue]; $arrValue = array_merge($arrValue, array($value[global_mapping::PropertyValue])); $limit--; } } //print_r($arrValue); $arrResult[$item][global_mapping::PropertyValue] = $arrValue; } //print_r($arrResult); return $arrResult; }
$manu = $_pgR["manu"]; $allCats = $objArticleType->getAllArticleType(0, null, '', null); $allCities = $objCity->getAllCity(); if ($catID == 0) { $allCatIDs = ''; } else { $allSubCats = $objArticleType->getAllArticleType(0, null, 'ParentID=' . $catID, null); //print_r($allSubCats); if (count($allSubCats) <= 0) { $allCatIDs = $catID; } else { $allCatIDs = global_common::getArrayColumn($allSubCats, global_mapping::ArticleTypeID); } } if ($allCatIDs) { $search = '`' . global_mapping::CatalogueID . '` IN ( ' . global_common::convertToQueryIN($allCatIDs) . ' )'; } if ($keyword) { if ($search) { $search .= ' and (`' . global_mapping::ProductName . '` like \'%' . global_common::escape_mysql_string($keyword) . '%\' or `' . global_mapping::Description . '` like \'%' . global_common::escape_mysql_string($keyword) . '%\')'; } else { $search .= '(`' . global_mapping::ProductName . '` like \'%' . global_common::escape_mysql_string($keyword) . '%\' or `' . global_mapping::Description . '` like \'%' . global_common::escape_mysql_string($keyword) . '%\')'; } } if ($manu) { if ($search) { $search .= ' and (`' . global_mapping::ManufactoryID . '` = ' . global_common::escape_mysql_string($manu) . ')'; } else { $search .= '(`' . global_mapping::ManufactoryID . '` = ' . global_common::escape_mysql_string($manu) . ')'; } }
private function getArticleDetails($articleList, $objConnection, $selectField = '*') { $arrID = global_common::splitString($articleList); $strQueryIN = global_common::convertToQueryIN($arrID); $whereClause = 'WHERE ' . global_mapping::ArticleID . ' IN (' . $strQueryIN . ')'; $strSQL .= global_common::prepareQuery(global_common::SQL_SELECT_FREE, array('*', Model_Article::TBL_SL_ARTICLE, $whereClause)); //echo $strSQL; $arrArticles = $objConnection->selectCommand($strSQL); return $arrArticles; }
/** * Get Aticles By Type (Categories) * * @param mixed $articleTypeIDs This is a description * @return mixed This is the return value description * */ private function getArticleIDsByTypes($articleTypeIDs) { $arrTypeID = global_common::splitString($articleTypeIDs); $strQueryIN = global_common::convertToQueryIN($arrTypeID); $whereClause = 'WHERE ' . global_mapping::ArticleTypeID . ' IN (' . $strQueryIN . ')'; $strSQL .= global_common::prepareQuery(global_common::SQL_SELECT_FREE, array('*', self::TBL_SL_ARTICLE_TYPE_ID, $whereClause)); //echo $strSQL; $articleTypes = $this->_objConnection->selectCommand($strSQL); return global_common::getArrayColumn($articleTypes, global_mapping::ArticleID); }
public function getPropertyGroupByIDs($arrIDs) { $arrIDs = global_common::splitString($arrIDs); $strQueryIN = global_common::convertToQueryIN($arrIDs); $whereClause = 'WHERE ' . global_mapping::PropertyGroupID . ' IN (' . $strQueryIN . ')'; $strSQL .= global_common::prepareQuery(global_common::SQL_SELECT_FREE, array('*', self::TBL_SL_PROPERTY_GROUP, $whereClause)); //echo $strSQL; $propertyGroups = $this->_objConnection->selectCommand($strSQL); if (!$propertyGroups) { global_common::writeLog('get getPropertyGroupByIDs:' . $strSQL, 1, $_mainFrame->pPage); return null; } //print_r($arrResult); return $propertyGroups; }
$currentParentType = $cmArea; } if ($cmCategory) { //echo '$currentTypeID'; if ($lastPage) { $lastPage .= 'cmCategory=' . $cmCategory . '&'; } else { $lastPage .= 'cmCategory=' . $cmCategory; } $currentTypeID = $cmCategory; $condition .= $condition ? ' and ' : ''; $condition .= global_mapping::CatalogueID . '=' . $cmCategory; } else { $subTypes = $objArticleType->getAllArticleType(0, null, 'ParentID=' . $currentParentType, 'Level'); $arrSubTypes = global_common::getArrayColumn($subTypes, global_mapping::ArticleTypeID); $strCatIN = global_common::convertToQueryIN($arrSubTypes); $condition .= $condition ? ' and ' : ''; $condition .= global_mapping::CatalogueID . ' IN (' . $strCatIN . ')'; } if ($cmManufactory) { if ($lastPage) { $lastPage .= 'cmManufactory=' . $cmManufactory . '&'; } else { $lastPage .= 'cmManufactory=' . $cmManufactory; } //echo '$curentManuID'; $curentManuID = $cmManufactory; $condition .= $condition ? ' and ' : ''; $condition .= global_mapping::ManufactoryID . '=' . $cmManufactory; } if ($txtKeyword) {
/** * This is method getTopArticleByType. For show article type list page * * @param mixed $listTypeID This is a description * @param mixed $limitRow This is a description * @param mixed $selectField This is a description * @return mixed This is the return value description * */ public function getTopArticleByType($listTypeID, $limitRow, $selectField = '*', $whereClause = '', $orderBy = '') { $arrTypeID = global_common::splitString($listTypeID); $strQueryIN = global_common::convertToQueryIN($arrTypeID); $arrSummary = global_common::getContentInfoByIDs($this->_objConnection, $strQueryIN, global_common::ARTICLE_TYPE); //print_r($arrSummary); if ($arrSummary == null) { global_common::writeLog('Can not get content from table summary'); return null; } $strSQL = Model_Article::getSQLSelectByTableName($arrSummary, -1, $limitRow, $selectField, $whereClause, $orderBy); $arrResult = self::getArticlesFromDB($strSQL); //print_r($arrResult); return $arrResult; }
if (!$page) { $page = 1; } if ($catID == 0) { $allCatIDs = ''; } else { $allSubCats = $objArticleType->getAllArticleType(0, null, 'ParentID=' . $catID, null); //print_r($allSubCats); if (count($allSubCats) <= 0) { $allCatIDs = $catID; } else { $allCatIDs = global_common::getArrayColumn($allSubCats, global_mapping::ArticleTypeID); } } if ($allCatIDs) { $search = '`' . global_mapping::ArticleTypeID . '` IN ( ' . global_common::convertToQueryIN($allCatIDs) . ' )'; } if ($keyword) { if ($search) { $search .= ' and (`' . global_mapping::ProductName . '` like \'%' . global_common::escape_mysql_string($keyword) . '%\' or `' . global_mapping::Description . '` like \'%' . global_common::escape_mysql_string($keyword) . '%\')'; } else { $search .= '(`' . global_mapping::ProductName . '` like \'%' . global_common::escape_mysql_string($keyword) . '%\' or `' . global_mapping::Description . '` like \'%' . global_common::escape_mysql_string($keyword) . '%\')'; } } $allAds = $objAdvertising->getAllAdvertising($page, null, $search, null, $total); $allAdType = $objAdType->getAllAdType(0, null, null, null); $_SESSION[global_common::SES_C_CUR_PAGE] = "admin/admin_advertising.php"; include_once 'include/_admin_header.inc'; ?> <script type="text/javascript" src="<?php echo $_objSystem->locateJs('user_advertising.js');
public function getRetailerByProducts($intPage, $productIds, $type, $city, $status, &$total) { if (!$selectField) { $selectField = '*'; } $arrIDs = global_common::splitString($productIds); $strQueryIN = global_common::convertToQueryIN($arrIDs); if ($strQueryIN) { $strQueryIN = global_mapping::ProductID . ' IN( ' . $strQueryIN . ') and'; } else { $strQueryIN = '1 != and'; } if ($city) { $city = ' and `' . global_mapping::CityID . '` = ' . $city . ' '; } else { $city = ' and 1=1 '; } if ($type) { $type = ' and `' . global_mapping::ProductStatusID . '` = ' . $type . ' '; } else { $type = ' and 1=1 '; } if ($status) { $status = ' (`' . global_mapping::StatusID . '` = ' . global_common::STATUS_ACTIVE . ' or `' . global_mapping::StatusID . '` is null)'; } else { $status = ' `' . global_mapping::StatusID . '` = ' . global_common::STATUS_INACTIVE; } if ($intPage > 0) { $strSQLCount = global_common::prepareQuery(global_common::SQL_SELECT_FREE, array("count(*)", self::TBL_SL_RETAILER, 'WHERE ' . $strQueryIN . $status . $type . $city)); $strSQL = global_common::prepareQuery(global_common::SQL_SELECT_FREE, array($selectField, self::TBL_SL_RETAILER, 'WHERE ' . $strQueryIN . $status . $type . $city . $orderBy . ' limit ' . ($intPage - 1) * self::NUM_PER_PAGE . ',' . self::NUM_PER_PAGE)); } else { $strSQL = global_common::prepareQuery(global_common::SQL_SELECT_FREE, array($selectField, self::TBL_SL_RETAILER, 'WHERE ' . $strQueryIN . $status . $type . $city)); } //echo '<br>SQL:'.$strSQL; $arrResult = $this->_objConnection->selectCommand($strSQL); if (!$arrResult) { global_common::writeLog('get sl_retailer ByID:' . $strSQL, 1, $_mainFrame->pPage); return null; } if ($strSQLCount) { //echo $strSQLCount; $arrTotal = $this->_objConnection->selectCommand($strSQLCount); $total = $arrTotal[0][0]; } //echo $total; $productIDs = global_common::getArrayColumn($arrResult, global_mapping::ProductID); //print_r($productIDs); $productIDs = array_unique($productIDs); $objProduct = new Model_Product($this->_objConnection); $products = $objProduct->getProductByIDs($productIDs); $temp = array(); foreach ($products as $key => $info) { $temp[$info[global_mapping::ProductID]] = $info; unset($products[$key]); } $products = $temp; //print_r($products); $objStatus = new Model_Status($this->_objConnection); $allStatus = $objStatus->getAllStatus(); $statuses = array(); foreach ($allStatus as $key => $info) { $statuses[$info[global_mapping::StatusID]] = $info; unset($allStatus[$key]); } $count = count($arrResult); for ($i = 0; $i < $count; $i++) { $arrResult[$i][global_mapping::ProductStatus] = $statuses[$arrResult[$i][global_mapping::ProductStatusID]][global_mapping::StatusName]; $arrResult[$i][global_mapping::ProductName] = $products[$arrResult[$i][global_mapping::ProductID]][global_mapping::ProductName]; } $arrResult = global_common::mergeUserInfo($arrResult, $this->_objConnection); //print_r($arrResult); return $arrResult; }
public function getLatestRetailer($intPage = 0, $whereClause = '', $type, &$total) { if ($whereClause) { $whereClause = ' WHERE ' . $whereClause; } $orderBy = ' ORDER BY ' . global_mapping::ModifiedDate . ' DESC'; $strSQL = global_common::prepareQuery(global_common::SQL_SELECT_FREE, array(global_mapping::ProductID, Model_Product::TBL_SL_PRODUCT, $whereClause)); //echo '<br>SQL:'.$strSQL; $products = $this->_objConnection->selectCommand($strSQL); if (!$products) { global_common::writeLog('get All sl_product:' . $strSQL, 1, $_mainFrame->pPage); return null; } $productIDs = global_common::getArrayColumn($products, global_mapping::ProductID); $productIDs = array_unique($productIDs); //print_r($productIDs); $strQueryIN = global_common::convertToQueryIN($productIDs); $whereClause = 'Where ' . global_mapping::ProductID . ' IN (' . $strQueryIN . ')'; if ($type) { $whereClause .= ' And ' . global_mapping::ProductStatusID . '=' . $type; } $strSQL = global_common::prepareQuery(global_common::SQL_SELECT_FREE, array('*', Model_Retailer::TBL_SL_RETAILER, $whereClause . $orderBy . ' limit ' . ($intPage - 1) * self::NUM_PER_PAGE . ',' . self::NUM_PER_PAGE)); $arrResult = $this->_objConnection->selectCommand($strSQL); //echo $strSQL; if (!$arrResult) { global_common::writeLog('get All Retailers:' . $strSQL, 1, $_mainFrame->pPage); return null; } $strSQLCount = global_common::prepareQuery(global_common::SQL_SELECT_FREE, array('count(*)', Model_Retailer::TBL_SL_RETAILER, $whereClause)); //Get details of product to display $productIDs = global_common::getArrayColumn($arrResult, global_mapping::ProductID); $productIDs = array_unique($productIDs); //print_r($productIDs); $strQueryIN = global_common::convertToQueryIN($productIDs); $productDetails = $this->getProductByIDs($productIDs); $convertedProducts = array(); foreach ($productDetails as $key => $info) { $convertedProducts[$info[global_mapping::ProductID]] = $info; unset($productDetails[$key]); } $objStatus = new Model_Status($this->_objConnection); $productStatus = $objStatus->getAllStatus(); $convertedStatus = array(); foreach ($productStatus as $key => $info) { $convertedStatus[$info[global_mapping::StatusID]] = $info; unset($productStatus[$key]); } //echo '<br>$strSQLCount:'.$strSQLCount; //Get total results if ($strSQLCount) { $arrTotal = $this->_objConnection->selectCommand($strSQLCount); $total = $arrTotal[0][0]; } //Assign product details to retailers by ProductID $count = count($arrResult); for ($index = 0; $index < $count; $index++) { $arrResult[$index]["Product"] = $convertedProducts[$arrResult[$index][global_mapping::ProductID]]; $arrResult[$index][global_mapping::StatusName] = $convertedStatus[$arrResult[$index][global_mapping::ProductStatusID]][global_mapping::StatusName]; } //echo 'Before merge comment info'; $arrResult = global_common::mergeUserInfo($arrResult, $this->_objConnection); return $arrResult; }
public function getStoreByIDs($arrIDs) { $arrIDs = global_common::splitString($arrIDs); $strQueryIN = global_common::convertToQueryIN($arrIDs); if ($strQueryIN) { $strQueryIN = global_mapping::StoreID . ' IN (' . $strQueryIN . ')'; } else { $strQueryIN = '1=1'; } $whereClause = 'WHERE ' . $strQueryIN; $strSQL .= global_common::prepareQuery(global_common::SQL_SELECT_FREE, array('*', self::TBL_SL_STORE, $whereClause . ' ' . ' limit 0,' . self::NUM_PER_PAGE)); //echo $strSQL; $arrResult = $this->_objConnection->selectCommand($strSQL); if (!$arrResult) { global_common::writeLog('get getProductByIDs:' . $strSQL, 1, $_mainFrame->pPage); return null; } $objCity = new Model_City($this->_objConnection); $objDistrict = new Model_District($this->_objConnection); $tempVarCities = $objCity->getAllCity(); $allCities = null; foreach ($tempVarCities as $key => $info) { $allCities[$info[global_mapping::CityID]] = $info; unset($tempVarCities[$key]); } $tempDistricts = $objDistrict->getAllDistrict(); $allDistricts = null; foreach ($tempDistricts as $key => $info) { $allDistricts[$info[global_mapping::DistrictID]] = $info; unset($tempDistricts[$key]); } // print_r($allDistricts); // return; $count = count($arrResult); $objArticle = new Model_Article($this->_objConnection); for ($i = 0; $i < $count; $i++) { //echo $arrResult; //print_r( $allCities); //$arrResult[$i][global_mapping::CityID] = $allCities[$arrResult[$i][global_mapping::CityID]]; $arrResult[$i][global_mapping::CityName] = $allCities[$arrResult[$i][global_mapping::CityID]][global_mapping::CityName]; // print_r($arrResult[$i]); //return; // print_r($allCities[$arrResult[$i][global_mapping::CityID]]); //break; $arrResult[$i][global_mapping::DistrictName] = $allDistricts[$arrResult[$i][global_mapping::DistrictID]][global_mapping::DistrictName]; $arrResult[$i][global_mapping::Latitude] = global_common::convertToDecimal($arrResult[$i][global_mapping::Latitude]); $arrResult[$i][global_mapping::Longitude] = global_common::convertToDecimal($arrResult[$i][global_mapping::Longitude]); $arrArticle = $objArticle->getArticleByStoreID($arrResult[$i][global_mapping::StoreID]); $shortDescription = global_common::formatPlanText($arrArticle[0][global_mapping::Content]); $arrResult[$i][global_mapping::Content] = global_common::cutString2($shortDescription, 0, 16); // print_r($arrResult[$i]); //echo $arrResult[$i][global_mapping::DistrictID]; //echo $allDistricts[$arrResult[$i][global_mapping::DistrictID]][global_mapping::DistrictName]; //print_r($allDistricts); //return ; } //print_r($stores); return $arrResult; }
$objProduct = new Model_Product($objConnection); $objProductProperty = new Model_ProductProperty($objConnection); $objManufactory = new Model_Manufactory($objConnection); //$propertyInfo = $objProduct->getPropertyInfoByID(30); //print_r($propertyInfo); $intMode = 0; //add mode $parentTypes = $objArticleType->getAllArticleType(0, null, 'ParentID=0', 'Level'); $allTypes = $objArticleType->getAllArticleType(0, null, 'ParentID!=0', 'Level'); //set default selected section $currentParentType = $parentTypes[0][global_mapping::ArticleTypeID]; $allGroups = $objPropertyGroup->getAllPropertyGroup(0, '*', '', ''); $allManuFactories = $objManufactory->getAllManufactory(0, '*', '', global_mapping::ManufactoryName); //print_r($allGroups); $allGroupIDs = global_common::getArrayColumn($allGroups, global_mapping::PropertyGroupID); $strQueryIN = global_mapping::PropertyGroupID . ' IN(' . global_common::convertToQueryIN($allGroupIDs) . ')'; //echo($allCities); $allProperties = $objProperty->getAllProperty(0, '*', $strQueryIN, '`Order`'); //print_r($allProperties); if ($_pgR["pid"]) { $productID = $_pgR["pid"]; $product = $objProduct->getProductByID($productID); $intMode = 1; //edit mode $createBy = $product[global_mapping::CreatedBy]; $currentUserID = $_SESSION[global_common::SES_C_USERINFO][global_mapping::UserID]; if ($createBy != $currentUserID) { global_common::redirectByScript("index.php"); return; } //print_r($article[global_mapping::ArticleID]);
else { //echo 'lat & long'; $location = array('lat' =>global_common::convertToDecimal( $_pgR["lat"]), 'long' => global_common::convertToDecimal($_pgR["lng"])); } */ $location = array('lat' => global_common::convertToDecimal($_pgR["lat"]), 'long' => global_common::convertToDecimal($_pgR["lng"])); //echo $address; //echo $address; $condition = ''; if ($cat && $cat != 'undefined') { $childCats = $objArticleType->getAllArticleType(0, '*', global_mapping::ParentID . '=' . $cat); if (count($childCats) > 0) { $arrCatID = global_common::getArrayColumn($childCats, global_mapping::ArticleTypeID); $condition = '`' . global_mapping::MainCategoryId . '` IN (' . global_common::convertToQueryIN($arrCatID) . ')'; } else { $condition = '`' . global_mapping::MainCategoryId . '` =' . $cat; } } else { $cat = '0'; } if ($address) { if ($condition) { $condition .= ' AND '; } $condition .= '`' . global_mapping::Name . '` like \'%' . $address . '%\''; } //echo $condition; //print_r($location); //return;