1{* $Id$ *}
2
3{title url='tiki-admin_surveys.php' help="Surveys"}{tr}Admin surveys{/tr}{/title}
4
5<div class="t_navbar btn-group form-group row">
6	{button href="tiki-list_surveys.php" class="btn btn-info" _icon_name="list" _text="{tr}List{/tr}"}
7	{button href="tiki-survey_stats.php" class="btn btn-info" _icon_name="chart" _text="{tr}Stats{/tr}"}
8	{button surveyId=0 _anchor='content_admin_surveys1-2' _auto_args="surveyId" class="btn btn-primary" _icon_name="create" _text="{tr}Create{/tr}"}
9</div>
10
11{tabset}
12
13	{tab name="{tr}Surveys{/tr}"}
14		<h2>{tr}Surveys{/tr}</h2>
15		{if $channels or ($find ne '')}
16			{include file='find.tpl'}
17		{/if}
18
19		<div class="{if $js}table-responsive{/if}"> {* table-responsive class cuts off css drop-down menus *}
20			<table class="table table-striped table-hover">
21				<tr>
22					<th>
23						{self_link _sort_arg='sort_mode' _sort_field='surveyId'}{tr}ID{/tr}{/self_link}
24					</th>
25					<th>
26						{self_link _sort_arg='sort_mode' _sort_field='name'}{tr}Survey{/tr}{/self_link}
27					</th>
28					<th>
29						{self_link _sort_arg='sort_mode' _sort_field='status'}{tr}Status{/tr}{/self_link}
30					</th>
31					<th>{tr}Questions{/tr}</th>
32					<th></th>
33				</tr>
34
35				{section name=user loop=$channels}
36					<tr>
37						<td class="id">{$channels[user].surveyId}</td>
38						<td class="text">
39							<b>{$channels[user].name|escape}</b>
40							<div class="subcomment">
41								{wiki}{$channels[user].description}{/wiki}
42							</div>
43						</td>
44						<td class="icon">
45							{if $channels[user].status eq 'o'}
46								{icon name='unlock' class='tips' title=":{tr}Open{/tr}"}
47							{else}
48								{icon name='lock' class='tips' title=":{tr}Closed{/tr}"}
49							{/if}
50						</td>
51						<td class="integer"><span class="badge badge-secondary">{$channels[user].questions}</span></td>
52						<td class="action">
53							{actions}
54								{strip}
55									<action>
56										<a href="tiki-admin_survey_questions.php?surveyId={$channels[user].surveyId}">
57											{icon name='list' _menu_text='y' _menu_icon='y' alt="{tr}Questions{/tr}"}
58										</a>
59									</action>
60									<action>
61										{permission_link mode=text type=survey permType=surveys id=$channels[user].surveyId title=$channels[user].name}
62									</action>
63									{if ($tiki_p_admin eq 'y') or ($channels[user].individual eq 'n' and $tiki_p_view_survey_stats eq 'y') or ($channels[user].individual_tiki_p_view_survey_stats eq 'y')}
64										<action>
65											<a href="tiki-survey_stats_survey.php?surveyId={$channels[user].surveyId}">
66											{icon name='chart' _menu_text='y' _menu_icon='y' alt="{tr}Stats{/tr}"}
67											</a>
68										</action>
69									{/if}
70								 	<action>
71										{self_link _icon_name='edit' _anchor='content_admin_surveys1-2' _menu_text='y' _menu_icon='y' surveyId=$channels[user].surveyId}
72											{tr}Edit{/tr}
73										{/self_link}
74									</action>
75									<action>
76										<a href="tiki-admin_surveys.php?offset={$offset}&amp;sort_mode={$sort_mode}&amp;remove={$channels[user].surveyId}">
77											{icon name='remove' _menu_text='y' _menu_icon='y' alt="{tr}Remove{/tr}"}
78										</a>
79									</action>
80								{/strip}
81							{/actions}
82						</td>
83					</tr>
84				{sectionelse}
85					{norecords _colspan=5}
86				{/section}
87			</table>
88		</div>
89
90		{pagination_links cant=$cant_pages step=$prefs.maxRecords offset=$offset}{/pagination_links}
91	{/tab}
92
93	{tab name="{tr}Create/Edit Surveys{/tr}"}
94		{if $info.surveyId > 0}
95			<h2>{tr}Edit this Survey:{/tr} {$info.name}</h2>
96		{else}
97			<h2>{tr}Create New Survey{/tr}</h2>
98		{/if}
99
100		{if $individual eq 'y'}
101			{permission_link mode=link type=survey permType=surveys id=$info.surveyId title=$info.name label="{tr}There are individual permissions set for this survey{/tr}"}
102		{/if}
103
104		<form action="tiki-admin_surveys.php" method="post" class="form-horizontal" role="form">
105			<div class="form-group row">
106				<input type="hidden" name="surveyId" value="{$info.surveyId|escape}">
107				<label for="name" class="col-sm-2 col-form-label">{tr}Name{/tr}</label>
108				<div class="col-sm-10">
109					<input type="text" name="name" id="name" class="form-control" value="{$info.name|escape}">
110				</div>
111			</div>
112			<div class="form-group row">
113				<label for="description" class="col-sm-2 col-form-label">{tr}Description{/tr}</label>
114				<div class="col-sm-10">
115					{textarea name="description" rows="6" id="description" class="form-control" _toolbars='y' _simple='y' comments='y'}{$info.description}{/textarea}
116				</div>
117			</div>
118			<div class="mb-4">
119				{include file='categorize.tpl' labelcol='2' inputcol='10'}
120			</div>
121			<div class="form-group row">
122				<label for="status" class="col-sm-2 col-form-label">{tr}Status{/tr}</label>
123				<div class="col-sm-10">
124					<select name="status" class="form-control">
125						<option value="o" {if $info.status eq 'o'}selected='selected'{/if}>{tr}Open{/tr}</option>
126						<option value="c" {if $info.status eq 'c'}selected='selected'{/if}>{tr}Closed{/tr}</option>
127					</select>
128				</div>
129			</div>
130			<div class="form-group row">
131				<div class="col-sm-10 offset-sm-2">
132					<input type="submit" class="btn btn-secondary" name="save" value="{tr}Save{/tr}">
133				</div>
134			</div>
135		</form>
136	{/tab}
137
138{/tabset}
139