added units used to Preorder
This commit is contained in:
@@ -80,6 +80,25 @@ class Building extends mfBaseModel {
|
||||
return $code;
|
||||
}
|
||||
|
||||
public function getUsedTerminationCount($includePreorders = false) {
|
||||
if(!$this->id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
|
||||
$orders = OrderModel::search(['building_id' => $this->id]);
|
||||
$count += count($orders);
|
||||
|
||||
if($includePreorders) {
|
||||
$preorders = PreorderModel::search(['building_id' => $this->id]);
|
||||
$count += count($preorders);
|
||||
}
|
||||
|
||||
return $count;
|
||||
|
||||
}
|
||||
|
||||
public function loadWorkflowItems() {
|
||||
$item_ids = [];
|
||||
|
||||
|
||||
@@ -294,10 +294,10 @@ class BuildingController extends mfBaseController {
|
||||
$data['email'] = $building->email;
|
||||
}
|
||||
/*
|
||||
// no more lineworker_id in Termination
|
||||
if($building->lineworker_id) {
|
||||
$data['lineworker_id'] = $building->lineworker_id;
|
||||
}*/
|
||||
// no more lineworker_id in Termination
|
||||
if($building->lineworker_id) {
|
||||
$data['lineworker_id'] = $building->lineworker_id;
|
||||
}*/
|
||||
if($building->oan_id) {
|
||||
$data['oan_id'] = $building->oan_id. "." . sprintf("%03d", $i);
|
||||
}
|
||||
@@ -418,6 +418,7 @@ class BuildingController extends mfBaseController {
|
||||
$u['oan_id'] = $building->oan_id;
|
||||
$u['code'] = $building->code;
|
||||
$u['units'] = ($building->units) ? $building->units : 1;
|
||||
$u['units_used'] = $building->getUsedTerminationCount(true);
|
||||
$u['status'] = $building->status->name;
|
||||
$unsorted[$building->street."-".$building->id] = $u;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user