sivann / itdb

IT Items Database
http://www.sivann.gr/software/itdb/
GNU General Public License v3.0
154 stars 105 forks source link

Location data being lost when importing items into ITDB #62

Open computerman-13 opened 7 years ago

computerman-13 commented 7 years ago

I noticed an issue when importing data into the database using the import function.
When I attempt to import a file, the location information is populated pre import check, but once the data is imported and I list the items, the location field is blank. Additionally, if there is information in the area field in the csv file, that is entered into the database.

kalanUM commented 7 years ago

Hi computerman-13, Check out the file import.php - find "INSERT into items" query, change this:

           //'locationid'=>$locationid,
           'locationid'=>$locid,

Or find the two "$locid" vars and change them to $locationid (note, don't change the 'locid' array tags):

    $lr=getlocidsbynames($cols[$name2fno['location']],$cols[$name2fno['area']]);
    if ($lr[0]<0) {
        echo "Location/locarea non existent: {$cols[$name2fno['location']]}/{$cols[$name2fno['area']]}<br>";
        $locid="";
        $locareaid="";
    }
    else {
        $locid=$lr['locid'];
        $locareaid=$lr['locareaid'];
    }
computerman-13 commented 7 years ago

I first tried the first change changing 'locationid'=>$locid, which I saw a few days ago in your othe post, but that did not correct the issue.
I also tried changing $lr=getlocidsbynames($cols[$name2fno['location']],$cols[$name2fno['area']]); if ($lr[0]<0) { echo "Location/locarea non existent: {$cols[$name2fno['location']]}/{$cols[$name2fno['area']]}
"; $locid=""; $locareaid=""; } else { $locid=$lr['locid']; $locareaid=$lr['locareaid']; }

to $locationid but that did not work either.

computerman-13 commented 7 years ago

I just did some additional testing. I found that If I put in an area as well as the location, then the location is imported into the database correctly. If there is only a location in the itdb database, then the information isn't imported because it appears to be referencing the locareaid table. I looked at the table and nothing is created in the table unless an area is filled in for each location.

nikband commented 7 years ago

Location (example London with floor 1,2,3 have different locationid) have problem with actual import procedure.

I try to solve this in my fork but I not able to fix... @sivann can you help with this location-floor-area import problem?

info: There is a check if SN is present into items? for skip just imported items or done an UPDATE (i prefer a skip)