JezK
Edit File: send_message.php
<?php session_start(); include("menuheader.php"); if(!(in_array(3,$access) && in_array(3,$allow))) echo "<script>location.replace('dashboard.php');</script>"; include_once("school_admin_access.php"); include_once("school_admin_student.php"); $admin=new adminaccess(); $student=new studentacess(); if($_POST['action'] == "add"){ //print_r($_POST); if($_POST['cat_type'] == 5){ $result = $student->insert_generalnotice_foryou($_POST,$_SESSION,$_FILES); }else{ $result = $student->insert_generalnotice($_POST,$_SESSION,$_FILES); } echo "<script>location.replace('noticeboard_management.php?cresult=ERR203&type=".$_POST['category']."');</script>" ; } $sch_id = $_SESSION['child']['log_school_id']; $acadamic_id = $_SESSION['child']['choosen_academic_id']; $details=$admin->get_classes_byschool_total($sch_id,$acadamic_id); if($_GET['type'] == "1"){ $gen_class = "selected"; }else if($_GET['type'] == "2"){ $vac_class = "selected"; }else if($_GET['type'] == "3"){ $act_class = "selected"; }else if($_GET['type'] == "4"){ $ptm_class = "selected"; }else if($_GET['type'] == "5"){ $foru_class = "selected"; } ?> <style> .upload { background-color: #E1E1E1; width: 86px; margin: -30px 0px 0px 150px; height: 30px; text-align: center; font-size: 14px; padding: 5px 5px; color:#555555; border-radius:4px; cursor:pointer; } #nav { margin: auto; width:751px; 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); } </style> <script> $(document).ready(function(){ $('#err_category').hide(); $('#err_class').hide(); $('#err_section').hide(); $('#err_student').hide(); $('#err_subject_title').hide(); $('#err_description').hide(); }); function inputvalidations(){ $('#err_category').hide(); $('#err_class').hide(); $('#err_section').hide(); $('#err_description').hide(); $('#err_student').hide(); $('#err_image').hide(); var notice_category = document.getElementById('category').value; var notice_class = document.getElementById('classes').value; var notice_section = document.getElementById('sections').value; //var notice_student = document.getElementById('student').value; //var notice_subject = document.getElementById('notice_subject').value; var notice_description = document.getElementById('notice_description').value; var stu_status = document.getElementById('status').value; var cat_type = document.getElementById('cat_type').value; var pics =document.getElementsByName("photos[]"); if(notice_category == ''){ $('#err_category').show(); return false; }else if(notice_class == '0' || notice_class == ''){ $('#err_class').show(); return false; }else if(notice_section == '0'){ $('#err_section').show(); return false; }else if(stu_status == '' && notice_category == 5){ $('#err_student').show(); $('#err_student').text('Please select atleast one Student'); return false; }else if(notice_description == ''){ $('#err_description').show(); return false; } for(var i =0; i < pics.length; i++) { if(pics[i].value != ''){ FileUploadPath = pics[i].value; var Extension = FileUploadPath.substring( FileUploadPath.lastIndexOf('.') + 1).toLowerCase(); if (Extension == "gif" || Extension == "png" || Extension == "jpeg" || Extension == "jpg") { } else { //alert("Image only allows file types of GIF, PNG, JPG, JPEG"); $('#err_image').show(); $('#err_image').text('Please choose GIF, PNG, JPG, JPEG images only '); return false; } } } //return false; } function ValidateFileUpload() { var fuData = document.getElementById('fileChooser'); var FileUploadPath = fuData.value; var Extension = FileUploadPath.substring( FileUploadPath.lastIndexOf('.') + 1).toLowerCase(); if (Extension == "gif" || Extension == "png" || Extension == "jpeg" || Extension == "jpg") { } else { //alert("Image only allows file types of GIF, PNG, JPG, JPEG"); $('#err_image').show(); $('#err_image').text('Please choose GIF, PNG, JPG, JPEG images only '); return false; } } </script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <body style="overflow-x: hidden;"> <div class="row" style="margin-top: 30px;margin-top:30px;"> <div class="col-md-9 text-left" style="font:Arial, Helvetica, sans-serif;font-style:normal;font-size:1.4em; margin-left:20px;"> <i class=" glyphicon glyphicon-plus" title ="New Message" style="font-size: 16px;"></i> New Message </div> </div> <br> <div class="menuu"> <ul id="nav" class="margn_auto"> <li class="<?=$gen_class?>" style="border-right:1px solid #FFFFFF;width:150px; text-align:center;margin-left:-3px;font-family:Arial, Helvetica, sans-serif;font-style:normal; font-size:14px;"><a href="noticeboard_management.php"><img src="images/general@2x.png" title ="General" style="margin-right:5px;"/>General</a></li> <li class="<?=$ptm_class?>" style="border-right:1px solid #FFFFFF; width:150px; text-align:center; margin-left:-3px; font-family:Arial, Helvetica, sans-serif;font-style:normal; font-size:14px;"><a href="ptm.php"><img src="images/ptm@2x.png" title ="PTM" style="margin-right:5px;"/>PTM</a></li> <li class="<?=$vac_class?>" style="border-right:1px solid #FFFFFF; width:150px; text-align:center; margin-left:-3px; font-family:Arial, Helvetica, sans-serif;font-style:normal; font-size:14px;"><a href="vacation.php"><img src="images/vacation@2x.png" title ="Vacation" style="margin-right:5px;"/>Vacation</a></li> <li class="<?=$act_class?>" style="border-right:1px solid #FFFFFF; width:150px; text-align:center; margin-left:-3px; font-family:Arial, Helvetica, sans-serif;font-style:normal; font-size:14px;"><a href="activities.php"><img src="images/activity@2x.png" title ="Activities" style="margin-right:5px;"/>Activities</a></li> <li class="<?=$foru_class?>" style="width:150px; text-align:center; margin-left:-3px; font-family:Arial, Helvetica, sans-serif;font-style:normal; font-size:14px;border-right:0px solid #FFFFFF;"><a href="for_you.php"><img src="images/for-you@2x.png" title ="For You" style="margin-right:5px;"/>For You</a></li> <!-- <li style="width:150px; text-align:center; margin-left:-3px; font-family:Arial, Helvetica, sans-serif;font-style:normal; font-size:14px;"><a href="hosteller.php"><img src="images/for-you@2x.png" title ="For You" style="margin-right:5px;"/> Hosteller</a></li>--> </ul> </div> <form class="form-horizontal" style="margin-top:30px; margin-left:-10px;" method="post" enctype="multipart/form-data" id="imageform"> <div class="box-body" style="background-color:#fff; padding: 10px; font-family:Arial, Helvetica, sans-serif; font-size:13px; "> <div class="class"> <div class="form-group col-md-6" style="margin-bottom:1.0%; clear:both;"> <div class="col-md-4 text-right"><b style="color:#666666; ">Category</b><span style="color:#FF0000; margin:2px;">*</span> </div> <div class="col-md-7" style="margin-left:-40px;"> <select class="form-control" id="category" name="category" style="height:29px; width:328px!important;font-size:12px;margin-left: 20px;" tabindex="1" > <option value='' >--Select Category--</option> <option value='1'<?=$_GET['type'] == '1' ? 'selected=selected':''?>>General</option> <option value='4'<?=$_GET['type'] == '4' ? 'selected=selected':''?>>PTM</option> <option value='2'<?=$_GET['type'] == '2' ? 'selected=selected':''?>>Vacation</option> <option value='3'<?=$_GET['type'] == '3' ? 'selected=selected':''?>>Hostlers</option> <option value='5'<?=$_GET['type'] == '5' ? 'selected=selected':''?>>For You</option> </select> <!-- if there is an error--> <div class="col-md-7" id="err_category" style="color:#990000;margin-left:6px;">Please select Category</div> <!--- end error--> </div> </div> </div> <div class="class"> <div class="form-group col-md-6" style="margin-bottom:1.0%; clear:both;"> <div class="col-md-4 text-right"><b style="color:#666666; ">Class</b><span style="color:#FF0000; margin:2px;">*</span> </div> <div class="col-md-7" style="margin-left:-40px;"> <select class="form-control" id="classes" name="classes" style="height:29px; width:328px!important;font-size:12px;margin-left: 20px;" tabindex="2" > <option selected="selected" value='' >--Select Class--</option> <?php if($_GET['type'] != 5){ ?> <option value='all' >All</option> <?php } ?> <?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;margin-left:6px;">Please select Class </div> <!--- end error--> </div> </div> </div> <div class="class"> <div class="form-group col-md-6" style="margin-bottom:1.0%; clear:both;"> <div class="col-md-4 text-right"><b style="color:#666666; ">Section</b><span style="color:#FF0000; margin:2px;">*</span> </div> <div class="col-md-7" style="margin-left:-40px;"> <select class="form-control" id="sections" name="sections" style="height:29px; width:328px!important;font-size:12px;margin-left: 20px;" tabindex="3" > <option selected="selected" value='' >--Select Section--</option> </select> <!-- if there is an error--> <div class="col-md-7" id="err_section" style="color:#990000;margin-left:6px;">Please select Section</div> <!--- end error--> </div> </div> </div> <div class="class" id="student_details" style="display:none;"> <div class="form-group col-md-6" style="margin-bottom:1.0%; clear:both;"> <div class="col-md-4 text-right"><b style="color:#666666; ">Student Name</b><span style="color:#FF0000; margin:2px;">*</span> </div> <div class="col-md-7" style="margin-left:-40px;"> <select class="form-control" onclick="check_type(this.value);" id="student" name="student[]" value="<?=$_POST['student']?>" style="height:100px; width:328px!important;font-size:12px;margin-left: 20px;" tabindex="1" name="student" multiple > </select> <!-- if there is an error--> <div class="col-md-12" id="err_student" style="color:#990000;margin-left:6px;">Please Enter Student</div> <!--- end error--> </div> </div> </div> <div class="class"> <div class="form-group col-md-6" style="margin-bottom:1.0%; clear:both;"> <div class="col-md-4 text-right"><b style="color:#666666;">Message</b><span style="color:#FF0000; margin:2px; ">*</span></div> <div class="col-md-7" style="margin-left:-40px;"> <textarea class="form-control" id="notice_description" maxlength="1000" name="notice_description" value="<?=$_POST['notice_subject']?>" rows="3" style="font-size:13px;width:329px;margin-left: 20px;"tabindex="5"></textarea> <!-- if there is an error--> <div class="col-md-7" id="err_description" style="color:#990000;margin-left:6px;">Please enter Description</div> <!--- end error--> </div> </div> </div> <div class="class"> <div class="form-group col-md-6" style="margin-bottom:1.0%; clear:both;"> <div class="col-md-4 text-right"> <b style="color:#666666; ">Images</b> </div> <div class="col-md-7" style="margin-left:-40px;" id="addmoreimg"> <!-- if there is an error--> <div class="col-md-7" id="err_image" style="color:#990000;margin-left:6px;"></div> <!--- end error--> <input type="file" name="photos[]" id="fileChooser" onchange="return ValidateFileUpload()" style="margin-left: 20px;"/> <i style="font-size: 14px;margin-top:10px; margin-left:2px;color:#01aee6;" title="Add More Sections " class=" glyphicon glyphicon-plus" onclick="addmoreimages()"></i> <br> (Please upload GIF, PNG, JPG, JPEG Images only) </div> </div> </div> <div class="form-group" style="margin-left:-50px;"> <div class="col-md-8" align="center"> <button type="submit" class="btn btn-default custom-button-width .navbar-right btnclr" tabindex="16" style="font-family:Arial, Helvetica, sans-serif;font-style:normal;font-size:13px; margin:10px; " tabindex="7" onclick="return inputvalidations()">Add</button> <button type="button" class="btn btn-default custom-button-width .navbar-right btnclr" tabindex="17" style="font-family:Arial, Helvetica, sans-serif;font-style:normal;font-size:13px; margin:10px; " tabindex="8" onclick="return clearall('<?=$_GET['type']?>')">Cancel</button> </div> </div> </div> </div> <input type="hidden" name="school_id" id="school_id" value="<?=$sch_id?>"> <input type="hidden" name="academic_id" id="academic_id" value="<?=$acadamic_id?>"> <input type="hidden" name="status" id="status" value=""> <input type="hidden" name="cat_type" id="cat_type" value="<?=$_GET['type']?>"> <input type="hidden" name="action" id="action" value="add"> </form> <script> /*$("#category").change(function(){ if($(this).val() != 5){ var class_option = '<option value="0">Choose Class</option>'; class_option += '<option value="all">All</option>'; } $("#classes").html(class_option); }); */ function addmoreimages() { var photo=document.getElementsByName("photos[]"); var cnt=photo.length; cnt++; var img='<div id="ph'+cnt+'"><input type="file" name="photos[]" id="fileChooser'+cnt+'" onchange="return ValidateFileUploadmore('+cnt+')" style="margin-left:20px;"/><i style="font-size: 14px;margin-top:10px;color:#01aee6;margin-left:3px;" title="Add More Sections " class=" glyphicon glyphicon-remove-circle" onclick="remove_me('+cnt+')"></i></div>'; $("#addmoreimg").append(img); } function ValidateFileUploadmore(num){ var fuData = document.getElementById('fileChooser'+num); var FileUploadPath = fuData.value; var Extension = FileUploadPath.substring( FileUploadPath.lastIndexOf('.') + 1).toLowerCase(); if (Extension == "gif" || Extension == "png" || Extension == "jpeg" || Extension == "jpg") { } else { //alert("Image only allows file types of GIF, PNG, JPG, JPEG "); $('#err_image').show(); $('#err_image').text('Please choose GIF, PNG, JPG, JPEG images only '); return false; } } function remove_me(me) { $('#ph'+me).remove(); } $("#category").change(function(){ var category =$(this).val(); if($(this).val() != 5) { document.getElementById('student_details').style.display="none"; }else{ //alert('test'); var class_id=$("#classes").val(); var section_id=$("#sections").val(); // alert(class_id); // alert(section_id); document.getElementById('student_details').style.display="block"; } window.location="send_message.php?type="+category; }); $("#sections").change(function(){ var class_id=$("#classes").val(); var section_id=$("#sections").val(); var school_id=$("#school_id").val(); var category_id=$("#category").val(); if(category_id == 5){ document.getElementById('student_details').style.display="block"; } $.ajax({ url: "ajaxcalls.php", type:"POST", data:"mode="+"choose_students"+"&school_id="+school_id+"&class_id="+class_id+"§ion_id="+section_id, success: function(result) { var result2 = eval("("+result+")"); // alert(result2); var students_option = ''; if(result2 == null){ document.getElementById('status').value = ""; students_option = ''; $("#student").html(students_option); }else{ students_option = '<option value="all">All</option>'; for(var i = 0;i < result2.length;i++){ var fullname = result2[i].student_firstname+" "+result2[i].student_lastname; students_option += '<option value="'+result2[i].student_id+'">'+fullname+'</option>'; } $("#student").html(students_option); } } }); }); $("#classes").change(function() { var category_id=$("#category").val(); if(category_id == 5 && $(this).val() == "all"){ alert("Please select the one class for the for you section"); return false; } else if($(this).val() == 0) { //alert("Choose Class"); $('#err_class').show(); return false; } else if($(this).val() == 'all' && category_id != 5){ var section_option = '<option value="0">Choose Section</option>'; section_option += '<option value="all" selected>All</option>'; $("#sections").html(section_option); }else { var x = $(this).val(); $.ajax({ url: "ajaxcalls.php", type:"POST", data:"mode="+"choose_class"+"&data="+x, success: function(result) { var result2 = eval("("+result+")"); var section_option = '<option value="0">Choose Section</option>'; if(category_id != 5 ){ section_option += '<option value="all">All</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); }, error : function(e) { } }); } }); function clearall(type) { //alert(type); window.location="noticeboard_management.php?type="+type; } function check_type(type){ if(type == ''){ $('#err_student').show(); $('#err_student').text('Please select atleast one Student'); return false; }else{ $('#err_student').hide(); var total_length = $('#student option').length; var select_length = $("#student :selected").length; if(type == "all" || total_length == select_length+1){ $("#student option:first").prop('selected', true); $('#student option').prop('selected', true); document.getElementById('status').value = "all"; }else { document.getElementById('status').value = "1"; } } } </script> <script type="text/javascript"> $(document).ready(function() { $('#photoimg').on('change', function() { var A=$("#imageloadstatus"); var B=$("#imageloadbutton"); $("#imageform").ajaxForm({target: '#preview', beforeSubmit:function(){ A.show(); B.hide(); }, success:function(){ A.hide(); B.show(); }, error:function(){ A.hide(); B.show(); } }).submit(); }); }); </script> </body> </html>