Hello,
I wrote some time ago an handy feature that add a little button on any dolibarr table (list of customers, list of invoices, etc.). When you click on it, it copy the table content to clipboard. Then you can paste it to Excel.
The file modified is :
htdocs\core\class\html.form.class.php
And the function ![]()
public function showFilterButtons($pos = '')
{
$out = '<div class="nowraponall">';
$out .= '<a class="liste_titre button_copycb" style="cursor: pointer"><span class="fa fa-copy"></span></a>';
if ($pos == 'left') {
$out .= '<button type="submit" class="liste_titre button_search reposition" name="button_search_x" value="x"><span class="fas fa-search"></span></button>';
$out .= '<button type="submit" class="liste_titre button_removefilter reposition" name="button_removefilter_x" value="x"><span class="fas fa-times"></span></button>';
} else {
$out .= '<button type="submit" class="liste_titre button_search reposition" name="button_search_x" value="x"><span class="fas fa-search"></span></button>';
$out .= '<button type="submit" class="liste_titre button_removefilter reposition" name="button_removefilter_x" value="x"><span class="fas fa-times"></span></button>';
}
$out .= '</div>';
$out .= '<script>
$(document).ready(function() {
$(".button_copycb").click(function() {
var TableContent = $(this).closest("table").clone();
TableContent.find("a[href^=mailto]").each(function() {
$(this).html($(this).attr("href").substr(7));
});
TableContent.find("a").contents().unwrap();
TableContent.find("tr.liste_titre_filter").remove();
TableContent.find("input").remove();
TableContent.find("script").remove();
TableContent.find("img").remove();
TableContent.find(".dropdown").remove();
navigator.clipboard.writeText(TableContent[0].outerHTML).then(function() {
console.log("Copied to clipboard successfully!");
}, function() {
console.error("Unable to write to clipboard. :-(");
});
});
});
</script>';
return $out;
}




