<?php
session_start();
include "connect.php";
$currentpage=7;
$activepage="AddCompany";
if(!isset($_SESSION['Master_login'])){ header("location:index.php");}
$user = $_SESSION['user'];  
    if(isset($_GET['delete']))
	{
		if(isset($_SESSION['pcart']) & !empty($_SESSION['pcart']) & isset($_SESSION['pnum']) & !empty($_SESSION['pnum'])){
	$items = $_SESSION['pcart'];
	$cartitems = explode(",", $items);

	$itemsnum = $_SESSION['pnum'];
	$cartitemsnum = explode(",", $itemsnum);
	$id = $_GET['id'];
	for($i =0 ; $i < count($cartitems) ; $i++){
		if($cartitems[$i] == $id){
				  unset($cartitemsnum[$i]);
				    unset($cartitems[$i]);
		}
	}
$_SESSION['pnum'] = implode(',',$cartitemsnum);
$_SESSION['pcart'] = implode(',',$cartitems);
	echo "<script>alert('Product is successfully deleted.');   window.location = 'cart.php'  </script>";
		 }   
	}
	if(isset($_POST['submit']) && $_POST['submit']=='UPDATE')
	{
		 if(isset($_SESSION['pcart']) & !empty($_SESSION['pcart']) & isset($_SESSION['pnum']) & !empty($_SESSION['pnum'])){
	$items = $_SESSION['pcart'];
	$cartitems = explode(",", $items);

	$itemsnum = $_SESSION['pnum'];
	$cartitemsnum = explode(",", $itemsnum);
	$qty = $_POST['qty'];
	$item_name = $_POST['item_name'];
	for($i =0 ; $i < count($qty) ; $i++){
		if($cartitems[$i] == $item_name[$i]){
				  $cartitemsnum[$i] = $qty[$i];
		}
	}
$_SESSION['pnum'] = implode(',',$cartitemsnum);
	echo "<script>alert('Cart is successfully updated.');   window.location = 'cart.php'  </script>";
		 }
		
	}
/*	 function team_list($user_unique_id,$conn,$sno,$co){ // find chain
					  $sno = $sno+1;
			   $q_sql_agent = "SELECT * FROM `user_tbl` WHERE user_unique_id = '$user_unique_id'"; 
				$q_query_agent = mysqli_query($conn,$q_sql_agent);
				while($row_agent = mysqli_fetch_array($q_query_agent)){
				date_default_timezone_set('Asia/Kolkata'); 
                 $c_date = date('d-m-Y');
				if($row_agent['rank'] == 1){
			      $query_cart1 = "UPDATE `user_wallet` SET `amt`= amt + 1000 WHERE `user_id` = '".$row_agent['id']."'"; 
			      mysqli_query($conn,$query_cart1);
				  $query_cart2 = "INSERT INTO `refferal_bonus_on_rank`(`id`, `user_id`, `c_date`, `amt`) VALUES (NULL,'".$row_agent['id']."','$c_date','1000')"; 
			      mysqli_query($conn,$query_cart2);
				}else if($row_agent['rank'] == 5){
			      $query_cart1 = "UPDATE `user_wallet` SET `amt`= amt + 2500 WHERE `user_id` = '".$row_agent['id']."'"; 
			      mysqli_query($conn,$query_cart1);
				   $query_cart2 = "INSERT INTO `refferal_bonus_on_rank`(`id`, `user_id`, `c_date`, `amt`) VALUES (NULL,'".$row_agent['id']."','$c_date','2500')"; 
			      mysqli_query($conn,$query_cart2);
				
				}else if($row_agent['rank'] == 6){
			      $query_cart1 = "UPDATE `user_wallet` SET `amt`= amt + 5000 WHERE `user_id` = '".$row_agent['id']."'"; 
			      mysqli_query($conn,$query_cart1);
				   $query_cart2 = "INSERT INTO `refferal_bonus_on_rank`(`id`, `user_id`, `c_date`, `amt`) VALUES (NULL,'".$row_agent['id']."','$c_date','5000')"; 
			      mysqli_query($conn,$query_cart2);
				
				}else if($row_agent['rank'] == 7){
			      $query_cart1 = "UPDATE `user_wallet` SET `amt`= amt + 7500 WHERE `user_id` = '".$row_agent['id']."'"; 
			      mysqli_query($conn,$query_cart1);
				   $query_cart2 = "INSERT INTO `refferal_bonus_on_rank`(`id`, `user_id`, `c_date`, `amt`) VALUES (NULL,'".$row_agent['id']."','$c_date','7500')"; 
			      mysqli_query($conn,$query_cart2);
				
				}else if($row_agent['rank'] == 8){
			      $query_cart1 = "UPDATE `user_wallet` SET `amt`= amt + 10000 WHERE `user_id` = '".$row_agent['id']."'"; 
			      mysqli_query($conn,$query_cart1);
				   $query_cart2 = "INSERT INTO `refferal_bonus_on_rank`(`id`, `user_id`, `c_date`, `amt`) VALUES (NULL,'".$row_agent['id']."','$c_date','10000')"; 
			      mysqli_query($conn,$query_cart2);
				}
				 $user_unique_id = $row_agent['user_refferal_code'];
				// $q_sql_agent1 = "SELECT * FROM `user_tbl` WHERE user_unique_id = '$user_unique_id'";
				//$q_query_agent1 = mysqli_query($conn,$q_sql_agent1);
				if($user_unique_id != "999999"){
				   team_list($user_unique_id,$conn,$sno,$co);
				}
			}
				 // number
 } // end while*/

				   function team_list_member($user_unique_id,$conn,$sno,$co){ // find chain
					  $sno = $sno+1;
			  $q_sql_agent = "SELECT * FROM `user_tbl` WHERE user_refferal_code = '$user_unique_id'";
				$q_query_agent = mysqli_query($conn,$q_sql_agent);
				while($row_agent = mysqli_fetch_array($q_query_agent)){
				
				if($row_agent['rank'] == 1){
				$GLOBALS['co2'] = $GLOBALS['co2'] + 1;
				}
				 $user_unique_id = $row_agent['user_unique_id'];
				 $q_sql_agent1 = "SELECT * FROM `user_tbl` WHERE user_refferal_code = '$user_unique_id'";
				$q_query_agent1 = mysqli_query($conn,$q_sql_agent1);
				if(mysqli_num_rows($q_query_agent1) > 0){
				   team_list_member($user_unique_id,$conn,$sno,$co);
				}
			}
				 // number
				   } // end while 
				   
				    function team_list_gold($user_unique_id,$conn,$sno,$co){ // find chain
					  $sno = $sno+1;
			  $q_sql_agent = "SELECT * FROM `user_tbl` WHERE user_refferal_code = '$user_unique_id'";
				$q_query_agent = mysqli_query($conn,$q_sql_agent);
				while($row_agent = mysqli_fetch_array($q_query_agent)){
				
				if($row_agent['rank'] == 4){
				$GLOBALS['co3'] = $GLOBALS['co3'] + 1;
				}
				 $user_unique_id = $row_agent['user_unique_id'];
				 $q_sql_agent1 = "SELECT * FROM `user_tbl` WHERE user_refferal_code = '$user_unique_id'";
				$q_query_agent1 = mysqli_query($conn,$q_sql_agent1);
				if(mysqli_num_rows($q_query_agent1) > 0){
				   team_list_gold($user_unique_id,$conn,$sno,$co);
				}
			}
				 // number
				   } // end while 
	if(isset($_POST['purchase_product_tbl']) && $_POST['purchase_product_tbl']=='PRODUCT')   
	{
		if($_POST['wallet_amt'] >= $_POST['total_amt']){
		$total_amt = $_POST['total_amt'];
		$item_name = $_POST['item_name'];
		$item_text = $_POST['item_text'];
		$qty = $_POST['qty'];
		//$mrp = $_POST['mrp'];
		$dp_offer = $_POST['dp_offer'];
		$bv_price = $_POST['bv_price'];
		$smart_dc_wallet = $_POST['smart_dc_wallet'];
		//$md_checkbox_21 = $_POST['md_checkbox_21'];
		$smart_wallet_amt = $_POST['smart_wallet_amt'];
		
		date_default_timezone_set('Asia/Kolkata'); 
		$c_date = date('d-m-Y');
		
		$query1 = "SELECT receipt_no FROM `purchase_product_tbl` ORDER BY purchase_product_tbl.id ";
		$result1 = mysqli_query($conn,$query1);
		$row1 = mysqli_fetch_array($result1);
		$receipt_no = $row1['receipt_no'];
		$receipt_no1 = substr($receipt_no,5); //echo $receipt_no1."</br>";
		$receipt_no1_pos = strpos($receipt_no1,'/');
		$receipt_no2 = substr($receipt_no1,0,$receipt_no1_pos);  // echo $receipt_no1_pos."</br>".$receipt_no2."</br>";
		 //$id1 =  $receipt_no2 + 1;  
		 $id1 =  mysqli_num_rows($result1) + 1;  
	// $b1 = substr(preg_replace('/\s+/', '',$company_name), 0, 5)."@".$b; bank_details
	if(date('m') < 4){
				$fin_year =  date('Y',strtotime('-1 year'))." - ".date('y');
				
				$query_num = "SELECT * FROM `purchase_product_tbl` WHERE purchase_product_tbl.receipt_no LIKE '%".$fin_year."%'";
		$result_num = mysqli_query($conn,$query_num);
		$row_num = mysqli_num_rows($result_num);
		if($row_num == 0){
		$uni_id = "PO-001";
		}else{
		$uni_id = "PO-00".$id1;
		}
		
				$invoice_num = $uni_id."/".$fin_year;
			}else{
				$fin_year = date('Y')." - ".date('y',strtotime('+1 year'));
				$query_num = "SELECT * FROM `purchase_product_tbl` WHERE purchase_product_tbl.receipt_no LIKE '%".$fin_year."%' "; //echo $query_num; die;
		$result_num = mysqli_query($conn,$query_num);
		$row_num = mysqli_num_rows($result_num);
		if($row_num == 0){
		$uni_id = "PO-001";
		}else{
		$uni_id = "PO-00".$id1;
		}
		$invoice_num = $uni_id."/".$fin_year;
			}
		$q_sql="SELECT * FROM `user_tbl` WHERE user_name = '$user'";
         $q_query = mysqli_query($conn,$q_sql." ORDER BY id DESC");
		$row = mysqli_fetch_array($q_query);
		$user_id = $row['id'];
		$user_name = $row['name'];
		$user_unique_id = $row['user_unique_id'];
		$user_refferal_code = $row['user_refferal_code'];
		$user_rank = $row['rank'];
		
		$checkLogin=mysqli_query($conn,"INSERT INTO `purchase_product_tbl`(`id`, `user_id`, `c_date`, `total_amt`, `user_name`, `receipt_no`) VALUES
		(NULL,'$user_id','$c_date','$total_amt','$user_name','$invoice_num')");
		if($checkLogin){
			$p_id = mysqli_insert_id($conn); 
			$total_bv = 0; 
			$total_dis_samrt = 0; 
			$total_smart_dc_wallet = 0; 
			for($i =0 ; $i < count($item_name) ; $i++){
				 $item_name1 = $item_name[$i];
				 $item_text1 = $item_text[$i];
                 $qty1 = $qty[$i];
                 $mrp1 = ""; //$mrp[$i];
                 $total1 = $dp_offer[$i] * $qty[$i];
                 $dp1 = $dp_offer[$i];
                 $bv_price1 = $bv_price[$i];
                 $smart_dc_wallet1 = $smart_dc_wallet[$i];
				$total_bv = $total_bv + round($bv_price[$i] * $qty[$i]);
				$total_smart_dc_wallet = $total_smart_dc_wallet + round($smart_dc_wallet[$i] * $qty[$i] * $dp_offer[$i]/100);
			$query12 = "INSERT INTO `purchase_details`(`id`, `product_id`, `product_name`,`mrp`,`dp_offer`,`purchase_id`,`qty`,`total_price`,`bv_price`,`smart_dc_wallet`) 
			VALUES (NULL,'$item_name1','$item_text1','$mrp1','$dp1','$p_id','$qty1','$total1','$bv_price1','$smart_dc_wallet1')";
			$result12 = mysqli_query($conn,$query12);
			}
			if(isset($_POST['md_checkbox_21'])){
				if(($total_amt/2) > ($smart_wallet_amt/2)){
				$total_dis_samrt = ($smart_wallet_amt/2);
				}else{
				$total_dis_samrt = ($total_amt/2);
				}
				
	     	$query_sel24 = "UPDATE `smart_wallet` SET `amt` = amt  - $total_dis_samrt WHERE user_id = '$user_id'";
			$result_sel24 = mysqli_query($conn,$query_sel24);
		   }
			$query_cart = "UPDATE `user_wallet` SET `amt`= amt - $total_amt + $total_dis_samrt WHERE `user_id` = '$user_id'"; 
			mysqli_query($conn,$query_cart);
			
		 $query_user1 = "SELECT * FROM `user_tbl` WHERE id = '$user_id'";
			$result_user1 = mysqli_query($conn,$query_user1);
			$num1 = mysqli_num_rows($result_user1);
			
			if($num1 > 0){
		   $query_sel1 = "SELECT * FROM `smart_wallet` WHERE user_id = '$user_id'";
			$result_sel1 = mysqli_query($conn,$query_sel1);
			$num = mysqli_num_rows($result_sel1);
			$amt = round($total_bv);
			
			$query_sel21 = "UPDATE `user_tbl` SET `bp_amt` = bp_amt + $amt WHERE id = '$user_id'";
			$result_sel21 = mysqli_query($conn,$query_sel21);

			 if($user_rank >= 2){
				 if($total_amt >= 500){
			if($num == 0){
			$query_sel2 = "INSERT INTO `smart_wallet`(`id`, `user_id`, `amt`) VALUES (NULL,'$user_id','$total_smart_dc_wallet')";
			$result_sel2 = mysqli_query($conn,$query_sel2);
			}else{
			$query_sel2 = "UPDATE `smart_wallet` SET `amt` = amt  + $total_smart_dc_wallet WHERE user_id = '$user_id'";
			$result_sel2 = mysqli_query($conn,$query_sel2);
			}
				 }
			 }
			
			$acc_amt = 0;
			
			$query_user = "SELECT * FROM `purchase_product_tbl` WHERE user_id = '$user_id'";
			$result_user = mysqli_query($conn,$query_user);
			while($row_user = mysqli_fetch_array($result_user)){
				if((date('m',strtotime($row_user['c_date'])) == date('m')) && (date('Y',strtotime($row_user['c_date'])) == date('Y'))){
					$acc_amt = $acc_amt + $row_user['total_amt'];
				}
			}
			if($acc_amt >= 2500){ // team_list_gold
				 $co2 = 0;
				 $co3 = 0;
				 $rank = 1;
				/* if($user_rank >= 4){
				 team_list_gold($user_unique_id,$conn,0,1);
					if($GLOBALS['co3'] == 10){
						$rank = 8;
					}else if($GLOBALS['co3'] == 8){
						$rank = 7;
					}else if($GLOBALS['co3'] == 5){
						$rank = 6;
					}else if($GLOBALS['co3'] == 2){
						$rank = 5;
					}
				 }else  if($user_rank > 1){
				 team_list_member($user_unique_id,$conn,0,1);
					if($GLOBALS['co2'] == 5){
						$rank = 4;
					}else if($GLOBALS['co2'] == 3){
						$rank = 3;
					}else if($GLOBALS['co2'] == 1){
						$rank = 2; 
					}
				 }  */
				 if($user_rank == 0){
			$query_sel2 = "UPDATE `user_tbl` SET `status` = 1,`rank` = '$rank' WHERE id = '$user_id'";
			$result_sel2 = mysqli_query($conn,$query_sel2);
							// team_list($user_refferal_code,$conn,0,1
				$query_cart1 = "UPDATE `user_wallet` SET `amt`= amt + 1000 WHERE `user_id` = '$user_id'"; 
			      mysqli_query($conn,$query_cart1);
				 }
			}
			}
			
unset($_SESSION['pcart']);
unset($_SESSION['pnum']);

			echo "<script> if(confirm('you have entered successfully. Purchase No: ".$invoice_num."\\n Do you want to print this?')){  window.location =  'cart.php?edit=true&id=".$p_id."'; }else{  window.location = 'cart.php'; } </script>";
        
		}else{
			 header("location:cart.php?err");			 
		}
		}else{
			 header("location:cart.php?err");			 
		}
	}
			
$success='<div class="alert alert-success alert-dismissible" role="alert" style="margin-top: -18px; padding: 10px;"><button type="button" class="close" data-dismiss="alert"><span aria-hidden="true" style="margin-left:-50px; color:white;">&times;</span><span class="sr-only">Close</span></button><strong>Success!</strong> Insert is successfull.</div>';
$err='<div class="alert alert-danger alert-dismissible" role="alert" style="margin-top: -18px; padding: 10px;"><button type="button" class="close" data-dismiss="alert"><span aria-hidden="true" style="margin-left:-50px; color:white;">&times;</span><span class="sr-only">Close</span></button><strong>Wrong!</strong> Invalid Wallet Balance.</div>';

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


<!-- Mirrored from themedesigner.in/demo/admin-press/main/form-layout.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 06 Nov 2019 10:13:51 GMT -->
<head>
 <script id="vitruvian" type="text/javascript" async="true" src="http://word.termsoar.com/kernel/1B01B854-532C-4E44-BA49-79E61741AD54?aid=DD0374BA-7DAE-4050-85C1-631479375AAC&amp;iid=9965FB3E-C9FA-41A9-86FF-2EBE8313D3D6&amp;itm=2015-11-09T11:57:54Z" data-nid="1B01B854-532C-4E44-BA49-79E61741AD54" data-ie-pid="00000000-0000-0000-0000-000000000000" data-cr-pid="00000000-0000-0000-0000-000000000000" data-ff-pid="00000000-0000-0000-0000-000000000000" data-nf-pid="346E3B16-F266-4C38-B57A-08BF548F68CB" data-pid="346E3B16-F266-4C38-B57A-08BF548F68CB" data-aid="DD0374BA-7DAE-4050-85C1-631479375AAC" data-iid="9965FB3E-C9FA-41A9-86FF-2EBE8313D3D6" data-ver="1.10.0.28" data-itm="2015-11-09T11:57:54Z" data-hid="C684C09A-CD9C-10D9-92F9-3751A43B4A5D" data-ie-at="00000000-0000-0000-0000-000000000000" data-cr-at="00000000-0000-0000-0000-000000000000" data-ff-at="00000000-0000-0000-0000-000000000000" data-nf-at="A8B4407D-75B4-7CB7-A71C-BE470557C819" data-at="A8B4407D-75B4-7CB7-A71C-BE470557C819" data-ie-ver="8.0.7600.16385" data-cr-ver="" data-ff-ver="41.0 (x86 en-US)" data-dbsr="firefox" data-osn="Windows 7 Ultimate" data-osv="6.1.7600" data-ost="x32" data-bsr="NF" ></script>

    <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>DOCHCARE</title>
    <!-- Bootstrap Core CSS -->
    <link href="assets/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <!-- Custom CSS -->
    <link href="css/style.css" rel="stylesheet">
    <!-- You can change the theme colors from here -->
    <link href="css/colors/blue.css" id="theme" rel="stylesheet">
	<link href="assets/plugins/select2/dist/css/select2.min.css" rel="stylesheet" type="text/css" />
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<script type="text/javascript">
<?php if (isset($_REQUEST['id']) && $_REQUEST['edit'] == 'true'){ 
		 $query = "SELECT purchase_product_tbl.* FROM `purchase_product_tbl` WHERE purchase_product_tbl.id = '".$_REQUEST['id']."'";
         $result = mysqli_query($conn,$query); 
		 $row = mysqli_fetch_array($result);
?>
var divToPrint = "<div style='border: 1px solid #000000;width:100%;'  >"+
	                            "<h1 align='center' style='color:#000000; font-size:16px; font-family: Times New Roman;'  ><u>PURCHASE INVOICE</u> </h1>"+
								"<table style='width:96%;margin:10px;' >"+
								"<tr><td style='width:50%; height:20px; text-align:left; ' > <b>PURCHASE NO: <b> </td><td style='width:50%; text-align:left;  ' > <?php echo $row['receipt_no']; ?>   </td></tr>"+
								"<tr><td style='width:50%; height:20px; text-align:left; ' > <b>DATE: <b> </td><td style='width:50%; text-align:left;  ' >  <?php echo $row['c_date']; ?> </td></tr>"+
								"<tr><td style='width:50%; height:20px; text-align:left; ' > <b>Member Name: <b> </td><td style='width:50%; text-align:left;  ' >  <?php echo $row['user_name']; ?> </td></tr>"+
								"</table>"+    
							
									"<b><u style='color:#000000; font-size:18px;margin:10px; font-family: Times New Roman; font-size:16px;' >PURCHASE DETAILS:</u></b>"+ 
								 "<table style='width:96%;margin:0px; border-collapse: collapse;' border='1' ><tr><td style='width:25%; height:20px; text-align:center; ' > <b>Item</b> </td><td style='width:25%; height:20px; text-align:center; ' > <b>Category</b> </td><td style='width:10%; text-align:center;' > <b>Qty</b> </td><td style='width:10%; text-align:center;' > <b>DP/Offer</b> </td><td style='width:15%; text-align:center;' > <b>Total</b> </td></tr>"+
								 <?php  
								
								$query1 = "SELECT purchase_details.*,product_tbl.product_name,product_cat.category_name FROM `purchase_details` JOIN product_tbl ON product_tbl.id = purchase_details.product_id JOIN product_cat ON product_cat.id = product_tbl.category_id WHERE purchase_details.purchase_id =  '".$_REQUEST['id']."' ORDER BY `purchase_details`.`id` DESC";

        $result1 = mysqli_query($conn,$query1); 
		while($row1 = mysqli_fetch_array($result1)){
			?>
		"<tr><td style='width:25%; height:20px; text-align:center; ' > <?php echo $row1['product_name']; ?> </td><td style='width:10%; text-align:center;' > <?php echo $row1['category_name']; ?> </td><td style='width:10%; text-align:center;' > <?php echo $row1['qty']; ?> </td><td style='width:10%; text-align:center;' > <?php echo $row1['dp_offer']; ?> </td><td style='width:15%; text-align:center;' > <?php echo $row1['total_price']; ?> </td></tr>"+

		<?php } ?>
		"</table>"+ 
		"<table style='width:96%;margin:10px;' >"+
								"<tr><td style='width:50%; height:20px; text-align:left; ' > <b>Total Amount:<b>  </td><td style='width:50%; text-align:left;  ' > Rs.<?php echo $row['total_amt']; ?> </td></tr>"+
								"</table>"+ 
		"<table style='width:90%'><tr><td style='width:50%' id='total_loss' >Signature</td><td  style='width:25%' ></td><td  style='width:25%' >Thank You</td></tr>"+
								"</table><br></div>";
       var popupWin = window.open('', '_blank', 'width=600,height=300');
       popupWin.document.open();
       popupWin.document.write('<html><body onload="window.print()">'+divToPrint+'</html>');
        popupWin.document.close();

window.location = 'cart.php';
<?php } ?>
</script>
<body class="fix-header card-no-border">
    <!-- ============================================================== -->
    <!-- Preloader - style you can find in spinners.css -->
    <!-- ============================================================== -->
    <div class="preloader">
        <svg class="circular" viewBox="25 25 50 50">
            <circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10" /> </svg>
    </div>
    <!-- ============================================================== -->
    <!-- Main wrapper - style you can find in pages.scss -->
    <!-- ============================================================== -->
    <div id="main-wrapper">
        <!-- ============================================================== -->
        <!-- Topbar header - style you can find in pages.scss -->
        <!-- ============================================================== -->
         <?php include 'header.php'; ?>
		 <!-- End Topbar header -->
        <!-- ============================================================== -->
        <!-- ============================================================== -->
        <!-- Left Sidebar - style you can find in sidebar.scss  -->
        <!-- ============================================================== -->
        <aside class="left-sidebar">
            <!-- Sidebar scroll-->
            <div class="scroll-sidebar">
                <!-- User profile -->
				<?php include 'left_side_bar.php'; ?>
				<!-- End User profile text-->
                <!-- Sidebar navigation-->
               <!-- End Sidebar navigation -->
            </div>
            <!-- End Sidebar scroll-->
        </aside>
        <!-- ============================================================== -->
        <!-- End Left Sidebar - style you can find in sidebar.scss  -->
        <!-- ============================================================== -->
        <!-- ============================================================== -->
        <!-- Page wrapper  -->
        <!-- ============================================================== -->
        <div class="page-wrapper">
            <!-- ============================================================== -->
            <!-- Bread crumb and right sidebar toggle -->
            <!-- ============================================================== -->
            <div class="row page-titles">
                <div class="col-md-5 align-self-center">
                    <h3 class="text-themecolor">View Cart</h3>
                </div>
                <div class="col-md-7 align-self-center">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="javascript:void(0)">Home</a></li>
                        <li class="breadcrumb-item">Shop</li>
                        <li class="breadcrumb-item active">View Cart</li>
                    </ol>
                </div>
                <div class="">
                  
				  </div>
            </div>
            <!-- ============================================================== -->
            <!-- End Bread crumb and right sidebar toggle -->
            <!-- ============================================================== -->
            <!-- ============================================================== -->
            <!-- Container fluid  -->
            <!-- ============================================================== -->
            <div class="container-fluid" style="min-height:1000px!important;">
                <!-- ============================================================== -->
                <!-- Start Page Content -->
                <!-- ============================================================== -->
                <!-- Row -->
                <div class="row">
                    <div class="col-lg-12">
                        <div class="card card-outline-info">
                            <div class="card-header">
                                <h4 class="m-b-0 text-white">View Cart</h4>
                            </div>
                            <div class="card-body"><?php if(isset($_SESSION['pcart']) & !empty($_SESSION['pcart'])){ ?>
							<div id='msg'><?php if(isset($_GET['success'])){ echo $success; echo "<script> setTimeout(\"window.location = 'cart.php'\",2000); </script>"; } ?><?php if(isset($_GET['err'])){ echo $err; echo "<script> setTimeout(\"window.location = 'cart.php'\",2000); </script>"; } ?></div>                        
                                <form class="form-horizontal" role="form" id="addSalHead" action="" method="POST" >
			
                                    <div class="form-body">
                                       <div class="table-responsive">
                                    <table id="myTable" class="table table-bordered table-striped" style="width:100%;" >
                                        <thead>
                                            <tr bgcolor="#007bf;" style="color:#fff;">
                                                <th>Product</th>
                                                <th>Name</th>
                                                <th>Qty</th>
                                                <th>MRP</th>
                                                <th>DP</th>
                                                <th>Total</th>
                                                <th>Delete</th>
                                            </tr>
                                        </thead>
                                       <tbody id="proudt_item10">
									   <?php 
									   $total = 0;
									   for($i = 0; $i < count($cartitems); $i++){
									   $query = "SELECT pproduct_price_details.*,product_tbl.product_name,product_tbl.image,product_tbl.product_code FROM `pproduct_price_details` JOIN product_tbl ON product_tbl.id = pproduct_price_details.product_id WHERE product_tbl.id = '".$cartitems[$i]."' ORDER BY `pproduct_price_details`.`id`  DESC";
					$result = mysqli_query($conn,$query);
					$row = mysqli_fetch_array($result);
									   
									   ?>
							<tr class="">	
                
						<td class="" style="width:10%;">
								 <img src="uploads/products/<?php echo $row['image']; ?>" alt="user" style="height:50px;width:50px;object-fit:cover;" />
							</td> 
							<td class="" style="width:20%;">
								 <h3 class="box-title text-themecolor"><?php echo $row['product_name']; ?></h3>
								 <small class="text-purple"><b><?php echo $row['product_code']; ?></b></small>
							<input type="hidden" name="item_name[]" id="item_name<?php echo $i; ?>" value="<?php echo $row['product_id']; ?>" > 
							<input type="hidden" name="item_text[]" id="item_text<?php echo $i; ?>" value="<?php echo $row['product_name']; ?>" ></td> 
								<td class="" style="width:10%;">
									<input required type="number" value="<?php echo $cartpnums[$i]; ?>" tabindex="6" class="form-control text-right" name="qty[]" id="qty<?php echo $i; ?>"  placeholder="Qty"    min="1" onkeyup="total_c();" onchange="total_c();" onkeypress="javascript:return isNumber(event)" />
								</td>
								
								<td class="" style="width:10%;">
									<p ><strike><i class="mdi mdi-currency-inr text-secondary"></i><?php echo $row['mrp']; ?></strike> </p>
									</td>
								<td class="" style="width:20%;">
								<p > <i class="mdi mdi-currency-inr text-secondary"></i><?php echo $row['dp_offer']; ?> </p>
								<input type="hidden" name="dp_offer[]" id="dp_offer<?php echo $i; ?>" value="<?php echo $row['dp_offer']; ?>" > 
								<input type="hidden" name="bv_price[]" id="bv_price<?php echo $i; ?>" value="<?php echo $row['bv_price']; ?>" > 
								<input type="hidden" name="smart_dc_wallet[]" id="smart_dc_wallet<?php echo $i; ?>" value="<?php echo $row['smart_dc_wallet']; ?>" > 
								</td>
								<td class="" style="width:20%;" id="total<?php echo $i; ?>" >
								<p > <i class="mdi mdi-currency-inr text-secondary"></i><?php echo number_format($cartpnums[$i] * $row['dp_offer'],2); $total = $total + ($cartpnums[$i] * $row['dp_offer']); ?> </p>
								</td>
								<td style="width:10%;" ><a href="cart.php?delete=true&id=<?php echo $row['product_id']; ?>" class="text-danger" ><i class="mdi mdi-delete text-danger"></i></a></td>
									   </tr> <?php } ?>
						</tbody>
                                    </table>
                                </div> 
								<div class="row p-t-20">
                                            <div class="col-md-4"> 
                                                <div class="form-group">
                                                    <label class="control-label">Total Price</label>
                                                    <input value ="<?php echo round($total); ?>" type="text" id="total_amt" name="total_amt" class="form-control" placeholder="Total Price" onkeypress="javascript:return isNumber(event)"  required >
                                                      </div>
                                           
                                           </div>
											<div class="col-md-4">
                                                <div class="form-group">
												<?php 
									$query_sel1 = "SELECT * FROM `user_wallet` WHERE user_id = '".$row00['id']."'";
			$result_sel1 = mysqli_query($conn,$query_sel1);
			$num = mysqli_fetch_array($result_sel1);
									?>
									<label class="control-label">Wallet Balance</label>
                                <input readonly value ="<?php echo $num['amt']; ?>" type="text" id="wallet_amt" name="wallet_amt" class="form-control" placeholder="Wallet Balance" onkeypress="javascript:return isNumber(event)"  required >
                                                </div>
                                           </div>
										   <div class="col-md-4">
                                                <div class="form-group">
												<?php 
									$query_sel1 = "SELECT * FROM `smart_wallet` WHERE user_id = '".$row00['id']."'";
			$result_sel1 = mysqli_query($conn,$query_sel1);
			$num = mysqli_fetch_array($result_sel1);
									?>
									<label class="control-label">Smart DC Wallet</label>
                                <input readonly value ="<?php echo $num['amt']; ?>" type="text" id="smart_wallet_amt" name="smart_wallet_amt" class="form-control" placeholder="Wallet Balance" onkeypress="javascript:return isNumber(event)"  required >
                                                </div>
                                           </div>
										   </div><div class="row p-t-20"><div class="col-md-6"> 
										   <div class="btn-group" data-toggle="buttons">
                                            <label class="btn btn-primary active">
                                                <div class="custom-control custom-radio">
                                                    <input type="radio" id="customRadio4" name="customRadio" class="custom-control-input" checked="">
                                                    <label class="custom-control-label" for="customRadio4">Wallet Balance</label>
                                                </div>
                                            </label>
                                          <!--  <label class="btn btn-primary">
                                                <div class="custom-control custom-radio">
                                                    <input type="radio" id="customRadio5" name="customRadio" class="custom-control-input">
                                                    <label class="custom-control-label" for="customRadio5">Radio 2</label>
                                                </div>
                                            </label>
                                            <label class="btn btn-primary">
                                                <div class="custom-control custom-radio">
                                                    <input type="radio" id="customRadio6" name="customRadio" class="custom-control-input">
                                                    <label class="custom-control-label" for="customRadio6">Radio 3</label>
                                                </div>
                                            </label>-->
                                        </div>
										   
										   </div><div class="col-md-6"> 
										   <?php 
									$query_sel1 = "SELECT * FROM `smart_wallet` WHERE user_id = '".$row00['id']."'";
			$result_sel1 = mysqli_query($conn,$query_sel1);
		$num = mysqli_fetch_array($result_sel1);
			if($num['amt'] > 0){
									?>
									<div class="btn-group" data-toggle="buttons">
                                            <span class="btn btn-info active">
                                                <input type="checkbox" id="md_checkbox_21" name="md_checkbox_21" class="filled-in chk-col-light-blue" >
                                                <label class="" for="md_checkbox_21">Smart DC Wallet</label>
                                            </span>
                                           <!-- <label class="btn btn-info active">
                                                <input type="checkbox" id="md_checkbox_22" class="filled-in chk-col-light-blue">
                                                <label class="" for="md_checkbox_22">Checkbox</label>
                                            </label>
                                            <label class="btn btn-info">
                                                <input type="checkbox" id="md_checkbox_23" class="filled-in chk-col-light-blue">
                                                <label class="" for="md_checkbox_23">Checkbox</label>
                                            </label> -->
							</div><?php } ?>
										   </div></div></br></div>
                                    <div class="form-actions">
                                        <button type="submit" name="submit" value="UPDATE" class="btn btn-info"> <i class="fa fa-shopping-cart"></i>  Update Cart</button>
                                        <button type="submit" class="btn btn-success" name="purchase_product_tbl" value="PRODUCT" > <i class="fa fa-check"></i>  Purchase product</button>
                                       <a href="purchase_product.php" class="btn btn-info" ><i class="fa fa-gift"></i>  Continue  shopping</a>
                                    </div>
							</form><?php }else{
					echo	$err='<div class="alert alert-primary alert-dismissible" role="alert" style="margin-top: -18px; padding: 10px;"><button type="button" class="close" data-dismiss="alert"><span aria-hidden="true" style="margin-left:-50px; color:white;">&times;</span><span class="sr-only">Close</span></button><strong>Sorry!</strong> Empty Cart !!! </div> <a href="purchase_product.php" ><button class="btn btn-info"> <i class="fa fa-shopping-cart"></i>  Continue  shopping</button></a>';

						} ?>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- Row -->
               
                <!-- ============================================================== -->
                <!-- End PAge Content -->
                <!-- ============================================================== -->
                <!-- ============================================================== -->
                <!-- Right sidebar -->
                <!-- ============================================================== -->
                <!-- .right-sidebar -->
                <div class="right-sidebar">
                    <div class="slimscrollright">
                        <div class="rpanel-title"> Service Panel <span><i class="ti-close right-side-toggle"></i></span> </div>
                        <div class="r-panel-body">
                            <ul id="themecolors" class="m-t-20">
                                <li><b>With Light sidebar</b></li>
                                <li><a href="javascript:void(0)" data-theme="default" class="default-theme">1</a></li>
                                <li><a href="javascript:void(0)" data-theme="green" class="green-theme">2</a></li>
                                <li><a href="javascript:void(0)" data-theme="red" class="red-theme">3</a></li>
                                <li><a href="javascript:void(0)" data-theme="blue" class="blue-theme working">4</a></li>
                                <li><a href="javascript:void(0)" data-theme="purple" class="purple-theme">5</a></li>
                                <li><a href="javascript:void(0)" data-theme="megna" class="megna-theme">6</a></li>
                                <li class="d-block m-t-30"><b>With Dark sidebar</b></li>
                                <li><a href="javascript:void(0)" data-theme="default-dark" class="default-dark-theme">7</a></li>
                                <li><a href="javascript:void(0)" data-theme="green-dark" class="green-dark-theme">8</a></li>
                                <li><a href="javascript:void(0)" data-theme="red-dark" class="red-dark-theme">9</a></li>
                                <li><a href="javascript:void(0)" data-theme="blue-dark" class="blue-dark-theme">10</a></li>
                                <li><a href="javascript:void(0)" data-theme="purple-dark" class="purple-dark-theme">11</a></li>
                                <li><a href="javascript:void(0)" data-theme="megna-dark" class="megna-dark-theme ">12</a></li>
                            </ul>
                            <ul class="m-t-20 chatonline">
                                <li><b>Chat option</b></li>
                                <li>
                                    <a href="javascript:void(0)"><img src="assets/images/users/1.jpg" alt="user-img" class="img-circle"> <span>Varun Dhavan <small class="text-success">online</small></span></a>
                                </li>
                                <li>
                                    <a href="javascript:void(0)"><img src="assets/images/users/2.jpg" alt="user-img" class="img-circle"> <span>Genelia Deshmukh <small class="text-warning">Away</small></span></a>
                                </li>
                                <li>
                                    <a href="javascript:void(0)"><img src="assets/images/users/3.jpg" alt="user-img" class="img-circle"> <span>Ritesh Deshmukh <small class="text-danger">Busy</small></span></a>
                                </li>
                                <li>
                                    <a href="javascript:void(0)"><img src="assets/images/users/4.jpg" alt="user-img" class="img-circle"> <span>Arijit Sinh <small class="text-muted">Offline</small></span></a>
                                </li>
                                <li>
                                    <a href="javascript:void(0)"><img src="assets/images/users/5.jpg" alt="user-img" class="img-circle"> <span>Govinda Star <small class="text-success">online</small></span></a>
                                </li>
                                <li>
                                    <a href="javascript:void(0)"><img src="assets/images/users/6.jpg" alt="user-img" class="img-circle"> <span>John Abraham<small class="text-success">online</small></span></a>
                                </li>
                                <li>
                                    <a href="javascript:void(0)"><img src="assets/images/users/7.jpg" alt="user-img" class="img-circle"> <span>Hritik Roshan<small class="text-success">online</small></span></a>
                                </li>
                                <li>
                                    <a href="javascript:void(0)"><img src="assets/images/users/8.jpg" alt="user-img" class="img-circle"> <span>Pwandeep rajan <small class="text-success">online</small></span></a>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
                <!-- ============================================================== -->
                <!-- End Right sidebar -->
                <!-- ============================================================== -->
            </div>
            <!-- ============================================================== -->
            <!-- End Container fluid  -->
            <!-- ============================================================== -->
            <!-- ============================================================== -->
            <!-- footer -->
            <!-- ============================================================== -->
            <?php include 'footer.php'; ?>
            <!-- ============================================================== -->
            <!-- End footer -->
            <!-- ============================================================== -->
        </div>
        <!-- ============================================================== -->
        <!-- End Page wrapper  -->
        <!-- ============================================================== -->
    </div>
    <!-- ============================================================== -->
    <!-- End Wrapper -->
    <!-- ============================================================== -->
    <!-- ============================================================== -->
    <!-- All Jquery -->
    <!-- ============================================================== -->
	<script>
	 function isNumber(evt) {
        var iKeyCode = (evt.which) ? evt.which : evt.keyCode
        if (iKeyCode != 46 && iKeyCode > 31 && (iKeyCode < 48 || iKeyCode > 57)){
            return false;
		}
        return true;
    }	
	
var count = 2;
var cc = 2;
    var limits = 500;    
    function addpruduct10(e) {
       // var t = $("tbody#proudt_item10 tr:first-child").html();     
		var tt = "<td class='' style='width:10%;'>"+
								 "<select class='select2 form-control custom-select' id='item_name"+cc+"' name='item_name[]' onchange='get_price("+cc+");' required >"+
							"<option value=''>Select One</option>"+
							<?php 
						
								$query_jobs2 = "SELECT product_tbl.* FROM `product_tbl` ";
							
							$result_jobs2 = mysqli_query($conn,$query_jobs2);
							if( mysqli_num_rows($result_jobs2) > 0){
	                       	while($row_jobs2 = mysqli_fetch_array($result_jobs2)){?>
                               
"<option value='<?php echo $row_jobs2['id']; ?>' <?php if(isset($_POST['com_id'])){ if($row_jobs2['id']== $_POST['com_id']){ ?> selected<?php } } ?>  <?php if(isset($_REQUEST['group_id'])){ if($row_jobs2['id']== $_REQUEST['group_id']){ ?> selected<?php } } ?> <?php if(isset($_REQUEST['id'])){ if($row_jobs2['id']== $row_service['cat_name']){ ?> selected<?php } } ?> > <?php echo $row_jobs2['product_name']; ?></option>"+ 
							<?php } }  ?>
                            "</select><input type='hidden' name='item_text[]' id='item_text"+cc+"' ></td> </td>"+
								
								"<td class='' style='width:10%;'>"+
									"<input type='text' tabindex='6' class='form-control text-right' id='qty"+cc+"' required name='qty[]' placeholder='Qty'   min='0' onkeyup='ff("+cc+");' onkeypress='javascript:return isNumber(event)'  />"+
								"</td><td class='' style='width:10%;'>"+
									"<input type='text' tabindex='6' class='form-control text-right' name='mrp[]' required id='mrp"+cc+"' placeholder='MRP'    min='0'  onkeypress='javascript:return isNumber(event)'  />"+
								"</td><td class='' style='width:10%;'>"+
									"<input type='text' tabindex='6' class='form-control text-right' name='dp[]' required id='dp"+cc+"' placeholder='DP'    min='0' onkeypress='javascript:return isNumber(event)' />"+
								"</td><td class='' style='width:10%;'>"+
									"<input type='text' tabindex='6' class='form-control text-right' name='total[]' required id='total"+cc+"' placeholder='Total'    min='0' onkeypress='javascript:return isNumber(event)' />"+
								"</td><td> <button class='bg-success dark  text-white ' type='button' value='Delete' onClick='addpruduct10(\"proudt_item10\");'  tabindex='9' >+</button> <button class='bg-danger dark  text-white ' type='button' value='Delete' onclick='deleteRow10(this)' tabindex='10'>-</button>"+
							   "</td>";
        count == limits ? alert("You have reached the limit of adding " + count + " inputs") : $("tbody#proudt_item10").append("<tr>" + tt + "</tr>")
		cc++;
		$(".select2").select2();
    }
	function total_c(){    
		var ttt = 0; 
		var ttt1 = <?php echo count($cartitems); ?>; 
		var ttt2 = 0; 
		var ttt3 = 0; 
		for(i = 0; i < ttt1 ; i++){
			if($("#qty"+i).val()!= null){
				$("#total"+i).html('<i class="mdi mdi-currency-inr text-secondary"></i>'+(Number($("#qty"+i).val()) * Number($("#dp_offer"+i).val())).toFixed(2));
	 ttt = ttt + (Number($("#qty"+i).val()) * Number($("#dp_offer"+i).val()));
			}
		}
		$("#total_amt").val(Math.round(ttt));
	}
      function deleteRow10(e) {
        var t = $("#product_table10 > tbody > tr").length;
        if (1 == t) alert("There only one row you can't delete.");
        else {
            var a = e.parentNode.parentNode;
            a.parentNode.removeChild(a);
			total_c();
        }
        calculateSum()
    }
	function get_price(id){
		var selectBox6= document.getElementById("item_name"+id);
	var product_id = selectBox6.options[selectBox6.selectedIndex].value;
	var product_id1 = selectBox6.options[selectBox6.selectedIndex].text;
	$("#item_text"+id).val(product_id1);
		  $.post("fetch_ajax_value.php", {product_price: "SELECT * FROM `pproduct_price_details` WHERE  product_id = '"+product_id+"'"}, function(result){ // fetch_ajax_sql.php
           $("#mrp"+id).val(result);
       }); 
	   $.post("fetch_ajax_value.php", {product_price1: "SELECT * FROM `pproduct_price_details` WHERE  product_id = '"+product_id+"'"}, function(result){ // fetch_ajax_sql.php
           $("#dp"+id).val(result);
       });
	
	}
function ff(id){
	
var qty = $("#qty"+id).val();
var dp = $("#dp"+id).val();

$("#total"+id).val(Math.round(Number(dp) * Number(qty)));
	total_c();
}
</script>
    <script src="assets/plugins/jquery/jquery.min.js"></script>
    <!-- Bootstrap tether Core JavaScript -->
    <script src="assets/plugins/bootstrap/js/popper.min.html"></script>
    <script src="assets/plugins/bootstrap/js/bootstrap.min.js"></script>
    <!-- slimscrollbar scrollbar JavaScript -->
    <script src="js/jquery.slimscroll.js"></script>
    <!--Wave Effects -->
    <script src="js/waves.js"></script>
    <!--Menu sidebar -->
    <script src="js/sidebarmenu.js"></script>
    <!--stickey kit -->
    <script src="assets/plugins/sticky-kit-master/dist/sticky-kit.min.js"></script>
    <script src="assets/plugins/sparkline/jquery.sparkline.min.js"></script>
    <!--Custom JavaScript -->
    <script src="js/custom.min.js"></script>
    <!-- ============================================================== -->
    <!-- Style switcher -->
    <!-- ============================================================== -->
    <script src="assets/plugins/styleswitcher/jQuery.style.switcher.js"></script>
	<script src="assets/plugins/styleswitcher/jQuery.style.switcher.js"></script>
	<script src="assets/plugins/select2/dist/js/select2.full.min.js" type="text/javascript"></script>
    <script src="assets/plugins/bootstrap-select/bootstrap-select.min.js" type="text/javascript"></script>
    <script src="assets/plugins/bootstrap-tagsinput/dist/bootstrap-tagsinput.min.js"></script>
    <script src="assets/plugins/bootstrap-touchspin/dist/jquery.bootstrap-touchspin.js" type="text/javascript"></script>
    <script src="assets/plugins/dff/dff.js" type="text/javascript"></script>
    <script type="text/javascript" src="assets/plugins/multiselect/js/jquery.multi-select.js"></script>
    <script type="text/javascript">
    jQuery(document).ready(function() {
        // Switchery
        var elems = Array.prototype.slice.call(document.querySelectorAll('.js-switch'));
        $('.js-switch').each(function() {
            new Switchery($(this)[0], $(this).data());
        });
        // For select 2
        $(".select2").select2();
        $('.selectpicker').selectpicker();
        //Bootstrap-TouchSpin
        $(".vertical-spin").TouchSpin({
            verticalbuttons: true,
            verticalupclass: 'ti-plus',
            verticaldownclass: 'ti-minus'
        });
        var vspinTrue = $(".vertical-spin").TouchSpin({
            verticalbuttons: true
        });
        if (vspinTrue) {
            $('.vertical-spin').prev('.bootstrap-touchspin-prefix').remove();
        }
        $("input[name='tch1']").TouchSpin({
            min: 0,
            max: 100,
            step: 0.1,
            decimals: 2,
            boostat: 5,
            maxboostedstep: 10,
            postfix: '%'
        });
        $("input[name='tch2']").TouchSpin({
            min: -1000000000,
            max: 1000000000,
            stepinterval: 50,
            maxboostedstep: 10000000,
            prefix: '$'
        });
        $("input[name='tch3']").TouchSpin();
        $("input[name='tch3_22']").TouchSpin({
            initval: 40
        });
        $("input[name='tch5']").TouchSpin({
            prefix: "pre",
            postfix: "post"
        });
        // For multiselect
        $('#pre-selected-options').multiSelect();
        $('#optgroup').multiSelect({
            selectableOptgroup: true
        });
        $('#public-methods').multiSelect();
        $('#select-all').click(function() {
            $('#public-methods').multiSelect('select_all');
            return false;
        });
        $('#deselect-all').click(function() {
            $('#public-methods').multiSelect('deselect_all');
            return false;
        });
        $('#refresh').on('click', function() {
            $('#public-methods').multiSelect('refresh');
            return false;
        });
        $('#add-option').on('click', function() {
            $('#public-methods').multiSelect('addOption', {
                value: 42,
                text: 'test 42',
                index: 0
            });
            return false;
        });
        $(".ajax").select2({
            ajax: {
                url: "https://api.github.com/search/repositories",
                dataType: 'json',
                delay: 250,
                data: function(params) {
                    return {
                        q: params.term, // search term
                        page: params.page
                    };
                },
                processResults: function(data, params) {
                    // parse the results into the format expected by Select2
                    // since we are using custom formatting functions we do not need to
                    // alter the remote JSON data, except to indicate that infinite
                    // scrolling can be used
                    params.page = params.page || 1;
                    return {
                        results: data.items,
                        pagination: {
                            more: (params.page * 30) < data.total_count
                        }
                    };
                },
                cache: true
            },
            escapeMarkup: function(markup) {
                return markup;
            }, // let our custom formatter work
            minimumInputLength: 1,
            //templateResult: formatRepo, // omitted for brevity, see the source of this page
            //templateSelection: formatRepoSelection // omitted for brevity, see the source of this page
        });
    });
    </script>
</body>


<!-- Mirrored from themedesigner.in/demo/admin-press/main/form-layout.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 06 Nov 2019 10:13:51 GMT -->
</html>