<?php $this->load->view('includes/header'); ?>
<!-- PAGE TITLE -->
<div class="page-title">                    
  <h2><span ></span><?php echo $heading_title; ?></h2>
  <div class="buttons">
    <!--<a href="<?php echo base_url(); ?>sitepanel/products/add/<?php echo $this->uri->segment(4, 0); ?><?php if(isset($_GET['cust_id']) && $_GET['cust_id']!='' && $_GET['cust_id']>0){ echo '/'.$_GET['cust_id']; } ?>" class="btn btn-primary pull-right">Add product</a>-->

  </div>
</div>
<!-- END PAGE TITLE -->                

<div class="row">
  <?php echo form_open("sitepanel/products/old_products/", 'id="myForm" method="get"'); ?>
  <div class="col-md-8">
    <div class="panel panel-default">
      <div class="panel-body">
        <div class="table-responsive">

          <table  width="100%" align="center" bgcolor="#999999" border="0" cellspacing="1" cellpadding="3" >
            <tr bgcolor="#FFFFFF">
              <td colspan="3" width="100%" colspan="2" align="left"><strong style="font-size:14px">Search</strong></td>
            </tr>
            <tr bgcolor="#FFFFFF">
              <td width="30%" align="" ><strong>Keyword (Name, Description)</strong></td>
              <td width="40%">
                <input type="text" name="keyword" value="<?php echo $this->input->get_post('keyword');?>" />&nbsp;
                <input type="hidden" name="action" value="Seach" />
              </td>
              <td width="30%" colspan="2"><input type="submit" value="Search" /></td>
            </tr>
          </table>

        </div>
      </div>
    </div>
  </div>
  <div class="col-md-4">
    <div class="panel panel-default">
      <div class="panel-body">
        <div class="table-responsive">
          Records Per Page : <?php //echo display_record_per_page(); ?> <select name="pagesize" id="pagesize" class="form-control" style="width:60px;">
          <option value="70">70</option>
          <!--<option value="100">100</option>
          <option value="200">200</option>
          <option value="300">300</option>
          <option value="400">400</option>
          <option value="500">500</option>
          <option value="600">600</option>-->
            <!--<option value="20">
        20</option>
            <option value="30">
        30</option>
            <option value="40">
        40</option>
            <option value="50">
        50</option>-->
        </select> </div>
          <div>Total Products : <?php echo $category_result_found;?></div>
      </div>
    </div>
  </div>
  <?php echo form_close(); ?>
</div>

<!-- PAGE CONTENT WRAPPER -->
<div class="page-content-wrap">                

  <div class="row">
    <div class="col-md-12">
      <?php
      error_message();
      validation_message();
      ?>
      <!-- START DEFAULT DATATABLE -->
      <div class="panel panel-default">
        <div class="panel-body">
          <div class="table-responsive">
            <?php
            if (is_array($res) && !empty($res)) { //sitepanel/products/old_products/
              echo form_open("", 'id="data_form"');
              $selcatID='';
              ?>
              <table class="list" width="30%"> 
              <tr>
              <td align="left">New Category List : </td>
              <td align="left">
              <select name="category_id[]" multiple="multiple" size="15" class="form-control">
                  <?php echo get_nested_dropdown_menu(0, $selcatID); ?>
                </select>
              </td></tr>
              </table>
              <table class="table" id="my_data">
                <?php
                $atts = array(
                    'width' => '650',
                    'height' => '400',
                    'scrollbars' => 'yes',
                    'status' => 'yes',
                    'resizable' => 'yes',
                    'screenx' => '0',
                    'screeny' => '0'
                );
                ?>
                <thead>
                  <tr>
                    <th  width="23" style="text-align: center;">
                      <input type="checkbox" onclick="$('input:checkbox').not(this).prop('checked', this.checked);" />
                    </th>
                    <th>Product Name</th>
                    <th>Product Code</th>
                    <th>Price</th>
                    <th>Product Picture</th>
                    <th>Details</th>
                    <th>Status</th>
                    <th>Action</th>
                  </tr>
                </thead>
                <tbody>
                  <?php $i=0;
                  foreach ($res as $catKey => $pageVal) { $i++;
                    ?>   

                    <tr>
                      <td width="23" style="text-align: center;">
                        <input type="checkbox" name="arr_ids[]" class="chk" value="<?php echo $pageVal['productID']; ?>" /><?php echo $i;?>
                      </td>
                      <td><?php echo $pageVal['productName']; ?>   &nbsp; (<?php echo $pageVal['productID']; ?> )  
                      <p><strong>Product Type: </strong> <span style="color:red"><?php if($pageVal['prostatus']==2){ echo 'Service'; }else if($pageVal['prostatus']==1){ echo 'Product';} ?></span></p>              
                      <?php $catRes = get_db_single_row("category_tbl", 'catID, catName', "catID='".$pageVal['mainCategory']."'"); ?>
                        <p><strong>Old Category Name : </strong> <span style="color:green"><?php echo $catRes['catName'];?> (<?php echo $catRes['catID'];?>)</span></p>

                        <div id="dialog_<?php echo $pageVal['productID']; ?>" title="Description" style="display:none;"><?php echo $pageVal['completeDescription']; ?></div>
                      </td>
                      <td><?php echo $pageVal['productCode']; ?></td>
                      <td>
                        <?php
                        if ($pageVal['discountedPrice'] == '0.00') {
                          ?>
                          <span style="color: #b00;"><?php echo display_price($pageVal['productPrice']); ?></span>
                          <?php
                        } else {
                          ?>
                          <span style="text-decoration: line-through;"><?php echo display_price($pageVal['productPrice']); ?></span><br> 
                          <span style="color: #b00;"><?php echo display_price($pageVal['discountedPrice']); ?></span>
                          <?php
                        }
                        ?>
                      </td>
                      <td align="center" valign="top">
                        <img src="<?php echo get_image('product_images_s', $pageVal['image1'], 50, 50, 'AR'); ?>" />
                      </td>
                      <td>
                        <a href="#" data-toggle="modal" data-target=".pro_list_<?php echo $pageVal['productID']; ?>">
                          View Description
                        </a>
                        <div class="modal fade pro_list_<?php echo $pageVal['productID']; ?>" 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">Description</h4>
                              </div>
                              <div class="modal-body">
                                <?php echo html_entity_decode($pageVal['completeDescription']); ?>
                              </div>
                            </div>
                          </div>
                        </div>           
                      </td>
                      <td class="left" valign="top"><?php echo ($pageVal['status'] == 'Y') ? "Active" : "In-active"; ?></td>
                      <td align="center" valign="top">
                       <?php /* <p >                    
                          <?php echo anchor("sitepanel/products/edit/$pageVal[products_id]/" . query_string(), "<span>Edit</span>", 'class="btn btn-info" '); ?> 
                        </p>
                        <!--p>
                        <?php //echo anchor_popup('sitepanel/products/related/' . $pageVal['products_id'], 'Add Related Products', $atts); ?>
                        </p>
                      <p>
                        <?php //echo anchor_popup('sitepanel/products/view_related/' . $pageVal['products_id'], 'View Related Products', $atts); ?>
                      </p>
                        <p>
                        <?php //echo anchor_popup('sitepanel/products/view_stocks_store/' . $pageVal['products_id'], "<span>Manage Stocks</span>", $atts); ?>
                        </p>--> */ ?>
                      </td>
                    </tr>
                  <?php } ?>
                </tbody>
              </table>
              <table class="list" width="100%"> 
                <tr><td align="right"><?php echo $page_links; ?></td></tr>
                <tr>
                  <td align="left" style="padding:5px">
                  <input name="status_action" type="submit" class="button2" id="Save" value="Shift to New Category"  onClick="return validcheckstatus('arr_ids[]', 'Shift to New Category', 'Record');"/>
                   <?php /* <input name="status_action" type="submit"  value="Activate" class="button2" id="Activate" onClick="return validcheckstatus('arr_ids[]', 'Activate', 'Record', 'u_status_arr[]');"/>

                    <input name="status_action" type="submit" class="button2" value="Deactivate" id="Deactivate"  onClick="return validcheckstatus('arr_ids[]', 'Deactivate', 'Record', 'u_status_arr[]');"/>
                    <input name="status_action" type="submit" class="button2" id="Delete" value="Delete"  onClick="return validcheckstatus('arr_ids[]', 'delete', 'Record');"/>
                    <?php echo form_dropdown("set_as", $this->config->item('product_set_as_config'), $this->input->post('set_as'), 'style="width:120px;" onchange="return onclickgroup()"'); ?>

                    <?php echo form_dropdown("unset_as", $this->config->item('product_unset_as_config'), $this->input->post('unset_as'), 'style="width:120px;" onchange="return onclickgroup()"'); ?> */ ?>

                  </td>
                </tr>
              </table>
              <?php
              echo form_close();
            } else {
              ?>
              <center><strong><?php echo "No Record(s) Found!"; ?></strong></center>
            <?php } ?>
          </div>
        </div>
      </div>
      <!-- END DEFAULT DATATABLE -->
    </div>
  </div>
</div>
<!-- PAGE CONTENT WRAPPER --> 
<script type="text/javascript">
  function onclickgroup() {
    if (validcheckstatus('arr_ids[]', 'set', 'record', 'u_status_arr[]')) {
      $('#data_form').submit();
    }
  }



</script>
<?php $this->load->view('includes/footer'); ?>
<script type="text/javascript">

  $('#pagesize').change(function () {
    $('#myForm').submit();
  });

  $('#my_data').dataTable({
    "bInfo": false, //Dont display info e.g. "Showing 1 to 4 of 4 entries"
    "paging": false, //Dont want paging                
    "bPaginate": false, //Dont want paging 
    "searching": false,
    "sort": false,
  })
</script>