 <!--Rickh Text Editor-->
<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>assets/admin/assets/bootstrap-wysihtml5/bootstrap-wysihtml5.css" />
<div class="row">
  <div class="col-md-12">
    <?php echo $this->session->flashdata('msg');?>

       <form class="form-horizontal" action="<?php echo site_url('admin/realestate/sendbulkemail');?>" method="post">

        <div class="box">

          <div class="box-title">
            <h3><i class="fa fa-bars"></i>Bulk Email</h3>
            <div class="box-tool">
              <a href="#" data-action="collapse"><i class="fa fa-chevron-up"></i></a>
            </div>
          </div>

          <div class="box-content">

         <div class="form-group">
              <label class="col-sm-3 col-lg-2 control-label">To :</label>
              <div class="col-sm-4 col-lg-5 controls">
                <select class="form-control col-md-12 to-emails" name="to[]" id="to" multiple="multiple">
                  <?php
                  $emails = array();
                  foreach($posts->result() as $row){  
                    $val = $row->value;
                    $val = json_decode($val);
                    if(isset($emails[$val->sender_email])==FALSE)
                    {
                      $emails[$val->sender_email] = 1;
                      $sel = (isset($_POST['to']) && in_array($val->sender_email, $_POST['to']))?'selected="selected"':'';
                  ?>
                    <option value="<?php echo $val->sender_email;?>" <?php echo $sel;?>><?php echo $val->sender_email;?></option>
                  <?php
                    }
                  }
                  ?>
                </select>
                <?php echo form_error('to');?>
                <span class="help-inline"><a href="#" onclick="jQuery('#to option').prop('selected', true);">All</a>&nbsp;|&nbsp;<a href="#" onclick="jQuery('#to option').prop('selected', false);">None</a></span>
              </div>    
        </div>
        <div style="clear:both"></div>

        <div class="form-group">
              <label class="col-sm-3 col-lg-2 control-label">Subject :</label>
              <div class="col-sm-4 col-lg-5 controls">
                <input class="form-control col-md-12" type="text" name="subject" value="<?php echo set_value('subject');?>" />
                <?php echo form_error('subject');?>
                <span class="help-inline">&nbsp;</span>
              </div>
        </div>      
        <div style="clear:both"></div>

        <div class="form-group">
              <label class="col-sm-3 col-lg-2 control-label">Message :</label>
              <div class="col-sm-4 col-lg-5 controls">
                <textarea class="form-control wysihtml5" name="message" style="min-height:300px"><?php echo set_value('message');?></textarea>
                <?php echo form_error('message');?>
              <span class="help-inline">&nbsp;</span>
              </div>  
        </div>
        <div style="clear:both"></div>

        <div class="form-group">
              <label class="col-sm-3 col-lg-2 control-label">&nbsp;</label>
              <div class="col-sm-4 col-lg-5 controls">
              <button class="btn btn-primary" type="submit">Send</button>               
              <span class="help-inline">&nbsp;</span>
              </div>  
        </div>
        <div style="clear:both"></div>
        

        </div>
      </div>  

      </form>
  </div>
</div>      
<!--Rich text editor-->
<script src="<?php echo base_url();?>assets/admin/assets/bootstrap-wysihtml5/wysihtml5-0.3.0.js"></script> 
<script src="<?php echo base_url();?>assets/admin/assets/bootstrap-wysihtml5/bootstrap-wysihtml5.js"></script>
