示例#1
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;
 }
示例#2
0
 public function saverowOnClick($sender)
 {
     $id = $this->editdetail->edittovar->getKey();
     if ($id == 0) {
         $this->setError("Не выбран товар");
         return;
     }
     $item = Item::load($id);
     $item->quantity = 1000 * $this->editdetail->editquantity->getText();
     $item->price = $this->editdetail->editprice->getText() * 100;
     $item->sn = $this->editdetail->editsn->getText();
     $item->warranty = $this->editdetail->editwarranty->getText();
     unset($this->_tovarlist[$this->_rowid]);
     $this->_tovarlist[$item->item_id] = $item;
     $this->editdetail->setVisible(false);
     $this->docform->setVisible(true);
     $this->docform->detail->Reload();
     //очищаем  форму
     $this->editdetail->edittovar->setKey(0);
     $this->editdetail->edittovar->setText('');
     $this->editdetail->editquantity->setText("1");
     $this->editdetail->editprice->setText("");
     $this->editdetail->editsn->setText("");
     $this->editdetail->editwarranty->setText("");
 }
示例#3
0
 public function OnChangeItem($sender)
 {
     $id = $sender->getKey();
     $item = Item::load($id);
     $this->editdetail->editprice->setText(H::fm($item->priceopt));
     $this->editdetail->qtystore->setText(Item::getQuantity($id, $this->docform->timeline->getDate()) / 1000);
     $this->updateAjax(array('editprice', 'qtystore'));
 }
示例#4
0
 public function OnChangeItem($sender)
 {
     $item = Item::load($id);
     $this->editdetail->editprice->setText(H::fm($item->priceopt));
     $nds = H::nds();
     $this->editdetail->editpricends->setText(H::fm($item->priceopt + $item->priceopt * $nds));
     $this->updateAjax(array('editprice', 'editpricends', 'qtystock'));
 }
示例#5
0
 public function OnChangeItem($sender)
 {
     $id = $sender->getKey();
     $item = Item::load($id);
     $this->editdetail->editprice->setText(H::fm($item->priceopt));
     $this->editdetail->editpricends->setText(H::fm($item->priceopt));
     if ($this->docform->isnds->IsChecked()) {
         $nds = H::nds();
         $this->editdetail->editpricends->setText(H::fm($item->priceopt + $item->priceopt * $nds));
     }
     // $this->editdetail->editquantity->setText(Item::getQuantity($id, $this->docform->timeline->getDate())/1000);
     $this->updateAjax(array('editprice', 'editpricends'));
 }
示例#6
0
 public function OnChangeItem($sender)
 {
     $id = $sender->getKey();
     $stock = Stock::load($id);
     $item = Item::load($stock->item_id);
     $this->editdetail->editprice->setText(H::fm($stock->price));
     $this->editdetail->qtystock->setText(Stock::getQuantity($id, $this->docform->document_date->getDate()) / 1000 . ' ' . $stock->measure_name);
     $this->updateAjax(array('editprice', 'qtystock'));
 }
示例#7
0
 public function getItem($id)
 {
     return Item::load($id);
 }
示例#8
0
 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');
 }
示例#9
0
 public function OnChangeItem($sender)
 {
     $id = $sender->getKey();
     $stock = Stock::load($id);
     $this->editdetail->qtystock->setText(Stock::getQuantity($id, $this->docform->document_date->getDate(), $this->editdetail->edittype->getValue()) / 1000 . ' ' . $stock->measure_name);
     $item = Item::load($stock->item_id);
     $this->editdetail->editprice->setText(H::fm($item->priceopt));
     $nds = 0;
     if ($this->docform->isnds->isChecked()) {
         $nds = H::nds();
     }
     $this->editdetail->editpricends->setText(H::fm($item->priceopt + $item->priceopt * $nds));
     $this->updateAjax(array('editprice', 'editpricends', 'qtystock'));
 }
示例#10
0
 public function OnChangeItem($sender)
 {
     $id = $sender->getKey();
     $stock = Stock::load($id);
     $item = Item::load($stock->item_id);
     $this->editdetail->editprice->setText(H::fm($stock->price));
     $this->updateAjax(array('editprice'));
 }
示例#11
0
 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) {
     }
 }
示例#12
0
 public function OnChangeItem($sender)
 {
     $stock_id = $sender->getKey();
     $stock = Stock::load($stock_id);
     $this->editdetail->qtystock->setText(Stock::getQuantity($stock_id, $this->docform->document_date->getDate(), $this->editdetail->edittype->getValue()) / 1000 . ' ' . $stock->measure_name);
     $store = Store::load($this->docform->storeto->getValue());
     if ($store->store_type == Store::STORE_TYPE_OPT) {
         // $this->editdetail->editprice->setText(H::fm($stock->price));
     } else {
         $item = Item::load($stock->item_id);
         $this->editdetail->editprice->setText(H::fm($item->priceret));
     }
     if ($store->store_type == Store::STORE_TYPE_RET) {
         //если  уже   есть  товар  в  магазине  берем  цену  оттуда
         $stock = Stock::getFirst("store_id={$store->store_id} and item_id={$stock->item_id} and closed <> 1");
         if ($stock instanceof Stock) {
             $this->editdetail->editprice->setText(H::fm($stock->price));
         }
     }
 }