public static function updateInvestmentProfile($investmentProfileID, $investmentProfileData)
 {
     global $db;
     // check if exists
     if (InvestmentProfiles::getInvestmentProfile($investmentProfileID)) {
         // update summary
         $summary = array();
         foreach ($investmentProfileData['investmentProfile'] as $fieldName => $field) {
             foreach ($field as $option => $pref) {
                 if ($pref != 'נייטרלי') {
                     $summary[$option] = $pref;
                 }
             }
         }
         $investmentProfileData['summary'] = json_encode($summary);
         $investmentProfileData['investmentProfile'] = json_encode($investmentProfileData['investmentProfile']);
         return $db->update('investmentProfiles', $investmentProfileData, ['id' => $investmentProfileID]);
     }
     return -1;
 }
Пример #2
0
<?php

$this->respond(['GET', 'POST'], '/get/matching-assets/[i:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    // assets Matching given InvestmentProfile
    $result = Assets::getInvestmentProfileMatchingAssets($id);
    if ($result) {
        $response->json(Result::success('', $result));
    } else {
        $response->json(Result::error('InvestmentProfile not found'));
    }
});
$this->respond(['GET', 'POST'], '/get/matching-investment-profiles/[i:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    // InvestmentProfiles Matching given asset
    $result = InvestmentProfiles::getAssetMatchingInvestmentProfiles($id);
    if ($result) {
        $response->json(Result::success('', $result));
    } else {
        $response->json(Result::error('Asset not found'));
    }
});
$this->respond(['GET', 'POST'], '/match/asset-and-investment-profile', function ($request, $response, $service, $app) {
    $assetID = $request->param('assetID');
    $investmentProfileID = $request->param('investmentProfileID');
    $reasons = $request->param('reasons');
    $isMatching = $request->param('isMatching');
    if (Logs::isLogAlreadyConnectedToInvestor($assetID, $investmentProfileID)) {
        $response->json(Result::error('קיים כבר לוג בין המשקיע לנכס'));
    } else {
        $result = Logs::matchAssetAndInvestmentProfile($assetID, $investmentProfileID, $reasons, $isMatching);
Пример #3
0
    Notes::deleteInvestorNotes($id);
    Assets::deleteInvestorAssets($id);
    Logs::deleteInvestorLogs($id);
    Contacts::deleteInvestorContacts($id);
    if ($investorResult > 0) {
        $response->json(Result::success('Investor Deleted.'));
    } else {
        $response->json(Result::error('Investor not Deleted'));
    }
});
$this->respond(['GET', 'POST'], '/get/[i:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $investorData = Investors::getInvestor($id);
    $investorContacts = Contacts::getInvestorContacts($id);
    $investorAssets = Assets::getInvestorAssets($id);
    $investorProfiles = InvestmentProfiles::getInvestorProfiles($id);
    $investorBuyLogs = Logs::getInvestorLogs($id);
    $investorSellLogs = Logs::getInvestorAssetsLogs($id);
    $investorConversations = Conversations::getInvestorConversations($id);
    $investorNotes = Notes::getInvestorNotes($id);
    $result = array("investorData" => $investorData, "investorContacts" => $investorContacts, "investorAssets" => $investorAssets, "investorProfiles" => $investorProfiles, "investorBuyLogs" => $investorBuyLogs, "investorSellLogs" => $investorSellLogs, "investorConversations" => $investorConversations, "investorNotes" => $investorNotes);
    if ($investorData) {
        $response->json(Result::success('', $result));
    } else {
        $response->json(Result::error('Investor not found'));
    }
});
$this->respond(['GET', 'POST'], '/get/all', function ($request, $response, $service, $app) {
    $result = Investors::getAllInvestors();
    $response->json(Result::success('', $result));
});
});
$this->respond(['GET', 'POST'], '/edit/[:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $data = json_decode($request->body(), true);
    $result = InvestmentProfiles::updateInvestmentProfile($id, $data);
    if ($result > 0) {
        $response->json(Result::success('InvestmentProfile Updated.'));
    } elseif ($result === 0) {
        $response->json(Result::success('InvestmentProfile not Updated.'));
    } else {
        $response->json(Result::error('InvestmentProfile not found'));
    }
});
$this->respond(['GET', 'POST'], '/delete/[:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $result = InvestmentProfiles::deleteInvestmentProfile($id);
    if ($result > 0) {
        $response->json(Result::success('InvestmentProfile Deleted.'));
    } else {
        $response->json(Result::error('InvestmentProfile not Deleted'));
    }
});
$this->respond(['GET', 'POST'], '/get-investor-from-profile/[:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $result = Investors::getInvestorFromProfile($id);
    if ($result > 0) {
        $response->json(Result::success('', $result));
    } else {
        $response->json(Result::error('Investor not found'));
    }
});