Commit 96045ac4 authored by Ana Rute Mendes's avatar Ana Rute Mendes 🌈
Browse files

LOCAL: Maniphest: trigger Shipping Req. autofill

If a Shipping Request is edited and it has the asset id field
filled, trigger the method that will fetch the data from Snipe-IT
and fill the item details in the task.
parent d3859c16
...@@ -366,6 +366,7 @@ final class ManiphestTransactionEditor ...@@ -366,6 +366,7 @@ final class ManiphestTransactionEditor
array $xactions) { array $xactions) {
$this->setContinueOnNoEffect(true); $this->setContinueOnNoEffect(true);
$snipe_api = new SnipeItHelper();
$actor = $this->getActor(); $actor = $this->getActor();
$actor_phid = $actor->getPHID(); $actor_phid = $actor->getPHID();
...@@ -396,7 +397,6 @@ final class ManiphestTransactionEditor ...@@ -396,7 +397,6 @@ final class ManiphestTransactionEditor
// CCU: create Item in the inventory system if it's a Purchase request and // CCU: create Item in the inventory system if it's a Purchase request and
// its status was changed to "to release" // its status was changed to "to release"
if (!$this->getIsNewObject()) { if (!$this->getIsNewObject()) {
$snipe_api = new SnipeItHelper();
$asset_id = $snipe_api->createAssetItem($new_status, $object, $xactions); $asset_id = $snipe_api->createAssetItem($new_status, $object, $xactions);
} }
break; break;
...@@ -598,6 +598,15 @@ final class ManiphestTransactionEditor ...@@ -598,6 +598,15 @@ final class ManiphestTransactionEditor
->setNewValue($asset_id); ->setNewValue($asset_id);
} }
// CCU: if it's a Shipping Request, check if it has an asset item
// in Snipe-IT and automatically fill in some fields.
if ($subtype == 'shipping') {
$transactions = $snipe_api->fetchAssetItem($object, $xactions);
foreach ($transactions as $transaction) {
$results[] = $transaction;
}
}
return $results; return $results;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment