Jump to content

Duplicate Flight Numbers Schedule Import


skyguyt

Recommended Posts

Hello,

I know I have found it in here before but I've spent about an hour searching various things to see if I could find the thread again with no luck. How do I set my settings to accept multiple flights with the same number? Basically when I upload the .csv for schedules and have 2-4 flights with the same number, how do I ensure they all get added instead of the second one overwriting the first and leaving only one in the system.

For example:

Flight #45 flies BOS-JFK and then returns JFK-BOS as #45 as well. After uploading the .csv file and by searching #45, I can only get JFK-BOS as that has updated over the BOS-JFK route.

Thank you!

Link to comment
Share on other sites

  • Moderators
3 hours ago, skyguyt said:

Hello,

I know I have found it in here before but I've spent about an hour searching various things to see if I could find the thread again with no luck. How do I set my settings to accept multiple flights with the same number? Basically when I upload the .csv for schedules and have 2-4 flights with the same number, how do I ensure they all get added instead of the second one overwriting the first and leaving only one in the system.

For example:

Flight #45 flies BOS-JFK and then returns JFK-BOS as #45 as well. After uploading the .csv file and by searching #45, I can only get JFK-BOS as that has updated over the BOS-JFK route.

Thank you!

Hi, please find the following code in the line 937 of file /admin/module/Operations/Operations.php

and comment lines bellow, this will allow you to add schedules with same flight num.

$sched = SchedulesData::getScheduleByFlight($this->post->code, $this->post->flightnum);
        if (is_object($sched)) {
            $this->set('message', 'This schedule already exists!');
            $this->render('core_error.php');

            return;
        }
Link to comment
Share on other sites

On 10/31/2019 at 1:30 PM, ProSkyDesign said:

Hi, please find the following code in the line 937 of file /admin/module/Operations/Operations.php

and comment lines bellow, this will allow you to add schedules with same flight num.


$sched = SchedulesData::getScheduleByFlight($this->post->code, $this->post->flightnum);
        if (is_object($sched)) {
            $this->set('message', 'This schedule already exists!');
            $this->render('core_error.php');

            return;
        }

Perfect, thank you very much!

On 10/31/2019 at 4:26 PM, ProAvia said:

Or you can add a letter after the flight number.... 45A, 45B, 45C, etc.

^ Thanks! I'd done this in the past which definitely works, too. I'm working on a project that is based off of a real world US based airline and feel as though the A, B,C, etc takes away from some of the realism!

Link to comment
Share on other sites

  • 2 weeks later...
On 11/4/2019 at 11:20 PM, ProSkyDesign said:

You're welcome :)

Well, that worked perfectly for adding routes in the admin center. Now I am running into the issue with importing through .csv. Any ideas on that? It goes through and adds everything which should be a little over 6,000 total flights, I go back to the main screen and it only shows a little over 3,000 and none of the duplicate numbers are added. 🤨 Any ideas?

Link to comment
Share on other sites

  • Moderators
13 minutes ago, skyguyt said:

Well, that worked perfectly for adding routes in the admin center. Now I am running into the issue with importing through .csv. Any ideas on that? It goes through and adds everything which should be a little over 6,000 total flights, I go back to the main screen and it only shows a little over 3,000 and none of the duplicate numbers are added. 🤨 Any ideas?

Open admin/modules/Import/Import.php and go to line 446

Replace this:

# Check if the schedule exists:
            if (($schedinfo = SchedulesData::getScheduleByFlight($code, $flightnum))) {
                # Update the schedule instead
                $val = SchedulesData::updateScheduleFields($schedinfo->id, $data);
                $updated++;
            } else {
                # Add it
                $val = SchedulesData::addSchedule($data);
                $added++;
            }

with this:

# Ignore duplicate schedules:          
$val = SchedulesData::addSchedule($data);
$added++;
         

this will allow you import schedules with duplicate flight code but I guess you should delete first all your schedules and then import news because this won't update the duplicate flights this will append data.

Link to comment
Share on other sites

  • Administrators
2 hours ago, ProSkyDesign said:

Open admin/modules/Import/Import.php and go to line 446

Replace this:


# Check if the schedule exists:
            if (($schedinfo = SchedulesData::getScheduleByFlight($code, $flightnum))) {
                # Update the schedule instead
                $val = SchedulesData::updateScheduleFields($schedinfo->id, $data);
                $updated++;
            } else {
                # Add it
                $val = SchedulesData::addSchedule($data);
                $added++;
            }

with this:


# Ignore duplicate schedules:          
$val = SchedulesData::addSchedule($data);
$added++;
         

this will allow you import schedules with duplicate flight code but I guess you should delete first all your schedules and then import news because this won't update the duplicate flights this will append data.

But you will loose the ability to update the schedules. And if you just delete the schedules to upload a full set again, if the DB is set to auto-increment the record number (which is the usual default), all your old data will be screwed up. For example - you upload 100 routes to a blank schedules table, so record number 1-100. Now, since you can't update any longer, you delete the old schedules and add the new/updated ones back. The record number will start with 101 - so any data stored in other tables referencing the record numbers of the previous schedules won't be able to locate that data cause you deleted it.

Seems way more trouble than it's worth - unless you want to manually edit the DB directly.

Edited by ProAvia
Link to comment
Share on other sites

3 hours ago, ProSkyDesign said:

Open admin/modules/Import/Import.php and go to line 446

Replace this:


# Check if the schedule exists:
            if (($schedinfo = SchedulesData::getScheduleByFlight($code, $flightnum))) {
                # Update the schedule instead
                $val = SchedulesData::updateScheduleFields($schedinfo->id, $data);
                $updated++;
            } else {
                # Add it
                $val = SchedulesData::addSchedule($data);
                $added++;
            }

with this:


# Ignore duplicate schedules:          
$val = SchedulesData::addSchedule($data);
$added++;
         

this will allow you import schedules with duplicate flight code but I guess you should delete first all your schedules and then import news because this won't update the duplicate flights this will append data.

Worked great, thank you!

Link to comment
Share on other sites

53 minutes ago, ProAvia said:

But you will loose the ability to update the schedules. And if you just delete the schedules to upload a full set again, if the DB is set to auto-increment the record number (which is the usual default), all your old data will be screwed up. For example - you upload 100 routes to a blank schedules table, so record number 1-100. Now, since you can't update any longer, you delete the old schedules and add the new/updated ones back. The record number will start with 101 - so any data stored in other tables referencing the record numbers of the previous schedules won't be able to locate that data cause you deleted it.

Seems way more trouble than it's worth - unless you want to manually edit the DB directly.

Ahh, very true and good point. So for an example, yesterday I flew twice with the old schedules and uploaded those flights via SmartCARS to the website. Got them accepted, and they were all fine and dandy. Today I deleted all old schedules when I did the new import and just checked the PIREPs from the old schedules are still locked in to my account and the airline stats even though if you went to search those id's they'd technically be gone and no longer matched in the database as you pointed out. Is there something larger that could potentially go wrong that you are foreseeing that I am missing? It appeared as if the data held enough to keep the profiles and stats populated correctly.

 

Thank you both for all of your help. I appreciate the time given!

Link to comment
Share on other sites

  • Moderators
16 hours ago, skyguyt said:

Worked great, thank you!

you're welcome

17 hours ago, ProAvia said:

But you will loose the ability to update the schedules. And if you just delete the schedules to upload a full set again, if the DB is set to auto-increment the record number (which is the usual default), all your old data will be screwed up. For example - you upload 100 routes to a blank schedules table, so record number 1-100. Now, since you can't update any longer, you delete the old schedules and add the new/updated ones back. The record number will start with 101 - so any data stored in other tables referencing the record numbers of the previous schedules won't be able to locate that data cause you deleted it.

Seems way more trouble than it's worth - unless you want to manually edit the DB directly.

as ProAvia said, you will loose that feature, the best thing you can do is import de DB directly from phpmyadmin (or other mysql gestor) instead of use import function in admin panel, this will ignore that rule (because the duplicate check is created with a php if rule so in data table this rule doesn't exist).

Other thing you can do is add to your csv a column (last column) called id and put the id of the schedule here with the format of autoincrement (starting by 1 and so...)

in line 359 of admin/module/Import/Import.php you should add $id variable

// list fields:
            $code = $fields[0];
            $flightnum = $fields[1];
            $depicao = $fields[2];
            $arricao = $fields[3];
            $route = $fields[4];
            $aircraft = $fields[5];
            $flightlevel = $fields[6];
            $distance = $fields[7];
            $deptime = $fields[8];
            $arrtime = $fields[9];
            $flighttime = $fields[10];
            $notes = $fields[11];
            $price = $fields[12];
            $flighttype = $fields[13];
            $daysofweek = $fields[14];
            $enabled = $fields[15];
            $week1 = $fields[16];
            $week2 = $fields[17];
            $week3 = $fields[18];
            $week4 = $fields[19];
            $id = $fields[20];

in line 437 of admin/module/Import/Import.php in $data array replace the following (adding 'id' value to the data):

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

 

Edited by ProSkyDesign
Link to comment
Share on other sites

  • Administrators
2 hours ago, skyguyt said:

Ahh, very true and good point. So for an example, yesterday I flew twice with the old schedules and uploaded those flights via SmartCARS to the website. Got them accepted, and they were all fine and dandy. Today I deleted all old schedules when I did the new import and just checked the PIREPs from the old schedules are still locked in to my account and the airline stats even though if you went to search those id's they'd technically be gone and no longer matched in the database as you pointed out. Is there something larger that could potentially go wrong that you are foreseeing that I am missing? It appeared as if the data held enough to keep the profiles and stats populated correctly.

 

Thank you both for all of your help. I appreciate the time given!

It shouldn't affect PIREPS - but there are so many interconnected bits and pieces, there is no telling what else may be affected. Also no telling how it may affect addon modules and their functionality.

Link to comment
Share on other sites

  • 3 weeks later...
On 11/16/2019 at 7:27 PM, ProSkyDesign said:

you're welcome

as ProAvia said, you will loose that feature, the best thing you can do is import de DB directly from phpmyadmin (or other mysql gestor) instead of use import function in admin panel, this will ignore that rule (because the duplicate check is created with a php if rule so in data table this rule doesn't exist).

Other thing you can do is add to your csv a column (last column) called id and put the id of the schedule here with the format of autoincrement (starting by 1 and so...)

in line 359 of admin/module/Import/Import.php you should add $id variable


// list fields:
            $code = $fields[0];
            $flightnum = $fields[1];
            $depicao = $fields[2];
            $arricao = $fields[3];
            $route = $fields[4];
            $aircraft = $fields[5];
            $flightlevel = $fields[6];
            $distance = $fields[7];
            $deptime = $fields[8];
            $arrtime = $fields[9];
            $flighttime = $fields[10];
            $notes = $fields[11];
            $price = $fields[12];
            $flighttype = $fields[13];
            $daysofweek = $fields[14];
            $enabled = $fields[15];
            $week1 = $fields[16];
            $week2 = $fields[17];
            $week3 = $fields[18];
            $week4 = $fields[19];
            $id = $fields[20];

in line 437 of admin/module/Import/Import.php in $data array replace the following (adding 'id' value to the data):


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

 

Awesome, I like the idea. So leave the previous changes as well or revert to original files and then implement this new idea?

 

Thanks!

Link to comment
Share on other sites

  • 3 years later...

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