alert("Sorry You Don\'t Have The Permission.")'; header('Location: page-logout.php') ; exit ; } // check query exsits $mysqli_page = $mysqli->query("SELECT post_id, post_title, post_content FROM system_post WHERE post_type = 'page-dashboard' AND post_categories = 'page-dashboard' AND post_trash = '0' LIMIT 1") ; //pagination if (isset($page) && !empty($page)) { $product_page = $page ; } else { $product_page = 1 ; } // next and prev page (5 thing need to change) $limit_dash = 20; $start_from = ($product_page - 1) * $limit_dash ; //end next and prev page $search_name = escapeString($_GET['search_name']); $search_idno = escapeString($_GET['search_idno']); $export_excel = escapeString($_GET['export-excel']); $search_query = '' ; if( $search_name != ''){ $search_query .= " AND b.staff_name LIKE '%".$search_name."%'" ; } if( $search_idno != ''){ $search_query .= " AND b.staff_idno LIKE '%".$search_idno."%'" ; } $mysqli_achievement = $mysqli->query("SELECT a.*, b.staff_name, b.staff_point, b.staff_idno FROM staff_monthly_achievement a LEFT JOIN staff b ON ( a.staff_id = b.staff_id ) WHERE a.staff_id != '' AND Year(a.created_at) = Year(Now()) AND MONTH(a.created_at) = month(Now()) ".$search_query." ".$user_branch_permission_sql_b." GROUP BY a.staff_id ORDER BY b.staff_point DESC LIMIT $start_from, ".$limit_dash) ; $mysqli_achievement_query = "SELECT a.*, b.staff_name, b.staff_point, b.staff_idno FROM staff_monthly_achievement a LEFT JOIN staff b ON ( a.staff_id = b.staff_id ) WHERE a.staff_id != '' AND Year(a.created_at) = Year(Now()) AND MONTH(a.created_at) = month(Now()) ".$search_query." ".$user_branch_permission_sql_b." GROUP BY a.staff_id ORDER BY b.staff_point DESC"; if ( $export_excel == 'export_eae' ){ $page_export_file_name = 'Monthly Achivement-'; $t_title_header_excel = 'Monthly Achivement Report '; $array_header_excel = array( 'ID', 'Name', 'Monthly Point Achievement', 'Current Point', 'Redeemed Point', 'Total Accumulated Point', 'Star', 'Achievement' ) ; $mysqli_export = $mysqli->query( $mysqli_achievement_query ) ; if ( $mysqli_export->num_rows > 0 ){ while ( $mysqli_export_page = $mysqli_export->fetch_assoc() ){ $mysqli_accumulated_point = $mysqli->query("SELECT SUM(amount) AS total_accumulated FROM staff_point_movement WHERE staff_id = '".$mysqli_export_page['staff_id']."' AND from_table NOT IN ('redeem','staff_point_movement_cutoff') AND Year(created_at) = Year(Now())"); if ( $mysqli_accumulated_point->num_rows > 0 ){ $row_accumulated = $mysqli_accumulated_point->fetch_array(MYSQLI_ASSOC); } $mysqli_total_redeem = $mysqli->query("SELECT SUM(amount) AS total_redeem FROM staff_point_movement WHERE staff_id = '".$mysqli_export_page['staff_id']."' AND from_table = 'redeem' AND Year(created_at) = Year(Now())"); if ( $mysqli_total_redeem->num_rows > 0 ){ $row_redeem = $mysqli_total_redeem->fetch_array(MYSQLI_ASSOC); } $current_point = $row_accumulated['total_accumulated'] + $row_redeem['total_redeem']; $current_point = number_format($current_point, 2, '.', ''); $array_body_excel[] = array( $mysqli_export_page['staff_idno'], $mysqli_export_page['staff_name'], $mysqli_export_page['staff_point_achievement'], $current_point, ($row_redeem['total_redeem'] != '' ? $row_redeem['total_redeem'] : '0.00' ), ($row_accumulated['total_accumulated'] != '' ? $row_accumulated['total_accumulated'] : '0.00' ), $mysqli_export_page['staff_star'], $mysqli_export_page['staff_achievement'] ) ; } } include 'export_excel_default.php'; } // start header here include 'requires/page_header.php' ; // include 'requires/page_top.php' ; $search_url = 'page_mode=all&search_name='.$search_name.'&search_idno='.$search_idno ; $page_pagination = nextPrevious($product_page, $limit_dash, $search_url, $mysqli_achievement_query) ; ?>
| ID | Name | Monthly Point Achievement | Current Point | Redeemed Point | Total Accumulated Point | Star | Achievement |
|---|---|---|---|---|---|---|---|
| '.dataFilter($row_achievement['staff_idno']).' | '.dataFilter($row_achievement['staff_name']).' | '.dataFilter($row_achievement['staff_point_achievement']).' | '; $mysqli_accumulated_point = $mysqli->query("SELECT SUM(amount) AS total_accumulated FROM staff_point_movement WHERE staff_id = '".$row_achievement['staff_id']."' AND from_table NOT IN ('redeem','staff_point_movement_cutoff') AND Year(created_at) = Year(Now())"); if ( $mysqli_accumulated_point->num_rows > 0 ){ $row_accumulated = $mysqli_accumulated_point->fetch_array(MYSQLI_ASSOC); } $mysqli_total_redeem = $mysqli->query("SELECT SUM(amount) AS total_redeem FROM staff_point_movement WHERE staff_id = '".$row_achievement['staff_id']."' AND from_table = 'redeem' AND Year(created_at) = Year(Now())"); if ( $mysqli_total_redeem->num_rows > 0 ){ $row_redeem = $mysqli_total_redeem->fetch_array(MYSQLI_ASSOC); } $current_point = $row_accumulated['total_accumulated'] + $row_redeem['total_redeem']; $current_point = number_format($current_point, 2, '.', ''); echo ''.dataFilter($current_point).' | '.($row_redeem['total_redeem'] != '' ?dataFilter($row_redeem['total_redeem']) : '0.00' ).' | '.($row_accumulated['total_accumulated'] != '' ?dataFilter($row_accumulated['total_accumulated']) : '0.00' ).' | '; // $mysqli_current_point echo ''.dataFilter($row_achievement['staff_star']).' | '.dataFilter($row_achievement['staff_achievement']).' |
| '.$lang['no_data'].' |