<?php
	
//////////////////////////////////////////////////////////////////
//
//	acc_organizations
//
/////////////////////////////////////////////////////////////////

	$select_acc_org = function($_p) {
    	if (isset($_POST['data']) && isset($_COOKIE)) {
    		$data = json_decode($_POST['data'], true);
			if(isset($data["org_id"]) && isset($_COOKIE['user_account'])) {
				require_once '../../../library_html/properties/core/dat/dat_properties.php';
				$org_id = $data["org_id"];
    			$user = $_COOKIE['user_account'];
    			$dat = new dat_user_accounts();
    			$result = $dat->select_user_accounts(["email_address"=>$user]);
    			if (count($result) > 0) {
					$dat = new dat_properties();
					$comp = $dat->insert_settings(["user_id"=>$result[0]['user_id'], "property"=>"ACC_SEL_ORG", "setting"=>$org_id]);
				} else {
					//do nothing
				}
			} else {
				// do nothing
			}
		}
    };

	$postIndex = [
		'select_acc_org'=>	$select_acc_org,
	];
?>