Advertisement
Guest User

Untitled

a guest
Jul 29th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 3.22 KB | None | 0 0
  1. #
  2. # File: record-time.pl
  3. #
  4. # Parameters:
  5. #
  6. # task_title
  7. # task_desc
  8. # task_hrs_alloc
  9. # task_hrs_rec
  10. # task_hrs_left
  11. # task_ref   (required)
  12. # task_user (required)
  13. # task_conf
  14. # task_percent
  15. #
  16. # form_start
  17. # form_end
  18. # form_date_sel
  19. #
  20. # tms_date_to
  21. # tms_date_for
  22. # tms_conf
  23. # tms_hourstorec
  24. # tms_hourstoshow
  25. #
  26. # Exit Status:
  27. #
  28. # 1/0
  29. #
  30. # Description:
  31. # Displays a popup window that allows the user to record time against a task.
  32. # Hours can be recorded for a single day or x hours to each day in a range.
  33. #
  34. #
  35. ################################################################################
  36. use strict;
  37. use File::Basename;
  38.  
  39. use CGI;
  40. use CGImis;
  41. use Dates;
  42. use TMS;
  43. use Userblog;
  44. use Randomtask;
  45. use Blog;
  46. use Taskdiary;
  47.  
  48. use Authenticate;
  49. use myDBob;
  50. use Debug;
  51. use CGI qw(:standard escapeHTML);
  52. use URI::Escape;
  53.  
  54. use Date::Calc qw(Add_Delta_Days Add_Delta_DHMS Day_of_Week);
  55.  
  56. #Start the web page
  57. $CGI_mis::query = CGI::new();
  58. print $CGI_mis::query->header();
  59. $Utils::HTML = 1;
  60. $Debug::HTML = 1;
  61.  
  62. CGI_mis::PrintHeader("Record Time", undef, 1);
  63.  
  64. my $script         = basename($0);
  65. my $all_params_ref = CGI_mis::GetAllParams($script);
  66. my $user           = Authenticate::GetUser();
  67.  
  68. my $numb_days;
  69. my $extra_js;
  70.  
  71.  
  72. #
  73. # Check the required parameters
  74. #
  75.  
  76. # New code to attempt to have # symbols not break the url
  77. if (defined $all_params_ref->{'task_desc'})
  78. {
  79.     $all_params_ref->{'task_desc'} = uri_escape($all_params_ref->{'task_desc'});
  80. }
  81.  
  82.  
  83. if(! defined $all_params_ref->{'task_ref'})
  84. {
  85.     error("No task ref - Cannot log time");
  86. }
  87. if(! defined $all_params_ref->{'task_user'})
  88. {
  89.     error("No task user - Cannot log time");
  90. }
  91.  
  92.  
  93.     #
  94.     # Display the page
  95.     #
  96.     my ($title, $param, $date_sel);
  97.     my ($newhrsinput, $forinput, $toinput, $confidenceinput);
  98.  
  99.     my $calendar   = 1;
  100.     my $confidence = 1;
  101.     my $taskdiary  = 0;
  102.  
  103.     if($all_params_ref->{'task_ref'} =~ /^(CPO|RFR|RND)/)
  104.     {
  105.         $confidence = 0;
  106.         $taskdiary  = 1;
  107.     }
  108.     elsif($all_params_ref->{'task_ref'} =~ /^BUG/)
  109.     {
  110.         $taskdiary  = 1;
  111.     }
  112.  
  113.  
  114.     # Display the task title, but if not defined use the task_ref
  115.     $title = $all_params_ref->{'task_title'} || $all_params_ref->{'task_ref'};
  116.  
  117.     # add on the description if defined
  118.     if(defined $all_params_ref->{'task_desc'})
  119.     {
  120.         $title .= "<br>".escapeHTML($all_params_ref->{'task_desc'});
  121.     }
  122.     print "<h3 class='tmstitle'>$title</h3>\n";
  123.  
  124.     # We'll need to escape anything which may have 'odd' characters
  125.     $all_params_ref->{'task_title'} = escapeHTML($all_params_ref->{'task_title'})
  126.         if defined $all_params_ref->{'task_title'};
  127.     $all_params_ref->{'task_desc'}  = escapeHTML($all_params_ref->{'task_desc'})
  128.         if defined $all_params_ref->{'task_desc'};
  129.  
  130. ##################################
  131. #
  132. # error
  133. #
  134. # Simple function to display an
  135. # error, add a close window link
  136. # and finish the page off.
  137. #
  138. ##################################
  139. sub error
  140. {
  141.     my $text = shift || "Unknown";
  142.  
  143.     Utils::Error('ERROR', $text);
  144.  
  145.     print "<a href='javascript:void(null)' ".
  146.         "onclick='javascript:window.close()'>Close Window</a>";
  147.     print "</body></html>\n";
  148.     exit(0);
  149. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement