Ejemplo n.º 1
0
function inheritanceForm($db, $pj_id, $sop_id, $tpl_id)
{
    // 同じSOPに所属するテンプレートの中で一番新しいものを取得。
    $sql = getSQLBaseForTplList() . " AND tpl.pj_id = :pj_id AND tpl.sop_id = :sop_id AND tpl.tpl_id < :tpl_id ORDER BY tpl.tpl_id DESC LIMIT 1";
    $row = R::getRow($sql, array(':pj_id' => $pj_id, ':sop_id' => $sop_id, ':tpl_id' => $tpl_id));
    if (!$row) {
        return;
    }
    $src_tpl_id = $row['tpl_id'];
    $sql = getSQLBaseForFormList() . " AND pj_id = :pj_id AND sop_id = :sop_id AND tpl_id = :tpl_id ORDER BY form_id";
    foreach (R::getAll($sql, array(':pj_id' => $pj_id, ':sop_id' => $sop_id, ':tpl_id' => $src_tpl_id)) as $form) {
        addForm($db, $pj_id, $sop_id, $tpl_id, $form['x'], $form['y'], $form['width'], $form['height'], $form['type'], $form['default_value']);
    }
}
Ejemplo n.º 2
0
    }
    // DB更新 (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_ADD_APRV, date("Y-m-d H:i:s"), $user_id, $user_id_2, null);
    if (!$rslt) {
        \Sop\Log::error(__FILE__, __LINE__, 'Failed to add history.');
        $msg004 = "The update failed.: history";
        // 更新に失敗しました: history
        \Sop\Api::exitWithError(array($msg004));
    }
}
// ---------------------------
// ファイル情報取得
// ---------------------------
// --- tpl データ存在チェック
$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));