Overhauled export, and other minor updates

This commit is contained in:
Deon George
2013-05-14 23:53:04 +10:00
parent 81cb759667
commit c56742d127
33 changed files with 690 additions and 652 deletions

View File

@@ -1,31 +1,34 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports OSB exporting by rending the exportable items.
* This class supports OSB exporting.
*
* @package Export
* @category Helpers
* @category Model
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Export extends ORM_OSB {
protected $_serialize_column = array(
'map_data',
// Relationships
protected $_has_many = array(
'export_module' => array('far_key'=>'id','xforeign_key'=>'x'),
);
public function list_itemsnoexport() {
$result = array();
protected $_form = array('id'=>'id','value'=>'name');
$mo = ORM::factory('Module',array('name'=>'product'));
$p = ORM::factory('Product')
->order_by('id');
/**
* Return the object of the product plugin
*/
public function plugin(Model_Export_Module $emo,$type='') {
$c = Kohana::classname('Export_Plugin_'.$this->plugin);
foreach ($p->find_all() as $po)
if (! ORM::factory('Export')->where('module_id','=',$mo->id)->where('item_id','=',$po->id)->find()->loaded())
$result[$po->id] = $po;
if (! $this->plugin OR ! class_exists($c))
return NULL;
return $result;
$o = new $c($emo);
return $type ? $o->$type : $o;
}
}
?>

View File

@@ -0,0 +1,36 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports OSB exporting.
*
* @package Export
* @category Model
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Export_DataMap extends ORM_OSB {
// Relationships
protected $_belongs_to = array(
'export_module' => array(),
'module' => array(),
);
public function list_itemsnoexport(Model $o,$emoid,$desc='title()') {
$result = array();
$o->select(array($this->table_name().'.id','edm'))
->join($this->table_name(),'LEFT OUTER')
->on($this->table_name().'.site_id','=',$o->table_name().'.site_id') // @todo This should be automatic
->on($this->table_name().'.item_id','=',$o->table_name().'.id')
->on('export_module_id','=',$emoid)
->where($o->table_name().'.status','=',TRUE)
->having('edm','=',NULL);
foreach ($o->find_all() as $object)
$result[$object->id] = $object->resolve($desc);
return $result;
}
}
?>

View File

@@ -0,0 +1,18 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports OSB exporting.
*
* @package Export
* @category Model
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Export_Item extends ORM_OSB {
// Relationships
protected $_belongs_to = array(
'export_module' => array(),
);
}
?>

View File

@@ -0,0 +1,42 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports OSB exporting.
*
* @package Export
* @category Model
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Export_Module extends ORM_OSB {
protected $_created_column = FALSE;
protected $_updated_column = FALSE;
// Relationships
protected $_belongs_to = array(
'export' => array(),
'module' => array(),
);
protected $_has_many = array(
'export_item' => array('far_key'=>'id'),
);
protected $_nullifempty = array(
'display',
);
public function list_export() {
$o = $this->module->module();
return $o
->select(array($this->export_item->table_name().'.date_orig','exported'))
->join($this->export_item->table_name(),'LEFT OUTER')
->on($this->export_item->table_name().'.site_id','=',$o->table_name().'.site_id') // @todo This should be automatic
->on($this->export_item->table_name().'.item_id','=',$o->table_name().'.id')
->on('export_module_id','=',$this->id)
->where($o->table_name().'.date_orig','>=',time()-86400*90)
->find_all();
}
}
?>