<?php TPL::output('admin/global/header.tpl.htm'); ?>

<!--left-->
<?php TPL::output('admin/global/left.tpl.htm'); ?>
<!--left-->

<!-- main -->
<div id="main-content">
	<div class="clear"></div>
	<div class="content-box">
		<div class="content-box-header">
			<h3>Question Manage</h3>
			<ul class="content-box-tabs">
				<li><a href="#tab1" class="default-tab current">Question list</a></li>
				<li><a href="#tab2" class="">Search</a></li>
			</ul>
			<div class="clear"></div>
		</div>
		<div class="content-box-content">
			<div class="tab-content default-tab" id="tab1">
			
				<?php if($_GET['action'] == 'search'){ ?>
					<div style="margin-bottom:5px;">There are <?php echo intval($this->question_num); ?> qualifying content.</div>
				<?php } ?>
				
				<?php if($this->list){ ?>
				<form id="batchs_form" action="admin/question/question_batch/" method="post">
					<table class="list">
						<thead>
							<tr>
								<th style="width:20px;"><input type="checkbox" class="check-all"></th>
								<th style="width:280px;">Question title</th>
								<?php if(get_setting('category_enable') == 'Y'){ ?>
								<th><a href="<?php echo $this->search_url; ?>__sort_key-category_id__order-<?php if($_GET['sort_key'] == 'category_id' && $_GET['order'] == 'ASC'){ ?>DESC<?php }else{ ?>ASC<?php } ?>">Classification<?php if($_GET['sort_key'] == 'category_id'){ ?><?php if($_GET['order'] == 'ASC'){ ?><em class="listup">&uarr;</em><?php }else{ ?><em class="listdown">&darr;</em><?php } ?><?php } ?></a></th>
								<?php } ?>
								<th>View topic</th>
								<th><a href="<?php echo $this->search_url; ?>__sort_key-answer_count__order-<?php if($_GET['sort_key'] == 'answer_count' && $_GET['order'] == 'DESC'){ ?>ASC<?php }else{ ?>DESC<?php } ?>">Answers<?php if($_GET['sort_key'] == 'answer_count'){ ?><?php if($_GET['order'] == 'ASC'){ ?><em class="listup">&uarr;</em><?php }else{ ?><em class="listdown">&darr;</em><?php } ?><?php } ?></a></th>
								<th><a href="<?php echo $this->search_url; ?>__sort_key-view_count__order-<?php if($_GET['sort_key'] == 'view_count' && $_GET['order'] == 'DESC'){ ?>ASC<?php }else{ ?>DESC<?php } ?>">Views<?php if($_GET['sort_key'] == 'view_count'){ ?><?php if($_GET['order'] == 'ASC'){ ?><em class="listup">&uarr;</em><?php }else{ ?><em class="listdown">&darr;</em><?php } ?><?php } ?></a></th>
								<th><a href="<?php echo $this->search_url; ?>__sort_key-unverified_modify__order-<?php if($_GET['sort_key'] == 'unverified_modify' && $_GET['order'] == 'DESC'){ ?>ASC<?php }else{ ?>DESC<?php } ?>">Confirm edit<?php if($_GET['sort_key'] == 'unverified_modify'){ ?><?php if($_GET['order'] == 'ASC'){ ?><em class="listup">&uarr;</em><?php }else{ ?><em class="listdown">&darr;</em><?php } ?><?php } ?></a></th>
								<th><a href="<?php echo $this->search_url; ?>__sort_key-published_uid__order-<?php if($_GET['sort_key'] == 'published_uid' && $_GET['order'] == 'ASC'){ ?>DESC<?php }else{ ?>ASC<?php } ?>">Author<?php if($_GET['sort_key'] == 'published_uid'){ ?><?php if($_GET['order'] == 'ASC'){ ?><em class="listup">&uarr;</em><?php }else{ ?><em class="listdown">&darr;</em><?php } ?><?php } ?></a></th>
								<th><a href="<?php echo $this->search_url; ?>__sort_key-add_time__order-<?php if($_GET['sort_key'] == 'add_time' && $_GET['order'] == 'ASC'){ ?>DESC<?php }else{ ?>ASC<?php } ?>">Published time<?php if($_GET['sort_key'] == 'add_time'){ ?><?php if($_GET['order'] == 'ASC'){ ?><em class="listup">&uarr;</em><?php }else{ ?><em class="listdown">&darr;</em><?php } ?><?php } ?></a></th>
								<th><a href="<?php echo $this->search_url; ?>__sort_key-update_time__order-<?php if($_GET['sort_key'] == 'update_time' && $_GET['order'] == 'ASC'){ ?>DESC<?php }else{ ?>ASC<?php } ?>">Last updated<?php if($_GET['sort_key'] == 'update_time'){ ?><?php if($_GET['order'] == 'ASC'){ ?><em class="listup">&uarr;</em><?php }else{ ?><em class="listdown">&darr;</em><?php } ?><?php } ?></a></th>
								<th>Operation</th>
							</tr>
						</thead>
						<tfoot>
							<tr>
								<td colspan="11">
									<div class="bulk-actions align-left"><a class="button" onClick="ajax_post($('#batchs_form'), _ajax_post_alert_processer); return false;" href="javascript:;">Delete selected</a></div>
									<div class="pagination"><?php echo $this->pagination; ?></div>
									<div class="clear"></div>
								</td>
							</tr>
						</tfoot>
						<tbody style="border-bottom: 1px solid #ddd;">
							<?php foreach ($this->list AS $key => $val) { ?>
							<tr>
								<td><input type="checkbox" name="question_ids[]" value="<?php echo $val['question_id']; ?>"></td>
								<td><a href="question/<?php echo $val['question_id']; ?>" target="_blank" title="View Issues"><?php echo $val['question_content']; ?></a></td>
								<?php if(get_setting('category_enable') == 'Y'){ ?>
								<td><a href="admin/question/question_list/action-<?php echo $_GET['action']; ?>__category_id-<?php echo $val['category']['id']; ?>"><?php echo $val['category']['title']; ?></a></td>
								<?php } ?>
								<td><?php if($val['topics']){ ?><?php foreach($val['topics'] as $topic){ ?><a href="topic/<?php echo $topic['url_token']?>" target="_blank"><?php echo $topic['topic_title']; ?></a>&nbsp;<?php } ?><?php } ?></td>
								<td><?php if($val['answer_count']){ ?><a href="admin/question/answer_list/question_id-<?php echo $val['question_id']; ?>" title="Check and reply"><?php echo $val['answer_count']; ?></a><?php }else{ ?>0<?php } ?></td>
								<td><?php echo $val['view_count']; ?></td>
								<td><?php if($val['unverified_modify']){ ?><a href="question/id-<?php echo $val['question_id']; ?>__column-log__rf-false" target="_blank">Have</a><?php }else{ ?>No<?php } ?></td>
								<td><a href="people/<?php echo $val['user']['url_token']; ?>" target="_blank"><?php echo $val['user']['user_name']; ?></a></td>
								<td><?php echo date("Y-m-d H:i", $val['add_time']); ?></td>
								<td><?php echo date("Y-m-d H:i", $val['update_time']); ?></td>
								<td>
									<a href="publish/question_id-<?php echo $val['question_id']; ?>#question" title="Modification" target="_blank"><img src="<?php echo GET_STATIC_URL;?>/admin/images/icons/pencil.png" alt="Modification" /></a> </td>
							</tr>
							<?php } ?>
						</tbody>
					</table>
				</form>
				<?php } ?>
			</div>
			
			<div class="tab-content" id="tab2" style="display:none;">
				<form method="post" action="admin/question/question_list/" onsubmit="return false;" id="search_form">
				<input name="action" type="hidden" value="search"/>
				<p>
					<label> Keyword:</label>
					<input type="text" value="<?php echo rawurldecode($_GET['keyword']); ?>" name="keyword" class="text-input small-input">
				</p>
				<div style="margin-top:5px;">
					<label> Category:</label>
					<p style="width:100%; margin-bottom:5px; padding-bottom:3px;">
					<select name="category_id" style="float:left; width:200px;">
						<option value="0"></option>
						<?php echo $this->category_list; ?>
					</select>
					<label style=" float:left; padding-top:7px;margin-left:10px;"><input type="checkbox" value="1" name="category_child"<?php if(!$_GET['action'] || $_GET['category_child'] == '1'){ ?> checked="true"<?php } ?>> Include subcategories</label>
					</p>
				</div>
				<p>
					<label style="clear:both;"> Period of published time:</label>
					<input type="text" value="<?php echo base64_decode($_GET['start_date']); ?>" name="start_date" class="text-input date_picker" style="width:150px;"> -- <input type="text" value="<?php echo base64_decode($_GET['end_date']); ?>" name="end_date" class="text-input date_picker" style="width:150px;">
				</p>
				<p>
					<label> Author:</label>
					<input type="text" value="<?php echo rawurldecode($_GET['username']); ?>" name="username" class="text-input small-input">
				</p>
				<p>
					<label> Answers:</label>
					<input type="text" name="answer_count_min" value="<?php echo $_GET['answer_count_min']; ?>" class="text-input" style="width:40px;"> - <input type="text" name="answer_count_max" value="<?php echo $_GET['answer_count_max']; ?>" class="text-input" style="width:40px;">
				</p>
				<p>
					<label> Contains topics:</label>
					<input type="text" value="<?php echo rawurldecode($_GET['topic']); ?>" name="topic" id="topic" class="text-input small-input">
				</p>
				<p>
					<label> Whether there is a best reply:<input type="checkbox" value="1" name="best_answer"<?php if($_GET['best_answer'] == '1'){ ?> checked="true"<?php } ?>> There is a best reply</label>
				</p>
				<p style="clear:both;">
					<input type="button" onclick="ajax_post($('#search_form'), _form_process);" value="Search" class="button">
				</p>
				</form>
			</div>
			
		</div>
		<div class="clear"></div>
		<div id="notf_tip" style="display:none;" class="notification png_bg"> <a href="javascript:;" class="close"><img src="<?php echo GET_STATIC_URL;?>/admin/images/icons/cross_grey_small.png" alt="Close" /></a>
			<div id="notf_cont"></div>
		</div>
	</div>

<!-- footer -->
<?php TPL::output('admin/global/footer.tpl.htm'); ?>
<!-- footer -->

</div>
<!-- main -->

</div>

</body>
</html>