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 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('提交上限申请失败,请重试')]); }