event.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. <?php
  2. /* Copyright (C) 2010 Regis Houssin <regis.houssin@inodbox.com>
  3. * Copyright (C) 2012 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2021 florian.henry@scopen.fr <florian.henry@scopen.fr>
  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. /**
  20. * \file htdocs/projet/event.php
  21. * \ingroup project
  22. * \brief Tab event organization
  23. */
  24. require '../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
  28. require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  29. // Load translation files required by the page
  30. $langs->load('projects', 'eventorganization');
  31. $action = GETPOST('action', 'aZ09');
  32. $id = GETPOST('id', 'int');
  33. $ref = GETPOST('ref', 'alpha');
  34. $mine = $_REQUEST['mode'] == 'mine' ? 1 : 0;
  35. //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
  36. $object = new Project($db);
  37. include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once
  38. // Security check
  39. $socid = 0;
  40. if ($user->socid > 0) {
  41. $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement.
  42. }
  43. $result = restrictedArea($user, 'eventorganization', $id);
  44. $permissiontoread = $user->rights->eventorganization->read;
  45. $permissiontoadd = $user->rights->eventorganization->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
  46. $permissiontodelete = $user->rights->eventorganization->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
  47. /*
  48. * Actions
  49. */
  50. if ($action == 'update' && empty(GETPOST('cancel')) && $permissiontoadd) {
  51. $error = 0;
  52. $object->oldcopy = clone $object;
  53. $object->accept_conference_suggestions=(GETPOST('accept_conference_suggestions', 'alpha') == 'on' ? 1 : 0);
  54. $object->accept_booth_suggestions=(GETPOST('accept_booth_suggestions', 'alpha') == 'on' ? 1 : 0);
  55. $object->price_registration=price2num(GETPOST('price_registration', 'alphanohtml'));;
  56. $object->price_booth=price2num(GETPOST('price_booth', 'alphanohtml'));;
  57. $result = $object->update($user);
  58. if ($result < 0) {
  59. setEventMessages($object->error, $object->errors, 'errors');
  60. $db->rollback();
  61. $action = 'edit';
  62. } else {
  63. $db->commit();
  64. if (GETPOST('socid', 'int') > 0) {
  65. $object->fetch_thirdparty(GETPOST('socid', 'int'));
  66. } else {
  67. unset($object->thirdparty);
  68. }
  69. $action='';
  70. }
  71. }
  72. /*
  73. * View
  74. */
  75. $title = $langs->trans("Project").' - '.$langs->trans("ConferenceOrBoothTab").' - '.$object->ref.' '.$object->name;
  76. if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
  77. $title = $object->ref.' '.$object->name.' - '.$langs->trans("Note");
  78. }
  79. //TODO Make wiki docs
  80. $help_url = '';
  81. llxHeader("", $title, $help_url);
  82. $form = new Form($db);
  83. $userstatic = new User($db);
  84. $now = dol_now();
  85. if ($id > 0 || !empty($ref)) {
  86. $head = project_prepare_head($object);
  87. print dol_get_fiche_head($head, 'eventorganisation', $langs->trans('ConferenceOrBoothTab'), -1);
  88. // Project card
  89. $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  90. $morehtmlref = '<div class="refidno">';
  91. // Title
  92. $morehtmlref .= $object->title;
  93. // Thirdparty
  94. if ($object->thirdparty->id > 0) {
  95. $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project');
  96. }
  97. $morehtmlref .= '</div>';
  98. // Define a complementary filter for search of next/prev ref.
  99. if (!$user->rights->projet->all->lire) {
  100. $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
  101. $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
  102. }
  103. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  104. print '<div class="fichecenter">';
  105. print '<div class="fichehalfleft">';
  106. print '<div class="underbanner clearboth"></div>';
  107. print '<table class="border tableforfield" width="100%">';
  108. // Usage
  109. print '<tr><td class="tdtop">';
  110. print $langs->trans("Usage");
  111. print '</td>';
  112. print '<td>';
  113. if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
  114. print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_opportunity ? ' checked="checked"' : '')).'"> ';
  115. $htmltext = $langs->trans("ProjectFollowOpportunity");
  116. print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext);
  117. print '<br>';
  118. }
  119. if (empty($conf->global->PROJECT_HIDE_TASKS)) {
  120. print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_task ? ' checked="checked"' : '')).'"> ';
  121. $htmltext = $langs->trans("ProjectFollowTasks");
  122. print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext);
  123. print '<br>';
  124. }
  125. if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
  126. 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"' : '')).'"> ';
  127. $htmltext = $langs->trans("ProjectBillTimeDescription");
  128. print $form->textwithpicto($langs->trans("BillTime"), $htmltext);
  129. print '<br>';
  130. }
  131. if (!empty($conf->eventorganization->enabled)) {
  132. 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"' : '')).'"> ';
  133. $htmltext = $langs->trans("EventOrganizationDescriptionLong");
  134. print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext);
  135. }
  136. print '</td></tr>';
  137. // Visibility
  138. print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
  139. if ($object->public) {
  140. print $langs->trans('SharedProject');
  141. } else {
  142. print $langs->trans('PrivateProject');
  143. }
  144. print '</td></tr>';
  145. if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) && !empty($object->usage_opportunity)) {
  146. // Opportunity status
  147. print '<tr><td>'.$langs->trans("OpportunityStatus").'</td><td>';
  148. $code = dol_getIdFromCode($db, $object->opp_status, 'c_lead_status', 'rowid', 'code');
  149. if ($code) {
  150. print $langs->trans("OppStatus".$code);
  151. }
  152. print '</td></tr>';
  153. // Opportunity percent
  154. print '<tr><td>'.$langs->trans("OpportunityProbability").'</td><td>';
  155. if (strcmp($object->opp_percent, '')) {
  156. print price($object->opp_percent, 0, $langs, 1, 0).' %';
  157. }
  158. print '</td></tr>';
  159. // Opportunity Amount
  160. print '<tr><td>'.$langs->trans("OpportunityAmount").'</td><td>';
  161. /*if ($object->opp_status)
  162. {
  163. print price($obj->opp_amount, 1, $langs, 1, 0, -1, $conf->currency);
  164. }*/
  165. if (strcmp($object->opp_amount, '')) {
  166. print price($object->opp_amount, 0, $langs, 1, 0, -1, $conf->currency);
  167. }
  168. print '</td></tr>';
  169. // Opportunity Weighted Amount
  170. print '<tr><td>'.$langs->trans('OpportunityWeightedAmount').'</td><td>';
  171. if (strcmp($object->opp_amount, '') && strcmp($object->opp_percent, '')) {
  172. print price($object->opp_amount * $object->opp_percent / 100, 0, $langs, 1, 0, -1, $conf->currency);
  173. }
  174. print '</td></tr>';
  175. }
  176. // Date start - end
  177. print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>';
  178. $start = dol_print_date($object->date_start, 'day');
  179. print ($start ? $start : '?');
  180. $end = dol_print_date($object->date_end, 'day');
  181. print ' - ';
  182. print ($end ? $end : '?');
  183. if ($object->hasDelay()) {
  184. print img_warning("Late");
  185. }
  186. print '</td></tr>';
  187. // Budget
  188. print '<tr><td>'.$langs->trans("Budget").'</td><td>';
  189. if (strcmp($object->budget_amount, '')) {
  190. print price($object->budget_amount, 0, $langs, 1, 0, 0, $conf->currency);
  191. }
  192. print '</td></tr>';
  193. // Other attributes
  194. $cols = 2;
  195. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
  196. print '</table>';
  197. print '</div>';
  198. print '<div class="fichehalfright">';
  199. print '<div class="ficheaddleft">';
  200. print '<div class="underbanner clearboth"></div>';
  201. if ($action == 'edit') {
  202. print '<form action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
  203. print '<input type="hidden" name="token" value="' . newToken() . '">';
  204. print '<input type="hidden" name="action" value="update">';
  205. print '<input type="hidden" name="id" value="' . $object->id . '">';
  206. }
  207. print '<table class="border tableforfield" width="100%">';
  208. // Description
  209. print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
  210. print dol_htmlentitiesbr($object->description);
  211. print '</td></tr>';
  212. // Categories
  213. if ($conf->categorie->enabled) {
  214. print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
  215. print $form->showCategories($object->id, Categorie::TYPE_PROJECT, 1);
  216. print "</td></tr>";
  217. }
  218. if ($action == 'edit' && $permissiontoadd) {
  219. //Allow unknown people to suggest conferences
  220. print '<tr><td class="valignmiddle">' . $langs->trans("AllowUnknownPeopleSuggestConf") . $form->textwithpicto('', $langs->trans("AllowUnknownPeopleSuggestConfHelp")) . '</td><td>';
  221. print '<input type="checkbox" name="accept_conference_suggestions"' . (GETPOSTISSET('accept_conference_suggestions') ? (GETPOST('accept_conference_suggestions', 'alpha') != '' ? ' checked="checked"' : '') : ($object->accept_conference_suggestions ? ' checked="checked"' : '')) . '"> ';
  222. print "</td></tr>";
  223. //Allow unknown people to suggest booth
  224. print '<tr><td class="valignmiddle">' . $langs->trans("AllowUnknownPeopleSuggestBooth") . $form->textwithpicto('', $langs->trans("AllowUnknownPeopleSuggestBoothHelp")) . '</td><td>';
  225. print '<input type="checkbox" name="accept_booth_suggestions"' . (GETPOSTISSET('accept_booth_suggestions') ? (GETPOST('accept_booth_suggestions', 'alpha') != '' ? ' checked="checked"' : '') : ($object->accept_booth_suggestions ? ' checked="checked"' : '')) . '"> ';
  226. print "</td></tr>";
  227. //Price of registration
  228. print '<tr><td class="valignmiddle">' . $langs->trans("PriceOfRegistration") . '</td><td>';
  229. print '<input size="5" type="text" name="price_registration" value="'.(GETPOSTISSET('price_registration') ? GETPOST('price_registration') : (strcmp($object->price_registration, '') ? price2num($object->price_registration) : '')).'">';
  230. print "</td></tr>";
  231. //Price of registration
  232. print '<tr><td class="valignmiddle">' . $langs->trans("PriceOfBooth") . '</td><td>';
  233. print '<input size="5" type="text" name="price_booth" value="'.(GETPOSTISSET('price_booth') ? GETPOST('price_booth') : (strcmp($object->price_booth, '') ? price2num($object->price_booth) : '')).'">';
  234. print "</td></tr>";
  235. } else {
  236. //Allow unknown people to suggest conferences
  237. print '<tr><td class="valignmiddle">' . $langs->trans("AllowUnknownPeopleSuggestConf") . $form->textwithpicto('', $langs->trans("AllowUnknownPeopleSuggestConfHelp")) . '</td><td>';
  238. print '<input type="checkbox" disabled name="accept_conference_suggestions"' . (GETPOSTISSET('accept_conference_suggestions') ? (GETPOST('accept_conference_suggestions', 'alpha') != '' ? ' checked="checked"' : '') : ($object->accept_conference_suggestions ? ' checked="checked"' : '')) . '"> ';
  239. print "</td></tr>";
  240. //Allow unknown people to suggest booth
  241. print '<tr><td class="valignmiddle">' . $langs->trans("AllowUnknownPeopleSuggestBooth") . $form->textwithpicto('', $langs->trans("AllowUnknownPeopleSuggestBoothHelp")) . '</td><td>';
  242. print '<input type="checkbox" disabled name="accept_booth_suggestions"' . (GETPOSTISSET('accept_booth_suggestions') ? (GETPOST('accept_booth_suggestions', 'alpha') != '' ? ' checked="checked"' : '') : ($object->accept_booth_suggestions ? ' checked="checked"' : '')) . '"> ';
  243. print "</td></tr>";
  244. //Price of registration
  245. print '<tr><td class="valignmiddle">' . $langs->trans("PriceOfRegistration") . '</td><td>';
  246. if (strcmp($object->price_registration, '')) {
  247. print price($object->price_registration, 0, $langs, 1, 0, 0, $conf->currency);
  248. }
  249. print "</td></tr>";
  250. //Price of registration
  251. print '<tr><td class="valignmiddle">' . $langs->trans("PriceOfBooth") . '</td><td>';
  252. if (strcmp($object->price_booth, '')) {
  253. print price($object->price_booth, 0, $langs, 1, 0, 0, $conf->currency);
  254. }
  255. print "</td></tr>";
  256. }
  257. //ICS Link
  258. print '<tr><td class="valignmiddle">'.$langs->trans("EventOrganizationICSLink").'</td><td>';
  259. //TODO ICS Link
  260. //print '<a href="ICSLink">ICS</a>';
  261. print "</td></tr>";
  262. print '</table>';
  263. print '</table>';
  264. print '</div>';
  265. print '</div>';
  266. print '</div>';
  267. print '<div class="clearboth"></div>';
  268. }
  269. print dol_get_fiche_end();
  270. if ($action == 'edit' && $permissiontoadd > 0) {
  271. print '<div class="center">';
  272. print '<input name="update" class="button" type="submit" value="'.$langs->trans("Save").'">&nbsp; &nbsp; &nbsp;';
  273. print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
  274. print '</div>';
  275. print '</form>';
  276. }
  277. /*
  278. * Actions Buttons
  279. */
  280. print '<div class="tabsAction">';
  281. $parameters = array();
  282. $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
  283. // modified by hook
  284. if (empty($reshook)) {
  285. // Modify
  286. if ($object->statut != Project::STATUS_CLOSED && $action=='') {
  287. if ($permissiontoadd > 0) {
  288. print '<a class="butAction" href="event.php?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>';
  289. } else {
  290. print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('Modify').'</a>';
  291. }
  292. }
  293. }
  294. // End of page
  295. llxFooter();
  296. $db->close();