lpf20011 Posted June 30, 2014 Report Posted June 30, 2014 Hello, I am looking for some help with phpvms - go figure right? Basically I want to add to each aircraft entry its ZFW and selcal. Ultimately I want to display a ZFW on a pilots bid but I want to walk before I can run. I tried to add selcal but I couldn't get it to update in the admin section or update. I could however get it to show in the aircraft list if I entered the field directly into the database via phpmyadmin. If anyone can point me in the direction of the files I need to alter to take this into account I would appreciate it. I have a local install for testing/building. I tried editing several different files - Operations.tpl it might have been but again couldn't get it to work. Cheers, Tim Quote
freshJet Posted June 30, 2014 Report Posted June 30, 2014 Edit the MySQL table first and then go through your core/common/AircraftData.class.php and add the relevant modifications in wherever necessary. Do the same for the admin panel templates. The relevant modifications being, for example, if the function was for adding an aircraft, adding to the SQL. Quote
lpf20011 Posted June 30, 2014 Author Report Posted June 30, 2014 I don't have the AircraftData.class.php in core/common/ . I'm guessing it will be in OperationsData.class.php Contains this extract - public static function addAircaft($data) { /*$data = array('icao'=>$this->post->icao, 'name'=>$this->post->name, 'fullname'=>$this->post->fullname, 'registration'=>$this->post->registration, 'downloadlink'=>$this->post->downloadlink, 'imagelink'=>$this->post->imagelink, 'range'=>$this->post->range, 'weight'=>$this->post->weight, 'cruise'=>$this->post->cruise, 'maxpax'=>$this->post->maxpax, 'maxcargo'=>$this->post->maxcargo, 'enabled'=>$this->post->enabled);*/ Quote
lpf20011 Posted June 30, 2014 Author Report Posted June 30, 2014 After altering OperationsData.class.php I get the error "There was an error editing this aircraft" Extract quoted below from .php file - I can't see any reason why it shouldn't work as its the same entry as the other fields. Also edited Operations.php in admin /modules /operations still not working. Cheers, /** * Add an aircraft * * $data = array( 'icao'=>$this->post->icao, 'name'=>$this->post->name, 'fullname'=>$this->post->fullname, 'registration'=>$this->post->registration, 'downloadlink'=>$this->post->downloadlink, 'imagelink'=>$this->post->imagelink, 'range'=>$this->post->range, 'weight'=>$this->post->weight, 'cruise'=>$this->post->cruise, 'maxpax'=>$this->post->maxpax, 'maxcargo'=>$this->post->maxcargo, 'selcal'=>$this->post->selcal, 'enabled'=>$this->post->enabled); */ public static function addAircaft($data) { /*$data = array('icao'=>$this->post->icao, 'name'=>$this->post->name, 'fullname'=>$this->post->fullname, 'registration'=>$this->post->registration, 'downloadlink'=>$this->post->downloadlink, 'imagelink'=>$this->post->imagelink, 'range'=>$this->post->range, 'weight'=>$this->post->weight, 'cruise'=>$this->post->cruise, 'maxpax'=>$this->post->maxpax, 'maxcargo'=>$this->post->maxcargo, 'selcal'=>$this->post->selcal, 'enabled'=>$this->post->enabled);*/ $data['icao'] = DB::escape(strtoupper($data['icao'])); $data['name'] = DB::escape(strtoupper($data['name'])); $data['registration'] = DB::escape(strtoupper($data['registration'])); $data['range'] = ($data['range'] == '') ? 0 : $data['range']; $data['weight'] = ($data['weight'] == '') ? 0 : $data['weight']; $data['cruise'] = ($data['cruise'] == '') ? 0 : $data['cruise']; $data['range'] = str_replace(',', '', $data['range']); $data['weight'] = str_replace(',', '', $data['weight']); $data['cruise'] = str_replace(',', '', $data['cruise']); $data['maxpax'] = str_replace(',', '', $data['maxpax']); $data['maxcargo'] = str_replace(',', '', $data['maxcargo']); $data['selcal'] = str_replace(',', '', $data['selcal']); if($data['enabled'] === true) $data['enabled'] = 1; else $data['enabled'] = 0; if($data['minrank'] > 0) { $rank_level = RanksData::getRankLevel($data['minrank']); } else { $rank_level = 0; } $sql = "INSERT INTO ".TABLE_PREFIX."aircraft ( `icao`, `name`, `fullname`, `registration`, `downloadlink`, `imagelink`, `range`, `weight`, `cruise`, `selcal`, `maxpax`, `maxcargo`, `minrank`, `ranklevel`, `enabled`) VALUES ( '{$data['icao']}', '{$data['name']}', '{$data['fullname']}', '{$data['registration']}', '{$data['downloadlink']}', '{$data['imagelink']}', '{$data['range']}', '{$data['weight']}', '{$data['cruise']}', '{$data['maxpax']}', '{$data['maxcargo']}', '{$data['selcal']}’, {$data['minrank']}, {$rank_level}, {$data['enabled']})"; $res = DB::query($sql); if(DB::errno() != 0) return false; CodonCache::delete('all_aircraft'); CodonCache::delete('all_aircraft_enabled'); CodonCache::delete('all_aircraft_search'); CodonCache::delete('all_aircraft_search_enabled'); return true; } /** * Edit an aircraft */ public static function editAircraft($data) { $data['icao'] = DB::escape(strtoupper($data['icao'])); $data['name'] = DB::escape(strtoupper($data['name'])); $data['registration'] = DB::escape(strtoupper($data['registration'])); $data['range'] = ($data['range'] == '') ? 0 : $data['range']; $data['weight'] = ($data['weight'] == '') ? 0 : $data['weight']; $data['cruise'] = ($data['cruise'] == '') ? 0 : $data['cruise']; $data['range'] = str_replace(',', '', $data['range']); $data['weight'] = str_replace(',', '', $data['weight']); $data['cruise'] = str_replace(',', '', $data['cruise']); $data['maxpax'] = str_replace(',', '', $data['maxpax']); $data['maxcargo'] = str_replace(',', '', $data['maxcargo']); $data['selcal'] = str_replace(',', '', $data['selcal']); if(empty($data['minrank'])) { $data['minrank'] = 0; } if($data['enabled'] === true) $data['enabled'] = 1; else $data['enabled'] = 0; if($data['minrank'] > 0) { $rank_level = RanksData::getRankLevel($data['minrank']); } else { $rank_level = 0; } $sql = "UPDATE " . TABLE_PREFIX."aircraft SET `icao`='{$data['icao']}', `name`='{$data['name']}', `fullname`='{$data['fullname']}', `registration`='{$data['registration']}', `downloadlink`='{$data['downloadlink']}', `imagelink`='{$data['imagelink']}', `range`='{$data['range']}', `weight`='{$data['weight']}', `cruise`='{$data['cruise']}', `maxpax`='{$data['maxpax']}', `maxcargo`='{$data['maxcargo']}', `selcal`='{$data['selcal']}’, `minrank`={$data['minrank']}, `ranklevel`={$rank_level}, `enabled`={$data['enabled']} WHERE `id`={$data['id']}"; $res = DB::query($sql); if(DB::errno() != 0) return false; CodonCache::delete('all_aircraft'); CodonCache::delete('all_aircraft_enabled'); CodonCache::delete('all_aircraft_search'); CodonCache::delete('all_aircraft_search_enabled'); return true; } public static function updateAircraftRankLevels() { $all_aircraft = self::getAllAircraft(false); if(!$all_aircraft) { return; } foreach($all_aircraft as $aircraft) { $rank_level = RanksData::getRankLevel($aircraft->minrank); $sql = "UPDATE ".TABLE_PREFIX."aircraft SET `ranklevel`={$rank_level} WHERE `id`={$aircraft->id}"; DB::query($sql); } } Quote
freshJet Posted June 30, 2014 Report Posted June 30, 2014 Sorry that's what I meant. You have to ensure that in your template file on the admin panel (the page you add the aircraft on) you have a field named 'selcal', otherwise there is no data being handled. Quote
lpf20011 Posted July 1, 2014 Author Report Posted July 1, 2014 Yes did that swell. Stills get there was an error editing this aircraft message. There isn't another option I've missed?? Added the aircraft form.tpl to view below Cheers, Tim <h3><?php echo $title;?></h3><p>* Denotes required fields</p> <form action="<?php echo adminurl('/operations/aircraft');?>" method="post"> <dl> <dt>* Aircraft ICAO Code</dt> <dd><input name="icao" type="text" value="<?php echo $aircraft->icao; ?>" /></dd> <dt>* Aircraft Name/Type (i.e B747-400)</dt> <dd><input name="name" type="text" value="<?php echo $aircraft->name; ?>" /></dd> <dt>* Full Name (Boeing 747-400 Combi)</dt> <dd><input name="fullname" type="text" value="<?php echo $aircraft->fullname; ?>" /></dd> <dt>* Aircraft Registration</dt> <dd><input name="registration" type="text" value="<?php echo $aircraft->registration; ?>" /> <p>TIP: Place an X in the registration to denote an inactive aircraft</p> </dd> <dt>* Maximum Passengers</dt> <dd><input name="maxpax" type="text" value="<?php echo $aircraft->maxpax; ?>" /> <p>The maximum number of passengers that can be flown on this aircraft, for passenger or charter flights</p> </dd> <dt>* Maximum Cargo</dt> <dd><input name="maxcargo" type="text" value="<?php echo $aircraft->maxcargo; ?>" /> <p>The maximum cargo load of this aircraft in <?php echo Config::Get('CARGO_UNITS'); ?>, for cargo flights</p> </dd> <dt>Selcal</dt> <dd><input name=“selcal†type="text" value="<?php echo $aircraft->selcal; ?>" /></dd> <dt>Link to download aircraft</dt> <dd><input name="downloadlink" type="text" value="<?php echo $aircraft->downloadlink; ?>" /></dd> <dt>Link to aircraft image</dt> <dd><input name="imagelink" type="text" value="<?php echo $aircraft->imagelink; ?>" /></dd> <dt></dt> <dd>Some of this aircraft can be retrieved from <a href="http://www.airliners.net/aircraft-data/" target="_new">this site</a>.</dd> <dt>Range</dt> <dd><input name="range" type="text" value="<?php echo $aircraft->range; ?>" /></dd> <dt>Weight</dt> <dd><input name="weight" type="text" value="<?php echo $aircraft->weight; ?>" /></dd> <dt>Cruise</dt> <dd><input name="cruise" type="text" value="<?php echo $aircraft->cruise; ?>" /></dd> <dt>Minimum Rank Required to fly</dt> <dd> <select name="minrank"> <option value="0" <?php if($aircraft->minrank == 0){ echo 'selected'; } ?>>None</option> <?php foreach($allranks as $rank) { if($aircraft->minrank == $rank->rankid) $sel = 'selected="selected"'; else $sel = ''; echo "<option value=\"{$rank->rankid}\" {$sel} >{$rank->rank}</option>"; } ?> </select> </dd> <dt>Enabled?</dt> <?php $checked = ($aircraft->enabled==1 || !$aircraft)?'CHECKED':''; ?> <dd><input type="checkbox" id="enabled" name="enabled" value="1" <?php echo $checked ?> /></dd> <dt></dt> <dd><input type="hidden" name="id" value="<?php echo $aircraft->id;?>" /> <input type="hidden" name="action" value="<?php echo $action;?>" /> <input type="submit" name="submit" value="<?php echo $title;?>" /> </dd> </dl> </form> Quote
freshJet Posted July 1, 2014 Report Posted July 1, 2014 I only looked briefly at your code but make sure your colums and values are in order. $sql = "INSERT INTO ".TABLE_PREFIX."aircraft ( `icao`, `name`, `fullname`, `registration`, `downloadlink`, `imagelink`, `range`, `weight`, `cruise`, `selcal`, `maxpax`, `maxcargo`, `minrank`, `ranklevel`, `enabled`) VALUES ( '{$data['icao']}', '{$data['name']}', '{$data['fullname']}', '{$data['registration']}', '{$data['downloadlink']}', '{$data['imagelink']}', '{$data['range']}', '{$data['weight']}', '{$data['cruise']}', '{$data['selcal']}’, '{$data['maxpax']}', '{$data['maxcargo']}', {$data['minrank']}, {$rank_level}, {$data['enabled']})"; Try that. You'll see that in the column listing it's after 'cruise' and before 'maxpax'. Keep it that way throughout your code. Also, I'm assuming this is the order it's in in the table? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.