public static function FORMAT($S, $R, $P) { $I = array(); if ($P === false) { $I[] = STR_REPLACE("/", "-", $R) . " 00:00:00"; $I[] = STR_REPLACE("/", "-", $R) . " 24:59:59"; $SET = 'HOUR'; } else { $R = explode(" - ", $R); $I[] = STR_REPLACE("/", "-", $R[0]); $I[] = STR_REPLACE("/", "-", $R[1]); $SET = 'DAY'; } $I[] = $S['s_id']; $Q = "SELECT MIN(t_checkout_created) AS `time`, AVG(t_checkout_price) AS `cost` FROM core_tickets_processed WHERE t_checkout_created >= ? AND t_checkout_created <= ? AND t_store = ? GROUP BY"; $CA = MYSQL::QUERY($Q . " {$SET}(t_checkout_created) ORDER BY t_checkout_created ASC", $I); $CO = MYSQL::QUERY($Q . " t_checkout_created ORDER BY t_checkout_created ASC", $I); $STRING = array(); $STRING[] = array('name' => 'Average Charge', 'data' => ''); $STRING[] = array('name' => 'Checkout Charges', 'data' => ''); foreach ($CA as $C) { $T = Date_UTC($C['time']); $STRING[0]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $T[3] . "," . $C['cost']; } foreach ($CO as $C) { $T = Date_UTC($C['time']); $STRING[1]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $T[3] . "," . $T[4] . "," . $C['cost']; } echo JSON_ENCODE($STRING); }
public static function FORMAT($S, $R, $P) { $I = array($S['s_id']); if ($P === false) { $TI = "AND d_date = ? LIMIT 1"; $I[] = str_replace("/", "-", $R); } else { $R = explode(" - ", $R); $TI = "AND d_date >= ? AND d_date <= ? ORDER BY d_date ASC"; $I[] = str_replace("/", "-", $R[0]); $I[] = str_replace("/", "-", $R[1]); } $CT = MYSQL::QUERY("SELECT * FROM core_stores_daily_checkouts WHERE s_id = ? {$TI}", $I); $STRING = array(array('name' => 'Sales', 'data' => '')); if (!$P === false) { foreach ($CT as $CL) { $T = Date_UTC($CL['d_date']); $Total = $CL['d_gross_nontaxable'] + $CL['d_gross_taxable']; $STRING[0]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $Total; } } else { $T = Date_UTC($CT['d_date']); $Total = $CT['d_gross_nontaxable'] + $CT['d_gross_taxable']; $STRING[0]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $Total; } if ($P === false) { $STRING[0]['type'] = 'column'; } echo JSON_ENCODE($STRING); }
public static function FORMAT($S, $R, $P) { $I = array($S['s_id']); if ($P === false) { $TI = "AND d_date = ? LIMIT 1"; $I[] = str_replace("/", "-", $R); } else { $R = explode(" - ", $R); $TI = "AND d_date >= ? AND d_date <= ? ORDER BY d_date ASC"; $I[] = str_replace("/", "-", $R[0]); $I[] = str_replace("/", "-", $R[1]); } $CT = MYSQL::QUERY("SELECT * FROM core_stores_daily_checkouts WHERE s_id = ? {$TI}", $I); $STRING = array(array('name' => 'Cash', 'data' => ''), array('name' => 'Check', 'data' => ''), array('name' => 'American Express', 'data' => ''), array('name' => 'Discover', 'data' => ''), array('name' => 'Master Card', 'data' => ''), array('name' => 'Visa', 'data' => ''), array('name' => 'Debit', 'data' => '')); if (!$P === false) { foreach ($CT as $CL) { $T = Date_UTC($CL['d_date']); $STRING[0]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $CL['d_cash']; $STRING[1]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $CL['d_check']; $STRING[2]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $CL['d_amex']; $STRING[3]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $CL['d_discover']; $STRING[4]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $CL['d_master']; $STRING[5]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $CL['d_visa']; $STRING[6]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $CL['d_debit']; } } else { $T = Date_UTC($CT['d_date']); $STRING[0]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $CT['d_cash']; $STRING[1]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $CT['d_check']; $STRING[2]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $CT['d_amex']; $STRING[3]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $CT['d_discover']; $STRING[4]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $CT['d_master']; $STRING[5]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $CT['d_visa']; $STRING[6]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $CT['d_debit']; } if ($P === false) { $STRING[0]['type'] = 'column'; $STRING[1]['type'] = 'column'; $STRING[2]['type'] = 'column'; $STRING[3]['type'] = 'column'; $STRING[4]['type'] = 'column'; $STRING[5]['type'] = 'column'; $STRING[6]['type'] = 'column'; } echo JSON_ENCODE($STRING); }
public static function FORMAT($S, $R, $P) { $I = array($S['s_id']); if ($P === false) { $TI = "AND d_date = ? LIMIT 1"; $I[] = str_replace("/", "-", $R); } else { $R = explode(" - ", $R); $TI = "AND d_date >= ? AND d_date <= ? ORDER BY d_date ASC"; $I[] = str_replace("/", "-", $R[0]); $I[] = str_replace("/", "-", $R[1]); } $CT = MYSQL::QUERY("SELECT * FROM core_stores_daily_tickets WHERE s_id = ? {$TI}", $I); $AE = MYSQL::QUERY("SELECT * FROM core_stores_daily_accepts WHERE s_id = ? {$TI}", $I); $WT = MYSQL::QUERY("SELECT * FROM core_stores_daily_walkouts WHERE s_id = ? {$TI}", $I); $CD = MYSQL::QUERY("SELECT * FROM core_stores_daily_checkouts WHERE s_id = ? {$TI}", $I); $RD = MYSQL::QUERY("SELECT * FROM core_stores_daily_repairs WHERE s_id = ? {$TI}", $I); $CC = MYSQL::QUERY("SELECT * FROM core_stores_daily_customers WHERE s_id = ? {$TI}", $I); $STRING = array(array('name' => 'Created Tickets', 'data' => ''), array('name' => 'Accepted Estimates', 'data' => ''), array('name' => 'Walked Out Tickets', 'data' => ''), array('name' => 'Checked Out Tickets', 'data' => ''), array('name' => 'Repaired Devices', 'data' => ''), array('name' => 'Customer Accounts Created', 'data' => '')); if (!$P === false) { foreach ($CT as $CL) { $T = Date_UTC($CL['d_date']); $STRING[0]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $CL['d_key']; } foreach ($AE as $A) { $T = Date_UTC($A['d_date']); $STRING[1]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $A['d_key']; } foreach ($WT as $W) { $T = Date_UTC($W['d_date']); $STRING[2]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $W['d_key']; } foreach ($CD as $C) { $T = Date_UTC($C['d_date']); $STRING[3]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $C['d_key']; } foreach ($RD as $R) { $T = Date_UTC($R['d_date']); $STRING[4]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $R['d_key']; } foreach ($CC as $C) { $T = Date_UTC($C['d_date']); $STRING[5]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $C['d_key']; } } else { $T = Date_UTC($CT['d_date']); $STRING[0]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $CT['d_key']; $STRING[1]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $AE['d_key']; $STRING[2]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $WT['d_key']; $STRING[3]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $CD['d_key']; $STRING[4]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $RD['d_key']; $STRING[5]['data'][] .= $T[0] . "," . $T[1] . "," . $T[2] . "," . $CC['d_key']; } if ($P === false) { $STRING[0]['type'] = 'column'; $STRING[1]['type'] = 'column'; $STRING[2]['type'] = 'column'; $STRING[3]['type'] = 'column'; $STRING[4]['type'] = 'column'; $STRING[5]['type'] = 'column'; } echo JSON_ENCODE($STRING); }