Work on import module
This commit is contained in:
parent
841869ede5
commit
c13477f860
@ -78,15 +78,22 @@ else $type=dol_mimetype($original_file);
|
|||||||
|
|
||||||
// Define attachment (attachment=true to force choice popup 'open'/'save as')
|
// Define attachment (attachment=true to force choice popup 'open'/'save as')
|
||||||
$attachment = true;
|
$attachment = true;
|
||||||
|
// Documents
|
||||||
|
if (eregi('\.doc$',$original_file)) { $attachment = true; }
|
||||||
|
if (eregi('\.ppt$',$original_file)) { $attachment = true; }
|
||||||
|
if (eregi('\.xls$',$original_file)) { $attachment = true; }
|
||||||
|
if (eregi('\.pdf$',$original_file)) { $attachment = true; }
|
||||||
|
// Misc
|
||||||
if (eregi('\.sql$',$original_file)) { $attachment = true; }
|
if (eregi('\.sql$',$original_file)) { $attachment = true; }
|
||||||
if (eregi('\.html$',$original_file)) { $attachment = false; }
|
if (eregi('\.html$',$original_file)) { $attachment = false; }
|
||||||
|
// Text files
|
||||||
if (eregi('\.csv$',$original_file)) { $attachment = true; }
|
if (eregi('\.csv$',$original_file)) { $attachment = true; }
|
||||||
if (eregi('\.tsv$',$original_file)) { $attachment = true; }
|
if (eregi('\.tsv$',$original_file)) { $attachment = true; }
|
||||||
if (eregi('\.pdf$',$original_file)) { $attachment = true; }
|
// Images
|
||||||
if (eregi('\.xls$',$original_file)) { $attachment = true; }
|
|
||||||
if (eregi('\.jpg$',$original_file)) { $attachment = true; }
|
if (eregi('\.jpg$',$original_file)) { $attachment = true; }
|
||||||
if (eregi('\.png$',$original_file)) { $attachment = true; }
|
if (eregi('\.png$',$original_file)) { $attachment = true; }
|
||||||
if (eregi('\.tiff$',$original_file)) { $attachment = true; }
|
if (eregi('\.tiff$',$original_file)) { $attachment = true; }
|
||||||
|
// Calendar
|
||||||
if (eregi('\.vcs$',$original_file)) { $attachment = true; }
|
if (eregi('\.vcs$',$original_file)) { $attachment = true; }
|
||||||
if (eregi('\.ics$',$original_file)) { $attachment = true; }
|
if (eregi('\.ics$',$original_file)) { $attachment = true; }
|
||||||
if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false;
|
if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false;
|
||||||
@ -364,7 +371,7 @@ if ($modulepart)
|
|||||||
$sqlprotectagainstexternals = '';
|
$sqlprotectagainstexternals = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wrapping pour les exports
|
// Wrapping for export module
|
||||||
if ($modulepart == 'export')
|
if ($modulepart == 'export')
|
||||||
{
|
{
|
||||||
// Aucun test necessaire car on force le rep de doanwload sur
|
// Aucun test necessaire car on force le rep de doanwload sur
|
||||||
@ -374,6 +381,16 @@ if ($modulepart)
|
|||||||
$sqlprotectagainstexternals = '';
|
$sqlprotectagainstexternals = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Wrapping for import module
|
||||||
|
if ($modulepart == 'import')
|
||||||
|
{
|
||||||
|
// Aucun test necessaire car on force le rep de doanwload sur
|
||||||
|
// le rep export qui est propre a l'utilisateur
|
||||||
|
$accessallowed=1;
|
||||||
|
$original_file=$conf->import->dir_temp.'/'.$original_file;
|
||||||
|
$sqlprotectagainstexternals = '';
|
||||||
|
}
|
||||||
|
|
||||||
// Wrapping pour l'editeur wysiwyg
|
// Wrapping pour l'editeur wysiwyg
|
||||||
if ($modulepart == 'editor')
|
if ($modulepart == 'editor')
|
||||||
{
|
{
|
||||||
|
|||||||
@ -376,7 +376,7 @@ class FormFile
|
|||||||
print '</a>';
|
print '</a>';
|
||||||
if (!$iconPDF) print '</td>';
|
if (!$iconPDF) print '</td>';
|
||||||
// Affiche taille fichier
|
// Affiche taille fichier
|
||||||
if (!$iconPDF) print '<td align="right">'.filesize($filedir."/".$file["name"]). ' bytes</td>';
|
if (!$iconPDF) print '<td align="right">'.dol_filesize($filedir."/".$file["name"]).'</td>';
|
||||||
// Affiche date fichier
|
// Affiche date fichier
|
||||||
if (!$iconPDF) print '<td align="right">'.dol_print_date(filemtime($filedir."/".$file["name"]),'dayhour').'</td>';
|
if (!$iconPDF) print '<td align="right">'.dol_print_date(filemtime($filedir."/".$file["name"]),'dayhour').'</td>';
|
||||||
|
|
||||||
@ -489,4 +489,16 @@ class FormFile
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return size of a file with units
|
||||||
|
*
|
||||||
|
* @param $pathoffile
|
||||||
|
* @return string File size with units translated
|
||||||
|
*/
|
||||||
|
function dol_filesize($pathoffile)
|
||||||
|
{
|
||||||
|
global $langs;
|
||||||
|
return filesize($pathoffile). ' '.$langs->trans("Bytes");
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -375,7 +375,7 @@ if ($step == 2 && $datatoimport)
|
|||||||
$var=true;
|
$var=true;
|
||||||
|
|
||||||
// Add help informations
|
// Add help informations
|
||||||
print '<tr class="liste_titre"><td colspan="4">';
|
print '<tr class="liste_titre"><td colspan="6">';
|
||||||
print $langs->trans("FileMustHaveOneOfFollowingFormat");
|
print $langs->trans("FileMustHaveOneOfFollowingFormat");
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
$liste=$objmodelimport->liste_modeles($db);
|
$liste=$objmodelimport->liste_modeles($db);
|
||||||
@ -384,20 +384,20 @@ if ($step == 2 && $datatoimport)
|
|||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'>';
|
print '<tr '.$bc[$var].'>';
|
||||||
print '<td width="16">'.img_picto_common($key,$objmodelimport->getPicto($key)).'</td>';
|
print '<td width="16">'.img_picto_common($key,$objmodelimport->getPicto($key)).'</td>';
|
||||||
print '<td colspan="3">'.$objmodelimport->getDriverLabel($key).'</td>';
|
print '<td colspan="5">'.$objmodelimport->getDriverLabel($key).'</td>';
|
||||||
//print '<td>'.$objmodelimport->getLibLabel($key).'</td><td>'.$objmodelimport->getLibVersion($key).'</td>';
|
//print '<td>'.$objmodelimport->getLibLabel($key).'</td><td>'.$objmodelimport->getLibVersion($key).'</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<tr><td colspan="4"> </td></tr>';
|
print '<tr><td colspan="6"> </td></tr>';
|
||||||
|
|
||||||
print '<tr><td colspan="4">'.$langs->trans("ChooseFileToImport").'</td></tr>';
|
print '<tr><td colspan="6">'.$langs->trans("ChooseFileToImport").'</td></tr>';
|
||||||
|
|
||||||
print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("FileWithDataToImport").'</td></tr>';
|
print '<tr class="liste_titre"><td colspan="6">'.$langs->trans("FileWithDataToImport").'</td></tr>';
|
||||||
|
|
||||||
// Input file name box
|
// Input file name box
|
||||||
$var=false;
|
$var=false;
|
||||||
print '<tr '.$bc[$var].'><td colspan="4">';
|
print '<tr '.$bc[$var].'><td colspan="6">';
|
||||||
print '<input type="file" name="userfile" size="20" maxlength="80"> ';
|
print '<input type="file" name="userfile" size="20" maxlength="80"> ';
|
||||||
print '<input type="submit" class="button" value="'.$langs->trans("AddFile").'" name="sendit">';
|
print '<input type="submit" class="button" value="'.$langs->trans("AddFile").'" name="sendit">';
|
||||||
print '<input type="hidden" value="'.$step.'" name="step">';
|
print '<input type="hidden" value="'.$step.'" name="step">';
|
||||||
@ -436,12 +436,25 @@ if ($step == 2 && $datatoimport)
|
|||||||
{
|
{
|
||||||
if (eregi('^\.',$file)) continue;
|
if (eregi('^\.',$file)) continue;
|
||||||
|
|
||||||
|
$modulepart='import';
|
||||||
|
$urlsource=$_SERVER["PHP_SELF"].'?step='.$step.'&datatoimport='.$datatoimport;
|
||||||
|
$relativepath=$file;
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'>';
|
print '<tr '.$bc[$var].'>';
|
||||||
print '<td width="16">'.img_mime($file).'</td>';
|
print '<td width="16">'.img_mime($file).'</td>';
|
||||||
print '<td>'.$file.'</td>';
|
print '<td>'.$file.'</td>';
|
||||||
print '<td align="center">del</td>';
|
// Affiche taille fichier
|
||||||
print '<td align="right">next</td>';
|
print '<td align="right">'.dol_filesize($dir.'/'.$file).'</td>';
|
||||||
|
// Affiche date fichier
|
||||||
|
print '<td align="right">'.dol_print_date(filemtime($dir.'/'.$file),'dayhour').'</td>';
|
||||||
|
// Del button
|
||||||
|
print '<td align="right"><a href="'.DOL_URL_ROOT.'/document.php?action=remove_file&modulepart='.$modulepart.'&file='.urlencode($relativepath);
|
||||||
|
print '&urlsource='.urlencode($urlsource);
|
||||||
|
print '">'.img_delete().'</a></td>';
|
||||||
|
// Action button
|
||||||
|
print '<td align="right">';
|
||||||
|
print '<a href="'.DOL_URL_ROOT.'/imports/import.php?step=3&datatoimport='.$datatoimport.'&filetoimport='.urlencode($relativepath).'">'.img_picto($langs->trans("NewImport"),'filenew').'</a>';
|
||||||
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
}
|
}
|
||||||
//print '</table></td></tr>';
|
//print '</table></td></tr>';
|
||||||
@ -499,57 +512,24 @@ if ($step == 3 && $datatoimport)
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Nbre champs importes
|
// Nbre champs importes
|
||||||
print '<tr><td width="25%">'.$langs->trans("ImportedFields").'</td>';
|
print '<tr><td width="25%">'.$langs->trans("FileToImport").'</td>';
|
||||||
$list='';
|
print '<td>'.$_GET["filetoimport"].'</td></tr>';
|
||||||
foreach($array_selected as $code=>$value)
|
|
||||||
{
|
|
||||||
$list.=($list?',':'');
|
|
||||||
$list.=$langs->trans($objimport->array_import_fields[0][$code]);
|
|
||||||
}
|
|
||||||
print '<td>'.$list.'</td></tr>';
|
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
print $langs->trans("ChooseFieldsOrdersAndTitle").'<br>';
|
print $langs->trans("SelectImportFields");
|
||||||
|
|
||||||
print '<table class="noborder" width="100%">';
|
print '<table class="noborder" width="100%">';
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
|
print '<td>'.$langs->trans("FieldsTitle").'</td>';
|
||||||
|
print '<td> </td>';
|
||||||
print '<td>'.$langs->trans("Entities").'</td>';
|
print '<td>'.$langs->trans("Entities").'</td>';
|
||||||
print '<td>'.$langs->trans("ImportedFields").'</td>';
|
print '<td>'.$langs->trans("ImportedFields").'</td>';
|
||||||
print '<td align="right" colspan="2">'.$langs->trans("Position").'</td>';
|
print '<td align="right" colspan="2">'.$langs->trans("Position").'</td>';
|
||||||
print '<td> </td>';
|
|
||||||
print '<td>'.$langs->trans("FieldsTitle").'</td>';
|
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
|
|
||||||
// List deroulante des modeles d'import
|
|
||||||
/* print '<form action="import.php" method="post">';
|
|
||||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
|
||||||
print '<input type="hidden" name="action" value="select_model">';
|
|
||||||
print '<input type="hidden" name="step" value="2">';
|
|
||||||
print '<input type="hidden" name="datatoimport" value="'.$datatoimport.'">';
|
|
||||||
print '<table><tr><td>';
|
|
||||||
print $langs->trans("SelectImportFields");
|
|
||||||
print '</td><td>';
|
|
||||||
$htmlother->select_import_model($importmodelid,'importmodelid',$datatoimport,1);
|
|
||||||
print '<input type="submit" class="button" value="'.$langs->trans("Select").'">';
|
|
||||||
print '</td></tr></table>';
|
|
||||||
print '</form>';
|
|
||||||
|
|
||||||
|
|
||||||
print '<table class="noborder" width="100%">';
|
|
||||||
print '<tr class="liste_titre">';
|
|
||||||
print '<td>'.$langs->trans("Entities").'</td>';
|
|
||||||
print '<td>'.$langs->trans("ImportableFields").'</td>';
|
|
||||||
print '<td width="12" align="middle">';
|
|
||||||
print '<a title='.$langs->trans("All").' alt='.$langs->trans("All").' href="'.$_SERVER["PHP_SELF"].'?step=2&datatoimport='.$datatoimport.'&action=selectfield&field=all">'.$langs->trans("All")."</a>";
|
|
||||||
print '/';
|
|
||||||
print '<a title='.$langs->trans("None").' alt='.$langs->trans("None").' href="'.$_SERVER["PHP_SELF"].'?step=2&datatoimport='.$datatoimport.'&action=unselectfield&field=all">'.$langs->trans("None")."</a>";
|
|
||||||
print '</td>';
|
|
||||||
print '<td width="44%">'.$langs->trans("ImportedFields").'</td>';
|
|
||||||
print '</tr>';
|
|
||||||
|
|
||||||
// Champs importables
|
// Champs importables
|
||||||
$fieldsarray=$objimport->array_import_fields[0];
|
$fieldsarray=$objimport->array_import_fields[0];
|
||||||
|
|
||||||
@ -598,7 +578,6 @@ if ($step == 3 && $datatoimport)
|
|||||||
}
|
}
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
$var=true;
|
$var=true;
|
||||||
|
|||||||
@ -54,5 +54,6 @@ LineTotalTTC=Amount with tax for line
|
|||||||
LineTotalVAT=Amount of VAT for line
|
LineTotalVAT=Amount of VAT for line
|
||||||
TypeOfLineServiceOrProduct=Type of line (0=product, 1=service)
|
TypeOfLineServiceOrProduct=Type of line (0=product, 1=service)
|
||||||
FileWithDataToImport=File with data to import
|
FileWithDataToImport=File with data to import
|
||||||
|
FileToImport=File to import
|
||||||
FileMustHaveOneOfFollowingFormat=File to import must have one of following format
|
FileMustHaveOneOfFollowingFormat=File to import must have one of following format
|
||||||
ChooseFileToImport=Choose file to import...
|
ChooseFileToImport=Choose file to import...
|
||||||
@ -54,5 +54,6 @@ LineTotalTTC=Montant TTC de la ligne
|
|||||||
LineTotalVAT=Montant TVA de la ligne
|
LineTotalVAT=Montant TVA de la ligne
|
||||||
TypeOfLineServiceOrProduct=Type de ligne (0=produit, 1=service)
|
TypeOfLineServiceOrProduct=Type de ligne (0=produit, 1=service)
|
||||||
FileWithDataToImport=Fichier contenant les données à importer
|
FileWithDataToImport=Fichier contenant les données à importer
|
||||||
|
FileToImport=Fichier à importer
|
||||||
FileMustHaveOneOfFollowingFormat=Le fichier à importer doit avoir un des formats suivants
|
FileMustHaveOneOfFollowingFormat=Le fichier à importer doit avoir un des formats suivants
|
||||||
ChooseFileToImport=Choisissez le fichier à importer...
|
ChooseFileToImport=Choisissez le fichier à importer...
|
||||||
Loading…
Reference in New Issue
Block a user