Exemplo n.º 1
0
// ---------------------------
$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;
Exemplo n.º 2
0
$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;
Exemplo n.º 3
0
<?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;
Exemplo n.º 4
0
        $node = array();
        $node['text'] = $row['pj_name'];
        $node['id'] = "pj_{$row['pj_id']}";
        $node['cls'] = 'folder';
        array_push($node_list, $node);
    }
} else {
    $pj_id = str_replace('pj_', '', $node);
    $sql = getSQLBaseForSopList();
    $sql .= " AND sop.pj_id = :pj_id AND v_pj.grp_id = :grp_id ORDER BY sop.sop_name";
    $params = array();
    $params[':pj_id'] = $pj_id;
    $params[':grp_id'] = $grp_id;
    $stmt = $db->prepare($sql);
    $stmt->execute($params);
    foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
        $node = array();
        $node['checker_required_flag'] = $row['checker_required_flag'];
        $node['text'] = $row['sop_name'];
        $node['id'] = "sop_{$row['sop_id']}";
        $node['cls'] = 'file';
        $node['leaf'] = true;
        array_push($node_list, $node);
    }
}
// ---------------------------
// 終了処理
// ---------------------------
header("Content-Type: text/json");
echo json_encode(\Sop\Api::htmlEncode($node_list));
Exemplo n.º 5
0
function upsertHwr($db, $file_id, $hwr_list, $image_output_path)
{
    // 手書きデータの id 取得。
    $sql = getSQLBaseForFilehwrList();
    $sql .= " AND file_hwr.file_id = :file_id";
    $params = array();
    $params[':file_id'] = $file_id;
    $stmt = $db->prepare($sql);
    $stmt->execute($params);
    $saved_hwr_list = array();
    foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
        $saved_hwr_list[$row['mark_position_y']] = $row;
    }
    foreach ($hwr_list as $index => $hwr) {
        $hwr_val = $hwr['hwr_val'];
        $update_time = date("Y-m-d H:i:s", $hwr['update_time']);
        $mark_position_y = isset($hwr['mark_position_y']) ? $hwr['mark_position_y'] : '0';
        $hwr_image = array_key_exists('hwr_image', $hwr) ? $hwr['hwr_image'] : null;
        if (array_key_exists('hwr_id', $hwr)) {
            $hwr_id = $hwr['hwr_id'];
            // --- TBL: hwr
            $rslt = updHwr($db, $hwr_id, $hwr_val, $update_time);
            if (!$rslt) {
                \Sop\Log::error(__FILE__, __LINE__, 'Failed to update hwr.');
                $msg001 = "The update failed.: hwr";
                // 更新に失敗しました: hwr
                \Sop\Api::exitWithError(array($msg001));
            }
        } else {
            if (array_key_exists($mark_position_y, $saved_hwr_list)) {
                $hwr_id = $saved_hwr_list[$mark_position_y]['hwr_id'];
                // --- TBL: hwr
                $rslt = updHwr($db, $hwr_id, $hwr_val, $update_time);
                if (!$rslt) {
                    \Sop\Log::error(__FILE__, __LINE__, 'Failed to update hwr.');
                    $msg002 = "The update failed.: hwr";
                    // 更新に失敗しました: hwr
                    \Sop\Api::exitWithError(array($msg002));
                }
            } else {
                // insert
                // --- TBL: hwr
                $hwr_id = -1;
                $rslt = addHwr($db, $hwr_id, $hwr_val, $update_time, $mark_position_y);
                if (!$rslt) {
                    \Sop\Log::error(__FILE__, __LINE__, 'Failed to add hwr.');
                    $msg003 = "The registration failed.: hwr";
                    // 登録に失敗しました: hwr
                    \Sop\Api::exitWithError(array($msg003));
                }
                $hwr_id = getLastId($db);
                // --- TBL: file_hwr
                $rslt = addFilehwr($db, $file_id, $hwr_id);
                if (!$rslt) {
                    \Sop\Log::error(__FILE__, __LINE__, 'Failed to add file_hwr.');
                    $msg004 = "The registration failed.: file_hwr";
                    // 登録に失敗しました: file_hwr
                    \Sop\Api::exitWithError(array($msg004));
                }
            }
        }
        // ---------------------------
        // 手書きの画像をファイルに書き出す。
        // ---------------------------
        if ($hwr_image != null) {
            $file_path = $image_output_path . '/' . $file_id . '_' . $hwr_id . '.png';
            $hwr_image = preg_replace('#^data:image/png;base64,#', '', $hwr_image);
            $hwr_image = base64_decode($hwr_image);
            file_put_contents($file_path, $hwr_image);
        }
    }
}
Exemplo n.º 6
0
<?php

include_once __DIR__ . "/config.php";
include_once __DIR__ . "/db_common.php";
/**
 * ログインチェック
 */
if (\Sop\Session::getSiteData('user_id') === NULL) {
    \Sop\Api::exitWithSessionExpired();
}
Exemplo n.º 7
0
            $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;
Exemplo n.º 8
0
$sel_sql = getSQLBaseForTplList();
$sel_sql .= " AND tpl.tpl_id = :tpl_id";
$sql = "SELECT count(*) cnt FROM ({$sel_sql}) as tmp";
$params = array();
$params[':tpl_id'] = $tpl_id;
$stmt = $db->prepare($sql);
$stmt->execute($params);
$cnt = 0;
foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
    $cnt = (int) $row['cnt'];
}
if ($cnt == 0) {
    \Sop\Log::warning(__FILE__, __LINE__, 'User tries to get non-existent sop.');
    $msg005 = "The object of data already has been deleted.";
    // 対象のデータは既に削除されています
    \Sop\Api::exitWithError(array($msg005));
}
// --- schema 取得
$sql = getSQLBaseForSchemaList();
$sql .= " AND schema.tpl_id = :tpl_id AND v_tpl.grp_id = :grp_id";
$params = array();
$params[':tpl_id'] = $tpl_id;
$params[':grp_id'] = $grp_id;
$stmt = $db->prepare($sql);
$stmt->execute($params);
$schema = null;
foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
    $schema = $row;
}
$schema_id = (int) $schema['schema_id'];
$schema_type = (int) $schema['schema_type'];
Exemplo n.º 9
0
    \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;
Exemplo n.º 10
0
    }
    // --- TBL: history
    $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 update history.');
        $msg009 = "The update failed.: history";
        // 更新に失敗しました: history
        \Sop\Api::exitWithError(array($msg009));
    }
}
// ---------------------------
// 手書きの画像をファイルに書き出す。
// ---------------------------
$file_path = $DATA_DIR_PATH_HWR . '/' . $hwr_id . '.png';
$hwr_image = preg_replace('#^data:image/png;base64,#', '', $hwr_image);
$hwr_image = base64_decode($hwr_image);
file_put_contents($file_path, $hwr_image);
// ---------------------------
// 出力
// ---------------------------
$db->commit();
$db = null;
$msg010 = "The registration completed.";
// 登録が完了しました
$msg011 = "The update completed.";
// 更新が完了しました
$msg = $div == 'add' ? '{$msg010}' : '{$msg011}';
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;
Exemplo n.º 11
0
$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;
Exemplo n.º 12
0
/**
 * 共同作業者の候補一覧
 */
$db = createDBConnection();
// ---------------------
// parameters 取得
// ---------------------
$grp_id = \Sop\Session::getSiteData('grp_id');
$user_id = \Sop\Session::getSiteData('user_id');
// ---------------------
// データ取得
// ---------------------
$sel_sql = getSQLBaseForUser();
$sel_sql .= ' AND v_user.user_id != :user_id AND v_user.grp_id = :grp_id';
$results = R::getAll($sel_sql, array(':user_id' => $user_id, ':grp_id' => $grp_id));
$users = array();
$msg001 = "Please select.";
// 選択してください
$users[] = array('user_id' => '', 'text' => $msg001);
foreach ($results as $user) {
    $role_user = (bool) substr($user['role'], 2, 1);
    if ($role_user) {
        $users[] = array('user_id' => $user['user_id'], 'text' => $user['user_id']);
    }
}
// ---------------------
// 出力
// ---------------------
header("Content-type:application/json; charset=utf-8");
echo json_encode(array('success' => true, 'root' => \Sop\Api::htmlEncode($users)));
exit;
Exemplo n.º 13
0
        }
    }
    // --- テンプレートバージョン情報を付加
    $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;