Merge pull request #22085 from lkotsoni/Add_notes_to_productlot

[NEW][#22048][Added notes to productlot module]
This commit is contained in:
Laurent Destailleur
2022-10-07 23:28:13 +02:00
committed by GitHub
5 changed files with 142 additions and 2 deletions

View File

@@ -253,6 +253,24 @@ function productlot_prepare_head($object)
$head[$h][2] = 'documents';
$h++;
// Notes
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
$nbNote = 0;
if (!empty($object->note_private)) {
$nbNote++;
}
if (!empty($object->note_public)) {
$nbNote++;
}
$head[$h][0] = DOL_URL_ROOT .'/product/stock/productlot_note.php?id=' . $object->id;
$head[$h][1] = $langs->trans('Notes');
if ($nbNote > 0) {
$head[$h][1] .= '<span class="badge marginleftonlyshort">' . $nbNote . '</span>';
}
$head[$h][2] = 'note';
$h++;
}
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab

View File

@@ -145,6 +145,9 @@ CREATE TABLE llx_bank_extrafields
ALTER TABLE llx_bank_extrafields ADD INDEX idx_bank_extrafields (fk_object);
ALTER TABLE llx_product_lot ADD COLUMN note_public text DEFAULT NULL after batch;
ALTER TABLE llx_product_lot ADD COLUMN note_private text DEFAULT NULL after note_public;
ALTER TABLE llx_user CHANGE COLUMN note note_private text;
UPDATE llx_c_effectif SET code='EF101-500', libelle='101 - 500' WHERE code='EF100-500';

View File

@@ -22,6 +22,8 @@ CREATE TABLE llx_product_lot (
entity integer DEFAULT 1,
fk_product integer NOT NULL, -- Id of product
batch varchar(128) DEFAULT NULL, -- Lot or serial number
note_public text DEFAULT NULL,
note_private text DEFAULT NULL,
eatby date DEFAULT NULL, -- Eatby date
sellby date DEFAULT NULL, -- Sellby date
eol_date datetime NULL,

View File

@@ -101,7 +101,7 @@ class Productlot extends CommonObject
'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501),
'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510, 'foreignkey'=>'llx_user.rowid'),
'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511),
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000),
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000)
);
/**
@@ -295,7 +295,9 @@ class Productlot extends CommonObject
$sql .= " t.tms,";
$sql .= " t.fk_user_creat,";
$sql .= " t.fk_user_modif,";
$sql .= " t.import_key";
$sql .= " t.import_key,";
$sql .= " t.note_public,";
$sql .= " t.note_private";
$sql .= " FROM ".$this->db->prefix().$this->table_element." as t";
if ($product_id > 0 && $batch != '') {
$sql .= " WHERE t.batch = '".$this->db->escape($batch)."' AND t.fk_product = ".((int) $product_id);
@@ -329,6 +331,8 @@ class Productlot extends CommonObject
$this->fk_user_creat = $obj->fk_user_creat;
$this->fk_user_modif = $obj->fk_user_modif;
$this->import_key = $obj->import_key;
$this->note_public = $obj->note_public;
$this->note_private = $obj->note_private;
// Retrieve all extrafield
// fetch optionals attributes and labels

View File

@@ -0,0 +1,113 @@
<?php
/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) ---Put here your own copyright and developer email---
*
* 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
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \file productlot_note.php
* \ingroup productlot
* \brief Tab for notes on productlot
*/
require '../../main.inc.php';
dol_include_once('/product/stock/class/productlot.class.php');
dol_include_once('/core/lib/product.lib.php');
// Load translation files required by the page
$langs->loadLangs(array('other', 'products'));
// Get parameters
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09');
// Initialize technical objects
$object = new Productlot($db);
$extrafields = new ExtraFields($db);
$diroutputmassaction = $conf->productlot->dir_output.'/temp/massgeneration/'.$user->id;
$hookmanager->initHooks(array('productlotnote')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element);
// 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
if ($id > 0 || !empty($ref)) {
$upload_dir = $conf->productlot->multidir_output[!empty($object->entity) ? $object->entity : $conf->entity]."/".$object->id;
}
$permissionnote = $user->rights->produit->lire; // Used by the include of actions_setnotes.inc.php
// Security check (enable the most restrictive one)
//if ($user->socid > 0) accessforbidden();
//if ($user->socid > 0) $socid = $user->socid;
//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
//if (empty($conf->calibration->enabled)) accessforbidden();
//if (!$permissiontoread) accessforbidden();
/*
* Actions
*/
$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) {
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
}
/*
* View
*/
$form = new Form($db);
$help_url = '';
llxHeader('', $langs->trans('productlot'), $help_url);
if ($id > 0 || !empty($ref)) {
$object->fetch_thirdparty();
$head = productlot_prepare_head($object);
print dol_get_fiche_head($head, 'note', '', -1, $object->picto);
// Object card
// ------------------------------------------------------------
$linkback = '<a href="'.dol_buildpath('/stock/productlot_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'batch');
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
$cssclass = "titlefield";
include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
print '</div>';
print dol_get_fiche_end();
}
// End of page
llxFooter();
$db->close();