dolibarr  9.0.0
document.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2017 Alexandre Spangaro <aspangaro@zendsi.com>
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 <http://www.gnu.org/licenses/>.
16  * or see http://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','alpha');
38 $confirm = GETPOST('confirm','alpha');
39 
40 // Security check
41 $socid = GETPOST("socid","int");
42 if ($user->societe_id) $socid=$user->societe_id;
43 $result = restrictedArea($user, 'banque', '', '', '');
44 
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 
56 
57 $object = new PaymentVarious($db);
58 $object->fetch($id, $ref);
59 
60 $upload_dir = $conf->banque->dir_output.'/'.dol_sanitizeFileName($object->id);
61 $modulepart='banque';
62 
63 
64 /*
65  * Actions
66  */
67 
68 include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
69 
70 
71 /*
72  * View
73  */
74 
75 $form = new Form($db);
76 
77 $title = $langs->trans("VariousPayment") . ' - ' . $langs->trans("Documents");
78 $help_url = '';
79 llxHeader("",$title,$help_url);
80 
81 if ($object->id)
82 {
83  $head=various_payment_prepare_head($object);
84 
85  dol_fiche_head($head, 'documents', $langs->trans("VariousPayment"), -1, 'payment');
86 
87  $morehtmlref='<div class="refidno">';
88  // Project
89  if (! empty($conf->projet->enabled))
90  {
91  $langs->load("projects");
92  $morehtmlref.=$langs->trans('Project') . ' : ';
93  if ($user->rights->banque->modifier && 0)
94  {
95  if ($action != 'classify')
96  $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
97  if ($action == 'classify') {
98  //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
99  $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
100  $morehtmlref.='<input type="hidden" name="action" value="classin">';
101  $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
102  $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
103  $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
104  $morehtmlref.='</form>';
105  } else {
106  $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
107  }
108  } else {
109  if (! empty($object->fk_project)) {
110  $proj = new Project($db);
111  $proj->fetch($object->fk_project);
112  $morehtmlref.=$proj->getNomUrl(1);
113  } else {
114  $morehtmlref.='';
115  }
116  }
117  }
118  $morehtmlref.='</div>';
119  $linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/various_payment/list.php?restore_lastsearch_values=1'.(! empty($socid)?'&socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
120 
121  dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright);
122 
123  print '<div class="fichecenter">';
124  print '<div class="underbanner clearboth"></div>';
125 
126  // Build file list
127  $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
128  $totalsize=0;
129  foreach($filearray as $key => $file)
130  {
131  $totalsize+=$file['size'];
132  }
133 
134  print '<table class="border" width="100%">';
135 
136  print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
137  print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
138  print '</table>';
139 
140  print '</div>';
141 
142  print '<div class="clearboth"></div>';
143 
144  dol_fiche_end();
145 
146  $modulepart = 'banque';
147  $permission = $user->rights->banque->modifier;
148  $param = '&id=' . $object->id;
149  include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
150 }
151 else
152 {
153  print $langs->trans("ErrorUnknown");
154 }
155 
156 // End of page
157 llxFooter();
158 $db->close();
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
Class to manage various payments.
img_edit($titlealt='default', $float=0, $other='class="pictoedit"')
Show logo editer/modifier fiche.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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.
various_payment_prepare_head($object)
Prepare array with list of tabs.
Definition: bank.lib.php:164
Class to manage generation of HTML components Only common components must be here.
Class to manage projects.
dol_fiche_end($notab=0)
Show tab footer of a card.
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:59
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.
llxFooter()
Footer empty.
Definition: document.php:68
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='')
Show tab header of a card.
if(isset($_GET["hashp"]) &&! defined("NOLOGIN")) if((isset($_GET["modulepart"]) && $_GET["modulepart"]=='medias')) llxHeader()
Header empty.
Definition: document.php:60