8 echo _(
'Importation de données');
13 <?php echo _(
"Pour importer des données, c'est-à-dire transformer des fichiers CSV (Valeur séparé par des virgules) en des fiches. Vous devez choisir, un fichier et donner une catégorie de fiche existante. Ensuite, il suffit d'indiquer quelles colonnes correspondent à quelle attribut. ");?>
21 <td> <?php echo $_POST[
'rdelimiter']?></td>
24 <td><?php echo _(
"Fichier à charger");?></td><td> <?php echo $_FILES[
'csv_file'][
'name']?></td>
27 <td><?php echo _(
"Catégorie de fiche");?></td><td> <?php echo $file_cat;?></td>
30 <td><?php echo _(
"Encodage");?> </td><td> <?php echo $encoding?></td>
33 <td><?php echo _(
"Texte entouré par");?></td><td> <?php echo $_POST[
'rsurround'];?></td>
37 foreach (array(
'rfichedef',
'rdelimiter',
'encodage') as $e)
39 if ( isset($_POST[$e])) echo HtmlInput::hidden($e,$_POST[$e]);
41 echo HtmlInput::hidden(
'filename',$filename);
43 echo HtmlInput::submit(
'record_import',
'Valider');
45 <input type=
"hidden" name=
"rsurround" value=
'<?php echo $_POST['rsurround
']?>'>
55 $fcard=fopen($filename,
'r');
58 while ((
$row=fgetcsv(
$fcard,0,$_POST[
'rdelimiter'],$_POST[
'rsurround'])) !==
false)
61 echo
'<tr style="border:solid 1px black">';
63 $count_col=count(
$row);
65 for ($i=0;$i<$count_col;$i++)
67 echo td(
$row[$i],
'style="border:solid 1px black"');
75 echo
'<table style="border:solid 1px black;width:100%">
81 $header=
new ISelect(
'head_col[]');
82 $fiche_def=HtmlInput::default_value_post(
'rfichedef', -1);
83 if ( $fiche_def == -1 ||isNumber($fiche_def)==0) {
84 throw new Exception(_(
'Catégorie invalide'));
86 $sql=sprintf(
'select ad_id,ad_text from jnt_fic_attr join attr_def using(ad_id) where fd_id=%d order by ad_text ', sql_string($fiche_def));
87 $a_attribute=$cn->get_array(
$sql);
89 $header->value[]=array(
'value'=>-1,
'label'=>
'-- Non Utilisé --');
91 echo th(_(
'Numéro de ligne'));
92 for ($i=0;$i<
$max;$i++)
95 $header->selected=$a_attribute[$i][
'ad_id'];
96 echo
'<th>'.$header->input().
'</th>';
if($fcard==FALSE) $row_count
for($i=0;$i< Database::num_row($ret);$i++) $row
while(($row=fgetcsv($fcard, 0, $delimiter, $surround))!==false) $table
$fcard
Open the file and parse it.