Beispiel #1
0
 public function run()
 {
     $model = new Leadership();
     if (isset($_POST['manager']) && $_POST['supervisor']) {
         $model->setIsNewRecord(false);
         $model->manager = $_POST['manager'];
         $model->supervisor = $_POST['supervisor'];
         if ($model->delete()) {
             echo 'Ok, deleted';
             Yii::app()->end();
         }
     }
     throw new CHttpException(404);
 }
Beispiel #2
0
 public function index()
 {
     $lang = Cookie::get('lang', 'ru');
     $leaders = Leadership::select("lead_fio_{$lang}", "lead_post_{$lang}", "lead_text_{$lang}", "lead_photo", "lead_email", "lead_phone")->get();
     $news = News::select('news_id', 'news_alias', "news_title_{$lang}", "updated_at")->orderBy('updated_at', 'DESC')->limit(5)->get();
     $cookie = Cookie::make('page', 'about_us', 60 * 24 * 180);
     $view = View::make('leaders')->with(array('leaders' => $leaders, 'news' => $news, 'lang' => $lang));
     return Response::make($view)->withCookie($cookie);
 }
Beispiel #3
0
 public function run()
 {
     if (isset($_POST['Leadership'])) {
         $data = $_POST['Leadership'];
         //Проверяем на наличие записи в БД
         $condition = 'manager=:manager and supervisor=:supervisor';
         $params = array(':manager' => (int) $data['manager'], ':supervisor' => (int) $data['supervisor']);
         if (!Leadership::model()->exists($condition, $params)) {
             //Сохраняем модель
             $model = new Leadership();
             $model->attributes = $data;
             if ($model->save()) {
                 echo 'Ok, saved';
             }
         } else {
             echo 'Ok, record exists.';
         }
         Yii::app()->end();
     }
     throw new CHttpException(404, 'Invalid data!');
 }
require '../inc/classes/Helpers.php';
// page vars
$page_title = "";
$id = $_REQUEST['id'];
// id required
if ($id == "") {
    header("Location:mainpage.php");
    exit;
}
// if form was submitted
if ($_POST['commit'] == "Cancel") {
    header("Location:leadership_list.php");
    exit;
}
if ($_POST['commit'] == "Delete Leadership") {
    $objLeadership = new Leadership();
    $objLeadership->Delete($id);
    header("Location:leadership_list.php");
    exit;
}
$objLeadership = new Leadership($id);
include "includes/pagetemplate.php";
function PageContent()
{
    global $objLeadership;
    global $id;
    ?>

            <div class="layout laymidwidth">

                <?php 
}
if ($_POST['commit'] == "Save Leadership") {
    if ($id == 0) {
        // add the listing
        $objLeadership = new Leadership();
        $objLeadership->LeaderName = $_REQUEST["leader_name"];
        $objLeadership->LeaderTitle = $_REQUEST["leader_title"];
        $objLeadership->LinkedIn = $_REQUEST["linked_in"];
        $objLeadership->Create();
        $objLeadership->HandleFileUploads();
        $objLeadership->HandleDropFileUploads($aDropFields[0], 'ImageFile');
        // redirect to listing list
        header("Location:leadership_list.php");
        exit;
    } else {
        $objLeadership = new Leadership($_REQUEST["id"]);
        $objLeadership->LeaderName = $_REQUEST["leader_name"];
        $objLeadership->LeaderTitle = $_REQUEST["leader_title"];
        $objLeadership->LinkedIn = $_REQUEST["linked_in"];
        $objLeadership->Update();
        $objLeadership->HandleFileUploads();
        $objLeadership->HandleDropFileUploads($aDropFields[0], 'ImageFile');
        // redirect to listing list
        header("Location:leadership_list.php");
        exit;
    }
} else {
    if ($_REQUEST['mode'] == 'e') {
        //listing
        $objLeadership = new Leadership($id);
        $leader_name = $objLeadership->LeaderName;
function PageContent()
{
    ?>
    
        <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
        <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
        <script type="text/javascript">
            $(document).ready(function() {
                // fix to preserve width of cells
                var fixHelper = function(e, ui) {
                    ui.children().each(function() {
                        $(this).width($(this).width());
                    });
                    return ui;
                };
                var saveIndex = function(e, ui) {
                    //alert("New position: " + ui.item.index());
                    //alert("Image Id: " + ui.item.attr("id"));
                    id = ui.item.attr("id").replace("img_", "");
                    $.ajax({
                        url: 'leadership_list.php',
                        data: {
                            dragsort: 1,
                            idx: ui.item.index(),
                            id: id
                        },
                        type: 'POST',
                        dataType: 'html',
                        success: function (data) {
                            //alert("done");
                        },
                        error: function (xhr, status) {
                            alert('Sorry, there was a problem!');
                        }
                    });
                }; // end saveIndex
    
                $("#list_table tbody").sortable({
                    helper: fixHelper,
                    stop: saveIndex
                }).disableSelection();
    
            }); // end document.ready
        </script>
        <style>
            .icon-resize-vertical:hover {
                cursor:grab;
            }
        </style>        
    
            <div class="layout center-flex">

                <?php 
    $aLabels = array();
    $aLinks = array();
    $aLabels[0] = 'Home';
    $aLinks[0] = 'mainpage.php';
    $aLabels[1] = 'Leadership';
    $aLinks[1] = '';
    echo Helpers::CreateBreadCrumbs($aLabels, $aLinks);
    ?>

                <div class="bigbotspace flex-container space-between">
                    <p class="larger auto heading">Leadership</p>
                    <button class=" "><a href="leadership_admin.php" class="button_link">Add New Leadership</a></button>
                </div>
            </div>
    
            <div class="layout">
    
                <table class="tablestyle" id="list_table">
                    <thead>
                        <tr>
                            <th>ID</th>
                            <th>Name</th>
                            <th>Title</th>
                            <th>Image</th>
                            <th class="mid">Order</th>
                            <th class="mid">Actions</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php 
    $objLeadership = new Leadership();
    $oLeadership = $objLeadership->GetAllLeadership('sort_order');
    foreach ($oLeadership as $leadership) {
        echo '<tr id="img_' . $leadership->Id . '">' . PHP_EOL;
        echo '<td style="vertical-align: top;">' . $leadership->Id . '</td>' . PHP_EOL;
        echo '<td style="vertical-align: top;">' . $leadership->LeaderName . '</td>' . PHP_EOL;
        echo '<td style="vertical-align: top;">' . $leadership->LeaderTitle . '</td>' . PHP_EOL;
        echo '<td>';
        if ($leadership->ImageFile != '') {
            echo '<img src="/' . $objLeadership->GetPath() . $leadership->ImageFile . '" width="100" />';
        } else {
            echo '&nbsp;';
        }
        echo '</td>' . PHP_EOL;
        echo '<td class="mid" style="vertical-align: top;"><img src="img/arrow-up-down.png" /></td>' . PHP_EOL;
        echo '<td class="mid" style="vertical-align: top;"><a href="leadership_admin.php?id=' . $leadership->Id . '"><img src="img/edit-icon.png" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="leadership_delete.php?id=' . $leadership->Id . '"><img src="img/delete-icon.png" /></a></td>' . PHP_EOL;
        echo '</tr>' . PHP_EOL;
    }
    ?>
                    </tbody>
                </table>
    
            </div> <!-- layout -->
    
<?php 
}