From 6dbc57998a362dca3834c022bf9a8892f7183909 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Fri, 4 Nov 2022 11:51:47 +0100 Subject: [PATCH 1/5] Fix Object Linked MO Line --- htdocs/core/class/html.form.class.php | 5 +- htdocs/mrp/tpl/linkedobjectblock.tpl.php | 92 ++++++++++++++++-------- 2 files changed, 64 insertions(+), 33 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 5efbdeae8e1..6caf54638c9 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7544,7 +7544,6 @@ class Form public function selectForForms($objectdesc, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $disabled = 0, $selected_input_value = '') { global $conf, $user; - $objecttmp = null; // Example of value for $objectdec: @@ -7771,7 +7770,7 @@ class Form } $sql .= $this->db->order($sortfield ? $sortfield : $fieldstoshow, "ASC"); //$sql.=$this->db->plimit($limit, 0); - //print $sql; +// print $sql; // Build output string $resql = $this->db->query($sql); @@ -8509,7 +8508,6 @@ class Form { global $conf, $langs, $hookmanager; global $bc, $action; - $object->fetchObjectLinked(); // Bypass the default method @@ -8624,6 +8622,7 @@ class Form // Output template part (modules that overwrite templates must declare this into descriptor) $dirtpls = array_merge($conf->modules_parts['tpl'], array('/'.$tplpath.'/tpl')); + foreach ($dirtpls as $reldir) { if ($nboftypesoutput == ($nbofdifferenttypes - 1)) { // No more type to show after global $noMoreLinkedObjectBlockAfter; diff --git a/htdocs/mrp/tpl/linkedobjectblock.tpl.php b/htdocs/mrp/tpl/linkedobjectblock.tpl.php index 9374fc2e4d0..7189228abe0 100644 --- a/htdocs/mrp/tpl/linkedobjectblock.tpl.php +++ b/htdocs/mrp/tpl/linkedobjectblock.tpl.php @@ -39,44 +39,76 @@ $langs->load("bom"); $total = 0; $ilink = 0; -$mo_static = new Mo($db); -$res = $mo_static->fetch($object->id); -$TMoChilds = $mo_static->getMoChilds(); +if($object->element == 'mo') { -foreach ($TMoChilds as $key => $objectlink) { - $ilink++; + $mo_static = new Mo($db); + $res = $mo_static->fetch($object->id); + $TMoChilds = $mo_static->getMoChilds(); - $trclass = 'oddeven'; - echo ''; - echo ''.$langs->trans("ManufacturingOrder"); - if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { - print ' $objectlink) { + $ilink++; + + $trclass = 'oddeven'; + + echo ''; + echo '' . $langs->trans("ManufacturingOrder"); + if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { + print ' '; + echo '' . $objectlink->getNomUrl(1) . ''; + + echo ''; + // $result = $product_static->fetch($objectlink->fk_product); + print ''; + echo '' . dol_print_date($objectlink->date_creation, 'day') . ''; + echo '-'; + echo '' . $objectlink->getLibStatut(3) . ''; + echo ''; + + // we want to make the link via element_element for delete action + $sql = " Select rowid from " . MAIN_DB_PREFIX . "element_element"; + $sql .= " WHERE fk_source = " . (int)$object->id . " and fk_target = '" . dol_escape_htmltag($key) . "'"; + + $resql = $db->query($sql); + $k = 0; + if ($resql) { + $obj = $db->fetch_object($resql); + if ($obj->rowid && $obj->rowid > 0) $k = $obj->rowid; + } + echo '' . img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink') . ''; + echo ''; + echo "\n"; } - echo ''; - echo ''.$objectlink->getNomUrl(1).''; +} else { + $linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1); - echo ''; - // $result = $product_static->fetch($objectlink->fk_product); - print ''; - echo ''.dol_print_date($objectlink->date_creation, 'day').''; - echo '-'; - echo ''.$objectlink->getLibStatut(3).''; - echo ''; + $total = 0; + $ilink = 0; + foreach ($linkedObjectBlock as $key => $objectlink) { + $ilink++; - // we want to make the link via element_element for delete action - $sql = " Select rowid from " . MAIN_DB_PREFIX . "element_element"; - $sql .= " WHERE fk_source = ". (int) $object->id . " and fk_target = '" . dol_escape_htmltag($key) ."'"; + $trclass = 'oddeven'; + if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) { + $trclass .= ' liste_sub_total'; + } + print ''; + print ''.$langs->trans("ManufacturingOrder"); + if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { + $url = DOL_URL_ROOT.'/mrp/mo_card.php?id='.$objectlink->id; + print ' '; + } + print ''; - $resql = $db->query($sql); - $k = 0; - if ($resql) { - $obj = $db->fetch_object($resql); - if ($obj->rowid && $obj->rowid > 0 ) $k = $obj->rowid; + print ''.$objectlink->getNomUrl(1).''; + print ''.$objectlink->ref_client.''; + print ''.dol_print_date($objectlink->date_start_planned, 'day').''; + print '-'; + print ''.$objectlink->getLibStatut(3).''; + print ''.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').''; + print "\n"; } - echo '' . img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink') . ''; - echo ''; - echo "\n"; } echo "\n"; From d166ae9167d6d2d5eb892c67e357590304479f32 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Tue, 8 Nov 2022 09:46:55 +0100 Subject: [PATCH 2/5] MOChild => Linked Object --- htdocs/mrp/mo_card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index 2c333ff616e..b7d3f86b9e7 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -731,7 +731,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, array('mo')); - $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, false, 'MOChild'); + $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, false); print '
'; From 0a9c0d704e59dee43c8f0346dc15c928ead37897 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Tue, 8 Nov 2022 09:49:20 +0100 Subject: [PATCH 3/5] Clean --- htdocs/core/class/html.form.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 6caf54638c9..50b1e226739 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7770,7 +7770,7 @@ class Form } $sql .= $this->db->order($sortfield ? $sortfield : $fieldstoshow, "ASC"); //$sql.=$this->db->plimit($limit, 0); -// print $sql; + //print $sql; // Build output string $resql = $this->db->query($sql); @@ -8622,7 +8622,6 @@ class Form // Output template part (modules that overwrite templates must declare this into descriptor) $dirtpls = array_merge($conf->modules_parts['tpl'], array('/'.$tplpath.'/tpl')); - foreach ($dirtpls as $reldir) { if ($nboftypesoutput == ($nbofdifferenttypes - 1)) { // No more type to show after global $noMoreLinkedObjectBlockAfter; From f4cf7363bd20cf18a7e50b0d794dd9e0f1d51247 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Tue, 8 Nov 2022 09:50:54 +0100 Subject: [PATCH 4/5] Clean code --- htdocs/core/class/html.form.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 50b1e226739..5efbdeae8e1 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7544,6 +7544,7 @@ class Form public function selectForForms($objectdesc, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $disabled = 0, $selected_input_value = '') { global $conf, $user; + $objecttmp = null; // Example of value for $objectdec: @@ -8508,6 +8509,7 @@ class Form { global $conf, $langs, $hookmanager; global $bc, $action; + $object->fetchObjectLinked(); // Bypass the default method From 15a2f71534f1b34c6f15888abbd2fbe6443e2fcd Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 8 Nov 2022 08:55:25 +0000 Subject: [PATCH 5/5] Fixing style errors. --- htdocs/mrp/tpl/linkedobjectblock.tpl.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/mrp/tpl/linkedobjectblock.tpl.php b/htdocs/mrp/tpl/linkedobjectblock.tpl.php index 7189228abe0..dfa6d9797c2 100644 --- a/htdocs/mrp/tpl/linkedobjectblock.tpl.php +++ b/htdocs/mrp/tpl/linkedobjectblock.tpl.php @@ -39,8 +39,7 @@ $langs->load("bom"); $total = 0; $ilink = 0; -if($object->element == 'mo') { - +if ($object->element == 'mo') { $mo_static = new Mo($db); $res = $mo_static->fetch($object->id); $TMoChilds = $mo_static->getMoChilds(); @@ -69,7 +68,7 @@ if($object->element == 'mo') { // we want to make the link via element_element for delete action $sql = " Select rowid from " . MAIN_DB_PREFIX . "element_element"; - $sql .= " WHERE fk_source = " . (int)$object->id . " and fk_target = '" . dol_escape_htmltag($key) . "'"; + $sql .= " WHERE fk_source = " . (int) $object->id . " and fk_target = '" . dol_escape_htmltag($key) . "'"; $resql = $db->query($sql); $k = 0;