dolibarr 24.0.0-beta
calendar_contact.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2023 Alice Adminson <aadminson@example.com>
4 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
26// Load Dolibarr environment
27require '../main.inc.php';
37require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
38require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
39require_once DOL_DOCUMENT_ROOT.'/bookcal/class/calendar.class.php';
40require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_calendar.lib.php';
41
42// Load translation files required by the page
43$langs->loadLangs(array("agenda", "companies", "other", "mails"));
44
45$id = (GETPOST('id') ? GETPOSTINT('id') : GETPOSTINT('facid')); // For backward compatibility
46$ref = GETPOST('ref', 'alpha');
47$lineid = GETPOSTINT('lineid');
48$socid = GETPOSTINT('socid');
49$action = GETPOST('action', 'aZ09');
50
51// Initialize a technical objects
52$object = new Calendar($db);
53$diroutputmassaction = $conf->bookcal->dir_output.'/temp/massgeneration/'.$user->id;
54$hookmanager->initHooks(array('calendarcontact', 'globalcard')); // Note that conf->hooks_modules contains array
55// Fetch optionals attributes and labels
56$extrafields->fetch_name_optionals_label($object->table_element);
57
58// Load object
59include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'. Include fetch and fetch_thirdparty but not fetch_optionals
60
61// There is several ways to check permission.
62// Set $enablepermissioncheck to 1 to enable a minimum low level of checks
63$enablepermissioncheck = 0;
64if ($enablepermissioncheck) {
65 $permissiontoread = $user->hasRight('bookcal', 'calendar', 'read');
66 $permission = $user->hasRight('bookcal', 'calendar', 'write');
67} else {
68 $permissiontoread = 1;
69 $permission = 1;
70}
71
72// Security check (enable the most restrictive one)
73//if ($user->socid > 0) accessforbidden();
74//if ($user->socid > 0) $socid = $user->socid;
75//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
76//restrictedArea($user, $object->module, $object->id, $object->table_element, $object->element, 'fk_soc', 'rowid', $isdraft);
77if (!isModEnabled("bookcal")) {
79}
80if (!$permissiontoread) {
82}
83
84
85/*
86 * Add a new contact
87 */
88
89if ($action == 'addcontact' && $permission) {
90 $contactid = (GETPOST('userid') ? GETPOSTINT('userid') : GETPOSTINT('contactid'));
91 $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
92 $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
93
94 if ($result >= 0) {
95 header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
96 exit;
97 } else {
98 if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
99 $langs->load("errors");
100 setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
101 } else {
102 setEventMessages($object->error, $object->errors, 'errors');
103 }
104 }
105} elseif ($action == 'swapstatut' && $permission) {
106 // Toggle the status of a contact
107 $result = $object->swapContactStatus(GETPOSTINT('ligne'));
108} elseif ($action == 'deletecontact' && $permission) {
109 // Deletes a contact
110 $result = $object->delete_contact($lineid);
111
112 if ($result >= 0) {
113 header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
114 exit;
115 } else {
117 }
118}
119
120
121/*
122 * View
123 */
124
125$title = $langs->trans('Calendar')." - ".$langs->trans('ContactsAddresses');
126$help_url = '';
127//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
128llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-bookcal page-card_calendar_contact');
129
130$form = new Form($db);
131$formcompany = new FormCompany($db);
132$contactstatic = new Contact($db);
133$userstatic = new User($db);
134
135
136/* *************************************************************************** */
137/* */
138/* View and edit mode */
139/* */
140/* *************************************************************************** */
141
142if ($object->id) {
143 /*
144 * Show tabs
145 */
146 $head = calendarPrepareHead($object);
147
148 print dol_get_fiche_head($head, 'contact', $langs->trans("Calendar"), -1, $object->picto);
149
150 $linkback = '<a href="'.dol_buildpath('/bookcal/calendar_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
151
152 $morehtmlref = '<div class="refidno">';
153 /*
154 // Ref customer
155 $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
156 $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
157 // Thirdparty
158 $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
159 // Project
160 if (isModEnabled('project')) {
161 $langs->load("projects");
162 $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
163 if ($permissiontoadd)
164 {
165 if ($action != 'classify')
166 //$morehtmlref.='<a class="editfielda" href="' . dolBuildUrl($_SERVER['PHP_SELF'], ['action' => 'classify', 'id' => $object->id], true) . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
167 $morehtmlref.=' : ';
168 if ($action == 'classify') {
169 //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
170 $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
171 $morehtmlref.='<input type="hidden" name="action" value="classin">';
172 $morehtmlref.='<input type="hidden" name="token" value="'.newToken().'">';
173 $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
174 $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
175 $morehtmlref.='</form>';
176 } else {
177 $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
178 }
179 } else {
180 if (!empty($object->fk_project)) {
181 $proj = new Project($db);
182 $proj->fetch($object->fk_project);
183 $morehtmlref .= ': '.$proj->getNomUrl();
184 } else {
185 $morehtmlref .= '';
186 }
187 }
188 }*/
189 $morehtmlref .= '</div>';
190
191 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
192
193 print dol_get_fiche_end();
194
195 print '<br>';
196
197 // Contacts lines (modules that overwrite templates must declare this into descriptor)
198 $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl'));
199 foreach ($dirtpls as $reldir) {
200 $file = dol_buildpath($reldir.'/contacts.tpl.php');
201 if (file_exists($file)) {
202 $res = @include $file;
203 if ($res) {
204 break;
205 }
206 }
207 }
208}
209
210// End of page
211llxFooter();
212$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
calendarPrepareHead($object)
Prepare array of tabs for Calendar.
Class for Calendar.
Class to manage contact/addresses.
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.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
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.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
isModEnabled($module)
Is Dolibarr module enabled.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.