示例#1
0
 public static function updateRentArea($rentAreaID, $rentAreaData)
 {
     global $db;
     // check if exists
     if (RentAreas::getRentArea($rentAreaID)) {
         return $db->update('rentAreas', $rentAreaData, ['id' => $rentAreaID]);
     }
     return -1;
 }
示例#2
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));
});
    $id = $request->param('id');
    $assetData = $request->param('assetData');
    $contactsData = $request->param('assetContacts');
    $investorsData = $request->param('assetInvestors');
    $result = Assets::updateAssetInvest($id, $assetData, $contactsData, $investorsData);
    if ($result > 0) {
        $response->json(Result::success('Asset Updated.'));
    } elseif ($result === 0) {
        $response->json(Result::success('Asset not Updated.'));
    } else {
        $response->json(Result::error('Asset not found'));
    }
});
$this->respond(['GET', 'POST'], '/delete/[:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $assetResult = Assets::deleteAsset($id);
    Logs::deleteAssetInvestLogs($id);
    Contacts::deleteAssetContacts($id);
    Investors::deleteAssetInvestors($id);
    RentAreas::deleteAssetRentAreas($id);
    RentProcesses::deleteAssetRentProcesses($id);
    if ($assetResult > 0) {
        $response->json(Result::success('Asset Deleted.'));
    } else {
        $response->json(Result::error('Asset not Deleted'));
    }
});
$this->respond(['GET', 'POST'], '/get/all', function ($request, $response, $service, $app) {
    $result = Assets::getAllAssets();
    $response->json(Result::success('', $result));
});
示例#4
0
 private static function isAssetMatching($rentDemand, $asset)
 {
     // check employmentRegion
     if (!empty($rentDemand['employmentRegion']) && $rentDemand['employmentRegion'] != $asset['employmentRegion']) {
         $empRegionFlexList = json_decode($rentDemand['employmentRegionFlexibility'], true);
         if (!empty($empRegionFlexList)) {
             $foundEquals = false;
             foreach ($empRegionFlexList as $empRegionFlex) {
                 if ($empRegionFlex == $asset['employmentRegion']) {
                     $foundEquals = true;
                     break;
                 }
             }
             if (!$foundEquals) {
                 return false;
             }
         } else {
             return false;
         }
     }
     // check if at least one rentArea is matching
     $rentAreas = RentAreas::getAssetRentAreas($asset['id']);
     $availableCount = 0;
     $matchingCount = 0;
     $ans = array();
     $isMatching = false;
     foreach ($rentAreas as $rentArea) {
         $availableCount++;
         if (Assets::isRentAreaMatching($rentDemand, $rentArea)) {
             $matchingCount++;
             // getting from first match
             if (!$isMatching) {
                 $ans['availableDate'] = $rentArea['populating'];
                 $ans['price'] = $rentArea['price'];
                 $ans['finishing'] = $rentArea['finishing'];
             }
             $isMatching = true;
         }
     }
     if (!$isMatching) {
         return $isMatching;
     } else {
         $ans['matchRatio'] = $availableCount == 0 ? 0 : $matchingCount / $availableCount * 100;
         return $ans;
     }
 }
示例#5
0
});
$this->respond(['GET', 'POST'], '/get/[i:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $result = RentAreas::getRentArea($id);
    if ($result) {
        $response->json(Result::success('', $result));
    } else {
        $response->json(Result::error('RentArea not found'));
    }
});
$this->respond(['GET', 'POST'], '/edit/[:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $data = json_decode($request->body());
    $result = RentAreas::updateRentArea($id, $data);
    if ($result > 0) {
        $response->json(Result::success('RentArea Updated.'));
    } elseif ($result === 0) {
        $response->json(Result::success('RentArea not Updated.'));
    } else {
        $response->json(Result::error('RentArea not found'));
    }
});
$this->respond(['GET', 'POST'], '/delete/[:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $result = RentAreas::deleteRentArea($id);
    if ($result > 0) {
        $response->json(Result::success('RentArea Deleted.'));
    } else {
        $response->json(Result::error('RentArea not Deleted'));
    }
});