]> git.mxchange.org Git - mailer.git/blob - inc/modules/admin/what-add_rallye.php
Mailer project continued:
[mailer.git] / inc / modules / admin / what-add_rallye.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                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  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009 - 2012 by Mailer Developer Team                   *
20  * For more information visit: http://mxchange.org                      *
21  *                                                                      *
22  * This program is free software; you can redistribute it and/or modify *
23  * it under the terms of the GNU General Public License as published by *
24  * the Free Software Foundation; either version 2 of the License, or    *
25  * (at your option) any later version.                                  *
26  *                                                                      *
27  * This program is distributed in the hope that it will be useful,      *
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
30  * GNU General Public License for more details.                         *
31  *                                                                      *
32  * You should have received a copy of the GNU General Public License    *
33  * along with this program; if not, write to the Free Software          *
34  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // Some security stuff...
39 if ((!defined('__SECURITY')) || (!isAdmin())) {
40         die();
41 } // END - if
42
43 // Add description as navigation point
44 addYouAreHereLink('admin', __FILE__);
45
46 if (isFormSent()) {
47         // Generate timestamps
48         $START = mktime(postRequestElement('start_time_hour'), postRequestElement('start_time_min'), 0, postRequestElement('start_time_month'), postRequestElement('start_time_day'), postRequestElement('start_time_year'));
49         $END   = mktime(postRequestElement('end_time_hour')  , postRequestElement('end_time_min')  , 0, postRequestElement('end_time_month')  , postRequestElement('end_time_day')  , postRequestElement('end_time_year')  );
50
51         // Is there already a rallye running?
52         $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",
53                 array($START, $START, $START, $END), __FILE__, __LINE__);
54
55         if (SQL_HASZERONUMS($result)) {
56                 // Ok, start and end time did not overlap
57                 SQL_QUERY_ESC("INSERT INTO
58         `{?_MYSQL_PREFIX?}_rallye_data`
59 (
60         `admin_id`,
61         `title`,
62         `descr`,
63         `template`,
64         `start_time`,
65         `end_time`,
66         `auto_add_new_user`,
67         `is_active`,
68         `send_notify`,
69         `min_users`,
70         `min_prices`
71 ) VALUES (
72         %s,
73         '%s',
74         '%s',
75         '%s',
76         %s,
77         %s,
78         '%s',
79         '%s',
80         '%s',
81         %s,
82         %s
83 )",
84                         array(
85                                 getCurrentAdminId(),
86                                 postRequestElement('title'),
87                                 postRequestElement('descr'),
88                                 postRequestElement('template'),
89                                 $START,
90                                 $END,
91                                 postRequestElement('auto_add'),
92                                 postRequestElement('active'),
93                                 postRequestElement('notify'),
94                                 bigintval(postRequestElement('min_users')),
95                                 bigintval(postRequestElement('min_prices'))
96                         ), __FILE__, __LINE__);
97
98                 // Load id
99                 $id = SQL_INSERTID();
100
101                 if (!empty($id)) {
102                         // Reload to prices...
103                         redirectToUrl('modules.php?module=admin&amp;what=config_rallye_prices&amp;rallye_id=' . bigintval($id));
104                 } else {
105                         // Problem detected...
106                         displayMessage('{--ADMIN_RALLYE_PROBLEM_CREATE--}');
107                 }
108         } else {
109
110                 // Overlapping detected
111                 displayMessage('{--ADMIN_RALLYE_OVERLAP_TIMES--}');
112         }
113
114         // Free memory
115         SQL_FREERESULT($result);
116 } // END - if
117
118 // Starting day
119 $content['start_min']   = addSelectionBox('min'  , 0                   , 'start_time');
120 $content['start_hour']  = addSelectionBox('hour' , getShortHour()      , 'start_time');
121 $content['start_day']   = addSelectionBox('day'  , getDay()            , 'start_time');
122 $content['start_month'] = addSelectionBox('month', getMonth()          , 'start_time');
123 $content['start_year']  = addSelectionBox('year' , getYear()           , 'start_time');
124
125 // Ending timestamp
126 $endingStamp = time() + (getOneDay() * 7);
127
128 // Ending day
129 $content['end_min']   = addSelectionBox('min'  , 0                     , 'end_time');
130 $content['end_hour']  = addSelectionBox('hour' , getShortHour()        , 'end_time');
131 $content['end_day']   = addSelectionBox('day'  , getDay($endingStamp)  , 'end_time');
132 $content['end_month'] = addSelectionBox('month', getMonth($endingStamp), 'end_time');
133 $content['end_year']  = addSelectionBox('year' , getYear($endingStamp) , 'end_time');
134
135 // Load template
136 loadTemplate('admin_add_rallye', false, $content);
137
138 // [EOF]
139 ?>