File manager - Edit - /home/autoph/tmp/public_html/pms_v1/pcpDocuments/pcpLoadEmployeeListBAK.php
Back
<?php include_once("../../../cfg/conn.php"); include ("../functions/users.php"); //error_reporting(0); if(isset($_POST['pmsAction'])){ $infCanvass = $_POST['infCanvass']; $start = $_POST['start']; $limit = $_POST['limit']; $activeFilter = $_POST['activeFilter']; $userID = $_POST['userID']; $accessLevel =""; //DROP EXISTIN TABLE AND CREATE EMPTY TEMP. TABLE $dropT = "DROP TABLE IF EXISTS `tempMaRViews`"; if ($conn->query($dropT) === TRUE) { } else { } //create temp. table if not exist $sql = "CREATE TABLE IF NOT EXISTS `tempMaRViews` ( `id` int(11) NOT NULL AUTO_INCREMENT, `emp_rec_id` int(11) NOT NULL, `emp_id` int(11) NOT NULL, `comp_code` varchar(15) NOT NULL, `branch_code` varchar(15) NOT NULL, `first_name` varchar(30) NOT NULL, `last_name` varchar(30) NOT NULL, `position` varchar(30) NOT NULL, `owner_id` varchar(30) NOT NULL, PRIMARY KEY (`id`))"; if ($conn->query($sql) === TRUE) { $sqlMessage = "Table has been created: <br>"; } else { $sqlMessage = "Error: " . $sql . "<br>" . $conn->error; } $myKingdom = "SELECT * FROM `approver_setup` WHERE `approver_id`='$userID' ORDER BY `id` ASC"; $qKing = mysqli_query($conn,$myKingdom); while($km = mysqli_fetch_array($qKing)){ $myLevel = $km['level']; $activeUnitID = $km['unit_id']; switch($myLevel){ case 'EMPL': if($infCanvass!=''){ $getEmp = "SELECT * FROM `pms_employee_data` WHERE `id`='$activeUnitID' AND deleted=0 AND `last_name` like '%$infCanvass%' || `id`='$activeUnitID' AND deleted=0 AND `first_name` like '%$infCanvass%' || `id`='$activeUnitID' AND deleted=0 AND `emp_id` like '%$infCanvass%'"; }else{ $getEmp = "SELECT * FROM `pms_employee_data` WHERE `id`='$activeUnitID' AND deleted=0 || `id`='$userID' AND deleted=0 "; } $qEmp = mysqli_query($conn,$getEmp); while($sec = mysqli_fetch_array($qEmp)){ $empRecID = $sec['id']; $empEmpNo = $sec['emp_id']; $compID = $sec['comp_id']; $branchID = $sec['branch_id']; $empFName = $sec['first_name']; $empLName = $sec['last_name']; $empPosition = $sec['position']; //insert record to temp. table for later viewing $checkIFrecordExist = "SELECT * FROM tempMaRViews WHERE emp_rec_id='$empRecID'"; $qcheckIFrecordExist = mysqli_query($conn,$checkIFrecordExist); $existCount = mysqli_num_rows($qcheckIFrecordExist); if($existCount > 0){ }else{ $sql = "INSERT INTO tempMaRViews (`id`, `emp_rec_id`, `emp_id`,`comp_code`,`branch_code`,`first_name`,`last_name`,`position`,`owner_id`) VALUES ('', '$empRecID', '$empEmpNo','$compID','$branchID','$empFName','$empLName','$empPosition','$userID')"; if ($conn->query($sql) === TRUE) { //echo "New record created successfully"; } else { //echo "Error: " . $sql . "<br>" . $conn->error; } } } break; case 'SECT': if($infCanvass!=''){ $getEmp = "SELECT * FROM `pms_employee_data` WHERE `unit_id`='$activeUnitID' AND deleted=0 AND `last_name` like '%$infCanvass%' || `unit_id`='$activeUnitID' AND deleted=0 AND `first_name` like '%$infCanvass%' || `unit_id`='$activeUnitID' AND deleted=0 AND `emp_id` like '%$infCanvass%'"; }else{ $getEmp = "SELECT * FROM `pms_employee_data` WHERE `unit_id`='$activeUnitID' AND deleted=0 || `id`='$userID' AND deleted=0 "; } $qEmp = mysqli_query($conn,$getEmp); while($sec = mysqli_fetch_array($qEmp)){ $empRecID = $sec['id']; $empEmpNo = $sec['emp_id']; $compID = $sec['comp_id']; $branchID = $sec['branch_id']; $empFName = $sec['first_name']; $empLName = $sec['last_name']; $empPosition = $sec['position']; //insert record to temp. table for later viewing $checkIFrecordExist = "SELECT * FROM tempMaRViews WHERE emp_rec_id='$empRecID'"; $qcheckIFrecordExist = mysqli_query($conn,$checkIFrecordExist); $existCount = mysqli_num_rows($qcheckIFrecordExist); if($existCount > 0){ }else{ $sql = "INSERT INTO tempMaRViews (`id`, `emp_rec_id`, `emp_id`,`comp_code`,`branch_code`,`first_name`,`last_name`,`position`,`owner_id`) VALUES ('', '$empRecID', '$empEmpNo','$compID','$branchID','$empFName','$empLName','$empPosition','$userID')"; if ($conn->query($sql) === TRUE) { //echo "New record created successfully"; } else { //echo "Error: " . $sql . "<br>" . $conn->error; } } } break; case 'DEPT': if($infCanvass!=''){ $getEmp = "SELECT * FROM `pms_employee_data` WHERE `department_id`='$activeUnitID' AND deleted=0 AND `last_name` like '%$infCanvass%' || `department_id`='$activeUnitID' AND deleted=0 AND `first_name` like '%$infCanvass%' || `department_id`='$activeUnitID' AND deleted=0 AND `emp_id` like '%$infCanvass%'"; }else{ $getEmp = "SELECT * FROM `pms_employee_data` WHERE `department_id`='$activeUnitID' AND deleted=0 || `id`='$userID' AND deleted=0 "; } $qEmp = mysqli_query($conn,$getEmp); while($dep = mysqli_fetch_array($qEmp)){ $empRecID = $dep['id']; $empEmpNo = $dep['emp_id']; $compID = $dep['comp_id']; $branchID = $dep['branch_id']; $empFName = $dep['first_name']; $empLName = $dep['last_name']; $empPosition = $dep['position']; //insert record to temp. table for later viewing $checkIFrecordExist = "SELECT * FROM tempMaRViews WHERE emp_rec_id='$empRecID'"; $qcheckIFrecordExist = mysqli_query($conn,$checkIFrecordExist); $existCount = mysqli_num_rows($qcheckIFrecordExist); if($existCount > 0){ }else{ $sql = "INSERT INTO tempMaRViews (`id`, `emp_rec_id`, `emp_id`,`comp_code`,`branch_code`,`first_name`,`last_name`,`position`,`owner_id`) VALUES ('', '$empRecID', '$empEmpNo','$compID','$branchID','$empFName','$empLName','$empPosition','$userID')"; if ($conn->query($sql) === TRUE) { //echo "New record created successfully"; } else { //echo "Error: " . $sql . "<br>" . $conn->error; } } } break; case 'DIVM': if($infCanvass!=''){ $getEmp = "SELECT * FROM `pms_employee_data` WHERE `division_id`='$activeUnitID' AND deleted=0 AND `last_name` like '%$infCanvass%' || `division_id`='$activeUnitID' AND deleted=0 AND `first_name` like '%$infCanvass%' || `division_id`='$activeUnitID' AND deleted=0 AND `emp_id` like '%$infCanvass%'"; }else{ $getEmp = "SELECT * FROM `pms_employee_data` WHERE `division_id`='$activeUnitID' AND deleted=0 || `id`='$userID' AND deleted=0 "; } $qEmp = mysqli_query($conn,$getEmp); while($dep = mysqli_fetch_array($qEmp)){ $empRecID = $dep['id']; $empEmpNo = $dep['emp_id']; $compID = $dep['comp_id']; $branchID = $dep['branch_id']; $empFName = $dep['first_name']; $empLName = $dep['last_name']; $empPosition = $dep['position']; //insert record to temp. table for later viewing $checkIFrecordExist = "SELECT * FROM tempMaRViews WHERE emp_rec_id='$empRecID'"; $qcheckIFrecordExist = mysqli_query($conn,$checkIFrecordExist); $existCount = mysqli_num_rows($qcheckIFrecordExist); if($existCount > 0){ }else{ $sql = "INSERT INTO tempMaRViews (`id`, `emp_rec_id`, `emp_id`,`comp_code`,`branch_code`,`first_name`,`last_name`,`position`,`owner_id`) VALUES ('', '$empRecID', '$empEmpNo','$compID','$branchID','$empFName','$empLName','$empPosition','$userID')"; if ($conn->query($sql) === TRUE) { //echo "New record created successfully"; } else { //echo "Error: " . $sql . "<br>" . $conn->error; } } } break; case 'SUBG': if($infCanvass!=''){ $getEmp = "SELECT * FROM `pms_employee_data` WHERE `sub_group_id`='$activeUnitID' AND deleted=0 AND `last_name` like '%$infCanvass%' || `sub_group_id`='$activeUnitID' AND deleted=0 AND `first_name` like '%$infCanvass%' || `sub_group_id`='$activeUnitID' AND deleted=0 AND `emp_id` like '%$infCanvass%'"; }else{ $getEmp = "SELECT * FROM `pms_employee_data` WHERE `sub_group_id`='$activeUnitID' AND deleted=0 || `id`='$userID' AND deleted=0 "; } $qEmp = mysqli_query($conn,$getEmp); while($dep = mysqli_fetch_array($qEmp)){ $empRecID = $dep['id']; $empEmpNo = $dep['emp_id']; $compID = $dep['comp_id']; $branchID = $dep['branch_id']; $empFName = $dep['first_name']; $empLName = $dep['last_name']; $empPosition = $dep['position']; //insert record to temp. table for later viewing $checkIFrecordExist = "SELECT * FROM tempMaRViews WHERE emp_rec_id='$empRecID'"; $qcheckIFrecordExist = mysqli_query($conn,$checkIFrecordExist); $existCount = mysqli_num_rows($qcheckIFrecordExist); if($existCount > 0){ }else{ $sql = "INSERT INTO tempMaRViews (`id`, `emp_rec_id`, `emp_id`,`comp_code`,`branch_code`,`first_name`,`last_name`,`position`,`owner_id`) VALUES ('', '$empRecID', '$empEmpNo','$compID','$branchID','$empFName','$empLName','$empPosition','$userID')"; if ($conn->query($sql) === TRUE) { //echo "New record created successfully"; } else { //echo "Error: " . $sql . "<br>" . $conn->error; } } } break; case 'DEAL': if($infCanvass!=''){ $getEmp = "SELECT * FROM `pms_employee_data` WHERE `branch_id`='$activeUnitID' AND deleted=0 AND `last_name` like '%$infCanvass%' || `branch_id`='$activeUnitID' AND deleted=0 AND `first_name` like '%$infCanvass%' || `branch_id`='$activeUnitID' AND deleted=0 AND `emp_id` like '%$infCanvass%'"; }else{ $getEmp = "SELECT * FROM `pms_employee_data` WHERE `branch_id`='$activeUnitID' AND deleted=0 || `id`='$userID' AND deleted=0 "; } $qEmp = mysqli_query($conn,$getEmp); while($dep = mysqli_fetch_array($qEmp)){ $empRecID = $dep['id']; $empEmpNo = $dep['emp_id']; $compID = $dep['comp_id']; $branchID = $dep['branch_id']; $empFName = $dep['first_name']; $empLName = $dep['last_name']; $empPosition = $dep['position']; //insert record to temp. table for later viewing $checkIFrecordExist = "SELECT * FROM tempMaRViews WHERE emp_rec_id='$empRecID'"; $qcheckIFrecordExist = mysqli_query($conn,$checkIFrecordExist); $existCount = mysqli_num_rows($qcheckIFrecordExist); if($existCount > 0){ }else{ $sql = "INSERT INTO tempMaRViews (`id`, `emp_rec_id`, `emp_id`,`comp_code`,`branch_code`,`first_name`,`last_name`,`position`,`owner_id`) VALUES ('', '$empRecID', '$empEmpNo','$compID','$branchID','$empFName','$empLName','$empPosition','$userID')"; if ($conn->query($sql) === TRUE) { //echo "New record created successfully"; } else { //echo "Error: " . $sql . "<br>" . $conn->error; } } } break; case 'COMP': if($infCanvass!=''){ $getEmp = "SELECT * FROM `pms_employee_data` WHERE `comp_id`='$activeUnitID' AND deleted=0 AND `last_name` like '%$infCanvass%' || `comp_id`='$activeUnitID' AND deleted=0 AND `first_name` like '%$infCanvass%' || `comp_id`='$activeUnitID' AND deleted=0 AND `emp_id` like '%$infCanvass%'"; }else{ $getEmp = "SELECT * FROM `pms_employee_data` WHERE `comp_id`='$activeUnitID' AND deleted=0 || `id`='$userID' AND deleted=0 "; } $qEmp = mysqli_query($conn,$getEmp); while($dep = mysqli_fetch_array($qEmp)){ $empRecID = $dep['id']; $empEmpNo = $dep['emp_id']; $compID = $dep['comp_id']; $branchID = $dep['branch_id']; $empFName = $dep['first_name']; $empLName = $dep['last_name']; $empPosition = $dep['position']; //insert record to temp. table for later viewing $checkIFrecordExist = "SELECT * FROM tempMaRViews WHERE emp_rec_id='$empRecID'"; $qcheckIFrecordExist = mysqli_query($conn,$checkIFrecordExist); $existCount = mysqli_num_rows($qcheckIFrecordExist); if($existCount > 0){ }else{ $sql = "INSERT INTO tempMaRViews (`id`, `emp_rec_id`, `emp_id`,`comp_code`,`branch_code`,`first_name`,`last_name`,`position`,`owner_id`) VALUES ('', '$empRecID', '$empEmpNo','$compID','$branchID','$empFName','$empLName','$empPosition','$userID')"; if ($conn->query($sql) === TRUE) { //echo "New record created successfully"; } else { //echo "Error: " . $sql . "<br>" . $conn->error; } } } break; } } //getAccess Level from Approver table so we need to load data under his/her level of authority //getInfo(this) //getInfo(this) $getMyProfile = "SELECT * FROM `tempMaRViews` WHERE `owner_id`='$userID' ORDER BY `last_name` ASC LIMIT $start, $limit"; $getMyPro = mysqli_query($conn,$getMyProfile); while($row = mysqli_fetch_array($getMyPro)){ $myDealID = $row['branch_code']; $myCompID = $row['comp_code']; $posID = $row['position']; ?><tr onclick="javascript:getInfo(this);"><?php echo "<td class='text-dark' style='width:5%'>".$row['emp_rec_id']."</td>"; echo "<td class='text-dark'style='width:8%'>".$row['emp_id']."</td>"; echo "<td class='text-dark'style='width:8%'>"; if($myCompID !=0){ echo getCompanyNameSub($myCompID)[1]; } echo "</td>"; echo "<td class='text-dark'style='width:8%'>"; if($myDealID !=0){ echo getDealerNameSub($myDealID)[1]; } echo "</td>"; echo "<td class='text-dark'style='width:23%'>".$row['first_name']."</td>"; echo "<td class='text-dark'style='width:23%'>".$row['last_name']."</td>"; echo "<td class='text-dark'style='width:16%'>"; if($posID !=0){ echo getPositionName($posID)[0]; } echo "</td>"; echo "<td style='width:3%'>";?> <!--<abbr title='View KRA'><i class='fa fa-plus-circle' aria-hidden='true' style='cursor:pointer;color:green;float:right;font-size:18px'></i> </abbr>--> <i data-toggle="modal" data-target="#kraModal" class="fa fa-ellipsis-h" style='cursor:pointer;color:green;float:right;font-size:14px'></i> <?php echo "</td>"; echo "<td style='width:2%'>";?> <!--<abbr title='View KRA'><i class='fa fa-plus-circle' aria-hidden='true' style='cursor:pointer;color:green;float:right;font-size:18px'></i> </abbr>--> <i data-toggle="modal" data-target="#editPMSModal" class="fa fa-pencil" style='cursor:pointer;color:green;float:right;font-size:14px'></i> <?php echo "</td>"; echo "<td style='width:3%'> <abbr title='Delete record'><i class='fa fa-trash ' aria-hidden='true' style='color:#FF0800;float:left;font-size:14px'></i></abbr> </td>"; echo "</tr>"; } $conn->close(); } ?>
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0.05 |
proxy
|
phpinfo
|
Settings