function ExportfMandiri2($id) {

  global $db,$ar;  

  $sql4 = select * from mandiri_mutasi where id=.$id;

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

  $r4 = mysqli_fetch_assoc($res4);

  //echo <pre>; print_r($r4); echo </pre>;

  

  if($r4[debit]==0) {

      $amount=$r4[kredit];

      $inout=2;

      $payto=Mandiri IDR .substr($r4[rek],-3);

      $payfrom=;

  } else {

      $amount=$r4[debit];

      $inout=1;

      $payfrom=Mandiri IDR .substr($r4[rek],-3);

      $payto=;

  }

  

  if($r4[payto]!=) {

      $payto2=$r4[payto];

  } else {

      $payto2=$payto;

  }



  $sql3 = select * from action where bank=1 and amount=.$amount. and tgl=.$r4[tgl].;

  echo $sql3.<br>;

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

  if(mysqli_num_rows($res3)>0) {

    $r3 = mysqli_fetch_assoc($res3);

    //echo <pre>; print_r($r3); echo </pre>;

    $udt=array(

      action_id=>$r3[id],

    );

    Update($db,mandiri_mutasi,$udt,id=.$r4[id],1);

      

  } else {

    $sql2 = select id from action where id2=id order by id desc limit 1;

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

    $r2 = mysqli_fetch_assoc($res2);

    $id2=$r2[id]+1;

    $idt=array(

          id=>$id2,

          action_at=>$r4[tgl2],

          tgl=>$r4[tgl],

          month=>$r4[month],

          year=>$r4[year],

          descr=>$r4[keterangan]. .$r4[remark],

          pay_to=>$payto2,

          pay_from=>$payfrom,

          cat=>$inout,

          seq=>$r4[seq],

          inout=>$inout,

          bank=>$ar[manp][$r4[rek]],

          amount=>$amount,

          st=>1,

          update_at=>time(),

    );

    Insert($db,action,$idt,1);

    tool_id3(action);      

    $udt=array(

      action_id=>$id2,

    );

    Update($db,mandiri_mutasi,$udt,id=.$r4[id],1);

  }  

}