PageRenderTime 83ms CodeModel.GetById 67ms app.highlight 12ms RepoModel.GetById 1ms app.codeStats 0ms

/magehelp/application/views/acl/role_grid.php

https://bitbucket.org/jit_bec/shopifine
PHP | 215 lines | 178 code | 21 blank | 16 comment | 5 complexity | 7cc430d63cc0d8d0ac211aa0ccec2b0f MD5 | raw file
  1<html>
  2    <head>
  3       <?php $this->load->view("common/header"); ?>
  4<!--        <script type="text/javascript" src="http://jzaefferer.github.com/jquery-validation/jquery.validate.js"></script>-->
  5        <link rel="stylesheet" rev="stylesheet" href="<?php echo base_url();?>css/shopifine.css" />
  6        <link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url(); ?>css/ui.jqgrid.css" />
  7        <link rel="stylesheet" rev="stylesheet" href="<?php echo base_url();?>css/chosen.css" />
  8        <script src="<?php echo base_url(); ?>js/i18n/grid.locale-en.js" type="text/javascript"></script>
  9        <script src="<?php echo base_url(); ?>js/jquery.jqGrid.min.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
 10        <script src="<?php echo base_url();?>js/chosen.jquery.min.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
 11<!--        <script src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/rollups/md5.js"></script>-->
 12         <script>
 13            $(document).ready(function(){
 14                
 15                
 16                //user grid
 17                $("#roleform").validate();
 18                
 19                
 20                var myGrid = $("#roles"),lastsel2;
 21                var editparameters = {
 22                    "keys" : true,
 23                    "oneditfunc" : null,
 24                    "successfunc" : function(){
 25                        var successStatus = "Roles successfully edited";
 26                        showSuccessMessage(successStatus);
 27                        lastsel2=undefined;
 28                        myGrid.trigger("reloadGrid");
 29                        return true;
 30                    },
 31                    "aftersavefunc" : null,
 32                    "errorfunc": function(response)
 33                        {
 34                            var errorStatus = " Roles could not be updated due to internal error";
 35                            showErrorMessage(errorStatus);
 36                            lastsel2=undefined;
 37                        },
 38                    "afterrestorefunc" : null,
 39                    "restoreAfterError" : true,
 40                    "mtype" : "POST"
 41                };
 42                myGrid.jqGrid({
 43                    url:'index.php/acls/populateRoles',
 44                    datatype: 'json',
 45                    mtype: 'GET',
 46                    colNames:['Role','Parent Role'],
 47                    colModel :[ 
 48                        {name:'role_id', index:'role_id', width:120, align:'right',editable:true,edittype:"select",editoptions:{dataUrl:"index.php/acls/populateRolesEdit",buildSelect:function(response)
 49                        {
 50                            var select = "<select name=" + "parentOpEdit" + "id =" +"parentOpEdit" +">" +
 51                                        "<option value=" + ">Select one..." + response + "</select>";
 52                                    
 53                            return select;
 54                        }}},
 55                        /*{name:'description',index:'description', width:120, align:'right',editable:true,editoptions:{size:"20",maxlength:"30"}},*/
 56                        {name:'parent_role_id', index:'parent_role_id', width:120, align:'right',editable:true,edittype:"select",editoptions:{dataUrl:"index.php/acls/populateRolesEdit",buildSelect:function(response)
 57                        {
 58                            var select = "<select name=" + "parentOpEdit" + "id =" +"parentOpEdit" +">" +
 59                                        "<option value=" + ">Select one..." + response + "</select>";
 60                                    
 61                            return select;
 62                        }}},
 63                        
 64                    ],
 65                    pager: '#pager',
 66                    rowNum:10,
 67                    rowList:[5,10,20],
 68                    sortname: 'id',
 69                    sortorder: 'desc',
 70                    viewrecords: true,
 71                    gridview: true,
 72                    ignoreCase:true,
 73                    rownumbers:true,
 74                    height:'auto',
 75                    width:'300px',
 76                    caption: 'Roles',
 77            
 78                    jsonReader : {
 79                        root:"roledata",
 80                        page: "page",
 81                        total: "total",
 82                        records: "records",
 83                        cell: "dprow",
 84                        id: "id"
 85                    },
 86                    onSelectRow: function(id){if(id && id!==lastsel2){
 87                            myGrid.restoreRow(lastsel2);
 88                            myGrid.editRow(id,editparameters);
 89                            lastsel2=id;
 90                        }
 91                    },
 92                    editurl:'index.php/acls/editRoleInheritance'
 93                    
 94                }).navGrid("#pager",{edit:false,add:true,del:false,search:false},
 95               /* edit Option*/ {height:280,reloadAfterSubmit:false,closeAfterEdit:true,recreateForm:true,checkOnSubmit:true},
 96            /* Add Option*/     {reloadAfterSubmit:true,recreateForm:true /*, beforeShowForm:function(form){
 97                                var roleElem = $("#tr_role_name",form);
 98                                $('<tr class="FormData" id="tr_username" disply>\n\
 99                                    <td class="CaptionTD">User Name</td>\n\
100                                    <td class="DataTD">&nbsp;<input type="text" size="20" maxlength="30" id="username" \n\
101                                    name="username" role="textbox" class="FormElement ui-widget-content ui-corner-all">\n\
102                                    </td></tr>').insertBefore(roleElem);
103                                $('<tr class="FormData" id="tr_password">\n\
104                                    <td class="CaptionTD">Temporary Password</td>\n\
105                                    <td class="DataTD">&nbsp;<input type="text" size="20" maxlength="30" id="password" \n\
106                                    name="password" role="textbox" class="FormElement ui-widget-content ui-corner-all">\n\
107                                    </td></tr>').insertBefore(roleElem);
108                                                   
109                                }            */      
110                                ,afterSubmit: function (response,postdata){
111                                var success = false;
112                                var message;
113                                var res = response.responseText;
114                                if (res == 'error')
115                                    return [false,'This Parent Already Exists for Role'];
116                                else {
117                                    return [true,''];
118                                }
119
120
121                                } 
122                },{},{},{});
123               
124                myGrid.jqGrid('filterToolbar', {stringResult: true, searchOnEnter: true, defaultSearch : "cn"});
125                
126                $("#addBtn").click(function(e){
127                    //e.preventDefault();
128                        var bValid =  $("#roleform").valid();
129                        if (bValid ){
130                            var name = $("#name").val();
131                            var parent = $("#parentOptions").val();
132                            console.log(parent);
133                            $.ajax({url:"index.php/acls/createRole",
134                                    type:"POST",
135                                    data:{name:name,parent:parent},
136
137                                    success:function(response)
138                                    {
139                                        var successStatus = "Role successfully added";
140                                        showSuccessMessage(successStatus);
141                                        myGrid.trigger("reloadGrid");
142                                    },
143                                    error:function(response)
144                                    {
145                                        var errorStatus = " Role could not be added due to internal error";
146                                        showErrorMessage(errorStatus);
147                                    }
148                        })
149                    }
150                });
151                    
152            });
153        </script>
154    </head>
155     
156    <body>
157         <?php $this->load->view("common/menubar"); ?>
158        
159        <div style="display: block;height: 500px;width:50%;left:0em;margin:0 auto;" class="shopifine-ui-dialog ui-widget ui-widget-content ui-corner-all" tabindex="-1" role="dialog" aria-labelledby="ui-dialog-title-dialog-form">
160            <div class="form-container">
161                <div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix">
162                    <span class="ui-dialog-title" id="ui-dialog-title-dialog-form">&nbsp;</span>
163                    <a href="#" class="ui-dialog-titlebar-close ui-corner-all" role="button">
164
165                    </a>
166                </div>
167                <div  class="ui-dialog-content" style="width: auto; min-height: 65.1333px; height: auto;" scrolltop="0" scrollleft="0">
168                    <h1 id="formHeader">Add Role </h1> 
169                    <form id="roleform" class="single-column-form" style="left:0%">
170                        <fieldset>
171                            <div class="row single-column-row">
172                                <div class="column single-column">
173                                <div class="field">
174                                        <label for="name">Name of Role :</label>  
175                                        <input id="name" name ="name" type="text" class="required"/>  
176                                    </div> 
177                                </div>
178                                
179                            </div>
180                            <div class="row single-column-row">
181                                <div class="column single-column">
182                                    <div class="field">
183                                        
184                                        <label for="parentOptions">Choose Parents :</label>  
185                                        <select name="parentOptions[]" id ="parentOptions" class="chzn-select" multiple="multiple" style="width:200px;height:20px;"> 
186                                                <option value="">Choose 
187                                                <?=$roleOptions?> 
188                                        </select>
189                                    </div>
190                                </div>
191                            </div>
192                            
193                        </fieldset>
194                    </form>
195                </div>
196                <div class="ui-dialog-buttonpane shopifine-ui-widget-content ui-helper-clearfix">
197                    <div class="shopifine-ui-dialog-buttonset">
198                        <button id="addBtn" type="button" class="shopifine-ui-button ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false">
199                            <span class="ui-button-text">Add Roles</span>
200                    </div> 
201                </div>
202            </div>
203            <?php $this->load->view("common/message"); ?>
204            <div class="table-grid" style="margin: 0 auto; width:65%">
205                <h1 id="table header">Parents to Roles</h1>
206                <table id="roles"><tr><td/></tr></table> 
207                <div id="pager"></div>
208            </div>
209        </div>
210        <?php $this->load->view("partial/footer"); ?>
211    </body>
212</html>
213<script>
214    $(".chzn-select").chosen();
215    </script>