phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] property/inc/class.sob_account.inc.php, 1.2


From: nomail
Subject: [Phpgroupware-cvs] property/inc/class.sob_account.inc.php, 1.2
Date: Wed, 2 Jun 2004 20:54:28 +0200

Update of /property/inc
Added Files:
        Branch: 
          class.sob_account.inc.php

date: 2004/06/02 18:54:28;  author: sigurdne;  state: Exp;  lines: +146 -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 sob_account
        {

                function sob_account()
                {
                        $this->currentapp       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
                        $this->db               = $GLOBALS['phpgw']->db;
                        $this->db2              = $this->db;
                        $this->account  = 
$GLOBALS['phpgw_info']['user']['account_id'];
                }

                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']:'');
                                $allrows        = 
(isset($data['allrows'])?$data['allrows']:'');
                        }

                        if ($order)
                        {
                                $ordermethod = " order by $order $sort";

                        }
                        else
                        {
                                $ordermethod = ' order by id asc';
                        }

                        $table = 'fm_b_account';

                        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())
                        {
                                $b_account[] = array
                                (
                                        'id'    => $this->db->f('id'),
                                        'descr'                 => 
$this->db->f('descr')
                                );
                        }
                        return $b_account;
                }

                function read_single($id)
                {

                        $table = 'fm_b_account';

                        $sql = "SELECT * FROM $table  where id='$id'";

                        $this->db->query($sql,__LINE__,__FILE__);

                        if ($this->db->next_record())
                        {
                                $b_account['id']                        = 
$this->db->f('id');
                                $b_account['descr']                     = 
$this->db->f('descr');
                                $b_account['group']                     = 
$this->db->f('grouping');

                                return $b_account;
                        }
                }

                function add($b_account)
                {
                        $table = 'fm_b_account';

                        $b_account['descr'] = 
$this->db->db_addslashes($b_account['descr']);

                        $this->db->query("INSERT INTO $table (id, 
descr,grouping) "
                                . "VALUES ('" . $b_account['id'] . "','" . 
$b_account['descr']. "','" . substr($b_account['id'],0,2) . 
"')",__LINE__,__FILE__);

                        $receipt['message'][]=array('msg'=>lang('budget account 
%1 has been saved',$b_account['id']));
                        return $receipt;
                }

                function edit($b_account)
                {

                        $table = 'fm_b_account';

                        $b_account['descr'] = 
$this->db->db_addslashes($b_account['descr']);

                        $this->db->query("UPDATE $table set descr='" . 
$b_account['descr']
                                                        . "' WHERE id='" . 
$b_account['id']. "'",__LINE__,__FILE__);


                        $receipt['message'][]=array('msg'=>lang('budget account 
%1 has been edited',$b_account['id']));
                        return $receipt;
                }

                function delete($id)
                {
                        $table = 'fm_b_account';

                        $this->db->query("DELETE FROM $table WHERE id='" . $id 
. "'",__LINE__,__FILE__);
                }
        }
?>




reply via email to

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