'RulonAction', 'description' => 'RulonAction settings' ]; } public function onCreateAction() { $user = \Auth::user(); $data = post(); $actionType = $data["type"]; $stock = Stock::where("type", 'rulon')->first(); if ($actionType == 'inbox') { $productionMachine = ProductionMachine::where("id", $data["itemId"])->first(); $createResult = new ActionModel(); $createResult->product_id = $data["itemId"]; $createResult->type = 'inbox'; $createResult->status_accountant = "new"; $createResult->status_director = "new"; $createResult->note = ""; $createResult->amount = $productionMachine->produced_weight; $createResult->stock_id = $stock->id; $createResult->user_id = $user->id; $createResult->save(); // $createResult = DollorModel::create([]); // dd($data); if ($createResult) { Flash::success("Rulon Action Inbox Ustunlikli Goshuldy"); return Redirect::refresh(); } } elseif ($actionType == 'outbox') { $qty = ActionModel::where("product_id", $data["product_id"]) ->where("stock_id", $stock->id) ->where("status_accountant", "accept") ->where("status_director", "accept") ->sum("produced_weight"); if ($qty >= $data["quantity"]) { $createResult = new ActionModel(); $createResult->product_id = $data["product_id"]; $createResult->type = 'outbox'; $createResult->amount = -$data["quantity"]; $createResult->stock_id = $data["stock_id"]; $createResult->user_id = $user->id; $createResult->save(); // $createResult = DollorModel::create([]); // dd($data); if ($createResult) { Flash::success("Harytlar sklatdan ustunlikli chykaryldy"); return Redirect::refresh(); } } else { Flash::error("Bu mukdarda haryt ýok"); return Redirect::refresh(); } } } public function onUpdateAction() { $user = \Auth::user(); $data = post(); $stock = Stock::where("type", 'rulon')->first(); $updateResult = ActionModel::where('id', $data["id"]) ->update(array( 'note' => $data["note"], 'user_id' => $user->id, )); // $createResult = DollorModel::create([]); // dd($data); if ($updateResult) { Flash::success("Action Ustunlikli Uytgedildi"); return Redirect::refresh(); } } public function onApproveAction(){ $data = post(); if($data["user_type"] == "director"){ $updateResult = ActionModel::where('id', $data["id"]) ->update(array( 'status_director' => "accept", )); }else{ $updateResult = ActionModel::where('id', $data["id"]) ->update(array( 'status_accountant' => "accept", )); } if ($updateResult) { Flash::success("Hereket Ustunlikli Tassyklandy"); return Redirect::refresh(); } } public function onGetAction() { $id = post('id'); return ActionModel::where('id', $id)->first(); } public function onDeleteAction() { $id = post('id'); $item = ActionModel::Find($id); $item->delete(); if ($item) { Flash::success("Action Ustunlikli Pozuldy"); return Redirect::refresh(); } } // public function onDeleteSellerAction() // { // $id = post('id'); // $item = SellerActionModel::Find($id); // $item->delete(); // if ($item) { // Flash::success("Action Ustunlikli Pozuldy"); // return Redirect::refresh(); // } // } // public function onGetSellerAction() // { // $id = post('id'); // return SellerActionModel::where('id', $id)->first(); // } // public function onCreateSellerAction() // { // $user = \Auth::user(); // $data = post(); // $qty = ActionModel::where("product_id", $data["product_id"]) // ->where("stock_id", $data["stock_id"]) // ->sum("quantity"); // if ($qty >= $data["quantity"]) { // $createResult = new ActionModel(); // $createResult->product_id = $data["product_id"]; // $createResult->type = 'outbox'; // $createResult->quantity = -$data["quantity"]; // $createResult->stock_id = $data["stock_id"]; // $createResult->user_id = $user->id; // $createResult->save(); // $createSellerResult = new SellerActionModel(); // $createSellerResult->seller_id = $data["seller_id"]; // $createSellerResult->product_id = $data["product_id"]; // $createSellerResult->quantity = $data["quantity"]; // $createSellerResult->stock_id = $data["stock_id"]; // $createSellerResult->user_id = $user->id; // $createSellerResult->save(); // // $createResult = DollorModel::create([]); // // dd($data); // if ($createResult && $createSellerResult) { // Flash::success("Action Outbox Ustunlikli Goshuldy"); // return Redirect::refresh(); // } // } else { // Flash::error("Данного товара нет в наличии"); // return Redirect::refresh(); // } // } // public function onUpdateSellerAction() // { // $user = \Auth::user(); // $data = post(); // $qty = ActionModel::where("product_id", $data["product_id"]) // ->where("stock_id", $data["stock_id"]) // ->sum("quantity"); // if ($qty >= $data["quantity"]) { // $updateResult = SellerActionModel::where('id', $data["id"]) // ->update(array( // 'product_id' => $data["product_id"], // 'quantity' => $data["quantity"], // 'stock_id' => $data["stock_id"], // 'user_id' => $user->id, // )); // // $createResult = DollorModel::create([]); // // dd($data); // if ($updateResult) { // Flash::success("Action Ustunlikli Uytgedildi"); // return Redirect::refresh(); // } // } else { // Flash::error("Данного товара нет в наличии"); // return Redirect::refresh(); // } // } }