Example #1
0
    $latest_tpl = $row;
}
// --- 承認済み tpl が存在しない場合はクリア、存在する場合は更新
if ($latest_tpl == null) {
    // --- TBL: sop
    $rslt = updSopAprv($db, $sop_id, null);
    // latest_tpl_id に null をセット
    if (!$rslt) {
        \Sop\Log::error(__FILE__, __LINE__, 'Failed to update sop.');
        $msg009 = "The update faild.: sop clear";
        // 更新に失敗しました: sop clear
        \Sop\Api::exitWithError(array($msg009));
    }
} else {
    // --- TBL: sop
    $rslt = updSopAprv($db, $sop_id, $latest_tpl['tpl_id']);
    // 1つ前のバージョンを最新として更新
    if (!$rslt) {
        \Sop\Log::error(__FILE__, __LINE__, 'Failed to update sop.');
        $msg010 = "The update faild.: sop aprv";
        // 更新に失敗しました: sop aprv
        \Sop\Api::exitWithError(array($msg010));
    }
    // --- TBL: tpl
    $rslt = updTplLatest($db, $latest_tpl['tpl_id'], $LATEST_FLG);
    if (!$rslt) {
        \Sop\Log::error(__FILE__, __LINE__, 'Failed to update tpl.');
        $msg011 = "The update faild.: tpl";
        // 更新に失敗しました: tpl
        \Sop\Api::exitWithError(array($msg011));
    }
Example #2
0
    $sql .= " AND tpl.tpl_id = :tpl_id";
    $params = array();
    $params[':tpl_id'] = $ex_latest_tpl_id;
    $stmt = $db->prepare($sql);
    $stmt->execute($params);
    foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
        $ex_latest_tpl_ver = $row['revision_no'];
    }
}
// ---------------------------
// DB更新
// ---------------------------
$db->beginTransaction();
$tpl_aprv_date = date("Y-m-d H:i:s");
// --- TBL: sop
$rslt = updSopAprv($db, $sop_id, $tpl_id);
// 最新バージョン更新
if (!$rslt) {
    \Sop\Log::error(__FILE__, __LINE__, 'Failed to update sop.');
    \Sop\Api::exitWithError(array("更新に失敗しました: sop"));
}
// --- TBL: tpl
$revision_no = $ex_latest_tpl_ver + 1;
$rslt = updTplAprv($db, $tpl_id, $APRV_FLG_OK, $LATEST_FLG, $aprv_cmnt, $tpl_aprv_date, $user_id, $revision_no);
// 承認
if (!$rslt) {
    \Sop\Log::error(__FILE__, __LINE__, 'Failed to update tpl.');
    \Sop\Api::exitWithError(array("更新に失敗しました: tpl"));
}
// --- TBL: history
$history_id = -1;