Jump to content

Recommended Posts

Posted (edited)

Hello,

 

I need to know if there's any piece of code in order to add the pilot ID column in the admin pilot list. Thank you!

Edited by Imanol
  • Moderators
Posted

First of all, which phpVMS version are you using? v2 or v5? As far as I know, v5 already includes that. Please let us know and we should be able to give you the most practical solution.

  • Moderators
Posted

In that case you will have to make a couple of changes. First of all, open your admin/modules/PilotAdmin/PilotAdmin.php file and find this:

foreach($allpilots as $row)
		{
			$status = ($row->retired==0) ? 'Active' : 'Retired';
			$location = '<img src="'.Countries::getCountryImage($row->location).'" alt="'.$row->location.'" />';
			$edit = '<a href="'.adminurl('/pilotadmin/viewpilots?action=viewoptions&pilotid='.$row->pilotid).'">Edit</a>';
			
			$tmp = array(
				'id' => $row->id,
				'cell' => array(
					# Each column, in order
					$row->id,
					$row->firstname,
					$row->lastname,
					$row->email,
					$location,
					$status,
					$row->rank,
					$row->totalflights,
					$row->totalhours,
					$row->lastip,
					$edit,
				),
			);
			
			$json['rows'][] = $tmp;
		}

And replace it with this:

foreach($allpilots as $row)
		{
			$pilotid = PilotData::getPilotCode($row->code, $row->pilotid);
			$status = ($row->retired==0) ? 'Active' : 'Retired';
			$location = '<img src="'.Countries::getCountryImage($row->location).'" alt="'.$row->location.'" />';
			$edit = '<a href="'.adminurl('/pilotadmin/viewpilots?action=viewoptions&pilotid='.$row->pilotid).'">Edit</a>';
			
			$tmp = array(
				'id' => $row->id,
				'cell' => array(
					# Each column, in order
					$row->id,
					$pilotid,
					$row->firstname,
					$row->lastname,
					$row->email,
					$location,
					$status,
					$row->rank,
					$row->totalflights,
					$row->totalhours,
					$row->lastip,
					$edit,
				),
			);
			
			$json['rows'][] = $tmp;
		}

Then open your admin/templates/pilots_list.tpl, find this:

$("#grid").jqGrid({
   url: '<?php echo adminaction('/pilotadmin/getpilotsjson');?>',
   datatype: 'json',
   mtype: 'GET',
   colNames: ['','First', 'Last', 'Email', 'Location', 'Status', 'Rank', 'Flights', 'Hours', 'IP', 'Edit'],
   colModel : [
		{index: 'id', name: 'id', hidden: true, search: false },
		{index: 'firstname', name : 'firstname',sortable : true, align: 'left', search: 'true', searchoptions:{sopt:['in']}},
		{index: 'lastname', name : 'lastname',  sortable : true, align: 'left', searchoptions:{sopt:['in']}},
		{index: 'email', name : 'email', sortable : true, align: 'left',searchoptions:{sopt:['li']}},
		{index: 'location', name : 'location',  sortable : true, align: 'center',searchoptions:{sopt:['eq','ne']}},
		{index: 'status', name : 'status', sortable : true, align: 'center',searchoptions:{sopt:['in']}},
		{index: 'rank', name : 'rank', sortable : true, align: 'center', searchoptions:{sopt:['eq','ne']}},
		{index: 'totalflights', name : 'totalflights', sortable : true, align: 'center',searchoptions:{sopt:['lt','gt']}},
		{index: 'totalhours', name : 'totalhours', sortable : true, align: 'center',searchoptions:{sopt:['lt','gt']}},
		{index: 'lastip', name : 'lastip', sortable : true, align: 'center', searchoptions:{sopt:['in']}},
		{index: '', name : '', sortable : true, align: 'center', search: false}
	],
    pager: '#pager', rowNum: 25,
    sortname: 'lastname', sortorder: 'asc',
    viewrecords: true, autowidth: true,
    height: '100%'
});

and replace it with this:

$("#grid").jqGrid({
   url: '<?php echo adminaction('/pilotadmin/getpilotsjson');?>',
   datatype: 'json',
   mtype: 'GET',
   colNames: ['','Pilot ID', 'First', 'Last', 'Email', 'Location', 'Status', 'Rank', 'Flights', 'Hours', 'IP', 'Edit'],
   colModel : [
		{index: 'id', name: 'id', hidden: true, search: false },
		{index: 'pilotid', name : 'pilotid',sortable : true, align: 'left', search: 'true', searchoptions:{sopt:['in']}},
		{index: 'firstname', name : 'firstname',sortable : true, align: 'left', search: 'true', searchoptions:{sopt:['in']}},
		{index: 'lastname', name : 'lastname',  sortable : true, align: 'left', searchoptions:{sopt:['in']}},
		{index: 'email', name : 'email', sortable : true, align: 'left',searchoptions:{sopt:['li']}},
		{index: 'location', name : 'location',  sortable : true, align: 'center',searchoptions:{sopt:['eq','ne']}},
		{index: 'status', name : 'status', sortable : true, align: 'center',searchoptions:{sopt:['in']}},
		{index: 'rank', name : 'rank', sortable : true, align: 'center', searchoptions:{sopt:['eq','ne']}},
		{index: 'totalflights', name : 'totalflights', sortable : true, align: 'center',searchoptions:{sopt:['lt','gt']}},
		{index: 'totalhours', name : 'totalhours', sortable : true, align: 'center',searchoptions:{sopt:['lt','gt']}},
		{index: 'lastip', name : 'lastip', sortable : true, align: 'center', searchoptions:{sopt:['in']}},
		{index: '', name : '', sortable : true, align: 'center', search: false}
	],
    pager: '#pager', rowNum: 25,
    sortname: 'lastname', sortorder: 'asc',
    viewrecords: true, autowidth: true,
    height: '100%'
});

Do not forget to keep a backup of the files that you should edit to ensure that you will be able to "come back" in case something breaks out.

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...