public function addCalendarEvent($postValues){
	    
	    $responseData = array();
	    
	    $calendarTable = $this->getServiceLocator()->get('MelisCalendarTable');
	    $melisCoreAuth = $this->getServiceLocator()->get('MelisCoreAuth');
	    
	    $userAuthDatas =  $melisCoreAuth->getStorage()->read();
	    $userId = (int) $userAuthDatas->usr_id;
	     
	    if (!isset($postValues['cal_id']))
	    {
	         
	        $postValues['cal_date_end'] = $postValues['cal_date_start'];
	        $postValues['cal_date_last_update'] = $postValues['cal_date_start'];
	        $postValues['cal_date_added'] = date('Y-m-d H:i:s');
	        $postValues['cal_last_update_by'] = $userId;
	        $postValues['cal_created_by'] = $userId;
	        
	        $eventId = $calendarTable->save($postValues);
	        
	        $responseData = array(
	            'id' => $eventId,
	            'title' => $postValues['cal_event_title'],
	            'start' => $postValues['cal_date_start'],
	            'end' => $postValues['cal_date_end'],
	        );
	         
	    }
	    else
	    {
	        $resultEvent = $calendarTable->getEntryById($postValues['cal_id']);
	         
	        if (!empty($resultEvent)){
	             
	            $event = $resultEvent->current();
	             
	            if (!empty($event)){
	                
        	        $postValues['cal_last_update_by'] = $userId;
        	        $postValues['cal_date_last_update'] = date('Y-m-d H:i:s');
        	         
        	        $calendarTable->save($postValues,$postValues['cal_id']);
        	         
        	        $responseData = array(
        	            'id' => $postValues['cal_id'],
        	            'title' => $postValues['cal_event_title'],
                    );
	            }
	        }
	    }
	    
	    return $responseData;
	}
public function addCalendarEvent($postValues){
	    
	    $responseData = array();
	    
	    $calendarTable = $this->getServiceLocator()->get('MelisCalendarTable');
	    $melisCoreAuth = $this->getServiceLocator()->get('MelisCoreAuth');
	    
	    $userAuthDatas =  $melisCoreAuth->getStorage()->read();
	    $userId = (int) $userAuthDatas->usr_id;
	     
	    if (!isset($postValues['cal_id']))
	    {
	         
	        $postValues['cal_date_end'] = $postValues['cal_date_start'];
	        $postValues['cal_date_last_update'] = $postValues['cal_date_start'];
	        $postValues['cal_date_added'] = date('Y-m-d H:i:s');
	        $postValues['cal_last_update_by'] = $userId;
	        $postValues['cal_created_by'] = $userId;
	        
	        $eventId = $calendarTable->save($postValues);
	        
	        $responseData = array(
	            'id' => $eventId,
	            'title' => $postValues['cal_event_title'],
	            'start' => $postValues['cal_date_start'],
	            'end' => $postValues['cal_date_end'],
	        );
	         
	    }
	    else
	    {
	        $resultEvent = $calendarTable->getEntryById($postValues['cal_id']);
	         
	        if (!empty($resultEvent)){
	             
	            $event = $resultEvent->current();
	             
	            if (!empty($event)){
	                
        	        $postValues['cal_last_update_by'] = $userId;
        	        $postValues['cal_date_last_update'] = date('Y-m-d H:i:s');
        	         
        	        $calendarTable->save($postValues,$postValues['cal_id']);
        	         
        	        $responseData = array(
        	            'id' => $postValues['cal_id'],
        	            'title' => $postValues['cal_event_title'],
                    );
	            }
	        }
	    }
	    
	    return $responseData;
	}
public function addCalendarEvent ( $ postValues ) { $ responseData = array ( ) ; $ calendarTable = $ this -> getServiceLocator ( ) -> get ( 'MelisCalendarTable' ) ; $ melisCoreAuth = $ this -> getServiceLocator ( ) -> get ( 'MelisCoreAuth' ) ; $ userAuthDatas = $ melisCoreAuth -> getStorage ( ) -> read ( ) ; $ userId = ( int ) $ userAuthDatas -> usr_id ; if ( ! isset ( $ postValues [ 'cal_id' ] ) ) { $ postValues [ 'cal_date_end' ] = $ postValues [ 'cal_date_start' ] ; $ postValues [ 'cal_date_last_update' ] = $ postValues [ 'cal_date_start' ] ; $ postValues [ 'cal_date_added' ] = date ( 'Y-m-d H:i:s' ) ; $ postValues [ 'cal_last_update_by' ] = $ userId ; $ postValues [ 'cal_created_by' ] = $ userId ; $ eventId = $ calendarTable -> save ( $ postValues ) ; $ responseData = array ( 'id' => $ eventId , 'title' => $ postValues [ 'cal_event_title' ] , 'start' => $ postValues [ 'cal_date_start' ] , 'end' => $ postValues [ 'cal_date_end' ] , ) ; } else { $ resultEvent = $ calendarTable -> getEntryById ( $ postValues [ 'cal_id' ] ) ; if ( ! empty ( $ resultEvent ) ) { $ event = $ resultEvent -> current ( ) ; if ( ! empty ( $ event ) ) { $ postValues [ 'cal_last_update_by' ] = $ userId ; $ postValues [ 'cal_date_last_update' ] = date ( 'Y-m-d H:i:s' ) ; $ calendarTable -> save ( $ postValues , $ postValues [ 'cal_id' ] ) ; $ responseData = array ( 'id' => $ postValues [ 'cal_id' ] , 'title' => $ postValues [ 'cal_event_title' ] , ) ; } } } return $ responseData ; }
Adding and Updating Calendar Event

@param array $postValues

if the action is adding new Event, the postValues containing
cal_event_title
cal_date_start
if the action is updating the Event title, the postValues containing
cal_id
cal_event_title
cal_date_start

@return Array
Adding and Updating Calendar Event