Untitled
unknown
plain_text
a year ago
1.5 kB
6
Indexable
function get_monthly_report() { extract($_POST); $data = array(); // Assuming your table has a 'time_taken' column to store the time taken by each employee by ashish pandey $get = $this->db->query("SELECT t.*, p.name as ticket_for FROM ticket_list t INNER JOIN pricing p ON p.id = t.pricing_id WHERE DATE(t.date_created) BETWEEN '$date_from' AND '$date_to' ORDER BY UNIX_TIMESTAMP(t.date_created) DESC "); while ($row = $get->fetch_assoc()) { $row['date_created'] = date("M d, Y", strtotime($row['date_created'])); $row['name'] = ucwords($row['name']); $row['adult_price'] = number_format($row['adult_price'], 2); $row['child_price'] = number_format($row['child_price'], 2); $row['amount'] = number_format($row['amount'], 2); $monthYear = date("Y-m", strtotime($row['date_created'])); // Create a new array for each employee and month if it doesn't exist by ashish pandey if (!isset($data[$row['name']][$monthYear])) { $data[$row['name']][$monthYear] = array( 'total_amount' => 0, 'total_time_taken' => 0, 'tickets' => array() ); } // Update the total amount and time taken for the employee and month ashish pandey $data[$row['name']][$monthYear]['total_amount'] += $row['amount']; $data[$row['name']][$monthYear]['total_time_taken'] += $row['time_taken']; // Store ticket details for reference if needed pandey $data[$row['name']][$monthYear]['tickets'][] = $row; } return json_encode($data); }
Editor is loading...
Leave a Comment