dolibarr  16.0.5
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 require '../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
32 
33 // Load translation files required by the page
34 $langs->load("companies");
35 
36 $id = GETPOST('id', 'int');
37 $ref = GETPOST('ref', 'alpha');
38 $action = GETPOST('action', 'aZ09');
39 
40 // Security check
41 $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : ''));
42 $fieldtype = (!empty($ref) ? 'ref' : 'rowid');
43 if ($user->socid) {
44  $socid = $user->socid;
45 }
46 
47 $object = new Product($db);
48 if ($id > 0 || !empty($ref)) {
49  $object->fetch($id, $ref);
50 }
51 
52 $permissionnote = ($user->rights->produit->creer || $user->rights->service->creer); // Used by the include of actions_setnotes.inc.php
53 
54 if ($object->id > 0) {
55  if ($object->type == $object::TYPE_PRODUCT) {
56  restrictedArea($user, 'produit', $object->id, 'product&product', '', '');
57  }
58  if ($object->type == $object::TYPE_SERVICE) {
59  restrictedArea($user, 'service', $object->id, 'product&product', '', '');
60  }
61 } else {
62  restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
63 }
64 
65 
66 $hookmanager->initHooks(array('productnote'));
67 
68 
69 /*
70  * Actions
71  */
72 $reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks
73 if ($reshook < 0) {
74  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
75 }
76 if (empty($reshook)) {
77  include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
78 }
79 
80 
81 /*
82  * View
83  */
84 
85 $form = new Form($db);
86 
87 $help_url = '';
88 if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) {
89  $help_url = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos';
90 }
91 if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) {
92  $help_url = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios';
93 }
94 
95 $title = $langs->trans('ProductServiceCard');
96 $shortlabel = dol_trunc($object->label, 16);
97 if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) {
98  $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Notes');
99  $help_url = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos';
100 }
101 if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) {
102  $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Notes');
103  $help_url = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios';
104 }
105 
106 llxHeader('', $title, $help_url);
107 
108 if ($id > 0 || !empty($ref)) {
109  /*
110  * Affichage onglets
111  */
112  if (!empty($conf->notification->enabled)) {
113  $langs->load("mails");
114  }
115 
116  $head = product_prepare_head($object);
117  $titre = $langs->trans("CardProduct".$object->type);
118  $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product');
119 
120  print dol_get_fiche_head($head, 'note', $titre, -1, $picto);
121 
122  $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
123  $object->next_prev_filter = " fk_product_type = ".$object->type;
124 
125  $shownav = 1;
126  if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
127  $shownav = 0;
128  }
129 
130  dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref');
131 
132  $cssclass = 'titlefield';
133  //if ($action == 'editnote_public') $cssclass='titlefieldcreate';
134  //if ($action == 'editnote_private') $cssclass='titlefieldcreate';
135 
136  //print '<div class="fichecenter">';
137 
138  print '<div class="underbanner clearboth"></div>';
139 
140  include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
141 
142  print dol_get_fiche_end();
143 }
144 
145 // End of page
146 llxFooter();
147 $db->close();
dol_trunc
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.
Definition: functions.lib.php:3805
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
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
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
product_prepare_head
product_prepare_head($object)
Prepare array with list of tabs.
Definition: product.lib.php:35
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
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
$help_url
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:116
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
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
Product
Class to manage products or services.
Definition: product.class.php:46
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
Product\TYPE_SERVICE
const TYPE_SERVICE
Service.
Definition: product.class.php:504
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
Product\TYPE_PRODUCT
const TYPE_PRODUCT
Regular product.
Definition: product.class.php:500
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