Subversion Repositories SmartDukaan

Rev

Rev 31787 | Rev 32819 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 31787 Rev 32813
Line 68... Line 68...
68
	
68
	
69
</script>
69
</script>
70
<section class="wrapper">
70
<section class="wrapper">
71
	<div class="row">
71
	<div class="row">
72
		<div class="col-lg-12">
72
		<div class="col-lg-12">
73
			<h3 class="page-header"><i class="icon_document_alt"></i>TICKET</h3>
73
			<h3 class="page-header"><i class="icon_document_alt"></i>CREATE POSITION</h3>
74
			<ol class="breadcrumb">
74
			<ol class="breadcrumb">
75
				<li><i class="fa fa-home"></i><a href="${rc.contextPath}/dashboard">Home</a></li>
75
				<li><i class="fa fa-home"></i><a href="${rc.contextPath}/dashboard">Home</a></li>
76
				<li><i class="icon_document_alt"></i>Create Position</li>						  	
76
				<li><i class="icon_document_alt"></i>Create Position</li>						  	
77
			</ol>
77
			</ol>
78
		</div>
78
		</div>
Line 135... Line 135...
135
 
135
 
136
   
136
   
137
<div id="position-table">
137
<div id="position-table">
138
		<div class="row">
138
		<div class="row">
139
	    	<div class="col-lg-12">
139
	    	<div class="col-lg-12">
-
 
140
	    	<input type="file" class="btn btn-primary upload-button" type="button" value="Upload" id="positionupload"><br>
-
 
141
 
-
 
142
            <input class="btn btn-primary upload-button positionfileupload" type="button" value="Upload">
-
 
143
 
140
            <table class="table table-border table-condensed table-bordered" id="createPosition" style="width:100%">
144
            <table class="table table-border table-condensed table-bordered" id="createPosition" style="width:100%">
141
	    	
145
	    	
142
	    		
146
	    		
143
	    			 <thead>
147
	    			 <thead>
144
	    				<tr>
148
	    				<tr>
145
	    					<th>User</th>
149
	    					<th>User</th>
-
 
150
	    					<th>Position Id</th>
146
	    					<th>Category</th>
151
	    					<th>Category</th>
147
	    					<th>Region</th>
152
	    					<th>Region</th>
148
	    					<th>Created TimeStamp</th>
153
	    					<th>Created TimeStamp</th>
149
	    					<th>EscalationType</th>
154
	    					<th>EscalationType</th>
150
	    					<th>Partners</th>
155
	    					<th>Partners</th>
Line 156... Line 161...
156
	    				<tbody>
161
	    				<tbody>
157
	    				#if(!$positions.isEmpty())
162
	    				#if(!$positions.isEmpty())
158
	 							#foreach($position in $positions)
163
	 							#foreach($position in $positions)
159
	 							<tr>
164
	 							<tr>
160
	 							<td>$authUserIdAndAuthUserMap.get($position.getAuthUserId()).getFullName()</td>
165
	 							<td>$authUserIdAndAuthUserMap.get($position.getAuthUserId()).getFullName()</td>
-
 
166
	 							<td>$position.getId()</td>
161
	 							#if($position.getCategoryId()==0)
167
	 							#if($position.getCategoryId()==0)
162
	 							<td>All Category</td>
168
	 							<td>All Category</td>
163
	 							#else
169
	 							#else
164
	 							<td>$categoryIdAndCategoryMap.get($position.getCategoryId()).getName()</td>
170
	 							<td>$categoryIdAndCategoryMap.get($position.getCategoryId()).getName()</td>
165
	 							#end
171
	 							#end
Line 210... Line 216...
210
              "fixedHeader": true,
216
              "fixedHeader": true,
211
              
217
              
212
              
218
              
213
              });
219
              });
214
              
220
              
-
 
221
         });
-
 
222
 
-
 
223
     $(document).ready(function() {
-
 
224
         $('input.positionfileupload').on('click', function () {
-
 
225
             var fileSelector = $('#positionupload')[0];
-
 
226
             if (fileSelector != undefined && fileSelector.files[0] != undefined) {
-
 
227
                 if (confirm("Confirm Upload?")) {
-
 
228
                     var reader = new FileReader();
-
 
229
 
-
 
230
                     reader.onload = function (e) {
-
 
231
                         var csvContent = e.target.result;
-
 
232
                         var positions = parseCsv(csvContent);
-
 
233
 
-
 
234
                         // Now 'positions' is an array of objects containing CSV data
-
 
235
                         console.log('positionsssssss',positions);
-
 
236
 
-
 
237
                         // Assuming you have a function to send the data to the server
-
 
238
                         // Modify this function according to your needs
-
 
239
                         sendCsvDataToServer(positions);
-
 
240
                     };
-
 
241
 
-
 
242
                     reader.readAsText(fileSelector.files[0]);
-
 
243
                 }
-
 
244
             } else {
-
 
245
                 alert("Please upload a file!");
-
 
246
             }
-
 
247
             return false;
-
 
248
         });
-
 
249
     });
-
 
250
 
-
 
251
     function parseCsv(csvContent) {
-
 
252
         var lines = csvContent.split('\n');
-
 
253
         var positions = [];
-
 
254
 
-
 
255
         for (var i = 0; i < lines.length; i++) {
-
 
256
             var columns = lines[i].trim().split(','); // Use ',' as the delimiter for your CSV
-
 
257
 
-
 
258
             // Check if the row has the expected number of columns and contains non-empty values
-
 
259
             if (columns.length && columns.some(column => column.trim() !== '')) {
-
 
260
                 // Skip the header row
-
 
261
                 if (i === 0) continue;
-
 
262
 
-
 
263
                 var position = {
-
 
264
                     storeCode: columns[0] ? columns[0].trim() : '',
-
 
265
                     positionIdFrom: columns[1] ? columns[1].trim() : '',
-
 
266
                     positionIdTo: columns[2] ? columns[2].trim() : ''
-
 
267
                 };
-
 
268
 
-
 
269
                 positions.push(position);
-
 
270
             }
-
 
271
         }
-
 
272
 
-
 
273
         return positions;
-
 
274
     }
-
 
275
 
-
 
276
 
-
 
277
 
-
 
278
     function sendCsvDataToServer(data) {
-
 
279
 
-
 
280
         $.ajax({
-
 
281
             type: "POST",
-
 
282
             url: "${rc.contextPath}/partner-position/update",
-
 
283
             data: JSON.stringify(data),
-
 
284
             contentType: "application/json; charset=utf-8",
-
 
285
 
-
 
286
             success: function(response) {
-
 
287
                 if (response) {
-
 
288
                     alert("Content updated successfully..");
-
 
289
                 }
215
              });
290
             }
-
 
291
         });
-
 
292
 
-
 
293
 
-
 
294
     }
-
 
295
 
216
                 
296
                 
217
</script>
297
</script>