TAV1702 Posted April 7, 2011 Report Share Posted April 7, 2011 Hi everyone. I am working on yet another little project that I could use a hand with. In the schedule results.tpl file, I have added the following to show what type of flight it is, Cargo, Passenger, or charter. <?php echo ($route->flighttype=='') ? '' : '<strong>Flight Type: </strong>'.$route->flighttype.'<br />' ?> Now I am curious. Can an if statement be included so say if flghttype = C echo Cargo? Right now the way I have it, it simply shows the results as C, P, or H. I would like to add another code like the one above to show how much it pays for that flight but have yet to get that one to work. Maybe I can ix the code from the schedules are in the admin panel? So in all, the schedule results page would show on the left like SYX1067 (KMKE - KSDF) Departure: 8:05 AM CDT Arrival: 10:45 AM EDT Equipment: B1900D (N801SK) Distance: 303.318nm Days Flown: T W Th F Flight Type: Charter Pay for Flight: $765 Quote Link to comment Share on other sites More sharing options...
Nuclear Posted April 7, 2011 Report Share Posted April 7, 2011 Yes, you could use a series of if statements: <?php echo 'Flight Type: '; if($route->flighttype=='P') echo 'Passenger<br />'; elseif($route-flighttype=='C') echo 'Cargo<br />'; ...?> You can also use a switch statement: <?php echo 'Flight Type: '; switch($route->flighttype) { case 'C': echo 'Cargo<br />'; break; case 'P': echo 'Passenger<br />'; break; ... }?> 1 Quote Link to comment Share on other sites More sharing options...
TAV1702 Posted April 8, 2011 Author Report Share Posted April 8, 2011 The top one actually works out pretty good as far as the passengers part goes. It seems to ignore the Cargo and charter flights. If you have any ideas, I am game to try. I am also working on this as we speak. If I get it to work, I will let you know. Thanks for helping out on this one. Ray Quote Link to comment Share on other sites More sharing options...
TAV1702 Posted April 8, 2011 Author Report Share Posted April 8, 2011 Ok so I tweaked it a tad and now I got it to echo charter as well, issue is, I did away with the elseif and went with another else echo and now all non passenger flights show up as Charter. I had figured that was going to be the result but tried it anyhow. <?php echo '<strong>Flight Type: </strong>'; if($route->flighttype=='P') echo 'Passenger<br />'; elseif($route-flighttype=='C') echo 'Cargo<br />'; else echo 'Charter<br />'; ?> Quote Link to comment Share on other sites More sharing options...
TAV1702 Posted April 8, 2011 Author Report Share Posted April 8, 2011 Got it! I had a typo. I debugged it and now she works. <?php echo '<strong>Flight Type: </strong>'; if($route->flighttype=="P"){ echo "Passenger<br />"; } elseif($route->flighttype=="C"){ echo "Cargo<br />"; } else { echo "Charter<br />"; } ?> Now if Nabeel or some kind soul would chime in and tell us how to pull up the Flight Value part, I would be happier then could possibly be. Thanks for pointing me down the right path Nuclear. Quote Link to comment Share on other sites More sharing options...
Jeff Posted April 8, 2011 Report Share Posted April 8, 2011 <td align = "center">$<?php echo $result->price;?></td> Try this Ray. Tis is what I use to show the price of my flights on the results page. Quote Link to comment Share on other sites More sharing options...
Jeff Posted April 8, 2011 Report Share Posted April 8, 2011 Actually, this one might work better for you... <strong>Price: </strong>$<?php echo $route->price;?> 1 Quote Link to comment Share on other sites More sharing options...
TAV1702 Posted April 8, 2011 Author Report Share Posted April 8, 2011 Nice Jeff! Thanks man. That worked out great. Quote Link to comment Share on other sites More sharing options...
TAV1702 Posted April 8, 2011 Author Report Share Posted April 8, 2011 You know what...... I just noticed, it is showing ticket price for passengers or cargo charge. Ijust saw one flight valued at $2.95 lol I wonder how many pilots would turn down that job. And at $2.95 that same flight actually pays the pilot like $1100 I believe it was. That works if we wish to show how much we are charging the passenger or cargo for the flight. I need to figure out how to make it show me how much cash the pilot will be paid for said flight. Not sure if we can do that or not with the pilot pay by the hour or per flight. I am sure there is a way though. The trick is to figure it out. Quote Link to comment Share on other sites More sharing options...
TAV1702 Posted April 11, 2011 Author Report Share Posted April 11, 2011 I un-marked this one as solved. It is kind of solved. I have played with code until I was blue in the face and I can not get this to pull the pilot pay for a flight one. Using the code suggested above, it does pull either the ticket price or cargo per unit charge and echos it, but it will not show the actual pilot pay. Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted April 11, 2011 Administrators Report Share Posted April 11, 2011 Did you try $route->pilotpay? If you do: echo '<pre>'; print_r($route); echo '</pre>'; It will tell you all of the contents of the $route variable, you can pick and chose what you want 1 Quote Link to comment Share on other sites More sharing options...
TAV1702 Posted April 12, 2011 Author Report Share Posted April 12, 2011 Did you try $route->pilotpay? If you do: echo '<pre>'; print_r($route); echo '</pre>'; It will tell you all of the contents of the $route variable, you can pick and chose what you want Nope I don't think I traveled down that road Nabeel. I'll give that a go here in a few minutes. I think I tried every thing but that one. Quote Link to comment Share on other sites More sharing options...
TAV1702 Posted April 12, 2011 Author Report Share Posted April 12, 2011 GOT IT! Thanks Nabeel! To show the pilot pay the code is: <strong>Flight Value: </strong>$<?php echo $route->payforflight;?> I have to remember to use that print r thing. It has saved my bacon more than once now. Quote Link to comment Share on other sites More sharing options...
Jeff Posted May 3, 2011 Report Share Posted May 3, 2011 Ray... I added this code and i get a blank number after the "$" AC1144 (CYQB - CYYZ) Departure: 1:15 Arrival: 2:42 Equipment: CRJ-700 (AC-CRJ7) Distance: 395.813nm Days Flown: M T W Th F S Su Airline: Air Canada Jazz Flight Type: Passenger Price: $135 Flight Value: $ <----------------It is blank Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted May 3, 2011 Administrators Report Share Posted May 3, 2011 Try the print_r trick to see what variables are populated Quote Link to comment Share on other sites More sharing options...
Jeff Posted May 3, 2011 Report Share Posted May 3, 2011 I noticed on some flights it was showing: $ This flight has been bid on 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.