// We create VCard $v = new vCard(); $v->setProdId('Dolibarr '.DOL_VERSION); $v->setUid('DOLIBARR-CONTACTID-'.$contact->id); $v->setName($contact->name, $contact->firstname, "", "", ""); $v->setFormattedName($contact->getFullName($langs)); // By default, all informations are for work (except phone_perso and phone_mobile) $v->setPhoneNumber($contact->phone_pro, "PREF;WORK;VOICE"); $v->setPhoneNumber($contact->phone_mobile, "CELL;VOICE"); $v->setPhoneNumber($contact->fax, "WORK;FAX"); $v->setAddress("", "", $contact->address, $contact->ville, "", $contact->cp, ($contact->pays_code?$contact->pays:''), "WORK;POSTAL"); $v->setLabel("", "", $contact->address, $contact->ville, "", $contact->cp, ($contact->pays_code?$contact->pays:''), "WORK"); $v->setEmail($contact->email,'internet,pref'); $v->setNote($contact->note); $v->setTitle($contact->poste); // Data from linked company if ($company->id) { $v->setURL($company->url, "WORK"); if (! $contact->phone_pro) $v->setPhoneNumber($company->tel, "WORK;VOICE"); if (! $contact->fax) $v->setPhoneNumber($company->fax, "WORK;FAX"); if (! $contact->cp) $v->setAddress("", "", $company->address, $company->ville, "", $company->cp, $company->pays_code, "WORK;POSTAL"); if ($company->email != $contact->email) $v->setEmail($company->email,'internet'); // Si contact lie a un tiers non de type "particulier" if ($contact->typent_code != 'TE_PRIVATE') $v->setOrg($company->nom);
if ($contact->socid) { $result = $company->fetch($contact->socid); //print "ee"; } // We create VCard $v = new vCard(); $v->setProdId('Dolibarr ' . DOL_VERSION); $v->setUid('DOLIBARR-CONTACTID-' . $contact->id); $v->setName($contact->lastname, $contact->firstname, "", "", ""); $v->setFormattedName($contact->getFullName($langs)); // By default, all informations are for work (except phone_perso and phone_mobile) $v->setPhoneNumber($contact->phone_pro, "PREF;WORK;VOICE"); $v->setPhoneNumber($contact->phone_mobile, "CELL;VOICE"); $v->setPhoneNumber($contact->fax, "WORK;FAX"); $v->setAddress("", "", $contact->address, $contact->town, "", $contact->zip, $contact->country_code ? $contact->country_id : '', "WORK;POSTAL"); $v->setLabel("", "", $contact->address, $contact->town, "", $contact->zip, $contact->country_code ? $contact->country_id : '', "WORK"); $v->setEmail($contact->email, 'internet,pref'); $v->setNote($contact->note); $v->setTitle($contact->poste); // Data from linked company if ($company->id) { $v->setURL($company->url, "WORK"); if (!$contact->phone_pro) { $v->setPhoneNumber($company->phone, "WORK;VOICE"); } if (!$contact->fax) { $v->setPhoneNumber($company->fax, "WORK;FAX"); } if (!$contact->zip) { $v->setAddress("", "", $company->address, $company->town, "", $company->zip, $company->country_code, "WORK;POSTAL"); }
$sql2 = "SELECT * FROM contacts_titlelist WHERE title_id = '{$contact_title}' LIMIT 1"; $result2 = mysql_query($sql2, $conn) or die(mysql_error()); $array2 = mysql_fetch_array($result2); $title_name = $array2['title_name']; // WRAP UP OTHER INFORMATION INTO A NOTE if ($contact_reference != "") { $contact_reference = "Notes:\n" . $contact_reference; } $contact_reference = $contact_reference . "\nContact Added to Database:\n" . $contact_added; // USAGE EXAMPLE $v = new vCard(); $v->setPhoneNumber($output_telephone, "TEL;PREF;WORK;VOICE"); $v->setPhoneNumber($contact_telephone_home, "TEL;HOME;VOICE"); $v->setPhoneNumber($output_fax, "TEL;WORK;FAX"); $v->setPhoneNumber($contact_mobile, "TEL;CELL;VOICE"); $v->setName($contact_namesecond, $contact_namefirst, "", ""); $v->setTitle($title_name); $v->setBirthday(""); $v->setCompany($company_name); $v->setLabel("", "", $contact_address, $contact_city, "", $contact_postcode); $v->setAddress("", "", $company_address, $company_city, "", $company_postcode); $v->setEmail($contact_email); $v->setNote($contact_reference); $v->setURL($company_web); $output = $v->getVCard(); $filename = $v->getFileName(); //Header("Content-Disposition: attachment; filename=$filename"); //Header("Content-Length: ".strlen($output)); //Header("Connection: close"); //Header("Content-Type: text/x-vCard; name=$filename"); echo $output;