<?php
$this->load->view('includes/header');
$block_path = $inq_type == 'Wholesale' ? "enquiry/wholesale/" : "enquiry/";
?> 
<div class="page-title">                    
  <h2><span ></span><?php echo $heading_title; ?></h2> 
</div>
<div class="page-content-wrap">                

  <div class="fix"></div>
  <div class="row">
    <div class="col-md-12">
      <?php
      if ($this->session->flashdata('success')) {
        ?>
        <div class="alert alert-info">
          <?php echo $this->session->flashdata('success'); ?>
        </div>
        <?php
      }
      ?>
      <!-- START DEFAULT DATATABLE -->
      <div class="panel panel-default">
        <div class="panel-body">
          <div class="table-responsive">
            <?php
            if (is_array($res) && !empty($res)) {
              ?>
              <?php echo form_open("sitepanel/enquiry/", 'id="data_form"'); ?>
              <table class="table datatable" id="my_data">
                <?php
                $atts = array(
                    'width' => '700',
                    'height' => '550',
                    'scrollbars' => 'yes',
                    'status' => 'yes',
                    'resizable' => 'yes',
                    'screenx' => '350',
                    'screeny' => '100'
                );
                ?>
                <thead>
                  <tr>
                    <th style="text-align: center; width: 10%;">
                      <input type="checkbox" onclick="$('input:checkbox').not(this).prop('checked', this.checked);" /></th>
                    <th style="width: 35%;">Product Info</th>
                    <th style="width: 35%;">User Info</th>                    
                    <th style="width: 10%;">Comments</th>
                    <th style="width: 10%;">Action</th>
                  </tr>
                </thead>
                <tbody>
                  <?php
                  foreach ($res as $catKey => $res) {
                    $address_details = array();
                    ?> 
                    <tr>
                      <td style="text-align: center;" valign="top">
                        <input type="checkbox" name="arr_ids[]" value="<?php echo $res['id']; ?>" /></td>
                      <td>
                        <?php
                        if (!empty($res['customers_id'])) {
                          echo "<b>Company Name : </b>" . get_db_field_value('wps_customers', "company_name", "WHERE customers_id='" . $res['customers_id'] . "'") . "<br />";
                        }
                        if (!empty($res['products_id'])) {
                          echo "<b>Product Enquired : </b>" . get_db_field_value('wps_products', "product_name", "WHERE products_id='" . $res['products_id'] . "'") . "<br />";
                        }
                        if ($res['quantity'] > 0) {
                          echo "<b>Quantity : </b>" . $res['quantity'];
                        }
                        if ($res['is_verified'] == '1') {
                          ?>
                          <br /><br /><span class="btn btn-success">Verified</span>  
                          <?php
                        }else{
                          ?>
                          <br /><br /><span class="btn btn-danger">Pending</span>  
                          <?php
                        }
                        ?>
                      </td>
                      <td>
                        <?php echo $res['first_name']; ?> <?php echo $res['last_name']; ?> <br>
                        <?php
                        if ($res['mobile_number'] != "" && $res['mobile_number'] != '0') {
                          $address_details[] = "<b>Mobile No. : </b>" . $res['mobile_number'];
                        }
                        if ($res['post_url'] != "" && $res['post_url']) {
                          $address_details[] = "<b>Posted URL : </b>" . $res['post_url'];
                        }
                        if (!empty($address_details)) {
                          echo implode("<br>", $address_details) . "<br />";
                        }
                        echo '<b>Email ID :</b> '.$res['email'].'<br />';
                        if($res['location']){
                          echo '<b>Location :</b> '.$res['location'].'<br />';
                        }
                        
                        if ($res['reply_status'] == 'Y') {
                          ?>
                          <font color="#FF0000">Replied</font>  
                          <?php
                        }
                        ?>
                        <br />
                        <?php echo anchor_popup('sitepanel/enquiry/send_reply/' . $res['id'], 'Send Reply', $atts); ?>
                      </td>
                      <td>
                        <a href="#" data-toggle="modal" data-target=".enq_list_<?php echo $res['id']; ?>">
                          View Message
                        </a>
                        <div class="modal fade enq_list_<?php echo $res['id']; ?>" tabindex="-1" role="dialog" aria-labelledby="description" aria-hidden="true">
                          <div class="modal-dialog modal-lg">
                            <div class="modal-content">

                              <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                                <h4 class="modal-title" id="description">Message</h4>
                              </div>
                              <div class="modal-body">
                                <?php echo html_entity_decode($res['message']); ?>
                              </div>
                            </div>
                          </div>
                        </div>
                      </td>
                      <td>
                      <?php if($type==1 || $type==4){?>
                        <?php echo anchor("sitepanel/enquiry/edit/".$res['id']."". query_string(), '<span>Edit Enquiry</span>', 'class="btn btn-info"'); ?><br /><br />
                        <?php echo anchor("sitepanel/enquiry/forward/".$res['id']."". query_string(), '<span>Forward Enquiry</span>', 'class="btn btn-info" target="_blank"'); ?>
                        <?php } ?>
                      </td>
                    </tr>
                    <?php
                  }
                  ?>

                </tbody>
                <tr>
                  <td align="left" colspan="6" style="padding:2px" height="35">
                    <input name="status_action" type="submit" class="button2" id="Delete" value="Delete"  onClick="return validcheckstatus('arr_ids[]', 'delete', 'Record');"/>
                    <input name="status_action" type="submit" class="button2" value="Mark as Verified" id="verified"  onClick="return validcheckstatus('arr_ids[]', 'Mark as Verified', 'Record', 'u_status_arr[]');"/>
                    <input name="status_action" type="submit" class="button2" value="Mark as Un-Verified" id="verified"  onClick="return validcheckstatus('arr_ids[]', 'Mark as Un-Verified', 'Record', 'u_status_arr[]');"/>
                  </td>
                </tr>
              </table>
              <?php echo form_close(); ?>
            <?php } else { ?>
              <center><strong><?php echo "No Record(s) Found!" ?></strong></center>
            <?php } ?>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

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