dolibarr/htdocs/bom/bom_note.php

128 lines
4.1 KiB
PHP
Raw Normal View History

2019-02-26 19:27:04 +01:00
<?php
2019-03-06 18:26:23 +01:00
/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr>
2019-02-26 19:27:04 +01:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2019-02-26 19:27:04 +01:00
*/
/**
* \file bom_note.php
* \ingroup bom
* \brief Car with notes on BillOfMaterials
*/
// Load Dolibarr environment
2019-03-06 18:26:23 +01:00
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php';
2019-03-12 13:09:31 +01:00
require_once DOL_DOCUMENT_ROOT.'/bom/lib/bom.lib.php';
2019-02-26 19:27:04 +01:00
// Load translation files required by the page
$langs->loadLangs(array("mrp", "companies"));
2019-02-26 19:27:04 +01:00
// Get parameters
$id = GETPOST('id', 'int');
2019-02-26 19:27:04 +01:00
$ref = GETPOST('ref', 'alpha');
2020-09-16 19:39:50 +02:00
$action = GETPOST('action', 'aZ09');
2021-02-23 17:51:46 +01:00
$cancel = GETPOST('cancel', 'aZ09');
2019-02-26 19:27:04 +01:00
$backtopage = GETPOST('backtopage', 'alpha');
// Initialize technical objects
$object = new BOM($db);
2019-02-26 19:27:04 +01:00
$extrafields = new ExtraFields($db);
$diroutputmassaction = $conf->bom->dir_output.'/temp/massgeneration/'.$user->id;
$hookmanager->initHooks(array('bomnote', 'globalcard')); // Note that conf->hooks_modules contains array
2019-09-28 10:55:09 +02:00
2019-02-26 19:27:04 +01:00
// Fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element);
2019-02-26 19:27:04 +01:00
// Security check - Protection if external user
2019-11-22 15:35:19 +01:00
//if ($user->socid > 0) accessforbidden();
//if ($user->socid > 0) $socid = $user->socid;
2019-02-26 19:27:04 +01:00
//$result = restrictedArea($user, 'bom', $id);
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
2021-02-23 17:51:46 +01:00
if ($id > 0 || !empty($ref)) {
2022-05-18 12:31:09 +02:00
$upload_dir = (!empty($conf->bom->multidir_output[$object->entity]) ? $conf->bom->multidir_output[$object->entity] : $conf->bom->dir_output)."/".$object->id;
2021-02-23 17:51:46 +01:00
}
2019-02-26 19:27:04 +01:00
2021-03-18 20:44:53 +01:00
$permissionnote = $user->rights->bom->write; // Used by the include of actions_setnotes.inc.php
2019-02-26 19:27:04 +01:00
2021-03-18 20:44:53 +01:00
// Security check - Protection if external user
//if ($user->socid > 0) accessforbidden();
//if ($user->socid > 0) $socid = $user->socid;
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
2021-03-23 18:02:52 +01:00
restrictedArea($user, 'bom', $object->id, 'bom_bom', '', '', 'rowid', $isdraft);
2019-02-26 19:27:04 +01:00
/*
* Actions
*/
2021-07-09 18:36:21 +02:00
$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks
2021-07-11 09:44:01 +02:00
if ($reshook < 0) {
2021-07-09 18:36:21 +02:00
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2021-07-11 09:44:01 +02:00
}
2021-07-11 09:44:41 +02:00
if (empty($reshook)) {
2021-07-09 18:36:21 +02:00
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
2021-07-11 09:44:01 +02:00
}
2019-02-26 19:27:04 +01:00
/*
* View
*/
$form = new Form($db);
2021-04-12 18:49:35 +02:00
$title = $langs->trans('BillOfMaterials');
$help_url = 'EN:Module_BOM';
2021-04-12 18:49:35 +02:00
llxHeader('', $title, $help_url);
2019-02-26 19:27:04 +01:00
2021-02-23 17:51:46 +01:00
if ($id > 0 || !empty($ref)) {
2019-02-26 19:27:04 +01:00
$object->fetch_thirdparty();
$head = bomPrepareHead($object);
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head($head, 'note', $langs->trans("BillOfMaterials"), -1, 'bom');
2019-02-26 19:27:04 +01:00
// Object card
// ------------------------------------------------------------
$linkback = '<a href="'.DOL_URL_ROOT.'/bom/bom_list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
2019-02-26 19:27:04 +01:00
$morehtmlref = '<div class="refidno">';
2021-06-11 15:08:54 +02:00
$morehtmlref .= '</div>';
2019-02-26 19:27:04 +01:00
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
$cssclass = "titlefield";
2019-02-26 19:27:04 +01:00
include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
print '</div>';
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end();
2019-02-26 19:27:04 +01:00
}
// End of page
llxFooter();
$db->close();