Plugins  LAST
 All Data Structures Files Functions Variables Pages
Public Member Functions | Data Fields | Static Public Attributes
Impacc_File Class Reference
Collaboration diagram for Impacc_File:
Collaboration graph

Public Member Functions

 save_file ()
 Save the uploaded file and CSV setting if it is CSV import. More...
 
 load ($p_import_id)
 
 record ()
 Load the file in a temporary table. More...
 
 input_file ()
 Display the parameters and the file to upload. More...
 
 check ()
 Check the rows of the imported file. More...
 
 result ()
 Display the rows of the imported file and a status for each row. More...
 
 transfer ()
 Transfer to accountancy. More...
 
 result_transfer ()
 Show the result of the file import. More...
 
 display_list ()
 
 delete ($id)
 Delete a row in impacc.import_file. More...
 

Data Fields

 $format
 
 $filename
 
 $import_file
 Impacc_Import_file_SQL $impid. More...
 

Static Public Attributes

static $aformat =array(1=>"CSV")
 

Detailed Description

Definition at line 34 of file class_impacc_file.php.

Member Function Documentation

Impacc_File::check ( )

Check the rows of the imported file.

Definition at line 133 of file class_impacc_file.php.

134  {
135  if ($this->import_file->i_type=='CSV')
136  {
137  $operation=new Impacc_Operation();
138  $operation->check($this);
139  }
140  }
Redirect to CSV or other format.
Impacc_File::delete (   $id)

Delete a row in impacc.import_file.

Definition at line 200 of file class_impacc_file.php.

References $cn, and $id.

201  {
202  $cn=Dossier::connect();
203  $cn->exec_sql("delete from impacc.import_file where id=$1",array($id));
204 
205  }
global $cn
Impacc_File::display_list ( )

Definition at line 180 of file class_impacc_file.php.

References $array, and $cn.

181  {
182  $cn=Dossier::connect();
183  $array=$cn->get_array(
184  "
185  select
186  id,
187  i_filename,
188  i_type,
189  to_char(i_date_transfer,'DD.MM.YY HH:MI') as stransfer,
190  to_char(i_date_import,'DD.MM.YY HH:MI') as simport,
191  to_char(i_date_transfer,'YYYYMMDDHHMI') as sorder_transfer
192  from
193  impacc.import_file
194  order by i_date_transfer desc
195  "
196  );
197  require_once DIR_IMPORT_ACCOUNT."/template/history_file.php";
198  }
if(isset($_POST['remove'])) $array
global $cn
Impacc_File::input_file ( )

Display the parameters and the file to upload.

Definition at line 118 of file class_impacc_file.php.

References $file, and $format.

119  {
120 
121  $file=new IFile("file_operation");
122  $format=new ISelect("format");
123  $format->id="format_sel";
124  $format->value=array(
125  array("value"=>0, "label"=>"-"),
126  array("value"=>1, "label"=>"CSV")
127  );
128  $format->javascript="onchange=\"ctl_display()\"";
129  require_once DIR_IMPORT_ACCOUNT."/template/input_file.php";
130  }
$file
Definition: import_bank.php:60
Impacc_File::load (   $p_import_id)

Definition at line 100 of file class_impacc_file.php.

References $cn.

101  {
102  $cn=Dossier::connect();
103  $this->import_file=new Impacc_Import_file_SQL($cn,$p_import_id);
104 
105  }
global $cn
Impacc_File::record ( )

Load the file in a temporary table.

Definition at line 107 of file class_impacc_file.php.

References $cn.

108  {
109  $operation=new Impacc_Operation();
110  $operation->record_file($this);
111  $cn=Dossier::connect();
112  $cn->exec_sql("update impacc.import_file set i_date_transfer=now() where id=$1",
113  array($this->import_file->id));
114  }
global $cn
Redirect to CSV or other format.
Impacc_File::result ( )

Display the rows of the imported file and a status for each row.

Definition at line 143 of file class_impacc_file.php.

144  {
145  if ($this->import_file->i_type=='CSV')
146  {
147  $operation=new Impacc_CSV();
148  $operation->result($this);
149  }
150  }
Used by all Import CSV Operation , contains the setting (delimiter,thousand ...)
Impacc_File::result_transfer ( )

Show the result of the file import.

Definition at line 163 of file class_impacc_file.php.

References $cn, and $ledger.

164  {
165  if ($this->import_file->i_type == 'CSV')
166  {
167  $cn=Dossier::connect();
168  // Show first the successfully transfered record
169  // Show the failed
170  $operation=new Impacc_CSV();
171  $operation->load_import($this->import_file->id);
172  // Show the target ledger
173  $ledger=new Acc_Ledger($cn,$operation->detail->jrn_def_id);
174  echo "<h1>";
175  printf(_("Importation dans le journal %s"),$ledger->get_name());
176  echo "</h1>";
177  $operation->result($this);
178  }
179  }
Used by all Import CSV Operation , contains the setting (delimiter,thousand ...)
global $cn
Impacc_File::save_file ( )

Save the uploaded file and CSV setting if it is CSV import.

Definition at line 50 of file class_impacc_file.php.

References $cn, and $format.

51  {
52  if (trim($_FILES['file_operation']['name'])=='')
53  {
54  alert(_('Pas de fichier donnĂ©'));
55  return -1;
56  }
57  $format=HtmlInput::default_value_post("format", -1);
58 
59  if (!isset(self::$aformat[$format]))
60  {
61  alert(_("Format inconnu"));
62  return -1;
63  }
64  $this->format=self::$aformat[$format];
65  $this->filename=tempnam($_ENV['TMP'], 'upload_');
66  if (!move_uploaded_file($_FILES["file_operation"]["tmp_name"],
67  $this->filename))
68  {
69  throw new Exception(_("Fichier non sauvĂ©"), 1);
70  }
71  $cn=Dossier::connect();
72  $imp=new Impacc_Import_file_SQL($cn);
73  $imp->setp('i_tmpname', $this->filename);
74  $imp->setp('i_filename', $_FILES['file_operation']['name']);
75  $imp->setp("i_type", self::$aformat[$format]);
76  $imp->insert();
77  $cn->exec_sql("update impacc.import_file set i_date_transfer=now() where id=$1",
78  array($imp->id));
79  $this->import_file=$imp;
80  $this->impid=$imp->getp("id");
81 
82  // For CSV only
83  if ($imp->i_type=="CSV")
84  {
85  try
86  {
87  $csv=new Impacc_CSV();
88  $csv->set_import($this->impid);
89  $csv->set_setting();
90  $csv->check_setting();
91  $csv->save_setting();
92  }
93  catch (Exception $ex)
94  {
95  error_log($ex->getTraceAsString());
96  echo _("Format invalide")," : ",$ex->getMessage();
97  }
98  }
99  }
Used by all Import CSV Operation , contains the setting (delimiter,thousand ...)
global $cn
Impacc_File::transfer ( )

Transfer to accountancy.

Definition at line 152 of file class_impacc_file.php.

153  {
154  if ($this->import_file->i_type=='CSV')
155  {
156  $operation=new Impacc_CSV();
157  $operation->load_import($this->impid);
158  $operation->transfer();
159  }
160  }
Used by all Import CSV Operation , contains the setting (delimiter,thousand ...)

Field Documentation

Impacc_File::$aformat =array(1=>"CSV")
static

Definition at line 43 of file class_impacc_file.php.

Impacc_File::$filename

Definition at line 45 of file class_impacc_file.php.

Impacc_File::$format

Definition at line 44 of file class_impacc_file.php.

Referenced by input_file(), and save_file().

Impacc_File::$import_file

Impacc_Import_file_SQL $impid.

Definition at line 46 of file class_impacc_file.php.


The documentation for this class was generated from the following file: