Advertisement
Guest User

Untitled

a guest
Apr 24th, 2011
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php require ('php/bookings.php'); ?>
  2.  
  3. <script type="text/javascript" src="forms/edit/js/bookings.js"></script>
  4.  
  5. <script type="text/javascript">
  6. function dump(arr,level) {
  7.  var dumped_text = "";
  8.  if(!level) level = 0;
  9.  
  10.  //The padding given at the beginning of the line.
  11.  var level_padding = "";
  12.  for(var j=0;j<level+1;j++) level_padding += "    ";
  13.  
  14.  if(typeof(arr) == 'object') { //Array/Hashes/Objects
  15.   for(var item in arr) {
  16.    var value = arr[item];
  17.    
  18.    if(typeof(value) == 'object') { //If it is an array,
  19.     dumped_text += level_padding + "'" + item + "' ...\n";
  20.     dumped_text += dump(value,level+1);
  21.    } else {
  22.     dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
  23.    }
  24.   }
  25.  } else { //Stings/Chars/Numbers etc.
  26.   dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
  27.  }
  28.  return dumped_text;
  29. }
  30. $(document).ready(function() {
  31.     $('div.message-error').hide();
  32.     $('div.message-success').hide();
  33.     $('li').remove('.titleName');  
  34.     $('li').remove('.stipulationName');
  35.     $('li').remove('.competitorName');
  36.    
  37.     for ( var matchNum = 0; matchNum < <?php echo $numMatches ?>; matchNum++ ) {
  38.         var titlesCount = $('ul#titlesDefended'+ matchNum +' li').size();
  39.         if(titlesCount == 0){$('ul#titlesDefended'+ matchNum).append('<li titleID="0" class="notitle">There are no titles being defended.</li>');}
  40.         var stipulationsCount = $('ul#stipulationsAdded'+ matchNum +' li').size();
  41.         if(stipulationsCount == 0){$('ul#stipulationsAdded'+ matchNum).append('<li stipulationID="0" class="nostipulation">There are no stipulations for this match.</li>');}
  42.         var competitorsCount = $('ul#competitors'+ matchNum +' li').size();
  43.         if(competitorsCount == 0){$('ul#competitors'+ matchNum).append('<li competitorID="0" class="nocompetitor">There are no competitors for this match.</li>');}
  44.     }
  45.    
  46.     $("#bookerForm").validate({
  47.         rules: {
  48.             introduction: {
  49.                 required: true
  50.             },
  51.             matchtypeID: {
  52.                 required: true
  53.             },
  54.             liCompetitors: {
  55.                 required: true
  56.             },
  57.             matchwriterID: {
  58.                 required: true
  59.             },
  60.             matchTitle: {
  61.                 required: true
  62.             },
  63.             preview: {
  64.                 required: true
  65.             },
  66.             segment: {
  67.                 required: true
  68.             }
  69.         },
  70.         messages: {
  71.             introduction: "Please enter the event introduction!",
  72.             matchtypeID: "Please choose the type of match!",
  73.             liCompetitors: "Please choose atleast 2 competitors!",
  74.             matchwriterID: "Please choose a match writer!",
  75.             matchTitle: "Please enter a match title!",
  76.             preview: "Please enter a preview!",
  77.             segment: "Please choose a segment writer!"
  78.         },
  79.         submitHandler: function(form) {
  80.             var eventName = $("#event").val();
  81.             var eventID = $("#eventID").val();
  82.             var introduction = $("#introduction").val();
  83.             var type = $("#type").val();
  84.             var subArray = new Array;
  85.             var matchArray = new Array;
  86.             var matchArrayIndex = 0;
  87.             var segmentArray = new Array;
  88.             var segmentArrayIndex = 0;
  89.             var matchNumX = new Array;
  90.             var matchTypeIDX = new Array;
  91.             var titlesIDListX = new Array;
  92.             var stipulationsIDListX = new Array;
  93.             var competitorsIDListX = new Array;
  94.             var matchWriterIDX = new Array;
  95.             var matchTitleX = new Array;
  96.             var previewX = new Array;
  97.             var segmentNumX = new Array;
  98.             var segmentWriterIDX = new Array;
  99.             var segmentOrderX = new Array;
  100.             var i = 0;
  101.             for(i=0;i<<?php echo $numMatches ?>; i++) {
  102.                 var matchNum = i + 1;
  103.                 var matchTypeID = $('select#matchTypeDrop'+ matchNum).val();  
  104.                 var liTitles = $('ul#titlesDefended'+ matchNum +' li');
  105.                 var titlesIDList = "";
  106.                 var j = 0;
  107.                 $('ul#titlesDefended'+ matchNum +' li').each(function(){
  108.                     var liTitle = $( liTitles[ j ] );
  109.                    
  110.                     // only start appending commas in after the first characterID
  111.                     if( j > 0 ) {
  112.                         titlesIDList += ",";
  113.                     }
  114.                    
  115.                     // append the current li element's characterID to the list
  116.                     titlesIDList += liTitle.attr( 'titleID' );
  117.                     j++;
  118.                 });
  119.                 var j = 0;
  120.                 var liStipulations = $('ul#stipulationsAdded'+ matchNum +' li');
  121.                 //alert(liStipulations);
  122.                 var stipulationsIDList = "";
  123.                 $('ul#stipulationsAdded'+ matchNum +' li').each(function(){
  124.                     var liStipulation = $( liStipulations[ j ] );
  125.                     //alert(liStipulation);
  126.                    
  127.                     // only start appending commas in after the first characterID
  128.                     if( j > 0 ) {
  129.                         stipulationsIDList += ",";
  130.                     }
  131.                    
  132.                     // append the current li element's characterID to the list
  133.                     stipulationsIDList += liStipulation.attr( 'stipulationID' );
  134.                     //alert(liStipulation.attr( 'stipulationID' ));
  135.                     j++;
  136.                 });
  137.                 //alert(stipulationsIDList);
  138.                 var j = 0;
  139.                 var liCompetitors = $('ul#competitors'+ matchNum +' li');
  140.                 var competitorsIDList = "";
  141.                 $('ul#competitors'+ matchNum +' li').each(function(){
  142.                     var liCompetitor = $( liCompetitors[ j ] );
  143.                    
  144.                     // only start appending commas in after the first characterID
  145.                     if( j > 0 ) {
  146.                         competitorsIDList += ",";
  147.                     }
  148.                    
  149.                     // append the current li element's characterID to the list
  150.                     competitorsIDList += liCompetitor.attr( 'competitorID' );
  151.                     j++;
  152.                 });
  153.                 var matchWriterID = $('select#matchWriter' + matchNum + '').val();
  154.                 var matchTitle = $('input#matchTitle'+ matchNum +'').val();
  155.                 var preview = $('textarea#preview'+ matchNum +'').val();
  156.                 matchNumX.push(matchNum);
  157.                 matchTypeIDX.push(matchTypeID);
  158.                 titlesIDListX.push(titlesIDList);
  159.                 stipulationsIDListX.push(stipulationsIDList);
  160.                 competitorsIDListX.push(competitorsIDList);
  161.                 matchWriterIDX.push(matchWriterID);
  162.                 matchTitleX.push(matchTitle);
  163.                 previewX.push(preview);
  164.                 matchArray[matchArrayIndex] = new Object();              
  165.                 matchArray[matchArrayIndex]['matchNum'] = matchNumX;
  166.                 matchArray[matchArrayIndex]['matchtypeID'] = matchTypeIDX;
  167.                 matchArray[matchArrayIndex]['titlesIDList'] = titlesIDListX;
  168.                 matchArray[matchArrayIndex]['stipulationsIDList'] = stipulationsIDListX;
  169.                 matchArray[matchArrayIndex]['competitorsIDList'] = competitorsIDListX;
  170.                 matchArray[matchArrayIndex]['matchWriterID'] = matchWriterIDX;
  171.                 matchArray[matchArrayIndex]['matchTitle'] = matchTitleX;
  172.                 matchArray[matchArrayIndex]['preview'] = previewX;
  173.             }
  174.             for(i=0;i<<?php echo $numSegments ?>; i++) {
  175.                 var segmentNum = i + 1;
  176.                 var segmentWriterID = $('select#segmentWriter' + segmentNum + '').val();
  177.                 var segmentOrder = $('select#segmentOrder' + segmentNum + '').val();
  178.                 segmentNumX.push(segmentNum);
  179.                 segmentWriterIDX.push(segmentWriterID);
  180.                 segmentOrderX.push(segmentOrder);
  181.                 segmentArray[segmentArrayIndex] = new Object();              
  182.                 segmentArray[segmentArrayIndex]['segmentNumber'] = segmentNumX;
  183.                 segmentArray[segmentArrayIndex]['segmentWriterID'] = segmentWriterIDX;
  184.                 segmentArray[segmentArrayIndex]['segmentOrder'] = segmentOrderX;
  185.             }
  186.             alert(dump(subArray));
  187.             var dataString = 'matchArray=' + matchArray;
  188.             dataString += '&eventID=' + eventID + '&introduction=' + introduction + '&submitBooking=True';  
  189.             $.ajax({
  190.                 type: "POST",
  191.                 url: "processes/bookings.php",
  192.                 data: dataString,
  193.                 success: function() {
  194.                     $('div.message-error').hide();
  195.                     $("div.message-success").html("<h6>Operation successful</h6><p>" + eventName + " saved successfully.</p>");
  196.                     $("div.message-success").show().delay(10000).hide("slow");
  197.                     return true;
  198.                 }
  199.             });
  200.             return false;
  201.         }    
  202.     });
  203. });
  204. </script>
  205.  
  206. <p class="listInfos">
  207.     Card Lineup for <?php echo "".$event." on ".$bookingDate."" ?>
  208. </p>
  209.        
  210. <!-- Form -->
  211. <form action="#" id="bookerForm" >
  212.     <fieldset>
  213.         <legend>Introduction</legend>
  214.         <div class="field required">
  215.             <label for="introduction">Introduction:</label>
  216.             <textarea name="introduction" id="introduction" title="Introduction"></textarea>
  217.             <span class="required-icon tooltip" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span>
  218.         </div>
  219.     </fieldset>
  220.     <?php for( $i = 0; $i < $numMatches; $i++ ) { ?>
  221.     <fieldset>
  222.         <legend>Match #<?php echo $i+1 ?></legend>
  223.         <div class="field required">
  224.             <label for="matchTypeDrop<?php echo $i+1 ?>">Match Type:</label>
  225.             <select class="dropdown" name="matchTypeDrop<?php echo $i+1 ?>" id="matchTypeDrop<?php echo $i+1 ?>" title="Match Type <?php echo $i+1 ?>">
  226.                 <option value="">- Select -</option>
  227.                <?php
  228.                     mysqli_data_seek( $matchtypesResult, 0 );
  229.                     while ( $row = mysqli_fetch_array ( $matchtypesResult, MYSQL_ASSOC ) ) {
  230.                         print "<option value=\"".$row['ID']."\">".$row['matchType']."</option>\r";
  231.                     }
  232.                 ?>
  233.             </select>
  234.             <span class="required-icon tooltip" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span>
  235.         </div>
  236.         <div class="field required">
  237.             <label for="titlesDefended<?php echo $i+1 ?>">Title On The Line:</label><ul id="titlesDefended<?php echo $i+1 ?>" style="list-style: none; margin-left: 195px;"></ul>
  238.             <select class="dropdown" name="titlesDrop<?php echo $i+1 ?>" id="titlesDrop<?php echo $i+1 ?>" title="Titles Dropdown <?php echo $i+1 ?>" style="margin-left: 195px;">
  239.                 <option value="">- Select -</option>
  240.                <?php
  241.                     mysqli_data_seek( $titlesResult, 0 );
  242.                     while ( $row = mysqli_fetch_array ( $titlesResult, MYSQL_ASSOC ) ) {
  243.                         print "<option value=\"".$row['ID']."\">".$row['titleName']."</option>\r";
  244.                     }
  245.                 ?>
  246.             </select>
  247.             <input type="button" value="Add Title" class="" onclick="TitlesDefended(<?php echo $i+1?>)"/>
  248.         </div>
  249.         <div class="field required">
  250.             <label for="stipulationsAdded<?php echo $i+1 ?>">Stipulation:</label><ul id="stipulationsAdded<?php echo $i+1 ?>" style="list-style: none; margin-left: 195px;"></ul>
  251.             <select class="dropdown" name="stipulationsDrop<?php echo $i+1 ?>" id="stipulationsDrop<?php echo $i+1 ?>" title="Stipulations Dropown <?php echo $i+1 ?>" style="margin-left: 195px;">
  252.                 <option value="">- Select -</option>
  253.                <?php
  254.                     mysqli_data_seek( $stipulationsResult, 0 );
  255.                     while ( $row = mysqli_fetch_array ( $stipulationsResult, MYSQL_ASSOC ) ) {
  256.                         print "<option value=\"".$row['ID']."\">".$row['stipulation']."</option>\r";
  257.                     }
  258.                 ?>
  259.             </select>
  260.             <input type="button" value="Add Stipulation" class="" onclick="StipulationsAdded(<?php echo $i+1 ?>)"/>
  261.         </div>
  262.         <div class="field required">
  263.             <label for="competitors<?php echo $i+1 ?>">Competitors:</label><ul id="competitors<?php echo $i+1 ?>" style="list-style: none; margin-left: 195px;"></ul>
  264.             <select class="dropdown" name="charactersDrop<?php echo $i+1 ?>" id="charactersDrop<?php echo $i+1 ?>" title="Characters Dropdown <?php echo $i+1 ?>" style="margin-left: 195px;">
  265.                 <option value="">- Select -</option>
  266.                <?php
  267.                     mysqli_data_seek( $charactersResult, 0 );
  268.                     while ( $row = mysqli_fetch_array ( $charactersResult, MYSQL_ASSOC ) ) {
  269.                         print "<option value=\"".$row['ID']."\">".$row['characterName']."</option>\r";
  270.                     }
  271.                 ?>
  272.             </select>
  273.             <span class="required-icon tooltip" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span>
  274.             <input type="button" value="Add Character" class="" onclick="Competitors(<?php echo $i+1 ?>)"/>
  275.         </div>
  276.         <div class="field required">
  277.             <label for="matchWriter<?php echo $i+1 ?>">Match Writer:</label>
  278.             <select class="dropdown" name="matchWriter<?php echo $i+1 ?>" id="matchWriter<?php echo $i+1 ?>" title="Match Writer <?php echo $i+1 ?>">
  279.                 <option value="0">- Select -</option>
  280.                <?php
  281.                     mysqli_data_seek( $matchwriterResult, 0 );
  282.                     while ( $row = mysqli_fetch_array ( $matchwriterResult, MYSQL_ASSOC ) ) {
  283.                         print "<option value=\"".$row['ID']."\">".$row['name']."</option>\r";
  284.                     }
  285.                ?>
  286.             </select>
  287.             <span class="required-icon tooltip" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span>
  288.         </div>
  289.         <div class="field required">
  290.             <label for="matchTitle<?php echo $i+1 ?>">Match Title</label>
  291.             <input type="text" class="text" name="matchTitle<?php echo $i+1 ?>" id="matchTitle<?php echo $i+1 ?>" title="Match Title<?php echo $i+1 ?>"/>
  292.             <span class="required-icon tooltip" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span>
  293.         </div>
  294.         <div class="field required">
  295.             <label for="preview<?php echo $i+1 ?>">Preview:</label>
  296.             <textarea name="preview<?php echo $i+1 ?>" id="preview<?php echo $i+1 ?>" title="preview <?php echo $i+1 ?>"></textarea>
  297.             <span class="required-icon tooltip" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span>
  298.         </div>
  299.         <input type="hidden" name="type" id="type" value="Match" />
  300.     </fieldset>
  301.         <?php
  302.         }
  303.         ?>
  304.        
  305.     <?php if ($numSegments > 0) { ?>
  306.         <?php for( $i = 0; $i < $numSegments; $i++ ) { ?>
  307.             <fieldset>
  308.                 <legend>Segment <?php echo $i+1 ?></legend>
  309.                     <div class="field required">
  310.                         <label for="segmentWriter<?php echo $i+1 ?>">Segment Writer:</label>
  311.                         <select class="dropdown" name="segmentWriter<?php echo $i+1 ?>" id="segmentWriter<?php echo $i+1 ?>" title="Segment Writer <?php echo $i+1 ?>">
  312.                         <option value="0">- Select -</option>
  313.                        <?php
  314.                             mysqli_data_seek( $matchwriterResult, 0 );
  315.                             while ( $row = mysqli_fetch_array ( $matchwriterResult, MYSQL_ASSOC ) ) {
  316.                                 print "<option value=\"".$row['ID']."\">".$row['name']."</option>\r";
  317.                             }
  318.                        ?>
  319.                     </select>
  320.                         <span class="required-icon tooltip" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span>
  321.                     </div>
  322.                     <div class="field required">
  323.                         <label for="segmentOrder<?php echo $i+1 ?>">Segment After:</label>
  324.                         <select class="dropdown" name="segmentOrder<?php echo $i+1 ?>" id="segmentOrder<?php echo $i+1 ?>" title="Segment Order <?php echo $i+1 ?>">
  325.                         <option value="0">- Select -</option>
  326.                         <option value="introduction">Introduction</option>
  327.                        <?php
  328.                             for( $j = 1; $j <= $numMatches; $j++ ) {
  329.                                 print "<option value=$j>Match $j</option>\r";
  330.                             }
  331.                        ?>
  332.                     </select>
  333.                         <span class="required-icon tooltip" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span>
  334.                     </div>
  335.                     <input type="hidden" name="type" id="type" value="Segment" />
  336.             </fieldset>
  337.         <? } ?>
  338.     <?php } ?>
  339.        
  340.     <fieldset>
  341.     <input type="hidden" name="eventID" id="eventID" value="<?php echo $eventID; ?>" />
  342.     <input type="hidden" name="event" id="event" value="<?php echo $event; ?>" />
  343.     <input type="submit" class="submit" name="submitBooking" id="submitBooking" title="Submit Booking" value="Submit Booking"/>
  344.     </fieldset>
  345. </form>
  346. <!-- /Form -->
  347.  
  348. <!-- Messages -->
  349. <div class="message message-error">
  350.     <h6>Required field missing</h6>
  351.     <p>Please fill in all required fields. </p>
  352. </div>
  353. <div class="message message-success">
  354.     <h6>Operation succesful</h6>
  355.     <p>Booking was added to the database.</p>
  356. </div>
  357. <!-- /Messages -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement