dolibarr 20.0.2
mrp_mo.lib.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) ---Put here your own copyright and developer email---
3 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
32{
33 global $db, $langs, $conf;
34
35 $langs->loadLangs(array("mrp", "stocks"));
36
37 $h = 0;
38 $head = array();
39
40 $head[$h][0] = DOL_URL_ROOT . '/mrp/mo_card.php?id=' . $object->id;
41 $head[$h][1] = $langs->trans("ManufacturingOrder");
42 $head[$h][2] = 'card';
43 $h++;
44
45 $head[$h][0] = DOL_URL_ROOT . '/mrp/mo_production.php?id=' . $object->id;
46 $head[$h][1] = $langs->trans("Production");
47 $arrayproduced = $object->fetchLinesLinked('produced', 0);
48 $nbProduced = 0;
49 foreach ($arrayproduced as $lineproduced) {
50 $nbProduced += $lineproduced['qty'];
51 }
52 $head[$h][1] .= '<span class="badge marginleftonlyshort">' . $nbProduced . ' / ' . $object->qty . '</span>';
53 $head[$h][2] = 'production';
54 $h++;
55
56 $head[$h][0] = DOL_URL_ROOT . '/mrp/mo_movements.php?id=' . $object->id;
57 $head[$h][1] = $langs->trans("StockMovements");
58 $nbMove = $object->countMovements();
59 $head[$h][1] .= '<span class="badge marginleftonlyshort">' . $nbMove . '</span>';
60 $head[$h][2] = 'stockmovement';
61 $h++;
62
63 if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
64 $nbNote = 0;
65 if (!empty($object->note_private)) {
66 $nbNote++;
67 }
68 if (!empty($object->note_public)) {
69 $nbNote++;
70 }
71 $head[$h][0] = DOL_URL_ROOT . '/mrp/mo_note.php?id=' . $object->id;
72 $head[$h][1] = $langs->trans('Notes');
73 if ($nbNote > 0) {
74 $head[$h][1] .= '<span class="badge marginleftonlyshort">' . $nbNote . '</span>';
75 }
76 $head[$h][2] = 'note';
77 $h++;
78 }
79
80 require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
81 require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php';
82 $upload_dir = $conf->mrp->dir_output . "/" . dol_sanitizeFileName($object->ref);
83 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
84 $nbLinks = Link::count($db, $object->element, $object->id);
85 $head[$h][0] = DOL_URL_ROOT . '/mrp/mo_document.php?id=' . $object->id;
86 $head[$h][1] = $langs->trans('Documents');
87 if (($nbFiles + $nbLinks) > 0) {
88 $head[$h][1] .= '<span class="badge marginleftonlyshort">' . ($nbFiles + $nbLinks) . '</span>';
89 }
90 $head[$h][2] = 'document';
91 $h++;
92
93 $head[$h][0] = DOL_URL_ROOT . '/mrp/mo_agenda.php?id=' . $object->id;
94 $head[$h][1] = $langs->trans("Events");
95 $head[$h][2] = 'agenda';
96 $h++;
97
98 // Show more tabs from modules
99 // Entries must be declared in modules descriptor with line
100 //$this->tabs = array(
101 // 'entity:+tabname:Title:@mrp:/mrp/mypage.php?id=__ID__'
102 //); // to add new tab
103 //$this->tabs = array(
104 // 'entity:-tabname:Title:@mrp:/mrp/mypage.php?id=__ID__'
105 //); // to remove a tab
106 complete_head_from_modules($conf, $langs, $object, $head, $h, 'mo@mrp');
107
108 complete_head_from_modules($conf, $langs, $object, $head, $h, 'mo@mrp', 'remove');
109
110 return $head;
111}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
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).
moPrepareHead($object)
Prepare array of tabs for Mo.