<?php session_start(); ?> <!-- session start -->
<?php include("../include/config.php"); ?> <!-- database connection -->
<?php include("../include/connect_url.php"); ?> <!-- connection url/link folder -->
<?php include("../include/date_time.php"); ?> <!-- date & time format -->
<?php include("../database/account.php"); ?> <!-- query database account -->
<?php include("../include/lang.php"); ?> <!-- language -->
<?php include("../include/session_login.php"); ?> <!-- session login -->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<title><?php include("../template/title.php"); ?></title>

<link rel="shortcut icon" href="<?php echo $connect_url_data; ?>/favicon.ico" />

<link href="<?php echo $connect_url_data; ?>/css/styles.css" rel="stylesheet" type="text/css" />
<!--[if IE]> <link href="<?php echo $connect_url_data; ?>/css/ie.css" rel="stylesheet" type="text/css"> <![endif]-->
<link rel="stylesheet" href="<?php echo $connect_url_data; ?>/font/font-awesome-4.3.0/css/font-awesome.min.css">

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/download/jquery183.js"></script> 
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/download/jquery192.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/charts/excanvas.min.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/charts/jquery.flot.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/charts/jquery.flot.orderBars.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/charts/jquery.flot.pie.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/charts/jquery.flot.resize.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/charts/jquery.sparkline.min.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/tables/jquery.dataTables.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/tables/jquery.sortable.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/tables/jquery.resizable.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.autosize.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.uniform.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.inputlimiter.min.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.tagsinput.min.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.maskedinput.min.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.autotab.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.select2.min.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.dualListBox.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.cleditor.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.ibutton.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.validationEngine-en.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.validationEngine.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/globalize/globalize.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/globalize/globalize.culture.de-DE.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/globalize/globalize.culture.ja-JP.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/uploader/plupload.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/uploader/plupload.html4.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/uploader/plupload.html5.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/uploader/jquery.plupload.queue.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/wizards/jquery.form.wizard.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/wizards/jquery.validate.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/wizards/jquery.form.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.collapsible.min.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.breadcrumbs.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.tipsy.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.progress.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.timeentry.min.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.colorpicker.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.jgrowl.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.fancybox.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.fileTree.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.sourcerer.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/others/jquery.fullcalendar.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/others/jquery.elfinder.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.mousewheel.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.easytabs.min.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/files/bootstrap.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/files/functions.js"></script>

</head>

<body>

<!-- header-->
<?php include("../template/header.php"); ?>

<!-- sidebar-->
<?php include("../template/sidebar.php"
	      ); ?>
   
<!-- Content begins -->
<div id="content">
    
    <!-- Breadcrumbs line -->
    <div class="breadLine">
        <div class="bc">
            <ul id="breadcrumbs" class="breadcrumbs">
              <li><a href="<?php echo $connect_url_data; ?>/dashboard"><?php echo $lang['Dashboard']; ?></a></li>
                <li><a href="<?php echo $connect_url_data; ?>/item"><?php echo $lang['Item']; ?></a></li>
                <li class="current"><a href="#"><?php echo $lang['Create Item']; ?></a></li>
				
            </ul>
        </div>
        
<!-- breaklink -->
<?php include("../menu/breadlink.php"); ?>
	
    </div>
    
    <!-- Main content -->
    <div class="wrapper">

<?php
if($_POST)
{
//item
$query_item1= mysql_query("SELECT * FROM tbl_item");
while($row= mysql_fetch_assoc($query_item1))
{
    $db_item1_id= $row['id'];
}
    $db_item1_id_add = $db_item1_id + 1;
    $db_item1_id_add_comp = "$date_year$db_item1_id_add";
    
$barcode =mysql_real_escape_string($_POST['barcode']); 
$item =mysql_real_escape_string(ucwords($_POST['item']));
$description =mysql_real_escape_string($_POST['description']);
$item_category =$_POST['item_category'];


//number format
include("../include/number_format.php");



if($item==""){
die ("<script> alert('Please fill item.');
window.location.href='javascript:history.back();';		
</script> ");
}

//create item
$query_insert = mysql_query("
  INSERT INTO tbl_item VALUES ('','$db_item1_id_add_comp','$barcode','$item','$description','$item_category','$db_user_id','$date','$time','1');
");

$mysql_insert_id = mysql_insert_id();

//price
$query_insert = mysql_query("
  INSERT INTO tbl_item_price VALUES ('','$mysql_insert_id','$price_nf','$db_user_id','$date','$time','1');
");



die ("<script> alert('Saved.');
window.location.href='$connect_url_data/item';		
</script> ");
}
?>

<form name="form" id="form" action="<?php echo $connect_url_data; ?>/create-item" class="main" method="POST"  enctype="multipart/form-data">
            <fieldset>
                <div class="widget fluid">
                    <div class="whead"><h6><span class="icos-add" style="margin-top:-2px;"></span>&nbsp; <?php echo $lang['Create Item']; ?></h6></div>
               
		   <div class="formRow">
                        <div class="grid2"><label><?php echo $lang['Barcode']; ?>:</label></div>
                        <div class="grid10"><input type="text" name="barcode" id="barcode"/></div>
                    </div>
	       
		    <div class="formRow">
                        <div class="grid2"><label><?php echo $lang['Item Name']; ?>:</label></div>
                        <div class="grid10"><input type="text" name="item" id="item"/></div>
                    </div>
		    
		    <div class="formRow">
                        <div class="grid2"><label><?php echo $lang['Description']; ?>:</label></div>
                        <div class="grid10">
                            <textarea rows="8" cols="" name="description" id="description" class="auto lim"></textarea>
                            <span class="note" id="limitingtext">Field limited to 100 characters.</span>
                        </div>
                    </div>
		    
		   <div class="formRow">
                            <div class="grid2"><label><?php echo $lang['Category']; ?>:</label></div>
                            <div class="grid10">
                               <?php
				$query_item_category1=mysql_query("SELECT * FROM tbl_item_category ORDER BY item_category ASC");
				$option_item_category1="";
				while($row=mysql_fetch_array($query_item_category1)) {
				$option_item_category1 .= "<option value='$row[id]'";
				$option_item_category1 .= ">". $row['item_category'] ."</option>";  }
				?>    
				<select name="item_category" id="item_category"  data-placeholder="Choose" class="select" tabindex="2" style="width:100%;">
                                <option value=""></option> 
				<?php echo $option_item_category1; ?>
				</select>
                            </div>             
                    </div>
		 
		   
		    <div class="formRow">
                        <div class="grid2"><label><?php echo $lang['Price']; ?>:</label></div>
                        <div class="grid10"><input type="text" name="price" id="price" placeholder="<?php echo $db_currency_code1; ?><?php echo $db_number_format_number_format; ?>"/></div>
                    </div>
		   
		    <div class="formRow">
                    <div class="grid2"><br /></div>
                    <div class="grid10">
				<a href="#" class="buttonM bBlue" onclick="document.getElementById('form').submit();"><span class="fa fa-save"></span><span><?php echo $lang['Save']; ?></span></a>
		        <a href="#" class="buttonM bBlue" onclick="window.location.href='<?php echo $connect_url_data; ?>/item'"><span class="fa fa-times-circle"></span><span><?php echo $lang['Cancel']; ?></span></a>
		    </div>
		    
		    </div>
                  
                </div>
            </fieldset>

	    
	    
        </div>
	
    </div>
    <!-- Main content ends -->
    
</div>
<!-- Content ends -->  
             
</body>
</html>
