Jump to content

Pirep does not accept


CarlosEduardo2409

Recommended Posts

Greetings everyone,

 

From a time to here, I start to change the layout of my admin panel, everything is working perfectly, actually almost perfection, I have a problem in the pending pirep, when I click to accept the pirep it does not accept, does not happen anything.

 

My code of the pirep button:

<?php if($error == false) { ?>
	<button class="pirepaction btn btn-success {button:{icons:{primary:'ui-icon-trash'}}}" href="<?php echo adminaction('/pirepadmin/'.$load.'?pilotid='.$pirep->pilotid.'');?>" action="approvepirep" id="<?php echo $pirep->pirepid;?>"> Accept </button>
<?php } ?>

 

My whole code:

Quote

<?php if(!defined('IN_PHPVMS') && IN_PHPVMS !== true) { die(); } ?>
<div class="row">
    <div class="col-md-12">
        <div class="card">
            <div class="card-header" data-background-color="purple">
                <h4 class="title">Pilot Reports</h4>
                <p class="category">There are a total of <?php echo count($pireps);?> flight reports in this category. <a href="<?php echo SITE_URL?>/admin/index.php/pirepadmin/approveall">Click to approve all</a></p>
            </div>
            
            <div class="card-content table-responsive">
                <?php 
                	if($_GET['module'] == 'pirepadmin' && $_GET['page'] == 'viewall') {
                		Template::Show('pireps_filter.tpl');
                	}
                
                	if(isset($paginate)) {
                ?>
                	<div style="float: right;">
                		<a href="?admin=<?php echo $admin?>&start=<?php echo $start?>">Next Page</a>
                		<br />
                	</div>
                <?php } ?>
                
                <?php if(!$pireps) {
                	echo '<p>No reports have been found</p></div>';
                	return;
                } ?>
                <table class="table">
                    <thead class="text-primary">
                        <th>Pilot</th>
                        <th>Flight</th>
                    	<th>Dep/Arr</th>	
                    	<th>Flight Time</th>
                    	<th>Submit Date</th>
                        <th>Current Status</th>
                        <th>Details</th>
                        <th>Options</th>
                    </thead>
                                            
                    <tbody>
                        <?php foreach($pireps as $pirep) {	
                            	if($pirep->accepted == PIREP_PENDING)
                            		$td_class = 'pending';
                            	else
                            		$td_class = '';
                            	
                            	$error = false;
                        ?>
                        <tr class="<?php echo $class?> pirep_list" id="row<?php echo $pirep->pirepid;?>">
                            <td>
                                <a href="<?php echo SITE_URL?>/admin/index.php/pilotadmin/viewpilots?action=viewoptions&pilotid=<?php echo $pirep->pilotid;?>"><?php echo PilotData::GetPilotCode($pirep->pcode, $pirep->pilotid) . ' - ' .$pirep->firstname .' ' . $pirep->lastname;?></a>
		                    </td>
                            <td><?php echo $pirep->code . $pirep->flightnum; ?></td>
                            <td><?php echo $pirep->depicao; ?>/<?php echo $pirep->arricao; ?></td>
                            <td><?php echo $pirep->flighttime; ?></td>
                            <td><?php echo date(DATE_FORMAT, $pirep->submitdate); ?> </td>
                            <td><?php
                                    if($pirep->accepted == PIREP_ACCEPTED)
                                    	echo 'Accepted';
                                	elseif($pirep->accepted == PIREP_REJECTED)
                                		echo 'Rejected';
                                	elseif($pirep->accepted == PIREP_PENDING)
                                		echo 'Approval Pending';
                            	?>
                            	<?php
                                	if($pirep->aircraft == '') {
                                		$error = true;
                                	}	
                            	?>
                            </td>
                            
                            
                            <td>
                                <a href="#" onclick="$('#details_dialog_<?php echo $pirep->pirepid;?>').toggle()">Details</a>
                            
                                <!-- Start Table - Details -->
                                <table class="table" id="details_dialog_<?php echo $pirep->pirepid;?>" style="display:none; border-left: 3px solid #FF6633; margin-top: 3px;padding-left: 3px;" width="100%">
                                    <tr>
                                        <td><strong>Client: </strong> <?php echo $pirep->source; ?></td>
                                    	<td><strong>Aircraft: </strong>
                                    	    <?php 
                                    		    if($pirep->aircraft == '') {
                                    			    $error = true;
                                    				echo '<span style="color: red">No aircraft! Edit to change</span>';
                                    			} else
                                    				echo $pirep->aircraft. " ($pirep->registration)";
                                    	    ?>
                                        </td>
                                    	<td><strong>Flight Time: </strong> <?php echo $pirep->flighttime_stamp; ?></td>
                                    	<td><strong>Distance: </strong><?php echo $pirep->distance; ?> </td>
                                    	<td><strong>Landing Rate: </strong><?php echo $pirep->landingrate; ?> </td>
                                    </tr>
                                    <tr>
                                    	<td colspan="5"><strong>Route: </strong><?php echo $pirep->route;?> 
                                            <a data-toggle="modal" href="<?php echo SITE_URL?>/admin/action.php/operations/viewmap?type=pirep&id=<?php echo $pirep->pirepid;?>" data-target="#route">View</a>
                                        </td>
                                    </tr>
                                    <tr>
                                    	<td><strong>Load/Price: </strong><?php echo (($pirep->load!='')?$pirep->load:'-').' / '.FinanceData::formatMoney($pirep->price);?></td>
                                    	<td><strong>Pilot Pay: </strong><?php echo FinanceData::formatMoney($pirep->pilotpay);?></td>
                                    	<td><strong>Fuel Used: </strong><?php echo ($pirep->fuelused!='') ? $pirep->fuelused.Config::Get('LIQUID_UNIT_NAMES', Config::Get('LiquidUnit')) : '-';?></td>
                                    	<td><strong>Revenue: </strong><?php echo FinanceData::formatMoney($pirep->revenue);?></td>
                                    	<td><strong>Gross: </strong><?php echo FinanceData::formatMoney($pirep->gross);?></td>
                                    </tr>
                                    <?php
                                        // Get the additional fields
                                        //	I know, badish place to put it, but it's pulled per-PIREP
                                        $fields = PIREPData::GetFieldData($pirep->pirepid);
                                        if(!$fields) {
                                        	echo '';
                                        } else {
                                        	$i=1;
                                        	echo '<tr>';
                                        	
                                        	foreach ($fields as $field)	{
                                        		if($i == 1) {
                                        			echo '<tr>';
                                        		}
                                        		
                                        		echo "<td><strong>{$field->title}:</strong> {$field->value}</td>";
                                        		
                                        		if($i == 5) {
                                        			echo '</tr>';
                                        			$i = 0;
                                        		}
                                        		
                                        		$i++;
                                        	}
                                        }
                                        
                                        echo '</tr>';
                                    ?>
                                </table>
                            </td>
                            
                            <td class="<?php echo $td_class;?>" align="center" width="1%" nowrap>
                                <!-- Accept Pirep Button -->
                                <?php if($error == false) { ?>
                                <button class="pirepaction btn btn-success {button:{icons:{primary:'ui-icon-trash'}}}" href="<?php echo adminaction('/pirepadmin/'.$load.'?pilotid='.$pirep->pilotid.'');?>" action="approvepirep" id="<?php echo $pirep->pirepid;?>"> Accept </button>
                                <?php } ?>
                                <!-- /. Accept Pirep Button -->
                                <a data-toggle="modal" class="btn btn-danger" href="<?php echo SITE_URL?>/admin/action.php/pirepadmin/rejectpirep?pirepid=<?php echo $pirep->pirepid;?>&pilotid=<?php echo $pirep->pilotid; ?>" data-target="#reject">Reject</a>
                            </td>
                        </tr>
                        <?php } ?>
                    </tbody>
                </table>
                
                <?php if(isset($paginate)) { ?>
                	<div style="float: right;">
                		<a href="?admin=<?php echo $admin?>&start=<?php echo $start?>">Next Page</a>
                		<br />
                	</div>
                <?php } /* Close the paginate loop */ ?>
                
                <script type="text/javascript">
                    $("button, input:button, input:submit").button();
                </script>
                
                <!-- Modal -->
                <div class="modal fade" id="log" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                	<div class="modal-dialog" role="document">
                        <div class="modal-content">
                            <div class="modal-header">
                				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                				<h4 class="modal-title" id="myModalLabel">Log for <?php echo $report->code.$report->pirepid?></h4>
                            </div>
                			
                            <div class="modal-body">
                                        
                            </div>
                			
                            <div class="modal-footer">
                				<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                				<button type="button" class="btn btn-primary">Save changes</button>
                            </div>
                        </div>
                	</div>
                </div>
                
                <!-- Modal -->
                <div class="modal fade" id="comments" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                	<div class="modal-dialog" role="document">
                        <div class="modal-content">
                            <div class="modal-header">
                				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                				<h4 class="modal-title" id="myModalLabel"></h4>
                            </div>
                			
                            <div class="modal-body" style="padding:5px;">
                                        
                            </div>
                			
                            <div class="modal-footer">
                				<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                				<button type="button" class="btn btn-primary">Save changes</button>
                            </div>
                        </div>
                	</div>
                </div>
                
                <!-- Modal -->
                <div class="modal fade" id="addcomment" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                	<div class="modal-dialog" role="document">
                        <div class="modal-content">
                            <div class="modal-header">
                				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                				<h4 class="modal-title" id="myModalLabel">Add Comment For <?php echo $report->code.$report->pirepid?></h4>
                            </div>
                			
                            <div class="modal-body" style="padding:5px;">
                                        
                            </div>
                			
                            <div class="modal-footer">
                				<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                				<button type="button" class="btn btn-primary">Save changes</button>
                            </div>
                        </div>
                	</div>
                </div>
                
                <!-- Modal -->
                <div class="modal fade" id="reject" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                	<div class="modal-dialog" role="document">
                        <div class="modal-content">
                            <div class="modal-header">
                				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                				<h4 class="modal-title" id="myModalLabel">Reject Pilot Report <?php echo $report->code.$report->pirepid?></h4>
                            </div>
                			
                            <div class="modal-body">
                                        
                            </div>
                			
                            <div class="modal-footer">
                				<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                				<button type="button" class="btn btn-primary">Save changes</button>
                            </div>
                        </div>
                	</div>
                </div>
                
                <!-- Modal -->
                <div class="modal fade" id="route" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                	<div class="modal-dialog" role="document">
                        <div class="modal-content">
                            <div class="modal-header">
                				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                				<h4 class="modal-title" id="myModalLabel"></h4>
                            </div>
                			
                            <div class="modal-body">
                                        
                            </div>
                			
                            <div class="modal-footer">
                				<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                				<button type="button" class="btn btn-primary">Save changes</button>
                            </div>
                        </div>
                	</div>
                </div>
            </div>
        </div>
    </div>
</div>

 

Regards,

Carlos.

Link to comment
Share on other sites

Check your browser console. Also, there are a number of jQuery issues with the admin panel, so for instance the version cannot be higher than 1.8.3 because some of the default functions are not supported in later versions (you could change these and update them though, they're in adminfunctions.js from memory).

I would say this is your problem, so either sort out the jQuery issues or revert back to the default template.

Link to comment
Share on other sites

Are you sure, my jquery is 3.0

This is the code of foother.php

                </div>
            </div>
                <footer class="footer">
                    <div class="container-fluid">
                        <nav class="pull-left">
                            <ul>
                                <li>
                                    <a href="#"> Home </a>
                                </li>
                                
                                <li>
                                    <a href="#"> Company </a>
                                </li>
                                
                                <li>
                                    <a href="#"> Portfolio </a>
                                </li>
                                
                                <li>
                                    <a href="#"> Blog </a>
                                </li>
                            </ul>
                        </nav>
                        
                        <p class="copyright pull-right">
                            &copy;
                            <script>
                                document.write(new Date().getFullYear())
                            </script>
                            <a href="http://www.creative-tim.com">Creative Tim</a>, made with love for a better web
                        </p>
                    </div>
                </footer>
            </div>
        </div>
    </body>
    
    <?php Template::Show('core_footer.php'); ?>
    
    <!--   Core JS Files   -->
    <script src="<?php echo SITE_URL;?>/admin/lib/layout/js/jquery-3.2.1.min.js" type="text/javascript"></script>
    <script src="<?php echo SITE_URL;?>/admin/lib/layout/js/bootstrap.min.js" type="text/javascript"></script>
    <script src="<?php echo SITE_URL;?>/admin/lib/layout/js/material.min.js" type="text/javascript"></script>
    
    <!--  Charts Plugin -->
    <script src="<?php echo SITE_URL;?>/admin/lib/layout/js/chartist.min.js"></script>
    
    <!--  Dynamic Elements plugin -->
    <script src="<?php echo SITE_URL;?>/admin/lib/layout/js/arrive.min.js"></script>
    
    <!--  PerfectScrollbar Library -->
    <script src="<?php echo SITE_URL;?>/admin/lib/layout/js/perfect-scrollbar.jquery.min.js"></script>
    
    <!--  Notifications Plugin    -->
    <script src="<?php echo SITE_URL;?>/admin/lib/layout/js/bootstrap-notify.js"></script>
    
    
    <!-- Material Dashboard javascript methods -->
    <script src="<?php echo SITE_URL;?>/admin/lib/layout/js/material-dashboard.js?v=1.2.0"></script>
    
    <!-- Material Dashboard DEMO methods, don't include it in your project! -->
    <script src="<?php echo SITE_URL;?>/admin/lib/layout/js/demo.js"></script>
    <script type="text/javascript">
        $(document).ready(function() {
            // Javascript method's body can be found in assets/js/demos.js
            demo.initDashboardPageCharts();
    
        });
    </script>
</html>

 

But the only problem is that if I remove it from the site to do most of the functions, then I'll have to leave the skin default, unless I have a solution.

 

But thank you @web541, I thank you every time you helped me, there were several.

Link to comment
Share on other sites

  • 1 year later...
6 hours ago, Karamellwuerfel said:

Was this problem solved? How?

@Karamellwuerfel I was making a custom skin for the admin panel, but the jQuery I was using was newer than phpVMS jQuery, so it didn't get the function that was assigned to the buttons.

 

What I had to do (example):

In the pilots_pending file, this is the default skin button to accept pilots in the company:

<button href="<?php echo SITE_URL?>/admin/action.php/pilotadmin/pendingpilots" action="approvepilot" id="<?php echo $pilot->pilotid;?>" class="ajaxcall {button:{icons:{primary:'ui-icon-circle-check'}}}">Accept</button>

We can see that inside the class attribute of the button above is located "ajaxcall". And if we go to the phpvmsadmin.js file (file that is located most of the admin panel button functions and located in admin/lib), we can find the "ajaxcall" function. So what the button above is doing is pull the "ajaxcall" function which is located in the phpvmsadmin.js file. This is the "ajaxcall" function code:

$('.ajaxcall').live('click', function() {
	$("#bodytext").load($(this).attr("href"), { action: $(this).attr("action"), id: $(this).attr("id") },
	function(d) { $('a.button, button, input[type=submit]').button(); })
});

So, in the above function, we can see that it is pulling some "ajaxcall" class, obviously within a class attribute.

 

But my phpVMS could not find the file phpvmsadmin.js to pull the function (Probably because of my jQuery), ie the button was simply just a normal button that if I pressed nothing would happen. So, the solution I found was to put the button and function in the same file, so that's how my code went:

<button href="<?php echo SITE_URL?>/admin/action.php/pilotadmin/pendingpilots" action="approvepilot" id="<?php echo $pilot->pilotid;?>" class="ajaxcall {button:{icons:{primary:'ui-icon-circle-check'}}}">Accept</button>

<script>
  	$('.ajaxcall').live('click', function() {
		$("#bodytext").load($(this).attr("href"), { action: $(this).attr("action"), id: $(this).attr("id") },
		function(d) { $('a.button, button, input[type=submit]').button(); })
	});
</script>

 

Yes, I was putting the function of the buttons in each file, but as I was already changing all files for making the admin skin, so I had no problem putting in all files. Obviously there should be a better solution, but that's what I got.

 

Hope this helps! 😉

Link to comment
Share on other sites

Wow, thanks for this awesome long explanation! :)
I'll try it at home.

jQuery says:

Quote

The live() method was deprecated in jQuery version 1.7, and removed in version 1.9. Use the on() method instead.

So I think (in my admin theme I use jquery 3.x) I just have to replace the .live() function?

Also I had problems with the "modal" funtion phpvms uses. There are some errors with '.fpq' or something like that. I'll check it later.

 

Thanks again!

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...