Odstranjenn projekt
dodan vnos pozicije fakture
This commit is contained in:
@@ -10,7 +10,6 @@ using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using EveryThing.Models.CodeTable;
|
||||
using EveryThing.Models.Invoice;
|
||||
using EveryThing.Models.Project;
|
||||
|
||||
namespace EveryThing.Data
|
||||
{
|
||||
@@ -46,9 +45,6 @@ namespace EveryThing.Data
|
||||
public DbSet<TransportLoadingOrder> TransportLoadingOrders {get; set; }
|
||||
public DbSet<TransportLoadingOrderLoadUnload> TransportLoadingOrderLoadUnloads { get; set; }
|
||||
public DbSet<CodeTablePartner> CodeTablePartners { get; set; }
|
||||
public DbSet<Project> Projects { get; set; }
|
||||
public DbSet<ProjectPart> ProjectParts { get; set; }
|
||||
public DbSet<ProjectPartItem> ProjectPartItems { get; set; }
|
||||
public DbSet<CodeTableItem> CodeTableItems { get; set; }
|
||||
public DbSet<Invoice> Invoices { get; set; }
|
||||
public DbSet<InvoiceItem> InvoiceItems { get; set; }
|
||||
@@ -107,7 +103,6 @@ namespace EveryThing.Data
|
||||
modelBuilder.Entity<CodeTableCompany>().HasMany(t => t.CompanyTransportLoadingOrder).WithOne(t => t.Company).OnDelete(DeleteBehavior.Restrict);
|
||||
modelBuilder.Entity<CodeTableCompany>().HasMany(t => t.CompanyEmployee).WithOne(t => t.Company).OnDelete(DeleteBehavior.Restrict);
|
||||
modelBuilder.Entity<CodeTableCompany>().HasMany(t => t.CompanyPrePostText).WithOne(t => t.Company).OnDelete(DeleteBehavior.Restrict);
|
||||
modelBuilder.Entity<CodeTableCompany>().HasMany(t => t.CompanyProject).WithOne(t => t.Company).OnDelete(DeleteBehavior.Restrict);
|
||||
modelBuilder.Entity<CodeTableCompany>().HasMany(t => t.CompanyItem).WithOne(t => t.Company).OnDelete(DeleteBehavior.Restrict);
|
||||
modelBuilder.Entity<CodeTableCompany>().HasMany(t => t.CompanyInvoice).WithOne(t => t.Company).OnDelete(DeleteBehavior.Restrict);
|
||||
modelBuilder.Entity<CodeTableJob>().HasMany(t => t.JobEmployee).WithOne(t => t.Job).OnDelete(DeleteBehavior.Restrict);
|
||||
@@ -119,10 +114,6 @@ namespace EveryThing.Data
|
||||
modelBuilder.Entity<Vehicle>().HasMany(t => t.VehicleVehicleIssue).WithOne(t => t.Vehicle).OnDelete(DeleteBehavior.Restrict);
|
||||
modelBuilder.Entity<Vehicle>().HasMany(t => t.VehicleVehicleMeterReading).WithOne(t => t.Vehicle).OnDelete(DeleteBehavior.Restrict);
|
||||
modelBuilder.Entity<Vehicle>().HasMany(t => t.VehicleTransportLoadingOrder).WithOne(t => t.Vehicle).OnDelete(DeleteBehavior.Restrict);
|
||||
modelBuilder.Entity<Project>().HasMany(t => t.ProjectProjectPart).WithOne(t => t.Project).OnDelete(DeleteBehavior.Restrict);
|
||||
modelBuilder.Entity<ProjectPart>().HasMany(t => t.ProjectPartProjectPartItem).WithOne(t => t.ProjectPart).OnDelete(DeleteBehavior.Restrict);
|
||||
modelBuilder.Entity<CodeTableItem>().HasMany(t => t.ItemProjectPartItem).WithOne(t => t.Item).OnDelete(DeleteBehavior.Restrict);
|
||||
modelBuilder.Entity<CodeTableItem>().HasMany(t => t.ItemProjectPartItemMaterial).WithOne(t => t.Material).OnDelete(DeleteBehavior.Restrict);
|
||||
modelBuilder.Entity<Invoice>().HasMany(t => t.InvoiceInvoiceItem).WithOne(t => t.Invoice).OnDelete(DeleteBehavior.Restrict);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
<TypeScriptCompile Remove="node_modules\**" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Migrations\" />
|
||||
<Folder Include="Properties\PublishProfiles\" />
|
||||
<Folder Include="Properties\ServiceDependencies\" />
|
||||
<Folder Include="wwwroot\Uploads\Files\" />
|
||||
|
||||
2347
EveryThing/Migrations/20220614112949_2.Designer.cs
generated
2347
EveryThing/Migrations/20220614112949_2.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
@@ -1,270 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace EveryThing.Migrations
|
||||
{
|
||||
public partial class _2 : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_InvoiceItems_Invoices_IdInvoiceFk",
|
||||
table: "InvoiceItems");
|
||||
|
||||
migrationBuilder.DropPrimaryKey(
|
||||
name: "PK_Invoices",
|
||||
table: "Invoices");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "IdProject",
|
||||
table: "Invoices",
|
||||
newName: "Type");
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "Type",
|
||||
table: "Invoices",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "int")
|
||||
.OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "IdInvoice",
|
||||
table: "Invoices",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn);
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "Date",
|
||||
table: "Invoices",
|
||||
type: "datetime(6)",
|
||||
nullable: false,
|
||||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "IdPartnerFk",
|
||||
table: "Invoices",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.AddColumn<double>(
|
||||
name: "Discount",
|
||||
table: "InvoiceItems",
|
||||
type: "double",
|
||||
nullable: false,
|
||||
defaultValue: 0.0);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "IdItemFk",
|
||||
table: "InvoiceItems",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "IdProjectPartItem",
|
||||
table: "InvoiceItems",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "ItemDescription",
|
||||
table: "InvoiceItems",
|
||||
type: "longtext",
|
||||
nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Note",
|
||||
table: "InvoiceItems",
|
||||
type: "longtext",
|
||||
nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AddColumn<double>(
|
||||
name: "Price",
|
||||
table: "InvoiceItems",
|
||||
type: "double",
|
||||
nullable: false,
|
||||
defaultValue: 0.0);
|
||||
|
||||
migrationBuilder.AddColumn<double>(
|
||||
name: "Quantity",
|
||||
table: "InvoiceItems",
|
||||
type: "double",
|
||||
nullable: false,
|
||||
defaultValue: 0.0);
|
||||
|
||||
migrationBuilder.AddColumn<double>(
|
||||
name: "Tax",
|
||||
table: "InvoiceItems",
|
||||
type: "double",
|
||||
nullable: false,
|
||||
defaultValue: 0.0);
|
||||
|
||||
migrationBuilder.AddPrimaryKey(
|
||||
name: "PK_Invoices",
|
||||
table: "Invoices",
|
||||
column: "IdInvoice");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Invoices_IdPartnerFk",
|
||||
table: "Invoices",
|
||||
column: "IdPartnerFk");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_InvoiceItems_IdItemFk",
|
||||
table: "InvoiceItems",
|
||||
column: "IdItemFk");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_InvoiceItems_IdProjectPartItem",
|
||||
table: "InvoiceItems",
|
||||
column: "IdProjectPartItem");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_InvoiceItems_CodeTableItems_IdItemFk",
|
||||
table: "InvoiceItems",
|
||||
column: "IdItemFk",
|
||||
principalTable: "CodeTableItems",
|
||||
principalColumn: "IdItem");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_InvoiceItems_Invoices_IdInvoiceFk",
|
||||
table: "InvoiceItems",
|
||||
column: "IdInvoiceFk",
|
||||
principalTable: "Invoices",
|
||||
principalColumn: "IdInvoice",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_InvoiceItems_ProjectPartItems_IdProjectPartItem",
|
||||
table: "InvoiceItems",
|
||||
column: "IdProjectPartItem",
|
||||
principalTable: "ProjectPartItems",
|
||||
principalColumn: "IdProjectPartItem",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Invoices_CodeTablePartners_IdPartnerFk",
|
||||
table: "Invoices",
|
||||
column: "IdPartnerFk",
|
||||
principalTable: "CodeTablePartners",
|
||||
principalColumn: "IdPartner",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_InvoiceItems_CodeTableItems_IdItemFk",
|
||||
table: "InvoiceItems");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_InvoiceItems_Invoices_IdInvoiceFk",
|
||||
table: "InvoiceItems");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_InvoiceItems_ProjectPartItems_IdProjectPartItem",
|
||||
table: "InvoiceItems");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Invoices_CodeTablePartners_IdPartnerFk",
|
||||
table: "Invoices");
|
||||
|
||||
migrationBuilder.DropPrimaryKey(
|
||||
name: "PK_Invoices",
|
||||
table: "Invoices");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Invoices_IdPartnerFk",
|
||||
table: "Invoices");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_InvoiceItems_IdItemFk",
|
||||
table: "InvoiceItems");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_InvoiceItems_IdProjectPartItem",
|
||||
table: "InvoiceItems");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IdInvoice",
|
||||
table: "Invoices");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Date",
|
||||
table: "Invoices");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IdPartnerFk",
|
||||
table: "Invoices");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Discount",
|
||||
table: "InvoiceItems");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IdItemFk",
|
||||
table: "InvoiceItems");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IdProjectPartItem",
|
||||
table: "InvoiceItems");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ItemDescription",
|
||||
table: "InvoiceItems");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Note",
|
||||
table: "InvoiceItems");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Price",
|
||||
table: "InvoiceItems");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Quantity",
|
||||
table: "InvoiceItems");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Tax",
|
||||
table: "InvoiceItems");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "Type",
|
||||
table: "Invoices",
|
||||
newName: "IdProject");
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "IdProject",
|
||||
table: "Invoices",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "int")
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn);
|
||||
|
||||
migrationBuilder.AddPrimaryKey(
|
||||
name: "PK_Invoices",
|
||||
table: "Invoices",
|
||||
column: "IdProject");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_InvoiceItems_Invoices_IdInvoiceFk",
|
||||
table: "InvoiceItems",
|
||||
column: "IdInvoiceFk",
|
||||
principalTable: "Invoices",
|
||||
principalColumn: "IdProject",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
}
|
||||
}
|
||||
}
|
||||
2350
EveryThing/Migrations/20220614114647_3.Designer.cs
generated
2350
EveryThing/Migrations/20220614114647_3.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
@@ -1,26 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace EveryThing.Migrations
|
||||
{
|
||||
public partial class _3 : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "State",
|
||||
table: "Invoices",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "State",
|
||||
table: "Invoices");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace EveryThing.Migrations
|
||||
{
|
||||
public partial class _4 : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_InvoiceItems_ProjectPartItems_IdProjectPartItem",
|
||||
table: "InvoiceItems");
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "IdProjectPartItem",
|
||||
table: "InvoiceItems",
|
||||
type: "int",
|
||||
nullable: true,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "int");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_InvoiceItems_ProjectPartItems_IdProjectPartItem",
|
||||
table: "InvoiceItems",
|
||||
column: "IdProjectPartItem",
|
||||
principalTable: "ProjectPartItems",
|
||||
principalColumn: "IdProjectPartItem");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_InvoiceItems_ProjectPartItems_IdProjectPartItem",
|
||||
table: "InvoiceItems");
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "IdProjectPartItem",
|
||||
table: "InvoiceItems",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "int",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_InvoiceItems_ProjectPartItems_IdProjectPartItem",
|
||||
table: "InvoiceItems",
|
||||
column: "IdProjectPartItem",
|
||||
principalTable: "ProjectPartItems",
|
||||
principalColumn: "IdProjectPartItem",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
}
|
||||
}
|
||||
2363
EveryThing/Migrations/20220617041022_5.Designer.cs
generated
2363
EveryThing/Migrations/20220617041022_5.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
@@ -1,70 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace EveryThing.Migrations
|
||||
{
|
||||
public partial class _5 : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "InvoiceNumber",
|
||||
table: "Invoices",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "InvoiceYear",
|
||||
table: "Invoices",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Note",
|
||||
table: "Invoices",
|
||||
type: "longtext",
|
||||
nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "PostText",
|
||||
table: "Invoices",
|
||||
type: "longtext",
|
||||
nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "PreText",
|
||||
table: "Invoices",
|
||||
type: "longtext",
|
||||
nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "InvoiceNumber",
|
||||
table: "Invoices");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "InvoiceYear",
|
||||
table: "Invoices");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Note",
|
||||
table: "Invoices");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "PostText",
|
||||
table: "Invoices");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "PreText",
|
||||
table: "Invoices");
|
||||
}
|
||||
}
|
||||
}
|
||||
2381
EveryThing/Migrations/20220617071940_6.Designer.cs
generated
2381
EveryThing/Migrations/20220617071940_6.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
@@ -1,58 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace EveryThing.Migrations
|
||||
{
|
||||
public partial class _6 : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "IdPartnerFk",
|
||||
table: "Projects",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "LogoFileName",
|
||||
table: "CodeTableCompanies",
|
||||
type: "longtext",
|
||||
nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Projects_IdPartnerFk",
|
||||
table: "Projects",
|
||||
column: "IdPartnerFk");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Projects_CodeTablePartners_IdPartnerFk",
|
||||
table: "Projects",
|
||||
column: "IdPartnerFk",
|
||||
principalTable: "CodeTablePartners",
|
||||
principalColumn: "IdPartner",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Projects_CodeTablePartners_IdPartnerFk",
|
||||
table: "Projects");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Projects_IdPartnerFk",
|
||||
table: "Projects");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IdPartnerFk",
|
||||
table: "Projects");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "LogoFileName",
|
||||
table: "CodeTableCompanies");
|
||||
}
|
||||
}
|
||||
}
|
||||
2384
EveryThing/Migrations/20220728190422_7.Designer.cs
generated
2384
EveryThing/Migrations/20220728190422_7.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
@@ -1,26 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace EveryThing.Migrations
|
||||
{
|
||||
public partial class _7 : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "DateOfDispatch",
|
||||
table: "Invoices",
|
||||
type: "datetime(6)",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "DateOfDispatch",
|
||||
table: "Invoices");
|
||||
}
|
||||
}
|
||||
}
|
||||
2387
EveryThing/Migrations/20220729120715_8.Designer.cs
generated
2387
EveryThing/Migrations/20220729120715_8.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
2390
EveryThing/Migrations/20220905044842_9.Designer.cs
generated
2390
EveryThing/Migrations/20220905044842_9.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
@@ -1,26 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace EveryThing.Migrations
|
||||
{
|
||||
public partial class _9 : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "State",
|
||||
table: "InvoiceItems",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "State",
|
||||
table: "InvoiceItems");
|
||||
}
|
||||
}
|
||||
}
|
||||
2399
EveryThing/Migrations/20220926142447_10.Designer.cs
generated
2399
EveryThing/Migrations/20220926142447_10.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
@@ -1,48 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace EveryThing.Migrations
|
||||
{
|
||||
public partial class _10 : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "Buyer",
|
||||
table: "CodeTablePartners",
|
||||
type: "tinyint(1)",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "Supplier",
|
||||
table: "CodeTablePartners",
|
||||
type: "tinyint(1)",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "CodeTableItemType",
|
||||
table: "CodeTableItems",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Buyer",
|
||||
table: "CodeTablePartners");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Supplier",
|
||||
table: "CodeTablePartners");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CodeTableItemType",
|
||||
table: "CodeTableItems");
|
||||
}
|
||||
}
|
||||
}
|
||||
2417
EveryThing/Migrations/20220930114206_11.Designer.cs
generated
2417
EveryThing/Migrations/20220930114206_11.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
@@ -1,81 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace EveryThing.Migrations
|
||||
{
|
||||
public partial class _11 : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "BuyersOrderNumber",
|
||||
table: "Projects",
|
||||
type: "longtext",
|
||||
nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "ProjectNumber",
|
||||
table: "Projects",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "ProjectYear",
|
||||
table: "Projects",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "ProjectPartNumber",
|
||||
table: "ProjectParts",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "DeliveryDate",
|
||||
table: "ProjectPartItems",
|
||||
type: "datetime(6)",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "ProjectPartItemNumber",
|
||||
table: "ProjectPartItems",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "BuyersOrderNumber",
|
||||
table: "Projects");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ProjectNumber",
|
||||
table: "Projects");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ProjectYear",
|
||||
table: "Projects");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ProjectPartNumber",
|
||||
table: "ProjectParts");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "DeliveryDate",
|
||||
table: "ProjectPartItems");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ProjectPartItemNumber",
|
||||
table: "ProjectPartItems");
|
||||
}
|
||||
}
|
||||
}
|
||||
2420
EveryThing/Migrations/20220930123821_12.Designer.cs
generated
2420
EveryThing/Migrations/20220930123821_12.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
@@ -1,26 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace EveryThing.Migrations
|
||||
{
|
||||
public partial class _12 : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "BuyersOrderNumber",
|
||||
table: "Invoices",
|
||||
type: "longtext",
|
||||
nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "BuyersOrderNumber",
|
||||
table: "Invoices");
|
||||
}
|
||||
}
|
||||
}
|
||||
2423
EveryThing/Migrations/20221011035800_13.Designer.cs
generated
2423
EveryThing/Migrations/20221011035800_13.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
@@ -1,26 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace EveryThing.Migrations
|
||||
{
|
||||
public partial class _13 : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<float>(
|
||||
name: "SellingPrice",
|
||||
table: "ProjectPartItems",
|
||||
type: "float",
|
||||
nullable: false,
|
||||
defaultValue: 0f);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "SellingPrice",
|
||||
table: "ProjectPartItems");
|
||||
}
|
||||
}
|
||||
}
|
||||
2426
EveryThing/Migrations/20221203123112_14.Designer.cs
generated
2426
EveryThing/Migrations/20221203123112_14.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
@@ -1,27 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace EveryThing.Migrations
|
||||
{
|
||||
public partial class _14 : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "DateModified",
|
||||
table: "ProjectPartItems",
|
||||
type: "datetime(6)",
|
||||
nullable: false,
|
||||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "DateModified",
|
||||
table: "ProjectPartItems");
|
||||
}
|
||||
}
|
||||
}
|
||||
2437
EveryThing/Migrations/20230117050632_15.Designer.cs
generated
2437
EveryThing/Migrations/20230117050632_15.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
@@ -1,45 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace EveryThing.Migrations
|
||||
{
|
||||
public partial class _15 : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "IdInvoiceItemJoinFk",
|
||||
table: "InvoiceItems",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_InvoiceItems_IdInvoiceItemJoinFk",
|
||||
table: "InvoiceItems",
|
||||
column: "IdInvoiceItemJoinFk");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_InvoiceItems_InvoiceItems_IdInvoiceItemJoinFk",
|
||||
table: "InvoiceItems",
|
||||
column: "IdInvoiceItemJoinFk",
|
||||
principalTable: "InvoiceItems",
|
||||
principalColumn: "IdInvoiceItem");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_InvoiceItems_InvoiceItems_IdInvoiceItemJoinFk",
|
||||
table: "InvoiceItems");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_InvoiceItems_IdInvoiceItemJoinFk",
|
||||
table: "InvoiceItems");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IdInvoiceItemJoinFk",
|
||||
table: "InvoiceItems");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,8 +11,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
namespace EveryThing.Migrations
|
||||
{
|
||||
[DbContext(typeof(ApplicationDbContext))]
|
||||
[Migration("20220615133522_4")]
|
||||
partial class _4
|
||||
[Migration("20230513104253_Initial")]
|
||||
partial class Initial
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
@@ -56,6 +56,9 @@ namespace EveryThing.Migrations
|
||||
b.Property<int>("IdCountryFk")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("LogoFileName")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Phone")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
@@ -274,6 +277,9 @@ namespace EveryThing.Migrations
|
||||
b.Property<bool>("Active")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<int>("CodeTableItemType")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
@@ -323,6 +329,9 @@ namespace EveryThing.Migrations
|
||||
b.Property<bool>("Active")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<bool>("Buyer")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<string>("City")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
@@ -354,6 +363,9 @@ namespace EveryThing.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<bool>("Supplier")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<string>("TaxNumber")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
@@ -669,9 +681,15 @@ namespace EveryThing.Migrations
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("BuyersOrderNumber")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<DateTime?>("DateOfDispatch")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<int>("IdCompanyFk")
|
||||
.HasColumnType("int");
|
||||
|
||||
@@ -679,6 +697,21 @@ namespace EveryThing.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("InvoiceNumber")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("InvoiceYear")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Note")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("PostText")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("PreText")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("State")
|
||||
.HasColumnType("int");
|
||||
|
||||
@@ -706,6 +739,9 @@ namespace EveryThing.Migrations
|
||||
b.Property<int>("IdInvoiceFk")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("IdInvoiceItemJoinFk")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("IdItemFk")
|
||||
.HasColumnType("int");
|
||||
|
||||
@@ -724,6 +760,9 @@ namespace EveryThing.Migrations
|
||||
b.Property<double>("Quantity")
|
||||
.HasColumnType("double");
|
||||
|
||||
b.Property<int>("State")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Tax")
|
||||
.HasColumnType("double");
|
||||
|
||||
@@ -731,133 +770,13 @@ namespace EveryThing.Migrations
|
||||
|
||||
b.HasIndex("IdInvoiceFk");
|
||||
|
||||
b.HasIndex("IdItemFk");
|
||||
b.HasIndex("IdInvoiceItemJoinFk");
|
||||
|
||||
b.HasIndex("IdProjectPartItem");
|
||||
b.HasIndex("IdItemFk");
|
||||
|
||||
b.ToTable("InvoiceItems");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Project.Project", b =>
|
||||
{
|
||||
b.Property<int>("IdProject")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<DateTime?>("FinishedDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<int>("IdCompanyFk")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("IdProject");
|
||||
|
||||
b.HasIndex("IdCompanyFk");
|
||||
|
||||
b.ToTable("Projects");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Project.ProjectPart", b =>
|
||||
{
|
||||
b.Property<int>("IdProjectPart")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<DateTime?>("FinishedDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<int>("IdProjectFk")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime?>("ShippedDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("IdProjectPart");
|
||||
|
||||
b.HasIndex("IdProjectFk");
|
||||
|
||||
b.ToTable("ProjectParts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Project.ProjectPartItem", b =>
|
||||
{
|
||||
b.Property<int>("IdProjectPartItem")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime?>("FinishedDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<int?>("IdItemFk")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("IdMaterialFk")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("IdMaterialSupplierFk")
|
||||
.IsRequired()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("IdProjectPartFk")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("MaterialDimensions")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<float>("MaterialPrice")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<float>("NumberOfItems")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<float>("NumberOfItemsFinished")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<float>("NumberOfSets")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<DateTime?>("ShippingDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<float>("WorkPrice")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("IdProjectPartItem");
|
||||
|
||||
b.HasIndex("IdItemFk");
|
||||
|
||||
b.HasIndex("IdMaterialFk");
|
||||
|
||||
b.HasIndex("IdMaterialSupplierFk");
|
||||
|
||||
b.HasIndex("IdProjectPartFk");
|
||||
|
||||
b.ToTable("ProjectPartItems");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Transport.TransportLoadingOrder", b =>
|
||||
{
|
||||
b.Property<int>("IdTransportLoadingOrder")
|
||||
@@ -1755,74 +1674,19 @@ namespace EveryThing.Migrations
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("EveryThing.Models.Invoice.InvoiceItem", "InvoiceItemJoin")
|
||||
.WithMany()
|
||||
.HasForeignKey("IdInvoiceItemJoinFk");
|
||||
|
||||
b.HasOne("EveryThing.Models.CodeTable.CodeTableItem", "Item")
|
||||
.WithMany("InvoiceItem")
|
||||
.HasForeignKey("IdItemFk");
|
||||
|
||||
b.HasOne("EveryThing.Models.Project.ProjectPartItem", "ProjectPartItem")
|
||||
.WithMany("InvoiceItem")
|
||||
.HasForeignKey("IdProjectPartItem");
|
||||
|
||||
b.Navigation("Invoice");
|
||||
|
||||
b.Navigation("Item");
|
||||
|
||||
b.Navigation("ProjectPartItem");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Project.Project", b =>
|
||||
{
|
||||
b.HasOne("EveryThing.Models.CodeTable.CodeTableCompany", "Company")
|
||||
.WithMany("CompanyProject")
|
||||
.HasForeignKey("IdCompanyFk")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Company");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Project.ProjectPart", b =>
|
||||
{
|
||||
b.HasOne("EveryThing.Models.Project.Project", "Project")
|
||||
.WithMany("ProjectProjectPart")
|
||||
.HasForeignKey("IdProjectFk")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Project");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Project.ProjectPartItem", b =>
|
||||
{
|
||||
b.HasOne("EveryThing.Models.CodeTable.CodeTableItem", "Item")
|
||||
.WithMany("ItemProjectPartItem")
|
||||
.HasForeignKey("IdItemFk")
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
b.HasOne("EveryThing.Models.CodeTable.CodeTableItem", "Material")
|
||||
.WithMany("ItemProjectPartItemMaterial")
|
||||
.HasForeignKey("IdMaterialFk")
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
b.HasOne("EveryThing.Models.CodeTable.CodeTablePartner", "MaterialSupplier")
|
||||
.WithMany("PartnerProjectPartItem")
|
||||
.HasForeignKey("IdMaterialSupplierFk")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("EveryThing.Models.Project.ProjectPart", "ProjectPart")
|
||||
.WithMany("ProjectPartProjectPartItem")
|
||||
.HasForeignKey("IdProjectPartFk")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
b.Navigation("InvoiceItemJoin");
|
||||
|
||||
b.Navigation("Item");
|
||||
|
||||
b.Navigation("Material");
|
||||
|
||||
b.Navigation("MaterialSupplier");
|
||||
|
||||
b.Navigation("ProjectPart");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Transport.TransportLoadingOrder", b =>
|
||||
@@ -2182,8 +2046,6 @@ namespace EveryThing.Migrations
|
||||
|
||||
b.Navigation("CompanyPrePostText");
|
||||
|
||||
b.Navigation("CompanyProject");
|
||||
|
||||
b.Navigation("CompanyTransportLoadingOrder");
|
||||
|
||||
b.Navigation("CompanyVehicle");
|
||||
@@ -2243,10 +2105,6 @@ namespace EveryThing.Migrations
|
||||
modelBuilder.Entity("EveryThing.Models.CodeTable.CodeTableItem", b =>
|
||||
{
|
||||
b.Navigation("InvoiceItem");
|
||||
|
||||
b.Navigation("ItemProjectPartItem");
|
||||
|
||||
b.Navigation("ItemProjectPartItemMaterial");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.CodeTable.CodeTableJob", b =>
|
||||
@@ -2258,8 +2116,6 @@ namespace EveryThing.Migrations
|
||||
{
|
||||
b.Navigation("Invoice");
|
||||
|
||||
b.Navigation("PartnerProjectPartItem");
|
||||
|
||||
b.Navigation("PartnerTransportLoadingOrder");
|
||||
|
||||
b.Navigation("PartnerTransportLoadingOrderLoad");
|
||||
@@ -2277,21 +2133,6 @@ namespace EveryThing.Migrations
|
||||
b.Navigation("InvoiceInvoiceItem");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Project.Project", b =>
|
||||
{
|
||||
b.Navigation("ProjectProjectPart");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Project.ProjectPart", b =>
|
||||
{
|
||||
b.Navigation("ProjectPartProjectPartItem");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Project.ProjectPartItem", b =>
|
||||
{
|
||||
b.Navigation("InvoiceItem");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Transport.TransportLoadingOrder", b =>
|
||||
{
|
||||
b.Navigation("TransportLoadingOrderLoadUnload");
|
||||
@@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace EveryThing.Migrations
|
||||
{
|
||||
public partial class _1 : Migration
|
||||
public partial class Initial : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
@@ -60,6 +60,8 @@ namespace EveryThing.Migrations
|
||||
{
|
||||
IdCompany = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
LogoFileName = table.Column<string>(type: "longtext", nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Title = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
ShortTitle = table.Column<string>(type: "longtext", nullable: true)
|
||||
@@ -162,7 +164,8 @@ namespace EveryThing.Migrations
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Description = table.Column<string>(type: "longtext", nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Active = table.Column<bool>(type: "tinyint(1)", nullable: false)
|
||||
Active = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||
CodeTableItemType = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
@@ -224,7 +227,9 @@ namespace EveryThing.Migrations
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Email = table.Column<string>(type: "longtext", nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Active = table.Column<bool>(type: "tinyint(1)", nullable: false)
|
||||
Active = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||
Buyer = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||
Supplier = table.Column<bool>(type: "tinyint(1)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
@@ -375,52 +380,6 @@ namespace EveryThing.Migrations
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Invoices",
|
||||
columns: table => new
|
||||
{
|
||||
IdProject = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
IdCompanyFk = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Invoices", x => x.IdProject);
|
||||
table.ForeignKey(
|
||||
name: "FK_Invoices_CodeTableCompanies_IdCompanyFk",
|
||||
column: x => x.IdCompanyFk,
|
||||
principalTable: "CodeTableCompanies",
|
||||
principalColumn: "IdCompany",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Projects",
|
||||
columns: table => new
|
||||
{
|
||||
IdProject = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
IdCompanyFk = table.Column<int>(type: "int", nullable: false),
|
||||
Title = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Description = table.Column<string>(type: "longtext", nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Status = table.Column<int>(type: "int", nullable: false),
|
||||
FinishedDate = table.Column<DateTime>(type: "datetime(6)", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Projects", x => x.IdProject);
|
||||
table.ForeignKey(
|
||||
name: "FK_Projects_CodeTableCompanies_IdCompanyFk",
|
||||
column: x => x.IdCompanyFk,
|
||||
principalTable: "CodeTableCompanies",
|
||||
principalColumn: "IdCompany",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "VehicleFuelingCards",
|
||||
columns: table => new
|
||||
@@ -638,6 +597,47 @@ namespace EveryThing.Migrations
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Invoices",
|
||||
columns: table => new
|
||||
{
|
||||
IdInvoice = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
IdCompanyFk = table.Column<int>(type: "int", nullable: false),
|
||||
Date = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
Type = table.Column<int>(type: "int", nullable: false),
|
||||
State = table.Column<int>(type: "int", nullable: false),
|
||||
IdPartnerFk = table.Column<int>(type: "int", nullable: false),
|
||||
InvoiceNumber = table.Column<int>(type: "int", nullable: false),
|
||||
InvoiceYear = table.Column<int>(type: "int", nullable: false),
|
||||
PreText = table.Column<string>(type: "longtext", nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
PostText = table.Column<string>(type: "longtext", nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Note = table.Column<string>(type: "longtext", nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
BuyersOrderNumber = table.Column<string>(type: "longtext", nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
DateOfDispatch = table.Column<DateTime>(type: "datetime(6)", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Invoices", x => x.IdInvoice);
|
||||
table.ForeignKey(
|
||||
name: "FK_Invoices_CodeTableCompanies_IdCompanyFk",
|
||||
column: x => x.IdCompanyFk,
|
||||
principalTable: "CodeTableCompanies",
|
||||
principalColumn: "IdCompany",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_Invoices_CodeTablePartners_IdPartnerFk",
|
||||
column: x => x.IdPartnerFk,
|
||||
principalTable: "CodeTablePartners",
|
||||
principalColumn: "IdPartner",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Documents",
|
||||
columns: table => new
|
||||
@@ -764,53 +764,6 @@ namespace EveryThing.Migrations
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "InvoiceItems",
|
||||
columns: table => new
|
||||
{
|
||||
IdInvoiceItem = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
IdInvoiceFk = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_InvoiceItems", x => x.IdInvoiceItem);
|
||||
table.ForeignKey(
|
||||
name: "FK_InvoiceItems_Invoices_IdInvoiceFk",
|
||||
column: x => x.IdInvoiceFk,
|
||||
principalTable: "Invoices",
|
||||
principalColumn: "IdProject",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ProjectParts",
|
||||
columns: table => new
|
||||
{
|
||||
IdProjectPart = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
IdProjectFk = table.Column<int>(type: "int", nullable: false),
|
||||
Title = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Description = table.Column<string>(type: "longtext", nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Status = table.Column<int>(type: "int", nullable: false),
|
||||
FinishedDate = table.Column<DateTime>(type: "datetime(6)", nullable: true),
|
||||
ShippedDate = table.Column<DateTime>(type: "datetime(6)", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ProjectParts", x => x.IdProjectPart);
|
||||
table.ForeignKey(
|
||||
name: "FK_ProjectParts_Projects_IdProjectFk",
|
||||
column: x => x.IdProjectFk,
|
||||
principalTable: "Projects",
|
||||
principalColumn: "IdProject",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Vehicles",
|
||||
columns: table => new
|
||||
@@ -913,52 +866,43 @@ namespace EveryThing.Migrations
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ProjectPartItems",
|
||||
name: "InvoiceItems",
|
||||
columns: table => new
|
||||
{
|
||||
IdProjectPartItem = table.Column<int>(type: "int", nullable: false)
|
||||
IdInvoiceItem = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
IdProjectPartFk = table.Column<int>(type: "int", nullable: false),
|
||||
IdInvoiceFk = table.Column<int>(type: "int", nullable: false),
|
||||
IdProjectPartItem = table.Column<int>(type: "int", nullable: true),
|
||||
IdItemFk = table.Column<int>(type: "int", nullable: true),
|
||||
NumberOfItems = table.Column<float>(type: "float", nullable: false),
|
||||
NumberOfSets = table.Column<float>(type: "float", nullable: false),
|
||||
IdMaterialFk = table.Column<int>(type: "int", nullable: true),
|
||||
MaterialDimensions = table.Column<string>(type: "longtext", nullable: true)
|
||||
IdInvoiceItemJoinFk = table.Column<int>(type: "int", nullable: true),
|
||||
ItemDescription = table.Column<string>(type: "longtext", nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
IdMaterialSupplierFk = table.Column<int>(type: "int", nullable: false),
|
||||
MaterialPrice = table.Column<float>(type: "float", nullable: false),
|
||||
WorkPrice = table.Column<float>(type: "float", nullable: false),
|
||||
NumberOfItemsFinished = table.Column<float>(type: "float", nullable: false),
|
||||
Status = table.Column<int>(type: "int", nullable: false),
|
||||
FinishedDate = table.Column<DateTime>(type: "datetime(6)", nullable: true),
|
||||
ShippingDate = table.Column<DateTime>(type: "datetime(6)", nullable: true)
|
||||
Note = table.Column<string>(type: "longtext", nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Quantity = table.Column<double>(type: "double", nullable: false),
|
||||
Price = table.Column<double>(type: "double", nullable: false),
|
||||
Discount = table.Column<double>(type: "double", nullable: false),
|
||||
Tax = table.Column<double>(type: "double", nullable: false),
|
||||
State = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ProjectPartItems", x => x.IdProjectPartItem);
|
||||
table.PrimaryKey("PK_InvoiceItems", x => x.IdInvoiceItem);
|
||||
table.ForeignKey(
|
||||
name: "FK_ProjectPartItems_CodeTableItems_IdItemFk",
|
||||
name: "FK_InvoiceItems_CodeTableItems_IdItemFk",
|
||||
column: x => x.IdItemFk,
|
||||
principalTable: "CodeTableItems",
|
||||
principalColumn: "IdItem",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
principalColumn: "IdItem");
|
||||
table.ForeignKey(
|
||||
name: "FK_ProjectPartItems_CodeTableItems_IdMaterialFk",
|
||||
column: x => x.IdMaterialFk,
|
||||
principalTable: "CodeTableItems",
|
||||
principalColumn: "IdItem",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
name: "FK_InvoiceItems_InvoiceItems_IdInvoiceItemJoinFk",
|
||||
column: x => x.IdInvoiceItemJoinFk,
|
||||
principalTable: "InvoiceItems",
|
||||
principalColumn: "IdInvoiceItem");
|
||||
table.ForeignKey(
|
||||
name: "FK_ProjectPartItems_CodeTablePartners_IdMaterialSupplierFk",
|
||||
column: x => x.IdMaterialSupplierFk,
|
||||
principalTable: "CodeTablePartners",
|
||||
principalColumn: "IdPartner",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ProjectPartItems_ProjectParts_IdProjectPartFk",
|
||||
column: x => x.IdProjectPartFk,
|
||||
principalTable: "ProjectParts",
|
||||
principalColumn: "IdProjectPart",
|
||||
name: "FK_InvoiceItems_Invoices_IdInvoiceFk",
|
||||
column: x => x.IdInvoiceFk,
|
||||
principalTable: "Invoices",
|
||||
principalColumn: "IdInvoice",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
@@ -1460,40 +1404,25 @@ namespace EveryThing.Migrations
|
||||
table: "InvoiceItems",
|
||||
column: "IdInvoiceFk");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_InvoiceItems_IdInvoiceItemJoinFk",
|
||||
table: "InvoiceItems",
|
||||
column: "IdInvoiceItemJoinFk");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_InvoiceItems_IdItemFk",
|
||||
table: "InvoiceItems",
|
||||
column: "IdItemFk");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Invoices_IdCompanyFk",
|
||||
table: "Invoices",
|
||||
column: "IdCompanyFk");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProjectPartItems_IdItemFk",
|
||||
table: "ProjectPartItems",
|
||||
column: "IdItemFk");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProjectPartItems_IdMaterialFk",
|
||||
table: "ProjectPartItems",
|
||||
column: "IdMaterialFk");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProjectPartItems_IdMaterialSupplierFk",
|
||||
table: "ProjectPartItems",
|
||||
column: "IdMaterialSupplierFk");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProjectPartItems_IdProjectPartFk",
|
||||
table: "ProjectPartItems",
|
||||
column: "IdProjectPartFk");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProjectParts_IdProjectFk",
|
||||
table: "ProjectParts",
|
||||
column: "IdProjectFk");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Projects_IdCompanyFk",
|
||||
table: "Projects",
|
||||
column: "IdCompanyFk");
|
||||
name: "IX_Invoices_IdPartnerFk",
|
||||
table: "Invoices",
|
||||
column: "IdPartnerFk");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_TransportLoadingOrderLoadUnloads_IdLoadingFk",
|
||||
@@ -1693,9 +1622,6 @@ namespace EveryThing.Migrations
|
||||
migrationBuilder.DropTable(
|
||||
name: "InvoiceItems");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ProjectPartItems");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "TransportLoadingOrderLoadUnloads");
|
||||
|
||||
@@ -1729,14 +1655,11 @@ namespace EveryThing.Migrations
|
||||
migrationBuilder.DropTable(
|
||||
name: "IdentityUser");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Invoices");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "CodeTableItems");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ProjectParts");
|
||||
name: "Invoices");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "TransportLoadingOrders");
|
||||
@@ -1747,9 +1670,6 @@ namespace EveryThing.Migrations
|
||||
migrationBuilder.DropTable(
|
||||
name: "CodeTableEmployees");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Projects");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "CodeTablePartners");
|
||||
|
||||
@@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
namespace EveryThing.Migrations
|
||||
{
|
||||
[DbContext(typeof(ApplicationDbContext))]
|
||||
[Migration("20220312183512_1")]
|
||||
[Migration("20230513134758_1")]
|
||||
partial class _1
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
@@ -56,6 +56,9 @@ namespace EveryThing.Migrations
|
||||
b.Property<int>("IdCountryFk")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("LogoFileName")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Phone")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
@@ -274,6 +277,9 @@ namespace EveryThing.Migrations
|
||||
b.Property<bool>("Active")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<int>("CodeTableItemType")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
@@ -323,6 +329,9 @@ namespace EveryThing.Migrations
|
||||
b.Property<bool>("Active")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<bool>("Buyer")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<string>("City")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
@@ -354,6 +363,9 @@ namespace EveryThing.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<bool>("Supplier")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<string>("TaxNumber")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
@@ -665,17 +677,53 @@ namespace EveryThing.Migrations
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Invoice.Invoice", b =>
|
||||
{
|
||||
b.Property<int>("IdProject")
|
||||
b.Property<int>("IdInvoice")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("BuyersOrderNumber")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<DateTime?>("DateOfDispatch")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<int>("IdCompanyFk")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("IdProject");
|
||||
b.Property<int?>("IdPartnerFk")
|
||||
.IsRequired()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("InvoiceNumber")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("InvoiceYear")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Note")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("PostText")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("PreText")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("State")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Type")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("IdInvoice");
|
||||
|
||||
b.HasIndex("IdCompanyFk");
|
||||
|
||||
b.HasIndex("IdPartnerFk");
|
||||
|
||||
b.ToTable("Invoices");
|
||||
});
|
||||
|
||||
@@ -685,134 +733,51 @@ namespace EveryThing.Migrations
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Discount")
|
||||
.HasColumnType("double");
|
||||
|
||||
b.Property<int>("IdInvoiceFk")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("IdInvoiceItemJoinFk")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("IdItemFk")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("IdProjectPartItem")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ItemDescription")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Note")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double");
|
||||
|
||||
b.Property<double>("Quantity")
|
||||
.HasColumnType("double");
|
||||
|
||||
b.Property<int>("State")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Tax")
|
||||
.HasColumnType("double");
|
||||
|
||||
b.Property<string>("UnlistedItem")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("IdInvoiceItem");
|
||||
|
||||
b.HasIndex("IdInvoiceFk");
|
||||
|
||||
b.ToTable("InvoiceItems");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Project.Project", b =>
|
||||
{
|
||||
b.Property<int>("IdProject")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<DateTime?>("FinishedDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<int>("IdCompanyFk")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("IdProject");
|
||||
|
||||
b.HasIndex("IdCompanyFk");
|
||||
|
||||
b.ToTable("Projects");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Project.ProjectPart", b =>
|
||||
{
|
||||
b.Property<int>("IdProjectPart")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<DateTime?>("FinishedDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<int>("IdProjectFk")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime?>("ShippedDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("IdProjectPart");
|
||||
|
||||
b.HasIndex("IdProjectFk");
|
||||
|
||||
b.ToTable("ProjectParts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Project.ProjectPartItem", b =>
|
||||
{
|
||||
b.Property<int>("IdProjectPartItem")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime?>("FinishedDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<int?>("IdItemFk")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("IdMaterialFk")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("IdMaterialSupplierFk")
|
||||
.IsRequired()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("IdProjectPartFk")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("MaterialDimensions")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<float>("MaterialPrice")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<float>("NumberOfItems")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<float>("NumberOfItemsFinished")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<float>("NumberOfSets")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<DateTime?>("ShippingDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<float>("WorkPrice")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("IdProjectPartItem");
|
||||
b.HasIndex("IdInvoiceItemJoinFk");
|
||||
|
||||
b.HasIndex("IdItemFk");
|
||||
|
||||
b.HasIndex("IdMaterialFk");
|
||||
|
||||
b.HasIndex("IdMaterialSupplierFk");
|
||||
|
||||
b.HasIndex("IdProjectPartFk");
|
||||
|
||||
b.ToTable("ProjectPartItems");
|
||||
b.ToTable("InvoiceItems");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Transport.TransportLoadingOrder", b =>
|
||||
@@ -1693,7 +1658,15 @@ namespace EveryThing.Migrations
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("EveryThing.Models.CodeTable.CodeTablePartner", "Partner")
|
||||
.WithMany("Invoice")
|
||||
.HasForeignKey("IdPartnerFk")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Company");
|
||||
|
||||
b.Navigation("Partner");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Invoice.InvoiceItem", b =>
|
||||
@@ -1704,62 +1677,19 @@ namespace EveryThing.Migrations
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Invoice");
|
||||
});
|
||||
b.HasOne("EveryThing.Models.Invoice.InvoiceItem", "InvoiceItemJoin")
|
||||
.WithMany()
|
||||
.HasForeignKey("IdInvoiceItemJoinFk");
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Project.Project", b =>
|
||||
{
|
||||
b.HasOne("EveryThing.Models.CodeTable.CodeTableCompany", "Company")
|
||||
.WithMany("CompanyProject")
|
||||
.HasForeignKey("IdCompanyFk")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Company");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Project.ProjectPart", b =>
|
||||
{
|
||||
b.HasOne("EveryThing.Models.Project.Project", "Project")
|
||||
.WithMany("ProjectProjectPart")
|
||||
.HasForeignKey("IdProjectFk")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Project");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Project.ProjectPartItem", b =>
|
||||
{
|
||||
b.HasOne("EveryThing.Models.CodeTable.CodeTableItem", "Item")
|
||||
.WithMany("ItemProjectPartItem")
|
||||
.HasForeignKey("IdItemFk")
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
.WithMany("InvoiceItem")
|
||||
.HasForeignKey("IdItemFk");
|
||||
|
||||
b.HasOne("EveryThing.Models.CodeTable.CodeTableItem", "Material")
|
||||
.WithMany("ItemProjectPartItemMaterial")
|
||||
.HasForeignKey("IdMaterialFk")
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
b.Navigation("Invoice");
|
||||
|
||||
b.HasOne("EveryThing.Models.CodeTable.CodeTablePartner", "MaterialSupplier")
|
||||
.WithMany("PartnerProjectPartItem")
|
||||
.HasForeignKey("IdMaterialSupplierFk")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("EveryThing.Models.Project.ProjectPart", "ProjectPart")
|
||||
.WithMany("ProjectPartProjectPartItem")
|
||||
.HasForeignKey("IdProjectPartFk")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
b.Navigation("InvoiceItemJoin");
|
||||
|
||||
b.Navigation("Item");
|
||||
|
||||
b.Navigation("Material");
|
||||
|
||||
b.Navigation("MaterialSupplier");
|
||||
|
||||
b.Navigation("ProjectPart");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Transport.TransportLoadingOrder", b =>
|
||||
@@ -2119,8 +2049,6 @@ namespace EveryThing.Migrations
|
||||
|
||||
b.Navigation("CompanyPrePostText");
|
||||
|
||||
b.Navigation("CompanyProject");
|
||||
|
||||
b.Navigation("CompanyTransportLoadingOrder");
|
||||
|
||||
b.Navigation("CompanyVehicle");
|
||||
@@ -2179,9 +2107,7 @@ namespace EveryThing.Migrations
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.CodeTable.CodeTableItem", b =>
|
||||
{
|
||||
b.Navigation("ItemProjectPartItem");
|
||||
|
||||
b.Navigation("ItemProjectPartItemMaterial");
|
||||
b.Navigation("InvoiceItem");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.CodeTable.CodeTableJob", b =>
|
||||
@@ -2191,7 +2117,7 @@ namespace EveryThing.Migrations
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.CodeTable.CodeTablePartner", b =>
|
||||
{
|
||||
b.Navigation("PartnerProjectPartItem");
|
||||
b.Navigation("Invoice");
|
||||
|
||||
b.Navigation("PartnerTransportLoadingOrder");
|
||||
|
||||
@@ -2210,16 +2136,6 @@ namespace EveryThing.Migrations
|
||||
b.Navigation("InvoiceInvoiceItem");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Project.Project", b =>
|
||||
{
|
||||
b.Navigation("ProjectProjectPart");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Project.ProjectPart", b =>
|
||||
{
|
||||
b.Navigation("ProjectPartProjectPartItem");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Transport.TransportLoadingOrder", b =>
|
||||
{
|
||||
b.Navigation("TransportLoadingOrderLoadUnload");
|
||||
@@ -4,13 +4,13 @@
|
||||
|
||||
namespace EveryThing.Migrations
|
||||
{
|
||||
public partial class _8 : Migration
|
||||
public partial class _1 : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "PathOfPlans",
|
||||
table: "ProjectParts",
|
||||
name: "UnlistedItem",
|
||||
table: "InvoiceItems",
|
||||
type: "longtext",
|
||||
nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
@@ -19,8 +19,8 @@ namespace EveryThing.Migrations
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "PathOfPlans",
|
||||
table: "ProjectParts");
|
||||
name: "UnlistedItem",
|
||||
table: "InvoiceItems");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -764,6 +764,9 @@ namespace EveryThing.Migrations
|
||||
b.Property<double>("Tax")
|
||||
.HasColumnType("double");
|
||||
|
||||
b.Property<string>("UnlistedItem")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("IdInvoiceItem");
|
||||
|
||||
b.HasIndex("IdInvoiceFk");
|
||||
@@ -772,163 +775,9 @@ namespace EveryThing.Migrations
|
||||
|
||||
b.HasIndex("IdItemFk");
|
||||
|
||||
b.HasIndex("IdProjectPartItem");
|
||||
|
||||
b.ToTable("InvoiceItems");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Project.Project", b =>
|
||||
{
|
||||
b.Property<int>("IdProject")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("BuyersOrderNumber")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<DateTime?>("FinishedDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<int>("IdCompanyFk")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("IdPartnerFk")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ProjectNumber")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ProjectYear")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("IdProject");
|
||||
|
||||
b.HasIndex("IdCompanyFk");
|
||||
|
||||
b.HasIndex("IdPartnerFk");
|
||||
|
||||
b.ToTable("Projects");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Project.ProjectPart", b =>
|
||||
{
|
||||
b.Property<int>("IdProjectPart")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<DateTime?>("FinishedDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<int>("IdProjectFk")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("PathOfPlans")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("ProjectPartNumber")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime?>("ShippedDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("IdProjectPart");
|
||||
|
||||
b.HasIndex("IdProjectFk");
|
||||
|
||||
b.ToTable("ProjectParts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Project.ProjectPartItem", b =>
|
||||
{
|
||||
b.Property<int>("IdProjectPartItem")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateModified")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<DateTime?>("DeliveryDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<DateTime?>("FinishedDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<int?>("IdItemFk")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("IdMaterialFk")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("IdMaterialSupplierFk")
|
||||
.IsRequired()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("IdProjectPartFk")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("MaterialDimensions")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<float>("MaterialPrice")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<float>("NumberOfItems")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<float>("NumberOfItemsFinished")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<float>("NumberOfSets")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int>("ProjectPartItemNumber")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<float>("SellingPrice")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<DateTime?>("ShippingDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<float>("WorkPrice")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("IdProjectPartItem");
|
||||
|
||||
b.HasIndex("IdItemFk");
|
||||
|
||||
b.HasIndex("IdMaterialFk");
|
||||
|
||||
b.HasIndex("IdMaterialSupplierFk");
|
||||
|
||||
b.HasIndex("IdProjectPartFk");
|
||||
|
||||
b.ToTable("ProjectPartItems");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Transport.TransportLoadingOrder", b =>
|
||||
{
|
||||
b.Property<int>("IdTransportLoadingOrder")
|
||||
@@ -1834,80 +1683,11 @@ namespace EveryThing.Migrations
|
||||
.WithMany("InvoiceItem")
|
||||
.HasForeignKey("IdItemFk");
|
||||
|
||||
b.HasOne("EveryThing.Models.Project.ProjectPartItem", "ProjectPartItem")
|
||||
.WithMany("InvoiceItem")
|
||||
.HasForeignKey("IdProjectPartItem");
|
||||
|
||||
b.Navigation("Invoice");
|
||||
|
||||
b.Navigation("InvoiceItemJoin");
|
||||
|
||||
b.Navigation("Item");
|
||||
|
||||
b.Navigation("ProjectPartItem");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Project.Project", b =>
|
||||
{
|
||||
b.HasOne("EveryThing.Models.CodeTable.CodeTableCompany", "Company")
|
||||
.WithMany("CompanyProject")
|
||||
.HasForeignKey("IdCompanyFk")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("EveryThing.Models.CodeTable.CodeTablePartner", "Partner")
|
||||
.WithMany("PartnerProject")
|
||||
.HasForeignKey("IdPartnerFk")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Company");
|
||||
|
||||
b.Navigation("Partner");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Project.ProjectPart", b =>
|
||||
{
|
||||
b.HasOne("EveryThing.Models.Project.Project", "Project")
|
||||
.WithMany("ProjectProjectPart")
|
||||
.HasForeignKey("IdProjectFk")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Project");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Project.ProjectPartItem", b =>
|
||||
{
|
||||
b.HasOne("EveryThing.Models.CodeTable.CodeTableItem", "Item")
|
||||
.WithMany("ItemProjectPartItem")
|
||||
.HasForeignKey("IdItemFk")
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
b.HasOne("EveryThing.Models.CodeTable.CodeTableItem", "Material")
|
||||
.WithMany("ItemProjectPartItemMaterial")
|
||||
.HasForeignKey("IdMaterialFk")
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
b.HasOne("EveryThing.Models.CodeTable.CodeTablePartner", "MaterialSupplier")
|
||||
.WithMany("PartnerProjectPartItem")
|
||||
.HasForeignKey("IdMaterialSupplierFk")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("EveryThing.Models.Project.ProjectPart", "ProjectPart")
|
||||
.WithMany("ProjectPartProjectPartItem")
|
||||
.HasForeignKey("IdProjectPartFk")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Item");
|
||||
|
||||
b.Navigation("Material");
|
||||
|
||||
b.Navigation("MaterialSupplier");
|
||||
|
||||
b.Navigation("ProjectPart");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Transport.TransportLoadingOrder", b =>
|
||||
@@ -2267,8 +2047,6 @@ namespace EveryThing.Migrations
|
||||
|
||||
b.Navigation("CompanyPrePostText");
|
||||
|
||||
b.Navigation("CompanyProject");
|
||||
|
||||
b.Navigation("CompanyTransportLoadingOrder");
|
||||
|
||||
b.Navigation("CompanyVehicle");
|
||||
@@ -2328,10 +2106,6 @@ namespace EveryThing.Migrations
|
||||
modelBuilder.Entity("EveryThing.Models.CodeTable.CodeTableItem", b =>
|
||||
{
|
||||
b.Navigation("InvoiceItem");
|
||||
|
||||
b.Navigation("ItemProjectPartItem");
|
||||
|
||||
b.Navigation("ItemProjectPartItemMaterial");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.CodeTable.CodeTableJob", b =>
|
||||
@@ -2343,10 +2117,6 @@ namespace EveryThing.Migrations
|
||||
{
|
||||
b.Navigation("Invoice");
|
||||
|
||||
b.Navigation("PartnerProject");
|
||||
|
||||
b.Navigation("PartnerProjectPartItem");
|
||||
|
||||
b.Navigation("PartnerTransportLoadingOrder");
|
||||
|
||||
b.Navigation("PartnerTransportLoadingOrderLoad");
|
||||
@@ -2364,21 +2134,6 @@ namespace EveryThing.Migrations
|
||||
b.Navigation("InvoiceInvoiceItem");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Project.Project", b =>
|
||||
{
|
||||
b.Navigation("ProjectProjectPart");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Project.ProjectPart", b =>
|
||||
{
|
||||
b.Navigation("ProjectPartProjectPartItem");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Project.ProjectPartItem", b =>
|
||||
{
|
||||
b.Navigation("InvoiceItem");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EveryThing.Models.Transport.TransportLoadingOrder", b =>
|
||||
{
|
||||
b.Navigation("TransportLoadingOrderLoadUnload");
|
||||
|
||||
@@ -155,10 +155,6 @@ namespace EveryThing.Models.CodeTable
|
||||
[InverseProperty("Company")]
|
||||
public virtual ICollection<CodeTablePrePostText> CompanyPrePostText { get; set; }
|
||||
|
||||
// Project
|
||||
[InverseProperty("Company")]
|
||||
public virtual ICollection<Project.Project> CompanyProject { get; set; }
|
||||
|
||||
// CodeTableItem
|
||||
[InverseProperty("Company")]
|
||||
public virtual ICollection<CodeTableItem> CompanyItem { get; set; }
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using EveryThing.Models.Project;
|
||||
|
||||
namespace EveryThing.Models.CodeTable
|
||||
{
|
||||
@@ -41,14 +40,6 @@ namespace EveryThing.Models.CodeTable
|
||||
// ForeignKey
|
||||
public CodeTableCompany Company { get; set; }
|
||||
|
||||
// ProjectPartItem
|
||||
[InverseProperty("Item")]
|
||||
public virtual ICollection<ProjectPartItem> ItemProjectPartItem { get; set; }
|
||||
|
||||
// ProjectPartItem
|
||||
[InverseProperty("Material")]
|
||||
public virtual ICollection<ProjectPartItem> ItemProjectPartItemMaterial { get; set; }
|
||||
|
||||
// InoviceItem
|
||||
[InverseProperty("Item")]
|
||||
public virtual ICollection<Invoice.InvoiceItem> InvoiceItem { get; set; }
|
||||
|
||||
@@ -4,7 +4,6 @@ using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using EveryThing.Models.Project;
|
||||
using EveryThing.Models.Transport;
|
||||
|
||||
namespace EveryThing.Models.CodeTable
|
||||
@@ -85,16 +84,9 @@ namespace EveryThing.Models.CodeTable
|
||||
[InverseProperty("Partner")]
|
||||
public virtual ICollection<TransportLoadingOrder> PartnerTransportLoadingOrder { get; set; }
|
||||
|
||||
// ProjectPartItem
|
||||
[InverseProperty("MaterialSupplier")]
|
||||
public virtual ICollection<ProjectPartItem> PartnerProjectPartItem { get; set; }
|
||||
|
||||
// InvoicePart
|
||||
[InverseProperty("Partner")]
|
||||
public virtual ICollection<Invoice.Invoice> Invoice { get; set; }
|
||||
|
||||
// Project
|
||||
[InverseProperty("Partner")]
|
||||
public virtual ICollection<Project.Project> PartnerProject { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,11 @@ namespace EveryThing.Models.Invoice
|
||||
[Display(Name = "Opis pozicije")]
|
||||
public string ItemDescription { get; set; }
|
||||
|
||||
[Display(Name = "Artikel")]
|
||||
public string UnlistedItem { get; set; }
|
||||
|
||||
[NotMapped] public string ItemDisplay => Item?.Title ?? UnlistedItem;
|
||||
|
||||
[Display(Name = "Opomba")]
|
||||
public string Note { get; set; }
|
||||
|
||||
@@ -69,8 +74,6 @@ namespace EveryThing.Models.Invoice
|
||||
// ForeignKey
|
||||
public Invoice Invoice { get; set; }
|
||||
|
||||
public Project.ProjectPartItem ProjectPartItem { get; set; }
|
||||
|
||||
public CodeTable.CodeTableItem Item { get; set; }
|
||||
/// <summary>
|
||||
/// Povezana pozicija fakture, npr ko se iz dob naredi racun
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using EveryThing.Models.CodeTable;
|
||||
|
||||
namespace EveryThing.Models.Project
|
||||
{
|
||||
public enum ProjectStatus
|
||||
{
|
||||
[Display(Name = "Odprt")]
|
||||
Opened = 0,
|
||||
|
||||
[Display(Name = "V izdelavi")]
|
||||
InProduction = 1,
|
||||
|
||||
[Display(Name = "Zaključen")]
|
||||
Finished = 2,
|
||||
[Display(Name = "Ponudba")]
|
||||
Offer = 10
|
||||
}
|
||||
|
||||
public class Project
|
||||
{
|
||||
[Key]
|
||||
public int IdProject { get; set; }
|
||||
|
||||
[Required]
|
||||
[ForeignKey("Company")]
|
||||
public int IdCompanyFk { get; set; }
|
||||
[Required]
|
||||
[Display(Name = "Partner")]
|
||||
[ForeignKey("Partner")]
|
||||
public int IdPartnerFk { get; set; }
|
||||
|
||||
[Required]
|
||||
[Display(Name = "Naziv")]
|
||||
public string Title { get; set; }
|
||||
|
||||
[Display(Name = "Številka naročila kupca")]
|
||||
public string BuyersOrderNumber { get; set; }
|
||||
|
||||
[Display(Name = "Opis")]
|
||||
public string Description { get; set; }
|
||||
|
||||
[Required]
|
||||
public int ProjectNumber { get; set; } = 0;
|
||||
|
||||
[Required]
|
||||
public int ProjectYear { get; set; } = 0;
|
||||
|
||||
[Required]
|
||||
[Display(Name = "Status")]
|
||||
public ProjectStatus Status { get; set; } = ProjectStatus.Opened;
|
||||
|
||||
[Display(Name = "Datum zaključka")]
|
||||
[DisplayFormat(DataFormatString = "{0:dd.MM.yyyy}", ApplyFormatInEditMode = true)]
|
||||
public DateTime? FinishedDate { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
[Display(Name = "Številka projekta")]
|
||||
public string ProjectNumberFormatted => $"{ProjectYear}-{ProjectNumber:D4}";
|
||||
|
||||
[NotMapped]
|
||||
[Display(Name = "Prvi dobavni rok")]
|
||||
public DateTime? FirstDeliveryDate { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
[Display(Name = "Prvi dobavni rok")]
|
||||
public string FirstDeliveryDateString => FirstDeliveryDate == null || (DateTime)FirstDeliveryDate == DateTime.MaxValue
|
||||
? ""
|
||||
: ((DateTime)FirstDeliveryDate).ToString("dd.MM.yyyy");
|
||||
|
||||
// ForeignKey
|
||||
public CodeTableCompany Company { get; set; }
|
||||
public CodeTablePartner Partner { get; set; }
|
||||
|
||||
// ProjectPart
|
||||
[InverseProperty("Project")]
|
||||
public virtual ICollection<ProjectPart> ProjectProjectPart { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EveryThing.Models.Project
|
||||
{
|
||||
public enum ProjectPartStatus
|
||||
{
|
||||
[Display(Name = "Odprto")]
|
||||
Opened = 0,
|
||||
|
||||
[Display(Name = "V izdelavi")]
|
||||
InProduction = 1,
|
||||
|
||||
[Display(Name = "Zaključeno")]
|
||||
Finished = 2,
|
||||
|
||||
[Display(Name = "Odpremljeno")]
|
||||
Shipped = 3
|
||||
}
|
||||
|
||||
public class ProjectPart
|
||||
{
|
||||
[Key]
|
||||
public int IdProjectPart { get; set; }
|
||||
|
||||
[Required]
|
||||
[ForeignKey("Project")]
|
||||
public int IdProjectFk { get; set; }
|
||||
|
||||
[Required]
|
||||
[Display(Name = "Naziv")]
|
||||
public string Title { get; set; }
|
||||
|
||||
[Display(Name = "Opis")]
|
||||
public string Description { get; set; }
|
||||
|
||||
[Required]
|
||||
[Display(Name = "Status")]
|
||||
public ProjectPartStatus Status { get; set; } = ProjectPartStatus.Opened;
|
||||
|
||||
[Display(Name = "Datum zaključka")]
|
||||
[DisplayFormat(DataFormatString = "{0:dd.MM.yyyy}", ApplyFormatInEditMode = true)]
|
||||
public DateTime? FinishedDate { get; set; }
|
||||
|
||||
[Display(Name = "Datum odpreme")]
|
||||
[DisplayFormat(DataFormatString = "{0:dd.MM.yyyy}", ApplyFormatInEditMode = true)]
|
||||
public DateTime? ShippedDate { get; set; }
|
||||
|
||||
[Display(Name = "Pot načrtov")]
|
||||
public string PathOfPlans { get; set; }
|
||||
|
||||
[Required]
|
||||
public int ProjectPartNumber { get; set; } = 0;
|
||||
|
||||
[NotMapped]
|
||||
public string ProjectPartNumberFormatted => (Project != null ? Project.ProjectNumberFormatted : "") + $"-{ProjectPartNumber:D4}";
|
||||
|
||||
// ForeignKey
|
||||
public Project Project { get; set; }
|
||||
|
||||
// ProjectPartItem
|
||||
[InverseProperty("ProjectPart")]
|
||||
public virtual ICollection<ProjectPartItem> ProjectPartProjectPartItem { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,164 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using EveryThing.Models.CodeTable;
|
||||
using EveryThing.Models.Invoice;
|
||||
|
||||
namespace EveryThing.Models.Project
|
||||
{
|
||||
public enum ProjectPartItemStatus
|
||||
{
|
||||
[Display(Name = "Odprto")]
|
||||
Opened = 0,
|
||||
|
||||
[Display(Name = "V izdelavi")]
|
||||
InProduction = 1,
|
||||
|
||||
[Display(Name = "Zaključeno")]
|
||||
Finished = 2,
|
||||
|
||||
[Display(Name = "Odpremljeno")]
|
||||
Shipped = 3
|
||||
}
|
||||
|
||||
public class ProjectPartItem
|
||||
{
|
||||
[Key]
|
||||
public int IdProjectPartItem { get; set; }
|
||||
|
||||
[Required]
|
||||
[ForeignKey("ProjectPart")]
|
||||
public int IdProjectPartFk { get; set; }
|
||||
|
||||
[ForeignKey("Item")]
|
||||
[Display(Name = "Artikel")]
|
||||
public int? IdItemFk { get; set; }
|
||||
|
||||
[Required]
|
||||
[Display(Name = "Število kosov")]
|
||||
public float NumberOfItems { get; set; }
|
||||
|
||||
[Display(Name = "Število kompletov")]
|
||||
public float NumberOfSets { get; set; }
|
||||
|
||||
[ForeignKey("Material")]
|
||||
[Display(Name = "Material")]
|
||||
public int? IdMaterialFk { get; set; }
|
||||
|
||||
[Display(Name = "Dimenzije surovca")]
|
||||
public string MaterialDimensions { get; set; }
|
||||
|
||||
[Required]
|
||||
[ForeignKey("MaterialSupplier")]
|
||||
[Display(Name = "Dobavitelj materiala")]
|
||||
public int? IdMaterialSupplierFk { get; set; }
|
||||
|
||||
[Display(Name = "Cena - Material")]
|
||||
public float MaterialPrice { get; set; }
|
||||
|
||||
[Display(Name = "Cena - Delo")]
|
||||
public float WorkPrice { get; set; }
|
||||
|
||||
[Display(Name = "Prodajna cena")]
|
||||
public float SellingPrice { get; set; } = 0;
|
||||
|
||||
[Display(Name = "Število kosov - Zaključeno")]
|
||||
public float NumberOfItemsFinished { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
[Display(Name = "Vrednost - Delo")]
|
||||
public double WorkValue
|
||||
{
|
||||
get => Convert.ToDouble(NumberOfSets) * Convert.ToDouble(NumberOfItems) * Convert.ToDouble(WorkPrice);
|
||||
set => WorkPrice = Convert.ToSingle(Convert.ToDouble(NumberOfSets) * Convert.ToDouble(NumberOfItems == 0
|
||||
? 0
|
||||
: value / (Convert.ToDouble(NumberOfSets) * Convert.ToDouble(NumberOfItems))));
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
[Display(Name = "Vrednost - Delo")]
|
||||
public double MaterialValue
|
||||
{
|
||||
get => Convert.ToDouble(NumberOfSets) * Convert.ToDouble(NumberOfItems) * Convert.ToDouble(MaterialPrice);
|
||||
set => MaterialPrice = Convert.ToSingle(Convert.ToDouble(NumberOfSets) * Convert.ToDouble(NumberOfItems == 0
|
||||
? 0
|
||||
: value / (Convert.ToDouble(NumberOfSets) * Convert.ToDouble(NumberOfItems))));
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
[Display(Name = "Vrednost - cena")]
|
||||
public double CostPrice=> Convert.ToDouble(WorkPrice) + Convert.ToDouble(MaterialPrice);
|
||||
|
||||
[NotMapped]
|
||||
[Display(Name = "Vrednost - strošek")]
|
||||
public double CostValue => Convert.ToDouble(NumberOfSets) * Convert.ToDouble(NumberOfItems) * Convert.ToDouble(CostPrice);
|
||||
|
||||
[NotMapped]
|
||||
[Display(Name = "Prodajna vrednost")]
|
||||
public double SellingValue
|
||||
{
|
||||
get => Convert.ToDouble(NumberOfSets) * Convert.ToDouble(NumberOfItems) * Convert.ToDouble(SellingPrice);
|
||||
set => SellingPrice = Convert.ToSingle(Convert.ToDouble(NumberOfSets) * Convert.ToDouble(NumberOfItems == 0
|
||||
? 0
|
||||
: value / (Convert.ToDouble(NumberOfSets) * Convert.ToDouble(NumberOfItems))));
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
[Display(Name = "RVC")]
|
||||
public double DifferenceInPrice
|
||||
{
|
||||
get => SellingPrice - (MaterialPrice + WorkPrice);
|
||||
set => SellingPrice = Convert.ToSingle(value + (MaterialPrice + WorkPrice));
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
[Display(Name = "RVC")]
|
||||
public double DifferenceInPriceValue => SellingValue - (MaterialValue + WorkValue);
|
||||
|
||||
[NotMapped]
|
||||
[Display(Name = "RVC")]
|
||||
public double DifferenceInPricePercentage =>
|
||||
(Convert.ToDouble(MaterialValue) + Convert.ToDouble(WorkValue)) == 0
|
||||
? 100
|
||||
: ((SellingValue / (MaterialValue + WorkValue) - 1) * 100);
|
||||
|
||||
[Required]
|
||||
[Display(Name = "Status")]
|
||||
public ProjectPartItemStatus Status { get; set; } = ProjectPartItemStatus.Opened;
|
||||
|
||||
[Display(Name = "Datum zaključka")]
|
||||
[DisplayFormat(DataFormatString = "{0:dd.MM.yyyy}", ApplyFormatInEditMode = true)]
|
||||
public DateTime? FinishedDate { get; set; }
|
||||
|
||||
[Display(Name = "Datum odpreme")]
|
||||
[DisplayFormat(DataFormatString = "{0:dd.MM.yyyy}", ApplyFormatInEditMode = true)]
|
||||
public DateTime? ShippingDate { get; set; }
|
||||
|
||||
[Display(Name = "Dobavni rok")]
|
||||
[DisplayFormat(DataFormatString = "{0:dd.MM.yyyy}", ApplyFormatInEditMode = true)]
|
||||
public DateTime? DeliveryDate { get; set; }
|
||||
|
||||
[Display(Name = "Spremenjeno")]
|
||||
public DateTime DateModified { get; set; } = DateTime.Now;
|
||||
|
||||
|
||||
[Required]
|
||||
public int ProjectPartItemNumber { get; set; } = 0;
|
||||
|
||||
[NotMapped]
|
||||
public string ProjectPartNumberFormatted => (ProjectPart != null ? ProjectPart.ProjectPartNumberFormatted : "") + $"-{ProjectPartItemNumber:D4}";
|
||||
|
||||
// ForeignKey
|
||||
public ProjectPart ProjectPart { get; set; }
|
||||
public CodeTablePartner MaterialSupplier { get; set; }
|
||||
public CodeTableItem Item { get; set; }
|
||||
public CodeTableItem Material { get; set; }
|
||||
|
||||
//Invoice item
|
||||
[InverseProperty("ProjectPartItem")]
|
||||
public virtual ICollection<InvoiceItem> InvoiceItem { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -2,25 +2,31 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using DocumentFormat.OpenXml.ExtendedProperties;
|
||||
using EveryThing.Data;
|
||||
using EveryThing.Models;
|
||||
using EveryThing.Models.CodeTable;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace EveryThing.Pages.AdministrationCompanies
|
||||
{
|
||||
[Authorize(Roles = "Administrator")]
|
||||
//[Authorize(Roles = "Administrator")]
|
||||
public class SetupModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
private readonly UserManager<IdentityApplicationUser> _userManager;
|
||||
private readonly SignInManager<IdentityApplicationUser> _signInManager;
|
||||
private readonly RoleManager<IdentityApplicationRole> _roleManager;
|
||||
private readonly ILogger<SetupModel> _logger;
|
||||
|
||||
public SetupModel(UserManager<IdentityApplicationUser> userManager, SignInManager<IdentityApplicationUser> signInManager, ILogger<SetupModel> logger, RoleManager<IdentityApplicationRole> roleManager)
|
||||
public SetupModel(ApplicationDbContext context, UserManager<IdentityApplicationUser> userManager, SignInManager<IdentityApplicationUser> signInManager, ILogger<SetupModel> logger, RoleManager<IdentityApplicationRole> roleManager)
|
||||
{
|
||||
_context = context;
|
||||
_userManager = userManager;
|
||||
_signInManager = signInManager;
|
||||
_logger = logger;
|
||||
@@ -30,10 +36,38 @@ namespace EveryThing.Pages.AdministrationCompanies
|
||||
public async Task<IActionResult> OnGetAsync()
|
||||
{
|
||||
//TODO osnovno podjetje?
|
||||
|
||||
var adminCompany = _context.CodeTableCompanies.FirstOrDefault(x => x.Title == "AdminCompany");
|
||||
if (adminCompany == null)
|
||||
{
|
||||
var countrySlo = _context.CodeTableCountries.FirstAsync(x => x.Code == "SI");
|
||||
adminCompany = new CodeTableCompany
|
||||
{
|
||||
Title = "AdminCompany",
|
||||
Active = true,
|
||||
IdCountryFk = countrySlo.Id,
|
||||
City = "Ravne na Koroškem",
|
||||
Street = "Ulica",
|
||||
HouseNumber = "1",
|
||||
PostNumber = 2380,
|
||||
Post = "Pošta",
|
||||
TaxNumber = "xxxxx",
|
||||
RegistrationNumber = "xxxxx",
|
||||
Email = "email@email.com",
|
||||
Bank = "SI",
|
||||
Iban = "SI",
|
||||
SwiftBic = "SI",
|
||||
Phone = "000 000 000",
|
||||
Ceo = "Admin"
|
||||
|
||||
};
|
||||
_context.CodeTableCompanies.Add(adminCompany);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
var rolesDefinitions = new List<(string RoleName, string RoleDescription)>
|
||||
{
|
||||
("TransportThingUser", "TransporThing uporabniki"),
|
||||
("ProjecThingUser", "ProjecThing uporabniki"),
|
||||
("InvoicingUser", "Fakturiranje uporabniki"),
|
||||
("Administrator", "Administratorji"),
|
||||
};
|
||||
@@ -52,7 +86,9 @@ namespace EveryThing.Pages.AdministrationCompanies
|
||||
}
|
||||
}
|
||||
|
||||
if (_userManager.FindByNameAsync("admin") == null)
|
||||
var user = await _userManager.FindByNameAsync("admin");
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
IdentityApplicationUser identityApplicationUser = new IdentityApplicationUser
|
||||
{
|
||||
@@ -68,7 +104,7 @@ namespace EveryThing.Pages.AdministrationCompanies
|
||||
PhoneNumber = "123456789",
|
||||
PhoneNumberConfirmed = true,
|
||||
Active = true,
|
||||
IdCompanyFk = 1
|
||||
IdCompanyFk = adminCompany.IdCompany
|
||||
};
|
||||
|
||||
var result = await _userManager.CreateAsync(identityApplicationUser, "Master#Admin22!");
|
||||
|
||||
@@ -97,18 +97,19 @@ namespace EveryThing.Pages.CodeTableItems
|
||||
}
|
||||
else
|
||||
{
|
||||
var projectPartItem = _context.ProjectPartItems
|
||||
.OrderByDescending(x => x.DateModified)
|
||||
.ThenByDescending(x => x.IdProjectPartItem)
|
||||
.FirstOrDefault(x => x.IdItemFk == item.IdItem);
|
||||
//TODO ?
|
||||
//var projectPartItem = _context.ProjectPartItems
|
||||
// .OrderByDescending(x => x.DateModified)
|
||||
// .ThenByDescending(x => x.IdProjectPartItem)
|
||||
// .FirstOrDefault(x => x.IdItemFk == item.IdItem);
|
||||
|
||||
if (projectPartItem != null)
|
||||
{
|
||||
materialPrice = projectPartItem.MaterialPrice;
|
||||
workPrice = projectPartItem.WorkPrice;
|
||||
sellingPrice = projectPartItem.SellingPrice;
|
||||
differenceInPricePercentage = projectPartItem.DifferenceInPricePercentage;
|
||||
}
|
||||
//if (projectPartItem != null)
|
||||
//{
|
||||
// materialPrice = projectPartItem.MaterialPrice;
|
||||
// workPrice = projectPartItem.WorkPrice;
|
||||
// sellingPrice = projectPartItem.SellingPrice;
|
||||
// differenceInPricePercentage = projectPartItem.DifferenceInPricePercentage;
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
@@ -136,8 +137,6 @@ namespace EveryThing.Pages.CodeTableItems
|
||||
|
||||
CodeTableItem item = _context.CodeTableItems
|
||||
.Where(x => x.IdCompanyFk == user.IdCompanyFk)
|
||||
.Include(x => x.ItemProjectPartItem)
|
||||
.Include(x => x.ItemProjectPartItemMaterial)
|
||||
.Include(x => x.InvoiceItem)
|
||||
.FirstOrDefault(x => x.IdItem == idCodeTableItem);
|
||||
|
||||
@@ -148,10 +147,7 @@ namespace EveryThing.Pages.CodeTableItems
|
||||
}
|
||||
else
|
||||
{
|
||||
itemInUse = item.ItemProjectPartItem.Count > 0 || item.ItemProjectPartItemMaterial.Count > 0 || item.InvoiceItem.Count > 0;
|
||||
//Cene se json zacikla neki IDK.
|
||||
item.ItemProjectPartItem = null;
|
||||
item.ItemProjectPartItemMaterial = null;
|
||||
itemInUse = item.InvoiceItem.Count > 0;
|
||||
item.InvoiceItem = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
@page
|
||||
@using EveryThing.Models.Project
|
||||
@model EveryThing.Pages.Files.UploadModel
|
||||
|
||||
@{
|
||||
|
||||
@@ -9,7 +9,6 @@ using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using EveryThing.Data;
|
||||
using EveryThing.Models;
|
||||
using EveryThing.Models.Project;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.IO;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
@@ -21,7 +20,7 @@ using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace EveryThing.Pages.Files
|
||||
{
|
||||
[Authorize(Roles = "Administrator,ProjecThingUser")]
|
||||
[Authorize(Roles = "Administrator")]
|
||||
public class UploadModel : PageModel
|
||||
{
|
||||
private readonly IWebHostEnvironment _hostingEnvironment;
|
||||
@@ -112,10 +111,6 @@ namespace EveryThing.Pages.Files
|
||||
|
||||
switch (fileType)
|
||||
{
|
||||
case FileType.ProjectPart:
|
||||
return RedirectToPage("/Projects/Edit", new { id = _context.ProjectParts.FirstOrDefault(x => x.IdProjectPart == idReferenceFk)!.IdProjectFk});
|
||||
case FileType.Project:
|
||||
return RedirectToPage("/Projects/Edit", new { id = idReferenceFk });
|
||||
case FileType.CodeTableItem:
|
||||
return RedirectToPage("/CodeTableItems/Index");
|
||||
default:
|
||||
|
||||
@@ -5,7 +5,6 @@ using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using EveryThing.Data;
|
||||
using EveryThing.Models;
|
||||
using EveryThing.Models.Project;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -47,226 +46,8 @@ namespace EveryThing.Pages
|
||||
|
||||
public IActionResult OnGetData(int year)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
var dateMonthFrom = new DateTime(DateTime.Now.AddDays(-31).Year, DateTime.Now.AddDays(-31).Month, DateTime.Now.AddDays(-31).Day, 0, 0, 0);
|
||||
var dateMonthTo = new DateTime(DateTime.Now.AddDays(-1).Year, DateTime.Now.AddDays(-1).Month, DateTime.Now.AddDays(-1).Day, 23, 59, 59);
|
||||
|
||||
var xAxisMonth = Enumerable.Range(0, 1 + dateMonthTo.Subtract(dateMonthFrom).Days)
|
||||
.Select(offset => dateMonthFrom.AddDays(offset))
|
||||
.OrderBy(x => x)
|
||||
.Select(x => x.ToString("dd.MM.yy"))
|
||||
.Distinct()
|
||||
.ToList();
|
||||
|
||||
var projectPartItemsMonth = _context.ProjectPartItems
|
||||
.Include(x => x.ProjectPart)
|
||||
.ThenInclude(x => x.Project)
|
||||
.Where(x => x.ProjectPart.Project.IdCompanyFk == user.IdCompanyFk && x.ShippingDate >= dateMonthFrom && x.ShippingDate <= dateMonthTo)
|
||||
.ToList();
|
||||
|
||||
//Neka fora z chart JS da ne pozicionira prav ce ni nastavjleno y=0 za prazne
|
||||
//var month = new
|
||||
//{
|
||||
// xAxis = xAxisMonth,
|
||||
// diferenceInPrice = projectPartItemsMonth
|
||||
// .GroupBy(x => new DateTime(((DateTime)x.ShippingDate).Year, ((DateTime)x.ShippingDate).Month, ((DateTime)x.ShippingDate).Day))
|
||||
// .Select(x => new { x = x.Key.ToString("dd.MM.yy"), y = x.Sum(y => y.DifferenceInPriceValue) }),
|
||||
// sales = projectPartItemsMonth
|
||||
// .GroupBy(x => new DateTime(((DateTime)x.ShippingDate).Year, ((DateTime)x.ShippingDate).Month, ((DateTime)x.ShippingDate).Day))
|
||||
// .Select(x => new { x = x.Key.ToString("dd.MM.yy"), y = x.Sum(y => y.SellingValue) }),
|
||||
// expenses = projectPartItemsMonth
|
||||
// .GroupBy(x => new DateTime(((DateTime)x.ShippingDate).Year, ((DateTime)x.ShippingDate).Month, ((DateTime)x.ShippingDate).Day))
|
||||
// .Select(x => new { x = x.Key.ToString("dd.MM.yy"), y = x.Sum(y => y.MaterialValue + y.WorkValue) })
|
||||
//};
|
||||
|
||||
var dicDiferenceInPriceMonth = new Dictionary<string, double>();
|
||||
var dicSalesMonth = new Dictionary<string, double>();
|
||||
var dicExpensesMonth = new Dictionary<string, double>();
|
||||
xAxisMonth.ForEach(x =>
|
||||
{
|
||||
dicDiferenceInPriceMonth[x] = 0;
|
||||
dicSalesMonth[x] = 0;
|
||||
dicExpensesMonth[x] = 0;
|
||||
});
|
||||
|
||||
foreach (var day in projectPartItemsMonth
|
||||
.GroupBy(x => new DateTime(((DateTime)x.ShippingDate).Year, ((DateTime)x.ShippingDate).Month, ((DateTime)x.ShippingDate).Day))
|
||||
.OrderBy(x => x.Key))
|
||||
{
|
||||
var x = day.Key.ToString("dd.MM.yy");
|
||||
dicDiferenceInPriceMonth[x] = day.Sum(x => x.DifferenceInPriceValue);
|
||||
dicSalesMonth[x] = day.Sum(x => x.SellingValue);
|
||||
dicExpensesMonth[x] = day.Sum(x => x.WorkValue + x.MaterialValue);
|
||||
}
|
||||
|
||||
var month = new
|
||||
{
|
||||
xAxis = xAxisMonth,
|
||||
diferenceInPrice = dicDiferenceInPriceMonth.Select(x => new {x = x.Key, y = Math.Round(x.Value, 2) }),
|
||||
sales = dicSalesMonth.Select(x => new {x = x.Key, y = Math.Round(x.Value, 2) }),
|
||||
expenses = dicExpensesMonth.Select(x => new {x = x.Key, y = Math.Round(x.Value, 2) }),
|
||||
};
|
||||
|
||||
//Leto
|
||||
|
||||
var dateYearTo = new DateTime(year, 12, 31, 23, 59, 59);
|
||||
var dateYearFrom = new DateTime(year, 1, 1, 1, 0, 0, 0);
|
||||
|
||||
var xAxisYear = Enumerable.Range(0, 1 + dateYearTo.Subtract(dateYearFrom).Days)
|
||||
.Select(offset => dateYearFrom.AddDays(offset))
|
||||
.OrderBy(x => x)
|
||||
.Select(x => x.ToString("MM.yy"))
|
||||
.Distinct()
|
||||
.ToList();
|
||||
|
||||
var projectPartItemsYear = _context.ProjectPartItems
|
||||
.Include(x => x.ProjectPart)
|
||||
.ThenInclude(x => x.Project)
|
||||
.Where(x => x.ProjectPart.Project.IdCompanyFk == user.IdCompanyFk && x.ShippingDate >= dateYearFrom && x.ShippingDate <= dateYearTo)
|
||||
.ToList();
|
||||
|
||||
//Neka fora z chart JS da ne pozicionira prav ce ni nastavjleno y=0 za prazne
|
||||
//var month = new
|
||||
//{
|
||||
// xAxis = xAxisMonth,
|
||||
// diferenceInPrice = projectPartItemsMonth
|
||||
// .GroupBy(x => new DateTime(((DateTime)x.ShippingDate).Year, ((DateTime)x.ShippingDate).Month, ((DateTime)x.ShippingDate).Day))
|
||||
// .Select(x => new { x = x.Key.ToString("dd.MM.yy"), y = x.Sum(y => y.DifferenceInPriceValue) }),
|
||||
// sales = projectPartItemsMonth
|
||||
// .GroupBy(x => new DateTime(((DateTime)x.ShippingDate).Year, ((DateTime)x.ShippingDate).Month, ((DateTime)x.ShippingDate).Day))
|
||||
// .Select(x => new { x = x.Key.ToString("dd.MM.yy"), y = x.Sum(y => y.SellingValue) }),
|
||||
// expenses = projectPartItemsMonth
|
||||
// .GroupBy(x => new DateTime(((DateTime)x.ShippingDate).Year, ((DateTime)x.ShippingDate).Month, ((DateTime)x.ShippingDate).Day))
|
||||
// .Select(x => new { x = x.Key.ToString("dd.MM.yy"), y = x.Sum(y => y.MaterialValue + y.WorkValue) })
|
||||
//};
|
||||
|
||||
var dicDiferenceInPriceYear = new Dictionary<string, double>();
|
||||
var dicSalesYear = new Dictionary<string, double>();
|
||||
var dicExpensesYear = new Dictionary<string, double>();
|
||||
xAxisYear.ForEach(x =>
|
||||
{
|
||||
dicDiferenceInPriceYear[x] = 0;
|
||||
dicSalesYear[x] = 0;
|
||||
dicExpensesYear[x] = 0;
|
||||
});
|
||||
|
||||
foreach (var day in projectPartItemsYear
|
||||
.GroupBy(x => new DateTime(((DateTime)x.ShippingDate).Year, ((DateTime)x.ShippingDate).Month, ((DateTime)x.ShippingDate).Day))
|
||||
.OrderBy(x => x.Key))
|
||||
{
|
||||
var x = day.Key.ToString("MM.yy");
|
||||
dicDiferenceInPriceYear[x] = day.Sum(x => x.DifferenceInPriceValue);
|
||||
dicSalesYear[x] = day.Sum(x => x.SellingValue);
|
||||
dicExpensesYear[x] = day.Sum(x => x.WorkValue + x.MaterialValue);
|
||||
}
|
||||
|
||||
var yearData = new
|
||||
{
|
||||
xAxis = xAxisYear,
|
||||
diferenceInPrice = dicDiferenceInPriceYear.Select(x => new { x = x.Key, y = Math.Round(x.Value, 2) }),
|
||||
sales = dicSalesYear.Select(x => new { x = x.Key, y = Math.Round(x.Value, 2) }),
|
||||
expenses = dicExpensesYear.Select(x => new { x = x.Key, y = Math.Round(x.Value, 2) }),
|
||||
};
|
||||
|
||||
//Zgornji napisi - labels
|
||||
var dateLabelsFrom = new DateTime(DateTime.Now.AddDays(-31).Year, DateTime.Now.AddDays(-31).Month, DateTime.Now.AddDays(-31).Day, 0, 0, 0);
|
||||
var dateLabelsTo = new DateTime(DateTime.Now.AddDays(-1).Year, DateTime.Now.AddDays(-1).Month, DateTime.Now.AddDays(-1).Day, 23, 59, 59);
|
||||
|
||||
var projectPartItemsLabels = _context.ProjectPartItems
|
||||
.Include(x => x.ProjectPart)
|
||||
.ThenInclude(x => x.Project)
|
||||
.Where(x => x.ProjectPart.Project.IdCompanyFk == user.IdCompanyFk && x.ShippingDate >= dateLabelsFrom && x.ShippingDate <= dateLabelsTo)
|
||||
.ToList();
|
||||
|
||||
var labels = new
|
||||
{
|
||||
diferenceInPrice = Math.Round(projectPartItemsLabels.Sum(x => x.DifferenceInPriceValue),2).ToString("#,###,##0.00", new CultureInfo("sl-SI")),
|
||||
sales = Math.Round(projectPartItemsLabels.Sum(x => x.SellingValue), 2).ToString("#,###,##0.00", new CultureInfo("sl-SI")),
|
||||
expenses = Math.Round(projectPartItemsLabels.Sum(x => x.WorkValue + x.MaterialValue), 2).ToString("#,###,##0.00", new CultureInfo("sl-SI")),
|
||||
activeProjects = _context.Projects.Count(x => x.IdCompanyFk == user.IdCompanyFk && x.Status != ProjectStatus.Finished)
|
||||
};
|
||||
|
||||
//Graf po partnerjih preteklo leto
|
||||
var datePartnersYearTo = new DateTime(year, 12, 31, 23, 59, 59);
|
||||
var datePartnersYearFrom = new DateTime(year, 1, 1, 1, 0, 0, 0);
|
||||
|
||||
var projectPartItemsPartnersYear = _context.ProjectPartItems
|
||||
.Include(x => x.ProjectPart)
|
||||
.ThenInclude(x => x.Project)
|
||||
.ThenInclude(x => x.Partner)
|
||||
.Where(x => x.ProjectPart.Project.IdCompanyFk == user.IdCompanyFk && x.ShippingDate >= datePartnersYearFrom && x.ShippingDate <= datePartnersYearTo)
|
||||
.ToList();
|
||||
|
||||
|
||||
var diferenceInPricePartnersYear = new List<dynamic>();
|
||||
var salesPartnersYear = new List<dynamic>();
|
||||
var expensesPartnersYear = new List<dynamic>();
|
||||
var xAxisPartnersYear = new List<string>();
|
||||
|
||||
foreach (var partner in projectPartItemsPartnersYear
|
||||
.GroupBy(x => x.ProjectPart.Project.Partner.Title)
|
||||
.OrderBy(x => x.Key))
|
||||
{
|
||||
var x = partner.Key;
|
||||
if (x.Length > 20)
|
||||
x = x.Substring(0, 20);
|
||||
|
||||
xAxisPartnersYear.Add(x);
|
||||
diferenceInPricePartnersYear.Add(new {x = x, y = Math.Round(partner.Sum(x => x.DifferenceInPriceValue))});
|
||||
salesPartnersYear.Add(new {x = x, y = Math.Round(partner.Sum(x => x.SellingValue))});
|
||||
expensesPartnersYear.Add(new {x = x, y = Math.Round(partner.Sum(x => x.WorkValue+ x.MaterialValue))});
|
||||
}
|
||||
|
||||
var partnersYear = new
|
||||
{
|
||||
xAxis = xAxisPartnersYear,
|
||||
diferenceInPrice = diferenceInPricePartnersYear,
|
||||
sales = salesPartnersYear,
|
||||
expenses = expensesPartnersYear,
|
||||
};
|
||||
|
||||
//Graf po projetkih preteklo leto
|
||||
var dateProjectsYearTo = new DateTime(year, 12, 31, 23, 59, 59);
|
||||
var dateProjectsYearFrom = new DateTime(year, 1, 1, 1, 0, 0, 0);
|
||||
|
||||
var projectPartItemsProjectsYear = _context.ProjectPartItems
|
||||
.Include(x => x.ProjectPart)
|
||||
.ThenInclude(x => x.Project)
|
||||
.Where(x => x.ProjectPart.Project.IdCompanyFk == user.IdCompanyFk && x.ShippingDate >= dateProjectsYearFrom && x.ShippingDate <= dateProjectsYearTo)
|
||||
.ToList();
|
||||
|
||||
|
||||
var diferenceInPriceProjectsYear = new List<dynamic>();
|
||||
var salesProjectsYear = new List<dynamic>();
|
||||
var expensesProjectsYear = new List<dynamic>();
|
||||
var xAxisProjectsYear = new List<string>();
|
||||
|
||||
foreach (var partner in projectPartItemsProjectsYear
|
||||
.GroupBy(x => x.ProjectPart.Project.Title)
|
||||
.OrderBy(x => x.Key))
|
||||
{
|
||||
var x = partner.Key;
|
||||
if (x.Length > 20)
|
||||
x = x.Substring(0, 20);
|
||||
|
||||
xAxisProjectsYear.Add(x);
|
||||
diferenceInPriceProjectsYear.Add(new { x = x, y = Math.Round(partner.Sum(x => x.DifferenceInPriceValue)) });
|
||||
salesProjectsYear.Add(new { x = x, y = Math.Round(partner.Sum(x => x.SellingValue)) });
|
||||
expensesProjectsYear.Add(new { x = x, y = Math.Round(partner.Sum(x => x.WorkValue + x.MaterialValue)) });
|
||||
}
|
||||
|
||||
var projectsYear = new
|
||||
{
|
||||
xAxis = xAxisProjectsYear,
|
||||
diferenceInPrice = diferenceInPriceProjectsYear,
|
||||
sales = salesProjectsYear,
|
||||
expenses = expensesProjectsYear,
|
||||
};
|
||||
|
||||
var data = new { month, year = yearData, labels, partnersYear, projectsYear };
|
||||
|
||||
return new JsonResult(new { data, error = "", successful = true });
|
||||
return new JsonResult(new { data = new List<int>(), error = "", successful = true });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
@page
|
||||
@using EveryThing.Models.Invoice
|
||||
@using Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
@model EveryThing.Pages.Invoices.EditModel
|
||||
@{
|
||||
ViewData["Title"] = "Vnos fakture";
|
||||
@@ -36,6 +38,14 @@
|
||||
.table-status {
|
||||
width: 140px;
|
||||
}
|
||||
|
||||
.table-hover>tbody>tr.no-hover:hover {
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
.input-number {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
|
||||
<form method="post" onsubmit="handleEditors()">
|
||||
@@ -176,7 +186,10 @@
|
||||
<th class="table-header-number">Rabat</th>
|
||||
<th class="table-header-number">DDV</th>
|
||||
<th class="table-header-number">Vrednost</th>
|
||||
<th>Status</th>
|
||||
@if (Model.Invoice.Type != Invoice.InvoiceType.Invoice)
|
||||
{
|
||||
<th>Status</th>
|
||||
}
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@@ -11,13 +11,11 @@ using EveryThing.Data;
|
||||
using EveryThing.Models;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using EveryThing.Models.Project;
|
||||
using System.Text.Json;
|
||||
using static EveryThing.Pages.Projects.EditModel;
|
||||
|
||||
namespace EveryThing.Pages.Invoices
|
||||
{
|
||||
[Authorize(Roles = "Administrator,InvoicingUser,ProjecThingUser")]
|
||||
[Authorize(Roles = "Administrator,InvoicingUser")]
|
||||
public class EditModel : PageModel
|
||||
{
|
||||
public class EditInvoiceItemData
|
||||
@@ -188,6 +186,7 @@ namespace EveryThing.Pages.Invoices
|
||||
{
|
||||
var item = _context.InvoiceItems
|
||||
.Include(x => x.Item)
|
||||
.Include(x => x.Invoice)
|
||||
.First(x => x.IdInvoiceItem == id);
|
||||
|
||||
return Partial("InvoiceItemDetails", item);
|
||||
|
||||
@@ -106,15 +106,6 @@
|
||||
break;
|
||||
}
|
||||
</td>
|
||||
@if (Model.ShowProjects)
|
||||
{
|
||||
<td>
|
||||
@if (item.InvoiceInvoiceItem.FirstOrDefault() != null)
|
||||
{
|
||||
<a asp-page="/Projects/Edit" asp-route-id="@item.InvoiceInvoiceItem.FirstOrDefault()?.ProjectPartItem?.ProjectPart?.Project?.IdProject">@string.Join(" ", item.InvoiceInvoiceItem.Select(x => x.ProjectPartItem?.ProjectPart?.Project?.ProjectNumberFormatted).Distinct())</a>
|
||||
}
|
||||
</td>
|
||||
}
|
||||
<td class="text-right">
|
||||
<a class="btn btn-xs icon-btn btn-outline-success borderless" href='javascript:;' onclick="generateExcel(this)" data-toggle="tooltip" data-placement="left" title="Izvozi pozicije v .xlsx format" data-state="success"><i class="far fa-file-excel"></i></a>
|
||||
<a class="btn btn-xs icon-btn btn-outline-primary borderless" asp-page="/Invoices/Print" asp-route-id="@item.IdInvoice" data-toggle="tooltip" data-placement="top" title="Tiskanje" data-state="primary"><i class="ion ion-md-print"></i></a>
|
||||
|
||||
@@ -7,7 +7,6 @@ using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using EveryThing.Data;
|
||||
using EveryThing.Models;
|
||||
using EveryThing.Models.Project;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using ClosedXML.Excel;
|
||||
@@ -16,7 +15,7 @@ using Microsoft.AspNetCore.Hosting;
|
||||
|
||||
namespace EveryThing.Pages.Invoices
|
||||
{
|
||||
[Authorize(Roles = "Administrator,InvoicingUser,ProjecThingUser")]
|
||||
[Authorize(Roles = "Administrator,InvoicingUser")]
|
||||
public class IndexModel : PageModel
|
||||
{
|
||||
private readonly IWebHostEnvironment _hostingEnvironment;
|
||||
@@ -37,8 +36,6 @@ namespace EveryThing.Pages.Invoices
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
ShowProjects = User.IsInRole("ProjecThingUser") || User.IsInRole("Administrator");
|
||||
|
||||
var invoiceType = (Models.Invoice.Invoice.InvoiceType)type;
|
||||
|
||||
//Kako spraviti type preko osvezovanja
|
||||
@@ -46,30 +43,13 @@ namespace EveryThing.Pages.Invoices
|
||||
ViewData["SearchString"] = searchString;
|
||||
ViewData["FinishedProjects"] = finishedProjects == "on" ? "checked" : "";
|
||||
|
||||
if (ShowProjects)
|
||||
{
|
||||
Invoice = await _context.Invoices
|
||||
.Include(p => p.Company)
|
||||
.Include(p => p.Partner)
|
||||
.Include(x => x.InvoiceInvoiceItem)
|
||||
.ThenInclude(x => x.ProjectPartItem)
|
||||
.ThenInclude(x => x.ProjectPart)
|
||||
.ThenInclude(x => x.Project)
|
||||
.Where(x => x.Type == invoiceType)
|
||||
.OrderBy(x => x.InvoiceYear)
|
||||
.ThenBy(x => x.InvoiceNumber)
|
||||
.ToListAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
Invoice = await _context.Invoices
|
||||
.Include(p => p.Company)
|
||||
.Include(p => p.Partner)
|
||||
.Where(x => x.Type == invoiceType)
|
||||
.OrderBy(x => x.InvoiceYear)
|
||||
.ThenBy(x => x.InvoiceNumber)
|
||||
.ToListAsync();
|
||||
}
|
||||
Invoice = await _context.Invoices
|
||||
.Include(p => p.Company)
|
||||
.Include(p => p.Partner)
|
||||
.Where(x => x.Type == invoiceType)
|
||||
.OrderBy(x => x.InvoiceYear)
|
||||
.ThenBy(x => x.InvoiceNumber)
|
||||
.ToListAsync();
|
||||
|
||||
// Search string
|
||||
if (!string.IsNullOrEmpty(searchString))
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
@model EveryThing.Models.Invoice.InvoiceItem
|
||||
@using EveryThing.Models.Invoice
|
||||
@model EveryThing.Models.Invoice.InvoiceItem
|
||||
|
||||
<tr data-idinvoiceitem="@Model.IdInvoiceItem">
|
||||
<td>
|
||||
@Html.DisplayFor(x => Model.Item.Title) <br/>
|
||||
@Html.DisplayFor(x => Model.ItemDescription)
|
||||
@Html.DisplayFor(x => Model.ItemDisplay)
|
||||
</td>
|
||||
<td class="table-number">@Html.DisplayFor(x => Model.Quantity)</td>
|
||||
<td class="table-number">@Html.DisplayFor(x => Model.Price)</td>
|
||||
<td class="table-number">@Html.DisplayFor(x => Model.Discount)</td>
|
||||
<td class="table-number">@Html.DisplayFor(x => Model.Tax)</td>
|
||||
<td class="table-number">@Html.DisplayFor(x => Model.TotalValue)</td>
|
||||
<td class="table-status">@Html.DisplayFor(modelItem => Model.State)</td>
|
||||
@if (Model.Invoice.Type != Invoice.InvoiceType.Invoice)
|
||||
{
|
||||
<td class="table-status">@Html.DisplayFor(modelItem => Model.State)</td>
|
||||
}
|
||||
<td class="text-right" style="width: 70px;">
|
||||
<a class="btn btn-xs icon-btn btn-outline-secondary borderless" data-state="secondary" href='javascript:;'><i class="fas fa-pencil-alt" hx-get="@Url.Page("Edit", "InvoiceItemEdit", new {id = Model.IdInvoiceItem})" hx-swap="outerHTML" hx-target="closest tr"></i></a>
|
||||
<a class="btn btn-xs icon-btn btn-outline-danger borderless" data-state="danger" href='javascript:;' onclick="deleteInvoiceItem(this)"><i class="fas fa-times"></i></a>
|
||||
|
||||
@@ -1,35 +1,94 @@
|
||||
@model EveryThing.Pages.Invoices.EditModel.EditInvoiceItemData
|
||||
|
||||
<tr>
|
||||
<tr class="no-hover">
|
||||
@using (Html.BeginForm("UpdateInvoiceItem", "Edit", FormMethod.Post))
|
||||
{
|
||||
<td>
|
||||
<td colspan="100">
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-2 col-form-label">Artikel</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="hidden" asp-for="InvoiceItem.IdInvoiceItem" />
|
||||
<select id="selTblItem_@(Model.InvoiceItem.IdInvoiceItem.ToString())" asp-for="InvoiceItem.IdItemFk" class="form-control" asp-items="Model.SelectListItems" style="width: 100%"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-2 col-form-label">Opis</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea id="inpTblItemDescription_@(Model.InvoiceItem.IdInvoiceItem.ToString())" asp-for="InvoiceItem.ItemDescription" class="form-control" rows="3" style="width: 100%; resize: none;"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-4 col-form-label">Količina</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="inpTblQuantity_@(Model.InvoiceItem.IdInvoiceItem.ToString())" asp-for="InvoiceItem.Quantity" class="form-control input-number" style="width:100%" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-4 col-form-label">Rabat</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="inpTblDiscount_@(Model.InvoiceItem.IdInvoiceItem.ToString())" asp-for="InvoiceItem.Discount" class="form-control input-number" style="width: 100%" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-4 col-form-label">Cena</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="inpTblPrice_@(Model.InvoiceItem.IdInvoiceItem.ToString())" asp-for="InvoiceItem.Price" class="form-control input-number" style="width: 100%" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-4 col-form-label">DDV</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="inpTblTax_@(Model.InvoiceItem.IdInvoiceItem.ToString())" asp-for="InvoiceItem.Tax" class="form-control input-number" style="width: 100%" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-2 col-form-label">Status</label>
|
||||
<div class="col-sm-10">
|
||||
<select id="selTblStatus_@(Model.InvoiceItem.IdInvoiceItem.ToString())" asp-for="InvoiceItem.State" asp-items="Html.GetEnumSelectList<EveryThing.Models.Invoice.InvoiceItem.InvoiceItemState>()" class="form-control" style="width: 100%">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="width: 100%; text-align: right;">
|
||||
<a class="btn btn-primary btn-sm" href='javascript:;' data-state="success" data-iditem="@(Model.InvoiceItem.IdInvoiceItem)" onclick="updateInvoiceItem(this)">Potrdi</a>
|
||||
<a class="btn btn-default btn-sm" id="btnTblCancel_@(Model.InvoiceItem.IdInvoiceItem.ToString())" href='javascript:;' class="btn btn-xs icon-btn btn-outline-danger borderless" data-state="danger" hx-get="@Url.Page("Edit", "InvoiceItemDetails", new { id = Model.InvoiceItem.IdInvoiceItem })" hx-swap="outerHTML" hx-target="closest tr">Prekliči</a>
|
||||
</div>
|
||||
</td>
|
||||
@* <td>
|
||||
<input type="hidden" asp-for="InvoiceItem.IdInvoiceItem" />
|
||||
<select id="selTblItem_@(Model.InvoiceItem.IdInvoiceItem.ToString())" asp-for="InvoiceItem.IdItemFk" class="form-control" asp-items="Model.SelectListItems" style="width: 100%"></select>
|
||||
<input id="inpTblItemDescription_@(Model.InvoiceItem.IdInvoiceItem.ToString())" asp-for="InvoiceItem.ItemDescription" class="form-control" style="width:100%" />
|
||||
</td>
|
||||
<td class="table-eddit table-price-edit">
|
||||
<input id="inpTblQuantity_@(Model.InvoiceItem.IdInvoiceItem.ToString())" asp-for="InvoiceItem.Quantity" class="form-control" style="width:100%"/>
|
||||
|
||||
</td>
|
||||
<td class="table-eddit table-price-edit">
|
||||
<input id="inpTblPrice_@(Model.InvoiceItem.IdInvoiceItem.ToString())" asp-for="InvoiceItem.Price" class="form-control" style="width: 100%"/>
|
||||
|
||||
</td>
|
||||
<td class="table-eddit table-price-edit">
|
||||
<input id="inpTblDiscount_@(Model.InvoiceItem.IdInvoiceItem.ToString())" asp-for="InvoiceItem.Discount" class="form-control"style="width: 100%"/>
|
||||
</td>
|
||||
<td class="table-eddit table-price-edit">
|
||||
<input id="inpTblTax_@(Model.InvoiceItem.IdInvoiceItem.ToString())" asp-for="InvoiceItem.Tax" class="form-control" style="width: 100%"/>
|
||||
</td>
|
||||
<td class="table-eddit table-price-edit">
|
||||
@Html.DisplayFor(x => Model.InvoiceItem.TotalValue)
|
||||
</td>
|
||||
<td class="table-status">
|
||||
<select id="selTblStatus_@(Model.InvoiceItem.IdInvoiceItem.ToString())" asp-for="InvoiceItem.State" asp-items="Html.GetEnumSelectList<EveryThing.Models.Invoice.InvoiceItem.InvoiceItemState>()" class="form-control" style="width: 100%">
|
||||
</select>
|
||||
|
||||
</td>
|
||||
<td class="text-right" style="width: 70px;">
|
||||
<a class="btn btn-xs icon-btn btn-outline-success borderless" href='javascript:;' data-state="success" data-iditem="@(Model.InvoiceItem.IdInvoiceItem)" onclick="updateInvoiceItem(this)"><i class="fas fa-check"></i></a>
|
||||
<a id="btnTblCancel_@(Model.InvoiceItem.IdInvoiceItem.ToString())" href='javascript:;' class="btn btn-xs icon-btn btn-outline-danger borderless" data-state="danger" hx-get="@Url.Page("Edit", "InvoiceItemDetails", new { id = Model.InvoiceItem.IdInvoiceItem })" hx-swap="outerHTML" hx-target="closest tr"><i class="fas fa-ban"></i></a>
|
||||
</td>
|
||||
</td>*@
|
||||
}
|
||||
</tr>
|
||||
|
||||
@@ -94,18 +94,6 @@ namespace EveryThing.Pages.Invoices
|
||||
|
||||
SetTranslation(translationLanguage, Invoice.State);
|
||||
|
||||
var showProjects = User.IsInRole("ProjecThingUser") || User.IsInRole("Administrator");
|
||||
|
||||
if (showProjects)
|
||||
{
|
||||
var project = _context.InvoiceItems
|
||||
.Include(x => x.ProjectPartItem)
|
||||
.ThenInclude(x => x.ProjectPart)
|
||||
.ThenInclude(x => x.Project).FirstOrDefault(x => x.IdInvoiceFk == Invoice.IdInvoice);
|
||||
if (project != null && project.ProjectPartItem != null)
|
||||
ProjectNumber = project.ProjectPartItem.ProjectPart.Project.ProjectNumberFormatted;
|
||||
}
|
||||
|
||||
return Page();
|
||||
}
|
||||
|
||||
|
||||
@@ -45,15 +45,6 @@
|
||||
<a asp-page="/TransportLoadingOrder/Index" class="sidenav-link"><i class="sidenav-icon fas fa-truck-loading"></i><div>Nakladi/Razkladi</div></a>
|
||||
</li>
|
||||
}
|
||||
@if (User.IsInRole("Administrator") || User.IsInRole("ProjecThingUser"))
|
||||
{
|
||||
<li class="sidenav-divider mb-1"></li>
|
||||
<li class="sidenav-header small font-weight-semibold">PROJECTHING</li>
|
||||
|
||||
<li class="sidenav-item@(currentPage.StartsWith("/Projects/") ? " active" : "")">
|
||||
<a asp-page="/Projects/Index" class="sidenav-link"><i class="sidenav-icon fas fa-project-diagram"></i><div>Projekti</div></a>
|
||||
</li>
|
||||
}
|
||||
@if (User.IsInRole("Administrator") || User.IsInRole("ProjecThingUser") || User.IsInRole("InvoicingUser"))
|
||||
{
|
||||
<li class="sidenav-divider mb-1"></li>
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
@page
|
||||
@model EveryThing.Pages.Projects.CreateModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Nov projekt";
|
||||
Layout = "~/Pages/Layouts/_Layout.cshtml";
|
||||
}
|
||||
|
||||
<form method="post">
|
||||
|
||||
<h4 class="d-flex justify-content-between align-items-center w-100 font-weight-bold py-1 mb-4">
|
||||
<span>
|
||||
<span class="text-muted font-weight-light">Projekt /</span> Nov
|
||||
</span>
|
||||
</h4>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="card">
|
||||
<h6 class="card-header">
|
||||
Podatki projekta
|
||||
</h6>
|
||||
<div class="card-body">
|
||||
<div class="form-group">
|
||||
<label asp-for="Project.Title" class="form-label"></label>
|
||||
<input autocomplete="off" asp-for="Project.Title" class="form-control" />
|
||||
<span asp-validation-for="Project.Title" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Project.IdPartnerFk" class="control-label"></label>
|
||||
<select asp-for="Project.IdPartnerFk" class="form-control" asp-items="ViewBag.IdPartnerFk"></select>
|
||||
<span asp-validation-for="Project.IdPartnerFk" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Project.Description" class="form-label"></label>
|
||||
<input autocomplete="off" asp-for="Project.Description" class="form-control" />
|
||||
<span asp-validation-for="Project.Description" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer py-3 text-right">
|
||||
<button type="submit" class="btn btn-primary">Dodaj projekt</button>
|
||||
<a asp-page="Index" class="btn btn-default">Prekliči</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
|
||||
</form>
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using EveryThing.Data;
|
||||
using EveryThing.Models;
|
||||
using EveryThing.Models.Project;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace EveryThing.Pages.Projects
|
||||
{
|
||||
[Authorize(Roles = "Administrator,ProjecThingUser")]
|
||||
public class CreateModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
private readonly UserManager<IdentityApplicationUser> _userManager;
|
||||
private readonly SignInManager<IdentityApplicationUser> _loginManager;
|
||||
private readonly RoleManager<IdentityApplicationRole> _roleManager;
|
||||
|
||||
public CreateModel(ApplicationDbContext context, UserManager<IdentityApplicationUser> userManager, SignInManager<IdentityApplicationUser> loginManager, RoleManager<IdentityApplicationRole> roleManager)
|
||||
{
|
||||
_context = context;
|
||||
_userManager = userManager;
|
||||
_loginManager = loginManager;
|
||||
_roleManager = roleManager;
|
||||
}
|
||||
|
||||
public IActionResult OnGet()
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
ViewData["IdPartnerFk"] = new SelectList(_context.CodeTablePartners.Where(x => x.IdCompanyFk == user.IdCompanyFk && x.Active), "IdPartner", "Title");
|
||||
|
||||
return Page();
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public Models.Project.Project Project { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return Page();
|
||||
}
|
||||
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
Project.IdCompanyFk = user.IdCompanyFk;
|
||||
Project.Status = ProjectStatus.Opened;
|
||||
|
||||
Project.ProjectYear = DateTime.Now.Year;
|
||||
var items = _context.Projects
|
||||
.Where(x => x.IdCompanyFk == user.IdCompanyFk
|
||||
&& x.ProjectYear == Project.ProjectYear).ToList();
|
||||
|
||||
Project.ProjectNumber = items.Count <= 0 ? 1 : items.Max(x => x.ProjectNumber) + 1;
|
||||
|
||||
_context.Projects.Add(Project);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return RedirectToPage("./Edit", new { id = Project.IdProject });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,250 +0,0 @@
|
||||
@page
|
||||
@using EveryThing.Models.Project
|
||||
@model EveryThing.Pages.Projects.CreateEditPartItemModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Nov del projekta";
|
||||
Layout = "~/Pages/Layouts/_Layout.cshtml";
|
||||
}
|
||||
<link rel="stylesheet" href="~/vendor/libs/select2/select2.css" asp-append-version="true" />
|
||||
|
||||
|
||||
<form method="post">
|
||||
|
||||
<h4 class="d-flex justify-content-between align-items-center w-100 font-weight-bold py-1 mb-4">
|
||||
<span>
|
||||
<span class="text-muted font-weight-light">Projekt /</span>
|
||||
@if ((bool)ViewData["Edit"])
|
||||
{
|
||||
<span> Urejanje pozicije dela projekta</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span> Nova pozicija dela projekta</span>
|
||||
}
|
||||
|
||||
</span>
|
||||
</h4>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="card">
|
||||
<h6 class="card-header">
|
||||
Podatki pozicije
|
||||
@if ((bool)ViewData["Edit"])
|
||||
{
|
||||
<i>@Model.ProjectPartItem.ProjectPartNumberFormatted</i>
|
||||
}
|
||||
</h6>
|
||||
<div class="card-body">
|
||||
<input type="hidden" asp-for="ProjectPartItem.IdProjectPartFk" />
|
||||
<input type="hidden" asp-for="IdProject" />
|
||||
<input type="hidden" asp-for="ProjectPartItem.IdProjectPartItem" />
|
||||
<input type="hidden" asp-for="ProjectPartItem.ProjectPartItemNumber" />
|
||||
<input type="hidden" asp-for="@ViewData["Edit"]" name="edit" />
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="form-group">
|
||||
<label asp-for="ProjectPartItem.IdItemFk" class="form-label"></label>
|
||||
<div class="form-row">
|
||||
<div class="col-12">
|
||||
<select id="selCodeTableItem" asp-for="ProjectPartItem.IdItemFk" class="form-control select2" asp-items="ViewBag.IdItemFk"></select>
|
||||
<button class="btn btn-success" type="button" onclick="copyDataFromLastPartItem();">Napolni prejšnje</button>
|
||||
<button class="btn btn-primary" type="button" onclick="addNewCodeTableItem();">Novi artikel</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="ProjectPartItem.NumberOfItems" class="form-label"></label>
|
||||
<input asp-for="ProjectPartItem.NumberOfItems" class="form-control" />
|
||||
<span asp-validation-for="ProjectPartItem.NumberOfItems" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="ProjectPartItem.NumberOfSets" class="form-label"></label>
|
||||
<input asp-for="ProjectPartItem.NumberOfSets" class="form-control" />
|
||||
<span asp-validation-for="ProjectPartItem.NumberOfSets" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="form-group">
|
||||
<label asp-for="ProjectPartItem.IdMaterialFk" class="form-label"></label>
|
||||
<div class="form-row">
|
||||
<div class="col-9">
|
||||
<select id="selCodeTableItemMaterial" asp-for="ProjectPartItem.IdMaterialFk" class="form-control select2" asp-items="ViewBag.IdMaterialFk"></select>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<button class="btn btn-primary" type="button" onclick="addNewCodeTableItemMaterial();">Novi material</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="form-group">
|
||||
<label asp-for="ProjectPartItem.MaterialDimensions" class="form-label"></label>
|
||||
<input asp-for="ProjectPartItem.MaterialDimensions" class="form-control" />
|
||||
<span asp-validation-for="ProjectPartItem.MaterialDimensions" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="form-group">
|
||||
<label asp-for="ProjectPartItem.IdMaterialSupplierFk" class="form-label"></label>
|
||||
<select asp-for="ProjectPartItem.IdMaterialSupplierFk" class="form-control select2" asp-items="ViewBag.IdMaterialSupplierFk"></select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="ProjectPartItem.MaterialPrice" class="form-label"></label>
|
||||
<input asp-for="ProjectPartItem.MaterialPrice" class="form-control" />
|
||||
<span asp-validation-for="ProjectPartItem.MaterialPrice" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="ProjectPartItem.WorkPrice" class="form-label"></label>
|
||||
<input asp-for="ProjectPartItem.WorkPrice" class="form-control" />
|
||||
<span asp-validation-for="ProjectPartItem.WorkPrice" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="ProjectPartItem.SellingPrice" class="form-label"></label>
|
||||
<input asp-for="ProjectPartItem.SellingPrice" class="form-control" />
|
||||
<span asp-validation-for="ProjectPartItem.SellingPrice" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="ProjectPartItem.DeliveryDate" class="form-label"></label>
|
||||
@Html.TextBoxFor(m => m.ProjectPartItem.DeliveryDate, "{0:yyyy-MM-dd}", new { @class = "form-control", type = "date" })
|
||||
<span asp-validation-for="ProjectPartItem.DeliveryDate" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="ProjectPartItem.Status" class="form-label"></label>
|
||||
<select asp-for="ProjectPartItem.Status" asp-items="Html.GetEnumSelectList<ProjectPartItemStatus>()" class="form-control">
|
||||
<option>Izberite status</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label asp-for="ProjectPartItem.ShippingDate" class="form-label"></label>
|
||||
@Html.TextBoxFor(m => m.ProjectPartItem.ShippingDate, "{0:yyyy-MM-dd}", new { @class = "form-control", type = "date" })
|
||||
<span asp-validation-for="ProjectPartItem.ShippingDate" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer py-3 text-right">
|
||||
@if (ViewData["Edit"] != null && (bool)ViewData["Edit"])
|
||||
{
|
||||
<button type="submit" class="btn btn-primary">Shrani</button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<button type="submit" class="btn btn-primary">Dodaj del projekta</button>
|
||||
}
|
||||
|
||||
<a asp-page="Edit" asp-route-id="@ViewBag.IdProject" class="btn btn-default">Prekliči</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<div id="divModalCodetableItemAddEditPlaceholder"></div>
|
||||
@Html.AntiForgeryToken()
|
||||
</form>
|
||||
|
||||
@section Scripts {
|
||||
@{
|
||||
await Html.RenderPartialAsync("_ValidationScriptsPartial");
|
||||
}
|
||||
<script src="~/js/codeTableItemHelper.js?v=3" asp-append-version="true"></script>
|
||||
<script src="~/vendor/libs/select2/select2.js" asp-append-version="true"></script>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('[data-toggle="tooltip"]').tooltip({ container: 'table' });
|
||||
$('.select2').select2();
|
||||
});
|
||||
|
||||
function addNewCodeTableItem() {
|
||||
codeTableItemAddEdit('#divModalCodetableItemAddEditPlaceholder',
|
||||
false,
|
||||
null,
|
||||
(idCodeTableItem) => {
|
||||
refreshCodeTableItems('#selCodeTableItem', idCodeTableItem, 0);
|
||||
});
|
||||
}
|
||||
|
||||
function addNewCodeTableItemMaterial() {
|
||||
codeTableItemAddEdit('#divModalCodetableItemAddEditPlaceholder',
|
||||
false,
|
||||
null,
|
||||
(idCodeTableItem) => {
|
||||
refreshCodeTableItems('#selCodeTableItemMaterial', idCodeTableItem, 1);
|
||||
},
|
||||
null,
|
||||
1);
|
||||
}
|
||||
|
||||
function refreshCodeTableItems(selector, idToSelect, type) {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "CreateEditPartItem/?handler=CodeTableItems",
|
||||
data: {
|
||||
type
|
||||
},
|
||||
success: function(data) {
|
||||
console.log(data);
|
||||
$(selector).empty();
|
||||
$(data.items).each(function() {
|
||||
$(selector).append($("<option></option>").val(this.value).html(this.text));
|
||||
});
|
||||
$(selector).val(idToSelect).trigger('change');
|
||||
},
|
||||
error: function(xhr, ajaxOptions, thrownError) {
|
||||
console.log(xhr);
|
||||
alert(xhr.responseText);
|
||||
$.unblockUI();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function copyDataFromLastPartItem() {
|
||||
let params = new URLSearchParams(window.location.search);
|
||||
let idProjectPartItem = params.get('idProjectPartItem');
|
||||
let idProject = params.get('idProject');
|
||||
let idProjectPart = params.get('idProjectPart');
|
||||
let edit = params.get('edit');
|
||||
|
||||
let idArticle = $('#selCodeTableItem').val();
|
||||
if (isNaN(parseInt(idArticle))) {
|
||||
return;
|
||||
}
|
||||
|
||||
location.replace(`CreateEditPartItem?idProjectPartItem=${idProjectPartItem}&idProject=${idProject}&idProjectPart=${idProjectPart}&edit=${edit}&idArticleCopyFrom=${idArticle}`);
|
||||
}
|
||||
|
||||
</script>
|
||||
}
|
||||
@@ -1,162 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using EveryThing.Data;
|
||||
using EveryThing.Models;
|
||||
using EveryThing.Models.CodeTable;
|
||||
using EveryThing.Models.Project;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace EveryThing.Pages.Projects
|
||||
{
|
||||
[Authorize(Roles = "Administrator,ProjecThingUser")]
|
||||
public class CreateEditPartItemModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
private readonly UserManager<IdentityApplicationUser> _userManager;
|
||||
private readonly SignInManager<IdentityApplicationUser> _loginManager;
|
||||
private readonly RoleManager<IdentityApplicationRole> _roleManager;
|
||||
|
||||
public CreateEditPartItemModel(ApplicationDbContext context, UserManager<IdentityApplicationUser> userManager, SignInManager<IdentityApplicationUser> loginManager, RoleManager<IdentityApplicationRole> roleManager)
|
||||
{
|
||||
_context = context;
|
||||
_userManager = userManager;
|
||||
_loginManager = loginManager;
|
||||
_roleManager = roleManager;
|
||||
}
|
||||
|
||||
public IActionResult OnGet(int idProject, int idProjectPart, bool edit, int? idProjectPartItem, int? idArticleCopyFrom)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
IdProject = idProject;
|
||||
ViewData["IdProject"] = idProject;
|
||||
ViewData["IdItemFk"] = new SelectList(_context.CodeTableItems
|
||||
.Where(x => x.IdCompanyFk == user.IdCompanyFk && x.Active && x.CodeTableItemType == CodeTableItemType.Product)
|
||||
.OrderBy(x => x.Title), "IdItem", "Title");
|
||||
ViewData["IdMaterialFk"] = new SelectList(_context.CodeTableItems
|
||||
.Where(x => x.IdCompanyFk == user.IdCompanyFk && x.Active && x.CodeTableItemType == CodeTableItemType.Material)
|
||||
.OrderBy(x => x.Title), "IdItem", "Title");
|
||||
ViewData["IdMaterialSupplierFk"] = new SelectList(_context.CodeTablePartners
|
||||
.Where(x => x.IdCompanyFk == user.IdCompanyFk && x.Active && x.Supplier)
|
||||
.OrderBy(x => x.Title), "IdPartner", "Title");
|
||||
|
||||
ViewData["Edit"] = edit;
|
||||
|
||||
if (edit)
|
||||
{
|
||||
ProjectPartItem = _context.ProjectPartItems
|
||||
.Include(x => x.ProjectPart)
|
||||
.ThenInclude(x => x.Project)
|
||||
.FirstOrDefault(x => x.IdProjectPartItem == idProjectPartItem);
|
||||
|
||||
if (ProjectPartItem == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ProjectPartItem = new ProjectPartItem
|
||||
{
|
||||
NumberOfSets = 1,
|
||||
IdProjectPartFk = idProjectPart
|
||||
};
|
||||
}
|
||||
|
||||
if (idArticleCopyFrom != null)
|
||||
{
|
||||
var item = _context.ProjectPartItems
|
||||
.OrderByDescending(x => x.DateModified)
|
||||
.ThenByDescending(x => x.IdProjectPartItem)
|
||||
.FirstOrDefault(x => x.IdItemFk == idArticleCopyFrom && (!edit || x.IdProjectPartFk != ProjectPartItem.IdProjectPartFk));
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
ProjectPartItem.IdItemFk = item.IdItemFk;
|
||||
ProjectPartItem.NumberOfItems = item.NumberOfItems;
|
||||
ProjectPartItem.NumberOfSets = item.NumberOfSets;
|
||||
ProjectPartItem.IdMaterialFk = item.IdMaterialFk;
|
||||
ProjectPartItem.MaterialDimensions = item.MaterialDimensions;
|
||||
ProjectPartItem.IdMaterialSupplierFk = item.IdMaterialSupplierFk;
|
||||
ProjectPartItem.MaterialPrice = item.MaterialPrice;
|
||||
ProjectPartItem.WorkPrice = item.WorkPrice;
|
||||
ProjectPartItem.SellingPrice = item.SellingPrice;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return Page();
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public Models.Project.ProjectPartItem ProjectPartItem { get; set; }
|
||||
|
||||
[BindProperty]
|
||||
public int IdProject { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnPostAsync(bool edit)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return Page();
|
||||
}
|
||||
ProjectPartItem.DateModified = DateTime.Now;
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
if (!edit)
|
||||
{
|
||||
ProjectPartItem.Status = ProjectPartItemStatus.Opened;
|
||||
|
||||
var items = _context.ProjectPartItems
|
||||
.Where(x => x.IdProjectPartFk == ProjectPartItem.IdProjectPartFk).ToList();
|
||||
|
||||
ProjectPartItem.ProjectPartItemNumber = items.Count <= 0 ? 1 : items.Max(x => x.ProjectPartItemNumber) + 1;
|
||||
_context.ProjectPartItems.Add(ProjectPartItem);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
_context.Attach(ProjectPartItem).State = EntityState.Modified;
|
||||
|
||||
try
|
||||
{
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
if (!ProjectPartItemExists(ProjectPartItem.IdProjectPartItem))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return RedirectToPage("./Edit", new { id = IdProject });
|
||||
}
|
||||
|
||||
private bool ProjectPartItemExists(int id)
|
||||
{
|
||||
return _context.ProjectPartItems.Any(e => e.IdProjectPartItem == id);
|
||||
}
|
||||
|
||||
public IActionResult OnGetCodeTableItems(int type)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
var codeTableItemType = (CodeTableItemType)type;
|
||||
|
||||
var items = new SelectList(_context.CodeTableItems
|
||||
.Where(x => x.IdCompanyFk == user.IdCompanyFk && x.Active && x.CodeTableItemType == codeTableItemType)
|
||||
.OrderBy(x => x.Title), "IdItem", "Title");
|
||||
|
||||
return new JsonResult(new { items = items });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
@page
|
||||
@model EveryThing.Pages.Projects.CreatePartModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Nov del projekta";
|
||||
Layout = "~/Pages/Layouts/_Layout.cshtml";
|
||||
}
|
||||
|
||||
<form method="post">
|
||||
|
||||
<h4 class="d-flex justify-content-between align-items-center w-100 font-weight-bold py-1 mb-4">
|
||||
<span>
|
||||
<span class="text-muted font-weight-light">Projekt /</span> Nov del
|
||||
</span>
|
||||
</h4>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="card">
|
||||
<h6 class="card-header">
|
||||
Podatki dela projekta
|
||||
</h6>
|
||||
<div class="card-body">
|
||||
<input type="hidden" asp-for="ProjectPart.IdProjectFk" />
|
||||
<div class="form-group">
|
||||
<label asp-for="ProjectPart.Title" class="form-label"></label>
|
||||
<input autocomplete="off" asp-for="ProjectPart.Title" class="form-control"/>
|
||||
<span asp-validation-for="ProjectPart.Title" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="ProjectPart.Description" class="form-label"></label>
|
||||
<input autocomplete="off" asp-for="ProjectPart.Description" class="form-control"/>
|
||||
<span asp-validation-for="ProjectPart.Description" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="ProjectPart.PathOfPlans" class="form-label"></label>
|
||||
<input autocomplete="off" asp-for="ProjectPart.PathOfPlans" class="form-control"/>
|
||||
<span asp-validation-for="ProjectPart.PathOfPlans" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer py-3 text-right">
|
||||
<button type="submit" class="btn btn-primary">Dodaj del projekta</button>
|
||||
<a asp-page="Edit" asp-route-id="@ViewBag.IdProject" class="btn btn-default">Prekliči</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
|
||||
</form>
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using EveryThing.Data;
|
||||
using EveryThing.Models;
|
||||
using EveryThing.Models.Project;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace EveryThing.Pages.Projects
|
||||
{
|
||||
[Authorize(Roles = "Administrator,ProjecThingUser")]
|
||||
public class CreatePartModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
private readonly UserManager<IdentityApplicationUser> _userManager;
|
||||
private readonly SignInManager<IdentityApplicationUser> _loginManager;
|
||||
private readonly RoleManager<IdentityApplicationRole> _roleManager;
|
||||
|
||||
public CreatePartModel(ApplicationDbContext context, UserManager<IdentityApplicationUser> userManager, SignInManager<IdentityApplicationUser> loginManager, RoleManager<IdentityApplicationRole> roleManager)
|
||||
{
|
||||
_context = context;
|
||||
_userManager = userManager;
|
||||
_loginManager = loginManager;
|
||||
_roleManager = roleManager;
|
||||
}
|
||||
|
||||
public IActionResult OnGet(int idProject)
|
||||
{
|
||||
ViewData["IdProject"] = idProject;
|
||||
|
||||
ProjectPart = new ProjectPart
|
||||
{
|
||||
IdProjectFk = idProject
|
||||
};
|
||||
|
||||
return Page();
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public Models.Project.ProjectPart ProjectPart { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return Page();
|
||||
}
|
||||
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
ProjectPart.Status = ProjectPartStatus.Opened;
|
||||
|
||||
var items = _context.ProjectParts
|
||||
.Where(x => x.IdProjectFk == ProjectPart.IdProjectFk).ToList();
|
||||
|
||||
ProjectPart.ProjectPartNumber = items.Count <= 0 ? 1 : items.Max(x => x.ProjectPartNumber) + 1;
|
||||
|
||||
_context.ProjectParts.Add(ProjectPart);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return RedirectToPage("./Edit", new { id = ProjectPart.IdProjectFk });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
@page
|
||||
@using EveryThing.Models.Project
|
||||
@model EveryThing.Pages.Projects.CreatePartItemImportExcelModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Uvoz pozicij dela projekta";
|
||||
Layout = "~/Pages/Layouts/_Layout.cshtml";
|
||||
}
|
||||
|
||||
<form method="post">
|
||||
|
||||
<h4 class="d-flex justify-content-between align-items-center w-100 font-weight-bold py-1 mb-4">
|
||||
<span>
|
||||
<span class="text-muted font-weight-light">Projekt /</span> Uvoz pozicij dela projekta
|
||||
</span>
|
||||
</h4>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="card">
|
||||
<h6 class="card-header">
|
||||
Povezovanje excel z pozicijo
|
||||
</h6>
|
||||
<div class="card-body">
|
||||
<input type="hidden" asp-for="IdProjectPart" />
|
||||
<input type="hidden" asp-for="IdProject" />
|
||||
<input type="hidden" asp-for="FileName" />
|
||||
<input type="hidden" asp-for="SelectedItems" name="selectedItems" class="inp-selected-items" />
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
@{
|
||||
foreach (var item in Model.ExcelItems)
|
||||
{
|
||||
<div class="form-group">
|
||||
<label class="control-label">@item.Name</label>
|
||||
<select data-index="@item.CellIndex" class="form-control select-item" asp-items="ViewBag.ProjectPartItems"></select>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer py-3 text-right">
|
||||
<button type="submit" class="btn btn-primary" onclick="prepareData(); return true;">Potrdi</button>
|
||||
<a asp-page="Edit" asp-route-id="IdProject" class="btn btn-default">Prekliči</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
|
||||
</form>
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
|
||||
<script type="text/javascript">
|
||||
function prepareData(){
|
||||
let data = "";
|
||||
$('.select-item').each(function(index, element) {
|
||||
let value = $(element).val();
|
||||
if (value !== '') {
|
||||
let dataIndex = $(element).attr("data-index");
|
||||
data += `${dataIndex};${value}#`;
|
||||
}
|
||||
});
|
||||
$('.inp-selected-items').val(data);
|
||||
}
|
||||
</script>
|
||||
}
|
||||
@@ -1,199 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using EveryThing.Data;
|
||||
using EveryThing.Models;
|
||||
using EveryThing.Models.Project;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.IO;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using ClosedXML.Excel;
|
||||
|
||||
namespace EveryThing.Pages.Projects
|
||||
{
|
||||
[Authorize(Roles = "Administrator,ProjecThingUser")]
|
||||
public class CreatePartItemImportExcelModel : PageModel
|
||||
{
|
||||
private readonly IWebHostEnvironment _hostingEnvironment;
|
||||
private readonly ApplicationDbContext _context;
|
||||
private readonly UserManager<IdentityApplicationUser> _userManager;
|
||||
private readonly SignInManager<IdentityApplicationUser> _loginManager;
|
||||
private readonly RoleManager<IdentityApplicationRole> _roleManager;
|
||||
|
||||
public CreatePartItemImportExcelModel(ApplicationDbContext context, UserManager<IdentityApplicationUser> userManager, SignInManager<IdentityApplicationUser> loginManager, RoleManager<IdentityApplicationRole> roleManager, IWebHostEnvironment environment)
|
||||
{
|
||||
_context = context;
|
||||
_userManager = userManager;
|
||||
_loginManager = loginManager;
|
||||
_roleManager = roleManager;
|
||||
_hostingEnvironment = environment;
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public int IdProject { get; set; }
|
||||
[BindProperty]
|
||||
public int IdProjectPart { get; set; }
|
||||
[BindProperty]
|
||||
public string FileName { get; set; }
|
||||
[BindProperty]
|
||||
public List<ExcelItem> ExcelItems { get; set; }
|
||||
[BindProperty]
|
||||
public string SelectedItems { get; set; }
|
||||
|
||||
public IActionResult OnGet(int idProject, int idProjectPart, string fileName)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
IdProject = idProject;
|
||||
IdProjectPart = idProjectPart;
|
||||
FileName = fileName;
|
||||
|
||||
var tmpList = typeof(Models.Project.ProjectPartItem).GetProperties()
|
||||
.Where(x => x.GetCustomAttributes(true).Length > 0 && x.GetCustomAttributes(true).Any(y => y.GetType() == typeof(System.ComponentModel.DataAnnotations.DisplayAttribute)))
|
||||
.Select(x => new
|
||||
{
|
||||
Name = x.Name,
|
||||
Display = ((System.ComponentModel.DataAnnotations.DisplayAttribute)x.GetCustomAttributes(true).First(y => y.GetType() == typeof(System.ComponentModel.DataAnnotations.DisplayAttribute))).Name
|
||||
}).ToList();
|
||||
tmpList.Insert(0, new { Name = "", Display = "Ni izbrano" });
|
||||
|
||||
ViewData["ProjectPartItems"] = new SelectList(tmpList, "Name", "Display");
|
||||
|
||||
ExcelItems = new List<ExcelItem>();
|
||||
string path = Path.Combine(_hostingEnvironment.WebRootPath, "Uploads");
|
||||
|
||||
var xlWorkbook = new XLWorkbook(Path.Combine(path, fileName));
|
||||
|
||||
//ONLY FIRST LIST
|
||||
var worksheet = xlWorkbook.Worksheet(1);
|
||||
|
||||
int i = 1;
|
||||
if (!worksheet.Row(i).IsEmpty())
|
||||
{
|
||||
IXLRow row = worksheet.Row(i);
|
||||
int j = 1;
|
||||
while (!row.Cell(j).IsEmpty())
|
||||
{
|
||||
var cellData = row.Cell(j).Value;
|
||||
|
||||
ExcelItems.Add(new ExcelItem
|
||||
{
|
||||
CellIndex = j,
|
||||
Name = cellData.ToString(),
|
||||
});
|
||||
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAsync(string selectedItems)
|
||||
{
|
||||
if (selectedItems == "")
|
||||
{
|
||||
return Page(); //TODO Error
|
||||
}
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
var excelItems = new List<ExcelItem>();
|
||||
|
||||
var items = selectedItems.Split('#');
|
||||
foreach (var item in items)
|
||||
{
|
||||
var itemData = item.Split(';');
|
||||
if (itemData.Length != 2)
|
||||
continue;
|
||||
|
||||
excelItems.Add(new ExcelItem
|
||||
{
|
||||
CellIndex = Convert.ToInt32(itemData[0]),
|
||||
Name = itemData[1],
|
||||
});
|
||||
}
|
||||
|
||||
string path = Path.Combine(_hostingEnvironment.WebRootPath, "Uploads");
|
||||
|
||||
var xlWorkbook = new XLWorkbook(Path.Combine(path, FileName));
|
||||
|
||||
//ONLY FIRST LIST
|
||||
var worksheet = xlWorkbook.Worksheet(1);
|
||||
|
||||
var currentPositionNumber = _context.ProjectPartItems
|
||||
.Where(x => x.IdProjectPartFk == IdProjectPart).Max(x => x.ProjectPartItemNumber);
|
||||
|
||||
if (currentPositionNumber <= 0)
|
||||
currentPositionNumber = 0;
|
||||
|
||||
int i = 2;//Skip header
|
||||
while (!worksheet.Row(i).IsEmpty())
|
||||
{
|
||||
currentPositionNumber++;
|
||||
IXLRow row = worksheet.Row(i);
|
||||
var newPosition = new Models.Project.ProjectPartItem
|
||||
{
|
||||
IdProjectPartFk = IdProjectPart,
|
||||
NumberOfItems = 1,
|
||||
NumberOfSets = 1,
|
||||
IdMaterialSupplierFk = _context.CodeTablePartners.First().IdPartner,
|
||||
ProjectPartItemNumber = currentPositionNumber
|
||||
};
|
||||
|
||||
foreach (var excelItem in excelItems)
|
||||
{
|
||||
if (row.Cell(excelItem.CellIndex) == null)
|
||||
continue;
|
||||
|
||||
string value = row.Cell(excelItem.CellIndex).Value.ToString();
|
||||
|
||||
if (excelItem.Name == "IdItemFk"
|
||||
|| excelItem.Name == "IdMaterialFk")
|
||||
{
|
||||
var completableItem = _context.CodeTableItems.FirstOrDefault(x => x.Title == value && x.Active == true);
|
||||
if (completableItem == null)
|
||||
{
|
||||
//Add new if not exists
|
||||
completableItem = new Models.CodeTable.CodeTableItem
|
||||
{
|
||||
Active = true,
|
||||
IdCompanyFk = user.IdCompanyFk,
|
||||
Title = value
|
||||
};
|
||||
_context.CodeTableItems.Add(completableItem);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
if (excelItem.Name == "IdItemFk")
|
||||
newPosition.IdItemFk = completableItem.IdItem;
|
||||
else
|
||||
newPosition.IdMaterialFk = completableItem.IdItem;
|
||||
}
|
||||
else
|
||||
{
|
||||
var propertyInfo = newPosition.GetType().GetProperties().First(x => x.Name == excelItem.Name);
|
||||
object propertyValue = Convert.ChangeType(value, Nullable.GetUnderlyingType(propertyInfo.PropertyType) ?? propertyInfo.PropertyType);
|
||||
propertyInfo.SetValue(newPosition, propertyValue);
|
||||
}
|
||||
}
|
||||
_context.ProjectPartItems.Add(newPosition);
|
||||
await _context.SaveChangesAsync();
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
return RedirectToPage("./Edit", new {id = IdProject});
|
||||
}
|
||||
|
||||
public class ExcelItem
|
||||
{
|
||||
public int CellIndex { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
@page
|
||||
@using EveryThing.Models.Project
|
||||
@model EveryThing.Pages.Projects.CreatePartItemUploadExcelModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Uvoz pozicij dela projekta";
|
||||
Layout = "~/Pages/Layouts/_Layout.cshtml";
|
||||
}
|
||||
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
|
||||
<h4 class="d-flex justify-content-between align-items-center w-100 font-weight-bold py-1 mb-4">
|
||||
<span>
|
||||
<span class="text-muted font-weight-light">Projekt /</span> Uvoz pozicij dela projekta
|
||||
</span>
|
||||
</h4>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="card">
|
||||
<h6 class="card-header">
|
||||
Podatki pozicije
|
||||
</h6>
|
||||
<div class="card-body">
|
||||
<input type="hidden" asp-for="IdProjectPart" name="idProjectPart" />
|
||||
<input type="hidden" asp-for="IdProject" name="idProject"/>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="form-group">
|
||||
<input type="file" name="postedFiles" multiple/>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer py-3 text-right">
|
||||
<input type="submit" class="btn btn-primary" value="Naloži excel" asp-page-handler="Upload" />
|
||||
<a asp-page="Edit" asp-route-id="IdProject" class="btn btn-default">Prekliči</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
|
||||
</form>
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
}
|
||||
@@ -1,126 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using EveryThing.Data;
|
||||
using EveryThing.Models;
|
||||
using EveryThing.Models.Project;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.IO;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
|
||||
namespace EveryThing.Pages.Projects
|
||||
{
|
||||
[Authorize(Roles = "Administrator,ProjecThingUser")]
|
||||
public class CreatePartItemUploadExcelModel : PageModel
|
||||
{
|
||||
private readonly IWebHostEnvironment _hostingEnvironment;
|
||||
private readonly ApplicationDbContext _context;
|
||||
private readonly UserManager<IdentityApplicationUser> _userManager;
|
||||
private readonly SignInManager<IdentityApplicationUser> _loginManager;
|
||||
private readonly RoleManager<IdentityApplicationRole> _roleManager;
|
||||
|
||||
public CreatePartItemUploadExcelModel(ApplicationDbContext context, UserManager<IdentityApplicationUser> userManager, SignInManager<IdentityApplicationUser> loginManager, RoleManager<IdentityApplicationRole> roleManager, IWebHostEnvironment environment)
|
||||
{
|
||||
_context = context;
|
||||
_userManager = userManager;
|
||||
_loginManager = loginManager;
|
||||
_roleManager = roleManager;
|
||||
_hostingEnvironment = environment;
|
||||
}
|
||||
|
||||
|
||||
[BindProperty]
|
||||
public IFormFile File { get; set; }
|
||||
[BindProperty]
|
||||
public int IdProject { get; set; }
|
||||
[BindProperty]
|
||||
public int IdProjectPart { get; set; }
|
||||
|
||||
|
||||
public IActionResult OnGet(int idProject, int idProjectPart)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
IdProject = idProject;
|
||||
IdProjectPart = idProjectPart;
|
||||
|
||||
|
||||
return Page();
|
||||
}
|
||||
|
||||
//public async Task<IActionResult> OnPostAsync()
|
||||
//{
|
||||
// if (!ModelState.IsValid)
|
||||
// {
|
||||
// return Page();
|
||||
// }
|
||||
// string uploads = Path.Combine(_hostingEnvironment.WebRootPath, "uploads");
|
||||
|
||||
// if (File.Length > 0)
|
||||
// {
|
||||
// string filePath = Path.Combine(uploads, File.FileName);
|
||||
// using (Stream fileStream = new FileStream(filePath, FileMode.Create))
|
||||
// {
|
||||
// await File.CopyToAsync(fileStream);
|
||||
// }
|
||||
// }
|
||||
|
||||
// return RedirectToPage("./Edit");
|
||||
//}
|
||||
|
||||
//public async Task<IActionResult> OnPostUploadAsync(List<IFormFile> files)
|
||||
//{
|
||||
// long size = files.Sum(f => f.Length);
|
||||
|
||||
// foreach (var formFile in files)
|
||||
// {
|
||||
// if (formFile.Length > 0)
|
||||
// {
|
||||
// var filePath = Path.GetTempFileName();
|
||||
// System.Diagnostics.Debug.WriteLine(filePath);
|
||||
// using (var stream = System.IO.File.Create(filePath))
|
||||
// {
|
||||
// await formFile.CopyToAsync(stream);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Process uploaded files
|
||||
// // Don't rely on or trust the FileName property without validation.
|
||||
|
||||
// return RedirectToPage("./Edit");
|
||||
//}
|
||||
|
||||
public async Task<IActionResult> OnPostUpload(int idProject, int idProjectPart, List<IFormFile> postedFiles)
|
||||
{
|
||||
if (postedFiles == null
|
||||
|| postedFiles.Count != 1)
|
||||
{
|
||||
return Page();//TODO return error
|
||||
}
|
||||
string path = Path.Combine(_hostingEnvironment.WebRootPath, "Uploads");
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
}
|
||||
|
||||
List<string> uploadedFiles = new List<string>();
|
||||
|
||||
var postedFile = postedFiles[0];
|
||||
|
||||
string fileName = Guid.NewGuid().ToString().Replace("-", "_") + Path.GetExtension(postedFile.FileName);
|
||||
using (FileStream stream = new FileStream(Path.Combine(path, fileName), FileMode.Create))
|
||||
{
|
||||
postedFile.CopyTo(stream);
|
||||
uploadedFiles.Add(fileName);
|
||||
}
|
||||
return RedirectToPage("./CreatePartItemImportExcel", new { idProject = idProject, idProjectPart = idProjectPart, fileName = fileName});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
@page
|
||||
@model EveryThing.Pages.Projects.DeleteModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Delete";
|
||||
Layout = "~/Pages/Layouts/_Layout.cshtml";
|
||||
}
|
||||
|
||||
<h1>Delete</h1>
|
||||
|
||||
<h3>Are you sure you want to delete this?</h3>
|
||||
<div>
|
||||
<h4>Project</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Project.Title)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Project.Title)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Project.Description)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Project.Description)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Project.Status)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Project.Status)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Project.FinishedDate)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Project.FinishedDate)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Project.Company)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Project.Company.Bank)
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<form method="post">
|
||||
<input type="hidden" asp-for="Project.IdProject" />
|
||||
<input type="submit" value="Delete" class="btn btn-danger" /> |
|
||||
<a asp-page="./Index">Back to List</a>
|
||||
</form>
|
||||
</div>
|
||||
@@ -1,62 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using EveryThing.Data;
|
||||
using EveryThing.Models.Project;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace EveryThing.Pages.Projects
|
||||
{
|
||||
[Authorize(Roles = "Administrator,ProjecThingUser")]
|
||||
public class DeleteModel : PageModel
|
||||
{
|
||||
private readonly EveryThing.Data.ApplicationDbContext _context;
|
||||
|
||||
public DeleteModel(EveryThing.Data.ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public Models.Project.Project Project { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Project = await _context.Projects
|
||||
.Include(p => p.Company).FirstOrDefaultAsync(m => m.IdProject == id);
|
||||
|
||||
if (Project == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Project = await _context.Projects.FindAsync(id);
|
||||
|
||||
if (Project != null)
|
||||
{
|
||||
_context.Projects.Remove(Project);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
return RedirectToPage("./Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
@page
|
||||
@model EveryThing.Pages.Projects.DetailsModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Details";
|
||||
Layout = "~/Pages/Layouts/_Layout.cshtml";
|
||||
}
|
||||
|
||||
<h1>Details</h1>
|
||||
|
||||
<div>
|
||||
<h4>Project</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Project.Title)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Project.Title)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Project.Description)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Project.Description)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Project.Status)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Project.Status)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Project.FinishedDate)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Project.FinishedDate)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Project.Company)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Project.Company.Bank)
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div>
|
||||
<a asp-page="./Edit" asp-route-id="@Model.Project.IdProject">Edit</a> |
|
||||
<a asp-page="./Index">Back to List</a>
|
||||
</div>
|
||||
@@ -1,43 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using EveryThing.Data;
|
||||
using EveryThing.Models.Project;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace EveryThing.Pages.Projects
|
||||
{
|
||||
[Authorize(Roles = "Administrator,ProjecThingUser")]
|
||||
public class DetailsModel : PageModel
|
||||
{
|
||||
private readonly EveryThing.Data.ApplicationDbContext _context;
|
||||
|
||||
public DetailsModel(EveryThing.Data.ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public Models.Project.Project Project { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Project = await _context.Projects
|
||||
.Include(p => p.Company).FirstOrDefaultAsync(m => m.IdProject == id);
|
||||
|
||||
if (Project == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
@using System.Globalization
|
||||
@model EveryThing.Models.Project.ProjectPartItem
|
||||
|
||||
<tr data-idpartitem="@Model.IdProjectPartItem">
|
||||
<td style="width: 20px;">
|
||||
@if(Model.Status != Models.Project.ProjectPartItemStatus.Shipped)
|
||||
{
|
||||
<input type="checkbox" class="form-control" name="projectPartItem" style="width:15px; height:15px; margin: 0px;"/>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
@if (Model.Item != null)
|
||||
{
|
||||
<a data-idcodetableitem="@Model.Item.IdItem" href="javascript:;" onclick="editCodetableItem(this)">@Html.DisplayFor(modelItem => Model.Item.Title)</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
@Html.DisplayFor(modelItem => Model.IdItemFk)
|
||||
}
|
||||
<br/>
|
||||
@(Model.ProjectPartNumberFormatted)
|
||||
</td>
|
||||
<td>
|
||||
@if (Model.Material != null)
|
||||
{
|
||||
<a data-idcodetableitem="@Model.Material.IdItem" href="javascript:;" onclick="editCodetableItem(this)">@Html.DisplayFor(modelItem => Model.Material.Title)</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
@Html.DisplayFor(modelItem => Model.IdMaterialFk)
|
||||
}
|
||||
-
|
||||
@Html.DisplayFor(modelItem => Model.MaterialSupplier.Title)
|
||||
@*@Html.DisplayFor(modelItem => Model.MaterialSupplier.Title)*@
|
||||
<br/>
|
||||
@Html.DisplayFor(modelItem => Model.MaterialDimensions)
|
||||
</td>
|
||||
<td class="table-number">
|
||||
@(Model.NumberOfItems.ToString("0.00", new CultureInfo("sl-SI")))
|
||||
<br/>
|
||||
@(Model.NumberOfSets.ToString("0.00", new CultureInfo("sl-SI")))
|
||||
</td>
|
||||
<td class="table-number">
|
||||
@(Model.MaterialPrice.ToString("0.00", new CultureInfo("sl-SI")))
|
||||
<br/>
|
||||
@(Model.MaterialValue.ToString("0.00", new CultureInfo("sl-SI")))
|
||||
</td>
|
||||
<td class="table-number">
|
||||
@(Model.WorkPrice.ToString("0.00", new CultureInfo("sl-SI")))
|
||||
<br />
|
||||
@(Model.WorkValue.ToString("0.00", new CultureInfo("sl-SI")))
|
||||
</td>
|
||||
<td class="table-number">
|
||||
@(Model.CostPrice.ToString("0.00", new CultureInfo("sl-SI")))
|
||||
<br />
|
||||
@(Model.CostValue.ToString("0.00", new CultureInfo("sl-SI")))
|
||||
</td>
|
||||
<td class="table-number">
|
||||
@(Model.DifferenceInPrice.ToString("0.00", new CultureInfo("sl-SI")))
|
||||
<br />
|
||||
@(Model.DifferenceInPricePercentage.ToString("0.00", new CultureInfo("sl-SI")))%
|
||||
</td>
|
||||
<td class="table-number">
|
||||
@(Model.SellingPrice.ToString("0.00", new CultureInfo("sl-SI")))
|
||||
<br />
|
||||
@(Model.SellingValue.ToString("0.00", new CultureInfo("sl-SI")))
|
||||
</td>
|
||||
<td style="width: 100px">
|
||||
@Html.DisplayFor(modelItem => Model.Status)
|
||||
<br/>
|
||||
@Html.DisplayFor(modelItem => Model.DeliveryDate)
|
||||
</td>
|
||||
<td class="text-right" style="width: 90px;">
|
||||
<a asp-page="CreateEditPartItem" asp-route-idProjectPartItem="@Model.IdProjectPartItem" asp-route-idProject="@Model.ProjectPart.IdProjectFk" asp-route-idProjectPart="@Model.IdProjectPartFk" asp-route-edit="@true" class="btn btn-xs icon-btn btn-outline-secondary borderless" data-state="secondary"><i class="far fa-edit"></i></a>
|
||||
<a class="btn btn-xs icon-btn btn-outline-secondary borderless" data-state="secondary" href='javascript:;'><i class="fas fa-pencil-alt" hx-get="@Url.Page("Edit", "EditPartItem", new {id = Model.IdProjectPartItem})" hx-swap="outerHTML" hx-target="closest tr"></i></a>
|
||||
<a class="btn btn-xs icon-btn btn-outline-danger borderless" data-state="danger" href='javascript:;' onclick="deletePartItem(this)"><i class="fas fa-times"></i></a>
|
||||
<a style="display: none;" id="btnTblCancel_@(Model.IdProjectPartItem.ToString())" href='javascript:;' class="btn btn-xs icon-btn btn-outline-danger borderless" data-state="danger" hx-get="@Url.Page("Edit", "DetailPartItem", new { id = Model.IdProjectPartItem })" hx-swap="outerHTML" hx-target="closest tr"><i class="fas fa-ban"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,744 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using EveryThing.Data;
|
||||
using EveryThing.Models;
|
||||
using EveryThing.Models.Project;
|
||||
using System.Text.Json;
|
||||
using EveryThing.Models.CodeTable;
|
||||
using DocumentFormat.OpenXml.InkML;
|
||||
using EveryThing.Models.Invoice;
|
||||
using EveryThing.Models.Vehicle;
|
||||
using static EveryThing.Pages.CodeTableVehicleFuelTypes.IndexModel;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using NuGet.Packaging;
|
||||
|
||||
namespace EveryThing.Pages.Projects
|
||||
{
|
||||
[Authorize(Roles = "Administrator,ProjecThingUser")]
|
||||
public class EditModel : PageModel
|
||||
{
|
||||
public class EditProjectPartData
|
||||
{
|
||||
public ProjectPartItem Item { get; set; }
|
||||
|
||||
public SelectList SelectListItems { get; set; }
|
||||
public SelectList SelectListMaterials { get; set; }
|
||||
public SelectList SelectListSuppliers { get; set; }
|
||||
|
||||
}
|
||||
private readonly ApplicationDbContext _context;
|
||||
private readonly UserManager<IdentityApplicationUser> _userManager;
|
||||
private readonly SignInManager<IdentityApplicationUser> _loginManager;
|
||||
private readonly RoleManager<IdentityApplicationRole> _roleManager;
|
||||
|
||||
public EditModel(ApplicationDbContext context, UserManager<IdentityApplicationUser> userManager, SignInManager<IdentityApplicationUser> loginManager, RoleManager<IdentityApplicationRole> roleManager)
|
||||
{
|
||||
_context = context;
|
||||
_userManager = userManager;
|
||||
_loginManager = loginManager;
|
||||
_roleManager = roleManager;
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public Models.Project.Project Project { get; set; }
|
||||
public IList<ProjectPart> Parts { get; set; }
|
||||
public IList<ProjectPartItem> PartItems { get; set; }
|
||||
public IList<Models.Invoice.Invoice> Invoices { get; set; }
|
||||
public IList<Models.File> FilesProject { get; set; }
|
||||
public IList<Models.File> FilesProjectParts { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
ViewData["IdPartnerFk"] = new SelectList(_context.CodeTablePartners
|
||||
.Where(x => x.IdCompanyFk == user.IdCompanyFk && x.Active && x.Buyer)
|
||||
.OrderBy(x => x.Title), "IdPartner", "Title");
|
||||
|
||||
Project = await _context.Projects.FirstOrDefaultAsync(m => m.IdProject == id && m.IdCompanyFk == user.IdCompanyFk);
|
||||
|
||||
if (Project == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Parts = await _context.ProjectParts
|
||||
.Include(c => c.ProjectPartProjectPartItem)
|
||||
.ThenInclude(x => x.MaterialSupplier)
|
||||
.Include(c => c.ProjectPartProjectPartItem)
|
||||
.ThenInclude(x => x.Material)
|
||||
.Include(c => c.ProjectPartProjectPartItem)
|
||||
.ThenInclude(x => x.Item)
|
||||
.Where(x => x.IdProjectFk == id)
|
||||
.OrderBy(x => x.ProjectPartNumber).ThenBy(x => x.IdProjectPart)
|
||||
.ToListAsync();
|
||||
|
||||
Invoices = await _context.Invoices
|
||||
.Include(x => x.Partner)
|
||||
.Include(x => x.InvoiceInvoiceItem)
|
||||
.ThenInclude(x => x.ProjectPartItem)
|
||||
.ThenInclude(x => x.ProjectPart)
|
||||
.Where(x => x.InvoiceInvoiceItem.Any(x => x.ProjectPartItem.ProjectPart.IdProjectFk == id))
|
||||
.OrderBy(x => x.InvoiceYear).ThenBy(x => x.InvoiceNumber)
|
||||
.ToListAsync();
|
||||
|
||||
FilesProject = await _context.Files
|
||||
.Where(x => x.IdCompanyFk == user.IdCompanyFk
|
||||
&& x.IdReferenceFk == Project.IdProject
|
||||
&& x.FileType == FileType.Project)
|
||||
.ToListAsync();
|
||||
|
||||
FilesProjectParts = await _context.Files
|
||||
.Where(x => x.IdCompanyFk == user.IdCompanyFk
|
||||
&& Parts.Select(x => x.IdProjectPart).Contains(x.IdReferenceFk)
|
||||
&& x.FileType == FileType.ProjectPart)
|
||||
.ToListAsync();
|
||||
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return Page();
|
||||
}
|
||||
|
||||
_context.Attach(Project).State = EntityState.Modified;
|
||||
|
||||
try
|
||||
{
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
if (!ProjectExists(Project.IdProject))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return RedirectToPage("./Edit", new { id = Project.IdProject});
|
||||
}
|
||||
|
||||
private bool ProjectExists(int id)
|
||||
{
|
||||
return _context.Projects.Any(e => e.IdProject == id);
|
||||
}
|
||||
|
||||
public IActionResult OnGetEditPartItem(int id)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
var item = _context.ProjectPartItems
|
||||
.Include(x => x.MaterialSupplier)
|
||||
.Include(x => x.Item)
|
||||
.Include(x => x.Material)
|
||||
.Include(x => x.ProjectPart)
|
||||
.ThenInclude(x => x.Project)
|
||||
.First(x => x.IdProjectPartItem == id);
|
||||
var selListItems = new SelectList(_context.CodeTableItems.Where(x => x.IdCompanyFk == user.IdCompanyFk && x.Active && x.CodeTableItemType == CodeTableItemType.Product).OrderBy(x => x.Title), "IdItem", "Title");
|
||||
var selListMaterials = new SelectList(_context.CodeTableItems.Where(x => x.IdCompanyFk == user.IdCompanyFk && x.Active && x.CodeTableItemType == CodeTableItemType.Material).OrderBy(x => x.Title), "IdItem", "Title");
|
||||
var selListSuppliers = new SelectList(_context.CodeTablePartners.Where(x => x.IdCompanyFk == user.IdCompanyFk && x.Active && x.Supplier).OrderBy(x => x.Title), "IdPartner", "Title");
|
||||
|
||||
|
||||
return Partial("EditPartItem", new EditProjectPartData
|
||||
{
|
||||
Item = item,
|
||||
SelectListItems = selListItems,
|
||||
SelectListMaterials = selListMaterials,
|
||||
SelectListSuppliers = selListSuppliers
|
||||
});
|
||||
}
|
||||
|
||||
public IActionResult OnGetDetailPartItem(int id)
|
||||
{
|
||||
var item = _context.ProjectPartItems
|
||||
.Include(x => x.ProjectPart)
|
||||
.Include(x => x.MaterialSupplier)
|
||||
.Include(x => x.Item)
|
||||
.Include(x => x.Material)
|
||||
.Include(x => x.ProjectPart)
|
||||
.ThenInclude(x => x.Project)
|
||||
.First(x => x.IdProjectPartItem == id);
|
||||
|
||||
return Partial("DetailsPartItem", item);
|
||||
}
|
||||
|
||||
public IActionResult OnPostCreateOrder(string itemsJson, bool inquiry)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
var itemsId = JsonSerializer.Deserialize<List<int>>(itemsJson);
|
||||
|
||||
var items = _context.ProjectPartItems
|
||||
.Include(x => x.ProjectPart)
|
||||
.ThenInclude(x => x.Project)
|
||||
.Where(x => itemsId.Contains(x.IdProjectPartItem)).ToList();
|
||||
|
||||
var suppliers = _context.ProjectPartItems
|
||||
.Where(x => itemsId.Contains(x.IdProjectPartItem))
|
||||
.Select(x => x.IdMaterialSupplierFk).Distinct().ToList();
|
||||
var idInvoice = -1;
|
||||
|
||||
foreach (var idSupplier in suppliers)
|
||||
{
|
||||
var invoice = _context.Invoices
|
||||
.Include(x => x.InvoiceInvoiceItem)
|
||||
.ThenInclude(x => x.ProjectPartItem)
|
||||
.ThenInclude(x => x.ProjectPart)
|
||||
.Where(x => ((!inquiry && x.State == Models.Invoice.Invoice.InvoiceState.New) || (inquiry && x.State == Models.Invoice.Invoice.InvoiceState.Inquiry))
|
||||
&& x.Type == Models.Invoice.Invoice.InvoiceType.Order
|
||||
//Ce ze kateri item obstaja na dobavnici
|
||||
&& x.InvoiceInvoiceItem.Any(invoiceItem => items.Select(item => item.ProjectPart.IdProjectFk).Contains(invoiceItem.ProjectPartItem.ProjectPart.IdProjectFk)))
|
||||
.FirstOrDefault(x => x.IdPartnerFk == idSupplier);
|
||||
|
||||
|
||||
if (invoice == null)
|
||||
{
|
||||
//Create new invoice
|
||||
var newInvoice = new Models.Invoice.Invoice();
|
||||
Pages.Invoices.CreateModel.SetNewInvoice(user.IdCompanyFk, Models.Invoice.Invoice.InvoiceType.Order, ref newInvoice, _context);
|
||||
newInvoice.IdPartnerFk = idSupplier;
|
||||
newInvoice.Date = DateTime.Now.Date;
|
||||
if (inquiry)
|
||||
newInvoice.State = Invoice.InvoiceState.Inquiry;
|
||||
|
||||
_context.Invoices.Add(newInvoice);
|
||||
_context.SaveChanges();
|
||||
idInvoice = newInvoice.IdInvoice;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Add to existing invoice
|
||||
idInvoice = invoice.IdInvoice;
|
||||
}
|
||||
|
||||
foreach (var projectPartItem in items.Where(x => x.IdMaterialSupplierFk == idSupplier))
|
||||
{
|
||||
var newInvoiceItem = new Models.Invoice.InvoiceItem
|
||||
{
|
||||
Discount = 0,
|
||||
IdInvoiceFk = idInvoice,
|
||||
IdProjectPartItem = projectPartItem.IdProjectPartItem,
|
||||
IdItemFk = projectPartItem.IdMaterialFk,
|
||||
ItemDescription = projectPartItem.MaterialDimensions,
|
||||
Note = "",
|
||||
Price = projectPartItem.MaterialPrice,
|
||||
//Quantity = projectPartItem.NumberOfItems * projectPartItem.NumberOfSets
|
||||
Quantity = projectPartItem.NumberOfItems
|
||||
};
|
||||
_context.InvoiceItems.Add(newInvoiceItem);
|
||||
}
|
||||
_context.SaveChanges();
|
||||
}
|
||||
|
||||
return new JsonResult(new { error = "", successful = true, idInvoice});
|
||||
}
|
||||
|
||||
public IActionResult OnPostCreateDeliveryNote(string itemsJson)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
var itemsId = JsonSerializer.Deserialize<List<int>>(itemsJson);
|
||||
|
||||
var items = _context.ProjectPartItems
|
||||
.Include(x => x.ProjectPart)
|
||||
.ThenInclude(x => x.Project)
|
||||
.Where(x => itemsId.Contains(x.IdProjectPartItem)).ToList();
|
||||
|
||||
if (!items.Any())
|
||||
return new OkResult();
|
||||
|
||||
var idPartner = items.First().ProjectPart.Project.IdPartnerFk;
|
||||
|
||||
var invoice = _context.Invoices
|
||||
.Include(x => x.InvoiceInvoiceItem)
|
||||
.ThenInclude(x => x.ProjectPartItem)
|
||||
.ThenInclude(x => x.ProjectPart)
|
||||
.Where(x => x.State == Models.Invoice.Invoice.InvoiceState.New
|
||||
&& x.Type == Models.Invoice.Invoice.InvoiceType.DeliveryNote
|
||||
//Ce ze kateri item obstaja na dobavnici
|
||||
&& x.InvoiceInvoiceItem.Any(invoiceItem => items.Select(item => item.ProjectPart.IdProjectFk).Contains(invoiceItem.ProjectPartItem.ProjectPart.IdProjectFk)))
|
||||
.FirstOrDefault(x => x.IdPartnerFk == idPartner);
|
||||
|
||||
int idInvoice;
|
||||
if (invoice == null)
|
||||
{
|
||||
//Create new invoice
|
||||
var newInvoice = new Models.Invoice.Invoice();
|
||||
Pages.Invoices.CreateModel.SetNewInvoice(user.IdCompanyFk, Models.Invoice.Invoice.InvoiceType.DeliveryNote, ref newInvoice, _context);
|
||||
newInvoice.IdPartnerFk = idPartner;
|
||||
newInvoice.Date = DateTime.Now.Date;
|
||||
newInvoice.DateOfDispatch = DateTime.Now.Date;
|
||||
newInvoice.BuyersOrderNumber = items.First().ProjectPart.Project.BuyersOrderNumber;
|
||||
|
||||
_context.Invoices.Add(newInvoice);
|
||||
_context.SaveChanges();
|
||||
idInvoice = newInvoice.IdInvoice;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Add to existing invoice
|
||||
idInvoice = invoice.IdInvoice;
|
||||
}
|
||||
|
||||
foreach (var projectPartItem in items)
|
||||
{
|
||||
var newInvoiceItem = new Models.Invoice.InvoiceItem
|
||||
{
|
||||
Discount = 0,
|
||||
IdInvoiceFk = idInvoice,
|
||||
IdProjectPartItem = projectPartItem.IdProjectPartItem,
|
||||
IdItemFk = projectPartItem.IdItemFk,
|
||||
ItemDescription = "",
|
||||
Note = "",
|
||||
Price = projectPartItem.SellingPrice,
|
||||
//Quantity = projectPartItem.NumberOfItems * projectPartItem.NumberOfSets
|
||||
Quantity = projectPartItem.NumberOfItems * projectPartItem.NumberOfSets
|
||||
};
|
||||
projectPartItem.Status = ProjectPartItemStatus.Shipped;
|
||||
projectPartItem.ShippingDate = DateTime.Now;
|
||||
|
||||
_context.InvoiceItems.Add(newInvoiceItem);
|
||||
}
|
||||
_context.SaveChanges();
|
||||
|
||||
return new OkResult();
|
||||
}
|
||||
|
||||
public IActionResult OnPostUpdatePartItem(int idItem, string json)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
var tmpItem = JsonSerializer.Deserialize<ProjectPartItem>(json);
|
||||
|
||||
var item = _context.ProjectPartItems
|
||||
.Include(x => x.ProjectPart)
|
||||
.ThenInclude(x => x.Project)
|
||||
.FirstOrDefault(x => x.IdProjectPartItem == idItem
|
||||
&& x.ProjectPart.Project.IdCompanyFk == user.IdCompanyFk);
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
return new JsonResult(new { error = $"Project part item with id {idItem} not exists!", successful = false});
|
||||
}
|
||||
|
||||
item.DateModified = DateTime.Now;
|
||||
item.IdItemFk = tmpItem.IdItemFk;
|
||||
item.NumberOfSets = tmpItem.NumberOfSets;
|
||||
item.NumberOfItems = tmpItem.NumberOfItems;
|
||||
item.IdMaterialFk = tmpItem.IdMaterialFk;
|
||||
item.MaterialDimensions = tmpItem.MaterialDimensions;
|
||||
item.IdMaterialSupplierFk = tmpItem.IdMaterialSupplierFk;
|
||||
item.MaterialPrice = tmpItem.MaterialPrice;
|
||||
item.WorkPrice = tmpItem.WorkPrice;
|
||||
item.Status = tmpItem.Status;
|
||||
item.DeliveryDate = tmpItem.DeliveryDate;
|
||||
item.SellingPrice = tmpItem.SellingPrice;
|
||||
_context.SaveChanges();
|
||||
|
||||
return new JsonResult(new { error = "", successful = true });
|
||||
}
|
||||
|
||||
public IActionResult OnDeletePartItem(int idPartItem)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
var successful = true;
|
||||
var error = "";
|
||||
|
||||
var item = _context.ProjectPartItems
|
||||
.Include(x=>x.ProjectPart)
|
||||
.ThenInclude(x => x.Project)
|
||||
.Include(x=> x.InvoiceItem)
|
||||
.FirstOrDefault(x => x.IdProjectPartItem == idPartItem
|
||||
&& x.ProjectPart.Project.IdCompanyFk == user.IdCompanyFk);
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
return new JsonResult(new { error = $"Project part item with id {idPartItem} not exists!", successful = false });
|
||||
}
|
||||
|
||||
if (item.InvoiceItem.Count > 0)
|
||||
{
|
||||
return new JsonResult(new { error = $"Pozicija ima povezane fakture!\nBrisanje ni možno!", successful = false });
|
||||
}
|
||||
|
||||
_context.ProjectPartItems.Remove(item);
|
||||
_context.SaveChanges();
|
||||
|
||||
return new JsonResult(new { error = "", successful = true});
|
||||
}
|
||||
|
||||
public IActionResult OnPostCopyProjectPart(int idProjectPart)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
bool successful = true;
|
||||
string error = "";
|
||||
|
||||
var projectPart = _context.ProjectParts
|
||||
.Include(x => x.Project)
|
||||
.Where(x => x.Project.IdCompanyFk == user.IdCompanyFk)
|
||||
.FirstOrDefault(x => x.IdProjectPart == idProjectPart);
|
||||
if (projectPart != null)
|
||||
{
|
||||
|
||||
var newProjectPart = new ProjectPart
|
||||
{
|
||||
IdProjectFk = projectPart.IdProjectFk,
|
||||
Description = projectPart.Description,
|
||||
//FinishedDate = item.FinishedDate,
|
||||
PathOfPlans = projectPart.PathOfPlans,
|
||||
ShippedDate = projectPart.ShippedDate,
|
||||
Status = projectPart.Status,
|
||||
Title = projectPart.Title,
|
||||
ProjectPartNumber = _context.ProjectParts.Where(x => x.IdProjectFk == projectPart.IdProjectFk).Max(x => x.ProjectPartNumber) + 1
|
||||
};
|
||||
|
||||
if (newProjectPart.ProjectPartNumber <= 0)
|
||||
newProjectPart.ProjectPartNumber = 1;
|
||||
|
||||
_context.ProjectParts.Add(newProjectPart);
|
||||
|
||||
_context.SaveChanges();
|
||||
|
||||
var projectPartItemCounter = 1;
|
||||
foreach (var projectPartItem in _context.ProjectPartItems.Where(x => x.IdProjectPartFk == projectPart.IdProjectPart))
|
||||
{
|
||||
var newProjectPartItem = new ProjectPartItem
|
||||
{
|
||||
IdItemFk = projectPartItem.IdItemFk,
|
||||
IdMaterialFk = projectPartItem.IdMaterialFk,
|
||||
IdMaterialSupplierFk = projectPartItem.IdMaterialSupplierFk,
|
||||
IdProjectPartFk = newProjectPart.IdProjectPart,
|
||||
MaterialDimensions = projectPartItem.MaterialDimensions,
|
||||
MaterialPrice = projectPartItem.MaterialPrice,
|
||||
NumberOfItems = projectPartItem.NumberOfItems,
|
||||
NumberOfItemsFinished = projectPartItem.NumberOfItemsFinished,
|
||||
WorkPrice = projectPartItem.WorkPrice,
|
||||
NumberOfSets = projectPartItem.NumberOfSets,
|
||||
Status = ProjectPartItemStatus.Opened,
|
||||
ProjectPartItemNumber = projectPartItemCounter
|
||||
};
|
||||
_context.ProjectPartItems.Add(newProjectPartItem);
|
||||
|
||||
projectPartItemCounter++;
|
||||
}
|
||||
_context.SaveChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
successful = false;
|
||||
error = $"Project part with ID: {idProjectPart} not found";
|
||||
}
|
||||
|
||||
return new JsonResult(new { error, successful });
|
||||
}
|
||||
|
||||
public IActionResult OnGetProjectPart(int idProjectPart)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
var successful = true;
|
||||
var error = "";
|
||||
var inUse = false;
|
||||
|
||||
var projectPart = _context.ProjectParts
|
||||
.Include(x => x.Project)
|
||||
.Include(x => x.ProjectPartProjectPartItem)
|
||||
.ThenInclude(x => x.InvoiceItem)
|
||||
.FirstOrDefault(x => x.IdProjectPart == idProjectPart
|
||||
&& x.Project.IdCompanyFk == user.IdCompanyFk);
|
||||
|
||||
if (projectPart == null)
|
||||
{
|
||||
successful = false;
|
||||
error = $"Project part with ID: {idProjectPart} not found";
|
||||
}
|
||||
else
|
||||
{
|
||||
inUse = projectPart.ProjectPartProjectPartItem.Any(x => x.InvoiceItem.Count > 0);
|
||||
//Cene se json zacikla neki IDK.
|
||||
projectPart.Project = null;
|
||||
projectPart.ProjectPartProjectPartItem = null;
|
||||
}
|
||||
|
||||
return new JsonResult(new { projectPart, error, successful, inUse });
|
||||
}
|
||||
|
||||
public IActionResult OnGetProjectPriceDetails(int idProject)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
var successful = true;
|
||||
var error = "";
|
||||
|
||||
var projectPartItems = _context.ProjectPartItems
|
||||
.Include(x => x.ProjectPart)
|
||||
.ThenInclude(x => x.Project)
|
||||
.Where(x => x.ProjectPart.IdProjectFk == idProject && x.ProjectPart.Project.IdCompanyFk == user.IdCompanyFk)
|
||||
.ToList();
|
||||
|
||||
var totals = new
|
||||
{
|
||||
parts = projectPartItems
|
||||
.GroupBy(x => x.ProjectPart)
|
||||
.Select(x => new
|
||||
{
|
||||
idProjectPart = x.Key.IdProjectPart,
|
||||
text = $"Strošek delo: <b>{x.Sum(y => y.WorkValue).ToString("#,###,##0.00", new CultureInfo("sl-SI"))} €</b>"
|
||||
+ $"<br/>Strošek material: <b>{x.Sum(y => y.MaterialValue).ToString("#,###,##0.00", new CultureInfo("sl-SI"))} €</b>"
|
||||
+ $"<br/>Strošek skupaj: <b>{x.Sum(y => y.WorkValue + y.MaterialValue).ToString("#,###,##0.00", new CultureInfo("sl-SI"))} €</b>"
|
||||
+ $"<br/>Prodajna vrednost: <b>{x.Sum(y => y.SellingValue).ToString("#,###,##0.00", new CultureInfo("sl-SI"))} €</b>"
|
||||
+ $"<br/>Razlika: <b>{x.Sum(y => y.DifferenceInPriceValue).ToString("#,###,##0.00", new CultureInfo("sl-SI"))} €</b>"
|
||||
}).ToList(),
|
||||
project = new
|
||||
{
|
||||
text = $"Strošek delo: <b>{projectPartItems.Sum(y => y.WorkValue).ToString("#,###,##0.00", new CultureInfo("sl-SI"))} €</b>"
|
||||
+ $"<br/>Strošek material: <b>{projectPartItems.Sum(y => y.MaterialValue).ToString("#,###,##0.00", new CultureInfo("sl-SI"))} €</b>"
|
||||
+ $"<br/>Strošek skupaj: <b>{projectPartItems.Sum(y => y.WorkValue + y.MaterialValue).ToString("#,###,##0.00", new CultureInfo("sl-SI"))} €</b>"
|
||||
+ $"<br/>Prodajna vrednost: <b>{projectPartItems.Sum(y => y.SellingValue).ToString("#,###,##0.00", new CultureInfo("sl-SI"))} €</b>"
|
||||
+ $"<br/>Razlika: <b>{projectPartItems.Sum(y => y.DifferenceInPriceValue).ToString("#,###,##0.00", new CultureInfo("sl-SI"))} €</b>"
|
||||
},
|
||||
};
|
||||
|
||||
return new JsonResult(new { totals, error, successful });
|
||||
}
|
||||
|
||||
public IActionResult OnDeleteProjectPart(int idProjectPart)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
var successful = true;
|
||||
var error = "";
|
||||
|
||||
var projectPart = _context.ProjectParts
|
||||
.Include(x => x.Project)
|
||||
.FirstOrDefault(x => x.IdProjectPart == idProjectPart
|
||||
&& x.Project.IdCompanyFk == user.IdCompanyFk);
|
||||
|
||||
if (projectPart != null)
|
||||
{
|
||||
foreach (var projectPartItem in _context.ProjectPartItems.Where(x => x.IdProjectPartFk == projectPart.IdProjectPart).ToList())
|
||||
{
|
||||
_context.ProjectPartItems.Remove(projectPartItem);
|
||||
}
|
||||
_context.ProjectParts.Remove(projectPart);
|
||||
_context.SaveChanges();
|
||||
|
||||
projectPart.Project = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
successful = false;
|
||||
error = $"Project part with ID: {idProjectPart} not found";
|
||||
}
|
||||
|
||||
return new JsonResult(new { projectPart, error, successful });
|
||||
}
|
||||
|
||||
public IActionResult OnPostProjectPartAddMarginOnAllPositions(int idProjectPart, double value)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
var successful = true;
|
||||
var error = "";
|
||||
|
||||
var projectPart = _context.ProjectParts
|
||||
.Include(x => x.Project)
|
||||
.FirstOrDefault(x => x.IdProjectPart == idProjectPart
|
||||
&& x.Project.IdCompanyFk == user.IdCompanyFk);
|
||||
|
||||
if (projectPart != null)
|
||||
{
|
||||
var items = _context.ProjectPartItems
|
||||
.Where(x => x.IdProjectPartFk == projectPart.IdProjectPart);
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
var costs = Convert.ToDouble(item.MaterialPrice) + Convert.ToDouble(item.WorkPrice);
|
||||
var newDifferenceInPricePercentage = item.DifferenceInPricePercentage + value;
|
||||
|
||||
item.SellingPrice = Convert.ToSingle(costs * (newDifferenceInPricePercentage + 100.0) / 100.0);
|
||||
}
|
||||
|
||||
_context.SaveChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
successful = false;
|
||||
error = $"Project part with ID: {idProjectPart} not found";
|
||||
}
|
||||
|
||||
return new JsonResult(new { error, successful });
|
||||
}
|
||||
|
||||
public IActionResult OnPostProjectPartNewSaleValueForAllPositions(int idProjectPart, double value)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
var successful = true;
|
||||
var error = "";
|
||||
|
||||
var projectPart = _context.ProjectParts
|
||||
.Include(x => x.Project)
|
||||
.FirstOrDefault(x => x.IdProjectPart == idProjectPart
|
||||
&& x.Project.IdCompanyFk == user.IdCompanyFk);
|
||||
|
||||
if (projectPart != null)
|
||||
{
|
||||
var items = _context.ProjectPartItems
|
||||
.Where(x => x.IdProjectPartFk == projectPart.IdProjectPart);
|
||||
|
||||
var totalCost = _context.ProjectPartItems
|
||||
.Where(x => x.IdProjectPartFk == projectPart.IdProjectPart)
|
||||
.ToList()
|
||||
.Sum(x => x.CostValue);
|
||||
|
||||
var coefficient = Math.Round(value,2) / Math.Round(totalCost, 2);
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
if (item.NumberOfItems * item.NumberOfSets == 0)
|
||||
item.SellingPrice = 0;
|
||||
else
|
||||
item.SellingPrice = Convert.ToSingle(Math.Round((coefficient * item.CostValue) / (item.NumberOfItems * item.NumberOfSets), 8));
|
||||
}
|
||||
|
||||
_context.SaveChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
successful = false;
|
||||
error = $"Project part with ID: {idProjectPart} not found";
|
||||
}
|
||||
|
||||
return new JsonResult(new { error, successful });
|
||||
}
|
||||
|
||||
public IActionResult OnPostCreateInvoice(string itemsJson)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
var itemsId = JsonSerializer.Deserialize<List<int>>(itemsJson);
|
||||
|
||||
var deliveryNotes = _context.Invoices
|
||||
.Include(x => x.InvoiceInvoiceItem)
|
||||
.Where(x => itemsId.Contains(x.IdInvoice)).ToList();
|
||||
|
||||
if (!deliveryNotes.Any())
|
||||
return new JsonResult(new { successful = false, error = "Delivery notes not found!" });
|
||||
|
||||
var idPartner = deliveryNotes.First().IdPartnerFk;
|
||||
|
||||
var newInvoice = new Models.Invoice.Invoice();
|
||||
Pages.Invoices.CreateModel.SetNewInvoice(user.IdCompanyFk, Models.Invoice.Invoice.InvoiceType.Invoice, ref newInvoice, _context);
|
||||
newInvoice.IdPartnerFk = idPartner;
|
||||
newInvoice.Date = DateTime.Now.Date;
|
||||
newInvoice.DateOfDispatch = deliveryNotes.Min(x => x.DateOfDispatch);
|
||||
newInvoice.BuyersOrderNumber = deliveryNotes.First().BuyersOrderNumber;
|
||||
|
||||
_context.Invoices.Add(newInvoice);
|
||||
_context.SaveChanges();
|
||||
var idInvoice = newInvoice.IdInvoice;
|
||||
|
||||
foreach (var deliveryNote in deliveryNotes)
|
||||
{
|
||||
foreach (var invoiceItem in deliveryNote.InvoiceInvoiceItem)
|
||||
{
|
||||
var newInvoiceItem = new InvoiceItem
|
||||
{
|
||||
Discount = invoiceItem.Discount,
|
||||
IdInvoiceFk = idInvoice,
|
||||
IdProjectPartItem = invoiceItem.IdProjectPartItem,
|
||||
IdItemFk = invoiceItem.IdItemFk,
|
||||
ItemDescription = invoiceItem.ItemDescription,
|
||||
Note = invoiceItem.Note,
|
||||
Price = invoiceItem.Price,
|
||||
Quantity = invoiceItem.Quantity,
|
||||
IdInvoiceItemJoinFk = invoiceItem.IdInvoiceItem
|
||||
};
|
||||
invoiceItem.State = InvoiceItem.InvoiceItemState.Closed;
|
||||
|
||||
_context.InvoiceItems.Add(newInvoiceItem);
|
||||
}
|
||||
|
||||
deliveryNote.State = Invoice.InvoiceState.Closed;
|
||||
|
||||
}
|
||||
_context.SaveChanges();
|
||||
|
||||
return new JsonResult(new { successful = true, error = "", idInvoice });
|
||||
}
|
||||
|
||||
public IActionResult OnPostCreateOfferFromProject(int idProject, string itemsJson)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
var itemsId = JsonSerializer.Deserialize<List<int>>(itemsJson);
|
||||
|
||||
var project = _context.Projects
|
||||
.Include(x => x.Partner)
|
||||
.Include(x => x.ProjectProjectPart)
|
||||
.ThenInclude(x => x.ProjectPartProjectPartItem)
|
||||
.FirstOrDefault(x => x.IdProject == idProject );
|
||||
|
||||
if (project == null)
|
||||
return new JsonResult(new { successful = false, error = "Project not found!" });
|
||||
|
||||
var idPartner = project.IdPartnerFk;
|
||||
|
||||
var newInvoice = new Invoice();
|
||||
Pages.Invoices.CreateModel.SetNewInvoice(user.IdCompanyFk, Invoice.InvoiceType.BuyersOrder, ref newInvoice, _context);
|
||||
newInvoice.IdPartnerFk = idPartner;
|
||||
newInvoice.Date = DateTime.Now.Date;
|
||||
newInvoice.DateOfDispatch = project.ProjectProjectPart.Min(x => x.ProjectPartProjectPartItem.Where(x => itemsId.Contains(x.IdProjectPartItem)).Min(y => y.DeliveryDate));
|
||||
newInvoice.State = Invoice.InvoiceState.Offer;
|
||||
newInvoice.BuyersOrderNumber = "";
|
||||
|
||||
_context.Invoices.Add(newInvoice);
|
||||
_context.SaveChanges();
|
||||
var idInvoice = newInvoice.IdInvoice;
|
||||
|
||||
foreach (var projectPart in project.ProjectProjectPart.OrderBy(x => x.ProjectPartNumber))
|
||||
{
|
||||
foreach (var projectPartItem in projectPart.ProjectPartProjectPartItem.Where(x => itemsId.Contains(x.IdProjectPartItem)).OrderBy(x => x.ProjectPartItemNumber))
|
||||
{
|
||||
var newInvoiceItem = new InvoiceItem
|
||||
{
|
||||
IdProjectPartItem = projectPartItem.IdProjectPartItem,
|
||||
Discount = 0,
|
||||
IdInvoiceFk = idInvoice,
|
||||
IdItemFk = projectPartItem.IdItemFk,
|
||||
ItemDescription = projectPartItem.MaterialDimensions,
|
||||
Note = "",
|
||||
Price = projectPartItem.SellingPrice,
|
||||
Quantity = projectPartItem.NumberOfItems * projectPartItem.NumberOfSets
|
||||
};
|
||||
|
||||
_context.InvoiceItems.Add(newInvoiceItem);
|
||||
}
|
||||
|
||||
}
|
||||
_context.SaveChanges();
|
||||
|
||||
return new JsonResult(new { successful = true, error = "", idInvoice });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
@page
|
||||
@using EveryThing.Models.Project
|
||||
@model EveryThing.Pages.Projects.EditPartModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Urejanje dela projekta";
|
||||
Layout = "~/Pages/Layouts/_Layout.cshtml";
|
||||
}
|
||||
|
||||
<form method="post">
|
||||
|
||||
<h4 class="d-flex justify-content-between align-items-center w-100 font-weight-bold py-1 mb-4">
|
||||
<span>
|
||||
<span class="text-muted font-weight-light">Projekt /</span> Urejanje dela projekta
|
||||
</span>
|
||||
</h4>
|
||||
|
||||
<div class="row mb-4">
|
||||
<div class="col-4">
|
||||
<div class="card">
|
||||
<h6 class="card-header">
|
||||
Podatki dela projekta
|
||||
</h6>
|
||||
<div class="card-body">
|
||||
<input type="hidden" asp-for="ProjectPart.IdProjectPart" />
|
||||
<input type="hidden" asp-for="ProjectPart.IdProjectFk" />
|
||||
<input type="hidden" asp-for="ProjectPart.ProjectPartNumber" />
|
||||
<div class="form-group">
|
||||
<label asp-for="ProjectPart.Title" class="form-label"></label>
|
||||
<input asp-for="ProjectPart.Title" class="form-control" />
|
||||
<span asp-validation-for="ProjectPart.Title" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="ProjectPart.Description" class="form-label"></label>
|
||||
<input asp-for="ProjectPart.Description" class="form-control" />
|
||||
<span asp-validation-for="ProjectPart.Description" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="ProjectPart.PathOfPlans" class="form-label"></label>
|
||||
<input autocomplete="off" asp-for="ProjectPart.PathOfPlans" class="form-control"/>
|
||||
<span asp-validation-for="ProjectPart.PathOfPlans" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">
|
||||
<div class="form-group">
|
||||
<label asp-for="ProjectPart.Status" class="form-label"></label>
|
||||
<select asp-for="ProjectPart.Status" asp-items="Html.GetEnumSelectList<ProjectPartStatus>()" class="form-control">
|
||||
<option>Izberite status</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<div class="form-group">
|
||||
<label asp-for="ProjectPart.ShippedDate" class="form-label"></label>
|
||||
<input asp-for="ProjectPart.ShippedDate" class="form-control" />
|
||||
<span asp-validation-for="ProjectPart.ShippedDate" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<div class="form-group">
|
||||
<label asp-for="ProjectPart.FinishedDate" class="form-label"></label>
|
||||
<input asp-for="ProjectPart.FinishedDate" class="form-control" />
|
||||
<span asp-validation-for="ProjectPart.FinishedDate" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer py-3 text-right">
|
||||
<button type="submit" class="btn btn-primary">Shrani</button>
|
||||
<a asp-page="Edit" asp-route-id="@ViewBag.IdProject" class="btn btn-default">Prekliči</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using EveryThing.Data;
|
||||
using EveryThing.Models;
|
||||
using EveryThing.Models.Project;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace EveryThing.Pages.Projects
|
||||
{
|
||||
[Authorize(Roles = "Administrator,ProjecThingUser")]
|
||||
public class EditPartModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
private readonly UserManager<IdentityApplicationUser> _userManager;
|
||||
private readonly SignInManager<IdentityApplicationUser> _loginManager;
|
||||
private readonly RoleManager<IdentityApplicationRole> _roleManager;
|
||||
|
||||
public EditPartModel(ApplicationDbContext context, UserManager<IdentityApplicationUser> userManager, SignInManager<IdentityApplicationUser> loginManager, RoleManager<IdentityApplicationRole> roleManager)
|
||||
{
|
||||
_context = context;
|
||||
_userManager = userManager;
|
||||
_loginManager = loginManager;
|
||||
_roleManager = roleManager;
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public ProjectPart ProjectPart { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
ProjectPart = await _context.ProjectParts.FirstOrDefaultAsync(m => m.IdProjectPart == id);
|
||||
|
||||
if (ProjectPart == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
ViewData["IdProject"] = ProjectPart.IdProjectFk;
|
||||
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return Page();
|
||||
}
|
||||
|
||||
_context.Attach(ProjectPart).State = EntityState.Modified;
|
||||
|
||||
try
|
||||
{
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
if (!ProjectExists(ProjectPart.IdProjectPart))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return RedirectToPage("./Edit",new { id = ProjectPart.IdProjectFk });
|
||||
}
|
||||
|
||||
private bool ProjectExists(int id)
|
||||
{
|
||||
return _context.ProjectParts.Any(e => e.IdProjectPart == id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
@model EveryThing.Pages.Projects.EditModel.EditProjectPartData
|
||||
|
||||
<tr data-iditem="@(Model.Item.IdProjectPartItem)">
|
||||
@using (Html.BeginForm("UpdatePartItem", "Edit", FormMethod.Post))
|
||||
{
|
||||
<input type="hidden" asp-for="Item.IdProjectPartItem" />
|
||||
<td class="table-eddit" style="width: 20px;">
|
||||
</td>
|
||||
<td class="table-eddit">
|
||||
<select id="selTblItem_@(Model.Item.IdProjectPartItem.ToString())" asp-for="Item.IdItemFk" class="form-control select2" asp-items="Model.SelectListItems" style="width: 100%"></select>
|
||||
@(Model.Item.ProjectPartNumberFormatted)
|
||||
</td>
|
||||
<td class="table-eddit">
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<select id="selTblMaterial_@(Model.Item.IdProjectPartItem.ToString())" asp-for="Item.IdMaterialFk" class="form-control select2" asp-items="Model.SelectListMaterials" style="width: 50% !important"></select>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<select id="selTblMaterialSupplier_@(Model.Item.IdProjectPartItem.ToString())" asp-for="Item.IdMaterialSupplierFk" class="form-control select2" asp-items="Model.SelectListSuppliers" style="width: 50% !important"></select>
|
||||
</div>
|
||||
</div>
|
||||
<input id="inpTblMaterialDimensions_@(Model.Item.IdProjectPartItem.ToString())" asp-for="Item.MaterialDimensions" class="form-control" style="width: 100%"/>
|
||||
</td>
|
||||
<td class="table-eddit table-number-edit">
|
||||
<input id="inpTblNumberOfItems_@(Model.Item.IdProjectPartItem.ToString())" asp-for="Item.NumberOfItems" class="form-control" style="width: 100%" />
|
||||
<input id="inpTblNumberOfSets_@(Model.Item.IdProjectPartItem.ToString())" asp-for="Item.NumberOfSets" class="form-control" style="width: 100%" />
|
||||
</td>
|
||||
<td class="table-eddit table-price-edit">
|
||||
<input id="inpTblMaterialPrice_@(Model.Item.IdProjectPartItem.ToString())" asp-for="Item.MaterialPrice" class="form-control inp-tbl-edit-calculate-difference-in-price" style="width: 100%" />
|
||||
</td>
|
||||
<td class="table-eddit table-price-edit">
|
||||
<input id="inpTblWrokPrice_@(Model.Item.IdProjectPartItem.ToString())" asp-for="Item.WorkPrice" class="form-control inp-tbl-edit-calculate-difference-in-price" style="width:100%" />
|
||||
</td>
|
||||
<td class="table-eddit table-price-edit">
|
||||
<input id="inpTblCostPrice_@(Model.Item.IdProjectPartItem.ToString())" asp-for="Item.CostPrice" class="form-control" readonly="readonly" style="width:100%" />
|
||||
</td>
|
||||
<td class="table-eddit table-price-edit">
|
||||
<input id="inpTblDifferenceInPrice_@(Model.Item.IdProjectPartItem.ToString())" asp-for="Item.DifferenceInPricePercentage" class="form-control inp-tbl-edit-calculate-price" style="width:100%" />
|
||||
</td>
|
||||
<td class="table-eddit table-price-edit">
|
||||
<input id="inpTblSellingPrice_@(Model.Item.IdProjectPartItem.ToString())" asp-for="Item.SellingPrice" class="form-control inp-tbl-edit-calculate-difference-in-price" style="width:100%" />
|
||||
</td>
|
||||
<td class="table-eddit" style="width: 120px !important;">
|
||||
<select id="selTblStatus_@(Model.Item.IdProjectPartItem.ToString())" asp-for="Item.Status" asp-items="Html.GetEnumSelectList<EveryThing.Models.Project.ProjectPartItemStatus>()" class="form-control" style="width: 100%">
|
||||
</select>
|
||||
@Html.TextBoxFor(m => m.Item.DeliveryDate, "{0:yyyy-MM-dd}", new { @class = "form-control", type = "date", id = "inpTblDeliveryDate_" + Model.Item.IdProjectPartItem.ToString() })
|
||||
</td>
|
||||
<td class="text-right table-eddit" style="width: 70px;">
|
||||
<a class="btn btn-xs icon-btn btn-outline-success borderless" href='javascript:;' data-state="success" data-iditem="@(Model.Item.IdProjectPartItem)" onclick="updatePartItem(this)"><i class="fas fa-check"></i></a>
|
||||
<a id="btnTblCancel_@(Model.Item.IdProjectPartItem.ToString())" href='javascript:;' class="btn btn-xs icon-btn btn-outline-danger borderless" data-state="danger" hx-get="@Url.Page("Edit", "DetailPartItem", new { id = Model.Item.IdProjectPartItem })" hx-swap="outerHTML" hx-target="closest tr"><i class="fas fa-ban"></i></a>
|
||||
</td>
|
||||
}
|
||||
</tr>
|
||||
@@ -1,230 +0,0 @@
|
||||
@page
|
||||
@using EveryThing.Models.Project
|
||||
@model EveryThing.Pages.Projects.IndexModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Projekti";
|
||||
Layout = "~/Pages/Layouts/_Layout.cshtml";
|
||||
}
|
||||
|
||||
<h4 class="d-flex justify-content-between align-items-center w-100 font-weight-bold py-1 mb-4">
|
||||
<span>
|
||||
<span class="text-muted font-weight-light">Projekti /</span> Pregled
|
||||
</span>
|
||||
</h4>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 mb-2 text-right">
|
||||
<form method="get">
|
||||
<div class="btn-group">
|
||||
<input class="form-control" type="text" name="searchString" value="@ViewData["SearchString"]" placeholder="Iskanje..." autocomplete="off">
|
||||
<select asp-for="Year" class="form-control" asp-items="ViewBag.Years"></select>
|
||||
<div class="btn-group" title="Columns">
|
||||
<button class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown" aria-label="Nastavitve" title="Nastavitve">
|
||||
<i class="opacity-75 ion ion-md-apps"></i>
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<label class="dropdown-item">
|
||||
<input type="checkbox" name="openProjects" @ViewData["OpenProjects"]> <span>Odprti</span>
|
||||
</label>
|
||||
<label class="dropdown-item">
|
||||
<input type="checkbox" name="inProductionProjects" @ViewData["InProductionProjects"]> <span>V izdelavi</span>
|
||||
</label>
|
||||
<label class="dropdown-item">
|
||||
<input type="checkbox" name="finishedProjects" @ViewData["FinishedProjects"]> <span>Zaključeni projekti</span>
|
||||
</label>
|
||||
<label class="dropdown-item">
|
||||
<input type="checkbox" name="offerProjects" @ViewData["OffersProjects"]> <span>Ponudbe</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-secondary" aria-label="Osveži" title="Osveži">
|
||||
<i class="opacity-75 ion ion-md-refresh"></i>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
|
||||
<h6 class="card-header">
|
||||
Seznam projektov
|
||||
</h6>
|
||||
|
||||
<table class="table card-table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 150px;">
|
||||
@Html.DisplayNameFor(model => model.Project[0].ProjectNumberFormatted)
|
||||
</th>
|
||||
<th style="width: 200px;">
|
||||
@Html.DisplayNameFor(model => model.Project[0].Title)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Project[0].IdPartnerFk)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Project[0].Description)
|
||||
</th>
|
||||
<th style="width: 140px">
|
||||
@Html.DisplayNameFor(model => model.Project[0].FirstDeliveryDateString)
|
||||
</th>
|
||||
<th style="width: 100px">
|
||||
@Html.DisplayNameFor(model => model.Project[0].Status)
|
||||
</th>
|
||||
<th style="width: 110px;"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model.Project)
|
||||
{
|
||||
<tr data-idproject="@item.IdProject" data-title="@item.Title">
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.ProjectNumberFormatted)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-page="Edit" asp-route-id="@item.IdProject">@Html.DisplayFor(modelItem => item.Title)</a>
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Partner.Title)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Description)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.FirstDeliveryDateString)
|
||||
</td>
|
||||
<td>
|
||||
@switch (item.Status)
|
||||
{
|
||||
case ProjectStatus.Finished:
|
||||
<span class='badge badge-success'>@Html.DisplayFor(modelItem => item.Status)</span>
|
||||
break;
|
||||
case ProjectStatus.InProduction:
|
||||
<span class='badge badge-warning'>@Html.DisplayFor(modelItem => item.Status)</span>
|
||||
break;
|
||||
case ProjectStatus.Offer:
|
||||
<span class='badge badge-default'>@Html.DisplayFor(modelItem => item.Status)</span>
|
||||
break;
|
||||
default:
|
||||
<span class='badge badge-info'>@Html.DisplayFor(modelItem => item.Status)</span>
|
||||
break;
|
||||
}
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<a class="btn btn-xs icon-btn btn-outline-secondary borderless" asp-page="Edit" asp-route-id="@item.IdProject" data-toggle="tooltip" data-placement="top" title="Urejanje" data-state="secondary"><i class="fas fa-pencil-alt"></i></a>
|
||||
<a data-idproject="@item.IdProject" class="btn btn-xs icon-btn btn-outline-secondary borderless" data-toggle="tooltip" data-placement="top" title="Kopiraj projekt" data-state="secondary" href="javascript:;" onclick="copyProject(this);"><i class="far fa-copy"></i></a>
|
||||
<a class="btn btn-xs icon-btn btn-outline-danger borderless" data-state="danger" href='javascript:;' onclick="deleteProject(this)" data-toggle="tooltip" data-placement="top" title="Izbriši"><i class="fas fa-times"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="card-footer py-3 text-right">
|
||||
<a asp-page="Create" class="btn btn-primary">Vnos projekta</a>
|
||||
</div>
|
||||
</div>
|
||||
@Html.AntiForgeryToken()
|
||||
@section Scripts {
|
||||
<script>
|
||||
$('[data-toggle="tooltip"]').tooltip({container: 'table'});
|
||||
|
||||
function deleteProject(element) {
|
||||
let row = $(element).parent().parent();
|
||||
let idProject = $(row).attr('data-idproject');
|
||||
let title = $(row).attr('data-title');
|
||||
|
||||
Swal.fire({
|
||||
title: `Izbrišem projekt ${title}?`,
|
||||
text: "Tega dejanja ni možno razveljaviti!",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Da, izbriši!',
|
||||
cancelButtonText: 'Prekliči!'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
$.blockUI();
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
beforeSend: function (xhr) {
|
||||
xhr.setRequestHeader("XSRF-TOKEN",
|
||||
$('input:hidden[name="__RequestVerificationToken"]').val());
|
||||
},
|
||||
url: "/Projects/Index/?handler=Project",
|
||||
data: {
|
||||
idProject
|
||||
},
|
||||
success: function (data) {
|
||||
$.unblockUI();
|
||||
if (data.successful) {
|
||||
$(row).remove();
|
||||
} else {
|
||||
console.log(data);
|
||||
Swal.fire('Napaka pri brisanju projekta',
|
||||
data.error,
|
||||
'error');
|
||||
}
|
||||
|
||||
},
|
||||
error: function (xhr, ajaxOptions, thrownError) {
|
||||
console.log(xhr);
|
||||
alert(xhr.responseText);
|
||||
$.unblockUI();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function copyProject(element) {
|
||||
let idProject = $(element).attr('data-idproject');
|
||||
|
||||
Swal.fire({
|
||||
title: `Kopiram projekt?`,
|
||||
text: "Tega dejanja ni možno razveljaviti!",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Da, kopiraj!',
|
||||
cancelButtonText: 'Prekliči!'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
$.blockUI();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
beforeSend: function (xhr) {
|
||||
xhr.setRequestHeader("XSRF-TOKEN",
|
||||
$('input:hidden[name="__RequestVerificationToken"]').val());
|
||||
},
|
||||
url: "/Projects/Index/?handler=CopyProject",
|
||||
data: {
|
||||
idProject
|
||||
},
|
||||
success: function (data) {
|
||||
$.unblockUI();
|
||||
if (data.successful) {
|
||||
location.reload();
|
||||
} else {
|
||||
Swal.fire('Napaka pri kopiranju projekta',
|
||||
data.error,
|
||||
'error');
|
||||
}
|
||||
|
||||
},
|
||||
error: function (xhr, ajaxOptions, thrownError) {
|
||||
console.log(xhr);
|
||||
alert(xhr.responseText);
|
||||
$.unblockUI();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
}
|
||||
@@ -1,252 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using EveryThing.Data;
|
||||
using EveryThing.Models;
|
||||
using EveryThing.Models.Project;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using DocumentFormat.OpenXml.Bibliography;
|
||||
|
||||
namespace EveryThing.Pages.Projects
|
||||
{
|
||||
[Authorize(Roles = "Administrator,ProjecThingUser")]
|
||||
public class IndexModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
private readonly UserManager<IdentityApplicationUser> _userManager;
|
||||
|
||||
public IndexModel(ApplicationDbContext context, UserManager<IdentityApplicationUser> userManager)
|
||||
{
|
||||
_context = context;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
public IList<Project> Project { get;set; }
|
||||
public string Year { get; set; }
|
||||
|
||||
|
||||
public async Task OnGetAsync(string searchString, string finishedProjects, string openProjects, string offerProjects, string inProductionProjects, string year)
|
||||
{
|
||||
ViewData["SearchString"] = searchString;
|
||||
ViewData["FinishedProjects"] = finishedProjects == "on" ? "checked" : "";
|
||||
ViewData["OpenProjects"] = openProjects == "on" ? "checked" : "";
|
||||
ViewData["OffersProjects"] = offerProjects == "on" ? "checked" : "";
|
||||
ViewData["InProductionProjects"] = inProductionProjects == "on" ? "checked" : "";
|
||||
|
||||
Year = year;
|
||||
Year ??= DateTime.Now.Year.ToString();
|
||||
|
||||
ViewData["Years"] = new SelectList(Enumerable.Range(2022, (DateTime.Now.Year - 2022) + 2));
|
||||
|
||||
Project = new List<Project>();
|
||||
|
||||
await _context.Projects
|
||||
.Include(p => p.Company)
|
||||
.Include(p => p.Partner)
|
||||
.Include(x => x.ProjectProjectPart)
|
||||
.ThenInclude(x => x.ProjectPartProjectPartItem)
|
||||
.Where(x => x.ProjectYear == Convert.ToInt32(Year))
|
||||
.ForEachAsync(x =>
|
||||
{
|
||||
x.FirstDeliveryDate = x.ProjectProjectPart.Max(y => y.ProjectPartProjectPartItem
|
||||
.Where(a => a.Status == ProjectPartItemStatus.InProduction ||
|
||||
a.Status == ProjectPartItemStatus.Opened).Max(z => z.DeliveryDate)) == null
|
||||
? DateTime.MaxValue
|
||||
: x.ProjectProjectPart.Max(y =>
|
||||
y.ProjectPartProjectPartItem.Where(a =>
|
||||
a.Status == ProjectPartItemStatus.InProduction ||
|
||||
a.Status == ProjectPartItemStatus.Opened).Max(z => z.DeliveryDate));
|
||||
Project.Add(x);
|
||||
});
|
||||
|
||||
Project = Project.OrderBy(x => (int)x.Status)
|
||||
.ThenBy(x => x.FirstDeliveryDate)
|
||||
.ToList();
|
||||
|
||||
var listStatus = new List<ProjectStatus>();
|
||||
// Active companies
|
||||
if (!string.IsNullOrEmpty(finishedProjects)
|
||||
&& finishedProjects == "on")
|
||||
{
|
||||
listStatus.Add(ProjectStatus.Finished);
|
||||
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(openProjects)
|
||||
&& openProjects == "on")
|
||||
{
|
||||
listStatus.Add(ProjectStatus.Opened);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(offerProjects)
|
||||
&& offerProjects == "on")
|
||||
{
|
||||
listStatus.Add(ProjectStatus.Offer);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(inProductionProjects)
|
||||
&& inProductionProjects == "on")
|
||||
{
|
||||
listStatus.Add(ProjectStatus.InProduction);
|
||||
}
|
||||
|
||||
if (listStatus.Count > 0)
|
||||
{
|
||||
Project = Project.Where(s => listStatus.Contains(s.Status)).ToList();
|
||||
}
|
||||
|
||||
// Search string
|
||||
if (!string.IsNullOrEmpty(searchString))
|
||||
{
|
||||
Project = Project
|
||||
.Where(s => s.Title.Contains(searchString, StringComparison.InvariantCultureIgnoreCase)
|
||||
|| s.Partner.Title.Contains(searchString, StringComparison.InvariantCultureIgnoreCase)
|
||||
|| (s.Description != null && s.Description.Contains(searchString, StringComparison.InvariantCultureIgnoreCase))
|
||||
|| s.ProjectNumberFormatted.Contains(searchString, StringComparison.CurrentCultureIgnoreCase))
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public IActionResult OnDeleteProject(int idProject)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
bool successful = true;
|
||||
string error = "";
|
||||
|
||||
var project = _context.Projects
|
||||
.Include(x => x.ProjectProjectPart)
|
||||
.ThenInclude(x => x.ProjectPartProjectPartItem)
|
||||
.ThenInclude(x => x.InvoiceItem)
|
||||
.Where(x => x.IdCompanyFk == user.IdCompanyFk)
|
||||
.FirstOrDefault(x => x.IdProject == idProject);
|
||||
|
||||
|
||||
if (project == null)
|
||||
{
|
||||
successful = false;
|
||||
error = $"Project with ID: {idProject} not found";
|
||||
}
|
||||
else if (project.ProjectProjectPart.Any(x => x.ProjectPartProjectPartItem.Any(x => x.InvoiceItem.Count > 0)))
|
||||
{
|
||||
successful = false;
|
||||
error = $"Projekt ima vezane dokumente fakturiranja!\nBrisanje ni možno!";
|
||||
}
|
||||
else
|
||||
{
|
||||
var projectParts = _context.ProjectParts.Where(x => x.IdProjectFk == idProject).ToList();
|
||||
|
||||
for (int i = 0; i < projectParts.Count(); i++)
|
||||
{
|
||||
var part = projectParts[i];
|
||||
var projectPartItems = _context.ProjectPartItems.Where(x => x.IdProjectPartFk == part.IdProjectPart).ToList();
|
||||
|
||||
for (int j = 0; j < projectPartItems.Count; j++)
|
||||
{
|
||||
_context.ProjectPartItems.Remove(projectPartItems[j]);
|
||||
}
|
||||
|
||||
_context.ProjectParts.Remove(part);
|
||||
}
|
||||
_context.Projects.Remove(project);
|
||||
_context.SaveChanges();
|
||||
}
|
||||
|
||||
return new JsonResult(new { idProject = idProject, error = error, successful = successful });
|
||||
}
|
||||
|
||||
public IActionResult OnPostCopyProject(int idProject)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
bool successful = true;
|
||||
string error = "";
|
||||
|
||||
var project = _context.Projects
|
||||
.FirstOrDefault(x => x.IdCompanyFk == user.IdCompanyFk && x.IdProject == idProject);
|
||||
|
||||
if (project != null)
|
||||
{
|
||||
var newProject = new Project
|
||||
{
|
||||
IdCompanyFk = user.IdCompanyFk,
|
||||
Status = ProjectStatus.Opened,
|
||||
BuyersOrderNumber = project.BuyersOrderNumber,
|
||||
Description = project.Description,
|
||||
IdPartnerFk = project.IdPartnerFk,
|
||||
ProjectYear = DateTime.Now.Year,
|
||||
ProjectNumber = _context.Projects.Where(x => x.IdCompanyFk == user.IdCompanyFk && x.ProjectYear == DateTime.Now.Year).Max(x => x.ProjectNumber) + 1,
|
||||
Title = project.Title,
|
||||
};
|
||||
|
||||
if (newProject.ProjectNumber <= 0)
|
||||
newProject.ProjectNumber = 1;
|
||||
|
||||
_context.Projects.Add(newProject);
|
||||
|
||||
_context.SaveChanges();
|
||||
|
||||
var projectParts = _context.ProjectParts.Where(x => x.IdProjectFk == project.IdProject)
|
||||
.OrderBy(x => x.ProjectPartNumber).ThenBy(x => x.IdProjectFk).ToList();
|
||||
|
||||
var projectPartCounter = 1;
|
||||
foreach (var projectPart in projectParts)
|
||||
{
|
||||
var newProjectPart = new ProjectPart
|
||||
{
|
||||
IdProjectFk = newProject.IdProject,
|
||||
Description = projectPart.Description,
|
||||
//FinishedDate = item.FinishedDate,
|
||||
PathOfPlans = projectPart.PathOfPlans,
|
||||
ShippedDate = projectPart.ShippedDate,
|
||||
Status = projectPart.Status,
|
||||
Title = projectPart.Title,
|
||||
ProjectPartNumber = projectPartCounter
|
||||
};
|
||||
|
||||
_context.ProjectParts.Add(newProjectPart);
|
||||
|
||||
_context.SaveChanges();
|
||||
|
||||
var projectPartItemCounter = 1;
|
||||
foreach (var projectPartItem in _context.ProjectPartItems.Where(x => x.IdProjectPartFk == projectPart.IdProjectPart).ToList())
|
||||
{
|
||||
var newProjectPartItem = new ProjectPartItem
|
||||
{
|
||||
IdItemFk = projectPartItem.IdItemFk,
|
||||
IdMaterialFk = projectPartItem.IdMaterialFk,
|
||||
IdMaterialSupplierFk = projectPartItem.IdMaterialSupplierFk,
|
||||
IdProjectPartFk = newProjectPart.IdProjectPart,
|
||||
MaterialDimensions = projectPartItem.MaterialDimensions,
|
||||
MaterialPrice = projectPartItem.MaterialPrice,
|
||||
NumberOfItems = projectPartItem.NumberOfItems,
|
||||
NumberOfItemsFinished = projectPartItem.NumberOfItemsFinished,
|
||||
WorkPrice = projectPartItem.WorkPrice,
|
||||
NumberOfSets = projectPartItem.NumberOfSets,
|
||||
Status = ProjectPartItemStatus.Opened,
|
||||
SellingPrice = projectPartItem.SellingPrice,
|
||||
ProjectPartItemNumber = projectPartItemCounter
|
||||
};
|
||||
_context.ProjectPartItems.Add(newProjectPartItem);
|
||||
|
||||
projectPartItemCounter++;
|
||||
}
|
||||
_context.SaveChanges();
|
||||
|
||||
projectPartCounter++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
successful = false;
|
||||
error = $"Project with ID: {idProject} not found";
|
||||
}
|
||||
|
||||
return new JsonResult(new { error, successful });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"ConnectionStrings": {
|
||||
"DataConnection": "server=192.168.111.85;user=everything;password=EveryThing2022!;database=EveryThingDev"
|
||||
"DataConnection": "server=192.168.111.85;user=everything;password=EveryThing2022!;database=EveryThing2"
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
|
||||
Reference in New Issue
Block a user