Skip to content

Commit

Permalink
Merge pull request #700 from leon-mbs/dev
Browse files Browse the repository at this point in the history
промо  в  кафе
  • Loading branch information
leon-mbs authored Feb 20, 2024
2 parents b8d1dfc + 167f2fa commit bb12cd2
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 20 deletions.
2 changes: 1 addition & 1 deletion www/app/pages/empacc.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function OnSubmitS($sender) {

$conn = \ZDB\DB::getConnect();

$sql = "select coalesce(sum(amount),0) from empacc where optype < 100 and emp_id = {$emp_id} and createdon < " . $conn->DBDate($from);
$sql = "select coalesce(sum(amount),0) from empacc where emp_id = {$emp_id} and createdon < " . $conn->DBDate($from);

$b = $conn->GetOne($sql);

Expand Down
37 changes: 24 additions & 13 deletions www/app/pages/register/itemlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -379,24 +379,28 @@ public function oncsv($sender) {
$header['E1'] = "Категорiя";
$header['F1'] = "Бренд";
$header['G1'] = "Кiл.";
$header['H1'] = "Обл. цiна";
if($this->_tvars["noshowpartion"] == true) {
$header['H1'] ='';
}

if(strlen($common['price1'])) {
$header['H1'] = $common['price1'];
$header['I1'] = $common['price1'];
}
if(strlen($common['price2'])) {
$header['I1'] = $common['price2'];
$header['J1'] = $common['price2'];
}
if(strlen($common['price3'])) {
$header['J1'] = $common['price3'];
$header['K1'] = $common['price3'];
}
if(strlen($common['price4'])) {
$header['K1'] = $common['price4'];
$header['L1'] = $common['price4'];
}
if(strlen($common['price5'])) {
$header['L1'] = $common['price5'];
$header['M1'] = $common['price5'];
}

$header['M1'] = "На суму";
$header['N1'] = "На суму";

$i = 1;
foreach ($list as $item) {
Expand All @@ -408,31 +412,38 @@ public function oncsv($sender) {
$data['E' . $i] = $item->cat_name;
$data['F' . $i] = $item->manufacturer;
$qty = $item->getQuantity($store);
$pr = $item->getPartion($store);


$data['G' . $i] = H::fqty($qty);
$data['H' . $i] = H::fa($pr);
if($this->_tvars["noshowpartion"] == true) {
$data['H' . $i] ='';
}


if ($item->price1 > 0) {
$data['H' . $i] = $item->getPrice('price1', $store);
$data['I' . $i] = $item->getPrice('price1', $store);
}
if ($item->price2 > 0) {
$data['I' . $i] = $item->getPrice('price2', $store);
$data['J' . $i] = $item->getPrice('price2', $store);
}
if ($item->price3 > 0) {
$data['J' . $i] = $item->getPrice('price3', $store);
$data['K' . $i] = $item->getPrice('price3', $store);
}
if ($item->price4 > 0) {
$data['K' . $i] = $item->getPrice('price4', $store);
$data['L' . $i] = $item->getPrice('price4', $store);
}
if ($item->price5 > 0) {
$data['L' . $i] = $item->getPrice('price5', $store);
$data['M' . $i] = $item->getPrice('price5', $store);
}

if($pt=='price') {
$am = $item->getAmount($store);
$am = $qty * $pr;
} else {
$am = $qty * $item->getPrice($pt, $store) ;
}
$data['M' . $i] = H::fa(abs($am));
$data['N' . $i] = H::fa(abs($am));

}

Expand Down
49 changes: 48 additions & 1 deletion www/app/pages/service/armfood.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ public function __construct() {
$this->docpanel->navform->add(new AutocompleteTextInput('itemfast'))->onText($this, 'OnAutoItem');
$this->docpanel->navform->add(new SubmitButton('addfast'))->onClick($this, 'addfastOnClick');

$this->docpanel->navform->add(new TextInput('promocode'));
$this->docpanel->navform->promocode->setVisible(\App\Entity\PromoCode::findCnt('') > 0);


$this->docpanel->navform->add(new ClickLink('openshift', $this, 'OnOpenShift'));
$this->docpanel->navform->add(new ClickLink('closeshift', $this, 'OnCloseShift'));

Expand Down Expand Up @@ -833,6 +837,7 @@ public function onStatus($sender) {

$this->docpanel->listsform->notes->setText($this->_doc->notes);
$this->docpanel->listsform->table->setText($this->_doc->headerdata['table']);
$this->docpanel->navform->promocode->setText($this->_doc->headerdata['promocode']);
$this->docpanel->listsform->bonus->setText($this->_doc->headerdata['bonus']);
$this->docpanel->listsform->totaldisc->setText($this->_doc->headerdata['totaldisc']);
$this->docpanel->listsform->addcust->setVisible(false) ;
Expand Down Expand Up @@ -928,6 +933,20 @@ public function calcTotal() {
foreach ($this->_itemlist as $item) {
$amount += H::fa($item->quantity * $item->price);
}

$code= trim($this->docpanel->navform->promocode->getText());
if($code != '') {
$r = \App\Entity\PromoCode::check($code,$this->docpanel->listsform->customer->getKey()) ;
if($r == ''){
$p = \App\Entity\PromoCode::findByCode($code);
$disc = doubleval($p->disc );
if($disc >0) {
$td = H::fa( $amount * ($p->disc/100) );
$this->docpanel->listsform->totaldisc->setText($td);
}
}
}

$this->docpanel->listsform->totalamount->setText(H::fa($amount));


Expand Down Expand Up @@ -1372,6 +1391,7 @@ public function createdoc() {
$this->_doc->headerdata["inn"] = $firm['inn'];
$this->_doc->headerdata["address"] = $firm['address'];
$this->_doc->headerdata["phone"] = $firm['phone'];
$this->_doc->headerdata["promocode"] = $this->docpanel->navform->promocode->getText();
$this->_doc->headerdata["totaldisc"] = $this->docpanel->listsform->totaldisc->getText();
$this->_doc->headerdata["bonus"] = $this->docpanel->listsform->bonus->getText();

Expand Down Expand Up @@ -1877,6 +1897,33 @@ public function onFisc($sender) {
}



public function chechPromo($args, $post=null) {
$code = trim($args[0]) ;
if($code=='') {
return json_encode([], JSON_UNESCAPED_UNICODE);
}
$r = \App\Entity\PromoCode::check($code,$this->docpanel->listsform->customer->getKey()) ;
if($r != ''){
return json_encode(array('error'=>$r), JSON_UNESCAPED_UNICODE);
}
$total = 0;

foreach ($this->_itemlist as $item) {
$total += H::fa($item->quantity * $item->price);
}

$p = \App\Entity\PromoCode::findByCode($code);
$disc = doubleval($p->disc );
if($disc >0) {
$td = H::fa( $total * ($p->disc/100) );
$ret=array('disc'=>$td) ;
return json_encode($ret, JSON_UNESCAPED_UNICODE);

}

return json_encode([], JSON_UNESCAPED_UNICODE);


}

}
11 changes: 7 additions & 4 deletions www/templates/modules/note/pages/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{{={| |}=}}
<div class="row" id="vapp">
<div class=" col-12" >
<div class="row">
<div class="row">
<div class="col-md-4 col-12">
<div class=" mb-1" style="height:30px;">
<a v-on:click.prevent="onNewNode" v-show="selectedNode != null" class="btn btn-primary btn-sm mr-2" ><i class="fa fa-plus-circle"></i> Новий вузол</a>
Expand Down Expand Up @@ -130,9 +130,8 @@
</div>
</div>

</div>
</div>

</div>


<div id="nodeedit" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog" >
Expand Down Expand Up @@ -231,7 +230,11 @@
</div>


</div>

</div>



{|={{ }}=|}

Expand Down
20 changes: 19 additions & 1 deletion www/templates/pages/service/armfood.html
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ <h3>Оформлення замовлення</h3>

{{/usescanner}}

<input placeholder="Промокод" style="width:150px" zippy="promocode" class="form-control">

{{#fiscal}}
&nbsp; &nbsp;
<a zippy="openshift"><i class="fa fa-bullhorn"></i> Вiдкрити змiну</a>
Expand Down Expand Up @@ -704,7 +706,23 @@ <h3>&nbsp;Новий покупець </h3>
return true;
}


$("#promocode").blur(function () {
var promodode = $("#promocode").val();



callPM('chechPromo',[promodode], null,(data)=>
{
if(checkPMAnswer(data)) {

$('#totaldisc').val(data.disc)
} else {
$('#totaldisc').val('0')
$('#promocode').val('')
}

});
});
var vapp = new Vue({
el: '#vapp',

Expand Down

0 comments on commit bb12cd2

Please sign in to comment.