Пример #1
0
 /**
  * @Route("/testdb",name="database")
  */
 public function test()
 {
     $member = new Entity\Member();
     $member->setMobile("07129832");
     $member->setRegisterDate("12/12/2012");
     $member->setEmail("*****@*****.**");
     $member->setFirstName("Nuwan");
     $member->setLastName("Rathnayaka");
     $member->setStudentId("123456F");
     $member->setDeptName("noone");
     $r = new Entity\Resource();
     $r->setResourceId("1");
     $r->setDescription("this  description");
     $r->setOfficerId("1234");
     $r->setValue("sdsds");
     $ra = new Entity\ResourceAllocation();
     $ra->setResourceId("1");
     $ra->setMemberId("123456F");
     $ra->setComments("Use enjoy it");
     $ra->setDueDate("2016-01-07");
     $ra->setIssuedDate("2015-12-34");
     $testdb = new Modal\DBAccess($r);
     $testdb->update();
     return new Response();
 }
Пример #2
0
 /**
  * @Route("/register/newresourcetype", name="new_esource_type_registration")
  */
 public function newresourcetypeAction(Request $request)
 {
     $resource = new NewResourceType();
     $formtitle = "New Resource Type";
     $form = $this->createFormBuilder($resource)->add('name', \Symfony\Component\Form\Extension\Core\Type\TextType::class, ['label' => 'Resource Name'])->add('o_id', ChoiceType::class, array('mapped' => true, 'choices' => $this->getOfficername(), 'label' => 'Officer Name'))->add('save', SubmitType::class, ['label' => 'Submit'])->getForm();
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         $db = new DBAccess($resource);
         $db->insert();
         return new RedirectResponse($this->generateUrl('new_esource_type_registration'), array('error_description' => 'you are successfully completed your action'));
     }
     return $this->render('default/index.html.twig', array('form' => $form->createView(), 'title' => $formtitle, 'table' => false, 'profile' => false));
 }
Пример #3
0
 private function getUser($username)
 {
     $db = new DBConnection();
     $link = $db->connect();
     $query = "SELECT * FROM app_user WHERE email ='{$username}'";
     $result = $link->query($query);
     $user = null;
     $member_id = 0;
     while ($row = mysqli_fetch_assoc($result)) {
         $user = new User($row['email'], $row['password'], "", unserialize($row['role']));
         $member_id = $row['id'];
     }
     $db->closeConnection();
     $member = new Member();
     $member->setStudentId($member_id);
     $da = new DBAccess($member);
     $user->setMember($da->getDetail());
     return $user;
 }
Пример #4
0
 /**
  * @Route("/register/event1", name="event_register1S")
  */
 public function eventAction(Request $request)
 {
     $event = new Event();
     $title = "New Event Registration";
     $form = $this->createForm(EventType::class, $event);
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         $date = explode('-', $event->getDaterange());
         $event->setStartdate(date('Y-m-d', strtotime($date[0])));
         $event->setEnddate(date('Y-m-d', strtotime($date[0])));
         $event->setStarttime($event->getStarttime()->getTimestamp());
         $event->setEndtime($event->getEndtime()->getTimestamp());
         var_dump($event);
         $db = new DBAccess($event);
         $db->insert();
         return new RedirectResponse($this->generateUrl('event_register1S'), array('error_description' => 'you are successfully completed your action'));
     }
     return $this->render('default/index.html.twig', array('form' => $form->createView(), 'title' => $title, 'table' => false, 'profile' => false));
 }
Пример #5
0
 /**
  * @Route("/register/member/{email}", name="student_nregistration")
  */
 public function newmemberAction(Request $request, $email)
 {
     $member = new Member();
     $member->setEmail($email);
     $title = "Student Registration";
     $date = date("Y-m-d");
     $member->setRegisterDate($date);
     $form = $this->createForm(MemberType::class, $member);
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         $db = new DBAccess($member);
         $id = $db->insert();
         if (!$id) {
             return $this->redirect($this->generateUrl('student_check', array('error_description' => 'Email is not available')));
         } else {
             return $this->redirect($this->generateUrl('student_check', array('error_description' => 'New member added with DI ' . $id)));
         }
     }
     return $this->render('default/index.html.twig', array('form' => $form->createView(), 'title' => $title, 'table' => false, 'profile' => false));
 }
Пример #6
0
 /**
  * @Route("/register", name="user_registration")
  */
 public function registerAction(Request $request)
 {
     // 1) build the form
     $user = $this->getUser();
     $form = $this->createForm(UserType::class, $user);
     // 2) handle the submit (will only happen on POST)
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         // 3) Encode the password (you could also do this via Doctrine listener)
         $password = $this->get('security.password_encoder')->encodePassword($user, $user->getPlainPassword());
         $user->setPassword($password);
         $db = new DBAccess($user);
         $db->resetPassword($password);
         // 4) save the User!
         // ... do any other work - like send them an email, etc
         // maybe set a "flash" success message for the user
         return $this->redirectToRoute('homepage');
     }
     return $this->render('registration/register.html.twig', array('form' => $form->createView(), 'table' => false, 'title' => "nuwan", 'profile' => false));
 }
 /**
  * @Route("/reserve/{slug}")
  * @Route("/reserve/sport", name="reserve_sport")
  * @Route("/reserve/other", name="reserve_other")
  *
  *
  */
 public function reserveSportAction(Request $request, $slug)
 {
     $task = new DynamicAllocation();
     $formtitle = " Resource  Reservation";
     if ($slug == 'sport') {
         $row = ResourceAccess::getResourceAvalability('SEQP');
     } else {
         $row = ResourceAccess::getResourceAvalability('OTHER');
     }
     $col = array_keys($row[0]);
     $form = $this->createFormBuilder($task)->add('type_id', ChoiceType::class, array('mapped' => true, 'choices' => $this->optionBuild("SEQP"), 'label' => 'Type'))->add('quntity', IntegerType::class, ['label' => 'Quntity'])->add('daterange', TextType::class, array('label' => 'Reservation period', 'attr' => array('class' => 'form-control pull-right', 'data-inputmask' => "'alias': 'yyyy-mm-dd'", 'data-mask')))->add('comments', TextType::class, ['label' => 'Comments'])->add('save', SubmitType::class, ['label' => 'Submit'])->getForm();
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         $result = $form->getData();
         $date = explode('-', $result->getDaterange());
         $task->setIssuedDate(date('Y-m-d', strtotime($date[0])));
         $task->setDueDate(date('Y-m-d', strtotime($date[0])));
         $task->setMemberId($this->getUser()->getMember()->getStudentId());
         $db = new DBAccess($task);
         $db->insert();
         return new RedirectResponse($this->generateUrl('reserve'), array('error_description' => 'you are successfully completed your action'));
     }
     return $this->render('default/index.html.twig', array('form' => $form->createView(), 'title' => $formtitle, 'table' => true, 'row' => $row, 'col' => $col, 'profile' => false));
 }
Пример #8
0
<?php

/**
* Created by PhpStorm.
// * User: bmCSoft
* Date: 2015-12-16
* Time: 4:57 PM
*/
namespace AppBundle\Modal;

use AppBundle\Entity\Member;
use AppBundle\Entity\Resource;
use AppBundle\Entity\User;
use AppBundle\Entity\ResourceAllocation;
use Symfony\Component\Config\Definition\Exception\Exception;
$r = new DBAccess(null);
$r->insert();
class DBAccess
{
    private $entity_type;
    private $entity;
    private $error = false;
    function myErrorHandler($errno, $errstr, $errfile, $errline)
    {
        if (!$this->error) {
            $error = true;
        }
        exit;
    }
    function __construct($entity)
    {