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

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

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


include("user.php");
date_default_timezone_set('Asia/Dhaka');
$date_c = date('Y-m-d h:i:s', time());
$temp_id=$_GET['id'];
$sql = "SELECT * FROM invoices WHERE id = '$temp_id' ";
$sql = mysqli_query($connection, $sql);
$sql = mysqli_fetch_object($sql);
$invid=$sql->inv_id;

if (isset($_POST['del_product'])) {
	
	$item_id = $_POST['item_id'];
	$sql_ref = "SELECT * FROM invoice_items WHERE item_id = '$item_id' ";
    $sql_ref = mysqli_query($connection, $sql_ref);
    $sql_ref = mysqli_fetch_object($sql_ref);
    $sql_ref=$sql_ref->refid;
	
	
	$sqlrmv = "DELETE FROM `invoice_items` WHERE `invoice_items`.`item_id` = '$item_id';";
    $sqlinsert = mysqli_query($connection, $sqlrmv); 
	
    $sqlUpdate = "INSERT INTO `activity_log` (`id`, `user`, `activity`, `time`) VALUES (NULL, '$ad_id', 'invoice updated, deleted item from invoice,invoice ID $invid', '$date_c')";
    $sqlUpdate = mysqli_query($connection, $sqlUpdate); 

}

if (isset($_POST['discount'])) {
	$inv_id = $_POST['inv_id'];
	$discount_amt = $_POST['discount_amt'];
	$sqlUpdate = "UPDATE invoices SET
  discount = '$discount_amt',
 updated_at = '$date_c'
												  											  
 WHERE
 inv_id = '$inv_id'           
";
$sqlUpdate = mysqli_query($connection, $sqlUpdate); 
}

if (isset($_POST['add_product'])) {
	
	$inv_id = $_POST['inv_id'];
	
	$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', NULL, NULL, NULL, NULL, NULL, NULL, '$date_c','$date_c');";
											   
     $sqlinsert = mysqli_query($connection, $sqlinsert);
	 
	 $sqlUpdate = "INSERT INTO `activity_log` (`id`, `user`, `activity`, `time`) VALUES (NULL, '$ad_id', 'invoice updated, added new item invoice ID $invid', '$date_c')";
$sqlUpdate = mysqli_query($connection, $sqlUpdate); 
	
}

if (isset($_POST['save_product'])) {
	
$item_id = $_POST['item_id'];
$product_id = $_POST['product_id'];
$product_details = $_POST['product_details'];
$selling_price = $_POST['selling_price'];
$quantity = $_POST['quantity'];
$total_price = $_POST['total_price'];


	


$sqlUpdate = "UPDATE invoice_items SET
  product_id = '$product_id',
  description = '$product_details',
 qty = '$quantity',
 unit_price = '$selling_price',
 total = '$total_price',
 updated_at = '$date_c'
												  											  
 WHERE
 item_id = '$item_id'           
";
$sqlUpdate = mysqli_query($connection, $sqlUpdate); 	
	
 
	
$sqlUpdate = "INSERT INTO `activity_log` (`id`, `user`, `activity`, `time`) VALUES (NULL, '$ad_id', 'invoice updated, invoice ID $invid', '$date_c')";
$sqlUpdate = mysqli_query($connection, $sqlUpdate); 	
	
	
	
}



if (isset($_POST['submit'])) {
	$date = $_POST['date'];
	$notes = $_POST['notes'];
$sqlUpdate = "UPDATE invoices SET
  date = '$date',
  notes = '$notes',
   updated_at = '$date_c'
												  											  
 WHERE
id = '$temp_id'           
";
$sqlUpdate = mysqli_query($connection, $sqlUpdate); 


}





$bookingtSQL = mysqli_query($connection, "select t1.*, t2.id, t2.discount, t2.date, t2.customer_id,t2.notes,t4.name invoice_by,t3.address,t3.cell_1,t3.cell_2, t2.added_at, t2.updated_at,t3.name c_name,t3.email from (SELECT invoice_id, sum(total) inv_amount FROM `invoice_items` group by invoice_id order by invoice_id desc) as t1 left join invoices as t2 on t1.invoice_id=t2.inv_id left join bookings as t3 on t2.customer_id=t3.id left join users as t4 on t2.added_by=t4.id where t2.id='$temp_id'");
$list= mysqli_fetch_object($bookingtSQL);
									
                                $idn = $list->id;
                                  $invoice_id = $list->invoice_id;
								 $inv_amount = $list->inv_amount;
								 $inv_discount = $list->discount;
								 $sub_total=$inv_amount-$inv_discount;
								 $idn = $list->id;
								 $date = $list->date;
								 $date = date("Y-m-d", strtotime($date));
								 $customer_id = $list->customer_id;
								 $customer_name = $list->c_name;
								 $invoice_by = $list->invoice_by;
								 $added_at = $list->added_at;
								 $updated_at = $list->updated_at;
								 
								 
								 $notes = $list->notes;
								 $address_1 = $list->address;
								 $c_email = $list->email;
								 $cell_1 = $list->cell_1;
								$cell_2 = $list->cell_2;
								
							

?>

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

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Edit 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 -->
           
               <div class="card-body">

                <div class="row">

                    <div class="col-md-4">
                        <div class="form-group">
						  <label>Customer</label>
											<select class="form-control"  name="customer_id">
												
												 
													 <option value="<?php echo $customer_id; ?>"> <?php echo $customer_name; ?> </option>
                                                  
						
                                                    </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_id; ?>">
                        </div>
                    </div>

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

                           
                        </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">
						
						<?php
						$sl=0;
						$sqlSelectedLG = "SELECT t1.*,t2.title p_name FROM `invoice_items` as t1 left join pos_products as t2 on t1.product_id=t2.id where t1.invoice_id='$invoice_id'";
						
						$sqlSelectedLG = mysqli_query($connection, $sqlSelectedLG);
						while ($listt = mysqli_fetch_object($sqlSelectedLG)) {

                                    
                                  $item_id = $listt->item_id;
                                    $product = $listt->p_name;
									 $product_id = $listt->product_id;
									$qty = $listt->qty;
									$description = $listt->description;
									$unit_price = $listt->unit_price;
									$total = $listt->total;
									$sl=$sl+1;
                                    
                                ?>
						
						
						  <form method="post" action="pos_invoice_edit.php?id=<?php echo $temp_id; ?>">
                            <tr>
                                <td>
								  
                                    <select id="tags_1" name="product_id" class="form-control" required="">
                                   	<option value="<?php echo $product_id ;?>"  > <?php echo $product;?> </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" value="<?php echo  $description; ?>" class="proname form-control">
                            </td>

                            <td>
                                <input name="quantity" required="" id="quantity_<?php echo $sl ;?>" placeholder="0" value="<?php echo  $qty; ?>" class="quant form-control">
                            </td>
                            <td>
                                <input type="hidden" name="purchasing_price[]" id="unitcost_<?php echo $sl ;?>" class="purchaseprice form-control">

                                <input name="selling_price" placeholder="0" id="unitprice_<?php echo $sl ;?>" value="<?php echo  $unit_price; ?>"  class="unitprice form-control">
                            </td>
                            <td>
                                <input id="totalprice_<?php echo $sl ;?>" name="total_price" readonly="" value="<?php echo  $total; ?>"  placeholder="Total Price..." class="totalprice form-control">
                            </td>
                            <td>
							 <input type="hidden" name="item_id" readonly="" class="form-control" value="<?php echo $item_id; ?>">
							 <input type="hidden" name="inv_date" readonly="" class="form-control" value="<?php echo $date; ?>">
							 <input type="hidden" name="inv_customer" readonly="" class="form-control" value="<?php echo $customer_id; ?>">
							   <button type="submit" name="save_product"><i class="ti-save color-success"></i></button><button onclick="return confirm('Are you sure you want to Remove?');" type="submit" name="del_product"><i class="ti-trash color-danger"></i></button>
							   
				</td>
                        </tr>
						</form>
	<?php } ?>
	
	
	
                   </tbody>
                </table>
                <table class="table">

                    <tbody><tr>
                        <td style="border-top: medium none;">
                             <form method="post" action="pos_invoice_edit.php?id=<?php echo $temp_id; ?>">
							  <input type="hidden" name="inv_id" readonly="" class="form-control" value="<?php echo $invoice_id; ?>">
                                <button type="submit" name="add_product" class="btn btn-info btn-flat btn-sm">  <i class="ti-plus"></i> New Product</button> 
                             </form>
                        </td>
						
						 <form method="post" action="pos_invoice_edit.php?id=<?php echo $temp_id; ?>">
						 <input type="hidden" name="inv_id" readonly="" class="form-control" value="<?php echo $invoice_id; ?>">
                        <td style="width: 22%;border-top: medium none;">Discount <input type="submit" name="discount" value="save" /> </td>
                        <td style="border-top: medium none;">
                            <input name="discount_amt" id="discount" value="<?php echo $inv_discount; ?>" placeholder="0" class="form-control">
                        </td>
						</form>
                    </tr>
					
					<tr>
                        <td style="border-top: medium none;">
                            
                        </td>
						
						 <form method="post" action="pos_invoice_edit.php?id=<?php echo $temp_id; ?>">
                        <td style="width: 22%;border-top: medium none;">Sub Total</td>
                        <td style="border-top: medium none;">
                            <input name="sub_total" id="subtotal" value="<?php echo $sub_total; ?>" readonly="" placeholder="0" class="form-control">
                        </td>
                    </tr>
					

                    <tr>
                        <td rowspan="6" style="border-top: medium none;">
						
						
                          

                            <input type="date" value="<?php echo $date; ?>" placeholder="dd/mm/yyyy" name="date"  >
                            <textarea id="editor1" name="notes" rows="7" style="width: 92%;" class="form-control textareawysihtml5"><?php echo $notes; ?></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;"></td>
                        <td style="border-top: medium none;">
                            <input type="hidden" id="grandtotal" value="<?php echo $inv_amount; ?>" name="grand_total" readonly="" placeholder="0" class="form-control">
							<input type="hidden" name="discount" id="discount" placeholder="0" class="form-control">
							 <input type="hidden" id="net_total" value="<?php echo $inv_amount; ?>" name="net_total" readonly="" placeholder="0" class="form-control">
                        </td>
                    </tr>

                   


                    <input type="hidden" id="paidamount" name="paid_amount" class="form-control">

                    <tr>
                        <td style="border-top: medium none;"></td>
                        <td style="border-top: medium none;">
                            <input  type="hidden" id="dueamount" value="<?php echo $inv_amount; ?>" 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 Save?&#39;);">Save Changes
            </button>
			   <a href="pos_invoice_print.php?id=<?php echo $temp_id;  ?>" target="blank">   <i class="ti-printer color-success"></i></a>
    </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 refid,acc_name FROM `xadmin_account_name` WHERE `act_group_head` = 'SALES' ";
							  
							   
                                $sqlSelectMem = mysqli_query($connection, $sqlSelectMem);


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

                                    
                                   
                                    $name = $list->acc_name;
									$idn = $list->refid;
                                   
                                ?><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 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);
                $("#grandtotal").append().val(subtotal + vat_amount);
                $("#net_total").append().val(subtotal + vat_amount);
                $("#dueamount").append().val(subtotal + vat_amount);

            }

            $(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());
        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 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);
    });

    $(document).on("keyup", "#paidamount", function(event) {
        var paidamount = $(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>