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 (isset($permissiontoadd) && ! isset($permission)) {
44 $permission = $permissiontoadd;
47if ($module ==
'propal') {
48 $permission = $user->hasRight(
'propal',
'creer');
49} elseif ($module ==
'fichinter') {
50 $permission = $user->hasRight(
'ficheinter',
'creer');
51} elseif ($module ==
'order_supplier') {
53 $permission = $user->hasRight(
'fournisseur',
'commande',
'creer');
55 $permission = $user->hasRight(
'supplier_order',
'creer');
57} elseif ($module ==
'invoice_supplier' && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) {
59 $permission = $user->hasRight(
'fournisseur',
'facture',
'creer');
61 $permission = $user->hasRight(
'supplier_invoice',
'creer');
63} elseif ($module ==
'project') {
64 $permission = $user->hasRight(
'projet',
'creer');
65} elseif ($module ==
'action') {
66 $permission = $user->hasRight(
'agenda',
'myactions',
'create');
67} elseif ($module ==
'shipping') {
68 $permission = $user->hasRight(
'expedition',
'creer');
69} elseif ($module ==
'reception') {
70 $permission = $user->hasRight(
'reception',
'creer');
71} elseif ($module ==
'project_task') {
72 $permission = $user->hasRight(
'projet',
'creer');
73} elseif (!isset($permission) && $user->hasRight($module,
'creer')) {
74 $permission = $user->hasRight($module,
'creer');
75} elseif (!isset($permission) && $user->hasRight($module,
'write')) {
76 $permission = $user->hasRight($module,
'write');
80$companystatic =
new Societe($db);
81$contactstatic =
new Contact($db);
82$userstatic =
new User($db);
86<!-- BEGIN PHP TEMPLATE CONTACTS -->
89 print
'<div class="underbanner clearboth"></div>'.
"\n";
91 print
'<div class="div-table-responsive-no-min">'.
"\n";
92 print
'<div class="tagtable tableforcontact centpercent noborder nobordertop allwidth">'.
"\n"; ?>
93 <form
class=
"tagtr liste_titre">
94 <div
class=
"tagtd liste_titre"><?php echo
img_object(
'',
'company',
'class="optiongrey paddingright"').$langs->trans(
"ThirdParty"); ?></div>
95 <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>
96 <div
class=
"tagtd liste_titre"><?php echo $langs->trans(
"ContactType"); ?></div>
97 <div
class=
"tagtd liste_titre"> </div>
98 <div
class=
"tagtd liste_titre"> </div>
103 if (empty($hideaddcontactforuser)) {
105 <form
class=
"tagtr impair nohover" action=
"<?php echo $_SERVER["PHP_SELF
"].'?id='.$object->id; ?>" method=
"POST">
106 <input
type=
"hidden" name=
"token" value=
"<?php echo newToken(); ?>" />
107 <input
type=
"hidden" name=
"id" value=
"<?php echo $object->id; ?>" />
108 <input
type=
"hidden" name=
"action" value=
"addcontact" />
109 <input
type=
"hidden" name=
"source" value=
"internal" />
110 <?php
if (!empty($withproject)) {
111 print
'<input type="hidden" name="withproject" value="'.$withproject.
'">';
114 <div
class=
"tagtd"><?php echo $conf->global->MAIN_INFO_SOCIETE_NOM; ?></div>
115 <!-- <div
class=
"nowrap tagtd"><?php echo
img_object(
'',
'user').
' '.$langs->trans(
"Users"); ?></div> -->
116 <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>
117 <div
class=
"tagtd maxwidthonsmartphone">
119 $tmpobject = $object;
120 if (($object->element ==
'shipping' || $object->element ==
'reception') && is_object($objectsrc)) {
121 $tmpobject = $objectsrc;
123 $formcompany->selectTypeContact($tmpobject,
'',
'type',
'internal',
'position', 0,
'minwidth125imp widthcentpercentminusx maxwidth400'); ?></div>
124 <div
class=
"tagtd"> </div>
125 <div
class=
"tagtd center"><input
type=
"submit" class=
"button small" value=
"<?php echo $langs->trans("Add
"); ?>"></div>
131 if (empty($hideaddcontactforthirdparty)) {
134 <form
class=
"tagtr pair nohover" action=
"<?php echo $_SERVER["PHP_SELF
"].'?id='.$object->id; ?>" method=
"POST">
135 <input
type=
"hidden" name=
"token" value=
"<?php echo newToken(); ?>" />
136 <input
type=
"hidden" name=
"id" value=
"<?php echo $object->id; ?>" />
137 <input
type=
"hidden" name=
"action" value=
"addcontact" />
138 <input
type=
"hidden" name=
"source" value=
"external" />
139 <input
type=
"hidden" name=
"page_y" value=
"" />
140 <?php
if (!empty($withproject)) {
141 print
'<input type="hidden" name="withproject" value="'.$withproject.
'">';
144 <div
class=
"tagtd nowrap noborderbottom">
146 $selectedCompany = GETPOSTISSET(
"newcompany") ?
GETPOST(
"newcompany",
'int') : (empty($object->socid) ? 0 : $object->socid);
147 $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; ?>
160 <div
class=
"tagtd noborderbottom">
162 $tmpobject = $object;
163 if (($object->element ==
'shipping' || $object->element ==
'reception') && is_object($objectsrc)) {
164 $tmpobject = $objectsrc;
166 $formcompany->selectTypeContact($tmpobject, $preselectedtypeofcontact,
'typecontact',
'external',
'position', 0,
'minwidth125imp widthcentpercentminusx maxwidth400'); ?>
168 <div
class=
"tagtd noborderbottom"> </div>
169 <div
class=
"tagtd center noborderbottom">
170 <input
type=
"submit" id=
"add-customer-contact" class=
"button small" value=
"<?php echo $langs->trans("Add
"); ?>"<?php
if (!$nbofcontacts) {
190foreach (array(
'internal',
'external') as $source) {
191 if (($object->element ==
'shipping' || $object->element ==
'reception') && is_object($objectsrc)) {
192 $contactlist = $objectsrc->liste_contact(-1, $source);
194 $contactlist = $object->liste_contact(-1, $source);
197 foreach ($contactlist as $contact) {
199 $entry->id = $contact[
'rowid'];
200 $entry->type_id = $contact[
'fk_c_type_contact'];
201 $entry->type = $contact[
'libelle'];
203 $entry->nature_html =
"";
204 $entry->thirdparty_id = 0;
205 $entry->thirdparty_html =
"";
206 $entry->thirdparty_name =
"";
207 $entry->contact_html =
"";
208 $entry->contact_name =
"";
210 $entry->status_html =
"";
212 if ($contact[
'source'] ==
'internal') {
213 $entry->nature =
'user';
214 $entry->nature_html = $langs->trans(
"User");
215 } elseif ($contact[
'source'] ==
'external') {
216 $entry->nature =
'thirdparty';
217 $entry->nature_html = $langs->trans(
"ThirdPartyContact");
220 if ($contact[
'socid'] > 0) {
221 $companystatic->fetch($contact[
'socid']);
222 $entry->thirdparty_id = $companystatic->id;
223 $entry->thirdparty_html = $companystatic->getNomUrl(1);
224 $entry->thirdparty_name = strtolower($companystatic->getFullName($langs));
225 } elseif ($contact[
'socid'] < 0) {
226 $entry->thirdparty_html = $conf->global->MAIN_INFO_SOCIETE_NOM;
227 $entry->thirdparty_name = strtolower($conf->global->MAIN_INFO_SOCIETE_NOM);
230 if ($contact[
'source'] ==
'internal') {
231 $userstatic->fetch($contact[
'id']);
232 $entry->contact_id = $userstatic->id;
233 $entry->contact_html = $userstatic->getNomUrl(-1,
'', 0, 0, 0, 0,
'',
'valignmiddle');
234 $entry->contact_name = strtolower($userstatic->getFullName($langs));
235 } elseif ($contact[
'source'] ==
'external') {
236 $contactstatic->fetch($contact[
'id']);
237 $entry->contact_id = $contactstatic->id;
238 $entry->contact_html = $contactstatic->getNomUrl(1,
'', 0,
'', 0, 0);
239 $entry->contact_name = strtolower($contactstatic->getFullName($langs));
242 if ($contact[
'source'] ==
'internal') {
243 $entry->status = $contact[
'statuscontact'];
244 $entry->status_html = $userstatic->LibStatut($contact[
'statuscontact'], 3);
245 } elseif ($contact[
'source'] ==
'external') {
246 $entry->status = $contact[
'statuscontact'];
247 $entry->status_html = $contactstatic->LibStatut($contact[
'statuscontact'], 3);
255$sortfield =
GETPOST(
"sortfield",
"aZ09comma");
256$sortorder =
GETPOST(
"sortorder",
'aZ09comma');
259 $sortfield =
"nature";
269 'rowid' => array(
'label'=>$langs->trans(
"Id"),
'checked'=>1),
270 'nature' => array(
'label'=>$langs->trans(
"NatureOfContact"),
'checked'=>1),
271 'thirdparty' => array(
'label'=>$langs->trans(
"ThirdParty"),
'checked'=>1),
272 'contact' => array(
'label'=>$langs->trans(
"Users").
' | '.$langs->trans(
"Contacts"),
'checked'=>1),
273 'type' => array(
'label'=>$langs->trans(
"ContactType"),
'checked'=>1),
274 'status' => array(
'label'=>$langs->trans(
"Status"),
'checked'=>1),
275 'link' => array(
'label'=>$langs->trans(
"Link"),
'checked'=>1),
278$param =
'id='.$object->id.
'&mainmenu=home';
283print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
284print
'<input type="hidden" name="token" value="'.newToken().
'">';
285print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
286print
'<input type="hidden" name="action" value="list">';
287print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
288print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
290print
'<div class="div-table-responsive-no-min">'.
"\n";
291print
'<table class="tagtable nobottomiftotal liste">';
293print
'<tr class="liste_titre">';
294print_liste_field_titre($arrayfields[
'thirdparty'][
'label'], $_SERVER[
"PHP_SELF"],
"thirdparty_name",
"", $param,
"", $sortfield, $sortorder);
295print_liste_field_titre($arrayfields[
'contact'][
'label'], $_SERVER[
"PHP_SELF"],
"contact_name",
"", $param,
"", $sortfield, $sortorder);
296print_liste_field_titre($arrayfields[
'nature'][
'label'], $_SERVER[
"PHP_SELF"],
"nature",
"", $param,
"", $sortfield, $sortorder);
297print_liste_field_titre($arrayfields[
'type'][
'label'], $_SERVER[
"PHP_SELF"],
"type",
"", $param,
"", $sortfield, $sortorder);
298print_liste_field_titre($arrayfields[
'status'][
'label'], $_SERVER[
"PHP_SELF"],
"statut",
"", $param,
"", $sortfield, $sortorder,
'center ');
300 print_liste_field_titre(
'', $_SERVER[
"PHP_SELF"],
"",
"",
"",
"", $sortfield, $sortorder,
'center maxwidthsearch ');
304foreach ($list as $entry) {
305 print
'<tr class="oddeven" data-rowid="' . $entry->id .
'">';
307 print
'<td class="tdoverflowmax200" data-thirdparty_id="' . ((int) $entry->thirdparty_id) .
'" data-thirdparty_name="' .
dol_escape_htmltag($entry->thirdparty_name) .
'">'.$entry->thirdparty_html.
'</td>';
308 print
'<td class="tdoverflowmax200" data-contact_id="' . ((int) $entry->contact_id) .
'">'.$entry->contact_html.
'</td>';
309 print
'<td class="nowrap" data-nature="' .
dol_escape_htmltag($entry->nature) .
'"><span class="opacitymedium">'.dol_escape_htmltag($entry->nature_html).
'</span></td>';
310 print
'<td class="tdoverflowmax200" data-type_id="' . ((int) $entry->type_id) .
'" data-type="' .
dol_escape_htmltag($entry->type) .
'">'.dol_escape_htmltag($entry->type).
'</td>';
311 print
'<td class="tdoverflowmax200 center" data-status_id="' . ((int) $entry->status) .
'">'.$entry->status_html.
'</td>';
314 $href = $_SERVER[
"PHP_SELF"];
315 $href .=
'?id='.((int) $object->id);
316 $href .=
'&action=deletecontact&token='.newToken();
317 $href .=
'&lineid='.((int) $entry->id);
319 print
'<td class="center">';
320 print
'<a href="'.$href.
'">';
321 print
img_picto($langs->trans(
"Unlink"),
"unlink");
329 $colspan = 5 + ($permission ? 1 : 0);
330 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">';
331 if (is_object($object) && !empty($object->thirdparty)) {
332 print $form->textwithpicto($langs->trans(
"NoSpecificContactAddress"), $langs->trans(
"NoSpecificContactAddressBis"));
334 print $langs->trans(
"NoSpecificContactAddress");
344print
"<!-- TEMPLATE CONTACTS HOOK BEGIN HERE -->\n";
345if (is_object($hookmanager)) {
346 $hookmanager->initHooks(array(
'contacttpl'));
347 $parameters = array();
348 $reshook = $hookmanager->executeHooks(
'formContactTpl', $parameters, $object, $action);
350print
"<!-- 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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
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.