/
formularze.php
402 lines (343 loc) · 8.39 KB
/
formularze.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
<?php
/**
*
*/
abstract class in_type
{
const text="text";
const password="password";
const hidden="hidden";
}
function form_start($target,$method="post")
{
echo "<form action=\"".$target."\" method=\"".$method."\">";
}
function form_stop($submitname="",$class="normal")
{
echo '<input type="submit" class="'.$class.'" value="'.$submitname.'"/></form>';
}
// function input_add($type,$name,$label="",$value="")
// {
// $val="";
// $lab="";
// if($value!="")
// {
// $val="value=\"".$value."\"";
// }
// if($label!="")
// {
// $lab="<label>".$label."</label>";
// }
// echo $label."<input type=\"".$type."\" name=\"".$name."\"".$val."/>";
// }
function input_add($type,$name,$label="",$value="")
{
return $inputs = array('type' =>$type ,
'name'=>$name,
'label'=>$label,
'value'=>$value
);
}
class form
{
private $struktura ;
public function get(){
return $this->struktura;
}
}
class form_element
{
//private $type='';
private $id=null;
private $name=null;
private $value=null;
private $label=null;
private $dispaly=null;
private $msg=null;
//public function get_type(){return $this->type;}
//public function set_type($val){$this->type=$val;}
public function get_id(){return $this->id;}
public function set_id($val){$this->id=$val;}
public function get_name(){return $this->name;}
public function set_name($val){$this->name=$val;}
public function get_value(){return $this->value;}
public function set_value($val){$this->value=$val;}
public function get_label(){return $this->label;}
public function set_label($val){$this->label=$val;}
public function get_display(){return $this->display;}
public function set_display($val){$this->display=$val;}
public function get_msg(){return $this->msg;}
public function set_msg($val){$this->msg=$val;}
public function disp_filed(){echo 'abstract';}
//abstract public function validate();
public function valid()
{
$err=null;
$index=$this->get_name();
try{
if(!empty($_POST[$index]))
{
$err=null;
}
else
$err=$this->get_label();
}
catch(Exception $e){
}
return $err;
}
public function show()
{
echo $this->label.' ';
echo $this->disp_filed();
$msg=$this->msg;
if($msg!=null){echo '<span class="msg">'.$msg.'</span>';}//wyświtlanie aleru dla błędnie wypełninego pola
$display=$this->dispaly;
if($display=='next'){echo'<br/>'; }//sposób wyświtlania pól obok siebie lub pod sobą
else{echo ' ';}
}
}
class form_input extends form_element
{
private $type='text';
public function set_params($id,$type,$name,$label,$display,$value)
{
$this->set_id($id);
$this->set_name($name);
$this->set_label($label);
$this->set_display($display);
$this->set_value($value);
$this->type=$type;
}
public function disp_filed()
{
echo '<input id="'.$this->get_id().'" ';
echo 'type="'.$this->type.'" ';
echo 'name="'.$this->get_name().'" ';
$val=$this->get_value();
if($val!=null){echo'value="'.$val.'" ';}
echo '/>';
}
// public function valid()
// {
// $veryfy=null;
// $index=$this->get_name();
// try{
// if(!empty($_POST[$index]))
// $veryfy=TRUE;
// else
// $veryfy=FALSE;
// }
// catch(Exception $e){
//
// }
// }
}
class form_select extends form_element
{
private $op_name=null;
private function set_opname($value)
{
$this->op_name=$value;
}
private function get_opname()
{
return $this->op_name;
}
public function set_params($id,$name,$label,$display,$value,$option)
{
$this->set_id($id);
$this->set_name($name);
$this->set_label($label);
$this->set_display($display);
$this->set_value($value);
$this->set_opname($option);
}
public function disp_filed()
{
$values=$this->get_value();
$options=$this->get_opname();
$valsize=sizeof($values);
$valoptions=sizeof($options);
$iter_to=0;
if($valsize<$valoptions)
$iter_to=$valsize;
else
$iter_to=$valoptions;
echo '<select id="'.$this->get_id().'" ';
echo 'name="'.$this->get_name().'"> ';
for($ii=0;$ii<$iter_to;$ii++)
{
echo '<option value="'.$values[$ii].'">'.$options[$ii].'</option>';
}
echo '</select>';
}
// public function valid()
// {
// $index=$this->get_name();
// try{
// if(!empty($_POST[$index]));
// }
// catch(Exception $e){
//
// }
// }
}
function form_wyswietl($tab)
{
foreach($tab as $pole)
{
$pole->show();
}
}
function form_spawdz($tab)
{
$err_tab=array();
foreach($tab as $pole)
{
$val=$pole->valid();
if($val!=null)
{
$err_tab[]=$val;
}
}
return $err_tab;
}
function logowanie()
{
$tab=array();
$pole= new form_input;
$pole->set_params('login',in_type::text,'login','login',null, null);
$tab[]=$pole;
$pole= new form_input;
$pole->set_params('pass',in_type::password,'pass','hasło',null, null);
$tab[]=$pole;
$pole= new form_input;
return $tab;
}
function form_szukaj_narzedzia()
{
$tab=array();
$pole= new form_input;
$pole->set_params('pole',in_type::text,'szukaj_narzedzia','szukaj narzedzia:','next', null);
$tab[]=$pole;
return $tab;
}
function form_admin_doadaj_uzytkownika()
{
$tab=array();
$pole= new form_input;
$pole->set_params('dane',in_type::text,'dane','dane osobowe',null, null);
$tab[]=$pole;
$pole= new form_input;
$pole->set_params('nazwa_uz',in_type::text,'nazwa_uz','nazwa uzytkownika',null, null);
$tab[]=$pole;
$pole= new form_input;
$pole->set_params('pass1',in_type::password,'pass1','hasło',null, null);
$tab[]=$pole;
$pole= new form_input;
$pole->set_params('pass2',in_type::password,'pass2','potwierdz hało',null, null);
$tab[]=$pole;
$pole= new form_input;
$pole->set_params('kontakt',in_type::password,'kontakt','kontakt',null, null);
$tab[]=$pole;
$pole= new form_select;
$values=array('typ1','typ2');
$option=array('pracownik','użytkownik');
$pole->set_params('typ','typ','typ użytkownika',null,$values,$option);
$tab[]=$pole;
return $tab;
}
function form_admin_doadaj_polke()
{
$tab=array();
$pole= new form_input;
$pole->set_params('nazwa_pk',in_type::text,'nazwa_pk','nazwa półki',null, null);
$tab[]=$pole;
$pole= new form_input;
$pole->set_params('hala',in_type::text,'hala','hala',null, null);
$tab[]=$pole;
return $tab;
}
function form_admin_doadaj_hale()
{
$tab=array();
$pole= new form_input;
$pole->set_params('nazwa_hala',in_type::text,'nazwa_hala','nazwa hali',null, null);
$tab[]=$pole;
return $tab;
}
function form_pracownik_wybierz_klienta()
{
$tab=array();
$pole= new form_input;
$pole->set_params('klient',in_type::text,'klient','klient',null, null);
$tab[]=$pole;
return $tab;
}
function form_pracownik_ustaw_klienta()
{
$tab=array();
$pole= new form_input;
$pole->set_params('klient',in_type::hidden,'klient','klient',null, null);
$tab[]=$pole;
}
function form_pracownik_dodaj_narzedzie ()
{
$tab=array();
$pole= new form_input;
$pole->set_params('nazwa',in_type::text,'nazwa','nazwa narzędzia',null, null);
$tab[]=$pole;
$pole= new form_input;
$pole->set_params('hala',in_type::text,'hala','hala',null, null);
$tab[]=$pole;
$pole= new form_input;
$pole->set_params('polka',in_type::text,'polka','pólka',null, null);
$tab[]=$pole;
return $tab;
}
function dform_wyswietl_narzedzia($response)
{
$tab=array();
$pole= new form_input;
$pole->set_params('narzedzie',in_type::hidden,'narzedzie',$response[1],null,$response[0]);
$tab[]=$pole;
return $tab;
}
function dform_wyswietl_uzytkownika($response)
{
$tab=array();
$pole= new form_input;
$pole->set_params('uzytkownik',in_type::hidden,'uzytkownik',$response[3],null,$response[0]);
$tab[]=$pole;
return $tab;
}
function dform_pracownik_wypozyczenia_uz($response)
{
$tab=array();
$pole= new form_input;
$pole->set_params('hidden_id',in_type::hidden,'narzedzie',$response[2],null,$response[0]);
$tab[]=$pole;
$pole= new form_input;
$pole->set_params('hidden_data',in_type::hidden,'data',$response[3],null,null);
$tab[]=$pole;
return $tab;
}
function form_zmien_haslo()
{
$pole= new form_input;
$pole->set_params('passold',in_type::text,'passold','stare hasło',null, null);
$tab[]=$pole;
$pole= new form_input;
$pole->set_params('pass1',in_type::password,'pass1','nowe hasło',null, null);
$tab[]=$pole;
$pole= new form_input;
$pole->set_params('pass2',in_type::password,'pass2','powtórz hasło',null, null);
$tab[]=$pole;
return $tab;
}
function form_pracownik_pokaz_wypozyczenia()
{
echo "jeszcze nie gotowe";
}
?>