public function buildDashboard()
 {
     $this->setDashboardTitle("Stock Dashboard");
     $this->setActionPath("/static/transfer/build/tour/motherboard_stock_action.php");
     $kpi = new KPIGroupComponent('kpi');
     $kpi->setDimensions(12, 2);
     $kpi->setCaption('Units stock by Category');
     $Units = $this->get_units(true);
     foreach ($Units as $key => $value) {
         $kpi->addKPI($value['id'], array('caption' => $value['CategoryName'], 'value' => $value['Quantity'], 'numberSuffix' => ' units', 'numberHumanize' => true));
     }
     $this->addComponent($kpi);
     $table = new TableComponent('table');
     $table->setCaption("List of Item in Stock");
     $table->setDimensions(6, 5);
     $stock = $this->get_stock();
     $table->addColumn('id', 'Product Id');
     $table->addColumn('name', 'Product Name');
     $table->addColumn('category', 'Category');
     $table->addColumn('price', 'Price', array("numberPrefix" => "\$", "dataType" => "number"));
     $table->addColumn('stock', 'Stock');
     $table->addMultipleRows($this->PolulateData($stock));
     $this->addComponent($table);
     $c12 = new FormComponent('filter');
     $c12->setDimensions(6, 5);
     $c12->setCaption('Filter items in stock');
     $category = $this->get_category();
     $c12->addSelectField('category', 'Select Category', array_merge(['no selection'], ArrayUtils::pluck($category, 'CategoryName')));
     $c12->addTextField('contains', 'Product Name Contains');
     $c12->addNumericRangeField('stock', 'Units In Stock', array(0, 100));
     $this->addComponent($c12);
     $c12->onApplyClick(array($table), 'handleApply', $this);
 }
 public function get_cities($source, $target, $params)
 {
     $cityDataQuery = $this->pdo->prepare("SELECT SUM(amount) as total_amount, city FROM Payments NATURAL JOIN Customers where Customers.state = :paymentState GROUP BY city;");
     $cityDataQuery->execute(array('paymentState' => $params['label']));
     $cityData = $cityDataQuery->fetchAll(PDO::FETCH_ASSOC);
     $source->clearChart();
     $source->setLabels(ArrayUtils::pluck($cityData, 'city'));
     $source->addSeries("sales", "Sales", ArrayUtils::pluck($cityData, "total_amount"), array('numberPrefix' => "\$"));
 }
Exemple #3
0
 public function handleArtistChartClick($source, $target, $params)
 {
     $artistName = $params['label'];
     $topAlbumsChart = $this->getComponentByID("c2");
     $top_albums = $this->getTopAlbums($artistName);
     $topAlbumsChart->setCaption("Top 5 albums by " . $artistName);
     $topAlbumsChart->clearChart();
     $topAlbumsChart->setLabels(ArrayUtils::pluck($top_albums, "Title"));
     $topAlbumsChart->addSeries('top_albums', "Top Albums", ArrayUtils::pluck($top_albums, "total_sales"));
 }
Exemple #4
0
 public function get_daywise($source, $target, $params)
 {
     $month = array_search($params['label'], $this->monthName);
     $daywiseQuery = $this->pdo->prepare("SELECT SUM(UnitPrice * Quantity) as total_amount, strftime('%d', OrderDate) as payment_day FROM 'Order' as o, 'OrderDetail' as od where o.Id = od.OrderId and strftime('%Y', OrderDate)=:paymentYear and strftime('%m', OrderDate)=:paymentMonth GROUP BY payment_day;");
     $daywiseQuery->execute(array('paymentYear' => $params['drillLabelList'][0], 'paymentMonth' => $month));
     $daywise = $daywiseQuery->fetchAll(PDO::FETCH_ASSOC);
     $source->clearChart();
     $source->setLabels(ArrayUtils::pluck($daywise, 'payment_day'));
     $totalSalesArr = ArrayUtils::pluck($daywise, "total_amount");
     $source->addSeries("sales", "Sales", $totalSalesArr, array('numberPrefix' => "\$"));
     $totalSales = 0;
     foreach ($totalSalesArr as $key => $value) {
         $totalSales += $value;
     }
     $source->addComponentKPI("sales", array("caption" => "Total Sales", "value" => $totalSales, "numberPrefix" => "\$", "numberHumanize" => true));
     $source->addComponentKPI("second", array("caption" => "Revenue", "value" => $totalSales, "numberPrefix" => "\$", "numberHumanize" => true));
 }
 public function handleForm($source, $target, $params)
 {
     $Date = $source->getInputValue('datebtw');
     $dateStartArray = date_parse($Date[0]);
     $dateEndArray = date_parse($Date[1]);
     $dailySales = $this->getComponentByID("c1");
     $item = $this->getComponentByID("c3");
     $chart = $this->getComponentByID("pie_chart");
     $hour = $this->getComponentByID("c4");
     $dateStartString = $dateStartArray['year'] . '-' . $dateStartArray['month'] . '-' . $dateStartArray['day'];
     $dateEndString = $dateEndArray['year'] . '-' . $dateEndArray['month'] . '-' . $dateEndArray['day'];
     $dailySalesData = $this->getDailySales($dateStartString, $dateEndString);
     $dailySales->setLabels(ArrayUtils::pluck($dailySalesData, "tarih2"));
     $dailySales->addSeries('food', "Food", ArrayUtils::pluck($dailySalesData, "cikis"), array("numberHumanize" => true));
     $dailySalesFoodData = $this->getDailySalesFood($dateStartString, $dateEndString);
     $dailySales->addSeries('covers', "Covers", ArrayUtils::pluck($dailySalesFoodData, "cikis"), array("numberHumanize" => true, "yAxis" => "covers"));
     $itemCategories = $this->getItemCategories($dateStartString, $dateEndString);
     $item->setLabels(ArrayUtils::pluck($itemCategories, "grupadi"));
     $item->addSeries('items', "Items", ArrayUtils::pluck($itemCategories, "cikis"), array("numberHumanize" => true));
     $clerkData = $this->getClerkSales($dateStartString, $dateEndString);
     $chart->setLabels(ArrayUtils::pluck($clerkData, "garson"));
     $chart->setPieValues(ArrayUtils::pluck($clerkData, "cikis"));
     $hourlySales = $this->getHourlySales($dateStartString, $dateEndString);
     $hour->setLabels(ArrayUtils::pluck($hourlySales, "SAAT"));
     $hour->addSeries('items', "Items", ArrayUtils::pluck($hourlySales, "CIKIS"), array("numberHumanize" => true));
 }