public function testUpdateExpenseControlVoiceOneSim()
 {
     $data = array('voice' => array('enabled' => true, 'value' => 22));
     $expenseLimitModel = new ExpenseControlLimitModel($data);
     $sim = $this->_service->load("00000000000000000015");
     $this->_service->changeExpenseLimit($expenseLimitModel, $sim);
 }
 protected function _getSim()
 {
     $id = $this->_getId();
     $type = $this->_getType('id');
     if ($type !== 'id') {
         $id = explode(':', $id, 2);
         $id = $id[1];
         if ($type === 'imsi') {
             $id = str_replace('-', '', $id);
         }
     }
     $sim = $this->_simSrv->load($id, \App::getOrgUserLogged(), $type);
     if (empty($sim)) {
         throw new \Application\Exceptions\NotFoundException("Resource {$type} does not exist");
     }
     $this->_helper->allowed('read', $sim);
     return $sim;
 }
 protected function _getSim()
 {
     $id = $this->_getId();
     $type = 'id';
     if (strpos($id, ':') !== false) {
         list($type, $id) = explode(':', $id, 2);
     }
     if ($type === 'tel') {
         $type = 'msisdn';
     }
     if ($type === 'imsi') {
         $id = str_replace('-', '', $id);
     }
     $sim = $this->_simSrv->load($id, \App::getOrgUserLogged(), $type);
     if (empty($sim)) {
         throw new \Application\Exceptions\NotFoundException("Resource {$id} does not exist");
     }
     $this->_helper->allowed('read', $sim);
     return $sim;
 }
 /**
  * Deletes the given user
  */
 public function deleteAction()
 {
     // Try to load the chosen user
     $id = $this->getRequest()->getParam('id');
     $sim = $this->_simSrv->load($id, \App::getOrgUserLogged());
     if (empty($sim)) {
         throw new NotFoundException('Sim ' . $id . ' not found', 404);
     }
     // Check permissions
     $this->_helper->allowed('delete', $sim);
     // Remove the user
     try {
         $this->_simSrv->delete($id);
     } catch (Exception $e) {
         throw new InvalidArgumentException($e->getMessage(), null, $e);
     }
     $this->view->data = true;
 }
 public function changeManLocationAction()
 {
     $data = $this->_helper->requestData();
     if (isset($data['id']) && strlen($data['id'])) {
         // Sync request
         $resp = 'data';
         $simOrList = $this->_simSrv->load($data['id']);
         if (!$simOrList) {
             throw new InvalidArgumentException('Invalid sim Id.');
         }
         $this->_helper->allowed('update', $simOrList);
         $this->_helper->allowed('async_sim_change_man_location', $simOrList);
     } else {
         // Async request
         $resp = 'watcher';
         $data = $this->_checkAndGetListData('async_sim_change_man_location', true, array('POST', 'DELETE'));
         $simOrList = $data['list'];
     }
     $method = $this->getRequest()->getMethod();
     if ($method == 'POST') {
         if (!$data['location']) {
             throw new InvalidArgumentException('Bad Request. Malformed Json. parameter {location} is required');
         }
         $location = new \Application\Model\Sim\LocationModel($data['location']);
         $this->view->{$resp} = $this->_simSrv->changeManLocation($simOrList, $location);
     } else {
         if ($method == 'DELETE') {
             $this->view->{$resp} = $this->_simSrv->removeManLocation($simOrList);
         } else {
             throw new AppEx\UnexpectedException("Resquest must be POST or DELETE");
         }
     }
     if ($resp == 'watcher') {
         $this->_helper->filterNotAllowedFields('read_field', $this->view->{$resp});
     }
 }