Warning: file_get_contents(https://raw.githubusercontent.com/Den1xxx/Filemanager/master/languages/ru.json): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 88
Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 215
Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 216
Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 217
Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 218
Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 219
Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 220
load->helper("url");
$this->load->library("pagination");
require_once APPPATH."/third_party/PHPExcel.php";
if($this->session->userdata('type')){
if($this->session->userdata('type') == 'officer'){
$this->session->set_flashdata('flash_data', 'You don\'t have access!');
redirect('Officer');
}
}else{
redirect('login');
}
}
public function index(){
$this->load->view('includes/header');
$this->load->view('pages/dashboard');
$this->load->view('includes/footer');
}
public function registerOfficers(){
$msg = 'Record already exist. ';
$rankId = $this->input->post('currentRankId');
$unit = $this->input->post('unit');
foreach($this->db->where('id',$rankId)->get("ranksType")->result() as $r){
$ranklevel = $r->level;
}
$uploadedStatus = 0;
if ( isset($_POST["Submit"]) ) {
if (isset($_FILES["file"])) {
//if there was an error uploading the file
if ($_FILES["file"]["error"] > 0) {
echo "Return Code: " . $_FILES["file"]["error"] . "
";
}
else {
if (file_exists($_FILES["file"]["name"])) {
unlink($_FILES["file"]["name"]);
}
$storagename = "./application/views/Excelsheets/".$rankId.'.xlsx';
move_uploaded_file($_FILES["file"]["tmp_name"], $storagename);
$uploadedStatus = 1;
}
} else {
echo "No file selected
";
}
}
$inputFileName = "./application/views/Excelsheets/".$rankId.'.xlsx';
try {
/// it will be your file name that you are posting with a form or can pass static name $_FILES["file"]["name"];
$objPHPExcel = PHPExcel_IOFactory::load($inputFileName);
}
catch(Exception $e) {
die('Error loading file "'.pathinfo($inputFileName,PATHINFO_BASENAME).'": '.$e->getMessage());
}
$data = array();
$data2 = array();
$valid_officer = 0;
$totalrows=$objPHPExcel->setActiveSheetIndex(0)->getHighestRow();
$objWorksheet=$objPHPExcel->setActiveSheetIndex(0);
$allDataInSheet = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
$invalid_gender=0;
$invalid_type=0;
$name = " ";
$data_saved=0;
$j=0;
for ($i=1; $i < $totalrows+1; $i++) {
$first_name = str_replace(" ","",$allDataInSheet[$i]['B']);
$first_name = strtoupper($first_name);
$middle_name = str_replace(" ","",$allDataInSheet[$i]['C']);
$middle_name = strtoupper($middle_name);
$last_name = str_replace(" ","",$allDataInSheet[$i]['D']);
$last_name = strtoupper($last_name);
$unique_number = str_replace(" ","",$allDataInSheet[$i]['A']);
$unique_number = strtoupper($unique_number);
$title_gender = str_replace(" ","",$allDataInSheet[$i]['F']);
$title_gender = strtoupper($title_gender);
if($first_name != "FIRSTNAME" || $middle_name != "MIDDLENAME" || $last_name != "LASTNAME" || $unique_number != "UNIQUENUMBER" || $title_gender != "GENDER"){
if(!is_null($allDataInSheet[$i]["J"])){
# do nothing, it is the supportde entry.
}else{
$j++;
$invalid_type++;
$name.="
".$j." ".$allDataInSheet[$i]["B"];
}
if(!is_null($allDataInSheet[$i]["F"]) || strtoupper(trim($allDataInSheet[$i]["F"])) == "F" || strtoupper(trim($allDataInSheet[$i]["F"])) == "M" || strtoupper(trim($allDataInSheet[$i]["B"])) == "FEMALE" || strtoupper(trim($allDataInSheet[$i]["B"])) == "MALE" ){
# do nothing, it is the supportde entry.
}else{
$j++;
$invalid_gender++;
$name.="
".$j." ".$allDataInSheet[$i]["B"];
}
}
$data_saved=0;#usiifute hii variable;
$A=strtoupper(str_replace(' ','',$allDataInSheet[1]['A']));
$B=strtoupper(str_replace(' ','',$allDataInSheet[1]['B']));
$C=strtoupper(str_replace(' ','',$allDataInSheet[1]['C']));
$D=strtoupper(str_replace(' ','',$allDataInSheet[1]['D']));
$E=strtoupper(str_replace(' ','',$allDataInSheet[1]['E']));
$F=strtoupper(str_replace(' ','',$allDataInSheet[1]['F']));
$G=strtoupper(str_replace(' ','',$allDataInSheet[1]['G']));
$H=strtoupper(str_replace(' ','',$allDataInSheet[1]['H']));
$I=strtoupper(str_replace(' ','',$allDataInSheet[1]['I']));
$J=strtoupper(str_replace(' ','',$allDataInSheet[1]['J']));
if($B != "FIRSTNAME" || $C != "MIDDLENAME" || $D != "LASTNAME" || $A != "UNIQUENUMBER" || $E != "PROMOTIONDATE(DD/MM/YYY)" || $F != "GENDER" || $G != "NIDA" || $H != "BIRTHDATE(DD/MM/YYY)" || $I != "PHONENUMBER" || $J != "EMAIL"){
redirect('admin/addPersonalDetails?format_error');
}else if($invalid_gender > 0 || $invalid_type > 0){
$b = base64_encode($name);
redirect('admin/addPersonalDetails/'.$invalid_type.'/'.$invalid_gender.'?err='.$b);
}else{
foreach($allDataInSheet as $import){
$first_name = str_replace(" ","",$allDataInSheet[$i]['B']);
$first_name = strtoupper($first_name);
$middle_name = str_replace(" ","",$allDataInSheet[$i]['C']);
$middle_name = strtoupper($middle_name);
$last_name = str_replace(" ","",$allDataInSheet[$i]['D']);
$last_name = strtoupper($last_name);
$unique_number = str_replace(" ","",$allDataInSheet[$i]['A']);
$unique_number = strtoupper($unique_number);
$title_gender = str_replace(" ","",$allDataInSheet[$i]['F']);
$title_gender = strtoupper($title_gender);
$A=str_replace("'","_",$import['A']);
$B=str_replace("'","_",$import['B']);
$C=str_replace("'","_",$import['C']);
$D=str_replace("'","_",$import['D']);
$E=str_replace("'","_",$import['E']);
$F=str_replace("'","_",$import['F']);
$G=str_replace("'","_",$import['G']);
$H=str_replace("'","_",$import['H']);
$I=str_replace("'","_",$import['I']);
$J=str_replace("'","_",$import['J']);
$rankLevel = $ranklevel;
$count = $this->db->where('uniqueNumber',$A)->count_all_results('personalDetails');
if($A == 'UNIQUE NUMBER' || $count>0){
}else{
//converting date of birth and promotion date
$dateString = trim($H);
$date = DateTime::createFromFormat('d/m/Y', $dateString);
if ($date !== false) {
$dateOfbirth = date('Y-m-d', $date->getTimestamp());
echo $dateOfbirth; // Output: 2002-10-20
} else {
echo ' Invalid birth date format' .$dateString ;
}
$dateString1 = trim($E);
$date1 = DateTime::createFromFormat('d/m/Y', $dateString1);
if ($date1 !== false) {
$promotionDate = date('Y-m-d', $date1->getTimestamp());
echo $promotionDate; // Output: 2002-10-20
} else {
echo ' Invalid promotion date format' .$dateString1;
}
//get unit brigade command ids
$exp = explode('-',$this->UserModel->getUnitIds($unit));
//dunping data to the database
$data = array(
'currentRankId' => $rankId,
'commandId'=>$exp[2],
'brigadeId'=>$exp[1],
'unit'=>$exp[0],
'uniqueNumber' => trim($A),
'firstName' => $B,
'middleName' => $C,
'lastName' => $D,
'email' => $J,
'phoneNumber' => $I,
'nida' => $G,
'dateOfbirth' => $dateOfbirth,
'gender' => $F,
'password' => md5($D),
'password1' => $D,
'date'=>date('Y-m-d'),
'registeredBy'=>$this->session->userdata('id'),
);
$this->db->insert('personalDetails',$data);
$userId = $this->db->insert_id();
$data2 = array(
'userId'=>$userId,
'rankId'=>$rankId,
'rankLevel'=>$rankLevel,
'promotionDate'=>trim($promotionDate),
'date'=>date('Y-m-d'),
);
$data_saved++;
$this->db->insert('officerRanks',$data2);
}
}
}
redirect('Admin/addPersonalDetails/?sent='.$data_saved);
}
}
}
?>