예제 #1
0
    /**
     * Get Dashboard Data by UserUid
     *
     * @param string $usr_uid Unique id of User
     *
     * return uid
     *
     * @author Jenny Murillo <*****@*****.**>
     */
    public function getDashboardDataByUser($usr_uid)
    {
        $resp = array();
        $dashboards = $this->getDashboardsUidByUser($usr_uid);
        $existFavorite = false;
		$cont = 0;
        foreach($dashboards as $i=>$x) {
            //$resp[$i] = $this->getDashboard($x['DAS_UID']);
            $dashboardUser = $this->getDashboard($x['DAS_UID']);
            if ($dashboardUser['DAS_STATUS'] == 0) {
                continue;
            }
            $resp[$cont] = $dashboardUser;
            $Dashboard = new \ProcessMaker\BusinessModel\Dashboard();
            $dashConfig = $Dashboard->getConfig($usr_uid);
            $resp[$cont]['DAS_FAVORITE'] = 0;
            foreach ($dashConfig as $dashId=>$dashData) {
                if($dashId == $x['DAS_UID'] ) {
                    $resp[$cont]['DAS_FAVORITE'] = $dashData['dashFavorite'];
                    if ($dashData['dashFavorite']==1) {
                        $existFavorite = true;
                    }
                }
            }
			$cont++;
        }
        //if no favorite is set, the default favorite is the first one
        if ($existFavorite == false && $resp != null &&  sizeof($resp)>0) {
            $resp[0]['DAS_FAVORITE'] = 1;
        }
        return $resp;
    }
예제 #2
0
 /**
  * Put dashboards configuration by usr_uid
  *
  * @param array $request_data
  *
  * @author Jenny Murillo <*****@*****.**>
  * @copyright Colosa - Bolivia
  *
  * @url PUT /config
  *
  */
 public function doPutDashboardConfigByUsrUid($request_data)
 {
 	try {
 		$usrUid = $this->getUserId();
 
 		$ConfigDashboards = new \ProcessMaker\BusinessModel\Dashboard();
 		$response = $ConfigDashboards->putConfigByUsr($request_data, $usrUid);
 		return $response;
 	} catch (\Exception $e) {
 		throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
 	}
 }