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