示例#1
0
    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) . ')';
    }
}
$products = $objProduct->getAllProduct(1, '*', $search, null, $total);
$allManuFactories = $objManufactory->getAllManufactory(0);
$stores = $objStatus->getAllStatus(0, '*', global_mapping::Type . '=\'' . global_common::STATUS_PRODUCT_PRICE . '\'');
$_SESSION[global_common::SES_C_CUR_PAGE] = "admin/admin_product.php";
include_once 'include/_admin_header.inc';
?>

<script type="text/javascript" src="<?php 
echo $_objSystem->locateJs('user_product.js');
?>
"></script>
<div id="admin-article">
	<div class="row-fluid">
		<div class="span12">
			<!-- BEGIN PAGE TITLE & BREADCRUMB-->
			<h3 class="page-title">
				Quản lý sản phẩm
			</h3>
示例#2
0
 public function getProductPriceByProduct($objID, $selectField = '*')
 {
     $selectField = $selectField ? $selectField : '*';
     $strSQL .= global_common::prepareQuery(global_common::SQL_SELECT_FREE, array($selectField, self::TBL_SL_PRODUCT_PRICE, 'WHERE ProductID = \'' . $objID . '\' '));
     //echo '<br>SQL:'.$strSQL;
     $arrResult = $this->_objConnection->selectCommand($strSQL);
     if (!$arrResult) {
         global_common::writeLog('get sl_product_price ByID:' . $strSQL, 1, $_mainFrame->pPage);
         return null;
     }
     $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]);
     }
     //print_r($statuses);
     $count = count($arrResult);
     for ($index = 0; $index < $count; $index++) {
         //print_r($statuses[$arrResult[$index][global_mapping::TypeID]]);
         if ($statuses[$arrResult[$index][global_mapping::TypeID]]) {
             $pathCode = $statuses[$arrResult[$index][global_mapping::TypeID]][global_mapping::ExtraInfo];
             //echo$arrResult[$index][global_mapping::ProductLink];
             try {
                 $arrResult[$index][global_mapping::Price] = global_common::getPriceFromURL($arrResult[$index][global_mapping::ProductLink], $pathCode);
             } catch (Exception $ex) {
                 //$arrResult[$index]
             }
         }
     }
     //print_r($arrResult);
     return $arrResult;
 }
示例#3
0
 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;
 }
示例#4
0
include_once 'include/_permission.inc';
include_once 'class/model_articletype.php';
include_once 'class/model_product.php';
include_once 'class/model_comment.php';
include_once 'class/model_user.php';
include_once 'class/model_city.php';
include_once 'class/model_district.php';
include_once 'class/model_status.php';
include_once 'class/model_retailer.php';
$objProduct = new Model_Product($objConnection);
$objArticleType = new Model_ArticleType($objConnection);
$objCity = new Model_City($objConnection);
$objDistrict = new Model_District($objConnection);
$objStatus = new Model_Status($objConnection);
$objRetailer = new Model_Retailer($objConnection);
$productStatuses = $objStatus->getAllStatus(0, '*', global_mapping::Type . '=' . global_common::STATUS_PRODUCT_TYPE);
$intMode = 0;
//add mode
$allCities = $objCity->getAllCity();
//echo 'get city:';
//echo($allCities);
if ($_pgR["pid"]) {
    $currentProduct = $objProduct->getProductByID($_pgR["pid"]);
}
if ($_pgR["rid"]) {
    $retailerID = $_pgR["rid"];
    $retailter = $objRetailer->getRetailerByID($retailerID);
    $intMode = 1;
    //edit mode
    $createBy = $retailter[global_mapping::CreatedBy];
    $currentUserID = $_SESSION[global_common::SES_C_USERINFO][global_mapping::UserID];
示例#5
0
 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;
 }