/home/techb158/exp.abdallabala.com/application/controllers
Edit: /home/techb158/exp.abdallabala.com/application/controllers/tax.php (5024B)
assign('_application_menu', 'settings');
$ui->assign('_title', $_L['Accounts'] . '- ' . $config['CompanyName']);
$ui->assign('_st', $_L['TAX']);
$action = $routes['1'];
$user = User::_info();
$ui->assign('user', $user);
switch ($action) {
case 'list':
$paginator = Paginator::bootstrap('sys_tax');
$d = ORM::for_table('sys_tax')
->offset($paginator['startpoint'])
->limit($paginator['limit'])
->order_by_desc('id')
->find_many();
$ui->assign('d', $d);
$ui->assign('paginator', $paginator);
$ui->assign(
'xjq',
'
$(".cdelete").click(function (e) {
e.preventDefault();
var id = this.id;
bootbox.confirm("' .
$_L['are_you_sure'] .
'", function(result) {
if(result){
var _url = $("#_url").val();
window.location.href = _url + "delete/tax/" + id;
}
});
});
'
);
$ui->assign('ib_money_format_apply', true);
Event::trigger('tax/list/');
$ui->display('list-tax.tpl');
break;
case 'modal-form':
echo '
';
break;
case 'edit-form':
$id = $routes['2'];
$d = ORM::for_table('sys_tax')->find_one($id);
if ($d) {
echo '
';
} else {
echo 'not found';
}
break;
case 'add-post':
$msg = '';
$rate = _post('rate');
$name = _post('name');
if ($name == '') {
$msg .= 'Name is Required
';
}
if (!is_numeric($rate)) {
$msg .= 'Invalid Tax Rate
';
}
if ($msg == '') {
$d = ORM::for_table('sys_tax')->create();
$d->name = $name;
$d->rate = $rate;
$d->save();
echo $d->id();
} else {
echo $msg;
}
break;
case 'edit-post':
$msg = '';
$id = _post('id');
$rate = _post('rate');
$name = _post('name');
if ($name == '') {
$msg .= 'Name is Required
';
}
if (!is_numeric($rate)) {
$msg .= 'Invalid Tax Rate
';
} else {
}
if ($msg == '') {
$d = ORM::for_table('sys_tax')->find_one($id);
if ($d) {
$d->name = $name;
$d->rate = $rate;
$d->save();
echo $d->id();
} else {
echo 'Not Found';
}
} else {
echo $msg;
}
break;
case 'delete':
$id = $routes['2'];
$d = ORM::for_table('sys_tax')->find_one($id);
if ($d) {
$d->delete();
}
break;
case 'rate':
$tid = _post('tid');
$d = ORM::for_table('sys_tax')->find_one($tid);
if ($d) {
echo $d['rate'];
} else {
echo '0.00';
}
break;
default:
echo 'action not defined';
}