/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Contract::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['contr_id' => $this->contr_id, 'is_lock' => $this->is_lock, 'lock_time' => $this->lock_time, 'status' => $this->status, 'audit_status' => $this->audit_status, 'is_submit' => $this->is_submit, 'sub_time' => $this->sub_time, 'sign_time' => $this->sign_time, 'price' => $this->price, 'num' => $this->num, 'createtime' => $this->createtime, 'modified' => $this->modified]); $query->andFilterWhere(['like', 'contr_no', $this->contr_no])->andFilterWhere(['like', 'vercode', $this->vercode])->andFilterWhere(['like', 'type', $this->type])->andFilterWhere(['like', 'transactor', $this->transactor])->andFilterWhere(['like', 'oldcontr', $this->oldcontr])->andFilterWhere(['like', 'orgid', $this->orgid])->andFilterWhere(['like', 'userid', $this->userid])->andFilterWhere(['like', 'extra_data', $this->extra_data]); return $dataProvider; }
/** * 获取组织下的合同 * @return \yii\db\ActiveQuery */ public function getContracts() { return $this->hasMany(Contract::className(), ['orgid' => 'orgid']); }
/** * Lists all AccessApp models. * @return mixed */ public function actionPreviewTpl($contr_id = '1') { /** * @var Pdf $pdf * @var Contract $ec * @var Group $group * @var Organization $provider * @var Traveller $assigned * @var Other $other */ $this->layout = 'main_outer.php'; $ec = Contract::findOne($contr_id); if (empty($ec)) { throw new Exception('合同不存在'); } $version = ContractVersion::findOne($ec->vercode); if (empty($version)) { throw new Exception('合同版本不存在'); } $travellers = Traveller::find()->andWhere('contr_id=:contr_id', [':contr_id' => $ec->contr_id])->all(); $provider = Organization::findOne(1); $assigned = Traveller::find()->andWhere('contr_id=:contr_id and is_leader=:is_leader', [':contr_id' => $ec->contr_id, ':is_leader' => '1'])->one(); $group = Group::find()->andWhere('contr_id=:contr_id', [':contr_id' => $ec->contr_id])->one(); $other = Other::findOne($contr_id); $pay = json_decode($other->pay, true); $insurance = json_decode($other->insurance, true); $groupcorp = json_decode($other->groupcorp, true); $otherGroup = json_decode($other->group, true); $effect = json_decode($other->effect, true); $routes = Routes::find()->andWhere('contr_id=:contr_id and parentid=:parentid', [':contr_id' => $ec->contr_id, ':parentid' => 0])->all(); //自愿购物活动补充协议 $shops = ShopAgreement::find()->where("contr_id='{$ec->contr_id}'")->orderBy('index asc')->all(); //自愿参加另行付费旅游项目补充协议 $chargeables = Chargeable::find()->where("contr_id='{$ec->contr_id}'")->orderBy('index asc')->all(); $data = ['contract' => $ec, 'version' => $version, 'provider' => $provider, 'group' => $group, 'assigned' => $assigned, 'travellers' => $travellers, 'routes' => $routes, 'shops' => $shops, 'chargeables' => $chargeables, 'other' => $other, 'pay' => $pay, 'insurance' => $insurance, 'groupcorp' => $groupcorp, 'otherGroup' => $otherGroup, 'effect' => $effect, 'app' => ConfigHelper::getParamsConfigArray('app'), 'company' => ConfigHelper::getParamsConfigArray('company'), 'year' => date('Y'), 'PAGE_BREAK' => PdfHelper::PAGE_BREAK]; //pdf $css = Yii::$app->basePath . "/web/css/ec.css"; $css = file_get_contents($css); $htmlContent = $this->renderPartial('inside.tpl', $data); //file_get_contents("D:/template/t2.htm"); $pdf = Yii::$app->pdf; $pdf->cssInline .= $css; $pdf->content = $htmlContent; $pdf->filename = "电子合同-{$ec->contr_no}.pdf"; //methods $pdf->methods['SetHeader'] = "合同编号<span class=\"color-tno\">{$ec->contr_no}</span>"; $pdf->methods['SetTitle'] = ConfigHelper::getAppConfig('down'); $pdf->methods['SetAuthor'] = ConfigHelper::getAppConfig('author'); $pdf->methods['SetCreator'] = ConfigHelper::getAppConfig('creator'); $pdf->methods['SetSubject'] = ConfigHelper::getAppConfig('subject'); //$pdf->output($htmlContent); return $pdf->render(); //return $this->render('inside.tpl',$data); //echo $htmlContent; }
/** * Finds the Contract model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Contract the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Contract::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @更改合同状态[未提交--提交] * @author lvkui * @param $data * @throws \Exception * @throws \yii\base\Exception */ function sys_submitStatus($data) { try { if (!isset($data['contr_id']) || $this->isStrEmpty($data['contr_id'])) { throw new Exception('an empty string is not allowed for $contr_id'); } if (!isset($data['contr_no']) || $this->isStrEmpty($data['contr_no'])) { throw new Exception('an empty string is not allowed for $contr_no'); } $ec = Contract::find()->where(['contr_id' => $data['contr_id'], 'contr_no' => $data['contr_no']])->one(); if (empty($ec)) { throw new Exception('contract does not exist'); } if ($ec->status = Contract::CONTRACT_STATUS_UNCOMMIT) { $ec->status = Contract::CONTRACT_STATUS_COMMITIN; $ec->update(); } } catch (Exception $e) { throw $e; } }