122 lines
4.1 KiB
PHP
122 lines
4.1 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: leos
|
|
* Date: 7/21/17
|
|
* Time: 3:33 PM.
|
|
*/
|
|
|
|
namespace KupShop\AdminBundle;
|
|
|
|
use KupShop\KupShopBundle\Config;
|
|
|
|
trait OrdersMassProcess
|
|
{
|
|
public function ChangeStatus($oID, $status, $balikId, $price, $weight)
|
|
{
|
|
$cfg = Config::get();
|
|
$dbcfg = \Settings::getDefault();
|
|
|
|
$order_message = null;
|
|
|
|
$order = new \Order();
|
|
$order->createFromDB($oID);
|
|
|
|
$sendEmail = true;
|
|
|
|
if ((findModule(\Modules::ORDERS_MASS_PROCESS) && $status == findModule(\Modules::ORDERS_MASS_PROCESS, 'post_default_to'))
|
|
|| findModule(\Modules::BALIKONOS) && $status == findModule(\Modules::BALIKONOS, 'post_default_to', 2)
|
|
) {
|
|
$delivery = $order->getDeliveryType()->id_delivery;
|
|
$balikonosProvider = findModule(\Modules::BALIKONOS, 'provider', 'balikonos');
|
|
|
|
// Do not send email if no user message specified in settings
|
|
if (empty($dbcfg[$balikonosProvider]['delivery_type'][$delivery]['message_name'])) {
|
|
$sendEmail = false;
|
|
} else {
|
|
$order_message = $dbcfg[$balikonosProvider]['delivery_type'][$delivery]['message_name'];
|
|
}
|
|
|
|
$order->setPlaceholder('BALIK_ID', $balikId);
|
|
$order->setPlaceholder('HMOTNOST', $weight);
|
|
$order->setPlaceholder('VAHA', $weight);
|
|
$order->setPlaceholder('CENA', printPrice($price, ['currency' => $order->currency]));
|
|
}
|
|
|
|
$order->changeStatus($status, null, $sendEmail, $order_message);
|
|
|
|
return true;
|
|
}
|
|
|
|
public function printListHeader($labels, $orderParam = null)
|
|
{
|
|
$sum = 0;
|
|
foreach ($labels as $label => $value) {
|
|
$sum += $value;
|
|
}
|
|
$index = 1; ?>
|
|
<thead>
|
|
<?php foreach ($labels as $label => $value) {
|
|
?>
|
|
<th width="<?php echo $value / $sum * 100; ?>%">
|
|
<div class="win_list_header" onMouseOver="_XP_listHdrHighlight(this, 'over');"
|
|
onMouseOut="_XP_listHdrHighlight(this, 'out');">
|
|
<?php
|
|
if ($orderParam) {
|
|
echo figureOrder($index++, $orderParam, $label);
|
|
} else {
|
|
echo $label;
|
|
} ?>
|
|
</div>
|
|
</th>
|
|
<?php
|
|
} ?>
|
|
</thead>
|
|
<?php
|
|
}
|
|
|
|
public function listOrders($orders)
|
|
{
|
|
global $cfg; ?>
|
|
<script src="./static/js/jquery.tablesorter.min.js"></script>
|
|
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="list">
|
|
|
|
<?php $this->printListHeader(['Kód objednávky' => 1, 'Datum' => 1, 'Zákazník' => 1, 'Cena' => 1, 'Počet položek' => 1]); ?>
|
|
|
|
<tbody>
|
|
<?php
|
|
foreach ($orders as $order) {
|
|
$code = $order['id']; ?>
|
|
<tr>
|
|
<td title='<?php echo $order['order_no']; ?>'>
|
|
<div class='list_item'>
|
|
<input type=checkbox name=orders[] value="<?php echo $code; ?>" checked='checked'>
|
|
<a href="javascript:nw('order', '<?php echo $code; ?>');"><?php echo $order['order_no']; ?></a>
|
|
</div>
|
|
</td>
|
|
<td title='<?php echo $order['date_purchased']; ?>'>
|
|
<div class='list_item'><?php echo $order['date_purchased']; ?></div>
|
|
</td>
|
|
<td title='<?php echo $order['customer']; ?>'>
|
|
<div class='list_item'><?php echo $order['customer']; ?></div>
|
|
</td>
|
|
<td title='<?php echo $order['total_price']; ?>'>
|
|
<div class='list_item'><?php echo printPrice($order['total_price']); ?></div>
|
|
</td>
|
|
<td title='<?php echo $order['amount']; ?>'>
|
|
<div class='list_item'><?php echo $order['amount']; ?></div>
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
} ?>
|
|
</tbody>
|
|
</table>
|
|
<script>
|
|
$(document).ready(function () {
|
|
$("#list").tablesorter({sortList: [[4, 1]]});
|
|
});
|
|
</script>
|
|
<?php
|
|
}
|
|
}
|