当前位置: 首页>>代码示例>>PHP>>正文


PHP Proc::GetArrayValuesByKeyName方法代码示例

本文整理汇总了PHP中app\func\Proc::GetArrayValuesByKeyName方法的典型用法代码示例。如果您正苦于以下问题:PHP Proc::GetArrayValuesByKeyName方法的具体用法?PHP Proc::GetArrayValuesByKeyName怎么用?PHP Proc::GetArrayValuesByKeyName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\func\Proc的用法示例。


在下文中一共展示了Proc::GetArrayValuesByKeyName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionToexcel

 public function actionToexcel()
 {
     $searchModel = new ImportemployeeSearch();
     $params = Yii::$app->request->queryParams;
     $inputdata = json_decode($params['inputdata']);
     $modelname = $searchModel->formName();
     $dataProvider = $searchModel->search(Proc::GetArrayValuesByKeyName($modelname, $inputdata));
     Proc::Grid2Excel($dataProvider, $modelname, 'Импорт сотрудников');
 }
开发者ID:vovancho,项目名称:yii2test,代码行数:9,代码来源:ImportemployeeController.php

示例2: actionToexcel

 public function actionToexcel()
 {
     $searchModel = new AuthitemSearch();
     $params = Yii::$app->request->queryParams;
     $inputdata = json_decode($params['inputdata']);
     $modelname = $searchModel->formName();
     $dataProvider = $searchModel->search(Proc::GetArrayValuesByKeyName($modelname, $inputdata));
     $selectvalues = json_decode($params['selectvalues']);
     Proc::Grid2Excel($dataProvider, $modelname, 'Авторизованные единицы', $selectvalues, new AuthitemFilter());
 }
开发者ID:vovancho,项目名称:yii2test,代码行数:10,代码来源:AuthitemController.php

示例3: actionToexcel

 public function actionToexcel()
 {
     $searchModel = new MaterialSearch();
     $params = Yii::$app->request->queryParams;
     $inputdata = json_decode($params['inputdata']);
     $modelname = $searchModel->formName();
     $dataProvider = $searchModel->search(Proc::GetArrayValuesByKeyName($modelname, $inputdata));
     $selectvalues = json_decode($params['selectvalues']);
     $labelvalues = isset($params['labelvalues']) ? json_decode($params['labelvalues']) : NULL;
     Proc::Grid2Excel($dataProvider, $modelname, 'Список материальных ценностей', $selectvalues, new MaterialFilter(), $labelvalues);
 }
开发者ID:vovancho,项目名称:yii2test,代码行数:11,代码来源:MaterialController.php

示例4: Grid2Excel

 /**
  * @param $dataProvider
  * @param $modelName
  * @param $reportName
  * @param null $selectvalues
  * @param null $ModelFilter
  * @param null $LabelValues
  * @throws \PHPExcel_Exception
  * @throws \PHPExcel_Reader_Exception
  */
 public static function Grid2Excel($dataProvider, $modelName, $reportName, $selectvalues = NULL, $ModelFilter = NULL, $LabelValues = NULL)
 {
     $objPHPExcel = new \PHPExcel();
     /* Границы таблицы */
     $ramka = array('borders' => ['allborders' => ['style' => \PHPExcel_Style_Border::BORDER_THIN]]);
     /* Жирный шрифт для шапки таблицы */
     $font = array('font' => array('bold' => true), 'alignment' => array('horizontal' => \PHPExcel_Style_Alignment::HORIZONTAL_CENTER));
     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, 1, $reportName);
     $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow(0, 1)->applyFromArray(['font' => ['bold' => true, 'size' => 14]]);
     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, 2, 'Дата: ' . date('d.m.Y'));
     $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow(0, 2)->applyFromArray(['font' => ['italic' => true]]);
     $params = Yii::$app->request->queryParams;
     $inputdata = json_decode($params['inputdata']);
     $fields = Proc::GetArrayValuesByKeyName($modelName, $inputdata);
     $selectvalues = (array) $selectvalues;
     $labels = self::GetAllLabelsFromAR($dataProvider, $fields[$modelName], $LabelValues);
     $dataProvider->pagination = false;
     $filter = 'Фильтр:';
     foreach ($fields[$modelName] as $attr => $value) {
         $val_result = $value;
         if (!empty($value)) {
             if (isset($selectvalues[$modelName . '[' . $attr . ']'])) {
                 $val_result = $selectvalues[$modelName . '[' . $attr . ']'][$fields[$modelName][$attr]];
             }
             $filter .= ' ' . $labels[$attr] . ': "' . $val_result . '";';
         }
     }
     if ($ModelFilter instanceof Model) {
         $dopfilter = self::ConstructFilterOutput($ModelFilter);
         if (!empty($dopfilter)) {
             $filter .= ' ' . $dopfilter;
         }
     }
     $i = 0;
     $r = 5;
     if (count((array) $dataProvider->getModels()) > 0) {
         foreach ($dataProvider->getModels() as $row => $ar) {
             $r++;
             // Названия полей
             if ($row === 0) {
                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, $r - 1, '№');
                 $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow(0, $r - 1)->applyFromArray($font);
                 foreach ($labels as $label) {
                     $i++;
                     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($i, $r - 1, $label);
                     $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($i, $r - 1)->applyFromArray($font);
                 }
             }
             $data = self::GetAllDataFromAR($ar, $fields[$modelName]);
             $i = 0;
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($i, $r, $r - 5);
             foreach (array_keys($data) as $attr) {
                 $i++;
                 $ValidatorsAttr = $ar->getActiveValidators($attr);
                 array_walk($ValidatorsAttr, function (&$val) {
                     $val = (new \ReflectionClass($val::className()))->getShortName();
                 });
                 if (isset($selectvalues[$modelName . '[' . $attr . ']'])) {
                     $data[$attr] = $selectvalues[$modelName . '[' . $attr . ']'][$data[$attr]];
                 }
                 if (in_array('StringValidator', $ValidatorsAttr)) {
                     $objPHPExcel->getActiveSheet()->setCellValueExplicitByColumnAndRow($i, $r, isset($data[$attr]) ? $data[$attr] : '', \PHPExcel_Cell_DataType::TYPE_STRING);
                 } else {
                     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($i, $r, isset($data[$attr]) ? $data[$attr] : '');
                 }
             }
             $objPHPExcel->getActiveSheet()->getStyle('A5:' . self::getNameFromNumber($i) . $r)->applyFromArray($ramka);
         }
     } else {
         $r++;
         $labels = self::GetAllLabelsFromAR($dataProvider, $fields[$modelName], $LabelValues);
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, $r - 1, '№');
         $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow(0, $r - 1)->applyFromArray($font);
         foreach ($labels as $label) {
             $i++;
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($i, $r - 1, $label);
             $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($i, $r - 1)->applyFromArray($font);
         }
         $objPHPExcel->getActiveSheet()->getStyle('A5:' . self::getNameFromNumber($i) . ($r - 1))->applyFromArray($ramka);
     }
     $objPHPExcel->getActiveSheet()->mergeCellsByColumnAndRow(0, 1, $i, 1);
     /* Авторазмер колонок Excel */
     $objPHPExcel->getActiveSheet()->getColumnDimensionByColumn(0)->setWidth(6);
     for ($i = 1; $i <= count($labels) + 1; $i++) {
         $objPHPExcel->getActiveSheet()->getColumnDimensionByColumn($i)->setAutoSize(true);
     }
     if ($filter !== 'Фильтр:') {
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, 3, $filter);
         $objPHPExcel->getActiveSheet()->mergeCellsByColumnAndRow(0, 3, $i, 3);
         $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow(0, 3)->applyFromArray(['font' => ['italic' => true]]);
//.........这里部分代码省略.........
开发者ID:vovancho,项目名称:yii2test,代码行数:101,代码来源:Proc.php


注:本文中的app\func\Proc::GetArrayValuesByKeyName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。