<?php
$this->load->view("top_application");
//$additionalArr = ($this->input->post('additional_business_nature')) ? $this->input->post('additional_business_nature') : array();
//$additionalArr = ($this->input->post('business_nature')) ? $this->input->post('business_nature') : array();
//trace($member_account);
?>
<section>
  <div class="tz">  
    <!--<div class="header-area">
      <nav class="navbar navbar-default">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".bs-example-navbar-collapse-1" aria-expanded="false">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
        </div>
        <div class="collapse navbar-collapse main-menu bs-example-navbar-collapse-1" id="navbar-example">
          <ul class="nav navbar-nav navbar-right">
            <li class="active"><a href="">My Dashboard</a></li>
            <li><a href="">Company Facsheet</a></li>
            <li class="dropdown">
              <a href="" class="dropdown-toggle" data-toggle="dropdown">Manage Categories <i class="fa fa-angle-down"></i></a>
              <ul class="dropdown-menu" role="menu">
                <li><a href=# >Drop Down 1</a></li>
                <li><a href=# >Drop Down 2</a></li>
              </ul> 
            </li>
            <li><a href="">Manage Enquiries</a></li>
            <li><a href="" title="Log Out">Log Out</a></li>

          </ul>
        </div>
      </nav>
    </div>-->

    <!--LEFT SECTION-->
    <div class="tz-l">
      <?php $this->load->view("members/left"); ?>
    </div>
    <!--CENTER SECTION-->
    <div class="tz-4 col_right">
      <div class="tz-2-com tz-2-main">
        <h4>Manage Account</h4>

        <?php
        if ($member_account['is_self_verified'] == '1' && $member_account['is_manufacturer'] == '1' && $member_account['status'] != '0') {
          ?>
          <div class="tz-2-main-com">
            <div class="tz-2-main-1">
              <div class="tz-2-main-2"><i class="fa fa-list"></i><span>All Product Listings</span>
                <a href="<?php echo site_url('members/manage-products'); ?>"><h2><?php echo $productlisting; ?></h2></a> 
              </div>
            </div>
            <div class="tz-2-main-1">
              <div class="tz-2-main-2"> <i class="fa fa-list-alt"></i><span>All Service Listing</span>
                <a href="<?php echo site_url('members/manage-services'); ?>"><h2><?php echo $servicelisting; ?></h2></a> 
              </div>
            </div>
            <div class="tz-2-main-1">
              <div class="tz-2-main-2"><i class="fa fa-list-ol"></i><span>Enquiries</span>
                <a href="<?php echo site_url('members/manage-enquiries'); ?>"><h2><?php echo $enq; ?></h2></a>
              </div>
            </div>
          </div>
          <?php
          if (is_array($res) && !empty($res)) {
            ?>
            <div class="db-list-com tz-db-table">
              <div class="row">
                <div class="col-md-6 col-xs-8">
                  <div class="ds-boar-title">
                    <h2>Recent Listings</h2>
                  </div>
                </div>
                <div class="col-md-6 col-xs-4">
                  <div class="ds-boar-title pull-right">
                    <a class="view_all31" href="<?php echo site_url('members/manage-products'); ?>">View All</a>
                  </div>
                </div>
              </div>
              <div class="table-responsive">
              <table>
                <thead>
                  <tr>
                    <th>
                      SL.
                    </th>
                    <th class="for_image31"><strong></strong></th>
                    <th><strong>Product Name</strong></th>
                    <th><strong>Categories</strong></th>
                    <th><strong>Date</strong></th>
                    <th><strong>Status</strong></th>
                    <th><strong>Edit</strong></th>
                  </tr>
                </thead>
                <tbody>
                  <?php
                  $slno = 1;
                  foreach ($res as $rkey => $rval) {
                    $catArr = explode(',', $rval['category_id']);
                    ?>
                    <tr>
                      <td>
                        <?php echo $slno; ?>.
                      </td>
                      <td>
                        <?php //echo $slno; ?>
                        <img src="<?php echo get_image('product_images', $rval['media'], '75', '75', 'R'); ?>" id="pic1" class="profile_picture" />
                      </td>
                      <td><?php echo $rval['product_name']; ?></td>
                      <td>
                        <?php
                        foreach ($catArr as $catId) {
                          echo '<i class="fa fa-arrow-right"></i>&nbsp;';
                          echo get_db_field_value("wps_categories", "category_name", "WHERE category_id = '" . $catId . "'");
                          echo "<br />";
                        }
                        ?>
                      </td>
                      <td><?php echo getDateFormat($rval['product_added_date'], 3); ?></td>
                      <td>
                        <span class="db-list-ststus">
                          <?php echo ($rval['status'] == '1') ? 'Activated' : 'Deactivated'; ?>
                        </span>
                      </td>
                      <td><a href="<?php echo site_url(); ?>members/edit-product/<?php echo $rval['products_id']; ?>" class="db-list-edit">Edit</a>
                      </td>
                    </tr>
                    <?php
                    $slno++;
                  }
                  ?>
                </tbody>
              </table>
                </div>
            </div>
            <?php
          }
        } elseif ($member_account['is_manufacturer'] == 0 && $member_account['is_self_verified'] == 1) {
          ?>
          <div class="db-list-com tz-db-table">
            <div class="ds-boar-title">
              <h2>Profile Under Verification</h2>
            </div>
            <div class="hom-cre-acc-left hom-cre-acc-right">
              <p>Dear Customer, Our Verification team is looking at your profile. Our Team will soon Contact you for further proceedures.<br /><br />Thanks,<br />Team Natural Therapy India
            </div>
          </div>
          <?php
        }  elseif ($member_account['status'] == '0') {
          ?>
          <div class="db-list-com tz-db-table">
            <div class="ds-boar-title">
              <h2>Account Deactivated</h2>
            </div>
            <div class="hom-cre-acc-left hom-cre-acc-right">
              <p>Dear Customer, Your Account has been Deactivated. Please contact Our Teanm for more Details.<br /><br />Thanks,<br />Team GerManufacturers.Com
            </div>
          </div>
          <?php
        } else {
          ?>
          <div class="db-list-com tz-db-table">
            <div class="ds-boar-title">
              <h2>Proceed to List your Company</h2>
            </div>
            <div class="hom-cre-acc-left hom-cre-acc-right">
              <div class="">
                <?php echo validation_message(); ?>
                <form class="" action="<?php echo current_url(); ?>" method="post">
                  <div class="row">
                    <div class="input-field col s8">
                      <div class="row">
                        <div class="input-field col s1">
                          <input id="disclaimer" name="disclaimer" type="checkbox" value="1" class="validate" checked />
                          <label for="disclaimer" style="left:-5px"></label>
                        </div>
                        <div class="input-field col s11">
                          <p>I understand that Natural Therapy India is exclusive B2B Directory & Portal for Manufacturers of all sizes from all over the world. If I am not a manufacturer, then my company listing may not be approved to be displayed/showcased on Natural Therapy India.</p>
                        </div>
                      </div>
                    </div>
                    <?php  //echo '<pre>'; print_r($this->input->post('business_nature')); ?>

                    <div class="row">
                      <div class="input-field col s12">
                        <h5 style="margin-bottom: 5px;">Nature of Business*</h5>
                      </div>
                      <?php
                         /* $sl = 1;
                          foreach ($businessNatureAll as $k => $v) {
                            echo $k."==".$v;
                            $sl++;
                          } */
                          //1==Manufacturer 2==Exporter3==Wholesale Supplier4==Service Provider
                          //1==manufacturer 2==Exporter 3==Wholesale Supplier 4==service_provider
                          ?>
                      <div class="row">
                        <div class="input-field col s4">
                          <input id="manufacturer" name="business_nature[]" value="1" type="checkbox" <?php if(in_array(1,$business_nature_Arr)){ echo 'checked="checked"'; } ?> class="validate" />
                          <label for="manufacturer" style="font-size:16px;">Manufacturer</label>
                        </div>
                      </div>
                      <div class="row">
                        <div class="input-field col s4">
                          <input id="exporter" name="business_nature[]" value="2" <?php if(in_array(2,$business_nature_Arr)){ echo 'checked="checked"'; } ?> type="checkbox" class="validate" />
                          <label for="exporter" style="font-size:16px;">Exporter</label>
                        </div>
                        <div class="input-field col s4 hidden">
                          <input id="iec_code" name="iec_code" type="text" class="validate">
                          <label for="gstin">IEC Code</label>
                        </div>
                      </div>
                      <div class="row">
                        <div class="input-field col s4">
                          <input id="wholesale_supplier" name="business_nature[]" value="3" <?php if(in_array(3,$business_nature_Arr)){ echo 'checked="checked"'; } ?> type="checkbox" class="validate" />
                          <label for="wholesale_supplier" style="font-size:16px;">Wholesale Supplier</label>
                        </div>
                        <div class="input-field col s4 hidden">
                          <input id="gstin" name="gstin" type="text" class="validate">
                          <label for="gstin">GSTIN No.</label>
                        </div>
                      </div>
                      <div class="row">
                        <div class="input-field col s4">
                          <input id="service_provider" name="business_nature[]" value="4" <?php if(in_array(4,$business_nature_Arr)){ echo 'checked="checked"'; } ?> type="checkbox" class="validate" />
                          <label for="service_provider" style="font-size:16px;">Service Provider</label>
                        </div>
                      </div>
                    </div>
                    <div class="row">
                      <div class="input-field col s12">&nbsp;</div>
                    </div>
                    <div class="row hidden" id="products">
                      <div class="input-field col s8">
                        <h5 style="margin-bottom: 5px;">Product(s) You Manufacture</h5>
                      </div>
                      <div class="attribute">
                        <div class="col s12">
                          <div class="input-field col s3">
                            <input name="product_name[]" type="text" class="validate">
                            <label for="product_name">Product Name*</label>
                          </div>
                          <div class="input-field col s3">
                            <input name="product_name[]" type="text" class="validate">
                            <label for="product_name">Product Name*</label>
                          </div>
                          <div class="input-field col s3">
                            <input name="product_name[]" type="text" class="validate">
                            <label for="product_name">Product Name*</label>
                          </div>
                          <div class="input-field col s3">
                            <a href="javascript:void(0);" class="btn btn-info addMore">ADD More</a>
                          </div>
                        </div>
                      </div>
                    </div>
                    <div class="row hidden" id="service_provider_product">
                      <div class="input-field col s8">
                        <h5 style="margin-bottom: 5px;">Product(s) Service Provider</h5>
                      </div>
                      <div class="attributeService">
                        <div class="col s12">
                          <div class="input-field col s3">
                            <input name="service_product_name[]" type="text" class="validate">
                            <label for="product_name">Product Name*</label>
                          </div>
                          <div class="input-field col s3">
                            <input name="service_product_name[]" type="text" class="validate">
                            <label for="product_name">Product Name*</label>
                          </div>
                          <div class="input-field col s3">
                            <input name="service_product_name[]" type="text" class="validate">
                            <label for="product_name">Product Name*</label>
                          </div>
                          <div class="input-field col s3">
                            <a href="javascript:void(0);" class="btn btn-info addMoreService">ADD More</a>
                          </div>
                        </div>
                      </div>
                    </div>
                    <div class="row">
                      <div class="input-field col s8 v2-mar-top-40"> 
                        <button class="waves-effect waves-light btn-large full-btn" type="submit">Confirm Your Details</button>
                        <input type="hidden" name="action" value="Self Verification" />
                      </div>
                    </div>
                  </div>
                </form>
              </div>
            </div>
          </div>
          <?php
        }
        ?>
      </div>
    </div>
    <!--RIGHT SECTION-->
  </div>
</section>
<?php $this->load->view("bottom_application"); ?>
<script type="text/javascript">
  $('.addMore').click(function () {
    $('.attribute').append('<div class="additionalAttr"><div class="col s12"><div class="input-field col s3"><input id="" name="product_name[]" type="text" class="validate"><label for="product_name">Product Name*</label></div><div class="input-field col s3"><input id="" name="product_name[]" type="text" class="validate"><label for="product_name">Product Name*</label></div><div class="input-field col s3"><input id="" name="product_name[]" type="text" class="validate"><label for="product_name">Product Name*</label></div><div class="input-field col s3"><a href="javascript:void(0);" class="btn btn-danger remove">Remove</a></div></div></div>');
  });
  $('.attribute').on('click', '.remove', function () { 
    $(this).parent().parent().parent('.additionalAttr').remove();
  });

  $('.addMoreService').click(function () {
    $('.attributeService').append('<div class="additionalAttrService"><div class="col s12"><div class="input-field col s3"><input id="" name="service_product_name[]" type="text" class="validate"><label for="service_product_name">Product Name*</label></div><div class="input-field col s3"><input id="" name="service_product_name[]" type="text" class="validate"><label for="service_product_name">Product Name*</label></div><div class="input-field col s3"><input id="" name="service_product_name[]" type="text" class="validate"><label for="service_product_name">Product Name*</label></div><div class="input-field col s3"><a href="javascript:void(0);" class="btn btn-danger removeService">Remove</a></div></div></div>');
  });
  $('.attributeService').on('click', '.removeService', function () { 
    $(this).parent().parent().parent('.additionalAttrService').remove();
  });



  $('#wholesale_supplier').click(function () {
    if ($(this).is(':checked')) {
      $('#products').removeClass('hidden');
      $(this).parent().next('div').removeClass('hidden');
    } else {
      if (!$('#manufacturer').is(':checked') && !$('#exporter').is(':checked') && !$('#wholesale_supplier').is(':checked')) {
        $('#products').addClass('hidden');
      }
      $(this).parent().next('div').addClass('hidden');
    }
  });

  $('#exporter').click(function () {
    if ($(this).is(':checked')) {
      $('#products').removeClass('hidden');
      $(this).parent().next('div').removeClass('hidden');
    } else {
      if (!$('#manufacturer').is(':checked') && !$('#exporter').is(':checked') && !$('#wholesale_supplier').is(':checked')) {
        $('#products').addClass('hidden');
      }
      $(this).parent().next('div').addClass('hidden');
    }
  });

  $('#manufacturer').click(function () {
    if ($(this).is(':checked')) {
      $('#products').removeClass('hidden');
    } else{
      if (!$('#manufacturer').is(':checked') && !$('#exporter').is(':checked') && !$('#wholesale_supplier').is(':checked')) {
        $('#products').addClass('hidden');
      }
    }
  });

  if ($('#manufacturer').is(':checked') || $('#exporter').is(':checked') || $('#wholesale_supplier').is(':checked')){
      $('#products').removeClass('hidden');
  }

  if ($('#exporter').is(':checked')){
      $('#exporter').parent().next('div').removeClass('hidden');
  }

  if ($('#wholesale_supplier').is(':checked')){
      $('#wholesale_supplier').parent().next('div').removeClass('hidden');
  }

  if ($('#service_provider').is(':checked')){
      $('#service_provider_product').removeClass('hidden');
  }


  $('#service_provider').click(function () {
    if ($(this).is(':checked')) {
      $('#service_provider_product').removeClass('hidden');
    } else{
      $('#service_provider_product').addClass('hidden');
    }
  });

<?php /*
if (in_array('3', $business_nature_Arr)) {
  ?>
    $('#wholesale_supplier').trigger('click');
  <?php
}
if (in_array('2', $business_nature_Arr)) {
  ?>
    $('#exporter').trigger('click');
  <?php
} */
?>
</script>