00001 <?php
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 require_once FASTFRAME_ROOT . 'lib/FastFrame/DataAccess.php';
00026
00027
00028
00029
00039
00040 class FF_DataAccess_Log_mysql extends FF_DataAccess {
00041
00042
00047 var $profileTable;
00048
00049
00050
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
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
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
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 ?>