phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] property/class.someter.php, 1.1.1.3


From: nomail
Subject: [Phpgroupware-cvs] property/class.someter.php, 1.1.1.3
Date: Fri, 21 May 2004 19:21:44 -0000

Update of /property
Modified Files:
        Branch: 
          class.someter.php

date: 2004/04/23 21:26:33;  author: sigurdne;  state: Exp;  lines: +285 -285

Log Message:
no message
=====================================================================
Index: property/class.someter.php
diff -u property/class.someter.php:1.1.1.2 property/class.someter.php:1.1.1.3
--- property/class.someter.php:1.1.1.2  Fri Apr 23 20:25:53 2004
+++ property/class.someter.php  Fri Apr 23 21:26:33 2004
@@ -1,285 +1,285 @@
-<?php
-       
/**************************************************************************\
-       * phpGroupWare - property                                               
   *
-       * http://www.phpgroupware.org                                           
   *
-       *                                                                       
   *
-       * Facilities Management                                                 
   *
-       * Written by Sigurd Nes [sigurdne at online.no]                         
   *
-       * 
------------------------------------------------------------------------ *
-       * Copyright 2000 - 2003 Free Software Foundation, Inc                   
   *
-       * This program is part of the GNU project, see http://www.gnu.org/      
   *
-       * 
------------------------------------------------------------------------ *
-       * This program is free software; you can redistribute it and/or modify 
it  *
-       * under the terms of the GNU General Public License as published by the 
   *
-       * Free Software Foundation; either version 2 of the License, or (at 
your   *
-       * option) any later version.                                            
   *
-       
\**************************************************************************/
-
-       class property_someter
-       {
-
-               function property_someter()
-               {
-                       $this->currentapp       = 'property'; 
//$GLOBALS['phpgw_info']['flags']['currentapp'];
-                       $this->db               = $GLOBALS['phpgw']->db;
-                       $this->db2              = $this->db;
-                       $this->account  = $GLOBALS['phpgw_data']['user']['id'];
-                       $this->bocommon         = 
CreateObject($this->currentapp.'_bocommon');
-                       $this->join                     = $this->bocommon->join;
-               }
-
-               function get_category_list()
-               {
-
-                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT id, 
descr FROM fm_meter_category ORDER BY descr ");
-
-                       $i = 0;
-                       while (!$dbresult->EOF)
-                       {
-                               $categories[$i]['id']                           
= $dbresult->fields['id'];
-                               $categories[$i]['name']                         
= stripslashes($dbresult->fields['descr']);
-                               $i++;
-                               $dbresult->MoveNext();
-
-                       }
-                       return $categories;
-               }
-
-               function check_meter_num($num='')
-               {
-                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT 
count(*) FROM fm_meter where num='$num'");
-
-                       if ( $dbresult->fields[0])
-                       {
-                               return True;
-                       }
-               }
-
-               function read($data)
-               {
-                       if(is_array($data))
-                       {
-                               if ($data['start'])
-                               {
-                                       $start=$data['start'];
-                               }
-                               else
-                               {
-                                       $start=0;
-                               }
-                               $filter = 
(isset($data['filter'])?$data['filter']:'none');
-                               $query = 
(isset($data['query'])?$data['query']:'');
-                               $sort = 
(isset($data['sort'])?$data['sort']:'DESC');
-                               $order = 
(isset($data['order'])?$data['order']:'');
-                               $cat_id = 
(isset($data['cat_id'])?$data['cat_id']:0);
-                       }
-
-
-                       $entity_table = 'fm_meter';
-
-                       $cols .= $entity_table . '.location_code';
-                       $cols_return[] = 'location_code';
-
-                       $cols .= ",$entity_table.id as meter_id";
-                       $cols_return[] = 'meter_id';
-
-                       $cols .= ",$entity_table.num as num";
-                       $cols_return[]                          = 'num';
-                       $uicols['input_type'][]         = 'text';
-                       $uicols['name'][]                       = 'num';
-                       $uicols['descr'][]                      = lang('Meter 
ID');
-                       $uicols['statustext'][]         = lang('Meter ID');
-
-                       $cols .= ",$entity_table.name ";
-                       $cols_return[]                          = 'name';
-                       $uicols['input_type'][]         = 'text';
-                       $uicols['name'][]                       = 'name';
-                       $uicols['descr'][]                      = lang('Name');
-                       $uicols['statustext'][]         = lang('Name');
-
-                       $cols .= ",fm_meter_category.descr as meter_type";
-                       $cols_return[]                          = 'meter_type';
-                       $uicols['input_type'][]         = 'text';
-                       $uicols['name'][]                       = 'meter_type';
-                       $uicols['descr'][]                      = lang('Meter 
Type');
-                       $uicols['statustext'][]         = lang('Meter Type');
-
-
-                       $joinmethod .= " $this->join  fm_meter_category ON 
($entity_table.category = fm_meter_category.id))";
-                       $paranthesis .='(';
-
-
-                       $sql    = 
$this->bocommon->generate_sql(array('entity_table'=>$entity_table,'cols'=>$cols,'cols_return'=>$cols_return,
-                                                                               
                                        
'uicols'=>$uicols,'joinmethod'=>$joinmethod,'paranthesis'=>$paranthesis,'query'=>$query));
-
-
-                       if ($order)
-                       {
-                               $ordermethod = " order by $entity_table.$order 
$sort";
-                       }
-                       else
-                       {
-                               $ordermethod = " order by 
$entity_table.location_code asc";
-                       }
-
-
-                       $where = 'WHERE';
-                       if ($cat_id)
-                       {
-                               $filtermethod .= " $where 
fm_meter.category='$cat_id' ";
-                               $where = 'AND';
-                       }
-
-                       if($query)
-                       {
-                               $query = ereg_replace("'",'',$query);
-                               $query = ereg_replace('"','',$query);
-
-                               $querymethod = " $where (fm_meter.name LIKE 
'%$query%' OR fm_meter.num LIKE '%$query%' OR fm_meter.location_code LIKE 
'%$query%' OR fm_meter.address LIKE '%$query%')";
-                       }
-
-                       $sql .= " $filtermethod $querymethod";
-//echo $sql;
-                       $this->uicols           = $this->bocommon->uicols;
-                       $cols_return            = $this->bocommon->cols_return;
-                       $type_id                        = 
$this->bocommon->type_id;
-                       $this->cols_extra       = $this->bocommon->cols_extra;
-
-                       $dbresult2 = $GLOBALS['phpgw']->db->Execute($sql);
-                       $this->total_records = $dbresult2->_numOfRows;
-                       $maxmatchs = 15;
-                       $dbresult = $GLOBALS['phpgw']->db->SelectLimit($sql . 
$ordermethod,$maxmatchs,$start);
-
-
-                       $j=0;
-                       while (!$dbresult->EOF)
-                       {
-                               for ($i=0;$i<count($cols_return);$i++)
-                               {
-                                       $meter[$j][$cols_return[$i]] = 
$dbresult->fields[$cols_return[$i]];
-                               }
-
-                               $location_code= 
$dbresult->fields['location_code'];
-                               $location = split('-',$location_code);
-                               for ($m=0;$m<count($location);$m++)
-                               {
-                                       $meter[$j]['loc' . ($m+1)] = 
$location[$m];
-                                       $meter[$j]['query_location']['loc' . 
($m+1)]=implode("-", array_slice($location, 0, ($m+1)));
-                               }
-
-                               $j++;
-                               $dbresult->MoveNext();
-                       }
-
-//html_print_r($meter);
-                       return $meter;
-               }
-
-               function read_single($meter_id)
-               {
-                       $sql = "SELECT * FROM fm_meter where id='$meter_id'";
-
-                       $dbresult = $GLOBALS['phpgw']->db->Execute($sql);
-
-                       if (!$dbresult->EOF)
-                       {
-                               $meter['meter_id']                      = 
$dbresult->fields['id'];
-                               $meter['num']                           = 
$dbresult->fields['num'];
-                               $meter['name']                          = 
stripslashes($dbresult->fields['name']);
-                               $meter['remark']                        = 
stripslashes($dbresult->fields['remark']);
-                               $meter['cat_id']                        = 
$dbresult->fields['category'];
-                               $meter['location_code']         = 
$dbresult->fields['location_code'];
-                               $meter['p_num']                         = 
$dbresult->fields['p_num'];
-                               $meter['p_entity_id']           = 
$dbresult->fields['p_entity_id'];
-                               $meter['p_cat_id']                      = 
$dbresult->fields['p_cat_id'];
-                       }
-                       return $meter;
-               }
-
-               function add($meter)
-               {
-
-                       while (is_array($meter['location']) && 
list($input_name,$value) = each($meter['location']))
-                       {
-                               if($value)
-                               {
-                                       $cols[] = $input_name;
-                                       $vals[] = $value;
-                               }
-                       }
-
-                       if($cols)
-                       {
-                               $cols   = "," . implode(",", $cols);
-                               $vals   = ",'" . implode("','", $vals) . "'";
-                       }
-
-                       if($meter['street_name'])
-                       {
-                               $address[]= $meter['street_name'];
-                               $address[]= $meter['street_number'];
-                               $address        = implode(" ", $address);
-                       }
-
-                       if(!$address)
-                       {
-                               $address = $meter['location_name'];
-                       }
-
-                       $meter['remark'] = 
$this->db->db_addslashes($meter['remark']);
-
-                       $GLOBALS['phpgw']->db->Execute("INSERT INTO fm_meter 
(location_code, num,user_id,entry_date,name,address,category,remark $cols ) "
-                               . "VALUES ('" . $meter['location_code'] . "','" 
. $meter['num'] . "','" . $this->account . "','" . time() . "','" . 
$meter['name']
-                               . "','" . $address ."','" . $meter['cat_id'] 
."','" . $meter['remark']. "' $vals )");
-
-
-                       $meter_id = 
$this->db->get_last_insert_id('fm_meter','id');
-
-                       $receipt['meter_id'] = $meter_id;
-                       $receipt['message'][]=array('msg'=>lang('Meter %1 has 
been saved',$meter['num']));
-                       return $receipt;
-               }
-
-               function edit($meter)
-               {
-
-                       while (is_array($meter['location']) && 
list($input_name,$value) = each($meter['location']))
-                       {
-                               $vals[] = "$input_name = '$value'";
-                       }
-
-                       if($vals)
-                       {
-                               $vals   = "," . implode(",",$vals);
-                       }
-
-                       if($meter['street_name'])
-                       {
-                               $address[]= $meter['street_name'];
-                               $address[]= $meter['street_number'];
-                               $address        = implode(" ", $address);
-                       }
-
-                       if(!$address)
-                       {
-                               $address = $meter['location_name'];
-                       }
-
-                       $meter['remark'] = 
$this->db->db_addslashes($meter['remark']);
-
-
-                       $GLOBALS['phpgw']->db->Execute("UPDATE fm_meter set 
name='" . $meter['name'] . "', entry_date='" . time() . "', category='"
-                                                       . $meter['cat_id'] . 
"', location_code='" . $meter['location_code'] . "', address='" . $address . 
"', remark='" . $meter['remark']
-                                                       . "' $vals WHERE id='" 
. $meter['meter_id'] . "'");
-
-                       $receipt['message'][]=array('msg'=>lang('Meter %1 has 
been edited',$meter['num']));
-                       return $receipt;
-               }
-
-               function delete($meter_id)
-               {
-                       $GLOBALS['phpgw']->db->Execute("DELETE FROM fm_meter 
WHERE id='" . $meter_id ."'");
-               }
-
-       }
-?>
+<?php
+       
/**************************************************************************\
+       * phpGroupWare - property                                               
   *
+       * http://www.phpgroupware.org                                           
   *
+       *                                                                       
   *
+       * Facilities Management                                                 
   *
+       * Written by Sigurd Nes [sigurdne at online.no]                         
   *
+       * 
------------------------------------------------------------------------ *
+       * Copyright 2000 - 2003 Free Software Foundation, Inc                   
   *
+       * This program is part of the GNU project, see http://www.gnu.org/      
   *
+       * 
------------------------------------------------------------------------ *
+       * This program is free software; you can redistribute it and/or modify 
it  *
+       * under the terms of the GNU General Public License as published by the 
   *
+       * Free Software Foundation; either version 2 of the License, or (at 
your   *
+       * option) any later version.                                            
   *
+       
\**************************************************************************/
+
+       class property_someter
+       {
+
+               function property_someter()
+               {
+                       $this->currentapp       = 'property'; 
//$GLOBALS['phpgw_info']['flags']['currentapp'];
+                       $this->db               = $GLOBALS['phpgw']->db;
+                       $this->db2              = $this->db;
+                       $this->account  = $GLOBALS['phpgw_data']['user']['id'];
+                       $this->bocommon         = 
CreateObject($this->currentapp.'_bocommon');
+                       $this->join                     = $this->bocommon->join;
+               }
+
+               function get_category_list()
+               {
+
+                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT id, 
descr FROM fm_meter_category ORDER BY descr ");
+
+                       $i = 0;
+                       while (!$dbresult->EOF)
+                       {
+                               $categories[$i]['id']                           
= $dbresult->fields['id'];
+                               $categories[$i]['name']                         
= stripslashes($dbresult->fields['descr']);
+                               $i++;
+                               $dbresult->MoveNext();
+
+                       }
+                       return $categories;
+               }
+
+               function check_meter_num($num='')
+               {
+                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT 
count(*) FROM fm_meter where num='$num'");
+
+                       if ( $dbresult->fields[0])
+                       {
+                               return True;
+                       }
+               }
+
+               function read($data)
+               {
+                       if(is_array($data))
+                       {
+                               if ($data['start'])
+                               {
+                                       $start=$data['start'];
+                               }
+                               else
+                               {
+                                       $start=0;
+                               }
+                               $filter = 
(isset($data['filter'])?$data['filter']:'none');
+                               $query = 
(isset($data['query'])?$data['query']:'');
+                               $sort = 
(isset($data['sort'])?$data['sort']:'DESC');
+                               $order = 
(isset($data['order'])?$data['order']:'');
+                               $cat_id = 
(isset($data['cat_id'])?$data['cat_id']:0);
+                       }
+
+
+                       $entity_table = 'fm_meter';
+
+                       $cols .= $entity_table . '.location_code';
+                       $cols_return[] = 'location_code';
+
+                       $cols .= ",$entity_table.id as meter_id";
+                       $cols_return[] = 'meter_id';
+
+                       $cols .= ",$entity_table.num as num";
+                       $cols_return[]                          = 'num';
+                       $uicols['input_type'][]         = 'text';
+                       $uicols['name'][]                       = 'num';
+                       $uicols['descr'][]                      = lang('Meter 
ID');
+                       $uicols['statustext'][]         = lang('Meter ID');
+
+                       $cols .= ",$entity_table.name ";
+                       $cols_return[]                          = 'name';
+                       $uicols['input_type'][]         = 'text';
+                       $uicols['name'][]                       = 'name';
+                       $uicols['descr'][]                      = lang('Name');
+                       $uicols['statustext'][]         = lang('Name');
+
+                       $cols .= ",fm_meter_category.descr as meter_type";
+                       $cols_return[]                          = 'meter_type';
+                       $uicols['input_type'][]         = 'text';
+                       $uicols['name'][]                       = 'meter_type';
+                       $uicols['descr'][]                      = lang('Meter 
Type');
+                       $uicols['statustext'][]         = lang('Meter Type');
+
+
+                       $joinmethod .= " $this->join  fm_meter_category ON 
($entity_table.category = fm_meter_category.id))";
+                       $paranthesis .='(';
+
+
+                       $sql    = 
$this->bocommon->generate_sql(array('entity_table'=>$entity_table,'cols'=>$cols,'cols_return'=>$cols_return,
+                                                                               
                                        
'uicols'=>$uicols,'joinmethod'=>$joinmethod,'paranthesis'=>$paranthesis,'query'=>$query));
+
+
+                       if ($order)
+                       {
+                               $ordermethod = " order by $entity_table.$order 
$sort";
+                       }
+                       else
+                       {
+                               $ordermethod = " order by 
$entity_table.location_code asc";
+                       }
+
+
+                       $where = 'WHERE';
+                       if ($cat_id)
+                       {
+                               $filtermethod .= " $where 
fm_meter.category='$cat_id' ";
+                               $where = 'AND';
+                       }
+
+                       if($query)
+                       {
+                               $query = ereg_replace("'",'',$query);
+                               $query = ereg_replace('"','',$query);
+
+                               $querymethod = " $where (fm_meter.name LIKE 
'%$query%' OR fm_meter.num LIKE '%$query%' OR fm_meter.location_code LIKE 
'%$query%' OR fm_meter.address LIKE '%$query%')";
+                       }
+
+                       $sql .= " $filtermethod $querymethod";
+//echo $sql;
+                       $this->uicols           = $this->bocommon->uicols;
+                       $cols_return            = $this->bocommon->cols_return;
+                       $type_id                        = 
$this->bocommon->type_id;
+                       $this->cols_extra       = $this->bocommon->cols_extra;
+
+                       $dbresult2 = $GLOBALS['phpgw']->db->Execute($sql);
+                       $this->total_records = $dbresult2->_numOfRows;
+                       $maxmatchs = 15;
+                       $dbresult = $GLOBALS['phpgw']->db->SelectLimit($sql . 
$ordermethod,$maxmatchs,$start);
+
+
+                       $j=0;
+                       while (!$dbresult->EOF)
+                       {
+                               for ($i=0;$i<count($cols_return);$i++)
+                               {
+                                       $meter[$j][$cols_return[$i]] = 
$dbresult->fields[$cols_return[$i]];
+                               }
+
+                               $location_code= 
$dbresult->fields['location_code'];
+                               $location = split('-',$location_code);
+                               for ($m=0;$m<count($location);$m++)
+                               {
+                                       $meter[$j]['loc' . ($m+1)] = 
$location[$m];
+                                       $meter[$j]['query_location']['loc' . 
($m+1)]=implode("-", array_slice($location, 0, ($m+1)));
+                               }
+
+                               $j++;
+                               $dbresult->MoveNext();
+                       }
+
+//html_print_r($meter);
+                       return $meter;
+               }
+
+               function read_single($meter_id)
+               {
+                       $sql = "SELECT * FROM fm_meter where id='$meter_id'";
+
+                       $dbresult = $GLOBALS['phpgw']->db->Execute($sql);
+
+                       if (!$dbresult->EOF)
+                       {
+                               $meter['meter_id']                      = 
$dbresult->fields['id'];
+                               $meter['num']                           = 
$dbresult->fields['num'];
+                               $meter['name']                          = 
stripslashes($dbresult->fields['name']);
+                               $meter['remark']                        = 
stripslashes($dbresult->fields['remark']);
+                               $meter['cat_id']                        = 
$dbresult->fields['category'];
+                               $meter['location_code']         = 
$dbresult->fields['location_code'];
+                               $meter['p_num']                         = 
$dbresult->fields['p_num'];
+                               $meter['p_entity_id']           = 
$dbresult->fields['p_entity_id'];
+                               $meter['p_cat_id']                      = 
$dbresult->fields['p_cat_id'];
+                       }
+                       return $meter;
+               }
+
+               function add($meter)
+               {
+
+                       while (is_array($meter['location']) && 
list($input_name,$value) = each($meter['location']))
+                       {
+                               if($value)
+                               {
+                                       $cols[] = $input_name;
+                                       $vals[] = $value;
+                               }
+                       }
+
+                       if($cols)
+                       {
+                               $cols   = "," . implode(",", $cols);
+                               $vals   = ",'" . implode("','", $vals) . "'";
+                       }
+
+                       if($meter['street_name'])
+                       {
+                               $address[]= $meter['street_name'];
+                               $address[]= $meter['street_number'];
+                               $address        = implode(" ", $address);
+                       }
+
+                       if(!$address)
+                       {
+                               $address = $meter['location_name'];
+                       }
+
+                       $meter['remark'] = 
$this->db->db_addslashes($meter['remark']);
+
+                       $GLOBALS['phpgw']->db->Execute("INSERT INTO fm_meter 
(location_code, num,user_id,entry_date,name,address,category,remark $cols ) "
+                               . "VALUES ('" . $meter['location_code'] . "','" 
. $meter['num'] . "','" . $this->account . "','" . time() . "','" . 
$meter['name']
+                               . "','" . $address ."','" . $meter['cat_id'] 
."','" . $meter['remark']. "' $vals )");
+
+
+                       $meter_id = 
$this->db->get_last_insert_id('fm_meter','id');
+
+                       $receipt['meter_id'] = $meter_id;
+                       $receipt['message'][]=array('msg'=>lang('Meter %1 has 
been saved',$meter['num']));
+                       return $receipt;
+               }
+
+               function edit($meter)
+               {
+
+                       while (is_array($meter['location']) && 
list($input_name,$value) = each($meter['location']))
+                       {
+                               $vals[] = "$input_name = '$value'";
+                       }
+
+                       if($vals)
+                       {
+                               $vals   = "," . implode(",",$vals);
+                       }
+
+                       if($meter['street_name'])
+                       {
+                               $address[]= $meter['street_name'];
+                               $address[]= $meter['street_number'];
+                               $address        = implode(" ", $address);
+                       }
+
+                       if(!$address)
+                       {
+                               $address = $meter['location_name'];
+                       }
+
+                       $meter['remark'] = 
$this->db->db_addslashes($meter['remark']);
+
+
+                       $GLOBALS['phpgw']->db->Execute("UPDATE fm_meter set 
name='" . $meter['name'] . "', entry_date='" . time() . "', category='"
+                                                       . $meter['cat_id'] . 
"', location_code='" . $meter['location_code'] . "', address='" . $address . 
"', remark='" . $meter['remark']
+                                                       . "' $vals WHERE id='" 
. $meter['meter_id'] . "'");
+
+                       $receipt['message'][]=array('msg'=>lang('Meter %1 has 
been edited',$meter['num']));
+                       return $receipt;
+               }
+
+               function delete($meter_id)
+               {
+                       $GLOBALS['phpgw']->db->Execute("DELETE FROM fm_meter 
WHERE id='" . $meter_id ."'");
+               }
+
+       }
+?>




reply via email to

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