mseiwald Posted July 3, 2012 Author Report Share Posted July 3, 2012 how would i try it that way you suggested? the reason why the thing with the schedules table came to my mind is because there already is the column "timesflown" in there which actually shows the count how often the route was flown. I was thinking that has to be Incremented by the PIREPData.class when a pirep was submited.... so i thought if that info can be passed into the schedules table it also should be possible to pass the date into another column of the schedules table. or comes the timesflown from the bids which of course would then be inside the SchedulesData.... EDIT: ok i just found it is in the schedules data */ public static function IncrementFlownCount($code, $flightnum) { $schedid = intval($schedid); $code = strtoupper($code); $flightnum = strtoupper($flightnum); $sql = 'UPDATE '.TABLE_PREFIX."schedules SET timesflown=timesflown+1 WHERE code='{$code}' AND flightnum='{$flightnum}'"; $res = DB::query($sql); if(DB::errno() != 0) return false; return true; } however from where does the info come to increment it? .... or wait... wouldn`t it be possible to just add that to this function to populate the lastflown column with the date too? we wouldn`t even need to look for the pirep submitdate...it would be enough if everytime a flight is incremented by 1 also the lastflown column is updated by todays date. that would be enough Quote Link to comment Share on other sites More sharing options...
mseiwald Posted July 3, 2012 Author Report Share Posted July 3, 2012 I got it that works: public static function IncrementFlownCount($code, $flightnum) { $schedid = intval($schedid); $code = strtoupper($code); $flightnum = strtoupper($flightnum); $today = $today = date("Y-m-d"); $sql = 'UPDATE '.TABLE_PREFIX."schedules SET timesflown=timesflown+1, lastflown='$today' WHERE code='{$code}' AND flightnum='{$flightnum}'"; $res = DB::query($sql); if(DB::errno() != 0) return false; return true; } Quote Link to comment Share on other sites More sharing options...
Moderators Parkho Posted July 3, 2012 Moderators Report Share Posted July 3, 2012 Great. I have different approach to get the schedules flight count for today but can you share the info? Quote Link to comment Share on other sites More sharing options...
mseiwald Posted July 3, 2012 Author Report Share Posted July 3, 2012 there is nothing else to do... i got into phpMyAdmin and added a column called lastflown at the bottom of the schedules table then the original code inside the SchedulesData.class.php was */ public static function IncrementFlownCount($code, $flightnum) { $schedid = intval($schedid); $code = strtoupper($code); $flightnum = strtoupper($flightnum); $sql = 'UPDATE '.TABLE_PREFIX."schedules SET timesflown=timesflown+1 WHERE code='{$code}' AND flightnum='{$flightnum}'"; $res = DB::query($sql); if(DB::errno() != 0) return false; return true; } i changed that to: public static function IncrementFlownCount($code, $flightnum) { $schedid = intval($schedid); $code = strtoupper($code); $flightnum = strtoupper($flightnum); $today = $today = date("Y-m-d"); $sql = 'UPDATE '.TABLE_PREFIX."schedules SET timesflown=timesflown+1, lastflown='$today' WHERE code='{$code}' AND flightnum='{$flightnum}'"; $res = DB::query($sql); if(DB::errno() != 0) return false; return true; } now the lastflown column is updated whenever a pirep is filed with the actual date and that can be called in the schedule_results.tpl by using $route->lastflown i have the if statement in the schedules_results.tpl like that: $today = date("Y-m-d"); if($route->lastflown == $today) { .................. } and it works just perfect hehe Quote Link to comment Share on other sites More sharing options...
Moderators Parkho Posted July 3, 2012 Moderators Report Share Posted July 3, 2012 Yep! Works like a charm. You did it Quote Link to comment Share on other sites More sharing options...
mseiwald Posted July 3, 2012 Author Report Share Posted July 3, 2012 great! so i can mark that thread as solved Quote Link to comment Share on other sites More sharing options...
michael Kraan Posted April 5, 2013 Report Share Posted April 5, 2013 i dont know where i can put that code, i know in the schedules_results.tpl. But and than? I hop that you can help? $today = date("Y-m-d"); if($route->lastflown == $today) { .................. } Quote Link to comment Share on other sites More sharing options...
Txmmy83 Posted April 8, 2013 Report Share Posted April 8, 2013 i dont know where i can put that code, i know in the schedules_results.tpl. But and than? I hop that you can help? $today = date("Y-m-d"); if($route->lastflown == $today) { .................. } I am also Interested where that code need to be placed? think we have to wait til mseiwald or Parviz answer! Quote Link to comment Share on other sites More sharing options...
mseiwald Posted April 9, 2013 Author Report Share Posted April 9, 2013 it depends on what you want to do. If you want to skip all routes that have already been flown on that day then you can search this /* THIS BEGINS ONE TABLE ROW */ in your schedule_results.tpl and just above that add $today = date("Y-m-d"); if($route->lastflown == $today) { continue; } 1 Quote Link to comment Share on other sites More sharing options...
Txmmy83 Posted April 9, 2013 Report Share Posted April 9, 2013 thanks works great Quote Link to comment Share on other sites More sharing options...
Txmmy83 Posted April 19, 2013 Report Share Posted April 19, 2013 how can this modified to work with latest beta which I need to use because of aircraft buy mod the function is splitted into two instead of one in the beta public static function incrementFlownCount($code, $flightnum) { return self::changeFlownCount($code, $flightnum, '+1'); } /** * SchedulesData::changeFlownCount() * * @param mixed $code * @param mixed $flightnum * @param mixed $amount * @return void */ public static function changeFlownCount($code, $flightnum, $amount) { $schedid = intval($schedid); $code = strtoupper($code); $flightnum = strtoupper($flightnum); if(substr_count($amount, '+') == 0) { $amount = '+'.$amount; } $sql = 'UPDATE ' . TABLE_PREFIX . "schedules SET timesflown=timesflown {$amount} WHERE code='{$code}' AND flightnum='{$flightnum}'"; $res = DB::query($sql); if (DB::errno() != 0) return false; return true; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.