first commit

This commit is contained in:
2025-08-02 16:30:27 +02:00
commit 23646bfcee
14851 changed files with 1750626 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
<?php
$lang = getVal('lang');
if ($lang) {
switchLanguage($lang);
loadLanguage('printOrder', $lang);
}
$smarty = createSmarty(true, true);
if (empty($ID_ITEM)) {
$ID_ITEM = getVal('ID');
}
$order = new Order($ID_ITEM);
$order->createFromDB($ID_ITEM, true, true, true);
$order->fetchItems();
global $dbcfg, $cfg;
if (getVal('rate')) {
$dbcfg['currency'] = '€';
$dbcfg['rate'] = (float) str_replace(',', '.', getVal('rate'));
} else {
$dbcfg['rate'] = 1; // CNB::getCurrency('EUR');
}
if (!$order->date_handle) {
$order->date_handle = new DateTime();
}
$order['date_payment'] = clone $order->date_handle;
$order['date_payment'] = $order['date_payment']->modify(' + '.($dbcfg['shop_due_days'] ?: '0').' days'); // $order->date_handle->modify("+{$dbcfg['shop_due_days']} days");//new DateTime($order->date_handle. ' + '.$dbcfg['shop_due_days'].' days');
$smarty->assign([
'order' => $order,
'dbcfg' => $dbcfg,
'cfg' => $cfg,
]);
$template_name = getVal('template');
if ($template_name == 'invoiceSimple') {
$smarty->assign([
'slovy' => PrintCenter::prepisSlovne(roundPrice($order->getRemainingPayment(), -1, 'DB', 0)),
]);
}
$template = 'printCenter/'.$template_name.'.tpl';
if ($smarty->templateExists($template)) {
$smarty->display($template);
} else {
$smarty->display('printCenter/invoiceForeign.tpl');
}
switchLanguage(null, true);
loadLanguage('printOrder', null);

View File

@@ -0,0 +1,50 @@
<?php
use KupShop\GraphQLBundle\ApiShared\Types\DateInterval;
use KupShop\POSBundle\Util\PosEntity;
class DatabaseCommunicationClass
{
use DatabaseCommunication;
}
$smarty = createSmarty(false, true);
$start_date = getVal('date_from');
$end_date = getVal('date_to');
$idPos = getVal('idPos');
if ($idPos) {
$posEntity = new PosEntity();
$posEntity->createFromDB($idPos)->activateContexts();
$posAppStats = new \KupShop\POSBundle\Util\PosAppStats();
$posAppStats->setPosEntity($posEntity);
$interval = null;
if ($start_date && $end_date) {
$interval = new DateInterval(new DateTime($start_date), new DateTime($end_date));
$vars['now_time'] = (new \DateTime($end_date))
->setTime(18, 0)
->format('Y-m-d H:i:s');
}
$posAppStats->setDatetimeInterval($interval);
$posAppStats->fetchStats();
if (findModule(Modules::SKEET)) {
$vars['paid_by_the_invoice_cash'] = $posAppStats->getPaidOfTheInvoiceCash();
$vars['paid_by_the_invoice_card'] = $posAppStats->getPaidOfTheInvoiceCard();
}
$vars['stats'] = $posAppStats->getStats();
$vars['actually_in_pos'] = $posAppStats->getActualCashInPos();
$vars['today_sales'] = $posAppStats->getSales();
$vars['discounts'] = $posAppStats->getDiscounts();
$vars['roundings'] = $posAppStats->getRounding();
}
$dcc = new DatabaseCommunicationClass();
if (!isset($vars['now_time'])) {
$vars['now_time'] = getVal('date_to') ? $dcc->prepareDate(str_replace('.', '-', getVal('date_to'))).' 18:00:00' : date('Y-m-d H:i:s', time());
}
$smarty->assign($vars);
$smarty->display('printCenter/NewPOSClosure.tpl');

View File

@@ -0,0 +1,23 @@
<?php
class printCenterOrders extends Base
{
private $pageVars;
protected $template = 'massOrderViewprintPickingList.tpl';
public function __construct($pageVars)
{
$this->pageVars = $pageVars;
}
public function get_vars()
{
return array_merge($this->pageVars, parent::get_vars());
}
public function init_smarty()
{
$this->smarty = createSmarty(false, true);
}
}

View File

@@ -0,0 +1,32 @@
<?php
$smarty = createSmarty(true, true);
if (empty($ID_ITEM)) {
$ID_ITEM = getVal('ID');
}
global $adminName;
$order = new Order($ID_ITEM);
$order->createFromDB($ID_ITEM);
$order->fetchItems();
if (!empty($order->admin)) {
$adminName = returnSQLResult('SELECT login FROM admins WHERE id=:id', ['id' => $order->admin]);
}
$smarty->assign([
'order' => $order,
'adminName' => $adminName,
]);
$template_name = getVal('template');
$template = 'printCenter/'.$template_name.'.tpl';
if ($smarty->templateExists($template)) {
$smarty->display($template);
} else {
$smarty->display('printCenter/invoiceForeign.tpl');
}

View File

@@ -0,0 +1,42 @@
<?php
class DatabaseCommunicationClass
{
use DatabaseCommunication;
}
$smarty = createSmarty(true, true);
$start_date = getVal('date_from', null, date('d.m.Y', time()));
$end_date = getVal('date_to');
$Pos = new \Pos();
$specific_pos = getVal('specific_pos');
if ($specific_pos) {
$Pos->setSpecificPos($specific_pos);
$vars['admin_name'] = returnSQLResult('SELECT login FROM admins WHERE id=:id', ['id' => $specific_pos]);
} else {
global $adminName;
if (!empty($adminName)) {
$vars['admin_name'] = 'Nedefinováno';
}
}
$Pos->setStartDatetime($start_date.' '.date(Settings::getTimeFormat(), mktime(0, 0, 0)));
$Pos->setEndDatetime($end_date.' '.date(Settings::getTimeFormat(), mktime(23, 59, 59)));
$vars['stats'] = $Pos->getPayments();
$vars['actually_in_pos'] = $Pos->getActuallyCashInPOS();
$vars['today_sales'] = $Pos->getSales();
$vars['discounts'] = $Pos->getDiscounts();
$vars['now_time'] = getVal('date_to') ? prepareDate(str_replace('.', '-', getVal('date_to'))).' 18:00:00' : date('Y-m-d H:i:s', time());
$smarty->assign($vars);
$smarty->display('printCenter/POSClosure.tpl');

View File

@@ -0,0 +1,21 @@
<?php
// ##############################################################
if (!empty($TYPE) && !empty($ID_ITEM)) {
?>
<style type="text/css" media="all">
@media print {
@page {
margin: 2.5cm;
}
}
</style>
<?php
$class_order = new Orders($ID_ITEM, 'admin');
$html = $class_order->getOrder();
echo $html;
}
// ################################################
?>

View File

@@ -0,0 +1,78 @@
<?php
use KupShop\KupShopBundle\Util\Compat\ServiceContainer;
class PrintCenterProducts extends Base
{
use DatabaseCommunication;
private $pageVars;
public function __construct($pageVars)
{
$this->pageVars = $pageVars;
}
public function get_vars()
{
$vars = parent::get_vars();
$vars = array_merge($this->pageVars, $vars);
$printLabels = ServiceContainer::getService(\KupShop\AdminBundle\AdminRegister\ProductsPrintLabelsLocator::class);
$generic = [];
foreach ($printLabels->getPrintClasses() as $class) {
$generic[$class->getLabel()] = $class->getDimensions();
}
if (!($printClass = $printLabels->getPrintClass($vars['template_type']))) {
$printClasses = $printLabels->getPrintClasses();
$printClass = reset($printClasses);
$vars['template_type'] = $printClass->getLabel();
}
$this->setTemplate($printClass->getTemplate());
$vars['count_rows'] = $generic[$vars['template_type']][1];
$vars['count_columns'] = $generic[$vars['template_type']][0];
$IDs = [];
if ($IDo = getVal('IDo')) {
$IDs = sqlFetchAll(sqlQuery('SELECT id_product AS idp, id_variation AS idv, pieces AS pcs FROM order_items WHERE id_order=:id', ['id' => $IDo]));
} elseif (getVal('ID')) {
$qb = sqlQueryBuilder()->select('p.id AS idp ,pv.id AS idv')
->from('products', 'p')
->leftJoin('p', 'products_variations', 'pv', 'pv.id_product=p.id')
->where(\Query\Operator::equals(['p.id' => getVal('ID')]));
if (getVal('IDv')) {
$qb->andWhere(\Query\Operator::equals(['pv.id' => getVal('IDv')]));
}
$IDs = $qb->execute()->fetchAll();
} elseif ($json = getVal('json', null, getVal('JSON_IDs'))) {
// Když to přijde z GET parametrů, hodí se to zrovna do pole.
$vars['json'] = is_string($json) ? json_decode($json, true) : $json;
foreach ($vars['json'] as $item) {
if ($item['idp'] ?? false || $item['idv'] ?? false) {
$qb = sqlQueryBuilder()->select('p.id AS idp')
->from('products', 'p');
if ($item['idv'] ?? false) {
$qb->addSelect('pv.id AS idv')
->leftJoin('p', 'products_variations', 'pv', 'pv.id_product=p.id')
->where(\Query\Operator::equals(['pv.id' => $item['idv']]));
} else {
$qb->where(\Query\Operator::equals(['p.id' => $item['idp']]));
}
foreach ($qb->execute()->fetchAll() as $product) {
$IDs[] = ['idp' => $product['idp'], 'idv' => $product['idv'] ?? null, 'pcs' => getVal('pcs', $item, 1)];
}
}
}
}
if (isset($IDs)) {
$vars['products'] = $printClass->getData($IDs, $vars);
} else {
echo 'Nebyl vybrán žádný produkt!';
}
return $vars;
}
}

View File

@@ -0,0 +1,64 @@
<?php
use KupShop\KupShopBundle\Util\Compat\ServiceContainer;
use KupShop\ReclamationsBundle\Util\ReclamationsUtil;
class PrintCenterReclamations extends Base
{
protected $template = 'printCenter/reclamations_zebra.tpl';
protected function get_vars()
{
$vars = parent::get_vars();
/** @var ReclamationsUtil $reclamations */
$reclamations = ServiceContainer::getService(ReclamationsUtil::class);
if ($ID = getVal('ID')) {
$reclamation = $reclamations->getReclamation($ID);
$vars['reclamation'] = $reclamation;
$boughtDate = sqlQueryBuilder()
->select('COALESCE(o.date_handle, o.date_created) as date')
->from('order_items', 'oi')
->join('oi', 'orders', 'o', 'o.id = oi.id_order')
->where(\Query\Operator::equals(['oi.id' => $reclamation->getIdItem()]))
->execute()->fetchColumn();
$vars['boughtDate'] = new DateTime($boughtDate);
$productEan = $reclamation->getItem()['ean'] ?? false;
if (findModule(Modules::PRODUCTS_SUPPLIERS) && $productEan) {
$vars['product_barcode_chars'] = formatEAN($productEan);
}
$item = $reclamation->getItem();
if (findModule(Modules::PRODUCTS_SUPPLIERS)) {
$suppliersCodes = sqlQueryBuilder()->select('s.id, s.name, pos.code')
->from('products_of_suppliers', 'pos')
->leftJoin('pos', 'suppliers', 's', 's.id = pos.id_supplier')
->where(\Query\Operator::equalsNullable(['id_product' => $item['id_product'], 'id_variation' => $item['id_variation']]))
->execute()->fetchAll();
$vars['suppliers_codes'] = \KupShop\KupShopBundle\Util\Functional\Mapping::mapKeys($suppliersCodes, function ($k, $v) {
return [$v['id'], $v];
});
}
if (findModule(\Modules::PRODUCTS_SERIAL_NUMBERS)) {
$serialNumber = sqlQueryBuilder()
->select('psn.serial_number')
->from('products_serial_numbers', 'psn')
->where(\Query\Operator::equalsNullable(['psn.id_product' => $item['id_product'], 'psn.id_variation' => $item['id_variation'], 'psn.id_order_item' => $item['id']]))
->execute()->fetchOne();
$vars['serial_number'] = $serialNumber;
}
}
return $vars;
}
}
(new PrintCenterReclamations())->run();

View File

@@ -0,0 +1,232 @@
<?php
// ##############################################################
if (!empty($TYPE) && !empty($ID_ITEM)) {
if (empty($_SESSION['printCenter'][$SET]['start'])) {
$_SESSION['printCenter'][$SET]['start'] = 1;
}
if (isset($_REQUEST['changeStart'])) {
$_SESSION['printCenter'][$SET]['start'] = intval($_REQUEST['changeStart']);
}
$class_order = new Orders($ID_ITEM);
$html = $class_order->getOrder(true, true);
$order = $class_order->getOrderValues();
// ------------------------------------------------------
$cena = roundPrice($order['total_price']);
$dobirka = '='.number_format($cena, 2, ',', '').'=';
// PROVIDER
$odesilatel_firma = $GLOBALS['dbcfg']['shop_firm_name'];
$odesilatel = $GLOBALS['dbcfg']['shop_address'];
// DORUCOVACI UDAJE
$prijemce[0] = $order['delivery_name'].' '.$order['delivery_surname'];
if (!empty($order['delivery_name'])) {
$prijemce[] = "\t".$order['delivery_firm'];
}
if (!empty($order['delivery_street'])) {
$prijemce[] = $order['delivery_street'];
}
if (!empty($order['delivery_city'])) {
$prijemce[] = $order['delivery_city'];
}
if (!empty($order['delivery_zip'])) {
$prijemce[] = $order['delivery_zip'];
}
// if(!empty($order['delivery_country']))
// $prijemce[] = $order['delivery_country'];
$cena = roundPrice($order['total_price']);
$cena_format = showPrice($order['total_price'], 0, 0, true, true, true);
$cena_slova = ucfirst($this->prepisSlovne(number_format($cena, 0, '', ''))); ?>
<div class="printHidden">
<form method="post" action="launch.php?s=printCenter.php&type=<?php echo $TYPE; ?>&ID=<?php echo $ID_ITEM; ?>&set=<?php echo $SET; ?>">
<select name="changeStart">
<?php
for ($x = 1; $x <= 6; $x++) {
echo '<option value="'.$x.'"'.checkSelect($_SESSION['printCenter'][$SET]['start'] + 1, $x).'>'.htmlspecialchars($x).'</option>';
} ?>
</select>
<input class="button" type="submit" value="Posunout tištěnou řádku"/>
</form>
</div>
<?php
$no = $_SESSION['printCenter'][$SET]['start'];
$posTop = (($no - 1) * 16.6);
// if($no > 1) $posTop += 1;
$posTopMM = (($no - 1) * 47);
unset($no); ?>
<style type="text/css" media="all">
BODY {
margin: 0;
padding: 0;
}
#Stitky_2x6 {
width: 817px;
height: 1175px;
margin-top: 16px;
position: relative;
border: 1px solid #DDD;
}
#s2x6_1, #s2x6_2 {
position: absolute;
overflow: hidden;
top: <?php echo $posTop; ?>%;
width: 405px;
height: 185px;
}
#s2x6_1 {
left: 0px;
border-right: 1px solid #DDD;
}
#s2x6_2 {
left: 410px;
}
.kolonka {
background-color: transparent;
border: 0;
text-align: left;
margin: 0;
}
.odesilatel_1 {
font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
overflow: hidden;
width: 365px;
margin: 20 20px 0 20px;
}
.prijemce_1 {
font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
overflow: hidden;
width: 365px;
margin: 20 20px 0 20px;
}
.prijemce_2,
.odesilatel_2 {
font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
overflow: hidden;
width: 365px;
height: 150px;
margin: 5px 20px 20px 20px;
}
.vel_pismo1 {
font-size: 14px
}
.vel_pismo2 {
font-size: 20px
}
.vel_pismo3 {
font-size: 17px
}
@media print {
@page {
margin: 0cm;
padding: 0cm;
page-break-after: avoid;
}
BODY {
margin: 0;
padding: 0;
background-color: white;
}
#Stitky_2x6 {
background: white;
border: 0;
width: auto;
height: auto;
page-break-inside: avoid;
margin-top: 8mm;
}
#Stitky_2x6 DIV {
border: 0;
page-break-after: avoid;
}
#s2x6_1, #s2x6_2 {
top: <?php echo $posTopMM; ?>mm;
width: 105mm;
height: 48mm;
}
#s2x6_1 {
left: 0mm;
border-right: 0;
}
#s2x6_2 {
left: 105mm;
}
.odesilatel_1 {
margin: 5mm 5mm 0 5mm;
width: 95mm;
}
.prijemce_1 {
margin: 8mm 5mm 0 5mm;
width: 95mm;
}
.odesilatel_2, .prijemce_2 {
margin: 1mm 5mm 5mm 5mm;
width: 95mm;
height: 43mm;
}
}
</style>
<div id="Stitky_2x6">
<div id="s2x6_1">
<input class="kolonka odesilatel_1 vel_pismo2" type="text" name="textfield" maxlength=""
value="<?php echo htmlspecialchars($odesilatel_firma); ?>"/>
<textarea class="kolonka odesilatel_2 vel_pismo1" wrap="hard"><?php
echo htmlspecialchars($odesilatel);
echo "\n";
echo "\n";
echo "Dobírka:\t".$cena_format;
echo "\n";
echo "Slovy:\t".wordwrap($cena_slova, 35, "\n\t", 1);
echo "\n";
echo "Cena:\t".$cena_format; ?></textarea>
</div>
<div id="s2x6_2">
<input class="kolonka prijemce_1 vel_pismo2" type="text" name="textfield" maxlength=""
value="<?php echo htmlspecialchars($prijemce[0]); ?>"/>
<textarea class="kolonka prijemce_2 vel_pismo3" wrap="hard"><?php
for ($x = 1; $x < count($prijemce); $x++) {
echo $prijemce[$x]."\n";
} ?></textarea>
</div>
</div>
<?php
}
// ################################################
?>

View File

@@ -0,0 +1,17 @@
<?php
$smarty = createSmarty(true, true);
$order = new Order();
$order->createFromDB($ID_ITEM);
$order->fetchItems();
$smarty->assign([
'order' => $order,
]);
ob_clean();
$smarty->display('printCenter/cash_receipt.tpl');
exit;

View File

@@ -0,0 +1,27 @@
<?php
// ##############################################################
if (!empty($TYPE) && !empty($ID_ITEM)) {
?>
<style type="text/css" media="print">
@page {
margin: 2.5cm;
}
</style>
<?php
increaseMemoryLimit(500);
$class_order = new Orders($ID_ITEM);
// Hack to differentiate when printing from admin
$_GET['from_admin'] = 1;
$html = $class_order->getOrder();
echo $html;
}
// ################################################
?>

View File

@@ -0,0 +1,23 @@
<?php
// ##############################################################
if (!empty($TYPE) && !empty($ID_ITEM)) {
?>
<style type="text/css" media="print">
@page {
margin: 2.5cm;
}
</style>
<?php
$smarty = createSmarty(true, true);
$smarty->assign(['cfg' => $GLOBALS['cfg'], 'dbcfg' => $GLOBALS['dbcfg'], 'ctrl' => $GLOBALS['ctrl']]);
$order = new Order();
$order->createFromDB($ID_ITEM, true, true, true);
$smarty->assign('order', $order);
echo $smarty->fetch('email/orderShopkeeper.tpl');
}
// ################################################
?>

View File

@@ -0,0 +1,54 @@
<?php
use KupShop\KupShopBundle\Util\Compat\ServiceContainer;
class PrintCenterWarehousePositions extends Base
{
use DatabaseCommunication;
private $pageVars;
public function __construct($pageVars)
{
$this->pageVars = $pageVars;
}
public function get_vars()
{
$vars = parent::get_vars();
$vars = array_merge($this->pageVars, $vars);
$printLabels = ServiceContainer::getService(\KupShop\AdminBundle\AdminRegister\WarehousePositionsPrintLabelsLocator::class);
$generic = [];
foreach ($printLabels->getPrintClasses() as $class) {
$generic[$class->getLabel()] = $class->getDimensions();
}
if (!($printClass = $printLabels->getPrintClass($vars['template_type']))) {
$printClasses = $printLabels->getPrintClasses();
$printClass = reset($printClasses);
}
$this->setTemplate($printClass->getTemplate());
$vars['count_rows'] = $generic[$vars['template_type']][1];
$vars['count_columns'] = $generic[$vars['template_type']][0];
$qb = sqlQueryBuilder()->select('*')
->from('warehouse_positions', 'wp');
$positions = getVal('positions');
if ($positions) {
$qb->andWhere(\Query\Operator::inIntArray($positions, 'id'));
}
$location = getVal('location');
if ($location) {
$qb->andWhere(\Query\Operator::equals(['id_location' => $location]));
}
$vars['positions'] = $qb->execute();
$vars['positionsArrow'] = getVal('arrows');
$vars['positionsBarcode'] = getVal('barcode_position');
return $vars;
}
}