Theme work with focusbusiness and baseadmin
Improvements to NAVBAR, updates to StaticList methods, other minor items Enable product category rendering and other minor improvements Added ADSL-large category price plan
This commit is contained in:
@@ -9,48 +9,165 @@
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_Admin_Product extends Controller_TemplateDefault_Admin {
|
||||
class Controller_Admin_Product extends Controller_Product {
|
||||
protected $auth_required = TRUE;
|
||||
|
||||
protected $secure_actions = array(
|
||||
'ajaxtranslateform'=>TRUE,
|
||||
'ajaxtranslatecategory'=>TRUE,
|
||||
'ajaxtranslate'=>TRUE,
|
||||
'category'=>TRUE,
|
||||
'edit'=>TRUE,
|
||||
'list'=>TRUE,
|
||||
'update'=>TRUE,
|
||||
'view'=>TRUE,
|
||||
);
|
||||
|
||||
public function action_ajaxtranslateform() {
|
||||
$this->auto_render = FALSE;
|
||||
|
||||
public function action_ajaxtranslate() {
|
||||
$po = ORM::factory('Product',$this->request->param('id'));
|
||||
|
||||
if (! $this->request->is_ajax() OR ! $po->loaded() OR ! isset($_REQUEST['key']))
|
||||
$this->response->body(_('Unable to find translate data'));
|
||||
|
||||
else {
|
||||
if (! $po->loaded() OR ! isset($_REQUEST['key'])) {
|
||||
$output = _('Unable to find translate data');
|
||||
|
||||
} else {
|
||||
$pto = $po->product_translate->where('language_id','=',$_REQUEST['key'])->find();
|
||||
|
||||
$this->response->body(View::factory($this->viewpath())->set('pto',$pto));
|
||||
$output = View::factory('product/admin/ajaxtranslate')
|
||||
->set('o',$pto);
|
||||
}
|
||||
|
||||
$this->response->body($output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the product category translate record
|
||||
*/
|
||||
public function action_ajaxtranslatecategory() {
|
||||
$pco = ORM::factory('Product_Category',$this->request->param('id'));
|
||||
|
||||
if (! $pco->loaded() OR ! isset($_REQUEST['key'])) {
|
||||
$output = _('Unable to find translate data');
|
||||
|
||||
} else {
|
||||
$pcto = $pco->product_category_translate->where('language_id','=',$_REQUEST['key'])->find();
|
||||
|
||||
$output = View::factory('product/category/admin/ajaxtranslate')
|
||||
->set('o',$pcto);
|
||||
}
|
||||
|
||||
$this->response->body($output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the product category
|
||||
*/
|
||||
public function action_category() {
|
||||
$pco = ORM::factory('Product_Category',$this->request->param('id'));
|
||||
|
||||
if (! $pco->loaded())
|
||||
HTTP::redirect('welcome/index');
|
||||
|
||||
if ($_POST)
|
||||
$pco->values($_POST)->save();
|
||||
|
||||
Script::factory()
|
||||
->type('stdin')
|
||||
->data('
|
||||
$(document).ready(function() {
|
||||
$("select[name=language_id]").change(function() {
|
||||
// If we select a blank, then dont continue
|
||||
if (this.value == 0)
|
||||
return false;
|
||||
|
||||
// Send the request and update sub category dropdown
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
data: "key="+$(this).val(),
|
||||
dataType: "html",
|
||||
cache: false,
|
||||
url: "'.URL::link('admin','product/ajaxtranslatecategory/'.$pco->id,TRUE).'",
|
||||
timeout: 2000,
|
||||
error: function(x) {
|
||||
alert("Failed to submit");
|
||||
},
|
||||
success: function(data) {
|
||||
$("div[id=translate]").replaceWith(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
');
|
||||
|
||||
Block::factory()
|
||||
->type('form-horizontal')
|
||||
->title('Update Category')
|
||||
->title_icon('icon-wrench')
|
||||
->body(View::factory('product/category/admin/edit')
|
||||
->set('o',$pco));
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a product configuration
|
||||
*/
|
||||
public function action_edit() {
|
||||
$po = ORM::factory('Product',$this->request->param('id'));
|
||||
|
||||
if (! $po->loaded())
|
||||
HTTP::redirect('welcome/index');
|
||||
|
||||
if ($_POST)
|
||||
$po->values($_POST)->save();
|
||||
|
||||
Script::factory()
|
||||
->type('stdin')
|
||||
->data('
|
||||
$(document).ready(function() {
|
||||
$("select[name=language_id]").change(function() {
|
||||
// If we select a blank, then dont continue
|
||||
if (this.value == 0)
|
||||
return false;
|
||||
// Send the request and update sub category dropdown
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
data: "key="+$(this).val(),
|
||||
dataType: "html",
|
||||
cache: false,
|
||||
url: "'.URL::link('admin','product/ajaxtranslate/'.$po->id,TRUE).'",
|
||||
timeout: 2000,
|
||||
error: function(x) {
|
||||
alert("Failed to submit");
|
||||
},
|
||||
success: function(data) {
|
||||
$("div[id=translate]").replaceWith(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
');
|
||||
|
||||
Block::factory()
|
||||
->type('form-horizontal')
|
||||
->title('Update Product')
|
||||
->title_icon('icon-wrench')
|
||||
->body(View::factory('product/admin/edit')
|
||||
->set('plugin_form',$po->admin_update())
|
||||
->set('o',$po));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a list of products
|
||||
*/
|
||||
public function action_list() {
|
||||
if ($this->request->param('id'))
|
||||
$prods = ORM::factory('Product_Category',$this->request->param('id'))->products();
|
||||
else
|
||||
$prods = ORM::factory('Product')->order_by('status DESC,prod_plugin_file')->find_all();
|
||||
$products = ($x=$this->request->param('id')) ? ORM::factory('Product_Category',$x)->products() : ORM::factory('Product')->order_by('status DESC,prod_plugin_file')->find_all();
|
||||
|
||||
Block::add(array(
|
||||
'title'=>_('Customer Products'),
|
||||
'body'=>Table::display(
|
||||
$prods,
|
||||
Block::factory()
|
||||
->title(_('Products'))
|
||||
->title_icon('icon-th')
|
||||
->body(Table::display(
|
||||
$products,
|
||||
25,
|
||||
array(
|
||||
'id'=>array('label'=>'ID','url'=>URL::link('admin','product/view/')),
|
||||
'name()'=>array('label'=>'Details'),
|
||||
'status'=>array('label'=>'Active'),
|
||||
'title()'=>array('label'=>'Details'),
|
||||
'status(TRUE)'=>array('label'=>'Active'),
|
||||
'prod_plugin_file'=>array('label'=>'Plugin Name'),
|
||||
'prod_plugin_data'=>array('label'=>'Plugin Data'),
|
||||
'price_type'=>array('label'=>'Price Type'),
|
||||
@@ -62,81 +179,31 @@ class Controller_Admin_Product extends Controller_TemplateDefault_Admin {
|
||||
'page'=>TRUE,
|
||||
'type'=>'select',
|
||||
'form'=>URL::link('admin','product/view'),
|
||||
)),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a product configuration
|
||||
*/
|
||||
public function action_update() {
|
||||
$po = ORM::factory('Product',$this->request->param('id'));
|
||||
|
||||
if (! $po->loaded())
|
||||
HTTP::redirect('welcome/index');
|
||||
|
||||
if ($_POST) {
|
||||
if (isset($_POST['product_translate']['id']) AND ($pto=ORM::factory('Product_Translate',$_POST['product_translate']['id'])) AND $pto->loaded())
|
||||
if (! $pto->values($_POST['product_translate'])->save())
|
||||
throw new Kohana_Exception('Failed to save updates to product_translate data for record :record',array(':record'=>$po->id()));
|
||||
|
||||
if (! $po->values($_POST)->save())
|
||||
throw new Kohana_Exception('Failed to save updates to product data for record :record',array(':record'=>$so->id()));
|
||||
}
|
||||
|
||||
Block::add(array(
|
||||
'title'=>sprintf('%s %s:%s',_('Update Product'),$po->id,$po->name()),
|
||||
'body'=>View::factory($this->viewpath())
|
||||
->set('po',$po)
|
||||
->set('mediapath',Route::get('default/media'))
|
||||
->set('plugin_form',$po->admin_update()),
|
||||
));
|
||||
|
||||
Script::add(array('type'=>'stdin','data'=>'
|
||||
$(document).ready(function() {
|
||||
$("select[name=language_id]").change(function() {
|
||||
// Send the request and update sub category dropdown
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
data: "key="+$(this).val(),
|
||||
dataType: "html",
|
||||
cache: false,
|
||||
url: "'.URL::link('admin','product/ajaxtranslateform/'.$po->id,TRUE).'",
|
||||
timeout: 2000,
|
||||
error: function(x) {
|
||||
alert("Failed to submit");
|
||||
},
|
||||
success: function(data) {
|
||||
$("div[id=translate]").replaceWith(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
'));
|
||||
)));
|
||||
}
|
||||
|
||||
public function action_view() {
|
||||
$po = ORM::factory('Product',$this->request->param('id'));
|
||||
|
||||
Block::add(array(
|
||||
'title'=>sprintf('%s: %s',_('Current Services Using this Product'),$po->name()),
|
||||
'body'=>Table::display(
|
||||
ORM::factory('Service')->where('product_id','=',$po->id)->find_all(),
|
||||
Block::factory()
|
||||
->title(sprintf('%s: %s',_('Current Services Using this Product'),$po->title()))
|
||||
->title_icon('icon-th-list')
|
||||
->body(Table::display(
|
||||
$po->services()->find_all(),
|
||||
25,
|
||||
array(
|
||||
'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),
|
||||
'account->accnum()'=>array(),
|
||||
'account->name()'=>array('label'=>'Account'),
|
||||
'name()'=>array('label'=>'Details'),
|
||||
'status'=>array('label'=>'Active'),
|
||||
'status(TRUE)'=>array('label'=>'Active'),
|
||||
'price(TRUE,TRUE)'=>array('label'=>'Price','align'=>'right'),
|
||||
),
|
||||
array(
|
||||
'page'=>TRUE,
|
||||
'type'=>'select',
|
||||
'form'=>URL::link('user','service/view'),
|
||||
)),
|
||||
));
|
||||
)));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user