[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [7455] property: more on import
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [7455] property: more on import |
Date: |
Thu, 30 Jun 2011 08:35:07 +0000 |
Revision: 7455
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=7455
Author: sigurdne
Date: 2011-06-30 08:35:07 +0000 (Thu, 30 Jun 2011)
Log Message:
-----------
property: more on import
Modified Paths:
--------------
trunk/property/inc/class.uiimport.inc.php
trunk/property/inc/import/default/cvs_oppdater_rental_party_bkb
Modified: trunk/property/inc/class.uiimport.inc.php
===================================================================
--- trunk/property/inc/class.uiimport.inc.php 2011-06-30 06:35:47 UTC (rev
7454)
+++ trunk/property/inc/class.uiimport.inc.php 2011-06-30 08:35:07 UTC (rev
7455)
@@ -22,6 +22,8 @@
protected $account;
protected $conv_type;
protected $import_conversion;
+ protected $steps = 0;
+ protected $fields = array();
// Label on the import button. Changes as we step through the
import process.
protected $import_button_label;
@@ -57,17 +59,16 @@
// If the parameter 'importsubmit' exist (submit button
in import form), set path
if (phpgw::get_var("importsubmit"))
{
-
- if($GLOBALS['phpgw']->session->is_repost())
+ if($GLOBALS['phpgw']->session->is_repost() &&
!phpgw::get_var('debug', 'bool'))
{
echo('Hmm... looks like a repost!');
$action =
$GLOBALS['phpgw']->link('/index.php',
array('menuaction'=>'property.uiimport.index'));
echo "<br><a href= '$action'>Start
over</a>" ;
$GLOBALS['phpgw']->common->phpgw_exit();
+
}
-
$this->conv_type =
phpgw::get_var('conv_type');
$start_time = time(); // Start time of import
@@ -117,11 +118,12 @@
switch ($file['type'])
{
case 'application/vnd.ms-excel':
- $this->csvdata =
$this->getexceldata($this->file);
+ $this->csvdata =
$this->getexceldata($file['name']);
$valid_type = true;
break;
case 'text/csv':
- $this->csvdata =
$this->getcsvdata($this->file);
+ case
'text/comma-separated-values':
+ $this->csvdata =
$this->getcsvdata($file['name']);
$valid_type = true;
break;
}
@@ -129,6 +131,9 @@
if($valid_type)
{
$result = $this->import();
+ $this->messages =
array_merge($this->messages,$this->import_conversion->messages);
+ $this->warnings =
array_merge($this->warnings,$this->import_conversion->warnings);
+ $this->errors =
array_merge($this->errors,$this->import_conversion->errors);
$this->csvdata = array();
echo '<li class="info">Import:
finished step ' .$result. '</li>';
}
@@ -141,10 +146,6 @@
$end = date("G:i:s",$end_time);
echo "<h3>Import ended at: {$end}. Import
lasted {$difference} minutes.";
- $this->messages =
array_merge($this->messages,$this->import_conversion->messages);
- $this->warnings =
array_merge($this->warnings,$this->import_conversion->warnings);
- $this->errors =
array_merge($this->errors,$this->import_conversion->errors);
-
if ($this->errors)
{
echo "<ul>";
@@ -230,7 +231,7 @@
*/
public function import()
{
- $steps = 1;
+ $this->steps++;
/* Import logic:
*
@@ -240,26 +241,20 @@
* 4. Log messages for this step
*
*/
-
- $this->messages = array();
- $this->warnings = array();
- $this->errors = array();
$this->import_data();
- $this->log_messages(1);
- return '1';
+ $this->log_messages($this->steps);
+ return $this->steps;
}
protected function import_data()
{
+ $this->import_conversion->fields = $this->fields;
+
$start_time = time();
$datalines = $this->csvdata;
- $this->messages[] = "Read 'import_all.csv' file in " .
(time() - $start_time) . " seconds";
- $this->messages[] = "'importfile.csv' contained " .
count($datalines) . " lines";
-
-
$ok = true;
$_ok = false;
$this->db->transaction_begin();
@@ -296,7 +291,7 @@
if ($skipfirstline)
{
// Read the first line to get the headers out
of the way
- $this->getcsv($handle);
+ $this->fields = $this->getcsv($handle);
}
$result = array();
@@ -308,6 +303,9 @@
fclose($handle);
+ $this->messages[] = "Read '{$path}' file in " . (time()
- $start_time) . " seconds";
+ $this->messages[] = "'{$path}' contained " .
count($result) . " lines";
+
return $result;
}
@@ -320,6 +318,11 @@
$start = $skipfirstline ? 2 : 1; // Read the first line
to get the headers out of the way
+ if ($skipfirstline)
+ {
+ $this->fields = $data->sheets[0]['cells'][1];
+ }
+
$rows = $data->sheets[0]['numRows']+1;
for ($i=$start; $i<$rows; $i++ ) //First data entry on
row 2
@@ -331,6 +334,9 @@
$result[] =
array_values($data->sheets[0]['cells'][$i]);
}
+ $this->messages[] = "Read '{$path}' file in " . (time()
- $start_time) . " seconds";
+ $this->messages[] = "'{$path}' contained " .
count($result) . " lines";
+
return $result;
}
@@ -437,6 +443,4 @@
return $file_list;
}
-
-
}
Modified: trunk/property/inc/import/default/cvs_oppdater_rental_party_bkb
===================================================================
--- trunk/property/inc/import/default/cvs_oppdater_rental_party_bkb
2011-06-30 06:35:47 UTC (rev 7454)
+++ trunk/property/inc/import/default/cvs_oppdater_rental_party_bkb
2011-06-30 08:35:07 UTC (rev 7455)
@@ -6,6 +6,7 @@
public $warnings = array();
public $errors = array();
public $debug = true;
+ public $fields = array();
public function __construct()
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [7455] property: more on import,
Sigurd Nes <=