<?php $this->load->view('header');?>

	<!-- BEGIN PAGE HEADER-->

	<div class="row-fluid">

		<div class="span12">

			<!-- BEGIN PAGE TITLE & BREADCRUMB-->

			<h3 class="page-title"><?php echo $this->lang->line('hf_compose_message');?></h3>

			<ul class="breadcrumb">

				<li>

					<i class="icon-home"></i>

					<a href="<?php echo base_url();?>home/"><?php echo $this->lang->line('hf_home');?></a> 

					<i class="icon-angle-right"></i>

				</li>
				<li><?php echo $this->lang->line('hf_private_message');?> <i class="icon-angle-right"></i></li>

				<li>

					<?php echo $this->lang->line('hf_compose_message');?>

				</li>
			</ul>

			<!-- END PAGE TITLE & BREADCRUMB-->

		</div>

	</div>

	<!-- END PAGE HEADER-->

	<!-- BEGIN PAGE CONTENT-->

	<div class="row-fluid">

		<div class="span12">

			<div class="portlet box blue">

				<div class="portlet-title">

					<div class="caption"><i class="icon-reorder"></i><?php echo $this->lang->line('hf_compose_message');?></div>

				</div>

				<div class="portlet-body form">

					<form id="message-form" class="form-horizontal" method="post" action="<?php echo base_url();?>message/compose_submit/" onsubmit="return validateForm('message-form')">
						<?php 
							$alert_box = '';
							$alert_msg = '';
							
							if($this->session->userdata('form_msg_type') == 100) {
								$alert_box = 'success';
								$alert_msg = $this->session->userdata('form_msg');
							}
							else if($this->session->userdata('form_msg_type') == 200) {
								$alert_box = 'error';
								$alert_msg = $this->session->userdata('form_msg');
							}
							
							if($this->session->userdata('form_msg_type') == 100 OR $this->session->userdata('form_msg_type') == 200) {
								$this->session->unset_userdata(array('form_msg_type' => '', 'form_msg' => ''));
							}

							if( ! empty($alert_msg)) {
						?>
						<div class="alert alert-<?php echo $alert_box;?>">
							<button class="close" data-dismiss="alert"></button>
							<?php echo $alert_msg;?>
						</div>
						<?php }?>
						
						<div class="control-group">
							<label class="control-label"><?php echo $this->lang->line('member_include_username');?></label>
							<div class="controls">
								<input id="tags_2" name="include_usernames" type="text" class="medium tags" value="<?php echo isset($include_usernames) ? htmlspecialchars($include_usernames, ENT_QUOTES) : '';?>" />
							</div>
						</div>
						
						<div class="control-group">
							<label class="control-label"><?php echo $this->lang->line('member_exclude_username');?></label>
							<div class="controls">
								<input id="tags_3" name="exclude_usernames" type="text" class="medium tags" value="<?php echo isset($exclude_usernames) ? htmlspecialchars($exclude_usernames, ENT_QUOTES) : '';?>" />
							</div>
						</div>
						
						<div class="control-group">
							<label class="control-label"><?php echo $this->lang->line('member_register_date');?></label>
							<div class="controls">
								<select id="search_register_date" name="search_register_date" class="medium m-wrap" tabindex="1">
									<option <?php echo (isset($search_register_date) && $search_register_date == 1) ? 'selected="selected"' : '';?> value="1"><?php echo $this->lang->line('member_register_date_all');?></option>
									<option <?php echo (isset($search_register_date) && $search_register_date == 2) ? 'selected="selected"' : '';?> value="2"><?php echo $this->lang->line('member_register_date_custom');?></option>
								</select>
							</div>
						</div>								
										
						<div id="custom_date_panel" <?php echo (isset($search_register_date) && $search_register_date == 2) ? '' : 'class="no_display"';?>>
							<div class="control-group">
								<label class="control-label"><?php echo $this->lang->line('member_start_date');?></label>
								<div class="controls">
									<div class="input-append date date-picker" data-date="<?php echo date('d-m-Y');?>" data-date-format="dd-mm-yyyy" data-date-viewmode="years">
										<input class="m-wrap m-ctrl-medium date-picker" readonly size="16" type="text" name="search_start_date" value="<?php echo isset($search_start_date) ? htmlspecialchars($search_start_date, ENT_QUOTES) : date('m/d/Y');?>" /><span class="add-on"><i class="icon-calendar"></i></span>
									</div>
								</div>
							</div>
							<div class="control-group">
								<label class="control-label"><?php echo $this->lang->line('member_end_date');?></label>
								<div class="controls">
									<div class="input-append date date-picker" data-date="<?php echo date('d-m-Y');?>" data-date-format="dd-mm-yyyy" data-date-viewmode="years">
										<input class="m-wrap m-ctrl-medium date-picker" readonly size="16" type="text" name="search_end_date" value="<?php echo isset($search_end_date) ? htmlspecialchars($search_end_date, ENT_QUOTES) : date('m/d/Y');?>" /><span class="add-on"><i class="icon-calendar"></i></span>
									</div>
								</div>
							</div>
						</div>
						
						<div class="control-group">
							<label class="control-label"><?php echo $this->lang->line('member_member_type');?></label>
							<div class="controls">
								<div class="row-fluid">
									<?php
									if($this->session->userdata('member_search_register_date')) {
										$op1 = '';
										$op2 = '';
										$op3 = '';
										$op4 = '';
										$op5 = '';
										$op6 = '';
										$arr = explode(',', $this->session->userdata('member_search_member_type'));
										foreach($arr as $v) {
											switch($v) {
												case 1: $op1 = 'checked="checked"'; break;
												case 2: $op2 = 'checked="checked"'; break;
												case 3: $op3 = 'checked="checked"'; break;
												case 4: $op4 = 'checked="checked"'; break;
												case 5: $op5 = 'checked="checked"'; break;
												case 6: $op6 = 'checked="checked"'; break;
											}
										}
									?>
									<div class="span10 paddingTop7">
										<label class="checkbox line inline-label">
											<input type="checkbox" name="search_member_type[]" value="1" <?php echo $op1;?> /> <?php echo $this->lang->line('registration_empty_sales');?>
										</label>
										<label class="checkbox line inline-label">
											<input type="checkbox" name="search_member_type[]" value="2" <?php echo $op2;?> /> <?php echo $this->lang->line('registration_real_sales');?>
										</label>
										<label class="checkbox line inline-label">
											<input type="checkbox" name="search_member_type[]" value="3" <?php echo $op3;?> /> <?php echo $this->lang->line('registration_borrow_sales');?>
										</label>
									</div>
									<?php
									}
									else {
									?>
									<div class="span10 paddingTop7">
										<label class="checkbox line inline-label">
											<input type="checkbox" name="search_member_type[]" value="1" checked="checked" /> <?php echo $this->lang->line('registration_empty_sales');?>
										</label>
										<label class="checkbox line inline-label">
											<input type="checkbox" name="search_member_type[]" value="2" checked="checked" /> <?php echo $this->lang->line('registration_real_sales');?>
										</label>
										<label class="checkbox line inline-label">
											<input type="checkbox" name="search_member_type[]" value="3" checked="checked" /> <?php echo $this->lang->line('registration_borrow_sales');?>
										</label>
									</div>
									<?php }?>
								</div>
							</div>
						</div>
						
						<div class="control-group">
							<label class="control-label"><?php echo $this->lang->line('message_subject');?> <span class="mandatory">*</span></label>
							<div class="controls">
								<input type="text" id="message_subject" name="message_subject" class="m-wrap large" value="<?php echo isset($message_subject) ? htmlspecialchars($message_subject, ENT_QUOTES) : '';?>" />
							</div>
						</div>
						<div class="control-group">
							<label class="control-label"><?php echo $this->lang->line('message_message');?> <span class="mandatory">*</span></label>
							<div class="controls">
								<textarea id="message_message" name="message_message" class="span10 wysihtml5 m-wrap" rows="15"><?php echo isset($message_message) ? htmlspecialchars($message_message, ENT_QUOTES) : '';?></textarea>
							</div>
						</div>					
						<div class="form-actions">
							<input class="no_display" type="hidden" id="<?php echo $this->security->get_csrf_token_name(); ?>" name="<?php echo $this->security->get_csrf_token_name(); ?>" value="<?php echo $this->security->get_csrf_hash(); ?>" />
							<button type="submit" class="btn blue"><i class="icon-ok"></i> <?php echo $this->lang->line('message_submit');?></button>
						</div>
					</form>

					<!-- END FORM-->

				</div>

			</div>

		</div>

	</div>

	<!-- END PAGE CONTENT -->

<?php $this->load->view('footer');?>