示例#1
0
         $('.modal-backdrop').hide();*/
        $("#sale").modal('hide').on('hidden.bs.modal', functionThatEndsUpDestroyingTheDOM);
        $('.modal-backdrop').hide();
    }
</script>
<div class="modal-dialog shape">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" onclick="closeModal()" class="close" data-dismiss="modal" aria-hidden="true"></button>
            <?php 
$branch = new \App\Branch();
$branchName = \App\Branch::find($stock->branch_id);
?>
            <h3>Stock Detail for {{$branchName->name}}</h3>
            <?php 
$stockdetails = \App\StockDetail::where('invoice_id', '=', $stock->invoice_id)->first();
$stockName = \App\StockInfo::find($stockdetails->stock_info_id);
?>

            <h4>Branch Name : <?php 
echo $branchName->name;
?>
</h4>
            <h4>Stock Name : <?php 
echo $stockName->name;
?>
</h4>
            <h4>Product Type : <?php 
echo $stockdetails->product_type;
?>
</h4>
示例#2
0
 public function getShowinvoice($invoiceId)
 {
     $stockDetails = StockDetail::where('invoice_id', '=', $invoiceId)->get();
     $stock = StockInvoice::where('invoice_id', '=', $invoiceId)->first();
     return view('Stocks.showInvoice', compact('stockDetails'))->with('stock', $stock);
 }
示例#3
0
 public function getSale($invoice_id)
 {
     $saleDetails = SAleDetail::where('invoice_id', '=', $invoice_id)->get();
     $sale = Sale::where('invoice_id', '=', $invoice_id)->get();
     $temp = 0;
     $stockInvoiceId = StockInvoice::generateInvoiceId();
     foreach ($saleDetails as $saleDetail) {
         //$stock->status = "Activate";
         //           $stockDetails->branch_id = Input::get('branch_id');
         //           $stockDetails->product_id = Input::get('product_id');
         //           $stockDetails->entry_type = Input::get('entry_type');
         //           $stockDetails->product_type = Input::get('product_type');
         //           $stockDetails->stock_info_id = Input::get('stock_info_id');
         //           $stockDetails->remarks = Input::get('remarks');
         //           $stockDetails->invoice_id = Input::get('invoice_id');
         //           $stockDetails->quantity = Input::get('product_quantity');
         $stock_Count = StockCount::where('product_id', '=', $saleDetail->product_id)->where('stock_info_id', '=', $saleDetail->stock_info_id)->get();
         if (!empty($stock_Count[0])) {
             if ($stock_Count[0]->product_quantity >= $saleDetail->quantity) {
             } else {
                 $temp++;
                 Session::flash('message', 'You Dont have enough products in Stock');
             }
         } else {
             $temp++;
             Session::flash('message', 'You Dont have This products in This Stock');
         }
     }
     if ($temp == 0) {
         foreach ($saleDetails as $saleDetail) {
             $stockInvoces = new StockInvoice();
             $stockInvoces->branch_id = $saleDetail->branch_id;
             $stockInvoces->status = 'Activate';
             $stockInvoces->remarks = '';
             $stockInvoces->user_id = Session::get('user_id');
             $stockInvoces->invoice_id = $stockInvoiceId;
             $stock_invoices_check = StockInvoice::where('invoice_id', '=', $stockInvoiceId)->get();
             if (empty($stock_invoices_check[0])) {
                 $stockInvoces->save();
             }
             $stock = new StockDetail();
             $stock->branch_id = $saleDetail->branch_id;
             $stock->product_id = $saleDetail->product_id;
             $stock->product_type = $saleDetail->product_type;
             $stock->quantity = $saleDetail->quantity;
             $stock->entry_type = "StockOut";
             $stock->remarks = $saleDetail->remarks;
             $stock->invoice_id = $stockInvoiceId;
             $stock->stock_info_id = $saleDetail->stock_info_id;
             //$stock->status = "Activate";
             //           $stockDetails->branch_id = Input::get('branch_id');
             //           $stockDetails->product_id = Input::get('product_id');
             //           $stockDetails->entry_type = Input::get('entry_type');
             //           $stockDetails->product_type = Input::get('product_type');
             //           $stockDetails->stock_info_id = Input::get('stock_info_id');
             //           $stockDetails->remarks = Input::get('remarks');
             //           $stockDetails->invoice_id = Input::get('invoice_id');
             //           $stockDetails->quantity = Input::get('product_quantity');
             $stock_Count = StockCount::where('product_id', '=', $saleDetail->product_id)->where('stock_info_id', '=', $saleDetail->stock_info_id)->get();
             if (!empty($stock_Count[0])) {
                 if ($stock_Count[0]->product_quantity >= $stock->quantity) {
                     $stock_Count[0]->product_quantity = $stock_Count[0]->product_quantity - $stock->quantity;
                     //$stock->save();
                     $stock_Count[0]->save();
                     $stock->save();
                     $sale[0]->is_sale = 1;
                     $sale[0]->save();
                     //Session::flash('message', 'Stock has been Successfully Created && Product Quantity Subtracted');
                 } else {
                     Session::flash('message', 'You Dont have enough products in Stock');
                 }
             } else {
                 Session::flash('message', 'You Dont have This products in This Stock');
             }
         }
     }
     //        if($temp == 0) {
     //            foreach($saleDetails as $saleDetail)
     //            {
     //                $stock = new Stock();
     //                $stock->branch_id = $saleDetail->branch_id;
     //                $stock->product_id = $saleDetail->product_id;
     //                $stock->product_type = $saleDetail->product_type;
     //                $stock->product_quantity = $saleDetail->quantity;
     //                $stock->entry_type = "StockOut";
     //                $stock->remarks = $saleDetail->remarks;
     //                $stock->user_id = Session::get('user_id');
     //                $stock->stock_info_id = $saleDetail->stock_info_id;
     //                $stock->status = "Activate";
     //
     //                $stockCount = StockCount::where('product_id','=',$saleDetail->product_id)
     //                    ->where('stock_info_id','=',$saleDetail->stock_info_id)
     //                    ->get();
     //
     //
     //
     //                if(!empty($stockCount[0])) {
     //
     //                    if ($stockCount[0]->product_quantity >= $saleDetail->quantity) {
     //
     //                        $stockCount[0]->product_quantity = $stockCount[0]->product_quantity - $saleDetail->quantity;
     //                        $stock->save();
     //                        $stockCount[0]->save();
     //                        $sale[0]->is_sale=1;
     //                        $sale[0]->save();
     //                        //Session::flash('message', 'Stock  has been Successfully Balanced.');
     //                    }
     //                }
     //            }
     //
     //        }
     return Redirect::to('sales/index');
 }