dolibarr 21.0.0-beta
partnership_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) 2021 NextGestion <contact@nextgestion.com>
4 * Copyright (C) 2024 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
27// Load Dolibarr environment
28require '../main.inc.php';
29
30require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
31require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
32require_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership.class.php';
33require_once DOL_DOCUMENT_ROOT.'/partnership/lib/partnership.lib.php';
34
43// Load translation files required by the page
44$langs->loadLangs(array("partnership", "companies", "other", "mails"));
45
46$id = (GETPOST('id') ? GETPOSTINT('id') : GETPOSTINT('facid')); // For backward compatibility
47$ref = GETPOST('ref', 'alpha');
48$lineid = GETPOSTINT('lineid');
49$socid = GETPOSTINT('socid');
50$action = GETPOST('action', 'aZ09');
51
52// Initialize a technical objects
53$object = new Partnership($db);
54$extrafields = new ExtraFields($db);
55$diroutputmassaction = $conf->partnership->dir_output.'/temp/massgeneration/'.$user->id;
56$hookmanager->initHooks(array('partnershipcontact', 'globalcard')); // Note that conf->hooks_modules contains array
57// Fetch optionals attributes and labels
58$extrafields->fetch_name_optionals_label($object->table_element);
59
60// Load object
61include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'. Include fetch and fetch_thirdparty but not fetch_optionals
62
63$permissiontoread = $user->hasRight('partnership', 'read');
64$permission = $user->hasRight('partnership', 'write');
65$managedfor = getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty');
66
67// Security check - Protection if external user
68//if ($user->socid > 0) accessforbidden();
69//if ($user->socid > 0) $socid = $user->socid;
70//$result = restrictedArea($user, 'partnership', $object->id);
71if (empty($conf->partnership->enabled)) {
73}
74if (empty($permissiontoread)) {
76}
77if ($object->id > 0 && !($object->fk_member > 0) && $managedfor == 'member') {
79}
80if ($object->id > 0 && !($object->fk_soc > 0) && $managedfor == 'thirdparty') {
82}
83
84
85
86/*
87 * Actions
88 */
89
90if ($action == 'addcontact' && $permission) {
91 $contactid = (GETPOST('userid') ? GETPOSTINT('userid') : GETPOSTINT('contactid'));
92 $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
93 $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
94
95 if ($result >= 0) {
96 header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
97 exit;
98 } else {
99 if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
100 $langs->load("errors");
101 setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
102 } else {
103 setEventMessages($object->error, $object->errors, 'errors');
104 }
105 }
106} elseif ($action == 'swapstatut' && $permission) {
107 // Toggle the status of a contact
108 $result = $object->swapContactStatus(GETPOST('ligne'));
109} elseif ($action == 'deletecontact' && $permission) {
110 // Deletes a contact
111 $result = $object->delete_contact($lineid);
112
113 if ($result >= 0) {
114 header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
115 exit;
116 } else {
117 dol_print_error($db);
118 }
119}
120
121
122/*
123 * View
124 */
125
126$title = $langs->trans('Partnership')." - ".$langs->trans('ContactsAddresses');
127$help_url = '';
128//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
129llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-partnership page-contact');
130
131$form = new Form($db);
132$formcompany = new FormCompany($db);
133$contactstatic = new Contact($db);
134$userstatic = new User($db);
135
136
137/* *************************************************************************** */
138/* */
139/* View and edit mode */
140/* */
141/* *************************************************************************** */
142
143if ($object->id) {
144 /*
145 * Show tabs
146 */
147 $head = partnershipPrepareHead($object);
148
149 print dol_get_fiche_head($head, 'contact', $langs->trans("Partnership"), -1, $object->picto);
150
151 $linkback = '<a href="'.dol_buildpath('/partnership/partnership_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
152
153 $morehtmlref = '<div class="refidno">';
154 /*
155 // Ref customer
156 $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
157 $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
158 // Thirdparty
159 $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
160 // Project
161 if (isModEnabled('project'))
162 {
163 $langs->load("projects");
164 $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
165 if ($permissiontoadd)
166 {
167 if ($action != 'classify')
168 //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token='.newToken().'&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
169 $morehtmlref.=' : ';
170 if ($action == 'classify') {
171 //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
172 $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
173 $morehtmlref.='<input type="hidden" name="action" value="classin">';
174 $morehtmlref.='<input type="hidden" name="token" value="'.newToken().'">';
175 $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
176 $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
177 $morehtmlref.='</form>';
178 } else {
179 $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
180 }
181 } else {
182 if (!empty($object->fk_project)) {
183 $proj = new Project($db);
184 $proj->fetch($object->fk_project);
185 $morehtmlref .= ': '.$proj->getNomUrl();
186 } else {
187 $morehtmlref .= '';
188 }
189 }
190 }*/
191 $morehtmlref .= '</div>';
192
193 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
194
195 print dol_get_fiche_end();
196
197 print '<br>';
198
199 // Contacts lines (modules that overwrite templates must declare this into descriptor)
200 $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl'));
201 foreach ($dirtpls as $reldir) {
202 $res = @include dol_buildpath($reldir.'/contacts.tpl.php');
203 if ($res) {
204 break;
205 }
206 }
207}
208
209// End of page
210llxFooter();
211$db->close();
$id
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
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:71
Class to manage contact/addresses.
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 Partnership.
Class to manage Dolibarr users.
llxFooter()
Footer empty.
Definition document.php:107
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)
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...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
partnershipPrepareHead($object)
Prepare array of tabs for Partnership.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.