JezK
Edit File: update_feeschedule.php
<?php session_start(); include('session_check.php'); include('adm_operations.php'); $operations=new adm_operations(); include("menuheader.php"); if(!(in_array(6,$access) && in_array(6,$allow))) echo "<script>location.replace('dashboard.php');</script>"; $aydates=$operations->getAcadamicYearwithId($_SESSION['child']['choosen_academic_id']); $class=$operations->getallClassesforOrder($_SESSION['child']['log_school_id'],$_SESSION['child']['choosen_academic_id']); $thisterm=$operations->gettermforEdit($_GET['fsd']); if($class!=0) { $sections=$operations->getallsectionsdetailsbyclassId($thisterm['class_id']); } if(isset($_POST['updateterm'])) { $cls_id=$_POST['class_name']; $sec_id=$_POST['section_name']; $termname=$_POST['termname']; $amount=$_POST['termamount']; $duedate=str_replace('/','-',$_POST['lastdate']); $duedate=date('Y-m-d',strtotime($duedate)); $termid=$_POST['reference']; $acdid=$_SESSION['child']['choosen_academic_id']; $save=$operations->updatefeeterm($termid,$_SESSION['child']['auth_id'],$_SESSION['child']['log_school_id'],$cls_id,$sec_id,$termname,$amount,$duedate,$_POST['prevamt'],$acdid); if($save=='exist') { echo '<script>alert("The Amount can not be edited as at least one Parent has made the payment");</script>'; } else { $gourl="fee_management.php?cln=".$cls_id."&scn=".$sec_id; echo "<script>window.location.href='".$gourl."';</script>"; } } ?> <style> #nav { margin: auto; width:300px; padding-left:0; padding-right:0; list-style: none; background: #66CEF0; } #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: #01749a; width:90px; } #nav li.selected { background: #01749a; } /*///new ///*/ #nav { margin: auto; width:302px; 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); } #nav li.selected { background: rgb(54, 120, 102); } select { background-color: #FFF; border: 1px solid #CCC; } /*/// end my ////*/ </style> <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:1.4em; margin-left:20px;"> <i class=" glyphicon glyphicon-pencil" title ="Update Fee Schedule " style="font-size: 16px;margin-left:-13px;"></i> Update Fee Schedule </div> </div> <div class="menuu"> <ul id="nav" class="margn_auto"> <li class="selected" 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="fee_management.php"><img src="images/free-account_white.png" title ="Fee Schedule" style="margin-right:5px;"/>Fee Schedule</a> </li> <li style="width:152px; text-align:center; margin-left:-3px; font-family:Arial, Helvetica, sans-serif;font-style:normal; font-size:14px;"> <a href="fee_accounts.php"><img src="images/exam-schedule_white.png" title ="Fee Accounts" style="margin-right:5px;"/>Fee Accounts</a> </li> </ul> </div> <form class="form-horizontal" style="margin-top:20px; margin-left:-60px;" method="post"> <div class="box-body" style="background-color:#fff; padding: 10px; font-family:Arial, Helvetica, sans-serif; font-size:13px; "> <div class="clear"> <div class="form-group col-md-6" style="margin-bottom:1.0%;"> <div class="col-md-4 text-right"> <b style="color:#666666;">Class Name</b><span style="color:#FF0000; margin:2px;">*</span> </div> <div class="col-md-7"> <input type="hidden" name="reference" value="<?=$_GET['fsd'];?>"> <input type="hidden" id="start_dated" name="start_dates" value="<?php echo $aydates['academic_startdate'];?>"> <input type="hidden" id="end_dated" name="end_dates" value="<?php echo $aydates['academic_enddate'];?>"> <select class="form-control" id="classname" name="classname" style="height:29px; width:295px!important;font-size:12px;" tabindex="1" disabled> <option value='0'>--Select Class--</option> <? if($class!='0') foreach($class as $cls) if($thisterm[class_id]==$cls[class_id]) echo "<option value='".$cls[class_id]."' selected >".$cls[class_name]."</option>"; else echo "<option value='".$cls[class_id]."' >".$cls[class_name]."</option>"; ?> </select> <!-- if there is an error--> <div class="col-md-10" id="err_classname" style="color:#990000;margin-left:-15px;"></div> <!---end error--> </div> </div> </div> <div class="clear"> <div class="form-group col-md-6" style="margin-bottom:1.0%;"> <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"> <select class="form-control" id="sectionname" name="sectionname" style="height:29px; width:295px!important; font-size:12px;" tabindex="2" disabled> <option value='0' >--Select Section--</option> <? if($sections!='0') foreach($sections as $sec) if($thisterm[section_id]==$sec[section_id]) echo "<option value='".$sec[section_id]."' selected >".$sec[section_name]."</option>"; else echo "<option value='".$sec[section_id]."'>".$sec[section_name]."</option>"; ?> </select> <!-- if there is an error--> <div class="col-md-10" id="err_sectionname" style="color:#990000;margin-left:-15px;"></div> <!--- end error--> </div> </div> </div> <div class="clear"> <div class="form-group col-md-6" style="margin-bottom:1.0%; "> <div class="col-md-4 text-right "> <b style="color:#666666;">Term Name</b><span style="color:#FF0000; margin:2px; ">*</span> </div> <div class="col-md-7"> <input type=" text" class="form-control" id="termname" name="termname" style="height:29px; width:295px!important; font-size:12px;" value="<?if(isset($_POST[termname])) echo $_POST[termname];else echo $thisterm['term_name'];?>" tabindex="3" maxlength="60"> <!-- if there is an error--> <div class="col-md-10" id="err_termname" style="color:#990000;margin-left:-15px;"></div> <!--- end error--> </div> </div> </div> <div class="clear"> <div class="form-group col-md-6" style="margin-bottom:1.0%; "> <div class="col-md-4 text-right "> <b style="color:#666666;">Amount</b><span style="color:#FF0000; margin:2px; ">*</span> </div> <div class="col-md-7"> <input type=" text" class="form-control" id="termamount" name="termamount" style="height:29px; width:295px!important; font-size:12px;" value="<?if(isset($_POST[termamount])) echo $_POST[termamount];else echo $thisterm['term_amount'];?>" tabindex="4" maxlength="7"> <!-- if there is an error--> <div class="col-md-10" id="err_termamount" style="color:#990000;margin-left:-15px;"></div> <!--- end error--> </div> </div> </div> <input type="hidden" name="class_name" value=<?=$thisterm['class_id']?>> <input type="hidden" name="section_name" value=<?=$thisterm['section_id']?>> <input type="hidden" name="prevamt" value=<?=$thisterm['term_amount']?>> <div class="clear"> <div class="form-group col-md-6" style="margin-bottom:1.0%; "> <div class="col-md-4 text-right"> <b style="color:#666666;">Due Date</b><span style="color:#FF0000; margin:2px; ">*</span> </div> <div class="col-md-7"> <div id="datetimepicker" class="input-append date"> <input type="text" name="lastdate" id="lastdate" size="12" style="height:30px;width:268px!important;" value="<?if(isset($_POST[lastdate])) echo $_POST[lastdate];else echo date('d/m/Y',strtotime(str_replace('-','/',$thisterm['term_duedate'])));?>" tabindex="5"/> <span class="add-on" style="height:30px;"> <i data-time-icon="icon-time" data-date-icon="icon-calendar"></i> </span> </div> <!-- if there is an error--> <div class="col-md-10" id="err_lastdate" style="color:#990000;margin-left:-15px;"></div> <!--- end error--> </div> </div> <div style="clear:both;"></div> <div class="form-group"> <div class="col-md-7" align="center" style="margin-left:-50px;"> <button type="submit" name="updateterm" class="btn btn-default custom-button-width .navbar-right" tabindex="6" style="font-family:Arial, Helvetica, sans-serif;font-style:normal;font-size:13px; margin:10px;" onclick="return checkfields();">Update</button> <button type="button" class="btn btn-default custom-button-width .navbar-right" tabindex="7" style="font-family:Arial, Helvetica, sans-serif;font-style:normal;font-size:13px; margin:10px;" onclick="cancelupdate()">Cancel</button> </div> </div> </form> <script> function checkfields() { $('#err_classname').text(''); $('#err_sectionname').text(''); $('#err_termname').text(''); $('#err_termamount').text(''); $('#err_lastdate').text(''); var varc=document.getElementById('classname').value; var vars=document.getElementById('sectionname').value; var term=document.getElementById('termname').value.trim(); var amount=document.getElementById('termamount').value.trim(); var due=document.getElementById('lastdate').value; var regex=/^[a-zA-Z0-9\- ]+$/; var done= $("#start_dated").val(); var dtwo = $("#end_dated").val(); /*if(varc==0) { $('#err_classname').text("Please select Class"); document.getElementById('classname').focus(); return false; } else if(vars==0) { $('#err_sectionname').text("Please select Section"); document.getElementById('sectionname').focus(); return false; } else if(!due.match(re)) { $('#err_lastdate').text("Invalid Term Due Date"); document.getElementById('lastdate').focus(); return false; }*/ if(term=='') { $('#err_termname').text("Please enter Term Name"); $('#err_termname').show(); document.getElementById('termname').focus(); return false; } else if(!regex.test(term)) { $('#err_termname').text("Please enter valid Term Name"); $('#err_termname').show(); document.getElementById('termname').focus(); return false; } else if(amount=='') { $('#err_termamount').text("Please enter Term Amount"); $('#err_termamount').show(); document.getElementById('termamount').focus(); return false; } else if(isNaN(amount)) { $('#err_termamount').text("Please enter valid Term Amount"); $('#err_termamount').show(); document.getElementById('termamount').focus(); return false; } else if(due=='') { $('#err_lastdate').text("Please select Term Due Date"); $('#err_lastdate').show(); document.getElementById('lastdate').focus(); return false; } var dayone = done.split('/'); var daytwo = dtwo.split('/'); var cmp= due; var dcmp=cmp.split('/'); var mone=dayone[1]-1; var mtwos=daytwo[1]-1; var mcdate=dcmp[1]-1; //alert(JSON.stringify(dcmp)); var dones = new Date(dayone[2],mone,dayone[0]); var dtwos = new Date(daytwo[2],mtwos,daytwo[0]); var cdate= new Date(dcmp[2],mcdate,dcmp[0]); if(cdate>=dones && cdate<=dtwos) { } else { if(due!='') { $('#err_lastdate').text("Please select the Exam date within chosen Academic Year range"); $('#err_lastdate').show(); document.getElementById('lastdate').focus(); return false; } } } function cancelupdate() { var c=document.getElementById("classname").value; var s=document.getElementById("sectionname").value; window.location.href="fee_management.php?cln="+c+"&scn="+s; } </script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script type="text/javascript" src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/js/bootstrap.min.js"></script> <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"> $('#datetimepicker').datetimepicker({ format: 'dd/MM/yyyy', pickTime: false }).on('changeDate', function(){ $(this).datetimepicker('hide'); }); </script> </body> </html>