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 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535
| <?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>Enter latitude and longitude of country/place to display on map</label>
<th scope="row">Latitude</th>
<td>
<input type="text" name="<?php echo $data_field_name; ?>" value="<?php echo esc_attr( get_option('latitude') ); ?>" size="20">
</td> </tr>
<tr valign="top">
<th scope="row">Longitude</th>
<td>
<input type="text" name="longitude" value="<?php echo esc_attr( get_option('longitude') ); ?>" size="20">
</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();
}
function fc_displayservice(){ ?>
<div class="faretable">
<h2>Data to be displayed on front end </h2>
<table >
<th>Service</th><th>Fare</th><th>Action</th>
<?php
global $wpdb;
$table_name = $wpdb->prefix . "fare";
$postids = $wpdb->get_results("SELECT id,service,fare FROM $table_name");
if(isset($_POST['delid'])){
global $wpdb;
echo $did=$_POST['delid'];
$table_name = $wpdb->prefix . "fare";
$wpdb->query(" DELETE FROM $table_name where id=".$did);
?>
<div class="updated"><p><strong><?php _e('Row Deleted.', 'menu-test' ); ?></strong></p></div>
<?php
}
foreach ($postids as $value) {
echo '<tr valign="top">';
echo '<td>' . $value->service . '</td>';
echo '<td>' . $value->fare . '</td>';
echo "<td><form method='post' action=''>
<input name='delid' type='hidden' value='$value->id'/><input type='submit' value='Delete'/></form></td>";
echo '</tr>';
}
?>
</table>
</div>
<?php //fc_mapui();
}
/************** map interface *****************/
function fc_fare(){?>
<style type="text/css">html{height:0%}body{height:0%;margin-left:-50px;padding:0px;font-family:tahoma;font-size:10pt}#total{font-size:large;text-align:center;font-family:arial;color:black;margin:5px 0 10px 0;font-size:14px;width:250px}input{margin:5px 0px;font-family:tahoma;font-size:8pt}</style>
<head><script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false&libraries=places"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script>
$(function() {
$( "#datepicker" ).datepicker();
});
</script>
<script type="text/javascript">//<![CDATA[
var map=null;var directionDisplay;
var directionsService=new google.maps.DirectionsService();
function fc_initialize(){directionsDisplay=new google.maps.DirectionsRenderer();
var India=new google.maps.LatLng(<?php echo esc_attr( get_option('latitude') ); ?>,<?php echo esc_attr( get_option('longitude') ); ?>);
var mapOptions={center:India,zoom:10,minZoom:3,
streetViewControl:false,
mapTypeId:google.maps.MapTypeId.ROADMAP,
zoomControlOptions:{style:google.maps.ZoomControlStyle.MEDIUM}};
map=new google.maps.Map(document.getElementById('map_canvas'),mapOptions);
var fromText=document.getElementById('start');var fromAuto=new google.maps.places.Autocomplete(fromText);fromAuto.bindTo('bounds',map);
var toText=document.getElementById('end');
var toAuto=new google.maps.places.Autocomplete(toText);toAuto.bindTo('bounds',map);
directionsDisplay.setMap(map);directionsDisplay.setPanel(document.getElementById('directions-panel'));}
function fc_calcRoute(){
var start=document.getElementById('start').value;
var end=document.getElementById('end').value;
document.getElementById("fc_source").value=start;
document.getElementById("fc_destination").value=end;
//document.getElementById("sd").innerHTML= start+""+"-"+""+end;
var request={origin:start,destination:end,travelMode:google.maps.DirectionsTravelMode.DRIVING};
directionsService.route(request,
function(response,status){if(status==google.maps.DirectionsStatus.OK){directionsDisplay.setDirections(response);fc_computeTotalDistance(response);}});}
function fc_computeTotalDistance(result){var total=0;
var myroute=result.routes[0];
for(i=0;i<myroute.legs.length;i++){total+=myroute.legs[i].distance.value;}
total=total/1000;var e=document.getElementById("car");
var strUser=e.options[e.selectedIndex].value;
var selectedcar =e.options[e.selectedIndex].text;
var dist=strUser*total;
document.getElementById("fc_price").value=dist;
document.getElementById("fc_dist").value=total;
document.getElementById("fc_car").value=selectedcar;
document.getElementById("total").innerHTML="Distance = "+total+" km </br> Estimation = "+dist+" ";}
function auto(){var input=document.getElementById[('start'),('end')];var types
var options={types:[],componentRestrictions:{country:["IND"]}};var autocomplete=new google.maps.places.Autocomplete(input,options);}
google.maps.event.addDomListener(window,'load',fc_initialize);
//]]></script>
<style>#car{ border: 1px solid #c6c6c6;
padding: 5px;
width: 50%;}
#map_canvas{
width: 100% !important;
}
</style>
</head>
<body onLoad="fc_initialize()">
<div class="post style-2 bottom-2">
<div class='sdc'>
<table style="float: left;margin-left:30%;"><tr><td>
<span style="color: black;"> De:</span></td>
<td> <input type="text" id="start" size="50px" name="start" required placeholder="Entrez le point de départ" style="float: left;"></td>
<tr><td> <span style="color: black;float: left;"> À:</span></td>
<td> <input size="50px" type="text" id="end" name="end" required placeholder="Entrez la destination" style="float: left;"> </td>
<tr><td style="color: black;margin-left:150%;">Distance approximative</td><td><select value="select car" id="car" style="float: left;">
<?php
global $wpdb;
$table_name = $wpdb->prefix . "fare";
$postids = $wpdb->get_results("SELECT service,fare FROM $table_name");
foreach ($postids as $value) {
echo '<option value='.$value->fare.'>' . $value->service . '</option>' ;
}
?>
</select></td></tr>
<tr> <td><input type="button" position="center" value="Calculer" onClick="fc_calcRoute();"></td>
<td> <div style="float: left;margin-left:100%;"" id="total"></td></tr>
<div id="map_canvas" style="width: 874px; height: 300px; border: solid 1px #336699"></div>
</div>
</div>
</div>
</body>
<?php fc_distprice();
}
function fc_distprice(){
$page=get_page_by_title('booktaxi');
$taxiurl=site_url().'/?page_id='.$page->ID;
?>
<form action='' method='POST'>
<tr><input type="hidden" id="fc_source" name="fc_source" >
<input type="hidden" id="fc_destination" name="fc_destination">
<input type="hidden" id="fc_car" name="fc_car">
<input type="hidden" id="fc_dist" name="fc_dist">
<input type="hidden" id="fc_price" name="fc_price"></tr>
</form>
</table>
<?php
}
function fc_bookings()
{
global $wpdb;
$table_name = $wpdb->prefix . "taxibooked";
$bookings = $wpdb->get_results("SELECT * FROM $table_name where status=1 ORDER BY id DESC LIMIT 30");
if (!empty($_POST['bdelid'])) {
$bdid=$_POST['bdelid'];
$table_name = $wpdb->prefix . "taxibooked";
// / $wpdb->query(" DELETE FROM $table_name where id=".$bdid);
$wpdb->query(" UPDATE $table_name SET status = 0 where id=".$bdid);
}
if (!empty($_POST['bdelidc'])) {
$bdidc=$_POST['bdelidc'];
$table_name = $wpdb->prefix . "taxibooked";
$wpdb->query(" DELETE FROM $table_name where id=".$bdidc);
}
echo "<style> table, tr, td, th {border:1px solid black;}</style>";
echo "<h2>Bookings</h2>";
echo "<table><th>Id</th>
<th>Name</th>
<th>Source-Destination</th><th>Vehicle</th>
<th>Distance</th>
<th>Price</th>
<th>Address</th>
<th>Phone</th>
<th>Email</th>
<th>OnBoard Date</th>
<th>Confirm</th>
<th>Delete</th>
";
foreach ($bookings as $bvalue) {
?>
<tr><td><?php echo $bvalue->id; ?></td> <td><?php echo $bvalue->name; ?></td>
<td><?php echo $bvalue->sd; ?></td>
<td><?php echo $bvalue->vehicle; ?></td>
<td><?php echo $bvalue->distance; ?></td>
<td><?php echo $bvalue->price; ?></td>
<td><?php echo $bvalue->address ?></td>
<td><?php echo $bvalue->phone ;?></td>
<td><?php echo $bvalue->email ;?></td>
<td><?php echo $bvalue->date_booked; ?></td>
<td><form method='POST' action=''><input name='bdelid' type='hidden' value='<?php echo $bvalue->id; ?>'/><input type='submit' value='OK'/></form></td>
<td><form method='POST' action=''><input name='bdelidc' type='hidden' value='<?php echo $bvalue->id; ?>'/><input type='submit' value='Delete'/></form></td>
</tr>
<?php }
echo "</table>";
}
function fc_confirmbookings()
{
global $wpdb;
$table_name = $wpdb->prefix . "taxibooked";
$bookings = $wpdb->get_results("SELECT * FROM $table_name where status=0 ORDER BY id DESC LIMIT 30");
if (!empty($_POST['bdelidc'])) {
$bdidc=$_POST['bdelidc'];
$table_name = $wpdb->prefix . "taxibooked";
$wpdb->query(" DELETE FROM $table_name where id=".$bdidc);
}
echo "<style> table, tr, td, th {border:1px solid black;}</style>";
echo "<h2>Confirmed Bookings</h2>";
echo "<table><th>Id</th>
<th>Name</th>
<th>Source-Destination</th><th>Vehicle</th>
<th>Distance</th>
<th>Price</th>
<th>Address</th>
<th>Phone</th>
<th>Email</th>
<th>OnBoard Date</th>
<th>Delete</th>
";
foreach ($bookings as $bvalue) {
?>
<tr><td><?php echo $bvalue->id; ?></td> <td><?php echo $bvalue->name; ?></td>
<td><?php echo $bvalue->sd; ?></td>
<td><?php echo $bvalue->vehicle; ?></td>
<td><?php echo $bvalue->distance; ?></td>
<td><?php echo $bvalue->price; ?></td>
<td><?php echo $bvalue->address ?></td>
<td><?php echo $bvalue->phone ;?></td>
<td><?php echo $bvalue->email ;?></td>
<td><?php echo $bvalue->date_booked; ?></td>
<td><form method='POST' action=''><input name='bdelidc' type='hidden' value='<?php echo $bvalue->id; ?>'/><input type='submit' value='Delete'/></form></td>
</tr>
<?php }
echo "</table>";
}
function fc_settings(){ ?>
<div><h2>Welcome Admin</h2>
<h3>Shortcode To Display Taxi fare calculator [fc_fare]</h3></br>
<h3>
Fro Pro Options:
payment Options through paypal,
Transaction Id Storages in db
==>Contact Me:</h3>
<p>Krish </br>
Email: krishna25auro@gmail.com </p>
</div>
<?php }
add_shortcode('fc_fare', 'fc_fare');
//add_shortcode('fc_booktaxi', 'fc_booktaxi'); |
Partager