dolibarr 21.0.0-beta
document.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2016 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 Alexandre Spangaro <aspangaro@open-dsi.fr>
10 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <https://www.gnu.org/licenses/>.
24 * or see https://www.gnu.org/
25 */
26
33// Load Dolibarr environment
34require '../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
36require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
37require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php';
38require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
39if (isModEnabled('project')) {
40 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
41 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
42}
43
52// Load translation files required by the page
53$langs->loadLangs(array('companies', 'other', 'donations'));
54
55$id = GETPOSTINT('id');
56$ref = GETPOST('ref', 'alpha');
57$action = GETPOST('action', 'aZ09');
58$confirm = GETPOST('confirm', 'alpha');
59$projectid = (GETPOST('projectid') ? GETPOSTINT('projectid') : 0);
60
61// Get parameters
62$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
63$sortfield = GETPOST('sortfield', 'aZ09comma');
64$sortorder = GETPOST('sortorder', 'aZ09comma');
65$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
66if (empty($page) || $page == -1) {
67 $page = 0;
68} // If $page is not defined, or '' or -1
69$offset = $limit * $page;
70$pageprev = $page - 1;
71$pagenext = $page + 1;
72if (!$sortorder) {
73 $sortorder = "ASC";
74}
75if (!$sortfield) {
76 $sortfield = "name";
77}
78
79$object = new Don($db);
80if ($id > 0 || !empty($ref)) {
81 $object->fetch($id, $ref);
82}
83
84if ($id > 0 || !empty($ref)) {
85 $upload_dir = $conf->don->multidir_output[$object->entity ? $object->entity : $conf->entity]."/".get_exdir(0, 0, 0, 1, $object);
86}
87
88$modulepart = 'don';
89
90// Security check
91if ($user->socid) {
92 $socid = $user->socid;
93}
94$result = restrictedArea($user, 'don', $object->id);
95
96$permissiontoadd = $user->hasRight('don', 'creer'); // Used by the include of actions_dellink.inc.php
97
98
99/*
100 * Actions
101 */
102
103include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
104
105if ($action == 'classin' && $user->hasRight('don', 'creer')) {
106 $object->fetch($id);
107 $object->setProject($projectid);
108}
109
110/*
111 * View
112 */
113
114$form = new Form($db);
115if (isModEnabled('project')) {
116 $formproject = new FormProjets($db);
117}
118
119$title = $langs->trans('Donation')." - ".$langs->trans('Documents');
120
121$help_url = 'EN:Module_Donations|FR:Module_Dons|ES:M&oacute;dulo_Donaciones|DE:Modul_Spenden';
122
123llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-donation page-card_documents');
124
125
126if ($object->id) {
127 $object->fetch_thirdparty();
128
129 $head = donation_prepare_head($object);
130
131 print dol_get_fiche_head($head, 'documents', $langs->trans("Donation"), -1, 'donation');
132
133
134 // Build file list
135 $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1);
136 $totalsize = 0;
137 foreach ($filearray as $key => $file) {
138 $totalsize += $file['size'];
139 }
140
141 $linkback = '<a href="'.DOL_URL_ROOT.'/don/list.php'.(!empty($socid) ? '?socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
142
143 $morehtmlref = '<div class="refidno">';
144 // Project
145 if (isModEnabled('project')) {
146 $langs->load("projects");
147 $morehtmlref .= $langs->trans('Project').' ';
148 if ($user->hasRight('don', 'creer')) {
149 if ($action != 'classify') {
150 // $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token='.newToken().'&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
151 }
152 if ($action == 'classify') {
153 //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
154 $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
155 $morehtmlref .= '<input type="hidden" name="action" value="classin">';
156 $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
157 $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
158 $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
159 $morehtmlref .= '</form>';
160 } else {
161 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300');
162 }
163 } else {
164 if (!empty($object->fk_project)) {
165 $proj = new Project($db);
166 $proj->fetch($object->fk_project);
167 $morehtmlref .= ' : '.$proj->getNomUrl(1);
168 if ($proj->title) {
169 $morehtmlref .= ' - '.$proj->title;
170 }
171 } else {
172 $morehtmlref .= '';
173 }
174 }
175 }
176 $morehtmlref .= '</div>';
177
178
179 dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref);
180
181 print '<div class="fichecenter">';
182 print '<div class="underbanner clearboth"></div>';
183
184 print '<table class="border tableforfield centpercent">';
185
186 // Ref
187 /*
188 print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>';
189 print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'ref', '');
190 print '</td></tr>';
191 */
192
193 // Societe
194 //print "<tr><td>".$langs->trans("Company")."</td><td>".$object->client->getNomUrl(1)."</td></tr>";
195
196 print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
197 print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize, 1, 1).'</td></tr>';
198 print '</table>';
199
200 print '</div>';
201
202 print '<div class="clearboth"></div>';
203
204 print dol_get_fiche_end();
205
206 $modulepart = 'don';
207 $permissiontoadd = $user->hasRight('don', 'creer');
208 $permtoedit = $user->hasRight('don', 'creer');
209 $param = '&id='.$object->id;
210 include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
211} else {
212 print $langs->trans("ErrorUnknown");
213}
214
215llxFooter();
216
217$db->close();
$id
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:71
Class to manage donations.
Definition don.class.php:41
Class to manage generation of HTML components Only common components must be here.
Class to manage building of HTML components.
Class to manage projects.
llxFooter()
Footer empty.
Definition document.php:107
donation_prepare_head($object)
Prepare array with list of tabs.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:63
dol_print_size($size, $shortvalue=0, $shortunit=0)
Return string with formatted size.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.