<?php
session_name("AUTHENUSER");
session_start();
$USERNAME = $_SESSION['SES_USERNAME'];
$act = $_REQUEST['act'];
if(!session_name("AUTHENUSER"))
	{
?>
						<script language="javascript">
						 alert("Waktu Login telah habis.Silahkan Login Kembali");
						document.location="index.php";
						</script>
<?php
	}
if(!$USERNAME)
	{
?>
						<script language="javascript">
						 alert("Harap Login Dahulu.");
						document.location="index.php";
						</script>
<?php
	}

		
	if($act != 1)
	{
		$barcodeno = $_REQUEST['barcodeno'];
		$weight = $_REQUEST['weight'];	
		$cbprice = $_REQUEST['cbprice'];	
		$lbprice = $_REQUEST['lbprice'];
		//$description = $_REQUEST['description'];
	?>
	<script language="javascript">
	var r=confirm("Do you want to print description?")
	if (r==true)
	  {
	  document.location="printfont.php?print=1&act=1&barcodeno=<?php echo $barcodeno; ?>&cbprice=<?php echo $cbprice; ?>&lbprice=<?php echo $lbprice; ?>&weight=<?php echo $weight; ?>&description=<?php echo $description; ?>";
	  }
	else
	  {
	  document.location="printfont.php?print=2&act=1&barcodeno=<?php echo $barcodeno; ?>&cbprice=<?php echo $cbprice; ?>&lbprice=<?php echo $lbprice; ?>&weight=<?php echo $weight; ?>&description=<?php echo $description; ?>";
	  }
	</script>
    <?php } ?>
 <?php include 'common/config.php'?><html>
 <?php
 if($act == 1)
{
	?>
<head>
	<title>Print Barcode</title>
    <style type="text/css">
body,td,th {
	font-size: 7px;
	font-family:Arial, Helvetica, sans-serif;
}

p {padding: 0 0 0 0; margin-bottom: 0; margin-top: 0}

</style>
</head>
<body>
<?php 

 define (__TRACE_ENABLED__, false);
 define (__DEBUG_ENABLED__, false);
								   
 require("barcode.php");		   
 require("i25object.php");
 require("c39object.php");
 require("c128aobject.php");
 require("c128bobject.php");
 require("c128cobject.php");
		$barcodeno = $_REQUEST['barcodeno'];
		$weight = $_REQUEST['weight'];	
		$cbprice = $_REQUEST['cbprice'];	
		$lbprice = $_REQUEST['lbprice'];
		$print = $_REQUEST['print'];
		//$description = $_REQUEST['description'];

		$sql = mysql_fetch_array(mysql_query("select * from (select kode_stock,barcodeno,description,weight,rapprice as cbprice,lbprice from inventory_diamond where status_stock=1  
						union all
						select kode_stock,barcodeno,description,weight,cbprice,'0' as lbprice from inventory_gold where status_stock=1
						union all
						select kode_stock,barcodeno,description,weight,cbprice,'0' as lbprice from inventory_logam where status_stock=1 
						union all
						select kode_stock,barcodeno,description,weight,cbprice,lbprice from inventory_readyitem where status_stock=1 
						union all
						select kode_stock,barcodeno,description,weight,cbprice,lbprice from inventory_gkgr where status_stock=1 
						union all
						select kode_stock,barcodeno,description,weight,cbprice,lbprice from inventory_kerabu where status_stock=1 
						union all
						select kode_stock,barcodeno,description,weight,cbprice,lbprice from inventory_liontin where status_stock=1 
						union all
						select kode_stock,barcodeno,description,weight,cbprice,lbprice from inventory_mastura where status_stock=1 
						union all
						select kode_stock,barcodeno,description,weight,cbprice,lbprice from inventory_rangka where status_stock=1 
						union all
						select kode_stock,barcodeno,description,weight,cbprice,lbprice from inventory_cincin where status_stock=1 
						) a 
					where barcodeno = '$barcodeno' order by kode_stock"));

				$description = $sql['description'];
		if($print == 1)
		{
			$description1 = $sql['description'];
			//echo $description1; 
		}
		else
		{
			$description1 = "";
		}
		
		$cbprice = $sql['cbprice'];
			$cbprice0 = str_replace('0','O',$cbprice); 
			$cbprice1 = str_replace('1','I',$cbprice0);
			$cbprice2 = str_replace('2','G',$cbprice1);
			$cbprice3 = str_replace('3','S',$cbprice2);
			$cbprice4 = str_replace('4','C',$cbprice3);
			$cbprice5 = str_replace('5','U',$cbprice4);
			$cbprice6 =  str_replace('6','L',$cbprice5);
			$cbprice7 = str_replace('7','T',$cbprice6);
			$cbprice8 = str_replace('8','P',$cbprice7);
			$cbprice9 = str_replace('9','K',$cbprice8);
		$lbprice = $sql['lbprice'];
				$lbprice0 = str_replace('0','O',$lbprice); 
				$lbprice1 = str_replace('1','I',$lbprice0);
				$lbprice2 = str_replace('2','G',$lbprice1);
				$lbprice3 = str_replace('3','S',$lbprice2);
				$lbprice4 = str_replace('4','C',$lbprice3);
				$lbprice5 = str_replace('5','U',$lbprice4);
				$lbprice6 =  str_replace('6','L',$lbprice5);
				$lbprice7 = str_replace('7','T',$lbprice6);
				$lbprice8 = str_replace('8','P',$lbprice7);
				$lbprice9 = str_replace('9','K',$lbprice8);
	$insert = mysql_query("insert into print_barcode (barcodeno,user_print) values ('$barcodeno','$USERNAME')");					  
/* Default value */
if (!isset($output))  $output   = "png"; 
if (!isset($barcode)) $barcode  = $barcodeno;
if (!isset($type))    $type     = "C128C";
if (!isset($width))   $width    = "150";
if (!isset($height))  $height   = "40";
if (!isset($xres))    $xres     = "1";
if (!isset($font))    $font     = "3";
/*********************************/ 
									
if (isset($barcode) && strlen($barcode)>0) {    
  $style  = BCS_ALIGN_CENTER;					       
  $style |= ($output  == "png" ) ? BCS_IMAGE_PNG  : 0; 
  $style |= ($output  == "jpeg") ? BCS_IMAGE_JPEG : 0; 
  $style |= ($border  == "on"  ) ? BCS_BORDER 	  : 0; 
  $style |= ($drawtext== "on"  ) ? BCS_DRAW_TEXT  : 0; 
  $style |= ($stretchtext== "on" ) ? BCS_STRETCH_TEXT  : 0; 
  $style |= ($negative== "on"  ) ? BCS_REVERSE_COLOR  : 0; 
  
  switch ($type)
  {
    case "I25":
			  $obj = new I25Object(250, 120, $style, $barcode);
			  break;
    case "C39":
			  $obj = new C39Object(250, 120, $style, $barcode);
			  break;
    case "C128A":
			  $obj = new C128AObject(250, 120, $style, $barcode);
			  break;
    case "C128B":
			  $obj = new C128BObject(250, 120, $style, $barcode);
			  break;
    case "C128C":
              $obj = new C128CObject(250, 120, $style, $barcode);
			  break;
	default:
			$obj = false;
  }

    if ($obj) {
     if ($obj->DrawObject($xres)) {
	 
	//$description2=str_replace('|', '<br>', $description);
	//$description2=str_replace('|', '<br>', $description);
	//$description = "fgshsgsg sgshaa aaarete tyreue ueueutedsfs retshfd hxfdgd";
	 
		//echo $sql['description']; exit;
		
         echo "<table style='width:150px;table-layout:fixed;nowrap:nowrap' cellpadding='0' cellspacing='0' border='0'>
		 <tr><td align='center'>
		 <img  width='150' height='20' align='center'  src='./image.php?code=".$barcode."&style=".$style."&type=".$type."&width=".$width."&height=".$height."&xres=".$xres."&font=".$font."'>
		 </td>
		 </tr> 
	<tr>
    <td align='center' style='font-size:8px'><b>".$barcodeno."</b></td>
  </tr>
	<tr>
    <td align='center' style='font-size:8px'><b>CB : ".$cbprice9." &nbsp; &nbsp;LB : ".$lbprice9."</b></td>
  </tr>
		<tr>
		 <td height='2px'></td>
		</tr>
  <tr>
    <td align='center'>Weight : ".$weight." gr</td>
  </tr>
		<tr>
		 <td height='5px'></td>
		</tr>
  <tr>
    <td align='center' style='nowrap='nowrap' style='padding-left:6px'>
				".$description1."
				</td>
  </tr>
  </table>"; //exit;
     } else echo "<table align='center'><tr><td><font color='#FF0000'>".($obj->GetError())."</font></td></tr></table>";
  }
}
//exit;
?>
</body>
<?php

 include "common/include/template.php";
	$temp=new template;
	$temp->define_theme("themes/themeprint.html");
	$temp->define_tag("{PAGE_TITLE}", $webtitle);
	$temp->define_tag("{APPCONTENT}", $content);
	$temp->parse();
	$temp->printproses();
}
?>
</html>

