Пример #1
1
 public function Execute()
 {
     $conn = \ZCL\DB\DB::getConnect();
     $store_id = $this->headerdata['store_id'];
     $item = \ZippyERP\ERP\Entity\Item::getSumItem();
     $stock = \ZippyERP\ERP\Entity\Stock::getStock($store_id, $item->item_id, 1, true);
     $discont = 0;
     //скидки  704  счет
     $date = new Carbon();
     $date->setTimestamp($this->document_date);
     $end = $date->endOfMonth()->getTimestamp();
     $begin = $date->startOfMonth()->getTimestamp();
     $sql = " select coalesce(abs(sum(amount)),0) from erp_account_subconto where amount < 0  and account_id=285 and  extcode  = {$store_id} and  document_date  <= " . $conn->DBDate($end);
     $tm = $conn->GetOne($sql);
     //торговая  наценка на  конец периода
     //остатки на  конец периода
     $sql = " select coalesce(sum(quantity),0) AS quantity,coalesce(price,0) as price  from erp_account_subconto sc join erp_store_stock  st on sc.stock_id = st.stock_id where    store_id = {$store_id} and date(document_date) <= " . $conn->DBDate($end);
     $row = $conn->GetRow($sql);
     $ost = $row['quantity'] / 1000;
     $ost = $ost * $row['price'];
     if ($ost == 0) {
         return;
     }
     //выручка
     $sql = " select coalesce(abs(sum(amount)),0) from erp_account_subconto where amount < 0  and account_id=702 and  extcode  = {$store_id} and date(document_date) <= " . $conn->DBDate($end) . " and date(document_date) >= " . $conn->DBDate($begin);
     $saled = $conn->GetOne($sql);
     //выручка сданная в кассу
     $k = ($tm - $discont) / ($ost - $discont);
     $sb = (1 - $k) * $saled;
     //себестоимость
     // списываем  наценку
     Entry::AddEntry("285", "282", $saled - $sb, $this->document_id, $this->document_date);
     // себестоимость реализации
     Entry::AddEntry("902", "282", $sb, $this->document_id, $this->document_date);
     $item = \ZippyERP\ERP\Entity\Item::getSumItem();
     $stockto = \ZippyERP\ERP\Entity\Stock::getStock($store_id, $item->item_id, 1, true);
     $sc = new SubConto($this, 282, 0 - $saled);
     $sc->setStock($stockto->stock_id);
     $sc->setQuantity(0 - $saled * 1000);
     //цена  единицы  товара - 1 копейка.
     $sc->save();
     // НДС
     $nds = H::nds(true);
     Entry::AddEntry("702", "641", $saled * $nds, $this->document_id, $this->document_date);
     return true;
 }
Пример #2
0
 public function __construct($file_id)
 {
     if (!is_numeric($file_id)) {
         die;
     }
     $user = \ZippyERP\System\System::getUser();
     if ($user->user_id == 0) {
         die;
     }
     $file = \ZippyERP\ERP\Helper::loadFile($file_id);
     if ($file == null) {
         die;
     }
     $type = "";
     $pos = strrpos($file['filename'], '.');
     if ($pos !== false) {
         $type = substr($file['filename'], $pos + 1);
     }
     $size = strlen($file['filedata']);
     if ($size > 0) {
         header('Content-Description: File Transfer');
         header('Content-Type: application/octet-stream');
         header('Content-Disposition: attachment; filename=' . $file['filename']);
         header('Content-Transfer-Encoding: binary');
         header('Expires: 0');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header('Pragma: public');
         header('Content-Length: ' . $size);
         flush();
         echo $file['filedata'];
     }
     die;
 }
Пример #3
0
 public function __construct($docid = 0)
 {
     parent::__construct();
     $this->add(new Form('docform'));
     $this->docform->add(new TextInput('document_number'));
     $this->docform->add(new TextInput('amount'));
     $this->docform->add(new Date('created', time()));
     $this->docform->add(new DropDownChoice('customer', Customer::findArray("customer_name", "")));
     $this->docform->add(new Date('startdate', time()));
     $this->docform->add(new Date('enddate', time()));
     $this->docform->add(new TextArea('description'));
     $this->docform->add(new SubmitButton('submit'))->setClickHandler($this, 'submitOnClick');
     $this->docform->add(new Button('cancel'))->setClickHandler($this, 'cancelOnClick');
     if ($docid > 0) {
         //загружаем   содержимок  документа настраницу
         $this->_doc = Document::load($docid);
         $this->docform->document_number->setText($this->_doc->document_number);
         $this->docform->created->setDate($this->_doc->document_date);
         $this->docform->startdate->setDate($this->_doc->headerdata['startdate']);
         $this->docform->enddate->setDate($this->_doc->headerdata['enddate']);
         $this->docform->description->setText($this->_doc->headerdata['description']);
         $this->docform->amount->setText(H::fm($this->_doc->headerdata['amount']));
         $this->docform->customer->setValue($this->_doc->headerdata['customer']);
     } else {
         $this->_doc = Document::create('Contract');
         $this->docform->document_number->setText($this->_doc->nextNumber());
     }
 }
Пример #4
0
 public function dlistOnRow($row)
 {
     $item = $row->getDataItem();
     $row->add(new Label('amount', H::fm($item->amount)));
     $row->add(new Label('ddate', date('Y-m-d', $item->document_date)));
     $row->add(new ClickLink('ddoc', $this, 'ddocOnClick'))->setValue($item->description . ' ' . $item->document_number);
 }
Пример #5
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;
 }
Пример #6
0
 public function generateReport()
 {
     $customer = \ZippyERP\ERP\Entity\Customer::load($this->headerdata["customer"]);
     $header = array('date' => date('d.m.Y', $this->document_date), "document_number" => $this->document_number, "customer" => $customer->customer_name, "description" => $this->headerdata["description"], 'startdate' => date('d.m.Y', $this->headerdata["startdate"]), 'enddate' => date('d.m.Y', $this->headerdata["enddate"]), "amount" => H::fm($this->headerdata["amount"]));
     $report = new \ZippyERP\ERP\Report('contract.tpl');
     $html = $report->generate($header);
     return $html;
 }
Пример #7
0
 public function entrylistOnRow($row)
 {
     $item = $row->getDataItem();
     $row->add(new Label('acc_d', $item->acc_d));
     $row->add(new Label('acc_c', $item->acc_c));
     $row->add(new Label('amount', $item->amount > 0 ? H::fm($item->amount) : ""));
     $row->add(new Label('created', date('d-m-Y', $item->document_date)));
     $row->add(new ClickLink('show', $this, 'showOnClick'))->setValue($item->meta_desc . ' ' . $item->document_number);
 }
Пример #8
0
 public function listOnRow($row)
 {
     $item = $row->getDataItem();
     $row->add(new Label('code', $item->acc_code));
     $row->add(new Label('name', $item->acc_name));
     $saldo = $item->getSaldo();
     $row->add(new Label('dt', $saldo > 0 ? H::fm($saldo) : ""));
     $row->add(new Label('ct', $saldo < 0 ? H::fm(0 - $saldo) : ""));
 }
Пример #9
0
 /**
  * Метод  для   получения  имени  ТМЦ  с  ценой
  *
  * @param mixed $criteria
  * @return []
  * @static
  */
 public static function findArrayEx($criteria = "", $orderbyfield = null, $orderbydir = null, $count = -1, $offset = -1)
 {
     $entitylist = self::find($criteria, $orderbyfield, $orderbydir, $count, $offset);
     $list = array();
     foreach ($entitylist as $key => $value) {
         $list[$key] = $value->itemname . ', ' . \ZippyERP\ERP\Helper::fm($value->price);
     }
     return $list;
 }
Пример #10
0
 public function detailOnRow($row)
 {
     $item = $row->getDataItem();
     $row->add(new Label('item', $item->itemname));
     $row->add(new Label('measure', $item->measure_name));
     $row->add(new Label('quantity', $item->quantity / 1000));
     $row->add(new Label('price', H::fm($item->price)));
     $row->add(new ClickLink('edit'))->setClickHandler($this, 'editOnClick');
     $row->add(new ClickLink('delete'))->setClickHandler($this, 'deleteOnClick');
 }
Пример #11
0
 /**
  * Функция  возвращающая  описание страницы.
  * Может  перегружатся  дочерними  страницами.
  * Как  правило  выводится  описание с  обьекта  метадагнных
  * @return mixed
  */
 public function getPageInfo()
 {
     $class = explode("\\", get_class($this));
     $classname = $class[count($class) - 1];
     $info = \ZippyERP\ERP\Helper::getMetaNotes($classname);
     if (strlen($info) == 0) {
         return "Об этой  странице нет информации";
     } else {
         return $info;
     }
 }
Пример #12
0
 public function generateReport()
 {
     $myfirm = \ZippyERP\System\System::getOptions("firmdetail");
     $myaccount = \ZippyERP\ERP\Entity\MoneyFund::load($this->headerdata['bankaccount']);
     $mybank = \ZippyERP\ERP\Entity\Bank::load($myaccount->bank);
     $customer = \ZippyERP\ERP\Entity\Customer::load($this->headerdata['customer']);
     $cbank = \ZippyERP\ERP\Entity\Bank::load($customer->bank);
     $header = array('date' => date('d.m.Y', $this->document_date), 'myname' => $myfirm['name'], 'mycode' => $myfirm['code'], 'mybankaccount' => $myaccount->bankaccount, 'mybank' => $mybank->bank_name, 'mybankcode' => $mybank->mfo, 'cname' => $customer->customer_name, 'ccode' => $customer->code, 'cbankaccount' => $customer->bankaccount, 'cbank' => $cbank->bank_name, 'cbankcode' => $cbank->mfo, "document_number" => $this->document_number, "document_date" => date('Y.m.d', $this->document_date), "notes" => $this->headerdata['notes'], "amount" => H::fm($this->amount), "amountstr" => \ZippyERP\ERP\Util::ucfirst(\ZippyERP\ERP\Util::money2str($this->amount / 100)));
     $report = new \ZippyERP\ERP\Report('transferorder.tpl');
     $html = $report->generate($header, array());
     return $html;
 }
Пример #13
0
 public function generateReport()
 {
     $header = array('date' => date('d.m.Y', $this->document_date), "document_number" => $this->document_number, "summa" => H::fm($this->headerdata['summa']), "store" => $this->headerdata['storename']);
     $i = 1;
     $detail = array();
     foreach ($this->detaildata as $value) {
         $detail[] = array("no" => $i++, "item_name" => $value['itemname'], "measure" => $value['measure_name'], "price" => H::fm($value['price']), "newprice" => H::fm($value['newprice']));
     }
     $report = new \ZippyERP\ERP\Report('revaluationret.tpl');
     $html = $report->generate($header, $detail);
     return $html;
 }
Пример #14
0
 public function generateReport()
 {
     // $customer = \ZippyERP\ERP\Entity\Customer::load($this->headerdata["customer"]);
     $i = 1;
     $detail = array();
     foreach ($this->detaildata as $value) {
         $detail[] = array("no" => $i++, "itemname" => $value['itemname'], "measure" => $value['measure_name'], "quantity" => $value['quantity'] / 1000, "price" => H::fm($value['price']), "pricends" => H::fm($value['pricends']), "totalnds" => H::fm($this->headerdata["totalnds"]), "amount" => H::fm($value['amount']));
     }
     $header = array('date' => date('d.m.Y', $this->document_date), "customer" => $this->headerdata["customername"], "document_number" => $this->document_number, "totalnds" => H::fm($this->headerdata["totalnds"]), "total" => H::fm($this->headerdata["total"]));
     $report = new \ZippyERP\ERP\Report('goodsreceipt.tpl');
     $html = $report->generate($header, $detail);
     return $html;
 }
Пример #15
0
 public function generateReport()
 {
     $i = 1;
     $detail = array();
     foreach ($this->detaildata as $value) {
         $detail[] = array("no" => $i++, "tovar_name" => $value['itemname'], "measure" => $value['measure_name'], "quantity" => $value['quantity'] / 1000, "price" => H::fm($value['price']), "amount" => H::fm($value['quantity'] / 1000 * $value['price']));
     }
     $firm = \ZippyERP\System\System::getOptions("firmdetail");
     $header = array('date' => date('d.m.Y', $this->document_date), "firmname" => $firm['name'], "firmcode" => $firm['code'], "kassa" => $this->headerdata["kassa"], "return" => $this->headerdata["return"], "document_number" => $this->document_number, "total" => H::fm($this->headerdata["total"]), "totalnds" => H::fm($this->headerdata["totalnds"]));
     $report = new \ZippyERP\ERP\Report('registerreceipt.tpl');
     $html = $report->generate($header, $detail);
     return $html;
 }
Пример #16
0
 public function generateReport()
 {
     $header = array('date' => date('d.m.Y', $this->document_date), "from" => Store::load($this->headerdata["storefrom"])->storename, "to" => Store::load($this->headerdata["storeto"])->storename, "document_number" => $this->document_number);
     $reportgen = new \ZCL\RepGen\RepGen(_ROOT . 'templates/erp/printforms/moveitem.html', $header);
     $i = 1;
     $detail = array();
     foreach ($this->detaildata as $value) {
         $detail[] = array("no" => $i++, "item_name" => $value['itemname'], "measure" => $value['measure_name'], "price" => H::fm($value['price']), "quantity" => $value['quantity'] / 1000);
     }
     $report = new \ZippyERP\ERP\Report('movebackitem.tpl');
     $html = $report->generate($header, $detail);
     return $html;
 }
Пример #17
0
 public function generateReport()
 {
     $i = 1;
     $detail = array();
     $total = 0;
     foreach ($this->detaildata as $value) {
         $detail[] = array("no" => $i++, "tovar_name" => $value['itemname'], "measure" => $value['measure_name'], "quantity" => $value['quantity'] / 1000, "price" => H::fm($value['price']), "amount" => H::fm($value['quantity'] / 1000 * $value['price']));
         $total += $value['quantity'] / 1000 * $value['price'];
     }
     $header = array('date' => date('d.m.Y', $this->document_date), "customername" => $this->suppliername, "document_number" => $this->document_number, "timeline" => date('d.m.Y', $this->headerdata['timeline']), "total" => H::fm($total));
     $report = new \ZippyERP\ERP\Report('supplierorder.tpl');
     $html = $report->generate($header, $detail);
     return $html;
 }
Пример #18
0
 public function generateReport()
 {
     $i = 1;
     $detail = array();
     foreach ($this->detaildata as $value) {
         $detail[] = array("no" => $i++, "tovar_name" => $value['itemname'], "measure" => $value['measure_name'], "quantity" => $value['quantity'] / 1000, "price" => H::fm($value['price']), "amount" => H::fm($value['quantity'] / 1000 * $value['price']));
     }
     $firm = \ZippyERP\System\System::getOptions("firmdetail");
     // $customer = \ZippyERP\ERP\Entity\Customer::load($this->headerdata["customer"]);
     $header = array('date' => date('d.m.Y', $this->document_date), "firmname" => $firm['name'], "firmcode" => $firm['code'], "customername" => $this->headerdata["customername"], "document_number" => $this->document_number, "total" => H::fm($this->headerdata["total"]), "totalnds" => H::fm($this->headerdata["totalnds"]), "summa" => Util::ucfirst(Util::money2str($total + $this->headerdata["nds"] / 100, '.', '')));
     $report = new \ZippyERP\ERP\Report('retailissue.tpl');
     $html = $report->generate($header, $detail);
     return $html;
 }
Пример #19
0
 public function generateReport()
 {
     $types = $this->getTypes();
     $i = 1;
     $detail = array();
     $total = 0;
     foreach ($this->detaildata as $value) {
         $detail[] = array("type" => $types[$value['optype']], "cust" => $value['customername'], "amount" => H::fm($value['amount']), "comment" => $value['comment']);
     }
     $header = array('date' => date('d.m.Y', $this->document_date), 'bankaccount' => \ZippyERP\ERP\Entity\MoneyFund::load($this->headerdata['bankaccount'])->title, "document_number" => $this->document_number);
     $report = new \ZippyERP\ERP\Report('bankstatement.tpl');
     $html = $report->generate($header, $detail);
     return $html;
 }
Пример #20
0
 public function generateReport()
 {
     $employee = \ZippyERP\ERP\Entity\Employee::load($this->headerdata["employee"]);
     $i = 1;
     $detail = array();
     foreach ($this->detaildata as $value) {
         $detail[] = array("no" => $i++, "itemname" => $value['itemname'], "measure" => $value['measure_name'], "quantity" => $value['quantity'] / 1000, "price" => H::fm($value['price']), "pricends" => H::fm($value['pricends']), "amount" => H::fm($value['amount']));
     }
     $elist = self::expenceList();
     $header = array('date' => date('d.m.Y', $this->document_date), "employee" => $employee->shortname, "expenseamount" => H::fm($this->headerdata["expenseamount"]), "expensetype" => $elist[$this->headerdata["expensetype"]], "employee" => $employee->shortname, "document_number" => $this->document_number, "totalnds" => H::fm($this->headerdata["totalnds"]), "total" => H::fm($this->headerdata["total"]));
     $report = new \ZippyERP\ERP\Report('expensereport.tpl');
     $html = $report->generate($header, $detail);
     return $html;
 }
Пример #21
0
 public function generateReport()
 {
     $i = 1;
     $detail = array();
     foreach ($this->detaildata as $value) {
         $detail[] = array("no" => $i++, "itemname" => $value['itemname'], "measure" => $value['measure_name'], "quantity" => $value['quantity'] / 1000, "price" => H::fm($value['price']), "pricends" => H::fm($value['pricends']), "amount" => H::fm($value['amount']));
     }
     $bank = \ZippyERP\ERP\Entity\Bank::load($f->bank);
     //$customer = \ZippyERP\ERP\Entity\Customer::load($this->headerdata["customer"]);
     $header = array('date' => date('d.m.Y', $this->document_date), "account" => $f->bankaccount, "bank" => $bank->bank_name, "mfo" => $bank->mfo, "address" => $firm['city'] . ', ' . $firm['street'], "customername" => $this->headerdata["customername"], "document_number" => $this->document_number, "base" => $this->base, "paydate" => date('d.m.Y', $this->headerdata["payment_date"]), "totalnds" => H::fm($this->headerdata["totalnds"]), "total" => H::fm($this->headerdata["total"]));
     $report = new \ZippyERP\ERP\Report('purchaseinvoice.tpl');
     $html = $report->generate($header, $detail);
     return $html;
 }
Пример #22
0
 public function generateReport()
 {
     $i = 1;
     $detail = array();
     $total = 0;
     foreach ($this->detaildata as $value) {
         $detail[] = array("no" => $i++, "tovar_name" => $value['itemname'], "quantity" => $value['quantity'] / 1000, "price" => H::fm($value['price']), "amount" => H::fm($value['quantity'] / 1000 * $value['price']), "sn" => $value['sn'], "warranty" => $value['warranty']);
         $total += $value['quantity'] * $value['price'] / 100;
     }
     $firm = \ZippyERP\System\System::getOptions("firmdetail");
     $header = array('date' => date('d.m.Y', $this->document_date), "firmname" => $firm['name'], "customer" => strlen($this->headerdata["customer"]) > 0 ? $this->headerdata["customer"] : '', "document_number" => $this->document_number);
     $report = new \ZippyERP\ERP\Report('warranty.tpl');
     $html = $report->generate($header, $detail);
     return $html;
 }
Пример #23
0
 public function generateReport()
 {
     $i = 1;
     $detail = array();
     foreach ($this->detaildata as $value) {
         if (isset($detail[$value['item_id']])) {
             $detail[$value['item_id']]['quantity'] += $value['quantity'] / 1000;
         } else {
             $detail[$value['item_id']] = array("no" => $i++, "tovar_name" => $value['itemname'], "measure" => $value['measure_name'], "quantity" => $value['quantity'] / 1000, "price" => H::fm($value['price']), "amount" => H::fm($value['quantity'] / 1000 * $value['price']));
         }
     }
     //$customer = \ZippyERP\ERP\Entity\Customer::load($this->headerdata["customer"]);
     $header = array('date' => date('d.m.Y', $this->document_date), "customername" => $this->headerdata["customername"], "document_number" => $this->document_number, "nds" => H::fm($this->headerdata["totalnds"]), "total" => H::fm($this->headerdata["total"]), "summa" => Util::ucfirst(Util::money2str($this->headerdata["total"] / 100, '.', '')));
     $report = new \ZippyERP\ERP\Report('returngoodsissue.tpl');
     $html = $report->generate($header, $detail);
     return $html;
 }
Пример #24
0
 public function Execute()
 {
     $cash = MoneyFund::getCash();
     $ret = "";
     $optype = $this->headerdata['optype'];
     if ($optype == self::TYPEOP_CUSTOMER) {
         $ret = Entry::AddEntry(30, 36, $this->headerdata['amount'], $this->document_id, $this->document_date);
         $sc = new SubConto($this, 36, 0 - $this->headerdata['amount']);
         $sc->setCustomer($this->headerdata['opdetail']);
         $sc->save();
     }
     if ($optype == self::TYPEOP_CASH) {
         $ret = Entry::AddEntry(30, 372, $this->headerdata['amount'], $this->document_id, $this->document_date);
         $sc = new SubConto($this, 372, 0 - $this->headerdata['amount']);
         $sc->setEmployee($this->headerdata['opdetail']);
         $sc->save();
     }
     if ($optype == self::TYPEOP_BANK) {
         $ret = Entry::AddEntry(30, 31, $this->headerdata['amount'], $this->document_id, $this->document_date);
         $sc = new SubConto($this, 31, 0 - $this->headerdata['amount']);
         $sc->setMoneyfund($this->headerdata['opdetail']);
         $sc->save();
     }
     if ($optype == self::TYPEOP_RET) {
         $store_id = $this->headerdata['opdetail'];
         // магазин
         $ret = Entry::AddEntry(30, 702, $this->headerdata['amount'], $this->document_id, $this->document_date);
         $sc = new SubConto($this, 702, 0 - $this->headerdata['amount']);
         $sc->setExtCode($this->headerdata['opdetail']);
         $sc->save();
         $store = \ZippyERP\ERP\Entity\Store::load($store_id);
         if ($store->store_type == \ZippyERP\ERP\Entity\Store::STORE_TYPE_RET_SUM) {
             $nds = \ZippyERP\ERP\Helper::nds(true);
             Entry::AddEntry(702, 643, $nds * $this->headerdata['amount'], $this->document_id, $this->document_date);
         }
     }
     //касса
     $sc = new SubConto($this, 30, $this->headerdata['amount']);
     $sc->setMoneyfund($cash->id);
     $sc->save();
     if (strlen($ret) > 0) {
         throw new \Exception($ret);
     }
     return true;
 }
Пример #25
0
 public function generateReport()
 {
     $i = 1;
     $detail = array();
     $total = 0;
     foreach ($this->detaildata as $value) {
         $detail[] = array("no" => $i++, "tovar_name" => $value['itemname'], "measure" => $value['measure_name'], "quantity" => $value['quantity'] / 1000, "price" => H::fm($value['price']), "amount" => H::fm($value['quantity'] / 1000 * $value['price']));
         $total += $value['quantity'] / 1000 * $value['price'];
     }
     $firm = \ZippyERP\System\System::getOptions("firmdetail");
     $f = \ZippyERP\ERP\Entity\MoneyFund::findOne('ftype = 1');
     $bank = \ZippyERP\ERP\Entity\Bank::load($f->bank);
     //  $customer = \ZippyERP\ERP\Entity\Customer::load($this->headerdata["customer"]);
     $header = array('date' => date('d.m.Y', $this->document_date), "firmname" => $firm['name'], "firmcode" => $firm['code'], "account" => $f->bankaccount, "bank" => $bank->bank_name, "mfo" => $bank->mfo, "address" => $firm['city'] . ', ' . $firm['street'], "customername" => $this->headerdata["customername"], "document_number" => $this->document_number, "base" => $this->base, "paydate" => date('d.m.Y', $this->headerdata["payment_date"]), "total" => H::fm($total), "totalnds" => H::fm($total + $this->headerdata["totalnds"]), "summa" => Util::ucfirst(Util::money2str($total + $this->headerdata["nds"] / 100, '.', '')));
     $report = new \ZippyERP\ERP\Report('invoice.tpl');
     $html = $report->generate($header, $detail);
     return $html;
 }
Пример #26
0
 public function generateReport()
 {
     $header = array('date' => date('d.m.Y', $this->document_date), "document_number" => $this->document_number, "notes" => $this->headerdata['notes'], "amount" => \ZippyERP\ERP\Helper::fm($this->headerdata["amount"]));
     $optype = $this->headerdata['optype'];
     if ($optype == self::TYPEOP_CUSTOMER) {
         $header['optype'] = "Оплата поставщику";
     }
     if ($optype == self::TYPEOP_CASH) {
         $header['optype'] = "В  подотчет";
     }
     if ($optype == self::TYPEOP_BANK) {
         $header['optype'] = "Перечисление на счет";
     }
     $header['opdetail'] = $this->headerdata["opdetailname"];
     $report = new \ZippyERP\ERP\Report('cashreceiptout.tpl');
     $html = $report->generate($header);
     return $html;
 }
Пример #27
0
 /**
  * передает  данные для  редактирования
  * 
  * @param mixed $item
  */
 public function open(\ZippyERP\ERP\Entity\Item $item = null)
 {
     if ($item == null) {
         $item = new \ZippyERP\ERP\Entity\Item();
     }
     $this->item = $item;
     $this->itemdetail->editname->setText($this->item->itemname);
     $this->itemdetail->editpriceret->setText(H::fm($this->item->priceret));
     $this->itemdetail->editpriceopt->setText(H::fm($this->item->priceopt));
     $this->itemdetail->editdescription->setText($this->item->description);
     $this->itemdetail->editcode->setText($this->item->code);
     $this->itemdetail->edituktzed->setText($this->item->uktzed);
     $this->itemdetail->editbarcode->setText($this->item->barcode);
     $this->itemdetail->editmeasure->setValue($this->item->measure_id);
     $this->itemdetail->editgroup->setValue($this->item->group_id);
     $this->itemdetail->edittype->setValue($this->item->item_type);
     $this->setVisible(true);
 }
Пример #28
0
 public function generateReport()
 {
     $header = array('date' => date('d.m.Y', $this->document_date), "document_number" => $this->document_number, "summa" => H::fm($this->headerdata['summa']), "actual" => H::fm($this->headerdata['actual']), "storename" => $this->headerdata['storename']);
     switch ($this->headerdata['type']) {
         case 1:
             $header['typename'] = "Переоценка";
             break;
         case 2:
             $header['typename'] = "Списание недостач";
             break;
         case 3:
             $header['typename'] = "Оприходование излишков";
             break;
     }
     $report = new \ZippyERP\ERP\Report('revaluationretsum.tpl');
     $html = $report->generate($header);
     return $html;
 }
Пример #29
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;
 }
Пример #30
0
 private function generateReport()
 {
     $store = $this->filter->store->getValue();
     $item = $this->filter->item->getKey();
     $from = $this->filter->from->getDate();
     $to = $this->filter->to->getDate();
     $header = array('datefrom' => date('d.m.Y', $from), 'dateto' => date('d.m.Y', $to), "store" => Store::load($store)->storename, "item" => Item::load($item)->itemname, "measure" => Item::load($item)->measure_name);
     $i = 1;
     $detail = array();
     $conn = \ZCL\DB\DB::getConnect();
     $sql = "\n            SELECT\n              t.*,\n              (SELECT\n                  COALESCE(SUM(u.`quantity`), 0)\n                FROM erp_account_subconto u\n                WHERE u.`document_date` < t.dt\n                AND u.`stock_id` = t.`stock_id`) AS begin_quantity\n            FROM (\n            SELECT\n                st.stock_id,\n                price,\n                DATE(sc.document_date) AS dt,\n                SUM(\n                CASE WHEN quantity > 0 THEN quantity ELSE 0 END) AS obin,\n                SUM(\n                CASE WHEN quantity < 0 THEN 0 - quantity ELSE 0 END) AS obout,\n                GROUP_CONCAT(dc.document_number) AS docs\n              FROM\n               erp_account_subconto  sc join erp_store_stock  st on  sc.stock_id = st.stock_id\n               join erp_document  dc  on sc.document_id = dc.document_id\n\n              WHERE st.item_id = {$item}\n              AND st.store_id = {$store}\n              AND DATE(sc.document_date) >= " . $conn->DBDate($from) . "\n              AND DATE(sc.document_date) <= " . $conn->DBDate($to) . "\n              GROUP BY st.stock_id,\n                       st.price,\n                       DATE(sc.document_date)) t\n            ORDER BY dt\n        ";
     $rs = $conn->Execute($sql);
     foreach ($rs as $row) {
         $detail[] = array("no" => $i++, "date" => date("d.m.Y", strtotime($row['dt'])), "documents" => str_replace(',', '<br>', $row['docs']), "price" => H::fm($row['price']), "in" => $row['begin_quantity'] / 1000, "obin" => $row['obin'] / 1000, "obout" => $row['obout'] / 1000, "out" => ($row['begin_quantity'] + $row['obin'] - $row['obout']) / 1000);
     }
     $report = new \ZippyERP\ERP\Report('itemactivity.tpl');
     $html = $report->generate($header, $detail);
     return $html;
 }