CHANGE_MAKE_MODEL_REODERLIST : AADHAVAN

This commit is contained in:
aadhavan valli 2024-05-08 08:21:55 +05:30
parent 6b25c16edf
commit f2659976a9
11 changed files with 218 additions and 139 deletions

View File

@ -103,6 +103,7 @@ $routes->get('vendor_index/', 'Vendor::vendor_index');
$routes->post("add_vendor", "Vendor::add_vendor");
$routes->get("new_vendor/(:any)", "Vendor::new_vendor/$1");
$routes->get("delete_vendor/(:any)", "Vendor::delete_vendor/$1");
$routes->get("get_product_by_vendor/(:any)", "Vendor::get_product_by_vendor/$1");
$routes->post("fetch_models", "Vendor::fetch_models");
//end Vendor
@ -140,7 +141,7 @@ $routes->get('dashboard', 'Users::dashboard');
// Model //
$routes->get('bike_model_index/(:any)', 'Model::index/$1');
$routes->post('create_model/(:any)', 'Model::create_model/(:any)');
$routes->post('create_model/(:any)', 'Model::create_model/$1');
$routes->get('delete_model/(:any)', 'Model::delete_model/$1');
$routes->post('status_model', 'Model::status_model');
// Model End's//

View File

@ -35,12 +35,12 @@ class Complaint extends BaseController
"labour_charge" => $this->request->getPost('labour_charge'),
"cgst" => $this->request->getPost('tax')/2,
"sgst" => $this->request->getPost('tax')/2,
"tax" => $this->request->getPost('tax')
"tax" => $this->request->getPost('tax'),
];
if (!$complaint_id) {
$ComplaintModel = new ComplaintModel();
// $data = $this->request->getPost();
$data['business_id'] = $this->session->get('logged_user_business_id');
$inserted = $ComplaintModel->insert($data);
if ($inserted) {
$result = $data;

View File

@ -59,7 +59,7 @@ class Model extends BaseController
}
public function create_model($model_id)
public function create_model($model_id = 0)
{
try {
$make_id = $this->request->getPost('make_id');
@ -70,9 +70,9 @@ class Model extends BaseController
'make_id' => $make_id,
'model_name' => $model_name
];
if (!$model_id) {
// print_r($model_id);die;
if (!$model_id) {
try {
$inserted = $BikemodelsModel->insert($data);
} catch (\CodeIgniter\Database\Exceptions\DatabaseException $e) {
@ -90,6 +90,7 @@ class Model extends BaseController
}
}
else{
$updated = $BikemodelsModel->update($model_id ,$data);
if ($updated) {
$result = $data;

View File

@ -291,24 +291,25 @@ class Purchase extends BaseController
}
// print_r($child_data);die;
if (!empty($purchase_order_child_id[$key])) {
// print_r($purchase_order_child_id[$key]);die;
$PurchaseOrderChildModel->update($purchase_order_child_id[$key], $child_data);
} else {
$PurchaseOrderChildModel->insert($child_data);
// send purhase data through mail
$VendorModel = new VendorModel();
$vendor = $VendorModel->where('vendor_id',$this->request->getPost('vendor_id'))->findAll();
$mail_status = $this->download_purchase_invoice($purchase_order_id, $vendor[0]['vendor_email']);
// echo $mail_status;die;
$_SESSION['mail_status'] = $mail_status;
}
}
return redirect()->to('purchase_index');
@ -417,6 +418,7 @@ public function download_purchase_invoice($purchase_order_id, $mail = null)
// Fetch the invoice data based on $invoice_id
$model = new PurchaseOrderModel();
$data = $model->getPurchasePdf($purchase_order_id);
$items = $model->getPurchaseOrderProductsForPdf($purchase_order_id);
// Create an mPDF object
$mpdf = new Mpdf([

View File

@ -27,12 +27,14 @@ class Reorderlevel extends BaseController
$productModel = new ProductModel();
$reorder = $productModel->select('products.*, vendor.vendor_name as prefered_vendor_name, COUNT(vendor.vendor_name) as product_count')
->join('vendor', 'vendor.vendor_id = products.prefered_vendor')
->where('products.qty_stock <= purchase_order_level')
->where('products.qty_stock <= products.purchase_order_level')
->groupBy('products.prefered_vendor')
->orderBy('prefered_vendor_name', 'ASC')
->findAll();
// echo json_encode($reorder);die;
$data['reorder']=$reorder;
// echo "<pre>";
// print_r($reorder);die;
return view('reorder_level_list',$data);
}

View File

@ -8,6 +8,7 @@ use App\Models\UsersModel;
use App\Models\BikemakeModel;
use App\Models\BikemodelsModel;
use App\Models\ManufacturerModel;
use App\Models\ProductModel;
class Vendor extends BaseController
@ -152,6 +153,17 @@ class Vendor extends BaseController
// Send the formatted models as JSON response back to the client
return $this->response->setJSON($formatted_models);
}
public function get_product_by_vendor($vendor_id){
$productModel = new ProductModel();
$reorder = $productModel->select('products.*')
->where('products.qty_stock <= products.purchase_order_level')
->where('products.prefered_vendor',$vendor_id)
->findAll();
return json_encode($reorder);
}

View File

@ -36,7 +36,7 @@ class PurchaseOrderModel extends Model
->join('branches as B','B.branch_id = purchase_order.branch_id','left')
->join('vendor as V','V.vendor_id = purchase_order.vendor_id','left')
->select('purchase_order.*')
->select('V.vendor_name,V.contact_person_mobile1,V.address as vendor_address,V.city as vendor_city,V.state,V.postal_code as vendor_postal,B.branch_name ,B.address as company_address,B.city as company_city,B.state as company_state,B.postal_code as company_postal_code,B.mobile_no as company_mobile_no')
->select('V.vendor_name,V.contact_person_mobile1,V.address as vendor_address,V.city as vendor_city,V.state,V.postal_code as vendor_postal,B.branch_name ,B.address as company_address,B.city as company_city,B.state as company_state,B.postal_code as company_postal_code,B.contact_1 as company_mobile_no')
->get()
->getResult();

View File

@ -93,14 +93,16 @@
<script>
function submitModels(params) {
// console.log( $('#modelname').val());
var formData = {
make_id: $('#make_id').val(),
modelname: $('#modelname').val()
};
var edit_model_id = $('#edit_model_id').val();
if (!edit_model_id) {
edit_model_id =0;
}
var formData = {
make_id: $('#make_id').val(),
modelname: $('#modelname').val()
};
$.ajax({
type: 'POST',
url: '<?php echo base_url()."create_model/"?>'+edit_model_id,
@ -145,6 +147,7 @@
$('tbody').append(row);
});
}
window.location.reload();
},
error: function(xhr, status, error) {
// Handle error response here

View File

@ -145,17 +145,21 @@
make_id: $('#make_id').val(),
modelname: $('#modelname').val()
};
var model_id =0;
$.ajax({
type: 'POST',
url: 'create_model/'+$('#make_id').val(),
url: 'create_model/'+model_id,
data: formData,
dataType: 'json',
success: function(response) {
// Handle success response here
console.log(response);
$('#bike_model_login-modal').modal('hide');
$('#modelname').val('');
if (response.status == "failed") {
toastr.warning(response.data, 'Warning');
}else{
$('#bike_model_login-modal').modal('hide');
$('#modelname').val('');
toastr.success(response.data, 'Success');
}
},
error: function(xhr, status, error) {
// Handle error response here

View File

@ -1,34 +1,34 @@
<?php include('layout/header.php'); ?>
<div class="row">
<div class="col-12">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title"><?php echo $page_name?></h4>
<div class="page-title-right">
<a href="<?= base_url() . "reorder_level_index"; ?>" class="btn btn-secondary waves-effect">Cancel</a>
<ol class="breadcrumb m-0">
</ol>
</div>
<div class="row">
<div class="col-12">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title"><?php echo $page_name?></h4>
<div class="page-title-right">
<a href="<?= base_url() . "reorder_level_index"; ?>" class="btn btn-secondary waves-effect">Cancel</a>
<ol class="breadcrumb m-0">
</ol>
</div>
</div>
</div>
<div class="row">
</div>
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-body">
<h4 class="header-title"></h4>
<form action="<?= base_url() . "add_purchase"; ?>" method="post">
<input type="hidden" id="purchase_order_id" name="purchase_order_id" value=""readonly>
<h4 class="header-title">Purchase Details :</h4><br>
<input type="hidden" id="purchase_order_id" name="purchase_order_id" value=""readonly>
<h4 class="header-title">Purchase Details :</h4><br>
<div class="form-row">
<div class="form-group col-md-4">
<label for="make" class="col-form-label">Vendor<span class="text-danger">*</span></label>
<select class="form-control vendor-select SelExample" name="vendor_id" id="vendor_id" >
<option value="0">Select Vendor</option>
<?php foreach ($vendor as $item): ?>
<option value="<?= $item['vendor_id'] ?>" <?= isset($item['vendor_id']) && $item['vendor_id'] ? 'selected' : '' ?>>
<?= $item['vendor_name'] ?>
</option>
<option value="<?= $item['vendor_id'] ?>" <?= isset($item['vendor_id']) && $item['vendor_id'] ? 'selected' : '' ?>>
<?= $item['vendor_name'] ?>
</option>
<?php endforeach; ?>
</select>
</div>
@ -57,114 +57,114 @@
</select>
</div>
</div>
<h4 class="header-title">Billing Addresss :</h4><br>
<div class="form-row">
<div class="form-group col-md-3">
<label for="billing_address" class="col-form-label">Billing Addresss<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="billing_address" id="billing_address" placeholder="Billing Addresss"value="<?= isset($business['address']) ? $business['address'] : (isset($purchase['billing_address']) ? $purchase['billing_address'] : '') ?>" required>
</div>
<h4 class="header-title">Billing Addresss :</h4><br>
<div class="form-row">
<div class="form-group col-md-3">
<label for="billing_address" class="col-form-label">Billing Addresss<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="billing_address" id="billing_address" placeholder="Billing Addresss"value="<?= isset($business['address']) ? $business['address'] : (isset($purchase['billing_address']) ? $purchase['billing_address'] : '') ?>" required>
</div>
<div class="form-group col-md-3" >
<label for="billing_state" class="col-form-label">Billing State</label>
<input type="text" class="form-control" name="billing_state" id="billing_state" placeholder="Billing State"value="<?= isset($business['state']) ? $business['state'] : (isset($purchase['billing_state']) ? $purchase['billing_state'] : '') ?>" >
</div>
<div class="form-group col-md-3">
<label for="Billing City" class="col-form-label">Billing City<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="billing_city" id="billing_city" placeholder="Billing City"value="<?= isset($business['city']) ? $business['city'] : (isset($purchase['billing_city']) ? $purchase['billing_city'] : '') ?>" required>
</div>
<div class="form-group col-md-3">
<label for="Billing Postal Code" class="col-form-label">Billing Pin Code<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="billing_postal_code" id="billing_postal_code" placeholder="Billing Pin Code"value="<?= isset($business['postal_code']) ? $business['postal_code'] : (isset($purchase['billing_postal_code']) ? $purchase['billing_postal_code'] : '') ?>" required>
</div>
</div><br>
<h4 class="header-title">Shipping Addresss :</h4><br>
<div class="form-row">
<div class="form-group col-md-3">
<label for="shipping_address" class="col-form-label">Shipping Addresss<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="shipping_address" id="shipping_address" placeholder="Shipping Addresss"value="<?= isset($branch['address']) ? $branch['address'] : (isset($purchase['shipping_address']) ? $purchase['shipping_address'] : '') ?>" required>
</div>
<div class="form-group col-md-3" >
<label for="shipping_state" class="col-form-label">Shipping State</label>
<input type="text" class="form-control" name="shipping_state" id="shipping_state" placeholder="Shipping State"value="<?= isset($branch['state']) ? $branch['state'] : (isset($purchase['shipping_state']) ? $purchase['shipping_state'] : '') ?>" >
</div>
<div class="form-group col-md-3">
<label for="Shipping City" class="col-form-label">Shipping City<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="shipping_city" id="shipping_city" placeholder="Shipping City"value="<?= isset($branch['city']) ? $branch['city'] : (isset($purchase['shipping_city']) ? $purchase['shipping_city'] : '') ?>" required>
</div>
<div class="form-group col-md-3">
<label for="Shipping Postal Code" class="col-form-label">Shipping Pin Code<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="shipping_postal_code" id="shipping_postal_code" placeholder="Shipping Pin Code"value="<?= isset($branch['postal_code']) ? $branch['postal_code'] : (isset($purchase['shipping_postal_code']) ? $purchase['shipping_postal_code'] : '') ?>" required>
</div>
</div><br>
<div class="form-row" id="itemTableContainer">
<div class="form-group col-md-12">
<h4>Item Details</h4>
<br />
<table class="table table-bordered" id="itemTable">
<thead>
<tr>
<th>Item Details</th>
<th>Qty</th>
<div class="form-group col-md-3" >
<label for="billing_state" class="col-form-label">Billing State</label>
<input type="text" class="form-control" name="billing_state" id="billing_state" placeholder="Billing State"value="<?= isset($business['state']) ? $business['state'] : (isset($purchase['billing_state']) ? $purchase['billing_state'] : '') ?>" >
</div>
<div class="form-group col-md-3">
<label for="Billing City" class="col-form-label">Billing City<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="billing_city" id="billing_city" placeholder="Billing City"value="<?= isset($business['city']) ? $business['city'] : (isset($purchase['billing_city']) ? $purchase['billing_city'] : '') ?>" required>
</div>
<div class="form-group col-md-3">
<label for="Billing Postal Code" class="col-form-label">Billing Pin Code<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="billing_postal_code" id="billing_postal_code" placeholder="Billing Pin Code"value="<?= isset($business['postal_code']) ? $business['postal_code'] : (isset($purchase['billing_postal_code']) ? $purchase['billing_postal_code'] : '') ?>" required>
</div>
</div><br>
<h4 class="header-title">Shipping Addresss :</h4><br>
<div class="form-row">
<div class="form-group col-md-3">
<label for="shipping_address" class="col-form-label">Shipping Addresss<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="shipping_address" id="shipping_address" placeholder="Shipping Addresss"value="<?= isset($branch['address']) ? $branch['address'] : (isset($purchase['shipping_address']) ? $purchase['shipping_address'] : '') ?>" required>
</div>
<div class="form-group col-md-3" >
<label for="shipping_state" class="col-form-label">Shipping State</label>
<input type="text" class="form-control" name="shipping_state" id="shipping_state" placeholder="Shipping State"value="<?= isset($branch['state']) ? $branch['state'] : (isset($purchase['shipping_state']) ? $purchase['shipping_state'] : '') ?>" >
</div>
<div class="form-group col-md-3">
<label for="Shipping City" class="col-form-label">Shipping City<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="shipping_city" id="shipping_city" placeholder="Shipping City"value="<?= isset($branch['city']) ? $branch['city'] : (isset($purchase['shipping_city']) ? $purchase['shipping_city'] : '') ?>" required>
</div>
<div class="form-group col-md-3">
<label for="Shipping Postal Code" class="col-form-label">Shipping Pin Code<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="shipping_postal_code" id="shipping_postal_code" placeholder="Shipping Pin Code"value="<?= isset($branch['postal_code']) ? $branch['postal_code'] : (isset($purchase['shipping_postal_code']) ? $purchase['shipping_postal_code'] : '') ?>" required>
</div>
</div><br>
<div class="form-row" id="itemTableContainer">
<div class="form-group col-md-12">
<h4>Item Details</h4>
<br />
<table class="table table-bordered" id="itemTable">
<thead>
<tr>
<th>Item Details</th>
<th>Qty</th>
<th hidden></th>
<th></th>
</tr>
</thead>
<tbody>
<?php if (isset($products) && !empty($products)) :
foreach ($products as $product) { ?>
<?php if ($product['per'] == 'ml') {
$value_ml = ' ('.$product['ml'].$product['per'].')';
} else {
$value_ml = '';
}
?>
<tr>
<td style="width:10%;">
<select class="form-control book-select SelExample" name="item_details[]" required data-toggle="select2" id="" style="width: 249px !important;">
<option value="">Select a Product</option>
<option value="<?= $product["product_id"] ?>" <?= isset($product['product_id']) ? 'selected' : '' ?>>
<?= $product["product_name"].$value_ml.' - '. $product['manufacturer_name']; ?>
</option>
</select>
</td>
<td style="width:5%;">
<input type="number" class="form-control item-quantity" name="quantity[]" min="1" value="<?= isset($product['reorder_level']) ? $product['reorder_level'] : '' ?>">
</td>
<td style="width:5%;">
<center><i class="fa fa-trash"></i></center>
</td>
</tr>
<?php } endif; ?>
<!-- You can add more rows as needed using JavaScript -->
</tbody>
</table>
<div class="form-group text-right m-b-0">
<!-- Show the "Add More Item" button only if invoice_type is not 1 -->
<a class="btn" id="addItem">
<h4><i class="fa fa-plus" aria-hidden="true"></i> Add Product</h4>
</a>
</div>
</div>
</div>
<h4 class="header-title">Terms & Condition :</h4><br>
<div class="form-row">
<div class="form-group col-md-12">
<label for="inputPassword4" class="col-form-label">Terms & Condition</label>
<textarea class="form-control" name="terms_condition" placeholder="Terms & Condition" >
<?= isset($sales['terms_condition']) ? $sales['terms_condition'] : 'Please check the products properly before purchase. Products once sold cannot be returned.' ?>
</textarea>
</div>
<th hidden></th>
<th></th>
</tr>
</thead>
<tbody>
<?php if (isset($products) && !empty($products)) :
foreach ($products as $product) { ?>
<?php if ($product['per'] == 'ml') {
$value_ml = ' ('.$product['ml'].$product['per'].')';
} else {
$value_ml = '';
}
?>
<tr>
<td style="width:10%;">
<select class="form-control book-select SelExample" name="item_details[]" required data-toggle="select2" id="" style="width: 249px !important;">
<option value="">Select a Product</option>
<option value="<?= $product["product_id"] ?>" <?= isset($product['product_id']) ? 'selected' : '' ?>>
<?= $product["product_name"].$value_ml.' - '. $product['manufacturer_name']; ?>
</option>
</select>
</td>
<td style="width:5%;">
<input type="number" class="form-control item-quantity" name="quantity[]" min="1" value="<?= isset($product['reorder_level']) ? $product['reorder_level'] : '' ?>">
</td>
<td style="width:5%;">
<center><i class="fa fa-trash"></i></center>
</td>
</tr>
<?php } endif; ?>
<!-- You can add more rows as needed using JavaScript -->
</tbody>
</table>
<div class="form-group text-right m-b-0">
<!-- Show the "Add More Item" button only if invoice_type is not 1 -->
<a class="btn" id="addItem">
<h4><i class="fa fa-plus" aria-hidden="true"></i> Add Product</h4>
</a>
</div>
</div>
<?php if (!isset($purchase['status']) || $purchase['status'] !== 'Received') : ?>
<button type="submit" id="editaddbutton"class="btn btn-primary">Submit</button>
<?php endif; ?>
</form>
</div>
</div>
<h4 class="header-title">Terms & Condition :</h4><br>
<div class="form-row">
<div class="form-group col-md-12">
<label for="inputPassword4" class="col-form-label">Terms & Condition</label>
<textarea class="form-control" name="terms_condition" placeholder="Terms & Condition" >
<?= isset($sales['terms_condition']) ? $sales['terms_condition'] : 'Please check the products properly before purchase. Products once sold cannot be returned.' ?>
</textarea>
</div>
</div>
<?php if (!isset($purchase['status']) || $purchase['status'] !== 'Received') : ?>
<button type="submit" id="editaddbutton"class="btn btn-primary">Submit</button>
<?php endif; ?>
</form>
</div>
</div>
</div>
</div>
</div>
<input type="hidden" id="pr_data" value="<?= htmlspecialchars(json_encode($product_data)); ?>">
<?php include('layout/footer.php'); ?>

View File

@ -38,8 +38,8 @@
<tbody>
<?php foreach ($reorder as $value) : ?>
<tr>
<tr id="<?php echo $value['prefered_vendor']; ?>">
<div></div>
<td><?= $value['prefered_vendor_name']; ?></td>
<td><?= $value['product_count']; ?></td>
<!-- <td><?= $value['prefered_vendor_name']; ?></td>
@ -62,6 +62,25 @@
</div> <!-- end col -->
</div>
<!-- Start Product List Pop-UP -->
<div id="product_list_model" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content justify-content-center" style="height: 40vh;">
<div class="modal-body">
<div class="text-center mt-2 mb-4">
<h4>Product List</h4>
</div>
<div class="form-group" id="product_list_model_body">
</div>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<?php include('layout/footer.php'); ?>
<script>
@ -110,5 +129,40 @@ $(document).ready(function() {
},
"ordering": false
});
});
});
$('tr').click(function () {
var vendor_id = $(this).attr('id');
$.ajax({
url: '<?php echo base_url()."get_product_by_vendor/"?>'+vendor_id,
method: 'GET',
success: function(response) {
var product_list = JSON.parse(response);
if (product_list) {
// console.log(product_list);
$('#product_list_model').modal('show');
var html = '';
html += '<table class="table table-striped dt-responsive nowrap w-100"><thead><tr><th>Name </th><th>Qty</th></tr></thead><tbody>';
product_list.forEach(function(product) {
// console.log(product);
html += '<tr><td>'+ product.product_name+'</td><td>'+product.qty_stock+'</td></tr>';
});
html += '</tbody></table>'
$("#product_list_model_body").html(html);
}
},
error: function(xhr, status, error) {
console.error('Error occurred while deleting the item:', error);
}
});
})
</script>