Clean code

This commit is contained in:
Laurent Destailleur 2021-05-12 09:07:36 +02:00
parent dd00feae00
commit b8254186ce
2 changed files with 49 additions and 29 deletions

View File

@ -56,6 +56,52 @@ class FormOther
$this->db = $db;
}
/**
* Return HTML code for scanner tool
*
* @param string $jstoexecuteonadd Name of javascript function to call
* @return string HTML component
*/
public function getHTMLScannerForm($jstoexecuteonadd = 'barcodscannerjs')
{
global $langs;
$out = '';
$out .= '<form name="barcodescanner" method="POST">';
$out .= '<!-- Popup for mass barcode scanning -->'."\n";
$out .= '<div class="div-for-modal-topright" style="padding: 15px">';
$out .= '<center><strong>Barcode scanner tool...</strong></center><br>';
$out .= '<input type="checkbox" name="barcodeforautodetect" checked="checked"> Autodetect if we scan a product barcode or a lot/serial barcode<br>';
$out .= '<input type="checkbox" name="barcodeforproduct"> Scan a product barcode<br>';
$out .= '<input type="checkbox" name="barcodeforlotserial"> Scan a product lot or serial number<br>';
$out .= $langs->trans("QtyToAddAfterBarcodeScan").' <input type="text" name="barcodeproductqty" class="width50 right" value="1"><br>';
$out .= '<textarea type="text" name="barcodelist" class="centpercent" autofocus rows="'.ROWS_3.'"></textarea>';
/*print '<br>'.$langs->trans("or").'<br>';
print '<br>';
print '<input type="text" name="barcodelotserial" class="width200"> &nbsp; &nbsp; Qty <input type="text" name="barcodelotserialqty" class="width50 right" value="1"><br>';
*/
$out .= '<br>';
$out .= '<center>';
$out .= '<input type="submit" class="button paddingleftonly paddingrightonly" name="addscan" value="'.$langs->trans("Add").'">';
$out .= '<input type="submit" class="button paddingleftonly paddingrightonly" name="cancel" value="'.$langs->trans("Cancel").'">';
$out .= '<br>';
$out .= '<span class="opacitymedium">'.$langs->trans("FeatureNotYetAvailable").'</span>';
// TODO Add call of javascript $jstoexecuteonadd so each scan will add qty into the inventory page + an ajax save.
$out .= '</center>';
$out .= '</div>';
$out .= '</form>';
return $out;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**

View File

@ -524,35 +524,9 @@ if ($object->id > 0) {
// Popup for mass barcode scanning
if ($action == 'updatebyscaning') {
print '<form name="barcodescanner" method="POST">';
print '<!-- Popup for mass barcode scanning -->'."\n";
print '<div class="div-for-modal-topright" style="padding: 15px">';
print '<center><strong>Barcode scanner tool...</strong></center><br>';
print '<input type="checkbox" name="barcodeforautodetect" checked="checked"> Autodetect if we scan a product barcode or a lot/serial barcode<br>';
print '<input type="checkbox" name="barcodeforproduct"> Scan a product barcode<br>';
print '<input type="checkbox" name="barcodeforlotserial"> Scan a product lot or serial number<br>';
print $langs->trans("QtyToAddAfterBarcodeScan").' <input type="text" name="barcodeproductqty" class="width50 right" value="1"><br>';
print '<textarea type="text" name="barcodelist" class="centpercent" autofocus rows="'.ROWS_3.'"></textarea>';
/*print '<br>'.$langs->trans("or").'<br>';
print '<br>';
print '<input type="text" name="barcodelotserial" class="width200"> &nbsp; &nbsp; Qty <input type="text" name="barcodelotserialqty" class="width50 right" value="1"><br>';
*/
print '<br>';
print '<center>';
print '<input type="submit" class="button" value="'.$langs->trans("Add").'"><br>';
print '<span class="opacitymedium">'.$langs->trans("FeatureNotYetAvailable").'</span>';
// TODO Add javascript so each scan will add qty into the inventory page + an ajax save.
print '</center>';
print '</div>';
print '</form>';
include DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
$formother = new FormOther($db);
print $formother->getHTMLScannerForm();
}