Orders
Order Quantity
33
153.85% Increase
Order Amount
$979,292
Order Status
326
- Shipped - 90.8%
- Resolved - 2.8%
- In Process - 2.1%
- Others - 4.3%
Order Number | Customer | Order Date | Shipped Date | Status | ||
---|---|---|---|---|---|---|
10100 | Omkarms5 | January 25, 2025 | November 30, 2024 | Shipped | ||
10101 | Technics | January 17, 2025 | January 17, 2025 | Shipped | ||
10102 | Vitachrome Inc. | January 10, 2023 | January 14, 2023 | Shipped | ||
10103 | ddd | January 29, 2023 | February 2, 2023 | Shipped | ||
10104 | Euro+ Shopping Channel | January 31, 2023 | February 1, 2023 | Shipped | ||
10105 | Danish Wholesale Imports | February 10, 2023 | February 12, 2023 | Resolved | ||
10106 | Rovelli Gifts | February 17, 2023 | February 21, 2023 | Shipped | ||
10107 | Land of Toys Inc. | February 28, 2023 | February 26, 2023 | Resolved | ||
10108 | Cruz & Sons Co. | March 3, 2023 | March 8, 2023 | Shipped | ||
10109 | Motor Mint Distributors Inc. | March 10, 2023 | March 11, 2023 | Shipped |
Admin Panel is a new feature of Dashboard Framework which can help to contruct beautiful dashboard admin panel. Setting up different views of your data, applying data search & filter, adding custom actions on your data are all possible.
This example demonstrates creating Order
resource to manage your orders table.
<?php
namespace demo\admin\order;
use demo\admin\customer\Customer;
use koolreport\dashboard\admin\glasses\Glass;
use koolreport\dashboard\fields\Currency;
use koolreport\dashboard\fields\ID;
use koolreport\dashboard\fields\RelationLink;
class MostValuedOrders extends Glass
{
protected function onCreated()
{
$this->type("success")
->icon("fas fa-sort-amount-up");
}
protected function query($query)
{
$query
->join("customers","orders.customerNumber","=","customers.customerNumber")
->join("orderdetails","orders.orderNumber","=","orderdetails.orderNumber")
->select("orders.orderNumber","customerName","orders.customerNumber")
->sum("quantityOrdered * priceEach")->alias("orderedAmount")
->groupBy("orders.orderNumber")
->orderBy("orderedAmount","desc");
return $query;
}
protected function fields()
{
return [
ID::create("orderNumber"),
RelationLink::create("customerNumber")->label("Customer Name")
->formatUsing(function($value,$row){
return $row["customerName"];
})
->linkTo(Customer::class),
Currency::create("orderedAmount")
->USD()->symbol()
];
}
}
<?php
namespace demo\admin\order;
use demo\admin\customer\Customer;
use demo\AdminAutoMaker;
use koolreport\dashboard\admin\relations\HasMany;
use koolreport\dashboard\admin\Resource;
use koolreport\dashboard\fields\Badge;
use koolreport\dashboard\fields\Date;
use koolreport\dashboard\fields\ID;
use koolreport\dashboard\fields\Number;
use koolreport\dashboard\fields\RelationLink;
use koolreport\dashboard\fields\Text;
use koolreport\dashboard\inputs\Select;
class Order extends Resource
{
protected function onCreated()
{
$this->manageTable("orders")->inSource(AdminAutoMaker::class);
}
protected function query($query)
{
$query->leftJoin("customers","orders.customerNumber","=","customers.customerNumber")
->select("orderNumber","orderDate","shippedDate","status")
->select("customerName")
->select("orders.customerNumber");
return $query;
}
protected function relations()
{
return [
HasMany::resource(OrderDetail::class)
->link(["orderNumber"=>"orderNumber"])
];
}
protected function glasses()
{
return [
MostValuedOrders::create(),
];
}
protected function fields()
{
return [
ID::create("orderNumber"),
RelationLink::create("customerNumber")
->label("Customer")
->formatUsing(function($value,$row){
return $row["customerName"];
})
->linkTo(Customer::class)
->inputWidget(
Select::create()
->dataSource(function(){
return AdminAutoMaker::table("customers")
->select("customerNumber","customerName");
})
->fields(function(){
return [
Number::create("customerNumber"),
Text::create("customerName"),
];
})
),
Date::create("orderDate")
->displayFormat("F j, Y"),
Date::create("shippedDate")
->allowNullValue(true)
->displayFormat("F j, Y"),
Badge::create("status")
->type(function($status){
switch($status){
case "Shipped":
case "Resolved":
return "success";
case "Cancelled":
case "Disputed":
return "danger";
case "On Hold":
return "warning";
case "In Process":
return "info";
default:
return "default";
}
})
->sortable(true)
->inputWidget(
Select::create()
->dataSource(function(){
return AdminAutoMaker::table("orders")->select("status")->distinct();
})
->fields(function(){
return [
Text::create("status")
];
})
)
];
}
protected function highlights()
{
return [
OrderQuantity::create(),
OrderAmount::create(),
OrderStatus::create(),
];
}
/**
* The bottom is where you can put extra widgets,
* Here we just put the CodeDemo to show our demo code
* which is not important in your real application.
* @return array
*/
protected function bottom()
{
return [
\demo\CodeDemo::create("
Admin Panel is a new feature of Dashboard Framework which can help to contruct beautiful dashboard
admin panel. Setting up different views of your data, applying data search & filter, adding custom
actions on your data are all possible.
<p>
This example demonstrates creating <code>Order</code> resource to manage your orders table.
</p>
")->raw(true)
];
}
}
<?php
namespace demo\admin\order;
use \koolreport\dashboard\metrics\Trend;
use \demo\AdminAutoMaker;
use \koolreport\dashboard\fields\Date;
use \koolreport\dashboard\fields\Currency;
class OrderAmount extends Trend
{
protected function onInit()
{
$this
->type("warning")
->defaultRange("This Month");
}
protected function dataSource()
{
return AdminAutoMaker::rawSQL("
SELECT
orderDate,
orderdetails.priceEach*orderdetails.quantityOrdered AS total
FROM
orders
JOIN
orderdetails
ON
orders.orderNumber = orderdetails.orderNumber
");
}
protected function ranges()
{
return [
"This Week"=>$this::thisWeek(),
"Last 7 Days"=>$this::last7days(),
"Last 30 Days"=>$this::last30days(),
"This Month"=>$this::thisMonth(),
"This Quarter"=>$this::thisQuarter(),
"This Year"=>$this::thisYear(),
];
}
protected function fields()
{
return [
$this->group(Date::create("orderDate")),
$this->sum(
Currency::create("total")
->USD()
->symbol()
->decimals(0)
)
];
}
}
<?php
namespace demo\admin\order;
use demo\admin\product\Product;
use demo\AdminAutoMaker;
use koolreport\dashboard\admin\Resource;
use koolreport\dashboard\fields\Currency;
use koolreport\dashboard\fields\ID;
use koolreport\dashboard\fields\Number;
use koolreport\dashboard\fields\RelationLink;
class OrderDetail extends Resource
{
protected function onCreated()
{
$this->manageTable("orderdetails")->inSource(AdminAutoMaker::class);
$this->listScreen()->relationTable()
->rowActionsField(null)
->showFooter(true);
}
protected function query($query)
{
$query->join("products","orderdetails.productCode","=","products.productCode")
->select("productName")
->select("orderdetails.orderNumber","orderdetails.productCode")
->select("quantityOrdered","priceEach")
->select("quantityOrdered * priceEach")->alias("total");
return $query;
}
protected function fields()
{
return [
ID::create("orderNumber"),
RelationLink::create("productCode")->label("Product")
->formatUsing(function($value, $row){
return $row["productName"];
})
->linkTo(Product::class),
Number::create("quantityOrdered"),
Currency::create("priceEach")->USD()->symbol(),
Currency::create("total")->USD()->symbol()->footer("sum"),
];
}
}
<?php
namespace demo\admin\order;
use \koolreport\dashboard\metrics\Value;
use \demo\AdminAutoMaker;
use \koolreport\dashboard\fields\Date;
use \koolreport\dashboard\fields\Text;
class OrderQuantity extends Value
{
protected function onInit()
{
$this
->type("primary")
->defaultRange("This Month");
}
protected function dataSource()
{
return AdminAutoMaker::table("orders")
->select("orderDate");
}
protected function ranges()
{
return [
"This Week"=>$this::thisWeek(),
"Last 7 Days"=>$this::last7days(),
"Last 30 Days"=>$this::last30days(),
"This Month"=>$this::thisMonth(),
"This Quarter"=>$this::thisQuarter(),
"This Year"=>$this::thisYear(),
];
}
protected function fields()
{
return [
Date::create("orderDate"),
$this->count(
Text::create("orderDate")
)
];
}
}
<?php
namespace demo\admin\order;
use \koolreport\dashboard\metrics\Category;
use \demo\AdminAutoMaker;
use \koolreport\dashboard\fields\Text;
class OrderStatus extends Category
{
protected function onCreated()
{
$this->type("danger");
}
protected function dataSource()
{
return AdminAutoMaker::table("orders")
->select("status");
}
protected function fields()
{
return [
$this->group(Text::create("status"))->showTop(3)->andShowOthers(),
$this->count(Text::create("status"))
];
}
}