phpvms / phpvms_v2

Virtual Airline Management (not maintained)
http://www.phpvms.net
BSD 3-Clause "New" or "Revised" License
41 stars 46 forks source link

PIREPData::findPIREP issue found... #66

Closed ghost closed 12 years ago

ghost commented 12 years ago

Hey Nabeel!

Long time, no talk!

While I was writing a custom module for a virtual airline, the module is going to use the findPIREP from the PIREPData class, however, I noticed there are two same colum names "code" in the PIREP table and the Pilot table.

So I went to find the SQL query and fixed it up by adding this... "u.code AS pcode"

So to show the pilot's code would be like this $pirep->pcode and for the PIREP code is $pirep->code.

    $sql = 'SELECT p.*, UNIX_TIMESTAMP(p.submitdate) as submitdate, u.code AS pcode,
                u.pilotid, u.firstname, u.lastname, u.email, u.rank,
                a.id AS aircraftid, a.name as aircraft, a.registration,
                dep.name as depname, dep.lat AS deplat, dep.lng AS deplng,
                arr.name as arrname, arr.lat AS arrlat, arr.lng AS arrlng                       
            FROM '.TABLE_PREFIX.'pireps p
            LEFT JOIN '.TABLE_PREFIX.'aircraft a ON a.id = p.aircraft
            LEFT JOIN '.TABLE_PREFIX.'airports AS dep ON dep.icao = p.depicao
            LEFT JOIN '.TABLE_PREFIX.'airports AS arr ON arr.icao = p.arricao 
            LEFT JOIN '.TABLE_PREFIX.'pilots u ON u.pilotid = p.pilotid ';

It does that to PIREP Admin, when you are looking at the PIREP list, the code to pilot is not correct. For example, my airline code is TVA, and the PIREP that the pilot flew, the code would be WTA. The pilot id will show WTA1000, but the pilot's id is really TVA1000.

If you want me to update the forked phpVMS from my repo with the new SQL query and update the tpl files needed, and put up the pull request, then I would be happy to do that for you.

Cheers!

nabeelio commented 12 years ago

My assumption was that you will have the pilot's information if you're running this query, so I didn't include any pilot information.

But, sure, send a pull request, I'll merge it in. Thanks!

ghost commented 12 years ago

Well, it's just only the u.code AS pcode. No another pilot info needed. There's two same columns named code since you joined the tables. It just needed to be changed little bit.

I'll grab from your repo and fix it up and put the pull request soon.

Cheers!

nabeelio commented 12 years ago

Sounds good!

nabeelio commented 12 years ago

fixed with pull request #67