public function searchAction() { $numberPage = 1; if ($this->request->isPost()) { $query = Criteria::fromInput($this->di, "Companies", $_POST); $this->persistent->searchParams = $query->getParams(); } else { $numberPage = $this->request->getQuery("page", "int"); if ($numberPage <= 0) { $numberPage = 1; } } $parameters = array(); if ($this->persistent->searchParams) { $parameters = $this->persistent->searchParams; } $companies = Department::find($parameters); if (count($companies) == 0) { $this->flash->notice("没有找到对应的部门"); return $this->forward("companies/index"); } $paginator = new Phalcon\Paginator\Adapter\Model(array("data" => $companies, "limit" => 10, "page" => $numberPage)); $page = $paginator->getPaginate(); $this->view->setVar("page", $page); $this->view->setVar("companies", $companies); }
public function all() { if (\KodeInfo\Utilities\Utils::isDepartmentAdmin(Auth::user()->id)) { $department_admin = DepartmentAdmins::where('user_id', Auth::user()->id)->first(); $department = Department::where('id', $department_admin->department_id)->first(); $company = Company::where('id', $department->company_id)->first(); $messages = CannedMessages::where('company_id', $company->id)->where('department_id', $department->id)->orderBy('id', 'desc')->get(); } elseif (\KodeInfo\Utilities\Utils::isOperator(Auth::user()->id)) { $department_admin = OperatorsDepartment::where('user_id', Auth::user()->id)->first(); $department = Department::where('id', $department_admin->department_id)->first(); $company = Company::where('id', $department->company_id)->first(); $messages = CannedMessages::where('company_id', $company->id)->where('department_id', $department->id)->where('operator_id', Auth::user()->id)->orderBy('id', 'desc')->get(); } else { $messages = CannedMessages::orderBy('id', 'desc')->get(); } foreach ($messages as $message) { $operator = User::find($message->operator_id); $department = Department::find($message->department_id); $company = Company::find($message->company_id); $message->operator = $operator; $message->department = $department; $message->company = $company; } $this->data['messages'] = $messages; return View::make('canned_messages.all', $this->data); }
public function indexAction() { $departments = Department::find(); $this->view->departments = $departments; $employees = Employee::find(); $this->view->employees = $employees; }
public static function getDepartmentPermissions($department_id) { $department = Department::find($department_id); $permissions_keys = explode(",", $department->permissions); $permissions = Permissions::whereIn('key', $permissions_keys)->get(); return $permissions; }
public function detail() { $department = Department::find(Input::get('department_id')); if ($department) { $this->set_template('hospital.department.detail'); $this->set_data(array('name' => $department->name, 'photo' => $department->photo, 'content' => $department->description)); // Json response: // Remove html tags $this->set_postprocess_function('json', function ($result, $status) { if ($status) { $result['content'] = strip_tags($result['content']); } return $result; }); // Html response: // add some information $this->set_postprocess_function('html', function ($result, $status) use($department) { if ($status) { $chief_doctor = $department->doctors()->where('is_chief', true)->first(); $hospital_name = $department->hospital()->first()->name; $result['photo'] = $department->photo; $result['hospital_name'] = $hospital_name; if (isset($chief_doctor)) { $result['doctor'] = array('photo' => $chief_doctor->photo, 'description' => $chief_doctor->description, 'specialty' => $chief_doctor->specialty); } } return $result; }); } else { $this->set_error_code($this->not_found_error_code); } return $this->response(); }
public function showSpecificDepartment() { $departmentIDInput = Input::get('department-dropdown'); $department = Department::find($departmentIDInput); $departmentprograms = $department->programs()->where('degreelevel', 'U')->whereNotIn('programid', array(62, 66, 38))->get(); //ave students per year and ave difference $programids = $department->programs()->whereNotIn('programid', array(62, 66, 38))->where('degreelevel', 'U')->lists('programid'); //To get batches of program whithin 2000-2009 $yearsArray = Studentterm::whereIn('programid', $programids)->where('year', '>', 1999)->where('year', '<', 2014)->groupBy('year')->orderBy('year', 'asc')->lists('year'); $yearlyStudentAverage = []; $departmentProgramsAverage = []; foreach ($yearsArray as $yearData) { $aveStudents = round($department->getYearlyAveStudents($yearData), 2); if ($aveStudents > 1) { $yearlyStudentAverage[$yearData] = $aveStudents; } } foreach ($departmentprograms as $departmentprogram) { $departmentProgramsAverage[$departmentprogram->programtitle] = round($departmentprogram->getAveStudents(), 2); } $batchAttrition = $department->getBatchAttrition(); $programsAttrition = $department->getProgramsAveBatchAttrition(); $aveAttrition = $department->getAveAttrition(); $aveShiftRate = $department->getAveShiftRate(); $aveYearsBeforeDropout = $department->getAveYearsBeforeDropout(); $aveYearsBeforeShifting = $department->getAveYearsBeforeShifting(); $gradeCount = $department->getGradeCount(); $shiftGradeCount = $department->getShiftGradeCount(); $stbracketCount = $department->getSTBracketCount(); $shiftBracketCount = $department->getShiftSTBracketCount(); return View::make('department.department-specific', ['department' => $department, 'yearlyStudentAverage' => $yearlyStudentAverage, 'departmentprograms' => $departmentprograms, 'departmentProgramsAverage' => $departmentProgramsAverage, 'aveAttrition' => $aveAttrition, 'batchAttrition' => $batchAttrition, 'aveShiftRate' => $aveShiftRate, 'aveYearsBeforeDropout' => $aveYearsBeforeDropout, 'aveYearsBeforeShifting' => $aveYearsBeforeShifting, 'programsAttrition' => $programsAttrition, 'gradeCount' => $gradeCount, 'shiftGradeCount' => $shiftGradeCount, 'stbracketCount' => $stbracketCount, 'shiftBracketCount' => $shiftBracketCount]); }
/** * @desc - สร้างฟอร์มสำหรับ่ข้อมูลพนักงานที่เรียกดู * @return object */ public function editFormAction($SSN) { $employee = Employee::findFirst(array("conditions" => "SSN=?0", "bind" => array($SSN))); $this->tag->setDefault('SSN', $employee->SSN); $this->tag->setDefault('FNAME', $employee->FNAME); $this->tag->setDefault('LNAME', $employee->LNAME); $this->tag->setDefault('DNO', $employee->DNO); $this->view->department = Department::find(); }
function getDepartmentList($compCode) { App::import("Model", "Department"); $model = new Department(); $con2 = $model->find('list', array('fields' => array('Department.dept_code', 'Department.dept_name'), 'conditions' => array('Department.comp_code' => $compCode))); if (empty($con2)) { return 0; } else { return $con2; } }
/** * Departments tree * * @return \View */ public function getIndex($department_id = NULL) { $department = NULL; if ($department_id) { $department = Department::find($department_id); } $root = Department::find(1); $tree = $root->getNestedList("name", NULL, "- "); $items = Position::select(["positions.id", "positions.name", "departments.name as department_name", DB::RAW("(SELECT COUNT(*) FROM users WHERE users.position_id = positions.id) as count_users"), "positions.chief_position_id"])->leftjoin("departments", "departments.id", "=", "positions.department_id")->wheredepartment($department)->orderBy("departments.name")->orderBy("positions.name")->paginate(50); $departments = Department::whereNotNull("parent_id")->orderBy("name")->get(); $content = View::make("positions/list", ["department" => $department, "departments" => $departments, "tree" => $tree, "items" => $items]); return View::make("common/tpl", array("template" => $content)); }
public function select_doctor() { $department = Department::find(Input::get('department_id')); if (!isset($department)) { // .. } $doctors = $department->doctors; if (!isset($doctors)) { // .. } foreach ($doctors as $doctor) { $doctor['title'] = $doctor->title; } return View::make('register.select_doctor', array('hospital_name' => $department->hospital->name, 'department' => $department, 'doctors' => $doctors)); }
function test_find() { //Arrange $name = "Biology"; $address = "346 Stupid Avenue"; $test_department = new Department($name, $address); $test_department->save(); $name2 = "Chemiology"; $address2 = "55 Bo Ct"; $test_department2 = new Department($name2, $address2); $test_department2->save(); //Act $result = Department::find($test_department2->getId()); //Assert $this->assertEquals($test_department2, $result); }
public function get_doctors() { $department = Department::find(Input::get('department_id')); if (!isset($department)) { return Response::json(array('error_code' => 1, 'message' => '不存在该诊室')); } $doctors = $department->doctors; if (!isset($doctors)) { return Response::json(array('error_code' => 2, 'message' => '该诊室无医生...')); } $result = array(); foreach ($doctors as $doctor) { $result[] = array('id' => $doctor->id, 'name' => $doctor->name, 'title' => $doctor->title, 'photo' => $doctor->photo, 'specialty' => strip_tags($doctor->specialty), 'can_be_registered' => $this->can_be_registered($doctor->id), 'is_consultable' => $doctor->is_consultable); } return Response::json(array('error_code' => 0, 'doctors' => $result)); }
function testFind() { //Arrange $name = "Math"; $id = 1; $test_department = new Department($name, $id); $test_department->save(); $name2 = "Business"; $id2 = 2; $test_department2 = new Department($name2, $id2); $test_department2->save(); //Act $id = $test_department->getId(); $result = Department::find($id); //Assert $this->assertEquals($test_department, $result); }
public function downloadTable($id, $year, $month) { $contents = "DATA ABSENSI BINA BAKTI\n\n"; $department = Department::find($id); $contents .= "Unit: ," . $department->name . "\n"; $months = MyDate::get_month_names(); $contents .= "Bulan: ," . $months[$month - 1] . "\n"; $contents .= "Tahun: ," . $year . "\n\n"; $contents .= "KODE,NAMA,NORMAL,,PULANG AWAL,,,TERLAMBAT,LUPA,TUGAS LUAR,,OTHER,TIDAK MASUK,,,JUMLAH HARI MASUK,,JUMLAH HARI TIDAK MASUK,NOMINAL UANG KONSUMSI\n"; $contents .= ",,WEEKDAY,WEEKEND,WEEKDAY < 12,WEEKDAY >= 12,WEEKEND,,,WEEKDAY,WEEKEND,,SAKIT,IZIN,ALPHA,WEEKDAY,WEEKEND,,WEEKDAY,WEEKEND,PULANG AWAL,TOTAL\n"; $employees = Employee::where('department_id', '=', $id)->orderBy('name')->get(); $total = 0; foreach ($employees as $employee) { $contents .= $employee->ssn . ","; $contents .= $employee->name . ","; $data = Session::pull($employee->id, 'default'); $total += $data['konsumsi_total']; $contents .= $data['normal_weekday'] . ","; $contents .= $data['normal_weekend'] . ","; $contents .= $data['pulang_awal_weekday_before_12'] . ","; $contents .= $data['pulang_awal_weekday'] . ","; $contents .= $data['pulang_awal_weekend'] . ","; $contents .= $data['terlambat'] . ","; $contents .= $data['lupa'] . ","; $contents .= $data['tugas_luar_weekday'] . ","; $contents .= $data['tugas_luar_weekend'] . ","; $contents .= $data['other'] . ","; $contents .= $data['sakit'] . ","; $contents .= $data['izin'] . ","; $contents .= $data['alpha'] . ","; $contents .= $data['masuk_weekday'] . ","; $contents .= $data['masuk_weekend'] . ","; $contents .= $data['tidak_masuk'] . ","; $contents .= $data['konsumsi_weekday'] . ","; $contents .= $data['konsumsi_weekend'] . ","; $contents .= $data['konsumsi_pulang_awal'] . ","; $contents .= $data['konsumsi_total'] . ","; $contents .= "\n"; } $contents .= ",,,,,,,,,,,,,,,,,,,,," . $total; // $file_name = "allowance.csv"; $file = public_path() . "/download/allowance.csv"; File::put($file, $contents); return Response::download($file, "allowance-" . strtolower($department->name) . "-" . $month . "-" . $year . ".csv", array('Content-Type' => 'text/csv', 'Content-Disposition' => 'attachment;')); }
public function __construct() { $this->beforeFilter(function () { if (!Session::has('deptIdForPC')) { if (Auth::check()) { if (Helpers::isDeptAdminOrHigher()) { Session::put('deptIdForPC', Auth::user()->current_department); Session::put('deptNameForPC', Department::find(Session::get('deptIdForPC'))->long_name); } else { if (Request::header('Referer') != URL::to('/') . '/dashboard') { return "Invalid Session"; } } } else { return "Invalid Session"; } } }); }
public function getOperators($company_id) { $department_ids = Department::where('company_id', $company_id)->lists('id'); $operators = []; if (sizeof($department_ids) > 0) { $operator_ids = OperatorsDepartment::whereIn('department_id', $department_ids)->lists('user_id'); if (sizeof($operator_ids) > 0) { $operators = User::whereIn('id', $operator_ids)->get(); } } foreach ($operators as $operator) { $department_id = OperatorsDepartment::where('user_id', $operator->id)->pluck("department_id"); $department = Department::find($department_id); $company = Company::find($department->company_id); $operator->department = $department; $operator->company = $company; } $this->data['operators'] = $operators; return View::make('companies.operators', $this->data); }
/** * Remove the specified resource from storage. * DELETE /department/{id} * * @param int $id * @return Response */ public function destroy($id) { $department = Department::find($id)->delete(); if (is_null($department)) { $class = 'error'; $message = 'Record does not exist.'; } else { $class = 'success'; $message = 'Record successfully deleted.'; } return Redirect::route('department.index')->with('class', $class)->with('message', $message); }
public function findAllDepartmentName($comp_code = null) { App::import("Model", "Department"); $model = new Department(); if (empty($comp_code)) { $conditions = array('comp_code' => $comp_code); } else { $conditions = array(); } $dept_name = $model->find("list", array('fields' => array('Department.dept_code', 'Department.dept_name'), 'conditions' => $conditions)); if (!empty($dept_name)) { return $dept_name; } else { return false; } }
/** * Show the form for editing the specified branch. * * @param int $id * @return Response */ public function edit($id) { $department = Department::find($id); return View::make('departments.edit', compact('department')); }
</div> <div style="padding-top:20px;"></div><button class="btn btn-success"> <i class="glyphicon glyphicon-filter"></i> Filter</button> {{ Form::token() }} </form> @if(empty($users)) <br>No record @else @if($deptid != "*") <?php $dept = Department::find($deptid); ?> <h2><label>Department: </label> {{ $dept->name }}</h2> @else <h2><label>Department: </label> All Departments</h2> @endif <h2><label>Years Working: </label> {{$yearString}}</h2> <div class="col-md-2"> <div style="padding-top:20px;"></div><a href="{{ route('ems-reports-pdf') }}" class="btn btn-primary" target="_blank"> <i class="fa fa-print"></i> Print</a> </div> <div class="col-md-offset-9"> <h3 style="color:green;">{{ $users->count()}} records found. </h3></div>
@extends('layouts.admin.default') @section('content') <?php $departmentCount = Department::count(); $departments = Department::paginate(10); $departmentDelete = Department::find($id); $message = Session::get('message'); ?> <div class="page-container"> <div class="row" style="padding-bottom:20px;"> <div class="col-md-2 clearfix"> <aside class="sidebar"> <nav class="sidebar-nav"> <ul id="menu"> <li> <a href="{{ url('/admin/dashboard') }}"> <span class="sidebar-nav-item-icon fa fa-tachometer fa-lg"></span> <span class="sidebar-nav-item">Dashboard</span> </a> </li> <li> <a href="#"> <span class="sidebar-nav-item-icon fa fa-users fa-lg"></span> <span class="sidebar-nav-item">Employees</span>
public function save_department() { $id = Input::get('id'); $store_id = Input::get('store_id'); $department = Department::find($id); if (!$department) { $department = new Department(); } $department->name = Input::get('name'); $department->store_id = $store_id; $department->save(); $message = "Successfully updated the department"; $type = "success"; return Redirect::to('/admin/store/' . $store_id . '/departments')->with('type', $type)->with('message', $message); }
public function chooseDepartmentPost() { $rules = array('currentDepartment' => 'required'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::to('cd')->with('cd_errors', true); } else { if (!Department::find(Input::get('currentDepartment'))) { return Redirect::to('cd')->with('cd_errors', true); } $user = Auth::user(); $user->current_department = Input::get('currentDepartment'); $user->save(); return Redirect::to('dashboard'); } }
/** * Remove the specified resource from storage. * DELETE /department/{id} * * @param int $id * @return Response */ public function destroy($id) { $barang = Department::find($id); $barang->delete(); // redirect Session::flash('message', 'Successfully deleted Department!'); return Redirect::to('department'); // }
/** * Delete department from DB. Cannot delete one that's in use. * * @param $id * @return mixed */ public function deleteDept($id) { $dept = Department::find($id); if (count($dept->employees()->get()->toArray())) { return Redirect::back()->with('danger_flash_message', 'You cannot delete a department that is in use.'); } $dept->delete(); return Redirect::route('manageDepartments')->with('flash_message', 'Department ' . $dept->name . ' has been deleted'); }
<td>{{ $property->properties->id }}</td> <td><a href="{{ route('view-property', $property->properties_id) }}">{{ $property->properties->propname }} </a></td> <td> <?php $cat = PropertyCategory::find($property->cat_id); ?> {{ $cat->catname }} </td> <td>{{ $property->properties->propcondition }}</td> <td>{{ $property->user->formatName(':fn :ln') }}</td> <td> <?php $dept = Department::find($property->dept_id); ?> {{ $dept->name }} </td> <td>{{ $property->properties->par }}</td> <td>{{ $property->formatTimeAssign()}}</td> <td> <a href="{{ route('remove-accountability', $property->id) }}" class="btn btn-primary" style="float: right;"><span class="fa fa-arrows-h"></span>Transfer</a> </td> </tr> @endforeach </tbody>
public function search() { $paginatorFilter = ""; if (Input::has('busq')) { $busq = Input::get('busq'); $auxLider = Publicaciones::leftJoin('categoria', 'categoria.id', '=', 'publicaciones.categoria')->leftJoin('usuario', 'usuario.id', '=', 'publicaciones.user_id')->leftJoin('departamento', 'publicaciones.departamento', '=', 'departamento.id')->where('publicaciones.status', '=', 'Aprobado')->where('publicaciones.deleted', '=', 0)->where(function ($query) { $query->where('publicaciones.ubicacion', '=', 'Categoria')->orWhere('publicaciones.ubicacion', '=', 'Ambos'); })->where(function ($query) { $query->where('publicaciones.fechFin', '>=', date('Y-m-d'))->orWhere('publicaciones.fechFinNormal', '>=', date('Y-m-d')); })->where(function ($query) use($busq) { $query->whereRaw("LOWER(`publicaciones`.`titulo`) LIKE '%" . strtolower($busq) . "%'")->orWhereRaw("LOWER(`publicaciones`.`pag_web`) LIKE '%" . strtolower($busq) . "%'")->orWhereRaw("LOWER(`categoria`.`desc`) LIKE '%" . strtolower($busq) . "%'"); }); $auxRes = Publicaciones::leftJoin('categoria', 'publicaciones.categoria', '=', 'categoria.id')->leftJoin('departamento', 'publicaciones.departamento', '=', 'departamento.id')->leftJoin('usuario', 'usuario.id', '=', 'publicaciones.user_id')->where(function ($query) use($busq) { $query->whereRaw("LOWER(`publicaciones`.`titulo`) LIKE '%" . strtolower($busq) . "%'")->orWhereRaw("LOWER(`departamento`.`nombre`) LIKE '%" . strtolower($busq) . "%'")->orWhereRaw("LOWER(`categoria`.`desc`) LIKE '%" . strtolower($busq) . "%'"); })->where(function ($query) { $query->where('publicaciones.fechFin', '>=', date('Y-m-d'))->orWhere('publicaciones.fechFinNormal', '>=', date('Y-m-d')); })->where('publicaciones.tipo', '!=', 'Lider')->where('publicaciones.status', '=', 'Aprobado')->where('publicaciones.deleted', '=', 0); /*Se agrega*/ if (Input::has('filter')) { $filter = Input::get('filter'); if ($filter != -1) { $filter = Department::find(Input::get('filter')); $auxRes = $auxRes->where('publicaciones.departamento', '=', $filter->id); $paginatorFilter .= '&filter=' . $filter->id; } else { $filter = ""; } } if (Input::has('min') || Input::has('max')) { $min = Input::get('min'); $max = Input::get('max'); $currency = Input::get('currency'); if (!is_null($min) && !is_null($max) && !empty($min) && !empty($max)) { $minmax = array($min, $max); $paginatorFilter .= '&min=' . $min . '&max=' . $max . '¤cy=' . $currency; $auxLider = $auxLider->where('publicaciones.moneda', '=', $currency)->where('publicaciones.precio', '>=', $min)->whereRaw('`publicaciones`.`precio` <= ' . $max); $auxRes = $auxRes->where('publicaciones.precio', '>=', $min)->whereRaw('`publicaciones`.`precio` <= ' . $max)->where('publicaciones.moneda', '=', $currency); } else { if (!is_null($max) && !empty($max)) { $minmax = array('', $max); $paginatorFilter .= '&max=' . $max . '¤cy=' . $currency; $auxLider = $auxLider->where('publicaciones.moneda', '=', $currency)->whereRaw('`publicaciones`.`precio` <= ' . $max); $auxRes = $auxRes->whereRaw('`publicaciones`.`precio` <= ' . $max)->where('publicaciones.moneda', '=', $currency); } elseif (!is_null($min) && !empty($min)) { $minmax = array($min, ''); $paginatorFilter .= '&min=' . $min . '¤cy=' . $currency; $auxLider = $auxLider->where('publicaciones.moneda', '=', $currency)->where('precio', '>=', $min); $auxRes = $auxRes->where('publicaciones.moneda', '=', $currency)->where('publicaciones.precio', '>=', $min); } } } if (Input::has('rel')) { $rel = Input::get('rel'); switch ($rel) { case 'rep': $auxLider = $auxLider->orderBy('usuario.reputation', 'DESC'); $auxRes = $auxRes->orderBy('usuario.reputation', 'DESC'); $paginatorFilter .= '&rel=rep'; break; case 'fin': $auxLider = $auxLider->orderBy('publicaciones.fechFin', 'ASC')->orderBy('publicaciones.fechFinNormal', 'ASC'); $auxRes = $auxRes->orderBy('publicaciones.fechFin', 'ASC')->orderBy('publicaciones.fechFinNormal', 'ASC'); $paginatorFilter .= '&rel=fin'; break; case 'ini': $auxLider = $auxLider->orderBy('publicaciones.fechIni', 'DESC')->orderBy('publicaciones.fechIniNormal', 'DESC'); $auxRes = $auxRes->orderBy('publicaciones.fechIni', 'DESC')->orderBy('publicaciones.fechIniNormal', 'DESC'); $paginatorFilter .= '&rel=ini'; break; default: break; } } if (Input::has('cond')) { $cond = Input::get('cond'); $paginatorFilter .= '&cond=' . $cond; $auxRes = $auxRes->where('publicaciones.condicion', '=', strtolower($cond)); } if (Input::has('buss')) { $buss = Input::get('buss'); $paginatorFilter .= '&buss=' . $buss; $auxLider = $auxLider->where('publicaciones.bussiness_type', '=', strtolower($buss)); $auxRes = $auxRes->where('publicaciones.bussiness_type', '=', strtolower($buss)); } $lider = $auxLider->get($this->toReturn); $res = $auxRes->paginate(5, $this->toReturn); $categorias = Categorias::where('id', '=', $busq)->pluck('desc'); if (!is_null($categorias)) { $busq = $categorias; } else { $busq = $busq; } $departamentos = Department::get(); $view = array('publicaciones' => $res, 'busq' => $busq, 'lider' => $lider, 'departamento' => $departamentos, 'paginatorFilter' => $paginatorFilter); if (isset($filter)) { $view = $view + array('filter' => $filter); } if (isset($currency)) { $view = $view + array('minmax' => $minmax, 'currency' => $currency); } if (isset($cond)) { $view = $view + array('cond' => $cond); } if (isset($buss)) { $view = $view + array('buss' => $buss); } if (isset($rel)) { $view = $view + array('rel' => $rel); } return Response::json($view); } elseif (Input::has('cat')) { $id = Input::geT('cat'); /*Query inicial*/ $auxLider = Publicaciones::leftJoin('usuario', 'usuario.id', '=', 'publicaciones.user_id')->leftJoin('departamento', 'publicaciones.departamento', '=', 'departamento.id')->where('publicaciones.status', '=', 'Aprobado')->where('publicaciones.deleted', '=', 0)->where(function ($query) { $query->where('publicaciones.ubicacion', '=', 'Categoria')->orWhere('publicaciones.ubicacion', '=', 'Ambos'); })->where(function ($query) { $query->where('publicaciones.fechFin', '>=', date('Y-m-d'))->orWhere('publicaciones.fechFinNormal', '>=', date('Y-m-d')); })->where('publicaciones.categoria', '=', $id); //->get(array('id','img_1','titulo','precio','moneda')); $auxRes = Publicaciones::leftJoin('departamento', 'publicaciones.departamento', '=', 'departamento.id')->leftJoin('usuario', 'usuario.id', '=', 'publicaciones.user_id')->where('publicaciones.status', '=', 'Aprobado')->where('publicaciones.categoria', '=', $id)->where('publicaciones.tipo', '!=', 'Lider')->where('publicaciones.deleted', '=', 0)->where(function ($query) { $query->where('publicaciones.ubicacion', '=', 'Categoria')->orWhere('publicaciones.ubicacion', '=', 'Ambos'); })->where(function ($query) { $query->where('publicaciones.fechFin', '>=', date('Y-m-d', time()))->orWhere('publicaciones.fechFinNormal', '>=', date('Y-m-d', time())); }); /*Se agrega*/ if (Input::has('filter')) { $filter = Input::get('filter'); if ($filter != -1) { $filter = Department::find(Input::get('filter')); $auxRes = $auxRes->where('publicaciones.departamento', '=', $filter->id); $paginatorFilter .= '&filter=' . $filter->id; } else { $filter = ""; } } if (Input::has('min') || Input::has('max')) { $min = Input::get('min'); $max = Input::get('max'); $currency = Input::get('currency'); if (!is_null($min) && !is_null($max) && !empty($min) && !empty($max)) { $minmax = array($min, $max); $paginatorFilter .= '&min=' . $min . '&max=' . $max . '¤cy=' . $currency; $auxLider = $auxLider->whereRaw('`publicaciones`.`precio` >= ' . $min)->whereRaw('`publicaciones`.`precio` <= ' . $max)->where('moneda', '=', $currency); $auxRes = $auxRes->whereRaw('`publicaciones`.`precio` >= ' . $min)->whereRaw('`publicaciones`.`precio` <= ' . $max)->where('publicaciones.moneda', '=', $currency); } else { if (!is_null($max) && !empty($max)) { $minmax = array('', $max); $paginatorFilter .= '&max=' . $max . '¤cy=' . $currency; $auxLider = $auxLider->where('moneda', '=', $currency)->whereRaw('`publicaciones`.`precio` <= ' . $max); $auxRes = $auxRes->whereRaw('`publicaciones`.`precio` <= ' . $max)->where('publicaciones.moneda', '=', $currency); } elseif (!is_null($min) && !empty($min)) { $minmax = array($min, ''); $paginatorFilter .= '&min=' . $min . '¤cy=' . $currency; $auxLider = $auxLider->whereRaw('`publicaciones`.`precio` >= ' . $min)->where('moneda', '=', $currency); $auxRes = $auxRes->where('publicaciones.moneda', '=', $currency)->whereRaw('`publicaciones`.`precio` >= ' . $min); } } } if (Input::has('rel')) { $rel = Input::get('rel'); switch ($rel) { case 'rep': $auxLider = $auxLider->leftJoin('usuario', 'usuario.id', '=', 'publicaciones.user_id')->orderBy('usuario.reputation', 'DESC'); $auxRes = $auxRes->leftJoin('usuario', 'usuario.id', '=', 'publicaciones.user_id')->orderBy('usuario.reputation', 'DESC'); $paginatorFilter .= '&rel=rep'; break; case 'fin': $auxLider = $auxLider->orderBy('publicaciones.fechFin', 'ASC')->orderBy('publicaciones.fechFinNormal', 'ASC'); $auxRes = $auxRes->orderBy('publicaciones.fechFin', 'ASC')->orderBy('publicaciones.fechFinNormal', 'ASC'); $paginatorFilter .= '&rel=fin'; break; case 'ini': $auxLider = $auxLider->orderBy('publicaciones.fechIni', 'DESC')->orderBy('publicaciones.fechIniNormal', 'DESC'); $auxRes = $auxRes->orderBy('publicaciones.fechIni', 'DESC')->orderBy('publicaciones.fechIniNormal', 'DESC'); $paginatorFilter .= '&rel=ini'; break; default: break; } } if (Input::has('cond')) { $cond = Input::get('cond'); $paginatorFilter .= '&cond=' . $cond; $auxRes = $auxRes->where('publicaciones.condicion', '=', strtolower($cond)); } if (Input::has('buss')) { $buss = Input::get('buss'); $paginatorFilter .= '&buss=' . $buss; $auxLider = $auxLider->where('publicaciones.bussiness_type', '=', strtolower($buss)); $auxRes = $auxRes->where('publicaciones.bussiness_type', '=', strtolower($buss)); } $lider = $auxLider->get($this->toReturn); $res = $auxRes->paginate(5, $this->toReturn); $categorias = Categorias::where('id', '=', $id)->pluck('id'); if (!is_null($categorias)) { $busq = $categorias; } else { $busq = $id; } $departamentos = Department::get(); $view = array('publicaciones' => $res, 'busq' => $busq, 'lider' => $lider, 'departamento' => $departamentos, 'paginatorFilter' => $paginatorFilter); if (isset($filter)) { $view = $view + array('filter' => $filter); } if (isset($currency)) { $view = $view + array('minmax' => $minmax, 'currency' => $currency); } if (isset($cond)) { $view = $view + array('cond' => $cond); } if (isset($buss)) { $view = $view + array('buss' => $buss); } if (isset($rel)) { $view = $view + array('rel' => $rel); } return Response::json($view); } }
//DELETE: EXISTING COMPANY Route::get('/admin/department/delete/{id}', array('as' => 'adminDeleteDepartment', 'uses' => function ($id) { $id = (int) $id; $employeeId = Session::get('userEmployeeId'); $userId = Session::get('userId'); $employee = new Employee(); $employeeInfo = $employee->getEmployeeInfoById($employeeId); //return 'Update Company'; return View::make('admin.departmentdelete', array('id' => $id, 'employeeInfo' => $employeeInfo)); //return Redirect::route('updateCompany', array('id' => $id)); })); //DELETE: EXISTING COMPANY Route::post('/admin/department/delete/{id}', array('as' => 'adminProcessDeleteDepartment', 'uses' => function ($id) { $data = Input::all(); $id = (int) $id; $department = Department::find($id); if ($department->delete()) { $message = 'Deleted Successfully.'; return Redirect::route('adminNewDepartment')->with('message', $message); } })); //CREATE: new JobTitle Route::get('/admin/jobtitle/new', array('as' => 'adminNewJobTitle', 'uses' => function () { //return 'Add Job Title'; $employeeId = Session::get('userEmployeeId'); $userId = Session::get('userId'); $employee = new Employee(); $employeeInfo = $employee->getEmployeeInfoById($employeeId); return View::make('admin.jobtitlenew', ['employeeInfo' => $employeeInfo]); })); //CREATE: new JobTitle
$summary = DB::table('employee_summary')->select(DB::raw('SUM(lates) as lates, SUM(undertime) as undertime, SUM(absent) as absent, SUM(paid_sick_leave) as paid_sick_leave, SUM(paid_vacation_leave) as paid_vacation_leave, SUM(leave_without_pay) as leave_without_pay, SUM(maternity_leave) as maternity_leave, SUM(paternity_leave) as paternity_leave, SUM(regular) as regular, SUM(regular_overtime) as regular_overtime, SUM(regular_overtime_night_diff) as regular_overtime_night_diff, SUM(regular_night_differential) as regular_night_differential, SUM(rest_day) as rest_day, SUM(rest_day_overtime) as rest_day_overtime, SUM(rest_day_overtime_night_diff) as rest_day_overtime_night_diff, SUM(rest_day_night_differential) as rest_day_night_differential, SUM(rest_day_special_holiday) as rest_day_special_holiday, SUM(rest_day_special_holiday_overtime) as rest_day_special_holiday_overtime, SUM(rest_day_special_holiday_overtime_night_diff) as rest_day_special_holiday_overtime_night_diff, SUM(rest_day_special_holiday_night_diff) as rest_day_special_holiday_night_diff, SUM(rest_day_legal_holiday) as rest_day_legal_holiday, SUM(rest_day_legal_holiday_overtime) as rest_day_legal_holiday_overtime, SUM(rest_day_legal_holiday_overtime_night_diff) as rest_day_legal_holiday_overtime_night_diff, SUM(rest_day_legal_holiday_night_diff) as rest_day_legal_holiday_night_diff, SUM(special_holiday) as special_holiday, SUM(special_holiday_overtime) as special_holiday_overtime, SUM(special_holiday_overtime_night_diff) as special_holiday_overtime_night_diff, SUM(special_holiday_night_diff) as special_holiday_night_diff, SUM(legal_holiday) as legal_holiday, SUM(legal_holiday_overtime) as legal_holiday_overtime, SUM(legal_holiday_overtime_night_diff) as legal_holiday_overtime_night_diff, SUM(legal_holiday_night_diff) as legal_holiday_night_diff'))->where('employee_id', $employeeId)->whereBetween('daydate', [$cutOffDateFrom, $cutOffDateTo])->first(); //dd($summary); $userGroups = DB::table('users_groups')->where('user_id', $userId)->first(); //$userGroups = DB::table('users_groups')->where('user_id', Auth::user()->id)->first(); if (!empty($userGroups)) { $groups = DB::table('groups')->where('id', (int) $userGroups->group_id)->first(); } $currentUser = Sentry::getUser(); //$employeeId = Session::get('userEmployeeId'); //$employeeInfo[0]->id $company = Company::find($employeeInfo[0]->company_id); $department = Department::find($employeeInfo[0]->department_id); $jobTitle = JobTitle::find($employeeInfo[0]->position_id); $manager = ''; $manager = Employee::where('id', '=', $employeeInfo[0]->manager_id)->first(); if (!empty($manager)) { $managerFullname = $manager->firstname . ', ' . $manager->lastname; } else { $managerFullname = ''; } $employees = DB::table('employees')->where('manager_id', $employeeInfo[0]->id)->orWhere('supervisor_id', $employeeInfo[0]->id)->get(); $employeeArr[0] = ''; foreach ($employees as $employee) { $employeeArr[$employee->id] = $employee->firstname . ', ' . $employee->lastname; } //$getSchedule = DB::table('employee_schedule')->where('employee_id', $employee->id)->where('schedule_date', trim($currentDate))->get(); //$getWorkShiftByDayOfTheWeek = DB::table('work_shift')->where('employee_id', $employee->id)->where('name_of_day', $dayOfTheWeek)->where('shift', $shift)->get();
<?php Route::collection(array('before' => 'auth,csrf'), function () { Route::get(array('admin/departments', 'admin/departments/(:num)'), function ($page = 1) { $vars['messages'] = Notify::read(); $vars['departments'] = Department::paginate($page, Config::get('meta.posts_per_page')); return View::create('departments/index', $vars)->partial('header', 'partials/header')->partial('footer', 'partials/footer'); }); Route::get('admin/departments/edit/(:num)', function ($id) { $vars['messages'] = Notify::read(); $vars['token'] = Csrf::token(); $vars['department'] = Department::find($id); $vars['fields'] = Extend::fields('department', $id); return View::create('departments/edit', $vars)->partial('header', 'partials/header')->partial('footer', 'partials/footer'); }); Route::post('admin/departments/edit/(:num)', function ($id) { $input = Input::get(array('title', 'slug', 'description')); $validator = new validator($input); $validator->check('title')->is_max(3, __('departments.title_missing')); if ($errors = $validator->errors()) { Input::flash(); Notify::error($errors); return Response::redirect('admin/departments/edit/' . $id); } if (empty($input['slug'])) { $input['slug'] = $input['title']; } $input['slug'] = slug($input['slug']); department::update($id, $input); Extend::process('department', $id); Notify::successs(__('departments.update'));