Beispiel #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;
 }
Beispiel #2
0
 public function Execute()
 {
     $acc702 = Account::load("702");
     $s702 = $acc702->getSaldo($this->document_date);
     Entry::AddEntry(702, 79, abs($s702), $this->document_id, $this->document_date);
     $acc902 = Account::load("902");
     $s902 = $acc902->getSaldo($this->document_date);
     Entry::AddEntry(79, 902, abs($s902), $this->document_id, $this->document_date);
     return true;
 }
Beispiel #3
0
 private function generateReport()
 {
     $acc = Account::load($this->filter->acc->getValue());
     $from = $this->filter->from->getDate();
     $to = $this->filter->to->getDate();
     $header = array('from' => date('d.m.Y', $from), 'to' => date('d.m.Y', $to), 'acc' => $acc->acc_name);
     $detail = array();
     $conn = \ZCL\DB\DB::getConnect();
     $data = $acc->getSaldoAndOb($from, $to);
     //получаем остатки  и  обороты  на  период
     $sql = "select sum(case when acc_d = {$acc->acc_code} then amount else 0 end )  as ad,\n            sum(case when acc_c = {$acc->acc_code} then amount else 0 end )  as ac ,document_number,document_date\n            from erp_account_entry_view  where ( acc_d ={$acc->acc_code} or acc_c ={$acc->acc_code} ) and document_date >= " . $conn->DBDate($from) . " and document_date <= " . $conn->DBDate($to) . "  group by  document_number,document_date  order  by  document_date            ";
     $rs = $conn->Execute($sql);
     $startdt = $data['startdt'];
     $startct = $data['startct'];
     foreach ($rs as $row) {
         $amount = 0;
         $enddt = 0;
         $endct = 0;
         if ($row['ad'] > 0) {
             $amount = $row['ad'];
             $enddt = $startdt + $row['ad'];
             $endct = $startct;
         }
         if ($row['ac'] > 0) {
             $amount = 0 - $row['ac'];
             $endct = $startct + $row['ac'];
             $enddt = $startdt;
         }
         if ($enddt - $endct > 0) {
             $enddt = $enddt - $endct;
             $endct = 0;
         } else {
             $endct = $endct - $enddt;
             $enddt = 0;
         }
         $detail[] = array("date" => date("d.m.Y", strtotime($row['document_date'])), "doc" => $row['document_number'], "amount" => H::fm($amount), "startdt" => H::fm($startdt), "startct" => H::fm($startct), "enddt" => H::fm($enddt), "endct" => H::fm($endct));
         $startdt = $enddt;
         $startct = $endct;
     }
     $report = new \ZippyERP\ERP\Report('accountactivity.tpl');
     $html = $report->generate($header, $detail);
     return $html;
 }
Beispiel #4
0
 public function __construct()
 {
     parent::__construct();
     $filter = Filter::getFilter("entrylist");
     $this->add(new Form('filter'))->setSubmitHandler($this, 'filterOnSubmit');
     $this->filter->add(new Date('from', strlen($filter->from) > 0 ? $filter->from : time() - 7 * 24 * 3600));
     $this->filter->add(new Date('to', strlen($filter->to) > 0 ? $filter->to : time()));
     $this->filter->add(new DropDownChoice('dt', \ZippyERP\ERP\Entity\Account::findArrayEx("acc_code not in (select acc_pid  from erp_account_plan)")));
     $this->filter->add(new DropDownChoice('ct', \ZippyERP\ERP\Entity\Account::findArrayEx("acc_code not in (select acc_pid  from erp_account_plan)")));
     if (strlen($filter->dt) > 0) {
         $this->filter->dt->setValue($filter->dt);
     }
     if (strlen($filter->ct) > 0) {
         $this->filter->ct->setValue($filter->ct);
     }
     $this->add(new DataView('entrylist', new EntryDataSource(), $this, 'entrylistOnRow'));
     $this->add(new \ZippyERP\ERP\Blocks\DocView('docview'))->setVisible(false);
     $this->add(new \Zippy\Html\DataList\Paginator("paginator", $this->entrylist));
     $this->entrylist->setPageSize(10);
     $this->entrylist->setSelectedClass('success');
     $this->entrylist->Reload();
 }
Beispiel #5
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;
 }
Beispiel #6
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;
 }
Beispiel #7
0
 public function __construct()
 {
     parent::__construct();
     $this->add(new DataView('list', new ArrayDataSource(Account::find("", "cast(acc_code as char)")), $this, 'listOnRow'))->Reload();
 }
Beispiel #8
0
 public function __construct($docid = 0)
 {
     parent::__construct();
     $this->add(new Form('docform'));
     $this->docform->add(new TextInput('document_number'));
     $this->docform->add(new TextArea('description'));
     $this->docform->add(new Date('document_date'));
     //проводки
     $this->docform->add(new DataView('acctable', new ArrayDataSource($this, '_entryarr'), $this, 'acctableOnRow'));
     $this->docform->add(new DropDownChoice('e_acclistd', Account::findArrayEx('acc_code not in(select acc_pid from erp_account_plan)', 'cast(acc_code as char)')));
     $this->docform->add(new DropDownChoice('e_acclistc', Account::findArrayEx('acc_code not in(select acc_pid from erp_account_plan)', 'cast(acc_code as char)')));
     $this->docform->add(new TextInput('e_accsumma'));
     $this->docform->add(new SubmitButton('addaccbtn'))->setClickHandler($this, 'addaccbtnOnClick');
     //ТМЦ
     $this->docform->add(new DataView('itemtable', new ArrayDataSource($this, '_itemarr'), $this, 'itemtableOnRow'));
     $this->docform->add(new DropDownChoice('e_storelist', Store::findArray('storename', 'store_type=' . Store::STORE_TYPE_OPT, 'storename')));
     $this->docform->add(new AutocompleteTextInput('e_itemlist'))->setAutocompleteHandler($this, "OnAutoItem");
     $this->docform->add(new TextInput('e_quantity'));
     $this->docform->add(new TextInput('e_price'));
     $this->docform->add(new DropDownChoice('e_itemop', new Bind($this, '_acclist')));
     $this->docform->add(new SubmitButton('additembtn'))->setClickHandler($this, 'additembtnOnClick');
     //Сотрудники
     $this->docform->add(new DataView('emptable', new ArrayDataSource($this, '_emparr'), $this, 'emptableOnRow'));
     $this->docform->add(new DropDownChoice('e_empop', new Bind($this, '_acclist')));
     $this->docform->add(new AutocompleteTextInput('e_emplist'))->setAutocompleteHandler($this, "OnAutoEmp");
     $this->docform->add(new TextInput('e_empamount'));
     $this->docform->add(new SubmitButton('addempbtn'))->setClickHandler($this, 'addempbtnOnClick');
     //контрагенты
     $this->docform->add(new DataView('ctable', new ArrayDataSource($this, '_carr'), $this, 'ctableOnRow'));
     $this->docform->add(new AutocompleteTextInput('e_сlist'))->setAutocompleteHandler($this, "OnAutoCont");
     $this->docform->add(new TextInput('e_сamount'));
     $this->docform->add(new SubmitButton('addсbtn'))->setClickHandler($this, 'addсbtnOnClick');
     $this->docform->add(new DropDownChoice('e_cop', new Bind($this, '_acclist')));
     //Денежные счета
     $this->docform->add(new DataView('ftable', new ArrayDataSource($this, '_farr'), $this, 'ftableOnRow'))->Reload();
     $this->docform->add(new DropDownChoice('e_flist', MoneyFund::findArray('title', '', 'title')));
     $this->docform->add(new TextInput('e_famount'));
     $this->docform->add(new SubmitButton('addfbtn'))->setClickHandler($this, 'addfbtnOnClick');
     $this->docform->add(new DropDownChoice('e_foper', new Bind($this, '_acclist')));
     $this->docform->add(new Button('backtolist'))->setClickHandler($this, 'backtolistOnClick');
     $this->docform->add(new SubmitButton('savedoc'))->setClickHandler($this, 'savedocOnClick');
     $this->docform->add(new SubmitButton('execdoc'))->setClickHandler($this, 'savedocOnClick');
     if ($docid > 0) {
         //загружаем   содержимок  документа на страницу
         $this->_edited = true;
         $this->_doc = Document::load($docid);
         $this->docform->document_number->setText($this->_doc->document_number);
         $this->docform->description->setText($this->_doc->headerdata['description']);
         $this->docform->document_date->setText(date('Y-m-d', $this->_doc->document_date));
         $this->_entryarr = unserialize(base64_decode($this->_doc->headerdata['entry']));
         $this->_itemarr = unserialize(base64_decode($this->_doc->headerdata['item']));
         $this->_emparr = unserialize(base64_decode($this->_doc->headerdata['emp']));
         $this->_carr = unserialize(base64_decode($this->_doc->headerdata['c']));
         $this->_farr = unserialize(base64_decode($this->_doc->headerdata['f']));
         $this->docform->acctable->Reload();
         $this->updateAccList();
         $this->docform->itemtable->Reload();
         $this->docform->emptable->Reload();
         $this->docform->ftable->Reload();
         $this->docform->ctable->Reload();
     } else {
         $this->_doc = Document::create('ManualEntry');
         $this->docform->document_date->setDate(time());
     }
 }