<?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";
include_once "classes/cls_products.php";
include_once "classes/cls_store.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( $_GET["artistid"]) && $_GET["artistid"]!=""){
	$artistid = $_GET["artistid"];
}else if(isset( $_POST["artistid"]) && $_POST["artistid"]!=""){
	$artistid = $_POST["artistid"];
}
if(isset( $_GET["productid"]) && $_GET["productid"]!=""){
	$productid = $_GET["productid"];
}else if(isset( $_POST["productid"]) && $_POST["productid"]!=""){
	$productid = $_POST["productid"];
}

/*if(isset( $_SESSION["sess_userid"]) && $_SESSION["sess_userid"]!=""){
	$userid = $_SESSION["sess_userid"];
}else{
	header("Location:login.php?action=artistfeedbacks&artistid=$artistid&productid=$productid");
	exit();
}*/

if($artistid==''){
	header("Location:categorydetail.php");
	exit();
}

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




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

}

$select_artist_id = "SELECT artist_id,artist_name FROM ".$tableprefix."artists WHERE plan_expired = 'N' AND artist_id = '".$artistid."'";
	
$result_artist_id = mysql_query($select_artist_id) or die(mysql_error());

if(mysql_num_rows($result_artist_id) > 0)
{

        $artist_row = mysql_fetch_assoc($result_artist_id);
        $artist_id = $artist_row['artist_id'];


}
    

if($artist_id=='')
{
    header("Location:".SITE_URL."/index.php");
    exit;
}

        
        
 $sql=" SELECT f.*, u.user_name,u.first_name,u.last_name FROM ".$tableprefix."artist_feedbacks f
    
	INNER JOIN ".$tableprefix."users u ON f.user_id = u.user_id
	WHERE f.artist_id = '".addslashes($artistid)."' AND f.published='Y'  order by date_added DESC   ";
$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,2,2,"&artistid=".addslashes($artistid)."&productid=".addslashes($productid)."&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();



if($productid!=NULL)
{
    $productInfo    =   Products::getProductInfo($productid);    
    $categoryID     =   $productInfo->product_category;
    $aliasname      =   $productInfo->alias;
    $homeLink       = getOptimisedLink(SITE_URL, $categoryID, $aliasname);
}else{
       
    if($artistid!=''){
        
         $storeInfoObj =  Store::get_seller_account_info($artistid);
         $storeInfo    = $storeInfoObj->data;
         if ($enable_seller_friendly == "Y") {
                                 $homeLink = (!empty($storeInfo->storename)) ? SITE_URL . "/stores/" . $storeInfo->storename : SITE_URL . "/store/" . $storeInfo->artist_name;
                             } else {
                                 $homeLink = (!empty($storeInfo->storename)) ? SITE_URL . "/showportfolio.php?storename=" . $storeInfo->storename : SITE_URL . "/showportfolio.php?artistid=" . $artist_id;
                             }
    }
}


include "includes/htmltop.php";

/* Top File Name */

include_once ("includes/".$active_template[0]);

?>
<script language="JavaScript" type="text/JavaScript">
function clickSearch()
{
	document.frmFeedbacks.submit();
}

</script>

<!--mainbody area start -->
<div class="main_body">
	<div class="container">
		<div class="row">
		<!--center content area start-->		
		<form action="<?php echo $_SERVER["PHP_SELF"]?>" method="post" name="frmFeedbacks">
			<input type="hidden" name="artistid" value="<?php echo $artistid;?>" >
			<input type="hidden" name="productid" value="<?php echo $productid;?>" >
			
			
		<div class="col-sm-12 col-lg-12 col-md-12 " id="item_details">
	
		<!--items display area start -->
	
		<div align="left" id="items_top_area">
				<div align="left" id="items_top_area_ttl"><?php echo SELLER_FEEDBACK_TEXT;?></div>
		</div>
		
		<div class="text_information" align="center"><?php echo $message?></div>
		
		<div class="prodetails_topsection">				
																				
																										
			<table width="98%"  border="0" cellpadding="0" cellspacing="0"  align="center">
				<tr>
					<td >
						<table width="98%" cellpadding="2" cellspacing="2" border=0>
							<tr><td>&nbsp;</td><td colspan="2" align="center"></td></tr>
							<?php 
							$i=1;
							while($row  = mysql_fetch_array($rs))
							{
								echo "<tr>
								          <td width='5%' valign='top' class='message'><span>#".$i."</span></td>
								          <td align='left' colspan=2 width='95%'>
											  <div align='left' >
												<p>".nl2br(stripslashes($row["feedback_content"]))."</p>
											  </div>
										  </td>
									  </tr>";
								echo "<tr class='prdetails_productprice' ><td width='5%' height='15' valign='top'>&nbsp;</td>
								           <td align='left' colspan=2 width='95%'>".BY_TEXT." <span class='sellername'>".$row["first_name"]." &nbsp;" .$row["last_name"]."</span>&nbsp;&nbsp;&nbsp;&nbsp;
										   ";
							?>
					
									<div class="ratings"> <div class="fleft rating_<?php echo GetSellerRatingStar($row['artist_feedback_id'])?>"></div></div>

										   </td>
									 </tr>
						<?php			 
								echo "<tr><td colspan=3 width='100%'>&nbsp;</td></tr>";
	
								$i++;
							}
							?>
							<tr><td colspan=3 align='center'><?php echo($navigate[2]); ?></td></tr>
					  </table>
					</td>
				</tr>
				
				<tr>
					<td align="center">
                                            <input type="button" class="button" value="<?php echo ($productid!=NULL)?BACK_TO_PRODUCT_DETAILS_BUTTON:HOME_LINK;?>" onClick="window.location.href='<?php echo $homeLink;?>';" ></td>
				</tr>
			</table>
						
			<div class="clear"></div>
		</div>	
	
	
		<div align="left" class="float_clear1"></div>
					
					
		 <!--items display area end -->
		  </div>
		
		</form>
		<!--center content area end-->	
	</div>
	</div>
</div>
<!--mainbody area end -->
        


<?php
include "includes/".$active_template[2];	/* Bottom File Name */
?>