<?php
header("Content-type: text/html; charset=windows-1256");

//Report Version For MARIO
session_start();
if($_SESSION['dbName']==""){
header("location:../index.php");
}

print <<< HERE
<HTML>
<HEAD>
<TITLE> Slip Report </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">

<style type="text/css">

table.master h1 { font-size: 16px; 
                  font-weight: bold;
                  font-family:Times-New-Roman;
                }				 
				
table.master th { font-size: 12px; 
                  font-weight: bold;
                  font-family:Times-New-Roman;
                }				 
table.master td { font-size: 12px; 
                  font-family:Times-New-Roman;
                 }
table.detail th { font-size: 12px; 
                  font-weight: bold;
                  font-family:Times-New-Roman;
                }				 
				 
table.detail td { font-size: 12px; 
                  font-family:Times-New-Roman;
                 }				 
				 
				 
table.totals td.labels { font-size: 13px; 
                         font-weight: bold;
                         font-family:Times-New-Roman;
					  }					  
table.totals td.labels1 { font-size: 16px; 
                          font-weight: bold;
                          font-family:Times-New-Roman;
					   }					  					  
table.totals td.amounts { font-size: 13px; 
                          font-family:Times-New-Roman;
					    }
table.totals td.amounts1 { font-size: 16px; 
						   font-weight: bold;
                           font-family:Times-New-Roman;
					     }
table.totals p { border-width: 1px;
 				 border-style: none none dotted none;
				 border-color: #666666;
				}	
h4 { border-top-style: double; 
	 border-top-color: black; 
	 border-top-width: 1px;
   }				
				 
table.notes th { font-size: 12px; 
                 font-weight: bold;
                 font-family:Times-New-Roman;
                }				 
table.notes td { font-size: 12px; 
                 font-family:Times-New-Roman;
                }
</style>


</HEAD>

<BODY>
HERE;

include("config.inc.php");
include("function.inc.php");


$connection = mysql_connect($config['dbServer'],$config['dbUser'],$config['dbPass']) or die("Could not connect to DB");
mysql_select_db($_SESSION['dbName'],$connection) or die("Could not find DB");

/*$querylog=" Select FullName As User_FullName ".
          " From ".$_SESSION['dbLabel'].".login where user_account='".$_SESSION['useraccount']."' and Upper(Login_Schema) = Upper('".$_SESSION['dbName']."')  ";
$resultlog=mysql_query($querylog,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($resultlog)){
	extract($rows);
}*/


//Read From CashRegister Table
$queryCashRegister=" Select Upper(CashRegister_Name) As CashRegister_Name, Currency_Code As StpCurrCode, CostCenter_Code As StpCostCentCode, Project_Code As StpProjectCode, ".
                   " ifNull(CashRegister_BarCode,0) As CashRegisterBarCode, ifNull(CashRegister_SerialNo,0) As CashRegisterSerialNo, ifNull(CashRegister_Discount,0) As CashRegisterDiscount, ".
				   " CashRegisterTTC, Client_Account As StpClientAccount, ifNull(CashRegister_SlipPrinter,0) As CashRegister_SlipPrinter, ".
				   " ifNull(CashRegister_AutoPost,0) As CashRegister_AutoPost, ifNull(CashReg_Vendor,0) As CashReg_Vendor, ".
				   " ifNull(CashRegister_DisplayLed,0) As CashRegister_DisplayLed, ifNull(CashRegister_DispCOM,0) As CashRegister_DispCOM, ".
				   " ifNull(CashRegister_PrintBarcode,0) As CashRegister_PrintBarcode, ifNull(CashReg_ForcingVendor,0) As CashReg_ForcingVendor, ".
				   " ifNull(CashRegister_LedDescLength,0) As CashRegister_LedDescLength, ifNull(CashRegister_Printer,0) As CashRegister_Printer, ".
				   " ifNull(Module_CashRegisterFastItem,0) As Module_CashRegisterFastItem, ifNull(Module_RestaurantDelivery,0) As Module_RestaurantDelivery, ".
				   " ifNull(Module_CashRegisterStandardView,0) As Module_CashRegisterStandardView, ifNull(Module_CashRegisterTable,0) As Module_CashRegisterTable, ".
				   " ifNull(Module_CashRegAutoItemsList,0) As Module_CashRegAutoItemsList  ".
				   " From CashRegister ".
				   " Where CashRegister_Name = '".$_SESSION['cashregister']."' ";
				 //echo$queryCashRegister;
$resultCashRegister=mysql_query($queryCashRegister,$connection) or die(mysql_error());
while($rowCashRegister=mysql_fetch_array($resultCashRegister)){
	extract($rowCashRegister);
}


$queryusers=" Select User_Name As User_FullName ".
			" From ".$_SESSION['dbLabel'].".users where user_account='".$_SESSION['useraccount']."' ";
$resultusers=mysql_query($queryusers,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($resultusers)){
	extract($rows);
}


//Read From Setup Table							
$querysetup= " Select DecimalBase, DecimalBase1, DecimalBase2, base1, base2, grid_color1, grid_color2, ".
             " Company_Name As CompanyName, Company_Memo As CompanyMemo, Company_City As CompanyCity, ".
			 " Company_Telephone As CompanyTelephone, Company_Fax As CompanyFax, Company_Logo As CompanyLogo, ".
			 " Setup_VatNo, Setup_VatPercentage, ifNull(CashReg_RoundDivisor,1) As CashReg_RoundDivisor from setup ";
$resultsetup=mysql_query($querysetup,$connection) or die(mysql_error());
while($rowsetup=mysql_fetch_array($resultsetup)){
	extract($rowsetup);
}


//Read From CashRegister Table
$queryCashRegister=" Select ifNull(CashRegisterTTC,0) As CashRegisterTTC,ifNull(CashRegister_DrawerCOM,0) As CashRegister_DrawerCOM ".
				   " From CashRegister ".
				   " Where CashRegister_Name = '".$_SESSION['cashregister']."' ";
$resultCashRegister=mysql_query($queryCashRegister,$connection) or die(mysql_error());
while($rowCashRegister=mysql_fetch_array($resultCashRegister)){
	extract($rowCashRegister);
}

	
$now=current_server_time($connection);
$dt=split(" ",$now[0]);
$printdate=split("-",$dt[0]);

$TotalQty = 0;

$RetailId = $_GET['RetailId']; if ($RetailId == ""){$RetailId = $_POST["RetailId"];}

if($ic != '')
{
			 
	$query = "select item_description, Item_SellingPrice1Base1 from items where item_code = '".$ic."'  ";		 
			 
	$result=mysql_query($query,$connection) or die(mysql_error());
	while($rows=mysql_fetch_array($result)){
		extract($rows);
	}
	
		
	echo "<table border=0 width='250' cellspacing=0 cellpadding=0 class='master' style='table-layout:fixed;' >
		  <col width=250>";

		
	
	echo "<tr height=30px>
			<td align='center' valign='middle' style='border-top:1px solid black;'>$item_description</td>
		 </tr>";
	echo "<tr height=30px>
			<td align='center' valign='middle' style='border-bottom:1px solid black;'>".number_format($Item_SellingPrice1Base1, $DecimalBase1)."</td>
		</tr>";
	
	
	
	echo "</table>";
	echo "<br>";
	

}


function current_server_time($connection){

  $string="Select date_format(NOW(),'%Y-%m-%d %h:%i %p') ";
  $result=mysql_query($string,$connection) or die(mysql_error());
  $now=mysql_fetch_row($result);

  return $now;
}

function format_currency($amount, $DecimalBase) { 

    if($amount < 0) 
        return "(".number_format(abs($amount),$DecimalBase).")"; 
 
    else return number_format($amount, $DecimalBase); 
} 


print <<< HERE

<script language='VBScript'>
Sub Print()
       OLECMDID_PRINT = 6
       OLECMDEXECOPT_DONTPROMPTUSER = 2
       OLECMDEXECOPT_PROMPTUSER = 1
       call WB.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER,1)
End Sub
document.write "<object ID='WB' WIDTH=0 HEIGHT=0 CLASSID='CLSID:8856F961-340A-11D0-A96B-00C04FD705A2'></object>"
</script>

<script language=javascript>
if (typeof(window.print) != 'undefined')
{
    window.print();
	
	
}

//self.close();
</script>

</BODY>
</HTML>
HERE;


?>

