Merge branch 'main' of bitbucket.org:venbainformationtechnology/the_mechanic
This commit is contained in:
commit
d6c0cb6ead
@ -42,6 +42,7 @@ $routes->get("new_product/(:any)", "Products::new_product/$1");
|
||||
$routes->get("delete_product/(:any)", "Products::delete_product/$1");
|
||||
$routes->post("get_vendors_by_model", "Products::get_vendors_by_model");
|
||||
$routes->post("get_models", "Products::get_models");
|
||||
$routes->post("save_make", "Products::save_make");
|
||||
//end products//
|
||||
|
||||
//Sales order //
|
||||
@ -86,7 +87,7 @@ $routes->get('dashboard', 'Users::dashboard');
|
||||
|
||||
|
||||
|
||||
//---------------------- Make And Model | Service | Manufacturer
|
||||
//---------------------- Make And Model | Service | Manufacturer | Inventory->Purchase
|
||||
// Make
|
||||
$routes->get('make_index', 'Make::index');
|
||||
$routes->post('create_make', 'Make::create_make');
|
||||
@ -112,3 +113,10 @@ $routes->get("delete_service/(:any)", "Service::delete_service/$1");
|
||||
$routes->get('spare_manufacturer_index', 'Manufacturer::index');
|
||||
$routes->post('create_manufacturer', 'Manufacturer::create_manufacturer');
|
||||
|
||||
|
||||
// Purchase
|
||||
|
||||
$routes->get('purchase_index', 'Purchase::purchase_index');
|
||||
$routes->get("new_purchase/(:any)", "Purchase::new_purchase/$1");
|
||||
$routes->get('get_product/(:any)', 'Purchase::get_product/$1');
|
||||
$routes->post("add_purchase", "Purchase::add_purchase");
|
||||
|
||||
@ -35,11 +35,11 @@ class Manufacturer extends BaseController
|
||||
{
|
||||
try {
|
||||
$manufacturer_name = $this->request->getPost('manufacturername');
|
||||
$quantity = $this->request->getPost('quantity');
|
||||
$quality = $this->request->getPost('quality');
|
||||
$ManufacturerModel = new ManufacturerModel();
|
||||
$data = [
|
||||
'manufacturer_name' => $manufacturer_name,
|
||||
'quantity' => $quantity,
|
||||
'quality' => $quality,
|
||||
];
|
||||
$inserted = $ManufacturerModel->insert($data);
|
||||
if ($inserted) {
|
||||
|
||||
@ -6,6 +6,8 @@ use App\Models\ProductModel;
|
||||
use App\Models\BikemakeModel;
|
||||
use App\Models\VendorModel;
|
||||
use App\Models\BikemodelsModel;
|
||||
use App\Models\ManufacturerModel;
|
||||
|
||||
|
||||
|
||||
class Products extends BaseController
|
||||
@ -23,9 +25,12 @@ class Products extends BaseController
|
||||
|
||||
if ($manufacturer_id) {
|
||||
$ProductModel = new ProductModel();
|
||||
$ManufacturerModel = new ManufacturerModel();
|
||||
$products = $ProductModel->where('manufacturer_id',$manufacturer_id)->findAll();
|
||||
$manufacturer = $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 {
|
||||
@ -60,7 +65,10 @@ class Products extends BaseController
|
||||
$data['make'] = $BikemakeModel->findAll();
|
||||
$VendorModel = new VendorModel();
|
||||
$data['vendors']=$VendorModel->findAll();
|
||||
$ManufacturerModel = new ManufacturerModel();
|
||||
$data['manufacturers']=$ManufacturerModel->findAll();
|
||||
$data['page_name']="Add Product";
|
||||
$data['vendorsProduct'] =[];
|
||||
} else if ($product_id !== '0') {
|
||||
$data['page_name']="Edit Product";
|
||||
$ProductModel = new ProductModel();
|
||||
@ -78,9 +86,24 @@ class Products extends BaseController
|
||||
$data['tax']=$tax;
|
||||
$VendorModel = new VendorModel();
|
||||
$data['vendors']=$VendorModel->findAll();
|
||||
|
||||
// print_r($data);die;
|
||||
|
||||
$ManufacturerModel = new ManufacturerModel();
|
||||
$data['manufacturers']=$ManufacturerModel->findAll();
|
||||
$vendorIds = json_decode($products['vendor'], true);
|
||||
$vendors = [];
|
||||
$VendorModel = new VendorModel();
|
||||
foreach ($vendorIds as $vendorId) {
|
||||
$vendor = $VendorModel->find($vendorId);
|
||||
if ($vendor) {
|
||||
$vendors[] = ['id' => $vendor['vendor_id'], 'name' => $vendor['vendor_name']];
|
||||
}
|
||||
}
|
||||
$data['vendorsProduct'] = $vendors;
|
||||
// print_r($data['vendors']);die;
|
||||
|
||||
$preferredVendorId = $products['prefered_vendor'];
|
||||
// Pass the preferred vendor ID to the view
|
||||
$data['preferredVendorId'] = $preferredVendorId; // print_r($data);die;
|
||||
// print_r($data);die;
|
||||
}
|
||||
$data['product_id'] = $product_id;
|
||||
|
||||
@ -99,7 +122,7 @@ class Products extends BaseController
|
||||
'product_name' => $this->request->getPost('productname'),
|
||||
'product_category' => $this->request->getPost('productcategory'),
|
||||
'mfr_part_no' => $this->request->getPost('mfr_part_no'),
|
||||
'serial_no' => $this->request->getPost('serial_no'),
|
||||
|
||||
'unit_price' => $this->request->getPost('unit_price'),
|
||||
'commision_rate' => $this->request->getPost('commision_rate'),
|
||||
'sgst' => $tax,
|
||||
@ -114,11 +137,14 @@ class Products extends BaseController
|
||||
'quality' => $this->request->getPost('quality'),
|
||||
'make_id' => $this->request->getPost('make'),
|
||||
'models_id' => json_encode($this->request->getPost('model')),
|
||||
'rack_number' => $this->request->getPost('rack_number'),
|
||||
'manufacturer_id' => $this->request->getPost('manufacturer'),
|
||||
'prefered_vendor' => $this->request->getPost('prefered_vendor'),
|
||||
'isactive' => 1 ,
|
||||
'branch_id' => $this->session->get('logged_user_branch_id')
|
||||
];
|
||||
// print_r($data);die;
|
||||
|
||||
|
||||
// print_r($data);die;
|
||||
$product_id = $this->request->getPost('product_id');
|
||||
|
||||
|
||||
@ -131,7 +157,7 @@ class Products extends BaseController
|
||||
$product_id = $ProductModel->getInsertID();
|
||||
}
|
||||
|
||||
$orderNumber = 'SKU-' . date('md') . '-' . str_pad($product_id, 5, '0', STR_PAD_LEFT);
|
||||
$orderNumber = 'TM' . str_pad($product_id, 8, '0', STR_PAD_LEFT);
|
||||
// print_r($orderNumber);die;
|
||||
// Update sales order with generated order number
|
||||
$ProductModel->update($product_id, ['sku_id' => $orderNumber]);
|
||||
@ -226,4 +252,47 @@ public function get_models()
|
||||
return $this->response->setJSON($models);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function save_make() {
|
||||
$response = []; // Initialize an empty array to hold the response data
|
||||
|
||||
// Assuming BikemakeModel and BikemodelsModel are properly defined
|
||||
|
||||
$BikemakeModel = new BikemakeModel();
|
||||
$BikemodelsModel = new BikemodelsModel();
|
||||
|
||||
$make = $this->request->getPost('make');
|
||||
$model = $this->request->getPost('model');
|
||||
|
||||
// Check if both make and model are provided
|
||||
if (!empty($make) && !empty($model)) {
|
||||
$data = [
|
||||
'make' => $make
|
||||
];
|
||||
|
||||
// Insert the make into the database
|
||||
$BikemakeModel->insert($data);
|
||||
$make_id = $BikemakeModel->getInsertID();
|
||||
|
||||
$modelData = [
|
||||
'model_name' => $model,
|
||||
'make_id' => $make_id,
|
||||
];
|
||||
|
||||
// Insert the model into the database
|
||||
$BikemodelsModel->insert($modelData);
|
||||
|
||||
// Set success status in the response
|
||||
$response['success'] = true;
|
||||
} else {
|
||||
// If make or model is empty, set success status to false
|
||||
$response['success'] = false;
|
||||
}
|
||||
|
||||
// Send JSON response back to the client
|
||||
return $this->response->setJSON($response);
|
||||
}
|
||||
|
||||
}
|
||||
209
app/Controllers/Purchase.php
Normal file
209
app/Controllers/Purchase.php
Normal file
@ -0,0 +1,209 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\PurchaseOrderModel;
|
||||
use App\Models\ProductModel;
|
||||
use App\Models\VendorModel;
|
||||
use App\Models\BranchModel;
|
||||
use App\Models\BusinessModel;
|
||||
|
||||
|
||||
class Purchase extends BaseController
|
||||
{
|
||||
public $session;
|
||||
public function __construct()
|
||||
{
|
||||
$this->session = session();
|
||||
}
|
||||
|
||||
public function purchase_index()
|
||||
{
|
||||
$PurchaseOrderModel = new PurchaseOrderModel();
|
||||
|
||||
$purchase = $PurchaseOrderModel->findAll();
|
||||
// echo "<pre>";
|
||||
// print_r($product);die;
|
||||
$data['purchase']=$purchase;
|
||||
|
||||
echo "<pre>";
|
||||
print_r($data);die;
|
||||
return view('purchase_list',$data);
|
||||
}
|
||||
|
||||
public function new_purchase($purchase_id)
|
||||
{
|
||||
if ($purchase_id === '0') {
|
||||
|
||||
$data['purchase'] = [];
|
||||
$PurchaseOrderModel = new PurchaseOrderModel();
|
||||
$ProductModel = new ProductModel();
|
||||
$product = $ProductModel->select('product_id,product_name')->findAll();
|
||||
|
||||
$data['page_name']="Add Purchase Order";
|
||||
$data['product']=$product;
|
||||
|
||||
} else if ($purchase_id !== '0') {
|
||||
$data['page_name']="Edit Product";
|
||||
$ProductModel = new ProductModel();
|
||||
$products=$ProductModel->where('product_id', $product_id)->get()->getRowArray();
|
||||
|
||||
$data['products']=$products;
|
||||
|
||||
$BikemakeModel = new BikemakeModel();
|
||||
$data['make'] = $BikemakeModel->findAll();
|
||||
$BikemodelsModel = new BikemodelsModel();
|
||||
$make_id = $products['make_id'];
|
||||
$data['models'] = $BikemodelsModel->where('make_id', $make_id)->findAll();
|
||||
|
||||
$tax=$ProductModel->getTax();
|
||||
$data['tax']=$tax;
|
||||
$VendorModel = new VendorModel();
|
||||
$data['vendors']=$VendorModel->findAll();
|
||||
}
|
||||
$data['purchase_id'] = $purchase_id;
|
||||
|
||||
echo view('purchase_form',$data);
|
||||
}
|
||||
|
||||
public function add_purchase()
|
||||
{
|
||||
|
||||
$PurchaseOrderModel = new PurchaseOrderModel();
|
||||
|
||||
|
||||
$data = [
|
||||
'product_id' => $this->request->getPost('product_id'),
|
||||
'vendor_id' => $this->request->getPost('vendor_id'),
|
||||
'product_quantity' => $this->request->getPost('product_quantity'),
|
||||
'unit_price' => $this->request->getPost('unit_price'),
|
||||
'total_price' => $this->request->getPost('total_price'),
|
||||
'order_date' => $this->request->getPost('order_date'),
|
||||
'contact_person_name' => $this->request->getPost('contact_person_name'),
|
||||
'contact_person_mobile'=> $this->request->getPost('contact_person_mobile'),
|
||||
'status'=> $this->request->getPost('purchase_status'),
|
||||
'billing_addresss' => $this->request->getPost('billing_addresss'),
|
||||
'billing_state' => $this->request->getPost('billing_state'),
|
||||
'billing_city' => $this->request->getPost('billing_city'),
|
||||
'billing_postal_code' => $this->request->getPost('billing_postal_code'),
|
||||
'shipping_addresss' => $this->request->getPost('shipping_addresss'),
|
||||
'shipping_state' => json_encode($this->request->getPost('shipping_state')),
|
||||
'shipping_city' =>$this->request->getPost('shipping_city'),
|
||||
'shipping_postal_code' => $this->request->getPost('shipping_postal_code'),
|
||||
'description' => $this->request->getPost('description'),
|
||||
];
|
||||
|
||||
// $product_id = $this->request->getPost('product_id');
|
||||
|
||||
|
||||
// if (!empty($product_id)) {
|
||||
|
||||
// $PurchaseOrderModel->update($product_id, $data);
|
||||
// } else {
|
||||
|
||||
$PurchaseOrderModel->insert($data);
|
||||
// }
|
||||
|
||||
|
||||
return redirect()->to('product_index');
|
||||
}
|
||||
|
||||
public function delete_product($product_id)
|
||||
{
|
||||
$model = new ProductModel();
|
||||
$where = ['product_id' => $product_id, 'isactive' => 1 , 'branch_id' => $this->session->get('logged_user_branch_id')]; // Assuming 'isactive' is a column in your database
|
||||
$existingProduct = $model->where($where)->first();
|
||||
|
||||
if ($existingProduct) {
|
||||
$data['isactive'] = 0;
|
||||
|
||||
if ($model->update($product_id, $data)) {
|
||||
session()->setFlashdata('success', 'Deleted successfully.');
|
||||
$this->logger->info("Users: has been Inactivated successfully. Inactivated ID = ".$product_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return redirect()->to('product_index');
|
||||
}
|
||||
|
||||
// Retrieve the make_id from the AJAX request
|
||||
public function get_vendors_by_model()
|
||||
{
|
||||
|
||||
$model_ids = $this->request->getPost('model_ids');
|
||||
$make_id = $this->request->getPost('make_id');
|
||||
$vendorModel = new VendorModel();
|
||||
$Vendors = $vendorModel->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
|
||||
if($Vendors){
|
||||
|
||||
$data = [];
|
||||
|
||||
foreach ($model_ids as $modelKey => $modelValue)
|
||||
{
|
||||
foreach ($Vendors as $vendorsKey => $vendorsValue)
|
||||
{
|
||||
$modelsArray = json_decode($vendorsValue['model'], true);
|
||||
if (is_array($modelsArray))
|
||||
{
|
||||
$findIfModelExist = array_search($modelValue, $modelsArray);
|
||||
if ($findIfModelExist !== false)
|
||||
{
|
||||
array_push($data,$vendorsValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($data)) {
|
||||
|
||||
$arrayOfArrays = array_map(function($obj) {
|
||||
return (array) $obj;
|
||||
}, $data);
|
||||
|
||||
// Remove duplicates based on string representation of each object
|
||||
$uniqueArray = array_map('unserialize', array_unique(array_map('serialize', $arrayOfArrays)));
|
||||
|
||||
// Convert the unique array of associative arrays back to an array of objects
|
||||
$uniqueObjectsArray = array_map(function($arr) {
|
||||
return (object) $arr;
|
||||
}, $uniqueArray);
|
||||
|
||||
return $this->response->setJSON($uniqueArray);
|
||||
|
||||
} else {
|
||||
|
||||
return $this->response->setJSON([]);
|
||||
}
|
||||
}else {
|
||||
|
||||
return $this->response->setJSON([]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function get_product($product_id)
|
||||
{
|
||||
|
||||
$ProductModel = new ProductModel();
|
||||
$BranchModel = new BranchModel();
|
||||
$BusinessModel = new BusinessModel();
|
||||
|
||||
$branch = $BranchModel->where('branch_id', $this->session->get('logged_user_branch_id'))->get()->getRowArray();
|
||||
$business = $BusinessModel->where('business_id', $this->session->get('logged_user_business_id'))->get()->getRowArray();
|
||||
|
||||
|
||||
$products=$ProductModel->where('product_id', $product_id)->get()->getRowArray();
|
||||
if ($products['prefered_vendor']) {
|
||||
$VendorModel = new VendorModel();
|
||||
$products +=$VendorModel->where('vendor_id',$products['prefered_vendor'])->select('vendor_name,contact_person_name1,contact_person_mobile1')->get()->getRowArray();
|
||||
}
|
||||
|
||||
$products['branch']=$branch;
|
||||
$products['business']=$business;
|
||||
|
||||
return json_encode($products);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -7,6 +7,7 @@ use App\Models\VendorModel;
|
||||
use App\Models\UsersModel;
|
||||
use App\Models\BikemakeModel;
|
||||
use App\Models\BikemodelsModel;
|
||||
use App\Models\ManufacturerModel;
|
||||
|
||||
|
||||
class Vendor extends BaseController
|
||||
@ -36,10 +37,13 @@ class Vendor extends BaseController
|
||||
if ($vendor_id === '0') {
|
||||
$data['vendor'] = [];
|
||||
$data['page_name'] = "Add Vendor";
|
||||
$ManufacturerModel = new ManufacturerModel();
|
||||
$data['manufacturers']=$ManufacturerModel->findAll();
|
||||
} else {
|
||||
$VendorModel = new VendorModel();
|
||||
$vendor = $VendorModel->where('vendor_id', $vendor_id)->get()->getRowArray();
|
||||
|
||||
$ManufacturerModel = new ManufacturerModel();
|
||||
$data['manufacturers']=$ManufacturerModel->findAll();
|
||||
$data['vendor'] = $vendor;
|
||||
$data['page_name'] = "Edit Vendor";
|
||||
|
||||
@ -66,6 +70,7 @@ class Vendor extends BaseController
|
||||
'state' => $this->request->getPost('state'),
|
||||
'postal_code' => $this->request->getPost('postalcode'),
|
||||
'country' => $this->request->getPost('country'),
|
||||
'vendortype' => $this->request->getPost('vendortype'),
|
||||
'category' => $this->request->getPost('category'),
|
||||
'contact_person_name1' => $this->request->getPost('contact_person_name1'),
|
||||
'contact_person_name2' => $this->request->getPost('contact_person_name2'),
|
||||
@ -73,9 +78,10 @@ class Vendor extends BaseController
|
||||
'contact_person_mobile1' => $this->request->getPost('contact_person_mobile1'),
|
||||
'contact_person_mobile2' => $this->request->getPost('contact_person_mobile2'),
|
||||
'contact_person_mobile3' => $this->request->getPost('contact_person_mobile3'),
|
||||
'contact_person_resignation1' => $this->request->getPost('contact_person_resignation1'),
|
||||
'contact_person_resignation2' => $this->request->getPost('contact_person_resignation2'),
|
||||
'contact_person_resignation3' => $this->request->getPost('contact_person_resignation3'),
|
||||
'contact_person_designation1' => $this->request->getPost('contact_person_designation1'),
|
||||
'contact_person_designation2' => $this->request->getPost('contact_person_designation2'),
|
||||
'contact_person_designation3' => $this->request->getPost('contact_person_designation3'),
|
||||
'manufacturer_id' => json_encode($this->request->getPost('manufacturer')),
|
||||
'isactive' => 1 ,
|
||||
'branch_id' => $this->session->get('logged_user_branch_id'),
|
||||
];
|
||||
|
||||
@ -5,7 +5,7 @@ class ManufacturerModel extends Model
|
||||
{
|
||||
protected $table = 'manufacturer';
|
||||
protected $primaryKey = 'manufacturer_id';
|
||||
protected $allowedFields = ['manufacturer_id','manufacturer_name','isactive','quantity'];
|
||||
protected $allowedFields = ['manufacturer_id','manufacturer_name','isactive','quality'];
|
||||
|
||||
|
||||
}
|
||||
@ -5,7 +5,7 @@ class ProductModel extends Model
|
||||
{
|
||||
protected $table = 'products';
|
||||
protected $primaryKey = 'product_id';
|
||||
protected $allowedFields = ['sku_id','product_id','manufacturer_id','make_id','models_id','quality','product_name','branch_id','search_tag','product_category','mfr_part_no','purchase_order_level','serial_no','unit_price','commision_rate','sgst','cgst','purchase_cost','usage_unit','vendor','qty_stock','reorder_level','handler','qty_in_demand','product_image','description','isactive'];
|
||||
protected $allowedFields = ['sku_id','product_id','rack_number','manufacturer_id','make_id','models_id','quality','product_name','branch_id','prefered_vendor','product_category','mfr_part_no','purchase_order_level','unit_price','commision_rate','sgst','cgst','purchase_cost','usage_unit','vendor','qty_stock','reorder_level','handler','qty_in_demand','product_image','description','isactive'];
|
||||
|
||||
|
||||
public function getTax()
|
||||
|
||||
@ -5,7 +5,7 @@ class PurchaseOrderModel extends Model
|
||||
{
|
||||
protected $table = 'purchase_order';
|
||||
protected $primaryKey = 'purchase_order_id';
|
||||
protected $allowedFields = ['purchase_order_id','subject','vendor','requesition_number','tracking_number','contact_name','due_date','carrier','sales_commision','excise_duty','status','billing_address','billing_city','billing_state','billing_country','billing_postal_code','shipping_address','shipping_city','shipping_state','shipping_country','shipping_postal_code','terms_condition','isactive'];
|
||||
protected $allowedFields = ['purchase_order_id','vendor_id','status','billing_address','billing_city','billing_state','billing_country','billing_postal_code','shipping_address','shipping_city','shipping_state','shipping_country','shipping_postal_code','terms_condition','isactive','product_id','product_quantity','unit_price','total_price','order_date','contact_person_name','contact_person_mobile'];
|
||||
|
||||
|
||||
}
|
||||
@ -143,6 +143,9 @@
|
||||
<li>
|
||||
<a href="<?php echo base_url('vendor_index') ?>">Vendor</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?php echo base_url('purchase_index') ?>">Purchase</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Manufacturer </th>
|
||||
<th>Quantity</th>
|
||||
<th>Quality</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -34,7 +34,7 @@
|
||||
<?php foreach ($manufacturer as $item): ?>
|
||||
<tr>
|
||||
<td><?php echo $item['manufacturer_name']; ?></td>
|
||||
<td><?php echo $item['quantity']; ?></td>
|
||||
<td><?php echo $item['quality']; ?></td>
|
||||
<td>
|
||||
<a href="<?= "product_index/" . $item['manufacturer_id']; ?>" class="view-list-button" title="Model List" style="margin-left: 16px;">
|
||||
<i class="ri-list-check-2 icon-large"></i>
|
||||
@ -66,13 +66,13 @@
|
||||
<input class="form-control" type="text" id="manufacturer_name" required="" placeholder="Make Name....">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="manufacturername">Quantity</label>
|
||||
<select name="quantity" id="quantity" class="form-control" style="border-color: lightgray;color: #6c757d;">
|
||||
<option value="0">Select Quantity</option>
|
||||
<option value="q1">Q1</option>
|
||||
<option value="q2">Q2</option>
|
||||
<option value="q3">Q3</option>
|
||||
<option value="q4">Q4</option>
|
||||
<label for="manufacturername">Quality</label>
|
||||
<select name="quality" id="quality" class="form-control" style="border-color: lightgray;color: #6c757d;">
|
||||
<option value="0">Select Quality</option>
|
||||
<option value="Q1">Q1</option>
|
||||
<option value="Q2">Q2</option>
|
||||
<option value="Q3">Q3</option>
|
||||
<option value="Q4">Q4</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@ -98,7 +98,7 @@
|
||||
function submitMake(params) {
|
||||
var formData = {
|
||||
manufacturername: $('#manufacturer_name').val(),
|
||||
quantity: $('#quantity').val()
|
||||
quality: $('#quality').val()
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?php include('layout/header.php'); ?>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="page-title-box page-title-box-alt">
|
||||
@ -25,7 +25,8 @@
|
||||
<h4 class="header-title">Product Details :</h4><br>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="make" class="col-form-label">Make<span class="text-danger">*</span></label>
|
||||
|
||||
<label for="make" class="col-form-label">Make<span class="text-danger">*</span><i type="button" class="fe-plus-circle" id="addMakeModalButton" style="font-size: 18px;" data-toggle="modal" data-target="#addMakeModal" title="Add Client"></i></label>
|
||||
<select class="form-control SelExample" id="make" name="make" required>
|
||||
<option value="">Select a Make</option>
|
||||
|
||||
@ -56,6 +57,28 @@
|
||||
<input type="text" class="form-control" name="productname" placeholder="Product Name" value="<?= isset($products['product_name']) ? $products['product_name'] : '' ?>" required>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="manufacturer" class="col-form-label">Manufacturer<span class="text-danger">*</span></label>
|
||||
<select class="form-control SelExample" id="manufacturer" name="manufacturer" required>
|
||||
<option value="">Select a Manufacturer</option>
|
||||
<?php foreach ($manufacturers as $value): ?>
|
||||
<option value="<?= $value['manufacturer_id'] ?>" <?= isset($products['manufacturer_id']) && $products['manufacturer_id'] == $value['manufacturer_id'] ? 'selected' : '' ?>>
|
||||
<?= $value['manufacturer_name'] ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="quality" class="col-form-label">Quality<span class="text-danger">*</span></label>
|
||||
<select class="form-control" name="quality" id="quality" required data-toggle="select2">
|
||||
<!-- Options for quality will be populated dynamically via JavaScript -->
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputAddress" class="col-form-label">Manfacturer Part Number</label>
|
||||
<input type="text" class="form-control" name="mfr_part_no" placeholder="Manfacturer Part Number" value="<?= isset($products['mfr_part_no']) ? $products['mfr_part_no'] : '' ?>" >
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="vendor" class="col-form-label">Vendor<span class="text-danger">*</span></label>
|
||||
<select class="form-control SelExample" id="vendor" name="vendor[]" required multiple>
|
||||
<!-- Placeholder option -->
|
||||
@ -70,27 +93,25 @@
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="vendor" class="col-form-label">Quality<span class="text-danger">*</span></label>
|
||||
<select class="form-control " name="quality" required data-toggle="select2" >
|
||||
<!-- <option value="">Select a Status</option> -->
|
||||
<option value="Q1" <?= isset($products['quality']) && $products['quality'] === 'Q1' ? 'selected' : '' ?>>Q1</option>
|
||||
<option value="Q2" <?= isset($products['quality']) && $products['quality'] === 'Q2' ? 'selected' : '' ?>>Q2 </option>
|
||||
<option value="Q3" <?= isset($products['quality']) && $products['quality'] === 'Q3' ? 'selected' : '' ?>>Q3</option>
|
||||
<option value="Q4" <?= isset($products['quality']) && $products['quality'] === 'Q4' ? 'selected' : '' ?>>Q4</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<label for="preferred_vendor" class="col-form-label">Preferred Vendor<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="preferred_vendor" name="prefered_vendor" required>
|
||||
<!-- Loop through vendors and set selected attribute if ID matches preferredVendorId -->
|
||||
<?php foreach ($vendorsProduct as $vendor): ?>
|
||||
<option value="<?= $vendor['id'] ?>" <?= (isset($preferredVendorId) && $vendor['id'] == $preferredVendorId) ? 'selected' : '' ?>>
|
||||
<?= $vendor['name'] ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputAddress" class="col-form-label">Manfacturer Part Number</label>
|
||||
<input type="text" class="form-control" name="mfr_part_no" placeholder="Manfacturer Part Number" value="<?= isset($products['mfr_part_no']) ? $products['mfr_part_no'] : '' ?>" >
|
||||
<label for="inputEmail4" class="col-form-label">Product Category<span class="text-danger"></span></label>
|
||||
<input type="text" class="form-control" name="productcategory" placeholder="Product Category" value="<?= isset($products['product_category']) ? $products['product_category'] : '' ?>" >
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputPassword4" class="col-form-label">Serial Number<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="serial_no" placeholder="Serial Number"value="<?= isset($products['serial_no']) ? $products['serial_no'] : '' ?>" required>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputEmail4" class="col-form-label">Product Category<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="productcategory" placeholder="Product Category" value="<?= isset($products['product_category']) ? $products['product_category'] : '' ?>" required>
|
||||
<label for="inputEmail4" class="col-form-label">Rack Number<span class="text-danger"></span></label>
|
||||
<input type="text" class="form-control" name="rack_number" placeholder="Rack Number" value="<?= isset($products['rack_number']) ? $products['rack_number'] : '' ?>" >
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@ -167,7 +188,34 @@
|
||||
</div>
|
||||
</div>
|
||||
<?php include('layout/footer.php'); ?>
|
||||
|
||||
<div class="modal fade" id="addMakeModal" tabindex="-1" role="dialog" aria-labelledby="addMakeModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="addMakeModalLabel">Add New Make</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="addClientForm">
|
||||
<div class="form-group">
|
||||
<label for="clientName">Make</label>
|
||||
<input type="text" class="form-control" id="makes" placeholder="Enter Make"required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="clientMobile">Model</label>
|
||||
<input type="text" class="form-control" id="models" placeholder="Enter Model"required>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||
<button type="button" class="btn btn-primary" id="saveMakeBtn">Save Make</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
// Check SGST checkbox by default
|
||||
@ -282,4 +330,132 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
font-weight: 500;
|
||||
border-bottom: 1px solid #747474;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
<script>
|
||||
// Function to update the quality dropdown based on selected manufacturer
|
||||
function updateQualityDropdown(manufacturerId) {
|
||||
// Clear existing options
|
||||
$('#quality').empty();
|
||||
// Find the selected manufacturer
|
||||
var selectedManufacturer = <?= json_encode($manufacturers) ?>.find(function(manufacturer) {
|
||||
return manufacturer.manufacturer_id == manufacturerId;
|
||||
});
|
||||
// Populate quality options based on all manufacturers
|
||||
var allQualities = <?= json_encode($manufacturers) ?>.map(function(manufacturer) {
|
||||
return manufacturer.quality.split(',');
|
||||
}).flat().filter(function(item, index, self) {
|
||||
return self.indexOf(item) === index;
|
||||
}).sort();
|
||||
allQualities.forEach(function(quality) {
|
||||
$('#quality').append('<option value="' + quality.trim() + '" ' + (selectedManufacturer && selectedManufacturer.quality.includes(quality.trim()) ? 'selected' : '') + '>' + quality.trim() + '</option>');
|
||||
});
|
||||
}
|
||||
|
||||
// Call the function initially
|
||||
$(document).ready(function() {
|
||||
// Get the selected manufacturer ID
|
||||
var selectedManufacturerId = $('#manufacturer').val();
|
||||
// Update the quality dropdown initially
|
||||
updateQualityDropdown(selectedManufacturerId);
|
||||
|
||||
// Update the quality dropdown when manufacturer selection changes
|
||||
$('#manufacturer').change(function() {
|
||||
var manufacturerId = $(this).val();
|
||||
updateQualityDropdown(manufacturerId);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
// Set selected manufacturer and quality for editing
|
||||
$(document).ready(function() {
|
||||
// Check if products data is available (for editing)
|
||||
var productsData = <?= json_encode($products) ?>;
|
||||
if (productsData) {
|
||||
// Set selected manufacturer
|
||||
$('#manufacturer').val(productsData.manufacturer_id);
|
||||
// Trigger change event to update quality dropdown
|
||||
$('#manufacturer').trigger('change');
|
||||
// Set selected quality
|
||||
|
||||
$('#quality').val(productsData.quality);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
// Function to update the preferred vendor dropdown based on selected vendors
|
||||
function updatePreferredVendorDropdown() {
|
||||
var selectedVendors = $('#vendor').val();
|
||||
// Clear existing options
|
||||
$('#preferred_vendor').empty();
|
||||
// Populate preferred vendor options based on selected vendors
|
||||
selectedVendors.forEach(function(vendorId) {
|
||||
var vendorName = $('#vendor option[value="' + vendorId + '"]').text();
|
||||
$('#preferred_vendor').append('<option value="' + vendorId + '" selected>' + vendorName + '</option>');
|
||||
});
|
||||
}
|
||||
|
||||
// Call the function initially
|
||||
$(document).ready(function() {
|
||||
// Update the preferred vendor dropdown initially
|
||||
// updatePreferredVendorDropdown();
|
||||
|
||||
// Update the preferred vendor dropdown when vendors selection changes
|
||||
$('#vendor').change(function() {
|
||||
updatePreferredVendorDropdown();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
<script>
|
||||
$('#saveMakeBtn').click(function() {
|
||||
var make = $('#makes').val();
|
||||
var model = $('#models').val();
|
||||
|
||||
if (make != '' && model != '') {
|
||||
$.ajax({
|
||||
url: '<?php echo base_url().'save_make'?>',
|
||||
method: 'POST',
|
||||
data: {
|
||||
make: make,
|
||||
model: model
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
$('#addMakeModalButton').modal('hide');
|
||||
// Handle success here, e.g., show a success message
|
||||
toastr.success("Make and model saved successfully");
|
||||
window.location.reload();
|
||||
} else {
|
||||
// Handle failure here, e.g., show an error message
|
||||
toastr.error("Failed to save make and model");
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('Error occurred while saving make and model:', error);
|
||||
toastr.error("Failed to save make and model. Please try again");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
toastr.warning("Please fill in both make and model fields");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
.select2-container--default .select2-results__option--highlighted[aria-selected]{
|
||||
color:#ffffff;
|
||||
background: #526dee!important;
|
||||
}
|
||||
.select2-container .select2-selection--single{
|
||||
height: 36px;
|
||||
border:1px solid #ced4da;
|
||||
}
|
||||
.select2-container--default .select2-selection--single .select2-selection__rendered{
|
||||
line-height: 36px;
|
||||
}
|
||||
.select2-container--default .select2-selection--single .select2-selection__arrow{
|
||||
top:4px;
|
||||
}
|
||||
</style>
|
||||
@ -3,7 +3,7 @@
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="page-title-box page-title-box-alt">
|
||||
<h4 class="page-title">Product List</h4>
|
||||
<h4 class="page-title">Product List <?= isset($manufacturer_id) && !empty($manufacturer_id) ? $manufacturer_name : '' ?></h4>
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<?php if(!$manufacturer_id) { ?>
|
||||
@ -30,9 +30,9 @@
|
||||
<thead>
|
||||
|
||||
<tr>
|
||||
<th>SKU Id</th>
|
||||
<th>Product Name</th>
|
||||
<th>Category</th>
|
||||
<th>Serial Number</th>
|
||||
<th>Unit Price</th>
|
||||
<th>Qty in Stock</th>
|
||||
<th>Sgst</th>
|
||||
@ -46,10 +46,11 @@
|
||||
<?php foreach ($products as $value) :
|
||||
if ($value['isactive'] == 1) : ?>
|
||||
<tr>
|
||||
<td><?= $value['sku_id']; ?></td>
|
||||
<td><?= $value['product_name']; ?></td>
|
||||
<td><?= $value['product_category']; ?></td>
|
||||
<td><?= $value['serial_no']; ?></td>
|
||||
<td><?= number_format($value['unit_price']); ?></td>
|
||||
|
||||
<td><?= number_format($value['unit_price']); ?></td>
|
||||
<td><?= $value['qty_stock']; ?></td>
|
||||
<td><?= $value['cgst']; ?>%</td>
|
||||
<td><?= $value['sgst']; ?>%</td>
|
||||
|
||||
242
app/Views/purchase_form.php
Normal file
242
app/Views/purchase_form.php
Normal file
@ -0,0 +1,242 @@
|
||||
<?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() . "product_index"; ?>" class="btn btn-secondary waves-effect">Cancel</a>
|
||||
<ol class="breadcrumb m-0">
|
||||
|
||||
</li>
|
||||
<!-- <li class="breadcrumb-item"><a href="javascript: void(0);">Tables</a></li>
|
||||
<li class="breadcrumb-item active">Datatables</li> -->
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</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">
|
||||
<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">Product<span class="text-danger">*</span></label>
|
||||
<select class="form-control" name="product_id" id="product_id">
|
||||
<option value="0">Select Product</option>
|
||||
<?php foreach ($product as $item): ?>
|
||||
<option value="<?= $item['product_id'] ?>"><?= $item['product_name'] ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="model" class="col-form-label">Vendor<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="vendor_id" id="vendor_id">
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputEmail4" class="col-form-label">Product Quantity<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="product_quantity" id="product_quantity" placeholder="Product Quantity" value="<?= isset($products['product_quantity']) ? $products['product_quantity'] : '' ?>" required>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="vendor" class="col-form-label">Unit Price<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="unit_price" id="unit_price">
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="vendor" class="col-form-label">Total Price<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="total_price" id="total_price">
|
||||
</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="<?= isset($purchase['order_date']) ? $purchase['order_date'] : '' ?>" >
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="contact_person_name" class="col-form-label">Contact Person Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="contact_person_name" id="contact_person_name" placeholder="Contact Person Name.."value="<?= isset($purchase['contact_person_name']) ? $purchase['contact_person_name'] : '' ?>" required>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="contact_person_mobile" class="col-form-label">Contact Person Mobile<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="contact_person_mobile" id="contact_person_mobile" placeholder="Contact Person Mobile" value="<?= isset($purchase['contact_person_mobile']) ? $purchase['contact_person_mobile'] : '' ?>" required>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="purchase_status" class="col-form-label">Purchase Status<span class="text-danger">*</span></label>
|
||||
<select name="purchase_status" id="purchase_status" class="form-control">
|
||||
<option value="draft">Draft</option>
|
||||
<option value="released">Released</option>
|
||||
<option value="cancel">Cancel</option>
|
||||
</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_addresss" class="col-form-label">Billing Addresss<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="billing_addresss" id="billing_addresss" placeholder="Billing Addresss"value="<?= isset($purchase['billing_addresss']) ? $purchase['billing_addresss'] : '' ?>" 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($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($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($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_addresss" class="col-form-label">Shipping Addresss<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="shipping_addresss" id="shipping_addresss" placeholder="Shipping Addresss"value="<?= isset($purchase['shipping_addresss']) ? $purchase['shipping_addresss'] : '' ?>" 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($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($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($purchase['shipping_postal_code']) ? $purchase['shipping_postal_code'] : '' ?>" required>
|
||||
</div>
|
||||
</div><br>
|
||||
<h4 class="header-title">Description Details :</h4><br>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="inputPassword4" class="col-form-label">Description</label>
|
||||
<textarea class="form-control" name="description" placeholder="Description"value="<?= isset($products['description']) ? $products['description'] : '' ?>" required>
|
||||
</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php include('layout/footer.php'); ?>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
// Check SGST checkbox by default
|
||||
$('#sgstCheckbox').prop('checked', true);
|
||||
$('#sgstValue').removeClass('d-none');
|
||||
|
||||
// Check CGST checkbox by default
|
||||
$('#cgstCheckbox').prop('checked', true);
|
||||
$('#cgstValue').removeClass('d-none');
|
||||
|
||||
// Handle change event for SGST checkbox
|
||||
$('#sgstCheckbox').change(function() {
|
||||
if ($(this).is(":checked")) {
|
||||
$('#sgstValue').removeClass('d-none');
|
||||
} else {
|
||||
$('#sgstValue').addClass('d-none');
|
||||
}
|
||||
});
|
||||
|
||||
// Handle change event for CGST checkbox
|
||||
$('#cgstCheckbox').change(function() {
|
||||
if ($(this).is(":checked")) {
|
||||
$('#cgstValue').removeClass('d-none');
|
||||
} else {
|
||||
$('#cgstValue').addClass('d-none');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/css/select2.min.css" rel="stylesheet">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
// Initialize select2
|
||||
$(".SelExample").select2();
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#product_id').change(function() {
|
||||
var product_id = $(this).val();
|
||||
|
||||
$.ajax({
|
||||
url: '<?php echo base_url('get_product/') ?>' + product_id,
|
||||
type: 'GET',
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
console.log(response);
|
||||
|
||||
if (response) {
|
||||
$('#unit_price').val(response.unit_price);
|
||||
$('#vendor_id').val(response.vendor_name);
|
||||
$('#vendor_id').attr('data-id', response.prefered_vendor);
|
||||
|
||||
$('#product_quantity').val(response.reorder_level);
|
||||
$('#contact_person_name').val(response.contact_person_name1);
|
||||
$('#contact_person_mobile').val(response.contact_person_mobile1);
|
||||
$('#total_price').val(response.unit_price * response.reorder_level);
|
||||
|
||||
|
||||
var currentDate = new Date().toISOString().split('T')[0]; // Get current date in yyyy-mm-dd format
|
||||
$('#order_date').val(currentDate);
|
||||
|
||||
|
||||
$('#shipping_addresss').val(response.branch.address);
|
||||
$('#shipping_state').val(response.branch.state);
|
||||
$('#shipping_city').val(response.branch.city);
|
||||
$('#shipping_postal_code').val(response.branch.postal_code);
|
||||
|
||||
|
||||
$('#billing_addresss').val(response.business.address);
|
||||
$('#billing_state').val(response.business.state);
|
||||
$('#billing_city').val(response.business.city);
|
||||
$('#billing_postal_code').val(response.business.postal_code);
|
||||
console.log(response.branch);
|
||||
}
|
||||
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Handle error
|
||||
console.error(xhr.responseText);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<style>
|
||||
.select2-container .select2-selection--multiple .select2-selection__choice{
|
||||
padding: 5px 7px 5px 0 !important;
|
||||
color: #000000;
|
||||
|
||||
}
|
||||
.select2-container--default .select2-results__option--highlighted[aria-selected]{
|
||||
color:#ffffff;
|
||||
background-color: #526dee;
|
||||
}
|
||||
.select2-container--default .select2-results__option{
|
||||
border-bottom: 1px solid #dddddd;
|
||||
}
|
||||
.select2-container--default .select2-results__option[aria-selected=true]{
|
||||
color: #000000;
|
||||
background-color: #3efba4;
|
||||
font-weight: 500;
|
||||
border-bottom: 1px solid #747474;
|
||||
}
|
||||
</style>
|
||||
70
app/Views/purchase_list.php
Normal file
70
app/Views/purchase_list.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?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">Purchase List </h4>
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class=""> <a href="<?= base_url() . "new_purchase/0"; ?>" class="btn btn-primary waves-effect"> <i class="ri-add-line"></i></a>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<!-- <h4 class="header-title">Business List</h4> -->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<table id="datatable-buttons" class="table table-striped dt-responsive nowrap w-100"
|
||||
style="width:100% !important;">
|
||||
<thead>
|
||||
|
||||
<tr>
|
||||
<th>Product Name</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<?php foreach ($products as $value) :
|
||||
if ($value['isactive'] == 1) : ?>
|
||||
<tr>
|
||||
<td><?= $value['product_name']; ?></td>
|
||||
<td><?= $value['product_category']; ?></td>
|
||||
<?php if(!$manufacturer_id) { ?><td><?= $value['serial_no']; ?></td><?php } ?>
|
||||
<td><?= number_format($value['unit_price']); ?></td>
|
||||
<td><?= $value['qty_stock']; ?></td>
|
||||
<td><?= $value['cgst']; ?>%</td>
|
||||
<td><?= $value['sgst']; ?>%</td>
|
||||
|
||||
<!-- Call the model method -->
|
||||
<?php if(!$manufacturer_id) { ?>
|
||||
<td>
|
||||
<a href="<?= "new_product/" . $value['product_id']; ?>" class="edit-button"><i
|
||||
class="ri-pencil-line"></i></a>
|
||||
<a href="<?= "delete_product/" . $value['product_id']; ?>"
|
||||
class="delete-button"><i class="ri-delete-bin-line"></i></a>
|
||||
</td>
|
||||
<?php } ?>
|
||||
<?php endif?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div> <!-- end table-responsive-->
|
||||
|
||||
</div>
|
||||
</div> <!-- end card -->
|
||||
</div> <!-- end col -->
|
||||
|
||||
</div>
|
||||
<?php include('layout/footer.php'); ?>
|
||||
@ -23,7 +23,7 @@
|
||||
<h4 class="header-title">Vehicle Details :</h4>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputPassword4" class="col-form-label">Make<span class="text-danger">*</span></label>
|
||||
<label for="inputPassword4" class="col-form-label">Make<span class="text-danger">*</span><i type="button" class="fe-plus-circle" id="addMakeModalButton" style="font-size: 18px;" data-toggle="modal" data-target="#addMakeModal" title="Add Client"></i></label>
|
||||
<select class="form-control SelExample" name="make" id="make" <?= isset($vehicle['make']) ? '' : 'required' ?>>
|
||||
<?= isset($vehicle['make']) ? '' : '<option value="">Select a Make</option>' ?>
|
||||
<?php foreach ($makeData as $value) : ?>
|
||||
@ -119,7 +119,35 @@
|
||||
|
||||
<?php include('layout/footer.php'); ?>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="addMakeModal" tabindex="-1" role="dialog" aria-labelledby="addMakeModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="addMakeModalLabel">Add New Make</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="addClientForm">
|
||||
<div class="form-group">
|
||||
<label for="clientName">Make</label>
|
||||
<input type="text" class="form-control" id="makes" placeholder="Enter Make"required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="clientMobile">Model</label>
|
||||
<input type="text" class="form-control" id="models" placeholder="Enter Model"required>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||
<button type="button" class="btn btn-primary" id="saveMakeBtn">Save Make</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Client Modal -->
|
||||
<div class="modal fade" id="addClientModal" tabindex="-1" role="dialog" aria-labelledby="addClientModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
@ -280,7 +308,41 @@ $(document).ready(function() {
|
||||
// Define the clients array and populate it with data
|
||||
var clients = <?php echo json_encode($client); ?>;
|
||||
</script>
|
||||
<!-- Mkae Modal ajax -->
|
||||
<script>
|
||||
$('#saveMakeBtn').click(function() {
|
||||
var make = $('#makes').val();
|
||||
var model = $('#models').val();
|
||||
|
||||
if (make != '' && model != '') {
|
||||
$.ajax({
|
||||
url: '<?php echo base_url().'save_make'?>',
|
||||
method: 'POST',
|
||||
data: {
|
||||
make: make,
|
||||
model: model
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
$('#addMakeModalButton').modal('hide');
|
||||
// Handle success here, e.g., show a success message
|
||||
toastr.success("Make and model saved successfully");
|
||||
window.location.reload();
|
||||
} else {
|
||||
// Handle failure here, e.g., show an error message
|
||||
toastr.error("Failed to save make and model");
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('Error occurred while saving make and model:', error);
|
||||
toastr.error("Failed to save make and model. Please try again");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
toastr.warning("Please fill in both make and model fields");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
.select2-container--default .select2-results__option--highlighted[aria-selected]{
|
||||
color:#ffffff;
|
||||
|
||||
@ -55,10 +55,22 @@
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="manufacturer" class="col-form-label">Manufacturer<span class="text-danger">*</span></label>
|
||||
<select class="form-control SelExample" id="manufacturer" name="manufacturer[]" required multiple>
|
||||
<option value="">Select a Manufacturer</option>
|
||||
<?php if(isset($manufacturers) && !empty($manufacturers)): ?>
|
||||
<?php foreach($manufacturers as $value): ?>
|
||||
<option value="<?= $value['manufacturer_id'] ?>" <?= isset($vendor['manufacturer_id']) && in_array($value['manufacturer_id'], json_decode($vendor['manufacturer_id'], true)) ? 'selected' : '' ?>>
|
||||
<?= $value['manufacturer_name'] ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<br>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user