From be3216ce2e613414b6b6d245dc7ad7ef98d49732 Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Thu, 28 Nov 2024 11:01:00 +0530 Subject: [PATCH] Client feedback : GWM --- app/Config/Routes.php | 3 +- app/Controllers/Products.php | 62 +++++++++++++++--------------- app/Controllers/Purchase.php | 6 +-- app/Controllers/Sales.php | 1 - app/Models/SalesOrderModel.php | 3 ++ app/Views/client_form.php | 3 +- app/Views/invoice_pdf_template.php | 2 +- app/Views/product_categories.php | 2 +- app/Views/product_list.php | 4 +- app/Views/sales_order_form.php | 7 ++-- app/Views/vehicle_form.php | 3 +- 11 files changed, 49 insertions(+), 47 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 908fc5c..6b1cd00 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -62,7 +62,8 @@ $routes->get('get_branch_edit_form/(:any)',"Branch::get_branch_edit_form/$1"); $routes->get('product_index/', 'Products::product_index'); $routes->get('product_index/(:any)', 'Products::product_index/$1'); $routes->post("add_product", "Products::add_product"); -$routes->get("new_product/(:any)", "Products::new_product/$1"); +$routes->get("add_new_product", "Products::add_new_product"); +$routes->get("edit_product/(:any)", "Products::edit_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"); diff --git a/app/Controllers/Products.php b/app/Controllers/Products.php index 0c2ce7c..4992773 100755 --- a/app/Controllers/Products.php +++ b/app/Controllers/Products.php @@ -80,13 +80,11 @@ class Products extends BaseController } - public function new_product($product_id) + public function add_new_product() { if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); } - if ($product_id === '0') { - - + $tax = $this->ProductModel->getTax(); $data['tax']=$tax; @@ -103,20 +101,29 @@ class Products extends BaseController $data['vendorsProduct'] =[]; + $productcategory = $this->ProductCategoryModel->orderBy('product_category_id')->findAll(); + $data['product_id'] = 0; + $data['additionalProdutName'] = []; - } else if ($product_id !== '0') { - $data['page_name']="Edit Product"; + echo view('product_form',$data); + } + + public function edit_product($product_id) + { + + if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); } + + + $data['page_name'] = "Edit Product"; $products = $this->ProductModel->where('product_id', $product_id)->get()->getRowArray(); $products['make_id'] = json_decode($products['make_id'], true); $products['models_id'] = json_decode($products['models_id'], true); - $data['products'] = $products; - $data['make'] = $this->BikemakeModel->where('business_id', $this->session->get('logged_user_business_id'))->orderBy('make')->findAll(); $make_id = $products['make_id']; @@ -139,12 +146,7 @@ class Products extends BaseController $vendorIds = json_decode($products['vendor'], true); - - $vendors = []; - - - foreach ($vendorIds as $vendorId) { $vendor = $this->VendorModel->find($vendorId); if ($vendor) { @@ -152,28 +154,24 @@ class Products extends BaseController } } $data['vendorsProduct'] = $vendors; - // print_r($data['vendors']);die; + + $preferredVendorId = $products['prefered_vendor']; + + $data['preferredVendorId'] = $preferredVendorId; + - $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; - $data['product_id'] = $product_id; + $productcategory = $this->ProductCategoryModel->orderBy('product_category_id')->findAll(); + $additionalProdutName = $this->additionalProductNameModal + ->where('product_id', $product_id) + ->where('isactive', 1) + ->orderBy('product_names_id', 'asc') + ->findAll(); + $data['productcategory'] = $productcategory; + $data['additionalProdutName'] = $additionalProdutName; - $productcategory = $this->ProductCategoryModel->orderBy('product_category_id')->findAll(); - $additionalProdutName = $this->additionalProductNameModal - ->where('product_id', $product_id) - ->where('isactive', 1) - ->orderBy('product_names_id', 'asc') - ->findAll(); - $data['productcategory'] = $productcategory; - $data['additionalProdutName'] = $additionalProdutName; - - - - echo view('product_form',$data); + echo view('product_form',$data); } public function add_product() diff --git a/app/Controllers/Purchase.php b/app/Controllers/Purchase.php index e462084..c3ad635 100755 --- a/app/Controllers/Purchase.php +++ b/app/Controllers/Purchase.php @@ -245,7 +245,7 @@ class Purchase extends BaseController $this->PurchaseOrderModel->update($purchase_order_id, $data); } else { - + $this->PurchaseOrderModel->insert($data); $purchase_order_id = $this->PurchaseOrderModel->getInsertID(); } @@ -317,10 +317,10 @@ class Purchase extends BaseController // send purhase data through mail $vendor = $this->VendorModel->where('vendor_id',$this->request->getPost('vendor_id'))->findAll(); - $mail_status = $this->download_purchase_invoice($purchase_order_id, $vendor[0]['vendor_email']); + // $mail_status = $this->download_purchase_invoice($purchase_order_id, $vendor[0]['vendor_email']); // echo $mail_status;die; - $_SESSION['mail_status'] = $mail_status; + // $_SESSION['mail_status'] = $mail_status; } } diff --git a/app/Controllers/Sales.php b/app/Controllers/Sales.php index 31ea2c3..bc7a75f 100755 --- a/app/Controllers/Sales.php +++ b/app/Controllers/Sales.php @@ -419,7 +419,6 @@ class Sales extends BaseController ->first(); $data['items'] = $this->SalesOrderModel->getSalesOrderProductsForPdf($sales_order_id); - $html = view('invoice_pdf_template', $data); return $this->respond(['status' => 'success','code' => 200,'data' => $html],200); } diff --git a/app/Models/SalesOrderModel.php b/app/Models/SalesOrderModel.php index 7af6d1a..aa14d53 100755 --- a/app/Models/SalesOrderModel.php +++ b/app/Models/SalesOrderModel.php @@ -12,8 +12,11 @@ class SalesOrderModel extends Model ->where('sales_order_id', $sales_order_id) ->join('branches as B','B.branch_id = sales_order.branch_id','left') + ->join('vehicle as V','V.vehicle_id = sales_order.vehicle_id','left') + ->join('client as C','V.client_id = C.client_id','left') ->select('sales_order.*') ->select('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_1,B.contact_2 as company_mobile_no_2,B.gstno as company_gstno') + ->select('C.gstnumber as client_gst') ->get() ->getResult(); diff --git a/app/Views/client_form.php b/app/Views/client_form.php index 19ae56d..949d146 100755 --- a/app/Views/client_form.php +++ b/app/Views/client_form.php @@ -52,7 +52,8 @@
- + +
diff --git a/app/Views/invoice_pdf_template.php b/app/Views/invoice_pdf_template.php index eddf8c6..ef5640e 100644 --- a/app/Views/invoice_pdf_template.php +++ b/app/Views/invoice_pdf_template.php @@ -61,7 +61,7 @@ mode_of_payment; ?> - Mobile: mobile_no; ?> + Mobile: mobile_no; ?> , GST: client_gst) ? $sales[0]->client_gst : 'nil'; ?>       diff --git a/app/Views/product_categories.php b/app/Views/product_categories.php index 46f6459..1c1ed18 100644 --- a/app/Views/product_categories.php +++ b/app/Views/product_categories.php @@ -9,7 +9,7 @@
diff --git a/app/Views/product_list.php b/app/Views/product_list.php index 6c16830..58d8e5f 100755 --- a/app/Views/product_list.php +++ b/app/Views/product_list.php @@ -31,7 +31,7 @@
  • " class="btn btn-primary waves-effect">Categories View - " class="btn btn-primary waves-effect"> Add New Product + " class="btn btn-primary waves-effect"> Add New Product
  • @@ -112,7 +112,7 @@