public function createInvoice() { try { $_invoice = new Invoices(); $_invoice->firstName = Session::get('checkout.address')[0]['firstName']; $_invoice->lastName = Session::get('checkout.address')[0]['lastName']; $_invoice->companyname = Session::get('checkout.address')[0]['companyname']; $_invoice->email = Session::get('checkout.address')[0]['email']; $_invoice->country = Session::get('checkout.address')[0]['country']; $_invoice->state = Session::get('checkout.address')[0]['state']; $_invoice->street = Session::get('checkout.address')[0]['street']; $_invoice->zipcode = Session::get('checkout.address')[0]['zipcode']; $_invoice->telephone = Session::get('checkout.address')[0]['telephone']; $_invoice->comment = Session::get('checkout.address')[0]['comment']; $_invoice->invoiceCreater = Session::get('checkout.payment')[0]['payment']; $_invoice->invoiceCreatedDate = date("Y-m-d"); $_itemsCount = Cart::instance('shopping')->count(); $_contentCart = Cart::instance('shopping')->content(); $_contentTotal = Cart::instance('shopping')->total() + Cart::instance('shopping')->total() * 10 / 100; $_calculateinvoice = $this->getinvoicenumber(); $_invoice->invoice = $_calculateinvoice; $_invoice->save(); foreach ($_contentCart as $row) { $_resultData = DB::table('qlm_printerdetails')->where('detailId', $row->id)->get(); $_invoicedetails = new InvoiceDetails(); $_invoicedetails->product = $row->name; $_invoicedetails->quantity = $row->qty; $_invoicedetails->unitprice = $row->price; $_invoicedetails->gst = $row->price * 10 / 100; $_invoicedetails->total = $row->price * $row->qty + $row->price * $row->qty * 10 / 100; $_invoicedetails->invoice = $_calculateinvoice; $_invoicedetails->save(); } } catch (Exception $_ex) { Log::info("\$\$\$ --- Error: " . $_ex . " --- \$\$\$"); } }
private function removeLineItem() { $invoiceId = $this->_getParam('id'); $lineItem = $this->_getParam('detail'); $invoiceDetailsTable = new InvoiceDetails(); $detail = $invoiceDetailsTable->find($lineItem)->current(); if ($detail->invoice_id == $invoiceId) { $detail->delete(); } $this->_redirect('/invoices/view/id/' . $invoiceId); }