在删除时,在codeigniter弹出窗口中替换用户

时间:2015-05-26 06:01:36

标签: javascript php jquery codeigniter

如果用户在userview文件中有任何已分配的任务,我想替换下拉列表,然后确认框应该出现

 <link href="<?php echo PLUGIN_URL; ?>fancybox/source/jquery.fancybox.css" rel="stylesheet" type="text/css"/>
    <link href="<?php echo CSS_URL; ?>pages/portfolio.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="<?php echo PLUGIN_URL; ?>jquery-mixitup/jquery.mixitup.min.js"></script>
    <script type="text/javascript" src="<?php echo PLUGIN_URL; ?>fancybox/source/jquery.fancybox.pack.js"></script>  
    <script>
    var tblList = null;
    var statusSelected = 0;
    $(document).ready(function(){
        $('.mix-grid').mixitup(); 
        $('#show_as_list, #outtaHere10, #outtaHere11, #outtaHere20').change(function(event){
            statusSelected = 0;
            manageViews();
            event.preventDefault();
        });

        $('.status-filter').click(function(event){
            statusSelected = $(this).attr('data-filter');
            manageViews();
            event.preventDefault();
        });
    });

    function manageViews(){
        if($('#show_as_list').attr('checked') === "checked"){
            if($('#users_list tbody').length == 0){
                initializeTbl();
            }else{
//                initializeTbl();
                tblList.fnDraw(true);
            }
            $('.list_view').css('display','block');
            $('.mix-grid').css('display','none');
        } else{
            $('.list_view').css('display','none');
            $('.mix-grid').css('display','block');
        }
    }

    function initializeTbl(){
        tblList = $('#users_list').dataTable({

            "bJQueryUI": false,
            "aaSorting": [],
            "bProcessing": true,
            "bServerSide": true,
            "bInfo": true,
            "sPaginationType": "full_numbers",
            "bPaginate": false,
            "iDisplayLength":25,
            "iDisplayStart":0,
             "aoColumns": [
                null,
                { "bSortable": false }
            ],

            "aLengthMenu": [[10, 25, 50,100, -1], [10, 25, 50,100, "All"]],
            "bFilter": true,
            "aoColumns":[{sWidth : '20%'},{sWidth : '20%'},{sWidth : '20%'},null,{sWidth : '5%'},null],
            "fnServerParams": function ( aoData ) {

                aoData.push( 

                { "name": "status", "value": statusSelected },
                { "name": "company", "value": $('#outtaHere10').val() },
                { "name": "team", "value": $('#outtaHere11').val() },

                { "name": "project", "value": $('#outtaHere20').val() });

            },

            "sAjaxSource": "<?php echo base_url(); ?>datatable/getUsersForList/"
        });

    }

    function deleteRow(ele){
        var current_id = ele;
        //alert(ele);

        //alert(http_host_js+'news/delete_news_detail/'+current_id);


        $.confirm({
            'title'     : 'Delete User',
            'message'   : 'Would u like to delete user ?',
            //jConfirm('Are you shure?', function() {
            //jAlert('You click "OK"')}, 'Title')
            'buttons'   : {
                'yes'   : {'class'  : 'blue',
                    'action': function(){
                         $.ajax({

                            //alert:'hello',
                            type : 'POST',
                            url : base_url+'users/delete_user/',
                            data: {'id':current_id} ,

                            success: function() {

                                window.open(base_url+'users','_self');

                            },
                            error : function(XMLHttpRequest, textStatus, errorThrown) {
                                alert('error');
                            }
                        }); 
                    }
                },
                'No'    : {
                    'class' : 'gray',
                    'action': function(){}  // Nothing to do in this case. You can as well omit the action property.
                }
            }
        });
        return false;
    }  
</script>

<div class="row">
    <!-- BEGIN FILTER -->           
    <div class="row mix-grid"><?php //var_dump($query); ?>
        <?php foreach ($query as $row): ?>
            <?php

            if($row->TEAM_ID != ' '){
             $teamid = explode(',', $row->TEAM_ID); 
             //echo $row->TEAM_ID;

            }else{
               $teamid = ''; 
            }
            $project_id_list = $this->user_model->get_project_id_list($row->id);  
            $false_image = base_url() . "assets/images/icon-trash.png";
            $url = base_url() . "assets/upload/images/users/" . $row->PHOTO;
            if ($row->STATUS == 'Active') {
                $status_image = base_url() . "assets/images/green.png";
            } else {
                $status_image = base_url() . "assets/images/red.png";
            }

            $default_image = get_default_image();
            $default_user_image = base_url() . "assets/upload/images/default_image/" . $default_image[0]->VALUE_CHAR;
            ?>
            <div class="col-md-2 col-sm-2 mix <?php if ($row->STATUS == 'Active') { echo $row->STATUS; } else { echo "Inactive"; } ?> <?php echo 'c'.$row->CLT_ID; ?> <?php foreach ($project_id_list as $project_value){ echo "p".$project_value->PJT_ID.' '; } ?>   <?PHP if(isset($teamid) and $teamid != '') { foreach ($teamid as $tid) {echo "t".$tid.' ';}}?>">
                <div class="mix-inner">
                    <?php if (isset($row->PHOTO) && $row->PHOTO != '') { ?>
                        <img class="img-responsive" src="<?php echo $url; ?>" alt="" style="height: 200px;width: 200px;">
    <?php } else { ?>
                        <img class="img-responsive" src="<?php echo $default_user_image; ?>" alt="" style="height: 200px;width: 200px;">
    <?php } ?>
                    <div class="mix-details">
                        <h5>&nbsp;</h5>
                        <h5><?php echo $row->FIRST_NAME; ?></h5>
                        <h5><?php echo $row->EMAIL_ADDRESS; ?></h5>
                        <h5><a href="<?php echo base_url(); ?>project/user/<?php echo $row->id; ?>"><?php echo $row->count_project; ?>&nbsp;Projects</a></h5>
                        <a class="mix-preview fancybox-button" href="<?php echo base_url(); ?>users/edit/<?php echo $row->id; ?>" title="<?php echo $row->FIRST_NAME; ?>" data-rel="fancybox-button"><i class="fa fa-search"></i></a>
                    </div>
                </div>
            </div>


<?php endforeach; ?>
    </div>
    <!-- END FILTER -->    
</div>
<div class="row list_view">
    <div class="col-md-12">
        <!-- BEGIN SAMPLE FORM PORTLET-->   
        <div class="portlet box">
            <div class="portlet-body">
                <form class="form">
                    <div class="row">
                        <div class="col-md-12">
                            <div class="responsive" >
                                <table class="table table-striped table-bordered table-hover td-wrap-on" id="users_list">
                                    <thead>
                                        <tr>
                                            <th><?php echo $this->lang->line("Name"); ?></th>
                                            <th>Mail Address</th>
                                            <th>Company Name</th>
                                            <th>Teams</th>
                                            <th>Status</th>
                                            <th></th>
                                        </tr>
                                    </thead>
                                </table>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <!-- END SAMPLE FORM PORTLET-->
    </div>
</div>

0 个答案:

没有答案