示例#1
0
 public function distributionPlanIsCreated()
 {
     $date = new DateTime();
     $from = '"' . $date->format('Y.m.d') . ' 00:00:00"';
     $to = '"' . $date->format('Y.m.d') . ' 23:59:00"';
     $data = $this->db->select('*')->from($this->table)->where('date>' . $from . ' AND date<' . $to)->fetchAll();
     if (isset($data[0])) {
         return true;
     }
     return false;
 }
示例#2
0
 /**
  * @param \App\Model\Entities\Article|NULL $article Clanek k editaci
  * @return Form 
  */
 public function create($article = NULL, $tags = [])
 {
     $form = $this->baseFormFactory->create();
     $form->addText('title', 'system.postName')->setRequired($form->getTranslator()->translate('system.requiredItem', ['label' => '%label']));
     $form->addText('description', 'system.postDescription')->setRequired($form->getTranslator()->translate('system.requiredItem', ['label' => '%label']));
     $form->addCheckbox('published', 'system.isPublished');
     //chybi publish_date - datum zverejneni
     $today = new DateTime();
     $form->addText('publishDate', 'system.published')->setType('datetime-local')->setDefaultValue($today->format('d. m. Y, H:i'));
     //->setAttribute('placeholder', 'd. m. Y, H:i (den. měsíc. rok');
     $form->addMultiSelect('tags', new Phrase('system.tag', 2))->setItems($tags);
     $form->addUpload('image', 'system.postImage')->addCondition(Form::FILLED)->addRule(Form::IMAGE, $form->getTranslator()->translate('system.formImage', ['item' => '%label']));
     $form->addText('imageSource', 'system.postImageSource');
     $form->addTextArea('content', 'system.postContent')->setRequired($form->getTranslator()->translate('system.requiredItem', ['label' => '%label']))->setAttribute('rows', 10);
     $form->addSubmit('send', 'system.save');
     //id, vychozi hodnoty pri editaci
     $form->addHidden('id');
     if ($article !== NULL) {
         $defaults = $this->getDefaults($article);
         $form->setDefaults($defaults);
     }
     $form->onValidate[] = [$this, 'validateForm'];
     $form->onSuccess[] = [$this, 'formSucceeded'];
     return $form;
 }
示例#3
0
 /**
  * @param array $types
  * @param \App\Model\Entities\Vote $vote
  * @return Form 
  */
 public function create($types, $vote = NULL)
 {
     $form = $this->baseFormFactory->create();
     $form->addText('question', 'system.voteQuestion')->setRequired($form->getTranslator()->translate('system.requiredItem', ['label' => '%label']));
     $form->addSelect('type', 'system.voteType')->setItems($types)->setPrompt('Zvolte typ dotazu')->setRequired($form->getTranslator()->translate('system.requiredItem', ['label' => '%label']));
     $form->addText('expiration', 'system.voteExpiration')->setType('datetime-local')->setAttribute('placeholder', 'd. m. Y, H:i (den. měsíc. rok, hodina:minuta');
     $options = $form->addDynamic('options', function (Container $option) {
         $option->addText('option', 'system.voteOption');
         $option->addSubmit('remove', 'system.delete')->addRemoveOnClick();
     }, 1);
     $options->addSubmit('add', 'system.new')->setValidationScope(FALSE)->addCreateOnClick();
     $form->addSubmit('send', 'system.save');
     $form->addHidden('id');
     if ($vote) {
         $defaults = $this->getDefaults($vote);
         $form->setDefaults($defaults);
         $options->setValues($defaults['options']);
     } else {
         $today = new DateTime();
         $today->modify('+6 month');
         $default = ['expiration' => $today->format(self::$dateMask)];
         $form->setDefaults($default);
     }
     $form->onValidate[] = [$this, 'validateForm'];
     $form->onSuccess[] = [$this, 'formSucceeded'];
     return $form;
 }
示例#4
0
 /**
  * Generate table
  */
 protected function generate()
 {
     $days = $this->getSpecificDays();
     $table = new Table\Sheet();
     $line = new Table\Line();
     $lastTimeFrom = NULL;
     $lastTimeTo = NULL;
     $lastDay = NULL;
     $lastTags = NULL;
     $now = new DateTime();
     foreach ($days as $day) {
         $timeFrom = (new FilterTime\Def($day->openTime))->output;
         $timeTo = (new FilterTime\Def($day->closeTime))->output;
         if ($lastTimeFrom === $timeFrom && $lastTimeTo === $timeTo && $this->tagsAreSame($lastTags, $day->tags) && $lastDay !== NULL && (int) $lastDay->day->diff($day->day)->format('%r%a') === 1) {
             $line->dateTo = $day->day;
         } else {
             $lastTimeTo !== NULL && $table->addLine($line);
             $line = new Table\Line();
             $line->dateFrom = $day->day;
             $line->dateTo = $day->day;
             $line->tags = $day->tags;
             $this->lineAddTime($line, $timeFrom, $timeTo);
         }
         if ($day->day->format('Y-m-d') === $now->format('Y-m-d')) {
             $line->setActive();
         }
         $lastTags = $day->tags;
         $lastTimeFrom = $timeFrom;
         $lastTimeTo = $timeTo;
         $lastDay = $day;
     }
     $lastTimeTo !== NULL && $table->addLine($line);
     $this->generatedTable = $table;
 }
示例#5
0
 public function isOk()
 {
     $now = new DateTime();
     if ($this->active && intval($this->getExpiration()->format("U")) > intval($now->format("U"))) {
         return TRUE;
     }
     return FALSE;
 }
示例#6
0
 public function update(Items\Base $item, $data)
 {
     if (preg_match('~^\\d{1,2}[/.]{1}[ ]{0,1}\\d{1,2}[/.]{1}[ ]{0,1}\\d{4}$~', $data, $arr)) {
         $dateArr = preg_split('/[.\\/]{1}[ ]{0,1}/s', $arr[0]);
         $date = new Nette\Utils\DateTime($dateArr[2] . '-' . $dateArr[1] . '-' . $dateArr[0]);
         $data = $date->format('Y-m-d');
     }
     return $data;
 }
示例#7
0
 /**
  * @return array of string
  * @throws NoQueryException
  */
 public function toRequestArray()
 {
     $ret = array();
     $ret[self::$ID_DT] = $this->dt->format(Ares::REQUEST_DATE_FORMAT);
     $ret[self::$ID_OUTPUT_FORMAT] = $this->outputFormat;
     $ret[self::$ID_REQUEST_TYPE] = $this->requestType;
     $ret[self::$ID_REQUESTS_COUNT] = $this->queryCount;
     $ret[self::$ID_EMAIL] = $this->email;
     $ret[self::$ID_REQUEST] = array();
     if (!count($this->queries)) {
         throw new NoQueryException();
     }
     foreach ($this->queries as $query) {
         /* @var $query \Sasule\Ares\Query */
         $ret[self::$ID_REQUEST][] = $query->toRequestArray();
     }
     return $ret;
 }
 /**
  * Get settings for control
  *
  * @return array
  */
 protected function getControlSettings()
 {
     $settings = ['format' => $this->getDateTimeFormat(), 'daysOfWeekDisabled' => $this->daysOfWeekDisabled, 'autoclose' => $this->autoClose, 'startView' => $this->startView, 'minViewMode' => $this->minViewMode, 'todayHighlight' => $this->todayHighlight, 'inline' => $this->inline, 'multidate' => $this->multidate, 'multidateSeparator' => $this->multidateSeparator];
     if (!empty($this->datesDisabled)) {
         $dates = [];
         foreach ($this->datesDisabled as $dateTime) {
             $dates[] = $dateTime->format($this->getDateTimeFormat(TRUE));
         }
         $settings['datesDisabled'] = $dates;
     }
     if ($this->startDateTime != NULL) {
         $settings['startDate'] = $this->startDateTime->format($this->getDateTimeFormat(TRUE));
     }
     if ($this->endDateTime != NULL) {
         $settings['endDate'] = $this->endDateTime->format($this->getDateTimeFormat(TRUE));
     }
     return $settings;
 }
示例#9
0
文件: Query.php 项目: sasule/ares
 /**
  * @return array of string
  * @throws QueryMissingKeyPartException
  */
 public function toRequestArray()
 {
     $ret = array();
     if ($this->keyPart instanceof KeyPart) {
         $ret[self::$ID_HELPER_ID] = $this->helperId;
         if ($this->checkUsable($this->searchType)) {
             $ret[self::$ID_SEARCH_TYPE] = $this->searchType;
         }
         $ret[self::$ID_KEY_PART] = $this->keyPart->toRequestArray();
         if ($this->checkUsable($this->city)) {
             $ret[self::$ID_CITY] = $this->city;
         }
         if ($this->dtValid instanceof DateTime) {
             $ret[self::$ID_DT_VALID] = $this->dtValid->format(Ares::REQUEST_DATE_FORMAT);
         }
         if ($this->checkUsable($this->registerType)) {
             $ret[self::$ID_REGISTER_TYPE] = $this->registerType;
         }
         $ret[self::$ID_MAX_COUNT] = $this->maxCount;
     } else {
         throw new QueryMissingKeyPartException();
     }
     return $ret;
 }
示例#10
0
 /**
  * 
  * @param DateTime|NULL $day
  * @return WeekDay
  */
 public function getDay(DateTime $day)
 {
     if (isset($this->specificDays[$day->format('Y-m-d')])) {
         return $this->specificDays[$day->format('Y-m-d')];
     } elseif (isset($this->openingHours[(string) $day->format('w')])) {
         return $this->openingHours[(string) $day->format('w')];
     }
     return NULL;
 }
示例#11
0
 /**
  * Sestavi poradi bodu nezavisle na discipline v ramci oddilu.
  * @param number $course Delka bazenu.
  * @return object $data Poradi bodu.
  */
 public function ByPoint($course)
 {
     $data = $this->database->query('
         select  -- 4. select
             @rownum := @rownum + 1 AS rank,
             sel_2.body, 
             sel_2.prijmeni, 
             sel_2.jmeno, 
             sel_2.rocnik,
             sel_2.styl,
             sel_2.cas,
             sel_2.datum,
             sel_2.zavod
           from
           (
             select -- 2. select
               sel_1.body as body, 
               plavci.surname as prijmeni, 
               plavci.firstname as jmeno, 
               plavci.year as rocnik,
               styly.id as styl,
               cas.time as cas,
               zavody.date as datum,
               zavody.name as zavod
             from
               sm_event zavody,
               sm_stroke styly,
               sm_swimmer plavci,
               sm_time cas,
               (
                 select  -- 1. select
                   a.id_swimmer as plavec,                  
                   max(a.point) as body
                 from
                   sm_time a,
                   sm_event b,
                   sm_swimmer c
                 where
                   a.id_event = b.id and
                   a.id_swimmer = c.id and                  
                   b.lcm = ?
                 group by
                   a.id_swimmer  
               ) sel_1
             where
               cas.id_swimmer = sel_1.plavec and
               cas.point = sel_1.body and              
               cas.id_event = zavody.id and
               cas.id_stroke = styly.id and
               cas.id_swimmer = plavci.id and
               
               zavody.lcm = ? 
             group by
               sel_1.body
             order by
               sel_1.body desc
           ) sel_2,
           (SELECT @rownum := 0) sel_3 -- 3. select', $course, $course)->fetchAll();
     foreach ($data as $row) {
         $formated_date = new DateTime($row->datum);
         $row->datum = $formated_date->format('d. m. Y');
     }
     return $data;
 }
示例#12
0
 public function renderCreate()
 {
     $dateNow = new DateTime();
     $d = array('platneOd' => $dateNow->format(self::$dateFormat));
     $this['nastenkaForm']->setDefaults($d);
 }
示例#13
0
文件: Data.php 项目: filsedla/dbtool
 public static function footer()
 {
     $now = new DateTime();
     return "\n" . "\n" . "-- {$now->format('Y-m-d H:i:s')}\n";
 }
示例#14
0
 public function timeAgo(DateTime $d)
 {
     return Html::el('time')->setText($d->format('j.n.Y H:i'))->addAttributes(['datetime' => $d->format('c')]);
 }
示例#15
0
 public function setValidated($id)
 {
     $now = new \Nette\Utils\DateTime();
     $this->localLoginModel->update($id, array("validated" => $now->format('Y-m-d H:i:s')));
 }
示例#16
0
文件: Poll.php 项目: krupaj/my-blog
 /**
  * @return string Jednoznacny retezec pro identifikaci jednoho hlasovani
  */
 public static function generateVoteIdentificator()
 {
     $now = new DateTime();
     $rand = Random::generate();
     return $now->format('d.m.Y,H:i:s') . 'rand' . $rand;
 }
示例#17
0
 /**
  * @Secured(resource="showEventDay")
  */
 public function actionShowEventDay($year, $month, $day)
 {
     try {
         $data = $this->eventService->getForDate($year, $month, $day);
         $date = new DateTime();
         $date->setDate($year, $month, $day);
         $this->template->date = $date->format(self::DATE_FORMAT);
         $this->template->data = $data;
     } catch (Exceptions\DataErrorException $ex) {
         $this->handleDataLoad(null, "this", $ex);
     }
 }
 /**
  * Vrati aktualne probihajici rezervace pro apartman (2)
  * @return Nette\Database\Table\Selection
  */
 public function getAktualRezervaceApartman()
 {
     $currentDate = new Nette\Utils\DateTime();
     $rezervace = $this->db->table('rezervace')->where('doDatum >= ? AND typPokoje = ?', $currentDate->format('Y-m-d'), self::APARTMAN)->order('odDatum');
     return $rezervace;
 }
示例#19
0
 /**
  * Get Date from ::addDate() field
  *
  * @param Nette\Forms\Controls\TextInput|string $input
  *
  * @return string
  */
 public static function getDateValue($input)
 {
     if ($input instanceof Nette\Forms\Controls\TextInput) {
         $value = $input->getValue();
     } else {
         $value = $input;
     }
     if (preg_match('~^\\d{1,2}[/.]{1}[ ]{0,1}\\d{1,2}[/.]{1}[ ]{0,1}\\d{4}$~', $value, $arr)) {
         $dateArr = preg_split('/[.\\/]{1}[ ]{0,1}/s', $arr[0]);
         $date = new Nette\Utils\DateTime($dateArr[2] . '-' . $dateArr[1] . '-' . $dateArr[0]);
         return $date->getTimestamp() < 10 ? NULL : $date->format('Y-m-d');
     }
     return empty($value) || $value == '0000-00-00' ? NULL : $value;
 }