dolibarr  16.0.5
note.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19  */
20 
27 require '../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/sendings.lib.php';
30 if (!empty($conf->project->enabled)) {
31  require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
32  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
33 }
34 
35 // Load translation files required by the page
36 $langs->loadLangs(array('sendings', 'companies', 'bills', 'deliveries', 'orders', 'stocks', 'other', 'propal'));
37 
38 $id = (GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility
39 $ref = GETPOST('ref', 'alpha');
40 $action = GETPOST('action', 'aZ09');
41 
42 $object = new Expedition($db);
43 if ($id > 0 || !empty($ref)) {
44  $object->fetch($id, $ref);
45  $object->fetch_thirdparty();
46 
47  if (!empty($object->origin)) {
48  $typeobject = $object->origin;
49  $origin = $object->origin;
50  $object->fetch_origin();
51  }
52 
53  // Linked documents
54  if ($typeobject == 'commande' && $object->$typeobject->id && !empty($conf->commande->enabled)) {
55  $objectsrc = new Commande($db);
56  $objectsrc->fetch($object->$typeobject->id);
57  }
58  if ($typeobject == 'propal' && $object->$typeobject->id && !empty($conf->propal->enabled)) {
59  $objectsrc = new Propal($db);
60  $objectsrc->fetch($object->$typeobject->id);
61  }
62 
63  $upload_dir = $conf->expedition->dir_output."/sending/".dol_sanitizeFileName($object->ref);
64 }
65 
66 $permissionnote = $user->rights->expedition->creer; // Used by the include of actions_setnotes.inc.php
67 
68 // Security check
69 if ($user->socid) {
70  $socid = $user->socid;
71 }
72 
73 $hookmanager->initHooks(array('expeditionnote'));
74 $result = restrictedArea($user, 'expedition', $object->id, '');
75 
76 
77 /*
78  * Actions
79  */
80 
81 $reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks
82 if ($reshook < 0) {
83  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
84 }
85 if (empty($reshook)) {
86  include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
87 }
88 
89 
90 /*
91  * View
92  */
93 
94 llxHeader();
95 
96 $form = new Form($db);
97 
98 if ($id > 0 || !empty($ref)) {
99  $head = shipping_prepare_head($object);
100  print dol_get_fiche_head($head, 'note', $langs->trans("Shipment"), -1, $object->picto);
101 
102 
103  // Shipment card
104  $linkback = '<a href="'.DOL_URL_ROOT.'/expedition/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
105 
106  $morehtmlref = '<div class="refidno">';
107  // Ref customer shipment
108  $morehtmlref .= $form->editfieldkey("RefCustomer", '', $object->ref_customer, $object, $user->rights->expedition->creer, 'string', '', 0, 1);
109  $morehtmlref .= $form->editfieldval("RefCustomer", '', $object->ref_customer, $object, $user->rights->expedition->creer, 'string', '', null, null, '', 1);
110  // Thirdparty
111  $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
112  // Project
113  if (!empty($conf->project->enabled)) {
114  $langs->load("projects");
115  $morehtmlref .= '<br>'.$langs->trans('Project').' ';
116  if (0) { // Do not change on shipment
117  if ($action != 'classify') {
118  $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
119  }
120  if ($action == 'classify') {
121  // $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
122  $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
123  $morehtmlref .= '<input type="hidden" name="action" value="classin">';
124  $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
125  $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
126  $morehtmlref .= '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
127  $morehtmlref .= '</form>';
128  } else {
129  $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
130  }
131  } else {
132  // We don't have project on shipment, so we will use the project or source object instead
133  // TODO Add project on shipment
134  $morehtmlref .= ' : ';
135  if (!empty($objectsrc->fk_project)) {
136  $proj = new Project($db);
137  $proj->fetch($objectsrc->fk_project);
138  $morehtmlref .= ' : '.$proj->getNomUrl(1);
139  if ($proj->title) {
140  $morehtmlref .= ' - '.$proj->title;
141  }
142  } else {
143  $morehtmlref .= '';
144  }
145  }
146  }
147  $morehtmlref .= '</div>';
148 
149 
150  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
151 
152 
153  print '<div class="underbanner clearboth"></div>';
154 
155  $cssclass = 'titlefield';
156  include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
157 
158  print dol_get_fiche_end();
159 }
160 
161 // End of page
162 llxFooter();
163 $db->close();
dol_sanitizeFileName
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Definition: functions.lib.php:1226
restrictedArea
restrictedArea($user, $features, $objectid=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.
Definition: security.lib.php:234
Expedition
Class to manage shipments.
Definition: expedition.class.php:52
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
Project
Class to manage projects.
Definition: project.class.php:35
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
img_edit
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
Definition: functions.lib.php:4389
dol_banner_tab
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.
Definition: functions.lib.php:2046
shipping_prepare_head
shipping_prepare_head($object)
Prepare array with list of tabs.
Definition: sendings.lib.php:35
Commande
Class to manage customers orders.
Definition: commande.class.php:46
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:10878
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
Propal
Class to manage proposals.
Definition: propal.class.php:52
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59