Many updates as a result of updating lnapp; added SSL service order

This commit is contained in:
Deon George
2016-06-05 22:33:12 +10:00
parent 44769e3de7
commit 0c7fe830a3
25 changed files with 384 additions and 268 deletions

View File

@@ -13,14 +13,27 @@ class Controller_Admin_Product extends Controller_Product {
protected $auth_required = TRUE;
protected $secure_actions = array(
'ajaxaccounting'=>TRUE,
'ajaxtranslatecategory'=>TRUE,
'ajaxtranslate'=>TRUE,
'category'=>TRUE,
'edit'=>TRUE,
'list'=>TRUE,
'listused'=>TRUE,
'view'=>TRUE,
);
public function action_ajaxaccounting() {
$products = ORM::factory('Product')->where('accounting','LIKE','%'.$this->request->query('term').'%')->find_all();
$result = array();
foreach ($products as $po)
array_push($result,array('value'=>$po->accounting,'label'=>$po->accounting));
$this->response->headers('Content-Type','application/json');
$this->response->body(json_encode(array_values($result)));
}
public function action_ajaxtranslate() {
$po = ORM::factory('Product',$this->request->param('id'));
@@ -140,13 +153,56 @@ $(document).ready(function() {
}
});
});
$("input[name=accounting]").typeahead({
minLength: 2,
source: function (query,process) {
accounting(\'a/product/ajaxaccounting\',query,process);
},
matcher: function () { return true; },
});
});
var d=0;
var accounting = _.debounce(function(url,query,process){
$.ajax({
url : site_url+url,
type : "GET",
data : "term=" + query,
dataType : "JSON",
async : true,
cache : false,
beforeSend : function() {
if (d++ == 0) $(\'i[name=acclook]\').removeClass("hidden");
},
success : function(data) {
// if json is null, means no match, won\'t do again.
if(data==null || (data.length===0)) return;
users = {};
userLabels = [];
_.each(data,function(item,ix,list) {
if (_.contains(users,item.label)) item.label = item.label + \' #\' + item.value;
userLabels.push(item.label);
users[item.label] = item.value;
});
process(userLabels);
},
complete : function() {
if (--d == 0) $(\'i[name=acclook]\').addClass("hidden");
}
})
}, 500);
');
Block::factory()
->type('form-horizontal')
->title('Update Product')
->title_icon('icon-wrench')
->title_icon('fa fa-wrench')
->body(View::factory('product/admin/edit')
->set('plugin_form',$po->plugin_edit())
->set('o',$po));
@@ -156,30 +212,33 @@ $(document).ready(function() {
* Show a list of products
*/
public function action_list() {
$products = ($x=$this->request->param('id')) ? ORM::factory('Product_Category',$x)->products() : ORM::factory('Product')->order_by('status','DESC')->order_by('prod_plugin_file')->find_all();
$products = ($x=ORM::factory('Product_Category',$this->request->param('id')) AND $x->loaded()) ? $x->products() : ORM::factory('Product')->order_by('status','DESC')->order_by('prod_plugin_file')->find_all();
Block::factory()
->title(_('Products'))
->title_icon('icon-th')
->body(Table::factory()
->data($products)
->page_items(25)
->columns(array(
'id'=>'ID',
'title()'=>'Details',
'status'=>'Active',
'prod_plugin_file'=>'Plugin Name',
'prod_plugin_data'=>'Plugin Data',
'price_type'=>'Price Type',
'taxable'=>'Taxable',
'service->list_count()'=>'Services',
'invoice->list_count()'=>'Invoices',
))
->prepend(array(
'id'=>array('url'=>URL::link('admin','product/edit/')),
)));
->title(_('Products').($x->loaded() ? ' - '.$x->name() : ' - All'))
->title_icon('fa fa-list')
->body(View::factory('product/list')->set('list',$products));
}
/**
* List all the products that have an active service
*/
public function action_listused() {
$db = Database::instance();
$columns = '';
foreach (array_keys(ORM::factory('Product')->table_columns()) as $text)
$columns .= ($columns ? ',' : '').'p.'.$text;
$products = $db->query(Database::SELECT,sprintf('SELECT %s FROM ab_product p,ab_service s WHERE s.product_id=p.id AND s.status=1 AND p.site_id = s.site_id AND s.site_id=%s GROUP BY p.id',$columns,Company::instance()->site()),'Model_Product');
Block::factory()
->title(_('Products with Active Services'))
->title_icon('fa fa-list')
->body(View::factory('product/list')->set('list',$products));
}
public function action_view() {
$po = ORM::factory('Product',$this->request->param('id'));