<?php

// Created by Olloyor on 06.03.2021

require_once('connect.php');

$sql = "SELECT agent_id, fio, boshagan, telefon, parol, region_idlar, kontr_idlar, gruppa_idlar, can_narx, can_zakaz, can_tolov, can_otchot,naqd,optom,kelishilgan, sklad_id, is_dostavshik FROM agentlar";

mysqli_set_charset($conn,"utf8");
$result = mysqli_query($conn,"SET NAMES utf8");

$result = mysqli_query($conn, $sql);

$count=1;

$list_kontr = array();

if ($result !== false && $result->num_rows > 0) {
    while($row=mysqli_fetch_array($result)){


        $agent_id=$row['agent_id'];
        $fio=$row['fio'];
        $fio=str_replace('"', '|', $fio);
        $boshagan=$row['boshagan'];
        $telefon=$row['telefon'];
        $parol=$row['parol'];
        $region_idlar=$row['region_idlar'];
        $kontr_idlar=$row['kontr_idlar'];
        $gruppa_idlar=$row['gruppa_idlar']; 
        $can_narx=$row['can_narx'];
        $can_zakaz=$row['can_zakaz'];
        $can_tolov=$row['can_tolov'];
        $can_otchot=$row['can_otchot'];
        $naqd=$row['naqd'];
        $optom=$row['optom'];
        $kelishilgan=$row['kelishilgan'];
        $sklad_id=$row['sklad_id'];
        $is_dostavshik=$row['is_dostavshik'];

        array_push($list_kontr,
                array(
                        'agent_id' => $agent_id,
                        'fio' => $fio,
                        'boshagan' => $boshagan,
                        'telefon' => $telefon,
                        'parol' => $parol,
                        'region_idlar' => $region_idlar,
                        'kontr_idlar' => $kontr_idlar,
                        'gruppa_idlar' => $gruppa_idlar, 
                        'can_narx' => $can_narx,
                        'can_zakaz' => $can_zakaz,
                        'can_tolov' => $can_tolov,
                        'can_otchot' => $can_otchot,
                        'naqd' => $naqd,
                        'optom' => $optom,
                        'sklad_id' => $sklad_id,
                        'is_dostavshik' => $is_dostavshik,
                        'kelishilgan' => $kelishilgan
                     )
                  );

        }

    }

echo json_encode($list_kontr);
$conn->close();
?>

