Example #1
0
 public function connectAction()
 {
     /**
      * @var Request $request
      */
     $request = $this->getRequest();
     $result = ['status' => 'error', 'msg' => TextConstants::ERROR];
     try {
         if ($request->isPost() && $request->isXmlHttpRequest()) {
             $details = $request->getPost('data');
             $apartmentDetailsDao = new Details($this->getServiceLocator());
             $apartmentDetailsDao->connectToCubilis($this->apartmentId, (int) $request->getPost('connect'));
             if ((int) $request->getPost('connect') && is_array($details) && count($details)) {
                 $apartmentDetailsDao->updateCubilisDetails($this->apartmentId, $details['cubilis_id'], $details['cubilis_username'], $details['cubilis_password']);
             }
             $successMessage = (int) $request->getPost('connect') ? TextConstants::SUCCESS_CONNECTED_TO_CUBILIS : TextConstants::SUCCESS_DISCONNECTED_FROM_CUBILIS;
             Helper::setFlashMessage(['success' => $successMessage]);
             $result = ['status' => 'success', 'msg' => $successMessage];
         } else {
             throw new \Exception(TextConstants::ERROR_BAD_REQUEST);
         }
     } catch (\Exception $ex) {
         $result['msg'] = $ex->getMessage();
     }
     return new JsonModel($result);
 }
Example #2
0
 public function getCubilisDetailsAsArray($apartmentId)
 {
     $productDetailsDao = new DetailsDao($this->getServiceLocator());
     $productDetailsDomain = $productDetailsDao->getCubilisDetails($apartmentId);
     return ['sync_cubilis' => $productDetailsDomain->getSync_cubilis(), 'cubilis_id' => $productDetailsDomain->getCubilisId(), 'cubilis_username' => $productDetailsDomain->getCubilisUs(), 'cubilis_password' => $productDetailsDomain->getCubilisPass()];
 }