$companyAddress = html_entity_decode($_pgR[global_mapping::CompanyAddress], ENT_COMPAT, 'UTF-8');
     $companyWebsite = html_entity_decode($_pgR[global_mapping::CompanyWebsite], ENT_COMPAT, 'UTF-8');
     $companyPhone = html_entity_decode($_pgR[global_mapping::CompanyPhone], ENT_COMPAT, 'UTF-8');
     $adType = html_entity_decode($_pgR[global_mapping::AdType], ENT_COMPAT, 'UTF-8');
     $startDate = html_entity_decode($_pgR[global_mapping::StartDate], ENT_COMPAT, 'UTF-8');
     $endDate = html_entity_decode($_pgR[global_mapping::EndDate], ENT_COMPAT, 'UTF-8');
     $happyDays = html_entity_decode($_pgR[global_mapping::HappyDays], ENT_COMPAT, 'UTF-8');
     $startHappyHour = html_entity_decode($_pgR[global_mapping::StartHappyHour], ENT_COMPAT, 'UTF-8');
     $endHappyHour = html_entity_decode($_pgR[global_mapping::EndHappyHour], ENT_COMPAT, 'UTF-8');
     $addresses = html_entity_decode($_pgR[global_mapping::Addresses], ENT_COMPAT, 'UTF-8');
     $dictricts = html_entity_decode($_pgR[global_mapping::Dictricts], ENT_COMPAT, 'UTF-8');
     $cities = html_entity_decode($_pgR[global_mapping::Cities], ENT_COMPAT, 'UTF-8');
     $fileName = html_entity_decode($_pgR[global_mapping::FileName], ENT_COMPAT, 'UTF-8');
     $status = 1;
     $createdBy = $c_userInfo[global_mapping::UserID];
     $arrCat = global_common::splitString($catalogueID);
     $stores = $objStore->getStoreByFBID($pageID);
     $arrStoreID = global_common::getArrayColumn($stores, global_mapping::StoreID);
     $resultID = $objArticle->insert($title, $fileName, $content, null, $tags, $arrCat, $createdBy, $renewedNum, $companyName, $companyAddress, $companyWebsite, $companyPhone, $adType, $startDate, $endDate, $happyDays, $startHappyHour, $endHappyHour, $addresses, $dictricts, $cities, $status, $arrStoreID, $postID);
     if ($resultID) {
         $arrHeader = global_common::getMessageHeaderArr($banCode);
         //$banCode
         echo global_common::convertToXML($arrHeader, array("rs", "inf"), array(1, 'Đăng bài viết thành công'), array(0, 1));
         return;
     } else {
         echo global_common::convertToXML($arrHeader, array("rs", "inf"), array(0, "Input data is invalid"), array(0, 1));
         return;
     }
 }
 //else
 //{
 /**
  * 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);
 }
    if ($createBy != $currentUserID) {
        global_common::redirectByScript("index.php");
        return;
    }
    //print_r($article[global_mapping::ArticleID]);
    $currentTypes = $objArticle->getArticleTypesByID($article[global_mapping::ArticleID]);
    //print_r($currentTypes);
    $type = $objArticleType->getArticleTypeByID($currentTypes[0]);
    $currentParentType = $type[global_mapping::ParentID];
    //print_r($currentParentType);
    $parentTypes = $objArticleType->getAllArticleType(0, null, 'ParentID=0', 'Level');
    $allTypes = $objArticleType->getAllArticleType(0, null, 'ParentID=' . $currentParentType, 'Level');
    //print_r($allTypes);
    $addresses = global_common::splitString($article[global_mapping::Addresses], ';');
    $districts = global_common::splitString($article[global_mapping::Dictricts], ';');
    $cities = global_common::splitString($article[global_mapping::Cities], ';');
    //print_r($parentTypes);
    //$intPage = 1;
    //$total = 0;
    //$comments = $objComment->getCommentByArticle($intPage,$total,$articleID,'*','',' CreatedDate DESC');
    //print_r($article);
}
?>

<script type="text/javascript" src="<?php 
echo $_objSystem->locateJPlugin('ckeditor/ckeditor.js');
?>
"></script>
<script type="text/javascript" src="<?php 
echo $_objSystem->locateJPlugin('ckeditor/adapters/jquery.js');
?>
 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;
 }
 /**
  * lấy thông tin detail của một vài c_user,c_user_detail
  *
  * @param string $userList danh sách các id c_user
  * @param object $objConnection connect to db
  * @param string $selectField các cột sẽ lấy dữ liệu về
  * @return array thông tin các user
  * GiaTran
  */
 private function getUserDetailByMultiTable($userList, $objConnection, $selectField = '*')
 {
     // build group table - optimize select query
     $userList = global_common::splitString($userList);
     //print_r($userList);
     $arrDocInTable = array();
     foreach ($userList as $key) {
         $suffix = global_common::getTableSuffixByAlphabet($key);
         $arrDocInTable[$suffix] .= '\'' . $key . '\',';
     }
     foreach ($arrDocInTable as $iDoc) {
         $key = global_common::getTableSuffixByAlphabet(substr($iDoc, 1, 2));
         $arrDocInTable[$key] = global_common::cutLast($iDoc, 1);
         $tbName = global_common::builtTableName(Model_User::TBL_SL_USER, $key);
         $selectField = '*';
         $strSQL .= "(" . global_common::prepareQuery(global_common::SQL_SELECT_BY_CONDITION1, array($selectField, $tbName, '`UserID` IN (' . $arrDocInTable[$key] . ')')) . ') UNION ALL ';
     }
     if ($strSQL != '') {
         $strSQL = substr($strSQL, 0, strlen($strSQL) - strlen(' UNION ALL '));
     }
     if ($selectField == '') {
         $strSQL = '(select * from (' . $strSQL . ') as tbl_user)';
     } else {
         $strSQL = '(select ' . $selectField . ' from (' . $strSQL . ') as tbl_user)';
     }
     //echo $strSQL;
     return $objConnection->selectCommand($strSQL);
 }
Beispiel #6
0
 /**
  * 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;
 }
Beispiel #7
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;
 }
Beispiel #8
0
 public function getProductByIDs($arrIDs)
 {
     $arrIDs = global_common::splitString($arrIDs);
     $strQueryIN = global_common::convertToQueryIN($arrIDs);
     if ($strQueryIN) {
         $strQueryIN = global_mapping::ProductID . ' IN (' . $strQueryIN . ')';
     } else {
         $strQueryIN = '1=1';
     }
     $whereClause = 'WHERE ' . $strQueryIN;
     $strSQL .= global_common::prepareQuery(global_common::SQL_SELECT_FREE, array('*', self::TBL_SL_PRODUCT, $whereClause . ' '));
     //echo $strSQL;
     $products = $this->_objConnection->selectCommand($strSQL);
     if (!$products) {
         global_common::writeLog('get getProductByIDs:' . $strSQL, 1, $_mainFrame->pPage);
         return null;
     }
     //print_r($products);
     return $products;
 }
Beispiel #9
0
 public function getCommentByArticle(&$intPage, &$total, $articleID, $selectField = '*', $whereClause = '', $orderBy = '')
 {
     $arrSummary = global_common::getContentIDs($this->_objConnection, $intPage, $articleID, global_common::COMMENT_TYPE);
     if ($arrSummary) {
         if ($orderBy) {
             $orderBy = ' ORDER BY ' . $orderBy;
         }
         $listCommentID = '';
         foreach ($arrSummary as $item) {
             $listCommentID = $item[global_mapping::SubContents] . $listCommentID;
         }
         $IDList = global_common::splitString($listCommentID);
         $total = count($IDList);
         $arrDocInTable = global_common::getListTableName($listCommentID, $intPage, Model_Comment::NUM_PER_PAGE, global_common::SEPARATE_BY_MONTH);
         $strSQL = '';
         $condition = '';
         foreach ($arrDocInTable as $key => $iDoc) {
             //check endWith ',' and then remove it
             if (global_common::endsWith($iDoc, ',')) {
                 $strDocInTable = global_common::cutLast($iDoc, 1);
             }
             $strTableName = Model_Comment::TBL_SL_COMMENT . '_' . $key;
             if ($whereClause) {
                 $condition = 'WHERE (' . global_mapping::IsDeleted . ' IS NULL or ' . global_mapping::IsDeleted . ' = \'0\') and `' . global_mapping::CommentID . '` IN (' . $strDocInTable . ') and ' . $whereClause;
             } else {
                 $condition = 'WHERE (' . global_mapping::IsDeleted . ' IS NULL or ' . global_mapping::IsDeleted . ' = \'0\') and `' . global_mapping::CommentID . '` IN (' . $strDocInTable . ')';
             }
             $strSQL .= "(" . global_common::prepareQuery(global_common::SQL_SELECT_FREE, array($selectField, $strTableName, $condition . $orderBy)) . " ) UNION ALL ";
         }
         //xóa bỏ đoạn text UNION ALL cuối chuỗi $strSQL
         $strSQL = global_common::cutLast($strSQL, strlen('UNION ALL '));
         $arrResult = $this->_objConnection->selectCommand($strSQL);
         $arrResult = global_common::mergeUserInfo($arrResult);
         //print_r($arrResult);
         return $arrResult;
     }
     return null;
 }
 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;
 }