<?php

namespace App\System\Task;

use App\System\Model\AccountingModel;
use App\System\Model\AccountingPeriodModel;
use \Exception;

class AccountingPeriodTask {
    public function run_task($task){
        $day = date("d");
        $accountingperiods = AccountingPeriodModel::beSelect("apid,cid,apname,aptype,aptotal")->beWhere("apdate",$day)->beGetAll();
        foreach($accountingperiods as $accountingperiod){
            AccountingModel::beInsert([
                "cid" => $accountingperiod["cid"],
                "aname" => $accountingperiod["apname"],
                "atype" => $accountingperiod["aptype"],
                "atotal" => $accountingperiod["aptotal"],
                "adateline" => BE_TIME
            ]);
        }
    }
}

?>