本文整理汇总了PHP中Department::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Department::find方法的具体用法?PHP Department::find怎么用?PHP Department::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Department
的用法示例。
在下文中一共展示了Department::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: searchAction
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);
}
示例2: all
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);
}
示例3: indexAction
public function indexAction()
{
$departments = Department::find();
$this->view->departments = $departments;
$employees = Employee::find();
$this->view->employees = $employees;
}
示例4: getDepartmentPermissions
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;
}
示例5: detail
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();
}
示例6: showSpecificDepartment
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]);
}
示例7: editFormAction
/**
* @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();
}
示例8: getDepartmentList
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;
}
}
示例9: getIndex
/**
* 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));
}
示例10: select_doctor
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));
}
示例11: test_find
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);
}
示例12: get_doctors
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));
}
示例13: testFind
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);
}
示例14: downloadTable
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;'));
}
示例15: __construct
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";
}
}
});
}