JezK
Edit File: add_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']); if(isset($_GET['cln']) && isset($_GET['scn'])) { $class=$operations->getallClassesforOrder($_SESSION['child']['log_school_id'],$_SESSION['child']['choosen_academic_id']); $sections=$operations->getallsectionsdetailsbyclassId($_GET['cln']); $classid=$_GET['cln']; $sectionid=$_GET['scn']; } else { $class=$operations->getallClassesforOrder($_SESSION['child']['log_school_id'],$_SESSION['child']['choosen_academic_id']); if($class!=0) { $sections=$operations->getallsectionsdetailsbyclassId($class[0][class_id]); $classid=$class[0][class_id]; } if($sections!=0) $sectionid=$sections[0][section_id]; } // form submission if(isset($_POST['addterm'])) { $error=0; $now=date('Y-m-d'); $cls_id=$_POST['classname']; $sec_id=$_POST['sectionname']; $termname=$_POST['termname']; $amount=$_POST['termamount']; $duedate=$_POST['duedate']; foreach($_POST['duedate'] as $dt) { $duedate[]=date('Y-m-d',strtotime(str_replace('/','-',$dt))); } $save=$operations->addfeetermstoClass($_SESSION['child']['auth_id'],$_SESSION['child']['log_school_id'],$_SESSION['child']['choosen_academic_id'],$cls_id,$sec_id,$termname,$amount,$duedate); if($save=='exist') { echo "<script>alert('Term Name already exist in the system');</script>"; } else { $nurl="fee_management.php?cln=".$cls_id."&scn=".$sec_id; echo "<script>window.location.href='".$nurl."';</script>"; } } // when posted all values if(isset($_POST['addterm'])) { $clsoptions="<option value='0'>--Select Class--</option>"; foreach($class as $cls) if($_POST['classname']==$cls[class_name]) $clsoptions.="<option value='".$cls[class_id]."' selected >".$cls[class_name]."</option>"; else $clsoptions.="<option value='".$cls[class_id]."'>".$cls[class_name]."</option>"; $scnoption="<option value='0'>--Select Section--</option>"; foreach($sections as $sec) if($_POST['sectionname']==$sec[section_id]) $scnoption.="<option value='".$sec[section_id]."' selected >".$sec[section_name]."</option>"; else $scnoption.="<option value='".$sec[section_id]."'>".$sec[section_name]."</option>"; } else { $clsoptions="<option value='0'>--Select Class--</option>"; if($class!=0) foreach($class as $cls) if($_GET['cln']==$cls[class_id]) $clsoptions.="<option value='".$cls[class_id]."' selected>".$cls[class_name]."</option>"; else $clsoptions.="<option value='".$cls[class_id]."'>".$cls[class_name]."</option>"; $scnoption="<option value='0'>--Select Section--</option>"; //foreach($sections as $sec) //$scnoption.="<option value='".$sec[section_id]."'>".$sec[section_name]."</option>"; } ?> <style> .add { color: #01aee6; margin-top:15px; } .delete { color: #01aee6; margin-top:7px; margin-left:23px; } #nav { margin: auto; width:300px; 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> <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-plus" title ="Add Fee Schedule" style="font-size:16px;margin-left:-50px;margin-left:-13px;"></i> Add Fee Schedule </div> </div> <br> <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</b> <span style="color:#FF0000; margin:2px;">*</span> </div> <div class="col-md-7"> <select class="form-control" id="classname" name="classname" style="height:29px; width:295px!important;font-size:12px;" onchange="onchangeClass(this.value)"> <?php echo $clsoptions;?> </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;"> <?php echo $scnoption; ?> </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="row"> <div class="col-md-12"> <div class="col-md-2"></div> <div class="col-md-9" style="margin-left:-30px; margin-top:20px;"> <div class="col-md-3"><b style="color: #666666;">Term Name</b></div> <div class="col-md-3"><b style="color: #666666;">Amount</b></div> <div class="col-md-3"><b style="color: #666666;">Due Date</b></div> </div> </div> </div> <!-- <div class="row" id="firstbox"> <div class="col-md-12"> <div class="col-md-2"></div> <div class="col-md-9" style="margin-left:-30px; margin-top:10px;"> <div class="col-md-3"> <input type="text" class="form-control" name="termname[]" style="height:29px;font-size:13px;"> </div> <div class="col-md-3"> <input type="text" class="form-control" name="termamount[]" style="height:29px;font-size:13px;"> </div> <div class="col-md-3"> <input type="text" class="form-control" name="duedate[]" style="height:29px;font-size:13px;"> </div> </div> <div class="col-md-1" style="margin-left:-260px;"> <a href="javascript:void(0)"> <i class="glyphicon glyphicon-plus" title ="Add More " style="font-size: 14px;margin-top:15px;" onclick="appendhtmlfornewterm()"></i> </a> </div> </div> </div> <div id="newbox"> </div>--> <div id='TextBoxesGroup'> <div id="TextBoxDiv1"> <div class="row"> <div class="col-md-12"> <div class="col-md-2"> <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'];?>"> </div> <div class="col-md-9" style="margin-left:-30px; margin-top:10px;"> <div class="col-md-3"> <input type="text" class="form-control" name="termname[]" style="height:29px;font-size:13px;" id="alltermid" maxlength="60"> <!-- if there is an error--> <div class="col-md-12" id="err_termname" style="color:#990000;margin-left:-14px;font-size:12px;"></div> <!--- end error--> </div> <div class="col-md-3"> <input type="text" class="form-control" name="termamount[]" style="height:29px;font-size:13px;" id="alltermamount" maxlength="7"> <!-- if there is an error--> <div class="col-md-12" id="err_termamount" style="color:#990000;margin-left:-14px;font-size:12px;"></div> <!--- end error--> </div> <div class="col-md-3"> <div id="datetimepicker1" class="input-append date"> <input type="text" name="duedate[]" id="startdate" size="12" style="height:30px;"/> <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-12" id="err_duedate" style="color:#990000;margin-left:-14px;font-size:12px;"></div> <!--- end error--> </div> </div> <div class="col-md-1" style="margin-left:-185px;"> <!--<a href="javascript:void(0)"> <i class="glyphicon glyphicon-plus" title ="Add More " style="font-size: 14px;margin-top:15px;" onclick="appendhtmlfornewterm()"></i> </a>--> <a><i class="glyphicon glyphicon-plus add" type='button' value='Add' id='addButton'></i></a> </div> </div> </div> </div> </div> <div class="row"> <div class="col-md-12"> <div class="col-md-2"></div> <div class="col-md-9" style="margin-left:-30px; margin-top:10px;"></div> </div> <div style="clear:both;"></div> <div class="form-group"> <div class="col-md-11" align="center"> <button type="submit" name="addterm" class="btn btn-default custom-button-width .navbar-right btnclr" style="font-family:Arial, Helvetica, sans-serif;font-style:normal;font-size:13px; margin:10px;" onclick="return checkallfilled();">Add</button> <button type="button" class="btn btn-default custom-button-width .navbar-right btnclr" style="font-family:Arial, Helvetica, sans-serif;font-style:normal;font-size:13px; margin:10px;" onclick="canceladd()">Cancel</button> </div> </div> </div> </form> <script> function checkallfilled() { $("#err_classname").text(''); $("#err_sectionname").text(''); $("#err_termname").text(''); $("#err_termamount").text(''); $("#err_duedate").text(''); var varc=document.getElementById('classname').value; var vars=document.getElementById('sectionname').value; var regex=/^[a-zA-Z0-9\- ]+$/; if(varc==0) { $("#err_classname").text('Please select Class'); $("#err_classname").show(); document.getElementById('classname').focus(); return false; } else if(vars==0) { $("#err_sectionname").text('Please select Section'); $("#err_sectionname").show(); document.getElementById('sectionname').focus(); return false; } // checking term name is empty var terms=document.getElementsByName("termname[]"); var amounts=document.getElementsByName("termamount[]"); var duedates=document.getElementsByName("duedate[]"); for(var i = 0; i < terms.length; i++) { if(terms[i].value.trim()=='') // term name validation { if(i==0) { $("#err_termname").text('Please enter Term Name'); $("#err_termname").show(); return false; } else { $("#err_termname").text('Please enter missing Term Name'); $("#err_termname").show(); return false; } } else if(!regex.test(terms[i].value)) { if(i==0) { $("#err_termname").text('Please enter valid Term Name'); $("#err_termname").show(); return false; } else { $("#err_termname").text('Please enter valid Term Name for each Term'); $("#err_termname").show(); return false; } } else if(amounts[i].value.trim()=='') // term amount validation { if(i==0) { $('#err_termamount').text('Please enter Term Amount'); $('#err_termamount').show(); return false; } else { $('#err_termamount').text('Please enter missing Term Amount'); $('#err_termamount').show(); return false; } } else if(isNaN(amounts[i].value)) { if(i==0) { $('#err_termamount').text('Please enter valid Term Amount'); $('#err_termamount').show(); return false; } else { $('#err_termamount').text('Please enter valid Term Amount for each Term '); $('#err_termamount').show(); return false; } } else if(duedates[i].value=='') // date validation { if(i==0) { $('#err_duedate').text('Please select Term Due Date'); $('#err_duedate').show(); return false; } else { $('#err_duedate').text('Please enter missing Term Due Date'); $('#err_duedate').show(); return false; } } else { var dtfun=checkdateay(duedates[i].value); if(dtfun==false) return false; } } } function canceladd() { window.location.href="fee_management.php"; } function checkdateay(value) { var done= $("#start_dated").val(); var dtwo = $("#end_dated").val(); var dayone = done.split('/'); var daytwo = dtwo.split('/'); var cmp= value; 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(value!='') { alert('Please select the date within chosen Academic Year range'); return false; } } } </script> <script type="text/javascript"> $(document).ready(function() { var counter = 2; $("#addButton").click(function () { var newTextBoxDiv = $(document.createElement('div')).attr("id", 'TextBoxDiv' + counter); newTextBoxDiv.after().html('<div class="row">\ <div class="col-md-12">\ <div class="col-md-2"></div>\ <div class="col-md-9" style="margin-left:-30px; margin-top:10px;">\ <div class="col-md-3">\ <input type="text" class="form-control" name="termname[]" id="ter'+counter+'" style="height:29px;font-size:13px;" maxlength="60">\ </div>\ <div class="col-md-3">\ <input type="text" class="form-control" name="termamount[]" id="ta'+counter+'" style="height:29px;font-size:13px;" maxlength="7">\ </div>\ <div class="col-md-3">\ <div id="datetimepicker'+counter+'" class="input-append date">\ <input type="text" name="duedate[]" size="12" style="height:30px;" />\ <span class="add-on" style="height:30px;">\ <i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>\ </span>\ </div>\ </div>\ <div class="col-md-1" style="margin-left:16px;"><a><i class="glyphicon glyphicon-remove-circle delete" value="Remove" onclick="Remove_row('+counter+');"></i></a></div>\ </div></div></div>'); newTextBoxDiv.appendTo("#TextBoxesGroup"); $('#datetimepicker'+counter).datetimepicker({ format: 'dd/MM/yyyy', pickTime: false }).on('changeDate', function(){ $(this).datetimepicker('hide'); }); counter++; return false; }); }); function Remove_row(cntr) { if(cntr>1) { $("#TextBoxDiv" + cntr).remove(); } } function onchangeClass(x) { if(x == 0) { section_option = '<option value="0">--Select Section--</option>'; $("#sectionname").html(section_option); return false; } else { $.ajax({ url: "ajaxcalls_attn.php", type:"POST", data:"mode="+"choose_class"+"&data="+x, 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>'; } $("#sectionname").html(section_option); }, error : function(e) { //alert(e); } }); } } </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://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"> $('#datetimepicker1').datetimepicker({ format: 'dd/MM/yyyy', pickTime: false }).on('changeDate', function(){ $(this).datetimepicker('hide'); }); </script> </body> </html>