Пример #1
0
 public static function getRentDemandProcesses($rentDemandID)
 {
     global $db;
     $processes = $db->select('rentProcesses', '*', ['rentDemand' => $rentDemandID]);
     $ans = [];
     foreach ($processes as $process) {
         $process['assetName'] = Assets::getAsset($process['asset'])['name'];
         $assetContacts = Contacts::getAssetContacts($process['asset']);
         if (!empty($assetContacts)) {
             $process['assetContact'] = $assetContacts[0]['fullName'];
             $process['assetPhone'] = $assetContacts[0]['mobilePhone'];
         }
         array_push($ans, $process);
     }
     return $ans;
 }
Пример #2
0
 private static function setCalculatedFields($asset)
 {
     $asset['totalArea'] = RentAreas::getAssetTotalRentAreas($asset['id']);
     $asset['available'] = RentAreas::getAssetTotalAvailableRentAreas($asset['id']);
     $asset['populatePercentage'] = $asset['totalArea'] == 0 ? 0 : number_format($asset['available'] / $asset['totalArea'] * 100, 2);
     $contacts = Contacts::getAssetContacts($asset['id']);
     if (count($contacts)) {
         $firstContact = $contacts[0];
         $asset['assetContact'] = $firstContact['fullName'];
         $asset['contactPhone'] = $firstContact['mobilePhone'];
     }
     $asset['alive'] = RentProcesses::getAssetTotalRentProcessesWithStatus($asset['id'], 'חי');
     $asset['closed'] = RentProcesses::getAssetTotalRentProcessesWithStatus($asset['id'], 'סגור');
     $asset['failed'] = RentProcesses::getAssetTotalRentProcessesWithStatus($asset['id'], 'נכשל');
     $asset['picture'] = $asset['floorPicture'];
     return $asset;
 }
Пример #3
0
    }
});
$this->respond(['GET', 'POST'], '/get/[i:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $assetData = Assets::getAsset($id);
    $assetInvestors = Investors::getAssetInvestors($id);
    $result = array("assetData" => $assetData, "assetInvestors" => $assetInvestors);
    if ($assetData) {
        $response->json(Result::success('', $result));
    } else {
        $response->json(Result::error('Asset not found'));
    }
});
$this->respond(['GET', 'POST'], '/get-for-edit/[i:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $assetData = Assets::getAsset($id);
    $assetContacts = Contacts::getAssetContacts($id);
    $assetInvestors = Investors::getAssetInvestors($id);
    $assetAreas = RentAreas::getAssetRentAreas($id);
    $assetProcesses = RentProcesses::getAssetRentProcesses($id);
    $result = array("assetData" => $assetData, "assetContacts" => $assetContacts, "assetInvestors" => $assetInvestors, "assetAreas" => $assetAreas, "assetProcesses" => $assetProcesses);
    if ($assetData) {
        $response->json(Result::success('', $result));
    } else {
        $response->json(Result::error('Asset not found'));
    }
});
$this->respond(['GET', 'POST'], '/get/all', function ($request, $response, $service, $app) {
    $result = Assets::getAllAssets();
    $response->json(Result::success('', $result));
});