Exemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Organization::find();
     $query->joinWith(['user']);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]);
     $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(['like', 'name', $this->name])->andFilterWhere(['like', 'enname', $this->enname])->andFilterWhere(['like', 'createuserid', $this->createuserid])->andFilterWhere(['like', 'user.username', $this->username])->andFilterWhere(['isdelete' => $this->isdelete]);
     return $dataProvider;
 }
 /**
  * Finds the Organization model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Organization the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Organization::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemplo n.º 3
0
 public function getOrg()
 {
     return $this->hasOne(Organization::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;
 }