$sel_sql = getSQLBaseForPjSmplList(); $sel_sql .= " WHERE pj_smpl.pj_id = :pj_id AND v_pj.grp_id = :grp_id"; $params = array(); $params[':pj_id'] = $pj_id; $params[':grp_id'] = $grp_id; // --- 件数取得 $sql = "SELECT count(*) cnt FROM ({$sel_sql}) as tmp"; $stmt = $db->prepare($sql); $stmt->execute($params); $cnt = 0; foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) { $cnt = (int) $row['cnt']; } // --- データ取得 $sql = $sel_sql; $sql .= " ORDER BY display_order LIMIT {$limit} OFFSET {$start} "; $stmt = $db->prepare($sql); $stmt->execute($params); $pjsmpl_list = array(); foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) { array_push($pjsmpl_list, $row); } // --------------------- // 出力 // --------------------- $db = null; header("Content-type:application/json; charset=utf-8"); $msg001 = "The system succeeded to obtaion the data."; // データの取得に成功しました echo json_encode(array('success' => true, 'msg' => \Sop\Api::htmlEncodeLines(array($msg001)), 'root' => \Sop\Api::htmlEncode($pjsmpl_list), 'total' => $cnt)); exit;
<?php require_once __DIR__ . '/../../../../backend/src/bootstrap.php'; include_once __DIR__ . "/config.php"; /** * Global config の取得 */ // --------------------- // 出力 // --------------------- header("Content-type:application/json; charset=utf-8"); $msg001 = "The system succeeded in an accession to the data."; // データの取得に成功しました echo json_encode(array('success' => true, 'msg' => \Sop\Api::htmlEncodeLines(array($msg001)), 'root' => \Sop\SystemConfigForUI::getConfigs())); exit;
// --------------------------- $db->beginTransaction(); $date = date("Y-m-d H:i:s"); // --- TBL: tpl $rslt = updTplTransitAprv($db, $tpl_id, $new_aprv_flg); if (!$rslt) { \Sop\Log::error(__FILE__, __LINE__, 'Failed to update tpl.'); $msg002 = ""; // 登録に失敗しました: transit_aprv \Sop\Api::exitWithError(array($msg002)); } // --- TBL: history $history_id = -1; $rslt = addHistory($db, $history_id, $pj_id, $sop_id, $tpl_id, null, null, null, $HISTORY_ACTION_TPL_TRANSIT, $date, $user_id, null, null); if (!$rslt) { \Sop\Log::error(__FILE__, __LINE__, 'Failed to add history.'); $msg003 = "The registration failed: history"; // 登録に失敗しました: history \Sop\Api::exitWithError(array($msg003)); } // --------------------------- // 終了処理 // --------------------------- $db->commit(); $db = null; $msg004 = "The data was changed to the acceptance available."; // 承認可能にしました $msg005 = "The data was chaged to the acceptance disable."; // 承認申請を取り消しました echo json_encode(array('success' => true, 'msg' => \Sop\Api::htmlEncodeLines(array($new_aprv_flg == 0 ? $msg004 : $msg005)), 'role_aprv' => (bool) $role_aprv, 'role_upld' => (bool) $role_upld)); exit;
$history_id = -1; $rslt = addHistory($db, $history_id, $pj_id, $sop_id, $tpl_id, $schema_id, $file_id, $smpl_given_no, $HISTORY_ACTION_FILE_UPD, $date, $user_id, $user_id_2, null); if (!$rslt) { \Sop\Log::error(__FILE__, __LINE__, 'Failed to add history.'); $msg013 = "The update failed.: history"; // 更新に失敗しました: history \Sop\Api::exitWithError(array($msg013)); } } // --- フォームの最終更新日時の更新。 $rslt = updValLastUpdateTime($db, $file_id, $target_val_name, $update_time); if (!$rslt) { \Sop\Log::error(__FILE__, __LINE__, 'Failed to update last update time.'); $msg014 = "Failed to update last update time.: val"; // フォーム最終更新時刻の更新に失敗しました: val \Sop\Api::exitWithError(array($msg014)); exit; } // 手書きデータを DB に反映する。 upsertHwr($db, $file_id, $hwr_list, $DATA_DIR_PATH_HWR); // --------------------------- // 出力 // --------------------------- $db->commit(); $db = null; $msg015 = "The input was saved.(time"; // 入力を保存しました(時刻 $msg = "{$msg015}" . date("H:i:s") . ")"; header("Content-type:application/json; charset=utf-8"); echo json_encode(array('success' => true, 'msg' => \Sop\Api::htmlEncodeLines(array($msg)), 'file_id' => $file_id, 'div' => 'upd')); exit;
$msg004 = "The update failed."; // 更新に失敗しました: form \Sop\Api::exitWithError(array($msg004)); } } } // --- TBL: history $history_id = -1; $rslt = addHistory($db, $history_id, $pj_id, $sop_id, $tpl_id, null, null, null, $HISTORY_ACTION_TPL_FORM_UPSERT, date("Y-m-d H:i:s"), $user_id, null, null); if (!$rslt) { \Sop\Log::error(__FILE__, __LINE__, 'Failed to update form.'); $msg005 = "The registration and/or update failed.: history"; // 登録・更新に失敗しました: history \Sop\Api::exitWithError(array($msg005)); } // --------------------------- // 終了処理 // --------------------------- $db->commit(); $db = null; if ($div == 'add') { $msg006 = "The registration completed."; echo json_encode(array('success' => true, 'msg' => \Sop\Api::htmlEncodeLines(array($msg006)))); // 登録が完了しました } if ($div == 'upd') { $msg007 = "The update completed."; echo json_encode(array('success' => true, 'msg' => \Sop\Api::htmlEncodeLines(array($msg007)))); // 更新が完了しました } exit;
\Sop\Log::error(__FILE__, __LINE__, 'Failed to delete row.'); $msg011 = "The delete failed.: row"; // 削除に失敗しました: row \Sop\Api::exitWithError(array(_("削除に失敗しました: row"))); } // --- TBL: history $history_id = -1; $rslt = addHistory($db, $history_id, $pj_id, null, null, null, null, null, $HISTORY_ACTION_PJ_DEL, date("Y-m-d H:i:s"), $user_id, null, null); if (!$rslt) { \Sop\Log::error(__FILE__, __LINE__, 'Failed to delete history.'); $msg012 = "The delete failed.: history"; // 削除に失敗しました: history \Sop\Api::exitWithError(array($msg012)); } // --------------------------- // ファイル削除 // --------------------------- foreach ($file_path_list as $file_path) { if (file_exists($file_path)) { unlink($file_path); } } // --------------------------- // 終了処理 // --------------------------- $db->commit(); $db = null; $msg013 = "The delete completed."; // 削除が完了しました echo json_encode(array('success' => true, 'msg' => \Sop\Api::htmlEncodeLines(array($msg013)), 'role_aprv' => (bool) $role_aprv, 'role_upld' => (bool) $role_upld)); exit;
$params = array(); $params[':tpl_id'] = $tpl_id; $stmt = $db->prepare($sql); $stmt->execute($params); $schema_list = array(); foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) { $schema = $row; if ($schema['schema_type'] == $SCHEMA_TYPE_SRC) { $html = str_replace(array("\r\n", "\r", "\n", "\t"), '', file_get_contents($schema['file_path'])); $html = \Sop\Form::replaceFormInjectionTag($html, $tpl_id); $schema['config'] = $html; } if ($schema['schema_type'] == $SCHEMA_TYPE_TBL) { $schema['config'] = getSchemaVcfgForExt($db, $schema['schema_id']); } array_push($schema_list, $schema); } if (count($schema_list) == 0) { \Sop\Log::warning(__FILE__, __LINE__, 'There is not associated schema.'); $msg002 = "There is not the schema information."; // スキーマ情報が存在しません \Sop\Api::exitWithError(array($msg002)); } // --------------------------- // 終了処理 // --------------------------- $db = null; $msg003 = "The system succeeded in an accession to the data."; // データの取得に成功しました echo json_encode(array('success' => true, 'msg' => \Sop\Api::htmlEncodeLines(array($msg003)), 'schema_list' => $schema_list)); exit;
} } // --- テンプレートバージョン情報を付加 $sop['revision_no'] = 0; $sop['latest_flg'] = $LATEST_FLG_NOT; // 承認済み tpl がある場合 if (!is_null($sop['latest_tpl_id'])) { $trgt_tpl_id = isset($sop['tpl_id']) ? $sop['tpl_id'] : $sop['latest_tpl_id']; // $sop['tpl_id'] セット済みならfileあり、そうでなければfileなし $sql = getSQLBaseForTplList(); $sql .= " AND tpl.tpl_id = :tpl_id"; $params = array(); $params[':tpl_id'] = $trgt_tpl_id; $stmt = $db->prepare($sql); $stmt->execute($params); foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) { $tpl = $row; $sop['tpl_name'] = $tpl['tpl_name']; $sop['revision_no'] = $tpl['revision_no']; $sop['latest_flg'] = $tpl['latest_flg']; } } array_push($sop_list, $sop); } // --------------------- // 出力 // --------------------- $db = null; header("Content-type:application/json; charset=utf-8"); echo json_encode(array('success' => true, 'msg' => \Sop\Api::htmlEncodeLines(array('データの取得に成功しました')), 'root' => \Sop\Api::htmlEncode($sop_list), 'total' => $cnt)); exit;