document.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <?php
  2. /* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
  5. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
  6. * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. /**
  22. * \file htdocs/comm/propal/document.php
  23. * \ingroup propal
  24. * \brief Management page of documents attached to a business proposal
  25. */
  26. require '../../main.inc.php';
  27. require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  30. require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  32. $langs->load('compta');
  33. $langs->load('other');
  34. $action = GETPOST('action','alpha');
  35. $confirm = GETPOST('confirm','alpha');
  36. $id = GETPOST('id','int');
  37. $ref = GETPOST('ref','alpha');
  38. // Security check
  39. $socid='';
  40. if (! empty($user->societe_id))
  41. {
  42. $action='';
  43. $socid = $user->societe_id;
  44. }
  45. $result = restrictedArea($user, 'propal', $id);
  46. // Get parameters
  47. $sortfield = GETPOST("sortfield",'alpha');
  48. $sortorder = GETPOST("sortorder",'alpha');
  49. $page = GETPOST("page",'int');
  50. if ($page == -1) { $page = 0; }
  51. $offset = $conf->liste_limit * $page;
  52. $pageprev = $page - 1;
  53. $pagenext = $page + 1;
  54. if (! $sortorder) $sortorder="ASC";
  55. if (! $sortfield) $sortfield="name";
  56. $object = new Propal($db);
  57. $object->fetch($id,$ref);
  58. if ($object->id > 0)
  59. {
  60. $object->fetch_thirdparty();
  61. $upload_dir = $conf->propal->dir_output.'/'.dol_sanitizeFileName($object->ref);
  62. include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php';
  63. }
  64. /*
  65. * Actions
  66. */
  67. /*
  68. * View
  69. */
  70. llxHeader('',$langs->trans('Proposal'),'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos');
  71. $form = new Form($db);
  72. if ($object->id > 0)
  73. {
  74. $upload_dir = $conf->propal->dir_output.'/'.dol_sanitizeFileName($object->ref);
  75. $head = propal_prepare_head($object);
  76. dol_fiche_head($head, 'document', $langs->trans('Proposal'), 0, 'propal');
  77. // Construit liste des fichiers
  78. $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
  79. $totalsize=0;
  80. foreach($filearray as $key => $file)
  81. {
  82. $totalsize+=$file['size'];
  83. }
  84. print '<table class="border"width="100%">';
  85. $linkback='<a href="'.DOL_URL_ROOT.'/comm/propal/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
  86. // Ref
  87. print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="3">';
  88. print $form->showrefnav($object,'ref',$linkback,1,'ref','ref','');
  89. print '</td></tr>';
  90. // Ref client
  91. print '<tr><td>';
  92. print '<table class="nobordernopadding" width="100%"><tr><td class="nowrap">';
  93. print $langs->trans('RefCustomer').'</td><td align="left">';
  94. print '</td>';
  95. print '</tr></table>';
  96. print '</td><td colspan="3">';
  97. print $object->ref_client;
  98. print '</td>';
  99. print '</tr>';
  100. // Customer
  101. print "<tr><td>".$langs->trans("Company")."</td>";
  102. print '<td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>';
  103. print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
  104. print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
  105. print '</table>';
  106. print '</div>';
  107. $modulepart = 'propal';
  108. $permission = $user->rights->propal->creer;
  109. $param = '&id=' . $object->id;
  110. include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
  111. }
  112. else
  113. {
  114. print $langs->trans("ErrorUnknown");
  115. }
  116. llxFooter();
  117. $db->close();