Esempio n. 1
0
 public function transTest()
 {
     $trans = Transactions::find()->orderBy(['num' => SORT_ASC, 'linenum' => SORT_ASC])->All();
     $num = 0;
     $linenum = 0;
     $sum = 0;
     //$singleLine=true;
     foreach ($trans as $tran) {
         if ($tran->num != $num) {
             if ($tran->num != $num + 1) {
                 $this->errors[] = 'Invalid Transaction number: ' . $tran->num . " id: " . $tran->id;
             }
             $num = $tran->num;
             if (abs($sum) > 0.001 && $linenum == 1) {
                 //spacial case single line
                 $this->errors[] = 'Invalid Transaction sum: ' . $sum . " num: " . ($tran->num - 1);
             }
             $sum = $tran->leadsum;
             $linenum = 1;
         } else {
             if ($tran->linenum == $linenum + 1) {
                 $linenum = $tran->linenum;
                 $sum += $tran->leadsum;
                 //$singleLine=false;
             } else {
                 $this->errors[] = 'Invalid Transaction line in number: ' . $tran->num . " id: " . $tran->id;
             }
         }
     }
 }
Esempio n. 2
0
 /**
  * Lists all Products models.
  * @return mixed
  */
 public function actionUser()
 {
     $transactions = [];
     $user_account = null;
     $pagination = null;
     $date_posted = '';
     $g_total_quantity = $g_total_amount = $g_total_amount_paid = 0;
     $user_id = Yii::$app->request->post('player_select');
     if (Yii::$app->request->post('date_range')) {
         $date_posted = Yii::$app->request->post('date_range');
     } elseif (Yii::$app->request->getQueryParam('page')) {
         $date_posted = Yii::$app->session['date_posted'];
         $user_id = Yii::$app->session['user_id'];
     }
     if ($date_posted != '') {
         Yii::$app->session['date_posted'] = $date_posted;
         Yii::$app->session['user_id'] = $user_id;
         $date_range = explode(' to ', $date_posted);
         $start_date = $date_range[0];
         $end_date = $date_range[1];
         $query = Transactions::find()->where(['BETWEEN', 'transaction_date', Yii::$app->formatter->asDate($start_date, 'php:Y-m-d') . ' 00:00:00', Yii::$app->formatter->asDate($end_date, 'php:Y-m-d') . ' 23:59:59'])->orderBy(['transaction_date' => SORT_DESC]);
         if ($user_id > 0) {
             $query->andWhere(['user_id' => $user_id]);
         }
         $pagination = new Pagination(['totalCount' => $query->count(), 'pageSize' => 10]);
         $g_total_quantity = $query->sum('total_quantity');
         $g_total_amount = $query->sum('total_amount');
         $g_total_amount_paid = $query->sum('amount_paid');
         $transactions = $query->offset($pagination->offset)->limit($pagination->limit)->all();
         $user_account = UserAccounts::findOne($user_id);
     }
     return $this->render('users', ['transactions' => $transactions, 'user_account' => $user_account, 'g_total_quantity' => $g_total_quantity, 'g_total_amount' => $g_total_amount, 'g_total_amount_paid' => $g_total_amount_paid, 'pagination' => $pagination]);
 }
Esempio n. 3
0
 public function search($id)
 {
     //echo $id . uniqid();
     $query = Transactions::find();
     $query->andFilterWhere(['account_id' => $id]);
     $query->andFilterWhere(['between', 'valuedate', $this->from_date, $this->to_date]);
     $dataProvider = new \yii\data\ActiveDataProvider(['query' => $query, "sort" => ['defaultOrder' => ['num' => SORT_DESC]], 'pagination' => false]);
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Transactions::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $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;
     }
     $query->andFilterWhere(['id' => $this->id, 'trans_date' => $this->trans_date, 'type_id' => $this->type_id]);
     $query->andFilterWhere(['like', 'trans_code', $this->trans_code])->andFilterWhere(['like', 'remarks', $this->remarks]);
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Transactions::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $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;
     }
     $query->joinWith('transEmployee');
     $query->andFilterWhere(['trans_date' => $this->trans_date]);
     $query->andFilterWhere(['like', 'CONCAT(employees.employee_name)', $this->trans_employee]);
     $query->andFilterWhere(['like', 'trans_id', $this->trans_id])->andFilterWhere(['like', 'trans_status', $this->trans_status]);
     return $dataProvider;
 }
Esempio n. 6
0
 public function index($s = null)
 {
     $greencoin = new Greencoin('http://' . GREENCOIN_WALLET_SERVER . ':' . GREENCOIN_WALLET_PORT, GREENCOIN_WALLET_USERNAME, GREENCOIN_WALLET_PASSWORD);
     $paytxfee = Parameters::find('first');
     $txfee = $paytxfee['payxgctxfee'];
     $getrawtransaction = $greencoin->getrawtransaction($s);
     $decoderawtransaction = $greencoin->decoderawtransaction($getrawtransaction);
     foreach ($decoderawtransaction['vout'] as $out) {
         foreach ($out['scriptPubKey']['addresses'] as $address) {
             $username = $greencoin->getaccount($address);
             $Amount = (double) $out['value'];
             if ($greencoin->getaccount($address) != "") {
                 $Transactions = Transactions::find('first', array('conditions' => array('TransactionHash' => $s)));
                 if ($Transactions['_id'] == "") {
                     $t = Transactions::create();
                     $Amount = $Amount;
                     $comment = "Move from User: "******"; Address: " . GREENCOINX_ADDRESS . "; Amount:" . $Amount . ";";
                     $transfer = $greencoin->sendfrom($username, GREENCOINX_ADDRESS, (double) $Amount, (int) 0, $comment);
                     if (isset($transfer['error'])) {
                         $error = $transfer['error'];
                     } else {
                         $error = $transfer;
                     }
                     $data = array('DateTime' => new \MongoDate(), 'TransactionHash' => $s, 'username' => $username, 'address' => $address, 'Currency' => 'XGC', 'Amount' => $Amount, 'Added' => true, 'Transfer' => $comment);
                     $t->save($data);
                     $userName = str_replace("SiiCrypto-", "", $username);
                     $details = Details::find('first', array('conditions' => array('username' => (string) $userName)));
                     $dataDetails = array('balance.XGC' => (double) ((double) $details['balance.XGC'] + (double) $Amount), 'XGCnewaddress' => 'Yes');
                     $details = Details::find('all', array('conditions' => array('username' => (string) $userName)))->save($dataDetails);
                 } else {
                     $Transactions = Transactions::find('first', array('conditions' => array('TransactionHash' => $s)))->save($data);
                 }
             }
         }
     }
 }
Esempio n. 7
0
 private function calc($accounts = array(), $types = array())
 {
     $sum = 0;
     /*
             $criteria = new CDbCriteria;
             $criteria->condition = "date BETWEEN :from_date AND :to_date";
             $criteria->params = array(
                 ':from_date' => $from_date,
                 ':to_date' => $to_date,
             );
             $criteria->compare('type', $types);
             $criteria->compare('account_id', $accounts);
     */
     $trans = Transactions::find()->where(['BETWEEN', 'valuedate', $this->from_date, $this->to_date])->andWhere(['type' => $types, 'account_id' => $accounts])->All();
     $sum = 0;
     $data = array();
     foreach ($trans as $tran) {
         $sum = $tran->sum;
         if ($sum != 0) {
             $data[] = array('id' => $tran->id, 'name' => $tran->account_id, 'sum' => $sum, 'id6111' => $tran->id);
         }
     }
     return $data;
 }
Esempio n. 8
0
 public function listTransactions($username, $address)
 {
     $transactions = Transactions::find('all', array('conditions' => array('address' => $address), 'order' => array('blocktime' => 'DESC')));
     return compact('transactions');
 }
Esempio n. 9
0
 public function search($params)
 {
     $query = Tasks::find();
     //формируем провайдер
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     //задание сортировки по умолчанию
     $dataProvider->sort->attributes = ['TASKS.ID' => ['asc' => ['TASKS.ID' => SORT_ASC], 'desc' => ['TASKS.ID' => SORT_DESC]]];
     $dataProvider->sort->defaultOrder = ['TASKS.ID' => SORT_DESC];
     //overdue issues filter
     if (isset($params['overdue']) && $params['overdue'] == 1) {
         $tasks = \app\models\Tasks::find()->all();
         $list = [];
         foreach ($tasks as $task) {
             $id = $task->ID;
             $persons = \app\models\PersTasks::find()->where(['TASK_ID' => $id, 'DEL_TRACT_ID' => 0])->all();
             if ($persons) {
                 $states_array = [];
                 foreach ($persons as $person) {
                     $pers_tasks = \app\models\PersTasks::find()->where(['TASK_ID' => $id, 'TN' => $person->TN, 'DEL_TRACT_ID' => 0])->one();
                     $task_state = \app\models\TaskStates::find()->where(['IS_CURRENT' => 1, 'PERS_TASKS_ID' => $pers_tasks->ID, 'TASK_ID' => $id])->one();
                     if ($task_state) {
                         $states_array[] = $task_state->STATE_ID;
                     } else {
                         $list[] = $id;
                     }
                 }
                 if (!empty($states_array)) {
                     $min_state = min($states_array);
                     $state = \app\models\States::findOne($min_state);
                 }
             }
             if (isset($state)) {
                 if ($state->ID != 7 || $state->ID != 9) {
                     $list[] = $id;
                 }
             }
         }
         $list = array_unique($list);
         $query->andFilterWhere(['TASKS.ID' => $list]);
         $now = date("Y-m-d");
         $query->andFilterWhere(['<', 'TASKS.DEADLINE', new \yii\db\Expression("to_date('" . $now . "','{$this->dateFormat}')")]);
         $query->joinWith('perstasks');
         $query->andFilterWhere(['PERS_TASKS.TN' => \Yii::$app->user->id]);
     }
     //own issues filter
     if (isset($params['own_issues']) && $params['own_issues'] == 1) {
         $query->joinWith('perstasks');
         $query->andFilterWhere(['PERS_TASKS.TN' => \Yii::$app->user->id]);
     }
     if (isset($params['for_person']) && $params['for_person'] != '') {
         $query->joinWith('perstasks');
         $query->andFilterWhere(['PERS_TASKS.TN' => $params['for_person']]);
     }
     if (isset($params['for_podr']) && $params['for_podr'] != '') {
         $query->joinWith('podrtasks');
         $query->andFilterWhere(['PODR_TASKS.KODZIFR' => $params['for_podr']]);
     }
     //podr issues filter
     if (isset($params['podr_issues']) && $params['podr_issues'] == 1) {
         //check permission
         $permissions_podr_tasks_my = \app\models\Permissions::find()->where('(SUBJECT_TYPE = :subject_type and SUBJECT_ID = :user_id and DEL_TRACT_ID = :del_tract and PERM_LEVEL != :perm_level and ACTION_ID = :action) or
             (SUBJECT_TYPE = :subject_type_dolg and SUBJECT_ID = :id_dolg and DEL_TRACT_ID = :del_tract and PERM_LEVEL != :perm_level and ACTION_ID = :action)', ['subject_type_dolg' => 1, 'id_dolg' => \Yii::$app->session->get('user.user_iddolg'), 'action' => 21, 'subject_type' => 2, 'user_id' => \Yii::$app->user->id, 'del_tract' => 0, 'perm_level' => 0])->one();
         if ($permissions_podr_tasks_my) {
             if ($permissions_podr_tasks_my->PERM_LEVEL == 1 || $permissions_podr_tasks_my->PERM_LEVEL == 2) {
                 //get podr id of this user
                 $query_dao = new \yii\db\Query();
                 $query_dao->select('*')->from('STIGIT.V_F_PERS')->where('TN = \'' . \Yii::$app->user->id . '\'');
                 $command = $query_dao->createCommand();
                 $data = $command->queryOne();
                 //вот тут решить что означает выданные моему подразделению
                 $query->joinWith('podrtasks');
                 $query->andFilterWhere(['PODR_TASKS.KODZIFR' => trim($data['KODZIFR'])]);
             } else {
                 throw new \yii\web\ForbiddenHttpException('У Вас нет прав на "Выданные любым задания"');
             }
         } else {
             throw new \yii\web\ForbiddenHttpException('У Вас нет прав на "Выданные любым задания"');
         }
     }
     //tasks my filter
     if (isset($params['tasks_my']) && $params['tasks_my'] == 1) {
         //check permission
         $permissions_podr_tasks_my = \app\models\Permissions::find()->where('(SUBJECT_TYPE = :subject_type and SUBJECT_ID = :user_id and DEL_TRACT_ID = :del_tract and PERM_LEVEL != :perm_level and ACTION_ID = :action) or
         (SUBJECT_TYPE = :subject_type_dolg and SUBJECT_ID = :id_dolg and DEL_TRACT_ID = :del_tract and PERM_LEVEL != :perm_level and ACTION_ID = :action)', ['subject_type_dolg' => 1, 'id_dolg' => \Yii::$app->session->get('user.user_iddolg'), 'action' => 23, 'subject_type' => 2, 'user_id' => \Yii::$app->user->id, 'del_tract' => 0, 'perm_level' => 0])->one();
         if ($permissions_podr_tasks_my) {
             if ($permissions_podr_tasks_my->PERM_LEVEL == 1 || $permissions_podr_tasks_my->PERM_LEVEL == 2) {
                 //get all current user transactions
                 $transactions = \app\models\Transactions::find()->where(['TN' => \Yii::$app->user->id])->all();
                 if ($transactions) {
                     $transactions_array = [];
                     foreach ($transactions as $transaction) {
                         $transactions_array[] = $transaction->ID;
                     }
                     $query->andFilterWhere(['TRACT_ID' => $transactions_array]);
                 }
             } else {
                 throw new \yii\web\ForbiddenHttpException('У Вас нет прав на "Выданные лично задания"');
             }
         } else {
             throw new \yii\web\ForbiddenHttpException('У Вас нет прав на "Выданные лично задания"');
         }
     }
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     //проверяем существует ли фильтр и добавляем его в запрос провайдера для каждого из полей фильтра
     if (!empty($this->states)) {
         $query->joinWith('taskstates');
         $query->andFilterWhere(['TASK_STATES.STATE_ID' => $this->states]);
     }
     if (!empty($this->podr_list)) {
         $podr_list = array_map('trim', explode(',', $this->podr_list));
         $query->joinWith('podrtasks');
         $query->andFilterWhere(['PODR_TASKS.KODZIFR' => $podr_list]);
     }
     if (!empty($this->agreed_podr_list)) {
         $agreed_podr_list = array_map('trim', explode(',', $this->agreed_podr_list));
         $query->joinWith('taskconfirms');
         $query->andFilterWhere(['TASK_CONFIRMS.KODZIFR' => $agreed_podr_list]);
     }
     if (!empty($this->persons_list)) {
         $persons_list = array_map('trim', explode(',', $this->persons_list));
         $query->joinWith('perstasks');
         $query->andFilterWhere(['PERS_TASKS.TN' => $persons_list]);
     }
     if (!empty($this->documentation)) {
         $query->joinWith('taskdocs');
         $query->andFilterWhere(['TASK_DOCS.DOC_CODE' => $this->documentation]);
     }
     if ($this->deadline_from != '' && $this->deadline_to != '') {
         $deadline_from = explode('-', $this->deadline_from);
         $deadline_from_formatted = $deadline_from[2] . '-' . $deadline_from[1] . '-' . $deadline_from[0];
         $deadline_to = explode('-', $this->deadline_to);
         $deadline_to_formatted = $deadline_to[2] . '-' . $deadline_to[1] . '-' . $deadline_to[0];
         $query->andFilterWhere(['>=', 'DEADLINE', new \yii\db\Expression("to_date('" . $deadline_from_formatted . "','{$this->dateFormat}')")])->andFilterWhere(['<=', 'DEADLINE', new \yii\db\Expression("to_date('" . $deadline_to_formatted . "','{$this->dateFormat}')")]);
     } else {
         if ($this->deadline_from != '' && $this->deadline_to == '') {
             $deadline_from = explode('-', $this->deadline_from);
             $deadline_from_formatted = $deadline_from[2] . '-' . $deadline_from[1] . '-' . $deadline_from[0];
             $query->andFilterWhere(['>=', 'DEADLINE', new \yii\db\Expression("to_date('" . $deadline_from_formatted . "','{$this->dateFormat}')")]);
         } else {
             if ($this->deadline_from == '' && $this->deadline_to != '') {
                 $deadline_to = explode('-', $this->deadline_to);
                 $deadline_to_formatted = $deadline_to[2] . '-' . $deadline_to[1] . '-' . $deadline_to[0];
                 $query->andFilterWhere(['<=', 'DEADLINE', new \yii\db\Expression("to_date('" . $deadline_to_formatted . "','{$this->dateFormat}')")]);
             }
         }
     }
     if ($this->task_type_date_3_from != '' && $this->task_type_date_3_to != '') {
         $query->joinWith('datetype3');
         $task_type_date_3_from = explode('-', $this->task_type_date_3_from);
         $task_type_date_3_from_formatted = $task_type_date_3_from[2] . '-' . $task_type_date_3_from[1] . '-' . $task_type_date_3_from[0];
         $task_type_date_3_to = explode('-', $this->task_type_date_3_to);
         $task_type_date_3_to_formatted = $task_type_date_3_to[2] . '-' . $task_type_date_3_to[1] . '-' . $task_type_date_3_to[0];
         $query->andFilterWhere(['>=', 'TASK_DATES.TASK_TYPE_DATE', new \yii\db\Expression("to_date('" . $task_type_date_3_from_formatted . "','{$this->dateFormat}')")])->andFilterWhere(['<=', 'TASK_DATES.TASK_TYPE_DATE', new \yii\db\Expression("to_date('" . $task_type_date_3_to_formatted . "','{$this->dateFormat}')")]);
     } else {
         if ($this->task_type_date_3_from != '' && $this->task_type_date_3_to == '') {
             $query->joinWith('datetype3');
             $task_type_date_3_from = explode('-', $this->task_type_date_3_from);
             $task_type_date_3_from_formatted = $task_type_date_3_from[2] . '-' . $task_type_date_3_from[1] . '-' . $task_type_date_3_from[0];
             $query->andFilterWhere(['>=', 'TASK_DATES.TASK_TYPE_DATE', new \yii\db\Expression("to_date('" . $task_type_date_3_from_formatted . "','{$this->dateFormat}')")]);
         } else {
             if ($this->task_type_date_3_from == '' && $this->task_type_date_3_to != '') {
                 $query->joinWith('datetype3');
                 $task_type_date_3_to = explode('-', $this->task_type_date_3_to);
                 $task_type_date_3_to_formatted = $task_type_date_3_to[2] . '-' . $task_type_date_3_to[1] . '-' . $task_type_date_3_to[0];
                 $query->andFilterWhere(['<=', 'TASK_DATES.TASK_TYPE_DATE', new \yii\db\Expression("to_date('" . $task_type_date_3_to_formatted . "','{$this->dateFormat}')")]);
             }
         }
     }
     if ($this->task_type_date_1_from != '' && $this->task_type_date_1_to != '') {
         $query->joinWith('datetype1');
         $task_type_date_1_from = explode('-', $this->task_type_date_1_from);
         $task_type_date_1_from_formatted = $task_type_date_1_from[2] . '-' . $task_type_date_1_from[1] . '-' . $task_type_date_1_from[0];
         $task_type_date_1_to = explode('-', $this->task_type_date_1_to);
         $task_type_date_1_to_formatted = $task_type_date_1_to[2] . '-' . $task_type_date_1_to[1] . '-' . $task_type_date_1_to[0];
         $query->andFilterWhere(['>=', 'TASK_DATES.TASK_TYPE_DATE', new \yii\db\Expression("to_date('" . $task_type_date_1_from_formatted . "','{$this->dateFormat}')")])->andFilterWhere(['<=', 'TASK_DATES.TASK_TYPE_DATE', new \yii\db\Expression("to_date('" . $task_type_date_1_to_formatted . "','{$this->dateFormat}')")]);
     } else {
         if ($this->task_type_date_1_from != '' && $this->task_type_date_1_to == '') {
             $query->joinWith('datetype1');
             $task_type_date_1_from = explode('-', $this->task_type_date_1_from);
             $task_type_date_1_from_formatted = $task_type_date_1_from[2] . '-' . $task_type_date_1_from[1] . '-' . $task_type_date_1_from[0];
             $query->andFilterWhere(['>=', 'TASK_DATES.TASK_TYPE_DATE', new \yii\db\Expression("to_date('" . $task_type_date_1_from_formatted . "','{$this->dateFormat}')")]);
         } else {
             if ($this->task_type_date_1_from == '' && $this->task_type_date_1_to != '') {
                 $query->joinWith('datetype1');
                 $task_type_date_1_to = explode('-', $this->task_type_date_1_to);
                 $task_type_date_1_to_formatted = $task_type_date_1_to[2] . '-' . $task_type_date_1_to[1] . '-' . $task_type_date_1_to[0];
                 $query->andFilterWhere(['<=', 'TASK_DATES.TASK_TYPE_DATE', new \yii\db\Expression("to_date('" . $task_type_date_1_to_formatted . "','{$this->dateFormat}')")]);
             }
         }
     }
     if ($this->task_type_date_4_from != '' && $this->task_type_date_4_to != '') {
         $query->joinWith('datetype4');
         $task_type_date_4_from = explode('-', $this->task_type_date_4_from);
         $task_type_date_4_from_formatted = $task_type_date_4_from[2] . '-' . $task_type_date_4_from[1] . '-' . $task_type_date_4_from[0];
         $task_type_date_4_to = explode('-', $this->task_type_date_4_to);
         $task_type_date_4_to_formatted = $task_type_date_4_to[2] . '-' . $task_type_date_4_to[1] . '-' . $task_type_date_4_to[0];
         $query->andFilterWhere(['>=', 'TASK_DATES.TASK_TYPE_DATE', new \yii\db\Expression("to_date('" . $task_type_date_4_from_formatted . "','{$this->dateFormat}')")])->andFilterWhere(['<=', 'TASK_DATES.TASK_TYPE_DATE', new \yii\db\Expression("to_date('" . $task_type_date_4_to_formatted . "','{$this->dateFormat}')")]);
     } else {
         if ($this->task_type_date_4_from != '' && $this->task_type_date_4_to == '') {
             $query->joinWith('datetype4');
             $task_type_date_4_from = explode('-', $this->task_type_date_4_from);
             $task_type_date_4_from_formatted = $task_type_date_4_from[2] . '-' . $task_type_date_4_from[1] . '-' . $task_type_date_4_from[0];
             $query->andFilterWhere(['>=', 'TASK_DATES.TASK_TYPE_DATE', new \yii\db\Expression("to_date('" . $task_type_date_4_from_formatted . "','{$this->dateFormat}')")]);
         } else {
             if ($this->task_type_date_4_from == '' && $this->task_type_date_4_to != '') {
                 $query->joinWith('datetype4');
                 $task_type_date_4_to = explode('-', $this->task_type_date_4_to);
                 $task_type_date_4_to_formatted = $task_type_date_4_to[2] . '-' . $task_type_date_4_to[1] . '-' . $task_type_date_4_to[0];
                 $query->andFilterWhere(['<=', 'TASK_DATES.TASK_TYPE_DATE', new \yii\db\Expression("to_date('" . $task_type_date_4_to_formatted . "','{$this->dateFormat}')")]);
             }
         }
     }
     if ($this->task_type_date_2_from != '' && $this->task_type_date_2_to != '') {
         $query->joinWith('datetype2');
         $task_type_date_2_from = explode('-', $this->task_type_date_2_from);
         $task_type_date_2_from_formatted = $task_type_date_2_from[2] . '-' . $task_type_date_2_from[1] . '-' . $task_type_date_2_from[0];
         $task_type_date_2_to = explode('-', $this->task_type_date_2_to);
         $task_type_date_2_to_formatted = $task_type_date_2_to[2] . '-' . $task_type_date_2_to[1] . '-' . $task_type_date_2_to[0];
         $query->andFilterWhere(['>=', 'TASK_DATES.TASK_TYPE_DATE', new \yii\db\Expression("to_date('" . $task_type_date_2_from_formatted . "','{$this->dateFormat}')")])->andFilterWhere(['<=', 'TASK_DATES.TASK_TYPE_DATE', new \yii\db\Expression("to_date('" . $task_type_date_2_to_formatted . "','{$this->dateFormat}')")]);
     } else {
         if ($this->task_type_date_2_from != '' && $this->task_type_date_2_to == '') {
             $query->joinWith('datetype2');
             $task_type_date_2_from = explode('-', $this->task_type_date_2_from);
             $task_type_date_2_from_formatted = $task_type_date_2_from[2] . '-' . $task_type_date_2_from[1] . '-' . $task_type_date_2_from[0];
             $query->andFilterWhere(['>=', 'TASK_DATES.TASK_TYPE_DATE', new \yii\db\Expression("to_date('" . $task_type_date_2_from_formatted . "','{$this->dateFormat}')")]);
         } else {
             if ($this->task_type_date_2_from == '' && $this->task_type_date_2_to != '') {
                 $query->joinWith('datetype2');
                 $task_type_date_2_to = explode('-', $this->task_type_date_2_to);
                 $task_type_date_2_to_formatted = $task_type_date_2_to[2] . '-' . $task_type_date_2_to[1] . '-' . $task_type_date_2_to[0];
                 $query->andFilterWhere(['<=', 'TASK_DATES.TASK_TYPE_DATE', new \yii\db\Expression("to_date('" . $task_type_date_2_to_formatted . "','{$this->dateFormat}')")]);
             }
         }
     }
     $query->andFilterWhere(['like', 'SOURCENUM', $this->SOURCENUM]);
     $query->andFilterWhere(['like', 'TASK_TEXT', $this->TASK_TEXT]);
     $query->andFilterWhere(['or like', 'PEOORDERNUM', $this->PEOORDERNUM]);
     $query->andFilterWhere(['or like', 'ORDERNUM', $this->ORDERNUM]);
     $query->andFilterWhere(['like', 'TASK_NUMBER', $this->TASK_NUMBER]);
     $query->andFilterWhere(['like', 'LOWER(DESIGNATION)', mb_strtolower($this->DESIGNATION, 'UTF-8')]);
     return $dataProvider;
 }
Esempio n. 10
0
 public function actionChangestatus()
 {
     if (Yii::$app->request->isAjax) {
         $status_id = $_POST['status'];
         $selected_issues = $_POST['selected_issues'];
         $user_cant_permissions_on = [];
         $user_have_permission_and_status_changed_on = [];
         foreach (json_decode($selected_issues) as $issue) {
             $pers_tasks_this = \app\models\PersTasks::find()->where(['TASK_ID' => $issue, 'TN' => \Yii::$app->user->id, 'DEL_TRACT_ID' => 0])->one();
             //проверяем имеет ли доступ пользователь к заданию и входит ли вообще в него
             if ($pers_tasks_this) {
                 $task_state = \app\models\TaskStates::find()->where(['PERS_TASKS_ID' => $pers_tasks_this->ID, 'IS_CURRENT' => 1])->one();
                 if ($task_state) {
                     // проверяем есть ли статус
                     $last_state = $task_state->STATE_ID;
                 } else {
                     // иначе устанавливаем значние даты null
                     $last_state = null;
                 }
                 if ($last_state != $status_id) {
                     $transactions = \app\models\Transactions::find()->where(['TN' => \Yii::$app->user->id])->orderBy('ID DESC')->one();
                     $new_state = new \app\models\TaskStates();
                     $new_state->TASK_ID = $issue;
                     $new_state->STATE_ID = $status_id;
                     $new_state->TRACT_ID = $transactions->ID;
                     $new_state->IS_CURRENT = 1;
                     $pers_tasks_this = \app\models\PersTasks::find()->where(['TASK_ID' => $issue, 'TN' => \Yii::$app->user->id, 'DEL_TRACT_ID' => 0])->one();
                     $new_state->PERS_TASKS_ID = $pers_tasks_this->ID;
                     $new_state->save();
                     $user_have_permission_and_status_changed_on[] = $issue;
                     //обновление поля IS_CURRENT для предыдущего состояния
                     if ($last_state != null) {
                         $task_state->IS_CURRENT = 0;
                         $task_state->save();
                     }
                 }
             } else {
                 $user_cant_permissions_on[] = $issue;
             }
         }
         $string_status_changed = '';
         if (!empty($user_have_permission_and_status_changed_on)) {
             foreach ($user_have_permission_and_status_changed_on as $issue) {
                 $task = \app\models\Tasks::findOne($issue);
                 $string_status_changed .= 'Задание №' . $task->TASK_NUMBER . ',';
             }
         }
         $string_status_not_changed = '';
         if (!empty($user_cant_permissions_on)) {
             foreach ($user_cant_permissions_on as $issue) {
                 $task = \app\models\Tasks::findOne($issue);
                 $string_status_not_changed .= 'Задание №' . $task->TASK_NUMBER . ',';
             }
         }
         Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
         return ['string_status_changed' => $string_status_changed, 'string_status_not_changed' => $string_status_not_changed];
     }
 }
Esempio n. 11
0
 public function getTotal($from_date, $to_date)
 {
     $sum = 0;
     $transactions = Transactions::find()->where(['between', 'valuedate', $from_date, $to_date])->andWhere(['account_id' => $this->id])->all();
     //$transactions = Transactions::findAll($criteria);
     foreach ($transactions as $transaction) {
         $sum += $transaction->sum;
     }
     return $sum;
 }
Esempio n. 12
0
 public function removetransaction($TransactionID, $ID, $url, $currency)
 {
     $Transaction = Transactions::find('first', array('conditions' => array('_id' => new MongoID($ID))));
     if (String::hash($Transaction['_id']) == $TransactionID) {
         $Remove = Transactions::remove(array('_id' => new MongoID($ID)));
     }
     return $this->redirect('/Users/' . $url . '/' . $currency);
 }
Esempio n. 13
0
 public function search($params)
 {
     $query = Transactions::find();
     $dataProvider = new \yii\data\ActiveDataProvider(['query' => $query, "sort" => ['defaultOrder' => ['num' => SORT_DESC]]]);
     $this->load($params);
     if (!$this->validate()) {
         var_dump($this->errors);
         //    return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'num' => $this->num, 'account_id' => $this->account_id, 'type' => $this->type, 'refnum1' => $this->refnum1]);
     $query->andFilterWhere(['like', 'details', $this->details]);
     /*
             $query->andFilterWhere(['like', 'name', $this->name])
                 ->andFilterWhere(['like', 'contact', $this->contact])
                 ->andFilterWhere(['like', 'department', $this->department])
                 ->andFilterWhere(['like', 'vatnum', $this->vatnum])
                 ->andFilterWhere(['like', 'email', $this->email])
                 ->andFilterWhere(['like', 'phone', $this->phone])
                 ->andFilterWhere(['like', 'dir_phone', $this->dir_phone])
                 ->andFilterWhere(['like', 'cellular', $this->cellular])
                 ->andFilterWhere(['like', 'fax', $this->fax])
                 ->andFilterWhere(['like', 'web', $this->web])
                 ->andFilterWhere(['like', 'address', $this->address])
                 ->andFilterWhere(['like', 'city', $this->city])
                 ->andFilterWhere(['like', 'zip', $this->zip])
                 ->andFilterWhere(['like', 'currency_id', $this->currency_id])
                 ->andFilterWhere(['like', 'comments', $this->comments]);
     */
     /*if (!empty($this->from_date) && empty($this->to_date)) {
           $query->andFilterWhere(['>=', 'valuedate',  $this->from_date]);
       } elseif (!empty($this->to_date) && empty($this->from_date)) {
           $query->andFilterWhere(['>=', 'valuedate',  $this->to_date]);
       } elseif (!empty($this->to_date) && !empty($this->from_date)) {
           $query->andFilterWhere(['between', 'valuedate', $this->from_date, $this->to_date]);
       }*/
     if (!is_null($this->valuedate)) {
         $tmp = explode(" to ", $this->valuedate);
         if (isset($tmp[0]) && isset($tmp[1])) {
             $query->andFilterWhere(['between', 'valuedate', $tmp[0], $tmp[1]]);
         }
     }
     if (!is_null($this->reg_date)) {
         $tmp = explode(" to ", $this->reg_date);
         if (isset($tmp[0]) && isset($tmp[1])) {
             $query->andFilterWhere(['between', 'reg_date', $tmp[0], $tmp[1]]);
         }
     }
     return $dataProvider;
 }
 public function _checkPermissions($action, $task_id)
 {
     switch ($action) {
         case 'open_issue_modal':
             //проверка прав на просмотр задания (в модальном окне)
             $permissions_for_open_issue_modal = \app\models\Permissions::find()->where('(SUBJECT_TYPE = :subject_type and SUBJECT_ID = :user_id and ACTION_ID = :action and DEL_TRACT_ID = :del_tract and PERM_LEVEL != :perm_level and PERM_TYPE = :perm_type)  or 
                                                                                     (SUBJECT_TYPE = :subject_type_dolg and SUBJECT_ID = :dolg_id and ACTION_ID = :action and DEL_TRACT_ID = :del_tract and PERM_LEVEL != :perm_level and PERM_TYPE = :perm_type)', ['subject_type_dolg' => 1, 'dolg_id' => \Yii::$app->session->get('user.user_iddolg'), 'perm_type' => 1, 'subject_type' => 2, 'user_id' => \Yii::$app->user->id, 'del_tract' => 0, 'perm_level' => 0, 'action' => 3])->one();
             if ($permissions_for_open_issue_modal) {
                 //в случае если есть доступ на просмотр данных о задании
                 $user_in_persons_or_podr_list = false;
                 //получаем массив подразделений задания
                 $podr_tasks = \app\models\PodrTasks::find()->where(['TASK_ID' => $task_id, 'DEL_TRACT_ID' => 0])->all();
                 if ($podr_tasks) {
                     // если существуют подразделения, то формируем их список
                     $podr_list_kodzifr_array = [];
                     foreach ($podr_tasks as $task) {
                         //обходим список подразделений
                         $query = new \yii\db\Query();
                         $query->select('*')->from('STIGIT.V_F_PODR')->where('KODZIFR = \'' . trim($task->KODZIFR) . '\'');
                         $command = $query->createCommand();
                         $data = $command->queryOne();
                         if (isset($data['KODZIFR'])) {
                             // проверяем на существование названия подразделения (на момент разработки не для всех были названия)
                             $podr_list_kodzifr_array[] = $data['KODZIFR'];
                         }
                     }
                 }
                 //проверяем входит ли данный пользователь в список исполнителей задания
                 //получаем список пользователей, кому назначено задание
                 $pers_tasks = \app\models\PersTasks::find()->where(['TASK_ID' => $task_id, 'DEL_TRACT_ID' => 0])->all();
                 if ($pers_tasks) {
                     // если существуют исполнители, то формируем их список
                     $persons_array = [];
                     foreach ($pers_tasks as $task) {
                         $query = new \yii\db\Query();
                         $query->select('*')->from('STIGIT.V_F_PERS')->where('TN = \'' . $task->TN . '\'');
                         $command = $query->createCommand();
                         $data = $command->queryOne();
                         $persons_array[] = $data['TN'];
                     }
                     //проверяем, входит ли пользователь в этот список
                     if (in_array(\Yii::$app->user->id, $persons_array)) {
                         //пользователь входит в список исполнителей
                         $user_in_persons_or_podr_list = true;
                     }
                 } else {
                     //в этом случае, задания назначено всем исполнителям из списка подразделений задания
                     $persons_array = [];
                     //обходим массив подразделений для проверки, входит ли в него текущий пользователь
                     $ids = join(',', $podr_list_kodzifr_array);
                     $query = new \yii\db\Query();
                     $query->select('*')->from('STIGIT.V_F_PERS')->where('TN = \'' . \Yii::$app->user->id . '\' and KODZIFR in (' . $ids . ')');
                     $command = $query->createCommand();
                     $data = $command->queryAll();
                     if (!empty($data)) {
                         // проверяем вхождение пользователя в список исполнителей подразделений задания
                         $user_in_persons_or_podr_list = true;
                         // текущий пользователь входит в подразделения, указанные в задании
                     }
                 }
                 //проверяем, является ли пользователь начальником подразделений, указанных в задании
                 //получаем список подчиненных подразделений
                 $user_boss_of = \Yii::$app->session->get('user.user_boss_of');
                 if (!empty($user_boss_of) && !$user_in_persons_or_podr_list) {
                     //проверяем, является ли пользователь начальником подразделений, указанных в задании
                     if (in_array($user_boss_of, $podr_list_kodzifr_array)) {
                         //пользователь является руководителем, но не входит в спиок исполнителей или указанных подразделений
                         //осуществляем проверку прав на 'podr_tasks_my_edit'
                         $permissions_for_open_issue_modal_for_boss = \app\models\Permissions::find()->where('(SUBJECT_TYPE = :subject_type and SUBJECT_ID = :user_id and ACTION_ID = :action and DEL_TRACT_ID = :del_tract and PERM_LEVEL != :perm_level and PERM_TYPE = :perm_type)  or 
                                                                                         (SUBJECT_TYPE = :subject_type_dolg and SUBJECT_ID = :dolg_id and ACTION_ID = :action and DEL_TRACT_ID = :del_tract and PERM_LEVEL != :perm_level and PERM_TYPE = :perm_type)', ['subject_type_dolg' => 1, 'dolg_id' => \Yii::$app->session->get('user.user_iddolg'), 'perm_type' => 1, 'subject_type' => 2, 'user_id' => \Yii::$app->user->id, 'del_tract' => 0, 'perm_level' => 0, 'action' => 101])->one();
                         if ($permissions_for_open_issue_modal_for_boss) {
                             //пользователю разрешен просмотр и редактирование заданий своего подразделения
                             $user_in_persons_or_podr_list = true;
                         }
                     }
                 }
                 if ($user_in_persons_or_podr_list) {
                     //пользователь имеет доступ к заданию, так как входит в список исполнителей выбранного задания, либо находится в составе подразделей задания,
                     //либо является руководителем подразделений, указанных в задании
                     return true;
                 }
             } else {
                 return false;
             }
             break;
         case 'open_issue_modal_in_current_status':
             //проверка прав на просмотр задания (в модальном окне) в текущем статусе задания
             //получаем текущий статус задания для данного пользователя
             $current_status = self::_getCurrentTaskStatusForCurrentUser($task_id);
             if ($current_status != 'empty_status' && $current_status != 'user_not_in_persons_list') {
                 //проверяем есть ли доступ у пользователя к заданию в текущем статусе
                 $permissions_for_open_issue_modal_in_current_status = \app\models\Permissions::find()->where('(SUBJECT_TYPE = :subject_type and SUBJECT_ID = :user_id and DEL_TRACT_ID = :del_tract and PERM_LEVEL != :perm_level and ACTION_ID = :action and PERM_TYPE = :perm_type) or
                                                                                         (SUBJECT_TYPE = :subject_type_dolg and SUBJECT_ID = :id_dolg and DEL_TRACT_ID = :del_tract and PERM_LEVEL != :perm_level and ACTION_ID = :action and PERM_TYPE = :perm_type)', ['subject_type_dolg' => 1, 'id_dolg' => \Yii::$app->session->get('user.user_iddolg'), 'perm_type' => 2, 'subject_type' => 2, 'user_id' => \Yii::$app->user->id, 'del_tract' => 0, 'perm_level' => 0, 'action' => $current_status])->one();
                 if ($permissions_for_open_issue_modal_in_current_status) {
                     //досутп на просмотр в текущем статусе разрешен
                     return 'true';
                 } else {
                     $state = \app\models\States::findOne($current_status);
                     return 'У Вас нет прав на "Форма свойств задания" в статусе "' . $state->STATE_NAME . '"';
                 }
             } elseif ($current_status == 'empty_status') {
                 //устанавливаем статус "Принято при первом открытии задания"
                 $pers_tasks = \app\models\PersTasks::find()->where(['TASK_ID' => $task_id, 'TN' => \Yii::$app->user->id, 'DEL_TRACT_ID' => 0])->one();
                 $transactions = \app\models\Transactions::find()->where(['TN' => \Yii::$app->user->id])->orderBy('ID DESC')->one();
                 //пишем первый статус в БД
                 $task_states = new \app\models\TaskStates();
                 $task_states->TASK_ID = $task_id;
                 $task_states->STATE_ID = 1;
                 $task_states->TRACT_ID = $transactions->ID;
                 $task_states->IS_CURRENT = 1;
                 if ($pers_tasks->ID) {
                     // устанавливаем pers_tasks id
                     $task_states->PERS_TASKS_ID = $pers_tasks->ID;
                 }
                 $task_states->save();
                 //разрешаем пользователю смотреть информацию по заданию
                 return 'true';
             } elseif ($current_status == 'user_not_in_persons_list') {
                 //пользователь не стоит в списке исполнителей задания
                 //проверяем, если он руководитель показываем информацию по заданию (остальные пользователи сбда не попадут из-за проверки выше)
                 return 'true_for_boss';
             }
             break;
         case 'update_issue':
             //проверяем, есть ли доступ на редактирование задания для исполнителей
             $permissions_for_update_issue = \app\models\Permissions::find()->where('(SUBJECT_TYPE = :subject_type and SUBJECT_ID = :user_id and ACTION_ID = :action and DEL_TRACT_ID = :del_tract and PERM_LEVEL = :perm_level and PERM_TYPE = :perm_type)  or 
                                                                                     (SUBJECT_TYPE = :subject_type_dolg and SUBJECT_ID = :dolg_id and ACTION_ID = :action and DEL_TRACT_ID = :del_tract and PERM_LEVEL = :perm_level and PERM_TYPE = :perm_type)', ['subject_type_dolg' => 1, 'dolg_id' => \Yii::$app->session->get('user.user_iddolg'), 'perm_type' => 1, 'subject_type' => 2, 'user_id' => \Yii::$app->user->id, 'del_tract' => 0, 'perm_level' => 2, 'action' => 3])->one();
             //проверка доступа на редактирование для руководителей
             $permissions_for_update_issue_boss = \app\models\Permissions::find()->where('(SUBJECT_TYPE = :subject_type and SUBJECT_ID = :user_id and ACTION_ID = :action and DEL_TRACT_ID = :del_tract and PERM_LEVEL = :perm_level and PERM_TYPE = :perm_type)  or 
                                                                                     (SUBJECT_TYPE = :subject_type_dolg and SUBJECT_ID = :dolg_id and ACTION_ID = :action and DEL_TRACT_ID = :del_tract and PERM_LEVEL = :perm_level and PERM_TYPE = :perm_type)', ['subject_type_dolg' => 1, 'dolg_id' => \Yii::$app->session->get('user.user_iddolg'), 'perm_type' => 1, 'subject_type' => 2, 'user_id' => \Yii::$app->user->id, 'del_tract' => 0, 'perm_level' => 2, 'action' => 101])->one();
             //проверяем кто редактирует задание
             $pers_tasks = \app\models\PersTasks::find()->where(['TASK_ID' => $task_id, 'DEL_TRACT_ID' => 0])->all();
             if ($pers_tasks) {
                 // если существуют исполнители, то формируем их список
                 $persons_array = [];
                 foreach ($pers_tasks as $task) {
                     $query = new \yii\db\Query();
                     $query->select('*')->from('STIGIT.V_F_PERS')->where('TN = \'' . $task->TN . '\'');
                     $command = $query->createCommand();
                     $data = $command->queryOne();
                     $persons_array[] = $data['TN'];
                 }
                 //проверяем, входит ли пользователь в этот список
                 if (in_array(\Yii::$app->user->id, $persons_array)) {
                     //пользователь входит в список исполнителей
                     $user_is_person = 1;
                 } else {
                     $user_is_person = 0;
                 }
             }
             if ($permissions_for_update_issue && $user_is_person == 1) {
                 return 'update_issue_for_person';
             } elseif ($permissions_for_update_issue_boss && $user_is_person == 0) {
                 return 'update_issue_for_boss';
             } else {
                 return false;
             }
             break;
     }
 }
Esempio n. 15
0
 public function Transactionhistory($key = null)
 {
     if (!$this->request->data) {
         return $this->render(array('json' => array('success' => 0, 'now' => time(), 'error' => "Not submitted through POST.")));
     }
     if ($key == null) {
         return $this->render(array('json' => array('success' => 0, 'now' => time(), 'error' => "Key not specified. Please get your key from your settings page under security.")));
     } else {
         $details = Details::find('first', array('conditions' => array('key' => $key)));
         if (count($details) == 0) {
             return $this->render(array('json' => array('success' => 0, 'now' => time(), 'error' => "Incorrect Key! Please get your key from your settings page under security.")));
         } else {
             if (!$this->requestAPI("transactionhistory", $details['username'])) {
                 return $this->render(array('json' => array('success' => 0, 'now' => time(), 'error' => "Too many requests from your IP. Try after some time.")));
             }
             $count = $this->request->data['count'];
             if ($count == "") {
                 $count = 1000;
             }
             $currency = $this->request->data['currency'];
             if ($currency == "") {
                 $currency = 'All';
             }
             $order = $this->request->data['order'];
             if ($order == "") {
                 $order = 'DESC';
             }
             $start = $this->request->data['start'];
             if ($start == "") {
                 $start = '2013-10-01';
             }
             $end = $this->request->data['end'];
             if ($end == "") {
                 $currency = gmdate('Y-m-d', time());
             }
             $type = $this->request->data['type'];
             if ($type == "") {
                 $type = "All";
             }
             $StartDate = new MongoDate(strtotime($start));
             $EndDate = new MongoDate(strtotime($end));
             if ($type == "Deposit") {
                 $typeofTran = array(true);
             }
             if ($type == "Withdrawal") {
                 $typeofTran = array(false);
             }
             if ($type == "All") {
                 $typeofTran = array('$in' => array(true, false));
             } elseif ($type == "Deposit") {
                 $typeofTran = array('$in' => array(true));
             } elseif ($type == "Withdrawal") {
                 $typeofTran = array('$in' => array(false));
             }
             switch ($currency) {
                 case "All":
                     $currencyType = array('$in' => array('BTC', 'USD', 'GBP', 'EUR'));
                     break;
                 case "BTC":
                     $currencyType = array('$in' => array('BTC'));
                     break;
                 case "Other":
                     $currencyType = array('$in' => array('USD', 'GBP', 'EUR'));
                     break;
                 case "USD":
                     $currencyType = array('$in' => array('USD'));
                     break;
                 case "GBP":
                     $currencyType = array('$in' => array('GBP'));
                     break;
                 case "EUR":
                     $currencyType = array('$in' => array('EUR'));
                     break;
             }
             $conditions = array('username' => $details['username'], 'DateTime' => array('$gte' => $StartDate, '$lte' => $EndDate), 'Added' => $typeofTran, 'Currency' => $currencyType);
             $transactions = Transactions::find('all', array('conditions' => $conditions, 'limit' => $count, 'order' => array('Datetime' => $order)));
             $i = 0;
             foreach ($transactions as $tx) {
                 $result[$i]['DateTime'] = $tx['DateTime']->sec;
                 $result[$i]['Amount'] = $tx['Amount'];
                 $result[$i]['Currency'] = $tx['Currency'];
                 if ($tx['Added'] == true) {
                     $result[$i]['Type'] = "Deposit";
                 } else {
                     $result[$i]['Type'] = "Withdrawal";
                 }
                 if ($tx['Currency'] != "BTC") {
                     $result[$i]['Approved'] = $tx['Approved'];
                     $result[$i]['Reference'] = $tx['Reference'];
                     if ($tx['Approved'] == "Rejected") {
                         $result[$i]['Reason'] = $tx['Reason'];
                     }
                     if ($tx['Approved'] == "Yes") {
                         $result[$i]['AmountApproved'] = $tx['AmountApproved'];
                     }
                 } else {
                     $result[$i]['TransactionHash'] = $tx['TransactionHash'];
                     $result[$i]['Address'] = $tx['address'];
                     if ($tx['Added'] == false) {
                         $result[$i]['txFee'] = $tx['txFee'];
                         $result[$i]['Transfer'] = $tx['Transfer'];
                     }
                 }
                 $i++;
             }
             return $this->render(array('json' => array('success' => 1, 'now' => time(), 'result' => $result)));
         }
     }
 }
Esempio n. 16
0
 public function greencointransaction()
 {
     if ($this->__init() == false) {
         $this->redirect('ex::dashboard');
     }
     if ($this->request->data) {
         $StartDate = new MongoDate(strtotime($this->request->data['StartDate']));
         $EndDate = new MongoDate(strtotime($this->request->data['EndDate']));
     } else {
         $StartDate = new MongoDate(strtotime(gmdate('Y-m-d H:i:s', mktime(0, 0, 0, gmdate('m', time()), gmdate('d', time()), gmdate('Y', time())) - 60 * 60 * 24 * 30)));
         $EndDate = new MongoDate(strtotime(gmdate('Y-m-d H:i:s', mktime(0, 0, 0, gmdate('m', time()), gmdate('d', time()), gmdate('Y', time())) + 60 * 60 * 24 * 1)));
     }
     $transactions = Transactions::find('all', array('conditions' => array('Currency' => 'XGC', 'DateTime' => array('$gte' => $StartDate, '$lte' => $EndDate)), 'order' => array('DateTime' => -1)));
     $title = "Greencoin Transactions";
     $keywords = "Greencoin Transactions";
     $description = "Admin panel for Litecoin transactions";
     return compact('transactions', 'StartDate', 'EndDate', 'title', 'keywords', 'description');
 }
Esempio n. 17
0
<?php

use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
use app\assets\AppAsset;
use yii\web\View;
use yii\helpers\Url;
$transactions = \app\models\Transactions::find()->where(['TN' => \Yii::$app->user->id])->orderBy('ID DESC')->one();
/* @var $this \yii\web\View */
/* @var $content string */
AppAsset::register($this);
$this->beginPage();
?>
<!DOCTYPE html>
<html lang="<?php 
echo Yii::$app->language;
?>
">
<head>
    <meta charset="<?php 
echo Yii::$app->charset;
?>
">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <?php 
echo Html::csrfMetaTags();
?>
    <title><?php 
echo Html::encode($this->title);
Esempio n. 18
0
 public function make($cid)
 {
     $this->id = rand(0, 999999);
     //$this->iniArr=array('b110'=>0,'b100'=>0,'m100'=>0,'c100'=>0,'d100'=>0,'d110'=>0,'d120'=>0,);
     //$this->docArr=array(0=>0,305=>0,300=>0,);
     $bkmv = '';
     //$this->line=1;
     //$yiidatetimesec=Yii::$app->locale->getDateFormat('yiidatetimesec');
     //$phpdbdatetime=Yii::$app->locale->getDateFormat('phpdbdatetime');
     $from_date = $this->from_date . " 00:00:00";
     $to_date = $this->to_date . " 23:59:59";
     //$types=array(3,4,9,11,13,14);
     //accounts
     $accounts = Accounts::find()->All();
     $record = array('id' => 'B110', 'name' => OpenFormatType::getDesc('B110'), 'count' => 0);
     foreach ($accounts as $account) {
         $this->line++;
         $bkmv .= $account->openfrmt($this->line, $from_date, $to_date);
         $record['count']++;
     }
     $this->iniArr[] = $record;
     //items
     $items = Item::find()->All();
     $record = array('id' => 'M100', 'name' => OpenFormatType::getDesc('M100'), 'count' => 0);
     foreach ($items as $item) {
         $this->line++;
         $bkmv .= $item->openfrmt($this->line, $from_date, $to_date);
         $record['count']++;
     }
     $this->iniArr[] = $record;
     //
     //transactions
     $transactions = Transactions::find()->where(['BETWEEN', 'valuedate', $from_date, $to_date])->All();
     $record = array('id' => 'B100', 'name' => OpenFormatType::getDesc('B100'), 'count' => 0);
     foreach ($transactions as $transaction) {
         $this->line++;
         $bkmv .= $transaction->openfrmt($this->line, $from_date, $to_date);
         $record['count']++;
     }
     $this->iniArr[] = $record;
     //docs
     $docs = Docs::find()->where(['BETWEEN', 'due_date', $from_date, $to_date])->All();
     //OpenFormatType::getDesc('C100')
     $record = array('id' => 'C100', 'name' => OpenFormatType::getDesc('C100'), 'count' => 0);
     $d110 = array('id' => 'D110', 'name' => OpenFormatType::getDesc('D110'), 'count' => 0);
     $d120 = array('id' => 'D120', 'name' => OpenFormatType::getDesc('D120'), 'count' => 0);
     foreach ($docs as $doc) {
         if ($doc->docType->openformat != '0') {
             $this->line++;
             $bkmv .= $doc->openfrmt($this->line, $from_date, $to_date);
             foreach ($doc->docDetailes as $detial) {
                 $this->line++;
                 $bkmv .= $detial->openfrmt($this->line, $from_date, $to_date);
                 $d110['count']++;
             }
             foreach ($doc->docCheques as $detial) {
                 $this->line++;
                 $bkmv .= $detial->openfrmt($this->line, $from_date, $to_date);
                 $d120['count']++;
             }
             $type = $doc->OpenfrmtType();
             $this->docArr[$type] = isset($this->docArr[$type]) ? $this->docArr[$type] + 1 : 0;
             $this->docSumArr[$type] = isset($this->docSumArr[$type]) ? $this->docSumArr[$type] + $doc->total : $doc->total;
             $record['count']++;
         }
     }
     $this->iniArr[] = $record;
     $this->iniArr[] = $d110;
     $this->iniArr[] = $d120;
     $company = \app\models\Settings::findOne(['company.name']);
     //A100
     $bkmv = $company->a100(1, $this->id, $from_date, $to_date) . $bkmv;
     //Z900
     $bkmv = $bkmv . $company->z900($this->line + 1, $this->id, $this->line + 1);
     $bkmvFile = new Files();
     $bkmvFile->name = 'bkmvdata.txt';
     $bkmvFile->path = 'openformat/';
     //
     $bkmvFile->expire = 360;
     $bkmvFile->save();
     $bkmvFile->writeFile($bkmv);
     $this->bkmvId = $bkmvFile->id;
     //A000
     $ini = $company->a000(1, $this->id, $this->line + 1, $from_date, $to_date);
     foreach ($this->iniArr as $line) {
         $ini .= $line['id'] . sprintf("%015d", $line['count']) . "\r\n";
     }
     //Z
     $iniFile = new Files();
     $iniFile->name = 'ini.txt';
     $iniFile->path = 'openformat/';
     //
     $iniFile->expire = 360;
     $iniFile->save();
     $iniFile->writeFile($ini);
     $this->iniId = $iniFile->id;
     return $this->id;
 }