Plugins  LAST
 All Data Structures Files Functions Variables Pages
imd_operation.inc.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of NOALYSS.
5  *
6  * NOALYSS is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * NOALYSS is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with NOALYSS; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 /* $Revision$ */
21 
22 // Copyright (c) 2016 Author Dany De Bontridder dany@alchimerys.be
23 
24 /***
25  * @file
26  * @brief upload operation
27  *
28  */
29 require_once 'class_impacc_file.php';
30 
31 // step 1, select a file
32 if (!isset($_POST['upload'])&&!isset($_POST['check'])&&!isset($_POST['transfer']))
33 {
34 
35  $impacc_Operation = new Impacc_File();
36  $impacc_Operation->input_file();
37  return;
38 }
39 // step 2 save file into impdol.operation
40 if (isset($_POST['upload']))
41 {
42  // save the file
43  $io=new Impacc_File();
44 
45  // save info for file + setting
46  $io->save_file();
47 
48  // record the rows of the file into the right table CSV or XML
49  $io->record();
50 
51  // Basic check
52  $io->check();
53 
54  // show the result
55  $io->result();
56  echo '<div style="margin-left:20%">';
57  echo '<form method="POST">';
58  echo "<p class=\"notice\">".
59  _("Les opérations qui ne sont pas marquées comme correctes ne seront pas transfèrées").
60  " </p>";
61  echo HtmlInput::hidden("impid", $io->impid);
62  // If CSV show the target
63  if ( $io->import_file->i_type=="CSV")
64  {
65  $csv=new Impacc_CSV();
66  $csv->load_import($io->impid);
67  $target=$csv->make_csv_class($io->impid);
68  $ledger=new Acc_Ledger($cn,$csv->detail->jrn_def_id);
69  printf (_("Transfert vers le journal %s"),$ledger->get_name());
70  }
71  echo '<p>';
72  echo HtmlInput::submit("transfer", _("Transfert des opérations"));
73  echo '</p>';
74  echo "</FORM>";
75  echo '</div>';
76 }
77 // step 3, insert data into the target ledger
78 if (isset($_POST['transfer']))
79 {
80  $io=new Impacc_File();
81  $io->impid=HtmlInput::default_value_post('impid',0);
82  $io->load($io->impid);
83  if ( $io->impid == 0 ) throw new Exception(_("Erreur paramètre"));
84  $io->transfer();
85  $io->result_transfer();
86 }
87 ?>
$target
Definition: search_view.php:22
Used by all Import CSV Operation , contains the setting (delimiter,thousand ...)
global $cn