DataAccess/mysql/Log.php

Go to the documentation of this file.
00001 <?php
00003 // {{{ license
00004 
00005 // +----------------------------------------------------------------------+
00006 // | FastFrame Application Framework                                      |
00007 // +----------------------------------------------------------------------+
00008 // | Copyright (c) 2002-2006 The Codejanitor Group                        |
00009 // +----------------------------------------------------------------------+
00010 // | This source file is subject to the GNU Lesser Public License (LGPL), |
00011 // | that is bundled with this package in the file LICENSE, and is        |
00012 // | available at through the world-wide-web at                           |
00013 // | http://www.fsf.org/copyleft/lesser.html                              |
00014 // | If you did not receive a copy of the LGPL and are unable to          |
00015 // | obtain it through the world-wide-web, you can get it by writing the  |
00016 // | Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
00017 // | MA 02111-1307, USA.                                                  |
00018 // +----------------------------------------------------------------------+
00019 // | Authors: Jason Rust <jrust@codejanitor.com>                          |
00020 // +----------------------------------------------------------------------+
00021 
00022 // }}}
00023 // {{{ requires
00024 
00025 require_once FASTFRAME_ROOT . 'lib/FastFrame/DataAccess.php';
00026 
00027 // }}}
00028 // {{{ class FF_DataAccess_Log_mysql 
00029 
00039 // }}}
00040 class FF_DataAccess_Log_mysql extends FF_DataAccess {
00041     // {{{ properties
00042 
00047     var $profileTable;
00048 
00049     // }}}
00050     // {{{ constructor
00051 
00058     function FF_DataAccess_Log_mysql()
00059     {
00060         FF_DataAccess::FF_DataAccess();
00061         $this->table = $this->o_registry->getConfigParam('data/log_table');
00062         $this->profileTable = $this->o_registry->getConfigParam('data/table', 'profile', 'profile');
00063     }
00064 
00065     // }}}
00066     // {{{ add()
00067 
00076     function add($in_data)
00077     {
00078         $in_data['date'] = $this->timestampToISODate($in_data['date']);
00079         $in_data['`table`'] = $in_data['table'];
00080         unset($in_data['table']);
00081         unset($in_data['username']);
00082         $o_result =& parent::add($in_data);
00083     }
00084 
00085     // }}}
00086     // {{{ getListData()
00087 
00100     function getListData($in_where, $in_orderByField, $in_orderByDir, $in_fields = '*')
00101     {
00102         $s_query = "SELECT user_id, username, 
00103                     UNIX_TIMESTAMP(date) AS date, action, target_id, loan_id, `table`
00104                     FROM $this->table 
00105                     LEFT JOIN $this->profileTable ON user_id=$this->profileTable.id
00106                     WHERE $in_where ORDER BY `$in_orderByField` " .
00107                     $this->_getOrderByDirection($in_orderByDir);
00108 
00109         $result =& $this->o_data->query($s_query);
00110         return $result;
00111     }
00112 
00113     // }}}
00114     // {{{ getLoanLog()
00115 
00124     function getLoanLog($in_loanId)
00125     {
00126         $s_ocTable = $this->o_registry->getConfigParam('data/override_codes_table');
00127         $s_transTable = $this->o_registry->getConfigParam('data/transaction_items_table');
00128         $s_itemsTable = $this->o_registry->getConfigParam('data/items_table');
00129         $s_query = "SELECT user_id, 
00130                     CONCAT(firstname, ' ', lastname) AS name, 
00131                     UNIX_TIMESTAMP(date) AS date, action, target_id, `table`, 
00132                     code, i.name AS item_name, i.barcode
00133                     FROM $this->table 
00134                     LEFT JOIN $this->profileTable ON user_id = $this->profileTable.id
00135                     LEFT JOIN $s_ocTable AS oc ON target_id = oc.id AND `table` = ?
00136                     LEFT JOIN $s_transTable AS ti ON target_id = ti.item_id AND `table` = ? 
00137                         AND ti.return_date = date
00138                     LEFT JOIN $s_itemsTable AS i ON ti.item_id = i.id
00139                     WHERE target_id = ? OR loan_id = ? ORDER BY date ASC";
00140         
00141         return $this->o_data->getAll($s_query, array($s_ocTable, $s_transTable, $in_loanId, $in_loanId));
00142     }
00143 
00144     // }}}
00145 }
00146 ?>

Generated on Fri Jun 23 11:38:17 2006 for FastFrame by  doxygen 1.4.4