fin2@agn
BNI-PT
Man-PT
KasKecil
BCA 671
Man 709
Account Tree
db backup
eBook #1
eBook #2
eBook #3
Tax eBook #4
Color
Logout
Mutasi BNI PT
Mutasi Mandiri PT
Mutasi Mandiri 709
Mutasi Mandiri 202
Mutasi BCA 671
Mutasi BCA 471
Mutasi Jago
Action
Transaction
Journal
Report
FilePHP
Tes cURL [1]
Copy This
Save
folder
slug
param
method
body
remark
php
Copy
/home/u902783705/domains/azkapersada.com/public_html/sub/fin/
inc.transaction.php
<main> <div class="container-fluid"> <div class="row align-items-center justify-content-between pt-2"> <div class="col-auto mb-3"> <h2>Transaction</h2> </div> <div class="col-12 col-xl-auto mb-3"> <!--<a class="btn btn-xs btn-color-red" href="?op=transaction&op2=add&t=1">Cash-In</a> <a class="btn btn-xs btn-color-pink" href="?op=transaction&op2=add&t=2">Cash-Out</a> <a class="btn btn-xs btn-color-purple" href="?op=transaction&op2=add&t=3">Beli</a> <a class="btn btn-xs btn-color-indigo" href="?op=transaction&op2=add&t=4">Jual</a> <a class="btn btn-xs btn-color-blue" href="?op=transaction&op2=add&t=5">Penyusutan Aset</a> <a class="btn btn-xs btn-color-cyan" href="?op=transaction&op2=add&t=6">Penyisihan Piutang</a> <a class="btn btn-xs btn-color-brown" href="?op=transaction&op2=list&col=cat&q=3">Inventory</a>--> </div> </div> <?php switch($op2) { case "add"; add($_GET['action_id']); break; case "copy"; $sql4 = "select * from transaction order by id desc limit 1"; $res4 = mysqli_query($db, $sql4); $rw4 = mysqli_fetch_assoc($res4); if(isset($rw['id'])) { $id2=$rw4['id']+1; } else { $id2=1; } $sql = "select * from transaction where id=".$_GET['id']; $res = mysqli_query($db, $sql); $rw = mysqli_fetch_assoc($res); if(isset($rw['id'])) { $id2=$rw4['id']+1; } else { $id2=1; } $idt=array( 'id'=>$id2, 'action_at'=>strtotime($rw['action_at']), 'descr'=>$rw['descr'], 'pay_to'=>$rw['pay_to'], 'pay_from'=>$rw['pay_from'], 'cat'=>$rw['cat'], 'bank'=>$rw['bank'], 'inout'=>$rw['inout'], 'debit_1'=>$rw['debit_1'], 'credit_1'=>$rw['credit_1'], 'debit_2'=>$rw['debit_2'], 'credit_2'=>$rw['credit_2'], 'debit_amount_1'=>$rw['debit_amount_1'], 'credit_amount_1'=>$rw['credit_amount_1'], 'debit_amount_2'=>$rw['debit_amount_2'], 'credit_amount_2'=>$rw['credit_amount_2'], 'st'=>1, 'update_at'=>time(), ); Insert($db,"transaction",$idt,1); edit($id2); break; case "add2"; //echo "<pre>"; print_r($_POST); echo "</pre>"; $sql6 = "select * from action where id=".$_POST['action_id']; $res6 = mysqli_query($db, $sql6); //echo $sql; $r6 = mysqli_fetch_assoc($res6); $udt=array( 'st_trx'=>1, ); Update($db,"action",$udt,"id=".$_POST['action_id'],0); $sql5 = "select * from transaction where action_id=".$_POST['action_id']; $res5 = mysqli_query($db, $sql5); if(mysqli_num_rows($res5)==0) { $sql4 = "select * from transaction where id2=id order by id desc limit 1"; $res4 = mysqli_query($db, $sql4); $rw4 = mysqli_fetch_assoc($res4); if(isset($rw4['id'])) { $id2=$rw4['id']+1; } else { $id2=1; } //$amount=to_numeric($_POST['amount']); $udata=array( 'id'=>$id2, 'action_at'=>$_POST['action_at'], 'action_id'=>$_POST['action_id'], 'year'=>date("Y",$_POST['action_at']), 'month'=>date("Ym",$_POST['action_at']), 'seq'=>$r6['seq'], 'cat'=>$_POST['cat'], 'inout'=>$_POST['inout'], 'debit'=>$_POST['debit'], 'credit'=>$_POST['credit'], 'amount'=>to_numeric($_POST['amount']), 'st'=>1, 'update_at'=>time(), ); Insert($db,"transaction",$udata,1); tool_id3("transaction"); } else { $udt2=array( 'action_at'=>$_POST['action_at'], 'year'=>date("Y",$_POST['action_at']), 'month'=>date("Ym",$_POST['action_at']), 'seq'=>$r6['seq'], 'cat'=>$_POST['cat'], 'inout'=>$_POST['inout'], 'debit'=>$_POST['debit'], 'credit'=>$_POST['credit'], 'amount'=>to_numeric($_POST['amount']), 'st'=>1, 'update_at'=>time(), ); Update($db,"transaction",$udt2,"action_id=".$_POST['action_id'],1); } $col="b.bank"; $q=$r6['bank']; $col2="a.month"; $q2=date("Ym",$_POST['action_at']); listtransaction($q,$col,$q2,$col2,$sortby,$sort,$page); break; case "edit"; edit($_GET['id']); break; case "edit2"; //echo "<pre>"; print_r($_POST); echo "</pre>"; //$timestr=strtotime($_POST['action_at']); $sql6 = "select * from action where id=".$_POST['action_id']; $res6 = mysqli_query($db, $sql6); //echo $sql; $r6 = mysqli_fetch_assoc($res6); $timestr=$_POST['action_at']; $udata=array( //'action_at'=>strtotime($_POST['action_at']), //'action_id'=>$_POST['action_id'], //'cat'=>$_POST['cat'], //'inout'=>$_POST['inout'], 'year'=>date("Y",$timestr), 'month'=>date("Ym",$timestr), 'debit'=>$_POST['debit'], 'credit'=>$_POST['credit'], 'amount'=>to_numeric($_POST['amount']), 'update_at'=>time(), ); Update($db,"transaction",$udata,"id=".$_POST['id'],0); $sql4 = "select * from journal where id2=id order by id desc limit 1"; $res4 = mysqli_query($db, $sql4); $rw4 = mysqli_fetch_assoc($res4); $id2=$rw4['id']+1; $idt1=array( 'id'=>$id2, 'transaction_id'=>$_POST['id'], 'action_id'=>$_POST['action_id'], 'action_at'=>$_POST['action_at'], 'amount'=>to_numeric($_POST['amount']), 'debit'=>to_numeric($_POST['amount']), 'inout'=>1, 'account_code'=>$_POST['debit'], 'year'=>date("Y",$timestr), 'week'=>date("W",$timestr), 'month'=>date("Ym",$timestr), ); $udt1=array( 'transaction_id'=>$_POST['id'], 'action_id'=>$_POST['action_id'], 'action_at'=>$_POST['action_at'], 'amount'=>to_numeric($_POST['amount']), 'debit'=>to_numeric($_POST['amount']), 'inout'=>1, 'account_code'=>$_POST['debit'], 'year'=>date("Y",$timestr), 'week'=>date("W",$timestr), 'month'=>date("Ym",$timestr), 'update_at'=>time(), ); InsertUpdate($db,"journal",$idt1,$udt1,1); tool_id3("journal"); $sql4 = "select * from journal where id2=id order by id desc limit 1"; $res4 = mysqli_query($db, $sql4); $rw4 = mysqli_fetch_assoc($res4); $id2=$rw4['id']+1; $idt2=array( 'id'=>$id2, 'action_at'=>$_POST['action_at'], 'action_id'=>$_POST['action_id'], 'transaction_id'=>$_POST['id'], 'amount'=>to_numeric($_POST['amount']), 'credit'=>to_numeric($_POST['amount']), 'inout'=>2, 'account_code'=>$_POST['credit'], 'year'=>date("Y",$timestr), 'week'=>date("W",$timestr), 'month'=>date("Ym",$timestr), ); $udt2=array( 'transaction_id'=>$_POST['id'], 'action_at'=>$_POST['action_at'], 'action_id'=>$_POST['action_id'], 'amount'=>to_numeric($_POST['amount']), 'credit'=>to_numeric($_POST['amount']), 'inout'=>2, 'account_code'=>$_POST['credit'], 'year'=>date("Y",$timestr), 'week'=>date("W",$timestr), 'month'=>date("Ym",$timestr), 'update_at'=>time(), ); InsertUpdate($db,"journal",$idt2,$udt2,1); tool_id3("journal"); //add inventory if($_POST['debit']=='12100' or $_POST['debit']=='12200') { $sql5 = "select * from inventory order by id desc limit 1"; $res5 = mysqli_query($db, $sql5); $rw5 = mysqli_fetch_assoc($res5); if(isset($rw5['id'])) { $id5=$rw5['id']+1; } else { $id5=1; } $idt5=array( 'id'=>$id5, 'transaction_id'=>$_POST['id'], 'action_id'=>$_POST['action_id'], 'remark'=>$_POST['descr'], 'purchase_date'=>$timestr, 'code'=>$_POST['debit'], 'price_per_unit'=>to_numeric($_POST['amount']), 'create_at'=>time(), ); $udt5=array( 'remark'=>$_POST['descr'], 'action_id'=>$_POST['action_id'], 'code'=>$_POST['debit'], 'purchase_date'=>$timestr, 'price_per_unit'=>to_numeric($_POST['amount']), 'update_at'=>time(), ); InsertUpdate($db,"inventory",$idt5,$udt5,1); } $_POST['action_at']=$timestr; account_equation($_POST); JournalCount(date("Y",$_POST['action_at'])); $col="b.bank"; $q=$r6['bank']; $col2="a.year"; $q2=date("Y",$_POST['action_at']); listtransaction($q,$col,$q2,$col2,$sortby,$sort,$page); break; case "tool"; $sql4 = "select * from transaction order by id desc limit 1"; $res4 = mysqli_query($db, $sql4); $rw4 = mysqli_fetch_assoc($res4); if(isset($rw['id'])) { $id2=$rw4['id']+1; } else { $id2=1; } $sql = "select * from cash order by transaction_date "; $res = mysqli_query($db, $sql); while($rw = mysqli_fetch_assoc($res)) { $idt=array( 'id'=>$id2, 'action_at'=>$rw['transaction_date'], 'descr'=>$rw['description'], 'invoice'=>$rw['invoice'], 'pay_to'=>$rw['pay_to'], 'pay_from'=>$rw['pay_from'], 'amount'=>$rw['amount'], 'inout'=>$rw['inout'], 'update_at'=>time(), 'st'=>1, ); $udt=array( 'action_at'=>$rw['transaction_date'], 'descr'=>$rw['description'], 'invoice'=>$rw['invoice'], 'pay_to'=>$rw['pay_to'], 'pay_from'=>$rw['pay_from'], 'amount'=>$rw['amount'], 'inout'=>$rw['inout'], 'update_at'=>time(), ); InsertUpdate($db,"transaction",$idt,$udt,1); $id2++; } listtransaction($q,$col,$q2,$col2,$sortby,$sort,$page); break; case "tool2"; $sql = "select * from transaction order by id "; $res = mysqli_query($db, $sql); while($rw = mysqli_fetch_assoc($res)) { $udt=array( 'action_at'=>$rw['action_at'], 'update_at'=>time(), ); Update($db,"journal",$udt,"transaction_id=".$rw['id'],1); } listtransaction($q,$col,$q2,$col2,$sortby,$sort,$page); break; case "del"; $udata=array( 'st'=>0, 'update_at'=>time(), ); Update($db,"transaction",$udata,"id=".$_GET['id'],0); listtransaction($q,$col,$q2,$col2,$sortby,$sort,$page); break; case "reset"; $udata=array( 'st'=>1, 'update_at'=>time(), ); Update($db,"transaction",$udata,"",0); listtransaction($q,$col,$q2,$col2,$sortby,$sort,$page); case "list"; default; listtransaction($q,$col,$q2,$col2,$sortby,$sort,$page); } ?> </div> </main> <?php function listtransaction($q,$col,$q2,$col2,$sortby,$sort,$page) { global $db,$ar; //print_r($ar); ?> <table class="table table-bordered table-striped" id="dataTable_13d" width="100%" cellspacing="0"> <thead> <tr class="table-primary"> <th>Id</th> <th>At</th> <th>Y</th> <th>M</th> <th>ActionId</th> <th>Descr</th> <th>Amount</th> <th>Via</th> <th>Cat</th> <th>Debit</th> <th>Credit</th> <th>Jo</th> <th>Eq</th> <th>Update</th> <th>Menu</th> </tr> </thead> <tbody> <?php $sql = "select a.*,b.descr as descr, b.bank as bank from transaction a JOIN `action` b ON a.action_id=b.id where a.st>0 "; if($col!='') { $sql .= " and ".$col."='".$q."' "; } if($col2!='') { $sql .= " and ".$col2."='".$q2."' "; } $sql .= " order by a.action_at asc,a.seq asc"; $res = mysqli_query($db, $sql); //echo $sql; $j['amount']=0; while($rw = mysqli_fetch_assoc($res)) { $j['amount']=$j['amount']+$rw['amount']; $sql2="SELECT count(*) as jum from journal where transaction_id=".$rw['id']; $res2 = mysqli_query($db, $sql2); $r2 = mysqli_fetch_assoc($res2); $sql3="SELECT count(*) as jum from account_equation where transaction_id=".$rw['id']; $res3 = mysqli_query($db, $sql3); $r3 = mysqli_fetch_assoc($res3); ?> <tr> <td><?=$rw['id'];?></td> <td><?=date("Y-m-d",$rw['action_at']);?>-<?=$rw['seq'];?></td> <td><a href="?op=transaction&op2=list&col=a.year&q=<?=$rw['year'];?>"><?=$rw['year'];?></a></td> <td><a href="?op=transaction&op2=list&col=a.month&q=<?=$rw['month'];?>"><?=$rw['month'];?></a></td> <td><a href="?op=action&op2=edit&id=<?=$rw['action_id'];?>"><?=$rw['action_id'];?></a></td> <td><?=$rw['descr'];?></td> <td class="text-right"><?=ang2($rw['amount']);?></td> <td><a href="?op=transaction&op2=list&col2=b.bank&q2=<?=$rw['bank'];?>&col=<?=$col;?>&q=<?=$q;?>"><?=$rw['bank'];?></a></td> <td><a href="?op=transaction&op2=list&col=a.cat&q=<?=$rw['cat'];?>"><?=$rw['cat'];?></a></td> <td><a href="?op=transaction&op2=list&col=a.debit&q=<?=$rw['debit'];?>"><?=$rw['debit'];?></a></td> <td><a href="?op=transaction&op2=list&col=a.credit&q=<?=$rw['credit'];?>"><?=$rw['credit'];?></a></td> <td class="text-right"><?=ang2($r2['jum']);?></td> <td class="text-right"><?=ang2($r3['jum']);?></td> <td class="text-right"><?=date("y-m-d H:i:s",$rw['update_at']);?></td> <td nowrap> <a class="btn btn-xs btn-warning" href="?op=transaction&op2=edit&id=<?=$rw['id'];?>">edit</a> <!--<a class="btn btn-xs btn-success" href="?op=transaction&op2=copy&id=<?=$rw['id'];?>">copy</a> <!--<a class="btn btn-xs btn-danger" onclick="updateRecord('transaction','st',0,<?=$rw['id'];?>);">del</a>--> <a class="btn btn-xs btn-info" onclick="PostEq(<?=$rw['id'];?>);">Update</a> </td> </tr> <?php } ?> </tbody> <tfoot> <tr class="table-primary"> <th colspan="6"></th> <th class="text-right"><?=ang2($j['amount']);?></th> <th colspan="8"></th> </tr> </tfoot> </table><?=$sql;?><br> <script> function updateRecord(tbl,col,val,id) { $.ajax({ url: "tbl.update.php", type: "POST", data:'tbl='+tbl+'&col='+col+'&val='+val+'&id='+id, success: function(data){ //$(editableObj).css("background","#FDFDFD"); } }); } function PostEq(id) { //if(confirm("Are you sure you want to delete this row?")) { $.ajax({ url: "post_eq.php", type: "POST", data:'id='+id, success: function(data){ //$("#table-row-"+id).remove(); } }); //} } </script> <?php } function edit($id) { global $db,$ar; $sql = "select * from transaction where id=".$id; $res = mysqli_query($db, $sql); //echo $sql; $rw = mysqli_fetch_assoc($res); $sql2 = "select * from `action` where id=".$rw['action_id']; $res2 = mysqli_query($db, $sql2); //echo $sql; $r2 = mysqli_fetch_assoc($res2); $rw['descr']=$r2['descr']; ?> <h3>Edit</h3> <form action="index.php?op=transaction&op2=edit2" method="post" enctype="multipart/form-data"> <input type="hidden" name="id" value="<?=$id;?>"> <input type="hidden" name="cat" value="<?=$rw['cat'];?>"> <input type="hidden" name="action_id" value="<?=$rw['action_id'];?>"> <input type="hidden" name="inout" value="<?=$rw['inout'];?>"> <input type="hidden" name="action_at" value="<?=$rw['action_at'];?>"> <div class="form-group row"> <label for="debit" class="col-sm-1 col-form-label">Debit</label> <div class="col-sm-2"> <select class="form-control" name="debit"> <option value=0></option> <?php $sql1 = "select * from account where trx=1 order by code"; $res1 = mysqli_query($db, $sql1); //echo $sql; while($rw1 = mysqli_fetch_assoc($res1)) { if($rw['debit']==$rw1['code']) { $sel="selected"; } else { $sel=""; } ?> <option <?=$sel;?> value="<?=$rw1['code'];?>"><?=$rw1['code'].", ".$rw1['name'];?></option> <?php } ?> </select> </div> <label for="credit" class="col-sm-1 col-form-label">Credit</label> <div class="col-sm-2"> <select class="form-control" name="credit"> <option value=0></option> <?php $sql1 = "select * from account where trx=1 order by code"; $res1 = mysqli_query($db, $sql1); //echo $sql; while($rw1 = mysqli_fetch_assoc($res1)) { if($rw['credit']==$rw1['code']) { $sel="selected"; } else { $sel=""; } ?> <option <?=$sel;?> value="<?=$rw1['code'];?>"><?=$rw1['code'].", ".$rw1['name'];?></option> <?php } ?> </select> </div> <label for="amount" class="col-sm-1 col-form-label">Amount</label> <div class="col-sm-2"> <input type="text" value="<?=$rw['amount'];?>" class="form-control" name="amount" placeholder="Amount"> </div> </div> <div class="form-group row"> <div class="col-sm-10 offset-sm-2 text-right"> <!--<a href="?op=transaction&op2=del&id=<?=$id;?>" class="btn btn-danger">Delete</a> --><button type="submit" name="submit" class="btn btn-primary">Update</button> </div> </div> </form> <h3>Journal</h3> <?php list_journal($rw); $sql4 = "select * from `account_equation` where action_id=".$rw['action_id']; $res4 = mysqli_query($db, $sql4); //echo $sql; $r4 = mysqli_fetch_assoc($res4); echo "<pre>"; print_r($r4); echo "</pre>"; } function add($id) { global $db,$ar; $sql2 = "select * from `action` where id=".$id; $res2 = mysqli_query($db, $sql2); //echo $sql; $rw = mysqli_fetch_assoc($res2); //$rw['descr']=$r2['descr']; echo "<pre>"; print_r($rw); echo "</pre>"; ?> <h3>Add</h3> <form action="index.php?op=transaction&op2=add2" method="post" enctype="multipart/form-data"> <input type="hidden" name="cat" value="<?=$rw['cat'];?>"> <input type="hidden" name="action_id" value="<?=$rw['id'];?>"> <input type="hidden" name="inout" value="<?=$rw['inout'];?>"> <input type="hidden" name="action_at" value="<?=$rw['action_at'];?>"> <div class="form-group row"> <label for="amount" class="col-sm-1 col-form-label">Amount</label> <div class="col-sm-2"> <input type="text" class="form-control" name="amount" placeholder="Amount"> </div> <label for="debit" class="col-sm-1 col-form-label">Debit</label> <div class="col-sm-2"> <select class="form-control" name="debit"> <option value=0></option> <?php $sql1 = "select * from account where trx=1 order by code"; $res1 = mysqli_query($db, $sql1); //echo $sql; while($rw1 = mysqli_fetch_assoc($res1)) { //if($rw['debit']==$rw1['code']) { $sel="selected"; } else { $sel=""; } ?> <option value="<?=$rw1['code'];?>"><?=$rw1['code'].", ".$rw1['name'];?></option> <?php } ?> </select> </div> </div> <div class="form-group row"> <label for="debit" class="col-sm-5 col-form-label"></label> <label for="credit" class="col-sm-1 col-form-label">Credit</label> <div class="col-sm-2"> <select class="form-control" name="credit"> <option value=0></option> <?php $sql1 = "select * from account where trx=1 order by code"; $res1 = mysqli_query($db, $sql1); //echo $sql; while($rw1 = mysqli_fetch_assoc($res1)) { //if($rw['credit']==$rw1['code']) { $sel="selected"; } else { $sel=""; } ?> <option value="<?=$rw1['code'];?>"><?=$rw1['code'].", ".$rw1['name'];?></option> <?php } ?> </select> </div> </div> <div class="form-group row"> <div class="col-sm-10 offset-sm-2 text-right"> <button type="submit" name="submit" class="btn btn-primary">Add</button> </div> </div> </form> <?php } function list_journal($trx) { global $db,$ar; //print_r($ar); ?> <h4><?=$trx['descr'];?></h4> <table class="table table-bordered table-striped" id="dataTable_1a" width="100%" cellspacing="0"> <thead> <tr class="table-primary"> <th>ID</th> <th>At</th> <th>Code</th> <th>Name</th> <th>Debit</th> <th>Credit</th> <th>Menu</th> </tr> </thead> <tbody> <?php $sql = "select a.*,b.name from journal a JOIN account b ON a.account_code=b.code where a.st>0 and a.transaction_id=".$trx['id']; $res = mysqli_query($db, $sql); //echo $sql; while($rw = mysqli_fetch_assoc($res)) { ?> <tr> <td><?=$rw['id'];?></td> <td class="text-right"><?=date("Y-m-d",$trx['action_at']);?></td> <td><?=$rw['account_code'];?></td> <td><?=$rw['name'];?></td> <td class="text-right"><?=ang2($rw['debit']);?></td> <td class="text-right"><?=ang2($rw['credit']);?></td> <td nowrap> <a class="btn btn-xs btn-warning" href="?op=transaction&op2=edit&id=<?=$rw['id'];?>">edit</a> <a class="btn btn-xs btn-danger" onclick="updateRecord('journal','st',0,<?=$rw['id'];?>);">del</a> </td> </tr> <?php } ?> </tbody> </table> <?php } function list_acc_equal($trx) { global $db,$ar; //print_r($ar); ?> <h4><?=$trx['descr'];?></h4> <table class="table table-bordered table-striped" id="dataTable_1a" width="100%" cellspacing="0"> <thead> <tr class="table-primary"> <th>ID</th> <th>At</th> <th>Code</th> <th>Name</th> <th>Debit</th> <th>Credit</th> <th>Menu</th> </tr> </thead> <tbody> <?php $sql = "select * from account_equation where a.st>0 and id=".$trx['id']; $res = mysqli_query($db, $sql); //echo $sql; while($rw = mysqli_fetch_assoc($res)) { ?> <tr> <td><?=$rw['id'];?></td> <td class="text-right"><?=date("Y-m-d",$trx['action_at']);?></td> <td><?=$rw['account_code'];?></td> <td><?=$rw['name'];?></td> <td class="text-right"><?=ang2($rw['debit']);?></td> <td class="text-right"><?=ang2($rw['credit']);?></td> <td nowrap> <a class="btn btn-xs btn-warning" href="?op=transaction&op2=edit&id=<?=$rw['id'];?>">edit</a> <a class="btn btn-xs btn-danger" onclick="updateRecord('journal','st',0,<?=$rw['id'];?>);">del</a> </td> </tr> <?php } ?> </tbody> </table> <?php } ?>