diff --git a/app/Controllers/Invoice.php b/app/Controllers/Invoice.php index fbadc66e..5349988e 100644 --- a/app/Controllers/Invoice.php +++ b/app/Controllers/Invoice.php @@ -144,6 +144,8 @@ class Invoice extends BaseController $duedate = $this->request->getVar('due_date'); $invdate = $this->request->getVar('invoice_date'); $invoice_status = $this->request->getPost('status'); + // echo 'Hi'; + // echo($this->request->getPost('invoice_number'));die(); $invoice_id = (!empty($this->request->getPost('invoice_id'))) ? $this->request->getPost('invoice_id') : ""; $customer_id = (int)$this->request->getPost('customer_name'); $invoiceType = $this->request->getPost('invoice_type'); @@ -164,12 +166,13 @@ class Invoice extends BaseController 'discount' => (int)$this->request->getPost('discount'), 'total_amount' => (int)$this->request->getPost('grand_total'), 'shipping_charge' => (int)$this->request->getPost('shippingCharges'), + 'shipping_label' =>$this->request->getPost('shippingChargesLabel'), 'order_number' => $this->request->getPost('order_number'), - 'payment_method' => 'Cash on Delivery', // "Credit Card," "Cash on Delivery," "PayPal","PayTm","Gpay" + 'payment_method' =>$this->request->getPost('payment_method'), // "Credit Card," "Cash on Delivery," "PayPal","PayTm","Gpay" 'payment_status' => 'Pending', //"Paid," "Pending," "Failed," "Refunded," "Canceled," "Authorized," and "Completed." 'event_id' => (int)$this->request->getPost('event_id'), 'business_id' => (int)get_business_id(), - 'status' => $this->request->getPost('status'), + 'status' => $this->request->getPost('saveas'), 'isactive' => 1 ]; ## Based on the invoice ID, we designated Insert or Update on Details... @@ -521,8 +524,17 @@ class Invoice extends BaseController $model = new InvoiceModel(); $data = $model->getInvoiceData($id); $invoiceItems = $model->getInvoiceItems($id); - $invoiceTerms=$model->getInvoiceData($id); - // print_r($invoiceTerms);die() + $invoiceTerms= $model->getInvoiceData($id); + + foreach($invoiceItems as $index => $singleItem) + { + $productImgs= $model->getProductImgs($singleItem->product); + $invoiceItems[$index]->imgs = $productImgs; + + } + + + // print_r($invoiceItems);die(); $invoice_type = $data[0]->invoice_type; // print_r($invoiceItems);die(); diff --git a/app/Models/InvoiceModel.php b/app/Models/InvoiceModel.php index b508a178..f9e820d6 100644 --- a/app/Models/InvoiceModel.php +++ b/app/Models/InvoiceModel.php @@ -8,7 +8,7 @@ class InvoiceModel extends Model protected $table = 'invoice'; protected $primaryKey = 'invoice_id'; // protected $allowedFields = ['invoice_id','invoice_number','customer_id','invoice_date','event_id','business_id','created_on','business_id']; -protected $allowedFields = ['invoice_id', 'invoice_number', 'customer_id','notes', 'invoice_date', 'due_date', 'subtotal', 'tax', 'discount', 'shipping_charge','total_amount', 'payment_status', 'order_number','invoice_type', 'payment_method', 'event_id', 'business_id', 'shipping_address_id', 'billing_address_id', 'created_on', 'created_by', 'updated_on', 'updated_by','category','isactive','billing_address','shipping_address','status']; +protected $allowedFields = ['invoice_id', 'invoice_number', 'customer_id','notes', 'invoice_date', 'due_date', 'subtotal', 'tax', 'discount', 'shipping_charge','shipping_label','total_amount', 'payment_status', 'order_number','invoice_type', 'payment_method', 'event_id', 'business_id', 'shipping_address_id', 'billing_address_id', 'created_on', 'created_by', 'updated_on', 'updated_by','category','isactive','billing_address','shipping_address','status']; public function saveInvoiceItemDetails($data){ $i = 0; @@ -125,15 +125,39 @@ public function updateData($table, $data, $where) } // this function Also Used For Approve Notification. - public function getInvoiceItems($id) - { - return $this->db->table('invoiceitems') - ->where(['invoice_id'=>$id,'invoiceitems.isactive'=>1]) - ->join('books as B','B.book_id=invoiceitems.product','left') - ->select('invoiceitems.*,B.title') - ->get() - ->getResult(); - } + + public function getInvoiceItems($id) + { + $data = $this->db->table('invoiceitems') + ->where(['invoice_id' => $id, 'invoiceitems.isactive' => 1]) + ->join('books as B', 'B.book_id = invoiceitems.product', 'left') + // ->join('book_images as BI', 'BI.book_id = invoiceitems.product', 'left') + ->select('invoiceitems.*,B.*') + //->orderBy("book_img_id", "asc") // Order by book_img_id in ascending order + //->limit(1,0) + ->get() + ->getResult(); + + // print_r($this->db->getLastQuery()); + return $data; + } + + public function getProductImgs($productId) + { + $data = $this->db->table('book_images') + ->where(['book_id' => $productId]) + // ->join('books as B', 'B.book_id = invoiceitems.product', 'left') + // ->join('book_images as BI', 'BI.book_id = invoiceitems.product', 'left') + ->select('book_images.*') + //->orderBy("book_img_id", "asc") // Order by book_img_id in ascending order + //->limit(1,0) + ->get() + ->getResult(); + + // print_r($this->db->getLastQuery()); + return $data; + } + public function getCategoryBooks() { return $this->db->table('books') diff --git a/app/Views/invoice_form.php b/app/Views/invoice_form.php index 6559c9cf..7926660c 100644 --- a/app/Views/invoice_form.php +++ b/app/Views/invoice_form.php @@ -1,767 +1,890 @@ -
+ + + .discount-header { + text-align: center; + /* Add this to center-align the content */ + } + + -