+ Custom fields should now display properly in both tickets and replies. Also added a setting so that admins can choose where in the ticket each field shows up. ! Moved the quick reply and the action log to the right side column so they're now the same width as the replies ! Some minor changes to improve ticket display in Core. We won't give much thought as to supporting Core, though.
cookiemonster

cookiemonster commited on 2010-12-04 10:18:34
Showing 9 changed files, with 275 additions and 73 deletions.

... ...
@@ -10,7 +10,7 @@ div.grid_header
10 10
 }
11 11
 
12 12
 /* You no left float, Core! */
13
-h3.grid_header img
13
+div.grid_header img
14 14
 {
15 15
 	float: none;
16 16
 }
... ...
@@ -98,15 +98,24 @@ h3.ticketheader img
98 98
 }
99 99
 
100 100
 /* Ticket details (Left-floated box) */
101
-.shd_ticketdetails
101
+.shd_ticket_side_column
102 102
 {
103 103
 	float: left;
104 104
 	width: 215px;	
105
+	margin-right: 20px;	
106
+}
107
+.shd_ticketdetails
108
+{
105 109
 	min-height: 280px;
106 110
 	overflow: auto;
107
-	margin-right: 20px;
111
+	width: 100%;
108 112
 }
109
-.shd_ticketdetails ul
113
+.shd_additional_details
114
+{
115
+	overflow: auto;
116
+	width: 100%;	
117
+}
118
+.shd_ticket_side_column ul
110 119
 {
111 120
 	list-style-type: none;
112 121
 	padding-left: 0;
... ...
@@ -190,6 +199,10 @@ h3.ticketheader img
190 199
 	position: relative;
191 200
 	left: 4px;
192 201
 }
202
+#shd_custom_fields_swap
203
+{
204
+	margin-top: 8px;
205
+}
193 206
 .shd_ticket_log_expand_container
194 207
 {
195 208
 	margin-right: 3px;
... ...
@@ -373,4 +373,10 @@ $txt['shd_ticket_reltype_linked'] = 'Linked to';
373 373
 $txt['shd_ticket_reltype_duplicated'] = 'Duplicate of';
374 374
 $txt['shd_ticket_reltype_parent'] = 'Parent of';
375 375
 $txt['shd_ticket_reltype_child'] = 'Child of';
376
+
377
+// Custom fields in ticket
378
+$txt['shd_ticket_additional_information'] = 'Additional information';
379
+$txt['shd_ticket_additional_details'] = 'Additional details';
380
+$txt['shd_ticket_empty_field'] = 'This field is empty.';
381
+$txt['shd_ticket_empty_field_short'] = '-';
376 382
 ?>
377 383
\ No newline at end of file
... ...
@@ -299,6 +299,10 @@ $txt['shd_admin_custom_field_can_edit_desc'] = 'Select who can edit/use this fie
299 299
 $txt['shd_admin_custom_field_users'] = 'Users';
300 300
 $txt['shd_admin_custom_field_staff'] = 'Staff';
301 301
 $txt['shd_admin_custom_field_admins'] = 'Admins';
302
+$txt['shd_admin_custom_field_placement'] = 'Placement inside ticket';
303
+$txt['shd_admin_custom_field_placement_desc'] = 'Where in the ticket should this field be displayed? Please note that large fields may not fit very well in to the "additional details" box.';
304
+$txt['shd_admin_custom_field_placement_details'] = 'Additional details (Left side box)';
305
+$txt['shd_admin_custom_field_placement_information'] = 'Additional information (Below ticket body)';
302 306
 //@}
303 307
 
304 308
 //! Plugins
... ...
@@ -357,3 +357,20 @@ ActionLog.prototype.swap = function ()
357 357
 
358 358
 	this.bCollapsed = !this.bCollapsed;
359 359
 }
360
+
361
+function CustomFields(oOptions)
362
+{
363
+	this.opt = oOptions;
364
+	this.bCollapsed = false;
365
+}
366
+
367
+// Expand and collapse the additional information block
368
+CustomFields.prototype.infoswap = function ()
369
+{
370
+	document.getElementById(this.opt.sImageId).src = this.opt.sImagesUrl + "/" + (this.bCollapsed ? this.opt.sImageCollapsed : this.opt.sImageExpanded);
371
+	document.getElementById(this.opt.sContainerId).style.display = this.bCollapsed ? '' : 'none';
372
+	document.getElementById(this.opt.sFooterId).style.display = this.bCollapsed ? '' : 'none';
373
+	document.getElementById(this.opt.sHeaderId).setAttribute('class', (this.bCollapsed ? 'title_bar grid_header' : 'title_bar'));
374
+
375
+	this.bCollapsed = !this.bCollapsed;
376
+}
360 377
\ No newline at end of file
... ...
@@ -121,6 +121,7 @@ function shd_admin_custom_new()
121 121
 		'new_field' => true,
122 122
 		'field_loc' => CFIELD_TICKET,
123 123
 		'field_active' => ' checked="checked"',
124
+		'placement' => CFIELD_PLACE_DETAILS,
124 125
 	));
125 126
 	
126 127
 	$context['custom_field']['options'] = array('', '', '');
... ...
@@ -141,7 +142,8 @@ function shd_admin_custom_edit()
141 142
 
142 143
 	$query = shd_db_query('', '
143 144
 		SELECT id_field, active, field_order, field_name, field_desc, field_loc, icon, field_type,
144
-		field_length, field_options, bbc, default_value, can_see, can_edit, display_empty, required
145
+		field_length, field_options, bbc, default_value, can_see, can_edit, display_empty, required,
146
+		placement
145 147
 		FROM {db_prefix}helpdesk_custom_fields
146 148
 		WHERE id_field = {int:field}',
147 149
 		array(
... ...
@@ -172,6 +174,7 @@ function shd_admin_custom_edit()
172 174
 			'field_icon_value' => $context['custom_field']['icon'],
173 175
 			'field_loc' => $context['custom_field']['field_loc'],
174 176
 			'field_active' => $context['custom_field']['active'] == 1 ? ' checked="checked"' : '',
177
+			'placement' => $context['custom_field']['placement'],
175 178
 		));
176 179
 		
177 180
 		
... ...
@@ -310,13 +313,13 @@ function shd_admin_custom_save()
310 313
 				'active' => 'int', 'field_name' => 'string', 'field_desc' => 'string',
311 314
 				'field_loc' => 'int', 'icon' => 'string', 'field_type' => 'int', 'field_length' => 'int',
312 315
 				'field_options' => 'string', 'bbc' => 'int', 'default_value' => 'string', 'can_see' => 'string',
313
-				'can_edit' => 'string', 'display_empty' => 'int', 'required' => 'int',
316
+				'can_edit' => 'string', 'display_empty' => 'int', 'required' => 'int', 'placement' => 'int',
314 317
 			),
315 318
 			array(
316 319
 				$_POST['active'], $_POST['field_name'], $_POST['description'],
317 320
 				$_POST['field_visible'],$_POST['field_icon'], $_POST['field_type'], $_POST['field_length'],
318 321
 				$options, $_POST['bbc'], $_POST['default_check'], $can_see,
319
-				$can_edit, $_POST['display_empty'], $_POST['required'],
322
+				$can_edit, $_POST['display_empty'], $_POST['required'], $_POST['placement'],
320 323
 			),
321 324
 			array(
322 325
 				'id_field',
... ...
@@ -340,7 +343,8 @@ function shd_admin_custom_save()
340 343
 				icon = {string:field_icon}, field_type = {int:field_type},
341 344
 				field_length = {int:field_length}, field_options = {string:field_options},
342 345
 				bbc = {int:bbc}, default_value = {string:default_value}, can_see = {string:can_see},
343
-				can_edit = {string:can_edit}, display_empty = {int:display_empty}, required = {int:required}
346
+				can_edit = {string:can_edit}, display_empty = {int:display_empty}, required = {int:required},
347
+				placement = {int:placement}
344 348
 			WHERE id_field = {int:id_field}',
345 349
 			array(
346 350
 				'id_field' => $_REQUEST['field'],
... ...
@@ -358,6 +362,7 @@ function shd_admin_custom_save()
358 362
 				'can_edit' => $can_edit,
359 363
 				'display_empty' => $_POST['display_empty'],
360 364
 				'required' => $_POST['required'],
365
+				'placement' => $_POST['placement'],
361 366
 			)
362 367
 		);
363 368
 
... ...
@@ -172,49 +172,80 @@ function shd_view_ticket()
172 172
 		'deleted' => $ticketinfo['deleted'],
173 173
 	);
174 174
 	
175
-	// Load all custom fields that are to be displayed in the ticket
175
+	// Load all of our custom fields
176 176
 	$custom_fields = shd_db_query('', '
177 177
 		SELECT cf.id_field, cf.active, cf.field_order, cf.field_name, cf.field_loc, cf.icon,
178 178
 		cf.field_type, cf.default_value, cf.bbc, cf.can_see, cf.can_edit, cf.field_length,
179
-		cf.display_empty
179
+		cf.display_empty, cf.required, cf.placement
180 180
 		FROM {db_prefix}helpdesk_custom_fields AS cf
181
-		WHERE (cf.field_loc = {int:field_loc_ticket} OR {int:field_loc_ticket})
182
-			AND cf.active = 1
181
+		WHERE cf.active = 1
183 182
 		ORDER BY cf.field_order',
183
+		array()
184
+	);
185
+	
186
+	// Now load the values of each field in the ticket
187
+	$custom_field_values = shd_db_query('', '
188
+		SELECT cfv.id_post, cfv.id_field, cfv.value
189
+		FROM {db_prefix}helpdesk_custom_fields_values AS cfv
190
+		WHERE cfv.id_post = {int:ticket}
191
+			AND cfv.post_type = 1',
184 192
 		array(
185
-			'field_loc_ticket_reply' => (CFIELD_TICKET | CFIELD_REPLY),
186
-			'field_loc_ticket' => CFIELD_TICKET,
193
+			'ticket' => $context['ticket_id'],
187 194
 		)
188 195
 	);
189 196
 	
190
-	$context['ticket']['custom_fields']['right'] = array();
191
-	$context['ticket']['custom_fields']['center'] = array();
197
+	$field_values = array();
192 198
 
193
-	while($row = $smcFunc['db_fetch_assoc']($custom_fields))
199
+	while($row = $smcFunc['db_fetch_assoc']($custom_field_values))
194 200
 	{
201
+		$field_values[$row['id_field']] = $row['value'];
202
+	}
203
+	$smcFunc['db_free_result']($custom_field_values);
204
+	
205
+	$context['custom_fields_replies'] = array();
206
+	$context['ticket']['custom_fields'] = array(
207
+		'details' => array(),
208
+		'information' => array(),
209
+	);
195 210
 
211
+	// Loop through all fields and figure out where they should be.
212
+	while($row = $smcFunc['db_fetch_assoc']($custom_fields))
213
+	{
196 214
 		$row['can_see'] = explode(',',$row['can_see']);
197 215
 
198
-		if((shd_allowed_to('shd_staff') && $row['can_see'][1] == 1) || (!shd_allowed_to('shd_staff') && $row['can_see'][0] == 1))
216
+		if(((shd_allowed_to('shd_staff') && $row['can_see'][1] == 1) || (!shd_allowed_to('shd_staff') && $row['can_see'][0] == 1)) || shd_allowed_to('admin_forum'))
199 217
 		{
200
-			if($row['field_type'] == CFIELD_TYPE_LARGETEXT || ($row['field_type'] == CFIELD_TYPE_TEXT && $row['field_length'] > 30))
201
-				$pos = 'center';
218
+			// If this is going to be displayed for the individual ticket, we need to figure out where it should go.
219
+			if($row['field_loc'] == 1 || $row['field_loc'] == 3)
220
+			{
221
+				if($row['placement'] == 1)
222
+					$pos = 'details';
202 223
 				else
203
-				$pos = 'right';
224
+					$pos = 'information';
225
+			}
204 226
 			
205
-			$context['ticket']['custom_fields'][$pos][$row['id_field']] = array(
227
+			$field = array(
206 228
 				'id' => $row['id_field'],
207 229
 				'name' => $row['field_name'],
208 230
 				'icon' => $row['icon'],
209 231
 				'type' => $row['field_type'],
210
-				'value' => !empty($row['value']) ? $row['value'] : ($row['field_type'] == CFIELD_TYPE_LARGETEXT ? '' : $row['default_value']),
211
-				'display_empty' => $row['display_empty'],
232
+				'default_value' => $row['default_value'],
233
+				'value' => !empty($field_values[$row['id_field']]) ? $field_values[$row['id_field']] : ($row['field_type'] == CFIELD_TYPE_LARGETEXT ? '' : $row['default_value']), // This is only for fields that display in the ticket, replies are taken care of later on
234
+				'display_empty' => $row['required'] == 1 ? 1 : $row['display_empty'], // Required and "selection" fields will always be displayed.
235
+				'bbc' => $row['bbc'] == 1
212 236
 			);
213 237
 			
214
-			if(($row['field_type'] == CFIELD_TYPE_TEXT || $row['field_type'] == CFIELD_TYPE_LARGETEXT) && $row['bbc'] == 1)
215
-				$context['ticket']['custom_fields'][$pos][$row['id_field']]['value'] = shd_format_text($context['ticket']['custom_fields'][$pos][$row['id_field']]['value']);
238
+			if($field['bbc'] == 1)
239
+				$field['value'] = shd_format_text($context['ticket']['custom_fields'][$pos][$row['id_field']]['value']);
240
+				
241
+			// Add it to the array.
242
+			if($row['field_loc'] == 1 || $row['field_loc'] == 3)
243
+				$context['ticket']['custom_fields'][$pos][$row['id_field']]	= $field;
244
+			if($row['field_loc'] == 2 || $row['field_loc'] == 3)
245
+				$context['custom_fields_replies'][$row['id_field']]	= $field;
216 246
 		}
217 247
 	}	
248
+	$smcFunc['db_free_result']($custom_fields);
218 249
 
219 250
 	// IP address next
220 251
 	$context['link_ip_address'] = allowedTo('moderate_forum'); // for trackip access
... ...
@@ -556,6 +587,15 @@ function shd_view_ticket()
556 587
 		sImageCollapsed: "collapse.gif",
557 588
 		sImageExpanded: "expand.gif",
558 589
 		sHeaderId: "ticket_log_header",
590
+	});
591
+	var oCustomFields = new CustomFields({
592
+		sImagesUrl: "' . $settings['images_url'] . '",
593
+		sContainerId: "additional_info",
594
+		sImageId: "shd_custom_fields_swap",
595
+		sImageCollapsed: "collapse.gif",
596
+		sImageExpanded: "expand.gif",
597
+		sHeaderId: "additionalinfoheader",
598
+		sFooterId: "additional_info_footer",
559 599
 	});	';
560 600
 
561 601
 	if (!empty($options['display_quick_reply']) && $context['can_go_advanced'])
... ...
@@ -715,6 +755,35 @@ function shd_prepare_ticket_context()
715 755
 	if (!empty($context['ticket_start_newfrom']) && $context['ticket_start_newfrom'] == $message['id_msg'])
716 756
 		$output['is_new'] = true;
717 757
 	
758
+	// Load the values of any custom field.
759
+	$custom_field_values = shd_db_query('', '
760
+		SELECT cfv.id_post, cfv.id_field, cfv.value
761
+		FROM {db_prefix}helpdesk_custom_fields_values AS cfv
762
+		WHERE cfv.id_post = {int:reply}
763
+			AND cfv.post_type = 2',
764
+		array(
765
+			'reply' => $message['id_msg'],
766
+		)
767
+	);
768
+	
769
+	$field_values = array();
770
+
771
+	while($row = $smcFunc['db_fetch_assoc']($custom_field_values))
772
+	{
773
+		$field_values[$row['id_field']] = $row['value'];
774
+	}
775
+	$smcFunc['db_free_result']($custom_field_values);
776
+	
777
+	$output['custom_fields'] = array();
778
+
779
+	foreach($context['custom_fields_replies'] AS $field)
780
+	{
781
+		$output['custom_fields'][$field['id']]['value'] = !empty($field_values[$field['id']]) ? $field_values[$field['id']] : ($field['type'] == CFIELD_TYPE_LARGETEXT ? '' : $field['default_value']);
782
+			
783
+		if($field['bbc'] == 1)
784
+		$output['custom_fields'][$field['id']]['value'] = shd_format_text($output['custom_fields'][$field['id']]['value']);		
785
+	}	
786
+
718 787
 	return $output;
719 788
 }
720 789
 
... ...
@@ -79,6 +79,10 @@ function shd_init()
79 79
 	define('CFIELD_TICKET', 1);
80 80
 	define('CFIELD_REPLY', 2);
81 81
 	
82
+	define('CFIELD_PLACE_DETAILS', 1);
83
+	define('CFIELD_PLACE_INFO', 2);
84
+	
85
+
82 86
 	define('CFIELD_TYPE_TEXT', 1);
83 87
 	define('CFIELD_TYPE_LARGETEXT', 2);
84 88
 	define('CFIELD_TYPE_INT', 3);
... ...
@@ -164,6 +164,11 @@ function template_shd_custom_field_edit()
164 164
 					document.getElementById("edit_" + role).disabled = state == "on" ? "" : "disabled";
165 165
 					document.getElementById("edit_" + role).checked = state == "on" ? "" : "";
166 166
 				}
167
+				function update_field_location(loc)
168
+				{
169
+					document.getElementById("placement_dt").style.display = loc == ',CFIELD_TICKET,' || loc == ',(CFIELD_TICKET | CFIELD_REPLY),' ? "" : "none";
170
+					document.getElementById("placement_dd").style.display = loc == ',CFIELD_TICKET,' || loc == ',(CFIELD_TICKET | CFIELD_REPLY),' ? "" : "none";					
171
+				}				
167 172
 				// ]', ']></script>
168 173
 				<form action="', $scripturl, '?action=admin;area=helpdesk_customfield;sa=save',!empty($context['new_field']) ? ';new' : '','" method="post">
169 174
 				<div class="tborder">
... ...
@@ -211,12 +216,19 @@ function template_shd_custom_field_edit()
211 216
 							<dt><strong>', $txt['shd_admin_custom_fields_visible'], ':</strong><br /><span class="smalltext">', $txt['shd_admin_custom_fields_visible_desc'], '</span></dt>
212 217
 							<dd>
213 218
 								<span id="cf_fieldvisible_icon"></span>
214
-								<select name="field_visible" id="cf_fieldvisible">
219
+								<select name="field_visible" id="cf_fieldvisible" onchange="javascript:update_field_location(this.value);">
215 220
 									<option value="', CFIELD_TICKET, '"',($context['field_loc'] == CFIELD_TICKET ? ' selected="selected"' : ''), '>', $txt['shd_admin_custom_fields_visible_ticket'], '</option>
216 221
 									<option value="', CFIELD_REPLY, '"',($context['field_loc'] == CFIELD_REPLY ? ' selected="selected"' : ''), '>', $txt['shd_admin_custom_fields_visible_field'], '</option>
217 222
 									<option value="', (CFIELD_TICKET | CFIELD_REPLY), '"',($context['field_loc'] == (CFIELD_TICKET | CFIELD_REPLY) ? ' selected="selected"' : ''), '>', $txt['shd_admin_custom_fields_visible_both'], '</option>
218 223
 								</select>
219 224
 							</dd>
225
+							<dt id="placement_dt"',(($context['field_loc'] == CFIELD_TICKET || $context['field_loc'] == (CFIELD_TICKET | CFIELD_REPLY)) ? '' : ' style="display: none;"'),'><strong>',$txt['shd_admin_custom_field_placement'],':</strong><br /><span class="smalltext">',$txt['shd_admin_custom_field_placement_desc'],'</span></dt>
226
+							<dd id="placement_dd"',(($context['field_loc'] == CFIELD_TICKET || $context['field_loc'] == (CFIELD_TICKET | CFIELD_REPLY)) ? '' : ' style="display: none;"'),'>
227
+								<select name="placement" id="cf_placement">
228
+									<option value="', CFIELD_PLACE_DETAILS, '"',($context['placement'] == CFIELD_PLACE_DETAILS ? ' selected="selected"' : ''), '>',$txt['shd_admin_custom_field_placement_details'],'</option>
229
+									<option value="', CFIELD_PLACE_INFO, '"',($context['placement'] == CFIELD_PLACE_INFO ? ' selected="selected"' : ''), '>',$txt['shd_admin_custom_field_placement_information'],'</option>
230
+								</select>
231
+							</dd>							
220 232
 							<dt><strong>',$txt['shd_admin_custom_field_can_see'],':</strong><br /><span class="smalltext">',$txt['shd_admin_custom_field_can_see_desc'],'</span></dt>
221 233
 							<dd>
222 234
 								<input type="checkbox" name="see_users" class="input_check" ',!empty($context['custom_field']['can_see'][0]) && $context['custom_field']['can_see'][0] == 1 ? 'checked="checked"' : '' ,' onchange="javascript:update_permissions(this.value,\'users\');"/> <img src="', $settings['default_images_url'], '/simpledesk/user.png" class="icon" alt="',$txt['shd_admin_custom_field_users'],'" title="',$txt['shd_admin_custom_field_users'],'"/>
... ...
@@ -62,7 +62,8 @@ function template_viewticket()
62 62
 				</h3>
63 63
 			</div>
64 64
 			<div class="windowbg">
65
-				<div class="content shd_ticket">';
65
+				<div class="content shd_ticket">
66
+					<div class="shd_ticket_side_column">';
66 67
 
67 68
 			// General ticket details
68 69
 			echo '
... ...
@@ -91,20 +92,38 @@ function template_viewticket()
91 92
 					echo '
92 93
 								<li><img src="', $settings['default_images_url'], '/simpledesk/ip.png" alt="" class="shd_smallicon" /> ', $txt['shd_ticket_ip'], ': ', $context['ticket']['ip_address'], '</li>';
93 94
 			
95
+				echo'
96
+							</ul>';
97
+							
98
+			// Display ticket poster avatar?
99
+			if (!empty($modSettings['shd_display_avatar']) && empty($options['show_no_avatars']) && !empty($context['ticket']['poster_avatar']['image']))
100
+				echo '
101
+						<div class="shd_ticket_avatar">
102
+							', shd_profile_link($context['ticket']['poster_avatar']['image'], $context['ticket']['member']['id']), '
103
+						</div>';
104
+						
105
+				echo'
106
+						</div>';
107
+				
94 108
 			// Custom fields :D
95
-			if(!empty($context['ticket']['custom_fields']['right']))
109
+			if(!empty($context['ticket']['custom_fields']['details']))
96 110
 			{
97
-				foreach($context['ticket']['custom_fields']['right'] AS $field)
111
+				echo'
112
+						<div class="information shd_additional_details">
113
+							<ul>
114
+							<strong><img src="', $settings['default_images_url'], '/simpledesk/additional_details.png" alt="" class="shd_smallicon shd_icon_minihead" /> ',$txt['shd_ticket_additional_details'],'</strong>
115
+							<hr />';
116
+
117
+				foreach($context['ticket']['custom_fields']['details'] AS $field)
98 118
 				{
99
-					if((empty($field['value']) && $field['display_empty']) || !empty($field['value']))
119
+					if($field['display_empty'] || !empty($field['value']))
100 120
 					{
101 121
 						echo'	<li>
102
-								<img src="', $settings['default_images_url'], '/simpledesk/cf/', $field['icon'], '" alt="" class="shd_smallicon" />
122
+									', !empty($field['icon']) ? '<img src="' . $settings['default_images_url'] . '/simpledesk/cf/' . $field['icon'] . '" alt="" class="shd_smallicon" />' : '','
103 123
 										', $field['name'],': ';
104 124
 						
105 125
 						if(empty($field['value']) && $field['display_empty'])
106
-							echo'
107
-								Empty';
126
+							echo $txt['shd_ticket_empty_field_short'];
108 127
 						elseif(!empty($field['value']))
109 128
 							echo $field['type'] == CFIELD_TYPE_CHECKBOX ? ($field['value'] == 1 ? $txt['yes'] : $txt['no']) : $field['value'];
110 129
 							
... ...
@@ -112,22 +131,12 @@ function template_viewticket()
112 131
 								</li>';
113 132
 					}				
114 133
 				}
115
-			}
116
-			
117
-			echo '
118
-						</ul>';
119
-
120
-			// Display ticket poster avatar?
121
-			if (!empty($modSettings['shd_display_avatar']) && empty($options['show_no_avatars']) && !empty($context['ticket']['poster_avatar']['image']))
122
-				echo '
123
-						<div class="shd_ticket_avatar">
124
-							', shd_profile_link($context['ticket']['poster_avatar']['image'], $context['ticket']['member']['id']), '
125
-						</div>';
126
-
127
-			echo '
134
+			echo '		</ul>
128 135
 					</div>';				
136
+			}
129 137
 
130 138
 			echo '
139
+					</div>
131 140
 					<div class="shd_ticket_description">';
132 141
 
133 142
 			if (!empty($context['ticket']['display_recycle']))
... ...
@@ -141,26 +150,6 @@ function template_viewticket()
141 150
 							<div id="shd_ticket_text">
142 151
 								', $context['ticket']['body'];								
143 152
 
144
-			// Again, custom fields...
145
-			if(!empty($context['ticket']['custom_fields']['center']))
146
-			{
147
-				foreach($context['ticket']['custom_fields']['center'] AS $field)
148
-				{
149
-					if((empty($field['value']) && $field['display_empty']) || !empty($field['value']))
150
-					{
151
-						echo'	<br /><br />
152
-								<img src="', $settings['default_images_url'], '/simpledesk/cf/', $field['icon'], '" alt="" class="shd_smallicon" /> 
153
-								<strong>', $field['name'],':</strong><hr />';
154
-						
155
-						if(empty($field['value']) && $field['display_empty'])
156
-							echo'
157
-								This field is empty.';
158
-						elseif(!empty($field['value']))
159
-							echo $field['value'];
160
-					}
161
-				}
162
-			}								
163
-
164 153
 			if ($settings['show_modify'] && !empty($context['ticket']['modified']))
165 154
 			{
166 155
 				echo '
... ...
@@ -199,6 +188,12 @@ function template_viewticket()
199 188
 	// Left column (ticket relationships, attachments)
200 189
 	template_ticket_leftcolumn();
201 190
 	
191
+	echo'
192
+		<div class="shd_ticket_rightcolumn floatleft"', empty($context['leftcolumndone']) ? ' style="width: 100%;"' : '', '>';
193
+	
194
+	// Additional information (custom fields)
195
+	template_additional_fields();
196
+
202 197
 	// The replies column
203 198
 	template_viewreplies();
204 199
 	
... ...
@@ -207,6 +202,10 @@ function template_viewticket()
207 202
 
208 203
 	// The ticket action log, lastly.
209 204
 	template_ticketactionlog();	
205
+	
206
+	echo'
207
+		</div><br class="clear" />';
208
+
210 209
 }
211 210
 
212 211
 /**
... ...
@@ -227,7 +226,7 @@ function template_ticket_leftcolumn()
227 226
 
228 227
 	echo '
229 228
 				<div class="shd_ticket_leftcolumn floatleft">
230
-					<div class="tborder shd_attachmentcolumn">';
229
+					<div class="shd_attachmentcolumn">';
231 230
 
232 231
 	// Related tickets
233 232
 	template_viewrelationships();
... ...
@@ -253,7 +252,7 @@ function template_viewticketattach()
253 252
 
254 253
 	if (!empty($context['ticket_attach']['ticket']))
255 254
 	{
256
-		echo '
255
+		echo '	<div class="tborder">
257 256
 					<div class="title_bar grid_header">
258 257
 						<h3 class="titlebg">
259 258
 							<img src="', $settings['default_images_url'], '/simpledesk/attachments.png" alt="x" />', $txt['shd_ticket_attachments'], ' (', count($context['ticket_attach']['ticket']), ')
... ...
@@ -288,10 +287,62 @@ function template_viewticketattach()
288 287
 		echo '
289 288
 						</div>
290 289
 						<span class="botslice"><span></span></span>
290
+					</div>
291 291
 				</div>';
292 292
 	}
293 293
 }
294 294
 
295
+/**
296
+ *	Additional information
297
+ *
298
+ *	This template displays the "Additional information" block below the ticket body. It contains any custom fields that the admin has set to display there.
299
+ *
300
+ *	@since 1.1
301
+*/
302
+function template_additional_fields()
303
+{
304
+	global $context, $scripturl, $options, $txt, $settings;
305
+	
306
+	if(!empty($context['ticket']['custom_fields']['information']))
307
+	{	
308
+		echo'	<div class="tborder">
309
+					<div class="title_bar grid_header" id="additionalinfoheader">
310
+						<h3 class="titlebg">
311
+							<span class="floatright"><a href="javascript:oCustomFields.infoswap();"><img src="', $settings['images_url'], '/collapse.gif" alt="+" id="shd_custom_fields_swap" class="icon" /></a></span>
312
+							<img src="', $settings['default_images_url'], '/simpledesk/additional_information.png" alt="x" />
313
+							<a href="javascript:oCustomFields.infoswap();">',$txt['shd_ticket_additional_information'],'</a>
314
+						</h3>
315
+					</div>
316
+					<div class="roundframe" id="additional_info">
317
+						<div class="content">';	
318
+
319
+			foreach($context['ticket']['custom_fields']['information'] AS $field)
320
+			{
321
+				if($field['display_empty'] || !empty($field['value']))
322
+				{
323
+					echo'
324
+							<div class="description">
325
+							', !empty($field['icon']) ? '<img src="' . $settings['default_images_url'] . '/simpledesk/cf/' . $field['icon'] . '" alt="" class="shd_smallicon" />' : '','
326
+							<strong>', $field['name'],':</strong><hr />';
327
+
328
+					if(empty($field['value']) && $field['display_empty'])
329
+						echo $txt['shd_ticket_empty_field'];
330
+					elseif(!empty($field['value']))
331
+						echo $field['value'];
332
+						
333
+						echo'</div>';
334
+				}
335
+			}
336
+		
337
+		echo'
338
+			</div>
339
+		</div>
340
+		<span class="lowerframe" id="additional_info_footer"><span></span></span>
341
+		</div>
342
+		<br />';
343
+	}
344
+}
345
+
295 346
 /**
296 347
  *	Displays the quick reply/go advanced box
297 348
  *
... ...
@@ -426,7 +477,6 @@ function template_viewreplies()
426 477
 	global $context, $settings, $txt, $scripturl, $options, $modSettings, $reply_request;
427 478
 
428 479
 	echo '
429
-		<div class="shd_ticket_rightcolumn floatleft"', empty($context['leftcolumndone']) ? ' style="width: 100%;"' : '', '>
430 480
 		<div class="tborder">
431 481
 		<div class="title_bar grid_header">
432 482
 			<h3 class="titlebg">
... ...
@@ -503,6 +553,28 @@ function template_viewreplies()
503 553
 							', $reply['body'], '
504 554
 							<br /><br />';
505 555
 							
556
+		// Custom fields for replies!
557
+		if(!empty($context['custom_fields_replies']))
558
+		{
559
+			echo'
560
+				<hr/>';
561
+
562
+			foreach($context['custom_fields_replies'] AS $field)
563
+			{
564
+				if($field['display_empty'] || !empty($message['custom_field'][$field['id']]['value']))
565
+				{
566
+					echo'	
567
+							', !empty($field['icon']) ? '<img src="' . $settings['default_images_url'] . '/simpledesk/cf/' . $field['icon'] . '" alt="" class="shd_smallicon" />' : '','
568
+							<strong>', $field['name'],':</strong>';
569
+
570
+					if(empty($message['custom_field'][$field['id']]['value']) && $field['display_empty'])
571
+						echo $txt['shd_ticket_empty_field'], '<br /><br />';
572
+					elseif(!empty($message['custom_field'][$field['id']]['value']))
573
+						echo $message['custom_field'][$field['id']]['value'], '<br /><br />';
574
+				}
575
+			}
576
+		}							
577
+
506 578
 			if ($settings['show_modify'] && !empty($reply['modified']))
507 579
 			{
508 580
 				echo '
... ...
@@ -532,8 +604,7 @@ function template_viewreplies()
532 604
 				<br class="clear" />
533 605
 			</div>
534 606
 			<span class="lowerframe"><span></span></span>
535
-		</div>
536
-		</div><br class="clear" />';
607
+		</div>';
537 608
 }
538 609
 
539 610
 /**
... ...
@@ -549,7 +620,7 @@ function template_viewrelationships()
549 620
 
550 621
 	if (!empty($context['display_relationships']))
551 622
 	{
552
-		echo '
623
+		echo '	<div class="tborder">
553 624
 					<div class="title_bar grid_header">
554 625
 						<h3 class="titlebg">
555 626
 							<img src="', $settings['default_images_url'], '/simpledesk/relationships.png" alt="x" />', $txt['shd_ticket_relationships'], ' (', $context['relationships_count'], ')
... ...
@@ -608,6 +679,7 @@ function template_viewrelationships()
608 679
 						</div>
609 680
 						<span class="botslice"><span></span></span>
610 681
 					</div>
682
+				</div>
611 683
 					<br />';
612 684
 	}
613 685
 }
614 686