Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ``` // The first query that will execute to get the students in database ('Added By: Ron Ivin Gregorio - 02/20/2023')
- const getAllCustomer = async () => {
- let skip = 0;
- let final_array_count = 0;
- $('.customers-list').empty();
- try {
- do{
- const data = {
- 'search' : search,
- 'advanced_search': advanced_search,
- 'order': order,
- 'sort': sort,
- 'skip': skip
- };
- const response = await fetch('process/get_all_customers.php', {
- method: "POST",
- headers: {
- "Content-Type": "application/json"
- },
- body: JSON.stringify(data)
- });
- const result = await response.json();
- if (result.status) {
- if (0 < result.c_length) {
- final_array_count = result.c_length;
- skip += 20;
- } else {
- final_array_count = final_array_count - 20;
- let minus = final_array_count
- if (minus < 20) {
- skip += minus;
- } else {
- skip += 20;
- }
- }
- if(0 < result.data.length){
- let count = 0;
- let num = $('.row_link').length;
- result.data.forEach((value) => {
- let x = '<tr id="row_link'+num+'" class="row_link" cid= "'+value['id']+'">';
- x += '<td>' + ++num +'</td>';
- x += '<td class="timestamp">' + value['registration_date'] + '<br>' + value['registration_time'] +'</td>';
- x += '<td>' + value ['name'] +'</td>';
- x += '<td>' + value ['dlnum'] +'</td>';
- x += '<td>' + value ['student_ids'] +'</td>';
- x += '<td>' + value ['courses'] +'</td>';
- x += '<td>' + value ['classes'] +'</td>';
- x += '<td>' + value ['affiliates'] +'</td>';
- x += '<td>' + value ['companies'] +'</td>';
- x += '<td>' + value ['status'] +'</td>';
- x += '</tr>';
- $('.customers-list').append(x)
- count++;
- });
- }
- }
- }while(0 < final_array_count);
- let num = $('.row_link').length;
- if(num < 20){
- let add_row = 20 - num;
- for(let x = 0; x < add_row; x++){
- let y = '<tr>';
- y += '<td></td>';
- y += '<td></td>';
- y += '<td></td>';
- y += '<td></td>';
- y += '<td></td>';
- y += '<td></td>';
- y += '<td></td>';
- y += '<td></td>';
- y += '<td></td>';
- y += '<td></td>';
- y += '</tr>';
- $('.customers-list').append(y)
- }
- }
- } catch (error) {
- // console.log(error.message)
- let num = $('.row_link').length;
- if(num < 20){
- let add_row = 20 - num;
- for(let x = 0; x < add_row; x++){
- let y = '<tr>';
- y += '<td></td>';
- y += '<td></td>';
- y += '<td></td>';
- y += '<td></td>';
- y += '<td></td>';
- y += '<td></td>';
- y += '<td></td>';
- y += '<td></td>';
- y += '<td></td>';
- y += '<td></td>';
- y += '</tr>';
- $('.customers-list').append(y)
- }
- }
- }
- }
- getAllCustomer(); ```
Advertisement
Add Comment
Please, Sign In to add comment