Skip to content

Commit

Permalink
Merge pull request #193 from minzords/main
Browse files Browse the repository at this point in the history
Fix Search Button, add info/add button for contract,contact
  • Loading branch information
AntoineLemarchand authored Jan 22, 2024
2 parents f613a68 + 8c24dee commit d38bcc9
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 191 deletions.
8 changes: 7 additions & 1 deletion css/palettes/_itsmng.scss
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,10 @@ ul {

a.vsubmit, .vsubmit a {
color: #8f5a0a;
}
}

.btn-transparent {
background-color: transparent;
border-color: transparent;
color: #fff;
}
2 changes: 0 additions & 2 deletions inc/config.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -675,8 +675,6 @@ function showFormAuthentication() {
return;
}

require_once GLPI_ROOT . '/src/twig/twig.utils.php';

$form = [
'action' => Toolbox::getItemTypeFormURL('config'),
'buttons' => [
Expand Down
2 changes: 2 additions & 0 deletions inc/contact.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,14 @@ function showForm($ID) {
'type' => 'select',
'values' => getOptionForItems("contacttype"),
'value' => $this->fields['contacttypes_id'],
'actions' => getItemActionButtons(['info', 'add'], "contacttype"),
],
__('Title') => [
'name' => 'usertitles_id',
'type' => 'select',
'values' => getOptionForItems("usertitle"),
'value' => $this->fields['usertitles_id'],
'actions' => getItemActionButtons(['info', 'add'], "usertitle"),
],
__('Comments') => [
'name' => 'comment',
Expand Down
1 change: 1 addition & 0 deletions inc/contract.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ function showForm($ID, $options = []) {
'name' => 'contracttypes_id',
'values' => getOptionForItems('ContractType'),
'value' => $this->fields['contracttypes_id'],
'actions' => getItemActionButtons(['info', 'add'], "contracttype"),
],
_x('phone', 'Number') => [
'type' => 'text',
Expand Down
178 changes: 26 additions & 152 deletions inc/mailcollector.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,144 +219,6 @@ static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtem
function showForm($ID) {

return MailServer::showMailServerConfigForm('mailcollector', $this->fields, $this->isNewID($ID), $ID);

// $this->initForm($ID, $options);
// $options['colspan'] = 1;
// $this->showFormHeader($options);

// echo "<tr class='tab_bg_1'><td>";
// echo __('Name');
// echo '&nbsp;';
// Html::showToolTip(__('If name is a valid email address, it will be automatically added to blacklisted senders.'));
// echo "</td><td>";
// Html::autocompletionTextField($this, "name");
// echo "</td></tr>";

// if ($this->fields['errors']) {
// echo "<tr class='tab_bg_1_2'><td>".__('Connection errors')."</td>";
// echo "<td>".$this->fields['errors']."</td>";
// echo "</tr>";
// }

// echo "<tr class='tab_bg_1'><td>".__('Active')."</td><td>";
// Dropdown::showYesNo("is_active", $this->fields["is_active"]);
// echo "</td></tr>";

// $type = Toolbox::showMailServerConfig($this->fields["host"]);

// echo "<tr class='tab_bg_1'><td>".__('Login')."</td><td>";
// Html::autocompletionTextField($this, "login");
// echo "</td></tr>";

// echo "<tr class='tab_bg_1'><td>".__('Password')."</td>";
// echo "<td><input type='password' name='passwd' value='' size='20' autocomplete='new-password'>";
// if ($ID > 0) {
// echo "<input type='checkbox' name='_blank_passwd'>&nbsp;".__('Clear');
// }
// echo "</td></tr>";

// if ($type != "pop") {
// echo "<tr class='tab_bg_1'><td>" . __('Accepted mail archive folder (optional)') . "</td>";
// echo "<td>";
// echo "<input size='30' type='text' id='accepted_folder' name='accepted' value=\"".$this->fields['accepted']."\">";
// echo "<i class='fa fa-list pointer get-imap-folder'></i>";
// echo "</td></tr>\n";

// echo "<tr class='tab_bg_1'><td>" . __('Refused mail archive folder (optional)') . "</td>";
// echo "<td>";
// echo "<input size='30' type='text' id='refused_folder' name='refused' value=\"".$this->fields['refused']."\">";
// echo "<i class='fa fa-list pointer get-imap-folder'></i>";
// echo "</td></tr>\n";
// }

// echo "<tr class='tab_bg_1'>";
// echo "<td width='200px'> ". __('Maximum size of each file imported by the mails receiver').
// "</td><td>";
// self::showMaxFilesize('filesize_max', $this->fields["filesize_max"]);
// echo "</td></tr>";

// echo "<tr class='tab_bg_1'><td>" . __('Use mail date, instead of collect one') . "</td>";
// echo "<td>";
// Dropdown::showYesNo("use_mail_date", $this->fields["use_mail_date"]);
// echo "</td></tr>\n";

// echo "<tr class='tab_bg_1'><td>" . __('Use Reply-To as requester (when available)') . "</td>";
// echo "<td>";
// Dropdown::showFromArray("requester_field", [
// self::REQUESTER_FIELD_FROM => __('No'),
// self::REQUESTER_FIELD_REPLY_TO => __('Yes')
// ], ["value" => $this->fields['requester_field']]);
// echo "</td></tr>\n";

// echo "<tr class='tab_bg_1'><td>" . __('Add CC users as observer') . "</td>";
// echo "<td>";
// Dropdown::showYesNo("add_cc_to_observer", $this->fields["add_cc_to_observer"]);
// echo "</td></tr>\n";

// echo "<tr class='tab_bg_1'><td>" . __('Collect only unread mail') . "</td>";
// echo "<td>";
// Dropdown::showYesNo("collect_only_unread", $this->fields["collect_only_unread"]);
// echo "</td></tr>\n";

// echo "<tr class='tab_bg_1'><td>".__('Comments')."</td>";
// echo "<td><textarea cols='45' rows='5' name='comment' >".$this->fields["comment"]."</textarea>";

// if ($ID > 0) {
// echo "<br>";
// //TRANS: %s is the datetime of update
// printf(__('Last update on %s'), Html::convDateTime($this->fields["date_mod"]));
// }
// echo "</td></tr>";

// $this->showFormButtons($options);

// if ($type != 'pop') {
// echo "<div id='imap-folder'></div>";
// echo Html::scriptBlock("$(function() {
// $('#imap-folder')
// .dialog(options = {
// autoOpen: false,
// autoResize:true,
// width: 'auto',
// modal: true,
// });

// $(document).on('click', '.get-imap-folder', function() {
// var input = $(this).prev('input');

// var data = 'action=getFoldersList';
// data += '&input_id=' + input.attr('id');
// // Get form values without server_mailbox value to prevent filtering
// data += '&' + $(this).closest('form').find(':not([name=\"server_mailbox\"])').serialize();
// // Force empty value for server_mailbox
// data += '&server_mailbox=';

// $('#imap-folder')
// .html('')
// .load('".$CFG_GLPI['root_doc']."/ajax/mailcollector.php', data)
// .dialog('open');
// });

// $(document).on('click', '.select_folder li', function(event) {
// event.stopPropagation();

// var li = $(this);
// var input_id = li.data('input-id');
// var folder = li.children('.folder-name').html();

// var _label = '';
// var _parents = li.parents('li').children('.folder-name');
// for (i = _parents.length -1 ; i >= 0; i--) {
// _label += $(_parents[i]).html() + '/';
// }
// _label += folder;

// $('#'+input_id).val(_label);
// $('#imap-folder').dialog('close');
// })
// });");
// }
return true;
}

/**
Expand Down Expand Up @@ -426,20 +288,32 @@ private function displayFolder($folder, $input_id) {
}


function showGetMessageForm($ID) {

echo "<br><br><div class='center'>";
echo "<form name='form' method='post' action='".Toolbox::getItemTypeFormURL(__CLASS__)."'>";
echo "<table class='tab_cadre'>";
echo "<tr class='tab_bg_2'><td class='center'>";
echo "<input type='submit' name='get_mails' value=\""._sx('button', 'Get email tickets now').
"\" class='submit'>";
echo "<input type='hidden' name='id' value='$ID'>";
echo "</td></tr>";
echo "</table>";
Html::closeForm();
echo "</div>";
}
function showGetMessageForm($ID) {
$form = [
'action' => Toolbox::getItemTypeFormURL(__CLASS__),
'buttons' => [
[
'type' => 'submit',
'name' => 'get_mails',
'value' => _sx('button', 'Get email tickets now'),
'class' => 'btn btn-secondary',
]
],
'content' => [
'' => [
'visible' => true,
'inputs' => [
$this->isNewID($ID) ? [] : [
'type' => 'hidden',
'name' => 'id',
'value' => $ID
]
]
]
]
];
renderTwigForm($form);
}


function rawSearchOptions() {
Expand Down
102 changes: 70 additions & 32 deletions inc/notepad.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,24 +307,44 @@ static function showForItem(CommonDBTM $item, $withtemplate = 0) {

if ($canedit
&& !(!empty($withtemplate) && ($withtemplate == 2))) {
echo "<div class='boxnote center'>";

echo "<div class='boxnoteleft'></div>";
echo "<form name='addnote_form$rand' id='addnote_form$rand' ";
echo " method='post' action='".Toolbox::getItemTypeFormURL('Notepad')."'>";
echo Html::hidden('itemtype', ['value' => $item->getType()]);
echo Html::hidden('items_id', ['value' => $item->getID()]);

echo "<div class='boxnotecontent'>";
echo "<textarea name='content' rows=5 cols=100></textarea>";
echo "</div>"; // box notecontent

echo "<div class='boxnoteright'><br>";
echo Html::submit(_x('button', 'Add'), ['name' => 'add']);
echo "</div>";

Html::closeForm();
echo "</div>"; // boxnote
$form = [
'action' => Toolbox::getItemTypeFormURL('Notepad'),
'buttons' => [
[
'type' => 'submit',
'name' => 'add',
'value' => _x('button', 'Add'),
'class' => 'btn btn-secondary',
],
],
'content' => [
__('Comment') => [
'visible' => true,
'inputs' => [
'itemtype' => [
'type' => 'hidden',
'name' => 'itemtype',
'value' => $item->getType()
],
'items_id' => [
'type' => 'hidden',
'name' => 'items_id',
'value' => $item->getID()
],
'' => [
'name' => 'content',
'type' => 'textarea',
'col_lg' => 12,
'col_md' => 12,
'rows' => 3,
'value' => ''
],
]
]
]
];
renderTwigForm($form);
}

if (count($notes)) {
Expand Down Expand Up @@ -387,21 +407,39 @@ static function showForItem(CommonDBTM $item, $withtemplate = 0) {

if ($canedit) {
echo "<div class='boxnote starthidden' id='edit$id'>";
echo "<form name='update_form$id$rand' id='update_form$id$rand' ";
echo " method='post' action='".Toolbox::getItemTypeFormURL('Notepad')."'>";

echo "<div class='boxnoteleft'></div>";
echo "<div class='boxnotecontent'>";
echo Html::hidden('id', ['value' => $note['id']]);
echo "<textarea name='content' rows=5 cols=100>".$note['content']."</textarea>";
echo "</div>"; // boxnotecontent

echo "<div class='boxnoteright'><br>";
echo Html::submit(_x('button', 'Update'), ['name' => 'update']);
echo "</div>"; // boxnoteright

Html::closeForm();
echo "</div>"; // boxnote
$form = [
'action' => Toolbox::getItemTypeFormURL('Notepad'),
'buttons' => [
[
'type' => 'submit',
'name' => 'update',
'value' => _x('button', 'Update'),
'class' => 'btn btn-secondary',
],
],
'content' => [
__('Comment') => [
'visible' => true,
'inputs' => [
'id' => [
'type' => 'hidden',
'name' => 'id',
'value' => $note['id']
],
'' => [
'name' => 'content',
'type' => 'textarea',
'col_lg' => 12,
'col_md' => 12,
'rows' => 3,
'value' => $note['content'] ?? '',
],
]
]
]
];
renderTwigForm($form);
echo "</div>";
}
}
}
Expand Down
14 changes: 10 additions & 4 deletions templates/menus/headers/header.twig
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,16 @@
<span class='sr-only'>{{"Home"|trans}}</span>
</a>
</div>
<div id="searchbar">
<input id="searchbar" type="search" placeholder="{{"Search"|trans}}...">
<i class="fa fa-search"></i>
</div>

<div id="searchbar">
<form role="search" method="get" action="/front/search.php">
<input type="search" name="globalsearch" placeholder="{{"Search"|trans}}...">
<button type="submit" class="btn-transparent">
<i class="fa fa-search"></i>
</button>
</form>
</div>

<ul class='d-flex justify-content-around m-0'>
<li id='language_link' class="p-2">
<a href="{{root_doc}}/front/preference.php?forcetab=User$1" title={{'Language'|trans}}>
Expand Down

0 comments on commit d38bcc9

Please sign in to comment.