<style>
body{background:#EAEDED;
form{box-shadow:0 0 2px;}
a{color:black;}
a:hover{text-decoration:none;}
/*h3{font-weight:600;font-size:22px;}*/
.main-heading{font-weight:700;font-size:18px;}
</style>

<?php
$title='';
$id='';
$student_first_name='';
$student_last_name='';
$father_name='';
$course='';
$address='';
// $scholor_number='';
$mobile_number='';
$section='';
$course_id='';
$gender='';
$acedemic_session='';
$table='enquiry';
if($data){
    $title='Update Information';
    $get_enquiry_info=$this->EnquiryModel->get_item_info($data,$table);
    if($get_enquiry_info){
        foreach($get_enquiry_info as $info){
            $id=$info['id'];
            $gender=$info['gender'];
            $student_first_name=$info['first_name'];
            $student_last_name=$info['last_name'];
            $father_name=$info['father_name'];
            $course_id=$info['course_id'];
            $course=$info['class'];
            $address=$info['address'];
            // $scholor_number=$info['enquiry_no'];
            $mobile_number=$info['mobile_number'];
            $section=$info['section'];
            $acedemic_session=$info['acedemic_session'];
        }
    }


}else{
    $title='Add New Student Enquiry';
}

?>

<div class="container-fluid mt-3 mb-3">
    <div class="row">
        <div class="col-sm-12 p-3 bg-white">

            <ul class="breadcrumb">
                <li class="breadcrumb-item"><a href="<?php echo base_url(); ?>Welcome">Home</a></li>
                <li class="breadcrumb-item"><a href="<?php echo base_url(); ?>Enquiry/list_enquiry">Enquiry</a></li> 
                <li class="breadcrumb-item">Add New Enquiry</li>
            </ul>

            <form method="post" action="#" class="p-3 mt-3 mb-3">
                <h3 class="text-center main-heading"><?php echo $title;?></h3>
                <hr>
                <?php 
                if($success){
                    echo "<p class='alert alert-success'>".$success."</p>";
                }

                if($error){
                    echo "<p class='alert alert-danger'>".$error."</p>";
                }
                ?>


                <input type="hidden" name="id" value="<?php echo $id;?>">

                <!--<div class="form-group">
                    <label>Scholor No</label>
                    <input type="number" class="form-control" name="scholor_number" placeholder="Scholor Number" value="<?php if($scholor_number){echo $scholor_number;} ?>" >
                </div>-->


                <div class="form-group">
                    <label>Student's First Name</label>
                    <input type="text" name="student_first_name" class="form-control" placeholder="Student First Name" value="<?php if($student_first_name){echo $student_first_name;}else {echo  set_value('student_first_name');}?>">
                    <h7 class="" style="color:red;"><?php echo form_error('student_first_name'); ?></h7>
                </div>

                <div class="form-group">
                    <label>Student's Last Name</label>
                    <input type="text" name="student_last_name" class="form-control" placeholder="Student Last Name" value="<?php if($student_last_name){echo $student_last_name;} else {echo  set_value('student_last_name');} ?>">
                    <h7 class="" style="color:red;"><?php echo form_error('student_last_name'); ?></h7>
                </div>

                <div class="form-group">
                    <label>Father's Name</label>
                    <input type="text" name="father_name" class="form-control" placeholder="Father Name" value="<?php if($father_name){echo $father_name;} else {echo  set_value('father_name');}?>">
                    <h7 class="" style="color:red;"><?php echo form_error('father_name'); ?></h7>
                </div>


                <div class="form-group">
                    <label>Class</label>
                    <select name="course_id" class="form-control"> 
                        <option value="">-- select course --</option>

                        <?php
                        $table='courses';
                        $get_courses=$this->WelcomeModel->get_data($table);
                        if($get_courses){
                            foreach($get_courses as $courses){
                        ?>
                                <option value="<?php echo $courses['id'];?>" <?php if($course_id == $courses['id']){echo "selected";} else {echo  set_value('course_id');} ?>><?php echo $courses['course']; echo " ";  echo $courses['subject_stream'];?></option>
                        <?php
                            }
                        }
                        ?>
                    </select>
                    <h7 class="" style="color:red;"><?php echo form_error('course'); ?></h7>
                </div>

                    <div class="form-group">
                        <label>Section</label>
                        <select name="section" class="form-control">
                            <option value="A" <?php if($section=='A'){echo "selected";} ?>>A</option>
                            <option value="B" <?php if($section=='B'){echo "selected";} ?>>B</option>
                            <option value="C" <?php if($section=='C'){echo "selected";} ?>>C</option>
                        </select>

                    </div>  

                    <div class="form-group">
                        <label>Gender</label>
                        <select class="form-control" name="gender" required>
                            <option value="">-- select gender --</option>
                            <option value="male" <?php if($gender == "male"){ echo "selected"; }?>>Male</option>
                            <option value="female" <?php if($gender == "female"){ echo "selected"; }?>>Female</option>
                        </select>
                    </div>
                <div class="form-group">
                    <label>Mobile</label>
                    <input type="number" name="mobile_number" class="form-control"  placeholder="Mobile Number" value="<?php if($mobile_number){echo $mobile_number;} else {echo  set_value('mobile_number');}?>">
                    <h7 class="" style="color:red;"><?php echo form_error('mobile_number'); ?></h7>
                </div>

                <div class="form-group">
                    <label>Address</label>
                    <textarea name="address" class="form-control" col="6" placeholder="Address" ><?php if($address){echo $address;} else {echo  set_value('address');} ?></textarea>
                    <h7 class="" style="color:red;"><?php echo form_error('address'); ?></h7>
                </div>
                <div class="form-group">
                    <label>Acedemic Session</label>
                    <select class="form-control" name="acedemic_session">
                        <?php 
                        $academic_session_details='academic_session_details';
                        $ace_data=$this->WelcomeModel->get_data($academic_session_details);
                        if($ace_data){
                            foreach($ace_data as $data){
                                // if($data['id'] == 4){
                        ?>
                        <option value="<?php echo $data['id']; ?>" <?php if($data['id'] == 3){echo "selected";} ?>><?php echo $data['year_long']; ?></option>
                        <?php 
                                // }
                            }
                        }
                        ?>
                    </select>
                </div>



                <div class="form-group">
                    <input type="submit" class="btn btn-sm btn-success" name="new_enquiry" value="Submit">    
                </div>
            </form>

        </div>
    </div>
</div>