/**
  * Sets reseller to customer from form
  *
  * @param IXP_Form_Customer $form The Send form object
  * @param \Entities\Customer $object The Doctrine2 entity (being edited or blank for add)
  * @return bool If false, the form is not processed
  */
 private function _setReseller($form, $object)
 {
     if (!$this->resellerMode()) {
         return true;
     }
     if ($form->getValue('isResold')) {
         $reseller = $this->getD2R("\\Entities\\Customer")->find($form->getValue("reseller"));
         if (!$reseller) {
             $form->getElement("resller")->setErrorMessages(['Select Reseller'])->markAsError();
             return false;
         }
         if ($object->getReseller() && $object->getReseller()->getId() != $form->getValue('reseller')) {
             foreach ($object->getVirtualInterfaces() as $viInt) {
                 foreach ($viInt->getPhysicalInterfaces() as $phInt) {
                     if ($phInt->getFanoutPhysicalInterface() && $phInt->getFanoutPhysicalInterface()->getVirtualInterface()->getCustomer()->getId() == $object->getReseller()->getId()) {
                         $form->getElement('isResold')->setErrorMessages([''])->markAsError();
                         $this->addMessage('You can not change the reseller because there are still fanout ports from the current reseller linked to this customer\'s physical interfaces. You need to reassign these first.', OSS_Message::INFO);
                         return false;
                     }
                 }
             }
         }
         $object->setReseller($reseller);
     } else {
         if ($object->getReseller()) {
             foreach ($object->getVirtualInterfaces() as $viInt) {
                 foreach ($viInt->getPhysicalInterfaces() as $phInt) {
                     if ($phInt->getFanoutPhysicalInterface() && $phInt->getFanoutPhysicalInterface()->getVirtualInterface()->getCustomer()->getId() == $object->getReseller()->getId()) {
                         $form->getElement('isResold')->setValue(1);
                         $form->getElement('isResold')->setErrorMessages([''])->markAsError();
                         $this->addMessage('You can not change this resold customer state because there are still physical interface(s) of this customer linked to fanout ports or the current reseller. You need to reassign these first.', OSS_Message::INFO);
                         return false;
                     }
                 }
             }
             $object->setReseller(null);
         }
     }
     if (!$form->getValue('isReseller') && $object->getIsReseller() && count($object->getResoldCustomers())) {
         $form->getElement('isReseller')->setErrorMessages([''])->markAsError();
         $this->addMessage('You can not change the reseller state because this customer still has resold customers. You need to reassign these first.', OSS_Message::INFO);
         return false;
     }
     return true;
 }
 public function getReseller()
 {
     $this->__load();
     return parent::getReseller();
 }