28if (empty($object) || !is_object($object)) {
 
   29  print 
"Error, template page can't be called as URL";
 
   33if (empty($preselectedtypeofcontact)) {
 
   34  $preselectedtypeofcontact = 0;
 
   37require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
 
   38require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
 
   40$module = $object->element;
 
   43if ($module == 
'propal') {
 
   44  $permission = $user->rights->propal->creer;
 
   45} elseif ($module == 
'fichinter') {
 
   46  $permission = $user->rights->ficheinter->creer;
 
   47} elseif ($module == 
'order_supplier') {
 
   48  if (empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) {
 
   49    $permission = $user->rights->fournisseur->commande->creer;
 
   51    $permission = $user->rights->supplier_order->creer;
 
   53} elseif ($module == 
'invoice_supplier' && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) {
 
   54  if (empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) {
 
   55    $permission = $user->rights->fournisseur->facture->creer;
 
   57    $permission = $user->rights->supplier_invoice->creer;
 
   59} elseif ($module == 
'project') {
 
   60  $permission = $user->rights->projet->creer;
 
   61} elseif ($module == 
'action') {
 
   62  $permission = $user->hasRight(
'agenda', 
'myactions', 
'create');
 
   63} elseif ($module == 
'shipping') {
 
   64  $permission = $user->rights->expedition->creer;
 
   65} elseif ($module == 
'reception') {
 
   66  $permission = $user->rights->reception->creer;
 
   67} elseif ($module == 
'project_task') {
 
   68  $permission = $user->rights->projet->creer;
 
   69} elseif (!isset($permission) && isset($user->rights->$module->creer)) {
 
   70  $permission = $user->rights->$module->creer;
 
   71} elseif (!isset($permission) && isset($user->rights->$module->write)) {
 
   72  $permission = $user->rights->$module->write;
 
   76$companystatic = 
new Societe($db);
 
   77$contactstatic = 
new Contact($db);
 
   78$userstatic = 
new User($db);
 
   82<!-- BEGIN PHP TEMPLATE CONTACTS -->
 
   85  print 
'<div class="underbanner clearboth"></div>'.
"\n";
 
   87  print 
'<div class="div-table-responsive-no-min">'.
"\n";
 
   88  print 
'<div class="tagtable tableforcontact centpercent noborder nobordertop allwidth">'.
"\n";
 
   91  <form 
class=
"tagtr liste_titre">
 
   92    <div 
class=
"tagtd liste_titre"><?php echo 
img_object(
'', 
'company', 
'class="optiongrey paddingright"').$langs->trans(
"ThirdParty"); ?></div>
 
   93    <div 
class=
"tagtd liste_titre"><?php echo 
img_picto($langs->trans(
"Users"), 
'user', 
'class="optiongrey paddingright"').$langs->trans(
"Users").
' | '.
img_picto($langs->trans(
"Contacts"), 
'contact', 
'class="optiongrey paddingright"').$langs->trans(
"Contacts"); ?></div>
 
   94    <div 
class=
"tagtd liste_titre"><?php echo $langs->trans(
"ContactType"); ?></div>
 
   95    <div 
class=
"tagtd liste_titre"> </div>
 
   96    <div 
class=
"tagtd liste_titre"> </div>
 
  101  if (empty($hideaddcontactforuser)) {
 
  103  <form 
class=
"tagtr impair nohover" action=
"<?php echo $_SERVER["PHP_SELF
"].'?id='.$object->id; ?>" method=
"POST">
 
  104    <input 
type=
"hidden" name=
"token" value=
"<?php echo newToken(); ?>" />
 
  105    <input 
type=
"hidden" name=
"id" value=
"<?php echo $object->id; ?>" />
 
  106    <input 
type=
"hidden" name=
"action" value=
"addcontact" />
 
  107    <input 
type=
"hidden" name=
"source" value=
"internal" />
 
  108    <?php 
if (!empty($withproject)) {
 
  109      print 
'<input type="hidden" name="withproject" value="'.$withproject.
'">';
 
  112    <div 
class=
"tagtd"><?php echo $conf->global->MAIN_INFO_SOCIETE_NOM; ?></div>
 
  113    <!--  <div 
class=
"nowrap tagtd"><?php echo 
img_object(
'', 
'user').
' '.$langs->trans(
"Users"); ?></div> -->
 
  114    <div 
class=
"tagtd maxwidthonsmartphone"><?php echo 
img_object(
'', 
'user', 
'class="pictofixedwidth"').$form->select_dolusers($user->id, 
'userid', 0, (!empty($userAlreadySelected) ? $userAlreadySelected : null), 0, null, null, 0, 56, 0, 
'', 0, 
'', 
'minwidth100imp widthcentpercentminusxx maxwidth400'); ?></div>
 
  115    <div 
class=
"tagtd maxwidthonsmartphone">
 
  117    $tmpobject = $object;
 
  118    if (($object->element == 
'shipping' || $object->element == 
'reception') && is_object($objectsrc)) {
 
  119      $tmpobject = $objectsrc;
 
  121    $formcompany->selectTypeContact($tmpobject, 
'', 
'type', 
'internal', 
'position', 0, 
'minwidth125imp widthcentpercentminusx maxwidth400');
 
  123    <div 
class=
"tagtd"> </div>
 
  124    <div 
class=
"tagtd center"><input 
type=
"submit" class=
"button small" value=
"<?php echo $langs->trans("Add
"); ?>"></div>
 
  130  if (empty($hideaddcontactforthirdparty)) {
 
  133  <form 
class=
"tagtr pair nohover" action=
"<?php echo $_SERVER["PHP_SELF
"].'?id='.$object->id; ?>" method=
"POST">
 
  134    <input 
type=
"hidden" name=
"token" value=
"<?php echo newToken(); ?>" />
 
  135    <input 
type=
"hidden" name=
"id" value=
"<?php echo $object->id; ?>" />
 
  136    <input 
type=
"hidden" name=
"action" value=
"addcontact" />
 
  137    <input 
type=
"hidden" name=
"source" value=
"external" />
 
  138    <input 
type=
"hidden" name=
"page_y" value=
"" />
 
  139    <?php 
if (!empty($withproject)) {
 
  140      print 
'<input type="hidden" name="withproject" value="'.$withproject.
'">';
 
  143    <div 
class=
"tagtd nowrap noborderbottom">
 
  145      $selectedCompany = GETPOSTISSET(
"newcompany") ? 
GETPOST(
"newcompany", 
'int') : (empty($object->socid) ?  0 : $object->socid);
 
  146      $selectedCompany = $formcompany->selectCompaniesForNewContact($object, 
'id', $selectedCompany, 
'newcompany', 
'', 0, 
'', 
'minwidth300imp maxwidth400 widthcentpercentminusx'); 
 
  149    <div 
class=
"tagtd noborderbottom minwidth500imp">
 
  151      print 
img_object(
'', 
'contact', 
'class="pictofixedwidth"').$form->selectcontacts(($selectedCompany > 0 ? $selectedCompany : -1), 
'', 
'contactid', 3, 
'', 
'', 1, 
'minwidth100imp widthcentpercentminusxx maxwidth400');
 
  152      $nbofcontacts = $form->num;
 
  155      if (!empty($object->socid) && $object->socid > 1 && $user->hasRight(
'societe', 
'creer')) {
 
  156        $newcardbutton .= 
'<a href="'.DOL_URL_ROOT.
'/contact/card.php?socid='.$selectedCompany.
'&action=create&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?id='.$object->id).
'" title="'.$langs->trans(
'NewContact').
'"><span class="fa fa-plus-circle valignmiddle paddingleft"></span></a>';
 
  158      print $newcardbutton;
 
  161    <div 
class=
"tagtd noborderbottom">
 
  163      $tmpobject = $object;
 
  164      if (($object->element == 
'shipping' || $object->element == 
'reception') && is_object($objectsrc)) {
 
  165        $tmpobject = $objectsrc;
 
  167      $formcompany->selectTypeContact($tmpobject, $preselectedtypeofcontact, 
'typecontact', 
'external', 
'position', 0, 
'minwidth125imp widthcentpercentminusx maxwidth400');
 
  170    <div 
class=
"tagtd noborderbottom"> </div>
 
  171    <div 
class=
"tagtd center noborderbottom">
 
  172      <input 
type=
"submit" id=
"add-customer-contact" class=
"button small" value=
"<?php echo $langs->trans("Add
"); ?>"<?php 
if (!$nbofcontacts) {
 
  192foreach (array(
'internal', 
'external') as $source) {
 
  193  if (($object->element == 
'shipping' || $object->element == 
'reception') && is_object($objectsrc)) {
 
  194    $contactlist = $objectsrc->liste_contact(-1, $source);
 
  196    $contactlist = $object->liste_contact(-1, $source);
 
  199  foreach ($contactlist as $contact) {
 
  200    $entry = 
new stdClass();
 
  201    $entry->id   = $contact[
'rowid'];
 
  202    $entry->type = $contact[
'libelle'];
 
  204    $entry->thirdparty_html = 
"";
 
  205    $entry->thirdparty_name = 
"";
 
  206    $entry->contact_html = 
"";
 
  207    $entry->contact_name = 
"";
 
  210    if ($contact[
'source'] == 
'internal') {
 
  211      $entry->nature = $langs->trans(
"User");
 
  212    } elseif ($contact[
'source'] == 
'external') {
 
  213      $entry->nature = $langs->trans(
"ThirdPartyContact");
 
  216    if ($contact[
'socid'] > 0) {
 
  217      $companystatic->fetch($contact[
'socid']);
 
  218      $entry->thirdparty_html = $companystatic->getNomUrl(1);
 
  219      $entry->thirdparty_name = strtolower($companystatic->getFullName($langs));
 
  220    } elseif ($contact[
'socid'] < 0) {
 
  221      $entry->thirdparty_html = $conf->global->MAIN_INFO_SOCIETE_NOM;
 
  222      $entry->thirdparty_name = strtolower($conf->global->MAIN_INFO_SOCIETE_NOM);
 
  225    if ($contact[
'source'] == 
'internal') {
 
  226      $userstatic->fetch($contact[
'id']);
 
  227      $entry->contact_html = $userstatic->getNomUrl(-1, 
'', 0, 0, 0, 0, 
'', 
'valignmiddle');
 
  228      $entry->contact_name = strtolower($userstatic->getFullName($langs));
 
  229    } elseif ($contact[
'source'] == 
'external') {
 
  230      $contactstatic->fetch($contact[
'id']);
 
  231      $entry->contact_html = $contactstatic->getNomUrl(1, 
'', 0, 
'', 0, 0);
 
  232      $entry->contact_name = strtolower($contactstatic->getFullName($langs));
 
  235    if ($contact[
'source'] == 
'internal') {
 
  236      $entry->status = $userstatic->LibStatut($contact[
'statuscontact'], 3);
 
  237    } elseif ($contact[
'source'] == 
'external') {
 
  238      $entry->status = $contactstatic->LibStatut($contact[
'statuscontact'], 3);
 
  246$sortfield = 
GETPOST(
"sortfield", 
"aZ09comma");
 
  247$sortorder = 
GETPOST(
"sortorder", 
'aZ09comma');
 
  250  $sortfield = 
"nature";
 
  260  'rowid'     => array(
'label'=>$langs->trans(
"Id"), 
'checked'=>1),
 
  261  'nature'    => array(
'label'=>$langs->trans(
"NatureOfContact"), 
'checked'=>1),
 
  262  'thirdparty'  => array(
'label'=>$langs->trans(
"ThirdParty"), 
'checked'=>1),
 
  263  'contact'     => array(
'label'=>$langs->trans(
"Users").
' | '.$langs->trans(
"Contacts"), 
'checked'=>1),
 
  264  'type'      => array(
'label'=>$langs->trans(
"ContactType"), 
'checked'=>1),
 
  265  'status'    => array(
'label'=>$langs->trans(
"Status"), 
'checked'=>1),
 
  266  'link'      => array(
'label'=>$langs->trans(
"Link"), 
'checked'=>1),
 
  269$param = 
'id='.$object->id.
'&mainmenu=home';
 
  274print 
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
 
  275print 
'<input type="hidden" name="token" value="'.newToken().
'">';
 
  276print 
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
 
  277print 
'<input type="hidden" name="action" value="list">';
 
  278print 
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
 
  279print 
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
 
  281print 
'<div class="div-table-responsive-no-min">'.
"\n";
 
  282print 
'<table class="tagtable nobottomiftotal liste">';
 
  284print 
'<tr class="liste_titre">';
 
  285print_liste_field_titre($arrayfields[
'thirdparty'][
'label'], $_SERVER[
"PHP_SELF"], 
"thirdparty_name", 
"", $param, 
"", $sortfield, $sortorder);
 
  286print_liste_field_titre($arrayfields[
'contact'][
'label'], $_SERVER[
"PHP_SELF"], 
"contact_name", 
"", $param, 
"", $sortfield, $sortorder);
 
  287print_liste_field_titre($arrayfields[
'nature'][
'label'], $_SERVER[
"PHP_SELF"], 
"nature", 
"", $param, 
"", $sortfield, $sortorder);
 
  288print_liste_field_titre($arrayfields[
'type'][
'label'], $_SERVER[
"PHP_SELF"], 
"type", 
"", $param, 
"", $sortfield, $sortorder);
 
  289print_liste_field_titre($arrayfields[
'status'][
'label'], $_SERVER[
"PHP_SELF"], 
"statut", 
"", $param, 
"", $sortfield, $sortorder, 
'center ');
 
  290print_liste_field_titre(
'', $_SERVER[
"PHP_SELF"], 
"", 
"", 
"", 
"", $sortfield, $sortorder, 
'center maxwidthsearch ');
 
  293foreach ($list as $entry) {
 
  294  print 
'<tr class="oddeven">';
 
  296  print 
'<td class="tdoverflowmax200">'.$entry->thirdparty_html.
'</td>';
 
  297  print 
'<td class="tdoverflowmax200">'.$entry->contact_html.
'</td>';
 
  298  print 
'<td class="nowrap"><span class="opacitymedium">'.$entry->nature.
'</span></td>';
 
  299  print 
'<td class="tdoverflowmax200">'.$entry->type.
'</td>';
 
  300  print 
'<td class="tdoverflowmax200 center">'.$entry->status.
'</td>';
 
  303    $href = $_SERVER[
"PHP_SELF"];
 
  304    $href .= 
'?id='.((int) $object->id);
 
  305    $href .= 
'&action=deletecontact&token='.newToken();
 
  306    $href .= 
'&lineid='.((int) $entry->id);
 
  308    print 
'<td class="center">';
 
  309    print 
'<a href="'.$href.
'">';
 
  310    print 
img_picto($langs->trans(
"Unlink"), 
"unlink");
 
  318  $colspan = 5 + ($permission ? 1 : 0);
 
  319  print 
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">';
 
  320  if (is_object($object) && !empty($object->thirdparty)) {
 
  321    print $form->textwithpicto($langs->trans(
"NoSpecificContactAddress"), $langs->trans(
"NoSpecificContactAddressBis"));
 
  323    print $langs->trans(
"NoSpecificContactAddress");
 
  333print 
"<!-- TEMPLATE CONTACTS HOOK BEGIN HERE -->\n";
 
  334if (is_object($hookmanager)) {
 
  335  $hookmanager->initHooks(array(
'contacttpl'));
 
  336  $parameters = array();
 
  337  $reshook = $hookmanager->executeHooks(
'formContactTpl', $parameters, $object, $action);
 
  339print 
"<!-- END PHP TEMPLATE CONTACTS -->\n";
 
Class to manage third parties objects (customers, suppliers, prospects...)
 
Class to manage Dolibarr users.
 
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
 
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
 
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
 
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
 
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
 
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
 
$conf db name
Only used if Module[ID]Name translation string is not found.