mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-11 19:04:31 +02:00
Add supplier information to KiCad part exports (#955)
* Add supplier information to KiCad part exports - Include supplier name and part numbers from order details in KiCad exports - Handle multiple suppliers with sequential numbering (Supplier 2, Supplier 3, etc.) - Include both active and obsolete order details for comprehensive supplier info - Add null checks to prevent errors when supplier or part number is missing * Add SPN suffix to field name --------- Co-authored-by: Jan Böhmer <mail@jan-boehmer.de>
This commit is contained in:
parent
442a7aa235
commit
beea572c47
1 changed files with 24 additions and 0 deletions
|
@ -237,6 +237,30 @@ class KiCadHelper
|
||||||
$result["fields"]["Part-DB IPN"] = $this->createField($part->getIpn());
|
$result["fields"]["Part-DB IPN"] = $this->createField($part->getIpn());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add supplier information from orderdetails (include obsolete orderdetails)
|
||||||
|
if ($part->getOrderdetails(false)->count() > 0) {
|
||||||
|
$supplierCounts = [];
|
||||||
|
|
||||||
|
foreach ($part->getOrderdetails(false) as $orderdetail) {
|
||||||
|
if ($orderdetail->getSupplier() !== null && $orderdetail->getSupplierPartNr() !== '') {
|
||||||
|
$supplierName = $orderdetail->getSupplier()->getName();
|
||||||
|
|
||||||
|
$supplierName .= " SPN"; // Append "SPN" to the supplier name to indicate Supplier Part Number
|
||||||
|
|
||||||
|
if (!isset($supplierCounts[$supplierName])) {
|
||||||
|
$supplierCounts[$supplierName] = 0;
|
||||||
|
}
|
||||||
|
$supplierCounts[$supplierName]++;
|
||||||
|
|
||||||
|
// Create field name with sequential number if more than one from same supplier (e.g. "Mouser", "Mouser 2", etc.)
|
||||||
|
$fieldName = $supplierCounts[$supplierName] > 1
|
||||||
|
? $supplierName . ' ' . $supplierCounts[$supplierName]
|
||||||
|
: $supplierName;
|
||||||
|
|
||||||
|
$result["fields"][$fieldName] = $this->createField($orderdetail->getSupplierPartNr());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue