diff --git a/app/Config/App.php b/app/Config/App.php index 74b28bfe..69f14c0d 100755 --- a/app/Config/App.php +++ b/app/Config/App.php @@ -19,7 +19,7 @@ class App extends BaseConfig * http://example.com/ */ // public string $baseURL = 'http://localhost:8080/'; - public string $baseURL = 'http://localhost/vb_book/'; + public string $baseURL = 'http://192.168.1.24/vb_book/'; /** * Allowed Hostnames in the Site URL other than the hostname in the baseURL. diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 27b99fcc..95f9fbb2 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -117,6 +117,7 @@ $routes->post("insert_invoice_number_format", "Event::insert_invoice_number_form #invoices $routes->get("invoice_list/", "Invoice::index"); $routes->get("offline_invoice/", "Invoice::offline_invoice"); +$routes->get('walkin_invoice','Invoice::walkin_customer'); $routes->get("new_book_invoice/(:any)", "Invoice::new_book_invoice/$1"); $routes->get("new_subscription_invoice/(:any)", "Invoice::new_subscription_invoice/$1"); // $routes->get("download_invoice_pdf/(:num)",'Invoice::download_invoice_pdf/$1'); diff --git a/app/Controllers/Customer.php b/app/Controllers/Customer.php index 24a27742..ed175683 100755 --- a/app/Controllers/Customer.php +++ b/app/Controllers/Customer.php @@ -196,7 +196,8 @@ class Customer extends BaseController // $address_array[$x]['company'] = ""; $address_array[$x]['email'] = $requestData['cmail']; $address_array[$x]['mobile_no'] = $requestData['cmobile']; - $address_array[$x]['address_1'] = $baddress1[$x]; + $saddress1_name = $requestData['saddress1_name'][0]; + $address_array[$x]['address_1'] = $saddress1_name.','. $baddress1[$x]; $address_array[$x]['address_2'] = $baddress2[$x]; $address_array[$x]['city'] = $bcity[$x]; $address_array[$x]['state'] = $bcountry[$x] === 'IN' ? $bdropdownstate[$x] : $binputstate[$x] ; @@ -650,11 +651,13 @@ class Customer extends BaseController 'billing_city' => $this->request->getPost('QB_city'), 'billing_pincode' => $this->request->getPost('QB_zip'), ]; + $shipping_address_name = $this->request->getPost('shipping_name'); + $shippingData = [ 'customer_id' => $this->request->getPost('customer_id'), 'first_name' => $this->request->getPost('first_name'), 'last_name' => $this->request->getPost('last_name'), - 'shipping_address1'=> $this->request->getPost('QS_address'), + 'shipping_address1'=> $shipping_address_name . ','.$this->request->getPost('QS_address'), 'shipping_address2'=> '', 'shipping_country' => $this->request->getPost('QS_country'), 'shipping_state' => $this->request->getPost('QS_state'), diff --git a/app/Controllers/Invoice.php b/app/Controllers/Invoice.php index 88a78fe1..8c954f10 100755 --- a/app/Controllers/Invoice.php +++ b/app/Controllers/Invoice.php @@ -72,7 +72,7 @@ class Invoice extends BaseController helper('financial_year_helper'); $model = new InvoiceModel(); - $where = ['business_id' => (int)get_business_id()]; + $where = ['business_id' => (int)get_business_id(),'isactive' =>1]; // Get customer names for the dropdown, events details, and books details $data['customers'] = $model->getData('customers', $where); @@ -386,6 +386,7 @@ class Invoice extends BaseController $this->logger->info("Invoice: Insert/Update Details"); try { // Retrieve form data + dd($_POST); $invoice_status = $this->request->getPost('status'); $invoice_id = (!empty($this->request->getPost('invoice_id'))) ? $this->request->getPost('invoice_id') : ""; $invoiceType = $this->request->getPost('invoice_type'); @@ -1654,5 +1655,39 @@ public function create_or_update_subscription($invoice_id,$invoice_status, $msg_ return $this->response->setJSON($response); } - + public function walkin_customer($id = '0'){ + + helper('session'); + helper('financial_year_helper'); + + $model = new InvoiceModel(); + $where = ['business_id' => (int)get_business_id()]; + + // Get customer names for the dropdown, events details, and books details + $data['customers'] = $model->getData('customers', $where); + $data['events'] = $model->getData('events', $where); + $data['financial_year'] = get_financial_year(); + $data['invoice_number_formatting'] = $model->getData('invoice_number_formatting', $where); + $data['books'] = $model->getCategoryBooks(1); // Invocie type = 2 (invoice) + + if ($id === '0') { + $this->logger->info("Book Invoice: In Add Details"); + $data['page_name'] = 'Walkin Customers'; + $data['invoice_type'] = '1'; + $data['invoice_details'] = []; + $data['invoice_item_details'] = []; + } elseif ($id !== '0') { + $data['page_name'] = 'Edit Walkin Customers'; + $data['invoice_type'] = '1'; + $data['invoice_details'] = $model->where(['invoice_id' => $id, 'isactive' => 1])->first(); + $select = ["customer_address_id", "CONCAT(address_1,' ',address_2) as address"]; + $where = ['address_type' => 2, 'customer_addresses.isactive' => 1, 'customer_addresses.customer_id' => (int)$data['invoice_details']['customer_id']]; + $data['customer_shipping_arr'] = $this->get_customer_address($where, $select); + $data['invoice_item_details'] = $this->get_invoice_item($id); + } + $country = new Customer(); + $data['country_details'] = $country->get_country_details(); + $this->render_page('invoice_form', $data); + } + } diff --git a/app/Controllers/Subscription.php b/app/Controllers/Subscription.php index 1a93ee2d..90b76107 100755 --- a/app/Controllers/Subscription.php +++ b/app/Controllers/Subscription.php @@ -277,6 +277,7 @@ public function download_details() $html = view('print_addresses_form', ['customerDetails' => $customerDetails, 'action' => $action, 'pdf' => $pdf]); // echo $html;die; // Add the details to the PDF + ini_set('pcre.backtrack_limit', 10000000); $pdf->WriteHTML($html); // Set the PDF filename diff --git a/app/Models/HomeModel.php b/app/Models/HomeModel.php index e9e46c6e..163edc26 100755 --- a/app/Models/HomeModel.php +++ b/app/Models/HomeModel.php @@ -59,7 +59,7 @@ class HomeModel extends Model // Today $date_where = ['DATE(created_on)' => date('Y-m-d'), 'invoice_type' => 1, 'isactive' => 1]; - $date_query = $this->db->table('invoice')->where($date_where)->countAllResults(); + $date_query = $this->db->table('invoice')->where($date_where)->where('status','Approved')->countAllResults(); $date_amount_query = $this->db->table('invoice')->selectSum('total_amount')->where($date_where)->where('status','Approved')->get()->getRowArray(); $invoice['today'] = [ 'count' => $date_query, @@ -68,8 +68,8 @@ class HomeModel extends Model // Current Month $month_where = ['MONTH(created_on)' => date('m'), 'invoice_type' => 1, 'isactive' => 1]; - $month_query = $this->db->table('invoice')->where($month_where)->countAllResults(); - $month_amount_query = $this->db->table('invoice')->selectSum('total_amount')->where($month_where)->get()->getRowArray(); + $month_query = $this->db->table('invoice')->where($month_where)->where('status','Approved')->countAllResults(); + $month_amount_query = $this->db->table('invoice')->selectSum('total_amount')->where($month_where)->where('status','Approved')->get()->getRowArray(); $invoice['month'] = [ 'count' => $month_query, 'total_amount' => $month_amount_query['total_amount'] ?? 0, @@ -77,8 +77,8 @@ class HomeModel extends Model // Current Financial Year $fin_year_where = ['DATE(created_on) >=' => $start_date, 'DATE(created_on) <=' => $end_date, 'invoice_type' => 1, 'isactive' => 1]; - $fin_year_query = $this->db->table('invoice')->where($fin_year_where)->countAllResults(); - $fin_year_amount_query = $this->db->table('invoice')->selectSum('total_amount')->where($fin_year_where)->get()->getRowArray(); + $fin_year_query = $this->db->table('invoice')->where($fin_year_where)->where('status','Approved')->countAllResults(); + $fin_year_amount_query = $this->db->table('invoice')->selectSum('total_amount')->where($fin_year_where)->where('status','Approved')->get()->getRowArray(); $invoice['year'] = [ 'count' => $fin_year_query, 'total_amount' => $fin_year_amount_query['total_amount'] ?? 0, diff --git a/app/Views/customer_form.php b/app/Views/customer_form.php index 0e75d561..ef237786 100755 --- a/app/Views/customer_form.php +++ b/app/Views/customer_form.php @@ -193,13 +193,19 @@