Example #1
0
 /**
  * @access protected
  * @global array $registry
  * @return render Add Employee Template & Add Employee
  */
 protected function add()
 {
     global $registry;
     if (isset($_GET['name']) && isset($_GET['email'])) {
         $employee = array('name' => $_GET['name'], 'email' => $_GET['email']);
         $this->registry['template']->data('employee', $employee);
         $validate = new Form();
         $set_name = $validate->validateText($employee['name']);
         $set_email = $validate->validateEmail($employee['email']);
         if (!$set_name) {
             $this->registry['template']->data('set_name', $set_name);
         }
         if (!$set_email) {
             $this->registry['template']->data('set_email', $set_email);
         }
         if ($set_name && $set_email) {
             $employee_object = new Employees();
             if ($employee_object->insertEmployee($_GET['name'], $_GET['email'])) {
                 return $this->added($_GET['name']);
             } else {
                 return $this->failed();
             }
         }
     }
     $this->registry['template']->data('title', 'Add Employee');
     $this->registry['template']->render('header');
     $this->registry['template']->data('action', 'Add');
     $this->registry['template']->render('employee/edit');
     $this->registry['template']->render('footer');
 }
 public function addMember()
 {
     $json = array();
     $json['name'] = Form::validateText($_POST['uname']);
     $json['email'] = Form::validateEmail($_POST['email']);
     $json['exists_email'] = $this->isEmailExistsInMembersAtCurrentCalendar($_POST['email'], $_POST['calendarname']);
     $json['phone'] = Form::validateText($_POST['phone'], 10, 30);
     if (in_array(FALSE, $json)) {
         echo json_encode($json);
         die;
     }
     if (isset($_POST['scheduleid'])) {
         $datetime = $this->getAppointmentDateTimeByID($_POST['scheduleid']);
         $json['date'] = $datetime[0]['date'];
         $json['time'] = $datetime[0]['time'];
         $_POST['dateformat'] = $datetime[0]['date'];
         $_POST['timeformat'] = $datetime[0]['time'];
     }
     $this->addRegisterInDB($_POST);
     $this->emailCustomerHtml($_POST);
     $this->emailAdminHtml($_POST);
     $json['calendarname'] = $_POST['calendarname'];
     $json['success'] = TRUE;
     echo json_encode($json);
     die;
 }
Example #3
0
 /**
  * Validate Data on Event Popup Window 
  * @access public
  * @return array results of Validation
  */
 public function validateData()
 {
     $json = '';
     $validate = new Form();
     $date1 = new DateTime($_REQUEST['date'] . ' ' . $_REQUEST['start_time']);
     $date2 = new DateTime($_REQUEST['date'] . ' ' . $_REQUEST['end_time']);
     $error['date'] = $validate->validateDate($date1->format('Y-m-d H:i:s'), $date2->format('Y-m-d H:i:s'));
     if (!$error['date']) {
         $json['date'] = 'Invalid Date';
     }
     $error['description'] = $validate->validateText($_REQUEST['specifics'], 3, 1000);
     if (!$error['description']) {
         $json['description'] = 'Minimum 3 characters maximum 1000 characters';
     }
     $schedules = new Schedules();
     $appointments = $schedules->getAppointmentsByDate($_REQUEST['boardroom_id'], $date1->format('Y-m-d H:i:s'), $date2->format('Y-m-d H:i:s'), $_REQUEST['schedule_id']);
     if ($appointments) {
         $json['appointments'] = $appointments[0];
     }
     if (!$json) {
         if ($appointments = $schedules->updateAppointments($date1->format('Y-m-d H:i:s'), $date2->format('Y-m-d H:i:s'), $_REQUEST)) {
             $json['success'] = "Event changed";
         } else {
             $json['success'] = "Something was broken";
         }
     }
     echo json_encode($json);
     die;
 }