query( $query ) ; if ( $mysqli_query->num_rows > 0 ){ $status = '200' ; $row = $mysqli_query->fetch_assoc() ; $temp = [] ; $temp['title'] = dataFilter( $row['title'] ) ; $temp['content'] = dataFilter( $row['content'] ) ; $temp['file'] = ( $row['file'] != '' ? PATH.'uploads/ProfilePoint/b/'.$row['file'] : '' ) ; $temp['created_at'] = resetDateFormat( $row['created_at'] ) ; $list = $temp ; } // get total accumulated point // 'system','staff_point_movement_cutoff','task','redeem','adjustment','training' $select_movement = $mysqli->query( "SELECT SUM( amount ) as total FROM staff_point_movement WHERE staff_id = '".$staff_info['staff_id']."' AND from_table IN ( 'system','task','adjustment','training' ) AND created_at LIKE '%".date('Y', time())."-%'" ) ; if ( $select_movement->num_rows > 0 ){ $data_movement = $select_movement->fetch_assoc() ; $total_accumulated = $data_movement['total'] ; } // get total redeem $select_movement = $mysqli->query( "SELECT SUM( amount ) as total FROM staff_point_movement WHERE staff_id = '".$staff_info['staff_id']."' AND from_table IN ( 'redeem' ) AND created_at LIKE '%".date('Y', time())."-%'" ) ; if ( $select_movement->num_rows > 0 ){ $data_movement = $select_movement->fetch_assoc() ; $total_redeem = $data_movement['total'] ; $total_redeem = numberFormat( $total_redeem < 0 ? -( $total_redeem ) : 0 ) ; } $data['list'] = $list ; $data['total_accumulated'] = $total_accumulated ; $data['total_redeem'] = $total_redeem ; } // direct echo if ( $array['iswebview'] == 'yes' ){ require( $require_path.'languages/'.$array['lang'].'.php' ) ; $search_year = ( $array['search_year'] != '' ? $array['search_year'] : date('Y') ) ; $search_type = ( $array['search_type'] != '' ? $array['search_type'] : 'personal' ) ; $staff_settings = $staff_info['staff_settings'] ; $months = [] ; $months_name = [ $lang['Jan'], $lang['Feb'], $lang['Mar'], $lang['Apr'], $lang['May'], $lang['Jun'], $lang['Jul'], $lang['Aug'], $lang['Sep'], $lang['Oct'], $lang['Nov'], $lang['Dec'] ] ; for ( $a = 1 ; $a <= 12 ; $a++ ){ $months[$a] = 0 ; } // monthly report = by personal or whole branch $array_report = [ 'personal' => [ 'yes' => $months ], ] ; $filtertype = [] ; foreach ( $array_report as $k => $v ){ if ( $k == $search_type ){ $filtertype[] = $k ; } } foreach ( $filtertype as $k => $v ){ $search_query = " AND ( a.staff_id = '".$staff_info['staff_id']."' )" ; $select_task = $mysqli->query( "SELECT SUM(a.staff_point_achievement) as total, MONTH(a.reported_at) as month FROM staff_monthly_achievement a WHERE a.deleted_at IS NULL AND a.reported_at LIKE '%".$search_year."%' ".$search_query." GROUP BY MONTH(a.reported_at)" ) ; if ( $select_task->num_rows > 0 ){ while ( $row_report = $select_task->fetch_assoc() ){ $array_report[$v]['yes'][$row_report['month']] = $row_report['total'] ; } } } $html .= '
' ; } } if ( $array['iswebview'] == 'yes' ){ echo $html ; exit ; } require( $require_sub.'footer.php' ) ; ?>