Beispiel #1
0
<?php

require 'vendor/autoload.php';
$response = array('codigo' => '', 'mensaje' => '');
$db = Connection::getConnection();
$post = $_POST;
$usuario = Usuarios::with('roles')->where('id', '=', $post['id_maestro'])->get();
if (count($usuario) > 0) {
    $db::beginTransaction();
    try {
        $maestro = null;
        $maestro = Maestros::find($usuario[0]->id);
        if ($maestro == null) {
            $maestro = new Maestros();
            $maestro->id_maestro = $usuario[0]->id;
        }
        $maestro->antiguedad_docen = $post['antiguedad_docen'];
        $maestro->antiguedad_laboral = $post['antiguedad_laboral'];
        $maestro->plaza_actual_id = $post['plaza_actual_id'];
        $maestro->deptos_academicos_id = $post['deptos_academicos_id'];
        $maestro->rfc = $post['rfc'];
        $maestro->estados_id = $post['estados_id'];
        $maestro->fecha_ingreso_sist = $post['fecha_ingreso_sist'];
        $maestro->escolaridad_id = $post['escolaridad_id'];
        $maestro->nombre_profesion = $post['nombre_profesion'];
        $maestro->plaza_aparticipar_id = $post['plaza_aparticipar_id'];
        $maestro->plaza_cat_id = $post['plaza_cat_id'];
        $maestro->save();
        $db::commit();
        $response['code'] = 1;
        $response['mensaje'] = "Se guardó correctamente";
 public function updateMaestro()
 {
     $response = array('codigo' => '', 'mensaje' => '');
     $post = $this->app->request->post();
     $usuario = Usuarios::with('roles')->where('id', '=', $post['id_maestro'])->get();
     if (count($usuario) > 0) {
         $db = Connection::getConnection();
         $db::beginTransaction();
         try {
             $maestro = null;
             $maestro = Maestros::find($usuario[0]->id);
             if ($maestro == null) {
                 $maestro = new Maestros();
                 $maestro->id_maestro = $usuario[0]->id;
             }
             $maestro->antiguedad_docen = $post['antiguedad_docen'];
             $maestro->antiguedad_laboral = $post['antiguedad_laboral'];
             $maestro->plaza_actual_id = $post['plaza_actual_id'];
             $maestro->deptos_academicos_id = $post['deptos_academicos_id'];
             $maestro->rfc = $post['rfc'];
             $maestro->estados_id = $post['estados_id'];
             $maestro->fecha_ingreso_sist = $post['fecha_ingreso_sist'];
             $maestro->escolaridad_id = $post['escolaridad_id'];
             $maestro->nombre_profesion = $post['nombre_profesion'];
             $maestro->plaza_aparticipar_id = $post['plaza_aparticipar_id'];
             $maestro->plaza_cat_id = $post['plaza_cat_id'];
             $maestro->save();
             $db::commit();
             $response['code'] = 1;
             $response['mensaje'] = "Se guardó correctamente";
         } catch (Exception $e) {
             $db::rollback();
             $response['code'] = 3;
             $response['mensaje'] = $e->getMessage();
         }
     } else {
         $response['codigo'] = 2;
         $response['mensaje'] = 'El usuario no existe';
     }
     echo json_encode($response);
 }
Beispiel #3
0
<?php

require 'vendor/autoload.php';
$db = Connection::getConnection();
error_reporting(E_ALL);
$response = array('codigo' => 0, 'mensaje' => '');
if (isset($_POST['id_maestro']) && isset($_POST['tipo_documento_id']) && $_POST['clasificacion_documento_id']) {
    $maestro = Maestros::find($_POST['id_maestro']);
    if ($maestro == null) {
        $response['mensaje'] = 'Maestro no encontrado';
    } else {
        $userDir = __DIR__ . '/uploads/' . $maestro->id_maestro;
        if (!file_exists($userDir) && !is_dir($userDir)) {
            $oldmask = umask(0);
            try {
                mkdir($userDir, 0777);
            } catch (Exception $e) {
                $response['mensaje'] = $e->getMessage();
            }
            $dirs = array(__DIR__ . '/uploads/' . $maestro->id_maestro . '/documentacion/', __DIR__ . '/uploads/' . $maestro->id_maestro . '/alternativa_1/', __DIR__ . '/uploads/' . $maestro->id_maestro . '/alternativa_2/');
            foreach ($dirs as $key => $value) {
                try {
                    mkdir($value, 0777);
                } catch (Exception $e) {
                    $response['mensaje'] = $e->getMessage();
                }
            }
            umask($oldmask);
        }
        $documento = Documentos::find($_POST['id_documento']);
        if ($documento == null) {