27 if (empty($object) || !is_object($object))
29 print "Error, template page can't be called as URL";
33 if (empty($preselectedtypeofcontact)) {
34 $preselectedtypeofcontact = 0;
37 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
40 $module = $object->element;
43 if ($module ==
'propal') {
44 $permission = $user->rights->propale->creer;
45 } elseif ($module ==
'fichinter') {
46 $permission = $user->rights->ficheinter->creer;
47 } elseif ($module ==
'order_supplier') {
48 $permission = $user->rights->fournisseur->commande->creer;
49 } elseif ($module ==
'invoice_supplier') {
50 $permission = $user->rights->fournisseur->facture->creer;
51 } elseif ($module ==
'project') {
52 $permission = $user->rights->projet->creer;
53 } elseif ($module ==
'action') {
54 $permission = $user->rights->agenda->myactions->create;
55 } elseif ($module ==
'shipping') {
56 $permission = $user->rights->expedition->creer;
57 } elseif ($module ==
'reception') {
58 $permission = $user->rights->reception->creer;
59 } elseif ($module ==
'project_task') {
60 $permission = $user->rights->projet->creer;
61 } elseif (!isset($permission) && isset($user->rights->$module->creer)) {
62 $permission = $user->rights->$module->creer;
63 } elseif (!isset($permission) && isset($user->rights->$module->write)) {
64 $permission = $user->rights->$module->write;
68 $companystatic =
new Societe($db);
69 $contactstatic =
new Contact($db);
70 $userstatic =
new User($db);
74 <!-- BEGIN PHP TEMPLATE CONTACTS -->
78 print '<div class="underbanner clearboth"></div>'.
"\n";
80 print '<div class="div-table-responsive-no-min">'.
"\n";
81 print '<div class="tagtable tableforcontact centpercent noborder nobordertop allwidth">'.
"\n";
84 <form
class=
"tagtr liste_titre">
85 <div
class=
"tagtd liste_titre"><?php echo $langs->trans(
"NatureOfContact"); ?></div>
86 <div
class=
"tagtd liste_titre"><?php echo $langs->trans(
"ThirdParty"); ?></div>
87 <div
class=
"tagtd liste_titre"><?php echo $langs->trans(
"Users").
'/'.$langs->trans(
"Contacts"); ?></div>
88 <div
class=
"tagtd liste_titre"><?php echo $langs->trans(
"ContactType"); ?></div>
89 <div
class=
"tagtd liste_titre"> </div>
90 <div
class=
"tagtd liste_titre"> </div>
95 if (empty($hideaddcontactforuser))
98 <form
class=
"tagtr impair nohover" action=
"<?php echo $_SERVER["PHP_SELF
"].'?id='.$object->id; ?>" method=
"POST">
99 <input
type=
"hidden" name=
"token" value=
"<?php echo $_SESSION['newtoken']; ?>" />
100 <input type=
"hidden" name=
"id" value=
"<?php echo $object->id; ?>" />
101 <input type=
"hidden" name=
"action" value=
"addcontact" />
102 <input type=
"hidden" name=
"source" value=
"internal" />
103 <?php
if ($withproject)
print '<input type="hidden" name="withproject" value="'.$withproject.
'">'; ?>
104 <div
class=
"nowrap tagtd"><?php echo
img_object(
'',
'user').
' '.$langs->trans(
"Users"); ?></div>
105 <div
class=
"tagtd"><?php echo $conf->global->MAIN_INFO_SOCIETE_NOM; ?></div>
106 <div
class=
"tagtd maxwidthonsmartphone"><?php echo $form->select_dolusers($user->id,
'userid', 0, (!empty($userAlreadySelected) ? $userAlreadySelected : null), 0, null, null, 0, 56,
'', 0,
'',
'minwidth200imp'); ?></div>
107 <div
class=
"tagtd maxwidthonsmartphone">
109 $tmpobject = $object;
110 if (($object->element ==
'shipping' || $object->element ==
'reception') && is_object($objectsrc)) $tmpobject = $objectsrc;
111 $formcompany->selectTypeContact($tmpobject,
'',
'type',
'internal');
113 <div
class=
"tagtd"> </div>
114 <div
class=
"tagtd center"><input type=
"submit" class=
"button" value=
"<?php echo $langs->trans("Add
"); ?>"></div>
120 if (empty($hideaddcontactforthirdparty)) {
123 <form
class=
"tagtr pair nohover" action=
"<?php echo $_SERVER["PHP_SELF
"].'?id='.$object->id; ?>" method=
"POST">
124 <input type=
"hidden" name=
"token" value=
"<?php echo $_SESSION['newtoken']; ?>" />
125 <input type=
"hidden" name=
"id" value=
"<?php echo $object->id; ?>" />
126 <input type=
"hidden" name=
"action" value=
"addcontact" />
127 <input type=
"hidden" name=
"source" value=
"external" />
128 <?php
if ($withproject)
print '<input type="hidden" name="withproject" value="'.$withproject.
'">'; ?>
129 <div
class=
"tagtd nowrap noborderbottom"><?php echo
img_object(
'',
'contact').
' '.$langs->trans(
"ThirdPartyContacts"); ?></div>
130 <div
class=
"tagtd nowrap maxwidthonsmartphone noborderbottom">
131 <?php $selectedCompany = isset($_GET[
"newcompany"]) ? $_GET[
"newcompany"] : $object->socid; ?>
134 if ($selectedCompany)
136 echo
img_object(
'',
'company',
'class="hideonsmartphone"');
139 <?php $selectedCompany = $formcompany->selectCompaniesForNewContact($object,
'id', $selectedCompany,
'newcompany',
'', 0,
'',
'minwidth300imp'); ?>
141 <div
class=
"tagtd maxwidthonsmartphone noborderbottom">
143 print $form->selectcontacts(($selectedCompany > 0 ? $selectedCompany : -1),
'',
'contactid', 3,
'',
'', 1,
'minwidth100imp');
144 $nbofcontacts = $form->num;
147 if (!empty($object->socid) && $object->socid > 1 && $user->rights->societe->creer)
149 $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>';
151 print $newcardbutton;
154 <div
class=
"tagtd maxwidthonsmartphone noborderbottom">
156 $tmpobject = $object;
157 if (($object->element ==
'shipping' || $object->element ==
'reception') && is_object($objectsrc)) $tmpobject = $objectsrc;
158 $formcompany->selectTypeContact($tmpobject, $preselectedtypeofcontact,
'typecontact',
'external',
'position', 0,
'minwidth100imp');
161 <div
class=
"tagtd noborderbottom"> </div>
162 <div
class=
"tagtd center noborderbottom">
163 <input type=
"submit" id=
"add-customer-contact" class=
"button" value=
"<?php echo $langs->trans("Add
"); ?>"<?php
if (!$nbofcontacts) echo
' disabled'; ?>>
181 foreach (array(
'internal',
'external') as $source)
183 if (($object->element ==
'shipping' || $object->element ==
'reception') && is_object($objectsrc))
185 $contactlist = $objectsrc->liste_contact(-1, $source);
187 $contactlist = $object->liste_contact(-1, $source);
190 foreach ($contactlist as $contact)
192 $entry =
new stdClass();
193 $entry->id = $contact[
'rowid'];
194 $entry->type = $contact[
'libelle'];
196 $entry->thirdparty_html =
"";
197 $entry->thirdparty_name =
"";
198 $entry->contact_html =
"";
199 $entry->contact_name =
"";
202 if ($contact[
'source'] ==
'internal')
204 $entry->nature = $langs->trans(
"User");
205 } elseif ($contact[
'source'] ==
'external') {
206 $entry->nature = $langs->trans(
"ThirdPartyContact");
209 if ($contact[
'socid'] > 0)
211 $companystatic->fetch($contact[
'socid']);
212 $entry->thirdparty_html = $companystatic->getNomUrl(1);
213 $entry->thirdparty_name = strtolower($companystatic->getFullName($langs));
214 } elseif ($contact[
'socid'] < 0) {
215 $entry->thirdparty_html = $conf->global->MAIN_INFO_SOCIETE_NOM;
216 $entry->thirdparty_name = strtolower($conf->global->MAIN_INFO_SOCIETE_NOM);
219 if ($contact[
'source'] ==
'internal')
221 $userstatic->fetch($contact[
'id']);
222 $entry->contact_html = $userstatic->getNomUrl(-1,
'', 0, 0, 0, 0,
'',
'valignmiddle');
223 $entry->contact_name = strtolower($userstatic->getFullName($langs));
224 } elseif ($contact[
'source'] ==
'external') {
225 $contactstatic->fetch($contact[
'id']);
226 $entry->contact_html = $contactstatic->getNomUrl(1,
'', 0,
'', 0, 0);
227 $entry->contact_name = strtolower($contactstatic->getFullName($langs));
230 if ($contact[
'source'] ==
'internal')
232 $entry->status = $userstatic->LibStatut($contact[
'statuscontact'], 3);
233 } elseif ($contact[
'source'] ==
'external') {
234 $entry->status = $contactstatic->LibStatut($contact[
'statuscontact'], 3);
242 $sortfield =
GETPOST(
"sortfield",
"aZ09comma");
243 $sortorder =
GETPOST(
"sortorder",
'aZ09comma');
245 if (!$sortfield) $sortfield =
"nature";
246 if (!$sortorder) $sortorder =
"asc";
251 $arrayfields = array(
252 'rowid' => array(
'label'=>$langs->trans(
"Id"),
'checked'=>1),
253 'nature' => array(
'label'=>$langs->trans(
"NatureOfContact"),
'checked'=>1),
254 'thirdparty' => array(
'label'=>$langs->trans(
"ThirdParty"),
'checked'=>1),
255 'contact' => array(
'label'=>$langs->trans(
"Users").
'/'.$langs->trans(
"Contacts"),
'checked'=>1),
256 'type' => array(
'label'=>$langs->trans(
"ContactType"),
'checked'=>1),
257 'status' => array(
'label'=>$langs->trans(
"Status"),
'checked'=>1),
258 'link' => array(
'label'=>$langs->trans(
"Link"),
'checked'=>1),
261 $param =
'id='.$object->id.
'&mainmenu=home';
266 print '<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
267 print '<input type="hidden" name="token" value="'.newToken().
'">';
268 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
269 print '<input type="hidden" name="action" value="list">';
270 print '<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
271 print '<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
273 print '<div class="div-table-responsive-no-min">'.
"\n";
274 print '<table class="tagtable nobottomiftotal liste">';
279 print '<tr class="liste_titre">';
288 foreach ($list as $entry)
290 print '<tr class="oddeven">';
292 print '<td class="nowrap">'.$entry->nature.
'</td>';
293 print '<td class="tdoverflowmax200">'.$entry->thirdparty_html.
'</td>';
294 print '<td class="tdoverflowmax200">'.$entry->contact_html.
'</td>';
295 print '<td class="tdoverflowmax200">'.$entry->type.
'</td>';
296 print '<td class="tdoverflowmax200 center">'.$entry->status.
'</td>';
301 $href .=
'?id='.$object->id;
302 $href .=
'&action=deletecontact&token='.newToken();
303 $href .=
'&lineid='.$entry->id;
305 print "<td class='center'>";
306 print "<a href='$href'>";
320 print "<!-- TEMPLATE CONTACTS HOOK BEGIN HERE -->\n";
321 if (is_object($hookmanager)) {
322 $hookmanager->initHooks(array(
'contacttpl'));
323 $parameters = array();
324 $reshook = $hookmanager->executeHooks(
'formContactTpl', $parameters, $object, $action);
326 print "<!-- END PHP TEMPLATE CONTACTS -->\n";
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage Dolibarr users.
$conf db name
Only used if Module[ID]Name translation string is not found.
Class to manage third parties objects (customers, suppliers, prospects...)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
print $_SERVER["PHP_SELF"]
Edit parameters.
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
Draft customers invoices.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type