コード例 #1
0
 protected function Body()
 {
     $ID = $this->getDopparamID();
     $this->setReportName('Заявка на списание основных средств №' . $ID);
     $Spisosnovakt = Spisosnovakt::find($ID)->joinWith(['idMol', 'idEmployee', 'idSchetuchet'])->one();
     $Spisosnovmaterials = Spisosnovmaterials::findAll(['id_spisosnovakt' => $ID]);
     $objPHPExcel = $this->getObjPHPExcel();
     $objPHPExcel->getActiveSheet()->setCellValue('A3', 'основных средств № ' . $Spisosnovakt->spisosnovakt_id . ' от ' . Yii::$app->formatter->asDate($Spisosnovakt->spisosnovakt_date));
     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(2, 4, $Spisosnovakt->idMol->idperson->auth_user_fullname . ', ' . $Spisosnovakt->idMol->iddolzh->dolzh_name);
     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(2, 5, $Spisosnovakt->idMol->idpodraz->podraz_name);
     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(2, 6, $Spisosnovakt->idSchetuchet->schetuchet_kod . ', ' . $Spisosnovakt->idSchetuchet->schetuchet_name);
     $num = 11;
     foreach ($Spisosnovmaterials as $ar) {
         $objPHPExcel->getActiveSheet()->insertNewRowBefore($num);
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, $num, $num - 10);
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(1, $num, $ar->idMattraffic->idMaterial->material_name);
         $objPHPExcel->getActiveSheet()->mergeCellsByColumnAndRow(1, $num, 2, $num);
         $objPHPExcel->getActiveSheet()->setCellValueExplicitByColumnAndRow(3, $num, $ar->idMattraffic->idMaterial->material_inv, \PHPExcel_Cell_DataType::TYPE_STRING);
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(4, $num, empty($ar->idMattraffic->idMaterial->material_serial) ? '-' : $ar->idMattraffic->idMaterial->material_serial);
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(5, $num, empty($ar->idMattraffic->idMaterial->material_release) ? '-' : Yii::$app->formatter->asDate($ar->idMattraffic->idMaterial->material_release));
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(6, $num, $ar->spisosnovmaterials_number);
         if (!empty($ar->idMattraffic->idMaterial->material_release)) {
             $DateRelease = new \DateTime($ar->idMattraffic->idMaterial->material_release);
             $DateNow = new \DateTime();
             $Years = $DateNow->diff($DateRelease)->y;
             $Months = $DateNow->diff($DateRelease)->m;
             $CountYears = ($Years === 0 ? '' : $Years . ' л ') . ($Months === 0 ? '' : $Months . ' м');
         } else {
             $CountYears = '-';
         }
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(7, $num, $CountYears);
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(8, $num, $ar->idMattraffic->idMaterial->material_price);
         $objPHPExcel->getActiveSheet()->getStyle('A' . $num . ':I' . $num)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
         $num++;
     }
     $objPHPExcel->getActiveSheet()->removeRow($num);
     $crows = count($Spisosnovmaterials);
     $num = 12;
     $objPHPExcel->getActiveSheet()->unmergeCellsByColumnAndRow(1, $num + $crows - 1, 2, $num + $crows - 1);
     $objPHPExcel->getActiveSheet()->getStyle('C' . ($num + $crows - 1))->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(3, $num + $crows, $Spisosnovakt->idMol->iddolzh->dolzh_name);
     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(5, $num + $crows, $Spisosnovakt->idMol->idperson->auth_user_fullname);
     if (isset($Spisosnovakt->idEmployee)) {
         $objPHPExcel->getActiveSheet()->insertNewRowBefore($num + $crows + 1);
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, $num + $crows + 1, 'Иное ответственное лицо');
         $objPHPExcel->getActiveSheet()->mergeCellsByColumnAndRow(0, $num + $crows + 1, 1, $num + $crows + 1);
         $objPHPExcel->getActiveSheet()->mergeCellsByColumnAndRow(3, $num + $crows + 1, 4, $num + $crows + 1);
         $objPHPExcel->getActiveSheet()->mergeCellsByColumnAndRow(5, $num + $crows + 1, 8, $num + $crows + 1);
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(3, $num + $crows + 1, $Spisosnovakt->idEmployee->iddolzh->dolzh_name);
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(5, $num + $crows + 1, $Spisosnovakt->idEmployee->idperson->auth_user_fullname);
     } else {
         $objPHPExcel->getActiveSheet()->removeRow($num + $crows + 1);
     }
 }
コード例 #2
0
 /**
  * Deletes an existing Spisosnovakt model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param string $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     $transaction = Yii::$app->db->beginTransaction();
     try {
         Spisosnovmaterials::deleteAll(['id_spisosnovakt' => $id]);
         $this->findModel($id)->delete();
         $transaction->commit();
     } catch (Exception $e) {
         $transaction->rollBack();
         throw new Exception($e->getMessage());
     }
 }
コード例 #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Spisosnovmaterials::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $query->joinWith(['idMattraffic.idMaterial']);
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['spisosnovmaterials_id' => $this->spisosnovmaterials_id, 'id_mattraffic' => $this->id_mattraffic, 'id_spisosnovakt' => $this->id_spisosnovakt]);
     $query->andFilterWhere(Proc::WhereConstruct($this, 'spisosnovmaterials_number'));
     $query->andFilterWhere(['LIKE', 'idMaterial.material_name', $this->getAttribute('idMattraffic.idMaterial.material_name')]);
     $query->andFilterWhere(['LIKE', 'idMaterial.material_inv', $this->getAttribute('idMattraffic.idMaterial.material_inv')]);
     $query->andFilterWhere(['LIKE', 'idMaterial.material_serial', $this->getAttribute('idMattraffic.idMaterial.material_serial')]);
     $query->andFilterWhere(Proc::WhereConstruct($this, 'idMattraffic.idMaterial.material_release', Proc::Date));
     $query->andFilterWhere(Proc::WhereConstruct($this, 'idMattraffic.idMaterial.material_price'));
     Proc::AssignRelatedAttributes($dataProvider, ['idMattraffic.idMaterial.material_name', 'idMattraffic.idMaterial.material_inv', 'idMattraffic.idMaterial.material_serial', 'idMattraffic.idMaterial.material_release', 'idMattraffic.idMaterial.material_price']);
     return $dataProvider;
 }
コード例 #4
0
 /**
  * Finds the Spisosnovmaterials model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Spisosnovmaterials the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Spisosnovmaterials::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #5
0
ファイル: Spisosnovakt.php プロジェクト: vovancho/yii2test
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSpisosnovmaterials()
 {
     return $this->hasMany(Spisosnovmaterials::className(), ['id_spisosnovakt' => 'spisosnovakt_id'])->from(['spisosnovmaterials' => Spisosnovmaterials::tableName()]);
 }