CREATE TABLE tm_Dotacion (
	tmEst  CHAR(2) NOT NULL DEFAULT ('01'),
	tmIdEmpleado VARCHAR(16) NOT NULL,
	tmNContrato INT NOT NULL DEFAULT (0),
	tmFecha SMALLDATETIME NOT NULL,
	tmTipo VARCHAR(10) NOT NULL,
	tmIdCia CHAR(2) NOT NULL,
	tmNumReg INT NOT NULL DEFAULT (0),
	tmDiasPlazo INT NOT NULL DEFAULT (0),
	tmFecVence SMALLDATETIME NULL,
	tmDetalle VARCHAR(1000) NULL
  CONSTRAINT PK_tm_Dotacion PRIMARY KEY CLUSTERED (tmEst,tmIdEmpleado),
  CONSTRAINT CK_tm_DotaciontmEst CHECK ((len([tmEst])>(0))),
  CONSTRAINT CK_tm_DotaciontmTipo CHECK ((len([tmTipo])>(0))))
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[paQrytm_Dotacion] @pmtmEst CHAR(2)
 AS 
 SELECT tmIdEmpleado,Apellidos,Nombres,tmNContrato,tmTipo,tmFecha,tmDiasPlazo,tmFecVence,tmIdCia,CI.Compania,tmNumReg,tmDetalle
,FecIngreso,Indefinido,C.IdNom AS CdNom,TipoNomina,C.IdTipCon AS CdTipCon,TipoContrato,C.IdArea AS CdArea,Area,C.IdDep AS CdDep,Dependencia,C.IdInstala AS IdInstla,Instlacion
,C.IdCargo AS CodCargo,Cargo,C.IdCia AS ConCdCia,CN.Compania AS ConCompania,C.TipoLiquida AS TipoLiq,DchDotacion,VrSalario,VrAuxTrans,SalMinimo,SalIntegral
,E.Codigo,e_mail,E.Sexo,E.IdProf AS CodProf,Profesion,FecUltDot,TallaCam,TallaPan,TallaZap
FROM tm_Dotacion AS T INNER JOIN Empleados AS E ON T.tmIdEmpleado=E.IdEmpleado INNER JOIN Profesiones AS P ON E.IdProf=P.IdProf
INNER JOIN Emp_Contrato AS C ON T.tmNContrato=C.NContrato INNER JOIN TiposCon AS TC ON C.IdTipCon=TC.IdTipCon
INNER JOIN Cargos AS CG ON C.IdCargo=CG.IdCargo INNER JOIN Dependencias AS DP ON C.IdDep=DP.IdDep
INNER JOIN Areas AS AR ON C.IdArea=AR.IdArea INNER JOIN Instalaciones AS I ON C.IdInstala=I.IdInstala
INNER JOIN Companias AS CN ON C.IdCia=CN.IdCia INNER JOIN TiposNom AS TN ON C.IdNom=TN.IdNom
LEFT JOIN Companias AS CI ON T.tmIdCia=CI.IdCia
WHERE tmEst=@pmtmEst
GO
INSERT INTO Sys_ObjetosApp (IdObj,IdGrupo,SubModulo,IndObj,Nombre,Formulario,Permisos,NivelMinimo,NomArchivo)
 VALUES ('FRMLDOT','NOMINF','GEN',13,'Informe de Dotaciones','FRMLDOT','S',0,'')
INSERT INTO Sys_Report (TipoRep,IdRep,Descripcion,Formato,TipoPapel,Orientacion,VistaPrevia,VerSetup,NumCopias,sp_Nombre,Ind_Location,NomRep)
 VALUES ('LDO','01','Dotaciones','CrLtDot.rpt',1,1,1,0,1,'paQrytm_Dotacion','','Dotaciones')