[ "dashboard-view" => "View Dashboard" ] ]; $array_permission2['visitor'] = [ "visitor" => [ "visitor-list-view" => "View Visitor" ] ] ; $array_permission2['hr'] = [ "staff-application" => [ "application-form-view" => "View Application Form", "application-form-new" => "New Application Form", "application-list-view" => "View Application List", "application-list-edit" => "Edit Application", "application-list-update" => "Update Status Application Form" ], "staff" => [ "staff-list-view" => "View Staff List", "staff-resign-list-view" => "View Staff Resign List", "staff-run-away-list-view" => "View Staff Run Away List", "staff-list-new" => "New Staff", "staff-list-edit" => "Edit Staff", "staff-list-update" => "Update Status Staff", "staff-list-trash" => "Trash Staff", "staff-adjustment-view" => "View Point Adjustment List", "staff-adjustment-new" => "New Point Adjustment", "staff-adjustment-wallet-view" => "View Wallet Adjustment List", "staff-adjustment-wallet-new" => "New Wallet Adjustment" ], "merit-points" => [ "hr-merit-points-movement-view" => "View Merit Points Movement", "hr-merit-points-adjustment-view" => "View Merit Points Adjustment", "hr-merit-points-task-view" => "View Merit Points Task", ], "attendance" => [ "attendance-list-view" => "View Attendance List", "attendance-list-edit" => "Edit Attendance", "attendance-list-report" => "View Attendance Report", "attendance-attendance-reprocessing" => "Attendance Reprocessing", "attendance-list-qrcode" => "View Qrcode", "attendance-list-qrcode-topunch" => "Punch Card", "attendance-health-view" => "View Health", "attendance-health-new" => "New Health", "attendance-health-update" => "Edit Health" ], "leave" => [ "leave-view" => "View Leave List", "leave-new" => "New Leave", "leave-update" => "Edit Leave", ] ] ; $array_permission2['salary'] = [ "salary-list" => [ "salary-view" => "View Salary List" ] ] ; $array_permission2['task'] = [ "task-list" => [ "task-list-view" => "View Task List", "task-list-trash" => "Trash Task", "task-report-view" => "View Report List" ] ] ; $array_permission2['service'] = [ "announcement" => [ "announcement-view" => "View Announcement List", "announcement-new" => "New Announcement", "announcement-trash" => "Trash Announcement" ], "inbox" => [ "inbox-view" => "View Inbox", "inbox-new" => "New Inbox", "inbox-trash" => "Trash Inbox" ], "our-inbox" => [ "our-suggestion-view" => "View Suggestion List", "our-suggestion-edit" => "Edit Suggestion", "our-suggestion-trash" => "Trash Suggestion", "our-request-view" => "View Request List", "our-request-edit" => "Edit Request", "our-request-trash" => "Trash Request", "our-category-gallery" => "View Request Gallery", "our-category-main-view" => "View Main Category List", "our-category-main-new" => "New Main Category", "our-category-main-edit" => "Edit Main Category", "our-category-main-trash" => "Trash Main Category", "our-category-main-stock" => "Control Main Category Stock", "our-category-sub-view" => "View Sub Category List", "our-category-sub-new" => "New Sub Category", "our-category-sub-edit" => "Edit Sub Category", "our-category-sub-trash" => "Trash Sub Category", "our-category-sub-stock" => "Control Sub Category Stock", "our-grievance-view" => "View Grievance List", "our-grievance-edit" => "Edit Grievance", "our-grievance-trash" => "Trash Grievance" ], "form-submission" => [ "form-headcount-view" => "View Headcount List", "form-headcount-edit" => "Edit Headcount", "form-headcount-trash" => "Trash Headcount", "form-nomination-view" => "View Nomination List", "form-nomination-trash" => "Trash Nomination", "form-nomination-question-view" => "View Nomination Question", "form-nomination-question-new" => "New Nomination Question", "form-nomination-question-edit" => "Edit Nomination Question", "form-nomination-question-trash" => "Trash Nomination Question", "form-resignation-view" => "View resignation List", "form-resignation-edit" => "Edit resignation", "form-resignation-trash" => "Trash resignation", "form-submission-category-view" => "View Category", "form-submission-category-new" => "New Category", "form-submission-category-edit" => "Edit Category", "form-submission-category-trash" => "Trash Category" ], "redeem" => [ "redeem-list-view" => "View Redeem List", "redeem-list-new" => "New Redeem", "redeem-list-edit" => "Edit Redeem", "redeem-list-trash" => "Trash Redeem" ], "association" => [ "association-list-view" => "View Association List", "association-list-new" => "New Association", "association-list-edit" => "Edit Association", "association-list-trash" => "Trash Association", "association-list-qr" => "Qr Code Association", "association-list-gallery-category" => "View Association Gallery Category", "association-list-gallery" => "View Association Gallery", "association-category-view" => "View Category", "association-category-new" => "New Category", "association-category-edit" => "Edit Category", "association-category-trash" => "Trash Category" ], "training" => [ "training-view" => "View Training List", "training-new" => "New Training", "training-edit" => "Edit Training", "training-trash" => "Trash Training", "training-qr" => "QR Code Training", "training-gallery-category" => "View Training Gallery Category", "training-gallery" => "View Training Gallery", ], "form" => [ "form-list-view" => "View Form List", "form-list-new" => "New Form", "form-list-edit" => "Edit Form", "form-list-trash" => "Trash Form" ], "handbook" => [ "handbook-list-view" => "View Handbook List", "handbook-list-new" => "New Handbook", "handbook-list-edit" => "Edit Handbook", "handbook-list-trash" => "Trash Handbook" ] ] ; $array_permission2['import'] = [ "import" => [ "import-full-attendance-view" => "View Import Full Attendance List", "import-full-attendance-upload" => "Upload Full Attendance List", "import-full-attendance-trash" => "Trash Full Attendance List", "import-outstanding-employee-view" => "View Import Outstanding Employee List", "import-outstanding-employee-upload" => "Upload Outstanding Employee List", "import-outstanding-employee-trash" => "Trash Outstanding Employee List", "import-lateness-board-view" => "View Import Lateness Board List", "import-lateness-board-upload" => "Upload Lateness Board List", "import-lateness-board-trash" => "Trash Lateness Board List", "import-point-view" => "View Import Point List", "import-point-upload" => "Upload Point List", ] ] ; $array_permission2['report'] = [ "year-end-cut-off" => [ "year-end-cut-off-view" => "View Year End Cut Off Report" ] ] ; $array_permission2['setting'] = [ "user-setting" => [ "user-user-view" => "User", "user-new-user-new" => "New User", "user-user-edit" => "Edit User", "user-user-update" => "Update User" ], "service-annoucment" => [ "user-notification-view" => "View Notification List", "user-notification-edit" => "Edit Notification", "user-notification-trash" => "Trash Notification", "user-letterhead-view" => "View Letterhead List", "user-letterhead-new" => "New Letterhead", "user-letterhead-edit" => "Edit Letterhead", "user-letterhead-trash" => "Trash Letterhead" ], "hr-setting" => [ "hr-branch-view" => "View Branch List", "hr-branch-new" => "New Branch", "hr-branch-edit" => "Edit Branch", "hr-branch-trash" => "Trash Branch", "hr-working-hours-view" => "View Working Hours List", "hr-working-hours-new" => "New Working Hours", "hr-working-hours-edit" => "Edit Working Hours", "hr-working-hours-trash" => "Trash Working Hours", "hr-department-list-View" => "ViewDepartment List", "hr-department-list-new" => "New Department", "hr-department-list-edit" => "Edit Department", "hr-department-list-trash" => "Trash Department", "hr-section-list-view" => "View Section List", "hr-section-list-new" => "New Section", "hr-section-list-edit" => "Edit Section", "hr-section-list-trash" => "Trash Section", "hr-position-list-view" => "View Designation List", "hr-position-list-new" => "New Designation", "hr-position-list-edit" => "Edit Designation", "hr-position-list-trash" => "Trash Designation" ], "app-setting" => [ "app-welcome-screen-view" => "View Welcome Screen List", "app-welcome-screen-new" => "New Welcome Screen", "app-welcome-screen-edit" => "Edit Welcome Screen", "app-welcome-screen-trash" => "Trash Welcome Screen", "app-pop-up-view" => "View Pop Up", "app-pop-up-edit" => "Edit Pop Up", "app-service-view" => "View Sevice List", "app-service-edit" => "Edit Sevice", "app-service-trash" => "Trash Sevice", "app-page-view" => "View Page List", "app-page-new" => "New Page", "app-page-edit" => "Edit Page", "app-page-trash" => "Trash Page", "app-menu-view" => "View Menu List", "app-menu-new" => "New Menu", "app-menu-edit" => "Edit Menu", "app-menu-trash" => "Trash Menu", "app-support-view" => "View Support List", "app-support-new" => "New Support", "app-support-edit" => "Edit Support", "app-support-trash" => "Trash Support", "app-pasword-view" => "View Password List", "app-pasword-edit" => "Edit Password", "app-difficulty-view" => "View Difficulty List", "app-difficulty-new" => "New Difficulty", "app-difficulty-edit" => "Edit Difficulty", "app-difficulty-trash" => "Trash Difficulty", "app-adjustment-view" => "View Adjustment List", "app-adjustment-new" => "New Adjustment", "app-adjustment-edit" => "Edit Adjustment", "app-adjustment-trash" => "Trash Adjustment", "app-point-view" => "View Point Adjustment List", "app-point-new" => "New Point Adjustment", "app-point-edit" => "Edit Point Adjustment", "app-adjustment-group-view" => "View Adjustment Group List", "app-adjustment-group-new" => "New Adjustment Group", "app-adjustment-group-edit" => "Edit Adjustment Group", "app-adjustment-group-trash" => "Trash Adjustment Group", "profile-star-view" => "View Star List", "profile-star-edit" => "Edit Star", "profile-point-view" => "View Point List", "profile-point-edit" => "Edit Point", "profile-achievement-view" => "View Achievement List", "profile-achievement-edit" => "Edit Achievement", "profile-tier-view" => "Tier List", "profile-tier-edit" => "Edit Tier" ] ] ; // keep parameter in value $page = escapeString($_GET['page']) ; $page_mode = escapeString($_GET['page_mode']) ; $order = escapeString($_GET['order']) ; $type = escapeString($_GET['type']) ; $search = escapeString($_GET['search']) ; // get all branch $branch_all = [] ; $get_branch = $mysqli->query("SELECT * FROM branch WHERE deleted_at IS NULL") ; if ( $get_branch->num_rows > 0 ){ while ( $row_branch = $get_branch->fetch_assoc() ){ $branch_all[$row_branch['branch_id']] = $row_branch['branch_name'] ; } } // get all requires $tier_list = [] ; $tier_list_id = [] ; $mysqli_tier = $mysqli->query("SELECT a.tier_id, b.title FROM profile_tier a LEFT JOIN profile_tier_translation b ON ( a.tier_id = b.tier_id ) WHERE a.deleted_at IS NULL AND b.lang = 'en' ORDER BY a.sortable DESC") ; if ( $mysqli_tier->num_rows > 0 ){ while ( $row_tier = $mysqli_tier->fetch_assoc() ){ $tier_list[] = $row_tier ; $tier_list_id[$row_tier['tier_id']] = $row_tier['title'] ; } } // form submit if ($_POST['hide'] == 1){ $call = escapeString($_POST['call']) ; $username = escapeString($_POST['username']) ; $email = escapeString($_POST['email']) ; $fullname = escapeString($_POST['fullname']) ; $password = escapeString($_POST['password']) ; $permission = escapeString($_POST['permission']) ; $branch = escapeString($_POST['branch']) ; $colour = escapeString($_POST['colour']) ; $verification_code = escapeString($_POST['verification_code']) ; $user_is_interview_by = escapeString($_POST['user_is_interview_by']) ; $hide_user_id = escapeString($_POST['hide_user_id']) ; $branch_permission = $_POST['branch_permission'] ; $branch_permission = json_encode($branch_permission) ; $permission2 = ($_POST['permission2']) ; $temp_permission2 = multipleArrayTo($permission2) ; $boolean_redirect = false ; if ($username != '' && $email != '' && $fullname != ''){ // query for user $user_query = ($hide_user_id != '' ? " AND user_id != '".$hide_user_id."'" : '') ; // if not admin if ( $row_user['user_permission'] != 'admin' ){ $user_query .= " AND user_permission != 'admin'" ; $permission = 'user' ; $verification_code = 'no' ; $user_is_interview_by = 'no' ; } // check user exsits $mysqli_check_user = $mysqli->query("SELECT * FROM system_user WHERE user_name = '".$username."' AND user_trash = '0' ".$user_query." LIMIT 1") ; // check if username exsits if ($mysqli_check_user->num_rows > 0){ $boolean_user = false ; }else{ $boolean_user = true ; } // password $boolean_password = false ; if (strlen($password) >= 6){ $boolean_password = true ; } // check user status if ($boolean_user){ // set image in variable $image = $_FILES["image"]["name"] ; // remove photo $remove_photo = $_POST['remove_photo'] ; if ($remove_photo == 1){ $image = '' ; $image_query = "user_signature = ''," ; } $temp_user_tier = [] ; foreach ( $_POST['user_tier'] as $kusertier => $vusertier ){ $temp_user_tier[] = escapeString($vusertier) ; } $user_tier = implode(',', $temp_user_tier) ; // check status switch($_POST['hide_status']){ case 'new' : // check permission if ( !permissionCheck($row_user, 'user-new') ){ header('Location: index.php') ; exit ; } // reset password $code = rand(0, 9999) ; $password = md5(md5($password).$code) ; // check password if ($boolean_password){ // check password $mysqli->query( "INSERT INTO system_user (user_tier, user_call, user_name, user_email, user_password, user_code, user_fullname, user_permission, user_permission2, user_branch, user_verification_type, user_colour, user_last_login, user_date, user_modified, user_trash, user_permission_branch) VALUES ('".$user_tier."', '".$call."', '".$username."', '".$email."', '".$password."', '".$code."', '".$fullname."', '".$permission."', '".$temp_permission2."', '".$branch."', '".$verification_code."', '".$colour."', '".TODAYDATE."', '".TODAYDATE."', '".TODAYDATE."', '0', '".$branch_permission."')") ; $page = $mysqli->insert_id ; $boolean_redirect = true ; }else{ $boolean_password = false ; } break ; case 'edit' : // check permission if ( !permissionCheck($row_user, 'user-update') ){ header('Location: index.php') ; exit ; } // password null if (strlen($password) == 0){ // set boolean = true $boolean_password = true ; }else{ if (strlen($password) >= 6){ // set boolean = true $boolean_password = true ; // reset password $code = rand(0, 9999) ; $password = md5(md5($password).$code) ; // query for password $password_query = " user_password = '".$password."', user_code = '".$code."'," ; } } // check boolean status if ($boolean_password){ // customer join company $mysqli_page = $mysqli->query("SELECT * FROM system_user WHERE user_id = '".$page."' AND user_trash = '0' LIMIT 1") ; // set query as array $row_page = $mysqli_page->fetch_array(MYSQLI_ASSOC) ; // check is admin can edit permission if ( $row_user['user_permission'] == 'admin' ){ $admin_query = "user_verification_type = '".$verification_code."', user_is_interview_by = '".$user_is_interview_by."', user_colour = '".$colour."', user_tier = '".$user_tier."', user_permission = '".$permission."', user_permission_branch = '".$branch_permission."', user_permission2 = '".$temp_permission2."'," ; } $mysqli->query("UPDATE system_user SET user_call = '".$call."', user_name = '".$username."', user_email = '".$email."', ".$password_query." ".$admin_query." ".$image_query." user_fullname = '".$fullname."', user_modified = '".TODAYDATE."' WHERE user_id = '".$page."'") ; } break ; } // resize image $create_image = reCreateImage('User', $page, $page, '', $image, $_FILES["image"]["type"], $_FILES['image']['tmp_name']) ; // Image uploads when exists if ($create_image['result'] && is_array($create_image['crop']) && count($create_image['result']) > 0){ $resizeObj = new resize($create_image['original']) ; // Initialise load image foreach($create_image['crop'] as $value){ // Resize image (options: exact, portrait, landscape, auto, crop) $resizeObj -> resizeImage($value['width'], $value['height'], $value['type']) ; $resizeObj -> saveImage($value['source']) ; // Save image } // update database $mysqli->query("UPDATE system_user SET user_signature = '".$create_image['image']."' WHERE user_id = '".$page."'"); } // new user if ($boolean_redirect){ // redirect to main page header("Location: user.php?page_mode=all") ; exit ; } }else{ $boolean_password = true ; } } } // mode type | all list | new | edit switch($page_mode){ // new customer case 'new' : // check permission if ( !permissionCheck($row_user, 'user-new-user-new') ){ header('Location: index.php') ; exit ; } // active menu bar $active_main_menu = 'setting' ; $active_sub_menu = 'setting-user' ; $active_menu = 'user-new' ; // start header here include 'requires/page_header.php' ; include 'requires/page_top.php' ; ?>