fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [16880] property_soreport:formatting code


From: sigurdne
Subject: [Fmsystem-commits] [16880] property_soreport:formatting code
Date: Wed, 28 Jun 2017 06:23:48 -0400 (EDT)

Revision: 16880
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=16880
Author:   sigurdne
Date:     2017-06-28 06:23:48 -0400 (Wed, 28 Jun 2017)
Log Message:
-----------
property_soreport:formatting code

Modified Paths:
--------------
    trunk/phpgwapi/inc/accounts/class.accounts_sql.inc.php
    trunk/property/inc/class.sodocument.inc.php
    trunk/property/inc/class.soreport.inc.php

Modified: trunk/phpgwapi/inc/accounts/class.accounts_sql.inc.php
===================================================================
--- trunk/phpgwapi/inc/accounts/class.accounts_sql.inc.php      2017-06-27 
13:33:09 UTC (rev 16879)
+++ trunk/phpgwapi/inc/accounts/class.accounts_sql.inc.php      2017-06-28 
10:23:48 UTC (rev 16880)
@@ -503,7 +503,8 @@
 
                                        if(strpos($query, ',' ))
                                        {
-                                               $whereclause .= 
"account_lastname || ', ' || account_firstname $this->like '$query%')";
+                                               $whereclause .= 
"account_lastname || ', ' || account_firstname $this->like '$query%'"
+                                                       . " OR account_lastname 
|| ',' || account_firstname $this->like '$query%')";
                                        }
                                        else
                                        {

Modified: trunk/property/inc/class.sodocument.inc.php
===================================================================
--- trunk/property/inc/class.sodocument.inc.php 2017-06-27 13:33:09 UTC (rev 
16879)
+++ trunk/property/inc/class.sodocument.inc.php 2017-06-28 10:23:48 UTC (rev 
16880)
@@ -199,6 +199,12 @@
                                $this->bocommon->fm_cache('sql_document_' . 
$entity_id, $sql);
 
                                $this->uicols = $this->bocommon->uicols;
+
+                               $this->uicols['input_type'][] = 'text';
+                               $this->uicols['name'][] = 'doc_type';
+                               $this->uicols['descr'][] = lang('category');
+                               $this->uicols['statustext'][] = 
lang('category');
+
                                $cols_return = $this->bocommon->cols_return;
                                $type_id = $this->bocommon->type_id;
                                $this->cols_extra = $this->bocommon->cols_extra;
@@ -388,7 +394,7 @@
                                        . " $this->like '%$query%')";
                        }
 
-                       $sql = "SELECT fm_document.*, phpgw_categories.cat_name 
as category FROM fm_document"
+                       $sql = "SELECT DISTINCT fm_document.*, 
phpgw_categories.cat_name as category FROM fm_document"
                                . " $this->join phpgw_categories on 
fm_document.category = phpgw_categories.cat_id"
                                . " $filtermethod $querymethod";
 

Modified: trunk/property/inc/class.soreport.inc.php
===================================================================
--- trunk/property/inc/class.soreport.inc.php   2017-06-27 13:33:09 UTC (rev 
16879)
+++ trunk/property/inc/class.soreport.inc.php   2017-06-28 10:23:48 UTC (rev 
16880)
@@ -1,4 +1,5 @@
 <?php
+
        /**
         * phpGroupWare - property: a part of a Facilities Management System.
         *
@@ -26,8 +27,7 @@
         * @subpackage logistic
         * @version $Id: class.soreport.inc.php 14913 2016-04-27 12:27:37Z 
sigurdne $
         */
-
-       class property_soreport 
+       class property_soreport
        {
 
                function __construct()
@@ -35,35 +35,35 @@
                        $this->db = & $GLOBALS['phpgw']->db;
                        $this->join = & $this->db->join;
                        $this->left_join = & $this->db->left_join;
-                       $this->like = & $this->db->like;                
+                       $this->like = & $this->db->like;
                        $this->total_records = 0;
-                                       
+
                        $this->operators_equal = array(
-                               'equal' => '=', 
-                               'not_equal' => '!=', 
-                               'less' => '<', 
-                               'less_equal' => '<=', 
-                               'greater' => '>', 
+                               'equal' => '=',
+                               'not_equal' => '!=',
+                               'less' => '<',
+                               'less_equal' => '<=',
+                               'greater' => '>',
                                'greater_equal' => '>='
                        );
                        $this->operators_like = array(
-                               'like' => 'LIKE', 
-                               'not_like' => 'NOT LIKE', 
-                               'ilike' => 'ILIKE', 
+                               'like' => 'LIKE',
+                               'not_like' => 'NOT LIKE',
+                               'ilike' => 'ILIKE',
                                'not_ilike' => 'NOT ILIKE'
                        );
                        $this->operators_in = array(
-                               'in' => 'IN', 
+                               'in' => 'IN',
                                'not_in' => 'NOT IN'
                        );
                        $this->operators_null = array(
-                               'is_null' => 'IS NULL', 
+                               'is_null' => 'IS NULL',
                                'is_not_null' => 'IS NOT NULL'
                        );
                        $this->operators = array_merge($this->operators_equal, 
$this->operators_like, $this->operators_in, $this->operators_null);
                }
 
-               function read_single ( $id, $values = array() )
+               function read_single( $id, $values = array() )
                {
                        $id = (int)$id;
                        $sql = "SELECT * FROM fm_view_dataset_report WHERE id = 
{$id}";
@@ -84,8 +84,8 @@
 
                        return $values;
                }
-               
-               public function read($data)
+
+               public function read( $data )
                {
                        $start = isset($data['start']) && $data['start'] ? 
$data['start'] : 0;
                        $query = isset($data['query']) ? $data['query'] : '';
@@ -94,7 +94,7 @@
                        $allrows = isset($data['allrows']) ? $data['allrows'] : 
'';
                        $dataset_id = isset($data['dataset_id']) ? 
$data['dataset_id'] : '';
                        $results = isset($data['results']) && $data['results'] 
? (int)$data['results'] : 0;
-                       
+
                        if ($order)
                        {
                                $ordermethod = " ORDER BY $order $sort";
@@ -149,7 +149,7 @@
 
                        return $values;
                }
-               
+
                public function get_views()
                {
                        $sql = "SELECT table_name as name
@@ -156,7 +156,7 @@
                                        FROM information_schema.tables
                                        WHERE table_schema = current_schema()
                                        AND table_type = 'VIEW'";
-       
+
                        $this->db->query($sql, __LINE__, __FILE__);
 
                        $values = array();
@@ -168,14 +168,14 @@
                                        'name' => $this->db->f('name')
                                );
                        }
-                       
+
                        return $values;
                }
-               
+
                public function get_datasets()
                {
                        $sql = "SELECT * FROM fm_view_dataset";
-       
+
                        $this->db->query($sql, __LINE__, __FILE__);
 
                        $values = array();
@@ -188,23 +188,23 @@
                                        'name' => $this->db->f('dataset_name')
                                );
                        }
-                       
+
                        return $values;
                }
-               
-               public function get_view_columns($id)
+
+               public function get_view_columns( $id )
                {
                        $dataset = $this->read_single_dataset($id);
-                       
+
                        $sql = "SELECT column_name, data_type
                                FROM   information_schema.columns
-                               WHERE  table_name = '".$dataset['view_name']."'
+                               WHERE  table_name = '" . $dataset['view_name'] 
. "'
                                ORDER  BY ordinal_position";
-       
+
                        $this->db->query($sql, __LINE__, __FILE__);
 
                        $values = array();
-                       
+
                        while ($this->db->next_record())
                        {
                                $values[] = array
@@ -213,32 +213,32 @@
                                        'type' => $this->db->f('data_type')
                                );
                        }
-                       
+
                        return $values;
                }
-               
-               function get_view_content ( $id )
+
+               function get_view_content( $id )
                {
                        $id = (int)$id;
 
                        $dataset = $this->read_single_dataset($id);
-                       
+
                        $sql = "SELECT column_name, data_type
                                FROM   information_schema.columns
-                               WHERE  table_name = '".$dataset['view_name']."'
+                               WHERE  table_name = '" . $dataset['view_name'] 
. "'
                                ORDER  BY ordinal_position";
                        $this->db->query($sql, __LINE__, __FILE__);
 
                        $columns = array();
-                       
+
                        while ($this->db->next_record())
                        {
                                $columns[] = $this->db->f('column_name');
                        }
-                       
-                       $sql = "SELECT * FROM ".$dataset['view_name'];
+
+                       $sql = "SELECT * FROM " . $dataset['view_name'];
                        $this->db->limit_query($sql, 0, __LINE__, __FILE__, 20);
-                       
+
                        $values = array();
                        while ($this->db->next_record())
                        {
@@ -249,37 +249,42 @@
                                }
                                $values[] = $value;
                        }
-                       
+
                        return $values;
                }
-               
-               private function _is_date( $str ) {
-                       try {
-                               $dt = new DateTime( trim($str) );
+
+               private function _is_date( $str )
+               {
+                       try
+                       {
+                               $dt = new DateTime(trim($str));
                        }
-                       catch( Exception $e ) {
+                       catch (Exception $e)
+                       {
                                return false;
                        }
                        $month = $dt->format('m');
                        $day = $dt->format('d');
                        $year = $dt->format('Y');
-                       if( checkdate($month, $day, $year) ) {
+                       if (checkdate($month, $day, $year))
+                       {
                                return true;
                        }
-                       else {
+                       else
+                       {
                                return false;
                        }
                }
 
-               private function _build_conditions_equal($param, $type)
-               {               
+               private function _build_conditions_equal( $param, $type )
+               {
                        $result = '';
-                       
-                       switch ($type) 
+
+                       switch ($type)
                        {
                                case 'character varying':
                                case 'text':
-                                       $result = $param['field']." 
".$this->operators[$param['operator']]." '".$param['value1']."'";
+                                       $result = $param['field'] . " " . 
$this->operators[$param['operator']] . " '" . $param['value1'] . "'";
                                        break;
                                case 'integer':
                                case 'smallint':
@@ -286,7 +291,7 @@
                                case 'numeric':
                                        if (is_numeric($param['value1']))
                                        {
-                                               $result = $param['field']." 
".$this->operators[$param['operator']]." ".$param['value1'];
+                                               $result = $param['field'] . " " 
. $this->operators[$param['operator']] . " " . $param['value1'];
                                        }
                                        break;
                                case 'date':
@@ -293,14 +298,14 @@
                                case 'timestamp without time zone':
                                        if ($this->_is_date($param['value1']))
                                        {
-                                               $result = $param['field']." 
".$this->operators[$param['operator']]." '".$param['value1']."'";
+                                               $result = $param['field'] . " " 
. $this->operators[$param['operator']] . " '" . $param['value1'] . "'";
                                        }
-                       }                               
-               
+                       }
+
                        return $result;
                }
-               
-               private function _build_conditions($criteria, $id)
+
+               private function _build_conditions( $criteria, $id )
                {
                        $columns = $this->get_view_columns($id);
                        $_columns = array();
@@ -308,46 +313,46 @@
                        {
                                $_columns[$column['name']] = $column['type'];
                        }
-                       
+
                        $n = 1;
                        $where = array();
                        foreach ($criteria as $param)
                        {
-                               switch (true) 
+                               switch (true)
                                {
                                        case 
(array_key_exists($param['operator'], $this->operators_equal)):
-                                               $result =  
$this->_build_conditions_equal($param, $_columns[$param['field']]);
+                                               $result = 
$this->_build_conditions_equal($param, $_columns[$param['field']]);
                                                break;
                                        case 
(array_key_exists($param['operator'], $this->operators_like)):
                                                if ($param['value1'] != '')
                                                {
-                                                       $result =  
$param['field']."::text ".$this->operators[$param['operator']]." 
'%".$param['value1']."%'";                                                  
+                                                       $result = 
$param['field'] . "::text " . $this->operators[$param['operator']] . " '%" . 
$param['value1'] . "%'";
                                                }
                                                break;
                                        case 
(array_key_exists($param['operator'], $this->operators_null)):
-                                               $result =  $param['field']." 
".$this->operators[$param['operator']];
+                                               $result = $param['field'] . " " 
. $this->operators[$param['operator']];
                                                break;
                                        case 
(array_key_exists($param['operator'], $this->operators_in)):
                                                if ($param['value1'] != '')
                                                {
                                                        $values = 
array_map('trim', explode(',', $param['value1']));
-                                                       $_string = 
"'".implode("','", $values)."'";
-                                                       $result =  
$param['field']."::text ".$this->operators[$param['operator']]." 
(".$_string.")";
+                                                       $_string = "'" . 
implode("','", $values) . "'";
+                                                       $result = 
$param['field'] . "::text " . $this->operators[$param['operator']] . " (" . 
$_string . ")";
                                                }
                                                break;
                                }
-                               
+
                                if ($result)
                                {
-                                       $where[] = $result." 
".$param['conector'];                              
+                                       $where[] = $result . " " . 
$param['conector'];
                                }
                                $n++;
                        }
-                       
+
                        return $where;
                }
-               
-               function read_to_export ( $id, $data = array() )
+
+               function read_to_export( $id, $data = array() )
                {
                        $id = (int)$id;
 
@@ -356,44 +361,47 @@
                                $dataset = $this->read_single_dataset($id);
                                $jsonB = $data;
                        }
-                       else {
+                       else
+                       {
                                $definition = $this->read_single($id);
-                               $dataset = 
$this->read_single_dataset($definition['dataset_id']);                          
     
+                               $dataset = 
$this->read_single_dataset($definition['dataset_id']);
                                $jsonB = 
json_decode($definition['report_definition'], true);
                        }
 
                        $string_columns = implode(',', $jsonB['columns']);
-                       
+
                        $array_order = array();
                        $group = implode(',', $jsonB['group']);
                        if ($group)
                        {
-                               $array_order[] = $group.' ASC';
+                               $array_order[] = $group . ' ASC';
                        }
                        $order = implode(',', $jsonB['order']);
                        if ($order)
                        {
-                               $array_order[] = $order.' ASC';
+                               $array_order[] = $order . ' ASC';
                        }
-                       
+
                        if (count($array_order))
                        {
-                               $ordering = 'ORDER BY '.implode(', ', 
array_unique($array_order));
+                               $ordering = 'ORDER BY ' . implode(', ', 
array_unique($array_order));
                        }
-       
+
                        $cond = $this->_build_conditions($jsonB['criteria'], 
$id);
-                       
+
                        if ($cond)
                        {
-                               $where = 'WHERE '.implode(' ', $cond);
+                               $where = 'WHERE ' . implode(' ', $cond);
                        }
-                       
-                       $sql = "SELECT ".$string_columns." FROM 
".$dataset['view_name']." ".$where." ".$ordering;
 
+                       $sql = "SELECT " . $string_columns . " FROM " . 
$dataset['view_name'] . " " . $where . " " . $ordering;
+
                        if (count($data))
                        {
                                $this->db->limit_query($sql, 0, __LINE__, 
__FILE__, 20);
-                       } else {
+                       }
+                       else
+                       {
                                $this->db->query($sql, __LINE__, __FILE__);
                        }
 
@@ -400,21 +408,21 @@
                        $columns = array_values($jsonB['columns']);
                        array_unshift($columns, "");
                        $functions = $jsonB['cbo_aggregate'];
-               
+
                        $values = array();
                        $array_sum = array();
                        $array_count = array();
-                       
+
                        while ($this->db->next_record())
                        {
                                $_group = ($group) ? $this->db->f($group) : 
'any_group';
-                               
+
                                $value = array();
                                foreach ($columns as $column)
                                {
                                        $value[$column] = $this->db->f($column);
                                }
-                               
+
                                foreach ($functions as $k => $v)
                                {
                                        if ($v == 'sum')
@@ -426,8 +434,8 @@
                                                $array_count[$_group][$k][] = 
$this->db->f($k);
                                        }
                                }
-                               
-                               $values[$_group][] = $value;                    
        
+
+                               $values[$_group][] = $value;
                        }
 
                        if (count($values))
@@ -434,25 +442,25 @@
                        {
                                $result = $this->_generate_total_sum($values, 
$array_sum, $array_count);
                        }
-                       
+
                        return $result;
                }
-               
-               private function _generate_total_sum($values, $array_sum, 
$array_count)
-               {               
+
+               private function _generate_total_sum( $values, $array_sum, 
$array_count )
+               {
                        $result = array();
                        $array_operations = array();
-                       
+
                        foreach ($values as $k => $group)
                        {
                                $columns = array_keys($group[0]);
-                               
+
                                $operations = array();
                                $empty = array();
                                foreach ($columns as $columm)
                                {
                                        $empty[$columm] = $operations[$columm] 
= '';
-                                       
+
                                        if (is_array($array_sum[$k][$columm]))
                                        {
                                                $operations[$columm] = 
array_sum($array_sum[$k][$columm]);
@@ -464,19 +472,19 @@
                                        if ($columm == '')
                                        {
                                                $operations[$columm] = 
lang('Total');
-                                       }                                       
-                               }       
-                               
+                                       }
+                               }
+
                                $array_operations[] = $operations;
                                if ($k != 'any_group')
                                {
-                                       $group[] =  $operations;
+                                       $group[] = $operations;
                                }
-                               $group[] =  $empty;
-                               
+                               $group[] = $empty;
+
                                $result = array_merge($result, $group);
-                       }       
-                       
+                       }
+
                        $grand_total = array();
                        $columns = array_keys($array_operations[0]);
                        foreach ($array_operations as $value)
@@ -486,20 +494,20 @@
                                        if ($columm == '')
                                        {
                                                $grand_total[$columm] = 
lang('Grand Total');
-                                       }  
-                                       else 
-                                       { 
+                                       }
+                                       else
+                                       {
                                                $grand_total[$columm] = 
($grand_total[$columm] + $value[$columm]) ? ($grand_total[$columm] + 
$value[$columm]) : '';
                                        }
-                               }                               
+                               }
                        }
-                       
+
                        $result[] = $grand_total;
-                       
+
                        return $result;
                }
-               
-               function read_single_dataset ( $id, $values = array() )
+
+               function read_single_dataset( $id, $values = array() )
                {
                        $id = (int)$id;
                        $sql = "SELECT * FROM fm_view_dataset WHERE id = {$id}";
@@ -519,8 +527,8 @@
 
                        return $values;
                }
-               
-               function read_dataset ( $data )
+
+               function read_dataset( $data )
                {
                        $start = isset($data['start']) && $data['start'] ? 
$data['start'] : 0;
                        $query = isset($data['query']) ? $data['query'] : '';
@@ -528,7 +536,7 @@
                        $order = isset($data['order']) ? $data['order'] : '';
                        $allrows = isset($data['allrows']) ? $data['allrows'] : 
'';
                        $results = isset($data['results']) && $data['results'] 
? (int)$data['results'] : 0;
-                       
+
                        if ($order)
                        {
                                $ordermethod = " ORDER BY $order $sort";
@@ -540,11 +548,11 @@
 
                        $where = 'HAVING';
 
-                       /*if ($dimb_id > 0)
-                       {
-                               $filtermethod .= " $where 
fm_budget.ecodimb={$dimb_id}";
-                               $where = 'AND';
-                       }*/
+                       /* if ($dimb_id > 0)
+                         {
+                         $filtermethod .= " $where 
fm_budget.ecodimb={$dimb_id}";
+                         $where = 'AND';
+                         } */
 
                        if ($query)
                        {
@@ -585,8 +593,8 @@
 
                        return $values;
                }
-               
-               function add ( $data )
+
+               function add( $data )
                {
                        $receipt = array();
                        $values_insert = array
@@ -597,12 +605,12 @@
                                'owner_id' => 
$GLOBALS['phpgw_info']['user']['account_id'],
                                'entry_date' => time()
                        );
-                       
+
                        $this->db->transaction_begin();
 
                        $this->db->query("INSERT INTO fm_view_dataset_report (" 
. implode(',', array_keys($values_insert)) . ') VALUES ('
-                                       . 
$this->db->validate_insert(array_values($values_insert)) . ')', __LINE__, 
__FILE__);
-                       
+                               . 
$this->db->validate_insert(array_values($values_insert)) . ')', __LINE__, 
__FILE__);
+
                        if ($this->db->transaction_commit())
                        {
                                $receipt['message'][] = array('msg' => 
lang('dataset has been saved'));
@@ -612,11 +620,11 @@
                        {
                                $receipt['error'][] = array('msg' => 
lang('dataset has not been saved'));
                        }
-                       
+
                        return $receipt;
                }
 
-               function update ( $data )
+               function update( $data )
                {
                        $receipt = array();
 
@@ -632,7 +640,7 @@
                        $value_set = $this->db->validate_update($value_set);
 
                        $this->db->transaction_begin();
-                       
+
                        $this->db->query("UPDATE fm_view_dataset_report SET 
{$value_set} WHERE id='" . $data['id'] . "'", __LINE__, __FILE__);
 
                        $receipt['id'] = $data['id'];
@@ -644,17 +652,17 @@
                        {
                                $receipt['error'][] = array('msg' => 
lang('dataset has not been updated'));
                        }
-                       
+
                        return $receipt;
                }
-               
-               function delete ( $id )
+
+               function delete( $id )
                {
                        $id = (int)$id;
                        $receipt = array();
 
                        $this->db->transaction_begin();
-                       
+
                        //$this->db->query("DELETE FROM fm_view_dataset WHERE 
id ='{$id}'", __LINE__, __FILE__);
                        $this->db->query("DELETE FROM fm_view_dataset_report 
WHERE id ='{$id}'", __LINE__, __FILE__);
 
@@ -666,11 +674,11 @@
                        {
                                $receipt['error'][] = array('msg' => 
lang('report has not been deleted'));
                        }
-                       
+
                        return $receipt;
-               }       
-               
-               function add_dataset ( $data )
+               }
+
+               function add_dataset( $data )
                {
                        $receipt = array();
                        $values_insert = array
@@ -680,12 +688,12 @@
                                'owner_id' => 
$GLOBALS['phpgw_info']['user']['account_id'],
                                'entry_date' => time()
                        );
-                       
+
                        $this->db->transaction_begin();
 
                        $this->db->query("INSERT INTO fm_view_dataset (" . 
implode(',', array_keys($values_insert)) . ') VALUES ('
-                                       . 
$this->db->validate_insert(array_values($values_insert)) . ')', __LINE__, 
__FILE__);
-                       
+                               . 
$this->db->validate_insert(array_values($values_insert)) . ')', __LINE__, 
__FILE__);
+
                        if ($this->db->transaction_commit())
                        {
                                $receipt['message'][] = array('msg' => 
lang('dataset has been saved'));
@@ -695,11 +703,11 @@
                        {
                                $receipt['error'][] = array('msg' => 
lang('dataset has not been saved'));
                        }
-                       
+
                        return $receipt;
                }
 
-               function update_dataset ( $data )
+               function update_dataset( $data )
                {
                        $receipt = array();
 
@@ -714,7 +722,7 @@
                        $value_set = $this->db->validate_update($value_set);
 
                        $this->db->transaction_begin();
-                       
+
                        $this->db->query("UPDATE fm_view_dataset SET 
{$value_set} WHERE id='" . $data['id'] . "'", __LINE__, __FILE__);
 
                        $receipt['id'] = $data['id'];
@@ -726,17 +734,17 @@
                        {
                                $receipt['error'][] = array('msg' => 
lang('dataset has not been updated'));
                        }
-                       
+
                        return $receipt;
                }
-               
-               function delete_dataset ( $id )
+
+               function delete_dataset( $id )
                {
                        $id = (int)$id;
                        $receipt = array();
 
                        $this->db->transaction_begin();
-                       
+
                        $this->db->query("DELETE FROM fm_view_dataset_report 
WHERE dataset_id ='{$id}'", __LINE__, __FILE__);
                        $this->db->query("DELETE FROM fm_view_dataset WHERE id 
='{$id}'", __LINE__, __FILE__);
 
@@ -748,8 +756,7 @@
                        {
                                $receipt['error'][] = array('msg' => 
lang('dataset has not been deleted'));
                        }
-                       
+
                        return $receipt;
-               }               
-               
+               }
        }
\ No newline at end of file




reply via email to

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