mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-12-06 02:59:29 +00:00
Add export functionality to batch select and fix errors
This commit is contained in:
parent
facfb37383
commit
1fb137e89f
5 changed files with 10 additions and 5 deletions
|
|
@ -92,7 +92,7 @@ class EntityExporter
|
|||
$options = $resolver->resolve($options);
|
||||
|
||||
//Handle Excel formats by converting from CSV
|
||||
if (in_array($options['format'], ['xlsx', 'xls'])) {
|
||||
if (in_array($options['format'], ['xlsx', 'xls'], true)) {
|
||||
return $this->exportToExcel($entities, $options);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -346,7 +346,7 @@ class EntityImporter
|
|||
$this->configureOptions($resolver);
|
||||
$options = $resolver->resolve($options);
|
||||
|
||||
if (in_array($options['format'], ['xlsx', 'xls'])) {
|
||||
if (in_array($options['format'], ['xlsx', 'xls'], true)) {
|
||||
$this->logger->info('Converting Excel file to CSV', [
|
||||
'filename' => $file->getFilename(),
|
||||
'format' => $options['format'],
|
||||
|
|
|
|||
|
|
@ -30,13 +30,11 @@ use App\Entity\Parts\Manufacturer;
|
|||
use App\Entity\Parts\MeasurementUnit;
|
||||
use App\Entity\Parts\Part;
|
||||
use App\Entity\Parts\PartLot;
|
||||
use App\Repository\PartRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use InvalidArgumentException;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
use Symfony\Contracts\Translation\TranslatableInterface;
|
||||
|
||||
use function Symfony\Component\Translation\t;
|
||||
|
||||
|
|
@ -100,7 +98,7 @@ implode(',', array_map(static fn (PartLot $lot) => $lot->getID(), $part->getPart
|
|||
|
||||
//When action starts with "export_" we have to redirect to the export controller
|
||||
$matches = [];
|
||||
if (preg_match('/^export_(json|yaml|xml|csv)$/', $action, $matches)) {
|
||||
if (preg_match('/^export_(json|yaml|xml|csv|xlsx)$/', $action, $matches)) {
|
||||
$ids = implode(',', array_map(static fn (Part $part) => $part->getID(), $selected_parts));
|
||||
$level = match ($target_id) {
|
||||
2 => 'extended',
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@
|
|||
<option {% if not is_granted('@parts.read') %}disabled{% endif %} value="export_csv" data-url="{{ path('select_export_level')}}" data-turbo="false">{% trans %}part_list.action.export_csv{% endtrans %}</option>
|
||||
<option {% if not is_granted('@parts.read') %}disabled{% endif %} value="export_yaml" data-url="{{ path('select_export_level')}}" data-turbo="false">{% trans %}part_list.action.export_yaml{% endtrans %}</option>
|
||||
<option {% if not is_granted('@parts.read') %}disabled{% endif %} value="export_xml" data-url="{{ path('select_export_level')}}" data-turbo="false">{% trans %}part_list.action.export_xml{% endtrans %}</option>
|
||||
<option {% if not is_granted('@parts.read') %}disabled{% endif %} value="export_xlsx" data-url="{{ path('select_export_level')}}" data-turbo="false">{% trans %}part_list.action.export_xlsx{% endtrans %}</option>
|
||||
</optgroup>
|
||||
</select>
|
||||
|
||||
|
|
|
|||
|
|
@ -10906,6 +10906,12 @@ Element 1 -> Element 1.2]]></target>
|
|||
<target>Export to XML</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="xLSXExport" name="part_list.action.export_xlsx">
|
||||
<segment state="translated">
|
||||
<source>part_list.action.export_xlsx</source>
|
||||
<target>Export to Excel</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="w0AgPEI" name="parts.import.title">
|
||||
<segment state="translated">
|
||||
<source>parts.import.title</source>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue