/modules/altinn/termins.php

https://github.com/mblix/ODOL · PHP · 148 lines · 127 code · 11 blank · 10 comment · 22 complexity · 43590654480ea2b3fbbf0d21cd4cb5f8 MD5 · raw file

  1. <?php
  2. /****************************************************************************
  3. ** Copyright (c) 2005 Actra AS.
  4. ** All rights reserved!
  5. **
  6. ** Developed by Gunnar Skeid (gunnar@actra.no)
  7. **
  8. ** Prints out MVA termins of the user in order to let the user do things
  9. ** with the termins, like sending a report to AltInn.
  10. ****************************************************************************/
  11. require_once '_include/class_lodo.php';
  12. require_once '_include/class_layout.php';
  13. require_once '_include/class_database.php';
  14. require_once '_include/class_mva.php';
  15. require_once '_include/class_config.php';
  16. $lodo = new lodo();
  17. $db = new Db( $lodo );
  18. if ( !$db->Connect() ) {
  19. $layout->PrintError("Kunne ikke koble til databasen.");
  20. die();
  21. }
  22. $layout = new Layout( $lodo );
  23. $mva = new Mva( $db );
  24. $config = new Config( $db );
  25. /* Configure range for years. Default is the current year. */
  26. $yearLow = 2004;
  27. $yearHigh = date("Y");
  28. $year = $_REQUEST['year'];
  29. if ($year == '' || !is_numeric($year)) {$year = date("Y");}
  30. $layout->PrintHead( "AltInn" );
  31. if ( $lodo->inLodo ) {
  32. includeinc('top');
  33. includeinc('left');
  34. }
  35. ?>
  36. <h1>MVA-terminer</h1>
  37. <h2>År</h2>
  38. <p>
  39. <?php
  40. for ($yearCounter = $yearLow; $yearCounter <= $yearHigh; $yearCounter++)
  41. {
  42. if ( $yearCounter == $year ) {echo('<strong>');}
  43. ?>
  44. <a href="<?php echo($lodo->LodoUrlSelf( "", $lodo->LODOURLTYPE_HREF ));?>&amp;year=<?php echo($yearCounter);?>"><?php echo($yearCounter);?></a>
  45. <?php
  46. if ( $yearCounter == $year ) {echo('</strong>');}
  47. }
  48. ?>
  49. </p>
  50. <?php
  51. $terminList = $mva->GetTerminListRange( $config->GetConfig( $config->TYPE_TERMIN ), mktime(0,0,0,1,1,$year), mktime(23,59,59,12,31,$year) );
  52. ?>
  53. <table>
  54. <tr>
  55. <th>#</th>
  56. <th>År</th>
  57. <th>Termin</th>
  58. <th>Sendinger</th>
  59. <th>Kladder</th>
  60. <th></th>
  61. </tr>
  62. <?php
  63. foreach ( $terminList as $key => $value )
  64. {
  65. ?>
  66. <tr>
  67. <td><?php echo( $terminList[ $key ]['terminitem'] );?></td>
  68. <td><?php echo( $terminList[ $key ]['year'] );?></td>
  69. <td><?php echo( $terminList[ $key ]['terminname'] );?></td>
  70. <?php
  71. $sqlStr = 'SELECT COUNT(*) FROM altinn_packet WHERE customer_id=' . $lodo->lodoCurrentClientId .
  72. ' AND status>0' .
  73. ' AND year=' . $terminList[ $key ]['year'] .
  74. ' AND termin=' . $terminList[ $key ]['terminitem'] .
  75. ' AND termintype=' . $config->GetConfig( $config->TYPE_TERMIN );
  76. if ( $rs = $db->Query( $sqlStr ) )
  77. {
  78. if ( $row = $db->NextRow( $rs ) )
  79. {
  80. $packages = $row[0];
  81. }
  82. $db->EndQuery( $rs );
  83. }
  84. if ($packages > 0)
  85. {
  86. if ($packages < 2) {
  87. $txtSending = "sending";
  88. }
  89. else {
  90. $txtSending = "sendinger";
  91. }
  92. ?>
  93. <td><?php echo($packages);?> <?php echo($txtSending);?> [<a href="<?php echo($lodo->LodoUrlGet( '', $lodo->LODOURLTYPE_HREF, 'altinn.packages' ));?>&amp;terminitem=<?php echo( $terminList[ $key ]['terminitem'] );?>&amp;year=<?php echo( $terminList[ $key ]['year'] );?>&amp;status=1">Vis</a>]</td>
  94. <?php
  95. }
  96. else {
  97. echo('<td>&#160;</td>');
  98. }
  99. $sqlStr = 'SELECT COUNT(*) FROM altinn_packet WHERE customer_id=' . $lodo->lodoCurrentClientId .
  100. ' AND status<1' .
  101. ' AND year=' . $terminList[ $key ]['year'] .
  102. ' AND termin=' . $terminList[ $key ]['terminitem'] .
  103. ' AND termintype=' . $config->GetConfig( $config->TYPE_TERMIN );
  104. if ( $rs = $db->Query( $sqlStr ) )
  105. {
  106. if ( $row = $db->NextRow( $rs ) )
  107. {
  108. $packages = $row[0];
  109. }
  110. $db->EndQuery( $rs );
  111. }
  112. if ($packages > 0)
  113. {
  114. if ($packages < 2) {
  115. $txtSending = "kladd";
  116. }
  117. else {
  118. $txtSending = "kladder";
  119. }
  120. ?>
  121. <td><?php echo($packages);?> <?php echo($txtSending);?> [<a href="<?php echo($lodo->LodoUrlGet( '', $lodo->LODOURLTYPE_HREF, 'altinn.packages' ));?>&amp;terminitem=<?php echo( $terminList[ $key ]['terminitem'] );?>&amp;year=<?php echo( $terminList[ $key ]['year'] );?>&amp;status=0">Editer</a>]</td>
  122. <?php
  123. }
  124. else {
  125. echo('<td>&#160;</td>');
  126. }
  127. ?>
  128. <td>[<a href="<?php echo($lodo->LodoUrlGet( '', $lodo->LODOURLTYPE_HREF, 'altinn.packagemva' ));?>&amp;terminitem=<?php echo( $terminList[ $key ]['terminitem'] );?>&amp;year=<?php echo( $terminList[ $key ]['year'] );?>">Nytt skjema</a>]</td>
  129. </tr>
  130. <?php
  131. }
  132. ?>
  133. </table>
  134. <?php
  135. $layout->PrintFoot( );
  136. $db->Disconnect();
  137. ?>