32require_once DOL_DOCUMENT_ROOT.
"/product/class/html.formproduct.class.php";
 
   35if (empty($object) || !is_object($object)) {
 
   36  print 
"Error: this template page cannot be called directly as an URL";
 
   41global $forceall, $forcetoshowtitlelines, $filtertype;
 
   43if (empty($forceall)) {
 
   47if (empty($filtertype)) {
 
   50if (!empty($object->element) && $object->element == 
'contrat' && !
getDolGlobalString(
'STOCK_SUPPORT_SERVICES')) {
 
   61$objectline = 
new BOMLine($this->db);
 
   63print 
"<!-- BEGIN PHP TEMPLATE objectline_create.tpl.php -->\n";
 
   65$nolinesbefore = (count($this->lines) == 0 || $forcetoshowtitlelines);
 
   68  print 
'<tr class="liste_titre nodrag nodrop">';
 
   70    print 
'<td class="linecolnum center"></td>';
 
   72  print 
'<td class="linecoldescription minwidth500imp">';
 
   73  print 
'<div id="add"></div><span class="hideonsmartphone">'.$langs->trans(
'AddNewLine').
'</span>';
 
   75  print 
'<td class="linecolqty right">'.$langs->trans(
'Qty').
'</td>';
 
   77  if ($filtertype != 1) {
 
   79      print 
'<td class="linecoluseunit left">';
 
   80      print 
'<span id="title_units">';
 
   81      print $langs->trans(
'Unit');
 
   84    print 
'<td class="linecolqtyfrozen right">' . $form->textwithpicto($langs->trans(
'QtyFrozen'), $langs->trans(
"QuantityConsumedInvariable")) . 
'</td>';
 
   85    print 
'<td class="linecoldisablestockchange right">' . $form->textwithpicto($langs->trans(
'DisableStockChange'), $langs->trans(
'DisableStockChangeHelp')) . 
'</td>';
 
   86    print 
'<td class="linecollost right">' . $form->textwithpicto($langs->trans(
'ManufacturingEfficiency'), $langs->trans(
'ValueOfMeansLoss')) . 
'</td>';
 
   88    print 
'<td class="linecolunit right">' . $form->textwithpicto($langs->trans(
'Unit'), 
'').
'</td>';
 
   89    if (isModEnabled(
'workstation')) {
 
   90      print 
'<td class="linecolworkstation right">' .  $form->textwithpicto($langs->trans(
'Workstation'), 
'') . 
'</td>';
 
   92    print 
'<td class="linecoltotalcost right">' .  $form->textwithpicto($langs->trans(
'TotalCost'), 
'') . 
'</td>';
 
   95  print 
'<td class="linecoledit" colspan="' . $colspan . 
'"> </td>';
 
   98print 
'<tr class="pair nodrag nodrop nohoverpair'.(($nolinesbefore || $object->element == 
'contrat') ? 
'' : 
' liste_titre_create').
'">';
 
  104  echo 
'<td class="bordertop nobottom linecolnum center"></td>';
 
  108print 
'<td class="bordertop nobottom linecoldescription minwidth500imp">';
 
  111if (isModEnabled(
"product") || isModEnabled(
"service")) {
 
  112  if ($filtertype == 1) {
 
  113    print $langs->trans(
"Service");
 
  115    print $langs->trans(
"Product");
 
  117  echo 
'<span class="prod_entry_mode_predef">';
 
  121    print $form->select_produits(
GETPOST(
'idprod', 
'int'), (($filtertype == 1) ? 
'idprodservice' : 
'idprod'), $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, 
'', 1, array(), $buyer->id, 
'1', 0, 
'maxwidth500', 0, 
'warehouseopen,warehouseinternal', 
GETPOST(
'combinations', 
'array'), 1);
 
  123    print $form->select_produits(
GETPOST(
'idprod', 
'int'), (($filtertype == 1) ? 
'idprodservice' : 
'idprod'), $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, 
'', 1, array(), $buyer->id, 
'1', 0, 
'maxwidth500', 0, 
'', 
GETPOST(
'combinations', 
'array'), 1);
 
  125  $urltocreateproduct = DOL_URL_ROOT.
'/product/card.php?action=create&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?id='.$object->id);
 
  126  print 
'<a href="'.$urltocreateproduct.
'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddProduct").
'"></span></a>';
 
  131  print 
'<br><span class="opacitymedium">'.$langs->trans(
"or").
'</span><br>'.$langs->trans(
"BOM");
 
  132  print $form->select_bom(
'', 
'bom_id', 0, 1, 0, 
'1', 
'', 1);
 
  135if (is_object($objectline)) {
 
  136  $temps = $objectline->showOptionals($extrafields, 
'create', array(), 
'', 
'', 1, 
'line');
 
  138  if (!empty($temps)) {
 
  139    print 
'<div style="padding-top: 10px" id="extrafield_lines_area_create" name="extrafield_lines_area_create">';
 
  149print 
'<td class="bordertop nobottom linecolqty right"><input type="text" size="2" name="qty" id="qty" class="flat right" value="'.(GETPOSTISSET(
"qty") ? 
GETPOST(
"qty", 
'alpha', 2) : 1).
'">';
 
  152if ($filtertype != 1) {
 
  155    print 
'<td class="nobottom linecoluseunit left">';
 
  160  print 
'<td class="bordertop nobottom linecolqtyfrozen right"><input type="checkbox" name="qty_frozen" id="qty_frozen" class="flat right" value="1"' . (
GETPOST(
"qty_frozen", 
'alpha') ? 
' checked="checked"' : 
'') . 
'>';
 
  165  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"' : 
'') . 
'">';
 
  169  print 
'<td class="bordertop nobottom nowrap linecollost right">';
 
  170  print 
'<input type="text" size="2" name="efficiency" id="efficiency" class="flat right" value="' . ((GETPOSTISSET(
"efficiency") && $action == 
'addline') ? 
GETPOST(
"efficiency", 
'alpha') : 1) . 
'">';
 
  174  print 
'<td class="bordertop nobottom nowrap linecolcost right">';
 
  179  require_once DOL_DOCUMENT_ROOT.
'/core/class/cunits.class.php';
 
  180  $cUnit = 
new CUnits($this->db);
 
  181  $fk_unit_default = $cUnit->getUnitFromCode(
'h', 
'short_label', 
'time');
 
  182  print 
'<td class="bordertop nobottom nowrap linecolunit right">';
 
  183  print  $formproduct->selectMeasuringUnits(
"fk_unit", 
"time", $fk_unit_default, 0, 0);
 
  187  print 
'<td class="bordertop nobottom nowrap linecolworkstation right">';
 
  188  print $formproduct->selectWorkstations(
'', 
'idworkstations', 1);
 
  192  print 
'<td class="bordertop nobottom nowrap linecolcost right">';
 
  197  $coldisplay += $colspan;
 
  198  print 
'<td class="bordertop nobottom linecoledit center valignmiddle" colspan="' . $colspan . 
'">';
 
  199  print 
'<input type="submit" class="button button-add" name="addline" id="addline" value="' . $langs->trans(
'Add') . 
'">';
 
  208jQuery(document).ready(
function() {
 
  210  $(
"#idprod").change(
function()
 
  212    console.log(
"#idprod change triggered");
 
  215      if (jQuery(
'#idprod').val() > 0)
 
  218      jQuery(
'#dp_desc').focus();
 
  220      if (typeof CKEDITOR == 
"object" && typeof CKEDITOR.instances != 
"undefined")
 
  222        var editor = CKEDITOR.instances[
'dp_desc'];
 
  223           if (editor) { editor.focus(); }
 
  229  <?php 
if ($filtertype == 1) { ?>
 
  230  $(
'#idprodservice').change(
function(){
 
  231    var idproduct = $(
this).val();
 
  234        url : 
"<?php echo dol_buildpath('/bom/ajax/ajax.php', 1); ?>" 
  237          'action': 
'getDurationUnitByProduct' 
  238          ,
'token' : 
"<?php echo newToken() ?>" 
  239          ,
'idproduct' : idproduct
 
  241      }).done(
function(data) {
 
  244        $(
"#fk_unit").val(data).change();
 
  248        url : 
"<?php echo dol_buildpath('/bom/ajax/ajax.php', 1); ?>" 
  251          'action': 
'getWorkstationByProduct' 
  252          ,
'token' :  
"<?php echo newToken() ?>" 
  253          ,
'idproduct' : idproduct
 
  255      }).done(
function(data) {
 
  256        $(
'#idworkstations').val(data.defaultWk).select2();
 
  265<!-- END PHP TEMPLATE objectline_create.tpl.php -->
 
Class of dictionary type of thirdparty (used by imports)
 
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
 
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
 
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
 
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type