TRUE, 'listdomainservicesbydnshost'=>TRUE, 'listhostservicesbysupplier'=>TRUE, 'update'=>TRUE, 'view'=>TRUE, ); public function action_listdomainservicesbysupplier() { $svs = ORM::factory('Service')->list_bylistgroup('DOMAIN'); Sort::MAsort($svs,'plugin()->domain_registrar_id,name()'); $list = array(); foreach ($svs as $so) $list[$so->plugin()->domain_registrar_id][] = $so; foreach (array_keys($list) as $sid) Block::add(array( 'title'=>sprintf(_('Domain Names by Supplier %s'),$sid), 'body'=>Table::display( $list[$sid], 25, array( 'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')), 'service_name()'=>array('label'=>'Details'), 'plugin()->display("domain_expire")'=>array('label'=>'Expire'), 'recur_schedule'=>array('label'=>'Billing'), 'price(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'), 'account->accnum()'=>array('label'=>'Cust ID'), 'account->name()'=>array('label'=>'Customer'), 'display("date_next_invoice")'=>array('label'=>'Next Invoice'), ), array( 'page'=>TRUE, 'type'=>'select', 'form'=>URL::link('user','service/view'), )), )); } public function action_listdomainservicesbydnshost() { $svs = ORM::factory('Service')->list_bylistgroup('DOMAIN'); Sort::MAsort($svs,'plugin()->service_plugin_host,name()'); $list = array(); foreach ($svs as $so) $list[$so->plugin()->service_plugin_host->host_server_id][] = $so; foreach (array_keys($list) as $sid) Block::add(array( 'title'=>sprintf(_('Domain Names by DNS Host [%s]'),$sid), 'body'=>Table::display( $list[$sid], 25, array( 'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')), 'service_name()'=>array('label'=>'Details'), 'plugin()->domain_registrar->id'=>array('label'=>'SID'), 'plugin()->domain_registrar->name'=>array('label'=>'Supplier'), 'display("date_next_invoice")'=>array('label'=>'Next Invoice'), ), array( 'page'=>TRUE, 'type'=>'select', 'form'=>URL::link('user','service/view'), )), )); } public function action_listhostservicesbysupplier() { $svs = ORM::factory('Service')->list_bylistgroup('HOST'); Sort::MAsort($svs,'plugin()->host_server,name()'); $list = array(); foreach ($svs as $so) $list[$so->plugin()->host_server_id][] = $so; foreach (array_keys($list) as $sid) Block::add(array( 'title'=>sprintf(_('Hosting by Supplier %s'),$sid), 'body'=>Table::display( $list[$sid], 25, array( 'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')), 'service_name()'=>array('label'=>'Details'), 'plugin()->display("host_expire")'=>array('label'=>'Expire'), 'recur_schedule'=>array('label'=>'Billing'), 'price(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'), 'account->accnum()'=>array('label'=>'Cust ID'), 'account->name()'=>array('label'=>'Customer'), 'display("date_next_invoice")'=>array('label'=>'Next Invoice'), ), array( 'page'=>TRUE, 'type'=>'select', 'form'=>URL::link('user','service/view'), )), )); } public function action_update() { list($id,$output) = Table::page(__METHOD__); $so = ORM::factory('Service',$id); if (! $so->loaded()) HTTP::redirect('welcome/index'); if ($_POST) { // Entry updated if (isset($_POST['plugin']) AND $_POST['plugin']) { $p = $so->plugin(); if ($p->values($_POST['plugin'])->changed() AND ! $this->save($p)) $p->reload(); } if ($so->values($_POST)->changed() AND ! $this->save($so)) $so->reload(); } Script::factory() ->type('file') ->data('media/theme/bootstrap/vendor/datepicker/js/bootstrap-datepicker.js'); Style::factory() ->type('file') ->data('media/theme/bootstrap/vendor/datepicker/css/datepicker.css'); Script::factory() ->type('stdin') ->data(' var nowTemp = new Date(); var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0); $(document).ready(function() { $("#date_next_invoice_label").datepicker({ autoclose : true, startDate : now, format : "dd-M-yyyy", todayBtn : true, }).on("hide",function(ev) { $("input[name=date_next_invoicel]").val(ev.date.valueOf()/1000); }); }); '); Block::factory() ->type('form-horizontal') ->title(sprintf('%s: %s %s',_('Update Service'),$id,$so->name())) ->title_icon('icon-wrench') ->body(View::factory('service/admin/edit') ->set('o',$so) ->set('plugin_form',$so->admin_update()) ); } public function action_view() { list($id,$output) = Table::page(__METHOD__); $so = ORM::factory('Service',$id); if (! $so->loaded() OR ! Auth::instance()->authorised($so->account)) throw HTTP_Exception::factory(403,'Service either doesnt exist, or you are not authorised to see it'); $doutput = $loutput = ''; $loutput .= View::factory('service/admin/view') ->set('o',$so); // Validate the transactions $bt = NULL; $save = (isset($_REQUEST['go']) && $_REQUEST['go']=1) ? 1 : 0; $xsid=197; foreach ($so->transactions()->where('item_type','=',0)->find_all() as $iio) { if (! $iio->invoice->status) continue; // @todo This hard coding of 3070 should be removed. if ($iio->service_id == $xsid AND $iio->invoice_id < 3070) continue; if ($iio->quantity < 0 OR $iio->price_base < 0) continue; if (in_array($iio->id,array(960))) continue; if ($iio->invoice_id > 4000 OR $iio->product->prod_plugin_file=="ADSL") $a = FALSE; else $a = TRUE; if (is_null($bt)) $bt = $iio->date_start; $pdata = Period::details($iio->recurring_schedule,$a ? NULL : $iio->product->price_recurr_weekday,$bt,TRUE,TRUE); switch ($iio->recurring_schedule) { case 1: case 2: case 4: case 5: if ($iio->date_start != $pdata['start_time']) { $doutput .= sprintf('%s: Set start_time: %s [%s]
',$iio->id,Config::date($pdata['start_time']),$pdata['start_time']); $iio->date_start=$pdata['start_time']; } if ($iio->date_stop != $pdata['end_time']) { $doutput .= sprintf('%s: Set end_time: %s [%s]
',$iio->id,Config::date($pdata['end_time']),$pdata['end_time']); $iio->date_stop=$pdata['end_time']; } $bt = $pdata['end_time']+86400; //$doutput .= sprintf('%s: BT now: %s (%s) [%s]
',$iio->id,Config::date($bt),Config::date($pdata['end_time']),$bt); break; default: $doutput .= sprintf('%s: %s Not handled',$iio->id,$iio->recurring_schedule); } //$doutput .= '
'; if ($save) { $iio->save(); } } if (isset($_REQUEST['go'])) HTTP::redirect(URL::link('admin','service/view/'.$so->id)); Block::add(array( 'title'=>sprintf('Transaction History for %s: %s',$so->id(),$so->name()), 'body'=>$loutput, )); Block::add(array( 'title'=>sprintf('Transaction Debug for %s: %s',$so->id(),$so->name()), 'body'=>$doutput, )); $output .= View::factory('service/user/view') ->set('o',$so); Block::add(array( 'title'=>sprintf('%s: %s',$so->id(),$so->service_name()), 'body'=>$output, )); } } ?>