From aae79a1d0e33849dac8b76e9bfa582211b58e638 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Wed, 13 Oct 2021 14:56:10 +0200 Subject: [PATCH 1/4] WIP import select --- htdocs/imports/import.php | 119 +++++++++++++++++++++++++++++--------- 1 file changed, 92 insertions(+), 27 deletions(-) diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 2ab7e3976aa..fc4a6330b71 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -142,6 +142,8 @@ $updatekeys = (GETPOST('updatekeys', 'array') ? GETPOST('updatekeys', 'array') $separator = (GETPOST('separator', 'nohtml') ? GETPOST('separator', 'nohtml') : (!empty($conf->global->IMPORT_CSV_SEPARATOR_TO_USE) ? $conf->global->IMPORT_CSV_SEPARATOR_TO_USE : ',')); $enclosure = (GETPOST('enclosure', 'nohtml') ? GETPOST('enclosure', 'nohtml') : '"'); +$import_wip = 0; + $objimport = new Import($db); $objimport->load_arrays($user, ($step == 1 ? '' : $datatoimport)); @@ -321,15 +323,30 @@ if ($action == 'saveorder') { $serialized_array_match_file_to_database = ''; $array_match_file_to_database = array(); $fieldsarray = explode(',', $list); - $pos = 0; + if (empty($import_wip)) { + $pos = 0; + } foreach ($fieldsarray as $fieldnb) { // For each elem in list. fieldnb start from 1 to ... // Get name of database fields at position $pos and put it into $namefield - $posbis = 0; $namefield = ''; + if (empty($import_wip)) { + $posbis = 0; + } else { + $pos = 1; + } + + $namefield = ''; foreach ($fieldstarget as $key => $val) { // key: val: //dol_syslog('AjaxImport key='.$key.' val='.$val); - if ($posbis < $pos) { - $posbis++; - continue; + if (empty($import_wip)) { + if ($posbis < $pos) { + $posbis++; + continue; + } + } else { + if ($pos < $fieldnb) { + $pos++; + continue; + } } // We found the key of targets that is at position pos $namefield = $key; @@ -1000,9 +1017,9 @@ if ($step == 4 && $datatoimport) { // List of source fields $var = true; $lefti = 1; - foreach ($array_match_file_to_database as $key => $val) { + foreach ($import_wip?$fieldssource:$array_match_file_to_database as $key => $val) { $var = !$var; - show_elem($fieldssource, $key, $val, $var); // key is field number in source file + show_elem($fieldssource, $key, $val, $var, '', $import_wip); // key is field number in source file //print '> '.$lefti.'-'.$key.'-'.$val; $listofkeys[$key] = 1; $fieldsplaced[$key] = 1; @@ -1021,7 +1038,7 @@ if ($step == 4 && $datatoimport) { while ($lefti <= $num) { $var = !$var; $newkey = getnewkey($fieldssource, $listofkeys); - show_elem($fieldssource, $newkey, '', $var); // key start after field number in source file + show_elem($fieldssource, $newkey, '', $var, '', $import_wip); // key start after field number in source file //print '> '.$lefti.'-'.$newkey; $listofkeys[$key] = 1; $lefti++; @@ -1035,11 +1052,20 @@ if ($step == 4 && $datatoimport) { print ''; // List of target fields - $height = '24px'; //needs px for css height attribute below + if (empty($import_wip)) { + $height = '24px'; //needs px for css height attribute below + } else { + $height = '29px'; + } $i = 0; $mandatoryfieldshavesource = true; - + if (!empty($import_wip)) { + $fieldselect = 1; + } print ''; + if (!empty($import_wip)) { + $pos = 1; + } foreach ($fieldstarget as $code => $label) { print ''; @@ -1054,18 +1080,45 @@ if ($step == 4 && $datatoimport) { print ''; print ''; // Info field print ''; print ''; + if (!empty($import_wip)) { + $fieldselect++; + } } print '
=>'.img_object('', $entityicon).' '.$langs->trans($entitylang).''; - $newlabel = preg_replace('/\*$/', '', $label); - $text = $langs->trans($newlabel); - $more = ''; - if (preg_match('/\*$/', $label)) { - $text = ''.$text.''; - $more = ((!empty($valforsourcefieldnb[$i]) && $valforsourcefieldnb[$i] <= count($fieldssource)) ? '' : img_warning($langs->trans("FieldNeedSource"))); - if ($mandatoryfieldshavesource) { - $mandatoryfieldshavesource = (!empty($valforsourcefieldnb[$i]) && ($valforsourcefieldnb[$i] <= count($fieldssource))); + if (empty($import_wip)) { + $newlabel = preg_replace('/\*$/', '', $label); + $text = $langs->trans($newlabel); + $more = ''; + if (preg_match('/\*$/', $label)) { + $text = ''.$text.''; + $more = ((!empty($valforsourcefieldnb[$i]) && $valforsourcefieldnb[$i] <= count($fieldssource)) ? '' : img_warning($langs->trans("FieldNeedSource"))); + if ($mandatoryfieldshavesource) { + $mandatoryfieldshavesource = (!empty($valforsourcefieldnb[$i]) && ($valforsourcefieldnb[$i] <= count($fieldssource))); + } + //print 'xx'.($i).'-'.$valforsourcefieldnb[$i].'-'.$mandatoryfieldshavesource; } - //print 'xx'.($i).'-'.$valforsourcefieldnb[$i].'-'.$mandatoryfieldshavesource; + print $text; + } else { + print ''; } - print $text; print ''; @@ -1127,6 +1180,9 @@ if ($step == 4 && $datatoimport) { print '
'; @@ -1145,7 +1201,7 @@ if ($step == 4 && $datatoimport) { if (empty($fieldsplaced[$key])) { // $nbofnotimportedfields++; - show_elem($fieldssource, $key, '', $var, 'nostyle'); + show_elem($fieldssource, $key, '', $var, 'nostyle', $import_wip); //print '> '.$lefti.'-'.$key; $listofkeys[$key] = 1; $lefti++; @@ -1154,7 +1210,7 @@ if ($step == 4 && $datatoimport) { // Print one more empty field $newkey = getnewkey($fieldssource, $listofkeys); - show_elem($fieldssource, $newkey, '', $var, 'nostyle'); + show_elem($fieldssource, $newkey, '', $var, 'nostyle', $import_wip); //print '> '.$lefti.'-'.$newkey; $listofkeys[$newkey] = 1; $nbofnotimportedfields++; @@ -1167,7 +1223,7 @@ if ($step == 4 && $datatoimport) { $i = 0; while ($i < $nbofnotimportedfields) { // Print empty cells - show_elem('', '', 'none', $var, 'nostyle'); + show_elem('', '', 'none', $var, 'nostyle', $import_wip); $i++; } print ''; @@ -2089,13 +2145,18 @@ $db->close(); * @param string $key Key * @param boolean $var Line style (odd or not) * @param int $nostyle Hide style + * @param int $import_wip WIP * @return void */ -function show_elem($fieldssource, $pos, $key, $var, $nostyle = '') +function show_elem($fieldssource, $pos, $key, $var, $nostyle = '', $import_wip = 1) { global $langs, $bc; - $height = '24px'; + if (empty($import_wip)) { + $height = '24px'; + } else { + $height = '29px'; + } if ($key == 'none') { //stop multiple duplicate ids with no number @@ -2112,7 +2173,9 @@ function show_elem($fieldssource, $pos, $key, $var, $nostyle = '') if ($pos && $pos > count($fieldssource)) { // No fields print ''; print ''; - print img_picto(($pos > 0 ? $langs->trans("MoveField", $pos) : ''), 'grip_title', 'class="boxhandle" style="cursor:move;"'); + if (empty($import_wip)) { + print img_picto(($pos > 0 ? $langs->trans("MoveField", $pos) : ''), 'grip_title', 'class="boxhandle" style="cursor:move;"'); + } print ''; print ''; print $langs->trans("NoFields"); @@ -2132,7 +2195,9 @@ function show_elem($fieldssource, $pos, $key, $var, $nostyle = '') print ''; print ''; // The image must have the class 'boxhandle' beause it's value used in DOM draggable objects to define the area used to catch the full object - print img_picto($langs->trans("MoveField", $pos), 'grip_title', 'class="boxhandle" style="cursor:move;"'); + if (empty($import_wip)) { + print img_picto($langs->trans("MoveField", $pos), 'grip_title', 'class="boxhandle" style="cursor:move;"'); + } print ''; print ''; print $langs->trans("Field").' '.$pos; From 5dfb496bad53827355ac28c4db39b00140f2c96e Mon Sep 17 00:00:00 2001 From: Lucas Marcouiller Date: Sat, 23 Oct 2021 17:16:19 +0200 Subject: [PATCH 2/4] update import.php to start import to line 2 --- htdocs/imports/import.php | 16 +++++++++++++++- htdocs/langs/en_US/exports.lang | 1 + htdocs/langs/fr_FR/exports.lang | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index fc4a6330b71..d24f9057987 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -136,7 +136,7 @@ $step = (GETPOST('step') ? GETPOST('step') : 1); $import_name = GETPOST('import_name'); $hexa = GETPOST('hexa'); $importmodelid = GETPOST('importmodelid'); -$excludefirstline = (GETPOST('excludefirstline') ? GETPOST('excludefirstline') : 1); +$excludefirstline = (GETPOST('excludefirstline') ? GETPOST('excludefirstline') : 2); $endatlinenb = (GETPOST('endatlinenb') ? GETPOST('endatlinenb') : ''); $updatekeys = (GETPOST('updatekeys', 'array') ? GETPOST('updatekeys', 'array') : array()); $separator = (GETPOST('separator', 'nohtml') ? GETPOST('separator', 'nohtml') : (!empty($conf->global->IMPORT_CSV_SEPARATOR_TO_USE) ? $conf->global->IMPORT_CSV_SEPARATOR_TO_USE : ',')); @@ -1524,6 +1524,20 @@ if ($step == 5 && $datatoimport) { if ($action == 'launchsimu') { print '   '.$langs->trans("Modify").''; } + if ($excludefirstline == 2) { + print $form->textwithpicto("", $langs->trans("WarningFirstImportedLine", $excludefirstline), 1, 'warning', "warningexcludefirstline"); + print ''; + } print ''; // Keys for data UPDATE (not INSERT of new data) diff --git a/htdocs/langs/en_US/exports.lang b/htdocs/langs/en_US/exports.lang index f2f2d2cf587..a20741472b7 100644 --- a/htdocs/langs/en_US/exports.lang +++ b/htdocs/langs/en_US/exports.lang @@ -135,3 +135,4 @@ NbInsert=Number of inserted lines: %s NbUpdate=Number of updated lines: %s MultipleRecordFoundWithTheseFilters=Multiple records have been found with these filters: %s StocksWithBatch=Stocks and location (warehouse) of products with batch/serial number +WarningFirstImportedLine=The first line(s) will not be imported with the current selection diff --git a/htdocs/langs/fr_FR/exports.lang b/htdocs/langs/fr_FR/exports.lang index 5bed116241b..63f155cf9cd 100644 --- a/htdocs/langs/fr_FR/exports.lang +++ b/htdocs/langs/fr_FR/exports.lang @@ -135,3 +135,4 @@ NbInsert=Nombre de lignes insérées: %s NbUpdate=Nombre de lignes mises à jour: %s MultipleRecordFoundWithTheseFilters=Plusieurs enregistrements ont été trouvés avec ces filtres: %s StocksWithBatch=Stocks et entrepôts des produits avec numéro de lot/série +WarningFirstImportedLine=Les première(s) ligne(s) ne seront pas importée(s) avec cette selection From c4efac891a710ca629b7af823efa7d3a75488ad8 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Mon, 20 Dec 2021 16:10:07 +0100 Subject: [PATCH 3/4] remove warning --- htdocs/imports/import.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index edbba1dea5d..566c0c725f9 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -1076,7 +1076,7 @@ if ($step == 4 && $datatoimport) { $tablealias = preg_replace('/(\..*)$/i', '', $code); $tablename = $objimport->array_import_tables[0][$tablealias]; - $entityicon = $entitytoicon[$entity] ? $entitytoicon[$entity] : $entity; // $entityicon must string name of picto of the field like 'project', 'company', 'contact', 'modulename', ... + $entityicon = !empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity; // $entityicon must string name of picto of the field like 'project', 'company', 'contact', 'modulename', ... $entitylang = $entitytolang[$entity] ? $entitytolang[$entity] : $objimport->array_import_label[0]; // $entitylang must be a translation key to describe object the field is related to, like 'Company', 'Contact', 'MyModyle', ... print '=>'.img_object('', $entityicon).' '.$langs->trans($entitylang).''; @@ -1143,7 +1143,7 @@ if ($step == 4 && $datatoimport) { } // Source required $htmltext .= $langs->trans("SourceRequired").': '.yn(preg_match('/\*$/', $label)).'
'; - $example = $objimport->array_import_examplevalues[0][$code]; + $example = !empty($objimport->array_import_examplevalues[0][$code])?$objimport->array_import_examplevalues[0][$code]:""; // Example if (empty($objimport->array_import_convertvalue[0][$code])) { // If source file does not need convertion if ($example) { From 8e11b1c996764e1feb46f798a26c6bb1c59725d1 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Thu, 23 Dec 2021 11:25:57 +0100 Subject: [PATCH 4/4] import with select boxes --- htdocs/imports/import.php | 259 ++++++++++++++++---------------- htdocs/langs/en_US/exports.lang | 3 +- htdocs/langs/fr_FR/exports.lang | 3 +- 3 files changed, 136 insertions(+), 129 deletions(-) diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 566c0c725f9..6913309d620 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -142,7 +142,6 @@ $updatekeys = (GETPOST('updatekeys', 'array') ? GETPOST('updatekeys', 'array') $separator = (GETPOST('separator', 'nohtml') ? GETPOST('separator', 'nohtml') : (!empty($conf->global->IMPORT_CSV_SEPARATOR_TO_USE) ? $conf->global->IMPORT_CSV_SEPARATOR_TO_USE : ',')); $enclosure = (GETPOST('enclosure', 'nohtml') ? GETPOST('enclosure', 'nohtml') : '"'); -$import_wip = 0; $objimport = new Import($db); $objimport->load_arrays($user, ($step == 1 ? '' : $datatoimport)); @@ -161,7 +160,7 @@ foreach ($fieldsarray as $elem) { $tabelem = explode('=', $elem, 2); $key = $tabelem[0]; $val = (isset($tabelem[1]) ? $tabelem[1] : ''); - if ($key && $val) { + if ($key && $val && ($key > 0 && $step != 4)) { $array_match_file_to_database[$key] = $val; } } @@ -323,31 +322,19 @@ if ($action == 'saveorder') { $serialized_array_match_file_to_database = ''; $array_match_file_to_database = array(); $fieldsarray = explode(',', $list); - if (empty($import_wip)) { - $pos = 0; - } + $pos = 0; foreach ($fieldsarray as $fieldnb) { // For each elem in list. fieldnb start from 1 to ... // Get name of database fields at position $pos and put it into $namefield - if (empty($import_wip)) { - $posbis = 0; - } else { - $pos = 1; - } + $posbis = 0; $namefield = ''; foreach ($fieldstarget as $key => $val) { // key: val: //dol_syslog('AjaxImport key='.$key.' val='.$val); - if (empty($import_wip)) { - if ($posbis < $pos) { - $posbis++; - continue; - } - } else { - if ($pos < $fieldnb) { - $pos++; - continue; - } + if ($posbis < $pos) { + $posbis++; + continue; } + // We found the key of targets that is at position pos $namefield = $key; //dol_syslog('AjaxImport Field name found for file field nb '.$fieldnb.'='.$namefield); @@ -1018,9 +1005,9 @@ if ($step == 4 && $datatoimport) { // List of source fields $var = true; $lefti = 1; - foreach ($import_wip?$fieldssource:$array_match_file_to_database as $key => $val) { + foreach ($array_match_file_to_database as $key => $val) { $var = !$var; - show_elem($fieldssource, $key, $val, $var, '', $import_wip); // key is field number in source file + show_elem($fieldssource, $key, $val, $var, 1, '', $listofkeys); // key is field number in source file //print '> '.$lefti.'-'.$key.'-'.$val; $listofkeys[$key] = 1; $fieldsplaced[$key] = 1; @@ -1039,7 +1026,7 @@ if ($step == 4 && $datatoimport) { while ($lefti <= $num) { $var = !$var; $newkey = getnewkey($fieldssource, $listofkeys); - show_elem($fieldssource, $newkey, '', $var, '', $import_wip); // key start after field number in source file + show_elem($fieldssource, $newkey, '', $var, 1, '', $listofkeys); // key start after field number in source file //print '> '.$lefti.'-'.$newkey; $listofkeys[$key] = 1; $lefti++; @@ -1053,20 +1040,14 @@ if ($step == 4 && $datatoimport) { print ''; // List of target fields - if (empty($import_wip)) { - $height = '24px'; //needs px for css height attribute below - } else { - $height = '29px'; - } + // $height = '24px'; //needs px for css height attribute below + $height = '30px'; $i = 0; $mandatoryfieldshavesource = true; - if (!empty($import_wip)) { - $fieldselect = 1; - } + $fieldselect = 1; print ''; - if (!empty($import_wip)) { - $pos = 1; - } + $pos = 1; + foreach ($fieldstarget as $code => $label) { print ''; @@ -1081,49 +1062,22 @@ if ($step == 4 && $datatoimport) { print ''; print ''; // Info field print ''; print ''; - if (!empty($import_wip)) { - $fieldselect++; - } + $fieldselect++; } print '
=>'.img_object('', $entityicon).' '.$langs->trans($entitylang).''; - if (empty($import_wip)) { - $newlabel = preg_replace('/\*$/', '', $label); - $text = $langs->trans($newlabel); - $more = ''; - if (preg_match('/\*$/', $label)) { - $text = ''.$text.''; - $more = ((!empty($valforsourcefieldnb[$i]) && $valforsourcefieldnb[$i] <= count($fieldssource)) ? '' : img_warning($langs->trans("FieldNeedSource"))); - if ($mandatoryfieldshavesource) { - $mandatoryfieldshavesource = (!empty($valforsourcefieldnb[$i]) && ($valforsourcefieldnb[$i] <= count($fieldssource))); - } - //print 'xx'.($i).'-'.$valforsourcefieldnb[$i].'-'.$mandatoryfieldshavesource; + $newlabel = preg_replace('/\*$/', '', $label); + $text = $langs->trans($newlabel); + $more = ''; + if (preg_match('/\*$/', $label)) { + $text = ''.$text.''; + $more = ((!empty($valforsourcefieldnb[$i]) && $valforsourcefieldnb[$i] <= count($fieldssource)) ? '' : img_warning($langs->trans("FieldNeedSource"))); + if ($mandatoryfieldshavesource) { + $mandatoryfieldshavesource = (!empty($valforsourcefieldnb[$i]) && ($valforsourcefieldnb[$i] <= count($fieldssource))); } - print $text; - } else { - print ''; + //print 'xx'.($i).'-'.$valforsourcefieldnb[$i].'-'.$mandatoryfieldshavesource; } + print $text; print ''; - $filecolumn = $array_match_database_to_file[$code]; + $filecolumn = !empty($array_match_database_to_file[$code])?$array_match_database_to_file[$code]:0; // Source field info $htmltext = ''.$langs->trans("FieldSource").'
'; if ($filecolumn > count($fieldssource)) { @@ -1181,9 +1135,7 @@ if ($step == 4 && $datatoimport) { print '
'; @@ -1202,7 +1154,7 @@ if ($step == 4 && $datatoimport) { if (empty($fieldsplaced[$key])) { // $nbofnotimportedfields++; - show_elem($fieldssource, $key, '', $var, 'nostyle', $import_wip); + show_elem($fieldssource, $key, '', $var, 0, 'nostyle', $listofkeys); //print '> '.$lefti.'-'.$key; $listofkeys[$key] = 1; $lefti++; @@ -1211,7 +1163,7 @@ if ($step == 4 && $datatoimport) { // Print one more empty field $newkey = getnewkey($fieldssource, $listofkeys); - show_elem($fieldssource, $newkey, '', $var, 'nostyle', $import_wip); + show_elem($fieldssource, $newkey, '', $var, 1, 'nostyle', $listofkeys); //print '> '.$lefti.'-'.$newkey; $listofkeys[$newkey] = 1; $nbofnotimportedfields++; @@ -1224,7 +1176,7 @@ if ($step == 4 && $datatoimport) { $i = 0; while ($i < $nbofnotimportedfields) { // Print empty cells - show_elem('', '', 'none', $var, 'nostyle', $import_wip); + show_elem('', '', 'none', $var, 0, 'nostyle', $listofkeys); $i++; } print ''; @@ -1235,35 +1187,51 @@ if ($step == 4 && $datatoimport) { if ($conf->use_javascript_ajax) { print ''."\n"; @@ -2162,23 +2130,21 @@ $db->close(); /** * Function to put the movable box of a source field * - * @param array $fieldssource List of source fields - * @param int $pos Pos - * @param string $key Key - * @param boolean $var Line style (odd or not) - * @param int $nostyle Hide style - * @param int $import_wip WIP + * @param array $fieldssource List of source fields + * @param int $pos Pos + * @param string $key Key + * @param boolean $var Line style (odd or not) + * @param boolean $isimportedfield Verify if it's an imported field + * @param int $nostyle Hide style + * @param array $listofkeys List of keys for select boxes * @return void */ -function show_elem($fieldssource, $pos, $key, $var, $nostyle = '', $import_wip = 1) +function show_elem($fieldssource, $pos, $key, $var, $isimportedfield, $nostyle = '', &$listofkeys = array()) { global $langs, $bc; - if (empty($import_wip)) { - $height = '24px'; - } else { - $height = '29px'; - } + // $height = '24px'; + $height = '30px'; if ($key == 'none') { //stop multiple duplicate ids with no number @@ -2195,9 +2161,7 @@ function show_elem($fieldssource, $pos, $key, $var, $nostyle = '', $import_wip = if ($pos && $pos > count($fieldssource)) { // No fields print ''; print ''; - if (empty($import_wip)) { - print img_picto(($pos > 0 ? $langs->trans("MoveField", $pos) : ''), 'grip_title', 'class="boxhandle" style="cursor:move;"'); - } + //print img_picto(($pos > 0 ? $langs->trans("MoveField", $pos) : ''), 'grip_title', 'class="boxhandle" style="cursor:move;"'); print ''; print ''; print $langs->trans("NoFields"); @@ -2212,24 +2176,65 @@ function show_elem($fieldssource, $pos, $key, $var, $nostyle = '', $import_wip = print ' '; print ''; print ''; + } elseif (empty($isimportedfield)) { + $example = !empty($fieldssource[$pos]['example1'])?$fieldssource[$pos]['example1']:""; + if ($example) { + if (!utf8_check($example)) { + $example = utf8_encode($example); + } + print ''; + print ''; + print ' '; + print ''; + print ''; + print $langs->trans("EmptyField").': '; + print ' ('.$example.')'; + print ''; + print ''; + } } else { // Print field of source file print ''; print ''; // The image must have the class 'boxhandle' beause it's value used in DOM draggable objects to define the area used to catch the full object - if (empty($import_wip)) { - print img_picto($langs->trans("MoveField", $pos), 'grip_title', 'class="boxhandle" style="cursor:move;"'); - } + //print img_picto($langs->trans("MoveField", $pos), 'grip_title', 'class="boxhandle" style="cursor:move;"'); print ''; - print ''; - print $langs->trans("Field").' '.$pos; - $example = $fieldssource[$pos]['example1']; + print ''; + $example = !empty($fieldssource[$pos]['example1'])?$fieldssource[$pos]['example1']:""; + if ($example != "") { + print $langs->trans("Field").' '.$pos.': '; + } else { + print $langs->trans("EmptyField").': '; + } if ($example) { if (!utf8_check($example)) { $example = utf8_encode($example); } - print ' ('.$example.')'; } + $nameselect = ($pos > 0) ? $pos : (-$pos); + print ''; + print '