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

Commit

Permalink
close #24, added different pilot statuses
Browse files Browse the repository at this point in the history
  • Loading branch information
Nabeel Shahzad committed Apr 25, 2011
1 parent 2f18270 commit 35a51d1
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 62 deletions.
29 changes: 19 additions & 10 deletions admin/modules/PilotAdmin/PilotAdmin.php
Expand Up @@ -129,20 +129,14 @@ public function viewpilots() {
return;
}

if (intval($this->post->retired) == 1) {
$retired = true;
} else {
$retired = false;
}

$params = array(
'code' => $this->post->code,
'firstname' => $this->post->firstname,
'lastname' => $this->post->lastname,
'email' => $this->post->email,
'location' => $this->post->location,
'hub' => $this->post->hub,
'retired' => $retired,
'retired' => $this->post->retired,
'totalhours' => $this->post->totalhours,
'totalflights' => $this->post->totalflights,
'totalpay' => floatval($this->post->totalpay),
Expand All @@ -168,7 +162,9 @@ public function viewpilots() {


$pilot = PilotData::getPilotData($this->post->pilotid);
LogData::addLog(Auth::$userinfo->pilotid, 'Updated profile for ' . PilotData::getPilotCode($pilot->code, $pilot->pilotid) . ' ' . $pilot->firstname . ' ' . $pilot->lastname);
LogData::addLog(Auth::$userinfo->pilotid, 'Updated profile for '
.PilotData::getPilotCode($pilot->code, $pilot->pilotid)
.' '.$pilot->firstname.' '.$pilot->lastname);

return;
break;
Expand Down Expand Up @@ -336,6 +332,7 @@ protected function ShowPilotsList() {
* @return
*/
public function getpilotsjson() {

$page = $this->get->page; // get the requested page
$limit = $this->get->rows; // get how many rows we want to have into the grid
$sidx = $this->get->sidx; // get index row - i.e. user click to sort
Expand Down Expand Up @@ -383,10 +380,20 @@ public function getpilotsjson() {
# Form the json header
$json = array('page' => $page, 'total' => $total_pages, 'records' => $count, 'rows' => array());

$statuses = Config::get('PILOT_STATUS_TYPES');

# Add each row to the above array
foreach ($allpilots as $row) {

$pilotid = PilotData::getPilotCode($row->code, $row->pilotid);
$status = ($row->retired == 0) ? 'Active' : 'Retired';

foreach($statuses as $id => $details) {
if($row->retired == $id) {
$status = $details['name'];
break;
}
}

$location = '<img src="' . Countries::getCountryImage($row->location) . '" alt="' . $row->location . '" />';
$edit = '<a href="' . adminurl('/pilotadmin/viewpilots?action=viewoptions&pilotid=' . $row->pilotid) . '">Edit</a>';

Expand Down Expand Up @@ -429,6 +436,7 @@ protected function ViewPilotDetails() {
* @return
*/
protected function SetGroupsData($pilotid) {

# This is for the groups tab
$freegroups = array();

Expand Down Expand Up @@ -556,10 +564,11 @@ protected function ShowGroups() {
* @return
*/
protected function ApprovePilot() {

PilotData::AcceptPilot($this->post->id);
RanksData::CalculatePilotRanks();

$pilot = PilotData::GetPilotData($this->post->id);
$pilot = PilotData::getPilotData($this->post->id);

# Send pilot notification
$subject = Lang::gs('email.register.accepted.subject');
Expand Down
25 changes: 14 additions & 11 deletions admin/templates/pilots_details.tpl
Expand Up @@ -150,18 +150,21 @@
</tr>
<tr>
<td>Pilot active?</td>
<td><?php
if(intval($pilotinfo->retired) == 1) {
$retsel='selected';
$activesel = '';
} else {
$activesel = 'selected';
$retsel = '';
}
<td><select name="retired">
<?php

$pilotStatuses = Config::get('PILOT_STATUS_TYPES');
foreach($pilotStatuses as $id => $info) {
if($pilotinfo->retired == $id) {
$active = 'selected';
} else {
$active = '';
}

echo '<option value="'.$id.'" '.$active.'>'.$info['name'].'</option>';
}

?>
<select name="retired">
<option value="0" <?php echo $activesel?>>Active</option>
<option value="1" <?php echo $retsel?>>Inactive</option>
</select>

</td>
Expand Down
1 change: 1 addition & 0 deletions changelog.htm
Expand Up @@ -45,6 +45,7 @@ <h1>Version ##REVISION##</h1>
<li>Added four week rotating schedule (Mon-Fri for Week 1-4 in a month)</li>
<li>Create reverse route from existing schedule</li>
<li>Assign a pilot pay per-schedule flown, instead of per-flight hour</li>
<li>Added different pilot statuses, can be customized</li>
<li>Admin can accept PIREP from email</li>
<li>Rank images fixed in signature</li>
<li>Airline added as a search filter (w/ template change)</li>
Expand Down
32 changes: 31 additions & 1 deletion core/app.config.php
Expand Up @@ -455,7 +455,37 @@
'G'=>'Percent (per flight)'
)
);



/* These are pilot statuses which can be selected in
the admin panel */
Config::Set('PILOT_STATUS_TYPES', array(
0 => array(
'name' => 'Active', # The title to show in the dropdown
'message' => '', # Message to show if they can't login (below is false)
'canlogin' => false, # Are they allowed to log in
'active' => true, # Are they an active pilot?
),
1 => array(
'name' => 'Inactive',
'message' => 'Your account was marked inactive',
'canlogin' => false,
'active' => false,
),
2 => array(
'name' => 'Banned',
'message' => 'Your account is banned, please contact an admin!',
'canlogin' => false,
'active' => false,
),
3 => array(
'name' => 'On Leave',
'message' => 'You have been marked as on leave',
'canlogin' => false,
'active' => false,
),
));

define('SIGNATURE_PATH', '/lib/signatures');
define('AVATAR_PATH', '/lib/avatars');

Expand Down
7 changes: 5 additions & 2 deletions core/classes/Config.class.php
@@ -1,8 +1,10 @@
<?php

class Config {

static $values = array();
static $final = array();
static $merge = array();


/**
Expand All @@ -28,11 +30,12 @@ public static function Add($name, $value, $final = false) {
*
*/
public static function Set($name, $value, $final = false) {

if (in_array($name, self::$final))
return;

self::$values[$name] = $value;

if ($final == true) {
self::$final[] = $name;
}
Expand Down
12 changes: 12 additions & 0 deletions core/common/Auth.class.php
Expand Up @@ -251,6 +251,18 @@ public static function ProcessLogin($useridoremail, $password) {
return false;
}

/* Implement the pilot statuses, see if they are allowed in
according to their status */
$pilotStatuses = Config::get('PILOT_STATUS_TYPES');
foreach($pilotStatuses as $id => $info) {
if($userinfo->retired == $id) {
if($info['canlogin'] == false) {
self::$error_message = $info['message'];
return false;
}
}
}

/*if($userinfo->retired == 1)
{
self::$error_message = 'Your account was deactivated, please contact an admin';
Expand Down
24 changes: 8 additions & 16 deletions core/templates/pilot_public_profile.tpl
@@ -1,6 +1,5 @@
<?php
if(!$userinfo)
{
if(!$userinfo) {
echo '<h3>This pilot does not exist!</h3>';
return;
}
Expand All @@ -10,12 +9,9 @@ if(!$userinfo)
<tr>
<td align="center" valign="top">
<?php
if(!file_exists(SITE_ROOT.AVATAR_PATH.'/'.$pilotcode.'.png'))
{
if(!file_exists(SITE_ROOT.AVATAR_PATH.'/'.$pilotcode.'.png')) {
echo 'No avatar';
}
else
{
} else {
echo '<img src="'.SITE_URL.AVATAR_PATH.'/'.$pilotcode.'.png'.'" alt="No Avatar" /> ';
}
?>
Expand All @@ -36,10 +32,8 @@ if(!$userinfo)

<?php
// Show the public fields
if($allfields)
{
foreach($allfields as $field)
{
if($allfields) {
foreach($allfields as $field) {
echo "<li><strong>$field->title: </strong>$field->value</li>";
}
}
Expand All @@ -49,17 +43,15 @@ if(!$userinfo)
<p>
<strong>Awards</strong>
<?php
if(is_array($allawards))
{
if(is_array($allawards)) {
?>
<ul>
<?php foreach($allawards as $award)
{
<?php
foreach($allawards as $award) {
/* To show the image:
<img src="<?php echo $award->image?>" alt="<?php echo $award->descrip?>" />
*/
?>
<li><?php echo $award->name ?></li>
<?php } ?>
Expand Down
2 changes: 1 addition & 1 deletion core/version
@@ -1 +1 @@
v2.1.934-124-g18e8cca
v2.1.934-125-g2f18270
12 changes: 6 additions & 6 deletions install/hashlist
Expand Up @@ -25,7 +25,7 @@ b93585ee3d7e1d70cb3d4937f3e8069b *./core/lang/en.lang.php
a5e10c076798685fd1f8e84a7115fb74 *./core/common/MaintenanceData.class.php
bf728ada7c00dd8e9cf57c98a55cafac *./core/common/PIREPData.class.php
8a5cb317fbcafa8badef4df19ba10488 *./core/common/LedgerData.class.php
e61e61593cae4813c33914be562701ae *./core/common/Auth.class.php
a2ef10c1861c7458bef3e9c3879c4379 *./core/common/Auth.class.php
596033119a76e293a7ead1d29978fd97 *./core/common/jqgrid.class.php
0ad7f1a221a5b7aed18e4665bd817ef1 *./core/common/RegistrationData.class.php
4b930556c0957f86bb290023be2f41fd *./core/common/StatsData.class.php
Expand Down Expand Up @@ -119,7 +119,7 @@ c9d56fa8afc976e59e3f3967699a1d0f *./core/templates/pilots_list.tpl
a7809ff8c48c4a9b8a332c84b16c0eb3 *./core/templates/login_unconfirmed.tpl
484b9180ba5ad41b0e25b6379cdc3c81 *./core/templates/downloads_list.tpl
d41d8cd98f00b204e9800998ecf8427e *./core/templates/profile_myroutesmap.tpl
5e54dfea61c0477557872f73219710dc *./core/templates/pilot_public_profile.tpl
88b174ac4cbcf7a72d703bfab58a7878 *./core/templates/pilot_public_profile.tpl
74509a45104870fffb6cffd731a7602d *./core/templates/download_item.tpl
195bccea8218c5a0fece3b909cce0c51 *./core/templates/email_lostpassword.tpl
024e111d80c93ed5565f22fdb858b789 *./core/templates/fspax_config.tpl
Expand Down Expand Up @@ -149,7 +149,7 @@ fd37aa8d637c2ba981952ab95c5f89f5 *./core/classes/CodonForm.class.php
8bc0a726762131516617e3d876ff90de *./core/classes/SessionManager.class.php
c24936573bc8c875aee085610bb0e218 *./core/classes/CodonModule.class.php
cf7005129f40c0b800ed987809debd89 *./core/classes/autoload.php
d38a564ddc5e1f2de95d9742dae56f75 *./core/classes/Config.class.php
6a2c875fa3afa32e728d98506c17b5f4 *./core/classes/Config.class.php
5f3d848a8309174f0bf2348b06a9ad75 *./core/classes/Template.class.php
74f79f15db7476a6ce4a8521996eeeef *./core/classes/CodonCondenser.class.php
a62228aa685f0a0f68871de6558aae5b *./core/classes/ezdb/ezdb.class.php
Expand All @@ -162,7 +162,7 @@ c5464e3a9e0079bd8229a1b1aa27379d *./core/classes/ezdb/ezdb_oracle.class.php
c56b2790383f5891808777c40c03e269 *./core/hooks/system/postmoduleload.php.1
d41d8cd98f00b204e9800998ecf8427e *./core/index.php
d41d8cd98f00b204e9800998ecf8427e *./core/pages/index.php
caf692be17176c27aaff9a1828e13b09 *./core/app.config.php
95f83d60405f7684eef520c46fb1d1b8 *./core/app.config.php
c26d9878cab6959c8e58a14fc31fb614 *./core/modules/Schedules/Schedules.php
e58ee78f8e857ad150badae9ba04dddc *./core/modules/news/news.php
73fc6e1d3106739551d5358922d65d40 *./core/modules/Activity/Activity.php
Expand Down Expand Up @@ -209,7 +209,7 @@ f4810662fd0c7191ae537045f4994d65 *./admin/templates/sidebar_awards.tpl
316f9c45b89506a2646a6a1a3c392c92 *./admin/templates/finance_summarysheet.tpl
7eee22e868ad1cfa54c020876b10153c *./admin/templates/sidebar_settings.tpl
e8c22cb9ae3fdd723ac9948697850c1c *./admin/templates/import_aircraftform.tpl
1b29b4a4eafb787b1af5edfaec5b5658 *./admin/templates/pilots_details.tpl
da4c1ef3981ee1a3abe6ef50df8e55c7 *./admin/templates/pilots_details.tpl
43647f7912f986186e1bd6999c535ca9 *./admin/templates/core_message.tpl
8d0515f54ff8db717a6a8fe45e6075d7 *./admin/templates/pireps_list.tpl
2e79fc0f2948a8aae1d33b58a7fd60c5 *./admin/templates/downloads_overview.tpl
Expand Down Expand Up @@ -301,7 +301,7 @@ f1c016469d12fd1974599d675da8d97b *./admin/modules/Reports/Reports.php
eb48b61566644404735718c7607dce33 *./admin/modules/VACentral/VACentral.php
65e788f582caecc863b2b469c2c29220 *./admin/modules/Finance/Finance.php
c1de104017f08ab3f33a2635c0a6acf2 *./admin/modules/Logs/Logs.php
6765c065ba9be5374340f14134fbb488 *./admin/modules/PilotAdmin/PilotAdmin.php
dc6d5075b5505a99c9ffb54511ce9c8d *./admin/modules/PilotAdmin/PilotAdmin.php
36b45668ad6e73826bc8ef7ff02f7e4d *./admin/modules/PilotRanking/PilotRanking.php
7f8afe3dfe944a0a010c23bcbd7e2467 *./admin/modules/Downloads/Downloads.php
2184a2fe0b3e89301b3c0171b9435d0a *./admin/modules/MassMailer/MassMailer.php
Expand Down

0 comments on commit 35a51d1

Please sign in to comment.