Fixed: Changed the preview image, change class names, and removed unnecessary function calls
Co-authored-by: Name <sumit201@webkul.in>
This commit is contained in:
125
classes/IdProof.php
Normal file
125
classes/IdProof.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
/**
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/license/osl-3.0-php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to support@qloapps.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this module to a newer
|
||||
* versions in the future. If you wish to customize this module for your needs
|
||||
* please refer to https://store.webkul.com/customisation-guidelines for more information.
|
||||
*
|
||||
* @author Webkul IN
|
||||
* @copyright Since 2010 Webkul
|
||||
* @license https://opensource.org/license/osl-3.0-php Open Software License version 3.0
|
||||
*/
|
||||
|
||||
class IdProofCore extends ObjectModel
|
||||
{
|
||||
public $active = 1;
|
||||
public $name;
|
||||
public $date_add;
|
||||
public $date_upd;
|
||||
|
||||
public static $definition = array(
|
||||
'table' => 'guest_reg_id_proof',
|
||||
'primary' => 'id_guest_reg_id_proof',
|
||||
'multilang' => true,
|
||||
'fields' => array(
|
||||
'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
|
||||
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
|
||||
'name' => array(
|
||||
'type' => self::TYPE_STRING,
|
||||
'lang' => true,
|
||||
'validate' => 'isCatalogName',
|
||||
'required' => true,
|
||||
'size' => 255,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* @param int|null $active 1 = active only, 0 = inactive only, null = all
|
||||
* @param int $idLang 0 falls back to current context language
|
||||
*
|
||||
* @return array|false
|
||||
*/
|
||||
public static function getRegistrationIdProofs($active = null, $idLang = 0)
|
||||
{
|
||||
if (!$idLang) {
|
||||
$idLang = (int)Context::getContext()->language->id;
|
||||
}
|
||||
|
||||
$activeCondition = ($active !== null) ? ' AND a.`active` = '.(int)$active : '';
|
||||
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(
|
||||
'SELECT a.`id_guest_reg_id_proof`, al.`name`
|
||||
FROM `'._DB_PREFIX_.'guest_reg_id_proof` a
|
||||
INNER JOIN `'._DB_PREFIX_.'guest_reg_id_proof_lang` al
|
||||
ON (a.`id_guest_reg_id_proof` = al.`id_guest_reg_id_proof`
|
||||
AND al.`id_lang` = '.(int)$idLang.')
|
||||
WHERE 1'.$activeCondition.'
|
||||
ORDER BY al.`name` ASC'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array All rows with names for every installed language, for the admin management table.
|
||||
*/
|
||||
public static function getRegistrationIdProofRows(): array
|
||||
{
|
||||
$languages = Language::getLanguages(false);
|
||||
$rows = array();
|
||||
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(
|
||||
'SELECT a.`id_guest_reg_id_proof`, a.`active`, a.`date_add`, al.`id_lang`, al.`name`
|
||||
FROM `'._DB_PREFIX_.'guest_reg_id_proof` a
|
||||
LEFT JOIN `'._DB_PREFIX_.'guest_reg_id_proof_lang` al
|
||||
ON (a.`id_guest_reg_id_proof` = al.`id_guest_reg_id_proof`)
|
||||
ORDER BY a.`id_guest_reg_id_proof` ASC'
|
||||
);
|
||||
|
||||
if ($result) {
|
||||
foreach ($result as $row) {
|
||||
$id = (int)$row['id_guest_reg_id_proof'];
|
||||
if (!isset($rows[$id])) {
|
||||
$rows[$id] = array(
|
||||
'id' => $id,
|
||||
'form_key' => $id,
|
||||
'active' => (int)$row['active'],
|
||||
'date_add' => $row['date_add'],
|
||||
'name' => array(),
|
||||
);
|
||||
foreach ($languages as $language) {
|
||||
$rows[$id]['name'][(int)$language['id_lang']] = '';
|
||||
}
|
||||
}
|
||||
if ((int)$row['id_lang']) {
|
||||
$rows[$id]['name'][(int)$row['id_lang']] = $row['name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array_values($rows);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array All persisted IDs.
|
||||
*/
|
||||
public static function getRegistrationIdProofIds(): array
|
||||
{
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(
|
||||
'SELECT `id_guest_reg_id_proof` FROM `'._DB_PREFIX_.'guest_reg_id_proof`'
|
||||
);
|
||||
|
||||
return $result ? array_map('intval', array_column($result, 'id_guest_reg_id_proof')) : array();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user