| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218 |
- <?php
- class admin_utils {
- static function dbconnect() {
- global $config;
- global $conn;
- $conn = mysqli_connect($config['db_host'],$config['db_username'],$config['db_password'],$config['db_name']);
- mysqli_query($conn,"SET NAMES utf8");
- mysqli_set_charset($conn, 'utf8mb4');
- return true;
- }
- static function getText($id, $field) {
- self::dbconnect();
- global $conn;
- $res = mysqli_query($conn,"SELECT * FROM azonics_text_pages WHERE page_id='".$id."';");
- if (mysqli_num_rows($res)>0) {
- $row = mysqli_fetch_array($res);
- $text = $row[$field];
- $text = str_replace("<div>","",$text);
- $text = str_replace("</div>","",$text);
- $text = str_replace("<p>","",$text);
- $text = str_replace("</p>","",$text);
- $text = str_replace("<span>","",$text);
- $text = str_replace("</span>","",$text);
- return $text;
- }
- else {
- return 'No data available';
- }
- }
-
- static function getAdminName() {
- return $_SESSION['admin_user']->admin_real_name;
- }
-
-
- static function getAdminAccessLevels($selected='') {
- self::dbconnect();
- global $conn;
-
- $result = mysqli_query($conn,"select * from azonics_roles where role_status='1' order by role_name asc;");
-
- $temp = '<option value="">'.lang::_('Please select admin user access level...').'</option>';
-
- if (mysqli_num_rows($result)>0) {
- while ($row = mysqli_fetch_array($result)) {
- if ($_SESSION['access_level'] == 11) {
- if ($selected==$row['role_id']) {
- $temp.= '<option value="'.$row['role_id'].'" selected>'.$row['role_name'].'</option>';
- }
- else {
- $temp.= '<option value="'.$row['role_id'].'">'.$row['role_name'].'</option>';
- }
- }
- else if ($_SESSION['access_level'] == 13) {
- if ($row['role_id'] == 14) {
- $temp.= '<option value="'.$row['role_id'].'" selected>'.$row['role_name'].'</option>';
- }
- }
- }
- }
- else {
- $temp.= '<option value="">'.lang::_('Actually no active role group...').'</option>';
- }
-
- return $temp;
- }
-
- static function getUserTypes($selected='') {
- self::dbconnect();
- global $conn;
- $result = mysqli_query($conn,"select * from azonics_user_types where user_type_status='1' order by user_type_name asc;");
-
- $temp = '<option value="">'.lang::_('Please select user type...').'</option>';
-
- if (mysqli_num_rows($result)>0) {
- while ($row = mysqli_fetch_array($result)) {
- if ($selected==$row['user_type_id']) {
- $temp.= '<option value="'.$row['user_type_id'].'" selected>'.$row['user_type_name'].'</option>';
- }
- else {
- $temp.= '<option value="'.$row['user_type_id'].'">'.$row['user_type_name'].'</option>';
- }
- }
- }
- else {
- $temp.= '<option value="">'.lang::_('Actually no active user type...').'</option>';
- }
-
- return $temp;
- }
-
-
- static function getUserTypeName($type='') {
- self::dbconnect();
- global $conn;
- if ($type!='') {
- $result = mysqli_query($conn,"select * from azonics_user_types where user_type_id='".$type."';");
- if (mysqli_num_rows($result)>0) {
- $row = mysqli_fetch_array($result);
- return '<span class="'.$row['user_type_color'].'">'.$row['user_type_name'].'</span>';
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
-
-
- static function getUserState($user_id='') {
- self::dbconnect();
- global $conn;
- if ($user_id!='') {
- $result = mysqli_query($conn,"select * from users where id='".$user_id."';");
- if (mysqli_num_rows($result)>0) {
- $row = mysqli_fetch_array($result);
- if ($row['status']=='1') {
- return ' checked';
- }
- else {
- return '';
- }
- }
- else {
- return '';
- }
- }
- else {
- return '';
- }
- }
- static function getUserName($user_id='') {
- self::dbconnect();
- global $conn;
- if ($user_id!='') {
- $result = mysqli_query($conn,"select * from azonics_users where user_id='".$user_id."';");
- if (mysqli_num_rows($result)>0) {
- $row = mysqli_fetch_array($result);
- return $row['user_first_name']." ".$row['user_last_name'];
- }
- else {
- return '';
- }
- }
- else {
- return '';
- }
- }
-
-
- static function getUserDefaultMailerState($user_id='') {
- self::dbconnect();
- global $conn;
- if ($user_id!='') {
- $result = mysqli_query($conn,"select * from azonics_users where user_id='".$user_id."';");
- if (mysqli_num_rows($result)>0) {
- $row = mysqli_fetch_array($result);
- if ($row['user_default_mailer_status']=='1') {
- return ' checked';
- }
- else {
- return '';
- }
- }
- else {
- return '';
- }
- }
- else {
- return '';
- }
- }
-
-
- static function checkAdminAccessToModule($module='') {
- self::dbconnect();
- global $conn;
- if ($module!='') {
- $result = mysqli_query($conn,"select * from azonics_modules_role where "
- . "modrole_role_id='".$_SESSION['admin_user']->admin_access_level."' and "
- . "modrole_module_id='".$module."' and "
- . "modrole_status='1';");
-
- if (mysqli_num_rows($result)>0) {
- return true;
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
-
-
- static function getMenu($parent=0) {
- self::dbconnect();
- global $conn;
- $result = mysqli_query($conn,"select * from azonics_modules where module_status='1' and module_display_parent='".$parent."' order by display_order asc;") or die(mysql_error());
-
- $resultObjects = null;
-
- if (mysqli_num_rows($result)>0) {
- while($row = mysqli_fetch_object($result)) {
- if (self::checkAdminAccessToModule($row->module_id)) {
- $resultObjects[] = $row;
- }
- }
- return $resultObjects;
- }
- else {
- return $resultObjects;
- }
- }
-
- static function checkMenuActive($slug='') {
- if (stristr($_SERVER['REQUEST_URI'],$slug)) {
- return ' active';
- }
- else {
- return '';
- }
- }
-
-
- static function checkSubmenuActive($moduleID='') {
- self::dbconnect();
- global $conn;
- $temp = explode('/',$_SERVER['REQUEST_URI']);
- $slug = $temp[2];
- $res_check = mysqli_query($conn,"select * from azonics_modules where module_controller='".$slug."' and module_status='1';");
- if (mysqli_num_rows($res_check)>0) {
- $row_check = mysqli_fetch_array($res_check);
- if ($row_check['module_display_parent']==$moduleID) {
- return ' active';
- }
- else {
- return '';
- }
- }
- else {
- return '';
- }
- }
-
-
- static function reloadAccount() {
- self::dbconnect();
- global $conn;
- if ($_SESSION['admin_user']->admin_id!='') {
- $res = mysqli_query($conn,"select * from azonics_admin_users where admin_id='".$_SESSION['admin_user']->admin_id."';");
- if (mysqli_num_rows($res)>0) {
- $_SESSION['admin_user'] = mysqli_fetch_object($res);
- return true;
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
-
-
- static function isLanguageModuleEnabled($admin_id='') {
- self::dbconnect();
- global $conn;
- if ($admin_id!='') {
- $res_module_access = mysqli_query($conn,"select * from "
- . "azonics_modules, "
- . "azonics_modules_role, "
- . "azonics_admin_users where "
- . "module_controller='translator' and "
- . "module_status='1' and "
- . "admin_id='".$admin_id."' and "
- . "admin_status<>'0' and "
- . "modrole_role_id=admin_access_level and "
- . "modrole_module_id=module_id and "
- . "modrole_status='1';");
- if (mysqli_num_rows($res_module_access)>0) {
- return true;
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
-
-
- static function loadSystemSettings() {
- self::dbconnect();
- global $conn;
- $res = mysqli_query($conn,"select * from azonics_settings where setting_status='1';");
- if (mysqli_num_rows($res)>0) {
- while ($row = mysqli_fetch_object($res)) {
- $hash = $row->setting_name;
- $data[$hash] = $row;
- }
- return $data;
- }
- else {
- return false;
- }
- }
-
- static function getSystemParam($paramName='') {
- self::dbconnect();
- global $conn;
- $res = mysqli_query($conn,"select * from azonics_settings where setting_name='".$paramName."';");
- if (mysqli_num_rows($res)>0) {
- $row = mysqli_fetch_object($res);
- if ($_SESSION['admin_lang'] == 'hu') {
- return $row->setting_value_text;
- }
- else {
- return $row->setting_value_text;
- }
- }
- else {
- return false;
- }
- }
- static function getAccessLevelName($level_id='') {
- self::dbconnect();
- global $conn;
- if ($level_id!='') {
- $res = mysqli_query($conn,"select * from azonics_roles where role_id='".$level_id."';");
- if (mysqli_num_rows($res)>0) {
- $row = mysqli_fetch_array($res);
- return '<span class="'.$row['role_color'].'">'.$row['role_name'].'</span>';
- }
- else {
- return '';
- }
- }
- else {
- return '';
- }
- }
-
-
- static function checkForUpdates() {
- global $config;
- $update_xml_file = file_get_contents('http://updates.kreatio.hu/updates.php?key='.$config['licence_key']);
- $update_xml = file_get_contents($update_xml_file);
-
- if ($update_xml!='') {
- $dom = simplexml_load_string($update_xml);
- $ftp = ftp_connect('ftp.kreatio.hu');
- $login = ftp_login($ftp,'updates@kreatio.hu','zTaD[fIGpgCI');
- foreach ($dom->file as $file) {
- ftp_get($ftp,$file['path'],$file['path'],FTP_ASCII);
- }
- return $dom->message;
- }
- else {
- return '';
- }
- }
-
-
- static function getSiteName($default='') {
- self::dbconnect();
- global $conn;
- $res = mysqli_query($conn,"select * from azonics_settings where setting_name='SITENAME' and setting_status='1';");
- if (mysqli_num_rows($res)>0) {
- $row = mysqli_fetch_array($res);
- return $row['setting_value_text'];
- }
- else {
- return $default;
- }
- }
-
- static function getPageName() {
- self::dbconnect();
- global $conn;
- $res = mysqli_query($conn,"select * from azonics_settings where setting_name='PAGENAME' and setting_status='1';");
- if (mysqli_num_rows($res)>0) {
- $row = mysqli_fetch_array($res);
- return $row['setting_value_text'];
- }
- else {
- return '';
- }
- }
-
-
- static function getBaseColorScheme($default='') {
- self::dbconnect();
- global $conn;
- $res = mysqli_query($conn,"select * from azonics_settings where setting_name='COLOR' and setting_status='1';");
- if (mysqli_num_rows($res)>0) {
- $row = mysqli_fetch_array($res);
- return $row['setting_value_text'];
- }
- else {
- return $default;
- }
- }
-
-
- static function getSlogan($default='') {
- self::dbconnect();
- global $conn;
- $res = mysqli_query($conn,"select * from azonics_settings where setting_name='SLOGAN' and setting_status='1';");
- if (mysqli_num_rows($res)>0) {
- $row = mysqli_fetch_array($res);
- return $row['setting_value_text'];
- }
- else {
- return $default;
- }
- }
-
-
- static function userComboBox($sel='') {
- self::dbconnect();
- global $conn;
- $res = mysqli_query($conn,"select * from azonics_users where user_status<>'0' order by user_nick asc;");
-
- $result = '<option value="">'.lang::_('Choose user').'</option>';
-
- if (mysqli_num_rows($res)>0) {
- while ($row = mysqli_fetch_array($res)) {
- if ($sel==$row['user_id']) {
- $result.= '<option value="'.$row['user_id'].'" selected>'.$row['user_nick'].' ('.$row['user_first_name'].' '.$row['user_last_name'].')</option>';
- }
- else {
- $result.= '<option value="'.$row['user_id'].'">'.$row['user_nick'].' ('.$row['user_first_name'].' '.$row['user_last_name'].')</option>';
- }
- }
- }
-
- return $result;
- }
-
-
- static function getUserNameByID($user_id='') {
- self::dbconnect();
- global $conn;
- $user_id = mysql_real_escape_string($user_id);
- $res = mysqli_query($conn,"select * from azonics_users where user_id='".$user_id."';");
- if (mysqli_num_rows($res)>0) {
- $row = mysqli_fetch_array($res);
- return $row['user_first_name'].' '.$row['user_last_name'].' ('.$row['user_nick'].')';
- }
- else {
- return false;
- }
- }
-
-
- static function categoryComboBox($sel='') {
- self::dbconnect();
- global $conn;
- $res = mysqli_query($conn,"select * from azonics_categories where category_status<>'0' order by category_name asc;");
-
- $result = '<option value="">'.lang::_('Choose category').'</option>';
-
- if (mysqli_num_rows($res)>0) {
- while ($row = mysqli_fetch_array($res)) {
- if ($sel==$row['category_id']) {
- $result.= '<option value="'.$row['category_id'].'" selected>'.$row['category_name'].'</option>';
- }
- else {
- $result.= '<option value="'.$row['category_id'].'">'.$row['category_name'].'</option>';
- }
- }
- }
-
- return $result;
- }
-
-
- static function getProfileCategory($id='') {
- self::dbconnect();
- global $conn;
- if ($id!='') {
- $res = mysqli_query($conn,"select * from azonics_categories where category_id='".$id."';");
- $row = mysqli_fetch_array($res);
- return $row['category_name'];
- }
- else {
- return false;
- }
- }
-
-
- static function getProductStatus($status='',$pid='') {
- if ($status=='1') {
- return '<div class="btn-group">'
- . '<button type="button" class="btn btn-success">'.lang::_('Active').'</button>'
- . '<button aria-expanded="false" type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown">'
- . '<span class="caret"></span>'
- . '<span class="sr-only">Toggle Dropdown</span>'
- . '</button>'
- . '<ul class="dropdown-menu" role="menu">'
- . '<li><a href="/admin/products/set/?status=3&id='.$pid.'">'.lang::_('Set inactive').'</a></li>'
- . '<li><a href="/admin/products/delete/?id='.$pid.'">'.lang::_('Delete').'</a></li>'
- . '</ul>'
- . '</div>';
- }
- else if ($status=='3') {
- return '<div class="btn-group">'
- . '<button type="button" class="btn btn-default">'.lang::_('Inactive').'</button>'
- . '<button aria-expanded="false" type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">'
- . '<span class="caret"></span>'
- . '<span class="sr-only">Toggle Dropdown</span>'
- . '</button>'
- . '<ul class="dropdown-menu" role="menu">'
- . '<li><a href="/admin/products/set/?status=1&id='.$pid.'">'.lang::_('Set active').'</a></li>'
- . '<li><a href="/admin/products/delete/?id='.$pid.'">'.lang::_('Delete').'</a></li>'
- . '</ul>'
- . '</div>';
- }
- }
-
-
- static function getProfileStatus($status='',$pid='') {
- if ($status=='1') {
- return '<div class="btn-group">'
- . '<button type="button" class="btn btn-xs btn-success">'.lang::_('Active').'</button>'
- . '<button aria-expanded="false" type="button" class="btn btn-success btn-xs dropdown-toggle" data-toggle="dropdown">'
- . '<span class="caret"></span>'
- . '<span class="sr-only">Toggle Dropdown</span>'
- . '</button>'
- . '<ul class="dropdown-menu" role="menu">'
- . '<li><a href="/admin/profiles/set/?status=2&id='.$pid.'">'.lang::_('Set inactive').'</a></li>'
- . '<li><a href="/admin/profiles/delete/?id='.$pid.'">'.lang::_('Delete').'</a></li>'
- . '</ul>'
- . '</div>';
- }
- else if ($status=='2') {
- return '<div class="btn-group">'
- . '<button type="button" class="btn btn-xs btn-default">'.lang::_('Inactive').'</button>'
- . '<button aria-expanded="false" type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">'
- . '<span class="caret"></span>'
- . '<span class="sr-only">Toggle Dropdown</span>'
- . '</button>'
- . '<ul class="dropdown-menu" role="menu">'
- . '<li><a href="/admin/profiles/set/?status=1&id='.$pid.'">'.lang::_('Set active').'</a></li>'
- . '<li><a href="/admin/profiles/delete/?id='.$pid.'">'.lang::_('Delete').'</a></li>'
- . '</ul>'
- . '</div>';
- }
- else if ($status=='3') {
- return '<div class="btn-group">'
- . '<button type="button" class="btn btn-xs btn-info">'.lang::_('Waiting').'</button>'
- . '<button aria-expanded="false" type="button" class="btn btn-info btn-xs dropdown-toggle" data-toggle="dropdown">'
- . '<span class="caret"></span>'
- . '<span class="sr-only">Toggle Dropdown</span>'
- . '</button>'
- . '<ul class="dropdown-menu" role="menu">'
- . '<li><a href="/admin/profiles/set/?status=1&id='.$pid.'">'.lang::_('Enable').'</a></li>'
- . '<li><a href="/admin/profiles/delete/?id='.$pid.'">'.lang::_('Delete').'</a></li>'
- . '</ul>'
- . '</div>';
- }
- }
-
-
- static function getMainImage($pid) {
- self::dbconnect();
- global $conn;
-
- $res2 = mysqli_query($conn,"select * from azonics_galeries where "
- . "galery_design_id='".$pid."' and "
- . "galery_status='1' and galery_main_image='1';");
- if (mysqli_num_rows($res2)>0) {
- $row2 = mysqli_fetch_array($res2);
- return '<img src="'.BASE_URL.$row2['galery_image'].'" alt="Image" />';
- }
- else {
- return '<img src="http://placehold.it/500x500" alt="Image" />';
- }
- }
-
-
- static function battleTypesOptions($sel='') {
- self::dbconnect();
- global $conn;
- $res_bt = mysqli_query($conn,"select * from azonics_battle_types where "
- . "battle_type_status='1' "
- . "order by battle_type_name asc;");
-
- $temp = '<option value="">Choose battle type</option>';
-
- if (mysqli_num_rows($res_bt)>0) {
- while ($row_bt = mysqli_fetch_array($res_bt)) {
- if ($sel==$row_bt['battle_type_id']) {
- $temp.= '<option value="'.$row_bt['battle_type_id'].'" selected>'.$row_bt['battle_type_name'].'</option>';
- }
- else {
- $temp.= '<option value="'.$row_bt['battle_type_id'].'">'.$row_bt['battle_type_name'].'</option>';
- }
- }
- }
-
- return $temp;
- }
-
-
- static function battleAwardsOptions($sel='') {
- self::dbconnect();
- global $conn;
- $res_bw = mysqli_query($conn,"select * from azonics_awards where "
- . "award_status='1' "
- . "order by award_name asc;");
-
- $temp = '<option value="">Choose award</option>';
-
- if (mysqli_num_rows($res_bw)>0) {
- while ($row_bw = mysqli_fetch_array($res_bw)) {
- if ($sel==$row_bw['award_id']) {
- $temp.= '<option value="'.$row_bw['award_id'].'" selected>'.$row_bw['award_name'].'</option>';
- }
- else {
- $temp.= '<option value="'.$row_bw['award_id'].'">'.$row_bw['award_name'].'</option>';
- }
- }
- }
-
- return $temp;
- }
-
-
- static function getBattleType($type_id='') {
- self::dbconnect();
- global $conn;
- if ($type_id!='') {
- $res_type = mysqli_query($conn,"select * from azonics_battle_types where battle_type_id='".$type_id."';");
- if (mysqli_num_rows($res_type)>0) {
- $row_type = mysqli_fetch_array($res_type);
- return $row_type['battle_type_name'];
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
-
- static function getBattleAward($award_id='') {
- self::dbconnect();
- global $conn;
- if ($award_id!='') {
- $res_award = mysqli_query($conn,"select * from azonics_awards where award_id='".$award_id."';");
- if (mysqli_num_rows($res_award)>0) {
- $row_award = mysqli_fetch_array($res_award);
- return $row_award['award_name'];
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
-
-
- static function generateSlug($name='') {
- if ($name!='') {
- $text = preg_replace('~[^\\pL\d]+~u', '-', $text);
- $text = trim($text, '-');
- $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
- $text = strtolower($text);
- $text = preg_replace('~[^-\w]+~', '', $text);
-
- if (empty($text)) return time();
-
- return $text;
- }
- else {
- return time();
- }
- }
-
-
- static function getProductTags($product_category='') {
- $tags = explode(",",$product_category);
- foreach ($tags as $tag) {
- if ($tag!='') $list.= '<span class="label label-info">'.$tag.'</span> ';
- }
-
- return $list;
- }
-
-
- static function getProductMeta($product_id='') {
- self::dbconnect();
- global $conn;
- $list = '';
-
- if ($product_id!='') {
- $res = mysqli_query($conn,"select * from azonics_product_meta where "
- . "meta_pid='".$product_id."' and "
- . "meta_status='1' order by meta_date asc;");
-
- if (mysqli_num_rows($res)>0) {
- while ($row = mysqli_fetch_array($res)) {
- $list.= '<!--Metarow:'.$row['meta_id'].'-->'
- . '<tr>'
- . '<td><input type="text" name="meta_key" onblur="save_product_meta_data($(this))" value="'.$row['meta_key'].'" class="form-control" data-mid="'.$row['meta_id'].'" /></td>'
- . '<td><input type="text" name="meta_value" onblur="save_product_meta_data($(this))" value="'.$row['meta_value'].'" class="form-control" data-mid="'.$row['meta_id'].'" /></td>'
- . '<td><button type="button" name="meta_delete" class="btn btn-danger" data-mid="'.$row['meta_id'].'" data-pid="'.$row['meta_pid'].'" onclick="delete_product_meta($(this))"><i class="fa fa-trash"></i></button></td>'
- . '</tr>';
- }
- }
- }
-
- return $list;
- }
-
- static function bannerZones($selectedZone='') {
- $temp = '<option value="">'.lang::_('Choose banner zone!').'</option>';
-
- if ($selectedZone=='zone1') {
- $temp.= '<option value="zone1" selected>'.lang::_('Főoldali slider').'</option>';
- }
- else {
- $temp.= '<option value="zone1">'.lang::_('Főoldali slider').'</option>';
- }
-
- return $temp;
- }
-
-
- static function getBannerZoneName($zone_id) {
- if ($zone_id=='zone1') {
- return lang::_('Speciális kínálat');
- }
- else {
- return lang::_('Rólunk mondták');
- }
- }
-
-
- static function trim_url($url) {
- if ($url!='') {
- $url = str_replace("http://","",$url);
- }
-
- return $url;
- }
-
-
- static function add_url_prefix($url) {
- if ($url!='') {
- $url = "http://".$url;
- }
-
- return $url;
- }
-
-
- static function get_category_selector($selected) {
- self::dbconnect();
- global $conn;
- $res = mysqli_query($conn,"select * from azonics_categories where category_status='0' order by category_name asc;");
-
- $options = '';
-
- if (mysqli_num_rows($res)>0) {
- while ($row = mysqli_fetch_object($res)) {
- if ($_SESSION['category']=='') $_SESSION['category'] = $row->category_id;
-
- if ($selected==$row->category_id) {
- $options.= '<option value="'.$row->category_id.'" selected>'.$row->category_name.'</option>';
- }
- else {
- $options.= '<option value="'.$row->category_id.'">'.$row->category_name.'</option>';
- }
- }
- }
-
- if ($_SESSION['category']=='') $_SESSION['category'] = '0';
-
- $options.= '<option value="0">'.lang::_('Minden kategória').'</option>';
-
- return $options;
- }
-
-
- static function getLendingStatusByID($status_id='1',$field='ls_name') {
- self::dbconnect();
- global $conn;
- if ($status_id!='') {
- $res_item = mysqli_query($conn,"select * from mingo_lending_status where ls_id='".$status_id."';");
- $row_item = mysqli_fetch_array($res_item);
- return $row_item[$field];
- }
- else {
- return false;
- }
- }
-
-
- static function getLendingStatusCombo($selected='1',$lending_id='') {
- self::dbconnect();
- global $conn;
- $res = mysqli_query($conn,"select * from mingo_lending_status where ls_status='1' order by ls_id asc;");
- if ($selected=='') $selected='1';
-
- $result = '<div class="btn-group">';
- $result.= '<button type="button" class="btn '.self::getLendingStatusByID($selected,'ls_color').'">'.self::getLendingStatusByID($selected,'ls_name').'</button>';
- $result.= '<button aria-expanded="false" type="button" class="btn '.self::getLendingStatusByID($selected,'ls_color').' dropdown-toggle" data-toggle="dropdown">
- <span class="caret"></span>
- <span class="sr-only">Toggle Dropdown</span>
- </button>
- <ul class="dropdown-menu" role="menu">';
-
- if (mysqli_num_rows($res)>0) {
- while ($row = mysqli_fetch_array($res)) {
- $result.= '<li><a href="/admin/lendings/set/?status='.$row['ls_id'].'&lending_id='.$lending_id.'">'.$row['ls_name'].'</a></li>';
- }
- }
-
- $result.= '</ul></div>';
-
- return $result;
- }
-
-
- static function lendingStatusComboBox($selected='') {
- self::dbconnect();
- global $conn;
- $res = mysqli_query($conn,"select * from mingo_lending_status where ls_status='1' order by ls_id asc;");
- if (mysqli_num_rows($res)>0) {
- while ($row = mysqli_fetch_array($res)) {
- if ($selected==$row['ls_id']) {
- $result.= '<option value="'.$row['ls_id'].'" selected>'.$row['ls_name'].'</option>';
- }
- else {
- $result.= '<option value="'.$row['ls_id'].'">'.$row['ls_name'].'</option>';
- }
- }
- }
- else {
- $result.= '<option value="0">Nem lehet státuszt állítani!</option>';
- }
-
- return $result;
- }
-
- static function get_todos($show_all='all',$uid=0,$lending_id=0,$limit=10,$orderby='todo_date',$order='asc',$comments=false,$finished=true) {
- self::dbconnect();
- global $conn;
- if ($comments==true) {
- $comments_selector = " and todo_date<>'NULL'";
- }
- else {
- $comments_selector = '';
- }
- if ($finished==false) {
- $finish = " and todo_finished<>'1'";
- }
- else {
- $finish = "";
- }
- if ($show_all=='all') {
- $res = mysqli_query($conn,"select * from mingo_todos where todo_status='1'".$comments_selector." and todo_admin_id='".$_SESSION['admin_user']->admin_id."'".$finish." order by ".$orderby." ".$order." limit 0,".$limit.";");
- }
- elseif ($show_all=='users') {
- $res = mysqli_query($conn,"select * from mingo_todos where todo_status='1'".$comments_selector." and todo_user_id<>'0' and todo_admin_id='".$_SESSION['admin_user']->admin_id."'".$finish." order by ".$orderby." ".$order." limit 0,".$limit.";");
- }
- elseif ($show_all=='lendings') {
- $res = mysqli_query($conn,"select * from mingo_todos where todo_status='1'".$comments_selector." and todo_lending_id<>'0' and todo_admin_id='".$_SESSION['admin_user']->admin_id."'".$finish." order by ".$orderby." ".$order." limit 0,".$limit.";");
- }
- elseif ($uid>0) {
- $res = mysqli_query($conn,"select * from mingo_todos where todo_status='1'".$comments_selector." and todo_user_id='".$uid."' and todo_admin_id='".$_SESSION['admin_user']->admin_id."'".$finish." order by ".$orderby." ".$order." limit 0,".$limit.";");
- }
- elseif ($lending_id>0) {
- $res = mysqli_query($conn,"select * from mingo_todos where todo_status='1'".$comments_selector." and todo_lending_id='".$lending_id."' and todo_admin_id='".$_SESSION['admin_user']->admin_id."'".$finish." order by ".$orderby." ".$order." limit 0,".$limit.";");
- }
- if (mysqli_num_rows($res)>0) {
- while ($row = mysqli_fetch_object($res)) {
- $result[] = $row;
- }
- return $result;
- }
- else {
- return false;
- }
- }
- function get_todo_object($id) {
- self::dbconnect();
- global $conn;
- $res = mysqli_query($conn,"select * from mingo_todos where todo_id='".$id."';");
- if (mysqli_num_rows($res)>0) {
- return mysqli_fetch_object($res);
- }
- else {
- return false;
- }
- }
-
-
-
- function get_group_options($group,$selected='') {
- self::dbconnect();
- global $conn;
- $res = mysqli_query($conn,"SELECT * FROM sc_variants WHERE variant_group='".$group."' AND variant_status='1' ORDER BY variant_name ASC;");
-
- $result = '<option value="">Válasszon!</option>';
-
- if (mysqli_num_rows($res)>0) {
- while ($row = mysqli_fetch_array($res)) {
- if ($selected==$row['variant_id']) {
- $result.= '<option value="'.$row['variant_id'].'" selected>'.$row['variant_name'].'</option>';
- }
- else {
- $result.= '<option value="'.$row['variant_id'].'">'.$row['variant_name'].'</option>';
- }
- }
- }
-
- return $result;
- }
-
- function get_rajz($cikkszam='') {
- self::dbconnect();
- global $conn;
- if ($cikkszam!='') {
- $res = mysqli_query($conn,"select * from sc_rajzok where rajz_cikkszam='".$cikkszam."' and rajz_status='1';");
- if (mysqli_num_rows($res)>0) {
- $row = mysqli_fetch_array($res);
- return $row['rajz_file'];
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
-
-
- function has_rajz($cikkszam='') {
- self::dbconnect();
- global $conn;
- if ($cikkszam!='') {
- $res = mysqli_query($conn,"select * from sc_rajzok where rajz_cikkszam='".$cikkszam."' and rajz_status='1';");
- if (mysqli_num_rows($res)>0) {
- return true;
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
-
-
- function has_document($id) {
- self::dbconnect();
- global $conn;
- if ($id!='') {
- $res = mysqli_query($conn,"select * from sc_beszerzes where beszer_id='".$id."';");
- if (mysqli_num_rows($res)>0) {
- $row = mysqli_fetch_array($res);
- return $row['beszer_document'];
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
-
-
- function has_bill_image($bill_number='') {
- self::dbconnect();
- global $conn;
- if ($bill_number!='') {
- $res = mysqli_query($conn,"select * from sc_bills where bill_number='".$bill_number."' and bill_status='1';");
- if (mysqli_num_rows($res)>0) {
- return true;
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
-
-
- function get_bill_image($bill_number='') {
- self::dbconnect();
- global $conn;
- if ($bill_number!='') {
- $res = mysqli_query($conn,"select * from sc_bills where bill_number='".$bill_number."' and bill_status='1';");
- if (mysqli_num_rows($res)>0) {
- $row = mysqli_fetch_array($res);
- return $row['bill_image'];
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
-
- function check_admin_access_to_action() {
- if ($_SESSION['admin_user']->admin_access_level=='1') {
- return true;
- }
- else {
- return false;
- }
- }
-
-
- function get_modules_select($selected='') {
- self::dbconnect();
- global $conn;
- $res = mysqli_query($conn,"SELECT * FROM azonics_modules WHERE module_status='1' ORDER BY display_order ASC;");
- $result = '';
- if (mysqli_num_rows($res)>0) {
- while ($row = mysqli_fetch_array($res)) {
- if ($selected==$row['module_controller']) {
- $result.= '<option value="'.$row['module_controller'].'" selected>'.$row['module_name'].'</option>';
- }
- else {
- $result.= '<option value="'.$row['module_controller'].'">'.$row['module_name'].'</option>';
- }
- }
- }
-
- return $result;
- }
-
-
- static function get_product_data($pid) {
- self::dbconnect();
- global $conn;
- if ($pid!=='') {
- $res = mysqli_query($conn,"SELECT * FROM products_temp WHERE id='".$pid."';");
- if (mysqli_num_rows($res)>0) {
- $row = mysqli_fetch_object($res);
- $result = 'Termék név: '.$row->name.'<br>Brand: '.$row->brand.'<br>Part.no.: '.$row->part_no.'<br>Short desc.: '.$row->short_description.'<br>Price: '.$row->price.'<br>Type: '.$row->type;
- return $result;
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
-
-
- static function get_product_image($pid,$type) {
- self::dbconnect();
- global $conn;
- if ($pid!=='' && $type!=='') {
- $res = mysqli_query($conn,"SELECT * FROM products_temp WHERE id='".$pid."';");
- if (mysqli_num_rows($res)>0) {
- $row = mysqli_fetch_object($res);
- if ($row->$type!==NULL) {
- $result = '<img src="http://webshop.rackmester.hu/'.$row->$type.'" style="width: 50px;" />';
- }
- else {
- $result = ' - ';
- }
- return $result;
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
-
-
- static function get_ertekkeszlet($kategoria,$mezo) {
- self::dbconnect();
- global $conn;
- if ($kategoria!=='' && $mezo!=='') {
- $res = mysqli_query($conn,"SELECT * FROM azonics_codomains WHERE kategoria='".$kategoria."' AND mezo='".$mezo."' AND status='1' ORDER BY ertek ASC;");
- if (mysqli_num_rows($res)>0) {
- while ($row = mysqli_fetch_array($res)) {
- $result[] = $row['ertek'];
- }
- return $result;
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
-
-
- static function get_category_factor($category) {
- self::dbconnect();
- global $conn;
- if ($category!='') {
- $res = mysqli_query($conn,"SELECT * FROM azonics_category_price_factors WHERE category='".$category."' AND status='1';");
- if (mysqli_num_rows($res)>0) {
- return mysqli_fetch_object($res);
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
- static function get_velemenyek_by_agent_id($agentid) {
- self::dbconnect();
- global $conn;
- if ($agentid!='') {
- $res = mysqli_query($conn,"SELECT * FROM velemenyek WHERE agent_id='".$agentid."';");
- return mysqli_num_rows($res);
- }
- else {
- return 0;
- }
- }
-
-
- }
|