dolibarr 21.0.0-beta
bom.lib.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2019 Maxime Kohlhaas <maxime@atm-consulting.fr>
3 * Copyright (C) 2019-2023 Frédéric France <frederic.france@netlogic.fr>
4 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
32{
33 global $langs, $conf;
34
35 $langs->load("mrp");
36
37 $h = 0;
38 $head = array();
39
40 $head[$h][0] = DOL_URL_ROOT."/admin/bom.php";
41 $head[$h][1] = $langs->trans("Settings");
42 $head[$h][2] = 'settings';
43 $h++;
44
45 $head[$h][0] = DOL_URL_ROOT."/admin/bom_extrafields.php";
46 $head[$h][1] = $langs->trans("ExtraFields");
47 $head[$h][2] = 'bom_extrafields';
48 $h++;
49
50 $head[$h][0] = DOL_URL_ROOT."/admin/bomline_extrafields.php";
51 $head[$h][1] = $langs->trans("ExtraFieldsLines");
52 $head[$h][2] = 'bomline_extrafields';
53 $h++;
54
55 // Show more tabs from modules
56 // Entries must be declared in modules descriptor with line
57 //$this->tabs = array(
58 // 'entity:+tabname:Title:@bom:/bom/mypage.php?id=__ID__'
59 //); // to add new tab
60 //$this->tabs = array(
61 // 'entity:-tabname:Title:@bom:/bom/mypage.php?id=__ID__'
62 //); // to remove a tab
63 complete_head_from_modules($conf, $langs, null, $head, $h, 'bom@mrp');
64
65 complete_head_from_modules($conf, $langs, null, $head, $h, 'bom@mrp', 'remove');
66
67 return $head;
68}
69
70
71
72
80{
81 global $db, $langs, $conf;
82
83 $langs->load("mrp");
84
85 $h = 0;
86 $head = array();
87
88 $head[$h][0] = DOL_URL_ROOT."/bom/bom_card.php?id=".$object->id;
89 $head[$h][1] = $langs->trans("BOM");
90 $head[$h][2] = 'card';
91 $h++;
92
93 $head[$h][0] = DOL_URL_ROOT."/bom/bom_net_needs.php?id=".$object->id;
94 $head[$h][1] = $langs->trans("BOMNetNeeds");
95 $head[$h][2] = 'net_needs';
96 $h++;
97
98 if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
99 $nbNote = 0;
100 if (!empty($object->note_private)) {
101 $nbNote++;
102 }
103 if (!empty($object->note_public)) {
104 $nbNote++;
105 }
106 $head[$h][0] = DOL_URL_ROOT.'/bom/bom_note.php?id='.$object->id;
107 $head[$h][1] = $langs->trans('Notes');
108 if ($nbNote > 0) {
109 $head[$h][1] .= (!getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER') ? '<span class="badge marginleftonlyshort">'.$nbNote.'</span>' : '');
110 }
111 $head[$h][2] = 'note';
112 $h++;
113 }
114
115 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
116 require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
117 $upload_dir = $conf->bom->dir_output."/".dol_sanitizeFileName($object->ref);
118 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
119 $nbLinks = Link::count($db, $object->element, $object->id);
120 $head[$h][0] = DOL_URL_ROOT.'/bom/bom_document.php?id='.$object->id;
121 $head[$h][1] = $langs->trans('Documents');
122 if (($nbFiles + $nbLinks) > 0) {
123 $head[$h][1] .= (!getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER') ? '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>' : '');
124 }
125 $head[$h][2] = 'document';
126 $h++;
127
128 $head[$h][0] = DOL_URL_ROOT.'/bom/bom_agenda.php?id='.$object->id;
129 $head[$h][1] = $langs->trans("Events");
130 $head[$h][2] = 'agenda';
131 $h++;
132
133 // Show more tabs from modules
134 // Entries must be declared in modules descriptor with line
135 //$this->tabs = array(
136 // 'entity:+tabname:Title:@bom:/bom/mypage.php?id=__ID__'
137 //); // to add new tab
138 //$this->tabs = array(
139 // 'entity:-tabname:Title:@bom:/bom/mypage.php?id=__ID__'
140 //); // to remove a tab
141 complete_head_from_modules($conf, $langs, $object, $head, $h, 'bom');
142
143 complete_head_from_modules($conf, $langs, $object, $head, $h, 'bom', 'remove');
144
145 return $head;
146}
147
154{
155 ?>
156
157 <script type="text/javascript" language="javascript">
158
159 $(document).ready(function () {
160 function folderManage(element, onClose = 0) {
161 let id_bom_line = element.attr('id').replace('collapse-', '');
162 let TSubLines = $('[parentid="'+ id_bom_line +'"]');
163
164 if(element.html().indexOf('folder-open') <= 0 && onClose < 1) {
165 $('[parentid="'+ id_bom_line +'"]').show();
166 element.html('<?php echo dol_escape_js(img_picto('', 'folder-open')); ?>');
167 }
168 else {
169 for (let i = 0; i < TSubLines.length; i++) {
170 let subBomFolder = $(TSubLines[i]).children('.linecoldescription').children('.collapse_bom');
171
172 if (subBomFolder.length > 0) {
173 onClose = 1
174 folderManage(subBomFolder, onClose);
175 }
176 }
177 TSubLines.hide();
178 element.html('<?php echo dol_escape_js(img_picto('', 'folder')); ?>');
179 }
180 }
181
182 // When clicking on collapse
183 $(".collapse_bom").click(function() {
184 folderManage($(this));
185 return false;
186 });
187
188 // To Show all the sub bom lines
189 $("#show_all").click(function() {
190 console.log("We click on show all");
191 $("[class^=sub_bom_lines]").show();
192 $("[class^=collapse_bom]").html('<?php echo dol_escape_js(img_picto('', 'folder-open')); ?>');
193 return false;
194 });
195
196 // To Hide all the sub bom lines
197 $("#hide_all").click(function() {
198 console.log("We click on hide all");
199 $("[class^=sub_bom_lines]").hide();
200 $("[class^=collapse_bom]").html('<?php echo dol_escape_js(img_picto('', 'folder')); ?>');
201 return false;
202 });
203 });
204
205 </script>
206
207 <?php
208}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
mrpCollapseBomManagement()
Manage collapse bom display.
Definition bom.lib.php:153
bomAdminPrepareHead()
Prepare admin pages header.
Definition bom.lib.php:31
bomPrepareHead($object)
Prepare array of tabs for BillOfMaterials.
Definition bom.lib.php:79
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:63
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:149