document.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. $object->fetch($id,$ref);
  44. if ($object->id > 0)
  45. {
  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. if ($object->societe->id > 0) $result=$object->societe->fetch($object->societe->id);
  72. // To verify role of users
  73. //$userAccess = $object->restrictedProjectArea($user,'read');
  74. $userWrite = $object->restrictedProjectArea($user,'write');
  75. //$userDelete = $object->restrictedProjectArea($user,'delete');
  76. //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete;
  77. $head = project_prepare_head($object);
  78. dol_fiche_head($head, 'document', $langs->trans("Project"), 0, ($object->public?'projectpub':'project'));
  79. // Files list constructor
  80. $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
  81. $totalsize=0;
  82. foreach($filearray as $key => $file)
  83. {
  84. $totalsize+=$file['size'];
  85. }
  86. print '<table class="border" width="100%">';
  87. $linkback = '<a href="'.DOL_URL_ROOT.'/projet/liste.php">'.$langs->trans("BackToList").'</a>';
  88. // Ref
  89. print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>';
  90. // Define a complementary filter for search of next/prev ref.
  91. if (! $user->rights->projet->all->lire)
  92. {
  93. $projectsListId = $object->getProjectsAuthorizedForUser($user,$mine,0);
  94. $object->next_prev_filter=" rowid in (".(count($projectsListId)?join(',',array_keys($projectsListId)):'0').")";
  95. }
  96. print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref');
  97. print '</td></tr>';
  98. // Label
  99. print '<tr><td>'.$langs->trans("Label").'</td><td>'.$object->title.'</td></tr>';
  100. // Company
  101. print '<tr><td>'.$langs->trans("ThirdParty").'</td><td>';
  102. if (! empty($object->societe->id)) print $object->societe->getNomUrl(1);
  103. else print '&nbsp;';
  104. print '</td></tr>';
  105. // Visibility
  106. print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
  107. if ($object->public) print $langs->trans('SharedProject');
  108. else print $langs->trans('PrivateProject');
  109. print '</td></tr>';
  110. // Statut
  111. print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
  112. // Files infos
  113. print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
  114. print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
  115. print "</table>\n";
  116. print "</div>\n";
  117. $modulepart = 'project';
  118. $permission = ($userWrite > 0);
  119. include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
  120. }
  121. else
  122. {
  123. dol_print_error('','NoRecordFound');
  124. }
  125. llxFooter();
  126. $db->close();