function start_old(){

  global $ar,$db;

  $dt=array();

$dt2=array();



//account_trx

$sql2=SELECT `id`,`name`,`code`,`c3`,`parent_id` from `account` where trx=1;

$res2=mysqli_query($db,$sql2);

$r2=mysqli_num_rows($res2);

$dt[account_trx][count]=$r2;



$sql=$sql2. order by `code`;

//echo $sql.;<br>;

$res=mysqli_query($db,$sql);

if(mysqli_num_rows($res2)>0) {

  $c=0; $d=0;

  while($r1=mysqli_fetch_assoc($res)) {

    $dt[account_trx][data][all][$r1[code]]=$r1;

    if($r1[c3]<30) {

      $dt[account_trx][data][left][$c]=$r1;

      $c++;

    } else {

      $dt[account_trx][data][right][$d]=$r1; 

      $d++;     

    }

  }

} else {

  $dt[account_trx][count]=0;

}



$sql2=SELECT * from `account_equation` where id>0;

$res2=mysqli_query($db,$sql2);

$r2=mysqli_num_rows($res2);

$dt[account_equation][count]=$r2;



$sql=$sql2. order by id;

//echo $sql.;<br>;

$res=mysqli_query($db,$sql);

if(mysqli_num_rows($res2)>0) {

  $c=0;

  while($r1=mysqli_fetch_assoc($res)) {

    $dt[account_equation][data][$c]=$r1;    

    //$dt[data][$c][update]=date(Y-m-d H:i:s,$r1[update_at]);

    $c++;

  }

} else {

  $dt[account_equation][count]=0;

}



//action

$sql2=SELECT * from `action` where id>0;

$res2=mysqli_query($db,$sql2);

$r2=mysqli_num_rows($res2);

$dt[action][count]=$r2;



$sql=$sql2. order by id;

//echo $sql.;<br>;

$res=mysqli_query($db,$sql);

if(mysqli_num_rows($res2)>0) {

  while($r1=mysqli_fetch_assoc($res)) {

    $c=$r1[id];

    $dt[action][data][$c]=$r1;    

    $dt[action][data][$c][rp]=ang2($r1[amount]);    

    $dt[action][data][$c][update]=date(Y-m-d H:i:s,$r1[update_at]);

  }

} else {

  $dt[action][count]=0;

}



//bank

$sql2=SELECT * from `bank` where id>0;

$res2=mysqli_query($db,$sql2);

$r2=mysqli_num_rows($res2);

$dt[bank][count]=$r2;



$sql=$sql2. order by id;

//echo $sql.;<br>;

$res=mysqli_query($db,$sql);

if(mysqli_num_rows($res2)>0) {

  $c=0;

  while($r1=mysqli_fetch_assoc($res)) {

    $dt[bank][data][$c]=$r1;    

    $dt[bank][data][$c][update]=date(Y-m-d H:i:s,$r1[update_at]);

    $c++;

  }

} else {

  $dt[bank][count]=0;

}



//company

$sql2=SELECT * from `company` where id>0;

$res2=mysqli_query($db,$sql2);

$r2=mysqli_num_rows($res2);

$dt[company][count]=$r2;



$sql=$sql2. order by id;

//echo $sql.;<br>;

$res=mysqli_query($db,$sql);

if(mysqli_num_rows($res2)>0) {

  $c=0;

  while($r1=mysqli_fetch_assoc($res)) {

    $dt[company][data][$c]=$r1;    

    $dt[company][data][$c][update]=date(Y-m-d H:i:s,$r1[update_at]);

    $c++;

  }

} else {

  $dt[company][count]=0;

}



//inventory

$sql2=SELECT * from `inventory` where id>0;

$res2=mysqli_query($db,$sql2);

$r2=mysqli_num_rows($res2);

$dt[inventory][count]=$r2;



$sql=$sql2. order by id;

//echo $sql.;<br>;

$res=mysqli_query($db,$sql);

if(mysqli_num_rows($res2)>0) {

  $c=0;

  while($r1=mysqli_fetch_assoc($res)) {

    $dt[inventory][data][$c]=$r1;    

    $dt[inventory][data][$c][rp]=ang2($r1[amount]);    

    $dt[inventory][data][$c][update]=date(Y-m-d H:i:s,$r1[update_at]);

    $c++;

  }

} else {

  $dt[inventory][count]=0;

}



//journal

$sql2=SELECT a.*,b.descr from `journal` a JOIN `action` b ON a.action_id=b.id where a.id>0;

$res2=mysqli_query($db,$sql2);

$r2=mysqli_num_rows($res2);

$dt[journal][count]=$r2;



$sql=$sql2. order by a.action_at desc,a.id desc;

//echo $sql.;<br>;

$res=mysqli_query($db,$sql);

if(mysqli_num_rows($res2)>0) {

  $c=0;

  while($r1=mysqli_fetch_assoc($res)) {

    $dt[journal][data][$c]=$r1;    

    $dt[journal][data][$c][rp_debit]=ang2($r1[debit]);    

    $dt[journal][data][$c][rp_credit]=ang2($r1[credit]);    

    $dt[journal][data][$c][rp_balance]=ang2($r1[balance]);    

    $dt[journal][data][$c][rp]=ang2($r1[amount]);    

    $dt[journal][data][$c][update]=date(Y-m-d H:i:s,$r1[update_at]);

    $c++;

  }

} else {

  $dt[journal][count]=0;

}



//person

$sql2=SELECT * from `person` where id>0;

$res2=mysqli_query($db,$sql2);

$r2=mysqli_num_rows($res2);

$dt[person][count]=$r2;



$sql=$sql2. order by id;

//echo $sql.;<br>;

$res=mysqli_query($db,$sql);

if(mysqli_num_rows($res2)>0) {

  $c=0;

  while($r1=mysqli_fetch_assoc($res)) {

    $dt[person][data][$c]=$r1;    

    $dt[person][data][$c][update]=date(Y-m-d H:i:s,$r1[update_at]);

    $c++;

  }

} else {

  $dt[person][count]=0;

}



//product



$sql2=SELECT id,name,img,brand,qty,item_code,price_per_unit,update_at from `product` where del=0;

$res2=mysqli_query($db,$sql2);

$r2=mysqli_num_rows($res2);

$dt[product_byid][count]=$r2;



$sql=$sql2. order by id;

//echo $sql.;<br>;

$res=mysqli_query($db,$sql);

if(mysqli_num_rows($res2)>0) {

  //$c=0;

  while($r1=mysqli_fetch_assoc($res)) {

    $c=$r1[id];

    $dt[product_byid][data][$c]=$r1;

    $dt[product_byid][data][$c][hpp]=ang2($r1[price_per_unit]);

    $dt[product_byid][data][$c][amount]=ang2($r1[price_per_unit]*$r1[qty]);

    $dt[product_byid][data][$c][update]=date(Y-m-d H:i:s,$r1[update_at]);

    $sql3=SELECT a.id,a.action_id,a.transaction_id,a.item_in,a.item_out,a.`balance`,a.invoice,a.tgl,a.`inout`,b.descr from `product_trx` a JOIN `action` b ON a.action_id=b.id where product_id=.$r1[id]. order by a.action_at,a.action_id ;

    $res3=mysqli_query($db,$sql3);

    $d=0;

    while($r3=mysqli_fetch_assoc($res3)) {

      $dt[product_byid][data][$c][trx][$d]=$r3;

      $dt[product_byid][data][$c][trx][$d][amount]=ang2($r3[balance]*$r1[price_per_unit]);

      $d++;

    }

  }

} else {

  $dt[product_byid][count]=0;

}

/* */



$sql2=SELECT `brand` from `product` where `del`=0 group by `brand` order by `brand`;

  $res2=mysqli_query($db,$sql2);

  //$dt[count]=$r2;

  $count=0;

  if(mysqli_num_rows($res2)>0) {

    $c=0;

    while($r2=mysqli_fetch_assoc($res2)) {

      $dt[product][data][$c][brand]=$r2[brand];

      $sql3=SELECT id,name,qty,item_code,price_per_unit,img,update_at from `product` where del=0 and brand=.$r2[brand]. order by `name`;

      $res3=mysqli_query($db,$sql3);

      $d=0;

      while($r3=mysqli_fetch_assoc($res3)) {

        $dt[product][data][$c][items][$d]=$r3;

        $dt[product][data][$c][items][$d][hpp]=ang2($r3[price_per_unit]);

        $dt[product][data][$c][items][$d][amount]=ang2($r3[price_per_unit]*$r3[qty]);

        $dt[product][data][$c][items][$d][update]=date(Y-m-d H:i:s,$r3[update_at]);



        $sql4=SELECT a.id,a.action_id,a.transaction_id,a.item_in,a.item_out,a.`balance`,a.invoice,a.tgl,a.`inout`,b.descr from `product_trx` a JOIN `action` b ON a.action_id=b.id where product_id=.$r3[id]. order by a.action_at,a.action_id ;

        $res4=mysqli_query($db,$sql4);

        $e=0;

        while($r4=mysqli_fetch_assoc($res4)) {

          $dt[product][data][$c][items][$d][trx][$e]=$r4;

          $dt[product][data][$c][items][$d][trx][$e][amount]=ang2($r4[balance]*$r3[price_per_unit]);

          $e++;

        }        

        $d++;

        $count++;

      }

      $c++;

    }

    $dt[product][count]=$count;

  } else {

    $dt[product][count]=0;

  }  





//[sales]

$sql2=SELECT * from `sales` where del=0;

$res2=mysqli_query($db,$sql2);

$r2=mysqli_num_rows($res2);

$dt[sales][count]=$r2;



$sql=$sql2. order by id;

//echo $sql.;<br>;

$res=mysqli_query($db,$sql);

if(mysqli_num_rows($res2)>0) {

  $c=0;

  while($r1=mysqli_fetch_assoc($res)) {

    $dt[sales][data][$c]=$r1;

    $dt[sales][data][$c][rp_hpp]=ang2($r1[hpp]);

    $dt[sales][data][$c][rp_price]=ang2($r1[price]);

    $dt[sales][data][$c][rp_amount]=ang2($r1[amount]);

    $dt[sales][data][$c][pay]=$ar[cash_credit][$r1[cash_credit]];

    $dt[sales][data][$c][update]=date(Y-m-d H:i:s,$r1[update_at]);

    $c++;

  }

} else {

  $dt[sales][count]=0;

}



//[transaction]

$sql2=SELECT a.*,b.descr,b.invoice from `transaction` a JOIN `action` b ON a.id=b.id where a.id>0;

$res2=mysqli_query($db,$sql2);

$r2=mysqli_num_rows($res2);

$dt[transaction][count]=$r2;



$sql=$sql2. order by a.action_at desc,a.id desc;

//echo $sql.;<br>;

$res=mysqli_query($db,$sql);

if(mysqli_num_rows($res2)>0) {

  $c=0;

  while($r1=mysqli_fetch_assoc($res)) {

    $dt[transaction][data][$c]=$r1;    

    $dt[transaction][data][$c][tgl]=date(Y-m-d,$r1[action_at]);    

    $dt[transaction][data][$c][debit_acc]=$ar[acc_name][$r1[debit]];    

    $dt[transaction][data][$c][credit_acc]=$ar[acc_name][$r1[credit]];    

    $dt[transaction][data][$c][rp_amount]=ang2($r1[amount]);

    $dt[transaction][data][$c][update]=date(Y-m-d H:i:s,$r1[update_at]);

    $c++;

  }

} else {

  $dt[transaction][count]=0;

}



//icons

include_once $ar[path_core].u9/inc.ar.f7icon.php;

$dt[icons][count]=count($ar[f7_icon]);

foreach($ar[f7_icon] as $k=>$v) {

  $dt[icons][data][$k][name]=$v;

  $dt[icons][data][$k][id]=$k+1;

}







$dt2[result]=$dt;

$dt2[status]=true;

//echo json_encode($dt2);







  return $dt2;

  $db->close();

}