document.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. /* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2015 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@inodbox.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. * Copyright (C) 2015-2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 3 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. * or see http://www.gnu.org/
  24. */
  25. /**
  26. * \file htdocs/compta/salaries/document.php
  27. * \ingroup salaries
  28. * \brief Page of linked files onto salaries
  29. */
  30. require '../../main.inc.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  32. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  33. require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php';
  34. require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php';
  35. // Load translation files required by the page
  36. $langs->loadLangs(array("compta","bills","users","salaries","hrm"));
  37. $id = GETPOST('id','int');
  38. $ref = GETPOST('ref', 'alpha');
  39. $action = GETPOST('action','alpha');
  40. $confirm = GETPOST('confirm','alpha');
  41. // Security check
  42. $socid = GETPOST("socid","int");
  43. if ($user->societe_id) $socid=$user->societe_id;
  44. $result = restrictedArea($user, 'salaries', '', '', '');
  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 PaymentSalary($db);
  56. $object->fetch($id, $ref);
  57. $upload_dir = $conf->salaries->dir_output.'/'.dol_sanitizeFileName($object->id);
  58. $modulepart='salaries';
  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("SalaryPayment"));
  68. if ($object->id)
  69. {
  70. $object->fetch_thirdparty();
  71. $head=salaries_prepare_head($object);
  72. dol_fiche_head($head, 'documents', $langs->trans("SalaryPayment"), -1, 'payment');
  73. // Build file list
  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. $linkback = '<a href="'.DOL_URL_ROOT.'/compta/salaries/list.php?restore_lastsearch_values=1'.(! empty($socid)?'&socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
  81. $morehtmlref='<div class="refidno">';
  82. $userstatic=new User($db);
  83. $userstatic->fetch($object->fk_user);
  84. $morehtmlref.=$langs->trans('Employee') . ' : ' . $userstatic->getNomUrl(1);
  85. $morehtmlref.='</div>';
  86. dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', '');
  87. print '<div class="fichecenter">';
  88. print '<div class="underbanner clearboth"></div>';
  89. print '<table class="border" width="100%">';
  90. print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
  91. print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize,1,1).'</td></tr>';
  92. print '</table>';
  93. print '</div>';
  94. dol_fiche_end();
  95. $modulepart = 'salaries';
  96. $permission = $user->rights->salaries->write;
  97. $param = '&id=' . $object->id;
  98. include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
  99. }
  100. else
  101. {
  102. print $langs->trans("ErrorUnknown");
  103. }
  104. // End of page
  105. llxFooter();
  106. $db->close();