CHANGE_zclient feedback in product and sales

This commit is contained in:
Gowtham M 2024-11-27 14:38:06 +05:30
parent 9f41c55910
commit 4ebcac1890
12 changed files with 238 additions and 36 deletions

View File

@ -74,6 +74,7 @@ $routes->get("product_list_for_service", "Products::product_list_for_service");
$routes->post('status_product', 'Products::status_product');
$routes->get('delete_product_name/(:any)', 'Products::delete_product_name/$1');
$routes->get('get_product_addtional_details/(:any)', 'Products::get_product_addtional_details/$1');
$routes->get('product_categories', 'Products::product_categories');
//end products//
//Sales order //

View File

@ -20,10 +20,10 @@ class ProductCategory extends BaseController
public function index()
{
// print_r($this->session->get());die;
$ProductCategoryModel = new ProductCategoryModel();
$productcategory = $ProductCategoryModel->orderBy('product_category_id')->findAll();
$data['productcategory']=$productcategory;
$data['productcategory'] = $productcategory;
return view('product_category_list',$data);
}
@ -40,21 +40,39 @@ class ProductCategory extends BaseController
try {
$data['business_id'] = $this->session->get('logged_user_business_id');
$data['created_by'] = $logged_user;
// Check for duplicate entry
$existing = $ProductCategoryModel->where('product_category_name', $product_category_name)->first();
if ($existing) {
return $this->respond([
'status' => 'failed',
'code' => 200,
'data' => 'Duplicate entry detected.'
], 200);
}
// Insert data if no duplicate found
$inserted = $ProductCategoryModel->insert($data);
} catch (\CodeIgniter\Database\Exceptions\DatabaseException $e) {
return $this->respond(['status' => 'failed','code' => 404,'data' => $e->getMessage()],200);
return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $e->getMessage()], 500);
}
if ($inserted) {
$result = $data;
$product_category_list = $ProductCategoryModel->orderBy('product_category_id','asc')->findAll();
return $this->respond(['status' => 'success','code' => 200,'data' => $result,'product_category_list'=>$product_category_list],200);
$product_category_list = $ProductCategoryModel->orderBy('product_category_id', 'asc')->findAll();
return $this->respond([
'status' => 'success',
'code' => 200,
'data' => $result,
'product_category_list' => $product_category_list
], 200);
} else {
$result = "No Match's";
return $this->respond(['status' => 'failed','code' => 404,'data' => $result],404);
$result = "Insert failed.";
return $this->respond(['status' => 'failed', 'code' => 400, 'data' => $result], 400);
}
}else{
$data['updated_by'] = $logged_user;
$updated = $ProductCategoryModel->update($product_category_id,$data);

View File

@ -38,26 +38,39 @@ class Products extends BaseController
$this->additionalProductNameModal = new AdditionalProductNameModal();
}
public function product_categories()
{
$ProductCategoryModel = new ProductCategoryModel();
$productcategory = $ProductCategoryModel->orderBy('product_category_id')->findAll();
$data['productcategory'] = $productcategory;
return view('product_categories',$data);
}
public function product_index($manufacturer_id = null)
{
if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
$category = $this->request->getGet('category');
if ($manufacturer_id) {
$products = $this->ProductModel->where('manufacturer_id',$manufacturer_id)->orderBy('product_name')->findAll();
$data['products'] = $this->ProductModel->where('manufacturer_id',$manufacturer_id)->orderBy('product_name')->findAll();
$manufacturer = $this->ManufacturerModel->where('manufacturer_id',$manufacturer_id)->select('manufacturer_name')->first();
$data['products']=$products;
$data['manufacturer_id'] = $manufacturer_id;
$data['manufacturer_name'] = $manufacturer['manufacturer_name'];
return view('product_list',$data);
} else {
} else if(isset($category)) {
$products = $this->ProductModel->get_products($this->session->get('logged_user_branch_id'));
$data['products']=$products;
// echo "<pre>";
// print_r($products);die;
$data['products'] = $this->ProductModel->get_products($this->session->get('logged_user_branch_id'),$category);
$data['manufacturer_id'] = $manufacturer_id;
return view('product_list',$data);
}else {
$data['products'] = $this->ProductModel->get_products($this->session->get('logged_user_branch_id'));
$data['manufacturer_id'] = $manufacturer_id;

View File

@ -19,14 +19,13 @@ class ClientDetailsUpdate
$client_id = $VehicleModel->where('vehicle_id', $vehicle_id)->get()->getRow()->client_id;
$data = [
'address' => $address['billing_address'],
'city' => $address['billing_city'],
'state' => $address['billing_state'],
'postal_code' => $address['billing_postal_code']
];
$VehicleModel->update($vehicle_id, $data);
$update = $ClientModel->update($client_id, $data);
if($update){

View File

@ -28,11 +28,15 @@ class ProductModel extends Model
}
}
public function get_products($branch_id)
public function get_products($branch_id,$category = null)
{
$this->select('products.*, manufacturer.manufacturer_name');
$this->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id','left');
$this->where('products.branch_id', $branch_id);
if($category != null)
{
$this->where('products.product_category', $category);
}
$this->orderBy('products.product_name');
return $this->findAll();
}

View File

@ -84,7 +84,7 @@
</tbody>
</table>
<p style="height: 0px;">&nbsp;</p>
<table style="border-collapse: collapse; width: 100%; height: 252px;" border="0">
<table style="border-collapse: collapse; width: 100%;" border="0">
<thead>
<tr style="height: 36px; border: 1px solid lightgrey;background: lightgray; font-size: x-small;">
@ -112,14 +112,14 @@
?>
<tr >
<td style="width: 10%; height: 5px;text-align: center; font-size: small;"> <?= $key+1; ?> </td>
<td style="width: 10%; height: 5px; font-size: small;"> <?= $value->product_name; ?> </td>
<td style="width: 10%; height: 5px;text-align: center; font-size: small;"><?php echo $value->net_price; ?></td>
<td style="width: 10%; height: 5px;text-align: center; font-size: small;"><?= $value->qty; ?></td>
<td style="width: 10%; height: 5px;text-align: center; font-size: small;"><?= $value->per; ?></td>
<td style="width: 10%; height: 5px;text-align: center; font-size: small;"><?= $value->tax; ?></td>
<td style="width: 10%; height: 5px;text-align: center; font-size: small;">&nbsp;<?php echo number_format($tax, 2, '.', ''); ?></td>
<td style="width: 10%; height: 5px;text-align: right; font-size: small;"><?php echo number_format($value->amount, 2, '.', ''); ?></td>
<td style="width: 10%; padding:10px; text-align: center; font-size: small;"> <?= $key+1; ?> </td>
<td style="width: 10%; padding:10px; font-size: small;"> <?= $value->product_name; ?> </td>
<td style="width: 10%; padding:10px; text-align: center; font-size: small;"><?php echo $value->net_price; ?></td>
<td style="width: 10%; padding:10px; text-align: center; font-size: small;"><?= $value->qty; ?></td>
<td style="width: 10%; padding:10px; text-align: center; font-size: small;"><?= $value->per; ?></td>
<td style="width: 10%; padding:10px; text-align: center; font-size: small;"><?= $value->tax; ?></td>
<td style="width: 10%; padding:10px; text-align: center; font-size: small;">&nbsp;<?php echo number_format($tax, 2, '.', ''); ?></td>
<td style="width: 10%; padding:10px; text-align: right; font-size: small;"><?php echo number_format($value->amount, 2, '.', ''); ?></td>
</tr>
<?php } ?>

View File

@ -418,7 +418,8 @@
<div class="collapse" id="sidebarLayouts">
<ul class="nav-second-level">
<li>
<a href="<?php echo base_url('product_index') ?>">Products</a>
<!-- <a href="<?php echo base_url('product_index') ?>">Products</a> -->
<a href="<?php echo base_url('product_categories') ?>">Products</a>
</li>
<li>
<a href="<?php echo base_url('product_category_index') ?>">Product Category</a>

View File

@ -0,0 +1,136 @@
<?php include('layout/header.php'); ?>
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title">Product Category</h4>
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class="">
<a href="<?= base_url() . "product_index"; ?>" class="btn btn-primary waves-effect"> View All Product</a>
<a href="<?= base_url() . "new_product/0"; ?>" class="btn btn-primary waves-effect"> Add New Product</a>
</li>
</ol>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<table id="datatable-productcategory" class="table table-striped dt-responsive nowrap w-100" style="width:100% !important;text-align: center;width: 100%;">
<thead>
<tr>
<th>Product Category</th>
<th>Status</th>
<th>Products</th>
</tr>
</thead>
<tbody>
<?php foreach ($productcategory as $index => $item): ?>
<tr class="productcategory_tr_<?php echo $index+1; ?>">
<td class="productcategory"><?php echo $item['product_category_name']; ?></td>
<td>
<?php if($item['isactive'] == 1): ?>
<span style="color:green">Active</span>
<?php else: ?>
<span style="color:red">Inactive</span>
<?php endif; ?>
</td>
<td>
<a href="<?php echo base_url('product_index?category=').$item['product_category_name']; ?>" ><i class="ri-eye-line" style="font-size: 15px;"></i></a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?php include('layout/footer.php'); ?>
<script>
var datatable_make ='';
$(document).ready(function() {
datatable_make = $('#datatable-productcategory').DataTable({
"order": [[0, 'asc']], // Set initial sorting to descending on the first column
"dom": 'Bfrtip', // Show export buttons
"buttons": [{extend: 'pdfHtml5',title: 'Products', text: 'PDF',},
{extend: 'print',title: 'Products',text: 'Print',},
{extend: 'copy',text: 'Copy', titleAttr: 'Copy',},
{extend: 'csv',text: 'CSV', title: 'Products', }],
"language": {
"search": "Search: " // Customize search label
},
});
//Start DataTable Paging is session is set
var savedPage = sessionStorage.getItem('currentPage');
var hightlight_tr = sessionStorage.getItem('hightlight_tr');
// console.log(savedPage);
// console.log(hightlight_tr);
// Ensure savedPage is a number
savedPage = parseInt(savedPage);
// Check if savedPage is not null and adjust if necessary
if (savedPage !== null && !isNaN(savedPage)) {
// Check if the saved page number is within the bounds of the current DataTable
var totalPages = datatable_make.page.info().pages; // Total number of pages in the DataTable
if (savedPage >= totalPages) {
// adjust to the last page of the DataTable
savedPage = totalPages > 0 ? totalPages - 1 : 0;
}
// Move DataTable to the saved page and draw
datatable_make.page(savedPage).draw(false);
// Select the highlighted row
var $row = $('.' + hightlight_tr);
// Smoothly scroll to the row and center it in the viewport
$('html, body').animate({
scrollTop: $row.offset().top - ($(window).height() / 2) + ($row.height() / 2)
}, 500, function() {
// After focusing, change background color
$row.css('background', '#faf6ca');
// Remove background color after 4 seconds
setTimeout(function() {
$row.css('background', '');
}, 4000);
});
}
sessionStorage.removeItem('currentPage');
sessionStorage.removeItem('hightlight_tr');
//End DataTable Paging is session is set
})
function datatablePC(value) {
var currentPage = datatable_make.page.info().page;
sessionStorage.setItem('currentPage', currentPage);
sessionStorage.setItem('hightlight_tr', value);
}
</script>

View File

@ -132,6 +132,7 @@
data: formData,
dataType: 'json',
success: function(response) {
console.log(response);
if (response.status == "failed") {
toastr.warning(response.data, 'Warning');
}else{

View File

@ -29,7 +29,9 @@
<div class="page-title-right">
<ol class="breadcrumb m-0">
<?php if(!$manufacturer_id) { ?>
<li class=""> <a href="<?= base_url() . "new_product/0"; ?>" class="btn btn-primary waves-effect"> Add Product</a>
<li class="">
<a href="<?= base_url() . "product_categories"; ?>" class="btn btn-primary waves-effect">Categories View</a>
<a href="<?= base_url() . "new_product/0"; ?>" class="btn btn-primary waves-effect"> Add New Product</a>
</li>
<?php } ?>
</ol>

View File

@ -60,7 +60,7 @@
</div>
<div class="form-group col-md-4">
<label for="order_date" class="col-form-label">Order Date</label>
<input type="date" class="form-control" name="order_date" id="order_date" value="<?= empty($purchase['order_date']) ? date('Y-m-d') : date('Y-m-d', strtotime($purchase['order_date'])) ?>" readonly>
<input type="date" class="form-control" name="order_date" id="order_date" value="<?= empty($purchase['order_date']) ? date('Y-m-d') : date('Y-m-d', strtotime($purchase['order_date'])) ?>" >
</div>
<?php if (!empty($purchase["status"])): ?>
<div class="form-group col-md-4">

View File

@ -255,7 +255,7 @@
</td> -->
<td style="width:13%;">
<input type="text" class="form-control item-amount" name="amount[]"
value="<?= isset($salechild['amount']) ? $salechild['amount'] : '' ?>">
value="<?= isset($salechild['amount']) ? $salechild['amount'] : '' ?>" readonly>
</td>
<td hidden><input type="hidden"
value="<?= isset($salechild['sales_order_product_id']) ? $salechild['sales_order_product_id'] : '' ?>"
@ -580,9 +580,11 @@ $(document).ready(function() {
var quantity = $(this).closest('tr').find('.item-quantity').val(1);
if(productId == 0){
$(this).closest('tr').find('.item-quantity').prop('readonly', true);
$(this).closest('tr').find('.item-amount').prop('readonly', false);
}
console.log(products);
console.log(productId);
// Find product details from JSON
var product = products.find(function(item) {
return item.product_id == productId;
@ -609,6 +611,28 @@ $(document).ready(function() {
updateCalculations();
});
$(document).on('keyup', '.item-amount', function()
{
var total_amount = $(this).val();
var totalTax = $(this).closest('tr').find('.item-tax').val();
var unitPrice = total_amount / parseFloat((totalTax / 100) + 1);
var unitPrice = parseFloat(unitPrice).toFixed(2);
var taxAmt = total_amount - unitPrice;
var taxAmt = parseFloat(taxAmt).toFixed(2)
$(this).closest('tr').find('.tax-amount').val(taxAmt);
$(this).closest('tr').find('.item-rate').val(unitPrice);
$(this).closest('tr').find('.item-result').val(unitPrice);
updateCalculations();
});
// Event listener for quantity change
$(document).on('input', '.item-quantity', function() {
calculateAmount($(this).closest('tr'));
@ -740,7 +764,7 @@ $(document).ready(function() {
'<td style="width:14%;"><input type="text" class="form-control item-result" readonly /></td>' +
'<td style="width:8%;"><input type="text" class="form-control item-tax" name="item-tax[]" readonly /></td>' +
'<td style="width:13%;"><input type="text" class="form-control tax-amount" name="tax-amount[]" readonly /></td>' +
'<td style="width:13%;"><input type="text" class="form-control item-amount" name="amount[]"/></td>' +
'<td style="width:13%;"><input type="text" class="form-control item-amount" name="amount[]" readonly/></td>' +
'<td hidden><input type="hidden"></td>' +
'<td><center><i class="fa fa-trash remove-item"></i></center></td>' +
'</tr>';
@ -1125,6 +1149,9 @@ $(document).on('click', '#selectClient', function() {
}
});
</script>
<!-- script for set the product name id -->