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

$admin_id = $this->session->userdata('admin_id');

$admin_type = $this->session->userdata('admin_type');

$pcatID = ($this->uri->segment(4) > 0) ? $this->uri->segment(4) : "0";

$pcatID = (int) $pcatID;

$selcatID = ($this->input->post('category_id[]') != '') ? implode(",", $this->input->post('category_id[]')) : $pcatID;

$selcatID = $selcatID;

//echo "ssssssssssssssssssss".$selcatID;die;
?>

<!--  BEGIN MAIN CONTAINER  -->

<link rel="stylesheet" type="text/css" href="<?php echo admin_url(); ?>assets/css/forms/switches.css">

<link rel="stylesheet" type="text/css" href="<?php echo admin_url(); ?>plugins/editors/markdown/simplemde.min.css">

<div class="main-container" id="container">

  <div class="overlay"></div>

  <div class="search-overlay"></div>

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

  <!--  BEGIN CONTENT AREA  -->

  <div id="content" class="main-content">

    <div class="layout-px-spacing">

      <div class="row layout-top-spacing layout-spacing">

        <div class="col-lg-12">

          <div class="statbox widget box box-shadow">

            <?php
            echo form_open_multipart('wps-admin/products/add/', 'id="data_form"');

            echo success_message();
            validation_message();
            error_message();
            ?>

            <div class="widget-header">

              <div class="row">

                <div class="col-xl-6 col-md-6 col-sm-6 col-6">

                  <h4><?php echo $headingTitle; ?></h4>

                </div>

                <div class="col-xl-6 col-md-6 col-sm-6 col-6 text-right">

                  <h4>

                    <a href="<?php echo base_url(); ?>wps-admin/products/index/" class="btn btn-danger btn-sm mb-2"><i class="fa fa-exclamation-circle"></i> Cancel</a>

                    <button type="submit" class="btn btn-primary btn-sm mb-2"><i class="fa fa-plus"></i> Save</button>

                    <!-- <button type="submit" class="btn btn-info btn-sm mb-2"><i class="fa fa-plus-square"></i> Save & New</button>

                    <button type="submit" class="btn btn-secondary btn-sm mb-2"><i class="fa fa-plus-square"></i> Save & Close</button> -->

                  </h4>

                </div>

              </div>

            </div>

            <div class="widget-content widget-content-area">

              <div class="table-responsive mb-4">

                <div class="form-group row  mb-4">

                  <label class="col-sm-3 col-form-label col-form-label-sm" for="category_id">Category <span class="red">*</span></label>

                  <div class="col-sm-9">
                    <div style="max-height: 150px; overflow-y: scroll; border: 1px solid #e1e1e1; padding: 5px;">

                      <div class="col-md-12">
                        <?php echo get_nested_dropdown_menu(0, $selcatID); ?>
                      </div>

                    </div>

                    <?php echo form_error('category_id[]'); ?>

                  </div>

                </div>


                <div class="form-group row  mb-4">
                  <label class="col-sm-3 col-form-label col-form-label-sm" for="youtube_id">Brand</label>
                  <div class="col-sm-6">
                      <div class="" style="max-height: 150px; overflow-y: scroll; border: 1px solid #e1e1e1; padding: 5px;">
                          <div class="col-md-12">
                          <?php
                        $posted_brand_arr = array();

                        if ($this->input->post('brand_id')) {

                          $posted_brand_arr = $this->input->post('brand_id');
                        }

                        if (is_array($brands) && !empty($brands)) {

                          foreach ($brands as $val) {
                            ?>

                            <div class="col-md-4 col-lg-4 col-sm-4 col-xs-6">

                              <input type="checkbox" name="brand_id[]" value="<?php echo $val['brand_id']; ?>" <?php echo (@in_array($val['sizebrand_id_id'], $posted_brand_arr)) ? ' checked' : ''; ?>  /> <?php echo $val['brand_name']; ?>

                            </div>

                            <?php
                          }
                        }
                        ?>
                          </div>
                    </div>
                <?php echo form_error('brand_id[]'); ?>
                  </div>
                </div>
          



                <div class="form-group row  mb-4">

                  <label class="col-sm-3 col-form-label col-form-label-sm" for="product_name">Product Name<span class="red">*</span></label>

                  <div class="col-sm-6">

                    <input type="text" class="url_creator form-control" id="product_name" name="product_name" value="<?php echo set_value('product_name'); ?>" placeholder="Product Name" required /><?php echo form_error('product_name'); ?>

                    <span id="error_url_creator" class="red"></span>

                  </div>

                </div>

                <div class="form-group row  mb-4">

                  <label class="col-sm-3 col-form-label col-form-label-sm" for="friendlyUrl">Friendly Url <span class="red">*</span></label>

                  <div class="col-sm-6">

                    <input type="text" class="seo_friendly_url form-control" id="friendlyUrl" name="friendly_url" value="<?php echo set_value('friendlyUrl'); ?>" readonly required /><?php echo form_error('friendlyUrl'); ?>

                    <span id="error_friendly_url" class="red"></span>

                  </div>

                </div>

                <div class="form-group row  mb-4">

                  <label class="col-md-3 col-xs-12 control-label">Product Images</label>

                  <div class="col-md-2">

                    <div class="">

                      <img src="<?php echo get_image('products', '', '125', '125', 'R'); ?>" id="pic1" class="profile_picture" width="75" height="125"  /><div class="clearfix"></div>

                      <a href="javascript:void(0);" onclick="$('#img1').trigger('click');"  class="profile_picture">Add Image</a>

                    </div>

                    <input id="img1" name="img1" type="file" onchange="document.getElementById('pic1').src = window.URL.createObjectURL(this.files[0])" class="validate" style="display: none;" />

                  </div>

                  <div class="col-md-2">

                    <div class="">

                      <img src="<?php echo get_image('products', '', '125', '125', 'R'); ?>" id="pic2" class="profile_picture" width="75" height="125" /><div class="clearfix"></div>

                      <a href="javascript:void(0);" onclick="$('#img2').trigger('click');" class="profile_picture">Add Image</a>

                    </div>

                    <input id="img2" name="img2" type="file" onchange="document.getElementById('pic2').src = window.URL.createObjectURL(this.files[0])" class="validate" style="display: none;" />

                  </div>

                  <div class="col-md-2">

                    <div class="">

                      <img src="<?php echo get_image('products', '', '125', '125', 'R'); ?>" id="pic3" class="profile_picture" width="75" height="125" /><div class="clearfix"></div>

                      <a href="javascript:void(0);" onclick="$('#img3').trigger('click');" class="profile_picture">Add Image</a>

                    </div>

                    <input id="img3" name="img3" type="file" onchange="document.getElementById('pic3').src = window.URL.createObjectURL(this.files[0])" class="validate" style="display: none;" />

                  </div>

                  <div class="col-md-2">
                    <div class="">
                      <img src="<?php echo get_image('products', '', '125', '125', 'R'); ?>" id="pic4" class="profile_picture" width="75" height="125" /><div class="clearfix"></div>
                      <a href="javascript:void(0);" onclick="$('#img4').trigger('click');" class="profile_picture">Add Image</a>
                    </div>
                    <input id="img4" name="img4" type="file" onchange="document.getElementById('pic4').src = window.URL.createObjectURL(this.files[0])" class="validate" style="display: none;" />
                  </div>

<!--
                  <div class="col-md-1">
                    <div class="">
                      <img src="<?php echo get_image('products', '', '125', '125', 'R'); ?>" id="pic4" class="profile_picture" width="75" height="125" /><div class="clearfix"></div>
                      <a href="javascript:void(0);" onclick="$('#img5').trigger('click');" class="profile_picture">Add Image</a>
                    </div>
                    <input id="img5" name="img5" type="file" onchange="document.getElementById('pic5').src = window.URL.createObjectURL(this.files[0])" class="validate" style="display: none;" />
                  </div>
-->

<!--

                  <div class="col-md-1">
                    <div class="">
                      <img src="<?php echo get_image('products', '', '125', '125', 'R'); ?>" id="pic6" class="profile_picture" width="75" height="125" /><div class="clearfix"></div>
                      <a href="javascript:void(0);" onclick="$('#img6').trigger('click');" class="profile_picture">Add Image</a>
                    </div>
                    <input id="img6" name="img6" type="file" onchange="document.getElementById('pic6').src = window.URL.createObjectURL(this.files[0])" class="validate" style="display: none;" />
                  </div>
-->

<!--
                  <div class="col-md-1">
                    <div class="">
                      <img src="<?php echo get_image('products', '', '125', '125', 'R'); ?>" id="pic7" class="profile_picture" width="75" height="125" /><div class="clearfix"></div>
                      <a href="javascript:void(0);" onclick="$('#img7').trigger('click');" class="profile_picture">Add Image</a>
                    </div>
                    <input id="img7" name="img7" type="file" onchange="document.getElementById('pic7').src = window.URL.createObjectURL(this.files[0])" class="validate" style="display: none;" />
                  </div>
-->

<!--
                  <div class="col-md-1">
                    <div class="">
                      <img src="<?php echo get_image('products', '', '125', '125', 'R'); ?>" id="pic8" class="profile_picture" width="75" height="125" /><div class="clearfix"></div>
                      <a href="javascript:void(0);" onclick="$('#img8').trigger('click');" class="profile_picture">Add Image</a>
                    </div>
                    <input id="img8" name="img8" type="file" onchange="document.getElementById('pic8').src = window.URL.createObjectURL(this.files[0])" class="validate" style="display: none;" />
                  </div>
-->

                </div>



                <div class="form-group row  mb-4">

                  <label class="col-sm-3 col-form-label col-form-label-sm" for="product_price">Product Price <span class="red">*</span></label>

                  <div class="col-sm-6 row">

                    <div class="col-sm-6">

                      <input id="product_price" name="product_price" value="<?php echo set_value('product_price'); ?>" type="text" required class="form-control"><?php echo form_error('product_price'); ?>

                      <label for="product_code"><span class="required">*</span>MRP</label>

                    </div>

                    <div class="col-sm-6">

                      <input id="unit_value" name="discounted_price" value="<?php echo set_value('discounted_price'); ?>" type="text" required class="form-control"><?php echo form_error('discounted_price'); ?>

                      <label for="product_code"><span class="required">*</span>Selling Price</label> 

                    </div>

                  </div>

                </div>







                <div class="form-group row  mb-4">

                  <label class="col-sm-3 col-form-label col-form-label-sm" for="product_code">Product Additional Information <span class="red">*</span></label>

                  <div class="col-sm-6 row">

                    <div class="col-sm-6">

                      <input id="product_code" name="product_code" value="<?php echo set_value('product_code'); ?>" type="text" class="form-control" required><?php echo form_error('product_code'); ?>

                      <label for="product_code"><span class="required">*</span>Product Code</label>

                    </div>

                    <div class="col-sm-6">

                      <input id="product_qty" name="product_qty" value="<?php echo set_value('product_qty'); ?>" type="text" class="form-control" required><?php echo form_error('product_qty'); ?>

                      <label for="product_qty"><span class="required">*</span>Product Qty</label>

                    </div>

                  </div>

                </div>
                  
<!--
                      <div class="form-group row  mb-4">
                       <label class="col-sm-3 col-form-label col-form-label-sm" for="product_code">GST(%) <span class="red">*</span></label>

                  <div class="col-sm-6 row">
                     <div class="col-sm-6">

                <select name="product_gst" class="form-control">
                  <option value="">Select GST</option>
                  <option value="5">5%</option>
                  <option value="12">12%</option>
                  <option value="18">18%</option>
                </select>
                <label for="product_gst">GST**</label>
              </div>
                  </div>
                  </div>
-->

                <!--<div class="form-group row  mb-4">
                  <label class="col-sm-3 col-form-label col-form-label-sm" for="additional_desc">Additional Description</label>
                  <div class="col-sm-6">
                    <textarea name="additional_desc" rows="5" cols="50" id="short_desc" ><?php echo set_value('additional_desc'); ?></textarea> <?php echo form_error('additional_desc'); ?>
                  </div>
                </div>

                <div class="form-group row  mb-4">
                  <label class="col-sm-3 col-form-label col-form-label-sm" for="hsn_code">HSN Code<span class="red">*</span></label>
                  <div class="col-sm-6">
                    <input id="hsn_code" name="hsn_code" value="<?php echo set_value('hsn_code'); ?>" type="text" class="form-control"><?php echo form_error('hsn_code'); ?>
                  </div>
                </div--> 

                <!-- <div class="form-group row  mb-4">

                  <label class="col-sm-3 col-form-label col-form-label-sm" for="youtube_id">Youtube Video Id <span class="red">*</span></label>

                  <div class="col-sm-6">

                  <input id="product_code" name="youtube_id" value="<?php echo set_value('youtube_id'); ?>" type="text" class="form-control"><?php echo form_error('youtube_id'); ?>

                  </div>

                </div> -->

                <!--div class="form-group row  mb-4">
                  <label class="col-sm-3 col-form-label col-form-label-sm" for="youtube_id">Major Color</label>
                  <div class="col-sm-8">
                    <div class="" style="max-height: 150px; border: 1px solid #e1e1e1; padding: 5px;">
                      <div class="row">
                        <?php
                        $posted_color_arr = array();

                        if ($this->input->post('majorcolor_id')) {
                          $posted_color_arr = $this->input->post('majorcolor_id');
                        }
                        if (is_array($majorcolors) && !empty($majorcolors)) {
                          foreach ($majorcolors as $val) {
                            ?>
                            <div class="col-md-4 col-lg-4 col-sm-4 col-xs-6">
                              <input type="checkbox" name="majorcolor_id[]" value="<?php echo $val['color_id']; ?>" <?php echo (@in_array($val['color_id'], $posted_color_arr)) ? ' checked' : ''; ?>  /> <?php echo $val['color_name']; ?>
                            </div>
                            <?php
                          }
                        }
                        ?>
                      </div>
                    </div>
                    <?php echo form_error('majorcolor_id[]'); ?>
                  </div>
                </div-->

<!--
                <div class="form-group row  mb-4">

                  <label class="col-sm-3 col-form-label col-form-label-sm" for="youtube_id">Color </label>

                  <div class="col-sm-8">

                    <div class="" style="max-height: 150px; border: 1px solid #e1e1e1; padding: 5px;">

                      <div class="row">

                        <?php
                        $posted_color_arr = array();

                        if ($this->input->post('color_id')) {

                          $posted_color_arr = $this->input->post('color_id');
                        }

                        if (is_array($colors) && !empty($colors)) {

                          foreach ($colors as $val) {
                            ?>

                            <div class="col-md-4 col-lg-4 col-sm-4 col-xs-6">

                              <input type="checkbox" name="color_id[]" value="<?php echo $val['color_id']; ?>" <?php echo (@in_array($val['color_id'], $posted_color_arr)) ? ' checked' : ''; ?>  /> <?php echo $val['color_name']; ?>

                            </div>

                            <?php
                          }
                        }
                        ?>

                      </div>

                    </div>

                    <?php echo form_error('color_id[]'); ?>

                  </div>

                </div> 

                <div class="form-group row  mb-4">

                  <label class="col-sm-3 col-form-label col-form-label-sm" for="size">Size</label>

                  <div class="col-sm-8">

                    <div class="" style="max-height: 150px; border: 1px solid #e1e1e1; padding: 5px;">

                      <div class="row">

                        <?php
                        $posted_size_arr = array();

                        if ($this->input->post('size_id')) {

                          $posted_size_arr = $this->input->post('size_id');
                        }

                        if (is_array($sizes) && !empty($sizes)) {

                          foreach ($sizes as $val) {
                            ?>

                            <div class="col-md-4 col-lg-4 col-sm-4 col-xs-6">

                              <input type="checkbox" name="size_id[]" value="<?php echo $val['size_id']; ?>" <?php echo (@in_array($val['size_id'], $posted_size_arr)) ? ' checked' : ''; ?>  /> <?php echo $val['size_name']; ?>

                            </div>

                            <?php
                          }
                        }
                        ?>

                      </div>

                    </div>

                    <?php echo form_error('size_id[]'); ?>

                  </div>

                </div>



                <div class="form-group row  mb-4">

                  <label class="col-sm-3 col-form-label col-form-label-sm" for="youtube_id">Styles </label>

                  <div class="col-sm-8">

                    <div class="" style="max-height: 150px; border: 1px solid #e1e1e1; padding: 5px;">

                      <div class="row">

                        <?php
                        $posted_style_arr = array();

                        if ($this->input->post('style_id')) {

                          $posted_style_arr = $this->input->post('style_id');
                        }

                        if (is_array($styles) && !empty($styles)) {

                          foreach ($styles as $val) {
                            ?>

                            <div class="col-md-4 col-lg-4 col-sm-4 col-xs-6">

                              <input type="checkbox" name="style_id[]" value="<?php echo $val['style_id']; ?>" <?php echo (@in_array($val['style_id'], $posted_style_arr)) ? ' checked' : ''; ?>  /> <?php echo $val['style_name']; ?>

                            </div>

                            <?php
                          }
                        }
                        ?>

                      </div>

                    </div>

                    <?php echo form_error('style_id[]'); ?>

                  </div>

                </div> 
-->



                <!--div class="form-group row  mb-4">

                  <label class="col-sm-3 col-form-label col-form-label-sm" for="youtube_id">Rooms</label>

                  <div class="col-sm-8">

                    <div class="" style="max-height: 150px; border: 1px solid #e1e1e1; padding: 5px;">

                      <div class="row">

                        <?php
                        $posted_room_arr = array();

                        if ($this->input->post('room_id')) {

                          $posted_room_arr = $this->input->post('room_id');
                        }

                        if (is_array($rooms) && !empty($rooms)) {

                          foreach ($rooms as $val) {
                            ?>

                            <div class="col-md-4 col-lg-4 col-sm-4 col-xs-6">

                              <input type="checkbox" name="room_id[]" value="<?php echo $val['room_id']; ?>" <?php echo (@in_array($val['room_id'], $posted_room_arr)) ? ' checked' : ''; ?>  /> <?php echo $val['room_name']; ?>

                            </div>

                            <?php
                          }
                        }
                        ?>

                      </div>

                    </div>

                    <?php echo form_error('room_id[]'); ?>

                  </div>

                </div--> 



                <div class="form-group row  mb-4">

                  <label class="col-sm-3 col-form-label col-form-label-sm" for="short_desc">Short Description</label>

                  <div class="col-sm-6">

                    <textarea name="short_desc" rows="5" cols="50" id="short_desc" ><?php echo set_value('short_desc'); ?></textarea><?php echo display_ckeditor($ckeditor); ?> <?php echo form_error('short_desc'); ?>

                  </div>

                </div>



                <div class="form-group row  mb-4">

                  <label class="col-sm-3 col-form-label col-form-label-sm" for="description">Description <span class="red">*</span></label>

                  <div class="col-sm-6">

                    <textarea name="description" rows="5" cols="50" id="description" ><?php echo set_value('description'); ?></textarea> <?php echo display_ckeditor($ckeditor1); ?><?php echo form_error('description'); ?>

                  </div>

                </div>



                <div class="form-group row  mb-4">

                  <label class="col-sm-3 col-form-label col-form-label-sm" for="specification">Specification </label>

                  <div class="col-sm-6">

                    <textarea name="specification" rows="5" cols="50" id="specification" ><?php echo set_value('specification'); ?></textarea> <?php echo display_ckeditor($ckeditor2); ?><?php echo form_error('specification'); ?>

                  </div>

                </div>





                <div class="">

                  <h6 class="" style="background-color: #e9e8e8; padding: 12px 10px 10px 20px;margin-bottom: 20px;">SEO Parameters</h6>

                </div>

                <div class="form-group row  mb-4">

                  <label class="col-sm-3 col-form-label col-form-label-sm" for="metaTitle">Meta Title</label>

                  <div class="col-sm-6">

                    <input type="text" class="form-control" id="metaTitle" name="metaTitle" value="<?php echo set_value('metaTitle'); ?>" placeholder="Meta Title" /><?php echo form_error('title'); ?>

                  </div>

                </div>

                <div class="form-group row  mb-4">

                  <label class="col-sm-3 col-form-label col-form-label-sm" for="metaDescription">Meta Description</label>

                  <div class="col-sm-6">

                    <textarea class="form-control" id="description" name="metaDescription"><?php echo set_value('metaDescription'); ?></textarea><?php echo form_error('metaDescription'); ?>

                  </div>

                </div>

                <div class="form-group row  mb-4">

                  <label class="col-sm-3 col-form-label col-form-label-sm" for="metaKeyword">Meta Keyword</label>

                  <div class="col-sm-6">

                    <input type="text" class="form-control" id="metaKeyword" name="metaKeyword" placeholder="Meta Keyword" value="<?php echo set_value('metaKeyword'); ?>" /><?php echo form_error('metaKeyword'); ?>

                  </div>

                </div>



                <div class="widget-header">

                  <div class="row">

                    <div class="col-xl-6 col-md-6 col-sm-6 col-6">&nbsp;</div>

                    <div class="col-xl-6 col-md-6 col-sm-6 col-6 text-right">

                      <h4>

                        <a href="<?php echo base_url(); ?>wps-admin/products" class="btn btn-danger btn-sm mb-2"><i class="fa fa-exclamation-circle"></i> Cancel</a>

                        <button type="submit" class="btn btn-primary btn-sm mb-2"><i class="fa fa-plus"></i> Save</button>

                      <!-- <button type="submit" class="btn btn-info btn-sm mb-2"><i class="fa fa-plus-square"></i> Save & New</button>

                      <button type="submit" class="btn btn-secondary btn-sm mb-2"><i class="fa fa-plus-square"></i> Save & Close</button> -->

                      </h4>

                    </div>

                  </div>

                </div>

                <?php echo form_close(); ?>

              </div>

            </div>

          </div>

        </div>

        <div class="footer-wrapper">

          <div class="footer-section f-section-1">

            <p class="terms-conditions">All Rights Reserved. Powered By <a href="https://www.webpulseindia.com/" target="_blank">Webpulse</a></p>

          </div>

          <div class="footer-section f-section-2">

            <p class="">Coded with <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-heart"><path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"></path></svg></p>

          </div>

        </div>

      </div>

      <!--  END CONTENT AREA  -->

    </div>

    <!-- END MAIN CONTAINER -->

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



    <?php die(); ?>

