dolibarr  16.0.5
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  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <https://www.gnu.org/licenses/>.
18  */
19 
26 require '../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
28 require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
36 
37 // Load translation files required by the page
38 $langsLoad=array('projects', 'companies');
39 if (!empty($conf->eventorganization->enabled)) {
40  $langsLoad[]='eventorganization';
41 }
42 
43 $langs->loadLangs($langsLoad);
44 
45 $id = GETPOST('id', 'int');
46 $ref = GETPOST('ref', 'alpha');
47 $action = GETPOST('action', 'aZ09');
48 $backtopage = GETPOST('backtopage', 'alpha');
49 $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
50 $backtopagejsfields = GETPOST('backtopagejsfields', 'alpha');
51 $cancel = GETPOST('cancel', 'alpha');
52 $confirm = GETPOST('confirm', 'aZ09');
53 $dol_openinpopup = GETPOST('dol_openinpopup', 'aZ09');
54 
55 $status = GETPOST('status', 'int');
56 $opp_status = GETPOST('opp_status', 'int');
57 $opp_percent = price2num(GETPOST('opp_percent', 'alpha'));
58 $objcanvas = GETPOST("objcanvas", "alpha");
59 $comefromclone = GETPOST("comefromclone", "alpha");
60 
61 if ($id == '' && $ref == '' && ($action != "create" && $action != "add" && $action != "update" && !GETPOST("cancel"))) {
63 }
64 
65 $mine = GETPOST('mode') == 'mine' ? 1 : 0;
66 //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
67 
68 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
69 $hookmanager->initHooks(array('projectcard', 'globalcard'));
70 
71 $object = new Project($db);
72 $extrafields = new ExtraFields($db);
73 
74 // Load object
75 //include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Can't use generic include because when creating a project, ref is defined and we dont want error if fetch fails from ref.
76 if ($id > 0 || !empty($ref)) {
77  $ret = $object->fetch($id, $ref); // If we create project, ref may be defined into POST but record does not yet exists into database
78  if ($ret > 0) {
79  $object->fetch_thirdparty();
80  if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) {
81  $object->fetchComments();
82  }
83  $id = $object->id;
84  }
85 }
86 
87 // fetch optionals attributes and labels
88 $extrafields->fetch_name_optionals_label($object->table_element);
89 
90 $date_start = dol_mktime(0, 0, 0, GETPOST('projectstartmonth', 'int'), GETPOST('projectstartday', 'int'), GETPOST('projectstartyear', 'int'));
91 $date_end = dol_mktime(0, 0, 0, GETPOST('projectendmonth', 'int'), GETPOST('projectendday', 'int'), GETPOST('projectendyear', 'int'));
92 
93 // Security check
94 $socid = GETPOST('socid', 'int');
95 //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 assignement.
96 restrictedArea($user, 'projet', $object->id, 'projet&project');
97 
98 $permissiondellink = $user->rights->projet->creer; // Used by the include of actions_dellink.inc.php
99 
100 
101 /*
102  * Actions
103  */
104 
105 $parameters = array('id'=>$socid, 'objcanvas'=>$objcanvas);
106 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
107 if ($reshook < 0) {
108  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
109 }
110 
111 if (empty($reshook)) {
112  $backurlforlist = DOL_URL_ROOT.'/projet/list.php';
113 
114  // Cancel
115  if ($cancel) {
116  if (GETPOST("comefromclone") == 1) {
117  $result = $object->delete($user);
118  if ($result > 0) {
119  header("Location: index.php");
120  exit;
121  } else {
122  dol_syslog($object->error, LOG_DEBUG);
123  setEventMessages($langs->trans("CantRemoveProject", $langs->transnoentitiesnoconv("ProjectOverview")), null, 'errors');
124  }
125  }
126  }
127 
128  if (empty($backtopage) || ($cancel && empty($id))) {
129  if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
130  if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
131  $backtopage = $backurlforlist;
132  } else {
133  $backtopage = DOL_URL_ROOT.'/projet/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
134  }
135  }
136  }
137 
138  if ($cancel) {
139  if (!empty($backtopageforcancel)) {
140  header("Location: ".$backtopageforcancel);
141  exit;
142  } elseif (!empty($backtopage)) {
143  header("Location: ".$backtopage);
144  exit;
145  }
146  $action = '';
147  }
148 
149  include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once
150 
151  if ($action == 'add' && $user->rights->projet->creer) {
152  $error = 0;
153  if (!GETPOST('ref')) {
154  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors');
155  $error++;
156  }
157  if (!GETPOST('title')) {
158  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("ProjectLabel")), null, 'errors');
159  $error++;
160  }
161 
162  if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
163  if (GETPOST('opp_amount') != '' && !(GETPOST('opp_status') > 0)) {
164  $error++;
165  setEventMessages($langs->trans("ErrorOppStatusRequiredIfAmount"), null, 'errors');
166  }
167  }
168 
169  // Create with status validated immediatly
170  if (!empty($conf->global->PROJECT_CREATE_NO_DRAFT)) {
171  $status = Project::STATUS_VALIDATED;
172  }
173 
174  if (!$error) {
175  $error = 0;
176 
177  $db->begin();
178 
179  $object->ref = GETPOST('ref', 'alphanohtml');
180  $object->title = GETPOST('title', 'alphanohtml');
181  $object->socid = GETPOST('socid', 'int');
182  $object->description = GETPOST('description', 'restricthtml'); // Do not use 'alpha' here, we want field as it is
183  $object->public = GETPOST('public', 'alphanohtml');
184  $object->opp_amount = price2num(GETPOST('opp_amount', 'alphanohtml'));
185  $object->budget_amount = price2num(GETPOST('budget_amount', 'alphanohtml'));
186  $object->date_c = dol_now();
187  $object->date_start = $date_start;
188  $object->date_end = $date_end;
189  $object->statut = $status;
190  $object->opp_status = $opp_status;
191  $object->opp_percent = $opp_percent;
192  $object->usage_opportunity = (GETPOST('usage_opportunity', 'alpha') == 'on' ? 1 : 0);
193  $object->usage_task = (GETPOST('usage_task', 'alpha') == 'on' ? 1 : 0);
194  $object->usage_bill_time = (GETPOST('usage_bill_time', 'alpha') == 'on' ? 1 : 0);
195  $object->usage_organize_event = (GETPOST('usage_organize_event', 'alpha') == 'on' ? 1 : 0);
196 
197  // Fill array 'array_options' with data from add form
198  $ret = $extrafields->setOptionalsFromPost(null, $object);
199  if ($ret < 0) {
200  $error++;
201  }
202 
203  $result = $object->create($user);
204  if (!$error && $result > 0) {
205  // Add myself as project leader
206  $typeofcontact = 'PROJECTLEADER';
207  $result = $object->add_contact($user->id, $typeofcontact, 'internal');
208 
209  // -3 means type not found (PROJECTLEADER renamed, de-activated or deleted), so don't prevent creation if it has been the case
210  if ($result == -3) {
211  setEventMessage('ErrorPROJECTLEADERRoleMissingRestoreIt', 'errors');
212  $error++;
213  } elseif ($result < 0) {
214  $langs->load("errors");
215  setEventMessages($object->error, $object->errors, 'errors');
216  $error++;
217  }
218  } else {
219  $langs->load("errors");
220  setEventMessages($object->error, $object->errors, 'errors');
221  $error++;
222  }
223  if (!$error && !empty($object->id) > 0) {
224  // Category association
225  $categories = GETPOST('categories', 'array');
226  $result = $object->setCategories($categories);
227  if ($result < 0) {
228  $langs->load("errors");
229  setEventMessages($object->error, $object->errors, 'errors');
230  $error++;
231  }
232  }
233 
234  if (!$error) {
235  $db->commit();
236 
237  if (!empty($backtopage)) {
238  $backtopage = preg_replace('/--IDFORBACKTOPAGE--|__ID__/', $object->id, $backtopage); // New method to autoselect project after a New on another form object creation
239  $backtopage = $backtopage.'&projectid='.$object->id; // Old method
240  header("Location: ".$backtopage);
241  exit;
242  } else {
243  header("Location:card.php?id=".$object->id);
244  exit;
245  }
246  } else {
247  $db->rollback();
248  unset($_POST["ref"]);
249  $action = 'create';
250  }
251  } else {
252  $action = 'create';
253  }
254  }
255 
256  if ($action == 'update' && empty(GETPOST('cancel')) && $user->rights->projet->creer) {
257  $error = 0;
258 
259  if (empty($ref)) {
260  $error++;
261  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors');
262  }
263  if (!GETPOST("title")) {
264  $error++;
265  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("ProjectLabel")), null, 'errors');
266  }
267 
268  $db->begin();
269 
270  if (!$error) {
271  $object->oldcopy = clone $object;
272 
273  $old_start_date = $object->date_start;
274 
275  $object->ref = GETPOST('ref', 'alpha');
276  $object->title = GETPOST('title', 'alphanohtml'); // Do not use 'alpha' here, we want field as it is
277  $object->statut = GETPOST('status', 'int');
278  $object->socid = GETPOST('socid', 'int');
279  $object->description = GETPOST('description', 'restricthtml'); // Do not use 'alpha' here, we want field as it is
280  $object->public = GETPOST('public', 'alpha');
281  $object->date_start = (!GETPOST('projectstart')) ? '' : $date_start;
282  $object->date_end = (!GETPOST('projectend')) ? '' : $date_end;
283  if (GETPOSTISSET('opp_amount')) {
284  $object->opp_amount = price2num(GETPOST('opp_amount', 'alpha'));
285  }
286  if (GETPOSTISSET('budget_amount')) {
287  $object->budget_amount = price2num(GETPOST('budget_amount', 'alpha'));
288  }
289  if (GETPOSTISSET('opp_status')) {
290  $object->opp_status = $opp_status;
291  }
292  if (GETPOSTISSET('opp_percent')) {
293  $object->opp_percent = $opp_percent;
294  }
295  $object->usage_opportunity = (GETPOST('usage_opportunity', 'alpha') == 'on' ? 1 : 0);
296  $object->usage_task = (GETPOST('usage_task', 'alpha') == 'on' ? 1 : 0);
297  $object->usage_bill_time = (GETPOST('usage_bill_time', 'alpha') == 'on' ? 1 : 0);
298  $object->usage_organize_event = (GETPOST('usage_organize_event', 'alpha') == 'on' ? 1 : 0);
299 
300  // Fill array 'array_options' with data from add form
301  $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
302  if ($ret < 0) {
303  $error++;
304  }
305  }
306 
307  if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
308  if ($object->opp_amount && ($object->opp_status <= 0)) {
309  $error++;
310  setEventMessages($langs->trans("ErrorOppStatusRequiredIfAmount"), null, 'errors');
311  }
312  }
313 
314  if (!$error) {
315  $result = $object->update($user);
316  if ($result < 0) {
317  $error++;
318  if ($result == -4) {
319  setEventMessages($langs->trans("ErrorRefAlreadyExists"), null, 'errors');
320  } else {
321  setEventMessages($object->error, $object->errors, 'errors');
322  }
323  } else {
324  // Category association
325  $categories = GETPOST('categories', 'array');
326  $result = $object->setCategories($categories);
327  if ($result < 0) {
328  $error++;
329  setEventMessages($object->error, $object->errors, 'errors');
330  }
331  }
332  }
333 
334  if (!$error) {
335  if (GETPOST("reportdate") && ($object->date_start != $old_start_date)) {
336  $result = $object->shiftTaskDate($old_start_date);
337  if ($result < 0) {
338  $error++;
339  setEventMessages($langs->trans("ErrorShiftTaskDate").':'.$object->error, $object->errors, 'errors');
340  }
341  }
342  }
343 
344  // Check if we must change status
345  if (GETPOST('closeproject')) {
346  $resclose = $object->setClose($user);
347  if ($resclose < 0) {
348  $error++;
349  setEventMessages($langs->trans("FailedToCloseProject").':'.$object->error, $object->errors, 'errors');
350  }
351  }
352 
353 
354  if ($error) {
355  $db->rollback();
356  $action = 'edit';
357  } else {
358  $db->commit();
359 
360  if (GETPOST('socid', 'int') > 0) {
361  $object->fetch_thirdparty(GETPOST('socid', 'int'));
362  } else {
363  unset($object->thirdparty);
364  }
365  }
366  }
367 
368  // Build doc
369  if ($action == 'builddoc' && $user->rights->projet->creer) {
370  // Save last template used to generate document
371  if (GETPOST('model')) {
372  $object->setDocModel($user, GETPOST('model', 'alpha'));
373  }
374 
375  $outputlangs = $langs;
376  if (GETPOST('lang_id', 'aZ09')) {
377  $outputlangs = new Translate("", $conf);
378  $outputlangs->setDefaultLang(GETPOST('lang_id', 'aZ09'));
379  }
380  $result = $object->generateDocument($object->model_pdf, $outputlangs);
381  if ($result <= 0) {
382  setEventMessages($object->error, $object->errors, 'errors');
383  $action = '';
384  }
385  }
386 
387  // Delete file in doc form
388  if ($action == 'remove_file' && $user->rights->projet->creer) {
389  if ($object->id > 0) {
390  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
391 
392  $langs->load("other");
393  $upload_dir = $conf->project->multidir_output[$object->entity];
394  $file = $upload_dir.'/'.GETPOST('file');
395  $ret = dol_delete_file($file, 0, 0, 0, $object);
396  if ($ret) {
397  setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs');
398  } else {
399  setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors');
400  }
401  $action = '';
402  }
403  }
404 
405 
406  if ($action == 'confirm_validate' && $confirm == 'yes') {
407  $result = $object->setValid($user);
408  if ($result <= 0) {
409  setEventMessages($object->error, $object->errors, 'errors');
410  }
411  }
412 
413  if ($action == 'confirm_close' && $confirm == 'yes') {
414  $result = $object->setClose($user);
415  if ($result <= 0) {
416  setEventMessages($object->error, $object->errors, 'errors');
417  }
418  }
419 
420  if ($action == 'confirm_reopen' && $confirm == 'yes') {
421  $result = $object->setValid($user);
422  if ($result <= 0) {
423  setEventMessages($object->error, $object->errors, 'errors');
424  }
425  }
426 
427  if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights->projet->supprimer) {
428  $object->fetch($id);
429  $result = $object->delete($user);
430  if ($result > 0) {
431  setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
432  header("Location: list.php?restore_lastsearch_values=1");
433  exit;
434  } else {
435  dol_syslog($object->error, LOG_DEBUG);
436  setEventMessages($object->error, $object->errors, 'errors');
437  }
438  }
439 
440  if ($action == 'confirm_clone' && $user->rights->projet->creer && $confirm == 'yes') {
441  $clone_contacts = GETPOST('clone_contacts') ? 1 : 0;
442  $clone_tasks = GETPOST('clone_tasks') ? 1 : 0;
443  $clone_project_files = GETPOST('clone_project_files') ? 1 : 0;
444  $clone_task_files = GETPOST('clone_task_files') ? 1 : 0;
445  $clone_notes = GETPOST('clone_notes') ? 1 : 0;
446  $move_date = GETPOST('move_date') ? 1 : 0;
447  $clone_thirdparty = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : 0;
448 
449  $result = $object->createFromClone($user, $object->id, $clone_contacts, $clone_tasks, $clone_project_files, $clone_task_files, $clone_notes, $move_date, 0, $clone_thirdparty);
450  if ($result <= 0) {
451  setEventMessages($object->error, $object->errors, 'errors');
452  } else {
453  // Load new object
454  $newobject = new Project($db);
455  $newobject->fetch($result);
456  $newobject->fetch_optionals();
457  $newobject->fetch_thirdparty(); // Load new object
458  $object = $newobject;
459  $action = 'edit';
460  $comefromclone = true;
461  }
462  }
463 
464  // Actions to send emails
465  $triggersendname = 'PROJECT_SENTBYMAIL';
466  $paramname = 'id';
467  $autocopy = 'MAIN_MAIL_AUTOCOPY_PROJECT_TO'; // used to know the automatic BCC to add
468  $trackid = 'proj'.$object->id;
469  include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
470 }
471 
472 
473 /*
474  * View
475  */
476 
477 $form = new Form($db);
478 $formfile = new FormFile($db);
479 $formproject = new FormProjets($db);
480 $userstatic = new User($db);
481 
482 $title = $langs->trans("Project").' - '.$object->ref.(!empty($object->thirdparty->name) ? ' - '.$object->thirdparty->name : '').(!empty($object->title) ? ' - '.$object->title : '');
483 if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE)) {
484  $title = $object->ref.(!empty($object->thirdparty->name) ? ' - '.$object->thirdparty->name : '').(!empty($object->title) ? ' - '.$object->title : '');
485 }
486 $help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos|DE:Modul_Projekte";
487 
488 llxHeader("", $title, $help_url);
489 
490 $titleboth = $langs->trans("LeadsOrProjects");
491 $titlenew = $langs->trans("NewLeadOrProject"); // Leads and opportunities by default
492 if (!getDolGlobalInt('PROJECT_USE_OPPORTUNITIES')) {
493  $titleboth = $langs->trans("Projects");
494  $titlenew = $langs->trans("NewProject");
495 }
496 if (getDolGlobalInt('PROJECT_USE_OPPORTUNITIES') == 2) { // 2 = leads only
497  $titleboth = $langs->trans("Leads");
498  $titlenew = $langs->trans("NewLead");
499 }
500 
501 if ($action == 'create' && $user->rights->projet->creer) {
502  /*
503  * Create
504  */
505 
506  $thirdparty = new Societe($db);
507  if ($socid > 0) {
508  $thirdparty->fetch($socid);
509  }
510 
511  print load_fiche_titre($titlenew, '', 'project');
512 
513  print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
514  print '<input type="hidden" name="action" value="add">';
515  print '<input type="hidden" name="token" value="'.newToken().'">';
516  print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
517  print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
518  print '<input type="hidden" name="backtopagejsfields" value="'.$backtopagejsfields.'">';
519 
520  print dol_get_fiche_head();
521 
522  print '<table class="border centpercent tableforfieldcreate">';
523 
524  $defaultref = '';
525  $modele = empty($conf->global->PROJECT_ADDON) ? 'mod_project_simple' : $conf->global->PROJECT_ADDON;
526 
527  // Search template files
528  $file = ''; $classname = ''; $filefound = 0;
529  $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
530  foreach ($dirmodels as $reldir) {
531  $file = dol_buildpath($reldir."core/modules/project/".$modele.'.php', 0);
532  if (file_exists($file)) {
533  $filefound = 1;
534  $classname = $modele;
535  break;
536  }
537  }
538 
539  if ($filefound) {
540  $result = dol_include_once($reldir."core/modules/project/".$modele.'.php');
541  $modProject = new $classname;
542 
543  $defaultref = $modProject->getNextValue($thirdparty, $object);
544  }
545 
546  if (is_numeric($defaultref) && $defaultref <= 0) {
547  $defaultref = '';
548  }
549 
550  // Ref
551  $suggestedref = (GETPOST("ref") ? GETPOST("ref") : $defaultref);
552  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).'">';
553  print ' '.$form->textwithpicto('', $langs->trans("YouCanCompleteRef", $suggestedref));
554  print '</td></tr>';
555 
556  // Label
557  print '<tr><td><span class="fieldrequired">'.$langs->trans("ProjectLabel").'</span></td><td><input class="width500 maxwidth150onsmartphone" type="text" name="title" value="'.dol_escape_htmltag(GETPOST("title", 'alphanohtml')).'" autofocus></td></tr>';
558 
559  // Usage (opp, task, bill time, ...)
560  if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || !empty($conf->eventorganization->enabled)) {
561  print '<tr><td class="tdtop">';
562  print $langs->trans("Usage");
563  print '</td>';
564  print '<td>';
565  if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
566  print '<input type="checkbox" id="usage_opportunity" name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') ? ' checked="checked"' : '') : ' checked="checked"').'"> ';
567  $htmltext = $langs->trans("ProjectFollowOpportunity");
568  print '<label for="usage_opportunity">'.$form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext).'</label>';
569  print '<script>';
570  print '$( document ).ready(function() {
571  jQuery("#usage_opportunity").change(function() {
572  if (jQuery("#usage_opportunity").prop("checked")) {
573  console.log("Show opportunities fields");
574  jQuery(".classuseopportunity").show();
575  } else {
576  console.log("Hide opportunities fields "+jQuery("#usage_opportunity").prop("checked"));
577  jQuery(".classuseopportunity").hide();
578  }
579  });
580  ';
581  if (GETPOSTISSET('usage_opportunity') && !GETPOST('usage_opportunity')) {
582  print 'jQuery(".classuseopportunity").hide();';
583  }
584  print '});';
585  print '</script>';
586  print '<br>';
587  }
588  if (empty($conf->global->PROJECT_HIDE_TASKS)) {
589  print '<input type="checkbox" id="usage_task" name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') ? ' checked="checked"' : '') : ' checked="checked"').'"> ';
590  $htmltext = $langs->trans("ProjectFollowTasks");
591  print '<label for="usage_task">'.$form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext).'</label>';
592  print '<br>';
593  }
594  if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
595  print '<input type="checkbox" id="usage_bill_time" name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') ? ' checked="checked"' : '') : '').'"> ';
596  $htmltext = $langs->trans("ProjectBillTimeDescription");
597  print '<label for="usage_bill_time">'.$form->textwithpicto($langs->trans("BillTime"), $htmltext).'</label>';
598  print '<br>';
599  }
600  if (!empty($conf->eventorganization->enabled)) {
601  print '<input type="checkbox" id="usage_organize_event" name="usage_organize_event"'.(GETPOSTISSET('usage_organize_event') ? (GETPOST('usage_organize_event', 'alpha') ? ' checked="checked"' : '') :'').'"> ';
602  $htmltext = $langs->trans("EventOrganizationDescriptionLong");
603  print '<label for="usage_organize_event">'.$form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext).'</label>';
604  }
605  print '</td>';
606  print '</tr>';
607  }
608 
609  // Thirdparty
610  if (isModEnabled('societe')) {
611  print '<tr><td>';
612  print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) ? '' : '<span class="fieldrequired">');
613  print $langs->trans("ThirdParty");
614  print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) ? '' : '</span>');
615  print '</td><td class="maxwidthonsmartphone">';
616  $filteronlist = '';
617  if (!empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) {
618  $filteronlist = $conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST;
619  }
620  $text = img_picto('', 'company').$form->select_company(GETPOST('socid', 'int'), 'socid', $filteronlist, 'SelectThirdParty', 1, 0, array(), 0, 'minwidth300 widthcentpercentminusxx maxwidth500');
621  if (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) && empty($conf->dol_use_jmobile)) {
622  $texthelp = $langs->trans("IfNeedToUseOtherObjectKeepEmpty");
623  print $form->textwithtooltip($text.' '.img_help(), $texthelp, 1);
624  } else {
625  print $text;
626  }
627  if (!GETPOSTISSET('backtopage')) {
628  $url = '/societe/card.php?action=create&client=3&fournisseur=0&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create');
629  $newbutton = '<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("AddThirdParty").'"></span>';
630  // TODO @LDR Implement this
631  if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
632  $tmpbacktopagejsfields = 'addthirdparty:socid,search_socid';
633  print dolButtonToOpenUrlInDialogPopup('addthirdparty', $langs->transnoentitiesnoconv('AddThirdParty'), $newbutton, $url, '', '', $tmpbacktopagejsfields);
634  } else {
635  print ' <a href="'.DOL_URL_ROOT.$url.'">'.$newbutton.'</a>';
636  }
637  }
638  print '</td></tr>';
639  }
640 
641  // Status
642  if ($status != '') {
643  print '<tr><td>'.$langs->trans("Status").'</td><td>';
644  print '<input type="hidden" name="status" value="'.$status.'">';
645  print $object->LibStatut($status, 4);
646  print '</td></tr>';
647  }
648 
649  // Visibility
650  print '<tr><td>'.$langs->trans("Visibility").'</td><td class="maxwidthonsmartphone">';
651  $array = array();
652  if (empty($conf->global->PROJECT_DISABLE_PRIVATE_PROJECT)) {
653  $array[0] = $langs->trans("PrivateProject");
654  }
655  if (empty($conf->global->PROJECT_DISABLE_PUBLIC_PROJECT)) {
656  $array[1] = $langs->trans("SharedProject");
657  }
658 
659  if (count($array) > 0) {
660  print $form->selectarray('public', $array, GETPOST('public'), 0, 0, 0, '', 0, 0, 0, '', '', 1);
661  } else {
662  print '<input type="hidden" name="public" id="public" value="'.GETPOST('public').'">';
663 
664  if (GETPOST('public') == 0) {
665  print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
666  print $langs->trans("PrivateProject");
667  } else {
668  print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
669  print $langs->trans("SharedProject");
670  }
671  }
672  print '</td></tr>';
673 
674  // Date start
675  print '<tr><td>'.$langs->trans("DateStart").'</td><td>';
676  print $form->selectDate(($date_start ? $date_start : ''), 'projectstart', 0, 0, 0, '', 1, 0);
677  print '</td></tr>';
678 
679  // Date end
680  print '<tr><td>'.$langs->trans("DateEnd").'</td><td>';
681  print $form->selectDate(($date_end ? $date_end : -1), 'projectend', 0, 0, 0, '', 1, 0);
682  print '</td></tr>';
683 
684  if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
685  // Opportunity status
686  print '<tr class="classuseopportunity"><td>'.$langs->trans("OpportunityStatus").'</td>';
687  print '<td class="maxwidthonsmartphone">';
688  print $formproject->selectOpportunityStatus('opp_status', GETPOSTISSET('opp_status') ? GETPOST('opp_status') : $object->opp_status, 1, 0, 0, 0, '', 0, 1);
689  print '</tr>';
690 
691  // Opportunity probability
692  print '<tr class="classuseopportunity"><td>'.$langs->trans("OpportunityProbability").'</td>';
693  print '<td><input size="5" type="text" id="opp_percent" name="opp_percent" value="'.dol_escape_htmltag(GETPOSTISSET('opp_percent') ? GETPOST('opp_percent') : '').'"><span class="hideonsmartphone"> %</span>';
694  print '<input type="hidden" name="opp_percent_not_set" id="opp_percent_not_set" value="'.dol_escape_htmltag(GETPOSTISSET('opp_percent') ? '0' : '1').'">';
695  print '</td>';
696  print '</tr>';
697 
698  // Opportunity amount
699  print '<tr class="classuseopportunity"><td>'.$langs->trans("OpportunityAmount").'</td>';
700  print '<td><input size="5" type="text" name="opp_amount" value="'.dol_escape_htmltag(GETPOSTISSET('opp_amount') ? GETPOST('opp_amount') : '').'"></td>';
701  print '</tr>';
702  }
703 
704  // Budget
705  print '<tr><td>'.$langs->trans("Budget").'</td>';
706  print '<td><input size="5" type="text" name="budget_amount" value="'.dol_escape_htmltag(GETPOSTISSET('budget_amount') ? GETPOST('budget_amount') : '').'"></td>';
707  print '</tr>';
708 
709  // Description
710  print '<tr><td class="tdtop">'.$langs->trans("Description").'</td>';
711  print '<td>';
712  $doleditor = new DolEditor('description', GETPOST("description", 'restricthtml'), '', 90, 'dolibarr_notes', '', false, true, getDolGlobalString('FCKEDITOR_ENABLE_SOCIETE'), ROWS_3, '90%');
713  $doleditor->Create();
714  print '</td></tr>';
715 
716  if (!empty($conf->categorie->enabled)) {
717  // Categories
718  print '<tr><td>'.$langs->trans("Categories").'</td><td colspan="3">';
719  $cate_arbo = $form->select_all_categories(Categorie::TYPE_PROJECT, '', 'parent', 64, 0, 1);
720  $arrayselected = GETPOST('categories', 'array');
721  print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
722  print "</td></tr>";
723  }
724 
725  // Other options
726  $parameters = array();
727  $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
728  print $hookmanager->resPrint;
729  if (empty($reshook)) {
730  print $object->showOptionals($extrafields, 'create');
731  }
732 
733  print '</table>';
734 
735  print dol_get_fiche_end();
736 
737  print $form->buttonsSaveCancel('CreateDraft');
738 
739  print '</form>';
740 
741  // Change probability from status or role of project
742  print '<script type="text/javascript">
743  jQuery(document).ready(function() {
744  function change_percent()
745  {
746  var element = jQuery("#opp_status option:selected");
747  var defaultpercent = element.attr("defaultpercent");
748  /*if (jQuery("#opp_percent_not_set").val() == "") */
749  jQuery("#opp_percent").val(defaultpercent);
750  }
751 
752  /*init_myfunc();*/
753  jQuery("#opp_status").change(function() {
754  change_percent();
755  });
756 
757  jQuery("#usage_task").change(function() {
758  console.log("We click on usage task "+jQuery("#usage_task").is(":checked"));
759  if (! jQuery("#usage_task").is(":checked")) {
760  jQuery("#usage_bill_time").prop("checked", false);
761  }
762  });
763 
764  jQuery("#usage_bill_time").change(function() {
765  console.log("We click on usage to bill time");
766  if (jQuery("#usage_bill_time").is(":checked")) {
767  jQuery("#usage_task").prop("checked", true);
768  }
769  });
770  });
771  </script>';
772 } elseif ($object->id > 0) {
773  /*
774  * Show or edit
775  */
776 
777  $res = $object->fetch_optionals();
778 
779  // To verify role of users
780  $userAccess = $object->restrictedProjectArea($user, 'read');
781  $userWrite = $object->restrictedProjectArea($user, 'write');
782  $userDelete = $object->restrictedProjectArea($user, 'delete');
783  //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete;
784 
785 
786  // Confirmation validation
787  if ($action == 'validate') {
788  print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateProject'), $langs->trans('ConfirmValidateProject'), 'confirm_validate', '', 0, 1);
789  }
790  // Confirmation close
791  if ($action == 'close') {
792  print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("CloseAProject"), $langs->trans("ConfirmCloseAProject"), "confirm_close", '', '', 1);
793  }
794  // Confirmation reopen
795  if ($action == 'reopen') {
796  print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ReOpenAProject"), $langs->trans("ConfirmReOpenAProject"), "confirm_reopen", '', '', 1);
797  }
798  // Confirmation delete
799  if ($action == 'delete') {
800  $text = $langs->trans("ConfirmDeleteAProject");
801  $task = new Task($db);
802  $taskarray = $task->getTasksArray(0, 0, $object->id, 0, 0);
803  $nboftask = count($taskarray);
804  if ($nboftask) {
805  $text .= '<br>'.img_warning().' '.$langs->trans("ThisWillAlsoRemoveTasks", $nboftask);
806  }
807  print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("DeleteAProject"), $text, "confirm_delete", '', '', 1);
808  }
809 
810  // Clone confirmation
811  if ($action == 'clone') {
812  $formquestion = array(
813  'text' => $langs->trans("ConfirmClone"),
814  array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int') > 0 ?GETPOST('socid', 'int') : $object->socid, 'socid', '', "None", 0, 0, null, 0, 'minwidth200 maxwidth250')),
815  array('type' => 'checkbox', 'name' => 'clone_contacts', 'label' => $langs->trans("CloneContacts"), 'value' => true),
816  array('type' => 'checkbox', 'name' => 'clone_tasks', 'label' => $langs->trans("CloneTasks"), 'value' => true),
817  array('type' => 'checkbox', 'name' => 'move_date', 'label' => $langs->trans("CloneMoveDate"), 'value' => true),
818  array('type' => 'checkbox', 'name' => 'clone_notes', 'label' => $langs->trans("CloneNotes"), 'value' => true),
819  array('type' => 'checkbox', 'name' => 'clone_project_files', 'label' => $langs->trans("CloneProjectFiles"), 'value' => false),
820  array('type' => 'checkbox', 'name' => 'clone_task_files', 'label' => $langs->trans("CloneTaskFiles"), 'value' => false)
821  );
822 
823  print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ToClone"), $langs->trans("ConfirmCloneProject"), "confirm_clone", $formquestion, '', 1, 400, 590);
824  }
825 
826 
827  print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
828  print '<input type="hidden" name="token" value="'.newToken().'">';
829  print '<input type="hidden" name="action" value="update">';
830  print '<input type="hidden" name="id" value="'.$object->id.'">';
831  print '<input type="hidden" name="comefromclone" value="'.$comefromclone.'">';
832 
833  $head = project_prepare_head($object);
834 
835  if ($action == 'edit' && $userWrite > 0) {
836  print dol_get_fiche_head($head, 'project', $langs->trans("Project"), 0, ($object->public ? 'projectpub' : 'project'));
837 
838  print '<table class="border centpercent">';
839 
840  // Ref
841  $suggestedref = $object->ref;
842  print '<tr><td class="titlefield fieldrequired">'.$langs->trans("Ref").'</td>';
843  print '<td><input size="25" name="ref" value="'.$suggestedref.'">';
844  print ' '.$form->textwithpicto('', $langs->trans("YouCanCompleteRef", $suggestedref));
845  print '</td></tr>';
846 
847  // Label
848  print '<tr><td class="fieldrequired">'.$langs->trans("ProjectLabel").'</td>';
849  print '<td><input class="quatrevingtpercent" name="title" value="'.dol_escape_htmltag($object->title).'"></td></tr>';
850 
851  // Status
852  print '<tr><td class="fieldrequired">'.$langs->trans("Status").'</td><td>';
853  print '<select class="flat" name="status">';
854  foreach ($object->statuts_short as $key => $val) {
855  print '<option value="'.$key.'"'.((GETPOSTISSET('status') ?GETPOST('status') : $object->statut) == $key ? ' selected="selected"' : '').'>'.$langs->trans($val).'</option>';
856  }
857  print '</select>';
858  print '</td></tr>';
859 
860  // Usage
861  if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || !empty($conf->eventorganization->enabled)) {
862  print '<tr><td class="tdtop">';
863  print $langs->trans("Usage");
864  print '</td>';
865  print '<td>';
866  if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
867  print '<input type="checkbox" id="usage_opportunity" name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_opportunity ? ' checked="checked"' : '')).'"> ';
868  $htmltext = $langs->trans("ProjectFollowOpportunity");
869  print '<label for="usage_opportunity">'.$form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext).'</label>';
870  print '<script>';
871  print '$( document ).ready(function() {
872  jQuery("#usage_opportunity").change(function() {
873  if (jQuery("#usage_opportunity").prop("checked")) {
874  console.log("Show opportunities fields");
875  jQuery(".classuseopportunity").show();
876  } else {
877  console.log("Hide opportunities fields "+jQuery("#usage_opportunity").prop("checked"));
878  jQuery(".classuseopportunity").hide();
879  }
880  });
881  ';
882  print '
883  });';
884  print '</script>';
885  print '<br>';
886  }
887  if (empty($conf->global->PROJECT_HIDE_TASKS)) {
888  print '<input type="checkbox" id="usage_task" name="usage_task"' . (GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_task ? ' checked="checked"' : '')) . '"> ';
889  $htmltext = $langs->trans("ProjectFollowTasks");
890  print '<label for="usage_task">'.$form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext).'</label>';
891  print '<br>';
892  }
893  if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
894  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"' : '')) . '"> ';
895  $htmltext = $langs->trans("ProjectBillTimeDescription");
896  print '<label for="usage_bill_time">'.$form->textwithpicto($langs->trans("BillTime"), $htmltext).'</label>';
897  print '<br>';
898  }
899  if (!empty($conf->eventorganization->enabled)) {
900  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"' : '')) . '"> ';
901  $htmltext = $langs->trans("EventOrganizationDescriptionLong");
902  print '<label for="usage_organize_event">'.$form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext).'</label>';
903  }
904  print '</td></tr>';
905  }
906  print '</td></tr>';
907 
908  // Thirdparty
909  if (isModEnabled('societe')) {
910  print '<tr><td>';
911  print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) ? '' : '<span class="fieldrequired">');
912  print $langs->trans("ThirdParty");
913  print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) ? '' : '</span>');
914  print '</td><td>';
915  $filteronlist = '';
916  if (!empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) {
917  $filteronlist = $conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST;
918  }
919  $text = $form->select_company($object->thirdparty->id, 'socid', $filteronlist, 'None', 1, 0, array(), 0, 'minwidth300');
920  if (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) && empty($conf->dol_use_jmobile)) {
921  $texthelp = $langs->trans("IfNeedToUseOtherObjectKeepEmpty");
922  print $form->textwithtooltip($text.' '.img_help(), $texthelp, 1, 0, '', '', 2);
923  } else {
924  print $text;
925  }
926  print '</td></tr>';
927  }
928 
929  // Visibility
930  print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
931  $array = array();
932  if (empty($conf->global->PROJECT_DISABLE_PRIVATE_PROJECT)) {
933  $array[0] = $langs->trans("PrivateProject");
934  }
935  if (empty($conf->global->PROJECT_DISABLE_PUBLIC_PROJECT)) {
936  $array[1] = $langs->trans("SharedProject");
937  }
938 
939  if (count($array) > 0) {
940  print $form->selectarray('public', $array, $object->public, 0, 0, 0, '', 0, 0, 0, '', '', 1);
941  } else {
942  print '<input type="hidden" id="public" name="public" value="'.$object->public.'">';
943 
944  if ($object->public == 0) {
945  print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
946  print $langs->trans("PrivateProject");
947  } else {
948  print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
949  print $langs->trans("SharedProject");
950  }
951  }
952  print '</td></tr>';
953 
954  if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
955  $classfortr = ($object->usage_opportunity ? '' : ' hideobject');
956  // Opportunity status
957  print '<tr class="classuseopportunity'.$classfortr.'"><td>'.$langs->trans("OpportunityStatus").'</td>';
958  print '<td>';
959  print $formproject->selectOpportunityStatus('opp_status', $object->opp_status, 1, 0, 0, 0, 'inline-block valignmiddle', 0, 1);
960  print '<div id="divtocloseproject" class="inline-block valign" style="display: none;"> &nbsp; &nbsp; ';
961  print '<input type="checkbox" id="inputcloseproject" name="closeproject" />';
962  print '<label for="inputcloseproject">'.$langs->trans("AlsoCloseAProject").'</label>';
963  print '</div>';
964  print '</td>';
965  print '</tr>';
966 
967  // Opportunity probability
968  print '<tr class="classuseopportunity'.$classfortr.'"><td>'.$langs->trans("OpportunityProbability").'</td>';
969  print '<td><input size="5" type="text" id="opp_percent" name="opp_percent" value="'.(GETPOSTISSET('opp_percent') ? GETPOST('opp_percent') : (strcmp($object->opp_percent, '') ?vatrate($object->opp_percent) : '')).'"> %';
970  print '<span id="oldopppercent"></span>';
971  print '</td>';
972  print '</tr>';
973 
974  // Opportunity amount
975  print '<tr class="classuseopportunity'.$classfortr.'"><td>'.$langs->trans("OpportunityAmount").'</td>';
976  print '<td><input size="5" type="text" name="opp_amount" value="'.(GETPOSTISSET('opp_amount') ? GETPOST('opp_amount') : (strcmp($object->opp_amount, '') ? price2num($object->opp_amount) : '')).'">';
977  print $langs->getCurrencySymbol($conf->currency);
978  print '</td>';
979  print '</tr>';
980  }
981 
982  // Date start
983  print '<tr><td>'.$langs->trans("DateStart").'</td><td>';
984  print $form->selectDate($object->date_start ? $object->date_start : -1, 'projectstart', 0, 0, 0, '', 1, 0);
985  print ' &nbsp; &nbsp; <input type="checkbox" class="valignmiddle" id="reportdate" name="reportdate" value="yes" ';
986  if ($comefromclone) {
987  print ' checked ';
988  }
989  print '/><label for="reportdate" class="opacitymedium">'.$langs->trans("ProjectReportDate").'</label>';
990  print '</td></tr>';
991 
992  // Date end
993  print '<tr><td>'.$langs->trans("DateEnd").'</td><td>';
994  print $form->selectDate($object->date_end ? $object->date_end : -1, 'projectend', 0, 0, 0, '', 1, 0);
995  print '</td></tr>';
996 
997  // Budget
998  print '<tr><td>'.$langs->trans("Budget").'</td>';
999  print '<td><input size="5" type="text" name="budget_amount" value="'.(GETPOSTISSET('budget_amount') ? GETPOST('budget_amount') : (strcmp($object->budget_amount, '') ? price2num($object->budget_amount) : '')).'">';
1000  print $langs->getCurrencySymbol($conf->currency);
1001  print '</td>';
1002  print '</tr>';
1003 
1004  // Description
1005  print '<tr><td class="tdtop">'.$langs->trans("Description").'</td>';
1006  print '<td>';
1007  $doleditor = new DolEditor('description', $object->description, '', 90, 'dolibarr_notes', '', false, true, getDolGlobalInt('FCKEDITOR_ENABLE_SOCIETE'), ROWS_3, '90%');
1008  $doleditor->Create();
1009  print '</td></tr>';
1010 
1011  // Tags-Categories
1012  if (isModEnabled('categorie')) {
1013  print '<tr><td>'.$langs->trans("Categories").'</td><td>';
1014  $cate_arbo = $form->select_all_categories(Categorie::TYPE_PROJECT, '', 'parent', 64, 0, 1);
1015  $c = new Categorie($db);
1016  $cats = $c->containing($object->id, Categorie::TYPE_PROJECT);
1017  foreach ($cats as $cat) {
1018  $arrayselected[] = $cat->id;
1019  }
1020  print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, $arrayselected, 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, '0');
1021  print "</td></tr>";
1022  }
1023 
1024  // Other options
1025  $parameters = array();
1026  $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1027  print $hookmanager->resPrint;
1028  if (empty($reshook)) {
1029  print $object->showOptionals($extrafields, 'edit');
1030  }
1031 
1032  print '</table>';
1033  } else {
1034  print dol_get_fiche_head($head, 'project', $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project'));
1035 
1036  // Project card
1037 
1038  $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
1039 
1040  $morehtmlref = '<div class="refidno">';
1041  // Title
1042  $morehtmlref .= dol_escape_htmltag($object->title);
1043  // Thirdparty
1044  $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : ';
1045  if (!empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
1046  $morehtmlref .= $object->thirdparty->getNomUrl(1, 'project');
1047  }
1048  $morehtmlref .= '</div>';
1049 
1050  // Define a complementary filter for search of next/prev ref.
1051  if (empty($user->rights->projet->all->lire)) {
1052  $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
1053  $object->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")";
1054  }
1055 
1056  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
1057 
1058  print '<div class="fichecenter">';
1059  print '<div class="fichehalfleft">';
1060  print '<div class="underbanner clearboth"></div>';
1061 
1062  print '<table class="border tableforfield" width="100%">';
1063 
1064  // Usage
1065  if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || !empty($conf->eventorganization->enabled)) {
1066  print '<tr><td class="tdtop">';
1067  print $langs->trans("Usage");
1068  print '</td>';
1069  print '<td>';
1070  if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
1071  print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_opportunity ? ' checked="checked"' : '')).'"> ';
1072  $htmltext = $langs->trans("ProjectFollowOpportunity");
1073  print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext);
1074  print '<br>';
1075  }
1076  if (empty($conf->global->PROJECT_HIDE_TASKS)) {
1077  print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_task ? ' checked="checked"' : '')).'"> ';
1078  $htmltext = $langs->trans("ProjectFollowTasks");
1079  print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext);
1080  print '<br>';
1081  }
1082  if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
1083  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"' : '')).'"> ';
1084  $htmltext = $langs->trans("ProjectBillTimeDescription");
1085  print $form->textwithpicto($langs->trans("BillTime"), $htmltext);
1086  print '<br>';
1087  }
1088 
1089  if (!empty($conf->eventorganization->enabled)) {
1090  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"' : '')).'"> ';
1091  $htmltext = $langs->trans("EventOrganizationDescriptionLong");
1092  print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext);
1093  }
1094  print '</td></tr>';
1095  }
1096 
1097  // Visibility
1098  print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
1099  if ($object->public) {
1100  print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
1101  print $langs->trans('SharedProject');
1102  } else {
1103  print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
1104  print $langs->trans('PrivateProject');
1105  }
1106  print '</td></tr>';
1107 
1108  if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) && !empty($object->usage_opportunity)) {
1109  // Opportunity status
1110  print '<tr><td>'.$langs->trans("OpportunityStatus").'</td><td>';
1111  $code = dol_getIdFromCode($db, $object->opp_status, 'c_lead_status', 'rowid', 'code');
1112  if ($code) {
1113  print $langs->trans("OppStatus".$code);
1114  }
1115  print '</td></tr>';
1116 
1117  // Opportunity percent
1118  print '<tr><td>'.$langs->trans("OpportunityProbability").'</td><td>';
1119  if (strcmp($object->opp_percent, '')) {
1120  print price($object->opp_percent, 0, $langs, 1, 0).' %';
1121  }
1122  print '</td></tr>';
1123 
1124  // Opportunity Amount
1125  print '<tr><td>'.$langs->trans("OpportunityAmount").'</td><td>';
1126  if (strcmp($object->opp_amount, '')) {
1127  print '<span class="amount">'.price($object->opp_amount, 0, $langs, 1, 0, -1, $conf->currency).'</span>';
1128  if (strcmp($object->opp_percent, '')) {
1129  print ' &nbsp; &nbsp; &nbsp; <span title="'.dol_escape_htmltag($langs->trans('OpportunityWeightedAmount')).'"><span class="opacitymedium">'.$langs->trans("Weighted").'</span>: <span class="amount">'.price($object->opp_amount * $object->opp_percent / 100, 0, $langs, 1, 0, -1, $conf->currency).'</span></span>';
1130  }
1131  }
1132  print '</td></tr>';
1133 
1134  // Opportunity Weighted Amount
1135  /*
1136  print '<tr><td>'.$langs->trans('OpportunityWeightedAmount').'</td><td>';
1137  if (strcmp($object->opp_amount, '') && strcmp($object->opp_percent, '')) {
1138  print '<span class="amount">'.price($object->opp_amount * $object->opp_percent / 100, 0, $langs, 1, 0, -1, $conf->currency).'</span>';
1139  }
1140  print '</td></tr>';
1141  */
1142  }
1143 
1144  // Date start - end
1145  print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>';
1146  $start = dol_print_date($object->date_start, 'day');
1147  print ($start ? $start : '?');
1148  $end = dol_print_date($object->date_end, 'day');
1149  print ' - ';
1150  print ($end ? $end : '?');
1151  if ($object->hasDelay()) {
1152  print img_warning("Late");
1153  }
1154  print '</td></tr>';
1155 
1156  // Budget
1157  print '<tr><td>'.$langs->trans("Budget").'</td><td>';
1158  if (strcmp($object->budget_amount, '')) {
1159  print '<span class="amount">'.price($object->budget_amount, 0, $langs, 1, 0, 0, $conf->currency).'</span>';
1160  }
1161  print '</td></tr>';
1162 
1163  // Other attributes
1164  $cols = 2;
1165  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
1166 
1167  print '</table>';
1168 
1169  print '</div>';
1170  print '<div class="fichehalfright">';
1171  print '<div class="underbanner clearboth"></div>';
1172 
1173  print '<table class="border tableforfield centpercent">';
1174 
1175  // Description
1176  print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
1177  print dol_htmlentitiesbr($object->description);
1178  print '</td></tr>';
1179 
1180  // Categories
1181  if (isModEnabled('categorie')) {
1182  print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
1183  print $form->showCategories($object->id, Categorie::TYPE_PROJECT, 1);
1184  print "</td></tr>";
1185  }
1186 
1187  print '</table>';
1188 
1189  print '</div>';
1190  print '</div>';
1191 
1192  print '<div class="clearboth"></div>';
1193  }
1194 
1195  print dol_get_fiche_end();
1196 
1197  if ($action == 'edit' && $userWrite > 0) {
1198  print $form->buttonsSaveCancel();
1199  }
1200 
1201  print '</form>';
1202 
1203  // Change probability from status
1204  if (!empty($conf->use_javascript_ajax) && !empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
1205  // Default value to close or not when we set opp to 'WON'.
1206  $defaultcheckedwhenoppclose = 1;
1207  if (empty($conf->global->PROJECT_HIDE_TASKS)) {
1208  $defaultcheckedwhenoppclose = 0;
1209  }
1210 
1211  print '<!-- Javascript to manage opportunity status change -->';
1212  print '<script type="text/javascript">
1213  jQuery(document).ready(function() {
1214  function change_percent()
1215  {
1216  var element = jQuery("#opp_status option:selected");
1217  var defaultpercent = element.attr("defaultpercent");
1218  var defaultcloseproject = '.((int) $defaultcheckedwhenoppclose).';
1219  var elemcode = element.attr("elemcode");
1220  var oldpercent = \''.dol_escape_js($object->opp_percent).'\';
1221 
1222  console.log("We select "+elemcode);
1223 
1224  /* Define if checkbox to close is checked or not */
1225  var closeproject = 0;
1226  if (elemcode == \'LOST\') closeproject = 1;
1227  if (elemcode == \'WON\') closeproject = defaultcloseproject;
1228  if (closeproject) jQuery("#inputcloseproject").prop("checked", true);
1229  else jQuery("#inputcloseproject").prop("checked", false);
1230 
1231  /* Make the close project checkbox visible or not */
1232  console.log("closeproject="+closeproject);
1233  if (elemcode == \'WON\' || elemcode == \'LOST\')
1234  {
1235  jQuery("#divtocloseproject").show();
1236  }
1237  else
1238  {
1239  jQuery("#divtocloseproject").hide();
1240  }
1241 
1242  /* Change percent with default percent (defaultpercent) if new status (defaultpercent) is higher than current (jQuery("#opp_percent").val()) */
1243  console.log("oldpercent="+oldpercent);
1244  if (oldpercent != \'\' && (parseFloat(defaultpercent) < parseFloat(oldpercent)))
1245  {
1246  if (jQuery("#opp_percent").val() != \'\' && oldpercent != \'\') jQuery("#oldopppercent").text(\' - '.dol_escape_js($langs->transnoentities("PreviousValue")).': \'+oldpercent+\' %\');
1247  if (parseFloat(oldpercent) != 100) { jQuery("#opp_percent").val(oldpercent); }
1248  else { jQuery("#opp_percent").val(defaultpercent); }
1249  }
1250  else
1251  {
1252  if ((parseFloat(jQuery("#opp_percent").val()) < parseFloat(defaultpercent)));
1253  {
1254  if (jQuery("#opp_percent").val() != \'\' && oldpercent != \'\') jQuery("#oldopppercent").text(\' - '.dol_escape_js($langs->transnoentities("PreviousValue")).': \'+oldpercent+\' %\');
1255  jQuery("#opp_percent").val(defaultpercent);
1256  }
1257  }
1258  }
1259 
1260  jQuery("#opp_status").change(function() {
1261  change_percent();
1262  });
1263  });
1264  </script>';
1265  }
1266 
1267  /*
1268  * Actions Buttons
1269  */
1270  print '<div class="tabsAction">';
1271  $parameters = array();
1272  $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
1273  // modified by hook
1274  if (empty($reshook)) {
1275  if ($action != "edit" && $action != 'presend') {
1276  // Create event
1277  /*if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a
1278  // "workflow" action so should appears somewhere else on
1279  // page.
1280  {
1281  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>';
1282  }*/
1283 
1284  // Send
1285  if (empty($user->socid)) {
1286  if ($object->statut != Project::STATUS_CLOSED) {
1287  print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER["PHP_SELF"].'?action=presend&amp;token='.newToken().'&amp;id='.$object->id.'&amp;mode=init#formmailbeforetitle', '');
1288  }
1289  }
1290 
1291  // Modify
1292  if ($object->statut != Project::STATUS_CLOSED && $user->rights->projet->creer) {
1293  if ($userWrite > 0) {
1294  print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?action=edit&amp;token='.newToken().'&amp;id='.$object->id, '');
1295  } else {
1296  print dolGetButtonAction($langs->trans('NotOwnerOfProject'), $langs->trans('Modify'), 'default', $_SERVER['PHP_SELF']. '#', '', false);
1297  }
1298  }
1299 
1300  // Validate
1301  if ($object->statut == Project::STATUS_DRAFT && $user->rights->projet->creer) {
1302  if ($userWrite > 0) {
1303  print dolGetButtonAction('', $langs->trans('Validate'), 'default', $_SERVER["PHP_SELF"].'?action=validate&amp;token='.newToken().'&amp;id='.$object->id, '');
1304  } else {
1305  print dolGetButtonAction($langs->trans('NotOwnerOfProject'), $langs->trans('Validate'), 'default', $_SERVER['PHP_SELF']. '#', '', false);
1306  }
1307  }
1308 
1309  // Close
1310  if ($object->statut == Project::STATUS_VALIDATED && $user->rights->projet->creer) {
1311  if ($userWrite > 0) {
1312  print dolGetButtonAction('', $langs->trans('Close'), 'default', $_SERVER["PHP_SELF"].'?action=close&amp;token='.newToken().'&amp;id='.$object->id, '');
1313  } else {
1314  print dolGetButtonAction($langs->trans('NotOwnerOfProject'), $langs->trans('Close'), 'default', $_SERVER['PHP_SELF']. '#', '', false);
1315  }
1316  }
1317 
1318  // Reopen
1319  if ($object->statut == Project::STATUS_CLOSED && $user->rights->projet->creer) {
1320  if ($userWrite > 0) {
1321  print dolGetButtonAction('', $langs->trans('ReOpen'), 'default', $_SERVER["PHP_SELF"].'?action=reopen&amp;token='.newToken().'&amp;id='.$object->id, '');
1322  } else {
1323  print dolGetButtonAction($langs->trans('NotOwnerOfProject'), $langs->trans('ReOpen'), 'default', $_SERVER['PHP_SELF']. '#', '', false);
1324  }
1325  }
1326 
1327  // Add button to create objects from project
1328  if (!empty($conf->global->PROJECT_SHOW_CREATE_OBJECT_BUTTON)) {
1329  if (!empty($conf->propal->enabled) && $user->rights->propal->creer) {
1330  $langs->load("propal");
1331  print dolGetButtonAction('', $langs->trans('AddProp'), 'default', DOL_URL_ROOT.'/comm/propal/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, '');
1332  }
1333  if (!empty($conf->commande->enabled) && $user->rights->commande->creer) {
1334  $langs->load("orders");
1335  print dolGetButtonAction('', $langs->trans('CreateOrder'), 'default', DOL_URL_ROOT.'/commande/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, '');
1336  }
1337  if (isModEnabled('facture') && $user->rights->facture->creer) {
1338  $langs->load("bills");
1339  print dolGetButtonAction('', $langs->trans('CreateBill'), 'default', DOL_URL_ROOT.'/compta/facture/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, '');
1340  }
1341  if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->creer) {
1342  $langs->load("supplier_proposal");
1343  print dolGetButtonAction('', $langs->trans('AddSupplierProposal'), 'default', DOL_URL_ROOT.'/supplier_proposal/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, '');
1344  }
1345  if (!empty($conf->supplier_order->enabled) && ($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer)) {
1346  $langs->load("suppliers");
1347  print dolGetButtonAction('', $langs->trans('AddSupplierOrder'), 'default', DOL_URL_ROOT.'/fourn/commande/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, '');
1348  }
1349  if (!empty($conf->supplier_invoice->enabled) && ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer)) {
1350  $langs->load("suppliers");
1351  print dolGetButtonAction('', $langs->trans('AddSupplierInvoice'), 'default', DOL_URL_ROOT.'/fourn/facture/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, '');
1352  }
1353  if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer) {
1354  $langs->load("interventions");
1355  print dolGetButtonAction('', $langs->trans('AddIntervention'), 'default', DOL_URL_ROOT.'/fichinter/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, '');
1356  }
1357  if (!empty($conf->contrat->enabled) && $user->rights->contrat->creer) {
1358  $langs->load("contracts");
1359  print dolGetButtonAction('', $langs->trans('AddContract'), 'default', DOL_URL_ROOT.'/contrat/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, '');
1360  }
1361  if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->creer) {
1362  $langs->load("trips");
1363  print dolGetButtonAction('', $langs->trans('AddTrip'), 'default', DOL_URL_ROOT.'/expensereport/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, '');
1364  }
1365  if (!empty($conf->don->enabled) && $user->rights->don->creer) {
1366  $langs->load("donations");
1367  print dolGetButtonAction('', $langs->trans('AddDonation'), 'default', DOL_URL_ROOT.'/don/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, '');
1368  }
1369  }
1370 
1371  // Clone
1372  if ($user->rights->projet->creer) {
1373  if ($userWrite > 0) {
1374  print dolGetButtonAction('', $langs->trans('ToClone'), 'default', $_SERVER["PHP_SELF"].'?action=clone&amp;token='.newToken().'&amp;id='.$object->id, '');
1375  } else {
1376  print dolGetButtonAction($langs->trans('NotOwnerOfProject'), $langs->trans('ToClone'), 'default', $_SERVER['PHP_SELF']. '#', '', false);
1377  }
1378  }
1379 
1380  // Delete
1381  if ($user->rights->projet->supprimer || ($object->statut == Project::STATUS_DRAFT && $user->rights->projet->creer)) {
1382  if ($userDelete > 0 || ($object->statut == Project::STATUS_DRAFT && $user->rights->projet->creer)) {
1383  print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?action=delete&amp;token='.newToken().'&amp;id='.$object->id, '');
1384  } else {
1385  print dolGetButtonAction($langs->trans('NotOwnerOfProject'), $langs->trans('Delete'), 'default', $_SERVER['PHP_SELF']. '#', '', false);
1386  }
1387  }
1388  }
1389  }
1390 
1391  print "</div>";
1392 
1393  if (GETPOST('modelselected')) {
1394  $action = 'presend';
1395  }
1396 
1397  if ($action != 'presend') {
1398  print '<div class="fichecenter"><div class="fichehalfleft">';
1399  print '<a name="builddoc"></a>'; // ancre
1400 
1401  /*
1402  * Generated documents
1403  */
1404  $filename = dol_sanitizeFileName($object->ref);
1405  $filedir = $conf->project->multidir_output[$object->entity]."/".dol_sanitizeFileName($object->ref);
1406  $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
1407  $genallowed = ($user->rights->projet->lire && $userAccess > 0);
1408  $delallowed = ($user->rights->projet->creer && $userWrite > 0);
1409 
1410  print $formfile->showdocuments('project', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 0, 0, '', '', '', '', '', $object);
1411 
1412  print '</div><div class="fichehalfright">';
1413 
1414  $MAXEVENT = 10;
1415 
1416  $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/projet/info.php?id='.$object->id);
1417 
1418  // List of actions on element
1419  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
1420  $formactions = new FormActions($db);
1421  $somethingshown = $formactions->showactions($object, 'project', 0, 1, '', $MAXEVENT, '', $morehtmlcenter);
1422 
1423  print '</div></div>';
1424  }
1425 
1426  // Presend form
1427  $modelmail = 'project';
1428  $defaulttopic = 'SendProjectRef';
1429  $diroutput = $conf->project->multidir_output[$object->entity];
1430  $autocopy = 'MAIN_MAIL_AUTOCOPY_PROJECT_TO'; // used to know the automatic BCC to add
1431  $trackid = 'proj'.$object->id;
1432 
1433  include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
1434 
1435  // Hook to add more things on page
1436  $parameters = array();
1437  $reshook = $hookmanager->executeHooks('mainCardTabAddMore', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1438 } else {
1439  print $langs->trans("RecordNotFound");
1440 }
1441 
1442 // End of page
1443 llxFooter();
1444 $db->close();
Societe
Class to manage third parties objects (customers, suppliers, prospects...)
Definition: societe.class.php:48
dol_escape_htmltag
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
Definition: functions.lib.php:1468
dol_sanitizeFileName
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Definition: functions.lib.php:1226
restrictedArea
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
Definition: security.lib.php:234
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
Project
Class to manage projects.
Definition: project.class.php:35
dolButtonToOpenUrlInDialogPopup
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled='', $morecss='button bordertransp', $backtopagejsfields='')
Return HTML code to output a button to open a dialog popup box.
Definition: functions.lib.php:1720
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
FormActions
Class to manage building of HTML components.
Definition: html.formactions.class.php:30
img_help
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
Definition: functions.lib.php:4481
dol_include_once
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
Definition: functions.lib.php:1033
Translate
Class to manage translations.
Definition: translate.class.php:30
dol_buildpath
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
Definition: functions.lib.php:1062
img_warning
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
Definition: functions.lib.php:4521
Task
Class to manage tasks.
Definition: task.class.php:37
FormProjets
Class to manage building of HTML components.
Definition: html.formprojet.class.php:30
project_prepare_head
project_prepare_head(Project $project, $moreparam='')
Prepare array with list of tabs.
Definition: project.lib.php:38
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
dolGetButtonAction
dolGetButtonAction($label, $html='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
Definition: functions.lib.php:10450
Categorie
Class to manage categories.
Definition: categorie.class.php:47
dol_banner_tab
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
Definition: functions.lib.php:2046
$help_url
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:116
price2num
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
Definition: functions.lib.php:5661
dol_print_date
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Definition: functions.lib.php:2514
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
dol_delete_file
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.
Definition: files.lib.php:1231
$formactions
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif($action=='specimen') elseif($action=='setmodel') elseif($action=='del') elseif($action=='setdoc') $formactions
View.
Definition: agenda_other.php:178
dol_escape_js
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
Definition: functions.lib.php:1423
dol_getIdFromCode
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
Definition: functions.lib.php:8535
FormFile
Class to offer components to list and upload files.
Definition: html.formfile.class.php:36
dolGetButtonTitle
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
Definition: functions.lib.php:10605
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1603
setEventMessage
setEventMessage($mesgs, $style='mesgs')
Set event message in dol_events session object.
Definition: functions.lib.php:8108
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
getDolGlobalString
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
Definition: functions.lib.php:80
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:10878
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:105
User
Class to manage Dolibarr users.
Definition: user.class.php:44
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
Project\STATUS_VALIDATED
const STATUS_VALIDATED
Open/Validated status.
Definition: project.class.php:303
ExtraFields
Class to manage standard extra fields.
Definition: extrafields.class.php:39
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
$parameters
$parameters
Actions.
Definition: card.php:78
dol_htmlentitiesbr
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
Definition: functions.lib.php:6991
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2845
price
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.
Definition: functions.lib.php:5541
Project\STATUS_CLOSED
const STATUS_CLOSED
Closed status.
Definition: project.class.php:308
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
dol_mktime
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
Definition: functions.lib.php:2757
getDolGlobalInt
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
Definition: functions.lib.php:93
Project\STATUS_DRAFT
const STATUS_DRAFT
Draft status.
Definition: project.class.php:298
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59
DolEditor
Class to manage a WYSIWYG editor.
Definition: doleditor.class.php:30
vatrate
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formated for view output Used into pdf and HTML pages.
Definition: functions.lib.php:5492