dolibarr 19.0.3
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
32// Load Dolibarr environment
33require '../main.inc.php';
34require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
35require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
36require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
37require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
38
39$form = new Form($db);
40
41// Load translation files required by the page
42$langs->loadLangs(array('companies', 'projects'));
43
44$action = GETPOST('action', 'aZ09');
45$massaction = GETPOST('massaction', 'alpha');
46$confirm = GETPOST('confirm', 'alpha');
47
48$toselect = GETPOST('toselect', 'array');
49
50
51// Security check
52$socid = GETPOST('socid', 'int');
53if ($user->socid) {
54 $socid = $user->socid;
55}
56$result = restrictedArea($user, 'societe', $socid, '&societe');
57
58// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
59$hookmanager->initHooks(array('projectthirdparty'));
60
61$object = new Societe($db);
62$permissiontodelete = $user->hasRight('societe', 'supprimer');
63
64
65
66/*
67 * Actions
68 */
69
70
71if (GETPOST('cancel', 'alpha')) {
72 $massaction = '';
73}
74if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
75 $massaction = '';
76 $massactionbutton = '';
77}
78
79
80$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
81if ($reshook < 0) {
82 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
83}
84
85$parameters = array('id'=>$socid);
86
87// List of mass actions available
88$arrayofmassactions = array();
89if (!empty($permissiontodelete)) {
90 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
91}
92if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) {
93 $arrayofmassactions = array();
94}
95
96if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag', 'preenable', 'preclose'))) {
97 $arrayofmassactions = array();
98}
99
100// Mass actions
101$objectclass = 'Project';
102$objectlabel = 'Project';
103$uploaddir = $conf->societe->dir_output;
104include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
105
106$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
107
108
109/*
110 * View
111 */
112
113unset($_SESSION['pageforbacktolist']['project']);
114if ($socid) {
115 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
116 require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
117
118 $langs->load("companies");
119
120 $result = $object->fetch($socid);
121
122 $title = $langs->trans("Projects");
123 if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
124 $title = $object->name." - ".$title;
125 }
126 llxHeader('', $title);
127
128 if (isModEnabled('notification')) {
129 $langs->load("mails");
130 }
131 $head = societe_prepare_head($object);
132
133 print dol_get_fiche_head($head, 'project', $langs->trans("ThirdParty"), -1, 'company');
134
135 $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
136
137 dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
138
139 print '<div class="fichecenter">';
140
141 print '<div class="underbanner clearboth"></div>';
142 print '<table class="border centpercent tableforfield">';
143
144
145 // Type Prospect/Customer/Supplier
146 print '<tr><td class="titlefield">'.$langs->trans('NatureOfThirdParty').'</td><td>';
147 print $object->getTypeUrl(1);
148 print '</td></tr>';
149
150 if (getDolGlobalString('SOCIETE_USEPREFIX')) { // Old not used prefix field
151 print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
152 }
153
154 if ($object->client) {
155 print '<tr><td class="titlefield">';
156 print $langs->trans('CustomerCode').'</td><td colspan="3">';
157 print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client));
158 $tmpcheck = $object->check_codeclient();
159 if ($tmpcheck != 0 && $tmpcheck != -5) {
160 print ' <span class="error">('.$langs->trans("WrongCustomerCode").')</span>';
161 }
162 print '</td></tr>';
163 }
164
165 if ($object->fournisseur) {
166 print '<tr><td class="titlefield">';
167 print $langs->trans('SupplierCode').'</td><td colspan="3">';
168 print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur));
169 $tmpcheck = $object->check_codefournisseur();
170 if ($tmpcheck != 0 && $tmpcheck != -5) {
171 print ' <span class="error">('.$langs->trans("WrongSupplierCode").')</span>';
172 }
173 print '</td></tr>';
174 }
175
176 print '</table>';
177 print '</div>';
178
179 print dol_get_fiche_end();
180
181 print '<br>';
182 $params = '';
183 $backtopage = $_SERVER['PHP_SELF'].'?socid='.$object->id;
184 $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);
185
186 if (empty($conf->dol_optimize_smallscreen)) {
187 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'">';
188 print '<input type="hidden" name="token" value="'.newToken().'">';
189 print '<div class="nobordernopadding center valignmiddle col-center">'.$massactionbutton.'</div>';
190 }
191
192
193 // Projects list
194 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
195 $arrayofselected = is_array($toselect) ? $toselect : array();
196 $result = show_projects($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id, 1, $newcardbutton);
197
198 if (empty($conf->dol_optimize_smallscreen)) {
199 print '</form>';
200 }
201}
202
203// End of page
204llxFooter();
205$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 generation of HTML components Only common components must be here.
Class to manage third parties objects (customers, suppliers, prospects...)
show_projects($conf, $langs, $db, $object, $backtopage='', $nocreatelink=0, $morehtmlright='')
Show html area for list of projects.
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
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.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
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.
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.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
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.