$val = trim($val, "\"");
 // 常勤区分を取得
 if ($fields[$key] == "cteiinkb") {
     if ($val == "1") {
         $joukin_kbn = JOUKIN_KBN_FULLTIME;
         $post_code_nm = "syksy_cde";
         $job_code_nm = "knmei_cde";
     } else {
         $joukin_kbn = JOUKIN_KBN_PARTTIME;
         $post_code_nm = "hjksyk_misy_cde";
         $job_code_nm = "hjksyk_skin_cde";
     }
 }
 // カナ名は全角に
 if ($fields[$key] == "cnamekna" || $fields[$key] == "kyu_kn_nme") {
     $val = string::han2zen($val);
     $val = str_replace(" ", " ", $val);
 }
 // 非常勤の場合役職コードに文字列を付与(特殊処理)
 if ($fields[$key] == "hjksyk_skin_cde") {
     if ($joukin_kbn == JOUKIN_KBN_PARTTIME) {
         $val = "HJK_" . $val;
     }
 }
 // 掛講座が「000000」の場合、空にする
 if ($fields[$key] == "kkrkoza_cde") {
     if ($val == "000000") {
         $val = "";
     }
 }
 $vals[$fields[$key]] = $val;
<?php

set_include_path('.:/usr/share/pear:/var/www/phplib');
require_once "mgr/common_mgr.class.php";
$oMgr = new common_mgr();
$pass = $argv[1];
$kanjiname = str_replace(" ", " ", "渋田 和芳");
print_r($kanjiname);
print_r(":");
$kanjiname = string::han2zen($kanjiname);
print_r($kanjiname);
print_r(":");
$strUser .= string::mb_str_pad($kanjiname, 20, " ");
print_r($strUser);
print_r(":");
$passwd = trim($pass, "\"");
$passwd = $oMgr->passwordDecrypt($passwd);
exit;
 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();
     // 統合ID
     if (@$request['login_id'] != "") {
         $aryCond[] = "UM.login_id LIKE '%" . string::replaceSql($request['login_id']) . "%'";
     }
     // カードNo.
     if (@$request['staffcode'] != "") {
         $aryCond[] = "EXISTS (SELECT * FROM kyoto_user_card_tbl WHERE UM.user_id = user_id AND del_flg = '0' AND key_number LIKE '%" . string::replaceSql($request['staffcode']) . "%')";
     }
     // カナ氏名
     if (@$request['kananame'] != "") {
         $kananame = string::han2zen($request['kananame']);
         $kananame = str_replace(" ", " ", $kananame);
         $kananame = str_replace(" ", "", $kananame);
         $strBuff = "(";
         $strBuff .= "COALESCE(UM.kanasei, ' ') || COALESCE(UM.kanamei, ' ') LIKE '%" . string::replaceSql($request['kananame']) . "%'";
         $strBuff .= " OR ";
         $strBuff .= "COALESCE(UM.kanjisei, ' ') || COALESCE(UM.kanjimei, ' ') LIKE '%" . string::replaceSql($request['kananame']) . "%'";
         $strBuff .= " OR ";
         $strBuff .= "UM.kanasei || UM.kanamei LIKE '%" . string::replaceSql($kananame) . "%'";
         $strBuff .= " OR ";
         $strBuff .= "UM.kanjisei || UM.kanjimei LIKE '%" . string::replaceSql($kananame) . "%'";
         $strBuff .= " OR ";
         $strBuff .= "EXISTS (SELECT * FROM user_his_tbl WHERE UM.user_id = user_id AND del_flg = '0' AND replace(replace(kananame, ' ', ' '), ' ', '') LIKE '%" . string::replaceSql($kananame) . "%')";
         $strBuff .= " OR ";
         $strBuff .= "EXISTS (SELECT * FROM user_his_tbl WHERE UM.user_id = user_id AND del_flg = '0' AND replace(replace(kanjiname, ' ', ' '), ' ', '') LIKE '%" . string::replaceSql($kananame) . "%')";
         $strBuff .= ")";
         $aryCond[] = $strBuff;
     }
     // 職種
     if (@$request['job_id'] != "") {
         $strBuff = "(";
         $strBuff .= "UM.job_id = " . string::replaceSql($request['job_id']);
         $strBuff .= " OR ";
         $strBuff .= "EXISTS (SELECT * FROM user_sub_job_tbl WHERE UM.user_id = user_id AND del_flg = '0' AND job_id = " . string::replaceSql($request['job_id']) . ")";
         $strBuff .= ")";
         $aryCond[] = $strBuff;
     }
     // 役職
     if (@$request['post_id'] != "") {
         $strBuff = "(";
         $strBuff .= "UM.post_id = " . string::replaceSql($request['post_id']);
         $strBuff .= " OR ";
         $strBuff .= "EXISTS (SELECT * FROM user_sub_post_tbl WHERE UM.user_id = user_id AND del_flg = '0' AND post_id = " . string::replaceSql($request['post_id']) . ")";
         $strBuff .= ")";
         $aryCond[] = $strBuff;
     }
     // 常勤/非常勤
     if (@$request['joukin_kbn'] != "") {
         $aryCond[] = "UM.joukin_kbn = '" . string::replaceSql($request['joukin_kbn']) . "'";
     }
     // 所属
     if (@$request['belong_chg_id'] != "") {
         $strBuff = "(";
         $strBuff .= "UM.belong_chg_id = " . string::replaceSql($request['belong_chg_id']);
         $strBuff .= " OR ";
         $strBuff .= "EXISTS (SELECT * FROM user_sub_chg_tbl WHERE UM.user_id = user_id AND del_flg = '0' AND belong_chg_id = " . string::replaceSql($request['belong_chg_id']) . ")";
         $strBuff .= ")";
         $aryCond[] = $strBuff;
     } else {
         if (@$request['belong_sec_id'] != "") {
             $strBuff = "(";
             $strBuff .= "EXISTS (SELECT * FROM belong_chg_mst WHERE UM.belong_chg_id = belong_chg_id AND del_flg = '0' AND belong_sec_id = " . string::replaceSql($request['belong_sec_id']) . ")";
             $strBuff .= " OR ";
             $strBuff .= "EXISTS (SELECT * FROM user_sub_chg_tbl AS USC,belong_chg_mst AS BCM WHERE UM.user_id = USC.user_id AND USC.belong_chg_id = BCM.belong_chg_id AND BCM.del_flg = '0' AND BCM.belong_sec_id = " . string::replaceSql($request['belong_sec_id']) . ")";
             $strBuff .= ")";
             $aryCond[] = $strBuff;
         } else {
             if (@$request['belong_dep_id'] != "") {
                 $strBuff = "(";
                 $strBuff .= "EXISTS (SELECT * FROM belong_chg_mst AS BCM,belong_sec_mst AS BSM WHERE UM.belong_chg_id = BCM.belong_chg_id AND BCM.belong_sec_id = BSM.belong_sec_id AND BCM.del_flg = '0' AND BSM.del_flg = '0' AND BSM.belong_dep_id = " . string::replaceSql($request['belong_dep_id']) . ")";
                 $strBuff .= " OR ";
                 $strBuff .= "EXISTS (SELECT * FROM user_sub_chg_tbl AS USC,belong_chg_mst AS BCM,belong_sec_mst AS BSM WHERE UM.user_id = USC.user_id AND USC.belong_chg_id = BCM.belong_chg_id AND BCM.belong_sec_id = BSM.belong_sec_id AND BCM.del_flg = '0' AND BSM.del_flg = '0' AND BSM.belong_dep_id = " . string::replaceSql($request['belong_dep_id']) . ")";
                 $strBuff .= ")";
                 $aryCond[] = $strBuff;
             } else {
                 if (@$request['belong_div_id'] != "") {
                     $strBuff = "(";
                     $strBuff .= "EXISTS (SELECT * FROM belong_chg_mst AS BCM,belong_sec_mst AS BSM,belong_dep_mst AS BDM WHERE UM.belong_chg_id = BCM.belong_chg_id AND BCM.belong_sec_id = BSM.belong_sec_id AND BSM.belong_dep_id = BDM.belong_dep_id AND BCM.del_flg = '0' AND BSM.del_flg = '0' AND BDM.del_flg = '0' AND BDM.belong_div_id = " . string::replaceSql($request['belong_div_id']) . ")";
                     $strBuff .= " OR ";
                     $strBuff .= "EXISTS (SELECT * FROM user_sub_chg_tbl AS USC,belong_chg_mst AS BCM,belong_sec_mst AS BSM,belong_dep_mst AS BDM WHERE UM.user_id = USC.user_id AND USC.belong_chg_id = BCM.belong_chg_id AND BCM.belong_sec_id = BSM.belong_sec_id AND BSM.belong_dep_id = BDM.belong_dep_id AND BCM.del_flg = '0' AND BSM.del_flg = '0' AND BDM.del_flg = '0' AND BDM.belong_div_id = " . string::replaceSql($request['belong_div_id']) . ")";
                     $strBuff .= ")";
                     $aryCond[] = $strBuff;
                 } else {
                     if (@$request['belong_class_id'] != "") {
                         $strBuff = "(";
                         $strBuff .= "EXISTS (SELECT * FROM belong_chg_mst AS BCM,belong_sec_mst AS BSM,belong_dep_mst AS BDM,belong_div_mst AS BVM WHERE UM.belong_chg_id = BCM.belong_chg_id AND BCM.belong_sec_id = BSM.belong_sec_id AND BSM.belong_dep_id = BDM.belong_dep_id AND BDM.belong_div_id = BVM.belong_div_id AND BCM.del_flg = '0' AND BSM.del_flg = '0' AND BDM.del_flg = '0' AND BVM.del_flg = '0' AND BVM.belong_class_id = " . string::replaceSql($request['belong_class_id']) . ")";
                         $strBuff .= " OR ";
                         $strBuff .= "EXISTS (SELECT * FROM user_sub_chg_tbl AS USC,belong_chg_mst AS BCM,belong_sec_mst AS BSM,belong_dep_mst AS BDM,belong_div_mst AS BVM WHERE UM.user_id = USC.user_id AND USC.belong_chg_id = BCM.belong_chg_id AND BCM.belong_sec_id = BSM.belong_sec_id AND BSM.belong_dep_id = BDM.belong_dep_id AND BDM.belong_div_id = BVM.belong_div_id AND BCM.del_flg = '0' AND BSM.del_flg = '0' AND BDM.del_flg = '0' AND BVM.del_flg = '0' AND BVM.belong_class_id = " . string::replaceSql($request['belong_class_id']) . ")";
                         $strBuff .= ")";
                         $aryCond[] = $strBuff;
                     }
                 }
             }
         }
     }
     // 利用者種別
     if (is_array(@$request['user_type_id'])) {
         $strUserTypeIds = implode(",", array_keys($request['user_type_id']));
         $aryCond[] = "EXISTS (SELECT * FROM user_role_tbl WHERE UM.user_id = user_id AND del_flg = '0' AND role_id IN (" . $strUserTypeIds . "))";
     }
     if (@$request['search_option'] == "3") {
         // 期限切れのみ
         $aryCond[] = "UM.end_date < (now() + '-6 months')::date";
     } else {
         if (@$request['search_option'] == "2") {
             // 利用期間外は表示しない
             $aryCond[] = "UM.start_date <= now()::date";
             $aryCond[] = "COALESCE(UM.end_date, now()::date) >= now()::date";
         } else {
             if (@$request['search_option'] == "1") {
                 // 退職者は表示しない
                 $aryCond[] = "(UM.retire_flg = '0' OR (UM.retire_flg = '1' AND COALESCE(UM.end_date, now()::date) >= now()::date))";
             }
         }
     }
     if (count($aryCond) > 0) {
         $args['COND'] = " WHERE " . join(" AND ", $aryCond);
     }
     return $args;
 }
    function getSearchArgs($request)
    {
        $args = $this->getSqlArgs();
        $args['COND'] = "";
        $args['ENTRY_STATUS_ENTRY'] = $this->sqlItemChar(ENTRY_STATUS_ENTRY);
        $args['ENTRY_STATUS_REJECT'] = $this->sqlItemChar(ENTRY_STATUS_REJECT);
        // ソート処理のために以下の定数をSQLパラメータに追加
        $args['IP_KBN_DHCP'] = $this->sqlItemChar(IP_KBN_DHCP);
        $args['IP_KBN_FREE'] = $this->sqlItemChar(IP_KBN_FREE);
        $args['DUMY_IP_ADDR_DHCP'] = $this->sqlItemChar(DUMY_IP_ADDR_DHCP);
        $args['DUMY_IP_ADDR_NONE'] = $this->sqlItemChar(DUMY_IP_ADDR_NONE);
        $args['WIRE_KBN_WLESS'] = $this->sqlItemChar(WIRE_KBN_WLESS);
        $args['WIRE_KBN_FREE'] = $this->sqlItemChar(WIRE_KBN_FREE);
        $aryCond = array();
        // 機器種別
        if (@$request['app_type_id'] != "") {
            $aryCond[] = "APP.app_type_id = " . string::replaceSql($request['app_type_id']);
        }
        // 設置場所
        if (@$request['vlan_id'] != "") {
            $aryCond[] = "APP.vlan_id = " . string::replaceSql($request['vlan_id']);
        } else {
            if (@$request['vlan_room_id'] != "") {
                $aryCond[] = "APP.vlan_room_id = " . string::replaceSql($request['vlan_room_id']);
            } else {
                if (@$request['vlan_floor_id'] != "") {
                    $aryCond[] = "EXISTS (SELECT * FROM vlan_room_mst WHERE APP.vlan_room_id = vlan_room_id AND del_flg = '0' AND vlan_floor_id = " . string::replaceSql($request['vlan_floor_id']) . ")";
                } else {
                    if (@$request['vlan_ridge_id'] != "") {
                        $aryCond[] = "EXISTS (SELECT * FROM vlan_room_mst AS VRM,vlan_floor_mst AS VFM WHERE APP.vlan_room_id = VRM.vlan_room_id AND VRM.vlan_floor_id = VFM.vlan_floor_id AND VRM.del_flg = '0' AND VFM.del_flg = '0' AND VFM.vlan_ridge_id = " . string::replaceSql($request['vlan_ridge_id']) . ")";
                    }
                }
            }
        }
        // 申請者名(漢字・カナ)
        if (@$request['app_user_name'] != "") {
            $kananame = string::han2zen($request['app_user_name']);
            $kananame = str_replace(" ", " ", $kananame);
            $kananame = str_replace(" ", "", $kananame);
            $strBuff = "EXISTS (SELECT * FROM user_mst AS UM ";
            $strBuff .= "WHERE (";
            $strBuff .= "APP.app_user_id = UM.user_id ";
            $strBuff .= " OR ";
            $strBuff .= "APP.entry_id = UM.user_id ";
            $strBuff .= ") AND (";
            $strBuff .= "UM.kanasei || UM.kanamei LIKE '%" . string::replaceSql($kananame) . "%'";
            $strBuff .= " OR ";
            $strBuff .= "UM.kanjisei || UM.kanjimei LIKE '%" . string::replaceSql($kananame) . "%'";
            $strBuff .= ")";
            $strBuff .= ")";
            $aryCond[] = $strBuff;
        }
        // MACアドレス
        if (@$request['mac_addr'] != "") {
            $mac_addr = strtolower($request['mac_addr']);
            $mac_addr = str_replace(":", "", $mac_addr);
            $mac_addr = str_replace("-", "", $mac_addr);
            $aryCond[] = "APP.mac_addr LIKE '%" . string::replaceSql($mac_addr) . "%'";
        }
        // IPアドレス
        if (@$request['ip_addr'] != "") {
            $aryCond[] = "APP.ip_addr LIKE '%" . string::replaceSql($request['ip_addr']) . "%'";
        }
        // 名称
        if (@$request['app_name'] != "") {
            $aryCond[] = "APP.app_name LIKE '%" . string::replaceSql($request['app_name']) . "%'";
        }
        $cnt = 0;
        if (is_array($request['entry_kbn_status'])) {
            foreach ($request['entry_kbn_status'] as $key => $val) {
                if ($val != "1") {
                    continue;
                }
                if ($key == 'agreed') {
                    $aryKbnStat[] = "(APP.entry_kbn IS NULL AND APP.entry_status IS NULL)";
                }
                list($entry_kbn, $entry_status) = explode("_", $key);
                $aryKbnStat[] = "(APP.entry_kbn = '" . string::replaceSql($entry_kbn) . "' AND APP.entry_status = '" . string::replaceSql($entry_status) . "')";
                $cnt++;
            }
        }
        if ($cnt > 0) {
            $aryCond[] = "(" . implode(" OR ", $aryKbnStat) . ")";
        }
        // ログインユーザの権限によって処理分け
        // 管理権限があるか?
        if (!$this->hasAdminActType('apps_search.php')) {
            // 一般ユーザの場合自分の申請したもののみ表示
            $user_id = $this->getSessionData('LOGIN_USER_ID');
            $uid = string::replaceSql($user_id);
            $usersCond = <<<SQL
(
EXISTS (SELECT * FROM app_head_entry WHERE APP.app_id = app_id AND entry_id = {$uid})
OR
APP.app_user_id = {$uid}

SQL;
            if ($this->isVlanAdminUser()) {
                // VLAN管理者の場合
                $usersCond .= <<<SQL
OR
EXISTS (SELECT * FROM vlan_admin_list WHERE APP.vlan_id = vlan_id AND del_flg = '0' AND user_id = {$uid})
OR
EXISTS (SELECT * FROM vlan_admin_list AS VA, app_list_tbl AS AL WHERE VA.vlan_id = AL.vlan_id AND AL.app_id = APP.app_id AND VA.del_flg = '0' AND AL.del_flg = '0' AND VA.user_id = {$uid})
OR
EXISTS (SELECT * FROM vlan_admin_list AS VA, app_list_entry AS AL WHERE VA.vlan_id = AL.vlan_id AND AL.app_id = APP.app_id AND AL.entry_no = APP.entry_no AND VA.del_flg = '0' AND AL.del_flg = '0' AND VA.user_id = {$uid})

SQL;
            }
            $aryCond[] = $usersCond . ")";
        }
        if (count($aryCond) > 0) {
            $args['COND'] = " WHERE " . join(" AND ", $aryCond);
        }
        return $args;
    }
 function outputLibraryData($mode, $is_inf_format = false)
 {
     $tel_len = 12;
     $pbno_len = 3;
     if ($is_inf_format) {
         $tel_len = 13;
         $pbno_len = 4;
     }
     $sql = $this->getQuery('GET_LIBRARY_OUTPUT_DATA');
     $aryRet = $this->oDb->getAll($sql);
     $strUser = "";
     if (is_array($aryRet)) {
         foreach ($aryRet as $data) {
             // 固定
             $strUser .= "1601";
             // 職員コード
             $strUser .= str_pad($data['staffcode'], 10);
             // 新旧フラグ固定
             $strUser .= "0";
             // 予備
             $strUser .= str_pad("", 15);
             // 所属部署コード
             $strUser .= str_pad($data['wardcode'], 5);
             // 職種コード
             $strUser .= str_pad($data['professioncode'], 3);
             // パスワード
             $password = $data['password'];
             $password = $this->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);
             // 予約項目コード
             $strUser .= str_pad($data['appcode'], 5);
             // 予備
             $strUser .= str_pad("", 19);
             // ローマ字氏名
             $eijiname = $data['eijiname'];
             if (strlen($eijiname) > 25) {
                 list($sei, $mei) = explode(".", $eijiname);
                 $sei = substr($sei, 0, 1);
                 $eijiname = $sei . "." . $mei;
             }
             $strUser .= str_pad($eijiname, 25);
             // 住所
             $strUser .= string::mb_str_pad("", 60, " ");
             // 備考
             $note = string::han2zen($date['note']);
             $note = string::nr2null($note);
             if (string::strlen($note) > 60) {
                 $note = mb_substr($note, 0, 60, 'UTF-8');
             }
             $strUser .= string::mb_str_pad($note, 60, " ");
             // 電話番号
             $strUser .= str_pad("", $tel_len);
             // 生年月日
             $strUser .= str_pad($data['birthday'], 8);
             // 性別
             $sex = "";
             if ($data['sex'] == "0") {
                 $sex = "M";
             } else {
                 if ($data['sex'] == "1") {
                     $sex = "F";
                 }
             }
             $strUser .= str_pad($sex, 1);
             // 終了区分
             $strUser .= "0";
             // PHS番号
             $pbno_start = 4 - $pbno_len;
             $pbno = substr($data['pbno'], $pbno_start, $pbno_len);
             $strUser .= str_pad($pbno, $pbno_len);
             // 内線
             $strUser .= substr(str_pad($data['naisen'], 4), 0, 4);
             // 有効開始日
             $strUser .= str_pad($data['validstartdate'], 8);
             // 有効終了日
             $strUser .= str_pad($data['validenddate'], 8);
             // 予備
             $strUser .= str_pad("", 10);
             // 更新日
             $strUser .= str_pad($data['send_date'], 8);
             // 更新端末
             $strUser .= str_pad("", 4);
             // 更新者
             $strUser .= str_pad($data['update_staffcode'], 10);
             // 部署名
             $strUser .= string::mb_str_pad($data['wardname'], 40, " ");
             // 所属名
             $strUser .= string::mb_str_pad($data['deptname'], 20, " ");
             // 役職名
             $strUser .= string::mb_str_pad($data['gradename'], 20, " ");
             // 棒給表名
             $strUser .= string::mb_str_pad("", 10, " ");
             // 予備
             $strUser .= str_pad("", 5);
             // 扉許可情報
             $strUser .= "111111111111111111111111111111111111111111111111111111111111";
             $strUser .= "\r\n";
         }
     }
     $file = $mode . microtime(true) . ".txt";
     $file_path = EXPTEMP_PATH . $file;
     file_put_contents($file_path, $strUser);
     return $file;
     /*
     $filename = $title . "用データ_" . date("YmdHis") . ".txt";
     
     $this->strDl($filename, $strUser);
     */
 }
    function getSearchArgs($request)
    {
        $args = $this->getSqlArgs();
        $args['COND'] = "";
        $args['ENTRY_STATUS_ENTRY'] = $this->sqlItemChar(ENTRY_STATUS_ENTRY);
        // ソート処理のために以下の定数をSQLパラメータに追加
        $args['IP_KBN_DHCP'] = $this->sqlItemChar(IP_KBN_DHCP);
        $args['IP_KBN_FREE'] = $this->sqlItemChar(IP_KBN_FREE);
        $args['DUMY_IP_ADDR_DHCP'] = $this->sqlItemChar(DUMY_IP_ADDR_DHCP);
        $args['DUMY_IP_ADDR_NONE'] = $this->sqlItemChar(DUMY_IP_ADDR_NONE);
        $args['WIRE_KBN_WLESS'] = $this->sqlItemChar(WIRE_KBN_WLESS);
        $args['WIRE_KBN_FREE'] = $this->sqlItemChar(WIRE_KBN_FREE);
        $aryCond = array();
        // 機器種別
        if (@$request['app_type_id'] != "") {
            $aryCond[] = "AHE.app_type_id = " . string::replaceSql($request['app_type_id']);
        }
        // 設置場所
        if (@$request['vlan_id'] != "") {
            $aryCond[] = "AHE.vlan_id = " . string::replaceSql($request['vlan_id']);
        } else {
            if (@$request['vlan_room_id'] != "") {
                $aryCond[] = "AHE.vlan_room_id = " . string::replaceSql($request['vlan_room_id']);
            } else {
                if (@$request['vlan_floor_id'] != "") {
                    $aryCond[] = "EXISTS (SELECT * FROM vlan_room_mst WHERE AHE.vlan_room_id = vlan_room_id AND del_flg = '0' AND vlan_floor_id = " . string::replaceSql($request['vlan_floor_id']) . ")";
                } else {
                    if (@$request['vlan_ridge_id'] != "") {
                        $aryCond[] = "EXISTS (SELECT * FROM vlan_room_mst AS VRM,vlan_floor_mst AS VFM WHERE AHE.vlan_room_id = VRM.vlan_room_id AND VRM.vlan_floor_id = VFM.vlan_floor_id AND VRM.del_flg = '0' AND VFM.del_flg = '0' AND VFM.vlan_ridge_id = " . string::replaceSql($request['vlan_ridge_id']) . ")";
                    }
                }
            }
        }
        // 申請者名(漢字・カナ)
        if (@$request['entry_user_name'] != "") {
            $kananame = string::han2zen($request['entry_user_name']);
            $kananame = str_replace(" ", " ", $kananame);
            $kananame = str_replace(" ", "", $kananame);
            $strBuff = "EXISTS (SELECT * FROM user_mst AS UM WHERE AHE.entry_id = UM.user_id AND ";
            $strBuff .= "(";
            $strBuff .= "UM.kanasei || UM.kanamei LIKE '%" . string::replaceSql($kananame) . "%'";
            $strBuff .= " OR ";
            $strBuff .= "UM.kanjisei || UM.kanjimei LIKE '%" . string::replaceSql($kananame) . "%'";
            $strBuff .= ")";
            $strBuff .= ")";
            $aryCond[] = $strBuff;
        }
        // MACアドレス
        if (@$request['mac_addr'] != "") {
            $mac_addr = strtolower($request['mac_addr']);
            $mac_addr = str_replace(":", "", $mac_addr);
            $mac_addr = str_replace("-", "", $mac_addr);
            $aryCond[] = "AHE.mac_addr LIKE '%" . string::replaceSql($mac_addr) . "%'";
        }
        // IPアドレス
        if (@$request['ip_addr'] != "") {
            $aryCond[] = "AHE.ip_addr LIKE '%" . string::replaceSql($request['ip_addr']) . "%'";
        }
        // 名称
        if (@$request['app_name'] != "") {
            $aryCond[] = "AHE.app_name LIKE '%" . string::replaceSql($request['app_name']) . "%'";
        }
        // ログインユーザの権限によって処理分け
        // 管理権限があるか?
        if (!$this->hasAdminActType('apps_req.php')) {
            // VLAN管理者になっているもののみ表示
            $user_id = $this->getSessionData('LOGIN_USER_ID');
            $uid = string::replaceSql($user_id);
            $aryCond[] = <<<SQL
(
EXISTS (SELECT * FROM vlan_admin_list WHERE AHE.vlan_id = vlan_id AND del_flg = '0' AND user_id = {$uid})
OR
EXISTS (SELECT * FROM vlan_admin_list AS VA, app_list_entry AS AL WHERE VA.vlan_id = AL.vlan_id AND AL.app_id = AHE.app_id AND AL.entry_no = AHE.entry_no AND VA.del_flg = '0' AND AL.del_flg = '0' AND VA.user_id = {$uid})
)

SQL;
        }
        if (count($aryCond) > 0) {
            $args['COND'] = " AND " . join(" AND ", $aryCond);
        }
        return $args;
    }
 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($data['appcode'], 5);
 // 予備
 $strUser .= str_pad("", 19);
 // ローマ字氏名
 $eijiname = $data['eijiname'];
 if (strlen($eijiname) > 25) {
     list($sei, $mei) = explode(".", $eijiname);
     $sei = substr($sei, 0, 1);
     $eijiname = $sei . "." . $mei;
 }
 $strUser .= str_pad($eijiname, 25);
 // 住所
 $strUser .= string::mb_str_pad("", 60, " ");
 // 備考
 $note = string::han2zen($date['note']);
 $note = string::nr2null($note);
 if (string::strlen($note) > 60) {
     $note = mb_substr($note, 0, 60, 'UTF-8');
 }
 $strUser .= string::mb_str_pad($note, 60, " ");
 // 電話番号
 $strUser .= str_pad("", 12);
 // 生年月日
 $strUser .= str_pad($data['birthday'], 8);
 // 性別
 $sex = "";
 if ($data['sex'] == "0") {
     $sex = "M";
 } else {
     if ($data['sex'] == "1") {