[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] property/inc/class.socategory.inc.php, 1.2
From: |
nomail |
Subject: |
[Phpgroupware-cvs] property/inc/class.socategory.inc.php, 1.2 |
Date: |
Wed, 2 Jun 2004 20:54:28 +0200 |
Update of /property/inc
Added Files:
Branch:
class.socategory.inc.php
date: 2004/06/02 18:54:28; author: sigurdne; state: Exp; lines: +209 -0
Log Message:
no message
=====================================================================
<?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 socategory
{
function socategory()
{
$this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
$this->db = $GLOBALS['phpgw']->db;
$this->db2 = $this->db;
$this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
$this->socommon =
CreateObject($this->currentapp.'.socommon');
$this->join = $this->socommon->join;
}
function read($data)
{
if(is_array($data))
{
if ($data['start'])
{
$start=$data['start'];
}
else
{
$start=0;
}
$query =
(isset($data['query'])?$data['query']:'');
$sort =
(isset($data['sort'])?$data['sort']:'DESC');
$order =
(isset($data['order'])?$data['order']:'');
$type =
(isset($data['type'])?$data['type']:'');
$type_id =
(isset($data['type_id'])?$data['type_id']:'');
$allrows =
(isset($data['allrows'])?$data['allrows']:'');
}
if(!$type)
{
return;
}
if ($order)
{
$ordermethod = " order by $order $sort";
}
else
{
$ordermethod = ' order by id asc';
}
$table = $this->select_table($type,$type_id);
if($query)
{
$query = ereg_replace("'",'',$query);
$query = ereg_replace('"','',$query);
$querymethod = " where id LIKE '%$query%' or
descr LIKE '%$query%'";
}
$sql = "SELECT * FROM $table $querymethod";
$this->db2->query($sql,__LINE__,__FILE__);
$this->total_records = $this->db2->num_rows();
if(!$allrows)
{
$this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
}
else
{
$this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
}
while ($this->db->next_record())
{
$category[] = array
(
'id' => $this->db->f('id'),
'descr' =>
$this->db->f('descr')
);
}
return $category;
}
function select_table($type,$type_id)
{
switch($type)
{
case 'dim_d':
$table='fm_dim_d';
break;
case 'tender_chapter':
$table='fm_chapter';
break;
case 'ticket':
$table='fm_tts_category';
break;
case 'request':
$table='fm_request_category';
break;
case 'wo':
$table='fm_workorder_category';
break;
case 'location':
$table='fm_location' . $type_id .
'_category';
break;
case 'drawing':
$table='fm_drawing_category';
break;
case 'meter':
$table='fm_meter_category';
break;
case 'document':
$table='fm_document_category';
break;
case 'owner':
$table='fm_owner_category';
break;
case 'tenant':
$table='fm_tenant_category';
break;
case 'vendor':
$table='fm_vendor_category';
break;
case 'district':
$table='fm_district';
break;
case 'street':
$table='fm_streetaddress';
break;
}
return $table;
}
function read_single($id,$type,$type_id)
{
$table = $this->select_table($type,$type_id);
$sql = "SELECT * FROM $table where id='$id'";
$this->db->query($sql,__LINE__,__FILE__);
if ($this->db->next_record())
{
$category['id'] =
$this->db->f('id');
$category['descr']
= $this->db->f('descr');
return $category;
}
}
function add($category,$type,$type_id)
{
$table = $this->select_table($type,$type_id);
$category['descr'] =
$this->db->db_addslashes($category['descr']);
$this->db->query("INSERT INTO $table (id, descr) "
. "VALUES ('" . $category['id'] . "','" .
$category['descr']. "')",__LINE__,__FILE__);
$receipt['message'][]=array('msg'=>lang('category has
been saved'));
return $receipt;
}
function edit($category,$type,$type_id)
{
$table = $this->select_table($type,$type_id);
$category['descr'] =
$this->db->db_addslashes($category['descr']);
$this->db->query("UPDATE $table set descr='" .
$category['descr']
. "' WHERE id='" .
$category['id']. "'",__LINE__,__FILE__);
$receipt['message'][]=array('msg'=>lang('category has
been edited'));
return $receipt;
}
function delete($id,$type,$type_id)
{
$table = $this->select_table($type,$type_id);
$this->db->query("DELETE FROM $table WHERE id='" . $id
. "'",__LINE__,__FILE__);
}
}
?>
- [Phpgroupware-cvs] property/inc/class.socategory.inc.php, 1.2,
nomail <=