Passed
Push — scrutinizer-code-quality ( 09f5a1...c4c5fb )
by Adam
56:05 queued 14:08
created

EmployeesViewEdit::EmployeesViewEdit()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 1 Features 1
Metric Value
cc 2
eloc 7
c 1
b 1
f 1
nc 2
nop 0
dl 0
loc 10
ccs 0
cts 10
cp 0
crap 6
rs 9.4285
1
<?php
2
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3
4
/*********************************************************************************
5
 * SugarCRM Community Edition is a customer relationship management program developed by
6
 * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
7
8
 * SuiteCRM is an extension to SugarCRM Community Edition developed by Salesagility Ltd.
9
 * Copyright (C) 2011 - 2014 Salesagility Ltd.
10
 *
11
 * This program is free software; you can redistribute it and/or modify it under
12
 * the terms of the GNU Affero General Public License version 3 as published by the
13
 * Free Software Foundation with the addition of the following permission added
14
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
15
 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
16
 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
17
 *
18
 * This program is distributed in the hope that it will be useful, but WITHOUT
19
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20
 * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
21
 * details.
22
 *
23
 * You should have received a copy of the GNU Affero General Public License along with
24
 * this program; if not, see http://www.gnu.org/licenses or write to the Free
25
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26
 * 02110-1301 USA.
27
 *
28
 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
29
 * SW2-130, Cupertino, CA 95014, USA. or at email address [email protected].
30
 *
31
 * The interactive user interfaces in modified source and object code versions
32
 * of this program must display Appropriate Legal Notices, as required under
33
 * Section 5 of the GNU Affero General Public License version 3.
34
 *
35
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
36
 * these Appropriate Legal Notices must retain the display of the "Powered by
37
 * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not
38
 * reasonably feasible for  technical reasons, the Appropriate Legal Notices must
39
 * display the words  "Powered by SugarCRM" and "Supercharged by SuiteCRM".
40
 ********************************************************************************/
41
42
43
class EmployeesViewEdit extends ViewEdit {
44
    var $useForSubpanel = true;
45
 	function __construct(){
46
 		parent::__construct();
47
 	}
48
49
    /**
50
     * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
51
     */
52
    function EmployeesViewEdit(){
53
        $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
54
        if(isset($GLOBALS['log'])) {
55
            $GLOBALS['log']->deprecated($deprecatedMessage);
56
        }
57
        else {
58
            trigger_error($deprecatedMessage, E_USER_DEPRECATED);
59
        }
60
        self::__construct();
61
    }
62
63
64
 	function display() {
65
       	if(is_admin($GLOBALS['current_user'])) {
66
            $json = getJSONobj();
67
            require_once('include/QuickSearchDefaults.php');
68
            $qsd = QuickSearchDefaults::getQuickSearchDefaults();
69
            $sqs_objects = array('EditView_reports_to_name' => $qsd->getQSUser());
70
            $sqs_objects['EditView_reports_to_name']['populate_list'] = array('reports_to_name', 'reports_to_id');
71
            $quicksearch_js = '<script type="text/javascript" language="javascript">sqs_objects = ' . $json->encode($sqs_objects) . '; enableQS();</script>';
72
73
            $this->ss->assign('REPORTS_TO_JS', $quicksearch_js);
74
			$this->ss->assign('EDIT_REPORTS_TO', true);
75
        }
76
77
78
       //retrieve employee bean if it is not already in focus
79
         if(empty($this->bean->id)  && !empty($_REQUEST['record'])){
80
            $this->bean->retrieve($_REQUEST['record']);
81
         }
82
         //populate values for non admin users
83
        if(!empty($this->bean->id)) {
84
            global $app_list_strings;
85
            if( !empty($this->bean->status) ) {
86
                $this->ss->assign('STATUS_READONLY',$app_list_strings['user_status_dom'][$this->bean->status]); }
87
            if( !empty($this->bean->employee_status) ) {
88
                $this->ss->assign('EMPLOYEE_STATUS_READONLY', $app_list_strings['employee_status_dom'][$this->bean->employee_status]);
89
            }
90
            if( !empty($this->bean->reports_to_id) ) {
91
                $reportsToUser = get_assigned_user_name($this->bean->reports_to_id);
92
                $reportsToUserField = "<input type='text' name='reports_to_name' id='reports_to_name' value='{$reportsToUser}' disabled>\n";
93
                $reportsToUserField .= "<input type='hidden' name='reports_to_id' id='reports_to_id' value='{$this->bean->reports_to_id}'>";
94
                $this->ss->assign('REPORTS_TO_READONLY', $reportsToUserField);
95
            }
96
            if( !empty($this->bean->title) ) {
97
                $this->ss->assign('TITLE_READONLY', $this->bean->title);
98
            }
99
            if( !empty($this->bean->department) ) {
100
                $this->ss->assign('DEPT_READONLY', $this->bean->department);
101
            }
102
        }
103
104
 		parent::display();
105
 	}
106
}
107
?>
108