diff --git a/ClientsCrm.dpr b/ClientsCrm.dpr
index e00a328..b017c08 100644
--- a/ClientsCrm.dpr
+++ b/ClientsCrm.dpr
@@ -21,7 +21,12 @@ uses
UfrClientAnalitic in 'UfrClientAnalitic.pas' {frClientAnalitic},
UfrClientAnaliticR in 'UfrClientAnaliticR.pas' {frClientAnaliticR},
UfrAnaliticDep in 'UfrAnaliticDep.pas' {frAnaliticDep},
- UfrAnaliticDepR in 'UfrAnaliticDepR.pas' {frAnaliticDepR};
+ UfrAnaliticDepR in 'UfrAnaliticDepR.pas' {frAnaliticDepR},
+ UfrAnaliticWork in 'UfrAnaliticWork.pas' {frAnaliticWork},
+ UfrAnaliticWorkR in 'UfrAnaliticWorkR.pas' {frAnaliticWorkR},
+ UfrAnaliticUsers in 'UfrAnaliticUsers.pas' {frAnaliticUsers},
+ UfrAnaliticUsersR in 'UfrAnaliticUsersR.pas' {frAnaliticUsersR},
+ UfrAbout in 'UfrAbout.pas' {frAbout};
{$R *.res}
@@ -30,6 +35,11 @@ begin
Application.MainFormOnTaskbar := True;
Application.CreateForm(Tdm, dm);
Application.CreateForm(TfrLogin, frLogin);
+ //Application.CreateForm(TfrAbout, frAbout);
+ //Application.CreateForm(TfrAnaliticUsersR, frAnaliticUsersR);
+ //Application.CreateForm(TfrAnaliticUsers, frAnaliticUsers);
+ //Application.CreateForm(TfrAnaliticWorkR, frAnaliticWorkR);
+ //Application.CreateForm(TfrAnaliticWork, frAnaliticWork);
//Application.CreateForm(TfrAnaliticDepR, frAnaliticDepR);
//Application.CreateForm(TfrAnaliticDep, frAnaliticDep);
//Application.CreateForm(TfrClientAnaliticR, frClientAnaliticR);
diff --git a/ClientsCrm.dproj b/ClientsCrm.dproj
index 237d439..8bb5d4b 100644
--- a/ClientsCrm.dproj
+++ b/ClientsCrm.dproj
@@ -168,6 +168,26 @@
dfm
+
+
+ dfm
+
+
+
+ dfm
+
+
+
+ dfm
+
+
+
+ dfm
+
+
+
+ dfm
+
Cfg_2
Base
diff --git a/ClientsCrm.dproj.local b/ClientsCrm.dproj.local
index ba4b13c..5cfe4fb 100644
--- a/ClientsCrm.dproj.local
+++ b/ClientsCrm.dproj.local
@@ -1,61 +1,76 @@
п»ї
- 1899.12.30 00:00:00.000.871,=D:\projects\ClientsCrm\Unit1.pas
- 1899.12.30 00:00:00.000.963,=D:\projects\ClientsCrm\Unit1.pas
+ 1899.12.30 00:00:00.000.194,D:\projects\ClientsCrm\UfrAnaliticUsersR.dfm=D:\projects\ClientsCrm\Unit1.dfm
+ 1899.12.30 00:00:00.000.671,=D:\projects\ClientsCrm\EncryptUnit.pas
+ 1899.12.30 00:00:00.000.545,D:\projects\ClientsCrm\UfrAnaliticWorkR.pas=D:\projects\ClientsCrm\Unit1.pas
+ 1899.12.30 00:00:00.000.191,D:\projects\ClientsCrm\UfrClientWorkReportR.dfm=D:\projects\ClientsCrm\Unit1.dfm
+ 1899.12.30 00:00:00.000.610,C:\Users\admin\Documents\Embarcadero\Studio\Projects\Unit1.dfm=D:\projects\ClientsCrm\LoginUnit.dfm
+ 1899.12.30 00:00:00.000.194,D:\projects\ClientsCrm\UfrAnaliticUsersR.pas=D:\projects\ClientsCrm\Unit1.pas
+ 1899.12.30 00:00:00.000.666,=D:\projects\ClientsCrm\DataUnit.pas
+ 1899.12.30 00:00:00.000.431,D:\projects\ClientsCrm\UfrReportClient.dfm=D:\projects\ClientsCrm\Unit1.dfm
+ 1899.12.30 00:00:00.000.545,D:\projects\ClientsCrm\UfrAnaliticWorkR.dfm=D:\projects\ClientsCrm\Unit1.dfm
+ 1899.12.30 00:00:00.000.803,=D:\projects\ClientsCrm\Unit1.pas
+ 1899.12.30 00:00:00.000.030,=D:\projects\ClientsCrm\Unit1.pas
1899.12.30 00:00:00.000.901,=D:\projects\ClientsCrm\Unit1.pas
- 1899.12.30 00:00:00.000.713,=D:\projects\ClientsCrm\Unit1.pas
+ 1899.12.30 00:00:00.000.176,=D:\projects\ClientsCrm\Unit1.pas
1899.12.30 00:00:00.000.364,=D:\projects\ClientsCrm\Unit1.pas
- 1899.12.30 00:00:00.000.030,=D:\projects\ClientsCrm\Unit1.pas
- 1899.12.30 00:00:00.000.070,=D:\projects\ClientsCrm\Unit1.pas
- 1899.12.30 00:00:00.000.507,D:\projects\ClientsCrm\Unit1.pas=D:\projects\ClientsCrm\MainUnit.pas
- 1899.12.30 00:00:00.000.236,D:\projects\ClientsCrm\Unit1.pas=D:\projects\ClientsCrm\UfrEditUser.pas
- 1899.12.30 00:00:00.000.803,=D:\projects\ClientsCrm\Unit1.pas
- 1899.12.30 00:00:00.000.102,D:\projects\ClientsCrm\Unit1.pas=D:\projects\ClientsCrm\UtilsUnit.pas
- 1899.12.30 00:00:00.000.696,D:\projects\ClientsCrm\Unit1.pas=D:\projects\ClientsCrm\UfrEditTask.pas
- 1899.12.30 00:00:00.000.791,D:\projects\ClientsCrm\Unit1.pas=D:\projects\ClientsCrm\TaskUnit.pas
- 1899.12.30 00:00:00.000.960,=D:\projects\ClientsCrm\Unit1.pas
- 1899.12.30 00:00:00.000.191,D:\projects\ClientsCrm\UfrClientWorkReportR.dfm=D:\projects\ClientsCrm\Unit1.dfm
1899.12.30 00:00:00.000.432,=D:\projects\ClientsCrm\UserModel.pas
- 1899.12.30 00:00:00.000.228,D:\projects\ClientsCrm\Unit1.pas=D:\projects\ClientsCrm\UfrAnaliticDep.pas
- 1899.12.30 00:00:00.000.610,C:\Users\admin\Documents\Embarcadero\Studio\Projects\Unit1.pas=D:\projects\ClientsCrm\LoginUnit.pas
- 1899.12.30 00:00:00.000.685,=C:\Users\admin\Documents\Embarcadero\Studio\Projects\Unit1.pas
+ 1899.12.30 00:00:00.000.713,=D:\projects\ClientsCrm\Unit1.pas
+ 1899.12.30 00:00:00.000.166,=D:\projects\ClientsCrm\Unit1.pas
1899.12.30 00:00:00.000.642,=C:\Users\admin\Documents\Embarcadero\Studio\Projects\Unit1.pas
- 1899.12.30 00:00:00.000.176,=D:\projects\ClientsCrm\Unit1.pas
- 1899.12.30 00:00:00.000.062,=D:\projects\ClientsCrm\Unit1.pas
- 1899.12.30 00:00:00.000.253,=D:\projects\ClientsCrm\Unit1.pas
- 1899.12.30 00:00:00.000.798,=D:\projects\ClientsCrm\Unit1.pas
- 1899.12.30 00:00:00.000.970,D:\projects\ClientsCrm\Unit1.pas=D:\projects\ClientsCrm\UfrClientAnaliticR.pas
- 1899.12.30 00:00:00.000.361,=D:\projects\ClientsCrm\Unit1.pas
- 1899.12.30 00:00:00.000.820,D:\projects\ClientsCrm\Unit1.pas=D:\projects\ClientsCrm\UfrClientAnaliic.pas
- 1899.12.30 00:00:00.000.072,D:\projects\ClientsCrm\Unit1.pas=D:\projects\ClientsCrm\UfrManageUsers.pas
- 1899.12.30 00:00:00.000.250,=D:\projects\ClientsCrm\UfrSett.pas
- 1899.12.30 00:00:00.000.539,C:\Users\admin\Documents\Embarcadero\Studio\Projects\Project1.dproj=D:\projects\ClientsCrm\ClientsCrm.dproj
- 1899.12.30 00:00:00.000.332,D:\projects\ClientsCrm\UfrClientAnaliic.dfm=D:\projects\ClientsCrm\UfrClientAnalitic.dfm
- 1899.12.30 00:00:00.000.257,D:\projects\ClientsCrm\UfrClientWorkReport.pas=D:\projects\ClientsCrm\Unit1.pas
- 1899.12.30 00:00:00.000.332,D:\projects\ClientsCrm\UfrClientAnaliic.pas=D:\projects\ClientsCrm\UfrClientAnalitic.pas
- 1899.12.30 00:00:00.000.428,D:\projects\ClientsCrm\LoginUnit.pas=
- 1899.12.30 00:00:00.000.876,D:\projects\ClientsCrm\UfrReportClientR.pas=D:\projects\ClientsCrm\Unit1.pas
- 1899.12.30 00:00:00.000.431,D:\projects\ClientsCrm\UfrReportClient.dfm=D:\projects\ClientsCrm\Unit1.dfm
- 1899.12.30 00:00:00.000.666,=D:\projects\ClientsCrm\DataUnit.pas
- 1899.12.30 00:00:00.000.610,C:\Users\admin\Documents\Embarcadero\Studio\Projects\Unit1.dfm=D:\projects\ClientsCrm\LoginUnit.dfm
- 1899.12.30 00:00:00.000.431,D:\projects\ClientsCrm\UfrReportClient.pas=D:\projects\ClientsCrm\Unit1.pas
- 1899.12.30 00:00:00.000.191,D:\projects\ClientsCrm\UfrClientWorkReportR.pas=D:\projects\ClientsCrm\Unit1.pas
- 1899.12.30 00:00:00.000.671,=D:\projects\ClientsCrm\EncryptUnit.pas
+ 1899.12.30 00:00:00.000.970,D:\projects\ClientsCrm\Unit1.dfm=D:\projects\ClientsCrm\UfrClientAnaliticR.dfm
1899.12.30 00:00:00.000.687,D:\projects\ClientsCrm\Unit1.dfm=D:\projects\ClientsCrm\UfrHandbook.dfm
- 1899.12.30 00:00:00.000.072,D:\projects\ClientsCrm\Unit1.dfm=D:\projects\ClientsCrm\UfrManageUsers.dfm
- 1899.12.30 00:00:00.000.507,D:\projects\ClientsCrm\Unit1.dfm=D:\projects\ClientsCrm\MainUnit.dfm
1899.12.30 00:00:00.000.820,D:\projects\ClientsCrm\Unit1.dfm=D:\projects\ClientsCrm\UfrClientAnaliic.dfm
- 1899.12.30 00:00:00.000.687,D:\projects\ClientsCrm\Unit1.pas=D:\projects\ClientsCrm\UfrHandbook.pas
+ 1899.12.30 00:00:00.000.236,D:\projects\ClientsCrm\Unit1.dfm=D:\projects\ClientsCrm\UfrEditUser.dfm
1899.12.30 00:00:00.000.228,D:\projects\ClientsCrm\Unit1.dfm=D:\projects\ClientsCrm\UfrAnaliticDep.dfm
- 1899.12.30 00:00:00.000.970,D:\projects\ClientsCrm\Unit1.dfm=D:\projects\ClientsCrm\UfrClientAnaliticR.dfm
+ 1899.12.30 00:00:00.000.072,D:\projects\ClientsCrm\Unit1.dfm=D:\projects\ClientsCrm\UfrManageUsers.dfm
+ 1899.12.30 00:00:00.000.696,D:\projects\ClientsCrm\Unit1.dfm=D:\projects\ClientsCrm\UfrEditTask.dfm
+ 1899.12.30 00:00:00.000.507,D:\projects\ClientsCrm\Unit1.dfm=D:\projects\ClientsCrm\MainUnit.dfm
+ 1899.12.30 00:00:00.000.692,D:\projects\ClientsCrm\Unit1.dfm=D:\projects\ClientsCrm\UfrAnaliticUsers.dfm
+ 1899.12.30 00:00:00.000.876,D:\projects\ClientsCrm\UfrReportClientR.pas=D:\projects\ClientsCrm\Unit1.pas
+ 1899.12.30 00:00:00.000.332,D:\projects\ClientsCrm\UfrClientAnaliic.dfm=D:\projects\ClientsCrm\UfrClientAnalitic.dfm
+ 1899.12.30 00:00:00.000.685,=C:\Users\admin\Documents\Embarcadero\Studio\Projects\Unit1.pas
+ 1899.12.30 00:00:00.000.610,C:\Users\admin\Documents\Embarcadero\Studio\Projects\Unit1.pas=D:\projects\ClientsCrm\LoginUnit.pas
+ 1899.12.30 00:00:00.000.359,D:\projects\ClientsCrm\UfrAbout.pas=D:\projects\ClientsCrm\Unit1.pas
+ 1899.12.30 00:00:00.000.848,D:\projects\ClientsCrm\UfrAnaliticWork.pas=D:\projects\ClientsCrm\Unit1.pas
+ 1899.12.30 00:00:00.000.539,C:\Users\admin\Documents\Embarcadero\Studio\Projects\Project1.dproj=D:\projects\ClientsCrm\ClientsCrm.dproj
+ 1899.12.30 00:00:00.000.250,=D:\projects\ClientsCrm\UfrSett.pas
+ 1899.12.30 00:00:00.000.070,=D:\projects\ClientsCrm\Unit1.pas
+ 1899.12.30 00:00:00.000.848,D:\projects\ClientsCrm\UfrAnaliticWork.dfm=D:\projects\ClientsCrm\Unit1.dfm
+ 1899.12.30 00:00:00.000.791,D:\projects\ClientsCrm\Unit1.pas=D:\projects\ClientsCrm\TaskUnit.pas
+ 1899.12.30 00:00:00.000.257,D:\projects\ClientsCrm\UfrClientWorkReport.pas=D:\projects\ClientsCrm\Unit1.pas
1899.12.30 00:00:00.000.710,=D:\projects\ClientsCrm\UfrLogin.pas
+ 1899.12.30 00:00:00.000.253,=D:\projects\ClientsCrm\Unit1.pas
+ 1899.12.30 00:00:00.000.696,=D:\projects\ClientsCrm\Unit1.pas
+ 1899.12.30 00:00:00.000.236,D:\projects\ClientsCrm\Unit1.pas=D:\projects\ClientsCrm\UfrEditUser.pas
+ 1899.12.30 00:00:00.000.228,D:\projects\ClientsCrm\Unit1.pas=D:\projects\ClientsCrm\UfrAnaliticDep.pas
+ 1899.12.30 00:00:00.000.024,D:\projects\ClientsCrm\UfrAnaliticDepR.dfm=D:\projects\ClientsCrm\Unit1.dfm
+ 1899.12.30 00:00:00.000.024,D:\projects\ClientsCrm\UfrAnaliticDepR.pas=D:\projects\ClientsCrm\Unit1.pas
+ 1899.12.30 00:00:00.000.359,D:\projects\ClientsCrm\UfrAbout.dfm=D:\projects\ClientsCrm\Unit1.dfm
+ 1899.12.30 00:00:00.000.191,D:\projects\ClientsCrm\UfrClientWorkReportR.pas=D:\projects\ClientsCrm\Unit1.pas
+ 1899.12.30 00:00:00.000.431,D:\projects\ClientsCrm\UfrReportClient.pas=D:\projects\ClientsCrm\Unit1.pas
1899.12.30 00:00:00.000.257,D:\projects\ClientsCrm\UfrClientWorkReport.dfm=D:\projects\ClientsCrm\Unit1.dfm
1899.12.30 00:00:00.000.876,D:\projects\ClientsCrm\UfrReportClientR.dfm=D:\projects\ClientsCrm\Unit1.dfm
- 1899.12.30 00:00:00.000.696,D:\projects\ClientsCrm\Unit1.dfm=D:\projects\ClientsCrm\UfrEditTask.dfm
- 1899.12.30 00:00:00.000.236,D:\projects\ClientsCrm\Unit1.dfm=D:\projects\ClientsCrm\UfrEditUser.dfm
- 2018.07.11 10:44:57.408,=D:\projects\ClientsCrm\Unit1.pas
- 2018.07.11 10:46:23.024,D:\projects\ClientsCrm\UfrAnaliticDepR.pas=D:\projects\ClientsCrm\Unit1.pas
- 2018.07.11 10:46:23.024,D:\projects\ClientsCrm\UfrAnaliticDepR.dfm=D:\projects\ClientsCrm\Unit1.dfm
+ 1899.12.30 00:00:00.000.332,D:\projects\ClientsCrm\UfrClientAnaliic.pas=D:\projects\ClientsCrm\UfrClientAnalitic.pas
+ 1899.12.30 00:00:00.000.428,D:\projects\ClientsCrm\LoginUnit.pas=
+ 1899.12.30 00:00:00.000.072,D:\projects\ClientsCrm\Unit1.pas=D:\projects\ClientsCrm\UfrManageUsers.pas
+ 1899.12.30 00:00:00.000.692,D:\projects\ClientsCrm\Unit1.pas=D:\projects\ClientsCrm\UfrAnaliticUsers.pas
+ 1899.12.30 00:00:00.000.820,D:\projects\ClientsCrm\Unit1.pas=D:\projects\ClientsCrm\UfrClientAnaliic.pas
+ 1899.12.30 00:00:00.000.960,=D:\projects\ClientsCrm\Unit1.pas
+ 1899.12.30 00:00:00.000.102,D:\projects\ClientsCrm\Unit1.pas=D:\projects\ClientsCrm\UtilsUnit.pas
+ 1899.12.30 00:00:00.000.502,=D:\projects\ClientsCrm\Unit1.pas
+ 1899.12.30 00:00:00.000.871,=D:\projects\ClientsCrm\Unit1.pas
+ 1899.12.30 00:00:00.000.963,=D:\projects\ClientsCrm\Unit1.pas
+ 1899.12.30 00:00:00.000.408,=D:\projects\ClientsCrm\Unit1.pas
+ 1899.12.30 00:00:00.000.737,=D:\projects\ClientsCrm\Unit1.pas
+ 1899.12.30 00:00:00.000.696,D:\projects\ClientsCrm\Unit1.pas=D:\projects\ClientsCrm\UfrEditTask.pas
+ 1899.12.30 00:00:00.000.687,D:\projects\ClientsCrm\Unit1.pas=D:\projects\ClientsCrm\UfrHandbook.pas
+ 1899.12.30 00:00:00.000.970,D:\projects\ClientsCrm\Unit1.pas=D:\projects\ClientsCrm\UfrClientAnaliticR.pas
+ 1899.12.30 00:00:00.000.507,D:\projects\ClientsCrm\Unit1.pas=D:\projects\ClientsCrm\MainUnit.pas
+ 1899.12.30 00:00:00.000.361,=D:\projects\ClientsCrm\Unit1.pas
+ 1899.12.30 00:00:00.000.798,=D:\projects\ClientsCrm\Unit1.pas
+ 1899.12.30 00:00:00.000.962,=D:\projects\ClientsCrm\Unit1.pas
+ 1899.12.30 00:00:00.000.062,=D:\projects\ClientsCrm\Unit1.pas
diff --git a/ClientsCrm.identcache b/ClientsCrm.identcache
index ee138b2..f4c2b08 100644
Binary files a/ClientsCrm.identcache and b/ClientsCrm.identcache differ
diff --git a/ClientsCrm.stat b/ClientsCrm.stat
index 6a1b9bd..5c6a461 100644
--- a/ClientsCrm.stat
+++ b/ClientsCrm.stat
@@ -1,10 +1,10 @@
[Stats]
-EditorSecs=11300
-DesignerSecs=1126
-InspectorSecs=1385
-CompileSecs=227925
-OtherSecs=1169
+EditorSecs=17193
+DesignerSecs=1510
+InspectorSecs=1794
+CompileSecs=330956
+OtherSecs=1504
StartTime=28.06.2018 13:46:55
RealKeys=0
EffectiveKeys=0
-DebugSecs=3379
+DebugSecs=5533
diff --git a/DataUnit.pas b/DataUnit.pas
index a938d2f..5339bc5 100644
--- a/DataUnit.pas
+++ b/DataUnit.pas
@@ -43,6 +43,23 @@ Tdm = class(TDataModule)
'LEFT JOIN department ON (department.`id`=users.`id_dep`)';
taskSqlGrop:String='GROUP BY tasks.id';
+ userWithFiredSql:string='select users.*,'+chr(13)+
+ 'department.`name` as `dname`'+chr(13) +
+ ', user_roles.`name` as `role`'+chr(13) +
+ 'from users'+chr(13)+
+ 'LEFT JOIN department ON (department.`id`=users.`id_dep`)'+chr(13)+
+ 'LEFT JOIN user_roles ON (user_roles.`id`=users.`id_role`)'+chr(13) +
+ 'GROUP BY users.id';
+
+ userWithoutFiredSql:string='select users.*,'+chr(13)+
+ 'department.`name` as `dname`'+chr(13) +
+ ', user_roles.`name` as `role`'+chr(13) +
+ 'from users'+chr(13)+
+ 'LEFT JOIN department ON (department.`id`=users.`id_dep`)'+chr(13)+
+ 'LEFT JOIN user_roles ON (user_roles.`id`=users.`id_role`)'+chr(13) +
+ 'WHERE users.`fired`<>1 '+chr(13)+
+ 'GROUP BY users.id';
+
var
dm: Tdm;
ini:TIniFile;
diff --git a/MainUnit.dfm b/MainUnit.dfm
index e6a6e86..9ff5ed1 100644
--- a/MainUnit.dfm
+++ b/MainUnit.dfm
@@ -3,8 +3,8 @@ object frMain: TfrMain
Left = 0
Top = 0
Caption = 'ClientsCRM'
- ClientHeight = 482
- ClientWidth = 735
+ ClientHeight = 611
+ ClientWidth = 1005
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
@@ -21,7 +21,7 @@ object frMain: TfrMain
object ToolBar1: TToolBar
Left = 0
Top = 0
- Width = 735
+ Width = 1005
Height = 33
ButtonHeight = 30
ButtonWidth = 31
@@ -109,13 +109,88 @@ object frMain: TfrMain
ImageIndex = 6
Style = tbsDropDown
end
+ object ToolButton8: TToolButton
+ Left = 279
+ Top = 0
+ Width = 8
+ Caption = 'ToolButton8'
+ ImageIndex = 7
+ Style = tbsSeparator
+ end
+ object ToolButton9: TToolButton
+ Left = 287
+ Top = 0
+ Caption = 'ToolButton9'
+ ImageIndex = 7
+ OnClick = ToolButton9Click
+ end
+ object ToolButton10: TToolButton
+ Left = 318
+ Top = 0
+ Width = 27
+ Caption = 'ToolButton10'
+ ImageIndex = 8
+ Style = tbsSeparator
+ end
+ object Panel1: TPanel
+ Left = 345
+ Top = 0
+ Width = 380
+ Height = 30
+ BevelOuter = bvNone
+ Ctl3D = False
+ ParentBackground = False
+ ParentCtl3D = False
+ TabOrder = 0
+ object Label1: TLabel
+ Left = 140
+ Top = 8
+ Width = 12
+ Height = 13
+ Caption = #1087#1086
+ end
+ object Label2: TLabel
+ Left = 16
+ Top = 8
+ Width = 5
+ Height = 13
+ Caption = #1089
+ end
+ object dtFrom: TDateTimePicker
+ Left = 27
+ Top = 6
+ Width = 107
+ Height = 21
+ Date = 43717.505210856490000000
+ Time = 43717.505210856490000000
+ TabOrder = 0
+ end
+ object dtTo: TDateTimePicker
+ Left = 158
+ Top = 6
+ Width = 105
+ Height = 21
+ Date = 43717.506663946760000000
+ Time = 43717.506663946760000000
+ TabOrder = 1
+ end
+ object btnFilter: TButton
+ Left = 269
+ Top = 6
+ Width = 100
+ Height = 21
+ Caption = #1054#1090#1092#1080#1083#1100#1090#1088#1086#1074#1072#1090#1100
+ TabOrder = 2
+ OnClick = btnFilterClick
+ end
+ end
end
object DBGridEh1: TDBGridEh
AlignWithMargins = True
Left = 3
Top = 36
- Width = 729
- Height = 443
+ Width = 999
+ Height = 572
Align = alClient
DataSource = dm.taskDS
DynProps = <>
@@ -504,6 +579,45 @@ object frMain: TfrMain
3CBE77FB968823ECA66363CF192564945236E327BE69C02965338492D1643229
D4124E467A1606001880F7CC4F7C5B8093A70031175CAD893FE23FC01FF2EDDB
AF4F531BCA0000000049454E44AE426082}
+ end
+ item
+ ImageFormat = ifPNG
+ ImageName = 'if_19_330401'
+ ImgData = {
+ 89504E470D0A1A0A0000000D4948445200000018000000180806000000E0773D
+ F80000000473424954080808087C086488000000097048597300000B1300000B
+ 1301009A9C18000003D0494441544889B5954D6C546514869F73EE9D99524A53
+ 714147E54721A61D22602536608C12A495D8A026D69068628CD185220B138341
+ 713A1503D1101213DCB1901F7F005D1085528D1313E2A6860211A810051A9A12
+ D010AC5098997B8E8B9671DA4E292E38AB7B73BEF33EEF39F7FBEE07B73964A2
+ 05BFA59B1E36A305F1068C242A82CB45178EBA4B474A1BB392C9D8FF061C4B37
+ 3FA1CE46E02103073BA968AFE1867952D1144AE8D8EF82A4EBDB3B77DE12209B
+ 7E2CACF58ACDC02A8C5E844D1A855F47416106C22CC11591BE88A0473C5A06FE
+ B6220FB8FB5EB956F162FDC77B074AF5B4F4C55B5B835A4FEC0256E1BE251EC4
+ 1E75F1D905CD1D17E16781CF4176E064C5F367C46856935673D6B8F8534CBA9E
+ 3D997EB27A5C404FFDE58F409E35678DA87F93F3FC214156ABEA88A2A1424D88
+ F282C161752E8807AD18F323F39D5E3299E2C38974D3627339A8F85677DD211E
+ 75A21A1FEF1B8D09F3575CA446844D6EFE526A7DE7B6118063EF37FF28C6DC28
+ E10BC3BC7401D346388E4FE2AED677C08CBE3D1BF07C6E14C07241103C1845D1
+ 76943BCF4B6ECE92CC4F0505F835DD34476109E25BC21CAF8E1607884D4D5275
+ 7F2355758B88D5D48EED40355E30CF10B0017466D2E2CB004280C0590EA00576
+ 45817FAF3276F75E3FFF077D5FB6E366E42EF6969D9238CF785E577BE883822E
+ 07F687C3B9796097246E39F5F09E72C555758BD08AC968BC92A0B29AE8EADF65
+ BA204468C0A55BC416143B30649A9AF747129B2EE265DD7954A0B6E54D248C73
+ F5F491F280A13E668A581F26F3879880B8BBAB8A6B545E1DB872AA8BC2C05FE3
+ A5FF93C70D1731752F025CE4BC9BDD4D2176F6A6D5E3E24B00EA6744988ED35F
+ 0404F86155AD16CB4F31383DB1CC386196ABC925BA0D5BA06877111045E13E03
+ 27D4958A6F1D5740870EBE0441D9B4A3BB2F05D7972A9A30E4BB2260EE87FBCE
+ 0A7488D8EB8518DB30C6ECC33B1A5750F8E71283E77A98FA482B5A3179B4FBAB
+ B1C0DB505F0B9C4A6963164A4EF2F174738347D6A52ABB54D86C916751ADBCA5
+ C98007C64A13AF13918C20CFD7B577EC2E760090CA1C38A4AAEB415646262B3C
+ 08961ADE37B1B80D88F05CA4245CA40DE3AB1BE223000075ED07DA30DB2EC2BB
+ B8BDE1628B1D5F0FD65FC6F565F04F55749E982F043E53ECE0E42B535E2E5D37
+ E69FE02027D6357FE0C25AB03FD5F593C0E48B5C4842CDEF15257038971FBC76
+ 215651F1B41B6FA9729FE33BAA06AA5F9BB179CFE04D0137E2D8BA658DC04615
+ 7D7CD8733F682F98999154D559C3868E20FE5E2AD3F96D399D092FFD9E74539D
+ 1B2D380D269E54541D2E201C1589F6D7677EF865228DDB1AFF02E7D4A80E1803
+ A7E90000000049454E44AE426082}
end>
Left = 464
Top = 368
@@ -635,10 +749,15 @@ object frMain: TfrMain
end
object N6: TMenuItem
Caption = #1040#1085#1072#1083#1080#1090#1080#1082#1072' '#1074#1080#1076#1099' '#1088#1072#1073#1086#1090
+ OnClick = N6Click
end
object N7: TMenuItem
Caption = #1044#1086#1083#1103' '#1088#1072#1073#1086#1090#1099' '#1087#1086#1076#1088#1072#1079#1076#1077#1083#1077#1085#1080#1081
OnClick = N7Click
end
+ object N8: TMenuItem
+ Caption = #1040#1085#1072#1083#1080#1079' '#1089#1088#1072#1074#1085#1080#1090#1077#1083#1100#1085#1099#1081
+ OnClick = N8Click
+ end
end
end
diff --git a/MainUnit.pas b/MainUnit.pas
index 8915753..3f22549 100644
--- a/MainUnit.pas
+++ b/MainUnit.pas
@@ -9,7 +9,8 @@ interface
DBGridEhGrouping, ToolCtrlsEh, DBGridEhToolCtrls, DynVarsEh, EhLibVCL,
GridsEh, DBAxisGridsEh, DBGridEh, DataUnit, UfrEditTask, TaskUnit, Data.DB,
MemDS, DBAccess, MyAccess, StrUtils, DbUtilsEh, UfrReportClient, UfrClientWorkReport,
- UfrClientAnalitic, UfrAnaliticDep;
+ UfrClientAnalitic, UfrAnaliticDep, UfrAnaliticWork, UfrAnaliticUsers, UfrAbout,
+ Vcl.StdCtrls, Vcl.ExtCtrls, DateUtils;
type
TfrMain = class(TForm)
@@ -42,6 +43,16 @@ TfrMain = class(TForm)
F1: TMenuItem;
N6: TMenuItem;
N7: TMenuItem;
+ N8: TMenuItem;
+ ToolButton8: TToolButton;
+ ToolButton9: TToolButton;
+ ToolButton10: TToolButton;
+ Panel1: TPanel;
+ dtFrom: TDateTimePicker;
+ Label1: TLabel;
+ dtTo: TDateTimePicker;
+ Label2: TLabel;
+ btnFilter: TButton;
procedure CreateParams(var Params: TCreateParams); override;
procedure btnAdminClick(Sender: TObject);
@@ -64,6 +75,10 @@ TfrMain = class(TForm)
procedure N2Click(Sender: TObject);
procedure F1Click(Sender: TObject);
procedure N7Click(Sender: TObject);
+ procedure N6Click(Sender: TObject);
+ procedure N8Click(Sender: TObject);
+ procedure ToolButton9Click(Sender: TObject);
+ procedure btnFilterClick(Sender: TObject);
private
{ Private declarations }
function getTaskSql:string;
@@ -79,6 +94,7 @@ TfrMain = class(TForm)
var
frMain: TfrMain;
+ dtFS, dtTS:string;
implementation
@@ -86,6 +102,11 @@ implementation
uses UfrManageUsers;
+function qs(s:string):string;
+begin
+ Result:=chr(39)+s+chr(39);
+end;
+
function TfrMain.getTaskSql:string;
begin
if(CurrentUser.Role<>urAdmin) then
@@ -125,6 +146,14 @@ procedure TfrMain.N2Click(Sender: TObject);
frReport.ShowModal;
end;
+procedure TfrMain.N6Click(Sender: TObject);
+var frRep:TfrAnaliticWork;
+begin
+frRep:=TfrAnaliticWork.Create(Application);
+frRep.ShowModal;
+
+end;
+
procedure TfrMain.N7Click(Sender: TObject);
var frRep:TfrAnaliticDep;
begin
@@ -132,6 +161,13 @@ procedure TfrMain.N7Click(Sender: TObject);
frRep.ShowModal;
end;
+procedure TfrMain.N8Click(Sender: TObject);
+var frRep:TfrAnaliticUsers;
+begin
+frRep:=TfrAnaliticUsers.Create(Application);
+frRep.ShowModal;
+end;
+
procedure TfrMain.CreateParams(var Params: TCreateParams);
begin
inherited;
@@ -237,6 +273,7 @@ procedure TfrMain.FormCreate(Sender: TObject);
var
RestoreParams:TDBGridEhRestoreParams;
begin
+dtFrom.Date:=IncDay(now, -6);
RestoreParams:=[grpColWidthsEh];
DBGridEh1.RestoreGridLayoutIni(getmys+settFolder+'\'+'gridMain.ini','main', RestoreParams);
n3.Visible:=False;
@@ -249,12 +286,22 @@ procedure TfrMain.FormShow(Sender: TObject);
n1.Enabled:=CurrentUser.Role=urAdmin;
g1.Enabled:=CurrentUser.Role=urAdmin;
+dtFs:=FormatDateTime('yyyy-mm-dd', dtFrom.Date);
+dtTs:=FormatDateTime('yyyy-mm-dd', dtTo.Date);
+
+//ShowMessage(dtFS+' '+dtTS);
+
if(CurrentUser.Role<>urAdmin) then
-begin
+begin //FormatDateTime
dm.taskQ.SQL.Text:=dataUnit.taskSql
- +' WHERE tasks.`user_id`='+inttostr(CurrentUser.id)
+ +' WHERE (tasks.`user_id`='+inttostr(CurrentUser.id)+')'
+ +' AND (tasks.`dt` BETWEEN '+qs(dtFS)+' AND '+qs(dtTS)+')'
+' '+DataUnit.taskSqlGrop;
//ShowMessage(dm.taskQ.SQL.Text);
+end else begin
+ dm.taskQ.SQL.Text:=dataUnit.taskSql
+ +'WHERE tasks.`dt` BETWEEN '+qs(dtFS)+' AND '+qs(dtTS)
+ +' '+DataUnit.taskSqlGrop;
end;
dm.tasksFilter.SQL.Text:=getTaskSql;
dm.taskQ.Open;
@@ -316,6 +363,14 @@ procedure TfrMain.ToolButton6Click(Sender: TObject);
if(dm.taskQ.Active)then dm.taskQ.Refresh;
end;
+procedure TfrMain.ToolButton9Click(Sender: TObject);
+var
+frAbout:TfrAbout;
+begin
+ frAbout:=TfrAbout.Create(Application);
+ frAbout.ShowModal;
+end;
+
procedure TfrMain.btnAddClick(Sender: TObject);
var frTask:TfrEditTask;
begin
@@ -333,4 +388,33 @@ procedure TfrMain.btnAdminClick(Sender: TObject);
frManageU.ShowModal;
end;
+procedure TfrMain.btnFilterClick(Sender: TObject);
+begin
+Try
+ dtFs:=FormatDateTime('yyyy-mm-dd', dtFrom.Date);
+ dtTs:=FormatDateTime('yyyy-mm-dd', dtTo.Date)
+except
+ on E : Exception do begin
+ ShowMessage('Неверный формат даты и времени');
+ exit;
+ end;
+end;
+
+dm.taskQ.close;
+if(CurrentUser.Role<>urAdmin) then
+begin //FormatDateTime
+ dm.taskQ.SQL.Text:=dataUnit.taskSql
+ +' WHERE (tasks.`user_id`='+inttostr(CurrentUser.id)+')'
+ +' AND (tasks.`dt` BETWEEN '+qs(dtFS)+' AND '+qs(dtTS)+')'
+ +' '+DataUnit.taskSqlGrop;
+ //ShowMessage(dm.taskQ.SQL.Text);
+end else begin
+ dm.taskQ.SQL.Text:=dataUnit.taskSql
+ +'WHERE tasks.`dt` BETWEEN '+qs(dtFS)+' AND '+qs(dtTS)
+ +' '+DataUnit.taskSqlGrop;
+end;
+
+dm.taskQ.Open;
+end;
+
end.
diff --git a/UfrAbout.dfm b/UfrAbout.dfm
new file mode 100644
index 0000000..3b9819f
--- /dev/null
+++ b/UfrAbout.dfm
@@ -0,0 +1,49 @@
+object frAbout: TfrAbout
+ Left = 0
+ Top = 0
+ BorderStyle = bsDialog
+ Caption = #1054' '#1087#1088#1086#1075#1088#1072#1084#1084#1077
+ ClientHeight = 90
+ ClientWidth = 245
+ Color = clBtnFace
+ Font.Charset = DEFAULT_CHARSET
+ Font.Color = clWindowText
+ Font.Height = -12
+ Font.Name = 'Tahoma'
+ Font.Style = []
+ OldCreateOrder = False
+ Position = poDesktopCenter
+ OnClose = FormClose
+ PixelsPerInch = 96
+ TextHeight = 14
+ object Label1: TLabel
+ Left = 8
+ Top = 8
+ Width = 79
+ Height = 19
+ Caption = 'ClientsCRM'
+ Font.Charset = DEFAULT_CHARSET
+ Font.Color = clWindowText
+ Font.Height = -16
+ Font.Name = 'Tahoma'
+ Font.Style = []
+ ParentFont = False
+ end
+ object Label2: TLabel
+ Left = 8
+ Top = 33
+ Width = 70
+ Height = 14
+ Caption = #1042#1077#1088#1089#1080#1103' 1.02'
+ end
+ object Button1: TButton
+ Left = 162
+ Top = 56
+ Width = 75
+ Height = 25
+ Caption = 'OK'
+ Default = True
+ TabOrder = 0
+ OnClick = Button1Click
+ end
+end
diff --git a/UfrAbout.pas b/UfrAbout.pas
new file mode 100644
index 0000000..adf6730
--- /dev/null
+++ b/UfrAbout.pas
@@ -0,0 +1,39 @@
+unit UfrAbout;
+
+interface
+
+uses
+ Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
+ Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
+
+type
+ TfrAbout = class(TForm)
+ Label1: TLabel;
+ Label2: TLabel;
+ Button1: TButton;
+ procedure Button1Click(Sender: TObject);
+ procedure FormClose(Sender: TObject; var Action: TCloseAction);
+ private
+ { Private declarations }
+ public
+ { Public declarations }
+ end;
+
+var
+ frAbout: TfrAbout;
+
+implementation
+
+{$R *.dfm}
+
+procedure TfrAbout.Button1Click(Sender: TObject);
+begin
+close;
+end;
+
+procedure TfrAbout.FormClose(Sender: TObject; var Action: TCloseAction);
+begin
+Action:=caFree;
+end;
+
+end.
diff --git a/UfrAnaliticDepR.dfm b/UfrAnaliticDepR.dfm
index 2ed4f90..4e46e71 100644
--- a/UfrAnaliticDepR.dfm
+++ b/UfrAnaliticDepR.dfm
@@ -26,44 +26,56 @@ object frAnaliticDepR: TfrAnaliticDepR
Align = alClient
Columns = <
item
- AutoSize = True
Caption = #1050#1083#1080#1077#1085#1090
+ Width = 200
end
item
- AutoSize = True
Caption = #1048#1090#1086#1075#1086' '#1087#1086' '#1082#1083#1080#1077#1085#1090#1091
+ Width = 121
end
item
- AutoSize = True
Caption = #1057#1091#1084#1084#1072' '#1074#1088#1077#1084#1077#1085#1080' '#1087#1086#1076#1088#1072#1079#1076#1077#1083#1077#1085#1080#1103' '#1041#1091#1093#1075#1072#1083#1090#1077#1088
- MinWidth = 100
+ Width = 300
end
item
- AutoSize = True
Caption = #1057#1091#1084#1084#1072' '#1074#1088#1077#1084#1077#1085#1080' '#1087#1086#1076#1088#1072#1079#1076#1072#1083#1077#1085#1080#1103' '#1052#1083#1072#1076#1096#1080#1081' '#1087#1077#1088#1089#1086#1085#1072#1083
+ Width = 360
end
item
- AutoSize = True
Caption = #1044#1086#1083#1103' '#1084#1083#1072#1076#1096#1077#1075#1086' '#1087#1077#1088#1089#1086#1085#1072#1083#1072' '#1074' '#1088#1072#1073#1086#1090#1077' '#1089' '#1050#1083#1080#1077#1085#1090#1086#1074',%'
+ Width = 360
end
item
- AutoSize = True
Caption = #1044#1086#1083#1103' '#1073#1091#1093#1075#1072#1083#1090#1077#1088#1086#1074' '#1074' '#1088#1072#1073#1086#1090#1077' '#1089' '#1050#1083#1080#1077#1085#1090#1086#1074',%'
+ Width = 290
end>
GridLines = True
ReadOnly = True
RowSelect = True
+ PopupMenu = PopupMenu1
TabOrder = 0
ViewStyle = vsReport
OnColumnClick = lvColumnClick
OnCompare = lvCompare
OnCustomDrawItem = lvCustomDrawItem
- ExplicitLeft = -2
- ExplicitTop = -2
end
object q: TMyQuery
Connection = dm.cn
Left = 664
Top = 408
end
+ object PopupMenu1: TPopupMenu
+ Left = 120
+ Top = 88
+ object N1: TMenuItem
+ Caption = #1069#1082#1089#1087#1086#1088#1090' '#1074' '#1101#1082#1089#1077#1083#1100
+ OnClick = N1Click
+ end
+ end
+ object SaveDialog1: TSaveDialog
+ DefaultExt = 'xls'
+ Filter = #1069#1082#1089#1077#1083#1100' '#1092#1072#1081#1083'|*.xls'
+ Left = 200
+ Top = 104
+ end
end
diff --git a/UfrAnaliticDepR.pas b/UfrAnaliticDepR.pas
index 575b459..2b2dbc5 100644
--- a/UfrAnaliticDepR.pas
+++ b/UfrAnaliticDepR.pas
@@ -5,12 +5,15 @@ interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Data.DB, MemDS, DBAccess, MyAccess, DataUnit,
- Vcl.ComCtrls, UtilsUnit;
+ Vcl.ComCtrls, UtilsUnit, Vcl.Menus;
type
TfrAnaliticDepR = class(TForm)
q: TMyQuery;
lv: TListView;
+ PopupMenu1: TPopupMenu;
+ N1: TMenuItem;
+ SaveDialog1: TSaveDialog;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure lvColumnClick(Sender: TObject; Column: TListColumn);
@@ -18,6 +21,7 @@ TfrAnaliticDepR = class(TForm)
var Compare: Integer);
procedure lvCustomDrawItem(Sender: TCustomListView; Item: TListItem;
State: TCustomDrawState; var DefaultDraw: Boolean);
+ procedure N1Click(Sender: TObject);
private
{ Private declarations }
procedure createSqlReport;
@@ -209,7 +213,15 @@ procedure TfrAnaliticDepR.lvCustomDrawItem(Sender: TCustomListView;
begin
Sender.Canvas.Font.Style:= Sender.Canvas.Font.Style + [fsBold];
Sender.Canvas.Brush.Color:=cl3dLight;
+end else if item.Index mod 2=0 then Sender.Canvas.Brush.Color:=$00EFEFEF;
+
end;
+
+procedure TfrAnaliticDepR.N1Click(Sender: TObject);
+begin
+if not SaveDialog1.Execute(handle) then exit;
+
+UtilsUnit.saveListViewToExel(lv, saveDialog1.FileName);
end;
end.
diff --git a/UfrAnaliticUsers.dfm b/UfrAnaliticUsers.dfm
new file mode 100644
index 0000000..99561f5
--- /dev/null
+++ b/UfrAnaliticUsers.dfm
@@ -0,0 +1,126 @@
+object frAnaliticUsers: TfrAnaliticUsers
+ Left = 0
+ Top = 0
+ BorderStyle = bsDialog
+ Caption = #1057#1088#1072#1074#1085#1080#1090#1077#1083#1100#1085#1099#1081' '#1072#1085#1072#1083#1080#1079
+ ClientHeight = 290
+ ClientWidth = 561
+ Color = clBtnFace
+ Font.Charset = DEFAULT_CHARSET
+ Font.Color = clWindowText
+ Font.Height = -12
+ Font.Name = 'Tahoma'
+ Font.Style = []
+ OldCreateOrder = False
+ Position = poDesktopCenter
+ OnClose = FormClose
+ OnCreate = FormCreate
+ PixelsPerInch = 96
+ TextHeight = 14
+ object Label5: TLabel
+ Left = 8
+ Top = 69
+ Width = 66
+ Height = 14
+ Caption = #1042#1080#1076#1099' '#1088#1072#1073#1086#1090
+ end
+ object Label1: TLabel
+ Left = 8
+ Top = 8
+ Width = 43
+ Height = 14
+ Caption = #1055#1077#1088#1080#1086#1076
+ end
+ object Label2: TLabel
+ Left = 288
+ Top = 69
+ Width = 79
+ Height = 14
+ Caption = #1055#1086#1083#1100#1079#1086#1074#1072#1090#1077#1083#1080
+ end
+ object lbWorks: TCheckListBox
+ Left = 8
+ Top = 89
+ Width = 265
+ Height = 129
+ ItemHeight = 14
+ TabOrder = 0
+ end
+ object Button4: TButton
+ Left = 168
+ Top = 224
+ Width = 105
+ Height = 18
+ Caption = #1057#1085#1103#1090#1100' '#1074#1089#1077
+ TabOrder = 1
+ OnClick = Button4Click
+ end
+ object Button3: TButton
+ Left = 57
+ Top = 224
+ Width = 105
+ Height = 18
+ Caption = #1054#1090#1084#1077#1090#1080#1090#1100' '#1074#1089#1077
+ TabOrder = 2
+ OnClick = Button3Click
+ end
+ object dt2: TDateTimePicker
+ Left = 152
+ Top = 28
+ Width = 121
+ Height = 22
+ Date = 43291.414696736110000000
+ Time = 43291.414696736110000000
+ TabOrder = 3
+ end
+ object dt1: TDateTimePicker
+ Left = 8
+ Top = 28
+ Width = 121
+ Height = 22
+ Date = 43291.414696736110000000
+ Time = 43291.414696736110000000
+ TabOrder = 4
+ end
+ object lbUsers: TCheckListBox
+ Left = 288
+ Top = 89
+ Width = 265
+ Height = 129
+ ItemHeight = 14
+ TabOrder = 5
+ end
+ object Button1: TButton
+ Left = 448
+ Top = 226
+ Width = 105
+ Height = 18
+ Caption = #1057#1085#1103#1090#1100' '#1074#1089#1077
+ TabOrder = 6
+ OnClick = Button1Click
+ end
+ object Button2: TButton
+ Left = 337
+ Top = 226
+ Width = 105
+ Height = 18
+ Caption = #1054#1090#1084#1077#1090#1080#1090#1100' '#1074#1089#1077
+ TabOrder = 7
+ OnClick = Button2Click
+ end
+ object Button5: TButton
+ Left = 478
+ Top = 257
+ Width = 75
+ Height = 25
+ Caption = 'OK'
+ Default = True
+ TabOrder = 8
+ OnClick = Button5Click
+ end
+ object q: TMyQuery
+ Connection = dm.cn
+ Left = 360
+ Top = 24
+ end
+end
diff --git a/UfrAnaliticUsers.pas b/UfrAnaliticUsers.pas
new file mode 100644
index 0000000..d2f237d
--- /dev/null
+++ b/UfrAnaliticUsers.pas
@@ -0,0 +1,137 @@
+unit UfrAnaliticUsers;
+
+interface
+
+uses
+ Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
+ Vcl.Controls, Vcl.Forms, Vcl.Dialogs, UtilsUnit, Vcl.ComCtrls, Vcl.StdCtrls,
+ Vcl.CheckLst, dataunit, Data.DB, MemDS, DBAccess, MyAccess, UfrAnaliticUsersR;
+
+type
+ TfrAnaliticUsers = class(TForm)
+ lbWorks: TCheckListBox;
+ Button4: TButton;
+ Button3: TButton;
+ Label5: TLabel;
+ Label1: TLabel;
+ dt2: TDateTimePicker;
+ dt1: TDateTimePicker;
+ lbUsers: TCheckListBox;
+ Label2: TLabel;
+ Button1: TButton;
+ Button2: TButton;
+ Button5: TButton;
+ q: TMyQuery;
+ procedure FormClose(Sender: TObject; var Action: TCloseAction);
+ procedure FormCreate(Sender: TObject);
+ procedure Button4Click(Sender: TObject);
+ procedure Button1Click(Sender: TObject);
+ procedure Button2Click(Sender: TObject);
+ procedure Button3Click(Sender: TObject);
+ procedure Button5Click(Sender: TObject);
+ private
+ { Private declarations }
+ public
+ { Public declarations }
+ users, works:TLockupValue;
+ end;
+
+var
+ frAnaliticUsers: TfrAnaliticUsers;
+ i:integer;
+
+implementation
+
+{$R *.dfm}
+
+procedure TfrAnaliticUsers.Button1Click(Sender: TObject);
+begin
+lbUsers.CheckAll(cbUnChecked);
+end;
+
+procedure TfrAnaliticUsers.Button2Click(Sender: TObject);
+begin
+lbUsers.CheckAll(cbChecked);
+end;
+
+procedure TfrAnaliticUsers.Button3Click(Sender: TObject);
+begin
+lbWorks.CheckAll(cbChecked);
+end;
+
+procedure TfrAnaliticUsers.Button4Click(Sender: TObject);
+begin
+lbWorks.CheckAll(cbUnChecked);
+end;
+
+procedure TfrAnaliticUsers.Button5Click(Sender: TObject);
+var frRep:TfrAnaliticUsersR;
+ selClients, selWorks:TLockupValue;
+begin
+selWorks:=TLockupValue.Create;
+selClients:=TLockupValue.Create;
+
+for I := 0 to lbUsers.Items.Count-1 do
+ if(lbUsers.Checked[i]) then selClients.addPair(users.getPair(i));
+
+for I := 0 to lbWorks.Items.Count-1 do
+ if(lbWorks.Checked[i]) then selWorks.addPair(works.getPair(i));
+
+frRep:=TfrAnaliticUsersR.Create(Application);
+frRep.dt1:=dt1.Date;
+frRep.dt2:=dt2.Date;
+
+frRep.works.Assign(selWorks);
+frRep.users.Assign(selClients);
+selWorks.Free;
+selClients.Free;
+frRep.ShowModal;
+end;
+
+procedure TfrAnaliticUsers.FormClose(Sender: TObject; var Action: TCloseAction);
+begin
+Action:=caFree;
+end;
+
+procedure TfrAnaliticUsers.FormCreate(Sender: TObject);
+begin
+works:=TLockupValue.Create;
+users:=TLockupValue.Create;
+
+dt1.date:=now;
+dt2.date:=now;
+
+q.SQL.Text:='select * from works order by name asc';
+q.Open;
+if(q.RecordCount=0)then
+begin
+ ShowMessage('Работ пока нет');
+ exit;
+ Button1.Enabled:=false;
+end;
+
+for I := 0 to q.RecordCount-1 do
+ begin
+ works.addPair(q.FieldByName('id').AsInteger, q.FieldByName('name').AsString);
+ q.Next;
+ end;
+lbWorks.Items.Assign(works.slValues);
+lbWorks.CheckAll(cbChecked);
+q.Close;
+
+
+q.SQL.Text:='select id, user_name from users order by user_name asc';
+q.Open;
+
+for I := 0 to q.RecordCount-1 do
+ begin
+ users.addPair(q.FieldByName('id').AsInteger, q.FieldByName('user_name').AsString);
+ q.Next;
+ end;
+lbUsers.Items.Assign(users.slValues);
+lbUsers.CheckAll(cbChecked);
+
+q.Close
+end;
+
+end.
diff --git a/UfrAnaliticUsersR.dfm b/UfrAnaliticUsersR.dfm
new file mode 100644
index 0000000..7c61e31
--- /dev/null
+++ b/UfrAnaliticUsersR.dfm
@@ -0,0 +1,90 @@
+object frAnaliticUsersR: TfrAnaliticUsersR
+ AlignWithMargins = True
+ Left = 0
+ Top = 0
+ BorderIcons = [biSystemMenu, biMaximize]
+ Caption = #1040#1085#1072#1083#1080#1079' '#1089#1088#1072#1074#1085#1080#1090#1077#1083#1100#1085#1099#1081
+ ClientHeight = 498
+ ClientWidth = 709
+ Color = clBtnFace
+ Font.Charset = DEFAULT_CHARSET
+ Font.Color = clWindowText
+ Font.Height = -12
+ Font.Name = 'Tahoma'
+ Font.Style = []
+ OldCreateOrder = False
+ Position = poDesktopCenter
+ OnClose = FormClose
+ OnCreate = FormCreate
+ OnShow = FormShow
+ PixelsPerInch = 96
+ TextHeight = 14
+ object lv: TListView
+ Left = 0
+ Top = 0
+ Width = 709
+ Height = 498
+ Align = alClient
+ Columns = <
+ item
+ Caption = #1057#1086#1090#1088#1091#1076#1085#1080#1082
+ Width = 200
+ end
+ item
+ Caption = #1042#1080#1076' '#1088#1072#1073#1086#1090
+ Width = 250
+ end
+ item
+ Caption = #1042#1088#1077#1084#1103
+ Width = 60
+ end
+ item
+ Caption = #1057#1088#1077#1076#1085#1077#1077
+ Width = 90
+ end>
+ GridLines = True
+ ReadOnly = True
+ RowSelect = True
+ PopupMenu = PopupMenu1
+ TabOrder = 0
+ ViewStyle = vsReport
+ OnCustomDrawItem = lvCustomDrawItem
+ OnCustomDrawSubItem = lvCustomDrawSubItem
+ end
+ object DBGridEh1: TDBGridEh
+ Left = 24
+ Top = 272
+ Width = 677
+ Height = 209
+ DataSource = MyDataSource1
+ DynProps = <>
+ TabOrder = 1
+ Visible = False
+ object RowDetailData: TRowDetailPanelControlEh
+ end
+ end
+ object q: TMyQuery
+ Connection = dm.cn
+ Left = 304
+ Top = 120
+ end
+ object MyDataSource1: TMyDataSource
+ DataSet = q
+ Left = 504
+ Top = 168
+ end
+ object PopupMenu1: TPopupMenu
+ Left = 120
+ Top = 88
+ object N1: TMenuItem
+ Caption = #1069#1082#1089#1087#1086#1088#1090' '#1074' '#1101#1082#1089#1077#1083#1100
+ OnClick = N1Click
+ end
+ end
+ object SaveDialog1: TSaveDialog
+ DefaultExt = 'xls'
+ Filter = #1069#1082#1089#1077#1083#1100' '#1092#1072#1081#1083'|*.xls'
+ Left = 200
+ Top = 104
+ end
+end
diff --git a/UfrAnaliticUsersR.pas b/UfrAnaliticUsersR.pas
new file mode 100644
index 0000000..ae007d3
--- /dev/null
+++ b/UfrAnaliticUsersR.pas
@@ -0,0 +1,184 @@
+unit UfrAnaliticUsersR;
+
+interface
+
+uses
+ Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
+ Vcl.Controls, Vcl.Forms, Vcl.Dialogs, UtilsUnit, DataUnit, Data.DB, MemDS,
+ DBAccess, MyAccess, Vcl.ComCtrls, DBGridEhGrouping, ToolCtrlsEh,
+ DBGridEhToolCtrls, DynVarsEh, EhLibVCL, GridsEh, DBAxisGridsEh, DBGridEh,
+ Vcl.Menus;
+
+type
+ TfrAnaliticUsersR = class(TForm)
+ lv: TListView;
+ q: TMyQuery;
+ MyDataSource1: TMyDataSource;
+ DBGridEh1: TDBGridEh;
+ PopupMenu1: TPopupMenu;
+ N1: TMenuItem;
+ SaveDialog1: TSaveDialog;
+ procedure FormClose(Sender: TObject; var Action: TCloseAction);
+ procedure FormCreate(Sender: TObject);
+ procedure FormShow(Sender: TObject);
+ procedure lvCustomDrawItem(Sender: TCustomListView; Item: TListItem;
+ State: TCustomDrawState; var DefaultDraw: Boolean);
+ procedure lvCustomDrawSubItem(Sender: TCustomListView; Item: TListItem;
+ SubItem: Integer; State: TCustomDrawState; var DefaultDraw: Boolean);
+ procedure N1Click(Sender: TObject);
+ private
+ { Private declarations }
+ procedure createReportSql;
+ procedure createReport;
+ public
+ { Public declarations }
+ users, works:TLockupValue;
+ dt1, dt2:TDate;
+ end;
+
+const
+ sqlReport:string=
+ 'select tasks.id, tasks.id_client, tasks.id_work, tasks.time_work, tasks.dt, tasks.user_id,'+chr(13)+
+ 'works.`name` as `work`'+chr(13)+
+ 'from tasks'+chr(13)+
+ 'LEFT JOIN works ON (works.`id`=tasks.`id_work`)'+chr(13)+
+ 'WHERE (tasks.dt BETWEEN :dt1 AND :dt2)';
+ sqlGroup:string=' GROUP BY tasks.id';
+ sqlOrder:string=' ORDER BY tasks.`user_id` ASC, tasks.id_work ASC';
+
+var
+ frAnaliticUsersR: TfrAnaliticUsersR;
+
+implementation
+
+{$R *.dfm}
+
+procedure TfrAnaliticUsersR.createReport;
+var i:integer;
+ tm, currWork, nextWork, cntWorks, currUser, nextUser:integer;
+ user, work:string;
+
+function addItem(name, work:string; tm, countWorks:integer):TListItem;
+var item:TListItem;
+begin
+ item:=lv.Items.Add;
+ item.Caption:=name;
+ item.SubItems.Add(work);
+ item.SubItems.Add(inttostr(tm));
+ item.SubItems.Add(FormatFloat('#0.##', tm/countWorks));
+ {r:= tm2-tm;
+ item.SubItems.Add(inttostr(r));
+ item.SubItems.Add(FormatFloat('#0.##', r/60));
+ if(tm<>0) then
+ item.SubItems.Add(FormatFloat('#0.##', (tm2/tm -1)*100 ))
+ else item.SubItems.Add('----'); }
+ Result:=item;
+end;
+
+
+begin
+q.Open;
+if(q.RecordCount=0) then exit;
+
+currWork:=q.FieldByName('id_work').AsInteger;
+currUser:=q.FieldByName('user_id').AsInteger;
+//currWork2:=q.FieldByName('id_client').AsInteger;
+user:=users.getValueFromId(q.FieldByName('user_id').AsInteger);
+work:=q.FieldByName('work').AsString;
+tm:=0;
+cntWorks:=0;
+
+//q.SQL.SaveToFile('d:\sql.txt');
+//ShowMessage(q.sql.Text);
+//ShowMessage('cnt ='+inttostr(q.RecordCount));
+
+for I := 0 to q.RecordCount-1 do
+ begin
+ nextWork:= q.FieldByName('id_work').AsInteger;
+ nextUser:=q.FieldByName('user_id').AsInteger;
+
+ if(currWork=nextWork)and(currUser=nextUser) then
+ begin
+ tm:=tm+q.FieldByName('time_work').AsInteger;
+ inc(cntWorks);
+ //Showmessage('#'+inttostr(q.RecNo));
+ //showmessage(inttostr(tm));
+
+ if(i=q.RecordCount-1) then addItem(user, work, tm, cntWorks);
+ end else
+ begin
+ addItem(user, work, tm, cntWorks);
+
+ tm:=q.FieldByName('time_work').AsInteger;
+ cntWorks:=1;
+ user:=users.getValueFromId(q.FieldByName('user_id').AsInteger);
+ work:=q.FieldByName('work').AsString;
+ currWork:=q.FieldByName('id_work').AsInteger;
+ currUser:=q.FieldByName('user_id').AsInteger;
+
+ if(i=q.RecordCount-1) then addItem(user, work, tm, cntWorks);
+ end;
+
+ q.Next;
+ end;
+
+q.Close;
+end;
+
+procedure TfrAnaliticUsersR.createReportSql;
+begin
+q.SQL.Text:=sqlReport+chr(13)+
+ 'AND (tasks.user_id in('+users.getIds(',')+'))'+chr(13)+
+ 'AND (tasks.id_work in('+works.getIds(',')+'))'
+ +sqlGroup+sqlOrder;
+q.ParamByName('dt1').Value:=toMySqlDate(dt1);
+q.ParamByName('dt2').Value:=toMySqlDate(dt2);
+createReport;
+end;
+
+procedure TfrAnaliticUsersR.FormClose(Sender: TObject;
+ var Action: TCloseAction);
+begin
+Action:=caFree;
+end;
+
+procedure TfrAnaliticUsersR.FormCreate(Sender: TObject);
+begin
+works:=TLockupValue.Create;
+users:=TLockupValue.Create;
+end;
+
+procedure TfrAnaliticUsersR.FormShow(Sender: TObject);
+begin
+createReportSql;
+end;
+
+procedure TfrAnaliticUsersR.lvCustomDrawItem(Sender: TCustomListView;
+ Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
+begin
+{if(Item.Caption='Итого') then
+begin
+ Sender.Canvas.Font.Style:= Sender.Canvas.Font.Style + [fsBold];
+ Sender.Canvas.Brush.Color:=cl3dLight;
+end else }if item.Index mod 2=0 then Sender.Canvas.Brush.Color:=$00EFEFEF;
+end;
+
+procedure TfrAnaliticUsersR.lvCustomDrawSubItem(Sender: TCustomListView;
+ Item: TListItem; SubItem: Integer; State: TCustomDrawState;
+ var DefaultDraw: Boolean);
+begin
+{if(SubItem=Item.SubItems.Count) then
+begin
+ Sender.Canvas.Font.Style:= Sender.Canvas.Font.Style + [fsBold];
+ Sender.Canvas.Brush.Color:=cl3dLight;
+end;}
+end;
+
+procedure TfrAnaliticUsersR.N1Click(Sender: TObject);
+begin
+if not SaveDialog1.Execute(handle) then exit;
+
+UtilsUnit.saveListViewToExel(lv, saveDialog1.FileName);
+end;
+
+end.
diff --git a/UfrAnaliticWork.dfm b/UfrAnaliticWork.dfm
new file mode 100644
index 0000000..f695b94
--- /dev/null
+++ b/UfrAnaliticWork.dfm
@@ -0,0 +1,133 @@
+object frAnaliticWork: TfrAnaliticWork
+ Left = 0
+ Top = 0
+ BorderStyle = bsDialog
+ Caption = #1040#1085#1072#1083#1080#1090#1080#1082#1072' '#1074#1080#1076#1099' '#1088#1072#1073#1086#1090
+ ClientHeight = 406
+ ClientWidth = 280
+ Color = clBtnFace
+ Font.Charset = DEFAULT_CHARSET
+ Font.Color = clWindowText
+ Font.Height = -12
+ Font.Name = 'Tahoma'
+ Font.Style = []
+ OldCreateOrder = False
+ Position = poDesktopCenter
+ OnClose = FormClose
+ OnCreate = FormCreate
+ PixelsPerInch = 96
+ TextHeight = 14
+ object Label2: TLabel
+ Left = 8
+ Top = 64
+ Width = 54
+ Height = 14
+ Caption = #1055#1077#1088#1080#1086#1076' 2'
+ end
+ object Label1: TLabel
+ Left = 8
+ Top = 8
+ Width = 54
+ Height = 14
+ Caption = #1055#1077#1088#1080#1086#1076' 1'
+ end
+ object Label5: TLabel
+ Left = 8
+ Top = 184
+ Width = 66
+ Height = 14
+ Caption = #1042#1080#1076#1099' '#1088#1072#1073#1086#1090
+ end
+ object Label4: TLabel
+ Left = 8
+ Top = 136
+ Width = 41
+ Height = 14
+ Caption = #1050#1083#1080#1077#1085#1090
+ end
+ object dt4: TDateTimePicker
+ Left = 152
+ Top = 84
+ Width = 121
+ Height = 22
+ Date = 43291.414696736110000000
+ Time = 43291.414696736110000000
+ TabOrder = 0
+ end
+ object Button1: TButton
+ Left = 198
+ Top = 379
+ Width = 75
+ Height = 25
+ Caption = 'OK'
+ Default = True
+ TabOrder = 1
+ OnClick = Button1Click
+ end
+ object dt3: TDateTimePicker
+ Left = 8
+ Top = 84
+ Width = 121
+ Height = 22
+ Date = 43291.414696736110000000
+ Time = 43291.414696736110000000
+ TabOrder = 2
+ end
+ object dt2: TDateTimePicker
+ Left = 152
+ Top = 28
+ Width = 121
+ Height = 22
+ Date = 43291.414696736110000000
+ Time = 43291.414696736110000000
+ TabOrder = 3
+ end
+ object dt1: TDateTimePicker
+ Left = 8
+ Top = 28
+ Width = 121
+ Height = 22
+ Date = 43291.414696736110000000
+ Time = 43291.414696736110000000
+ TabOrder = 4
+ end
+ object cbClient: TComboBox
+ Left = 8
+ Top = 156
+ Width = 265
+ Height = 22
+ Style = csDropDownList
+ TabOrder = 5
+ end
+ object lbWorks: TCheckListBox
+ Left = 8
+ Top = 204
+ Width = 265
+ Height = 129
+ ItemHeight = 14
+ TabOrder = 6
+ end
+ object Button3: TButton
+ Left = 57
+ Top = 339
+ Width = 105
+ Height = 18
+ Caption = #1054#1090#1084#1077#1090#1080#1090#1100' '#1074#1089#1077
+ TabOrder = 7
+ OnClick = Button3Click
+ end
+ object Button4: TButton
+ Left = 168
+ Top = 339
+ Width = 105
+ Height = 18
+ Caption = #1057#1085#1103#1090#1100' '#1074#1089#1077
+ TabOrder = 8
+ OnClick = Button4Click
+ end
+ object q: TMyQuery
+ Connection = dm.cn
+ Left = 104
+ Top = 104
+ end
+end
diff --git a/UfrAnaliticWork.pas b/UfrAnaliticWork.pas
new file mode 100644
index 0000000..3289acb
--- /dev/null
+++ b/UfrAnaliticWork.pas
@@ -0,0 +1,164 @@
+unit UfrAnaliticWork;
+
+interface
+
+uses
+ Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
+ Vcl.Controls, Vcl.Forms, Vcl.Dialogs, UfrAnaliticWorkR, Data.DB, MemDS,
+ DBAccess, MyAccess, Vcl.StdCtrls, Vcl.ComCtrls, UtilsUnit, DataUnit,
+ Vcl.CheckLst;
+
+type
+ TfrAnaliticWork = class(TForm)
+ dt4: TDateTimePicker;
+ Button1: TButton;
+ dt3: TDateTimePicker;
+ dt2: TDateTimePicker;
+ dt1: TDateTimePicker;
+ Label2: TLabel;
+ Label1: TLabel;
+ cbClient: TComboBox;
+ q: TMyQuery;
+ Label5: TLabel;
+ Label4: TLabel;
+ lbWorks: TCheckListBox;
+ Button3: TButton;
+ Button4: TButton;
+ procedure FormClose(Sender: TObject; var Action: TCloseAction);
+ procedure FormCreate(Sender: TObject);
+ function validDate:boolean;
+ procedure Button1Click(Sender: TObject);
+ procedure Button4Click(Sender: TObject);
+ procedure Button3Click(Sender: TObject);
+ private
+ { Private declarations }
+ public
+ { Public declarations }
+ end;
+
+var
+ frAnaliticWork: TfrAnaliticWork;
+ clients, works:TLockupValue;
+ i:integer;
+
+implementation
+
+{$R *.dfm}
+
+procedure TfrAnaliticWork.Button1Click(Sender: TObject);
+var frRep:TfrAnaliticWorkR;
+ selClients, selWorks:TLockupValue;
+begin
+if not validDate then exit;
+{if(cbWork1.ItemIndex=cbWork2.ItemIndex)
+then begin
+ ShowMessage('Работы для сравнения должны быть разными');
+ exit;
+ end; }
+
+selWorks:=TLockupValue.Create;
+selClients:=TLockupValue.Create;
+
+{for I := 0 to lbClient.Items.Count-1 do
+ if(lbClient.Checked[i]) then selClients.addPair(clients.getPair(i));}
+selClients.addPair(clients.getIdFromPosValue(cbClient.ItemIndex), cbClient.Text);
+for I := 0 to lbWorks.Items.Count-1 do
+ if(lbWorks.Checked[i]) then selWorks.addPair(works.getPair(i));
+
+
+
+frRep:=TfrAnaliticWorkR.Create(Application);
+frRep.dt1:=dt1.Date;
+frRep.dt2:=dt2.Date;
+frRep.dt3:=dt3.Date;
+frRep.dt4:=dt4.Date;
+frRep.idClient:=clients.getIdFromPosValue(cbClient.ItemIndex);
+frRep.works.Assign(selWorks);
+frRep.clients.Assign(selClients);
+selWorks.Free;
+selClients.Free;
+frRep.ShowModal;
+end;
+
+procedure TfrAnaliticWork.Button3Click(Sender: TObject);
+begin
+lbWorks.CheckAll(cbChecked);
+end;
+
+procedure TfrAnaliticWork.Button4Click(Sender: TObject);
+begin
+lbWorks.CheckAll(cbUnChecked);
+end;
+
+procedure TfrAnaliticWork.FormClose(Sender: TObject; var Action: TCloseAction);
+begin
+Action:=caFree;
+end;
+
+procedure TfrAnaliticWork.FormCreate(Sender: TObject);
+begin
+dt1.date:=now;
+dt2.date:=now;
+dt3.date:=now;
+dt4.date:=now;
+clients:=TLockupValue.Create;
+works:=TLockupValue.Create;
+q.SQL.Text:='select * from clients order by name asc';
+q.Open;
+if(q.RecordCount=0)then
+begin
+ ShowMessage('Клиентов пока нет');
+ exit;
+ Button1.Enabled:=false;
+end;
+
+for I := 0 to q.RecordCount-1 do
+ begin
+ clients.addPair(q.FieldByName('id').AsInteger, q.FieldByName('name').AsString);
+ q.Next;
+ end;
+cbClient.Items.Assign(clients.slValues);
+cbClient.ItemIndex:=0;
+q.Close;
+
+
+q.SQL.Text:='select * from works order by name asc';
+q.Open;
+if(q.RecordCount=0)then
+begin
+ ShowMessage('Работ пока нет');
+ exit;
+ Button1.Enabled:=false;
+end;
+
+for I := 0 to q.RecordCount-1 do
+ begin
+ works.addPair(q.FieldByName('id').AsInteger, q.FieldByName('name').AsString);
+ q.Next;
+ end;
+lbWorks.Items.Assign(works.slValues);
+lbWorks.CheckAll(cbChecked);
+
+q.Close;
+end;
+
+function TfrAnaliticWork.validDate: boolean;
+begin
+result:=true;
+if dt1.Date>dt2.Date then begin
+ ShowMessage('Период 1: дата начала не может быть больше даты конца');
+ result:=false;
+end;
+
+if dt3.Date>dt4.Date then begin
+ ShowMessage('Период 2: дата начала не может быть больше даты конца');
+ result:=false;
+end;
+
+if dt3.Date<=dt2.Date then begin
+ ShowMessage('Период 2 должен следовать за периодом 1');
+ result:=false;
+end;
+end;
+
+end.
diff --git a/UfrAnaliticWorkR.dfm b/UfrAnaliticWorkR.dfm
new file mode 100644
index 0000000..f953e90
--- /dev/null
+++ b/UfrAnaliticWorkR.dfm
@@ -0,0 +1,58 @@
+object frAnaliticWorkR: TfrAnaliticWorkR
+ Left = 0
+ Top = 0
+ BorderIcons = [biSystemMenu, biMaximize]
+ Caption = #1040#1085#1072#1083#1080#1090#1080#1082#1072' '#1074#1080#1076#1099' '#1088#1072#1073#1086#1090
+ ClientHeight = 503
+ ClientWidth = 790
+ Color = clBtnFace
+ Font.Charset = DEFAULT_CHARSET
+ Font.Color = clWindowText
+ Font.Height = -12
+ Font.Name = 'Tahoma'
+ Font.Style = []
+ OldCreateOrder = False
+ Position = poDesktopCenter
+ OnClose = FormClose
+ OnCreate = FormCreate
+ OnShow = FormShow
+ PixelsPerInch = 96
+ TextHeight = 14
+ object lv: TListView
+ AlignWithMargins = True
+ Left = 3
+ Top = 3
+ Width = 784
+ Height = 497
+ Align = alClient
+ Columns = <>
+ GridLines = True
+ ReadOnly = True
+ RowSelect = True
+ PopupMenu = PopupMenu1
+ TabOrder = 0
+ ViewStyle = vsReport
+ OnCustomDrawItem = lvCustomDrawItem
+ ExplicitLeft = 8
+ ExplicitTop = -2
+ end
+ object q: TMyQuery
+ Connection = dm.cn
+ Left = 448
+ Top = 296
+ end
+ object PopupMenu1: TPopupMenu
+ Left = 120
+ Top = 88
+ object N1: TMenuItem
+ Caption = #1069#1082#1089#1087#1086#1088#1090' '#1074' '#1101#1082#1089#1077#1083#1100
+ OnClick = N1Click
+ end
+ end
+ object SaveDialog1: TSaveDialog
+ DefaultExt = 'xls'
+ Filter = #1069#1082#1089#1077#1083#1100' '#1092#1072#1081#1083'|*.xls'
+ Left = 200
+ Top = 104
+ end
+end
diff --git a/UfrAnaliticWorkR.pas b/UfrAnaliticWorkR.pas
new file mode 100644
index 0000000..bc7d062
--- /dev/null
+++ b/UfrAnaliticWorkR.pas
@@ -0,0 +1,236 @@
+unit UfrAnaliticWorkR;
+
+interface
+
+uses
+ Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
+ Vcl.Controls, Vcl.Forms, Vcl.Dialogs, DataUnit, Vcl.ComCtrls, Data.DB, MemDS,
+ DBAccess, MyAccess, UtilsUnit, DBGridEhGrouping, ToolCtrlsEh,
+ DBGridEhToolCtrls, DynVarsEh, EhLibVCL, GridsEh, DBAxisGridsEh, DBGridEh,
+ Vcl.Menus;
+
+type
+ TfrAnaliticWorkR = class(TForm)
+ lv: TListView;
+ q: TMyQuery;
+ PopupMenu1: TPopupMenu;
+ N1: TMenuItem;
+ SaveDialog1: TSaveDialog;
+ procedure FormClose(Sender: TObject; var Action: TCloseAction);
+ procedure FormShow(Sender: TObject);
+ procedure FormCreate(Sender: TObject);
+ procedure lvCustomDrawItem(Sender: TCustomListView; Item: TListItem;
+ State: TCustomDrawState; var DefaultDraw: Boolean);
+ procedure N1Click(Sender: TObject);
+ private
+ { Private declarations }
+ procedure createSqlReport;
+ procedure createReport;
+ procedure getReportItemByPair(pair:TLockupPair);
+ public
+ { Public declarations }
+ dt1, dt2, dt3, dt4:TDate;
+ idClient:string;
+ clients, works:TLockupValue;
+ end;
+
+const
+ sqlReport:string=
+ 'select tasks.id, tasks.id_client, tasks.id_work, tasks.time_work, tasks.dt, tasks.user_id,'+chr(13)+
+ 'clients.`name` as `client`,'+chr(13)+
+ 'works.`name` as `work`'+chr(13)+
+ 'from tasks'+chr(13)+
+ 'LEFT JOIN works ON (works.`id`=tasks.`id_work`)'+chr(13)+
+ 'LEFT JOIN clients ON (clients.`id`=tasks.`id_client`)'+chr(13)+
+ 'WHERE (tasks.dt BETWEEN :dt1 AND :dt2)';
+ sqlGroup:string=' GROUP BY tasks.id';
+ sqlOrder:string=' ORDER BY tasks.`id_client` ASC';
+
+var
+ frAnaliticWorkR: TfrAnaliticWorkR;
+
+implementation
+
+{$R *.dfm}
+
+procedure TfrAnaliticWorkR.createReport;
+var i:integer;
+
+function addColumn(caption:string; const width:integer=150):TListColumn;
+begin
+ result:=lv.Columns.Add;
+ Result.Caption:=caption;
+ Result.Width:=width;
+end;
+
+begin
+
+addColumn(clients.getPair(0).value, 220);
+for I := 0 to works.slValues.Count-1 do begin
+ addColumn(works.slValues.Strings[i], 150);
+ addColumn('Расхождение, мин');
+ addColumn('Расхождение, ч');
+ addColumn('В % отношении увел/умен,%', 200);
+end;
+
+q.Open;
+if(q.RecordCount=0) then begin
+ q.Close;
+ exit;
+end;
+
+for I := 0 to clients.count-1 do
+ getReportItemByPair(clients.getPair(i));
+
+q.Close;
+end;
+
+procedure TfrAnaliticWorkR.createSqlReport;
+begin
+q.SQL.Text:=sqlReport+chr(13)+
+ 'AND (clients.id in('+idClient+'))'
+ +sqlGroup+sqlOrder;
+q.ParamByName('dt1').Value:=toMySqlDate(dt1);
+q.ParamByName('dt2').Value:=toMySqlDate(dt4);
+
+createReport;
+end;
+
+procedure TfrAnaliticWorkR.FormClose(Sender: TObject; var Action: TCloseAction);
+begin
+Action:=caFree;
+end;
+
+procedure TfrAnaliticWorkR.FormCreate(Sender: TObject);
+begin
+works:=TLockupValue.Create;
+clients:=TLockupValue.Create;
+end;
+
+procedure TfrAnaliticWorkR.FormShow(Sender: TObject);
+begin
+createSqlReport;
+end;
+
+procedure TfrAnaliticWorkR.getReportItemByPair(pair: TLockupPair);
+var items: array[0..1] of TListItem;
+ i, j, n, posWork, tm1, tm2:integer;
+
+function getNumInterval:integer;
+begin
+ if(q.FieldByName('dt').AsDateTime<=dt2)and(q.FieldByName('dt').AsDateTime>=dt1)
+ then result:=1 else
+ if(q.FieldByName('dt').AsDateTime>=dt3)and(q.FieldByName('dt').AsDateTime<=dt4)
+ then Result:=2 else Result:=-1;
+end;
+
+procedure addSubItems();
+var b5, b4, c5, c4:integer;//названия и эксель
+begin
+b5:=strtoint(items[1].SubItems[posWork]);
+b4:=strtoint(items[0].SubItems[posWork]);
+
+c5:=b5-b4;
+c4:= b4-b5;
+
+items[0].SubItems[posWork+1]:=inttostr(c4);
+items[1].SubItems[posWork+1]:=inttostr(c5);
+
+items[0].SubItems[posWork+2]:=FormatFloat('#0.##', c4/60);
+items[1].SubItems[posWork+2]:=FormatFloat('#0.##', c5/60);
+
+if(b5<>0) then items[0].SubItems[posWork+3]:=FormatFloat('#0.##', (b4/b5 -1)*100)
+ else items[0].SubItems[posWork+3]:='---';
+if(b4<>0) then items[1].SubItems[posWork+3]:=FormatFloat('#0.##', (b5/b4 -1)*100)
+ else items[1].SubItems[posWork+3]:='---'
+end;
+
+begin
+tm1:=0;
+tm2:=0;
+items[0]:=lv.Items.Add;
+items[1]:=lv.Items.Add;
+items[0].Caption:=DateToStr(dt1)+'-'+DateToStr(dt2);
+items[1].Caption:=DateToStr(dt3)+'-'+DateToStr(dt4);
+
+for I := 0 to length(items)-1 do //т.к. 2 периода сравниваем
+ for j := 0 to works.count-1 do begin //+3 т.к. будут 3 пол расчета по формулам
+ items[i].SubItems.Add('0');
+ items[i].SubItems.Add('0');
+ items[i].SubItems.Add('0');
+ items[i].SubItems.Add('0');
+ end;
+
+//теперь для каждой работы нужно посчитать часы и аналитику
+for n := 0 to works.count-1 do begin
+//go go go
+tm1:=0;
+tm2:=0;
+q.First;
+//ShowMessage(IntToStr(q.RecordCount));
+for I := 0 to q.RecordCount-1 do
+begin
+//ShowMessage(q.FieldByName('id_client').AsString);
+ if(pair.id=q.FieldByName('id_client').AsInteger) then
+ begin
+ {posWork:=works.getPositionFromId(q.FieldByName('id_work').AsInteger);
+ //ShowMessage('pos work '+inttostr(posWork));
+ //если мы не находим у этого клиента такую работу, то идем дальше
+ if(posWork=-1) then
+ begin
+ q.Next;
+ Continue;
+ end; }
+ //если работа не та
+ if(q.FieldByName('id_work').AsInteger<>works.getPair(n).id)then
+ begin
+ q.Next;
+ Continue;
+ end;
+ //ShowMessage('interval '+inttostr(getNumInterval));
+ //если работа не влезла ни в один из периодов
+ if(getNumInterval=-1) then
+ begin
+ q.Next;
+ Continue;
+ end;
+
+ //ShowMessage('interval '+inttostr(getNumInterval));
+ //ShowMessage('interval '+inttostr(getNumInterval));
+ posWork:=n*4;
+ //ShowMessage(q.FieldByName('time_work').AsString);
+ if(getNumInterval=1) then
+ begin
+ tm1:=strtoint(items[0].SubItems.Strings[posWork]);
+ tm1:=tm1+q.FieldByName('time_work').AsInteger;
+ items[0].SubItems.Strings[posWork]:=inttostr(tm1);
+ end else
+ begin
+ tm2:=strtoint(items[1].SubItems.Strings[posWork]);
+ tm2:=tm2+q.FieldByName('time_work').AsInteger;
+ items[1].SubItems.Strings[posWork]:=inttostr(tm2);
+ end;
+
+ end;//тут стоит добавить else continue
+ q.Next;
+end;
+
+//FormatFloat('#0.##', r/60)
+addSubItems; //а вот тут считаем аналитику
+end;//end woprks analitic
+end;
+
+procedure TfrAnaliticWorkR.lvCustomDrawItem(Sender: TCustomListView;
+ Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
+begin
+if item.Index mod 2=0 then Sender.Canvas.Brush.Color:=$00EFEFEF;
+end;
+
+procedure TfrAnaliticWorkR.N1Click(Sender: TObject);
+begin
+if not SaveDialog1.Execute(handle) then exit;
+
+UtilsUnit.saveListViewToExel(lv, saveDialog1.FileName);
+end;
+
+end.
diff --git a/UfrClientAnaliticR.dfm b/UfrClientAnaliticR.dfm
index 158076b..0f958f0 100644
--- a/UfrClientAnaliticR.dfm
+++ b/UfrClientAnaliticR.dfm
@@ -45,19 +45,37 @@ object frClientAnaliticR: TfrClientAnaliticR
end
item
Caption = #1042' % '#1086#1090#1085#1086#1096#1077#1085#1080#1080' '#1091#1074#1077#1083#1080#1095#1077#1085#1080'/'#1059#1084#1077#1085#1100#1096#1077#1085#1080#1077',%'
- Width = 90
+ Width = 250
end>
GridLines = True
ReadOnly = True
RowSelect = True
+ PopupMenu = PopupMenu1
TabOrder = 0
ViewStyle = vsReport
OnColumnClick = lvColumnClick
OnCompare = lvCompare
+ OnCustomDrawItem = lvCustomDrawItem
+ ExplicitLeft = 8
+ ExplicitTop = -2
end
object q: TMyQuery
Connection = dm.cn
Left = 592
Top = 376
end
+ object PopupMenu1: TPopupMenu
+ Left = 120
+ Top = 88
+ object N1: TMenuItem
+ Caption = #1069#1082#1089#1087#1086#1088#1090' '#1074' '#1101#1082#1089#1077#1083#1100
+ OnClick = N1Click
+ end
+ end
+ object SaveDialog1: TSaveDialog
+ DefaultExt = 'xls'
+ Filter = #1069#1082#1089#1077#1083#1100' '#1092#1072#1081#1083'|*.xls'
+ Left = 200
+ Top = 104
+ end
end
diff --git a/UfrClientAnaliticR.pas b/UfrClientAnaliticR.pas
index 6e38e9f..79f0bed 100644
--- a/UfrClientAnaliticR.pas
+++ b/UfrClientAnaliticR.pas
@@ -5,17 +5,23 @@ interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Data.DB, MemDS, DBAccess, MyAccess, DataUnit,
- UtilsUnit, Vcl.ComCtrls;
+ UtilsUnit, Vcl.ComCtrls, Vcl.Menus;
type
TfrClientAnaliticR = class(TForm)
q: TMyQuery;
lv: TListView;
+ PopupMenu1: TPopupMenu;
+ N1: TMenuItem;
+ SaveDialog1: TSaveDialog;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure lvCompare(Sender: TObject; Item1, Item2: TListItem; Data: Integer;
var Compare: Integer);
procedure lvColumnClick(Sender: TObject; Column: TListColumn);
+ procedure lvCustomDrawItem(Sender: TCustomListView; Item: TListItem;
+ State: TCustomDrawState; var DefaultDraw: Boolean);
+ procedure N1Click(Sender: TObject);
private
{ Private declarations }
procedure createSqlReport;
@@ -76,6 +82,19 @@ function getNumInterval:integer;
then Result:=2 else Result:=-1;
end;
+procedure getTotalSum;
+var t1, t2, i:integer;
+begin
+t1:=0;
+t2:=0;
+ for I := 0 to lv.Items.Count-1 do
+ begin
+ t1:=t1+strtoint(lv.Items.Item[i].SubItems[0]);
+ t2:=t2+strtoint(lv.Items.Item[i].SubItems[1]);
+ end;
+ addItem('Итого', t1, t2);
+end;
+
begin
q.SQL.Text:=sqlReport+sqlGroup+sqlOrder;
q.ParamByName('dt1').Value:=toMySqlDate(dt1);
@@ -134,7 +153,7 @@ function getNumInterval:integer;
q.Close;
-
+getTotalSum;
end;
procedure TfrClientAnaliticR.FormClose(Sender: TObject;
@@ -185,4 +204,22 @@ procedure TfrClientAnaliticR.lvCompare(Sender: TObject; Item1, Item2: TListItem;
end;
+procedure TfrClientAnaliticR.lvCustomDrawItem(Sender: TCustomListView;
+ Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
+begin
+if(Item.Caption='Итого') then
+begin
+ Sender.Canvas.Font.Style:= Sender.Canvas.Font.Style + [fsBold];
+ Sender.Canvas.Brush.Color:=cl3dLight;
+end else
+if item.Index mod 2=0 then Sender.Canvas.Brush.Color:=$00EFEFEF;
+end;
+
+procedure TfrClientAnaliticR.N1Click(Sender: TObject);
+begin
+if not SaveDialog1.Execute(handle) then exit;
+
+UtilsUnit.saveListViewToExel(lv, saveDialog1.FileName);
+end;
+
end.
diff --git a/UfrClientWorkReport.pas b/UfrClientWorkReport.pas
index 77d029f..d6b3e7c 100644
--- a/UfrClientWorkReport.pas
+++ b/UfrClientWorkReport.pas
@@ -86,7 +86,8 @@ procedure TfrClientWorkReport.Button5Click(Sender: TObject);
frRep.clients.Assign(selClients);
frRep.works.Assign(selWorks);
-
+ selClients.Free;
+ selWorks.Free;
frRep.ShowModal;
end;
diff --git a/UfrClientWorkReportR.dfm b/UfrClientWorkReportR.dfm
index deadaf4..2c5de22 100644
--- a/UfrClientWorkReportR.dfm
+++ b/UfrClientWorkReportR.dfm
@@ -41,15 +41,13 @@ object frClientWorkReportR: TfrClientWorkReportR
GridLines = True
ReadOnly = True
RowSelect = True
+ PopupMenu = PopupMenu1
TabOrder = 1
ViewStyle = vsReport
OnColumnClick = lvColumnClick
OnCompare = lvCompare
+ OnCustomDrawItem = lvCustomDrawItem
OnCustomDrawSubItem = lvCustomDrawSubItem
- ExplicitLeft = 8
- ExplicitTop = 8
- ExplicitWidth = 670
- ExplicitHeight = 225
end
object q: TMyQuery
Connection = dm.cn
@@ -61,4 +59,18 @@ object frClientWorkReportR: TfrClientWorkReportR
Left = 640
Top = 440
end
+ object PopupMenu1: TPopupMenu
+ Left = 120
+ Top = 88
+ object N1: TMenuItem
+ Caption = #1069#1082#1089#1087#1086#1088#1090' '#1074' '#1101#1082#1089#1077#1083#1100
+ OnClick = N1Click
+ end
+ end
+ object SaveDialog1: TSaveDialog
+ DefaultExt = 'xls'
+ Filter = #1069#1082#1089#1077#1083#1100' '#1092#1072#1081#1083'|*.xls'
+ Left = 200
+ Top = 104
+ end
end
diff --git a/UfrClientWorkReportR.pas b/UfrClientWorkReportR.pas
index 1b1ddb6..82ec0b3 100644
--- a/UfrClientWorkReportR.pas
+++ b/UfrClientWorkReportR.pas
@@ -6,7 +6,7 @@ interface
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, DataUnit, DBGridEhGrouping, ToolCtrlsEh,
DBGridEhToolCtrls, DynVarsEh, Vcl.ComCtrls, EhLibVCL, GridsEh, DBAxisGridsEh,
- DBGridEh, Data.DB, DBAccess, MyAccess, MemDS, UtilsUnit;
+ DBGridEh, Data.DB, DBAccess, MyAccess, MemDS, UtilsUnit, Vcl.Menus;
type
TfrClientWorkReportR = class(TForm)
@@ -14,6 +14,9 @@ TfrClientWorkReportR = class(TForm)
ds: TMyDataSource;
DBGridEh1: TDBGridEh;
lv: TListView;
+ PopupMenu1: TPopupMenu;
+ N1: TMenuItem;
+ SaveDialog1: TSaveDialog;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure FormCreate(Sender: TObject);
@@ -22,10 +25,14 @@ TfrClientWorkReportR = class(TForm)
var Compare: Integer);
procedure lvCustomDrawSubItem(Sender: TCustomListView; Item: TListItem;
SubItem: Integer; State: TCustomDrawState; var DefaultDraw: Boolean);
+ procedure lvCustomDrawItem(Sender: TCustomListView; Item: TListItem;
+ State: TCustomDrawState; var DefaultDraw: Boolean);
+ procedure N1Click(Sender: TObject);
private
{ Private declarations }
procedure createSqlReport;
procedure fillReport;
+ procedure getTotalSum;
function getReportItemByPair(pair:TLockupPair):TListItem;
public
@@ -99,7 +106,7 @@ procedure TfrClientWorkReportR.createSqlReport;
procedure TfrClientWorkReportR.fillReport;
var i:integer;
-function addColumn(caption:string; width:integer):TListColumn;
+function addColumn(caption:string; const width:integer=150):TListColumn;
begin
result:=lv.Columns.Add;
Result.Caption:=caption;
@@ -107,9 +114,9 @@ function addColumn(caption:string; width:integer):TListColumn;
end;
begin
-addColumn('Клиенты', 120);
-for I := 0 to works.slValues.Count-1 do addColumn(works.slValues.Strings[i], 100);
-addColumn('Итого', 100);
+addColumn('Клиенты', 200);
+for I := 0 to works.slValues.Count-1 do addColumn(works.slValues.Strings[i]);
+addColumn('Итого');
for I := 0 to clients.count-1 do
getReportItemByPair(clients.getPair(i));
@@ -133,13 +140,14 @@ procedure TfrClientWorkReportR.FormCreate(Sender: TObject);
procedure TfrClientWorkReportR.FormShow(Sender: TObject);
begin
-Caption:='Отчет по клиента-видам работ';
+Caption:='Отчет по клиентам-видам работ';
//ShowMessage('selected clients count='+inttostr(clients.count)+' works count='+IntToStr(works.count));
createSqlReport;
//ShowMessage(q.SQL.Text);
q.Open;
fillReport;
+getTotalSum;
end;
@@ -185,6 +193,25 @@ function TfrClientWorkReportR.getReportItemByPair(pair: TLockupPair): TListItem;
Result:=item;
end;
+procedure TfrClientWorkReportR.getTotalSum;
+var i, j, sum:integer;
+ item:TListItem;
+begin
+item:=lv.Items.Add;
+item.Caption:='Итого';
+//showmessage(inttostr(works.count));
+//showmessage(inttostr(lv.Items.Count));
+ for I := 0 to works.count do begin
+ sum:=0;
+ for j := 0 to lv.Items.Count-2 do begin
+ //ShowMessage(lv.Items[j].Caption);
+ sum:=sum+strtoint(lv.Items[j].SubItems[i]);
+ end;
+ item.SubItems.Add(inttostr(sum));
+ end;
+
+end;
+
procedure TfrClientWorkReportR.lvColumnClick(Sender: TObject;
Column: TListColumn);
begin
@@ -220,6 +247,17 @@ procedure TfrClientWorkReportR.lvCompare(Sender: TObject; Item1,
end;
+procedure TfrClientWorkReportR.lvCustomDrawItem(Sender: TCustomListView;
+ Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
+begin
+if(Item.Caption='Итого') then
+begin
+ Sender.Canvas.Font.Style:= Sender.Canvas.Font.Style + [fsBold];
+ Sender.Canvas.Brush.Color:=cl3dLight;
+end else
+if item.Index mod 2=0 then Sender.Canvas.Brush.Color:=$00EFEFEF;
+end;
+
procedure TfrClientWorkReportR.lvCustomDrawSubItem(Sender: TCustomListView;
Item: TListItem; SubItem: Integer; State: TCustomDrawState;
var DefaultDraw: Boolean);
@@ -231,4 +269,11 @@ procedure TfrClientWorkReportR.lvCustomDrawSubItem(Sender: TCustomListView;
end;
end;
+procedure TfrClientWorkReportR.N1Click(Sender: TObject);
+begin
+if not SaveDialog1.Execute(handle) then exit;
+
+UtilsUnit.saveListViewToExel(lv, saveDialog1.FileName);
+end;
+
end.
diff --git a/UfrEditTask.dfm b/UfrEditTask.dfm
index 517bf2f..8fb2d9c 100644
--- a/UfrEditTask.dfm
+++ b/UfrEditTask.dfm
@@ -5,7 +5,7 @@ object frEditTask: TfrEditTask
BorderStyle = bsSingle
Caption = #1047#1072#1076#1072#1095#1072
ClientHeight = 390
- ClientWidth = 294
+ ClientWidth = 293
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
@@ -71,7 +71,6 @@ object frEditTask: TfrEditTask
Top = 76
Width = 257
Height = 22
- Style = csDropDownList
TabOrder = 1
OnKeyDown = FormKeyDown
end
@@ -80,7 +79,6 @@ object frEditTask: TfrEditTask
Top = 132
Width = 257
Height = 22
- Style = csDropDownList
TabOrder = 2
OnKeyDown = FormKeyDown
end
diff --git a/UfrEditTask.pas b/UfrEditTask.pas
index 4fabb68..e7e3bda 100644
--- a/UfrEditTask.pas
+++ b/UfrEditTask.pas
@@ -116,7 +116,7 @@ procedure TfrEditTask.FormCreate(Sender: TObject);
works:=TLockupValue.Create;
clients:=TLockupValue.Create;
-q.sql.Text:='select * from clients';
+q.sql.Text:='select * from clients order by name asc';
q.Open;
for I := 0 to q.RecordCount-1 do
begin
@@ -126,7 +126,7 @@ procedure TfrEditTask.FormCreate(Sender: TObject);
q.Close;
cbClients.Items.Assign(clients.slValues);
-q.sql.Text:='select * from works';
+q.sql.Text:='select * from works order by name asc';
q.Open;
for I := 0 to q.RecordCount-1 do
begin
diff --git a/UfrEditUser.dfm b/UfrEditUser.dfm
index 7c19144..f6d7664 100644
--- a/UfrEditUser.dfm
+++ b/UfrEditUser.dfm
@@ -3,7 +3,7 @@ object frEditUser: TfrEditUser
Top = 0
BorderStyle = bsDialog
Caption = #1056#1077#1076#1072#1082#1090#1080#1088#1086#1074#1072#1085#1080#1077' '#1087#1086#1083#1100#1079#1086#1074#1072#1090#1077#1083#1103
- ClientHeight = 293
+ ClientHeight = 317
ClientWidth = 316
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
@@ -92,7 +92,7 @@ object frEditUser: TfrEditUser
end
object Button1: TButton
Left = 233
- Top = 264
+ Top = 288
Width = 75
Height = 25
Caption = 'OK'
@@ -102,7 +102,7 @@ object frEditUser: TfrEditUser
end
object Button2: TButton
Left = 152
- Top = 264
+ Top = 288
Width = 75
Height = 25
Cancel = True
@@ -110,6 +110,14 @@ object frEditUser: TfrEditUser
TabOrder = 6
OnClick = Button2Click
end
+ object chFired: TCheckBox
+ Left = 8
+ Top = 256
+ Width = 97
+ Height = 17
+ Caption = #1059#1074#1086#1083#1077#1085
+ TabOrder = 7
+ end
object q: TMyQuery
Connection = dm.cn
Left = 136
diff --git a/UfrEditUser.pas b/UfrEditUser.pas
index bbd02f7..9bfbb61 100644
--- a/UfrEditUser.pas
+++ b/UfrEditUser.pas
@@ -5,7 +5,7 @@ interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Data.DB, MemDS,
- DBAccess, MyAccess,
+ DBAccess, MyAccess, System.Math,
DataUnit;
type
@@ -23,6 +23,7 @@ TfrEditUser = class(TForm)
Button1: TButton;
Button2: TButton;
q: TMyQuery;
+ chFired: TCheckBox;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
@@ -66,13 +67,14 @@ procedure TfrEditUser.Button1Click(Sender: TObject);
if(idUser=-1) then begin
q.SQL.Text:='insert into `users` '+
- '(`id_role`, `login`, `pass`, `user_name`, `id_dep`) '+
+ '(`id_role`, `login`, `pass`, `user_name`, `id_dep`, `fired`) '+
'values('
+qs(idRole)
+', '+qs(edLogin.Text)
+', '+qs(edPass.Text)
+', '+qs(edFio.Text)
+', '+qs(idDep)
+ +', '+inttostr(ifthen(chFired.Checked, 1,0))
+')';
q.Execute;
end else
@@ -82,7 +84,8 @@ procedure TfrEditUser.Button1Click(Sender: TObject);
'`login`='+qs(edLogin.Text)+', '+
'`pass`='+qs(edPass.Text)+', '+
'`id_role`='+qs(idRole)+', '+
- '`id_dep`='+qs(idDep)+
+ '`id_dep`='+qs(idDep)+ ', '+
+ '`fired`='+inttostr(ifthen(chFired.Checked, 1,0)) +
' WHERE `id`='+inttostr(iduser);
q.Execute
end;
@@ -143,6 +146,7 @@ procedure TfrEditUser.FormShow(Sender: TObject);
edPass.Text:=q.FieldByName('pass').AsString;
ComboBox1.ItemIndex:=roles.IndexOf(q.FieldByName('id_role').AsString);
ComboBox2.ItemIndex:=departments.IndexOf(q.FieldByName('id_dep').AsString);
+ chFired.Checked:=q.FieldByName('fired').AsInteger = 1;
q.Close;
end;
end;
diff --git a/UfrLogin.dfm b/UfrLogin.dfm
index 411cf56..729d548 100644
--- a/UfrLogin.dfm
+++ b/UfrLogin.dfm
@@ -19,7 +19,7 @@ object frLogin: TfrLogin
TextHeight = 13
object sSpeedButton1: TsSpeedButton
Left = 278
- Top = 112
+ Top = 117
Width = 33
Height = 25
OnClick = sSpeedButton1Click
@@ -2113,7 +2113,7 @@ object frLogin: TfrLogin
end
object OK: TButton
Left = 317
- Top = 112
+ Top = 117
Width = 75
Height = 25
Caption = 'OK'
diff --git a/UfrLogin.pas b/UfrLogin.pas
index efdb7a2..82e330f 100644
--- a/UfrLogin.pas
+++ b/UfrLogin.pas
@@ -103,6 +103,11 @@ procedure SetAsMainForm(aForm:TForm);
exit;
end else
begin
+ if(q.FieldByName('fired').AsInteger=1) then begin
+ MessageDlg('Вход заблокирован для уволенных сотрудников', mtError, [mbok], 0);
+ q.Close;
+ exit;
+ end;
user:=TUser.Create(q.FieldByName('id').AsInteger, q.FieldByName('login').AsString,
q.FieldByName('pass').AsString, q.FieldByName('user_name').AsString,
q.FieldByName('role').AsString);
diff --git a/UfrManageUsers.dfm b/UfrManageUsers.dfm
index 8a78276..bf5ff20 100644
--- a/UfrManageUsers.dfm
+++ b/UfrManageUsers.dfm
@@ -4,8 +4,8 @@ object frManageUsers: TfrManageUsers
Top = 0
BorderIcons = [biSystemMenu, biMaximize]
Caption = #1059#1087#1088#1072#1074#1083#1077#1085#1080#1077' '#1087#1086#1083#1100#1079#1086#1074#1072#1090#1077#1083#1103#1084#1080
- ClientHeight = 392
- ClientWidth = 660
+ ClientHeight = 396
+ ClientWidth = 858
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
@@ -19,13 +19,13 @@ object frManageUsers: TfrManageUsers
OnCloseQuery = FormCloseQuery
OnShow = FormShow
DesignSize = (
- 660
- 392)
+ 858
+ 396)
PixelsPerInch = 96
TextHeight = 14
object sSpeedButton1: TsSpeedButton
Left = 8
- Top = 368
+ Top = 372
Width = 23
Height = 22
Hint = #1044#1086#1073#1072#1074#1080#1090#1100
@@ -37,7 +37,7 @@ object frManageUsers: TfrManageUsers
end
object sSpeedButton2: TsSpeedButton
Left = 66
- Top = 368
+ Top = 372
Width = 23
Height = 22
Hint = #1059#1076#1072#1083#1080#1090#1100
@@ -49,7 +49,7 @@ object frManageUsers: TfrManageUsers
end
object sSpeedButton3: TsSpeedButton
Left = 37
- Top = 368
+ Top = 372
Width = 23
Height = 22
Hint = #1056#1077#1076#1072#1082#1090#1080#1088#1086#1074#1072#1090#1100
@@ -62,8 +62,8 @@ object frManageUsers: TfrManageUsers
object DBGridEh1: TDBGridEh
Left = 0
Top = 0
- Width = 660
- Height = 362
+ Width = 858
+ Height = 366
Align = alTop
Anchors = [akLeft, akTop, akRight, akBottom]
DataSource = dm.usersDS
@@ -129,7 +129,7 @@ object frManageUsers: TfrManageUsers
FieldName = 'dname'
Footers = <>
Title.Caption = #1055#1086#1076#1088#1072#1079#1076#1077#1083#1077#1085#1080#1077
- Width = 100
+ Width = 180
end
item
CellButtons = <>
@@ -139,10 +139,33 @@ object frManageUsers: TfrManageUsers
Footers = <>
Title.Caption = #1055#1088#1072#1074#1072
Width = 120
+ end
+ item
+ CellButtons = <>
+ Checkboxes = True
+ DynProps = <>
+ EditButtons = <>
+ FieldName = 'fired'
+ Footers = <>
+ KeyList.Strings = (
+ '1'
+ '0')
+ Title.Caption = #1059#1074#1086#1083#1077#1085
+ Width = 70
end>
object RowDetailData: TRowDetailPanelControlEh
end
end
+ object chFired: TCheckBox
+ Left = 95
+ Top = 372
+ Width = 162
+ Height = 22
+ Anchors = [akLeft, akBottom]
+ Caption = #1055#1086#1082#1072#1079#1072#1090#1100' '#1091#1074#1086#1083#1077#1085#1085#1099#1093
+ TabOrder = 1
+ OnClick = chFiredClick
+ end
object q: TMyQuery
Connection = dm.cn
Left = 424
diff --git a/UfrManageUsers.pas b/UfrManageUsers.pas
index bf87e12..b4d7b0a 100644
--- a/UfrManageUsers.pas
+++ b/UfrManageUsers.pas
@@ -7,7 +7,7 @@ interface
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, DBGridEhGrouping, ToolCtrlsEh,
DBGridEhToolCtrls, DynVarsEh, EhLibVCL, GridsEh, DBAxisGridsEh, DBGridEh, DataUnit,
MainUnit, Vcl.Buttons, sSpeedButton, UfrEditUser, Data.DB, MemDS, DBAccess,
- MyAccess;
+ MyAccess, Vcl.StdCtrls;
type
TfrManageUsers = class(TForm)
@@ -16,12 +16,14 @@ TfrManageUsers = class(TForm)
sSpeedButton2: TsSpeedButton;
sSpeedButton3: TsSpeedButton;
q: TMyQuery;
+ chFired: TCheckBox;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure sSpeedButton1Click(Sender: TObject);
procedure sSpeedButton3Click(Sender: TObject);
procedure sSpeedButton2Click(Sender: TObject);
+ procedure chFiredClick(Sender: TObject);
private
{ Private declarations }
public
@@ -35,6 +37,15 @@ implementation
{$R *.dfm}
+procedure TfrManageUsers.chFiredClick(Sender: TObject);
+begin
+DataUnit.dm.usersq.close;
+if(chFired.Checked)then
+DataUnit.dm.usersQ.SQL.Text:=DataUnit.userWithFiredSql else
+DataUnit.dm.usersQ.SQL.Text:=DataUnit.userWithoutFiredSql;
+DataUnit.dm.usersq.open;
+end;
+
procedure TfrManageUsers.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action:=caFree;
@@ -47,6 +58,9 @@ procedure TfrManageUsers.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure TfrManageUsers.FormShow(Sender: TObject);
begin
+if(chFired.Checked)then
+DataUnit.dm.usersQ.SQL.Text:=DataUnit.userWithFiredSql else
+DataUnit.dm.usersQ.SQL.Text:=DataUnit.userWithoutFiredSql;
DataUnit.dm.usersq.open;
end;
diff --git a/UfrReportClient.dfm b/UfrReportClient.dfm
index 96ab108..27ba88b 100644
--- a/UfrReportClient.dfm
+++ b/UfrReportClient.dfm
@@ -3,7 +3,7 @@ object frReportClient: TfrReportClient
Top = 0
BorderStyle = bsDialog
Caption = #1055#1072#1088#1072#1084#1077#1090#1088#1099' '#1086#1090#1095#1077#1090#1072
- ClientHeight = 149
+ ClientHeight = 190
ClientWidth = 363
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
@@ -17,13 +17,6 @@ object frReportClient: TfrReportClient
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 14
- object Label1: TLabel
- Left = 8
- Top = 64
- Width = 89
- Height = 14
- Caption = #1055#1086#1076#1088#1072#1079#1076#1077#1083#1077#1085#1080#1077
- end
object Label2: TLabel
Left = 8
Top = 8
@@ -40,7 +33,7 @@ object frReportClient: TfrReportClient
end
object Button1: TButton
Left = 280
- Top = 120
+ Top = 159
Width = 75
Height = 25
Caption = 'OK'
@@ -74,9 +67,37 @@ object frReportClient: TfrReportClient
Time = 43286.332057719900000000
TabOrder = 3
end
+ object rbDep: TRadioButton
+ Left = 8
+ Top = 56
+ Width = 113
+ Height = 17
+ Caption = #1055#1086#1076#1088#1072#1079#1076#1077#1083#1077#1085#1080#1077
+ Checked = True
+ TabOrder = 4
+ TabStop = True
+ OnClick = rbDepClick
+ end
+ object RadioButton1: TRadioButton
+ Left = 8
+ Top = 108
+ Width = 201
+ Height = 17
+ Caption = #1055#1086' '#1086#1090#1076#1077#1083#1100#1085#1099#1084' '#1089#1086#1090#1088#1091#1076#1085#1080#1082#1072#1084
+ TabOrder = 5
+ OnClick = RadioButton1Click
+ end
+ object cbUser: TComboBox
+ Left = 8
+ Top = 131
+ Width = 347
+ Height = 22
+ Style = csDropDownList
+ Enabled = False
+ TabOrder = 6
+ end
object q: TMyQuery
Connection = dm.cn
- Left = 176
- Top = 104
+ Left = 264
end
end
diff --git a/UfrReportClient.pas b/UfrReportClient.pas
index 8b6d179..a8b9183 100644
--- a/UfrReportClient.pas
+++ b/UfrReportClient.pas
@@ -11,15 +11,19 @@ interface
TfrReportClient = class(TForm)
Button1: TButton;
cb: TComboBox;
- Label1: TLabel;
q: TMyQuery;
Label2: TLabel;
dt1: TDateTimePicker;
dt2: TDateTimePicker;
Label3: TLabel;
+ rbDep: TRadioButton;
+ RadioButton1: TRadioButton;
+ cbUser: TComboBox;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
+ procedure RadioButton1Click(Sender: TObject);
+ procedure rbDepClick(Sender: TObject);
private
{ Private declarations }
public
@@ -29,7 +33,7 @@ TfrReportClient = class(TForm)
var
frReportClient: TfrReportClient;
i:integer;
- dep:TLockupValue;
+ dep, usr:TLockupValue;
implementation
@@ -39,10 +43,17 @@ procedure TfrReportClient.Button1Click(Sender: TObject);
var frRep:TfrReportClientR;
begin
frRep:=TfrReportClientR.Create(Application);
-frRep.idDep:=dep.getIdFromPosValue(cb.ItemIndex);
+if(rbDep.Checked) then begin
+ frRep.idDep:=dep.getIdFromPosValue(cb.ItemIndex);
+ frRep.nameDep:=cb.Text;
+end else begin
+ frRep.idDep:='-2';
+ frRep.userId:=usr.getIdFromPosValue(cbUser.ItemIndex);
+ frRep.nameDep:=cbUser.Text;
+end;
frRep.dt1:=dt1.Date;
frRep.dt2:=dt2.Date;
-frRep.nameDep:=cb.Text;
+
frRep.ShowModal;
end;
@@ -57,6 +68,7 @@ procedure TfrReportClient.FormCreate(Sender: TObject);
dt1.Date:=now;
dt2.Date:=now;
dep:=TLockupValue.Create;
+usr:=TLockupValue.Create;
q.SQL.Text:='select * from department order by name asc';
q.Open;
//if q.RecordCount=0 then exit;
@@ -69,6 +81,29 @@ procedure TfrReportClient.FormCreate(Sender: TObject);
q.Close;
cb.Items.Assign(dep.slValues);
cb.ItemIndex:=0;
+
+q.SQL.Text:='select id, user_name from users';
+q.Open;
+for I := 0 to q.RecordCount-1 do
+ begin
+ usr.addPair(q.FieldByName('id').AsInteger, q.FieldByName('user_name').AsString);
+ q.Next;
+ end;
+q.Close;
+cbuser.Items.Assign(usr.slValues);
+cbuser.ItemIndex:=0;
+end;
+
+procedure TfrReportClient.RadioButton1Click(Sender: TObject);
+begin
+cb.Enabled:=false;
+cbUser.Enabled:=true;
+end;
+
+procedure TfrReportClient.rbDepClick(Sender: TObject);
+begin
+cb.Enabled:=true;
+cbUser.Enabled:=false;
end;
end.
diff --git a/UfrReportClientR.dfm b/UfrReportClientR.dfm
index 257d8f0..6c80c01 100644
--- a/UfrReportClientR.dfm
+++ b/UfrReportClientR.dfm
@@ -117,6 +117,7 @@ object frReportClientR: TfrReportClientR
GridLines = True
ReadOnly = True
RowSelect = True
+ PopupMenu = PopupMenu1
TabOrder = 1
ViewStyle = vsReport
OnColumnClick = lvColumnClick
@@ -145,4 +146,18 @@ object frReportClientR: TfrReportClientR
Left = 456
Top = 352
end
+ object PopupMenu1: TPopupMenu
+ Left = 120
+ Top = 88
+ object N1: TMenuItem
+ Caption = #1069#1082#1089#1087#1086#1088#1090' '#1074' '#1101#1082#1089#1077#1083#1100
+ OnClick = N1Click
+ end
+ end
+ object SaveDialog1: TSaveDialog
+ DefaultExt = 'xls'
+ Filter = #1069#1082#1089#1077#1083#1100' '#1092#1072#1081#1083'|*.xls'
+ Left = 200
+ Top = 104
+ end
end
diff --git a/UfrReportClientR.pas b/UfrReportClientR.pas
index ea5e296..ba16c40 100644
--- a/UfrReportClientR.pas
+++ b/UfrReportClientR.pas
@@ -6,7 +6,7 @@ interface
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, DBGridEhGrouping, ToolCtrlsEh,
DBGridEhToolCtrls, DynVarsEh, EhLibVCL, GridsEh, DBAxisGridsEh, DBGridEh, DataUnit,
- Data.DB, DBAccess, MyAccess, MemDS, UtilsUnit, Vcl.ComCtrls;
+ Data.DB, DBAccess, MyAccess, MemDS, UtilsUnit, Vcl.ComCtrls, Vcl.Menus;
type
TfrReportClientR = class(TForm)
@@ -14,12 +14,16 @@ TfrReportClientR = class(TForm)
q: TMyQuery;
ds: TMyDataSource;
lv: TListView;
+ PopupMenu1: TPopupMenu;
+ N1: TMenuItem;
+ SaveDialog1: TSaveDialog;
procedure FormShow(Sender: TObject);
procedure lvCustomDrawItem(Sender: TCustomListView; Item: TListItem;
State: TCustomDrawState; var DefaultDraw: Boolean);
procedure lvCompare(Sender: TObject; Item1, Item2: TListItem; Data: Integer;
var Compare: Integer);
procedure lvColumnClick(Sender: TObject; Column: TListColumn);
+ procedure N1Click(Sender: TObject);
private
{ Private declarations }
procedure createSqlReport;
@@ -27,6 +31,7 @@ TfrReportClientR = class(TForm)
{ Public declarations }
idDep, nameDep:string;
dt1, dt2:TDate;
+ userId:string;
end;
const
@@ -55,6 +60,14 @@ implementation
procedure TfrReportClientR.createSqlReport;
var slUserIds:TStringList;
begin
+if(idDep='-2') then
+begin
+ q.SQL.Text:=sqlReport+chr(13)+
+ 'AND (tasks.user_id in('+userId+'))'
+ +sqlGroup+sqlOrder;
+ q.ParamByName('dt1').Value:=toMySqlDate(dt1);
+ q.ParamByName('dt2').Value:=toMySqlDate(dt2);
+end else
if(idDep='-1') then
begin
q.SQL.Text:=sqlReport+sqlGroup+sqlOrder;
@@ -198,7 +211,14 @@ procedure TfrReportClientR.lvCustomDrawItem(Sender: TCustomListView;
begin
Sender.Canvas.Font.Style:= Sender.Canvas.Font.Style + [fsBold];
Sender.Canvas.Brush.Color:=cl3dLight;
+end else if item.Index mod 2=0 then Sender.Canvas.Brush.Color:=$00EFEFEF;
end;
+
+procedure TfrReportClientR.N1Click(Sender: TObject);
+begin
+if not SaveDialog1.Execute(handle) then exit;
+
+UtilsUnit.saveListViewToExel(lv, saveDialog1.FileName);
end;
end.
diff --git a/UtilsUnit.pas b/UtilsUnit.pas
index 6a4635a..1d63b75 100644
--- a/UtilsUnit.pas
+++ b/UtilsUnit.pas
@@ -3,12 +3,13 @@
interface
Uses
- System.Classes, System.SysUtils;
+ System.Classes, System.SysUtils, ComObj, Vcl.ComCtrls, System.Variants;
function qs(s:string):string;
function toMySqlDate(dt:TDate):string;
function minToHour(min:integer):string;
function CompareDoubleInc(Item1, Item2: Double): Integer;
+ procedure saveListViewToExel(lv:TListView; fileName:String);
//function toMySqlDate(dt:string):string;
type
TSortState =(ssUp, ssDown, ssNone);
@@ -45,6 +46,7 @@ TLockupValue = class(TObject)
function getPositionFromId(id:integer):integer;
function getPair(index:integer):TLockupPair;
function count:integer;
+ function getIds(delimeter:char):string;
procedure addPair(id:integer; value:string); overload;
procedure addPair(id:string; value:string); overload;
procedure addPair(pair:TLockupPair); overload;
@@ -54,6 +56,40 @@ TLockupValue = class(TObject)
implementation
+procedure saveListViewToExel(lv:TListView; fileName:String);
+var i, j, r, c:integer;
+ excel, Sheet: OLEVariant;
+begin
+excel := CreateOleObject('Excel.Application');
+
+//делаем окно Excel невидимым
+excel.Visible := false;
+excel.DisplayAlerts := false;
+excel.Workbooks.Add;
+
+Sheet := excel.Workbooks[1].WorkSheets[1];
+
+c:=lv.Columns.Count-1;
+r:=lv.Items.Count;
+
+for j:= 0 to r do
+ for i:=0 to c do
+ if(j=0) then sheet.cells[j+1,i+1]:=lv.Columns.Items[i].Caption
+ else begin
+ if(i=0) then sheet.cells[j+1,i+1]:=lv.Items.Item[j-1].Caption
+ else sheet.cells[j+1,i+1]:=lv.Items.Item[j-1].SubItems[i-1];
+ end;
+
+excel.Visible := true;
+excel.WorkBooks[1].SaveAs(fileName);
+
+//excel.Quit;
+
+ //очищаем выделенную память
+ excel := unassigned;
+ Sheet := unassigned;
+end;
+
function CompareDoubleInc(Item1, Item2: Double): Integer;
begin
if Item1=Item2 then begin
@@ -144,6 +180,12 @@ function TLockupValue.getIdFromValue(value: string): string;
end;
+function TLockupValue.getIds(delimeter: char): string;
+begin
+slIds.Delimiter:=delimeter;
+Result:=slIds.DelimitedText;
+end;
+
function TLockupValue.getPair(index: integer): TLockupPair;
begin
Result:=TLockupPair.Create(strtoint(slIds.Strings[index]), slValues.Strings[index]);