public function getFilterByBranch() { $title = 'Entregas inmediatas'; $input = Input::all(); $branch = Branche::find($input['branch_id']); $instants = Instant::where('branch_id', '=', $input['branch_id'])->orderBy('id', 'desc')->paginate(6); $filterInstant = 'Entregas inmediatas de la sucursal <strong>' . $branch->name . '</strong>'; return View::make('instants.index')->with(compact('title', 'instants', 'filterInstant', 'input')); }
public function getFilterByStatusBranch() { $TIPO_REMISION = self::TIPO_REMISION; $title = 'Compras'; $input = Input::all(); $branch = Branche::find($input['branch_id']); $purchases = Purchase::where('status', '=', $input['estado'])->where('branch_id', '=', $input['branch_id'])->orderBy('id', 'desc')->paginate(6); $mensaje = 'Compras con estado <strong>' . $input['estado'] . '</strong> en la sucursal <strong>' . $branch->name . '</strong>'; return View::make('purchases.index')->with(compact('title', 'purchases', 'mensaje', 'input', 'TIPO_REMISION')); }
public function getExcelByBranch($idBranch) { $branch = Branche::find($idBranch); if (empty($branch)) { return Redirect::to('branches'); } /** Error reporting */ error_reporting(E_ALL); ini_set('display_errors', TRUE); ini_set('display_startup_errors', TRUE); date_default_timezone_set('America/Bogota'); if (PHP_SAPI == 'cli') { die('Este archivo corre únicamente desde un navegador web.'); } // Create new PHPExcel object $objPHPExcel = new PHPExcel(); // Set document properties $objPHPExcel->getProperties()->setCreator(Auth::user()->name)->setLastModifiedBy(Auth::user()->name)->setTitle("Informe de artículos")->setSubject("Sucursal " . $branch->name)->setDescription("Este documento contiene la lista de artículos de la sucursal " . $branch->name)->setKeywords("artículos, sucursal, " . $branch->name)->setCategory("Archivo generado"); // Datos de sucursal $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A1', 'Código de sucursal')->setCellValue('B1', $branch->id)->setCellValue('A2', 'Nombre de sucursal')->setCellValue('B2', $branch->name); // Encabezados con UTF-8 $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A3', 'Código de artículo')->setCellValue('B3', 'Nombre de artículo')->setCellValue('C3', 'Stock físico')->setCellValue('D3', 'Unidad de medida')->setCellValue('E3', 'Precio unitario')->setCellValue('F3', 'Costo unitario')->setCellValue('G3', 'Precio neto')->setCellValue('H3', 'Costo neto')->setCellValue('I3', 'Datos adicionales'); $stocks = Stock::where('branch_id', '=', $branch->id)->get(); $fila = 4; foreach ($stocks as $stock) { // $article = Article::find($stock->article->id); $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A' . $fila, $stock->article->id)->setCellValue('B' . $fila, $stock->article->name)->setCellValue('C' . $fila, $stock->stock)->setCellValue('D' . $fila, $stock->article->unit)->setCellValue('E' . $fila, $stock->article->price)->setCellValue('F' . $fila, $stock->article->cost)->setCellValue('G' . $fila, $stock->article->price * $stock->stock)->setCellValue('H' . $fila, $stock->article->cost * $stock->stock)->setCellValue('I' . $fila, $stock->article->comments); $fila++; } // Rename worksheet $objPHPExcel->getActiveSheet()->setTitle('s' . $branch->id . date('_Ymd')); // Set active sheet index to the first sheet, so Excel opens this as the first sheet $objPHPExcel->setActiveSheetIndex(0); // Redirect output to a client’s web browser (Excel2007) // header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); // header('Content-Disposition: attachment;filename="s'. $branch->id . date('_YmdHis') .'.xlsx"'); // header('Cache-Control: max-age=0'); $nombre_archivo = 's' . $branch->id . date('_His') . '.xlsx'; $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save(public_path() . '/excel/' . $nombre_archivo); return Redirect::to('branches')->with(array('mensajewell' => 'El archivo ' . $nombre_archivo . ' se ha creado con éxito, si la descarga no inicia automáticamente haga click <a id="descarga" href="' . url('excel/' . $nombre_archivo) . '">aquí</a> para descargarlo.<script>$(document).on("ready", function(){ $(location).attr("href", "' . url('excel/' . $nombre_archivo) . '"); });</script>')); // $objWriter->save('php://output'); // exit; }
public function getFilterByStatusBranch() { $title = 'Rotaciones'; $input = Input::all(); $branch = Branche::find($input['branch_id']); $rotations = Rotation::where('status', '=', $input['estado'])->whereRaw('branch_from = "' . $input['branch_id'] . '" OR branch_to = "' . $input['branch_id'] . '"')->orderBy('id', 'desc')->paginate(6); $filterRotation = 'Rotaciones con estado <strong>' . $input['estado'] . '</strong> en la sucursal <strong>' . $branch->name . '</strong>'; return View::make('rotations.index')->with(compact('title', 'rotations', 'filterRotation', 'input')); }
public function getFilterByStatusBranch() { $title = 'Daños'; $input = Input::all(); $branch = Branche::find($input['branch_id']); $damages = Damage::where('status', '=', $input['estado'])->where('branch_id', '=', $input['branch_id'])->orderBy('id', 'desc')->paginate(6); $filterDamage = 'Daños con estado <strong>' . $input['estado'] . '</strong> en la sucursal <strong>' . $branch->name . '</strong>'; return View::make('damages.index')->with(compact('title', 'damages', 'filterDamage', 'input')); }
/** * Devuelve Ok si hay stock suficiente para continuar con el tipo de movimiento. * De lo contrario retorna un mensaje indicando el artículo con stock insufiente en * la sucursal correspondiente. * @param Article $Article * @param string $idBranch id de la sucursal. * @param integer $amount Cantidad a verificar contra stock. * @param string $tipo Tipo de movimiento que se está procesando: venta, entrega inmediata, daño ó rotación. * @return string Mensaje de retorno. */ public static function checkStock($article, $idBranch, $amount, $tipo) { $articleStock = Stock::whereRaw("article_id='" . $article->id . "' and branch_id='" . $idBranch . "'")->first(); $branch = Branche::find($idBranch); if (empty($articleStock) || $article->disponible($branch) < $amount) { return 'El stock disponible del artículo <strong>' . $article->name . '</strong> en la sucursal <strong>' . $branch->name . '</strong> es insuficiente para <strong>' . $tipo . '</strong>.'; } else { return 'Ok'; } }