/**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $game = new Game();
     $game->score = $request->score;
     $series = Series::find($request->series);
     if (!$series) {
         $series = new Series();
         $series->save();
     }
     $game->series_id = $series->id;
     $game->save();
     return Redirect::route('games.index')->with('message', 'Game added');
 }
 public function store()
 {
     try {
         if (Input::get('detalleorden') && Input::get('idcliente')) {
             DB::beginTransaction();
             $serieobj = Series::where('idsucursal', '=', Input::get('idsucursal'))->where('activa', '=', 1)->first();
             $empresa = Empresas::find(Session::get('idempresa'));
             $cliente = Clientes::find(Input::get('idcliente'));
             $registro = new Ventas();
             $registro->tipo = $serieobj->tipo;
             $registro->serie = $serieobj->serie;
             $registro->numero = $serieobj->actual;
             $registro->nitempresa = $empresa->nit;
             $registro->nitempresa = $empresa->nit;
             $registro->nitcliente = $cliente->nit;
             $registro->idcliente = $cliente->id;
             $registro->valor = Input::get('valor');
             $registro->iva = Input::get('totaliva');
             $registro->total = Input::get('total');
             $registro->idempresa = $empresa->id;
             $registro->idsucursal = Input::get('idsucursal');
             if ($registro->save()) {
                 $detalleordenver = json_decode(Input::get('detalleorden'));
                 foreach ($detalleordenver as &$productover) {
                     $detalleventa = new DetalleVentas();
                     $detalleventa->idventa = $registro->id;
                     $detalleventa->idproducto = $productover->idproducto;
                     $detalleventa->cantidad = $productover->cantidad;
                     $detalleventa->precio = $productover->precio;
                     $detalleventa->subtotal = $productover->subtotal;
                     $detalleventa->save();
                 }
                 DB::commit();
                 $respuesta['registros'] = $registro->toArray();
                 $respuesta['mensaje'] = 'Registro creado exitosamente';
                 $respuesta['resultado'] = true;
                 return $respuesta;
             } else {
                 DB::rollback();
                 $respuesta['registros'] = array();
                 $respuesta['mensaje'] = 'Error al crear el registro';
                 $respuesta['resultado'] = false;
                 return $respuesta;
             }
         } else {
             $respuesta['registros'] = array();
             $respuesta['mensaje'] = 'Todos los campos son requeridos';
             $respuesta['resultado'] = false;
             return $respuesta;
         }
     } catch (\Exception $e) {
         DB::rollback();
         $respuesta['registros'] = array();
         $respuesta['mensaje'] = 'Error general: ' . $e;
         $respuesta['resultado'] = false;
         return $respuesta;
     }
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($series_id, $season_number)
 {
     $series = Series::findOrFail($series_id);
     $season = $series->seasons()->where('number', $season_number)->first();
     if ($season == null) {
         return response()->json(['status' => false, "message" => "No matching season!"]);
     }
     return view('season.show', compact('season', 'series'));
 }
Exemple #4
0
 public function app()
 {
     // Get RB sites that are not USGS
     // (USGS now removed in DataController sitesUpdate)
     $sites = Site::where('sitecode', 'LIKE', '%RB_%')->get();
     foreach ($sites as $site) {
         $site->series = Series::where('sitecode', '=', $site->sitecode)->get();
     }
     return view('pages.rbc', compact('sites'));
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     //try{
     $series = Series::findOrFail($id);
     if (!is_null($series->artwork)) {
         $artwork = (new Collection(json_decode($series->artwork)))->first();
     }
     return view('series.show', compact('series', 'artwork'));
     // }
     //catch(\Exception $e){
     //  return redirect("/series");
     // }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $series = new Series();
     $series->label = $request->label;
     $series->save();
     $game1 = new Game();
     $game1->score = $request->game1score;
     $game1->series_id = $series->id;
     $game1->series_game_number = 1;
     $game1->save();
     $game2 = new Game();
     $game2->score = $request->game2score;
     $game2->series_id = $series->id;
     $game2->series_game_number = 2;
     $game2->save();
     $game3 = new Game();
     $game3->score = $request->game3score;
     $game3->series_id = $series->id;
     $game3->series_game_number = 3;
     $game3->save();
     return Redirect::route('series.index')->with('message', 'Series added');
 }
 public function index_winning()
 {
     $lotteries = Lottery::all();
     $series = Series::all();
     $_results = Result::where(array('date' => date('Y-m-d')))->get();
     $results_multi = array();
     foreach ($_results as $result) {
         if (empty($results_multi["{$result->lottery_id}"])) {
             $results_multi["{$result->lottery_id}"] = array();
         }
         $results_multi["{$result->lottery_id}"]["{$result->series_id}"] = $result->winning_number;
     }
     $is_admin = true;
     return view('lotteries.winning', compact('lotteries', 'series', 'results_multi', 'is_admin'));
 }
Exemple #8
0
 public function postEdit(Request $request)
 {
     $this->validate($request, ['id' => 'required|numeric|exists:series', 'name' => "required|unique:series,name,{$request->input('id')},id|max:255", 'characters' => 'array', 'characters.*' => 'string']);
     $series = Series::find($request->input('id'));
     $series->name = $request->input('name');
     $series->save();
     if (!empty($request->input('characters'))) {
         Series_Characters::where("series_id", '=', $series->id)->whereNotIn("name", $request->input('characters'))->delete();
         foreach ($request->input('characters') as $c) {
             $character = Series_Characters::where("series_id", '=', $series->id)->where("name", '=', $c)->first();
             if (empty($character)) {
                 //As of now if the character exists, there is nothing to update. This may change over time
                 $character = new Series_Characters();
                 $character->series_id = $series->id;
                 $character->name = $c;
                 $character->save();
             }
         }
     }
     return redirect()->action('SeriesController@getList');
 }
 public function index()
 {
     /* Get data for timeline */
     $eventDates = \App\Event::select('timelineDate')->distinct()->get()->pluck('timelineDate')->toArray();
     $mediaDates = \App\Media::select('timelineDate')->distinct()->get()->pluck('timelineDate')->toArray();
     $dates = array_unique(array_merge($eventDates, $mediaDates), SORT_REGULAR);
     usort($dates, array('\\App\\Http\\Controllers\\TimelineController', 'dateCompare'));
     $media = array();
     $events = array();
     foreach ($dates as $date) {
         $eventsForThisDate = \App\Event::get()->where('timelineDate', $date)->toArray();
         $mediaForThisDate = \App\Media::get()->where('timelineDate', $date)->toArray();
         usort($eventsForThisDate, array('\\App\\Http\\Controllers\\TimelineController', 'itemCompare'));
         usort($mediaForThisDate, array('\\App\\Http\\Controllers\\TimelineController', 'itemCompare'));
         $media[$date] = $mediaForThisDate;
         $events[$date] = $eventsForThisDate;
     }
     /* Get data for filters */
     $mediums = \App\Media::select('medium')->distinct()->get()->pluck('medium')->toArray();
     $tags = \App\EventTag::select('tag')->distinct()->get()->pluck('tag')->toArray();
     $series = \App\Series::get()->pluck('seriesAbbreviation');
     sort($mediums);
     sort($tags);
     $eventIDToTags = array();
     $eventIDs = \App\Event::get()->pluck('id');
     foreach ($eventIDs as $eventID) {
         $eventIDToTags[$eventID] = \App\EventTag::select('tag')->where('eventID', $eventID)->get()->pluck('tag')->toArray();
     }
     $seriesToCollections = array();
     foreach ($series as $thisSeries) {
         $seriesToCollections[$thisSeries] = \App\Media::select('collection')->where('series', $thisSeries)->distinct()->get()->pluck('collection')->toArray();
     }
     /* Get event-media relationships */
     $eventMediaPairs = \App\EventMedia::get(array('eventID', 'mediaID'))->toArray();
     return view('timeline')->with(['seriesToCollections' => $seriesToCollections, 'eventMediaPairs' => $eventMediaPairs, 'eventIDToTags' => $eventIDToTags, 'mediums' => $mediums, 'events' => $events, 'dates' => $dates, 'media' => $media, 'tags' => $tags]);
 }
 public function delete($id)
 {
     \App\Media::where('id', $id)->delete();
     \App\EventMedia::where('mediaID', $id)->delete();
     \App\Series::leftJoin('media', 'series.seriesAbbreviation', '=', 'media.series')->where('media.series', NULL)->delete();
     return redirect('/');
 }
Exemple #11
0
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
use App\Client;
use App\Series;
Route::get('/', ['middleware' => 'auth', function () {
    return redirect('/dashboard');
}]);
Route::get('/dashboard', ['middleware' => 'auth', function () {
    $clients = Client::orderBy('name', 'ASC')->get();
    $series = Series::all();
    return view('dashboard', compact('clients', 'series'));
}]);
Route::resource('client', 'ClientController');
Route::resource('series', 'SeriesController');
/*
 * TODO: Add user roles and enable admins to register new users
 */
Route::get('/auth/register', function () {
    return 'Registering new users is not allowed.';
});
Route::controllers(['auth' => 'Auth\\AuthController', 'password' => 'Auth\\PasswordController']);
Route::get('/bar', 'ClientController@checkAccess');
 public function destroy($id)
 {
     try {
         DB::beginTransaction();
         if (Series::destroy($id)) {
             DB::commit();
             $respuesta['registros'] = array();
             $respuesta['mensaje'] = 'Registro eliminado correctamente';
             $respuesta['resultado'] = true;
             return $respuesta;
         } else {
             DB::rollback();
             $respuesta['registros'] = array();
             $respuesta['mensaje'] = 'Error al tratar de eliminar el registro';
             $respuesta['resultado'] = false;
             return $respuesta;
         }
     } catch (\Exception $e) {
         $respuesta['registros'] = array();
         $respuesta['mensaje'] = 'Error general: ' . $e;
         $respuesta['resultado'] = false;
         return $respuesta;
     }
 }
 public function showresult($date = '')
 {
     if (empty($date)) {
         $date = date_create('now');
     } else {
         $date = date_create_from_format('Y-m-d', $date);
     }
     $date->setTime(0, 0, 0);
     $today_date = date_create('now')->setTime(0, 0, 0);
     //block future date results
     if ($date > $today_date) {
         $datestr = $date->format('Y-m-d');
         $error = 'Future date, Result not declared yet';
         return view('results', compact('error', 'datestr'));
     }
     $datestr = $date->format('Y-m-d');
     $current_time = intval(date('Hi'));
     $_results = Result::with('lottery')->with('series')->where("date", '=', $date)->orderBy('lottery_id')->orderBy('series_id')->get();
     // dd($results[0]);
     $results = array();
     $time = date("");
     if (count($_results) > 0) {
         foreach ($_results as $_result) {
             if ($date == $today_date && intval($_result->lottery->draw_time) > $current_time) {
                 continue;
             }
             if (empty($results["{$_result->lottery->draw_time}"])) {
                 $results["{$_result->lottery->draw_time}"] = array();
             }
             $results["{$_result->lottery->draw_time}"]["{$_result->series->code}"] = $_result->winning_number;
         }
     }
     $series = Series::all();
     return view('results', compact('results', 'series', 'datestr'));
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($series_id)
 {
     $series = Series::find($series_id);
     $products = Product::where('series_id', $series_id)->orderBy('id', 'asc')->get();
     return view('seriesProducts', compact('products', 'series'));
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id, Request $request)
 {
     $client = Client::findOrFail($id);
     $series = Series::lists('code', 'id');
     return view('clients.edit', compact('client', 'series'));
 }
Exemple #16
0
 public function dataUpdate($sitecode, $variablecode, $silent = false)
 {
     error_reporting(E_ALL);
     ini_set('display_errors', 1);
     $filename = "{$sitecode}.{$variablecode}.json";
     $filepath = storage_path("data/{$filename}");
     // Get basic URL
     $where = ['sitecode' => $sitecode, 'variablecode' => $variablecode];
     $series = Series::where($where)->first();
     if (is_null($series)) {
         return;
     }
     $getdataURL = $series->getdataurl;
     // Parse the URL
     $parsedURL = parse_url($getdataURL);
     // Parse the query portion of the url
     parse_str($parsedURL['query'], $query);
     // startDate: the most recent timestamp+1 or empty
     $lastline = $this->lastJSONArray($filepath);
     $lastTimestamp = 0;
     if ($lastline != '') {
         $json = json_decode(trim($lastline, ','));
         $lastTimestamp = Carbon::createFromTimeStamp($json[0], "MST");
         // Account for 7 hour offset + 1 second so we don't get this record again
         $lastTimestamp->addSecond();
         $query['startDate'] = $lastTimestamp->format('Y-m-d\\TH:i:s');
         $trimcomma = false;
     } else {
         // This is an empty file. Plan to remove leading comma.
         $this->tepln(function () {
             return "File is empty";
         }, $silent);
         $trimcomma = true;
     }
     /*
     	    // endDate: now
     		$query['endDate'] = Carbon::now()->setTimezone('UTC')->format('Y-m-dTh:i:s');
     */
     // Rebuild the URL
     $parsedURL['query'] = http_build_query($query);
     $url = $parsedURL['scheme'] . "://" . $parsedURL['host'] . $parsedURL['path'] . "?" . $parsedURL['query'];
     // Get the XML
     $this->tepln(function () use(&$xml, $url, $query) {
         $xml = simplexml_load_file($url);
         return "downloaded XML with " . count($xml->timeSeries->values->value) . " values from '" . $query['startDate'] . "' until now";
     }, $silent);
     // Process XML
     $newdatastring = "";
     $startDate = $query['startDate'];
     $this->tepln(function () use(&$newdatastring, $xml, $lastTimestamp) {
         // Bad data looks like
         $noValue = $xml->timeSeries->variable->noDataValue;
         // Iterate through all data, ignoring bad values
         foreach ($xml->timeSeries->values->value as $value) {
             // Only add 'valid' values
             if ((string) $value != $noValue) {
                 $time = $value->attributes()->dateTimeUTC;
                 $time = Carbon::parse($time)->timestamp;
                 $value = (string) $value;
                 $newdatastring .= ",[{$time},{$value}]";
             }
         }
         return "processed new values";
     }, $silent);
     // Save processed data
     $this->tepln(function () use($filepath, $newdatastring, $trimcomma) {
         if ($trimcomma) {
             $newdatastring = trim($newdatastring, ',');
         }
         file_put_contents($filepath, $newdatastring, FILE_APPEND | LOCK_EX);
         return 'appended to existing data file';
     }, $silent);
     // Redirect
     //return redirect()->back();
     return;
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $series = Series::findOrFail($id);
     $series->delete();
 }