-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddedit.php
More file actions
165 lines (147 loc) · 6.11 KB
/
Copy pathaddedit.php
File metadata and controls
165 lines (147 loc) · 6.11 KB
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
<?php
##
## holiday module - A dotProject module for keeping track of holidays
##
## Sensorlink AS (c) 2006
## Vegard Fiksdal (fiksdal@sensorlink.no)
##
$holiday_id = defVal( @$_GET["holiday_id"], 0);
$holiday_white = defVal( @$_GET["white"], -1);
// Create date objects
$log_start_date = dPgetParam( $_POST, "log_start_date", 0 );
$log_end_date = dPgetParam( $_POST, "log_end_date", 0 );
$start_date = intval( $log_start_date ) ? new CDate( $log_start_date ) : new CDate();
$end_date = intval( $log_end_date ) ? new CDate( $log_end_date ) : new CDate();
$holiday_description = dPgetParam( $_POST, "holiday_description", '');
$holiday_annual = dPgetParam( $_POST, "holiday_annual", 0);
$action = @$_REQUEST["action"];
if($action) {
if( $action == "add" ) {
$sql = "INSERT INTO holiday (holiday_description,holiday_start_date,holiday_end_date,holiday_white,holiday_annual) ";
$sql.= "VALUES ('";
$sql.= $holiday_description;
$sql.= "','";
$sql.= $start_date->format(FMT_DATETIME_MYSQL);
$sql.= "','";
$sql.= $end_date->format(FMT_DATETIME_MYSQL);
$sql.= "','";
$sql.= $holiday_white;
$sql.= "','";
$sql.= $holiday_annual;
$sql.= "')";
$okMsg = "Holiday registered";
} else if ( $action == "update" ) {
$sql = "UPDATE holiday SET ";
$sql.= "holiday_description = '" . $holiday_description . "', ";
$sql.= "holiday_start_date = '" . $start_date->format(FMT_DATETIME_MYSQL) . "', ";
$sql.= "holiday_end_date = '" . $end_date->format(FMT_DATETIME_MYSQL) . "', ";
$sql.= "holiday_annual = '" . $holiday_annual . "' ";
$sql.= "WHERE holiday_id = " . $holiday_id;
$okMsg = "Holiday updated";
}
else if ( $action == "del" ) {
$sql = "DELETE FROM holiday WHERE holiday_id = ".$holiday_id;
$okMsg = "Holiday removed";
}
if(!db_exec($sql)) {
$AppUI->setMsg( db_error() );
} else {
$AppUI->setMsg( $okMsg );
}
$AppUI->redirect();
}
// pull the holiday from the database
db_loadHash( "SELECT * FROM holiday WHERE holiday_id = $holiday_id", $holiday );
if($holiday_white == -1)
{
$holiday_white = $holiday['holiday_white'];
}
?>
<script language="javascript">
var calendarField = '';
function popCalendar( field ){
calendarField = field;
idate = eval( 'document.AddEdit.log_' + field + '.value' );
window.open( 'index.php?m=public&a=calendar&dialog=1&callback=setCalendar&date=' + idate, 'calwin', 'width=250, height=220, scollbars=false' );
}
function setCalendar( idate, fdate ) {
fld_date = eval( 'document.AddEdit.log_' + calendarField );
fld_fdate = eval( 'document.AddEdit.' + calendarField );
fld_date.value = idate;
fld_fdate.value = fdate;
}
function delIt() {
document.AddEdit.action.value = "del";
document.AddEdit.submit();
}
</script>
<form name="AddEdit" method="post">
<table width="100%" border="0" cellpadding="0" cellspacing="1">
<input name="action" type="hidden" value="<?php echo $holiday_id ? "update" : "add" ?>">
<tr>
<td><img src="./images/icons/tasks.gif" alt="" border="0"></td>
<td align='left' nowrap='nowrap' width='100%'><h1>
<?php
if($holiday_white)
{
echo $AppUI->_( $holiday_id ? 'Edit holiday' : 'New holiday' );
}
else
{
echo $AppUI->_( $holiday_id ? 'Edit workday' : 'New workday' );
}
?>
</h1></td>
</tr>
</table>
<table border="0" cellpadding="4" cellspacing="0" width="98%">
<tr>
<td width="50%" align="right">
<a href="javascript:delIt()"><img align="absmiddle" src="./images/icons/stock_delete-16.png" width="16" height="16" alt="" border="0"><?php echo $AppUI->_( $holiday_white ? 'Delete holiday' : 'Delete workday' );?></a>
</td>
</tr>
</table>
<table border="1" cellpadding="4" cellspacing="0" width="98%" class="std">
<tr><td align="CENTER">
<?php echo $AppUI->_( 'Start date' );?>
<input type="hidden" name="log_start_date" value="<?php echo $start_date->format( FMT_TIMESTAMP_DATE );?>" />
<input type="text" name="start_date" onChange="copyDate()" value="<?php echo $start_date->format( $AppUI->getPref('SHDATEFORMAT') );?>" class="text" disabled="disabled" />
<a href="#" onClick="popCalendar('start_date')" >
<img src="./images/calendar.gif" width="24" height="12" title="<?php echo $AppUI->_('Calendar');?>" border="0" />
</a>
<?php echo $AppUI->_( 'End date' );?>
<input type="hidden" name="log_end_date" value="<?php echo $end_date->format( FMT_TIMESTAMP_DATE );?>" />
<input type="text" name="end_date" value="<?php echo $end_date->format( $AppUI->getPref('SHDATEFORMAT') );?>" class="text" disabled="disabled" size="20" />
<a href="#" onClick="popCalendar('end_date')">
<img src="./images/calendar.gif" width="24" height="12" title="<?php echo $AppUI->_('Calendar');?>" border="0" />
</a>
<td>
<?php echo $AppUI->_( 'Annual' );?>
<input type="checkbox" value="1" name="holiday_annual" <?php if($holiday["holiday_annual"]){?>checked="checked"<?php }?> />
</td>
<td>
<?php echo $AppUI->_( 'Description' );?>
<input type="text" class="text" SIZE="100%" name="holiday_description" value="<?php echo $holiday["holiday_description"];?>">
</td>
</td></tr>
<table border="0" cellspacing="0" cellpadding="3" width="98%">
<tr>
<td height="40" width="30%"> </td>
<td height="40" width="35%" align="right">
<table>
<tr>
<td>
<input class="button" type="button" name="cancel" value="<?php echo $AppUI->_('cancel'); ?>" onClick="javascript:if(confirm('<?php echo $AppUI->_('Are you sure you want to cancel?', UI_OUTPUT_JS); ?>')){location.href = '?<?php echo $AppUI->getPlace();?>';}">
</td>
<td>
<input class="button" type="button" name="btnFuseAction" value="<?php echo $AppUI->_('save'); ?>" onClick="submit()">
</td>
</tr>
</table>
</td>
</tr>
</table>
</table>
</form>
</body>
</html>