document.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <?php
  2. /* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
  5. * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
  6. * Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
  7. * Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
  8. * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. */
  23. /**
  24. * \file htdocs/fichinter/document.php
  25. * \ingroup fichinter
  26. * \brief Page des documents joints sur les contrats
  27. */
  28. require '../main.inc.php';
  29. require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
  30. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
  32. require_once DOL_DOCUMENT_ROOT.'/core/lib/fichinter.lib.php';
  33. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  34. $langs->load("other");
  35. $langs->load("fichinter");
  36. $langs->load("companies");
  37. $langs->load("interventions");
  38. $id = GETPOST('id','int');
  39. $ref = GETPOST('ref', 'alpha');
  40. $action = GETPOST('action','alpha');
  41. $confirm = GETPOST('confirm','alpha');
  42. // Security check
  43. if ($user->societe_id) $socid=$user->societe_id;
  44. $result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
  45. // Get parameters
  46. $sortfield = GETPOST('sortfield','alpha');
  47. $sortorder = GETPOST('sortorder','alpha');
  48. $page = GETPOST('page','int');
  49. if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
  50. $offset = $conf->liste_limit * $page;
  51. $pageprev = $page - 1;
  52. $pagenext = $page + 1;
  53. if (! $sortorder) $sortorder="ASC";
  54. if (! $sortfield) $sortfield="name";
  55. $object = new Fichinter($db);
  56. $object->fetch($id, $ref);
  57. $upload_dir = $conf->ficheinter->dir_output.'/'.dol_sanitizeFileName($object->ref);
  58. $modulepart='fichinter';
  59. /*
  60. * Actions
  61. */
  62. include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
  63. /*
  64. * View
  65. */
  66. $form = new Form($db);
  67. llxHeader('',$langs->trans("Intervention"));
  68. if ($object->id)
  69. {
  70. $object->fetch_thirdparty();
  71. $head=fichinter_prepare_head($object);
  72. dol_fiche_head($head, 'documents', $langs->trans("InterventionCard"), -1, 'intervention');
  73. // Construit liste des fichiers
  74. $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
  75. $totalsize=0;
  76. foreach($filearray as $key => $file)
  77. {
  78. $totalsize+=$file['size'];
  79. }
  80. // Intervention card
  81. $linkback = '<a href="'.DOL_URL_ROOT.'/fichinter/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
  82. $morehtmlref='<div class="refidno">';
  83. // Ref customer
  84. //$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
  85. //$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
  86. // Thirdparty
  87. $morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
  88. // Project
  89. if (! empty($conf->projet->enabled))
  90. {
  91. $langs->load("projects");
  92. $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
  93. if ($user->rights->commande->creer)
  94. {
  95. if ($action != 'classify')
  96. //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
  97. $morehtmlref.=' : ';
  98. if ($action == 'classify') {
  99. //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
  100. $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
  101. $morehtmlref.='<input type="hidden" name="action" value="classin">';
  102. $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  103. $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
  104. $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
  105. $morehtmlref.='</form>';
  106. } else {
  107. $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
  108. }
  109. } else {
  110. if (! empty($object->fk_project)) {
  111. $proj = new Project($db);
  112. $proj->fetch($object->fk_project);
  113. $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
  114. $morehtmlref.=$proj->ref;
  115. $morehtmlref.='</a>';
  116. } else {
  117. $morehtmlref.='';
  118. }
  119. }
  120. }
  121. $morehtmlref.='</div>';
  122. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  123. print '<div class="fichecenter">';
  124. print '<div class="underbanner clearboth"></div>';
  125. print '<table class="border" width="100%">';
  126. print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
  127. print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
  128. print '</table>';
  129. print '</div>';
  130. dol_fiche_end();
  131. $modulepart = 'ficheinter';
  132. $permission = $user->rights->ficheinter->creer;
  133. $permtoedit = $user->rights->ficheinter->creer;
  134. $param = '&id=' . $object->id;
  135. include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
  136. }
  137. else
  138. {
  139. print $langs->trans("ErrorUnknown");
  140. }
  141. llxFooter();
  142. $db->close();