fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [11469] generic import


From: Sigurd Nes
Subject: [Fmsystem-commits] [11469] generic import
Date: Sun, 17 Nov 2013 16:29:59 +0000

Revision: 11469
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11469
Author:   sigurdne
Date:     2013-11-17 16:29:55 +0000 (Sun, 17 Nov 2013)
Log Message:
-----------
generic import

Modified Paths:
--------------
    trunk/property/inc/class.bocommon.inc.php
    trunk/property/inc/class.soentity.inc.php
    trunk/property/inc/class.uiimport.inc.php

Modified: trunk/property/inc/class.bocommon.inc.php
===================================================================
--- trunk/property/inc/class.bocommon.inc.php   2013-11-16 18:18:26 UTC (rev 
11468)
+++ trunk/property/inc/class.bocommon.inc.php   2013-11-17 16:29:55 UTC (rev 
11469)
@@ -1572,11 +1572,18 @@
 
                        $count_uicols_name=count($name);
 
+                       $text_format = array();
                        $m=0;
                        for ($k=0;$k<$count_uicols_name;$k++)
                        {
                                if(!isset($input_type[$k]) || 
$input_type[$k]!='hidden')
                                {
+                                       if(preg_match('/^loc/i', $name[$k]))
+                                       {
+                                               $text_format[$m] = true;
+                                               
//$objPHPExcel->getActiveSheet()->getStyle('B3:B7')->applyFromArray($styleArray);
+
+                                       }
                                        
$objPHPExcel->setActiveSheetIndex(0)->setCellValueByColumnAndRow($m, 1, 
$descr[$k]);
                                        $m++;
                                }
@@ -1608,8 +1615,14 @@
                                        $rows = count($row);
                                        for ($i=0; $i < $rows; $i++)
                                        {
-                                               
$objPHPExcel->setActiveSheetIndex(0)->setCellValueByColumnAndRow($i, $line, 
$row[$i]);
-                                       //      
$objPHPExcel->setActiveSheetIndex(0)->setCellValue($col . $i,  $row[$i] );
+                                               if(isset($text_format[$i]))
+                                               {
+                                                       
$objPHPExcel->setActiveSheetIndex(0)->setCellValueExplicitByColumnAndRow($i, 
$line, $row[$i], PHPExcel_Cell_DataType::TYPE_STRING);
+                                               }
+                                               else
+                                               {
+                                                       
$objPHPExcel->setActiveSheetIndex(0)->setCellValueByColumnAndRow($i, $line, 
$row[$i]);
+                                               }
                                        }
                                        $col++;
                                }

Modified: trunk/property/inc/class.soentity.inc.php
===================================================================
--- trunk/property/inc/class.soentity.inc.php   2013-11-16 18:18:26 UTC (rev 
11468)
+++ trunk/property/inc/class.soentity.inc.php   2013-11-17 16:29:55 UTC (rev 
11469)
@@ -1645,7 +1645,7 @@
                                $values['user_id']                      = 
$this->db->f('user_id');
                                $values['entry_date']           = 
$this->db->f('entry_date');
 
-                               $xmldata = $this->db->f('xml_representation');
+                               $xmldata = 
$this->db->f('xml_representation',true);
                                $xml = new DOMDocument('1.0', 'utf-8');
                                $xml->loadXML($xmldata);
 

Modified: trunk/property/inc/class.uiimport.inc.php
===================================================================
--- trunk/property/inc/class.uiimport.inc.php   2013-11-16 18:18:26 UTC (rev 
11468)
+++ trunk/property/inc/class.uiimport.inc.php   2013-11-17 16:29:55 UTC (rev 
11469)
@@ -33,6 +33,13 @@
 
                protected $defalt_values;
 
+
+               private $valid_tables = array
+                               (
+                                       'fm_vendor',
+                                       'fm_condition_survey'
+                               );
+
                public function __construct()
                {
                        if ( !$GLOBALS['phpgw']->acl->check('run', 
phpgwapi_acl::READ, 'admin')
@@ -47,6 +54,11 @@
                        $this->account          = 
(int)$GLOBALS['phpgw_info']['user']['account_id'];
                        $this->db           = & $GLOBALS['phpgw']->db;
                        $this->table            = phpgw::get_var('table');
+                       
+                       if($this->table && !in_array($this->table, 
$this->valid_tables))
+                       {
+                               throw new Exception("Not a valid table: 
{$this->table}");                       
+                       }
                }
 
 
@@ -247,12 +259,8 @@
 HTML;
                                }
 
-               //              $tables = $this->db->table_names();
-                               $tables = array
-                               (
-                                       'fm_vendor',
-                                       'fm_condition_survey'
-                               );
+                               $tables = $this->valid_tables;
+
                                sort($tables);
 
                                $table_option = '<option value="">' . 
lang('none selected') . '</option>' . "\n";
@@ -363,6 +371,7 @@
 
                protected function get_template($location_id = 0)
                {
+                       $data = array();
                        $_fields = array();
                        if(!$location_id && $this->table)
                        {
@@ -373,6 +382,14 @@
                                        $_fields[$field] = true;
                                }
 
+                               $sql = "SELECT * FROM {$this->table}";
+                               $this->db->query($sql,__LINE__,__FILE__);
+
+                               while ($this->db->next_record())
+                               {
+                                       $data[] = $this->db->Record;
+                               }
+
                        }
                        else if($location_id && !$category = 
execMethod('property.soadmin_entity.get_single_category', $location_id ))
                        {
@@ -401,6 +418,30 @@
                                        $custom                 = 
createObject('property.custom_fields');
                                        $attributes     = 
$custom->find2($location_id, 0, '', 'ASC', 'attrib_sort', true, true);
 
+
+                                       $sql = "SELECT * FROM {$this->table} 
WHERE location_id = $location_id";
+                                       
$this->db->query($sql,__LINE__,__FILE__);
+
+                                       while ($this->db->next_record())
+                                       {
+                                               $_row_data = array();
+                                               foreach ($_fields as $_field => 
$dummy)
+                                               {
+                                                       $_row_data[$_field] = 
$this->db->f($_field,true);
+                                               }
+
+                                               $xmldata = 
$this->db->f('xml_representation',true);
+                                               $xml = new DOMDocument('1.0', 
'utf-8');
+                                               $xml->loadXML($xmldata);
+
+                                               foreach($attributes as 
$attribute)
+                                               {
+                                                       
$_row_data[$attribute['column_name']]   = 
$xml->getElementsByTagName($attribute['column_name'])->item(0)->nodeValue;
+                                               }
+
+                                               $data[] = $_row_data;
+                                       }
+
                                        foreach($attributes as $attribute)
                                        {
                                                
$_fields[$attribute['column_name']] = true;
@@ -414,6 +455,14 @@
                                        {
                                                $_fields[$field] = true;
                                        }
+
+                                       $sql = "SELECT * FROM {$this->table}";
+                                       
$this->db->query($sql,__LINE__,__FILE__);
+
+                                       while ($this->db->next_record())
+                                       {
+                                               $data[] = $this->db->Record;
+                                       }
                                }
                        }
 
@@ -426,7 +475,7 @@
                        else
                        {
                                $bocommon = CreateObject('property.bocommon');
-                               $bocommon->download(array(),$fields,$fields);
+                               $bocommon->download($data, $fields, $fields);
                                $GLOBALS['phpgw']->common->phpgw_exit();
                        }
                }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]