|
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/kamariallee.com/public_html/application/views/admin/products/ |
Upload File : |
<style>
table {
table-layout: fixed;
}
input[type=text] {background-color:#F9F9F9 !important; border: 1px solid grey; width: 95%;}
</style>
<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 Product List Page</a><br><br>
<h4><?= empty($products->id_products) ? 'Add a new product' : 'Edit Product: '
. $products->title; ?></h4>
<?= $this->session->flashdata('success'); //to display success message ?>
<?= $this->session->flashdata('result'); //to display result message ?>
</div>
</div>
<?= form_open_multipart(); ?>
<p style="text-align:right;"><?= form_submit('submit', 'Save Product', '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>Display</p>
</div>
<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>
</div>
<div class="row">
<div class="col-sm-3">
<p>Product Name</p>
</div>
<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>
</div>
<div class="row">
<div class="col-sm-3">
<p>International Custom Order</p>
</div>
<div class="col-sm-9">
<select name="international_custom_order" class="form-control">
<option value="no" <?php echo set_select('international_custom_order', 'no'); ?>
<?php if($products->international_custom_order == 'no') : ?>
selected
<?php endif; ?>
>No</option>
<option value="yes" <?php echo set_select('international_custom_order', 'yes'); ?>
<?php if($products->international_custom_order == 'yes') : ?>
selected
<?php endif; ?>
>Yes</option>
</select>
</div>
</div>
<div class="row">
<div class="col-sm-3">
<p>Brand</p>
</div>
<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>
</div>
<div class="row">
<div class="col-sm-3">
<p>Category</p>
</div>
<div class="col-sm-9">
<div style="height: 200px; overflow-y: scroll; padding: 20px; border:1px solid #ccc;">
<?php foreach($parent_categories as $category) : ?>
<input style="position:relative; bottom:3px; margin-right: 10px;" type="checkbox" name="category_id[]" value="<?= $category->id_categories; ?>" <?= set_checkbox('category_id[]', $category->id_categories); ?>
<?php if (isset($chosen_categories)) : ?>
<?php //checked item
foreach ($chosen_categories as $chosen_category) : ?>
<?php if ($chosen_category->id_category == $category->id_categories) : ?>
checked
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
> <?= 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>
</div>
<div class="row">
<div class="col-sm-3">
<p>Pre-Order Message<br>(Left empty if unused)</p>
</div>
<div class="col-sm-9">
<p>
<?php
$data = array(
'name' => 'preorder_message',
'value' => set_value('preorder_message', $products->preorder_message),
'class' => 'form-control'
);
if(empty($products->id_products)) {
$data['value'] = set_value('preorder_message', 'Pre - Order (7-14 days)', $products->preorder_message);
} else {
$data['value'] = set_value('preorder_message', $products->preorder_message);
}
echo form_input($data); ?>
<?= form_error('preorder_message'); ?></p>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<h4>Product Images (Up to 5 images)</h4>
<?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>
</div>
<div class="row">
<div class="col-sm-3">
<p>Product Image 1 (Cover Image)<br>
<?php if ($products->image1 != NULL): ?>
Image Preview: <img src="<?= base_url() . 'uploads/product/' .
$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>
<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 1000 pixel (width) x 1200 pixel (height), jpg/jpeg/png, max 800KB</span>
<span style="color:#F7931E;"><?php echo form_error('image1'); ?></span>
<?php echo $this->session->flashdata('image1-error'); //to display error message ?>
</div>
</div>
<div class="row">
<div class="col-sm-3">
<p>Product Image 2<br>
<?php if ($products->image2 != NULL): ?>
Image Preview: <img src="<?= base_url() . 'uploads/product/' .
$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>
<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 1000 pixel (width) x 1000 pixel (height), jpg/jpeg/png, max 800KB</span>
<span style="color:#F7931E;"><?php echo form_error('image2'); ?></span>
<?php echo $this->session->flashdata('image2-error'); //to display error message ?>
</div>
</div>
<div class="row">
<div class="col-sm-3">
<p>Product Image 3<br>
<?php if ($products->image3 != NULL): ?>
Image Preview: <img src="<?= base_url() . 'uploads/product/' .
$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>
<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 1000 pixel (width) x 1000 pixel (height), jpg/jpeg/png, max 800KB</span>
<span style="color:#F7931E;"><?php echo form_error('image3'); ?></span>
<?php echo $this->session->flashdata('image3-error'); //to display error message ?>
</div>
</div>
<div class="row">
<div class="col-sm-3">
<p>Product Image 4<br>
<?php if ($products->image4 != NULL): ?>
Image Preview: <img src="<?= base_url() . 'uploads/product/' .
$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>
<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 1000 pixel (width) x 1000 pixel (height), jpg/jpeg/png, max 800KB</span>
<span style="color:#F7931E;"><?php echo form_error('image4'); ?></span>
<?php echo $this->session->flashdata('image4-error'); //to display error message ?>
</div>
</div>
<div class="row">
<div class="col-sm-3">
<p>Product Image 5<br>
<?php if ($products->image5 != NULL): ?>
Image Preview: <img src="<?= base_url() . 'uploads/product/' .
$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>
<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 1000 pixel (width) x 1000 pixel (height), jpg/jpeg/png, max 800KB</span>
<span style="color:#F7931E;"><?php echo form_error('image5'); ?></span>
<?php echo $this->session->flashdata('image5-error'); //to display error message ?>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<h4>Product Details</h4>
<p>Please Fill in the option combinations. Field "Stocks" must not empty.</p>
</div>
</div>
<div class="row">
<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? All 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 = count($this->db->get()->result());
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">
<tr>
<?php foreach ($options as $option) : ?>
<?php if($option->id_product_size == 3 || $option->id_product_size == 4) : ?>
<th class="col-1"><?= ucwords($option->product_size); ?></th>
<?php endif; ?>
<?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>Image</th>
</tr>
<?php for($y = 0 ; $y < 10; $y++) : ?>
<?php
//get attribute items
if (isset($current_product_details[$y])) {
$attribute_items = $current_product_details[$y]['attributes'];
//convert $attribute_items to become array
$attribute_items_array = explode(',', $attribute_items);
$attribute_items_count = count($attribute_items_array);
}
?>
<tr>
<?php $option_count = 0; ?>
<?php foreach ($options as $option) : ?>
<?php if($option->id_product_size == 3 || $option->id_product_size == 4) : ?>
<td>
<select class="form-control" name="select<?= $y ?>[]">
<option value="">Select..</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->product_attributes; ?>"
<?php if (isset($current_product_details[$y])) : ?>
<?php if($attribute->product_attributes == $attribute_items_array[$option_count]) : ?>
selected
<?php endif; ?>
<?php endif; ?>
><?= $attribute->product_attributes; ?></option>
<?php endforeach; ?>
</select>
</td>
<?php endif; ?>
<?php $option_count++; ?>
<?php endforeach; ?>
<?php if (isset($current_product_details[$y])) : ?>
<td><input type="text" name="stock[]" value="<?= $current_product_details[$y]['stock']; ?>"></td>
<td><input type="text" name="sku[]" value="<?= $current_product_details[$y]['sku']; ?>"></td>
<td><input type="text" name="price[]" value="<?= $current_product_details[$y]['price']; ?>"></td>
<td><input type="text" name="discounted_price[]" value="<?= $current_product_details[$y]['discounted_price']; ?>"></td>
<td><input type="text" name="weight[]" value="<?= $current_product_details[$y]['weight']; ?>"></td>
<td>
<select class="form-control" name="image[]">
<option value="">Select..</option>
<?php for ($i=1; $i <= 5; $i++) : ?>
<option value="image<?= $i ?>"
<?php if(isset($current_product_details[$y]) && $current_product_details[$y]["image"] == "image{$i}") : ?>
selected
<?php endif; ?>
>Image <?= $i ?>
</option>
<?php endfor; ?>
</select>
</td>
<?php else : ?>
<td><input type="text" name="stock[]"></td>
<td><input type="text" 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>
<select class="form-control" name="image[]">
<option value="">Select..</option>
<?php for ($x=1; $x <= 5; $x++) : ?>
<option value="image<?= $x ?>">Image <?= $x ?></option>
<?php endfor; ?>
</select>
</td>
<?php endif; ?>
</tr>
<?php endfor; ?>
</table>
</div><!-- end class table-responsive-->
<?php endif; ?><!-- end if($count_options == 0) -->
</div>
</div>
<div class="row">
<div class="col-sm-12">
<h4>Customize Product</h4>
<p>Please choose customize options.</p>
</div>
</div>
<div class="row">
<div class="col-sm-3">
<p>Heels Type</p>
</div>
<div class="col-sm-9">
<div style="height: 150px; overflow-y: scroll; padding: 20px; border:1px solid #ccc;">
<?php foreach($heels_type as $item) : ?>
<input style="position:relative; bottom:3px; margin-right: 10px;" type="checkbox" name="heels_type[]" value="<?= $item['id_product_attributes']; ?>" <?= set_checkbox('heels_type[]', $item['id_product_attributes']); ?>
<?php if (isset($chosen_heels_type)) : ?>
<?php //checked item
foreach ($chosen_heels_type as $chosen) : ?>
<?php if ($chosen['id_attribute'] == $item['id_product_attributes']) : ?>
checked
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
> <?= ucfirst($item['product_attributes']); ?> - Additional price: Rp <?= number_format($item['additional_price'], 0, ',', '.'); ?><br>
<?php endforeach; ?>
</div>
<?= form_error('heels_type'); ?>
</div>
</div>
<div class="row">
<div class="col-sm-3">
<p>Heels Height</p>
</div>
<div class="col-sm-9">
<div style="height: 150px; overflow-y: scroll; padding: 20px; border:1px solid #ccc;">
<?php foreach($heels_height as $item) : ?>
<input style="position:relative; bottom:3px; margin-right: 10px;" type="checkbox" name="heels_height[]" value="<?= $item['id_product_attributes']; ?>" <?= set_checkbox('heels_height[]', $item['id_product_attributes']); ?>
<?php if (isset($chosen_heels_height)) : ?>
<?php //checked item
foreach ($chosen_heels_height as $chosen) : ?>
<?php if ($chosen['id_attribute'] == $item['id_product_attributes']) : ?>
checked
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
> <?= ucfirst($item['product_attributes']); ?> - Additional price: Rp <?= number_format($item['additional_price'], 0, ',', '.'); ?><br>
<?php endforeach; ?>
</div>
<?= form_error('heels_height'); ?>
</div>
</div>
<div class="row">
<div class="col-sm-3">
<p>Platform Style</p>
</div>
<div class="col-sm-9">
<div style="height: 150px; overflow-y: scroll; padding: 20px; border:1px solid #ccc;">
<?php foreach($platform_style as $item) : ?>
<input style="position:relative; bottom:3px; margin-right: 10px;" type="checkbox" name="platform_style[]" value="<?= $item['id_product_attributes']; ?>" <?= set_checkbox('platform_style[]', $item['id_product_attributes']); ?>
<?php if (isset($chosen_platform_style)) : ?>
<?php //checked item
foreach ($chosen_platform_style as $chosen) : ?>
<?php if ($chosen['id_attribute'] == $item['id_product_attributes']) : ?>
checked
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
> <?= ucfirst($item['product_attributes']); ?> - Additional price: Rp <?= number_format($item['additional_price'], 0, ',', '.'); ?><br>
<?php endforeach; ?>
</div>
<?= form_error('platform_style'); ?>
</div>
</div>
<div class="row">
<div class="col-sm-3">
<p>Platform Height</p>
</div>
<div class="col-sm-9">
<div style="height: 150px; overflow-y: scroll; padding: 20px; border:1px solid #ccc;">
<?php foreach($platform_height as $item) : ?>
<input style="position:relative; bottom:3px; margin-right: 10px;" type="checkbox" name="platform_height[]" value="<?= $item['id_product_attributes']; ?>" <?= set_checkbox('platform_height[]', $item['id_product_attributes']); ?>
<?php if (isset($chosen_platform_height)) : ?>
<?php //checked item
foreach ($chosen_platform_height as $chosen) : ?>
<?php if ($chosen['id_attribute'] == $item['id_product_attributes']) : ?>
checked
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
> <?= ucfirst($item['product_attributes']); ?> - Additional price: Rp <?= number_format($item['additional_price'], 0, ',', '.'); ?><br>
<?php endforeach; ?>
</div>
<?= form_error('platform_height'); ?>
</div>
</div>
<div class="row" style="display:none">
<div class="col-sm-3">
<p>Product Color Code<br>
(leave blank if not applied)</p>
</div>
<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>
</div>
<?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>
</div>
<div class="row" style="display:none">
<div class="col-sm-3">
<p>Choose Category</p>
</div>
<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>
</div>
<div class="row" style="display:none">
<div class="col-sm-3">
<p>Choose Product</p>
</div>
<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>
</div>
<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},
'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
},
'success' : function(data) {
$('#link_product_result').html(data);
}
});
}
});
</script>
<?php endif; ?>
<div class="row">
<div class="col-sm-3">
<p>Set as New Arrival ?</p>
</div>
<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>
</div>
<div class="row" style="display:none">
<div class="col-sm-3">
<p>Set as Featured Product ?</p>
</div>
<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>
</div>
<div class="row" style="display:none">
<div class="col-sm-3">
<p>Set as Best Seller ?</p>
</div>
<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>
</div>
<div class="row">
<div class="col-sm-3">
<p>Description</p>
</div>
<div class="col-sm-9">
<div class="tabbable">
<ul class="nav nav-tabs">
<li class="active"><a href="#description_id" data-toggle="tab">Description</a></li>
<!-- <li><a href="#description_en" data-toggle="tab">English</a></li> -->
</ul>
<div class="tab-content">
<div class="tab-pane active" id="description_id">
<?php echo form_textarea('description', set_value('description',
$products->description, FALSE)); ?>
<?php echo form_error('description'); ?>
</div><!-- end id="#description_id" -->
<div class="tab-pane" id="description_en">
<?php echo form_textarea('description_en', set_value('description_en',
$products->description_en, FALSE)); ?>
<?php echo form_error('description_en'); ?>
</div><!-- end id="#description_id" -->
</div><!-- end class tab-content-->
</div><!-- end tabbable -->
</div>
</div>
<div class="row">
<div class="col-sm-3">
<p>Detail</p>
</div>
<div class="col-sm-9">
<div class="tabbable">
<ul class="nav nav-tabs">
<li class="active"><a href="#longdescription_id" data-toggle="tab">Detail</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>
</div>
<div class="row" style="display:none">
<div class="col-sm-3">
<p>Specification / Additional Infos</p>
</div>
<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>
</div>
<div class="row">
<div class="col-sm-12">
<h4>SEO (Search Engine Optimization)</h4>
</div>
</div>
<div class="row">
<div class="col-sm-3">
<p>Page Meta Description</p>
</div>
<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>
</div>
<div class="row">
<div class="col-sm-3">
<p>Page Meta Keywords<br>(separated with comma)</p>
</div>
<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>
</div>
<?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>
</div>
<div class="row" style="display:none;">
<div class="col-sm-3">
<p>Quantity Discount<br>in percentage (%)</p>
</div>
<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; ?>},
'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'),
'success' : function(data) {
$('#quantityDiscountDisplay').html(data);
}
});
});
});
</script>
<?php endforeach; ?>
</table>
</div>
</div>
</div>
<?php endif; ?>
<div class="row">
<div class="col-sm-3">
</div>
<div class="col-sm-9">
<?= form_submit('submit', 'Save Product', 'class="btn btn-primary btn-success button-brown"'); ?>
<?= anchor('admin/products', 'cancel'); ?>
</div>
</div><!--end row -->
<?= form_close(); ?>