Beispiel #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\Shift::getById($data['id']);
         } elseif ($data['o_id'] > 0 and $data['o_id'] != "") {
             $object = \Object\Shift::getById($data['o_id']);
         } else {
             $object = $this->model;
             $date = new \Zend_Date();
             $object->setCreationDate($date->get());
             $object->setUserOwner(1);
             $object->setUserModification(1);
             if (method_exists($object, "N")) {
                 $object->setDateregister($date->get());
             }
             $object->setPublished(1);
         }
         if ($object instanceof \Object\Shift) {
             $object->setValues($data);
             $date = new \Zend_Date();
             $object->setModificationDate($date);
             if (!$object->getO_key()) {
                 $folder = $this->getFolderLocation();
                 $object->setParent($folder);
                 $key1 = $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;
     }
 }
 /**
  * view
  */
 public function view($keyterm = '')
 {
     $res = new Reponse();
     $res->isTree = false;
     if ($this->id > 0) {
         $rec = \Object\Shift::getById($this->id);
         $res->data = $rec instanceof Object\Shift ? $rec->toArray() : "";
     } else {
         $res->data = $this->getArray($this->getList());
     }
     $res->success = true;
     $res->message = "Affichage des informations";
     return $res;
 }
Beispiel #3
0
 public function getShifts($from = null, $to = null)
 {
     $result = array();
     $condition = "";
     if ($from) {
         $condition .= " AND o.start >= '" . $from->toString(\Zend_Date::TIMESTAMP) . "' ";
     }
     if ($to) {
         $condition .= " AND o.end <= '" . $from->toString(\Zend_Date::TIMESTAMP) . "' ";
     }
     if ($this->model->getId() > 0) {
         $sql = sprintf(" SELECT distinct r.src_id FROM `object_relations_7` r join object_query_7 o on o.oo_id=r.src_id WHERE r.`dest_id` = '%d' AND r.`fieldname` = 'location' ", $this->model->getId());
         $data = $this->db->FetchAll($sql . $condtion);
     }
     foreach ($data as $key => $row) {
         $loc = \Object\Shift::getById($row["src_id"]);
         if ($loc instanceof \Object\Shift) {
             $result[] = $loc;
         }
     }
     return $result;
 }