{source}
<?php
defined('_JEXEC') or die('Restricted access');
$document = &JFactory::getDocument();
//$document->addScript(JURI::root().'components/com_k2/templates/k2tabberfree/includes/simpletabs_1.3.js');
$document->addScript('components/com_k2/templates/k2tabberfree/includes/simpletabs_1.3.js');
$document->addScript('components/com_k2/templates/k2tabberfree/includes/base-model-number.js');
$document->addScript('components/com_k2/templates/k2tabberfree/includes/back-to-top/js/main.js');
$document->addStyleSheet('components/com_k2/templates/k2tabberfree/includes/back-to-top/css/demo.css');
$document->addStyleSheet('components/com_k2/templates/k2tabberfree/includes/back-to-top/css/reset.css');
$document->addStyleSheet('components/com_k2/templates/k2tabberfree/includes/back-to-top/css/style.css');
$document->addStyleSheet('components/com_k2/templates/k2tabberfree/includes/k2tabber.css');
$document->addStyleSheet('https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css');
$document->addScript('js/reseller/jquery-2.2.3.min.js');
$document->addScript('js/reseller/jquery.dataTables.min.js');
$document->addStyleSheet('js/reseller/jquery.dataTables.min.css');
?>
<script type="text/javascript">
( function($) {$(document).ready( function () {
console.log("<?php echo $_GET["model"]; ?>");
var base_model = "<?php echo $_GET["model"]; ?>";
var product_family = "Converter";
var website = "provantage";
var provantage = "/components/com_ajax/reseller_ajax.php?website="+website+"&model=";
var data_table_request = false;
$.ajax({timeout: 5000,"type": "POST", "url": provantage + base_model, success: function(data){
console.log("Data 1: " + data);
var ajax_call = JSON.parse(data);
var product_info = "<div id='base-model-info2'>" +
"</br>"+"<img src='https://www.provantage.com"+ajax_call['img']+"' align='left' width='75' style='margin-left: 5px; margin-right: 10px;' >"+
"<p align='left' style='font-size: 15px;' >" +
"Buy " + "<strong>" + product_family + " " + base_model + "</strong>" + " online " +
"<br>"+ ajax_call['total_products'] +" products found at "+ ajax_call['distributors'] + " distributor" +
"</p>"+
"</div>";
if(ajax_call['img'] != null)
$("div#base-model-info").append(product_info);
var table = $('#example').DataTable({
retrieve: false,
"searching": false,
"timeout": 2500,
paging: false,
'ajax': provantage + base_model,
'aoColumns': [
{ 'data': "distributor"
,'title': "Distributor"
},
{ 'data': "model"
,'title': "Model #"
,'render': function ( data, type, row, meta ) {
// If data is being displayed
console.log("Data 2:"+data);
var str = data.replace("Omnitron Systems Technology Part", "1");
return str;
},
},
{ 'data': "description"
,'title': "Description"
},
{ 'data': "price"
,'title': "Price"
},
{ 'data': "stock"
,'title': "Stock"
},
{ 'data': "href"
,'title': ""
,'render': function ( data, type, row, meta ) {
// If data is being displayed
return '<a href="https://www.provantage.com'+ data +'"' + ' target="_blank">'+'Buy Online'+'</a>';
},
}
],
"columnDefs": [
{ "width": "10%", "targets": 0 }
,{ "width": "10%", "targets": 1 }
,{ "width": "30%", "targets": 2, "orderable": false}
,{ "width": "8%", "targets": 3, "orderable": false}
,{ "width": "10%", "targets": 4, "orderable": false}
,{ "width": "10%", "targets": 5, "orderable": false ,"className": "dt-center" }
],
"oLanguage": {
"sEmptyTable": "<br><p align='left' style='font-size: 15px;' >" + "<strong>" + product_family + " " + base_model + "</strong>" + " currently not available at Omnitron online resellers" + "<br><a href='/support/contact-us.php' target='_blank' >Contact Omnitron for assistance with a quote</a>" + "</p"
}
});//Table Config
data_table_request = true;
},//End of Ajax
error: function(xhr, status, error){
if( data_table_request == true ){
$('#example').dataTable().fnDestroy();
data_table_request = false;
}
if ( $( "#error_message" ).length ){
document.getElementById("error_message").remove();
}
var err_message =
"<div id='error_message'>"+
"<br>"+"<img src='/images/reseller/caution.png' align='left' width='75' style='margin-left: 5px; margin-right: 5px;' >"+
"<br><p align='left' style='font-size: 15px;' >" +
"Unable to process this product search request at this time" +
"<br><a href='/support/contact-us.php' target='_blank' >Can’t find a Product or Need Help? Contact Omnitron for assistance with a quote</a>" +
"</p"+
"</div>";
$("table#example").append(err_message);
}
}); //End Ajax
});
} ) ( jQuery );
</script>
<div id="base-model-info" ></div>
<table id="example" class="display" width="100%"> <img id="model_img" >
</table>
{/source}