protected function createComponentMemberGrid($name)
 {
     $grid = new \Ublaboo\DataGrid\DataGrid($this, $name);
     if ($this->presenter->id == null) {
         $contacts = $this->database->table("users");
     } else {
         $contacts = $this->database->table("users")->where("categories_id", $this->id);
     }
     $grid->setTranslator($this->presenter->translator);
     $grid->setDataSource($contacts);
     $grid->addGroupAction('Delete')->onSelect[] = [$this, 'handleDelete'];
     $grid->addColumnLink('name', 'dictionary.main.Title')->setRenderer(function ($item) {
         $url = \Nette\Utils\Html::el('a')->href($this->presenter->link('edit', array("id" => $item->id)))->setText($item->username);
         return $url;
     })->setSortable();
     $grid->addColumnText('email', $this->presenter->translator->translate('dictionary.main.Email'))->setSortable();
     $grid->addColumnText('state', $this->presenter->translator->translate('dictionary.main.State'))->setRenderer(function ($item) {
         if ($item->date_created == 1) {
             $text = 'dictionary.main.enabled';
         } else {
             $text = 'dictionary.main.disabled';
         }
         return $this->presenter->translator->translate($text);
     })->setSortable();
     $grid->addColumnText('date_created', $this->presenter->translator->translate('dictionary.main.Date'))->setRenderer(function ($item) {
         $date = date("j. n. Y", strtotime($item->date_created));
         return $date;
     })->setSortable();
     //$grid->setTranslator($this->translator);
 }
 public function createComponentCarouselGrid($name)
 {
     $grid = new \Ublaboo\DataGrid\DataGrid($this, $name);
     $test = $this->database->table("carousel")->order("sorted");
     $grid->setDataSource($test);
     $grid->setSortable(true);
     $grid->addGroupAction('Smazat')->onSelect[] = [$this, 'handleDelete'];
     $grid->addColumnText('title', 'dictionary.main.Title')->setRenderer(function ($item) {
         if ($item->title == '') {
             $title = \Nette\Utils\Html::el('a')->href('/admin/appearance/carousel-detail/' . $item->id)->setText('- nemá název - ');
         } else {
             $title = \Nette\Utils\Html::el('a')->href('/admin/appearance/carousel-detail/' . $item->id)->setText($item->title);
         }
         return $title;
     });
     $grid->addColumnText('test', 'dictionary.main.Image')->setRenderer(function ($item) {
         if ($item->image == '') {
             $fileImage = '';
         } else {
             $fileImage = \Nette\Utils\Html::el('img', array('style' => 'max-height: 130px;'))->src('/images/carousel/' . $item->image);
         }
         return $fileImage;
     });
     $grid->setTranslator($this->presenter->translator);
 }
Example #3
0
 /**
  * factory to create grid
  * @param string $name
  * @return \Ublaboo\DataGrid\DataGrid
  */
 public function createComponentRemoteNodesGrid($name)
 {
     $grid = new \Ublaboo\DataGrid\DataGrid($this, $name);
     $grid->setDataSource($this->model->getTable());
     $grid->addColumnText('name', _('Name'));
     $grid->addColumnText('comment', _('Comment'));
     $grid->addColumnText('aet', _('AE title'));
     $grid->addColumnText('ip_address', _('IP address'));
     $grid->addColumnText('port', _('Port'));
     return $grid;
 }
 public function createComponentCommunicationGrid($name)
 {
     $grid = new \Ublaboo\DataGrid\DataGrid($this, $name);
     $dbCommunications = $this->database->table("contacts_communication")->where(array("contacts_id" => $this->presenter->getParameter('id')));
     $grid->setDataSource($dbCommunications);
     $grid->setItemsPerPageList(array(20));
     $grid->addGroupAction('dictionary.main.Delete')->onSelect[] = [$this, 'handleDeleteCommunication'];
     $grid->addColumnText('communication_type', 'Typ');
     $grid->addColumnText('communication_value', 'Hodnota');
     $grid->setTranslator($this->presenter->translator);
 }
Example #5
0
 /**
  * factory to create a grid
  * @param string $name
  * @return \Ublaboo\DataGrid\DataGrid
  */
 public function createComponentRemoteNodesGrid($name)
 {
     // create object
     $grid = new \Ublaboo\DataGrid\DataGrid($this, $name);
     // set data source
     $grid->setDataSource($this->model->getTable());
     // set columns hidable
     $grid->setColumnsHideable();
     //add collumn name which is sortable and may be filtered
     $grid->addFilterText('name', _("Node name"));
     $colName = $grid->addColumnText('name', _("Node name"))->setSortable();
     if ($this->user->isAllowed("config", "edit")) {
         $colName->setEditableCallback(function ($id, $value) {
             $this->model->saveChanges($id, array("name" => $value, "activated" => 0));
             $this->flashMessage(_("Name was updated"), "success");
             $this->redirect("this");
         });
     }
     // add collumn Comment which is sortable and may be filtered
     $grid->addFilterText('comment', _("Comment"));
     $colComment = $grid->addColumnText('comment', _("Comment"))->setSortable();
     if ($this->user->isAllowed("config", "edit")) {
         $colComment->setEditableCallback(function ($id, $value) {
             $this->model->saveChanges($id, array("comment" => $value, "activated" => 0));
             $this->flashMessage(_("Comment was updated"), "success");
             $this->redirect("this");
         });
     }
     // add collumn AET which is sortable and may be filtered
     $grid->addFilterText('aet', _("AE title"));
     $colAet = $grid->addColumnText('aet', _("AE title"))->setSortable();
     if ($this->user->isAllowed("config", "edit")) {
         $colAet->setEditableCallback(function ($id, $value) {
             $this->model->saveChanges($id, array("aet" => $value, "activated" => 0));
             $this->flashMessage(_("AE title was updated"), "success");
             $this->redirect("this");
         });
     }
     // add collumn IP address which is sortable and may be filtered
     $grid->addFilterText('ip_address', _("IP address"));
     $colIp = $grid->addColumnText('ip_address', _("IP address"))->setSortable();
     if ($this->user->isAllowed("config", "edit")) {
         $colIp->setEditableCallback(function ($id, $value) {
             $this->model->saveChanges($id, array("ip_address" => $value, "activated" => 0));
             $this->flashMessage(_("IP address was updated"), "success");
             $this->redirect("this");
         });
     }
     // add collumn port which is sortable and may be filtered
     $grid->addFilterText('port', _("Port number"));
     $colPort = $grid->addColumnText('port', _("Port number"))->setSortable();
     if ($this->user->isAllowed("config", "edit")) {
         $colPort->setEditableCallback(function ($id, $value) {
             $this->model->saveChanges($id, array("port" => $value, "activated" => 0));
             $this->flashMessage(_("Port number was updated"), "success");
             $this->redirect("this");
         });
     }
     // add collumn group which is sortable and may be filtered
     $grid->addFilterSelect('group', _("Group"), $this->groups);
     $grid->addColumnText('group', _("Group"))->setSortable();
     // add collumn compression
     $grid->addFilterSelect('compression', _("Compression"), $this->compressions);
     $grid->addColumnText('compression', _("Compression"));
     // add column active which may be sortable and filtered
     if (!$this->user->isAllowed("config", "edit")) {
         $grid->addFilterSelect('active', _('Active?'), [1 => $this->answers[1], 0 => $this->answers[0], '' => _("All")]);
     } else {
         $grid->addColumnStatus('active', _("Active?"))->addOption(1, _("Yes"))->setIcon('check')->setClass('btn-success')->endOption()->addOption(0, _("No"))->setIcon('close')->setClass('btn-danger')->endOption()->onChange[] = function ($id, $newValue) {
             if (!$this->user->isAllowed("config", "edit")) {
                 $this->flashMessage(_("You are not allowed to do this action."), "danger");
                 $this->redirect("this");
             }
             try {
                 $this->model->changeActive($id, $newValue);
                 $this->redirect("this");
             } catch (RemoteNodesException $exc) {
                 $this->getPresenter()->flashMessage($exc->getMessage(), "danger");
                 $this->redirect("this");
             }
         };
     }
     // add action - delete if is allowed
     if ($this->user->isAllowed("config", "delete")) {
         $grid->addAction("delete!", _("Delete"))->setClass('btn btn-xs btn-danger')->setIcon("trash")->setConfirm(_('Do you really want to delete row') . ' %s?', 'comment');
     }
     $grid->setItemsPerPageList([10, 50, 100, 9999]);
     return $grid;
 }
Example #6
0
 /**
  * factory to create a grid
  * @param string $name
  * @return \Ublaboo\DataGrid\DataGrid
  */
 public function createComponentPacsConfigGrid($name)
 {
     // create object
     $grid = new \Ublaboo\DataGrid\DataGrid($this, $name);
     // set data source
     $grid->setDataSource($this->model->getTable());
     // set columns hidable
     $grid->setColumnsHideable();
     // add collumn Comment which is sortable and may be filtered
     $grid->addFilterText('comment', _('Comment'));
     $grid->addColumnText('comment', _('Comment'))->setSortable();
     // add collumn group which is sortable and may be filtered
     $grid->addFilterSelect('group', _('Group'), $this->groups);
     $grid->addColumnText('group', _('Group'))->setSortable();
     // add collumn item (dicom.ini key) which is sortable and may be filtered
     $grid->addFilterText('item', _('Item'));
     $grid->addColumnText('item', _('Item'))->setSortable();
     // add collumn value (dicom.ini value) which is sortable and may be filtered and if os authorized allowed inline editing
     $grid->addFilterText('value', _('Value'));
     $colValue = $grid->addColumnText('value', _('Value'))->setSortable();
     if ($this->user->isAllowed("config", "edit")) {
         $colValue->setEditableCallback(function ($id, $value) {
             if (!$this->user->isAllowed("config", "edit")) {
                 $this->flashMessage(_("You are not allowed to do this action."), "danger");
                 $this->redirect("this");
             }
             if ($this->model->isEditable($id) == true) {
                 $this->model->saveChanges($id, $value);
                 $this->flashMessage(_("Value was updated"), "success");
                 $this->redirect("this");
             } else {
                 $this->flashMessage(_("Sorry this is not editable value"), "warning");
                 $this->redirect("this");
             }
         });
     }
     // all non editable columns are grey
     $grid->setRowCallback(function ($item, $row) {
         if ($item->editable == 0) {
             $row->addClass("nonEditable");
         }
     });
     // add column active which may be sortable and filtered
     if (!$this->user->isAllowed("config", "edit")) {
         $grid->addFilterSelect('active', _('Active?'), [1 => $this->answers[1], 0 => $this->answers[0], '' => _("All")]);
     } else {
         $grid->addColumnStatus('active', _("Active?"))->addOption(1, _("Yes"))->setIcon('check')->setClass('btn-success')->endOption()->addOption(0, _("No"))->setIcon('close')->setClass('btn-danger')->endOption()->onChange[] = function ($id, $newValue) {
             if (!$this->user->isAllowed("config", "edit")) {
                 $this->flashMessage(_("You are not allowed to do this action."), "danger");
                 $this->redirect("this");
             }
             try {
                 $this->model->changeActive($id, $newValue);
                 $this->redirect("this");
             } catch (PacsConfigException $exc) {
                 $this->flashMessage($exc->getMessage(), "danger");
                 $this->redirect("this");
             }
         };
     }
     // add action - delete if is allowed
     if ($this->user->isAllowed("config", "delete")) {
         $grid->addAction("delete!", _("Delete"))->setClass('btn btn-xs btn-danger')->setIcon("trash")->setConfirm(_('Do you really want to delete row') . '%s?', 'comment');
         $grid->allowRowsAction('delete!', function ($item) {
             return $item->editable == 1;
         });
     }
     $grid->setItemsPerPageList([10, 50, 100, 9999]);
     return $grid;
 }
Example #7
0
 /**
  * factory to grid
  * @return UseradminGrid
  */
 public function createComponentUseradminGrid($name)
 {
     $grid = new \Ublaboo\DataGrid\DataGrid($this, $name);
     // set data source
     $grid->setDataSource($this->model->getTable());
     // set columns hidable
     $grid->setColumnsHideable();
     $grid->addFilterText('username', _("Login name"));
     $grid->addColumnText('username', _("Login name"))->setSortable();
     $grid->addFilterText('name', _("Real name"));
     $grid->addColumnText('name', _("Real name"))->setSortable()->setEditableCallback(function ($id, $value) {
         if (!$this->user->isAllowed("useradmin", "edit")) {
             $this->flashMessage(_("You are not allowed to do this action.", "danger"));
             $this->redirect("this");
         }
         $this->model->saveChanges($id, "name", $value);
         $this->getPresenter()->flashMessage(_("Real name was updated"), "success");
         $this->redirect("this");
     });
     $grid->addFilterText('email', _("Email"));
     $grid->addColumnText('email', _("Email"))->setSortable()->setEditableCallback(function ($id, $value) {
         if (!$this->user->isAllowed("useradmin", "edit")) {
             $this->flashMessage(_("You are not allowed to do this action.", "danger"));
             $this->redirect("this");
         }
         $this->model->saveChanges($id, "email", $value);
         $this->getPresenter()->flashMessage(_("Email was updated"), "success");
         $this->redirect("this");
     });
     $grid->addFilterText('refer_phys_key', _("Reference physician key"));
     $grid->addColumnText('refer_phys_key', _("Reference physician key"))->setSortable()->setEditableCallback(function ($id, $value) {
         if (!$this->user->isAllowed("useradmin", "edit")) {
             $this->flashMessage(_("You are not allowed to do this action.", "danger"));
             $this->redirect("this");
         }
         $this->model->saveChanges($id, "refer_phys_key", $value);
         $this->getPresenter()->flashMessage(_("Reference physician key was updated"), "success");
         $this->redirect("this");
     });
     $role = $grid->addColumnStatus('role', _("Users role"));
     foreach ($this->roles as $key => $value) {
         $role->addOption($key, $value)->setIcon('group')->setClass('btn-success')->endOption();
     }
     $role->onChange[] = function ($id, $newValue) {
         if (!$this->user->isAllowed("useradmin", "edit")) {
             $this->flashMessage(_("You are not allowed to do this action.", "danger"));
             $this->redirect("this");
         }
         try {
             $this->model->changeRole($id, $newValue);
             $this->flashMessage(_("Users's role was changed."), "success");
             $this->redirect("this");
         } catch (RemoteNodesException $exc) {
             $this->getPresenter()->flashMessage($exc->getMessage(), "danger");
             $this->redirect("this");
         }
     };
     $grid->addColumnStatus('enable', _("Enabled"))->addOption(1, _("Yes"))->setIcon('check')->setClass('btn-success')->endOption()->addOption(0, _("No"))->setIcon('close')->setClass('btn-danger')->endOption()->onChange[] = function ($id, $newValue) {
         if (!$this->user->isAllowed("useradmin", "edit")) {
             $this->flashMessage(_("You are not allowed to do this action.", "danger"));
             $this->redirect("this");
         }
         try {
             $this->model->changeStatus($id, $newValue);
             $this->flashMessage(_("User's status was changed"), "success");
             $this->redirect("this");
         } catch (RemoteNodesException $exc) {
             $this->getPresenter()->flashMessage($exc->getMessage(), "danger");
             $this->redirect("this");
         }
     };
     $lang = $grid->addColumnStatus('lang', _("Language"));
     foreach ($this->translator->getLanguages() as $key => $value) {
         $lang->addOption($key, $value)->endOption();
     }
     $lang->onChange[] = function ($id, $value) {
         if (!$this->user->isAllowed("useradmin", "edit")) {
             $this->flashMessage(_("You are not allowed to do this action.", "danger"));
             $this->redirect("this");
         }
         try {
             $this->model->saveChanges($id, "lang", $value);
             $this->flashMessage(_("User's language was changed"), "success");
             $this->redirect("this");
         } catch (RemoteNodesException $exc) {
             $this->flashMessage($exc->getMessage(), "danger");
             $this->redirect("this");
         }
     };
     // add action - delete if is allowed
     if ($this->user->isAllowed("useradmin", "edit")) {
         $grid->addAction("changePassword", _("Change password"))->setClass('btn btn-xs btn-warning')->setIcon("edit");
     }
     // add action - delete if is allowed
     if ($this->user->isAllowed("useradmin", "delete")) {
         $grid->addAction("delete!", _("Delete"))->setClass('btn btn-xs btn-danger')->setIcon("trash")->setConfirm(_('Do you really want to delete row ') . ' %s?', 'username');
     }
     return $grid;
 }
Example #8
0
 /**
  * factory to detail grid control
  * @param string $name
  * @return \Ublaboo\DataGrid\DataGrid
  */
 public function createComponentDetailGrid($name)
 {
     $datasource = $this->model->getQuery()->setDestination($this->remoteAet)->series($this->studyInstanceUid)->setRequestedFields($this->seriesTableRows);
     $grid = new \Ublaboo\DataGrid\DataGrid($this, $name);
     try {
         $datasource->checkDestination();
     } catch (DicomNetworkException $exc) {
         $this->flashMessage($exc->getMessage(), "danger");
         $this->redirect("default");
     }
     // setting datasource
     $grid->setPrimaryKey('SeriesInstanceUID');
     $grid->setDataSource($datasource);
     $grid->addColumnText("SeriesNumber", _("Series number"));
     $grid->addColumnText("SeriesDescription", _("Series description"));
     $grid->addAction('retrieveSeries!', _('Retrieve'))->setDataAttribute("toggle", "modal")->setDataAttribute("target", "#retrieveModal")->setIcon('download');
     return $grid;
 }
 protected function createComponentContactsGrid($name)
 {
     $grid = new \Ublaboo\DataGrid\DataGrid($this, $name);
     if ($this->presenter->id == null) {
         $contacts = $this->database->table("contacts");
     } else {
         $contacts = $this->database->table("contacts")->where("categories_id", $this->presenter->id);
     }
     $grid->setDataSource($contacts);
     $grid->addGroupAction($this->presenter->translator->translate('dictionary.main.Delete'))->onSelect[] = [$this, 'handleDelete'];
     $grid->addColumnLink('name', 'dictionary.main.Title')->setRenderer(function ($item) {
         if (strlen($item->name) == 0 && strlen($item->company) == 0) {
             $name = 'nemá název';
         } elseif (strlen($item->name) == 0) {
             $name = $item->company;
         } else {
             $name = $item->name;
         }
         $url = \Nette\Utils\Html::el('a')->href($this->presenter->link('detail', array("id" => $item->pages_id)))->setText($name);
         return $url;
     })->setSortable();
     $grid->addFilterText('name', $this->presenter->translator->translate('dictionary.main.Name'));
     $grid->addColumnText('email', $this->presenter->translator->translate('dictionary.main.Email'))->setSortable();
     $grid->addFilterText('email', $this->presenter->translator->translate('dictionary.main.Email'));
     $grid->addColumnText('phone', $this->presenter->translator->translate('dictionary.main.Phone'))->setSortable();
     $grid->addFilterText('phone', $this->presenter->translator->translate('dictionary.main.Phone'));
     $grid->addColumnText('vatin', $this->presenter->translator->translate('dictionary.main.VatIn'))->setSortable();
     $grid->addFilterText('vatin', 'dictionary.main.VatIn');
     $grid->addColumnText('street', $this->presenter->translator->translate('dictionary.main.Address'))->setRenderer(function ($item) {
         $address = $item->street . ', ' . $item->zip . ' ' . $item->city;
         if (strlen($address) > 2) {
             $addressText = $address;
         } else {
             $addressText = null;
         }
         return $addressText;
     })->setSortable();
     $grid->addFilterText('street', 'dictionary.main.Street');
     $grid->setTranslator($this->presenter->translator);
 }
Example #10
0
 /**
  * factory to create grid
  * @param string $name
  * @return \Ublaboo\DataGrid\DataGrid
  */
 public function createComponentSopClassGrid($name)
 {
     // create object
     $grid = new \Ublaboo\DataGrid\DataGrid($this, $name);
     // set data source
     $grid->setDataSource($this->model->getTable());
     // set columns hidable
     $grid->setColumnsHideable();
     //add collumn SOP class name which is sortable and may be filtered
     $grid->addFilterText('name', _("SOP class name"));
     $colName = $grid->addColumnText('name', _("SOP class name"))->setSortable();
     if ($this->user->isAllowed("config", "edit")) {
         $colName->setEditableCallback(function ($id, $value) {
             $this->model->saveChanges($id, array("name" => $value, "activated" => 0));
             $this->flashMessage(_("SOP class name was updated"), "success");
             $this->redirect("this");
         });
     }
     // add collumn SOP class UIS which is sortable and may be filtered
     $grid->addFilterText('sop', _("SOP class UID"));
     $colSop = $grid->addColumnText('sop', _("SOP class UID"))->setSortable();
     if ($this->user->isAllowed("config", "edit")) {
         $colSop->setEditableCallback(function ($id, $value) {
             $this->model->saveChanges($id, array("sop" => $value, "activated" => 0));
             $this->flashMessage(_("SOP class UID was updated"), "success");
             $this->redirect("this");
         });
     }
     // add collumn aaplication type which is sortable and may be filtered
     $grid->addFilterText('application', _("SOP type"));
     $colApp = $grid->addColumnText('application', _("SOP type"))->setSortable();
     if ($this->user->isAllowed("config", "edit")) {
         $colApp->setEditableCallback(function ($id, $value) {
             $this->model->saveChanges($id, array("application" => $value, "activated" => 0));
             $this->flashMessage(_("Application type was updated"), "success");
             $this->redirect("this");
         });
     }
     // add collumn transfer which is sortable and may be filtered
     $grid->addFilterText('transfer', _("Transfer syntax (optional)"));
     $colTra = $grid->addColumnText('transfer', _("Transfer syntax (optional)"))->setSortable();
     if ($this->user->isAllowed("config", "edit")) {
         $colTra->setEditableCallback(function ($id, $value) {
             $this->model->saveChanges($id, array("transfer" => $value, "activated" => 0));
             $this->flashMessage(_("Transfer syntax was updated"), "success");
             $this->redirect("this");
         });
     }
     // add column active which may be sortable and filtered
     if (!$this->user->isAllowed("config", "edit")) {
         $grid->addFilterSelect('active', _('Active?'), [1 => $this->answers[1], 0 => $this->answers[0], '' => _("All")]);
     } else {
         $grid->addColumnStatus('active', _("Active?"))->addOption(1, _("Yes"))->setIcon('check')->setClass('btn-success')->endOption()->addOption(0, _("No"))->setIcon('close')->setClass('btn-danger')->endOption()->onChange[] = function ($id, $newValue) {
             if (!$this->user->isAllowed("config", "edit")) {
                 $this->flashMessage(_("You are not allowed to do this action."), "danger");
                 $this->redirect("this");
             }
             try {
                 $this->model->changeActive($id, $newValue);
                 $this->redirect("this");
             } catch (SopClassException $exc) {
                 $this->flashMessage($exc->getMessage(), "danger");
                 $this->redirect("this");
             }
         };
     }
     // add action - delete if is allowed
     if ($this->user->isAllowed("config", "delete")) {
         $grid->addAction("delete!", _("Delete"))->setClass('btn btn-xs btn-danger')->setIcon("trash")->setConfirm(_('Do you really want to delete row') . ' %s?', 'name');
     }
     $grid->setItemsPerPageList([10, 50, 100, 9999]);
     return $grid;
 }