dolibarr  13.0.2
document.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <https://www.gnu.org/licenses/>.
16  * or see https://www.gnu.org/
17  */
18 
25 require '../../../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
27 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
29 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
31 
32 // Load translation files required by the page
33 $langs->loadLangs(array("compta", "banks", "bills", "users", "accountancy"));
34 
35 $id = GETPOST('id', 'int');
36 $ref = GETPOST('ref', 'alpha');
37 $action = GETPOST('action', 'aZ09');
38 $confirm = GETPOST('confirm', 'alpha');
39 
40 // Security check
41 $socid = GETPOST("socid", "int");
42 if ($user->socid) $socid = $user->socid;
43 $result = restrictedArea($user, 'banque', '', '', '');
44 
45 // Get parameters
46 $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
47 $sortfield = GETPOST('sortfield', 'aZ09comma');
48 $sortorder = GETPOST('sortorder', 'aZ09comma');
49 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
50 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
51 $offset = $limit * $page;
52 $pageprev = $page - 1;
53 $pagenext = $page + 1;
54 if (!$sortorder) $sortorder = "ASC";
55 if (!$sortfield) $sortfield = "name";
56 
57 
58 $object = new PaymentVarious($db);
59 $object->fetch($id, $ref);
60 
61 $upload_dir = $conf->bank->dir_output.'/'.dol_sanitizeFileName($object->id);
62 $modulepart = 'banque';
63 
64 
65 /*
66  * Actions
67  */
68 
69 include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
70 
71 
72 /*
73  * View
74  */
75 
76 $form = new Form($db);
77 
78 $title = $langs->trans("VariousPayment").' - '.$langs->trans("Documents");
79 $help_url = '';
80 llxHeader("", $title, $help_url);
81 
82 if ($object->id)
83 {
84  $head = various_payment_prepare_head($object);
85 
86  print dol_get_fiche_head($head, 'documents', $langs->trans("VariousPayment"), -1, $object->picto);
87 
88  $morehtmlref = '<div class="refidno">';
89  // Project
90  if (!empty($conf->projet->enabled))
91  {
92  $langs->load("projects");
93  $morehtmlref .= $langs->trans('Project').' : ';
94  if ($user->rights->banque->modifier && 0)
95  {
96  if ($action != 'classify') {
97  $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
98  }
99  if ($action == 'classify') {
100  //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
101  $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
102  $morehtmlref .= '<input type="hidden" name="action" value="classin">';
103  $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
104  $morehtmlref .= $formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
105  $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
106  $morehtmlref .= '</form>';
107  } else {
108  $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
109  }
110  } else {
111  if (!empty($object->fk_project)) {
112  $proj = new Project($db);
113  $proj->fetch($object->fk_project);
114  $morehtmlref .= $proj->getNomUrl(1);
115  } else {
116  $morehtmlref .= '';
117  }
118  }
119  }
120  $morehtmlref .= '</div>';
121  $linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/various_payment/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
122 
123  dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright);
124 
125  print '<div class="fichecenter">';
126  print '<div class="underbanner clearboth"></div>';
127 
128  // Build file list
129  $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
130  $totalsize = 0;
131  foreach ($filearray as $key => $file)
132  {
133  $totalsize += $file['size'];
134  }
135 
136  print '<table class="border tableforfield centpercent">';
137 
138  print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
139  print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
140  print '</table>';
141 
142  print '</div>';
143 
144  print '<div class="clearboth"></div>';
145 
147 
148  $modulepart = 'banque';
149  $permission = $user->rights->banque->modifier;
150  $param = '&id='.$object->id;
151  include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
152 } else {
153  print $langs->trans("ErrorUnknown");
154 }
155 
156 // End of page
157 llxFooter();
158 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
Class to manage various payments.
various_payment_prepare_head($object)
Prepare array with list of tabs.
Definition: bank.lib.php:206
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage projects.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
Definition: files.lib.php:60
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
Definition: index.php:89
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
llxFooter()
Empty footer.
Definition: wrapper.php:59