shopifine /magehelp/application/views/impex/update_stock.php

Language PHP Lines 310
MD5 Hash 4e1a6988651c87a4bdee62dfc0fcd03b Estimated Cost $306 (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
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
    <html>
        <head>
            <?php $this->load->view("common/header"); ?>

            <!--<link rel="stylesheet" rev="stylesheet" href="<?php echo base_url(); ?>js/jqplot/jquery.jqplot.css" />-->
<!--            <script type="text/javascript" src="<?php echo base_url(); ?>js/jqplot/jquery.jqplot.min.js"></script>
            <script type="text/javascript" src="<?php echo base_url(); ?>js/jqplot/plugins/jquery.jqplot.min.js"></script>
            <script type="text/javascript" src="<?php echo base_url(); ?>js/jqplot/plugins/jqplot.barRenderer.min.js"></script>
            <script type="text/javascript" src="<?php echo base_url(); ?>js/jqplot/plugins/jqplot.categoryAxisRenderer.min.js"></script>
            <script type="text/javascript" src="<?php echo base_url(); ?>js/jqplot/plugins/jqplot.pointLabels.min.js"></script>-->
                     <!--<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>css/shopifine/message.css" />-->
            <style type="text/css">
                .menu_item {
                    display: inline;
                }
            </style>
            <style type="text/css">
                #menubar_admin_navigation {
                    top:49px;
                }
                
                 #content_area {width:100%;height:auto;}
                 .logoauth {color:green;}
                .shopifine-ui-dialog-buttonset {
                    float: left;
                    margin: 1em;
                    padding-left: 2em;
                }
                
                .shopifine-ui-widget-content {
                    border:none;
                }
            </style>
            <script>
                function checkStatus(){
                       var error= '<?php echo $error ?>';
                       if (error=="true"){
                           $("#mainCntnr").hide();
                           $("#forceMessageCntnr").show();
                       }
                       
                    }
                $(function() {
                    
                    var idsOfSelectedRows =[];
                    var updateIdsOfSelectedRows = function (id, isSelected) {
                        var contains = $.inArray(id, idsOfSelectedRows)
                            //idsOfSelectedRows.contains(id);
                        if (!isSelected && contains>-1) {
                            for(var i=0; i<idsOfSelectedRows.length; i++) {
                                if(idsOfSelectedRows[i] == id) {
                                    idsOfSelectedRows.splice(i, 1);
                                    break;
                                }
                            }
                        }
                        else if (contains==-1) {
                            idsOfSelectedRows.push(id);
                        }
                        console.log(idsOfSelectedRows);
                };
   
                    var myGrid = $("#product_stock");
               
                    myGrid.jqGrid({
                        url:'index.php/impex/populateProductsStocksToExport',
                        datatype: 'json',
                        mtype: 'GET',
                        colNames:['Barcode','Product ID','Stocks To Add'],
                        colModel :[ 
                            
                            {name:'barcode', index:'barcode', width:200, align:'right',editable:false},
                            {name:'product_id', index:'product_id', align:'right',hidden:true},
                            {name:'balance_to_update', index:'balance_to_update', width:100, align:'right'},
                            

                        ],
                        pager: '#pager',
                        rowNum:5,
                        rowList:[5,10,50],
                        sortname: 'id',
                        sortorder: 'desc',
                        viewrecords: true,
                        gridview: true,
                        ignoreCase:true,
                        rownumbers:true,
                        height:'auto',
                        width:250,
                        multiselect:true,
                        caption: 'Inventory To Be Updated',

                        jsonReader : {
                            root:"productstockdata",
                            page: "page",
                            total: "total",
                            records: "records",
                            cell: "dprow",
                            id: "id"
                        },
                        onSelectRow: function(rowid, status){
                            updateIdsOfSelectedRows(rowid, status);
                        },
                        onSelectAll: function (aRowids, status) {
                            var i, count, id;
                            for (i = 0, count = aRowids.length; i < count; i++) {
                                id = aRowids[i];
                                updateIdsOfSelectedRows(id, status);
                            }
                        }

                    }).navGrid("#pager",{edit:false,add:false,del:false,search:false},
                   /* edit Option*/ {},
                /* Add Option*/     {},
                                                     {},{},{});
                                                     
        myGrid.jqGrid('navButtonAdd','#pager',{
            caption:"", 
            title:"Create CSV To Begin Export Process",
            buttonicon:"ui-icon-newwin",
            
            onClickButton : function () { 
                var rowid = myGrid.jqGrid('getGridParam', 'selarrrow');
                var noOfRows = rowid.length;
                console.log(rowid);
               
                if (noOfRows == 0){
                    $( "#modal-warning-none" ).dialog("open");
                }
                else{
                    $(".inithide").hide();
                    $.ajax({
                        url:'index.php/impex/createExportStockFile',
                        method:'post',
                        data:{selected:idsOfSelectedRows},
                        success:function(response){
                            var responseObj = JSON.parse(response);
                            $(".inithide").hide();
                            if (responseObj.status == "success"){
                                $("#successCntnr").slideDown("slow");
                                $("#success-text").text(responseObj.message);
                                $("#selected_ids_hidden").val(idsOfSelectedRows);
                            }
                            else if (responseObj.status == "error"){
                                $("#failureCntnr").slideDown("slow");
                                $("#failure-text").text(responseObj.message);
                                $("#selected_ids_hidden").val("");
                            }
                            
                        },
                        error:function(response){
                            var responseObj = JSON.parse(response);
                            $(".inithide").hide();
                           
                                $("#failureCntnr").show();
                                $("#failure-text").text("File Could Not Ve Exported Due To Internal Error");
                                $("#selected_ids_hidden").val("");
                            }
                    })
                }
                
            }
        });
        $("#magmiBtn").click(function(){
            $("#syncBtn").show()
            $.ajax({
                        url:'index.php/impex/syncNeeeded',
                        method:'post',
                        data:{selected:$("#selected_ids_hidden").val()}
            });
        })
        $("#syncBtn").click(function(){
          
             $( "#dialog-confirm" ).dialog("open");
        });
         $("#forceSyncBtn").click(function(){
          
             $.ajax({
                           url:'index.php/impex/doSync',
                           method:'get',
                           
                           success:function (response){
                               var responseObj = JSON.parse(response);
                               if (responseObj.status=="success"){
                                   $("#mainCntnr").show();
                                   $("#forceMessageCntnr").hide();
                                   $("#success-text").text("Sync Successful");
                                   
                               }
                               else{
                                   $("#force-text").text("Force Sync Failed");
                               }
                                 
                               
                           },
                           error:function (response){
                               $("#force-text").text("Force Sync Failed");
                               
                           }
                       });
        })
        $( "#dialog-confirm" ).dialog({
            resizable: false,
            height:200,
             width:500,
            modal: true,
            autoOpen:false,
            buttons: {
                "Confirm": function() {
                     $.ajax({
                           url:'index.php/impex/doSync',
                           method:'get',
                           
                           success:function (response){
                               
                                 $("#success-text").text("Sync Completed");
                               
                           },
                           error:function (response){
                               $("#success-text").text("Sync Failed");
                               
                           }
                       });
                       $( this ).dialog( "close" );
                    
                },
                Cancel: function() {
                    $( this ).dialog( "close" );
                }
            }
        });
                 
                });
            </script>
        </head>

        <body onload="return checkStatus();">
            <?php $this->load->view("common/menubar"); ?>
            <div id="dialog-confirm" title="Warning" class="inithide">
            <p><span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span>
                Please See The Console To See If  Processing Complete.Sync Only When The Processing Is Over;Else System Will Be Inconsistent and Sync May Not Work. Is Processing Over?</p>
            </div>
             <?php //if (!$error): ?>
            <div id="mainCntnr" style="display: block;height: auto;" class="shopifine-ui-dialog ui-dialog-medium 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">Product Stock</h1>
                    <table id="product_stock"><tr><td/></tr></table> 
                    <div id="pager"></div>
                </div>
               
                <div id="successCntnr" class="inithide">
                    <h1>Export To CSV For New Product Creation  Completed</h1>
                    <h3 id="success-text"></h3>
                     <div  class="ui-dialog-content" style="width: auto; min-height: 65.1333px; height: auto;" scrolltop="0" scrollleft="0">
    <!--                    <h1 id="formHeader">Add Delivery Point</h1> -->
                        <form id="deliverypointform" target="iframeMagmi" method="post" action="<?php echo $server_url ?>/magmi/web/magmi.php">
                           <input type="hidden" name="logfile" value="progress.txt"/>
                            <input type="hidden" name="mode" value="<?php echo $mode ?>"/>
                            <input type="hidden" name="profile" value="<?php echo $profile ?>"/>
                            <input type="hidden" name="run" value="import"/>
                            <input id ="selected_ids_hidden" type="hidden" name="selected_ids_hidden" value="import"/>
                            <div class="ui-dialog-buttonpane shopifine-ui-widget-content ui-helper-clearfix">
                            <div class="shopifine-ui-dialog-buttonset">
                                <input id="magmiBtn" type="submit" class="shopifine-ui-button ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false" value="Process For  Magento">
                                <input id="syncBtn"  class="inithide shopifine-ui-button ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false" value="Sync After Process Completes!!">
                            </div> 
                        </div>
                        </form>
                    </div>


                   <iframe id="iframeMagmi" name="iframeMagmi" style="height:900px;width:100%" frameborder="no">
                   </iframe>
                </div>
                
               <?php //else: ?>
               <div id="faliureCntnr" class="inithide">
                   <h1 id ="failure-text"></h1>
               </div>
               
               <?php //endif; ?>
            </div>
             <?php //else: ?>
                <div id="forceMessageCntnr" style=" height: auto;" class="inithide shopifine-ui-dialog ui-dialog-medium ui-widget ui-widget-content ui-corner-all" tabindex="-1" role="dialog" aria-labelledby="ui-dialog-title-dialog-form">
                   <h3 id ="force-text">Sync Was Not Properly Done. You Can Not Update Stock Before The Previous Sync Is Done Properly. Please Do Force Sync And System Will Try To Resolve The Issue Else ConTact Admin </h3>
                   <div class="shopifine-ui-dialog-buttonset">
                    <input id="forceSyncBtn"  class="shopifine-ui-button ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false" value="Force Sync!!">
                    </div> 
               </div>
                 
             <?php //endif; ?>
<!--             <div style="display: block;height: 100%;left:0em; overflow: hidden;" class="shopifine-ui-dialog  ui-widget ui-widget-content ui-corner-all" tabindex="-1" role="dialog" aria-labelledby="ui-dialog-title-dialog-form">
                <?php //$this->load->view("common/message"); ?>
                
            </div>-->
            <?php $this->load->view("partial/footer"); ?>

        </body>
    </html>
    <script>
        function setOption(){
        $("#mode").val("xcreate");
        }
    </script>
    
Back to Top