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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
| <?php
/*
Plugin Name: farecalculator
Plugin URI: http://staunchire.com
Description: Easy way to calculate the fare price on taxi or any service, with the help of google map with auto suggestion place , this is the plugin you need.
Version: 1.1
Author: Gopi krishnan, MoB: +91 8122335200, Email: krishna25auro@gmail.com
Author URI: https://www.facebook.com/badchetah
License: GPL2
*/
/*
Copyright 2014 Gopi krishnan (email : krishna25auro@gmail.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program;
*/
require_once(ABSPATH.'wp-admin/includes/upgrade.php');
function fc_createtable(){
global $wpdb;
$charset_collate = '';
if ( ! empty( $wpdb->charset ) ) {
$charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
}
if ( ! empty( $wpdb->collate ) ) {
$charset_collate .= " COLLATE {$wpdb->collate}";
}
$table_name = $wpdb->prefix . "fare";
$sql = "CREATE TABLE $table_name (
id mediumint(9) NOT NULL AUTO_INCREMENT,
service tinytext NOT NULL,
fare tinytext NOT NULL,
UNIQUE KEY id (id)
) $charset_collate;";
$table_nameb = $wpdb->prefix . "taxibooked";
$sql2= "CREATE TABLE IF NOT EXISTS $table_nameb (
`id` mediumint(9) NOT NULL AUTO_INCREMENT,
`name` varchar(20) NOT NULL,
`sd` tinytext NOT NULL,
`vehicle` varchar(20) NOT NULL,
`distance` varchar(20) NOT NULL,
`price` varchar(20) NOT NULL,
`address` tinytext NOT NULL,
`phone` varchar(20) NOT NULL,
`email` varchar(40) NOT NULL,
`date_booked` varchar(20) NOT NULL,
`status` int(11) NOT NULL DEFAULT '1',
UNIQUE KEY `id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=19 ;";
dbDelta( $sql );
dbDelta( $sql2 );
}
/*****deactivate table ****/
function fc_fareremovetb() {
global $wpdb;
$table_name2 = $wpdb->prefix . "fare";
$table_nameb = $wpdb->prefix . "taxibooked";
$sql2 = "DROP TABLE IF EXISTS $table_name;";
$sql3 = "DROP TABLE IF EXISTS $table_nameb;";
$wpdb->query($sql2); $wpdb->query($sql3);
delete_option("my_plugin_db_version");
$page=get_page_by_title('booktaxi');
wp_delete_post($page_ID);
}
register_activation_hook( __FILE__, 'fc_createtable' );
register_deactivation_hook( __FILE__, 'fc_fareremovetb');
/*********administration page***********/
function fc_plugin_menu() {
add_menu_page('Fare Plugin Settings', 'Fare Settings', 'administrator', __FILE__, 'fc_faresettingspage',plugins_url('/images/fare.png', __FILE__));
// add_menu_page('My Page Title', 'My Menu Title', 'manage_options', __FILE__, 'my_menu_output' );
add_submenu_page(__FILE__, 'Submenu Page Title', 'Bookings', 'administrator','fare-calculator/send.php','fc_bookings' );
add_submenu_page(__FILE__, 'Submenu Page Title', 'ConfirmedBookings', 'administrator','fare-calculator/sendd.php','fc_confirmbookings' );
add_submenu_page(__FILE__, 'Submenu Page Title', 'Settings', 'administrator','fare-calculator/senddd.php','fc_settings' );
}
//add_submenu_page( 'tools.php', 'My Custom Submenu Page', 'My Custom Submenu Page', 'manage_options', 'my-custom-submenu-page', 'fc_service' ); }
add_action( 'admin_menu', 'fc_plugin_menu' );
// mt_settings_page() displays the page content for the Test settings submenu
function fc_faresettingspage() {
if (!current_user_can('manage_options'))
{
wp_die( __('You do not have sufficient permissions to access this page.') );
}
$lat = 'latitude';
$long='longitude';
$hidden_field_name = 'mt_submit_hidden';
$data_field_name = 'mt_favorite_color';
if( isset($_POST[ $hidden_field_name ]) && $_POST[ $hidden_field_name ] == 'Y' ) {
$lat_val = $_POST[ $data_field_name ];
$long_val=$_POST['longitude'];
update_option( $lat, $lat_val );
update_option( $long, $long_val );?>
<div class="updated"><p><strong><?php _e('settings saved.', 'menu-test' ); ?></strong></p></div>
<?php }
echo '<div class="wrap">';
echo "<h2>" . __( 'Fare Calculator Settings', 'menu-test' ) . "</h2>";
?>
<form name="form1" method="post" action="">
<input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
<table class="form-table">
<tr valign="top">
<label>Введите координаты страны, которая является центром карты</label>
<th scope="row">Широта</th>
<td>
<input type="text" name="<?php echo $data_field_name; ?>" value="11.9310" size="20" readonly>
</td> </tr>
<tr valign="top">
<th scope="row">Долгота</th>
<td>
<input type="text" name="Долгота" value="79.7852" size="20" readonly>
</td> </tr>
<tr>
<td></td>
<td>
<input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e('Save Changes') ?>" /></td>
</tr>
<hr />
</table>
</form>
<hr/>
</div>
<?php
//fc_paypal();
fc_addservice();
}
function fc_addservice()
{
global $wpdb;
if(isset($_POST['service'])){
$table_name = $wpdb->prefix . "fare";
$wpdb->insert( $table_name, array( 'service' => $_POST['service'], 'fare' => $_POST['fare'] ) );
?>
<div class="updated"><p><strong><?php _e('Added Successfully.', 'menu-test' ); ?></strong></p></div>
<?php } ?>
<form method="post" action="">
<table class="form-table">
<tr valign="top">
<h2>Enter Service and its price/fare</h2>
<th scope="row">Service</th>
<td><input type="text" name="service" value="" required="required" /> eg : INNOVA</td>
</tr>
<tr valign="top">
<th scope="row">Fare</th>
<td><input type="text" name="fare" value="" required="required" />eg : $ 1/km(mile)(for amount)</td>
</tr>
<tr><td></td> <td> <input type="submit" class="button-primary" value="ADD"/></td> </tr>
</table>
</form><hr/>
<?php
fc_displayservice();
} |