public function getAllCommentBad($intPage = 0, $selectField = '*', $whereClause = '', $orderBy = '')
 {
     if ($whereClause) {
         $whereClause = ' WHERE ' . $whereClause;
     }
     if ($orderBy) {
         $orderBy = ' ORDER BY ' . $orderBy;
     }
     if ($intPage > 0) {
         $strSQL .= global_common::prepareQuery(global_common::SQL_SELECT_FREE, array($selectField, Model_CommentBad::TBL_SL_COMMENT_BAD, $whereClause . $orderBy . ' limit ' . ($intPage - 1) * self::NUM_PER_PAGE . ',' . self::NUM_PER_PAGE));
     } else {
         $strSQL .= global_common::prepareQuery(global_common::SQL_SELECT_FREE, array($selectField, Model_CommentBad::TBL_SL_COMMENT_BAD, $whereClause . $orderBy));
     }
     //echo '<br>SQL:'.$strSQL;
     $arrResult = $this->_objConnection->selectCommand($strSQL);
     if (!$arrResult) {
         global_common::writeLog('get All sl_comment_bad:' . $strSQL, 1, $_mainFrame->pPage);
         return null;
     }
     //echo 'Merge bad comment info';
     //print_r($arrResult);
     $arrResult = global_common::mergeUserInfo($arrResult);
     //echo 'End Merge bad comment info';
     //print_r($arrResult);
     return $arrResult;
 }
 public function getAllBadComment($intPage = 0, $selectField = '*', $whereClause = '', $orderBy = '')
 {
     if ($whereClause) {
         $whereClause = ' WHERE ' . $whereClause . ' AND  CommentID IN (SELECT CommentID FROM sl_comment_bad)';
     } else {
         $whereClause = ' WHERE  CommentID IN (SELECT CommentID FROM sl_comment_bad)';
     }
     if ($orderBy) {
         $orderBy = ' ORDER BY ' . $orderBy;
     }
     if (!$selectField) {
         $selectField = '*';
     }
     if ($intPage > 0) {
         $strSQL .= global_common::prepareQuery(global_common::SQL_SELECT_FREE, array($selectField, Model_Comment::TBL_SL_COMMENT, $whereClause . $orderBy . ' limit ' . ($intPage - 1) * self::NUM_PER_PAGE . ',' . self::NUM_PER_PAGE));
     } else {
         $strSQL .= global_common::prepareQuery(global_common::SQL_SELECT_FREE, array($selectField, Model_Comment::TBL_SL_COMMENT, $whereClause . $orderBy));
     }
     //echo '<br>SQL:'.$strSQL;
     $arrResult = $this->_objConnection->selectCommand($strSQL);
     if (!$arrResult) {
         global_common::writeLog('function getCommentByIDs:' . $strSQL, 1, $_mainFrame->pPage);
         return null;
     }
     $arrResult = global_common::mergeReporterInfo($arrResult);
     //echo 'Before merge comment info';
     $arrResult = global_common::mergeUserInfo($arrResult);
     //echo 'End merge comment info';
     return $arrResult;
 }
 /**
  * Get Article with input is sql script
  *
  * @param mixed $strSQL This is a description
  * @return mixed This is the return value description
  *
  */
 private function getArticlesFromDB($strSQL)
 {
     $arrResult = $this->_objConnection->selectCommand($strSQL);
     if (!$arrResult) {
         global_common::writeLog('get sl_article from DB:' . $strSQL, 1, $_mainFrame->pPage);
         return null;
     }
     $count = count($arrResult);
     for ($i = 0; $i < $count; $i++) {
         //print_r($arrResult[$i]);
         $arrResult[$i][global_mapping::Content] = stripslashes($arrResult[$i][global_mapping::Content]);
     }
     return global_common::mergeUserInfo($arrResult);
 }
Esempio n. 4
0
 private function getArticlesFromDB($strSQL)
 {
     $arrResult = $this->_objConnection->selectCommand($strSQL);
     if (!$arrResult) {
         global_common::writeLog('get sl_article from DB:' . $strSQL, 1, $_mainFrame->pPage);
         return null;
     }
     return global_common::mergeUserInfo($arrResult);
 }
Esempio n. 5
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;
 }
Esempio n. 6
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;
 }
Esempio n. 7
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;
 }