Пример #1
0
 function addBeans($beans)
 {
     if (null == $beans) {
         return array();
     }
     $this->data = R::exportAll($beans);
 }
Пример #2
0
 public function index()
 {
     $perPage = 10;
     $page = @$_GET['page'] ? $_GET['page'] : 1;
     $start = ($page - 1) * $perPage;
     $items = R::find('news', ' ORDER BY sort_order LIMIT ?,?', [$start, $perPage]);
     $itemsAll = R::find('news', 'ORDER BY sort_order');
     $itemsAll = R::exportAll($items);
     $count = R::count('news');
     $maxPage = floor($count / $perPage) + ($count % $perPage == 0 ? 0 : 1);
     $this->slim->render("news/list.php", ['items' => $items, 'itemsAll' => $itemsAll, 'page' => $page, 'maxPage' => $maxPage]);
 }
Пример #3
0
 public function index()
 {
     $perPage = 10;
     $page = @$_GET['page'] ? $_GET['page'] : 1;
     $start = ($page - 1) * $perPage;
     $items = R::find('room', 'LIMIT ?,?', [$start, $perPage]);
     $count = R::count('room');
     $maxPage = floor($count / $perPage) + ($count % $perPage == 0 ? 0 : 1);
     $itemsExport = R::exportAll($items);
     $this->builds($itemsExport);
     $this->slim->render("room/list.php", ['items' => $itemsExport, 'page' => $page, 'maxPage' => $maxPage]);
 }
Пример #4
0
 public function index($roomId)
 {
     $perPage = 10;
     $page = @$_GET['page'] ? $_GET['page'] : 1;
     $start = ($page - 1) * $perPage;
     $room = R::findOne('room', 'id = ?', [$roomId]);
     $items = R::find('room_pattern', 'room_id = ? LIMIT ?,?', [$roomId, $start, $perPage]);
     $count = R::count('room_pattern', 'room_id = ?', [$roomId]);
     $maxPage = floor($count / $perPage) + ($count % $perPage == 0 ? 0 : 1);
     $itemsExport = R::exportAll($items);
     $this->builds($itemsExport);
     $this->slim->render("room/pattern/list.php", ['room' => $room, 'items' => $itemsExport, 'page' => $page, 'maxPage' => $maxPage]);
 }
Пример #5
0
 public function index()
 {
     $perPage = 10;
     $page = @$_GET['page'] ? $_GET['page'] : 1;
     $start = ($page - 1) * $perPage;
     $items = R::find('room', 'LIMIT ?,?', [$start, $perPage]);
     $count = R::count('room');
     $maxPage = floor($count / $perPage) + ($count % $perPage == 0 ? 0 : 1);
     $itemsExport = R::exportAll($items);
     $this->builds($itemsExport);
     header('Content-Type: application/json');
     echo json_encode(['items' => $itemsExport, 'page' => $page, 'maxPage' => $maxPage, 'total' => $count], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
     exit;
 }
Пример #6
0
 public function sheet()
 {
     $items = R::find("account", "email IS NOT NULL");
     $itemsExport = R::exportAll($items);
     $this->builds($itemsExport);
     // var_dump($itemsExport);
     $excel = new PHPExcel();
     $excel->getProperties()->setCreator("duragres - users");
     $excel->getProperties()->setLastModifiedBy("duragres - users");
     $excel->getProperties()->setTitle("duragres - users");
     $excel->getProperties()->setSubject("duragres - users");
     $excel->getProperties()->setDescription("duragres - users, report.");
     $excel->setActiveSheetIndex(0);
     $sheet = $excel->getActiveSheet();
     $sheet->setTitle("Report");
     foreach ($itemsExport as $key => $item) {
         if ($key == 0) {
             $sheet->SetCellValue('A' . '1', "ID");
             $sheet->SetCellValue('B' . '1', "Created At");
             $sheet->SetCellValue('C' . '1', "Email");
             $sheet->SetCellValue('F' . '1', "Product Count");
         }
         $i = $key + 2;
         $bTime = @strtotime($item["created_at"]);
         $bYear = @date('Y', $bTime);
         // + 543;
         $bStr = @date('d/m/', $bTime) . $bYear;
         $bStr = !empty($item["created_at"]) ? $bStr : "";
         $sheet->SetCellValue('A' . $i, $item["id"]);
         $sheet->SetCellValue('B' . $i, $bStr);
         $sheet->SetCellValue('C' . $i, $item["email"]);
         $sheet->SetCellValue('F' . $i, $item["product_count"]);
     }
     $objWriter = PHPExcel_IOFactory::createWriter($excel, 'Excel5');
     // We'll be outputting an excel file
     header('Content-type: application/vnd.ms-excel');
     // It will be called file.xls
     header('Content-Disposition: attachment; filename="users.xls"');
     // Write file to the browser
     $objWriter->save('php://output');
     exit;
 }
Пример #7
0
 public function index()
 {
     $perPage = 999999;
     $page = @$_GET['page'] ? $_GET['page'] : 1;
     $start = ($page - 1) * $perPage;
     $where = [];
     $whereParam = [];
     if (!empty($_GET['room_id'])) {
         $where[] = "room_id = ?";
         $whereParam[] = $_GET['room_id'];
     }
     $whereString = implode("AND", $where);
     $items = R::find('room_pattern', $whereString . ' LIMIT ?,?', array_merge($whereParam, [$start, $perPage]));
     $count = R::count('room_pattern', $whereString, $whereParam);
     $maxPage = floor($count / $perPage) + ($count % $perPage == 0 ? 0 : 1);
     $itemsExport = R::exportAll($items);
     $this->builds($itemsExport);
     header('Content-Type: application/json');
     echo json_encode(['items' => $itemsExport, 'page' => $page, 'maxPage' => $maxPage, 'total' => $count], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
     exit;
 }
Пример #8
0
            foreach ($board->sharedUser as $user) {
                if ($user->defaultBoard == $data->boardId) {
                    $user->defaultBoard = null;
                    R::store($user);
                }
            }
            R::trashAll($board->xownLane);
            R::trashAll($board->xownCategory);
            R::trash($board);
            R::exec('DELETE from board_user WHERE board_id = ?', [$data->boardId]);
            $jsonResponse->addAlert('success', 'Removed board ' . $board->name . '.');
            $actor = getUser();
            logAction($actor->username . ' removed board ' . $board->name, $before, null);
        }
        $jsonResponse->addBeans(getBoards());
        $jsonResponse->users = R::exportAll(getUsers());
    }
    $app->response->setBody($jsonResponse->asJson());
});
$app->post('/autoactions', function () use($app, $jsonResponse) {
    $data = json_decode($app->environment['slim.input']);
    if (validateToken(true)) {
        $board = R::load('board', $data->boardId);
        if ($board->id) {
            $autoAction = R::dispense('autoaction');
            $autoAction->triggerId = $data->triggerId;
            $autoAction->secondaryId = $data->secondaryId;
            $autoAction->actionId = $data->actionId;
            $autoAction->color = $data->color;
            $autoAction->categoryId = $data->categoryId;
            $autoAction->assigneeId = $data->assigneeId;
Пример #9
0
function getNextItemPosition($columnId)
{
    $retVal = 0;
    $column = R::load('lane', $columnId);
    if ($column->id) {
        $options = R::exportAll(getUser()->ownOption);
        if ($options[0]['tasks_order'] == 1) {
            // Tasks at top of column.
            renumberItems($columnId, 0, false);
        } else {
            try {
                $retVal = $column->countOwn('item');
            } catch (Exception $e) {
                // Ignore, just means there are no items.
            }
        }
    }
    return $retVal;
}
Пример #10
0
            R::store($user);
            addUserToBoard($data->defaultBoard, $user);
            foreach ($data->boardAccess as $board) {
                addUserToBoard($board, $user);
            }
            logAction($actor->username . ' updated user ' . $user->username, $before, $user->export());
            $jsonResponse->addAlert('success', 'User updated.');
        }
        $jsonResponse->addBeans(getUsers());
        $jsonResponse->boards = R::exportAll(getBoards());
    }
    $app->response->setBody($jsonResponse->asJson());
});
// Remove a user.
$app->post('/users/remove', function () use($app, $jsonResponse) {
    $data = json_decode($app->environment['slim.input']);
    if (validateToken(true)) {
        $user = R::load('user', $data->userId);
        $actor = getUser();
        if ($user->id == $data->userId && $actor->isAdmin) {
            $before = $user->export();
            R::trash($user);
            R::exec('DELETE from board_user WHERE user_id = ?', [$data->userId]);
            logAction($actor->username . ' removed user ' . $before['username'], $before, null);
            $jsonResponse->addAlert('success', 'Removed user ' . $user->username . '.');
        }
        $jsonResponse->addBeans(getUsers());
        $jsonResponse->boards = R::exportAll(getBoards());
    }
    $app->response->setBody($jsonResponse->asJson());
});
Пример #11
0
    if ($customer) {
        if (isset($customer->website)) {
            $customer->website = (string) $input->website;
        }
        if (isset($input->ownOptions)) {
            foreach ($input->ownOptions as $option) {
                $customerOption = \RedBeanPHP\R::dispense("options", 1);
                foreach ($option as $key => $val) {
                    $customerOption->{$key} = $val;
                }
                $customer->ownOptions[] = $customerOption;
            }
        }
        \RedBeanPHP\R::store($customer);
        $app->response()->header('Content-Type', 'application/json');
        echo json_encode(\RedBeanPHP\R::exportAll($customer));
    } else {
        $app->response()->status(404);
    }
});
// handle DELETE requests
$app->delete('/customers/:id', function ($id) use($app) {
    //\RedBeanPHP\R::dependencies(array('options'=>array('customers')));
    // retrieve specified element record
    $customer = \RedBeanPHP\R::findOne('customers', 'id = ?', array($id));
    if ($customer) {
        \RedBeanPHP\R::trashAll($customer->ownOptions);
        \RedBeanPHP\R::trash($customer);
        $app->response()->status(204);
    } else {
        $app->response()->status(404);