*--------------------------------------------------------------------------------------------------------------------------------------------------------
* (EN) AUTOGENERATED - ATTENTION!! - NOT INTENDED FOR EXECUTION!! USE ONLY FOR MERGING CHANGES AND STORING WITH SCM TOOLS!!
*--------------------------------------------------------------------------------------------------------------------------------------------------------
*< FOXBIN2PRG: Version="1.21" SourceFile="orapoarte_obinv.vcx" CPID="1252" /> (Solo para binarios VFP 9 / Only for VFP 9 binaries)
*
*
DEFINE CLASS frm_necesar_echipamente AS _frmbase OF "..\comun\clase\_frm_base.vcx" 
 	*< CLASSDATA: Baseclass="form" Timestamp="" Scale="Pixels" Uniqueid="" />

	*-- OBJECTDATA items order determines ZOrder / El orden de los items OBJECTDATA determina el ZOrder 
	*< OBJECTDATA: ObjPath="Label1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_listare1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_conditii" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_conditii.cDenumire.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_conditii.cDenumire.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_conditii.cAles.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_conditii.cAles.Check1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_excel1" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: cauta_persoane
		*m: get_necesar_echip
	*</DefinedPropArrayMethod>

	*<PropValue>
		BorderStyle = 1
		DoCreate = .T.
		Height = 441
		Name = "frm_necesar_echipamente"
		Width = 426
		_shape1.Height = 29
		_shape1.Left = 0
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape1.Width = 636
		_shape2.Height = 29
		_shape2.Left = 335
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Width = 91
		Lb_titlu_alb_b121.Caption = "Criterii raport"
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		BUT_TERMIN1.Left = 395
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.Top = 1
		Gridsort1.Left = 202
		Gridsort1.Name = "Gridsort1"
		Gridsort1.Top = 5
	*</PropValue>

	ADD OBJECT 'But_excel1' AS but_excel WITH ;
		Left = 366, ;
		Name = "But_excel1", ;
		Top = 1, ;
		Visible = .T.
		*< END OBJECT: ClassLib="..\comun\clase\cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_listare1' AS but_listare WITH ;
		Left = 336, ;
		Name = "But_listare1", ;
		Top = 1, ;
		Visible = .T.
		*< END OBJECT: ClassLib="..\comun\clase\cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'grid_conditii' AS _grdrow WITH ;
		ColumnCount = 2, ;
		DeleteMark = .F., ;
		Height = 368, ;
		Left = 12, ;
		Name = "grid_conditii", ;
		Panel = 1, ;
		ReadOnly = .T., ;
		RecordSource = "v_conditii", ;
		Top = 52, ;
		Width = 396, ;
		Column1.ControlSource = "denumire", ;
		Column1.Name = "cDenumire", ;
		Column1.ReadOnly = .T., ;
		Column1.Width = 327, ;
		Column2.ColumnOrder = 2, ;
		Column2.ControlSource = "ales", ;
		Column2.Name = "cAles", ;
		Column2.ReadOnly = .F., ;
		Column2.Sparse = .F., ;
		Column2.Width = 35
		*< END OBJECT: ClassLib="..\comun\clase\_grd_base.vcx" BaseClass="grid" />

	ADD OBJECT 'grid_conditii.cAles.Check1' AS checkbox WITH ;
		Alignment = 2, ;
		Caption = "", ;
		Height = 17, ;
		Left = 29, ;
		Name = "Check1", ;
		ReadOnly = .F., ;
		Top = 47, ;
		Width = 60
		*< END OBJECT: BaseClass="checkbox" />

	ADD OBJECT 'grid_conditii.cAles.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Ales", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grid_conditii.cDenumire.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Denumire", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grid_conditii.cDenumire.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T.
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'Label1' AS label WITH ;
		BackStyle = 0, ;
		Caption = "Conditia", ;
		Height = 17, ;
		Left = 12, ;
		Name = "Label1", ;
		Top = 36, ;
		Width = 48
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label2' AS label WITH ;
		BackStyle = 0, ;
		Caption = "Salariat", ;
		Height = 17, ;
		Left = 12, ;
		Name = "Label2", ;
		Top = 323, ;
		Visible = .F., ;
		Width = 44
		*< END OBJECT: BaseClass="label" />
	
	PROCEDURE cauta_persoane
		lcTabelCond = thisform.grid_conditii.RecordSource 
		SELECT (lcTabelCond) 
		
		lcConditie = &lcTabelCond..conditie
		IF EMPTY(lcConditie)
			RETURN
		ENDIF 	
		
		save_grid_tag(thisform.grid_persoane)
		poper.ca_baza1.cfiltru = [1=1 and ] + lcConditie
		poper.ca_baza1.afisare()
		restore_grid_tag(thisform.grid_persoane)
		
	ENDPROC

	PROCEDURE get_necesar_echip
		PARAMETERS tnX
		
		lofd = CREATEOBJECT('frm_data')
		lofd.SHOW(1)
		
		pcData = DTOS(pdData)
		
		IF buton = 2
			RETURN
		ENDIF
		
		LOCAL lcTabel
		lcTabel = THISFORM.grid_conditii.RECORDSOURCE
		
		PRIVATE pcIdCond && id-urile de conditii
		pcIdCond = ''
		
		SELECT (lcTabel)
		SCAN FOR ales = 1
			pcIdCond = pcIdCond + ALLTRIM(STR(id_conditie))+';'
		ENDSCAN
		
		IF LEN(pcIdCond)>1
			pcIdCond = SUBSTR(pcIdCond,1,LEN(pcIdCond)-1)
		ENDIF
		
		DO CASE
			CASE tnX = 1
				pnCumulat = 0
		*!*		CASE tnX = 2
		*!*			pnCumulat = 1
			CASE tnX = 2
				pnCumulat = 2
		ENDCASE
		
		
		PRIVATE pnId_responsabil
		STORE 0 TO pnId_responsabil
		
		IF pnCumulat = 0
			loResp = caut_responsabil(.T.)
			pnId_responsabil = loResp.id_responsabil
		ENDIF 
		
		lcSel = [{call pack_gest_rapoarte.get_necesar_echip(?gnAn,?gnLuna,?pdData,?pcIdCond,?pnCumulat,?pnId_responsabil, ?gnIdSucursala)}]
		lcCursor = 'cNecEchip'
		lnSucces = goExecutor.oExecute(lcSel,lcCursor)
		IF lnSucces < 0
			AMESSAGEBOX(goExecutor.cEroare,0+16,"Eroare")
			RETURN
		ENDIF
		
	ENDPROC

	PROCEDURE inainte_de_do_excel
		LOCAL lcTabel 
		lcTabel = THISFORM.grid_conditii.RECORDSOURCE
		SELECT (lcTabel)
		LOCATE FOR ales = 1
		IF !FOUND()
			aMESSAGEBOX('Bifati conditiile pentru care doriti sa generati raportul!',48,"Atentie")
			RETURN 
		ENDIF 
		
		lcmenu = "Defalcat pe responsabili;Cumulat pe articole"
		lnx = xmenu(lcmenu)
		
		IF !INLIST(lnx,1,2)
			RETURN
		ENDIF
		  
		THISFORM.get_necesar_echip(lnx)
		
		IF USED('cNecEchip')
			SELECT cNecEchip
		ELSE
			RETURN
		ENDIF
		
		DO export_xls WITH 'cNecEchip' IN oproceduri_comune.prg
		
		IF USED('cNecEchip')
			USE IN cNecEchip
		ENDIF
		
		
	ENDPROC

	PROCEDURE inainte_de_do_listare
		LOCAL lcTabel
		lcTabel = THISFORM.grid_conditii.RECORDSOURCE
		SELECT (lcTabel)
		LOCATE FOR ales = 1
		IF !FOUND()
			aMESSAGEBOX('Bifati conditiile pentru care doriti sa generati raportul!',48,"Atentie")
			RETURN
		ENDIF
		
		PRIVATE pcTitlu, pcDataOra
		pcDataOra = get_ora(2)
		
		lcmenu = "Defalcat pe responsabili;Cumulat pe articole"
		lnx = xmenu(lcmenu)
		
		IF !INLIST(lnx,1,2)
			RETURN
		ENDIF
		
		
		THISFORM.get_necesar_echip(lnx)
		
		THISFORM.ALWAYSONTOP = .F.
		
		IF USED('cNecEchip')
			SELECT cNecEchip
		ELSE
			RETURN
		ENDIF
		
		DO CASE
			CASE lnx = 1
				pcTitlu = "Necesar de echipamente"
				REPORT FORM rap_necesar_echip.frx TO PRINTER PROMPT PREVIEW
		
		*!*		CASE lnx = 2
		*!*			pcTitlu = "Necesar de echipamente cumulat"
		*!*			REPORT FORM rap_necesar_echip_cum.frx TO PRINTER PROMPT PREVIEW
		
			CASE lnx = 2
				pcTitlu = "Necesar de echipamente - total articole"
				REPORT FORM rap_necesar_echip_cum_art.frx TO PRINTER PROMPT PREVIEW
		ENDCASE
		
		THISFORM.ALWAYSONTOP = .T.
		
		
		IF USED('cNecEchip')
			USE IN cNecEchip
		ENDIF
		
		***-------------------------------
		
	ENDPROC

	PROCEDURE grid_conditii.AfterRowColChange
		LPARAMETERS nColIndex
		SELECT v_conditii 
		SCATTER NAME poconditii MEMO 
	ENDPROC

	PROCEDURE grid_conditii.cAles.Header1.DblClick
		LOCAL lctabel
		lctabel = THISFORM.grid_conditii.RECORDSOURCE
		SELECT (lctabel)
		LOCATE FOR ales = 1
		IF FOUND()
			REPLACE ALL ales WITH 0
		ELSE
			REPLACE ALL ales WITH 1
		ENDIF
		
	ENDPROC

ENDDEFINE
