Code Duplication    Length = 150-152 lines in 2 locations

src/records/create.php 1 location

@@ 567-718 (lines=152) @@
564
                        : NULL)
565
                  . '>';
566
567
            switch ($row['field_type'])
568
            {
569
                case FIELD_TYPE_NUMBER:
570
571
                    $xml .= '<label>' . ustr2html($row['field_name']) . '</label>';
572
573
                    $xml .= '<editbox maxlen="' . (ustrlen(MAX_FIELD_INTEGER) + 1) . '">'
574
                          . ustr2html(try_request($name, $value))
575
                          . '</editbox>';
576
577
                    $notes .= '<note>'
578
                            . ustrprocess(get_html_resource(RES_ALERT_FIELD_VALUE_OUT_OF_RANGE_ID), ustr2html($row['field_name']), $row['param1'], $row['param2'])
579
                            . '</note>';
580
581
                    break;
582
583
                case FIELD_TYPE_FLOAT:
584
585
                    $xml .= '<label>' . ustr2html($row['field_name']) . '</label>';
586
587
                    $xml .= '<editbox maxlen="' . ustrlen(MAX_FIELD_FLOAT) . '">'
588
                          . ustr2html(try_request($name, $value))
589
                          . '</editbox>';
590
591
                    $notes .= '<note>'
592
                            . ustrprocess(get_html_resource(RES_ALERT_FIELD_VALUE_OUT_OF_RANGE_ID),
593
                                          ustr2html($row['field_name']),
594
                                          value_find(FIELD_TYPE_FLOAT, $row['param1']),
595
                                          value_find(FIELD_TYPE_FLOAT, $row['param2']))
596
                            . '</note>';
597
598
                    break;
599
600
                case FIELD_TYPE_STRING:
601
602
                    $xml .= '<label>' . ustr2html($row['field_name']) . '</label>';
603
604
                    $xml .= '<editbox maxlen="' . $row['param1'] . '">'
605
                          . ustr2html(try_request($name, $value))
606
                          . '</editbox>';
607
608
                    $flag = TRUE;
609
610
                    break;
611
612
                case FIELD_TYPE_MULTILINED:
613
614
                    $xml .= '<label>' . ustr2html($row['field_name']) . '</label>';
615
616
                    $xml .= '<textbox rows="' . $_SESSION[VAR_TEXTROWS] . '" maxlen="' . MAX_FIELD_MULTILINED . '">'
617
                          . ustr2html(try_request($name, $value))
618
                          . '</textbox>';
619
620
                    $flag = TRUE;
621
622
                    break;
623
624
                case FIELD_TYPE_CHECKBOX:
625
626
                    $user_value = (try_request('submitted') == 'mainform')
627
                                ? isset($_REQUEST[$name])
628
                                : $value;
629
630
                    $xml .= '<label/>';
631
632
                    $xml .= ($user_value
633
                                ? '<checkbox checked="true">'
634
                                : '<checkbox>')
635
                          . ustr2html($row['field_name'])
636
                          . '</checkbox>';
637
638
                    break;
639
640
                case FIELD_TYPE_LIST:
641
642
                    $selected = try_request($name, $value);
643
644
                    $xml .= '<label>' . ustr2html($row['field_name']) . '</label>';
645
646
                    $xml .= '<combobox>'
647
                          . '<listitem value=""/>';
648
649
                    $rsv = dal_query('values/lvlist.sql', $row['field_id']);
650
651
                    while (($item = $rsv->fetch()))
652
                    {
653
                        $xml .= ($selected == $item['int_value']
654
                                    ? '<listitem value="' . $item['int_value'] . '" selected="true">'
655
                                    : '<listitem value="' . $item['int_value'] . '">')
656
                              . ustr2html($item['str_value'])
657
                              . '</listitem>';
658
                    }
659
660
                    $xml .= '</combobox>';
661
662
                    break;
663
664
                case FIELD_TYPE_RECORD:
665
666
                    $xml .= '<label>' . ustr2html($row['field_name']) . '</label>';
667
668
                    $xml .= '<editbox maxlen="' . ustrlen(MAXINT) . '">'
669
                          . ustr2html(try_request($name, $value))
670
                          . '</editbox>';
671
672
                    $notes .= '<note>'
673
                            . ustrprocess(get_html_resource(RES_ALERT_FIELD_VALUE_OUT_OF_RANGE_ID), ustr2html($row['field_name']), 1, MAXINT)
674
                            . '</note>';
675
676
                    break;
677
678
                case FIELD_TYPE_DATE:
679
680
                    $today = time();
681
682
                    $row['param1'] = date_offset($today, $row['param1']);
683
                    $row['param2'] = date_offset($today, $row['param2']);
684
685
                    $xml .= '<label>' . sprintf('%s (%s)', ustr2html($row['field_name']), get_date_format_str()) . '</label>';
686
687
                    $xml .= '<editbox maxlen="' . ustrlen(get_date(SAMPLE_DATE)) . '">'
688
                          . ustr2html(try_request($name, $value))
689
                          . '</editbox>';
690
691
                    $notes .= '<note>'
692
                            . ustrprocess(get_html_resource(RES_ALERT_FIELD_VALUE_OUT_OF_RANGE_ID), ustr2html($row['field_name']), get_date($row['param1']), get_date($row['param2']))
693
                            . '</note>';
694
695
                    $script .= '<onready>'
696
                             . '$("#' . $name . '").datepicker($.datepicker.regional["' . $_SESSION[VAR_LOCALE] . '"]);'
697
                             . '</onready>';
698
699
                    break;
700
701
                case FIELD_TYPE_DURATION:
702
703
                    $xml .= '<label>' . ustr2html($row['field_name']) . '</label>';
704
705
                    $xml .= '<editbox maxlen="' . ustrlen(time2ustr(MAX_FIELD_DURATION)) . '">'
706
                          . ustr2html(try_request($name, $value))
707
                          . '</editbox>';
708
709
                    $notes .= '<note>'
710
                            . ustrprocess(get_html_resource(RES_ALERT_FIELD_VALUE_OUT_OF_RANGE_ID), ustr2html($row['field_name']), time2ustr($row['param1']), time2ustr($row['param2']))
711
                            . '</note>';
712
713
                    break;
714
715
                default:
716
717
                    debug_write_log(DEBUG_WARNING, 'Unknown field type = ' . $row['field_type']);
718
            }
719
720
            if (ustrlen($row['description']) != 0)
721
            {

src/records/modify.php 1 location

@@ 215-364 (lines=150) @@
212
                        : NULL)
213
                  . '>';
214
215
            switch ($field['field_type'])
216
            {
217
                case FIELD_TYPE_NUMBER:
218
219
                    $xml .= '<label>' . ustr2html($field['field_name']) . '</label>';
220
221
                    $xml .= '<editbox maxlen="' . (ustrlen(MAX_FIELD_INTEGER) + 1) . '">'
222
                          . ustr2html(try_request($name, $value))
223
                          . '</editbox>';
224
225
                    $notes .= '<note>'
226
                            . ustrprocess(get_html_resource(RES_ALERT_FIELD_VALUE_OUT_OF_RANGE_ID), ustr2html($field['field_name']), $field['param1'], $field['param2'])
227
                            . '</note>';
228
229
                    break;
230
231
                case FIELD_TYPE_FLOAT:
232
233
                    $xml .= '<label>' . ustr2html($field['field_name']) . '</label>';
234
235
                    $xml .= '<editbox maxlen="' . ustrlen(MAX_FIELD_FLOAT) . '">'
236
                          . ustr2html(try_request($name, $value))
237
                          . '</editbox>';
238
239
                    $notes .= '<note>'
240
                            . ustrprocess(get_html_resource(RES_ALERT_FIELD_VALUE_OUT_OF_RANGE_ID),
241
                                          ustr2html($field['field_name']),
242
                                          value_find(FIELD_TYPE_FLOAT, $field['param1']),
243
                                          value_find(FIELD_TYPE_FLOAT, $field['param2']))
244
                            . '</note>';
245
246
                    break;
247
248
                case FIELD_TYPE_STRING:
249
250
                    $xml .= '<label>' . ustr2html($field['field_name']) . '</label>';
251
252
                    $xml .= '<editbox maxlen="' . $field['param1'] . '">'
253
                          . ustr2html(try_request($name, $value))
254
                          . '</editbox>';
255
256
                    $flag = TRUE;
257
258
                    break;
259
260
                case FIELD_TYPE_MULTILINED:
261
262
                    $xml .= '<label>' . ustr2html($field['field_name']) . '</label>';
263
264
                    $xml .= '<textbox rows="' . $_SESSION[VAR_TEXTROWS] . '" maxlen="' . MAX_FIELD_MULTILINED . '">'
265
                          . ustr2html(try_request($name, $value))
266
                          . '</textbox>';
267
268
                    $flag = TRUE;
269
270
                    break;
271
272
                case FIELD_TYPE_CHECKBOX:
273
274
                    $user_value = (try_request('submitted') == 'mainform')
275
                                ? isset($_REQUEST[$name])
276
                                : $value;
277
278
                    $xml .= '<label/>';
279
280
                    $xml .= ($user_value
281
                                ? '<checkbox checked="true">'
282
                                : '<checkbox>')
283
                          . ustr2html($field['field_name'])
284
                          . '</checkbox>';
285
286
                    break;
287
288
                case FIELD_TYPE_LIST:
289
290
                    $selected = try_request($name, $value);
291
292
                    $xml .= '<label>' . ustr2html($field['field_name']) . '</label>';
293
294
                    $xml .= '<combobox>'
295
                          . '<listitem value=""/>';
296
297
                    $list = dal_query('values/lvlist.sql', $field['field_id']);
298
299
                    while (($item = $list->fetch()))
300
                    {
301
                        $xml .= ($selected == $item['int_value']
302
                                    ? '<listitem value="' . $item['int_value'] . '" selected="true">'
303
                                    : '<listitem value="' . $item['int_value'] . '">')
304
                              . ustr2html($item['str_value'])
305
                              . '</listitem>';
306
                    }
307
308
                    $xml .= '</combobox>';
309
310
                    break;
311
312
                case FIELD_TYPE_RECORD:
313
314
                    $xml .= '<label>' . ustr2html($field['field_name']) . '</label>';
315
316
                    $xml .= '<editbox maxlen="' . ustrlen(MAXINT) . '">'
317
                          . ustr2html(try_request($name, $value))
318
                          . '</editbox>';
319
320
                    $notes .= '<note>'
321
                            . ustrprocess(get_html_resource(RES_ALERT_FIELD_VALUE_OUT_OF_RANGE_ID), ustr2html($field['field_name']), 1, MAXINT)
322
                            . '</note>';
323
324
                    break;
325
326
                case FIELD_TYPE_DATE:
327
328
                    $event_time = $state['event_time'];
329
330
                    $field['param1'] = date_offset($event_time, $field['param1']);
331
                    $field['param2'] = date_offset($event_time, $field['param2']);
332
333
                    $xml .= '<label>' . sprintf('%s (%s)', ustr2html($field['field_name']), get_date_format_str()) . '</label>';
334
335
                    $xml .= '<editbox maxlen="' . ustrlen(get_date(SAMPLE_DATE)) . '">'
336
                          . ustr2html(try_request($name, $value))
337
                          . '</editbox>';
338
339
                    $notes .= '<note>'
340
                            . ustrprocess(get_html_resource(RES_ALERT_FIELD_VALUE_OUT_OF_RANGE_ID), ustr2html($field['field_name']), get_date($field['param1']), get_date($field['param2']))
341
                            . '</note>';
342
343
                    $script .= '$("#' . $name . '").datepicker($.datepicker.regional["' . $_SESSION[VAR_LOCALE] . '"]);';
344
345
                    break;
346
347
                case FIELD_TYPE_DURATION:
348
349
                    $xml .= '<label>' . ustr2html($field['field_name']) . '</label>';
350
351
                    $xml .= '<editbox maxlen="' . ustrlen(time2ustr(MAX_FIELD_DURATION)) . '">'
352
                          . ustr2html(try_request($name, $value))
353
                          . '</editbox>';
354
355
                    $notes .= '<note>'
356
                            . ustrprocess(get_html_resource(RES_ALERT_FIELD_VALUE_OUT_OF_RANGE_ID), ustr2html($field['field_name']), time2ustr($field['param1']), time2ustr($field['param2']))
357
                            . '</note>';
358
359
                    break;
360
361
                default:
362
363
                    debug_write_log(DEBUG_WARNING, 'Unknown field type = ' . $field['field_type']);
364
            }
365
366
            if (ustrlen($field['description']) != 0)
367
            {