1<?php
2
3/*
4 * To change this template, choose Tools | Templates
5 * and open the template in the editor.
6 *
7 * Description of PerformanceReviewSearchForm
8 *
9 * @author nadeera
10 */
11
12class PerformanceReviewSearchForm extends BasePefromanceSearchForm {
13
14    /**
15     *
16     */
17    public function configure() {
18
19        $this->setWidgets($this->getFormWidgets());
20        $this->setValidators($this->getFormValidators());
21
22        $this->getWidgetSchema()->setNameFormat('performanceReview360SearchForm[%s]');
23        $this->getWidgetSchema()->setLabels($this->getFormLabels());
24    }
25
26    /**
27     *
28     * @return array
29     */
30    protected function getFormWidgets() {
31        $widgets = array(
32
33            'employeeName' => new sfWidgetFormInputText(),
34            'employeeNumber' => new sfWidgetFormInputHidden(),
35            'jobTitleCode' => new sfWidgetFormChoice(array('choices' => $this->getJobTitleListAsArrayWithAllOption()), array('class' => 'formSelect')),
36            'status' => new sfWidgetFormChoice(array('choices' => $this->getPerformanceReviewStatusAsArray(true)), array('class' => 'formSelect')),
37            'fromDate' => new ohrmWidgetDatePicker(array(), array('id' => 'fromDate')),
38            'toDate' => new ohrmWidgetDatePicker(array(), array('id' => 'toDate')),
39            'reviwerName' => new sfWidgetFormInputText(),
40            'reviwerNumber' => new sfWidgetFormInputHidden()
41
42        );
43        return $widgets;
44    }
45
46    /**
47     *
48     * @return array
49     */
50    protected function getFormValidators() {
51
52        $validators = array(
53            'employeeName' => new sfValidatorString(array('required' => false)),
54            'employeeNumber' => new sfValidatorString(array('required' => false)),
55            'jobTitleCode' => new sfValidatorString(array('required' => false)),
56            'fromDate' => new sfValidatorString(array('required' => false)),
57            'toDate' => new sfValidatorString(array('required' => false)),
58            'status' =>  new sfValidatorString(array('required' => false)),
59            'reviwerName' => new sfValidatorString(array('required' => false)),
60            'reviwerNumber' => new sfValidatorString(array('required' => false))
61        );
62        return $validators;
63    }
64
65    /**
66     *
67     * @return array
68     */
69    protected function getFormLabels() {
70        $labels = array(
71            'employeeName' => __('Employee Name'),
72            'jobTitleCode' => __('Job Title'),
73            'fromDate' =>  __('From Date'),
74            'toDate' =>  __('To Date'),
75            'status' =>  __('Status'),
76            'reviwerName' =>  __('Reviewer')
77        );
78        return $labels;
79    }
80
81    /**
82     *
83     * @return type
84     */
85    public function searchReviews($limit, $page = 1, $sortOrder = null, $sortFeild = null) {
86
87        $serachParams ['employeeName'] =  $this->getValue('employeeName');
88        $serachParams ['jobTitleCode'] =  $this->getValue('jobTitleCode');
89        $serachParams ['from'] =  (strtotime($this->getValue('fromDate')))? $this->getValue('fromDate') :"";
90        $serachParams ['to'] = (strtotime( $this->getValue('toDate')))?  $this->getValue('toDate') :"";
91        $serachParams ['reviewerId'] =  ($this->getValue('reviwerNumber') > 0)?$this->getValue('reviwerNumber'):"";
92        $serachParams['status']         =   ($this->getValue('status') > 0 )? $this->getValue('status') :"" ;
93        $serachParams['limit']         =   $limit;
94        $serachParams['page']         =   $page;
95
96        $orderBy['orderBy'] = $sortFeild;
97        $orderBy['sortOrder'] = $sortOrder;
98
99       return $this->getPerformanceReviewService()->searchReview($serachParams, $orderBy);
100
101    }
102
103    /**
104     * Returns the set of action buttons associated with each mode of the leave list
105     *
106     * @return array Array of action buttons as instances of ohrmWidegetButton class
107     */
108    public function getSearchActionButtons() {
109        return array(
110            'btnSearch' => new ohrmWidgetButton('btnSearch', 'Search', array()),
111            'btnReset' => new ohrmWidgetButton('btnReset', 'Reset', array('class' => 'reset')),
112        );
113    }
114
115    public function getCountReviewList(){
116        $serachParams ['employeeName'] =  $this->getValue('employeeName');
117        $serachParams ['jobTitleCode'] =  $this->getValue('jobTitleCode');
118        $serachParams ['from'] = (strtotime($this->getValue('fromDate')))? $this->getValue('fromDate') :"";
119        $serachParams ['to'] = (strtotime( $this->getValue('toDate')))?  $this->getValue('toDate') :"";
120        $serachParams ['reviewerId'] = ($this->getValue('reviwerNumber') > 0)?$this->getValue('reviwerNumber'):"";
121        $serachParams['status'] = ($this->getValue('status') > 0 )? $this->getValue('status') :"" ;
122        $serachParams['limit'] = null;
123        return $this->getPerformanceReviewService()->getCountReviewList($serachParams);
124    }
125
126    public function getStylesheets() {
127        $stylesheets = parent::getStylesheets();
128        $stylesheets[plugin_web_path('orangehrmPerformancePlugin','css/searchReviewSuccess.css')] = 'all';
129        return $stylesheets;
130
131    }
132
133}