Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php require ('php/bookings.php'); ?>
- <script type="text/javascript" src="forms/edit/js/bookings.js"></script>
- <script type="text/javascript">
- function dump(arr,level) {
- var dumped_text = "";
- if(!level) level = 0;
- //The padding given at the beginning of the line.
- var level_padding = "";
- for(var j=0;j<level+1;j++) level_padding += " ";
- if(typeof(arr) == 'object') { //Array/Hashes/Objects
- for(var item in arr) {
- var value = arr[item];
- if(typeof(value) == 'object') { //If it is an array,
- dumped_text += level_padding + "'" + item + "' ...\n";
- dumped_text += dump(value,level+1);
- } else {
- dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
- }
- }
- } else { //Stings/Chars/Numbers etc.
- dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
- }
- return dumped_text;
- }
- $(document).ready(function() {
- $('div.message-error').hide();
- $('div.message-success').hide();
- $('li').remove('.titleName');
- $('li').remove('.stipulationName');
- $('li').remove('.competitorName');
- for ( var matchNum = 0; matchNum < <?php echo $numMatches ?>; matchNum++ ) {
- var titlesCount = $('ul#titlesDefended'+ matchNum +' li').size();
- if(titlesCount == 0){$('ul#titlesDefended'+ matchNum).append('<li titleID="0" class="notitle">There are no titles being defended.</li>');}
- var stipulationsCount = $('ul#stipulationsAdded'+ matchNum +' li').size();
- if(stipulationsCount == 0){$('ul#stipulationsAdded'+ matchNum).append('<li stipulationID="0" class="nostipulation">There are no stipulations for this match.</li>');}
- var competitorsCount = $('ul#competitors'+ matchNum +' li').size();
- if(competitorsCount == 0){$('ul#competitors'+ matchNum).append('<li competitorID="0" class="nocompetitor">There are no competitors for this match.</li>');}
- }
- $("#bookerForm").validate({
- rules: {
- introduction: {
- required: true
- },
- matchtypeID: {
- required: true
- },
- liCompetitors: {
- required: true
- },
- matchwriterID: {
- required: true
- },
- matchTitle: {
- required: true
- },
- preview: {
- required: true
- },
- segment: {
- required: true
- }
- },
- messages: {
- introduction: "Please enter the event introduction!",
- matchtypeID: "Please choose the type of match!",
- liCompetitors: "Please choose atleast 2 competitors!",
- matchwriterID: "Please choose a match writer!",
- matchTitle: "Please enter a match title!",
- preview: "Please enter a preview!",
- segment: "Please choose a segment writer!"
- },
- submitHandler: function(form) {
- var eventName = $("#event").val();
- var eventID = $("#eventID").val();
- var introduction = $("#introduction").val();
- var type = $("#type").val();
- var subArray = new Array;
- var matchArray = new Array;
- var matchArrayIndex = 0;
- var segmentArray = new Array;
- var segmentArrayIndex = 0;
- var matchNumX = new Array;
- var matchTypeIDX = new Array;
- var titlesIDListX = new Array;
- var stipulationsIDListX = new Array;
- var competitorsIDListX = new Array;
- var matchWriterIDX = new Array;
- var matchTitleX = new Array;
- var previewX = new Array;
- var segmentNumX = new Array;
- var segmentWriterIDX = new Array;
- var segmentOrderX = new Array;
- var i = 0;
- for(i=0;i<<?php echo $numMatches ?>; i++) {
- var matchNum = i + 1;
- var matchTypeID = $('select#matchTypeDrop'+ matchNum).val();
- var liTitles = $('ul#titlesDefended'+ matchNum +' li');
- var titlesIDList = "";
- var j = 0;
- $('ul#titlesDefended'+ matchNum +' li').each(function(){
- var liTitle = $( liTitles[ j ] );
- // only start appending commas in after the first characterID
- if( j > 0 ) {
- titlesIDList += ",";
- }
- // append the current li element's characterID to the list
- titlesIDList += liTitle.attr( 'titleID' );
- j++;
- });
- var j = 0;
- var liStipulations = $('ul#stipulationsAdded'+ matchNum +' li');
- //alert(liStipulations);
- var stipulationsIDList = "";
- $('ul#stipulationsAdded'+ matchNum +' li').each(function(){
- var liStipulation = $( liStipulations[ j ] );
- //alert(liStipulation);
- // only start appending commas in after the first characterID
- if( j > 0 ) {
- stipulationsIDList += ",";
- }
- // append the current li element's characterID to the list
- stipulationsIDList += liStipulation.attr( 'stipulationID' );
- //alert(liStipulation.attr( 'stipulationID' ));
- j++;
- });
- //alert(stipulationsIDList);
- var j = 0;
- var liCompetitors = $('ul#competitors'+ matchNum +' li');
- var competitorsIDList = "";
- $('ul#competitors'+ matchNum +' li').each(function(){
- var liCompetitor = $( liCompetitors[ j ] );
- // only start appending commas in after the first characterID
- if( j > 0 ) {
- competitorsIDList += ",";
- }
- // append the current li element's characterID to the list
- competitorsIDList += liCompetitor.attr( 'competitorID' );
- j++;
- });
- var matchWriterID = $('select#matchWriter' + matchNum + '').val();
- var matchTitle = $('input#matchTitle'+ matchNum +'').val();
- var preview = $('textarea#preview'+ matchNum +'').val();
- matchNumX.push(matchNum);
- matchTypeIDX.push(matchTypeID);
- titlesIDListX.push(titlesIDList);
- stipulationsIDListX.push(stipulationsIDList);
- competitorsIDListX.push(competitorsIDList);
- matchWriterIDX.push(matchWriterID);
- matchTitleX.push(matchTitle);
- previewX.push(preview);
- matchArray[matchArrayIndex] = new Object();
- matchArray[matchArrayIndex]['matchNum'] = matchNumX;
- matchArray[matchArrayIndex]['matchtypeID'] = matchTypeIDX;
- matchArray[matchArrayIndex]['titlesIDList'] = titlesIDListX;
- matchArray[matchArrayIndex]['stipulationsIDList'] = stipulationsIDListX;
- matchArray[matchArrayIndex]['competitorsIDList'] = competitorsIDListX;
- matchArray[matchArrayIndex]['matchWriterID'] = matchWriterIDX;
- matchArray[matchArrayIndex]['matchTitle'] = matchTitleX;
- matchArray[matchArrayIndex]['preview'] = previewX;
- }
- for(i=0;i<<?php echo $numSegments ?>; i++) {
- var segmentNum = i + 1;
- var segmentWriterID = $('select#segmentWriter' + segmentNum + '').val();
- var segmentOrder = $('select#segmentOrder' + segmentNum + '').val();
- segmentNumX.push(segmentNum);
- segmentWriterIDX.push(segmentWriterID);
- segmentOrderX.push(segmentOrder);
- segmentArray[segmentArrayIndex] = new Object();
- segmentArray[segmentArrayIndex]['segmentNumber'] = segmentNumX;
- segmentArray[segmentArrayIndex]['segmentWriterID'] = segmentWriterIDX;
- segmentArray[segmentArrayIndex]['segmentOrder'] = segmentOrderX;
- }
- alert(dump(subArray));
- var dataString = 'matchArray=' + matchArray;
- dataString += '&eventID=' + eventID + '&introduction=' + introduction + '&submitBooking=True';
- $.ajax({
- type: "POST",
- url: "processes/bookings.php",
- data: dataString,
- success: function() {
- $('div.message-error').hide();
- $("div.message-success").html("<h6>Operation successful</h6><p>" + eventName + " saved successfully.</p>");
- $("div.message-success").show().delay(10000).hide("slow");
- return true;
- }
- });
- return false;
- }
- });
- });
- </script>
- <p class="listInfos">
- Card Lineup for <?php echo "".$event." on ".$bookingDate."" ?>
- </p>
- <!-- Form -->
- <form action="#" id="bookerForm" >
- <fieldset>
- <legend>Introduction</legend>
- <div class="field required">
- <label for="introduction">Introduction:</label>
- <textarea name="introduction" id="introduction" title="Introduction"></textarea>
- <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>
- </div>
- </fieldset>
- <?php for( $i = 0; $i < $numMatches; $i++ ) { ?>
- <fieldset>
- <legend>Match #<?php echo $i+1 ?></legend>
- <div class="field required">
- <label for="matchTypeDrop<?php echo $i+1 ?>">Match Type:</label>
- <select class="dropdown" name="matchTypeDrop<?php echo $i+1 ?>" id="matchTypeDrop<?php echo $i+1 ?>" title="Match Type <?php echo $i+1 ?>">
- <option value="">- Select -</option>
- <?php
- mysqli_data_seek( $matchtypesResult, 0 );
- while ( $row = mysqli_fetch_array ( $matchtypesResult, MYSQL_ASSOC ) ) {
- print "<option value=\"".$row['ID']."\">".$row['matchType']."</option>\r";
- }
- ?>
- </select>
- <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>
- </div>
- <div class="field required">
- <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>
- <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;">
- <option value="">- Select -</option>
- <?php
- mysqli_data_seek( $titlesResult, 0 );
- while ( $row = mysqli_fetch_array ( $titlesResult, MYSQL_ASSOC ) ) {
- print "<option value=\"".$row['ID']."\">".$row['titleName']."</option>\r";
- }
- ?>
- </select>
- <input type="button" value="Add Title" class="" onclick="TitlesDefended(<?php echo $i+1?>)"/>
- </div>
- <div class="field required">
- <label for="stipulationsAdded<?php echo $i+1 ?>">Stipulation:</label><ul id="stipulationsAdded<?php echo $i+1 ?>" style="list-style: none; margin-left: 195px;"></ul>
- <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;">
- <option value="">- Select -</option>
- <?php
- mysqli_data_seek( $stipulationsResult, 0 );
- while ( $row = mysqli_fetch_array ( $stipulationsResult, MYSQL_ASSOC ) ) {
- print "<option value=\"".$row['ID']."\">".$row['stipulation']."</option>\r";
- }
- ?>
- </select>
- <input type="button" value="Add Stipulation" class="" onclick="StipulationsAdded(<?php echo $i+1 ?>)"/>
- </div>
- <div class="field required">
- <label for="competitors<?php echo $i+1 ?>">Competitors:</label><ul id="competitors<?php echo $i+1 ?>" style="list-style: none; margin-left: 195px;"></ul>
- <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;">
- <option value="">- Select -</option>
- <?php
- mysqli_data_seek( $charactersResult, 0 );
- while ( $row = mysqli_fetch_array ( $charactersResult, MYSQL_ASSOC ) ) {
- print "<option value=\"".$row['ID']."\">".$row['characterName']."</option>\r";
- }
- ?>
- </select>
- <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>
- <input type="button" value="Add Character" class="" onclick="Competitors(<?php echo $i+1 ?>)"/>
- </div>
- <div class="field required">
- <label for="matchWriter<?php echo $i+1 ?>">Match Writer:</label>
- <select class="dropdown" name="matchWriter<?php echo $i+1 ?>" id="matchWriter<?php echo $i+1 ?>" title="Match Writer <?php echo $i+1 ?>">
- <option value="0">- Select -</option>
- <?php
- mysqli_data_seek( $matchwriterResult, 0 );
- while ( $row = mysqli_fetch_array ( $matchwriterResult, MYSQL_ASSOC ) ) {
- print "<option value=\"".$row['ID']."\">".$row['name']."</option>\r";
- }
- ?>
- </select>
- <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>
- </div>
- <div class="field required">
- <label for="matchTitle<?php echo $i+1 ?>">Match Title</label>
- <input type="text" class="text" name="matchTitle<?php echo $i+1 ?>" id="matchTitle<?php echo $i+1 ?>" title="Match Title<?php echo $i+1 ?>"/>
- <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>
- </div>
- <div class="field required">
- <label for="preview<?php echo $i+1 ?>">Preview:</label>
- <textarea name="preview<?php echo $i+1 ?>" id="preview<?php echo $i+1 ?>" title="preview <?php echo $i+1 ?>"></textarea>
- <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>
- </div>
- <input type="hidden" name="type" id="type" value="Match" />
- </fieldset>
- <?php
- }
- ?>
- <?php if ($numSegments > 0) { ?>
- <?php for( $i = 0; $i < $numSegments; $i++ ) { ?>
- <fieldset>
- <legend>Segment <?php echo $i+1 ?></legend>
- <div class="field required">
- <label for="segmentWriter<?php echo $i+1 ?>">Segment Writer:</label>
- <select class="dropdown" name="segmentWriter<?php echo $i+1 ?>" id="segmentWriter<?php echo $i+1 ?>" title="Segment Writer <?php echo $i+1 ?>">
- <option value="0">- Select -</option>
- <?php
- mysqli_data_seek( $matchwriterResult, 0 );
- while ( $row = mysqli_fetch_array ( $matchwriterResult, MYSQL_ASSOC ) ) {
- print "<option value=\"".$row['ID']."\">".$row['name']."</option>\r";
- }
- ?>
- </select>
- <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>
- </div>
- <div class="field required">
- <label for="segmentOrder<?php echo $i+1 ?>">Segment After:</label>
- <select class="dropdown" name="segmentOrder<?php echo $i+1 ?>" id="segmentOrder<?php echo $i+1 ?>" title="Segment Order <?php echo $i+1 ?>">
- <option value="0">- Select -</option>
- <option value="introduction">Introduction</option>
- <?php
- for( $j = 1; $j <= $numMatches; $j++ ) {
- print "<option value=$j>Match $j</option>\r";
- }
- ?>
- </select>
- <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>
- </div>
- <input type="hidden" name="type" id="type" value="Segment" />
- </fieldset>
- <? } ?>
- <?php } ?>
- <fieldset>
- <input type="hidden" name="eventID" id="eventID" value="<?php echo $eventID; ?>" />
- <input type="hidden" name="event" id="event" value="<?php echo $event; ?>" />
- <input type="submit" class="submit" name="submitBooking" id="submitBooking" title="Submit Booking" value="Submit Booking"/>
- </fieldset>
- </form>
- <!-- /Form -->
- <!-- Messages -->
- <div class="message message-error">
- <h6>Required field missing</h6>
- <p>Please fill in all required fields. </p>
- </div>
- <div class="message message-success">
- <h6>Operation succesful</h6>
- <p>Booking was added to the database.</p>
- </div>
- <!-- /Messages -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement