Fix Object Linked MO Line
This commit is contained in:
parent
bc2e226ef8
commit
6dbc57998a
@ -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;
|
||||
|
||||
@ -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 '<tr class="'.$trclass.'" >';
|
||||
echo '<td class="linkedcol-element" >'.$langs->trans("ManufacturingOrder");
|
||||
if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) {
|
||||
print '<a class="objectlinked_importbtn" href="'.$objectlink->getNomUrl(0, '', 0, 1).'&action=selectlines" data-element="'.$objectlink->element.'" data-id="'.$objectlink->id.'" > <i class="fa fa-indent"></i> </a';
|
||||
foreach ($TMoChilds as $key => $objectlink) {
|
||||
$ilink++;
|
||||
|
||||
$trclass = 'oddeven';
|
||||
|
||||
echo '<tr class="' . $trclass . '" >';
|
||||
echo '<td class="linkedcol-element" >' . $langs->trans("ManufacturingOrder");
|
||||
if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) {
|
||||
print '<a class="objectlinked_importbtn" href="' . $objectlink->getNomUrl(0, '', 0, 1) . '&action=selectlines" data-element="' . $objectlink->element . '" data-id="' . $objectlink->id . '" > <i class="fa fa-indent"></i> </a';
|
||||
}
|
||||
echo '</td>';
|
||||
echo '<td class="linkedcol-name nowraponall" >' . $objectlink->getNomUrl(1) . '</td>';
|
||||
|
||||
echo '<td class="linkedcol-ref" align="center">';
|
||||
// $result = $product_static->fetch($objectlink->fk_product);
|
||||
print '</td>';
|
||||
echo '<td class="linkedcol-date" align="center">' . dol_print_date($objectlink->date_creation, 'day') . '</td>';
|
||||
echo '<td class="linkedcol-amount right">-</td>';
|
||||
echo '<td class="linkedcol-statut right">' . $objectlink->getLibStatut(3) . '</td>';
|
||||
echo '<td class="linkedcol-action right">';
|
||||
|
||||
// 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 '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=dellink&token=' . newToken() . '&dellinkid=' . $k . '">' . img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink') . '</a>';
|
||||
echo '</td>';
|
||||
echo "</tr>\n";
|
||||
}
|
||||
echo '</td>';
|
||||
echo '<td class="linkedcol-name nowraponall" >'.$objectlink->getNomUrl(1).'</td>';
|
||||
} else {
|
||||
$linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1);
|
||||
|
||||
echo '<td class="linkedcol-ref" align="center">';
|
||||
// $result = $product_static->fetch($objectlink->fk_product);
|
||||
print '</td>';
|
||||
echo '<td class="linkedcol-date" align="center">'.dol_print_date($objectlink->date_creation, 'day').'</td>';
|
||||
echo '<td class="linkedcol-amount right">-</td>';
|
||||
echo '<td class="linkedcol-statut right">'.$objectlink->getLibStatut(3).'</td>';
|
||||
echo '<td class="linkedcol-action right">';
|
||||
$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 '<tr class="'.$trclass.'" data-element="'.$objectlink->element.'" data-id="'.$objectlink->id.'" >';
|
||||
print '<td class="linkedcol-element" >'.$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 '<a class="objectlinked_importbtn" href="'.$url.'&action=selectlines" data-element="'.$objectlink->element.'" data-id="'.$objectlink->id.'" > <i class="fa fa-indent"></i> </a>';
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
$resql = $db->query($sql);
|
||||
$k = 0;
|
||||
if ($resql) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
if ($obj->rowid && $obj->rowid > 0 ) $k = $obj->rowid;
|
||||
print '<td class="linkedcol-name nowraponall" >'.$objectlink->getNomUrl(1).'</td>';
|
||||
print '<td class="linkedcol-ref" >'.$objectlink->ref_client.'</td>';
|
||||
print '<td class="linkedcol-date center">'.dol_print_date($objectlink->date_start_planned, 'day').'</td>';
|
||||
print '<td class="linkedcol-amount right">-</td>';
|
||||
print '<td class="linkedcol-statut right">'.$objectlink->getLibStatut(3).'</td>';
|
||||
print '<td class="linkedcol-action right"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&token='.newToken().'&dellinkid='.$key.'">'.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').'</a></td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
echo '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=dellink&token=' . newToken() . '&dellinkid=' . $k . '">' . img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink') . '</a>';
|
||||
echo '</td>';
|
||||
echo "</tr>\n";
|
||||
}
|
||||
|
||||
echo "<!-- END PHP TEMPLATE -->\n";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user