dolibarr/htdocs/compta/bank/various_payment/document.php

166 lines
5.7 KiB
PHP
Raw Normal View History

2017-03-19 08:17:32 +01:00
<?php
2019-01-28 21:39:22 +01:00
/* Copyright (C) 2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
2017-03-19 08:17:32 +01:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* or see https://www.gnu.org/
2017-03-19 08:17:32 +01:00
*/
/**
2017-12-10 14:05:36 +01:00
* \file htdocs/compta/bank/various_payment/document.php
* \ingroup bank
* \brief Page of linked files onto various payment
2017-03-19 08:17:32 +01:00
*/
require '../../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
2018-10-04 19:19:29 +02:00
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
2017-03-19 08:17:32 +01:00
2018-05-27 09:40:17 +02:00
// Load translation files required by the page
2017-12-10 14:05:36 +01:00
$langs->loadLangs(array("compta", "banks", "bills", "users", "accountancy"));
2017-03-19 08:17:32 +01:00
$id = GETPOST('id', 'int');
2017-03-19 08:17:32 +01:00
$ref = GETPOST('ref', 'alpha');
2020-09-16 19:39:50 +02:00
$action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm', 'alpha');
2017-03-19 08:17:32 +01:00
// Security check
$socid = GETPOST("socid", "int");
2021-02-23 21:09:01 +01:00
if ($user->socid) {
$socid = $user->socid;
}
2017-12-10 14:05:36 +01:00
$result = restrictedArea($user, 'banque', '', '', '');
2017-03-19 08:17:32 +01:00
// Get parameters
2020-04-20 15:06:27 +02:00
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
2020-09-18 17:13:01 +02:00
$sortfield = GETPOST('sortfield', 'aZ09comma');
2020-09-17 14:31:25 +02:00
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
2021-02-23 21:09:01 +01:00
if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
2020-04-20 15:06:27 +02:00
$offset = $limit * $page;
2017-03-19 08:17:32 +01:00
$pageprev = $page - 1;
$pagenext = $page + 1;
2021-02-23 21:09:01 +01:00
if (!$sortorder) {
$sortorder = "ASC";
}
if (!$sortfield) {
$sortfield = "name";
}
2017-03-19 08:17:32 +01:00
$object = new PaymentVarious($db);
$object->fetch($id, $ref);
$upload_dir = $conf->bank->dir_output.'/'.dol_sanitizeFileName($object->id);
$modulepart = 'banque';
2017-03-19 08:17:32 +01:00
2021-10-25 15:32:10 +02:00
$permissiontoadd = $user->rights->banque->modifier; // Used by the include of actions_dellink.inc.php
2017-03-19 08:17:32 +01:00
/*
* Actions
*/
include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
2017-03-19 08:17:32 +01:00
/*
* View
*/
$form = new Form($db);
$title = $langs->trans("VariousPayment").' - '.$langs->trans("Documents");
2017-12-10 14:05:36 +01:00
$help_url = '';
llxHeader("", $title, $help_url);
2017-03-19 08:17:32 +01:00
2021-02-23 21:09:01 +01:00
if ($object->id) {
$head = various_payment_prepare_head($object);
2017-03-19 08:17:32 +01:00
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head($head, 'documents', $langs->trans("VariousPayment"), -1, $object->picto);
2017-03-19 08:17:32 +01:00
$morehtmlref = '<div class="refidno">';
2017-12-10 14:05:36 +01:00
// Project
2021-02-23 21:09:01 +01:00
if (!empty($conf->projet->enabled)) {
2017-12-10 14:05:36 +01:00
$langs->load("projects");
$morehtmlref .= $langs->trans('Project').' : ';
2021-02-23 21:09:01 +01:00
if ($user->rights->banque->modifier && 0) {
2019-10-26 14:42:25 +02:00
if ($action != 'classify') {
2021-09-18 22:09:55 +02:00
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
2019-10-26 14:42:25 +02:00
}
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref .= '<input type="hidden" name="action" value="classin">';
$morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
$morehtmlref .= $formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref .= '</form>';
2019-10-26 14:42:25 +02:00
} else {
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
2019-10-26 14:42:25 +02:00
}
2017-12-10 14:05:36 +01:00
} else {
if (!empty($object->fk_project)) {
2017-12-10 14:05:36 +01:00
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref .= $proj->getNomUrl(1);
2017-12-10 14:05:36 +01:00
} else {
$morehtmlref .= '';
2017-12-10 14:05:36 +01:00
}
}
}
$morehtmlref .= '</div>';
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/various_payment/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
2017-12-10 14:05:36 +01:00
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
2017-03-19 08:17:32 +01:00
2018-08-04 14:17:51 +02:00
// Build file list
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
$totalsize = 0;
2021-02-23 21:09:01 +01:00
foreach ($filearray as $key => $file) {
$totalsize += $file['size'];
2017-03-19 08:17:32 +01:00
}
2019-03-29 13:26:26 +01:00
print '<table class="border tableforfield centpercent">';
2017-03-19 08:17:32 +01:00
2019-12-25 23:15:56 +01:00
print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
2017-12-10 14:05:36 +01:00
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
print '</table>';
2017-03-19 08:17:32 +01:00
2017-12-10 14:05:36 +01:00
print '</div>';
2017-03-19 08:17:32 +01:00
2017-12-10 14:05:36 +01:00
print '<div class="clearboth"></div>';
2017-03-19 08:17:32 +01:00
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end();
2017-03-19 08:17:32 +01:00
2017-12-10 14:05:36 +01:00
$modulepart = 'banque';
2021-06-08 16:19:21 +02:00
$permissiontoadd = $user->rights->banque->modifier;
$param = '&id='.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
2020-05-21 15:05:19 +02:00
} else {
2017-03-19 08:17:32 +01:00
print $langs->trans("ErrorUnknown");
}
2018-07-29 19:16:28 +02:00
// End of page
2017-03-19 08:17:32 +01:00
llxFooter();
$db->close();