/** * 返回图片列表 * @access public */ function index() { $field = array('rotation_id', 'type', 'image_name'); $m = new Rotation(); $m->clear(); $m->setField($field); $m->setTable('vcb_rotation'); //$m->setWhere('status', '!=', '60000'); $data = $m->select(); print_r($data); //状态标题 $count = count($data); for ($i = 0; $i < $count; $i++) { //$data[$i]['status_cn'] = $m->getStatus('cn',$data[$i]['status']); //$data[$i]['status_th'] = $m->getStatus('th',$data[$i]['status']); $data[$i]['type'] = $m->getTypeCaption($data[$i]['type']); //$data[$i]['image_path'] = $m->getImage($data[$i]['category_id']); } echo "<br/>"; print_r($data); $this->assign('data', $data); }
<?php use Pagerfanta\Adapter\ArrayAdapter; use Pagerfanta\Pagerfanta; require 'vendor/autoload.php'; require 'db_config.php'; require 'models/franchises.php'; require 'models/games.php'; require 'models/rotations.php'; require 'RotationAdapter.php'; $franchiseModel = new Franchise($db); $rotationModel = new Rotation($db); $games = new Game($db); $current_week = filter_input(INPUT_GET, 'week', FILTER_SANITIZE_NUMBER_INT); $max_week = $games->getMaxWeek(); if ($current_week == 0) { $current_week = $max_week; } $franchises = $franchiseModel->getAll(); $rotations = $rotationModel->getAll(); /** * We need to add an empty set of rotations to our existing list for the week * after the most current ones we have */ $rotation_max_week = $rotationModel->getMaxWeek(); $rotations = array_merge($rotations, $rotationModel->addWeek($rotation_max_week + 1, $franchises)); // load all rotations into the pager $adapter = new RotationAdapter($rotations, $franchises); $adapter->processByWeek(); $pagerfanta = new Pagerfanta($adapter); $pagerfanta->setMaxPerPage(24);
$week_raw = $_POST['week']; $franchise_ids_raw = $_POST['franchise_id']; $rotations_raw = $_POST['rotation']; $new_flags_raw = $_POST['new']; // Filter out everything $week = filter_var($week_raw, FILTER_SANITIZE_NUMBER_INT); $franchise_ids = []; $rotations = []; foreach ($franchise_ids_raw as $id) { $franchise_ids[] = filter_var($id, FILTER_SANITIZE_NUMBER_INT); } foreach ($rotations_raw as $rotation) { $rotations[] = filter_var($rotation, FILTER_SANITIZE_STRING); } foreach ($new_flags_raw as $new) { $new_flags[] = filter_var($new, FILTER_SANITIZE_NUMBER_INT); } // Filter out empty rotations so we don't accidentally create doubles $rotations = array_filter($rotations, function ($v) { return $v !== ''; }); // Save or update existing rotations $rotationModel = new Rotation($db); foreach ($rotations as $key => $rotation) { if ($new_flags[$key] == 1) { $rotationModel->save($rotation, $franchise_ids[$key], $week); } else { $rotationModel->update($rotation, $franchise_ids[$key], $week); } } header("Location: rotation_management.php?week={$week}");
public function getFilterByArticleComments() { $title = 'Rotaciones'; $input = Input::all(); $idsRotation = '0'; $article = Article::find($input['article']); if (!empty($article)) { foreach ($article->rotationItems as $ritems) { $idsRotation .= $ritems->rotation->id . ','; } } #if $idsRotation = trim($idsRotation, ','); $rotations = Rotation::whereRaw('id in (' . $idsRotation . ')')->whereRaw('comments like "%' . $input['comments'] . '%"')->orderBy('id', 'desc')->paginate(6); $filterRotation = 'Rotaciones que contienen el artículo <strong>' . $input['article'] . '</strong> y en los comentarios del remisionero <strong>' . $input['comments'] . '</strong>.'; return View::make('rotations.index')->with(compact('title', 'rotations', 'filterRotation', 'input')); }
/** * Devuelve la cantidad involucrada en rotaciones pendientes en destino. * @param Branche $branch * @return integer $cantidad */ public function inRotationsTo($branch) { $rotationsPendientes = Rotation::where('status', '=', 'pendiente en destino')->where('branch_to', '=', $branch->id)->get(); $cantidad = 0; foreach ($rotationsPendientes as $rotation) { foreach ($rotation->rotationItems as $item) { if ($this->id == $item->article->id) { $cantidad += $item->amount; } } } return $cantidad; }