Jump to content

Recommended Posts

Posted

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!

  • Moderators
Posted
  On 10/31/2019 at 3:22 PM, 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!

Expand  

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;
        }
Posted
  On 10/31/2019 at 6: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;
        }
Expand  

Perfect, thank you very much!

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

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

Expand  

^ 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!

  • Moderators
Posted
  On 11/4/2019 at 8:59 PM, skyguyt said:

Perfect, thank you very much!

^ 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!

Expand  

You're welcome :)

  • 2 weeks later...
Posted
  On 11/5/2019 at 5:20 AM, ProSkyDesign said:

You're welcome :)

Expand  

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?

  • Moderators
Posted
  On 11/16/2019 at 7:29 PM, 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?

Expand  

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.

  • Administrators
Posted (edited)
  On 11/16/2019 at 7:46 PM, 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.

Expand  

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
Posted
  On 11/16/2019 at 7:46 PM, 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.

Expand  

Worked great, thank you!

Posted
  On 11/16/2019 at 10:45 PM, 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.

Expand  

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!

  • Moderators
Posted (edited)
  On 11/16/2019 at 11:38 PM, skyguyt said:

Worked great, thank you!

Expand  

you're welcome

  On 11/16/2019 at 10:45 PM, 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.

Expand  

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
  • Administrators
Posted
  On 11/16/2019 at 11:44 PM, 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!

Expand  

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.

  • 3 weeks later...
Posted
  On 11/17/2019 at 1:27 AM, 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
            );

 

Expand  

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

 

Thanks!

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

×
×
  • Create New...