36 $r = HtmlInput::extension() . Dossier::hidden();
49 $hidden = self::hidden() . HtmlInput::hidden(
'sb',
'test');
50 $delimiter =
new IText(
'rdelimiter');
52 $delimiter->value =
',';
54 $fd =
new ISelect(
'rfichedef');
55 $fd->value = $cn->make_array(
'select fd_id,fd_label from fiche_def order by 2');
56 $file =
new IFile(
'csv_file');
57 $encodage =
new ICheckBox(
'encodage');
58 $encodage->selected =
true;
59 require_once(
'template/input_file.php');
60 $r = ob_get_contents();
73 $hidden = self::hidden() . HtmlInput::hidden(
'sb',
'record');
75 if (trim($_FILES[
'csv_file'][
'name']) ==
'')
77 alert(
'Pas de fichier donné');
80 $filename = tempnam($_ENV[
'TMP'],
'upload_');
81 move_uploaded_file($_FILES[
"csv_file"][
"tmp_name"], $filename);
83 $file_cat = $cn->get_value(
'select fd_label from fiche_def where fd_id=$1', array($_POST[
'rfichedef']));
84 $encoding = (isset(
$_REQUEST[
'encodage'])) ?
'Unicode' :
'latin1';
85 $skip_row=HtmlInput::default_value_request(
"skip_row", 0);
86 require_once(
'template/test_file.php');
117 $fd = fopen($filename,
'r');
125 $valid_accounting = 0;
126 for ($i = 0; $i < count($head_col); $i++)
128 if ($head_col[$i] != -1)
130 if ($head_col[$i] == 1)
132 if ($head_col[$i] == ATTR_DEF_QUICKCODE)
134 if ($head_col[$i] == ATTR_DEF_ACCOUNT)
135 $valid_accounting = 1;
137 for ($e = $i + 1; $e < count($head_col); $e++)
138 if ($head_col[$i] == $head_col[$e] && $head_col[$e] != -1)
144 alert(
"Aucune colonne n'est définie");
147 if ($valid_name == 0)
149 alert(
"Les fiches doivent avoir au minimum un nom");
154 alert(
'Vous avez défini plusieurs fois la même colonne');
157 if ($valid_qcode == 0)
159 alert(
"Vous devez donner la colonne quick_code");
171 while ((
$row = fgetcsv($fd, 0, $_POST[
'rdelimiter'], $_POST[
'rsurround'])) !==
false)
176 echo
'<tr style="border:solid 1px black">';
178 $count_col = count(
$row);
180 for ($i = 0; $i < $count_col; $i++)
182 if ($head_col[$i] == -1)
185 $header[$col_count] = $head_col[$i];
189 $attr = sprintf(
'av_text%d', $head_col[$i]);
196 $quick_code= sprintf(
'av_text%d',ATTR_DEF_QUICKCODE);
197 if (
$fiche->get_by_qcode(
$array[$quick_code],
false)==0 )
200 $attr = sprintf(
'av_text%d', ATTR_DEF_ACCOUNT);
209 if ($valid_accounting == 0)
211 $attr = sprintf(
'av_text%d', ATTR_DEF_ACCOUNT);
221 echo td($e->getMessage());
225 $table_content = ob_get_contents();
229 for ($e = 0; $e < count(
$header); $e++)
231 $name = $cn->get_value(
'select ad_text from attr_def where ad_id=$1', array(
$header[$e]));
238 $name = $cn->get_value(
'select fd_label from fiche_def where fd_id=$1', array($rfichedef));
239 $cn->get_value(
'select comptaproc.fiche_attribut_synchro($1)', array($rfichedef));
240 echo
'<span class="notice">';
for($i=0;$i< Database::num_row($ret);$i++) $row
if(isset($_POST['remove'])) $array
static new_import()
show the first screen, you must here enter the date format the file, the card category,
static record_import()
record all rows
static hidden()
for the form we have here all the hidden variables
static test_import()
Test the CSV file, show the choosed delimiter, the CSV parsed, and replace column header by attribute...