0 ? 'plus' : ( $amount < 0 ? 'minus' : '' ) ) ; switch ( $adjustment_type ){ case 'plus' : $amount = ( $amount > 0 ? $amount : -($amount) ) ; break ; case 'minus' : $amount = ( $amount > 0 ? -($amount) : $amount ) ; break ; } if ( $adjustment_type != '' ){ $error = 'Invalid staff' ; $staff_id = [] ; // delete all department & receiver $receiver_type = dataFilter($_POST['receiver_type']) ; $receiver_to = $_POST['receiver_to'] ; $receiver_to_dept = $_POST['receiver_to_dept'] ; if ( $receiver_type == '1' ){ if( !empty( $receiver_to ) ){ for ( $i = 0 ; $i < count($receiver_to) ; $i++ ){ if ( $receiver_to[$i] != '' ){ $reset_staff = $receiver_to[$i] ; $staff_id[$reset_staff] = $receiver_to[$i] ; } } } }else{ if( !empty( $receiver_to_dept ) ){ $array_depart = [] ; for ( $i = 0 ; $i < count($receiver_to_dept) ; $i++ ){ $department_id = $receiver_to_dept[$i] ; if ( $department_id != '' ){ // save into department $selected_depart[]= $department_id ; // check department staff $reset_depart = str_replace( ['(', ')'], '', $department_id ) ; $get_depart_staff = $mysqli->query( "SELECT a.staff_id FROM staff_department a LEFT JOIN staff b ON ( a.staff_id = b.staff_id ) WHERE a.deleted_at IS NULL AND b.deleted_at IS NULL AND a.department_id = '".$reset_depart."'" ) ; if ( $get_depart_staff->num_rows > 0 ){ while ( $row_depart_staff = $get_depart_staff->fetch_assoc() ){ if ( !in_array($row_depart_staff['staff_id'], $array_depart) ){ $array_depart[] = $row_depart_staff['staff_id'] ; $staff_id[$row_depart_staff['staff_id']] = $row_depart_staff['staff_id'] ; } } } } } } } if ( count($staff_id) > 0 ){ $error = 'Failed To Submit' ; if ( $mysqli->query( "INSERT INTO staff_adjustmentwallet ( `adjustment_type`, `created_branch_id`, `created_by_userid`, `department_id`, `amount`, `remark` ) VALUES ( '".$adjustment_type."', '".$current_branch_id."', '".$_SESSION['system_id']."', '0', '".$amount."', '".$remark."' )" ) ){ $status = '200' ; $error = 'success-updated' ; $adjustment_id = $mysqli->insert_id ; $adjustment_so = 'AW'.strPad( 6, $adjustment_id ) ; $mysqli->query( "UPDATE staff_adjustmentwallet SET adjustment_so = '".$adjustment_so."' WHERE adjustment_id = '".$adjustment_id."'" ) ; // set amount movement $remark2 = 'You have been '.( $amount > 0 ? 'given' : 'deducted' ).' the amount from backend (' . $adjustment_so . ')' ; foreach ( $staff_id as $k => $v ){ $mysqli->query( "INSERT INTO staff_adjustment_wallet ( `adjustment_id`, `staff_id`, `amount` ) VALUES ( '".$adjustment_id."', '".$v."', '".$amount."' )" ) ; walletMovement( 'adjustment', $adjustment_id, $adjustment_type, 'normal', $v, $amount, $remark ) ; pushToUserCron( 'staff_adjustmentwallet', $adjustment_id, $v, 'Wallet Adjustment', $remark ) ; } } } } } // refresh page header("Location:hr-staff-adjustment-wallet.php?page_mode=all&success=1") ; $_SESSION['system_result'] = $error ; exit ; } if ( (!permissionCheck($row_user, 'staff-adjustment-wallet-new') ) ){ header('Location: hr-staff-adjustment-wallet.php') ; exit ; } // staff $staff_list = [] ; $mysqli_staff = $mysqli->query( "SELECT staff_id, staff_name, staff_idno FROM staff WHERE deleted_at IS NULL ".$user_branch_permission_sql . ( $get_user_tier['check'] ? " AND staff_tier IN ( ".implode(', ', $get_user_tier['tiers'])." )" : '' ) ) ; if ( $mysqli_staff->num_rows > 0 ){ while ( $row_staff = $mysqli_staff->fetch_assoc() ){ $staff_list[$row_staff['staff_id']] = dataFilter($row_staff['staff_name']) . ' ( ' . dataFilter($row_staff['staff_idno']) . ' )' ; } } // get all requires $department_list = [] ; $mysqli_department = $mysqli->query("SELECT a.department_id, b.department_desc FROM setting_department a LEFT JOIN setting_department_translation b ON ( a.department_id = b.department_id ) WHERE a.deleted_at IS NULL AND b.lang = 'en'") ; if ( $mysqli_department->num_rows > 0 ){ while ( $row_department = $mysqli_department->fetch_assoc() ){ $department_list[$row_department['department_id']] = dataFilter($row_department['department_desc']) ; } } if ( ( $page_mode == 'new' && !permissionCheck($row_user, 'handbook-list-new') ) || ( $page_mode == 'edit' && !permissionCheck($row_user, 'handbook-list-edit') ) ){ header('Location: app-training.php') ; exit ; } // get all selected staff & department $receiver_depart = ( $row_page['department_id'] != '' ? explode('/', $row_page['department_id']) : [] ) ; // setting $array_setting_adjustment = [] ; $select_setting = $mysqli->query( "SELECT a.adjustment_id, a.adjustment_type, b.title FROM setting_adjustment a LEFT JOIN setting_adjustment_translation b ON ( a.adjustment_id = b.adjustment_id ) WHERE a.deleted_at IS NULL AND b.lang = 'en' AND a.adjustment_site = 'backend'" ) ; if ( $select_setting->num_rows > 0 ){ while ( $row_setting = $select_setting->fetch_assoc() ){ $array_setting_adjustment[$row_setting['adjustment_type']][] = $row_setting ; } } // start header here include 'requires/page_header.php'; include 'requires/page_top.php'; ?>
| Staff | Amount | Created At |
|---|---|---|
| '.dataFilter($row_page['staff_name']).' | '.dataFilter($row_page['amount']).' | '.resetDateTimeFormat($row_page['created_at']).' |