2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 06/29/2004 *
4 * =================== Last change: 08/22/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-add_rallye.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Add new rallye *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Neue Ref-Rallye einfuegen *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
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 *
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. *
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. *
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, *
37 ************************************************************************/
39 // Some security stuff...
40 if ((!defined('__SECURITY')) || (!isAdmin())) {
44 // Add description as navigation point
45 addMenuDescription('admin', __FILE__);
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') );
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__);
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')",
62 postRequestElement('title'),
63 postRequestElement('descr'),
64 postRequestElement('template'),
67 postRequestElement('auto_add'),
68 postRequestElement('active'),
69 postRequestElement('notify'),
70 ), __FILE__, __LINE__);
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);
79 // Reload to prices...
80 redirectToUrl('modules.php?module=admin&what=config_rallye_prices&rallye='.$id);
82 // Problem detected...
83 loadTemplate('admin_settings_saved', false, getMessage('RALLYE_PROBLEM_CREATE'));
87 SQL_FREERESULT($result);
89 // Overlapping detected
90 loadTemplate('admin_settings_saved', false, getMessage('RALLYE_OVERLAP_TIMES'));
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') ));
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');
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));
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');
120 // Transfer (maybe found) templates into constant for the template
121 $content['templates_selection'] = addReferalRallyeTemplateSelection();
124 loadTemplate('admin_add_rallye', false, $content);