<?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: searchsales.php
  Description: Search Sales
  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;
}
 
include(FOLDER_PATH.'inc/cal_array.inc.php'); 
 
?>
<div align="center">
<?php
//Display search results
if (isset($SEARCH_RESULTS))
{
?>
<table width="100%" border="0" cellpadding="1" cellspacing="1" style="border: 2px solid #083253">
<tr>
    <td align="left" class="msgBox">&raquo; <b><?php echo $msg_search6; ?></b><br><br><?php echo $msg_searchsales3; ?></td>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0" class="menutable">
<tr>
    <td align="left" width="80%" class="leftPad">&raquo; <b><?php echo strtoupper(str_replace("{count}", rowCount('ipndata',' '.$sql_string), $msg_search10)); ?></b></td>
    <td align="center" width="20%" class="leftPad" style="border-left:0">[ <a href="index.php?cmd=searchsales" title="<?php echo $msg_search7; ?>" style="color:#FFFFFF"><?php echo $msg_search7; ?></a> ]</td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="1" style="border: 2px solid #083253">
<?php

while ($SALES = mysql_fetch_object($q_search))
{
  $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="65%" 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>
    </tr>
    </table>
    </td>
</tr>
<?php
}
?>
</table>
<?php
  echo admin_page_numbers(rowCount('ipndata',' '.$sql_string),$limit,$page);
}
else
{
?>
<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_adminmenu18; ?></b><br><br><?php echo $msg_searchsales; ?></td>
</tr>
</table>
<?php
//Display message if no results were found
if (isset($NO_RESULTS))
{
?>
<table cellpadding="0" cellspacing="0" width="100%" class="updateTable" style="margin-bottom:2px">
<tr>
    <td align="center" style="padding:5px"><?php echo $msg_search5; ?></td>
</tr>
</table>
<?php
}
?>
<table width="100%" cellpadding="0" cellspacing="0" class="menutable">
<tr>
    <td align="left" class="leftPad">&raquo; <b><?php echo strtoupper($msg_search8); ?></b></td>
</tr>
</table>
<form method="get" action="index.php">
<input type="hidden" name="cmd" value="searchsales">
<input type="hidden" name="search" value="1">
<table width="100%" border="0" cellpadding="0" cellspacing="1" style="border: 2px solid #083253">
<tr>
    <td align="left" valign="top" class="msgBox">
    <table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td width="30%" align="left" class="tdHeight"><?php echo $msg_search2; ?>:</td>
        <td width="70%" align="left" class="tdHeight"><input class="formbox" type="text" name="keywords" size="25" value="<?php echo (isset($_GET['keywords']) ? cleanData($_GET['keywords']) : ''); ?>"></td>
    </tr>
    <tr>
        <td align="left" class="tdHeight"><?php echo $msg_searchsales2; ?>:</td>
        <td align="left" class="tdHeight"><select name="from_day">
        <option selected value="0"> - </option>
        <?php

        foreach ($days as $s_days)
        {
          echo '<option value="'.$s_days.'" style="padding-left:3px"'.(isset($_GET['from_day']) && $_GET['from_day']==$s_days ? ' selected="selected"' : '').'>'.$s_days.'</option>'."\n";
        }

        ?>
        </select>
        <select name="from_month">
        <option selected value="0"> - </option>
        <?php

        foreach ($months as $s_months => $s_months_value)
        {
          echo '<option value="'.$s_months.'" style="padding-left:3px"'.(isset($_GET['from_month']) && $_GET['from_month']==$s_months ? ' selected="selected"' : '').'>'.$s_months_value.'</option>'."\n";
        }
        
        ?>
        </select>
        <select name="from_year">
        <option selected value="0"> - </option>
        <?php

        foreach ($years as $s_years)
        {
          echo '<option value="'.$s_years.'" style="padding-left:3px"'.(isset($_GET['from_year']) && $_GET['from_year']==$s_years ? ' selected="selected"' : '').'>'.$s_years.'</option>'."\n";
        }

        ?>
        </select>
        </td>
    </tr>
    <tr>
        <td align="left" class="tdHeight">&nbsp;</td>
        <td valign="top" align="left" class="tdHeight"><select name="to_day">
        <option selected value="0"> - </option>
        <?php

        foreach ($days as $s_days)
        {
          echo '<option value="'.$s_days.'" style="padding-left:3px"'.(isset($_GET['to_day']) && $_GET['to_day']==$s_days ? ' selected="selected"' : '').'>'.$s_days.'</option>'."\n";
        }

        ?>
        </select>
        <select name="to_month">
        <option selected value="0"> - </option>
        <?php

        foreach ($months as $s_months => $s_months_value)
        {
          echo '<option value="'.$s_months.'" style="padding-left:3px"'.(isset($_GET['to_month']) && $_GET['to_month']==$s_months ? ' selected="selected"' : '').'>'.$s_months_value.'</option>'."\n";
        }
        
        ?>
        </select>
        <select name="to_year">
        <option selected value="0"> - </option>
        <?php

        foreach ($years as $s_years)
        {
          echo '<option value="'.$s_years.'" style="padding-left:3px"'.(isset($_GET['to_year']) && $_GET['to_year']==$s_years ? ' selected="selected"' : '').'>'.$s_years.'</option>'."\n";
        }

        ?>
        </select>
        </td>
    </tr>
    <tr>
        <td align="left" class="tdHeight">&nbsp;</td>
        <td align="left" class="tdHeight"><input type="submit" class="formbutton" value="<?php echo $msg_adminmenu18; ?>" title="<?php echo $msg_adminmenu18; ?>"></td>
    </tr>
    </table>
    </td>
</tr>
</table>
</form>
<?php
}
?>
</div>
