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; }
public function saveOnClick($sender) { $this->_employee->contact_id = $this->employeedetail->editcontact->getKey(); if ($this->_employee->contact_id == 0) { $this->setError("Выберите контакт"); return; } $this->_employee->position_id = $this->employeedetail->editposition->getValue(); $this->_employee->department_id = $this->employeedetail->editdepartment->getValue(); $login = trim($this->employeedetail->editlogin->getText()); if (strlen($login) > 0) { if ($login == "admin") { $this->setError('Недопустимое значение логина'); return; } $_emp = Employee::getFirst("login = '******'"); if ($_emp != null && $_emp->employee_id != $this->_employee->employee_id) { $this->setError('Логин занят сотрудником ' . $_emp->getInitName()); return; } $user = \ZippyERP\System\User::getByLogin($login); if ($user == null) { $this->setError('Несуществующий логин'); return; } } $this->_employee->login = $login; $this->_employee->Save(); $this->employeedetail->setVisible(false); $this->employeetable->setVisible(true); $this->employeetable->employeelist->Reload(); $this->contactdetail->setVisible(false); $this->contactview->setVisible(false); }
public function __construct($docid = 0, $basedocid = 0) { parent::__construct(); $this->add(new Form('docform')); $this->docform->add(new TextInput('document_number')); $this->docform->add(new Date('document_date'))->setDate(time()); $this->docform->add(new AutocompleteTextInput('customer'))->setAutocompleteHandler($this, "OnAutoContragent"); $this->docform->add(new AutocompleteTextInput('contract'))->setAutocompleteHandler($this, "OnAutoContract"); $this->docform->add(new TextInput('author')); $this->docform->add(new TextInput('paytype')); $this->docform->add(new CheckBox('ernn')); $this->docform->add(new SubmitLink('addrow'))->setClickHandler($this, 'addrowOnClick'); $this->docform->add(new SubmitButton('savedoc'))->setClickHandler($this, 'savedocOnClick'); $this->docform->add(new Button('backtolist'))->setClickHandler($this, 'backtolistOnClick'); $this->docform->add(new Label('totalnds')); $this->docform->add(new Label('total')); $this->add(new Form('editdetail'))->setVisible(false); $this->editdetail->add(new AutocompleteTextInput('edittovar'))->setAutocompleteHandler($this, "OnAutoItem"); $this->editdetail->edittovar->setChangeHandler($this, 'OnChangeItem'); $this->editdetail->add(new TextInput('editquantity'))->setText("1"); $this->editdetail->add(new TextInput('editprice')); $this->editdetail->add(new TextInput('editpricends')); $this->editdetail->add(new Button('cancelrow'))->setClickHandler($this, 'cancelrowOnClick'); $this->editdetail->add(new SubmitButton('submitrow'))->setClickHandler($this, 'saverowOnClick'); if ($docid > 0) { //загружаем содержимок документа настраницу $this->_doc = Document::load($docid); $this->docform->document_number->setText($this->_doc->document_number); $this->docform->totalnds->setText(H::fm($this->_doc->headerdata['totalnds'])); $this->docform->document_date->setDate($this->_doc->document_date); $this->docform->ernn->setChecked($this->_doc->headerdata['ernn']); $this->docform->paytype->setText($this->_doc->headerdata['paytype']); $this->docform->author->setText($this->_doc->headerdata['author']); $this->docform->contract->setKey($this->_doc->headerdata['contract']); $this->docform->contract->setText($this->_doc->headerdata['contractnumber']); $this->docform->customer->setKey($this->_doc->headerdata['customer']); $this->docform->customer->setText($this->_doc->headerdata['customername']); $basedoc = Document::load($this->_doc->headerdata['based']); foreach ($this->_doc->detaildata as $item) { $item = new Item($item); $this->_tovarlist[$item->item_id] = $item; } } else { $this->_doc = Document::create('TaxInvoice'); $this->docform->document_number->setText($this->_doc->nextNumber()); $user = System::getUser(); $employee = \ZippyERP\ERP\Entity\Employee::find("login='******'"); if ($employee instanceof \ZippyERP\ERP\Entity\Employee) { $this->docform->author->setText($employee->fullname); } if ($basedocid > 0) { //создание на основании $basedoc = Document::load($basedocid); if ($basedoc instanceof Document) { $this->_basedocid = $basedocid; if ($basedoc->meta_name == 'GoodsIssue') { $this->docform->customer->setKey($basedoc->headerdata['customer']); $this->docform->customer->setText($basedoc->headerdata['customername']); $this->docform->contract->setKey($basedoc->headerdata['contract']); $this->docform->contract->setText($basedoc->headerdata['contractnumber']); foreach ($basedoc->detaildata as $item) { $item = new Item($item); $this->_tovarlist[$item->item_id] = $item; } } if ($basedoc->meta_name == 'Invoice') { $this->docform->customer->setKey($basedoc->headerdata['customer']); $this->docform->customer->setText($basedoc->headerdata['customername']); $this->docform->contract->setKey($basedoc->headerdata['contract']); $this->docform->contract->setText($basedoc->headerdata['contractnumber']); foreach ($basedoc->detaildata as $item) { $item = new Item($item); $this->_tovarlist[$item->item_id] = $item; } } } } } $this->docform->add(new DataView('detail', new \Zippy\Html\DataList\ArrayDataSource(new \Zippy\Binding\PropertyBinding($this, '_tovarlist')), $this, 'detailOnRow'))->Reload(); }
public function OnAutoEmp($sender) { $text = $sender->getValue(); return Employee::findArray('fullname', "fullname like '%{$text}%' "); }
public function getItem($id) { return Employee::load($id); }
public static function getAssignedList() { // return \ZippyERP\System\User::findArray('userlogin'); return \ZippyERP\ERP\Entity\Employee::findArray('shortname'); }
public function opdetailOnAutocomplete($sender) { $text = $sender->getValue(); $optype = $this->docform->optype->getValue(); if ($optype == CROUT::TYPEOP_CUSTOMER) { return Customer::findArray('customer_name', "customer_name like '%{$text}%' and ( cust_type=" . Customer::TYPE_SELLER . " or cust_type= " . Customer::TYPE_BUYER_SELLER . " )"); } if ($optype == CROUT::TYPEOP_BANK) { return MoneyFund::findArray('title', "title like '%{$text}%' "); } if ($optype == CROUT::TYPEOP_CASH) { return Employee::findArray('fullname', "fullname like '%{$text}%' "); } }
public function __construct($docid = 0, $basedocid = 0) { parent::__construct(); $this->add(new Form('docform')); $this->docform->add(new TextInput('document_number')); $this->docform->add(new Date('document_date'))->setDate(time()); $this->docform->add(new DropDownChoice('employee', Employee::findArray('shortname'))); $this->docform->add(new DropDownChoice('store', Store::findArray("storename", "store_type=" . Store::STORE_TYPE_OPT))); $this->docform->add(new DropDownChoice('expensetype', \ZippyERP\ERP\Entity\Doc\ExpenseReport::expenceList()))->setChangeHandler($this, 'OnExpenseList'); $this->docform->add(new TextInput('expenseamount'))->setVisible(false); $this->docform->add(new CheckBox('isnds'))->setChangeHandler($this, 'onIsnds'); $this->docform->add(new SubmitLink('addrow'))->setClickHandler($this, 'addrowOnClick'); $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'); $this->docform->add(new Label('totalnds')); $this->docform->add(new Label('total')); $this->add(new Form('editdetail'))->setVisible(false); $this->editdetail->add(new AutocompleteTextInput('edititem'))->setAutocompleteHandler($this, 'OnAutoItem'); $this->editdetail->add(new TextInput('editquantity'))->setText("1"); $this->editdetail->add(new TextInput('editprice')); $this->editdetail->add(new TextInput('editpricends')); $this->editdetail->add(new Button('cancelrow'))->setClickHandler($this, 'cancelrowOnClick'); $this->editdetail->add(new SubmitButton('saverow'))->setClickHandler($this, 'saverowOnClick'); // $this->editdetail->add(new SubmitLink('additem'))->setClickHandler($this, 'addItemOnClick'); if ($docid > 0) { //загружаем содержимок документа настраницу $this->_doc = Document::load($docid); $this->docform->document_number->setText($this->_doc->document_number); $this->docform->expenseamount->setText(H::fm($this->_doc->headerdata['expenseamount'])); $this->docform->isnds->setChecked($this->_doc->headerdata['isnds']); $this->docform->document_date->setDate($this->_doc->document_date); $this->docform->employee->setValue($this->_doc->headerdata['employee']); $this->docform->store->setValue($this->_doc->headerdata['store']); $this->docform->expensetype->setValue($this->_doc->headerdata['expensetype']); foreach ($this->_doc->detaildata as $item) { $item = new Item($item); $this->_itemlist[$item->item_id] = $item; } $val = $this->_doc->headerdata['expensetype']; if ($val == 201 || $val == 22 || $val == 281) { $this->docform->expenseamount->setVisible(false); $this->docform->store->setVisible(true); $this->docform->addrow->setVisible(true); } else { $this->docform->expenseamount->setVisible(true); $this->docform->store->setVisible(false); $this->docform->addrow->setVisible(false); } } else { $this->_doc = Document::create('ExpenseReport'); /* if ($basedocid > 0) { //создание на основании $basedoc = Document::load($basedocid); if ($basedoc instanceof Document) { $this->_basedocid = $basedocid; /* if ($basedoc->meta_name == 'PurchaseInvoice') { $this->docform->isnds->setChecked($basedoc->headerdata['isnds']); $this->docform->employee->setValue($basedoc->headerdata['employee']); foreach ($basedoc->detaildata as $_item) { $item = new Item($_item); $this->_itemlist[$item->item_id] = $item; } } } } */ } $this->docform->add(new DataView('detail', new \Zippy\Html\DataList\ArrayDataSource(new \Zippy\Binding\PropertyBinding($this, '_itemlist')), $this, 'detailOnRow'))->Reload(); $this->add(new \ZippyERP\ERP\Blocks\Item('itemdetail', $this, 'OnItem'))->setVisible(false); }