#!/usr/bin/perl BEGIN { use lib '/usr/home/cfg' ; require push_inc ; } use CGI qw( :standard ); use CGI::Carp qw(fatalsToBrowser); use Fcntl qw(:flock); use File::Copy; use File::Basename; require cfg ; print header; # CGI.pm method #--------------------------------------------------------------------------------------------------------------------------------------------------------------------- &today; #--------------------------------------------------------------------------------------------------------------------------------------------------------------------- # unless ($username eq 'rory') { print ">>>>>> APOLOGIES, DOING MAINTENANCE <<<<<<"; exit; } @ARGV = split(/\\*\&/, $ENV{'QUERY_STRING'}); $action = $ARGV[0] ; our ($q) = CGI -> new() ; our $iaction = $q -> param('iaction') || $action ; our $isaved = $q -> param('isaved') || '' ; # our $debug = 1 ; &common_min_restriction_super ; #-------- page opts -------------------------------------------------------------------------------------------------------------------------------------------------- &page_opts ; #--------------------------------------------------------------------------------------------------------------------------------------------------------------------- &common_min_action; exit; #------------------------------------------------------------------------------------------ sub validate { # my $exists = '' ; # &db_min_ro($table,'*',"name = '$i{name}'",'name','') ; # foreach my $id (keys %{$db{$table}}) { if ($db{$table}{$id}{name} eq $i{name}) { $exists = 1 ; } } # if ($exists) { $alert = &common_min_alert('warning',"$ucpage ALREADY EXISTS!",'ok') ; %col_name = (); &common_min_add_screen; &common_min_screen1; } } #------------------------------------------------------------------------------------------ sub insert { &add_db_fields ; $i{id} = &db_min_get_max($table,'id') ; &common_min_upload_files("leave/$i{id}") ; $i{date_time} = "$now_ccyy_mm_dd $now_hour:$now_min:$now_sec" ; $i{category} = 'leave' ; &db_min_insert($table) ; } #------------------------------------------------------------------------------------------ sub update { unless ($i{id}) { $error = qq(NO ID) ; return ; } &edit_db_fields ; &common_min_upload_files("leave/$i{id}") ; # unless ($i{block}) { $i{block} = '0' ; } # $i{lastupdate} = "$now_ccyy_mm_dd $now_hour:$now_min:$now_sec" ; &db_min_upd($table,"id='$i{id}'") ; } #------------------------------------------------------------------------------------------ sub list_screen { &db_min_ro('users','*','','','') ; foreach my $id (keys %{$db{users}}) { $user_name{$id} = $db{users}{$id}{name} ; } my $extra_sql = '' ; unless ($useropts{super}{lc $username}) { $extra_sql = " AND `user_id`='$userid'" ; } &db_min_ro($table,'*',"`category`='leave'$extra_sql",'','') ; foreach my $id (keys %{$db{$table}}) { my $leave_type = ucfirst $db{$table}{$id}{type} ; my $attach_butt = '' ; $attach_options = &common_min_get_uploads("leave/$id",'all') ; if ($attach_options) { $attach_butt = qq( ) ; } my $edit_butt = '' ; my $del_butt = '' ; if ($useropts{boss}{lc $username}){ $edit_butt = qq( ) ; $del_butt = qq() ; } $print_tbody .= qq( $id $db{$table}{$id}{date_time} $user_name{$db{$table}{$id}{user_id}} $db{$table}{$id}{startdate} $db{$table}{$id}{enddate} $db{$table}{$id}{days} $leave_type $db{$table}{$id}{notes}   $edit_butt $del_butt $attach_butt ) ; } } #------------------------------------------------------------------------------------------ sub thead { $print_thead = qq(IDDATE ADDEDSTAFF NAMESTART DATEEND DATEDAYSTYPENOTES ) ; } #------------------------------------------------------------------------------- sub add_db_fields { &hidden_db_fields ; # $ignore{id} = 1 ; $hidden{id} = 2 ; } #------------------------------------------------------------------------------------------ sub sort_leave_fields { $sort_field{1} = 'startdate' ; $sort_field{2} = 'enddate' ; $sort_field{3} = 'days' ; $sort_field{4} = 'type' ; $sort_field{5} = 'user_id' ; $sort_field{6} = 'notes' ; } #------------------------------------------------------------------------------- sub hidden_db_fields { $ignore{iaction} = 1 ; $textarea{notes} = 1 ; # $required{title} = 1 ; $required{category} = 1 ; $required{days} = 9 ; $datetimepicker{startdate} = 1 ; $datetimepicker{enddate} = 1 ; $ignore{completed} = 1 ; $ignore{iattachleave} = 1 ; $ignore{title} = 1 ; # $hidden{user_id} = 2 ; $hidden{date_time} = 2 ; $hidden{category} = 2 ; &sort_leave_fields ; } #------------------------------------------------------------------------------------------ sub edit_db_fields { &hidden_db_fields ; $hidden{id} = 1 ; } #------------------------------------------------------------------------------------------ sub add_screen { &select_opts('') ; } #------------------------------------------------------------------------------------------ sub edit_screen { $selected{'type'}{$db{$table}{$i{id}}{type}} = 'SELECTED' ; $leave_uploads = &common_min_get_uploads("leave/$i{id}",'leave') ; &select_opts($i{id}) ; } #------------------------------------------------------------------------------------------ sub select_opts { my ($id) = @_ ; @user_excl_sql = () ; foreach (keys %{$useropts{it}}) { push @user_excl_sql, "username <> '$_'" ; } my $user_excl_sql = join(" AND ", @user_excl_sql) ; &common_min_select_opts('user_id','users','name',$db{$table}{$id}{user_id},1,'',$user_excl_sql) ; &common_min_opts('leave_type','type',1) ; $extra_form_fields .= qq(
 

Upload file from PC.

$leave_uploads
) ; } #------------------------------------------------------------------------------- sub page_opts { our $glyphicon = 'calendar' ; our $lcpage = 'leave' ; $ucpage = uc $lcpage ; $ucfirstpage = ucfirst $lcpage ; our $table = 'events' ; $s{no} = 1 ; &common_min_add_extras ; &common_min_add_box_icon ; unless ($useropts{boss}{lc $username}) { $box_icon = '' ; } } #------------------------------------------------------------------------------- use common ; use today ; 1;