JezK
Edit File: editstaff.php
<?php $currentPage="staff"; include("header.php"); $staffID = isset($_REQUEST['id'])?$_REQUEST['id']:""; if($staffID != "") { $_SESSION['staffID'] = $staffID; include('app/getStaffDetails.php'); //checking if it is editable staff or not if($approved != 4) //not editable staff { echo "<script>location.replace('staff.php')</script>"; } include("app/getBDCDistrictsListApp.php"); } else { echo "<script>location.replace('staff.php')</script>"; } if(isset($_SESSION['saveSuccess'])) { echo "<script>alert('Staff details saved successfully.')</script>"; unset($_SESSION['saveSuccess']); } if(isset($_SESSION['saveFailed'])) { echo "<script>alert('Error!!! Unable to confrim staff details. Internal server error.')</script>"; unset($_SESSION['saveFailed']); } ?> <div id="page-wrapper"> <form enctype="multipart/form-data" action="app/addStaffApp.php" onsubmit="return validate()" method="post"> <div class="container-fluid"> <!-- Page Heading --> <div class="row"> <div class="col-lg-12"> <h1 class="page-header"> <small>Add Staff</small> </h1> </div> </div> <!-- /.row --> <div class="row" > <div class="col-md-12"> <div class="form-group row"> <input type="hidden" name="staffID" value="<?php echo $staffID; ?>"> <label class="col-md-2">Staff ID</label> <input type="tex" class="cs-textfield col-md-4" placeholder="" name="staffNumber" id="staffNumber" value="<?php echo $staffNumber; ?>" autofocus> </div> <div class="form-group row"> <label class="col-md-2">Staff Full Name</label> <input type="tex" class="cs-textfield col-md-4" placeholder="" name="staffName" id="staffName" value="<?php echo $staffName; ?>" autofocus> </div> <div class="form-group row"> <label class="col-md-2">District Name</label> <select name="districtName"> <?php echo $districts; ?> </select> <!--input type="tex" class="cs-textfield col-md-4" placeholder="" name="districtName" id="districtName" value="<?php echo $districtName; ?>"--> </div> <div class="form-group row"> <label class="col-md-2">Designation</label> <input type="tex" class="cs-textfield col-md-4" placeholder="" name="designation" id="designation" value="<?php echo $designation; ?>"> </div> <div class="form-group row" > <label class="col-md-2">Date of Birth</label> <div class="input-group date col-md-4" > <input type="text" class="form-control" name="dateOfBirth" id="dateOfBirth" placeholder="" value="<?php echo $dateOfBirth; ?>" style="border-radius: 9px 0px 0px 9px !important;"> <span class="input-group-addon"> <span class="glyphicon glyphicon-calendar"></span> </span> </div> </div> <div class="form-group row"> <label class="col-md-2">Gender</label> <input type="radio" name="gender" value="1" id="male" <?php echo $genderMale; ?>> <label for="male" style="color:black;font-weight:normal;cursor:pointer;">Male</label> <input type="radio" name="gender" value="2" id="female" <?php echo $genderFemale; ?>> <label for="female" style="color:black;font-weight:normal;cursor:pointer;">Female</label> </div> <div class="form-group row"> <label class="col-md-2">Android Mobile</label> <input type="radio" name="androidMobile" value="1" id="yes" <?php echo $androidMobileYes; ?> onchange="displayDetails('block')"> <label for="yes" style="color:black;font-weight:normal;cursor:pointer;">Yes</label> <input type="radio" name="androidMobile" value="0" id="no" <?php echo $androidMobileNo; ?> onchange="displayDetails('none')"> <label for="no" style="color:black;font-weight:normal;cursor:pointer;">No</label> </div> <div id="mobileDetails"> <div class="form-group row"> <label class="col-md-2">IMEI</label> <input type="tex" class="cs-textfield col-md-4" placeholder="" maxlength="15" name="IMEI" id="IMEI" value="<?php echo $IMEI; ?>" onkeypress="return number(event)"> </div> <div class="form-group row"> <label class="col-md-2">Mobile Brand</label> <input type="tex" class="cs-textfield col-md-4" placeholder="" name="brand" id="brand" value="<?php echo $brand; ?>"> </div> <div class="form-group row"> <label class="col-md-2">Model Number</label> <input type="tex" class="cs-textfield col-md-4" placeholder="" name="modelNumber" id="modelNumber" value="<?php echo $modelNumber; ?>"> </div> <div class="form-group row"> <label class="col-md-2">Android Version</label> <input type="tex" class="cs-textfield col-md-4" placeholder="" name="version" id="version" value="<?php echo $version; ?>"> </div> <div class="form-group row"> <label class="col-md-2">RAM in Mobile</label> <input type="tex" class="cs-textfield col-md-4" placeholder="" name="ram" id="ram" value="<?php echo $ram; ?>"> </div> <div class="form-group row"> <label class="col-md-2">ROM in Mobile</label> <input type="tex" class="cs-textfield col-md-4" placeholder="" name="rom" id="rom" value="<?php echo $rom; ?>"> </div> </div> <div class="form-group row"> <label class="col-md-2">Access Required</label> <input type="radio" name="accessRequired" value="1" id="insurance" <?php echo $insuranceOnly; ?>> <label for="insurance" style="color:black;font-weight:normal;cursor:pointer;">Insurance Only</label> <input type="radio" name="accessRequired" value="2" id="insuranceAndCms" <?php echo $insuranceAndCMS; ?>> <label for="insuranceAndCms" style="color:black;font-weight:normal;cursor:pointer;">Insurance and CMS</label> </div> <div class="form-group row"> <label class="col-md-2">Upload Photo</label> <input type="hidden" value="<?php echo $photoStatus; ?>" id="photoStatus"> <input type="hidden" value="<?php echo $photo; ?>" name="photoFile"> <input type="file" placeholder="" name="photo" id="photo" value="" style="display:inline-block;" onchange="ValidateFileUpload('photo','photoStatus','photoUploadStatus')"> <div id="photoUploadStatus" style="display:inline-block;" class="divSuccess"><?php echo $photoUploadStatus; ?></div> </div> <div class="form-group row"> <label class="col-md-2">Upload KYC</label> <input type="hidden" value="<?php echo $KYCStatus; ?>" id="KYCStatus"> <input type="hidden" value="<?php echo $KYC; ?>" name="KYCFile"> <input type="file" placeholder="" name="KYC" id="KYC" value="" onchange="ValidateFileUpload('KYC','KYCStatus','KYCUploadStatus')" style="display:inline-block;"> <div id="KYCUploadStatus" class="divSuccess" style="display:inline-block;"><?php echo $KYCUploadStatus; ?></div> </div> <div class="col-md-12 text-center"> <input type="submit" value="Save" name="submit" id="submit" class="btn btn-cs"> </div> </div> </div> <!-- /.row --> </div> <!-- /.container-fluid --> </form> </div> <!-- /#page-wrapper --> <script> $('.input-group.date').datepicker( { calendarWeeks: true, todayHighlight: true, autoclose: true, format:"dd/mm/yyyy", orientation:'bottom' }); $(document).ready(function() { var androidMobileValue = '<?php echo $androidMobileValue; ?>'; var status = (androidMobileValue == 1)?"block":"none"; displayDetails(status); }); function displayDetails(status) { document.getElementById('mobileDetails').style.display = status; } function ValidateFileUpload(id,fileStatus,uploadStatus) { photoFlag = 0; var photo = document.getElementById(id); var fileStatus = document.getElementById(fileStatus); var photoUploadStatus = document.getElementById(uploadStatus); var FileUploadPath = photo.value; //To check if user upload any file if (FileUploadPath == '') { alert("Please upload a image."); fileStatus.value = 0; photoFlag = 0; } else { var Extension = FileUploadPath.substring( FileUploadPath.lastIndexOf('.') + 1).toLowerCase(); //The file uploaded is an pdf if(Extension == "jpg" || Extension == "jpeg" || Extension == "png") { var size=1048576; var file_size=photo.files[0].size; if(file_size>=size) { alert('File too large'); photoUploadStatus.innerHTML = "<span class='fail'></span>"; fileStatus.value = 0; photoFlag = 0; } else { photoUploadStatus.innerHTML = "<span class='success'></span>"; photoFlag = 1; fileStatus.value = 1; } } //The file upload is NOT an pdf else { alert("Please upload a image."); photoUploadStatus.innerHTML = "<span class='fail'></span>"; fileStatus.value = 0; } } } function number(e) { 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() { var staffName = document.getElementById('staffName'); var districtName = document.getElementById('districtName'); var designation = document.getElementById('designation'); var dateOfBirth = document.getElementById('dateOfBirth'); var male = document.getElementById('male'); var female = document.getElementById('female'); var yes = document.getElementById('yes'); var no = document.getElementById('no'); var IMEI = document.getElementById('IMEI'); var brand = document.getElementById('brand'); var modelNumber = document.getElementById('modelNumber'); var version = document.getElementById('version'); var ram = document.getElementById('ram'); var rom = document.getElementById('rom'); var photoStatus = document.getElementById('photoStatus'); var KYCStatus = document.getElementById('KYCStatus'); var insurance = document.getElementById('insurance'); var insuranceAndCms = document.getElementById('insuranceAndCms'); if(staffName.value.trim() == '') { alert("Please enter staff name."); staffName.focus(); return false; } if(districtName.value.trim() == '') { alert("Please enter district name."); districtName.focus(); return false; } if(designation.value.trim() == '') { alert("Please enter designation."); designation.focus(); return false; } if(dateOfBirth.value.trim() == '') { alert("Please enter date of birth."); dateOfBirth.focus(); return false; } if(male.checked == false && female.checked == false) { alert("Please select gender."); male.focus(); return false; } if(yes.checked == false && no.checked == false) { alert("Please select android mobile is available or not?."); yes.focus(); return false; } if(yes.checked == true) { if(IMEI.value.trim() == '') { alert("Please enter IMEI."); IMEI.focus(); return false; } if(brand.value.trim() == '') { alert("Please enter mobile brand."); brand.focus(); return false; } if(modelNumber.value.trim() == '') { alert("Please enter model number."); modelNumber.focus(); return false; } if(version.value.trim() == '') { alert("Please enter version."); version.focus(); return false; } if(ram.value.trim() == '') { alert("Please enter RAM."); ram.focus(); return false; } if(rom.value.trim() == '') { alert("Please enter ROM."); rom.focus(); return false; } } if(insurance.checked == false && insuranceAndCms.checked == false) { alert("Please select access required."); insurance.focus(); return false; } if(photoStatus.value == '0') { alert("Please upload a photo."); photo.focus(); return false; } if(KYCStatus.value == '0') { alert("Please upload KYC."); KYC.focus(); return false; } return true; } </script> <?php include("footer.php");?>