PHP code example of d3yii2 / yii2-d3acc

1. Go to this page and download the library: Download d3yii2/yii2-d3acc library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

d3yii2 / yii2-d3acc example snippets


use \d3acc\models\AcRecAcc;
use Yii;
/**
 * Description of acc
 *
 * @author Dealer
 */
 class acc
{
    const MONTH_PERIOD = 1;

    const PLAYER_ACC        = 4;
    const EXPENSES          = 10;
    const FOND_PLAYGROUND   = 7;
    
    acc::CODE_CRD_PLAYGROUND = 'CreditPlaygound';

    /**
     * get player  account
     * @param int $personId
     * @return AcRecAcc
     */
    public static function player($personId)
    {
        return AcRecAcc::getAcc(self::PLAYER_ACC, ['person' => $personId]);
    }

    /**
     * get expenses  account
     * @return AcRecAcc
     */
    public static function expenses()
    {
        return AcRecAcc::getAcc(self::EXPENSES);
    }
    
    /**
     * get for player playground account
     * @param int $personId
     * @param int $playgroundId
     * @return AcRecAcc
     */
    public static function fondPlayground($personId, $playgroundId)
    {
        return AcRecAcc::getAcc(self::FOND_PLAYGROUND,
                ['person' => $personId, 'playground' => $playgroundId]);
    }    
}
 


       /**
        * player accounts
        */
       $recAccPPG    = acc::playerPlayground($person_id, $playground_id);
       $recAccPlayer = acc::player($person_id);
       $day = date('Y-m-d');
       $tran = AcTran::registre($recAccPlayer, $recAccPPG, $personAmt,
               $day, acc::MONTH_PERIOD, acc::CODE_CRD_PLAYGROUND);



use d3acc\models\AcPeriod;
$acPeriod = AcPeriod::getActivePeriod(acc::MONTH_PERIOD))

//close period
\d3acc\components\PeriodMonth::close(acc::MONTH_PERIOD);



 $recAccPlayer = acc::player($person_id);
 $data = AcTran::accPeriodTran($recAccPlayer, $acPeriod);


 $filter  = ['playground' => $playgroundId]
 $playgroundAllPersonBalance = AcTran::accBalanceFilter(acc::FOND_PLAYGROUND, $acPeriod,$filter);
 
 $filter  = ['person' => $personId]
 $personAllPlaygroundsBalance = AcTran::accBalanceFilter(acc::FOND_PLAYGROUND, $acPeriod,$filter);
 
 $allPlaygroundsAllPersonBalance = AcTran::accBalanceFilter(acc::FOND_PLAYGROUND, $acPeriod,[]);



$constructor = new AccConstructor();

$constructor->load($accId);
$constructor->create($code, $name);

$definition = $constructor->addDimension($table, $pkField);

$extAccount = $constructor->addExtendedAccount();

$constructor->addDimensionRecAcc($extAccount->id, $definition->id, $pk_value);

php composer.phar