public function run() { Equipment::create(['title' => '2012 American Augers DD-10 Directional Drill', 'description' => '100,000 pound drill rig has operators cabin with heat and A/C and wireline drive chuck, includes 8 empty rod boxes.', 'status' => 'available']); Equipment::create(['title' => '2009 Vermeer D100x120 Series II Directional Drill', 'description' => 'Unit is equipped with a 200 GPM Kerr pump, FSII drive chuck, does not include any drill rod but has 5 empty baskets.', 'status' => 'sold']); Equipment::create(['title' => '2008 Vermeer D100x120 Series II Directional Drill', 'description' => 'Used D100x120 Series II has been inspected by a certified service technician and is in good condition.', 'status' => 'sold']); //... add more starter equipment }
public function update($id, UpdateEquipmentRequest $request) { $equipment = Equipment::find($id); $equipment->update($request->all()); $equipment->warranty_expiration = $request->get('warranty_expiration') ? Carbon::createFromFormat('m/d/Y', $request->get('warranty_expiration')) : null; $equipment->save(); return redirect()->route('companies.show', $equipment->company_id)->with('successes', ['equipment updated successfully']); }
public function updateEquipment(Request $request, $id) { $equipment = Equipment::find($id); $equipment->title = $request->input('title'); $equipment->description = $request->input('description'); $equipment->status = $request->input('status'); $equipment->save(); return response()->json($equipment); }
public function searhEquipment($type, $name = '') { $equipments = Equipment::type($type); if (!empty($name)) { $equipments->name($name); } $equipmentItems = $equipments->get(); echo $equipmentItems; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Equipment::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'status_id' => $this->status_id, 'room_id' => $this->room_id, 'available' => $this->available, 'type_id' => $this->type_id]); $query->andFilterWhere(['like', 'inventory', $this->inventory])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'serial_number', $this->serial_number])->andFilterWhere(['like', 'location', $this->location]); return $dataProvider; }
/** * Run the database seeds. * * @return void */ public function run() { // DB::table('equipment')->delete(); Equipment::create(array('equipmenttype' => 'PC')); Equipment::create(array('equipmenttype' => 'NB')); Equipment::create(array('equipmenttype' => 'Mouse')); Equipment::create(array('equipmenttype' => 'Bag')); Equipment::create(array('equipmenttype' => 'Charger')); Equipment::create(array('equipmenttype' => 'Monitor')); Equipment::create(array('equipmenttype' => 'Keyboard')); }
public function getDataSet($postData, $dcTable, $facility_id, $occur_date, $properties) { $equip_group = $postData['EquipmentGroup']; $equip_type = $postData['CodeEquipmentType']; $equipment = Equipment::getTableName(); $where = ["{$equipment}.FACILITY_ID" => $facility_id]; if ($equip_group > 0) { $where["{$equipment}.EQUIPMENT_GROUP"] = $equip_group; } if ($equip_type > 0) { $where["{$equipment}.EQUIPMENT_TYPE"] = $equip_type; } // \DB::enableQueryLog(); $dataSet = Equipment::where($where)->leftJoin($dcTable, function ($join) use($equipment, $dcTable, $occur_date) { $join->on("{$equipment}.ID", '=', "{$dcTable}.EQUIPMENT_ID"); $join->where("{$dcTable}.OCCUR_DATE", '=', $occur_date); })->select("{$equipment}.ID as DT_RowId", "{$equipment}.NAME as {$dcTable}", "{$equipment}.FUEL_TYPE", "{$equipment}.GHG_REL_TYPE", "{$dcTable}.*", "{$equipment}.ID as EQUIPMENT_ID")->orderBy("{$dcTable}")->get(); // \Log::info(\DB::getQueryLog()); return ['dataSet' => $dataSet]; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Equipment::find(); $query->joinWith(['equipmentStatus', 'location.room', 'location', 'equipmentType']); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->sort->attributes['equipmentStatus'] = ['asc' => ['equipment_status.status' => SORT_ASC], 'desc' => ['equipment_status.status' => SORT_DESC]]; $dataProvider->sort->attributes['room'] = ['asc' => ['room.name' => SORT_ASC], 'desc' => ['room.name' => SORT_DESC]]; $dataProvider->sort->attributes['location'] = ['asc' => ['location.location' => SORT_ASC], 'desc' => ['location.location' => SORT_DESC]]; $dataProvider->sort->attributes['equipmentType'] = ['asc' => ['equipment_type.name' => SORT_ASC], 'desc' => ['equipment_type.name' => SORT_DESC]]; $this->load($params); if (!($this->load($params) && $this->validate())) { return $dataProvider; } /* if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } */ $query->andFilterWhere(['id' => $this->id, 'equipment.available' => $this->available]); $query->andFilterWhere(['like', 'inventory', $this->inventory])->andFilterWhere(['like', 'equipment_status.status', $this->equipmentStatus])->andFilterWhere(['like', 'room.name', $this->room])->andFilterWhere(['like', 'location.location', $this->location])->andFilterWhere(['like', 'equipment_type.name', $this->equipmentType])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'serial_number', $this->serial_number]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getEquipments() { return $this->hasMany(Equipment::className(), ['status_id' => 'id']); }
/** * @return \yii\db\ActiveQuery */ public function getEquipment() { return $this->hasOne(Equipment::className(), ['id' => 'equipment_id']); }
public function postEquipmnt(FormEquipmenteAdminRequest $request) { if (!empty($request)) { $data = $request->all(); $data['flagactive'] = $request->get('flagactive', 1); if ($request->id) { $obj = Equipment::find($request->id); $obj->update($data); } else { $obj = Equipment::create($data); } return array('msg' => 'ok', 'state' => 1, 'data' => null); } return array('msg' => 'Error al guardar el modelo', 'state' => 0, 'data' => null); }
<!--?= $form->field($model, 'equipment_id')->dropDownList( ArrayHelper::map( Equipment::find()->all(), 'id', 'inventory' ), [ 'prompt' => 'Selecciona un Número de Inventario...', ] ) ?--> <?php $inventoryData = []; if (!empty($model->location_id)) { $inventoryData = ArrayHelper::map(Equipment::find()->where(['id' => $model->equipment_id])->all(), 'id', 'nameWithInventory'); } ?> <?php echo $form->field($model, 'equipment_id')->dropDownList($inventoryData, ['prompt' => 'Selecciona un Número de Inventario...']); ?> <?php echo $form->field($model, 'purpose')->textarea(['maxlength' => 170, 'onkeyup' => 'javascript:this.value=this.value.toUpperCase();']); ?> <?php echo $form->field($model, 'start_time')->widget(TimePicker::classname(), ['options' => ['readonly' => true], 'pluginOptions' => ['minuteStep' => 1, 'showMeridian' => false, 'showSeconds' => true, 'defaultTime' => '0']])->hint('* Sólo para reservaciones.'); //VarDumper::dump($model->room); ?>
public static function getObjects() { return Equipment::all(); }
/** * Finds the Equipment model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Equipment the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Equipment::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
// alert(data); $("#incident-equipment_id").val(data).trigger("change"); })', ] ) ?--> <!--?= $form->field($model, 'equipment_id')->textInput([ 'maxlength'=>true, 'onchange' => '$.post("'.Yii::$app->urlManager->createUrl('incident/get-equipment-information?inventory=').'"+$(this).val(), function(data){ // $("#incident-equipment_id").html(data); $("#incident-equipment_id").val(data); })', ]) ?--> <?php echo $form->field($model, 'equipment_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(Equipment::find()->all(), 'id', 'inventory'), 'options' => ['placeholder' => 'Ingresa el número de inventario...', 'onchange' => '$.post("' . Yii::$app->urlManager->createUrl('incident/get-equipment-information?id=') . '"+$(this).val(), function(data){ // $("#incident-equipment_id").html(data); // $("#incident-description").html(data); var equipment = JSON.parse(data); $("#incident-room_id").val(equipment.room_id); $.post("' . Yii::$app->urlManager->createUrl('incident/list-locations?id=') . '"+$("#incident-room_id").val(), function(data){ $("#incident-location_id").html(data); $("#incident-location_id").val(equipment.location_id); $.post("' . Yii::$app->urlManager->createUrl('incident/list-equipment-types?id=') . '"+$("#incident-location_id").val(), function(data){ $("#incident-equipment_type_id").html(data); $("#incident-equipment_type_id").val(equipment.equipment_id); }) }) })'], 'pluginOptions' => ['allowClear' => true]]); ?>
public function actionShowInventory($id) { $equipments = Equipment::find()->where(['location_id' => $id])->all(); //echo "<option value=''>".Yii::t('app', 'Selecciona un Número de Inventario...')."</option>"; foreach ($equipments as $equipment) { echo "<option value='" . $equipment->id . "'>" . $equipment->nameWithInventory . "</option>"; } }
public function actionGetEquipmentInformation($id) { $equipment = Equipment::find()->where(['id' => $id])->one(); if (empty($equipment)) { throw new NotFoundHttpException('The requested page does not exist.'); } echo Json::encode(['room_id' => $equipment->location->room_id, 'location_id' => $equipment->location_id, 'equipment_id' => $equipment->id]); }