Plugins  LAST
 All Data Structures Files Functions Variables Pages
confirm_transfer.php
Go to the documentation of this file.
1 <?php
2 /*
3  * This file is part of NOALYSS.
4  *
5  * NOALYSS is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * NOALYSS is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with NOALYSS; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */
20 $max=0;
21 
22 // Parse and analyze the CSV File and store it into a variable to display
23 // later
24 ob_start();
25 
26 switch ($sep_field->selected)
27 {
28  case 1:
29  $sp=',';
30  break;
31  case 2:
32  $sp=';';
33  break;
34  default:
35  echo "Séparateur invalide ";
36  exit();
37 }
38 /**
39  * retrieve the format
40  */
41 $date_format=$aformat_date[$format_date->selected-1]['format'];
42 
43 // decimal delimiter, stored into $sep_thousand and $athousand and
45 
46 // $sep_decimal and $adecimal defined in bank_constant.php
48 
49 while (($row=fgetcsv($fbank, 0, $sp))!==false)
50 {
51  $skip_row=0;
52  $msg="";
53  $and="";
54  if ($row_count<$skip->value)
55  {
56  $msg=_('Lignes non prises');
57  $and="&";
58  $skip_row=1;
59  }
60  $row_count++;
61 
62  $array_row=$row;
63  $count_col=count($array_row);
64  $max=($count_col>$max)?$count_col:$max;
65  $table_row="";
66  $table_row .= td($row_count);
67  $table_row .= td($count_col);
68  if ( $skip_row == 0 && $count_col != $nb_col->value ) {
69  $msg=_('Nombre de colonnes incorrect');
70  $and="&";
71  $skip_row=1;
72  }
73  for ($i=0; $i<$count_col; $i++)
74  {
75  // check if data is ok
76  // date must be a date , it depends of the date format, stored into
77  // format_date and $aformat_date defined in bank_constant.php
78  if ($i==$pos_date && $skip_row == 0 )
79  {
80 
81 
82  // create a time thanks the format
83  $test=DateTime::createFromFormat($date_format, $array_row[$i]);
84 
85  // check result
86  if ($test==false)
87  {
88  $msg.=" $and "._('date incorrecte');
89  $msg.=" format = $date_format";
90  $and="&";
91  }
92  }
93  // check if amount is a valid numeric, it depends of the amount format,
94 
95  if ($i==$pos_amount && $skip_row == 0)
96  {
97  /* $sep_thousand->selected=$_POST['sep_thous'];
98  * $sep_decimal->selected=$_POST['sep_dec'];
99  */
100  $amount=$array_row[$i];
101  // replace + sign
102  $amount=str_replace('+', '', $amount);
103 
104  // remove space
105  $amount=str_replace(' ', '', $amount);
106 
107 
108  if ($thousand_format!='')
109  $amount=str_replace($thousand_format,'', $amount);
110  if ($decimal_format<>'.')
111  $amount=str_replace($decimal_format,'.', $amount);
112  if (isNumber($amount ) == 0)
113  {
114  $msg.=" $and "._('Montant incorrect');
115  $and="&";
116  }
117  }
118  $table_row.=td(utf8_encode($array_row[$i]),
119  'style="border:solid 1px black"');
120  }
121  $table_row .= td($msg);
122  if (trim(strlen($msg))==0)
123  {
124  echo '<tr style="border:solid 1px black">';
125  }
126  else
127  {
128  echo '<tr style="background:red;border:solid 1px red">';
129  }
130  echo $table_row;
131  echo '</tr>';
132 }
133 $table=ob_get_contents();
134 ob_end_clean();
135 
136 
137 $nb_col->value=($nb_col->value=='')?$max:$nb_col->value;
138 ?>
139 
140 <h2>Etape 3/4 : confirmez le transfert</h2>
141  Nom du format <?php echo hb($format->value); ?>
142  <?php echo HtmlInput::button_action(_('Changer format'), "$('import_bank_format_div').show()",'x','smallbutton')?>
143 <div id="import_bank_format_div" class="inner_box" style="width:auto;display:none;">
144 <form method="POST" enctype="multipart/form-data">
145  <table>
146  <tr>
147  <td>
148  Nom du format
149  </td>
150  <td>
151  <?php echo $format->input() ?>
152  </td>
153  </tr>
154  <tr>
155  <td>
156  A importer dans le journal de banque
157  </td>
158  <td>
159  <?php echo $jrn_def->input() ?>
160  </td>
161  </tr>
162  <tr>
163  <td>
164  Format de date
165  </td>
166  <td>
167  <?php echo $format_date->input() ?>
168  </td>
169  </tr>
170 
171  <tr>
172  <td>
173  Séparateur de champs
174  </td>
175  <td>
176  <?php echo $sep_field->input() ?>
177  </td>
178  </tr>
179 
180  <tr>
181  <td>
182  Séparateur de millier
183  </td>
184  <td>
185  <?php echo $sep_thousand->input() ?>
186  </td>
187  </tr>
188 
189  <tr>
190  <td>
191  Séparateur décimal
192  </td>
193  <td>
194  <?php echo $sep_decimal->input() ?>
195  </td>
196  </tr>
197  <tr>
198  <td>
199  Ligne d'en-tête à ne pas prendre en considération
200  </td>
201  <td>
202  <?php echo $skip->input() ?>
203  </td>
204  </tr>
205  <tr>
206  <td>
207  Les lignes ayant ce nombre de colonnes sont valides
208  </td>
209  <td>
210 <?php echo $nb_col->input() ?>
211  </td>
212  </tr>
213 
214 
215 
216 
217 
218  </table>
219  <p class="notice">Les lignes en rouge ne seront pas importées</p>
220 <?php
221 echo HtmlInput::post_to_hidden(array('gDossier', 'plugin_code', 'sa', 'format'));
222 echo HtmlInput::hidden('sb', 'upload_file');
223 echo HtmlInput::hidden('filename', $filename);
224 ?>
225  <ul class="aligned-block">
226  <li>
227  <?php echo HtmlInput::submit('correct_format', 'Changer format');?>
228  </li>
229  <li>
230  <?php echo HtmlInput::button_action(_('Fermer'), "$('import_bank_format_div').hide()","closeit","smallbutton");?>
231  </li>
232  </ul>
233 </form>
234 </div>
235  <form method="POST" enctype="multipart/form-data">
236 
237  <?php
238  echo HtmlInput::post_to_hidden(array('format', 'gDossier', 'plugin_code',
239  'sa', 'format', 'jrn_def', 'format_name', 'format_date', 'sep_field',
240  'sep_thous', 'sep_dec', 'skip'));
241  echo HtmlInput::hidden('sb', $sb);
242  echo HtmlInput::hidden('nb_col', $nb_col->value);
243 
244  echo HtmlInput::hidden('filename', $filename);
245  echo HtmlInput::submit('transfer_submit', 'Enregistrer les opérations');
246  ?>
247  <table>
248  <tr>
249  <?php
250  $header=new ISelect('header[]');
251  $header->value=$aheader;
252 
253  echo th('Ligne n°');
254  echo th('Nbre de colonnes');
255 
256  for ($i=0; $i<$max; $i++)
257  {
258  $header->selected=-1;
259  switch ($i)
260  {
261  case $pos_date:
262  $header->selected=0;
263  break;
264 
265  case $pos_amount:
266  $header->selected=1;
267  break;
268 
269  case $pos_lib:
270  $header->selected=2;
271  break;
272 
273  case $pos_operation_nb:
274  $header->selected=3;
275  break;
276  case $pos_third:
277  $header->selected=4;
278  break;
279  case $pos_extra:
280  $header->selected=5;
281  break;
282  }
283  echo '<th>'.$header->input()."</th>";
284  }
285  echo th(_('Résultat'));
286  echo '</tr>';
287  echo $table;
288  ?>
289  </table>
290 <?php echo HtmlInput::submit('transfer_submit', _('Enregistrer les opérations')) ?>
291  </form>
$msg
while(($row=fgetcsv($fbank, 0, $sp))!==false) $table
global $aformat_date
$note style
$thousand_format
for($i=0;$i< Database::num_row($ret);$i++) $row
$format_date
Definition: import_bank.php:57
$sep_decimal
Definition: import_bank.php:46
Format
Definition: importcard.js:18
$sep_thousand
Definition: import_bank.php:49
if(!isset($_REQUEST['sb'])) $format
Definition: import_bank.php:43
$sep_field
Definition: import_bank.php:52
$decimal_format
$skip_row
global $adecimal
switch($sep_field->selected) $date_format
retrieve the format
$categorie_appel table
$nb_col value
global $athousand
$nb_col
Definition: import_bank.php:65
$jrn_def
Definition: import_bank.php:44
$row_count