function execute($requests)
 {
     $u = $GLOBALS['KTAI_C_MEMBER_ID'];
     $this->set('tail', $GLOBALS['KTAI_URL_TAIL']);
     if (!biz_isPermissionSchedule($u, $requests['schedule_id'])) {
         handle_kengen_error();
     }
     $this->set('schedule_id', $requests['schedule_id']);
     $this->set("t_id", $requests['target_id']);
     return 'success';
 }
 function execute($requests)
 {
     $u = $GLOBALS['AUTH']->uid();
     $this->set('inc_navi', fetch_inc_navi("h"));
     if (!biz_isPermissionSchedule($u, $requests['schedule_id'])) {
         handle_kengen_error();
     }
     $this->set('inc_navi', fetch_inc_navi('h'));
     $this->set('schedule_id', $requests['schedule_id']);
     $this->set("is_rep", $requests['is_rep']);
     return 'success';
 }
 function execute($requests)
 {
     $u = $GLOBALS['KTAI_C_MEMBER_ID'];
     $this->set('tail', $GLOBALS['KTAI_URL_TAIL']);
     if (!biz_isPermissionSchedule($u, $requests['schedule_id'])) {
         handle_kengen_error();
     }
     if (empty($requests['target_id']) || $requests['target_id'] == $u) {
         //自分自身
         $target_id = $u;
         $this->set('is_h', true);
         //判別フラグ
     } else {
         //他人
         $target_id = $requests['target_id'];
         $this->set('is_f', true);
         //判別フラグ
     }
     //日付・時刻を出す
     if (!is_null($requests['begin_date'])) {
         $begin_year = date("y", strtotime($requests['begin_date']));
         $begin_month = date("m", strtotime($requests['begin_date']));
         $begin_day = date("d", strtotime($requests['begin_date']));
     }
     if (!is_null($requests['begin_time'])) {
         $begin_hour = date("H", strtotime($requests['begin_time']));
         $begin_min = date("i", strtotime($requests['begin_time']));
     }
     if (!is_null($requests['finish_time'])) {
         $finish_hour = date("H", strtotime($requests['finish_time']));
         $finish_min = date("i", strtotime($requests['finish_time']));
     }
     $j_members = unserialize($requests['members']);
     if ($j_members) {
         sort($j_members);
     }
     $begin = array('year' => $begin_year, 'month' => $begin_month, 'day' => $begin_day, 'hour' => $begin_hour, 'min' => $begin_min);
     $finish = array('hour' => $finish_hour, 'min' => $finish_min);
     $this->set('begin', $begin);
     $this->set('finish', $finish);
     $this->set('title', $requests['title']);
     $this->set('value', $requests['value']);
     $this->set('schedule_id', $requests['schedule_id']);
     $this->set('member', $j_members);
     $this->set('member_e', $requests['members']);
     $this->set('writer', $requests['writer']);
     $this->set('t_id', $target_id);
     $this->set('msg', $requests['msg']);
     $this->set('public_flag', $requests['public_flag']);
     return 'success';
 }
 function execute($requests)
 {
     $u = $GLOBALS['AUTH']->uid();
     $sessid = session_id();
     if (!biz_isPermissionSchedule($u, $requests['schedule_id'])) {
         handle_kengen_error();
     }
     if ($requests['is_rep']) {
         $rep_schedule = biz_getRepeatScheduleID($requests['schedule_id']);
         foreach ($rep_schedule as $value) {
             biz_deleteSchedule($value);
         }
     } else {
         biz_deleteSchedule($requests['schedule_id']);
     }
     $p = array();
     openpne_redirect('pc', 'page_h_home', $p);
 }
 function execute($requests)
 {
     $u = $GLOBALS['KTAI_C_MEMBER_ID'];
     $tail = $GLOBALS['KTAI_URL_TAIL'];
     $target_id = $requests['target_id'];
     if (!biz_isPermissionSchedule($u, $requests['schedule_id'])) {
         handle_kengen_error();
     }
     if ($requests['is_rep']) {
         $rep_schedule = biz_getRepeatScheduleID($requests['schedule_id']);
         foreach ($rep_schedule as $value) {
             biz_deleteSchedule($value);
         }
     } else {
         biz_deleteSchedule($requests['schedule_id']);
     }
     $p = array('target_id' => $requests['target_id']);
     ktai_biz_openpne_redirect('ktai_biz', 'page_fh_calendar_week', $p);
 }
Пример #6
0
function biz_getDateMemberSchedule($y, $m, $d, $target_c_member_id, $u)
{
    $schedule = array();
    $contain = array();
    $tmp = biz_getDateSchedule($y, $m, $d);
    $sc_list = array();
    $biz_group_id_list = array();
    foreach (biz_getJoinGroup($target_c_member_id) as $value) {
        $biz_group_id_list[] = $value['biz_group_id'];
    }
    foreach ($tmp as $biz_schedule_id) {
        $biz_schedule = biz_getScheduleInfo($biz_schedule_id);
        $sql = 'SELECT c_member_id FROM biz_schedule_member WHERE biz_schedule_id = ?';
        $biz_schedule_member_id_list = db_get_col($sql, array(intval($biz_schedule_id)));
        // スケジュールに参加しているメンバー
        $members = biz_getJoinIdSchedule($biz_schedule_id);
        if (biz_isPermissionSchedule($u, $biz_schedule_id)) {
            if (in_array($target_c_member_id, $members)) {
                $contain[] = $biz_schedule_id;
            }
        }
    }
    $tmp = array_unique($tmp);
    foreach ($contain as $key => $value) {
        if (!is_null($value)) {
            //そのidの予定を得る
            $sql = 'SELECT * FROM biz_schedule WHERE biz_schedule_id = ?';
            $params = array(intval($value));
            $schedule += array($key => db_get_row($sql, $params));
        }
    }
    return $schedule;
}
 function execute($requests)
 {
     $u = $GLOBALS['KTAI_C_MEMBER_ID'];
     $this->set('tail', $GLOBALS['KTAI_URL_TAIL']);
     if (!biz_isPermissionSchedule($u, $requests['id'])) {
         handle_kengen_error();
     }
     if (empty($requests['target_id']) || $requests['target_id'] == $u) {
         //自分自身
         $target_id = $u;
         $this->set('is_h', true);
         //判別フラグ
     } else {
         //他人
         $target_id = $requests['target_id'];
         $this->set('is_f', true);
         //判別フラグ
     }
     $this->set('inc_navi', fetch_inc_navi("h"));
     //プロフィール
     $target_member = db_member_c_member4c_member_id($u);
     $this->set("target_member", $target_member);
     //カレンダー関係
     //カレンダー開始用変数
     $year = date("Y");
     $month = date("n");
     //カレンダー用変数
     $date_val = array('year' => $year, 'month' => $month, 'day' => null);
     $this->set("date_val", $date_val);
     //日記のカレンダー
     $calendar = db_common_diary_monthly_calendar($year, $month, $u);
     $this->set("calendar", $calendar['days']);
     $this->set("ym", $calendar['ym']);
     $list = biz_getScheduleInfo($requests['id']);
     //繰り返しフラグのチェック
     $dayofweek = array('日', '月', '火', '水', '木', '金', '土');
     foreach ($dayofweek as $key => $value) {
         if ($list['rep_type'] & 1 << $key) {
             $tmp .= $value;
         }
     }
     $list += array('rep_type_loc' => $tmp);
     $list += array('writer_name' => biz_getMemberNickname($list['c_member_id']));
     $list['begin_time'] = substr($list['begin_time'], 0, 5);
     $list['finish_time'] = substr($list['finish_time'], 0, 5);
     $jmembers = biz_getJoinMemberSchedule($requests['id']);
     if (array_search($target_member['nickname'], $jmembers)) {
         $jmembers[$target_member['c_member_id']] = $target_member['nickname'];
         $jmembers = array_unique($jmembers);
     }
     //参加者は10人目まで表示
     if (count($jmembers) > 10) {
         $jam = count($jmembers);
         while ($jam != 10) {
             array_pop($jmembers);
             $jam--;
         }
     }
     $this->set('jam', $jam);
     $this->set('schedule', $list);
     $this->set('jmembers', $jmembers);
     $this->set('jmembers_enc', serialize($jmembers));
     $this->set('schedule_id', $requests['id']);
     $this->set('w', $requests['w']);
     $this->set('is_h', true);
     $this->set('t_id', $target_id);
     if ($list['rep_type']) {
         //繰り返し予定の場合は開始日と期間をセット
         $repeat_begin = biz_getRepeatBegin($requests['id']);
         $repeat_finish = biz_getRepeatFinish($requests['id']);
         $repeat_term = strtotime($repeat_finish) - strtotime($repeat_begin);
         $daycount = $repeat_term / (24 * 60 * 60) / 7;
         $this->set('repeat_begin_date', $repeat_begin);
         $this->set('repeat_term', intval($daycount));
     }
     if ($list['rep_type']) {
         //繰り返し予定の場合はまとめて既読済みに
         $rep_schedule = biz_getRepeatScheduleID($requests['id']);
         foreach ($rep_schedule as $value) {
             biz_readSchedule($u, $value);
         }
     } else {
         biz_readSchedule($u, $requests['id']);
     }
     return 'success';
 }
 function execute($requests)
 {
     $u = $GLOBALS['AUTH']->uid();
     if (!biz_isPermissionSchedule($u, $requests['schedule_id'])) {
         handle_kengen_error();
     }
     $form_val['subject'] = $requests['subject'];
     $form_val['body'] = $requests['body'];
     $this->set('banner', $requests['sc_bn']);
     if ($requests['sc_title']) {
         $requests['title'] = $requests['sc_title'];
     }
     if ($requests['sc_memo']) {
         $requests['value'] = $requests['sc_memo'];
     }
     if ($requests['sc_b_year'] && $requests['sc_b_month'] && $requests['sc_b_date']) {
         $requests['begin_date'] = $requests['sc_b_year'] . '-' . $requests['sc_b_month'] . '-' . $requests['sc_b_date'];
     }
     if ($requests['sc_b_hour'] && $requests['sc_b_minute']) {
         $requests['begin_time'] = $requests['sc_b_hour'] . ':' . $requests['sc_b_minute'];
     }
     if ($requests['sc_f_hour'] && $requests['sc_f_minute']) {
         $requests['finish_time'] = $requests['sc_f_hour'] . ':' . $requests['sc_f_minute'];
     }
     $sessid = session_id();
     $schedule = biz_getScheduleInfo($requests['schedule_id']);
     if ($schedule['c_member_id'] == $u) {
         //自分自身
         $target_id = $u;
         $this->set('is_h', true);
         //判別フラグ
         $this->set('inc_navi', fetch_inc_navi('h'));
     } else {
         //他人
         $target_id = $requests['target_id'];
         $this->set('is_f', true);
         //判別フラグ
         $this->set('inc_navi', fetch_inc_navi('f'));
     }
     //プロフィール
     $this->set("target_member", db_member_c_member4c_member_id($u));
     $this->set("form_val", $form_val);
     //カレンダー関係
     //カレンダー開始用変数
     $year = date("Y");
     $month = date("n");
     //カレンダー用変数
     $date_val = array('year' => $year, 'month' => $month, 'day' => null);
     $this->set("date_val", $date_val);
     //日記のカレンダー
     $calendar = db_common_diary_monthly_calendar($year, $month, $u);
     $this->set("calendar", $calendar['days']);
     $this->set("ym", $calendar['ym']);
     //日付関連
     if ($requests['rep_type']) {
         $begin_date = biz_getRepeatBegin($requests['schedule_id']);
     } else {
         $begin_date = $requests['begin_date'];
     }
     $nowyear = date("Y", strtotime($begin_date));
     $nowmonth = date("m", strtotime($begin_date));
     $nowday = date("d", strtotime($begin_date));
     for ($i = $nowyear; $i <= $nowyear + 10; $i++) {
         if ($i == $nowyear) {
             $years = '<option value="' . $i . '" selected="selected">';
         } else {
             $years .= '<option value="' . $i . '">';
         }
         $years .= $i . '年';
         $years .= '</option>';
     }
     for ($i = 1; $i <= 12; $i++) {
         $i_f = sprintf("%02d", $i);
         //月は常に二桁
         if ($i == $nowmonth) {
             $monthes .= '<option value="' . $i_f . '" selected="selected">';
         } else {
             $monthes .= '<option value="' . $i_f . '">';
         }
         $monthes .= $i . '月';
         $monthes .= '</option>';
     }
     for ($i = 1; $i <= 31; $i++) {
         $i_f = sprintf("%02d", $i);
         //日は常に二桁
         if ($i == $nowday) {
             $days .= '<option value="' . $i_f . '" selected="selected">';
         } else {
             $days .= '<option value="' . $i_f . '">';
         }
         $days .= $i . '日';
         $days .= '</option>';
     }
     $hours = biz_makeSerialArray(23);
     //時
     $mins = biz_makeSerialArray(55, 0, 5);
     //分
     $wk = array('日', '月', '火', '水', '木', '金', '土');
     //週
     $rp_count = biz_makeSerialArray(12, 1);
     //繰り返し回数
     $bn_num = biz_makeSerialArray(31, 1);
     //日数
     $this->set('years', $years);
     $this->set('monthes', $monthes);
     $this->set('days', $days);
     $this->set('hours', $hours);
     $this->set('mins', $mins);
     $this->set('wk', $wk);
     $this->set('rp_count', $rp_count);
     $this->set('bn_num', $bn_num);
     $this->set('title', $requests['title']);
     $this->set('value', $requests['value']);
     if (!is_null($requests['begin_time'])) {
         $this->set('begin_hour', date("G", strtotime($requests['begin_time'])));
     }
     if (!is_null($requests['begin_time'])) {
         $begin_min = date("i", strtotime($requests['begin_time']));
         if (substr($begin_min, 0, 1) == '0') {
             $begin_min = substr($begin_min, 1, 1);
         }
     }
     if (!is_null($requests['begin_time'])) {
         $this->set('begin_min', $begin_min);
     }
     if (!is_null($requests['finish_time'])) {
         $this->set('finish_hour', date("G", strtotime($requests['finish_time'])));
     } else {
         $this->set('finish_hour', null);
     }
     if (!is_null($requests['finish_time'])) {
         $finish_min = date("i", strtotime($requests['finish_time']));
     }
     if (substr($finish_min, 0, 1) == '0') {
         $finish_min = substr($finish_min, 1, 1);
     }
     if (!is_null($requests['begin_time'])) {
         $this->set('finish_min', $finish_min);
     } else {
         $this->set('finish_min', null);
     }
     if ($requests['rep_type']) {
         $is_rep = true;
     } else {
         if ($requests['sc_rp']) {
             $is_rep = true;
         } else {
             $is_rep = false;
         }
     }
     $dayofweek = array();
     if (empty($requests['rep_type'])) {
         foreach ($requests['sc_rwk'] as $value) {
             $rp_rule += 1 << $value;
         }
         $requests['rep_type'] = $rp_rule;
     }
     for ($i = 0; $i <= 6; $i++) {
         if ($requests['rep_type'] & 1 << $i) {
             array_push($dayofweek, 1);
         } else {
             array_push($dayofweek, 0);
         }
     }
     $this->set('rep_type', $dayofweek);
     $this->set('is_rep', $is_rep);
     $this->set('schedule_id', $requests['schedule_id']);
     $repeat_begin = biz_getRepeatBegin($requests['schedule_id']);
     $repeat_finish = biz_getRepeatFinish($requests['schedule_id']);
     $repeat_term = strtotime($repeat_finish) - strtotime($repeat_begin);
     $daycount = $repeat_term / (24 * 60 * 60) / 6;
     $this->set('repeat_begin_date', $repeat_begin);
     if (isset($requests["sc_rcount"])) {
         $daycount = $requests["sc_rcount"];
     }
     $this->set('repeat_term', ceil($daycount));
     $biz_group_count = biz_getGroupCount($target_id);
     $biz_group_list = biz_getJoinGroupList($target_id, 1, $biz_group_count);
     $this->set('biz_group_list', $biz_group_list[0]);
     $this->set('target_biz_group_id', $schedule['biz_group_id']);
     if ($requests['public_flag']) {
         $this->set('public_flag', $requests['public_flag']);
     } else {
         $this->set('public_flag', $schedule['public_flag']);
     }
     //追加
     if ($requests['members']) {
         $j_members = array_keys(unserialize($requests['members']));
         sort($j_members);
     } elseif ($requests['sc_j_mem']) {
         $j_members = $requests['sc_j_mem'];
     } else {
         $j_members = biz_getJoinMemberSchedule($requests['schedule_id']);
     }
     $this->set('j_members', $j_members);
     $members = array();
     $sql = 'SELECT c_member_id, nickname FROM c_member';
     $members = db_get_all($sql, $params);
     $i = 0;
     foreach ($members as $key => $value) {
         if (in_array($value['c_member_id'], $j_members)) {
             $members[$key]['checkflag'] = 1;
             $i++;
         }
         if (count($j_members) < $i) {
             break;
         }
     }
     $this->set('members', $members);
     return 'success';
 }
 function execute($requests)
 {
     $u = $GLOBALS['KTAI_C_MEMBER_ID'];
     $tail = $GLOBALS['KTAI_URL_TAIL'];
     if (!biz_isPermissionSchedule($u, $requests['schedule_id'])) {
         handle_kengen_error();
     }
     $schedule = biz_getScheduleInfo($requests['schedule_id']);
     $requests['sc_b_year'] = $requests['sc_b_year'] + 2000;
     //ERROR----------------
     //存在しない日付
     if (!checkdate($requests['sc_b_month'], $requests['sc_b_date'], $requests['sc_b_year'])) {
         $redirect_script = '?m=ktai_biz&a=page_fh_biz_schedule_edit&' . $tail;
         $msg = urlencode('存在しない日付が指定されました。');
         $schedule = biz_getScheduleInfo($requests['schedule_id']);
         $begin_date = $schedule['begin_date'];
         //日付関連の引数は返さなくてもよい
         $url = $redirect_script . '&msg=' . $msg . '&begin_date=' . $begin_date . '&title=' . $requests['sc_title'] . '&sc_rp=' . $requests['sc_rp'] . '&value=' . $requests['sc_memo'] . '&members=' . $requests['sc_j_mem'] . '&writer=' . $requests['writer'] . '&schedule_id=' . $requests['schedule_id'];
         $_REQUEST['schedule_id'] = $requests['schedule_id'];
         $_REQUEST['msg'] = '存在しない日付が指定されました。';
         openpne_forward('ktai_biz', 'page', "fh_biz_schedule_edit");
         exit;
     }
     //---------------------
     //ERROR----------------
     //タイトル未入力
     if (empty($requests['sc_title'])) {
         $redirect_script = '?m=ktai_biz&a=page_fh_biz_schedule_edit&id=' . $requests['schedule_id'] . '&' . $tail;
         $msg = urlencode('タイトルを入力してください。');
         $begin_date = $requests['sc_b_year'] . '-' . $requests['sc_b_month'] . '-' . $requests['sc_b_date'];
         $url = $redirect_script . '&msg=' . $msg . '&begin_date=' . $begin_date . '&sc_rp=' . $requests['sc_rp'] . '&sc_memo=' . $requests['sc_memo'] . '&members=' . $requests['sc_j_mem'] . '&writer=' . $requests['writer'] . '&sc_rwk_enc=' . serialize($requests['sc_rwk_enc']) . '&sc_rcount=' . $requests['sc_rcount'] . '&schedule_id=' . $requests['schedule_id'];
         $_REQUEST['schedule_id'] = $requests['schedule_id'];
         $_REQUEST['msg'] = 'タイトルを入力してください。';
         openpne_forward('ktai_biz', 'page', "fh_biz_schedule_edit");
         exit;
     }
     //---------------------
     if ($requests['sc_b_hour'] && !$requests['sc_b_minute']) {
         $requests['sc_b_minute'] = '00';
     }
     if ($requests['sc_f_hour'] && !$requests['sc_f_minute']) {
         $requests['sc_f_minute'] = '00';
     }
     //日付のフォーマットを設定
     $begin_date = $requests['sc_b_year'] . '-' . $requests['sc_b_month'] . '-' . $requests['sc_b_date'];
     $begin_time = $requests['sc_b_hour'] . ':' . $requests['sc_b_minute'];
     $finish_time = $requests['sc_f_hour'] . ':' . $requests['sc_f_minute'];
     //ERROR---------------
     if (strtotime($finish_time) < strtotime($begin_time) && $finish_time != ':') {
         //終了時間と開始時間が変
         $redirect_script = '?m=ktai_biz&a=page_fh_biz_schedule_edit&id=' . $requests['schedule_id'] . '&' . $tail;
         $msg = urlencode('終了時刻が開始時刻より先です。');
         $begin_date = $requests['sc_b_year'] . '-' . $requests['sc_b_month'] . '-' . $requests['sc_b_date'];
         $url = $redirect_script . '&msg=' . $msg . '&begin_date=' . $begin_date . '&sc_title=' . $requests['sc_title'] . '&sc_rp=' . $requests['sc_rp'] . '&sc_memo=' . $requests['sc_memo'] . '&members=' . $requests['sc_j_mem'] . '&writer=' . $requests['writer'] . '&sc_rwk_enc=' . serialize($requests['sc_rwk_enc']) . '&sc_rcount=' . $requests['sc_rcount'] . '&schedule_id=' . $requests['schedule_id'];
         $_REQUEST['schedule_id'] = $requests['schedule_id'];
         $_REQUEST['msg'] = '終了時刻が開始時刻より先です。';
         openpne_forward('ktai_biz', 'page', "fh_biz_schedule_edit");
         exit;
     }
     //--------------------
     $mem = unserialize($requests['sc_j_mem']);
     $requests['sc_j_mem'] = array();
     $i = 0;
     if ($mem) {
         foreach ($mem as $key => $value) {
             $requests['sc_j_mem'][$i] = $key;
             $i++;
         }
     }
     if (!($requests['sc_b_hour'] || $requests['sc_b_minute'] || $requests['sc_f_hour'] || $requests['sc_f_minute'])) {
         //時刻指定なし
         $begin_time = $finish_time = null;
     } elseif (!($requests['sc_f_hour'] || $requests['sc_f_minute'])) {
         $finish_time = null;
     }
     $finish_date = $begin_date;
     //当日中に終わる予定は、開始日と終了日は同一でなければならない
     $schedule_id = '';
     $biz_schedule_member = biz_getJoinIdSchedule($requests['schedule_id']);
     biz_editSchedule($requests['sc_title'], $schedule['c_member_id'], $begin_date, $finish_date, $begin_time, $finish_time, $requests['sc_memo'], $rp_rule, 0, $requests['sc_j_mem'], $requests['public_flag'], $requests['schedule_id'], $biz_schedule_member);
     $schedule_id = $requests['schedule_id'];
     $first_id = biz_getScheduleMax() + 1;
     //登録される予定のプライマリキー
     $week = date("W", abs(strtotime($begin_date) - strtotime(date("Y-m-d")))) - 1;
     if (strtotime($begin_date) - strtotime(date('Y-m-d')) < 0) {
         $week = $week - $week * 2;
     }
     $_REQUEST['msg'] = '予定を編集しました。';
     $_REQUEST['w'] = $week;
     $_REQUEST['target_id'] = $requests['target_id'];
     $_REQUEST['id'] = biz_getScheduleMax();
     openpne_forward('ktai_biz', 'page', "fh_calendar_week");
     exit;
 }
Пример #10
0
 function execute($requests)
 {
     $u = $GLOBALS['AUTH']->uid();
     if (!biz_isPermissionSchedule($u, $requests['id'])) {
         handle_kengen_error();
     }
     $form_val['subject'] = $requests['subject'];
     $form_val['body'] = $requests['body'];
     $sessid = session_id();
     if (empty($requests['target_id']) || $requests['target_id'] == $u) {
         //自分自身
         $target_id = $u;
         $this->set('is_h', true);
         //判別フラグ
         $this->set('inc_navi', fetch_inc_navi('h'));
     } else {
         //他人
         $target_id = $requests['target_id'];
         $this->set('is_f', true);
         //判別フラグ
         $this->set('inc_navi', fetch_inc_navi('f', $requests['target_id']));
     }
     //プロフィール
     $target_member = db_member_c_member4c_member_id($u);
     $this->set("target_member", $target_member);
     $this->set("form_val", $form_val);
     $this->set("target_c_member_id", $requests['target_id']);
     //カレンダー関係
     //カレンダー開始用変数
     $year = date("Y");
     $month = date("n");
     //カレンダー用変数
     $date_val = array('year' => $year, 'month' => $month, 'day' => null);
     $this->set("date_val", $date_val);
     //日記のカレンダー
     $calendar = db_common_diary_monthly_calendar($year, $month, $u);
     $this->set("calendar", $calendar['days']);
     $this->set("ym", $calendar['ym']);
     $list = biz_getScheduleInfo($requests['id']);
     //繰り返しフラグのチェック
     $dayofweek = array('日', '月', '火', '水', '木', '金', '土');
     foreach ($dayofweek as $key => $value) {
         if ($list['rep_type'] & 1 << $key) {
             $tmp .= $value;
         }
     }
     $list['rep_type_loc'] = $tmp;
     $list['writer_name'] = biz_getMemberNickname($list['c_member_id']);
     $list['begin_time'] = substr($list['begin_time'], 0, 5);
     $list['finish_time'] = substr($list['finish_time'], 0, 5);
     $jmembers = biz_getJoinMemberSchedule($requests['id']);
     if (array_search($target_member['nickname'], $jmembers)) {
         $jmembers[$target_member['c_member_id']] = $target_member['nickname'];
     } else {
         $list['target_c_member_nickname'] = biz_getMemberNickname($requests['target_id']);
     }
     $this->set('jmembers', $jmembers);
     $this->set('schedule', $list);
     $this->set('jmembers', $jmembers);
     $this->set('jmembers_enc', serialize($jmembers));
     $this->set('schedule_id', $requests['id']);
     $this->set('w', $requests['w']);
     $this->set('is_h', true);
     if ($list['rep_type']) {
         //繰り返し予定の場合は開始日と期間をセット
         $repeat_begin = biz_getRepeatBegin($requests['id']);
         $repeat_finish = biz_getRepeatFinish($requests['id']);
         $repeat_term = strtotime($repeat_finish) - strtotime($repeat_begin);
         $daycount = ceil($repeat_term / (24 * 60 * 60) / 6);
         if ($repeat_finish == $repeat_begin) {
             $daycount = 1;
         }
         $this->set('repeat_begin_date', $repeat_begin);
         $this->set('repeat_term', ceil($daycount));
     } else {
         // 繰り返さない予定の場合、日数をセット
         $term = strtotime($list["finish_date"]) - strtotime($list["begin_date"]);
         $daycount = ceil($term / (24 * 60 * 60)) + 1;
         $this->set('sc_bn', $daycount);
     }
     if ($list['rep_type']) {
         //繰り返し予定の場合はまとめて既読済みに
         $rep_schedule = biz_getRepeatScheduleID($requests['id']);
         foreach ($rep_schedule as $value) {
             biz_readSchedule($u, $value);
         }
     } else {
         biz_readSchedule($u, $requests['id']);
     }
     return 'success';
 }
Пример #11
0
 function execute($requests)
 {
     $u = $GLOBALS['AUTH']->uid();
     $sessid = session_id();
     if (!biz_isPermissionSchedule($u, $requests['schedule_id'])) {
         handle_kengen_error();
     }
     $schedule = biz_getScheduleInfo($requests['schedule_id']);
     if ($requests['sc_b_hour'] && !$requests['sc_b_minute']) {
         $requests['sc_b_minute'] = '00';
     }
     if ($requests['sc_f_hour'] && !$requests['sc_f_minute']) {
         $requests['sc_f_minute'] = '00';
     }
     //日付のフォーマットを設定
     $begin_date = $requests['sc_b_year'] . '-' . $requests['sc_b_month'] . '-' . $requests['sc_b_date'];
     if ($requests['sc_b_hour'] && $requests['sc_b_minute']) {
         $begin_time = $requests['sc_b_hour'] . ':' . $requests['sc_b_minute'];
     }
     if ($requests['sc_f_hour'] && $requests['sc_f_minute']) {
         $finish_time = $requests['sc_f_hour'] . ':' . $requests['sc_f_minute'];
     }
     // エラー遷移用
     $_REQUEST['begin_date'] = $begin_date;
     $_REQUEST['begin_time'] = $begin_time;
     $_REQUEST['finish_time'] = $finish_time;
     if (!checkdate($requests['sc_b_month'], $requests['sc_b_date'], $requests['sc_b_year'])) {
         $_REQUEST['msg'] = '存在しない日付が指定されました。';
         openpne_forward('biz', 'page', 'fh_biz_schedule_edit');
         exit;
     }
     if ($requests['sc_rp'] && empty($requests['sc_rwk'])) {
         $_REQUEST['msg'] = '繰り返し予定を登録する場合は、曜日を指定してください。';
         openpne_forward('biz', 'page', 'fh_biz_schedule_edit');
         exit;
     }
     if (strtotime($finish_time) < strtotime($begin_time) && isset($finish_time)) {
         $_REQUEST['msg'] = '終了時刻が開始時刻より先です。';
         openpne_forward('biz', 'page', 'fh_biz_schedule_edit');
         exit;
     }
     if ($requests['public_flag'] == 'group' && empty($requests['biz_group_id'])) {
         $_REQUEST['msg'] = '「グループまで公開」予定の場合はグループを指定してください';
         openpne_forward('biz', 'page', 'fh_biz_schedule_edit');
         exit;
     }
     //施設、参加者のチェック
     if (in_array('0', $requests['sc_j_mem'])) {
         //「全員」が含まれている場合は、配列を空に
         $requests['sc_j_mem'] = array();
     }
     if (!($requests['sc_b_hour'] || $requests['sc_b_minute'] || $requests['sc_f_hour'] || $requests['sc_f_minute'])) {
         //時刻指定なし
         $begin_time = $finish_time = null;
     } elseif (!($requests['sc_f_hour'] || $requests['sc_f_minute'])) {
         $finish_time = null;
     }
     if (!$requests['sc_rp'] && $requests['sc_bn'] == 1) {
         //当日中に終わる予定は、開始日と終了日は同一でなければならない
         $finish_date = $begin_date;
     }
     $schedule_id = '';
     if (!$requests['sc_rp']) {
         //繰り返しなし
         $finish_date = date("Y-m-d", strtotime($requests['sc_b_year'] . '-' . $requests['sc_b_month'] . '-' . ($requests['sc_b_date'] + ($requests['sc_bn'] - 1))));
         //繰り返しをしない予定登録
         biz_editSchedule($requests['sc_title'], $schedule['c_member_id'], $begin_date, $finish_date, $begin_time, $finish_time, $requests['sc_memo'], $rp_rule, 0, $requests['biz_group_id'], $requests['public_flag'], $requests['schedule_id'], $requests['sc_j_mem']);
         $schedule_id = $requests['schedule_id'];
     } else {
         //終了日の決定
         if (in_array(date('w', strtotime($begin_date)), $requests['sc_rwk'])) {
             $finish_date = date("Y-m-d", strtotime($begin_date . ' + ' . ($requests['sc_rcount'] - 1) * 7 . 'days'));
         } else {
             $finish_date = date("Y-m-d", strtotime($begin_date . ' + ' . $requests['sc_rcount'] * 7 . 'days'));
         }
         //繰り返しルールの決定
         foreach ($requests['sc_rwk'] as $value) {
             $rp_rule += 1 << $value;
         }
         //繰り返し予定
         $tmp = strtotime($begin_date);
         //処理中の日付
         if ($requests['iskeep']) {
             //繰り返し予定グループの維持(同予定から派生した繰り返し予定を一斉に編集)
             $replist = biz_getRepeatScheduleID($requests['schedule_id']);
             foreach ($replist as $value) {
                 biz_deleteSchedule($value);
                 //既存の繰り返し予定をすべて削除(予定日数の追加、削除のケースがありうるため)
             }
         }
         $first_id = biz_getScheduleMax() + 1;
         //登録される予定のプライマリキー
         for ($i = 0; $tmp < strtotime($finish_date); $i++) {
             //終了日に達するまで新規予定追加を繰り返す
             $nowday = strtotime($begin_date . ' +' . $i . 'days');
             $tmp = $nowday;
             if ($rp_rule & 1 << date("w", $nowday)) {
                 biz_insertSchedule($requests['sc_title'], $schedule['c_member_id'], date("Y-m-d", $tmp), date("Y-m-d", $tmp), $begin_time, $finish_time, $requests['sc_memo'], $rp_rule, $first_id, $requests['biz_group_id'], $requests['public_flag'], $requests['sc_j_mem']);
             }
         }
         $schedule_id = biz_getScheduleMax();
     }
     $week = date("W", abs(strtotime($begin_date) - strtotime(date("Y-m-d")))) - 1;
     $p = array('w' => $week, 'msg' => '予定を編集しました。', 'id' => $schedule_id, 'target_id' => $target_id);
     openpne_redirect('biz', 'page_fh_biz_schedule_view', $p);
 }