<?php

/*++++++++++++++++++++++++++++++++++++++++

  Script: Maian Gallery v2.0
  Written by: David Ian Bennett
  E-Mail: support@maianscriptworld.co.uk
  Website: http://www.maianscriptworld.co.uk

  ++++++++++++++++++++++++++++++++++++++++
  
  This File: view_order.php
  Description: View Order Details
  New in v2.0

  ++++++++++++++++++++++++++++++++++++++++*/

// Make sure that this file is being called from parent file
if (!defined('INCLUDE_FILES')) {
  accessDenied($msg_script18,$msg_script19);
  exit;
}

$q_sale = mysql_query("SELECT *,DATE_FORMAT(pay_date,'".$SETTINGS->mysql_date."') AS s_date  
                       FROM ".$database['prefix']."ipndata 
                       WHERE id = '{$_GET['view']}'
                       LIMIT 1
                       ") or die(mysql_error());
$SALE = mysql_fetch_object($q_sale);

$q_ptotal = mysql_query("SELECT SUM(pictureQty) AS qty 
                         FROM ".$database['prefix']."purchases
                         WHERE cartID = '{$SALE->cartID}'
                         ") or die(mysql_error());
$PTOTAL = mysql_fetch_object($q_ptotal);

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $msg_charset; ?>">
<title><?php echo $msg_sales23; ?></title>
<link href="css/css.css" rel="stylesheet" type="text/css">
<style type="text/css">
body {
  margin:0;
  padding:0;
}
</style>
<script type="text/javascript" src="js/js_code.js"></script>
</head>

<body>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
    <td align="left" style="padding:5px;background-color:#1EB5DD;color:#FFFFFF">
    <table cellpadding="0" cellspacing="0" width="100%" class="menutable">
    <tr>
     <td align="left" class="leftPad" width="90%">&raquo; <b><?php echo strtoupper($msg_sales23); ?></b></td>
     <td align="center" class="leftPad" width="10%" style="border-left:0"><b><a href="javascript:window.print()" title="<?php echo $msg_script29; ?>"><?php echo $msg_script29; ?></a></b></td>
    </tr>
    <tr>
     <td colspan="2" style="padding:5px;border-right:1px solid #083253;border-left:1px solid #083253;border-bottom:1px solid #083253">
     <b><?php echo $msg_sales7; ?></b>: <a href="mailto:<?php echo $SALE->email; ?>"><?php echo cleanData($SALE->first_name.' '.$SALE->last_name); ?></a><br>
     <b><?php echo $msg_sales11; ?></b>: <?php echo $SALE->s_date; ?> / <?php echo cleanData($SALE->invoice); ?><br>
     <b><?php echo $msg_sales24; ?></b>: <?php echo $SALE->txn_id; ?><br>
     <b><?php echo $msg_sales8; ?></b>: <?php echo $PTOTAL->qty; ?><br>
     </td>
    </tr> 
    </table>
    <table cellpadding="0" cellspacing="0" width="100%" class="menutable">
    <tr>
     <td align="left" colspan="2" class="leftPad">&raquo; <b><?php echo strtoupper($msg_sales25); ?></b></td>
    </tr>
    <tr>
     <td style="vertical-align:top;width:70%;padding:5px;border-right:1px solid #083253;border-left:1px solid #083253;border-bottom:1px solid #083253">
     <?php
     
     $q_purchases = mysql_query("SELECT * FROM ".$database['prefix']."purchases
                                 WHERE cartID = '{$SALE->cartID}'
                                 ORDER BY pictureID
                                 ") or die(mysql_error());
     while ($PURCHASES = mysql_fetch_object($q_purchases)) {
     $pic = getImageData($PURCHASES->pictureID);
     ?>
     <table width="100%" cellspacing="0" cellpadding="0" style="margin-bottom:2px;border:1px solid #083253">
     <tr>
       <td width="20%" style="text-align:center;padding:3px;border-right:1px solid #083253"><img src="<?php echo $SETTINGS->folder; ?>/galleries/<?php echo $SETTINGS->folder_name; ?>/<?php echo getFolderName($pic->cat); ?>/<?php echo $pic->thumbpath; ?>" alt="<?php echo cleanData($pic->name); ?>" height="<?php echo ADD_IMG_HGHT; ?>" width="<?php echo ADD_IMG_WDTH; ?>" class="image_pad_order" title="<?php echo cleanData($pic->name); ?>"></td>
       <td width="80%" style="text-align:left;padding:3px">
       <span style="font-weight:bold;color:#083253"><?php echo cleanData($pic->name); ?></span><br>
       <?php echo $msg_sales33; ?>: <?php echo $PURCHASES->pictureSize; ?><br>
       <?php echo $msg_sales34; ?>: <?php echo ($PURCHASES->pictureItem ? $PURCHASES->pictureItem : $msg_sales28); ?><br>
       <?php echo $msg_sales32; ?>: <?php echo $PURCHASES->pictureQty.' '.str_replace("{price}",get_cur_symbol($PURCHASES->pictureCost/$PURCHASES->pictureQty,$PP->ppCurrency),$msg_sales36); ?><br>
       <?php echo $msg_sales35; ?>: <b><?php echo get_cur_symbol($PURCHASES->pictureCost,$PP->ppCurrency); ?></b>
       </td>
     </tr>
     </table>
     <?php
     }
     
     ?>
     </td>
     <td style="vertical-align:top;width:30%;padding:5px;border-right:1px solid #083253;border-bottom:1px solid #083253">
     <b><?php echo $msg_sales26; ?></b>:<br><br>
     <?php echo cleanData($SALE->first_name.' '.$SALE->last_name); ?><br>
     <?php echo nl2br(cleanData($SALE->address)); ?><br><br>
     <b><?php echo $msg_sales27; ?></b>:<br><br>
     <?php echo ($SALE->memo ? nl2br(cleanData($SALE->memo)) : $msg_sales28); ?><br><br>
     <b><?php echo $msg_sales29; ?></b>:<br><br>
     <span style="font-size:18px"><?php echo get_cur_symbol($SALE->gross,$PP->ppCurrency); ?></span> <?php echo ($SALE->pictureShipping>0 ? '<br>('.$msg_sales30.' '.get_cur_symbol($SALE->pictureShipping,$PP->ppCurrency).')' : '<br>('.$msg_sales37.')'); ?><br><br>
     </td>
    </tr> 
    </table>
    </td>
</tr>
</table>    
</body>
</html>
