public function store()
 {
     $input = Input::all();
     for ($i = 1; $i < 179; $i++) {
         $infra = 0;
         $rect = 0;
         $mult = 0;
         if (isset($input['inf_' . $i])) {
             $infra = $input['inf_' . $i];
         }
         if (isset($input['rect_' . $i])) {
             $rect = $input['rect_' . $i];
         }
         if (isset($input['mult_' . $i])) {
             $mult = $input['mult_' . $i];
         }
         $id = $input['id_' . $i];
         $anexo = Anexo22::find($id);
         $anexo->a22_rectifiable = $rect;
         $anexo->a22_fine = $mult;
         $anexo->infractions_id = $infra;
         $anexo->save();
         echo $infra . $mult . $rect;
     }
     //return redirect()->back();
 }
 public function index()
 {
     $data = Infraction::all();
     $anexo = Anexo22::all();
     $infraccion = Infraction::lists('inf_description', 'id');
     return view('infraction.index')->with(["data" => $data, 'anexo' => $anexo, 'infra' => $infraccion]);
 }
 public function checkPedimento($referen, $valorOrigen)
 {
     if ($valorOrigen['entrada'] == 1) {
         $pk_referencia = $referen->pk_referencia;
         $tabla = 'optr02';
         $camposel1 = 'pk_factura';
         $camposel2 = 'pk_cove';
         $campow = 'pk_referencia';
     } else {
         $pk_referencia = $referen->folio_ds;
         $tabla = 'ds505';
         $camposel1 = 'NumeroFactura';
         $camposel2 = 'NumeroFactura';
         $campow = 'folio_ds';
     }
     //Recorrer campos del Anexo 22
     $anexo = Anexo22::all();
     foreach ($anexo as $anx) {
         //Checar validaciones por campo
         foreach ($anx->validations as $val) {
             $valid = $val->id;
             $camposbd = $anx->relationships->where('origin_id', $valorOrigen['entrada'])->first();
             $data = ["tabla" => $camposbd->table, "campos" => $camposbd->field, "attr_id" => $val->attribute_id, "data_val" => $val->val_data, "anx_id" => $anx->id, "entrada" => $valorOrigen['entrada'], "referencia" => $pk_referencia];
             $validacion = new Validation();
             $valor = $validacion->isValid($data);
             if ($valor == 0) {
                 if ($val->attribute_id == 9) {
                     $docum = 1;
                 } else {
                     $docum = 0;
                 }
                 $datos = ["res_referen" => $pk_referencia, "validations_id" => $valid, "res_document" => $docum, "res_company" => Session::get('empresa'), "res_user" => Session::get('usuario')];
                 $totalres = Result::where('res_referen', $pk_referencia)->where('validations_id', $valid)->count();
                 if ($totalres == 0) {
                     Result::create($datos);
                 }
             }
         }
     }
     $factura = \DB::connection('users')->table($tabla)->where($campow, $pk_referencia)->first();
     $cove = $this->checkCove($factura, $camposel1, $camposel2, $pk_referencia);
     echo $cove;
 }
Exemple #4
0
 public function isValid($data)
 {
     $tamanio = 0;
     $valor = 1;
     if ($data['entrada'] == 1) {
         $campo = 'pk_referencia';
     } else {
         $campo = 'folio_ds';
     }
     $consulta = \DB::connection('users')->table($data['tabla'])->where($campo, $data['referencia'])->get();
     if ($consulta != null) {
         foreach ($consulta as $query) {
             //============================== Validaciones ================================
             if ($data['attr_id'] == 4) {
                 if ($query->{$data}['campos'] == '') {
                     $valor = 0;
                 }
             }
             if ($data['attr_id'] == 2) {
                 $campo = explode(",", $data['campos']);
                 if ($data['attr_id'] == 2) {
                     for ($i = 0; $i < count($campo); $i++) {
                         $tamanio += strlen($query->{$campo}[$i]);
                     }
                     if ($tamanio != $data['data_val']) {
                         $valor = 0;
                     }
                 } else {
                     $campos = $campo[0];
                 }
             }
             if ($data['attr_id'] == 6 || $data['attr_id'] == 5) {
                 $catalogo = explode("|", $data['data_val']);
                 $tablaval = $catalogo[0];
                 $campoval = $catalogo[1];
                 Session::put('tablacat', $tablaval);
                 if ($data['attr_id'] == 5) {
                     $formula = explode(',', $catalogo[1]);
                     $campobd = $formula[0];
                     $operador = $formula[1];
                     $result = $formula[2];
                     $camposwh = Anexo22::find($result)->relationships->where('origin_id', $data['entrada'])->first();
                     $campowh = explode(',', $camposwh->field);
                     $val_campo = Catalog::where($catalogo[2], 'LIKE', '%' . $query->{$data}['campos'] . '%')->where($campobd, $query->{$campowh}[0])->count();
                 }
                 if ($data['attr_id'] == 6) {
                     $campo = explode(',', $data['campos']);
                     $campocat = $campo[0];
                     $val_campo = Catalog::where($campoval, $query->{$campocat})->count();
                 }
                 if ($val_campo == 0) {
                     $valor = 0;
                 }
             }
             if ($data['attr_id'] == 3) {
                 $camposval = explode(",", $data['data_val']);
                 $valanexo = Anexo22::find($camposval[0]);
                 $campanx = $valanexo->a22_field;
                 if ($query->{$campanx} != $camposval[1]) {
                     $valor = 0;
                 }
             }
             if ($data['attr_id'] == 8) {
                 //$camposval = explode(",", $data['campos']);
                 $valores = explode("|", $data['data_val']);
                 $identif = $valores[1];
                 $docum = $valores[0];
                 $documentos = \DB::connection('users')->table('opauimg')->where('pk_referencia', $data['referencia'])->where('imgtipodoc', $docum)->count();
                 if ($query->{$data}['campos'] != $identif && $documentos == 0) {
                     $valor = 0;
                 }
             }
         }
     }
     return $valor;
 }
 public function show($anx)
 {
     $anexo = Anexo22::where('id', $anx)->first();
     $validaciones = $anexo->validations()->where('anexo22_id', $anx)->get();
     return $validaciones;
 }
 public function show($anx)
 {
     $anexo = Anexo22::where('id', $anx)->first();
     $validaciones = $anexo->validations()->join('aud_attributes', 'attribute_id', '=', 'aud_attributes.id')->select('val_data', 'attribute_id', 'name', 'aud_validations.id as id')->where('anexo22_id', $anx)->get();
     return $validaciones;
 }