Menu â–¾ â–´

[c94d08]: / log.php  Maximize  Restore  History

Download this file

207 lines (173 with data), 6.5 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<?php
/*
<LICENSE>
This file is part of AGENCY.
AGENCY is Copyright (c) 2003-2022 by Ken Tanzer and Downtown Emergency
Service Center (DESC).
All rights reserved.
For more information about AGENCY, see http://agency-software.org/
For more information about DESC, see http://www.desc.org/.
AGENCY is free software: you can redistribute it and/or modify
it under the terms of version 3 of the GNU General Public License
as published by the Free Software Foundation.
AGENCY is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with AGENCY. If not, see <http://www.gnu.org/licenses/>.
For additional information, see the README.copyright file that
should be included in this distribution.
</LICENSE>
*/
function log_link( $idnum, $label="lookup" )
{ // Doesn't do Validate or Match
if (!$idnum) { return false; }
$def=get_def('log');
$log_table=$def['table'];
$id_field=$def['id_field'];
if ($label=="lookup")
{
//$label =sql_assign("SELECT SUBSTRING(COALESCE(subject,log_text) FROM 0 FOR 50) FROM $log_table",array($log_table . "_id" => $idnum));
$label =object_label('log',$idnum);
}
return elink('log',$idnum,$label);
}
/*
function engine_record_perm_log($control,$rec,$def) {
global $UID;
if ($control['action']=='add') { return true; }
if (isset($rec['_client_links'])) {
$clients = sql_to_php_array($rec['_client_links']);
} else {
$clients = get_clients_for_log( $rec['log_id'],'NF');
}
$clients = array_filter($clients);
if (isset($rec['_case_mgr_id'])) {
$cm = sql_to_php_array($rec['_case_mgr_id']);
} else {
$cm = get_staff_clients($clients);
}
if (isset($rec['_staff_alert_ids'])) {
$staff_alert=sql_to_php_array($rec['_staff_alert_ids']);
} else {
$staff_alert=get_alerts_for_log( $rec['log_id'],'NF' );
}
$in_logs=which_logs($rec,'log_');
$perm = (!$in_logs) // client_only entry
|| has_perm($in_logs,'R') // log_specific permission
|| in_array($UID,$staff_alert) // Flagged to user's attention
|| in_array($UID,$cm); //staff assigned to client
return $perm;
}
/*
function db_links_array($arr)
{
foreach ($arr as $key=>$link)
{
$arr[$key]=stripslashes($link);
}
return $arr;
}
*/
/* log/engine functions */
/*
function generate_list_medium_log($result,$fields,$max,$position,$total,$control,$def,$control_array_variable,&$rec_num)
{
return generate_list_long_log($result,$fields,$max,$position,$total,$control,$def,$control_array_variable,&$rec_num);
}
*/
function generate_list_long_log($result,$fields,$max,$position,$total,$control,$def,$control_array_variable,&$rec_num)
{
if (!in_array($control['format'],array('long','medium'))) {
return generate_list_generic($result,$fields,$max,$position,$total,$control,$def,$control_array_variable,$rec_num);
}
$pos=$control['list']['position'];
$mx=$control['list']['max'];
$seek_pos = $def['list_use_offset'] ? NULL : $pos;
while ( $x<$mx and $pos<$total) {
$a = sql_to_php_generic(sql_fetch_assoc($result,$seek_pos),$def);
$link = link_engine(array('object'=>$def['object'],'id'=>$a[$def['id_field']]),'View');
$out .= div(view_log($a,$def,'view',$control) . html_heading_6($link));
$seek_pos++;
$x++;
}
return $out . list_links($max,$position,$total,$control,$control_array_variable);
}
/* end log/engine functions */
function show_log_types($picks="",$formvar="",$sep="")
{
// create options to choose which logs to view
$formvar=orr($formvar,"pick_logs");
$picks=orr($picks,array());
return do_checkbox_sql('SELECT log_type_code AS value,description AS label FROM l_log_type',$formvar,$picks);
}
function show_pick_logs()
{
// allow user to select which logs to view
global $SHOW_LOGS,$logs_per_screen,$DISPLAY;
$output = formto($_SERVER['PHP_SELF'])
. table(row(leftcell(smaller("Jump to date: " . formvartext('log_jump_date','','size=7')))
. cell(
oline(smaller(hard_space("Logs per page "))
. formvartext("logs_index_count",$logs_per_screen,"size=5"))
. rightcell(formcheck("show_photos",$DISPLAY["photos"])
. smaller(hard_space(" Show Photos"))))
// . formcheck("pick_logs[flagged_only]",$SHOW_LOGS["flagged_only"])
// . smaller(hard_space(' "Red-flagged" Only'))
,' style="white-space: nowrap;"')
//. smaller(hard_space("Logs to view: ") . show_log_types($SHOW_LOGS))
. row(cell(''))
. row(cell(smaller(hard_space("Logs to view: ") . show_log_types($SHOW_LOGS))
. hiddenvar('$control[action]',"pick_logs")
. button("View","SUBMIT") . smaller(help("Logs","","Help!",'class="fancyLink"'))
. formend(),'colspan=2'))
,'',' cellpadding="0" cellspacing="0" width=100% class="pick"');
return $output;
}
function view_log($rec,$def,$action,$control='',$control_array_variable='control')
{
foreach ($rec as $key => $value) {
if (in_array($key,array('log_text','subject'))) {
$def['fields'][$key]['data_type'] = 'text';
$$key = value_generic($value,$def,$key,'view');
}
}
//post times
$added_at = dateof($rec['added_at']).' '.timeof($rec['added_at']);
$post_times = 'Posted at '.bold($added_at);
if ($occurred_at = $rec['occurred_at']) {
$occurred_at = dateof($occurred_at).' '.timeof($occurred_at);
$post_times .= oline().'Event time was '.bold($occurred_at);
}
$c_def=get_def(AG_MAIN_OBJECT_DB);
$client_refs = ($a=object_references_f('log',$rec['log_id'],NULL,'','to',array('client')))
? oline($c_def['plural'] . ':') . $a
: '';
$staff_alerts = ($a=staff_alerts_f('log',$rec['log_id']))
? oline(bold('Staff Alerts:')).$a
: '';
$in_logs = smaller(implode(oline(),$rec['log_type_code']));
/*
foreach( $rec['log_type_code'] as $a) {
$in_logs.=html_list_item($a);
}
$in_logs = $in_logs ? html_list($in_logs) : '';
*/
$title = (($action=='list')
? bold(bigger('Log '.$rec['log_id'].' ',2))
: '' )
.'(logs: '.$in_logs.')';
$out = //oline($title,2)
//refs/author info
table(row(
cell($in_logs)
. cell(oline('Posted by '.staff_link($rec['added_by'])) . $post_times,'class="info"')
. ($client_refs ? cell($client_refs,'class="client"') : '')
. ($staff_alerts ? cell($staff_alerts,'class="staff"') : '')
),'','class="logHeader"')
. div(html_heading_2($subject,' class="logSubject"')
. $log_text,'','class="logText generalTable"');
return $out;
}
?>