86 lines
2.7 KiB
PHP
86 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace BRSystems\Core\Cms\cmsCountToClass\inc;
|
|
|
|
use BRSystems\Core\Cms\cmsProductAttr\inc\cmsProductAttrModule;
|
|
use BRSystems\Core\Library\cDb\cDb;
|
|
|
|
class cmsCountToClassModule
|
|
{
|
|
public cDb $db;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->db = cDb::getInstance();
|
|
}
|
|
|
|
/**
|
|
* Function to get module data
|
|
*
|
|
* @param string $where - sql query
|
|
* @param string $sort - sql query
|
|
* @param int $offset - db table offset
|
|
* @param int $limitPerPage - limit per page
|
|
* @return null|array of data
|
|
* @category cmsCountToClass Module
|
|
* @author Aivars Žukovskis <keiss.mareks@gmail.com>
|
|
* @version 1.1
|
|
*/
|
|
public function getModuleRecords($where, $sort, $offset = 0, $limitPerPage = 20)
|
|
{
|
|
$sSql = "
|
|
SELECT SQL_CALC_FOUND_ROWS
|
|
cc.id as id,
|
|
cc.date,
|
|
cc.op_date,
|
|
cc.note,
|
|
mp.prod_nr as nr,
|
|
ii.prod_name,
|
|
COALESCE(tr.t_title, '') as cl1, tr.t_title,
|
|
COALESCE(tr2.t_title, '') as cl2, tr2.t_title,
|
|
COALESCE(cc.count, 0) as 'count',
|
|
ROUND(mcc.prod_incoming_price, 2) as ip,
|
|
ROUND(mcc.prod_price, 2) as p,
|
|
ROUND(cc.price_sold, 2) as pv,
|
|
cc.op_type,
|
|
CONCAT(uu.user_name, ' ', uu.user_surname) as op_user
|
|
FROM
|
|
mod_products mp
|
|
LEFT JOIN mod_products_info ii ON
|
|
mp.id = ii.prod_id
|
|
AND ii.lang_id = " . cmsProductAttrModule::LV_LANG_ID . "
|
|
LEFT JOIN mod_products_to_count_and_classificators mcc ON
|
|
mp.id = mcc.prod_id
|
|
LEFT JOIN mod_products_to_count cc ON
|
|
mp.id = cc.prod_id
|
|
AND cc.row_id = mcc.id
|
|
LEFT JOIN mod_items_attr_translations tr ON
|
|
mcc.prod_cl_id = tr.t_id
|
|
AND tr.t_lang_id = ii.lang_id
|
|
LEFT JOIN mod_items_attr_translations tr2 ON
|
|
mcc.prod_cl_id_2 = tr2.t_id
|
|
AND tr2.t_lang_id = ii.lang_id
|
|
LEFT JOIN site_users uu ON
|
|
uu.id = cc.user_id
|
|
HAVING
|
|
1 {$where}
|
|
ORDER BY
|
|
{$sort}
|
|
LIMIT {$offset}, {$limitPerPage}
|
|
";
|
|
|
|
$this->db->query($sSql);
|
|
return $this->db->getArray();
|
|
}
|
|
|
|
public function saveData($id, $data): bool
|
|
{
|
|
return $this->db->_queryUpdate('mod_products_to_count', $data, ['id' => $id]);
|
|
}
|
|
|
|
public function deleteRecords($ids): bool
|
|
{
|
|
return $this->db->_queryDelete('mod_products_to_count', ['id' => $ids]);
|
|
}
|
|
}
|