JezK
Edit File: update_general_comments.php
<?php session_start(); include("menuheader.php"); if (!(in_array(2, $access) && in_array(2, $allow))) echo "<script>location.replace('dashboard.php');</script>"; include_once("school_admin_access.php"); include_once("school_admin_student.php"); include 'android_push.php'; $admin = new adminaccess(); $student = new studentacess(); $page = basename($_SERVER['PHP_SELF']); //echo $page; if ($page == "general_comments.php") { $menuclass = "selected"; } else if ($page == "update_general_comments.php") { $menuclassu = "selected"; } $sch_id = $_SESSION['child']['log_school_id']; $auth_id = $_SESSION['child']['auth_id']; $acadamic_year = $_SESSION['child']['choosen_academic_id']; $details = $admin->get_classes_byschool_total($sch_id, $acadamic_year); //$sch_id = 1; //$class_id= 1; //$subjects_data = $student->get_subjects_dairy($class_id,$sch_id); if ($_POST['action'] == "add") { $today_date = date('d/m/Y'); if ($today_date == $_POST['dairy_date']) { $date_msg = "Today"; } else { $date_msg = $_POST['dairy_date']; } $dateInput = explode('/', $_POST['dairy_date']); $dairy_newdate = $dateInput[2] . '-' . $dateInput[1] . '-' . $dateInput[0]; /*$check_comment = $student->check_generalcomment($_POST); if($check_comment['cnt'] > 0 ){ $result = $student->update_generalcomment($check_comment,$_POST); }else { $result = $student->insert_generalcomment($_POST); }*/ //$result = $student->insert_generalcomment($_POST); $check_comment = $student->check_generalcomment_edit($_POST); if ($check_comment['cnt'] > 0) { if ($_FILES["attachment"]["name"]) { $t = $_FILES["attachment"]["tmp_name"]; $n = $_FILES["attachment"]["name"]; $p = strtotime(date('d-m-Y H:i:s')); $k = substr(str_shuffle($p), 0, 5); $tfname = $k . $n; if (move_uploaded_file($t, "uploads/homework/" . $tfname)) { $attachment_file = $tfname; } } $result = $student->update_generalcomment_new($_POST, $check_comment['School_diary_id'], $attachment_file); } else { if ($_FILES["attachment"]["name"]) { $t = $_FILES["attachment"]["tmp_name"]; $n = $_FILES["attachment"]["name"]; $p = strtotime(date('d-m-Y H:i:s')); $k = substr(str_shuffle($p), 0, 5); $tfname = $k . $n; if (move_uploaded_file($t, "uploads/homework/" . $tfname)) { $attachment_file = $tfname; } } $result = $student->insert_generalcomment($_POST, $attachment_file); } if ($result != ERR204) { echo "<script>location.replace('general_comments.php?cresult=ERR203');</script>"; } else { echo "<script>location.replace('update_general_comments.php?cresult=ERR204');</script>"; } } ?> <style> #nav { margin: auto; width: 427px !important; padding-left: 0; padding-right: 0; list-style: none; background: #18b88d; } #nav li { display: inline-block; margin: 0 auto; text-align: center; } #nav li a { display: inline-block; padding: 7px 0; text-align: center; text-decoration: none; color: #FFFFFF; margin: auto; } #nav li:hover, li:active { background-color: rgb(54, 120, 102); width: 90px; } #nav li.selected { background: rgb(54, 120, 102); } select { width: 62px !important; background-color: #FFF; border: 1px solid #CCC; } .multiselect { width: 290px; } .selectBox { position: relative; } .selectBox select { width: 100%; font-weight: bold; } .overSelect { position: absolute; left: 0; right: 0; top: 0; bottom: 0; } #checkboxes { display: none; border: 1px #dadada solid; } #checkboxes label { display: block; } #checkboxes label:hover { background-color: #1e90ff; } </style> <script> $(window).click(function(e) { var names = document.getElementById('student_allnames_data').value; var student = $('#students').val(); var student_status = $('#student_status').val(); var student_names = $('#student_allnames_data').val(); var student_names_total = $('#student_names').val(); student_names_total = student_names_total.replace(",,", ","); student_names_total = student_names_total.replace(/^,/g, ''); student_names_total = student_names_total.replace(/,$/g, ''); student_names = student_names.replace(",,", ","); student_names = student_names.replace(/^,/g, ''); student_names = student_names.replace(/,$/g, ''); if (student_status != '' && student_status != 'all') { if (student_names_total.length == student_names.length) { $(".checkboxall").prop("checked", true); } if (student_status != '' && names == '') { students_data = '<option selected="selected" > Select Students </option>'; //$("#students").html(students_data); } else if (student_names_total.length == student_names.length) { students_data = '<option selected="selected" > All </option>'; //$("#students").html(students_data); } else { student_names = student_names.replace(",,", ","); students_data = '<option selected="selected" > ' + student_names + ' </option>'; } $("#students").html(students_data); } }); $(document).ready(function() { $('#err_class').hide(); $('#err_section').hide(); $('#err_dairy').hide(); $('#err_subject').hide(); $('#err_description').hide(); $('#err_student').hide(); }); function inputvalidations() { $('#err_class').hide(); $('#err_section').hide(); $('#err_dairy').hide(); $('#err_subject').hide(); $('#err_description').hide(); $('#err_student').hide(); //alert('test'); var dairy_class = document.getElementById('classes').value; if (dairy_class != '') { var dairy_section = document.getElementById('sections').value; } var dairy_date = document.getElementById('dairy_date').value; var dairy_desription = document.getElementById('dairy_desription').value; if (dairy_section != '0') { var dairy_subjects = document.getElementById('subjects').value; } var student_ids_data = document.getElementById('student_ids_data').value; //alert(student_ids_data); //var dairy_desription = document.getElementById('dairy_desription').value; if (dairy_class == '') { $('#err_class').show(); return false; } else if (dairy_section == '0') { $('#err_section').show(); return false; } else if (dairy_date == '') { $('#err_dairy').show(); return false; } else if (dairy_subjects == '0' || dairy_subjects == '') { $('#err_subject').show(); return false; } else if (student_ids_data == '') { $('#err_student').show(); return false; } else if (dairy_desription == '') { $('#err_description').show(); return false; } } </script> <body style="overflow-x: hidden;"> <div class="row" style="margin-top: 30px;"> <div class="col-md-9 text-left" style="font:Arial, Helvetica, sans-serif;font-style:normal;font-size:24px; margin-left:20px;"> <i class="fa-solid fa-plus" title="Add / Update General Comments" style="font-size: 20px;"></i> Add/Update General Comments</a> </div> </div> <br> <div class="menuu"> <ul id="nav" class="margn_auto"> <li class="<?= $menuclass ?>" style="border-right:1px solid #FFFFFF;width:214px; text-align:center;margin-left:-3px;font-family:Arial, Helvetica, sans-serif;font-style:normal; font-size:14px;"><a href="diary_management.php"><img src="images/hom-work_white.png" title="Home Work" style="margin-right:5px;" />Home Work</a></li> <li class="<?= $menuclassu ?>" style="border-right:1px solid #FFFFFF; width:215px; text-align:center; margin-left:-3px; font-family:Arial, Helvetica, sans-serif;font-style:normal; font-size:14px;"><a href="general_comments.php"><img src="images/general-comments_white.png" title="General Comments" style="margin-right:5px;" />General Comments</a></li> </ul> </div> <form class="form-horizontal" style="margin-top:30px;" method="post" enctype="multipart/form-data"> <div class="box-body" style="background-color:#fff; padding: 10px; font-family:Arial, Helvetica, sans-serif; font-size:13px; "> <div class=""> <div class="form-group row col-md-6" style="margin-bottom:1.0%;"> <div class="col-md-4 text-md-end"><b style="color:#666666; ">Class</b><span style="color:#FF0000; margin:2px;">*</span> </div> <div class="col-md-7"> <select class="form-select" id="classes" name="classes" style="height:29px; width:295px!important;font-size:12px;" tabindex="2"> <option selected="selected" value=''>Select Class</option> <?php foreach ($details as $key => $row) { echo "<option value='{$row['class_id']}'>{$row['class_name']}</option>"; } ?> </select> <!-- if there is an error--> <div class="col-md-7" id="err_class" style="color:#990000; display:none;">Please enter Class</div> <!--- end error--> </div> </div> </div> <!-- clear --> <div class=""> <div class="form-group row col-md-6" style="margin-bottom:1.0%;"> <div class="col-md-4 text-md-end"><b style="color:#666666; ">Section</b><span style="color:#FF0000; margin:2px;">*</span> </div> <div class="col-md-7"> <select class="form-select" id="sections" name="sections" style="height:29px; width:295px!important;font-size:12px;" tabindex="2"> <option selected="selected" value=''>Select Section</option> </select> <!-- if there is an error--> <div class="col-md-7" id="err_section" style="color:#990000; display:none;">Please enter Section</div> <!--- end error--> </div> </div> </div> <div class=""> <div class="form-group row col-md-6" style="margin-bottom:1.0%;"> <div class="col-md-4 text-md-end"><b style="color:#666666; ">Student</b><span style="color:#FF0000; margin:2px;">*</span> </div> <div class="col-md-7"> <div class="multiselect"> <div class="selectBox" onclick="showCheckboxes()"> <select class="form-select" id="students" name="students" onclick="changestatus()" style="height:29px; width:295px!important;font-size:12px;" tabindex="2"> <option selected="selected" value=''>Select Students</option> </select> <div class="overSelect"></div> </div> <div id="checkboxes"> </div> </div> <!-- if there is an error--> <div class="col-md-7" id="err_student" style="color:#990000;display:none;">Please choose atleast one of the Student</div> <!--- end error--> </div> </div> </div> <div class="class"> <div class="form-group row col-md-6" style="margin-bottom:1.0%; clear:both;"> <div class="col-md-4 text-md-end"><b style="color:#666666;">Date</b><span style="color:#FF0000; margin:2px; ">*</span> </div> <div class="col-md-7 "> <div class="input-group date" id="datetimepicker"> <input type="text" class="form-control" name="dairy_date" id="dairy_date" value="<?= date('d/m/Y') ?>" tabindex="5"> <span class="input-group-append"> <span class="input-group-text bg-light d-block add-on"> <i class="fa fa-calendar-days"></i> </span> </span> </div> <!-- <div id="datetimepicker" class="input-append date d-flex"> <input type="text" class="form-control" name="dairy_date" id="dairy_date" value="<?= date('d/m/Y') ?>" style="height:30px; width:268px;font-size:13px;" tabindex="5"></input> <span class="add-on" style="height:30px;font-size:20px "> <i class="fa-solid fa-calendar"></i> </span> </div> --> <!-- if there is an error--> <div class="col-md-7" id="err_dairy" style="color:#990000; display:none;">Please enter Date</div> <!--- end error--> </div> </div> <div class=""> <div class="form-group row col-md-6" style="margin-bottom:1.0%;"> <div class="col-md-4 text-md-end"><b style="color:#666666; ">Subject</b><span style="color:#FF0000; margin:2px;">*</span> </div> <div class="col-md-7"> <select class="form-select" id="subjects" name="subjects" style="height:29px; width:295px!important;font-size:12px;" tabindex="2"> <option selected="selected" value=''>Select Subjects</option> </select> <!-- if there is an error--> <div class="col-md-7" id="err_subject" style="color:#990000; display:none;">Please enter Subject</div> <!--- end error--> </div> </div> </div> <div class=""> <div class="form-group row col-md-6" style="margin-bottom:1.0%;"> <div class="col-md-4 text-md-end"><b style="color:#666666; ">Description</b><span style="color:#FF0000; margin:2px;">*</span> </div> <div class="col-md-7"> <textarea class="form-control" rows="2" id="dairy_desription" name="dairy_desription" style="font-size:13px; width:295px!important;" tabindex="16" maxlength="1000"></textarea> <!-- if there is an error--> <div class="col-md-7" id="err_description" style="color:#990000; display:none;">Please enter Description</div> <!--- end error--> </div> </div> </div> <div class=""> <div class="form-group row col-md-6" style="margin-bottom:1.0%; clear:both;"> <div class="col-md-4 text-md-end"> <b style="color:#666666;">Attachment</b> </div> <div class="col-md-7"> <input type="file" class="form-control " id="attachment" name="attachment" style="height:40px;font-size:13px;" tabindex="2" value=""> <p><i>(Please upload DOC, XLS, PPT, PDF, GIF, PNG, JPG, JPEG files only. The size of the file should not be greater than 5 MB)</i></p> <!-- if there is an error--> <div class="col-md-10" id="err_desc11" style="color:#990000;"></div> <!--- end error--> </div> </div> <input type="hidden" name="school_id" id="school_id" value="<?= $sch_id ?>"> <input type="hidden" name="auth_id" id="auth_id" value="<?= $auth_id ?>"> <input type="hidden" name="acadamic_id" id="acadamic_id" value="<?= $acadamic_year ?>"> <input type="hidden" name="student_ids_data" id="student_ids_data" value=""> <input type="hidden" name="student_allids_data" id="student_allids_data" value=""> <input type="hidden" name="student_allnames_data" id="student_allnames_data" value=""> <input type="hidden" name="student_names_data" id="student_names_data" value=""> <input type="hidden" name="student_names" id="student_names" value=""> <input type="hidden" name="student_ids" id="student_ids" value=""> <input type="hidden" name="dairy_ids" id="dairy_ids" value=""> <input type="hidden" name="student_status" id="student_status_data" value="1"> <input type="hidden" name="student_status" id="student_status" value=""> </div> <div class="form-group"> <div class="col-md-8" align="center"> <button type="submit" class="btn btn-outline-secondary custom-button-width .navbar-right btnclr" tabindex="16" style="font-family:Arial, Helvetica, sans-serif;font-style:normal;font-size:13px; margin:10px; " onclick="return inputvalidations()">Add/Update</button> <button type="button" class="btn btn-outline-secondary custom-button-width .navbar-right btnclr" tabindex="24" style="font-family:Arial, Helvetica, sans-serif;font-style:normal;font-size:13px; margin:20px; " onclick="return clearall()">Cancel</button> </div> <input type="hidden" name="action" id="action" value="add"> </form> <!--<script type="text/javascript" src="http://tarruda.github.com/bootstrap-datetimepicker/assets/js/bootstrap-datetimepicker.min.js"> </script> <script type="text/javascript" src="http://tarruda.github.com/bootstrap-datetimepicker/assets/js/bootstrap-datetimepicker.pt-BR.js"> </script>--> <!-- <script type="text/javascript" src="js/bootstrap-datetimepicker.js" charset="UTF-8"></script> <script type="text/javascript" src="js/bootstrap-datetimepicker.fr.js" charset="UTF-8"></script> --> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-datepicker@1.9.0/dist/css/bootstrap-datepicker.min.css"> <!-- JavaScript --> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js"></script> <script type="text/javascript"> $('#datetimepicker').datepicker({ format: 'dd/mm/yyyy', minView: 2, pickTime: false, autoclose: true, todayBtn: true, todayHighlight: true }).on('changeDate', function() { $(this).datepicker('hide'); var class_id = $("#classes").val(); var school_id = $("#school_id").val(); var sec_id = $("#sections").val(); var dairy_date = $("#dairy_date").val(); var subject = $("#subjects").val(); var acadamic_id = <?php echo $acadamic_year ?>; var student_ids = $("#student_ids").val(); var student_ids_all = $("#student_ids_data").val(); if (student_ids == "all") { var str_new = "all"; } else { var str_new = student_ids_all; } if (dairy_date == '') { alert("Choose Date"); return false; } else { $.ajax({ url: "ajaxcalls.php", type: "POST", data: "mode=" + "choose_description_dairy" + "&school_id=" + school_id + "&class_id=" + class_id + "&sec_id=" + sec_id + "&acadamic_id=" + acadamic_id + "&studentids=" + str_new + "&subject=" + subject + "&dairy_date=" + dairy_date, success: function(result) { var res = eval("(" + result + ")"); if (res.description != undefined) { document.getElementById('dairy_desription').value = res.description; document.getElementById('dairy_ids').value = res.School_diary_id; } else { document.getElementById('dairy_desription').value = ""; document.getElementById('dairy_ids').value = ""; } } }); } }); $("#sections").change(function() { var class_id = $("#classes").val(); var school_id = $("#school_id").val(); var sec_id = $("#sections").val(); var acadamic_id = <?php echo $acadamic_year ?>; if ($(this).val() == 0) { //alert("Choose Section"); $('#err_section').show(); var subject_option = '<option value="0">Select Subject</option>'; $("#subjects").html(subject_option); document.getElementById('checkboxes').innerHTML = ''; return false; } else { $.ajax({ url: "ajaxcalls.php", type: "POST", data: "mode=" + "choose_subject_dairy" + "&school_id=" + school_id + "&class_id=" + class_id + "&sec_id=" + sec_id + "&acadamic_id=" + acadamic_id, success: function(result) { var arr = result.split('@'); var result2 = eval("(" + arr[0] + ")"); var result_stu = eval("(" + arr[1] + ")"); var students_ids = ''; var students_names = ''; if (result_stu == null) { students_data = '<option selected="selected" > Select Students </option>'; $("#students").html(students_data); document.getElementById('checkboxes').innerHTML = ''; } else { var students_data = '<input type="checkbox" class="checkboxall" name="selectall" id="selectall" onclick="check_all()" checked="checked"> All<br>'; for (var j = 0; j < result_stu.length; j++) { var fullname = result_stu[j].student_firstname + ' ' + result_stu[j].student_lastname; students_data += '<label for="one"><input type="checkbox" onclick="check_single(this.value,\'' + fullname + '\')" class="checkbox1" checked="checked" value="' + result_stu[j].student_id + '" name="students_ids[]" id="student_id' + result_stu[j].student_id + '" style="margin-top:-2px;"/ >' + result_stu[j].student_firstname + ' ' + result_stu[j].student_lastname + '</label>'; students_ids += "," + result_stu[j].student_id; students_names += "," + fullname; } students_ids = students_ids.replace(/^,/g, ''); students_ids = students_ids.replace(/,$/g, ''); document.getElementById('checkboxes').innerHTML = students_data; document.getElementById('student_ids_data').value = students_ids; document.getElementById('student_allids_data').value = students_ids; document.getElementById('student_ids').value = "all"; document.getElementById('student_allnames_data').value = students_names; document.getElementById('student_names').value = students_names; document.getElementById('student_status').value = "all"; students_data = '<option selected="selected" > All </option>'; $("#students").html(students_data); } var subject_option = '<option value="0">Select Subject</option>'; for (var i = 0; i < result2.length; i++) { subject_option += '<option value="' + result2[i].subject_id + '">' + result2[i].subject_name + '</option>'; } document.getElementById('dairy_desription').value = ""; // document.getElementById('dairy_ids').value = ""; $("#subjects").html(subject_option); } }); } }); // $('#datetimepicker1').datetimepicker({ // format: 'dd/MM/yyyy', // pickTime: false // }).on('changeDate', function() { // //$(this).datetimepicker('hide'); // }); $("#classes").change(function() { var acadamic_id = <?php echo $acadamic_year ?>; if ($(this).val() == 0) { //alert("Choose Class"); $('#err_class').show(); var section_option = '<option value="0">Select Section</option>'; $("#sections").html(section_option); var subject_option = '<option value="0">Select Subject</option>'; $("#subjects").html(subject_option); document.getElementById('checkboxes').innerHTML = ''; return false; } else { var x = $(this).val(); $.ajax({ url: "ajaxcalls.php", type: "POST", data: "mode=" + "choose_class_dairy" + "&data=" + x + "&acadamic_id=" + acadamic_id, success: function(result) { var result2 = eval("(" + result + ")"); var section_option = '<option value="0">Select Section</option>'; for (var i = 0; i < result2.length; i++) { section_option += '<option value="' + result2[i].section_id + '">' + result2[i].section_name + '</option>'; } $("#sections").html(section_option); document.getElementById('dairy_desription').value = ""; document.getElementById('dairy_ids').value = ""; students_data = '<option selected="selected" > Select Students </option>'; subject_option = '<option selected="selected" > Select Subjects </option>'; $("#subjects").html(subject_option); $("#students").html(students_data); }, error: function(e) { } }); } }); var expanded = false; function showCheckboxes() { var checkboxes = document.getElementById("checkboxes"); if (!expanded) { checkboxes.style.display = "block"; expanded = true; } else { checkboxes.style.display = "none"; expanded = false; } } function check_all() { students_ids = document.getElementsByName('students_ids[]'); var names = document.getElementById('student_allnames_data').value; var all_names = document.getElementById('student_names').value; //var temp = names; var student_status = $('#student_status').val(); var class_id = $("#classes").val(); var school_id = $("#school_id").val(); var sec_id = $("#sections").val(); var dairy_date = $("#dairy_date").val(); var student_ids = $("#student_ids").val(); var subject = $("#subjects").val(); var acadamic_id = <?php echo $acadamic_year ?>; var txt = ''; if (document.getElementById("selectall").checked == true) { document.getElementById('student_ids').value = 'all'; var student_ids = document.getElementById('student_ids').value; $(".checkbox1").prop("checked", true); for (var i = 0, n = students_ids.length; i < n; i++) { txt = txt + students_ids[i].value + "," // alert(txt); } txt_new = txt.replace(/^,/g, ''); txt_new = txt.replace(/,$/g, ''); document.getElementById('student_ids_data').value = txt; document.getElementById('student_allnames_data').value = all_names; document.getElementById('student_status').value = "all"; students_data = '<option selected="selected" > All </option>'; $("#students").html(students_data); if (subject != '' && dairy_date != '' && class_id != '' && school_id != '') { $.ajax({ url: "ajaxcalls.php", type: "POST", data: "mode=" + "choose_description_dairy" + "&school_id=" + school_id + "&class_id=" + class_id + "&sec_id=" + sec_id + "&acadamic_id=" + acadamic_id + "&studentids=" + student_ids + "&subject=" + subject + "&dairy_date=" + dairy_date, success: function(result) { var res = eval("(" + result + ")"); if (res.description != undefined) { document.getElementById('dairy_desription').value = res.description; document.getElementById('dairy_ids').value = res.School_diary_id; } else { document.getElementById('dairy_desription').value = ""; document.getElementById('dairy_ids').value = ""; } } }); } } else { $(".checkbox1").prop("checked", false); document.getElementById('student_ids').value = 'single'; document.getElementById('student_ids_data').value = ''; document.getElementById('student_allnames_data').value = ''; document.getElementById('student_status').value = ""; document.getElementById('dairy_desription').value = ""; students_data = '<option selected="selected" > Select Students </option>'; $("#students").html(students_data); } } function check_single(val, name) { // document.getElementById('student_status').value = "singles"; var class_id = $("#classes").val(); var school_id = $("#school_id").val(); var sec_id = $("#sections").val(); var dairy_date = $("#dairy_date").val(); var subject = $("#subjects").val(); var allstudent_data = $("#student_names").val(); var acadamic_id = <?php echo $acadamic_year ?>; var ids = document.getElementById('student_ids_data').value; var names = document.getElementById('student_allnames_data').value; if (document.getElementById("student_id" + val).checked == false) { document.getElementById('student_ids').value = 'single'; ids = ids.replace(val, ""); ids = ids.replace(",,", ","); names = names.replace(name, ""); names = names.replace(",,", ","); ids_new = ids.replace(/^,/g, ''); ids_new = ids.replace(/,$/g, ''); if (subject != '' && dairy_date != '' && class_id != '' && school_id != '') { $.ajax({ url: "ajaxcalls.php", type: "POST", data: "mode=" + "choose_description_dairy" + "&school_id=" + school_id + "&class_id=" + class_id + "&sec_id=" + sec_id + "&acadamic_id=" + acadamic_id + "&studentids=" + ids_new + "&subject=" + subject + "&dairy_date=" + dairy_date, success: function(result) { var res = eval("(" + result + ")"); if (res.description != undefined) { document.getElementById('dairy_desription').value = res.description; document.getElementById('dairy_ids').value = res.School_diary_id; } else { document.getElementById('dairy_desription').value = ""; document.getElementById('dairy_ids').value = ""; } } }); } } else { document.getElementById('student_ids').value = 'single'; ids += "," + val; names += "," + name; ids = ids.replace(",,", ","); names = names.replace(",,", ","); ids_new = ids.replace(/^,/g, ''); ids_new = ids.replace(/,$/g, ''); allstudent_data = allstudent_data.replace(/^,/g, ''); allstudent_data = allstudent_data.replace(/,$/g, ''); if (allstudent_data.length == names.length) { ids_new = "all"; document.getElementById('student_ids_data').value = 'all'; document.getElementById('student_ids').value = 'all'; document.getElementById('student_status_data').value = "all"; } if (subject != '' && dairy_date != '' && class_id != '' && school_id != '') { $.ajax({ url: "ajaxcalls.php", type: "POST", data: "mode=" + "choose_description_dairy" + "&school_id=" + school_id + "&class_id=" + class_id + "&sec_id=" + sec_id + "&acadamic_id=" + acadamic_id + "&studentids=" + ids_new + "&subject=" + subject + "&dairy_date=" + dairy_date, success: function(result) { var res = eval("(" + result + ")"); if (res.description != undefined) { document.getElementById('dairy_desription').value = res.description; document.getElementById('dairy_ids').value = res.School_diary_id; } else { document.getElementById('dairy_desription').value = ""; document.getElementById('dairy_ids').value = ""; } } }); } } ids = ids.replace(/^,/g, ''); ids = ids.replace(/,$/g, ''); $(".checkboxall").prop("checked", false); document.getElementById('student_ids_data').value = ids; //names=names.substring(1); if (names.indexOf(',') == 0) { names = names.substring(1); } document.getElementById('student_allnames_data').value = names; document.getElementById('student_status').value = "singles"; } function clearall() { window.location = "general_comments.php"; } $("#subjects").change(function() { var class_id = $("#classes").val(); var school_id = $("#school_id").val(); var sec_id = $("#sections").val(); var dairy_date = $("#dairy_date").val(); var subject = $("#subjects").val(); var acadamic_id = <?php echo $acadamic_year ?>; var student_ids_all = $("#student_ids_data").val(); var student_allids = $("#student_allids_data").val(); var student_ids = $("#student_ids").val(); if (student_ids == "all") { student_ids_all = "all"; } else if (student_allids.length == student_ids_all.length) { student_ids_all = "all"; document.getElementById('student_status').value = "all"; document.getElementById('student_ids').value = "all"; } student_ids_all = student_ids_all.replace(/^,/g, ''); student_ids_all = student_ids_all.replace(/,$/g, ''); if (dairy_date == '') { alert("Choose Date"); return false; } else { $.ajax({ url: "ajaxcalls.php", type: "POST", data: "mode=" + "choose_description_dairy" + "&school_id=" + school_id + "&class_id=" + class_id + "&sec_id=" + sec_id + "&acadamic_id=" + acadamic_id + "&studentids=" + student_ids_all + "&subject=" + subject + "&dairy_date=" + dairy_date, success: function(result) { var res = eval("(" + result + ")"); if (res.description != undefined) { document.getElementById('dairy_desription').value = res.description; document.getElementById('dairy_ids').value = res.School_diary_id; } else { document.getElementById('dairy_desription').value = ""; document.getElementById('dairy_ids').value = ""; } } }); } }); </script> </body> </html>