dolibarr 19.0.4
knowledgerecord_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) ---Put here your own copyright and developer email---
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';
27
28require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
29require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
30require_once DOL_DOCUMENT_ROOT.'/knowledgemanagement/class/knowledgerecord.class.php';
31require_once DOL_DOCUMENT_ROOT.'/knowledgemanagement/lib/knowledgemanagement_knowledgerecord.lib.php';
32
33// Load translation files required by the page
34$langs->loadLangs(array("knowledgemanagement", "companies", "other", "mails"));
35
36$id = (GETPOST('id') ? GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility
37$ref = GETPOST('ref', 'alpha');
38$lineid = GETPOST('lineid', 'int');
39$socid = GETPOST('socid', 'int');
40$action = GETPOST('action', 'aZ09');
41
42// Initialize technical objects
43$object = new KnowledgeRecord($db);
44$extrafields = new ExtraFields($db);
45$diroutputmassaction = $conf->knowledgemanagement->dir_output.'/temp/massgeneration/'.$user->id;
46$hookmanager->initHooks(array('knowledgerecordcontact', 'globalcard')); // Note that conf->hooks_modules contains array
47// Fetch optionals attributes and labels
48$extrafields->fetch_name_optionals_label($object->table_element);
49
50// Load object
51include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
52
53// Security check - Protection if external user
54//if ($user->socid > 0) accessforbidden();
55//if ($user->socid > 0) $socid = $user->socid;
56$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
57restrictedArea($user, $object->module, $object->id, $object->table_element, $object->element, '', 'rowid', $isdraft);
58
59$permission = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write');
60
61
62/*
63 * Actions
64 */
65
66if ($action == 'addcontact' && $permission) {
67 $contactid = (GETPOST('userid') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
68 $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
69 $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
70
71 if ($result >= 0) {
72 header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
73 exit;
74 } else {
75 if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
76 $langs->load("errors");
77 setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
78 } else {
79 setEventMessages($object->error, $object->errors, 'errors');
80 }
81 }
82} elseif ($action == 'swapstatut' && $permission) {
83 // Toggle the status of a contact
84 $result = $object->swapContactStatus(GETPOST('ligne', 'int'));
85} elseif ($action == 'deletecontact' && $permission) {
86 // Deletes a contact
87 $result = $object->delete_contact($lineid);
88
89 if ($result >= 0) {
90 header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
91 exit;
92 } else {
93 dol_print_error($db);
94 }
95}
96
97
98/*
99 * View
100 */
101
102$title = $langs->trans('KnowledgeRecord')." - ".$langs->trans('ContactsAddresses');
103$help_url = '';
104//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
105llxHeader('', $title, $help_url);
106
107$form = new Form($db);
108$formcompany = new FormCompany($db);
109$contactstatic = new Contact($db);
110$userstatic = new User($db);
111
112
113// View and edit mode
114
115if ($object->id) {
116 // Show tabs
117 $head = knowledgerecordPrepareHead($object);
118
119 print dol_get_fiche_head($head, 'contact', $langs->trans("KnowledgeRecord"), -1, $object->picto);
120
121 $linkback = '<a href="'.dol_buildpath('/knowledgemanagement/knowledgerecord_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
122
123 $morehtmlref = '<div class="refidno">';
124 /*
125 // Ref customer
126 $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
127 $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
128 // Thirdparty
129 $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
130 // Project
131 if (isModEnabled('project'))
132 {
133 $langs->load("projects");
134 $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
135 if ($permissiontoadd)
136 {
137 if ($action != 'classify')
138 //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token='.newToken().'&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
139 $morehtmlref.=' : ';
140 if ($action == 'classify') {
141 //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
142 $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
143 $morehtmlref.='<input type="hidden" name="action" value="classin">';
144 $morehtmlref.='<input type="hidden" name="token" value="'.newToken().'">';
145 $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
146 $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
147 $morehtmlref.='</form>';
148 } else {
149 $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
150 }
151 } else {
152 if (!empty($object->fk_project)) {
153 $proj = new Project($db);
154 $proj->fetch($object->fk_project);
155 $morehtmlref .= ': '.$proj->getNomUrl();
156 } else {
157 $morehtmlref .= '';
158 }
159 }
160 }*/
161 $morehtmlref .= '</div>';
162
163 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
164
165 print dol_get_fiche_end();
166
167 print '<br>';
168
169 // Contacts lines (modules that overwrite templates must declare this into descriptor)
170 $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl'));
171 foreach ($dirtpls as $reldir) {
172 $res = @include dol_buildpath($reldir.'/contacts.tpl.php');
173 if ($res) {
174 break;
175 }
176 }
177}
178
179// End of page
180llxFooter();
181$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
Class to manage standard extra fields.
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 for KnowledgeRecord.
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.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
knowledgerecordPrepareHead($object)
Prepare array of tabs for KnowledgeRecord.
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.
Contact()
Old copy.
Definition index.php:572