*

Sparky

  • ***
  • 88 posts
Free UPDATE - Car Attributes Osclass Plugin - 3.3.1

Download and Save your current files before uploading these in case you don't like the changes.

This free update will change "cc"  into   -   Cyl (cylinders of engine) ,  rearranged format , deleted some items.

I am using Osclass 8.0.1 and the Delta Theme 1.2.1 , and I checked on Sigma 1.3.3 and Starter Theme 1.3.3 with my changes and it works for me.
-------------------------------------------------------------------
A Visual of the Format at the bottom
-------------------------------------------------------------------
item_detail.php

Code: [Select]
<div class="table-attributes">
  <h2><?php _e('Car details''cars_attributes') ; ?></h2>
  <table class="car-details">
    <?php if( !empty($detail['e_seller']) ) { ?>
    <tr>
      <?php $seller = array('OWNER' => __('Owner''cars_attributes'), 'DEALER' => __('Dealer''cars_attributes')); ?>
      <td><label><?php _e('Seller''cars_attributes'); ?></label></td>
      <td><label><?php echo $seller[$detail['e_seller']]; ?></td>
    </tr>
    <?php ?>
    <tr>
      <td><label><?php _e('Warranty''cars_attributes'); ?>: </label></td>
      <td><?php echo @$detail['b_warranty'] ? '<strong>' __('Yes''cars_attributes') . '</strong>' __('No''cars_attributes'); ?></td>
    </tr>
    <tr>
      <td><label><?php _e('New''cars_attributes'); ?>: </label></td>
      <td><?php echo @$detail['b_new'] ? '<strong>' __('Yes''cars_attributes') . '</strong>' __('No''cars_attributes'); ?></td>
    </tr>     
    <?php if( !empty($detail['s_make']) ) { ?>
    <tr>
      <td><label><?php _e('Make''cars_attributes'); ?></label></td>
      <td><?php echo @$detail['s_make']; ?></td>
    </tr>
    <?php ?>
    <?php if( !empty($detail['s_model']) ) { ?>
    <tr>
      <td><label><?php _e('Model''cars_attributes'); ?></label></td>
      <td><?php echo @$detail['s_model']; ?></td>
    </tr>
    <?php ?>
    <?php $locale osc_current_user_locale(); ?>
    <?php if( !empty($detail['locale'][$locale]['s_car_type']) ) { ?>
    <tr>
      <td><label><?php _e('Car type''cars_attributes'); ?></label></td>
      <td><?php echo @$detail['locale'][$locale]['s_car_type']; ?></td>
    </tr>
    <?php ?>
    <?php if( !empty($detail['i_year']) ) { ?>
    <tr>
      <td><label><?php _e('Year''cars_attributes'); ?></label></td>
      <td><?php echo $detail['i_year']; ?></td>
    </tr>
    <?php ?>
    <?php if( !empty($detail['i_num_airbags']) ) { ?>
    <tr>
      <td><label><?php _e('Airbags''cars_attributes'); ?></label></td>
      <td><label><?php echo @$detail['i_num_airbags']; ?></td>
    </tr>
    <?php ?>
    <?php if( !empty($detail['i_doors']) ) { ?>
    <tr>
      <td><label><?php _e('Doors''cars_attributes'); ?></label></td>
      <td><?php echo @$detail['i_doors']; ?></td>
    </tr>
    <?php ?>
    <?php if( !empty($detail['i_seats']) ) { ?>
    <tr>
      <td><label><?php _e('Seats''cars_attributes'); ?></label></td>
      <td><?php echo @$detail['i_seats']; ?></td>
    </tr>
    <?php ?>
    <?php if( !empty($detail['i_mileage']) ) { ?>
    <tr>
      <td><label><?php _e('Mileage''cars_attributes'); ?></label></td>
      <td><?php echo @$detail['i_mileage']; ?></td>
    </tr>
    <?php ?>
    <?php if( !empty($detail['i_gears']) ) { ?>
    <tr>
      <td><label><?php _e('Cyl''cars_attributes'); ?></label></td>
      <td><?php echo @$detail['i_gears']; ?></td>
    </tr>
    <?php ?>
    <?php if( !empty($detail['e_transmission']) ) { ?>
    <tr>
      <?php $transmission = array('AUTO' => __('Auto''cars_attributes'), 'MANUAL' => __('Manual''cars_attributes')); ?>
      <td><label><?php _e('Trans''cars_attributes'); ?></label></td>
      <td><label><?php echo $transmission[$detail['e_transmission']]; ?></td>
    </tr>
    <?php ?>
    <?php if( !empty($detail['e_fuel']) ) { ?>
    <tr>
      <?php $fuel = array('GASOLINE'      => __('Gasoline''cars_attributes')
                 ,
'DIESEL'    => __('Diesel''cars_attributes')
                 ,
'ELECTRIC-HIBRID' => __('Electric-hibrid''cars_attributes')
                 ,
'OTHER'       => __('Other''cars_attributes'));
      
?>

      <td><label><?php _e('Fuel''cars_attributes'); ?></label></td>
      <td><label><?php echo $fuel[$detail['e_fuel']]; ?></td>
    </tr>
    <?php ?>
  </table>
</div>

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
item_edit.php

Code: [Select]
<script type="text/javascript">
  $(document).ready(function(){
    $('body').on('change', 'select[name="make"]', function(){
      var make_id = $(this).val();
      var url = '<?php echo osc_ajax_plugin_url('cars_attributes/ajax.php') . '&makeId='?>' + make_id;
      var result = '';
      if(make_id != '') {
        $('select[name="model"]').attr('disabled',false);
        $.ajax({
          type: "POST",
          url: url,
          dataType: 'json',
          success: function(data){
            var length = data.length;
            if(length > 0) {
              result += '<option value="" selected><?php _e('Select a model''cars_attributes'); ?></option>';
              for(key in data) {
                result += '<option value="' + data[key].pk_i_id + '">' + data[key].s_name + '</option>';
              }
            } else {
              result += '<option value=""><?php _e('No results''cars_attributes'); ?></option>';
            }
            $('select[name="model"]').html(result);
          }
         });
       } else {
        result += '<option value="" selected><?php _e('Select a model''cars_attributes'); ?></option>';
        $('select[name="model"]').attr('disabled',true);
        $('select[name="model"]').html(result);
       }
    });
   
    tabberAutomatic();
  });
</script>
<h2><?php _e('Car details''cars_attributes') ; ?></h2>
<div>
    <div class="row _200">
    <?php
      
if( Session::newInstance()->_getForm('pc_seller') != '' ) {
        
$detail['e_seller'] = Session::newInstance()->_getForm('pc_seller');
      }
    
?>

    <label><?php _e('Seller''cars_attributes'); ?></label>
    <select name="seller" id="seller">
      <option value="OWNER" <?php if(@$detail['e_seller'] == 'OWNER') { echo 'selected'; } ?>><?php _e('Owner''cars_attributes'); ?></option>
      <option value="DEALER" <?php if(@$detail['e_seller'] == 'DEALER') { echo 'selected'; } ?>><?php _e('Dealer''cars_attributes'); ?></option>
    </select>
  </div>
  <div class="row _20">
    <?php
      
if( Session::newInstance()->_getForm('pc_warranty') != '' ) {
        
$detail['b_warranty'] = Session::newInstance()->_getForm('pc_warranty');
      }
    
?>

    <input type="checkbox" name="warranty" id="warranty" value="1" <?php if(@$detail['b_warranty'] == 1) { echo 'checked="yes"'; } ?> /> <label><?php _e('Warranty''cars_attributes'); ?></label>
  </div>
  <div class="row _20">
    <?php
      
if( Session::newInstance()->_getForm('pc_new') != '' ) {
        
$detail['b_new'] = Session::newInstance()->_getForm('pc_new');
      }
    
?>

    <input type="checkbox" name="new" id="new" value="1" <?php if(@$detail['b_new'] == 1) { echo 'checked="yes"'; } ?> /> <label><?php _e('New''cars_attributes'); ?></label>
  </div> 
  <div class="row _200">
    <?php
      
if( Session::newInstance()->_getForm('pc_make') != '' ) {
        
$detail['fk_i_make_id'] = Session::newInstance()->_getForm('pc_make');
      }
    
?>

    <label><?php _e('Make''cars_attributes'); ?></label>
    <select name="make" id="make" >
      <option value=""><?php _e('Select a make''cars_attributes'); ?></option>
      <?php foreach($makes as $a){ ?>
      <option value="<?php echo $a['pk_i_id']; ?>" <?php if(@$detail['fk_i_make_id'] == $a['pk_i_id']) { echo 'selected'; } ?>><?php echo $a['s_name']; ?></option>
      <?php ?>
    </select>
  </div>
  <div class="row _200">
    <?php
      
if( Session::newInstance()->_getForm('pc_model') != '' ) {
        
$detail['fk_i_model_id'] = Session::newInstance()->_getForm('pc_model');
      }
    
?>

    <label><?php _e('Model''cars_attributes'); ?></label>
    <select name="model" id="model">
      <option value="" selected><?php _e('Select a model''cars_attributes'); ?></option>
      <?php foreach($models as $a) { ?>
      <option value="<?php echo $a['pk_i_id']; ?>" <?php if(@$detail['fk_i_model_id'] == $a['pk_i_id']) { echo 'selected'; } ?>><?php echo $a['s_name']; ?></option>
      <?php ?>
    </select>
  </div>
  <div class="row _200">
    <?php $locales osc_get_locales();
    if( 
Session::newInstance()->_getForm('pc_car_type') != '' ) {
      
$detail['fk_vehicle_type_id'] = Session::newInstance()->_getForm('pc_car_type');
    }
    if(
count($locales)==1) {
      
$locale $locales[0]; ?>

      <p>
        <label><?php _e('Car type''cars_attributes'); ?></label>
        <select name="car_type" id="car_type">
          <option value="" selected><?php _e('Select a car type''cars_attributes'); ?></option>
          <?php foreach($car_types[$locale['pk_c_code']] as $k => $v) { ?>
          <option value="<?php echo  $k?>" <?php if(@$detail['fk_vehicle_type_id'] == $k) { echo 'selected'; } ?>><?php echo @$v?></option>
          <?php ?>
        </select>
      </p>
    <?php } else { ?>
      <div class="tabber">
      <?php foreach($locales as $locale) {?>
        <div class="tabbertab">
          <h2><?php echo $locale['s_name']; ?></h2>
          <p>
            <label><?php _e('Car type''cars_attributes'); ?></label>
            <select name="car_type" id="car_type">
              <option value="" selected><?php _e('Select a car type''cars_attributes'); ?></option>
             
              <?php if(isset($locale['pk_c_code']) && isset($car_types[$locale['pk_c_code']]) && is_array($car_types[$locale['pk_c_code']]) && count($car_types[$locale['pk_c_code']]) > 0) { ?>
                <?php foreach($car_types[$locale['pk_c_code']] as $k => $v) { ?>
                  <option value="<?php echo  $k?>" <?php if(@$detail['fk_vehicle_type_id'] == $k) { echo 'selected'; } ?>><?php echo @$v?></option>
                <?php ?>
              <?php ?>
            </select>
          </p>
        </div>
      <?php ?>
      </div>
    <?php ?>
  </div>
  <div class="row _200">
    <?php
      
if( Session::newInstance()->_getForm('pc_year') != '' ) {
        
$detail['i_year'] = Session::newInstance()->_getForm('pc_year');
      }
    
?>

    <label><?php _e('Year Model''cars_attributes'); ?></label>
    <input type="text" name="year" id="year" value="<?php echo @$detail['i_year']; ?>" size=4 />
  </div>
    <div class="row auto">
    <?php
      
if( Session::newInstance()->_getForm('pc_num_airbags') != '' ) {
        
$detail['i_num_airbags'] = Session::newInstance()->_getForm('pc_num_airbags');
      }
    
?>

    <label><?php _e('Airbags''cars_attributes'); ?></label>
    <select name="num_airbags" id="num_airbags">
<option value=""><?php _e('Select num. of airbags''cars_attributes'); ?></option>
      <?php foreach(range(18) as $n) { ?>
      <option value="<?php echo $n?>" <?php if(@$detail['i_num_airbags'] == $n) { echo 'selected'; } ?>><?php echo $n?></option>
      <?php ?>
    </select>
  </div>
  <div class="row auto">
    <?php
      
if( Session::newInstance()->_getForm('pc_doors') != '' ) {
        
$detail['i_doors'] = Session::newInstance()->_getForm('pc_doors');
      }
    
?>

    <label><?php _e('Doors''cars_attributes'); ?></label>
    <select name="doors" id="doors">
<option value=""><?php _e('Select num. of doors''cars_attributes'); ?></option>
    <?php foreach(range(26) as $n) { ?>
      <option value="<?php echo $n?>" <?php if(@$detail['i_doors'] == $n) { echo 'selected'; } ?>><?php echo $n?></option>
    <?php ?>
    </select>
  </div>
  <div class="row auto">
    <?php
      
if( Session::newInstance()->_getForm('pc_seats') != '' ) {
        
$detail['i_seats'] = Session::newInstance()->_getForm('pc_seats');
      }
    
?>

    <label><?php _e('Seats''cars_attributes'); ?></label>
    <select name="seats" id="seats">
<option value=""><?php _e('Select num. of seats''cars_attributes'); ?></option>
      <?php foreach(range(28) as $n) { ?>
      <option value="<?php echo $n?>" <?php if(@$detail['i_seats'] == $n) { echo 'selected'; } ?>><?php echo $n?></option>
      <?php ?>
    </select>
  </div>
  <div class="row _200">
    <?php
      
if( Session::newInstance()->_getForm('pc_mileage') != '' ) {
        
$detail['i_mileage'] = Session::newInstance()->_getForm('pc_mileage');
      }
    
?>

    <label><?php _e('Mileage''cars_attributes'); ?></label>
    <input type="text" name="mileage" id="mileage" value="<?php echo @$detail['i_mileage']; ?>" />
  </div>
  <div class="row auto">
    <?php if( Session::newInstance()->_getForm('pc_gears') != '' ) {
        
$detail['i_gears'] = Session::newInstance()->_getForm('pc_gears');
      }
    
?>

    <label><?php _e('Cyl''cars_attributes'); ?></label>
    <select name="gears" id="gears">
<option value=""><?php _e('Select num. of Cyl.''cars_attributes'); ?></option>
    <?php foreach(range(2,12) as $n) { ?>
      <option value="<?php echo $n?>" <?php if(@$detail['i_gears'] == $n) { echo 'selected'; } ?>><?php echo $n?></option>
    <?php ?>
    </select>
  </div>
  <div class="row _200">
    <?php
      
if( Session::newInstance()->_getForm('pc_transmission') != '' ) {
        
$detail['e_transmission'] = Session::newInstance()->_getForm('pc_transmission');
      }
    
?>

    <label><?php _e('Trans''cars_attributes'); ?></label>
    <select name="transmission" id="transmission">
      <option value="AUTO" <?php if(@$detail['e_transmission'] == 'AUTO') { echo 'selected'; } ?>><?php _e('Auto''cars_attributes'); ?></option>
      <option value="MANUAL" <?php if(@$detail['e_transmission'] == 'MANUAL') { echo 'selected'; } ?>><?php _e('Manual''cars_attributes'); ?></option>
    </select>
  </div>
  <div class="row _200">
    <?php
      
if( Session::newInstance()->_getForm('pc_fuel') != '' ) {
        
$detail['e_fuel'] = Session::newInstance()->_getForm('pc_fuel');
      }
    
?>

    <label><?php _e('Fuel''cars_attributes'); ?></label>
    <select name="fuel" id="fuel">
      <option value="GASOLINE" <?php if(@$detail['e_fuel'] == 'GASOLINE') { echo 'selected'; } ?>><?php _e('Gasoline''cars_attributes'); ?></option>
      <option value="DIESEL" <?php if(@$detail['e_fuel'] == 'DIESEL') { echo 'selected'; } ?>><?php _e('Diesel''cars_attributes'); ?></option>
      <option value="ELECTRIC-HYBRID" <?php if(@$detail['e_fuel'] == 'ELECTRIC-HYBRID') { echo 'selected'; } ?>><?php _e('Electric-hybrid''cars_attributes'); ?></option>
      <option value="OTHER" <?php if(@$detail['e_fuel'] == 'OTHER') { echo 'selected'; } ?>><?php _e('Other''cars_attributes'); ?></option>
    </select>
  </div>
</div>


--------------------------------------------------------------------------------------------------------------------------------------------------
« Last Edit: January 25, 2022, 11:08:03 AM by Sparky »