The [[allModels]] property contains all data models that may be sorted and/or paginated. ArrayDataProvider will provide the data after sorting and/or pagination. You may configure the [[sort]] and [[pagination]] properties to customize the sorting and pagination behaviors. Elements in the [[allModels]] array may be either objects (e.g. model objects) or associative arrays (e.g. query results of DAO). Make sure to set the [[key]] property to the name of the field that uniquely identifies a data record or false if you do not have such a field. Compared to ActiveDataProvider, ArrayDataProvider could be less efficient because it needs to have [[allModels]] ready. ArrayDataProvider may be used in the following way: php $query = new Query; $provider = new ArrayDataProvider([ 'allModels' => $query->from('post')->all(), 'sort' => [ 'attributes' => ['id', 'username', 'email'], ], 'pagination' => [ 'pageSize' => 10, ], ]); get the posts in the current page $posts = $provider->getModels(); Note: if you want to use the sorting feature, you must configure the [[sort]] property so that the provider knows which columns can be sorted. For more details and usage information on ArrayDataProvider, see the guide article on data providers.
Since: 2.0
Author: Qiang Xue (qiang.xue@gmail.com)
Inheritance: extends BaseDataProvider
コード例 #1
0
 public function run($q)
 {
     $search = Yii::$app->search;
     $searchData = $search->search($q);
     $dataProvider = new ArrayDataProvider(['allModels' => $searchData, 'pagination' => ["pageSize" => $this->pageSize]]);
     return $this->controller->render($this->getTemplate(), ['models' => $dataProvider->getModels(), 'pagination' => $dataProvider->getPagination()]);
 }
コード例 #2
0
 protected function graphSchaduleWinLoss()
 {
     $AryDataProvider = new ArrayDataProvider(['allModels' => Yii::$app->db_esm->createCommand("CALL DASHBOARD_ESM_SALES_customer_visit_winloss('GRAPH_COUNTER_DAILY','" . date('Y-m-d') . "','','')")->queryAll(), 'pagination' => ['pageSize' => 100]]);
     $dataProvider = Json::encode($AryDataProvider->getModels());
     $prn = $dataProvider;
     return $prn;
 }
コード例 #3
0
 public function actionIndex()
 {
     if (\Yii::$app->user->isGuest) {
         return $this->render('../../../views/site/index_nologin');
     } else {
         /**
          * SUMMARY CUSTOMER PARENT
          * Detail Children Count
          * Author by Piter Novian [ptr.nov@gmail.com]
          */
         $dataParenCustomer = new ArrayDataProvider(['key' => 'CUST_KD', 'allModels' => Yii::$app->db_esm->cache(function ($db_esm) {
             return $db_esm->createCommand("\n\t\t\t\t\t\tSELECT x1.label,x1.value\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t(SELECT #x1.CUST_KD,x1.CUST_GRP,\n\t\t\t\t\t\t\t\t\t x1.CUST_NM as label,\n\t\t\t\t\t\t\t\t\t(SELECT COUNT(x2.CUST_KD) FROM c0001 x2 WHERE x2.CUST_GRP=x1.CUST_KD LIMIT 1 ) as value\n\t\t\t\t\t\t\tFROM c0001 x1\n\t\t\t\t\t\t\tWHERE x1.CUST_KD=x1.CUST_GRP) x1 \n\t\t\t\t\t\tORDER BY x1.value DESC;\n\t\t\t\t\t")->queryAll();
         }, 60), 'pagination' => ['pageSize' => 200]]);
         $parenCustomer = $dataParenCustomer->getModels();
         /**
          * SUMMARY PARENT KATEGORI
          * Author by Piter Novian [ptr.nov@gmail.com]
          */
         $dataParentKategori = new ArrayDataProvider(['allModels' => Yii::$app->db_esm->cache(function ($db_esm) {
             return $db_esm->createCommand("\n\t\t\t\t\t\tSELECT x1.CUST_KTG,x1.CUST_KTG_NM,(SELECT COUNT(CUST_KD)from c0001 WHERE STATUS<>3 AND CUST_KTG=x1.CUST_KTG) AS CUST_CNT\n\t\t\t\t\t\tFROM c0001k x1\n\t\t\t\t\t\tWHERE x1.CUST_KTG=x1.CUST_KTG_PARENT\n\t\t\t\t\t")->queryAll();
         }, 60), 'pagination' => ['pageSize' => 50]]);
         $parentKategori = $dataParentKategori->getModels();
         /**
          * SUMMARY KATEGORY DETAIL COUNT
          * Detail customer Category
          * Author by Piter Novian [ptr.nov@gmail.com]
          */
         $dataChartCountKategori = new ArrayDataProvider(['allModels' => Yii::$app->db_esm->cache(function ($db_esm) {
             return $db_esm->createCommand("\n\t\t\t\t\t\tSELECT a1.CUST_KTG,a1.KTG_NM,(SELECT COUNT(CUST_KD)from c0001 WHERE STATUS<>3 AND CUST_TYPE=a1.CUST_KTG) AS CUST_CNT\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t(SELECT x1.CUST_KTG,CONCAT(x2.CUST_KTG_NM,' ',x1.CUST_KTG_NM) AS KTG_NM\n\t\t\t\t\t\t\t\tFROM c0001k x1 INNER JOIN \n\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t SELECT CUST_KTG,CUST_KTG_NM,CUST_KTG_PARENT \n\t\t\t\t\t\t\t\t\t\t FROM c0001k \n\t\t\t\t\t\t\t\t\t\t WHERE CUST_KTG=CUST_KTG_PARENT\n\t\t\t\t\t\t\t\t\t) x2 on x1.CUST_KTG_PARENT=x2.CUST_KTG\n\t\t\t\t\t\t\t\tWHERE x1.CUST_KTG<>x1.CUST_KTG_PARENT\n\t\t\t\t\t\t\t  ORDER BY x1.CUST_KTG_PARENT\n\t\t\t\t\t\t\t) a1\t\n\t\t\t\t\t")->queryAll();
         }, 60), 'pagination' => ['pageSize' => 200]]);
         $ChartCountKategori = $dataChartCountKategori->getModels();
         //RENDER INDEX
         return $this->render('index', ['ChartCountKategori' => $ChartCountKategori, 'parenCustomer' => $parenCustomer, 'parentKategori' => $parentKategori]);
     }
 }
コード例 #4
0
 public function actionIndex($q = '')
 {
     /** @var \himiklab\search\Search $search */
     $search = Yii::$app->search;
     $searchData = $search->find($q);
     $dataProvider = new ArrayDataProvider(['allModels' => $searchData['results'], 'pagination' => ['pageSize' => self::PAGE_SIZE]]);
     return $this->render('index', ['hits' => $dataProvider->getModels(), 'pagination' => $dataProvider->getPagination(), 'query' => $searchData['query']]);
 }
コード例 #5
0
 public function actionSearch($q = '')
 {
     /** @var \himiklab\yii2\search\Search $search */
     $search = \Yii::$app->search;
     $searchData = $search->find($q);
     // Search by full index.
     //$searchData = $search->find($q, ['model' => 'page']); // Search by index provided only by model `page`.
     $dataProvider = new ArrayDataProvider(['allModels' => $searchData['results'], 'pagination' => ['pageSize' => 10]]);
     return $this->render('found', ['hits' => $dataProvider->getModels(), 'pagination' => $dataProvider->getPagination(), 'query' => $searchData['query']]);
 }
コード例 #6
0
 /**
  * Browsing latest torrents by category
  * @return string the rendering result.
  */
 public function actionIndex($q = null, $iht = null, $age = null)
 {
     if (is_null($q) && is_null($iht) && is_null($age)) {
         $this->redirect(Url::toRoute('/browse'));
     }
     if (!empty($iht)) {
         if (preg_match('#^\\d$#sui', $iht) && Category::getTag($iht)) {
             $iht = Category::getTag($iht);
         }
     }
     if (Yii::$app->request->getQueryParam('ihs', null) === '1') {
         $_GET['popular'] = '1';
     }
     $searchModel = new SearchForm();
     $searchModel->setScenario('simple');
     $searchModel->words = $q;
     $searchModel->tags = $iht;
     $searchModel->age = Yii::$app->request->getQueryParam('age', 0);
     $searchModel->popular = empty($_GET['popular']) ? 0 : 1;
     $searchModel->status = empty($status) ? 0 : 1;
     $searchModel->validate();
     $torrents = null;
     $totalCount = 0;
     if (!$searchModel->getErrors()) {
         $torrents = Search::getTorrentDataProvider($searchModel);
         $totalCount = $torrents->getTotalCount();
         if (empty($totalCount)) {
             $words = explode(' ', $searchModel->words);
             if (count($words) > 1) {
                 $searchModel->words = $words;
                 $torrents = Search::getTorrentDataProvider($searchModel);
                 $totalCount = $torrents->getTotalCount();
             }
         }
     } else {
         $torrents = new ArrayDataProvider();
     }
     if (isset($_REQUEST['lucky'])) {
         $t = $torrents->getModels();
         if (count($t)) {
             $tmp = [];
             foreach ($t as $torrent) {
                 $tmp[$torrent->seeders] = $torrent;
             }
             krsort($tmp);
             $torrent = array_shift($tmp);
             $this->redirect($torrent->getUrl());
             \Yii::$app->end();
         }
     }
     return $this->render('index', ['q' => $q, 'torrents' => $torrents, 'totalCount' => $totalCount, 'iht' => $iht]);
 }
コード例 #7
0
ファイル: ArrayDataProviderTest.php プロジェクト: howq/yii2
 public function testGetKeys()
 {
     $pagination = ['pageSize' => 2];
     $simpleArray = [['name' => 'zero'], ['name' => 'one'], ['name' => 'tow']];
     $dataProvider = new ArrayDataProvider(['allModels' => $simpleArray, 'pagination' => $pagination]);
     $this->assertEquals([0, 1], $dataProvider->getKeys());
     $namedArray = ['key1' => ['name' => 'zero'], 'key2' => ['name' => 'one'], 'key3' => ['name' => 'two']];
     $dataProvider = new ArrayDataProvider(['allModels' => $namedArray, 'pagination' => $pagination]);
     $this->assertEquals(['key1', 'key2'], $dataProvider->getKeys());
     $mixedArray = ['key1' => ['name' => 'zero'], 9 => ['name' => 'one'], 'key3' => ['name' => 'two']];
     $dataProvider = new ArrayDataProvider(['allModels' => $mixedArray, 'pagination' => $pagination]);
     $this->assertEquals(['key1', 9], $dataProvider->getKeys());
 }
コード例 #8
0
 public function actionIndex()
 {
     if (\Yii::$app->user->isGuest) {
         return $this->render('../../../views/site/index_nologin');
     } else {
         /* CUSTOMER CATEHORI COUNT [modern,general,horeca,other]*/
         $dataProvider_CustPrn = new ArrayDataProvider(['allModels' => Yii::$app->db_esm->createCommand("CALL DASHBOARD_ESM_SALES_custromer_ktg('count_kategory_customer_parent')")->queryAll(), 'pagination' => ['pageSize' => 50]]);
         $model_CustPrn = $dataProvider_CustPrn->getModels();
         $count_CustPrn = $dataProvider_CustPrn->getCount();
         //print_r($this->CountChildCustomer());
         //die();
         return $this->render('index', ['model_CustPrn' => $model_CustPrn, 'count_CustPrn' => $count_CustPrn, 'resultCountChildParen' => $this->CountChildCustomer()]);
     }
 }
コード例 #9
0
ファイル: DefaultController.php プロジェクト: Dominus77/blog
 public function actionSearch($q = '')
 {
     $time_start = microtime(true);
     //начало измерения
     /** @var \himiklab\yii2\search\Search $search */
     $search = Yii::$app->search;
     $searchData = $search->find($q);
     // Search by full index.
     //$searchData = $search->find($q, ['model' => 'post']); // Search by index provided only by model `page`.
     $time_end = microtime(true);
     //конец измерения
     $dataProvider = new ArrayDataProvider(['allModels' => $searchData['results'], 'pagination' => ['pageSize' => \Yii::$app->getModule('blog')->searchPageSize]]);
     $time = str_replace('.', ',', substr($time_end - $time_start, 0, 4));
     return $this->render('found', ['hits' => $dataProvider->getModels(), 'count' => count($searchData['results']), 'time' => $time, 'pagination' => $dataProvider->getPagination(), 'query' => $searchData['query']]);
 }
コード例 #10
0
 /**
  * Lists all Sot2 models.
  * @return mixed
  */
 public function actionIndex()
 {
     //print_r($this->getScripts());
     /**
      * PLSQL ! Array Data Provider
      * @author ptrnov [piter@lukison.com]
      * @since 2.1
      */
     $plsql_so_label = new ArrayDataProvider(['key' => 'ID', 'allModels' => $this->getScripts(), 'pagination' => ['pageSize' => 500]]);
     $attributeField = $plsql_so_label->allModels[0];
     //get label Array 0
     $attDinamik = [];
     foreach ($attributeField as $key => $value) {
         $attDinamik[] = [$key];
     }
     //print_r($attDinamik);
     $plsql_so_1 = new ArrayDataProvider(['key' => 'ID', 'allModels' => $this->getScripts(), 'pagination' => ['pageSize' => 500]]);
     // $plsql_so_detail= new ArrayDataProvider([
     // 'key' => 'ID',
     // 'allModels'=>$this->getScriptsDetail(),
     // 'pagination' => [
     // 'pageSize' => 500,
     // ]
     // ]);
     /**
      * PLSQL ! Column Label
      * @author ptrnov [piter@lukison.com]
      * @since 2.1
      */
     $attributeField = $plsql_so_1->allModels[0];
     //get label Array 0
     // $attDinamik=[];
     // foreach($attributeField as $key =>$value)
     // {
     // $attDinamik[]=[$key];
     // }
     // print_r($attDinamik);
     // $attributeField1=$plsql_so_detail->allModels[0];
     // print_r($plsql_so_1->getModels());
     $tes1 = $plsql_so_1->getModels();
     $searchModel = new Sot2Search();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'dataProviderX' => $plsql_so_1, 'attributeField' => $attributeField]);
 }
コード例 #11
0
ファイル: Search.php プロジェクト: dektrium/yii2-rbac
 /**
  * @param  array $params
  * @return ArrayDataProvider
  */
 public function search($params = [])
 {
     $dataProvider = \Yii::createObject(ArrayDataProvider::className());
     $query = (new Query())->select(['name', 'description', 'rule_name'])->andWhere(['type' => $this->type])->from($this->manager->itemTable);
     if ($this->load($params) && $this->validate()) {
         $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'rule_name', $this->rule_name]);
     }
     $dataProvider->allModels = $query->all($this->manager->db);
     return $dataProvider;
 }
コード例 #12
0
 /**
  * @param array $requestData
  * @return string JSON answer
  * @throws InvalidConfigException
  */
 protected function requestAction($requestData)
 {
     $dataProvider = new ArrayDataProvider(['allModels' => $this->models, 'pagination' => $this->getPagination($requestData), 'sort' => $this->getSort($requestData)]);
     $recordsTotalCount = $dataProvider->totalCount;
     $response = [];
     $response['page'] = $requestData['page'];
     $response['total'] = $requestData['rows'] != 0 ? ceil($recordsTotalCount / $requestData['rows']) : 0;
     $response['records'] = $recordsTotalCount;
     $i = 0;
     foreach ($dataProvider->getModels() as $id => $record) {
         if (!is_array($record)) {
             throw new InvalidConfigException('The `models` param isn\'t valid array.');
         }
         $response['rows'][$i]['id'] = $id;
         foreach ($record as $key => $value) {
             $response['rows'][$i]['cell'][$key] = $value;
         }
         ++$i;
     }
     return $response;
 }
コード例 #13
0
 /**
  * @inheritdoc
  */
 protected function prepareModels()
 {
     $pattern = $this->getPattern();
     if ($pattern == false) {
         return parent::prepareModels();
     }
     $origAll = $this->allModels;
     $attribute = $this->alphaAttribute;
     $this->allModels = array_filter($this->allModels, function ($v) use($attribute, $pattern) {
         $attrVal = $v->{$attribute};
         if (is_array($pattern)) {
             $pattern = '/^' . current($pattern) . '/';
             return preg_match($pattern, $attrVal) === 1;
         } else {
             return stripos($attrVal, $pattern) === 0;
         }
     });
     $r = parent::prepareModels();
     $this->allModels = $origAll;
     return $r;
 }
コード例 #14
0
 public function actionExport_datagudang()
 {
     $searchModelViewImport = new ImportViewSearch();
     $dataProvidergudang = $searchModelViewImport->searchViewHistoryGudang(Yii::$app->request->queryParams);
     $dpGudang = $dataProvidergudang->getModels();
     $aryData = [];
     foreach ($dpGudang as $key => $value) {
         $aryData[] = ['TGL' => $value['TGL'], 'NM_BARANG' => $value['NM_BARANG'], 'SO_QTY' => $value['SO_QTY'], 'UNIT_BARANG' => $value['UNIT_BARANG'], 'kartonqty' => $value['kartonqty'], 'beratunit' => $value['beratunit'], 'HARGA_DIS' => $value['HARGA_DIS'], 'subtotaldist' => $value['subtotaldist'], 'disNm' => $value['disNm'], 'USER_ID' => $value['USER_ID']];
     }
     $dataProviderAllDataImport = new ArrayDataProvider(['allModels' => $aryData, 'pagination' => ['pageSize' => 10]]);
     $modelDataExport = $dataProviderAllDataImport->getModels();
     //print_r($modelDataExport);
     $excel_data = Postman4ExcelBehavior::excelDataFormat($modelDataExport);
     $excel_title = $excel_data['excel_title'];
     $excel_ceils = $excel_data['excel_ceils'];
     $excel_content = [['sheet_name' => 'STOCK-GUDANG', 'sheet_title' => [['DATE', 'BARANG', 'QTY_PCS', 'UNIT_BARANG', 'QTY_KARTON', 'BERAT_GRAM', 'HARGA_DIS', 'SUB_TOTAL', 'DISTRIBUTOR', 'USER_ID']], 'ceils' => $excel_ceils, 'freezePane' => 'A2', 'headerColor' => Postman4ExcelBehavior::getCssClass("header"), 'headerStyle' => [['TGL' => ['align' => 'center'], 'NM_BARANG' => ['align' => 'center'], 'SO_QTY' => ['align' => 'center'], 'UNIT_BARANG' => ['align' => 'center'], 'kartonqty' => ['align' => 'center'], 'beratunit' => ['align' => 'center'], 'HARGA_DIS' => ['align' => 'center'], 'subtotaldist' => ['align' => 'center'], 'disNm' => ['align' => 'center'], 'USER_ID' => ['align' => 'center']]], 'contentStyle' => [['DATE' => ['align' => 'center'], 'BARANG' => ['align' => 'left'], 'QTY_PCS' => ['align' => 'right'], 'UNIT_BARANG' => ['align' => 'center'], 'QTY_KARTON' => ['align' => 'right'], 'BERAT_GRAM' => ['align' => 'right'], 'HARGA_DIS' => ['align' => 'right'], 'SUB_TOTAL' => ['align' => 'right'], 'DISTRIBUTOR' => ['align' => 'left'], 'USER_ID' => ['align' => 'center']]], 'oddCssClass' => Postman4ExcelBehavior::getCssClass("odd"), 'evenCssClass' => Postman4ExcelBehavior::getCssClass("even")]];
     $excel_file = "ImportDataGudang";
     $this->export4excel($excel_content, $excel_file, 0);
 }
コード例 #15
0
 /**
  * TimelineDataProvider constructor.
  * @param TimelinePanel $panel
  * @param array $config
  */
 public function __construct(TimelinePanel $panel, $config = [])
 {
     $this->panel = $panel;
     parent::__construct($config);
 }
コード例 #16
0
 /**
  * Updates an existing Customer model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param string $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $sale = new \backend\models\Saledata();
     $country = new \backend\models\Country();
     $province = new \backend\Models\Province();
     $updatecom = [];
     $updatesec = [];
     $updatedep = [];
     $updatesale = [];
     $n = 0;
     $m = 0;
     if ($model->Cus_Customeras != '') {
         $dbcon = Yii::$app->db3;
         $res = $dbcon->createCommand('SELECT * FROM Sale_SaleData WHERE Sal_id=' . $model->Cus_Customeras)->queryAll();
         foreach ($res as $res2) {
             $updatesale[$n]['recid'] = $res2['Sal_id'];
             $updatesale[$n]['salename'] = $res2['Sal_name'];
             //  $updatesale[$res2['Sal_id']]= $res2['Sal_name'];
             $com = Yii::$app->db->createCommand('EXEC sp_company2 @param=' . $res2['bch_id'])->queryAll();
             foreach ($com as $comres) {
                 $updatecom[$m]['recid'] = $res2['bch_id'];
                 //  $updatecom[$m]['comname']=$comres['company_name'];
                 // $updatecom[$comres['company'_id']]=$comres['company_name'];
             }
             $updatesec[$n]['recid'] = $res2['div_id'];
             $updatedep[$n]['recid'] = $res2['Sal_department'];
             // echo $updatesec[$n]['recid'];return;
             //                      $sec = Yii::$app->db->createCommand('EXEC sp_section2 @param='.$res2['div_id'])->queryAll();
             //                    foreach ($sec as $secres){
             //                        $updatesec[$m]['recid']=$secres['section_id'];
             //                        $updatecom[$m]['secname']=$secres['section_name'];
             //                        echo $secres['section_name'];return;
             //                    }
         }
     }
     $xmodel = [];
     $db = Yii::$app->db;
     //   $query = $db->createCommand('EXEC mytest @xid=27');
     $query = $db->createCommand('EXEC sp_company');
     $xec = $query->queryAll();
     foreach ($xec as $x) {
         //   $xmodel['recid']=$x['recid'];
         $xmodel[$x['company_id']] = $x['company_name'];
     }
     $prov = new ArrayDataProvider(['allModels' => $xec]);
     $modelx = $prov->getModels();
     $secmodel = [];
     $secdb = Yii::$app->db->createCommand('EXEC sp_section2')->queryAll();
     foreach ($secdb as $secdbres) {
         $secmodel[$secdbres['section_id']] = $secdbres['section_name'];
     }
     $depmodel = [];
     $depdb = Yii::$app->db->createCommand('EXEC sp_department2')->queryAll();
     foreach ($depdb as $depres) {
         $depmodel[$depres['department_id']] = $depres['department_name'];
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->Cus_id]);
     } else {
         return $this->render('update', ['model' => $model, 'sale' => $sale, 'country' => $country, 'province' => $province, 'xmodel' => $xmodel, 'updatesale' => $updatesale, 'updatecom' => $updatecom, 'updatesec' => $updatesec, 'updatedep' => $updatedep, 'secmodel' => $secmodel, 'depmodel' => $depmodel]);
     }
 }
コード例 #17
0
    /**
     * GENERAL SALES - monthly-Stock.
     * @author ptr.nov [ptr.nov@gmail.com]
     * @since 1.2
     */
    public function actionStockMonthly()
    {
        $request = Yii::$app->request;
        $tgl = $request->get('tgl');
        $tglParam = $tgl != '' ? $tgl : date('Y-m-d');
        //***get count data visiting
        $_visiting = new ArrayDataProvider(['allModels' => Yii::$app->db_esm->createCommand("\t\n\t\t\t\tSELECT \tx1.TGL, month(x1.TGL) AS bulan,DATE_FORMAT(x1.TGL,'%d') as TGL_NO,LEFT(COMPONEN_hari(x1.TGL),2) as hari, \n\t\t\t\t\t\tx1.CCval,x1.ACval,x2.ECval,x1.CASEval,x2.ACval_COMPARE\t\t\t\n\t\t\t\tFROM\n\t\t\t\t(\tSELECT \n\t\t\t\t\tsum(CASE WHEN  a1.CUST_ID <> '' AND a1.STATUS_CASE<>1 THEN  1 ELSE 0 END) AS CCval,\n\t\t\t\t\tsum(CASE WHEN a1.CUST_ID <> '' AND a1.STATUS= 1 THEN  1 ELSE 0 END) AS ACval,\n\t\t\t\t\tsum(CASE WHEN a1.CUST_ID <> '' AND a1.STATUS_CASE=1 THEN  1 ELSE 0 END) AS CASEval,a1.TGL\n\t\t\t\t\tFROM c0002scdl_detail a1 LEFT JOIN c0001 a2 ON a2.CUST_KD=a1.CUST_ID\n\t\t\t\t\tWHERE a1.STATUS<>3 AND a2.CUST_NM not LIKE 'customer demo%'\n\t\t\t\t\tGROUP BY  a1.TGL\n\t\t\t\t) x1 LEFT JOIN\n\t\t\t\t(\tSELECT sum(CASE WHEN  ID IS NOT NULL THEN  1 ELSE 0 END) AS ACval_COMPARE,\n\t\t\t\t\t\t\tsum(CASE WHEN STATUS_EC IS NOT NULL THEN  1 ELSE 0 END) AS ECval,TGL\n\t\t\t\t\tFROM c0002rpt_cc_time x1\n\t\t\t\t\tWHERE CUST_NM not LIKE 'customer demo%'\t\n\t\t\t\t\tGROUP BY TGL\n\t\t\t\t) x2 on x2.TGL=x1.TGL\n\t\t\t\t#WHERE MONTH(x1.TGL)=10 AND x1.TGL <= CURDATE()\n\t\t\t\tWHERE MONTH(x1.TGL)=month('" . $tglParam . "') AND x1.TGL <= CURDATE()\n\t\t\t")->queryAll(), 'pagination' => ['pageSize' => 200]]);
        $_modelVisiting = ArrayHelper::toArray($_visiting->getModels());
        foreach ($_modelVisiting as $row => $value) {
            $hari[] = ["label" => $value['hari'] . "-" . $value['TGL_NO'] . "-" . $value['bulan']];
            $cc[] = ["value" => strval($value['CCval'])];
            $ac[] = ["value" => strval($value['ACval'])];
            $ec[] = ["value" => strval($value['ECval'])];
            $case[] = ["value" => strval($value['CASEval'])];
            $acSum[] = $value['ACval'];
            $ecSum[] = $value['ECval'];
        }
        //***get AVG AC FROM data visiting
        $cntAC = count($acSum);
        $sumAC = array_sum($acSum);
        $avgAC = $sumAC / $cntAC;
        $avgACnm = "AvgAC (" . number_format($avgAC, 2) . ")";
        //***get AVG EC FROM data visiting
        $cntEC = count($ecSum);
        $sumEC = array_sum($ecSum);
        $avgEC = $sumEC / $cntEC;
        $avgECnm = "AvgEC (" . number_format($avgEC, 2) . ")";
        /**
         * Maping Chart 
         * Type : msline
         * 
         */
        $rsltSrc = '{
			"chart": {
				"caption": "Summary Stock Month Of Year",
				"subCaption": "Supllier, Distributor, Sales ",
				"captionFontSize": "12",
				"subcaptionFontSize": "10",
				"subcaptionFontBold": "0",
				"paletteColors": "#cc0000,#1e86e5,#16ce87,#b7843d",
				"bgcolor": "#ffffff",
				"showBorder": "0",
				"showShadow": "0",
				"showCanvasBorder": "0",
				"usePlotGradientColor": "0",
				"legendBorderAlpha": "0",
				"legendShadow": "0",
				"showAxisLines": "0",
				"showAlternateHGridColor": "0",
				"divlineThickness": "1",
				"divLineIsDashed": "1",
				"divLineDashLen": "1",
				"divLineGapLen": "1",
				"xAxisName": "Day",
				"showValues": "1"               
			},
			"categories": [
				{
					"category": ' . Json::encode($hari) . '
				}
			],
			"dataset": [
				{
					"seriesname": "PO-Purchase",
					"data":' . Json::encode($cc) . '
				}, 
				{
					"seriesname": "Stock-Gudang",
					"data":' . Json::encode($ac) . '
				},
				{
					"seriesname": "PO-Sales",
					"data":' . Json::encode($ec) . '
				},
				{
					"seriesname": "CASE",
					"data":' . Json::encode($case) . '
				}
			],
			"trendlines": [
                {
                    "line": [
                        {
                            "startvalue": "' . $avgAC . '",
                            "color": "#0b0d0f",
                            "valueOnRight": "1",
                            "displayvalue":"' . $avgACnm . '"
                        },
						{
                            "startvalue": "' . $avgEC . '",
                            "color": "#0b0d0f",
                            "valueOnRight": "1",
                            "displayvalue": "' . $avgECnm . '"
                        }
                    ]
                }
            ]
			
		}';
        return json::decode($rsltSrc);
        //return $avgAc;
    }
コード例 #18
0
ファイル: _results_tab.php プロジェクト: EuresTools/eVote-web
<?php

use app\components\grid\GridView;
use yii\data\ArrayDataProvider;
use yii\helpers\Html;
use yii\helpers\ArrayHelper;
use app\models\Option;
use yii\widgets\DetailView;
use miloschuman\highcharts\Highcharts;
use yii\widgets\Pjax;
global $optionIDs, $total, $used;
//$options = $model->getOptions()->with(['validVotes'])->all();
//$options = $model->getOptions()->withVoteCount()->all();
$options = $model->getOptions()->all();
$optionIDs = ArrayHelper::getColumn($options, 'id');
$dataProvider = new ArrayDataProvider(['allModels' => $options, 'sort' => ['attributes' => ['id', 'text', 'validVotesCount' => ['default' => SORT_DESC]], 'params' => array_merge($_GET, ['#' => 'results_gridview'])]]);
Pjax::begin(['id' => 'options', 'timeout' => 3000]);
// increase Pjax Timeout default 1 sek
// Status.
if ($model->isOver()) {
    echo Html::tag('h2', Yii::t('app', 'Status: Finished'), ['class' => 'status status-finished']);
} else {
    if ($model->isOpen()) {
        echo Html::tag('h2', Yii::t('app', 'Status: Open'), ['class' => 'status status-open']);
    } else {
        echo Html::tag('h2', Yii::t('app', 'Status: Not Started'), ['class' => 'status status-closed']);
    }
}
// Column chart.
if ($model->hasStarted()) {
    $this->registerJsFile('@web/js/reflowChart.js', ['depends' => \yii\web\JqueryAsset::className(), 'depends' => miloschuman\highcharts\HighchartsAsset::className()]);
コード例 #19
0
ファイル: index.php プロジェクト: adem-team/advanced
 * DAILY CUSTOMERS VISIT
 * @author ptrnov  [piter@lukison.com]
 * @since 1.2
 */
$actionClass = 'btn btn-info btn-xs';
$actionLabel = 'View';
$attDinamik = [];
/*GRIDVIEW ARRAY FIELD HEAD*/
$headColomnEvent = [['ID' => 0, 'ATTR' => ['FIELD' => 'TGL', 'SIZE' => '10px', 'label' => 'Date', 'align' => 'left', 'warna' => '249, 215, 100, 1', 'GRP' => false, 'FORMAT' => 'html', 'filter' => false, 'filterType' => false, 'filterwarna' => '249, 215, 100, 1']], ['ID' => 1, 'ATTR' => ['FIELD' => 'USER_NM', 'SIZE' => '10px', 'label' => 'User', 'align' => 'left', 'warna' => '249, 215, 100, 1', 'GRP' => false, 'FORMAT' => 'html', 'filter' => true, 'filterType' => false, 'filterwarna' => '249, 215, 100, 1']], ['ID' => 2, 'ATTR' => ['FIELD' => 'SCDL_GRP_NM', 'SIZE' => '10px', 'label' => 'Schadule', 'align' => 'left', 'warna' => '249, 215, 100, 1', 'GRP' => false, 'FORMAT' => 'html', 'filter' => true, 'filterType' => false, 'filterwarna' => '249, 215, 100, 1']], ['ID' => 3, 'ATTR' => ['FIELD' => 'TIME_DAYSTART', 'SIZE' => '10px', 'label' => 'Start Time', 'align' => 'left', 'warna' => '249, 215, 100, 1', 'GRP' => false, 'FORMAT' => 'html', 'filter' => true, 'filterType' => false, 'filterwarna' => '249, 215, 100, 1']], ['ID' => 4, 'ATTR' => ['FIELD' => 'TIME_DAYEND', 'SIZE' => '10px', 'label' => 'End Time', 'align' => 'left', 'warna' => '249, 215, 100, 1', 'GRP' => false, 'FORMAT' => 'html', 'filter' => true, 'filterType' => false, 'filterwarna' => '249, 215, 100, 1']], ['ID' => 5, 'ATTR' => ['FIELD' => 'DISTANCE_DAYSTART', 'SIZE' => '10px', 'label' => 'Radius.In', 'align' => 'left', 'warna' => '249, 215, 100, 1', 'GRP' => false, 'FORMAT' => 'html', 'filter' => true, 'filterType' => false, 'filterwarna' => '249, 215, 100, 1']], ['ID' => 6, 'ATTR' => ['FIELD' => 'DISTANCE_DAYEND', 'SIZE' => '10px', 'label' => 'Radius.Out', 'align' => 'left', 'warna' => '249, 215, 100, 1', 'GRP' => false, 'FORMAT' => 'html', 'filter' => true, 'filterType' => false, 'filterwarna' => '249, 215, 100, 1']]];
$gvHeadColomn = ArrayHelper::map($headColomnEvent, 'ID', 'ATTR');
/*GRIDVIEW EXPAND*/
$attDinamik[] = ['class' => 'kartik\\grid\\ExpandRowColumn', 'width' => '50px', 'header' => 'Detail', 'value' => function ($model, $key, $index, $column) {
    return GridView::ROW_COLLAPSED;
}, 'detail' => function ($model, $key, $index, $column) {
    /* [1] HEADER1 */
    $dataModelsHeader1 = new ArrayDataProvider(['allModels' => Yii::$app->db_esm->createCommand("CALL DASHBOARD_ESM_VISIT_header1('ALL_HEAD1','" . $model['TGL'] . "','" . $model['CUST_ID'] . "')")->queryAll(), 'pagination' => ['pageSize' => 50]]);
    /* [2] HEADER2 */
    $dataProviderHeader2 = new ArrayDataProvider(['allModels' => Yii::$app->db_esm->createCommand("CALL DASHBOARD_ESM_VISIT_header2('ALL_HEAD2','" . $model['USER_ID'] . "','" . $model['TGL'] . "')")->queryAll(), 'pagination' => ['pageSize' => 50]]);
    /* [3] IVENTORY */
    $inventoryProvider = new ArrayDataProvider(['allModels' => Yii::$app->db_esm->createCommand("CALL ERP_CUSTOMER_VISIT_inventory('" . $model['TGL'] . "','" . $model['CUST_ID'] . "','" . $model['USER_ID'] . "')")->queryAll(), 'pagination' => ['pageSize' => 50]]);
    /* [4] EXPIRED */
    /* [5] REQUEST */
    /* [6] IMAGE VISIT */
    $searchModel = new CustomerVisitImageSearch(['ID_DETAIL' => '' . $model['ID_DTL'] . '']);
    $dataProviderImage = $searchModel->search(Yii::$app->request->queryParams);
    /* DETAIL & SUMMARY */
    //'SUMMARY_ALL','2016-05-31','','30','1'
    $aryProviderDetailSummary = new ArrayDataProvider(['allModels' => Yii::$app->db_esm->createCommand("CALL MOBILE_CUSTOMER_VISIT_inventory_summary('SUMMARY_ALL','2016-05-31','','30','1');")->queryAll(), 'pagination' => ['pageSize' => 50]]);
    /*SUMMRY STOCK*/
    $aryProviderDataStock = new ArrayDataProvider(['allModels' => Yii::$app->db_esm->createCommand("CALL DASHBOARD_ESM_VISIT_inventory_summary('SUMMARY_STOCK_ITEM_CUST','" . $model['TGL'] . "','','" . $model['USER_ID'] . "','" . $model['SCDL_GROUP'] . "');")->queryAll(), 'pagination' => ['pageSize' => 50]]);
    $aryProviderHeaderStock = $aryProviderDataStock->allModels[0];
コード例 #20
0
 public function actionJsoncalendar()
 {
     //public function actionJsoncalendar(){
     /*  $events = array();
     		  $eventCalendar= Scheduleheader::find()->all();
        		//print_r($eventCalendar); */
     //die();
     //Demo
     //$Event = new \yii2fullcalendar\models\Event();
     //FIELD HARUS [id,start,end,title]
     /*  header('Content-type: application/json');
         echo Json::encode($eventCalendar);
         Yii::$app->end(); */
     $AryDataProviderVal1 = new ArrayDataProvider(['allModels' => Yii::$app->db_esm->createCommand("SELECT \n\t\t\t\t\tTGL1 as start, TGL2 as end, (SELECT SCDL_GROUP_NM FROM c0007 WHERE ID=SCDL_GROUP) as title\n\t\t\t\t\tFROM c0002scdl_header;")->queryAll(), 'pagination' => ['pageSize' => 100]]);
     $dataProviderVal1 = $AryDataProviderVal1->getModels();
     return Json::encode($dataProviderVal1);
 }
コード例 #21
0
 public function actionSend()
 {
     $x = date('N', strtotime(date("Y-m-d")));
     //date to string days
     if ($x != 2 or $x != 7) {
         //off selasa dan minggu
         $tglIn = date("Y-m-d");
         //$tglIn='2016-10-27';
         /*Content template*/
         $cusCount = Yii::$app->db_esm->createCommand("\r\n\t\t\t\tSELECT\r\n\t\t\t\t\tx2.TGL,x2.SALES_NM,x2.AREA\r\n\t\t\t\t\t,sum(x2.STS_CC) as TTL_CC\r\n\t\t\t\t\t,sum(x2.STS_AC) as TTL_AC\r\n\t\t\t\t\t,sum(x2.STS_EC) as TTL_EC\r\n\t\t\t\t\t,sum(CASE WHEN x2.SALES_NM<>'' THEN 1 ELSE 0 END) as TTL_SALES\r\n\t\t\t\t\t#\r\n\t\t\t\tFROM\r\n\t\t\t\t\t(\tSELECT\r\n\t\t\t\t\t\t\tx1.TGL,x1.SALES_NM,x1.AREA\r\n\t\t\t\t\t\t\t,sum(CASE WHEN x1.CUST_ID<>'' THEN 1 ELSE 0 END) as STS_CC\r\n\t\t\t\t\t\t\t,sum(CASE WHEN x1.STATUS='AC' THEN 1 ELSE 0 END) as STS_AC\r\n\t\t\t\t\t\t\t,sum(CASE WHEN x1.STATUS='EC' THEN 1 ELSE 0 END) as STS_EC\r\n\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\t(\tSELECT \r\n\t\t\t\t\t\t\t\t\tTGL,SALES_NM,\r\n\t\t\t\t\t\t\t\t\tCUST_ID,CUST_NM,\t\r\n\t\t\t\t\t\t\t\t\tABSEN_MASUK,ABSEN_KELUAR,\t\r\n\t\t\t\t\t\t\t\t\tCUST_CHKIN AS CHEKIN, CUST_CHKOUT AS CHECKOUT,LIVE_TIME AS VISIT_TIME, JRK_TEMPUH AS DISTANCE,\r\n\t\t\t\t\t\t\t\t\t(CASE WHEN STS=0 THEN 'CC' ELSE (CASE WHEN STATUS_EC>0 THEN 'EC' ELSE 'AC' END) END) as STATUS,\r\n\t\t\t\t\t\t\t\t\tSCDL_GRP_NM AS AREA,\r\n\t\t\t\t\t\t\t\t\t(CASE WHEN STS_CASE=0 THEN 'PLAN' ELSE 'CASE' END) as SCDL_EVENT,\r\n\t\t\t\t\t\t\t\t\t(CASE WHEN STS_CASE_PIC='' THEN 'SYSTEM' ELSE STS_CASE_PIC END) AS AUTHORIZED \r\n\t\t\t\t\t\t\t\tFROM c0002rpt_cc_time WHERE TGL='" . $tglIn . "' AND USER_ID NOT IN ('61','62')\r\n\t\t\t\t\t\t\t\tORDER BY USER_ID,CUST_CHKIN,CUST_CHKOUT\r\n\t\t\t\t\t\t\t) x1 GROUP BY x1.SALES_NM\r\n\t\t\t\t\t) x2\r\n\t\t\t")->queryAll();
         $dataList = new ArrayDataProvider(['allModels' => Yii::$app->db_esm->createCommand("\r\n\t\t\t\t\tSELECT x1.TGL,x1.USER_ID,x1.USER_NM,x1.SALES_NM\r\n\t\t\t\t\tFROM c0002rpt_cc_time x1 \r\n\t\t\t\t\tWHERE x1.TGL='" . $tglIn . "' AND x1.USER_ID NOT IN ('61','62')\r\n\t\t\t\t\tGROUP BY x1.TGL,x1.USER_ID\t\t\t\t\t\r\n\t\t\t\t")->queryAll()]);
         /**
          * MAP ATTACH 
          * EXISTING ATTACH xlsx,zip
          * @author Piter Novian [ptr.nov@gmail.com] 
          */
         //$rootPathExcel='/var/www/advanced/lukisongroup/cronjob/tmp_cronjob/';
         //$rootPathImageZip='/var/www/advanced/lukisongroup/cronjob/tmp_cronjob/img/';
         //$rootPathExcel=Yii::getAlias('@lukisongroup').'/cronjob/tmp_cronjob/';
         $rootPathExcel = '/var/www/backup/salesmd/excel/';
         $rootPathImageZip = '/var/www/backup/salesmd/photo/';
         //$rootPathImageZip=Yii::getAlias('@lukisongroup').'/cronjob/tmp_cronjob/img/';
         $filename = "PostmanDailySalesMd" . "-" . $tglIn;
         if ($dataList) {
             $listImg = $dataList->getModels();
             $filenameAll[] = ['path' => $rootPathExcel . $filename . '.xlsx', 'filename' => $filename, 'type' => 'xlsx'];
             foreach ($listImg as $row => $value) {
                 $fileAttach[] = ['path' => $rootPathImageZip . $value['TGL'] . '_visit_image-' . $value['SALES_NM'] . '.zip', 'filename' => $value['TGL'] . '_visit_image-' . $value['SALES_NM'], 'type' => 'zip'];
             }
             $filenameAll = ArrayHelper::merge($filenameAll, $fileAttach);
         }
         //print_r($filenameAll);
         /**
          * SEND EMAIL
          * EXISTING ATTACH xlsx,zip
          * @author Piter Novian [ptr.nov@gmail.com] 
          */
         //Get Content
         $contentBody = $this->renderPartial('_postmanBodyDailySales', ['cusCount' => $cusCount]);
         // Send-to,Subject,Body
         Yii::$app->mailer->compose()->setFrom(['*****@*****.**' => 'LG-ERP-POSTMAN'])->setTo(['*****@*****.**', '*****@*****.**', '*****@*****.**'])->setSubject('POSTMAN - DAILY REPORT SALES MD')->setHtmlBody($contentBody);
         // Array data Attach, checking exiting file
         foreach ($filenameAll as $row => $value) {
             if (file_exists($value['path'])) {
                 Yii::$app->mailer->compose()->attach($value['path'], [$value['filename'], $value['type']]);
             }
         }
         Yii::$app->mailer->compose()->send();
     }
 }
コード例 #22
0
    protected function graphEsmStockPerSku()
    {
        /*Category*/
        $AryDataProviderCtg = new ArrayDataProvider(['allModels' => Yii::$app->db_esm->createCommand("CALL ESM_GRAPH_stock_per_sku('kategory_label','')")->queryAll(), 'pagination' => ['pageSize' => 100]]);
        $dataProviderCtg = $AryDataProviderCtg->getModels();
        $resultCtg = Json::encode($dataProviderCtg);
        /*Item Value 1*/
        $AryDataProviderVal1 = new ArrayDataProvider(['allModels' => Yii::$app->db_esm->createCommand("CALL ESM_GRAPH_stock_per_sku('value','BRG.ESM.2016.01.0001')")->queryAll(), 'pagination' => ['pageSize' => 100]]);
        $dataProviderVal1 = $AryDataProviderVal1->getModels();
        $resultVal1 = Json::encode($dataProviderVal1);
        /*Item Value 2*/
        $AryDataProviderVal2 = new ArrayDataProvider(['allModels' => Yii::$app->db_esm->createCommand("CALL ESM_GRAPH_stock_per_sku('value','BRG.ESM.2016.01.0002')")->queryAll(), 'pagination' => ['pageSize' => 100]]);
        $dataProviderVal2 = $AryDataProviderVal2->getModels();
        $resultVal2 = Json::encode($dataProviderVal2);
        /*Item Value 3*/
        $AryDataProviderVal3 = new ArrayDataProvider(['allModels' => Yii::$app->db_esm->createCommand("CALL ESM_GRAPH_stock_per_sku('value','BRG.ESM.2016.01.0003')")->queryAll(), 'pagination' => ['pageSize' => 100]]);
        $dataProviderVal3 = $AryDataProviderVal3->getModels();
        $resultVal3 = Json::encode($dataProviderVal3);
        /*Item Value 4*/
        $AryDataProviderVal4 = new ArrayDataProvider(['allModels' => Yii::$app->db_esm->createCommand("CALL ESM_GRAPH_stock_per_sku('value','BRG.ESM.2016.01.0004')")->queryAll(), 'pagination' => ['pageSize' => 100]]);
        $dataProviderVal4 = $AryDataProviderVal4->getModels();
        $resultVal4 = Json::encode($dataProviderVal4);
        /*Item Value 5*/
        $AryDataProviderVal5 = new ArrayDataProvider(['allModels' => Yii::$app->db_esm->createCommand("CALL ESM_GRAPH_stock_per_sku('value','BRG.ESM.2016.01.0005')")->queryAll(), 'pagination' => ['pageSize' => 100]]);
        $dataProviderVal5 = $AryDataProviderVal5->getModels();
        $resultVal5 = Json::encode($dataProviderVal5);
        $prn = '{
			"chart": {
				"caption": "UPDATE ESM STOCK PER SKU",
				"showValues": "1" , 
                "captionFontSize": "14",
                "subcaptionFontSize": "14",
                "subcaptionFontBold": "0",
                "paletteColors": "#FF0033,#0B2536,#0075c2,#9E466B,#C5E323",
                "bgcolor": "#ffffff",
                "showBorder": "1",
                "showShadow": "0",
                "showCanvasBorder": "0",
                "usePlotGradientColor": "0",
                "legendBorderAlpha": "1",
                "legendShadow": "1",
                "showAxisLines": "0",
                "showAlternateHGridColor": "0",
                "divlineThickness": "1",
                "divLineIsDashed": "1",
                "divLineDashLen": "1",
                "divLineGapLen": "1"			
            },
			"categories": [{
				"category":' . $resultCtg . '
			}],
			"dataset": [
				 {
                    "seriesname": "MAXI Cassava Chips Balado",
                    "data": ' . $resultVal1 . '
                }, 
                {
                    "seriesname": "MAXI Talos Chips Black Paper",
                    "data":' . $resultVal2 . '
                },
				{
                    "seriesname": "MAXI Talos Roasted Corn",
                    "data":' . $resultVal3 . '
                },
				{
                    "seriesname": "MAXI Cassava Crackers Hot Spicy",
                    "data": ' . $resultVal4 . '
                },
				{
                    "seriesname": "MAXI mixed Roots",
                    "data": ' . $resultVal5 . '
                }
			]
		}';
        return $prn;
    }
コード例 #23
0
    /**
     * Status : Dev test.  ptr.nov
     */
    public function actionChartTest()
    {
        $dataParenCustomer1 = new ArrayDataProvider(['key' => 'CUST_KD', 'allModels' => Yii::$app->db_esm->cache(function ($db_esm) {
            return $db_esm->createCommand("\n\t\t\t\t\tSELECT x1.label,x1.value\n\t\t\t\t\tFROM\n\t\t\t\t\t\t(SELECT #x1.CUST_KD,x1.CUST_GRP,\n\t\t\t\t\t\t\t\t x1.CUST_NM as label,\n\t\t\t\t\t\t\t\t(SELECT COUNT(x2.CUST_KD) FROM c0001 x2 WHERE x2.CUST_GRP=x1.CUST_KD LIMIT 1 ) as value\n\t\t\t\t\t\tFROM c0001 x1\n\t\t\t\t\t\tWHERE x1.CUST_KD=x1.CUST_GRP) x1 \n\t\t\t\t\tORDER BY x1.value DESC;\n\t\t\t\t")->queryAll();
        }, 60), 'pagination' => ['pageSize' => 200]]);
        $chartdata = '{
				"chart": {
				 "caption":"Summary Customers Category Detail",
				 "xAxisName":"Category Name",
				 "yAxisName":"Count ",
				 "theme":"fint",
				 "is2D":"0",
				 "showValues":"1",
				 "palettecolors":"#583e78,#008ee4,#f8bd19,#e44a00,#6baa01,#ff2e2e",
				 "bgColor":"#ffffff",
				 "showBorder":"0",
				 "showCanvasBorder":"0"
				} , 
				"data": ' . json_encode($dataParenCustomer1->getModels()) . '	
			}';
        //return  json_encode($dataParenCustomer1->getModels());
        return $chartdata;
    }
コード例 #24
0
 /**
  * Verify models in widget output.
  *
  * @param string            $result
  * @param ArrayDataProvider $dataProvider
  */
 protected function verifyModels($result, $dataProvider)
 {
     for ($index = 1; $index <= $dataProvider->getTotalCount(); ++$index) {
         $this->assertContains('[model ' . $index . ']', $result);
     }
 }
コード例 #25
0
 public function actionJsoncalendar($start = NULL, $end = NULL, $_ = NULL)
 {
     //public function actionJsoncalendar(){
     $events = array();
     /*array dataprovider from ScheduleDetail author :wawan*/
     $AryDataProviderVal = new ArrayDataProvider(['allModels' => Yii::$app->db_esm->createCommand("SELECT DISTINCT\n    \t\t\t\t\tTGL as start, (SELECT SCDL_GROUP_NM FROM c0007 WHERE ID=SCDL_GROUP) as title\n    \t\t\t\t\tFROM c0002scdl_detail_temp;")->queryAll(), 'pagination' => ['pageSize' => 100]]);
     /*event calender from ScheduleDetail author :wawan*/
     $eventCalendar = $AryDataProviderVal->getModels();
     //Demo
     $Event = new \yii2fullcalendar\models\Event();
     //FIELD HARUS [id,start,end,title]
     header('Content-type: application/json');
     echo Json::encode($eventCalendar);
     Yii::$app->end();
 }
コード例 #26
0
 public function all()
 {
     $provider = new ArrayDataProvider(['key' => 'id', 'allModels' => $this->allModels, 'pagination' => ['totalCount' => count($this->allModels), 'pageSize' => 50, 'forcePageParam' => true]]);
     $models = $provider->getModels();
     $pager = LinkPager::widget(['pagination' => $provider->getPagination(), 'maxButtonCount' => 10]);
     $result = ['models' => array_values($models), 'pager' => $pager];
     return $result;
 }
コード例 #27
0
<?php

use kartik\helpers\Html;
use yii\widgets\DetailView;
use yii\bootstrap\ActiveForm;
use kartik\tabs\TabsX;
use yii\helpers\Json;
use yii\web\Response;
use yii\helpers\ArrayHelper;
use yii\data\ArrayDataProvider;
use yii\db\Query;
?>

<?php 
$provider = new ArrayDataProvider(['allModels' => Yii::$app->db_esm->createCommand("CALL PURCHASING_report_cc('CC_BISNIS','CORP')")->queryAll(), 'pagination' => ['pageSize' => 1000]]);
$dataJson = Json::encode($provider->getModels());
$dataJsonBisnisDept = 'data:' . $dataJson;
//print_r($$dataJsonBisnisDept);
//print_r(Json::encode($provider->getModels()));
//print_r($provider);
?>




<div id="column2d-cc-bisnis"></div>

<?php 
$this->registerJs("\n\t\tFusionCharts.ready(function () {\n\t\tvar myChart = new FusionCharts({\n\t\t\ttype: 'column2d',\n\t\t\twidth: '100%',\n\t\t\t//height: '100%',\t\t\t\n\t\t\trenderAt: 'column2d-cc-bisnis',\n\t\t\tdataFormat: 'json',\n\t\t\tdataSource: {\n\t\t\t\tchart: {\n\t\t\t\t\tcaption: 'COST CENTER BISNIS',\n\t\t\t\t\t//subCaption: 'Top 5 stores in last month by revenue',\n\t\t\t\t\t//subcaption: 'Yearly Actual Total Stock sell-out',\n\t\t\t\t\tsubcaptionFontBold: '0',\n\t\t\t\t\tsubcaptionFontSize: '14',\n\t\t\t\t\t//numberPrefix: 'IDR ',\n\t\t\t\t\t//yaxismaxvalue: '9000000',\n\t\t\t\t\tnumberscalevalue:'1000,1000,1000',\n\t\t\t\t\tnumberscaleunit:'R,Jt,M',\n\t\t\t\t\tborderAlpha: '0',\n\t\t\t\t\tbgColor: '#ffffff',\n\t\t\t\t\tusePlotGradientColor: '0',\n\t\t\t\t\tplotBorderAlpha: '10', \n\t\t\t\t\tshowAlternateHGridColor: '0',\n\t\t\t\t\tshowXAxisLine: '1'\t\t\t\t\t\t\n\t\t\t\t},\n\t\t\t\t{$dataJsonBisnisDept}\n\t\t\t\t/* data:[{\n\t\t\t\t\tlabel: 'Bakersfield Central',\n\t\t\t\t\tvalue: '880000'\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: 'Garden Groove harbour',\n\t\t\t\t\tvalue: '730000'\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: 'Los Angeles Topanga',\n\t\t\t\t\tvalue: '590000'\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: 'Compton-Rancho Dom',\n\t\t\t\t\tvalue: '520000'\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: 'Daly City Serramonte',\n\t\t\t\t\tvalue: '330000'\n\t\t\t\t}] */\n\t\t\t}\n\t\t});\n\t\t// Render the chart.\n\t\tmyChart.render();\n\t});\n", $this::POS_READY);
コード例 #28
0
    public function graphEsmSalesInventory()
    {
        /*Category*/
        $AryDataProviderCtg = new ArrayDataProvider(['allModels' => Yii::$app->db_esm->createCommand("CALL DASHBOARD_ESM_SALES_inventory('kategory_label','')")->queryAll(), 'pagination' => ['pageSize' => 100]]);
        $dataProviderCtg = $AryDataProviderCtg->getModels();
        $resultCtg = Json::encode($dataProviderCtg);
        /*Item Value 1*/
        $AryDataProviderVal1 = new ArrayDataProvider(['allModels' => Yii::$app->db_esm->createCommand("CALL DASHBOARD_ESM_SALES_inventory('value_stock','BRG.ESM.2016.01.0001')")->queryAll(), 'pagination' => ['pageSize' => 100]]);
        $dataProviderVal1 = $AryDataProviderVal1->getModels();
        $resultVal1 = Json::encode($dataProviderVal1);
        /*Item Value 2*/
        $AryDataProviderVal2 = new ArrayDataProvider(['allModels' => Yii::$app->db_esm->createCommand("CALL DASHBOARD_ESM_SALES_inventory('value_stock','BRG.ESM.2016.01.0002')")->queryAll(), 'pagination' => ['pageSize' => 100]]);
        $dataProviderVal2 = $AryDataProviderVal2->getModels();
        $resultVal2 = Json::encode($dataProviderVal2);
        /*Item Value 3*/
        $AryDataProviderVal3 = new ArrayDataProvider(['allModels' => Yii::$app->db_esm->createCommand("CALL DASHBOARD_ESM_SALES_inventory('value_stock','BRG.ESM.2016.01.0003')")->queryAll(), 'pagination' => ['pageSize' => 100]]);
        $dataProviderVal3 = $AryDataProviderVal3->getModels();
        $resultVal3 = Json::encode($dataProviderVal3);
        /*Item Value 4*/
        $AryDataProviderVal4 = new ArrayDataProvider(['allModels' => Yii::$app->db_esm->createCommand("CALL DASHBOARD_ESM_SALES_inventory('value_stock','BRG.ESM.2016.01.0004')")->queryAll(), 'pagination' => ['pageSize' => 100]]);
        $dataProviderVal4 = $AryDataProviderVal4->getModels();
        $resultVal4 = Json::encode($dataProviderVal4);
        /*Item Value 5*/
        $AryDataProviderVal5 = new ArrayDataProvider(['allModels' => Yii::$app->db_esm->createCommand("CALL DASHBOARD_ESM_SALES_inventory('value_stock','BRG.ESM.2016.01.0005')")->queryAll(), 'pagination' => ['pageSize' => 100]]);
        $dataProviderVal5 = $AryDataProviderVal5->getModels();
        $resultVal5 = Json::encode($dataProviderVal5);
        /*SELL OUT ALL*/
        $AryDataProviderValSellOutAll = new ArrayDataProvider(['allModels' => Yii::$app->db_esm->createCommand("CALL DASHBOARD_ESM_SALES_inventory('value_sell_out_all','')")->queryAll(), 'pagination' => ['pageSize' => 100]]);
        $dataProviderSellOutAll = $AryDataProviderValSellOutAll->getModels();
        $resultValSellOutAll = Json::encode($dataProviderSellOutAll);
        $prn = '{
			"chart": {				
				"caption":"SALESMAN DAILY STOCK",     											 
				"plotgradientcolor": "",
				"bgcolor": "FFFFFF",
				"showalternatehgridcolor": "0",
				"divlinecolor": "CCCCCC",
				"showvalues": "0",
				"showcanvasborder": "0",
				"canvasborderalpha": "0",
				"canvasbordercolor": "CCCCCC",
				"canvasborderthickness": "1",
				"yaxismaxvalue": "30000",
				"captionpadding": "30",
				"yaxisvaluespadding": "15",
				"legendshadow": "0",
				"legendborderalpha": "0",
				"palettecolors": "#583e78,#008ee4,#f8bd19,#e44a00,#6baa01,#ff2e2e",
				"showplotborder": "0",
				"showborder": "0"				
			},
			"categories": [
				{"category":' . $resultCtg . '}
			]
			,
			"dataset": [
				{
					"dataset": [
						{
							"seriesname": "MAXI Cassava Chips Balado",
							"data": ' . $resultVal1 . '
						}, 
						{
							"seriesname": "MAXI Talos Chips Black Paper",
							"data":' . $resultVal2 . '
						},
						{
							"seriesname": "MAXI Talos Roasted Corn",
							"data":' . $resultVal3 . '
						},
						{
							"seriesname": "MAXI Cassava Crackers Hot Spicy",
							"data": ' . $resultVal4 . '
						},
						{
							"seriesname": "MAXI mixed Roots",
							"data": ' . $resultVal5 . '
						}
					]
				}
			],
			"lineset": [					
				{
					"seriesname": "Sell Out",
					"showValues": "0",
					"data": ' . $resultValSellOutAll . '
				}, 						
					
			]
		}';
        return $prn;
    }
コード例 #29
0
 public function actionViewAllCustomer()
 {
     /* CUSTOMER CATEHORI COUNT [modern,general,horeca,other]*/
     $dataProvider_CustPrn = new ArrayDataProvider(['allModels' => Yii::$app->db_esm->cache(function ($db_esm) {
         return $db_esm->createCommand("CALL DASHBOARD_ESM_SALES_custromer_ktg('count_kategory_customer_parent')")->queryAll();
     }, 60), 'pagination' => ['pageSize' => 50]]);
     $model_CustPrn = $dataProvider_CustPrn->getModels();
     $count_CustPrn = $dataProvider_CustPrn->getCount();
     //print_r($this->CountChildCustomer());
     //die();
     return $this->render('_view_all_customer', ['model_CustPrn' => $model_CustPrn, 'count_CustPrn' => $count_CustPrn, 'resultCountChildParen' => $this->CountChildCustomer()]);
 }
コード例 #30
0
ファイル: index - Copy.php プロジェクト: adem-team/advanced
// 'contentOptions'=>[
// 'style'=>[
// 'text-align'=>'center',
// 'width'=>'10px',
// 'height'=>'10px',
// 'font-family'=>'tahoma, arial, sans-serif',
// 'font-size'=>'9pt',
// ]
// ],
// ];
/*GRIDVIEW EXPAND*/
$attDinamik[] = ['class' => 'kartik\\grid\\ExpandRowColumn', 'width' => '50px', 'header' => 'Detail', 'value' => function ($model, $key, $index, $column) {
    return GridView::ROW_COLLAPSED;
}, 'detail' => function ($model, $key, $index, $column) {
    /* [1] HEADER1 */
    $dataModelsHeader1 = new ArrayDataProvider(['allModels' => Yii::$app->db_esm->createCommand("CALL DASHBOARD_ESM_VISIT_header1('ALL_HEAD1','" . $model['TGL'] . "','" . $model['CUST_ID'] . "')")->queryAll(), 'pagination' => ['pageSize' => 50]]);
    /* [2] HEADER2 */
    $dataProviderHeader2 = new ArrayDataProvider(['allModels' => Yii::$app->db_esm->createCommand("CALL DASHBOARD_ESM_VISIT_header2('ALL_HEAD2','" . $model['USER_ID'] . "','" . $model['TGL'] . "')")->queryAll(), 'pagination' => ['pageSize' => 50]]);
    /* [3] IVENTORY */
    $inventoryProvider = new ArrayDataProvider(['allModels' => Yii::$app->db_esm->createCommand("CALL ERP_CUSTOMER_VISIT_inventory('" . $model['TGL'] . "','" . $model['CUST_ID'] . "','" . $model['USER_ID'] . "')")->queryAll(), 'pagination' => ['pageSize' => 50]]);
    /* [4] EXPIRED */
    /* [5] REQUEST */
    /* [6] IMAGE VISIT */
    $searchModel = new CustomerVisitImageSearch(['ID_DETAIL' => '' . $model['ID_DTL'] . '']);
    $dataProviderImage = $searchModel->search(Yii::$app->request->queryParams);
    /* RENDER */
    return Yii::$app->controller->renderPartial('_expand1', ['dataModelsHeader1' => $dataModelsHeader1->getModels(), 'dataProviderHeader2' => $dataProviderHeader2, 'inventoryProvider' => $inventoryProvider, 'searchModelImage' => $searchModel, 'dataProviderImage' => $dataProviderImage]);
}, 'collapseTitle' => 'Close Exploler', 'expandTitle' => 'Click to views detail', 'expandOneOnly' => true, 'headerOptions' => ['id' => 'xx', 'style' => ['text-align' => 'center', 'width' => '10px', 'font-family' => 'tahoma, arial, sans-serif', 'font-size' => '9pt', 'background-color' => 'rgba(74, 206, 231, 1)']], 'contentOptions' => ['id' => 'xx', 'style' => ['text-align' => 'center', 'width' => '10px', 'height' => '10px', 'font-family' => 'tahoma, arial, sans-serif', 'font-size' => '9pt']]];
/*GRIDVIEW ARRAY ROWS*/
foreach ($gvHeadColomn as $key => $value[]) {
    $attDinamik[] = ['attribute' => $value[$key]['FIELD'], 'label' => $value[$key]['label'], 'filterType' => $value[$key]['filterType'], 'filter' => $value[$key]['filter'], 'filterOptions' => ['style' => 'background-color:rgba(' . $value[$key]['filterwarna'] . '); align:center'], 'hAlign' => 'right', 'vAlign' => 'middle', 'noWrap' => true, 'group' => $value[$key]['GRP'], 'format' => $value[$key]['FORMAT'], 'headerOptions' => ['style' => ['text-align' => 'center', 'width' => $value[$key]['FIELD'], 'font-family' => 'tahoma, arial, sans-serif', 'font-size' => '8pt', 'background-color' => 'rgba(' . $value[$key]['warna'] . ')']], 'contentOptions' => ['style' => ['text-align' => $value[$key]['align'], 'font-family' => 'tahoma, arial, sans-serif', 'font-size' => '8pt']]];