2015-02-11 23:52:11 -05:00
< ? php
session_start ();
2017-05-11 13:22:44 -04:00
if ( file_exists ( " config.inc.php " )){
require_once ( " config.inc.php " );
} else {
echo " Configuration file not found - please complete setup before continuing. " ;
exit ;
}
2015-02-20 05:16:28 -05:00
require_once ( $yaptc_inc . " functions.inc.php " );
2015-02-25 16:01:50 -05:00
$yaptc_pagename = lang ( 'HOME' );
2016-02-04 14:18:34 -05:00
$yaptc_pageicon = '<i class="fa fa-home"></i>' ;
2015-02-11 23:52:11 -05:00
require_once ( $yaptc_inc . " header.inc.php " );
2015-02-20 01:57:34 -05:00
if ( getSessionStatus () == false ) :
2015-02-19 10:53:29 -05:00
killSession ();
2015-02-20 05:16:28 -05:00
else : ?>
2015-02-25 16:01:50 -05:00
<!-- ********** BEGIN CONTENT ********** -->
2017-05-11 16:57:56 -04:00
2015-02-24 10:37:52 -05:00
< ? php
2015-02-25 16:01:50 -05:00
// Get punch status for buttons and times
2017-05-11 13:22:44 -04:00
$session_punch = listPunches ( $yaptc_db , $session_user [ " 0 " ][ " userid " ], 1 );
2015-02-24 15:37:29 -05:00
if ( ! isset ( $session_punch [ '0' ][ 'intime' ])) :
$session_status = lang ( 'OUT' );
$session_message = lang ( 'PUNCH_STATUS' ) . " : " . lang ( 'NO_PUNCHES' );
else :
if ( ! empty ( $session_punch [ '0' ][ 'outtime' ])) :
$session_status = lang ( 'OUT' );
$statustime = $session_punch [ '0' ][ 'outtime' ];
$session_message = lang ( 'PUNCH_STATUS' ) . " : " . $session_status . " " . lang ( 'SINCE' ) . " " . date ( 'g:i a \o\n M jS, Y' , strtotime ( $statustime ));
else :
$session_status = lang ( 'IN' );
$statustime = $session_punch [ '0' ][ 'intime' ];
$punchid = $session_punch [ '0' ][ 'punchid' ];
$notes = $session_punch [ '0' ][ 'notes' ];
$session_message = lang ( 'PUNCH_STATUS' ) . " : " . $session_status . " " . lang ( 'SINCE' ) . " " . date ( 'g:i a \o\n M jS, Y' , strtotime ( $statustime ));
endif ;
endif ;
2015-02-24 10:47:00 -05:00
2015-02-25 16:01:50 -05:00
// Process posted data from quickpunch section
if ( isset ( $_POST [ 'quickpunch' ])) :
if ( ! empty ( $_POST [ 'notes' ])) : $notes = $_POST [ 'notes' ]; else : $notes = NULL ; endif ;
2017-05-11 23:07:56 -04:00
if ( $session_status == lang ( 'IN' )) : punchOut ( $yaptc_db , $punchid , $notes , $timenow , NULL ); $session_status = lang ( 'OUT' ); $session_message = lang ( 'PUNCH_STATUS' ) . " : " . $session_status . " " . lang ( 'SINCE' ) . " " . date ( 'g:i a \o\n M jS, Y' , strtotime ( $statustime )); $notes = NULL ;
elseif ( $session_status == lang ( 'OUT' )) : punchIn ( $yaptc_db , $_SESSION [ 'user_id' ], $notes , $timenow , NULL ); $session_status = lang ( 'IN' ); $session_message = lang ( 'PUNCH_STATUS' ) . " : " . $session_status . " " . lang ( 'SINCE' ) . " " . date ( 'g:i a \o\n M jS, Y' , strtotime ( $statustime ));
2015-02-25 16:01:50 -05:00
endif ;
header ( 'Location: ' . $_SERVER [ 'PHP_SELF' ]);
endif ;
2015-02-24 10:47:00 -05:00
2015-02-25 16:01:50 -05:00
// Process posted data from advancedpunch section
if ( isset ( $_POST [ 'advancedpunch' ])) :
2015-02-24 10:47:00 -05:00
if ( ! empty ( $_POST [ 'notes' ])) : $notes = $_POST [ 'notes' ]; else : $notes = NULL ; endif ;
2015-02-25 16:01:50 -05:00
if ( ! empty ( $_POST [ 'punchtime' ])) : $punchtime = $_POST [ 'punchtime' ]; else : $punchtime = $timenow ; endif ;
2017-05-11 23:07:56 -04:00
if ( $session_status == lang ( 'IN' )) : punchOut ( $yaptc_db , $punchid , $notes , $timenow , NULL ); $session_status = lang ( 'OUT' ); $session_message = lang ( 'PUNCH_STATUS' ) . " : " . $session_status . " " . lang ( 'SINCE' ) . " " . date ( 'g:i a \o\n M jS, Y' , strtotime ( $statustime )); $notes = NULL ;
elseif ( $session_status == lang ( 'OUT' )) : punchIn ( $yaptc_db , $_SESSION [ 'user_id' ], $notes , $punchtime , NULL ); $session_status = lang ( 'IN' ); $session_message = lang ( 'PUNCH_STATUS' ) . " : " . $session_status . " " . lang ( 'SINCE' ) . " " . date ( 'g:i a \o\n M jS, Y' , strtotime ( $statustime ));
2015-02-20 05:16:28 -05:00
endif ;
header ( 'Location: ' . $_SERVER [ 'PHP_SELF' ]);
2015-02-24 10:47:00 -05:00
endif ;
2017-05-11 23:07:56 -04:00
?>
// HTML
<!-- Begin page content -->
< div class = " container " >
< div class = " page-header " >
< h2 >< ? php echo $yaptc_pageicon ; echo $yaptc_pagename ; ?> </h2>
</ div >
< p class = " lead " >< ? php if ( isset ( $_SESSION [ 'user_id' ])) : echo lang ( 'USER' ) . " : " . $session_user [ " 0 " ][ " firstname " ] . ' ' . $session_user [ " 0 " ][ " lastname " ]; else : echo lang ( 'PLEASE_LOG_IN' ); endif ; ?> </p>
< p class = " lead " >< ? php echo $session_message ; ?> </p>
</ div >
2015-02-24 10:47:00 -05:00
2017-05-11 23:07:56 -04:00
< ? php
2015-02-25 16:01:50 -05:00
// HTML section for quick punch only
if ( $yaptc_allowuseradvancedpunch == " no " ) : ?>
2017-05-11 23:07:56 -04:00
<!-- Begin page content -->
< div class = " container " >
< div class = " page-header " >
< h2 >< i class = " glyphicon glyphicon-time " ></ i > < ? php echo lang ( 'QUICK_PUNCH' ); ?> </h2>
</ div >
< p class = " lead " >< ? php echo lang ( 'QUICK_PUNCH_PARAGRAPH' ); ?> </p>
< form action = " <?php echo $_SERVER['PHP_SELF'] ; ?> " method = " post " >
< fieldset id = " quickpunch " >
< div class = " form-group row " >
< div class = " col-sm-8 " >
< input class = " form-control " type = " text " name = " notes " placeholder = " <?php echo lang('NOTES_PLACEHOLDER'); ?> " maxlength = " 255 " value = " <?php if (isset( $notes )): echo $notes ; endif; ?> " />
</ div >
< div class = " col-sm-4 " >
< button type = " submit " class = " form-control btn btn-block <?php if ( $session_status == lang('IN')): echo " btn - danger " ; elseif ( $session_status == lang('OUT')): echo " btn - success " ; endif;?> " name = " quickpunch " >< ? php if ( $session_status == lang ( 'IN' )) : echo '<i class="glyphicon glyphicon-stop"></i> ' . lang ( 'PUNCH' ) . ' ' . lang ( 'OUT' ); elseif ( $session_status == lang ( 'OUT' )) : echo '<i class="glyphicon glyphicon-play"></i> ' . lang ( 'PUNCH' ) . ' ' . lang ( 'IN' ); endif ; ?> </button>
</ div >
</ div >
2015-02-25 16:01:50 -05:00
</ fieldset >
</ form >
2017-05-11 23:07:56 -04:00
</ div >
</ div >
2015-02-24 10:47:00 -05:00
2015-02-25 16:01:50 -05:00
< ? php
// HTML section for advanced punch only
elseif ( $yaptc_allowuseradvancedpunch == " yes " ) : ?>
2017-05-11 23:07:56 -04:00
<!-- Begin page content -->
< div class = " container " >
< div class = " page-header " >
< h2 >< i class = " glyphicon glyphicon-time " ></ i > < ? php echo lang ( 'ADVANCED_PUNCH' ); ?> </h2>
</ div >
< p class = " lead " >< ? php echo lang ( 'ADVANCED_PUNCH_PARAGRAPH' ); ?> </p>
< form action = " <?php echo $_SERVER['PHP_SELF'] ; ?> " method = " post " >
< fieldset id = " advancedpunch " >
< div class = " form-group row " >
< div class = " col-sm-3 " >
< input class = " form-control " type = " text " name = " punchtime " placeholder = " <?php echo $timenow ; ?> " />
</ div >
< div class = " col-sm-6 " >
< input class = " form-control " type = " text " name = " notes " placeholder = " <?php echo lang('NOTES_PLACEHOLDER'); ?> " maxlength = " 255 " value = " <?php if (isset( $notes )): echo $notes ; endif; ?> " />
</ div >
< div class = " col-sm-3 " >
< button type = " submit " class = " form-control btn btn-block <?php if ( $session_status == lang('IN')): echo " btn - danger " ; elseif ( $session_status == lang('OUT')): echo " btn - success " ; endif;?> " name = " advancedpunch " >< ? php if ( $session_status == lang ( 'IN' )) : echo '<i class="glyphicon glyphicon-stop"></i> ' . lang ( 'PUNCH' ) . ' ' . lang ( 'OUT' ); elseif ( $session_status == lang ( 'OUT' )) : echo '<i class="glyphicon glyphicon-play"></i> ' . lang ( 'PUNCH' ) . ' ' . lang ( 'IN' ); endif ; ?> </button>
</ div >
</ div >
2015-02-25 16:01:50 -05:00
</ fieldset >
</ form >
2017-05-11 23:07:56 -04:00
</ div >
</ div >
2015-02-24 10:47:00 -05:00
2015-02-25 16:01:50 -05:00
< ? php endif ; ?>
<!-- ********** END CONTENT ********** -->
2015-02-20 05:16:28 -05:00
< ? php endif ; require_once ( $yaptc_inc . " footer.inc.php " ); ?>