<?php 
$this->load->view("partial/header");
?>
<style>
.content_area_wrapper{
border-bottom: 0px solid #CCCCCC;
}
</style>

<div id="page_title" style="margin-bottom:8px;"><?php echo "NON Scaned Item Add"; ?></div>


<table width="100%">
<tr>
<td style="text-align:center; width:100%">
<?php echo form_open("reports/non_scaned_item_list", array('id' => 'add_item_form')); ?>
<label id="item_label" for="item">
    <?php
    echo $this->lang->line('sales_find_or_scan_item');
    ?>
</label>

<?php
echo form_input(array('name' => 'item', 'id' => 'item', 'size' => '65'));
?>
</form>

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

<?php
if (isset($error)) {
	echo "<div class='error_message' style='margin-top: 8px;padding: 4px;'>" . $error . "</div>";
}elseif (isset($warning)) {
	echo "<div class='warning_mesage' style='margin-top: 8px;padding: 4px;'>" . $warning . "</div>";
}elseif (isset($success)) {
	echo "<div class='success_message' style='margin-top: 8px;padding: 4px;'>" . $success . "</div>";
}
?>

<?php if(trim($item_description)){?>

<div id="page_subtitle" style="margin-bottom:8px;">

<table style='border-collapse: collapse; border: 2px solid #318ee1;width: 97%;margin: 12px;box-shadow: 0px 8px 8px #000;'>

<tr style="border: 0px solid #000000;border-collapse: collapse; color:#000000;background-color:#006882;color:#FFFFFF;">
		 <td colspan="2" style="border: 2px solid #318ee1;text-align:left;vertical-align: middle;width:100%;padding: 5px;">
			<font style="font-weight:bold;">Search Item Barcode : </font><font style="font-weight:normal;"><?php echo $search_item_code."@".$search_lot_no;?></font>
		 </td>
</tr>

<tr style="border: 0px solid #000000;border-collapse: collapse; color:#000000;">
		 <td style="border: 2px solid #318ee1;padding: 5px;text-align:left;vertical-align: middle;width:50%;background-color: #b9f1fe;">
			<font style="font-weight:bold;">Item Category : </font><font style="font-weight:normal;"><?php echo $cat_description;?></font>
		 </td>
		 <td style="border: 2px solid #318ee1;padding: 5px;text-align:left;vertical-align: middle;width:50%;background-color: #b9f1fe;">
			<font style="font-weight:bold;">Gender : </font><font style="font-weight:normal;"><?php echo $gender;?></font>
		 </td>
</tr>

<tr style="border: 0px solid #000000;border-collapse: collapse; color:#000000;">
		 <td style="border: 2px solid #318ee1;padding: 5px;text-align:left;vertical-align: middle;width:50%;background-color: #daf7fe;">
			<font style="font-weight:bold;">Item Name : </font><font style="font-weight:normal;"><?php echo $item_description;?></font>
		 </td>
		 <td style="border: 2px solid #318ee1;padding: 5px;text-align:left;vertical-align: middle;width:50%;background-color: #daf7fe;">
			<font style="font-weight:bold;">Item Size : </font><font style="font-weight:normal;"><?php echo $size;?></font>
		 </td>
</tr>

</table>

</div>
<?php 
if(count($product_in_local)){
?>

<div id="table-container" style="width:100%">
<table id="maintable" style='border-collapse: collapse; border: 2px solid #318ee1;width: 97%;margin: 12px;box-shadow: 0px 8px 8px #000;'>
    <thead>
        <tr>
			<th  style="background-color: #007c9b; color:#FFFFFF;font-size:14px; text-align:center;border: 2px solid #318ee1;border-collapse: collapse;height:31px;vertical-align: middle;">
			 Item Price 
			</th>
			<th  style="background-color: #007c9b; color:#FFFFFF;font-size:14px; text-align:center;border: 2px solid #318ee1;border-collapse: collapse;height:31px;vertical-align: middle;">
			 Quantity On Hand 
			</th>
		</tr>
	
    </thead>
    <tbody>

    <?php foreach ($product_in_local as $key => $value) {?>
    	
        <tr>
     	<td style=" font-weight:bold;color:#000000;font-size:14px; text-align:center;border: 1px solid #000000;border-collapse: collapse;padding:10px;vertical-align: middle;"> <?php echo number_format($value['item_price'],2,'.','');?></td>
     	<td style=" font-weight:bold;color:#000000;font-size:14px; text-align:center;border: 1px solid #000000;border-collapse: collapse;padding:10px;vertical-align: middle;"> <?php echo number_format($value['item_qoh'],2,'.','');?></td>
        </tr>
    
<?php }
?>

     </table>
     </div>

<?php
}elseif(count($product_in_own_location_in_live)){
?>

<div id="table-container" style="width:100%">
<table id="maintable" style='border-collapse: collapse; border: 2px solid #318ee1;width: 97%;margin: 12px;box-shadow: 0px 8px 8px #000;'>
    <thead>
        <tr>
			<th  style="background-color: #007c9b; color:#FFFFFF;font-size:14px; text-align:center;border: 2px solid #318ee1;border-collapse: collapse;height:31px;vertical-align: middle;">
			 Item Price 
			</th>
			<th  style="background-color: #007c9b; color:#FFFFFF;font-size:14px; text-align:center;border: 2px solid #318ee1;border-collapse: collapse;height:31px;vertical-align: middle;">
			 Quantity On LIVE SERVER
			</th>
		</tr>
	
    </thead>
    <tbody>

    <?php 
    
    foreach ($product_in_own_location_in_live as $key => $value) {?>
    	
        <tr>
     	<td style=" font-weight:bold;color:#000000;font-size:14px; text-align:center;border: 1px solid #000000;border-collapse: collapse;padding:10px;vertical-align: middle;"> <?php echo number_format($value->price,2,'.','');?></td>
     	<td style=" font-weight:bold;color:#000000;font-size:14px; text-align:center;border: 1px solid #000000;border-collapse: collapse;padding:10px;vertical-align: middle;"> <?php echo number_format($value->total_qty,2,'.','');?></td>
        </tr>
    
<?php }
?>

     </table>
     </div>

<?php
}elseif(count($product_in_non_sync_challlan)){
?>

<div id="table-container" style="width:100%">
<table id="maintable" style='border-collapse: collapse; border: 2px solid #318ee1;width: 97%;margin: 12px;box-shadow: 0px 8px 8px #000;'>
    <thead>
        <tr>
			<th  style="background-color: #007c9b; color:#FFFFFF;font-size:14px; text-align:center;border: 2px solid #318ee1;border-collapse: collapse;height:31px;vertical-align: middle;">
			 Challan No 
			</th>
			<th  style="background-color: #007c9b; color:#FFFFFF;font-size:14px; text-align:center;border: 2px solid #318ee1;border-collapse: collapse;height:31px;vertical-align: middle;">
			 Challan Date 
			</th>
			<th  style="background-color: #007c9b; color:#FFFFFF;font-size:14px; text-align:center;border: 2px solid #318ee1;border-collapse: collapse;height:31px;vertical-align: middle;">
			 Price
			</th>
			<th  style="background-color: #007c9b; color:#FFFFFF;font-size:14px; text-align:center;border: 2px solid #318ee1;border-collapse: collapse;height:31px;vertical-align: middle;">
			 Quantity On Challan
			</th>
		</tr>
	
    </thead>
    <tbody>

    <?php 
    
    foreach ($product_in_non_sync_challlan as $key => $value) {?>
    	
        <tr>
     	<td style=" font-weight:bold;color:#000000;font-size:14px; text-align:center;border: 1px solid #000000;border-collapse: collapse;padding:10px;vertical-align: middle;"> <?php echo $value->reference;?></td>
     	<td style=" font-weight:bold;color:#000000;font-size:14px; text-align:center;border: 1px solid #000000;border-collapse: collapse;padding:10px;vertical-align: middle;"> <?php echo date("d-M-Y",strtotime($value->tran_date));?></td>
     	<td style=" font-weight:bold;color:#000000;font-size:14px; text-align:center;border: 1px solid #000000;border-collapse: collapse;padding:10px;vertical-align: middle;"> <?php echo number_format($value->price,2,'.','');?></td>
     	<td style=" font-weight:bold;color:#000000;font-size:14px; text-align:center;border: 1px solid #000000;border-collapse: collapse;padding:10px;vertical-align: middle;"> <?php echo number_format($value->total_qty,2,'.','');?></td>
        </tr>
    
<?php }
?>

     </table>
     </div>

<?php
}elseif(count($found_in_cst)){
?>

<div id="table-container" style="width:100%">
<table id="maintable" style='border-collapse: collapse; border: 2px solid #318ee1;width: 97%;margin: 12px;box-shadow: 0px 8px 8px #000;'>
    <thead>
        <tr>
			<th  style="background-color: #007c9b; color:#FFFFFF;font-size:14px; text-align:center;border: 2px solid #318ee1;border-collapse: collapse;height:31px;vertical-align: middle;">
			 Price In Central Store
			</th>
			<th  style="background-color: #007c9b; color:#FFFFFF;font-size:14px; text-align:center;border: 2px solid #318ee1;border-collapse: collapse;height:31px;vertical-align: middle;">
			 Action
			</th>
		</tr>
	
    </thead>
    <tbody>

    <?php 
    
    foreach ($found_in_cst as $key => $value) {?>
    	
        <tr>
     	<td style=" font-weight:bold;color:#000000;font-size:14px; text-align:center;border: 1px solid #000000;border-collapse: collapse;padding:10px;vertical-align: middle;"> <?php echo number_format($value->price,2,'.','');?></td>
     	<td style=" font-weight:bold;color:#000000;font-size:14px; text-align:center;border: 1px solid #000000;border-collapse: collapse;vertical-align: middle;"> 
     	<?php 
				echo form_open('reports/add_non_scaned_item');
				echo form_hidden('trans_id', $value->trans_id);
				echo form_hidden('trans_no', $value->trans_no);
				echo form_hidden('type', $value->type);
				echo form_hidden('stock_id', $value->stock_id);
				echo form_hidden('lot_no', $value->lot_no);
				echo form_hidden('reference', $value->reference);
				echo form_hidden('tran_date', $value->tran_date);
				echo form_hidden('price', $value->price);
				echo form_hidden('standard_cost', $value->standard_cost);
				echo form_hidden('visible', $value->visible);
				echo form_hidden('is_imported', $value->is_imported);
				echo form_hidden('swatch_code', $value->swatch_code);
				?>
				<input type="submit" name="submit" value="<?php echo "ADD Your Database"; ?>" id="submit" onclick="return confirm('Are you sure to add item in your database?')"  class="button_thickbox_small button_thickbox_blue"></td>
				</form>
     	</td>
        </tr>
    
<?php }
?>

     </table>
     </div>

<?php
}
}
?>
 <div class="clearfix">&nbsp;</div>
<?php 
$this->load->view("partial/footer");
?>

<script type="text/javascript" language="javascript">
$(document).ready(function ()
{
	$(this).attr('value', "<?php echo $this->lang->line('sales_start_typing_item_name'); ?>");
	$("#find").blur(function () {
		var find_val = $(this).val();

		$("#button_find").attr('href', '<?php echo base_url(); ?>index.php/sales/globalsearch/' + find_val + '/width:480');
		$(this).attr('value', "<?php echo $this->lang->line('sales_start_typing_item_name'); ?>");
	});

	$("#recept_id").blur(function () {
		var find_val = $(this).val();

		$("#button_find").attr('href', '<?php echo base_url(); ?>index.php/sales/global_delivery/' + find_val + '/width:480');
		$(this).attr('placeholder', "<?php echo $this->lang->line('sales_start_typing_item_name'); ?>");
	});

	$('#item').bind('keyup', function() {

		var itemLength = $("#item").val().length;
		if(itemLength==14){
			if($("#item").val().match(/^\d+$/)) {
				$('#add_item_form').submit();
			}
		}
	});

	$("#item").autocomplete('<?php echo site_url("sales/item_search"); ?>',
	{
		minChars: 0,
		max: 100,
		selectFirst: false,
		delay: 10,
		formatItem: function (row) {
			//return row[1];
			return (row.length > 1 && row[1]) || row[0];
		}
	});


	$("#item").result(function (event, data, formatted)
	{
		$("#add_item_form").submit();
	});
	$('#item').focus();
	$('#find').focus();
	$('#recept_id').focus();

	$('#item').blur(function ()
	{
		$(this).attr('value', "<?php echo $this->lang->line('sales_start_typing_item_name'); ?>");
	});

	$("#find").autocomplete('<?php echo site_url("sales/item_search"); ?>',
	{
		minChars: 0,
		max: 100,
		selectFirst: false,
		delay: 10,
		formatItem: function (row) {
			return row[1];
		}
	});

	$('#check_date').datePicker();


	$('#item,#customer,#find,#recept_id').click(function ()
	{
		$(this).attr('value', '');

	});

	$("#customer").autocomplete('<?php echo site_url("sales/customer_search"); ?>',
	{
		minChars: 0,
		delay: 10,
		max: 100,
		formatItem: function (row) {
			return row[1];
		}
	});

	$("#customer").result(function (event, data, formatted)
	{
		$("#select_customer_form").submit();
	});

	$('#customer').blur(function ()
	{
		$(this).attr('value', "<?php echo $this->lang->line('sales_start_typing_customer_name'); ?>");
	});

	$('#comment').change(function ()
	{
		$.post('<?php echo site_url("sales/set_comment"); ?>', {comment: $('#comment').val()});
	});

	$('#receive_location').change(function ()
	{
		$.post('<?php echo site_url("sales/set_receive_location"); ?>', {receive_location: $('#receive_location').val()});
	});

	$('#email_receipt').change(function ()
	{
		$.post('<?php echo site_url("sales/set_email_receipt"); ?>', {email_receipt: $('#email_receipt').is(':checked') ? '1' : '0'});
	});


	$("#finish_sale_button").click(function ()
	{
		if (confirm('<?php echo $this->lang->line("sales_confirm_finish_sale"); ?>'))
		{
			$('#finish_sale_form').submit();
		}
	});
	$("#add_new_card_button").click(function ()
	{
		if (confirm('<?php echo "Are you sure you want to add this card? This cannot be undone."; ?>'))
		{
			$('#select_new_card_form').submit();
		}
	});

	$("#suspend_sale_button").click(function ()
	{
		if (confirm('<?php echo $this->lang->line("sales_confirm_suspend_sale"); ?>'))
		{
			$('#finish_sale_form').attr('action', '<?php echo site_url("sales/suspend"); ?>');
			$('#finish_sale_form').submit();
		}
	});

	$("#cancel_sale_button").click(function ()
	{
		if (confirm('<?php echo $this->lang->line("sales_confirm_cancel_sale"); ?>'))
		{
			$('#cancel_sale_form').submit();
		}
	});

	$("#edit_item_shawpon_button").click(function ()
	{
		$('#edit_item_shawpon_form').submit();
	});

	$("#add_payment_button").click(function ()
	{
		$('#add_payment_form').submit();
	});



	$("#payment_types").change(checkPaymentTypeGiftcard).ready(checkPaymentTypeGiftcard)
});

function post_item_form_submit(response)
{
	if (response.success)
	{
		$("#item").attr("value", response.item_id);
		$("#add_item_form").submit();
	}
}

function post_person_form_submit(response)
{
	if (response.success)
	{
		$("#customer").attr("value", response.person_id);
		$("#select_customer_form").submit();
	}
}
</script>
