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