public static function getAssetContacts($assetID) { global $db; $contacts = $db->select('assetContacts', ['[><]contacts' => ["contact" => "id"], '[><]assets' => ["asset" => "id"]], ['contacts.id'], ['assets.id' => $assetID]); $toReturn = []; foreach ($contacts as $contact) { array_push($toReturn, Contacts::getContact($contact['id'])); } // Adding investors contacts $assetInvestors = Investors::getAssetInvestors($assetID); foreach ($assetInvestors as $investor) { $investorContacts = Contacts::getInvestorContacts($investor['id']); $toReturn = array_merge($toReturn, $investorContacts); } return array_unique($toReturn, SORT_REGULAR); }
public static function getAssetMatchingInvestmentProfiles($assetID) { global $db; $result = array("matching" => [], "notMatching" => []); $assetRow = $db->get('assets', 'sellingProfile', ['id' => $assetID]); if ($assetRow === false) { return false; } $sellingProfile = json_decode($assetRow, true); $investmentProfileRows = $db->select('investmentProfiles', ['id', 'investmentProfile']); foreach ($investmentProfileRows as $investmentProfileRow) { $investmentProfile = json_decode($investmentProfileRow['investmentProfile'], true); $matchResult = Assets::checkMatch($sellingProfile, $investmentProfile); $toPush = array("id" => $investmentProfileRow['id'], "investor" => Investors::getInvestorFromProfile($investmentProfileRow['id']), "percentage" => $matchResult['percentage'], "reasons" => array("negative" => $matchResult['negativeReasons'], "positive" => $matchResult['positiveReasons']), "matched" => Logs::isLogExists($assetID, $investmentProfileRow['id'])); if ($matchResult['notMatching']) { array_push($result['notMatching'], $toPush); } else { array_push($result['matching'], $toPush); } } return $result; }
public static function getInvestorsForControlPanel() { $investors = Investors::getAllInvestors(); $investorsModified = []; foreach ($investors as $investor) { $lastCallDate = self::getLastCall($investor['id']); $investor['lastCallDate'] = $lastCallDate; $lastCallDate = $lastCallDate ? date_create($lastCallDate) : null; $dominantDate = strtotime($investor['dominantDate']) ? date_create($investor['dominantDate']) : null; $frequency = $investor['communicationFrequency']; $investor['nextCallDate'] = self::calcNextCall($frequency, $dominantDate, $lastCallDate); $investor['nextCallDisplay'] = isset($investor['nextCallDate']) ? date_format($investor['nextCallDate'], 'Y-m-d') : null; array_push($investorsModified, $investor); } usort($investorsModified, function ($a1, $a2) { $v1 = $a1['nextCallDate'] ? date_timestamp_get($a1['nextCallDate']) : null; $v2 = $a2['nextCallDate'] ? date_timestamp_get($a2['nextCallDate']) : null; return $v1 - $v2; // $v2 - $v1 to reverse direction }); return $investorsModified; }
public static function getEmailContactList($field_name) { $Investors['all_investors'] = 'All Investors'; $Entrepreneurs['all_entrepreneurs'] = 'All Entrepreneurs'; $Subscribers['all_subscribers'] = 'All Subscribers'; $contacts = array('Investors', 'Entrepreneurs', 'Subscribers'); foreach ($contacts as $contact) { switch ($contact) { case 'Investors': $listing = Investors::getInvestorslist(); break; case 'Entrepreneurs': $listing = Entrepreneurs::getEntrepreneurslist(); break; case 'Subscribers': $listing = Subscribers::getSubscriberslist(); break; } foreach ($listing as $item) { switch ($contact) { case 'Investors': $Investors[$item->key_] = $item->value; break; case 'Entrepreneurs': $Entrepreneurs[$item->key_] = $item->value; break; case 'Subscribers': $Subscribers[$item->key_] = $item->value; break; } } } $emailList = array('' => 'Select Recipients'); if (count($Subscribers) > 1) { $emailList['Subcscribers'] = array('all_subscribers' => 'All Subcscribers'); } if (count($Investors) > 1) { $emailList['Investors'] = $Investors; } if (count($Entrepreneurs) > 1) { $emailList['Entrepreneurs'] = $Entrepreneurs; } return Form::select($field_name, $emailList, '', array('class' => "form-control")); }
<?php $this->respond(['GET', 'POST'], '/get/crm', function ($request, $response, $service, $app) { $investors = Investors::getInvestorsForControlPanel(); $result = array("investors" => $investors); $response->json(Result::success('', $result)); });
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'])) { header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}"); } header("Content-type: application/vnd.ms-word"); header("Content-Disposition: attachment;Filename=building.doc"); // Load system. require_once __DIR__ . '/../libs/medoo-db/medoo.min.php'; require_once __DIR__ . '/../libs/medoo-db/db.php'; require_once __DIR__ . '/../loader/load-user-system.php'; require_once __DIR__ . '/../loader/load-models.php'; if (!User::isLoggedIn()) { die; } if (isset($_GET['id'])) { $asset = Assets::getAsset($_GET['id']); $investors = Investors::getAssetInvestors($_GET['id']); } else { die; } ?> <html dir="rtl" lang="he"> <head> <meta http-equiv="Content-Type" content="text/html" charset="UTF-8"> <style> <!-- /* Font Definitions */ @font-face { font-family: "Cambria Math"; panose-1: 2 4 5 3 5 4 6 3 2 4; }
} }); $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)); });
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)); });
public static function matchAssetAndInvestmentProfile($assetID, $investmentProfileID, $reasons, $isMatching) { global $db; $investor = Investors::getInvestorFromProfile($investmentProfileID); $reasons = json_encode($reasons); $data = ['asset' => $assetID, 'investmentProfile' => $investmentProfileID, 'investor' => $investor['id'], 'reasons' => $reasons, 'isMatching' => $isMatching, 'processStage' => 'marketing', 'status' => 'alive']; $id = $db->insert('logs', $data); return Logs::getLog($id); }
public static function getInvestmentProfileMatchingAssets($investmentProfileID) { global $db; $result = array("notMatching" => [], "matching" => array("forSale" => [], "notForSale" => [])); $investmentProfileRow = $db->get('investmentProfiles', 'investmentProfile', ['id' => $investmentProfileID]); if ($investmentProfileRow === false) { return false; } $investmentProfile = json_decode($investmentProfileRow, true); $investor = Investors::getInvestorFromProfile($investmentProfileID); $assets = self::getNotInvestorAssets($investor['id']); foreach ($assets as $asset) { $sellingProfile = json_decode($asset['sellingProfile'], true); $matchResult = Assets::checkMatch($sellingProfile, $investmentProfile); $toPush = array("id" => $asset['id'], "name" => $asset['name'], "percentage" => $matchResult['percentage'], "reasons" => array("negative" => $matchResult['negativeReasons'], "positive" => $matchResult['positiveReasons']), "matched" => Logs::isLogExists($asset['id'], $investmentProfileID)); if ($matchResult['notMatching']) { array_push($result['notMatching'], $toPush); } else { if ($asset['isForSale'] == 1) { array_push($result['matching']['forSale'], $toPush); } else { array_push($result['matching']['notForSale'], $toPush); } } } return $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)); });
}); $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')); } });