Ejemplo n.º 1
0
 public function MaxNumberSpis($attribute)
 {
     if (!empty($this->id_mattraffic)) {
         $currentMattraffic = Mattraffic::findOne($this->id_mattraffic);
         $query = Mattraffic::find()->join('LEFT JOIN', '(select id_material as id_material_m2, id_mol as id_mol_m2, mattraffic_date as mattraffic_date_m2, mattraffic_tip as mattraffic_tip_m2 from mattraffic) m2', 'mattraffic.id_material = m2.id_material_m2 and mattraffic.id_mol = m2.id_mol_m2 and mattraffic.mattraffic_date < m2.mattraffic_date_m2 and m2.mattraffic_tip_m2 in (1,2)')->andWhere(['id_material' => $currentMattraffic->id_material, 'id_mol' => $currentMattraffic->id_mol])->andWhere(['in', 'mattraffic_tip', [1, 2]])->andWhere(['m2.mattraffic_date_m2' => NULL])->one();
         if (!empty($query) && $this->spisosnovmaterials_number > $query->mattraffic_number) {
             $this->addError($attribute, 'Количество не может превышать ' . $query->mattraffic_number);
         }
     }
 }
Ejemplo n.º 2
0
 public function MaxNumberMove($attribute)
 {
     if (!empty($this->id_mattraffic)) {
         $query = Mattraffic::find()->andWhere(['mattraffic_id' => $this->id_mattraffic])->one();
         if ($query->mattraffic_number == 0 && in_array($query->idMaterial->material_tip, [2, 3])) {
             $query->mattraffic_number++;
         }
         if (!empty($query) && $this->mattraffic_number > $query->mattraffic_number) {
             $this->addError($attribute, 'Количество не может превышать ' . $query->mattraffic_number);
         }
     }
 }
Ejemplo n.º 3
0
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $Mattraffic = Mattraffic::find()->andWhere(['id_material' => $model->material_id])->andWhere(['in', 'mattraffic_tip', [1, 2]])->orderBy('mattraffic_date desc, mattraffic_id desc')->one();
     $searchModel_mattraffic = new MattrafficSearch();
     $dataProvider_mattraffic = $searchModel_mattraffic->searchformaterialmattraffic(Yii::$app->request->queryParams);
     $searchModel_recovery = new OsmotraktSearch();
     $dataProvider_recovery = $searchModel_recovery->searchformaterialkarta(Yii::$app->request->queryParams);
     $searchModel_recoverymat = new TrMatOsmotrSearch();
     $dataProvider_recoverymat = $searchModel_recoverymat->searchformaterialkarta(Yii::$app->request->queryParams);
     $searchModel_recoverysend = new RecoveryrecieveaktSearch();
     $dataProvider_recoverysend = $searchModel_recoverysend->searchformaterialkarta(Yii::$app->request->queryParams);
     $searchModel_recoverysendmat = new RecoveryrecieveaktmatSearch();
     $dataProvider_recoverysendmat = $searchModel_recoverysendmat->searchformaterialkarta(Yii::$app->request->queryParams);
     $searchModel_mattraffic_contain = new TrMatSearch();
     $dataProvider_mattraffic_contain = $searchModel_mattraffic_contain->searchformaterialcontain(Yii::$app->request->queryParams);
     if (Yii::$app->user->can('MaterialEdit') && $model->load(Yii::$app->request->post()) && $model->save() && $Mattraffic->load(Yii::$app->request->post()) && $Mattraffic->save()) {
         return $this->redirect(Proc::GetPreviousURLBreadcrumbsFromSession());
     } else {
         return $this->render('update', ['model' => $model, 'Mattraffic' => $Mattraffic, 'searchModel_mattraffic' => $searchModel_mattraffic, 'dataProvider_mattraffic' => $dataProvider_mattraffic, 'searchModel_recovery' => $searchModel_recovery, 'dataProvider_recovery' => $dataProvider_recovery, 'searchModel_recoverymat' => $searchModel_recoverymat, 'dataProvider_recoverymat' => $dataProvider_recoverymat, 'searchModel_recoverysend' => $searchModel_recoverysend, 'dataProvider_recoverysend' => $dataProvider_recoverysend, 'searchModel_recoverysendmat' => $searchModel_recoverysendmat, 'dataProvider_recoverysendmat' => $dataProvider_recoverysendmat, 'searchModel_mattraffic_contain' => $searchModel_mattraffic_contain, 'dataProvider_mattraffic_contain' => $dataProvider_mattraffic_contain]);
     }
 }
Ejemplo n.º 4
0
    public function actionImportRemont()
    {
        header('Content-Type: text/html');
        try {
            $conn = new \PDO('mysql:host=127.0.0.1;dbname=remont;charset=UTF8', 'root', '265463');
            $sql = 'SELECT akt.akt_id,
	pol.pol_name,
	obor.obor_name,
	akt.akt_inv,
	akttext.akttext_name,
	aktuser.aktuser_name,
	prog.aktuser_name AS prog_name,
	akt.akt_kab,
	akt.akt_date,
	akt.akt_serial,
	akt.akt_closedate,
	akt.akt_datesend
FROM akt
INNER JOIN akttext ON akt.id_akttext = akttext.akttext_id
INNER JOIN obor ON akt.id_obor = obor.obor_id
INNER JOIN pol ON akt.id_pol = pol.pol_id
INNER JOIN aktuser ON akt.id_aktuser = aktuser.aktuser_id
INNER JOIN aktuser prog ON akt.id_prog = prog.aktuser_id';
            $fail = 0;
            $succ = 0;
            // Prepare
            /*     $Employee = \app\models\Fregat\Employee::find()
                   ->joinWith([
                   'idperson' => function($query) {
                   $query->from(['idperson' => 'auth_user']);
                   }
                   ])
                   ->andWhere(['like', 'idperson.auth_user_fullname', 'ЧЕПЕНКО АЛЕКСЕЙ ВЛАДИМИРОВИЧ'])
                   ->one();
                   $Employee->id_build = 2;
                   $Employee->save(); */
            $Employee = \app\models\Fregat\Employee::find()->joinWith(['idperson'])->andWhere(['like', 'idperson.auth_user_fullname', 'БАЙТИНГЕР АНАСТАСИЯ ВЛАДИМИРОВНА'])->all();
            foreach ($Employee as $ar) {
                \app\models\Fregat\Employee::updateAll(['id_build' => 1], ['employee_id' => $ar->employee_id]);
            }
            $Organ = new \app\models\Fregat\Organ();
            $Organ->organ_name = 'ООО "Северная линия"';
            $Organ->save();
            $Organ = new \app\models\Fregat\Organ();
            $Organ->organ_name = 'ООО «Копи-Мастер»';
            $Organ->organ_email = '*****@*****.**';
            $Organ->organ_phones = '8(3466)31-02-09';
            $Organ->save();
            $Reason = new Reason();
            $Reason->reason_text = 'Требуется замена термопленки';
            $Reason->save();
            $Reason = new Reason();
            $Reason->reason_text = 'Требуется замена аккумулятора';
            $Reason->save();
            $Reason = new Reason();
            $Reason->reason_text = 'Требуется замена резинового вала';
            $Reason->save();
            $Reason = new Reason();
            $Reason->reason_text = 'Требуется замена фотобарабана';
            $Reason->save();
            $Reason = new Reason();
            $Reason->reason_text = 'Требуется ремонт печки';
            $Reason->save();
            $Reason = new Reason();
            $Reason->reason_text = 'Неисправен податчик бумаги';
            $Reason->save();
            $Reason = new Reason();
            $Reason->reason_text = 'Требуется замена инвертора подсветки матрицы';
            $Reason->save();
            $Reason = new Reason();
            $Reason->reason_text = 'Выводит на печать чистые листы';
            $Reason->save();
            $Reason = new Reason();
            $Reason->reason_text = 'Не определяет наличие бумаги в лотке';
            $Reason->save();
            $Reason = new Reason();
            $Reason->reason_text = 'Требуется заправка';
            $Reason->save();
            $Authuser = Authuser::findOne(1);
            //admin
            $Authuser->scenario = 'Changepassword';
            $Authuser->auth_user_password = '******';
            $Authuser->auth_user_password2 = '265463';
            $Authuser->save();
            $Authuser = Authuser::find()->andWhere(['in', 'auth_user_id', [989, 986, 987, 984, 988, 985, 1020]])->all();
            foreach ($Authuser as $ar) {
                $ar2 = Authuser::findOne($ar->primaryKey);
                $ar2->scenario = 'Changepassword';
                $ar2->auth_user_password = '******';
                $ar2->auth_user_password2 = '265463';
                $ar2->save();
                $auth = Yii::$app->authManager;
                if (!$auth->checkAccess($ar->primaryKey, 'Administrator')) {
                    $Role = $auth->getRole('Administrator');
                    $auth->assign($Role, $ar->primaryKey);
                }
            }
            $Hos = Authuser::find()->andWhere(['in', 'auth_user_id', [384, 489, 590, 614, 744, 466, 755, 614]])->all();
            foreach ($Hos as $ar) {
                $ar2 = Authuser::findOne($ar->primaryKey);
                $ar2->scenario = 'Changepassword';
                $ar2->auth_user_password = '******';
                $ar2->auth_user_password2 = '44444444';
                $ar2->save();
                $auth = Yii::$app->authManager;
                if (!$auth->checkAccess($ar->primaryKey, 'FregatHozSister')) {
                    $Role = $auth->getRole('FregatHozSister');
                    $auth->assign($Role, $ar->primaryKey);
                }
            }
            $querybuild = Build::find()->andWhere(['like', 'build_name', 'Административный корпус'])->one();
            if (empty($querybuild)) {
                $Build = new Build();
                $Build->build_name = 'Административный корпус';
                $Build->save();
            }
            // Prepare end
            foreach ($conn->query($sql, \PDO::FETCH_ASSOC) as $row) {
                //  var_dump($row);
                $mes = '<BR>' . 'akt №' . $row['akt_id'] . ' от ' . Yii::$app->formatter->asDate($row['akt_date']) . ' (Дата закрытия: ' . Yii::$app->formatter->asDate($row['akt_closedate']) . ')';
                $ok = false;
                $fail++;
                $mattraffic = \app\models\Fregat\Mattraffic::find()->joinWith(['idMaterial'])->join('LEFT JOIN', '(select id_material as id_material_m2, id_mol as id_mol_m2, mattraffic_date as mattraffic_date_m2, mattraffic_tip as mattraffic_tip_m2 from mattraffic) m2', 'mattraffic.id_material = m2.id_material_m2 and mattraffic.id_mol = m2.id_mol_m2 and mattraffic.mattraffic_date < m2.mattraffic_date_m2 and m2.mattraffic_tip_m2 in (1,2)')->andWhere(['in', 'mattraffic_tip', [1, 2]])->andWhere(['m2.mattraffic_date_m2' => NULL])->andWhere(['like', 'idMaterial.material_inv', $row['akt_inv'], false])->all();
                if (count($mattraffic) >= 2) {
                    $mattraffic = \app\models\Fregat\Mattraffic::find()->joinWith(['idMaterial'])->join('LEFT JOIN', '(select id_material as id_material_m2, id_mol as id_mol_m2, mattraffic_date as mattraffic_date_m2, mattraffic_tip as mattraffic_tip_m2 from mattraffic) m2', 'mattraffic.id_material = m2.id_material_m2 and mattraffic.id_mol = m2.id_mol_m2 and mattraffic.mattraffic_date < m2.mattraffic_date_m2 and m2.mattraffic_tip_m2 in (1,2)')->andWhere(['in', 'mattraffic_tip', [1, 2]])->andWhere(['m2.mattraffic_date_m2' => NULL])->andWhere(['idMaterial.material_tip' => 1])->andWhere(['like', 'idMaterial.material_inv', $row['akt_inv'], false])->all();
                }
                //  var_dump(count($mattraffic));
                if (count($mattraffic) == 1) {
                    $mes .= '<BR>' . $mattraffic[0]->idMaterial->material_name . ' inv=' . $mattraffic[0]->idMaterial->material_inv;
                    if ($mattraffic[0]->idMol->idbuild->build_name !== mb_strtoupper($row['pol_name'], 'UTF-8')) {
                        $mes .= '<BR>' . 'Build Problem: ' . $mattraffic[0]->idMol->idbuild->build_name . ' <> ' . mb_strtoupper($row['pol_name'], 'UTF-8');
                        /*   $Employee = \app\models\Fregat\Employee::find($mattraffic[0]->id_mol)->one();
                             $Employee_new = new \app\models\Fregat\Employee;
                             $Employee_new->attributes = $Employee->attributes;
                             $Employee_new->id_build = Build::find()->andWhere(['like', 'build_name', $row['pol_name']])->one()->build_id;
                             if (!$Employee_new->save())
                             $mes.='<BR>' . print_r($Employee_new->errors, true); */
                    } else {
                        $installer = \app\models\Fregat\Employee::find()->joinWith(['idperson', 'iddolzh', 'idpodraz', 'idbuild'])->andWhere(['like', 'idperson.auth_user_fullname', $row['prog_name']])->all();
                        $mes .= '<BR>' . 'instcount = ' . count($installer);
                        if (count($installer) == 0) {
                            $mes .= '<BR>' . $row['prog_name'] . ' not found';
                        } else {
                            if (count($installer) > 1) {
                                foreach ($installer as $ar) {
                                    $mes .= '<BR>' . $ar->idperson->auth_user_fullname . ' dolzh=' . $ar->iddolzh->dolzh_name;
                                }
                            } else {
                                if (count($installer) == 1) {
                                    $mes .= '<BR>' . $installer[0]->idperson->auth_user_fullname . ' dolzh=' . $installer[0]->iddolzh->dolzh_name;
                                    $transaction = Yii::$app->db->beginTransaction();
                                    try {
                                        $installakt = new \app\models\Fregat\Installakt();
                                        $installakt->installakt_date = substr($row['akt_date'], 0, 10);
                                        $installakt->id_installer = $installer[0]->primaryKey;
                                        if (!$installakt->save()) {
                                            $mes .= '<BR>' . print_r($installakt->errors, true);
                                            $transaction->rollBack();
                                        } else {
                                            $Mattraffic_tr = new \app\models\Fregat\Mattraffic();
                                            $Mattraffic_tr->attributes = $mattraffic[0]->attributes;
                                            $Mattraffic_tr->mattraffic_date = date('Y-m-d');
                                            $Mattraffic_tr->mattraffic_number = 1;
                                            $Mattraffic_tr->mattraffic_tip = 3;
                                            if ($Mattraffic_tr->validate()) {
                                                $Mattraffic_tr->save(false);
                                                $trosnov = new \app\models\Fregat\TrOsnov();
                                                $trosnov->id_installakt = $installakt->primaryKey;
                                                $trosnov->id_mattraffic = $Mattraffic_tr->primaryKey;
                                                $trosnov->tr_osnov_kab = $row['akt_kab'];
                                                if (!$trosnov->save()) {
                                                    $mes .= '<BR>' . print_r($trosnov->errors);
                                                    $transaction->rollBack();
                                                } else {
                                                    $mes .= '<BR>' . 'aktinstall saved';
                                                    $user = \app\models\Fregat\Employee::find()->joinWith(['idperson', 'iddolzh', 'idpodraz', 'idbuild'])->andWhere(['like', 'idperson.auth_user_fullname', $row['aktuser_name']])->all();
                                                    $mes .= '<BR>' . 'usercount = ' . count($user);
                                                    if (count($user) == 0) {
                                                        $mes .= '<BR>' . $row['aktuser_name'] . ' not found';
                                                        $transaction->rollBack();
                                                    } else {
                                                        if (count($user) >= 1) {
                                                            if (count($user) > 1) {
                                                                foreach ($user as $ar) {
                                                                    $mes .= '<BR>' . $ar->idperson->auth_user_fullname . ' dolzh=' . $ar->iddolzh->dolzh_name;
                                                                }
                                                            }
                                                            $osmotrakt = new \app\models\Fregat\Osmotrakt();
                                                            $osmotrakt->osmotrakt_id = $row['akt_id'];
                                                            $osmotrakt->osmotrakt_comment = $row['akttext_name'];
                                                            $osmotrakt->osmotrakt_date = substr($row['akt_date'], 0, 10);
                                                            $osmotrakt->id_master = $installer[0]->primaryKey;
                                                            $osmotrakt->id_user = $user[0]->primaryKey;
                                                            $osmotrakt->id_tr_osnov = $trosnov->primaryKey;
                                                            if (!$osmotrakt->save()) {
                                                                $mes .= '<BR>' . print_r($osmotrakt->errors);
                                                                $transaction->rollBack();
                                                            } else {
                                                                $mes .= '<BR>' . 'osmotrakt saved';
                                                                if (!empty($row['akt_closedate'])) {
                                                                    $Recoverysendakt = new \app\models\Fregat\Recoverysendakt();
                                                                    $organname = 'Северная линия';
                                                                    if (strtotime($row['akt_closedate']) >= strtotime('2016-05-04')) {
                                                                        $organname = 'Копи-Мастер';
                                                                    }
                                                                    $Organ = \app\models\Fregat\Organ::find()->andWhere(['like', 'organ_name', $organname])->one();
                                                                    $Recoverysendakt->id_organ = $Organ->PrimaryKey;
                                                                    $Recoverysendakt->recoverysendakt_date = substr($row['akt_closedate'], 0, 10);
                                                                    if (!$Recoverysendakt->save()) {
                                                                        $mes .= '<BR>' . print_r($Recoverysendakt->errors, true);
                                                                        $transaction->rollBack();
                                                                    } else {
                                                                        $Recoveryrecieveakt = new \app\models\Fregat\Recoveryrecieveakt();
                                                                        $Recoveryrecieveakt->id_osmotrakt = $osmotrakt->primaryKey;
                                                                        $Recoveryrecieveakt->id_recoverysendakt = $Recoverysendakt->primaryKey;
                                                                        $Recoveryrecieveakt->recoveryrecieveakt_result = 'Импортировано из старой программы';
                                                                        $Recoveryrecieveakt->recoveryrecieveakt_repaired = mb_stripos($row['obor_name'], 'ИБП', 0, 'UTF-8') === false ? 2 : 1;
                                                                        $Recoveryrecieveakt->recoveryrecieveakt_date = substr($row['akt_closedate'], 0, 10);
                                                                        if (!$Recoveryrecieveakt->save()) {
                                                                            $mes .= '<BR>' . print_r($Recoveryrecieveakt->errors, true);
                                                                            $transaction->rollBack();
                                                                        } else {
                                                                            $mes .= '<BR>' . 'Recoveryrecieveakt saved';
                                                                            $ok = true;
                                                                            $transaction->commit();
                                                                            $succ++;
                                                                            $fail--;
                                                                        }
                                                                    }
                                                                } else {
                                                                    $ok = true;
                                                                    $transaction->commit();
                                                                    $succ++;
                                                                    $fail--;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            } else {
                                                $mes .= '<BR>' . print_r($Mattraffic_tr->errors);
                                                $transaction->rollBack();
                                            }
                                        }
                                    } catch (Exception $e) {
                                        $transaction->rollBack();
                                        throw new Exception($e->getMessage());
                                    }
                                }
                            }
                        }
                    }
                } else {
                    if (count($mattraffic) == 0) {
                        $mes .= '<BR>' . $row['akt_inv'] . ' not found';
                    } else {
                        if (count($mattraffic) > 1) {
                            foreach ($mattraffic as $ar) {
                                $mes .= '<BR>' . $ar->idMaterial->material_name . ' inv=' . $ar->idMaterial->material_inv;
                            }
                        }
                    }
                }
                $mes .= '<BR>' . '------------------------------------------------------------------';
                if (!$ok) {
                    echo $mes;
                }
            }
            var_dump('success = ' . $succ . ' (' . round($succ * 100 / ($succ + $fail), 2) . '%), fail = ' . $fail . ' from ' . ($succ + $fail));
        } catch (PDOException $e) {
            die('Подключение не удалось: ' . $e->getMessage());
        }
    }
Ejemplo n.º 5
0
 public function searchforspisosnovakt($params)
 {
     $query = Mattraffic::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['mattraffic_date' => SORT_DESC, 'mattraffic_id' => SORT_DESC]]]);
     $query->join('LEFT JOIN', '(select id_material as id_material_m2, id_mol as id_mol_m2, mattraffic_date as mattraffic_date_m2, mattraffic_tip as mattraffic_tip_m2 from mattraffic) m2', 'mattraffic.id_material = m2.id_material_m2 and mattraffic.id_mol = m2.id_mol_m2 and mattraffic.mattraffic_date < m2.mattraffic_date_m2 and m2.mattraffic_tip_m2 in (1,2)');
     $this->baseRelations($query);
     $query->andWhere('(mattraffic_number > 0 and idMaterial.material_tip in (1,3))')->andWhere(['in', 'mattraffic_tip', [1]])->andWhere(['m2.mattraffic_date_m2' => NULL, 'idMaterial.material_writeoff' => 0]);
     $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;
     }
     $this->baseFilter($query);
     $this->baseSort($dataProvider);
     return $dataProvider;
 }
Ejemplo n.º 6
0
 private static function MaterialSpisanie()
 {
     $transaction = Yii::$app->db->beginTransaction();
     try {
         $Typemat = self::IsFileType(self::mat) ? 2 : 3;
         $SP = Mattraffic::find()->from(['m1' => 'mattraffic'])->join('LEFT JOIN', 'material', 'm1.id_material = material.material_id')->join('LEFT JOIN', 'mattraffic m2', 'm1.id_material = m2.id_material and m1.id_mol = m2.id_mol and m1.mattraffic_date < m2.mattraffic_date and m1.mattraffic_tip in (1,2) and m2.mattraffic_tip in (1,2)')->andWhere(['m1.mattraffic_forimport' => NULL, 'material_writeoff' => 0])->andWhere(['in', 'material_tip', [$Typemat]])->andWhere(['in', 'm1.mattraffic_tip', [1, 2]])->andWhere(['m1.mattraffic_tip' => 1])->andWhere(['m2.mattraffic_date' => NULL])->all();
         if (!empty($SP)) {
             foreach ($SP as $i => $ar) {
                 $spismat = self::SpisatMaterial($ar->id_material, $ar->id_mol);
                 $Mattraffic = new Mattraffic();
                 $Mattraffic->attributes = $ar->attributes;
                 $Mattraffic->mattraffic_date = date('Y-m-d');
                 $Mattraffic->mattraffic_number = 0;
                 $Mattraffic->mattraffic_tip = 2;
                 // Списание
                 if (isset($Mattraffic->scenarios()['import1c'])) {
                     $Mattraffic->scenario = 'import1c';
                 }
                 $Mattraffic->save(false);
                 $writeoffakt = new Writeoffakt();
                 $writeoffakt->id_mattraffic = $Mattraffic->mattraffic_id;
                 $writeoffakt->save(false);
                 $Material = Material::findOne($ar->id_material);
                 $Matlog = new Matlog();
                 $Matlog->attributes = $Material->attributes;
                 $Matlog->id_logreport = self::$logreport_id;
                 $Matlog->matlog_filename = self::$filename;
                 $Matlog->matlog_filelastdate = self::$filelastdate;
                 $Matlog->matlog_rownum = 0;
                 $Matlog->matlog_type = $spismat ? 4 : 2;
                 $Matlog->matlog_message = $spismat ? 'Материал списан. ' : 'Запись не изменялась. ';
                 $Matlog->matvid_name = self::GetNameByID('matvid', 'matvid_name', $Material->id_matvid);
                 $Matlog->izmer_name = self::GetNameByID('izmer', 'izmer_name', $Material->id_izmer);
                 $Matlog->schetuchet_kod = Schetuchet::findOne($Material->id_schetuchet)->schetuchet_kod;
                 $Matlog->schetuchet_name = Schetuchet::findOne($Material->id_schetuchet)->schetuchet_name;
                 $Matlog->material_writeoff = $Material->material_writeoff === 1 ? 'Да' : 'Нет';
                 $Matlog->material_release = isset($Material->material_release) ? Yii::$app->formatter->asDate($Material->material_release) : $Material->material_release;
                 $Matlog->save(false);
                 $Employee = Employee::find()->joinWith(['idperson', 'iddolzh', 'idpodraz', 'idbuild'])->where(['employee_id' => $ar->id_mol])->one();
                 $Employeelog = new Employeelog();
                 $Employeelog->attributes = $Employee->attributes;
                 $Employeelog->id_logreport = self::$logreport_id;
                 $Employeelog->employeelog_filename = self::$filename;
                 $Employeelog->employeelog_filelastdate = self::$filelastdate;
                 $Employeelog->employeelog_rownum = 0;
                 $Employeelog->employeelog_type = 2;
                 $Employeelog->employeelog_message = 'Запись не изменилась';
                 $Employeelog->employee_fio = $Employee->idperson->auth_user_fullname;
                 $Employeelog->dolzh_name = $Employee->iddolzh->dolzh_name;
                 $Employeelog->podraz_name = $Employee->idpodraz->podraz_name;
                 $Employeelog->build_name = $Employee->isRelationPopulated('idbuild') ? $Employee->idbuild['build_name'] : '';
                 $Employeelog->save(false);
                 $Traflog = new Traflog();
                 $Traflog->id_logreport = self::$logreport_id;
                 $Traflog->traflog_type = 1;
                 $Traflog->traflog_filename = self::$filename;
                 $Traflog->traflog_rownum = 0;
                 $Traflog->traflog_message = '';
                 $Traflog->id_matlog = $Matlog->primaryKey;
                 $Traflog->id_employeelog = $Employeelog->primaryKey;
                 $Traflog->traflog_message = 'Запись добавлена. Добавлен акт списания с номером "' . $writeoffakt->writeoffakt_id . '" на дату "' . date('d.m.Y', strtotime($Mattraffic->mattraffic_date)) . '".';
                 $Traflog->mattraffic_number = $ar->mattraffic_number;
                 $Traflog->save(false);
                 self::$logreport_additions++;
             }
         }
         Mattraffic::updateAll(['mattraffic_forimport' => NULL], ['mattraffic_forimport' => 1]);
         $transaction->commit();
     } catch (Exception $e) {
         $transaction->rollBack();
         Mattraffic::updateAll(['mattraffic_forimport' => NULL], ['mattraffic_forimport' => 1]);
         throw new Exception($e->getMessage() . ' MaterialSpisanie(), $filename = ' . self::$filename);
     }
 }
Ejemplo n.º 7
0
 public static function GetSumMattraffic_Number($mattraffic_id)
 {
     $mattraffic = self::findOne($mattraffic_id);
     $SumMN = Mattraffic::find()->leftJoin('mattraffic mt', 'mt.id_material = mattraffic.id_material and mt.id_mol = mattraffic.id_mol and mattraffic.mattraffic_tip in (1,2) and mattraffic.mattraffic_date < mt.mattraffic_date')->joinWith('idMaterial')->andWhere(['mattraffic.id_material' => $mattraffic->id_material, 'mt.mattraffic_id' => NULL])->andWhere(['in', 'mattraffic.mattraffic_tip', [1, 2]])->sum('mattraffic.mattraffic_number');
     return $SumMN;
 }