Skip to content

Commit

Permalink
6.2.2
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
leon-mbs authored Jun 26, 2022
2 parents 55662da + 2194124 commit 4942448
Show file tree
Hide file tree
Showing 27 changed files with 282 additions and 225 deletions.
4 changes: 2 additions & 2 deletions www/app/entity/doc/document.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Document extends \ZCL\DB\Entity
const EX_PDF = 3; // PDF
const EX_POS = 4; // POS терминал
const EX_MAIL = 5; // Отправка email
// const EX_XML_GNAU = 4;

//доставка
const DEL_SELF = 1; // самовывоз
const DEL_BOY = 2; // курьер
Expand Down Expand Up @@ -73,7 +73,7 @@ public function __construct($row = null) {
*/
protected function init() {
$this->document_id = 0;
$this->state = 0;
$this->state = self::STATE_NEW;
$this->customer_id = 0;
$this->branch_id = 0;
$this->parent_id = 0;
Expand Down
3 changes: 2 additions & 1 deletion www/app/entity/doc/goodsissue.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ public function getRelationBased() {
$list['ReturnIssue'] = self::getDesc('ReturnIssue');
$list['GoodsIssue'] = self::getDesc('GoodsIssue');
$list['TTN'] = self::getDesc('TTN');

$list['Invoice'] = self::getDesc('Invoice');

return $list;
}

Expand Down
11 changes: 2 additions & 9 deletions www/app/entity/doc/invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,7 @@ public function Execute() {
}
}

if ($this->headerdata['payment'] > 0 && $this->payed > 0) {
$payed = \App\Entity\Pay::addPayment($this->document_id, $this->document_date, $this->payed, $this->headerdata['payment']);
if ($payed > 0) {
$this->payed = $payed;
}
\App\Entity\IOState::addIOState($this->document_id, $this->payed, \App\Entity\IOState::TYPE_BASE_INCOME);

}

return true;
}

Expand All @@ -136,7 +129,7 @@ protected function getNumberTemplate() {
public function getRelationBased() {
$list = array();
$list['GoodsIssue'] = self::getDesc('GoodsIssue');
$list['Invoice'] = self::getDesc('Invoice');
// $list['Invoice'] = self::getDesc('Invoice');
$list['TTN'] = self::getDesc('TTN');
$list['ServiceAct'] = self::getDesc('ServiceAct');

Expand Down
21 changes: 14 additions & 7 deletions www/app/entity/doc/serviceact.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public function generateReport() {
"device" => $this->headerdata["device"],
"isfirm" => strlen($firm["firm_name"]) > 0,
"iscontract" => $this->headerdata["contract_id"] > 0,
"paydisc" => H::fa($this->headerdata["paydisc"]),
"isdisc" => $this->headerdata["paydisc"] > 0,
"devsn" => $this->headerdata["devsn"],
"document_number" => $this->document_number,
"payed" => $this->payed > 0 ? H::fa($this->payed) : false,
Expand Down Expand Up @@ -73,17 +75,22 @@ public function Execute() {
$sc->save();
}
}
protected function onState($state) {

public function Pay() {
if ($this->headerdata['payment'] > 0 && $this->payed > 0) {
$payed = \App\Entity\Pay::addPayment($this->document_id, $this->document_date, $this->payed, $this->headerdata['payment'] );
if ($payed > 0) {
$this->payed = $payed;
}
\App\Entity\IOState::addIOState($this->document_id, $this->payed, \App\Entity\IOState::TYPE_BASE_INCOME);
if ($state == self::STATE_INPROCESS) {


if ($this->headerdata['payment'] > 0 && $this->payed > 0) {
$payed = \App\Entity\Pay::addPayment($this->document_id, $this->document_date, $this->payed, $this->headerdata['payment']);
if ($payed > 0) {
$this->payed = $payed;
}
\App\Entity\IOState::addIOState($this->document_id, $this->payed, \App\Entity\IOState::TYPE_BASE_INCOME);

}
}
}


public function supportedExport() {
return array(self::EX_EXCEL, self::EX_PDF, self::EX_POS);
Expand Down
19 changes: 17 additions & 2 deletions www/app/entity/store.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,30 @@ protected function beforeDelete() {
$conn = \ZDB\DB::getConnect();
$sql = " select count(*) from store_stock where store_id = {$this->store_id}";
$cnt = $conn->GetOne($sql);
return ($cnt > 0) ? "Нельзя удалять используемый склад" : '';
return ($cnt > 0) ? \App\Helper::l("nodelusedstore") : '';
}

/**
* список складов для комбо
*
*/
public static function getList() {
return Store::findArray("storename", "");
return Store::findArray('storename','','store_id');
}
/**
* без ограничений по фииалам
*
*/
public static function getListAll() {
$conn = \ZDB\DB::getConnect();
$sql = " select storename,store_id from stores ";
$list = array();
foreach($conn->Execute($sql) as $row){
$list[$row['store_id']] = $row['storename'];
};


return $list;
}

public static function getConstraint() {
Expand Down
1 change: 1 addition & 0 deletions www/app/entity/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ protected function afterLoad() {


$this->noshowpartion = $acl['noshowpartion'];
$this->showotherstores = $acl['showotherstores'];

$this->aclview = $acl['aclview'];
$this->acledit = $acl['acledit'];
Expand Down
2 changes: 2 additions & 0 deletions www/app/entity/userrole.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ protected function afterLoad() {
}

$this->noshowpartion = $acl['noshowpartion'];
$this->showotherstores = $acl['showotherstores'];
$this->aclview = $acl['aclview'];
$this->acledit = $acl['acledit'];
$this->aclexe = $acl['aclexe'];
Expand All @@ -59,6 +60,7 @@ protected function beforeSave() {
$acl = array();

$acl['noshowpartion'] = $this->noshowpartion;
$acl['showotherstores'] = $this->showotherstores;
$acl['aclview'] = $this->aclview;
$acl['acledit'] = $this->acledit;
$acl['aclexe'] = $this->aclexe;
Expand Down
8 changes: 4 additions & 4 deletions www/app/modules/pu/orders.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function filterOnSubmit($sender) {

foreach ($data['orders'] as $puorder) {

$cnt = $conn->getOne("select count(*) from documents_view where meta_name='Order' and content like '%<puorder>{$puorder['id']}</wcorder>%' ") ;
$cnt = $conn->getOne("select count(*) from documents_view where meta_name='Order' and content like '%<puorder>{$puorder['id']}</puorder>%' ") ;

// $isorder = Document::findCnt("meta_name='Order' and content like '%<wcorder>{$puorder->id}</wcorder>%'");
if ( intval($cnt) > 0) { //уже импортирован
Expand Down Expand Up @@ -131,7 +131,7 @@ public function filterOnSubmit($sender) {

$neworder->document_date = time();
$neworder->notes = "PU номер:{$puorder['id']};";
$neworder->notes .= " Клиент:" .$puorder['client_first_name'] . ' ' . $puorder['client_last_name'].';';
$neworder->notes .= " Клієнт:" .$puorder['client_first_name'] . ' ' . $puorder['client_last_name'].';';
if (strlen($puorder['email']) > 0) {
$neworder->notes .= " Email:" . $puorder['email'] . ";";
}
Expand All @@ -143,10 +143,10 @@ public function filterOnSubmit($sender) {
}

if (strlen($puorder['delivery_address']) > 0) {
$neworder->notes .= " Адрес:" . $puorder['delivery_address'] . ";";
$neworder->notes .= " Адреса:" . $puorder['delivery_address'] . ";";
}
if (strlen($puorder['client_notes']) > 0) {
$neworder->notes .= " Комментарий:" . $puorder['client_notes'] . ";";
$neworder->notes .= " Комментар:" . $puorder['client_notes'] . ";";
}


Expand Down
6 changes: 3 additions & 3 deletions www/app/modules/wc/orders.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,15 @@ public function filterOnSubmit($sender) {

$neworder->document_date = time();
$neworder->notes = "WC номер:{$wcorder->id};";
$neworder->notes .= " Клиент:" . $wcorder->shipping->first_name . ' ' . $wcorder->shipping->last_name . ";";
$neworder->notes .= " Клієнт:" . $wcorder->shipping->first_name . ' ' . $wcorder->shipping->last_name . ";";
if (strlen($wcorder->billing->email) > 0) {
$neworder->notes .= " Email:" . $wcorder->billing->email . ";";
}
if (strlen($wcorder->billing->phone) > 0) {
$neworder->notes .= " Тел:" . $wcorder->billing->phone . ";";
}
$neworder->notes .= " Адрес:" . $wcorder->shipping->city . ' ' . $wcorder->shipping->address_1 . ";";
$neworder->notes .= " Комментарий:" . $wcorder->customer_note . ";";
$neworder->notes .= " Адреса:" . $wcorder->shipping->city . ' ' . $wcorder->shipping->address_1 . ";";
$neworder->notes .= " Комментар:" . $wcorder->customer_note . ";";

$this->_neworders[$wcorder->id] = $neworder;
}
Expand Down
43 changes: 20 additions & 23 deletions www/app/pages/doc/invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function __construct($docid = 0, $basedocid = 0) {
$this->docform->add(new TextInput('phone'));
$this->docform->add(new TextInput('customer_print'));

$this->docform->add(new DropDownChoice('payment', \App\Entity\MoneyFund::getList(), H::getDefMF()));
$this->docform->add(new DropDownChoice('payment', \App\Entity\MoneyFund::getList(2), H::getDefMF()));

$this->docform->add(new Label('discount'));
$this->docform->add(new TextInput('editpaydisc'));
Expand All @@ -66,9 +66,6 @@ public function __construct($docid = 0, $basedocid = 0) {

$this->docform->add(new TextInput('editpayamount'));
$this->docform->add(new SubmitButton('bpayamount'))->onClick($this, 'onPayAmount');
$this->docform->add(new TextInput('editpayed', "0"));
$this->docform->add(new SubmitButton('bpayed'))->onClick($this, 'onPayed');
$this->docform->add(new Label('payed', 0));
$this->docform->add(new Label('payamount', 0));

$this->docform->add(new SubmitLink('addcust'))->onClick($this, 'addcustOnClick');
Expand Down Expand Up @@ -123,11 +120,6 @@ public function __construct($docid = 0, $basedocid = 0) {
$this->docform->editpayamount->setText($this->_doc->payamount);
$this->docform->paydisc->setText($this->_doc->headerdata['paydisc']);
$this->docform->editpaydisc->setText($this->_doc->headerdata['paydisc']);
if ($this->_doc->payed == 0 && $this->_doc->headerdata['payed'] > 0) {
$this->_doc->payed = $this->_doc->headerdata['payed'];
}
$this->docform->editpayed->setText(H::fa($this->_doc->payed));
$this->docform->payed->setText(H::fa($this->_doc->payed));

$this->docform->total->setText($this->_doc->amount);

Expand Down Expand Up @@ -167,6 +159,23 @@ public function __construct($docid = 0, $basedocid = 0) {

$this->calcPay();

$this->_itemlist = $basedoc->unpackDetails('detaildata');
}
if ($basedoc->meta_name == 'GoodsIssue') {

$this->docform->customer->setKey($basedoc->customer_id);
$this->docform->customer->setText($basedoc->customer_name);
$this->OnChangeCustomer($this->docform->customer);

$this->docform->pricetype->setValue($basedoc->headerdata['pricetype']);

$this->docform->notes->setText(H::l("invoicefor", $basedoc->document_number));
$order = $basedoc->cast();

$this->docform->total->setText($order->amount);

$this->calcPay();

$this->_itemlist = $basedoc->unpackDetails('detaildata');
}
}
Expand Down Expand Up @@ -380,11 +389,6 @@ public function savedocOnClick($sender) {


$this->_doc->payamount = $this->docform->payamount->getText();
$this->_doc->payed = $this->docform->payed->getText();
$this->_doc->headerdata['payed'] = $this->docform->payed->getText();
if ($this->_doc->headerdata['payment'] == 0) {
$this->_doc->payed = 0;
}


$this->_doc->headerdata['paydisc'] = $this->docform->paydisc->getText();
Expand Down Expand Up @@ -450,9 +454,6 @@ public function onPayAmount($sender) {
$this->docform->payamount->setText(H::fa($this->docform->editpayamount->getText()));
}

public function onPayed($sender) {
$this->docform->payed->setText(H::fa($this->docform->editpayed->getText()));
}

public function onPayDisc() {

Expand Down Expand Up @@ -509,9 +510,7 @@ private function calcPay() {
$this->docform->editpayamount->setText(H::fa($total - $disc));
$this->docform->payamount->setText(H::fa($total - $disc));

$this->docform->editpayed->setText(H::fa($total - $disc));
// $this->docform->payed->setText(H::fa($total - $disc));


}

/**
Expand All @@ -537,9 +536,7 @@ private function checkForm() {
if (($this->docform->store->getValue() > 0) == false) {
$this->setError("noselstore");
}
if ($this->docform->payment->getValue() == 0 && $this->_doc->payed > 0) {
$this->setError("noselmfp");
}

$c = $this->docform->customer->getKey();
if ($c == 0) {
$this->setError("noselcust");
Expand Down
Loading

0 comments on commit 4942448

Please sign in to comment.