Update contact_import.php

This commit is contained in:
FusionPBX
2017-03-16 19:23:17 -06:00
committed by GitHub
parent 3b3e2f5715
commit 186ece4940
+20 -16
View File
@@ -72,6 +72,7 @@
} }
//copy the csv file //copy the csv file
//$_POST['submit'] == "Upload" &&
if ( is_uploaded_file($_FILES['ulfile']['tmp_name']) && permission_exists('contact_upload')) { if ( is_uploaded_file($_FILES['ulfile']['tmp_name']) && permission_exists('contact_upload')) {
if (check_str($_POST['type']) == 'csv') { if (check_str($_POST['type']) == 'csv') {
move_uploaded_file($_FILES['ulfile']['tmp_name'], $_SESSION['server']['temp']['dir'].'/'.$_FILES['ulfile']['name']); move_uploaded_file($_FILES['ulfile']['tmp_name'], $_SESSION['server']['temp']['dir'].'/'.$_FILES['ulfile']['name']);
@@ -163,6 +164,7 @@
//loop through user columns //loop through user columns
$x = 0; $x = 0;
foreach ($line_fields as $line_field) { foreach ($line_fields as $line_field) {
$line_field = trim(trim($line_field), $enclosure);
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
//echo " ".$text['label-zzz']."\n"; //echo " ".$text['label-zzz']."\n";
@@ -226,8 +228,8 @@
//upload the contact csv //upload the contact csv
if (file_exists($_SESSION['file']) && $action == 'import') { if (file_exists($_SESSION['file']) && $action == 'import') {
//form to match the fields to the column names //form to match the fields to the column names
require_once "resources/header.php"; //require_once "resources/header.php";
//user selected fields //user selected fields
$fields = $_POST['fields']; $fields = $_POST['fields'];
@@ -267,17 +269,16 @@ require_once "resources/header.php";
} }
//build the data array //build the data array
if (strlen($parent) == 0) { if (strlen($table_name) > 0) {
$array[$table_name][$row_id]['domain_uuid'] = $domain_uuid; if (strlen($parent) == 0) {
$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 {
$array[$parent][$row_id][$table_name][$y]['domain_uuid'] = $domain_uuid;
$array[$parent][$row_id][$table_name][$y][$field_name] = $result[$key];
}
} }
else {
$array[$parent][$row_id][$table_name][$y]['domain_uuid'] = $domain_uuid;
$array[$parent][$row_id][$table_name][$y][$field_name] = $result[$key];
}
//increment
$y++;
} }
//increment row id //increment row id
@@ -285,15 +286,18 @@ require_once "resources/header.php";
} }
fclose($handle); fclose($handle);
//debug info
//echo "<pre>\n";
//print_r($array);
//echo "</pre>\n";
//exit;
//save to the data //save to the data
$database = new database; $database = new database;
$database->app_name = 'contacts'; $database->app_name = 'contacts';
$database->app_uuid = '04481e0e-a478-c559-adad-52bd4174574c'; $database->app_uuid = '04481e0e-a478-c559-adad-52bd4174574c';
//if (strlen($contact_uuid) > 0) {
// $database->uuid($contact_uuid);
//}
$database->save($array); $database->save($array);
$message = $database->message; //$message = $database->message;
//send the redirect header //send the redirect header
header("Location: contacts.php"); header("Location: contacts.php");