public function destroy()
 {
     $id = Input::get('id');
     $material = Material::find($id);
     $material->delete();
     return Redirect::route('materiales.index');
 }
 public function getMaterialAccessoriesArray($id)
 {
     $results = Material::find($id);
     $allAccessories = array();
     foreach ($results->accessories as $result) {
         $allAccessories[] = $result->id;
     }
     return $allAccessories;
 }
 public function destroy($id)
 {
     $material = Material::find($id);
     if (sizeof($material->tasks) < 1) {
         $material->delete();
         return Redirect::to('/materials')->with('message', 'Registro eliminado')->with('organization', app('organization'));
     } else {
         return Redirect::to('/materials')->with('error', 'El registro ya se encuentra como gasto dentro de las actividades.');
     }
 }
 public function postDelete($id = null)
 {
     if ($id || ($id = Input::get('id'))) {
         $obj = Material::find($id);
         if (is_object($obj)) {
             $obj->delete();
         }
     }
     return Redirect::back();
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $message = Message::find($id);
     $message->fill(Input::all());
     $message->save();
     $material = Material::find(Input::get('materialid'));
     $material->status = 'ok';
     $material->save();
     return Redirect::to('/beheer');
 }
 /**
  * Show the form for editing the specified material.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $material = Material::find($id);
     return View::make('materials.edit', compact('material'));
 }
 function getMaterialByMaterialGroup($material_group_id = null)
 {
     App::import('Model', 'Inventory.Material');
     $material = new Material();
     $material_data = $material->find("list", array("fields" => array("id", "name"), 'conditions' => array('Material.material_group_id' => $material_group_id)));
     return $material_data;
 }
 public function getReservations($id)
 {
     $material = Material::find($id);
     $reservations = Material::find($id)->reservations()->orderBy('created_at', 'DESC')->get();
     //$this->reservation->getLastReservations($id);
     return View::make('materials.lastReservation', ['material' => $material, 'reservations' => $reservations]);
 }
 function get_material_list_by_material_group()
 {
     $material_group_id = $this->request->query['term'];
     App::uses("Material", "Inventory.Model");
     $material = new Material();
     $material_list = array();
     $material_list = $material->find("all", array('conditions' => array('material_group_id' => $material_group_id), 'order' => array('name' => 'asc')));
     $return_data = array();
     $index = 0;
     foreach ($material_list as $id => $val) {
         if ($val) {
             $return_data[$index]['id'] = $val['Material']['id'];
             $return_data[$index]['text'] = $val['Material']['name'];
             $return_data[$index]['detail'] = $val['Material'];
             $index++;
         }
     }
     print json_encode($return_data);
     exit;
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     if (Request::ajax()) {
         $input = Input::all();
         $this->reservation->begin = $input['start'];
         $this->reservation->end = $input['stop'];
         $materialId = $input['material_id'];
         $reservations = array();
         $this->reservation->fill($input);
         if ($this->reservation->isValid()) {
             //checken of er geen reservatie overlapt bij het hoofdarticle
             if (!$this->reservation->checkReservationCollision($this->reservation->begin, $this->reservation->end, $materialId)) {
                 if ($input['chainReservations'] != null) {
                     $allValid = true;
                     foreach ($input['chainReservations'] as $accessorieId) {
                         //checken of er geen reservatie overlapt bij de accessories
                         if ($this->reservation->checkReservationCollision($this->reservation->begin, $this->reservation->end, $accessorieId)) {
                             $allValid = false;
                             // $this->makeReservation(Input::get('users'),Input::all(),Input::get('endDate_submit'),Input::get('endHour_submit'),$accessorieId);
                         }
                         // else
                         // {
                         // 	$material = Material::find($accessorieId);
                         // 	return Redirect::back()->withInput()->with('message','De gekozen periode overlapt met een andere reservatie voor '.$material->name.' .');
                         // }
                     }
                     if (!$allValid) {
                         // return Redirect::back()->withInput()->with('message','De gekozen periode overlapt met een andere reservatie voor test .');
                         return Response::json(['errorMessage' => 'De gekozen periode overlapt met een andere reservatie voor één van de gekozen koppel accessoires'], 400);
                     } else {
                         foreach ($input['chainReservations'] as $accessorieId) {
                             $reservations[] = $this->makeReservation($input['users'], $input, $this->reservation->begin, $this->reservation->end, $accessorieId);
                         }
                     }
                 }
                 $reservations[] = $this->makeReservation($input['users'], $input, $this->reservation->begin, $this->reservation->end, $materialId);
                 return Response::json(['message' => 'Je reservatie is successvol geplaatst <br> Na het sluiten van deze popup wordt de pagina automatisch herladen.', 'reservations' => $reservations], 200);
             } else {
                 $material = Material::find($materialId);
                 return Response::json(['errorMessage' => 'De gekozen periode overlapt met een andere reservatie voor ' . $material->name . ' .'], 400);
             }
         } else {
             // return Redirect::back()->withInput()->withErrors($this->reservation->errors);
             return Response::json(['errorMessage' => 'Er waren validatie errors', 'errros' => $this->reservation->errors], 400);
         }
     } else {
         return Redirect::back();
     }
 }
Beispiel #11
0
<?php

if (!isset($_GET['id'])) {
    include "html/idxCRUD.php";
    include "lst/lstMaterial.php";
} else {
    $material = Material::find($_GET['id']);
    if ($material) {
        include "reg/regMaterial.php";
    } else {
        echo "Material inexistente!";
    }
}
include "frm/frmMaterial.php";
Beispiel #12
0
 public function post_edit()
 {
     $rules = array('id' => 'required|exists:materiales', 'clave' => 'required|max:10|alpha_dash', 'nombre' => 'required|max:30', 'stock_min' => 'numeric', 'cat_mat_id' => 'required|integer|exists:categoriamaterial,id', 'uni_mat_id' => 'required|integer|exists:unidadmaterial,id');
     $validation = Validator::make(Input::all(), $rules);
     if ($validation->fails()) {
         Messages::add('error', $validation->errors->all());
         return Redirect::to('admin/' . $this->views . '/edit')->with_input();
     } else {
         $mat = Material::find(Input::get('id'));
         $mat->clave = strtoupper(Input::get('clave'));
         $mat->nombre = strtoupper(Input::get('nombre'));
         $mat->stock_min = Input::get('stock_min');
         $mat->cat_mat_id = Input::get('cat_mat_id');
         $mat->uni_mat_id = Input::get('uni_mat_id');
         $mat->observaciones = Input::get('observaciones');
         $mat->save();
         Messages::add('success', 'Material Actualizado');
         return Redirect::to('admin/' . $this->views . '');
     }
 }
 private function getMaterialDetail($material_id)
 {
     App::import('Model', 'Inventory.Material');
     $material = new Material();
     $material_data = $material->find("first", array("conditions" => array('Material.id' => $material_id)));
     return $material_data;
 }