Jump to content

Restrict Aircraft


mattsmith

Recommended Posts

Add this to your OperationsData.class.php

public static function getBidByAircraft($aircraftid) {
  $aircraftid = DB::escape($aircraftid);
  $sql = 'SELECT s.*, b.bidid, a.name as aircraft, a.id as aircraftid, a.registration
    FROM ' . TABLE_PREFIX . 'schedules s, ' . TABLE_PREFIX . 'bids b,
    ' . TABLE_PREFIX . 'aircraft a
    WHERE b.routeid = s.id 
    AND s.aircraft='.$aircraftid;
  return DB::get_row($sql);
}

And Add/Replace this in your schedule_results.php file

<?php
# If aircraft is disabled
$aircraft = OperationsData::getAircraftInfo($schedule->aircraftid);
# Aircraft has already been bidded by another pilot
$acbidded = OperationsData::getBidByAircraft($schedule->aircraftid);
if($aircraft->enabled != 1) {
	echo 'Unable to Bid! Aircraft is disabled!';
} elseif($acbidded) {
	echo 'Unable to Bid! Aircraft already bidded!';						
} elseif(Config::Get('DISABLE_SCHED_ON_BID') == true && $schedule->bidid != 0) {
	echo '<a id="'.$schedule->id.'" class="addbid" href="'.SITE_URL.'/action.php/schedules/addbid/?id='.$schedule->id.'">Add to Bid</a>';
} else {
	if(Auth::LoggedIn()) {
		echo '<a id="'.$schedule->id.'" class="addbid" href="'.SITE_URL.'/index.php/schedules/addbid/?id='.$schedule->id.'">Add to Bid</a>';
	}
}
?>

 

Edited by web541
Link to comment
Share on other sites

  • Moderators
On 15/2/2017 at 5:47 PM, web541 said:

Add this to your OperationsData.class.php


public static function getBidByAircraft($aircraftid) {
  $aircraftid = DB::escape($aircraftid);
  $sql = 'SELECT s.*, b.bidid, a.name as aircraft, a.id as aircraftid, a.registration
    FROM ' . TABLE_PREFIX . 'schedules s, ' . TABLE_PREFIX . 'bids b,
    ' . TABLE_PREFIX . 'aircraft a
    WHERE b.routeid = s.id 
    AND s.aircraft='.$aircraftid;
  return DB::get_row($sql);
}

And Add/Replace this in your schedule_results.php file


<?php
# If aircraft is disabled
$aircraft = OperationsData::getAircraftInfo($schedule->aircraftid);
# Aircraft has already been bidded by another pilot
$acbidded = OperationsData::getBidByAircraft($schedule->aircraftid);
if($aircraft->enabled != 1) {
	echo 'Unable to Bid! Aircraft is disabled!';
} elseif($acbidded) {
	echo 'Unable to Bid! Aircraft already bidded!';						
} elseif(Config::Get('DISABLE_SCHED_ON_BID') == true && $schedule->bidid != 0) {
	echo '<a id="'.$schedule->id.'" class="addbid" href="'.SITE_URL.'/action.php/schedules/addbid/?id='.$schedule->id.'">Add to Bid</a>';
} else {
	if(Auth::LoggedIn()) {
		echo '<a id="'.$schedule->id.'" class="addbid" href="'.SITE_URL.'/index.php/schedules/addbid/?id='.$schedule->id.'">Add to Bid</a>';
	}
}
?>

 

And how can I do it by the "Fltbook"?

(I guess is your own module)

Link to comment
Share on other sites

2 hours ago, joooseb said:

And how can I do it by the "Fltbook"?

(I guess is your own module)

Try this (should be able to just replace $schedule with $route

<?php
# If aircraft is disabled
$aircraft = OperationsData::getAircraftInfo($schedule->aircraftid);
# Aircraft has already been bidded by another pilot
$acbidded = OperationsData::getBidByAircraft($schedule->aircraftid);
if($aircraft->enabled != 1) {
	echo '<div class="btn btn-danger btn-sm sharp disabled">Booked (Aircraft Disabled)</div>'; # Aircraft Disabled
} elseif($acbidded) {
	echo '<div class="btn btn-danger btn-sm sharp disabled">Booked (Aircraft Bidded)</div>'; # Aircraft Bidded			
} elseif(Config::Get('DISABLE_SCHED_ON_BID') == true && $schedule->bidid != 0) {
	echo '<a data-toggle="modal" href="'.SITE_URL.'/action.php/Fltbook/confirm?id='.$route->id.'&airline='.$route->code.'&aicao='.$route->aircrafticao.'" data-target="#confirm" class="btn btn-success btn-md">Book</a>'; # Schedule's already been bidded
} else {
	if(Auth::LoggedIn()) {
		echo '<a data-toggle="modal" href="'.SITE_URL.'/action.php/Fltbook/confirm?id='.$route->id.'&airline='.$route->code.'&aicao='.$route->aircrafticao.'" data-target="#confirm" class="btn btn-success btn-md">Book</a>'; # Default
	}
}
?>

Link to comment
Share on other sites

  • Moderators
58 minutes ago, web541 said:

Try this (should be able to just replace $schedule with $route

 

  Hide contents

 



<?php
# If aircraft is disabled
$aircraft = OperationsData::getAircraftInfo($schedule->aircraftid);
# Aircraft has already been bidded by another pilot
$acbidded = OperationsData::getBidByAircraft($schedule->aircraftid);
if($aircraft->enabled != 1) {
	echo '<div class="btn btn-danger btn-sm sharp disabled">Booked (Aircraft Disabled)</div>'; # Aircraft Disabled
} elseif($acbidded) {
	echo '<div class="btn btn-danger btn-sm sharp disabled">Booked (Aircraft Bidded)</div>'; # Aircraft Bidded			
} elseif(Config::Get('DISABLE_SCHED_ON_BID') == true && $schedule->bidid != 0) {
	echo '<a data-toggle="modal" href="'.SITE_URL.'/action.php/Fltbook/confirm?id='.$route->id.'&airline='.$route->code.'&aicao='.$route->aircrafticao.'" data-target="#confirm" class="btn btn-success btn-md">Book</a>'; # Schedule's already been bidded
} else {
	if(Auth::LoggedIn()) {
		echo '<a data-toggle="modal" href="'.SITE_URL.'/action.php/Fltbook/confirm?id='.$route->id.'&airline='.$route->code.'&aicao='.$route->aircrafticao.'" data-target="#confirm" class="btn btn-success btn-md">Book</a>'; # Default
	}
}
?>

 

 

Thanks, but i think the code must be on confirmbid.tpl

Here's my code: (confirmbid.tpl)

<style>
.sharp {
	border-radius: 0;	
	margin-left: 3px;
	margin-right: 3px;
}
</style>
<div class="container-fluid">
    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal">&times;</button>
      <h4 class="modal-title">Confirmar Reserva<!-- <?php echo $routeid; ?> | <?php echo $airline; ?> | <?php echo $aicao; ?> --></h4>
    </div>
        <div class="modal-body">
          <h3>Seleccionar Aeronave</h3>
    <form action="<?php echo url('/schedules/addbid');?>" method="post">
		<select class="form-control" name="aircraftid" id="aircraftid">
			<option value="" selected disabled>Selecciona Tu Avi贸n</option>




 <?php
            
            $allaircraft = FltbookData::getAllAircraftFltbook($airline, $aicao);
                        
            foreach($allaircraft as $aircraft)
            {
            	$icaoairline = "{$aircraft->icao}{$airline}";
                if($aircraft->registration == $icaoairline) {
                	echo '';
                } else {
                $sel = ($_POST['aircraft'] == $aircraft->name || $bid->registration == $aircraft->registration)?'selected':'';
                
                echo '<option value="'.$aircraft->id.'" '.$sel.'>'.$aircraft->registration.' - '.$aircraft->icao.' - '.$aircraft->name.' ('.(AircraftMarketData::getaccond($aircraft->id)).'%)</option>';
        		}
        }
        ?>
		</select>
        <hr />
        <input type="hidden" name="routeid" value="<?php echo $routeid; ?>" />
        <input type="submit" name="submit" class="btn btn-success" value="Reservar" />
        <button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
    </form>
        </div>
    <!-- 
        <a class="btn btn-success" href="<?php echo url('/schedules/addbid/'.$routeid.'?id='.$aircraft->id);?>">Book</a>
    -->
</div>

Where can I add the code above?

 

Link to comment
Share on other sites

Add the code from my above post in schedule_results and then add this in the confirmbid

<?php
$allaircraft = FltbookData::getAllAircraftFltbook($airline, $aicao);

foreach($allaircraft as $aircraft)
{
	$bidded = OperationsData::getBidByAircraft($aircraft->id);
	if($aircraft->enabled != 1) { continue; }
	if($bidded) { continue; }
	$icaoairline = "{$aircraft->icao}{$airline}";
	if($aircraft->registration == $icaoairline) {
		echo '';
	} else {
	$sel = ($_POST['aircraft'] == $aircraft->name || $bid->registration == $aircraft->registration)?'selected':'';

	echo '<option value="'.$aircraft->id.'" '.$sel.'>'.$aircraft->registration.' - '.$aircraft->icao.' - '.$aircraft->name.' ('.(AircraftMarketData::getaccond($aircraft->id)).'%)</option>';
	}
}
?>

 

Link to comment
Share on other sites

  • Moderators
On 17/2/2017 at 3:47 AM, web541 said:

Add the code from my above post in schedule_results and then add this in the confirmbid


<?php
$allaircraft = FltbookData::getAllAircraftFltbook($airline, $aicao);

foreach($allaircraft as $aircraft)
{
	$bidded = OperationsData::getBidByAircraft($aircraft->id);
	if($aircraft->enabled != 1) { continue; }
	if($bidded) { continue; }
	$icaoairline = "{$aircraft->icao}{$airline}";
	if($aircraft->registration == $icaoairline) {
		echo '';
	} else {
	$sel = ($_POST['aircraft'] == $aircraft->name || $bid->registration == $aircraft->registration)?'selected':'';

	echo '<option value="'.$aircraft->id.'" '.$sel.'>'.$aircraft->registration.' - '.$aircraft->icao.' - '.$aircraft->name.' ('.(AircraftMarketData::getaccond($aircraft->id)).'%)</option>';
	}
}
?>

 

Works but with some aircraft... Look at the attached pics!

Thanks for your time :D!

aasd1.png

asdasd2.png

asdasd3.png

Link to comment
Share on other sites

Add this

<?php
# Aircraft has already been bidded by another pilot
$acbidded = OperationsData::getBidByAircraft($schedule->aircraftid);
if($acbidded) {
	echo 'Aircraft Free!';		
} else {
	echo 'Aircraft Booked!';
}
?>

Change $schedule->aircraftid on the first line to the variable of your fleet page.

Link to comment
Share on other sites

  • Moderators
10 hours ago, web541 said:

Add this


<?php
# Aircraft has already been bidded by another pilot
$acbidded = OperationsData::getBidByAircraft($schedule->aircraftid);
if($acbidded) {
	echo 'Aircraft Free!';		
} else {
	echo 'Aircraft Booked!';
}
?>

Change $schedule->aircraftid on the first line to the variable of your fleet page.

Nice but i Think i don't have any variables for schedule :( jajaja look at my fleet page snippet code:

<?php require 'lib/skins/crewcenter/app_top.php' ?>

<section class="content-header">
    <h1>Flota</h1>
</section>
<section class="content">

<section class="content">
    <div class="row">
        <div class="col-lg-16">
            <div class="box box-primary">
                <div class="box-body table-responsive">
 <table id="tabledlist" class="tablesorter table table-hover">
                        <thead>
                            <tr>
                                <center>
			<th>Aerol&iacute;nea</th>
			<th>Tipo</th>
    			<th>Matr&iacute;cula</th>
			<th>Ubicaci&oacute;n</th>
			<th>Disponibilidad</th>
			<th>Estado</th>
			<th>Detalles</th>
		</tr>
	</thead>
	<tbody>
	<center>
	<?php if($aircrafts != null){ foreach($aircrafts as $aircrafts){ ?>
 		
		<tr>	<td><?php
                        
                         $allairlines = OperationsData::GetAllAirlines(true);
foreach($allairlines as $airline)
                             
			if($airline->code == $aircrafts->airline)
			{
                                         echo '<option value="'.$airline->code.'">'.$airline->name.'</option>';
                         }
                         ?></td>
			<td><?php echo $aircrafts->fullname; ?></td>

			<td><?php echo $aircrafts->registration; ?></td>
			
			<?php
	
			$params = (array('a.registration'=>$aircrafts->registration, 'p.accepted'=>PIREP_ACCEPTED));

$pirep = PIREPData::findPIREPS($params);
$current_location2 = $pirep[0]->arrname;
?>
<td style="font-weight: bolder;"><?php echo $current_location.''.$current_location2; ?></td>
<td><?php If($aircrafts->enabled == 1){echo 'Disponible';} elseif($aircrafts->enabled == 0) {echo '<p style="color:red">En Mantenimiento';} ?></td>

<td><?php echo AircraftMarketData::getaccond($aircrafts->id);?>%</td>

			


			<td><a class="btn btn-primary btn-block" href="<?php echo url('fleet/view/' . $aircrafts->id); ?>">Ver</a></td>
			
		</tr>
	
	<?php } }?>
	</tbody>
</table>
                </div>
            </div>
        </div>
    </div>
</section>

<?php require 'lib/skins/crewcenter/app_bottom.php' ?>

 

Link to comment
Share on other sites

Quote


<?php require 'lib/skins/crewcenter/app_top.php' ?>

<section class="content-header">
    <h1>Flota</h1>
</section>
<section class="content">

<section class="content">
    <div class="row">
        <div class="col-lg-16">
            <div class="box box-primary">
                <div class="box-body table-responsive">
                    <table id="tabledlist" class="tablesorter table table-hover">
                      <thead>
                        <tr>
                            <center>
	                            <th>Aerol&iacute;nea</th>
	                            <th>Tipo</th>
			                        <th>Matr&iacute;cula</th>
                        			<th>Ubicaci&oacute;n</th>
                        			<th>Disponibilidad</th>
                        			<th>Estado</th>
                        			<th>Detalles</th>
                            </center>
                    		</tr>
                      </thead>
	                    <tbody>
	                    <center>
	                    <?php if($aircrafts != null) { foreach($aircrafts as $aircrafts) { ?>
 		                     <tr>
                          <td>
                          <?php
                            $allairlines = OperationsData::GetAllAirlines(true);
                            foreach($allairlines as $airline) {
		                         if($airline->code == $aircrafts->airline) {
                                echo '<option value="'.$airline->code.'">'.$airline->name.'</option>';
                             }
                         ?>
                         </td>
			                   <td><?php echo $aircrafts->fullname; ?></td>
			                   <td><?php echo $aircrafts->registration; ?></td>
			                   <?php
  			                   $params = (array('a.registration'=>$aircrafts->registration, 'p.accepted'=>PIREP_ACCEPTED));
                           $pirep = PIREPData::findPIREPS($params);
                           $current_location2 = $pirep[0]->arrname;
                         ?>
                          <td style="font-weight: bolder;"><?php echo $current_location.''.$current_location2; ?></td>
                          <td><?php If($aircrafts->enabled == 1){ echo 'Disponible';} elseif($aircrafts->enabled == 0) {echo '<p style="color:red">En Mantenimiento';} ?></td>
                          <td><?php echo AircraftMarketData::getaccond($aircrafts->id);?>%</td>
                          <td><a class="btn btn-primary btn-block" href="<?php echo url('fleet/view/' . $aircrafts->id); ?>">Ver</a></td>
		                    </tr>
	                      <?php } }?>
                  	</tbody>
                  </table>
                </div>
            </div>
        </div>
    </div>
</section>

<?php require 'lib/skins/crewcenter/app_bottom.php' ?>

Try this

<?php
# Aircraft has already been bidded by another pilot
$acbidded = OperationsData::getBidByAircraft($aircrafts->id);
if($acbidded) {
	echo 'Aircraft Free!';		
} else {
	echo 'Aircraft Booked!';
}
?>

If that doesn't work, a link to your site and/or an image of the fleet page would help.

Link to comment
Share on other sites

  • 2 weeks later...
  • Moderators
On 21/2/2017 at 5:18 PM, web541 said:

Try this


<?php
# Aircraft has already been bidded by another pilot
$acbidded = OperationsData::getBidByAircraft($aircrafts->id);
if($acbidded) {
	echo 'Aircraft Free!';		
} else {
	echo 'Aircraft Booked!';
}
?>

If that doesn't work, a link to your site and/or an image of the fleet page would help.

Hi can you helo me? I'm using your fltbook system and A payware module (Tour system of Crazy creatives common). On booking process it works fine but when I try bid with tour center the following error appear:

Warning: Missing argument 3 for SchedulesData::addBid(), called in /home1/mcfilmsp/public_html/crewcenter/core/modules/TourCenter/TourCenter.php on line 188 and defined in /home1/mcfilmsp/public_html/crewcenter/core/common/SchedulesData.class.php on line 834
 
In Tourcenter.php missed the $aircraftid variable

 

 

Link to comment
Share on other sites

To do this, you've got a few options

  1. Add a few variable checks into the SchedulesData.class.php addbid function to check whether the $aircraftid variable exists for the tour center, this should allow both modules to work side-by-side.
  2. Move the SchedulesData.class.php addbid function into the Fltbook module, change a few links around and hope it works. Then get the original SchedulesData.class.php and replace your current one with it. This should also work as it is just the default which the TourCenter is trying to deal with.
  3. Merge my module and the TourCenter module to get both bookings to work side-by-side (I will not do this as I don't own it, and the dev. of the TourCenter probably won't either, so your on your own with this one).
  4. Test out my fltbook v2 module which should have everything concealed inside the module so that the default SchedulesData.class.php can be put back in and the TourCenter should work properly without interfering with fltbook.

Your choice. And what phpVMS version are you on? .tpl or .php.

Link to comment
Share on other sites

  • Moderators
14 hours ago, web541 said:

To do this, you've got a few options

  1. Add a few variable checks into the SchedulesData.class.php addbid function to check whether the $aircraftid variable exists for the tour center, this should allow both modules to work side-by-side.
  2. Move the SchedulesData.class.php addbid function into the Fltbook module, change a few links around and hope it works. Then get the original SchedulesData.class.php and replace your current one with it. This should also work as it is just the default which the TourCenter is trying to deal with.
  3. Merge my module and the TourCenter module to get both bookings to work side-by-side (I will not do this as I don't own it, and the dev. of the TourCenter probably won't either, so your on your own with this one).
  4. Test out my fltbook v2 module which should have everything concealed inside the module so that the default SchedulesData.class.php can be put back in and the TourCenter should work properly without interfering with fltbook.

Your choice. And what phpVMS version are you on? .tpl or .php.

I'm using .tpl version.

Where can I find your fltbook v2??

Edited by joooseb
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...