dolibarr 18.0.6
note.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2011 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 Florian Henry <florian.henry@open-concept.pro>
7 * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29// Load Dolibarr environment
30require '../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
33
34// Load translation files required by the page
35$langs->load("companies");
36
37$id = GETPOST('id', 'int');
38$ref = GETPOST('ref', 'alpha');
39$action = GETPOST('action', 'aZ09');
40
41// Security check
42$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : ''));
43$fieldtype = (!empty($ref) ? 'ref' : 'rowid');
44if ($user->socid) {
45 $socid = $user->socid;
46}
47
48$object = new Product($db);
49if ($id > 0 || !empty($ref)) {
50 $object->fetch($id, $ref);
51}
52
53$permissionnote = ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer')); // Used by the include of actions_setnotes.inc.php
54
55if ($object->id > 0) {
56 if ($object->type == $object::TYPE_PRODUCT) {
57 restrictedArea($user, 'product', $object->id, 'product&product', '', '');
58 }
59 if ($object->type == $object::TYPE_SERVICE) {
60 restrictedArea($user, 'service', $object->id, 'product&product', '', '');
61 }
62} else {
63 restrictedArea($user, 'product|service', $fieldvalue, 'product&product', '', '', $fieldtype);
64}
65
66
67$hookmanager->initHooks(array('productnote'));
68
69
70/*
71 * Actions
72 */
73
74$parameters = array();
75$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
76if ($reshook < 0) {
77 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
78}
79if (empty($reshook)) {
80 include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
81}
82
83
84/*
85 * View
86 */
87
88$form = new Form($db);
89
90$help_url = '';
91if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) {
92 $help_url = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos|DE:Modul_Produkte';
93}
94if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) {
95 $help_url = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios|DE:Modul_Leistungen';
96}
97
98$title = $langs->trans('ProductServiceCard');
99$shortlabel = dol_trunc($object->label, 16);
100if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) {
101 $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Notes');
102 $help_url = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos|DE:Modul_Produkte';
103}
104if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) {
105 $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Notes');
106 $help_url = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios|DE:Modul_Leistungen';
107}
108
109llxHeader('', $title, $help_url);
110
111if ($id > 0 || !empty($ref)) {
112 /*
113 * Affichage onglets
114 */
115 if (isModEnabled('notification')) {
116 $langs->load("mails");
117 }
118
119 $head = product_prepare_head($object);
120 $titre = $langs->trans("CardProduct".$object->type);
121 $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product');
122
123 print dol_get_fiche_head($head, 'note', $titre, -1, $picto);
124
125 $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1&type='.$object->type.'">'.$langs->trans("BackToList").'</a>';
126 $object->next_prev_filter = "fk_product_type = ".((int) $object->type);
127
128 $shownav = 1;
129 if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
130 $shownav = 0;
131 }
132
133 dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref');
134
135 $cssclass = 'titlefield';
136 //if ($action == 'editnote_public') $cssclass='titlefieldcreate';
137 //if ($action == 'editnote_private') $cssclass='titlefieldcreate';
138
139 //print '<div class="fichecenter">';
140
141 print '<div class="underbanner clearboth"></div>';
142
143 include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
144
145 print dol_get_fiche_end();
146}
147
148// End of page
149llxFooter();
150$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:56
llxFooter()
Empty footer.
Definition wrapper.php:70
Class to manage generation of HTML components Only common components must be here.
Class to manage products or services.
const TYPE_PRODUCT
Regular product.
const TYPE_SERVICE
Service.
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.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
product_prepare_head($object)
Prepare array with list of tabs.
restrictedArea(User $user, $features, $object=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.