###############################################################################
# CP_MoveMessages.src                                                         #
###############################################################################
# UltraBoard 2000 by UltraScripts.com, Inc.                                   #
# Scripts written by Jacky Wing Wa Yung, WebMaster@UltraScripts.com           #
# Available from http://www.UltraBoard.org/                                   #
# =========================================================================== #
# COPYRIGHT NOTICE :                                                          #
#                                                                             #
# Copyright (c) 1999-2000 UltraScripts.com, Inc. All Rights Reserved.         #
#                                                                             #
# This program is being distributed as shareware. It may be used and modified #
# free for personal, government or non-profit. Any commercial use must be     #
# registered. However, modified versions cannot be sold or distributed. You   #
# cannot alter the copyright and "powered by" notices throughout the scripts. #
# These notices must be clearly visible to the end users.                     #
#                                                                             #
# WARRANTY DISCLAIMER:                                                        #
#                                                                             #
# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT #
# ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR       #
# FITNESS FOR A PARTICULAR PURPOSE.                                           #
###############################################################################

package Source;

sub MoveMessages {

  ( # querying data from categories table
    my ($Categories, $CateogriesIndex) = &DB::Query (
      TABLE   => "Categories",
      COLUMNS => ["ID", "TITLE"]
    )
  ) || &HTML::Error("Boards Management / Messages Management / Manage messages / Move messages", "No category available for you to choose yet.<br>Sorry, you have to <a href=\"$SYSTEM::CP_URL/Panel.$SYSTEM::EXT?action=CreateCategory\" target=\"UBBODY\">create a new category</a> first!");

  ( # querying data from categories table
    my ($DB) = &DB::Query (
      TABLE   => "Boards"       ,
      COLUMNS => ["ID", "TITLE", "CATEGORY"],
      SORT    => "POSITION"     ,
      BY      => "A-Z"
    )
  ) || &HTML::Error("Boards Management / Messages Management / Manage messages / Move messages", "No board available for you to choose yet.<br>Sorry, you have to <a href=\"$SYSTEM::CP_URL/Panel.$SYSTEM::EXT?action=CreateBoard\" target=\"UBBODY\">create a new board</a> first!");

  my $Boards;
  for (my $i = 0; $i <= $#{ $DB }; $i++) {
    push (
      @{ $Boards },
      {
        KEY   => $DB->[$i]{'ID'},
        VALUE => $Categories->[ $CateogriesIndex->{ $DB->[$i]{'CATEGORY'} } ]{'TITLE'}." / ".$DB->[$i]{'TITLE'}
      }
    );
  }

  my %FORM;
  $FORM{'FORM_BOARDS'} = &HTML::Select (
    NAME      => "FORM_BOARD",
    VALUE     => $Boards      ,
    EXTRA     => "style=\"width:100%\""
  );

  my @PIDS = $UB::CGI->param('PID');
  my $PIDS = join (",", @PIDS);

  &Standard::PrintHTMLHeader();
  print &HTML::Header;
  print<<HTML;
<form action="$SYSTEM::CP_URL/Panel.$SYSTEM::EXT" method="post">
<input type="hidden" name="action" value="DoMoveMessages">
<input type="hidden" name="PIDS" value="$PIDS">
<table width="100%" border="0" cellspacing="0" cellpadding="5">
  <tr bgcolor="Gray">
    <td><font color="White"><b>
      <a href="$SYSTEM::CP_URL/Panel.$SYSTEM::EXT?action=body" target="UBBODY" class="address">Control Panel</a> / Messages Management / Manage messages / Move messages
    </b></font></td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td>
      <table width="100%" border="0" cellspacing="0" cellpadding="2">
        <tr>
          <td>
            <table width="100%" border="1" cellspacing="0" cellpadding="3" bordercolordark="White" bordercolorlight="Gray">
              <tr>
                <td>
                  <table width="100%" border="0" cellspacing="0" cellpadding="2">
                    <tr>
                      <td>
                      Please fill out all required (<font color="Red"><b>*</b></font>) fields.
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
            &nbsp;<br>
            <table width="100%" border="1" cellspacing="0" cellpadding="3" bordercolordark="White" bordercolorlight="Gray">
              <tr>
                <td>
                  <table width="100%" border="0" cellspacing="0" cellpadding="2">
                    <tr>
                      <td width="100" valign="top" nowrap>Move to <font color="Red"><b>*</b></font></td>
                      <td width="100%">$FORM{'FORM_BOARDS'}</td>
                      <td width="20" valign="top" nowrap><img src="$SYSTEM::IMAGE_URL/help.gif" width=20 height=20 border=0 alt="move those messages to which board?"></td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
      <table width="100%" border="0" cellspacing="0" cellpadding="5">
        <tr>
          <td align="right"><input type="submit" value="Move">&nbsp;&nbsp;<input type="Reset" value="Cancel"></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</form>
</body>
</html>
HTML
}

###############################################################################
1; # end of CP_MoveMessages.src file
###############################################################################