<?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.                                                       |
// +----------------------------------------------------------------------+
?>
<?php
include "../includes/config.php";
include "../includes/session.php";
include "../includes/functions.php";

if (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_adminname"]) and $_SESSION["sess_adminname"] != "") {
    $adminname = $_SESSION["sess_adminname"];
} else {
    header("Location:login.php");
    exit;
}

if (isset($_GET["feedbackid"]) and $_GET["feedbackid"] != "") {
    $feedbackid = $_GET["feedbackid"];
} else if (isset($_POST["feedbackid"]) and $_POST["feedbackid"] != "") {
    $feedbackid = $_POST["feedbackid"];
} else {
    header("Location:artists.php");
    exit;
}
if (isset($_GET["artistid"]) and $_GET["artistid"] != "") {
    $artistid = $_GET["artistid"];
} else if (isset($_POST["artistid"]) and $_POST["artistid"] != "") {
    $artistid = $_POST["artistid"];
} else {
    header("Location:artists.php");
    exit;
}

$chkPublished = $_POST["chkPublished"];
if ($chkPublished == "on") {
    $chkPublished = "Y";
} else {
    $chkPublished = "N";
}

if (isset($_POST["btnSaveChanges"])) {
    $sql = "UPDATE  " . $tableprefix . "artist_feedbacks SET
		published = '" . addslashes($chkPublished) . "'
		WHERE 	artist_feedback_id = '" . addslashes($feedbackid) . "'
		";
    $res = mysql_query($sql);

    $message = CHANGES_SAVED_SUCCESSFULLY;
} else if (isset($_POST["btnDelete"])) {
    $sql = "DELETE FROM  " . $tableprefix . "artist_feedbacks
		WHERE 	artist_feedback_id = '" . addslashes($feedbackid) . "'
		";
    $res = mysql_query($sql);
    header("Location:artistfeedbacks.php?artistid=$artistid&msg=deleted");
    exit;
}

if (isset($_GET["msg"]) and $_GET["msg"] != "") {
    $msg = $_GET["msg"];
    switch ($msg) {
        case "deleted": $message = FEEDBACK_DELETED_SUCC."!<br>";
            break;
        default:
            ;
    } // switch
}

$sql = "SELECT sf.*, u.first_name, u.last_name, u.user_name, u.email FROM " . $tableprefix . "artist_feedbacks sf
		INNER JOIN " . $tableprefix . "users u ON sf.user_id = u.user_id
		WHERE sf.artist_feedback_id = '" . addslashes($feedbackid) . "' ";
$result = mysql_query($sql);
if (mysql_num_rows($result) != 0) {
    $row = mysql_fetch_array($result);
    $txtFirstName = $row["first_name"];
    $txtLastName = $row["last_name"];
    $txtEmail = $row["email"];
    $txtUserName = $row["user_name"];
    $txtFeedbackContent = $row["feedback_content"];
    $txtDateAdded = $row["date_added"];
    $txtDateAdded = dateFormat($txtDateAdded, "Y-m-d", "m/d/Y");
    $userid = $row["user_id"];
    $chkPublished = $row["published"];
} else {
    if ($artistid != "") {
        header("Location:artistfeedbacks.php?artistid=$artistid");
        exit;
    } else {
        header("Location:artists.php");
        exit;
    }
}
include "../includes/htmltop.php";
?>

<SCRIPT>
    function confirmDelete(){
        if(confirm("<?php echo ARE_YOU_SURE_DELETE_RECORD;?>") ){
            return true;
        }
        return false;
    }
</SCRIPT>
<body>
<center>

    <div align="left" id="layout">




        <!--header area start -->
        <?php
        include_once("../includes/topheader_admin.php")
        ?>

        <!--header area end -->




        <div align="left" class="main_body">
            <!--main body start -->



<?php
include_once("../includes/admintopmenu.php")
?>		


            <div align="left" class="content_area">

                <!--content area start -->

                <div align="left" class="page_title"><?php echo SELLER_FB_DETAIL;?> (<?php echo getArtistName($artistid); ?>)</div>
                <div align="center" class="text_information_success grey_tr"><?php echo $message ?></div>
                <br>

                <div align="left">		

                    <form name="frmFeedback" action="<?php echo $_SERVER["PHP_SELF"] ?>" method="POST">
                        <input type="hidden" name="feedbackid" value="<?php echo htmlentities($feedbackid); ?>">
                        <input type="hidden" name="artistid" value="<?php echo htmlentities($artistid); ?>">
                        <table cellpadding="0" cellspacing="0" width="100%" class="manage_table">
                            <tr><td colspan="3">&nbsp;</td></tr>
                            <tr><td align="left" width='20%'><?php echo FNAME;?>&nbsp;</td>
                                <td width='5%'></td>
                                <td width='75%' align="left"  class="innertextCopy2"><?php echo ($txtFirstName); ?></td></tr>
                            <tr><td align="left" ><?php echo LNAME;?> &nbsp;</td><td ></td>
                                <td align="left"  class="innertextCopy2"><?php echo ($txtLastName); ?></td></tr>
                            <tr><td align="left" ><?php echo EMAIL;?>&nbsp;</td><td ></td>
                                <td align="left"  class="innertextCopy2"><?php echo htmlentities($txtEmail); ?></td></tr>
                            <tr><td align="left" valign="top"><?php echo USER_FB;?>&nbsp;</td><td ></td>
                                <td align="left"><div align="left"  class="innertextCopy2" style='word-break:break-all;'><?php echo nl2br((stripslashes($txtFeedbackContent))); ?></div></td></tr>
                            <tr><td align="left" ><?php echo PUBLISH;?>&nbsp;</td><td ></td>
                                <td align="left"  class="innertextCopy2"><input type="checkbox" class="checkbox" name="chkPublished" <?php if ($chkPublished == "Y") {
    echo "CHECKED";
} ?> ></td></tr>
                            <tr><td colspan="3">&nbsp;</td></tr>
                            <tr>
                            <td colspan="2">&nbsp;</td>
                            <td>
                                <input class="button" type="button" value="<?php echo BACK_TO_SELLER_FB;?>" name="btnbackToArtistFB" onClick="window.location.href='artistfeedbacks.php?artistid=<?php echo $artistid; ?>'" >&nbsp;&nbsp;<input type="submit" class="button" value="<?php echo DELETE;?>" name="btnDelete" onClick="return confirmDelete();" >&nbsp;&nbsp;<input type="submit" class="button" value="<?php echo BTN_SAVE_CHANGES;?>" name="btnSaveChanges">&nbsp;&nbsp;
                            </td>
                            </tr>
                        </table>
                    </form>

                </div>


                <!--content area end-->

            </div>



            <div align="left" class="clear_float"><img src="<?php echo $imagefolder; ?>/clear.gif" alt="" width="1" height="1" /></div>
            <!--main body end -->
        </div>


        <?php
        include "../includes/footer.php";
        ?>