/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Laboratorio();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Laboratorio'])) {
         $model->attributes = $_POST['Laboratorio'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Example #2
0
 /**
  * @name            obtenerLaboratorios
  * 
  * @description     Retorna un listado con los Laboratorios que proveen 
  *                  productos a Droguería.
  */
 public function obtenerLaboratorios()
 {
     set_time_limit(10000);
     $autorizacion = json_decode($this->obtenerTokenUsuario());
     $option = ['http' => ['method' => 'GET', 'header' => ['Authorization: GUID ' . $autorizacion->Guid, 'Content-Type: application/json']]];
     $context = stream_context_create($option);
     $laboratorios = json_decode(file_get_contents("http://test.dronena.com:8083/REST/Cloud/Proveedor/Listado", false, $context));
     if ($laboratorios) {
         foreach ($laboratorios->Proveedores->Proveedor as $p) {
             $labo = Laboratorio::where('Codigo', '=', $p->Codigo)->first();
             if (!$labo) {
                 $lab = new Laboratorio();
                 $lab->Codigo = $p->Codigo;
                 $lab->Nombre = $p->Nombre;
                 $lab->save();
             }
         }
     }
 }