From bd914566e63dcd92a06780f94a7f07146a9b4bc8 Mon Sep 17 00:00:00 2001 From: kitatsuji Date: Fri, 26 May 2017 20:03:59 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=E3=82=AB=E3=83=AC=E3=83=B3=E3=83=80?= =?UTF-8?q?=E3=83=BC=E7=99=BB=E9=8C=B2=E9=80=A3=E6=90=BA=E5=87=A6=E7=90=86?= =?UTF-8?q?=E5=8F=96=E3=82=8A=E8=BE=BC=E3=81=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controller/TaskContentEditController.php | 4 + Locale/eng/LC_MESSAGES/tasks.po | 8 ++ Locale/jpn/LC_MESSAGES/tasks.po | 10 ++ Locale/tasks.pot | 8 ++ Model/TaskContent.php | 116 ++++++++++++++++++ .../TaskContentEdit/task_period_edit_form.ctp | 20 +++ View/TaskContents/view.ctp | 10 ++ 7 files changed, 176 insertions(+) diff --git a/Controller/TaskContentEditController.php b/Controller/TaskContentEditController.php index dd15f9c..d4ac243 100644 --- a/Controller/TaskContentEditController.php +++ b/Controller/TaskContentEditController.php @@ -149,6 +149,8 @@ public function edit() { $key = $this->params['key']; $taskContent = $this->TaskContent->getTask($key); + $calendarKey = $taskContent['TaskContent']['calendar_key']; //ADD カレンダ連携キーの取り出し + $taskContent['TaskContent']['use_calendar'] = !is_null($calendarKey) ? true : false; if (! $this->request->data) { $this->request->data = $taskContent; } @@ -172,6 +174,8 @@ public function edit() { $this->_taskSetting['TaskSetting']['task_key']; $this->request->data['TaskContent']['key'] = $key; + $this->request->data['TaskContent']['calendar_key'] = $calendarKey; //ADD カレンダー連携キー転写 + // set status $status = $this->Workflow->parseStatus(); $this->request->data['TaskContent']['status'] = $status; diff --git a/Locale/eng/LC_MESSAGES/tasks.po b/Locale/eng/LC_MESSAGES/tasks.po index 6f886a8..45a79ff 100644 --- a/Locale/eng/LC_MESSAGES/tasks.po +++ b/Locale/eng/LC_MESSAGES/tasks.po @@ -242,6 +242,14 @@ msgstr "Progress rate: " msgid "Person in charge" msgstr "Person in charge: " +#: Tasks/View/TaskContents/view.ctp:50 +msgid "Calendar registered" +msgstr "Calendar registered" + +#: Tasks/View/TaskContents/view.ctp:54 +msgid "Calendar not registered" +msgstr "Calendar not registered" + #: Tasks/View/TaskMailSettings/edit.ctp:22 msgid "MailSetting.mail_fixed_phrase_body.popover" msgstr "" diff --git a/Locale/jpn/LC_MESSAGES/tasks.po b/Locale/jpn/LC_MESSAGES/tasks.po index a6e53d4..1ec5c8d 100644 --- a/Locale/jpn/LC_MESSAGES/tasks.po +++ b/Locale/jpn/LC_MESSAGES/tasks.po @@ -294,6 +294,16 @@ msgstr "進捗率:" msgid "Person in charge" msgstr "担当者:" +# 詳細画面で使用 +#: Tasks/View/TaskContents/view.ctp:50 +msgid "Calendar registered" +msgstr "カレンダー登録済み" + +# 詳細画面で使用 +#: Tasks/View/TaskContents/view.ctp:54 +msgid "Calendar not registered" +msgstr "カレンダー未登録" + # 投稿メール基本文で使用 #: Tasks/View/TaskMailSettings/edit.ctp:22 msgid "MailSetting.mail_fixed_phrase_body.popover" diff --git a/Locale/tasks.pot b/Locale/tasks.pot index b1c5c7a..6374cf2 100644 --- a/Locale/tasks.pot +++ b/Locale/tasks.pot @@ -242,6 +242,14 @@ msgstr "" msgid "Person in charge" msgstr "" +#: Tasks/View/TaskContents/view.ctp:50 +msgid "Calendar registered" +msgstr "" + +#: Tasks/View/TaskContents/view.ctp:54 +msgid "Calendar not registered" +msgstr "" + #: Tasks/View/TaskMailSettings/edit.ctp:22 msgid "MailSetting.mail_fixed_phrase_body.popover" msgstr "" diff --git a/Model/TaskContent.php b/Model/TaskContent.php index 59692cc..314cf0f 100644 --- a/Model/TaskContent.php +++ b/Model/TaskContent.php @@ -11,6 +11,8 @@ App::uses('TasksAppModel', 'Tasks.Model'); App::uses('MailQueueBehavior', 'Mails.Model/Behavior'); +App::uses('CalendarActionPlan', 'Calendars.Model'); //ADD +App::uses('CalendarDeleteActionPlan', 'Calendars.Model'); //ADD /** * Summary for TaskContent Model @@ -647,6 +649,93 @@ public function saveContent($data) { throw new InternalErrorException(__d('net_commons', 'Internal Server Error')); } + //カレンダー連携ここから ADD + $cmd = 'del'; + if ($data['TaskContent']['is_date_set']) { + $cmd =($data['TaskContent']['use_calendar']) ? 'save' : 'del'; + } + if ($cmd==='save') { + //実施期間設定あり&&カレンダー登録する + $this->loadModels([ + 'CalendarActionPlan' => 'Calendars.CalendarActionPlan', + ]); + + //登録・変更用settings指定付きでbehaviorロード + $this->CalendarActionPlan->Behaviors->load('Calendars.CalendarLink', array( + 'linkPlugin' => Current::read('Plugin.key'), + 'table' => $this->alias, //fieldsの対象テーブル + 'inputFields' => array( + 'title' => 'title', + 'description' => 'content', + ), + 'sysFields' => array( + 'key' => 'key', //tasksの場合、task_contentsテーブルのkey + 'calendar_key' => 'calendar_key', //tasksの場合、task_contentsテーブルのcalendar_key + ), + 'startendFields' => array( + 'start_datetime' => 'task_start_date', + 'end_datetime' => 'task_end_date', + ), + 'isServerTime' => true, + 'useStartendComplete' => true, + 'isLessthanOfEnd' => false, + 'isRepeat' => false, + 'isPlanRoomId' => false, + )); + + $calendarKey = $this->CalendarActionPlan->savePlanForLink($data); + if (is_string($calendarKey) && ! empty($calendarKey)) { + //カレンダ登録成功 + //calenar_keyを TaskContentにsave(update)しておく。 + $data['TaskContent']['calendar_key'] = $calendarKey; + $savedData = $this->save($data, false); + if ($savedData === false) { + throw new InternalErrorException(__d('net_commons', 'Internal Server Error')); + } + $data['TaskContent'] = $savedData['TaskContent']; + } elseif ($calendarKey === '') { + //未承認や一時保存はカレンダー登録条件を満たさないのでスルー(通常) + } else { //false + //カレンダー登録時にエラー発生(エラー) + //例外なげる + throw new InternalErrorException(__d('net_commons', 'Internal Server Error')); + } + $this->CalendarActionPlan->Behaviors->unload('Calendars.CalendarLink'); + } else { //cmd===del + if (! empty($data['TaskContent']['calendar_key'])) { + //calendar_keyが記録されているので、消しにいく。 + $this->loadModels([ + 'CalendarDeleteActionPlan' => 'Calendars.CalendarDeleteActionPlan', + ]); + //削除用settings指定 + $this->CalendarDeleteActionPlan->Behaviors->load('Calendars.CalendarLink', array( + 'linkPlugin' => Current::read('Plugin.key'), + 'table' => $this->alias, //fieldsの対象テーブル + 'sysFields' => array( + 'key' => 'key', //tasksの場合、task_contentsテーブルのkey + 'calendar_key' => 'calendar_key', //tasksの場合、task_contentsテーブルのcalendar_key + ), + 'isDelRepeat' => false, //tasksはfalse固定 + )); + $delCalendarKey = $this->CalendarDeleteActionPlan->deletePlanForLink($data); + if ($data['TaskContent']['calendar_key'] == $delCalendarKey) { + //削除が成功したので、calenar_keyをクリアし、use_calendarをOFFにして、 + //TaskContentにsave(update)しておく。 + $data['TaskContent']['calendar_key'] = ''; + $data['TaskContent']['use_calendar'] = 0; + $savedData = $this->save($data, false); + if ($savedData === false) { + throw new InternalErrorException(__d('net_commons', 'Internal Server Error')); + } + $data['TaskContent'] = $savedData['TaskContent']; + } + $this->CalendarDeleteActionPlan->Behaviors->unload('Calendars.CalendarLink'); + } else { + //calendar_keyが記録されていないので、なにもしない + } + } + //カレンダー連携ここまで ADD + //多言語化の処理 $this->set($savedData); $this->saveM17nData(); @@ -770,6 +859,33 @@ public function deleteContentByKey($key) { ) { throw new InternalErrorException(__d('net_commons', 'Internal Server Error')); } + + //カレンダー連携ここから ADD + $this->loadModels([ + 'CalendarDeleteActionPlan' => 'Calendars.CalendarDeleteActionPlan', + ]); + //削除用settings指定 + $this->CalendarDeleteActionPlan->Behaviors->load('Calendars.CalendarLink', array( + 'linkPlugin' => Current::read('Plugin.key'), + 'table' => $this->alias, //fieldsの対象テーブル + 'sysFields' => array( + 'key' => 'key', //tasksの場合、task_contentsテーブルのkey + 'calendar_key' => 'calendar_key', //tasksの場合、task_contentsテーブルのcalendar_key + ), + 'isDelRepeat' => false, //tasksはfalse固定 + )); + $datas = $this->find('all', array( + 'recursive' => -1, + 'conditions' => array( + 'TaskContent.key' => $key, + ) + )); + foreach ($datas as $data) { + $this->CalendarDeleteActionPlan->deletePlanForLink($data); + } + $this->CalendarDeleteActionPlan->Behaviors->unload('Calendars.CalendarLink'); + //カレンダー連携ここまで ADD + if (! $this->deleteAll(array($this->alias . '.key' => $key), false, true)) { throw new InternalErrorException(__d('net_commons', 'Internal Server Error')); } diff --git a/View/Elements/TaskContentEdit/task_period_edit_form.ctp b/View/Elements/TaskContentEdit/task_period_edit_form.ctp index 1b91b5f..bc9ee61 100644 --- a/View/Elements/TaskContentEdit/task_period_edit_form.ctp +++ b/View/Elements/TaskContentEdit/task_period_edit_form.ctp @@ -83,5 +83,25 @@ } ?> + + NetCommonsForm->checkbox('TaskContent.use_calendar', array( + 'class' => 'text-left pull-left', + )); + ?> + NetCommonsForm->label( + 'TaskContent.use_calendar', + __d('tasks', 'Use calendar') + ); + ?> + NetCommonsForm->error('TaskContent.use_calendar'); + //ADD + ?> diff --git a/View/TaskContents/view.ctp b/View/TaskContents/view.ctp index a6750d2..cc34c9e 100644 --- a/View/TaskContents/view.ctp +++ b/View/TaskContents/view.ctp @@ -45,6 +45,16 @@ echo $this->NetCommonsHtml->css('/tasks/css/tasks.css'); ); ?> + +
+ +
+ +
+ +
+ +
From d8563b4f9ea81a7a1ec6099123575bf9a2ca95e8 Mon Sep 17 00:00:00 2001 From: kitalab Date: Fri, 26 May 2017 21:56:21 +0900 Subject: [PATCH 2/3] =?UTF-8?q?=E3=82=AB=E3=83=AC=E3=83=B3=E3=83=80?= =?UTF-8?q?=E3=83=BC=E7=99=BB=E9=8C=B2=E3=82=B9=E3=83=86=E3=83=BC=E3=82=BF?= =?UTF-8?q?=E3=82=B9=E8=A1=A8=E7=A4=BA=E6=9D=A1=E4=BB=B6=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- View/TaskContents/view.ctp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/View/TaskContents/view.ctp b/View/TaskContents/view.ctp index cc34c9e..a2b568f 100644 --- a/View/TaskContents/view.ctp +++ b/View/TaskContents/view.ctp @@ -45,7 +45,7 @@ echo $this->NetCommonsHtml->css('/tasks/css/tasks.css'); ); ?>
- +
From 6e1002d2e8472bda0fd864e13ed8ffdad244dafe Mon Sep 17 00:00:00 2001 From: kitalab Date: Fri, 26 May 2017 22:59:40 +0900 Subject: [PATCH 3/3] =?UTF-8?q?=E7=B7=A8=E9=9B=86=E6=99=82=E3=81=AE?= =?UTF-8?q?=E3=82=AB=E3=83=AC=E3=83=B3=E3=83=80=E3=83=BC=E7=99=BB=E9=8C=B2?= =?UTF-8?q?=E6=9C=89=E7=84=A1=E3=83=81=E3=82=A7=E3=83=83=E3=82=AF=E5=88=A4?= =?UTF-8?q?=E5=AE=9A=E5=87=A6=E7=90=86=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controller/TaskContentEditController.php | 2 +- Model/TaskContent.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Controller/TaskContentEditController.php b/Controller/TaskContentEditController.php index d4ac243..07b16bf 100644 --- a/Controller/TaskContentEditController.php +++ b/Controller/TaskContentEditController.php @@ -150,7 +150,7 @@ public function edit() { $taskContent = $this->TaskContent->getTask($key); $calendarKey = $taskContent['TaskContent']['calendar_key']; //ADD カレンダ連携キーの取り出し - $taskContent['TaskContent']['use_calendar'] = !is_null($calendarKey) ? true : false; + $taskContent['TaskContent']['use_calendar'] = ($calendarKey == "") ? 0 : 1; if (! $this->request->data) { $this->request->data = $taskContent; } diff --git a/Model/TaskContent.php b/Model/TaskContent.php index 314cf0f..09f4552 100644 --- a/Model/TaskContent.php +++ b/Model/TaskContent.php @@ -718,7 +718,7 @@ public function saveContent($data) { 'isDelRepeat' => false, //tasksはfalse固定 )); $delCalendarKey = $this->CalendarDeleteActionPlan->deletePlanForLink($data); - if ($data['TaskContent']['calendar_key'] == $delCalendarKey) { +// if ($data['TaskContent']['calendar_key'] == $delCalendarKey) { //削除が成功したので、calenar_keyをクリアし、use_calendarをOFFにして、 //TaskContentにsave(update)しておく。 $data['TaskContent']['calendar_key'] = ''; @@ -728,7 +728,7 @@ public function saveContent($data) { throw new InternalErrorException(__d('net_commons', 'Internal Server Error')); } $data['TaskContent'] = $savedData['TaskContent']; - } +// } $this->CalendarDeleteActionPlan->Behaviors->unload('Calendars.CalendarLink'); } else { //calendar_keyが記録されていないので、なにもしない