order item settings
This commit is contained in:
parent
0dfe1f6801
commit
f58d6ab196
|
|
@ -12,6 +12,9 @@ use Carbon\Carbon;
|
|||
use Flash;
|
||||
use DB;
|
||||
use October\Rain\Support\Facades\Flash as FacadesFlash;
|
||||
use Romanah\Gokbakja\Models\BagAction;
|
||||
use Romanah\Gokbakja\Models\RulonAction;
|
||||
use Romanah\Gokbakja\Models\Stock;
|
||||
|
||||
class OrderItem extends ComponentBase
|
||||
{
|
||||
|
|
@ -43,61 +46,72 @@ class OrderItem extends ComponentBase
|
|||
$notCompleteCalc = 0;
|
||||
|
||||
if ($orderItems[$x]->order_item_type == 'rulon'){
|
||||
$stock = Stock::where("type", 'rulon')->first();
|
||||
|
||||
$machineProductionsFiltered = ProductionMachineModel::where("type_id", $orderItems[$x]->type_id)
|
||||
->where("size_id", $orderItems[$x]->size_id)
|
||||
->where("color_id", $orderItems[$x]->color_id)
|
||||
->withCount([
|
||||
'pivot_sewer AS leftSum' => function ($query) {
|
||||
$query->select(DB::raw("(amount - SUM(spent_amount)) as leftSum"))->where('status', 'complated');
|
||||
}
|
||||
])
|
||||
->withCount([
|
||||
'pivot_sewer AS spentSum' => function ($query) {
|
||||
$query->select(DB::raw("(SUM(spent_amount)) as spentSum"))->where('status', 'complated');
|
||||
}
|
||||
])
|
||||
->get();
|
||||
$bag_type = $orderItems[$x]->type_id;
|
||||
$bag_size = $orderItems[$x]->size_id;
|
||||
$color = $orderItems[$x]->color_id;
|
||||
$amountCalc = $orderItems[$x]->amount;
|
||||
|
||||
if($machineProductionsFiltered != null){
|
||||
for ($i = 0; $i < count($machineProductionsFiltered); $i++) {
|
||||
$rulonCalc = RulonAction::with('product')
|
||||
->whereHas('product', function($q)use($bag_type, $bag_size, $color){
|
||||
$q->where('type_id', $bag_type)
|
||||
->where('size_id', $bag_size)
|
||||
->where('color_id', $color);
|
||||
})
|
||||
->where("stock_id", $stock->id)
|
||||
->where("status_accountant", "accept")
|
||||
->where("status_director", "accept")
|
||||
->sum('amount');
|
||||
|
||||
$left = ($machineProductionsFiltered[$i]->produced_weight - $machineProductionsFiltered[$i]->spentSum);
|
||||
|
||||
$stockCalc += $left;
|
||||
}
|
||||
$stockCalc = $rulonCalc;
|
||||
|
||||
if($stockCalc > $orderItems[$x]->amount){
|
||||
$notCompleteCalc = 'artykmaç';
|
||||
}else{
|
||||
$notCompleteCalc = number_format(($orderItems[$x]->amount - $stockCalc),2).' kg';
|
||||
}
|
||||
}else{
|
||||
$stockCalc = 0;
|
||||
}
|
||||
// $stockCalc = number_format(($sumOfProduced - $prodMachine[0]->spentSum),2);
|
||||
|
||||
}else{
|
||||
$colorId = $orderItems[$x]->color_id;
|
||||
$bag_gram = $orderItems[$x]->bag_gram;
|
||||
|
||||
$sewerProductions = SewerModel::where("width", $orderItems[$x]->bag_width)
|
||||
->where("height", $orderItems[$x]->bag_height)
|
||||
->with("machin_production")
|
||||
->whereHas('machin_production', function ($query) use($colorId) {
|
||||
$query->where('color_id', $colorId);
|
||||
})
|
||||
->whereHas('pivot_sewer', function ($query) use($bag_gram) {
|
||||
$query->where('bag_gram', $bag_gram);
|
||||
})
|
||||
->sum("produced_bag_qty");
|
||||
$stockCalc= $sewerProductions;
|
||||
|
||||
if($stockCalc > $orderItems[$x]->amount){
|
||||
if($stockCalc > 0){
|
||||
$notCompleteCalc = 'artykmaç';
|
||||
}else{
|
||||
$notCompleteCalc = number_format(($orderItems[$x]->amount - $stockCalc),2).' sany';
|
||||
$notCompleteCalc = $stockCalc - $amountCalc;
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
$stock = Stock::where("type", 'bag')->first();
|
||||
|
||||
$bag_type = $orderItems[$x]->type_id;
|
||||
$bag_width = $orderItems[$x]->bag_width;
|
||||
$bag_height = $orderItems[$x]->bag_height;
|
||||
$color = $orderItems[$x]->color_id;
|
||||
$bag_gram = $orderItems[$x]->bag_gram;
|
||||
$amountCalc = $orderItems[$x]->amount;
|
||||
|
||||
$bagCalc = BagAction::with('product.rulon_action.product')
|
||||
->whereHas('product.rulon_action.product', function($q)use($bag_type, $color){
|
||||
$q->where('type_id', $bag_type)
|
||||
->where('color_id', $color);
|
||||
})
|
||||
->with('product.pivot_sewer')
|
||||
->whereHas('product.pivot_sewer', function($qq)use($bag_gram){
|
||||
$qq->where('bag_gram', $bag_gram);
|
||||
})
|
||||
->with('product')
|
||||
->whereHas('product', function($qqq)use($bag_width, $bag_height){
|
||||
$qqq->where('width', $bag_width)->where('height', $bag_height);
|
||||
})
|
||||
->where("stock_id", $stock->id)
|
||||
->where("status_accountant", "accept")
|
||||
->where("status_director", "accept")
|
||||
->sum('amount');
|
||||
|
||||
|
||||
$stockCalc = $bagCalc;
|
||||
|
||||
if($stockCalc > 0){
|
||||
$notCompleteCalc = 'artykmaç';
|
||||
}else{
|
||||
$notCompleteCalc = $stockCalc - $amountCalc;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
$editBtnPrice = '';
|
||||
|
|
@ -131,7 +145,7 @@ class OrderItem extends ComponentBase
|
|||
<td><a href="#" style="font-weight: bold;">';
|
||||
|
||||
if ($orderItems[$x]->order_item_type == 'rulon'){
|
||||
$html_data .= 'Rulon, '.$orderItems[$x]->type->name ?? "" .','. $orderItems[$x]->color->name ?? "";
|
||||
$html_data .= 'Rulon, '.($orderItems[$x]->type->name ?? "") .','. ($orderItems[$x]->color->name ?? "");
|
||||
}else{
|
||||
$html_data .= 'Halta, '. ($orderItems[$x]->color->name ?? "") .', '. (number_format($orderItems[$x]->bag_gram ?? 0, 2)) .' gr';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class BagAction extends Model
|
|||
|
||||
public $belongsTo = [
|
||||
'product' => [
|
||||
'Romanah\Gokbakja\Models\Product',
|
||||
'Romanah\Gokbakja\Models\SewerProduction',
|
||||
'key'=>'product_id'
|
||||
],
|
||||
'stock' => [
|
||||
|
|
|
|||
|
|
@ -26,9 +26,9 @@ class SewerProduction extends Model
|
|||
'Romanah\Gokbakja\Models\Employee',
|
||||
'key' => 'employee_id'
|
||||
],
|
||||
'machin_production' => [
|
||||
'Romanah\Gokbakja\Models\ProductionMachine',
|
||||
'key' => 'machine_production_id'
|
||||
'rulon_action' => [
|
||||
'Romanah\Gokbakja\Models\RulonAction',
|
||||
'key' => 'rulon_action_id'
|
||||
],
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -272,7 +272,6 @@ function onStart(){
|
|||
$("#bag_height").show();
|
||||
$("#bag_gram").show();
|
||||
|
||||
$("#rulon_type").hide();
|
||||
$("#rulon_size").hide();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,12 +8,13 @@ function onStart(){
|
|||
$stockId = $this->param("stockId");
|
||||
|
||||
$this["actions"] = Romanah\Gokbakja\Models\BagAction::select('romanah_gokbakja_bag_actions.*')
|
||||
->with(['product'])
|
||||
->with(['product.rulon_action.product.bag_type', 'product.rulon_action.product.color', 'product.pivot_sewer'])
|
||||
->where("stock_id", $stockId)
|
||||
->where("status_accountant", "accept")
|
||||
->where("status_director", "accept")
|
||||
->addSelect(DB::raw("SUM(amount) as quantity"))
|
||||
->groupBy('romanah_gokbakja_bag_actions.product_id')
|
||||
->orderBy('id', 'DESC')
|
||||
->get();
|
||||
// dd($this["actions"]);
|
||||
}
|
||||
|
|
@ -53,6 +54,9 @@ function onStart(){
|
|||
<tr>
|
||||
<th style="width: 5%;">№</th>
|
||||
<th>Dikiş Kody</th>
|
||||
<th>Halta Ölçegi</th>
|
||||
<th>Halta Gramy</th>
|
||||
<th>Ulanylan Material</th>
|
||||
<th>Hereket</th>
|
||||
<th>Mukdary (sany)</th>
|
||||
<th>Sene</th>
|
||||
|
|
@ -64,6 +68,10 @@ function onStart(){
|
|||
<tr>
|
||||
<td style="font-weight: bold;width: 5%;">{{key + 1}}</td>
|
||||
<td><a href="/sewer/new">#Dikiş{{record.product_id}}</a></td>
|
||||
<td>ini: {{record.product.width}} x boýy: {{record.product.height}}</td>
|
||||
<td>{{record.product.pivot_sewer[0].bag_gram|number_format}} gr</td>
|
||||
<td style="text-align: center;">
|
||||
<span class="badge badge-soft-primary" style="font-size: 14px;">#Rulon{{record.product.rulon_action.product.id}} - {{record.product.rulon_action.product.bag_type.name}}, {{record.product.rulon_action.product.color.name}}</span></td>
|
||||
<td style="text-align: center;">
|
||||
<span class="badge badge-soft-{% if record.type == 'inbox' %}success {% else %}danger {% endif %}" style="font-size: 14px;">{{record.type}}</span></td>
|
||||
<td style="color: #500101;font-weight: bold;">{{record.quantity|number_format}} sany</td>
|
||||
|
|
@ -76,7 +84,10 @@ function onStart(){
|
|||
<tfoot>
|
||||
<tr>
|
||||
<th style="width: 5%;">№</th>
|
||||
<th>Haryt Kody</th>
|
||||
<th>Dikiş Kody</th>
|
||||
<th>Halta Ölçegi</th>
|
||||
<th>Halta Gramy</th>
|
||||
<th>Ulanylan Material</th>
|
||||
<th>Hereket</th>
|
||||
<th>Mukdary (sany)</th>
|
||||
<th>Sene</th>
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ function onStart(){
|
|||
->where("status_director", "accept")
|
||||
->addSelect(DB::raw("SUM(amount) as quantity"))
|
||||
->groupBy('romanah_gokbakja_rulon_action.product_id')
|
||||
->orderBy('id', 'DESC')
|
||||
->get();
|
||||
// dd($this["actions"]);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue