[ 'plus' => $months, 'minus' => $months ], ] ; if ( $staff_settings['reportadjustmentbranch'] == 'yes' ){ $array_report['branch'] = [ 'plus' => $months, 'minus' => $months ] ; } $filtertype = [] ; foreach ( $array_report as $k => $v ){ if ( $k == $search_type ){ $filtertype[] = $k ; } } foreach ( $filtertype as $k => $v ){ $search_query = " AND ( b.created_branch_id = '".$array['branch_id']."' XXXXXX )" ; switch ( $v ){ case 'personal' : $search_query = str_replace( 'XXXXXX', " AND b.created_by = '".$staff_info['staff_id']."'", $search_query ) ; break ; case 'branch' : $search_query = str_replace( 'XXXXXX', '', $search_query ) ; break ; } $select_report = $mysqli->query( "SELECT SUM(a.point) as total, b.adjustment_type, MONTH(b.created_at) as month FROM staff_adjustment_point a LEFT JOIN staff_adjustment b ON ( a.adjustment_id = b.adjustment_id ) WHERE a.deleted_at IS NULL AND b.deleted_at IS NULL AND b.created_at LIKE '%".$search_year."%' ".$search_query." GROUP BY b.adjustment_type, MONTH(b.created_at)" ) ; if ( $select_report->num_rows > 0 ){ while ( $row_report = $select_report->fetch_assoc() ){ $array_report[$v][$row_report['adjustment_type']][$row_report['month']] = $row_report['total'] ; } } } // direct echo if ( $array['iswebview'] == 'yes' ){ $html .= '