JezK
Edit File: page2.php
<?php include("header.php"); $_SESSION['bcFormPage'] = "page2.php"; //echo "<pre>";print_r($details);exit; if(!isset($_SESSION['bcFormUserID'])) { echo "<script>location.replace('page1.php');</script>"; } if(isset($_SESSION['saveSuccess'])) { echo "<script>alert('Data saved successfully.');</script>"; unset($_SESSION['saveSuccess']); } if(isset($_SESSION['operationsSaveFailed'])) { echo "<script>alert('Error!!! Unable to save operation details. Internal server error.');</script>"; unset($_SESSION['operationsSaveFailed']); } if(isset($_SESSION['operationsUpdateFailed'])) { echo "<script>alert('Error!!! Unable to update operations details. Internal server error.');</script>"; unset($_SESSION['operationsUpdateFailed']); } if(isset($_SESSION['userSaveFailed'])) { echo "<script>alert('Error!!! Unable to save user details. Internal server error.');</script>"; unset($_SESSION['userSaveFailed']); } if(isset($_SESSION['projectsSaveFailed'])) { echo "<script>alert('Error!!! Unable to save projects details. Internal server error.');</script>"; unset($_SESSION['projectsSaveFailed']); } if(isset($_SESSION['projectsUpdateFailed'])) { echo "<script>alert('Error!!! Unable to update projects details. Internal server error.');</script>"; unset($_SESSION['projectsUpdateFailed']); } if(isset($_SESSION['deleteSuccess'])) { echo "<script>alert('Data deleted succesfully.');</script>"; unset($_SESSION['deleteSuccess']); } if(isset($_SESSION['deleteFailed'])) { echo "<script>alert('Error!!! Unable to delete registration details. Internal server error.');</script>"; unset($_SESSION['deleteFailed']); } if(isset($_SESSION['fcraUploadFailed'])) { echo "<script>alert('Error!!! Unable to upload FCRA file. Internal server error.');</script>"; unset($_SESSION['fcraUploadFailed']); } if(isset($_SESSION['panUploadFailed'])) { echo "<script>alert('Error!!! Unable to upload PAN file. Internal server error.');</script>"; unset($_SESSION['panUploadFailed']); } if(isset($_SESSION['fcraSaveFailed'])) { echo "<script>alert('Error!!! Unable to save FCRA details. Internal server error.');</script>"; unset($_SESSION['fcraSaveFailed']); } if(isset($_SESSION['panSaveFailed'])) { echo "<script>alert('Error!!! Unable to save PAN details. Internal server error.');</script>"; unset($_SESSION['panSaveFailed']); } ?> <div class="container main"> <div class="row"> <form action = "app/page2App.php" enctype="multipart/form-data" class="form-horizontal" method="post" onsubmit="return validatePage2()"> <div class="col-md-12 col-md-offset-0 formContainer"> <section> <div class="col-md-12 removePadding"> <h3 class="subHead col-md-11 removePadding">Area of Operation</h3> <input type="button" class="btn btn-default addBtn1 pull-right col-md-1" value="Add New" > </div> <div class="col-md-12 input_fields_wrapOPerations"></div> <?php echo $operationsDetails; ?> </section> <section> <div class="col-md-12 removePadding"> <h3 class="subHead col-md-11 removePadding">Projects Undertaken</h3> <input type="button" class="btn btn-default col-md-1 addBtn2 pull-right" value="Add New" > </div> <div class="col-md-12 table-responsive removePadding"> <table class="table table-bordered cs-table table-responsive"> <thead> <tr> <th>S.No</th> <th>Previous Projects</th> <th>Funder</th> <th>Period - Start Date</th> <th>Period - End Date</th> <th>Activity</th> <th>Action</th> </tr> </thead> <tbody class="input_fields_wrap2"> <?php echo $projectsDetails; ?> </tbody> </table> </div> </section> <section> <div class="col-md-12 removePadding"> <h3 class="subHead">Whether Registered under Foreign Contribution (Regulation) Act, 1976(FCRA)? <input type="radio" name="isFCRA" value="1" id="fcraYes" <?php echo $isFCRA1; ?> onclick="displayAct(1)"> <label for="fcraYes" style="color:black;font-weight:normal;cursor:pointer;">Yes</label> <input type="radio" name="isFCRA" value="0" id="fcraNo" <?php echo $isFCRA2; ?> onclick="displayAct(0)"> <label for="fcraNo" style="color:black;font-weight:normal;cursor:pointer;">No</label> </h3> </div> <div class="col-md-12" id="regulationAct"> <div class="form-group"> <label class="col-md-2" for="details">Details:</label> <textarea placeholder="Details" id="FCRADetails" rows="7" class="col-md-10" name="FCRADetails"><?php echo $FCRADetails; ?></textarea> </div> <div class="form-group"> <label class="col-md-2">File Upload<br> <small>(upload pdf/image only)</small>:</label> <input type="hidden" value="<?php echo $txtFCRAStatus; ?>" id="txtFCRAUpload" name="txtFCRAUpload"> <input type="hidden" value="<?php echo $txtFCRAFileName; ?>" name="txtFCRAFileName"> <input type="file" value="" id="FCRAFile" name="FCRAFile" class="browse-o" onchange="ValidateFileUpload('FCRAFile','txtFCRAUpload','FCRAUploadStatus')"> <button type="button" class="browse-d">Browse</button> <!--<input type="button" value="Upload" class="uploadBtn" onclick="validatePDF(2,'FCRAFile','FCRAUploadStatus','txtFCRAUpload')">--> <div id="FCRAUploadStatus" class="divSuccess"><?php echo $FCRAUploadStatus; ?></div> </div> </div> </section> <section> <!--<div class="col-md-12 removePadding"> <h3 class="subHead">* Whether a Permanent Account Number (PAN) obtained from Competent Authority? <input type="radio" name="isPAN" value="1" id="panYes" <?php echo $isPAN1; ?> onclick="displayAuthority(1)"> <label for="panYes" style="color:black;font-weight:normal;cursor:pointer;">Yes</label> <input type="radio" name="isPAN" value="0" id="panNo" <?php echo $isPAN2; ?> onclick="displayAuthority(0)"> <label for="panNo" style="color:black;font-weight:normal;cursor:pointer;">No</label> </h3> </div> <div class="form-group" id="panAuthority"> <label class="col-md-2">Upload a copy<br> <small>(upload pdf only)</small>:</label> <input type="hidden" value="<?php echo $txtAuthorityStatus; ?>" id="txtAuthorityUpload" name="txtAuthorityUpload"> <input type="hidden" value="<?php echo $txtPANFileName; ?>" name="txtPANFileName"> <input type="file" value="" id="panFile" name="panFile" class="browse-o" onchange="ValidateFileUpload('panFile','txtAuthorityUpload','authorityUploadStatus')"> <button type="button" class="browse-d">Browse</button> <!--<input type="button" value="Upload" class="uploadBtn" onclick="validatePDF(3,'panFile','authorityUploadStatus','txtAuthorityUpload')">--> <!-- <div id="authorityUploadStatus" class="divSuccess"><?php echo $authorityUploadStatus; ?></div> </div>--> <div class="col-md-12 removePadding "> <h3 class="subHead">Please upload a PAN <span class="star">*</span></h3> <div class="form-group" id="panAuthority"> <label class="col-md-3">Upload<br> <small>(upload pdf or image formats only)</small>:</label> <input type="hidden" value="<?php echo $txtAuthorityStatus; ?>" id="txtAuthorityUpload" name="txtAuthorityUpload"> <input type="hidden" value="<?php echo $txtPANFileName; ?>" name="txtPANFileName"> <input type="file" value="" id="panFile" name="panFile" class="browse-o" onchange="ValidateFileUpload('panFile','txtAuthorityUpload','authorityUploadStatus')"> <button type="button" class="browse-d">Browse</button> <!--<input type="button" value="Upload" class="uploadBtn" onclick="validatePDF(3,'panFile','authorityUploadStatus','txtAuthorityUpload')">--> <div id="authorityUploadStatus" class="divSuccess"><?php echo $authorityUploadStatus; ?></div> </div> <div class="form-group"> <label class="col-md-3" for="pan">PAN Number <span class="star">*</span></label> <div class="col-md-6"> <input type="text" name="pan" value="<?php echo $pan; ?>" id="pan" maxlength="10"> </div> </div> </div> </section> <div class="text-center col-md-12"> <a href="page1.php"><input type="button" value="Back" class="btn btn-cs"></a> <input type="submit" value="Next" class="btn btn-cs"> </div> <div class="col-md-12 text-right">2 of 6</div> </div><!--end formContainer--> </form> </div> </div> </div> <?php include"footer.php"?> <script type='text/javascript'> pdfFlag = 0; $(document).ready(function() { var fcra1 = '<?php echo $isFCRA1; ?>'; //var pan1 = '<?php echo $isPAN1; ?>'; if(fcra1 == '') { document.getElementById('regulationAct').style.display = "none"; } else { document.getElementById('regulationAct').style.display = "block"; } /* if(pan1 == '') { document.getElementById('panAuthority').style.display = "none"; } else { document.getElementById('panAuthority').style.display = "block"; }*/ $('.input-group.date').datepicker({ calendarWeeks: true, todayHighlight: true, autoclose: true, format:"dd/mm/yyyy" }); $(".browse-d").click(function(){ $(this).parents(".form-group").find('.browse-o').click(); //$(".browse-o").closest(".form-group"); }); //var max_fields = ; //maximum input boxes allowed var wrapper1 = $(".input_fields_wrapOPerations"); //Fields wrapper var add_button1 = $(".addBtn1"); //Add button ID var x1 = '<?php echo $operationsCount; ?>'; //initlal text box count $(add_button1).click(function(e) { /*address = document.getElementById('address'+x1); state = document.getElementById('state'+x1).value; district = document.getElementById('district'+x1).value; totalBoardMembers = document.getElementById('totalBoardMembers'+x1); totalStaff = document.getElementById('totalStaff'+x1);*/ //on add input button click addressLength = document.getElementsByName('address[]').length; //alert(addressLength); for(i=0;i<addressLength;i++) { address = document.getElementsByName('address[]'); state = document.getElementsByName('state[]'); district = document.getElementsByName('district[]'); totalBoardMembers = document.getElementsByName('totalBoardMembers[]'); totalStaff = document.getElementsByName('totalStaff[]'); if(address[i].value.trim() != "" && state[i].value.trim() != 0 && district[i].value.trim() != 0 && totalStaff[i].value.trim() != "") { flag = 1; } else { flag = 0; break; } } if(flag == 1) { //on add input button click e.preventDefault(); // if(x < max_fields){ //max input box allowed x1++; //text box increment $(wrapper1).prepend('<div class="tr" style="margin-bottom:50px;"><a class="action2"><i class="fa fa-trash remove_field1 pull-right" aria-hidden="true" ></i></a><div class="form-group"><label class="col-md-3" for="address">Address</label><div class=""><input type="hidden" name="operationID[]" id="operationID'+x1+'" value=""><input type="text" name="address[]" id="address'+x1+'" placeholder="H.no,Street Name" class="col-md-4"></div></div><div class="form-group"><label class="col-md-3" for="state" >State</label><div class=""><select name="state[]" id="state'+x1+'" class="col-md-4" onchange="getDistricts(this.value,'+x1+')"><option value="0">Select State</option><?php echo $newStates; ?></select></div></div><div class="form-group"><label class="col-md-3" for="district">District</label><div class=""><select name="district[]" id="district'+x1+'" class="col-md-4"><option value="0">Select District</option></select></div></div><div class="form-group"><label class="col-md-3" for="address" >Total No.of Staff</label><div class=""><input type="text" name="totalStaff[]" id="totalStaff'+x1+'" placeholder="Total No.of Staff" class="col-md-4" onkeypress="return number(event)"></div></div></div>'); //add input box //} } else { alert("Please fill all fields first."); } }); $(wrapper1).on("click",".remove_field1", function(e){ //user click on remove text e.preventDefault(); $(this).closest('.tr').remove();x1--; }); var wrapper2 = $(".input_fields_wrap2"); var add_button2 = $(".addBtn2"); var x = '<?php echo $projectsCount; ?>'; $(add_button2).click(function(e) { /*projectName = document.getElementById('projectName'+x); funder = document.getElementById('funder'+x); startDate = document.getElementById('startDate'+x); endDate = document.getElementById('endDate'+x); activity = document.getElementById('activity'+x);*/ projectNameLength = document.getElementsByName('projectName[]').length; for(i=0;i<projectNameLength;i++) { projectName = document.getElementsByName('projectName[]'); funder = document.getElementsByName('funder[]'); startDate = document.getElementsByName('startDate[]'); endDate = document.getElementsByName('endDate[]'); activity = document.getElementsByName('activity[]'); if(projectName[i].value.trim() != "" && funder[i].value.trim() != 0 && startDate[i].value.trim() != 0 && endDate[i].value.trim() != "" && activity[i].value.trim() != "") { flag1 = 1; } else { flag1 = 0; break; } } if(flag1 == 1) { e.preventDefault(); // if(x < max_fields){ //max input box allowed x++; //text box increment $(wrapper2).append('<tr><td>'+x+'</td><td><input type="hidden" name="projectID[]" id="projectID'+x+'" value=""><input type="text" name="projectName[]" id="projectName'+x+'" placeholder="Previous Projects"></td><td><input type="text" name="funder[]" id="funder'+x+'" placeholder="Funder" /></td><td><div class="input-group date" ><input type="text" class="form-control" name="startDate[]" id="startDate'+x+'" placeholder="Period - Start Date" readonly /><span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span></div> </td><td><div class="input-group date" ><input type="text" class="form-control" name="endDate[]" id="endDate'+x+'" placeholder="Period - End Date" /><span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span></div></td><td><input type="text" name="activity[]" id="activity'+x+'" placeholder="Activity"></td><td><a class="action2"><i class="fa fa-trash remove_field2" aria-hidden="true" ></i></a></td></tr>'); //add input box //} $('.input-group.date').datepicker( { calendarWeeks: true, todayHighlight: true, autoclose: true, format:"dd/mm/yyyy" }); } else { alert("Please fill all fields first."); } }); $(wrapper2).on("click",".remove_field2", function(e){ //user click on remove text e.preventDefault(); $(this).closest('tr').remove(); }) }); function getDistricts(stateID,i) { if(stateID == 0) { document.getElementById('district'+i).innerHTML = ""; document.getElementById('district'+i).innerHTML = '<option value="0">Select District</option>'; } else { $.post("app/ajax.php",{type:1,stateID:stateID},function(data) { document.getElementById('district'+i).innerHTML = '<option value="0">Select District</option>'+data; }); } } /* function number(e) { if(e.keyCode == 13 || (e.keyCode >= 48 && e.keyCode <= 57)) { return true; } else { return false; } } */ function number(e) { var key = e.keyCode || e.charCode; if(key == 13 || key == 43 || (key >= 48 && key <= 57) || key == 8 || key == 46) { //alert(); return true; } else { return false; } } function ValidateFileUpload(fileID,txtID,uploadStatusID) { pdfFlag = 0; var fuData = document.getElementById(fileID); var txtField = document.getElementById(txtID); var uploadStatus = document.getElementById(uploadStatusID); var FileUploadPath = fuData.value; //To check if user upload any file if (FileUploadPath == '') { alert("Please upload a pdf file or Image file."); uploadStatus.innerHTML = "<span class='fail'></span>"; txtField.value = 0; pdfFlag = 0; } else { var Extension = FileUploadPath.substring( FileUploadPath.lastIndexOf('.') + 1).toLowerCase(); //The file uploaded is an pdf if (Extension == "jpeg" || Extension == "jpg" || Extension == "png" || Extension == "pdf" ) { var size=1048576; var file_size=fuData.files[0].size; if(file_size>=size) { alert('File too large'); uploadStatus.innerHTML = "<span class='fail'></span>"; txtField.value = 0; pdfFlag = 0; } else { pdfFlag = 1; txtField.value = 1; uploadStatus.innerHTML = "<span class='success'></span>"; } } //The file upload is NOT an pdf else { alert("Please upload a pdf file or Image file."); uploadStatus.innerHTML = "<span class='fail'></span>"; txtField.value = 0; } } } function validatePDF(type,fileID,uploadStatusID,txtFieldID) { if(pdfFlag == 0) { alert('Please upload a valid file'); } else { var fuData = document.getElementById(fileID); var txtField = document.getElementById(txtFieldID); var fd = new FormData(); fd.append('userFile',$('#'+fileID)[0].files[0]); fd.append('type',type); $.ajax({ url: 'app/ajax.php', data: fd, processData: false, contentType: false, type: 'POST', success: function(data) { if(data == -4) { alert('Unable to upload deeds declarion file.'); } else if(data == -3) { alert('Error!!! Unable to save deed details. Internal server error.'); } else { alert('Data saved successfully.'); txtField.value = 1; document.getElementById(uploadStatusID).innerHTML = "<span class='success'></span>"; //location.reload(); } } }); } } function validatePage2() { state = document.getElementById('state1').value; district = document.getElementById('district1').value; fcraYes = document.getElementById('fcraYes'); FCRADetails = document.getElementById('FCRADetails'); FCRAFile = document.getElementById('FCRAFile'); txtFCRAUpload = document.getElementById('txtFCRAUpload'); txtAuthorityUpload = document.getElementById('txtAuthorityUpload'); pan = document.getElementById('pan'); var regEmail = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/; var regpan = /^([a-zA-Z]){5}([0-9]){4}([a-zA-Z]){1}?$/; if(state == 0) { alert("Please select state."); return false; } if(district == 0) { alert("Please select district."); return false; } if(fcraYes.checked == true) { if(FCRADetails.value.trim() == "") { alert("Please enter FCRA details.") return false; } if(txtFCRAUpload.value == 0) { alert("Please upload FCRA file.") return false; } } //if(panYes.checked == true) //{ if(txtAuthorityUpload.value == 0) { alert("Please upload PAN file.") return false; } if(pan.value.trim() == '') { alert("Please enter PAN."); pan.value = ""; pan.focus(); return false; } if(regpan.test(pan.value) == false) { alert("Invalid PAN. Please enter valid PAN."); pan.value = ""; pan.focus(); return false; } //} return true; } function displayAct(type) { if(type == 0) { document.getElementById('regulationAct').style.display = "none"; /*document.getElementById('FCRADetails').value = ""; document.getElementById('FCRAUploadStatus').innerHTML = ""; document.getElementById('FCRAFile').value = ""; document.getElementById('txtFCRAUpload').value = 0;*/ } else { document.getElementById('regulationAct').style.display = "block"; } } function displayAuthority(type) { if(type == 0) { document.getElementById('panAuthority').style.display = "none"; /*document.getElementById('panFile').value = ""; document.getElementById('authorityUploadStatus').innerHTML = ""; document.getElementById('txtAuthorityUpload').value = 0;*/ } else { document.getElementById('panAuthority').style.display = "block"; } } </script>