53 lines
1.3 KiB
PHP
53 lines
1.3 KiB
PHP
<?php
|
|
include ('includes/config/config.php');
|
|
include ('includes/functions.php');
|
|
|
|
$days = $_GET['days'];
|
|
$durationClause = "";
|
|
if ($days == 30) {}
|
|
|
|
$data = array();
|
|
$colors = array(
|
|
"#477def",
|
|
"#31f748",
|
|
"#e8277a",
|
|
"#f2e33e",
|
|
"#05b708",
|
|
"#2091CF",
|
|
"#FEE074",
|
|
"#8a1bf9",
|
|
"#AF4E96",
|
|
"#3cd2e0"
|
|
);
|
|
$query = "select item_id, sum(issued_qty) issued_qty from appointment_stock_history group by item_id order by sum(issued_qty) desc limit 10 ";
|
|
if (! $result = @mysqli_query($conn,$query)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
$x = 0;
|
|
$sum = 0;
|
|
if (mysqli_num_rows($result) > 0) {
|
|
while ($row = mysqli_fetch_assoc($result)) {
|
|
$data[$x]['data'] = $row['issued_qty'];
|
|
$sum += $row['issued_qty'];
|
|
$data[$x]['color'] = $colors[$x];
|
|
$data[$x]['label'] = getTableFieldValue('tbl_items', 'item_name', 'item_id', $row['item_id'], '');
|
|
$x ++;
|
|
}
|
|
}
|
|
$total =0;
|
|
$remaining =0;
|
|
$query = "select sum(issued_qty) issued_qty from appointment_stock_history ";
|
|
if (! $result = @mysqli_query($conn,$query)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
if (mysqli_num_rows($result) > 0) {
|
|
if ($row = mysqli_fetch_assoc($result)) {
|
|
$total = $row['issued_qty'];
|
|
}
|
|
}
|
|
$data[$x]['data'] = $total-$sum;
|
|
$data[$x]['color'] = "#eeeeee";
|
|
$data[$x]['label'] ='Others';
|
|
echo json_encode($data);
|
|
?>
|