| Server IP : 64.202.187.69 / Your IP : 216.73.217.74 Web Server : Apache System : Linux 69.187.202.64.host.secureserver.net 3.10.0-1160.144.1.el7.tuxcare.els6.x86_64 #1 SMP Fri May 29 16:22:24 UTC 2026 x86_64 User : transmarket ( 1001) PHP Version : 7.2.34 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/transmarket/translator/controllers/ |
Upload File : |
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
include 'connection.php';
require_once('functions.suggestions_marketing.php');
$suggestions_marketing_obj = new Suggestions_marketing();
if ( isset($_SESSION['tm_id']) && isset($_POST['suggestion_text']) ) {
$sentence_id = $_POST['sentence_id'];
if (is_numeric($sentence_id)) {
$suggestion_marketing_map_id = $_POST['suggestion_marketing_map_id'];
//get success suggested records
$resultSuggestionSuccessCount = $suggestions_marketing_obj->getSuccessSuggestedMarketingBySentenceId( $sentence_id );
//check sentence suggested success less than 3
if ($resultSuggestionSuccessCount->num_rows < 3) {
//accept the suggestion, update sentence suggestion map make lock and success suggestion
$resultUpdateS = $suggestions_marketing_obj->submitSuggestionMarketingAndUpdateToSuccess( addslashes($_POST['suggestion_text']), $suggestion_marketing_map_id );
if ($resultUpdateS == true) {
//update suggestion started at date in tbl_sentence_marketing, after received suggestion if date is null
$suggestions_marketing_obj->updateMarketplaceSentencePendingAtDate( $sentence_id );
//after submit again rerun success count query
$resultSuggestionSuccessCount2 = $suggestions_marketing_obj->getSuccessSuggestedMarketingBySentenceId( $sentence_id );
//check suggested success count
if( $resultSuggestionSuccessCount2->num_rows >= 3 ) {
//lock the sentence in main tbl_sentence_marketing table
$suggestions_marketing_obj->lockMarketplaceSentenceForSuggestions( $sentence_id );
//start voting at
$suggestions_marketing_obj->updateMarketplaceSentenceVotingStartedAtDate( $sentence_id );
}
echo json_encode(array("status" => "200", "msg" => "Suggestion submitted successfully"));
}else{
echo json_encode(array("status" => "300", "msg" => "Submission timed out took more than 5 mins"));
}
} else {
//make suggestion fail in sentence suggestion map
$suggestions_marketing_obj->makeSentenceSuggestionMarketingFailed( $suggestion_marketing_map_id );
echo json_encode(array("status" => "300", "msg" => "This sentence has already reached 3 suggestions.<br>
Please refresh page to contribute on a new one."));
}
} else {
echo json_encode(array("status" => "300", "msg" => 'Something went wrong, Please try again.'));
}
} else {
echo json_encode(array("status" => "300", "msg" => 'User not found'));
}