<link rel="stylesheet" href="<?php echo DOMAIN ?>/jquery_file_upload/css/style.css">
<link rel="stylesheet" href="<?php echo DOMAIN ?>/jquery_file_upload/css/jquery.fileupload.css">
<input type="hidden" class="file_url" value="<?php echo DOMAIN ?>/ajax/upload_single_image" />
<div class="error-main"></div>
<?php

if($templateType == 'edit')
{
    ?>

    <?php
}
?>



                                            <div class="form-group input-container">
                                                <label for="Name" class=" form-control-label">Product  Name</label>
                                                <input type="text" name="name" id="name" placeholder="Product Name" class="form-control" value="<?php if(isset($data['cl_name'])){echo htmlspecialchars($data['cl_name']);}?>" />
                                                <div class="error-input"></div>
                                            </div>

                                            <div class="form-group input-container">
                                                <label for="Name" class=" form-control-label">Slug</label>
                                                <input type="text" name="slug" id="slug" placeholder="Slug" class="form-control" value="<?php if(isset($data['cl_slug'])){echo htmlspecialchars($data['cl_slug']);}?>" />
                                                <div class="error-input"></div>
                                            </div>
                                            
                                             <?php
                                                if($templateType == 'edit')
                                                {
                                                    $current='Current Image : <img src="' . MAIN_DOMAIN . '"/uploads/products/'.$data['cl_image'].'" width="15"/>';
                                                }
                                                else
                                                {
                                                    $current='';
                                                }
                                            ?>

                                          <div class="form-group input-container file_upload_container">
                                                <label for="file" class=" form-control-label">Default Image</label>
                                                
                                                
                                                <?php
                                                
                                                $current = '';
                                                
                                                if(isset($data['cl_image']))
                                                {
                                                    if($data['cl_image_location'] == 'Server')
                                                    { 
                                                      $current =  'Current Image : <img src="' . MAIN_DOMAIN . '/uploads/products/' . htmlspecialchars($data['cl_image']).'" style="max-width:75px" />';
                                                    }
                                                    else if($data['cl_image_location'] == 'CDN')
                                                    {
                                                      $current = 'Current Image : <img src="https://cdn.action.pl/File.aspx?CID=73833&UID=efix2881&PID=ec4549b100d92e60dd4c768ae1e61033&P=' . htmlspecialchars($data['cl_image']).'" style="max-width:75px"/>';
                                                    }
                                                    else
                                                    {

                                                      $current = 'Current Image : <img src="' . htmlspecialchars($data['cl_image']).'" style="max-width:75px"/>';
                                                    }
                                                }
                                                
                                                ?>
                                                    <input type="hidden" class="image file_url" name="image" 
                                                           
                                                           value="<?php if(isset($data['cl_image'])){echo $data['cl_image'];}?>"/>
                                                    <input type="hidden" class="name"   />
                                                        <!-- The container for the uploaded files -->
                                                        <span class="btn btn-success fileinput-button">
                                                        <i class="glyphicon glyphicon-plus"></i>
                                                        <span>Select file</span>
                                                        <!-- The file input field used as target for the file upload widget -->
                                                        <input class="fileupload" type="file" name="file" >
                                                        </span>
                                                        <br>
                                                    <br>
                                                    <!-- The global progress bar -->
                                                    <div class="progress">
                                                        <div class="progress-bar progress-bar-success"></div>
                                                    </div>
                                                    <!-- The container for the uploaded files -->
                                                    <div class="files_area"></div>
                                                    <div class="file_name">
                                                            
                                                        </div>
                                                     <div class="error_area"></div>

                                            <?php echo $current;?>
                                            <div class="error-input"></div>
                                        </div>

                                            <div class="form-group input-container">
                                                <label for="Name" class=" form-control-label">Product  Category</label>
                                                <select name="cat_id" id="cat_id" class="form-control">
                                                    <option value="">---Select Category---</option>
                                                    <?php
                                                     foreach($productCategories as $cat)
                                                     {
                                                    ?>
                                                    <option value="<?php echo $cat['cl_id']; ?>" <?php if($data['cl_cat_id'] ==$cat['cl_id']){echo 'selected';}?>><?php echo $cat['cl_name_english']; ?></option>
                                                    <?php
                                                     }
                                                    ?>
                                                </select>

                                                <div class="error-input"></div>
                                            </div>
                                             <div class="form-group input-container">
                                                <label for="Name" class=" form-control-label">Product Sub Category</label>
                                                <select name="sub_cat_id" id="sub_cat_id" class="form-control">
                                                    <?php
                                                    if(isset($subCategories) && !empty($subCategories))
                                                    {
                                                        foreach($subCategories AS $subCategory)
                                                        {
                                                            ?>
                                                                <option value="<?php echo htmlspecialchars($subCategory['cl_id']) ?>" <?php if($data['cl_sub_cat_id'] ==$subCategory['cl_id']){echo 'selected';}?>><?php echo htmlspecialchars($subCategory['cl_name_english']) ?></option>
                                                            <?php
                                                        }
                                                    }
                                                    ?>
                                                </select>

                                                <div class="error-input"></div>
                                            </div>
                                            <div class="form-group input-container">
                                                <label for="Name" class=" form-control-label">Brand</label>
                                                <select name="brand_id" id="brand_id" class="form-control">
                                                    <?php
                                                     foreach($brands as $brand)
                                                     {
                                                    ?>
                                                    <option value="<?php echo $brand['cl_id']; ?>"<?php if($data['cl_brand_id'] ==$brand['cl_id']){echo 'selected';}?>><?php echo $brand['cl_name']; ?></option>
                                                    <?php
                                                     }
                                                    ?>
                                                </select>

                                                <div class="error-input"></div>
                                            </div>
                                            <div class="form-group input-container" style="display: none">
                                                <label for="Description" class=" form-control-label">Small Specification</label>
                                                <textarea  id="small_specification" name="small_specification" placeholder="Small Specification" class="form-control" ><?php if(isset($data['cl_small_specification'])){echo $data['cl_small_specification'];}else{echo '<table class="table short_description_table" border="0" cellpadding="1" cellspacing="1" style="width:100%">
    <tbody>
        <tr>
            <th>

            </th>
            <td>

            </td>
        </tr>
        <tr>
            <th>

            </th>
            <td>

            </td>
        </tr>
        <tr>
           <th>

            </th>
            <td>

            </td>
        </tr>
        <tr>
            <th>

            </th>
            <td>

            </td>
        </tr>

    </tbody>
</table>';}?></textarea>
                                                <div class="error-input"></div>
                                            </div>
                                            <div class="form-group input-container">
                                                <label for="Description" class=" form-control-label">Big Specification</label>
                                                <textarea  id="big_specification" name="big_specification" placeholder="Big Specification" class="form-control"  style="height: 150px"><?php if(isset($data['cl_big_specification']) && trim($data['cl_big_specification']) != '' && $data['cl_big_specification'] != null){echo $data['cl_big_specification'];}else{echo '<table class="table  big_description_table" border="0" cellpadding="1" cellspacing="1" style="width:100%">
    <tbody>
        <tr>
            <th>

            </th>
            <td>

            </td>
        </tr>
        <tr>
            <th>

            </th>
            <td>

            </td>
        </tr>
        <tr>
           <th>

            </th>
            <td>

            </td>
        </tr>
        <tr>
            <th>

            </th>
            <td>

            </td>
        </tr>

    </tbody>
</table>';}?></textarea>
                                                <div class="error-input"></div>
                                            </div>

                                               <div class="form-group input-container">
                                                <label for="Description" class=" form-control-label">Big Specification (English)</label>
                                                <textarea  id="big_specification_english" name="big_specification_english" placeholder="Big Specification (English)" class="form-control"  style="height: 150px"><?php if(isset($data['cl_big_specification_english']) && trim($data['cl_big_specification_english']) != '' && $data['cl_big_specification_english'] != null){echo $data['cl_big_specification_english'];}else{echo '<table class="table  big_description_table" border="0" cellpadding="1" cellspacing="1" style="width:100%">
    <tbody>
        <tr>
            <th>

            </th>
            <td>

            </td>
        </tr>
        <tr>
            <th>

            </th>
            <td>

            </td>
        </tr>
        <tr>
           <th>

            </th>
            <td>

            </td>
        </tr>
        <tr>
            <th>

            </th>
            <td>

            </td>
        </tr>

    </tbody>
</table>';}?></textarea>
                                                <div class="error-input"></div>
                                            </div>

                                            <div class="form-group input-container">
                                                <label for="Description" class=" form-control-label">Description</label>
                                                <textarea id="description" name="description" placeholder="Description" class="form-control" style="height: 150px"><?php if(isset($data['cl_description'])){echo $data['cl_description'];}?></textarea>
                                                <div class="error-input"></div>
                                            </div>
                                           <!-- <div class="form-group input-container">
                                                <label for="Description" class=" form-control-label">Video</label>
                                                <input type="text" id="Description" name="video" placeholder="Video" class="form-control" value="<?php if(isset($data['cl_video'])){echo $data['cl_video'];}?>" />
                                                <div class="error-input"></div>
                                            </div>-->
                                            <div class="form-group input-container" style="display: none">
                                                <label for="Description" class=" form-control-label">Regular Price</label>
                                                <input type="text" id="Description" name="regular_price" placeholder="Regular Price" class="form-control" value="<?php if(isset($data['cl_regular_price'])){echo $data['cl_regular_price'];}else{echo '0.00';}?>" />
                                                <div class="error-input"></div>
                                            </div>


                                            <div class="form-group input-container" style="display: none">
                                                <label for="Description" class=" form-control-label">Sale Price</label>
                                                <input type="text" id="sale_price" name="sale_price" placeholder="Sale Price" class="form-control" value="<?php if(isset($data['cl_sale_price'])){echo $data['cl_sale_price'];}else{echo '0.00';} ?>" />
                                                <div class="error-input"></div>
                                            </div>

                                            <div class="form-group input-container">
                                                <label for="keywords" class=" form-control-label">Supplier Price</label>
                                                <input type="text" id="supplier_price" name="supplier_price" placeholder="Supplier Price" class="form-control" value="<?php if(isset($data['cl_supplier_price'])){echo $data['cl_supplier_price'];}?>" />
                                                <div class="error-input"></div>
                                            </div>

                                            <div class="form-group input-container">
                                                <label for="keywords" class=" form-control-label">Profit Percentage</label>
                                                <input type="text" id="profit_percentage" name="profit_percentage" placeholder="Profit Percentage" class="form-control" value="<?php if(isset($data['cl_profit_percentage'])){echo $data['cl_profit_percentage'];}else{echo '0.00';}?>" />
                                                <div class="error-input"></div>
                                            </div>

                                            <div class="form-group input-container">
                                                <label for="monthly_price" class=" form-control-label">Monthly Price</label>
                                                <input type="text" id="monthly_price" name="monthly_price" placeholder="Monthly Price" class="form-control" value="<?php if(isset($data['cl_monthly_price'])){echo $data['cl_monthly_price'];}else{echo 0;}?>" />
                                                <div class="error-input"></div>
                                            </div>

                                            <div class="form-group input-container">
                                                <label for="monthly_price" class=" form-control-label">Courier Shipping Price</label>
                                                <input type="text" id="shipping_price" name="shipping_price" placeholder="Shipping Price" class="form-control" value="<?php if(isset($data['cl_shipping_price'])){echo $data['cl_shipping_price'];}else{echo 4.12;}?>" />
                                                <div class="error-input"></div>
                                            </div>

                                             <div class="form-group input-container">
                                                <label for="monthly_price" class=" form-control-label">Pickup Point Shipping Price</label>
                                                <input type="text" id="pickup_point_shipping_price" name="pickup_point_shipping_price" placeholder="Pickup Point Shipping Price" class="form-control" value="<?php if(isset($data['cl_pickup_point_shipping_price'])){echo $data['cl_pickup_point_shipping_price'];}else{echo 4.12;}?>" />
                                                <div class="error-input"></div>
                                            </div>

                                             <div class="form-group input-container">
                                                <label for="monthly_price" class=" form-control-label">Office Shipping Price</label>
                                                <input type="text" id="office_shipping_price" name="office_shipping_price" placeholder="Office Shipping Price" class="form-control" value="<?php if(isset($data['cl_office_shipping_price'])){echo $data['cl_office_shipping_price'];}else{echo 4.12;}?>" />
                                                <div class="error-input"></div>
                                            </div>


                                            <div class="form-group input-container">
                                                <label for="Description" class=" form-control-label">Recommended</label>
                                                <input type="checkbox" name="recommended"  value="1" <?php if(isset($data['cl_recommended']) && $data['cl_recommended'] == 1){echo 'checked';}?> />
                                                <div class="error-input"></div>
                                            </div>

                                            <div class="form-group input-container">
                                                <label for="featured" class=" form-control-label">Featured</label>
                                                <input type="checkbox" name="featured"  value="1" <?php if(isset($data['cl_featured']) && $data['cl_featured'] == 1){echo 'checked';}?> />
                                                <div class="error-input"></div>
                                            </div>
                                            <div class="form-group input-container">
                                                <label for="featured" class=" form-control-label">Recent</label>
                                                <input type="checkbox" name="recent"  value="1" <?php if(isset($data['cl_recent']) && $data['cl_recent'] == 1){echo 'checked';}?> />
                                                <div class="error-input"></div>
                                            </div>
                                            <div class="form-group input-container">
                                                <label for="meta_description" class=" form-control-label">Meta Description</label>
                                                <textarea id="meta_description" name="meta_description" placeholder="Meta Description" class="form-control" value="" style="height: 150px"><?php if(isset($data['cl_meta_description'])){echo $data['cl_meta_description'];}?></textarea>
                                                <div class="error-input"></div>
                                            </div>
                                            <div class="form-group input-container">
                                                <label for="keywords" class=" form-control-label">Keywords</label>
                                                <textarea id="keywords" name="keywords" placeholder="Keywords" class="form-control" value="" style="height: 150px"><?php if(isset($data['cl_keywords'])){echo $data['cl_keywords'];}?></textarea>
                                                <div class="error-input"></div>
                                            </div>
                                            <div class="form-group input-container">
                                                <label for="keywords" class=" form-control-label">Active</label>
                                                <select class="form-control" name="active">
                                                    <option value="1" <?php if(isset($data['cl_active'])&& $data['cl_active'] == 1){echo 'selected';}  ?>>Yes</option>
                                                    <option value="0" <?php if(isset($data['cl_active'])&& $data['cl_active'] == 0){echo 'selected';}  ?>>No</option>
                                                </select>
                                                <div class="error-input"></div>
                                            </div>

                                            <div class="form-group input-container">
                                                <label for="keywords" class=" form-control-label">Supplier</label>
                                                <input type="text" id="supplier" name="supplier" placeholder="Supplier" class="form-control" value="<?php if(isset($data['cl_supplier'])){echo $data['cl_supplier'];}?>" />
                                                <div class="error-input"></div>
                                            </div>

                                            <div class="form-group input-container">
                                                <label for="keywords" class=" form-control-label">Product ID</label>
                                                <input type="text" id="product_id" name="product_id" placeholder="Product ID" class="form-control" value="<?php if(isset($data['cl_product_id'])){echo $data['cl_product_id'];}?>" />
                                                <div class="error-input"></div>
                                            </div>

                                             <div class="form-group input-container">
                                                <label for="keywords" class=" form-control-label">EAN</label>
                                                <input type="text" id="ean" name="ean" placeholder="EAN" class="form-control" value="<?php if(isset($data['cl_ean'])){echo $data['cl_ean'];}?>" />
                                                <div class="error-input"></div>
                                            </div>

                                             <div class="form-group input-container">
                                                <label for="keywords" class=" form-control-label">Weight</label>
                                                <input type="text" id="weight" name="weight" placeholder="Weight" class="form-control" value="<?php if(isset($data['cl_weight'])){echo $data['cl_weight'];}?>" />
                                                <div class="error-input"></div>
                                            </div>
                                             <div class="form-group input-container">
                                                <label for="keywords" class=" form-control-label">X</label>
                                                <input type="text" id="weight" name="x" placeholder="Weight" class="form-control" value="<?php if(isset($data['cl_x'])){echo $data['cl_x'];}?>" />
                                                <div class="error-input"></div>
                                            </div>
                                             <div class="form-group input-container">
                                                <label for="keywords" class=" form-control-label">Y</label>
                                                <input type="text" id="weight" name="y" placeholder="Weight" class="form-control" value="<?php if(isset($data['cl_y'])){echo $data['cl_y'];}?>" />
                                                <div class="error-input"></div>
                                            </div>
                                             <div class="form-group input-container">
                                                <label for="keywords" class=" form-control-label">Z</label>
                                                <input type="text" id="weight" name="z" placeholder="Weight" class="form-control" value="<?php if(isset($data['cl_z'])){echo $data['cl_z'];}?>" />
                                                <div class="error-input"></div>
                                            </div>

                                            <div class="form-group input-container">
                                                <label for="keywords" class=" form-control-label">Stock</label>
                                                <select class="form-control" name="stock" id="stock">
                                                    <option value="1" <?php if(isset($data['cl_stock'])&& $data['cl_stock'] == 1){echo 'selected';}  ?>>Yes</option>
                                                    <option value="0" <?php if(isset($data['cl_stock'])&& $data['cl_stock'] == 0){echo 'selected';}  ?>>No</option>
                                                </select>
                                                <div class="error-input"></div>
                                            </div>
                                            <div class="form-group input-container">
                                                <label for="keywords" class=" form-control-label">Type</label>
                                                <select class="form-control" name="type" id="type">
                                                    <option value="General" <?php if(isset($data['cl_type'])&& $data['cl_type'] == 'General'){echo 'selected';}  ?>>General</option>
                                                    <option value="Variable" <?php if(isset($data['cl_type'])&& $data['cl_type'] == 'Variable'){echo 'selected';}  ?>>Variable</option>
                                                </select>
                                                <div class="error-input"></div>
                                            </div>
                                             <div class="form-group input-container">
                                                <label for="keywords" class=" form-control-label">Warranty Active</label>
                                                <select class="form-control" name="warranty_active" id="warranty_active">
                                                    <option value="1" <?php if(isset($data['cl_warranty_active'])&& $data['cl_warranty_active'] == '1'){echo 'selected';}  ?>>Yes</option>
                                                    <option value="0" <?php if(isset($data['cl_warranty_active'])&& $data['cl_warranty_active'] == '0'){echo 'selected';}  ?>>No</option>
                                                </select>
                                                <div class="error-input"></div>
                                            </div>

                                            <div class="form-group input-container">
                                                <label for="keywords" class=" form-control-label">Digital Product</label>
                                                <select class="form-control" name="digital" id="digital">
                                                    <option value="0" <?php if(isset($data['cl_digital'])&& $data['cl_digital'] == '0'){echo 'selected';}  ?>>No</option>
                                                    <option value="1" <?php if(isset($data['cl_digital'])&& $data['cl_digital'] == '1'){echo 'selected';}  ?>>Yes</option>
                                                </select>
                                                <div class="error-input"></div>
                                            </div>

                                             <div class="form-group input-container">
                                                <label for="keywords" class=" form-control-label">Free Shipping</label>
                                                <select class="form-control" name="free_shipping" id="free_shipping">
                                                    <option value="0" <?php if(isset($data['cl_free_shipping'])&& $data['cl_free_shipping'] == '0'){echo 'selected';}  ?>>No</option>
                                                    <option value="1" <?php if(isset($data['cl_free_shipping'])&& $data['cl_free_shipping'] == '1'){echo 'selected';}  ?>>Yes</option>
                                                </select>
                                                <div class="error-input"></div>
                                            </div>
                                            <div class="form-group input-container">
                                                <label for="l_stock" class=" form-control-label">Local Stock</label>
                                                <input type="text" name="l_stock" id="l_stock" placeholder="Local Stock" class="form-control" value="<?php if(isset($data['cl_l_stock'])){echo htmlspecialchars($data['cl_l_stock']);}?>" />
                                                <div class="error-input"></div>
                                            </div>
            								<div class="form-group input-container">
    										  <button type="submit" class="track-btn pull-right">Submit</button>

    										</div>

                                            <script>
                                                $(document).ready(function(){
                                                    $('#cat_id').change(function(){
                                                        var html = '';
                                                        var categoryID = $(this).val();
                                                        $.get('../ajax/product_subcategory/get?id=' + categoryID, function(res){
                                                            html+= '<option value="">---Select Sub Category---</option>';
                                                            $(res).each(function(i, value){
                                                                html+= '<option value="' + value.cl_id + '">' + value.cl_name + '</option>';
                                                            });

                                                            $('#sub_cat_id').html(html);
                                                        }, 'json');
                                                    });
                                                });

                                                $(document).on('click','.cke a', function(){
                                                        setTimeout(
                                                          function()
                                                          {
                                                            $('body').removeClass('fade-out');
                                                        }, 100);
                                                    });


                                                $(document).on('click', '.cke_reset_all a', function(){
                                                    setTimeout(
                                                      function()
                                                      {
                                                        $('body').removeClass('fade-out');
                                                    },
                                                    100);
                                                });
                                            </script>

  <!-- The Iframe Transport is required for browsers without support for XHR file uploads -->
<script src="<?php echo DOMAIN ?>/jquery_file_upload/js/jquery.iframe-transport.js"></script>
<!-- The basic File Upload plugin -->
<script src="<?php echo DOMAIN ?>/jquery_file_upload/js/jquery.fileupload.js"></script>