JezK
Edit File: addMonthlyReport.php
<?php $currentPage="monthlyReports"; include("header.php"); if($isUserExpired) { echo "<script>location.replace('dashboard.php');</script>"; } if(isset($_SESSION['saveSuccess'])) { echo "<script>alert('Data saved successfully.');</script>"; unset($_SESSION['saveSuccess']); } if(isset($_SESSION['fileUploadFailed'])) { echo "<script>alert('Upload Error!!! Unable to upload file. Internal server error.');</script>"; unset($_SESSION['fileUploadFailed']); } if(isset($_SESSION['reportInsertFailed'])) { echo "<script>alert('Error!!! Unable to save report details. Internal server error.');</script>"; unset($_SESSION['reportInsertFailed']); } if(isset($_SESSION['staffInsertFailed'])) { echo "<script>alert('Error!!! Unable to save staff report details. Internal server error.');</script>"; unset($_SESSION['staffInsertFailed']); } ?> <div id="page-wrapper"> <form enctype="multipart/form-data" action="app/monthlyReportApp.php" onsubmit="return validate()" method="post"> <div class="container-fluid"> <!-- Page Heading --> <div class="row"> <div class="col-lg-12 page-header"> <h1 class=" col-md-4"> <small>Monthly Performance Reports </small> </h1> <div class="col-md-2 cs-select"> <select class=" selectStyle" id="month" name="month" onchange="isReportAlreadySubmitted(this.value)"> <option value="0">Select Month</option> <option value="1">January</option> <option value="2">February</option> <option value="3">March</option> <option value="4">Apirl</option> <option value="5">May</option> <option value="6">June</option> <option value="7">July</option> <option value="8">August</option> <option value="9">September</option> <option value="10">October</option> <option value="11">November</option> <option value="12">December</option> </select> </div> <div class="col-md-2 cs-select"> <p class="yearStyle" id="year">Year : 2017</p> </div> </div> </div> <!-- /.row --> <div class="row" id="reportDiv"> <div class="col-md-12"> <div class="form-group"> <label class="col-md-8">Total Number of SHG's Credit Linked with NABFINS in the Month:</label> <input type="tex" class="cs-textfield" placeholder="Enter number only" name="totalSHG" id="totalSHG" value="" maxlength="15" onkeypress="return number(event)"> </div> <div class="form-group"> <label class="col-md-8">Proposed Number of SHG available for linkage in next Month :</label> <input type="tex" class="cs-textfield" placeholder="Enter number only" name="proposedSHG" id="proposedSHG" value="" maxlength="15" onkeypress="return number(event)"> </div> <div class="form-group"> <label class="col-md-8">Total collection During the Month :</label> <input type="tex" class="cs-textfield" placeholder="" name="totalCollection" id="totalCollection" value="" maxlength="15" onkeypress="return number2(event)"> </div> <div class="form-group"> <label class="col-md-8">Total Amount Remitted to NABFINS bank account in the Month: Rs</label> <input type="tex" class="cs-textfield" placeholder="" name="totalRemit" id="totalRemit" value="" maxlength="15" onkeypress="return number2(event)"> </div> <div class="form-group"> <label class="col-md-8">Actual cash holding, if any by B&DC as on last day of the Month :Rs</label> <input type="tex" class="cs-textfield" placeholder="" name="cashHolding" id="cashHolding" value="" maxlength="15" onkeypress="return number2(event)"> </div> <div class="form-group"> <label class="col-md-8">Any changes in Board members During the Month (Y/N) (if yes upload resolution copy) :</label> <div> <input type="radio" name="boardMembersChange" value="1" id="yes" onclick="displayFile('block')"> <label for="yes" style="color:black;font-weight:normal;cursor:pointer;">Yes</label> <input type="radio" name="boardMembersChange" value="0" id="no" onclick="displayFile('none')" checked> <label for="no" style="color:black;font-weight:normal;cursor:pointer;">No</label> </div> </div> <div class="form-group" id="uploadFile"> <label class="col-md-2" style="padding-top: 12px;"> Upload a file:</label> <input type="hidden" value="0" id="fileStatus"> <input type="file" value="" id="FCRAFile" name="FCRAFile" class="browse-o" onchange="ValidateFileUpload()"> <button type="button" class="browse-d">Browse</button> <!--<input type="button" value="Upload" class="uploadBtn">--> <div id="fileUploadStatus" class="divSuccess"></div> <span class="path"></span> </div> <div class="form-group"> <label class="col-md-8">No of SHG Meetings attended by B&DC Staff during the Month</label> <input type="tex" class="cs-textfield" placeholder="Enter number only" name="shgMeetings" id="shgMeetings" value="" maxlength="15" onkeypress="return number(event)"> </div> <div class="form-group"> <label class="col-md-8">No of SHG Promoted during the Month :</label> <input type="tex" class="cs-textfield" placeholder="Enter number only" name="shgPromoted" id="shgPromoted" value="" maxlength="15" onkeypress="return number(event)"> </div> <div class="form-group"> <label class="col-md-8">No of SHG Adopted by the B&DC during the Month</label> <input type="tex" class="cs-textfield" placeholder="Enter number only" name="shgAdopted" id="shgAdopted" value="" maxlength="15" onkeypress="return number(event)"> </div> <h3 class="col-md-11">Details of staff as on last day of the Month:</h3> <!--<input type="button" class="btn btn-default add_field_button col-md-1" value="Add New" >--> <div class="col-md-12 table-responsive"> <table class="table table-striped table-bordered" cellspacing="0" width="100%"> <thead> <tr> <th>S.No</th> <th>No. of staff working with B&DC </th> <th>No. of staff working with nabfins</th> <th>No. of staff having Nabfins id card</th> <th>Number of staff newly joined</th> <th>No. of staff involved in Nabfins</th> <th>No. of Staff using mobile cbs</th> <!--<th>Action</th>--> </tr> </thead> <tbody class="input_fields_wrap"> <tr> <td>1.</td> <td><input type="text" name="totalBCStaff[]" maxlength="8" class="cs-textfield" id="totalBCStaff1" value="" onkeypress="return number(event)"></td> <td><input type="text" name="totalNabfinsStaff[]" maxlength="8" class="cs-textfield" id="totalNabfinsStaff1" value="" onkeypress="return number(event)"></td> <td><input type="text" name="totalNabfinsStaffIDCards[]" maxlength="8" class="cs-textfield" id="totalNabfinsStaffIDCards1" value="" onkeypress="return number(event)"></td> <td><input type="text" name="totalNewStaffJoined[]" maxlength="8" class="cs-textfield" id="totalNewStaffJoined1" value="" onkeypress="return number(event)"></td> <td><input type="text" name="totalNabfinsInvolvedStaff[]" maxlength="8" class="cs-textfield" id="totalNabfinsInvolvedStaff1" value="" onkeypress="return number(event)"></td> <td><input type="text" name="totalBCMobileCBS[]" maxlength="8" class="cs-textfield" id="totalBCMobileCBS1" value=""onkeypress="return number(event)"></td> <!--<td></td>--> </tr> </tbody> </table> </div> <div class="col-md-12 table-responsive"> <h3 class="col-md-11 removePadding">Name of the staff who left the service</h3> <input type="button" class="btn btn-default add_field_button2 col-md-1" value="Add New" style="margin-top: 10px;" > <table class="table table-striped table-bordered" cellspacing="0" width="100%"> <thead> <tr> <th>S.No</th> <th>Name of the staff</th> <th>Action</th> </tr> </thead> <tbody class="inputSection2"> <tr> <td>1.</td> <td><input type="text" class="cs-textfield" name="leftedStaffName[]" id="leftedStaffName1" value="" maxlength="300"></td> <td></td> </tr> </tbody> </table> </div> <div class="col-md-12 table-responsive"> <h3 class="col-md-11 removePadding">Name of the staff who joined the service</h3> <input type="button" class="btn btn-default add_field_button3 col-md-1" value="Add New" > <table class="table table-striped table-bordered" cellspacing="0" width="100%"> <thead> <tr> <th>S.No</th> <th>Name of the staff</th> <th>Action</th> </tr> </thead> <tbody class="inputSection3"> <tr> <td>1.</td> <td><input type="text" class="cs-textfield" name="joinedStaffName[]" id="joinedStaffName1" value="" maxlength="300"></td> <td></td> </tr> </tbody> </table> </div> <div class="col-md-12 text-center"> <input type="submit" value="Submit" name="submit" id="submit" class="btn btn-cs"> </div> </form> </div> </div> <!-- /.row --> </div> <!-- /.container-fluid --> </div> <!-- /#page-wrapper --> <script> pdfFlag = 0; $(document).ready(function() { document.getElementById('uploadFile').style.display='none'; $(".browse-d").click(function(){ $(this).parents(".form-group").find('.browse-o').click(); }); $('.browse-o').change(function(){ var fileName =$(this).parents(".form-group").find('.browse-o').val(); fileName = fileName.substring(fileName.lastIndexOf("\\") + 1, fileName.length); $(this).closest('.form-group').find('.path').html(fileName); }); //var max_fields = ; //maximum input boxes allowed var wrapper = $(".input_fields_wrap"); //Fields wrapper var add_button = $(".add_field_button"); //Add button ID var x = 1; //initlal text box count $(add_button).click(function(e){ //on add input button click /*totalBCStaff = document.getElementById('totalBCStaff'+x); totalNabfinsStaff = document.getElementById('totalNabfinsStaff'+x); totalNabfinsStaffIDCards = document.getElementById('totalNabfinsStaffIDCards'+x); totalNewStaffJoined = document.getElementById('totalNewStaffJoined'+x); totalNabfinsInvolvedStaff = document.getElementById('totalNabfinsInvolvedStaff'+x); totalBCMobileCBS = document.getElementById('totalBCMobileCBS'+x);*/ totalBCStaff = document.getElementById('totalBCStaff1'); totalNabfinsStaff = document.getElementById('totalNabfinsStaff1'); totalNabfinsStaffIDCards = document.getElementById('totalNabfinsStaffIDCards1'); totalNewStaffJoined = document.getElementById('totalNewStaffJoined1'); totalNabfinsInvolvedStaff = document.getElementById('totalNabfinsInvolvedStaff1'); totalBCMobileCBS = document.getElementById('totalBCMobileCBS1'); if(totalBCStaff.value.trim() != "" && totalNabfinsStaff.value.trim() != "" && totalNabfinsStaffIDCards.value.trim() != "" && totalNewStaffJoined.value.trim() != "" && totalNabfinsInvolvedStaff.value.trim() != "" && totalBCMobileCBS.value.trim() != "") { e.preventDefault(); // if(x < max_fields){ //max input box allowed x++; //text box increment $(wrapper).append('<tr> \ <td>'+x+'</td> \ <td><input type="text" name="totalBCStaff[]" maxlength="8" class="cs-textfield" id="totalBCStaff'+x+'" value="" onkeypress="return number(event)"></td> \ <td><input type="text" name="totalNabfinsStaff[]" maxlength="8" class="cs-textfield" id="totalNabfinsStaff'+x+'" value="" onkeypress="return number(event)"></td> \ <td><input type="text" name="totalNabfinsStaffIDCards[]" maxlength="8" class="cs-textfield" id="totalNabfinsStaffIDCards'+x+'" value="" onkeypress="return number(event)"></td> \ <td><input type="text" name="totalNewStaffJoined[]" maxlength="8" class="cs-textfield" id="totalNewStaffJoined'+x+'" value="" onkeypress="return number(event)"></td> \ <td><input type="text" name="totalNabfinsInvolvedStaff[]" maxlength="8" class="cs-textfield" id="totalNabfinsInvolvedStaff'+x+'" value="" onkeypress="return number(event)"></td>\ <td><input type="text" name="totalBCMobileCBS[]" class="cs-textfield" maxlength="8" id="totalBCMobileCBS'+x+'" value="" onkeypress="return number(event)"></td> \ <td><a class="action2"><i class="fa fa-trash remove_field" aria-hidden="true" ></i></a></td> \ </tr>'); //add input box //} } else { alert("Please fill all the fields."); } }); $(wrapper).on("click",".remove_field", function(e){ //user click on remove text e.preventDefault(); $(this).closest('tr').remove();x--; }); //var max_fields = ; //maximum input boxes allowed var wrapper2 = $(".inputSection2"); //Fields wrapper var add_button2 = $(".add_field_button2"); //Add button ID var x2 = 1; //initlal text box count $(add_button2).click(function(e) { //on add input button click staffNameLength = document.getElementsByName('leftedStaffName[]').length; for(i=0;i<staffNameLength;i++) { leftedStaffName = document.getElementsByName('leftedStaffName[]'); if(leftedStaffName[i].value.trim() != "") { flag = 1; } else { flag = 0; break; } } if(flag == 1) { e.preventDefault(); x2++; $(wrapper2).append('<tr> \ <td>'+x2+'</td> \ <td><input type="text" class="cs-textfield" name="leftedStaffName[]" id="leftedStaffName'+x2+'" value="" maxlength="300"></td> \ <td><a class="action2"><i class="fa fa-trash remove_field2" aria-hidden="true" ></i></a></td> \ </tr> '); //add input box } else { alert("Staff name must not be empty."); } //alert(leftedStaffName2.length) }); $(wrapper2).on("click",".remove_field2", function(e){ //user click on remove text e.preventDefault(); $(this).closest('tr').remove(); }); //var max_fields = ; //maximum input boxes allowed var wrapper3 = $(".inputSection3"); //Fields wrapper var add_button3 = $(".add_field_button3"); //Add button ID var x3 = 1; //initlal text box count $(add_button3).click(function(e){ //on add input button click /*joinedStaffName = document.getElementById('joinedStaffName'+x3);*/ joinedStaffName = document.getElementById('joinedStaffName1'); if(joinedStaffName.value.trim() != "") { e.preventDefault(); // if(x < max_fields){ //max input box allowed x3++; //text box increment $(wrapper3).append('<tr> \ <td>'+x3+'</td> \ <td><input type="text" class="cs-textfield" name="joinedStaffName[]" id="joinedStaffName'+x3+'" value="" maxlength="300"></td>\ <td><a class="action2"><i class="fa fa-trash remove_field3" aria-hidden="true" ></i></a></td> \ </tr> '); //add input box //} } else { alert("Staff name must not be empty."); } }); $(wrapper3).on("click",".remove_field3", function(e){ //user click on remove text e.preventDefault(); $(this).closest('tr').remove();x3--; }); }); function displayFile(status) { document.getElementById('uploadFile').style.display=status; } function number(e) { //if(e.keyCode == 13 || (e.keyCode >= 48 && e.keyCode <= 57)) var key = e.keyCode || e.charCode; if(key == 13 || key == 43 || (key >= 48 && key <= 57) || key == 8 || key == 46) { return true; } else { return false; } } function number2(e) { //if(e.keyCode == 13 || e.keyCode == 46 || (e.keyCode >= 48 && e.keyCode <= 57)) var key = e.keyCode || e.charCode; if(key == 13 || key == 43 || (key >= 48 && key <= 57) || key == 8 || key == 46) { return true; } else { return false; } } function validate() { month = document.getElementById('month'); yes = document.getElementById('yes'); fileStatus = document.getElementById('fileStatus'); if(month.value == 0) { alert("Please select a month."); month.focus(); return false; } if(yes.checked == true) { if(fileStatus.value == 0) { alert("Please upload a valid file."); return false; } } return true; } function ValidateFileUpload() { pdfFlag = 0; var fuData = document.getElementById('FCRAFile'); var fileStatus = document.getElementById('fileStatus'); var fileUploadStatus = document.getElementById('fileUploadStatus'); var FileUploadPath = fuData.value; //To check if user upload any file if (FileUploadPath == '') { fileUploadStatus.innerHTML ='<span class="fail"></span>'; alert("Please upload a pdf file."); fileStatus.value = 0; pdfFlag = 0; } else { var Extension = FileUploadPath.substring( FileUploadPath.lastIndexOf('.') + 1).toLowerCase(); //The file uploaded is an pdf if (Extension == "pdf") { var size=1048576; var file_size=fuData.files[0].size; if(file_size>=size) { alert('File too large'); fileStatus.value = 0; pdfFlag = 0; fileUploadStatus.innerHTML ='<span class="fail"></span>'; } else { pdfFlag = 1; fileStatus.value = 1; fileUploadStatus.innerHTML ='<span class="success"></span>'; } } //The file upload is NOT an pdf else { alert("Please upload a pdf file."); fileStatus.value = 0; fileUploadStatus.innerHTML ='<span class="fail"></span>'; } } } function isReportAlreadySubmitted(reportMonth) { if(reportMonth != 0) { $.post('app/ajax.php',{type:1,reportMonth:reportMonth},function(data) { if(data != 0) { document.getElementById('reportDiv').style.display = 'none'; alert('Report already generated for selected month.'); } else { document.getElementById('reportDiv').style.display = 'block'; } }); } } </script> <?php include("footer.php");?>