Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 53 |
CRAP | |
0.00% |
0 / 798 |
CommonService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 53 |
35156.00 | |
0.00% |
0 / 798 |
__construct | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 3 |
|||
__clone | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 2 |
|||
getInstance | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 5 |
|||
getAcademicYear | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 10 |
|||
getLastDayOfMonth | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 4 |
|||
getMonthInWords | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 4 |
|||
getSettings | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 12 |
|||
getMultipleSettings | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 16 |
|||
updateSettingsValue | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 11 |
|||
getSettingsByType | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 11 |
|||
checkPhoneNo | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 12 |
|||
addOrdinalNumberSuffix | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 17 |
|||
updateSettings | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 12 |
|||
checkEmail | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 7 |
|||
getCollegeHeader | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 14 |
|||
getCollegeHeaderAsTableRows | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 20 |
|||
getCertificateHeader | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 30 |
|||
getFormat | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 3 |
|||
numberDropDown | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 23 |
|||
getExamReportHeader | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 22 |
|||
isName | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 3 |
|||
getActiveProductConfig | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 10 |
|||
getProductPackageType | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 13 |
|||
appendZero | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 6 |
|||
getIndianCurrency | |
0.00% |
0 / 1 |
182.00 | |
0.00% |
0 / 31 |
|||
selectNumber | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 19 |
|||
generateNumberDropdown | |
0.00% |
0 / 1 |
56.00 | |
0.00% |
0 / 23 |
|||
createSettings | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 11 |
|||
getOBESettings | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 13 |
|||
updateOBESettings | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 13 |
|||
updateJSONValueSettings | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 12 |
|||
generateQRcodeByStudentId | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 32 |
|||
getCustomTemplate | |
0.00% |
0 / 1 |
56.00 | |
0.00% |
0 / 21 |
|||
getAcademicYearByDate | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 12 |
|||
updateSettingsValueWithJson | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 14 |
|||
getAllHtmldata | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 13 |
|||
getEmailConfByModule | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 8 |
|||
numToOrdinalWord | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 9 |
|||
constructResponseHtmlForBarcode | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 37 |
|||
getCollegeHeaders | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 34 |
|||
getCollegeCommonHeader | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 5 |
|||
checkV3AdminIsEnabledToUser | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 12 |
|||
checkV3HrAdminIsEnabledToUser | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 19 |
|||
validateAdminWithStaff | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 15 |
|||
getDigitalValuationStaffPermission | |
0.00% |
0 / 1 |
272.00 | |
0.00% |
0 / 44 |
|||
getCustomFieldObjectList | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 18 |
|||
getDataType | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 12 |
|||
getStudentDetailsByFalseNumber | |
0.00% |
0 / 1 |
72.00 | |
0.00% |
0 / 24 |
|||
verifyMailId | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 9 |
|||
getStudentExamDetailsByRequest | |
0.00% |
0 / 1 |
156.00 | |
0.00% |
0 / 41 |
|||
htmlEntityDecodeArrayOfObjects | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 16 |
|||
url_exists | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 3 |
|||
getClusterDetails | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 8 |
<?php | |
namespace com\linways\core\ams\professional\service; | |
use com\linways\base\util\TwigRenderer; | |
use com\linways\core\ams\professional\exception\ProfessionalException; | |
use com\linways\core\ams\professional\mapper\CommonServiceMapper; | |
use com\linways\core\ams\professional\util\CommonUtil; | |
use com\linways\core\ams\professional\request\CommonHeaderRequest; | |
use com\linways\core\ams\professional\dto\SettingsConstents; | |
use com\linways\core\ams\professional\constant\ExamType; | |
use com\linways\core\ams\professional\service\ExamRevaluationService; | |
use com\linways\core\ams\professional\service\ExamService; | |
use TCPDFBarcode; | |
class CommonService extends BaseService | |
{ | |
// /Condition 1 - Presence of a static member variable | |
private static $_instance = null; | |
private $mapper = []; | |
// /Condition 2 - Locked down the constructor | |
private function __construct() | |
{ | |
$this->mapper = CommonServiceMapper::getInstance()->getMapper(); | |
} | |
// Prevent any oustide instantiation of this class | |
// /Condition 3 - Prevent any object or instance of that class to be cloned | |
private function __clone() | |
{ | |
} | |
// Prevent any copy of this object | |
// /Condition 4 - Have a single globally accessible static method | |
public static function getInstance() | |
{ | |
if (!is_object(self::$_instance)) // or if( is_null(self::$_instance) ) or if( self::$_instance == null ) | |
self::$_instance = new self (); | |
return self::$_instance; | |
} | |
/** | |
* get academic year of college | |
* | |
* @return string | |
*/ | |
public function getAcademicYear() | |
{ | |
$academicYear = ""; | |
if (date('m') > 06) { | |
$date = date('Y', strtotime("this year June 1st")); | |
} else { | |
$date = date('Y', strtotime("previous year June 1st")); | |
} | |
$academicYear = $date . "-" . substr(($date + 1), 2); | |
return $academicYear; | |
} | |
public function getLastDayOfMonth($month, $year) | |
{ | |
$date = date('Y-m-t', strtotime($year . '-' . $month . '-01')); | |
return $date; | |
} | |
public function getMonthInWords($month) | |
{ | |
$monthWords = date('F', mktime(0, 0, 0, $month, 1, date('Y'))); | |
return $monthWords; | |
} | |
/** | |
* Get value for a setting by name & type | |
* | |
* @param | |
* name | |
* @param | |
* type | |
* @return string | |
*/ | |
public function getSettings($type, $name) | |
{ | |
$type = $this->realEscapeString($type); | |
$name = $this->realEscapeString($name); | |
$value = NULL; | |
$sql = "SELECT value FROM settings where type='$type' AND name='$name'"; | |
try { | |
$value = $this->executeQueryForObject($sql)->value; | |
} catch (\Exception $e) { | |
throw new ProfessionalException ($e->getCode(), $e->getMessage()); | |
} | |
return $value; | |
} | |
/** | |
* Get multiple settings by name array | |
* | |
* @param | |
* Array[settingsName] | |
* | |
* @return Array | |
*/ | |
public function getMultipleSettings($requestArray = [], $searchBy = 'BY_NAME') | |
{ | |
switch($searchBy) { | |
case 'BY_NAME': | |
$sql = "SELECT name, value FROM settings WHERE name IN ('" . implode("','", $requestArray) . "')"; | |
break; | |
case 'BY_TYPE': | |
$sql = "SELECT name, value FROM settings WHERE type IN ('" . implode("','", $requestArray) . "')"; | |
break; | |
} | |
try { | |
$settings = $this->executeQueryForList($sql); | |
} catch (\Exception $e) { | |
throw new ProfessionalException ($e->getCode(), $e->getMessage()); | |
} | |
return $settings; | |
} | |
/** | |
* update the value of settings constants | |
* | |
* @param string $type | |
* @param string $name | |
* @param string $value | |
*/ | |
public function updateSettingsValue($type, $name, $value) | |
{ | |
$type = $this->realEscapeString($type); | |
$name = $this->realEscapeString($name); | |
$value = $this->realEscapeString($value); | |
$sql = "UPDATE settings SET value='$value' WHERE type='$type' AND name='$name'"; | |
try { | |
return $this->executeQuery($sql); | |
} catch (\Exception $e) { | |
throw new ProfessionalException ($e->getCode(), $e->getMessage()); | |
} | |
} | |
/** | |
* Get value for a setting by type | |
* | |
* @param | |
* name | |
* @return array | |
*/ | |
public function getSettingsByType($type) | |
{ | |
$type = $this->realEscapeString($type); | |
$value = []; | |
$sql = "SELECT name, value FROM settings where type='$type'"; | |
try { | |
$value = $this->executeQueryForList($sql); | |
} catch (\Exception $e) { | |
throw new ProfessionalException ($e->getCode(), $e->getMessage()); | |
} | |
return $value; | |
} | |
/** | |
* check if phone number is valid and returns with code embedded. | |
* | |
* @param string $phonNo | |
* | |
*/ | |
public function checkPhoneNo($phonNo) | |
{ | |
if (preg_match("/^91[0-9]{10}$/", $phonNo)) { | |
return $phonNo; | |
} else { | |
if (preg_match("/^[0-9]{10}$/", $phonNo)) { | |
$phonNo = "91" . $phonNo; | |
return $phonNo; | |
} else { | |
$phonNo = ""; | |
} | |
} | |
} | |
/** | |
* Add ordinal number suffix eg:1->st,2->nd | |
* | |
* @param int $num | |
* @return string | |
*/ | |
public function addOrdinalNumberSuffix($num) | |
{ | |
if (!in_array(($num % 100), array( | |
11, | |
12, | |
13 | |
))) { | |
switch ($num % 10) { | |
// Handle 1st, 2nd, 3rd | |
case 1 : | |
return $num . 'st'; | |
case 2 : | |
return $num . 'nd'; | |
case 3 : | |
return $num . 'rd'; | |
} | |
} | |
return $num . 'th'; | |
} | |
/** | |
* Update value for a setting by name & type | |
* | |
* @param | |
* name | |
* @param | |
* type | |
* @return string | |
*/ | |
public function updateSettings($type, $name, $value) | |
{ | |
$type = $this->realEscapeString($type); | |
$name = $this->realEscapeString($name); | |
$value = $this->realEscapeString($value); | |
global $connect; | |
$sql = "UPDATE settings SET value='$value' where type='$type' AND name='$name'"; | |
try { | |
return $this->executeQuery($sql); | |
} catch (\Exception $e) { | |
throw new ProfessionalException ($e->getCode(), $e->getMessage()); | |
} | |
} | |
/** | |
* check if email is valid | |
* | |
* @param string $email | |
* @return boolean | |
*/ | |
public function checkEmail($email) | |
{ | |
if (preg_match('/^\S+@[\w\d.-]{2,}\.[\w]{2,6}$/iU', $email)) { | |
return true; | |
} else { | |
return false; | |
} | |
} | |
/** | |
* college header for print and export | |
*/ | |
public function getCollegeHeader($wrapperClass = "well") | |
{ | |
global $COLLEGE_NAME; | |
global $COLLEGE_ADDRESS1; | |
global $COLLEGE_ADDRESS2; | |
global $COLLEGE_CONTACT1; | |
global $COLLEGE_CONTACT2; | |
global $COLLEGE_NAME_NEW; | |
return "<div class='$wrapperClass' align='center'> | |
<font size='4'><b>".($COLLEGE_NAME_NEW?$COLLEGE_NAME_NEW:$COLLEGE_NAME)."</b></font><br/> | |
<b>$COLLEGE_ADDRESS1.$COLLEGE_ADDRESS2</b><br/> | |
<b>$COLLEGE_CONTACT1</b><br/> | |
<i>$COLLEGE_CONTACT2</i><br/> | |
</div>"; | |
} | |
/** | |
* Undocumented function | |
* | |
* @param string $colspan | |
* @return void | |
*/ | |
public function getCollegeHeaderAsTableRows($colspan = "", $rowClass = '', $colClass = '') | |
{ | |
global $COLLEGE_NAME; | |
global $COLLEGE_ADDRESS1; | |
global $COLLEGE_ADDRESS2; | |
global $COLLEGE_CONTACT1; | |
global $COLLEGE_CONTACT2; | |
global $COLLEGE_NAME_NEW; | |
return "<tr align='center' class='$rowClass'> | |
<td class='$colClass' colspan='$colspan' data-a-h='center' data-a-v='vertical' data-b-a-s='thin' data-f-bold='true' >".($COLLEGE_NAME_NEW?$COLLEGE_NAME_NEW:$COLLEGE_NAME)."</td> | |
</tr> | |
<tr align='center' class='$rowClass'> | |
<td class='$colClass' colspan='$colspan' data-a-h='center' data-a-v='vertical' data-b-a-s='thin' data-f-bold='true'>$COLLEGE_ADDRESS1.<br/>$COLLEGE_ADDRESS2</td> | |
</tr> | |
<tr align='center' class='$rowClass'> | |
<td class='$colClass' colspan='$colspan' data-a-h='center' data-a-v='vertical' data-b-a-s='thin' data-f-bold='true'>$COLLEGE_CONTACT1</td> | |
</tr> | |
<tr align='center' class='$rowClass'> | |
<td class='$colClass' colspan='$colspan' data-a-h='center' data-a-v='vertical' data-b-a-s='thin' data-f-bold='true'>$COLLEGE_CONTACT2</td> | |
</tr>"; | |
} | |
/** | |
* get college certificate header | |
* | |
* @return string | |
*/ | |
public function getCertificateHeader($pageSize = 'A4') | |
{ | |
global $COLLEGE_NAME; | |
global $COLLEGE_ADDRESS1; | |
global $COLLEGE_ADDRESS2; | |
global $COLLEGE_CONTACT1; | |
global $COLLEGE_CONTACT2; | |
global $COLLEGE_AFFILIATIONS; | |
global $COLLEGE_NAME_NEW; | |
global $autonomous; | |
switch ($pageSize) { | |
case 'A5': | |
return " | |
<div style='font-family: Times New Roman;font-size:18px;letter-spacing: -1px;line-height: 23px; | |
text-align: center;'> | |
<b>".($COLLEGE_NAME_NEW?$COLLEGE_NAME_NEW:$COLLEGE_NAME)."</b> | |
</div>" . | |
(!empty($autonomous) ? "<div style='font-family: Times New Roman;text-align: center;font-size: 12px;padding-top: 11px;'>$autonomous</div>" : "") | |
. "<div style='font-family: Times New Roman;text-align: center;font-size: 12px;padding-top: 11px;'>$COLLEGE_AFFILIATIONS $COLLEGE_ADDRESS1 $COLLEGE_ADDRESS2</div>"; | |
break; | |
default: | |
return " | |
<div style='font-family: Times New Roman;font-size: 28px;letter-spacing: -1px;line-height: 23px; | |
text-align: center;'> | |
<b>".($COLLEGE_NAME_NEW?$COLLEGE_NAME_NEW:$COLLEGE_NAME)."</b> | |
</div>" . | |
(!empty($autonomous) ? "<div style='font-family: Times New Roman;text-align: center;font-size: 16px;padding-top: 11px;'>$autonomous</div>" : "") | |
. "<div style='font-family: Times New Roman;text-align: center;font-size: 16px;padding-top: 11px;'>$COLLEGE_AFFILIATIONS $COLLEGE_ADDRESS1 $COLLEGE_ADDRESS2</div>"; | |
break; | |
} | |
} | |
/** | |
* To get the format of file | |
* | |
* @param String $filename | |
* @return string | |
*/ | |
function getFormat($filename) | |
{ | |
return strtolower(substr(strrchr($filename, '.'), 1)); | |
} | |
/** | |
* It will generate html dropdown for number | |
* | |
* @param int $from | |
* @param int $limit | |
* @param string $id | |
* @param string $name | |
* @param string $class | |
* @param int $select | |
* @return string | |
* @author Sanoop | |
*/ | |
public function numberDropDown($from, $limit, $id = "", $name = "", $class = "", $select = 0) | |
{ | |
$limit = $from + $limit; | |
if ($select) { | |
$selected [$select] = 'selected'; | |
} | |
$response = "<select "; | |
if ($class) { | |
$response .= "class='$class' "; | |
} | |
if ($id) { | |
$response .= "id='$id' "; | |
} | |
if ($name) { | |
$response .= "name='$name' "; | |
} | |
$response .= ">"; | |
$response .= "<option value='0'>--select--</option>"; | |
for ($i = $from; $i <= $limit; $i++) { | |
$response .= "<option value='$i' " . $selected [$i] . ">$i</option>"; | |
} | |
$response .= "</select>"; | |
return $response; | |
} | |
public function getExamReportHeader() | |
{ | |
$examReportHeader = NULL; | |
$sql = "SELECT t1.header,t1.header_type,t1.alternate_header FROM header t1, exam_reporthead t2 WHERE t1.id = t2.header"; | |
try { | |
$examReportHeader = $this->executeQueryForObject($sql); | |
$header_type = $examReportHeader->header_type; | |
$header = $examReportHeader->header; | |
$export_head = $examReportHeader->header; | |
if ($header_type == 'image') { | |
$export_head = $row ['alternate_header']; | |
if (file_exists('../' . $header)) { | |
return "<div><img src='" . $header . "'/></div>"; | |
} else { | |
return $export_head; | |
} | |
} else { | |
return $header; | |
} | |
} catch (\Exception $e) { | |
throw new ProfessionalException ($e->getCode(), $e->getMessage()); | |
} | |
} | |
/** | |
* check common name | |
* | |
* @param string $name | |
* @return boolean | |
*/ | |
public function isName($name) | |
{ | |
return preg_match('/^([\w\d\s\&\-\_\+\.\:\|\/]+)$/iU', $name) ? TRUE : FALSE; | |
} | |
/** | |
* Method for getting active product configuration | |
* | |
* @return Object|null | |
* @throws ProfessionalException | |
*/ | |
public function getActiveProductConfig() | |
{ | |
$productConfig = null; | |
$sql = "SELECT * FROM product_package_config WHERE active = 1;"; | |
try { | |
$productConfig = $this->executeQueryForObject($sql, false, $this->mapper[CommonServiceMapper::GETACTIVEPRODUCTCONFIG]); | |
} catch (\Exception $e) { | |
throw new ProfessionalException ($e->getCode(), $e->getMessage()); | |
} | |
return $productConfig; | |
} | |
/** | |
* Method for getting active product package type | |
* @return string | |
* @throws ProfessionalException | |
*/ | |
public function getProductPackageType() | |
{ | |
$packageType = null; | |
$sql = "SELECT packageType FROM product_package_config WHERE active = 1;"; | |
try { | |
$response = $this->executeQueryForObject($sql); | |
if (!empty($response)) { | |
$packageType = $response->packageType; | |
} | |
} catch (\Exception $e) { | |
throw new ProfessionalException ($e->getCode(), $e->getMessage()); | |
} | |
return $packageType; | |
} | |
/** | |
* padding zero | |
* @param int $num | |
* @param int $paddingLength | |
* @return string | |
*/ | |
function appendZero($num, $paddingLength) | |
{ | |
if (is_numeric($num)) { | |
$num = str_pad($num, $paddingLength, "0", STR_PAD_LEFT); | |
} | |
return $num; | |
} | |
/** | |
* get numbers to indian currency | |
* @param float $number | |
* @return string | |
*/ | |
public function getIndianCurrency($number) | |
{ | |
$decimal = round($number - ($no = floor($number)), 2) * 100; | |
$hundred = null; | |
$digits_length = strlen($no); | |
$i = 0; | |
$str = array(); | |
$words = array(0 => '', 1 => 'one', 2 => 'two', | |
3 => 'three', 4 => 'four', 5 => 'five', 6 => 'six', | |
7 => 'seven', 8 => 'eight', 9 => 'nine', | |
10 => 'ten', 11 => 'eleven', 12 => 'twelve', | |
13 => 'thirteen', 14 => 'fourteen', 15 => 'fifteen', | |
16 => 'sixteen', 17 => 'seventeen', 18 => 'eighteen', | |
19 => 'nineteen', 20 => 'twenty', 30 => 'thirty', | |
40 => 'forty', 50 => 'fifty', 60 => 'sixty', | |
70 => 'seventy', 80 => 'eighty', 90 => 'ninety'); | |
$digits = array('', 'hundred', 'thousand', 'lakh', 'crore'); | |
while ($i < $digits_length) { | |
$divider = ($i == 2) ? 10 : 100; | |
$number = floor($no % $divider); | |
$no = floor($no / $divider); | |
$i += $divider == 10 ? 1 : 2; | |
if ($number) { | |
$plural = (($counter = count($str)) && $number > 9) ? '' : null; | |
$hundred = ($counter == 1 && $str[0]) ? ' and ' : null; | |
$str [] = ($number < 21) ? $words[$number] . ' ' . $digits[$counter] . $plural . ' ' . $hundred : $words[floor($number / 10) * 10] . ' ' . $words[$number % 10] . ' ' . $digits[$counter] . $plural . ' ' . $hundred; | |
} else $str[] = null; | |
} | |
$Rupees = ucfirst(implode('', array_reverse($str))); | |
// $paise = ($decimal) ? "." . ($words[$decimal / 10] . " " . $words[$decimal % 10]) . ' Paise' : ''; | |
$paise = ($decimal) ? "and " . ($words[$decimal / 10] . " " . (($decimal % 10) == 0 ? 'zero' : $words[$decimal % 10])) . ' Paise' : ''; | |
return ($Rupees ? $Rupees . 'Rupees ' : '') . $paise; | |
} | |
public function selectNumber($startNumber, $endNumber, $inputName, $titleName, $comparedVal = '', $order = 'asc') | |
{ | |
$response = ''; | |
if ($order == "desc") { | |
$response .= "<select id='$inputName' class='form-control input-sm' name='" . $inputName . "'><option value=''>" . $titleName . "</option>"; | |
for ($i = $endNumber; $i >= $startNumber; $i--) { | |
if ($i == $comparedVal) $response .= "<option value='$i' selected>$i</option>"; | |
else $response .= "<option value='$i'>$i</option>"; | |
} | |
$response .= "</select>"; | |
} else { | |
$response .= "<select id='$inputName' class='form-control input-sm' name='" . $inputName . "'><option value=''>" . $titleName . "</option>"; | |
for ($i = $startNumber; $i <= $endNumber; $i++) { | |
if ($i == $comparedVal) $response .= "<option value='$i' selected>$i</option>"; | |
else $response .= "<option value='$i'>$i</option>"; | |
} | |
$response .= "</select>"; | |
} | |
return $response; | |
} | |
/** | |
* generate nummber dropdown | |
* request contain startNumber, endNumber, inputName, titleName, comparedVal, order, required | |
* @param object $request | |
* @return string | |
*/ | |
public function generateNumberDropdown($request) | |
{ | |
$response = ''; | |
$required = ''; | |
if ($request->required == true) { | |
$required = 'required'; | |
} | |
if ($request->order == "desc") { | |
$response .= "<select id='$request->inputName' class='form-control input-sm' name='" . $request->inputName . "' $required><option value=''>" . $request->titleName . "</option>"; | |
for ($i = $request->endNumber; $i >= $request->startNumber; $i--) { | |
if ($i == $request->comparedVal) $response .= "<option value='$i' selected>$i</option>"; | |
else $response .= "<option value='$i'>$i</option>"; | |
} | |
$response .= "</select>"; | |
} else { | |
$response .= "<select id='$request->inputName' class='form-control input-sm' name='" . $request->inputName . "' $required><option value=''>" . $request->titleName . "</option>"; | |
for ($i = $request->startNumber; $i <= $request->endNumber; $i++) { | |
if ($i == $request->comparedVal) $response .= "<option value='$i' selected>$i</option>"; | |
else $response .= "<option value='$i'>$i</option>"; | |
} | |
$response .= "</select>"; | |
} | |
return $response; | |
} | |
/** | |
* Create settings | |
* @param string $type | |
* @param string $name | |
* @param string $value | |
* @return object|NULL|\com\linways\base\util\$objectList[] | |
* @throws ProfessionalException | |
*/ | |
public function createSettings($type, $name, $value) | |
{ | |
$type = $this->realEscapeString($type); | |
$name = $this->realEscapeString($name); | |
$value = $this->realEscapeString($value); | |
$sql = "INSERT INTO settings (name, value, type, created_by, created_date, updated_by, updated_date) VALUES ('$name', '$value', '$type', '1', UTC_TIMESTAMP(), '1', UTC_TIMESTAMP())"; | |
try { | |
return $this->executeQueryForObject($sql, true); | |
} catch (\Exception $e) { | |
throw new ProfessionalException ($e->getCode(), $e->getMessage()); | |
} | |
} | |
/** | |
* Get value for a obe setting by name & type | |
* | |
* @param | |
* name | |
* @param | |
* type | |
* @return string | |
*/ | |
public function getOBESettings($type, $name, $deptId = 'null') | |
{ | |
$type = $this->realEscapeString($type); | |
$name = $this->realEscapeString($name); | |
$deptId = $this->realEscapeString($deptId); | |
$value = NULL; | |
$sql = "SELECT value FROM obe_settings where type='$type' AND name='$name' AND deptId=$deptId"; | |
try { | |
$value = $this->executeQueryForObject($sql)->value; | |
} catch (\Exception $e) { | |
throw new ProfessionalException ($e->getCode(), $e->getMessage()); | |
} | |
return $value; | |
} | |
/** | |
* Update value for a setting by name & type | |
* | |
* @param | |
* name | |
* @param | |
* type | |
* @return string | |
*/ | |
public function updateOBESettings($type, $name, $value, $deptId = 'null') | |
{ | |
$type = $this->realEscapeString($type); | |
$name = $this->realEscapeString($name); | |
$value = $this->realEscapeString($value); | |
$deptId = $this->realEscapeString($deptId); | |
global $connect; | |
$sql = "UPDATE settings SET value='$value' where type='$type' AND name='$name' AND deptId=$deptId"; | |
try { | |
return $this->executeQuery($sql); | |
} catch (\Exception $e) { | |
throw new ProfessionalException ($e->getCode(), $e->getMessage()); | |
} | |
} | |
public function updateJSONValueSettings($type, $name, $value) | |
{ | |
$type = $this->realEscapeString($type); | |
$name = $this->realEscapeString($name); | |
$value = $this->realEscapeObject(json_encode($value)); | |
$value = htmlspecialchars_decode($value); | |
$query = "UPDATE settings SET value='$value' WHERE name='$name' and type='$type'"; | |
try { | |
$this->executeQuery($query); | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
/** | |
* Generate QR code | |
* @param studentId $studentId | |
* @return string QRcodeImageURL | |
* @throws ProfessionalException | |
*/ | |
public function generateQRcodeByStudentId($studentId) | |
{ | |
$studentId = $this->realEscapeString($studentId); | |
// $QUICK is the secret key defined in the conf.php | |
global $QUICK; | |
try { | |
$studentDetailsSQL = "SELECT cc.code, sa.studentName, sa.studentBirthday | |
FROM coursetype_code cc | |
INNER JOIN | |
batches b ON cc.courseTypeID = b.courseTypeID AND cc.batchID = b.batchID | |
INNER JOIN | |
studentaccount sa ON sa.batchID = b.batchID | |
WHERE studentID = \"" . $studentId . "\""; | |
$studentDetails = $this->executeQueryForObject($studentDetailsSQL); | |
$batchCode = $studentDetails->code; | |
$DOB = explode("-", $studentDetails->studentBirthday); | |
$DOBMonth = $DOB[1]; | |
$DOBDay = $DOB[2]; | |
$date = strtotime($studentDetails->studentBirthday); | |
$year = date("Y", $date); | |
$smallYear = substr($year, 2); | |
$studentDOB = trim($smallYear . $DOBMonth . $DOBDay); | |
$studentNameInQR = $studentDetails->studentName; | |
$studentNameInQR = str_replace(" ", "", trim($studentNameInQR)); | |
$studentNameInQR = str_replace(".", "", $studentNameInQR); | |
$combineString = $studentNameInQR . $studentDOB . $batchCode; | |
$ciphertext = hash_hmac('sha256', $combineString, $QUICK); | |
$ciphertext_base64 = base64_encode($ciphertext); | |
$allString = $combineString . "|" . $ciphertext_base64; | |
return "https://chart.googleapis.com/chart?chs=100x100&cht=qr&chl=$allString&choe=UTF-8"; | |
} catch (\Exception $e) { | |
throw new ProfessionalException ($e->getCode(), $e->getMessage()); | |
} | |
} | |
/** | |
* Get Template name from multiple templates | |
* @param settings type | |
* @param settings name | |
* @param $id | |
* @return string templateName | |
* @throws ProfessionalException | |
* @author Anoop | |
* | |
*/ | |
public function getCustomTemplate($type, $name, $id = NULL) | |
{ | |
$id = $this->realEscapeString($id); | |
$type = $this->realEscapeString($type); | |
$name = $this->realEscapeString($name); | |
$customTemplate = NULL; | |
try { | |
$customTemplateJSON = CommonService::getInstance()->getSettings($type, $name); | |
$customTemplateJSON = json_decode($customTemplateJSON); | |
if (!empty($customTemplateJSON->custom)) { | |
foreach ($customTemplateJSON->custom as $template) { | |
if (in_array($id, $template->id)) { | |
$customTemplate = $template->templateId; | |
} | |
} | |
} | |
$customTemplate = ($customTemplate && $id != NULL) ? $customTemplate : $customTemplateJSON->default; | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
return $customTemplate; | |
} | |
public function getAcademicYearByDate($date = null) | |
{ | |
$academicYear = ""; | |
$date = $date ? date("Y-m-d", strtotime($date)) : date("Y-m-d"); | |
$month = date("m", strtotime($date)); | |
if ($month > 06) { | |
$date = date('Y', strtotime($date)); | |
} else { | |
$date = date('Y', strtotime($date)) - 1; | |
} | |
$academicYear = $date . "-" . substr(($date + 1), 2); | |
return $academicYear; | |
} | |
/** | |
* update settings which contains json values as value | |
* | |
* @param [type] $type | |
* @param [type] $name | |
* @param [type] $key | |
* @param [type] $property | |
* @param [type] $value | |
* @return void | |
*/ | |
public function updateSettingsValueWithJson($type, $name, $key, $property, $value) | |
{ | |
$type = $this->realEscapeString($type); | |
$name = $this->realEscapeString($name); | |
$key = $this->realEscapeString($key); | |
$property = $this->realEscapeString($property); | |
$value = $this->realEscapeString($value); | |
global $connect; | |
$sql = "UPDATE settings SET value=JSON_SET(value, '\$.$key.$property', '$value') WHERE name='$name' AND TYPE='$type'"; | |
try { | |
return $this->executeQuery($sql); | |
} catch (\Exception $e) { | |
throw new ProfessionalException ($e->getCode(), $e->getMessage()); | |
} | |
} | |
/** | |
* Written for staff side quiz | |
*/ | |
function getAllHtmldata($string, $dontReplaceTags, $first, $last = null) | |
{ | |
$question = $first ? htmlspecialchars_decode($string) : $string; | |
$string = CommonUtil::get_string_between2_strings($question, '```', '```'); | |
$replaceString = $dontReplaceTags ? '|||' . htmlspecialchars($string) . '|||' : htmlspecialchars($string); | |
$question = str_replace('```' . $string . '```', $replaceString, $question); | |
if (CommonUtil::get_string_between2_strings($question, '```', '```')) { | |
$question = CommonService::getAllHtmldata($question, $dontReplaceTags, 0); | |
} | |
if ($last) { | |
$question = str_replace('|||', '```', $question); | |
} | |
return $question; | |
} | |
/** | |
* get email credential by module | |
* @param string $module | |
* @throws ProfessionalException | |
* @return object|NULL|\com\linways\base\util\$objectList[] | |
*/ | |
public function getEmailConfByModule($module) | |
{ | |
$sql ="SELECT * FROM module_email_configuration WHERE module='$module'"; | |
try { | |
return $this->executeQueryForObject($sql); | |
} catch ( \Exception $e ) { | |
throw new ProfessionalException ( $e->getCode (), $e->getMessage () ); | |
} | |
} | |
/** | |
* Convert number to ordinal word | |
* @param Integer $num | |
* @return String $string | |
*/ | |
function numToOrdinalWord($num) | |
{ | |
$first_word = array('eth','First','Second','Third','Fouth','Fifth','Sixth','Seventh','Eighth','Ninth','Tenth','Elevents','Twelfth','Thirteenth','Fourteenth','Fifteenth','Sixteenth','Seventeenth','Eighteenth','Nineteenth','Twentieth'); | |
$second_word =array('','','Twenty','Thirty','Forty','Fifty'); | |
if($num <= 20) | |
return $first_word[$num]; | |
$first_num = substr($num,-1,1); | |
$second_num = substr($num,-2,1); | |
return $string = str_replace('y-eth','ieth',$second_word[$second_num].'-'.$first_word[$first_num]); | |
} | |
function constructResponseHtmlForBarcode($studentDetails, $type) | |
{ | |
$responseHtml = ''; | |
$responseHtml .= " | |
<div id='printDiv_$type'> | |
<style> | |
.barcodeDiv { | |
width:5.25cm; | |
line-height:2cm; | |
vertical-align:middle !important; | |
text-align: center; | |
margin:1.5mm 0; | |
} | |
.barcodeDiv > div { margin : auto; } | |
table tr, | |
table tr td { | |
page-break-inside: avoid; | |
} | |
</style> | |
<table border='0' cellpadding='0' cellspacing='0'>"; | |
foreach ( $studentDetails as $student ) { | |
$barcodeobj = new TCPDFBarcode($student->regNo, 'C128'); | |
$responseHtml .= " | |
<tr style='text-align:center;'> | |
<td> | |
<div class='barcodeDiv' style='font-size:18px;'><b>".$student->regNo."</b></div> | |
</td> | |
<td> | |
<div class='barcodeDiv'>".$barcodeobj->getBarcodeHTML(1, 30, 'black')."</div> | |
</td> | |
</tr>"; | |
} | |
$responseHtml .= " | |
</table> | |
</div> | |
<button class='btn btn-sm btn-primary' style='margin-left:5cm' @click=\"printBarcode('printDiv_$type')\">Print</button>"; | |
return $responseHtml; | |
} | |
/** | |
* Undocumented function | |
* | |
* @param string $colspan | |
* @return Object | |
*/ | |
public function getCollegeHeaders() | |
{ | |
global $COLLEGE_NAME; | |
global $COLLEGE_ADDRESS1; | |
global $COLLEGE_ADDRESS2; | |
global $COLLEGE_CONTACT1; | |
global $COLLEGE_CONTACT2; | |
global $COLLEGE_CODE; | |
global $COLLEGE_AFFLIATE; | |
global $COLLEGE_WEBSITE; | |
global $COLLEGE_NAME_NEW; | |
global $COLLEGE_CODE; | |
$college = new \stdClass(); | |
$college->code = $COLLEGE_CODE; | |
$college->name = $COLLEGE_NAME_NEW?$COLLEGE_NAME_NEW:$COLLEGE_NAME; | |
$college->address1 = $COLLEGE_ADDRESS1; | |
$college->address2 = $COLLEGE_ADDRESS2; | |
$college->contact1 = $COLLEGE_CONTACT1; | |
$college->contact2 = $COLLEGE_CONTACT2; | |
$college->affliate = $COLLEGE_AFFLIATE; | |
$college->website = $COLLEGE_WEBSITE; | |
// $college->reportHeader = "../../libcommon/images/college/".($COLLEGE_NAME_NEW?$COLLEGE_NAME_NEW:$COLLEGE_NAME)."/report-header.png"; | |
$college->reportHeader = "../../libcommon/images/college/".($COLLEGE_CODE)."/report-header.png"; | |
$collegeUrl = $GLOBALS['_SERVER']['REQUEST_SCHEME']."://".$GLOBALS['_SERVER']['HTTP_HOST']; | |
$addOn = (getenv("DEBUG") === "true") ? "http://localhost/" : $collegeUrl."/"; | |
$bannerUrl = $addOn."libcommon/images/college/".$college->code."/college_header_banner.png"; | |
if (CommonService::getInstance()->url_exists($bannerUrl)) { | |
// If the header banner exists at the URL | |
$college->collegeBannerHeader = $bannerUrl; | |
$college->isCollegeBannerHeaderExist = true; | |
} | |
try{ | |
$college->templateSettings = json_decode( CommonService::getInstance()->getSettings("V4_COMMON_TEMPLATE_SETTINGS","V4_COMMON_TEMPLATE_CONFIGURATION")); | |
return $college; | |
}catch (\Exception $e) { | |
} | |
} | |
/** | |
* Common header function | |
* @param CommonHeaderRequest $headerRequest | |
* @return void | |
*/ | |
public function getCollegeCommonHeader(CommonHeaderRequest $headerRequest,$collegeProperty = null){ | |
$college = $this->getCollegeHeaders(); | |
$templateName = $college->templateSettings->templateName??"conventionalTemplate"; | |
$header = TwigRenderer::renderTemplateFileToHtml(__DIR__."/../../../../core/templates/headerTwigs/$templateName.twig", [ 'headerRequest' => $headerRequest,'collegeProperty'=>$collegeProperty,'college'=>$college]); | |
// need to display filters | |
return $header; | |
} | |
public function checkV3AdminIsEnabledToUser($staffId){ | |
$staffId = $this->realEscapeString($staffId); | |
if(empty($staffId)) | |
throw new ProfessionalException(ProfessionalException::INVALID_LOGIN,"Invalid user! Please try again"); | |
$sql = "SELECT a.adminID AS id, a.adminAccount AS account, a.adminPassword AS password, s.staffID as staffId, s.staffAccount, s.staffPassword from adminaccount a | |
INNER JOIN staffaccounts s ON s.staffID = a.staff_id | |
WHERE a.is_blocked = 0 AND s.isResigned = 0 AND s.staffID = $staffId ;"; | |
try { | |
return $this->executeQueryForObject($sql); | |
} catch (\Exception $e) { | |
throw new ProfessionalException ($e->getCode(), $e->getMessage()); | |
} | |
} | |
public function checkV3HrAdminIsEnabledToUser($staffId){ | |
$staffId = $this->realEscapeString($staffId); | |
if(empty($staffId)) | |
throw new ProfessionalException(ProfessionalException::INVALID_LOGIN,"Invalid user! Please try again"); | |
$sql = "SELECT a.adminID AS id, | |
a.adminAccount AS account, | |
a.adminPassword AS password, | |
s.staffID as staffId, | |
s.staffAccount, | |
s.staffPassword | |
from hr_admin a | |
INNER JOIN staffaccounts s ON s.staffID = a.staff_id | |
WHERE s.isResigned = 0 | |
AND s.staffID = $staffId ;"; | |
try { | |
return $this->executeQueryForObject($sql); | |
} catch (\Exception $e) { | |
throw new ProfessionalException ($e->getCode(), $e->getMessage()); | |
} | |
} | |
public function validateAdminWithStaff($staffId,$adminId){ | |
$staffId = $this->realEscapeString($staffId); | |
$adminId = $this->realEscapeString($adminId); | |
$where = ""; | |
if(empty($staffId)) | |
throw new ProfessionalException(ProfessionalException::INVALID_PARAMETERS,"Invalid user! Please try again"); | |
if($adminId){ | |
$where = " AND a.adminID <> $adminId "; | |
} | |
$sql = "select a.adminID as id from adminaccount a where a.staff_id = $staffId $where;"; | |
try { | |
return $this->executeQueryForObject($sql)->id; | |
} catch (\Exception $e) { | |
throw new ProfessionalException ($e->getCode(), $e->getMessage()); | |
} | |
} | |
/** | |
* get staff permissions for assigned digital valuation count | |
* @param string $request | |
* @throws ProfessionalException | |
* @return object|NULL|\com\linways\base\util\$objectList[] | |
*/ | |
public function getDigitalValuationStaffPermission($request) | |
{ | |
$request = $this->realEscapeObject($request); | |
$sql = ""; | |
$permissionSql = ""; | |
$permission = false; | |
$condition = ""; | |
if(!$request->staffId || !$request->studentId || !$request->examId || !$request->valCount){ | |
return $permission; | |
} | |
try { | |
if($request->revalId){ | |
$digitalValuationProperties = $this->getSettings(SettingsConstents::EXAM_CONTROLLER, SettingsConstents::DIGITAL_VALUATION_PROPERTIES); | |
$digitalValuationProperties = $digitalValuationProperties ? current(json_decode($digitalValuationProperties)->revaluation) : ""; | |
//FOR SCRUTINY | |
if($digitalValuationProperties->considerRevaluationType){ | |
$request->markEntryType = $request->scrId ? "SCRUTINY":"REVALUATION"; | |
$revaluationTypeId = (int)ExamRevaluationService::getInstance()->getRevaluationTypeIdByOeRequest($request)->revaluationTypeId; | |
$condition = $revaluationTypeId ? " AND revaluationTypeId IN ($revaluationTypeId)" : ""; | |
} | |
//FOR REVALUATION | |
$permissionSql = "SELECT id FROM examRevaluationStaffAssignedStudents | |
WHERE revaluationId = '$request->revalId' AND examId = '$request->examId' AND studentId = '$request->studentId' AND staffId = '$request->staffId' AND valuationCount = '$request->valCount' $condition "; | |
} | |
else if($request->rvwId){ | |
//consider reviewer as valuation count 2 | |
$request->valuationCount = 2; | |
$examList = StaffService::getInstance()->getExamsAssignedForValuationByStaff($request); | |
if(!empty($examList)){ | |
$permission = true; | |
} | |
return $permission; | |
} | |
else{ | |
//FOR REGULAR AND SUPPLY | |
$sql = "SELECT examID as examId,subjectID as subjectId ,IF(examregID,examregID,supply_examreg_id) as examRegId,IF(examregID,'REGULAR','SUPPLY') as examType FROM exam WHERE examID IN ($request->examId)"; | |
$examDetails = $this->executeQueryForObject($sql); | |
if ($examDetails) { | |
$permissionSql = "SELECT id FROM examValuationStaffAssignedStudents | |
WHERE examRegId = '$examDetails->examRegId' AND examType = '$examDetails->examType' AND subjectId = '$examDetails->subjectId' AND studentId = '$request->studentId' AND staffId = '$request->staffId' AND valuationCount = '$request->valCount'"; | |
} | |
} | |
$result = $permissionSql ? $this->executeQueryForObject($permissionSql)->id :""; | |
$permission = $result ? true : false; | |
return $permission; | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
/** | |
* get student custom field enabled values | |
* @param string $request | |
* @throws ProfessionalException | |
* @return object|NULL|\com\linways\base\util\$objectList[] | |
*/ | |
public function getCustomFieldObjectList($customFields) | |
{ | |
$fieldList = []; | |
$response = new \stdClass(); | |
$studentData = new \stdClass(); | |
$orderNo = 1; | |
foreach ($customFields as $customField) { | |
$field = json_decode('{"columnName":"","displayName":"","fieldType":"","format":"","orderNo":0,"validation":"text","editable":true,"required":false,"relatedFieldList":[],"relatedFieldSeperator":"","foreignkeyTableDetails":{},"tableType":"CUSTOM"}'); | |
$field->columnName = $customField->code; | |
$field->displayName = $customField->label; | |
$field->fieldType = $this->getDataType($customField->dataType); | |
$field->orderNo = $orderNo++; | |
$studentData->{$customField->code} = $customField->value; | |
$fieldList[] = $field; | |
} | |
$response->fieldList = $fieldList; | |
$response->studentData = $studentData; | |
return $response; | |
} | |
private function getDataType($dataType) | |
{ | |
switch ($dataType) { | |
case "longtext": | |
return "textarea"; | |
break; | |
case "varchar": | |
return "text"; | |
break; | |
case "integer": | |
return "text"; | |
} | |
} | |
/** | |
* Get studentDetails By false no ,examId | |
* @param int $request | |
* @return object|NULL|\com\linways\base\util\$objectList[] | |
* @throws ProfessionalException | |
*/ | |
public function getStudentDetailsByFalseNumber($request) | |
{ | |
$request = $this->realEscapeObject($request); | |
$sqlR = ""; | |
$sql = ""; | |
$regularExamId = ""; | |
if (!$request->examId || !$request->falseNumber) { | |
return false; | |
} | |
try { | |
//new digital valuation properties | |
$digitalValuationProperties = $this->getSettings(SettingsConstents::EXAM_CONTROLLER, SettingsConstents::DIGITAL_VALUATION_PROPERTIES); | |
$digitalValuationProperties = $digitalValuationProperties ? json_decode($digitalValuationProperties) : new \stdClass; | |
if ($request->examType == ExamType::SUPPLY && $digitalValuationProperties->getRegularFalseNumberForSupply) { | |
//get regular false number for supply | |
$sqlR = "SELECT er.examregID as examRegId,er.examID as regularExamId from exam es | |
INNER JOIN exam er ON er.semID = es.semID AND er.batchID=es.batchID AND er.subjectID = es.subjectID AND er.examregID IS NOT NULL | |
WHERE es.examID IN($request->examId)"; | |
$regularExamId = $this->executeQueryForObject($sqlR)->regularExamId; | |
} | |
$examId = $regularExamId ? $regularExamId : $request->examId; | |
$sql = "SELECT studentID as userId FROM examcontroller_false_number WHERE false_number = '$request->falseNumber' AND examID = '$examId'"; | |
return $this->executeQueryForObject($sql); | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
public function verifyMailId($mailId){ | |
$mailId = $this->realEscapeString($mailId); | |
$sql = " select studentAccount, studentPassword, studentEmail from studentaccount s where studentEmail = '$mailId'"; | |
try{ | |
$studentCredentials = $this->executeQueryForList($sql); | |
}catch(\Exception $e){ | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
return $studentCredentials; | |
} | |
/** | |
* Get student exam details by examId,studentId | |
* @param int $request | |
* @return Boolean | |
* @throws ProfessionalException | |
*/ | |
public function getStudentExamDetailsByRequest($request) | |
{ | |
$request = $this->realEscapeObject($request); | |
$status = false; | |
$sql = ""; | |
if (!$request->examId || !$request->studentId) { | |
return $status; | |
} | |
try { | |
$examDetails = ExamService::getInstance()->getExamDetailsByExamId($request->examId); | |
if($examDetails->examregID){ | |
$sql = "SELECT ers.studentID as studentId,e.examID as examId,e.examDate,e.examStartTime ,e.examEndTime FROM exam e | |
INNER JOIN exam_reg_studentsubject erss ON erss.subjectID = e.subjectID AND erss.examregID = e.examregID | |
INNER JOIN exam_reg_studentchallan ers ON ers.examregID = e.examregID AND ers.studentID = erss.studentID | |
WHERE e.examID IN ($request->examId) AND erss.studentID IN ($request->studentId) AND ers.paid =1"; | |
}else if($examDetails->supplyRegId){ | |
$sql = "SELECT ers.studentID as studentId,e.examID as examId,e.examDate,e.examStartTime ,e.examEndTime FROM exam e | |
INNER JOIN exam er ON er.subjectID = e.subjectID AND er.batchID = e.batchID AND er.semID = e.semID AND er.examregID IS NOT NULL | |
INNER JOIN exam_supplementary_student_subjects erss ON erss.exam_supplementary_id = e.supply_examreg_id AND erss.examID = er.examID | |
INNER JOIN exam_supplementary_student_details ers ON ers.exam_supplementary_id = e.supply_examreg_id AND ers.studentID = erss.studentID | |
WHERE e.examID IN ($request->examId) AND erss.studentID IN ($request->studentId) AND ers.paid =1"; | |
}else{ | |
return $status; | |
} | |
$studentExam = $this->executeQueryForObject($sql); | |
if($studentExam->examDate && $studentExam->examStartTime && $studentExam->examEndTime){ | |
$today = strtotime(date("Y-m-d")); | |
$currentTime = strtotime(date("h:i A")); | |
$examDate = strtotime($studentExam->examDate); | |
if ($today == $examDate) { | |
$startTime = strtotime($studentExam->examStartTime); | |
$endTime = strtotime($studentExam->examEndTime); | |
if (($currentTime >= $startTime) && ($currentTime < $endTime)) { | |
$status = true; | |
} | |
} | |
} | |
return $status; | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
/** | |
* Get student exam details by examId,studentId | |
* @param Array | |
* @return Array | |
* @throws ProfessionalException | |
*/ | |
public function htmlEntityDecodeArrayOfObjects($result) | |
{ | |
try { | |
$final = []; | |
foreach ($result as $value) { | |
$obj = []; | |
foreach ($value as $key => $val) { | |
$obj[$key] = html_entity_decode($val); | |
} | |
$obj = (Object) $obj; | |
$final[] = $obj; | |
} | |
return $final; | |
} catch (\Exception $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
/** | |
* Check file exist using url | |
* | |
* | |
**/ | |
public function url_exists($url) { | |
$headers = @get_headers($url); | |
return $headers && strpos($headers[0], '200') !== false; | |
} | |
/** | |
* GET CLUSTER DETAILS | |
* @param int $clusterId | |
* @return object | |
* @throws ProfessionalException | |
* @author Midhun Shaji | |
*/ | |
public function getClusterDetails($clusterId){ | |
$clusterId = $this->realEscapeString($clusterId); | |
$sql = "SELECT id, `name` , properties->>'$.clusterCategory' as clusterCategory FROM cluster WHERE id = '$clusterId'"; | |
try{ | |
return $this->executeQueryForObject($sql); | |
}catch(\Exception $e){ | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
} | |
} | |