public function actionSubmitApplication() { $me = _G('ME'); $group = _G('GROUP'); if (!$me->id || !$group->id || !$me->isAllowedTo('设置')) { return; } $form = $this->form('post'); $type = trim($form['type']); $casNO = trim($form['cas_no']); $volume = trim($form['volume']); $reason = trim($form['reason']); if (!$reason) { return \Gini\IoC::construct('\\Gini\\CGI\\Response\\JSON', ['code' => 1, 'message' => T('请填写申请理由')]); } $title = \Gini\ORM\ChemicalLimits\Request::getTypeTtile($type); if (!$type || !$title) { return \Gini\IoC::construct('\\Gini\\CGI\\Response\\JSON', ['code' => 2, 'message' => T('请选择分类')]); } if ($casNO) { $chemInfo = \Gini\ChemDB\Client::getChemicalInfo($casNO); if (empty($chemInfo)) { return \Gini\IoC::construct('\\Gini\\CGI\\Response\\JSON', ['code' => 3, 'message' => T('请重新选择化学品')]); } $chem = ['cas' => $casNO, 'state' => $chemInfo['state'], 'default']; } else { $chem = ['default']; } if (!\Gini\Unit\Conversion::of($chem)->validate($volume)) { return \Gini\IoC::construct('\\Gini\\CGI\\Response\\JSON', ['code' => 4, 'message' => T('上限设置格式错误,请输入数字+单位,例5mg(目前系统支持单位: 瓶/bottle/ml/g/cm3/ul/μl/ml/cl/dl/l/gal/lb/ug/μg/mg/kg/oz/lb/)')]); } $rpc = \Gini\Module\HazardousControlOrders::getRPC('chemical-limits'); $result = (bool) $rpc->admin->inventory->addRequest(['type' => $type, 'cas_no' => $casNO, 'volume' => $volume, 'group_id' => $group->id, 'owner_id' => $me->id, 'reason' => $reason]); return \Gini\IoC::construct('\\Gini\\CGI\\Response\\JSON', ['code' => $result ? 0 : 5, 'message' => $result ? T('上限申请提交成功') : T('提交上限申请失败,请重试')]); }
public function __index($page = 1) { $me = _G('ME'); $group = _G('GROUP'); if (!$me->id || !$group->id || !$me->isAllowedTo('设置')) { $this->redirect('error/401'); } $rpc = \Gini\Module\HazardousControlOrders::getRPC('chemical-limits'); $limits = $rpc->admin->inventory->getGroupLimits($group->id); $page = (int) $page; $vars = ['limits' => $limits, 'requestsHTML' => \Gini\CGI::request("ajax/settings/chemical-limits/requests-more/{$page}", $this->env)->execute()->content()]; $this->view->body = V('settings/chemical-limits', $vars); }
public function testShortcuts() { _G('@foo', 'bar'); $this->assertEquals(_G('@foo'), 'bar'); $this->assertEquals(_G('@foobar'), null); $s = s('Hello, %s!', 'world'); $this->assertEquals($s, 'Hello, world!'); $s = s('Hello, %s!'); $this->assertEquals($s, 'Hello, %s!'); $h = H('<html>'); $this->assertEquals($h, '<html>'); $h = H('<html> %s', '<html>'); $this->assertEquals($h, '<html> <html>'); $v = V('layout'); $this->assertTrue($v instanceof \Gini\View); }
function _GE($name) { G($name . "_"); _log("----------------------------Completed: " . _G($name) . "s", str_pad($name, 50 - _GW(0), "#", STR_PAD_LEFT), "Benchmark", "DEBUG"); _GW(-8); }
public static function headerSettingsMenu($e, $menu) { $me = _G('ME'); if ($me->id && $me->isAllowedTo('管理订单')) { $menu['general']['chemical-limits'] = ['url' => 'settings/chemical-limits', 'title' => T('化学品库存上限')]; } }