Source for file worktype.class.php

Documentation is available at worktype.class.php


1 <?php
2 /**
3 * class Worktype
4 *
5 * @category phpTimeSheet
6 * @package phpTimeSheet
7 * @version $Id: worktype.class.php,v 1.3 2003/09/25 14:08:27 cybot_tm Exp $
8 * @author Sebastian Mendel <info@sebastianmendel.de>
9 */
10
11
12 /**
13 * Class Worktype, reflects access to Table worker_time_worktype
14 *
15 * @package phpTimeSheet
16 */
17 class Worktype
18 {
19 /**
20 * @var int id
21 * @access protected
22 * @since v1.0
23 */
24 var $id = 0;
25
26 /**
27 * @var string name
28 * @access protected
29 * @since v1.0
30 */
31 var $name = 0;
32
33 /**
34 * @var double time_count
35 * @access protected
36 * @since v1.0
37 */
38 var $time_count = 0;
39
40 /**
41 * @var double holiday_count
42 * @access protected
43 * @since v1.0
44 */
45 var $holiday_count = 0;
46
47 /**
48 * expects Time in form of seconds as int
49 * or in form H:M[:S[.M]] as string
50 * or null, if $time is is null then current time is taken
51 *
52 * @param mixed Time
53 * @return bool success
54 * @since v1.0
55 */
56 function Worktype($worktype_id = null)
57 {
58 $this->SetId($worktype_id);
59 return true;
60 }
61
62 /**
63 * returns id
64 *
65 * @return int id
66 * @since v1.0
67 */
68 function GetId() { return $this->id; }
69
70 /**
71 * returns name
72 *
73 * @return string name
74 * @since v1.0
75 */
76 function GetName() { return $this->name; }
77
78 /**
79 * returns time_count
80 *
81 * @return double minutes
82 * @since v1.0
83 */
84 function GetTimeCount() { return $this->time_count; }
85
86 /**
87 * returns holiday_count
88 *
89 * @return double seconds
90 * @since v1.4
91 */
92 function GetHolidayCount() { return $this->holiday_count; }
93
94 /**
95 * sets id, returns true on success, otherwise false
96 *
97 * @param int $worktype_id
98 * @return bool success
99 * @since v1.0
100 */
101 function SetId($worktype_id)
102 {
103 $this->id = (int) $worktype_id;
104 return true;
105 }
106
107 /**
108 * sets name, returns true on success, otherwise false
109 *
110 * @param string name
111 * @return bool success
112 * @since v1.0
113 */
114 function SetName($name)
115 {
116 $this->name = (string) $name;
117 return true;
118 }
119
120 /**
121 * sets time_count, returns true on success, otherwise false
122 *
123 * @param double time_count
124 * @return bool success
125 * @since v1.0
126 */
127 function SetTimeCount($time_count)
128 {
129 $this->time_count = (double) $time_count;
130 return true;
131 }
132
133 /**
134 * sets holiday_count, returns true on success, otherwise false
135 *
136 * @param double holiday_count
137 * @return bool success
138 * @since v1.0
139 */
140 function SetHolidayCount($holiday_count)
141 {
142 $this->holiday_count = (double) $holiday_count;
143 return true;
144 }
145
146 /**
147 * returns HTML-code for selectbox with all worktypes
148 *
149 * @static
150 * @param int selected_worktype_id
151 * @return string htmlcode
152 * @since v1.0
153 */
154 function GetSelectBox($selected_worktype_id = null)
155 {
156 global $str
157 $sql = 'SELECT `id`, `name` FROM `' . PTS_TBL_WORKTYPE . '` ORDER BY `name`';
158 $result = mysql_query($sql) or die('<pre>' . __FILE__ . ': ' . __LINE__ . "\n" . __CLASS__ . '::' . __FUNCTION__ . "\n" . $sql . "\n" . mysql_error());
159
160 $selectbox = '<select name="worktype_id">';
161 while ( $row = mysql_fetch_assoc($result) )
162 {
163 if ( $selected_worktype_id == $row['id'] )
164 {
165 $selected = ' selected="selected"';
166 }
167 else
168 {
169 $selected = '';
170 }
171 $selectbox .= '<option value="' . $row['id'] . '"' . $selected . ' class="WORK' . $row['id'] . '">' . $str[$row['name']] . '</option>';
172 }
173 $selectbox .= '</select>';
174
175 return $selectbox;
176 }
177 }
178 ?>

Documentation generated on Fri, 26 Sep 2003 15:40:28 +0200 by phpDocumentor 1.2.2