dolibarr  16.0.5
project.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2005 Brice Davoleau <brice.davoleau@gmail.com>
4  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net>
6  * Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
7  * Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
8  * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
9  * Copyright (C) 2021 Frédéric France <frederic.france@netlogic.fr>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program. If not, see <https://www.gnu.org/licenses/>.
23  */
24 
31 require '../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
34 
35 $langs->loadLangs(array("companies", "projects"));
36 
37 // Security check
38 $socid = GETPOST('socid', 'int');
39 if ($user->socid) {
40  $socid = $user->socid;
41 }
42 $result = restrictedArea($user, 'societe', $socid, '&societe');
43 
44 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
45 $hookmanager->initHooks(array('projectthirdparty'));
46 
47 
48 /*
49  * Actions
50  */
51 
52 $parameters = array('id'=>$socid);
53 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
54 if ($reshook < 0) {
55  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
56 }
57 
58 
59 
60 /*
61  * View
62  */
63 
64 $contactstatic = new Contact($db);
65 
66 $form = new Form($db);
67 
68 if ($socid) {
69  require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
70  require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
71 
72  $langs->load("companies");
73 
74 
75  $object = new Societe($db);
76  $result = $object->fetch($socid);
77 
78  $title = $langs->trans("Projects");
79  if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
80  $title = $object->name." - ".$title;
81  }
82  llxHeader('', $title);
83 
84  if (!empty($conf->notification->enabled)) {
85  $langs->load("mails");
86  }
87  $head = societe_prepare_head($object);
88 
89  print dol_get_fiche_head($head, 'project', $langs->trans("ThirdParty"), -1, 'company');
90 
91  $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
92 
93  dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
94 
95  print '<div class="fichecenter">';
96 
97  print '<div class="underbanner clearboth"></div>';
98  print '<table class="border centpercent tableforfield">';
99 
100  // Type Prospect/Customer/Supplier
101  print '<tr><td class="titlefield">'.$langs->trans('NatureOfThirdParty').'</td><td>';
102  print $object->getTypeUrl(1);
103  print '</td></tr>';
104 
105  if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
106  print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
107  }
108 
109  if ($object->client) {
110  print '<tr><td class="titlefield">';
111  print $langs->trans('CustomerCode').'</td><td colspan="3">';
112  print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client));
113  $tmpcheck = $object->check_codeclient();
114  if ($tmpcheck != 0 && $tmpcheck != -5) {
115  print ' <span class="error">('.$langs->trans("WrongCustomerCode").')</span>';
116  }
117  print '</td></tr>';
118  }
119 
120  if ($object->fournisseur) {
121  print '<tr><td class="titlefield">';
122  print $langs->trans('SupplierCode').'</td><td colspan="3">';
123  print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur));
124  $tmpcheck = $object->check_codefournisseur();
125  if ($tmpcheck != 0 && $tmpcheck != -5) {
126  print ' <span class="error">('.$langs->trans("WrongSupplierCode").')</span>';
127  }
128  print '</td></tr>';
129  }
130 
131  print '</table>';
132 
133  print '</div>';
134 
135  print dol_get_fiche_end();
136 
137  $params = '';
138  $backtopage = $_SERVER['PHP_SELF'].'?socid='.$object->id;
139  $newcardbutton = dolGetButtonTitle($langs->trans("NewProject"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/card.php?action=create&socid='.$object->id.'&backtopageforcancel='.urlencode($backtopage), '', 1, $params);
140 
141  print '<br>';
142 
143 
144  // Projects list
145  $result = show_projects($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id, 1, $newcardbutton);
146 }
147 
148 // End of page
149 llxFooter();
150 $db->close();
Societe
Class to manage third parties objects (customers, suppliers, prospects...)
Definition: societe.class.php:48
dol_escape_htmltag
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
Definition: functions.lib.php:1468
restrictedArea
restrictedArea($user, $features, $objectid=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.
Definition: security.lib.php:234
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
dol_banner_tab
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.
Definition: functions.lib.php:2046
showValueWithClipboardCPButton
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
Definition: functions.lib.php:11087
dolGetButtonTitle
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
Definition: functions.lib.php:10605
Contact
Class to manage contact/addresses.
Definition: contact.class.php:40
show_projects
show_projects($conf, $langs, $db, $object, $backtopage='', $nocreatelink=0, $morehtmlright='')
Show html area for list of projects.
Definition: company.lib.php:778
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
societe_prepare_head
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
Definition: company.lib.php:42
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59