Jump to content

To get the pagination for the schedules to work


Strider

Recommended Posts

  • 1 month later...

hello guys

I tried to run the scrip on my site but nothing.

Someone can help me?

i copy the file

jquery.js

jquery.dataTables.js

jquery.dataTables.min.js

in lib/js/

i copy the image in:

in lib/images

This is my core_htmlhead.tpl

?>

<script type="text/javascript">

var baseurl = "<?php echo SITE_URL;?>";

var geourl = "<?php echo GEONAME_URL; ?>";

</script>

<link rel="stylesheet" media="all" type="text/css" href="<?php echo fileurl('lib/css/phpvms.css')?>" />

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo Config::Get('PAGE_ENCODING');?>" />

<script type="text/javascript" src="http://ajax.googleap...n.js"></script>

<script type="text/javascript" src="http://ajax.googleap...n.js"></script>

<script type="text/javascript" src="http://maps.google.c...true"></script>

<script type="text/javascript" src="<?php echo fileurl('lib/js/jquery.form.js');?>"></script>

<script type="text/javascript" src="<?php echo fileurl('lib/js/phpvms.js');?>"></script>

<script type="text/javascript" src="<?php echo fileurl('lib/js/jquery_dataTables.js');?>"></script>

<?php

echo $MODULE_HEAD_INC;

This is my schedule_result.tpl

<script type="text/javascript">

$(document).ready(function() {

$('#tabledlist').dataTable( {

"sPaginationType": "full_numbers"

} );

} );

</script>

<table id="tabledlist" class="display"">

<thead>

<tr>

<th>Flight Info</th>

<th>Info</th>

</tr>

</thead>

<tbody>

<?php

if(!$allroutes)

{

echo '<p align="center">No routes have been found!</p>';

return;

}

?>

<tbody>

<?php

foreach($allroutes as $route)

{

/* Uncomment this code if you want only schedules which are from the last PIREP that

pilot filed */

/*if(Auth::LoggedIn())

{

$search = array(

'p.pilotid' => Auth::$userinfo->pilotid,

'p.accepted' => PIREP_ACCEPTED

);

$reports = PIREPData::findPIREPS($search, 1); // return only one

if(is_object($reports))

{

# IF the arrival airport doesn't match the departure airport

if($reports->arricao != $route->depicao)

{

continue;

}

}

}*/

/*

Skip over a route if it's not for this day of week

Left this here, so it can be omitted if your VA

doesn't use this.

Comment out these two lines if you don't want to.

*/

/* Check if a 7 is being used for Sunday, since PHP

thinks 0 is Sunday */

$route->daysofweek = str_replace('7', '0', $route->daysofweek);

if(strpos($route->daysofweek, date('w')) === false)

continue;

/* END DAY OF WEEK CHECK */

/*

This will skip over a schedule if it's been bid on

This only runs if the below setting is enabled

If you don't want it to skip, then comment out

this code below by adding // in front of each

line until the END DISABLE SCHEDULE comment below

If you do that, and want to show some text when

it's been bid on, see the comment below

*/

if(Config::Get('DISABLE_SCHED_ON_BID') == true && $route->bidid != 0)

{

continue;

}

/* END DISABLE SCHEDULE ON BID */

/* Skip any schedules which have aircraft that the pilot

is not rated to fly (according to RANK), only skip them if

they are logged in. */

if(Config::Get('RESTRICT_AIRCRAFT_RANKS') === true && Auth::LoggedIn())

{

/* This means the aircraft rank level is higher than

what the pilot's ranklevel, so just do "continue"

and move onto the next route in the list

*/

if($route->aircraftlevel > Auth::$userinfo->ranklevel)

{

continue;

}

}

/* THIS BEGINS ONE TABLE ROW */

?>

<tr>

<td><a href="<?php echo url('/schedules/details/'.$route->id);?>"><?php echo '('.$route->depicao.' - '.$route->arricao.')'?><?php echo $route->code . $route->flightnum?></a></td>

<td nowrap> </td>

</tr>

<tr>

<td><strong>Departure: </strong><?php echo $route->deptime;?>         <strong>Arrival: </strong><?php echo $route->arrtime;?></td>

<td nowrap><a href="<?php echo url('/schedules/details/'.$route->id);?>">View Details</a></td>

</tr>

<tr>

<td><strong>Equipment: </strong><?php echo $route->aircraft; ?> (<?php echo $route->registration;?>) <strong>Distance: </strong><?php echo $route->distance . Config::Get('UNITS');?></td>

<td nowrap><a href="<?php echo url('/schedules/brief/'.$route->id);?>">Pilot Brief</a></td>

</tr>

<tr>

<td><strong>Days Flown: </strong><?php echo Util::GetDaysCompact($route->daysofweek); ?></td>

<td nowrap><?php

# Don't allow overlapping bids and a bid exists

if(Config::Get('DISABLE_SCHED_ON_BID') == true && $route->bidid != 0)

{

?>

<a id="<?php echo $route->id; ?>" class="addbid"

href="<?php echo actionurl('/schedules/addbid');?>">Add to Bid</a>

<?php

}

else

{

if(Auth::LoggedIn())

{

?>

<a id="<?php echo $route->id; ?>" class="addbid"

href="<?php echo url('/schedules/addbid');?>">Add to Bid</a>

<?php

}

}

?></td>

</tr>

<tr>

<td><br />

<?php echo ($route->route=='') ? '' : '<strong>Route: </strong>'.$route->route.'<br />' ?>

<?php echo ($route->notes=='') ? '' : '<strong>Notes: </strong>'.html_entity_decode($route->notes).'<br />' ?>

<?php

# Note: this will only show if the above code to

# skip the schedule is commented out

if($route->bidid != 0)

{

echo 'This route has been bid on';

}

?>

</td>

<td nowrap><br />

<br /></td>

</tr>

<?php

/* END OF ONE TABLE ROW */

}

?>

</tbody>

</table>

<hr>

Link to comment
Share on other sites

  • 7 months later...

Hmm I haven't got it to work. Any suggestions?

I copied the three .js files to lib/js

i copies the images to lib/images

and I put the two template files to core/templates

This is what the top of my schedule_results.tpl file looks like:

http://pastebin.com/mftXxdxV I just used the default table listed in there which was named "tabledlist". Should I be editing tables somewhere else besides this schedule_results.tpl file?

And this is what my core_htmlhead.tpl js links looks like:

http://pastebin.com/7czH44dx

Thanks for anyhelp!

Link to comment
Share on other sites

  • 2 weeks later...
  • 4 months later...
  • 2 years later...

web541,

Where do I place this code? In the jquery.dataTables.js or in my code on the page? And if in the jQuery.dataTables.js which line is it. I have looked every where in that code!

<script type="text/javascript">

$(document).ready(function() {

$('.table').dataTable( {

"sPaginationType": "full_numbers"

} );

} );

</script>

Thanks, brand new to this! I am also having trouble with the No Routes Passed on the schedule_results page. And I am using this for the pagination css and it's causing the No Routes Passed, on the schedules page, works on the pilot list and view all pireps.

Works on the schedules results but no styling:

http://screencast.com/t/AAgPFyoa0q

When I get the styling too work, there is the No Routes Passed code on the Schedule Results page:

http://screencast.com/t/M4vXDiTazi71

These are the 2 links I got off of the DataTables website:

<link rel="stylesheet" type="text/css" href="https://cdn.datatabl...trap.min.css"/>

<script type="text/javascript" src="https://cdn.datatabl...n.js"></script>

Image of the links:

http://screencast.com/t/NDuAe8mCsO

https://datatables.n.../bootstrap.html

Thanks!

Edited by jnascar
Link to comment
Share on other sites

You put that code I gave you in your code on the page

Assuming it was the above code, I've modified it for you

<script type="text/javascript">
$(document).ready(function() {
$('.table').dataTable({
 "sPaginationType": "full_numbers",
 "lengthMenu": "[ [10, 20, 50], [10, 20, 50] ]"
});
});
</script>

As for the "no route passed" error, do a search on the forums, it's a common problem, usually based with a jQuery problem, so check that in your skin, the only place you've specified it is in your core_htmlhead.php file.

If that doesn't work, I've found in the past that the best solution is this one

http://forum.phpvms.net/topic/7431-no-route-passed-solved/#entry49472

Link to comment
Share on other sites

Your code caused this:

http://screencast.com/t/9UZs7HH2HBa

Any ideas?

I mean I can click on the individual number like 2, 5, but the 10, 20, 50 is a no go. I actually want to change them to like 5,10,20, etc....

You have it working better than I did :)

And I see code here on the dataTables page:

https://datatables.n...tion/lengthMenu

But i am not sure how to implement it!

Thanks!

Got it working! Thank you so much web541, I really appreciate it, more than you know!

Now to get that pesky Route Passed stuff working :)

This is what I used off the site and modified it:

<script type="text/javascript">

$(document).ready(function() {

$('.table').dataTable({

"sPaginationType": "full_numbers",

"lengthMenu": [ [5, 10, 15, -1], [5, 10, 15, "All"] ]

});

});

</script>

I think your code was just missing a bracket, I think :)

Here it is working:

http://screencast.com/t/x18iKQki

And you can have different options on different pages....awesome!

http://screencast.com/t/sk67zEHK5U

Once again, many thanks!

Now to get it to work on the schedules results page as this is where it shines, as there are so many schedules on sites. And the searching for airports and other options is awesome. Darn No Routes Passed, always causing a problem. Have to get it working!

http://screencast.com/t/FSkhYjgGT

Edited by jnascar
Link to comment
Share on other sites

Alright besides the No Routes Passed on the schedule results page (what a pain), I having it working on most pages, and now I am trying to get it working on a page with multiple tables. There is a Datatable code for this but I can not get it to work yet on the phpVMS site, except for the test pagination page on my phpVMS site, that it is working on with multiple tables perfectly.

On my test pagination page I have 3 tables and they work independently of each other. Meaning I can sort each one separately and also search each one independently of each other, but I can not get it to work on my actual phpVMS page.

Here is the datatable code for multiple tables on one page:

<script>

$(document).ready(function() {

$('table.table').DataTable();

} );

</script>

<table class="table">

All 3 tables have the same class and work perfectly. Just can not figure out why the page I am working on does not work yet. I even tried a table ID and than a table class like:

<script>

$(document).ready(function() {

$('#fleet.table').DataTable();

} );

</script>

<table id="fleet" class="table">

And this did not work. There is another table on the page, but I gave it a separate table ID as not to confuse the Datatable code.

Confused again,

Thanks for your help!

Does anyone have this working with multiple tables on the same page?

Link to comment
Share on other sites

Try this?

<script>
// Separate each dataTable into their own function to target them only
$(document).ready(function() {
$('#idhere').dataTable();
});
$(document).ready(function() {
$('#fleet').dataTable();
});
// Or even this one, but I recommend using the id's otherwise every table on the page will be datatables
$(document).ready(function() {
$('.table').dataTable();
});
</script>

And here are your table tags

<table id="idhere" class="table">
<table id="fleet" class="table">
<table class="table">

Edited by web541
Link to comment
Share on other sites

  • 2 months later...
  • 4 months later...

Please make a BACKUP before trying any of my suggestions!

At the beginning of your table, right below the DataTable script what do you have?

Since you are using #plist , if I am not mistaken you should have:

<table class="plist">

Here is mine for pireps_viewall.php ( Of course I do not have over 1,000 pilots on my test server but I am going to try and see if I can change the number higher somehow)

Of course it is not BOLD I just did that to show you the matching code! This also lets you change the drop down number selections. BTW, thanks to web541for helping me out originally. I also have this code on the top of each page because I am lazy, to activate the code:

 

<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.12/css/dataTables.bootstrap.min.css"/>
<script type="text/javascript" src="https://cdn.datatables.net/v/bs/jq-2.2.3/dt-1.10.12/datatables.min.js"></script>

<script type="text/javascript">
$(document).ready(function() {
$('#pireps').dataTable({
  "sPaginationType": "full_numbers",
  "lengthMenu": [ [15, 30, 60, -1], [15, 30, 60, "All"] ]
});
});
</script>
<table id="pireps" class="table">

It works in the data tables example, under the salary ( not exactly like mine ). I can't imagine the AKA prefix would make a difference, but not sure.

https://www.datatables.net

BTW, if you get it working there is also code where you can select which column to sort by default. It looks like yours is by Pilot ID! I know that also messed me up one time. Somehow I had my table sorting by default in a column I did not want it too.

 

 

Edited by jnascar
Link to comment
Share on other sites

Another option would be to make a json response from the 'Pilot Module' and check the length of the pilotid, if it's shorter than four, append a zero to it before the number

so 996 would be 0996, then 1000, not ideal, but it should work. Then you can re-route datatables to read this.

Link to comment
Share on other sites

1 hour ago, jnascar said:

Please make a BACKUP before trying any of my suggestions!

At the beginning of your table, right below the DataTable script what do you have?

Since you are using #plist , if I am not mistaken you should have:

<table class="plist">

Here is mine for pireps_viewall.php ( Of course I do not have over 1,000 pilots on my test server but I am going to try and see if I can change the number higher somehow)

Of course it is not BOLD I just did that to show you the matching code! This also lets you change the drop down number selections. BTW, thanks to web541for helping me out originally. I also have this code on the top of each page because I am lazy, to activate the code:

 

<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.12/css/dataTables.bootstrap.min.css"/>
<script type="text/javascript" src="https://cdn.datatables.net/v/bs/jq-2.2.3/dt-1.10.12/datatables.min.js"></script>

<script type="text/javascript">
$(document).ready(function() {
$('#pireps').dataTable({
  "sPaginationType": "full_numbers",
  "lengthMenu": [ [15, 30, 60, -1], [15, 30, 60, "All"] ]
});
});
</script>
<table id="pireps" class="table">

It works in the data tables example, under the salary ( not exactly like mine ). I can't imagine the AKA prefix would make a difference, but not sure.

https://www.datatables.net

BTW, if you get it working there is also code where you can select which column to sort by default. It looks like yours is by Pilot ID! I know that also messed me up one time. Somehow I had my table sorting by default in a column I did not want it too.

 

 

Didn't work. I did it the way you did above and got pretty much the same results, with the buttons messed up.

http://www.flyaka.com/index.php/Pilots

<table id="plist" width="100%" border="0" cellspacing="0" cellpadding="0" class="aka_table">

 

Link to comment
Share on other sites

Yeah I changed the id's on my test server and it did not work for me either. However you do need the matching id in the script and the table for it to work correctly. 

Epic Fail...sorry

2017-01-27_1613

 

It doesn't have anything to do with the pilot length code does it. I saw somewhere when searching you can change the pilot id from like 4 to 3 or I guess 4 to 6, or whatever number of places you want. That's not it, is it?

Sorry I tried. If I do figure it out, I'll let you know! Or if you figure it out, or someone, let us know how you did it?

SBA1030

SBA1040

Not sorting correctly with the other pilot ID's...

Link to comment
Share on other sites

1 hour ago, web541 said:

Another option would be to make a json response from the 'Pilot Module' and check the length of the pilotid, if it's shorter than four, append a zero to it before the number

so 996 would be 0996, then 1000, not ideal, but it should work. Then you can re-route datatables to read this.

I think the default number is set to 4. I think! Someone might also mention this in the phpVMS3 area to see if they can avoid this in the new version.

Edited by jnascar
Link to comment
Share on other sites

No, not the default number sorry, the ordering, because it looks for number then length (I think), 0 comes before 1, so theoretically is you have these

  1. 10
  2. 20
  3. 1000

It will become like this currently

  1. 10
  2. 1000
  3. 20

By if you re-route a zero in front of it, it should become like this

  1. 0010
  2. 0020
  3. 1000

etc, so the id matches the length while still keeping the number there, might look silly, but it works.

Edited by web541
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...