Jump to content

Flight only once per day [SOLVED]


mseiwald

Recommended Posts

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

Link to comment
Share on other sites

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;
}

Link to comment
Share on other sites

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 ;)

Link to comment
Share on other sites

  • 9 months later...

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!

Link to comment
Share on other sites

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;
}

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

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;

   }

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...