dolibarr  13.0.2
document.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2002-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
6  * Copyright (C) 2013-2016 Jean-François Ferry <hello@librethic.io>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
28 require '../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/ticket.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
33 require_once DOL_DOCUMENT_ROOT."/core/lib/company.lib.php";
34 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
35 
36 // Load translation files required by the page
37 $langs->loadLangs(array("companies", "other", "ticket", "mails"));
38 
39 $id = GETPOST('id', 'int');
40 $ref = GETPOST('ref', 'alpha');
41 $track_id = GETPOST('track_id', 'alpha');
42 $action = GETPOST('action', 'alpha');
43 $confirm = GETPOST('confirm', 'alpha');
44 
45 // Security check
46 if (!$user->rights->ticket->read) {
48 }
49 
50 // Get parameters
51 $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
52 $sortfield = GETPOST("sortfield", 'alpha');
53 $sortorder = GETPOST("sortorder", 'alpha');
54 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
55 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
56 $offset = $limit * $page;
57 $pageprev = $page - 1;
58 $pagenext = $page + 1;
59 if (!$sortorder) $sortorder = "ASC";
60 if (!$sortfield) $sortfield = "position_name";
61 
62 $object = new Ticket($db);
63 $result = $object->fetch($id, $ref, $track_id);
64 
65 if ($result < 0) {
66  setEventMessages($object->error, $object->errors, 'errors');
67 } else {
68  $upload_dir = $conf->ticket->dir_output."/".dol_sanitizeFileName($object->ref);
69 }
70 
71 
72 /*
73  * Actions
74  */
75 
76 include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
77 
78 
79 
80 /*
81  * View
82  */
83 
84 $form = new Form($db);
85 
86 $help_url = '';
87 llxHeader('', $langs->trans("TicketDocumentsLinked").' - '.$langs->trans("Files"), $help_url);
88 
89 if ($object->id)
90 {
91  /*
92  * Show tabs
93  */
94  if ($socid > 0) {
95  $object->fetch_thirdparty();
96  $head = societe_prepare_head($object->thirdparty);
97  print dol_get_fiche_head($head, 'ticket', $langs->trans("ThirdParty"), 0, 'company');
98  dol_banner_tab($object->thirdparty, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom');
100  }
101 
102  if (!$user->socid && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) {
103  $object->next_prev_filter = "te.fk_user_assign = '".$user->id."'";
104  } elseif ($user->socid > 0) {
105  $object->next_prev_filter = "te.fk_soc = '".$user->socid."'";
106  }
107 
108  $head = ticket_prepare_head($object);
109 
110  print dol_get_fiche_head($head, 'tabTicketDocument', $langs->trans("Ticket"), 0, 'ticket');
111 
112  $morehtmlref = '<div class="refidno">';
113  $morehtmlref .= $object->subject;
114  // Author
115  if ($object->fk_user_create > 0) {
116  $morehtmlref .= '<br>'.$langs->trans("CreatedBy").' : ';
117 
118  $langs->load("users");
119  $fuser = new User($db);
120  $fuser->fetch($object->fk_user_create);
121  $morehtmlref .= $fuser->getNomUrl(0);
122  }
123  if (!empty($object->origin_email)) {
124  $morehtmlref .= '<br>'.$langs->trans("CreatedBy").' : ';
125  $morehtmlref .= $object->origin_email.' <small>('.$langs->trans("TicketEmailOriginIssuer").')</small>';
126  }
127 
128  // Thirdparty
129  if (!empty($conf->societe->enabled))
130  {
131  $morehtmlref .= '<br>'.$langs->trans('ThirdParty');
132  /*if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->socid && $user->rights->ticket->write) {
133  $morehtmlref.='<a class="editfielda" href="' . $url_page_current . '?action=editcustomer&amp;track_id=' . $object->track_id . '">' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . '</a>';
134  }*/
135  $morehtmlref .= ' : ';
136  if ($action == 'editcustomer') {
137  $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, 'editcustomer', '', 1, 0, 0, array(), 1);
138  } else {
139  $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, 'none', '', 1, 0, 0, array(), 1);
140  }
141  }
142 
143  // Project
144  if (!empty($conf->projet->enabled))
145  {
146  $langs->load("projects");
147  $morehtmlref .= '<br>'.$langs->trans('Project').' ';
148  if ($user->rights->ticket->write)
149  {
150  if ($action != 'classify') {
151  //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>';
152  $morehtmlref .= ' : ';
153  }
154  if ($action == 'classify') {
155  //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
156  $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
157  $morehtmlref .= '<input type="hidden" name="action" value="classin">';
158  $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
159  $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1);
160  $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
161  $morehtmlref .= '</form>';
162  } else {
163  $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
164  }
165  } else {
166  if (!empty($object->fk_project)) {
167  $proj = new Project($db);
168  $proj->fetch($object->fk_project);
169  $morehtmlref .= $proj->getNomUrl(1);
170  } else {
171  $morehtmlref .= '';
172  }
173  }
174  }
175 
176  $morehtmlref .= '</div>';
177 
178  $linkback = '<a href="'.dol_buildpath('/ticket/list.php', 1).'"><strong>'.$langs->trans("BackToList").'</strong></a> ';
179 
180  dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
181 
183 
184  // Build file list
185  $filearray = dol_dir_list($upload_dir, "files", 0, '', '\.meta$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1);
186  $totalsize = 0;
187  foreach ($filearray as $key => $file) {
188  $totalsize += $file['size'];
189  }
190 
191  //$object->ref = $object->track_id; // For compatibility we use track ID for directory
192  $modulepart = 'ticket';
193  $permission = $user->rights->ticket->write;
194  $permtoedit = $user->rights->ticket->write;
195  $param = '&id='.$object->id;
196 
197  include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
198 } else {
199  accessforbidden('', 0, 1);
200 }
201 
202 // End of page
203 llxFooter();
204 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
ticket_prepare_head($object)
Build tabs for a Ticket object.
Definition: ticket.lib.php:76
Class to manage Dolibarr users.
Definition: user.class.php:44
Class to manage ticket.
llxHeader()
Empty header.
Definition: wrapper.php:45
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
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.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
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
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
Definition: company.lib.php:42
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