--- /home/innovationhub/inventory.innovation-hub.co.za/bitrix_embed.php 2026-11-19 21:29:13.725101727 +0200
+++ /tmp/bitrix_embed.merged.php 2026-11-21 17:50:53.943513127 +0200
@@ -55,4 +55,5 @@
require_once dirname(__DIR__).'/private/inventory_app/InventoryAccess.php';
require_once dirname(__DIR__).'/private/inventory_app/InventoryVoid.php';
+require_once dirname(__DIR__).'/private/inventory_app/ReceivedByCustomer.php';
/** Pilot-scoped PBX history. A disabled flag or unrelated asset uses the existing path. */
@@ -315,4 +316,9 @@
}while(true);
$rows=InventoryVoid::filterRows($db,$rows);
+ // One customer lookup per rendered list; movement and PBX history are then read in batches.
+ $customerName='';
+ try{$co=api('crm.company.get',['id'=>$company],(string)$_SESSION['ihg_embed_auth'])['result']??[];$customerName=(string)($co['TITLE']??'');}catch(Throwable $ignored){}
+ $rows=ReceivedByCustomer::annotate($db,$rows,$company,$customerName);
+ if((string)($_GET['sort']??'')==='received')$rows=ReceivedByCustomer::sort($rows,(string)($_GET['dir']??'asc'));
}elseif($search!==''){$rows=InventoryVoid::filterRows($db,equipmentSearch($db,$search));}
@@ -356,4 +362,18 @@
}unset($row);
}
+ if($view==='search'){
+ $rows=ReceivedByCustomer::annotateSearch($db,$rows);
+ foreach($rows as &$row){
+ $liveLocation=trim((string)($row['location_label']??''));
+ if(preg_match('/^Client:\s*(.*)$/i',$liveLocation,$liveCustomer)){
+ $localCustomer=trim((string)($row['_received_by_customer_customer']??''));
+ if($localCustomer===''||mb_strtolower($localCustomer)!==mb_strtolower(trim($liveCustomer[1])))$row['received_by_customer']='Not recorded';
+ }elseif(preg_match('/^IHG (?:New Stock|Second-Hand Stock|Recovered - Hold)/i',$liveLocation)){
+ $row['received_by_customer']='—';
+ }else{$row['received_by_customer']='Not recorded';}
+ unset($row['_received_by_customer_customer']);
+ }unset($row);
+ if((string)($_GET['sort']??'')==='received')$rows=ReceivedByCustomer::sort($rows,(string)($_GET['dir']??'asc'));
+ }
}
// Receipt invoice references are resolved by local asset ID, never serial (duplicates are supported).
@@ -456,5 +476,5 @@
This hides the equipment in Inventory Manager and blocks movements. It does not delete the Bitrix record. History is retained.Void incorrect equipment entry (admin only)
=esc($warning)?>
| Date/time | Action | From | To | Source | Reference | Reason/notes |
|---|---|---|---|---|---|---|
| =esc($e['when'])?> | =esc($e['type'])?> | =esc($e['from'])?> | =esc($e['to'])?> | =esc($e['source'])?> | =esc($e['ref'])?> | =esc($e['notes'])?> |
| No recorded events | ||||||