Skip to content

Commit

Permalink
Merge pull request #23 from kitalab/master
Browse files Browse the repository at this point in the history
カレンダー連携用にTable構成変更
  • Loading branch information
kitatsuw committed Aug 4, 2016
2 parents d9375d7 + 54dd53b commit 52d7b38
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 53 deletions.
5 changes: 3 additions & 2 deletions Config/Migration/002_initialize.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,12 @@ class Initialize extends CakeMigration {
'title' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'title | タイトル | | ', 'charset' => 'utf8'),
'content' => array('type' => 'text', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'content | 内容', 'charset' => 'utf8'),
'priority' => array('type' => 'integer', 'null' => true, 'default' => '0', 'length' => 4, 'unsigned' => false, 'comment' => 'priority | 重要度 | 0:未設定、1:低、2:中、3:高'),
'task_start_date' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 8, 'collate' => 'utf8_general_ci', 'comment' => 'task start date (YYYYMMDD format) | 開始日 (YYYYMMDD形式)', 'charset' => 'utf8'),
'task_end_date' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 8, 'collate' => 'utf8_general_ci', 'comment' => 'utc end date (YYYYMMDD format) | 終了日 (YYYYMMDD形式)', 'charset' => 'utf8'),
'task_start_date' => array('type' => 'datetime', 'null' => true, 'default' => null),
'task_end_date' => array('type' => 'datetime', 'null' => true, 'default' => null),
'is_enable_mail' => array('type' => 'boolean', 'null' => false, 'default' => '0'),
'email_send_timing' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => 11, 'unsigned' => false),
'use_calendar' => array('type' => 'boolean', 'null' => false, 'default' => '0'),
'calendar_id' => array('type' => 'integer', 'null' => true, 'default' => null, 'unsigned' => false, 'comment' => 'calendar id | カレンダーID | calendar.id | '),
'is_completion' => array('type' => 'boolean', 'null' => false, 'default' => '0'),
'progress_rate' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => 11, 'unsigned' => false),
'key' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'key | content key | Hash値 | ', 'charset' => 'utf8'),
Expand Down
5 changes: 3 additions & 2 deletions Config/Schema/schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,12 @@ public function after($event = array()) {
'title' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'title | タイトル | | ', 'charset' => 'utf8'),
'content' => array('type' => 'text', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'content | 内容', 'charset' => 'utf8'),
'priority' => array('type' => 'integer', 'null' => true, 'default' => '0', 'length' => 4, 'unsigned' => false, 'comment' => 'priority | 重要度 0:未設定、1:低、2:中、3:高'),
'task_start_date' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 8, 'collate' => 'utf8_general_ci', 'comment' => 'task start date (YYYYMMDD format) | 開始日 (YYYYMMDD形式)', 'charset' => 'utf8'),
'task_end_date' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 8, 'collate' => 'utf8_general_ci', 'comment' => 'task end date (YYYYMMDD format) | 終了日 (YYYYMMDD形式)', 'charset' => 'utf8'),
'task_start_date' => array('type' => 'datetime', 'null' => true, 'default' => null),
'task_end_date' => array('type' => 'datetime', 'null' => true, 'default' => null),
'is_enable_mail' => array('type' => 'boolean', 'null' => false, 'default' => '0'),
'email_send_timing' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => 11, 'unsigned' => false),
'use_calendar' => array('type' => 'boolean', 'null' => false, 'default' => '0'),
'calendar_id' => array('type' => 'integer', 'null' => true, 'default' => null, 'unsigned' => false, 'comment' => 'calendar id | カレンダーID | calendar.id | '),
'is_completion' => array('type' => 'boolean', 'null' => false, 'default' => '0'),
'progress_rate' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => 11, 'unsigned' => false),
'key' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'key | content key | Hash値 | ', 'charset' => 'utf8'),
Expand Down
5 changes: 2 additions & 3 deletions Controller/TaskContentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public function delete() {
return $this->throwBadRequest();
}

if ($this->TaskContent->deleteEntryByKey($key) === false) {
if ($this->TaskContent->deleteContentByKey($key) === false) {
throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
}
return $this->redirect(
Expand Down Expand Up @@ -408,8 +408,7 @@ protected function _list($conditions) {
// order情報を整理
$order = array_merge($order, $defaultOrder);

$taskContents = $this->TaskContent->getList(
$params, $order, $userParam, $this->NetCommonsTime->getNowDatetime());
$taskContents = $this->TaskContent->getList($params, $order, $userParam);

// 期限間近のToDo一覧を分けて取得
if (isset($taskContents['DeadLine'])) {
Expand Down
6 changes: 1 addition & 5 deletions Locale/jpn/LC_MESSAGES/tasks.po
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,7 @@ msgstr "実施期間終了日の2日前"

# 登録(編集)画面で使用
msgid "One week before the task period"
msgstr "実施期間終了日の一週間前"

# 登録(編集)画面で使用
msgid "Two days previously"
msgstr "実施期間終了日の7日前"
msgstr "実施期間終了日の1週間前"

# 登録(編集)画面で使用
msgid "Use calendar"
Expand Down
84 changes: 51 additions & 33 deletions Model/TaskContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class TaskContent extends TasksAppModel {
const TASK_START_DATE_BEFORE = 1;

/**
* 実施終了日2日前のタスク
* 実施終了日間近のタスク
*
* @var const
*/
Expand Down Expand Up @@ -169,10 +169,9 @@ protected function _getValidateSpecification() {
* @param array $params 絞り込み条件
* @param array $order 並べ替え条件
* @param array $userParam 担当者絞り込み条件
* @param void $now 現在日時
* @return array
*/
public function getList($params = array(), $order = array(), $userParam = array(), $now = '') {
public function getList($params = array(), $order = array(), $userParam = array()) {
if ($userParam) {
$params = $this->getUserCondition($params, $userParam);
}
Expand All @@ -186,7 +185,7 @@ public function getList($params = array(), $order = array(), $userParam = array(
return array();
}

$taskContentList = $this->getTaskContentList($lists, $now);
$taskContentList = $this->getTaskContentList($lists);

return $taskContentList;
}
Expand All @@ -195,58 +194,52 @@ public function getList($params = array(), $order = array(), $userParam = array(
* カテゴリデータとToDoデータを整理したLISTを返す
*
* @param array $lists 担当者絞り込み条件で取得したデータ
* @param array $now 現在日時
*
* @return array
*/
public function getTaskContentList($lists, $now) {
$now = date('Ymd', strtotime($now));
public function getTaskContentList($lists) {
$now = date('Ymd', strtotime(date('Y/m/d H:i:s')));
$deadLine = date("Ymd", strtotime("+2 day"));
$deadTasks = array();
$contentLists = array();

foreach ($lists as $list) {
// 現在実施中
$list['TaskContent']['date_color'] = TaskContent::TASK_BEING_PERFORMED;
if ($list['TaskContent']['is_completion'] === true) {
$contentLists[] = $list;
continue;
}
// 現在の日付が開始日より前
$list['TaskContent']['date_color'] = TaskContent::TASK_START_DATE_BEFORE;
// 終了日が現在の日付から2日後以下でかつ現在の日付以下でないもの
if ($list['TaskContent']['task_end_date']) {
if (intval($list['TaskContent']['task_end_date']) <= intval($deadLine)
&& intval($list['TaskContent']['task_end_date']) >= intval($now)
if (!empty($list['TaskContent']['task_start_date'])
&& intval($list['TaskContent']['task_start_date']) > $now
) {
$list['TaskContent']['date_color'] = TaskContent::TASK_START_DATE_BEFORE;
}
if (!empty($list['TaskContent']['task_end_date'])) {
// 終了期限間近
if (intval($list['TaskContent']['task_end_date']) >= intval($now)
&& intval($list['TaskContent']['task_end_date']) <= intval($deadLine)
) {
$list['TaskContent']['date_color'] = TaskContent::TASK_DEADLINE_CLOSE;
$contentLists[] = $list;
$deadTasks[] = $list;
continue;
}
// 終了日が現在の日付以下のもの
if (intval($list['TaskContent']['task_end_date']) < intval($now)) {
// 終了期限切れ
} elseif (intval($list['TaskContent']['task_end_date']) < intval($now)) {
$list['TaskContent']['date_color'] = TaskContent::TASK_BEYOND_THE_END_DATE;
$contentLists[] = $list;
$deadTasks[] = $list;
continue;
}
}
// 開始日が設定されており現在の開始日が現在の日付以下のもの
if (!empty($list['TaskContent']['task_start_date'])
&& intval($list['TaskContent']['task_start_date']) <= intval($now)
) {
$list['TaskContent']['date_color'] = TaskContent::TASK_BEING_PERFORMED;
$contentLists[] = $list;
continue;
}
$contentLists[] = $list;
}

// カテゴリ情報を取得
$categoryArr = $this->getCategory($contentLists);

// ToDo一覧情報を取得
$taskContentList = $this->setCategoryContentList($categoryArr, $contentLists);
$taskContentList = $this->getCategoryContentList($categoryArr, $contentLists);

// 期限間近のToDoがある場合DeadLineデータとしてToDo一覧情報に追加する
if ($deadTasks) {
$taskContentList['DeadLine'] = $deadTasks;
}
// 期限間近のToDoをDeadLineデータとしてToDo一覧情報に追加する
$taskContentList['DeadLine'] = $deadTasks;

return $taskContentList;
}
Expand Down Expand Up @@ -309,7 +302,7 @@ public function getCategory($contentLists) {
*
* @return array
*/
public function setCategoryContentList($categoryArr, $contentLists) {
public function getCategoryContentList($categoryArr, $contentLists) {
$taskContentList = array();
foreach ($categoryArr as $category) {
$results = array();
Expand Down Expand Up @@ -485,4 +478,29 @@ public function saveProgressRate($key, $progressRate) {

return true;
}

/**
* TODO削除
*
* @param int $key オリジンID
* @throws InternalErrorException
* @return bool
*/
public function deleteContentByKey($key) {
$this->begin();
try{
// 記事削除
$this->contentKey = $key;
$conditions = array('TaskContent.key' => $key);
if ($result = $this->deleteAll($conditions, true, true)) {
$this->commit();
} else {
throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
}
} catch (Exception $e) {
$this->rollback($e);
//エラー出力
}
return $result;
}
}
4 changes: 2 additions & 2 deletions View/Elements/TaskContents/task_period_edit_form.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<div class="form-inline">
<div class="input-group" style="margin-bottom: 10px">
<?php echo $this->NetCommonsForm->input('TaskContent.task_start_date', array(
'datetimepicker' => 'datetimepicker',
'type' => 'datetime',
'datetimepicker-options' => $pickerOpt,
'ng-model' => 'TaskContent.task_start_date',
'data-toggle' => 'dropdown',
Expand All @@ -45,7 +45,7 @@
<span class="glyphicon glyphicon-minus"></span>
</span>
<?php echo $this->NetCommonsForm->input('TaskContent.task_end_date', array(
'datetimepicker' => 'datetimepicker',
'type' => 'datetime',
'datetimepicker-options' => $pickerOpt,
'ng-model' => 'TaskContent.task_end_date',
'data-toggle' => 'dropdown',
Expand Down
6 changes: 3 additions & 3 deletions View/TaskContents/index.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@
</div>
<?php else: ?>

<?php $isNotShow = false; ?>
<?php if (isset($params['user_id']) && $params['user_id'] !== Current::read('User.id')): ?>
<?php $isNotShow = true; ?>
<?php endif; ?>

<?php $params = $this->params['named']; ?>

<?php if (isset($deadLineTasks) && ! isset($params['category_id']) && $isNotShow = false): ?>
<?php if ($deadLineTasks && empty($params['category_id']) && $isNotShow === false): ?>
<div class="clearfix" style="height: 25px;">
<div style="border-bottom-width: 5px;" class="pull-left">
<?php echo __d('tasks', 'No category'); ?>
<?php echo __d('tasks', 'Deadline close Expiration'); ?>
</div>
</div>

Expand Down
11 changes: 8 additions & 3 deletions View/TaskContents/view.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,14 @@ echo $this->Html->css(
<div class="pull-left" style="margin-left: 10px">
<?php echo h(__d('tasks', 'Category') . __d('tasks', 'Colon')); ?>
<?php if ($taskContent['Category']['name']): ?>
<a href="">
<?php echo $taskContent['Category']['name']; ?>
</a>
<?php
$url = array(
'controller' => 'task_contents',
'action' => 'index');
?>
<?php echo $this->NetCommonsHtml->link($taskContent['Category']['name'],
Hash::merge($url, array('category_id' => $taskContent['Category']['id'])));
?>
<?php else : ?>
<?php echo h(__d('tasks', 'Not selected')); ?>
<?php endif; ?>
Expand Down

0 comments on commit 52d7b38

Please sign in to comment.