<?php
/*+***********************************************************************************
 * The contents of this file are subject to the vtiger CRM Public License Version 1.0
 * ("License"); You may not use this file except in compliance with the License
 * The Original Code is:  vtiger CRM Open Source
 * The Initial Developer of the Original Code is vtiger.
 * Portions created by vtiger are Copyright (C) vtiger.
 * All Rights Reserved.
 *************************************************************************************/
/*ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
*/
class Users_ObtenerUsuariosAsignados_Action extends Vtiger_IndexAjax_View {
	

	public function requiresPermission(Vtiger_Request $request) {
		#die("entro");
		$permissions = parent::requiresPermission($request);
		$permissions[] = array('module_parameter' => 'module', 'action' => 'DetailView');
		return true;
	}

	public function process(Vtiger_Request $request) {
		global $adb, $current_customer, $current_user;
		
		$userId = $request->get("recordId");
		$sql = $adb->pquery('SELECT group_concat(id) ids from vtiger_users WHERE reports_to_id ='.$userId);
		$resultData = $adb->query_result($sql,0,'ids');
		#var_dump($resultData); die;
	    $response = new Vtiger_Response();
		$response->setResult(array('success'=>true, 'data'=> $resultData));
		$response->emit();
	}
}
