<?php include("parent/callMe.php"); ?>

<?php  include("sessioncheck.php"); ?>



<?php



 $sql = "SELECT * FROM  dummy_data_insert";

 // print_r($sql);

 $WorkAssignListings = $m->query($sql); 



 ?>



<!DOCTYPE html>

<html lang="en">

  <head>

   

    <title> View Students | EduPortal </title>

     <?php include('RootMe/css_links.php');?> 

  </head>

  





  <body class="nav-md">

    <div class="container body">

      <div class="main_container">

        <div class="col-md-3 left_col">

     

            <?php include('RootMe/sidebar.php');?>



              <?php include('RootMe/header.php');?>

     

        <!-- page content -->

            <div class="right_col" role="main">

            <div class="row" style="background-color: white;">

  



<section class="add_sub_agent" id="table_sub_agent">

  <div class="container">







<table id="listofstudents" class="table table-striped table-bordered" style="width:100%">

  <input onClick="return confirm('Are you sure you want to struck of all students course completed?');" class="btn btn-primary pull-right" type="submit" name="Delete" value=" Struck of as Course Completed">

  

   

        <thead>

            <tr>



              

                <th width="5%">S.No</th>

                <th width="20%">Student Name</th>

                <th width="10%">Father Name</th>

                <th width="10%">Registration</th>

                <th width="10%"> rollNo </th>

                <th width="15%"> CellNo </th>

                <th width="10%"> DOA </th>

                <th width="10%"> DOB</th>

                <th width="10%"> Address</th>

                <th width="8%">class_id </th>

                <th width="8%">section </th>

                <th width="3%"> gender</th>

                <th width="3%"> monthlyFee</th>



               

                

            </tr>

        </thead>

        <tbody>





 

     <?php 

     //echo $_SESSION['branch'];

$count=1;

      foreach($WorkAssignListings as $WorkAssignListVal)

      { 

        $AdmDateForspace = preg_replace( '/\s+/', '', $WorkAssignListVal['AdmissionDate'] );



        $dobdatespace = preg_replace( '/\s+/', '', $WorkAssignListVal['DateofBirth'] );



        $joiningdatespace = preg_replace( '/\s+/', '', $WorkAssignListVal['DateOfJoining'] );



        $classSec=(explode("-",$WorkAssignListVal['class']));



        $admdate=(explode("/",$AdmDateForspace));

        $AdmDateFor=$admdate[2]."-".$admdate[1]."-".$admdate[0];

        //$AdmDateFor=$admdate[2]."-".$admdate[0]."-".$admdate[1];

//echo $classSec[0];



       $dobdate=(explode("/",$dobdatespace));

        $DobDateFor=$dobdate[2]."-".$dobdate[1]."-".$dobdate[0];

        //$DobDateFor=$dobdate[2]."-".$dobdate[0]."-".$dobdate[1];



        $joiningdate=(explode("/",$joiningdatespace));

        $JoiningDateFor=$joiningdate[2]."-".$joiningdate[1]."-".$joiningdate[0];





        $expeldate=(explode("/",$WorkAssignListVal['DateOfJoining']));

        $expelDateFor=$expeldate[2]."-".$expeldate[1]."-".$expeldate[0];



       // echo $DobDateFor."<br>";

        $m->where("Class_Name", $WorkAssignListVal['class']);

        $m->where("branch_id", $_SESSION['branch']);

        $class=$m->get("edu_class_config");

//echo $class[0]['class_id'];

        $m->where("class_id", $class[0]['class_id']);

        $m->where("section_name", $WorkAssignListVal['section']);

        $m->where("branch_id", $_SESSION['branch']);

        $section=$m->get("edu_adm_section_detail");

//echo $section[0]['section_id'];



        $m->where("locality_name", $WorkAssignListVal['RoadArea']);

        $m->where("branch_id", $_SESSION['branch']);

        $localityID=$m->get("eduportal_branch_locality");





        $m->where("Class_Name", $WorkAssignListVal['Batch']);

        $m->where("branch_id", $_SESSION['branch']);

        $classAdmited=$m->get("edu_class_config");





        $Fatherphone = preg_replace( '/\s+/', '', $WorkAssignListVal['ContactNoFather'] );

        $Motherphone = preg_replace( '/\s+/', '', $WorkAssignListVal['ContactNoMother'] );



       // $AdmDateFor = preg_replace( '/\s+/', '', $AdmDateFor );







      $m->where("session_id", $_SESSION['current_session']);



      $ss11=$m->get("edu_session_config");



      $session=$ss11[0]['session_year']-2000;



  // coding to generate auto roll number



        $ss="-".$session."-";



    $sql = "SELECT MAX(CAST(SUBSTR(candidate_roll_no,4,LENGTH(candidate_roll_no)) AS UNSIGNED)) AS prev_roll



    FROM edu_student_details as std WHERE std.branch_id =  '$branch' AND std.status='0'



    ";  



    //  print_r($sql);



      $numb;



      



      $evt =$m->query($sql);

      



      $prev= $evt[0]['prev_roll'];



        if($prev!=NULL){    



            $numb=$prev+1;        

//echo $numb;

        } else{$numb+=1;}



        $roll=str_pad($numb,3,'0',STR_PAD_LEFT);



    

        $newRoll=$session."-".$roll;







        if ($newRoll!=NULL){    



          $roll= $newRoll;



        }



        else{



          



          $roll= "--";



          



          } // closing code for generating roll number





 //echo "<pre>"; print_r($roll); echo "</pre>";

$complete='Course Completed';



$data = array(



'branch_id' => $_SESSION['branch'],

'session_id' => $_SESSION['current_session'],

'first_name' => $WorkAssignListVal['StudentName'],

'last_name' => $WorkAssignListVal['FatherName'],

'class_id' => $class[0]['class_id'],

'section_id' => $section[0]['section_id'],

'ref_no' => $WorkAssignListVal['AdmNo'],

//'studentID' => $WorkAssignListVal['StudentID'],

// 'expel_date' => $WorkAssignListVal['DateOfJoining'],

 //'expel_reason' => $complete,

'candidate_roll_no' => $roll,

'gender' => $WorkAssignListVal['Gender'],

//'adding_date' => date("Y-m-d"),

 //'cat_id' => 135,

'status' => '0',

'date_of_adms' => $AdmDateFor,

'cell_no' => "0".$WorkAssignListVal['ContactNoFather'],

//'father_cellno' => "0".$WorkAssignListVal['ContactNoMother'],

'mother_cell' => "0".$WorkAssignListVal['ContactNoMother'],

//'gardian_no' => $WorkAssignListVal['whatsapp_no'],

//'home_number' => "0".$WorkAssignListVal['whatsapp_no'],

//'whatsapp_number' => "0".$WorkAssignListVal['whatsapp_no'],

//'gardian_name' => $WorkAssignListVal['guardian'],

//'gardian_cnic' => $WorkAssignListVal['guardian_cnic'],

//'gardian_occupation' => $WorkAssignListVal['guardian_occupation'],

//'gardian_address' => $WorkAssignListVal['guardian_address'],

//'family_code' => $WorkAssignListVal['Family'],

//'Batch' => $WorkAssignListVal['Batch'],

//'father_Bnumber' => "0".$WorkAssignListVal['ContactNoMother'],

//'locality' => $localityID[0]['locality_id'],

 'class_admited' => $classAdmited[0]['class_id'],

//'father_occupation' => $WorkAssignListVal['FatherOcopation'], 

'dob' => $DobDateFor,

'religion' => $WorkAssignListVal['religen'],

//'place_of_birth' => $WorkAssignListVal['PlaceOfBirth']

// 'email' => $WorkAssignListVal['Email'],

'address' => $WorkAssignListVal['Address'],

// 'medium' => 'english',

  //'cast' => $WorkAssignListVal['Caste'],

//  'blood_group' => $WorkAssignListVal['blood_group'],

//'mother_name' => $WorkAssignListVal['MotherName'],

// 'mother_activity' => $WorkAssignListVal['MotherOccupation']

//'old_school' => $WorkAssignListVal['PreviousSchool'],

//'old_obtmarks' => $WorkAssignListVal['matric_marks'],

//'City_Id' => 50,

'cnic' => $WorkAssignListVal['father_cnic']

//'mother_cnic' => $WorkAssignListVal['mother_cnic']

//'formBNo' => $WorkAssignListVal['BForm_No']

//  'contact_details' => $WorkAssignListVal['Address']

//'user_fname' => $WorkAssignListVal['StudentName'],

//'user_lname' => $WorkAssignListVal['FatherName'],

//'user_gender' => $WorkAssignListVal['Gender'],

//'DOB' => $DobDateFor,

//'department_id' => $WorkAssignListVal['department'],

//'registratin_number' => $WorkAssignListVal['user_code'],

//'user_cnic' => $WorkAssignListVal['father_cnic'],

 //'user_religion' => $WorkAssignListVal['religen'],

 //'user_address' => $WorkAssignListVal['Address'],

 //'user_salary' => $WorkAssignListVal['MonthlyFee'],

 //'marital_status' => $WorkAssignListVal['marital_status'],

 //'user_qualification' => $WorkAssignListVal['father_education']

 //'user_joining' => $WorkAssignListVal['DateOfJoining'],

 //'designation_id' => $WorkAssignListVal['designation_num']



);



//echo "<pre>"; print_r($data); echo "</pre>";



$result =  $m->insert('edu_student_details', $data);

//$result =  $m->insert('edu_user_config', $data);



   $id=$m->getInsertId();



   $data1 = array(

    

    'branch_id' => $_SESSION['branch'],

    'student_id' => $id,

    'std_tution_fee' => $WorkAssignListVal['MonthlyFee'],

    //'std_scholarship' => $WorkAssignListVal['transportFee'],

    //'std_admission_fee' => $WorkAssignListVal['transportFee'],

    'standared_admission' => '15000',

    'class_id' => $class[0]['class_id'],

    'year' => '2023'

  );

  

//print_r($data);

  $result1 =  $m->insert('eduportal_student_fee_structure', $data1);



//========================create first  chalaln=======================


    //   $monthId='2023-10';         

    //   $sessId=$_SESSION['current_session'];

    //   $clsID=$class[0]['class_id'];

    //   $Ddate='2023-11-10';

    //   $stdTotalFee=$WorkAssignListVal['MonthlyFee']+$WorkAssignListVal['outstandingBalnce']/*+$WorkAssignListVal['medium']*/;

    //   $bid=$_SESSION['branch'];

        
        

    // $query="insert into eduportal_monthly_challan(from_year_month,to_year_month,year,classs_id,challan_duedate,total_challan_amt,branch_id,student_id) values";

    // $query .= "('$monthId','$monthId','2023','$clsID','2023-11-10','$stdTotalFee','$bid','$id')";

    // $m->query($query);

    // $challan_id= $m->getInsertId(); 


    //  //now inserting the challan details with other fee parameters
 

           
    //         $sessId=$_SESSION['current_session'];

    //         $bid=$_SESSION['branch'];

    //         $clsID=$class[0]['class_id'];

    //         $stdFee=$WorkAssignListVal['MonthlyFee'];

    //         $balance=$WorkAssignListVal['outstandingBalnce'];

    //         $annual=$WorkAssignListVal['medium'];        

           

    //   $query1="insert into eduportal_monthly_challan_details(challan_id,feetype_id,fee_amount,year,branch_id,class_id,month,student_id,created) values";


    //     $query1 .= "('$challan_id','1','$stdFee','2023','$bid','$clsID','2023-10','$id','2023-11-02')";


    //     $m->query($query1);





    //     $query1="insert into eduportal_monthly_challan_details(challan_id,feetype_id,fee_amount,year,branch_id,class_id,month,student_id,created) values";


    //     $query1 .= "('$challan_id','7','$balance','2023','$bid','$clsID','2023-10','$id','2023-11-02')";


    //     $m->query($query1);




    //     // $query1="insert into eduportal_monthly_challan_details(challan_id,feetype_id,fee_amount,year,branch_id,class_id,month,student_id,created) values";


    //     // $query1 .= "('$challan_id','5','$annual','2023','$bid','$clsID','2023-10','$id','2023-10-30')";


    //     // $m->query($query1);
        

      ?>



        <tr>



          <td style="text-align:center; padding: 2px;"><?php echo $count++;?></td>        



                  <td style="padding: 2px;" >             

                  

                   <?php echo $WorkAssignListVal['StudentName'];?> </td>



                  

                   <td style="padding: 2px; text-align: center;"><?php echo $WorkAssignListVal['Father'];?> </td>

                  

                  <td style="text-align:center; padding: 2px;"> <?php echo $WorkAssignListVal['Class'];?> </td>

                  

                  <td style="text-align:center; padding: 2px;"> <?php echo $WorkAssignListVal['Sec'];?> </td>



               <td style="text-align:center; padding: 2px;"> <?php echo $WorkAssignListVal['Contact1'];?> </td>



     

  <td style="text-align:center; padding: 2px;"> <?php echo $WorkAssignListVal['tuitioFee'];?> </td>



    <td style="text-align:center; padding: 2px;"> <?php echo $WorkAssignListVal['Area'];?> </td>



<td style="text-align:center; padding: 2px;"> <?php echo $WorkAssignListVal['Address'];?> </td>





              </tr>











              <?php

      } ?>

 

        </tbody>

        

    </table>



  </div>



    </form>



    <br><br>





  </div>

  <div class="clearfix"></div>

</section>



        </div> 

        </div>





            </div>

          </div>

        </div>





     

        <!-- /page content -->





 <!-- jQuery -->

    <script src="js/ajax_functions.js"></script>

  <?php include('RootMe/js_linksscript.php');?> 

  <!-- Links for Datatable-->



<script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>

 <script>

        

  $(document).ready(function() {

    $('#listofstudents').DataTable({

      "pageLength": 100

    });

    } 

  );



  $("#checkAll").change(function () {



      $("input:checkbox").prop('checked', $(this).prop("checked"));

  });





</script>

  

  </body>

</html>

