Skip to content

Commit

Permalink
Merge branch 'release/1.10.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-anne committed Jun 4, 2019
2 parents 64765b9 + a80eaee commit 1334deb
Show file tree
Hide file tree
Showing 33 changed files with 213 additions and 168 deletions.
86 changes: 63 additions & 23 deletions ajax/reorder.php
Original file line number Diff line number Diff line change
@@ -1,31 +1,71 @@
<?php
include ("../../../inc/includes.php");

$table = PluginFieldsField::getTable();
if (!array_key_exists('container_id', $_POST)
|| !array_key_exists('old_order', $_POST)
|| !array_key_exists('new_order', $_POST)) {
// Missing input
exit();
}

$table = PluginFieldsField::getTable();
$container_id = (int)$_POST['container_id'];
$old_order = (int)$_POST['old_order'];
$new_order = (int)$_POST['new_order'];

// Retrieve id of field to update
$field_iterator = $DB->request(
[
'SELECT' => 'id',
'FROM' => $table,
'WHERE' => [
'plugin_fields_containers_id' => $container_id,
'ranking' => $old_order,
],
]
);

if (0 === $field_iterator->count()) {
// Unknown field
exit();
}

// Récupération de l'ID du champ à modifier
$query = "SELECT id FROM $table
WHERE plugin_fields_containers_id = {$_POST['container_id']}
AND `ranking` = {$_POST['old_order']}";
$result = $DB->queryOrDie($query, 'Erreur');
$first = $result->fetch_assoc();
$id_item = $first['id'];
$field_id = $field_iterator->next()['id'];

// Réorganisation de tout les champs
if ($_POST['old_order'] < $_POST['new_order']) {
$DB->query("UPDATE $table SET
`ranking` = `ranking`-1
WHERE plugin_fields_containers_id = {$_POST['container_id']}
AND `ranking` > {$_POST['old_order']}
AND `ranking` <= {$_POST['new_order']}");
// Move all elements to their new ranking
if ($old_order < $new_order) {
$DB->update(
$table,
[
'ranking' => new \QueryExpression($DB->quoteName('ranking') . ' - 1'),
],
[
'plugin_fields_containers_id' => $container_id,
['ranking' => ['>', $old_order]],
['ranking' => ['<=', $new_order]],
]
);
} else {
$DB->query("UPDATE $table SET
`ranking` = `ranking`+1
WHERE plugin_fields_containers_id = {$_POST['container_id']}
AND `ranking` < {$_POST['old_order']}
AND `ranking` >= {$_POST['new_order']}");
$DB->update(
$table,
[
'ranking' => new \QueryExpression($DB->quoteName('ranking') . ' + 1'),
],
[
'plugin_fields_containers_id' => $container_id,
['ranking' => ['<', $old_order]],
['ranking' => ['>=', $new_order]],
]
);
}

$DB->query("UPDATE $table SET
`ranking` = {$_POST['new_order']}
WHERE id = $id_item");
// Update current element
$DB->update(
$table,
[
'ranking' => $new_order,
],
[
'id' => $field_id,
]
);
66 changes: 33 additions & 33 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion inc/container.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,8 @@ static function getItemtypes($is_domtab) {
'Supplier' => Supplier::getTypeName(2),
'Contact' => Contact::getTypeName(2),
'Contract' => Contract::getTypeName(2),
'Document' => Document::getTypeName(2)
'Document' => Document::getTypeName(2),
'Line' => Line::getTypeName(2),
];

$tabs[__('Tools')] = [
Expand Down
2 changes: 1 addition & 1 deletion inc/field.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ static function prepareHtmlFields($fields, $items_id, $itemtype, $canedit = true
break;
case 'dropdownuser':
if ($massiveaction) {
continue;
break;
}
if ($canedit && !$readonly) {
$html.= User::dropdown(['name' => $field['name'],
Expand Down
Binary file modified locales/cs_CZ.mo
Binary file not shown.
24 changes: 12 additions & 12 deletions locales/cs_CZ.po
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
# Translators:
# David Stepan <[email protected]>, 2016
# Merlin Merlin <[email protected]>, 2017
# Pavel Borecki <[email protected]>, 2018
# Pavel Borecki <[email protected]>, 2018-2019
msgid ""
msgstr ""
"Project-Id-Version: GLPI Plugin - Fields\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-02 10:39+0000\n"
"PO-Revision-Date: 2019-05-02 10:39+0000\n"
"Last-Translator: Cédric Anne\n"
"POT-Creation-Date: 2019-06-04 12:47+0000\n"
"PO-Revision-Date: 2019-05-03 11:12+0000\n"
"Last-Translator: Pavel Borecki <[email protected]>\n"
"Language-Team: Czech (Czech Republic) (http://www.transifex.com/teclib/glpi-plugin-plugin-fields/language/cs_CZ/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -111,7 +111,7 @@ msgstr "Znovu vytvořit kontejnerové soubory"

#: inc/container.class.php:87
msgid "Fix container names"
msgstr ""
msgstr "Opravit názvy kontejnerů"

#: inc/container.class.php:168
msgid "Updating generated containers files"
Expand Down Expand Up @@ -145,27 +145,27 @@ msgstr "Blok"
msgid "Tab"
msgstr "Tabulka"

#: inc/container.class.php:824
#: inc/container.class.php:825
msgid "Add tab"
msgstr "Přidat tabulku"

#: inc/container.class.php:825
#: inc/container.class.php:826
msgid "Insertion in the form (before save button)"
msgstr "Vložení do formuláře (před tlačítkem uložit)"

#: inc/container.class.php:826
#: inc/container.class.php:827
msgid "Insertion in the form of a specific tab (before save button)"
msgstr "Vložení do formuláře konkrétního panelu (před tlačítkem uložit)"

#: inc/container.class.php:1188
#: inc/container.class.php:1189
msgid "Some mandatory fields are empty"
msgstr "Některá povinná pole nejsou vyplněná"

#: inc/container.class.php:1193
#: inc/container.class.php:1194
msgid "Some numeric fields contains non numeric values"
msgstr "Některé číselné kolonky obsahují nečíselné hodnoty"

#: inc/container.class.php:1198
#: inc/container.class.php:1199
msgid "Some URL fields contains invalid links"
msgstr "Některé URL kolonky obsahují neplatné odkazy"

Expand All @@ -183,4 +183,4 @@ msgstr "Aktualizují se vytvořené soubory rozbalovací nabídky"

#: inc/toolbox.class.php:90
msgid "Fix fields names"
msgstr ""
msgstr "Opravit názvy kolonek"
Binary file modified locales/en_GB.mo
Binary file not shown.
Loading

0 comments on commit 1334deb

Please sign in to comment.