12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- defmodule GiomWeb.PtransController do
- use GiomWeb, :controller
- alias Giom.Accounting
- alias Giom.Accounting.Ptrans
- def index(conn, _params) do
- ptrans = Accounting.list_ptrans()
- render(conn, "index.html", ptrans: ptrans)
- end
- def new(conn, _params) do
- changeset = Accounting.change_ptrans(%Ptrans{})
- render(conn, "new.html", changeset: changeset)
- end
- def create(conn, %{"ptrans" => ptrans_params}) do
- case Accounting.create_ptrans(ptrans_params) do
- {:ok, ptrans} ->
- conn
- |> put_flash(:info, "Ptrans created successfully.")
- |> redirect(to: ptrans_path(conn, :show, ptrans))
- {:error, %Ecto.Changeset{} = changeset} ->
- render(conn, "new.html", changeset: changeset)
- end
- end
- def show(conn, %{"id" => id}) do
- ptrans = Accounting.get_ptrans!(id)
- render(conn, "show.html", ptrans: ptrans)
- end
- def edit(conn, %{"id" => id}) do
- ptrans = Accounting.get_ptrans!(id)
- changeset = Accounting.change_ptrans(ptrans)
- render(conn, "edit.html", ptrans: ptrans, changeset: changeset)
- end
- def update(conn, %{"id" => id, "ptrans" => ptrans_params}) do
- ptrans = Accounting.get_ptrans!(id)
- case Accounting.update_ptrans(ptrans, ptrans_params) do
- {:ok, ptrans} ->
- conn
- |> put_flash(:info, "Ptrans updated successfully.")
- |> redirect(to: ptrans_path(conn, :show, ptrans))
- {:error, %Ecto.Changeset{} = changeset} ->
- render(conn, "edit.html", ptrans: ptrans, changeset: changeset)
- end
- end
- def delete(conn, %{"id" => id}) do
- ptrans = Accounting.get_ptrans!(id)
- {:ok, _ptrans} = Accounting.delete_ptrans(ptrans)
- conn
- |> put_flash(:info, "Ptrans deleted successfully.")
- |> redirect(to: ptrans_path(conn, :index))
- end
- end
|