Esempio n. 1
0
<?php

require_once '../init.php';
$company = new Company();
$message = new Message();
$vacature = new Vacature();
$medewerker = new Medewerker();
$branche = new Branche();
$logged_in = $company->is_company_logged_in();
if (!$logged_in) {
    // check if company is logged in
    echo '<script>location.href="../company.php"</script>';
    // relocate user to login page
}
?>

<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Softjobs - Admin paneel</title>


    <!-- CK editor -->
Esempio n. 2
0
 public function postUpdate()
 {
     $title = 'Editar usuario';
     $branches = Branche::all();
     $input = array_except(Input::all(), array('_method', 'password2'));
     $id = $input['id'];
     $rules = array('name' => 'required', 'email' => 'required|email', 'password' => 'required');
     $v = Validator::make($input, $rules, User::$messages);
     if ($v->passes()) {
         $password = $input['password'];
         $password = Hash::make($password);
         $user = $this->user->find($id);
         $user->name = $input['name'];
         $user->email = $input['email'];
         $user->password = $password;
         try {
             $user->save();
         } catch (Exception $e) {
             // $message = $e->getMessage();
             $message = 'No se han guardado cambios porque hay otro usuario con ese nombre o email.';
             Session::flash('message', $message);
             return View::make('users.edit')->with(compact('title', 'user', 'branches'));
         }
         try {
             $rol = $user->roles()->first();
             $r['name'] = $input['rol'];
             $r['branch_id'] = $input['branch'];
             $r['user_id'] = $user->id;
             $rol->update($r);
             return Redirect::to('users/list');
         } catch (Exception $e) {
             $message = 'No se ha podido asignar el rol al usuario <strong>' . $user->name . '</strong>.';
             Session::flash('message', $message);
             return View::make('users.register')->with(compact('title', 'user', 'branches'));
         }
         return Redirect::to('users/list');
     }
     return Redirect::to('users/edit/' . $id)->withInput()->withErrors($v)->with('message', 'Hay errores de validación.');
 }
Esempio n. 3
0
 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'));
 }
Esempio n. 4
0
 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;
 }
Esempio n. 5
0
 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'));
 }
Esempio n. 6
0
 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'));
 }
Esempio n. 7
0
 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'));
 }
Esempio n. 8
0
 public function getSearch()
 {
     $title = "Artículos";
     $input = Input::all();
     $articles = null;
     $filtro = '';
     if ($input['filterBy'] == 'id') {
         $filtro = 'Artículo con código <strong>' . $input['search'] . '</strong>.';
         $articles = Article::whereRaw("id = '" . $input['search'] . "'")->paginate(6);
     } else {
         if ($input['filterBy'] == 'comments') {
             $palabras = explode(' ', $input['search']);
             $articles = Article::where('comments', 'LIKE', '%%');
             foreach ($palabras as $palabra) {
                 $articles->where('comments', 'LIKE', '%' . $palabra . '%');
             }
             $articles = $articles->orderBy('comments', 'ASC')->paginate(6);
             $filtro = 'Artículos que contienen en datos adicionales <strong>' . $input['search'] . '</strong>.';
             //$articles = Article::whereRaw("comments like '%". $input['search'] ."%'")->orderBy('name', 'asc')->paginate(6);
         } else {
             // Se asume que el filtro es por nombre.
             $palabras = explode(' ', $input['search']);
             $articles = Article::where('name', 'LIKE', '%%');
             foreach ($palabras as $palabra) {
                 $articles->where('name', 'LIKE', '%' . $palabra . '%');
             }
             $articles = $articles->orderBy('name', 'ASC')->paginate(6);
             $filtro = 'Artículos que contienen en el nombre <strong>' . $input['search'] . '</strong>.';
             //$articles = Article::whereRaw("name like '%". $input['search'] ."%'")->orderBy('name', 'asc')->paginate(6);
         }
     }
     $branches = Branche::orderBy('name', 'asc')->get();
     return View::make('articles.index')->with(compact('articles', 'title', 'branches', 'filtro', 'input'));
 }
Esempio n. 9
0
 /**
  * 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';
     }
 }
     $name = $_POST['bezeichnung'];
     if ($name == "") {
         $err->addError("Es wurde kein Branchenname eingegeben.");
     }
     if (!$err->moreErrors()) {
         if ($f = Branche::add($conn, $name, $err)) {
             $meldung = "Die Branche wurde erfolgreich angelegt.";
             $ok = 40;
         }
     } else {
         $ok = 41;
     }
 }
 //Auflistung der Branchen
 $vorhandene_Branchen = "";
 if (!($result = Branche::enumBranchen($conn))) {
     $err->addError("Die Branchen konnten von der Datenbank nicht gelesen werden. " . $conn->getLastError());
     if ($ok == 0 || $ok == 10) {
         $ok = 21;
     }
 } else {
     //Tabelle bilden
     if ($result->rowsCount() > 0) {
         $vorhandene_Branchen .= '<table border="0" cellspacing="0" cellpadding="0" class="StudiengangTable">';
         $vorhandene_Branchen .= '<tr><td width="50%" class="tableTitle">Branche</td>';
         $vorhandene_Branchen .= '<td width="50%" class="tableTitle">Aktion</td></tr>';
         while ($r = $result->getNextRow()) {
             $vorhandene_Branchen .= '<tr>';
             if ($r[2] != 0) {
                 $vorhandene_Branchen .= '<td valign="top" class="ausgegraut">' . $r[1] . '<br><br></td>';
             } else {