Skip to content

Commit 75e939f

Browse files
committed
UI/UX upgrade for employee CRUD; photo support for employees
1 parent 793a2d1 commit 75e939f

16 files changed

+391
-1151
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
*.pyg
55
*.aux
66
settings-local.php
7+
uploads

controllers/employee.php

+20-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
<?php
22
class EmployeeController extends Controller{
33
public static function listing( ) {
4-
$employees = Employee::listing( '' );
4+
global $settings;
5+
6+
$employees = Employee::listing();
7+
foreach ( $employees as $i => $employee ) {
8+
if ( !empty( $employee[ 'imageid' ] ) ) {
9+
$url = $settings[ 'uploadurl' ] . $employee[ 'imageid' ] . '.jpg';
10+
$employees[ $i ][ 'imageurl' ] = $url;
11+
}
12+
}
513
view( 'employee/listing', array( 'employees' => $employees ) );
614
}
715
public function createView( $errors, $umn, $ssn, $name, $phone, $addr, $salary, $occ ) {
816
if ( !empty( $umn ) ) {
917
$employee = Employee::item( $umn );
1018
if ( $employee === false ) {
11-
throw new Exception( 'The employee you are trying to edit does not exist' ); }
19+
throw new Exception( 'The employee you are trying to edit does not exist' );
20+
}
1221
if ( empty( $ssn ) ) {
1322
$ssn = $employee[ 'ssn' ];
1423
}
@@ -36,15 +45,15 @@ public static function create( $umn, $ssn, $name, $phone, $addr, $salary, $occ,
3645
}
3746
try {
3847
$employeeid = Employee::create( $umn, $ssn, $name, $phone, $addr, $salary );
39-
if ( !empty( $photo ) ) {
40-
$imageid = imageUpload( $photo[ 'tmp_name' ] );
41-
}
42-
Employee::update( $umn, $ssn, $name, $phone, $addr, $salary, $imageid );
4348
}
4449
catch ( Duplicate $e ) {
4550
$errors[] = 'duplicate';
4651
Redirect( 'employee/create?errors=' . implode( ',', $errors ) . '&name=' . $name . '&phone=' . $phone . '&addr=' . $addr . '&salary=' . $salary );
4752
}
53+
if ( !empty( $photo ) ) {
54+
$imageid = Image::create( $photo[ 'tmp_name' ], 130, 130 );
55+
Employee::update( $umn, false, false, false, false, false, $imageid );
56+
}
4857
if ( $occ == 'tech' ) {
4958
Tech::create( $umn );
5059
Redirect( 'tech/listing' );
@@ -64,13 +73,17 @@ public static function delete( $umn ) {
6473
Employee::delete( $umn );
6574
Redirect( 'employee/listing' );
6675
}
67-
public static function update( $umn, $ssn, $name, $phone, $addr, $salary ) {
76+
public static function update( $umn, $ssn, $name, $phone, $addr, $salary, $photo ) {
6877
$vars = compact( 'umn', 'ssn', 'name', 'phone', 'addr', 'salary' );
6978
$errors = Controller::validateInput( $vars );
7079
if ( !empty( $errors ) ) {
7180
Redirect( 'employee/create?errors=' . implode( ',', $errors ) . '&' . Controller::paramURL( $vars ) );
7281
}
7382
Employee::update( $umn, $ssn, $name, $phone, $addr, $salary );
83+
if ( !empty( $photo ) ) {
84+
$imageid = Image::create( $photo[ 'tmp_name' ], 130, 130 );
85+
Employee::update( $umn, false, false, false, false, false, $imageid );
86+
}
7487
Redirect( 'employee/listing' );
7588
}
7689
}

controllers/regulator.php

-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
<?php
22
class regulatorController extends Controller {
3-
public static function listing() {
4-
$regulators = Regulator::listing();
5-
view( 'regulator/listing', array( 'regulators' => $regulators ) );
6-
}
73
public static function delete( $umn ) {
84
$vars = compact( 'umn' );
95
$errors = Controller::validateInput( $vars );

controllers/tech.php

-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
<?php
22
class TechController extends Controller{
3-
public static function listing() {
4-
$techs = Tech::listing();
5-
view( 'tech/listing', array( 'techs' => $techs ) );
6-
}
7-
public function createView( $errors ) {
8-
Redirect( 'employee/create' );
9-
}
103
public static function delete( $umn ) {
114
$vars = compact( 'umn' );
125
$errors = Controller::validateInput( $vars );
@@ -16,8 +9,5 @@ public static function delete( $umn ) {
169
Tech::delete( $umn );
1710
Redirect( 'tech/listing' );
1811
}
19-
public static function update( $umn ) {
20-
Redirect( 'employee/create?umn=' . $umn );
21-
}
2212
}
2313
?>

css/form.css

+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
input.error, select.error {
2+
color: red;
3+
font-weight: bold;
4+
border: 2px solid red;
5+
}
6+
a.update, form.delete input {
7+
background: transparent url( '../images/edit.png' ) no-repeat;
8+
border: none;
9+
color: transparent;
10+
display: block;
11+
width: 16px;
12+
height: 16px;
13+
float: left;
14+
padding: 0 5px;
15+
cursor: pointer;
16+
overflow: hidden;
17+
}
18+
form.delete input {
19+
background-image: url( '../images/delete.png' );
20+
}
21+
form .actions a.cancel {
22+
float: right;
23+
display: block;
24+
border: 1px solid #999;
25+
border-bottom-color: #888;
26+
color: #333;
27+
background-color: #eee;
28+
font-size: 70%;
29+
padding: 4px;
30+
border-radius: 2px;
31+
margin: 5px 0;
32+
width: 60px;
33+
text-align: center;
34+
font-weight: bold;
35+
background-image: -webkit-linear-gradient(top, #fff, #ddd);
36+
background-image: -moz-linear-gradient(top, #fff, #ddd);
37+
background-image: linear-gradient(top, #fff, #ddd);
38+
}
39+
a.cancel:hover {
40+
text-decoration: none;
41+
}
42+
div.ui-datepicker {
43+
font-size: 75%;
44+
}
45+
form input[type=text], form input[type=file], form select {
46+
width: 200px;
47+
border: 1px solid #bdc7d8;
48+
border-radius: 4px;
49+
padding: 4px;
50+
}
51+
form select {
52+
width: 210px;
53+
}
54+
form div.actions {
55+
border-bottom: none;
56+
background-color: white;
57+
}
58+
form div.eof {
59+
border-bottom: none;
60+
}
61+
p.create a {
62+
padding-left: 20px;
63+
background-image: url( '../images/add.png' );
64+
background-repeat: no-repeat;
65+
background-position: left;
66+
}
67+
label {
68+
float: left;
69+
display: block;
70+
width: 200px;
71+
padding: 5px 5px;
72+
text-align: right;
73+
font-size: 80%;
74+
font-weight: bold;
75+
color: #555;
76+
}
77+
form {
78+
border: 1px solid #ccc;
79+
width: 425px;
80+
}
81+
form.delete {
82+
border: none;
83+
width: auto;
84+
}
85+
form div {
86+
padding: 5px 0;
87+
border-bottom: 1px solid #ccc;
88+
}
89+
form div:nth-child(even) {
90+
background-color: #f5f5f5;
91+
}
92+
form .actions {
93+
margin: 0 100px;
94+
}
95+
form .actions input[type=submit] {
96+
margin: 5px auto;
97+
display: block;
98+
width: 150px;
99+
padding: 5px;
100+
background-color: #4d90fe;
101+
color: white;
102+
border: 1px solid #3079ED;
103+
background-image: -webkit-linear-gradient(top, #4d90fe, #4787ed);
104+
background-image: -moz-linear-gradient(top, #4d90fe, #4787ed);
105+
background-image: linear-gradient(top, #4d90fe, #4787ed);
106+
border-radius: 2px;
107+
cursor: pointer;
108+
font-weight: bold;
109+
font-size: 70%;
110+
text-shadow: 1px 1px 1px #2f5bb7;
111+
float: left;
112+
}
113+
form .actions input[type=submit]:hover {
114+
background-image: -webkit-linear-gradient(top, #4d90fe, #357ae8);
115+
background-image: -moz-linear-gradient(top, #4d90fe, #357ae8);
116+
background-image: linear-gradient(top, #4d90fe, #357ae8);
117+
border: 1px solid #2f5bb7;
118+
}
119+
form .actions a.cancel:hover {
120+
background-image: -webkit-linear-gradient(top, #fff, #d0d0d0);
121+
background-image: -moz-linear-gradient(top, #fff, #d0d0d0);
122+
background-image: linear-gradient(top, #fff, #d0d0d0);
123+
}

css/person.css

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
ul.person {
2+
list-style: none;
3+
padding: 0;
4+
margin: 0;
5+
}
6+
ul.person li {
7+
float: left;
8+
width: 400px;
9+
height: 98px;
10+
overflow: hidden;
11+
border: 1px solid #c4cde0;
12+
border-radius: 3px;
13+
margin: 5px 5px 0 0;
14+
padding: 5px;
15+
position: relative;
16+
}
17+
ul.person h3 {
18+
margin: 0;
19+
font-size: 100%;
20+
}
21+
ul.person img {
22+
border-radius: 3px;
23+
float: left;
24+
margin-right: 5px;
25+
max-width: 100px;
26+
max-height: 98px;
27+
}
28+
ul.person .delete {
29+
position: absolute;
30+
top: 0;
31+
right: 0;
32+
padding: 5px;
33+
display: none;
34+
}
35+
ul.person li {
36+
background-image: linear-gradient(bottom, rgb(245,247,250) 0%, rgb(255,255,255) 80%);
37+
background-image: -o-linear-gradient(bottom, rgb(245,247,250) 0%, rgb(255,255,255) 80%);
38+
background-image: -moz-linear-gradient(bottom, rgb(245,247,250) 0%, rgb(255,255,255) 80%);
39+
background-image: -webkit-linear-gradient(bottom, rgb(245,247,250) 0%, rgb(255,255,255) 80%);
40+
background-image: -ms-linear-gradient(bottom, rgb(245,247,250) 0%, rgb(255,255,255) 80%);
41+
42+
background-image: -webkit-gradient(
43+
linear,
44+
left bottom,
45+
left top,
46+
color-stop(0, rgb(245,247,250)),
47+
color-stop(0.8, rgb(255,255,255))
48+
);
49+
}
50+
ul.person li:hover .delete {
51+
display: block;
52+
}
53+
ul.person li div {
54+
border-bottom: 1px solid #eee;
55+
padding: 4px 0 4px 0;
56+
}
57+
ul.person li div:last-child {
58+
border-bottom: none;
59+
padding-bottom: 0;
60+
}
61+
ul.person li strong {
62+
float: left;
63+
width: 70px;
64+
text-align: left;
65+
padding-right: 5px;
66+
color: #999;
67+
font-size: 80%;
68+
display: block;
69+
}
70+
ul.person li span {
71+
color: #333;
72+
font-size: 80%;
73+
display: block;
74+
}
75+
ul.person form.delete input {
76+
background: none;
77+
border: none;
78+
color: black;
79+
display: block;
80+
width: 16px;
81+
height: 16px;
82+
float: left;
83+
padding: 0 5px;
84+
cursor: pointer;
85+
overflow: hidden;
86+
font-size: 100%;
87+
}
88+
ul.person li.create {
89+
padding-top: 42px;
90+
padding-bottom: 42px;
91+
text-align: center;
92+
height: 24px;
93+
border: none;
94+
background: none;
95+
font-weight: bold;
96+
}
97+
ul.person li.create a {
98+
background: transparent url( '../images/add.png' ) no-repeat 0 4px;
99+
padding-left: 24px;
100+
}

0 commit comments

Comments
 (0)