<? include "top.php"; ?>
<!DOCTYPE html>
<html>
<head>
	<?php include('include/head.php'); ?>
	<title>Cash Farmer Transactions</title>
	<link rel="stylesheet" type="text/css" href="https://sarmac.b-cdn.net/plugins/datatables/media/css/jquery.dataTables.css">
	<link rel="stylesheet" type="text/css" href="https://sarmac.b-cdn.net/plugins/datatables/media/css/dataTables.bootstrap4.css">
	<link rel="stylesheet" type="text/css" href="https://sarmac.b-cdn.net/plugins/datatables/media/css/responsive.dataTables.css">
	<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/sweetalert2@9"></script>
</head>
<body>
	<?php include('include/header.php'); ?>
	<?php include('include/sidebar.php'); 

	$action=$_REQUEST['action'];
	if($action=='save'){
		$csdate=$_POST['csdate'];
		$csfarmer=$_POST['csfarmer'];
		$csliftman=$_POST['csliftman'];
		$csunit=$_POST['csunit'];
		$csbill=$_POST['csbill'];
		$cstotal=$_POST['grandtot'];
		$csac="SALES AC";
		$csadded=$_SESSION['murgibhai'];
		$csvno=$_POST['csvno'];
		$csfrieght=$_POST['csfrieght'];


		

			
				$res=mysqli_query($con,"INSERT INTO tbl_cash_sales SET csdate='$csdate',csfarmer='$csfarmer',csliftman='$csliftman',csunit='$csunit',csbill='$csbill',cstotal='$cstotal',csac='$csac',csadded='$csadded',csvno='$csvno',csfrieght='$csfrieght'");

				//echo "INSERT INTO tbl_cash_sales SET csdate='$csdate',csfarmer='$csfarmer',csliftman='$csliftman',csunit='$csunit',csbill='$csbill',cstotal='$cstotal',csac='$csac',csadded='$csadded'";

				$maxid=mysqli_insert_id($con);

				if($maxid>0){

						$rowcnt=$_POST['chrow'];
						for($i=1;$i<=$rowcnt;$i++){

								$prodid=$_POST['prodid'.$i];
								$prodname=$_POST['prodname'.$i];
								$quan=$_POST['quan'.$i];
								$quanquan=$_POST['quanquan'.$i];

								$price=$_POST['price'.$i];
								$total=$_POST['total'.$i];

								$getprodtp=f(q("SELECT * FROM tbl_product WHERE maid='$prodid'"));
								$csdtype=$getprodtp['macat'];


								$insdet=mysqli_query($con,"INSERT INTO tbl_csale_det SET csdsid='$maxid',csdprodid='$prodid',csdprodname='$prodname',csdquan='$quanquan',csdrate='$price',csdtotal='$total',csdtype='$csdtype'");







						}





				}


				if($res){?>

					 <script type="text/javascript">
            Swal.fire('Data Saved Successfully','','success')
             </script>
				<?}else{?>

					<script type="text/javascript">
            Swal.fire('Error Saving Data','','error')
             </script>

				<?}
				//echo $res;


	}elseif($action=='update'){
		$csdate=$_POST['csdate'];
		$csfarmer=$_POST['csfarmer'];
		$csliftman=$_POST['csliftman'];
		$csunit=$_POST['csunit'];
		$csbill=$_POST['csbill'];
		$cstotal=$_POST['grandtot'];
		$csac="SALES AC";
		$csadded=$_SESSION['murgibhai'];
		$csvno=$_POST['csvno'];
		$cid=$_REQUEST['cid'];

	$res=mysqli_query($con,"UPDATE tbl_cash_sales SET csdate='$csdate',csfarmer='$csfarmer',csliftman='$csliftman',csunit='$csunit',csbill='$csbill',cstotal='$cstotal',csvno='$csvno' WHERE csid='$cid'");

		$delall=mysqli_query($con,"DELETE FROM tbl_csale_det WHERE csdsid='$cid'");
		$maxid=$cid;

		if($maxid>0){

						$rowcnt=$_POST['chrow'];
						for($i=1;$i<=$rowcnt;$i++){

								$prodid=$_POST['prodid'.$i];
								$prodname=$_POST['prodname'.$i];
								$quan=$_POST['quan'.$i];
								$quanquan=$_POST['quanquan'.$i];

								$price=$_POST['price'.$i];
								$total=$_POST['total'.$i];
								$getprodtp=f(q("SELECT * FROM tbl_product WHERE maid='$prodid'"));
								$csdtype=$getprodtp['macat'];

								$insdet=mysqli_query($con,"INSERT INTO tbl_csale_det SET csdsid='$maxid',csdprodid='$prodid',csdprodname='$prodname',csdquan='$quanquan',csdrate='$price',csdtotal='$total',csdtype='$csdtype'");







						}





				}

				if($res){?>

					 <script type="text/javascript">
            Swal.fire('Data Updated Successfully','','success')
             </script>
				<?}else{?>

					<script type="text/javascript">
            Swal.fire('Error Updating Data','','error')
             </script>

				<?}





	}elseif($action=='edit'){
		$cid=$_REQUEST['cid'];
		$edit=f(q("SELECT * FROM tbl_cash_sales WHERE csid='$cid'"));



	}elseif($action=='delete'){

		$cid=$_REQUEST['cid'];

		$res=mysqli_query($con,"DELETE FROM tbl_cash_sales WHERE csid='$cid'");
		$delall=mysqli_query($con,"DELETE FROM tbl_csale_det WHERE csdsid='$cid'");
		if($res){?>

					 <script type="text/javascript">
            Swal.fire('Data Deleted Successfully','','success')
             </script>
				<?}else{?>

					<script type="text/javascript">
            Swal.fire('Error Deleting Data','','error')
             </script>

				<?}

	}

	


	?>
	<style type="text/css">
		.msmall{

			width: 50px;
			font-size: 12px;
		}
		.smallf{

			font-size: 12px;
		}
		tr{
			width: 100%;
		}
		td{
			width: 20%;
		}
		input[type="text"]:focus { 
    
    border: 2px solid red;   
    }
    select:focus{

         border: 2px solid red;  
    }
    textarea:focus{
        border: 2px solid red; 
    }

    input[type="checkbox"]:focus { 
    
    border: 1px solid red;   
    }
    .form-control:focus{
        border: 1px solid red;

    }
    .btn:focus{
        border: 1px solid red;

    }
	</style>
	<script type="text/javascript">
		function addtablerow(){
                       
                        var table = document.getElementById("prodtable");
                        var prodid=document.getElementById('chchicks').value;
                        var prodname=document.getElementById('prodname').value;
                        var quan=document.getElementById('chquan').value;
                        var price=document.getElementById('chrates').value;
                        var total=document.getElementById('chtotal').value;
                        //var tax=document.getElementById('tax').value;
                        // var total=document.getElementById('total').value;
                         var cnt=document.getElementById('chrow').value;
                        // var produnnit=document.getElementById('secunit').value;

                        produnnit="pieces";
                        if(cnt==0){

                            cnt=parseFloat(cnt)+1;
                        }else{
                            cnt=parseFloat(cnt)+1;
                        }
                        document.getElementById('chrow').value=cnt;

                            var tr = document.createElement("tr");
                            var tdprodid = document.createElement("td");
                            var tdquan = document.createElement("td");
                            var tdprice = document.createElement("td");
                           // var tdgst = document.createElement("td");
                            //var tdtax = document.createElement("td");
                            var tdtotal = document.createElement("td");
                            var tddelete = document.createElement("td");
                           
                           
                            var txtprodid =document.createElement('input'); 
                            txtprodid.setAttribute('type','hidden'); // set attributes ...
                            txtprodid.setAttribute('name','prodid'+cnt);
                            txtprodid.setAttribute('class','smallf');
                            txtprodid.setAttribute('value',prodid); 

                             var txtprodname =document.createElement('input'); 
                            txtprodname.setAttribute('type','text'); // set attributes ...
                            txtprodname.setAttribute('name','prodname'+cnt);
                            txtprodname.setAttribute('class','smallf');
                            txtprodname.setAttribute('value',prodname); 
                             //document.createTextNode(prodid);

                            var txtquan = document.createElement('input'); 
                            txtquan.setAttribute('type','text'); // set attributes ...
                            txtquan.setAttribute('name','quan'+cnt);
                            txtquan.setAttribute('class','smallf');
                            txtquan.setAttribute('value',quan+ ' ' + produnnit);  //document.createTextNode(quan);

                            // var txtquanunit = document.createElement('input'); 
                            // txtquanunit.setAttribute('type','hidden'); // set attributes ...
                            // txtquanunit.setAttribute('name','quanunit'+cnt);
                            // txtquanunit.setAttribute('value',produnnit);  //document.createTextNode(quan);

                            var txtquanquan = document.createElement('input'); 
                            txtquanquan.setAttribute('type','hidden'); // set attributes ...
                            txtquanquan.setAttribute('name','quanquan'+cnt);
                            txtquanquan.setAttribute('class','smallf');
                            txtquanquan.setAttribute('value',quan);  //document.createTextNode(quan);


                            var txtprice = document.createElement('input'); 
                            txtprice.setAttribute('type','text'); // set attributes ...
                            txtprice.setAttribute('name','price'+cnt);
                             txtprice.setAttribute('class','msmall');
                            txtprice.setAttribute('value',price);  //document.createTextNode(price);


                            var txttotal = document.createElement('input'); 
                            txttotal.setAttribute('type','text'); // set attributes ...
                            txttotal.setAttribute('name','total'+cnt);
                            txttotal.setAttribute('id','total'+cnt);
                            txttotal.setAttribute('class','smallf');
                            txttotal.setAttribute('value',total);  //document.createTextNode(total);


                            var butt = document.createElement('input'); // create a button
								butt.setAttribute('type','button'); // set attributes ...
								butt.setAttribute('name','javaSubmit');
								butt.setAttribute('class','smallf');
								butt.setAttribute('value','remove('+cnt+')');
								
								butt.onclick = function() { // set onclick handler
								  deleteRow(this);
								  
								}

                            tdprodid.appendChild(txtprodname);
                             tdprodid.appendChild(txtprodid);
                            tdquan.appendChild(txtquan);
                            // tdquan.appendChild(txtquanunit);
                            tdquan.appendChild(txtquanquan);
                            tdprice.appendChild(txtprice);
                           
                            // tdtax.appendChild(txttax);
                            tdtotal.appendChild(txttotal);
                            
                            tddelete.appendChild(butt);


                            tr.appendChild(tdprodid);
                            tr.appendChild(tdquan);
                            tr.appendChild(tdprice);
                            
                            // tr.appendChild(tdtax);
                            tr.appendChild(tdtotal);
                            
                            tr.appendChild(tddelete);

                            table.appendChild(tr);
                               // alert(cnt);
                                var gtot=0;
                                var disval=0;
                                var txtoto=0;
                                    for(a=1;a<=cnt;a++){

                                       // alert(a);
                                        try{
                                            var tots=document.getElementById('total'+a).value;
                                            //var totd=document.getElementById('discamt'+a).value;
                                        //var taxtots=document.getElementById('tax'+a).value;
                                        //alert(a);
                                        //alert(tots);
                                        gtot=parseFloat(gtot)+parseFloat(tots);
                                       // disval=parseFloat(disval)+parseFloat(totd);    

                                        //txtoto=parseFloat(txtoto) + parseFloat(taxtots);

                                        }catch(e) {

                                           // alert(e);
                                                        
                                                    }
                                        


                                    }
                                    //alert(gtot);
                                    var netsamt=parseFloat(gtot)-parseFloat(disval);
                                    //alert(netsamt);
                                    document.getElementById('grandtot').value=gtot.toFixed(2);
                                    // document.getElementById('p_discamt').value=disval.toFixed(2);
                                    // document.getElementById('p_netamt').value=netsamt.toFixed(2);

                                   // document.getElementById('taxtot').value=txtoto;
                                   /// calculateRowtot('purtable');

                                   document.getElementById("chchicks").focus();
                                   //gotoBottom('tablebody');


                    }
                    function deleteRow(btn) {
                        var row = btn.parentNode.parentNode;
                        row.parentNode.removeChild(row);
                        var cnt=document.getElementById('chrow').value;
                        //cnt=parseFloat(cnt)-1; 
                       // document.getElementById('rowcnt').value=cnt;   
                        var gtot=0;
                        var disval=0;
                        //alert(cnt);
                                    for(a=1;a<=cnt;a++){
                                        try{
                                            var tots=document.getElementById('total'+a).value;
                                            //var totd=document.getElementById('discamt'+a).value;
                                        //var taxtots=document.getElementById('tax'+a).value;
                                        //alert(tots);
                                         gtot=parseFloat(gtot)+parseFloat(tots);
                                         //disval=parseFloat(disval)+parseFloat(totd);    
                                        //txtoto=parseFloat(txtoto) + parseFloat(taxtots);

                                        }catch(e) {
                                                        
                                                    }


                                    }
                                    //var netsamt=parseFloat(gtot)-parseFloat(disval);
                                    document.getElementById('grandtot').value=gtot.toFixed(2);
                                    // document.getElementById('p_discamt').value=disval.toFixed(2);
                                    // document.getElementById('p_netamt').value=netsamt.toFixed(2);
                                    // CalculateRow() 
                                    
                                    //document.getElementById('taxtot').value=txtoto;
                        }
	</script>
	<? include "ajax.php"; ?>
	<div class="main-container">
		<div class="pd-ltr-20 customscroll customscroll-10-p height-100-p xs-pd-20-10">
			<div class="min-height-200px">
				<div class="page-header">
					<div class="row">
						<div class="col-md-6 col-sm-12">
							<div class="title">
								<h4>Cash Farmer Transactions</h4>
							</div>
							<nav aria-label="breadcrumb" role="navigation">
								<ol class="breadcrumb">
									<li class="breadcrumb-item"><a href="index.php">Home</a></li>
									<li class="breadcrumb-item active" aria-current="page">Product Master</li>
								</ol>
							</nav>
						</div>
						<div class="col-md-6 col-sm-12 text-right">
							<!-- <div class="dropdown">
								<a class="btn btn-secondary dropdown-toggle" href="#" role="button" data-toggle="dropdown">
									January 2018
								</a>
								<div class="dropdown-menu dropdown-menu-right">
									<a class="dropdown-item" href="#">Export List</a>
									<a class="dropdown-item" href="#">Policies</a>
									<a class="dropdown-item" href="#">View Assets</a>
								</div>
							</div> -->
						</div>
					</div>
				</div>
				<form action="<?=$_SERVER['PHP_SELF']?>?action=<? if($action=='edit'){?>update&cid=<?=$cid?><? }else{?>save<?} ?>" method="POST">
				<div class="pd-20 bg-white border-radius-4 box-shadow mb-30">

					<div class="row">
						<div class="col-lg-6">
							
							<div class="form-group row">
								<label class="col-sm-12 col-md-4">Date</label>
								<div class="col-sm-12 col-md-8">
									<input type="date" class="form-control" name="csdate" id="csdate" value="<? if($action=='edit'){?><?=$edit['csdate']?><? }else{ ?><? echo date('Y-m-d');?><? } ?>">
								</div>
							</div>
							<div class="form-group row">
								<label class="col-sm-12 col-md-4">Bill</label>
								<div class="col-sm-12 col-md-8">
									<input type="text" class="form-control" name="csbill" id="csbill" value="<?=$edit['csbill']?>">
								</div>
							</div>
							<div class="form-group row">
								<label class="col-sm-12 col-md-4">Vehicle No</label>
								<div class="col-sm-12 col-md-8">
									<input type="text" class="form-control" name="csvno" id="csvno"  value="<?=$edit['csvno']?>">
								</div>
							</div>
							<div class="form-group row">
								<label class="col-sm-12 col-md-4">Freight Charge</label>
								<div class="col-sm-12 col-md-8">
									<input type="text" class="form-control" name="csfrieght" id="csfrieght"  value="<?=$edit['csfrieght']?>">
								</div>
							</div>

						</div>
						<div class="col-lg-6">
							
							<div class="form-group row">
								<label class="col-sm-12 col-md-4">Unit</label>
								<div class="col-sm-12 col-md-8">
									<select name="csunit" class="form-control">
										<option value="0">Choose</option>
										<?
											$getuni=mysqli_query($con,"SELECT * FROM tbl_unit");
											while($arr=mysqli_fetch_array($getuni)){
										?>
										<option value="<?=$arr['unid']?>" <? if($edit['csunit']==$arr['unid']){?> selected <? } ?>><?=$arr['unname']?></option>

									<? } ?>

									</select>
								</div>
							</div>
							<div class="form-group row">
								<label class="col-sm-12 col-md-4">Farmer Name</label>
								<div class="col-sm-12 col-md-8">
									<select name="csfarmer" class="form-control">
										<option value="0">Choose</option>
										<?
											$getuni=mysqli_query($con,"SELECT * FROM tbl_farmer");
											while($arr=mysqli_fetch_array($getuni)){
										?>
										<option value="<?=$arr['faid']?>"  <? if($edit['csfarmer']==$arr['faid']){?> selected <? } ?>><?=$arr['faname']?></option>

									<? } ?>

									</select>
								</div>
							</div>
							<div class="form-group row">
								<label class="col-sm-12 col-md-4">Liftman Name</label>
								<div class="col-sm-12 col-md-8">
									<select name="csliftman" class="form-control">
										<option value="0">Choose</option>
										<?
											$getuni=mysqli_query($con,"SELECT * FROM tbl_liftman");
											while($arr=mysqli_fetch_array($getuni)){
										?>
										<option value="<?=$arr['lfid']?>"  <? if($edit['csliftman']==$arr['lfid']){?> selected <? } ?>><?=$arr['lfname']?></option>

									<? } ?>

									</select>
								</div>
							</div>
							<!-- <div class="form-group row">
								<label class="col-sm-12 col-md-4">Medicine</label>
								<div class="col-sm-12 col-md-8">
									<input type="text" class="form-control" name="csfrieght" id="csfrieght"  value="<?=$edit['csfrieght']?>">
								</div>
							</div> -->

						</div>

					</div>

				</div>
				<!-- Default Basic Forms Start -->
				<div class="pd-20 bg-white border-radius-4 box-shadow mb-30">
					<h4>Add Products</h4><br><br>
					<div class="row">
						<div class="col-lg-5">
							<? if($action=='edit'){ 

									$getprodc=f(q("SELECT COUNT(*) as tots FROM tbl_csale_det WHERE csdsid='$cid'"));
									$chrow=$getprodc['tots'];
								?>
							<input type="hidden" name="chrow" id="chrow" value="<?=$chrow?>">
							<?}else{ ?>

							<input type="hidden" name="chrow" id="chrow" value="0">

							<? } ?>
							<div class="form-group row">
								<label class="col-sm-12 col-md-2">Product</label>
								<div class="col-sm-12 col-md-10">
									<select class="form-control" name="chchicks" id="chchicks" onchange="getprods(this.value)">
										<option value="0">Choose</option>
									<?
										$getq=mysqli_query($con,"SELECT * FROM tbl_product");
										while($arr=mysqli_fetch_array($getq)){
											$getmtp=f(q("SELECT * FROM tbl_ptype WHERE ptid='$arr[maptype]'"));

											if($getmtp['ptname']!=''){

												$brck=$getmtp['ptname'];
											}else{

												$brck=$arr['maweight'];
											}
									?>
									<option value="<?=$arr['maid']?>"><?=$arr['maname']?>(<?=$brck?>)</option>

									<? } ?>
								</select>
								<input type="hidden" id="prodname" value="">
								</div>
							</div>
							<div class="form-group row">
								<label class="col-sm-12 col-md-2">Quantity (piece)</label>
								<div class="col-sm-12 col-md-10">
									<input type="number" class="form-control" name="chquan" id="chquan" onchange="prodtots()" onblur="prodtots()">
								</div>
							</div>
							<div class="form-group row ">
								<label class="col-sm-12 col-md-2">Rate</label>
								<div class="col-sm-12 col-md-10">
									<input type="number" class="form-control" name="chrates" id="chrates" step=0.01>
								</div>
							</div>
							<div class="form-group row ">
								<label class="col-sm-12 col-md-2">Total</label>
								<div class="col-sm-12 col-md-10">
									<input type="text" class="form-control" name="chtotal" id="chtotal">
								</div>
							</div>
							<div class="form-group row">
								<div class="col-sm-12 col-md-12 text-right">
								<button class="btn btn-warning" type="button" onclick="addtablerow()"> Add >></button>
								</div>
							</div>



						</div>
						<div class="col-lg-7">
							<div class="form-group row"  style="min-height: 300px; max-height: 300px;overflow-y: scroll;padding-left: 5%;">
							<table id="prodtable" style="width: 95%;">
								<tr style="width: 100%;">
									<td>Product</td>
									<td>Quantity</td>
									<td>Rate</td>
									<td>Total</td>
									<td>Remove</td>
								</tr>
								<? if($action=='edit'){ 
									$i=0;
									$getprods=mysqli_query($con,"SELECT * FROM tbl_csale_det WHERE csdsid='$cid'");
       								while($arrc=mysqli_fetch_array($getprods)){ 
       									$i=$i+1;
									?>

									<tr>
										<td><input type="text" name="prodname<?=$i?>" class="smallf" value="<?=$arrc['csdprodname']?>"><input type="hidden" name="prodid<?=$i?>" class="smallf" value="<?=$arrc['csdprodid']?>"></td>
										<td><input type="text" name="quan<?=$i?>" class="smallf" value="<?=$arrc['csdquan']?>pieces"><input type="hidden" name="quanquan<?=$i?>" class="smallf" value="<?=$arrc['csdquan']?>"></td>
										<td><input type="text" name="price<?=$i?>" class="msmall" value="<?=$arrc['csdrate']?>"></td>
										<td><input type="text" name="total<?=$i?>" id="total1" class="smallf" value="<?=$arrc['csdtotal']?>"></td>
										<td><input type="button" name="javaSubmit" class="smallf" value="remove(<?=$i?>)" onclick="deleteRow(this);"></td>
									</tr>




								<? } ?>

								<? } ?>
							</table>
						</div>
							<div class="form-group row ">
								<label class="col-sm-12 col-md-6 text-right">Net Amount</label>
								<div class="col-sm-12 col-md-6">
									<input type="text" class="form-control" name="grandtot" id="grandtot"  value="<?=$edit['cstotal']?>">
								</div>
							</div>


						</div>



					</div>
					<small style="color: red;"><?=$msg?></small>
					
					
					<div class="clearfix" style="min-height: 30px;"></div>
					
						
						<!-- <div class="form-group row">
							
							<div class="col-sm-12 col-md-10">
								<label class="weight-600">Commission Applicable</label>
									<div class="custom-control custom-radio mb-5">
										<input type="radio" id="customRadio1" name="maptype" class="custom-control-input" value="no" <? if($edit['maptype']=='no'){?>checked="true"<? } ?>>
										<label class="custom-control-label" for="customRadio1">No</label>
									</div>
									<div class="custom-control custom-radio mb-5">
									<input type="radio" id="customRadio2" name="maptype" class="custom-control-input" value="yes" <? if($edit['maptype']=='no'){?>checked="true"<? } ?>>
										<label class="custom-control-label" for="customRadio2">Yes</label>
									</div>
							</div>
						</div> -->
						
						<div class="clearfix">
						<div class="pull-left">
							<!-- <h4 class="text-blue">Default Basic Forms</h4>
							<p class="mb-30 font-14">All bootstrap element classies</p> -->
						</div>
						<div class="pull-right">
							<button type="submit" class="btn btn-primary btn-sm"><i class="fa fa-save"></i> Save</button>
							<!-- <a href="#basic-form1" class="btn btn-primary btn-sm scroll-click" rel="content-y"  data-toggle="collapse" role="button"><i class="fa fa-code"></i> Source Code</a> -->
						</div>
					</div>
					
					<div class="collapse collapse-box" id="basic-form1" >
						
					</div>
				</div>
				</form>
				
				

			</div>
			<?php include('include/footer.php'); ?>
		</div>
	</div>
	<?php include('include/script.php'); ?>

	<script src="src/plugins/datatables/media/js/jquery.dataTables.min.js"></script>
	<script src="src/plugins/datatables/media/js/dataTables.bootstrap4.js"></script>
	<script src="src/plugins/datatables/media/js/dataTables.responsive.js"></script>
	<script src="src/plugins/datatables/media/js/responsive.bootstrap4.js"></script>
	<!-- buttons for Export datatable -->
	<script src="src/plugins/datatables/media/js/button/dataTables.buttons.js"></script>
	<script src="src/plugins/datatables/media/js/button/buttons.bootstrap4.js"></script>
	<script src="src/plugins/datatables/media/js/button/buttons.print.js"></script>
	<script src="src/plugins/datatables/media/js/button/buttons.html5.js"></script>
	<script src="src/plugins/datatables/media/js/button/buttons.flash.js"></script>
	<script src="src/plugins/datatables/media/js/button/pdfmake.min.js"></script>
	<script src="src/plugins/datatables/media/js/button/vfs_fonts.js"></script>
	<script>
		$('document').ready(function(){
			$('.data-table').DataTable({
				scrollCollapse: true,
				autoWidth: false,
				responsive: true,
				columnDefs: [{
					targets: "datatable-nosort",
					orderable: false,
				}],
				"lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
				"language": {
					"info": "_START_-_END_ of _TOTAL_ entries",
					searchPlaceholder: "Search"
				},
			});
			$('.data-table-export').DataTable({
				scrollCollapse: true,
				autoWidth: false,
				responsive: true,
				columnDefs: [{
					targets: "datatable-nosort",
					orderable: false,
				}],
				"lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
				"language": {
					"info": "_START_-_END_ of _TOTAL_ entries",
					searchPlaceholder: "Search"
				},
				dom: 'Bfrtip',
				buttons: [
				'copy', 'csv', 'pdf', 'print'
				]
			});
			var table = $('.select-row').DataTable();
			$('.select-row tbody').on('click', 'tr', function () {
				if ($(this).hasClass('selected')) {
					$(this).removeClass('selected');
				}
				else {
					table.$('tr.selected').removeClass('selected');
					$(this).addClass('selected');
				}
			});
			var multipletable = $('.multiple-select-row').DataTable();
			$('.multiple-select-row tbody').on('click', 'tr', function () {
				$(this).toggleClass('selected');
			});
		});
	</script>
</body>
</html>