Hi I have posted this in case it is of help to anyone. I still have not had time to write my own code for contacts import, but this weekend a customer asked me to import 800 contact records so I had to do something. This apples to my Fusion 4.2.3 installation.
I had to modify contact_import.php a little. By default contacts import with no access permissions so I added some code to get the UUID for the users group and add this by default to all imported contacts. I also added the ContactType so this can be supplied in the .CSV. Here is the diff:
Code:
diff contact_import.php contact_import_orig.php
62,71d61
< // added by AHF - get UUID of users group
< $sql = "select group_uuid from v_groups where group_name = 'user'";
< $prep_statement = $db->prepare(check_sql($sql));
< $prep_statement->execute();
< $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
< $contact_vgroup_uuid = $result[0]["group_uuid"];
< unset ($prep_statement, $sql);
<
<
<
107,108d96
< //added by AHF
< $contact_type = $data['ContactType'];
141,159d128
< $sql .= ")";
< $db->exec(check_sql($sql));
< unset($sql);
<
< //added by AHF add the permission
< $contact_group_uuid = uuid();
< $sql = "insert into v_contact_groups ";
< $sql .= "(";
< $sql .= "contact_group_uuid, ";
< $sql .= "domain_uuid, ";
< $sql .= "contact_uuid, ";
< $sql .= "group_uuid ";
< $sql .= ")";
< $sql .= "values ";
< $sql .= "(";
< $sql .= "'$contact_group_uuid', ";
< $sql .= "'".$_SESSION['domain_uuid']."', ";
< $sql .= "'$contact_uuid', ";
< $sql .= "'$contact_vgroup_uuid' ";
It still doesn't import URLs, Email addresses etc. but it does do contacts, all the addresses and all the phone number types.
The CSV header is important, it determines what will be imported and obviously you have to match it to the .CSV data you have. Here are the list of headings it will now import:
"ContactType","Title","FirstName","LastName","Company","EmailAddress","Notes","Web Page",
"BusinessStreet","BusinessCity","BusinessState","BusinessPostalCode","BusinessCountry","HomeStreet",
"HomeCity","HomeState","HomePostalCode","HomeCountry","OtherStreet","OtherCity","OtherState",
"OtherPostalCode","OtherCountry","BusinessFax","BusinessPhone","BusinessPhone2","CompanyMainPhone",
"HomeFax","HomePhone","HomePhone2","MobilePhone","OtherFax","OtherPhone","Pager","PrimaryPhone"
So a very simple .CSV file to import may look something like this:
"ContactType","Company","CompanyMainPhone"
"supplier","A B C Ltd","01234 56789"
"customer","Joe Bloggs Ltd","0987 654321"
I hope this is helpful. Adrian.