dolibarr 24.0.0-beta
availabilities_contact.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2007-2024 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
25// Load Dolibarr environment
26require '../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
36require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
37require_once DOL_DOCUMENT_ROOT.'/bookcal/class/availabilities.class.php';
38require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_availabilities.lib.php';
39
40// Load translation files required by the page
41$langs->loadLangs(array("agenda", "companies", "other", "mails"));
42
43$id = (GETPOST('id') ? GETPOSTINT('id') : GETPOSTINT('facid')); // For backward compatibility
44$ref = GETPOST('ref', 'alpha');
45$lineid = GETPOSTINT('lineid');
46$socid = GETPOSTINT('socid');
47$action = GETPOST('action', 'aZ09');
48
49// Initialize a technical objects
51$diroutputmassaction = $conf->bookcal->dir_output.'/temp/massgeneration/'.$user->id;
52$hookmanager->initHooks(array('availabilitiescontact', 'globalcard')); // Note that conf->hooks_modules contains array
53// Fetch optionals attributes and labels
54$extrafields->fetch_name_optionals_label($object->table_element);
55
56// Load object
57include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'. Include fetch and fetch_thirdparty but not fetch_optionals
58
59$permissiontoread = $user->hasRight('bookcal', 'availabilities', 'read');
60$permission = $user->hasRight('bookcal', 'availabilities', 'write');
61
62// Security check (enable the most restrictive one)
63//if ($user->socid > 0) accessforbidden();
64//if ($user->socid > 0) $socid = $user->socid;
65//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
66//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
67if (!isModEnabled('bookcal')) {
69}
70if (!$permissiontoread) {
72}
73
74
75/*
76 * Add a new contact
77 */
78
79if ($action == 'addcontact' && $permission) {
80 $contactid = (GETPOST('userid') ? GETPOSTINT('userid') : GETPOSTINT('contactid'));
81 $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
82 $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
83
84 if ($result >= 0) {
85 header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
86 exit;
87 } else {
88 if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
89 $langs->load("errors");
90 setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
91 } else {
92 setEventMessages($object->error, $object->errors, 'errors');
93 }
94 }
95} elseif ($action == 'swapstatut' && $permission) {
96 // Toggle the status of a contact
97 $result = $object->swapContactStatus(GETPOSTINT('ligne'));
98} elseif ($action == 'deletecontact' && $permission) {
99 // Deletes a contact
100 $result = $object->delete_contact($lineid);
101
102 if ($result >= 0) {
103 header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
104 exit;
105 } else {
107 }
108}
109
110
111/*
112 * View
113 */
114
115$title = $langs->trans('Availabilities')." - ".$langs->trans('ContactsAddresses');
116$help_url = '';
117//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
118llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-bookcal page-card_availabilities_contact');
119
120$form = new Form($db);
121$formcompany = new FormCompany($db);
122$contactstatic = new Contact($db);
123$userstatic = new User($db);
124
125
126/* *************************************************************************** */
127/* */
128/* View and edit mode */
129/* */
130/* *************************************************************************** */
131
132if ($object->id) {
133 /*
134 * Show tabs
135 */
136 $head = availabilitiesPrepareHead($object);
137
138 print dol_get_fiche_head($head, 'contact', $langs->trans("Availabilities"), -1, $object->picto);
139
140 $linkback = '<a href="'.dol_buildpath('/bookcal/availabilities_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
141
142 $morehtmlref = '<div class="refidno">';
143 /*
144 // Ref customer
145 $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
146 $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
147 // Thirdparty
148 $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
149 // Project
150 if (isModEnabled('project'))
151 {
152 $langs->load("projects");
153 $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
154 if ($permissiontoadd)
155 {
156 if ($action != 'classify')
157 //$morehtmlref.='<a class="editfielda" href="' . dolBuildUrl($_SERVER['PHP_SELF'], ['action' => 'classify', 'id' => $object->id], true) . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
158 $morehtmlref.=' : ';
159 if ($action == 'classify') {
160 //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
161 $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
162 $morehtmlref.='<input type="hidden" name="action" value="classin">';
163 $morehtmlref.='<input type="hidden" name="token" value="'.newToken().'">';
164 $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
165 $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
166 $morehtmlref.='</form>';
167 } else {
168 $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
169 }
170 } else {
171 if (! empty($object->fk_project)) {
172 $proj = new Project($db);
173 $proj->fetch($object->fk_project);
174 $morehtmlref .= ': '.$proj->getNomUrl();
175 } else {
176 $morehtmlref .= '';
177 }
178 }
179 }*/
180 $morehtmlref .= '</div>';
181
182 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
183
184 print dol_get_fiche_end();
185
186 print '<br>';
187
188 // Contacts lines (modules that overwrite templates must declare this into descriptor)
189 $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl'));
190 foreach ($dirtpls as $reldir) {
191 $file = dol_buildpath($reldir.'/contacts.tpl.php');
192 if (file_exists($file)) {
193 $res = @include $file;
194 if ($res) {
195 break;
196 }
197 }
198 }
199}
200
201// End of page
202llxFooter();
203$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
availabilitiesPrepareHead($object)
Prepare array of tabs for Availabilities.
Class for Availabilities.
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.