These are chat archives for TijdschriftVoorGeneeskunde/TijdschriftVoorGeneeskunde

13th
Jun 2015
titmastercrunch
@titmastercrunch
Jun 13 2015 02:20

'''php
public function newSubscriptionAction(Request $request, $userid){

    $em = $this->getDoctrine()->getManager();
    $newsubscriber = false;

    $user = $em->getRepository('AppBundle:User')->findOneBy(array('id' => $userid));
    if(!$user->getSubscriber()){
        $user->setSubscriber(new Subscriber());
        $newsubscriber = true;
    }

    $subscriber = $user->getSubscriber();

    $subscriberform = $this->createForm(new SubscriberFormType(), $subscriber);
    $subscriberform->handleRequest($request);

    if ($subscriberform->isValid())
    {     
        $date = new \DateTime();
        $expire = new \DateTime();
        $promo = $request->get('SubscriberForm')['promoCode'];

        if($em->getRepository('AppBundle:Promo')->findOneBy(array('_code' => $promo))){
            $subscriber->setPricingType('FR');
            $expire->add(new \DateInterval('P3M'));
        }
        else{
            $expire->add(new \DateInterval('P1Y'));
        } 

        //create a new subscription with
        $subscription = new Subscription($date, $expire);
        $subscriber->addSubscription($subscription);
        $subscription->setSubscriber($subscriber);
        $user->setSubscriber($subscriber);
        $subscriber->setUser($user);

        $em->persist($subscription);
        if($newsubscriber){

            $em->persist($subscriber->getDeliveryAddress());
            $em->persist($subscriber->getFacturationAddress());
            $em->persist($subscriber);
        }

        $em->flush();
        $this->addFlash(
            'notice', $this->get('translator')->trans('Subscription added')
        );
        return $this->render('FOSUserBundle::Profile/show.html.twig', array(
            'user' => $user,
        ));
    }

    return $this->render('subscription/new.html.twig', array(
        'form' => $subscriberform->createView(),
        'newsubscriber' => $newsubscriber,
        'userid' => $userid,
    ));
}

code
'''

wauw die doet da auto
This message was deleted
This message was deleted
->add('promoCode', 'text', array(
'required' => false,
'label' => 'Promo code',
'mapped' => false,
))
en dees toegevoegd aan subscriberform

An exception occurred while executing 'INSERT INTO subscription (id, startDate, endDate, isPaid, pricingtype, subscriber_id) VALUES (?, ?, ?, ?, ?, ?)' with params [52, "2015-06-13 04:15:58", "2015-09-13 04:15:58", 0, null, 52]:

SQLSTATE[23502]: Not null violation: 7 ERROR: null value in column "pricingtype" violates not-null constraint
DETAIL: Failing row contains (52, 52, 2015-06-13 04:15:58, 2015-09-13 04:15:58, f, null).

titmastercrunch
@titmastercrunch
Jun 13 2015 02:42

class SubscriberFormType extends AbstractType{

public function buildForm(FormBuilderInterface $builder, array $options){
    $builder
        ->add('school', 'text', array('required' => false))
        ->add('pricingtype', 'choice', [
            'choices' => PaymentType::getChoices()
        ])
        ->add('graduation', 'collot_datetime',
            array(
                'required' => false,
                'pickerOptions' => array(
                    'format' => 'dd/mm/yyyy',
                    'minView' => 'month',
        )))
        ->add('wantsBill', 'checkbox',
            array(
                'required' => false,
            )
        )
        ->add('deliveryaddress', new AddressFormType())
        ->add('facturationaddress', new AddressFormType())
        ->add('sameaddress', 'checkbox', array(
                   'label' => 'Delivery address and facturation address are the same',
                'mapped' => false,

                'data' => true,
                'required' => false,

            ))
        ->add('vatNumber', 'text', array('required' => false))
        /*->add('paperversion', 'checkbox', array(
                'label'    => 'I want to receive a paper version',
                'required' => false,

            ))*/

        ->add('promoCode', 'text', array(
                'required' => false,
                'label' => 'Promo code',
                'mapped' => false,
            ))
        ->add('save', 'submit');


}

public function setDefaultOptions(OptionsResolverInterface $resolver)
{
    $resolver->setDefaults(array(
        'data_class' => 'AppBundle\Entity\Subscriber',
    ));
}

public function getName(){
    return 'SubscriberForm';
}

}

Numkil
@Numkil
Jun 13 2015 07:32
Ok wa gaam we nog allemaal doen vandaag en waar spreken we af morgen voor verslag en presentatie???
titmastercrunch
@titmastercrunch
Jun 13 2015 16:55
kwas ant denke om nog breadcrumbs te adde
ma uiteindelijk is de website redelijik straigh forward
dus kweeni of da nodig is
hoeveel mense gebruike da uiteindelijk xD
:shipit: