<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
// +----------------------------------------------------------------------+
// | PHP version 4/5                                                      |
// +----------------------------------------------------------------------+
// | This source file is a part of iScripts Multicart                     |
// +----------------------------------------------------------------------+
// | Authors: Programmer<programmer@armia.com>        		              |
// +----------------------------------------------------------------------+
// | Copyrights Armia Systems, Inc and iScripts.com  2005                |
// | All rights reserved                                                  |
// +----------------------------------------------------------------------+
// | This script may not be distributed, sold, given away for free to     |
// | third party, or used as a part of any internet services such as      |
// | webdesign etc.                                                       |
// +----------------------------------------------------------------------+
include "includes/config.php";
include "includes/session.php";
include "includes/functions.php";

if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) {
    $_POST = array_map('stripslashes_deep', $_POST);
    $_GET = array_map('stripslashes_deep', $_GET);
    $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
}
if (isset($_SESSION["sess_userid"]) && $_SESSION["sess_userid"] != "") {
    $userid = $_SESSION["sess_userid"];
}

if ($begin == "") {
    $begin = 0;
    $num = 1;
    $numBegin = 1;
}

$pid = ($_GET['pid'] != '') ? $_GET['pid'] : $_POST['pid'];

$sql = " SELECT * FROM " . $tableprefix . "feedbacks WHERE published='Y' ";

$sess_back = $_SERVER["PHP_SELF"] . "?begin=" . $begin . "&num=" . $num . "&numBegin=" . $numBegin . "&cmbSearchType=" . $cmbSearchType . "&txtSearch=" . $txtSearch;
$_SESSION["gbackurl"] = $sess_back;

$totalrows = mysql_num_rows(mysql_query($sql));

$navigate = pageBrowser($totalrows, 10, 10, "&pid=" . addslashes($pid) . "&cmbSearchType=$cmbSearchType&txtSearch=$txtSearch", $_GET[numBegin], $_GET[start], $_GET[begin], $_GET[num]);
$sql = $sql . $navigate[0];
$rs = mysql_query($sql);

/* display the active template */

$active_template = displayTemplate();


include "includes/htmltop.php";

/* Top File Name */

include_once ("includes/" . $active_template[0]);
?>
<style>
    .success_messgae{
        color:#009933;
    }
</style>
<!--mainbody area start -->
<div class="main_body">
	<div class="container">
		<div class="row">			
    <!--center content area start-->		

    <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"], ENT_QUOTES, 'UTF-8') ?>" method="post" name="frmReview">
        <input type="hidden" name="pid" value="<?php echo $pid; ?>" >
		<section class="sec_marg">
		<div class="col-sm-12 col-lg-12 col-md-12 ">
			<h3 id="items_top_area_ttl"><?php echo SITE_FEEDBACK_TEXT;?></h3>
		</div>
		</section>
		<div class="clear"></div>
		
        <div align="left" id="item_details">


            <!--items display area start -->


            <div class="col-sm-12 col-lg-12 col-md-12" id="items_display_area">		

				<div class="text_information" align="center"><?php echo $message ?></div>

                <table width="99%"  border="0" cellpadding="0" cellspacing="0"  align="center">
                    <tr>
                        <td >
                            <table width="100%" cellpadding="2" class="searc_tbltop" cellspacing="2" border=0>
                                
                                <?php
                                $i = 1; 
                                if (mysql_num_rows($rs)) { 
                                    while ($row = mysql_fetch_array($rs)) {
                                        ?>
                                        <tr>
                                            <td width='5%' valign='top' class='message'><b>#<?php echo $i; ?></b></td>
                                            <td colspan=2 align='left' valign="top"><div align='left' class='innertext' style='word-break:break-all;'>			
                                                    <?php echo nl2br((ucfirst(stripslashes($row["feedback_content"])))); ?></div></td>
                                        </tr>
                                        <tr>
                                            <td width='5%' class="prdetails_productprice" valign='top'>&nbsp;</td>
                                            <td align='left' colspan=2 class='prdetails_productprice'> &nbsp;&nbsp;&nbsp;<?php echo POSTED_BY_TEXT;?> <?php echo ucwords(stripslashes($row["first_name"])) . " " . ucwords(stripslashes($row["last_name"])); ?>
                                                <br>
                                                &nbsp; &nbsp;<?php echo POSTED_ON_TEXT;?> <?php echo dateFormat($row["date_added"], "Y-m-d", "m/d/Y") ?></td>
                                        </tr>
                                        <tr>
                                            <td width='100%' colspan=3>&nbsp;</td>
                                        </tr>
                                        <?php
                                        $i++;
                                    }
                                    ?>
                                    <tr><td colspan=3 align='center'><?php echo($navigate[2]); ?></td></tr>

                                    <?php
                                } else {
                                    ?>
                                    <tr>
                                        <td width='100%' colspan=3 align="center">
                                            <?php
                                            echo NO_FEEDBACK_MSG;
                                            ?>
                                        </td>
                                    </tr>
                                    <?php
                                }
                                ?>
								<tr><td colspan="3" align="right"><div style="padding:5px; ">
                                            <input type="button" name="post_feedback" value="<?php echo POST_FEEDBACK_BUTTON;?>" onClick='postFeedback();' class="button" />
                                        </div></td>
                                </tr>
                            </table>
                        </td>
                    </tr>

                </table>


            </div>	


            <div align="left" class="float_clear1"></div>


            <!--items display area end -->
        </div>

    </form>
    <!--center content area end-->	


    <div align="left" class="clear"></div>		
	</div>
	</div>
</div>		
<!--mainbody area end -->
<div align="left" class="clear"></div>


<?php
include "includes/" . $active_template[2]; /* Bottom File Name */
?>
<script type="text/javascript">
    function postFeedback()
    {
<?php
if ($_SESSION["sess_userid"]) {
    ?>
                window.location = "postfeedback.php";
    <?php
} else {
    ?>
                alert('<?php echo LOGIN_ALERT_TEXT;?>');
                return false;
    <?php
}
?>
    }
</script>