document.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <?php
  2. /* Copyright (C) 2010 Regis Houssin <regis.houssin@capnetworks.com>
  3. * Copyright (C) 2012 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.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 <http://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/projet/document.php
  21. * \ingroup project
  22. * \brief Page de gestion des documents attachees a un projet
  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/lib/files.lib.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  30. $langs->load('projects');
  31. $langs->load('other');
  32. $action = GETPOST('action','alpha');
  33. $confirm = GETPOST('confirm','alpha');
  34. $id = GETPOST('id','int');
  35. $ref = GETPOST('ref','alpha');
  36. $mine = (GETPOST('mode','alpha') == 'mine' ? 1 : 0);
  37. //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
  38. // Security check
  39. $socid=0;
  40. if ($user->societe_id > 0) $socid=$user->societe_id;
  41. $result=restrictedArea($user,'projet',$id,'');
  42. $object = new Project($db);
  43. if ($id > 0 || ! empty($ref))
  44. {
  45. $object->fetch($id,$ref);
  46. $object->fetch_thirdparty();
  47. $upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref);
  48. }
  49. // Get parameters
  50. $sortfield = GETPOST("sortfield",'alpha');
  51. $sortorder = GETPOST("sortorder",'alpha');
  52. $page = GETPOST("page",'int');
  53. if ($page == -1) { $page = 0; }
  54. $offset = $conf->liste_limit * $page;
  55. $pageprev = $page - 1;
  56. $pagenext = $page + 1;
  57. if (! $sortorder) $sortorder="ASC";
  58. if (! $sortfield) $sortfield="name";
  59. /*
  60. * Actions
  61. */
  62. include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php';
  63. /*
  64. * View
  65. */
  66. llxHeader('',$langs->trans('Project'),'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes');
  67. $form = new Form($db);
  68. if ($object->id > 0)
  69. {
  70. $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref);
  71. // To verify role of users
  72. //$userAccess = $object->restrictedProjectArea($user,'read');
  73. $userWrite = $object->restrictedProjectArea($user,'write');
  74. //$userDelete = $object->restrictedProjectArea($user,'delete');
  75. //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete;
  76. $head = project_prepare_head($object);
  77. dol_fiche_head($head, 'document', $langs->trans("Project"), 0, ($object->public?'projectpub':'project'));
  78. // Files list constructor
  79. $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
  80. $totalsize=0;
  81. foreach($filearray as $key => $file)
  82. {
  83. $totalsize+=$file['size'];
  84. }
  85. print '<table class="border" width="100%">';
  86. $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php">'.$langs->trans("BackToList").'</a>';
  87. // Ref
  88. print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>';
  89. // Define a complementary filter for search of next/prev ref.
  90. if (! $user->rights->projet->all->lire)
  91. {
  92. $projectsListId = $object->getProjectsAuthorizedForUser($user,$mine,0);
  93. $object->next_prev_filter=" rowid in (".(count($projectsListId)?join(',',array_keys($projectsListId)):'0').")";
  94. }
  95. print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref');
  96. print '</td></tr>';
  97. // Label
  98. print '<tr><td>'.$langs->trans("Label").'</td><td>'.$object->title.'</td></tr>';
  99. // Company
  100. print '<tr><td>'.$langs->trans("ThirdParty").'</td><td>';
  101. if (! empty($object->thirdparty->id)) print $object->thirdparty->getNomUrl(1);
  102. else print '&nbsp;';
  103. print '</td></tr>';
  104. // Visibility
  105. print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
  106. if ($object->public) print $langs->trans('SharedProject');
  107. else print $langs->trans('PrivateProject');
  108. print '</td></tr>';
  109. // Statut
  110. print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
  111. // Files infos
  112. print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
  113. print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
  114. print "</table>\n";
  115. print "</div>\n";
  116. $modulepart = 'project';
  117. $permission = ($userWrite > 0);
  118. include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
  119. }
  120. else
  121. {
  122. dol_print_error('','NoRecordFound');
  123. }
  124. llxFooter();
  125. $db->close();