Exemplo n.º 1
0
 public function buildDashboard()
 {
     $this->setDashboardTitle("Stock Dashboard");
     $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'] / 10, 'numberSuffix' => ' units', 'numberHumanize' => true));
     }
     $this->addComponent($kpi);
     $kpi1 = new KPIGroupComponent('kpi1');
     $kpi1->setDimensions(12, 2);
     // $kpi1->setCaption('Units stock by Category');
     $Units = $this->get_units(false);
     foreach ($Units as $key => $value) {
         $kpi1->addKPI($value['id'], array('caption' => $value['CategoryName'], 'value' => $value['Quantity'], 'numberSuffix' => ' units', 'numberHumanize' => true));
     }
     $this->addComponent($kpi1);
     $table = new TableComponent('table');
     $table->setCaption("List of Item in Stock");
     $table->setDimensions(6, 4);
     $stock = $this->get_stock();
     $table->addColumn('id', 'Product Id');
     $table->addColumn('name', 'Product Name');
     $table->addColumn('category', 'Category');
     $table->addColumn('price', 'Price');
     $table->addColumn('stock', 'Stock');
     $table->addMultipleRows($this->PolulateData($stock));
     $this->addComponent($table);
     $c12 = new FilterComponent('filter');
     $c12->setDimensions(6, 6);
     $c12->setCaption('Filter items in stock');
     $category = $this->get_category();
     $c12->addSelectFilter('category', 'Select Category', array_merge(['no selection'], ArrayUtils::pluck($category, 'CategoryName')));
     $c12->addTextFilter('contains', 'Product Name Contains');
     $c12->addNumericRangeFilter('stock', 'Units In Stock', array(0, 100));
     $this->addComponent($c12);
     $c12->onApplyClick(array($table), 'handleApply', $this);
 }