A lot texts rewritten and exclamation signs removed
[mailer.git] / inc / modules / admin / what-add_rallye.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 06/29/2004 *
4  * ================                             Last change: 08/22/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-add_rallye.php                              *
8  * -------------------------------------------------------------------- *
9  * Short description : Add new rallye                                   *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Neue Ref-Rallye einfuegen                        *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * Needs to be in all Files and every File needs "svn propset           *
18  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
19  * -------------------------------------------------------------------- *
20  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
21  * For more information visit: http://www.mxchange.org                  *
22  *                                                                      *
23  * This program is free software; you can redistribute it and/or modify *
24  * it under the terms of the GNU General Public License as published by *
25  * the Free Software Foundation; either version 2 of the License, or    *
26  * (at your option) any later version.                                  *
27  *                                                                      *
28  * This program is distributed in the hope that it will be useful,      *
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
31  * GNU General Public License for more details.                         *
32  *                                                                      *
33  * You should have received a copy of the GNU General Public License    *
34  * along with this program; if not, write to the Free Software          *
35  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
36  * MA  02110-1301  USA                                                  *
37  ************************************************************************/
38
39 // Some security stuff...
40 if ((!defined('__SECURITY')) || (!isAdmin())) {
41         die();
42 }
43
44 // Add description as navigation point
45 addMenuDescription('admin', __FILE__);
46
47 if (isFormSent()) {
48         // Generate timestamps
49         $START = mktime(postRequestElement('start_hour'), postRequestElement('start_min'), postRequestElement('start_sec'), postRequestElement('start_month'), postRequestElement('start_day'), postRequestElement('start_year'));
50         $END   = mktime(postRequestElement('end_hour')  , postRequestElement('end_min')  , postRequestElement('end_sec')  , postRequestElement('end_month')  , postRequestElement('end_day')  , postRequestElement('end_year')  );
51
52         // Is there already a rallye running?
53         $result = SQL_QUERY_ESC("SELECT id, admin_id FROM `{?_MYSQL_PREFIX?}_rallye_data` WHERE (start_time <= %s AND end_time >= %s) OR (start_time >= %s AND start_time <= %s) LIMIT 1",
54                 array($START, $START, $START, $END), __FILE__, __LINE__);
55
56         if (SQL_NUMROWS($result) == 0) {
57                 // Ok, start and end time did not overlap
58                 SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_rallye_data` (admin_id, title, descr, template, start_time, end_time, auto_add_new_user, is_active, send_notify)
59 VALUES ('%s','%s','%s','%s','%s','%s','%s','%s','%s')",
60                         array(
61                                 getCurrentAdminId(),
62                                 postRequestElement('title'),
63                                 postRequestElement('descr'),
64                                 postRequestElement('template'),
65                                 $START,
66                                 $END,
67                                 postRequestElement('auto_add'),
68                                 postRequestElement('active'),
69                                 postRequestElement('notify'),
70                         ), __FILE__, __LINE__);
71
72                 // Load id
73                 $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_rallye_data` WHERE start_time='%s' AND end_time='%s' AND `title`='%s' LIMIT 1",
74                 array($START, $END, postRequestElement('title')), __FILE__, __LINE__);
75                 list($id) = SQL_FETCHROW($result);
76                 SQL_FREERESULT($result);
77
78                 if (!empty($id)) {
79                         // Reload to prices...
80                         redirectToUrl('modules.php?module=admin&amp;what=config_rallye_prices&amp;rallye='.$id);
81                 } else {
82                         // Problem detected...
83                         loadTemplate('admin_settings_saved', false, getMessage('RALLYE_PROBLEM_CREATE'));
84                 }
85         } else {
86                 // Free memory
87                 SQL_FREERESULT($result);
88
89                 // Overlapping detected
90                 loadTemplate('admin_settings_saved', false, getMessage('RALLYE_OVERLAP_TIMES'));
91         }
92 }
93
94 // Prepare some constants for the template
95 $content['auto_add_options'] = generateOptionList('/ARRAY/', array('Y','N'), array(getMessage('YES'), getMessage('NO') ));
96 $content['active_options']   = generateOptionList('/ARRAY/', array('N','Y'), array(getMessage('NO') , getMessage('YES')));
97 $content['notify_options']   = generateOptionList('/ARRAY/', array('Y','N'), array(getMessage('YES'), getMessage('NO') ));
98
99 // Starting day
100 $content['start_sec']   = addSelectionBox('sec'  , 0              , 'start');
101 $content['start_min']   = addSelectionBox('min'  , 0              , 'start');
102 $content['start_hour']  = addSelectionBox('hour' , date('G', time()), 'start');
103 $content['start_day']   = addSelectionBox('day'  , date('d', time()), 'start');
104 $content['start_month'] = addSelectionBox('month', date('m', time()), 'start');
105 $content['start_year']  = addSelectionBox('year' , date('Y', time()), 'start');
106
107 // Calcualte ending date
108 $D = date('d', time() + (getConfig('ONE_DAY') * 7));
109 $M = date('m', time() + (getConfig('ONE_DAY') * 7));
110 $Y = date('Y', time() + (getConfig('ONE_DAY') * 7));
111
112 // Ending day
113 $content['end_sec']   = addSelectionBox('sec'  , 0              , 'end');
114 $content['end_min']   = addSelectionBox('min'  , 0              , 'end');
115 $content['end_hour']  = addSelectionBox('hour' , date('G', time()), 'end');
116 $content['end_day']   = addSelectionBox('day'  , $D               , 'end');
117 $content['end_month'] = addSelectionBox('month', $M               , 'end');
118 $content['end_year']  = addSelectionBox('year' , $Y               , 'end');
119
120 // Transfer (maybe found) templates into constant for the template
121 $content['templates_selection'] = addReferalRallyeTemplateSelection();
122
123 // Load template
124 loadTemplate('admin_add_rallye', false, $content);
125
126 // [EOF]
127 ?>