ok

Mini Shell

Direktori : /home2/selectio/public_html/lilyexpresslive/expense-invoice/api/
Upload File :
Current File : //home2/selectio/public_html/lilyexpresslive/expense-invoice/api/custom-function.php

<?php include"../config/config.php";

if($_POST['type']=="get_inhand_expense_amount"){
    
    $cash_con='';
    $exp_con='';
    
    if($_POST['payment_method']=="Cash"){$cash_con=" and type=1"; $exp_con=" and payment_method='Cash'"; }else{ $cash_con=" and type!=1"; $exp_con=" and payment_method!='Cash'";}

    
    
    
$amount=0;
 $location = $_POST['location'];
 	        $credit_amount=0;
			$depit_amount=0;
			$transfer_credit=0;$expense_amount=0;
        $statement = $pdo->prepare("SELECT tbl_cash.id,(select sum(amount) from tbl_cash WHERE type!=2 and location=$location $cash_con) as credit_amount,(select sum(amount) from tbl_cash WHERE type=0 and location=$location $cash_con) as depit_amount,(select sum(amount) from tbl_cash WHERE type=0 and otherLocation=$location $cash_con) as transfer_credit,(SELECT sum(amount) FROM `tbl_expense` where location=$location $exp_con) as expense_amount FROM `tbl_cash` WHERE location=$location GROUP BY location");
		$statement->execute();
		$query = $statement->fetchAll(PDO::FETCH_ASSOC);
		foreach( $query as $row ) {
			$credit_amount=$row['credit_amount'];
			$depit_amount=$row['depit_amount'];
			$transfer_credit=$row['transfer_credit'];
			$expense_amount=$row['expense_amount'];
		}
		if(is_null($credit_amount)){ $credit_amount=0;}if(is_null($depit_amount)){ $depit_amount=0;}if(is_null($transfer_credit)){ $transfer_credit=0;}if(is_null($expense_amount)){ $expense_amount=0;}
          $amount= ($credit_amount+$transfer_credit)-($depit_amount+$expense_amount);   
        echo $amount;
}

if($_POST['type']=="2"){
    $location = $_POST['location'];
        $statement = $pdo->prepare("SELECT id,employee_name FROM `tbl_employee` where location=$location");
		$statement->execute();
		$query = $statement->fetchAll(PDO::FETCH_ASSOC);
		$return_arr = array();
		foreach( $query as $row ) {
			$return_arr[] = $row;
		}
    echo json_encode($return_arr);
}
?>

Zerion Mini Shell 1.0