Пример #1
0
 public function getProductbalance($product_id)
 {
     $stockCount = StockCount::where('product_id', '=', $product_id)->where('stock_info_id', '=', Input::get('data'))->first();
     if ($stockCount) {
         echo "<p3 style='color: blue;font-size: 114%; margin-left: 32px;'>Your product Balance This Stock is {$stockCount->product_quantity}</p3>";
     } else {
         echo "<p3 style='color: blue;font-size: 114%; margin-left: 32px; '>You Dont have this Product In this Stock</p3>";
     }
 }
Пример #2
0
 public function getDelete($id)
 {
     $stock = StockDetail::find($id);
     $stockCount = StockCount::where('product_id', '=', $stock->product_id)->where('stock_info_id', '=', $stock->stock_info_id)->get();
     if ($stock->entry_type == 'StockIn') {
         $stockCount[0]->product_quantity = $stockCount[0]->product_quantity - $stock->quantity;
         $stockCount[0]->save();
     } elseif ($stock->entry_type == 'StockOut') {
         $stockCount[0]->product_quantity = $stockCount[0]->product_quantity + $stock->quantity;
         $stockCount[0]->save();
     } elseif ($stock->entry_type == 'Transfer') {
         $stockCount[0]->product_quantity = $stockCount[0]->product_quantity + $stock->quantity;
         $stockCount[0]->save();
         $stockCountTo = StockCount::where('product_id', '=', $stock->product_id)->where('stock_info_id', '=', $stock->to_stock_info_id)->get();
         $stockCountTo[0]->product_quantity = $stockCountTo[0]->product_quantity - $stock->quantity;
         $stockCountTo[0]->save();
     }
     $invoice_id = $stock->invoice_id;
     $stock->delete();
     $checkStockDetailsRow = StockDetail::where('invoice_id', '=', $invoice_id)->get();
     if (empty($checkStockDetailsRow[0])) {
         $stock_invoice = StockInvoice::where('invoice_id', '=', $invoice_id)->get();
         if (!empty($stock_invoice[0])) {
             echo 'deleted';
             $stock_invoice[0]->delete();
         }
     }
     //Session::flash('message', 'Stock  has been Successfully Deleted.');
     //return Redirect::to('stocks/index');
 }
Пример #3
0
 private function setStockData($import, $import_details, $stockDetails, $invoiceId, $to_stock_id)
 {
     $stock_Count = StockCount::where('product_id', '=', $import_details->product_id)->where('stock_info_id', '=', $to_stock_id)->get();
     $stockDetails->branch_id = $import->branch_id;
     $stockDetails->product_id = $import_details->product_id;
     $stockDetails->entry_type = "StockIn";
     $product = Product::find($import_details->product_id);
     $stockDetails->product_type = $product->product_type;
     $stockDetails->stock_info_id = $to_stock_id;
     $stockDetails->remarks = "";
     $stockDetails->invoice_id = $invoiceId;
     $stockDetails->quantity = $import_details->quantity;
     $import_details->stock_in_status = 1;
     $import_details->save();
     if ($stockDetails->entry_type == 'StockIn') {
         $stockDetails->consignment_name = $import->consignment_name;
         if (empty($stock_Count[0])) {
             $stock_Count = new StockCount();
             $stock_Count->product_id = $import_details->product_id;
             $stock_Count->stock_info_id = $stockDetails->stock_info_id;
             $stock_Count->product_quantity = $import_details->quantity;
             $stock_Count->save();
             $stockDetails->save();
             //$stockCounts->save();
         } else {
             $stock_Count[0]->product_quantity = $stock_Count[0]->product_quantity + $import_details->quantity;
             //$stock->save();
             $stock_Count[0]->save();
             $stockDetails->save();
         }
     }
 }
Пример #4
0
 public function getDelete($id)
 {
     $stock = Stock::find($id);
     $stockCount = StockCount::where('product_id', '=', $stock->product_id)->where('stock_info_id', '=', $stock->stock_info_id)->get();
     if ($stock->entry_type == 'StockIn') {
         $stockCount[0]->product_quantity = $stockCount[0]->product_quantity - $stock->product_quantity;
         $stockCount[0]->save();
     } elseif ($stock->entry_type == 'StockOut') {
         $stockCount[0]->product_quantity = $stockCount[0]->product_quantity + $stock->product_quantity;
         $stockCount[0]->save();
     } elseif ($stock->entry_type == 'Transfer') {
         $stockCount[0]->product_quantity = $stockCount[0]->product_quantity + $stock->product_quantity;
         $stockCount[0]->save();
         $stockCountTo = StockCount::where('product_id', '=', $stock->product_id)->where('stock_info_id', '=', $stock->to_stock_info_id)->get();
         $stockCountTo[0]->product_quantity = $stockCountTo[0]->product_quantity - $stock->product_quantity;
         $stockCountTo[0]->save();
     }
     $stock->delete();
     Session::flash('message', 'Stock  has been Successfully Deleted.');
     return Redirect::to('stocks/index');
 }
Пример #5
0
 public function getStocks($id)
 {
     $stocks = StockCount::where('product_id', '=', $id)->get();
     $stockArray = array();
     $x = "";
     foreach ($stocks as $row) {
         $stockInfo = StockInfo::find($row->stock_info_id);
         $x .= "<option value='" . $row->stock_info_id . "'>" . $stockInfo->name . " (" . $row->product_quantity . ")</option>";
         array_push($stockArray, $row->stock_info_id);
     }
     $stocks = StockInfo::whereNotIn('id', $stockArray)->get();
     foreach ($stocks as $row) {
         $x .= "<option value='" . $row->id . "'>" . $row->name . " (0)</option>";
     }
     $product = Product::find($id);
     $data = array('list' => $x, 'price' => $product->price);
     return json_encode($data);
 }