<?php session_start(); ob_start(); ?>
<?php  include 'header.php'; ?>
<?php
error_reporting(E_ALL);
ini_set('display_errors', 0);

if(empty($_SESSION['LOGINID']) && empty($_SESSION['LOGINNM']) ){

	header("Location:index.php");
}


include("user.php");

if (isset($_POST['submit'])) {
	
	date_default_timezone_set('Asia/Dhaka');
                    $date_c = date('Y-m-d H:i:s', time());
	
$customer_id = $_POST['customer_id'];
$inv_id = $_POST['inv_id'];
$date = $_POST['date'];
$notes = $_POST['notes'];
$discount = $_POST['discount'];
if(empty($discount)){$discount=0;}

if (isset($_POST['paid_amount'])) {
	$paid_amount = $_POST['paid_amount'];
	if($paid_amount>0){
	$paid_method = $_POST['method'];
	
	$mr_no = mysqli_query($connection, "SELECT max(mr_no) mr FROM `transactions` limit 1");
	$mr_no = mysqli_fetch_object($mr_no);
	$mr_no = $mr_no->mr;
	$mr_no = $mr_no+1;
	
	
	$sqlinsert = "INSERT INTO `transactions` (`id`, `date`, `temp_booking_id`,`mr_no`, `amount`,`method`,`details`, `updated_by`,`type`,`inv_id`, `added_at`, `updated_at`) VALUES (NULL, '$date', '$customer_id','$mr_no', '$paid_amount','$paid_method','$notes', '$ad_id','2','$inv_id', '$date_c', NULL);           
";
$sqlinsert = mysqli_query($connection, $sqlinsert); 
date_default_timezone_set('Asia/Dhaka');
$sqlUpdate = "INSERT INTO `activity_log` (`id`, `user`, `activity`, `time`) VALUES (NULL, '$ad_id', 'payment added MR NO $mr_no', '$date_c')";
$sqlUpdate = mysqli_query($connection, $sqlUpdate); 	
	
	} }


$vat = $_POST['vat'];
$sqlinsert = "INSERT INTO `invoices` (`id`, `inv_id`, `customer_id`, `date`, `vat`, `discount`, `notes`, `status`, `added_by`, `added_at`, `updated_at`) VALUES (NULL, '$inv_id', '$customer_id', '$date', '$vat', '$discount', '$notes', '0', '$ad_id', '$date_c', '$date_c');";
											   
$sqlinsert = mysqli_query($connection, $sqlinsert); 

$product_ids = $_POST['product_id'];
$product_details = $_POST['product_details'];
$selling_price = $_POST['selling_price'];
$quantity = $_POST['quantity'];
$total_price = $_POST['total_price'];
$dayBookDate=$date;
  $debit=$customer_id;
  
  $dayBookContra="Y";
$items_total=count($product_ids);
$sqlUpdate = "INSERT INTO `activity_log` (`id`, `user`, `activity`, `time`) VALUES (NULL, '$ad_id', 'invoice created invoice ID $inv_id', '$date_c')";
$sqlUpdate = mysqli_query($connection, $sqlUpdate); 

    $i=0;
	foreach ($product_ids as $product_id ) { 
                 
					$description=$product_details[$i];
					$credit=$product_id;
				  $dayBookAmount=$total_price[$i];
                 $sttts=1;
                 $backup=1;
                 	
	
	
$sqlinsert = "INSERT INTO `invoice_items` (`item_id`, `invoice_id`, `product_id`, `refid`, `description`, `qty`, `unit_price`, `total`, `added_at`, `updated_at`) VALUES
					(NULL, '$inv_id', '$product_id', '33', '$product_details[$i]', '$quantity[$i]', '$selling_price[$i]', '$total_price[$i]', '$date_c', '$date_c' );";
											   
$sqlinsert = mysqli_query($connection, $sqlinsert); 
	
$uname=$_SESSION['LOGINNM'];
$uid=$_SESSION['LOGINID'];
$user_tbl="admin";
$entry_type="ADD";
$date=date('l, F d, Y, h:i A');


					
					$i=$i+1;
					
			        }






header("Location: pos_invoice_list.php");
}


$sqlSelectedLG = mysqli_query($connection, "SELECT * FROM `invoices` ORDER BY `invoices`.`id` DESC LIMIT 0,1");
$in_cnt = mysqli_num_rows($sqlSelectedLG );
     while ($list = mysqli_fetch_object($sqlSelectedLG)) {
		 $invoiceno=$list->inv_id;
		 $invoice_no=$invoiceno;
		 
		
		 
	 }

 if ($in_cnt==0) {
			 $invoice_no=$invoice_start;
		 }
$invoice_no=$invoice_no+1;

?>

<!DOCTYPE html>
<html lang="en">

<head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Create Invoice</title>
    <!-- ================= Favicon ================== -->
    <!-- Standard -->
    <link rel="shortcut icon" href="http://placehold.it/64.png/000/fff">
    <!-- Retina iPad Touch Icon-->
    <link rel="apple-touch-icon" sizes="144x144" href="http://placehold.it/144.png/000/fff">
    <!-- Retina iPhone Touch Icon-->
    <link rel="apple-touch-icon" sizes="114x114" href="http://placehold.it/114.png/000/fff">
    <!-- Standard iPad Touch Icon-->
    <link rel="apple-touch-icon" sizes="72x72" href="http://placehold.it/72.png/000/fff">
    <!-- Standard iPhone Touch Icon-->
    <link rel="apple-touch-icon" sizes="57x57" href="http://placehold.it/57.png/000/fff">
    <!-- Styles -->
  
       <link href="assets/css/lib/calendar2/pignose.calendar.min.css" rel="stylesheet">
    <link href="assets/css/lib/themify-icons.css" rel="stylesheet">
    <link href="assets/css/lib/font-awesome.min.css" rel="stylesheet">
    <link href="assets/css/lib/menubar/sidebar.css" rel="stylesheet">
    <link href="assets/css/lib/bootstrap.min.css" rel="stylesheet">
    <link href="assets/css/lib/Unix.css" rel="stylesheet">
    <link href="assets/css/style.css" rel="stylesheet">
    <link href="assets/css/lib/select2/select2.min.css" rel="stylesheet">
	
	
	

    
    
    <!-- jQuery UI CSS -->
    <link href="assets/css/jquery-ui-1.10.3.custom.css" rel="stylesheet" type="text/css">
    <!-- Theme style -->
  
  

    
    <!-- jQuery 2.0.2 -->
    <script src="js/jquery-1.11.1.js"></script>
    <!-- jQuery UI -->
    <script src="js/jquery-ui-1.10.3.js" type="text/javascript"></script>



	
</head>

<body>
    <?php include("sidebar.php"); ?>
	
	
    <!-- /# sidebar -->
     <?php include("top.php"); ?>
	<!-- /# topebar --> 
	 
	 
    <div class="content-wrap">
        <div class="main">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-8 p-r-0 title-margin-right">
                        <div class="page-header">
                            <div class="page-title">
                                <h1>Create Invoice</h1>
                            </div>
                        </div>
                    </div>
                    <!-- /# column -->
                    <div class="col-lg-4 p-l-0 title-margin-left">
                        <div class="page-header">
                            <div class="page-title">
                                <ol class="breadcrumb text-right">
                                    <li><a href="#">Dashboard</a></li>
                                    <li class="active">Create Invoice</li>
                                </ol>
                            </div>
                        </div>
                    </div>
                    <!-- /# column -->
                </div>
                <!-- /# row -->
                <section id="main-content">
                   
				   
				   <div class="row">
    <div class="col-md-12">
         <div class="card alert">
               
                <hr>
           
            <!-- form start -->
            <form action="pos_invoice_create.php" method="POST" role="form">
               <div class="card-body">

                <div class="row">

                    <div class="col-md-4">
                        <div class="form-group">
						  <label>Customer</label>
											<select class="form-control js-example-basic-single"  name="customer_id">
												
												 
													 <option selected="" disabled=""> --- </option>
                                                  
									

									<?php 
												$sqlSelectMem = "SELECT * FROM `bookings` where status=3 OR status=1 ";

                                $sqlSelectMem = mysqli_query($connection, $sqlSelectMem);


                               while ($list = mysqli_fetch_object($sqlSelectMem)) {

                                    
                                   
                                    $booking_id = $list->booking_id;
									$temp_id = $list->id;
									$name = $list->name;
                                   
                                ?>
												
												
                                                       
														<option value="<?php echo $temp_id;  ?>"> <?php echo $booking_id;  ?> -  <?php echo $name;  ?>  </option>
														
							   <?php } ?>
						
                                                    </select>
											</div>
                    </div>


                    <div class="col-md-4">
                        <div class="form-group">
                            <label>Invoice No.</label>
                            <input name="inv_id" readonly="" class="form-control" value="<?php echo $invoice_no; ?>">
                        </div>
                    </div>

                    <div class="col-md-4">
                        <div class="form-group">
                            <label>Date</label>

                            <div class="input-group">
                                <div class="input-group-addon">
                                    <i class="fa fa-calendar"></i>
                                </div>
                                <input type="text" class="form-control calendar bg-ash" placeholder="dd/mm/yyyy" id="text-calendar" name="date" required>
                            </div>
                        </div>

                    </div>





                </div>




                <div>
                    <h4>Item Information</h4>
                    <table class="table table-striped table-bordered">
                        <thead>
                            <tr>
                                <th>Product</th>
                                <th>Description</th>
                                <th>Quantity</th>
                                <th>Unit Price</th>
                                <th>Total Price</th>
                                <th style="width:8%;">Action</th>
                            </tr>
                        </thead>
                        <tbody id="tableDynamic">
                            <tr>
                                <td>
								  
                                    <select id="tags_1" name="product_id[]" class="form-control" required="">
                                    <option selected="" disabled=""> --- </option>
                                        
										
										<?php 
								
								   $sqlSelectMem = "SELECT * FROM `pos_products` ";
							  
							   
                                $sqlSelectMem = mysqli_query($connection, $sqlSelectMem);


                               while ($list = mysqli_fetch_object($sqlSelectMem)) {

                                    
                                   
                                    $name = $list->title;
									$idn = $list->id;
                                   
                                ?>
												
												
                                                  <option value="<?php echo $idn;  ?>"> <?php echo $name;  ?> </option>    
														
							   <?php } ?>
										
						
                                                                    </select>
                            </td>
                            <td>
                                <input id="details_1" name="product_details[]" placeholder="Details" class="proname form-control">
                            </td>

                            <td>
                                <input name="quantity[]" required="" id="quantity_1" placeholder="0" class="quant form-control">
                            </td>
                            <td>
                                <input type="hidden" name="purchasing_price[]" id="unitcost_1" class="purchaseprice form-control">

                                <input name="selling_price[]" placeholder="0" id="unitprice_1" class="unitprice form-control">
                            </td>
                            <td>
                                <input id="totalprice_1" name="total_price[]" readonly="" placeholder="Total Price..." class="totalprice form-control">
                            </td>
                            <td></td>
                        </tr>

                    <tr>
            <td>
            <select id="tags_2" name="product_id[]" class="proname form-control">
            <option selected="selected" disabled="disabled"> --- </option> 
                
				
					<?php 
								
								  $sqlSelectMem = "SELECT * FROM `pos_products` ";
							  
							   
                                $sqlSelectMem = mysqli_query($connection, $sqlSelectMem);


                               while ($list = mysqli_fetch_object($sqlSelectMem)) {

                                    
                                   
                                    $name = $list->title;
									$idn = $list->id;
                                   
                                ?>
												
												
                                                  <option value="<?php echo $idn;  ?>"> <?php echo $name;  ?> </option>    
														
							   <?php } ?>
				
				
                 
                </select>
                </td>
                <td>
                <input id="details_2" name="product_details[]" placeholder="Details" class="prodetails form-control">
                </td>
                <td>
                <input name="quantity[]" id="quantity_2" placeholder="0" class="quant form-control">
                </td>
                <td>
                <input type="hidden" name="purchasing_price[]" placeholder="0" id="unitcost_2" class="purchaseprice form-control">
                <input name="selling_price[]" id="unitprice_2" placeholder="0" class="unitprice form-control">
                </td>
                <td>
                <input id="totalprice_2" name="total_price[]" readonly="" placeholder="Total Price..." class="totalprice form-control">
                </td>
                <td>
                <a href="javascript:void(0);" id="deleteRow_2" class="deleteRow btn btn-danger btn-flat btn-sm">Delete
                </a>
                </td>
                </tr></tbody>
                </table>
                <table class="table">

                    <tbody><tr>
                        <td style="border-top: medium none;">
                            <span id="addRow" class="btn btn-info btn-flat btn-sm">
                                <i class="fa fa-plus-circle"></i> New Product
                            </span>
                        </td>
                        <td style="width: 22%;border-top: medium none;">Sub Total</td>
                        <td style="border-top: medium none;">
                            <input name="sub_total" id="subtotal" readonly="" placeholder="0" class="form-control">
                        </td>
                    </tr>

                    <tr>
                        <td rowspan="6" style="border-top: medium none;">
                            <label for="">Note</label>
                            <textarea id="editor1" name="notes" rows="7" style="width: 92%;" class="form-control textareawysihtml5"></textarea>

                        </td>
                        <td style="border-top: medium none;"></td>
                        <td style="border-top: medium none;">
                            <input type="hidden" id="vat_rate" name="vat" class="form-control" value="">

                            <input type="hidden" id="vat_amount" name="vat" readonly="" placeholder="0" class="form-control">
                        </td>
                    </tr>



					<tr>
                        <td style="border-top: medium none;">Discount (Amount)</td>
                        <td style="border-top: medium none;">
                            <input id="discount" name="discount"  placeholder="0" class="form-control">
                        </td>
                    </tr>
					
					
					
                    <tr>
                        <td style="border-top: medium none;"></td>
                        <td style="border-top: medium none;">
                            <input type="hidden" id="grandtotal" name="grand_total" readonly="" placeholder="0" class="form-control">
							 <input type="hidden" id="net_total" name="net_total" readonly="" placeholder="0" class="form-control">
                        </td>
                    </tr>

					<tr>
                        <td style="border-top: medium none;">Payable</td>
                        <td style="border-top: medium none;">
                            <input id="payableamount" name="payable_amount" readonly="" placeholder="0" class="form-control">
							
                        </td>
                    </tr>
					
					
                   <tr>
                        <td style="border-top: medium none;">Payment  <select name="method" placeholder="payment method">
											    <option value=""> </option>
											   <option value="cash"> cash </option>
											   <option value="bkash"> bkash </option>
											   <option value="cheque"> cheque </option>
											   <option value="bank"> bank </option>
											    <option value="card"> card </option>
											   </select> </td>
                        <td style="border-top: medium none;">
                            <input id="paidamount" name="paid_amount"  placeholder="0" class="form-control">
							 <input type="hidden" id="net_total" name="net_total" readonly="" placeholder="0" class="form-control">
                        </td>
                    </tr>


                   

                    <tr>
                        <td style="border-top: medium none;">Due Amount</td>
                        <td style="border-top: medium none;">
                            <input id="dueamount" readonly="" name="due_amount" placeholder="0" class="form-control">
                        </td>
                    </tr>

                </tbody></table>
            </div>

        </div><!-- /.box-body -->

        <div class="box-footer text-right">
            <button type="submit" name="submit" class="btn btn-success btn-sm " onclick="return confirm(&#39;Sure to add?&#39;);">Create Invoice
        </button>
    </div>

</form>
</div>
</div>
</div>


<script type="text/javascript">

    $(function() {
        $('.dynamicDate').datepicker({
            format: 'yyyy/mm/dd',
        }).on('changeDate', function(e) {
            $(this).datepicker('hide');
        });
    });



</script>

<script type="text/javascript">

    var scntDiv = $('#tableDynamic');
    var i = $('#tableDynamic tr').size() + 1;

    $("#tags_11").autocomplete({
        source: 'getcustomernameId',
        select: function(event, ui) {
            console.log(ui);
            $("#tags_11").val(ui.item.value);
            $("#cst_id").val(ui.item.id);
            return false;
        }
    });

    $('#addRow').on('click', function() {
        $('<tr>\n\
            <td>\n\
            <select id="tags_' + i + '"  name="product_id[]" class="proname form-control">\n\
            <option selected="selected" disabled="disabled"> --- </option> \n\
                	<?php 
								
								   $sqlSelectMem = "SELECT * FROM pos_products ";
							  
							   
                                $sqlSelectMem = mysqli_query($connection, $sqlSelectMem);


                               while ($list = mysqli_fetch_object($sqlSelectMem)) {

                                    
                                   
                                    $name = $list->title;
									$idn = $list->id;
                                   
                                ?><option value="<?php echo $idn;  ?>">\n\
                <?php echo $name;  ?></option>\n\<?php } ?>	 \n\
                </select>\n\
                </td>\n\
                <td>\n\
                <input id="details_' + i + '" name="product_details[]" placeholder="Details" class="prodetails form-control">\n\
                </td>\n\
                <td>\n\
                <input name="quantity[]" id="quantity_' + i + '" placeholder="0" class="quant form-control">\n\
                </td>\n\
                <td>\n\
                <input type="hidden" name="purchasing_price[]" placeholder="0" id="unitcost_' + i + '" class="purchaseprice form-control">\n\
                <input name="selling_price[]" id="unitprice_' + i + '" placeholder="0" class="unitprice form-control">\n\
                </td>\n\
                <td>\n\
                <input id="totalprice_' + i + '" name="total_price[]" readonly placeholder="0" class="totalprice form-control">\n\
                </td>\n\
                <td>\n\
                <a href="javascript:void(0);" id="deleteRow_' + i + '" class="deleteRow btn btn-danger btn-flat btn-sm">Delete\n\
                </a>\n\
                </td>\n\
                </tr>').appendTo(scntDiv);

        i++;

        return false;
    });

    $(document).on("click", ".deleteRow", function(e) {
        if ($('#tableDynamic tr').size() > 1) {
            var target = e.target;

            var id_arr = $(this).attr('id');
            var id = id_arr.split("_");
            var element_id = id[id.length - 1];
            //console.log(element_id);

            var totalprice = parseFloat($("#totalprice_" + element_id).val());
            var subtotal = parseFloat($("#subtotal").val());
            var grandtotal = parseFloat($("#grandtotal").val());
            var net_total = parseFloat($("#net_total").val());
			var discount = parseFloat($("#discount").val());
			var payment = parseFloat($("#payment").val());
            var dueamount = parseFloat($("#dueamount").val());



            if (!isNaN(totalprice)) {


                $("#subtotal").val(subtotal - totalprice);
                $("#grandtotal").val(grandtotal - totalprice);
                $("#net_total").val(grandtotal - totalprice);
                $("#dueamount").val(dueamount - totalprice);

                var vat_rate = parseFloat($("#vat_rate").val());

                var subtotal = parseFloat($("#subtotal").val());

                if(isNaN(vat_rate)){
                    vat_rate = 0;
                }
                if(isNaN(subtotal)){
                    subtotal = 0;
                }

                var vat_amount = subtotal / 100 * vat_rate;
                //console.log(vat_rate);


                $("#vat_amount").append().val(vat_amount);
				  $("#net_total").append().val(subtotal + vat_amount);
                $("#grandtotal").append().val(subtotal + vat_amount - discount );
				$("#payableamount").append().val(subtotal + vat_amount - discount );
               
                $("#dueamount").append().val(subtotal + vat_amount - discount - payment);

            }

            $(target).closest('tr').remove();


        } else {
            //alert('One row should be present in table');
        }
    });

    $(document).on("keyup", ".proname", function(event) {
        var proname = $(this).val();
        var id_arr = $(this).attr('id');
        var id = id_arr.split("_");
        var element_id = id[id.length - 1];

    });

    $(document).on("keyup", ".unitprice", function(event) {
        var unitprice = $(this).val();
        var id_arr = $(this).attr('id');
        var id = id_arr.split("_");
        var element_id = id[id.length - 1];
        //console.log(element_id);

        var total = unitprice * $("#quantity_" + element_id).val();

        $("#totalprice_" + element_id).val(total);

        function findTotals() {
            $("#tableDynamic tr").each(function() {
                row_total = 0;
                $("td .totalprice").each(function() {
                    row_total += Number($(this).val());
                });
                $("#subtotal").append().val(row_total);

            });
        }
        row = findTotals();

        var vat_rate = parseFloat($("#vat_rate").val());
        var subtotal = parseFloat($("#subtotal").val());
        var dueamount = parseFloat($("#dueamount").val());
        if(isNaN(vat_rate)){
            vat_rate = 0;
        }
        if(isNaN(subtotal)){
            subtotal = 0;
        }
        if(isNaN(dueamount)){
            dueamount = 0;
        }

        var vat_amount = subtotal / 100 * vat_rate;

        console.log(vat_rate);


        $("#vat_amount").append().val(vat_amount);
        $("#grandtotal").append().val(subtotal + vat_amount);
        $("#net_total").append().val(subtotal + vat_amount);
        $("#dueamount").append().val(subtotal + vat_amount);
    });

    $(document).on("keyup", ".quant", function() {
        var quant = parseInt($(this).val());
        var id_arr = $(this).attr('id');
        var id = id_arr.split("_");
        var element_id = id[id.length - 1];
        //console.log(element_id);

        var totalprice = $("#totalprice_" + element_id).val();

        $("#totalprice_" + element_id).prop('value', '');
        $("#totalprice_" + element_id).attr({placeholder: 'Total Price...'});

        var total = $("#unitprice_" + element_id).val() * $("#quantity_" + element_id).val();

        $("#totalprice_" + element_id).val(total);

        function findTotals() {
            $("#tableDynamic tr").each(function() {
                row_total = 0;
                $("td .totalprice").each(function() {
                    row_total += Number($(this).val());
                });
                $("#subtotal").append().val(row_total);

            });
        }
        row = findTotals();

        var vat_rate = parseFloat($("#vat_rate").val());
        var subtotal = parseFloat($("#subtotal").val());
        var dueamount = parseFloat($("#dueamount").val());
        var grandtotal = parseFloat($("#grandtotal").val());
        if(isNaN(vat_rate)){
            vat_rate = 0;
        }
        if(isNaN(subtotal)){
            subtotal = 0;
        }
        if(isNaN(dueamount)){
            dueamount = 0;
        }

        var vat_amount = subtotal / 100 * vat_rate;
        console.log(vat_rate);


        $("#vat_amount").append().val(vat_amount);
        $("#grandtotal").append().val(subtotal + vat_amount);
        $("#net_total").append().val(subtotal + vat_amount);
        $("#dueamount").append().val(subtotal + vat_amount);


    });

    $(document).on("keyup", "#discount", function(event) {
        var discount = $(this).val();
        //console.log(discount);
        var subtotal = parseFloat($("#subtotal").val());
        var grandtotal = parseFloat($("#grandtotal").val());
        var dueamount = parseFloat($("#dueamount").val());
		var payableamount = parseFloat($("#payableamount").val());

        var vat_rate = parseFloat($("#vat_rate").val());
        var grandtotal = parseFloat($("#grandtotal").val());
        var dueamount = parseFloat($("#dueamount").val());

        var vat_amount = grandtotal / 100 * vat_rate;

        $("#net_total").append().val(grandtotal - discount);
        $("#dueamount").append().val(grandtotal - discount);
		$("#payableamount").append().val(grandtotal - discount);
    });

    $(document).on("keyup", "#paidamount", function(event) {
        var paidamount = $(this).val();
		var payableamount = $(this).val();
		
        var net_total = $("#net_total").val();
        var dueamount = $("#dueamount").val();

        $("#dueamount").append().val(net_total - paidamount);
    });


</script>
				   
				   
				   
				   
				   
				   
				   
				   
				   
				   
                    <?php include("footer.php"); ?>
                </section>
            </div>
        </div>
    </div>
    <div id="search">
        <button type="button" class="close">×</button>
        <form>
            <input type="search" value="" placeholder="type keyword(s) here" />
            <button type="submit" class="btn btn-primary">Search</button>
        </form>
    </div>
    <!-- jquery vendor -->
 
     <script src="assets/js/lib/jquery.nanoscroller.min.js"></script>
    <script src="assets/js/lib/jquery.nicescroll.min.js"></script>
    <script src="assets/js/lib/menubar/sidebar.js"></script>
    <script src="assets/js/lib/preloader/pace.min.js"></script>
	

    <script src="assets/js/scripts.js"></script>
	
	<!-- scripit init-->
  
 <script src="assets/js/lib/calendar-2/moment.latest.min.js"></script>
    <!-- scripit init-->
    <script src="assets/js/lib/calendar-2/semantic.ui.min.js"></script>
    <!-- scripit init-->
    <script src="assets/js/lib/calendar-2/prism.min.js"></script>
    <!-- scripit init-->
    <script src="assets/js/lib/calendar-2/pignose.calendar.min.js"></script>
    <!-- scripit init-->
    <script src="assets/js/lib/calendar-2/pignose.init.js"></script>
	
	
	<!-- scripit init-->
    <script src="assets/js/lib/calendar-2/moment.latest.min.js"></script>
    <!-- scripit init-->
    <script src="assets/js/lib/calendar-2/semantic.ui.min.js"></script>
    <!-- scripit init-->
    <script src="assets/js/lib/calendar-2/prism.min.js"></script>
    <!-- scripit init-->
    <script src="assets/js/lib/calendar-2/pignose.calendar.min.js"></script>
    <!-- scripit init-->
    <script src="assets/js/lib/calendar-2/pignose.init.js"></script>
  	 <script src="assets/js/lib/select2/select2.full.min.js"></script>
 <script>
        $(document).ready(function() {
            $('.js-example-basic-single').select2({
                allowClear: true,
                placeholder: 'Select an option'
            });
        });
    </script>

	
<!-- page script -->


<script>
    $(document).on("input", ".floatPositive", function(event)
    {
        this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');
    });
    
    $(document).on("input", ".integerPositive", function(event)
    {
        this.value = this.value.replace(/[^0-9]/g, '');
    });

    $(document).on('click', '.confirm_delete', function(e) {
        var sure = confirm('Are you sure you want to delete?');
        if(!sure)
        {
            e.preventDefault();
            return;
        }
    });

    function printDiv(divName)
    {
        var printContents = document.getElementById(divName).innerHTML;
        var originalContents = document.body.innerHTML;

        document.body.innerHTML = printContents;

        window.print();

        document.body.innerHTML = originalContents;
    }
</script>
	






</body>

</html>