From f85aed2010eb06271fd97c2149d47f3a5f3218df Mon Sep 17 00:00:00 2001 From: Francis Gonzales Date: Tue, 13 May 2014 12:51:23 -0500 Subject: [PATCH] From html form to FormValidator and some JS improvements - refs #6715 --- plugin/ticket/src/new_ticket.php | 468 ++++++++++++++++----------- plugin/ticket/src/ticket_details.php | 312 ++++++++++-------- 2 files changed, 461 insertions(+), 319 deletions(-) diff --git a/plugin/ticket/src/new_ticket.php b/plugin/ticket/src/new_ticket.php index 93b71b1d3c..77159fa754 100644 --- a/plugin/ticket/src/new_ticket.php +++ b/plugin/ticket/src/new_ticket.php @@ -31,19 +31,19 @@ if (api_is_platform_admin()) { $htmlHeadXtra[] = ' @@ -136,19 +160,16 @@ div.row div.formw2 { float:left } div.divTicket { - width: 70%; - float: center; - margin-left: 15%; padding-top: 100px; } '; $types = TicketManager::get_all_tickets_categories(); $htmlHeadXtra[] = ''; + var projects = ' . js_array($types, 'projects', 'project_id') . ' + var course_required = ' . js_array($types, 'course_required', 'course_required') . ' + var other_area = ' . js_array($types, 'other_area', 'other_area') . ' + var email = ' . js_array($types, 'email', 'email') . ' + '; $htmlHeadXtra[] = ''; $htmlHeadXtra[] = ''; @@ -184,158 +205,225 @@ function show_form_send_ticket() { global $types, $plugin; echo '
'; - echo '
'; - echo ''; - - // Category - $select_types = '
-
' . get_lang('Category') . ':
-
'; - $select_types .= '"; - $select_types .= '
'; - echo $select_types; - - $select_course = '
-
'; - echo $select_course; - - // Status - $status = array(); - $status[NEWTCK] = $plugin->get_lang('StsNew'); - $showStatus = "style='display: none;'"; + //End Category List + + //Status List + $statusList = array(); + $statusAttributes = array( + 'style' => 'display: none;', + 'id' => 'status_id', + 'for' => 'status_id' + ); + $statusList[NEWTCK] = $plugin->get_lang('StsNew'); if (api_is_platform_admin()) { - $showStatus = ""; - $status[PENDING] = $plugin->get_lang('StsPending'); - $status[UNCONFIRMED] = $plugin->get_lang('StsUnconfirmed'); - $status[CLOSE] = $plugin->get_lang('StsClose'); - $status[REENVIADO] = $plugin->get_lang('StsForwarded'); - } - $select_status = ' -
-
' . get_lang('Status') . ':
-
- -
-
'; - echo $select_status; - - // Source - $source = array(); + //End Status List + + //Source List + $sourceList = array(); + $sourceAttributes = array( + 'style' => 'display: none;', + 'id' => 'source_id', + 'for' => 'source_id' + ); + $sourceList[SRC_PLATFORM] = $plugin->get_lang('SrcPlatform'); if (api_is_platform_admin()) { - $showBlock = ""; - $source[SRC_EMAIL] = $plugin->get_lang('SrcEmail'); - $source[SRC_PHONE] = $plugin->get_lang('SrcPhone'); - $source[SRC_PRESC] = $plugin->get_lang('SrcPresential'); - } else { - $showBlock = "style='display: none;'"; - $source[SRC_PLATFORM] = $plugin->get_lang('SrcPlatform'); - } - - $select_source = ' -
-
' . $plugin->get_lang('Source') . ':
-
- -
-
'; - echo $select_source; - - // Subject - echo '
' . get_lang('Subject') . ':
-
-
'; - - // Email - echo '
' . $plugin->get_lang('PersonalEmail') . ':
-
-
'; - echo ''; - echo ''; - echo ''; - - // Message - echo '
-
' . get_lang('Message') . ':
-
- - - -
-
'; - - // Phone - echo '
' . get_lang('Phone') . ' (' . $plugin->get_lang('Optional') . '):
-
-
'; - - // Priority - $select_priority = '
-
' . $plugin->get_lang('Priority') . ':
-
'; - - $priority = array(); - $priority[NORMAL] = $plugin->get_lang('PriorityNormal'); - $priority[HIGH] = $plugin->get_lang('PriorityHigh'); - $priority[LOW] = $plugin->get_lang('PriorityLow'); - - $select_priority .= '"; - $select_priority .= '
'; - echo $select_priority; - - // Input file attach - echo '
-
' . get_lang('FilesAttachment') . ':
-
- -
- -
-
-
'; - echo '
-
- - ' . get_lang('AddOneMoreFile') . '  - (' . sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message_max_upload_filesize'))) . ') -
-
'; - echo '
-
-
-
-
-
'; - echo '
'; + //End Source List + + //Priority List + $priorityList = array(); + $priorityList[NORMAL] = $plugin->get_lang('PriorityNormal'); + $priorityList[HIGH] = $plugin->get_lang('PriorityHigh'); + $priorityList[LOW] = $plugin->get_lang('PriorityLow'); + //End Priority List + + $form = new FormValidator('send_ticket', + 'POST', + api_get_self(), + "", + array( + 'enctype' => 'multipart/form-data', + 'onsubmit' => 'return validate()', + 'class' => 'span8 offset1 form-horizontal' + ) + ); + + $form->addElement( + 'hidden', + 'user_id_request', + '', + array( + 'id' => 'user_id_request' + ) + ); + + $form->addElement( + 'hidden', + 'project_id', + '', + array( + 'id' => 'project_id' + ) + ); + + $form->addElement( + 'hidden', + 'other_area', + '', + array( + 'id' => 'other_area' + ) + ); + + $form->addElement( + 'hidden', + 'email', + '', + array( + 'id' => 'email' + ) + ); + + $form->addElement( + 'select', + 'category_id', + get_lang('Category'), + $categoryList, + array( + 'onchange' => 'changeType()', + 'id' => 'category_id', + 'for' => 'category_id', + 'style' => 'width: 562px;' + ) + ); + + $form->addElement( + 'html', + Display::div( + '', + array( + 'id' => 'user_request' + ) + ) + ); + + $form->addElement( + 'select', + 'status_id', + get_lang('Status'), + $statusList, + $statusAttributes + ); + + $form->addElement( + 'select', + 'source_id', + $plugin->get_lang('Source'), + $sourceList, + $sourceAttributes + ); + + $form->addElement( + 'text', + 'subject', + get_lang('Subject'), + array( + 'id' => 'subject', + 'style' => 'width: 550px;' + ) + ); + + $form->addElement( + 'text', + 'personal_email', + $plugin->get_lang('PersonalEmail'), + array( + 'id' => 'personal_email', + 'style' => 'width: 550px;' + ) + ); + + $form->add_html_editor( + 'content', + get_lang('Message'), + false, + false, + array( + 'ToolbarSet' => 'Profile', + 'Width' => '600', + 'Height' => '250' + ) + ); + + $form->addElement( + 'text', + 'phone', + get_lang('Phone') . ' (' . $plugin->get_lang('Optional') . ')', + array( + 'id' => 'phone' + ) + ); + + $form->addElement( + 'select', + 'priority_id', + $plugin->get_lang('Priority'), + $priorityList, + array( + 'id' => 'priority_id', + 'for' => 'priority_id' + ) + ); + + + $form->addElement('html', ''); + $form->addElement('html', '
'); + $form->addElement('file', 'attach_1', get_lang('FilesAttachment')); + $form->addElement('html', '
'); + $form->addElement('html', '
'); + + $form->addElement('html', '
'); + $form->addElement('html', ''); + $form->addElement('html', '' . get_lang('AddOneMoreFile') . ''); + $form->addElement('html', ''); + $form->addElement('html', '(' . sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message_max_upload_filesize'))) . ')'); + + $form->addElement('html', '
'); + $form->addElement( + 'button', + 'compose', + get_lang('SendMessage'), + array( + 'class' => 'save', + 'id' => 'btnsubmit' + ) + ); + + $form->display(); } /** diff --git a/plugin/ticket/src/ticket_details.php b/plugin/ticket/src/ticket_details.php index 4b4500ab7b..75449fc854 100644 --- a/plugin/ticket/src/ticket_details.php +++ b/plugin/ticket/src/ticket_details.php @@ -29,84 +29,114 @@ if ($isAdmin) { $htmlHeadXtra[] = ' '; + $htmlHeadXtra[] = ' '; $ticket_id = $_GET['ticket_id']; @@ -190,6 +227,7 @@ if (isset($_REQUEST['action'])) { break; } } + if (!isset($_POST['compose'])) { if (isset($_POST['close'])) { $_GET['ticket_id'] = $_POST['ticket_id']; @@ -294,26 +332,35 @@ if (!isset($_POST['compose'])) { echo "
"; echo "
"; foreach ($messages as $message) { - $class = "alert alert-info"; + $type = "success"; + if ($message['admin']) { - $class = "alert alert-success"; + $type = "normal"; if ($isAdmin) { $message['message'].='
' . $plugin->get_lang('AttendedBy') . ': ' . $message['user_created'] . " - " . api_convert_and_format_date(api_get_local_time($message['sys_insert_datetime']), DATE_TIME_FORMAT_LONG, _api_get_timezone()) . ""; } }else { $message['message'].='' . get_lang('Sent') . ': ' . api_convert_and_format_date(api_get_local_time($message['sys_insert_datetime']), DATE_TIME_FORMAT_LONG, _api_get_timezone()) . ""; } - echo '
' . get_lang('Subject') . ': ' . $message['subject'] . '
' . get_lang('Message') . ':' . $message['message'] . '
'; + + $receivedMessage = '' . get_lang('Subject') . ': ' . $message['subject'] . '
' . get_lang('Message') . ':' . $message['message'] . '
'; + $attachementLinks = ""; + if (isset($message['atachments'])) { + $attributeClass = array( + 'class' => 'attachment-link' + ); foreach ($message['atachments'] as $attach) { - echo $attach['attachment_link']; + $attachementLinks .= Display::tag('div', $attach['attachment_link'], $attributeClass); } } - echo '
'; + + $entireMessage = $receivedMessage . $attachementLinks; + echo Display::return_message($entireMessage, $type, false); } echo "
"; echo "
"; - $asunto = "RE: " . $message['subject']; + $subject = "RE: " . $message['subject']; $user_admin = api_is_platform_admin(); if ($ticket['ticket']['status_id'] != 'REE' AND $ticket['ticket']['status_id'] != 'CLS') { if (!$isAdmin && $ticket['ticket']['status_id'] != 'XCF') { @@ -340,73 +387,80 @@ function show_form_send_message() { global $isAdmin; global $ticket; - global $asunto; + global $subject; global $plugin; - echo '
-
-
'; - echo '
- -
- -
-
'; - echo '
- -
- - - -
-
-'; - echo ''; - echo '
- -
- -
- -
-
-
-
- - ' . get_lang('AddOneMoreFile') . ' - - - - - (' . sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message_max_upload_filesize'))) . ') -
-
'; + + Display::div('', array('span2')); + + $form = new FormValidator( + 'send_ticket', + 'POST', + api_get_self() . '?ticket_id=' . $ticket['ticket']['ticket_id'], + "", + array( + 'enctype' => 'multipart/form-data', + 'onsubmit' => 'return validate()', + 'class' => 'span9 offset1 form-horizontal' + ) + ); + + $form->addElement( + 'text', + 'subject', + get_lang('Subject'), + array( + 'for' => 'subject', + 'value' => $subject, + 'style' => 'width: 540px;' + ) + ); + + $form->addElement('hidden', 'ticket_id', $_GET['ticket_id']); + + $form->add_html_editor( + 'content', + get_lang('Message'), + false, + false, + array( + 'ToolbarSet' => 'Profile', + 'Width' => '550', + 'Height' => '250' + ) + ); + if ($isAdmin) { - echo '
- -
- -
-
'; + $form->addElement( + 'checkbox', + 'confirmation', + null, + $plugin->get_lang('RequestConfirmation') + ); } - - echo '
- -
'; - echo '
-
- '; + + $form->addElement('html', ''); + $form->addElement('html', '
'); + $form->addElement('file', 'attach_1', get_lang('FilesAttachment')); + $form->addElement('html', '
'); + $form->addElement('html', '
'); + + $form->addElement('html', '
'); + $form->addElement('html', ''); + $form->addElement('html', '' . get_lang('AddOneMoreFile') . ''); + $form->addElement('html', ''); + $form->addElement('html', '(' . sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message_max_upload_filesize'))) . ')'); + + $form->addElement('html', '
'); + $form->addElement( + 'button', + 'compose', + get_lang('SendMessage'), + array( + 'class' => 'save' + ) + ); + + $form->display(); } Display::display_footer();