dolibarr 19.0.4
contact.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
3 * Copyright (C) 2007-2009 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
5 * Copyright (C) 2016 Gilles Poirier <glgpoirier@gmail.com>
6 *
7 */
8
30// Load Dolibarr environment
31require '../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php';
33require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
34require_once DOL_DOCUMENT_ROOT.'/core/lib/resource.lib.php';
35require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
36
37// Load translation files required by the page
38$langs->loadLangs(array('companies', 'resource', 'sendings'));
39
40$id = GETPOST('id', 'int');
41$ref = GETPOST('ref', 'alpha');
42$action = GETPOST('action', 'aZ09');
43
44$object = new Dolresource($db);
45
46// Load object
47include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once
48
49// Security check
50if ($user->socid) {
51 $socid = $user->socid;
52}
53$result = restrictedArea($user, 'resource', $object->id, 'resource');
54
55// Security check
56if (!$user->hasRight('resource', 'read')) {
58}
59
60
61
62/*
63 * Actions
64 */
65
66// Add a new contact
67if ($action == 'addcontact' && $user->hasRight('resource', 'write')) {
68 if ($result > 0 && $id > 0) {
69 $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
70 $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
71 $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
72 }
73
74 if ($result >= 0) {
75 header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
76 exit;
77 } else {
78 if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
79 $langs->load("errors");
80 $mesg = $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType");
81 } else {
82 $mesg = $object->error;
83 }
84
85 setEventMessages($mesg, null, 'errors');
86 }
87} elseif ($action == 'swapstatut' && $user->hasRight('resource', 'write')) {
88 // Toggle the status of a contact
89 $result = $object->swapContactStatus(GETPOST('ligne', 'int'));
90} elseif ($action == 'deletecontact' && $user->hasRight('resource', 'write')) {
91 // Erase a contact
92 $result = $object->delete_contact(GETPOST('lineid', 'int'));
93
94 if ($result >= 0) {
95 header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
96 exit;
97 } else {
98 dol_print_error($db);
99 }
100}
101
102
103/*
104 * View
105 */
106
107$form = new Form($db);
108$formcompany = new FormCompany($db);
109$contactstatic = new Contact($db);
110$userstatic = new User($db);
111
112llxHeader('', $langs->trans("Resource"));
113
114// View and edit mode
115
116if ($id > 0 || !empty($ref)) {
117 $head = resource_prepare_head($object);
118 print dol_get_fiche_head($head, 'contact', $langs->trans("ResourceSingular"), -1, 'resource');
119
120
121 $linkback = '<a href="'.DOL_URL_ROOT.'/resource/list.php'.(!empty($socid) ? '?id='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
122
123
124 $morehtmlref = '<div class="refidno">';
125 $morehtmlref .= '</div>';
126
127
128 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
129
130
131 print '<div class="fichecenter">';
132 print '<div class="underbanner clearboth"></div>';
133
134
135 // Object
136
137 print '<table class="border tableforfield centpercent">';
138
139 // Resource type
140 print '<tr>';
141 print '<td class="titlefield">'.$langs->trans("ResourceType").'</td>';
142 print '<td>';
143 print $object->type_label;
144 print '</td>';
145 print '</tr>';
146
147 print '</table>';
148 print '</div>';
149
150 print dol_get_fiche_end();
151
152 print '<br>';
153
154 if (getDolGlobalString('RESOURCE_HIDE_ADD_CONTACT_USER')) {
155 $hideaddcontactforuser = 1;
156 }
157 if (getDolGlobalString('RESOURCE_HIDE_ADD_CONTACT_THIPARTY')) {
158 $hideaddcontactforthirdparty = 1;
159 }
160
161 $permission = 1;
162 // Contacts lines
163 include DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php';
164}
165
166// End of page
167llxFooter();
168$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
DAO Resource object.
Class to build HTML component for third parties management Only common components are here.
Class to manage generation of HTML components Only common components must be here.
Class to manage Dolibarr users.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
resource_prepare_head($object)
Prepare head for tabs.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
Contact()
Old copy.
Definition index.php:572