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; }
public function __construct() { $this->add(new \ZippyERP\System\Blocks\Header("header")); $this->add(new \Zippy\Html\Label("errormessage", new \Zippy\Binding\PropertyBinding($this, '_errormsg'), false, true))->setVisible(false); $user = System::getUser(); if ($user->user_id == 0) { App::Redirect("\\ZippyERP\\System\\Pages\\Userlogin"); } }
/** * Возвращает фильтр из сесии по имени фильтра * * @param mixed $name * @return Filter */ public static function getFilter($name) { $filter = \ZippyERP\System\System::getSession()->filter[$name]; if (!isset($filter)) { $filter = new Filter(); \ZippyERP\System\System::getSession()->filter[$name] = $filter; } return $filter; }
public function __construct($user_id) { parent::__construct(); $this->user = \ZippyERP\System\User::load($user_id); $this->add(new Label('login', $this->user->userlogin)); $this->add(new Label('createdate', date('Y-m-d', $this->user->registration_date))); $this->add(new Label('userroles', 'Зарегистрировнный пользователь')); $this->add(new \Zippy\Html\Form\Form('roleform'))->setVisible(System::getUser()->userlogin == 'admin'); $this->roleform->add(new \Zippy\Html\DataList\DataView("rolerow", new \ZCL\DB\EntityDataSource('\\ZippyERP\\System\\Role'), $this, 'OnAddRoleRow'))->Reload(); $this->roleform->setSubmitHandler($this, 'OnSubmit'); }
public function LogoutClick($sender) { setcookie("remember", '', 0); System::setUser(new \ZippyERP\System\User()); $_SESSION['user_id'] = 0; $_SESSION['userlogin'] = '******'; //$page = $this->getOwnerPage(); // $page = get_class($page) ; App::RedirectHome(); // App::$app->getresponse()->toBack(); }
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; }
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; }
public function __construct() { $this->title = 'Страница администратора'; $this->add(new \ZippyERP\System\Blocks\Header("header")); $this->add(new \Zippy\Html\Label("errormessage", new \Zippy\Binding\PropertyBinding($this, '_errormsg'), false, true))->setVisible(false); $user = System::getUser(); if ($user->user_id == 0) { App::Redirect("\\ZippyERP\\System\\Pages\\Userlogin"); } if ($user->userlogin !== 'admin') { App::Redirect('\\ZippyERP\\Pages\\Error', 'Вы не админ'); } }
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; }
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; }
public function __construct() { $this->add(new \ZippyERP\System\Blocks\Header("header")); $this->add(new Label("errormessage", new \Zippy\Binding\PropertyBinding($this, '_errormsg'), false, true))->setVisible(false); $this->add(new Label("warnmessage", new \Zippy\Binding\PropertyBinding($this, '_warnmsg'), false, true))->setVisible(false); $this->add(new Label("successmessage", new \Zippy\Binding\PropertyBinding($this, '_successmsg'), false, true))->setVisible(false); $this->add(new Label("menudoc", Helper::generateMenu(1), true)); $this->add(new Label("menurep", Helper::generateMenu(2), true)); $this->add(new Label("menureg", Helper::generateMenu(3), true)); $this->add(new Label("menuref", Helper::generateMenu(4), true)); $this->add(new Label("menupage", Helper::generateMenu(5), true)); $this->add(new ClickLink("pageinfo"))->setAttribute("data-content", $this->getPageInfo()); $user = System::getUser(); if ($user->user_id == 0) { App::Redirect("\\ZippyERP\\System\\Pages\\Userlogin"); } }
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; }
/** * добавление коментария * * @param mixed $sender */ public function OnMsgSubmit($sender) { $msg = new \ZippyERP\ERP\Entity\Message(); $msg->message = $this->addmsgform->addmsg->getText(); $msg->created = time(); $msg->user_id = System::getUser()->user_id; $msg->item_id = $this->_item->contact_id; $msg->item_type = \ZippyERP\ERP\Consts::MSG_ITEM_TYPE_CONTACT; if (strlen($msg->message) == 0) { return; } $msg->save(); $this->addmsgform->addmsg->setText(''); $this->updateMessages(); }
public function saveCommonOnClick($sender) { $common = array(); $common['closeddate'] = $this->common->closeddate->getDate(); $common['nds'] = $this->common->nds->getText(); $common['hasnds'] = $this->common->hasnds->isChecked(); $common['simpletax'] = $this->common->simpletax->isChecked(); $common['juridical'] = $this->common->juridical->isChecked(); \ZippyERP\System\System::setOptions("common", $common); }
public function beforeRequest() { if (System::getUser()->user_id > 0) { App::RedirectHome(); } }
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(); }
/** * Возвращает НДС * * @param mixed $revert возвращает обратную величину (наприме если 20% (0.2) возвращает 16.67% (0.1667) ) */ public static function nds($revert = false) { $common = System::getOptions("common"); // $nds = $common['nds'] / 100; if ($revert) { $nds = 1 - 100 / (100 + $common['nds']); } return $nds; }
/** * Експорт в ГНАУ формат XML */ public function export($type) { $common = System::getOptions("common"); $firm = System::getOptions("firmdetail"); $jf = ($common['juridical'] == true ? "J" : "F") . "1201004"; $edrpou = (string) sprintf("%10d", $firm['edrpou']); //2301 0011111111 F1201004 1 00 0000045 1 03 2015 2301.xml $number = (string) sprintf('%07d', 1); $filename = $firm['gni'] . $edrpou . $jf . "100{$number}1" . date('mY', $this->document_date) . $firm['gni'] . ".xml"; $filename = str_replace(' ', '0', $filename); $customer = \ZippyERP\ERP\Entity\Customer::load($this->headerdata["customer"]); $xml = '<?xml version="1.0" encoding="windows-1251"?>'; $xml .= '<DECLAR xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="' . $jf . '.xsd">'; $xml .= "<DECLARHEAD>"; $xml .= "<TIN>{$firm['edrpou']}</TIN>"; $xml .= "<C_DOC>J12</C_DOC>"; $xml .= "<C_DOC_SUB>010</C_DOC_SUB> "; $xml .= "<C_DOC_VER>4</C_DOC_VER>"; $xml .= "<C_DOC_TYPE>0</C_DOC_TYPE>"; $xml .= "<C_DOC_CNT>1</C_DOC_CNT>"; $xml .= "<C_REG>" . substr($firm['gni'], 0, 2) . "</C_REG> "; $xml .= "<C_RAJ>" . substr($firm['gni'], 2, 2) . "</C_RAJ>"; $xml .= "<PERIOD_MONTH>" . date(m) . "</PERIOD_MONTH>"; $xml .= "<PERIOD_TYPE>1</PERIOD_TYPE>"; $xml .= "<PERIOD_YEAR>" . date('Y') . "</PERIOD_YEAR>"; $xml .= "<C_STI_ORIG>{$firm['gni']}</C_STI_ORIG>"; $xml .= "<C_DOC_STAN>1</C_DOC_STAN>"; $xml .= "<D_FILL>" . (string) date('dmY') . "</D_FILL>"; $xml .= "<SOFTWARE>Zippy ERP</SOFTWARE>"; $xml .= "</DECLARHEAD>"; $xml .= "<DECLARBODY>"; $xml .= "<HORIG>1</HORIG>"; $xml .= "<HFILL>" . (string) date('dmY', $this->document_date) . "</HFILL>"; $xml .= "<HNUM>" . $this->document_number . "</HNUM>"; $xml .= "<HNAMESEL>{$firm['name']}</HNAMESEL>"; $xml .= "<HKSEL>{$firm['inn']}</HKSEL>"; $xml .= "<HLOCSEL>" . $firm['city'] . " " . $firm['street'] . "</HLOCSEL>"; if (strlen($firm['phone']) > 0) { $xml .= "<HTELSEL>{$firm['phone']}</HTELSEL>"; } $xml .= "<HNAMEBUY>{$customer->customer_name}</HNAMEBUY>"; $xml .= "<HKBUY>{$customer->inn}</HKBUY>"; $address = strlen($customer->laddress) > 0 ? $customer->laddress : $customer->faddress; $xml .= "<HLOCBUY>{$address}</HLOCBUY>"; if (strlen($this->headerdata['based']) > 0) { $xml .= "<H01G1S>{$this->headerdata['based']}</H01G1S>"; } if (strlen($this->headerdata['ernn']) == true) { $xml .= "<HERPN>true</HERPN>"; } $num = 0; foreach ($this->detaildata as $value) { $num++; $xml .= "<RXXXXG4S ROWNUM=\"{$num}\">{$value['measure_name']}</RXXXXG4S>"; $xml .= "<RXXXXG105_2S ROWNUM=\"{$num}\">{$value['measure_code']}</RXXXXG105_2S>"; if (strlen($value['uktzed'] > 0)) { $xml .= "<RXXXXG4 ROWNUM=\"{$num}\">{$value['uktzed']}</RXXXXG4>"; } $xml .= "<RXXXXG3S ROWNUM=\"{$num}\">{$value['itemname']}</RXXXXG3S>"; $xml .= "<RXXXXG5 ROWNUM=\"{$num}\">{$value['quantity']}</RXXXXG5>"; $xml .= "<RXXXXG6 ROWNUM=\"{$num}\">" . H::fm($value['price']) . "</RXXXXG6>"; $xml .= "<RXXXXG7 ROWNUM=\"{$num}\">" . H::fm($value['quantity'] * $value['price']) . "</RXXXXG7>"; } $total = H::fm($this->headerdata["total"]); $totalnds = H::fm($this->headerdata["totalnds"]); $all = $total + $totalnds; $xml .= "<R01G7>" . ($total - $totalnds) . "</R01G7>"; $xml .= "<R01G11>{$total}</R01G11>"; $xml .= "<R03G7>{$totalnds}</R03G7>"; $xml .= "<R03G11>{$totalnds}</R03G11>"; $xml .= "<R04G7>" . $total . "</R04G7>"; $xml .= "<R04G11>" . $total . "</R04G11>"; $xml .= "</DECLARBODY>"; $xml .= "</DECLAR>"; $xml = iconv("UTF-8", "WINDOWS-1251", $xml); return array("filename" => $filename, "content" => $xml); }
private function getWhere() { $conn = \ZCL\DB\DB::getConnect(); $filter = Filter::getFilter("doclist"); $where = " date(document_date) >= " . $conn->DBDate($filter->from) . " and date(document_date) <= " . $conn->DBDate($filter->to); if (strlen($filter->docgroup) > 1) { $where .= " and type_id in (select meta_id from erp_metadata where menugroup ='{$filter->docgroup}' )"; } if (strlen($filter->searchnumber) > 1) { $where .= " and document_number like '%{$filter->searchnumber}%' "; } if ($filter->onlymy == true) { $where .= " and user_id = " . System::getUser()->user_id; } return $where; }
public function addnewtaskOnClick($sender) { $this->taskstab->setVisible(false); $this->edittasktab->setVisible(true); $this->edittasktab->edittaskform->clean(); $this->_task = new Task(); $this->_task->project_id = $this->_project->project_id; $this->_task->createdby = System::getUser()->user_id; $this->_task->created = time(); $this->_task->updated = time(); $this->edittasktab->edittaskform->edittaskspriority->setValue(3); }
/** * Обновляет состояние документа * * @param mixed $state */ public function updateStatus($state) { if ($this->state == $state) { return false; } if ($this->document_id == 0) { return false; } if ($state == self::STATE_CANCELED) { $this->Cancel(); } if ($state == self::STATE_EXECUTED) { $this->Execute(); } $this->state = $state; $conn = \ZCL\DB\DB::getConnect(); $host = $conn->qstr($_SERVER["REMOTE_ADDR"]); $user = \ZippyERP\System\System::getUser()->getUserID(); $sql = "insert into erp_document_update_log (document_id,user_id,document_state,updatedon,hostname) values ({$this->document_id},{$user},{$this->state},now(),{$host})"; $conn->Execute($sql); $sql = "update erp_document set state={$this->state},updated=now() where document_id = {$this->document_id}"; $conn->Execute($sql); return true; }
public function beforeRender() { parent::beforeRender(); $user = System::getUser(); }