$objArticleType = new Model_ArticleType($objConnection); if ($_pgR["act"] == model_Article::ACT_ADD || $_pgR["act"] == model_Article::ACT_UPDATE) { if (global_common::isCLogin()) { //get user info $c_userInfo = $_SESSION[global_common::SES_C_USERINFO]; $articleid = $_pgR[global_mapping::ArticleID]; $content = html_entity_decode($_pgR[global_mapping::Content], ENT_COMPAT, 'UTF-8'); $createdby = $c_userInfo[global_mapping::UserID]; $status = 1; if ($_pgR["act"] == Model_Comment::ACT_ADD) { $createdBy = $c_userInfo[global_mapping::UserID]; $resultID = $objComment->insert($articleid, $content, $createdby, $status); //echo global_common::convertToXML($arrHeader, array("rs","info"), array(0,$resultID), array(0,1)); //return; if ($resultID) { $commentHTML = $objComment->getCommentHTMLByArticle($articleid); $arrHeader = global_common::getMessageHeaderArr($banCode); //$banCode echo global_common::convertToXML($arrHeader, array("rs", "inf", "form"), array(1, 'Gửi bình luận thành công', $commentHTML), array(0, 1, 1)); return; } else { echo global_common::convertToXML($arrHeader, array("rs", "info"), array(0, "Input data is invalid"), array(0, 1)); return; } } else { $modifiedBy = $c_userInfo[global_mapping::UserID]; $articleID = html_entity_decode($_pgR[global_mapping::ArticleID], ENT_COMPAT, 'UTF-8'); $currentArticle = $objArticle->getArticleByID($articleID); $resultID = $objArticle->update($articleID, null, $title, $fileName, $catalogueID, $content, null, $tags, null, null, $currentArticle[global_mapping::CreatedBy], $currentArticle[global_mapping::CreatedDate], $modifiedBy, global_common::nowSQL(), null, null, 1, null, null, null, null, $companyName, $companyAddress, $companyWebsite, $companyPhone, $adType, $startDate, $endDate, $happyDays, $startHappyHour, $endHappyHour, $addresses, $dictricts, $cities); if ($resultID) { $arrHeader = global_common::getMessageHeaderArr($banCode);
$objRetailer = new Model_Retailer($objConnection); $objProduct = new Model_Product($objConnection); if ($_pgR["act"] == Model_Comment::ACT_ADD) { if (global_common::isCLogin()) { //get user info $c_userInfo = $_SESSION[global_common::SES_C_USERINFO]; $retailerID = $_pgR[global_mapping::RetailerID]; $content = html_entity_decode($_pgR[global_mapping::Content], ENT_COMPAT, 'UTF-8'); $createdby = $c_userInfo[global_mapping::UserID]; $status = 1; $createdBy = $c_userInfo[global_mapping::UserID]; $resultID = $objComment->insert($retailerID, $content, $createdby, $status); //echo global_common::convertToXML($arrHeader, array("rs","info"), array(0,$resultID), array(0,1)); //return; if ($resultID) { $commentHTML = $objComment->getCommentHTMLByArticle($retailerID, 0); $arrHeader = global_common::getMessageHeaderArr($banCode); //$banCode echo global_common::convertToXML($arrHeader, array("rs", "inf", "form"), array(1, 'Gửi bình luận thành công', $commentHTML), array(0, 1, 1)); try { //echo $retailerID; $retailer = $objRetailer->getRetailerByID($retailerID); //print_r($retailer); //recieve email when got a comment if ($retailer[global_mapping::Status]) { //echo 'send mail:'; $product = $objProduct->getProductByID($retailer[global_mapping::ProductID]); $userRetailer = $objUser->getUserByID($retailer[global_mapping::CreatedBy]); $fullNameRetailer = $userRetailer[global_mapping::FullName]; $emailRetailer = $userRetailer[global_mapping::Email]; $fullName = $c_userInfo[global_mapping::FullName];