<?php
$index = $_GET['index'];
$error_messages = __('front_sys', true);
?>
<div class="container-fluid pjTsContainer">
	<?php include PJ_VIEWS_PATH . 'pjLoad/elements/header.php'; ?>
	<div class="panel panel-default pjTsBody">
		<header class="panel-heading text-center">
			<p class="panel-title"><?php __('front_add_ticket'); ?></p><!-- /.panel-title -->
		</header><!-- /.panel-heading text-center -->

		<div class="panel-body">
			<form id="pjTsAddTicketForm_<?php echo $index; ?>" action="<?php echo PJ_INSTALL_URL; ?>index.php?controller=pjLoad&amp;action=pjActionAddTicket" method="post" class="form-horizontal pjTsForm pjTsFormSendTicket" data-toggle="validator" role="form">
				<input type="hidden" name="add_ticket" value="1" />
				
				<div class="row">
					<?php
					if( $tpl['option_arr']['o_select_departments'] == 'Yes' && !empty($tpl['department_arr']))
					{ 
						?>
						<div class="form-group">
							<label for="" class="col-sm-3 control-label"><?php __('front_contact_department'); ?></label>
						
							<div class="col-sm-6">
								<select name="department_id" class="form-control required" data-msg-required="<?php echo $error_messages['add_department'];?>">
									<option value="">-- <?php __('lblChoose'); ?>--</option>
									<?php
									foreach ($tpl['department_arr'] as $k => $v)
									{
										if(isset($tpl['previousPost']))
										{
											?><option value="<?php echo $v['id']; ?>" <?php echo $tpl['previousPost']['department_id'] == $v['id'] ? 'selected="selected"' : null; ?>><?php echo $v['name']; ?></option><?php
										}else{
											?><option value="<?php echo $v['id']; ?>"><?php echo $v['name']; ?></option><?php
										}
									}
									?>
								</select>
							</div><!-- /.col-sm-6 -->
						</div><!-- /.form-group -->
						<?php
					} 
					?>
					
					<div class="form-group">
						<label for="" class="col-sm-3 control-label"><?php __('front_contact_message'); ?></label>
					
						<div class="col-sm-8">
							<textarea name="message" cols="30" rows="10" class="form-control required" data-msg-required="<?php echo $error_messages['add_message'];?>"><?php echo isset($tpl['previousPost']) ? $tpl['previousPost']['message'] : null;?></textarea>
							<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
						</div><!-- /.col-sm-8 -->
					</div><!-- /.form-group -->
					<?php
					if( $tpl['option_arr']['o_upload_files'] == 'Yes' )
					{ 
						$accept_msg = sprintf($error_messages['file_ext'], $tpl['option_arr']['o_file_allowed']);
						?>
						<div class="form-group">
							<div class="pjTsAddFile">
								<label for="" class="col-sm-3 control-label"><?php __('lblReplyFiles'); ?></label>

								<div class="col-sm-8">
									<div class="btn btn-default pjTsBtn pjTsBtnFile pjTsBtnUpload">
										<?php __('front_add_file');?>
																		
										<input type="file" name="files[]" class="pjTsFileUploadField" multiple="multiple" data-msg-extension="<?php echo $accept_msg;?>"/>
									</div>
															
									<a href="#" class="btn btn-default pjTsBtn pjTsBtnFile pjTsBtnReset"><?php __('front_add_file');?></a>

									<p class="pjTsUploadedFiles"></p><!-- /.pjTsUploadedFiles -->
									<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
								</div><!-- /.col-sm-8 -->
							</div><!-- /.pjTsAddFile -->
						</div><!-- /.form-group -->
						<?php
					}
					if(!$controller->checkLogin())
					{ 
						?>
						<div class="form-group pjTsCaptcha">
							<label for="" class="col-sm-3 control-label"><?php __('front_verification');?></label>
						
							<div class="col-sm-6">
								<input type="text" name="verification" maxlength="6" autocomplete="off" class="form-control required" data-msg-required="<?php echo $error_messages['add_verification'];?>" data-msg-remote="<?php echo $error_messages['add_verification_inv'];?>"/>
								<img id="pjTsCaptchaImage_<?php echo $index;?>" src="<?php echo PJ_INSTALL_URL; ?>index.php?controller=pjFront&amp;action=pjActionCaptcha&amp;rand=<?php echo rand(1, 999999); ?><?php echo isset($_GET['session_id']) ? '&session_id=' . $_GET['session_id'] : NULL;?>" alt="" />
								<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
							</div><!-- /.col-sm-6 -->
						</div><!-- /.form-group pjTsCaptcha -->
						<?php
					} 
					?>
					
					<div class="form-group">
						<div class="col-sm-9 col-sm-offset-3">
							<button type="submit" class="btn btn-default pjTsBtn pjTsBtnPrimary"><?php __('front_button_save'); ?></button>
						</div><!-- /.col-sm-9 col-sm-offset-3 -->
					</div><!-- /.form-group -->
					<div class="form-group" style="display: none;">
						<div class="col-sm-9 col-sm-offset-3">
							<p id="pjTsMessage_<?php echo $index;?>" class=""></p>
						</div><!-- /.col-sm-6 col-sm-offset-3 -->
					</div><!-- /.form-group -->
					
				</div><!-- /.row -->
			</form><!-- /.form-horizontal pjTsForm pjTsFormSendTicket -->
		</div><!-- /.panel-body -->
	</div><!-- /.panel panel-default pjTsBody -->
</div><!-- /.container-fluid pjTsContainer -->						