diff --git a/plugins/romanah/gokbakja/components/Order.php b/plugins/romanah/gokbakja/components/Order.php index 18d6cca..62cc614 100644 --- a/plugins/romanah/gokbakja/components/Order.php +++ b/plugins/romanah/gokbakja/components/Order.php @@ -259,14 +259,9 @@ class Order extends ComponentBase $html_data = ''; $orderDatas = OrderModel::with(["client", "shipping"]) - ->withCount(['order_items as order_all_amount' => function ($query) { - $query->select(DB::raw('sum(amount)')); - }]) + ->withCount(['order_items as qty']) ->withCount(['order_items as order_all_price' => function ($query) { - $query->select(DB::raw('sum(price) * sum(amount)')); - }]) - ->withCount(['payment as all_payments' => function ($query) { - $query->select(DB::raw('sum(amount)')); + $query->select(DB::raw('sum(price) * sum(amount) / qty')); }]) ->orderBy('id', 'DESC') ->get(); diff --git a/plugins/romanah/gokbakja/components/OrderItem.php b/plugins/romanah/gokbakja/components/OrderItem.php index dbfcfd6..af9baef 100644 --- a/plugins/romanah/gokbakja/components/OrderItem.php +++ b/plugins/romanah/gokbakja/components/OrderItem.php @@ -149,7 +149,7 @@ class OrderItem extends ComponentBase if($orderItems[$x]->user_id != $user->id){ $editBtnPrice = ''.number_format($orderItems[$x]->price).' $'; + style="font-size: 14px;">'.number_format($orderItems[$x]->price, 2).' $'; $editAmount = ''; @@ -159,11 +159,11 @@ class OrderItem extends ComponentBase data-request-data="orderItemId: '.$orderItems[$x]->id.'" data-bs-toggle="modal" data-bs-target=".bs-example-modal-sm-1" class="badge badge-soft-success" - style="font-size: 14px;">'.number_format($orderItems[$x]->price).' $' + style="font-size: 14px;">'.number_format($orderItems[$x]->price, 2).' $' : ''.number_format($orderItems[$x]->price).' $'; + style="font-size: 14px;">'.number_format($orderItems[$x]->price, 2).' $'; $editAmount = $crudOrderq ? 'orderBy('id', 'DESC'); + $productions = ProductionModel::with(['pivot_production', 'excruiter', 'shift', 'pivot_production_calculation'])->orderBy('date', 'DESC')->orderBy('time', 'DESC'); + $productionsCalc = ProductionModel::orderBy('id', 'DESC'); $productionsCalcPivot = ProductionCalculateModel::orderBy('id', 'DESC'); @@ -89,9 +90,17 @@ class Production extends ComponentBase } $productionsFiltered = $productions->get(); - $calculationAmount = $productionsCalcPivot->sum("amount_calc"); - //dd($calculationAmount); + //$calculationAmount = $productionsCalcPivot->sum("amount_calc"); + + $calculationAmountqq = $productions->where('id', '!=', $productionsFiltered[0]->id)->get()->pluck('id')->toArray(); + + $pivotIds = PivotProductionModel::whereIn('production_id', $calculationAmountqq)->get()->pluck('id')->toArray(); + + $calculationAmount = ProductionCalculateModel::whereIn('prev_pivot_id', $pivotIds)->sum("amount_calc"); + + + //dd($pivotIds); $html_data = ''; for ($x = 0; $x < count($productionsFiltered); $x++) { @@ -104,7 +113,7 @@ class Production extends ComponentBase // dd($productionsFiltered[0]->shift->desc); $html_data .= ' ' . ($x + 1) . ' - ' . $date . ' + ' . $date . ' ' . $productionsFiltered[$x]->shift->desc . ' param("month"); + $year = $this->param("year"); + + + + if($this["month"] == 'default'){ + $this["month"] = $currentDate->month; + } + + $reportDatas = []; + //dd($reportDatas); + + $bagProds = Romanah\Gokbakja\Models\SewerProduction::select('width', 'height') + ->whereMonth('date', 11) + ->whereYear('date', $currentDate->year) + ->groupBy('width') + ->groupBy('height') + ->orderBy('width', 'ASC') + ->distinct() + ->get(); + + + $bagGrams = Romanah\Gokbakja\Models\PivotSewer::select('bag_gram') + ->with('sewer_production') + ->whereHas('sewer_production', function($qq) use($currentDate){ + $qq->whereMonth('date', 11)->whereYear('date', $currentDate->year); + }) + ->groupBy('bag_gram') + ->orderBy('bag_gram', 'ASC') + ->distinct() + ->get(); + + for ($x = 0; $x < count($bagProds); $x++) { + + $reportDatas[$x]["width"] = $bagProds[$x]->width; + $reportDatas[$x]["height"] = $bagProds[$x]->height; + + + $action = Romanah\Gokbakja\Models\BagAction::select('romanah_gokbakja_bag_actions.*') + ->with('product') + ->with('product.pivot_sewer') + ->whereYear('created_at', $year) + ->whereMonth('created_at', $this["month"]) + ->whereHas('product', function($qq) use($bagProds, $x){ + $qq->where('width', $bagProds[$x]->width)->where('height', $bagProds[$x]->height); + }) + ->sum('amount'); + + + $reportDatas[$x]["amount"] = $action; + + } + + dd($reportDatas); + if($year){ + + }else{ + + } +} +?> +== +{% put styles %} + + + +{% endput %} + +
+ + +
+
+
+

Aýlar Boýunça {{year}}

+ +
+
+
+ + +
+
+ + + + + + + + +
+
+ +
+ + +{% partial 'dataTableJs' %} diff --git a/themes/gokbakja/pages/actions/rulon-report.htm b/themes/gokbakja/pages/actions/rulon-report.htm new file mode 100644 index 0000000..27a7461 --- /dev/null +++ b/themes/gokbakja/pages/actions/rulon-report.htm @@ -0,0 +1,253 @@ +title = "actions/rulon-report" +url = "/actions/rulon-report/:month/:year?" +layout = "platform_main" +is_hidden = 0 +== +param("month"); + $year = $this->param("year"); + + + + if($this["month"] == 'default'){ + $this["month"] = $currentDate->month; + } + + + //dd($reportDatas); + + + + if($year){ + $reportDatas = []; + + $rulonProds = Romanah\Gokbakja\Models\ProductionMachine::select('gram', 'width') + ->whereMonth('date', $this["month"]) + ->whereYear('date', $year) + ->groupBy('gram')->groupBy('width') + ->orderBy('width', 'ASC') + ->distinct() + ->get(); + + for ($x = 0; $x < count($rulonProds); $x++) { + + $action = Romanah\Gokbakja\Models\RulonAction::select('romanah_gokbakja_rulon_action.*') + ->with('product') + ->whereYear('created_at', $year) + ->whereMonth('created_at', $this["month"]) + ->whereHas('product', function($qq) use($rulonProds, $x){ + $qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width); + }) + ->sum('amount'); + + $actionIn = Romanah\Gokbakja\Models\RulonAction::select('romanah_gokbakja_rulon_action.*') + ->with('product') + ->where('type', 'inbox') + ->whereYear('created_at', $year) + ->whereMonth('created_at', $this["month"]) + ->whereHas('product', function($qq) use($rulonProds, $x){ + $qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width); + }) + ->sum('amount'); + + + $actionOut = Romanah\Gokbakja\Models\RulonAction::select('romanah_gokbakja_rulon_action.*') + ->with('product') + ->where('type', 'outbox') + ->whereYear('created_at', $year) + ->whereMonth('created_at', $this["month"]) + ->whereHas('product', function($qq) use($rulonProds, $x){ + $qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width); + }) + ->sum('amount'); + + $reportDatas[$x]["gram"] = $rulonProds[$x]->gram; + $reportDatas[$x]["width"] = $rulonProds[$x]->width; + $reportDatas[$x]["start_month"] = $action; + $reportDatas[$x]["in"] = $actionIn; + $reportDatas[$x]["out"] = $actionOut; + + } + + $this['reportDatas'] = $reportDatas; + }else{ + $reportDatas = []; + + $rulonProds = Romanah\Gokbakja\Models\ProductionMachine::select('gram', 'width') + ->whereMonth('created_at', $this["month"]) + ->whereYear('date', $currentDate->year) + ->groupBy('gram')->groupBy('width') + ->orderBy('width', 'ASC') + ->distinct() + ->get(); + + for ($x = 0; $x < count($rulonProds); $x++) { + + $action = Romanah\Gokbakja\Models\RulonAction::select('romanah_gokbakja_rulon_action.*') + ->with('product') + ->whereYear('created_at', $currentDate->year) + ->whereMonth('created_at', $this["month"]) + ->whereHas('product', function($qq) use($rulonProds, $x){ + $qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width); + }) + ->sum('amount'); + + $actionIn = Romanah\Gokbakja\Models\RulonAction::select('romanah_gokbakja_rulon_action.*') + ->with('product') + ->where('type', 'inbox') + ->whereYear('created_at', $currentDate->year) + ->whereMonth('created_at', $this["month"]) + ->whereHas('product', function($qq) use($rulonProds, $x){ + $qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width); + }) + ->sum('amount'); + + + $actionOut = Romanah\Gokbakja\Models\RulonAction::select('romanah_gokbakja_rulon_action.*') + ->with('product') + ->where('type', 'outbox') + ->whereYear('created_at', $currentDate->year) + ->whereMonth('created_at', $this["month"]) + ->whereHas('product', function($qq) use($rulonProds, $x){ + $qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width); + }) + ->sum('amount'); + + $reportDatas[$x]["gram"] = $rulonProds[$x]->gram; + $reportDatas[$x]["width"] = $rulonProds[$x]->width; + $reportDatas[$x]["start_month"] = $action; + $reportDatas[$x]["in"] = $actionIn; + $reportDatas[$x]["out"] = $actionOut; + + } + $this['reportDatas'] = $reportDatas; + } +} +?> +== +{% put styles %} + + + +{% endput %} + +
+ + +
+
+
+

Aýlar Boýunça {{year}}

+ +
+
+
+ + +
+
+ + + + + + + + +
+
+ +
+ + +{% partial 'dataTableJs' %} diff --git a/themes/gokbakja/pages/orders/order-detail.htm b/themes/gokbakja/pages/orders/order-detail.htm index d30144d..553ec2b 100644 --- a/themes/gokbakja/pages/orders/order-detail.htm +++ b/themes/gokbakja/pages/orders/order-detail.htm @@ -24,7 +24,7 @@ function onStart(){ ->first(); if($count > 0){ - $this["all"] = ($this["order"]->order_all_amount * $this["order"]->order_all_price) / $count; + $this["all"] = ($this["order"]->order_all_amount * $this["order"]->order_all_price) / $count; } $this["orderItems"] = Romanah\Gokbakja\Models\OrderItem::where("order_id", $orderId)->orderBy("id", "DESC")->with(["type", "size", "color"])->get(); diff --git a/themes/gokbakja/pages/orders/order-detaillogistics.htm b/themes/gokbakja/pages/orders/order-detaillogistics.htm index 3e6a095..baab1de 100644 --- a/themes/gokbakja/pages/orders/order-detaillogistics.htm +++ b/themes/gokbakja/pages/orders/order-detaillogistics.htm @@ -12,19 +12,23 @@ function onStart(){ $orderId = $this->param("orderId"); - $this["order"] = Romanah\Gokbakja\Models\Order::where("id", $orderId)->with(["client", "shipping"]) - ->withCount(['order_items as order_all_amount' => function($query) { - $query->select(DB::raw('sum(amount)')); - }]) - ->withCount(['order_items as order_all_price' => function($query) { - $query->select(DB::raw('sum(price)')); - }]) - ->first(); + $this["order"] = Romanah\Gokbakja\Models\Order::where("id", $orderId) + ->withCount(['order_items as order_all_amount' => function($query) { + $query->select(DB::raw('sum(amount)')); + }]) + ->withCount(['order_items as order_all_price' => function($query) { + $query->select(DB::raw('sum(price)')); + }]) + ->first(); + + $count = Romanah\Gokbakja\Models\OrderItem::where("order_id", $orderId)->count(); + + if($count > 0){ + $this["all"] = ($this["order"]->order_all_amount * $this["order"]->order_all_price) / $count; + } $this["orderItems"] = Romanah\Gokbakja\Models\OrderItem::where("order_id", $orderId)->get(); - $this["all"] = ($this["order"]->order_all_amount * $this["order"]->order_all_price); - $this["transports"] = Romanah\Gokbakja\Models\ShippingTransport::where("shipping_id", $this["order"]->shipping_id)->with('shipping.order')->with('order_item')->orderBy("id", "DESC")->get(); diff --git a/themes/gokbakja/pages/orders/order-detailpayment.htm b/themes/gokbakja/pages/orders/order-detailpayment.htm index 452cf53..41f2564 100644 --- a/themes/gokbakja/pages/orders/order-detailpayment.htm +++ b/themes/gokbakja/pages/orders/order-detailpayment.htm @@ -12,16 +12,20 @@ function onStart(){ $orderId = $this->param("orderId"); - $this["order"] = Romanah\Gokbakja\Models\Order::where("id", $orderId)->with(["client", "shipping"]) - ->withCount(['order_items as order_all_amount' => function($query) { - $query->select(DB::raw('sum(amount)')); - }]) - ->withCount(['order_items as order_all_price' => function($query) { - $query->select(DB::raw('sum(price)')); - }]) - ->first(); + $this["order"] = Romanah\Gokbakja\Models\Order::where("id", $orderId) + ->withCount(['order_items as order_all_amount' => function($query) { + $query->select(DB::raw('sum(amount)')); + }]) + ->withCount(['order_items as order_all_price' => function($query) { + $query->select(DB::raw('sum(price)')); + }]) + ->first(); - $this["all"] = ($this["order"]->order_all_amount * $this["order"]->order_all_price); + $count = Romanah\Gokbakja\Models\OrderItem::where("order_id", $orderId)->count(); + + if($count > 0){ + $this["all"] = ($this["order"]->order_all_amount * $this["order"]->order_all_price) / $count; + } $this["payments"] = Romanah\Gokbakja\Models\Payment::where("order_id", $orderId)->with('order')->orderBy("id", "DESC")->get(); diff --git a/themes/gokbakja/pages/produced/rulonstock.htm b/themes/gokbakja/pages/produced/rulonstock.htm index 6cf58ef..90ac9a7 100644 --- a/themes/gokbakja/pages/produced/rulonstock.htm +++ b/themes/gokbakja/pages/produced/rulonstock.htm @@ -12,8 +12,6 @@ function onStart(){ $q->with(['bag_type', 'bag_size', 'color']); }]) ->where("stock_id", $stockId) - //->where("status_accountant", "accept") - //->where("status_director", "accept") ->addSelect(DB::raw("SUM(amount) as quantity")) ->having('quantity', '>', 0) ->groupBy('romanah_gokbakja_rulon_action.product_id') diff --git a/themes/gokbakja/pages/production/production.htm b/themes/gokbakja/pages/production/production.htm index a1c7998..392a12e 100644 --- a/themes/gokbakja/pages/production/production.htm +++ b/themes/gokbakja/pages/production/production.htm @@ -455,4 +455,4 @@ function onStart(){ -{% endput %} \ No newline at end of file +{% endput %}