<?php
//
// +----------------------------------------------------------------------+
// |zen-cart Open Source E-commerce                                       |
// +----------------------------------------------------------------------+
// | Copyright (c) 2006 The zen-cart developers                           |
// |                                                                      |
// | http://www.zen-cart.com/index.php                                    |
// |                                                                      |
// | Portions Copyright (c) 2003 osCommerce                               |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license,       |
// | that is bundled with this package in the file LICENSE, and is        |
// | available through the world-wide-web at the following url:           |
// | http://www.zen-cart.com/license/2_0.txt.                             |
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to       |
// | license@zen-cart.com so we can mail you a copy immediately.          |
// +----------------------------------------------------------------------+
//  $Id: invoice.php 6251 2007-04-22 19:21:48Z wilt $
//
$posOnly = 1;
  require('includes/application_top.php');

  require(DIR_WS_CLASSES . 'currencies.php');
  $currencies = new currencies();

  $oID = zen_db_prepare_input($_GET['oID']);

  include(DIR_WS_CLASSES . 'order.php');
  $order = new order($oID);

  // prepare order-status pulldown list
  $orders_statuses = array();
  $orders_status_array = array();
  $orders_status = $db->Execute("select orders_status_id, orders_status_name
                                 from " . TABLE_ORDERS_STATUS . "
                                 where language_id = '" . (int)$_SESSION['languages_id'] . "'");
  while (!$orders_status->EOF) {
    $orders_statuses[] = array('id' => $orders_status->fields['orders_status_id'],
                               'text' => $orders_status->fields['orders_status_name'] . ' [' . $orders_status->fields['orders_status_id'] . ']');
    $orders_status_array[$orders_status->fields['orders_status_id']] = $orders_status->fields['orders_status_name'];
    $orders_status->MoveNext();
  }
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/menu.js"></script>
<script language="javascript" type="text/javascript"><!--
function couponpopupWindow(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=450,height=280,screenX=150,screenY=150,top=150,left=150')
}
function printnow()
{
	window.print();
}

//--></script>
</head>
<body onload="printnow()" marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">

<!-- body_text //-->
<!--<table border="0" width="100%" cellspacing="0" cellpadding="2">
  <tr>  <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>   <td class="pageHeading" align="center"><?php echo zen_image(DIR_WS_IMAGES . HEADER_LOGO_IMAGE, HEADER_ALT_TEXT); ?></td>
  </tr> </table></td>
  </tr>//-->

<table border="0" width="100%" cellspacing="0" cellpadding="2">
  <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr> <td align="center"><font size="4"><b><img src='http://black-tactical.com/store/admin/images/BTLOGO.GIF' );</b></font></td></tr>  
  <tr> <td align="center"><font size="4"><b><?php echo nl2br(STORE_NAME_ADDRESS); ?></b></font></td></tr>
  <tr> <td align="center"><font size="1">The Adelphi, 1 Coleman Street #04-36</font></td>  </tr> 
    <tr> <td align="center"><font size="1">Singapore 179803</font></td>  </tr> 
  </table></td>
  </tr>

  <tr> <td><table width="100%" border="0" cellspacing="0" cellpadding="2"> 
  <tr> <td colspan="2"><?php echo zen_draw_separator(); ?></td>
  </tr> 

<?php
      $order_check = $db->Execute("select cc_cvv, customers_name, customers_company, customers_street_address,
                                    customers_suburb, customers_city, customers_postcode,
                                    customers_state, customers_country, customers_telephone,
                                    customers_email_address, customers_address_format_id, delivery_name,
                                    delivery_company, delivery_street_address, delivery_suburb,
                                    delivery_city, delivery_postcode, delivery_state, delivery_country,
                                    delivery_address_format_id, billing_name, billing_company,
                                    billing_street_address, billing_suburb, billing_city, billing_postcode,
                                    billing_state, billing_country, billing_address_format_id,
                                    payment_method, cc_type, cc_owner, cc_number, cc_expires, currency,
                                    currency_value, date_purchased, orders_status, last_modified
                             from " . TABLE_ORDERS . "
                             where orders_id = '" . (int)$oID . "'");
  $show_customer = 'false';
  if ($order_check->fields['billing_name'] != $order_check->fields['delivery_name']) { $show_customer = 'true';  }
  if ($order_check->fields['billing_street_address'] != $order_check->fields['delivery_street_address']) { $show_customer = 'true';  }
  if ($show_customer == 'true') {?>


 <?php } ?>

 <!--      <tr> <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="2" font size="4">
          <tr> <td class="main"><font size="2"><b><?php echo ENTRY_SOLD_TO; ?></b></td></tr>
          <tr> <td class="main"><font size="2"><?php echo zen_address_format($order->customer['format_id'], $order->billing, 1, '', '<br>'); ?></td></tr>
          <tr> <td class="main"><font size="2"><?php echo $order->customer['telephone']; ?></td> </tr>
         </table></td>

        <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="2">
          <tr><td class="main"><font size="2"><b><?php echo ENTRY_SHIP_TO; ?></b></td>  </tr>
          <tr><td class="main"><font size="2"><?php echo zen_address_format($order->delivery['format_id'], $order->delivery, 1, '', '<br>'); ?></td>
          </tr></table></td></tr> </table></td></tr>

-->




  <tr><td><table border="0" cellspacing="0" cellpadding="2">
  <tr> <td class="main"><font size="2"><b>Sold To:</b> <?php echo $order->customer['name']; ?></td></tr>
    <tr><td class="main"><font size="2"><b>Order:</b>&nbsp<?php echo $oID; ?></td>  </tr>
      <tr><td class="main"><font size="2"><strong>Date:</strong>&nbsp<?php echo zen_date_long($order->info['date_purchased']); ?></td>

      <tr><td class="main"><font size="2"><b><?php echo ENTRY_PAYMENT_METHOD; ?></b>&nbsp<?php echo $order->info['payment_method']; ?></td>

      </tr></table></td></tr>



  <tr><td><table border="0" style="border:1px #000000 solid" width="100%" cellspacing="0" cellpadding="2">
      <tr class="dataTableHeadingRow"style="border:1px #000000 solid">
        <td class="dataTableHeadingContent" style="border:1px #000000 solid" bgcolor="#C0C0C0" colspan="2"><font size="2"><?php echo TABLE_HEADING_PRODUCTS; ?></td>
        <td class="dataTableHeadingContent" style="border:1px #000000 solid" bgcolor="#C0C0C0" align="right"><font size="2"><?php echo 'Price'; ?></td>
        <td class="dataTableHeadingContent" style="border:1px #000000 solid" bgcolor="#C0C0C0" align="right"><font size="2"><?php echo 'Total'; ?></td>    </tr>

<?php
    for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {
      echo '      <tr class="dataTableRow">' . "\n" .
           '      <td class="dataTableContent"  style="border:1px #000000 solid" bgcolor="#FFFFFF" valign="top" align="right" ><font size="1">' . $order->products[$i]['qty'] . '&nbsp;x</td>' . "\n" .
           '      
		   <td class="dataTableContent"  style="border:1px #000000 solid" bgcolor="#FFFFFF" valign="top"><font size="1">' . $order->products[$i]['name'];
      if (isset($order->products[$i]['attributes']) && (($k = sizeof($order->products[$i]['attributes'])) > 0)) { for ($j = 0; $j < $k; $j++) {
          echo '<br><nobr><small>&nbsp;<i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . nl2br(zen_output_string_protected($order->products[$i]['attributes'][$j]['value']));
          if ($order->products[$i]['attributes'][$j]['price'] != '0') echo ' (' . $order->products[$i]['attributes'][$j]['prefix'] . $currencies->format($order->products[$i]['attributes'][$j]['price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . ')';
          if ($order->products[$i]['attributes'][$j]['product_attribute_is_free'] == '1' and $order->products[$i]['product_is_free'] == '1') echo TEXT_INFO_ATTRIBUTE_FREE;
          echo '</i></small></nobr>';
        } }


		if($order->products[$i]['products_warrenty'] != "")
		{
			echo("<br><nobr><small>&nbsp;<i> - Warranty: ".$order->products[$i]['products_warrenty']."</i></small></nobr>");
		}

      echo '        <td class="dataTableContent"  style="border:1px #000000 solid" bgcolor="#FFFFFF" align="right" valign="top"><font size="1">' .
                      $currencies->format(zen_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']) .
                      ($order->products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->format(zen_add_tax($order->products[$i]['onetime_charges'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']) : '') .
                    '</td>' . "\n" .

           '         <td class="dataTableContent"  style="border:1px #000000 solid" bgcolor="#FFFFFF" align="right" valign="top"><font size="1">' .
                      $currencies->format(zen_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']) * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) .
                      ($order->products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->format(zen_add_tax($order->products[$i]['onetime_charges'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']) : '') .
                    '</td>' . "\n";
      echo '      </tr>' . "\n";
    }
?>
      
     </table>
	
	 <table border="0" align="right" width="100%" cellspacing="0" cellpadding="2">
<?php
  for ($i = 0, $n = sizeof($order->totals); $i < $n; $i++) {
    echo '          <tr>' . "\n" .
         '            <td align="right" class="'. str_replace('_', '-', $order->totals[$i]['class']) . '-Text"><b><font size="2">' . $order->totals[$i]['title'] . '</b></td>' . "\n" .
         '            <td align="right" class="'. str_replace('_', '-', $order->totals[$i]['class']) . '-Amount"><font size="2">' . $order->totals[$i]['text'] . '</td>' . "\n" .
         '          </tr>' . "\n";
  }
?>
    </table></td></tr>


		


			
		<table border="0" width="100%" cellspacing="0" cellpadding="2">
<br>
<?php echo zen_draw_separator(); ?>
  <tr>  <td align="left"><font size="2">
  Kindly double check your items are received in good condition before leaving the store.</td>
		
		
  </tr> </table></td>
  </tr></td> </tr>
	 


</table>
<!-- body_text_eof //-->

<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
