Esempio n. 1
0
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         $state_max_id = \backend\models\State::find()->max('id');
         $state_model_with_max_id = \backend\models\State::findOne($state_max_id);
         if ($this->isNewRecord) {
             $old_shop_state = $state_model_with_max_id->shop_state;
             $new_state = new \backend\models\State();
             $new_state->shop_state = $old_shop_state - $this->revenue;
             $new_state->cash_register_start = $state_model_with_max_id->cash_register_end;
             $new_state->cash_register_end = $state_model_with_max_id->cash_register_end + $this->revenue;
             $new_state->output = $this->revenue;
             $new_state->input = 0;
             $new_state->save();
         } else {
             $updating_model = $state_model_with_max_id;
             $previous_id = \backend\models\State::find()->select('max(id)')->andWhere(['<', 'id', $state_max_id]);
             $previous_model = \backend\models\State::findOne($previous_id);
             $updating_model->shop_state = $previous_model->shop_state - $this->revenue;
             $updating_model->cash_register_start = $previous_model->cash_register_end;
             $updating_model->cash_register_end = $previous_model->cash_register_end + $this->revenue;
             $updating_model->output = $this->revenue;
             $updating_model->input = 0;
             $updating_model->save();
         }
         return true;
     } else {
         return false;
     }
 }
Esempio n. 2
0
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         $state_max_id = \backend\models\State::find()->max('id');
         $state_model_with_max_id = \backend\models\State::findOne($state_max_id);
         $old_shop_state = $state_model_with_max_id->shop_state;
         $new_state = new State();
         $new_state->shop_state = $old_shop_state + $this->increment_price;
         $new_state->cash_register_start = $state_model_with_max_id->cash_register_end;
         $new_state->cash_register_end = $state_model_with_max_id->cash_register_end - $this->increment_price;
         $new_state->output = 0;
         $new_state->input = $this->increment_price;
         $new_state->save();
         return true;
     } else {
         return false;
     }
 }
Esempio n. 3
0
 public function actionGetStatisctic()
 {
     $request = Yii::$app->request;
     $year = $request->post('year');
     $state = $request->post('negeri');
     $data['centerPoint'] = State::getPoint($state);
     $data['userpointarray'] = PersonalInformation::getUserPositionByYear($year);
     Yii::$app->response->format = 'json';
     // klu nk convert smue data jdi json
     echo json_encode($data);
 }
 public function actionGetAdvancedReport()
 {
     /*$data["test"] = "lala";
       print_r($_POST);
       die();*/
     $request = Yii::$app->request;
     $state = $request->post('state');
     $race = $request->post('race');
     $age = $request->post('age');
     $gender = $request->post('gender');
     //education
     $advFaculty = $request->post('advFaculty');
     $advCourse = $request->post('advCourse');
     $level = $request->post('level');
     $year = $request->post('year');
     //occupation
     $stateWork = $request->post('stateWork');
     $workstatus = $request->post('workstatus');
     $position = $request->post('workposition');
     $data['student'] = State::getResultAdvancedReport($state, $race, $age, $gender, $advFaculty, $advCourse, $level, $year, $stateWork, $workstatus, $position);
     /*print_r($data['student']);
       die();*/
     return $this->render('viewReport', $data);
 }
 /**
  * Deletes an existing Orders model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     $orders_max_id = \backend\models\Orders::find()->max('id');
     $state_max_id = \backend\models\State::find()->max('id');
     $state_model_with_max_id = \backend\models\State::findOne($state_max_id);
     /*
      * if $state_model_with_max_id->output == 0 , 
      * then the last model in the state table is an order
      * otherwise it would have been a report
      */
     if ($id == $orders_max_id && $state_model_with_max_id->output == 0) {
         /*TRANSACTION*/
         $ordersItems = \backend\models\OrderItems::find()->where(['order_id' => $id])->all();
         //delete order items, then delete the order itself and then delete the last state model
         foreach ($ordersItems as $ordersItem) {
             $ordersItem->delete();
         }
         $this->findModel($id)->delete();
         $state_model_with_max_id->delete();
         /* TRANSACTION*/
         return $this->redirect(['index']);
     } else {
         throw new \yii\web\ForbiddenHttpException('You can NOT delete this order! ' . 'Please, contact the Admin for more information.');
     }
 }
Esempio n. 6
0
?>
</title>
        <?php 
$this->head();
?>
    </head>
    <body>
<?php 
$this->beginBody();
?>
        <div class="wrap">
        <?php 
$is_admin = ValueHelpers::getRoleValue('Admin');
if (!Yii::$app->user->isGuest) {
    $state_max_id = \backend\models\State::find()->max('id');
    $state_model_with_max_id = \backend\models\State::findOne($state_max_id);
    $shop_state = number_format($state_model_with_max_id->shop_state);
    NavBar::begin(['brandLabel' => 'Market <i class="fa fa-shopping-cart"></i> Admin &nbsp;&nbsp;&nbsp;&nbsp;<i class="fa fa-eur"></i>  ' . $shop_state, 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]);
} else {
    NavBar::begin(['brandLabel' => 'Market <i class="fa fa-shopping-cart"></i>', 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]);
}
if (!Yii::$app->user->isGuest && Yii::$app->user->identity->role_id >= $is_admin) {
    $menuItems[] = ['label' => '', 'url' => ['/site/index'], 'linkOptions' => ['class' => 'fa fa-gears']];
    $menuItems[] = ['label' => '', 'url' => ['user/index'], 'linkOptions' => ['class' => 'fa fa-users']];
    $menuItems[] = ['label' => 'Profiles', 'url' => ['profile/index']];
    $menuItems[] = ['label' => 'Roles', 'url' => ['/role/index']];
    $menuItems[] = ['label' => 'User Types', 'url' => ['/user-type/index']];
    $menuItems[] = ['label' => 'Statuses', 'url' => ['/status/index']];
}
if (Yii::$app->user->isGuest) {
    $menuItems[] = ['label' => 'Login', 'url' => ['/site/login']];
Esempio n. 7
0
 public static function actionGetReport()
 {
     $request = Yii::$app->request;
     $type = $request->post('type');
     $start = $request->post('start');
     $end = $request->post('end');
     $data = "";
     if ($type == "Negeri") {
         $data['currentYear'] = State::getStateReport();
         $data['rangeYear'] = State::getStateReportRange();
         /*  print_r($data);
             die();*/
     } else {
         if ($type == "Faculty") {
             $faculty = Institution::getFacultyReport($start, $end);
             $facultyDetailData = array();
             foreach ($faculty as $facultyData) {
                 $dataArray = array();
                 $dataSplit = explode(",", $facultyData['student']);
                 $facultyDetailData[$facultyData['inst_id']]["facultyName"] = $facultyData['inst_name'];
                 $facultyDetailData[$facultyData['inst_id']]["facultyCode"] = $facultyData['inst_code'];
                 for ($i = 0; $i < sizeof($dataSplit); $i++) {
                     $dataSplitDetail = explode("|", $dataSplit[$i]);
                     /*print_r($dataSplitDetail);
                       die();*/
                     //$facultyDetailData[$facultyData['inst_id']][] = isset($dataSplitDetail[1])?$dataSplitDetail[1]:'';
                     $dataArray[$facultyData['inst_id']][] = isset($dataSplitDetail[1]) ? $dataSplitDetail[1] : '';
                 }
                 $occurences = array();
                 foreach ($dataArray as $key) {
                     //print_r($key);
                     $occurences = array_count_values($key);
                     $facultyDetailData[$facultyData['inst_id']]['count'][] = $occurences;
                     //print_r($occurences);
                 }
             }
             $data = $facultyDetailData;
             //inst_id
             /*            print_r($data);
                        
                         die();*/
         } else {
             if ($type == "Course") {
                 $occurences = array();
                 $factID = $request->post('fact_id');
                 $course = Course::getCourseReport($factID, $start, $end);
                 /*print_r($course);
                   die();*/
                 $courseDetailData = array();
                 $bil2 = 1;
                 $sizecourse = sizeof($course);
                 foreach ($course as $courseData) {
                     $dataCourseArray = array();
                     $dataCourseSplit = explode(",", $courseData['students']);
                     $courseDetailData[$bil2]["courseName"] = $courseData['course_name'];
                     $courseDetailData[$bil2]["courseCode"] = $courseData['course_code'];
                     $courseDetailData[$bil2]["size"] = $sizecourse;
                     for ($i = 0; $i < sizeof($dataCourseSplit); $i++) {
                         $dataSplitDetail = explode("|", $dataCourseSplit[$i]);
                         // $courseDetailData[$courseData['course_id']][] = $dataCourseSplitDetail[1];
                         $dataCourseArray[$bil2][] = isset($dataSplitDetail[1]) ? $dataSplitDetail[1] : '';
                     }
                     $occurences = array();
                     foreach ($dataCourseArray as $key) {
                         //print_r($key);
                         $occurences = array_count_values($key);
                         $courseDetailData[$bil2]['count'][] = $occurences;
                         //print_r($occurences);
                     }
                     $bil2++;
                 }
                 $courseDetailData[$bil2]['count'][] = $occurences;
                 $data = $courseDetailData;
             } else {
                 if ($type == "Jantina") {
                     $data = Institution::getUserReport($start);
                 } else {
                     if ($type == "work") {
                         $data = Institution::getWorkingReport($start);
                     }
                 }
             }
         }
     }
     Yii::$app->response->format = 'json';
     //header json
     echo json_encode($data);
 }
 /**
  * Deletes an existing Reports model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     $report_max_id = Reports::find()->max('id');
     $state_max_id = \backend\models\State::find()->max('id');
     $state_model_with_max_id = \backend\models\State::findOne($state_max_id);
     /*
      * if $state_model_with_max_id->input == 0 , 
      * then the last model in the state table is a report
      * otherwise it would have been an order
      */
     if ($id == $report_max_id && $state_model_with_max_id->input == 0) {
         /*
          * TRANSACTION
          */
         $this->findModel($id)->delete();
         $state_model_with_max_id->delete();
         /*
          * TRANSACTION
          */
         return $this->redirect(['index']);
     } else {
         throw new \yii\web\ForbiddenHttpException('You can NOT delete this report! ' . 'Please, contact the Admin for more information.');
     }
 }