<%@ Page Language="C#" AutoEventWireup="true" CodeFile="admissioncancellist.aspx.cs" MasterPageFile="~/module/dashboardPage.master" Inherits="module_admissioncancellist" %>

<asp:Content ID="content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script type="text/javascript">
        $(document).ready(function () {
            datatable();
            $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: "admissioncancellist.aspx/PopulateDropDownList4",
                data: "",
                dataType: "json",
                success: function (result) {
                    $('select[id$=ddlyears]').empty();
                    $('select[id$=ddlyears]').append("<option value='0'>Select Year</option>");
                    $.each(result.d, function (key, value) {
                        var ddyear1 = value.DeptName;
                        var ddyear2 = value.year1;
                        var dtyear1 = new Date(ddyear1);
                        var dtyear2 = new Date(ddyear2);
                        var stryr = dtyear1.getFullYear() + "-" + dtyear2.getFullYear();

                        $('select[id$=ddlyears]').append($("<option data-toggle='tooltip' data-placement='top' title='" + stryr + "'></option>").val(value.DeptId).html(stryr));
                        //console.log(value.DeptName);
                    });
                    $('select[id$=ddlyears]').val('0').change();
                    $('select[id$=ddlyears]').trigger("change");
                    //$('select[id$=cat] option:eq(0)').attr("selected", true);
                    //  $('select[id$=ddlclassty]').selectpicker('refresh');
                    //  hdndoc=$('select[id$=cat] option:eq(1)').val();
                },
                error: function ajaxError(result) {
                    console.log(result.status + ' : ' + result.statusText);
                }

            });
            $('select[id$=ddlyears]').change(function () {
                $.ajax({
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    url: "admissioncancellist.aspx/PopulateDropDownList5",
                    data: "",
                    dataType: "json",
                    success: function (result) {
                        $('select[id$=ddlsclass]').empty();
                        $('select[id$=ddlsclass]').append("<option value='0'>Select class</option>");
                        $.each(result.d, function (key, value) {
                            var dd = value.DeptName;


                            $('select[id$=ddlsclass]').append($("<option data-toggle='tooltip' data-placement='top' title='" + dd + "'></option>").val(value.DeptId).html(dd));
                            //console.log(value.DeptName);
                        });
                        $('select[id$=ddlsclass]').val('0').change();
                        //$('select[id$=cat] option:eq(0)').attr("selected", true);
                        //  $('select[id$=ddlclassty]').selectpicker('refresh');
                        //  hdndoc=$('select[id$=cat] option:eq(1)').val();
                    },
                    error: function ajaxError(result) {
                        console.log(result.status + ' : ' + result.statusText);
                    }

                });
            });
            $('select[id$=ddlsclass]').change(function () {
                $.ajax({
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    url: "admissioncancellist.aspx/PopulateDropDownList6",
                    data: "{clids :'" + $('select[id$=ddlsclass]').val() + "'}",
                    dataType: "json",
                    success: function (result) {
                        $('select[id$=ddldivision]').empty();
                        $('select[id$=ddldivision]').append("<option value='0'>Select Division</option>");
                        $.each(result.d, function (key, value) {
                            var dd = value.DeptName;


                            $('select[id$=ddldivision]').append($("<option data-toggle='tooltip' data-placement='top' title='" + dd + "'></option>").val(value.DeptId).html(dd));
                            //console.log(value.DeptName);
                        });
                        $('select[id$=ddldivision]').val('0').change();
                        //$('select[id$=cat] option:eq(0)').attr("selected", true);
                        //  $('select[id$=ddlclassty]').selectpicker('refresh');
                        //  hdndoc=$('select[id$=cat] option:eq(1)').val();
                    },
                    error: function ajaxError(result) {
                        console.log(result.status + ' : ' + result.statusText);
                    }

                });
  });
        });
        var staddress = "";
        function datatable() {
            $.ajax({
                type: "POST",
                url: "admissioncancellist.aspx/GetData",
                contentType: "application/JSON; charset=utf-8",

                datatype: "JSON",
                success: function (data) {
                    var table = $('#dataemp').DataTable();
                    data = JSON.parse(data.d);

                    table.clear();
                    for (var i = 0, count = 1; i < data.length; i++, count++) {
                        staddress = data[i].resiaddrss + "," + data[i].cityname + "," + data[i].stname + "," + data[i].pin;
                        ddyear1 = data[i].fromdate;
                        ddyear2 = data[i].todate;
                        dtyear1 = new Date(ddyear1);
                        dtyear2 = new Date(ddyear2);
                        stryr = dtyear1.getFullYear() + "-" + dtyear2.getFullYear();
                        var fullname = data[i].title + "." + data[i].fname + " " + data[i].mname + " " + data[i].lname;
                        if (data[i].canceladmission == "1") {
                            staddress = "Cancelled";
                        }
                        table.row.add([

                        count, data[i].studid, fullname, data[i].admdt, stryr, data[i].classname, data[i].divname, staddress, '<button style="height:35px; width: 35px; padding-left:7px;" title="Readmission" onclick=readmitstudent(\'' + data[i].studid + '\',' + data[i].studentids + ') type="button" class="btn btn-primary"><i class="lni lni-save"></i></button>'
                            

                        ]).draw(true);

                    }
                }
            });
        }
        function readmitstudent(studid, stsud) {alert(stsud);
        
            $.ajax({
                url: 'admissioncancellist.aspx/readmit',
                type: 'post',
                contentType: 'application/json;charset=utf-8',
                dataType: 'json',
                data: "{studentids:'" + studid + "',sid:'" + stsud + "'}",
                success: function (data) {
                    if (data.d == "update") {
                        datatable();
                        noty({ text: 'Student Readmitted', layout: 'topRight', type: 'information' });
                        setTimeout(function () { $.noty.closeAll(); }, 3000);


                      
                    }
                },
                error: function () {
                    alert("Insert Error");

                }

            });

        }
        function getdata13() {
            var obj2 = {};
            obj2.yrsid = $("select[id$=ddlyears]").val();
            obj2.cldid = $("select[id$=ddlsclass]").val();
            obj2.divsid = $("select[id$=ddldivision]").val();
            $.ajax({
                type: "POST",
                url: "admissioncancellist.aspx/GetDatasearch",
                contentType: "application/JSON; charset=utf-8",
                data : JSON.stringify(obj2),
                datatype: "JSON",
                success: function (data) {
                    var table = $('#dataemp').DataTable();
                    data = JSON.parse(data.d);

                    table.clear();
                    for (var i = 0, count = 1; i < data.length; i++, count++) {
                        staddress = data[i].resiaddrss + "," + data[i].cityname + "," + data[i].stname + "," + data[i].pin;
                        ddyear1 = data[i].fromdate;
                        ddyear2 = data[i].todate;
                        dtyear1 = new Date(ddyear1);
                        dtyear2 = new Date(ddyear2);
                        stryr = dtyear1.getFullYear() + "-" + dtyear2.getFullYear();
                        var fullname = data[i].title + "." + data[i].fname + " " + data[i].mname + " " + data[i].lname;
                        if (data[i].canceladmission == "1") {
                            staddress = "Cancelled";
                        }
                        table.row.add([

                        count, data[i].studid, fullname, data[i].admdt, stryr, data[i].classname, data[i].divname, staddress, '<button style="height:35px; width: 35px; padding-left:7px;" title="Readmission" onclick=readmitstudent(\'' + data[i].studid + '\',' + data[i].studentids + ') type="button" class="btn btn-primary"><i class="lni lni-save"></i></button>'


                        ]).draw(true);

                    }
                }
            });
        }
    </script>
<div class="page-wrapper">
			<div class="page-content">
				<div class="row">
					<div class="col-md-12 mx-auto" >
                        	<div class="card">
					<div class="card-body">
						<div class="card-title d-flex align-items-center">

							<h6>Admission Cancel List</h6>
						</div>
						<hr/>
						
						
						<form class="row g-2">
							<div class="col-md-2">
								<label>Year</label>
								<select id="ddlyears" class="form-select mb-3" aria-label="Default select example">
													
								</select>
							</div>	
                            <div class="col-md-2">
								<label>College</label>
								<select id="Select1" class="form-select mb-3" aria-label="Default select example">
									<option value="0">Select</option>
									<option value="1">Hi-Tech College of B. Pharmacy</option>
												
								</select>
							</div>															
							<div class="col-md-2">
								<label>Class</label>
								<select id="ddlsclass" class="form-select mb-3" aria-label="Default select example">
						
								</select>
							</div>
							<div class="col-md-2">
								<label>Division</label>
								<select id="ddldivision" class="form-select mb-3" aria-label="Default select example">
																			
								</select>
							</div>														
					       <div class="col-md-3" style="margin-top: 4.7vh;">
							<button type="button" onclick="getdata13();" class="btn btn-primary"><i class='bx bx-search'></i>Search</button>
																
						   </div>						   
                           </form>
                       </div>
                   </div> 
                         <div class="overlay toggle-icon"></div>
				   <hr/>
				   <div class="col-md-12 mx-auto">
				   <div class="card">
					   <div class="card-body">
						   <div class="table-responsive">
							   <table id="dataemp" class="table table-striped table-bordered">
								   <thead>
									   <tr>
										   <th>Sr.no </th>	
										   <th>Student ID</th>
										   <th>Student Name</th>  
                                           <th>Admission Date</th>
                                           <th>Academic Year</th>
										   <th>Class Name</th>
										   <th>Divison</th>
										 <th>Status</th>
										 
										<%--   <th>Create Date</th>--%>
									 <th style="background-color:white;">Action</th>
									   </tr>
								   </thead>
                                
								   <%--<tbody>
									<tr>
										<td></td>
										<td><input></td>
										<td><input></td>
										<td><input></td>
										<td><input></td>
										<td><input></td>
										<td><input></td>
										<td><input></td>
										<td style="background-color:white;"></td>
									</tr>
									   <tr>
										   <td>1</td>
										   <td>1321</td>	
										   <td>CAP</td>
										   <td>B.Pharm</td>
										   <td>1st Year</td>
										   <td>12-14-2022</td>
										   <td>749.00</td>
										   <td>14-10-2022</td>
										   <td style="background-color: white;">
											<button style="height:35px; width: 35px; padding-left:7px;" type="button" class="btn btn-secondary" data-bs-toggle="modal" data-bs-target="#exampleLargeModal5"><i class="fadeIn animated bx bx-user-plus"></i>
											</button>							
											<button  style="height:35px; width: 35px; padding-left:7px;" type="button" class="btn btn-success"  data-bs-toggle="modal" data-bs-target="#exampleLargeModal5" ><i class='bx bx-message-square-edit'></i>
											</button>&nbsp;<button  style="height:35px; width: 35px; padding-left:7px;" type="button" class="btn btn-danger"><i class="fadeIn animated bx bx-trash-alt"></i>
											</button>
											<button  style="height:35px; width: 35px; padding-left:7px;" type="button" class="btn btn-primary"><i class="lni lni-save"></i>
											</button>
										   </td>										
										   </tr>
										   <tr>
											<td>2</td>
											<td>1321</td>	
											<td>APC</td>
											<td>M.Pharm</td>
											<td>1st Year</td>
											<td>12-14-2022</td>
											<td>749.00</td>
											<td>14-10-2022</td>
											<td style="background-color: white;">
											 <button style="height:35px; width: 35px; padding-left:7px;" type="button" class="btn btn-secondary" data-bs-toggle="modal" data-bs-target="#exampleLargeModal5"><i class="fadeIn animated bx bx-user-plus"></i>
											 </button>								
											 <button style="height:35px; width: 35px; padding-left:7px;" type="button" class="btn btn-success"  data-bs-toggle="modal" data-bs-target="#exampleLargeModal5" ><i class='bx bx-message-square-edit'></i>
											 </button>
											 <button style="height:35px; width: 35px; padding-left:7px;" type="button" class="btn btn-danger"><i class="fadeIn animated bx bx-trash-alt"></i>
											 </button>
											 <button style="height:35px; width: 35px; padding-left:7px;" type="button" class="btn btn-primary"><i class="lni lni-save"></i>
											 </button>
											</td>										
											</tr>
									   </tbody>--%>
							   </table>
						   </div>
					   </div>
				   </div>
			   </div>
                        </div>
                    </div>
                </div>
         </div>
    </asp:Content> 	