From 0674d062f8b0b3f07219ae674b138846f5fc39e5 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Fri, 15 Apr 2022 11:55:24 +0200 Subject: [PATCH 01/41] select on source fields import --- htdocs/imports/import.php | 583 +++++++++++++++++++++++++++++++- htdocs/langs/en_US/exports.lang | 1 + 2 files changed, 580 insertions(+), 4 deletions(-) diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 01f152f1ea5..b3303402d22 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -35,6 +35,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/import.lib.php'; // Load translation files required by the page $langs->loadLangs(array('exports', 'compta', 'errors')); +$selectimport = true; + // Security check $result = restrictedArea($user, 'import'); @@ -136,7 +138,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 : ',')); @@ -763,7 +765,7 @@ if ($step == 3 && $datatoimport) { // STEP 4: Page to make matching between source file and database fields -if ($step == 4 && $datatoimport) { +if ($step == 4 && $datatoimport && !$selectimport) { $model = $format; $list = $objmodelimport->liste_modeles($db); @@ -1315,6 +1317,565 @@ if ($step == 4 && $datatoimport) { } } +if ($step == 4 && $datatoimport && $selectimport) { + $model = $format; + $list = $objmodelimport->liste_modeles($db); + + // Create classe to use for import + $dir = DOL_DOCUMENT_ROOT."/core/modules/import/"; + $file = "import_".$model.".modules.php"; + $classname = "Import".ucfirst($model); + require_once $dir.$file; + $obj = new $classname($db, $datatoimport); + if ($model == 'csv') { + $obj->separator = $separator_used; + $obj->enclosure = $enclosure; + } + if ($model == 'xlsx') { + if (!preg_match('/\.xlsx$/i', $filetoimport)) { + $langs->load("errors"); + $param = '&datatoimport='.$datatoimport.'&format='.$format; + setEventMessages($langs->trans("ErrorFileMustHaveFormat", $model), null, 'errors'); + header("Location: ".$_SERVER["PHP_SELF"].'?step=3'.$param.'&filetoimport='.urlencode($relativepath)); + exit; + } + } + + if (GETPOST('update')) { + $array_match_file_to_database = array(); + } + + // Load source fields in input file + $fieldssource = array(); + $result = $obj->import_open_file($conf->import->dir_temp.'/'.$filetoimport, $langs); + if ($result >= 0) { + // Read first line + $arrayrecord = $obj->import_read_record(); + // Put into array fieldssource starting with 1. + $i = 1; + foreach ($arrayrecord as $key => $val) { + $fieldssource[$i]['example1'] = dol_trunc($val['val'], 24); + $i++; + } + $obj->import_close_file(); + } + + // Load targets fields in database + $fieldstarget = $objimport->array_import_fields[0]; + $fieldstarget_tmp = array(); + + foreach ($fieldstarget as $key => $label) { + $isrequired = preg_match('/\*$/', $label); + if (!empty($isrequired)) { + $newlabel = substr($label, 0, -1); + $fieldstarget_tmp[$key] = array("label"=>$newlabel,"required"=>true); + } else { + $fieldstarget_tmp[$key] = array("label"=>$label,"required"=>false); + } + $fieldstarget_tmp[$key]["imported"] = true; + } + $fieldstarget = $fieldstarget_tmp; + $maxpos = max(count($fieldssource), count($fieldstarget)); + + //var_dump($array_match_file_to_database); + + // Is it a first time in page (if yes, we must initialize array_match_file_to_database) + if (count($array_match_file_to_database) == 0) { + // This is first input in screen, we need to define + // $array_match_file_to_database + // $serialized_array_match_file_to_database + // $_SESSION["dol_array_match_file_to_database"] + $pos = 1; + $num = count($fieldssource); + while ($pos <= $num) { + if ($num >= 1 && $pos <= $num) { + $posbis = 1; + foreach ($fieldstarget as $key => $val) { + if ($posbis < $pos) { + $posbis++; + continue; + } + // We found the key of targets that is at position pos + $array_match_file_to_database[$pos] = $key; + if ($serialized_array_match_file_to_database) { + $serialized_array_match_file_to_database .= ','; + } + $serialized_array_match_file_to_database .= ($pos.'='.$key); + break; + } + } + $pos++; + } + // Save the match array in session. We now will use the array in session. + $_SESSION["dol_array_match_file_to_database"] = $serialized_array_match_file_to_database; + } + $array_match_database_to_file = array_flip($array_match_file_to_database); + + //print $serialized_array_match_file_to_database; + //print $_SESSION["dol_array_match_file_to_database"]; + //var_dump($array_match_file_to_database);exit; + + // Now $array_match_file_to_database contains fieldnb(1,2,3...)=>fielddatabase(key in $array_match_file_to_database) + + $param = '&format='.$format.'&datatoimport='.urlencode($datatoimport).'&filetoimport='.urlencode($filetoimport); + if ($excludefirstline) { + $param .= '&excludefirstline='.urlencode($excludefirstline); + } + if ($endatlinenb) { + $param .= '&endatlinenb='.urlencode($endatlinenb); + } + if ($separator) { + $param .= '&separator='.urlencode($separator); + } + if ($enclosure) { + $param .= '&enclosure='.urlencode($enclosure); + } + + llxHeader('', $langs->trans("NewImport"), $help_url); + + $head = import_prepare_head($param, 4); + + print dol_get_fiche_head($head, 'step4', '', -2); + + print '
'; + print '
'; + + print ''; + + // Module + print ''; + print ''; + + // Lot de donnees a importer + print ''; + print ''; + + print '
'.$langs->trans("Module").''; + $titleofmodule = $objimport->array_import_module[0]['module']->getName(); + // Special cas for import common to module/services + if (in_array($objimport->array_import_code[0], array('produit_supplierprices', 'produit_multiprice', 'produit_languages'))) { + $titleofmodule = $langs->trans("ProductOrService"); + } + print $titleofmodule; + print '
'.$langs->trans("DatasetToImport").''; + $entity = preg_replace('/:.*$/', '', $objimport->array_import_icon[0]); + $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity); + print img_object($objimport->array_import_module[0]['module']->getName(), $entityicon).' '; + print $objimport->array_import_label[0]; + print '
'; + print '
'; + + print load_fiche_titre($langs->trans("InformationOnSourceFile"), '', 'file-export'); + + print '
'; + print '
'; + print ''; + + // Source file format + print ''; + print ''; + + // Separator and enclosure + if ($model == 'csv') { + print ''; + print ''; + } + + // File to import + print ''; + print ''; + + print '
'.$langs->trans("SourceFileFormat").''; + $text = $objmodelimport->getDriverDescForKey($format); + print $form->textwithpicto($objmodelimport->getDriverLabelForKey($format), $text); + print '
'.$langs->trans("CsvOptions").''; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print $langs->trans("Separator").' : '; + print ''; + print '    '.$langs->trans("Enclosure").' : '; + print ' '; + print ''; + print '
'; + print '
'.$langs->trans("FileToImport").''; + $modulepart = 'import'; + $relativepath = GETPOST('filetoimport'); + print ''; + print img_mime($file, '', 'pictofixedwidth'); + print $filetoimport; + print ''; + print '
'; + print '
'; + + print dol_get_fiche_end(); + + print '
'."\n"; + + + // List of source fields + print ''."\n"; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print '
'; + print ''; + $s = $langs->trans("SelectImportFields", '{s1}'); + $s = str_replace('{s1}', img_picto('', 'grip_title', '', false, 0, 0, '', '', 0), $s); + print $s; + print ' '; + $htmlother->select_import_model($importmodelid, 'importmodelid', $datatoimport, 1, $user->id); + print ''; + print '
'; + print '
'; + + // Title of array with fields + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print ''; + print ''; + print ''; + print ''; + print ''; + + //var_dump($array_match_file_to_database); + + print ''; + + // List of not imported fields + print ''; + + print ''; + print ''; + + print '
'.$langs->trans("FieldsInSourceFile").''.$langs->trans("FieldsInTargetDatabase").'
'; + + $fieldsplaced = array(); + $valforsourcefieldnb = array(); + $listofkeys = array(); + foreach ($array_match_file_to_database as $key => $val) { + $listofkeys[$key] = 1; + } + + print "\n\n"; + print '
'."\n"; + + // List of source fields + $var = true; + $lefti = 1; + foreach ($array_match_file_to_database as $key => $val) { + $var = !$var; + show_elem($fieldssource, $key, $val, $var); // key is field number in source file + //print '> '.$lefti.'-'.$key.'-'.$val; + $listofkeys[$key] = 1; + $fieldsplaced[$key] = 1; + $valforsourcefieldnb[$lefti] = $key; + $lefti++; + + if ($lefti > count($fieldstarget)) { + break; // Other fields are in the not imported area + } + } + //var_dump($valforsourcefieldnb); + + // Complete source fields from count($fieldssource)+1 to count($fieldstarget) + $more = 1; + $num = count($fieldssource); + while ($lefti <= $num) { + $var = !$var; + $newkey = getnewkey($fieldssource, $listofkeys); + show_elem($fieldssource, $newkey, '', $var); // key start after field number in source file + //print '> '.$lefti.'-'.$newkey; + $listofkeys[$key] = 1; + $lefti++; + $more++; + } + + print "
\n"; + print "\n"; + + + print '
'; + + // List of target fields + $height = '24px'; //needs px for css height attribute below + $i = 0; + $mandatoryfieldshavesource = true; + + print ''; + + foreach ($fieldstarget as $code => $line) { + print ''; + $entity = (!empty($objimport->array_import_entities[0][$code]) ? $objimport->array_import_entities[0][$code] : $objimport->array_import_icon[0]); + + $tablealias = preg_replace('/(\..*)$/i', '', $code); + $tablename = $objimport->array_import_tables[0][$tablealias]; + + $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 ''; + print '"; + print ''; + } + print '
=>'.img_object('', $entityicon).' '.$langs->trans($entitylang).''; + print ''; + //print ajax_combobox("select_".$newlabel); + print "'; + $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)) { + $htmltext .= $langs->trans("DataComeFromNoWhere").'
'; + } else { + if (empty($objimport->array_import_convertvalue[0][$code])) { // If source file does not need convertion + $filecolumntoshow = $filecolumn; + $htmltext .= $langs->trans("DataComeFromFileFieldNb", $filecolumntoshow).'
'; + } else { + if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromref') { + $htmltext .= $langs->trans("DataComeFromIdFoundFromRef", $filecolumn, $langs->transnoentitiesnoconv($entitylang)).'
'; + } + if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromcodeid') { + $htmltext .= $langs->trans("DataComeFromIdFoundFromCodeId", $filecolumn, $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$code]['dict'])).'
'; + } + } + } + // Source required + $htmltext .= $langs->trans("SourceRequired").': '.yn($line["label"]).'
'; + $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) { + $htmltext .= $langs->trans("SourceExample").': '.$example.'
'; + } + } else { + if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromref') { + $htmltext .= $langs->trans("SourceExample").': '.$langs->transnoentitiesnoconv("ExampleAnyRefFoundIntoElement", $entitylang).($example ? ' ('.$langs->transnoentitiesnoconv("Example").': '.$example.')' : '').'
'; + } elseif ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromcodeid') { + $htmltext .= $langs->trans("SourceExample").': '.$langs->trans("ExampleAnyCodeOrIdFoundIntoDictionary", $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$code]['dict'])).($example ? ' ('.$langs->transnoentitiesnoconv("Example").': '.$example.')' : '').'
'; + } elseif ($example) { + $htmltext .= $langs->trans("SourceExample").': '.$example.'
'; + } + } + // Format control rule + if (!empty($objimport->array_import_regex[0][$code])) { + $htmltext .= $langs->trans("FormatControlRule").': '.$objimport->array_import_regex[0][$code].'
'; + } + $htmltext .= '
'; + // Target field info + $htmltext .= ''.$langs->trans("FieldTarget").'
'; + if (empty($objimport->array_import_convertvalue[0][$code])) { // If source file does not need convertion + $htmltext .= $langs->trans("DataIsInsertedInto").'
'; + } else { + if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromref') { + $htmltext .= $langs->trans("DataIDSourceIsInsertedInto").'
'; + } + if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromcodeid') { + $htmltext .= $langs->trans("DataCodeIDSourceIsInsertedInto").'
'; + } + } + $htmltext .= $langs->trans("FieldTitle").": ".$langs->trans($line["label"])."
"; + $htmltext .= $langs->trans("Table")." -> ".$langs->trans("Field").': '.$tablename." -> ".preg_replace('/^.*\./', '', $code)."
"; + print $form->textwithpicto($more, $htmltext); + print '
'; + + print '
'.$langs->trans("NotImportedFields").'
'; + + print "\n\n"; + print '\n"; + print "\n"; + + print ''; + $i = 0; + while ($i < $nbofnotimportedfields) { + // Print empty cells + show_elem('', '', 'none', $var, 'nostyle'); + $i++; + } + print '
'; + print '
'; + + + if ($conf->use_javascript_ajax) { + print ''."\n"; + } + + /* + * Action bar + */ + print '
'; + + if (count($array_match_file_to_database)) { + if ($mandatoryfieldshavesource) { + print ''.$langs->trans("NextStep").''; + } else { + print ''.$langs->trans("NextStep").''; + } + } + + print '
'; + + + // Area for profils import + if (count($array_match_file_to_database)) { + print '
'."\n"; + print ''."\n"; + print '
'.$langs->trans("SaveImportModel").'
'; + + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + + // List of existing import profils + $sql = "SELECT rowid, label, fk_user, entity"; + $sql .= " FROM ".MAIN_DB_PREFIX."import_model"; + $sql .= " WHERE type = '".$db->escape($datatoimport)."'"; + if (empty($conf->global->EXPORTS_SHARE_MODELS)) { // EXPORTS_SHARE_MODELS means all templates are visible, whatever is owner. + $sql .= " AND fk_user IN (0, ".((int) $user->id).")"; + } + $sql .= " ORDER BY rowid"; + + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + + $tmpuser = new user($db); + + $i = 0; + while ($i < $num) { + $obj = $db->fetch_object($resql); + + print ''; + print ''; + print ''; + $i++; + } + } else { + dol_print_error($db); + } + + print '
'.$langs->trans("ImportModelName").''.$langs->trans("Visibility").'
'; + $arrayvisibility = array('private'=>$langs->trans("Private"), 'all'=>$langs->trans("Everybody")); + print $form->selectarray('visibility', $arrayvisibility, 'private'); + print ''; + print ''; + print '
'; + print $obj->label; + print ''; + if (empty($obj->fk_user)) { + print $langs->trans("Everybody"); + } else { + $tmpuser->fetch($obj->fk_user); + print $tmpuser->getNomUrl(1); + } + print ''; + print 'rowid.'&filetoimport='.urlencode($filetoimport).'">'; + print img_delete(); + print ''; + print '
'; + print '
'; + + print '
'; + } +} // STEP 5: Summary of choices and launch simulation if ($step == 5 && $datatoimport) { @@ -1471,6 +2032,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) @@ -2121,7 +2696,7 @@ 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;"'); + //print img_picto(($pos > 0 ? $langs->trans("MoveField", $pos) : ''), 'grip_title', 'class="boxhandle" style="cursor:move;"'); print ''; print ''; print $langs->trans("NoFields"); @@ -2141,7 +2716,7 @@ 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;"'); + //print img_picto($langs->trans("MoveField", $pos), 'grip_title', 'class="boxhandle" style="cursor:move;"'); print ''; print ''; print $langs->trans("Field").' '.$pos; 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 From 81e238351526e5494f6db123754b44bce3d1831e Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Fri, 6 May 2022 15:38:47 +0200 Subject: [PATCH 02/41] import with selectbox --- htdocs/imports/import.php | 724 +++++++------------------------------- 1 file changed, 124 insertions(+), 600 deletions(-) diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index b3303402d22..a8fa3013ea2 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -167,6 +167,19 @@ foreach ($fieldsarray as $elem) { } } +if (empty($array_match_file_to_database)) { + $serialized_array_match_file_to_database = isset($_SESSION["dol_array_match_file_to_database_select"]) ? $_SESSION["dol_array_match_file_to_database_select"] : ''; + $array_match_file_to_database = array(); + $fieldsarray = explode(',', $serialized_array_match_file_to_database); + foreach ($fieldsarray as $elem) { + $tabelem = explode('=', $elem, 2); + $key = $tabelem[0]; + $val = (isset($tabelem[1]) ? $tabelem[1] : ''); + if ($key && $val) { + $array_match_file_to_database[$key] = $val; + } + } +} /* * Actions @@ -356,7 +369,22 @@ if ($action == 'saveorder') { $_SESSION["dol_array_match_file_to_database"] = $serialized_array_match_file_to_database; dol_syslog('dol_array_match_file_to_database='.$serialized_array_match_file_to_database); } - +if ($action == 'saveselectorder') { + // Enregistrement de la position des champs + $serialized_array_match_file_to_database = ''; + dol_syslog("selectorder=".GETPOST('selectorder'), LOG_DEBUG); + $selectorder = explode(",", GETPOST('selectorder')); + $fieldtarget = $fieldstarget = $objimport->array_import_fields[0]; + foreach ($selectorder as $key => $code) { + $serialized_array_match_file_to_database .= $key.'='.$code; + $serialized_array_match_file_to_database .= ','; + } + $serialized_array_match_file_to_database = substr($serialized_array_match_file_to_database, 0, -1); + dol_syslog('dol_array_match_file_to_database_select='.$serialized_array_match_file_to_database); + $_SESSION["dol_array_match_file_to_database_select"] = $serialized_array_match_file_to_database; + echo "{}"; + exit(0); +} @@ -765,7 +793,18 @@ if ($step == 3 && $datatoimport) { // STEP 4: Page to make matching between source file and database fields -if ($step == 4 && $datatoimport && !$selectimport) { +if ($step == 4 && $datatoimport && $selectimport) { + $serialized_array_match_file_to_database = isset($_SESSION["dol_array_match_file_to_database_select"]) ? $_SESSION["dol_array_match_file_to_database_select"] : ''; + $array_match_file_to_database = array(); + $fieldsarray = explode(',', $serialized_array_match_file_to_database); + foreach ($fieldsarray as $elem) { + $tabelem = explode('=', $elem, 2); + $key = $tabelem[0]; + $val = (isset($tabelem[1]) ? $tabelem[1] : ''); + if ($key && $val) { + $array_match_file_to_database[$key] = $val; + } + } $model = $format; $list = $objmodelimport->liste_modeles($db); @@ -810,9 +849,7 @@ if ($step == 4 && $datatoimport && !$selectimport) { // Load targets fields in database $fieldstarget = $objimport->array_import_fields[0]; - - $maxpos = max(count($fieldssource), count($fieldstarget)); - + $minpos = min(count($fieldssource), count($fieldstarget)); //var_dump($array_match_file_to_database); // Is it a first time in page (if yes, we must initialize array_match_file_to_database) @@ -843,525 +880,10 @@ if ($step == 4 && $datatoimport && !$selectimport) { $pos++; } // Save the match array in session. We now will use the array in session. - $_SESSION["dol_array_match_file_to_database"] = $serialized_array_match_file_to_database; + $_SESSION["dol_array_match_file_to_database_select"] = $serialized_array_match_file_to_database; } $array_match_database_to_file = array_flip($array_match_file_to_database); - //print $serialized_array_match_file_to_database; - //print $_SESSION["dol_array_match_file_to_database"]; - //var_dump($array_match_file_to_database);exit; - - // Now $array_match_file_to_database contains fieldnb(1,2,3...)=>fielddatabase(key in $array_match_file_to_database) - - $param = '&format='.$format.'&datatoimport='.urlencode($datatoimport).'&filetoimport='.urlencode($filetoimport); - if ($excludefirstline) { - $param .= '&excludefirstline='.urlencode($excludefirstline); - } - if ($endatlinenb) { - $param .= '&endatlinenb='.urlencode($endatlinenb); - } - if ($separator) { - $param .= '&separator='.urlencode($separator); - } - if ($enclosure) { - $param .= '&enclosure='.urlencode($enclosure); - } - - llxHeader('', $langs->trans("NewImport"), $help_url); - - $head = import_prepare_head($param, 4); - - print dol_get_fiche_head($head, 'step4', '', -2); - - print '
'; - print '
'; - - print ''; - - // Module - print ''; - print ''; - - // Lot de donnees a importer - print ''; - print ''; - - print '
'.$langs->trans("Module").''; - $titleofmodule = $objimport->array_import_module[0]['module']->getName(); - // Special cas for import common to module/services - if (in_array($objimport->array_import_code[0], array('produit_supplierprices', 'produit_multiprice', 'produit_languages'))) { - $titleofmodule = $langs->trans("ProductOrService"); - } - print $titleofmodule; - print '
'.$langs->trans("DatasetToImport").''; - $entity = preg_replace('/:.*$/', '', $objimport->array_import_icon[0]); - $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity); - print img_object($objimport->array_import_module[0]['module']->getName(), $entityicon).' '; - print $objimport->array_import_label[0]; - print '
'; - print '
'; - - print load_fiche_titre($langs->trans("InformationOnSourceFile"), '', 'file-export'); - - print '
'; - print '
'; - print ''; - - // Source file format - print ''; - print ''; - - // Separator and enclosure - if ($model == 'csv') { - print ''; - print ''; - } - - // File to import - print ''; - print ''; - - print '
'.$langs->trans("SourceFileFormat").''; - $text = $objmodelimport->getDriverDescForKey($format); - print $form->textwithpicto($objmodelimport->getDriverLabelForKey($format), $text); - print '
'.$langs->trans("CsvOptions").''; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print $langs->trans("Separator").' : '; - print ''; - print '    '.$langs->trans("Enclosure").' : '; - print ' '; - print ''; - print '
'; - print '
'.$langs->trans("FileToImport").''; - $modulepart = 'import'; - $relativepath = GETPOST('filetoimport'); - print ''; - print img_mime($file, '', 'pictofixedwidth'); - print $filetoimport; - print ''; - print '
'; - print '
'; - - print dol_get_fiche_end(); - - print '
'."\n"; - - - // List of source fields - print ''."\n"; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print '
'; - print ''; - $s = $langs->trans("SelectImportFields", '{s1}'); - $s = str_replace('{s1}', img_picto('', 'grip_title', '', false, 0, 0, '', '', 0), $s); - print $s; - print ' '; - $htmlother->select_import_model($importmodelid, 'importmodelid', $datatoimport, 1, $user->id); - print ''; - print '
'; - print '
'; - - // Title of array with fields - print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table - print ''; - print ''; - print ''; - print ''; - print ''; - - //var_dump($array_match_file_to_database); - - print ''; - - // List of not imported fields - print ''; - - print ''; - print ''; - - print '
'.$langs->trans("FieldsInSourceFile").''.$langs->trans("FieldsInTargetDatabase").'
'; - - $fieldsplaced = array(); - $valforsourcefieldnb = array(); - $listofkeys = array(); - foreach ($array_match_file_to_database as $key => $val) { - $listofkeys[$key] = 1; - } - - print "\n\n"; - print '
'."\n"; - - // List of source fields - $var = true; - $lefti = 1; - foreach ($array_match_file_to_database as $key => $val) { - $var = !$var; - show_elem($fieldssource, $key, $val, $var); // key is field number in source file - //print '> '.$lefti.'-'.$key.'-'.$val; - $listofkeys[$key] = 1; - $fieldsplaced[$key] = 1; - $valforsourcefieldnb[$lefti] = $key; - $lefti++; - - if ($lefti > count($fieldstarget)) { - break; // Other fields are in the not imported area - } - } - //var_dump($valforsourcefieldnb); - - // Complete source fields from count($fieldssource)+1 to count($fieldstarget) - $more = 1; - $num = count($fieldssource); - while ($lefti <= $num) { - $var = !$var; - $newkey = getnewkey($fieldssource, $listofkeys); - show_elem($fieldssource, $newkey, '', $var); // key start after field number in source file - //print '> '.$lefti.'-'.$newkey; - $listofkeys[$key] = 1; - $lefti++; - $more++; - } - - print "
\n"; - print "\n"; - - - print '
'; - - // List of target fields - $height = '24px'; //needs px for css height attribute below - $i = 0; - $mandatoryfieldshavesource = true; - - print ''; - foreach ($fieldstarget as $code => $label) { - print ''; - - $i++; - $entity = (!empty($objimport->array_import_entities[0][$code]) ? $objimport->array_import_entities[0][$code] : $objimport->array_import_icon[0]); - - $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', ... - $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 ''; - print ''; - // Info field - print ''; - - print ''; - } - 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))); - } - //print 'xx'.($i).'-'.$valforsourcefieldnb[$i].'-'.$mandatoryfieldshavesource; - } - print $text; - print ''; - $filecolumn = $array_match_database_to_file[$code]; - // Source field info - $htmltext = ''.$langs->trans("FieldSource").'
'; - if ($filecolumn > count($fieldssource)) { - $htmltext .= $langs->trans("DataComeFromNoWhere").'
'; - } else { - if (empty($objimport->array_import_convertvalue[0][$code])) { // If source file does not need convertion - $filecolumntoshow = $filecolumn; - $htmltext .= $langs->trans("DataComeFromFileFieldNb", $filecolumntoshow).'
'; - } else { - if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromref') { - $htmltext .= $langs->trans("DataComeFromIdFoundFromRef", $filecolumn, $langs->transnoentitiesnoconv($entitylang)).'
'; - } - if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromcodeid') { - $htmltext .= $langs->trans("DataComeFromIdFoundFromCodeId", $filecolumn, $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$code]['dict'])).'
'; - } - } - } - // Source required - $htmltext .= $langs->trans("SourceRequired").': '.yn(preg_match('/\*$/', $label)).'
'; - $example = $objimport->array_import_examplevalues[0][$code]; - // Example - if (empty($objimport->array_import_convertvalue[0][$code])) { // If source file does not need convertion - if ($example) { - $htmltext .= $langs->trans("SourceExample").': '.$example.'
'; - } - } else { - if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromref') { - $htmltext .= $langs->trans("SourceExample").': '.$langs->transnoentitiesnoconv("ExampleAnyRefFoundIntoElement", $entitylang).($example ? ' ('.$langs->transnoentitiesnoconv("Example").': '.$example.')' : '').'
'; - } elseif ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromcodeid') { - $htmltext .= $langs->trans("SourceExample").': '.$langs->trans("ExampleAnyCodeOrIdFoundIntoDictionary", $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$code]['dict'])).($example ? ' ('.$langs->transnoentitiesnoconv("Example").': '.$example.')' : '').'
'; - } elseif ($example) { - $htmltext .= $langs->trans("SourceExample").': '.$example.'
'; - } - } - // Format control rule - if (!empty($objimport->array_import_regex[0][$code])) { - $htmltext .= $langs->trans("FormatControlRule").': '.$objimport->array_import_regex[0][$code].'
'; - } - $htmltext .= '
'; - // Target field info - $htmltext .= ''.$langs->trans("FieldTarget").'
'; - if (empty($objimport->array_import_convertvalue[0][$code])) { // If source file does not need convertion - $htmltext .= $langs->trans("DataIsInsertedInto").'
'; - } else { - if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromref') { - $htmltext .= $langs->trans("DataIDSourceIsInsertedInto").'
'; - } - if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromcodeid') { - $htmltext .= $langs->trans("DataCodeIDSourceIsInsertedInto").'
'; - } - } - $htmltext .= $langs->trans("FieldTitle").": ".$langs->trans($newlabel)."
"; - $htmltext .= $langs->trans("Table")." -> ".$langs->trans("Field").': '.$tablename." -> ".preg_replace('/^.*\./', '', $code)."
"; - print $form->textwithpicto($more, $htmltext); - print '
'; - - print '
'.$langs->trans("NotImportedFields").'
'; - - print "\n\n"; - print '\n"; - print "\n"; - - print ''; - $i = 0; - while ($i < $nbofnotimportedfields) { - // Print empty cells - show_elem('', '', 'none', $var, 'nostyle'); - $i++; - } - print '
'; - print '
'; - - - if ($conf->use_javascript_ajax) { - print ''."\n"; - } - - /* - * Action bar - */ - print '
'; - - if (count($array_match_file_to_database)) { - if ($mandatoryfieldshavesource) { - print ''.$langs->trans("NextStep").''; - } else { - print ''.$langs->trans("NextStep").''; - } - } - - print '
'; - - - // Area for profils import - if (count($array_match_file_to_database)) { - print '
'."\n"; - print ''."\n"; - print '
'.$langs->trans("SaveImportModel").'
'; - - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - print ''; - - // List of existing import profils - $sql = "SELECT rowid, label, fk_user, entity"; - $sql .= " FROM ".MAIN_DB_PREFIX."import_model"; - $sql .= " WHERE type = '".$db->escape($datatoimport)."'"; - if (empty($conf->global->EXPORTS_SHARE_MODELS)) { // EXPORTS_SHARE_MODELS means all templates are visible, whatever is owner. - $sql .= " AND fk_user IN (0, ".((int) $user->id).")"; - } - $sql .= " ORDER BY rowid"; - - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); - - $tmpuser = new user($db); - - $i = 0; - while ($i < $num) { - $obj = $db->fetch_object($resql); - - print ''; - print ''; - print ''; - $i++; - } - } else { - dol_print_error($db); - } - - print '
'.$langs->trans("ImportModelName").''.$langs->trans("Visibility").'
'; - $arrayvisibility = array('private'=>$langs->trans("Private"), 'all'=>$langs->trans("Everybody")); - print $form->selectarray('visibility', $arrayvisibility, 'private'); - print ''; - print ''; - print '
'; - print $obj->label; - print ''; - if (empty($obj->fk_user)) { - print $langs->trans("Everybody"); - } else { - $tmpuser->fetch($obj->fk_user); - print $tmpuser->getNomUrl(1); - } - print ''; - print 'rowid.'&filetoimport='.urlencode($filetoimport).'">'; - print img_delete(); - print ''; - print '
'; - print '
'; - - print '
'; - } -} - -if ($step == 4 && $datatoimport && $selectimport) { - $model = $format; - $list = $objmodelimport->liste_modeles($db); - - // Create classe to use for import - $dir = DOL_DOCUMENT_ROOT."/core/modules/import/"; - $file = "import_".$model.".modules.php"; - $classname = "Import".ucfirst($model); - require_once $dir.$file; - $obj = new $classname($db, $datatoimport); - if ($model == 'csv') { - $obj->separator = $separator_used; - $obj->enclosure = $enclosure; - } - if ($model == 'xlsx') { - if (!preg_match('/\.xlsx$/i', $filetoimport)) { - $langs->load("errors"); - $param = '&datatoimport='.$datatoimport.'&format='.$format; - setEventMessages($langs->trans("ErrorFileMustHaveFormat", $model), null, 'errors'); - header("Location: ".$_SERVER["PHP_SELF"].'?step=3'.$param.'&filetoimport='.urlencode($relativepath)); - exit; - } - } - - if (GETPOST('update')) { - $array_match_file_to_database = array(); - } - - // Load source fields in input file - $fieldssource = array(); - $result = $obj->import_open_file($conf->import->dir_temp.'/'.$filetoimport, $langs); - if ($result >= 0) { - // Read first line - $arrayrecord = $obj->import_read_record(); - // Put into array fieldssource starting with 1. - $i = 1; - foreach ($arrayrecord as $key => $val) { - $fieldssource[$i]['example1'] = dol_trunc($val['val'], 24); - $i++; - } - $obj->import_close_file(); - } - - // Load targets fields in database - $fieldstarget = $objimport->array_import_fields[0]; $fieldstarget_tmp = array(); foreach ($fieldstarget as $key => $label) { @@ -1372,44 +894,13 @@ if ($step == 4 && $datatoimport && $selectimport) { } else { $fieldstarget_tmp[$key] = array("label"=>$label,"required"=>false); } - $fieldstarget_tmp[$key]["imported"] = true; + if (!empty($array_match_database_to_file[$key])) { + $fieldstarget_tmp[$key]["imported"] = true; + } else { + $fieldstarget_tmp[$key]["imported"] = false; + } } $fieldstarget = $fieldstarget_tmp; - $maxpos = max(count($fieldssource), count($fieldstarget)); - - //var_dump($array_match_file_to_database); - - // Is it a first time in page (if yes, we must initialize array_match_file_to_database) - if (count($array_match_file_to_database) == 0) { - // This is first input in screen, we need to define - // $array_match_file_to_database - // $serialized_array_match_file_to_database - // $_SESSION["dol_array_match_file_to_database"] - $pos = 1; - $num = count($fieldssource); - while ($pos <= $num) { - if ($num >= 1 && $pos <= $num) { - $posbis = 1; - foreach ($fieldstarget as $key => $val) { - if ($posbis < $pos) { - $posbis++; - continue; - } - // We found the key of targets that is at position pos - $array_match_file_to_database[$pos] = $key; - if ($serialized_array_match_file_to_database) { - $serialized_array_match_file_to_database .= ','; - } - $serialized_array_match_file_to_database .= ($pos.'='.$key); - break; - } - } - $pos++; - } - // Save the match array in session. We now will use the array in session. - $_SESSION["dol_array_match_file_to_database"] = $serialized_array_match_file_to_database; - } - $array_match_database_to_file = array_flip($array_match_file_to_database); //print $serialized_array_match_file_to_database; //print $_SESSION["dol_array_match_file_to_database"]; @@ -1568,7 +1059,7 @@ if ($step == 4 && $datatoimport && $selectimport) { // List of source fields $var = true; $lefti = 1; - foreach ($array_match_file_to_database as $key => $val) { + foreach ($fieldssource as $key => $val) { $var = !$var; show_elem($fieldssource, $key, $val, $var); // key is field number in source file //print '> '.$lefti.'-'.$key.'-'.$val; @@ -1603,13 +1094,28 @@ if ($step == 4 && $datatoimport && $selectimport) { print ''; // List of target fields + $optionsnotused = ""; + foreach ($fieldstarget as $code => $line) { + if (!$line["imported"]) { + $text = ''; + $optionsnotused .= $text; + } + } + $height = '24px'; //needs px for css height attribute below $i = 0; $mandatoryfieldshavesource = true; print ''; - foreach ($fieldstarget as $code => $line) { + if ($i == $minpos) { + break; + } print ''; $entity = (!empty($objimport->array_import_entities[0][$code]) ? $objimport->array_import_entities[0][$code] : $objimport->array_import_icon[0]); @@ -1621,9 +1127,14 @@ if ($step == 4 && $datatoimport && $selectimport) { print ''; print '"; @@ -1691,6 +1203,7 @@ if ($step == 4 && $datatoimport && $selectimport) { $htmltext .= $langs->trans("Table")." -> ".$langs->trans("Field").': '.$tablename." -> ".preg_replace('/^.*\./', '', $code)."
"; print $form->textwithpicto($more, $htmltext); print ''; + $i++; } print '
=>'.img_object('', $entityicon).' '.$langs->trans($entitylang).''; - print ''; + if ($line["imported"]) { + print ''; + print ''; + print ''; + print $optionsnotused; print ''; //print ajax_combobox("select_".$newlabel); print "
'; @@ -1705,11 +1218,11 @@ if ($step == 4 && $datatoimport && $selectimport) { print ''; @@ -2679,7 +2199,7 @@ function show_elem($fieldssource, $pos, $key, $var, $nostyle = '') { global $langs, $bc; - $height = '24px'; + $height = '28px'; if ($key == 'none') { //stop multiple duplicate ids with no number @@ -2693,7 +2213,7 @@ function show_elem($fieldssource, $pos, $key, $var, $nostyle = '') print ''."\n"; } - if ($pos && $pos > count($fieldssource)) { // No fields + if (($pos && $pos > count($fieldssource)) && (!isset($fieldssource[$pos]["imported"]))) { // No fields print ''; print ''; print '"; print ''; // List of not imported fields - print ''; + print ''; print ''; - print ''; print ''; print ''; print ''; From 23665c3f6be742523bd2e31f1e883eaa844927a3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 May 2022 10:02:59 +0200 Subject: [PATCH 13/41] Tooltip --- htdocs/projet/tasks/time.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 744a1667f7b..6f04cd16a51 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -905,6 +905,9 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser $linktocreatetimeBtnStatus = -2; $linktocreatetimeHelpText = $langs->trans("NotOwnerOfProject"); } + } else { + $linktocreatetimeBtnStatus = -2; + $linktocreatetimeHelpText = $langs->trans("NotEnoughPermissions"); } $paramsbutton = array('morecss'=>'reposition'); From e7ab9a354523d720170700b400594021b3792c29 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 May 2022 10:06:01 +0200 Subject: [PATCH 14/41] Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop --- htdocs/core/class/commonobject.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 6519a8b9e13..e1ed8855378 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2236,6 +2236,7 @@ abstract class CommonObject * Link element with a project * * @param int $projectid Project id to link element to + * @param int $notrigger Disable the trigger * @return int <0 if KO, >0 if OK */ public function setProject($projectid, $notrigger = 0) From da5cf74a08818ec6da638f1f233026e8f85074e6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 May 2022 10:17:56 +0200 Subject: [PATCH 15/41] Fix total --- htdocs/product/stock/stockatdate.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/product/stock/stockatdate.php b/htdocs/product/stock/stockatdate.php index 340fd7dc0df..26991915c2f 100644 --- a/htdocs/product/stock/stockatdate.php +++ b/htdocs/product/stock/stockatdate.php @@ -615,11 +615,12 @@ if ($mode == 'future') { $colspan++; } -print ''; -print ''; if (empty($date) || !$dateIsValid) { print ''; +} else { + print ''; + print ''; } print '
'; //print img_picto(($pos > 0 ? $langs->trans("MoveField", $pos) : ''), 'grip_title', 'class="boxhandle" style="cursor:move;"'); @@ -2720,7 +2240,11 @@ function show_elem($fieldssource, $pos, $key, $var, $nostyle = '') print ''; print $langs->trans("Field").' '.$pos; - $example = $fieldssource[$pos]['example1']; + if (empty($fieldssource[$pos]['example1'])) { + $example = $fieldssource[$pos]['label']; + } else { + $example = $fieldssource[$pos]['example1']; + } if ($example) { if (!utf8_check($example)) { $example = utf8_encode($example); From ed13280ea10d932419615a0bb64199354b078e28 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Tue, 10 May 2022 12:15:52 +0200 Subject: [PATCH 03/41] fix bug in select boxes --- htdocs/imports/import.php | 163 ++++++++++++++++---------------- htdocs/langs/en_US/exports.lang | 1 + 2 files changed, 85 insertions(+), 79 deletions(-) diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index a8fa3013ea2..d4b7ad4e4b6 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -35,8 +35,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/import.lib.php'; // Load translation files required by the page $langs->loadLangs(array('exports', 'compta', 'errors')); -$selectimport = true; - // Security check $result = restrictedArea($user, 'import'); @@ -321,54 +319,6 @@ if ($step == 4 && $action == 'select_model') { $_SESSION["dol_array_match_file_to_database"] = $serialized_array_match_file_to_database; } } - -if ($action == 'saveorder') { - // Enregistrement de la position des champs - dol_syslog("boxorder=".GETPOST('boxorder')." datatoimport=".GETPOST("datatoimport"), LOG_DEBUG); - $part = explode(':', GETPOST('boxorder')); - $colonne = $part[0]; - $list = $part[1]; - dol_syslog('column='.$colonne.' list='.$list); - - // Init targets fields array - $fieldstarget = $objimport->array_import_fields[0]; - - // Reinit match arrays. We redefine array_match_file_to_database - $serialized_array_match_file_to_database = ''; - $array_match_file_to_database = array(); - $fieldsarray = explode(',', $list); - $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 = ''; - foreach ($fieldstarget as $key => $val) { // key: val: - //dol_syslog('AjaxImport key='.$key.' val='.$val); - 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); - - break; - } - - if ($fieldnb && $namefield) { - $array_match_file_to_database[$fieldnb] = $namefield; - if ($serialized_array_match_file_to_database) { - $serialized_array_match_file_to_database .= ','; - } - $serialized_array_match_file_to_database .= ($fieldnb.'='.$namefield); - } - - $pos++; - } - - // We save new matching in session - $_SESSION["dol_array_match_file_to_database"] = $serialized_array_match_file_to_database; - dol_syslog('dol_array_match_file_to_database='.$serialized_array_match_file_to_database); -} if ($action == 'saveselectorder') { // Enregistrement de la position des champs $serialized_array_match_file_to_database = ''; @@ -793,7 +743,7 @@ if ($step == 3 && $datatoimport) { // STEP 4: Page to make matching between source file and database fields -if ($step == 4 && $datatoimport && $selectimport) { +if ($step == 4 && $datatoimport) { $serialized_array_match_file_to_database = isset($_SESSION["dol_array_match_file_to_database_select"]) ? $_SESSION["dol_array_match_file_to_database_select"] : ''; $array_match_file_to_database = array(); $fieldsarray = explode(',', $serialized_array_match_file_to_database); @@ -885,7 +835,8 @@ if ($step == 4 && $datatoimport && $selectimport) { $array_match_database_to_file = array_flip($array_match_file_to_database); $fieldstarget_tmp = array(); - + $arraykeysfieldtarget = array_keys($fieldstarget); + $position = 0; foreach ($fieldstarget as $key => $label) { $isrequired = preg_match('/\*$/', $label); if (!empty($isrequired)) { @@ -896,9 +847,27 @@ if ($step == 4 && $datatoimport && $selectimport) { } if (!empty($array_match_database_to_file[$key])) { $fieldstarget_tmp[$key]["imported"] = true; + $fieldstarget_tmp[$key]["position"] = $array_match_database_to_file[$key]-1; + $keytoswap = $key; + while (!empty($array_match_database_to_file[$keytoswap])) { + if ($position+1 > $array_match_database_to_file[$keytoswap]) { + $keytoswapwith = $array_match_database_to_file[$keytoswap]-1; + $tmp = [$keytoswap=>$fieldstarget_tmp[$keytoswap]]; + unset($fieldstarget_tmp[$keytoswap]); + $fieldstarget_tmp = arrayInsert($fieldstarget_tmp, $keytoswapwith, $tmp); + $keytoswapwith = $arraykeysfieldtarget[$array_match_database_to_file[$keytoswap]-1]; + $tmp = $fieldstarget_tmp[$keytoswapwith]; + unset($fieldstarget_tmp[$keytoswapwith]); + $fieldstarget_tmp[$keytoswapwith] = $tmp; + $keytoswap = $keytoswapwith; + } else { + break; + } + } } else { $fieldstarget_tmp[$key]["imported"] = false; } + $position++; } $fieldstarget = $fieldstarget_tmp; @@ -1144,7 +1113,6 @@ if ($step == 4 && $datatoimport && $selectimport) { print ''; print $optionsnotused; print ''; - //print ajax_combobox("select_".$newlabel); print "'; $filecolumn = !empty($array_match_database_to_file[$code])?$array_match_database_to_file[$code]:0; @@ -1210,7 +1178,7 @@ if ($step == 4 && $datatoimport && $selectimport) { print '
'.$langs->trans("NotImportedFields").'
'.$langs->trans("NotUsedFields").'
'; @@ -1261,15 +1229,42 @@ if ($step == 4 && $datatoimport && $selectimport) { print '$(".targetselectchange").focus(function(){'."\n"; print 'previousselectedvalueimport = $(this).val();'."\n"; print 'previousselectedlabelimport = $(this).children("option:selected").text();'."\n"; + print 'console.log(previousselectedvalueimport)'."\n"; print '})'."\n"; print '$(".targetselectchange").change(function(){'."\n"; print 'if(previousselectedlabelimport != "" && previousselectedvalueimport != -1){'."\n"; - print '$(".targetselectchange").not($( this )).append(new Option(previousselectedlabelimport,previousselectedvalueimport));'."\n"; + print '$(".targetselectchange").not($(this)).append(new Option(previousselectedlabelimport,previousselectedvalueimport));'."\n"; + print 'let valuetochange = $(this).val(); '."\n"; + print '$(".boxtdunused").each(function(){'."\n"; + print 'if ($(this).text().includes(valuetochange)){'."\n"; + print 'arraychild = $(this)[0].childNodes'."\n"; + print 'arraytexttomodify = arraychild[0].textContent.split(" ")'."\n"; + print 'arraytexttomodify[1] = previousselectedvalueimport '."\n"; + print 'textmodified = arraytexttomodify.join(" ") '."\n"; + print 'arraychild[0].textContent = textmodified'."\n"; + print 'arraychild[1].innerHTML = previousselectedlabelimport'."\n"; + print '}'."\n"; + print '})'."\n"; print '}'."\n"; print 'if($( this ).val() != -1){'."\n"; print '$(".targetselectchange").not($( this )).find(\'option[value="\'+$( this ).val()+\'"]\').remove();'."\n"; - print '$(".targetselectchange").not($( this )).find(\'option[value="\'+$( this ).val()+\'"]\').remove();'."\n"; print '}'."\n"; + print '$(this).blur()'."\n"; + print 'arrayselectedfields = [];'."\n"; + print 'arrayselectedfields.push("0");'."\n"; + print '$(".targetselectchange").each(function(){'."\n"; + print 'value = $(this).val()'."\n"; + print 'arrayselectedfields.push(value);'."\n"; + print '});'."\n"; + print '$.ajax({'."\n"; + print 'type: "POST",'."\n"; + print 'dataType: "json",'."\n"; + print 'url: "'.$_SERVER["PHP_SELF"].'?action=saveselectorder",'."\n"; + print 'data: "selectorder="+arrayselectedfields.toString(),'."\n"; + print 'success: function(){'."\n"; + print 'console.log("Select order saved");'."\n"; + print '},'."\n"; + print '});'."\n"; print '});'."\n"; print '})'."\n"; print ''."\n"; @@ -1282,31 +1277,10 @@ if ($step == 4 && $datatoimport && $selectimport) { if (count($array_match_file_to_database)) { if ($mandatoryfieldshavesource) { - print ''.$langs->trans("NextStep").''; + print ''.$langs->trans("NextStep").''; } else { print ''.$langs->trans("NextStep").''; } - if ($conf->use_javascript_ajax) { - print ''."\n"; - } } print ''; @@ -2238,7 +2212,11 @@ function show_elem($fieldssource, $pos, $key, $var, $nostyle = '') // 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;"'); print ''; + if (isset($fieldssource[$pos]['imported']) && $fieldssource[$pos]['imported'] == false) { + print ''; + } else { + print ''; + } print $langs->trans("Field").' '.$pos; if (empty($fieldssource[$pos]['example1'])) { $example = $fieldssource[$pos]['label']; @@ -2289,3 +2267,30 @@ function getnewkey(&$fieldssource, &$listofkey) $listofkey[$i] = 1; return $i; } +/** + * Return array with element inserted in it at position $position + * + * @param array $array Array of field source + * @param mixed $position key of postion to insert to + * @param array $insertArray Array to insert + * @return array + */ +function arrayInsert($array, $position, $insertArray) +{ + $ret = []; + + if ($position == count($array)) { + $ret = $array + $insertArray; + } else { + $i = 0; + foreach ($array as $key => $value) { + if ($position == $i++) { + $ret += $insertArray; + } + + $ret[$key] = $value; + } + } + + return $ret; +} diff --git a/htdocs/langs/en_US/exports.lang b/htdocs/langs/en_US/exports.lang index a20741472b7..44cb98d3679 100644 --- a/htdocs/langs/en_US/exports.lang +++ b/htdocs/langs/en_US/exports.lang @@ -136,3 +136,4 @@ 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 +NotUsedFields=Fields of database not used \ No newline at end of file From 7e439a824848546a539229f3fd19de4e5fabcf1d Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Tue, 10 May 2022 15:50:01 +0200 Subject: [PATCH 04/41] add of selectimportfieldsource in lang --- htdocs/imports/import.php | 8 +++++--- htdocs/langs/en_US/exports.lang | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index d4b7ad4e4b6..15d83cfe8e7 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -791,8 +791,10 @@ if ($step == 4 && $datatoimport) { // Put into array fieldssource starting with 1. $i = 1; foreach ($arrayrecord as $key => $val) { - $fieldssource[$i]['example1'] = dol_trunc($val['val'], 24); - $i++; + if ($val["type"] != -1) { + $fieldssource[$i]['example1'] = dol_trunc($val['val'], 24); + $i++; + } } $obj->import_close_file(); } @@ -994,7 +996,7 @@ if ($step == 4 && $datatoimport) { print '
'; print ''; - $s = $langs->trans("SelectImportFields", '{s1}'); + $s = $langs->trans("SelectImportFieldsSource", '{s1}'); $s = str_replace('{s1}', img_picto('', 'grip_title', '', false, 0, 0, '', '', 0), $s); print $s; print ' '; diff --git a/htdocs/langs/en_US/exports.lang b/htdocs/langs/en_US/exports.lang index 44cb98d3679..e7ac91e5722 100644 --- a/htdocs/langs/en_US/exports.lang +++ b/htdocs/langs/en_US/exports.lang @@ -136,4 +136,5 @@ 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 -NotUsedFields=Fields of database not used \ No newline at end of file +NotUsedFields=Fields of database not used +SelectImportFieldsSource = Choose the source file fields you want to import and their target field in database by choosing the fields in each select boxes, or select a predefined import profile: From 4d759c23b3fea2c63b0072b6bab8afdf67eaea85 Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Tue, 10 May 2022 23:47:04 +0200 Subject: [PATCH 05/41] burundi : regions (provinces) --- .../install/mysql/data/llx_10_c_regions.sql | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/htdocs/install/mysql/data/llx_10_c_regions.sql b/htdocs/install/mysql/data/llx_10_c_regions.sql index 43d2652298f..4014d58242b 100644 --- a/htdocs/install/mysql/data/llx_10_c_regions.sql +++ b/htdocs/install/mysql/data/llx_10_c_regions.sql @@ -384,3 +384,25 @@ insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values (9,934, -- Regions Angola (rowid country=35) INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES (35, 35001, 'AO', NULL, 'Angola'); + + +-- Burundi Regions (id country=61) -- https://fr.wikipedia.org/wiki/Provinces_du_Burundi +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6101, '', 0, "Bubanza"); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6102, '', 0, "Bujumbura Mairie"); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6103, '', 0, "Bujumbura Rural"); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6104, '', 0, "Bururi"); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6105, '', 0, "Cankuzo"); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6106, '', 0, "Cibitoke"); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6107, '', 0, "Gitega"); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6108, '', 0, "Karuzi"); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6109, '', 0, "Kayanza"); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6110, '', 0, "Kirundo"); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6111, '', 0, "Makamba"); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6112, '', 0, "Muramvya"); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6113, '', 0, "Muyinga"); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6114, '', 0, "Mwaro"); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6115, '', 0, "Ngozi"); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6116, '', 0, "Rumonge"); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6117, '', 0, "Rutana"); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6118, '', 0, "Ruyigi"); + From 99225dab9ff263104426ce9e0bb92f72e813a9e1 Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Tue, 10 May 2022 23:47:22 +0200 Subject: [PATCH 06/41] burundi departements (Communes) --- .../mysql/data/llx_20_c_departements.sql | 122 ++++++++++++++++++ 1 file changed, 122 insertions(+) diff --git a/htdocs/install/mysql/data/llx_20_c_departements.sql b/htdocs/install/mysql/data/llx_20_c_departements.sql index 9aff8d0355e..d2a97920f34 100644 --- a/htdocs/install/mysql/data/llx_20_c_departements.sql +++ b/htdocs/install/mysql/data/llx_20_c_departements.sql @@ -1626,3 +1626,125 @@ INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-NAM', NULL, NULL, 'NAMÍBE', 'Namíbe'); INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-UIG', NULL, NULL, 'UÍGE', 'Uíge'); INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-ZAI', NULL, NULL, 'ZAÍRE', 'Zaíre'); + + +-- Burundi Communes (id country=61) -- https://fr.wikipedia.org/wiki/Communes_du_Burundi +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6101, 'BI0001', '', 0, '', 'Bubanza'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6101, 'BI0002', '', 0, '', 'Gihanga'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6101, 'BI0003', '', 0, '', 'Musigati'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6101, 'BI0004', '', 0, '', 'Mpanda'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6101, 'BI0005', '', 0, '', 'Rugazi'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6102, 'BI0006', '', 0, '', 'Muha'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6102, 'BI0007', '', 0, '', 'Mukaza'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6102, 'BI0008', '', 0, '', 'Ntahangwa'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6103, 'BI0009', '', 0, '', 'Isale'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6103, 'BI0010', '', 0, '', 'Kabezi'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6103, 'BI0011', '', 0, '', 'Kanyosha'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6103, 'BI0012', '', 0, '', 'Mubimbi'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6103, 'BI0013', '', 0, '', 'Mugongomanga'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6103, 'BI0014', '', 0, '', 'Mukike'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6103, 'BI0015', '', 0, '', 'Mutambu'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6103, 'BI0016', '', 0, '', 'Mutimbuzi'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6103, 'BI0017', '', 0, '', 'Nyabiraba'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6104, 'BI0018', '', 0, '', 'Bururi'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6104, 'BI0019', '', 0, '', 'Matana'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6104, 'BI0020', '', 0, '', 'Mugamba'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6104, 'BI0021', '', 0, '', 'Rutovu'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6104, 'BI0022', '', 0, '', 'Songa'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6104, 'BI0023', '', 0, '', 'Vyanda'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6105, 'BI0024', '', 0, '', 'Cankuzo'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6105, 'BI0025', '', 0, '', 'Cendajuru'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6105, 'BI0026', '', 0, '', 'Gisagara'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6105, 'BI0027', '', 0, '', 'Kigamba'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6105, 'BI0028', '', 0, '', 'Mishiha'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6106, 'BI0029', '', 0, '', 'Buganda'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6106, 'BI0030', '', 0, '', 'Bukinanyana'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6106, 'BI0031', '', 0, '', 'Mabayi'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6106, 'BI0032', '', 0, '', 'Mugina'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6106, 'BI0033', '', 0, '', 'Murwi'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6106, 'BI0034', '', 0, '', 'Rugombo'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6107, 'BI0035', '', 0, '', 'Bugendana'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6107, 'BI0036', '', 0, '', 'Bukirasazi'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6107, 'BI0037', '', 0, '', 'Buraza'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6107, 'BI0038', '', 0, '', 'Giheta'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6107, 'BI0039', '', 0, '', 'Gishubi'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6107, 'BI0040', '', 0, '', 'Gitega'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6107, 'BI0041', '', 0, '', 'Itaba'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6107, 'BI0042', '', 0, '', 'Makebuko'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6107, 'BI0043', '', 0, '', 'Mutaho'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6107, 'BI0044', '', 0, '', 'Nyanrusange'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6107, 'BI0045', '', 0, '', 'Ryansoro'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6108, 'BI0046', '', 0, '', 'Bugenyuzi'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6108, 'BI0047', '', 0, '', 'Buhiga'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6108, 'BI0048', '', 0, '', 'Gihogazi'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6108, 'BI0049', '', 0, '', 'Gitaramuka'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6108, 'BI0050', '', 0, '', 'Mutumba'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6108, 'BI0051', '', 0, '', 'Nyabikere'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6108, 'BI0052', '', 0, '', 'Shombo'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6109, 'BI0053', '', 0, '', 'Butaganzwa'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6109, 'BI0054', '', 0, '', 'Gahombo'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6109, 'BI0055', '', 0, '', 'Gatara'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6109, 'BI0056', '', 0, '', 'Kabarore'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6109, 'BI0057', '', 0, '', 'Kayanza'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6109, 'BI0058', '', 0, '', 'Matongo'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6109, 'BI0059', '', 0, '', 'Muhanga'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6109, 'BI0060', '', 0, '', 'Muruta'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6109, 'BI0061', '', 0, '', 'Rango'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6110, 'BI0062', '', 0, '', 'Bugabira'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6110, 'BI0063', '', 0, '', 'Busoni'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6110, 'BI0064', '', 0, '', 'Bwambarangwe'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6110, 'BI0065', '', 0, '', 'Gitobe'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6110, 'BI0066', '', 0, '', 'Kirundo'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6110, 'BI0067', '', 0, '', 'Ntega'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6110, 'BI0068', '', 0, '', 'Vumbi'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6111, 'BI0069', '', 0, '', 'Kayogoro'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6111, 'BI0070', '', 0, '', 'Kibago'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6111, 'BI0071', '', 0, '', 'Mabanda'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6111, 'BI0072', '', 0, '', 'Makamba'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6111, 'BI0073', '', 0, '', 'Nyanza-Lac'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6111, 'BI0074', '', 0, '', 'Vugizo'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6112, 'BI0075', '', 0, '', 'Bukeye'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6112, 'BI0076', '', 0, '', 'Kiganda'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6112, 'BI0077', '', 0, '', 'Mbuye'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6112, 'BI0078', '', 0, '', 'Muramvya'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6112, 'BI0079', '', 0, '', 'Rutegama'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6113, 'BI0080', '', 0, '', 'Buhinyuza'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6113, 'BI0081', '', 0, '', 'Butihinda'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6113, 'BI0082', '', 0, '', 'Gashoho'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6113, 'BI0083', '', 0, '', 'Gasorwe'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6113, 'BI0084', '', 0, '', 'Giteranyi'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6113, 'BI0085', '', 0, '', 'Muyinga'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6113, 'BI0086', '', 0, '', 'Mwakiro'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6114, 'BI0087', '', 0, '', 'Bisoro'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6114, 'BI0088', '', 0, '', 'Gisozi'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6114, 'BI0089', '', 0, '', 'Kayokwe'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6114, 'BI0090', '', 0, '', 'Ndava'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6114, 'BI0091', '', 0, '', 'Nyabihanga'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6114, 'BI0092', '', 0, '', 'Rusaka'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6115, 'BI0093', '', 0, '', 'Busiga'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6115, 'BI0094', '', 0, '', 'Gashikanwa'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6115, 'BI0095', '', 0, '', 'Kiremba'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6115, 'BI0096', '', 0, '', 'Marangara'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6115, 'BI0097', '', 0, '', 'Mwumba'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6115, 'BI0098', '', 0, '', 'Ngozi'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6115, 'BI0099', '', 0, '', 'Nyamurenza'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6115, 'BI0100', '', 0, '', 'Ruhororo'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6115, 'BI0101', '', 0, '', 'Tangara'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6116, 'BI0102', '', 0, '', 'Bugarama'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6116, 'BI0103', '', 0, '', 'Burambi'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6116, 'BI0104', '', 0, '', 'Buyengero'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6116, 'BI0105', '', 0, '', 'Muhuta'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6116, 'BI0106', '', 0, '', 'Rumonge'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6117, 'BI0107', '', 0, '', 'Bukemba'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6117, 'BI0108', '', 0, '', 'Giharo'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6117, 'BI0109', '', 0, '', 'Gitanga'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6117, 'BI0110', '', 0, '', 'Mpinga-Kayove'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6117, 'BI0111', '', 0, '', 'Musongati'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6117, 'BI0112', '', 0, '', 'Rutana'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6118, 'BI0113', '', 0, '', 'Butaganzwa'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6118, 'BI0114', '', 0, '', 'Butezi'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6118, 'BI0115', '', 0, '', 'Bweru'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6118, 'BI0116', '', 0, '', 'Gisuru'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6118, 'BI0117', '', 0, '', 'Kinyinya'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6118, 'BI0118', '', 0, '', 'Nyabitsinda'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6118, 'BI0119', '', 0, '', 'Ruyigi'); From 7aad16bc80198b01b2a8d0cee4e613f8d8fc6fa2 Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Tue, 10 May 2022 23:47:36 +0200 Subject: [PATCH 07/41] burundi currencie --- htdocs/install/mysql/data/llx_c_currencies.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/install/mysql/data/llx_c_currencies.sql b/htdocs/install/mysql/data/llx_c_currencies.sql index 478c263af4c..6eb329b7d71 100644 --- a/htdocs/install/mysql/data/llx_c_currencies.sql +++ b/htdocs/install/mysql/data/llx_c_currencies.sql @@ -7,6 +7,7 @@ -- Copyright (C) 2007 Patrick Raguin -- Copyright (C) 2011 Juanjo Menent -- Copyright (C) 2020 Udo Tamm +-- Copyright (C) 2022 Éric Seigne -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -56,6 +57,7 @@ INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'BWP' INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'BGN', '[1083,1074]', 1, 'Bulgaria Lev'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'BRL', '[82,36]', 1, 'Brazil Real'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'BND', '[36]', 1, 'Brunei Darussalam Dollar'); +INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'BIF', NULL, 1, 'Burundi Franc'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'KHR', '[6107]', 1, 'Cambodia Riel'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'CAD', '[36]', 1, 'Canada Dollar'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'CVE', '[4217]', 1, 'Cap Verde Escudo'); From b8e73b4b7267594d0a0e1968ea437a0d94efc13d Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Tue, 10 May 2022 23:47:49 +0200 Subject: [PATCH 08/41] burundi companies type --- htdocs/install/mysql/data/llx_c_forme_juridique.sql | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/install/mysql/data/llx_c_forme_juridique.sql b/htdocs/install/mysql/data/llx_c_forme_juridique.sql index 7b02ee60ffa..9a15030ad1b 100644 --- a/htdocs/install/mysql/data/llx_c_forme_juridique.sql +++ b/htdocs/install/mysql/data/llx_c_forme_juridique.sql @@ -339,3 +339,9 @@ insert into llx_c_forme_juridique (fk_pays, code, libelle) values (13, '1306','S insert into llx_c_forme_juridique (fk_pays, code, libelle) values (13, '1307','Société en participation'); insert into llx_c_forme_juridique (fk_pays, code, libelle) values (13, '1308','Groupe de sociétés'); +-- Burundi (id contry=61) +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (61,'6100','Indépendant - Personne physique'); +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (61,'6101','Société Unipersonnelle'); +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (61,'6102','Société de personne à responsabilité limité (SPRL)'); +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (61,'6103','Société anonyme (SA)'); +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (61,'6104','Société coopérative'); From 6d4455ec1766d79db5caaa3e105a94d2d82f74e5 Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Tue, 10 May 2022 23:48:07 +0200 Subject: [PATCH 09/41] burundi profId mapping --- htdocs/langs/fr_FR/companies.lang | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/langs/fr_FR/companies.lang b/htdocs/langs/fr_FR/companies.lang index c07b5c4611f..c3d6a217bf2 100644 --- a/htdocs/langs/fr_FR/companies.lang +++ b/htdocs/langs/fr_FR/companies.lang @@ -138,6 +138,12 @@ ProfId3BE=- ProfId4BE=- ProfId5BE=Numéro EORI ProfId6BE=- +ProfId1BI=Id. prof. 1 (TIN) +ProfId2BI=Id. prof. 2 (PAN) +ProfId3BI=Id. prof. 3 (SRVC TAX) +ProfId4BI=Id. prof. 4 (FISCAL CENTER) +ProfId5BI=Id. prof. 5 +ProfId6BI=- ProfId1BR=- ProfId2BR=IE (Inscricao Estadual) ProfId3BR=IM (Inscricao Municipal) From aee6f408b255d40db1d46ad87a33ff88e6c15fe5 Mon Sep 17 00:00:00 2001 From: kamel Date: Wed, 11 May 2022 09:30:39 +0200 Subject: [PATCH 10/41] FIX: Set datec when add time spent on a project task --- htdocs/projet/class/task.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 8d9f91afaca..cda8494682b 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -1144,6 +1144,7 @@ class Task extends CommonObject dol_syslog(get_class($this)."::addTimeSpent", LOG_DEBUG); $ret = 0; + $now = dol_now(); // Check parameters if (!is_object($user)) { @@ -1169,6 +1170,7 @@ class Task extends CommonObject $sql .= ", task_duration"; $sql .= ", fk_user"; $sql .= ", note"; + $sql .= ", datec"; $sql .= ") VALUES ("; $sql .= $this->id; $sql .= ", '".$this->db->idate($this->timespent_date)."'"; @@ -1177,6 +1179,7 @@ class Task extends CommonObject $sql .= ", ".$this->timespent_duration; $sql .= ", ".$this->timespent_fk_user; $sql .= ", ".(isset($this->timespent_note) ? "'".$this->db->escape($this->timespent_note)."'" : "null"); + $sql .= ", '".$this->db->idate($now)."'"; $sql .= ")"; $resql = $this->db->query($sql); From 1c4c7201fce5125fc2cf55c0228ccc1a7e3bc31b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 May 2022 09:53:23 +0200 Subject: [PATCH 11/41] Trans --- htdocs/langs/en_US/admin.lang | 14 +++++++------- htdocs/projet/tasks/time.php | 13 +++++++------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 264dc86b440..3a0e96d58da 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -718,10 +718,9 @@ Permission34=Delete products Permission36=See/manage hidden products Permission38=Export products Permission39=Ignore minimum price -Permission41=Read projects and tasks (shared project and projects I'm contact for). -Permission145=Can enter time consumed, for me or my hierarchy, on assigned tasks (Timesheet) -Permission42=Create/modify projects (shared project and projects I'm contact for). Can also create tasks and assign users to project and tasks -Permission44=Delete projects (shared project and projects I'm contact for) +Permission41=Read projects and tasks (shared projects and projects of which I am a contact). +Permission42=Create/modify projects (shared projects and projects of which I am a contact). Can also assign users to projects and tasks +Permission44=Delete projects (shared projects and projects of which I am a contact) Permission45=Export projects Permission61=Read interventions Permission62=Create/modify interventions @@ -767,9 +766,10 @@ Permission122=Create/modify third parties linked to user Permission125=Delete third parties linked to user Permission126=Export third parties Permission130=Create/modify third parties payment information -Permission141=Read all projects and tasks (also private projects for which I am not a contact) -Permission142=Create/modify all projects and tasks (also private projects for which I am not a contact) -Permission144=Delete all projects and tasks (also private projects i am not contact for) +Permission141=Read all projects and tasks (as well as the private projects for which I am not a contact) +Permission142=Create/modify all projects and tasks (as well as the private projects for which I am not a contact) +Permission144=Delete all projects and tasks (as well as the private projects I am not a contact) +Permission145=Can enter time consumed, for me or my hierarchy, on assigned tasks (Timesheet) Permission146=Read providers Permission147=Read stats Permission151=Read direct debit payment orders diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 53d0e6c7f91..744a1667f7b 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -888,17 +888,18 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser $linktocreatetimeBtnStatus = 0; $linktocreatetimeUrl = ''; $linktocreatetimeHelpText = ''; - if ($user->rights->projet->all->lire || $user->rights->projet->time) { + if (!empty($user->rights->projet->time)) { if ($projectstatic->public || $userRead > 0) { $linktocreatetimeBtnStatus = 1; - if (!empty($projectidforalltimes)) { // We are on tab 'Time Spent' of project + if (!empty($projectidforalltimes)) { + // We are on tab 'Time Spent' of project $backtourl = $_SERVER['PHP_SELF'].'?projectid='.$projectstatic->id.($withproject ? '&withproject=1' : ''); - $linktocreatetimeUrl = $_SERVER['PHP_SELF'].'?'.($withproject ? 'withproject=1' : '').'&projectid='.$projectstatic->id.'&action=createtime'.$param.'&backtopage='.urlencode($backtourl); - } else // We are on tab 'Time Spent' of task - { + $linktocreatetimeUrl = $_SERVER['PHP_SELF'].'?'.($withproject ? 'withproject=1' : '').'&projectid='.$projectstatic->id.'&action=createtime&token='.newToken().$param.'&backtopage='.urlencode($backtourl); + } else { + // We are on tab 'Time Spent' of task $backtourl = $_SERVER['PHP_SELF'].'?id='.$object->id.($withproject ? '&withproject=1' : ''); - $linktocreatetimeUrl = $_SERVER['PHP_SELF'].'?'.($withproject ? 'withproject=1' : '').($object->id > 0 ? '&id='.$object->id : '&projectid='.$projectstatic->id).'&action=createtime'.$param.'&backtopage='.urlencode($backtourl); + $linktocreatetimeUrl = $_SERVER['PHP_SELF'].'?'.($withproject ? 'withproject=1' : '').($object->id > 0 ? '&id='.$object->id : '&projectid='.$projectstatic->id).'&action=createtime&token='.newToken().$param.'&backtopage='.urlencode($backtourl); } } else { $linktocreatetimeBtnStatus = -2; From ea0d6b18671b540f8ab9ed375469fa2b31147223 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 May 2022 10:00:37 +0200 Subject: [PATCH 12/41] css --- htdocs/projet/admin/project.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/admin/project.php b/htdocs/projet/admin/project.php index 37a2bb246ce..4bfb899cffe 100644 --- a/htdocs/projet/admin/project.php +++ b/htdocs/projet/admin/project.php @@ -818,7 +818,7 @@ print '
'.$langs->trans("TimesheetPreventAfterFollowingMonths").''; -print ' '; +print ' '; print ''; print '
'.$langs->trans("Totalforthispage").''.price(price2num($totalbuyingprice, 'MT')).'
'.$langs->trans("EnterADateCriteria").'
'.$langs->trans("Totalforthispage").''.price(price2num($totalbuyingprice, 'MT')).'
'; From c5a4877eb8dc3432ebb12ae536954c709d0a4997 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 May 2022 10:28:12 +0200 Subject: [PATCH 16/41] php8 --- htdocs/core/boxes/box_external_rss.php | 2 +- htdocs/core/lib/functions.lib.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/boxes/box_external_rss.php b/htdocs/core/boxes/box_external_rss.php index aff48328edb..2a04aa27803 100644 --- a/htdocs/core/boxes/box_external_rss.php +++ b/htdocs/core/boxes/box_external_rss.php @@ -127,7 +127,7 @@ class box_external_rss extends ModeleBoxes // Feed common fields $href = $item['link']; $title = urldecode($item['title']); - $date = $item['date_timestamp']; // date will be empty if conversion into timestamp failed + $date = empty($item['date_timestamp']) ? null : $item['date_timestamp']; // date will be empty if conversion into timestamp failed if ($rssparser->getFormat() == 'rss') { // If RSS if (!$date && isset($item['pubdate'])) { $date = $item['pubdate']; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 34d4120db24..14281e47a69 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2988,7 +2988,7 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli if (!empty($conf->global->MAIN_PHONE_SEPAR)) { $separ = $conf->global->MAIN_PHONE_SEPAR; } - if (empty($countrycode)) { + if (empty($countrycode) && is_object($mysoc)) { $countrycode = $mysoc->country_code; } From cdf9b89c0a476c8b4a5693b3506a8f04fdd7c05c Mon Sep 17 00:00:00 2001 From: lvessiller Date: Wed, 11 May 2022 10:51:43 +0200 Subject: [PATCH 17/41] FIX dictionary table for Debug v16 --- htdocs/core/modules/modTicket.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/modTicket.class.php b/htdocs/core/modules/modTicket.class.php index fc7e72388ea..13967fc4096 100644 --- a/htdocs/core/modules/modTicket.class.php +++ b/htdocs/core/modules/modTicket.class.php @@ -134,10 +134,10 @@ class modTicket extends DolibarrModules $this->dictionaries = array( 'langs' => 'ticket', 'tabname' => array( - MAIN_DB_PREFIX."c_ticket_type", - MAIN_DB_PREFIX."c_ticket_severity", - MAIN_DB_PREFIX."c_ticket_category", - MAIN_DB_PREFIX."c_ticket_resolution" + "c_ticket_type", + "c_ticket_severity", + "c_ticket_category", + "c_ticket_resolution" ), 'tablib' => array( "TicketDictType", From aed0296ae2ff9bfde1948fb9560dc8afd03f695c Mon Sep 17 00:00:00 2001 From: lvessiller Date: Wed, 11 May 2022 11:08:53 +0200 Subject: [PATCH 18/41] FIX dictionary table name in incoterms for Debug v16 --- htdocs/core/modules/modIncoterm.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modIncoterm.class.php b/htdocs/core/modules/modIncoterm.class.php index 9ef50fe3aac..ffbd14a88fb 100644 --- a/htdocs/core/modules/modIncoterm.class.php +++ b/htdocs/core/modules/modIncoterm.class.php @@ -85,7 +85,7 @@ class modIncoterm extends DolibarrModules } $this->dictionaries = array( 'langs'=>'incoterm', - 'tabname'=>array(MAIN_DB_PREFIX."c_incoterms"), // List of tables we want to see into dictonnary editor + 'tabname'=>array("c_incoterms"), // List of tables we want to see into dictonnary editor 'tablib'=>array("Incoterms"), // Label of tables 'tabsql'=>array('SELECT rowid, code, libelle, active FROM '.MAIN_DB_PREFIX.'c_incoterms'), // Request to select fields 'tabsqlsort'=>array("rowid ASC"), // Sort order From a5260214592d078ca63bede4ff0861c4bd68fadb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 May 2022 11:30:20 +0200 Subject: [PATCH 19/41] Better size --- htdocs/core/class/dolgraph.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 488becd06b7..2fe60cc323c 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -1548,7 +1548,7 @@ class DolGraph } } if ($direction == 'height') { - return (empty($conf->dol_optimize_smallscreen) ? ($defaultsize ? $defaultsize : '200') : '160'); + return (empty($conf->dol_optimize_smallscreen) ? ($defaultsize ? $defaultsize : '220') : '200'); } return 0; } From fc9c2295c0ac23f88783426b10e7ead63877d778 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Wed, 11 May 2022 11:38:44 +0200 Subject: [PATCH 20/41] Fix : adherent module agenda create backtopage --- htdocs/adherents/agenda.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/agenda.php b/htdocs/adherents/agenda.php index 9132dae5802..0a6abcd4955 100644 --- a/htdocs/adherents/agenda.php +++ b/htdocs/adherents/agenda.php @@ -163,7 +163,7 @@ if ($object->id > 0) { $newcardbutton = ''; if (!empty($conf->agenda->enabled)) { - $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage=1&origin=member&originid='.$id); + $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']).($object->id > 0 ? '?id='.$object->id : '').'&origin=member&originid='.$id); } if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { From e716c9abd6b38e167992de9fe944ec5d97e7817b Mon Sep 17 00:00:00 2001 From: atm-lena Date: Wed, 11 May 2022 12:38:24 +0200 Subject: [PATCH 21/41] Force to warehouse for consume produt in mo --- htdocs/mrp/mo_production.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index ad33a43b17f..cbe25d529d9 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -50,6 +50,7 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'moc $backtopage = GETPOST('backtopage', 'alpha'); $lineid = GETPOST('lineid', 'int'); $fk_movement = GETPOST('fk_movement', 'int'); +$fk_default_warehouse = GETPOST('fk_default_warehouse', 'int'); $collapse = GETPOST('collapse', 'aZ09comma'); @@ -734,6 +735,16 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; if ($collapse || in_array($action, array('consumeorproduce', 'consumeandproduceall'))) { print $langs->trans("Warehouse"); + + // Select warehouse to force it everywhere + if(in_array($action, array('consumeorproduce', 'consumeandproduceall'))) { + $listwarehouses = $tmpwarehouse->list_array(1); + if (count($listwarehouses) > 1) { + print '
' . $langs->trans("ForceTo") . ' ' . $form->selectarray('fk_default_warehouse', $listwarehouses, $fk_default_warehouse, 1, 0, 0, '', 0, 0, 0, '', 'minwidth100 maxwidth300', 1); + } elseif (count($listwarehouses) == 1) { + print '
' . $langs->trans("ForceTo") . ' ' . $form->selectarray('fk_default_warehouse', $listwarehouses, $fk_default_warehouse, 0, 0, 0, '', 0, 0, 0, '', 'minwidth100 maxwidth300', 1); + } + } } print ''; if ($conf->stock->enabled) { @@ -1057,6 +1068,16 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''; + // traitement entrepot par défaut + print ''; + // Lines to produce From 1555a6540b8cfab2494580b0fc22760bdf7c9420 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Wed, 11 May 2022 12:40:51 +0200 Subject: [PATCH 22/41] Translation --- htdocs/mrp/mo_production.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index cbe25d529d9..d6dc4d250d0 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -1068,7 +1068,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''; - // traitement entrepot par défaut + // default warehouse processing print ''; + // TODO @LDR for the save button, in action "add", set parent var to return data and close the window + //$retstring .= 'setid '; + //$retstring .= 'setlabel'; + } + return $retstring; } } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 14281e47a69..8776381b922 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1575,36 +1575,70 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename = * Such buttons must be included inside a HTML form. * * @param string $name A name for the html component - * @param string $label Label of button + * @param string $label Label shown in Popup title top bar * @param string $buttonstring button string * @param string $url Url to open * @param string $disabled Disabled text + * @param string $morecss More CSS + * @param string $backtopagejsfields The back to page must be managed using javascript instead of a redirect. + * Value is 'Name of html component to set with id:Name of html component to set with label' + * TODO Support this mode, for example when used from the page create a project on thirdparty creation. * @return string HTML component with button */ -function dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled = '') +function dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled = '', $morecss = 'button bordertransp', $backtopagejsfields = '') { if (strpos($url, '?') > 0) { - $url .= '&dol_hide_topmenu=1&dol_hide_leftmenu=1&dol_openinpopup=1'; + $url .= '&dol_hide_topmenu=1&dol_hide_leftmenu=1&dol_openinpopup='.urlencode($name); } else { - $url .= '?dol_hide_menuinpopup=1&dol_hide_leftmenu=1&dol_openinpopup=1'; + $url .= '?dol_hide_topmenu=1&dol_hide_leftmenu=1&dol_openinpopup='.urlencode($name); + } + + $out .= ''; + + $backtopagejsfieldsid = ''; $backtopagejsfieldslabel = ''; + if ($backtopagejsfields) { + $url .= '&backtopagejsfields='.urlencode($backtopagejsfields); + $tmpbacktopagejsfields = explode(':', $backtopagejsfields); + $backtopagejsfieldsid = empty($tmpbacktopagejsfields[0]) ? '' : $tmpbacktopagejsfields[0]; + $backtopagejsfieldslabel = empty($tmpbacktopagejsfields[1]) ? '' : $tmpbacktopagejsfields[1]; } //print ''; - $out = ''.$buttonstring.''; + $out .= ''."\n"; + $out .= ''.$buttonstring.''; + $out .= ''; + $out .= ''; + $out .= ''; $out .= ''; $out .= ''; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 21218f099fe..4581814f0f8 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1367,11 +1367,11 @@ if (!function_exists("llxHeader")) { print ''."\n"; // top menu and left menu area - if (empty($conf->dol_hide_topmenu) || GETPOST('dol_invisible_topmenu', 'int')) { + if ((empty($conf->dol_hide_topmenu) || GETPOST('dol_invisible_topmenu', 'int')) && !GETPOST('dol_openinpopup', 'aZ09')) { top_menu($head, $title, $target, $disablejs, $disablehead, $arrayofjs, $arrayofcss, $morequerystring, $help_url); } - if (empty($conf->dol_hide_leftmenu)) { + if (empty($conf->dol_hide_leftmenu) && !GETPOST('dol_openinpopup', 'aZ09')) { left_menu('', $help_url, '', '', 1, $title, 1); // $menumanager is retrieved with a global $menumanager inside this function } diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 6d5c807c3f0..002685415cc 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -87,13 +87,15 @@ $langs->loadLangs(array("mymodule@mymodule", "other")); // Get parameters $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); +$lineid = GETPOST('lineid', 'int'); + $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); $cancel = GETPOST('cancel', 'aZ09'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'myobjectcard'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); -$lineid = GETPOST('lineid', 'int'); +$dol_openinpopup = GETPOST('dol_openinpopup', 'aZ09'); // Initialize technical objects $object = new MyObject($db); diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index c5fc08a6402..6a27472a7e3 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -46,8 +46,11 @@ $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); +$backtopagejsfields = GETPOST('backtopagejsfields', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); $confirm = GETPOST('confirm', 'aZ09'); +$dol_openinpopup = GETPOST('dol_openinpopup', 'aZ09'); + $status = GETPOST('status', 'int'); $opp_status = GETPOST('opp_status', 'int'); $opp_percent = price2num(GETPOST('opp_percent', 'alpha')); @@ -505,9 +508,10 @@ if ($action == 'create' && $user->rights->projet->creer) { print load_fiche_titre($titlenew, '', 'project'); print '
'; - print ''; print ''; + print ''; print ''; + print ''; print dol_get_fiche_head(); @@ -605,7 +609,7 @@ if ($action == 'create' && $user->rights->projet->creer) { if (!empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) { $filteronlist = $conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST; } - $text = img_picto('', 'company').$form->select_company(GETPOST('socid', 'int'), 'socid', $filteronlist, 'SelectThirdParty', 1, 0, array(), 0, 'minwidth300 widthcentpercentminusxx'); + $text = img_picto('', 'company').$form->select_company(GETPOST('socid', 'int'), 'socid', $filteronlist, 'SelectThirdParty', 1, 0, array(), 0, 'minwidth300 widthcentpercentminusxx maxwidth500'); if (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) && empty($conf->dol_use_jmobile)) { $texthelp = $langs->trans("IfNeedToUseOtherObjectKeepEmpty"); print $form->textwithtooltip($text.' '.img_help(), $texthelp, 1); @@ -613,7 +617,12 @@ if ($action == 'create' && $user->rights->projet->creer) { print $text; } if (!GETPOSTISSET('backtopage')) { - print ' '; + $url = '/societe/card.php?action=create&client=3&fournisseur=0&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create'); + $newbutton = ''; + // TODO @LDR Impletment this + //$tmpbacktopagejsfields = 'socid:search_socid'; + //print dolButtonToOpenUrlInDialogPopup('addthirdparty', $langs->transnoentitiesnoconv('AddThirdParty'), $newbutton, $url, '', '', $tmpbacktopagejsfields); + print ' '.$newbutton.''; } print ''; } diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 154a376cca7..cbb8de3cf28 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -84,7 +84,9 @@ $error = 0; $errors = array(); $action = (GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'); $cancel = GETPOST('cancel', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); +$backtopagejsfields = GETPOST('backtopagejsfields', 'alpha'); $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); +$dol_openinpopup = GETPOST('dol_openinpopup', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); $socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int'); @@ -1262,8 +1264,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; // Chrome ignor autocomplete print ''; - print ''; print ''; + print ''; + print ''; print ''; print ''; print ''; @@ -1721,7 +1724,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print dol_get_fiche_end(); - print $form->buttonsSaveCancel("AddThirdParty"); + print $form->buttonsSaveCancel("AddThirdParty", 'Cancel', null, 0, '', $dol_openinpopup); print '
'."\n"; } elseif ($action == 'edit') { diff --git a/htdocs/website/index.php b/htdocs/website/index.php index d454ec8f532..02926e2add8 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -68,6 +68,9 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'websitelist'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$dol_hide_topmenu = GETPOST('dol_hide_topmenu', 'int'); +$dol_hide_leftmenu = GETPOST('dol_hide_leftmenu', 'int'); +$dol_openinpopup = GETPOST('dol_openinpopup', 'aZ09'); $type_container = GETPOST('WEBSITE_TYPE_CONTAINER', 'alpha'); @@ -2558,6 +2561,7 @@ print ''."\n"; print '
'; print ''; print ''; +print ''; if ($action == 'createsite') { print ''; @@ -2638,7 +2642,7 @@ if (!GETPOST('hide_websitemenu')) { //var_dump($objectpage);exit; - print '
'; + print '
'; // // Toolbar for websites