<?php 
session_start();
require_once("../../includes/display_internal_user_dryout.inc.php");
require_once("../../includes/functions_internal_user_dryout.inc.php");
$obj = new data();
$connect = $obj->funConnect();
$display = new display();
$display->logout_iu();
$pagename = basename($_SERVER['PHP_SELF']);
$msg = NULL; 



if(@$_REQUEST['action2'] == 'submit1')
{
	$msg = $obj->insertPurchaseInvDetails();
	// $msg = explode("_",$msg);
	header('Location:./purchase_invoice.php?msg='.$msg);
}


$creator = $obj->getUserAuthority($_SESSION['uid'], 'PUR_CHK_CRETR');

?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title><?php $display->title(); ?></title>
<?php $display->favicon(); ?>
<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
<?php $display->css(); ?>
<link href="../../css/datatables/dataTables.bootstrap.css" rel="stylesheet" type="text/css" />
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
  <script src="../js/html5shiv.js"></script>
  <script src="../js/respond.min.js"></script>
<![endif]-->
</head>
    <body class="skin-blue fixed">
        <!-- header logo: style can be found in header.less -->
        <?php $display->header_tag(); ?>
		<div class="wrapper row-offcanvas row-offcanvas-left">
            <?php $display->leftmenu(420); ?>
			<aside class="right-side">                
                <!-- Content Header (Page header) -->
                <section class="content-header">
                    <h1>
                        <i class="fa fa-suitcase"></i>&nbsp;Purchase Order&nbsp;&nbsp;&nbsp;&nbsp;<small><div class="headline text-center" id="time" style="color:#000; font-weight:bold; font-size:12px;"></div></small>
                    </h1>
                    <ol class="breadcrumb">
                        <li><a href="#"><i class="fa fa-home"></i> Home</a></li>
                        <li class="active">Purchase Order</li>
                    </ol>
                </section>

                <!-- Main content -->
                <section class="content">
				<!--   content put here..................-->
				<?php if(isset($_REQUEST['msg'])){
						$msg = $_REQUEST['msg'];
						if($msg == 0){?>
				<div class="alert alert-success alert-dismissable">
					<i class="fa fa-check"></i>
					<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
					<b>Congratulations!</b>  Purchase Order added/updated successfully.
				</div>
				<?php }?>
				<?php if($msg == 1){?>
				<div class="alert alert-danger alert-dismissable">
					<i class="fa fa-ban"></i>
					<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
					<b>Sorry!</b> there was an error while adding/updating Purchase Order.
				</div>
				<?php }}?>
				<div class="box box-primary">
				<h3 style=" text-align:center;">Purchase Order</h3>
			

				<div align="right"><a href="add_purchase_order.php" title="Add New"><button class="btn btn-info btn-flat">Add New</button></a>&nbsp;&nbsp;&nbsp;&nbsp;</div>


				<div style="height:10px;">&nbsp;</div>

				
				<?php $obj->displayPurchaseOrderList();?>
				</div>				
				<!--   content ends here..................-->
                </section><!-- /.content -->
            </aside><!-- /.right-side -->
        </div><!-- ./wrapper -->

			<div class="modal fade" id="compose-modal" tabindex="-1" role="dialog" aria-hidden="true">
						<div class="modal-dialog">
							<div class="modal-content">
								<div class="modal-header">
									<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
								</div>
								<div class="modal-body">
									<form name="frm2" id="frm2" enctype="multipart/form-data" action="<?php echo $pagename;?>" method="post"/>
                                        <div id="divPayment">
                                            
                                        </div>
                                        <div class="box-footer" align="right">
                                            <button type="submit" id="btnhide" class="btn btn-primary btn-flat" onClick="return getValid();" >Submit</button>
                                            <input type="hidden" id="action2" name="action2" value="submit1" />
                                            <input type="hidden" name="txtCRMFILE1" id="txtCRMFILE1" value="" />
                                            <input type="hidden" name="txtCRMNAME1" id="txtCRMNAME1" value="" />
                                            <input type="hidden" id="tblid" name="tblid" value=""/>
                                        </div>
									</form>
								</div>
							</div><!-- /.modal-content -->
						</div><!-- /.modal-dialog -->
					</div>


<?php $display->footer(); ?>
<?php $display->js(); ?>
<script src="../../js/plugins/datatables/jquery.dataTables.js" type="text/javascript"></script>
<script src="../../js/plugins/datatables/dataTables.bootstrap.js" type="text/javascript"></script>
<script src='../../js/jquery.autosize.js'></script>

<link href="../../css/datepicker/datepicker.css" rel="stylesheet" type="text/css" />
<script src="../../js/bootstrap-datepicker.js" type="text/javascript"></script>

<script language="JavaScript" type="text/javascript" src="../../js/jquery.numeric.js"></script>
<link href="../../css/jquery.alerts.css" rel="stylesheet" type="text/css" />


<script language="JavaScript" type="text/javascript" src="../../js/jquery.alerts.js"></script>
<script src="../../js/timer.js" type="text/javascript"></script>
<script type="text/javascript">
	$(function() {

		
	// $(".sidebar-toggle").click();
		
		$("#company_list").dataTable({


	
			"bDestroy": true,
			"bAutoWidth": false,
			// // "aaSorting": [[2, "desc"]],
			"aoColumns": [
			{ sWidth: '2%' },
			{ sWidth: '9%' },
			{ sWidth: '9%' },
			{ sWidth: '7%' },
			{ sWidth: '12%' },
			{ sWidth: '5%' },
			{ sWidth: '5%' },
		
				]
		});




	});
</script>


<script type="text/javascript">
// function openWin(var1)
// {

// 	// alert();

// 	$("#divPayment").empty();
// 	$("#divPayment").html('<div><img src="../../img/ajax-loader.gif" /><br><b>Loading...</b></div>'); 
	


			
// 		$.ajax({

// 			cache:false,
// 			url:'options.php?id=113',
// 			type:'POST',
// 			data:{
// 				invoiceid:var1,

// 			},

// 			success:function(html){
// 				setTimeout(function() {

// 					$("#divPayment").empty();
// 						$("#divPayment").append(html);


// 						$("#btnhide").show();	
		
					
// 						if($("#txtP_PR").val().length!=0)
// 						{

// 							$("#btnhide").hide();	
// 						}

	
// 						$("#txtP_PR").numeric();
// 						$('#txtP_Remarks').autosize({append: "\n"});
// 						$('#txtP_Date').datepicker({
// 							format: 'dd-mm-yyyy',
// 							autoclose:true
// 						});
// 					}, 500);


// 			}

					
// 		});
		


// }



</script>

<script>
function onkeyUp1()
{
    var txtInv = parseFloat($("#txtP_PR").val());if(isNaN(txtInv)){txtInv = 0;}
	var txtInvTDS = parseFloat($("#txtP_TDS").val());if(isNaN(txtInvTDS)){txtInvTDS = 0;}
	var txtP_TOTAL_AMT  = parseFloat(txtInv) - parseFloat(txtInvTDS);if(isNaN(txtP_TOTAL_AMT)){txtP_TOTAL_AMT = 0;}
	$("#txtP_TOTAL_AMT").val(txtP_TOTAL_AMT.toFixed(2));
}



function getValid()
{
	if($('#txtP_PR').val() == '' || $('#txtP_Date').val() =='' || $('#txtP_Remarks').val()=='')
	{
		jAlert('Please fill the Payment Received & Date & Remarks', 'Alert');
		return false;
	}
	else
	{
		var file_temp_name = $("[id^=fileForP_]").map(function () {return this.value;}).get().join(",");
	    $('#txtCRMFILE1').val(file_temp_name);
	    var file_actual_name = $("[id^=nameForP_]").map(function () {return this.value;}).get().join(",");
	    $('#txtCRMNAME1').val(file_actual_name);
		document.frm2.submit();
		return true;
	}
}




function getPdf(var1)
{

	location.href='allPdf.php?id=91&pur_id='+var1;

}




	</script>
    </body>
</html>