/** * Возвращает следующий номер при автонумерации * */ public function nextNumber() { $class = explode("\\", get_called_class()); $metaname = $class[count($class) - 1]; $doc = Document::getFirst("meta_name='" . $metaname . "'", "document_id desc"); if ($doc == null) { return ''; } $prevnumber = $doc->document_number; if (strlen($prevnumber) == 0) { return ''; } $number = preg_replace('/[^0-9]/', '', $prevnumber); if (strlen($number) == 0) { $number = 0; } $letter = preg_replace('/[0-9]/', '', $prevnumber); return $letter . sprintf("%05d", ++$number); }
public function saverowOnClick($sender) { $id = $this->editdetail->edititem->getKey(); if ($id == 0) { $this->setError("Не выбран ТМЦ"); return; } $stock = Stock::load($id); $stock->quantity = 1000 * $this->editdetail->editquantity->getText(); $stock->price = 100 * $this->editdetail->editprice->getText(); $stock->type = $this->editdetail->edittype->getValue(); $doc = Document::getFirst("meta_name ='MoveItem' and state=" . Document::STATE_EXECUTED . " and content like '%<item_id>{$stock->item_id}</item_id>%'"); if ($doc == null) { $this->setWarn('Не найден документ перемещения со склада с таким ТМЦ'); } $store = Store::load($this->docform->storefrom->getValue()); // $fromstock = Stock::getStock($this->docform->storefrom->getValue(),$stock->item_id,$stock->price,false); $stockfrom = Stock::getFirst("store_id={$store->store_id} and item_id={$stock->item_id} and price={$stock->price} and partion={$stock->partion} and closed <> 1"); if ($stockfrom == null && $store->store_type == Store::STORE_TYPE_RET) { $this->setError('Товар с такой ценой и партией не найден в магазине'); return; } $this->_itemlist[$stock->stock_id] = $stock; $this->editdetail->setVisible(false); $this->docform->setVisible(true); $this->docform->detail->Reload(); //очищаем форму $this->editdetail->edititem->setKey(0); $this->editdetail->edititem->setText(''); $this->editdetail->editquantity->setText("1"); $this->editdetail->editprice->setText(""); }