<?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: sales.php
  Description: View Sales

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

// Make sure that this file is being called from parent file
if (!defined('INCLUDE_FILES')) {
  accessDenied($msg_script18,$msg_script19);
  exit;
}
 
?>
<div align="center">
<table width="100%" border="0" cellpadding="0" cellspacing="1" style="border: 2px solid #083253">
<tr>
    <td align="left" class="msgBox">&raquo; <b><?php echo $msg_adminmenu12; ?></b><br><br><?php echo $msg_sales; ?></td>
</tr>
</table>
<table cellpadding="0" cellspacing="1" width="100%" class="menutable">
<tr>
    <td align="left" class="leftPad">&raquo; <b><?php echo strtoupper($msg_sales2); ?></b></td>
</tr>
</table>
<?php
$q_sales = mysql_query("SELECT *,DATE_FORMAT(pay_date,'".$SETTINGS->mysql_date."') AS s_date 
                        FROM ".$database['prefix']."ipndata 
                        WHERE activeCart = '1'
                        ORDER BY status ASC,id DESC
                        LIMIT $limitvalue,$limit
                        ") or die(mysql_error());
?>
<form method="POST" action="index.php?cmd=sales" onsubmit="return delete_confirm('<?php echo $msg_javascript; ?>')">
<input type="hidden" name="process" value="1">
<table width="100%" border="0" cellpadding="0" cellspacing="1" style="border: 2px solid #083253">
<?php

if (mysql_num_rows($q_sales)>0)
{
  while ($SALES = mysql_fetch_object($q_sales))
  {
    $q_ptotal = mysql_query("SELECT SUM(pictureQty) AS qty 
                             FROM ".$database['prefix']."purchases
                             WHERE cartID = '{$SALES->cartID}'
                             ") or die(mysql_error());
    $PTOTAL = mysql_fetch_object($q_ptotal);
  ?>
  <tr>
    <td align="center" class="msgBox">
    <table width="100%" cellspacing="0" cellpadding="0">
    <tr>
      <td align="left" width="60%" class="tdHeight">
      <b><?php echo $msg_sales7; ?></b>: <a href="mailto:<?php echo $SALES->email; ?>" title="<?php echo $msg_header3; ?>"><?php echo cleanData($SALES->first_name.' '.$SALES->last_name); ?></a><br />
      <b><?php echo $msg_sales8; ?></b>: <?php echo $PTOTAL->qty; ?><br />
      <b><?php echo $msg_sales9 ?></b>: <?php echo get_cur_symbol($SALES->gross,$PP->ppCurrency); ?> / <?php echo get_cur_symbol($SALES->fee,$PP->ppCurrency); ?> / <?php echo get_cur_symbol($SALES->pictureShipping,$PP->ppCurrency); ?><br />
      <b><?php echo $msg_sales10; ?></b>: 
      <?php
      switch ($SALES->status) {
        case '0': echo $msg_sales12; break;
        case '1': echo $msg_sales13; break;
        case '2': echo $msg_sales14; break;
      }
      ?>
      <br />
      <b><?php echo $msg_sales11; ?></b>: <?php echo $SALES->s_date; ?> / <?php echo cleanData($SALES->invoice); ?><br />
      </td>
      <td align="left" width="35%">
      <table width="100%" cellspacing="0" cellpadding="0">
      <tr>
        <td align="center" style="height:65px;width:50%;border:2px solid #083253"><a href="index.php?cmd=sales&amp;status=<?php echo $SALES->id; ?>" title="<?php echo $msg_sales5; ?>" rel="gb_page_center[680, 400]"><?php echo $msg_sales5; ?></a></td>
        <td style="width:1px">&nbsp;</td>
        <td align="center" style="height:65px;width:50%;border:2px solid #083253"><a href="index.php?cmd=sales&amp;view=<?php echo $SALES->id; ?>" title="<?php echo $msg_sales6; ?>" rel="gb_page_center[680, 550]"><?php echo $msg_sales6; ?></a></td>
      </tr>
      </table>
      </td>
      <td align="center" class="tdHeight"><input type="checkbox" name="id[]" value="<?php echo $SALES->id; ?>##<?php echo $SALES->cartID; ?>"></td>
    </tr>
    </table>
    </td>
  </tr>
  <?php
  }
}
else
{

?>
<tr>
    <td align="center" class="msgBox">[ <?php echo $msg_sales3; ?> ]</td>
</tr>
<?php
}
?>
</table>
<?php
// page numbers..
if (rowCount('ipndata',' WHERE activeCart = \'1\'')>0) {
  echo '<p align="right" class="pbutton"><input class="formbutton" type="submit" value="'.$msg_sales4.'" title="'.$msg_sales4.'"></p>';
  echo admin_page_numbers(rowCount('ipndata',' WHERE activeCart = \'1\''),$limit,$page);
}
?>
</form>
</div>
