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);
 }
 /**
  * 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;
 }
 /**
  * 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;
 }
Exemple #5
0
 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);
 }
 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>";
     }
 }
Exemple #7
0
				// 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]]);
?>
	
Exemple #8
0
    <!--?= $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 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]);
 }