Fix: [ bug #2570 ] [Contacts] Page should not process if ID is invalid
This commit is contained in:
parent
d422fac3fe
commit
8d7c1f8d4c
@ -23,6 +23,7 @@ Fix: [ bug #2837 ] Product list table column header does not match column body
|
|||||||
Fix: [ bug #2835 ] Customer prices of a product shows incorrect history order
|
Fix: [ bug #2835 ] Customer prices of a product shows incorrect history order
|
||||||
Fix: [ bug #2814 ] JPEG photos are not displayed in Product photos page
|
Fix: [ bug #2814 ] JPEG photos are not displayed in Product photos page
|
||||||
Fix: [ bug #2715 ] Statistics page has broken layout with long thirdparty names
|
Fix: [ bug #2715 ] Statistics page has broken layout with long thirdparty names
|
||||||
|
Fix: [ bug #2570 ] [Contacts] Page should not process if ID is invalid
|
||||||
|
|
||||||
***** ChangeLog for 3.5.6 compared to 3.5.5 *****
|
***** ChangeLog for 3.5.6 compared to 3.5.5 *****
|
||||||
Fix: Avoid missing class error for fetch_thirdparty method #1973
|
Fix: Avoid missing class error for fetch_thirdparty method #1973
|
||||||
|
|||||||
@ -33,81 +33,80 @@ $id = GETPOST('id', 'int');
|
|||||||
if ($user->societe_id) $socid=$user->societe_id;
|
if ($user->societe_id) $socid=$user->societe_id;
|
||||||
$result = restrictedArea($user, 'contact', $id, 'socpeople&societe');
|
$result = restrictedArea($user, 'contact', $id, 'socpeople&societe');
|
||||||
|
|
||||||
|
$contact = new Contact($db);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$form = new Form($db);
|
||||||
|
|
||||||
$title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
|
$title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
|
||||||
|
|
||||||
llxHeader('',$title,'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas');
|
llxHeader('',$title,'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas');
|
||||||
|
|
||||||
$form = new Form($db);
|
if ($id > 0)
|
||||||
|
|
||||||
$contact = new Contact($db);
|
|
||||||
$contact->fetch($id, $user);
|
|
||||||
|
|
||||||
|
|
||||||
$head = contact_prepare_head($contact);
|
|
||||||
|
|
||||||
dol_fiche_head($head, 'exportimport', $title, 0, 'contact');
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Fiche en mode visu
|
|
||||||
*/
|
|
||||||
print '<table class="border" width="100%">';
|
|
||||||
|
|
||||||
$linkback = '<a href="'.DOL_URL_ROOT.'/contact/list.php">'.$langs->trans("BackToList").'</a>';
|
|
||||||
|
|
||||||
// Ref
|
|
||||||
print '<tr><td>'.$langs->trans("Ref").'</td><td colspan="3">';
|
|
||||||
print $form->showrefnav($contact, 'id', $linkback);
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
// Name
|
|
||||||
print '<tr><td width="20%">'.$langs->trans("Lastname").' / '.$langs->trans("Label").'</td><td>'.$contact->lastname.'</td>';
|
|
||||||
print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="25%">'.$contact->firstname.'</td></tr>';
|
|
||||||
|
|
||||||
// Company
|
|
||||||
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
|
|
||||||
{
|
{
|
||||||
if ($contact->socid > 0)
|
$contact->fetch($id, $user);
|
||||||
{
|
|
||||||
$objsoc = new Societe($db);
|
|
||||||
$objsoc->fetch($contact->socid);
|
|
||||||
|
|
||||||
print '<tr><td width="15%">'.$langs->trans("Company").'</td><td colspan="3">'.$objsoc->getNomUrl(1).'</td></tr>';
|
$head = contact_prepare_head($contact);
|
||||||
}
|
|
||||||
else
|
dol_fiche_head($head, 'exportimport', $title, 0, 'contact');
|
||||||
{
|
|
||||||
print '<tr><td width="15%">'.$langs->trans("Company").'</td><td colspan="3">';
|
|
||||||
print $langs->trans("ContactNotLinkedToCompany");
|
/*
|
||||||
print '</td></tr>';
|
* Fiche en mode visu
|
||||||
}
|
*/
|
||||||
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
|
$linkback = '<a href="'.DOL_URL_ROOT.'/contact/list.php">'.$langs->trans("BackToList").'</a>';
|
||||||
|
|
||||||
|
// Ref
|
||||||
|
print '<tr><td>'.$langs->trans("Ref").'</td><td colspan="3">';
|
||||||
|
print $form->showrefnav($contact, 'id', $linkback);
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
// Name
|
||||||
|
print '<tr><td width="20%">'.$langs->trans("Lastname").' / '.$langs->trans("Label").'</td><td>'.$contact->lastname.'</td>';
|
||||||
|
print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="25%">'.$contact->firstname.'</td></tr>';
|
||||||
|
|
||||||
|
// Company
|
||||||
|
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
|
||||||
|
{
|
||||||
|
if ($contact->socid > 0)
|
||||||
|
{
|
||||||
|
$objsoc = new Societe($db);
|
||||||
|
$objsoc->fetch($contact->socid);
|
||||||
|
|
||||||
|
print '<tr><td width="15%">'.$langs->trans("Company").'</td><td colspan="3">'.$objsoc->getNomUrl(1).'</td></tr>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<tr><td width="15%">'.$langs->trans("Company").'</td><td colspan="3">';
|
||||||
|
print $langs->trans("ContactNotLinkedToCompany");
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Civility
|
||||||
|
print '<tr><td>'.$langs->trans("UserTitle").'</td><td colspan="3">';
|
||||||
|
print $contact->getCivilityLabel();
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
print '</table>';
|
||||||
|
|
||||||
|
print '</div>';
|
||||||
|
|
||||||
|
print '<br>';
|
||||||
|
|
||||||
|
print $langs->trans("ExportCardToFormat").': ';
|
||||||
|
print '<a href="'.DOL_URL_ROOT.'/contact/vcard.php?id='.$contact->id.'">';
|
||||||
|
print img_picto($langs->trans("VCard"),'vcard.png').' ';
|
||||||
|
print $langs->trans("VCard");
|
||||||
|
print '</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Civility
|
|
||||||
print '<tr><td>'.$langs->trans("UserTitle").'</td><td colspan="3">';
|
|
||||||
print $contact->getCivilityLabel();
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
print '</table>';
|
|
||||||
|
|
||||||
print '</div>';
|
|
||||||
|
|
||||||
print '<br>';
|
|
||||||
|
|
||||||
print $langs->trans("ExportCardToFormat").': ';
|
|
||||||
print '<a href="'.DOL_URL_ROOT.'/contact/vcard.php?id='.$contact->id.'">';
|
|
||||||
print img_picto($langs->trans("VCard"),'vcard.png').' ';
|
|
||||||
print $langs->trans("VCard");
|
|
||||||
print '</a>';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
llxFooter();
|
llxFooter();
|
||||||
?>
|
|
||||||
|
|||||||
@ -35,6 +35,8 @@ $contactid = GETPOST("id",'int');
|
|||||||
if ($user->societe_id) $socid=$user->societe_id;
|
if ($user->societe_id) $socid=$user->societe_id;
|
||||||
$result = restrictedArea($user, 'contact', $contactid, 'socpeople&societe');
|
$result = restrictedArea($user, 'contact', $contactid, 'socpeople&societe');
|
||||||
|
|
||||||
|
$contact = new Contact($db);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -43,25 +45,26 @@ $result = restrictedArea($user, 'contact', $contactid, 'socpeople&societe');
|
|||||||
|
|
||||||
llxHeader('',$langs->trans("ContactsAddresses"),'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas');
|
llxHeader('',$langs->trans("ContactsAddresses"),'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas');
|
||||||
|
|
||||||
|
if ($contactid > 0)
|
||||||
|
{
|
||||||
|
$result = $contact->fetch($contactid, $user);
|
||||||
|
|
||||||
$contact = new Contact($db);
|
$contact->info($contactid);
|
||||||
$contact->fetch($contactid, $user);
|
|
||||||
$contact->info($contactid);
|
|
||||||
|
|
||||||
|
|
||||||
$head = contact_prepare_head($contact);
|
$head = contact_prepare_head($contact);
|
||||||
|
|
||||||
dol_fiche_head($head, 'info', $langs->trans("ContactsAddresses"), 0, 'contact');
|
dol_fiche_head($head, 'info', $langs->trans("ContactsAddresses"), 0, 'contact');
|
||||||
|
|
||||||
|
|
||||||
print '<table width="100%"><tr><td>';
|
print '<table width="100%"><tr><td>';
|
||||||
print '</td></tr></table>';
|
print '</td></tr></table>';
|
||||||
|
|
||||||
dol_print_object_info($contact);
|
dol_print_object_info($contact);
|
||||||
|
|
||||||
print "</div>";
|
print "</div>";
|
||||||
|
}
|
||||||
|
|
||||||
llxFooter();
|
llxFooter();
|
||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
?>
|
|
||||||
|
|||||||
@ -40,37 +40,40 @@ if ($user->societe_id) $socid=$user->societe_id;
|
|||||||
$result = restrictedArea($user, 'contact', $id, 'socpeople&societe');
|
$result = restrictedArea($user, 'contact', $id, 'socpeople&societe');
|
||||||
|
|
||||||
$contact = new Contact($db);
|
$contact = new Contact($db);
|
||||||
$contact->fetch($id, $user);
|
|
||||||
|
|
||||||
|
if ($id > 0)
|
||||||
/*
|
|
||||||
* Actions
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ($action == 'dolibarr2ldap')
|
|
||||||
{
|
{
|
||||||
$message="";
|
$contact->fetch($id, $user);
|
||||||
|
|
||||||
$db->begin();
|
/*
|
||||||
|
* Actions
|
||||||
|
*/
|
||||||
|
|
||||||
$ldap=new Ldap();
|
if ($action == 'dolibarr2ldap')
|
||||||
$result=$ldap->connect_bind();
|
|
||||||
|
|
||||||
$info=$contact->_load_ldap_info();
|
|
||||||
$dn=$contact->_load_ldap_dn($info);
|
|
||||||
$olddn=$dn; // We can say that old dn = dn as we force synchro
|
|
||||||
|
|
||||||
$result=$ldap->update($dn,$info,$user,$olddn);
|
|
||||||
|
|
||||||
if ($result >= 0)
|
|
||||||
{
|
{
|
||||||
$message.='<div class="ok">'.$langs->trans("ContactSynchronized").'</div>';
|
$message="";
|
||||||
$db->commit();
|
|
||||||
}
|
$db->begin();
|
||||||
else
|
|
||||||
{
|
$ldap=new Ldap();
|
||||||
$message.='<div class="error">'.$ldap->error.'</div>';
|
$result=$ldap->connect_bind();
|
||||||
$db->rollback();
|
|
||||||
|
$info=$contact->_load_ldap_info();
|
||||||
|
$dn=$contact->_load_ldap_dn($info);
|
||||||
|
$olddn=$dn; // We can say that old dn = dn as we force synchro
|
||||||
|
|
||||||
|
$result=$ldap->update($dn,$info,$user,$olddn);
|
||||||
|
|
||||||
|
if ($result >= 0)
|
||||||
|
{
|
||||||
|
$message.='<div class="ok">'.$langs->trans("ContactSynchronized").'</div>';
|
||||||
|
$db->commit();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$message.='<div class="error">'.$ldap->error.'</div>';
|
||||||
|
$db->rollback();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,138 +82,139 @@ if ($action == 'dolibarr2ldap')
|
|||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$form = new Form($db);
|
||||||
|
|
||||||
$title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
|
$title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
|
||||||
|
|
||||||
llxHeader('',$title,'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas');
|
llxHeader('',$title,'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas');
|
||||||
|
|
||||||
$form = new Form($db);
|
if ($id > 0)
|
||||||
|
|
||||||
$head = contact_prepare_head($contact);
|
|
||||||
|
|
||||||
dol_fiche_head($head, 'ldap', $title, 0, 'contact');
|
|
||||||
|
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
|
||||||
|
|
||||||
// Ref
|
|
||||||
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td colspan="3">';
|
|
||||||
print $form->showrefnav($contact,'id');
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
// Name
|
|
||||||
print '<tr><td>'.$langs->trans("Lastname").' / '.$langs->trans("Label").'</td><td>'.$contact->lastname.'</td>';
|
|
||||||
print '<td>'.$langs->trans("Firstname").'</td><td width="25%">'.$contact->firstname.'</td></tr>';
|
|
||||||
|
|
||||||
// Company
|
|
||||||
if ($contact->socid > 0)
|
|
||||||
{
|
{
|
||||||
$objsoc = new Societe($db);
|
$head = contact_prepare_head($contact);
|
||||||
$objsoc->fetch($contact->socid);
|
|
||||||
|
|
||||||
print '<tr><td width="20%">'.$langs->trans("Company").'</td><td colspan="3">'.$objsoc->getNomUrl(1).'</td></tr>';
|
dol_fiche_head($head, 'ldap', $title, 0, 'contact');
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
print '<table class="border" width="100%">';
|
||||||
print '<tr><td width="20%">'.$langs->trans("Company").'</td><td colspan="3">';
|
|
||||||
print $langs->trans("ContactNotLinkedToCompany");
|
// Ref
|
||||||
|
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td colspan="3">';
|
||||||
|
print $form->showrefnav($contact,'id');
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
|
||||||
|
|
||||||
// Civility
|
// Name
|
||||||
print '<tr><td>'.$langs->trans("UserTitle").'</td><td colspan="3">';
|
print '<tr><td>'.$langs->trans("Lastname").' / '.$langs->trans("Label").'</td><td>'.$contact->lastname.'</td>';
|
||||||
print $contact->getCivilityLabel();
|
print '<td>'.$langs->trans("Firstname").'</td><td width="25%">'.$contact->firstname.'</td></tr>';
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
// LDAP DN
|
// Company
|
||||||
print '<tr><td>LDAP '.$langs->trans("LDAPContactDn").'</td><td class="valeur" colspan="3">'.$conf->global->LDAP_CONTACT_DN."</td></tr>\n";
|
if ($contact->socid > 0)
|
||||||
|
|
||||||
// LDAP Cle
|
|
||||||
print '<tr><td>LDAP '.$langs->trans("LDAPNamingAttribute").'</td><td class="valeur" colspan="3">'.$conf->global->LDAP_KEY_CONTACTS."</td></tr>\n";
|
|
||||||
|
|
||||||
// LDAP Server
|
|
||||||
print '<tr><td>LDAP '.$langs->trans("LDAPPrimaryServer").'</td><td class="valeur" colspan="3">'.$conf->global->LDAP_SERVER_HOST."</td></tr>\n";
|
|
||||||
print '<tr><td>LDAP '.$langs->trans("LDAPSecondaryServer").'</td><td class="valeur" colspan="3">'.$conf->global->LDAP_SERVER_HOST_SLAVE."</td></tr>\n";
|
|
||||||
print '<tr><td>LDAP '.$langs->trans("LDAPServerPort").'</td><td class="valeur" colspan="3">'.$conf->global->LDAP_SERVER_PORT."</td></tr>\n";
|
|
||||||
|
|
||||||
print '</table>';
|
|
||||||
|
|
||||||
print '</div>';
|
|
||||||
|
|
||||||
|
|
||||||
dol_htmloutput_mesg($message);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Barre d'actions
|
|
||||||
*/
|
|
||||||
|
|
||||||
print '<div class="tabsAction">';
|
|
||||||
|
|
||||||
if (! empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != 'ldap2dolibarr')
|
|
||||||
{
|
|
||||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$contact->id.'&action=dolibarr2ldap">'.$langs->trans("ForceSynchronize").'</a>';
|
|
||||||
}
|
|
||||||
|
|
||||||
print "</div>\n";
|
|
||||||
|
|
||||||
if (! empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != 'ldap2dolibarr') print "<br>\n";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Affichage attributs LDAP
|
|
||||||
print_titre($langs->trans("LDAPInformationsForThisContact"));
|
|
||||||
|
|
||||||
print '<table width="100%" class="noborder">';
|
|
||||||
|
|
||||||
print '<tr class="liste_titre">';
|
|
||||||
print '<td>'.$langs->trans("LDAPAttributes").'</td>';
|
|
||||||
print '<td>'.$langs->trans("Value").'</td>';
|
|
||||||
print '</tr>';
|
|
||||||
|
|
||||||
// Lecture LDAP
|
|
||||||
$ldap=new Ldap();
|
|
||||||
$result=$ldap->connect_bind();
|
|
||||||
if ($result > 0)
|
|
||||||
{
|
|
||||||
$info=$contact->_load_ldap_info();
|
|
||||||
$dn=$contact->_load_ldap_dn($info,1);
|
|
||||||
$search = "(".$contact->_load_ldap_dn($info,2).")";
|
|
||||||
$records=$ldap->getAttribute($dn,$search);
|
|
||||||
|
|
||||||
//var_dump($records);
|
|
||||||
|
|
||||||
// Affichage arbre
|
|
||||||
if (count($records) && $records != false && (! isset($records['count']) || $records['count'] > 0))
|
|
||||||
{
|
{
|
||||||
if (! is_array($records))
|
$objsoc = new Societe($db);
|
||||||
{
|
$objsoc->fetch($contact->socid);
|
||||||
print '<tr '.$bc[false].'><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>';
|
|
||||||
}
|
print '<tr><td width="20%">'.$langs->trans("Company").'</td><td colspan="3">'.$objsoc->getNomUrl(1).'</td></tr>';
|
||||||
else
|
|
||||||
{
|
|
||||||
$result=show_ldap_content($records,0,$records['count'],true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print '<tr '.$bc[false].'><td colspan="2">'.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')</td></tr>';
|
print '<tr><td width="20%">'.$langs->trans("Company").'</td><td colspan="3">';
|
||||||
|
print $langs->trans("ContactNotLinkedToCompany");
|
||||||
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$ldap->unbind();
|
// Civility
|
||||||
$ldap->close();
|
print '<tr><td>'.$langs->trans("UserTitle").'</td><td colspan="3">';
|
||||||
|
print $contact->getCivilityLabel();
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
// LDAP DN
|
||||||
|
print '<tr><td>LDAP '.$langs->trans("LDAPContactDn").'</td><td class="valeur" colspan="3">'.$conf->global->LDAP_CONTACT_DN."</td></tr>\n";
|
||||||
|
|
||||||
|
// LDAP Cle
|
||||||
|
print '<tr><td>LDAP '.$langs->trans("LDAPNamingAttribute").'</td><td class="valeur" colspan="3">'.$conf->global->LDAP_KEY_CONTACTS."</td></tr>\n";
|
||||||
|
|
||||||
|
// LDAP Server
|
||||||
|
print '<tr><td>LDAP '.$langs->trans("LDAPPrimaryServer").'</td><td class="valeur" colspan="3">'.$conf->global->LDAP_SERVER_HOST."</td></tr>\n";
|
||||||
|
print '<tr><td>LDAP '.$langs->trans("LDAPSecondaryServer").'</td><td class="valeur" colspan="3">'.$conf->global->LDAP_SERVER_HOST_SLAVE."</td></tr>\n";
|
||||||
|
print '<tr><td>LDAP '.$langs->trans("LDAPServerPort").'</td><td class="valeur" colspan="3">'.$conf->global->LDAP_SERVER_PORT."</td></tr>\n";
|
||||||
|
|
||||||
|
print '</table>';
|
||||||
|
|
||||||
|
print '</div>';
|
||||||
|
|
||||||
|
|
||||||
|
dol_htmloutput_mesg($message);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Barre d'actions
|
||||||
|
*/
|
||||||
|
|
||||||
|
print '<div class="tabsAction">';
|
||||||
|
|
||||||
|
if (! empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != 'ldap2dolibarr')
|
||||||
|
{
|
||||||
|
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$contact->id.'&action=dolibarr2ldap">'.$langs->trans("ForceSynchronize").'</a>';
|
||||||
|
}
|
||||||
|
|
||||||
|
print "</div>\n";
|
||||||
|
|
||||||
|
if (! empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != 'ldap2dolibarr') print "<br>\n";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Affichage attributs LDAP
|
||||||
|
print_titre($langs->trans("LDAPInformationsForThisContact"));
|
||||||
|
|
||||||
|
print '<table width="100%" class="noborder">';
|
||||||
|
|
||||||
|
print '<tr class="liste_titre">';
|
||||||
|
print '<td>'.$langs->trans("LDAPAttributes").'</td>';
|
||||||
|
print '<td>'.$langs->trans("Value").'</td>';
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
|
// Lecture LDAP
|
||||||
|
$ldap=new Ldap();
|
||||||
|
$result=$ldap->connect_bind();
|
||||||
|
if ($result > 0)
|
||||||
|
{
|
||||||
|
$info=$contact->_load_ldap_info();
|
||||||
|
$dn=$contact->_load_ldap_dn($info,1);
|
||||||
|
$search = "(".$contact->_load_ldap_dn($info,2).")";
|
||||||
|
$records=$ldap->getAttribute($dn,$search);
|
||||||
|
|
||||||
|
//var_dump($records);
|
||||||
|
|
||||||
|
// Affichage arbre
|
||||||
|
if (count($records) && $records != false && (! isset($records['count']) || $records['count'] > 0))
|
||||||
|
{
|
||||||
|
if (! is_array($records))
|
||||||
|
{
|
||||||
|
print '<tr '.$bc[false].'><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$result=show_ldap_content($records,0,$records['count'],true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<tr '.$bc[false].'><td colspan="2">'.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$ldap->unbind();
|
||||||
|
$ldap->close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dol_print_error('',$ldap->error);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
print '</table>';
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
dol_print_error('',$ldap->error);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
print '</table>';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
llxFooter();
|
llxFooter();
|
||||||
?>
|
|
||||||
|
|||||||
@ -38,210 +38,213 @@ if ($user->societe_id) $socid=$user->societe_id;
|
|||||||
$result = restrictedArea($user, 'contact', $id, 'socpeople&societe');
|
$result = restrictedArea($user, 'contact', $id, 'socpeople&societe');
|
||||||
$object = new Contact($db);
|
$object = new Contact($db);
|
||||||
|
|
||||||
/*
|
$result = $object->fetch($id, $user);
|
||||||
* Action
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ($action == 'update' && ! $_POST["cancel"] && $user->rights->societe->contact->creer)
|
if ($id > 0)
|
||||||
{
|
{
|
||||||
$ret = $object->fetch($id);
|
/*
|
||||||
|
* Action
|
||||||
|
*/
|
||||||
|
|
||||||
// Note: Correct date should be completed with location to have exact GM time of birth.
|
if ($action == 'update' && ! $_POST["cancel"] && $user->rights->societe->contact->creer)
|
||||||
$object->birthday = dol_mktime(0,0,0,$_POST["birthdaymonth"],$_POST["birthdayday"],$_POST["birthdayyear"]);
|
{
|
||||||
$object->birthday_alert = $_POST["birthday_alert"];
|
// Note: Correct date should be completed with location to have exact GM time of birth.
|
||||||
|
$object->birthday = dol_mktime(0,0,0,$_POST["birthdaymonth"],$_POST["birthdayday"],$_POST["birthdayyear"]);
|
||||||
|
$object->birthday_alert = $_POST["birthday_alert"];
|
||||||
|
|
||||||
$result = $object->update_perso($id, $user);
|
$result = $object->update_perso($id, $user);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
$object->old_name='';
|
$object->old_name='';
|
||||||
$object->old_firstname='';
|
$object->old_firstname='';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$error = $object->error;
|
$error = $object->error;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$form = new Form($db);
|
||||||
|
|
||||||
$now=dol_now();
|
$now=dol_now();
|
||||||
|
|
||||||
$title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
|
$title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
|
||||||
|
|
||||||
llxHeader('',$title,'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas');
|
llxHeader('',$title,'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas');
|
||||||
|
|
||||||
$form = new Form($db);
|
if ($id > 0)
|
||||||
|
|
||||||
$object->fetch($id, $user);
|
|
||||||
|
|
||||||
$head = contact_prepare_head($object);
|
|
||||||
|
|
||||||
dol_fiche_head($head, 'perso', $title, 0, 'contact');
|
|
||||||
|
|
||||||
if ($action == 'edit')
|
|
||||||
{
|
{
|
||||||
/*
|
$head = contact_prepare_head($object);
|
||||||
* Fiche en mode edition
|
|
||||||
*/
|
|
||||||
|
|
||||||
print '<form name="perso" method="POST" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
|
dol_fiche_head($head, 'perso', $title, 0, 'contact');
|
||||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
|
||||||
print '<input type="hidden" name="action" value="update">';
|
|
||||||
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
if ($action == 'edit')
|
||||||
|
|
||||||
// Ref
|
|
||||||
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td colspan="3">';
|
|
||||||
print $object->id;
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
// Name
|
|
||||||
print '<tr><td width="20%">'.$langs->trans("Lastname").' / '.$langs->trans("Label").'</td><td width="30%">'.$object->lastname.'</td>';
|
|
||||||
print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="30%">'.$object->firstname.'</td>';
|
|
||||||
|
|
||||||
// Company
|
|
||||||
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
|
|
||||||
{
|
{
|
||||||
if ($object->socid > 0)
|
/*
|
||||||
|
* Fiche en mode edition
|
||||||
|
*/
|
||||||
|
|
||||||
|
print '<form name="perso" method="POST" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
|
||||||
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
|
print '<input type="hidden" name="action" value="update">';
|
||||||
|
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||||
|
|
||||||
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
|
// Ref
|
||||||
|
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td colspan="3">';
|
||||||
|
print $object->id;
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
// Name
|
||||||
|
print '<tr><td width="20%">'.$langs->trans("Lastname").' / '.$langs->trans("Label").'</td><td width="30%">'.$object->lastname.'</td>';
|
||||||
|
print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="30%">'.$object->firstname.'</td>';
|
||||||
|
|
||||||
|
// Company
|
||||||
|
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
|
||||||
{
|
{
|
||||||
$objsoc = new Societe($db);
|
if ($object->socid > 0)
|
||||||
$objsoc->fetch($object->socid);
|
{
|
||||||
|
$objsoc = new Societe($db);
|
||||||
|
$objsoc->fetch($object->socid);
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans("Company").'</td><td colspan="3">'.$objsoc->getNomUrl(1).'</td>';
|
print '<tr><td>'.$langs->trans("Company").'</td><td colspan="3">'.$objsoc->getNomUrl(1).'</td>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print '<tr><td>'.$langs->trans("Company").'</td><td colspan="3">';
|
print '<tr><td>'.$langs->trans("Company").'</td><td colspan="3">';
|
||||||
print $langs->trans("ContactNotLinkedToCompany");
|
print $langs->trans("ContactNotLinkedToCompany");
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Civility
|
|
||||||
print '<tr><td>'.$langs->trans("UserTitle").'</td><td colspan="3">';
|
|
||||||
print $object->getCivilityLabel();
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
// Date To Birth
|
|
||||||
print '<tr><td>'.$langs->trans("DateToBirth").'</td><td>';
|
|
||||||
$form=new Form($db);
|
|
||||||
print $form->select_date($object->birthday,'birthday',0,0,1,"perso");
|
|
||||||
print '</td>';
|
|
||||||
|
|
||||||
print '<td colspan="2">'.$langs->trans("Alert").': ';
|
|
||||||
if (! empty($object->birthday_alert))
|
|
||||||
{
|
|
||||||
print '<input type="checkbox" name="birthday_alert" checked="checked"></td>';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print '<input type="checkbox" name="birthday_alert"></td>';
|
|
||||||
}
|
|
||||||
print '</tr>';
|
|
||||||
|
|
||||||
print "</table><br>";
|
|
||||||
|
|
||||||
print '<center>';
|
|
||||||
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
|
|
||||||
print ' ';
|
|
||||||
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
|
|
||||||
print '</center>';
|
|
||||||
|
|
||||||
print "</form>";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Fiche en mode visu
|
|
||||||
*/
|
|
||||||
print '<table class="border" width="100%">';
|
|
||||||
|
|
||||||
$linkback = '<a href="'.DOL_URL_ROOT.'/contact/list.php">'.$langs->trans("BackToList").'</a>';
|
|
||||||
|
|
||||||
// Ref
|
|
||||||
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td colspan="3">';
|
|
||||||
print $form->showrefnav($object, 'id', $linkback);
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
// Name
|
|
||||||
print '<tr><td width="20%">'.$langs->trans("Lastname").' / '.$langs->trans("Label").'</td><td width="30%">'.$object->lastname.'</td>';
|
|
||||||
print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="30%">'.$object->firstname.'</td></tr>';
|
|
||||||
|
|
||||||
// Company
|
|
||||||
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
|
|
||||||
{
|
|
||||||
if ($object->socid > 0)
|
|
||||||
{
|
|
||||||
$objsoc = new Societe($db);
|
|
||||||
$objsoc->fetch($object->socid);
|
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans("Company").'</td><td colspan="3">'.$objsoc->getNomUrl(1).'</td></tr>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
// Civility
|
||||||
{
|
print '<tr><td>'.$langs->trans("UserTitle").'</td><td colspan="3">';
|
||||||
print '<tr><td>'.$langs->trans("Company").'</td><td colspan="3">';
|
print $object->getCivilityLabel();
|
||||||
print $langs->trans("ContactNotLinkedToCompany");
|
print '</td></tr>';
|
||||||
print '</td></tr>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Civility
|
// Date To Birth
|
||||||
print '<tr><td>'.$langs->trans("UserTitle").'</td><td colspan="3">';
|
print '<tr><td>'.$langs->trans("DateToBirth").'</td><td>';
|
||||||
print $object->getCivilityLabel();
|
$form=new Form($db);
|
||||||
print '</td></tr>';
|
print $form->select_date($object->birthday,'birthday',0,0,1,"perso");
|
||||||
|
|
||||||
// Date To Birth
|
|
||||||
print '<tr>';
|
|
||||||
if (! empty($object->birthday))
|
|
||||||
{
|
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
|
||||||
|
|
||||||
print '<td>'.$langs->trans("DateToBirth").'</td><td colspan="3">'.dol_print_date($object->birthday,"day");
|
|
||||||
|
|
||||||
print ' ';
|
|
||||||
//var_dump($birthdatearray);
|
|
||||||
$ageyear=convertSecondToTime($now-$object->birthday,'year')-1970;
|
|
||||||
$agemonth=convertSecondToTime($now-$object->birthday,'month')-1;
|
|
||||||
if ($ageyear >= 2) print '('.$ageyear.' '.$langs->trans("DurationYears").')';
|
|
||||||
else if ($agemonth >= 2) print '('.$agemonth.' '.$langs->trans("DurationMonths").')';
|
|
||||||
else print '('.$agemonth.' '.$langs->trans("DurationMonth").')';
|
|
||||||
|
|
||||||
|
|
||||||
print ' - ';
|
|
||||||
if ($object->birthday_alert) print $langs->trans("BirthdayAlertOn");
|
|
||||||
else print $langs->trans("BirthdayAlertOff");
|
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
|
print '<td colspan="2">'.$langs->trans("Alert").': ';
|
||||||
|
if (! empty($object->birthday_alert))
|
||||||
|
{
|
||||||
|
print '<input type="checkbox" name="birthday_alert" checked="checked"></td>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<input type="checkbox" name="birthday_alert"></td>';
|
||||||
|
}
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
|
print "</table><br>";
|
||||||
|
|
||||||
|
print '<center>';
|
||||||
|
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
|
||||||
|
print ' ';
|
||||||
|
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||||
|
print '</center>';
|
||||||
|
|
||||||
|
print "</form>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print '<td>'.$langs->trans("DateToBirth").'</td><td colspan="3">'.$langs->trans("Unknown")."</td>";
|
/*
|
||||||
}
|
* Fiche en mode visu
|
||||||
print "</tr>";
|
*/
|
||||||
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
print "</table>";
|
$linkback = '<a href="'.DOL_URL_ROOT.'/contact/list.php">'.$langs->trans("BackToList").'</a>';
|
||||||
|
|
||||||
}
|
// Ref
|
||||||
|
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td colspan="3">';
|
||||||
|
print $form->showrefnav($object, 'id', $linkback);
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
dol_fiche_end();
|
// Name
|
||||||
|
print '<tr><td width="20%">'.$langs->trans("Lastname").' / '.$langs->trans("Label").'</td><td width="30%">'.$object->lastname.'</td>';
|
||||||
|
print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="30%">'.$object->firstname.'</td></tr>';
|
||||||
|
|
||||||
if ($action != 'edit')
|
// Company
|
||||||
{
|
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
|
||||||
// Barre d'actions
|
|
||||||
if ($user->societe_id == 0)
|
|
||||||
{
|
|
||||||
print '<div class="tabsAction">';
|
|
||||||
|
|
||||||
if ($user->rights->societe->contact->creer)
|
|
||||||
{
|
{
|
||||||
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit">'.$langs->trans('Modify').'</a>';
|
if ($object->socid > 0)
|
||||||
|
{
|
||||||
|
$objsoc = new Societe($db);
|
||||||
|
$objsoc->fetch($object->socid);
|
||||||
|
|
||||||
|
print '<tr><td>'.$langs->trans("Company").'</td><td colspan="3">'.$objsoc->getNomUrl(1).'</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<tr><td>'.$langs->trans("Company").'</td><td colspan="3">';
|
||||||
|
print $langs->trans("ContactNotLinkedToCompany");
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print "</div>";
|
// Civility
|
||||||
|
print '<tr><td>'.$langs->trans("UserTitle").'</td><td colspan="3">';
|
||||||
|
print $object->getCivilityLabel();
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
// Date To Birth
|
||||||
|
print '<tr>';
|
||||||
|
if (! empty($object->birthday))
|
||||||
|
{
|
||||||
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||||
|
|
||||||
|
print '<td>'.$langs->trans("DateToBirth").'</td><td colspan="3">'.dol_print_date($object->birthday,"day");
|
||||||
|
|
||||||
|
print ' ';
|
||||||
|
//var_dump($birthdatearray);
|
||||||
|
$ageyear=convertSecondToTime($now-$object->birthday,'year')-1970;
|
||||||
|
$agemonth=convertSecondToTime($now-$object->birthday,'month')-1;
|
||||||
|
if ($ageyear >= 2) print '('.$ageyear.' '.$langs->trans("DurationYears").')';
|
||||||
|
else if ($agemonth >= 2) print '('.$agemonth.' '.$langs->trans("DurationMonths").')';
|
||||||
|
else print '('.$agemonth.' '.$langs->trans("DurationMonth").')';
|
||||||
|
|
||||||
|
|
||||||
|
print ' - ';
|
||||||
|
if ($object->birthday_alert) print $langs->trans("BirthdayAlertOn");
|
||||||
|
else print $langs->trans("BirthdayAlertOff");
|
||||||
|
print '</td>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<td>'.$langs->trans("DateToBirth").'</td><td colspan="3">'.$langs->trans("Unknown")."</td>";
|
||||||
|
}
|
||||||
|
print "</tr>";
|
||||||
|
|
||||||
|
print "</table>";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
dol_fiche_end();
|
||||||
|
|
||||||
|
if ($action != 'edit')
|
||||||
|
{
|
||||||
|
// Barre d'actions
|
||||||
|
if ($user->societe_id == 0)
|
||||||
|
{
|
||||||
|
print '<div class="tabsAction">';
|
||||||
|
|
||||||
|
if ($user->rights->societe->contact->creer)
|
||||||
|
{
|
||||||
|
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit">'.$langs->trans('Modify').'</a>';
|
||||||
|
}
|
||||||
|
|
||||||
|
print "</div>";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,4 +252,3 @@ if ($action != 'edit')
|
|||||||
llxFooter();
|
llxFooter();
|
||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
?>
|
|
||||||
|
|||||||
@ -35,70 +35,72 @@ $id = GETPOST('id', 'int');
|
|||||||
$result = restrictedArea($user, 'contact', $id, 'socpeople&societe');
|
$result = restrictedArea($user, 'contact', $id, 'socpeople&societe');
|
||||||
|
|
||||||
$contact = new Contact($db);
|
$contact = new Contact($db);
|
||||||
$result=$contact->fetch($id);
|
|
||||||
|
|
||||||
$physicalperson=1;
|
if ($id > 0)
|
||||||
|
|
||||||
$company = new Societe($db);
|
|
||||||
if ($contact->socid)
|
|
||||||
{
|
{
|
||||||
$result=$company->fetch($contact->socid);
|
$result=$contact->fetch($id);
|
||||||
//print "ee";
|
|
||||||
|
$physicalperson=1;
|
||||||
|
|
||||||
|
$company = new Societe($db);
|
||||||
|
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");
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Personal informations
|
||||||
|
$v->setPhoneNumber($contact->phone_perso, "HOME;VOICE");
|
||||||
|
if ($contact->birthday) $v->setBirthday($contact->birthday);
|
||||||
|
|
||||||
|
$db->close();
|
||||||
|
|
||||||
|
|
||||||
|
// Renvoi la VCard au navigateur
|
||||||
|
|
||||||
|
$output = $v->getVCard();
|
||||||
|
|
||||||
|
$filename =trim(urldecode($v->getFileName())); // "Nom prenom.vcf"
|
||||||
|
$filenameurlencoded = dol_sanitizeFileName(urlencode($filename));
|
||||||
|
//$filename = dol_sanitizeFileName($filename);
|
||||||
|
|
||||||
|
|
||||||
|
header("Content-Disposition: attachment; filename=\"".$filename."\"");
|
||||||
|
header("Content-Length: ".dol_strlen($output));
|
||||||
|
header("Connection: close");
|
||||||
|
header("Content-Type: text/x-vcard; name=\"".$filename."\"");
|
||||||
|
|
||||||
|
print $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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");
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Personal informations
|
|
||||||
$v->setPhoneNumber($contact->phone_perso, "HOME;VOICE");
|
|
||||||
if ($contact->birthday) $v->setBirthday($contact->birthday);
|
|
||||||
|
|
||||||
$db->close();
|
|
||||||
|
|
||||||
|
|
||||||
// Renvoi la VCard au navigateur
|
|
||||||
|
|
||||||
$output = $v->getVCard();
|
|
||||||
|
|
||||||
$filename =trim(urldecode($v->getFileName())); // "Nom prenom.vcf"
|
|
||||||
$filenameurlencoded = dol_sanitizeFileName(urlencode($filename));
|
|
||||||
//$filename = dol_sanitizeFileName($filename);
|
|
||||||
|
|
||||||
|
|
||||||
header("Content-Disposition: attachment; filename=\"".$filename."\"");
|
|
||||||
header("Content-Length: ".dol_strlen($output));
|
|
||||||
header("Connection: close");
|
|
||||||
header("Content-Type: text/x-vcard; name=\"".$filename."\"");
|
|
||||||
|
|
||||||
print $output;
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user