<?php require_once("../../db.php"); ?>
<?php try {
	
		$core = Core::getInstance();
		$stmt = $core->dbh->prepare("INSERT INTO messages (mess_client_id, mess_message, mess_whosent) values (:mess_client_id, :mess_message, :mess_whosent)");
		$mess_whosent = "1";
		$stmt -> bindParam("mess_client_id", $_POST["inp_reply_clientID"], PDO::PARAM_INT);
		$stmt -> bindParam("mess_message", $_POST["txta_reply"], PDO::PARAM_STR);
		$stmt -> bindParam("mess_whosent", $mess_whosent, PDO::PARAM_STR);
		
		
		$stmt -> execute();
		$row_count = $stmt -> rowCount();
		
		if ($row_count > 0) {
			echo "true";
			$last_insert_id = $core->dbh->lastInsertId();
			$client_number = getClientNumber($_POST["inp_reply_clientID"]);
			pushSMS($_GET["ag"], $client_number, $_POST["txta_reply"], $last_insert_id);
		}
		
		
	} catch(PDOException $pe) {
		
		trigger_error('Could not connect to MySQL database. ' . $pe->getMessage() , E_USER_ERROR);
		
	}
?>