From 186ece494081e0f4818e8d0ce599e446c8f8d17a Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Thu, 16 Mar 2017 19:23:17 -0600 Subject: [PATCH] Update contact_import.php --- app/contacts/contact_import.php | 38 ++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/app/contacts/contact_import.php b/app/contacts/contact_import.php index fee9ea5a99..75d09149e8 100644 --- a/app/contacts/contact_import.php +++ b/app/contacts/contact_import.php @@ -72,6 +72,7 @@ } //copy the csv file + //$_POST['submit'] == "Upload" && if ( is_uploaded_file($_FILES['ulfile']['tmp_name']) && permission_exists('contact_upload')) { if (check_str($_POST['type']) == 'csv') { move_uploaded_file($_FILES['ulfile']['tmp_name'], $_SESSION['server']['temp']['dir'].'/'.$_FILES['ulfile']['name']); @@ -163,6 +164,7 @@ //loop through user columns $x = 0; foreach ($line_fields as $line_field) { + $line_field = trim(trim($line_field), $enclosure); echo "\n"; echo "\n"; //echo " ".$text['label-zzz']."\n"; @@ -226,8 +228,8 @@ //upload the contact csv if (file_exists($_SESSION['file']) && $action == 'import') { -//form to match the fields to the column names -require_once "resources/header.php"; + //form to match the fields to the column names + //require_once "resources/header.php"; //user selected fields $fields = $_POST['fields']; @@ -260,40 +262,42 @@ require_once "resources/header.php"; //get the parent table name $parent = get_parent($schema, $table_name); - + //remove formatting from the phone number if ($field_name == "phone_number") { $result[$key] = preg_replace('{\D}', '', $result[$key]); } //build the data array - if (strlen($parent) == 0) { - $array[$table_name][$row_id]['domain_uuid'] = $domain_uuid; - $array[$table_name][$row_id][$field_name] = $result[$key]; + if (strlen($table_name) > 0) { + if (strlen($parent) == 0) { + $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 $row_id++; } fclose($handle); + + //debug info + //echo "
\n";
+					//print_r($array);
+					//echo "
\n"; + //exit; //save to the data $database = new database; $database->app_name = 'contacts'; $database->app_uuid = '04481e0e-a478-c559-adad-52bd4174574c'; - //if (strlen($contact_uuid) > 0) { - // $database->uuid($contact_uuid); - //} $database->save($array); - $message = $database->message; + //$message = $database->message; //send the redirect header header("Location: contacts.php");