public function actionIndex()
 {
     $model = new Prospekdata();
     $regional = Regional::find()->asArray()->all();
     $data = array();
     foreach ($regional as $row) {
         $total = $model->find()->where(['FIELD4' => $row['FIELD1']])->asArray()->count();
         $produktif = $model->find()->where(['FIELD4' => $row['FIELD1']])->andwhere(['FIELD8' => 1])->asArray()->count();
         $nonproduktif = $model->find()->where(['FIELD4' => $row['FIELD1']])->andwhere(['FIELD8' => 0])->asArray()->count();
         $offering = $model->find()->where(['FIELD4' => $row['FIELD1']])->andWhere(['FIELD9' => 0])->asArray()->count();
         array_push($data, array('regional' => $row['FIELD1'], 'jumlah' => $total, 'produktif' => $produktif, 'nonproduktif' => $nonproduktif, 'offering' => $offering));
     }
     return $this->render('index', ['data' => $data, 'regional' => $regional]);
 }
Example #2
0
 public function actionProspekdata()
 {
     $model = new Prospekdata();
     $idproduktif = 0;
     for ($i = 1; $i <= 2000; $i++) {
         $tunggakan = 1;
         $idproduk = 1;
         $id_regional = 1;
         $id_area = 1;
         $idproduktif = 1;
         if ($i % 8 == 0) {
             $tunggakan = 54897987;
             $idproduk = 8;
             $id_regional = 8;
             $id_area = 8;
             $idproduktif = 1;
         } else {
             if ($i % 7 == 0) {
                 $tunggakan = 1231579;
                 $idproduk = 7;
                 $id_regional = 7;
                 $id_area = 7;
                 $idproduktif = 0;
             } else {
                 if ($i % 6 == 0) {
                     $tunggakan = 26579889;
                     $idproduk = 6;
                     $id_regional = 6;
                     $id_area = 6;
                     $idproduktif = 1;
                 } else {
                     if ($i % 5 == 0) {
                         $tunggakan = 897878;
                         $idproduk = 5;
                         $id_regional = 5;
                         $id_area = 5;
                         $idproduktif = 1;
                     } else {
                         if ($i % 4 == 0) {
                             $tunggakan = 4589745;
                             $idproduk = 4;
                             $id_regional = 4;
                             $id_area = 4;
                             $idproduktif = 1;
                         } else {
                             if ($i % 3 == 0) {
                                 $tunggakan = 26579889;
                                 $idproduk = 3;
                                 $id_regional = 3;
                                 $id_area = 3;
                                 $idproduktif = 0;
                             } else {
                                 if ($i % 2 == 0) {
                                     $tunggakan = 1564989;
                                     $idproduk = 2;
                                     $id_regional = 2;
                                     $id_area = 2;
                                     $idproduktif = 0;
                                 }
                             }
                         }
                     }
                 }
             }
         }
         $model->FIELD1 = $i;
         $model->FIELD2 = $idproduk;
         $model->FIELD3 = $idproduk;
         $model->FIELD4 = $id_regional;
         $model->FIELD5 = $id_area;
         $model->FIELD6 = "Test Description";
         $model->FIELD7 = $tunggakan;
         $model->FIELD8 = $idproduktif;
         $model->FIELD9 = $idproduktif;
         if ($model->insert()) {
             echo "sukses" . $i;
         } else {
             print_r($model->getErrors());
         }
     }
 }