/** * @before _secure, _vendor, _admin */ public function payments() { $this->seo(array("title" => "Vendor Profile", "view" => $this->getLayoutView())); $view = $this->getActionView(); $where["organization_id = ?"] = $this->organization->id; $period = RequestMethods::get("period", "total"); switch ($period) { case 'year': $year = strftime("%Y-%m-%d", strtotime('-1 year')); $where["created > ?"] = $year; break; case 'week': $week = strftime("%Y-%m-%d", strtotime('-1 year')); $where["created > ?"] = $week; break; case 'day': $day = strftime("%Y-%m-%d", strtotime('-1 day')); $where["created > ?"] = $day; break; } $centres = Centre::all(array("organization_id = ?" => $this->organization->id), array("id", "location_id")); $revenue = 0; $cash = 0; $online = 0; $appointments = Appointment::all($where); foreach ($appointments as $a) { $order = Order::first(array("id = ?" => $a->order_id), array("amount")); $revenue += $order->amount; switch ($order->mode) { case 'cash': $cash += $order->amount; break; default: $online += $order->amount; break; } } if (RequestMethods::get("action") == "invoice") { $this->paymentsInvoice($this->organization, $appointments, $revenue, $cash, $online, "show"); } $view->set("appointments", $appointments); $view->set("period", $period); $view->set("revenue", $revenue); $view->set("cash", $cash); $view->set("online", $online); $view->set("centres", $centres); }
/** * @before _secure, _vendor */ public function create() { $this->seo(array("title" => "Create runner", "view" => $this->getLayoutView())); $view = $this->getActionView(); $msg = ""; $centres = Centre::all(array("organization_id = ?" => $this->organization->id), array("id", "location_id")); $upload = function ($key) { if (isset($_FILES["image"]["name"][$key])) { $file = $_FILES["image"]; $path = APP_PATH . "/public/assets/uploads/images/"; $extension = pathinfo($file["name"][$key], PATHINFO_EXTENSION); if (!preg_match("/^(jpe?g|gif|png|bmp)\$/", $extension)) { return false; } $filename = uniqid() . ".{$extension}"; if (move_uploaded_file($file["tmp_name"][$key], $path . $filename)) { return $filename; } else { return FALSE; } } else { return false; } }; if (RequestMethods::post("phone")) { $phone = RequestMethods::post("phone"); $name = RequestMethods::post("name"); $centre_id = RequestMethods::post("centre_id"); foreach ($phone as $key => $value) { if (!empty($value)) { $exist = User::first(array("phone = ?" => $phone[$key]), array("id")); $img = $upload($key); if (!$img) { $msg = 'Not a vaild image'; } else { if ($exist) { $msg = 'Phone number already exists'; } } if (!$exist && $img) { $user = new User(array("name" => $name[$key], "email" => "", "phone" => $phone[$key], "password" => sha1(rand(100000, 9999999)), "gender" => $gender[$key], "birthday" => "", "live" => true)); $user->save(); foreach ($centre_id[$key] as $k => $v) { $runner = new Member(array("user_id" => $user->id, "organization_id" => $this->organization->id, "centre_id" => $v, "designation" => "runner", "image" => $img, "live" => true)); $runner->save(); } $msg = "Runner Created Successfully"; } else { $msg .= ", Not all were added"; } } } $view->set("message", $msg); } $locations = array(); foreach ($centres as $c) { $l = Location::first(array("id = ?" => $c->location_id), array("area_id")); $a = Area::first(array("id = ?" => $l->area_id), array("name", "id")); $data = array("id" => $c->id, "name" => $a->name); $data = ArrayMethods::toObject($data); $locations[$c->id] = $data; } $view->set("centres", $locations); }
/** * Crea un nou grup */ public function nouGrup() { if (Input::has('nom')) { $grup = new Grup(); $nom = Input::get('nom'); $nom = strip_tags($nom); $nom = trim($nom); $descripcio = Input::get('descripcio'); $descripcio = strip_tags($descripcio); $descripcio = trim($descripcio); $aula = Input::get('aula'); $aula = strip_tags($aula); $aula = trim($aula); $centre = Input::get('centre'); $validator = Validator::make(array('nombre' => $nom, 'descripción' => $descripcio, 'aula' => $aula, 'centro' => $centre), array('nombre' => array('required', 'max:60'), 'descripción' => array('max:255'), 'aula' => array('max:25'), 'centro' => array('max:150'))); if ($validator->fails()) { return Redirect::route('grup.nou')->withErrors($validator); } $grup->nom_grup = $nom; $grup->descripcio_grup = $descripcio; $grup->aula = $aula; $grup->centre_nom_centre = $centre; $grup->curs_nom_curs = '2013-2014'; $slug = $nom . uniqid(); $grup->slug_grup = $slug; $emaillog = Auth::user()->email_estudiant; $grup->estudiant_email_estudiant = $emaillog; $grup->save(); try { $estudiant = Estudiant::findOrFail($emaillog); } catch (ModelNotFoundException $e) { return Redirect::route('grups.meus'); } $estudiant->matricularEstudiant($slug); return Redirect::route('assignatures.nou', array('slug' => $slug)); } else { $centres = Centre::all(); $this->layout->title = 'Workshome - Nuevo grupo'; $this->layout->description = 'Crear nuevo grupo'; $this->layout->content = View::make('grups/nou', array('centres' => $centres)); } }
public function test() { $output = '<table>'; foreach (Centre::all() as $centre) { $output .= '<tr><td>' . $centre->name . '</td><td>' . $centre->address . '</td><td>' . $centre->city->name . '</td><td>' . $centre->city->state->name . '</td><td>' . $centre->pincode . '</td></tr>'; } $output .= '</table>'; return $output; return PDF::loadView('admin.certi')->stream('certi_final.pdf'); // return View::make('admin.centrecerti'); // $pdf = PDF::loadView('admin.centrecerti'); // return $pdf->stream('certi.pdf'); $out = '<table>'; $out .= '<tr><td>Name</td><td>Address</td><td>City</td><td>Pincode</td></tr>'; $count = 0; foreach (Centre::orderBy('city_id')->get() as $centre) { $out .= '<tr><td>' . $centre->name . '</td><td>' . $centre->address . '</td><td>' . $centre->city->name . '</td><td>' . $centre->pincode . '</td></tr>'; } // foreach (DB::table('results_2015')->where('rank','<','51')->where('kv',1)->get() as $user) // { // if(User::where('roll',$user->roll)->count()) { // $users = User::where('roll',$user->roll)->first(); // if($users->status == 3 || $users->status == 5) { //// dd($users); // $out .= '<tr><td>'.$user->rank.'</td><td>'.$user->roll.'</td><td>'.$user->mobile.'</td><td>'.$users->name1.'</td><td>'.$users->name2.'</td><td>'.$user->path.'</td><td></td><td></td><td></td><td></td><td></td><td></td><td>'.$users->squad.'</td></tr>'; // } // else { // try { // $out .= '<tr><td>'.$user->rank.'</td><td>'.$user->roll.'</td><td>'.$user->mobile.'</td><td>'.$users->name1.'</td><td>'.$users->name2.'</td><td>'.$users->school->name.'</td><td>'.$users->city->name.'</td><td>'.$users->school->address.'</td><td>'.$users->school->pincode.'</td><td>'.$users->school->contact.'</td><td>'.$users->contact1.'</td><td>'.$users->contact2.'</td><td>'.$users->squad.'</td></tr>'; // }catch (Exception $e) { // return var_dump($users); // } // } //// $count++; // } // } // return $count; return $out . '</table>'; $pdf = PDF::loadView('admin.certi'); return $pdf->stream('certi.pdf'); $det = '<table>'; foreach (City::orderBy('state_id')->get() as $city) { $count = User::whereCityId($city->id)->count(); if ($count) { $det .= '<tr><td>' . $city->name . '</td><td>' . $city->state->name . '</td><td>' . $count . '</td></tr>'; } } $det .= '</table>'; return $det; // $list = '<table>'; // foreach(DB::table('results_2015')->where('rank','<','27')->where('kv','!=',1)->where('roll','LIKE',"H%")->get() as $res) // { // $user = User::whereRoll($res->roll)->first(); // if(!$user) { // $name1 = 'User1'; // $name2 = 'User2'; // } // else { // $name1 = $user->name1; // $name2 = $user->name2; // } // $list .= '<tr><td>'.$res->rank.'</td><td>'.$res->roll.'</td><td>'.$name1.'</td><td>'.$name2.'</td><td>'.$res->mobile.'</td><td>'.$res->path.'</td></tr>'; // } // $list .= '</table>'; // return $list; // $rolls = array('HE53600040','HE53600004','HE53600027','HE53600022','HE53600023','HE53600002','HE53600005','HE53600003','HE53600006','HE53600034','HE53600033','HE53600037','HE53600001','HE53600039','HE53600038','HE53600018','HE53600011','HE53600010','HE53600009','HE53600008','HE53600007','HE53600025','HE53600026','HE53600020','HE53600019','HE53600016','HE53600017','HE53600015','HE53600014','HE53600013','HE53600012'); // $list = ''; // foreach($rolls as $roll) // { // $old = User::whereRoll($roll)->first(); // $user = $old->replicate(); // $user->squad = 'JUNIOR'; // $lastroll = User::withTrashed()->where('roll', 'LIKE', "%JE5360%")->count(); // $roll = 'JE5360'.str_pad(strval($lastroll + 1), 4, "0", STR_PAD_LEFT); // $user->roll = $roll; // $user->comments = 'Change squad'; // $user->push(); // $list .= $old->roll.' '.$user->roll.'<br>'; // } // return $list; $user = User::whereRoll('HE52530018')->first(); return $user->roll . '<br>' . Crypt::decrypt($user->result_pass) . '<br>' . $user->name1 . '<br>' . $user->name2; foreach (User::where('city_id', 21)->where('paid', 1)->get() as $user) { $password = str_random(6); $school = $user->school; $user->password = Hash::make($password); $user->save(); if ($user->email1 !== "") { Queue::push(function ($job) use($user, $password, $school) { Mail::send('emails.offline', array('user' => $user, 'school' => $school, 'password' => $password, 'name' => $user->name1), function ($message) use($user) { $message->to($user->email1, $user->name1)->subject('Technothlon Registration Details'); }); $job->delete; }); } if ($user->email1 !== "") { Queue::push(function ($job) use($user, $password, $school) { Mail::send('emails.offline', array('user' => $user, 'school' => $school, 'password' => $password, 'name' => $user->name2), function ($message) use($user) { $message->to($user->email2, $user->name2)->subject('Technothlon Registration Details'); }); $job->delete; }); } } return View::make('emails.kvroll'); return $pdf = PDF::loadView('technopedia.onlineadmitcard')->stream('admit-cards/users/' . Auth::user()->get()->roll . '.pdf'); return View::make('technopedia.onlineadmitcard'); $schools = ''; foreach (Centre::all() as $centre) { $count = User::where('centre_id', $centre->id)->count(); $schools .= $count . ' ' . ($centre->strength - $centre->left) . ' ' . $centre->id; } return $schools; foreach (School::where('verified', 2)->get() as $school) { $junior = User::where('school_id', $school->id)->where('squad', 'JUNIOR')->count(); $hauts = User::where('school_id', $school->id)->where('squad', 'HAUTS')->count(); $schools .= $school->name . '<br>' . $school->address . '<br>' . $school->city->name . ' Pin: ' . $school->pincode . '<br>' . $school->city->state->name . '<br>Ph.: ' . $school->contact . '<br>Junior:' . $junior . ' Hauts: ' . $hauts . '<br><br>'; } return $schools; // return View::make('admin.test'); }
/** * @before _secure, _admin */ public function unverified() { $this->seo(array("title" => "Unverified Labs", "view" => $this->getLayoutView())); $view = $this->getActionView(); $date = RequestMethods::get("date", date('Y-m-d', strtotime("now"))); $live = RequestMethods::get("live", 0); $centres = Centre::all(array("live = ?" => $live, "created LIKE ?" => "%{$date}%"), array("id", "location_id", "created", "organization_id", "live", "user_id")); $view->set("centres", $centres); $view->set("date", $date); $view->set("live", $live); }
/** * Retorna tots els centres de la BBDD */ public static function showCentres() { return Centre::all(); }
/** * @before _secure, _vendor */ public function download() { $this->noview(); $tests = Test::all(array("live = ?" => true), array("title")); $centres = Centre::all(array("organization_id = ?" => $this->organization->id), array("location_id")); $locations = array(); foreach ($centres as $centre) { $loc = Location::first(array("id = ?" => $centre->location_id), array("city")); array_push($locations, $loc->city); } header('Content-Type: text/csv; charset=utf-8'); header('Content-Disposition: attachment; filename=medicaltests.csv'); // create a file pointer connected to the output stream $output = fopen('php://output', 'w'); $first = array("Medical Test"); $locations = array_unique($locations); foreach ($locations as $location) { array_push($first, "Price at " . $location); } fputcsv($output, $first); foreach ($tests as $test) { $data = array(); array_push($data, $test->title); foreach ($locations as $location) { array_push($data, ""); } fputcsv($output, $data); } }