public static function updateRentDemand($rentDemandID, $rentDemandData) { global $db; // check if exists if (RentDemands::getRentDemand($rentDemandID)) { $rentDemandData['employmentRegionFlexibility'] = json_encode($rentDemandData['employmentRegionFlexibility']); return $db->update('rentDemands', $rentDemandData, ['id' => $rentDemandID]); } return -1; }
} }); $this->respond(['GET', 'POST'], '/match-mod/get/assets', function ($request, $response, $service, $app) { $id = $request->param('id'); $result = Assets::getRentDemandMatchingAssets($id); $response->json(Result::success('', $result)); }); $this->respond(['GET', 'POST'], '/match-mod/match', function ($request, $response, $service, $app) { $rentDemandID = $request->param('rentDemandID'); $assetID = $request->param('assetID'); $id = RentProcesses::matchRentDemandAndAsset($rentDemandID, $assetID); if ($id > 0) { $response->json(Result::success('Matched.', ['rentProcessID' => $id])); } else { $response->json(Result::error('Error trying to match')); } }); $this->respond(['GET', 'POST'], '/delete/[:id]', function ($request, $response, $service, $app) { $id = $request->param('id'); $rentDemandResult = RentDemands::deleteRentDemand($id); RentProcesses::deleteRentDemandProcesses($id); if ($rentDemandResult > 0) { $response->json(Result::success('Demand Deleted.')); } else { $response->json(Result::error('Demand not Deleted')); } }); $this->respond(['GET', 'POST'], '/get/all', function ($request, $response, $service, $app) { $result = RentDemands::getAllRentDemands(); $response->json(Result::success('', $result)); });
public static function getRentDemandMatchingAssets($rentDemandID) { global $db; $assets = $db->select('assets', '*'); $rentDemand = RentDemands::getRentDemand($rentDemandID); $matchingAssets = array(); foreach ($assets as $asset) { if (!RentProcesses::isRentDemandExists($asset['id'], $rentDemandID)) { $ans = Assets::isAssetMatching($rentDemand, $asset); if ($ans) { $asset['matchRatio'] = $ans['matchRatio'] . '%'; $asset['matchAvailableDate'] = $ans['availableDate']; $asset['matchPrice'] = $ans['price']; $asset['matchFinishing'] = $ans['finishing']; array_push($matchingAssets, $asset); } } } return $matchingAssets; }