********************************************************************* ** * ** Product of - Value Added Software, Inc *C ** 1511 East Harvard Ave *C ** Salt Lake City, UT 84105 *C ** (801) 581-1154 *C ** *C ** Copyright Notice *C ** *C ** Value Added Software, Inc *C ** Pete Helgren ** All rights, including copyrights reserved. *C ** Created: 2011 *C ** * ********************************************************************* ** Original version written: 11/16/11 By: P. Helgren * ** Modifications: * ** __________________________________________________________ * *************************************************************************** H option(*nodebugio) dftactgrp(*no) actgrp(*new) FPUNCHWS CF E WORKSTN INDDS(ScreenInds) D ScreenInds ds D ExitKey N overlay(ScreenInds:03) D InKey N overlay(ScreenInds:06) D OutKey N overlay(ScreenInds:07) D D PunchDate S D D PunchTime S 10A D Employee S 9S 0 d Day_Of_Week s 1p 0 D Punch PR 5A D RunSQL PR 5A D getLastPunch PR D eeparm 9S 0 D gSQLInsert S 2048A Varying D gSQLSelect S 2048A Varying C/free TITLE = 'Green Screen Time Clock'; // Normally we'd get an employee number from a login routine so we'll just // set it to 55 for now employee = 55; punchdate = %date(%char(%date():*MDY):*MDY); punchtime = %char(%time():*HMS); DAT = %char(%date():*MDY); exsr GetDayOfWeek; getLastPunch(employee); *in99=*on; dou (ExitKey = *on ); ExitKey = *off; InKey = *off; OutKey = *off; exfmt FMT01; if PB2 = 2 or OutKey = *on; PunchType = 'OUT'; punch(); ExitKey = *on; endif; if PB2 = 1 or InKey = *on; PunchType = 'IN'; punch(); ExitKey = *on; endif; enddo; *inlr = *on; /end-free //-------------------------------* Sub-Routine * // GetDayOfWeek() *---------------* // Get the day of the week * //-----------------------------------------------* C/free begsr GetDayOfWeek; Day_Of_Week = %rem(%diff(%date():d'0001-01-01':*days):7); select; when Day_Of_Week = 0; DOWEEK = 'Monday'; when Day_Of_Week = 1; DOWEEK = 'Tuesday'; when Day_Of_Week = 2; DOWEEK = 'Wednesday'; when Day_Of_Week = 3; DOWEEK = 'Thursday'; when Day_Of_Week = 4; DOWEEK = 'Friday'; when Day_Of_Week = 5; DOWEEK = 'Saturday'; when Day_Of_Week = 6; DOWEEK = 'Sunday'; endsl; endsr; /end-free C******************************************************** C* add punch C******************************************************** P Punch B D Punch PI 5A C/free gSQLInsert = 'insert into punches(employee, punchdate,'+ 'punchtime, punch) '+ 'values(?,?,?,?)'; runSQL(); return SQLSTT; /end-free P Punch E C********************************************************* C* Run the SQL statements C********************************************************* P RunSQL B D RunSQL PI 5A C/free exec sql prepare s1 from :gSQLInsert; exec sql execute s1 using :employee, :punchdate, :punchtime, :punchType; return SQLSTT; /end-free P RunSQL E C******************************************************** C* get the last punch C******************************************************** P getLastPunch B D getLastPunch PI D eeparm 9S 0 C/free gSQLSelect = 'select punch from Punches where ID = ' + ' (select max(id) ' + 'from Punches where employee = ?)'; exec sql prepare s1 from :gSQLSelect; exec sql declare c1 cursor for S1; exec sql open c1 using :eeparm; exec sql fetch from c1 into :PunchType; exec sql close c1; /end-free P getLastPunch E