Example #1
0
 public function getHREF()
 {
     $dir = $this->getUploadDir();
     $dir = array_keys($dir);
     $dir = array_pop($dir);
     return AdminHREF::getDefaultAdminRouteUri('dataEdit', $this->getShortName()) . '/' . urlencode($dir) . '/?ref=' . urlencode(AdminHREF::getFullCurrentHREF());
 }
Example #2
0
 public static function getCommonColumns()
 {
     $request = Request::initial();
     $id = $request->param('primary');
     $cart = ORM::factory('Orders', $id);
     return ['user_id' => ['dont_select' => true, 'label' => 'Пользователь', 'type' => 'caption', 'get_current_value' => function () use($cart) {
         $user = ORM::factory('User', $cart->user_id);
         if (!empty($user->id)) {
             return $user->username . ' <a href="/admin/dataEdit/Users/' . $user->id . '/?ref=' . urlencode(AdminHREF::getFullCurrentHREF()) . '">Просмотр пользователя</a>';
         }
         return 'Пользователь неопознан, его ID=' . $user->id;
     }], 'date' => ['label' => 'Дата', 'type' => 'date'], 'time' => ['label' => 'Время', 'type' => 'time'], 'cart' => ['label' => 'Корзина', 'type' => 'caption', 'dont_select' => true, 'get_current_value' => function () use($cart) {
         $cart = unserialize($cart->cart);
         $render = '';
         $sum = 0;
         if (is_array($cart) && !empty($cart)) {
             foreach ($cart as $good) {
                 $sum += $good['price'] * $good['count'];
                 $render .= "<div style='display:inline-block;padding: 5px;'><div><img class='previewAdminImage' src=\"/" . $good['image'] . "\"/> x " . $good['count'] . '</div>';
                 $render .= "<div> Артикул: " . ORM::factory('Articles', $good['article_id'])->article . "</div>";
                 $render .= "<div> Багет: " . $good['bag'] . "</div>";
                 $render .= "<div> Размер: " . $good['width'] . 'x' . $good['height'] . "</div></div>";
             }
             $render .= "<div> Сумма: " . $sum . " руб.</div>";
         }
         return $render;
     }], 'completed' => ['label' => 'Выполнен', 'type' => 'bool']];
 }
Example #3
0
 public function getActionButtons()
 {
     $buttons = parent::getActionButtons();
     $ref = urlencode(AdminHREF::getFullCurrentHREF());
     $changePass = function ($row) use($ref) {
         $href = AdminHREF::getDefaultAdminRouteUri('dataEdit', 'UsersPasswords', $row['id']) . '/?ref=' . $ref;
         $text = '<i class="fa fa-lock gc"></i>';
         return '<a title="Сменить пароль"  href="' . $href . '">' . $text . '</a>';
     };
     $changeRoles = function ($row) use($ref) {
         $href = AdminHREF::getDefaultAdminRouteUri('dataEdit', 'UsersRoles', $row['id']) . '/?ref=' . $ref;
         $text = '<i class="fa fa-user-secret gc"></i>';
         return '<a title="Роли пользователя" href="' . $href . '">' . $text . '</a>';
     };
     $loginUser = function ($row) use($ref) {
         $href = AdminHREF::getDefaultAdminRouteUri('loginuser', 'users', $row['id']);
         $text = '<i class="fa fa-sign-in gc"></i>';
         return '<a title="Войти от имени пользователя" href="' . $href . '">' . $text . '</a>';
     };
     $buttons['Роли пользователя'] = $changeRoles;
     $buttons['Сменить пароль'] = $changePass;
     $buttons['Войти'] = $loginUser;
     return $buttons;
 }
Example #4
0
<?php

if (!empty($caption)) {
    ?>
    <div class="captionDiv">
        <h4><?php 
    echo $caption;
    ?>
</h4>
    </div>
    <?php 
}
?>

<div class="list-group">
    <?php 
foreach ($values as $key => $value) {
    ?>
        <a class='list-group-item' href='<?php 
    echo AdminHREF::getFullCurrentHREF() . '/' . $key;
    ?>
'>
            <?php 
    echo $value;
    ?>
        </a>
        <?php 
}
?>
</div>
Example #5
0
 public function getActionButtons()
 {
     $buttons = [];
     $ref = urlencode(AdminHREF::getFullCurrentHREF());
     $edit = function ($row) use($ref) {
         $href = AdminHREF::getDefaultAdminRouteUri('dataEdit', $this->getShortName(), $row['id']) . '/?ref=' . $ref;
         $text = '<i class="fa fa-pencil gc"></i>';
         return '<a class="editHref"  title="Редактировать"  href="' . $href . '">' . $text . '</a>';
     };
     $delete = function ($row) use($ref) {
         $href = AdminHREF::getDefaultAdminRouteUri('dataDelete', $this->getShortName(), $row['id']) . '/?ref=' . $ref;
         $text = '<i class="fa fa-trash-o gc"></i>';
         return '<a class="delHref confirm" title="Удалить" confirmText="Вы уверены в удалении товара?" href="' . $href . '">' . $text . '</a>';
     };
     if ($this->isModifyingAllowed()) {
         $buttons['Редактировать'] = $edit;
     }
     if ($this->isDeletionAllowed()) {
         $buttons['Удалить'] = $delete;
     }
     return $buttons;
 }
Example #6
0
 public function action_dataInsert()
 {
     if ($this->check(['isAllowed', 'isModifyingAllowed'], ['getInsertColumns']) === true) {
         $menuItems = [self::getMainMenu()];
         $modelInfo = $this->model->getInfo();
         $menuItems[] = ['href' => AdminHREF::getFullCurrentHREF(), 'caption' => $this->model->getCaption() . '&rarr; Добавление'];
         $insertData = $this->model->getInsertColumns();
         $table = $insertData['tableName'];
         $columns = $insertData['columns'];
         $validate = function () {
             return true;
         };
         if (isset($insertData['validate']) && is_callable($insertData['validate'])) {
             $validate = $insertData['validate'];
         }
         $uploadsDirs = [];
         if (!empty($insertData['uploadsDirs'])) {
             $uploadsDirs = $insertData['uploadsDirs'];
         }
         $afterInsert = function () {
         };
         if (isset($insertData['afterInsert']) && is_callable($insertData['afterInsert'])) {
             $afterInsert = $insertData['afterInsert'];
         }
         $insert = function ($table, $post) {
             return DB::insert($table, array_keys($post))->values(array_values($post))->execute();
         };
         if (isset($insertData['insert']) && is_callable($insertData['insert'])) {
             $insert = $insertData['insert'];
         }
         $message = null;
         $messageType = null;
         $post = [];
         if (!empty($_POST)) {
             $message = 'Успешно добавлено';
             $messageType = 'success';
             $post = $_POST;
             if (isset($post['files'])) {
                 unset($post['files']);
             }
             $valid = $validate($post);
             if ($valid === true) {
                 try {
                     $insert = $insert($table, $post);
                     $afterInsert($insert[0]);
                     if (!empty($uploadsDirs)) {
                         $files = Admin::getPostFiles();
                         foreach ($files as $directoryIndex => $fileItems) {
                             if (!empty($uploadsDirs[$directoryIndex])) {
                                 $uploadsDirs[$directoryIndex]['directory'] = str_replace('<primary>', $insert[0], $uploadsDirs[$directoryIndex]['directory']);
                                 foreach ($fileItems as $file) {
                                     $this->upload($uploadsDirs[$directoryIndex], $file);
                                 }
                             }
                         }
                     }
                     $post = [];
                 } catch (Database_Exception $e) {
                     $messageType = 'danger';
                     $message = 'При добавлении записи произошла ошибка:<br/><br/>' . $e->getMessage() . "<br/><br/>Исправьте ошибку и повторите попытку или обратитесь к администратору";
                 }
             } else {
                 $messageType = 'danger';
                 $message = $valid;
             }
         }
         $content = View::factory('Admin/Data/Insert/Template', ['columns' => $columns, 'post' => $post, 'model' => $this->model, 'message' => $message, 'messageType' => $messageType, 'uploadsDirs' => $uploadsDirs]);
         $menuItems[] = self::getSiteMenu();
         $menuItems[] = self::getLogoutMenu();
         $menu = View::factory('Admin/Menu/Template', ['items' => $menuItems]);
         $this->template->content = $menu . $content;
     }
 }
Example #7
0
<?php

$reference = urlencode(empty($ref) ? AdminHREF::getFullCurrentHREF() : $ref);
?>
<div class="uploadsBlock">
    <?php 
if (!empty($files)) {
    $charsLimit = 20;
    $deletion = '';
    $croping = '';
    $descriptioning = '';
    $makeFirst = '';
    foreach ($files as $file) {
        $descriptioning = Upload::getDescription($file);
        ?>
            <div class='upload'>
                <?php 
        $class = 'otherUpload';
        if (Admin::isImageFile($file)) {
            $class = 'imageUpload';
        } elseif (Admin::isAudioFile($file)) {
            $class = 'audioUpload';
        }
        ?>
                
                <?php 
        if ($model->isDeletionAllowed()) {
            $delHref = AdminHREF::getDefaultAdminRouteUri('ajaxUploadDelete', $model->getShortName(), $params['primary']) . '/?directoryIndex=' . urlencode($directoryIndex) . '&file=' . urlencode(basename($file));
            $deletion = '<button ' . 'type="button" ' . 'class="ajaxUploadsDelete" ' . 'confirmText="Вы уверены в удалении?" ' . 'href="' . $delHref . '">' . '<i class="fa fa-trash-o"></i> ' . 'Удалить' . '</button>';
        }
        ?>
Example #8
0
    }
    ?>
        <?php 
    if (count($months) > 1) {
        ?>
            <ul class="nav nav-pills">
                <?php 
        foreach ($months as $month) {
            ?>
                    <li role="presentation"
                        class="<?php 
            echo $month == $currentMonth ? 'active' : '';
            ?>
">
                        <a href="<?php 
            echo AdminHREF::getFullCurrentHREF([], ['year' => $currentYear, 'month' => $month]);
            ?>
">
                            <?php 
            echo FieldString::translateMonthRuFromNumber($month);
            ?>
                        </a>
                    </li>
                    <?php 
        }
        ?>
            </ul>

            <?php 
    }
    ?>
Example #9
0
<div class="authFormNew">
    <form role="form"
          action='<?php 
echo AdminHREF::getDefaultAdminRouteUri('auth');
?>
?ref=<?php 
echo urlencode(AdminHREF::getFullCurrentHREF());
?>
'
          method="post">
        
        <?php 
if (!empty($embed)) {
    ?>
            <div class="alert alert-info">
                Для оформления заказа войдите на сайт или зарегистрируйтесь
            </div>
            <?php 
}
?>
        
        <?php 
if (empty($embed)) {
    ?>
            <div class="form-group">
                <h4 class="text-center">
                    <i class="fa fa-lock"></i>
                    Вход на сайт
                </h4>
            </div>
            <?php 
Example #10
0
 public function getHREF()
 {
     return AdminHREF::getDefaultAdminRouteUri('dataEdit', $this->getShortName(), Auth::instance()->get_user()) . '?ref=' . urlencode(AdminHREF::getFullCurrentHREF());
 }
Example #11
0
"><?php 
        echo $i;
        ?>
</a>
                </li>
                <?php 
    }
    ?>
            
            <?php 
    if ($pages > $spaces) {
        ?>
            
            <?php 
        //last page
        $href = AdminHREF::getFullCurrentHREF([], [$getParam => $pages]);
        ?>
            <li<?php 
        echo AdminHREF::isActiveHREF($href, $page == $pages) ? ' class="active" ' : '';
        ?>
>
                <a href="<?php 
        echo $href;
        ?>
">Последняя &rarr;</a>
            </li>
        
        <?php 
    }
    ?>