Пример #1
0
 public function replace($data = array())
 {
     try {
         if ($this->model->getId() > 0) {
             $object = $this->model;
         } elseif ($data['id'] > 0 and $data['id'] != "") {
             $object = \Object\Guest::getById($data['id']);
         } elseif ($data['o_id'] > 0 and $data['o_id'] != "") {
             $object = \Object\Guest::getById($data['o_id']);
         } else {
             $object = $this->model;
             $date = new \Zend_Date();
             $object->setCreationDate($date->get());
             //todo
             $object->setUserOwner(1);
             $object->setUserModification(1);
             if (method_exists($object, "setAvatar")) {
                 $object->setAvatar($this->getDefaultImage());
             }
             $object->setPublished(1);
         }
         if ($object instanceof \Object\Guest) {
             $object->setValues($data);
             $date = new \Zend_Date();
             $object->setModificationDate($date);
             if (!$object->getO_key()) {
                 $folder = $this->getFolderAlpha();
                 $object->setParent($folder);
                 if (!method_exists($object, getEmail)) {
                     $key1 = $this->model->getClassName();
                 } else {
                     $key1 = $object->getEmail() ? $object->getEmail() : $this->model->getClassName();
                 }
                 $numero = $date->get(\Zend_Date::TIMESTAMP);
                 $object_key = $this->correctClassname($key1) . '-' . $numero;
                 $object->setO_key(strtolower($object_key));
             }
             return $object;
         } else {
             \Logger::warning("Erreur :  Classe de l'objet erronnée");
             return false;
         }
     } catch (\Exception $e) {
         \Logger::warning($e->getMessage());
         return false;
     }
 }
Пример #2
0
 public function formatData($data)
 {
     $date = \Zend_Date::now();
     $timestart = new \Zend_Date($data['calendar'] . ' ' . $data['slotinput'] . ':00', 'dd-MM-YYYY HH:mm:ss');
     //$timestart = \Zend_Date::now();
     $location = \Object\Location::getById($data['locationid'], 1);
     if ($location instanceof \Object\Location) {
         $societe = $location->getSociete();
         $serving = \Object\Serving::getById($data['servinginput'], 1);
         if ($serving instanceof \Object\Serving) {
             $mealduration = $serving->getMealduration();
         }
         $end = $timestart->getTimestamp() + $mealduration * 60;
         $timeend = new \Zend_Date($end);
         $guest = \Object\Guest::getByEmail($data['email'], 1);
         if (!$guest instanceof \Object\Guest) {
             $guest = new \Object\Guest();
             $guest->updateData(array('tel' => $data['tel'], 'email' => $data['email'], 'lastname' => $data['lastname'], 'societe' => $societe, 'dateregister' => $date, 'location' => $location));
         }
     }
     $result = array();
     $result['id'] = $data['id'];
     $result['method'] = $data['method'];
     $result['tel'] = $data['tel'];
     $result['email'] = $data['email'];
     $result['lastname'] = $data['lastname'];
     $result['partysize'] = $data['partysize'];
     $result['person'] = $data['person'];
     $result['societe'] = $societe;
     $result['location'] = $location;
     $result['guest'] = $guest;
     $result['serving'] = $serving;
     $result['start'] = $timestart;
     $result['datereservation'] = $timestart;
     $result['end'] = $timeend;
     return $result;
 }
Пример #3
0
    public function profileAction()
    {
        $this->layout()->setLayout('portal');
        $this->view->guest = $this->getParam("id") ? \Object\Guest::getById($this->getParam("id")) : null;
        // $this->view->headScript()->appendFile(PIMCORE_WEBSITE_LAYOUTS.'/assets/js/table-guest-list.js');
        $this->view->inlineScript()->appendScript('jQuery(document).ready(function() {
					Main.init();
				});', 'text/javascript', array('noescape' => true));
        // Disable CDATA comments
    }
Пример #4
0
 public function formatData($data)
 {
     $data['tel'] = preg_replace("/[^0-9]/", "", $data['tel']);
     if ($data['datereservation']) {
         $datereservation = self::parseDateTime($data['datereservation'], 'dd-MM-YYYY');
         $start = self::parseDateTime($data['reservationdate'] . ' ' . $data['start'], 'dd-MM-YYYY HH:mm');
         if ($data['arrived'] == 1) {
             $actualstart = self::parseDateTime($data['reservationdate'] . ' ' . $data['start'], 'dd-MM-YYYY HH:mm');
         }
     } else {
         $chosenresa = Object\Reservation::getById($data['id'], 1);
         $chosenday = $chosenresa->getStart()->get('dd-MM-YYYY');
         $start = self::parseDateTime($chosenday . ' ' . $data['start'], 'dd-MM-YYYY HH:mm');
         if ($data['arrived'] == 1) {
             $actualstart = self::parseDateTime($data['reservationdate'] . ' ' . $data['start'], 'dd-MM-YYYY HH:mm');
         }
     }
     if ($data['arrived'] == 1) {
         $data['actualpartysize'] = $data['partysize'];
         $data['actualstart'] = $data['start'];
     }
     $location = \Object\Location::getById($data['locationid'], 1);
     if ($location instanceof \Object\Location) {
         $societe = $location->getSociete();
         $serving = \Object\Serving::getById($data['servinginput'], 1);
         if ($serving instanceof \Object\Serving) {
             $mealduration = $serving->getMealduration();
         }
         $end = new \Zend_date($start->getTimeStamp() + $mealduration * 60);
         if ($data['tel']) {
             $guest = \Object\Guest::getByTel($data['tel'], 1);
             if (!$guest instanceof \Object\Guest) {
                 $guest = new \Object\Guest();
                 $guest->updateData(array('tel' => $data['tel'], 'email' => $data['email'], 'lastname' => $data['lastname'], 'societe' => $societe, 'dateregister' => $date, 'location' => $location, 'bookingnotes' => $data['bookingnotes'], 'countrycode' => $data['countrycode']));
             }
         }
     }
     $result = array();
     $result['id'] = $data['id'];
     $result['method'] = $data['method'];
     $result['tel'] = $data['tel'];
     $result['countrycode'] = $data['countrycode'];
     $result['email'] = $data['email'];
     $result['lastname'] = $data['lastname'];
     $result['actualpartysize'] = $data['actualpartysize'];
     $result['partysize'] = $data['partysize'];
     $result['status'] = $data['status'];
     $result['arrived'] = $data['arrived'];
     $result['person'] = $data['person'];
     $result['societe'] = $societe;
     $result['location'] = $location;
     $result['guest'] = $guest;
     $result['serving'] = $serving;
     $result['actualstart'] = $actualstart;
     $result['start'] = $start;
     $result['datereservation'] = $datereservation;
     $result['end'] = $end;
     $result['bookingref'] = $data['bookingref'];
     $result['bookingnotes'] = $data['bookingnotes'];
     return $result;
 }
Пример #5
0
 public function getGuests($q = null)
 {
     $result = array();
     if ($this->model->getId() > 0) {
         $searchCondition = "";
         if ($q) {
             $qlike = "%" . $q . "%";
             $searchCondition = " and ( o.lastname like '{$qlike}' or o.tel like '{$qlike}' or o.email like '{$qlike}') ";
         }
         $sql = sprintf(" SELECT distinct r.src_id FROM `object_relations_12` r join object_query_12 o on o.oo_id=r.src_id WHERE r.`dest_id` = '%d' AND r.`fieldname` = 'societe' ", $this->model->getId()) . $searchCondition;
         $sql .= " order by o.lastname asc";
         $data = $this->db->FetchAll($sql);
     }
     foreach ($data as $key => $row) {
         $g = \Object\Guest::getById($row["src_id"]);
         if ($g instanceof \Object\Guest) {
             $result[] = $g;
         }
     }
     return $result;
 }
Пример #6
0
 /**
  * destroy
  */
 public function destroy()
 {
     $res = new Reponse();
     $rec = \Object\Guest::getById($this->id);
     if ($rec) {
         $rec->delete();
         $res->success = true;
         $res->message = 'Destroyed';
     } else {
         $res->message = "Failed to destroy";
     }
     return $res;
 }