1{* $Id$ *}
2{if !$viewItemPretty.override}
3	{title help="trackers"}{$tracker_item_main_value}{/title}
4{/if}
5
6
7{if ! isset($print_page) || $print_page ne 'y'}
8
9	{* --------- navigation ------ *}
10	<div class="t_navbar mb-4">
11		<div class="float-sm-right btn-group">
12			{if ! $js}<ul class="cssmenu_horiz"><li>{/if}
13			<a class="btn btn-link" data-toggle="dropdown" data-hover="dropdown" href="#">
14				{icon name='menu-extra'}
15			</a>
16			<ul class="dropdown-menu dropdown-menu-right">
17				<li class="dropdown-title">
18					{tr}Tracker item actions{/tr}
19				</li>
20				<li class="dropdown-divider"></li>
21				<li class="dropdown-item">
22					{if $viewItemPretty.override}
23						{self_link print='y' vi_tpl={$viewItemPretty.value}}
24							{icon name="print"} {tr}Print{/tr}
25						{/self_link}
26					{else}
27						{self_link print='y'}
28							{icon name="print"} {tr}Print{/tr}
29						{/self_link}
30					{/if}
31				</li>
32
33                {if $pdf_export eq 'y'}
34					<li class="dropdown-item">
35						<a href="{$smarty.server.SCRIPT_NAME}?{query pdf='y'}">
36							{icon name="pdf"} {tr}PDF{/tr}
37						</a>
38					</li>
39                {/if}
40
41				{if $item_info.logs.cant|default:null}
42					<li class="dropdown-item">
43						<a href="tiki-tracker_view_history.php?itemId={$itemId}">
44							{icon name="history"} {tr}History{/tr}
45						</a>
46					</li>
47				{/if}
48				{if $canRemove}
49					<li class="dropdown-item">
50						{self_link remove=$itemId}
51							{icon name="delete"} {tr}Delete{/tr}
52						{/self_link}
53					</li>
54				{/if}
55				{if $prefs.monitor_enabled eq 'y'}
56					<li class="dropdown-item">
57						{monitor_link type=trackeritem object=$itemId linktext="{tr}Notification{/tr}" class="link" title=""}
58					</li>
59				{/if}
60				{if $prefs.feature_user_watches eq 'y' and $tiki_p_watch_trackers eq 'y'}
61					<li class="dropdown-item">
62						{if $user_watching_tracker ne 'y'}
63							<a href="tiki-view_tracker_item.php?trackerId={$trackerId}&amp;itemId={$itemId}&amp;watch=add">
64								{icon name="watch"} {tr}Monitor{/tr}
65							</a>
66						{else}
67							<a href="tiki-view_tracker_item.php?trackerId={$trackerId}&amp;itemId={$itemId}&amp;watch=stop">
68								{icon name="stop-watching"} {tr}Stop monitoring{/tr}
69							</a>
70						{/if}
71					</li>
72					{if $prefs.feature_group_watches eq 'y' and ( $tiki_p_admin_users eq 'y' or $tiki_p_admin eq 'y' )}
73						<li class="dropdown-item">
74							<a href="tiki-object_watches.php?objectId={$itemId|escape:"url"}&amp;watch_event=tracker_item_modified&amp;objectType=tracker+{$trackerId}&amp;objectName={$tracker_info.name|escape:"url"}&amp;objectHref={'tiki-view_tracker_item.php?trackerId='|cat:$trackerId|cat:'&itemId='|cat:$itemId|escape:"url"}">
75								{icon name="watch-group"} {tr}Group monitor{/tr}
76							</a>
77						</li>
78					{/if}
79				{/if}
80				{if $prefs.sefurl_short_url eq 'y'}
81					<li class="dropdown-item">
82						<a id="short_url_link" href="#" onclick="(function() { $(document.activeElement).attr('href', 'tiki-short_url.php?url=' + encodeURIComponent(window.location.href) + '&title=' + encodeURIComponent(document.title)); })();">
83							{icon name="link"} {tr}Get a short URL{/tr}
84							{assign var="hasPageAction" value="1"}
85						</a>
86					</li>
87				{/if}
88				{if $tiki_p_admin_trackers eq "y"}
89					<li class="dropdown-item">
90						{permission_link mode=text type=trackeritem id=$itemId permType=trackers parentId=$trackerId}
91					</li>
92				{/if}
93                {if $prefs.user_favorites eq 'y' and isset($itemId)}
94					<li class="dropdown-item">
95						{favorite button_classes="favorite-icon" label="{tr}Favorite{/tr}"  type="trackeritem" object=$itemId }
96					</li>
97                {/if}
98			</ul>
99			{if ! $js}</li></ul>{/if}
100		</div>
101		{if $canModify && $prefs.tracker_legacy_insert neq 'y'}
102			{if not empty($smarty.request.from) and $prefs.pwa_feature ne 'y'}{$from = $smarty.request.from}{else}{$from=''}{/if}
103			<a class="btn btn-primary" href="{bootstrap_modal controller=tracker action=update_item trackerId=$trackerId itemId=$itemId redirect=$from size='modal-lg'}">{icon name="edit"} {tr}Edit{/tr}</a>
104		{/if}
105
106		{* only include actions bar if no custom view template is assigned *}
107		{if !$viewItemPretty.override}
108			{include file="tracker_actions.tpl"}
109		{/if}
110
111		{* show button back only if tpl has been set with vi_tpl or ei_tpl *}
112		{if $viewItemPretty.override and !empty($referer)}
113			<a class="btn btn-primary" href="{$referer}" title="{tr}Back{/tr}">{icon name="arrow-circle-left"} {tr}Back{/tr}</a>
114		{/if}
115	</div>
116
117	{if $user and $prefs.feature_user_watches eq 'y' and $category_watched eq 'y'}
118	<div class="categbar">
119		{tr}Watched by categories:{/tr}
120		{section name=i loop=$watching_categories}
121			<a href="tiki-browse_categories.php?parentId={$watching_categories[i].categId}">{$watching_categories[i].name|escape}</a>&nbsp;
122		{/section}
123	</div>
124	{/if}
125
126	{* ------- return/next/previous tab --- *}
127	{if $canView}
128		{pagination_links cant=$cant|default:null offset=$offset reloff=$smarty.request.reloff|default:null itemname="{tr}Item{/tr}"}
129			{* Do not specify an itemId in URL used for pagination, because it will use the specified itemId instead of moving to another item *}
130			{$smarty.server.php_self|default:null}?{query itemId=NULL trackerId=$trackerId}
131		{/pagination_links}
132	{/if}
133
134	{include file='tracker_error.tpl'}
135{else}
136	<style>
137	.tab-content .tab-pane {
138    	display:block;
139	}</style>
140{/if}
141{* print_page *}
142
143
144
145{tabset name='tabs_view_tracker_item' skipsingle=1 toggle=n}
146
147	{* when printing, no js is called to select the tab thus no class "active" assigned (would show nothing). print=y sets this class on printing *}
148	{tab name="{tr}View{/tr}" print=y}
149		{* --- tab with view ------------------------------------------------------------------------- *}
150		{* In most cases one will not want this header when viewing an item *}
151		{* <h3>{$tracker_info.name|escape}</h3> *}
152		{if $tracker_is_multilingual}
153			<div class="translations">
154				<a href="{service controller=translation action=manage type=trackeritem source=$itemId}">{tr}Translations{/tr}</a>
155			</div>
156			{jq}
157				$('.translations a').click(function () {
158					var link = this;
159					$(this).serviceDialog({
160						title: $(link).text(),
161						data: {
162							controller: 'translation',
163							action: 'manage',
164							type: 'trackeritem',
165							source: "{{$itemId|escape}}"
166						}
167					});
168					return false;
169				});
170			{/jq}
171		{/if}
172
173		{* show item *}
174		{trackerfields mode=view trackerId=$trackerId itemId=$itemId fields=$fields itemId=$itemId viewItemPretty=$viewItemPretty.value}
175
176		{* -------------------------------------------------- section with comments --- *}
177		{if $tracker_info.useComments eq 'y' and ($tiki_p_tracker_view_comments ne 'n' or $tiki_p_comment_tracker_items ne 'n' or $canViewCommentsAsItemOwner) and $prefs.tracker_show_comments_below eq 'y'}
178			<a id="Comments"></a>
179			<div id="comment-container-below" class="well well-sm" data-target="{service controller=comment action=list type=trackeritem objectId=$itemId}"></div>
180			{jq}
181				var id = '#comment-container-below';
182				$(id).comment_load($(id).data('target'));
183				$(document).ajaxComplete(function(){
184					$(id).tiki_popover();
185					$(id).applyColorbox();
186				});
187			{/jq}
188
189		{/if}
190
191	{/tab}
192
193	{* -------------------------------------------------- tab with comments --- *}
194	{if $tracker_info.useComments eq 'y' and ($tiki_p_tracker_view_comments ne 'n' or $tiki_p_comment_tracker_items ne 'n' or $canViewCommentsAsItemOwner) and $prefs.tracker_show_comments_below ne 'y'}
195
196		{tab name="{tr}Comments{/tr} (`$comCount`)" print=n}
197			<div id="comment-container" data-target="{service controller=comment action=list type=trackeritem objectId=$itemId}"></div>
198			{jq}
199				var id = '#comment-container';
200				$(id).comment_load($(id).data('target'));
201				$(document).ajaxComplete(function(){$(id).tiki_popover();});
202			{/jq}
203
204		{/tab}
205	{/if}
206
207	{* ---------------------------------------- tab with attachments --- *}
208	{if $tracker_info.useAttachments eq 'y' and $tiki_p_tracker_view_attachments eq 'y'}
209		{tab name="{tr}Attachments{/tr} (`$attCount`)" print=n}
210			{include file='attachments_tracker.tpl'}
211		{/tab}
212	{/if}
213
214	{* --------------------------------------------------------------- tab with edit --- *}
215	{if (! isset($print_page) || $print_page ne 'y') && $canModify && $prefs.tracker_legacy_insert eq 'y'}
216		{tab name=$editTitle}
217			<h2>{tr}Edit Item{/tr}</h2>
218
219			<div class="nohighlight"><table style="width: 100%;"><tr><td> {* Added this table tag as a nasty kludge because (after Bootstrappification) the page is breaking without it. *}
220				{include file="tracker_validator.tpl"}
221
222				{if $tiki_p_admin_trackers eq 'y' and !empty($trackers)}
223					<form role="form">
224						<input type="hidden" name="itemId" value="{$itemId}">
225						<select name="moveto">
226							{foreach from=$trackers item=tracker}
227								{if $tracker.trackerId ne $trackerId}
228									<option value="{$tracker.trackerId}">{$tracker.name|escape}</option>
229								{/if}
230							{/foreach}
231						</select>
232						<input type="submit" class="btn btn-primary btn-sm" name="go" value="{tr}Move to another tracker{/tr}">
233					</form>
234				{/if}
235
236				<form enctype="multipart/form-data" action="{$formAction}" method="post" id="editItemForm">
237					{if $special}
238						<input type="hidden" name="view" value=" {$special}">
239					{else}
240						<input type="hidden" name="trackerId" value="{$trackerId|escape}">
241						<input type="hidden" name="itemId" value="{$itemId|escape}">
242					{/if}
243					{if $from}
244						<input type="hidden" name="from" value="{$from}">
245					{/if}
246					{if $cant}
247						<input type="hidden" name="cant" value="{$cant}">
248					{/if}
249
250					<div class="previewTrackerItem"></div>
251
252					{remarksbox type="warning" title="{tr}Warning{/tr}"}<em class='mandatory_note'>{tr}Fields marked with an * are mandatory.{/tr}</em>{/remarksbox}
253
254					<div class="form-group mx-0">
255								{if count($fields) >= 5}
256									<input type="submit" class="btn btn-primary btn-sm" name="save" value="{tr}Save{/tr}" onclick="needToConfirm=false">
257									{* --------------------------- to return to tracker list after saving --------- *}
258									{if $canView}
259										<input type="submit" class="btn btn-primary btn-sm" name="save_return" value="{tr}Save Returning to Item List{/tr}" onclick="needToConfirm=false">
260
261										{if not empty($saveAndComment) and $saveAndComment neq 'n'}
262											<input type="submit" class="btn btn-primary btn-sm" name="save_and_comment" value="{tr}Save and Comment{/tr}">
263										{/if}
264
265										{if $canRemove}
266											<a class="btn btn-danger btn-sm" href="tiki-view_tracker.php?trackerId={$trackerId}&amp;remove={$itemId}" title="{tr}Delete{/tr}">{icon name='delete' alt="{tr}Delete{/tr}"}</a>
267										{/if}
268									{/if}
269								{/if}
270					</div>
271																	{* ------------------- *}
272						{if $tracker_info.showStatus eq 'y' or ($tracker_info.showStatusAdminOnly eq 'y' and $tiki_p_admin_trackers eq 'y')}
273							<div class="form-group row">
274								<label class="col-form-label col-sm-3">{tr}Status{/tr}</label>
275								<div class="col-sm-9">
276									{include file='tracker_status_input.tpl' item=$item_info form_status=edstatus}
277								</div>
278							</div>
279						{/if}
280
281						{* no template defined in the tracker *}
282						{if empty($editItemPretty.value)}
283
284							{foreach from=$ins_fields key=ix item=cur_field}
285								<div class="form-group row">
286									<label class="col-sm-3 {if $cur_field.type eq 'h'}h{$cur_field.options_map.level}{else}col-form-label{/if}">
287										{$cur_field.name|tra|escape}
288										{if $cur_field.isMandatory eq 'y'}
289											<strong class='mandatory_star text-danger tips' title=":{tr}This field is mandatory{/tr}">*</strong>
290										{/if}
291									</label>
292									<div class="col-sm-9">
293										{trackerinput field=$cur_field item=$item_info inTable=formcolor showDescription=y}
294									</div>
295								</div>
296							{/foreach}
297
298						{else}
299						{* we have a preset template: it could be a wiki:myPage or a tpl:MyTpl.tpl *}
300						{* Note: tracker plugin usally consumes a pagename or a tpl filename without a prefix of tpl: or wiki: as the tracker definition does *}
301							<div class="form-group row">
302
303								{if $editItemPretty.type eq 'wiki'}
304									{wikiplugin _name=tracker trackerId=$trackerId itemId=$itemId view=page wiki=$editItemPretty.value formtag='n'}{/wikiplugin}
305								{else}
306									{wikiplugin _name=tracker trackerId=$trackerId itemId=$itemId view=page tpl=$editItemPretty.value formtag='n'}{/wikiplugin}
307								{/if}
308
309							</div>
310						{/if}
311
312						{if $groupforalert ne ''}
313
314							<div class="form-group row">
315								<div class="col-sm-3">{tr}Choose users to alert{/tr}</div>
316								<div class="col-sm-9">
317									{section name=idx loop=$listusertoalert}
318										{if $showeachuser eq ''}
319											<input type="hidden" name="listtoalert[]" value="{$listusertoalert[idx].user}">
320										{else}
321											<input type="checkbox" name="listtoalert[]" value="{$listusertoalert[idx].user}"> {$listusertoalert[idx].user}
322										{/if}
323									{/section}
324								</div>
325
326							</div>
327						{/if}
328
329
330						{* -------------------- antibot code -------------------- *}
331						{if $prefs.feature_antibot eq 'y' && $user eq ''}
332							{include file='antibot.tpl'}
333						{/if}
334						<div class="form-group mx-0">
335								<input type="submit" class="btn btn-primary btn-sm" name="save" value="{tr}Save{/tr}" onclick="needToConfirm=false">
336								{* --------------------------- to return to tracker list after saving --------- *}
337								{if $canView}
338									<input type="submit" class="btn btn-primary btn-sm" name="save_return" value="{tr}Save Returning to Item List{/tr}" onclick="needToConfirm=false">
339								{/if}
340								{if not empty($saveAndComment) and $saveAndComment neq 'n'}
341									<input type="submit" class="btn btn-primary btn-sm" name="save_and_comment" value="{tr}Save and Comment{/tr}">
342								{/if}
343
344								{if $canRemove}
345									<a class="link tips text-danger" href="tiki-view_tracker.php?trackerId={$trackerId}&amp;remove={$itemId}" title=":{tr}Delete{/tr}">
346										{icon name='remove'}
347									</a>
348								{/if}
349								{if $item_info.logs.cant}
350									<a class="link tips" href="tiki-tracker_view_history.php?itemId={$itemId}" title=":{tr}History{/tr}">
351										{icon name='history'}
352									</a>
353								{/if}
354								{if $tiki_p_admin_trackers eq 'y' && empty($trackers)}
355									<a class="link tips" href="tiki-view_tracker_item.php?itemId={$itemId}&moveto" title=":{tr}Move to another tracker{/tr}">
356										{icon name='next'}
357									</a>
358								{/if}
359
360						</div>
361
362
363					{* ------------------- *}
364				</form>
365
366				{foreach from=$ins_fields item=cur_field}
367					{if $cur_field.type eq 'x'}
368						{capture name=trkaction}
369							<form action="{$cur_field.options_array[2]}" {if $cur_field.options_array[1] eq 'post'}method="post"{else}method="get"{/if}>
370								{section name=tl loop=$cur_field.options_array start=3}
371									{assign var=valvar value=$cur_field.options_array[tl]|regex_replace:"/^[^:]*:/":""|escape}
372									{if $info.$valvar eq ''}
373										{assign var=valvar value=$cur_field.options_array[tl]|regex_replace:"/^[^\=]*\=/":""|escape}
374										<input type="hidden" name="{$cur_field.options_array[tl]|regex_replace:"/\=.*$/":""|escape}" value="{$valvar|escape}">
375									{else}
376										<input type="hidden" name="{$cur_field.options_array[tl]|regex_replace:"/:.*$/":""|escape}" value="{$info.$valvar|escape}">
377									{/if}
378								{/section}
379								<div class="form-group row">
380										<div class="col-sm-6">
381											{$cur_field.name|tra}
382										</div>
383										<div class="col-sm-6">
384											<input type="submit" class="btn btn-primary btn-sm" name="trck_act" value="{$cur_field.options_array[0]|escape}" >
385										</div>
386								</div>
387							</form>
388						{/capture}
389						{assign var=trkact value=$trkact|cat:$smarty.capture.trkaction}
390					{/if}
391				{/foreach}
392				{if $trkact}
393					<h2>{tr}Special Operations{/tr}</h2>
394					{$trkact}
395				{/if}
396			</td></tr></table></div><!--nohighlight-->{*important comment to delimit the zone not to highlight in a search result*}
397		{/tab}
398	{/if}
399
400{/tabset}
401
402<br><br>
403
404{if isset($print_page) and $print_page eq 'y' and $prefs.print_original_url_tracker eq 'y'}
405	{tr}The original document is available at{/tr} <a href="{$base_url|escape}{$itemId|sefurl:trackeritem}">{$base_url|escape}{$itemId|sefurl:trackeritem}</a>
406{/if}
407