PageRenderTime 52ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/htdocs/projet/fiche.php

https://bitbucket.org/speedealing/speedealing
PHP | 733 lines | 526 code | 116 blank | 91 comment | 141 complexity | 8d9e4c5df10f8261137fbfae1da0af6b MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1, GPL-3.0, MIT
  1. <?php
  2. /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.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 <http://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/projet/fiche.php
  21. * \ingroup projet
  22. * \brief Project card
  23. */
  24. require '../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  26. require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php';
  30. $langs->load("projects");
  31. $langs->load('companies');
  32. $id=GETPOST('id','int');
  33. $ref=GETPOST('ref','alpha');
  34. $action=GETPOST('action','alpha');
  35. $backtopage=GETPOST('backtopage','alpha');
  36. if ($id == '' && $ref == '' && ($action != "create" && $action != "add" && $action != "update" && ! $_POST["cancel"])) accessforbidden();
  37. $mine = GETPOST('mode')=='mine' ? 1 : 0;
  38. //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
  39. // Security check
  40. $socid=0;
  41. if ($user->societe_id > 0) $socid=$user->societe_id;
  42. $result = restrictedArea($user, 'projet', $id);
  43. // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
  44. $hookmanager->initHooks(array('projectcard'));
  45. $object = new Project($db);
  46. $object->fetch($id,$ref);
  47. if ($object->id > 0)
  48. {
  49. $object->fetch_thirdparty();
  50. }
  51. $date_start=dol_mktime(0,0,0,GETPOST('projectmonth','int'),GETPOST('projectday','int'),GETPOST('projectyear','int'));
  52. $date_end=dol_mktime(0,0,0,GETPOST('projectendmonth','int'),GETPOST('projectendday','int'),GETPOST('projectendyear','int'));;
  53. /*
  54. * Actions
  55. */
  56. // Cancel
  57. if (GETPOST("cancel") && ! empty($backtopage))
  58. {
  59. if (GETPOST("comefromclone")==1)
  60. {
  61. $result=$object->delete($user);
  62. if ($result > 0)
  63. {
  64. header("Location: index.php");
  65. exit;
  66. }
  67. else
  68. {
  69. dol_syslog($object->error,LOG_DEBUG);
  70. $mesg='<div class="error">'.$langs->trans("CantRemoveProject").'</div>';
  71. }
  72. }
  73. header("Location: ".$backtopage);
  74. exit;
  75. }
  76. //if cancel and come from clone then delete the cloned project
  77. if (GETPOST("cancel") && (GETPOST("comefromclone")==1))
  78. {
  79. $result=$object->delete($user);
  80. if ($result > 0)
  81. {
  82. header("Location: index.php");
  83. exit;
  84. }
  85. else
  86. {
  87. dol_syslog($object->error,LOG_DEBUG);
  88. $mesg='<div class="error">'.$langs->trans("CantRemoveProject").'</div>';
  89. }
  90. }
  91. if ($action == 'add' && $user->rights->projet->creer)
  92. {
  93. $error=0;
  94. if (empty($_POST["ref"]))
  95. {
  96. $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")).'</div>';
  97. $error++;
  98. }
  99. if (empty($_POST["title"]))
  100. {
  101. $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")).'</div>';
  102. $error++;
  103. }
  104. if (! $error)
  105. {
  106. $error=0;
  107. $db->begin();
  108. $object->ref = GETPOST('ref','alpha');
  109. $object->title = GETPOST('title','alpha');
  110. $object->socid = GETPOST('socid','int');
  111. $object->description = GETPOST('description','alpha');
  112. $object->public = GETPOST('public','alpha');
  113. $object->datec=dol_now();
  114. $object->date_start=$date_start;
  115. $object->date_end=$date_end;
  116. $result = $object->create($user);
  117. if ($result > 0)
  118. {
  119. // Add myself as project leader
  120. $result = $object->add_contact($user->id, 'PROJECTLEADER', 'internal');
  121. if ($result < 0)
  122. {
  123. $langs->load("errors");
  124. $mesg='<div class="error">'.$langs->trans($object->error).'</div>';
  125. $error++;
  126. }
  127. }
  128. else
  129. {
  130. $langs->load("errors");
  131. $mesg='<div class="error">'.$langs->trans($object->error).'</div>';
  132. $error++;
  133. }
  134. if (! $error)
  135. {
  136. $db->commit();
  137. header("Location:fiche.php?id=".$object->id);
  138. exit;
  139. }
  140. else
  141. {
  142. $db->rollback();
  143. $action = 'create';
  144. }
  145. }
  146. else
  147. {
  148. $action = 'create';
  149. }
  150. }
  151. if ($action == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer)
  152. {
  153. $error=0;
  154. if (empty($ref))
  155. {
  156. $error++;
  157. //$_GET["id"]=$_POST["id"]; // On retourne sur la fiche projet
  158. $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")).'</div>';
  159. }
  160. if (empty($_POST["title"]))
  161. {
  162. $error++;
  163. //$_GET["id"]=$_POST["id"]; // On retourne sur la fiche projet
  164. $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")).'</div>';
  165. }
  166. if (! $error)
  167. {
  168. $object->oldcopy = dol_clone($object);
  169. $old_start_date = $object->date_start;
  170. $object->ref = GETPOST('ref','alpha');
  171. $object->title = GETPOST('title','alpha');
  172. $object->socid = GETPOST('socid','int');
  173. $object->description = GETPOST('description','alpha');
  174. $object->public = GETPOST('public','alpha');
  175. $object->date_start = empty($_POST["project"])?'':$date_start;
  176. $object->date_end = empty($_POST["projectend"])?'':$date_end;
  177. $result=$object->update($user);
  178. if (GETPOST("reportdate") && ($object->date_start!=$old_start_date))
  179. {
  180. $result=$object->shiftTaskDate($old_start_date);
  181. if (!$result)
  182. {
  183. $error++;
  184. $mesg='<div class="error">'.$langs->trans("ErrorShiftTaskDate").':'.$object->error.'</div>';
  185. }
  186. }
  187. }
  188. else
  189. {
  190. $action='edit';
  191. }
  192. }
  193. // Build doc
  194. if ($action == 'builddoc' && $user->rights->projet->creer)
  195. {
  196. if (GETPOST('model'))
  197. {
  198. $object->setDocModel($user, GETPOST('model'));
  199. }
  200. $outputlangs = $langs;
  201. if (GETPOST('lang_id'))
  202. {
  203. $outputlangs = new Translate();
  204. $outputlangs->setDefaultLang(GETPOST('lang_id'));
  205. }
  206. $result=project_pdf_create($db, $object, $object->modelpdf, $outputlangs);
  207. if ($result <= 0)
  208. {
  209. dol_print_error($db,$result);
  210. exit;
  211. }
  212. else
  213. {
  214. header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc'));
  215. exit;
  216. }
  217. }
  218. // Delete file in doc form
  219. if ($action == 'remove_file' && $user->rights->projet->creer)
  220. {
  221. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  222. if ($object->id > 0)
  223. {
  224. $langs->load("other");
  225. $upload_dir = $conf->projet->dir_output . "/";
  226. $file = $upload_dir . '/' . GETPOST('file');
  227. $ret=dol_delete_file($file);
  228. if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
  229. else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
  230. }
  231. }
  232. if ($action == 'confirm_validate' && GETPOST('confirm') == 'yes')
  233. {
  234. $result = $object->setValid($user);
  235. if ($result <= 0)
  236. {
  237. $mesg='<div class="error">'.$object->error.'</div>';
  238. }
  239. }
  240. if ($action == 'confirm_close' && GETPOST('confirm') == 'yes')
  241. {
  242. $result = $object->setClose($user);
  243. if ($result <= 0)
  244. {
  245. $mesg='<div class="error">'.$object->error.'</div>';
  246. }
  247. }
  248. if ($action == 'confirm_reopen' && GETPOST('confirm') == 'yes')
  249. {
  250. $result = $object->setValid($user);
  251. if ($result <= 0)
  252. {
  253. $mesg='<div class="error">'.$object->error.'</div>';
  254. }
  255. }
  256. if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights->projet->supprimer)
  257. {
  258. $object->fetch($id);
  259. $result=$object->delete($user);
  260. if ($result > 0)
  261. {
  262. header("Location: index.php");
  263. exit;
  264. }
  265. else
  266. {
  267. dol_syslog($object->error,LOG_DEBUG);
  268. $mesg='<div class="error">'.$langs->trans("CantRemoveProject").'</div>';
  269. }
  270. }
  271. if ($action == 'confirm_clone' && $user->rights->projet->creer && GETPOST('confirm') == 'yes')
  272. {
  273. $clone_contacts=GETPOST('clone_contacts')?1:0;
  274. $clone_tasks=GETPOST('clone_tasks')?1:0;
  275. $clone_files=GETPOST('clone_files')?1:0;
  276. $clone_notes=GETPOST('clone_notes')?1:0;
  277. $result=$object->createFromClone($object->id,$clone_contacts,$clone_tasks,$clone_files,$clone_notes);
  278. if ($result <= 0)
  279. {
  280. $mesg='<div class="error">'.$object->error.'</div>';
  281. }
  282. else
  283. {
  284. $object->fetch($result); // Load new object
  285. $action='edit';
  286. $comefromclone=true;
  287. }
  288. }
  289. /*
  290. * View
  291. */
  292. $form = new Form($db);
  293. $formfile = new FormFile($db);
  294. $userstatic = new User($db);
  295. llxHeader("",$langs->trans("Projects"));
  296. if ($action == 'create' && $user->rights->projet->creer)
  297. {
  298. /*
  299. * Create
  300. */
  301. print_fiche_titre($langs->trans("NewProject"));
  302. dol_htmloutput_mesg($mesg);
  303. print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  304. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  305. print '<input type="hidden" name="action" value="add">';
  306. print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
  307. print '<table class="border" width="100%">';
  308. $defaultref='';
  309. $obj = empty($conf->global->PROJECT_ADDON)?'mod_project_simple':$conf->global->PROJECT_ADDON;
  310. if (! empty($conf->global->PROJECT_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/project/".$conf->global->PROJECT_ADDON.".php"))
  311. {
  312. require_once DOL_DOCUMENT_ROOT ."/core/modules/project/".$conf->global->PROJECT_ADDON.'.php';
  313. $modProject = new $obj;
  314. $defaultref = $modProject->getNextValue($soc,$object);
  315. }
  316. if (is_numeric($defaultref) && $defaultref <= 0) $defaultref='';
  317. // Ref
  318. print '<tr><td><span class="fieldrequired">'.$langs->trans("Ref").'</span></td><td><input size="12" type="text" name="ref" value="'.($_POST["ref"]?$_POST["ref"]:$defaultref).'"></td></tr>';
  319. // Label
  320. print '<tr><td><span class="fieldrequired">'.$langs->trans("Label").'</span></td><td><input size="30" type="text" name="title" value="'.$_POST["title"].'"></td></tr>';
  321. // Customer
  322. print '<tr><td>'.$langs->trans("ThirdParty").'</td><td>';
  323. $text=$form->select_company(GETPOST('socid','int'),'socid','',1,1);
  324. $texthelp=$langs->trans("IfNeedToUseOhterObjectKeepEmpty");
  325. print $form->textwithtooltip($text.' '.img_help(),$texthelp,1);
  326. print '</td></tr>';
  327. // Public
  328. print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
  329. $array=array(0 => $langs->trans("PrivateProject"),1 => $langs->trans("SharedProject"));
  330. print $form->selectarray('public',$array,$object->public);
  331. print '</td></tr>';
  332. // Date start
  333. print '<tr><td>'.$langs->trans("DateStart").'</td><td>';
  334. print $form->select_date(($date_start?$date_start:''),'project');
  335. print '</td></tr>';
  336. // Date end
  337. print '<tr><td>'.$langs->trans("DateEnd").'</td><td>';
  338. print $form->select_date(($date_end?$date_end:-1),'projectend');
  339. print '</td></tr>';
  340. // Description
  341. print '<tr><td valign="top">'.$langs->trans("Description").'</td>';
  342. print '<td>';
  343. print '<textarea name="description" wrap="soft" cols="80" rows="'.ROWS_3.'">'.$_POST["description"].'</textarea>';
  344. print '</td></tr>';
  345. // Other options
  346. $parameters=array();
  347. $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
  348. print '</table>';
  349. print '<br><center>';
  350. print '<input type="submit" class="button" value="'.$langs->trans("Create").'">';
  351. if (! empty($backtopage))
  352. {
  353. print ' &nbsp; &nbsp; ';
  354. print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
  355. }
  356. print '</center>';
  357. print '</form>';
  358. }
  359. else
  360. {
  361. /*
  362. * Show or edit
  363. */
  364. dol_htmloutput_mesg($mesg);
  365. if ($object->societe->id > 0) $result=$object->societe->fetch($object->societe->id);
  366. // To verify role of users
  367. $userAccess = $object->restrictedProjectArea($user,'read');
  368. $userWrite = $object->restrictedProjectArea($user,'write');
  369. $userDelete = $object->restrictedProjectArea($user,'delete');
  370. //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete;
  371. $head=project_prepare_head($object);
  372. dol_fiche_head($head, 'project', $langs->trans("Project"),0,($object->public?'projectpub':'project'));
  373. // Confirmation validation
  374. if ($action == 'validate')
  375. {
  376. $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateProject'), $langs->trans('ConfirmValidateProject'), 'confirm_validate','',0,1);
  377. if ($ret == 'html') print '<br>';
  378. }
  379. // Confirmation close
  380. if ($action == 'close')
  381. {
  382. $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("CloseAProject"),$langs->trans("ConfirmCloseAProject"),"confirm_close",'','',1);
  383. if ($ret == 'html') print '<br>';
  384. }
  385. // Confirmation reopen
  386. if ($action == 'reopen')
  387. {
  388. $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("ReOpenAProject"),$langs->trans("ConfirmReOpenAProject"),"confirm_reopen",'','',1);
  389. if ($ret == 'html') print '<br>';
  390. }
  391. // Confirmation delete
  392. if ($action == 'delete')
  393. {
  394. $text=$langs->trans("ConfirmDeleteAProject");
  395. $task=new Task($db);
  396. $taskarray=$task->getTasksArray(0,0,$object->id,0,0);
  397. $nboftask=count($taskarray);
  398. if ($nboftask) $text.='<br>'.img_warning().' '.$langs->trans("ThisWillAlsoRemoveTasks",$nboftask);
  399. $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("DeleteAProject"),$text,"confirm_delete",'','',1);
  400. if ($ret == 'html') print '<br>';
  401. }
  402. // Clone confirmation
  403. if ($action == 'clone')
  404. {
  405. $formquestion=array(
  406. 'text' => $langs->trans("ConfirmClone"),
  407. array('type' => 'checkbox', 'name' => 'clone_contacts','label' => $langs->trans("CloneContacts"), 'value' => true),
  408. array('type' => 'checkbox', 'name' => 'clone_tasks', 'label' => $langs->trans("CloneTasks"), 'value' => true),
  409. array('type' => 'checkbox', 'name' => 'clone_notes', 'label' => $langs->trans("CloneNotes"), 'value' => true),
  410. array('type' => 'checkbox', 'name' => 'clone_files', 'label' => $langs->trans("CloneFiles"), 'value' => false)
  411. );
  412. print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("CloneProject"), $langs->trans("ConfirmCloneProject"), "confirm_clone", $formquestion, '', 1, 240);
  413. }
  414. if ($action == 'edit' && $userWrite > 0)
  415. {
  416. print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  417. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  418. print '<input type="hidden" name="action" value="update">';
  419. print '<input type="hidden" name="id" value="'.$object->id.'">';
  420. print '<input type="hidden" name="comefromclone" value="'.$comefromclone.'">';
  421. print '<table class="border" width="100%">';
  422. // Ref
  423. print '<tr><td width="30%">'.$langs->trans("Ref").'</td>';
  424. print '<td><input size="12" name="ref" value="'.$object->ref.'"></td></tr>';
  425. // Label
  426. print '<tr><td>'.$langs->trans("Label").'</td>';
  427. print '<td><input size="30" name="title" value="'.$object->title.'"></td></tr>';
  428. // Customer
  429. print '<tr><td>'.$langs->trans("Company").'</td><td>';
  430. $text=$form->select_company($object->societe->id,'socid','',1,1);
  431. $texthelp=$langs->trans("IfNeedToUseOhterObjectKeepEmpty");
  432. print $form->textwithtooltip($text.' '.img_help(),$texthelp,1);
  433. print '</td></tr>';
  434. // Visibility
  435. print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
  436. $array=array(0 => $langs->trans("PrivateProject"),1 => $langs->trans("SharedProject"));
  437. print $form->selectarray('public',$array,$object->public);
  438. print '</td></tr>';
  439. // Statut
  440. print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
  441. // Date start
  442. print '<tr><td>'.$langs->trans("DateStart").'</td><td>';
  443. print $form->select_date($object->date_start?$object->date_start:-1,'project');
  444. print ' &nbsp; &nbsp; <input type="checkbox" name="reportdate" value="yes" ';
  445. if ($comefromclone){print ' checked="checked" ';}
  446. print '/> '. $langs->trans("ProjectReportDate");
  447. print '</td></tr>';
  448. // Date end
  449. print '<tr><td>'.$langs->trans("DateEnd").'</td><td>';
  450. print $form->select_date($object->date_end?$object->date_end:-1,'projectend');
  451. print '</td></tr>';
  452. // Description
  453. print '<tr><td valign="top">'.$langs->trans("Description").'</td>';
  454. print '<td>';
  455. print '<textarea name="description" wrap="soft" cols="80" rows="'.ROWS_3.'">'.$object->description.'</textarea>';
  456. print '</td></tr>';
  457. // Other options
  458. $parameters=array();
  459. $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
  460. print '</table>';
  461. print '<div align="center"><br>';
  462. print '<input name="update" class="button" type="submit" value="'.$langs->trans("Modify").'"> &nbsp; ';
  463. print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></div>';
  464. print '</form>';
  465. }
  466. else
  467. {
  468. print '<table class="border" width="100%">';
  469. $linkback = '<a href="'.DOL_URL_ROOT.'/projet/liste.php">'.$langs->trans("BackToList").'</a>';
  470. // Ref
  471. print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>';
  472. // Define a complementary filter for search of next/prev ref.
  473. if (! $user->rights->projet->all->lire)
  474. {
  475. $objectsListId = $object->getProjectsAuthorizedForUser($user,$mine,0);
  476. $object->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")";
  477. }
  478. print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref');
  479. print '</td></tr>';
  480. // Label
  481. print '<tr><td>'.$langs->trans("Label").'</td><td>'.$object->title.'</td></tr>';
  482. // Third party
  483. print '<tr><td>'.$langs->trans("Company").'</td><td>';
  484. if ($object->societe->id > 0) print $object->societe->getNomUrl(1);
  485. else print'&nbsp;';
  486. print '</td></tr>';
  487. // Visibility
  488. print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
  489. if ($object->public) print $langs->trans('SharedProject');
  490. else print $langs->trans('PrivateProject');
  491. print '</td></tr>';
  492. // Statut
  493. print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
  494. // Date start
  495. print '<tr><td>'.$langs->trans("DateStart").'</td><td>';
  496. print dol_print_date($object->date_start,'day');
  497. print '</td></tr>';
  498. // Date end
  499. print '<tr><td>'.$langs->trans("DateEnd").'</td><td>';
  500. print dol_print_date($object->date_end,'day');
  501. print '</td></tr>';
  502. // Description
  503. print '<td valign="top">'.$langs->trans("Description").'</td><td>';
  504. print nl2br($object->description);
  505. print '</td></tr>';
  506. // Other options
  507. $parameters=array();
  508. $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
  509. print '</table>';
  510. }
  511. dol_fiche_end();
  512. /*
  513. * Boutons actions
  514. */
  515. print '<div class="tabsAction">';
  516. if ($action != "edit" )
  517. {
  518. // Validate
  519. if ($object->statut == 0 && $user->rights->projet->creer)
  520. {
  521. if ($userWrite > 0)
  522. {
  523. print '<a class="butAction" href="fiche.php?id='.$object->id.'&action=validate">'.$langs->trans("Valid").'</a>';
  524. }
  525. else
  526. {
  527. print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('Valid').'</a>';
  528. }
  529. }
  530. // Modify
  531. if ($object->statut != 2 && $user->rights->projet->creer)
  532. {
  533. if ($userWrite > 0)
  534. {
  535. print '<a class="butAction" href="fiche.php?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>';
  536. }
  537. else
  538. {
  539. print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('Modify').'</a>';
  540. }
  541. }
  542. // Close
  543. if ($object->statut == 1 && $user->rights->projet->creer)
  544. {
  545. if ($userWrite > 0)
  546. {
  547. print '<a class="butAction" href="fiche.php?id='.$object->id.'&amp;action=close">'.$langs->trans("Close").'</a>';
  548. }
  549. else
  550. {
  551. print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('Close').'</a>';
  552. }
  553. }
  554. // Reopen
  555. if ($object->statut == 2 && $user->rights->projet->creer)
  556. {
  557. if ($userWrite > 0)
  558. {
  559. print '<a class="butAction" href="fiche.php?id='.$object->id.'&amp;action=reopen">'.$langs->trans("ReOpen").'</a>';
  560. }
  561. else
  562. {
  563. print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('ReOpen').'</a>';
  564. }
  565. }
  566. // Clone
  567. if ($user->rights->projet->creer)
  568. {
  569. if ($userWrite > 0)
  570. {
  571. print '<a class="butAction" href="fiche.php?id='.$object->id.'&action=clone">'.$langs->trans('ToClone').'</a>';
  572. }
  573. else
  574. {
  575. print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('ToClone').'</a>';
  576. }
  577. }
  578. // Delete
  579. if ($user->rights->projet->supprimer)
  580. {
  581. if ($userDelete > 0)
  582. {
  583. print '<a class="butActionDelete" href="fiche.php?id='.$object->id.'&amp;action=delete">'.$langs->trans("Delete").'</a>';
  584. }
  585. else
  586. {
  587. print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('Delete').'</a>';
  588. }
  589. }
  590. }
  591. print "</div>";
  592. print "<br>\n";
  593. if ($action != 'presend')
  594. {
  595. print '<table width="100%"><tr><td width="50%" valign="top">';
  596. print '<a name="builddoc"></a>'; // ancre
  597. /*
  598. * Documents generes
  599. */
  600. $filename=dol_sanitizeFileName($object->ref);
  601. $filedir=$conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref);
  602. $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id;
  603. $genallowed=($user->rights->projet->lire && $userAccess > 0);
  604. $delallowed=($user->rights->projet->creer && $userWrite > 0);
  605. $var=true;
  606. $somethingshown=$formfile->show_documents('project',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf);
  607. print '</td><td valign="top" width="50%">';
  608. // List of actions on element
  609. include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
  610. $formactions=new FormActions($db);
  611. $somethingshown=$formactions->showactions($object,'project',$socid);
  612. print '</td></tr></table>';
  613. }
  614. }
  615. llxFooter();
  616. $db->close();
  617. ?>