Plugins  LAST
 All Data Structures Files Functions Variables Pages
test_operation.php
Go to the documentation of this file.
1 <?php
2 //This file is part of NOALYSS and is under GPL
3 //see licence.txt
4 ?>
5 
6 <h2>
7 <?php
8 echo _('Importation de données');
9 ?>
10 </h2>
11 
12 <p>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.
13 </p>
14 
15 <form method="POST" >
16 <?php echo $hidden?>
17 <table>
18 <tr>
19 <td>Délimiteur </td>
20 <td> <?php echo $_POST['rdelimiter']?></td>
21 </tr>
22 <tr>
23 <td>Fichier à charger</td><td> <?php echo $_FILES['csv_file']['name']?></td>
24 </tr>
25 <tr>
26 <td>Catégorie de fiche</td><td> <?php echo $file_cat;?></td>
27 </tr>
28 <tr>
29 <td>Encodage </td><td> <?php echo $encoding?></td>
30 </tr>
31 <tr>
32 <td>Texte entouré par</td><td> <?php echo $_POST['rsurround'];?></td>
33 </tr>
34 </table>
35 <?php
36 foreach (array('rfichedef','rdelimiter','encodage') as $e)
37 {
38  if ( isset($_POST[$e])) echo HtmlInput::hidden($e,$_POST[$e]);
39 }
40 echo HtmlInput::hidden('filename',$filename);
41 
42  echo HtmlInput::submit('record_import','Valider');
43 ?>
44 <input type="hidden" name="rsurround" value='<?php echo $_POST['rsurround']?>'>
45 
46 
47 
48 <?php
49  global $cn;
50  ob_start();
51  /**
52  * Open the file and parse it
53  */
54 $fcard=fopen($filename,'r');
55 $row_count=0;
56 $max=0;
57 while (($row=fgetcsv($fcard,0,$_POST['rdelimiter'],$_POST['rsurround'])) !== false)
58  {
59  $row_count++;
60  echo '<tr style="border:solid 1px black">';
61  echo td($row_count);
62  $count_col=count($row);
63  $max=($count_col>$max)?$count_col:$max;
64  for ($i=0;$i<$count_col;$i++)
65  {
66  echo td($row[$i],'style="border:solid 1px black"');
67  }
68  echo '</tr>';
69  }
70 $table=ob_get_contents();
71 ob_end_clean();
72 
73 
74 echo '<table style="border:solid 1px black;width:100%">
75 <tr>';
76 
77 /**
78  *create widget column header
79  */
80 $header=new ISelect('head_col[]');
81 
82 $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 ',$_POST['rfichedef']);
83 $header->value=$cn->make_array($sql);
84 $header->value[]=array('value'=>-1,'label'=>'-- Non Utilisé --');
85 $header->selected=-1;
86 echo th('Numéro de ligne');
87 for ($i=0;$i<$max;$i++)
88  {
89  echo '<th>'.$header->input().'</th>';
90  }
91 echo '</tr>';
92 echo $table;
93 echo '</table>';
94 echo '</form>';
95 ?>
while(($row=fgetcsv($fbank, 0, $sp))!==false) $table
for($i=0;$i< Database::num_row($ret);$i++) $row
$header
$p_year value
$categorie_appel table
$categorie_appel name
$sql
$row_count
global $cn
$fcard
Open the file and parse it.
Definition: test_file.php:26