'Entity Association Ruleset', 'padding' => FALSE, 'header-border' => TRUE]);
$form_id = 'rules-' . random_string(8);
//echo '
';
//echo '
';
generate_querybuilder_form($check['entity_type'], 'attribs', $form_id, $check['alert_assoc']);
// FIXME. Duplicated scripts for #btn-save, #btn-reset
$script = "
";
$footer_content
= '
' . $script;
echo generate_box_close(['footer_content' => $footer_content]);
} else {
$box_args = ['title' => 'Associations',
'header-border' => TRUE,
];
if ($_SESSION['userlevel'] >= 9) {
$box_args['header-controls'] = ['controls' => ['edit' => ['text' => 'Add',
'icon' => $config['icon']['plus'],
'url' => '#modal-add_assoc',
'data' => 'data-toggle="modal"']]];
}
echo generate_box_open($box_args);
echo '
';
?>
ID |
Device Match |
Entity Match |
|
$assoc) {
echo('' . PHP_EOL);
echo('' . $assoc['alert_assoc_id'] . ' | ' . PHP_EOL);
echo('');
echo('');
$assoc['device_attribs'] = json_decode($assoc['device_attribs'], TRUE);
$assoc_dev_text = [];
if (is_array($assoc['device_attribs'])) {
foreach ($assoc['device_attribs'] as $attribute) {
echo(escape_html($attribute['attrib']) . ' ');
echo(escape_html($attribute['condition']) . ' ');
echo(escape_html($attribute['value']));
echo(' ');
$assoc_dev_text[] = $attribute['attrib'] . ' ' . $attribute['condition'] . ' ' . $attribute['value'];
}
} else {
echo("*");
}
echo(" ");
echo(' | ');
echo('');
$assoc['entity_attribs'] = json_decode($assoc['entity_attribs'], TRUE);
$assoc_entity_text = [];
if (is_array($assoc['entity_attribs'])) {
foreach ($assoc['entity_attribs'] as $attribute) {
echo(escape_html($attribute['attrib']) . ' ');
echo(escape_html($attribute['condition']) . ' ');
echo(str_replace(',', ',',
escape_html($attribute['value']))); // add empty whitespace to commas for wrap
echo(' ');
$assoc_entity_text[] = $attribute['attrib'] . ' ' . $attribute['condition'] . ' ' . $attribute['value'];
}
} else {
echo("*");
}
echo ' | ';
echo '';
if ($_SESSION['userlevel'] >= 9) {
echo(' ');
$form = [
'type' => 'simple',
'userlevel' => 9, // Minimum user level for display form
'id' => 'assoc_del_' . $assoc['alert_assoc_id'],
//'title' => 'Delete Association Rule (Id: '. $assoc['alert_assoc_id'] . ')',
'style' => 'display:inline;',
];
$form['row'][0]['assoc_id'] = [
'type' => 'hidden',
'value' => $assoc['alert_assoc_id']];
$form['row'][0]['confirm_' . $assoc['alert_assoc_id']] = [
'type' => 'hidden',
'value' => 1];
$form['row'][99]['action'] = [
//$form['row'][99]['submit'] = array(
'type' => 'submit',
'icon_only' => TRUE, // hide button styles
'name' => '',
'icon' => $config['icon']['cancel'],
//'right' => TRUE,
//'class' => 'btn-small',
// confirmation dialog
'attribs' => ['data-toggle' => 'confirmation', // Enable confirmation dialog
'data-confirm-placement' => 'left',
'data-confirm-content' => ' Warning!
This association will be deleted!'],
'value' => 'delete_assoc'];
print_form($form);
unset($form);
}
echo(' | ');
echo('
');
/* Begin Edit association */
/*
$modal_args = array(
'id' => 'modal-edit_alert',
'title' => 'Edit Checker Details',
//'icon' => 'oicon-target',
//'hide' => TRUE,
//'fade' => TRUE,
//'role' => 'dialog',
'class' => 'modal-md',
);
*/
$form = ['type' => 'horizontal',
'userlevel' => 9, // Minimum user level for display form
'id' => 'modal-assoc_edit_' . $assoc['alert_assoc_id'],
'title' => 'Edit Association Conditions (Id: ' . $assoc['alert_assoc_id'] . ')',
//'modal_args' => $modal_args, // !!! This generate modal specific form
//'class' => '', // Clean default box class!
//'help' => 'Please exercise care when editing here.',
//'url' => generate_url(array('page' => 'alert_check')),
];
//$form['fieldset']['body'] = array(//'class' => 'modal-body'); // Required this class for modal body!
// 'offset'=> FALSE); // Do not add 'controls' class, disable 180px margin for form element
//$form['fieldset']['footer'] = array('class' => 'modal-footer'); // Required this class for modal footer!
$form['row'][0]['assoc_id'] = [
'type' => 'hidden',
'fieldset' => 'body',
'value' => $assoc['alert_assoc_id']];
$form['row'][6]['assoc_device_conditions_' . $assoc['alert_assoc_id']] = [
'type' => 'textarea',
'fieldset' => 'body',
'name' => 'Device match',
//'class' => 'input-xlarge',
'width' => '320px',
'rows' => 3,
'placeholder' => TRUE,
'value' => implode("\n", $assoc_dev_text)];
$form['row'][7]['assoc_entity_conditions_' . $assoc['alert_assoc_id']] = [
'type' => 'textarea',
'fieldset' => 'body',
'name' => 'Entity match',
//'class' => 'input-xlarge',
'width' => '320px',
'rows' => 3,
'placeholder' => TRUE,
'value' => implode("\n", $assoc_entity_text)];
$form['row'][99]['close'] = [
'type' => 'submit',
'fieldset' => 'footer',
'div_class' => '', // Clean default form-action class!
'name' => 'Close',
'icon' => '',
'attribs' => ['data-dismiss' => 'modal',
'aria-hidden' => 'true']];
$form['row'][99]['action'] = [
'type' => 'submit',
'fieldset' => 'footer',
'div_class' => '', // Clean default form-action class!
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
//'right' => TRUE,
'class' => 'btn-primary',
'value' => 'assoc_conditions'];
$modals .= generate_form_modal($form);
unset($form, $form_params);
/* End Edit association */
/* Begin delete association */
/*
$modal_args = array(
//'hide' => TRUE,
//'fade' => TRUE,
//'role' => 'dialog',
//'class' => 'modal-md',
);
*/
/* switched to confirm dialog
$form = array('type' => 'horizontal',
'userlevel' => 9, // Minimum user level for display form
'id' => 'modal-assoc_del_'.$assoc['alert_assoc_id'],
'title' => 'Delete Association Rule (Id: '. $assoc['alert_assoc_id'] . ')',
//'modal_args' => $modal_args,
//'help' => 'This will delete the selected association rule.',
//'class' => '', // Clean default box class!
//'url' => ''
);
//$form['fieldset']['body'] = array('class' => 'modal-body'); // Required this class for modal body!
//$form['fieldset']['footer'] = array('class' => 'modal-footer'); // Required this class for modal footer!
$form['row'][0]['assoc_id'] = array(
'type' => 'hidden',
'fieldset' => 'body',
'value' => $assoc['alert_assoc_id']);
$form['row'][0]['action'] = array(
'type' => 'hidden',
'fieldset' => 'body',
'value' => 'delete_assoc');
$form['row'][6]['confirm_'.$assoc['alert_assoc_id']] = array(
'type' => 'checkbox',
'fieldset' => 'body',
'name' => 'Confirm',
//'offset' => FALSE,
'placeholder' => 'Yes, please delete this association rule!',
'onchange' => "javascript: toggleAttrib('disabled', 'delete_assoc_".$assoc['alert_assoc_id']."'); showDiv(!this.checked, 'warning_assoc_".$assoc['alert_assoc_id']."_div');",
'value' => 'confirm');
$form['row'][7]['warning_assoc_'.$assoc['alert_assoc_id']] = array(
'type' => 'html',
'fieldset' => 'body',
'html' => ' Warning!
' .
' This association will be deleted!',
'div_style' => 'display: none', // hide initially
'div_class' => 'alert alert-warning');
$form['row'][99]['close'] = array(
'type' => 'submit',
'fieldset' => 'footer',
'div_class' => '', // Clean default form-action class!
'name' => 'Close',
'icon' => '',
'attribs' => array('data-dismiss' => 'modal', // dismiss modal
'aria-hidden' => 'true')); // do not sent any value
$form['row'][99]['delete_assoc_'.$assoc['alert_assoc_id']] = array(
'type' => 'submit',
'fieldset' => 'footer',
'div_class' => '', // Clean default form-action class!
'name' => 'Delete Association',
'icon' => 'icon-trash icon-white',
//'right' => TRUE,
'class' => 'btn-danger',
'disabled' => TRUE,
'value' => 'delete_assoc');
$modals .= generate_form_modal($form);
unset($form);
*/
/* End delete association */
} // End assocation loop
echo('
');
echo generate_box_close();
/* Begin Add association */
/*
$modal_args = array(
'id' => 'modal-edit_alert',
'title' => 'Edit Checker Details',
//'icon' => 'oicon-target',
//'hide' => TRUE,
//'fade' => TRUE,
//'role' => 'dialog',
'class' => 'modal-md',
);
*/
$form = ['type' => 'horizontal',
'userlevel' => 9, // Minimum user level for display form
'id' => 'modal-add_assoc',
'title' => 'Add Association Conditions',
//'modal_args' => $modal_args, // !!! This generate modal specific form
//'class' => '', // Clean default box class!
//'help' => 'Please exercise care when editing here.',
//'url' => generate_url(array('page' => 'alert_check')),
];
//$form['fieldset']['body'] = array(//'class' => 'modal-body'); // Required this class for modal body!
// 'offset'=> FALSE); // Do not add 'controls' class, disable 180px margin for form element
//$form['fieldset']['footer'] = array('class' => 'modal-footer'); // Required this class for modal footer!
$form['row'][6]['assoc_device_conditions'] = [
'type' => 'textarea',
'fieldset' => 'body',
'name' => 'Device match',
//'class' => 'input-xlarge',
'width' => '320px',
'rows' => 3,
'placeholder' => TRUE,
'value' => ''];
$form['row'][7]['assoc_entity_conditions'] = [
'type' => 'textarea',
'fieldset' => 'body',
'name' => 'Entity match',
//'class' => 'input-xlarge',
'width' => '320px',
'rows' => 3,
'placeholder' => TRUE,
'value' => ''];
$form['row'][99]['close'] = [
'type' => 'submit',
'fieldset' => 'footer',
'div_class' => '', // Clean default form-action class!
'name' => 'Close',
'icon' => '',
'attribs' => ['data-dismiss' => 'modal',
'aria-hidden' => 'true']];
$form['row'][99]['action'] = [
'type' => 'submit',
'fieldset' => 'footer',
'div_class' => '', // Clean default form-action class!
'name' => 'Add Assocation',
'icon' => 'icon-ok icon-white',
//'right' => TRUE,
'class' => 'btn-primary',
'value' => 'assoc_add'];
$modals .= generate_form_modal($form);
unset($form, $form_params);
/* End Add association */
}
?>
'Contacts',
'header-border' => TRUE,
];
if ($_SESSION['userlevel'] >= 9) {
$box_args['header-controls'] = [ 'controls' => [
'all' => [ 'text' => 'Add All',
'icon' => $config['icon']['plus'],
'url' => '#modal-contacts_add_all',
'data' => 'data-toggle="modal"'
],
'clear' => [ 'text' => 'Remove All',
'icon' => $config['icon']['cancel'],
'url' => '#modal-contacts_delete_all',
'data' => 'data-toggle="modal"' ] ]
];
/* Begin to add all contacts */
$form = [
'type' => 'horizontal',
'userlevel' => 9, // Minimum user level for display form
'id' => 'modal-contacts_add_all',
'title' => 'Add All unassociated contacts to Checker',
//'modal_args' => $modal_args,
//'help' => 'This will delete the selected association rule.',
//'class' => '', // Clean default box class!
//'url' => ''
];
//$form['fieldset']['body'] = array('class' => 'modal-body'); // Required this class for modal body!
//$form['fieldset']['footer'] = array('class' => 'modal-footer'); // Required this class for modal footer!
$form['row'][0]['alert_test_id'] = [
'type' => 'hidden',
'fieldset' => 'body',
'value' => $check['alert_test_id']];
$form['row'][0]['contact_id'] = [
'type' => 'hidden',
'fieldset' => 'body',
'value' => 'all'];
$form['row'][0]['action'] = [
'type' => 'hidden',
'fieldset' => 'body',
'value' => 'contact_alert_checker_addall'
];
$form['row'][6]['confirm_add_all'] = [
'type' => 'checkbox',
'fieldset' => 'body',
'name' => 'Confirm',
//'offset' => FALSE,
'placeholder' => 'Yes, please add all contacts to this checker!',
'onchange' => "javascript: toggleAttrib('disabled', 'contact_alert_checker_addall');",
'value' => 'confirm'];
$form['row'][99]['close'] = [
'type' => 'submit',
'fieldset' => 'footer',
'div_class' => '', // Clean default form-action class!
'name' => 'Close',
'icon' => '',
'attribs' => ['data-dismiss' => 'modal', // dismiss modal
'aria-hidden' => 'true']
]; // do not sent any value
$form['row'][99]['contact_alert_checker_addall'] = [
'type' => 'submit',
'fieldset' => 'footer',
'div_class' => '', // Clean default form-action class!
'name' => 'Add Contacts Association',
'icon' => 'icon-ok icon-white',
//'right' => TRUE,
'class' => 'btn-primary',
'disabled' => TRUE,
'value' => 'contact_alert_checker_addall'
];
$modals .= generate_form_modal($form);
unset($form);
/* End add all contacts */
/* Begin delete all contacts */
$form = ['type' => 'horizontal',
'userlevel' => 9, // Minimum user level for display form
'id' => 'modal-contacts_delete_all',
'title' => 'Delete All associated contacts from Checker',
//'modal_args' => $modal_args,
//'help' => 'This will delete the selected association rule.',
//'class' => '', // Clean default box class!
//'url' => ''
];
//$form['fieldset']['body'] = array('class' => 'modal-body'); // Required this class for modal body!
//$form['fieldset']['footer'] = array('class' => 'modal-footer'); // Required this class for modal footer!
$form['row'][0]['alert_test_id'] = [
'type' => 'hidden',
'fieldset' => 'body',
'value' => $check['alert_test_id']];
$form['row'][0]['contact_id'] = [
'type' => 'hidden',
'fieldset' => 'body',
'value' => 'all'];
$form['row'][0]['action'] = [
'type' => 'hidden',
'fieldset' => 'body',
'value' => 'contact_alert_checker_deleteall'
];
$form['row'][6]['confirm_delete_all'] = [
'type' => 'checkbox',
'fieldset' => 'body',
'name' => 'Confirm',
//'offset' => FALSE,
'placeholder' => 'Yes, please delete all contacts from this checker!',
'onchange' => "javascript: toggleAttrib('disabled', 'contact_alert_checker_deleteall');",
'value' => 'confirm'
];
$form['row'][99]['close'] = [
'type' => 'submit',
'fieldset' => 'footer',
'div_class' => '', // Clean default form-action class!
'name' => 'Close',
'icon' => '',
'attribs' => ['data-dismiss' => 'modal', // dismiss modal
'aria-hidden' => 'true']
]; // do not sent any value
$form['row'][99]['contact_alert_checker_deleteall'] = [
'type' => 'submit',
'fieldset' => 'footer',
'div_class' => '', // Clean default form-action class!
'name' => 'Delete Contacts Association',
'icon' => 'icon-trash icon-white',
//'right' => TRUE,
'class' => 'btn-danger',
'disabled' => TRUE,
'value' => 'contact_alert_checker_deleteall'
];
$modals .= generate_form_modal($form);
unset($form);
/* End delete all contacts */
}
echo generate_box_open($box_args);
echo '
';
if (count($contacts)) {
echo '
Transport |
Contact Description |
|
';
foreach ($contacts as $contact) {
$c_exist[$contact['contact_id']] = TRUE;
$form = [
'type' => 'simple',
'userlevel' => 9, // Minimum user level for display form
'id' => 'contact_alert_checker_delete',
//'title' => 'Delete Alert Contact Association',
];
$form['row'][0]['contact_id'] = [
'type' => 'hidden',
'value' => $contact['contact_id']
];
$form['row'][0]['confirm_' . $contact['contact_id']] = [
'type' => 'hidden',
'value' => 1
];
$form['row'][99]['action'] = [
//$form['row'][99]['submit'] = array(
'type' => 'submit',
//'icon_only' => TRUE, // hide button styles
//'fieldset' => 'footer',
//'div_class' => '', // Clean default form-action class!
'name' => '',
'icon' => 'icon-trash',
//'right' => TRUE,
'class' => 'btn-xs btn-danger',
// confirmation dialog
'attribs' => [ 'data-toggle' => 'confirmation', // Enable confirmation dialog
'data-confirm-placement' => 'left',
'data-confirm-content' => 'Delete contact \'' . escape_html($contact['contact_descr']) . '\' association?' ],
'value' => 'contact_alert_checker_delete'
];
echo '
' . $contact['contact_method'] . ' |
' . escape_html($contact['contact_descr']) . ' |
' . generate_form($form) . ' |
';
unset($form);
}
echo '';
} else {
echo '
This alert check is not assigned to any contacts |
';
}
echo '
';
$all_contacts = dbFetchRows('SELECT * FROM `alert_contacts` WHERE `contact_disabled` = 0 ORDER BY `contact_method`, `contact_descr`');
if (safe_count($all_contacts)) {
$form_items = [];
foreach ($all_contacts as $contact) {
if (!isset($c_exist[$contact['contact_id']])) {
$form_items['contacts'][$contact['contact_id']] = [
'name' => $contact['contact_descr'],
'subtext' => $contact['contact_method']
];
}
}
$form = [
'type' => 'simple',
'userlevel' => 9, // Minimum user level for display form
'style' => 'margin:5px;',
'right' => TRUE,
];
$form['row'][0]['type'] = [
'type' => 'hidden',
'value' => 'alert_checker'];
$form['row'][0]['contact_id'] = [
'type' => 'multiselect',
'live-search' => FALSE,
'width' => '220px',
'readonly' => $readonly,
'values' => $form_items['contacts']];
$form['row'][99]['action'] = [
//$form['row'][99]['submit'] = array(
'type' => 'submit',
//'icon_only' => TRUE, // hide button styles
'name' => 'Associate',
'icon' => 'icon-plus-sign',
'readonly' => $readonly,
//'right' => TRUE,
'class' => 'btn-primary',
'value' => 'contact_alert_checker_add'
];
$box_close['footer_content'] = generate_form($form);
$box_close['footer_nopadding'] = TRUE;
unset($form, $form_items);
} else {
// print_warning('No unassociated alert checkers.');
}
echo generate_box_close($box_close);
echo '