function checkInputdata()
 {
     $vpn_id = @$this->request['vpn_id'];
     // 名称
     if (!$this->oMgr->checkEmpty($this->request['vpn_name'])) {
         // エラーメッセージをセット
         $this->oMgr->setErr('E001', "ネットワークポリシー名");
     } else {
         if ($this->oMgr->existsVpnName($this->request['vpn_name'], $vpn_id)) {
             $this->oMgr->setErr('E017', "ネットワークポリシー名");
         }
     }
     // グループ名
     if (!$this->oMgr->checkEmpty($this->request['group_name'])) {
         // エラーメッセージをセット
         $this->oMgr->setErr('E001', "グループ/プロジェクト名");
     } else {
         if ($this->oMgr->existsGroupName($this->request['group_name'], $vpn_id)) {
             $this->oMgr->setErr('E017', "グループ/プロジェクト名");
         }
     }
     // グループコード
     $this->request['group_code'] = string::zen2han($this->request['group_code']);
     if (!$this->oMgr->checkEmpty($this->request['group_code'])) {
         //
         $this->oMgr->setErr('E001', "グループコード");
     } else {
         if (!ereg("^[A-Z]{2}\$", $this->request['group_code'])) {
             // エラーメッセージをセット
             $param = array();
             $param[0] = "グループコード";
             $param[1] = "英字大文字2文字";
             $this->oMgr->setErr('E004', $param);
         } else {
             if ($this->oMgr->existsGroupCode($this->request['group_code'], $vpn_id)) {
                 $this->oMgr->setErr('E017', "グループコード");
             }
         }
     }
     // 管理者
     if (!is_array($this->request['admin_id']) || count($this->request['admin_id']) == 0) {
         // エラーメッセージをセット
         $this->oMgr->setErr('E007', "管理者");
     }
     // エラーなし
     if (sizeof($this->oMgr->aryErrMsg) == 0) {
         return true;
     }
     // エラー発生
     $this->errMsg = $this->oMgr->getErrMsg();
     return false;
 }
 function checkInputdata()
 {
     $user_id = @$this->request['user_id'];
     if ($user_id != "") {
         $aryOld = $this->oMgr->getUserData($user_id);
         $old_login_id = $aryOld['login_id'];
         $old_mail_acc = $aryOld['mail_acc'];
         unset($aryOld);
     }
     // 職員番号
     if (!$this->oMgr->checkEmpty($this->request['staff_id'])) {
         // エラーメッセージをセット
         //$this->oMgr->setErr('E001',"職員ID");
     } else {
         if (!string::strlen($this->request['staff_id']) > STAFF_ID_LEN) {
             // エラーメッセージをセット
             $param = array();
             $param[0] = "職員番号";
             $param[1] = "半角" . STAFF_ID_LEN . "桁以内";
             $this->oMgr->setErr('E004', $param);
         } else {
             if ($this->oMgr->existsStaffId($this->request['staff_id'], $user_id)) {
                 $this->oMgr->setErr('E017', "職員番号");
             }
         }
     }
     // 漢字姓
     if (!$this->oMgr->checkEmpty($this->request['kanjisei'])) {
         // エラーメッセージをセット
         $this->oMgr->setErr('E001', "氏名(姓)");
     }
     // 漢字名
     if (!$this->oMgr->checkEmpty($this->request['kanjimei'])) {
         // エラーメッセージをセット
         $this->oMgr->setErr('E001', "氏名(名)");
     }
     // カナ姓
     $this->request['kanasei'] = string::han2zen($this->request['kanasei']);
     if (!$this->oMgr->checkEmpty($this->request['kanasei'])) {
         // エラーメッセージをセット
         $this->oMgr->setErr('E001', "氏名カナ(姓)");
     } else {
         if (!string::chackKatakana3($this->request['kanasei'])) {
             // エラーメッセージをセット
             $param = array();
             $param[0] = '氏名カナ(姓)';
             $param[1] = 'カタカナ';
             $this->oMgr->setErr('E004', $param);
         }
     }
     // カナ名
     $this->request['kanamei'] = string::han2zen($this->request['kanamei']);
     if (!$this->oMgr->checkEmpty($this->request['kanamei'])) {
         // エラーメッセージをセット
         $this->oMgr->setErr('E001', "氏名カナ(名)");
     } else {
         if (!string::chackKatakana3($this->request['kanamei'])) {
             // エラーメッセージをセット
             $param = array();
             $param[0] = '氏名カナ(名)';
             $param[1] = 'カタカナ';
             $this->oMgr->setErr('E004', $param);
         }
     }
     // 英字姓
     $this->request['eijisei'] = string::zen2han($this->request['eijisei']);
     $this->request['eijisei'] = strtolower($this->request['eijisei']);
     $chkEijisei = str_replace("-", "", $this->request['eijisei']);
     if (!$this->oMgr->checkEmpty($this->request['eijisei'])) {
         // 任意
     } else {
         if (!string::checkAlphabet($chkEijisei)) {
             // エラーメッセージをセット
             $param = array();
             $param[0] = '氏名英字(姓)';
             $param[1] = '半角英字';
             $this->oMgr->setErr('E004', $param);
         }
     }
     // 英字名
     $this->request['eijimei'] = string::zen2han($this->request['eijimei']);
     $this->request['eijimei'] = strtolower($this->request['eijimei']);
     $chkEijimei = str_replace("-", "", $this->request['eijimei']);
     if (!$this->oMgr->checkEmpty($this->request['eijimei'])) {
         // 任意
     } else {
         if (!string::checkAlphabet($chkEijimei)) {
             // エラーメッセージをセット
             $param = array();
             $param[0] = '氏名英字(名)';
             $param[1] = '半角英字';
             $this->oMgr->setErr('E004', $param);
         }
     }
     // HIS連携する場合
     if ($this->request['his_flg'] == '1') {
         // 性別
         $this->request['sex'] = (string) $this->request['sex'];
         if (!$this->oMgr->checkEmpty($this->request['sex'])) {
             // エラーメッセージをセット
             $this->oMgr->setErr('E007', "性別");
         }
         // 生年月日
         if (!$this->oMgr->checkEmpty($this->request['birth_year'])) {
             // エラーメッセージをセット
             $this->oMgr->setErr('E007', "生年月日(年)");
         }
         if (!$this->oMgr->checkEmpty($this->request['birth_mon'])) {
             // エラーメッセージをセット
             $this->oMgr->setErr('E007', "生年月日(月)");
         }
         if (!$this->oMgr->checkEmpty($this->request['birth_day'])) {
             // エラーメッセージをセット
             $this->oMgr->setErr('E007', "生年月日(日)");
         }
     }
     // 生年月日に入力がある場合
     if ($this->request['birth_year'] != "" || $this->request['birth_mon'] != "" || $this->request['birth_day'] != "") {
         if ($this->request['birth_year'] == "" || $this->request['birth_mon'] == "" || $this->request['birth_day'] == "") {
             // エラーメッセージをセット
             $this->oMgr->setErr('E006', "生年月日");
         } else {
             if (!checkdate($this->request['birth_mon'], $this->request['birth_day'], $this->request['birth_year'])) {
                 // エラーメッセージをセット
                 $this->oMgr->setErr('E013', "生年月日");
             }
         }
     }
     // 統合ID
     $this->request['login_id'] = string::zen2han($this->request['login_id']);
     $this->request['login_id'] = strtolower($this->request['login_id']);
     // 元データと変わってない場合チェックしない
     if ($old_login_id == $this->request['login_id']) {
         // 不明ユーザー(元データが空)の場合、パスワードとの相互必須チェック
         if ($old_login_id == "" && $this->request['login_passwd'] != "") {
             $this->oMgr->setErr('E001', "統合ID");
         }
     } else {
         if (!$this->oMgr->checkEmpty($this->request['login_id'])) {
             // 任意
             if ($this->request['mail_acc'] != "") {
                 $this->oMgr->setErr('E001', "統合ID");
             }
         } else {
             if (string::strlen($this->request['login_id']) > 20) {
                 // エラーメッセージをセット
                 $param = array();
                 $param[0] = '統合ID';
                 $param[1] = '20文字以内';
                 $this->oMgr->setErr('E004', $param);
             } else {
                 if (!ereg("^[a-z]+\\.[a-z]+\\.[a-z]{2}\$", $this->request['login_id'])) {
                     // エラーメッセージをセット
                     $param = array();
                     $param[0] = '統合ID';
                     $param[1] = '姓.名.規定の英字2文字';
                     $this->oMgr->setErr('E004', $param);
                 } else {
                     list($sei, $mei, $rand) = explode(".", $this->request['login_id']);
                     $aryRandStr = $this->oMgr->getAry('rand_tow_chars');
                     if (!in_array($rand, $aryRandStr)) {
                         // エラーメッセージをセット
                         $param = array();
                         $param[0] = '統合ID';
                         $param[1] = '姓.名.規定の英字2文字';
                         $this->oMgr->setErr('E004', $param);
                     } else {
                         if ($this->oMgr->existsLoginId($this->request['login_id'], $user_id)) {
                             $this->oMgr->setErr('E017', "統合ID");
                         }
                     }
                 }
             }
         }
     }
     // パスワード
     $this->request['login_passwd'] = string::zen2han($this->request['login_passwd']);
     if (!$this->oMgr->checkEmpty($this->request['login_passwd'])) {
         // 任意
         if ($this->request['login_id'] != "" && $user_id == "") {
             $this->oMgr->setErr('E001', "パスワード");
         } else {
             if ($this->request['login_id'] != "" && $this->request['is_unknown_user']) {
                 $this->oMgr->setErr('E001', "パスワード");
             }
         }
     } else {
         $passwd = $this->request['login_passwd'];
         if (!string::checkAlphanumWide($passwd, 6, 20) || !ereg("[0-9]", $passwd) || !ereg("[a-z]", $passwd) || !ereg("[A-Z]", $passwd)) {
             $param = array();
             $param[0] = "パスワード";
             $param[1] = "数字、英字大文字、英字小文字を各1文字以上使用し、6~20文字";
             // エラーメッセージをセット
             $this->oMgr->setErr('E004', $param);
         }
     }
     // メールアカウント
     $mailMsg = "";
     if (!$this->oMgr->checkEmpty($this->request['mail_acc'])) {
         //
     } else {
         if (!$this->oMgr->checkNcvcMailAcc($this->request['mail_acc'], "メールアカウント", &$mailMsg)) {
             // エラーメッセージをセット
             $this->oMgr->pushError($mailMsg);
         } else {
             if ($this->oMgr->existsMailAcc($this->request['mail_acc'], $user_id)) {
                 $this->oMgr->setErr('E017', "メールアカウント");
             } else {
                 if ($this->oMgr->existsMlistAcc($this->request['mail_acc'])) {
                     // メーリングリストとして使用中
                     $this->oMgr->setErr('E017', "メールアカウント");
                 } else {
                     if ($this->request['mail_acc'] == $this->request['login_id']) {
                         // 変わった場合だけ
                         if ($old_mail_acc != $this->request['mail_acc']) {
                             $param = array();
                             $param[0] = "メールアカウント";
                             $param[1] = "統合ID以外の文字列";
                             $this->oMgr->setErr('E004', $param);
                         }
                     }
                 }
             }
         }
     }
     // 所属
     if (!$this->oMgr->checkEmpty($this->request['belong_chg_id'])) {
         // エラーメッセージをセット
         //$this->oMgr->setErr('E007',"所属");
     }
     // 職種
     if (!$this->oMgr->checkEmpty($this->request['job_id'])) {
         // エラーメッセージをセット
         //$this->oMgr->setErr('E007',"職種");
     }
     // 内線
     $this->request['naisen'] = string::zen2han($this->request['naisen']);
     if (!$this->oMgr->checkEmpty($this->request['naisen'])) {
         // 任意
     } else {
         if (!string::checkNumber($this->request['naisen'], 4)) {
             // エラーメッセージをセット
             $param = array();
             $param[0] = "内線";
             $param[1] = "半角数字4桁";
             $this->oMgr->setErr('E004', $param);
         }
     }
     // PHS番号
     $this->request['pbno'] = string::zen2han($this->request['pbno']);
     if (!$this->oMgr->checkEmpty($this->request['pbno'])) {
         // 任意
     } else {
         if (!string::checkNumber($this->request['pbno'], 4)) {
             // エラーメッセージをセット
             $param = array();
             $param[0] = "PHS番号";
             $param[1] = "半角数字4桁";
             $this->oMgr->setErr('E004', $param);
         }
     }
     // 常勤/非常勤
     if (!$this->oMgr->checkEmpty($this->request['joukin_kbn'])) {
         // エラーメッセージをセット
         $this->oMgr->setErr('E007', "常勤/非常勤");
     }
     // HIS連携する場合
     if ($this->request['his_flg'] == '1') {
         $this->request['staffcode'] = string::zen2han($this->request['staffcode']);
         $this->request['kananame'] = string::han2zen($this->request['kananame']);
         $this->request['password'] = string::zen2han($this->request['password']);
         $this->request['appcode'] = string::zen2han($this->request['appcode']);
         $this->checkHisData();
     }
     // 複数HIS連携データがある場合
     if (is_array($this->request['sub_his_flg'])) {
         foreach ($this->request['sub_his_flg'] as $no => $val) {
             if ($val != "1") {
                 continue;
             }
             $this->request['sub_staffcode'][$no] = string::zen2han($this->request['sub_staffcode'][$no]);
             $this->request['sub_kananame'][$no] = string::han2zen($this->request['sub_kananame'][$no]);
             $this->request['sub_password'][$no] = string::zen2han($this->request['sub_password'][$no]);
             $this->request['sub_appcode'][$no] = string::zen2han($this->request['sub_appcode'][$no]);
             $this->checkHisData($no);
         }
     }
     $has_date_err = false;
     // 利用期間
     if (!$this->oMgr->checkEmpty($this->request['start_date'])) {
         // エラーメッセージをセット
         $this->oMgr->setErr('E001', "利用期間(開始日)");
         $has_date_err = true;
     } else {
         if (!$this->oMgr->checkDateFormat($this->request['start_date'])) {
             // エラーメッセージをセット
             $param = array();
             $param[0] = "利用期間(開始日)";
             $param[1] = "yyyy/mm/dd";
             $this->oMgr->setErr('E004', $param);
             $has_date_err = true;
         } else {
             if (!$this->oMgr->checkDate($this->request['start_date'])) {
                 // エラーメッセージをセット
                 $this->oMgr->setErr('E013', "利用期間(開始日)");
                 $has_date_err = true;
             }
         }
     }
     // 利用期間
     if (!$this->oMgr->checkEmpty($this->request['end_date'])) {
         // エラーメッセージをセット
         //$this->oMgr->setErr('E001',"利用期間(終了日)");
         $has_date_err = true;
     } else {
         if (!$this->oMgr->checkDateFormat($this->request['end_date'])) {
             // エラーメッセージをセット
             $param = array();
             $param[0] = "利用期間(終了日)";
             $param[1] = "yyyy/mm/dd";
             $this->oMgr->setErr('E004', $param);
             $has_date_err = true;
         } else {
             if (!$this->oMgr->checkDate($this->request['end_date'])) {
                 // エラーメッセージをセット
                 $this->oMgr->setErr('E013', "利用期間(終了日)");
                 $has_date_err = true;
             }
         }
     }
     if (!$has_date_err) {
         if (!$this->oMgr->checkDateTerm($this->request['start_date'], $this->request['end_date'])) {
             // エラーメッセージをセット
             $param = array();
             $param[0] = "利用期間(開始日)";
             $param[1] = "利用期間(終了日)";
             $this->oMgr->setErr('E012', $param);
         }
     }
     // エラーなし
     if (sizeof($this->oMgr->aryErrMsg) == 0) {
         return true;
     }
     // エラー発生
     $this->errMsg = $this->oMgr->getErrMsg();
     return false;
 }
 function checkKyotoCardData()
 {
     // 所属情報1~4
     for ($i = 1; $i <= 4; $i++) {
         $col = "belong_info_" . $i;
         $nam = "所属情報" . string::han2zen($i);
         // 半角に変換
         $this->request[$col] = string::zen2han($this->request[$col]);
         if (!$this->oMgr->checkEmpty($this->request[$col])) {
             //				if ($i == 1)
             //				{
             //					$this->oMgr->setErr('E001', $nam);
             //				}
         } else {
             if (!(string::checkNumber($this->request[$col], 8) || string::checkNumber($this->request[$col], 10))) {
                 // エラーメッセージをセット
                 $param = array();
                 $param[0] = $nam;
                 $param[1] = '半角数字8桁か10桁';
                 $this->oMgr->setErr('E004', $param);
             }
         }
     }
     // キー番号
     $this->request['key_number'] = string::zen2han($this->request['key_number']);
     if (!$this->oMgr->checkEmpty($this->request['key_number'])) {
         $this->oMgr->setErr('E001', "キー番号");
     } else {
         if (!string::checkAlphanum($this->request['key_number'])) {
             // エラーメッセージをセット
             $param = array();
             $param[0] = "キー番号";
             $param[1] = '半角英数字';
             $this->oMgr->setErr('E004', $param);
         }
     }
     // UID
     $this->request['uid'] = string::zen2han($this->request['uid']);
     if (!$this->oMgr->checkEmpty($this->request['uid'])) {
         $this->oMgr->setErr('E001', "UID");
     } else {
         if (!string::checkAlphanum($this->request['uid'])) {
             // エラーメッセージをセット
             $param = array();
             $param[0] = "UID";
             $param[1] = '半角英数字';
             $this->oMgr->setErr('E004', $param);
         }
     }
     // 利用期間
     if (!$this->oMgr->checkEmpty($this->request['start_date'])) {
         // エラーメッセージをセット
         $this->oMgr->setErr('E001', "利用期間(開始日)");
         $has_date_err = true;
     } else {
         if (!$this->oMgr->checkDateFormat($this->request['start_date'])) {
             // エラーメッセージをセット
             $param = array();
             $param[0] = "利用期間(開始日)";
             $param[1] = "yyyy/mm/dd";
             $this->oMgr->setErr('E004', $param);
             $has_date_err = true;
         } else {
             if (!$this->oMgr->checkDate($this->request['start_date'])) {
                 // エラーメッセージをセット
                 $this->oMgr->setErr('E013', "利用期間(開始日)");
                 $has_date_err = true;
             }
         }
     }
     // 利用期間
     if (!$this->oMgr->checkEmpty($this->request['end_date'])) {
         // エラーメッセージをセット
         $this->oMgr->setErr('E001', "利用期間(終了日)");
         $has_date_err = true;
     } else {
         if (!$this->oMgr->checkDateFormat($this->request['end_date'])) {
             // エラーメッセージをセット
             $param = array();
             $param[0] = "利用期間(終了日)";
             $param[1] = "yyyy/mm/dd";
             $this->oMgr->setErr('E004', $param);
             $has_date_err = true;
         } else {
             if (!$this->oMgr->checkDate($this->request['end_date'])) {
                 // エラーメッセージをセット
                 $this->oMgr->setErr('E013', "利用期間(終了日)");
                 $has_date_err = true;
             }
         }
     }
     if (!$has_date_err) {
         if (!$this->oMgr->checkDateTerm($this->request['start_date'], $this->request['end_date'])) {
             // エラーメッセージをセット
             $param = array();
             $param[0] = "利用期間(開始日)";
             $param[1] = "利用期間(終了日)";
             $this->oMgr->setErr('E012', $param);
         }
     }
     // エラーなし
     if (sizeof($this->oMgr->aryErrMsg) == 0) {
         return true;
     }
     // エラー発生
     $this->errMsg = $this->oMgr->getErrMsg();
     return false;
 }
 function getSearchArgs($request)
 {
     $args = $this->getSqlArgs();
     $args['COND'] = "";
     $aryCond = array();
     // 更新日:自
     if (@$request['issue_from'] != "") {
         $aryCond[] = "KUC.update_time::date >= '" . string::replaceSql($request['issue_from']) . "'";
     }
     // 更新日:至
     if (@$request['issue_to'] != "") {
         $aryCond[] = "KUC.update_time::date <= '" . string::replaceSql($request['issue_to']) . "'";
     }
     // キー番号
     $request['key_number'] = string::zen2han($request['key_number']);
     if (@$request['key_number'] != "") {
         $aryCond[] = "KUC.key_number LIKE '%" . string::replaceSql($request['key_number']) . "%'";
     }
     // option
     if (@$request['search_option'] == "1") {
         $aryCond[] = "KUC.make_time = KUC.update_time";
     } else {
         if (@$request['search_option'] == "2") {
             $aryCond[] = "KUC.make_time != KUC.update_time";
         }
     }
     // type
     if (@$request['data_type'] == "1") {
         $aryCond[] = "KUC.list_no = 0";
     }
     if (count($aryCond) > 0) {
         $args['COND'] = " WHERE " . join(" AND ", $aryCond);
     }
     return $args;
 }
 function outputCardData($mode, $kbn)
 {
     $args = array();
     if ($kbn == 'joukin') {
         $args['JOUKIN_KBN'] = " AND joukin_kbn in ('" . JOUKIN_KBN_FULLTIME . "','" . JOUKIN_KBN_PARTTIME . "')";
     } else {
         $args['JOUKIN_KBN'] = " AND joukin_kbn = '" . JOUKIN_KBN_OTHER . "'";
     }
     $sql = $this->getQuery('GET_USER_CARD_OUTPUT_DATA', $args);
     $aryRet = $this->oDb->getAll($sql);
     $arySex = $this->getAry('sex');
     $strUser = "";
     if (is_array($aryRet)) {
         foreach ($aryRet as $data) {
             // 識別コード(職員番号)
             $strUser .= '"' . $data['ident_code'] . '"';
             // 漢字氏名
             $strUser .= ',"' . $data['kanjisei'] . " " . $data['kanjimei'] . '"';
             // 英字氏名
             $eijiname = substr($data['eijimei'], 0, 1) . "." . $data['eijisei'];
             $eijiname = strtoupper($eijiname);
             $strUser .= ',"' . $eijiname . '"';
             // 生年月日
             $strUser .= ',"' . $data['birthday'] . '"';
             // 性別
             $sex = str_replace("性", "", $arySex[$data['sex']]);
             $strUser .= ',"' . $sex . '"';
             // 券種
             //$strUser .= ',"' . "" . '"';
             // 証明文書
             //$strUser .= ',"' . "" . '"';
             // 発行年月日
             $strUser .= ',"' . $data['first_issue_date'] . '"';
             // 発行回数
             $strUser .= ',"' . sprintf("%02d", $data['issue_cnt']) . '"';
             // 部署名
             $strUser .= ',"' . $data['belong_name'] . '"';
             // 職種
             $strUser .= ',"' . $data['job_name'] . '"';
             // 役職
             $strUser .= ',"' . $data['post_name'] . '"';
             // カナ氏名(半角)
             $kananame = $data['kanasei'] . $data['kanamei'];
             $kananame = string::zen2han($kananame);
             $strUser .= ',"' . $kananame . '"';
             // 有効期限
             $strUser .= ',"' . $data['end_date'] . '"';
             // 役職印刷名
             //$strUser .= ',"' . $data['post_name'] . '"';
             if ($kbn == 'joukin') {
                 // 識別コード(バーコード)
                 $strUser .= ',"' . $data['ident_code'] . '"';
             }
             $strUser .= "\r\n";
         }
     }
     $file = $mode . microtime(true) . ".csv";
     $file_path = EXPTEMP_PATH . $file;
     file_put_contents($file_path, $strUser);
     return $file;
 }
 function relationHis($request, $aryOld = "")
 {
     if (!defined("HIS_CSV_DIR")) {
         return;
         //define("HIS_CSV_DIR","/var/www/phplib/hiscsv/");
     }
     $user_id = $request['user_id'];
     $aryData = $this->getUserData($user_id);
     // 性別
     $request['sex'] = $aryData['sex'];
     $request['birth_year'] = $aryData['birth_year'];
     $request['birth_mon'] = $aryData['birth_mon'];
     $request['birth_day'] = $aryData['birth_day'];
     $request['pbno'] = $aryData['pbno'];
     if (@$aryOld['staffcode'] != "") {
         //if (!$this->isChangeHisData($request, $aryOld))
         //{
         // 変わってなければ処理しない
         //return ;
         //}
         // パスワードは変更画面から変更しないため空白をセット
         $request['password'] = "";
     }
     // 更新日時
     $update_time = date("YmdHis");
     //
     // 職員データを固定長1行データにする
     //
     $strUser = "";
     // 送信日加工
     list($sy, $sm, $sd) = explode("/", $request['send_date']);
     $send_date = sprintf("%04d%02d%02d", $sy, $sm, $sd);
     $strUser .= $send_date;
     // 病院コード01固定
     $strUser .= "01";
     // 職員コード
     $strUser .= str_pad($request['staffcode'], 10);
     // 所属部署コード
     $strUser .= str_pad($request['wardcode'], 5);
     // 職種コード
     $strUser .= str_pad($request['professioncode'], 2);
     // 役職コード
     $strUser .= str_pad($request['gradecode'], 2);
     // 職員カナ名称
     $kananame = str_replace(" ", " ", $request['kananame']);
     $kananame = string::zen2han($kananame);
     //$strUser .= str_pad($kananame, 20);
     $strUser .= string::mb_str_pad($kananame, 20);
     // 職員漢字名称
     //$strUser .= str_pad($request['kanjiname'], 20);
     //$kanjiname = str_replace(" ", " ", $request['kanjiname']);
     //$kanjiname = string::han2zen($kanjiname);
     //$strUser .= string::mb_str_pad($kanjiname, 10);
     $strUser .= string::mb_str_pad($request['kanjiname'], 20);
     // パスワード
     $strUser .= str_pad($request['password'], 10);
     // 有効開始日
     list($vsy, $vsm, $vsd) = explode("/", $request['validstartdate']);
     $validstartdate = sprintf("%04d%02d%02d", $vsy, $vsm, $vsd);
     $strUser .= $validstartdate;
     // 有効終了日
     list($vey, $vem, $ved) = explode("/", $request['validenddate']);
     $validenddate = sprintf("%04d%02d%02d", $vey, $vem, $ved);
     $strUser .= $validenddate;
     // 性別
     $strUser .= str_pad($request['sex'], 1);
     // 生年月日(和暦に変換)
     $gengou = "";
     $wadate = "";
     $this->toWareki($request['birth_year'], $request['birth_mon'], $request['birth_day'], &$gengou, &$wadate);
     $strUser .= str_pad($gengou, 1);
     $strUser .= str_pad($wadate, 6);
     // 更新日
     $strUser .= $update_time;
     // 更新端末
     //$strUser .= str_pad("利用者管理", 10);
     $strUser .= string::mb_str_pad("利用者管理", 10);
     // 更新者コード
     $login_staffcode = $this->getSessionData('LOGIN_STAFFCODE');
     $strUser .= str_pad($login_staffcode, 10);
     // PHS番号
     $strUser .= str_pad($request['pbno'], 4);
     // 所属科コード
     $strUser .= str_pad($request['deptcode'], 2);
     // 予約項目コード
     $strUser .= str_pad($request['appcode'], 5);
     // 診療グループコード
     $strUser .= str_pad($request['deptgroupcode'], 2);
     // ファイル名
     $file = "STAFF_" . $request['staffcode'] . "_" . $update_time . ".txt";
     $file_path = HIS_CSV_DIR . $file;
     file_put_contents($file_path, $strUser);
     //exit;
     return;
 }
 function checkInputdata()
 {
     // 職員番号
     if (!$this->oMgr->checkEmpty($this->request['staff_id'])) {
         // エラーメッセージをセット
         $this->oMgr->setErr('E001', "個人番号");
     } else {
         if (!string::strlen($this->request['staff_id']) > STAFF_ID_LEN) {
             // エラーメッセージをセット
             $param = array();
             $param[0] = "個人番号";
             $param[1] = "半角" . STAFF_ID_LEN . "桁";
             $this->oMgr->setErr('E004', $param);
         } else {
             if ($this->oMgr->existsStaffId($this->request['staff_id'])) {
                 $this->oMgr->setErr('E017', "個人番号");
             }
         }
     }
     // 漢字姓
     if (!$this->oMgr->checkEmpty($this->request['kanjisei'])) {
         // エラーメッセージをセット
         $this->oMgr->setErr('E001', "氏名(姓)");
     }
     // 漢字名
     if (!$this->oMgr->checkEmpty($this->request['kanjimei'])) {
         // エラーメッセージをセット
         $this->oMgr->setErr('E001', "氏名(名)");
     }
     // カナ姓
     $this->request['kanasei'] = string::han2zen($this->request['kanasei']);
     if (!$this->oMgr->checkEmpty($this->request['kanasei'])) {
         // エラーメッセージをセット
         $this->oMgr->setErr('E001', "氏名カナ(姓)");
     } else {
         if (!string::chackKatakana3($this->request['kanasei'])) {
             // エラーメッセージをセット
             $param = array();
             $param[0] = '氏名カナ(姓)';
             $param[1] = 'カタカナ';
             $this->oMgr->setErr('E004', $param);
         }
     }
     // カナ名
     $this->request['kanamei'] = string::han2zen($this->request['kanamei']);
     if (!$this->oMgr->checkEmpty($this->request['kanamei'])) {
         // エラーメッセージをセット
         $this->oMgr->setErr('E001', "氏名カナ(名)");
     } else {
         if (!string::chackKatakana3($this->request['kanamei'])) {
             // エラーメッセージをセット
             $param = array();
             $param[0] = '氏名カナ(名)';
             $param[1] = 'カタカナ';
             $this->oMgr->setErr('E004', $param);
         }
     }
     // カナ姓
     $this->request['kanasei_real'] = string::han2zen($this->request['kanasei_real']);
     if (!$this->oMgr->checkEmpty($this->request['kanasei_real'])) {
         //
     } else {
         if (!string::chackKatakana3($this->request['kanasei_real'])) {
             // エラーメッセージをセット
             $param = array();
             $param[0] = '戸籍氏名カナ(姓)';
             $param[1] = 'カタカナ';
             $this->oMgr->setErr('E004', $param);
         }
     }
     // カナ名
     $this->request['kanamei_real'] = string::han2zen($this->request['kanamei_real']);
     if (!$this->oMgr->checkEmpty($this->request['kanamei_real'])) {
         //
     } else {
         if (!string::chackKatakana3($this->request['kanamei_real'])) {
             // エラーメッセージをセット
             $param = array();
             $param[0] = '戸籍氏名カナ(名)';
             $param[1] = 'カタカナ';
             $this->oMgr->setErr('E004', $param);
         }
     }
     // 英字姓
     $this->request['eijisei'] = string::zen2han($this->request['eijisei']);
     $this->request['eijisei'] = strtolower($this->request['eijisei']);
     $chkEijisei = str_replace("-", "", $this->request['eijisei']);
     if (!$this->oMgr->checkEmpty($this->request['eijisei'])) {
         // 任意
     } else {
         if (!string::checkAlphabet($chkEijisei)) {
             // エラーメッセージをセット
             $param = array();
             $param[0] = '氏名英字(姓)';
             $param[1] = '半角英字';
             $this->oMgr->setErr('E004', $param);
         }
     }
     // 英字名
     $this->request['eijimei'] = string::zen2han($this->request['eijimei']);
     $this->request['eijimei'] = strtolower($this->request['eijimei']);
     $chkEijimei = str_replace("-", "", $this->request['eijimei']);
     if (!$this->oMgr->checkEmpty($this->request['eijimei'])) {
         // 任意
     } else {
         if (!string::checkAlphabet($chkEijimei)) {
             // エラーメッセージをセット
             $param = array();
             $param[0] = '氏名英字(名)';
             $param[1] = '半角英字';
             $this->oMgr->setErr('E004', $param);
         }
     }
     // 性別
     $this->request['sex'] = (string) $this->request['sex'];
     if (!$this->oMgr->checkEmpty($this->request['sex'])) {
         // エラーメッセージをセット
         $this->oMgr->setErr('E007', "性別");
     }
     // 生年月日
     if (!$this->oMgr->checkEmpty($this->request['birth_year'])) {
         // エラーメッセージをセット
         $this->oMgr->setErr('E007', "生年月日(年)");
     }
     if (!$this->oMgr->checkEmpty($this->request['birth_mon'])) {
         // エラーメッセージをセット
         $this->oMgr->setErr('E007', "生年月日(月)");
     }
     if (!$this->oMgr->checkEmpty($this->request['birth_day'])) {
         // エラーメッセージをセット
         $this->oMgr->setErr('E007', "生年月日(日)");
     }
     // 生年月日に入力がある場合
     if ($this->request['birth_year'] != "" || $this->request['birth_mon'] != "" || $this->request['birth_day'] != "") {
         if ($this->request['birth_year'] == "" || $this->request['birth_mon'] == "" || $this->request['birth_day'] == "") {
             // エラーメッセージをセット
             $this->oMgr->setErr('E006', "生年月日");
         } else {
             if (!checkdate($this->request['birth_mon'], $this->request['birth_day'], $this->request['birth_year'])) {
                 // エラーメッセージをセット
                 $this->oMgr->setErr('E013', "生年月日");
             }
         }
     }
     // 所属
     if (!$this->oMgr->checkEmpty($this->request['belong_chg_id'])) {
         // エラーメッセージをセット
         $this->oMgr->setErr('E007', "所属(メイン)");
     }
     // 職種
     if (!$this->oMgr->checkEmpty($this->request['job_id'])) {
         // エラーメッセージをセット
         $this->oMgr->setErr('E007', "職種(メイン)");
     }
     // 役職
     if (!$this->oMgr->checkEmpty($this->request['post_id'])) {
         // エラーメッセージをセット
         $this->oMgr->setErr('E007', "役職(メイン)");
     }
     // 内線
     $this->request['naisen'] = string::zen2han($this->request['naisen']);
     if (!$this->oMgr->checkEmpty($this->request['naisen'])) {
         // 任意
     } else {
         if (!string::checkNumberWide($this->request['naisen'], 1, 20)) {
             // エラーメッセージをセット
             $param = array();
             $param[0] = "内線";
             $param[1] = "半角数字20桁以内";
             $this->oMgr->setErr('E004', $param);
         }
     }
     // PHS番号
     $this->request['pbno'] = string::zen2han($this->request['pbno']);
     if (!$this->oMgr->checkEmpty($this->request['pbno'])) {
         // 任意
     } else {
         if (!string::checkNumber($this->request['pbno'], 4)) {
             // エラーメッセージをセット
             $param = array();
             $param[0] = "PHS番号";
             $param[1] = "半角数字4桁";
             $this->oMgr->setErr('E004', $param);
         }
     }
     // 常勤/非常勤
     if (!$this->oMgr->checkEmpty($this->request['joukin_kbn'])) {
         // エラーメッセージをセット
         $this->oMgr->setErr('E007', "常勤/非常勤");
     }
     // 統合ID
     $this->request['login_id'] = string::zen2han($this->request['login_id']);
     $this->request['login_id'] = strtolower($this->request['login_id']);
     // 元データと変わってない場合チェックしない
     if (!$this->oMgr->checkEmpty($this->request['login_id'])) {
         // 任意
         if ($this->request['mail_acc'] != "") {
             $this->oMgr->setErr('E001', "統合ID");
         }
     } else {
         if (string::strlen($this->request['login_id']) > 20) {
             // エラーメッセージをセット
             $param = array();
             $param[0] = '統合ID';
             $param[1] = '20文字以内';
             $this->oMgr->setErr('E004', $param);
         } else {
             if (!ereg("^[a-z]+\\.[a-z]+\\.[a-z]{2}\$", $this->request['login_id'])) {
                 // エラーメッセージをセット
                 $param = array();
                 $param[0] = '統合ID';
                 $param[1] = '姓.名.規定の英字2文字';
                 $this->oMgr->setErr('E004', $param);
             } else {
                 if ($this->oMgr->existsMailAcc($this->request['login_id'])) {
                     // メールアカウントとして使用中
                     $this->oMgr->setErr('E017', "統合ID");
                 } else {
                     if ($this->oMgr->existsMlistAcc($this->request['login_id'])) {
                         // メーリングリストとして使用中
                         $this->oMgr->setErr('E017', "統合ID");
                     } else {
                         if ($this->oMgr->existsOldMail($this->request['login_id'])) {
                             // エイリアスのアカウントとして使用中
                             $this->oMgr->setErr('E017', "統合ID");
                         } else {
                             list($sei, $mei, $rand) = explode(".", $this->request['login_id']);
                             $aryRandStr = $this->oMgr->getAry('rand_tow_chars');
                             if (!in_array($rand, $aryRandStr)) {
                                 // エラーメッセージをセット
                                 $param = array();
                                 $param[0] = '統合ID';
                                 $param[1] = '姓.名.規定の英字2文字';
                                 $this->oMgr->setErr('E004', $param);
                             } else {
                                 if ($this->oMgr->existsLoginId($this->request['login_id'], $user_id)) {
                                     $this->oMgr->setErr('E017', "統合ID");
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     // パスワード
     $this->request['login_passwd'] = string::zen2han($this->request['login_passwd']);
     if (!$this->oMgr->checkEmpty($this->request['login_passwd'])) {
         // 任意
         if ($this->request['login_id'] != "" && $user_id == "") {
             $this->oMgr->setErr('E001', "パスワード");
         }
     } else {
         $passwd = $this->request['login_passwd'];
         if (!string::checkAlphanumWide($passwd, 6, 20) || !ereg("[0-9]", $passwd) || !ereg("[a-z]", $passwd) || !ereg("[A-Z]", $passwd)) {
             $param = array();
             $param[0] = "パスワード";
             $param[1] = "数字、英字大文字、英字小文字を各1文字以上使用し、6~20文字";
             // エラーメッセージをセット
             $this->oMgr->setErr('E004', $param);
         }
     }
     // メールアカウント
     $mailMsg = "";
     if (!$this->oMgr->checkEmpty($this->request['mail_acc'])) {
         //
     } else {
         if (!$this->oMgr->checkNcvcMailAcc($this->request['mail_acc'], "メールアカウント", &$mailMsg)) {
             // エラーメッセージをセット
             $this->oMgr->pushError($mailMsg);
         } else {
             if ($this->oMgr->existsMailAcc($this->request['mail_acc'], $user_id)) {
                 $this->oMgr->setErr('E017', "メールアカウント");
             } else {
                 if ($this->oMgr->existsMlistAcc($this->request['mail_acc'])) {
                     // メーリングリストとして使用中
                     $this->oMgr->setErr('E017', "メールアカウント");
                 } else {
                     if ($this->oMgr->existsLoginId($this->request['mail_acc'])) {
                         // 統合IDとして使用中
                         $this->oMgr->setErr('E017', "メールアカウント");
                     } else {
                         if ($this->oMgr->existsOldMail($this->request['mail_acc'])) {
                             // エイリアスのアカウントとして使用中
                             $this->oMgr->setErr('E017', "メールアカウント");
                         } else {
                             if ($this->request['mail_acc'] == $this->request['login_id']) {
                                 $param = array();
                                 $param[0] = "メールアカウント";
                                 $param[1] = "統合ID以外の文字列";
                                 $this->oMgr->setErr('E004', $param);
                             }
                         }
                     }
                 }
             }
         }
     }
     // ファイル転送
     if (!$this->oMgr->checkEmpty($this->request['ftrans_user_kbn'])) {
         if ($this->request['ftrans_user_flg'] == '1') {
             // エラーメッセージをセット
             $this->oMgr->setErr('E007', "ファイル転送機能利用の権限");
         }
     }
     // 利用期間
     if (!$this->oMgr->checkEmpty($this->request['start_date'])) {
         // エラーメッセージをセット
         $this->oMgr->setErr('E001', "利用期間(開始日)");
         $has_date_err = true;
     } else {
         if (!$this->oMgr->checkDateFormat($this->request['start_date'])) {
             // エラーメッセージをセット
             $param = array();
             $param[0] = "利用期間(開始日)";
             $param[1] = "yyyy/mm/dd";
             $this->oMgr->setErr('E004', $param);
             $has_date_err = true;
         } else {
             if (!$this->oMgr->checkDate($this->request['start_date'])) {
                 // エラーメッセージをセット
                 $this->oMgr->setErr('E013', "利用期間(開始日)");
                 $has_date_err = true;
             }
         }
     }
     // 利用期間
     if (!$this->oMgr->checkEmpty($this->request['end_date'])) {
         // エラーメッセージをセット
         //$this->oMgr->setErr('E001',"利用期間(終了日)");
         $has_date_err = true;
     } else {
         if (!$this->oMgr->checkDateFormat($this->request['end_date'])) {
             // エラーメッセージをセット
             $param = array();
             $param[0] = "利用期間(終了日)";
             $param[1] = "yyyy/mm/dd";
             $this->oMgr->setErr('E004', $param);
             $has_date_err = true;
         } else {
             if (!$this->oMgr->checkDate($this->request['end_date'])) {
                 // エラーメッセージをセット
                 $this->oMgr->setErr('E013', "利用期間(終了日)");
                 $has_date_err = true;
             }
         }
     }
     if (!$has_date_err) {
         if (!$this->oMgr->checkDateTerm($this->request['start_date'], $this->request['end_date'])) {
             // エラーメッセージをセット
             $param = array();
             $param[0] = "利用期間(開始日)";
             $param[1] = "利用期間(終了日)";
             $this->oMgr->setErr('E012', $param);
         }
     }
     // エラーなし
     if (sizeof($this->oMgr->aryErrMsg) == 0) {
         return true;
     }
     // エラー発生
     $this->errMsg = $this->oMgr->getErrMsg();
     return false;
 }
 // 予備
 $strUser .= str_pad("", 15);
 // 所属部署コード
 $strUser .= str_pad($data['wardcode'], 5);
 // 職種コード
 $strUser .= str_pad($data['professioncode'], 3);
 // パスワード
 $password = $data['password'];
 $password = $oMgr->passwordDecrypt($password);
 if (strlen($password) > 5) {
     $password = substr($password, 0, 5);
 }
 $strUser .= str_pad($password, 5);
 // 職員カナ名称
 $kananame = str_replace(" ", " ", $data['kananame']);
 $kananame = string::zen2han($kananame);
 $strUser .= string::mb_str_pad($kananame, 20);
 // 職員漢字名称
 $strUser .= string::mb_str_pad($data['kanjiname'], 20, " ");
 // 発行番号
 $strUser .= str_pad("", 4);
 // 給与職員番号
 $strUser .= str_pad("", 4);
 // 所属科コード
 $strUser .= str_pad($data['deptcode'], 2);
 // 役職コード
 $strUser .= str_pad($data['gradecode'], 2);
 // 棒給表コード
 $strUser .= str_pad("", 2);
 // 所属科コード
 $strUser .= str_pad($data['deptcode'], 2);
 function makeLoginId($eijisei, $eijimei)
 {
     $eijisei = string::zen2han($eijisei);
     $eijimei = string::zen2han($eijimei);
     $eijisei = strtolower($eijisei);
     $eijimei = strtolower($eijimei);
     $eijisei = str_replace("-", "", $eijisei);
     $eijimei = str_replace("-", "", $eijimei);
     // ランダム文字列取得
     $aryChars = $this->getAry('rand_tow_chars');
     $rand = $aryChars[array_rand($aryChars, 1)];
     // 20 - 4 = 16 eijisei.eijimei.xx
     if (strlen($eijisei . $eijimei) > 16) {
         $len = strlen($eijisei . $eijimei) - 16;
         for ($i = 0; $i < $len; $i++) {
             if (strlen($eijimei) > 1) {
                 $eijimei = substr($eijimei, 0, -1);
             } else {
                 $eijisei = substr($eijisei, 0, -1);
             }
         }
     }
     $id = $eijisei . "." . $eijimei . "." . $rand;
     // 存在チェック
     if ($this->checkExistsLoginId($id)) {
         $id = self::makeLoginId($eijisei, $eijimei);
     }
     return $id;
 }