<?php
 if ($R['addCorporateId']) { $OK = true; $idCorporate = $R['addCorporateId']; $corp = \Entity\Corporate::select($idCorporate); if (!$corp->recordExists()) { $OK = false; $showMessage['warning'] = $_LANG['orderForm']['clientsList']['addCorporate']['noId']; } if ($OK and $corp->idRealCorporate) { $idCorporate = $corp->idRealCorporate; } if ($OK) { $orderFormHandler->addCorporate($idCorporate); $orderFormHandler->storeChanges(); $updateOwnerDetails=true; $showMessage['success'] = $_LANG['orderForm']['clientsList']['addCorporate']['addCorpOk']; } } if ($R['setOwnerCorporateId']) { $OK = true; $idCorporate = $R['setOwnerCorporateId']; $corp = \Entity\Corporate::select($idCorporate); if (!$corp->recordExists()) { $OK = false; $showMessage['warning'] = $_LANG['orderForm']['clientsList']['setCorpOwner']['noId']; } if ($OK) { if ( $idCorporate==$orderFormHandler->getOrder()->getField('idCorporateOwner') ) { $orderFormHandler->setIdCorporateOwner(0); } else { $orderFormHandler->setIdCorporateOwner($idCorporate); } $orderFormHandler->storeChanges(); $showMessage['success'] = $_LANG['orderForm']['clientsList']['setCorpOwner']['setOk']; $updateOwnerDetails=true; } } if ($R['deleteCorporateId']) { $OK = true; $idCorporate = $R['deleteCorporateId']; $corp = \Entity\Corporate::select($idCorporate); if (!$corp->recordExists()) { $OK = false; $showMessage['warning'] = $_LANG['orderForm']['clientsList']['delCorporate']['noId']; } if ($OK) { $orderFormHandler->removeCorporate($R['deleteCorporateId']); $orderFormHandler->storeChanges(); $showMessage['success'] = $_LANG['orderForm']['clientsList']['delCorporate']['ok']; $updateOwnerDetails=true; } } if ($section=="corporates") { $corporatesList= []; foreach($orderFormHandler->getCorporates() as $idCorp) { $corporatesList[] = \Entity\Corporate::select($idCorp); } if (!$corporatesList and !$R['addCorporateId']) { $showMessage['info'] = $_LANG['orderForm']['clientsList']['listCorporate']['noResults']; } } 