JezK
Edit File: edit_notice.php
<?php session_start(); ini_set("memory_limit","512M"); 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"); include_once("encription_key.php"); include_once("student_access.php"); define('NOTICEBOARD_IMAGES_PATH',ADMIN_PATH.'uploads/noticeboard/timthumb.php?h=100&w=100&src='); $encrypted_id = $_GET['id']; $admin=new adminaccess(); $student=new studentacess(); $encry=new Encryption(); $student_new =new student_access(); $notice_id = $encrypted_id; //$notice_id = $encry->decode($encrypted_id); $sch_id = $_SESSION['child']['log_school_id']; $acadamic_id = $_SESSION['child']['choosen_academic_id']; $notice_details = $student->notice_data_byid($notice_id); $details_sections =$student_new->get_sections_data_byclass($notice_details['class_id']); $savedfiles=$student->notice_data_images($notice_id); if($_POST['action'] == "update"){ /*$check_generalnotice = $student->check_generalnotice_data($_POST); echo "<pre>"; print_r($check_generalnotice); if($check_generalnotice['cnt'] > 0 ){ $result = $student->update_generalnotice_new($_POST,$check_generalnotice['notification_id']); } else { */ $result = $student->update_generalnotice($_POST,$_SESSION,$_FILES); echo "<script>location.replace('noticeboard_management.php?cresult=ERR203&type=".$_POST['category']."');</script>" ; //} } $details_students =$student->get_students_data_notice($notice_details['class_id'],$notice_details['section_id'],$sch_id); $ids = explode(",",$notice_details['student_id']); $details=$admin->get_classes_byschool_total($sch_id,$acadamic_id); if($notice_details['notification_type'] == "1"){ $gen_class = "selected"; }else if($notice_details['notification_type'] == "2"){ $vac_class = "selected"; }else if($notice_details['notification_type'] == "3"){ $act_class = "selected"; }else if($notice_details['notification_type'] == "4"){ $ptm_class = "selected"; }else if($notice_details['notification_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(){ var notice_description = document.getElementById('notice_description').value; var pics =document.getElementsByName("photos[]"); 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> <body style="overflow-x: hidden;"> <div class="row" style="margin-top: 30px; margin-left:20px;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=" glyphicon glyphicon-pencil" title ="Edit Message" style="font-size: 16px;"></i> Edit Message </div> </div> <br> <div class="menuu"> <ul id="nav" class="margn_auto"> <li class="<?php echo $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="<?php echo $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="<?php echo $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="<?php echo $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="<?php echo $foru_class?>" style="width:150px; text-align:center; margin-left:-3px; font-family:Arial, Helvetica, sans-serif;font-style:normal; font-size:14px;"><a href="for_you.php"><img src="images/for-you@2x.png" title ="For You" style="margin-right:5px;"/>For You</a></li> </ul> </div> <form class="form-horizontal" style="margin-top:30px; margin-left:-10px;" 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="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> </div> <div class="col-md-7"> <select class="form-control" id="category" name="category" style="height:29px; width:328px!important;font-size:12px;" tabindex="1" disabled> <option value='' >--Select Category--</option> <?php if($notice_details['notification_type'] == "1") { ?> <option value="1" selected>General</option> <?php }else if($notice_details['notification_type'] == "4") {?> <option value='4' selected>PTM</option> <?php } else if($notice_details['notification_type'] == "2") { ?> <option value='2' selected>Vacation</option> <?php }else if($notice_details['notification_type'] == "3") { ?> <option value='3' selected>Activities</option> <?php }else if($notice_details['notification_type'] == "5") {?> <option value='5' selected>For You</option> <?php } ?> </select> <!-- if there is an error--> <div class="col-md-7" id="err_category" style="color:#990000;margin-left:-15px;">Please Enter 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> </div> <div class="col-md-7"> <select class="form-control" id="classes" name="classes" style="height:29px; width:328px!important;font-size:12px;" tabindex="2" disabled> <option selected="selected" value='' >--Select Class--</option> <?php if($notice_details['class_id'] == "all") { ?> <option value='all' selected>All</option> <?php }else { foreach($details as $key=>$row) { if($row['class_id'] == $notice_details['class_id']) echo "<option value='".$row['class_id']."' selected>".$row['class_name']."</option>"; else 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:-15px;">Please Enter 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> </div> <div class="col-md-7"> <select class="form-control" id="sections" name="sections" style="height:29px; width:328px!important;font-size:12px;" tabindex="3" disabled> <option selected="selected" value='' >--Select Section--</option> <?php if($notice_details['section_id'] == "all"){ ?> <option value='all' selected>All</option> <?php }else { foreach($details_sections as $key=>$row) { if($row['section_id'] == $notice_details['section_id']) echo "<option value='".$row['section_id']."' selected>".$row['section_name']."</option>"; else echo "<option value='".$row['section_id']."'>".$row['section_name']."</option>"; } } ?> </select> <!-- if there is an error--> <div class="col-md-7" id="err_section" style="color:#990000;margin-left:-15px;">Please Enter Section</div> <!--- end error--> </div> </div> </div> <?php if($notice_details['notification_type'] == 5) { ?> <div class="class" id="student_details"> <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"> <select class="form-control" id="student" name="student[]" value="<?php echo $_POST['student']?>" style="height:100px; width:328px!important;font-size:12px;" tabindex="1" name="student" multiple > <?php $selected = ''; if($notice_details['student_id'] == 'all'){ echo "<option value='all' selected disabled>All</option>"; foreach($details_students as $key=>$row) { echo "<option value='".$row['student_id']."' selected disabled>".$row['student_firstname']." ".$row['student_lastname']."</option>"; } }else{ foreach($details_students as $key=>$row) { if(in_array($row['student_id'], $ids)){ $selected = 'selected'; }else{ $selected = ''; } echo "<option value='".$row['student_id']."' ".$selected." disabled>".$row['student_firstname']." ".$row['student_lastname']."</option>"; } } ?> </select> </div> </div> </div> <?php } ?> <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;">*</span></div> <div class="col-md-7"> <textarea class="form-control" id="notice_description" name="notice_description"rows="3" style="font-size:13px;width:328px;"tabindex="5" maxlength="1000"><?php echo $notice_details['notification_description']?></textarea> <!-- if there is an error--> <div class="col-md-7" id="err_description" style="color:#990000;margin-left:-15px;">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" id="addmoreimg"> <!-- if there is an error--> <div class="col-md-7" id="err_image" style="color:#990000;margin-left:6px;"></div> <!--- end error--> <br> <? if($savedfiles!=0) { $i=1; foreach($savedfiles as $fl) { /* echo '<img height="200px" width="200px" src="uploads/noticeboard/'.$fl[image].'"><i style="font-size: 14px;margin-top:10px;color:#01aee6;" title="Add More Sections " class=" glyphicon glyphicon-remove-circle" onclick="remove_saved('.$fl[noticeboard_img_id].')"></i>'; */ echo '<div id="editimage'.$i.'"><img height="100px" width="100px" src="'.NOTICEBOARD_IMAGES_PATH.$fl[image].'"><i style="font-size: 14px;margin-top:10px;color:#01aee6;" title="Add More Sections " class=" glyphicon glyphicon-remove-circle" onclick="remove_editme('.$fl[noticeboard_img_id].','.$i.')"></i></div></br>'; $i++; } }?> <input type="file" name="photos[]" id="fileChooser" onchange="return ValidateFileUpload()" /> <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()" >Send</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('<?php echo $notice_details['notification_type']?>')">Cancel</button> </div> </div> </div> </div> <input type="hidden" name="school_id" id="school_id" value="<?php echo $sch_id?>"> <input type="hidden" name="academic_id" id="academic_id" value="<?php echo $acadamic_id?>"> <input type="hidden" name="notice_id" id="notice_id" value="<?php echo $notice_id?>"> <input type="hidden" name="classes" id="classes" value="<?php echo $notice_details['class_id']?>"> <input type="hidden" name="sections" id="sections" value="<?php echo $notice_details['section_id']?>"> <input type="hidden" name="category" id="category" value="<?php echo $notice_details['notification_type']?>"> <input type="hidden" name="student" id="student" value="<?php echo $notice_details['student_id']?>"> <input type="hidden" name="action" id="action" value="update"> <input type="hidden" name="edit_image_ids" id="edit_image_ids" value=""> </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+')" /><i style="font-size: 14px;margin-top:10px;color:#01aee6;" 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(); } function remove_editme(val,me) { var edit_image_ids = ''; edit_image_ids = document.getElementById('edit_image_ids').value; document.getElementById('edit_image_ids').value = edit_image_ids+","+val; $('#editimage'+me).remove(); } function remove_saved(imgid,image) { $.ajax({ url: "ajaxcalls.php", type:"POST", data:"mode="+"delete_image"+"&imageid="+imgid+"&image="+image, success: function(result) { location.reload(); } }); } $("#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+")"); var students_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"); return false; } else if($(this).val() == 'all'){ var section_option = '<option value="0">Choose Section</option>'; section_option += '<option value="all">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>'; 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) { window.location="noticeboard_management.php?type="+type; } </script> </body> </html>