当前位置: 首页>>代码示例>>PHP>>正文


PHP calculate函数代码示例

本文整理汇总了PHP中calculate函数的典型用法代码示例。如果您正苦于以下问题:PHP calculate函数的具体用法?PHP calculate怎么用?PHP calculate使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了calculate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: calculate

function calculate($max)
{
    if ($max == 1) {
        return 1;
    }
    return lcd($max, calculate($max - 1));
}
开发者ID:juno,项目名称:code-snippet,代码行数:7,代码来源:prob5.php

示例2: set_variable

function set_variable($v, $e) {
	global $symbol_table;
	$symbol_table[$v] = $e;
}
function get_variable($v) {
	global $symbol_table;
	return doubleval($symbol_table[$v]);
}

function calculate($line) {
	global $parser;
	if (!strlen($line)) return;
	try {
		$parser->reset();
		foreach(tokenize($line) as $t) {
			if (is_numeric($t)) $parser->eat('num', doubleval($t));
			else if (ctype_alpha($t)) $parser->eat('var', $t);
			else $parser->eat("'$t'", null);
		}
		$parser->eat_eof();
	} catch (parse_error $e) {
		echo $e->getMessage(), "\n";
	}
}

$parser = new parse_engine(new calc());
while ($line = fgets(STDIN)) calculate(trim($line));



开发者ID:rvanvelzen,项目名称:lime,代码行数:27,代码来源:calc.php

示例3: foreach

            continue;
        }
        foreach ($lpp as $prevoz2) {
            //s katerimi lppji sploh ujamemo deadline
            if (strtotime($prevoz2[1] . ':00') >= strtotime($deadLine . ':00')) {
                continue;
            }
            //ali je dovolj velika razlika med alpteourjem in lppjem
            if (strtotime($prevoz2[0] . ':00') - strtotime($prevoz1[1] . ':00') < $varnostneMinuteNaPrestopu * 60) {
                continue;
            }
            $result = $prevoz1[0] . '->' . $prevoz1[1] . '   ' . $prevoz2[0] . '->' . $prevoz2[1] . "\r\n";
        }
    }
    echo $result;
}
//{04:35, 05:05}, {05:10, 05:40}...
//global
$alpetour = array();
$lpp = array();
$pathAlpetour = 'alpetour.txt';
$pathLpp = 'lpp2.txt';
$voznjaLpp = 12;
//lpp time to get from lpp.txt to destination
$varnostneMinuteNaPrestopu = 4;
// difference between alpetour arival time and lpp take off :)
$deadLine = '11:09';
//when you need to be at lpp destination
readData($pathAlpetour, $pathLpp, $voznjaLpp);
calculate($varnostneMinuteNaPrestopu, $deadLine);
开发者ID:andrazjelenc,项目名称:Alpetour2Lpp,代码行数:30,代码来源:run.php

示例4: calculate

//	$value = $_GET["edad"];
//}else{
//	$value = $POST["edad"];
//}
//$result = calculate($edad);
//echo $result;
?>
<html>
<head>
	<title></title>
</head>
<body>
	<?php 
$value = "";
if ($_SERVER["REQUEST_METHOD"] == "GET") {
    $value = $_GET["edad"];
} else {
    $value = $_POST["edad"];
}
$res = calculate($value);
if ($res["status"] == true) {
    echo "Fue exitoso: <br>" . $res["data"] . "</br>";
} else {
    if ($res["status"] == false) {
        //fall
        echo "Fallo:" . $res["data"];
    }
}
?>
</body>
</html>
开发者ID:enzomartinez,项目名称:php-training,代码行数:31,代码来源:calculate.php

示例5: array

			
			<article style="color:#FFFFFF;">
				<p>
					<!-- <center><img src="logo_big.png"></center> Insert Main Logo here -->
					
					<hr/>
					<center><h1>Bitcoin Tracker</h1></center>
					<hr/>
					<p>
						
						<?php 
// Get current information
$values = array();
$result = array();
$values = get_bitcoin_data("birdonwheels5");
$result = calculate($values);
?>
						
						<div class="box">
							<p>
								Welcome! This tool lets you track bitcoin purchases and spends.
							</p>
						</div>
						
						<div class="box">
							<p>
								<center><h3>Bitcoin Summary Statistics</h3>
								
								<table>
								<tr>
									<td>
开发者ID:newmight2015,项目名称:adminpanel,代码行数:30,代码来源:index.php

示例6: GroupCancelWrit

    case "GroupCancelWrit":
        GroupCancelWrit();
    case "selectPossibleTransferWrits":
        selectPossibleTransferWrits();
    case "selectArrearTransferWrits":
        selectArrearTransferWrits();
    case "transferAction":
        transferAction();
    case "ArrearTransferAction":
        ArrearTransferAction();
    case "confirmAction":
        confirmAction();
    case "recalculate":
        recalculate();
    case "calculate":
        calculate();
    case "Prior_Corrective_Writ":
        Prior_Corrective_Writ();
    case "Next_Corrective_Writ":
        Next_Corrective_Writ();
}
function selectPersonWrt()
{
    $query = "DROP TABLE IF EXISTS temp_sum_item_writs2";
    PdoDataAccess::runquery($query);
    $qry = " CREATE TEMPORARY TABLE temp_sum_item_writs2  AS\n                select sum(w.value) sumValue ,w.writ_id , w.writ_ver, w.staff_id\n\t\t\t\tfrom writ_salary_items w\n\t\t\t\t\tjoin staff s on(w.staff_id=s.staff_id)\n\t\t\t\t\tjoin persons p on(p.PersonID=? AND s.PersonID=p.PersonID)\n                group by writ_id , writ_ver, staff_id";
    PdoDataAccess::runquery($qry, array($_GET["Q0"]));
    //if($_SESSION['UserID'] == 'jafarkhani') {	echo PdoDataAccess::GetLatestQueryString();  die() ;  }
    $query = " ALTER TABLE temp_sum_item_writs2 ADD INDEX(writ_id,writ_ver,staff_id) ";
    PdoDataAccess::runquery($query);
    $whr = "";
开发者ID:jafarkhani,项目名称:rtfund,代码行数:31,代码来源:writ.data.php

示例7: calculate_possible_polls

function calculate_possible_polls($users)
{
    mysql_query("TRUNCATE TABLE candidate_poll");
    foreach ($users as $reviewee) {
        foreach ($users as $reviewer) {
            $reviewer_id = (int) $reviewer['ID'];
            $reviewee_id = (int) $reviewee['ID'];
            if ($reviewer_id == $reviewee_id) {
            } else {
                if ($reviewer_id == get_team_manager($reviewee_id)) {
                    // Enkel rijen toevegen waarbij de reviewer en reviewee verschillen of waarbij de reviewer niet te teammanager is van de reviewee.
                } else {
                    mysql_query("INSERT INTO candidate_poll (Reviewer, Reviewee, Score, Ok_reviewee, Ok_reviewer, Ok_overall) VALUES ({$reviewer_id}, {$reviewee_id}, 0, 0, 0, 0)");
                }
            }
        }
    }
    calculate($users);
}
开发者ID:johanheylen,项目名称:threesixtieweb,代码行数:19,代码来源:functions.php

示例8: display

function display($_POST)
{
    extract($_POST);
    $prev_yr_schema = substr(YR_DB, 0, 2) . (substr(YR_DB, 2) - 1);
    if ($prev_yr_schema < 0) {
        return "<li class='err'>No prior years found.</li>";
    }
    /* "prior" should be from beginning of month (iow the end of the previous)
    		or if it is the first period the end of period 0 (end of last year)  */
    global $MONPRD, $PRDMON;
    $month_from = $PRDMON[$MONPRD[$month_from] - 1];
    switch (strtolower($key)) {
        case "print":
        case "save":
        case "export to spreadsheet":
            $print_func = true;
            break;
        default:
            $print_func = false;
            break;
    }
    // Retrieve the accounts list from Cubit
    db_conn("cubit");
    $sql = "SELECT * FROM saved_cf_accounts";
    $cfacc_rslt = db_exec($sql) or errDie("Unable to retrieve accounts list from Cubit.");
    $i = 0;
    while ($cfacc_data = pg_fetch_array($cfacc_rslt)) {
        // Multidimensional array, variable variable
        ${$cfacc_data["category"]}[] = $cfacc_data["accid"];
    }
    $cat_list = array("nciis" => "Non Cash Item in Income Statement", "ciaal" => "Change in Assets and Liabilities", "cffuif" => "Cash Flows From / Used in Financing", "cffuii" => "Cash Flows From / Used in Investing");
    $cat_total = array("ciaal" => "Net cash provided by operating activities", "cffuif" => "Net cash provided by financing activities", "cffuii" => "Net cash used in investing activities");
    // Net cash and cash equivalents, beginning of period
    $cash_equiv_bop = array();
    $cash_equiv_bop["curr_total"] = 0;
    $cash_equiv_bop["prev_total"] = 0;
    $cash_equiv_bop["var_total"] = 0;
    $cash_equiv_bop["percvar_total"] = 0;
    foreach ($cat_list as $key => $value) {
        if (($key == "cffuif" || $key == "cffuii") && isset(${"acc_{$key}"})) {
            foreach (${"acc_{$key}"} as $accid) {
                db_conn("core");
                $sql = "SELECT * FROM trial_bal_actual WHERE accid='{$accid}' AND month='{$month_from}'";
                $rslt = db_exec($sql) or errDie("Unable to retrieve trial balance data from Cubit.");
                $py_data = pg_fetch_array($rslt);
                $sql = "SELECT * FROM trial_bal_actual WHERE accid='{$accid}' AND month='{$month_to}'";
                $rslt = db_exec($sql) or errDie("Unable to retrieve trial balance data from Cubit.");
                $tb_data = pg_fetch_array($rslt);
                /*if ($prev_yr_schema) {
                			db_conn($prev_yr_schema);
                			$sql = "SELECT * FROM year_balance WHERE accid='$accid'";
                			$rslt = db_exec($sql) or errDie("Unable to retrieve previous year data from Cubit.");
                			$py_data = pg_fetch_array($rslt);
                		} else {
                			$py_data = array(
                				"debit" => 0,
                				"credit" => 0
                			);
                		}*/
                db_conn("core");
                $sql = "SELECT toptype FROM accounts WHERE accid='{$accid}'";
                $rslt = db_exec($sql) or errDie("Unable to retrieve accounts from Cubit.");
                $toptype = pg_fetch_result($rslt, 0);
                $cash_equiv_bop["curr_total"] += calculate($toptype, $tb_data["debit"], $tb_data["credit"]);
                $cash_equiv_bop["prev_total"] += calculate($toptype, $py_data["debit"], $py_data["credit"]);
            }
        }
    }
    $cash_equiv_bop["var_total"] = $cash_equiv_bop["curr_total"] - $cash_equiv_bop["prev_total"];
    if ($cash_equiv_bop["curr_total"] && $cash_equiv_bop["prev_total"]) {
        $cash_equiv_bop["percvar_total"] = $cash_equiv_bop["curr_total"] / $cash_equiv_bop["prev_total"] * 100;
    } else {
        $cash_equiv_bop["percvar_total"] = 0;
    }
    // Net cash and cash equivalents, end of period
    $cash_equiv_eop = array();
    $cash_equiv_eop["curr_total"] = 0;
    $cash_equiv_eop["prev_total"] = 0;
    $cash_equiv_eop["var_total"] = 0;
    $cash_equiv_eop["percvar_total"] = 0;
    foreach ($cat_list as $key => $value) {
        if (($key == "cffuif" || $key == "cffuii") && isset(${"acc_{$key}"})) {
            foreach (${"acc_{$key}"} as $accid) {
                db_conn("core");
                $sql = "SELECT * FROM trial_bal_actual WHERE accid='{$accid}' AND month='{$month_from}'";
                $rslt = db_exec($sql) or errDie("Unable to retrieve trial balance data from Cubit.");
                $py_data = pg_fetch_array($rslt);
                $sql = "SELECT * FROM trial_bal_actual WHERE accid='{$accid}' AND month='{$month_to}'";
                $rslt = db_exec($sql) or errDie("Unable to retrieve trial balance data from Cubit.");
                $tb_data = pg_fetch_array($rslt);
                /*$py_month = strtolower(getMonthName($month_to));
                		db_conn($prev_yr_schema);
                		$sql = "SELECT * FROM $py_month WHERE accid='$accid'";
                		$rslt = db_exec($sql) or errDie("Unable to retrieve previous year data from Cubit.");
                		$py_data = pg_fetch_array($rslt);*/
                db_conn("core");
                $sql = "SELECT toptype FROM accounts WHERE accid='{$accid}'";
                $rslt = db_exec($sql) or errDie("Unable to retrieve accounts from Cubit.");
                $toptype = pg_fetch_result($rslt, 0);
                $cash_equiv_eop["curr_total"] += calculate($toptype, $tb_data["debit"], $tb_data["credit"]);
//.........这里部分代码省略.........
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:101,代码来源:cash-flow.php

示例9: AnotherCalculate

function AnotherCalculate($arr, $int)
{
    return calculate($arr, $int);
}
开发者ID:iqbalfn,项目名称:run-php,代码行数:4,代码来源:my-function.php

示例10: profitloss

 /**
  * profitloss method
  *
  * @return void
  */
 public function profitloss()
 {
     $this->set('title_for_layout', __d('webzash', 'Trading and Profit & Loss Statement'));
     $this->set('subtitle', '');
     /* POST */
     if ($this->request->is('post')) {
         if ($this->request->data['Profitloss']['opening'] == 1) {
             return $this->redirect(array('plugin' => 'webzash', 'controller' => 'reports', 'action' => 'profitloss', 'options' => 1, 'opening' => 1));
         } else {
             if (!empty($this->request->data['Profitloss']['startdate']) || !empty($this->request->data['Profitloss']['enddate'])) {
                 return $this->redirect(array('plugin' => 'webzash', 'controller' => 'reports', 'action' => 'profitloss', 'options' => 1, 'opening' => 0, 'startdate' => $this->request->data['Profitloss']['startdate'], 'enddate' => $this->request->data['Profitloss']['enddate']));
             } else {
                 return $this->redirect(array('plugin' => 'webzash', 'controller' => 'reports', 'action' => 'profitloss'));
             }
         }
     }
     $only_opening = false;
     $startdate = null;
     $enddate = null;
     if (empty($this->passedArgs['options'])) {
         $this->set('options', false);
         /* Sub-title*/
         $this->set('subtitle', __d('webzash', 'Closing Trading and Profit & Loss Statement as on ') . dateFromSql(Configure::read('Account.enddate')));
     } else {
         $this->set('options', true);
         if (!empty($this->passedArgs['opening'])) {
             $only_opening = true;
             $this->request->data['Profitloss']['opening'] = '1';
             /* Sub-title*/
             $this->set('subtitle', __d('webzash', 'Opening Trading and Profit & Loss Statement as on ') . dateFromSql(Configure::read('Account.startdate')));
         } else {
             if (!empty($this->passedArgs['startdate'])) {
                 $startdate = dateToSQL($this->passedArgs['startdate']);
                 $this->request->data['Profitloss']['startdate'] = $this->passedArgs['startdate'];
             }
             if (!empty($this->passedArgs['enddate'])) {
                 $enddate = dateToSQL($this->passedArgs['enddate']);
                 $this->request->data['Profitloss']['enddate'] = $this->passedArgs['enddate'];
             }
             /* Sub-title*/
             if (!empty($this->passedArgs['startdate']) && !empty($this->passedArgs['enddate'])) {
                 $this->set('subtitle', __d('webzash', 'Trading and Profit & Loss Statement from ' . dateFromSql(dateToSQL($this->passedArgs['startdate'])) . ' to ' . dateFromSql(dateToSQL($this->passedArgs['enddate']))));
             } else {
                 if (!empty($this->passedArgs['startdate'])) {
                     $this->set('subtitle', __d('webzash', 'Trading and Profit & Loss Statement from ' . dateFromSql(dateToSQL($this->passedArgs['startdate'])) . ' to ' . dateFromSql(Configure::read('Account.enddate'))));
                 } else {
                     if (!empty($this->passedArgs['enddate'])) {
                         $this->set('subtitle', __d('webzash', 'Trading and Profit & Loss Statement from ' . dateFromSql(Configure::read('Account.startdate')) . ' to ' . dateFromSql(dateToSQL($this->passedArgs['enddate']))));
                     }
                 }
             }
         }
     }
     /**********************************************************************/
     /*********************** GROSS CALCULATIONS ***************************/
     /**********************************************************************/
     /* Gross P/L : Expenses */
     $gross_expenses = new AccountList();
     $gross_expenses->Group =& $this->Group;
     $gross_expenses->Ledger =& $this->Ledger;
     $gross_expenses->only_opening = $only_opening;
     $gross_expenses->start_date = $startdate;
     $gross_expenses->end_date = $enddate;
     $gross_expenses->affects_gross = 1;
     $gross_expenses->start(4);
     $pandl['gross_expenses'] = $gross_expenses;
     $pandl['gross_expense_total'] = 0;
     if ($gross_expenses->cl_total_dc == 'D') {
         $pandl['gross_expense_total'] = $gross_expenses->cl_total;
     } else {
         $pandl['gross_expense_total'] = calculate($gross_expenses->cl_total, 0, 'n');
     }
     /* Gross P/L : Incomes */
     $gross_incomes = new AccountList();
     $gross_incomes->Group =& $this->Group;
     $gross_incomes->Ledger =& $this->Ledger;
     $gross_incomes->only_opening = $only_opening;
     $gross_incomes->start_date = $startdate;
     $gross_incomes->end_date = $enddate;
     $gross_incomes->affects_gross = 1;
     $gross_incomes->start(3);
     $pandl['gross_incomes'] = $gross_incomes;
     $pandl['gross_income_total'] = 0;
     if ($gross_incomes->cl_total_dc == 'C') {
         $pandl['gross_income_total'] = $gross_incomes->cl_total;
     } else {
         $pandl['gross_income_total'] = calculate($gross_incomes->cl_total, 0, 'n');
     }
     /* Calculating Gross P/L */
     $pandl['gross_pl'] = calculate($pandl['gross_income_total'], $pandl['gross_expense_total'], '-');
     /**********************************************************************/
     /************************* NET CALCULATIONS ***************************/
     /**********************************************************************/
     /* Net P/L : Expenses */
     $net_expenses = new AccountList();
//.........这里部分代码省略.........
开发者ID:lognaume,项目名称:webzash,代码行数:101,代码来源:ReportsController.php

示例11: switch

#
#
#
#
#
#
#
#
# get settings
require "settings.php";
require "libs/ext.lib.php";
require "core-settings.php";
if (isset($_POST['key'])) {
    switch ($_POST["key"]) {
        case "calc":
            $OUTPUT = calculate();
            break;
        default:
            $OUTPUT = confirm();
    }
} else {
    $OUTPUT = confirm();
}
# get template
require "template.php";
# confirm
function confirm()
{
    db_conn('cubit');
    $Sl = "SELECT * FROM monthcloses WHERE type='Interest' ORDER BY id DESC LIMIT 1";
    $Rx = db_exec($Sl) or errDie("Unable to get monthclose from db.");
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:31,代码来源:calc-int.php

示例12: calculate

		</select> 
		<input type="number" name="number2" class="form-control" value="<?php 
echo $_POST["number2"];
?>
"> 
		<input type="submit" value="Apreiķināt" class="btn btn-primary" name="submit">
	</form>
</p>

<?php 
$number1 = $_POST["number1"];
$number2 = $_POST["number2"];
$action = $_POST["action"];
if ($_POST["submit"]) {
    try {
        $result = calculate($number1, $number2, $action);
        echo '<div class="alert alert-info" role="alert">' . $number1 . ' ' . $action . ' ' . $number2 . ' = ' . $result . ' </div>';
    } catch (Exception $e) {
        echo '<div class="alert alert-danger" role="alert">' . $e->getMessage() . '</div>';
    }
}
function calculate($number1, $number2, $action)
{
    if ($number1 && $number2 && $action) {
        if (is_numeric($number1) && is_numeric($number2)) {
            switch ($action) {
                case '+':
                    return $number1 + $number2;
                    break;
                case '-':
                    return $number1 - $number2;
开发者ID:tehdns,项目名称:Calculator,代码行数:31,代码来源:cUzdevums+3.php

示例13: calculate4

    $total = 0;
    for ($i = 0; $i < 5; $i++) {
        $make = 0.75 * 1.32 * 10 - 10;
        $total += $make;
    }
    return $total;
}
function calculate4()
{
    $total = 0;
    for ($i = 0; $i < 5; $i++) {
        $make = 0.9 * 1.1 * 10 - 10;
        $total += $make;
    }
    return $total;
}
function calculate5()
{
    $total = 0;
    for ($i = 0; $i < 5; $i++) {
        $make = 0.95 * 1.0421 * 10 - 10;
        $total += $make;
    }
    return $total;
}
echo "For 0.25% chance, you made " . calculate() . " doge. </br>";
echo "For 0.25% chance, you made " . calculate1() . " doge.</br>";
echo "For 0.25% chance, you made " . calculate2() . " doge.</br>";
echo "For 0.25% chance, you made " . calculate3() . " doge.</br>";
echo "For 0.25% chance, you made " . calculate4() . " doge.</br>";
echo "For 0.25% chance, you made " . calculate5() . " doge.</br>";
开发者ID:SnowySailor,项目名称:CodeStuff,代码行数:31,代码来源:calculate.php

示例14: printChapter

function printChapter($chapter_title, $page_number)
{
    $dots = str_repeat(".", calculate($chapter_title, $page_number));
    print $chapter_title . $dots . $page_number . "<br>";
}
开发者ID:jjkramok,项目名称:webprogramming,代码行数:5,代码来源:TableOfContents.php

示例15: closingBalance

 /**
  * Calculate closing balance of specified ledger account for the given
  * date range
  *
  * @param1 int ledger id
  * @param2 date start date
  * @param3 date end date
  * @return array D/C, Amount
  */
 function closingBalance($id, $start_date = null, $end_date = null)
 {
     if (empty($id)) {
         throw new InternalErrorException(__d('webzash', 'Ledger not specified. Failed to calculate closing balance.'));
     }
     /* Load models that are needed for calculations */
     $Entry = ClassRegistry::init('Webzash.Entry');
     $Entryitem = ClassRegistry::init('Webzash.Entryitem');
     /* Opening balance */
     $op = $this->find('first', array('conditions' => array('Ledger.id' => $id)));
     if (!$op) {
         throw new InternalErrorException(__d('webzash', 'Ledger not found. Failed to calculate closing balance.'));
     }
     $op_total = 0;
     $op_total_dc = $op['Ledger']['op_balance_dc'];
     if (is_null($start_date)) {
         if (empty($op['Ledger']['op_balance'])) {
             $op_total = 0;
         } else {
             $op_total = $op['Ledger']['op_balance'];
         }
     }
     $dr_total = 0;
     $cr_total = 0;
     $dr_total_dc = 0;
     $cr_total_dc = 0;
     /* Debit total */
     $dr_conditions = array('Entryitem.ledger_id' => $id, 'Entryitem.dc' => 'D');
     if (!is_null($start_date)) {
         $dr_conditions['Entry.date >='] = $start_date;
     }
     if (!is_null($end_date)) {
         $dr_conditions['Entry.date <='] = $end_date;
     }
     $total = $Entryitem->find('first', array('fields' => array('SUM(Entryitem.amount) as total'), 'conditions' => $dr_conditions, 'joins' => array(array('table' => 'entries', 'alias' => 'Entry', 'type' => 'LEFT', 'conditions' => array('Entry.id = Entryitem.entry_id')))));
     if (empty($total[0]['total'])) {
         $dr_total = 0;
     } else {
         $dr_total = $total[0]['total'];
     }
     /* Credit total */
     $cr_conditions = array('Entryitem.ledger_id' => $id, 'Entryitem.dc' => 'C');
     if (!is_null($start_date)) {
         $cr_conditions['Entry.date >='] = $start_date;
     }
     if (!is_null($end_date)) {
         $cr_conditions['Entry.date <='] = $end_date;
     }
     $total = $Entryitem->find('first', array('fields' => array('SUM(Entryitem.amount) as total'), 'conditions' => $cr_conditions, 'joins' => array(array('table' => 'entries', 'alias' => 'Entry', 'type' => 'LEFT', 'conditions' => array('Entry.id = Entryitem.entry_id')))));
     if (empty($total[0]['total'])) {
         $cr_total = 0;
     } else {
         $cr_total = $total[0]['total'];
     }
     /* Add opening balance */
     if ($op_total_dc == 'D') {
         $dr_total_dc = calculate($op_total, $dr_total, '+');
         $cr_total_dc = $cr_total;
     } else {
         $dr_total_dc = $dr_total;
         $cr_total_dc = calculate($op_total, $cr_total, '+');
     }
     /* Calculate and update closing balance */
     $cl = 0;
     $cl_dc = '';
     if (calculate($dr_total_dc, $cr_total_dc, '>')) {
         $cl = calculate($dr_total_dc, $cr_total_dc, '-');
         $cl_dc = 'D';
     } else {
         if (calculate($cr_total_dc, $dr_total_dc, '==')) {
             $cl = 0;
             $cl_dc = $op_total_dc;
         } else {
             $cl = calculate($cr_total_dc, $dr_total_dc, '-');
             $cl_dc = 'C';
         }
     }
     return array('dc' => $cl_dc, 'amount' => $cl, 'dr_total' => $dr_total, 'cr_total' => $cr_total);
 }
开发者ID:richardkeep,项目名称:webzash,代码行数:88,代码来源:Ledger.php


注:本文中的calculate函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。