diff --git a/pandora_console/general/help_feedback.php b/pandora_console/general/help_feedback.php new file mode 100644 index 0000000000..1f702d6d36 --- /dev/null +++ b/pandora_console/general/help_feedback.php @@ -0,0 +1,77 @@ + '[HelpFeedBack]'.$e->getMessage() ]); + exit; + } else { + echo '[HelpFeedBack]'.$e->getMessage(); + } + + // Stop this execution, but continue 'globally'. + return; +} + +// Ajax controller. +if (is_ajax()) { + $method = get_parameter('method', ''); + + if (method_exists($helpfeedback, $method) === true) { + if ($helpfeedback->ajaxMethod($method) === true) { + $helpfeedback->{$method}(); + } else { + $helpfeedback->error('Unavailable method.'); + } + } else { + $helpfeedback->error('Method not found. ['.$method.']'); + } + + + // Stop any execution. + exit; +} else { + // Run. + $helpfeedback->run(); +} diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index cb29d78c06..5ffeb716d9 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -404,13 +404,42 @@ class Wizard /** * Print a block of inputs. + * Example, using direct to 'anidate' inputs directly to wrapper: + * [ + * 'wrapper' => 'div', + * 'block_id' => 'example_id', + * 'class' => 'your class', + * 'direct' => 1, + * 'block_content' => [ + * [ + * 'arguments' => [ + * 'label' => __('Sugesstion'), + * 'type' => 'button', + * 'attributes' => 'class="sub ok btn_sug"', + * 'name' => 'option_1', + * 'id' => 'option_1', + * 'script' => 'change_option1()', + * ], + * ], + * [ + * 'arguments' => [ + * 'label' => __('Something is not quite right'), + * 'type' => 'button', + * 'attributes' => 'class="sub ok btn_something"', + * 'name' => 'option_2', + * 'id' => 'option_2', + * 'script' => 'change_option2()', + * ], + * ], + * ], + * ]. * * @param array $input Definition of target block to be printed. * @param boolean $return Return as string or direct output. * * @return string HTML content. */ - public function printBlock(array $input, bool $return=false) + public function printBlock(array $input, bool $return=false, bool $not_direct=false) { $output = ''; if ($input['hidden'] == 1) { @@ -424,33 +453,47 @@ class Wizard } if (is_array($input['block_content']) === true) { + $not_direct = (bool) $input['direct']; + // Print independent block of inputs. + $output .= '
  • '; + if ($input['wrapper']) { - $output .= '
  • '; $output .= '<'.$input['wrapper'].' id="'.$input['block_id'].'" class="'.$class.'">'; - } else { - $output .= '
  • '; } - $output .= '
  • '; + if (!$not_direct) { + $output .= ''; } + + if ($input['wrapper']) { + $output .= ''; + } + + $output .= ''; } else { if ($input['arguments']['type'] != 'hidden') { - $output .= '
  • '; + if (!$not_direct) { + $output .= '
  • '; + } + $output .= ''; $output .= $this->printInput($input['arguments']); // Allow dynamic content. $output .= $input['extra']; - $output .= '
  • '; + if (!$not_direct) { + $output .= ''; + } } else { $output .= $this->printInput($input['arguments']); // Allow dynamic content. diff --git a/pandora_console/include/class/HelpFeedBack.class.php b/pandora_console/include/class/HelpFeedBack.class.php new file mode 100644 index 0000000000..074f3d8df2 --- /dev/null +++ b/pandora_console/include/class/HelpFeedBack.class.php @@ -0,0 +1,310 @@ +AJAXMethods); + } + + + /** + * Constructor. + * + * @param string $ajax_controller Controller. + * + * @return object + */ + public function __construct($ajax_controller) + { + $this->ajaxController = $ajax_controller; + + return $this; + } + + + /** + * Main method. + * + * @return void + */ + public function run() + { + ui_require_css_file('help_feedback'); + + $help_url = get_parameter('url', null); + if ($help_url === null) { + echo __('Page not found'); + } else { + ?> + + '; + // Load feedback form. + echo $this->loadFeedbackForm(); + echo ''; + } + + + /** + * Loads a feedback form + * + * @return​ ​string HTML code for form. + * + * @return Function loadFeedbackForm. + */ + public function loadFeedbackForm() + { + global $config; + + ui_require_css_file('helper'); + + $form = [ + 'action' => '#', + 'id' => 'feedback_form', + 'onsubmit' => 'return false;', + ]; + + $inputs = [ + [ + 'wrapper' => 'div', + 'block_id' => 'btn_section', + 'class' => 'btn_section', + 'direct' => 1, + 'block_content' => [ + [ + 'arguments' => [ + 'label' => __('Sugesstion'), + 'type' => 'button', + 'attributes' => 'class="btn_sug"', + 'name' => 'option_1', + 'id' => 'option_1', + 'script' => 'change_option1()', + ], + ], + [ + 'arguments' => [ + 'label' => __('Something is not quite right'), + 'type' => 'button', + 'attributes' => 'class="btn_something"', + 'name' => 'option_2', + 'id' => 'option_2', + 'script' => 'change_option2()', + ], + ], + ], + ], + [ + + 'label' => __('What Happend?'), + 'arguments' => [ + 'class' => 'textarea_feedback', + 'id' => 'feedback_text', + 'type' => 'textarea', + 'name' => 'feedback_text', + ], + ], + [ + 'label' => __('Your Email'), + 'arguments' => [ + 'id' => 'feedback_email', + 'name' => 'feedback_email', + 'input_class' => 'email_feedback', + 'class' => 'email_feedback', + 'type' => 'text', + ], + ], + [ + 'arguments' => [ + 'button_class' => 'btn_submit', + 'class' => 'btn_submit', + 'attributes' => 'class="sub next btn_submit_feed_back"', + 'type' => 'submit', + 'id' => 'submit_feedback', + 'label' => __('Submit'), + ], + ], + ]; + + $output = ui_toggle( + $this->printForm( + [ + 'form' => $form, + 'inputs' => $inputs, + ], + true + ), + __('Feedback'), + '', + '', + true, + false, + '', + 'no-border' + ); + + $output .= $this->loadJS(); + return $output; + } + + + /** + * Function send_mail_method,we use send_email_attachment method + * from functions_cron.php. + * + * @param​ ​string​ $feedback_option type fo mail. + * @param​ ​string​ $feedback_text text mail. + * @param​ ​string​ $feedback_mail costumer mail. + * + * @return integer Status of the email send task. + */ + public function sendMailMethod() + { + $subject = get_parameter('feedback_option', null); + $feedback_text = get_parameter('feedback_text', null); + $feedback_mail = get_parameter('feedback_email', null); + + $subject; + + if ($subject === null) { + echo json_encode(['error' => __('No ha seleccionado una opcion')]); + exit; + } + + enterprise_include_once('include/functions_cron.php'); + + $feedback_text .= ' + From '.$feedback_mail.' '; + + $res = enterprise_hook('send_email_attachment', ['feedback@artica.es', $feedback_text, $subject]); + + return $res; + + } + + + public function loadJS() + { + ob_start(); + ?> + + 'img_help', 'title' => __('Help'), - 'onclick' => "open_help ('".$url."')", + 'onclick' => "open_help ('".ui_get_full_url('index.php?sec=view&sec2=general/help_feedback&pure=1&url='.$url)."')", 'id' => $id, ], false, diff --git a/pandora_console/include/styles/help_feedback.css b/pandora_console/include/styles/help_feedback.css new file mode 100644 index 0000000000..3368f5b3d7 --- /dev/null +++ b/pandora_console/include/styles/help_feedback.css @@ -0,0 +1,105 @@ +html, +body { + width: 100%; + height: 100%; +} + +div.help_feedback { + position: fixed; + bottom: 0; + background: white; + height: auto; + width: 365px; + padding-left: 10px; + padding-right: 10px; +} + +.btn_sug { + margin-right: 10px; + margin-top: 10px; + margin-left: 10px; + + font-weight: normal; + -moz-border-radius: 2px; + -webkit-border-radius: 2px; + border-radius: 2px; + font-size: 1.2em; + background-repeat: no-repeat; + background-position: 92% 10px; + color: #000; + padding-bottom: 10px; + padding-top: 10px; + padding-left: 10px; + border: none; + font-family: "lato", "Open Sans", sans-serif; + cursor: pointer; + padding-right: 30px; +} + +.btn_something { + margin-top: 10px; + margin-left: 10px; + + font-weight: normal; + -moz-border-radius: 2px; + -webkit-border-radius: 2px; + border-radius: 2px; + font-size: 1.2em; + background-repeat: no-repeat; + background-position: 92% 10px; + color: #000; + padding-bottom: 10px; + padding-top: 10px; + padding-left: 10px; + border: none; + font-family: "lato", "Open Sans", sans-serif; + cursor: pointer; + padding-right: 30px; +} + +.textarea_feedback { + margin-left: 11px; + max-width: 200px; + margin-top: 10px; + font-weight: bolder; +} + +.email_feedback { + max-width: 200px; + margin-left: 39px; + margin-top: 10px; + margin-bottom: 10px; + font-weight: bolder; +} + +.btn_submit_feed_back { + margin-right: 50px; + margin-top: 5px; + margin-bottom: 10px; +} + +.btn_sug_not_selected { + font-weight: normal; + -moz-border-radius: 2px; + -webkit-border-radius: 2px; + border-radius: 2px; + font-size: 1.2em; + background-repeat: no-repeat; + background-position: 92% 10px; + color: #000; + padding-bottom: 10px; + padding-top: 10px; + padding-left: 10px; + border: 1px solid #888; + font-family: "lato", "Open Sans", sans-serif; + cursor: pointer; + margin-right: 20px; + margin-top: 10px; + margin-left: 10px; + background-image: url(../../images/input_tick.png); + padding-right: 30px; +} + +.btn_section { + display: flex; +}