public function date($name) { $value = isset($this->controller->request->data->{$name}) ? stripslashes($this->controller->request->data->{$name}) : EMPTYSTRING; $value = empty($value) ? dateConvert(dateInit()) : dateConvert($value); $buffer = EMPTYSTRING; $buffer .= $this->init($name); $buffer .= '<div class="input-group date form_datetime col-md-5" id="input' . $name . 'picker" data-date="' . $value . '" data-date-format="dd/mm/yyyy hh:ii">'; $buffer .= '<input class="form-control" type="text" readonly value="' . $value . '" name="' . $name . '" required>'; $buffer .= '<span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>'; $buffer .= '</div>'; $buffer .= $this->end($name); return $buffer; }
function getLastResult($id) { $this->loadModel(CALENDAR); return $this->Calendar->findFirst(array('fields' => ProjectUtils::$tableExtend[TEAM] . ',' . ProjectUtils::$tableExtend[CALENDAR], 'conditions' => 'Calendar.online = 1 AND Calendar.logical_delete = 0 AND Calendar.dayofgame < \'' . dateInit() . '\' AND Calendar.team=' . $id, 'order' => 'Calendar.dayofgame DESC', 'join' => array('team as Team' => 'Team.id=' . $id))); }
public function dateText($name, $readonly, $required) { $value = isset($this->controller->request->data->{$name}) ? stripslashes($this->controller->request->data->{$name}) : EMPTYSTRING; $value = empty($value) ? dateConvert(dateInit()) : dateConvert($value); $buffer = EMPTYSTRING; $buffer .= $this->init($name); $buffer .= '<input type="text" id="input' . $name . '" name="' . $name . '" value="' . $value . '" class="form-control" ' . $this->readonly($readonly) . ' ' . $this->required($required) . '>'; $buffer .= $this->end(); return $buffer; }
public function save($data) { $keyword = $this->primaryKey; $fields = array(); $d = array(); foreach ($data as $k => $v) { if ($k != $this->primaryKey) { if ($k == 'updated') { $v = dateInit(); } $fields[] = "{$k}=:{$k}"; $d[":{$k}"] = $v; } elseif (!empty($v)) { $d[":{$k}"] = $v; } } if (isset($data->{$keyword}) && !empty($data->{$keyword})) { $sql = 'UPDATE ' . $this->table . ' SET ' . implode(',', $fields) . ' WHERE ' . $keyword . '=:' . $keyword; $this->id = $data->{$keyword}; $action = 'update'; } else { $sql = 'INSERT ' . 'INTO ' . $this->table . ' SET ' . implode(',', $fields); $action = 'insert'; } try { $pre = $this->db->prepare($sql); $pre->execute($d); if ($action == 'insert') { $this->id = $this->db->lastInsertId(); } return $this->id; } catch (PDOException $e) { return $e->errorInfo[2]; } }