dolibarr  7.0.0-beta
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 
31 $langs->loadLangs(array("compta", "banks", "bills", "users", "accountancy"));
32 
33 $id = GETPOST('id','int');
34 $ref = GETPOST('ref', 'alpha');
35 $action = GETPOST('action','alpha');
36 $confirm = GETPOST('confirm','alpha');
37 
38 // Security check
39 $socid = GETPOST("socid","int");
40 if ($user->societe_id) $socid=$user->societe_id;
41 $result = restrictedArea($user, 'banque', '', '', '');
42 
43 // Get parameters
44 $sortfield = GETPOST('sortfield','alpha');
45 $sortorder = GETPOST('sortorder','alpha');
46 $page = GETPOST('page','int');
47 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
48 $offset = $conf->liste_limit * $page;
49 $pageprev = $page - 1;
50 $pagenext = $page + 1;
51 if (! $sortorder) $sortorder="ASC";
52 if (! $sortfield) $sortfield="name";
53 
54 
55 $object = new PaymentVarious($db);
56 $object->fetch($id, $ref);
57 
58 $upload_dir = $conf->banque->dir_output.'/'.dol_sanitizeFileName($object->id);
59 $modulepart='banque';
60 
61 
62 /*
63  * Actions
64  */
65 
66 include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
67 
68 
69 /*
70  * View
71  */
72 
73 $form = new Form($db);
74 
75 $title = $langs->trans("VariousPayment") . ' - ' . $langs->trans("Documents");
76 $help_url = '';
77 llxHeader("",$title,$help_url);
78 
79 if ($object->id)
80 {
81  $head=various_payment_prepare_head($object);
82 
83  dol_fiche_head($head, 'documents', $langs->trans("VariousPayment"), 0, 'payment');
84 
85  $morehtmlref='<div class="refidno">';
86  // Project
87  if (! empty($conf->projet->enabled))
88  {
89  $langs->load("projects");
90  $morehtmlref.=$langs->trans('Project') . ' ';
91  if ($user->rights->tax->charges->creer)
92  {
93  if ($action != 'classify')
94  $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
95  if ($action == 'classify') {
96  //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
97  $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
98  $morehtmlref.='<input type="hidden" name="action" value="classin">';
99  $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
100  $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
101  $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
102  $morehtmlref.='</form>';
103  } else {
104  $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
105  }
106  } else {
107  if (! empty($object->fk_project)) {
108  $proj = new Project($db);
109  $proj->fetch($object->fk_project);
110  $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
111  $morehtmlref.=$proj->ref;
112  $morehtmlref.='</a>';
113  } else {
114  $morehtmlref.='';
115  }
116  }
117  }
118  $morehtmlref.='</div>';
119  $linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/various_payment/index.php'.(! 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  // Construit liste des fichiers
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 llxFooter();
157 
158 $db->close();
Class to manage various payments.
llxHeader()
Header empty.
Definition: document.php:70
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='')
Show tab header of a card.
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
if(empty($reshook)) $form
View.
Definition: perms.php:103
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="")
Scan a directory and return a list of files/directories.
Definition: files.lib.php:58
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage generation of HTML components Only common components must be here.
Class to manage projects.
if($_POST["cancel"]==$langs->trans("Cancel")&&!$id) if($action== 'setdatev'&&$user->rights->tax->charges->creer) if($action== 'add'&&$_POST["cancel"]<> $langs->trans("Cancel")) if($action== 'delete') $title
Actions.
Definition: card.php:183
dol_fiche_end($notab=0)
Show tab footer of a card.
print
Draft customers invoices.
Definition: index.php:91
llxFooter()
Footer empty.
Definition: document.php:76
img_edit($titlealt= 'default', $float=0, $other= 'class="pictoedit"')
Show logo editer/modifier fiche.
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $objcanvas=null)
Check permissions of a user to show a page and an object.