<?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["paymentid"]) and $_GET["paymentid"]!= ""){
	$paymentid = $_GET["paymentid"];
}else if(isset( $_POST["paymentid"]) and $_POST["paymentid"]!= ""){
	$paymentid = $_POST["paymentid"];
}else{
	header("Location:payments.php");
	exit;
}


$txtPaymentMethod = $_POST["txtPaymentMethod"];
$txtComments = $_POST["txtComments"];
$txtPaymentDate = $_POST["txtPaymentDate"];

if(isset($_POST["btnSaveChanges"])){
	if(isNotNull($txtPaymentDate)){
		$txtPaymentDate = dateFormat($txtPaymentDate,"m/d/Y" ,"Y-m-d" );
	}
	$sql ="UPDATE  ".$tableprefix."artist_payments SET 
		payment_method = '".addslashes($txtPaymentMethod)."',
		comments= '".addslashes($txtComments)."',
		payment_date = '".addslashes($txtPaymentDate)."',
		payment_status='C'
		WHERE 	artist_payment_id = '".addslashes($paymentid)."'
		";
	$res = mysql_query($sql);
	//echo "<br>".$sql;
	$message = CHANGES_SAVED_SUCCESSFULLY;
}

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

 $sql = "SELECT sp.*, s.artist_name FROM ".$tableprefix."artist_payments sp INNER JOIN  ".$tableprefix."artists s ON sp.artist_id = s.artist_id
             WHERE sp.artist_payment_id = '".addslashes($paymentid)."' ";
$result = mysql_query($sql);
if(mysql_num_rows($result) != 0){
	$row = mysql_fetch_array($result);
	$txtArtistName = $row["artist_name"];
	$txtOrderNumber = $row["order_id"];
	$txtOrderTotal = $row["seller_order_total_amount"];
	$txtTotalPaid = $row["amount_paid"];
        
        $txtsellerTotal = $row["total_amount"];

	$txtArtistCommission = $row["admin_commision_amount"];
	$txtPaymentMarkedDate = (isNotNull($row["date_marked_for_payment"]) ? dateFormat($row["date_marked_for_payment"],"Y-m-d","m/d/Y") : "");
	$txtPaymentDate = (isNotNull($row["payment_date"] and ($row["payment_date"]!= "0000-00-00")) ? dateFormat($row["payment_date"],"Y-m-d","m/d/Y") : "");
	$txtComments = $row["comments"];
	$txtPaymentMethod = $row["payment_method"];
	$PaymentStatus	  = $row['payment_status'];
	$currencycode	  =	getSellerCurrencySybol($row['artist_id']);
	$currencySymbol	  =	getCurrencySybol($currencycode);
		
}

include "../includes/htmltop.php";
?>
<link href="../style/calendar-win2k-cold-1.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="../includes/calendar.js"></script>
<script type="text/javascript" src="../includes/calendar-setup.js"></script>
<script type="text/javascript" src="../includes/calendar-en.js"></script>
<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 PAYMENT_DETAILS;?></div>
					<div align="center" class="text_information grey_tr"><?php echo $message?></div>
            		<br>
											
					<div align="left">			
					
					<form name="frmPaymentDetails" action="<?php echo $_SERVER["PHP_SELF"]?>" method="POST">
					<input type="hidden" name="paymentid" value="<?php echo htmlentities($paymentid);?>">
					
						<table cellpadding="3" cellspacing="3" width="100%" class="manage_table">
						<tr><td colspan="3">&nbsp;</td></tr>
						<tr><td width="27%" align="left" ><?php echo SELLER_NAME;?>&nbsp;</td>
						<td width="3%" >:</td>
						<td width="70%" align="left" class="innertextCopy2"><?php echo ($txtArtistName);?></td></tr>
						<tr><td align="left" ><?php echo ORDER_NO;?> &nbsp;</td><td >:</td>
						<td align="left" class="innertextCopy2"><?php echo htmlentities($txtOrderNumber);?></td></tr>
						<tr><td align="left" ><?php echo SELLER_ORDER_TOTAL;?>&nbsp;</td><td >:</td>
						<td align="left" class="innertextCopy2"><?php echo $adminCurrency['currency_symbol'];?>&nbsp;<?php echo htmlentities(number_format($txtOrderTotal, 2, '.', ''));?></td></tr>

                                                <tr><td align="left" ><?php echo SELLER_PDT_TOT;?> &nbsp;</td><td >:</td>
						<td align="left" class="innertextCopy2"><?php echo $adminCurrency['currency_symbol'];?>&nbsp;<?php echo htmlentities(number_format($txtsellerTotal, 2, '.', ''));?></td></tr>
						<tr>
                                                <tr>

						  <td align="left" ><?php echo ADMIN_COMM_AMT;?> &nbsp;</td>
						  <td >:</td>
						<td align="left" class="innertextCopy2"><?php echo $adminCurrency['currency_symbol'];?> &nbsp;<?php echo htmlentities(number_format($txtArtistCommission, 2, '.', ''));?></td></tr>
						<tr><td align="left" ><?php echo TOT_PAID_SELLER;?>&nbsp;</td><td >:</td>
						<td align="left" class="innertextCopy2"><?php echo $adminCurrency['currency_symbol'];?>&nbsp;<?php echo htmlentities(number_format($txtTotalPaid, 2, '.', ''));?></td>
						</tr>
						<tr><td align="left" ><?php echo DATE_MARKED_FOR_PAYMENT;?>&nbsp;</td><td >:</td>
						<td align="left" class="innertextCopy2"><?php echo htmlentities($txtPaymentMarkedDate);?></td></tr>
						
						<?php if($PaymentStatus=='P') { ?>
						
						<tr>
							<td align="left" ><?php echo DATE_OF_ACTUAL_PAYMENT;?>&nbsp;</td>
							<td >:</td>
							<td align="left">
								<div style="float:left; "><input type="text" name="txtPaymentDate" size="30" id="txtPaymentDate" class="textarea" readonly value="<?php echo $txtPaymentDate?>"></div>
								<div style="float:left; margin-left:10px; "><input type="button" value="<?php echo PICK_DATE;?>" id="button1" name="button1"  class="button" ></div>
									<script type="text/javascript">
										 Calendar.setup({
										 inputField            : "txtPaymentDate",
										 button               : "button1",
										 ifFormat              : "%m/%d/%Y",       // format of the input field
										 showsTime             : true,
										 timeFormat             : "24"
										 });
									</script>
							</td>
						</tr>

						<tr><td align="left" ><?php echo PAYMENT_METHOD;?>&nbsp;</td><td >:</td>
						<td align="left"><input type="text" class="textarea" value="<?php echo htmlentities($txtPaymentMethod);?>" name="txtPaymentMethod" size="30" maxlength="100"></td></tr>
						

						<tr><td align="left" valign="top"><?php echo COMMENTS;?>&nbsp;</td><td valign="top" >:</td>
						<td align="left"><TEXTAREA name="txtComments" class="textarea2" rows="8" cols="45"><?php echo ($txtComments);?></TEXTAREA></td></tr>
<?php  }  else { ?>
						
						
						<tr>
							<td align="left" ><?php echo PAID_DATE;?>&nbsp;</td>
							<td >:</td>
							<td align="left">
								<?php echo $txtPaymentDate;?>
							</td>
						</tr>


						
						<?php  } ?>
						
						
						
						<tr><td colspan="3" align="center"><?php if($PaymentStatus=='P') { ?><input type="submit" value="<?php echo BTN_SAVE_CHANGES;?>" name="btnSaveChanges" class="button"> <?php  } // end if ?>&nbsp;&nbsp;<input class="button" type="button" value="<?php echo BACK;?>" name="btnBack" onClick="window.location.href='payments.php'" ></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";
?>