コード例 #1
0
ファイル: trademargin.php プロジェクト: Niqpue/zippyerp
 public function savedocOnClick($sender)
 {
     $store = Store::load($this->docform->store->getValue());
     if ($store == false) {
         $this->setError("Не  выбран  магазин");
         return;
     }
     $this->_doc->document_number = $this->docform->document_number->getText();
     $this->_doc->document_date = $this->docform->document_date->getDate();
     $this->_doc->headerdata['store_id'] = $store->store_id;
     $this->_doc->headerdata['storename'] = $store->storename;
     $isEdited = $this->_doc->document_id > 0;
     $conn = \ZCL\DB\DB::getConnect();
     $conn->BeginTrans();
     try {
         $this->_doc->save();
         if ($sender->id == 'execdoc') {
             $this->_doc->updateStatus(Document::STATE_EXECUTED);
         } else {
             $this->_doc->updateStatus($isEdited ? Document::STATE_EDITED : Document::STATE_NEW);
         }
         $conn->CommitTrans();
         App::RedirectBack();
     } catch (\ZippyERP\System\Exception $ee) {
         $conn->RollbackTrans();
         $this->setError($ee->message);
     } catch (\Exception $ee) {
         $conn->RollbackTrans();
         throw new \Exception($ee->message);
     }
 }
コード例 #2
0
ファイル: movebackitem.php プロジェクト: Niqpue/zippyerp
 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;
 }
コード例 #3
0
ファイル: cashreceiptin.php プロジェクト: Niqpue/zippyerp
 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;
 }
コード例 #4
0
ファイル: itemactivity.php プロジェクト: Niqpue/zippyerp
 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;
 }
コード例 #5
0
ファイル: manualentry.php プロジェクト: Niqpue/zippyerp
 public function additembtnOnClick($sender)
 {
     $id = $this->docform->e_itemlist->getKey();
     if (isset($this->_itemarr[$id])) {
         $this->setError('Дублирование строки');
         return;
     }
     if ($id == 0) {
         $this->setError('Не выбран  ТМЦ');
         return;
     }
     $item = Item::load($id);
     $item->op = $this->docform->e_itemop->getValue();
     if ($item->op == 0) {
         $this->setError('Не выбран  счет');
         return;
     }
     $item->store_id = $this->docform->e_storelist->getValue();
     if ($item->store_id == 0) {
         $this->setError('Не выбран склад');
         return;
     }
     $store = Store::load($item->store_id);
     $item->store_name = $store->storename;
     $item->qty = 1000 * $this->docform->e_quantity->getText();
     // $item->partion = 100 * $this->docform->e_price->getText();
     $item->price = 100 * $this->docform->e_price->getText();
     if ($item->price == 0) {
         $this->setError('Введите  цену');
         return;
     }
     if (strpos($item->op, '_c') > 0) {
         $stock = \ZippyERP\ERP\Entity\Stock::getStock($item->store_id, $id, $item->price, false);
         if ($stock == null) {
             $this->setError("Не найдена  партия " . H::fm($item->price));
             return;
         }
     }
     $this->_itemarr[$id] = $item;
     $this->docform->itemtable->Reload();
     $this->docform->e_quantity->setText('1');
     $this->docform->e_price->setText('0');
 }
コード例 #6
0
ファイル: movebackitem.php プロジェクト: Niqpue/zippyerp
 public function OnChangeItem($sender)
 {
     $stock_id = $sender->getKey();
     $stock = Stock::load($stock_id);
     $store = Store::load($this->docform->storeto->getValue());
     if ($store->store_type == Store::STORE_TYPE_OPT) {
     } else {
         $item = Item::load($stock->item_id);
     }
     if ($store->store_type == Store::STORE_TYPE_RET) {
     }
 }
コード例 #7
0
ファイル: revaluationret.php プロジェクト: Niqpue/zippyerp
 public function savedocOnClick($sender)
 {
     if ($this->checkForm() == false) {
         return;
     }
     $store = Store::load($this->docform->store->getValue());
     $this->_doc->headerdata = array('store' => $store->store_id, 'storename' => $store->storename);
     $this->_doc->detaildata = array();
     foreach ($this->_itemlist as $item) {
         $this->_doc->detaildata[] = $item->getData();
     }
     $this->_doc->document_number = $this->docform->document_number->getText();
     $this->_doc->document_date = strtotime($this->docform->document_date->getText());
     $isEdited = $this->_doc->document_id > 0;
     $conn = \ZCL\DB\DB::getConnect();
     $conn->BeginTrans();
     try {
         $this->_doc->save();
         if ($sender->id == 'execdoc') {
             $this->_doc->updateStatus(Document::STATE_EXECUTED);
         } else {
             $this->_doc->updateStatus($isEdited ? Document::STATE_EDITED : Document::STATE_NEW);
         }
         $conn->CommitTrans();
         App::RedirectBack();
     } catch (\ZippyERP\System\Exception $ee) {
         $conn->RollbackTrans();
         $this->setError($ee->message);
     } catch (\Exception $ee) {
         $conn->RollbackTrans();
         throw new \Exception($ee->message);
     }
 }
コード例 #8
0
ファイル: moveitem.php プロジェクト: Niqpue/zippyerp
 public function beforeRender()
 {
     parent::beforeRender();
     $store = Store::load($this->docform->storeto->getValue());
     if ($store->store_type == Store::STORE_TYPE_OPT) {
         $this->editdetail->editprice->setVisible(false);
     } else {
         $this->editdetail->editprice->setVisible(true);
     }
 }