1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15:
16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
17:
18: function frontendusers_valid_from_getTitle ()
19: {
20: return i18n("Valid from");
21: }
22:
23: function frontendusers_valid_from_display()
24: {
25: global $feuser,$db,$belang,$cfg;
26:
27: $langscripts = '';
28:
29: if (($lang_short = substr(strtolower($belang), 0, 2)) != "en") {
30: $langscripts= '<script type="text/javascript" src="scripts/jquery/plugins/timepicker-'.$lang_short.'.js"></script>
31: <script type="text/javascript" src="scripts/jquery/plugins/datepicker-'.$lang_short.'.js"></script>';
32: }
33:
34: $path_to_calender_pic = cRegistry::getBackendUrl() . $cfg['path']['images'] . 'calendar.gif';
35:
36: $template = '%s';
37:
38: $currentValue = $feuser->get("valid_from");
39:
40: if ($currentValue == '') {
41: $currentValue = '0000-00-00';
42: }
43: $currentValue = str_replace('00:00:00', '', $currentValue);
44:
45: $sValidFrom = ' <link rel="stylesheet" type="text/css" href="styles/jquery/plugins/timepicker.css">
46: <link rel="stylesheet" type="text/css" href="styles/jquery/jquery-ui.css">
47: <script type="text/javascript" src="scripts/jquery/jquery.js"></script>
48: <script type="text/javascript" src="scripts/jquery/jquery-ui.js"></script>
49: <script type="text/javascript" src="scripts/jquery/plugins/timepicker.js"></script>';
50: $sValidFrom .= $langscripts;
51:
52: $sValidFrom .= '<input type="text" id="valid_from" name="valid_from" value="'.$currentValue.'">';
53: $sValidFrom .= '<script type="text/javascript">
54:
55: $(document).ready(function() {
56: $("#valid_from").datetimepicker({
57: buttonImage:"'. $path_to_calender_pic.'",
58: buttonImageOnly: true,
59: showOn: "both",
60: dateFormat: "yy-mm-dd",
61: onClose: function(dateText, inst) {
62: var endDateTextBox = $("#valid_to");
63: if (endDateTextBox.val() != "") {
64: var testStartDate = new Date(dateText);
65: var testEndDate = new Date(endDateTextBox.val());
66: if (testStartDate > testEndDate)
67: endDateTextBox.val(dateText);
68: }
69: else {
70: endDateTextBox.val(dateText);
71: }
72: },
73: onSelect: function (selectedDateTime) {
74: var start = $(this).datetimepicker("getDate");
75: $("#valid_to").datetimepicker("option", "minDate", new Date(start.getTime()));
76: }
77: });
78:
79: });
80: </script>';
81:
82: return sprintf($template,$sValidFrom);
83: }
84:
85: function frontendusers_valid_from_wantedVariables ()
86: {
87: return (array("valid_from"));
88: }
89:
90: function frontendusers_valid_from_store ($variables)
91: {
92: global $feuser;
93:
94: $feuser->set("valid_from", $variables["valid_from"], false);
95: }
96: ?>
97: