public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $this->factory = $builder->getFormFactory();
     if ($billingSpec = $this->user->getAppointedBillingSpec()) {
         $fees = $billingSpec->getFees();
     } else {
         $fees = new ArrayCollection();
     }
     if (!$fees->count()) {
         $fee = new Fee();
         $fees[] = $fee;
     }
     $builder->add('fees', 'collection', array('type' => new FeeFormType($this->user), 'allow_add' => true, 'allow_delete' => true, 'prototype' => true, 'prototype_name' => '__name__', 'by_reference' => false, 'property_path' => false, 'data' => $fees))->add('minimum_billing_fee', 'number', array('precision' => 2, 'grouping' => true, 'required' => false));
     $builder->addEventListener(FormEvents::BIND, array($this, 'onBind'));
 }
Exemple #2
0
 /**
  * Reset Ria fee for License Fee Relationship
  *
  * @param User $ria
  */
 public function resetRiaFee(User $ria)
 {
     $appointedBillingSpec = $ria->getAppointedBillingSpec();
     if ($appointedBillingSpec) {
         if (1 === $appointedBillingSpec->getAppointedUsers()->count()) {
             $this->billingSpecManager->remove($appointedBillingSpec);
         } else {
             $appointedBillingSpec->removeAppointedUser($ria);
             $this->em->persist($appointedBillingSpec);
             $this->em->flush();
         }
     }
     $billingSpec = $this->billingSpecManager->initDefaultAdminSpec($ria);
     $ria->setAppointedBillingSpec($billingSpec);
     $fee = $this->initDefaultAdminLicenseFee();
     $billingSpec->addFee($fee);
     $this->em->persist($billingSpec);
     $this->em->persist($ria);
     $this->em->flush();
 }