|
Server : Apache/2.4.18 (Ubuntu) System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64 User : oppastar ( 1041) PHP Version : 7.0.33-0ubuntu0.16.04.15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, Directory : /var/www/ptbos.biz/public_html/application/views/admin/products/ |
Upload File : |
<div class="row">
<div class="col-sm-12">
<a href="<?= base_url('admin/products'); ?>"><i class="fa fa-arrow-left" aria-hidden="true"></i> Back to Projects List Page</a><br><br>
<h4><?= empty($products->id_products) ? 'Add a new project' : 'Edit Project: '
. $products->title; ?></h4>
<?= $this->session->flashdata('success'); //to display success message ?>
<?= $this->session->flashdata('result'); //to display result message ?>
</div><!-- end class="col-sm-12" -->
</div> <!-- end row -->
<?= form_open_multipart(); ?>
<p style="text-align:right;"><?= form_submit('submit', 'Save Project', 'class="btn btn-primary btn-success button-brown"'); ?> <?= anchor('admin/products', 'cancel'); ?></p><br>
<input type="hidden" name="product_id" value="<?= $products->id_products; ?>">
<div class="row">
<div class="col-sm-3">
<p>Project Name</p>
</div><!-- end class="col-sm-3" -->
<div class="col-sm-9">
<p>
<?php
$data = array(
'name' => 'product_name',
'value' => set_value('product_name', $products->title), //product_name is validation repopulate, $products->title is getting value from database (initial state)..
'class' => 'form-control'
);
echo form_input($data); ?>
<?= form_error('product_name'); ?></p>
</div><!-- end class="col-sm-9" -->
</div> <!-- end row -->
<div class="row" style="display: none;">
<div class="col-sm-3">
<p>Brand</p>
</div><!-- end class="col-sm-3" -->
<div class="col-sm-9">
<select name="brand_id" class="form-control">
<option value="">choose brand...</option>
<?php foreach($brands as $brand) : ?>
<option value="<?= $brand->id_brands; ?>" <?= set_select('brand_id', $brand->id_brands); ?>
<?php if (isset($brand_id)): ?>
<?php if ($brand_id == $brand->id_brands) : ?>
selected="selected"
<?php endif; ?>
<?php endif ?>
><?= $brand->brand; ?></option>
<?php endforeach; ?>
</select>
<?= form_error('brand_id'); ?>
</div><!-- end class="col-sm-9" -->
</div> <!-- end row -->
<div class="row">
<div class="col-sm-3">
<p>Category</p>
</div><!-- end class="col-sm-3" -->
<div class="col-sm-9">
<div style="height: 200px; overflow-y: scroll; padding: 20px; border:1px solid #ccc;">
<?php foreach($parent_categories as $category) : ?>
- <?= ucfirst($category->category); ?> <br>
<?php
//check if this parent categories does have sub categories
$this->db->select('id_categories')->from('categories')->where('parent', $category->id_categories);
$count_child = $this->db->get()->num_rows();
?>
<?php if ($count_child > 0) : //this category does have childen ?>
<?php
//get all child categories
$this->db->select('*')->from('categories')->where('parent', $category->id_categories)->order_by('priority', 'ASC');
$child_categories = $this->db->get()->result();
?>
<?php foreach ($child_categories as $child) : ?>
-- <input style="position:relative; bottom:3px; margin-right: 10px; margin-left:10px;" type="checkbox" name="category_id[]" value="<?= $child->id_categories; ?>" <?= set_checkbox('category_id[]', $child->id_categories); ?>
<?php if (isset($chosen_categories)) : ?>
<?php
//checked item
foreach ($chosen_categories as $chosen_category) : ?>
<?php if ($chosen_category->id_category == $child->id_categories) : ?>
checked
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
> <?= ucfirst($child->category); ?> <br>
<?php
//check if this parent categories does have sub categories
$this->db->select('id_categories')->from('categories')->where('parent', $child->id_categories);
$count_grandchild = $this->db->get()->num_rows();
?>
<?php if ($count_grandchild > 0) : //this category does have childen ?>
<?php
//get all child categories
$this->db->select('*')->from('categories')->where('parent', $child->id_categories)->order_by('priority', 'ASC');
$grandchild_categories = $this->db->get()->result();
?>
<?php foreach ($grandchild_categories as $grandchild) : ?>
------- <input style="position:relative; bottom:3px; margin-right: 10px; margin-left:10px;" type="checkbox" name="category_id[]" value="<?= $grandchild->id_categories; ?>" <?= set_checkbox('category_id[]', $grandchild->id_categories); ?>
<?php if (isset($chosen_categories)) : ?>
<?php
//checked item
foreach ($chosen_categories as $chosen_category) : ?>
<?php if ($chosen_category->id_category == $grandchild->id_categories) : ?>
checked
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
> <?= ucfirst($grandchild->category); ?> <br>
<?php endforeach; ?>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
<?php endforeach; ?>
</div>
<?= form_error('category_id[]'); ?>
</div><!-- end class="col-sm-9" -->
</div> <!-- end row -->
<div class="row" style="display: none;">
<div class="col-sm-12">
<h4>Product Details</h4>
<p>Please Fill in the option combinations. Fields must not empty.</p>
<p>SKU must be unique (do not use same SKU)</p>
<?= $this->session->flashdata('sku_error'); //to display sku error message ?>
</div><!-- end class="col-sm-12" -->
</div> <!-- end row -->
<div class="row" style="display: none;">
<div class="col-sm-12">
<?php
//get available product options
$this->db->select('*')->from('product_size')->order_by('id_product_size', 'ASC');
$options = $this->db->get()->result();
$count_options = count($options);
$has_attributes = true;
//check for each options, does it have attributes? Each options must have attributes before proceed....
if($count_options > 0) {
foreach($options as $option) {
//get attributes
$this->db->select('*')->from('product_attributes')->where('id_product_size', $option->id_product_size);
$count_attributes = $this->db->get()->num_rows();
if($count_attributes == 0) {
$has_attributes = false;
}
}
}
?>
<?php if($count_options == 0 || $has_attributes == false) : ?>
<!-- product options not available -->
<p style="color:red; font-weight:bold;">Product Details Not available. Please create product options and the attributes on Admin > Product Options Menu.</p>
<?php elseif($count_options != 0 && $has_attributes == true) : ?>
<!-- product options are available -->
<?php
//count and get current product details
$this->db->select('*')->from('product_details')->where('product_id', $products->id_products);
$current_product_details = $this->db->get()->result_array();
$count_current_product_details = count($current_product_details);
?>
<div class="table-responsive">
<!-- <table class="table table-striped"> -->
<table>
<tr>
<?php foreach ($options as $option) : ?>
<th><?= ucwords($option->product_size); ?></th>
<?php endforeach; ?>
<th>Stocks</th>
<th>SKU (Product Code)</th>
<th>Price (Rp)</th>
<th>Discounted<br>Price (Rp)</th>
<th>Weight (gram)</th>
<th>Delete</th>
</tr>
<?php for($i = 0 ; $i < 20; $i++) : ?>
<?php
//get attribute items
if (isset($current_product_details[$i])) {
//get product options detail
$this->db->select('id_product_detail_options, product_attributes_id')->from('product_detail_options')->where('product_details_id', $current_product_details[$i]['id_product_details']);
$current_attributes = $this->db->get()->result_array();
}
?>
<tr>
<?php $option_count = 0; ?>
<?php foreach ($options as $option) : ?>
<td>
<select class="form-control" name="select<?= $i; ?>[]">
<option value=""></option>
<?php
//get attributes
$this->db->select('*')->from('product_attributes')->where('id_product_size', $option->id_product_size)->order_by('product_attributes', 'ASC');
$attributes = $this->db->get()->result();
?>
<?php foreach ($attributes as $attribute) : ?>
<option value="<?= $attribute->id_product_attributes; ?>"
<?php if (isset($current_product_details[$i])) : ?>
<?php if(isset($current_attributes[$option_count])) : ?>
<?php if($attribute->id_product_attributes == $current_attributes[$option_count]['product_attributes_id']) : ?>
selected
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
><?= $attribute->product_attributes; ?></option>
<?php endforeach; ?>
</select>
</td>
<?php $option_count++; ?>
<?php endforeach; ?>
<?php if (isset($current_product_details[$i])) : ?>
<td><input type="text" name="stock[]" value="<?= $current_product_details[$i]['stock']; ?>"></td>
<td><input type="text" id="sku<?= $i; ?>" name="sku[]" value="<?= $current_product_details[$i]['sku']; ?>"></td>
<td><input type="text" name="price[]" value="<?= $current_product_details[$i]['price']; ?>"></td>
<td><input type="text" name="discounted_price[]" value="<?= $current_product_details[$i]['discounted_price']; ?>"></td>
<td><input type="text" name="weight[]" value="<?= $current_product_details[$i]['weight']; ?>"></td>
<td> <?= bt_delete('admin/products/delete_product_detail/' . $products->id_products . '/' . $current_product_details[$i]['id_product_details']); ?></td>
<?php else : ?>
<td><input type="text" name="stock[]"></td>
<td><input type="text" id="sku<?= $i; ?>" name="sku[]"></td>
<td><input type="text" name="price[]"></td>
<td><input type="text" name="discounted_price[]"></td>
<td><input type="text" name="weight[]"></td>
<td></td>
<?php endif; ?>
</tr>
<?php endfor; ?>
</table>
</div><!-- end class table-responsive-->
<?php endif; ?><!-- end if($count_options == 0) -->
</div><!-- end class="col-sm-12" -->
</div> <!-- end row -->
<div class="row">
<div class="col-sm-12">
<h4>Project Status & Ordering</h4>
</div><!-- end class="col-sm-12" -->
</div> <!-- end row -->
<div class="row" style="display: none;">
<div class="col-sm-3">
<p>Project Type</p>
</div><!-- end class="col-sm-3" -->
<div class="col-sm-9">
<select name="project_type" class="form-control">
<option value="progress" <?php echo set_select('product_status', 'progress'); ?>
<?php if($products->project_type == 'progress') : ?>
selected
<?php endif; ?>
>Progress</option>
<option value="accomplishment" <?php echo set_select('product_status', 'accomplishment'); ?>
<?php if($products->project_type == 'accomplishment') : ?>
selected
<?php endif; ?>
>Accomplishment</option>
</select>
</div><!-- end class="col-sm-9" -->
</div> <!-- end row -->
<div class="row">
<div class="col-sm-3">
<p>Display</p>
</div><!-- end class="col-sm-3" -->
<div class="col-sm-9">
<select name="product_status" class="form-control">
<option value="0" <?php echo set_select('product_status', '0'); ?>
<?php if($products->product_status == 0) : ?>
selected
<?php endif; ?>
>No</option>
<option value="1" <?php echo set_select('product_status', '1'); ?>
<?php if($products->product_status == 1) : ?>
selected
<?php endif; ?>
>Yes</option>
</select>
</div><!-- end class="col-sm-9" -->
</div> <!-- end row -->
<div class="row">
<div class="col-sm-3">
<p>Ordering (must be number only)</p>
</div><!-- end class="col-sm-3" -->
<div class="col-sm-9">
<p>
<?php
$data = array(
'name' => 'priority',
'value' => $products->priority,
'class' => 'form-control'
);
echo form_input($data); ?>
<?= form_error('priority'); ?></p>
</div><!-- end class="col-sm-9" -->
</div> <!-- end row -->
<div class="row" style="display: none;">
<div class="col-sm-3">
<p>Set as New Arrival ?</p>
</div><!-- end class="col-sm-3" -->
<div class="col-sm-9">
<select name="new_arrival" class="form-control">
<option value="no" <?= set_select('new_arrival', 'no'); ?>
<?php if ($products->new_arrival == 'no') : ?>
selected="selected"
<?php endif; ?>
>No</option>
<option value="yes" <?= set_select('new_arrival', 'yes'); ?>
<?php if ($products->new_arrival == 'yes') : ?>
selected="selected"
<?php endif; ?>
>Yes</option>
</select>
</div><!-- end class="col-sm-9" -->
</div> <!-- end row -->
<div class="row" style="display: none;">
<div class="col-sm-3">
<p>Set as Featured Product ?</p>
</div><!-- end class="col-sm-3" -->
<div class="col-sm-9">
<select name="popular_product" class="form-control">
<option value="no" <?= set_select('popular_product', 'no'); ?>
<?php if ($products->popular_product == 'no') : ?>
selected="selected"
<?php endif; ?>
>No</option>
<option value="yes" <?= set_select('popular_product', 'yes'); ?>
<?php if ($products->popular_product == 'yes') : ?>
selected="selected"
<?php endif; ?>
>Yes</option>
</select>
</div><!-- end class="col-sm-9" -->
</div> <!-- end row -->
<div class="row" style="display: none;">
<div class="col-sm-3">
<p>Set as Best Seller ?</p>
</div><!-- end class="col-sm-3" -->
<div class="col-sm-9">
<select name="best_seller" class="form-control">
<option value="no" <?= set_select('best_seller', 'no'); ?>
<?php if ($products->best_seller == 'no') : ?>
selected="selected"
<?php endif; ?>
>No</option>
<option value="yes" <?= set_select('best_seller', 'yes'); ?>
<?php if ($products->best_seller == 'yes') : ?>
selected="selected"
<?php endif; ?>
>Yes</option>
</select>
</div><!-- end class="col-sm-9" -->
</div> <!-- end row -->
<div style="display: none;">
<div class="row">
<div class="col-sm-12">
<h4>Project Descriptions</h4>
</div><!-- end class="col-sm-12" -->
</div> <!-- end row -->
<div class="row">
<div class="col-sm-3">
<!-- <p>Short Description</p> -->
<p>Description</p>
</div><!-- end class="col-sm-3" -->
<div class="col-sm-9">
<?php echo form_textarea('description', set_value('description',
$products->description, FALSE)); ?>
<?php echo form_error('description'); ?>
</div><!-- end class="col-sm-9" -->
</div> <!-- end row -->
</div>
<div class="row">
<div class="col-sm-3">
<!-- <p>Long Description</p> -->
<p>Deskripsi</p>
</div><!-- end class="col-sm-3" -->
<div class="col-sm-9">
<div class="tabbable">
<ul class="nav nav-tabs">
<li class="active"><a href="#longdescription_id" data-toggle="tab">Indonesian</a></li>
<li><a href="#longdescription_en" data-toggle="tab">English</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="longdescription_id">
<?php echo form_textarea('long_description', set_value('long_description',
$products->long_description, FALSE)); ?>
<?php echo form_error('long_description'); ?>
</div><!-- end id="#description_id" -->
<div class="tab-pane" id="longdescription_en">
<?php echo form_textarea('long_description_en', set_value('long_description_en',
$products->long_description_en, FALSE)); ?>
<?php echo form_error('long_description_en'); ?>
</div><!-- end id="#description_id" -->
</div><!-- end class tab-content-->
</div><!-- end tabbable -->
</div><!-- end class="col-sm-9" -->
</div> <!-- end row -->
<div class="row" style="display: none;">
<div class="col-sm-3">
<!-- <p>Specification / Additional Infos</p> -->
<p>Informasi Produk</p>
</div><!-- end class="col-sm-3" -->
<div class="col-sm-9">
<div class="tabbable">
<ul class="nav nav-tabs">
<li class="active"><a href="#additional_information_id" data-toggle="tab">Indonesian</a></li>
<li><a href="#additional_information_en" data-toggle="tab">English</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="additional_information_id">
<?php echo form_textarea('additional_information', set_value('additional_information',
$products->additional_information, FALSE)); ?>
<?php echo form_error('additional_information'); ?>
</div><!-- end id="#description_id" -->
<div class="tab-pane" id="additional_information_en">
<?php echo form_textarea('additional_information_en', set_value('additional_information_en',
$products->additional_information_en, FALSE)); ?>
<?php echo form_error('additional_information_en'); ?>
</div><!-- end id="#description_id" -->
</div><!-- end class tab-content-->
</div><!-- end tabbable -->
</div><!-- end class="col-sm-9" -->
</div> <!-- end row -->
<div class="row" style="display: none;">
<div class="col-sm-12">
<h4>Product Images</h4>
</div><!-- end class="col-sm-12" -->
</div> <!-- end row -->
<div class="row">
<div class="col-sm-12">
<h4>Project Images</h4>
</div><!-- end class="col-sm-12" -->
</div> <!-- end row -->
<div class="row">
<?php
//get product image width and height setting from configuration table
$this->db->select('product_image_width, product_image_height')->from('configuration')->where('id_configuration', 1);
$product_dimensions = $this->db->get()->row();
?>
<div class="col-sm-3">
<p>Project Image 1<br>
<?php if ($products->image1 != NULL): ?>
Image Preview: <img src="<?= base_url() . 'uploads/product/thumbnail/' .
$products->image1; ?>" style="width:50px; height:auto;">
<br>
<i class="fa fa fa-trash-o" aria-hidden="true"></i> <a href="<?= base_url() . 'admin/products/delete_image/' . $products->id_products . '/image1'; ?>">Delete</a>
<?php endif ?></p>
</div><!-- end class="col-sm-3" -->
<div class="col-sm-9">
<input class="form-control" type="file" name="image1" size="20" /><br>
<span style="font-size:12px; font-style: italic;">Image size must be maximum of <?= $product_dimensions->product_image_width; ?> (width) x <?= $product_dimensions->product_image_height; ?> (height) pixel, jpg/png</span>
<span style="color:#F7931E;"><?php echo form_error('image1'); ?></span>
<?php echo $this->session->flashdata('image1-error'); //to display error message ?>
</div><!-- end class="col-sm-9" -->
</div> <!-- end row -->
<div class="row">
<div class="col-sm-12">
<?php
//get product image width and height setting from configuration table
$this->db->select('product_image_width, product_image_height')->from('configuration')->where('id_configuration', 1);
$product_dimensions = $this->db->get()->row();
?>
</div><!-- end class="col-sm-12" -->
</div> <!-- end row -->
<div class="row">
<div class="col-sm-3">
<p>Project Image 2<br>
<?php if ($products->image2 != NULL): ?>
Image Preview: <img src="<?= base_url() . 'uploads/product/thumbnail/' .
$products->image2; ?>" style="width:50px; height:auto;">
<br>
<i class="fa fa fa-trash-o" aria-hidden="true"></i> <a href="<?= base_url() . 'admin/products/delete_image/' . $products->id_products . '/image2'; ?>">Delete</a>
<?php endif; ?></p>
</div><!-- end class="col-sm-3" -->
<div class="col-sm-9">
<input class="form-control" type="file" name="image2" size="20" /><br>
<span style="font-size:12px; font-style: italic;">Image size must be maximum of <?= $product_dimensions->product_image_width; ?> (width) x <?= $product_dimensions->product_image_height; ?> (height) pixel, jpg/png</span>
<span style="color:#F7931E;"><?php echo form_error('image2'); ?></span>
<?php echo $this->session->flashdata('image2-error'); //to display error message ?>
</div><!-- end class="col-sm-9" -->
<div class="col-sm-9 offset-sm-3" style="margin-top: 20px;">
<?php
error_reporting(0);
$icon_image = $this->db->select('icon_url')->from('product_image_icon')->where('product_id',$products->id_products)->where('image_target','image2')->get()->row()->icon_url;
if($icon_image != null):
?>
<img src="<?= base_url() . 'uploads/product/icon/'.$icon_image;?>" style="width: 5%;height: auto;border-radius: 10px;" alt="">
<?php endif; ?>
</div>
</div> <!-- end row -->
<div class="row">
<div class="col-sm-3">
<p>Project Image 3<br>
<?php if ($products->image3 != NULL): ?>
Image Preview: <img src="<?= base_url() . 'uploads/product/thumbnail/' .
$products->image3; ?>" style="width:50px; height:auto;">
<br>
<i class="fa fa fa-trash-o" aria-hidden="true"></i> <a href="<?= base_url() . 'admin/products/delete_image/' . $products->id_products . '/image3'; ?>">Delete</a>
<?php endif ?></p>
</div><!-- end class="col-sm-3" -->
<div class="col-sm-9">
<input class="form-control" type="file" name="image3" size="20" /><br>
<span style="font-size:12px; font-style: italic;">Image size must be maximum of <?= $product_dimensions->product_image_width; ?> (width) x <?= $product_dimensions->product_image_height; ?> (height) pixel, jpg/png</span>
<span style="color:#F7931E;"><?php echo form_error('image3'); ?></span>
<?php echo $this->session->flashdata('image3-error'); //to display error message ?>
</div><!-- end class="col-sm-9" -->
<div class="col-sm-9 offset-sm-3" style="margin-top: 20px;">
<?php
$icon_image = $this->db->select('icon_url')->from('product_image_icon')->where('product_id',$products->id_products)->where('image_target','image3')->get()->row()->icon_url;
if($icon_image != null):
?>
<img src="<?= base_url() . 'uploads/product/icon/'.$icon_image;?>" style="width: 5%;height: auto;border-radius: 10px;" alt="">
<?php endif; ?>
</div>
</div> <!-- end row -->
<div class="row">
<div class="col-sm-3">
<p>Project Image 4<br>
<?php if ($products->image4 != NULL): ?>
Image Preview: <img src="<?= base_url() . 'uploads/product/thumbnail/' .
$products->image4; ?>" style="width:50px; height:auto;">
<br>
<i class="fa fa fa-trash-o" aria-hidden="true"></i> <a href="<?= base_url() . 'admin/products/delete_image/' . $products->id_products . '/image4'; ?>">Delete</a>
<?php endif ?></p>
</div><!-- end class="col-sm-3" -->
<div class="col-sm-9">
<input class="form-control" type="file" name="image4" size="20" /><br>
<span style="font-size:12px; font-style: italic;">Image size must be maximum of <?= $product_dimensions->product_image_width; ?> (width) x <?= $product_dimensions->product_image_height; ?> (height) pixel, jpg/png</span>
<span style="color:#F7931E;"><?php echo form_error('image4'); ?></span>
<?php echo $this->session->flashdata('image4-error'); //to display error message ?>
</div><!-- end class="col-sm-9" -->
<div class="col-sm-9 offset-sm-3" style="margin-top: 20px;">
<?php
$icon_image = $this->db->select('icon_url')->from('product_image_icon')->where('product_id',$products->id_products)->where('image_target','image4')->get()->row()->icon_url;
if($icon_image != null):
?>
<img src="<?= base_url() . 'uploads/product/icon/'.$icon_image;?>" style="width: 5%;height: auto;border-radius: 10px;" alt="">
<?php endif; ?>
</div>
</div> <!-- end row -->
<div class="row">
<div class="col-sm-3">
<p>Project Image 5<br>
<?php if ($products->image5 != NULL): ?>
Image Preview: <img src="<?= base_url() . 'uploads/product/thumbnail/' .
$products->image5; ?>" style="width:50px; height:auto;">
<br>
<i class="fa fa fa-trash-o" aria-hidden="true"></i> <a href="<?= base_url() . 'admin/products/delete_image/' . $products->id_products . '/image5'; ?>">Delete</a>
<?php endif ?></p>
</div><!-- end class="col-sm-3" -->
<div class="col-sm-9">
<input class="form-control" type="file" name="image5" size="20" /><br>
<span style="font-size:12px; font-style: italic;">Image size must be maximum of <?= $product_dimensions->product_image_width; ?> (width) x <?= $product_dimensions->product_image_height; ?> (height) pixel, jpg/png</span>
<span style="color:#F7931E;"><?php echo form_error('image5'); ?></span>
<?php echo $this->session->flashdata('image5-error'); //to display error message ?>
</div><!-- end class="col-sm-9" -->
<div class="col-sm-9 offset-sm-3" style="margin-top: 20px;">
<?php
$icon_image = $this->db->select('icon_url')->from('product_image_icon')->where('product_id',$products->id_products)->where('image_target','image5')->get()->row()->icon_url;
if($icon_image != null):
?>
<img src="<?= base_url() . 'uploads/product/icon/'.$icon_image;?>" style="width: 5%;height: auto;border-radius: 10px;" alt="">
<?php endif; ?>
</div>
</div> <!-- end row -->
<div class="row">
<div class="col-sm-3">
<p>Project Image 6<br>
<?php if ($products->image6 != NULL): ?>
Image Preview: <img src="<?= base_url() . 'uploads/product/thumbnail/' .
$products->image6; ?>" style="width:50px; height:auto;">
<br>
<i class="fa fa fa-trash-o" aria-hidden="true"></i> <a href="<?= base_url() . 'admin/products/delete_image/' . $products->id_products . '/image6'; ?>">Delete</a>
<?php endif ?></p>
</div><!-- end class="col-sm-3" -->
<div class="col-sm-9">
<input class="form-control" type="file" name="image6" size="20" /><br>
<span style="font-size:12px; font-style: italic;">Image size must be maximum of <?= $product_dimensions->product_image_width; ?> (width) x <?= $product_dimensions->product_image_height; ?> (height) pixel, jpg/png</span>
<span style="color:#F7931E;"><?php echo form_error('image6'); ?></span>
<?php echo $this->session->flashdata('image6-error'); //to display error message ?>
</div><!-- end class="col-sm-9" -->
<div class="col-sm-9 offset-sm-3" style="margin-top: 20px;">
<?php
$icon_image = $this->db->select('icon_url')->from('product_image_icon')->where('product_id',$products->id_products)->where('image_target','image6')->get()->row()->icon_url;
if($icon_image != null):
?>
<img src="<?= base_url() . 'uploads/product/icon/'.$icon_image;?>" style="width: 5%;height: auto;border-radius: 10px;" alt="">
<?php endif; ?>
</div>
</div> <!-- end row -->
<div style="display: none;">
<div class="row">
<div class="col-sm-12">
<h4>SEO (Search Engine Optimization)</h4>
</div><!-- end class="col-sm-12" -->
</div> <!-- end row -->
<div class="row">
<div class="col-sm-3">
<p>Page Meta Description</p>
</div><!-- end class="col-sm-3" -->
<div class="col-sm-9">
<p>
<?php
$data = array(
'name' => 'meta_description',
'value' => set_value('meta_description', $products->meta_description),
'class' => 'form-control'
);
echo form_input($data); ?>
<?= form_error('meta_description'); ?></p>
</div><!-- end class="col-sm-9" -->
</div> <!-- end row -->
<div class="row">
<div class="col-sm-3">
<p>Page Meta Keywords<br>(separated with comma)</p>
</div><!-- end class="col-sm-3" -->
<div class="col-sm-9">
<p>
<?php
$data = array(
'name' => 'meta_keywords',
'value' => set_value('meta_keywords', $products->meta_keywords),
'class' => 'form-control'
);
echo form_input($data); ?>
<?= form_error('meta_keywords'); ?></p>
</div><!-- end class="col-sm-9" -->
</div> <!-- end row -->
<div class="col-sm-3">
<p>Product Color Code<br>
(leave blank if not applied)</p>
</div><!-- end class="col-sm-3" -->
<div class="col-sm-9">
<div id="cp2" class="input-group colorpicker-component">
<input name="color_code" type="text" value="<?= $products->color_code; ?>" class="form-control" />
<span class="input-group-addon"><i style="border:1px solid black;"></i> (click icon to choose color)</span>
</div>
<script>
$(function() {
$('#cp2').colorpicker();
});
</script>
<?= form_error('color_code'); ?>
</div><!-- end class="col-sm-9" -->
</div> <!-- end row -->
<?php if(!isset($new_product)) : ?>
<div class="row" style="display: none;">
<div class="col-sm-12">
<h4>Color Link to other product (leave empty if not applied)</h4>
</div><!-- end class="col-sm-12" -->
</div> <!-- end row -->
<div class="row" style="display: none;">
<div class="col-sm-3">
<p>Choose Category</p>
</div><!-- end class="col-sm-3" -->
<div class="col-sm-9">
<select id="link_category" name="link_category" class="form-control">
<?php
//get parent category id and name and parent from categories table
$this->db->select('id_categories, category')->from('categories')->where('parent', NULL)->order_by('priority', 'ASC');
$categories = $this->db->get()->result();
?>
<option value="">Select Category ...</option>
<?php foreach ($categories as $category) : ?>
<option value="<?= $category->id_categories; ?>"
<?php if (isset($category_id)) : ?>
<?php if ($category->id_categories == $category_id) : ?>
selected
<?php endif; ?>
<?php endif; ?>
><?= ucwords($category->category); ?></option>
<?php
//check if the current id does have child
$this->db->select('*')->from('categories')->where('parent', $category->id_categories);
$count_child_category = $this->db->get()->num_rows();
?>
<?php if ($count_child_category > 0): ?>
<?php
//get all existing child categories
$this->db->select('id_categories, category')->from('categories')->where('parent', $category->id_categories)->order_by('priority', 'ASC');
$child_categories = $this->db->get()->result();
?>
<?php foreach ($child_categories as $child_category) : ?>
<option style="margin-left: 10px;"value="<?= $child_category->id_categories; ?>"
<?php if (isset($category_id)) : ?>
<?php if ($child_category->id_categories == $category_id) : ?>
selected
<?php endif; ?>
<?php endif; ?>
>- <?= ucwords($child_category->category); ?></option>
<?php endforeach; ?>
<?php endif ?>
<?php endforeach; ?>
</select>
</div><!-- end class="col-sm-9" -->
</div> <!-- end row -->
<div class="row" style="display: none;">
<div class="col-sm-3">
<p>Choose Product</p>
</div><!-- end class="col-sm-3" -->
<div class="col-sm-9">
<select id="link_product" name="link_product" class="form-control"></select>
<br>
<input class="btn btn-primary" type="submit" name="productAddLink" id="productAddLink" value="Add to Link">
<div id="link_product_result">
<br>
<p><strong>LINK TO OTHER PRODUCTS</strong></p>
<table class="table table-striped">
<tr>
<th>Product Name</th>
<th>Color</th>
<th>Delete</th>
</tr>
<?php
//get link products data
$this->db->select('*')->from('product_link')->where('product_id', $products->id_products);
$link_products = $this->db->get()->result();
?>
<?php foreach( $link_products as $item) : ?>
<?php
//get item details
$this->db->select('title, color_code, id_products')->from('products')->where('id_products', $item->link_to_product_id);
$link_product_data = $this->db->get()->row();
?>
<tr>
<td><?= ucwords($link_product_data->title); ?></td>
<td><div style="background:<?= $link_product_data->color_code; ?>; width:20px; height:20px;"></div> <?= $link_product_data->color_code; ?></td>
<td><a href="<?= base_url() . 'admin/products/delete_link_product/' . $item->id_product_link . '/' . $products->id_products; ?>"><i class="fa fa fa-trash-o" aria-hidden="true"></i></a></td>
</tr>
<?php endforeach; ?>
</table>
</div>
</div><!-- end class="col-sm-9" -->
</div> <!-- end row -->
<script>
$(document).ready(function() {
$('#link_category').change(function() {
var category_id = $(this).val();
ajaxGetProducts(category_id);
});
$('#productAddLink').click(function(event) {
event.preventDefault();
var link_product_id = $('#link_product').val();
if(link_product_id.length != 0) {
ajaxAddLinkProducts(link_product_id);
}
});
function ajaxGetProducts(category_id) {
$.ajax({
'url' : '<?= base_url('admin/products/ajax_get_link_products'); ?>',
'type' : 'post',
'data' : {
'category_id' : category_id,
'<?= $this->security->get_csrf_token_name(); ?>' : '<?= $this->security->get_csrf_hash(); ?>'
},
'success' : function(data) {
$('#link_product').html(data);
}
});
}
function ajaxAddLinkProducts(link_product_id) {
$.ajax({
'url' : '<?= base_url('admin/products/ajax_add_link_products'); ?>',
'type' : 'post',
'data' : {'current_product_id' : '<?= $products->id_products; ?>',
'link_product_id' : link_product_id,
'<?= $this->security->get_csrf_token_name(); ?>' : '<?= $this->security->get_csrf_hash(); ?>'
},
'success' : function(data) {
$('#link_product_result').html(data);
}
});
}
});
</script>
<?php endif; ?>
<?php if(!isset($new_product)) : ?>
<div class="row" style="display: none;">
<div class="col-sm-12">
<h4>Quantity Discount (leave empty if not applied)</h4>
</div><!-- end class="col-sm-12" -->
</div> <!-- end row -->
<div class="row" style="display: none;">
<div class="col-sm-3">
<p>Activate Quantity Discount ?</p>
</div><!-- end class="col-sm-3" -->
<div class="col-sm-9">
<select name="quantity_discount_active" class="form-control">
<option value="no"
<?php if($products->quantity_discount_active == 'no') : ?>
selected
<?php endif; ?>
>No</option>
<option value="retail"
<?php if($products->quantity_discount_active == 'retail') : ?>
selected
<?php endif; ?>
>Retail Only</option>
<option value="reseller"
<?php if($products->quantity_discount_active == 'reseller') : ?>
selected
<?php endif; ?>
>Reseller Only</option>
<option value="retail-reseller"
<?php if($products->quantity_discount_active == 'retail-reseller') : ?>
selected
<?php endif; ?>
>Retail & Reseller</option>
</select>
</div><!-- end class="col-sm-9" -->
</div> <!-- end row -->
<div class="row" style="display: none;">
<div class="col-sm-3">
<p>Quantity Discount<br>in percentage (%)</p>
</div><!-- end class="col-sm-3" -->
<div class="col-sm-9">
Quantity: <input class="form-control" id="min_quantity" type="text" name="min_quantity" placeholder="input quantity"><br>Discount (%): <input class="form-control" type="text" name="quantity_discount" id="quantity_discount" placeholder="input percentage discount"><br>
<input class="btn btn-primary" type="submit" name="quantitydisocuntsubmit" id="quantitydisocuntsubmit" value="Add Quantity Discount">
<script>
$(document).ready(function() {
$('#quantitydisocuntsubmit').click(function(event) {
event.preventDefault();
var min_quantity = $('#min_quantity').val();
var quantity_discount = $('#quantity_discount').val();
ajaxAddQuantityDiscount(min_quantity, quantity_discount);
});
function ajaxAddQuantityDiscount(min_quantity, quantity_discount) {
$.ajax({
'url' : '<?= base_url('admin/products/ajax_add_quantitydiscount'); ?>',
'type' : 'post',
'data' : {
'min_quantity' : min_quantity,
'quantity_discount' : quantity_discount,
'id_product' : <?= $products->id_products; ?>,
'<?= $this->security->get_csrf_token_name(); ?>' : '<?= $this->security->get_csrf_hash(); ?>'
},
'success' : function(data) {
$('#quantityDiscountDisplay').html(data);
}
});
}
});
</script>
<br><br>
<div id="quantityDiscountDisplay">
<p><strong>QUANTITY DISCOUNT</strong></p>
<table class="table table-striped">
<tr>
<td>Quantity</td>
<td>Discount (%)</td>
<td>Delete</td>
</tr>
<?php
//get all quantity discount
$this->db->select('*')->from('quantity_discount')->where('product_id', $products->id_products)->order_by('min_quantity', 'ASC');
$quantity_discount = $this->db->get()->result();
?>
<?php $quantity_count = 0; ?>
<?php foreach ($quantity_discount as $discount) : ?>
<?php $quantity_count++; ?>
<tr>
<td><?= $discount->min_quantity; ?></td>
<td><?= $discount->discount_percentage; ?></td>
<td><a id="deleteQuantityDiscount<?= $quantity_count; ?>" href="<?= base_url() . 'admin/products/ajax_delete_quantitydiscount/' . $discount->id_quantity_discount; ?>"><i class="fa fa fa-trash-o" aria-hidden="true"></i></a></td>
</tr>
<script>
$(document).ready(function() {
$('a#deleteQuantityDiscount<?= $quantity_count; ?>').click(function(event) {
event.preventDefault();
$.ajax({
'url' : $(this).attr('href'),
'data' : {
'<?= $this->security->get_csrf_token_name(); ?>' : '<?= $this->security->get_csrf_hash(); ?>'
},
'success' : function(result) {
$('#quantityDiscountDisplay').html(result);
}
});
});
});
</script>
<?php endforeach; ?>
</table>
</div>
</div><!-- end class="col-sm-9" -->
</div> <!-- end row -->
<?php endif; ?>
<div class="row">
<div class="col-sm-3">
</div><!-- end class="col-sm-3" -->
<div class="col-sm-9">
<?= form_submit('submit', 'Save Project', 'class="btn btn-primary btn-success button-brown"'); ?>
<?= anchor('admin/products', 'cancel'); ?>
</div><!-- end class="col-sm-9" -->
</div><!--end row -->
<?= form_close(); ?>
<script>
$(document).ready(function() {
//submit form, check SKUs must not be the same..
$('form').submit(function(e){
var skuArray = []; //set sku array as empty array...
//add all sku input values into empty array
for(var i = 0; i < 20; i++) {
if($('#sku' + i).val() != '') {
skuArray.push($('#sku' + i).val());
}
}
//check for duplicate input. same row array will not be checked..
for (x = 0; x < skuArray.length; x++) {
for(var i = 0; i < 20; i++) {
if(i != x) {
if($('#sku' + i).val() == skuArray[x]) {
e.preventDefault();
alert('Check your input SKU. SKU must not the same.');
return false;
break;
}
}
}
}
});
});
</script>