Update device_imports.php

This commit is contained in:
FusionPBX
2018-10-20 14:53:11 -06:00
committed by GitHub
parent 1ba5bd4431
commit 5e3409f43a
+24 -7
View File
@@ -17,7 +17,7 @@
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2018 Portions created by the Initial Developer are Copyright (C) 2018
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
@@ -127,10 +127,11 @@
$i++; $i++;
} }
} }
//echo "<pre>\n";
//print_r($schema); $i++;
//echo "</pre>\n"; $schema[$i]['table'] = 'devices';
//exit; $schema[$i]['parent'] = '';
$schema[$i]['fields'][] = 'username';
} }
//match the column names to the field names //match the column names to the field names
@@ -245,6 +246,12 @@
//set the domain_uuid //set the domain_uuid
$domain_uuid = $_SESSION['domain_uuid']; $domain_uuid = $_SESSION['domain_uuid'];
//get the users
$sql = "select * from v_users where domain_uuid = '".$domain_uuid."' ";
$prep_statement = $db->prepare($sql);
$prep_statement->execute();
$users = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
//get the contents of the csv file and convert them into an array //get the contents of the csv file and convert them into an array
$handle = @fopen($_SESSION['file'], "r"); $handle = @fopen($_SESSION['file'], "r");
if ($handle) { if ($handle) {
@@ -280,13 +287,23 @@
//build the data array //build the data array
if (strlen($table_name) > 0) { if (strlen($table_name) > 0) {
if (strlen($parent) == 0) { if (strlen($parent) == 0) {
$array[$table_name][$row_id]['domain_uuid'] = $domain_uuid; if ($field_name != "username") {
$array[$table_name][$row_id][$field_name] = $result[$key]; $array[$table_name][$row_id]['domain_uuid'] = $domain_uuid;
$array[$table_name][$row_id][$field_name] = $result[$key];
}
} }
else { else {
$array[$parent][$row_id][$table_name][$y]['domain_uuid'] = $domain_uuid; $array[$parent][$row_id][$table_name][$y]['domain_uuid'] = $domain_uuid;
$array[$parent][$row_id][$table_name][$y][$field_name] = $result[$key]; $array[$parent][$row_id][$table_name][$y][$field_name] = $result[$key];
} }
if ($field_name == "username") {
foreach ($users as $field) {
if ($field['username'] == $result[$key]) {
$array[$table_name][$row_id]['device_user_uuid'] = $field['user_uuid'];
}
}
}
} }
} }