Example #1
0
 public function indexAction(Request $request, SessionInterface $session)
 {
     Util::checkUserIsLoggedInAndRedirect();
     $menuSelectedCategory = 'issue';
     $emptyName = false;
     $fields = $this->getRepository(Field::class)->getByClient($session->get('client/id'));
     if ($request->request->has('add_screen')) {
         $name = Util::cleanRegularInputField($request->request->get('name'));
         $description = Util::cleanRegularInputField($request->request->get('description'));
         $currentDate = Util::getServerCurrentDateTime();
         if (empty($name)) {
             $emptyName = true;
         }
         if (!$emptyName) {
             $screen = new Screen($session->get('client/id'), $name, $description);
             $screenId = $screen->save($currentDate);
             $order = 0;
             foreach ($request->request as $key => $value) {
                 if (substr($key, 0, 6) == 'field_') {
                     $order++;
                     $fieldId = str_replace('field_', '', $key);
                     $this->getRepository(Screen::class)->addData($screenId, $fieldId, $order, $currentDate);
                 }
             }
             $this->getLogger()->addInfo('ADD Yongo Screen ' . $name, $this->getLoggerContext());
             return new RedirectResponse('/yongo/administration/screens');
         }
     }
     $sectionPageTitle = $session->get('client/settings/title_name') . ' / ' . SystemProduct::SYS_PRODUCT_YONGO_NAME . ' / Create Screen';
     return $this->render(__DIR__ . '/../../../Resources/views/administration/screen/Add.php', get_defined_vars());
 }
Example #2
0
 public function indexAction(Request $request, SessionInterface $session)
 {
     Util::checkUserIsLoggedInAndRedirect();
     $screenId = $request->get('id');
     $screen = $this->getRepository(Screen::class)->getMetaDataById($screenId);
     if ($screen['client_id'] != $session->get('client/id')) {
         return new RedirectResponse('/general-settings/bad-link-access-denied');
     }
     $emptyScreenName = false;
     $screenExists = false;
     if ($request->request->has('edit_workflow_screen')) {
         $name = Util::cleanRegularInputField($request->request->get('name'));
         $description = Util::cleanRegularInputField($request->request->get('description'));
         if (empty($name)) {
             $emptyScreenName = true;
         }
         // check for duplication
         $screen_row_exists = $this->getRepository(Screen::class)->getByName($session->get('client/id'), mb_strtolower($name));
         if ($screen_row_exists) {
             $screenExists = true;
         }
         if (!$screenExists && !$emptyScreenName) {
             $copiedScreen = new Screen($session->get('client/id'), $name, $description);
             $currentDate = Util::getServerCurrentDateTime();
             $copiedScreenId = $copiedScreen->save($currentDate);
             $screenData = $this->getRepository(Screen::class)->getDataById($screenId);
             while ($data = $screenData->fetch_array(MYSQLI_ASSOC)) {
                 $this->getRepository(Screen::class)->addData($copiedScreenId, $data['field_id'], $data['position'], $currentDate);
             }
             return new RedirectResponse('/yongo/administration/screens');
         }
     }
     $menuSelectedCategory = 'issue';
     $sectionPageTitle = $session->get('client/settings/title_name') . ' / ' . SystemProduct::SYS_PRODUCT_YONGO_NAME . ' / Copy Screen';
     return $this->render(__DIR__ . '/../../../Resources/views/administration/screen/Copy.php', get_defined_vars());
 }