function CreateRoute($route, $startdate) { // routes : // 1 Thuis - La Treve - via autoroute du soleil // 2 La Treve - Nuits-Saint-Georges via Nimes // 3 La Treve - Nuits-Saint-Georges via Orange // 4 Nuits-Saint-Georges - Brecht (thuis) // 51 La Treve - Auxerre via Orange // 52 La Treve - Auxerre via Valence // 6 Auxerre - Brecht (thuis) // //$route = 4; // startdate = '2015-10-25 10:30' $uu = substr($startdate, 11, 2); $nn = substr($startdate, 14, 2); $dd = substr($startdate, 8, 2); $mm = substr($startdate, 5, 2); $jj = substr($startdate, 0, 4); echo 'Create New Trip<br>===============<br><br>'; // trip $t1 = new trip(); //$t1->att('statusid',1); if ($route == 1) { $t1->att('name', 'Thuis - La Treve - via autoroute du soleil'); } if ($route == 2) { $t1->att('name', 'La Treve - Ibis Nuits Saint Georges - via Nimes'); } if ($route == 3) { $t1->att('name', 'La Treve - Ibis Nuits Saint Georges - via Orange'); } if ($route == 4) { $t1->att('name', 'Nuits-Saint-Georges - Brecht (thuis)'); } if ($route == 51) { $t1->att('name', 'La Treve - Auxerre (via Orange)'); } if ($route == 52) { $t1->att('name', 'La Treve - Auxerre (via Valence)'); } if ($route == 6) { $t1->att('name', 'Auxerre - Brecht (thuis)'); } $t1->att('date', mktime($uu, $nn, 0, $mm, $dd, $jj)); $t1->att('car', '38855'); $t1->save(); $tripid = $t1->att('objid'); echo 'Trip ' . $t1->att('name') . ' (id : ' . $t1->att('objid') . ') saved<br>'; echo 'Create New Waypoints<br>====================<br><br>'; // waypoints if ($route == 1) { $wp = new waypoint(); $wp->att('tripid', $tripid); $wp->att('destination', 'Brecht'); $wp->att('typeid', 1); $wp->att('statusid', 3); $wp->att('theoreticaldistance', null); $wp->att('theoreticaltypical', null); $wp->att('theoreticalconsumption', null); $wp->att('theoreticaldrivetime', null); $wp->att('theoreticalchargetime', null); $wp->att('theoreticalchargeneeded', CalculateChargeNeeded(373)); $wp->save(); echo 'Waypoint ' . $wp->att('destination') . ' (id : ' . $wp->att('objid') . ') saved<br>'; $wp = new waypoint(); $wp->att('tripid', $tripid); $wp->att('destination', 'SuC Metz'); $wp->att('typeid', 3); $wp->att('statusid', 0); $wp->att('theoreticaldistance', 322.5); $wp->att('theoreticaltypical', 373); $wp->att('theoreticalconsumption', 70.0); $wp->att('theoreticaldrivetime', 195); $wp->att('theoreticalchargetime', null); $wp->att('theoreticalchargeneeded', CalculateChargeNeeded(86)); $wp->save(); echo 'Waypoint ' . $wp->att('destination') . ' (id : ' . $wp->att('objid') . ') saved<br>'; $wp = new waypoint(); $wp->att('tripid', $tripid); $wp->att('destination', 'SuC Nancy'); $wp->att('typeid', 3); $wp->att('statusid', 0); $wp->att('theoreticaldistance', 79.5); $wp->att('theoreticaltypical', 86); $wp->att('theoreticalconsumption', 16.0); $wp->att('theoreticaldrivetime', 60); $wp->att('theoreticalchargetime', null); $wp->att('theoreticalchargeneeded', CalculateChargeNeeded(287)); $wp->save(); echo 'Waypoint ' . $wp->att('destination') . ' (id : ' . $wp->att('objid') . ') saved<br>'; $wp = new waypoint(); $wp->att('tripid', $tripid); $wp->att('destination', 'Suc Nuits-Saint-Georges'); $wp->att('typeid', 3); $wp->att('statusid', 0); $wp->att('theoreticaldistance', 229.6); $wp->att('theoreticaltypical', 287); $wp->att('theoreticalconsumption', 53.0); $wp->att('theoreticaldrivetime', 130); $wp->att('theoreticalchargetime', null); $wp->att('theoreticalchargeneeded', CalculateChargeNeeded(225)); $wp->save(); echo 'Waypoint ' . $wp->att('destination') . ' (id : ' . $wp->att('objid') . ') saved<br>'; $wp = new waypoint(); $wp->att('tripid', $tripid); $wp->att('destination', 'Suc Vienne'); $wp->att('typeid', 3); $wp->att('statusid', 0); $wp->att('theoreticaldistance', 188.5); $wp->att('theoreticaltypical', 225); $wp->att('theoreticalconsumption', 42.0); $wp->att('theoreticaldrivetime', 115); $wp->att('theoreticalchargetime', null); $wp->att('theoreticalchargeneeded', CalculateChargeNeeded(289)); $wp->save(); echo 'Waypoint ' . $wp->att('destination') . ' (id : ' . $wp->att('objid') . ') saved<br>'; $wp = new waypoint(); $wp->att('tripid', $tripid); $wp->att('destination', 'Suc Nimes'); $wp->att('typeid', 3); $wp->att('statusid', 0); $wp->att('theoreticaldistance', 234.1); $wp->att('theoreticaltypical', 289); $wp->att('theoreticalconsumption', 54.0); $wp->att('theoreticaldrivetime', 130); $wp->att('theoreticalchargetime', null); $wp->att('theoreticalchargeneeded', CalculateChargeNeeded(143)); $wp->save(); echo 'Waypoint ' . $wp->att('destination') . ' (id : ' . $wp->att('objid') . ') saved<br>'; $wp = new waypoint(); $wp->att('tripid', $tripid); $wp->att('destination', 'La Trêve, Véreilles'); $wp->att('typeid', 2); $wp->att('statusid', 0); $wp->att('theoreticaldistance', 124.0); $wp->att('theoreticaltypical', 143); $wp->att('theoreticalconsumption', 27.0); $wp->att('theoreticaldrivetime', 110); $wp->att('theoreticalchargetime', null); $wp->att('theoreticalchargeneeded', null); $wp->save(); echo 'Waypoint ' . $wp->att('destination') . ' (id : ' . $wp->att('objid') . ') saved<br>'; } if ($route == 2) { $wp = new waypoint(); $wp->att('tripid', $tripid); $wp->att('destination', 'La Trêve'); $wp->att('typeid', 1); $wp->att('statusid', 3); $wp->att('theoreticaldistance', null); $wp->att('theoreticaltypical', null); $wp->att('theoreticalconsumption', null); $wp->att('theoreticaldrivetime', null); $wp->att('theoreticalchargetime', null); $wp->att('theoreticalchargeneeded', CalculateChargeNeeded(135)); $wp->save(); echo 'Waypoint ' . $wp->att('destination') . ' (id : ' . $wp->att('objid') . ') saved<br>'; $wp = new waypoint(); $wp->att('tripid', $tripid); $wp->att('destination', 'SuC Nimes'); $wp->att('typeid', 3); $wp->att('statusid', 0); $wp->att('theoreticaldistance', 124.8); $wp->att('theoreticaltypical', 135); $wp->att('theoreticalconsumption', 25.0); $wp->att('theoreticaldrivetime', 105); $wp->att('theoreticalchargetime', null); $wp->att('theoreticalchargeneeded', CalculateChargeNeeded(307)); $wp->save(); echo 'Waypoint ' . $wp->att('destination') . ' (id : ' . $wp->att('objid') . ') saved<br>'; $wp = new waypoint(); $wp->att('tripid', $tripid); $wp->att('destination', 'SuC Vienne'); $wp->att('typeid', 3); $wp->att('statusid', 0); $wp->att('theoreticaldistance', 234.1); $wp->att('theoreticaltypical', 307); $wp->att('theoreticalconsumption', 57.0); $wp->att('theoreticaldrivetime', 135); $wp->att('theoreticalchargetime', null); $wp->att('theoreticalchargeneeded', CalculateChargeNeeded(237)); $wp->save(); echo 'Waypoint ' . $wp->att('destination') . ' (id : ' . $wp->att('objid') . ') saved<br>'; $wp = new waypoint(); $wp->att('tripid', $tripid); $wp->att('destination', 'Suc Nuits-Saint-Georges (Ibis)'); $wp->att('typeid', 3); $wp->att('statusid', 0); $wp->att('theoreticaldistance', 189.9); $wp->att('theoreticaltypical', 237); $wp->att('theoreticalconsumption', 44.0); $wp->att('theoreticaldrivetime', 110); $wp->att('theoreticalchargetime', null); $wp->att('theoreticalchargeneeded', CalculateChargeNeeded(350)); $wp->save(); echo 'Waypoint ' . $wp->att('destination') . ' (id : ' . $wp->att('objid') . ') saved<br>'; } if ($route == 3) { $wp = new waypoint(); $wp->att('tripid', $tripid); $wp->att('destination', 'La Trêve'); $wp->att('typeid', 1); $wp->att('statusid', 3); $wp->att('theoreticaldistance', null); $wp->att('theoreticaltypical', null); $wp->att('theoreticalconsumption', null); $wp->att('theoreticaldrivetime', null); $wp->att('theoreticalchargetime', null); $wp->att('theoreticalchargeneeded', CalculateChargeNeeded(200)); $wp->save(); echo 'Waypoint ' . $wp->att('destination') . ' (id : ' . $wp->att('objid') . ') saved<br>'; $wp = new waypoint(); $wp->att('tripid', $tripid); $wp->att('destination', 'SuC Orange'); $wp->att('typeid', 3); $wp->att('statusid', 0); $wp->att('theoreticaldistance', 186.7); $wp->att('theoreticaltypical', 200); $wp->att('theoreticalconsumption', 37.0); $wp->att('theoreticaldrivetime', 135); $wp->att('theoreticalchargetime', null); $wp->att('theoreticalchargeneeded', CalculateChargeNeeded(220)); $wp->save(); echo 'Waypoint ' . $wp->att('destination') . ' (id : ' . $wp->att('objid') . ') saved<br>'; $wp = new waypoint(); $wp->att('tripid', $tripid); $wp->att('destination', 'SuC Vienne'); $wp->att('typeid', 3); $wp->att('statusid', 0); $wp->att('theoreticaldistance', 184.5); $wp->att('theoreticaltypical', 220); $wp->att('theoreticalconsumption', 42.0); $wp->att('theoreticaldrivetime', 120); $wp->att('theoreticalchargetime', null); $wp->att('theoreticalchargeneeded', CalculateChargeNeeded(230)); $wp->save(); echo 'Waypoint ' . $wp->att('destination') . ' (id : ' . $wp->att('objid') . ') saved<br>'; $wp = new waypoint(); $wp->att('tripid', $tripid); $wp->att('destination', 'Suc Nuits-Saint-Georges (Ibis)'); $wp->att('typeid', 3); $wp->att('statusid', 0); $wp->att('theoreticaldistance', 190.2); $wp->att('theoreticaltypical', 230); $wp->att('theoreticalconsumption', 44.0); $wp->att('theoreticaldrivetime', 110); $wp->att('theoreticalchargetime', null); $wp->att('theoreticalchargeneeded', CalculateChargeNeeded(350)); $wp->save(); echo 'Waypoint ' . $wp->att('destination') . ' (id : ' . $wp->att('objid') . ') saved<br>'; } if ($route == 4) { $wp = new waypoint(); $wp->att('tripid', $tripid); $wp->att('destination', 'Suc Nuits-Saint-Georges (Ibis)'); $wp->att('typeid', 1); $wp->att('statusid', 3); $wp->att('theoreticaldistance', null); $wp->att('theoreticaltypical', null); $wp->att('theoreticalconsumption', null); $wp->att('theoreticaldrivetime', null); $wp->att('theoreticalchargetime', null); $wp->att('theoreticalchargeneeded', CalculateChargeNeeded(350)); $wp->save(); echo 'Waypoint ' . $wp->att('destination') . ' (id : ' . $wp->att('objid') . ') saved<br>'; $wp = new waypoint(); $wp->att('tripid', $tripid); $wp->att('destination', 'SuC Châlon-en-Champagne'); $wp->att('typeid', 3); $wp->att('statusid', 0); $wp->att('theoreticaldistance', 287.3); $wp->att('theoreticaltypical', 350); $wp->att('theoreticalconsumption', 65.0); $wp->att('theoreticaldrivetime', 150); $wp->att('theoreticalchargetime', null); $wp->att('theoreticalchargeneeded', CalculateChargeNeeded(250)); $wp->save(); echo 'Waypoint ' . $wp->att('destination') . ' (id : ' . $wp->att('objid') . ') saved<br>'; $wp = new waypoint(); $wp->att('tripid', $tripid); $wp->att('destination', 'SuC Nivelles-Sud'); $wp->att('typeid', 3); $wp->att('statusid', 0); $wp->att('theoreticaldistance', 227.8); $wp->att('theoreticaltypical', 250); $wp->att('theoreticalconsumption', 44.5); $wp->att('theoreticaldrivetime', 170); $wp->att('theoreticalchargetime', null); $wp->att('theoreticalchargeneeded', CalculateChargeNeeded(120)); $wp->save(); echo 'Waypoint ' . $wp->att('destination') . ' (id : ' . $wp->att('objid') . ') saved<br>'; $wp = new waypoint(); $wp->att('tripid', $tripid); $wp->att('destination', 'Brecht (thuis)'); $wp->att('typeid', 2); $wp->att('statusid', 0); $wp->att('theoreticaldistance', 103.4); $wp->att('theoreticaltypical', 120); $wp->att('theoreticalconsumption', 21.0); $wp->att('theoreticaldrivetime', 90); $wp->att('theoreticalchargetime', null); $wp->att('theoreticalchargeneeded', null); $wp->save(); echo 'Waypoint ' . $wp->att('destination') . ' (id : ' . $wp->att('objid') . ') saved<br>'; } if ($route == 51) { $wp = new waypoint(); $wp->att('tripid', $tripid); $wp->att('destination', 'La Trêve'); $wp->att('typeid', 1); $wp->att('statusid', 3); $wp->att('theoreticaldistance', null); $wp->att('theoreticaltypical', null); $wp->att('theoreticalconsumption', null); $wp->att('theoreticaldrivetime', null); $wp->att('theoreticalchargetime', null); $wp->att('theoreticalchargeneeded', CalculateChargeNeeded(210)); $wp->save(); echo 'Waypoint ' . $wp->att('destination') . ' (id : ' . $wp->att('objid') . ') saved<br>'; $wp = new waypoint(); $wp->att('tripid', $tripid); $wp->att('destination', 'SuC Orange'); $wp->att('typeid', 3); $wp->att('statusid', 0); $wp->att('theoreticaldistance', 186.7); $wp->att('theoreticaltypical', 210); $wp->att('theoreticalconsumption', 40.0); $wp->att('theoreticaldrivetime', 150); $wp->att('theoreticalchargetime', null); $wp->att('theoreticalchargeneeded', CalculateChargeNeeded(240)); $wp->save(); echo 'Waypoint ' . $wp->att('destination') . ' (id : ' . $wp->att('objid') . ') saved<br>'; $wp = new waypoint(); $wp->att('tripid', $tripid); $wp->att('destination', 'SuC Vienne'); $wp->att('typeid', 3); $wp->att('statusid', 0); $wp->att('theoreticaldistance', 184.5); $wp->att('theoreticaltypical', 240); $wp->att('theoreticalconsumption', 45.0); $wp->att('theoreticaldrivetime', 110); $wp->att('theoreticalchargetime', null); $wp->att('theoreticalchargeneeded', CalculateChargeNeeded(200)); $wp->save(); echo 'Waypoint ' . $wp->att('destination') . ' (id : ' . $wp->att('objid') . ') saved<br>'; $wp = new waypoint(); $wp->att('tripid', $tripid); $wp->att('destination', 'SuC Beaune'); $wp->att('typeid', 3); $wp->att('statusid', 0); $wp->att('theoreticaldistance', 173.9); $wp->att('theoreticaltypical', 200); $wp->att('theoreticalconsumption', 37.0); $wp->att('theoreticaldrivetime', 110); $wp->att('theoreticalchargetime', null); $wp->att('theoreticalchargeneeded', CalculateChargeNeeded(188)); $wp->save(); echo 'Waypoint ' . $wp->att('destination') . ' (id : ' . $wp->att('objid') . ') saved<br>'; $wp = new waypoint(); $wp->att('tripid', $tripid); $wp->att('destination', 'Suc Auxerre (Novotel)'); $wp->att('typeid', 2); $wp->att('statusid', 0); $wp->att('theoreticaldistance', 153.2); $wp->att('theoreticaltypical', 188); $wp->att('theoreticalconsumption', 35.0); $wp->att('theoreticaldrivetime', 95); $wp->att('theoreticalchargetime', null); $wp->att('theoreticalchargeneeded', null); $wp->save(); echo 'Waypoint ' . $wp->att('destination') . ' (id : ' . $wp->att('objid') . ') saved<br>'; } if ($route == 52) { $wp = new waypoint(); $wp->att('tripid', $tripid); $wp->att('destination', 'La Trêve'); $wp->att('typeid', 1); $wp->att('statusid', 3); $wp->att('theoreticaldistance', null); $wp->att('theoreticaltypical', null); $wp->att('theoreticalconsumption', null); $wp->att('theoreticaldrivetime', null); $wp->att('theoreticalchargetime', null); $wp->att('theoreticalchargeneeded', CalculateChargeNeeded(313)); $wp->save(); echo 'Waypoint ' . $wp->att('destination') . ' (id : ' . $wp->att('objid') . ') saved<br>'; $wp = new waypoint(); $wp->att('tripid', $tripid); $wp->att('destination', 'SuC Valence'); $wp->att('typeid', 3); $wp->att('statusid', 0); $wp->att('theoreticaldistance', 272.6); $wp->att('theoreticaltypical', 313); $wp->att('theoreticalconsumption', 58.0); $wp->att('theoreticaldrivetime', 200); $wp->att('theoreticalchargetime', null); $wp->att('theoreticalchargeneeded', CalculateChargeNeeded(295)); $wp->save(); echo 'Waypoint ' . $wp->att('destination') . ' (id : ' . $wp->att('objid') . ') saved<br>'; $wp = new waypoint(); $wp->att('tripid', $tripid); $wp->att('destination', 'SuC Beaune'); $wp->att('typeid', 3); $wp->att('statusid', 0); $wp->att('theoreticaldistance', 254.8); $wp->att('theoreticaltypical', 295); $wp->att('theoreticalconsumption', 55.0); $wp->att('theoreticaldrivetime', 170); $wp->att('theoreticalchargetime', null); $wp->att('theoreticalchargeneeded', CalculateChargeNeeded(188)); $wp->save(); echo 'Waypoint ' . $wp->att('destination') . ' (id : ' . $wp->att('objid') . ') saved<br>'; $wp = new waypoint(); $wp->att('tripid', $tripid); $wp->att('destination', 'Suc Auxerre (Novotel)'); $wp->att('typeid', 2); $wp->att('statusid', 0); $wp->att('theoreticaldistance', 153.2); $wp->att('theoreticaltypical', 188); $wp->att('theoreticalconsumption', 35.0); $wp->att('theoreticaldrivetime', 95); $wp->att('theoreticalchargetime', null); $wp->att('theoreticalchargeneeded', null); $wp->save(); echo 'Waypoint ' . $wp->att('destination') . ' (id : ' . $wp->att('objid') . ') saved<br>'; } if ($route == 6) { $wp = new waypoint(); $wp->att('tripid', $tripid); $wp->att('destination', 'Suc Auxerre (Novotel)'); $wp->att('typeid', 1); $wp->att('statusid', 3); $wp->att('theoreticaldistance', null); $wp->att('theoreticaltypical', null); $wp->att('theoreticalconsumption', null); $wp->att('theoreticaldrivetime', null); $wp->att('theoreticalchargetime', null); $wp->att('theoreticalchargeneeded', CalculateChargeNeeded(240)); $wp->save(); echo 'Waypoint ' . $wp->att('destination') . ' (id : ' . $wp->att('objid') . ') saved<br>'; $wp = new waypoint(); $wp->att('tripid', $tripid); $wp->att('destination', 'SuC Senlis'); $wp->att('typeid', 3); $wp->att('statusid', 0); $wp->att('theoreticaldistance', 210.0); $wp->att('theoreticaltypical', 240); $wp->att('theoreticalconsumption', 42.0); $wp->att('theoreticaldrivetime', 145); $wp->att('theoreticalchargetime', null); $wp->att('theoreticalchargeneeded', CalculateChargeNeeded(200)); $wp->save(); echo 'Waypoint ' . $wp->att('destination') . ' (id : ' . $wp->att('objid') . ') saved<br>'; $wp = new waypoint(); $wp->att('tripid', $tripid); $wp->att('destination', 'SuC Lille'); $wp->att('typeid', 3); $wp->att('statusid', 0); $wp->att('theoreticaldistance', 165.0); $wp->att('theoreticaltypical', 200); $wp->att('theoreticalconsumption', 35.0); $wp->att('theoreticaldrivetime', 100); $wp->att('theoreticalchargetime', null); $wp->att('theoreticalchargeneeded', CalculateChargeNeeded(200)); $wp->save(); echo 'Waypoint ' . $wp->att('destination') . ' (id : ' . $wp->att('objid') . ') saved<br>'; $wp = new waypoint(); $wp->att('tripid', $tripid); $wp->att('destination', 'Brecht (thuis)'); $wp->att('typeid', 3); $wp->att('statusid', 0); $wp->att('theoreticaldistance', 160.0); $wp->att('theoreticaltypical', 200); $wp->att('theoreticalconsumption', 30.0); $wp->att('theoreticaldrivetime', 110); $wp->att('theoreticalchargetime', null); $wp->att('theoreticalchargeneeded', null); $wp->save(); echo 'Waypoint ' . $wp->att('destination') . ' (id : ' . $wp->att('objid') . ') saved<br>'; } echo '<br>done<br>'; }
//------------------------------------- // get other parameters $tripId = strtolower($_REQUEST['tripid']); $wpId = strtolower($_REQUEST['wpid']); $departuretypical = strtolower($_REQUEST['departuretypical']); $departuredistance = strtolower($_REQUEST['departuredistance']); $departureconsumption = strtolower($_REQUEST['departureconsumption']); // do the update of the waypoint $wp = new waypoint(); $wp->retrieve($wpId); $wp->att('departuredistance', $departuredistance); $wp->att('departuretypical', $departuretypical); $wp->att('departureconsumption', $departureconsumption); $wp->att('departuretime', time()); $wp->att('statusid', WaypointStatus::STATUS_LEFT); $wp->save(); // change status of Trip for start at first waypont if ($wp->att('typeid') == WaypointType::TYPE_STARTPOINT) { $trip = new trip(); $trip->retrieve($tripId); $trip->att('statusid', TripStatus::STATUS_STARTED); $trip->save(); } // retrieve the data echo json_encode(GetTripDetail($tripId)); break; default: echo ''; break; } function LogIn($car, $password)