dolibarr 21.0.0-beta
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 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
30// Load Dolibarr environment
31require '../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
34
43// Load translation files required by the page
44$langs->load("companies");
45
46$id = GETPOSTINT('id');
47$ref = GETPOST('ref', 'alpha');
48$action = GETPOST('action', 'aZ09');
49
50// Security check
51$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : ''));
52$fieldtype = (!empty($ref) ? 'ref' : 'rowid');
53if ($user->socid) {
54 $socid = $user->socid;
55}
56
57$object = new Product($db);
58if ($id > 0 || !empty($ref)) {
59 $object->fetch($id, $ref);
60}
61
62$permissionnote = ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer')); // Used by the include of actions_setnotes.inc.php
63
64$hookmanager->initHooks(array('productnote'));
65
66if ($object->id > 0) {
67 if ($object->type == $object::TYPE_PRODUCT) {
68 restrictedArea($user, 'product', $object->id, 'product&product', '', '');
69 }
70 if ($object->type == $object::TYPE_SERVICE) {
71 restrictedArea($user, 'service', $object->id, 'product&product', '', '');
72 }
73} else {
74 restrictedArea($user, 'product|service', $fieldvalue, 'product&product', '', '', $fieldtype);
75}
76
77/*
78 * Actions
79 */
80
81$parameters = array();
82$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
83if ($reshook < 0) {
84 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
85}
86if (empty($reshook)) {
87 include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be 'include', not 'include_once'
88}
89
90
91/*
92 * View
93 */
94
95$form = new Form($db);
96
97$help_url = '';
98if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) {
99 $help_url = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos|DE:Modul_Produkte';
100}
101if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) {
102 $help_url = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios|DE:Modul_Leistungen';
103}
104
105$title = $langs->trans('ProductServiceCard');
106$shortlabel = dol_trunc($object->label, 16);
107if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) {
108 $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Notes');
109 $help_url = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos|DE:Modul_Produkte';
110}
111if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) {
112 $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Notes');
113 $help_url = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios|DE:Modul_Leistungen';
114}
115
116llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-product page-card_note');
117
118if ($id > 0 || !empty($ref)) {
119 /*
120 * Show tabs
121 */
122 if (isModEnabled('notification')) {
123 $langs->load("mails");
124 }
125
126 $head = product_prepare_head($object);
127 $titre = $langs->trans("CardProduct".$object->type);
128 $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product');
129
130 print dol_get_fiche_head($head, 'note', $titre, -1, $picto);
131
132 $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1&type='.$object->type.'">'.$langs->trans("BackToList").'</a>';
133 $object->next_prev_filter = "fk_product_type:=:".((int) $object->type); // usf filter
134
135 $shownav = 1;
136 if ($user->socid && !in_array('product', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) {
137 $shownav = 0;
138 }
139
140 dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref');
141
142 $cssclass = 'titlefield';
143 //if ($action == 'editnote_public') $cssclass='titlefieldcreate';
144 //if ($action == 'editnote_private') $cssclass='titlefieldcreate';
145
146 //print '<div class="fichecenter">';
147
148 print '<div class="underbanner clearboth"></div>';
149
150 include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
151
152 print dol_get_fiche_end();
153}
154
155// End of page
156llxFooter();
157$db->close();
$id
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:71
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.
llxFooter()
Footer empty.
Definition document.php:107
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
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.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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.