Exemple #1
0
 private function generateReport()
 {
     $acclist = Account::find("", "cast(acc_code as char)");
     $detail = array();
     $totstartdt = 0;
     $totstartct = 0;
     $totobdt = 0;
     $totobct = 0;
     $totenddt = 0;
     $totendct = 0;
     $from = $this->filter->from->getDate();
     $to = $this->filter->to->getDate();
     foreach ($acclist as $acc) {
         $data = $acc->getSaldoAndOb($from, $to);
         //получаем остатки  и  обороты  на  период
         $detail[] = array("acc_code" => $acc->acc_code, 'startdt' => H::fm($data['startdt']), 'startct' => H::fm($data['startct']), 'obdt' => H::fm($data['obdt']), 'obct' => H::fm($data['obct']), 'enddt' => H::fm($data['enddt']), 'endct' => H::fm($data['endct']));
         if ($acc->acc_pid == 0) {
             $totstartdt += $data['startdt'];
             $totstartct += $data['startct'];
             $totobdt += $data['obdt'];
             $totobct += $data['obct'];
             $totenddt += $data['enddt'];
             $totendct += $data['endct'];
         }
     }
     $header = array('from' => date('d.m.Y', $from), 'to' => date('d.m.Y', $to), 'totstartdt' => H::fm($totstartdt), 'totstartct' => H::fm($totstartct), 'totobdt' => H::fm($totobdt), 'totobct' => H::fm($totobct), 'totenddt' => H::fm($totenddt), 'totendct' => H::fm($totendct));
     $report = new \ZippyERP\ERP\Report('obsaldo.tpl');
     $html = $report->generate($header, $detail);
     return $html;
 }
Exemple #2
0
 private function generateReport()
 {
     $acclist = Account::find("", "cast(acc_code as char)");
     $detail = array();
     $left = array();
     $top = array('');
     $right = array();
     $bottom = array('Кредит');
     $from = strtotime($this->filter->from->getValue());
     $to = strtotime($this->filter->to->getValue());
     foreach ($acclist as $acc) {
         $data = $acc->getSaldoAndOb($from, $to);
         //получаем остатки  и  обороты  на  период
         $left[] = $acc->acc_code;
         $top[] = $acc->acc_code;
         $right[] = H::fm($data['obdt']);
         $bottom[] = H::fm($data['obct']);
     }
     $top[] = 'Дебет';
     $bottom[] = '';
     $detail[] = $top;
     foreach ($acclist as $acc) {
         $arr = array();
         $data = $acc->getSaldoAndOb($from, $to);
         //получаем остатки  и  обороты  на  период
         $arr[] = $acc->acc_code;
         foreach ($acclist as $acc2) {
             $arr[] = H::fm(Account::getObBetweenAccount($acc->acc_code, $acc2->acc_code, $from, $to));
         }
         $arr[] = H::fm($data['obdt']);
         $detail[] = $arr;
     }
     $detail[] = $bottom;
     $header = array('from' => date('d.m.Y', $from), 'to' => date('d.m.Y', $to), 'size' => count($top) - 1);
     $report = new \ZippyERP\ERP\Report('shahmatka.tpl');
     $html = $report->generate($header, $detail);
     return $html;
 }
Exemple #3
0
 /**
  * Возвращает сальдо  с   учетом субсчетов
  * Положительное  значение  сальдо  по  дебету,  отрицательное - по  кредиту.
  *
  */
 public function getSaldo($date = null)
 {
     $saldo = 0;
     $children = Account::find("acc_pid=" . $this->acc_code);
     if (count($children) > 0) {
         // если   есть  субсчета
         foreach ($children as $child) {
             $saldo += $child->getSaldo($date);
         }
         return $saldo;
     }
     $conn = DB::getConnect();
     $sql = "select coalesce(sum(amount),0) from  erp_account_entry where  acc_d=" . $this->acc_code . $sqltag;
     if ($date > 0) {
         $sql = "select coalesce(sum(amount),0) from  erp_account_entry where  acc_d=" . $this->acc_code . "  and date(document_date) <= " . $conn->DBDate($date);
     }
     $deb = $conn->GetOne($sql);
     $sql = "select coalesce(sum(amount),0) from  erp_account_entry where  acc_c =" . $this->acc_code . $sqltag;
     if ($date > 0) {
         $sql = "select coalesce(sum(amount),0) from  erp_account_entry where  acc_c =" . $this->acc_code . "  and date(document_date) <= " . $conn->DBDate($date);
     }
     $cr = $conn->GetOne($sql);
     return $deb - $cr;
 }
Exemple #4
0
 public function __construct()
 {
     parent::__construct();
     $this->add(new DataView('list', new ArrayDataSource(Account::find("", "cast(acc_code as char)")), $this, 'listOnRow'))->Reload();
 }