shopifine /magehelp/application/views/procurement/purchase_order_grid_bk.php

Language PHP Lines 373
MD5 Hash 0e86e499aa2faca2d063a28df4a18069 Estimated Cost $61 (why?)
Repository https://bitbucket.org/jit_bec/shopifine.git View Raw File View Project SPDX
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
<html>
    <head>
       <?php $this->load->view("common/header"); ?>
<!--        <script type="text/javascript" src="http://jzaefferer.github.com/jquery-validation/jquery.validate.js"></script>-->
        <style>
            .column {
            float: left;
            padding: 1em;
            width:30%;
            }
            
            .extra-wide{
                width:95%;
            }
            .field{
                width:100%;
            }
            .ui-widget-header {height:12px;}
            .quote-column {
            float: left;
            padding-bottom: 0.5em;
            width: 45em;
            }
            .ui-combobox-input{
                width:23em;
            }
             #supplierOp-input{
                width:10em;
            }
            #warehouseOp-input{
                width:10em;
            }
             
            .calculated {
                color: green;
                font-size: 90%;
            }
            .row{
                width:95%;
            }
            
            .shopifine-ro-label {
                float: left;
                padding-right: 0.5em;
                width: 50%;
                word-wrap: break-word;
                color:#2E6E9E;
            }

            .shopifine-output {
             float: right;
             width: 45%;
             word-wrap: break-word;
             font-weight:bold;
            }
            
        </style>
       
        <script type="text/javascript">
                $(function() {
        
        //form validation 
        
         $("#quoteForm").validate();
         $("#itemForm").validate();
         
        // datepicker for Add Form 
        
        function quotegriddates(id){
            jQuery("#"+id+"_needed_by_date","#orders").datepicker({dateFormat:"yy-mm-dd",minDate:0});
        }
       
        //end datepicker
         
        var myGridPkd = $("#lineItems");
              
       $( "#dialog-form" ).dialog({
                                autoOpen: false,
                                height: 'auto',
                                width: '52%',
                                modal: true,
                                buttons: {
                                    "DoneButton": {
                                        id:"doneBtn",
                                        text:"Create Quote",
                                        click:function() {
                                        var isValid = $("#quoteForm").valid();
                                        if (isValid){
                                           $.ajax({url:"index.php/procurement/createPO",
                                                type:"POST",
                                                data:{  orderId:$("#orderId").val(),
                                                        supplierId:$("#supplierOp").val(),
                                                        warehouseId:$("#warehouseOp").val(),
                                                        reqdate:$("#reqdate").val(),
                                                        notes:$("#desc").val()
                                                        
                                                    },

                                                success:function(response)
                                                {}
                                                 
                                            }) //end ajax
                                            if ($("#orderId").val()!=""){
                                                $( this ).dialog( "close" );
                                            } 
 
                                        } //end ifvalid
                                        
                                    }}, //end of Create button
                                    Cancel: function() {
                                        $("#orderId").val("");
                                        $( this ).dialog( "close" );
                                    }
                                },//end buttons
                                open: function(){
                                     $('#tabs-movie').tabs({
            create: function(e, ui) {
                $('#closeBtn').click(function() {
                    $('#dialog-form').dialog('close');
                });
            }
        });
        $(this).parent().children('.ui-dialog-titlebar').remove(); 
                                     
//                                    $.ajax({
//                                       method:"POST",
//                                       url:'index.php/procurement/getOrderDetails',
//                                       data:{orderId: myGrid.getGridParam('selrow')},
//                                       success:function(response){
//                                           console.log(response);
//                                           var resJson = JSON.parse(response);
//                                           console.log(resJson);
//                                           
//                                           $("#supplierOP").text(resJson.quote_supplier_name);
//                                           $("#warehouseOP").text(resJson.quote_warehouse);
//                                           $("#quoteOP").text(resJson.quote_reference);
//                                           $("#raisedByOP").text(resJson.quote_raised_by_name);
//                                           $("#approvedByOP").text(resJson.quote_approved_by_name);
//                                           $("#estValueOP").text(resJson.quote_estimated_value);
//                                       }
//                                    })
//                                    $("#lineItems").jqGrid({
//                                        url:'index.php/procurement/populateOrderItems',
//                                        datatype: 'json',
//                                        mtype: 'POST',
//                                        postData:{orderId: myGrid.getGridParam('selrow')},
//                                        colNames:['Product','Quantity','Need By Date','Expected Price','Estimated Value',/*'Notes'*/],
//                                        colModel :[ 
//                                            {name:'name', index:'name',editable:false, width:80, align:'right'},
//                                            {name:'quoted_quantity', index:'quoted_quantity', editable:true,width:140, align:'right'},
//                                            {name:'needed_by_date',index:'needed_by_date',editable:true, width:80, align:'right'},
//                                            {name:'expected_price',index:'expected_price',editable:true, width:80, align:'right'},
//                                            {name:'estimated_value', index:'estimated_value',editable:false, width:80, align:'right'},
////                                            {name:'comments', index:'comments',editable:true, width:180, align:'right'}
//
//                                        ],
//                                        pager: '#pagerPk',
//                                        rowNum:10,
//                                        rowList:[5,10,20],
//                                        sortname: 'id',
//                                        sortorder: 'desc',
//                                        viewrecords: true,
//                                        gridview: true,
//                                        ignoreCase:true,
//                                        rownumbers:true,
//                                        height:'auto',
//                                        width:'50%',
//                                        caption: 'Line Items',
//
//                                        jsonReader : {
//                                            root:"quoteitemdata",
//                                            page: "page",
//                                            total: "total",
//                                            records: "records",
//                                            cell: "dprow",
//                                            id: "id"
//                                        }
//
//                                    }).navGrid("#pagerPk",{edit:false,add:false,del:true,search:false},{},{},{},{},{});
                                                            
                                },

                                close: function() {
                                    //allFields.val( "" ).removeClass( "ui-state-error" );
                                    $("#quoteForm").data('validator').resetForm();
                                    $("#quoteForm")[0].reset();
                                    myGridPkd.jqGrid("GridUnload");
                                    $("pkdheader").hide();
                                    $("#doneBtn > span").text("Create Quote");
                                    $("#orders").trigger("reloadGrid");
                                    
                                }
                            });
        
       
        // Main Request For Quotation Grid                    
        
        var myGrid = $("#orders"),lastsel2;
                var editparameters = {
                    "keys" : true,
                    "oneditfunc" : quotegriddates,
                    "successfunc" : function(){
                        lastsel2=undefined;
                        myGrid.trigger("reloadGrid");
                        return true;
                    },
                    "aftersavefunc" : null,
                    "errorfunc": function(){
                        lastsel2=undefined;
                        //myGrid.trigger("reloadGrid");
                       
                    },
                    "afterrestorefunc" : null,
                    "restoreAfterError" : true,
                    "mtype" : "POST"
                };
                
                myGrid.jqGrid({
                    url:'index.php/procurement/populatePO',
                    datatype: 'json',
                    mtype: 'GET',
                    colNames:['Reference','Supplier','Estimated Value',/*'Owner',*/'Status','Raised By',/*'Owner',*/'Needed By Date'],
                    colModel :[ 
                        {name:'reference', index:'reference', width:80, align:'right',editable:false},
                        {name:'quote_supplier_name', index:'supplier_name', width:140, align:'right',editable:false},
                        {name:'quote_estimated_value', index:'estimated_value', width:100, align:'right',editable:false,editoptions:{size:"20",maxlength:"30"}},
//                        {name:'owner', index:'owner', width:140, align:'right',editable:true,editoptions:{size:"20",maxlength:"30"}},
                        {name:'status', index:'status', width:60, align:'right',editable:false,editoptions:{size:"20",maxlength:"30"}},
                        {name:'quote_raised_by_name', index:'raised_by_name',editable:false, width:80, align:'right'},
//                        {name:'owner_name', index:'owner_name',editable:false, width:80, align:'right'},
                        {name:'quote_needed_by_date', index:'needed_by_date',editable:false, width:120, sorttype:'date'}
                    ],
                    pager: '#pager',
                    rowNum:10,
                    rowList:[5,10,20],
                    sortname: 'id',
                    sortorder: 'desc',
                    viewrecords: true,
                    gridview: true,
                    multiselect:true,
                    
                    ignoreCase:true,
                    rownumbers:true,
                    height:'auto',
                    width:680,
                    caption: 'Request For Quote',
            
                    jsonReader : {
                        root:"quotedata",
                        page: "page",
                        total: "total",
                        records: "records",
                        cell: "dprow",
                        id: "id"
                    },
                    onSelectRow: function(id){if(id && id!==lastsel2){
                            myGrid.restoreRow(lastsel2);
                            myGrid.editRow(id,editparameters);
                            lastsel2=id;
                        }
                    }
                    ,editurl:'index.php/procurement/modifyOrder'
                    ,subGrid:true,
                    subGridRowExpanded: function(subgrid_id, row_id) {
                            // we pass two parameters
                            // subgrid_id is a id of the div tag created whitin a table data
                            // the id of this elemenet is a combination of the "sg_" + id of the row
                            // the row_id is the id of the row
                            // If we wan to pass additinal parameters to the url we can use
                            // a method getRowData(row_id) - which returns associative array in type name-value
                            // here we can easy construct the flowing
                            var subgrid_table_id, pager_id;
                            subgrid_table_id = subgrid_id+"_t";
                            
                            pager_id = "p_"+subgrid_table_id;
                            
                            $("#"+subgrid_id).html("<table id='"+subgrid_table_id+"' class='scroll'></table><div id='"+pager_id+"' class='scroll'></div>");
                            jQuery("#"+subgrid_table_id).jqGrid({
                                    url:'index.php/procurement/populateOrderItems?q=2&orderId='+row_id,
                                    datatype: 'json',
                                    colNames:['Product','Quantity','Need By Date','Unit Price','Estimated Value','Notes'],
                                    colModel :[ 
                                        {name:'name', index:'name',editable:false, width:120, align:'right'},
                                        {name:'quoted_quantity', index:'quoted_quantity', editable:false,width:50, align:'right'},
                                        {name:'needed_by_date',index:'needed_by_date',editable:false, width:80, align:'right'},
                                        {name:'expected_price',index:'expected_price',editable:false, width:50, align:'right'},
                                        {name:'estimated_value', index:'estimated_value',editable:false, width:60, align:'right'},
                                        {name:'comments', index:'comments',editable:false, width:180, align:'right'}

                                    ],
                                    rowNum:20,
                                    pager: pager_id,
                                    sortname: 'id',
                                    sortorder: "asc",
                                    height: '100%',
                                    
                                    jsonReader : {
                                        root:"quoteitemdata",
                                        page: "page",
                                        total: "total",
                                        records: "records",
                                        cell: "dprow",
                                        id: "id"
                                    }
                                });
                            jQuery("#"+subgrid_table_id).jqGrid('navGrid',"#"+pager_id,{edit:false,add:false,del:false,search:false,view:true});
                             
                    }
                }).navGrid("#pager",{edit:false,add:false,view:true,del:true,search:false},{height:280,reloadAfterSubmit:false,closeAfterEdit:true,recreateForm:true,checkOnSubmit:true},{},{},{},{});
               
                myGrid.jqGrid('navButtonAdd','#pager',{
                   caption:"", 
                   title:"Create Product",
                   buttonicon:"ui-icon-plus",
                   id:"add_orders",
                   onClickButton : function () { 
                        $( "#dialog-form" ).dialog( "open" );
                    } 
                });
                myGrid.jqGrid('navButtonAdd','#pager',{
                   caption:"", 
                   title:"Generate Purchase Order",
                   buttonicon:"ui-icon-cart",
                   id:"po_orders",
                   onClickButton : function () { 
                        $( "#dialog-form" ).dialog( "open" );
                    } 
                });
                myGrid.jqGrid('filterToolbar', {stringResult: true, searchOnEnter: true, defaultSearch : "cn"});
                $("#del_orders").insertAfter("#add_orders");
                
                
    
    
    });        

        </script>
        
    </head>
     
    <body>
        <?php  $this->load->view("common/menubar"); ?>
        <div id ="dialog-form">
            <h1 id="formHeader">Purchase Order Details</h1>  
                    <div id="tabs-movie">
            <ul>
              <li><a href="form.html">Information</a></li>
              <li><a href="notes.html">Cast List</a></li>
              <li class="ui-tabs-close-button"><button id="closeBtn">X</button></li>
            </ul>
            
            
          </div>
          
        </div>
        
        <div style="display: block;height: 100%;" class="shopifine-ui-dialog ui-widget ui-widget-content ui-corner-all" tabindex="-1" role="dialog" aria-labelledby="ui-dialog-title-dialog-form">
            <div class="table-grid">
                <h1 id="table header">Request For Quotations</h1>
                <table id="orders"><tr><td/></tr></table> 
                <div id="pager"></div>
            </div>
            
        </div>
        
        <?php $this->load->view("partial/footer"); ?>       
</body>   
</html>



    
   
Back to Top