<?php
ob_start();
error_reporting(0);
include("connect.php");
session_start(); 
$ver = $_SESSION["admin_id"];
$admin_id = $_SESSION["admin_id"];
$dis_id = $_SESSION["manager_id"];
$user_type = $_SESSION["user_type"];
$user_session = $_SESSION["user_session"];

$agent_id = base64_decode($_GET['id']);
if(!isset($_SESSION["admin_id"])){
   header('location:http://www.btcover.appexperts.net');
}
date_default_timezone_set('Asia/Calcutta');
	$cdate  = date("Y-m-d");
	$cdate2  = date("m/d/Y");
	$cdate1=date('m/d/Y', strtotime($cdate .'-30 days'));
	$detail=array();
?>
<!DOCTYPE html>
<html dir="ltr" lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- Tell the browser to be responsive to screen width -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <!-- Favicon icon -->
    <link rel="icon" type="image/png" sizes="16x16" href="assets/images/favicon.png">
    <title>BTCOVER : Admin Dashboard</title>
    <!-- Custom CSS -->
    <link rel="stylesheet" type="text/css" href="assets/libs/select2/dist/css/select2.min.css">
    <link rel="stylesheet" type="text/css" href="assets/libs/jquery-minicolors/jquery.minicolors.css">
    <link rel="stylesheet" type="text/css" href="assets/libs/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css">
    <link rel="stylesheet" type="text/css" href="assets/libs/quill/dist/quill.snow.css">
    <link href="dist/css/style.min.css" rel="stylesheet">
   <script>
	
		function myFunction() {
			var txt;
		
			var r = confirm("Are you sure to reset!");
			if (r == true) {
				window.location.href="add-agent.php";
			} 
		}
		</script>
		<script>
		function exist(str)
		{
			
			 document.getElementById('percentage').style.display="block";	
			 document.getElementById('percentage2').style.display="none";	
			
		}
		</script>
		<script>
		function exist2(str)
		{
		
			 document.getElementById('percentage2').style.display="block";	
			 document.getElementById('percentage').style.display="none";	
			
		}
		</script>
		<script>
		function exist3(str)
		{
		
			 document.getElementById('percentage').style.display="block";	
			 document.getElementById('percentage2').style.display="block";	
			
		}
		</script>
		<script>
		function validate(str)
		{
			
			var t=(str>=0 && str <= 100);
          
            if (!t ) {
                alert("Please enter correct percentage.");
				document.getElementById('percentage11').value="";
                document.form.discount.focus();
                return false;
            }
	
		}
	 </script>
	 <script>
		function check(str)
		{
			
			var t=(str>=0 && str <= 100);
          
            if (!t ) {
                alert("Please enter correct percentage.");
				document.getElementById('percentage22').value="";
                document.form.discount.focus();
                return false;
            }
	
		}
	 </script>
</head>

<body>
    <!-- ============================================================== -->
    <!-- Preloader - style you can find in spinners.css -->
    <!-- ============================================================== -->
  
	 <div id="main-wrapper">
   <?php include("header.php"); ?>
    
     <?php include("menu.php"); ?>
	
        <div class="page-wrapper">
            <!-- ============================================================== -->
            <!-- Bread crumb and right sidebar toggle -->
            <!-- ============================================================== -->
            <div class="page-breadcrumb">
                <div class="row">
                    <div class="col-12 d-flex no-block align-items-center">
                        <h4 class="page-title">Pay Agent Commission</h4>
                        <div class="ml-auto text-right">
                            <nav aria-label="breadcrumb">
                                <ol class="breadcrumb">
                                    <li class="breadcrumb-item"><a href="dashboard.php">Dashboard</a></li>
									<?php if($agent_id!='' || isset($agent_id)) 
									{ ?>
                                    <li class="breadcrumb-item"><a href="pay-agent-commission.php">View Agent Detail</a></li>
                                    <?php } ?>
									
									
									<li class="breadcrumb-item active" aria-current="page">Pay Agent Commission</li>
                                </ol>
                            </nav>
                        </div>
                    </div>
                </div>
            </div>
            <!-- ============================================================== -->
            <!-- End Bread crumb and right sidebar toggle -->
            <!-- ============================================================== -->
            <!-- ============================================================== -->
            <!-- Container fluid  -->
            <!-- ============================================================== -->
            <div class="container-fluid">
                <!-- ============================================================== -->
                <!-- Start Page Content -->
                <!-- ============================================================== -->
                <div class="row">
                    <div class="col-md-12">
                        <div class="card">
                            <form class="form-horizontal" method="post" name="form"  enctype="multipart/form-data">
                                <div class="card-body">
                                  
									
                                   <div class="form-group row">
                                 
								
								 <div class="col-md-4" style="padding:0px;">	
									<div class="form-group ">
                                        <label for="fname" class=" text-left control-label col-form-label"><b>Start Date</b></label>
                                        <div class="input-group">
                                    <input type="text" class="form-control" id="datepicker-autoclose" name="start_date" placeholder="mm/dd/yyyy" value="<?php if(isset($_POST['searchd'])){ echo $_POST['start_date'];} else { echo $cdate1; } ?>">
                                    <div class="input-group-append">
                                        <span class="input-group-text"><i class="fa fa-calendar"></i></span>
                                    </div>
                                </div>
                                     </div>
                                </div>
								<div class="col-md-4" style="padding:0px;">	
									<div class="form-group ">
                                        <label for="fname" class=" text-left control-label col-form-label"><b>End Date</b></label>
                                        <div class="input-group">
                                    <input type="text" class="form-control" id="datepicker-autoclose1" name="end_date" placeholder="mm/dd/yyyy" value="<?php if(isset($_POST['searchd'])){ echo $_POST['end_date'];} else { echo $cdate1; } ?>">
                                    <div class="input-group-append">
                                        <span class="input-group-text"><i class="fa fa-calendar"></i></span>
                                    </div>
                                </div>
                                     </div>
                                </div>
								<div class="col-sm-1" style="padding-left:0px; margin-top:31px;">
										  <div class="form-group">  
                                           <button type="submit" class="form-control" name="searchd"> <i class="fa fa-search"></i></button>
										  </div>
										</div>
                                </div>
                                </div>
								</form>
							<?php	if(isset($_POST['searchd']))
						{
						$start_date1=$_POST['start_date'];
						$end_date1=$_POST['end_date'];
						$agent_id =$_REQUEST['id'];
					$start_date=date("Y-m-d", strtotime($start_date1) );
						$end_date=date("Y-m-d", strtotime($end_date1) );
						$amt=0;
						$i=0;
						$com=0;
						
							$select_premium = mysqli_query($con,"select * from tbl_customer_premium,tbl_policy_master where tbl_customer_premium.agent_id='$agent_id' and tbl_customer_premium.transaction_date>='$start_date' and tbl_customer_premium.transaction_date<='$end_date' and tbl_customer_premium.policy_no=tbl_policy_master.policy_no and tbl_customer_premium.status='Complete' ORDER by transaction_id");
							
					$amount=0;
	if(mysqli_num_rows($select_premium)>0)
	{    
		while($fetch_details=mysqli_fetch_assoc($select_premium))
		{
			
		$vehicle_id=$fetch_details['vehicle_id'];
		$premium=$fetch_details['agent_received_amt'];
		$policy_date=$fetch_details['transaction_date'];
		$totalA=$fetch_details['totalA'];
		$totalB=$fetch_details['totalB'];
		$totalC=$fetch_details['totalC'];
		$policy_no=$fetch_details['policy_no'];
		$premium=$fetch_details['agent_received_amt'];
		//$shortPremium=$fetch_details['short_premium'];
			
		$query = mysqli_query($con,"SELECT * from tbl_commission_type where tbl_commission_type.vehicle_id='$vehicle_id' order by tbl_commission_type.commission_id");
		
			if(mysqli_num_rows($query)>0)
			{
				while($fetch_percentage=mysqli_fetch_assoc($query)){
					
					$percentage=$fetch_percentage['percentage'];
				 	$percentage2=$fetch_percentage['percentage2'];
				 	$type=$fetch_percentage['type'];
					$start_date=$fetch_percentage['start_date'];
					$end_date=$fetch_percentage['end_date'];	
					if(strtotime($start_date) <= strtotime($policy_date) && strtotime($end_date) >= strtotime($policy_date)){
						if($type=='OD')
						{
							$per=$percentage;
								$per1=0;
							$com=($totalA+$totalC)*((float)$percentage/100);
							 $amt =(float)$amt+(float)$com;
							 
						}
						 elseif($type=='TP')
						 {
							
							$per1=$percentage2; 
								$per=0;
						$com =($totalB)*((float)$percentage2/100)+($totalC)*((float)$percentage/100);
						 $amt =(float)$amt+(float)$com;
						 }
						elseif($type=='Both')
						{
							$per=$percentage;
							$per1=$percentage2;
					 $com=($totalA)*((float)$percentage/100)+($totalB)*((float)$percentage2/100)+($totalC)*((float)$percentage/100);
					  $amt =(float)$amt+(float)$com;
						}
						
						$qur = mysqli_query($con,"Select tbl_vehicle_master.vehicle_type,tbl_agent_commission.credit_amt from tbl_vehicle_master,tbl_agent_commission WHERE tbl_vehicle_master.vehicle_id = '$vehicle_id' and tbl_agent_commission.policy_no='$policy_no'");
						// $qur = mysqli_query($con,"Select tbl_vehicle_master.vehicle_type from tbl_vehicle_master WHERE tbl_vehicle_master.vehicle_id = '$vehicle_id'");
						if(mysqli_num_rows($qur)>0){
							$fetch_qur=mysqli_fetch_assoc($qur);
							$vehicle_type= $fetch_qur['vehicle_type'];
							$short_cash= $fetch_qur['credit_amt'];
							$total_short_cash = $total_short_cash+$fetch_qur['credit_amt'];
						}
						else
						{
							$amount['vehicle_type']= "";
							$amount['short_cash']= "0";
							$total_short_cash = 0;
						}
				
					$detail[$i][0]=$policy_no;
					$detail[$i][1]=$premium;
					$detail[$i][2]=$com;
					$detail[$i][3]=$type;
					$detail[$i][4]=$per;
					$detail[$i][5]=$per1;
					$detail[$i][6]=$short_cash;
						$i++;
					}
				}	
			}
			
			}
			 
		
		}
	
		
		$amt1=number_format($amt,2,'.','');
		$total=strval(number_format($amt,2,'.','')-$total_short_cash);
		$date11=date('Y-m-d', strtotime($start_date .'-0 days'));
		$date22=date('Y-m-d', strtotime($end_date .'-0 days'));
							
						}
						else
						{
							$i=0;
							date_default_timezone_set('Asia/Calcutta');
	$cdate  = date("Y-m-d");
	$cdate1=date('Y-m-d', strtotime($cdate .'-30 days'));
	$agent_id =$_REQUEST['id'];
							$select_premium = mysqli_query($con,"select * from tbl_customer_premium,tbl_policy_master where tbl_customer_premium.agent_id='$agent_id' and tbl_customer_premium.transaction_date>='$cdate1' and tbl_customer_premium.transaction_date<='$cdate' and tbl_customer_premium.policy_no=tbl_policy_master.policy_no and tbl_customer_premium.status='Complete' ORDER by transaction_id");
							
					$amount=0;
	if(mysqli_num_rows($select_premium)>0)
	{    
		while($fetch_details=mysqli_fetch_assoc($select_premium))
		{
			
		$vehicle_id=$fetch_details['vehicle_id'];
		$premium=$fetch_details['agent_received_amt'];
		$policy_date=$fetch_details['transaction_date'];
		$totalA=$fetch_details['totalA'];
		$totalB=$fetch_details['totalB'];
		$totalC=$fetch_details['totalC'];
		$policy_no=$fetch_details['policy_no'];
		$premium=$fetch_details['agent_received_amt'];
		//$shortPremium=$fetch_details['short_premium'];
			
		$query = mysqli_query($con,"SELECT * from tbl_commission_type where tbl_commission_type.vehicle_id='$vehicle_id' order by tbl_commission_type.commission_id");
		
			if(mysqli_num_rows($query)>0)
			{
				while($fetch_percentage=mysqli_fetch_assoc($query)){
					$da=$
					$percentage=$fetch_percentage['percentage'];
				 	$percentage2=$fetch_percentage['percentage2'];
				 	$type=$fetch_percentage['type'];
					$start_date=$fetch_percentage['start_date'];
					$end_date=$fetch_percentage['end_date'];	
					if(strtotime($start_date) <= strtotime($policy_date) && strtotime($end_date) >= strtotime($policy_date)){
						if($type=='OD')
						{
							$per=$percentage;
								$per1=0;
							$com=($totalA+$totalC)*((float)$percentage/100);
							 $amt =(float)$amt+(float)$com;
							 
						}
						 elseif($type=='TP')
						 {
							$per1=$percentage2;
							$per=0;
														
						$com =($totalB)*((float)$percentage2/100)+($totalC)*((float)$percentage/100);
						 $amt =(float)$amt+(float)$com;
						 }
						elseif($type=='Both')
						{
							$per=$percentage;
							$per1=$percentage2;
					 $com=($totalA)*((float)$percentage/100)+($totalB)*((float)$percentage2/100)+($totalC)*((float)$percentage/100);
					  $amt =(float)$amt+(float)$com;
						}
						
						$qur = mysqli_query($con,"Select tbl_vehicle_master.vehicle_type,tbl_agent_commission.credit_amt from tbl_vehicle_master,tbl_agent_commission WHERE tbl_vehicle_master.vehicle_id = '$vehicle_id' and tbl_agent_commission.policy_no='$policy_no'");
						// $qur = mysqli_query($con,"Select tbl_vehicle_master.vehicle_type from tbl_vehicle_master WHERE tbl_vehicle_master.vehicle_id = '$vehicle_id'");
						if(mysqli_num_rows($qur)>0){
							$fetch_qur=mysqli_fetch_assoc($qur);
							$vehicle_type= $fetch_qur['vehicle_type'];
							$short_cash= $fetch_qur['credit_amt'];
							$total_short_cash = $total_short_cash+$fetch_qur['credit_amt'];
						}
						else
						{
							$amount['vehicle_type']= "";
							$amount['short_cash']= "0";
							$total_short_cash = 0;
						}
				
					$detail[$i][0]=$policy_no;
					$detail[$i][1]=$premium;
					$detail[$i][2]=$com;
					$detail[$i][3]=$type;
					$detail[$i][4]=$per;
					$detail[$i][5]=$per1;
					$detail[$i][6]=$short_cash;
						$i++;
					}
				}	
			}
			
			}
			 
		
		}
	
		
		$amt1=number_format($amt,2,'.','');
		$total=strval(number_format($amt,2,'.','')-$total_short_cash);
		
	$date22=date("Y-m-d");
		$date11  = date('Y-m-d', strtotime($cdate .'-30 days'));
							
						}
						
						
						?>
								 <form class="form-horizontal" method="post" name="form2"  enctype="multipart/form-data" style="margin-top:-60px;">
                                <div class="card-body">
                                  
								<div class="form-group row" >
								<div class="col-md-4" id="percentage">	
									<div class="form-group ">
                                        <label for="fname" class=" text-left control-label col-form-label"><b>Commission To be Paid</b></label>
                                        
                                            <input type="text" class="form-control" id="to_be_paid" name="to_be_paid" onkeypress="check(this.value)" value="<?php echo $amt1;?>" onkeyup="validate(this.value)" placeholder="Commission To be Paid" readonly>
											<input type="hidden" class="form-control" id="start_date1" name="date1" value="<?php echo $date11;?>"  >
											<input type="hidden" class="form-control" id="end_date1" name="date2"  value="<?php echo $date22;?>" >
                                        
                                    </div>
                                </div>
                             
								
								<div class="col-md-4" id="percentage2">	
									<div class="form-group ">
                                        <label for="fname" class="text-left control-label col-form-label"><b>Short Cash</b></label>
                                        
                                            <input type="text" class="form-control" id="amount"  name="amount" placeholder="Total" onkeypress="check(this.value)" value="<?php echo $total_short_cash;?>"  onkeyup="check(this.value)" readonly>
                                        
                                    </div>
                                    </div>
									<div class="col-md-4" id="percentage2">	
									<div class="form-group ">
                                        <label for="fname" class="text-left control-label col-form-label"><b>Total</b></label>
                                        
                                            <input type="text" class="form-control" id="amount"  name="amount" placeholder="Total" onkeypress="check(this.value)" value="<?php echo $total;?>"  onkeyup="check(this.value)" >
                                        
                                    </div>
                                    </div>
									
								
                                </div>
								<div class="form-group row">
                                 <div class="col-md-4">   
                                <div class="border-top">
                                    <div class="card-body">
                                       <div class="card-body">
                                    <button type="submit" name="sub" class="btn btn-success">Pay</button>
                                    <button type="button" onclick="myFunction()" name="subcancel" class="btn btn-primary">Reset</button>
                                    
                                </div>
                                    </div>
                                </div>
                                </div>
                                </div>
                            </form>
						
							 <table   border="2px;" width="100%">
                                <thead>
							
								<tr><th colspan="7" style="text-align:center"><b><h4 class="card-title m-b-0" > DETAILS</h4></b></th><tr>
                                 <tr>
								 <th style="text-align:center"><b><h6 class="card-title m-b-0" > Policy No</h6></b></th>
								 <th style="text-align:center"><b><h6 class="card-title m-b-0" > Premium</h6></b></th>
								  <th style="text-align:center"><b><h6 class="card-title m-b-0" > Type</h6></b></th>
								 <th style="text-align:center"><b><h6 class="card-title m-b-0" > OD</h6></b></th>
								 <th style="text-align:center"><b><h6 class="card-title m-b-0" >TP</h6></b></th>
								 <th style="text-align:center"><b><h6 class="card-title m-b-0" > Commission</h6></b></th>
								 <th style="text-align:center"><b><h6 class="card-title m-b-0" > Short Cash</h6></b></th>
								
								 
								 <tr>  
                                </thead>
                                <tbody>
                                    
									<?php for($hj=0;$hj<sizeof($detail);$hj++) { ?>
						
							<tr>
                                        <td><?php echo $detail[$hj][0];?></td>
                                        <td ><?php echo $detail[$hj][1];?></td>
                                        <td ><?php echo $detail[$hj][3];?></td>
                                        <td ><?php echo $detail[$hj][4].'%';?></td>
                                        <td ><?php echo $detail[$hj][5].'%';?></td>
                                        <td ><?php echo $detail[$hj][2];?></td>
                                        <td ><?php echo $detail[$hj][6];?></td>
										</tr>
					
                                    
							
                                   <?php } ?>
									
                                   
                              </tbody>
                            </table>
							
							<?php 
			
			if(isset($_POST['sub']))
				{


$ver = $_SESSION["manager_id"];
		$agent_id =$_REQUEST['id'];
	$to_be_paid=$_POST['to_be_paid'];
	$amount=$_POST['amount'];
	$date1=$_POST['date1'];
	$date2=$_POST['date2'];
	date_default_timezone_set('Asia/Calcutta');
	$cdate  = date("Y-m-d");
	$ctime=date('h:i:s');
	$res_product_stock = mysqli_query($con,"SELECT * FROM  tbl_commission where agent_id='$agent_id' and date1='$date1'and date2='$date2'");
	if(mysqli_num_rows($res_product_stock)<=0){
	$query = mysqli_query($con,"INSERT INTO `tbl_commission`(`agent_id`, `amount`,`date1`,`date2`, `to_be_paid`, `insert_date`, `insert_time`, `manager_id`, `status`) VALUES ('$agent_id','$amount','$date1','$date2','$to_be_paid','$cdate','$ctime','$ver','Pending')");

	$res_agent = mysqli_query($con,"SELECT agent_name,manager_name FROM `tbl_agent`,`tbl_manager` where agent_id ='$agent_id' and tbl_manager.manager_id = '$ver'");
	if(mysqli_num_rows($res_agent)>0)
	{	
		$fetch_detail=mysqli_fetch_assoc($res_agent);
		$agent_name=$fetch_detail['agent_name'];
		$manager_name=$fetch_detail['manager_name'];
	}	

	$title = "Agent Commission Request";
	$message="$manager_name has added request for Commission of Agent $agent_name of amount Rs. $amount";

	$res_device_id = mysqli_query($con,"SELECT device_id,manager_id FROM `tbl_manager` where manage_type = 'Admin'");
	if(mysqli_num_rows($res_device_id)>0)
	{	
		while( $fetch_detail=mysqli_fetch_assoc($res_device_id))
		{
			$key=$fetch_detail['device_id'];
			$manager_id=$fetch_detail['manager_id'];
			include("api/send_notification.php");
			$query = mysqli_query($con,"INSERT INTO `tbl_notification_history`(`manager_id`, `agent_id`, `title`, `message`, `date`, `time`) VALUES ('$manager_id','$agent_id','$title','$message','$cdate','$ctime')");
			
		}
		header('location:agent-commission-history.php');
	}
				}
		
			
				}	
				
							?>
							
							
                        </div>
                    
          

                    </div>
              
                </div>
				
                <!-- editor -->
               
                <!-- ============================================================== -->
                <!-- End PAge Content -->
                <!-- ============================================================== -->
                <!-- ============================================================== -->
                <!-- Right sidebar -->
                <!-- ============================================================== -->
                <!-- .right-sidebar -->
                <!-- ============================================================== -->
                <!-- End Right sidebar -->
                <!-- ============================================================== -->
            </div>
            </div>
            </div>
            <!-- ============================================================== -->
            <!-- End Container fluid  -->
            <!-- ============================================================== -->
            <!-- ============================================================== -->
            <!-- footer -->
            <!-- ============================================================== -->
             <footer class="footer text-center">
                  2019 &copy; All Rights Reserved by BTCOVER. Designed and Developed by <a href="http://www.belltechnology.in/">Bell Technology</a>.
            </footer>
          
            <!-- ============================================================== -->
            <!-- End footer -->
            <!-- ============================================================== -->
        </div>
        <!-- ============================================================== -->
        <!-- End Page wrapper  -->
        <!-- ============================================================== -->
    </div>
    <!-- ============================================================== -->
    <!-- End Wrapper -->
    <!-- ============================================================== -->
    <!-- ============================================================== -->
    <!-- All Jquery -->
    <!-- ============================================================== -->
    <script src="assets/libs/jquery/dist/jquery.min.js"></script>
    <!-- Bootstrap tether Core JavaScript -->
    <script src="assets/libs/popper.js/dist/umd/popper.min.js"></script>
    <script src="assets/libs/bootstrap/dist/js/bootstrap.min.js"></script>
    <!-- slimscrollbar scrollbar JavaScript -->
    <script src="assets/libs/perfect-scrollbar/dist/perfect-scrollbar.jquery.min.js"></script>
    <script src="assets/extra-libs/sparkline/sparkline.js"></script>
    <!--Wave Effects -->
    <script src="dist/js/waves.js"></script>
    <!--Menu sidebar -->
    <script src="dist/js/sidebarmenu.js"></script>
    <!--Custom JavaScript -->
    <script src="dist/js/custom.min.js"></script>
    <!-- This Page JS -->
    <script src="assets/libs/inputmask/dist/min/jquery.inputmask.bundle.min.js"></script>
    <script src="dist/js/pages/mask/mask.init.js"></script>
    <script src="assets/libs/select2/dist/js/select2.full.min.js"></script>
    <script src="assets/libs/select2/dist/js/select2.min.js"></script>
    <script src="assets/libs/jquery-asColor/dist/jquery-asColor.min.js"></script>
    <script src="assets/libs/jquery-asGradient/dist/jquery-asGradient.js"></script>
    <script src="assets/libs/jquery-asColorPicker/dist/jquery-asColorPicker.min.js"></script>
    <script src="assets/libs/jquery-minicolors/jquery.minicolors.min.js"></script>
    <script src="assets/libs/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>
    <script src="assets/libs/quill/dist/quill.min.js"></script>
	<script src="assets/extra-libs/multicheck/datatable-checkbox-init.js"></script>
    <script src="assets/extra-libs/multicheck/jquery.multicheck.js"></script>
    <script src="assets/extra-libs/DataTables/datatables.min.js"></script>
    <script>
        /****************************************
         *       Basic Table                   *
         ****************************************/
        $('#zero_config').DataTable();
    </script>
    <script>
        //***********************************//
        // For select 2
        //***********************************//
        $(".select2").select2();

        /*colorpicker*/
        $('.demo').each(function() {
        //
        // Dear reader, it's actually very easy to initialize MiniColors. For example:
        //
        //  $(selector).minicolors();
        //
        // The way I've done it below is just for the demo, so don't get confused
        // by it. Also, data- attributes aren't supported at this time...they're
        // only used for this demo.
        //
        $(this).minicolors({
                control: $(this).attr('data-control') || 'hue',
                position: $(this).attr('data-position') || 'bottom left',

                change: function(value, opacity) {
                    if (!value) return;
                    if (opacity) value += ', ' + opacity;
                    if (typeof console === 'object') {
                        console.log(value);
                    }
                },
                theme: 'bootstrap'
            });

        });
        /*datwpicker*/
        jQuery('.mydatepicker').datepicker();
        jQuery('#datepicker-autoclose').datepicker({
            autoclose: true,
            todayHighlight: true
        });
        var quill = new Quill('#editor', {
            theme: 'snow'
        });
		jQuery('.mydatepicker').datepicker();
        jQuery('#datepicker-autoclose1').datepicker({
            autoclose: true,
            todayHighlight: true
        });
        var quill = new Quill('#editor', {
            theme: 'snow'
        });

    </script>
</body>

</html>