public function agregar()
 {
     //Aca se manda a la funcion agregarItem de la clase Item
     //y se queda con la respuesta para redirigir cual sea el caso
     $respuesta = Producto::agregarProducto(Input::all());
     /*
      if ($respuesta['error'] == true) {
      return Redirect::to('admin/producto')->withErrors($respuesta['mensaje'])->withInput();
      } else {
      return Redirect::to('admin/producto')->with('mensaje', $respuesta['mensaje']);
      }
     * 
     */
     if ($respuesta['error'] == true) {
         $seccion = Seccion::find(Input::get('seccion_id'));
         $menu = $seccion->menuSeccion()->url;
         $ancla = '#' . $seccion->estado . $seccion->id;
         return Redirect::to($this->array_view['prefijo'] . '/admin/' . $this->folder_name . '/agregar/' . $seccion->id)->with('mensaje', $respuesta['mensaje'])->with('error', true);
         //return Redirect::to('admin/producto')->withErrors($respuesta['mensaje'])->withInput();
     } else {
         $seccion = Seccion::find(Input::get('seccion_id'));
         $menu = $seccion->menuSeccion()->lang()->url;
         $ancla = '#' . $seccion->estado . $seccion->id;
         return Redirect::to($this->array_view['prefijo'] . '/' . $menu)->with('mensaje', $respuesta['mensaje'])->with('ancla', $ancla)->with('ok', true);
     }
 }
Exemplo n.º 2
0
 public function crearProducto()
 {
     $respuesta = Producto::agregarProducto(Input::all());
     if ($respuesta['error'] == true) {
         return Redirect::to('producto')->withErrors($respuesta['mensaje'])->withInput();
     } else {
         return Redirect::to('producto')->with('mensaje', $respuesta['mensaje']);
     }
 }
Exemplo n.º 3
0
     $objCon->db_connect();
     $datos = $_POST['datosEnviar'];
     $datos = explode(',', $datos);
     $nuevoArr = array();
     $cont = 0;
     for ($i = 0; $i < count($datos); $i++) {
         $nuevoArr[$cont]['pre_id'] = $datos[$i];
         $nuevoArr[$cont]['ins_id'] = $datos[$i + 1];
         $nuevoArr[$cont]['val_monto'] = $datos[$i + 2];
         $i = $i + 2;
         $cont++;
     }
     try {
         $objCon->beginTransaction();
         $objPro->setProducto($_POST['pro_id'], $objUti->eliminaEspacios($_POST['pro_nom']), '0');
         $objPro->agregarProducto($objCon, $_POST['tip_pro_id'], $_POST['uni_id']);
         for ($i = 0; $i < count($nuevoArr); $i++) {
             $val_id = $objValores->buscarMaximoId($objCon);
             $objValores->setValores($val_id, $nuevoArr[$i]['val_monto']);
             $objValores->agregarValores($objCon, $_POST['pro_id'], $nuevoArr[$i]['pre_id'], $nuevoArr[$i]['ins_id']);
         }
         $objCon->commit();
         echo 'bien';
     } catch (PDOException $e) {
         $objCon->rollBack();
         $e->getMessage();
     }
     break;
 case "buscarProducto":
     $objCon->db_connect();
     try {