Work on MO
This commit is contained in:
parent
94d63a4c44
commit
dc77a58a73
@ -1051,7 +1051,7 @@ class BOMLine extends CommonObject
|
||||
'qty' => array('type'=>'double(24,8)', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'position'=>100, 'notnull'=>1, 'isameasure'=>'1',),
|
||||
'qty_frozen' => array('type'=>'smallint', 'label'=>'QuantityFrozen', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>105, 'css'=>'maxwidth50imp', 'help'=>'QuantityConsumedInvariable'),
|
||||
'disable_stock_change' => array('type'=>'smallint', 'label'=>'DisableStockChange', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>108, 'css'=>'maxwidth50imp', 'help'=>'DisableStockChangeHelp'),
|
||||
'efficiency' => array('type'=>'double(8,4)', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>1, 'default'=>1, 'position'=>110, 'notnull'=>1, 'css'=>'maxwidth50imp', 'help'=>'ValueOfMeansLoss'),
|
||||
//'efficiency' => array('type'=>'double(8,4)', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'position'=>110, 'notnull'=>1, 'css'=>'maxwidth50imp', 'help'=>'ValueOfEfficiencyConsumedMeans'),
|
||||
'position' => array('type'=>'integer', 'label'=>'Rank', 'enabled'=>1, 'visible'=>0, 'default'=>0, 'position'=>200, 'notnull'=>1,),
|
||||
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,),
|
||||
);
|
||||
|
||||
@ -128,10 +128,10 @@ $coldisplay++;
|
||||
print '<td class="bordertop nobottom linecoldisablestockchange right"><input type="checkbox" name="disable_stock_change" id="disable_stock_change" class="flat right" value="1"'.(GETPOST("disable_stock_change", 'alpha')?' checked="checked"':'').'">';
|
||||
print '</td>';
|
||||
|
||||
$coldisplay++;
|
||||
print '<td class="bordertop nobottom nowrap linecollost right">';
|
||||
print '<input type="text" size="1" name="efficiency" id="efficiency" class="flat right" value="'.(GETPOSTISSET("efficiency")?GETPOST("efficiency", 'alpha'):1).'">';
|
||||
print '</td>';
|
||||
//$coldisplay++;
|
||||
//print '<td class="bordertop nobottom nowrap linecollost right">';
|
||||
//print '<input type="text" size="1" name="efficiency" id="efficiency" class="flat right" value="'.(GETPOSTISSET("efficiency")?GETPOST("efficiency", 'alpha'):1).'">';
|
||||
//print '</td>';
|
||||
|
||||
|
||||
$coldisplay += $colspan;
|
||||
|
||||
@ -124,9 +124,9 @@ $coldisplay++;
|
||||
print '<td class="nobottom linecoldisablestockchange right"><input type="checkbox" name="disable_stock_change" id="disable_stock_change" class="flat right" value="1"'.(GETPOSTISSET('disablestockchange')?(GETPOST("disable_stock_change", 'int')?' checked="checked"':''):($line->disable_stock_change?' checked="checked"':'')).'">';
|
||||
print '</td>';
|
||||
|
||||
$coldisplay++;
|
||||
print '<td class="nobottom nowrap linecollost right">';
|
||||
print '<input type="text" size="1" name="efficiency" id="efficiency" class="flat right" value="'.$line->efficiency.'"></td>';
|
||||
//$coldisplay++;
|
||||
//print '<td class="nobottom nowrap linecollost right">';
|
||||
//print '<input type="text" size="1" name="efficiency" id="efficiency" class="flat right" value="'.$line->efficiency.'"></td>';
|
||||
|
||||
$coldisplay+=$colspan;
|
||||
print '<td class="nobottom linecoledit center valignmiddle" colspan="'.$colspan.'">';
|
||||
|
||||
@ -66,7 +66,7 @@ print '<td class="linecolqty right">'.$form->textwithpicto($langs->trans('QtyFro
|
||||
print '<td class="linecolqty right">'.$form->textwithpicto($langs->trans('DisableStockChange'), $langs->trans('DisableStockChangeHelp')).'</td>';
|
||||
|
||||
// Efficiency
|
||||
print '<td class="linecollost right">'.$form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')).'</td>';
|
||||
//print '<td class="linecollost right">'.$form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('XXX')).'</td>';
|
||||
|
||||
print '<td class="linecoledit"></td>'; // No width to allow autodim
|
||||
|
||||
|
||||
@ -97,12 +97,12 @@ $coldisplay++;
|
||||
echo $line->disable_stock_change ? yn($line->disable_stock_change) : ''; // Yes, it is a quantity, not a price, but we just want the formating role of function price
|
||||
print '</td>';
|
||||
|
||||
print '<td class="linecolqty nowrap right">';
|
||||
$coldisplay++;
|
||||
echo $line->efficiency;
|
||||
print '</td>';
|
||||
//print '<td class="linecolqty nowrap right">';
|
||||
//$coldisplay++;
|
||||
//echo $line->efficiency;
|
||||
//print '</td>';
|
||||
|
||||
if ($this->status == 0 && ($object_rights->write) && $action != 'selectlines' ) {
|
||||
if ($this->status == 0 && ($object_rights->write) && $action != 'selectlines' ) {
|
||||
print '<td class="linecoledit center">';
|
||||
$coldisplay++;
|
||||
if (($line->info_bits & 2) == 2 || ! empty($disableedit)) {
|
||||
|
||||
@ -4018,7 +4018,7 @@ abstract class CommonObject
|
||||
public function formAddObjectLine($dateSelector, $seller, $buyer, $defaulttpldir = '/core/tpl')
|
||||
{
|
||||
global $conf,$user,$langs,$object,$hookmanager,$extrafields;
|
||||
global $form,$bcnd,$var;
|
||||
global $form;
|
||||
|
||||
// Line extrafield
|
||||
if (! is_object($extrafields))
|
||||
@ -4116,7 +4116,6 @@ abstract class CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
$var = true;
|
||||
$i = 0;
|
||||
|
||||
print "<tbody>\n";
|
||||
@ -4130,18 +4129,18 @@ abstract class CommonObject
|
||||
{
|
||||
if (empty($line->fk_parent_line))
|
||||
{
|
||||
$parameters = array('line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer,'selected'=>$selected, 'table_element_line'=>$line->table_element);
|
||||
$parameters = array('line'=>$line, 'num'=>$num, 'i'=>$i, 'dateSelector'=>$dateSelector, 'seller'=>$seller, 'buyer'=>$buyer, 'selected'=>$selected, 'table_element_line'=>$line->table_element);
|
||||
$reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
}
|
||||
else
|
||||
{
|
||||
$parameters = array('line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer,'selected'=>$selected, 'table_element_line'=>$line->table_element, 'fk_parent_line'=>$line->fk_parent_line);
|
||||
$parameters = array('line'=>$line, 'num'=>$num, 'i'=>$i, 'dateSelector'=>$dateSelector, 'seller'=>$seller, 'buyer'=>$buyer, 'selected'=>$selected, 'table_element_line'=>$line->table_element, 'fk_parent_line'=>$line->fk_parent_line);
|
||||
$reshook = $hookmanager->executeHooks('printObjectSubLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
}
|
||||
}
|
||||
if (empty($reshook))
|
||||
{
|
||||
$this->printObjectLine($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected, $extrafields, $defaulttpldir);
|
||||
$this->printObjectLine($action, $line, '', $num, $i, $dateSelector, $seller, $buyer, $selected, $extrafields, $defaulttpldir);
|
||||
}
|
||||
|
||||
$i++;
|
||||
@ -4153,23 +4152,23 @@ abstract class CommonObject
|
||||
* Return HTML content of a detail line
|
||||
* TODO Move this into an output class file (htmlline.class.php)
|
||||
*
|
||||
* @param string $action GET/POST action
|
||||
* @param CommonObjectLine $line Selected object line to output
|
||||
* @param string $var Is it a an odd line (true)
|
||||
* @param int $num Number of line (0)
|
||||
* @param int $i I
|
||||
* @param int $dateSelector 1=Show also date range input fields
|
||||
* @param string $seller Object of seller third party
|
||||
* @param string $buyer Object of buyer third party
|
||||
* @param int $selected Object line selected
|
||||
* @param Extrafields $extrafields Object of extrafields
|
||||
* @param string $defaulttpldir Directory where to find the template
|
||||
* @param string $action GET/POST action
|
||||
* @param CommonObjectLine $line Selected object line to output
|
||||
* @param string $var Is it a an odd line (true)
|
||||
* @param int $num Number of line (0)
|
||||
* @param int $i I
|
||||
* @param int $dateSelector 1=Show also date range input fields
|
||||
* @param string $seller Object of seller third party
|
||||
* @param string $buyer Object of buyer third party
|
||||
* @param int $selected Object line selected
|
||||
* @param Extrafields $extrafields Object of extrafields
|
||||
* @param string $defaulttpldir Directory where to find the template
|
||||
* @return void
|
||||
*/
|
||||
public function printObjectLine($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected = 0, $extrafields = null, $defaulttpldir = '/core/tpl')
|
||||
{
|
||||
global $conf,$langs,$user,$object,$hookmanager;
|
||||
global $form,$bc,$bcdd;
|
||||
global $form;
|
||||
global $object_rights, $disableedit, $disablemove, $disableremove; // TODO We should not use global var for this !
|
||||
|
||||
$object_rights = $this->getRights();
|
||||
@ -4319,7 +4318,6 @@ abstract class CommonObject
|
||||
print '<td class="right">'.$langs->trans('ReductionShort').'</td>';
|
||||
print '<td class="center">'.$form->showCheckAddButtons('checkforselect', 1).'</td>';
|
||||
print '</tr>';
|
||||
$var = true;
|
||||
$i = 0;
|
||||
|
||||
if (! empty($this->lines))
|
||||
@ -4330,14 +4328,14 @@ abstract class CommonObject
|
||||
{
|
||||
if (empty($line->fk_parent_line))
|
||||
{
|
||||
$parameters=array('line'=>$line,'var'=>$var,'i'=>$i);
|
||||
$parameters=array('line'=>$line, 'i'=>$i);
|
||||
$action='';
|
||||
$hookmanager->executeHooks('printOriginObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->printOriginLine($line, $var, $restrictlist, '/core/tpl', $selectedLines);
|
||||
$this->printOriginLine($line, '', $restrictlist, '/core/tpl', $selectedLines);
|
||||
}
|
||||
|
||||
$i++;
|
||||
|
||||
@ -43,7 +43,9 @@ print '<td class="right">'.$this->tpl['remise_percent'].'</td>';
|
||||
|
||||
$selected=1;
|
||||
if (!empty($selectedLines) && !in_array($this->tpl['id'], $selectedLines)) $selected=0;
|
||||
print '<td class="center"><input id="cb'.$this->tpl['id'].'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$this->tpl['id'].'"'.($selected?' checked="checked"':'').'></td>';
|
||||
print '<td class="center">';
|
||||
print '<input id="cb'.$this->tpl['id'].'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$this->tpl['id'].'"'.($selected?' checked="checked"':'').'>';
|
||||
print '</td>';
|
||||
print '</tr>'."\n";
|
||||
?>
|
||||
<!-- END PHP TEMPLATE originproductline.tpl.php -->
|
||||
|
||||
@ -730,6 +730,96 @@ class Mo extends CommonObject
|
||||
|
||||
return $error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return HTML table table of source object lines
|
||||
* TODO Move this and previous function into output html class file (htmlline.class.php).
|
||||
* If lines are into a template, title must also be into a template
|
||||
* But for the moment we don't know if it's possible, so we keep the method available on overloaded objects.
|
||||
*
|
||||
* @param string $restrictlist ''=All lines, 'services'=Restrict to services only
|
||||
* @param array $selectedLines Array of lines id for selected lines
|
||||
* @return void
|
||||
*/
|
||||
public function printOriginLinesList($restrictlist = '', $selectedLines = array())
|
||||
{
|
||||
global $langs, $hookmanager, $conf, $form;
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans('Ref').'</td>';
|
||||
print '<td class="right">'.$langs->trans('Qty').'</td>';
|
||||
print '<td class="center">'.$langs->trans('QtyFrozen').'</td>';
|
||||
print '<td class="center">'.$langs->trans('DisableStockChange').'</td>';
|
||||
//print '<td class="right">'.$langs->trans('Efficiency').'</td>';
|
||||
//print '<td class="center">'.$form->showCheckAddButtons('checkforselect', 1).'</td>';
|
||||
print '<td class="center"></td>';
|
||||
print '</tr>';
|
||||
$i = 0;
|
||||
|
||||
if (! empty($this->lines))
|
||||
{
|
||||
foreach ($this->lines as $line)
|
||||
{
|
||||
if (is_object($hookmanager) && (($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line)))
|
||||
{
|
||||
if (empty($line->fk_parent_line))
|
||||
{
|
||||
$parameters=array('line'=>$line, 'i'=>$i);
|
||||
$action='';
|
||||
$hookmanager->executeHooks('printOriginObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->printOriginLine($line, '', $restrictlist, '/core/tpl', $selectedLines);
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return HTML with a line of table array of source object lines
|
||||
* TODO Move this and previous function into output html class file (htmlline.class.php).
|
||||
* If lines are into a template, title must also be into a template
|
||||
* But for the moment we don't know if it's possible as we keep a method available on overloaded objects.
|
||||
*
|
||||
* @param CommonObjectLine $line Line
|
||||
* @param string $var Var
|
||||
* @param string $restrictlist ''=All lines, 'services'=Restrict to services only (strike line if not)
|
||||
* @param string $defaulttpldir Directory where to find the template
|
||||
* @param array $selectedLines Array of lines id for selected lines
|
||||
* @return void
|
||||
*/
|
||||
public function printOriginLine($line, $var, $restrictlist = '', $defaulttpldir = '/core/tpl', $selectedLines = array())
|
||||
{
|
||||
global $langs, $conf;
|
||||
|
||||
$this->tpl['id'] = $line->id;
|
||||
|
||||
$this->tpl['label']='';
|
||||
if (! empty($line->fk_product))
|
||||
{
|
||||
$productstatic = new Product($this->db);
|
||||
$productstatic->fetch($line->fk_product);
|
||||
$this->tpl['label'].= $productstatic->getNomUrl(1);
|
||||
//$this->tpl['label'].= ' - '.$productstatic->label;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
$this->tpl['qty'] = $line->qty;
|
||||
$this->tpl['qty_frozen'] = $line->qty_frozen;
|
||||
$this->tpl['disable_stock_change'] = $line->disable_stock_change;
|
||||
//$this->tpl['efficiency'] = $line->efficiency;
|
||||
|
||||
$tpl = DOL_DOCUMENT_ROOT.'/mrp/tpl/originproductline.tpl.php';
|
||||
$res = include $tpl;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -47,8 +47,9 @@ require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
||||
dol_include_once('/mrp/class/mo.class.php');
|
||||
dol_include_once('/mrp/lib/mrp_mo.lib.php');
|
||||
require_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/mrp/lib/mrp_mo.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("mrp", "other"));
|
||||
@ -65,6 +66,7 @@ $backtopage = GETPOST('backtopage', 'alpha');
|
||||
|
||||
// Initialize technical objects
|
||||
$object = new Mo($db);
|
||||
$objectbom = new BOM($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
$diroutputmassaction = $conf->mrp->dir_output.'/temp/massgeneration/'.$user->id;
|
||||
$hookmanager->initHooks(array('mocard', 'globalcard')); // Note that conf->hooks_modules contains array
|
||||
@ -87,6 +89,16 @@ if (empty($action) && empty($id) && empty($ref)) $action = 'view';
|
||||
// Load object
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
|
||||
|
||||
if (GETPOST('fk_bom', 'int'))
|
||||
{
|
||||
$objectbom->fetch(GETPOST('fk_bom', 'int'));
|
||||
|
||||
$_POST['fk_product'] = $objectbom->fk_product;
|
||||
$_POST['qty'] = $objectbom->qty;
|
||||
$_POST['fk_warehouse'] = $objectbom->fk_warehouse;
|
||||
$_POST['note_private'] = $objectbom->note_private;
|
||||
}
|
||||
|
||||
// Security check - Protection if external user
|
||||
//if ($user->socid > 0) access_forbidden();
|
||||
//if ($user->socid > 0) $socid = $user->socid;
|
||||
@ -212,6 +224,9 @@ if ($action == 'create')
|
||||
console.log('We change value of BOM with BOM of id '+jQuery('#fk_bom').val());
|
||||
if (jQuery('#fk_bom').val() > 0)
|
||||
{
|
||||
// Redirect to page with fk_bom set
|
||||
window.location.href = '<?php echo $_SERVER["PHP_SELF"] ?>?action=create&fk_bom='+jQuery('#fk_bom').val();
|
||||
/*
|
||||
$.getJSON('<?php echo DOL_URL_ROOT ?>/mrp/ajax/ajax_bom.php?action=getBoms&idbom='+jQuery('#fk_bom').val(), function(data) {
|
||||
console.log(data);
|
||||
if (typeof data.rowid != "undefined") {
|
||||
@ -234,7 +249,7 @@ if ($action == 'create')
|
||||
} else {
|
||||
console.log("Failed to get BOM");
|
||||
}
|
||||
});
|
||||
});*/
|
||||
}
|
||||
else {
|
||||
/*
|
||||
@ -249,7 +264,7 @@ if ($action == 'create')
|
||||
}
|
||||
});
|
||||
|
||||
jQuery('#fk_bom').trigger('change');
|
||||
//jQuery('#fk_bom').trigger('change');
|
||||
})
|
||||
</script>
|
||||
<?php
|
||||
@ -260,6 +275,16 @@ if ($action == 'create')
|
||||
print '<input type="'.($backtopage ? "submit" : "button").'" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'"'.($backtopage ? '' : ' onclick="javascript:history.go(-1)"').'>'; // Cancel for create does not post form if we don't know the backtopage
|
||||
print '</div>';
|
||||
|
||||
print load_fiche_titre($langs->trans("ToConsume"));
|
||||
|
||||
print '<table class="noborder centpercent">';
|
||||
|
||||
$object->lines = $objectbom->lines;
|
||||
|
||||
$object->printOriginLinesList('', array());
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
|
||||
44
htdocs/mrp/tpl/originproductline.tpl.php
Normal file
44
htdocs/mrp/tpl/originproductline.tpl.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
/* Copyright (C) 2017 Charlie Benke <charlie@patas-monkey.com>
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
// Protection to avoid direct call of template
|
||||
if (empty($conf) || ! is_object($conf))
|
||||
{
|
||||
print "Error, template page can't be called as URL";
|
||||
exit;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<!-- BEGIN PHP TEMPLATE originproductline.tpl.php -->
|
||||
<?php
|
||||
print '<tr class="oddeven'.(empty($this->tpl['strike'])?'':' strikefordisabled').'">';
|
||||
print '<td>'.$this->tpl['label'].'</td>';
|
||||
print '<td class="right">'.$this->tpl['qty'].'</td>';
|
||||
print '<td class="center">'.yn($this->tpl['qty_frozen']).'</td>';
|
||||
print '<td class="center">'.yn($this->tpl['disable_stock_change']).'</td>';
|
||||
//print '<td class="right">'.$this->tpl['efficiency'].'</td>';
|
||||
|
||||
$selected=1;
|
||||
if (!empty($selectedLines) && !in_array($this->tpl['id'], $selectedLines)) $selected=0;
|
||||
print '<td class="center">';
|
||||
//print '<input id="cb'.$this->tpl['id'].'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$this->tpl['id'].'"'.($selected?' checked="checked"':'').'>';
|
||||
print '</td>';
|
||||
print '</tr>'."\n";
|
||||
?>
|
||||
<!-- END PHP TEMPLATE originproductline.tpl.php -->
|
||||
Loading…
Reference in New Issue
Block a user