public function _index() { $fo_group = $this->getFoGroup(); $code_flow_phase = CodeFlowPhase::all(['ID', 'NAME']); $code_alloc_type = CodeAllocType::all(['ID', 'NAME']); $loProductionUnit = LoProductionUnit::all(['ID', 'NAME']); return view('front.formula', ['fo_group' => $fo_group, 'code_flow_phase' => $code_flow_phase, 'code_alloc_type' => $code_alloc_type, 'loProductionUnit' => $loProductionUnit]); }
public function CodeFlowPhase() { $EuPhaseConfig = EuPhaseConfig::getTableName(); $code_flow_phase = CodeFlowPhase::getTableName(); $eu_id = $this->ID; $result = CodeFlowPhase::whereHas("EuPhaseConfig", function ($query) use($EuPhaseConfig, $eu_id) { $query->where("{$EuPhaseConfig}.EU_ID", $eu_id); })->get(["{$code_flow_phase}.ID", "{$code_flow_phase}.NAME"]); return $result; }
public function _indexDiagram() { $codeFlowPhase = CodeFlowPhase::all(['ID', 'NAME']); $loProductionUnit = LoProductionUnit::all(['ID', 'NAME']); $loArea = LoArea::where(['PRODUCTION_UNIT_ID' => $loProductionUnit[0]->ID])->get(['ID', 'NAME']); $facility = Facility::where(['AREA_ID' => $loArea[0]->ID])->get(['ID', 'NAME']); $intObjectType = IntObjectType::where(['DISPLAY_TYPE' => 1])->get(['CODE', 'NAME']); $tmp = ucwords($intObjectType[0]->NAME); $mode = 'App\\Models\\' . str_replace(' ', '', $tmp); $type = $mode::where(['FACILITY_ID' => $facility[0]->ID])->get(['ID', 'NAME']); return view('front.diagram', ['codeFlowPhase' => $codeFlowPhase, 'loProductionUnit' => $loProductionUnit, 'loArea' => $loArea, 'facility' => $facility, 'intObjectType' => $intObjectType, 'type' => $type]); }
public function getDataSet($postData, $dcTable, $facility_id, $occur_date, $properties) { $eu_group_id = $postData['EnergyUnitGroup']; $record_freq = $postData['CodeReadingFrequency']; $phase_type = $postData['CodeFlowPhase']; $event_type = $postData['CodeEventType']; $alloc_type = array_key_exists('CodeAllocType', $postData) ? $postData['CodeAllocType'] : 0; $eu = EnergyUnit::getTableName(); $codeFlowPhase = CodeFlowPhase::getTableName(); $codeStatus = CodeStatus::getTableName(); $euPhaseConfig = EuPhaseConfig::getTableName(); $codeEventType = CodeEventType::getTableName(); $euWheres = ['FACILITY_ID' => $facility_id, 'FDC_DISPLAY' => 1]; if ($record_freq > 0) { $euWheres["{$eu}.DATA_FREQ"] = $record_freq; } if ($eu_group_id > 0) { $euWheres["{$eu}.EU_GROUP_ID"] = $eu_group_id; } // else $euWheres["$eu.EU_GROUP_ID"]= null; // \DB::enableQueryLog(); $dataSet = EnergyUnit::join($codeStatus, 'STATUS', '=', "{$codeStatus}.ID")->join($euPhaseConfig, function ($query) use($eu, $euPhaseConfig, $phase_type, $event_type) { $query->on("{$euPhaseConfig}.EU_ID", '=', "{$eu}.ID"); if ($phase_type > 0) { $query->where("{$euPhaseConfig}.FLOW_PHASE", '=', $phase_type); } if ($event_type > 0) { $query->where("{$euPhaseConfig}.EVENT_TYPE", '=', $event_type); } //TODO note chu y active co the se dung // $query->with('CodeFlowPhase'); // $query->select('FLOW_PHASE as EU_FLOW_PHASE'); })->join($codeFlowPhase, "{$euPhaseConfig}.FLOW_PHASE", '=', "{$codeFlowPhase}.ID")->join($codeEventType, "{$euPhaseConfig}.EVENT_TYPE", '=', "{$codeEventType}.ID")->where($euWheres)->whereDate('EFFECTIVE_DATE', '<=', $occur_date)->leftJoin($dcTable, function ($join) use($eu, $dcTable, $occur_date, $alloc_type, $euPhaseConfig) { //TODO add table name $join->on("{$eu}.ID", '=', "{$dcTable}.EU_ID")->on("{$dcTable}.FLOW_PHASE", '=', "{$euPhaseConfig}.FLOW_PHASE")->on("{$dcTable}.EVENT_TYPE", '=', "{$euPhaseConfig}.EVENT_TYPE")->where("{$dcTable}.OCCUR_DATE", '=', $occur_date); $energyUnitDataAlloc = EnergyUnitDataAlloc::getTableName(); $energyUnitCompDataAlloc = EnergyUnitCompDataAlloc::getTableName(); if ($alloc_type > 0 && ($dcTable == $energyUnitDataAlloc || $dcTable == $energyUnitCompDataAlloc)) { $join->where("{$dcTable}.ALLOC_TYPE", '=', $alloc_type); } })->select("{$eu}.name as {$dcTable}", "{$euPhaseConfig}.ID as DT_RowId", "{$codeFlowPhase}.name as PHASE_NAME", "{$codeEventType}.name as TYPE_NAME", "{$euPhaseConfig}.EVENT_TYPE as " . config("constants.eventType"), "{$eu}.ID as " . config("constants.euId"), "{$euPhaseConfig}.FLOW_PHASE as EU_FLOW_PHASE", "{$codeStatus}.NAME as STATUS_NAME", "{$codeFlowPhase}.CODE as PHASE_CODE", "{$codeEventType}.CODE as TYPE_CODE", "{$dcTable}.*")->orderBy($dcTable)->orderBy('EU_FLOW_PHASE')->get(); // \Log::info(\DB::getQueryLog()); return ['dataSet' => $dataSet]; }
public function getDataSet($postData, $dcTable, $facility_id, $occur_date, $properties) { $record_freq = $postData['CodeReadingFrequency']; $phase_type = $postData['CodeFlowPhase']; $flow = Flow::getTableName(); $codeFlowPhase = CodeFlowPhase::getTableName(); $where = ['FACILITY_ID' => $facility_id, 'FDC_DISPLAY' => 1]; if ($record_freq > 0) { $where["{$flow}.RECORD_FREQUENCY"] = $record_freq; } if ($phase_type > 0) { $where['PHASE_ID'] = $phase_type; } // \DB::enableQueryLog(); $dataSet = Flow::join($codeFlowPhase, 'PHASE_ID', '=', "{$codeFlowPhase}.ID")->where($where)->whereDate('EFFECTIVE_DATE', '<=', $occur_date)->leftJoin($dcTable, function ($join) use($flow, $dcTable, $occur_date) { $join->on("{$flow}.ID", '=', "{$dcTable}.flow_id"); $join->where('OCCUR_DATE', '=', $occur_date); })->select("{$flow}.name as {$dcTable}", "{$flow}.ID as DT_RowId", "{$flow}.ID as " . config("constants.flowId"), "{$flow}.phase_id as FL_FLOW_PHASE", "{$codeFlowPhase}.name as PHASE_NAME", "{$codeFlowPhase}.CODE as PHASE_CODE", "{$dcTable}.*")->orderBy($dcTable)->orderBy('FL_FLOW_PHASE')->get(); // \Log::info(\DB::getQueryLog()); $dswk = $dataSet->keyBy('DT_RowId'); $objectIds = $dswk->keys(); return ['dataSet' => $dataSet, 'objectIds' => $objectIds]; }
public function getrunnerslist(Request $request) { $data = $request->all(); $alloc_runner = AllocRunner::getTableName(); $code_alloc_value_type = CodeAllocValueType::getTableName(); $code_alloc_type = CodeAllocType::getTableName(); $code_flow_phase = CodeFlowPhase::getTableName(); $result = DB::table($alloc_runner . ' AS a')->leftjoin($code_alloc_value_type . ' AS t', 'a.theor_value_type', '=', 't.ID')->leftjoin($code_alloc_type . ' AS b', 'a.alloc_type', '=', 'b.ID')->leftjoin($code_flow_phase . ' AS c', 'a.theor_phase', '=', 'c.ID')->where(['a.JOB_ID' => $data['job_id']])->orderBy('a.ORDER')->select('a.*', 't.NAME AS THEOR_VALUE_TYPE_NAME', 'b.NAME AS ALLOC_TYPE_NAME', 'c.NAME AS THEOR_PHASE_NAME')->get(); $i = 0; $str = ""; $runner_options = ""; foreach ($result as $row) { $runner_options .= "<option value='{$row->ID}'>{$row->NAME}</option>"; $allocrunnerobjects = AllocRunnerObjects::where(['RUNNER_ID' => $row->ID])->get(); if (count($allocrunnerobjects) > 0) { $o_in = ""; $o_out = ""; $o_in_x = ""; $o_out_x = ""; $count_in = 0; $count_out = 0; $s = []; foreach ($allocrunnerobjects as $ro) { $vname = ''; if ($ro->OBJECT_TYPE == 1) { $f = Flow::where(['ID' => $ro->OBJECT_ID])->select('NAME')->first(); $vname = $f->NAME; } elseif ($ro->OBJECT_TYPE == 2) { $f = EnergyUnit::where(['ID' => $ro->OBJECT_ID])->select('NAME')->first(); $vname = $f->NAME; } $ro['OBJECT_NAME'] = $vname; if ($ro->DIRECTION == 1) { $o_in .= "<span id='" . $ro->ID . "' o_type='" . $ro->OBJECT_TYPE . "' o_id='" . $ro->OBJECT_ID . "' minus='.{$ro->MINUS}.' style='display:block'>" . ($ro->MINUS == 1 ? '<font color="red">->- </font>' : '') . $ro->OBJECT_NAME . "</span>"; if ($count_in == 3) { $o_in_x = "<span id='Q_I_{$row->ID}'>{$o_in_x}" . "<br>... <span style='cursor:pointer;color:blue;text-decoration: underline;font-size:8pt' onclick='\$(\"#Qobjectfrom_{$row->ID}\").show();\$(\"#Q_I_{$row->ID}\").hide();'>Show all {objects}</span></span>"; } else { if ($count_in < 3) { $o_in_x .= ($o_in_x ? "<br>" : "") . $ro->OBJECT_NAME; } } $count_in++; } else { $o_out .= "<span id='" . $ro->ID . "' o_type='" . $ro->OBJECT_TYPE . "' o_id='" . $ro->OBJECT_ID . "' fixed='" . $ro->FIXED . "' style='display:block;'>" . $ro->OBJECT_NAME . " " . ($ro->FIXED == 1 ? '<font color="#609CB9">->fixed</font>' : '') . "</span>"; if ($count_out == 3) { $o_out_x = "<span id='Q_O_{$row->ID}'>{$o_out_x}" . "<br>... <span style='cursor:pointer;color:blue;text-decoration: underline;font-size:8pt' onclick='\$(\"#Qobjectto_{$row->ID}\").show();\$(\"#Q_O_{$row->ID}\").hide();'>Show all {objects}</span></span>"; } else { if ($count_out < 3) { $o_out_x .= ($o_out_x ? "<br>" : "") . $ro->OBJECT_NAME; } } $count_out++; } } $i++; if ($i % 2 == 0) { $bgcolor = "#eeeeee"; } else { $bgcolor = "#f8f8f8"; } $str .= "<tr bgcolor='{$bgcolor}'>"; $str .= "<td style=\"cursor:pointer\" onclick=\"\"><span id='Qorder_" . $row->ID . "'>{$row->ORDER}</span></td>"; $str .= "<td><span id='Qrunner_name_" . $row->ID . "'>{$row->NAME}</span></td>"; $str .= "<td><span style='display:none' id='alloc_type_" . $row->ID . "'>{$row->ALLOC_TYPE}</span><span style='display:none' id='theor_value_type_" . $row->ID . "'>{$row->THEOR_VALUE_TYPE}</span><span style='display:none' id='theor_phase_" . $row->ID . "'>{$row->THEOR_PHASE}</span>{$row->ALLOC_TYPE_NAME}" . ($row->THEOR_PHASE_NAME ? "<br><font size=1 color=green>(Theor phase: {$row->THEOR_PHASE_NAME})</font>" : "") . ($row->THEOR_VALUE_TYPE_NAME ? "<br><font size=1 color=green>(Theor value type: {$row->THEOR_VALUE_TYPE_NAME})</font>" : "") . "</td>"; if ($count_in > 5) { $str .= "<td>" . str_replace("{objects}", "{$count_in} objects", $o_in_x) . "<span id='Qobjectfrom_" . $row->ID . "' style='display:none'>{$o_in}</span></td>"; } else { $str .= "<td><span id='Qobjectfrom_" . $row->ID . "'>{$o_in}</span></td>"; } if ($count_out > 5) { $str .= "<td>" . str_replace("{objects}", "{$count_out} objects", $o_out_x) . "<span id='Qobjectto_" . $row->ID . "' style='display:none'>{$o_out}</span></td>"; } else { $str .= "<td><span id='Qobjectto_" . $row->ID . "'>{$o_out}</span></td>"; } $str .= "<td width='170' style='font-size:8pt'> "; $str .= "<a href=\"javascript:checkRunner({$row->ID})\">Simulate</a> |"; $str .= "<a href=\"javascript:deleteRunner({$row->ID})\">Delete</a> |"; $str .= "<a href=\"javascript:editRunner({$row->ID})\">Edit</a> |"; $str .= "<a href=\"javascript:runRunner({$row->ID})\">Run</a> |"; $str .= "<a href=\"javascript:clearAllocData({$row->ID})\">Clear</a></td>"; $str .= "</tr>"; } $result = $str . "#\$%" . $runner_options; } return response()->json($result); }
public function getUoms($properties = null, $facility_id, $dcTable = null, $locked = false) { $uoms = []; $model = null; $withs = []; $i = 0; $selectData = false; $rs = []; foreach ($properties as $property) { $columnName = is_array($property) && array_key_exists('data', $property) ? $property['data'] : $property->data; switch ($columnName) { case 'PRESS_UOM': $withs[] = 'CodePressUom'; $uoms[] = ['id' => 'CodePressUom', 'targets' => $i, 'COLUMN_NAME' => 'PRESS_UOM']; break; case 'TEMP_UOM': $withs[] = 'CodeTempUom'; $uoms[] = ['id' => 'CodeTempUom', 'targets' => $i, 'COLUMN_NAME' => 'TEMP_UOM']; break; case 'FL_POWR_UOM': case 'EU_POWR_UOM': $withs[] = 'CodePowerUom'; $uoms[] = ['id' => 'CodePowerUom', 'targets' => $i, 'COLUMN_NAME' => 'FL_POWR_UOM']; break; case 'FL_ENGY_UOM': case 'EU_ENGY_UOM': $withs[] = 'CodeEnergyUom'; $uoms[] = ['id' => 'CodeEnergyUom', 'targets' => $i, 'COLUMN_NAME' => 'FL_ENGY_UOM']; break; case 'FL_MASS_UOM': case 'EU_MASS_UOM': $withs[] = 'CodeMassUom'; $uoms[] = ['id' => 'CodeMassUom', 'targets' => $i, 'COLUMN_NAME' => 'FL_MASS_UOM']; break; case 'VOL_UOM': case 'FL_VOL_UOM': case 'EU_VOL_UOM': $withs[] = 'CodeVolUom'; $uoms[] = ['id' => 'CodeVolUom', 'targets' => $i, 'COLUMN_NAME' => 'FL_VOL_UOM']; break; case 'EU_STATUS': $selectData = ['id' => 'EuStatus', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = collect([(object) ['ID' => -1, 'NAME' => '(Auto)'], (object) ['ID' => 1, 'NAME' => 'Online'], (object) ['ID' => 0, 'NAME' => 'Offline']]); $rs[] = $selectData; break; case 'ALLOC_TYPE': $selectData = ['id' => 'CodeAllocType', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = CodeAllocType::all(); $rs[] = $selectData; break; case 'TEST_METHOD': $selectData = ['id' => 'CodeTestingMethod', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = CodeTestingMethod::all(); $rs[] = $selectData; break; case 'TEST_USAGE': $selectData = ['id' => 'CodeTestingUsage', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = CodeTestingUsage::all(); $rs[] = $selectData; break; case 'EVENT_TYPE': $selectData = ['id' => 'CodeEventType', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = CodeEventType::all(); $rs[] = $selectData; break; case 'SRC_TYPE': $selectData = ['id' => 'CodeQltySrcType', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = CodeQltySrcType::all(); $rs[] = $selectData; break; case 'PRODUCT_TYPE': $selectData = ['id' => 'CodeProductType', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = CodeProductType::all(); $rs[] = $selectData; break; case 'DEFER_REASON': $selectData = ['id' => 'CodeDeferReason', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = CodeDeferReason::all(); $rs[] = $selectData; break; case 'DEFER_STATUS': $selectData = ['id' => 'CodeDeferStatus', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = CodeDeferStatus::all(); $rs[] = $selectData; break; case 'CODE1': $selectData = ['id' => 'CodeDeferCode1', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = CodeDeferCode1::all(); $rs[] = $selectData; break; case 'DEFER_CATEGORY': $selectData = ['id' => 'CodeDeferCategory', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = CodeDeferCategory::all(); $rs[] = $selectData; break; case 'DEFER_GROUP_TYPE': $selectData = ['id' => 'CodeDeferGroupType', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = CodeDeferGroupType::all(); $rs[] = $selectData; break; case 'TICKET_TYPE': $selectData = ['id' => 'CodeTicketType', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = CodeTicketType::all(); $rs[] = $selectData; break; case 'TARGET_TANK': $selectData = ['id' => 'Tank', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = Tank::where('FACILITY_ID', $facility_id)->get(); $rs[] = $selectData; break; case 'CARRIER_ID': case 'PD_TRANSIT_CARRIER_ID': case 'CONNECTING_CARRIER': if ($dcTable == \App\Models\PdCargoNomination::getTableName() && !$locked) { break; } $selectData = ['id' => 'PdTransitCarrier', 'targets' => $i, 'COLUMN_NAME' => $columnName]; if ($dcTable == \App\Models\RunTicketFdcValue::getTableName() || $dcTable == \App\Models\RunTicketValue::getTableName()) { $selectData['data'] = PdTransitCarrier::where('TRANSIT_TYPE', 1)->get(); } else { $selectData['data'] = PdTransitCarrier::all(); } $rs[] = $selectData; break; case 'BA_ID': if ($dcTable != Personnel::getTableName()) { $selectData = ['id' => 'BaAddress', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = BaAddress::all(); $rs[] = $selectData; } break; case 'SEVERITY_ID': $selectData = ['id' => 'CodeSafetySeverity', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = CodeSafetySeverity::where('ACTIVE', 1)->orderBy('ORDER')->orderBy('ID')->get(); $rs[] = $selectData; break; case 'STATUS': $selectData = ['id' => 'CodeCommentStatus', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = CodeCommentStatus::where('ACTIVE', 1)->orderBy('ORDER')->orderBy('ID')->get(); $rs[] = $selectData; break; case 'OFFLINE_REASON_CODE': $selectData = ['id' => 'CodeEqpOfflineReason', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = CodeEqpOfflineReason::where('ACTIVE', 1)->orderBy('ORDER')->orderBy('ID')->get(); $rs[] = $selectData; break; case 'EQP_FUEL_CONS_TYPE': $selectData = ['id' => 'CodeEqpFuelConsType', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = CodeEqpFuelConsType::where('ACTIVE', 1)->orderBy('ORDER')->orderBy('ID')->get(); $rs[] = $selectData; break; case 'EQP_GHG_REL_TYPE': $selectData = ['id' => 'CodeEqpGhgRelType', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = CodeEqpGhgRelType::where('ACTIVE', 1)->orderBy('ORDER')->orderBy('ID')->get(); $rs[] = $selectData; break; case 'EQP_GHG_UOM': case 'EQP_CONS_UOM': $selectData = ['id' => 'CodeVolUom', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = CodeVolUom::all(); $rs[] = $selectData; break; case 'TYPE': $selectData = ['id' => 'CodePersonnelType', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = CodePersonnelType::all(); $rs[] = $selectData; break; case 'TITLE': $selectData = ['id' => 'CodePersonnelTitle', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = CodePersonnelTitle::all(); $rs[] = $selectData; break; case 'SYSTEM_ID': $selectData = ['id' => 'IntSystem', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = IntSystem::all(); $rs[] = $selectData; break; case 'FREQUENCY': $selectData = ['id' => 'CodeReadingFrequency', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = CodeReadingFrequency::all(); $rs[] = $selectData; break; case 'ALLOW_OVERRIDE': $selectData = ['id' => 'CodeBoolean', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = CodeBoolean::all(); $rs[] = $selectData; break; case 'FLOW_PHASE': $selectData = ['id' => 'CodeFlowPhase', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = CodeFlowPhase::all(); $rs[] = $selectData; break; case 'REQUEST_UOM': case 'NOMINATION_UOM': case 'REQUEST_QTY_UOM': case 'SCHEDULE_UOM': case 'ATTRIBUTE_UOM': case 'LOAD_UOM': case 'QTY_UOM': case 'ITEM_UOM': $selectData = ['id' => 'PdCodeMeasUom', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = \App\Models\PdCodeMeasUom::all(); $rs[] = $selectData; break; case 'PRIORITY': $selectData = ['id' => 'PdCodeCargoPriority', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = \App\Models\PdCodeCargoPriority::all(); $rs[] = $selectData; break; case 'QUANTITY_TYPE': $selectData = ['id' => 'PdCodeCargoQtyType', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = \App\Models\PdCodeCargoQtyType::all(); $rs[] = $selectData; break; case 'LIFTING_ACCT': case 'LIFTING_ACCOUNT': $selectData = ['id' => 'PdLiftingAccount', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = \App\Models\PdLiftingAccount::all(); $rs[] = $selectData; break; case 'CONTRACT_ID': $selectData = ['id' => 'PdContract', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = \App\Models\PdContract::all(); $rs[] = $selectData; break; case 'STORAGE_ID': $selectData = ['id' => 'Storage', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = \App\Models\Storage::where('FACILITY_ID', $facility_id)->get(); $rs[] = $selectData; break; case 'REQUEST_TOLERANCE': $selectData = ['id' => 'PdCodeQtyAdj', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = \App\Models\PdCodeQtyAdj::all(); $rs[] = $selectData; break; case 'ADJUSTABLE_TIME': case 'NOMINATION_ADJ_TIME': $selectData = ['id' => 'PdCodeTimeAdj', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = \App\Models\PdCodeTimeAdj::all(); $rs[] = $selectData; break; case 'INCOTERM': $selectData = ['id' => 'PdCodeIncoterm', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = \App\Models\PdCodeIncoterm::all(); $rs[] = $selectData; break; case 'TRANSIT_TYPE': $selectData = ['id' => 'PdCodeTransitType', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = \App\Models\PdCodeTransitType::all(); $rs[] = $selectData; break; /* case 'ACTIVITY_NAME' : $selectData = ['id'=>'ID','targets'=>$i,'COLUMN_NAME'=>'NAME']; $sql = ""; $sql .= " SELECT ID, NAME FROM pd_code_load_activity a where exists (select 1 from PD_CARGO_LOAD b join TERMINAL_TIMESHEET_DATA c ON ( b.ID = c.PARENT_ID AND c.IS_LOAD = 1 ) where c.ACTIVITY_ID = a.ID)"; $sql .= " union all"; $sql .= " SELECT ID, NAME FROM pd_code_load_activity a where exists (select 1 from PD_CARGO_UNLOAD b join TERMINAL_TIMESHEET_DATA c ON ( b.ID = c.PARENT_ID AND c.IS_LOAD = 1 ) where c.ACTIVITY_ID = a.ID)"; $tmp = \DB::select($sql); $selectData['data'] = $tmp; $rs[] = $selectData; break; */ /* case 'ACTIVITY_NAME' : $selectData = ['id'=>'ID','targets'=>$i,'COLUMN_NAME'=>'NAME']; $sql = ""; $sql .= " SELECT ID, NAME FROM pd_code_load_activity a where exists (select 1 from PD_CARGO_LOAD b join TERMINAL_TIMESHEET_DATA c ON ( b.ID = c.PARENT_ID AND c.IS_LOAD = 1 ) where c.ACTIVITY_ID = a.ID)"; $sql .= " union all"; $sql .= " SELECT ID, NAME FROM pd_code_load_activity a where exists (select 1 from PD_CARGO_UNLOAD b join TERMINAL_TIMESHEET_DATA c ON ( b.ID = c.PARENT_ID AND c.IS_LOAD = 1 ) where c.ACTIVITY_ID = a.ID)"; $tmp = \DB::select($sql); $selectData['data'] = $tmp; $rs[] = $selectData; break; */ case 'CARGO_ID': $selectData = ['id' => 'PdCargo', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = \App\Models\PdCargo::all(); $rs[] = $selectData; break; case 'BERTH_ID': $selectData = ['id' => 'PdBerth', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = \App\Models\PdBerth::all(); $rs[] = $selectData; break; case 'CARGO_STATUS': $selectData = ['id' => 'PdCodeCargoStatus', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = \App\Models\PdCodeCargoStatus::all(); $rs[] = $selectData; break; case 'CONTRACT_TYPE': case 'CONTACT_TYPE': $selectData = ['id' => 'PdCodeContractType', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = \App\Models\PdCodeContractType::all(); $rs[] = $selectData; break; case 'CONTRACT_PERIOD': $selectData = ['id' => 'PdCodeContractPeriod', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = \App\Models\PdCodeContractPeriod::all(); $rs[] = $selectData; break; case 'CONTRACT_EXPENDITURE': $selectData = ['id' => 'PdContractExpenditure', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = \App\Models\PdContractExpenditure::all(); $rs[] = $selectData; break; case 'CONTRACT_TEMPLATE': $selectData = ['id' => 'PdContractTemplate', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = \App\Models\PdContractTemplate::all(); $rs[] = $selectData; break; case 'DEMURRAGE_EBO': $selectData = ['id' => 'PdCodeDemurrageEbo', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = \App\Models\PdCodeDemurrageEbo::all(); $rs[] = $selectData; break; case 'SURVEYOR_BA_ID': $selectData = ['id' => 'BaAddress', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = \App\Models\BaAddress::where('SOURCE', 15)->get(); $rs[] = $selectData; break; case 'WITNESS_BA_ID1': case 'WITNESS_BA_ID2': $selectData = ['id' => 'BaAddress', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = \App\Models\BaAddress::where('SOURCE', 4)->get(); $rs[] = $selectData; break; case 'ACTIVITY_ID': case 'ACTIVITY_NAME': $selectData = ['id' => 'PdCodeLoadActivity', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = \App\Models\PdCodeLoadActivity::all(); $rs[] = $selectData; break; case 'VOYAGE_ID': $selectData = ['id' => 'PdVoyage', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = \App\Models\PdVoyage::all(); $rs[] = $selectData; break; case 'DEPART_PORT': case 'NEXT_DESTINATION_PORT': case 'PORT_ID': case 'ULLAGE_PORT': case 'ORIGIN_PORT': case 'DESTINATION_PORT': $selectData = ['id' => 'PdPort', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = \App\Models\PdPort::all(); $rs[] = $selectData; break; case 'FLOW_ID': $selectData = ['id' => 'Flow', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = \App\Models\Flow::where("FACILITY_ID", '=', $facility_id)->get(); $rs[] = $selectData; break; case 'MEASURED_ITEM': $selectData = ['id' => 'PdCodeMeasItem', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = \App\Models\PdCodeMeasItem::all(); $rs[] = $selectData; break; case 'FORMULA_ID': $selectData = ['id' => 'Formula', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = \App\Models\Formula::where("GROUP_ID", '=', 7)->get(); $rs[] = $selectData; break; case 'PROGRAM_TYPE': $selectData = ['id' => 'PdCodeProgramType', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = \App\Models\PdCodeProgramType::all(); $rs[] = $selectData; break; case 'RUN_FREQUENCY': $selectData = ['id' => 'PdCodeRunFrequency', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = \App\Models\PdCodeRunFrequency::all(); $rs[] = $selectData; break; case 'ADJUST_CODE': $selectData = ['id' => 'PdCodeLiftAcctAdj', 'targets' => $i, 'COLUMN_NAME' => $columnName]; $selectData['data'] = \App\Models\PdCodeLiftAcctAdj::all(); $rs[] = $selectData; break; } $i++; } if (count($withs) > 0) { $model = StandardUom::with($withs)->where('ID', $facility_id)->first(); if ($model == null) { $model = Facility::with($withs)->where('ID', $facility_id)->first(); } } // \DB::enableQueryLog(); if ($model != null) { foreach ($uoms as $key => $uom) { $uom['data'] = $model->{$uom}['id']; $uoms[$key] = $uom; $rs[] = $uom; } } return $rs; // \Log::info(\DB::getQueryLog()); }
public function loadEUPhase(Request $request) { $data = $request->all(); $eu_id = $data['eu_id']; $EuPhaseConfig = EuPhaseConfig::getTableName(); $code_flow_phase = CodeFlowPhase::getTableName(); //\DB::enableQueryLog (); $tmp = DB::table($EuPhaseConfig . ' AS a')->join($code_flow_phase . ' AS b', 'a.FLOW_PHASE', '=', 'b.ID')->where(['a.EU_ID' => $eu_id])->get(['b.ID', 'b.NAME']); //\Log::info ( \DB::getQueryLog () ); return response()->json(['result' => $tmp]); }