Merge pull request #16034 from Hystepik/develop#2

Close #16027 New Feature copy Code Client
This commit is contained in:
Laurent Destailleur 2021-01-28 11:17:10 +01:00 committed by GitHub
commit 4fbf2fff6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 3 deletions

View File

@ -210,3 +210,25 @@ print '
}
});
});'."\n";
print "\n/* JS CODE TO ENABLE ClipBoard copy paste*/\n";
print 'jQuery(\'.clipboardCopyPaste\').click(function() {
console.log(this.firstChild.innerText);
if ( window.getSelection ) {
selection = window.getSelection();
range = document.createRange();
range.selectNodeContents( this.firstChild );
selection.removeAllRanges();
selection.addRange( range );
}
document.execCommand( \'copy\' );
window.getSelection().removeAllRanges();
var lastchild = this.lastChild
var tmp =lastchild.innerHTML
lastchild.innerHTML = \''.dol_escape_js($langs->trans('CopiedToClipboard')).'\';
setTimeout(() => { lastchild.innerHTML = tmp; }, 1000);
})'."\n";

View File

@ -9239,3 +9239,14 @@ function readfileLowMemory($fullpath_original_file_osencoded, $method = -1)
fclose($handle2);
}
}
/**
* Create a button to copy $valuetoprint in the clipboard
* @param string $valuetoprint the value to print
* @return string the string to print for the button
*/
function showValueWithCopyAndPasteButton($valuetoprint)
{
$result = '<span class="clipboardCopyPaste"><span>'.$valuetoprint.'</span>&ensp;<span class="far fa-clipboard opacitymedium"></span></span>';
return $result;
}

View File

@ -467,3 +467,4 @@ RestOfEurope=Rest of Europe (EEC)
OutOfEurope=Out of Europe (EEC)
CurrentOutstandingBillLate=Current outstanding bill late
BecarefullChangeThirdpartyBeforeAddProductToInvoice=Be carefull, depending on your product price settings, you should change thirdparty before adding product to POS.
CopiedToClipboard = Copied to clipboard

View File

@ -2423,8 +2423,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
if ($object->client)
{
print '<tr><td>';
print $langs->trans('CustomerCode').'</td><td>';
print $object->code_client;
print $langs->trans('CustomerCode');
print '</td>';
print '<td>';
print showValueWithCopyAndPasteButton($object->code_client);
print '</td>';
$tmpcheck = $object->check_codeclient();
if ($tmpcheck != 0 && $tmpcheck != -5) {
print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
@ -2935,7 +2938,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
}
}
// End of page
llxFooter();
$db->close();