private function recoverysendaktDopFilter(&$query)
 {
     $filter = Proc::GetFilter($this->formName(), 'RecoverysendaktFilter');
     if (!empty($filter)) {
         $attr = 'mat_id_material';
         Proc::Filter_Compare(Proc::Strict, $query, $filter, ['Attribute' => $attr, 'SQLAttribute' => 'idMattraffic.id_material', 'ExistsSubQuery' => (new Query())->select('recoveryrecieveakts.id_recoverysendakt')->from('recoveryrecieveakt recoveryrecieveakts')->leftJoin('osmotrakt idOsmotrakt', 'idOsmotrakt.osmotrakt_id = recoveryrecieveakts.id_osmotrakt')->leftJoin('tr_osnov idTrosnov', 'idOsmotrakt.id_tr_osnov = idTrosnov.tr_osnov_id')->leftJoin('mattraffic idMattraffic', 'idMattraffic.mattraffic_id = idTrosnov.id_mattraffic')->andWhere('recoveryrecieveakts.id_recoverysendakt = recoverysendakt.recoverysendakt_id')]);
         $attr = 'recoverysendakt_closed_mark';
         if ($filter[$attr] === '1') {
             Proc::Filter_Compare(Proc::WhereStatement, $query, $filter, ['Attribute' => $attr, 'WhereStatement' => ['not exists', (new Query())->select('rsa.recoverysendakt_id')->from('recoverysendakt rsa')->leftJoin('recoveryrecieveakt rra', 'rsa.recoverysendakt_id = rra.id_recoverysendakt')->leftJoin('recoveryrecieveaktmat rramat', 'rsa.recoverysendakt_id = rramat.id_recoverysendakt')->andWhere(['rra.recoveryrecieveakt_repaired' => NULL])->andWhere(['rramat.recoveryrecieveaktmat_repaired' => NULL])->andWhere('rsa.recoverysendakt_id = recoverysendakt.recoverysendakt_id')]]);
         }
         $attr = 'recoverysendakt_opened_mark';
         if ($filter[$attr] === '1') {
             Proc::Filter_Compare(Proc::WhereStatement, $query, $filter, ['Attribute' => $attr, 'WhereStatement' => ['exists', (new Query())->select('rsa.recoverysendakt_id')->from('recoverysendakt rsa')->leftJoin('recoveryrecieveakt rra', 'rsa.recoverysendakt_id = rra.id_recoverysendakt')->leftJoin('recoveryrecieveaktmat rramat', 'rsa.recoverysendakt_id = rramat.id_recoverysendakt')->andWhere(['rra.recoveryrecieveakt_repaired' => NULL])->andWhere(['rramat.recoveryrecieveaktmat_repaired' => NULL])->andWhere('rsa.recoverysendakt_id = recoverysendakt.recoverysendakt_id')]]);
         }
         $attr = 'recoveryrecieveakt_repaired';
         Proc::Filter_Compare(Proc::WhereStatement, $query, $filter, ['Attribute' => $attr, 'WhereStatement' => ['exists', (new Query())->select('rsa.recoverysendakt_id')->from('recoverysendakt rsa')->leftJoin('recoveryrecieveakt rra', 'rsa.recoverysendakt_id = rra.id_recoverysendakt')->leftJoin('recoveryrecieveaktmat rramat', 'rsa.recoverysendakt_id = rramat.id_recoverysendakt')->andWhere(['or', ['rra.recoveryrecieveakt_repaired' => $filter[$attr]], ['rramat.recoveryrecieveaktmat_repaired' => $filter[$attr]]])->andWhere('rsa.recoverysendakt_id = recoverysendakt.recoverysendakt_id')]]);
         $attr = 'mol_id_person';
         Proc::Filter_Compare(Proc::Strict, $query, $filter, ['Attribute' => $attr, 'SQLAttribute' => 'idMol.id_person', 'ExistsSubQuery' => (new Query())->select('recoveryrecieveakts.id_recoverysendakt')->from('recoveryrecieveakt recoveryrecieveakts')->leftJoin('osmotrakt idOsmotrakt', 'idOsmotrakt.osmotrakt_id = recoveryrecieveakts.id_osmotrakt')->leftJoin('tr_osnov idTrosnov', 'idOsmotrakt.id_tr_osnov = idTrosnov.tr_osnov_id')->leftJoin('mattraffic idMattraffic', 'idMattraffic.mattraffic_id = idTrosnov.id_mattraffic')->leftJoin('employee idMol', 'idMattraffic.id_mol = idMol.employee_id')->andWhere('recoveryrecieveakts.id_recoverysendakt = recoverysendakt.recoverysendakt_id')]);
         $attr = 'mat_id_material_mat';
         Proc::Filter_Compare(Proc::Strict, $query, $filter, ['Attribute' => $attr, 'SQLAttribute' => 'idMattraffic.id_material', 'ExistsSubQuery' => (new Query())->select('recoveryrecieveaktmats.id_recoverysendakt')->from('recoveryrecieveaktmat recoveryrecieveaktmats')->leftJoin('tr_mat_osmotr idTrMatOsmotr', 'idTrMatOsmotr.tr_mat_osmotr_id = recoveryrecieveaktmats.id_tr_mat_osmotr')->leftJoin('tr_mat idTrMat', 'idTrMat.tr_mat_id = idTrMatOsmotr.id_tr_mat')->leftJoin('mattraffic idMattraffic', 'idMattraffic.mattraffic_id = idTrMat.id_mattraffic')->andWhere('recoveryrecieveaktmats.id_recoverysendakt = recoverysendakt.recoverysendakt_id')]);
         $attr = 'mol_id_person_mat';
         Proc::Filter_Compare(Proc::Strict, $query, $filter, ['Attribute' => $attr, 'SQLAttribute' => 'idMol.id_person', 'ExistsSubQuery' => (new Query())->select('recoveryrecieveaktmats.id_recoverysendakt')->from('recoveryrecieveaktmat recoveryrecieveaktmats')->leftJoin('tr_mat_osmotr idTrMatOsmotr', 'idTrMatOsmotr.tr_mat_osmotr_id = recoveryrecieveaktmats.id_tr_mat_osmotr')->leftJoin('tr_mat idTrMat', 'idTrMat.tr_mat_id = idTrMatOsmotr.id_tr_mat')->leftJoin('mattraffic idMattraffic', 'idMattraffic.mattraffic_id = idTrMat.id_mattraffic')->leftJoin('employee idMol', 'idMattraffic.id_mol = idMol.employee_id')->andWhere('recoveryrecieveaktmats.id_recoverysendakt = recoverysendakt.recoverysendakt_id')]);
     }
 }
Beispiel #2
0
 private function glaukDopFilter(&$query)
 {
     $filter = Proc::GetFilter($this->formName(), 'PatientFilter');
     if (!empty($filter)) {
         Proc::Filter_Compare(Proc::Text, $query, $filter, ['Attribute' => 'patient_fam']);
         Proc::Filter_Compare(Proc::Text, $query, $filter, ['Attribute' => 'patient_im']);
         Proc::Filter_Compare(Proc::Text, $query, $filter, ['Attribute' => 'patient_ot']);
         Proc::Filter_Compare(Proc::Text, $query, $filter, ['Attribute' => 'patient_dr']);
         Proc::Filter_Compare(Proc::Number, $query, $filter, ['Attribute' => 'patient_vozrast', 'SQLAttribute' => 'TIMESTAMPDIFF(YEAR, patient_dr, CURDATE())']);
         Proc::Filter_Compare(Proc::Strict, $query, $filter, ['Attribute' => 'patient_pol']);
         Proc::Filter_Compare(Proc::WhereStatement, $query, $filter, ['Attribute' => 'fias_city', 'WhereStatement' => ['or', ['and', ['LIKE', 'idFias.AOGUID', $filter['fias_city']], 'idFias.AOLEVEL < 7'], ['and', ['LIKE', 'idFias2.AOGUID', $filter['fias_city']], 'idFias.AOLEVEL >= 7']]]);
         Proc::Filter_Compare(Proc::WhereStatement, $query, $filter, ['Attribute' => 'fias_street', 'WhereStatement' => ['and', ['LIKE', 'idFias.AOGUID', $filter['fias_street']], 'idFias.AOLEVEL >= 7']]);
         Proc::Filter_Compare(Proc::Text, $query, $filter, ['Attribute' => 'patient_dom']);
         Proc::Filter_Compare(Proc::Text, $query, $filter, ['Attribute' => 'patient_korp']);
         Proc::Filter_Compare(Proc::Text, $query, $filter, ['Attribute' => 'patient_kvartira']);
         Proc::Filter_Compare(Proc::Mark, $query, $filter, ['Attribute' => 'is_glauk_mark', 'WhereStatement' => ['not', ['glaukuchets.glaukuchet_id' => null]]]);
         Proc::Filter_Compare(Proc::DateRange, $query, $filter, ['Attribute' => 'glaukuchet_uchetbegin']);
         Proc::Filter_Compare(Proc::MultiChoice, $query, $filter, ['Attribute' => 'glaukuchet_detect']);
         Proc::Filter_Compare(Proc::Mark, $query, $filter, ['Attribute' => 'is_glaukuchet_mark', 'WhereStatement' => ['glaukuchets.glaukuchet_deregreason' => null, 'glaukuchets.glaukuchet_deregdate' => null]]);
         Proc::Filter_Compare(Proc::MultiChoice, $query, $filter, ['Attribute' => 'glaukuchet_deregreason']);
         Proc::Filter_Compare(Proc::DateRange, $query, $filter, ['Attribute' => 'glaukuchet_deregdate']);
         Proc::Filter_Compare(Proc::MultiChoice, $query, $filter, ['Attribute' => 'glaukuchet_stage']);
         Proc::Filter_Compare(Proc::DateRange, $query, $filter, ['Attribute' => 'glaukuchet_operdate']);
         Proc::Filter_Compare(Proc::Mark, $query, $filter, ['Attribute' => 'glaukuchet_not_oper_mark', 'WhereStatement' => ['glaukuchets.glaukuchet_operdate' => null]]);
         Proc::Filter_Compare(Proc::MultiChoice, $query, $filter, ['Attribute' => 'glaukuchet_invalid']);
         Proc::Filter_Compare(Proc::Mark, $query, $filter, ['Attribute' => 'glaukuchet_not_invalid_mark', 'WhereStatement' => ['glaukuchets.glaukuchet_invalid' => null]]);
         Proc::Filter_Compare(Proc::DateRange, $query, $filter, ['Attribute' => 'glaukuchet_lastvisit']);
         Proc::Filter_Compare(Proc::DateRange, $query, $filter, ['Attribute' => 'glaukuchet_lastmetabol']);
         Proc::Filter_Compare(Proc::Mark, $query, $filter, ['Attribute' => 'glaukuchet_not_lastmetabol_mark', 'WhereStatement' => ['glaukuchets.glaukuchet_lastmetabol' => null]]);
         Proc::Filter_Compare(Proc::Strict, $query, $filter, ['Attribute' => 'glaukuchet_id_employee', 'SQLAttribute' => 'glaukuchets.id_employee']);
         Proc::Filter_Compare(Proc::MultiChoice, $query, $filter, ['Attribute' => 'employee_id_person', 'SQLAttribute' => 'idEmployee.id_person']);
         Proc::Filter_Compare(Proc::MultiChoice, $query, $filter, ['Attribute' => 'employee_id_dolzh', 'SQLAttribute' => 'idEmployee.id_dolzh']);
         Proc::Filter_Compare(Proc::MultiChoice, $query, $filter, ['Attribute' => 'employee_id_podraz', 'SQLAttribute' => 'idEmployee.id_podraz']);
         Proc::Filter_Compare(Proc::MultiChoice, $query, $filter, ['Attribute' => 'employee_id_build', 'SQLAttribute' => 'idEmployee.id_build']);
         Proc::Filter_Compare(Proc::WhereStatement, $query, $filter, ['Attribute' => 'glprep_id_preparat', 'WhereStatement' => 'glaukuchets.glaukuchet_id in (select gl1.id_glaukuchet from glprep gl1 where gl1.id_preparat ' . (empty($filter['glprep_id_preparat' . '_not']) ? 'IN' : 'NOT IN') . ' (' . implode(',', !is_array($filter['glprep_id_preparat']) ? [] : $filter['glprep_id_preparat']) . '))']);
         Proc::Filter_Compare(Proc::WhereStatement, $query, $filter, ['Attribute' => 'glprep_rlocat', 'WhereStatement' => 'glaukuchets.glaukuchet_id in (select gl1.id_glaukuchet from glprep gl1 where gl1.glprep_rlocat ' . (empty($filter['glprep_rlocat' . '_not']) ? 'IN' : 'NOT IN') . ' (' . implode(',', !is_array($filter['glprep_rlocat']) ? [] : $filter['glprep_rlocat']) . '))']);
         Proc::Filter_Compare(Proc::Mark, $query, $filter, ['Attribute' => 'glprep_not_preparat_mark', 'WhereStatement' => 'glaukuchets.glaukuchet_id not in (select gl1.id_glaukuchet from glprep gl1 group by gl1.id_glaukuchet)']);
         Proc::Filter_Compare(Proc::Mark, $query, $filter, ['Attribute' => 'glprep_preparat_mark', 'WhereStatement' => 'glaukuchets.glaukuchet_id in (select gl1.id_glaukuchet from glprep gl1 group by gl1.id_glaukuchet)']);
         Proc::Filter_Compare(Proc::Mark, $query, $filter, ['Attribute' => 'glaukuchet_comment_mark', 'WhereStatement' => "glaukuchets.glaukuchet_comment <> ''"]);
         Proc::Filter_Compare(Proc::Text, $query, $filter, ['Attribute' => 'glaukuchet_comment']);
         Proc::Filter_Compare(Proc::Text, $query, $filter, ['Attribute' => 'patient_username']);
         Proc::Filter_Compare(Proc::DateRange, $query, $filter, ['Attribute' => 'patient_lastchange']);
         Proc::Filter_Compare(Proc::Text, $query, $filter, ['Attribute' => 'glaukuchet_username']);
         Proc::Filter_Compare(Proc::DateRange, $query, $filter, ['Attribute' => 'glaukuchet_lastchange']);
     }
 }
Beispiel #3
0
 private function materialDopFilter(&$query)
 {
     $filter = Proc::GetFilter($this->formName(), 'MaterialFilter');
     if (!empty($filter)) {
         $attr = 'mol_fullname_material';
         Proc::Filter_Compare(Proc::Strict, $query, $filter, ['Attribute' => $attr, 'SQLAttribute' => 'idMol.id_person', 'ExistsSubQuery' => (new Query())->select('mattraffics.id_material')->from('mattraffic mattraffics')->leftJoin('employee idMol', 'idMol.employee_id = mattraffics.id_mol')->leftjoin('(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', 'mattraffics.id_material = m2.id_material_m2 and mattraffics.id_mol = m2.id_mol_m2 and mattraffics.mattraffic_date < m2.mattraffic_date_m2 and m2.mattraffic_tip_m2 in (1,2)')->andWhere(['m2.mattraffic_date_m2' => NULL])->andWhere(['in', 'mattraffics.mattraffic_tip', [1, 2]])->andWhere('mattraffics.id_material = material.material_id')]);
         Proc::Filter_Compare(Proc::Strict, $query, $filter, ['Attribute' => 'material_writeoff']);
         $attr = 'mat_id_grupa';
         Proc::Filter_Compare(Proc::Strict, $query, $filter, ['Attribute' => $attr, 'SQLAttribute' => 'grupavids.id_grupa', 'ExistsSubQuery' => (new Query())->select('material_id')->from('material materials')->leftJoin('matvid idMatv', 'idMatv.matvid_id = materials.id_matvid')->leftJoin('grupavid grupavids', 'idMatv.matvid_id = grupavids.id_matvid')->andWhere('materials.material_id = material.material_id')]);
         $attr = 'mol_id_build';
         Proc::Filter_Compare(Proc::Strict, $query, $filter, ['Attribute' => $attr, 'SQLAttribute' => 'idMol.id_build', 'ExistsSubQuery' => (new Query())->select('mattraffics.id_material')->from('mattraffic mattraffics')->leftJoin('employee idMol', 'idMol.employee_id = mattraffics.id_mol')->leftjoin('(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', 'mattraffics.id_material = m2.id_material_m2 and mattraffics.id_mol = m2.id_mol_m2 and mattraffics.mattraffic_date < m2.mattraffic_date_m2 and m2.mattraffic_tip_m2 in (3)')->andWhere(['m2.mattraffic_date_m2' => NULL])->andWhere(['in', 'mattraffics.mattraffic_tip', [3]])->andWhere('mattraffics.id_material = material.material_id')]);
         $attr = 'tr_osnov_kab';
         Proc::Filter_Compare(Proc::Text, $query, $filter, ['Attribute' => $attr, 'SQLAttribute' => 'trOsnovs.' . $attr, 'LikeManual' => true, 'ExistsSubQuery' => (new Query())->select('mattraffics.id_material')->from('mattraffic mattraffics')->leftJoin('tr_osnov trOsnovs', 'trOsnovs.id_mattraffic = mattraffics.mattraffic_id')->leftjoin('(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', 'mattraffics.id_material = m2.id_material_m2 and mattraffics.id_mol = m2.id_mol_m2 and mattraffics.mattraffic_date < m2.mattraffic_date_m2 and m2.mattraffic_tip_m2 in (3)')->andWhere(['m2.mattraffic_date_m2' => NULL])->andWhere(['in', 'mattraffics.mattraffic_tip', [3]])->andWhere('mattraffics.id_material = material.material_id')]);
         $attr = 'mattraffic_username';
         Proc::Filter_Compare(Proc::Text, $query, $filter, ['Attribute' => $attr, 'SQLAttribute' => 'mattraffics.' . $attr, 'ExistsSubQuery' => (new Query())->select('mattraffics.id_material')->from('mattraffic mattraffics')->leftjoin('(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', 'mattraffics.id_material = m2.id_material_m2 and mattraffics.id_mol = m2.id_mol_m2 and mattraffics.mattraffic_date < m2.mattraffic_date_m2')->andWhere(['m2.mattraffic_date_m2' => NULL])->andWhere('mattraffics.id_material = material.material_id')]);
         $attr = 'mattraffic_lastchange';
         Proc::Filter_Compare(Proc::DateRange, $query, $filter, ['Attribute' => $attr, 'SQLAttribute' => 'mattraffics.' . $attr, 'ExistsSubQuery' => (new Query())->select('mattraffics.id_material')->from('mattraffic mattraffics')->leftjoin('(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', 'mattraffics.id_material = m2.id_material_m2 and mattraffics.id_mol = m2.id_mol_m2 and mattraffics.mattraffic_date < m2.mattraffic_date_m2')->andWhere(['m2.mattraffic_date_m2' => NULL])->andWhere('mattraffics.id_material = material.material_id')]);
     }
 }