dolibarr 21.0.0-beta
card.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2023 Charlene Benke <charlene@patas_monkey.com>
6 * Copyright (C) 2023 Christian Foellmann <christian@foellmann.de>
7 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
8 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
9 * Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
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// Load Dolibarr environment
32require '../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
34require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
35require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
36require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
37require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
38require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
39require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php';
40require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
41require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
42
51// Load translation files required by the page
52$langsLoad = array('projects', 'companies');
53if (isModEnabled('eventorganization')) {
54 $langsLoad[] = 'eventorganization';
55}
56
57$langs->loadLangs($langsLoad);
58
59$id = GETPOSTINT('id');
60$ref = GETPOST('ref', 'alpha');
61$action = GETPOST('action', 'aZ09');
62$backtopage = GETPOST('backtopage', 'alpha');
63$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
64$backtopagejsfields = GETPOST('backtopagejsfields', 'alpha');
65$cancel = GETPOST('cancel', 'alpha');
66$confirm = GETPOST('confirm', 'aZ09');
67
68$dol_openinpopup = '';
69if (!empty($backtopagejsfields)) {
70 $tmpbacktopagejsfields = explode(':', $backtopagejsfields);
71 $dol_openinpopup = preg_replace('/[^a-z0-9_]/i', '', $tmpbacktopagejsfields[0]);
72}
73
74$status = GETPOSTINT('status');
75$opp_status = GETPOSTINT('opp_status');
76$opp_percent = price2num(GETPOST('opp_percent', 'alphanohtml'));
77$objcanvas = GETPOST("objcanvas", "alphanohtml");
78$comefromclone = GETPOST("comefromclone", "alphanohtml");
79$date_start = dol_mktime(0, 0, 0, GETPOSTINT('projectstartmonth'), GETPOSTINT('projectstartday'), GETPOSTINT('projectstartyear'));
80$date_end = dol_mktime(0, 0, 0, GETPOSTINT('projectendmonth'), GETPOSTINT('projectendday'), GETPOSTINT('projectendyear'));
81$date_start_event = dol_mktime(GETPOSTINT('date_start_eventhour'), GETPOSTINT('date_start_eventmin'), GETPOSTINT('date_start_eventsec'), GETPOSTINT('date_start_eventmonth'), GETPOSTINT('date_start_eventday'), GETPOSTINT('date_start_eventyear'), 'tzuserrel');
82$date_end_event = dol_mktime(GETPOSTINT('date_end_eventhour'), GETPOSTINT('date_end_eventmin'), GETPOSTINT('date_end_eventsec'), GETPOSTINT('date_end_eventmonth'), GETPOSTINT('date_end_eventday'), GETPOSTINT('date_end_eventyear'), 'tzuserrel');
83$location = GETPOST('location', 'alphanohtml');
84$fk_project = GETPOSTINT('fk_project');
85
86
87$mine = GETPOST('mode') == 'mine' ? 1 : 0;
88//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
89
90// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
91$hookmanager->initHooks(array('projectcard', 'globalcard'));
92
93$object = new Project($db);
94$extrafields = new ExtraFields($db);
95
96// Load object
97//include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Can't use generic include because when creating a project, ref is defined and we don't want error if fetch fails from ref.
98if ($id > 0 || !empty($ref)) {
99 $ret = $object->fetch($id, $ref); // If we create project, ref may be defined into POST but record does not yet exists into database
100 if ($ret > 0) {
101 $object->fetch_thirdparty();
102 if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($object, 'fetchComments') && empty($object->comments)) {
103 $object->fetchComments();
104 }
105 $id = $object->id;
106 }
107}
108
109// fetch optionals attributes and labels
110$extrafields->fetch_name_optionals_label($object->table_element);
111
112// Security check
113$socid = GETPOSTINT('socid');
114//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignment.
115restrictedArea($user, 'projet', $object->id, 'projet&project');
116
117if ($id == '' && $ref == '' && ($action != "create" && $action != "add" && $action != "update" && !GETPOST("cancel"))) {
119}
120
121$permissiontoadd = $user->hasRight('projet', 'creer');
122$permissiontodelete = $user->hasRight('projet', 'supprimer');
123$permissiondellink = $user->hasRight('projet', 'creer'); // Used by the include of actions_dellink.inc.php
124
125
126/*
127 * Actions
128 */
129$error = 0;
130$parameters = array('id' => $socid, 'objcanvas' => $objcanvas);
131$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
132if ($reshook < 0) {
133 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
134}
135
136if (empty($reshook)) {
137 $backurlforlist = DOL_URL_ROOT.'/projet/list.php';
138
139 // Cancel
140 if ($cancel) {
141 if (GETPOST("comefromclone") == 1) {
142 $result = $object->delete($user);
143 if ($result > 0) {
144 header("Location: index.php");
145 exit;
146 } else {
147 dol_syslog($object->error, LOG_DEBUG);
148 setEventMessages($langs->trans("CantRemoveProject", $langs->transnoentitiesnoconv("ProjectOverview")), null, 'errors');
149 }
150 }
151 }
152
153 if (empty($backtopage) || ($cancel && empty($id))) {
154 if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
155 if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
156 $backtopage = $backurlforlist;
157 } else {
158 $backtopage = DOL_URL_ROOT.'/projet/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
159 }
160 }
161 }
162
163 if ($cancel) {
164 if (!empty($backtopageforcancel)) {
165 header("Location: ".$backtopageforcancel);
166 exit;
167 } elseif (!empty($backtopage)) {
168 header("Location: ".$backtopage);
169 exit;
170 }
171 $action = '';
172 }
173
174 include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be 'include', not 'include_once'
175
176 // Action setdraft object
177 if ($action == 'confirm_setdraft' && $confirm == 'yes' && $permissiontoadd) {
178 $result = $object->setStatut($object::STATUS_DRAFT, null, '', 'PROJECT_MODIFY');
179 if ($result >= 0) {
180 // Nothing else done
181 } else {
182 $error++;
183 setEventMessages($object->error, $object->errors, 'errors');
184 }
185 $action = '';
186
187 // For backward compatibility
188 $object->statut = $object::STATUS_DRAFT; // this already set for $object->status by $object->setStatut()
189 }
190
191 // Action add
192 if ($action == 'add' && $permissiontoadd) {
193 $error = 0;
194 if (!GETPOST('ref')) {
195 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors');
196 $error++;
197 }
198 if (!GETPOST('title')) {
199 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("ProjectLabel")), null, 'errors');
200 $error++;
201 }
202
203 if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) {
204 if (GETPOST('usage_opportunity') != '' && !(GETPOST('opp_status') > 0)) {
205 $error++;
206 setEventMessages($langs->trans("ErrorOppStatusRequiredIfUsage"), null, 'errors');
207 }
208 if (GETPOST('opp_amount') != '' && !(GETPOST('opp_status') > 0)) {
209 $error++;
210 setEventMessages($langs->trans("ErrorOppStatusRequiredIfAmount"), null, 'errors');
211 }
212 }
213
214 // Create with status validated immediately
215 if (getDolGlobalString('PROJECT_CREATE_NO_DRAFT') && !$error) {
217 }
218
219 if (!$error) {
220 $error = 0;
221
222 $db->begin();
223
224 $object->ref = GETPOST('ref', 'alphanohtml');
225 $object->fk_project = GETPOSTINT('fk_project');
226 $object->title = GETPOST('title', 'alphanohtml');
227 $object->socid = GETPOSTINT('socid');
228 $object->description = GETPOST('description', 'restricthtml'); // Do not use 'alpha' here, we want field as it is
229 $object->public = GETPOSTINT('public') ? 1 : 0;
230 $object->opp_amount = GETPOSTFLOAT('opp_amount');
231 $object->budget_amount = GETPOSTFLOAT('budget_amount');
232 $object->date_c = dol_now();
233 $object->date_start = $date_start;
234 $object->date_end = $date_end;
235 $object->date_start_event = $date_start_event;
236 $object->date_end_event = $date_end_event;
237 $object->location = $location;
238 $object->status = $status;
239 $object->opp_status = $opp_status;
240 $object->opp_percent = $opp_percent;
241 $object->usage_opportunity = (GETPOST('usage_opportunity', 'alpha') == 'on' ? 1 : 0);
242 $object->usage_task = (GETPOST('usage_task', 'alpha') == 'on' ? 1 : 0);
243 $object->usage_bill_time = (GETPOST('usage_bill_time', 'alpha') == 'on' ? 1 : 0);
244 $object->usage_organize_event = (GETPOST('usage_organize_event', 'alpha') == 'on' ? 1 : 0);
245
246 // Fill array 'array_options' with data from add form
247 $ret = $extrafields->setOptionalsFromPost(null, $object);
248 if ($ret < 0) {
249 $error++;
250 }
251
252 $result = $object->create($user);
253 if (!$error && $result > 0) {
254 // Add myself as Owner Contact Selected in the form
255 $typeofcontact = GETPOST('typeofcontact');
256 $result = $object->add_contact($user->id, $typeofcontact, 'internal');
257
258 // -3 means type not found (renamed, de-activated or deleted), so don't prevent creation if it has been the case
259 if ($result == -3) {
260 setEventMessage('ErrorPROJECTLEADERRoleMissingRestoreIt', 'errors');
261 $error++;
262 } elseif ($result < 0) {
263 $langs->load("errors");
264 setEventMessages($object->error, $object->errors, 'errors');
265 $error++;
266 }
267 } else {
268 $langs->load("errors");
269 setEventMessages($object->error, $object->errors, 'errors');
270 $error++;
271 }
272 if (!$error && !empty($object->id) > 0) {
273 // Category association
274 $categories = GETPOST('categories', 'array');
275 $result = $object->setCategories($categories);
276 if ($result < 0) {
277 $langs->load("errors");
278 setEventMessages($object->error, $object->errors, 'errors');
279 $error++;
280 }
281 }
282
283 if (!$error) {
284 $db->commit();
285
286 if (!empty($backtopage)) {
287 $backtopage = preg_replace('/--IDFORBACKTOPAGE--|__ID__/', (string) $object->id, $backtopage); // New method to autoselect project after a New on another form object creation
288 $backtopage = $backtopage.'&projectid='.$object->id; // Old method
289 header("Location: ".$backtopage);
290 exit;
291 } else {
292 header("Location:card.php?id=".$object->id);
293 exit;
294 }
295 } else {
296 $db->rollback();
297 unset($_POST["ref"]);
298 $action = 'create';
299 }
300 } else {
301 $action = 'create';
302 }
303 }
304
305 if ($action == 'update' && empty(GETPOST('cancel')) && $permissiontoadd) {
306 if (empty($ref)) {
307 $error++;
308 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors');
309 }
310 if (!GETPOST("title")) {
311 $error++;
312 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("ProjectLabel")), null, 'errors');
313 }
314
315 $db->begin();
316 $old_start_date = null;
317 if (!$error) {
318 $object->oldcopy = clone $object;
319
320 $old_start_date = $object->date_start;
321
322 $object->ref = GETPOST('ref', 'alpha');
323 $object->fk_project = GETPOSTINT('fk_project');
324 $object->title = GETPOST('title', 'alphanohtml'); // Do not use 'alpha' here, we want field as it is
325 $object->status = GETPOSTINT('status');
326 $object->socid = GETPOSTINT('socid');
327 $object->description = GETPOST('description', 'restricthtml'); // Do not use 'alpha' here, we want field as it is
328 $object->public = GETPOSTINT('public') ? 1 : 0;
329 $object->date_start = (!GETPOST('projectstart')) ? '' : $date_start;
330 $object->date_end = (!GETPOST('projectend')) ? '' : $date_end;
331 $object->date_start_event = (!GETPOST('date_start_event')) ? '' : $date_start_event;
332 $object->date_end_event = (!GETPOST('date_end_event')) ? '' : $date_end_event;
333 $object->location = $location;
334 if (GETPOSTISSET('opp_amount')) {
335 $object->opp_amount = price2num(GETPOST('opp_amount', 'alpha'));
336 }
337 if (GETPOSTISSET('budget_amount')) {
338 $object->budget_amount = price2num(GETPOST('budget_amount', 'alpha'));
339 }
340 if (GETPOSTISSET('opp_status')) {
341 $object->opp_status = $opp_status;
342 }
343 if (GETPOSTISSET('opp_percent')) {
344 $object->opp_percent = $opp_percent;
345 }
346 $object->usage_opportunity = (GETPOST('usage_opportunity', 'alpha') == 'on' ? 1 : 0);
347 $object->usage_task = (GETPOST('usage_task', 'alpha') == 'on' ? 1 : 0);
348 $object->usage_bill_time = (GETPOST('usage_bill_time', 'alpha') == 'on' ? 1 : 0);
349 $object->usage_organize_event = (GETPOST('usage_organize_event', 'alpha') == 'on' ? 1 : 0);
350
351 // Fill array 'array_options' with data from add form
352 $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
353 if ($ret < 0) {
354 $error++;
355 }
356 }
357
358 if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) {
359 if ($object->opp_amount && ($object->opp_status <= 0)) {
360 $error++;
361 setEventMessages($langs->trans("ErrorOppStatusRequiredIfAmount"), null, 'errors');
362 }
363 }
364
365 if (!$error) {
366 $result = $object->update($user);
367 if ($result < 0) {
368 $error++;
369 if ($result == -4) {
370 setEventMessages($langs->trans("ErrorRefAlreadyExists"), null, 'errors');
371 } else {
372 setEventMessages($object->error, $object->errors, 'errors');
373 }
374 } else {
375 // Category association
376 $categories = GETPOST('categories', 'array');
377 $result = $object->setCategories($categories);
378 if ($result < 0) {
379 $error++;
380 setEventMessages($object->error, $object->errors, 'errors');
381 }
382 }
383 }
384
385 if (!$error) {
386 if (GETPOST("reportdate") && ($object->date_start != $old_start_date)) {
387 $result = $object->shiftTaskDate($old_start_date);
388 if ($result < 0) {
389 $error++;
390 setEventMessages($langs->trans("ErrorShiftTaskDate").':'.$object->error, $object->errors, 'errors');
391 }
392 }
393 }
394
395 // Check if we must change status
396 if (GETPOST('closeproject')) {
397 $resclose = $object->setClose($user);
398 if ($resclose < 0) {
399 $error++;
400 setEventMessages($langs->trans("FailedToCloseProject").':'.$object->error, $object->errors, 'errors');
401 }
402 }
403
404
405 if ($error) {
406 $db->rollback();
407 $action = 'edit';
408 } else {
409 $db->commit();
410
411 if (GETPOSTINT('socid') > 0) {
412 $object->fetch_thirdparty(GETPOSTINT('socid'));
413 } else {
414 unset($object->thirdparty);
415 }
416 }
417 }
418
419 if ($action == 'set_opp_status' && $user->hasRight('projet', 'creer')) {
420 if (GETPOSTISSET('opp_status')) {
421 $object->opp_status = $opp_status;
422 }
423 if (GETPOSTISSET('opp_percent')) {
424 $object->opp_percent = $opp_percent;
425 }
426
427 if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) {
428 if ($object->opp_amount && ($object->opp_status <= 0)) {
429 $error++;
430 setEventMessages($langs->trans("ErrorOppStatusRequiredIfAmount"), null, 'errors');
431 }
432 }
433
434 if (!$error) {
435 $result = $object->update($user);
436 if ($result < 0) {
437 $error++;
438 if ($result == -4) {
439 setEventMessages($langs->trans("ErrorRefAlreadyExists"), null, 'errors');
440 } else {
441 setEventMessages($object->error, $object->errors, 'errors');
442 }
443 }
444 }
445
446 if ($error) {
447 $db->rollback();
448 $action = 'edit';
449 } else {
450 $db->commit();
451 }
452 }
453
454 // Build doc
455 if ($action == 'builddoc' && $permissiontoadd) {
456 // Save last template used to generate document
457 if (GETPOST('model')) {
458 $object->setDocModel($user, GETPOST('model', 'alpha'));
459 }
460
461 $outputlangs = $langs;
462 if (GETPOST('lang_id', 'aZ09')) {
463 $outputlangs = new Translate("", $conf);
464 $outputlangs->setDefaultLang(GETPOST('lang_id', 'aZ09'));
465 }
466 $result = $object->generateDocument($object->model_pdf, $outputlangs);
467 if ($result <= 0) {
468 setEventMessages($object->error, $object->errors, 'errors');
469 $action = '';
470 }
471 }
472
473 // Delete file in doc form
474 if ($action == 'remove_file' && $permissiontoadd) {
475 if ($object->id > 0) {
476 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
477
478 $langs->load("other");
479 $upload_dir = $conf->project->multidir_output[$object->entity];
480 $file = $upload_dir.'/'.GETPOST('file');
481 $ret = dol_delete_file($file, 0, 0, 0, $object);
482 if ($ret) {
483 setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs');
484 } else {
485 setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors');
486 }
487 $action = '';
488 }
489 }
490
491
492 if ($action == 'confirm_validate' && $confirm == 'yes' && $permissiontoadd) {
493 $result = $object->setValid($user);
494 if ($result <= 0) {
495 setEventMessages($object->error, $object->errors, 'errors');
496 }
497 }
498
499 if ($action == 'confirm_close' && $confirm == 'yes' && $permissiontoadd) {
500 $result = $object->setClose($user);
501 if ($result <= 0) {
502 setEventMessages($object->error, $object->errors, 'errors');
503 }
504 }
505
506 if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd) {
507 $result = $object->setValid($user);
508 if ($result <= 0) {
509 setEventMessages($object->error, $object->errors, 'errors');
510 }
511 }
512
513 if ($action == 'confirm_delete' && $confirm == 'yes' && $permissiontodelete) {
514 $object->fetch($id);
515 $result = $object->delete($user);
516 if ($result > 0) {
517 setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
518
519 if (!empty($_SESSION['pageforbacktolist']) && !empty($_SESSION['pageforbacktolist']['project'])) {
520 $tmpurl = $_SESSION['pageforbacktolist']['project'];
521 $tmpurl = preg_replace('/__SOCID__/', (string) $object->socid, $tmpurl);
522 $urlback = $tmpurl.(preg_match('/\?/', $tmpurl) ? '&' : '?'). 'restore_lastsearch_values=1';
523 } else {
524 $urlback = DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1';
525 }
526
527 header("Location: ".$urlback);
528 exit;
529 } else {
530 dol_syslog($object->error, LOG_DEBUG);
531 setEventMessages($object->error, $object->errors, 'errors');
532 }
533 }
534
535 if ($action == 'confirm_clone' && $permissiontoadd && $confirm == 'yes') {
536 $clone_contacts = GETPOST('clone_contacts') ? 1 : 0;
537 $clone_tasks = GETPOST('clone_tasks') ? 1 : 0;
538 $clone_project_files = GETPOST('clone_project_files') ? 1 : 0;
539 $clone_task_files = GETPOST('clone_task_files') ? 1 : 0;
540 $clone_notes = GETPOST('clone_notes') ? 1 : 0;
541 $move_date = GETPOST('move_date') ? 1 : 0;
542 $clone_thirdparty = GETPOSTINT('socid') ? GETPOSTINT('socid') : 0;
543
544 $result = $object->createFromClone($user, $object->id, $clone_contacts, $clone_tasks, $clone_project_files, $clone_task_files, $clone_notes, $move_date, 0, $clone_thirdparty);
545 if ($result <= 0) {
546 setEventMessages($object->error, $object->errors, 'errors');
547 } else {
548 // Load new object
549 $newobject = new Project($db);
550 $newobject->fetch($result);
551 $newobject->fetch_optionals();
552 $newobject->fetch_thirdparty(); // Load new object
553 $object = $newobject;
554 $action = 'view';
555 $comefromclone = true;
556
557 setEventMessages($langs->trans("ProjectCreatedInDolibarr", $newobject->ref), null, 'mesgs');
558 //var_dump($newobject); exit;
559 }
560 }
561
562 // Actions to send emails
563 $triggersendname = 'PROJECT_SENTBYMAIL';
564 $paramname = 'id';
565 $autocopy = 'MAIN_MAIL_AUTOCOPY_PROJECT_TO'; // used to know the automatic BCC to add
566 $trackid = 'proj'.$object->id;
567 include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
568}
569
570
571/*
572 * View
573 */
574
575$form = new Form($db);
576$formfile = new FormFile($db);
577$formproject = new FormProjets($db);
578$userstatic = new User($db);
579
580$title = $langs->trans("Project").' - '.$object->ref.(!empty($object->thirdparty->name) ? ' - '.$object->thirdparty->name : '').(!empty($object->title) ? ' - '.$object->title : '');
581if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/projectnameonly/', getDolGlobalString('MAIN_HTML_TITLE'))) {
582 $title = $object->ref.(!empty($object->thirdparty->name) ? ' - '.$object->thirdparty->name : '').(!empty($object->title) ? ' - '.$object->title : '');
583}
584
585$help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos|DE:Modul_Projekte";
586
587llxHeader("", $title, $help_url, '', 0, 0, '', '', '', 'mod-project page-card');
588
589$titleboth = $langs->trans("LeadsOrProjects");
590$titlenew = $langs->trans("NewLeadOrProject"); // Leads and opportunities by default
591if (!getDolGlobalInt('PROJECT_USE_OPPORTUNITIES')) {
592 $titleboth = $langs->trans("Projects");
593 $titlenew = $langs->trans("NewProject");
594}
595if (getDolGlobalInt('PROJECT_USE_OPPORTUNITIES') == 2) { // 2 = leads only
596 $titleboth = $langs->trans("Leads");
597 $titlenew = $langs->trans("NewLead");
598}
599
600if ($action == 'create' && $user->hasRight('projet', 'creer')) {
601 /*
602 * Create
603 */
604
605 $thirdparty = new Societe($db);
606 if ($socid > 0) {
607 $thirdparty->fetch($socid);
608 }
609
610 print load_fiche_titre($titlenew, '', 'project');
611
612 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
613 print '<input type="hidden" name="action" value="add">';
614 print '<input type="hidden" name="token" value="'.newToken().'">';
615 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
616 print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
617 print '<input type="hidden" name="backtopagejsfields" value="'.$backtopagejsfields.'">';
618 print '<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.'">';
619
620 print dol_get_fiche_head();
621
622 print '<table class="border centpercent tableforfieldcreate">';
623
624 $defaultref = '';
625 $modele = getDolGlobalString('PROJECT_ADDON', 'mod_project_simple');
626
627 // Search template files
628 $file = '';
629 $classname = '';
630 $reldir = '';
631 $filefound = 0;
632 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
633 foreach ($dirmodels as $reldir) {
634 $file = dol_buildpath($reldir."core/modules/project/".$modele.'.php', 0);
635 if (file_exists($file)) {
636 $filefound = 1;
637 $classname = $modele;
638 break;
639 }
640 }
641
642 if ($filefound && !empty($classname)) {
643 $result = dol_include_once($reldir."core/modules/project/".$modele.'.php');
644 if (class_exists($classname)) {
645 $modProject = new $classname();
646 '@phan-var-force ModeleNumRefProjects $modProject';
647 $defaultref = $modProject->getNextValue($thirdparty, $object);
648 }
649 }
650
651 if (is_numeric($defaultref) && $defaultref <= 0) {
652 $defaultref = '';
653 }
654
655 // Ref
656 $suggestedref = (GETPOST("ref") ? GETPOST("ref") : $defaultref);
657 print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans("Ref").'</span></td><td class><input class="maxwidth150onsmartphone" type="text" name="ref" value="'.dol_escape_htmltag($suggestedref).'">';
658 if ($suggestedref) {
659 print ' '.$form->textwithpicto('', $langs->trans("YouCanCompleteRef", $suggestedref));
660 }
661 print '</td></tr>';
662
663 // Label
664 print '<tr><td><span class="fieldrequired">'.$langs->trans("Label").'</span></td><td><input class="width500 maxwidth150onsmartphone" type="text" name="title" value="'.dol_escape_htmltag(GETPOST("title", 'alphanohtml')).'" autofocus></td></tr>';
665
666 // Parent
667 if (getDolGlobalInt('PROJECT_ENABLE_SUB_PROJECT')) {
668 print '<tr><td>'.$langs->trans("Parent").'</td><td class="maxwidthonsmartphone">';
669 print img_picto('', 'project', 'class="pictofixedwidth"');
670 $formproject->select_projects(-1, '', 'fk_project', 64, 0, 1, 1, 0, 0, 0, '', 0, 0, '', '', '');
671 print '</td></tr>';
672 }
673
674 // Usage (opp, task, bill time, ...)
675 if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES') || !getDolGlobalString('PROJECT_HIDE_TASKS') || isModEnabled('eventorganization')) {
676 print '<tr><td class="tdtop">';
677 print $langs->trans("Usage");
678 print '</td>';
679 print '<td>';
680 if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) {
681 print '<input type="checkbox" id="usage_opportunity" name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') ? ' checked="checked"' : '') : ' checked="checked"').'"> ';
682 $htmltext = $langs->trans("ProjectFollowOpportunity");
683 print '<label for="usage_opportunity">'.$form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext).'</label>';
684 print '<script>';
685 print '$( document ).ready(function() {
686 jQuery("#usage_opportunity").change(function() {
687 if (jQuery("#usage_opportunity").prop("checked")) {
688 console.log("Show opportunities fields");
689 jQuery(".classuseopportunity").show();
690 } else {
691 console.log("Hide opportunities fields "+jQuery("#usage_opportunity").prop("checked"));
692 jQuery(".classuseopportunity").hide();
693 }
694 });
695 ';
696 if (GETPOSTISSET('usage_opportunity') && !GETPOST('usage_opportunity')) {
697 print 'jQuery(".classuseopportunity").hide();';
698 }
699 print '});';
700 print '</script>';
701 print '<br>';
702 }
703 if (!getDolGlobalString('PROJECT_HIDE_TASKS')) {
704 print '<input type="checkbox" id="usage_task" name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') ? ' checked="checked"' : '') : ' checked="checked"').'"> ';
705 $htmltext = $langs->trans("ProjectFollowTasks");
706 print '<label for="usage_task">'.$form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext).'</label>';
707 print '<script>';
708 print '$( document ).ready(function() {
709 jQuery("#usage_task").change(function() {
710 if (jQuery("#usage_task").prop("checked")) {
711 console.log("Show task fields");
712 jQuery(".classusetask").show();
713 } else {
714 console.log("Hide tasks fields "+jQuery("#usage_task").prop("checked"));
715 jQuery(".classusetask").hide();
716 }
717 });
718 ';
719 if (GETPOSTISSET('usage_task') && !GETPOST('usage_task')) {
720 print 'jQuery(".classusetask").hide();';
721 }
722 print '});';
723 print '</script>';
724 print '<br>';
725 }
726 if (!getDolGlobalString('PROJECT_HIDE_TASKS') && getDolGlobalString('PROJECT_BILL_TIME_SPENT')) {
727 print '<input type="checkbox" id="usage_bill_time" name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') ? ' checked="checked"' : '') : '').'"> ';
728 $htmltext = $langs->trans("ProjectBillTimeDescription");
729 print '<label for="usage_bill_time">'.$form->textwithpicto($langs->trans("BillTime"), $htmltext).'</label>';
730 print '<script>';
731 print '$( document ).ready(function() {
732 jQuery("#usage_bill_time").change(function() {
733 if (jQuery("#usage_bill_time").prop("checked")) {
734 console.log("Show bill time fields");
735 jQuery(".classusebilltime").show();
736 } else {
737 console.log("Hide bill time fields "+jQuery("#usage_bill_time").prop("checked"));
738 jQuery(".classusebilltime").hide();
739 }
740 });
741 ';
742 if (GETPOSTISSET('usage_bill_time') && !GETPOST('usage_bill_time')) {
743 print 'jQuery(".classusebilltime").hide();';
744 }
745 print '});';
746 print '</script>';
747 print '<br>';
748 }
749 if (isModEnabled('eventorganization')) {
750 print '<input type="checkbox" id="usage_organize_event" name="usage_organize_event"'.(GETPOSTISSET('usage_organize_event') ? (GETPOST('usage_organize_event', 'alpha') ? ' checked="checked"' : '') : '').'"> ';
751 $htmltext = $langs->trans("EventOrganizationDescriptionLong");
752 print '<label for="usage_organize_event">'.$form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext).'</label>';
753 print '<script>';
754 print '$( document ).ready(function() {
755 jQuery("#usage_organize_event").change(function() {
756 if (jQuery("#usage_organize_event").prop("checked")) {
757 console.log("Show organize event fields");
758 jQuery(".classuseorganizeevent").show();
759 } else {
760 console.log("Hide organize event fields "+jQuery("#usage_organize_event").prop("checked"));
761 jQuery(".classuseorganizeevent").hide();
762 }
763 });
764 ';
765 if (!GETPOST('usage_organize_event')) {
766 print 'jQuery(".classuseorganizeevent").hide();';
767 }
768 print '});';
769 print '</script>';
770 }
771 print '</td>';
772 print '</tr>';
773 }
774
775 // Thirdparty
776 if (isModEnabled('societe')) {
777 print '<tr><td>';
778 print(!getDolGlobalString('PROJECT_THIRDPARTY_REQUIRED') ? '' : '<span class="fieldrequired">');
779 print $langs->trans("ThirdParty");
780 print(!getDolGlobalString('PROJECT_THIRDPARTY_REQUIRED') ? '' : '</span>');
781 print '</td><td class="maxwidthonsmartphone">';
782 $filter = '';
783 if (getDolGlobalString('PROJECT_FILTER_FOR_THIRDPARTY_LIST')) {
784 $filter = getDolGlobalString('PROJECT_FILTER_FOR_THIRDPARTY_LIST');
785 }
786 $text = img_picto('', 'company', 'class="pictofixedwidth"').$form->select_company(GETPOSTINT('socid'), 'socid', $filter, 'SelectThirdParty', 1, 0, array(), 0, 'minwidth300 widthcentpercentminusxx maxwidth500');
787 if (!getDolGlobalString('PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') && empty($conf->dol_use_jmobile)) {
788 $texthelp = $langs->trans("IfNeedToUseOtherObjectKeepEmpty");
789 print $form->textwithtooltip($text.' '.img_help(), $texthelp, 1);
790 } else {
791 print $text;
792 }
793 if (!GETPOSTISSET('backtopage')) {
794 $url = '/societe/card.php?action=create&client=3&fournisseur=0&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create');
795 $newbutton = '<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("AddThirdParty").'"></span>';
796 // TODO @LDR Implement this
797 if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
798 $tmpbacktopagejsfields = 'addthirdparty:socid,search_socid';
799 print dolButtonToOpenUrlInDialogPopup('addthirdparty', $langs->transnoentitiesnoconv('AddThirdParty'), $newbutton, $url, '', '', '', $tmpbacktopagejsfields);
800 } else {
801 print ' <a href="'.DOL_URL_ROOT.$url.'">'.$newbutton.'</a>';
802 }
803 }
804 print '</td></tr>';
805 }
806
807 // Status
808 if ($status != '') {
809 print '<tr><td>'.$langs->trans("Status").'</td><td>';
810 print '<input type="hidden" name="status" value="'.$status.'">';
811 print $object->LibStatut($status, 4);
812 print '</td></tr>';
813 }
814
815 // Visibility
816 print '<tr><td>'.$langs->trans("Visibility").'</td><td class="maxwidthonsmartphone">';
817 $array = array();
818 if (!getDolGlobalString('PROJECT_DISABLE_PRIVATE_PROJECT')) {
819 $array[0] = $langs->trans("PrivateProject");
820 }
821 if (!getDolGlobalString('PROJECT_DISABLE_PUBLIC_PROJECT')) {
822 $array[1] = $langs->trans("SharedProject");
823 }
824
825 if (count($array) > 0) {
826 print $form->selectarray('public', $array, GETPOSTINT('public') ? 1 : 0, 0, 0, 0, '', 0, 0, 0, '', '', 1);
827 } else {
828 print '<input type="hidden" name="public" id="public" value="'.(GETPOSTINT('public') ? 1 : 0).'">';
829
830 if (GETPOSTINT('public') == 0) {
831 print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
832 print $langs->trans("PrivateProject");
833 } else {
834 print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
835 print $langs->trans("SharedProject");
836 }
837 }
838 print '</td></tr>';
839
840 if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) {
841 // Opportunity status
842 print '<tr class="classuseopportunity"><td><span class="fieldrequired">'.$langs->trans("OpportunityStatus").'</span></td>';
843 print '<td class="maxwidthonsmartphone">';
844 print $formproject->selectOpportunityStatus('opp_status', GETPOSTISSET('opp_status') ? GETPOST('opp_status') : $object->opp_status, 1, 0, 0, 0, '', 0, 1);
845
846 // Opportunity probability
847 print ' <input class="width50 right" type="text" id="opp_percent" name="opp_percent" title="'.dol_escape_htmltag($langs->trans("OpportunityProbability")).'" value="'.dol_escape_htmltag(GETPOSTISSET('opp_percent') ? GETPOST('opp_percent') : '').'"><span class="hideonsmartphone"> %</span>';
848 print '<input type="hidden" name="opp_percent_not_set" id="opp_percent_not_set" value="'.dol_escape_htmltag(GETPOSTISSET('opp_percent') ? '0' : '1').'">';
849 print '</td>';
850 print '</tr>';
851
852 // Opportunity amount
853 print '<tr class="classuseopportunity"><td>'.$langs->trans("OpportunityAmount").'</td>';
854 print '<td><input class="width75 right" type="text" name="opp_amount" value="'.dol_escape_htmltag(GETPOSTISSET('opp_amount') ? GETPOST('opp_amount') : '').'">';
855 print ' '.$langs->getCurrencySymbol($conf->currency);
856 print '</td>';
857 print '</tr>';
858 }
859
860 // Budget
861 print '<tr><td>'.$langs->trans("Budget").'</td>';
862 print '<td><input class="width75 right" type="text" name="budget_amount" value="'.dol_escape_htmltag(GETPOSTISSET('budget_amount') ? GETPOST('budget_amount') : '').'">';
863 print ' '.$langs->getCurrencySymbol($conf->currency);
864 print '</td>';
865 print '</tr>';
866
867 // Date project
868 print '<tr><td>'.$langs->trans("Date").(isModEnabled('eventorganization') ? ' <span class="classuseorganizeevent">('.$langs->trans("Project").')</span>' : '').'</td><td>';
869 print $form->selectDate(($date_start ? $date_start : ''), 'projectstart', 0, 0, 0, '', 1, 0);
870 print ' <span class="opacitymedium"> '.$langs->trans("to").' </span> ';
871 print $form->selectDate(($date_end ? $date_end : -1), 'projectend', 0, 0, 0, '', 1, 0);
872 print '</td></tr>';
873
874 if (isModEnabled('eventorganization')) {
875 // Date event
876 print '<tr class="classuseorganizeevent"><td>'.$langs->trans("Date").' ('.$langs->trans("Event").')</td><td>';
877 print $form->selectDate(($date_start_event ? $date_start_event : -1), 'date_start_event', 1, 1, 1, '', 1, 0);
878 print ' <span class="opacitymedium"> '.$langs->trans("to").' </span> ';
879 print $form->selectDate(($date_end_event ? $date_end_event : -1), 'date_end_event', 1, 1, 1, '', 1, 0);
880 print '</td></tr>';
881
882 // Location
883 print '<tr class="classuseorganizeevent"><td>'.$langs->trans("Location").'</td>';
884 print '<td><input class="minwidth300 maxwidth500" type="text" name="location" value="'.dol_escape_htmltag($location).'"></td>';
885 print '</tr>';
886 }
887
888 // Description
889 print '<tr><td class="tdtop">'.$langs->trans("Description").'</td>';
890 print '<td>';
891 $doleditor = new DolEditor('description', GETPOST("description", 'restricthtml'), '', 90, 'dolibarr_notes', '', false, true, isModEnabled('fckeditor') && getDolGlobalString('FCKEDITOR_ENABLE_SOCIETE'), ROWS_3, '90%');
892 $doleditor->Create();
893 print '</td></tr>';
894
895 if (isModEnabled('category')) {
896 // Categories
897 print '<tr><td>'.$langs->trans("Categories").'</td><td colspan="3">';
898 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PROJECT, '', 'parent', 64, 0, 3);
899 $arrayselected = GETPOST('categories', 'array');
900 print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('categories', $cate_arbo, $arrayselected, 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
901 print "</td></tr>";
902 }
903
904 // Selection of Owner contact type
905 print '<tr><td class="tdtop">'.$langs->trans("ProjectContactTypeManager").'</td>';
906 print '<td>';
907 $contactList = $object->liste_type_contact('internal', 'position', 1);
908 $typeofcontact = GETPOST('typeofcontact') ? GETPOST('typeofcontact') : 'PROJECTLEADER';
909 print $form->selectarray('typeofcontact', $contactList, $typeofcontact, 0, 0, 0, '', 0, 0, 0, '', '', 1);
910 print '</td></tr>';
911
912 // Other options
913 $parameters = array();
914 $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
915 print $hookmanager->resPrint;
916 if (empty($reshook)) {
917 print $object->showOptionals($extrafields, 'create');
918 }
919
920 print '</table>';
921
922 print dol_get_fiche_end();
923
924 print $form->buttonsSaveCancel('CreateDraft');
925
926 print '</form>';
927
928 // Change probability from status or role of project
929 // Set also dependencies between use task and bill time
930 print '<script type="text/javascript">
931 jQuery(document).ready(function() {
932 function change_percent()
933 {
934 var element = jQuery("#opp_status option:selected");
935 var defaultpercent = element.attr("defaultpercent");
936 /*if (jQuery("#opp_percent_not_set").val() == "") */
937 jQuery("#opp_percent").val(defaultpercent);
938 }
939
940 /*init_myfunc();*/
941 jQuery("#opp_status").change(function() {
942 change_percent();
943 });
944
945 jQuery("#usage_task").change(function() {
946 console.log("We click on usage task "+jQuery("#usage_task").is(":checked"));
947 if (! jQuery("#usage_task").is(":checked")) {
948 jQuery("#usage_bill_time").prop("checked", false);
949 }
950 });
951
952 jQuery("#usage_bill_time").change(function() {
953 console.log("We click on usage to bill time");
954 if (jQuery("#usage_bill_time").is(":checked")) {
955 jQuery("#usage_task").prop("checked", true);
956 }
957 });
958 });
959 </script>';
960} elseif ($object->id > 0) {
961 /*
962 * Show or edit
963 */
964
965 $res = $object->fetch_optionals();
966
967 // To verify role of users
968 $userAccess = $object->restrictedProjectArea($user, 'read');
969 $userWrite = $object->restrictedProjectArea($user, 'write');
970 $userDelete = $object->restrictedProjectArea($user, 'delete');
971 //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete;
972
973 $formconfirm = "" ;
974
975 // Confirmation validation
976 if ($action == 'validate') {
977 $text = $langs->trans('ConfirmValidateProject');
978 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateProject'), $text, 'confirm_validate', '', 0, 1);
979 }
980 // Confirmation close
981 if ($action == 'close') {
982 $text = $langs->trans("ConfirmCloseAProject");
983 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("CloseAProject"), $text, "confirm_close", '', '', 1);
984 }
985 // Confirmation reopen
986 if ($action == 'reopen') {
987 $text = $langs->trans("ConfirmReOpenAProject");
988 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ReOpenAProject"), $text, "confirm_reopen", '', '', 1);
989 }
990 // Confirmation delete
991 if ($action == 'delete') {
992 $text = $langs->trans("ConfirmDeleteAProject");
993 $task = new Task($db);
994 $taskarray = $task->getTasksArray(null, null, $object->id, 0, 0);
995 $nboftask = count($taskarray);
996 if ($nboftask) {
997 $text .= '<br>'.img_warning().' '.$langs->trans("ThisWillAlsoRemoveTasks", $nboftask);
998 }
999 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("DeleteAProject"), $text, "confirm_delete", '', '', 1);
1000 }
1001
1002 // Clone confirmation
1003 if ($action == 'clone') {
1004 $text = $langs->trans("ConfirmCloneProject");
1005 $formquestion = array(
1006 'text' => $langs->trans("ConfirmClone"),
1007 0 => array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOSTINT('socid') > 0 ? GETPOSTINT('socid') : $object->socid, 'socid', '', "None", 0, 0, array(), 0, 'minwidth200 maxwidth250')),
1008 1 => array('type' => 'checkbox', 'name' => 'clone_contacts', 'label' => $langs->trans("CloneContacts"), 'value' => true),
1009 2 => array('type' => 'checkbox', 'name' => 'clone_tasks', 'label' => $langs->trans("CloneTasks"), 'value' => true),
1010 3 => array('type' => 'checkbox', 'name' => 'move_date', 'label' => $langs->trans("CloneMoveDate"), 'value' => true),
1011 4 => array('type' => 'checkbox', 'name' => 'clone_notes', 'label' => $langs->trans("CloneNotes"), 'value' => true),
1012 5 => array('type' => 'checkbox', 'name' => 'clone_project_files', 'label' => $langs->trans("CloneProjectFiles"), 'value' => false),
1013 6 => array('type' => 'checkbox', 'name' => 'clone_task_files', 'label' => $langs->trans("CloneTaskFiles"), 'value' => false)
1014 );
1015
1016 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ToClone"), $text, "confirm_clone", $formquestion, '', 1, 400, 590);
1017 }
1018
1019 // Call Hook formConfirm
1020 $parameters = array('formConfirm' => $formconfirm);
1021 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1022 if (empty($reshook)) {
1023 $formconfirm .= $hookmanager->resPrint;
1024 } elseif ($reshook > 0) {
1025 $formconfirm = $hookmanager->resPrint;
1026 }
1027
1028 // Print form confirm
1029 print $formconfirm;
1030
1031
1032 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
1033 print '<input type="hidden" name="token" value="'.newToken().'">';
1034 print '<input type="hidden" name="action" value="update">';
1035 print '<input type="hidden" name="id" value="'.$object->id.'">';
1036 print '<input type="hidden" name="comefromclone" value="'.$comefromclone.'">';
1037
1039
1040 if ($action == 'edit' && $userWrite > 0) {
1041 print dol_get_fiche_head($head, 'project', $langs->trans("Project"), 0, ($object->public ? 'projectpub' : 'project'));
1042
1043 print '<table class="border centpercent">';
1044
1045 // Ref
1046 $suggestedref = $object->ref;
1047 print '<tr><td class="titlefield fieldrequired">'.$langs->trans("Ref").'</td>';
1048 print '<td><input class="width200" name="ref" value="'.$suggestedref.'">';
1049 print ' '.$form->textwithpicto('', $langs->trans("YouCanCompleteRef", $suggestedref));
1050 print '</td></tr>';
1051
1052 // Label
1053 print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td>';
1054 print '<td><input class="quatrevingtpercent" name="title" value="'.dol_escape_htmltag($object->title).'"></td></tr>';
1055
1056 // Status
1057 print '<tr><td class="fieldrequired">'.$langs->trans("Status").'</td><td>';
1058 print '<select class="flat" name="status" id="status">';
1059 $statuses = $object->labelStatusShort;
1060 if (getDolGlobalString('MAIN_DISABLEDRAFTSTATUS') || getDolGlobalString('MAIN_DISABLEDRAFTSTATUS_PROJECT')) {
1061 unset($statuses[$object::STATUS_DRAFT]);
1062 }
1063 foreach ($statuses as $key => $val) {
1064 print '<option value="'.$key.'"'.((GETPOSTISSET('status') ? GETPOST('status') : $object->status) == $key ? ' selected="selected"' : '').'>'.$langs->trans($val).'</option>';
1065 }
1066 print '</select>';
1067 print ajax_combobox('status');
1068 print '</td></tr>';
1069
1070 // Parent
1071 if (getDolGlobalInt('PROJECT_ENABLE_SUB_PROJECT')) {
1072 print '<tr><td>'.$langs->trans("Parent").'</td><td class="maxwidthonsmartphone">';
1073 print img_picto('', 'project', 'class="pictofixedwidth"');
1074 $formproject->select_projects(-1, $object->fk_project, 'fk_project', 64, 0, 1, 1, 0, 0, 0, '', 0, 0, '', '', '');
1075 print '</td></tr>';
1076 }
1077
1078 // Usage
1079 if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES') || !getDolGlobalString('PROJECT_HIDE_TASKS') || isModEnabled('eventorganization')) {
1080 print '<tr><td class="tdtop">';
1081 print $langs->trans("Usage");
1082 print '</td>';
1083 print '<td>';
1084 if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) {
1085 print '<input type="checkbox" id="usage_opportunity" name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_opportunity ? ' checked="checked"' : '')).'> ';
1086 $htmltext = $langs->trans("ProjectFollowOpportunity");
1087 print '<label for="usage_opportunity">'.$form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext).'</label>';
1088 print '<script>';
1089 print '$( document ).ready(function() {
1090 jQuery("#usage_opportunity").change(function() {
1091 set_usage_opportunity();
1092 });
1093
1094 set_usage_opportunity();
1095
1096 function set_usage_opportunity() {
1097 console.log("set_usage_opportunity");
1098 if (jQuery("#usage_opportunity").prop("checked")) {
1099 console.log("Show opportunities fields");
1100 jQuery(".classuseopportunity").show();
1101 } else {
1102 console.log("Hide opportunities fields "+jQuery("#usage_opportunity").prop("checked"));
1103 jQuery(".classuseopportunity").hide();
1104 }
1105 }
1106 });';
1107 print '</script>';
1108 print '<br>';
1109 }
1110 if (!getDolGlobalString('PROJECT_HIDE_TASKS')) {
1111 print '<input type="checkbox" id="usage_task" name="usage_task"' . (GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_task ? ' checked="checked"' : '')) . '> ';
1112 $htmltext = $langs->trans("ProjectFollowTasks");
1113 print '<label for="usage_task">'.$form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext).'</label>';
1114 print '<script>';
1115 print '$( document ).ready(function() {
1116 jQuery("#usage_task").change(function() {
1117 set_usage_task();
1118 });
1119
1120 set_usage_task();
1121
1122 function set_usage_task() {
1123 console.log("set_usage_task");
1124 if (jQuery("#usage_task").prop("checked")) {
1125 console.log("Show task fields");
1126 jQuery(".classusetask").show();
1127 } else {
1128 console.log("Hide task fields "+jQuery("#usage_task").prop("checked"));
1129 jQuery(".classusetask").hide();
1130 }
1131 }
1132 });';
1133 print '</script>';
1134 print '<br>';
1135 }
1136 if (!getDolGlobalString('PROJECT_HIDE_TASKS') && getDolGlobalString('PROJECT_BILL_TIME_SPENT')) {
1137 print '<input type="checkbox" id="usage_bill_time" name="usage_bill_time"' . (GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_bill_time ? ' checked="checked"' : '')) . '> ';
1138 $htmltext = $langs->trans("ProjectBillTimeDescription");
1139 print '<label for="usage_bill_time">'.$form->textwithpicto($langs->trans("BillTime"), $htmltext).'</label>';
1140 print '<script>';
1141 print '$( document ).ready(function() {
1142 jQuery("#usage_bill_time").change(function() {
1143 set_usage_bill_time();
1144 });
1145
1146 set_usage_bill_time();
1147
1148 function set_usage_bill_time() {
1149 console.log("set_usage_bill_time");
1150 if (jQuery("#usage_bill_time").prop("checked")) {
1151 console.log("Show bill time fields");
1152 jQuery(".classusebilltime").show();
1153 } else {
1154 console.log("Hide bill time fields "+jQuery("#usage_bill_time").prop("checked"));
1155 jQuery(".classusebilltime").hide();
1156 }
1157 }
1158 });';
1159 print '</script>';
1160 print '<br>';
1161 }
1162 if (isModEnabled('eventorganization')) {
1163 print '<input type="checkbox" id="usage_organize_event" name="usage_organize_event"'. (GETPOSTISSET('usage_organize_event') ? (GETPOST('usage_organize_event', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_organize_event ? ' checked="checked"' : '')) . '> ';
1164 $htmltext = $langs->trans("EventOrganizationDescriptionLong");
1165 print '<label for="usage_organize_event">'.$form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext).'</label>';
1166 print '<script>';
1167 print '$( document ).ready(function() {
1168 jQuery("#usage_organize_event").change(function() {
1169 set_usage_event();
1170 });
1171
1172 set_usage_event();
1173
1174 function set_usage_event() {
1175 console.log("set_usage_event");
1176 if (jQuery("#usage_organize_event").prop("checked")) {
1177 console.log("Show organize event fields");
1178 jQuery(".classuseorganizeevent").show();
1179 } else {
1180 console.log("Hide organize event fields "+jQuery("#usage_organize_event").prop("checked"));
1181 jQuery(".classuseorganizeevent").hide();
1182 }
1183 }
1184 });';
1185 print '</script>';
1186 }
1187 print '</td></tr>';
1188 }
1189 print '</td></tr>';
1190
1191 // Thirdparty
1192 if (isModEnabled('societe')) {
1193 print '<tr><td>';
1194 print(!getDolGlobalString('PROJECT_THIRDPARTY_REQUIRED') ? '' : '<span class="fieldrequired">');
1195 print $langs->trans("ThirdParty");
1196 print(!getDolGlobalString('PROJECT_THIRDPARTY_REQUIRED') ? '' : '</span>');
1197 print '</td><td>';
1198 $filter = '';
1199 if (getDolGlobalString('PROJECT_FILTER_FOR_THIRDPARTY_LIST')) {
1200 $filter = getDolGlobalString('PROJECT_FILTER_FOR_THIRDPARTY_LIST');
1201 }
1202 $text = img_picto('', 'company', 'class="pictofixedwidth"');
1203 $text .= $form->select_company(!empty($object->thirdparty->id) ? $object->thirdparty->id : "", 'socid', $filter, 'None', 1, 0, array(), 0, 'minwidth300');
1204 if (!getDolGlobalString('PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') && empty($conf->dol_use_jmobile)) {
1205 $texthelp = $langs->trans("IfNeedToUseOtherObjectKeepEmpty");
1206 print $form->textwithtooltip($text.' '.img_help(), $texthelp, 1, 0, '', '', 2);
1207 } else {
1208 print $text;
1209 }
1210 print '</td></tr>';
1211 }
1212
1213 // Visibility
1214 print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
1215 $array = array();
1216 if (!getDolGlobalString('PROJECT_DISABLE_PRIVATE_PROJECT')) {
1217 $array[0] = $langs->trans("PrivateProject");
1218 }
1219 if (!getDolGlobalString('PROJECT_DISABLE_PUBLIC_PROJECT')) {
1220 $array[1] = $langs->trans("SharedProject");
1221 }
1222
1223 if (count($array) > 0) {
1224 print $form->selectarray('public', $array, $object->public, 0, 0, 0, '', 0, 0, 0, '', '', 1);
1225 } else {
1226 print '<input type="hidden" id="public" name="public" value="'.$object->public.'">';
1227
1228 if ($object->public == 0) {
1229 print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
1230 print $langs->trans("PrivateProject");
1231 } else {
1232 print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
1233 print $langs->trans("SharedProject");
1234 }
1235 }
1236 print '</td></tr>';
1237
1238 if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) {
1239 $classfortr = ($object->usage_opportunity ? '' : ' hideobject');
1240 // Opportunity status
1241 print '<tr class="classuseopportunity'.$classfortr.'"><td>'.$langs->trans("OpportunityStatus").'</td>';
1242 print '<td>';
1243 print '<div>';
1244 print $formproject->selectOpportunityStatus('opp_status', $object->opp_status, 1, 0, 0, 0, 'minwidth150 inline-block valignmiddle', 1, 1);
1245
1246 // Opportunity probability
1247 print ' <input class="width50 right" type="text" id="opp_percent" name="opp_percent" title="'.dol_escape_htmltag($langs->trans("OpportunityProbability")).'" value="'.(GETPOSTISSET('opp_percent') ? GETPOST('opp_percent') : (strcmp($object->opp_percent, '') ? vatrate($object->opp_percent) : '')).'"> %';
1248 print '<span id="oldopppercent" class="opacitymedium"></span>';
1249 print '</div>';
1250
1251 print '<div id="divtocloseproject" class="inline-block valign clearboth paddingtop" style="display: none;">';
1252 print '<input type="checkbox" id="inputcloseproject" name="closeproject" />';
1253 print '<label for="inputcloseproject">';
1254 print $form->textwithpicto($langs->trans("AlsoCloseAProject"), $langs->trans("AlsoCloseAProjectTooltip")).'</label>';
1255 print ' </div>';
1256
1257 print '</td>';
1258 print '</tr>';
1259
1260 // Opportunity amount
1261 print '<tr class="classuseopportunity'.$classfortr.'"><td>'.$langs->trans("OpportunityAmount").'</td>';
1262 print '<td><input class="width75 right" type="text" name="opp_amount" value="'.(GETPOSTISSET('opp_amount') ? GETPOST('opp_amount') : (strcmp($object->opp_amount, '') ? price2num($object->opp_amount) : '')).'">';
1263 print $langs->getCurrencySymbol($conf->currency);
1264 print '</td>';
1265 print '</tr>';
1266 }
1267
1268 // Budget
1269 print '<tr><td>'.$langs->trans("Budget").'</td>';
1270 print '<td><input class="width75 right" type="text" name="budget_amount" value="'.(GETPOSTISSET('budget_amount') ? GETPOST('budget_amount') : (strcmp($object->budget_amount, '') ? price2num($object->budget_amount) : '')).'">';
1271 print $langs->getCurrencySymbol($conf->currency);
1272 print '</td>';
1273 print '</tr>';
1274
1275 // Date project
1276 print '<tr><td>'.$langs->trans("Date").(isModEnabled('eventorganization') ? ' <span class="classuseorganizeevent">('.$langs->trans("Project").')</span>' : '').'</td><td>';
1277 print $form->selectDate($object->date_start ? $object->date_start : -1, 'projectstart', 0, 0, 0, '', 1, 0);
1278 print ' <span class="opacitymedium"> '.$langs->trans("to").' </span> ';
1279 print $form->selectDate($object->date_end ? $object->date_end : -1, 'projectend', 0, 0, 0, '', 1, 0);
1280 $object->getLinesArray(null, 0);
1281 if (!empty($object->usage_task) && !empty($object->lines)) {
1282 print ' <span id="divreportdate" class="hidden">&nbsp; &nbsp; <input type="checkbox" class="valignmiddle" id="reportdate" name="reportdate" value="yes" ';
1283 if ($comefromclone) {
1284 print 'checked ';
1285 }
1286 print '/><label for="reportdate" class="valignmiddle opacitymedium">'.$langs->trans("ProjectReportDate").'</label></span>';
1287 }
1288 print '</td></tr>';
1289
1290 if (isModEnabled('eventorganization')) {
1291 // Date event
1292 print '<tr class="classuseorganizeevent"><td>'.$langs->trans("Date").' ('.$langs->trans("Event").')</td><td>';
1293 print $form->selectDate(($date_start_event ? $date_start_event : ($object->date_start_event ? $object->date_start_event : -1)), 'date_start_event', 1, 1, 1, '', 1, 0);
1294 print ' <span class="opacitymedium"> '.$langs->trans("to").' </span> ';
1295 print $form->selectDate(($date_end_event ? $date_end_event : ($object->date_end_event ? $object->date_end_event : -1)), 'date_end_event', 1, 1, 1, '', 1, 0);
1296 print '</td></tr>';
1297
1298 // Location
1299 print '<tr class="classuseorganizeevent"><td>'.$langs->trans("Location").'</td>';
1300 print '<td><input class="minwidth300 maxwidth500" type="text" name="location" value="'.dol_escape_htmltag(GETPOSTISSET('location') ? GETPOST('location') : $object->location).'"></td>';
1301 print '</tr>';
1302 }
1303
1304 // Description
1305 print '<tr><td class="tdtop">'.$langs->trans("Description").'</td>';
1306 print '<td>';
1307 $doleditor = new DolEditor('description', $object->description, '', 90, 'dolibarr_notes', '', false, true, isModEnabled('fckeditor') && getDolGlobalInt('FCKEDITOR_ENABLE_SOCIETE'), ROWS_3, '90%');
1308 $doleditor->Create();
1309 print '</td></tr>';
1310
1311 // Tags-Categories
1312 if (isModEnabled('category')) {
1313 $arrayselected = array();
1314 print '<tr><td>'.$langs->trans("Categories").'</td><td>';
1315 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PROJECT, '', 'parent', 64, 0, 3);
1316 $c = new Categorie($db);
1317 $cats = $c->containing($object->id, Categorie::TYPE_PROJECT);
1318 foreach ($cats as $cat) {
1319 $arrayselected[] = $cat->id;
1320 }
1321 print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('categories', $cate_arbo, $arrayselected, 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, '0');
1322 print "</td></tr>";
1323 }
1324
1325 // Other options
1326 $parameters = array();
1327 $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1328 print $hookmanager->resPrint;
1329 if (empty($reshook)) {
1330 print $object->showOptionals($extrafields, 'edit');
1331 }
1332
1333 print '</table>';
1334 } else {
1335 print dol_get_fiche_head($head, 'project', $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project'), 0, '', '', 0, '', 1);
1336
1337 // Project card
1338
1339 if (!empty($_SESSION['pageforbacktolist']) && !empty($_SESSION['pageforbacktolist']['project'])) {
1340 $tmpurl = $_SESSION['pageforbacktolist']['project'];
1341 $tmpurl = preg_replace('/__SOCID__/', (string) $object->socid, $tmpurl);
1342 $linkback = '<a href="'.$tmpurl.(preg_match('/\?/', $tmpurl) ? '&' : '?'). 'restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
1343 } else {
1344 $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
1345 }
1346
1347 $morehtmlref = '<div class="refidno">';
1348 // Title
1349 $morehtmlref .= dol_escape_htmltag($object->title);
1350 $morehtmlref .= '<br>';
1351 // Thirdparty
1352 if (!empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
1353 $morehtmlref .= $object->thirdparty->getNomUrl(1, 'project');
1354 }
1355 // Parent
1356 if (getDolGlobalInt('PROJECT_ENABLE_SUB_PROJECT')) {
1357 if (!empty($object->fk_project) && $object->fk_project) {
1358 $parent = new Project($db);
1359 $parent->fetch($object->fk_project);
1360 $morehtmlref .= $langs->trans("Child of").' '.$parent->getNomUrl(1, 'project').' '.$parent->title;
1361 }
1362 }
1363 $morehtmlref .= '</div>';
1364
1365 // Define a complementary filter for search of next/prev ref.
1366 if (!$user->hasRight('projet', 'all', 'lire')) {
1367 $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
1368 $object->next_prev_filter = "rowid:IN:(".$db->sanitize(count($objectsListId) ? implode(',', array_keys($objectsListId)) : '0').")";
1369 }
1370
1371 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
1372
1373 print '<div class="fichecenter">';
1374 print '<div class="fichehalfleft">';
1375 print '<div class="underbanner clearboth"></div>';
1376
1377 print '<table class="border tableforfield centpercent">';
1378
1379 // Usage
1380 if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES') || !getDolGlobalString('PROJECT_HIDE_TASKS') || isModEnabled('eventorganization')) {
1381 print '<tr><td class="tdtop">';
1382 print $langs->trans("Usage");
1383 print '</td>';
1384 print '<td>';
1385 if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) {
1386 print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_opportunity ? ' checked="checked"' : '')).'> ';
1387 $htmltext = $langs->trans("ProjectFollowOpportunity");
1388 print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext);
1389 print '<br>';
1390 }
1391 if (!getDolGlobalString('PROJECT_HIDE_TASKS')) {
1392 print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_task ? ' checked="checked"' : '')).'> ';
1393 $htmltext = $langs->trans("ProjectFollowTasks");
1394 print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext);
1395 print '<br>';
1396 }
1397 if (!getDolGlobalString('PROJECT_HIDE_TASKS') && getDolGlobalString('PROJECT_BILL_TIME_SPENT')) {
1398 print '<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_bill_time ? ' checked="checked"' : '')).'> ';
1399 $htmltext = $langs->trans("ProjectBillTimeDescription");
1400 print $form->textwithpicto($langs->trans("BillTime"), $htmltext);
1401 print '<br>';
1402 }
1403
1404 if (isModEnabled('eventorganization')) {
1405 print '<input type="checkbox" disabled name="usage_organize_event"'.(GETPOSTISSET('usage_organize_event') ? (GETPOST('usage_organize_event', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_organize_event ? ' checked="checked"' : '')).'> ';
1406 $htmltext = $langs->trans("EventOrganizationDescriptionLong");
1407 print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext);
1408 }
1409 print '</td></tr>';
1410 }
1411
1412 // Visibility
1413 print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
1414 if ($object->public) {
1415 print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
1416 print $langs->trans('SharedProject');
1417 } else {
1418 print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
1419 print $langs->trans('PrivateProject');
1420 }
1421 print '</td></tr>';
1422
1423 if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES') && !empty($object->usage_opportunity)) {
1424 // Opportunity status
1425 print '<tr><td>'.$langs->trans("OpportunityStatus");
1426 if ($action != 'edit_opp_status' && $user->hasRight('projet', 'creer')) {
1427 print '<a class="editfielda paddingtop" href="'.$_SERVER["PHP_SELF"].'?action=edit_opp_status&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'</a>';
1428 }
1429 print '</td><td>';
1430 $html_name_status = ($action == 'edit_opp_status') ? 'opp_status' : 'none';
1431 $html_name_percent = ($action == 'edit_opp_status') ? 'opp_percent' : 'none';
1432 $percent_value = (GETPOSTISSET('opp_percent') ? GETPOST('opp_percent') : (strcmp($object->opp_percent, '') ? vatrate($object->opp_percent) : ''));
1433 $formproject->formOpportunityStatus($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->opp_status, $percent_value, $html_name_status, $html_name_percent);
1434 print '</td></tr>';
1435
1436 // Opportunity Amount
1437 print '<tr><td>'.$langs->trans("OpportunityAmount").'</td><td>';
1438 if (strcmp($object->opp_amount, '')) {
1439 print '<span class="amount">'.price($object->opp_amount, 0, $langs, 1, 0, -1, $conf->currency).'</span>';
1440 if (strcmp($object->opp_percent, '')) {
1441 print ' &nbsp; &nbsp; &nbsp; <span title="'.dol_escape_htmltag($langs->trans('OpportunityWeightedAmount')).'"><span class="opacitymedium">'.$langs->trans("OpportunityWeightedAmountShort").'</span>: <span class="amount">'.price($object->opp_amount * $object->opp_percent / 100, 0, $langs, 1, 0, -1, $conf->currency).'</span></span>';
1442 }
1443 }
1444 print '</td></tr>';
1445 }
1446
1447 // Budget
1448 print '<tr><td>'.$langs->trans("Budget").'</td><td>';
1449 if (!is_null($object->budget_amount) && strcmp($object->budget_amount, '')) {
1450 print '<span class="amount">'.price($object->budget_amount, 0, $langs, 1, 0, 0, $conf->currency).'</span>';
1451 }
1452 print '</td></tr>';
1453
1454 // Date start - end project
1455 print '<tr><td>'.$langs->trans("Dates").'</td><td>';
1456 $start = dol_print_date($object->date_start, 'day');
1457 print($start ? $start : '?');
1458 $end = dol_print_date($object->date_end, 'day');
1459 print ' <span class="opacitymedium">-</span> ';
1460 print($end ? $end : '?');
1461 if ($object->hasDelay()) {
1462 print img_warning("Late");
1463 }
1464 print '</td></tr>';
1465
1466 // Other attributes
1467 $cols = 2;
1468 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
1469
1470 print '</table>';
1471
1472 print '</div>';
1473 print '<div class="fichehalfright">';
1474 print '<div class="underbanner clearboth"></div>';
1475
1476 print '<table class="border tableforfield centpercent">';
1477
1478 // Description
1479 print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
1480 print '<div class="longmessagecut">';
1481 print dolPrintHTML($object->description);
1482 print '</div>';
1483 print '</td></tr>';
1484
1485 // Categories
1486 if (isModEnabled('category')) {
1487 print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
1488 print $form->showCategories($object->id, Categorie::TYPE_PROJECT, 1);
1489 print "</td></tr>";
1490 }
1491
1492 print '</table>';
1493
1494 print '</div>';
1495 print '</div>';
1496
1497 print '<div class="clearboth"></div>';
1498 }
1499
1500 print dol_get_fiche_end();
1501
1502 if ($action == 'edit' && $userWrite > 0) {
1503 print $form->buttonsSaveCancel();
1504 }
1505
1506 print '</form>';
1507
1508 // Set also dependencies between use task and bill time
1509 print '<script type="text/javascript">
1510 jQuery(document).ready(function() {
1511 jQuery("#usage_task").change(function() {
1512 console.log("We click on usage task "+jQuery("#usage_task").is(":checked"));
1513 if (! jQuery("#usage_task").is(":checked")) {
1514 jQuery("#usage_bill_time").prop("checked", false);
1515 }
1516 });
1517
1518 jQuery("#usage_bill_time").change(function() {
1519 console.log("We click on usage to bill time");
1520 if (jQuery("#usage_bill_time").is(":checked")) {
1521 jQuery("#usage_task").prop("checked", true);
1522 }
1523 });
1524
1525 jQuery("#projectstart").change(function() {
1526 console.log("We modify the start date");
1527 jQuery("#divreportdate").show();
1528 });
1529 });
1530 </script>';
1531
1532 // Change probability from status
1533 if (!empty($conf->use_javascript_ajax) && getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) {
1534 // Default value to close or not when we set opp to 'WON'.
1535 $defaultcheckedwhenoppclose = 1;
1536 if (!getDolGlobalString('PROJECT_HIDE_TASKS')) {
1537 $defaultcheckedwhenoppclose = 0;
1538 }
1539
1540 print '<!-- Javascript to manage opportunity status change -->';
1541 print '<script type="text/javascript">
1542 jQuery(document).ready(function() {
1543 function change_percent()
1544 {
1545 var element = jQuery("#opp_status option:selected");
1546 var defaultpercent = element.attr("defaultpercent");
1547 var defaultcloseproject = '.((int) $defaultcheckedwhenoppclose).';
1548 var elemcode = element.attr("elemcode");
1549 var oldpercent = \''.dol_escape_js($object->opp_percent).'\';
1550
1551 console.log("We select "+elemcode);
1552
1553 /* Define if checkbox to close is checked or not */
1554 var closeproject = 0;
1555 if (elemcode == \'LOST\') closeproject = 1;
1556 if (elemcode == \'WON\') closeproject = defaultcloseproject;
1557 if (closeproject) jQuery("#inputcloseproject").prop("checked", true);
1558 else jQuery("#inputcloseproject").prop("checked", false);
1559
1560 /* Make the close project checkbox visible or not */
1561 console.log("closeproject="+closeproject);
1562 if (elemcode == \'WON\' || elemcode == \'LOST\')
1563 {
1564 jQuery("#divtocloseproject").show();
1565 }
1566 else
1567 {
1568 jQuery("#divtocloseproject").hide();
1569 }
1570
1571 /* Change percent with default percent (defaultpercent) if new status (defaultpercent) is higher than current (jQuery("#opp_percent").val()) */
1572 if (oldpercent != \'\' && (parseFloat(defaultpercent) < parseFloat(oldpercent)))
1573 {
1574 console.log("oldpercent="+oldpercent+" defaultpercent="+defaultpercent+" def < old");
1575 if (jQuery("#opp_percent").val() != \'\' && oldpercent != \'\') {
1576 jQuery("#oldopppercent").text(\' - '.dol_escape_js($langs->transnoentities("PreviousValue")).': \'+price2numjs(oldpercent)+\' %\');
1577 }
1578
1579 if (parseFloat(oldpercent) != 100 && elemcode != \'LOST\') { jQuery("#opp_percent").val(oldpercent); }
1580 else { jQuery("#opp_percent").val(price2numjs(defaultpercent)); }
1581 } else {
1582 console.log("oldpercent="+oldpercent+" defaultpercent="+defaultpercent);
1583 if (jQuery("#opp_percent").val() == \'\' || (parseFloat(jQuery("#opp_percent").val()) < parseFloat(defaultpercent))) {
1584 if (jQuery("#opp_percent").val() != \'\' && oldpercent != \'\') {
1585 jQuery("#oldopppercent").text(\' - '.dol_escape_js($langs->transnoentities("PreviousValue")).': \'+price2numjs(oldpercent)+\' %\');
1586 }
1587 jQuery("#opp_percent").val(price2numjs(defaultpercent));
1588 }
1589 }
1590 }
1591
1592 jQuery("#opp_status").change(function() {
1593 change_percent();
1594 });
1595 });
1596 </script>';
1597 }
1598
1599
1600 /*
1601 * Actions Buttons
1602 */
1603
1604 print '<div class="tabsAction">';
1605 $parameters = array();
1606 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
1607 // modified by hook
1608 if (empty($reshook)) {
1609 if ($action != "edit" && $action != 'presend') {
1610 // Create event
1611 /*if (isModEnabled('agenda') && !empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a
1612 // "workflow" action so should appears somewhere else on
1613 // page.
1614 {
1615 print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&amp;origin=' . $object->element . '&amp;originid=' . $object->id . '&amp;socid=' . $object->socid . '&amp;projectid=' . $object->id . '">' . $langs->trans("AddAction") . '</a>';
1616 }*/
1617
1618 // Send
1619 if (empty($user->socid)) {
1620 if ($object->status != Project::STATUS_CLOSED) {
1621 print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER["PHP_SELF"].'?action=presend&token='.newToken().'&id='.$object->id.'&mode=init#formmailbeforetitle', '');
1622 }
1623 }
1624
1625 // Accounting Report
1626 /*
1627 $accouting_module_activated = isModEnabled('comptabilite') || isModEnabled('accounting');
1628 if ($accouting_module_activated && $object->status != Project::STATUS_DRAFT) {
1629 $start = dol_getdate((int) $object->date_start);
1630 $end = dol_getdate((int) $object->date_end);
1631 $url = DOL_URL_ROOT.'/compta/accounting-files.php?projectid='.$object->id;
1632 if (!empty($object->date_start)) $url .= '&amp;date_startday='.$start['mday'].'&amp;date_startmonth='.$start['mon'].'&amp;date_startyear='.$start['year'];
1633 if (!empty($object->date_end)) $url .= '&amp;date_stopday='.$end['mday'].'&amp;date_stopmonth='.$end['mon'].'&amp;date_stopyear='.$end['year'];
1634 print dolGetButtonAction('', $langs->trans('ExportAccountingReportButtonLabel'), 'default', $url, '');
1635 }
1636 */
1637
1638 // Back to draft
1639 if (!getDolGlobalString('MAIN_DISABLEDRAFTSTATUS') && !getDolGlobalString('MAIN_DISABLEDRAFTSTATUS_PROJECT')) {
1640 if ($object->status != Project::STATUS_DRAFT && $user->hasRight('projet', 'creer')) {
1641 if ($userWrite > 0) {
1642 print dolGetButtonAction('', $langs->trans('SetToDraft'), 'default', $_SERVER["PHP_SELF"].'?action=confirm_setdraft&amp;confirm=yes&amp;token='.newToken().'&amp;id='.$object->id, '');
1643 } else {
1644 print dolGetButtonAction($langs->trans('NotOwnerOfProject'), $langs->trans('SetToDraft'), 'default', $_SERVER['PHP_SELF']. '#', '', false);
1645 }
1646 }
1647 }
1648
1649 // Modify
1650 if ($object->status != Project::STATUS_CLOSED && $user->hasRight('projet', 'creer')) {
1651 if ($userWrite > 0) {
1652 print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'&id='.$object->id, '');
1653 } else {
1654 print dolGetButtonAction($langs->trans('NotOwnerOfProject'), $langs->trans('Modify'), 'default', $_SERVER['PHP_SELF']. '#', '', false);
1655 }
1656 }
1657
1658 // Validate
1659 if ($object->status == Project::STATUS_DRAFT && $user->hasRight('projet', 'creer')) {
1660 if ($userWrite > 0) {
1661 print dolGetButtonAction('', $langs->trans('Validate'), 'default', $_SERVER["PHP_SELF"].'?action=validate&amp;token='.newToken().'&amp;id='.$object->id, '');
1662 } else {
1663 print dolGetButtonAction($langs->trans('NotOwnerOfProject'), $langs->trans('Validate'), 'default', $_SERVER['PHP_SELF']. '#', '', false);
1664 }
1665 }
1666
1667 // Close
1668 if ($object->status == Project::STATUS_VALIDATED && $user->hasRight('projet', 'creer')) {
1669 if ($userWrite > 0) {
1670 print dolGetButtonAction('', $langs->trans('Close'), 'default', $_SERVER["PHP_SELF"].'?action=close&amp;token='.newToken().'&amp;id='.$object->id, '');
1671 } else {
1672 print dolGetButtonAction($langs->trans('NotOwnerOfProject'), $langs->trans('Close'), 'default', $_SERVER['PHP_SELF']. '#', '', false);
1673 }
1674 }
1675
1676 // Reopen
1677 if ($object->status == Project::STATUS_CLOSED && $user->hasRight('projet', 'creer')) {
1678 if ($userWrite > 0) {
1679 print dolGetButtonAction('', $langs->trans('ReOpen'), 'default', $_SERVER["PHP_SELF"].'?action=reopen&amp;token='.newToken().'&amp;id='.$object->id, '');
1680 } else {
1681 print dolGetButtonAction($langs->trans('NotOwnerOfProject'), $langs->trans('ReOpen'), 'default', $_SERVER['PHP_SELF']. '#', '', false);
1682 }
1683 }
1684
1685
1686 // Buttons Create
1687 if (!getDolGlobalString('PROJECT_HIDE_CREATE_OBJECT_BUTTON')) {
1688 $arrayforbutaction = array(
1689 //1 => array('lang' => 'propal', 'enabled' => 1, 'perm' => 1, 'label' => 'XXX'),
1690 10 => array('lang' => 'propal', 'enabled' => isModEnabled("propal"), 'perm' => $user->hasRight('propal', 'creer') ? true : false, 'label' => 'AddProp', 'url' => '/comm/propal/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid),
1691 20 => array('lang' => 'orders', 'enabled' => isModEnabled("order"), 'perm' => $user->hasRight('commande', 'creer') ? true : false, 'label' => 'CreateOrder', 'url' => '/commande/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid),
1692 30 => array('lang' => 'bills', 'enabled' => isModEnabled("invoice"), 'perm' => $user->hasRight('facture', 'creer') ? true : false, 'label' => 'CreateBill', 'url' => '/compta/facture/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid),
1693 40 => array('lang' => 'supplier_proposal', 'enabled' => isModEnabled("supplier_proposal"), 'perm' => $user->hasRight('supplier_proposal', 'creer') ? true : false, 'label' => 'AddSupplierProposal', 'url' => '/supplier_proposal/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid),
1694 50 => array('lang' => 'suppliers', 'enabled' => isModEnabled("supplier_order"), 'perm' => $user->hasRight('fournisseur', 'commande', 'creer') ? true : false, 'label' => 'AddSupplierOrder', 'url' => '/fourn/commande/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid),
1695 60 => array('lang' => 'suppliers', 'enabled' => isModEnabled("supplier_invoice"), 'perm' => $user->hasRight('fournisseur', 'facture', 'creer') ? true : false, 'label' => 'AddSupplierInvoice', 'url' => '/fourn/facture/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid),
1696 70 => array('lang' => 'interventions', 'enabled' => isModEnabled("intervention"), 'perm' => $user->hasRight('fichinter', 'creer') ? true : false, 'label' => 'AddIntervention', 'url' => '/fichinter/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid),
1697 80 => array('lang' => 'contracts', 'enabled' => isModEnabled("contract"), 'perm' => $user->hasRight('contrat', 'creer') ? true : false, 'label' => 'AddContract', 'url' => '/contrat/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid),
1698 90 => array('lang' => 'trips', 'enabled' => isModEnabled("expensereport"), 'perm' => $user->hasRight('expensereport', 'creer') ? true : false, 'label' => 'AddTrip', 'url' => '/expensereport/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid),
1699 100 => array('lang' => 'donations', 'enabled' => isModEnabled("don"), 'perm' => $user->hasRight('don', 'creer') ? true : false, 'label' => 'AddDonation', 'url' => '/don/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid),
1700 );
1701
1702 $params = array('backtopage' => $_SERVER["PHP_SELF"].'?id='.$object->id);
1703 //$params = array('backtopage' => $_SERVER["PHP_SELF"].'?id='.$object->id, 'isDropDown' => true);
1704
1705 print dolGetButtonAction('', $langs->trans("Create"), 'default', $arrayforbutaction, '', 1, $params);
1706 }
1707
1708 // Clone
1709 if ($user->hasRight('projet', 'creer')) {
1710 if ($userWrite > 0) {
1711 print dolGetButtonAction('', $langs->trans('ToClone'), 'default', $_SERVER["PHP_SELF"].'?action=clone&token='.newToken().'&id='.((int) $object->id), '');
1712 } else {
1713 print dolGetButtonAction($langs->trans('NotOwnerOfProject'), $langs->trans('ToClone'), 'default', $_SERVER['PHP_SELF']. '#', '', false);
1714 }
1715 }
1716
1717 // Delete
1718 if ($user->hasRight('projet', 'supprimer') || ($object->status == Project::STATUS_DRAFT && $user->hasRight('projet', 'creer'))) {
1719 if ($userDelete > 0 || ($object->status == Project::STATUS_DRAFT && $user->hasRight('projet', 'creer'))) {
1720 print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$object->id, '');
1721 } else {
1722 print dolGetButtonAction($langs->trans('NotOwnerOfProject'), $langs->trans('Delete'), 'default', $_SERVER['PHP_SELF']. '#', '', false);
1723 }
1724 }
1725 }
1726 }
1727
1728 print "</div>";
1729
1730 if (GETPOST('modelselected')) {
1731 $action = 'presend';
1732 }
1733
1734 if ($action != 'presend') {
1735 print '<div class="fichecenter"><div class="fichehalfleft">';
1736 print '<a name="builddoc"></a>'; // ancre
1737
1738 if (getDolGlobalInt('PROJECT_ENABLE_SUB_PROJECT')) {
1739 /*
1740 * Sub-projects (children)
1741 */
1742 $children = $object->getChildren();
1743 if ($children) {
1744 print '<table class="centpercent notopnoleftnoright table-fiche-title">';
1745 print '<tr class="titre"><td class="nobordernopadding valignmiddle col-title">';
1746 print '<div class="titre inline-block">'.$langs->trans('Sub-projects').'</div>';
1747 print '</td></tr></table>';
1748
1749 print '<div class="div-table-responsive-no-min">';
1750 print '<table class="centpercent noborder'.($morecss ? ' '.$morecss : '').'">';
1751 print '<tr class="liste_titre">';
1752 print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', '', '', '', '', '', '', 1);
1753 print getTitleFieldOfList('Title', 0, $_SERVER["PHP_SELF"], '', '', '', '', '', '', '', 1);
1754 print getTitleFieldOfList('Status', 0, $_SERVER["PHP_SELF"], '', '', '', '', '', '', '', 1);
1755 print '</tr>';
1756 print "\n";
1757
1758 $subproject = new Project($db);
1759 foreach ($children as $child) {
1760 $subproject->fetch($child->rowid);
1761 print '<tr class="oddeven">';
1762 print '<td class="nowraponall">'.$subproject->getNomUrl(1, 'project').'</td>';
1763 print '<td class="nowraponall tdoverflowmax125">'.$child->title.'</td>';
1764 print '<td class="nowraponall">'.$subproject->getLibStatut(5).'</td>';
1765 print '</tr>';
1766 }
1767
1768 print '</table>';
1769 print '</div>';
1770 }
1771 }
1772
1773 /*
1774 * Generated documents
1775 */
1776 $filename = dol_sanitizeFileName($object->ref);
1777 $filedir = $conf->project->multidir_output[$object->entity]."/".dol_sanitizeFileName($object->ref);
1778 $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
1779 $genallowed = ($user->hasRight('projet', 'lire') && $userAccess > 0);
1780 $delallowed = ($user->hasRight('projet', 'creer') && $userWrite > 0);
1781
1782 print $formfile->showdocuments('project', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 0, 0, '', '', '', '', '', $object);
1783
1784 print '</div><div class="fichehalfright">';
1785
1786 $MAXEVENT = 10;
1787
1788 $morehtmlcenter = '<div class="nowraponall">';
1789 $morehtmlcenter .= dolGetButtonTitle($langs->trans('FullConversation'), '', 'fa fa-comments imgforviewmode', DOL_URL_ROOT.'/projet/messaging.php?id='.$object->id);
1790 $morehtmlcenter .= dolGetButtonTitle($langs->trans('FullList'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/projet/agenda.php?id='.$object->id);
1791 $morehtmlcenter .= '</div>';
1792
1793 // List of actions on element
1794 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
1795 $formactions = new FormActions($db);
1796 $somethingshown = $formactions->showactions($object, 'project', 0, 1, '', $MAXEVENT, '', $morehtmlcenter);
1797
1798 print '</div></div>';
1799 }
1800
1801 // Presend form
1802 $modelmail = 'project';
1803 $defaulttopic = 'SendProjectRef';
1804 $defaulttopiclang = 'projects';
1805 $diroutput = $conf->project->multidir_output[$object->entity];
1806 $autocopy = 'MAIN_MAIL_AUTOCOPY_PROJECT_TO'; // used to know the automatic BCC to add
1807 $trackid = 'proj'.$object->id;
1808
1809 include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
1810
1811 // Hook to add more things on page
1812 $parameters = array();
1813 $reshook = $hookmanager->executeHooks('mainCardTabAddMore', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1814} else {
1815 print $langs->trans("RecordNotFound");
1816}
1817
1818// End of page
1819llxFooter();
1820$db->close();
$id
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
Definition ajax.lib.php:459
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 categories.
Class to manage a WYSIWYG editor.
Class to manage standard extra fields.
Class to manage building of HTML components.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class to manage building of HTML components.
Class to manage projects.
const STATUS_VALIDATED
Open/Validated status.
const STATUS_CLOSED
Closed status.
const STATUS_DRAFT
Draft status.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage tasks.
Class to manage translations.
Class to manage Dolibarr users.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
Definition index.php:171
llxFooter()
Footer empty.
Definition document.php:107
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formatted for view output Used into pdf and HTML pages.
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
dolPrintHTML($s, $allowiframe=0)
Return a string (that can be on several lines) ready to be output on a HTML page.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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.
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled='', $morecss='classlink button bordertransp', $jsonopen='', $backtopagejsfields='', $accesskey='')
Return HTML code to output a button to open a dialog popup box.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessage($mesgs, $style='mesgs', $noduplicate=0, $attop=0)
Set event message in dol_events session object.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
GETPOSTFLOAT($paramname, $rounding='')
Return the value of a $_GET or $_POST supervariable, converted into float.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
project_prepare_head(Project $project, $moreparam='')
Prepare array with list of tabs.
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.