Esempio n. 1
0
 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;
 }
Esempio n. 2
0
    }
});
$this->respond(['GET', 'POST'], '/watch-mod/get/[i:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $rentDemandData = RentDemands::getRentDemand($id);
    $processes = RentProcesses::getRentDemandProcesses($id);
    $result = array("rentDemandData" => $rentDemandData, "processes" => $processes);
    if ($result) {
        $response->json(Result::success('', $result));
    } else {
        $response->json(Result::error('RentDemand not found'));
    }
});
$this->respond(['GET', 'POST'], '/match-mod/get/[i:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $result = RentDemands::getRentDemand($id);
    if ($result) {
        $response->json(Result::success('', $result));
    } else {
        $response->json(Result::error('RentDemand not found'));
    }
});
$this->respond(['GET', 'POST'], '/match-mod/edit/[:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $data = json_decode($request->body(), true);
    $result = RentDemands::updateRentDemand($id, $data);
    if ($result > 0) {
        $response->json(Result::success('RentDemand Updated.'));
    } elseif ($result === 0) {
        $response->json(Result::success('RentDemand not Updated.'));
    } else {
Esempio n. 3
0
 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;
 }