Jump to content

ARV187

Members
  • Posts

    260
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by ARV187

  1. I know that this cost includes a lot of expenses, all those that the plane has per hour. But as we wanted to have have each expense detailed, we were doing it with the "expenses" section below. The problem, as I commented in github, is that the cost type "time" is missing. Yes, what we want to simulate is the cost of the cabin crew, not the pilot. We could do a cost per flight but it would not adjust to the duration of the hours worked by the crew. The name change was to make it simpler for us, as much as changing a word, to know where it could be done, obviously the change was just for us to do it, not to be done in development πŸ˜…. It was difficult for us to know what was the "block time cost" because we knew it by the name given in the administration "cost per hour" and by doing the maths we realised that it was the field we used for the wage/hour of the crew. πŸ˜„ Thanks Dispo!!
  2. Hi, To recreate the cost of crew salary We are adding up their hourly wages and putting them in this box "Cost Per Hour" as there is no other box in the system to do an hourly calculation. When the pirep is sent instead of hourly cost it says "block time cost" so it was a bit difficult to relate that both were the same. You could change the word in the resulting pirep. Or better yet, do this: https://github.com/nabeelio/phpvms/issues/776 Adding the possibility of create a expense for time. Any solution? Thanks!!
  3. Thank you, it has been very helpful to start. P.S: Listeners not working.
  4. I'm thinking in this debit xD A full payback xD, but taking half can be good. Where you get flight_time and others, database fields? Or filled? I don't found that in \app\Events\PirepFiled.php
  5. Hi, I'm trying to charge to pilot to accept a pirep not scheduled. I tried to follow an example, but I don't know what I must write in condition. if ($event->pirep-> !scheduled) Or how charge the Debit of pirep $amount = pirep expenses/debit; Thanks! \app\Listeners\FreeFlight.php <?php namespace App\Listeners; use App\Contracts\Listener; use App\Events\Expenses; use App\Events\PirepAccepted; use App\Models\Enums\ExpenseType; use App\Models\Expense; class FreeFlight extends Listener { public function handle(Expenses $event) { $expenses = []; $amount = pirep expenses/debit; if ($event->pirep-> !scheduled) { return $expenses; } $expenses[] = new Expense([ 'type' => ExpenseType::FLIGHT, 'amount' => $amount, 'transaction_group' => 'Free Flight', 'name' => 'Free flight Fee For Pirep='.$event->pirep->id, 'multiplier' => false, 'charge_to_user' => true ]); return $expenses; } }
  6. Search by time: \lib\skins\YourSkin\schedule_searchform.tpl <li class="nav-item"><a class="nav-link" href="#flighttimetab"><span><button type="button" class="btn btn-primary">Por tiempo</button></span></a></li> //write this with the others tabs code <div id="flighttimetab" class="card-body text-white bg-dark"> <p>Selecciona tiempo de vuelo:</p> <select id="type" name="type"> <option value="greater">Mayor que</option> <option value="less">Menor que</option> </select> <input type="text" name="flighttime" value="" /> Horas <input type="submit" name="submit" value="Buscar vuelos" /> </div> \core\modules\Schedules\Schedules.php if($this->post->flighttime != '') { if($this->post->type == 'greater') $value = '> '; if($this->post->type == 'less') $value = '< '; $value .= $this->post->flighttime; $params = array('s.flighttime' => $value); }
  7. Thanks to @DisposableHero and @Nabeelfor the help Code from DisposableHero: <?php require_once ("xxx/db.php"); mysqli_select_db($db, $database_db); $resultSet = "SELECT icao, registration FROM phpvms_aircraft WHERE `enabled`='1' ORDER BY `icao` ASC"; ?> <select id="dropdown" onChange="ChangeFormValues()"> <?php $resultSet = mysqli_query($db, $resultSet) or die(mysqli_error($db)); while ($rows = $resultSet->fetch_assoc()) { $icao = $rows['icao']; $reg = $rows['registration']; // Build your dropdown with php, just put a seperator between them like # echo '<option value="'.$icao.'#'.$reg.'">'.$icao.' '.$reg.'</option>'; } ?> </select> <input type="text" id="icao" name="type" maxlength="4" placeholder="ICAO Type" readonly> <input type="text" id="reg" name="reg" maxlength="7" placeholder="Registration" readonly> <script selectIcao="text/javascript"> function ChangeFormValues() { // Get the selection, and then split it var selected = document.getElementById('dropdown').value.split("#") ; // Now set your form field values according to selection document.getElementById('icao').value = selected[0] ; // Start. Added later, as a quick and temporary solution to aircraft that are not in simbrief DB, a custom airframe is created and when choosing the icao in the dropdown it is replaced by the Simbrief Internal ID. if (document.getElementById('icao').value=="B38M") { document.getElementById('icao').value = "288759_1640167452930" ;} // end document.getElementById('reg').value = selected[1] ; } </script>
  8. Hi, I'm trying the solution via json aproach, but I get this error: SyntaxError: JSON.parse: expected property name or '}' at line 1 column 1 of the JSON data My code: <?php $resultSet = "SELECT icao, registration FROM phpvms_aircraft"; $resultSet = mysqli_query($xxxx, $resultSet) or die(mysqli_error($xxxx)); while($rows = $resultSet->fetch_assoc()) { echo $icao = $rows['icao'] . ' '; echo $reg = $rows['registration'] . '<br>'; $dropdown = array('icao','registration'); } //Print out the array in a JSON format. header('Content-Type: application/json'); echo json_encode($dropdown);//Print out the array in a JSON format. ?> I'm using this example: https://thisinterestsme.com/select-options-with-ajax/ Do you see what I am doing wrong at first glance? P.S: Fixed, I still don't know what was wrong. I'm now in dropdown step (select aircraft, extract icao & registration in separate inputs).
  9. Yeah, can be an option, anyway I only need a dropdown with airplanes icao's and automatically add the associated registration. I will see what option I choose to do it, thanks DisposableHero
  10. Thanks! I will post when I find the solution the next week. I guess that phpvms7 code is different because of laravel and OOP
  11. Thank you @DisposableHero I tried your modifications, but same result that mine. If I edit: $resultSet2 = "SELECT registration FROM phpvms_aircraft WHERE icao='".$avion."'"; To: $resultSet2 = "SELECT registration FROM phpvms_aircraft WHERE icao='A20N'"; The line: echo '<option value="'.$reg.'">'.$reg.'</option>'; Show: RG-101 (the right reg to A20N), but when I send the form (<form id="sbapiform"> in \lib\skins\bs4\schedule_briefing.tpl) the result from simbrief (SimBrief?ofp_id=fpNumber) is an auto reg because when you don't pass a "reg" simbrief autogenerate one. However if I write in input type text: <input name="reg" id="regist"> the result from simbrief is the correct value written in the input text field. So I see two issues: 1ΒΊ Form isn't sending the value from: echo '<option value="'.$reg.'">'.$reg.'</option>'; but this value is showed rightly in form page (<form id="sbapiform"> in \lib\skins\bs4\schedule_briefing.tpl). 2ΒΊ I'm not sure if WHERE variable is working because when I use icao='".$avion."' not is showing nothing in the web page echo '<option value="'.$reg.'">'.$reg.'</option>'; However if I use WHERE icao='A20N' is showed in form web page. $resultSet2 = "SELECT registration FROM phpvms_aircraft WHERE icao='".$avion."'"; The full original code is here Line 123 and below: https://github.com/vangelisb/Simbrief/tree/5022f0bcfa886767f197ae890bffcc29fb98ba6a/phpvms/copy included file to your template folder L131 <?php $planedata=(OperationsData::getAircraftByReg($schedule->registration)) ;?> <td><input type="hidden" name="type" size="5" type="text" placeholder="ZZZZ" value="<?php echo $planedata->icao ;?>"></td> L186 <input type="hidden" name="reg" value="<?php echo $schedule->registration?>">
  12. I'm so sorry, I completely forgot about that. phpVMS version? Version 2.1.936 PHP version? 5.6 MySQL/MariaDB version? 5.7.35 What modules are you using? None. Are you using the FltBook module? No. All work well, only I want add that auto reg selection in the input <input type="hidden" name="reg" value="<?php echo $schedule->registration?>"> For reference: https://github.com/vangelisb/Simbrief/tree/5022f0bcfa886767f197ae890bffcc29fb98ba6a/phpvms
  13. Hi there, Im trying autoselecting the registration code from DB after select aircraft in a dropdown menu. But I don't know why not work. Simbrief plan set an auto registration to selected airplane. At the moment I coded this: Input name values that simbrief form get are: "type" to aircraft, "reg" to registration. <?php require_once ("/Connections/db.php"); mysqli_select_db($db, $database_db); $resultSet = "SELECT icao, registration FROM phpvms_aircraft"; ?> <select name="type" id="typo" onChange="upicao()"> <?php $resultSet = mysqli_query($db, $resultSet) or die(mysqli_error($db)); while($rows = $resultSet->fetch_assoc()) { $icao = $rows['icao']; $reg = $rows['registration']; echo "<option value=$icao>$icao $reg</option>"; } ?> </select> <?php $avion = "<input type=hidden id=typo readonly>"; ?> <script type="text/javascript"> function upicao() { var select = document.getElementById('typo'); var option = select.options[select.selectedIndex]; document.getElementById('typo').value = option.value; } upicao(); </script> <?php if (($avion)!=null) { require_once ("/Connections/db.php"); mysqli_select_db($db, $database_db); $resultSet2 = "SELECT registration FROM phpvms_aircraft WHERE icao='" . $avion . "'"; ?> <b>Registro</b> (opcional):&nbsp; <input name="reg" id="regist"> <?php $resultSet2 = mysqli_query($db, $resultSet2) or die(mysqli_error($db)); while($rows = $resultSet2->fetch_assoc()) { $reg = $rows['registration']; echo "<option value=$reg>$reg</option>"; } } ?> Could someone help me with the code, it's been two weeks ... Thank you!
  14. Updated OSM for flown_routes_map from Discord by Justin RR <div id="routemap" style="width: 100%; height: 800px;"></div> <script src="<?php echo SITE_URL?>/lib/js/base_map.js"></script> <script type="text/javascript"> const map = createMap({ render_elem: 'routemap', provider: '<?php echo Config::Get("MAP_TYPE"); ?>', }); var latlngs = [ <?php $shown = array(); foreach($allschedules as $route) { // Dont show repeated routes if(in_array($route->code.$route->flightnum, $shown)) continue; else $shown[] = $route->code.$route->flightnum; if(empty($route->arrlat) || empty($route->arrlng) || empty($route->deplat) || empty($route->deplng)) { continue; } ?> [ new L.LatLng(<?php echo $route->deplat; ?>, <?php echo $route->deplng; ?>), new L.LatLng(<?php echo $route->arrlat; ?>, <?php echo $route->arrlng; ?>), ], <?php } ?> ]; const pointsLayer = L.geodesic(latlngs, { weight: 2, opacity: 0.5, color: '#2e4a66', steps: 10 }).addTo(map); </script>
  15. Hi, I' trying to modify the search function to not only have '<' or '>' distance, if not between 'distance1' and 'distance2' too, and by flight time. I have not gotten it to work for me, I don't know if I have to modify something else, or how to implement it in the existing code. My phpvms version is v2. Thanks! So in SchedulesData.class.php Line 19: class SchedulesData extends CodonData { /** * A generic find function for schedules. As parameters, do: * * $params = array( 's.depicao' => 'value', * 's.arricao' => array ('multiple', 'values'), * ); * * Syntax is ('s.columnname' => 'value'), where value can be * an array is multiple values, or with a SQL wildcard (%) * if that's what is desired. * * Columns from the schedules table should be prefixed by 's.', * the aircraft table as 'a.' * * You can also pass offsets ($start and $count) in order to * facilitate pagination * * @tutorial http://docs.phpvms.net/media/development/searching_and_retriving_schedules */ public static function findSchedules($params, $count = '', $start = '') { $sql = 'SELECT s.*, a.id as aircraftid, a.name as aircraft, a.registration, a.minrank as aircraft_minrank, a.ranklevel as aircraftlevel, dep.name as depname, dep.lat AS deplat, dep.lng AS deplng, arr.name as arrname, arr.lat AS arrlat, arr.lng AS arrlng FROM '.TABLE_PREFIX.'schedules AS s LEFT JOIN '.TABLE_PREFIX.'airports AS dep ON dep.icao = s.depicao LEFT JOIN '.TABLE_PREFIX.'airports AS arr ON arr.icao = s.arricao LEFT JOIN '.TABLE_PREFIX.'aircraft AS a ON a.id = s.aircraft '; /* Build the select "WHERE" based on the columns passed, this is a generic function */ $sql .= DB::build_where($params); // Order matters if(Config::Get('SCHEDULES_ORDER_BY') != '') { $sql .= ' ORDER BY '.Config::Get('SCHEDULES_ORDER_BY'); } if(strlen($count) != 0) { $sql .= ' LIMIT '.$count; } if(strlen($start) != 0) { $sql .= ' OFFSET '. $start; } $ret = DB::get_results($sql); return $ret; } schedule_searchform.tpl at line 92 <div id="flighttime"> <p>Selecciona tiempo de vuelo:</p> <select id="type" name="type"> <option value="greater">Mayor que</option> <option value="less">Menor que</option> </select> <input type="text" name="flighttime" value="" /> <input type="submit" name="submit" value="Buscar vuelos" /> </div> Schedules.php at line 175 public function findFlight() { if($this->post->depicao != '') { $params = array('s.depicao' => $this->post->depicao); } if($this->post->arricao != '') { $params = array('s.arricao' => $this->post->arricao); } if($this->post->equipment != '') { $params = array('a.name' => $this->post->equipment); } if($this->post->distance != '') { if($this->post->type == 'greater') $value = '> '; if($this->post->type == 'less') $value = '< '; $value .= $this->post->distance; $params = array('s.distance' => $value); } //////////////////////* my code start *//////////////////////// if($this->post->flighttime != '') { if($this->post->type == 'greater') $value = '> '; if($this->post->type == 'less') $value = '< '; $value .= $this->post->flighttime; $params = array('s.flighttime' => $value); } //////////////////////* my code end *//////////////////////// $params['s.enabled'] = 1; $this->set('allroutes', SchedulesData::findSchedules($params)); $this->render('schedule_results.tpl'); }
  16. The application allow me to continue and I never saw the issue again, but I wanted fix the issue anyway, and there are a forgotten row without static function hehe. So, thanks for your help!
  17. It was just the only line one that had not changed more than a year ago with "static". πŸ˜… SchedulesData.class.php L739 public static function getLatestBid($pilotid). I can't reproduce the error again nor before applying the fix, It only appeared once. Seems that the "you may be able to continue" was serious and has not reappeared. Will the "cannot modify header information" be fixed after the change? I found the file, in L394 say: "header('Content-type: text/xml');" public function sendXML($params) { $xml = new SimpleXMLElement("<sitedata />"); $info_xml = $xml->addChild('info'); foreach($params as $name => $value) { $info_xml->addChild($name, $value); } header('Content-type: text/xml'); $xml_string = $xml->asXML(); echo $xml_string; # For debug #$this->log("Sending: \n".print_r($xml_string, true), 'kacars'); return; }
  18. I know, There are a post with the issue static method, I fixed the ones that I saw in the post. I will check again!!. So...."cannot modify header information"? any clue? Thanks!
  19. v2.1.936 version, I saw that function, but I don't figure that do with that, the function calculate the distance between two points. I can do that in phpmyadmin with a sql sentence, but I do not know how to move it to that in schedule_searchform distances section with the existing form, where the data of the query "between" are those that the user enters in two fields type number. <div id="distance"> <p>Selecciona distancia:</p> <select id="type" name="type"> <option value="greater">Greater than</option> <option value="less">Less than</option> </select> <input type="text" name="distance" value="" /> <input type="submit" name="submit" value="Search flight" /> <br /><br /> <option value="between">Between</option> <?php $sql = "SELECT * FROM `phpvms_schedules` WHERE `distance` BETWEEN $distance1 AND $distance2"; ?> <input type="number" name="distance1" min="1" max="9999" value="" /> > <input type="number" name="distance2" min="1" max="9999" value="" /> <input type="submit" name="submit" value="Search flight" /> </div>
  20. I would like to add an option to allow you to search for a flight that has for example between 200 miles and 300 miles something similar to: search flight where 'distance' between "$distance1" and "$distance2" I have scanned these files: schedule_searchform.tpl core/modules/Schedules/schedules.php but I can not find out what code I need to do this.
  21. Yeah, that is working. Thank you! By default phpvms2 calculate flightime in this way ($schedule->arrtime - $schedule->deptime) don't use flightime database column.
  22. How I check that? In past versions are working, I'm thinking in reinstall again to see if that fix the issue, I need reset the database too or I can restore it?
  23. Hi, actually in my phpvms v2.1.936 I have this code: schedule_briefing.tpl <!-- Flight time Row --> <tr> <td colspan="2"><?php echo $schedule->arrtime - $schedule->deptime ?></td> </tr> But this code not show minutes, only hours, so if I have arr time = 12:59 and dep time = 09:00 the result is 3hours, not 3:59 hours. How can I fix this? Thanks!
×
×
  • Create New...