Пример #1
0
 public function genBLMR(Request $request)
 {
     $postData = $request->all();
     $pid = $postData['id'];
     $shipCargoBlmr = $this->getShipCargoBlmr($pid);
     $xid = $shipCargoBlmr ? $shipCargoBlmr->ID : 0;
     $results = \DB::transaction(function () use($xid, $pid) {
         $mdl = $this->modelName;
         $transportType = $mdl::getTableName();
         $shipCargoBlmr = ShipCargoBlmr::getTableName();
         if ($xid > 0) {
             // 			    			\DB::enableQueryLog();
             $values = $this->getUpdateFields($shipCargoBlmr, $transportType);
             ShipCargoBlmr::join($transportType, "{$transportType}.ID", '=', "{$shipCargoBlmr}.PARENT_ID")->where("{$shipCargoBlmr}.ID", $xid)->update($values);
             // 			   \Log::info(\DB::getQueryLog());
             return 'Success(only update exist rows)';
         } else {
             $pdVoyage = PdVoyage::getTableName();
             $storage = Storage::getTableName();
             $values = $this->getInsertFields($pid, $pdVoyage, $storage, $transportType);
             $mdl::join($pdVoyage, "{$pdVoyage}.ID", '=', "{$transportType}.VOYAGE_ID")->join($storage, "{$storage}.ID", '=', "{$pdVoyage}.STORAGE_ID")->where("{$transportType}.ID", $pid)->select($values)->chunk(10, function ($rows) {
                 ShipCargoBlmr::insert($rows->toArray());
             });
             return 'Success!';
         }
     });
     return response()->json($results);
 }
Пример #2
0
 /**
  * Get the Complete Name for the user.
  *
  * @return string
  */
 public function setPathAttribute($path)
 {
     if (!empty($path)) {
         $title = Carbon::now()->second . $path->getClientOriginalName();
         $this->attributes['path'] = $title;
         \Storage::disk('local')->put($title, \File::get($path));
     }
 }
Пример #3
0
 public function getDataSet($postData, $dcTable, $facility_id, $occur_date, $properties)
 {
     $date_end = array_key_exists('date_end', $postData) ? $postData['date_end'] : null;
     if ($date_end) {
         $date_end = \Helper::parseDate($date_end);
     }
     $mdlName = $postData[config("constants.tabTable")];
     $mdl = "App\\Models\\{$mdlName}";
     $storage = Storage::getTableName();
     $pdCargoNomination = PdCargoNomination::getTableName();
     //     	\DB::enableQueryLog();
     $query = $mdl::join($storage, "{$dcTable}.STORAGE_ID", '=', "{$storage}.ID")->leftJoin($pdCargoNomination, "{$pdCargoNomination}.CARGO_ID", '=', "{$dcTable}.ID")->where(["{$storage}.FACILITY_ID" => $facility_id])->select("{$dcTable}.ID as {$dcTable}", "{$dcTable}.ID as DT_RowId", "{$pdCargoNomination}.ID as IS_NOMINATED", "{$dcTable}.*");
     //   		    			->orderBy('EFFECTIVE_DATE')
     //   		    			->get();
     if ($date_end) {
         $query->whereDate("{$dcTable}.REQUEST_DATE", '<=', $date_end);
     }
     if ($occur_date) {
         $query->whereDate("{$dcTable}.REQUEST_DATE", '>=', $occur_date);
     }
     $dataSet = $query->get();
     //  		\Log::info(\DB::getQueryLog());
     return ['dataSet' => $dataSet];
 }
 public function down()
 {
     $this->dropTable(Config::tableName());
     $this->dropTable(Storage::tableName());
 }
Пример #5
0
 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());
 }
Пример #6
0
 public function setPictureAttribute($file)
 {
     if (is_string($file)) {
         $path = $file;
         //TODO: should we copy the picture to our storage instead?
     } elseif ($file instanceof UploadedFile) {
         //no $file->guessExtension() as this would create dups if the user uploads a pic with a different extension
         $rel_path = 'users/picture-' . $this->id;
         $stored = \Storage::put($rel_path, file_get_contents($file->getRealPath()));
         if (!$stored) {
             $this->errors()->add('picture', _('Sorry, we were unable to save your picture. Can you try again later?'));
         }
         $path = \Config::get('filesystems.root_url') . $rel_path;
     }
     if (isset($path)) {
         //FIXME: resize the picture to create a smaller avatar (what size?)
         $this->attributes['picture'] = $this->attributes['avatar'] = $path;
     }
 }
 /**
  * Возвращает ассоциативный массив:
  * ID Продукта -> [ ID Ценовой Колонки -> Цена ]
  * @return array
  * @throws \Exception
  */
 public function getProductsInOrdersPricesArr()
 {
     // Получаем все Ценовые Колонки для данной Закупки
     $pricing_grid_columns_models_arr = $this->getPricingGridColumns()->get();
     if (!count($pricing_grid_columns_models_arr)) {
         \App\Helpers\Assistant::exception("Pricing Grid Columns array is empty. PurchaseId = {$this->id}");
     }
     $pricing_grid_columns_ids_arr = [];
     // Собираем список ID всех Ценовых Колонок данной Закупки
     foreach ($pricing_grid_columns_models_arr as $pricing_grid_column_model) {
         $pricing_grid_columns_ids_arr[] = $pricing_grid_column_model->id;
     }
     // Получаем массив ID продуктов во всех заказах данной Закупки
     $all_orders_products_ids_arr = $this->getAllOrdersProductsIdsArr();
     if (empty($all_orders_products_ids_arr)) {
         return [];
     }
     \Storage::disk('local')->put('tests/all_orders_products_ids_arr.json', implode(',', $all_orders_products_ids_arr));
     \Storage::disk('local')->put('tests/pricing_grid_columns_ids_arr.json', implode(',', $pricing_grid_columns_ids_arr));
     $products_prices_mixes_arr = \DB::table('prices')->whereIn('product_id', $all_orders_products_ids_arr)->whereIn('column_id', $pricing_grid_columns_ids_arr)->select()->get();
     if (empty($products_prices_mixes_arr)) {
         \App\Helpers\Assistant::exception("Found the product without prices. PurchaseId = {$this->id}");
     }
     $products_prices_arr = [];
     foreach ($products_prices_mixes_arr as $product_price_mix) {
         $product_id = $product_price_mix->product_id;
         $column_id = $product_price_mix->column_id;
         $price = $product_price_mix->price;
         if (!array_key_exists($product_id, $products_prices_arr)) {
             $products_prices_arr[$product_id] = [];
         }
         if (!array_key_exists($column_id, $products_prices_arr[$product_id])) {
             $products_prices_arr[$product_id][$column_id] = [];
         }
         $products_prices_arr[$product_id][intval($column_id)] = doubleval($price);
     }
     return $products_prices_arr;
 }
Пример #8
0
 public static function getLink($objectName)
 {
     $result = Storage::where('object_name', $objectName)->first();
     return $result["object_link"];
 }
Пример #9
0
 public function getExtraDatasetBy($objectType, $facility_id)
 {
     $srcTypeData = null;
     if ($objectType == "PARCEL") {
         $storage = Storage::getTableName();
         $pdVoyageDetail = PdVoyageDetail::getTableName();
         $pdVoyage = PdVoyage::getTableName();
         $srcTypeData = PdVoyage::join($storage, function ($query) use($storage, $facility_id, $pdVoyage) {
             $query->on("{$pdVoyage}.STORAGE_ID", '=', "{$storage}.ID")->where("{$storage}.FACILITY_ID", '=', $facility_id);
         })->join($pdVoyageDetail, "{$pdVoyage}.ID", '=', "{$pdVoyageDetail}.VOYAGE_ID")->select("{$pdVoyageDetail}.ID", "{$pdVoyageDetail}.ID as CODE", "{$pdVoyage}.NAME as NAME", "{$pdVoyage}.ID as value", "{$pdVoyage}.NAME as text", "{$pdVoyageDetail}.PARCEL_NO as PARCEL_NO")->orderBy("{$pdVoyage}.ID")->orderBy("{$pdVoyageDetail}.PARCEL_NO")->get();
     } else {
         if ($objectType == "RESERVOIR") {
             $srcTypeData = \DB::table($objectType)->get(['ID', 'CODE', 'NAME', 'ID as value', 'NAME as text']);
         } else {
             if ($objectType) {
                 $srcTypeData = \DB::table($objectType)->where("FACILITY_ID", $facility_id)->get(['ID', 'CODE', 'NAME', 'ID as value', 'NAME as text']);
             }
         }
     }
     return $srcTypeData;
 }