Skip to content
This repository has been archived by the owner on Dec 6, 2019. It is now read-only.

Commit

Permalink
fixed pay per flight bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Nabeel Shahzad committed Mar 17, 2011
1 parent 4195cbc commit 9bef365
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 34 deletions.
20 changes: 14 additions & 6 deletions admin/modules/Operations/Operations.php
Expand Up @@ -924,16 +924,24 @@ protected function edit_schedule_post() {
$week4 = '';
}

$data = array('code' => $this->post->code, 'flightnum' => $this->post->flightnum,
'depicao' => $this->post->depicao, 'arricao' => $this->post->arricao, 'route' =>
$this->post->route, 'aircraft' => $this->post->aircraft, 'flightlevel' => $this->post->flightlevel,
'distance' => $this->post->distance, 'deptime' => $this->post->deptime,
'arrtime' => $this->post->arrtime, 'flighttime' => $this->post->flighttime,
$data = array(
'code' => $this->post->code,
'flightnum' => $this->post->flightnum,
'depicao' => $this->post->depicao,
'arricao' => $this->post->arricao,
'route' => $this->post->route,
'aircraft' => $this->post->aircraft,
'flightlevel' => $this->post->flightlevel,
'distance' => $this->post->distance,
'deptime' => $this->post->deptime,
'arrtime' => $this->post->arrtime,
'flighttime' => $this->post->flighttime,
'daysofweek' => $daysofweek,
'week1' => $week1, 'week2' => $week2, 'week3' => $week3, 'week4' => $week4,
'price' => $this->post->price, 'payforflight' => $this->post->payforflight,
'flighttype' => $this->post->flighttype, 'notes' => $this->post->notes,
'enabled' => $enabled);
'enabled' => $enabled
);

$val = SchedulesData::editScheduleFields($this->post->id, $data);
if (!$val) {
Expand Down
29 changes: 27 additions & 2 deletions admin/modules/PIREPAdmin/PIREPAdmin.php
Expand Up @@ -196,11 +196,13 @@ public function editpirep() {
}

public function viewcomments() {

$this->set('comments', PIREPData::GetComments($this->get->pirepid));
$this->render('pireps_comments.tpl');
}

public function deletecomment() {

if (!isset($this->post)) {
return;
}
Expand All @@ -214,11 +216,13 @@ public function deletecomment() {
}

public function viewlog() {

$this->set('report', PIREPData::GetReportDetails($this->get->pirepid));
$this->render('pirep_log.tpl');
}

public function addcomment() {

if (isset($this->post->submit)) {
$this->add_comment_post();

Expand All @@ -235,6 +239,7 @@ public function addcomment() {
/* Utility functions */

protected function add_comment_post() {

$comment = $this->post->comment;
$commenter = Auth::$userinfo->pilotid;
$pirepid = $this->post->pirepid;
Expand All @@ -259,6 +264,7 @@ protected function add_comment_post() {
* the pilot's data
*/
protected function approve_pirep_post() {

$pirepid = $this->post->id;

if ($pirepid == '')
Expand Down Expand Up @@ -330,7 +336,11 @@ protected function reject_pirep_post() {
}

protected function edit_pirep_post() {
if ($this->post->code == '' || $this->post->flightnum == '' || $this->post->depicao == '' || $this->post->arricao == '' || $this->post->aircraft == '' || $this->post->flighttime == '') {
if ($this->post->code == '' || $this->post->flightnum == ''
|| $this->post->depicao == '' || $this->post->arricao == ''
|| $this->post->aircraft == '' || $this->post->flighttime == ''
) {

$this->set('message', 'You must fill out all of the required fields!');
$this->render('core_error.tpl');
return false;
Expand All @@ -348,7 +358,22 @@ protected function edit_pirep_post() {
$fuelcost = $this->post->fuelused * $this->post->fuelunitcost;

# form the fields to submit
$data = array('pirepid' => $this->post->pirepid, 'code' => $this->post->code, 'flightnum' => $this->post->flightnum, 'depicao' => $this->post->depicao, 'arricao' => $this->post->arricao, 'aircraft' => $this->post->aircraft, 'flighttime' => $this->post->flighttime, 'load' => $this->post->load, 'price' => $this->post->price, 'pilotpay' => $this->post->pilotpay, 'fuelused' => $this->post->fuelused, 'fuelunitcost' => $this->post->fuelunitcost, 'fuelprice' => $fuelcost, 'expenses' => $this->post->expenses);
$data = array(
'pirepid' => $this->post->pirepid,
'code' => $this->post->code,
'flightnum' => $this->post->flightnum,
'depicao' => $this->post->depicao,
'arricao' => $this->post->arricao,
'aircraft' => $this->post->aircraft,
'flighttime' => $this->post->flighttime,
'load' => $this->post->load,
'price' => $this->post->price,
'pilotpay' => $this->post->pilotpay,
'fuelused' => $this->post->fuelused,
'fuelunitcost' => $this->post->fuelunitcost,
'fuelprice' => $fuelcost,
'expenses' => $this->post->expenses
);

if (!PIREPData::updateFlightReport($this->post->pirepid, $data)) {
$this->set('message', 'There was an error editing your PIREP');
Expand Down
2 changes: 1 addition & 1 deletion admin/templates/ops_scheduleform.tpl
Expand Up @@ -158,7 +158,7 @@
</tr>
<tr>
<td valign="top"><strong>Pay for Flight</strong> </td>
<td><input type="text" name="payforflight" value="<?php echo $schedule->price?>" />
<td><input type="text" name="payforflight" value="<?php echo $schedule->payforflight?>" />
<p>If a price is entered here, a pilot will be paid this amount, instead of the hourly pay.</p>
</td>
</tr>
Expand Down
38 changes: 27 additions & 11 deletions core/common/PIREPData.class.php
Expand Up @@ -18,6 +18,7 @@
*/

class PIREPData extends CodonData {

public static $lasterror;
public static $pirepid;

Expand Down Expand Up @@ -765,21 +766,36 @@ public static function updateFlightReport($pirepid, $pirepdata) {
$flighttime_stamp = str_replace('.', ':', $pirepdata['flighttime']) . ':00';
$pirepdata['flighttime'] = str_replace(':', ',', $pirepdata['flighttime']);

$data = array('price' => $pirepdata['price'], 'load' => $pirepdata['load'],
'expenses' => $pirepdata['expenses'], 'fuelprice' => $pirepdata['fuelprice'],
'pilotpay' => $pirepdata['pilotpay'], 'flighttime' => $pirepdata['flighttime'], );
$data = array(
'price' => $pirepdata['price'],
'load' => $pirepdata['load'],
'expenses' => $pirepdata['expenses'],
'fuelprice' => $pirepdata['fuelprice'],
'pilotpay' => $pirepdata['pilotpay'],
'flighttime' => $pirepdata['flighttime'],
);

$gross = floatval($pirepdata['load']) * floatval($pirepdata['price']);
$revenue = self::getPIREPRevenue($data);

$fields = array('code' => $pirepdata['code'], 'flightnum' => $pirepdata['flightnum'],
'depicao' => $pirepdata['depicao'], 'arricao' => $pirepdata['arricao'],
'aircraft' => $pirepdata['aircraft'], 'flighttime' => $pirepdata['flighttime'],
'flighttime_stamp' => $flighttime_stamp, 'load' => $pirepdata['load'], 'price' =>
$pirepdata['price'], 'gross' => $gross, 'pilotpay' => $pirepdata['pilotpay'],
'fuelused' => $pirepdata['fuelused'], 'fuelunitcost' => $pirepdata['fuelunitcost'],
'fuelprice' => $pirepdata['fuelprice'], 'expenses' => $pirepdata['expenses'],
'revenue' => $revenue, );
$fields = array(
'code' => $pirepdata['code'],
'flightnum' => $pirepdata['flightnum'],
'depicao' => $pirepdata['depicao'],
'arricao' => $pirepdata['arricao'],
'aircraft' => $pirepdata['aircraft'],
'flighttime' => $pirepdata['flighttime'],
'flighttime_stamp' => $flighttime_stamp,
'load' => $pirepdata['load'],
'price' => $pirepdata['price'],
'gross' => $gross,
'pilotpay' => $pirepdata['pilotpay'],
'fuelused' => $pirepdata['fuelused'],
'fuelunitcost' => $pirepdata['fuelunitcost'],
'fuelprice' => $pirepdata['fuelprice'],
'expenses' => $pirepdata['expenses'],
'revenue' => $revenue,
);

return self::editPIREPFields($pirepid, $fields);
}
Expand Down
2 changes: 1 addition & 1 deletion core/version
@@ -1 +1 @@
956
957
8 changes: 4 additions & 4 deletions install/hashlist
Expand Up @@ -27,7 +27,7 @@ d4d204c3560c283fa4d7a3a367473740 *./install/navdata.sql
45dc70edd04ab870c3ba86ebf305ff4c *./install/install.php
a177b8656fca431cc0b6d53ac301c537 *./core/lang/en.lang.php
a5e10c076798685fd1f8e84a7115fb74 *./core/common/MaintenanceData.class.php
b205b914412b0f617f06dc66fa2c9964 *./core/common/PIREPData.class.php
d484b7764020f467b99cdd75a356352e *./core/common/PIREPData.class.php
e61e61593cae4813c33914be562701ae *./core/common/Auth.class.php
596033119a76e293a7ead1d29978fd97 *./core/common/jqgrid.class.php
c201a1ea0a656bb46b7766b6f985f010 *./core/common/RegistrationData.class.php
Expand Down Expand Up @@ -240,7 +240,7 @@ a408163f9f6b777e784a6060a4ca2758 *./admin/templates/vacentral_index.tpl
40d93924c47d599145ddc1f159a53584 *./admin/templates/core_sidebar.tpl
63dfab48ce454fbe5857e4f1d431f04d *./admin/templates/pilots_viewallbids.tpl
5fab462c2781619206888e845e708d9d *./admin/templates/downloads_categoryform.tpl
61fb9086f6680346594149e3c183e1f2 *./admin/templates/ops_scheduleform.tpl
5721cbd877088da5727dc06518c7593d *./admin/templates/ops_scheduleform.tpl
d41d8cd98f00b204e9800998ecf8427e *./admin/templates/core_footer.tpl
fdf7f7a9ad04e276d263e0db7426df85 *./admin/templates/sidebar_maintenance.tpl
98de5bfe5dea4d187ddb66562cd5707b *./admin/templates/pilots_options.tpl
Expand Down Expand Up @@ -305,13 +305,13 @@ b801c932759797c3bbf41d7908f23ae7 *./admin/modules/PilotAdmin/PilotAdmin.php
7f8afe3dfe944a0a010c23bcbd7e2467 *./admin/modules/Downloads/Downloads.php
2184a2fe0b3e89301b3c0171b9435d0a *./admin/modules/MassMailer/MassMailer.php
fb4ca464f4e518e63c31b409e48588bf *./admin/modules/SiteCMS/SiteCMS.php
637a291ebfce78b3247ec658b8f4d448 *./admin/modules/Operations/Operations.php
a23f2bd3fb0a43ce87a859bf99b4b6a0 *./admin/modules/Operations/Operations.php
58be86122e37b9cd875b7d306a4425e8 *./admin/modules/Import/Import.php
086a4da89e7f2c4f6dba1284cc3ddc3a *./admin/modules/Settings/Settings.php
c32304847debef3cbef412e8102e7566 *./admin/modules/TemplateDiffs/TemplateDiffs.php
b912b3305bb2e94554ce6ec162610d9c *./admin/modules/Maintenance/Maintenance.php
238bc1a78f2f5026add9a08746f1c70e *./admin/modules/Dashboard/Dashboard.php
ba3138ce99d927339c508b7db92887d9 *./admin/modules/PIREPAdmin/PIREPAdmin.php
5f88707e6c5e6faf726c292ee6e2a92f *./admin/modules/PIREPAdmin/PIREPAdmin.php
d41d8cd98f00b204e9800998ecf8427e *./lib/avatars/index.php
d41d8cd98f00b204e9800998ecf8427e *./lib/signatures/index.php
56cde3e8c38b1e07d4b949503440b5dc *./lib/skins/crystal/layout.tpl
Expand Down
18 changes: 9 additions & 9 deletions install/structure.xml
Expand Up @@ -79,7 +79,7 @@
<field Field="chartlink" Type="text" Null="NO" Key="" Extra="" />
<key Table="phpvms_airports" Non_unique="0" Key_name="PRIMARY" Seq_in_index="1" Column_name="id" Collation="A" Cardinality="85" Null="" Index_type="BTREE" Comment="" />
<key Table="phpvms_airports" Non_unique="0" Key_name="icao" Seq_in_index="1" Column_name="icao" Collation="A" Cardinality="85" Null="" Index_type="BTREE" Comment="" />
<options Name="phpvms_airports" Engine="InnoDB" Version="10" Row_format="Compact" Rows="494" Avg_row_length="132" Data_length="65536" Max_data_length="0" Index_length="16384" Data_free="11534336" Auto_increment="1507" Create_time="2011-01-18 00:43:18" Collation="latin1_swedish_ci" Create_options="" Comment="" />
<options Name="phpvms_airports" Engine="InnoDB" Version="10" Row_format="Compact" Rows="377" Avg_row_length="173" Data_length="65536" Max_data_length="0" Index_length="16384" Data_free="11534336" Auto_increment="1507" Create_time="2011-01-18 00:43:18" Collation="latin1_swedish_ci" Create_options="" Comment="" />
</table_structure>
<table_structure name="phpvms_awards">
<field Field="awardid" Type="int(11)" Null="NO" Key="PRI" Extra="auto_increment" />
Expand Down Expand Up @@ -256,7 +256,7 @@
<field Field="lastip" Type="varchar(25)" Null="YES" Key="" Default="" Extra="" />
<field Field="comment" Type="text" Null="YES" Key="" Extra="" />
<key Table="phpvms_pilots" Non_unique="0" Key_name="PRIMARY" Seq_in_index="1" Column_name="pilotid" Collation="A" Cardinality="77" Null="" Index_type="BTREE" Comment="" />
<key Table="phpvms_pilots" Non_unique="1" Key_name="code" Seq_in_index="1" Column_name="code" Collation="A" Cardinality="5" Null="" Index_type="BTREE" Comment="" />
<key Table="phpvms_pilots" Non_unique="1" Key_name="code" Seq_in_index="1" Column_name="code" Collation="A" Cardinality="6" Null="" Index_type="BTREE" Comment="" />
<options Name="phpvms_pilots" Engine="InnoDB" Version="10" Row_format="Compact" Rows="77" Avg_row_length="638" Data_length="49152" Max_data_length="0" Index_length="16384" Data_free="11534336" Auto_increment="154" Create_time="2011-01-18 00:43:18" Collation="latin1_swedish_ci" Create_options="" Comment="" />
</table_structure>
<table_structure name="phpvms_pirepcomments">
Expand Down Expand Up @@ -310,8 +310,8 @@
<field Field="source" Type="varchar(25)" Null="NO" Key="" Extra="" />
<field Field="exported" Type="tinyint(4)" Null="NO" Key="" Extra="" />
<field Field="rawdata" Type="blob" Null="NO" Key="" Extra="" />
<key Table="phpvms_pireps" Non_unique="0" Key_name="PRIMARY" Seq_in_index="1" Column_name="pirepid" Collation="A" Cardinality="197" Null="" Index_type="BTREE" Comment="" />
<options Name="phpvms_pireps" Engine="InnoDB" Version="10" Row_format="Compact" Rows="137" Avg_row_length="1674" Data_length="229376" Max_data_length="0" Index_length="0" Data_free="11534336" Auto_increment="518" Create_time="2011-01-18 00:43:18" Collation="latin1_swedish_ci" Create_options="" Comment="" />
<key Table="phpvms_pireps" Non_unique="0" Key_name="PRIMARY" Seq_in_index="1" Column_name="pirepid" Collation="A" Cardinality="189" Null="" Index_type="BTREE" Comment="" />
<options Name="phpvms_pireps" Engine="InnoDB" Version="10" Row_format="Compact" Rows="166" Avg_row_length="1381" Data_length="229376" Max_data_length="0" Index_length="0" Data_free="11534336" Auto_increment="518" Create_time="2011-01-18 00:43:18" Collation="latin1_swedish_ci" Create_options="" Comment="" />
</table_structure>
<table_structure name="phpvms_pirepvalues">
<field Field="id" Type="int(11)" Null="NO" Key="PRI" Extra="auto_increment" />
Expand Down Expand Up @@ -358,11 +358,11 @@
<field Field="enabled" Type="int(11)" Null="NO" Key="" Default="1" Extra="" />
<field Field="bidid" Type="int(11)" Null="NO" Key="" Default="0" Extra="" />
<key Table="phpvms_schedules" Non_unique="0" Key_name="PRIMARY" Seq_in_index="1" Column_name="id" Collation="A" Cardinality="49" Null="" Index_type="BTREE" Comment="" />
<key Table="phpvms_schedules" Non_unique="1" Key_name="depicao" Seq_in_index="1" Column_name="depicao" Collation="A" Cardinality="16" Null="" Index_type="BTREE" Comment="" />
<key Table="phpvms_schedules" Non_unique="1" Key_name="depicao" Seq_in_index="1" Column_name="depicao" Collation="A" Cardinality="49" Null="" Index_type="BTREE" Comment="" />
<key Table="phpvms_schedules" Non_unique="1" Key_name="flightnum" Seq_in_index="1" Column_name="flightnum" Collation="A" Cardinality="49" Null="" Index_type="BTREE" Comment="" />
<key Table="phpvms_schedules" Non_unique="1" Key_name="depicao_arricao" Seq_in_index="1" Column_name="depicao" Collation="A" Cardinality="16" Null="" Index_type="BTREE" Comment="" />
<key Table="phpvms_schedules" Non_unique="1" Key_name="depicao_arricao" Seq_in_index="1" Column_name="depicao" Collation="A" Cardinality="49" Null="" Index_type="BTREE" Comment="" />
<key Table="phpvms_schedules" Non_unique="1" Key_name="depicao_arricao" Seq_in_index="2" Column_name="arricao" Collation="A" Cardinality="49" Null="" Index_type="BTREE" Comment="" />
<key Table="phpvms_schedules" Non_unique="1" Key_name="code" Seq_in_index="1" Column_name="code" Collation="A" Cardinality="1" Null="" Index_type="BTREE" Comment="" />
<key Table="phpvms_schedules" Non_unique="1" Key_name="code" Seq_in_index="1" Column_name="code" Collation="A" Cardinality="3" Null="" Index_type="BTREE" Comment="" />
<options Name="phpvms_schedules" Engine="InnoDB" Version="10" Row_format="Compact" Rows="58" Avg_row_length="1129" Data_length="65536" Max_data_length="0" Index_length="65536" Data_free="11534336" Auto_increment="117" Create_time="2011-02-20 22:32:25" Collation="latin1_swedish_ci" Create_options="" Comment="" />
</table_structure>
<table_structure name="phpvms_sessions">
Expand All @@ -371,7 +371,7 @@
<field Field="ipaddress" Type="varchar(25)" Null="NO" Key="" Extra="" />
<field Field="logintime" Type="datetime" Null="NO" Key="" Extra="" />
<key Table="phpvms_sessions" Non_unique="0" Key_name="PRIMARY" Seq_in_index="1" Column_name="id" Collation="A" Cardinality="26" Null="" Index_type="BTREE" Comment="" />
<options Name="phpvms_sessions" Engine="MyISAM" Version="10" Row_format="Dynamic" Rows="26" Avg_row_length="45" Data_length="42228" Max_data_length="281474976710655" Index_length="15360" Data_free="41056" Auto_increment="5670" Create_time="2009-10-31 20:05:09" Update_time="2011-03-13 16:18:36" Check_time="2010-04-20 19:10:29" Collation="latin1_swedish_ci" Create_options="" Comment="" />
<options Name="phpvms_sessions" Engine="MyISAM" Version="10" Row_format="Dynamic" Rows="26" Avg_row_length="44" Data_length="42228" Max_data_length="281474976710655" Index_length="15360" Data_free="41080" Auto_increment="5695" Create_time="2009-10-31 20:05:09" Update_time="2011-03-17 10:01:34" Check_time="2010-04-20 19:10:29" Collation="latin1_swedish_ci" Create_options="" Comment="" />
</table_structure>
<table_structure name="phpvms_settings">
<field Field="id" Type="int(11)" Null="NO" Key="PRI" Extra="auto_increment" />
Expand All @@ -390,7 +390,7 @@
<field Field="lastupdate" Type="datetime" Null="NO" Key="" Extra="" />
<key Table="phpvms_updates" Non_unique="0" Key_name="PRIMARY" Seq_in_index="1" Column_name="id" Collation="A" Cardinality="9" Null="" Index_type="BTREE" Comment="" />
<key Table="phpvms_updates" Non_unique="1" Key_name="name" Seq_in_index="1" Column_name="name" Collation="A" Cardinality="9" Null="" Index_type="BTREE" Comment="" />
<options Name="phpvms_updates" Engine="MyISAM" Version="10" Row_format="Dynamic" Rows="9" Avg_row_length="33" Data_length="300" Max_data_length="281474976710655" Index_length="3072" Data_free="0" Auto_increment="10" Create_time="2009-12-20 17:51:29" Update_time="2011-03-13 16:15:56" Check_time="2010-04-20 19:10:29" Collation="latin1_swedish_ci" Create_options="" Comment="" />
<options Name="phpvms_updates" Engine="MyISAM" Version="10" Row_format="Dynamic" Rows="9" Avg_row_length="33" Data_length="300" Max_data_length="281474976710655" Index_length="3072" Data_free="0" Auto_increment="10" Create_time="2009-12-20 17:51:29" Update_time="2011-03-16 17:21:15" Check_time="2010-04-20 19:10:29" Collation="latin1_swedish_ci" Create_options="" Comment="" />
</table_structure>
</database>
</mysqldump>

0 comments on commit 9bef365

Please sign in to comment.