/**
  * Editor k přidávání členů skupiny
  *
  * @param string $fieldName    název políčka formuláře
  * @param string $fieldCaption popisek políčka
  * @param IEcfg  $dataSource   editovaný objekt
  */
 public function __construct($fieldName, $fieldCaption, $dataSource, $members)
 {
     $iDColumn = $dataSource->keywordsInfo[$fieldName]['refdata']['idcolumn'];
     $nameColumn = $dataSource->keywordsInfo[$fieldName]['refdata']['captioncolumn'];
     $sTable = $dataSource->keywordsInfo[$fieldName]['refdata']['table'];
     if (isset($dataSource->keywordsInfo[$fieldName]['refdata']['condition'])) {
         $conditions = $dataSource->keywordsInfo[$fieldName]['refdata']['condition'];
     } else {
         $conditions = array();
     }
     if (isset($dataSource->keywordsInfo[$fieldName]['refdata']['public']) && intval($dataSource->keywordsInfo[$fieldName]['refdata']['public'])) {
         $sqlConds = " ( " . $dataSource->myDbLink->prepSelect(array_merge($conditions, array($dataSource->userColumn => EaseShared::user()->getUserID()))) . " ) OR ( " . $dataSource->myDbLink->prepSelect(array_merge($conditions, array('public' => 1))) . ")  ";
     } else {
         $sqlConds = $dataSource->myDbLink->prepSelect(array_merge($conditions, array($dataSource->userColumn => EaseShared::user()->getUserID())));
     }
     $initialContent = new EaseTWBPanel($fieldCaption);
     $initialContent->setTagCss(array('width' => '100%'));
     if (is_null($dataSource->getMyKey())) {
         $initialContent->addItem(_('Nejprve je potřeba uložit záznam'));
     } else {
         if ($sTable == $dataSource->myTable) {
             $tmpKey = $dataSource->getMyKey();
             if ($tmpKey) {
                 $members[$tmpKey] = true;
             }
         }
         if ($members && count($members)) {
             $aviavbleCond = 'AND ' . $iDColumn . ' NOT IN (' . join(',', array_keys($members)) . ') ';
         } else {
             $aviavbleCond = '';
         }
         $membersAviableArray = EaseShared::myDbLink()->queryToArray('SELECT ' . $nameColumn . ', ' . $iDColumn . ' ' . 'FROM `' . $sTable . '` ' . 'WHERE (' . $sqlConds . ') ' . $aviavbleCond . 'ORDER BY ' . $nameColumn, $iDColumn);
         if ($sTable == $dataSource->myTable) {
             unset($members[$dataSource->getMyKey()]);
         }
         $addText = _('Přiřadit');
         $delText = _('Odebrat');
         if (count($membersAviableArray)) {
             foreach ($membersAviableArray as $memberID => $memberName) {
                 $reftable = $dataSource->keywordsInfo[$fieldName]['refdata']['table'];
                 $initialContent->addItem(new EaseTWBButtonDropdown($memberName[$nameColumn], 'inverse', 'xs', array(new EaseHtmlATag($reftable . '.php?' . $reftable . '_id=' . $memberID, EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Editace')), new EaseHtmlATag(null, EaseTWBPart::GlyphIcon('plus-sign') . ' ' . $addText, array('onClick' => "addGroupMember('" . get_class($dataSource) . "','" . $dataSource->getId() . "','" . $fieldName . "','" . $memberName[$nameColumn] . "','" . $memberID . "')", 'class' => 'handle', 'data-addtext' => $addText, 'data-deltext' => $delText))), array('id' => get_class($dataSource) . '_' . $fieldName . '_' . $memberID, 'style' => 'margin: 1px;')));
             }
         }
         if ($members && count($members)) {
             $initialContent->addItem('</br>');
             foreach ($members as $memberID => $memberName) {
                 $reftable = $dataSource->keywordsInfo[$fieldName]['refdata']['table'];
                 $initialContent->addItem(new EaseTWBButtonDropdown($memberName, 'success', 'xs', array(new EaseHtmlATag($reftable . '.php?' . $reftable . '_id=' . $memberID, EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Editace')), new EaseHtmlATag(null, EaseTWBPart::GlyphIcon('remove') . ' ' . _('Odebrat'), array('onClick' => "delGroupMember('" . get_class($dataSource) . "','" . $dataSource->getId() . "','" . $fieldName . "','" . $memberName . "','" . $memberID . "')", 'class' => 'handle', 'data-addtext' => $addText, 'data-deltext' => $delText))), array('id' => get_class($dataSource) . '_' . $fieldName . '_' . $memberID, 'style' => 'margin: 1px;')));
             }
         }
     }
     parent::__construct($initialContent);
 }
 /**
  * Editor k přidávání členů skupiny
  *
  * @param IEServices $service
  */
 public function __construct($service)
 {
     $hostsAssigned = array();
     parent::__construct();
     $fieldName = $this->getmyKeyColumn();
     $initialContent = new EaseTWBPanel(_('Sledované hosty služby'), 'default');
     $initialContent->setTagCss(array('width' => '100%'));
     if (is_null($service->getMyKey())) {
         $initialContent->addItem(_('Nejprve je potřeba uložit záznam'));
     } else {
         $serviceName = $service->getName();
         $host = new IEHost();
         if (EaseShared::user()->getSettingValue('admin')) {
             $allHosts = $host->getAllFromMySQL(NULL, array($host->myKeyColumn, $host->nameColumn, 'platform', 'register'), null, $host->nameColumn, $host->myKeyColumn);
         } else {
             $allHosts = $host->getListing(null, true, array('platform', 'register'));
         }
         if ($service->getDataValue('host_name')) {
             foreach ($service->getDataValue('host_name') as $hostId => $hostName) {
                 if (isset($allHosts[$hostId])) {
                     $hostsAssigned[$hostId] = $allHosts[$hostId];
                 }
             }
         }
         foreach ($allHosts as $hostID => $hostInfo) {
             if ($hostInfo['register'] != 1) {
                 unset($allHosts[$hostID]);
             }
             if ($hostInfo['platform'] != 'generic' && $hostInfo['platform'] != $service->getDataValue('platform')) {
                 unset($allHosts[$hostID]);
             }
         }
         foreach ($hostsAssigned as $hostID => $hostInfo) {
             unset($allHosts[$hostID]);
         }
         if (count($allHosts)) {
             foreach ($allHosts as $hostID => $hostInfo) {
                 $initialContent->addItem(new EaseTWBButtonDropdown($hostInfo[$host->nameColumn], 'inverse', 'xs', array(new EaseHtmlATag('host.php?host_id=' . $hostID . '&amp;service_id=' . $service->getId(), EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Editace')), new EaseHtmlATag('?addhost=' . $hostInfo[$host->nameColumn] . '&amp;host_id=' . $hostID . '&amp;' . $service->getmyKeyColumn() . '=' . $service->getMyKey() . '&amp;' . $service->nameColumn . '=' . $service->getName(), EaseTWBPart::GlyphIcon('plus') . ' ' . _('Začít sledovat')))));
             }
         }
         if (count($hostsAssigned)) {
             $initialContent->addItem('<br/>');
             foreach ($hostsAssigned as $hostID => $hostInfo) {
                 $initialContent->addItem(new EaseTWBButtonDropdown($hostInfo[$host->nameColumn], 'success', 'xs', array(new EaseHtmlATag('?delhost=' . $hostInfo[$host->nameColumn] . '&amp;host_id=' . $hostID . '&amp;' . $service->getmyKeyColumn() . '=' . $service->getMyKey() . '&amp;' . $service->nameColumn . '=' . $service->getName(), EaseTWBPart::GlyphIcon('remove') . ' ' . _('Přestat sledovat')), new EaseHtmlATag('host.php?host_id=' . $hostID . '&amp;service_id=' . $service->getId(), EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Editace')))));
             }
         }
     }
     $this->addItem($initialContent);
 }
 /**
  * Editor k přidávání členů skupiny
  *
  * @param IEService|IEHost $holder
  */
 public function __construct($holder)
 {
     $contactsAssigned = array();
     parent::__construct();
     $fieldName = $this->getmyKeyColumn();
     $initialContent = new EaseTWBPanel(_('Cíle notifikací'));
     $initialContent->setTagCss(array('width' => '100%'));
     if (is_null($holder->getMyKey())) {
         $initialContent->addItem(_('Nejprve je potřeba uložit záznam'));
     } else {
         $serviceName = $holder->getName();
         $contact = new IEContact();
         $allContacts = $contact->getListing(null, true, array('alias', 'parent_id'));
         foreach ($holder->getDataValue('contacts') as $contactId => $contactName) {
             if (isset($allContacts[$contactId])) {
                 $contactsAssigned[$contactId] = $allContacts[$contactId];
             }
         }
         foreach ($allContacts as $contactID => $contactInfo) {
             if ($contactInfo['register'] != 1) {
                 unset($allContacts[$contactID]);
             }
             if (!$contactInfo['parent_id']) {
                 unset($allContacts[$contactID]);
             }
         }
         foreach ($contactsAssigned as $contactID => $contactInfo) {
             unset($allContacts[$contactID]);
         }
         if (count($allContacts)) {
             foreach ($allContacts as $contactID => $contactInfo) {
                 $initialContent->addItem(new EaseTWBButtonDropdown($contactInfo[$contact->nameColumn], 'inverse', 'xs', array(new EaseHtmlATag('contacttweak.php?contact_id=' . $contactInfo['parent_id'] . '&amp;service_id=' . $holder->getId(), EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Editace')), new EaseHtmlATag('?addcontact=' . $contactInfo[$contact->nameColumn] . '&amp;contact_id=' . $contactID . '&amp;' . $holder->getmyKeyColumn() . '=' . $holder->getMyKey() . '&amp;' . $holder->nameColumn . '=' . $holder->getName(), EaseTWBPart::GlyphIcon('plus') . ' ' . _('Začít obesílat')))));
             }
         }
         if (count($contactsAssigned)) {
             $initialContent->addItem('<br/>');
             foreach ($contactsAssigned as $contactID => $contactInfo) {
                 $initialContent->addItem(new EaseTWBButtonDropdown($contactInfo[$contact->nameColumn], 'success', 'xs', array(new EaseHtmlATag('?delcontact=' . $contactInfo[$contact->nameColumn] . '&amp;contact_id=' . $contactID . '&amp;' . $holder->getmyKeyColumn() . '=' . $holder->getMyKey() . '&amp;' . $holder->nameColumn . '=' . $holder->getName(), EaseTWBPart::GlyphIcon('remove') . ' ' . _('Přestat obesílat')), new EaseHtmlATag('contacttweak.php?contact_id=' . $contactInfo['parent_id'] . '&amp;service_id=' . $holder->getId(), EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Editace')))));
             }
         }
     }
     $this->addItem($initialContent);
 }
 /**
  * Editor k přidávání členů skupiny
  *
  * @param IEHost $host
  */
 public function __construct($host)
 {
     parent::__construct();
     $fieldName = $host->getmyKeyColumn();
     $initialContent = new EaseTWBPanel(_('rodiče hostu'));
     $addparentForm = $initialContent->addItem(new EaseTWBForm('addparent'));
     $addparentForm->addItem(new EaseTWBFormGroup(_('IP nebo Hostname'), new EaseHtmlInputTextTag('newparent')));
     $addparentForm->addItem(new EaseHtmlInputHiddenTag($fieldName, $host->getId()));
     $addparentForm->addItem(new EaseTWSubmitButton(_('Přidat rodiče'), 'success'));
     $initialContent->setTagCss(array('width' => '100%'));
     if (is_null($host->getMyKey())) {
         $initialContent->addItem(_('Nejprve je potřeba uložit záznam'));
     } else {
         $allParents = $host->getListing();
         unset($allParents[$host->getID()]);
         //Nenabízet sám sebe jako rodiče
         foreach ($allParents as $parentID => $parentInfo) {
             if ($parentInfo['register'] != 1) {
                 unset($allParents[$parentID]);
             }
         }
         $parentsAssigned = array();
         foreach ($host->getDataValue('parents') as $parentAssigned) {
             $parentID = EaseShared::myDbLink()->queryToValue('SELECT `' . $host->myKeyColumn . '` FROM ' . $host->myTable . ' WHERE `' . $host->nameColumn . '` = \'' . addSlashes($parentAssigned) . '\'');
             $parentsAssigned[$parentID][$host->nameColumn] = $parentAssigned;
             $parentsAssigned[$parentID][$host->myKeyColumn] = $parentID;
             unset($allParents[$parentID]);
         }
         if (count($allParents)) {
             foreach ($allParents as $parentID => $parentInfo) {
                 $initialContent->addItem($this->parentButton($parentInfo, 'plus', $host));
             }
         }
         if (count($parentsAssigned)) {
             $initialContent->addItem('</br>');
             foreach ($parentsAssigned as $parentID => $parentInfo) {
                 $initialContent->addItem($this->parentButton($parentInfo, 'remove', $host));
             }
         }
     }
     $this->addItem($initialContent);
 }
 /**
  * Editor k přidávání členů skupiny
  *
  * @param IEHosts $Host
  */
 public function __construct($Host)
 {
     $FieldName = 'parents';
     $InitialContent = new EaseTWBPanel(_('Potomci'));
     $InitialContent->setTagCss(array('width' => '100%'));
     if (is_null($Host->getMyKey())) {
         $InitialContent->addItem(_('Nejprve je potřeba uložit záznam'));
     } else {
         $Service = new IEService();
         $ServicesAssigned = $Service->myDbLink->queryToArray('SELECT ' . $Service->myKeyColumn . ',' . $Service->nameColumn . ' FROM ' . $Service->myTable . ' WHERE ' . $FieldName . ' LIKE \'%"' . $Host->getName() . '"%\'', $Service->myKeyColumn);
         $AllServices = $Service->getListing();
         foreach ($AllServices as $ServiceID => $ServiceInfo) {
             if ($ServiceInfo['register'] != 1) {
                 unset($AllServices[$ServiceID]);
             }
         }
         foreach ($ServicesAssigned as $ServiceID => $ServiceInfo) {
             unset($AllServices[$ServiceID]);
         }
         if (count($AllServices)) {
             foreach ($AllServices as $ServiceID => $ServiceInfo) {
                 $Jellybean = new EaseHtmlSpanTag($ServiceInfo[$Service->nameColumn], null, array('class' => 'jellybean gray'));
                 $Jellybean->addItem(new EaseHtmlATag('?addservice=' . $ServiceInfo[$Service->nameColumn] . '&amp;service_id=' . $ServiceID . '&amp;' . $Host->getmyKeyColumn() . '=' . $Host->getMyKey() . '&amp;' . $Host->nameColumn . '=' . $Host->getName(), $ServiceInfo[$Service->nameColumn]));
                 $InitialContent->addItem($Jellybean);
             }
         }
         if (count($ServicesAssigned)) {
             $InitialContent->addItem('</br>');
             foreach ($ServicesAssigned as $ServiceID => $ServiceInfo) {
                 $Jellybean = new EaseHtmlSpanTag($ServiceInfo[$Service->nameColumn], null, array('class' => 'jellybean'));
                 $Jellybean->addItem($ServiceInfo[$Service->nameColumn]);
                 $Jellybean->addItem(new EaseHtmlATag('?delservice=' . $ServiceInfo[$Service->nameColumn] . '&amp;service_id=' . $ServiceID . '&amp;' . $Host->getmyKeyColumn() . '=' . $Host->getMyKey() . '&amp;' . $Host->nameColumn . '=' . $Host->getName(), EaseTWBPart::GlyphIcon('remove')));
                 $InitialContent->addItem($Jellybean);
             }
         }
     }
     parent::__construct($InitialContent);
 }
 /**
  * Editor k přidávání členů skupiny
  *
  * @param IEHost $host
  */
 public function __construct($host)
 {
     parent::__construct();
     $fieldName = $this->getmyKeyColumn();
     if ($host->getDataValue('platform') == 'generic') {
         $note = '<small><span class="label label-info">Tip:</span> ' . _('Další sledovatelné služby budou nabídnuty po nastavení platformy hosta a vzdáleného senzoru.') . '</small>';
     } else {
         $note = array();
     }
     $initialContent = new EaseTWBPanel(_('Sledované služby'), 'default', null, $note);
     $initialContent->setTagCss(array('width' => '100%'));
     if (is_null($host->getMyKey())) {
         $initialContent->addItem(_('Nejprve je potřeba uložit záznam'));
     } else {
         $hostName = $host->getName();
         $service = new IEService();
         $parentServUsed = array();
         $host_active = (bool) $host->getCfgValue('active_checks_enabled');
         $host_passive = (bool) $host->getCfgValue('passive_checks_enabled');
         $servicesAssigned = $service->myDbLink->queryToArray('SELECT ' . $service->myKeyColumn . ',display_name,' . $service->nameColumn . ' FROM ' . $service->myTable . ' WHERE ' . $fieldName . ' LIKE \'%"' . $host->getName() . '"%\'', $service->myKeyColumn);
         $allServices = $service->getListing(null, true, array('platform', 'parent_id', 'passive_checks_enabled', 'active_checks_enabled', 'display_name'));
         foreach ($allServices as $serviceID => $serviceInfo) {
             $servicePassive = (bool) $serviceInfo['passive_checks_enabled'];
             $serviceActive = (bool) $serviceInfo['active_checks_enabled'];
             if ($serviceInfo['register'] != 1) {
                 unset($allServices[$serviceID]);
                 continue;
             }
             if ($serviceInfo['platform'] != 'generic' && $serviceInfo['platform'] != $host->getDataValue('platform')) {
                 unset($allServices[$serviceID]);
                 continue;
             }
             if ((!$host_passive || !$servicePassive) && (!$host_active || !$serviceActive)) {
                 unset($allServices[$serviceID]);
                 continue;
             }
         }
         foreach ($servicesAssigned as $serviceID => $serviceInfo) {
             if (isset($allServices[$serviceID]) && isset($parentServUsed[$allServices[$serviceID]['parent_id']])) {
                 $parentServUsed[$allServices[$serviceID]['parent_id']] = $allServices[$serviceID]['parent_id'];
             }
             unset($allServices[$serviceID]);
         }
         if (count($allServices)) {
             foreach ($allServices as $serviceID => $serviceInfo) {
                 if (isset($parentServUsed[$serviceInfo['parent_id']])) {
                     continue;
                 }
                 $unchMenu = array();
                 if (intval($serviceInfo['parent_id'])) {
                     $unchMenu[] = new EaseHtmlATag('servicetweak.php?service_id=' . $serviceID, EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Editace'));
                 }
                 $unchMenu[] = new EaseHtmlATag('?addservice=' . $serviceInfo[$service->nameColumn] . '&amp;service_id=' . $serviceID . '&amp;' . $host->getmyKeyColumn() . '=' . $host->getMyKey() . '&amp;' . $host->nameColumn . '=' . $host->getName(), EaseTWBPart::GlyphIcon('plus') . ' ' . _('Začít sledovat'));
                 if (strlen($serviceInfo['display_name'])) {
                     $serviceName = $serviceInfo['display_name'];
                 } else {
                     $serviceName = $serviceInfo[$service->nameColumn];
                 }
                 $initialContent->addItem(new EaseTWBButtonDropdown($serviceName, 'inverse', 'xs', $unchMenu));
             }
         }
         if (count($servicesAssigned)) {
             $saveAsTemplateButton = new EaseTWBLinkButton('stemplate.php?action=copyhost&host_id=' . $host->getId(), _('Uložit jako předlohu'), 'success');
             $initialContent->footer($saveAsTemplateButton);
             $initialContent->addItem('</br>');
             foreach ($servicesAssigned as $serviceID => $serviceInfo) {
                 if (strlen($serviceInfo['display_name'])) {
                     $serviceName = $serviceInfo['display_name'];
                 } else {
                     $serviceName = $serviceInfo[$service->nameColumn];
                 }
                 $initialContent->addItem(new EaseTWBButtonDropdown($serviceName, 'success', 'xs', array(new EaseHtmlATag('?delservice=' . $serviceInfo[$service->nameColumn] . '&amp;service_id=' . $serviceID . '&amp;' . $host->getmyKeyColumn() . '=' . $host->getMyKey() . '&amp;' . $host->nameColumn . '=' . $host->getName(), EaseTWBPart::GlyphIcon('remove') . ' ' . _('Přestat sledovat')), new EaseHtmlATag('servicetweak.php?service_id=' . $serviceID . '&amp;host_id=' . $host->getId(), EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Editace')))));
             }
         } else {
             $presetSelForm = new EaseTWBForm('presetSelForm');
             $presetSelForm->addItem(new EaseHtmlInputHiddenTag($host->getmyKeyColumn(), $host->getId()));
             $presetSelForm->addItem(new EaseHtmlInputHiddenTag('action', 'applystemplate'));
             $presetSelForm->addItem(new IEStemplateSelect('stemplate_id'));
             $presetSelForm->addItem(new EaseTWSubmitButton(_('Aplikovat předlohu'), 'success'));
             $presetSelForm->setTagClass('form-inline');
             $initialContent->footer($presetSelForm);
         }
     }
     $this->addItem($initialContent);
 }