dolibarr  17.0.4
project.php
Go to the documentation of this file.
1 <?php
2 /*
3  * Copyright (C) 2021 VIAL--GOUTEYRON Quentin <quentin.vial-gouteyron@atm-consulting.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
26 require '../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
28 
29 $langs->loadLangs(array("contacts", "companies", "projects"));
30 
31 // Security check
32 $id = GETPOST('id', 'int');
33 $result = restrictedArea($user, 'contact', $id, 'socpeople&societe');
34 
35 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
36 $hookmanager->initHooks(array('projectcontact'));
37 
38 /*
39  * Actions
40  */
41 
42 $parameters = array('id' => $id);
43 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
44 if ($reshook < 0) {
45  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
46 }
47 
48 /*
49  * View
50  */
51 
52 $form = new Form($db);
53 
54 if ($id) {
55  require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
56  require_once DOL_DOCUMENT_ROOT.'/core/lib/contact.lib.php';
57 
58  $object = new Contact($db);
59 
60  $result = $object->fetch($id);
61  if (empty($object->thirdparty)) {
62  $object->fetch_thirdparty();
63  }
64  $socid = $object->thirdparty->id;
65  $title = $langs->trans("Projects");
66  if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
67  $title = $object->name." - ".$title;
68  }
69  llxHeader('', $title);
70 
71  if (isModEnabled('notification')) {
72  $langs->load("mails");
73  }
74  $head = contact_prepare_head($object);
75 
76  print dol_get_fiche_head($head, 'project', $langs->trans("Contact"), -1, 'contact');
77 
78  $linkback = '<a href="'.DOL_URL_ROOT.'/contact/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
79 
80  $morehtmlref = '<a href="'.DOL_URL_ROOT.'/contact/vcard.php?id='.$object->id.'" class="refid">';
81  $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
82  $morehtmlref .= '</a>';
83 
84  $morehtmlref .= '<div class="refidno">';
85  if (empty($conf->global->SOCIETE_DISABLE_CONTACTS) && !empty($socid)) {
86  $object->thirdparty->fetch($socid);
87  // Thirdparty
88  $morehtmlref .= $langs->trans('ThirdParty').' : ';
89  if ($object->thirdparty->id > 0) {
90  $morehtmlref .= $object->thirdparty->getNomUrl(1, 'contact');
91  } else {
92  $morehtmlref .= $langs->trans("ContactNotLinkedToCompany");
93  }
94  }
95  $morehtmlref .= '</div>';
96 
97  dol_banner_tab($object, 'id', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom', $morehtmlref);
98 
99  print '<div class="fichecenter">';
100 
101  print '<div class="underbanner clearboth"></div>';
102  print '<table class="border centpercent tableforfield">';
103 
104  // Civility
105  print '<tr><td class="titlefield">'.$langs->trans("UserTitle").'</td><td>';
106  print $object->getCivilityLabel();
107  print '</td></tr>';
108 
109  print '</table>';
110 
111  print '</div>';
112 
113  print dol_get_fiche_end();
114  print '<br>';
115 
116  // Projects list
117  $result = show_contacts_projects($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?id='.$object->id, 1);
118 }
119 
120 // End of page
121 llxFooter();
122 $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:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage contact/addresses.
Class to manage generation of HTML components Only common components must be here.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
contact_prepare_head(Contact $object)
Prepare array with list of tabs.
Definition: contact.lib.php:33
show_contacts_projects($conf, $langs, $db, $object, $backtopage='', $nocreatelink=0, $morehtmlright='')
Show html area for list of projects.
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='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
isModEnabled($module)
Is Dolibarr module enabled.
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.