Skip to content

Instantly share code, notes, and snippets.

@hackimov
Last active March 9, 2020 06:19
Show Gist options
  • Save hackimov/870f04f00afeeeb2f1bc80030ccef648 to your computer and use it in GitHub Desktop.
Save hackimov/870f04f00afeeeb2f1bc80030ccef648 to your computer and use it in GitHub Desktop.
SQL TRICKS.
<?
/* created by ANNA
* edited by Hackimov
*/
require_once($_SERVER['DOCUMENT_ROOT']."/bitrix/modules/main/include/prolog_before.php");?>
<?php
$type = $_REQUEST["type"];
$request = json_decode(file_get_contents('php://input'));
// Получаем доп. обязательные поля тип реестра
function getFilterValue ($code) {
$filters = json_decode($_REQUEST["filter"]);
foreach ($filters as $filter) {
if ($filter->property == $code) {
return $filter->value;
}
}
return false;
}
$extra_fields = array();
if (($regtypeIDF = getFilterValue('RegistrTypeId')) > 0) {
$sqlFields = "SELECT mc.CFId, mc.FieldName, mc.FieldType, ml.ComplNeed, ml.ComplParId, mc.FieldOptions
FROM md_complfields mc
LEFT JOIN md_complfields mcParent ON mcParent.CFId=mc.CFParentId
INNER JOIN md_licensecomplpar ml ON ml.CFId = mc.CFId
WHERE ml.RegistrTypeId = $regtypeIDF AND ml.ComplNeed = 1 AND (mc.CFParentId is NULL OR mcParent.FieldType = 6)";
$rsTypeFields = $DBH->prepare($sqlFields);
$rsTypeFields->execute();
$arTypeFields = $rsTypeFields->fetchAll(PDO::FETCH_ASSOC);
foreach ($arTypeFields as $field) {
$extra_fields[] = "
(SELECT mc.Value FROM md_complparvalues mc
LEFT JOIN md_licensecomplpar mlc ON mlc.ComplParId = mc.ComplParId AND mlc.ComplNeed = 1
WHERE mc.LicId = l.LicId AND mc.ComplParId = {$field['ComplParId']}
) AS field_{$field['ComplParId']}
";
}
}
$extra_fields = implode(', ', $extra_fields);
$mainSql = 'SELECT SQL_CALC_FOUND_ROWS l.LicId, -- IF(lt.Type=0,lt.OrgId,lt.PersonId) AS LicensiatId,
l.LicensiatId AS LicensiatId, -- IF(lt.Type=0,lt.OrgId,lt.PersonId) AS UL_FLId,
-- lt.Type AS LicensiatType,
l.lic_LicId,
l.LicKindId,
lk.LicKindName_RU,
lk.LicKindName_UZ, -- lt.Type AS LicKindFaceType,
l.RootID,
l.LicSer,
l.LicNumb,
l.BlankNumb,
l.NumbInReestr,
l.BlankDate,
l.LicINN,
l.LicQrCode,
l.LicPin,
l.LicensiatName_RU,
l.LicensiatName_UZ,
l.LicensiatShortName_RU,
l.LicensiatShortName_UZ,
l.GuvNumb,
l.GuvNumbInReestr,
l.GuvRegDate,
l.GuvOutDate,
l.LicOPF,
l.OPFId,
IF(mo.isDeleted,
CONCAT(CONCAT(mo.OPFCode,\' - \',mo.OPFName_RU)," ('.MDLang::GetMessage("ADDITIONAL_LABEL_IS_OLDER").')") ,CONCAT(mo.OPFCode,\' - \',mo.OPFName_RU)) AS LicOPFFullName_RU,
IF(mo.isDeleted, CONCAT(CONCAT(mo.OPFCode,\' - \',mo.OPFName_UZ)," ('.MDLang::GetMessage("ADDITIONAL_LABEL_IS_OLDER").')") ,CONCAT(mo.OPFCode,\' - \',mo.OPFName_UZ)) AS LicOPFFullName_UZ,
IF(mrl.isDeleted, CONCAT(mrl.CODE_SOATO, \' - \', mrl.NAME_REGION_RU,\' ('.MDLang::GetMessage("ADDITIONAL_LABEL_IS_OLDER").')\') ,CONCAT(mrl.CODE_SOATO, \' - \', mrl.NAME_REGION_RU)) AS NameWithCode_RU,
IF(mrl.isDeleted, CONCAT(mrl.CODE_SOATO, \' - \', mrl.NAME_REGION_UZ,\' ('.MDLang::GetMessage("ADDITIONAL_LABEL_IS_OLDER").')\') ,CONCAT(mrl.CODE_SOATO, \' - \', mrl.NAME_REGION_UZ)) AS NameWithCode_UZ,
l.LicPostIndex,
l.LicAddress,
l.LicPaspSer,
l.LicPaspNumb,
l.LicPaspOuter,
l.LicPaspOutDate,
l.LicPaspEndDate,
l.LicPaspSer AS BossPaspSer,
l.LicPaspNumb AS BossPaspNumb,
l.LicPaspOuter AS BossPaspOuter,
l.LicPaspOutDate AS BossPaspOutDate,
l.LicPaspEndDate AS BossPaspEndDate,
l.LicKind,
l.IsLicContr,
l.RegisterId,
r.RName_RU,
r.RName_UZ,
l.DATE_CREATE,
l.ID_USER_CREATE,
UserName(l.ID_USER_CREATE) AS NAME_USER_CREATE,
l.DATE_EDIT,
l.ID_USER_EDIT,
UserName(l.ID_USER_EDIT) AS NAME_USER_EDIT,
l.LicKindText,
l.REG_TIME,
l.REGER,
UserName(l.REGER) AS REGER_NAME,
l.AddressOfActivity,
/*lt.Name_RU AS RefLicensiatName_RU,
lt.Name_UZ AS RefLicensiatName_UZ,
lt.OrgShortName_RU AS RefShortName_RU,
lt.OrgShortName_UZ AS RefShortName_UZ,*/
/* lt.PersonPaspSer AS RefPaspSer,
lt.PersonPaspNumb AS RefPaspNumb,
lt.PersonPaspOuter AS RefPaspOuter,
lt.PersonPaspOutDate AS RefPaspOutDate,
lt.PersonPaspEndDate AS RefPaspEndDate, */
/*moOrg.OPFName_RU AS RefOPFName_RU,
moOrg.OPFName_UZ AS RefOPFName_UZ,
lt.Post AS RefLicPostIndex,
lt.Address AS RefLicAddress,
lt.AddressOfActivity AS RefAddressOfActivity,
lt.OPFId AS RefLicOPF,
moOrg.OPFId AS RefOPFCode,
CONCAT(moOrg.OPFCode,\' - \',moOrg.OPFName_RU) AS RefLicOPFName_RU,
CONCAT(moOrg.OPFCode,\' - \',moOrg.OPFName_UZ) AS RefLicOPFName_UZ,*/
-- таблица изменений (операций)
ls.LSRId,
IF(l.REG_TIME IS NULL, "", "*") AS State,
lst.Name_RU AS LSRStateName_RU,
lst.Name_UZ AS LSRStateName_UZ,
ls.OperCode AS LastOperCode,
lst.PostCodes AS LastOperPostCodes,
IF(ls.REGER is NULL, fs.LicStatus , ls.LicStatus) AS LicStatus,
ls.LSRBeg,
ls.LSREnd,
ls.LSREnd is NULL AS isUnlimited,
ls.TimesCount,
ls.TimesCount IS NULL AS isUnlimitedCount,
IF(ls.LSRPeriod=0, NULL, ls.LSRPeriod) AS LSRPeriod,
ls.LSRMinSal,
ls.LSRStateDutyInMS,
ROUND(IFNULL(ls.LSRMinSal,0)*IFNULL(ls.LSRStateDutyInMS,0),2) AS DutyInSum,
ls.LSRStateDuty,
ls.LSRStateDutyDate,
IF(IFNULL(ls.LSRStateDutyPeriod,0)=0,\''.MDLang::GetMessage("LABEL_UNLIMITED").'\',ls.LSRStateDutyPeriod) AS LSRStateDutyPeriod,
-- ls.LSRStateDutyPeriod,
ls.LSRStateDate,
ls.LSRStateReason,
ls.LSRApplayInpDate,
ls.LSRBankAccount,
ls.BankId,
ls.LSRBank,
ls.LSREMail,
ls.LSRPhone,
ls.LSRFax,
ls.LSRHead,
ls.LSRRem,
ls.StopDays,
ls.REGER AS LastOperReger,
ls.LSRNumber,
ls.LSRDate,
ls.LSROrdNumber,
ls.lic_LSRId,
ls.IsBegInput,
ls.Sign IS NOT NULL AS isSigned,
IF((SELECT COUNT(*) FROM md_licenses WHERE lic_LicId=l.LicId)=0,0,1) AS HasChild,
-- CONCAT(IF(pl.LicId IS NOT NULL,IF(fs.OperCode=\'BLANC_DOUBLE\',\'Дубликат \',\'Переоформление \'),\'\'),pl.LicSer,\' \',pl.LicNumb) AS PrevLicName_RU,
-- fs.OperCode AS FirstOperCode,
prevOper.Name_RU AS PrevLSRStateName_RU,
prevOper.Name_UZ AS PrevLSRStateName_UZ,
postl.LicId AS PostLicId,
-- l.IsBegInput,
r.LicensiarId,
r.RegistrTypeId,
mr1.RT_KindIsNoLic,
l.ID_REGION,
/*mr.NAME_REGION_RU AS RefLicRegion_RU,
mr.NAME_REGION_UZ AS RefLicRegion_UZ,
mr.ID_REGION AS RefSoato,*/
l.NotifyDate,
l.ReplyNotifyDate,
ls.IsPerionInYearLicense,
' . (!empty($extra_fields) ? $extra_fields . ',' : '') . '
@LicExpiredDate := GetLicenseExpiredDate(l.LicId) AS LicExpiredDate,
DATEDIFF(@LicExpiredDate, NOW()) AS DaysLeft,
IF(ls.REGER IS NOT NULL AND IFNULL(ls.LicStatus, 0)=1 AND @LicExpiredDate IS NOT NULL,
IF(l.NotifyDate IS NULL, DATEDIFF(@LicExpiredDate, NOW()) <= mr1.DaysToNotify,
l.ReplyNotifyDate IS NULL AND DATEDIFF(NOW(), l.NotifyDate) >= mr1.DaysToReplyNotify), 0) as isExpired,
@LicExpiredDate <=> ls.LSREnd AS isLicenseEnd, -- Просрочена лицензия, если нет значит просрочена оплата
CONCAT(IF(l.LicNotCorrect, CONCAT(l.LicNotCorrectRem, ";"), ""),
(SELECT IFNULL(GROUP_CONCAT(IF(ml.LSRNotCorrect, CONCAT(mo.Name_RU," - ", ml.LSRNotCorrectRem), null) SEPARATOR ";"), "")
FROM md_licstateregrad ml
LEFT JOIN md_operation mo ON mo.OperCode=ml.OperCode
WHERE ml.LicId=l.LicId)) AS LicNotCorrectRem,
CONCAT(IFNULL(l.LicSer, "")," ", IFNULL(l.LicNumb, ""), IF(l.BlankNumb IS NOT NULL,CONCAT(" ",IFNULL("'.MDLang::GetMessage("MULTI_BLANK_NUMB").'","")," ", l.BlankNumb), "")) AS RefBoxText
FROM md_licenses l
LEFT JOIN md_licensekinds lk ON lk.LicKindId = l.LicKindId
LEFT JOIN md_registers r ON r.RegisterId = l.RegisterId
LEFT JOIN md_registrtypes mr1 ON mr1.RegistrTypeId=r.RegistrTypeId -- LEFT JOIN md_licensiat lt ON lt.LicensiatId=l.LicensiatId
-- LEFT JOIN md_region mr ON mr.ID_REGION=lt.ID_REGION
LEFT JOIN md_region mrl ON mrl.ID_REGION=l.ID_REGION
LEFT JOIN md_opf mo ON mo.OPFId = l.OPFId -- LEFT JOIN md_opf moOrg ON moOrg.OPFId = lt.OPFId
LEFT JOIN md_licstateregrad ls ON ls.LSRId=
(SELECT ls2.LSRId
FROM md_licstateregrad ls2
WHERE ls2.LicId=l.LicId
AND ls2.LSRDate<=>
(SELECT IF(SUM(IF(ml.LSRDate IS NULL, 1, 0)) > 0, NULL, MAX(ml.LSRDate))
FROM md_licstateregrad ml
WHERE ml.LicId=l.LicId)
ORDER BY ls2.LicId DESC
LIMIT 1)
LEFT JOIN md_licstateregrad fs ON fs.LSRId=
(SELECT fs2.LSRId
FROM md_licstateregrad fs2
WHERE fs2.LicId=l.LicId
AND fs2.LSRDate IS NOT NULL
AND fs2.LSRDate<=>
(SELECT MAX(ml.LSRDate)
FROM md_licstateregrad ml
WHERE ml.LicId=l.LicId
AND ml.LSRId<>ls.LSRId)
LIMIT 1)
LEFT JOIN md_operation lst ON lst.OperCode=ls.OperCode
LEFT JOIN md_operation prevOper ON prevOper.OperCode = fs.OperCode
LEFT JOIN md_licenses pl ON pl.LicId=l.lic_LicId
LEFT JOIN md_licenses postl ON postl.lic_LicId=l.LicId';
switch($type){
case "read":
$mapping = array(
"LicensiatName".MDLang::GetPostFix()=>"l.LicensiatName".MDLang::GetPostFix(),
"LicKindId"=>"l.LicKindId",
"OperCode"=>"ls.OperCode",
"BlankDate_from"=>"l.BlankDate",
"BlankDate_to"=>"l.BlankDate",
"LicSer"=>"l.LicSer",
"LicNumb"=>"l.LicNumb",
"NumbInReestr"=>"l.NumbInReestr",
//"RegistrTypeId"=>"r.RegistrTypeId",
//"LicensiarId"=>"r.LicensiarId",
"IsBegInput"=>"l.IsBegInput",
"LicINN"=>"l.LicINN",
"LicenseState"=>"IFNULL(IF(ls.REGER is NULL, fs.LicStatus , ls.LicStatus), 0)",
"LicId"=>"l.LicId",
"isExpired"=>"IF(ls.REGER IS NOT NULL AND IFNULL(ls.LicStatus, 0)=1 AND GetLicenseExpiredDate(l.LicId) IS NOT NULL,
IF(l.NotifyDate IS NULL, DATEDIFF(GetLicenseExpiredDate(l.LicId), NOW()) <= mr1.DaysToNotify,
l.ReplyNotifyDate IS NULL AND DATEDIFF(NOW(), l.NotifyDate) >= mr1.DaysToReplyNotify), 0)",
"onlyIncorrect"=>"(l.LicNotCorrect OR EXISTS(SELECT * FROM md_licstateregrad ml WHERE ml.LSRNotCorrect AND ml.LicId=l.LicId))"
);
$page = $_REQUEST["page"];
$start = $_REQUEST["start"];
$limit = $_REQUEST["limit"];
$sort = json_decode($_REQUEST["sort"]);
$lastAddedId = $DB->ForSql($_REQUEST["lastAddedId"]);
$refBoxLicId = $_REQUEST['LicId'];
$id = $_REQUEST["id"];
$historyId = $DB->ForSql($_REQUEST["historyId"]);
$onlyConfirmed = $_REQUEST["onlyConfirmed"];
$nextState = $_REQUEST["nextState"];
$filters = json_decode($_REQUEST["filter"]);
$where = "";
if($filters){
foreach ($filters as $filter) {
if(!isset($filter->value) || $filter->value==='') continue;
$prop = $filter->property;
if(($prop == "isExpired" && !$filter->value) || ($prop == "onlyIncorrect" && !$filter->value)) continue;
$field = $mapping[$prop] ? $mapping[$prop] : $filter->property;
$compareType;
if($prop == "ID_REGION"){
$idRegion = $filter->value;
}
if($prop == "RegistrTypeId"){
$registrTypeId = $filter->value;
continue;
}
if($prop == "LicensiarId"){
$licensiarId = $filter->value;
continue;
}
if($prop == "LicenseState"){
$LicenseState = $filter->value;
continue;
}
switch($filter->type){
case "like":
$compareType = "like";
break;
case "in":
$compareType = "IN";
break;
case "date_from":
$compareType = ">=";
break;
case "date_to":
$compareType = "<=";
break;
case "custom";
continue 2;
case "kinds_multi":
$compareType = "kinds_multi";
break;
default:
$compareType="=";
}
if(!preg_match('/AND(\s+)?$/', $where) && !empty($where)){
$where.=" AND ";
}
if($compareType == "IN"){
$where .= " FIND_IN_SET({$field},:{$prop})";
} else if ($compareType == "kinds_multi") {
if (is_array($filter->value) && count($filter->value) > 0) {
$valtmp = $filter->value;
$valtmp = array_filter($valtmp, function ($val) {
return (is_numeric($val) && $val > 0) ? true : false;
});
$valtmp = implode(', ', $valtmp);
$where .= " (l.LicKindId IN ($valtmp)
OR EXISTS(SELECT * FROM md_par4kind2lic mp WHERE mp.LicId = l.LicId AND mp.LicKindId IN ($valtmp) LIMIT 1)) ";
} else {
continue;
}
} else {
$where .= "{$field} $compareType :{$prop}";
}
}
}
/*$RegistrTypeId = $_REQUEST["RegistrTypeId"];
if(!empty($where)){
$where.=" AND ";
}
$where.=" r.RegistrTypeId=$RegistrTypeId ";*/
$sql = "SELECT mr.RegisterId FROM md_registers mr WHERE mr.RegistrTypeId=:RegistrTypeId and mr.LicensiarId=:LicensiarId";
$result = $DBH->prepare($sql);
$result->bindValue(":RegistrTypeId", $registrTypeId);
$result->bindValue(":LicensiarId", $licensiarId);
$result->execute();
$data = $result->fetch(PDO::FETCH_ASSOC);
$registrId = $data["RegisterId"];
if($registrId) {
if (!preg_match('/AND(\s+)?$/', $where) && !empty($where))
$where .= " AND ";
$where .= " l.RegisterId=:registrId ";
}
if($LicenseState !== false && $LicenseState !== null) {
if (!preg_match('/AND(\s+)?$/', $where) && !empty($where))
$where .= " AND ";
$where .= " (IFNULL(IF(ls.REGER is NULL, fs.LicStatus , ls.LicStatus), 0) = $LicenseState) ";
}
if($historyId){
$sql = "SET @child = $historyId;
SET @parent = $historyId;";
$DBH->exec($sql);
$childs = $currentChilds = $historyId;
$sql = "SELECT GROUP_CONCAT(ml.LicId) as childs FROM md_licenses ml WHERE FIND_IN_SET(ml.lic_LicId,:childs)";
while($currentChilds){
$result = $DBH->prepare($sql);
$result->bindValue(":childs", $currentChilds);
$result->execute();
$data = $result->fetch(PDO::FETCH_ASSOC);
$currentChilds = $data["childs"];
if($currentChilds){
$childs .= "," . $currentChilds;
}
}
$parent = $historyId;
$parents = "";
$sql = "SELECT ml.lic_LicId as parent FROM md_licenses ml WHERE ml.LicId=:parent";
while($parent){
$result = $DBH->prepare($sql);
$result->bindValue(":parent", $parent);
$result->execute();
$data = $result->fetch(PDO::FETCH_ASSOC);
$parent = $data["parent"];
if(!$parent) continue;
if($parents){
$parents .= ",";
}
$parents .= $parent;
}
$licenses = $childs;
if($parents){
if($licenses)
$licenses.=",";
$licenses .= $parents;
}
/*$sql = "SELECT GROUP_CONCAT(lv) AS LicensesChain
FROM (
SELECT (SELECT @parent:= GROUP_CONCAT(ml1.lic_LicId)
FROM md_licenses ml1
WHERE FIND_IN_SET(ml1.LicId, @parent) OR ml1.LicId=@parent) AS lv
FROM md_licenses ml
WHERE @parent != 0
UNION
SELECT @child:=(SELECT GROUP_CONCAT(ml1.LicId)
FROM md_licenses ml1
WHERE FIND_IN_SET(ml1.lic_LicId, @child) OR ml1.LicId=@child) AS lv
FROM md_licenses ml
WHERE @child != 0) a;";
$result = $DBH->query($sql);
$row = $result->fetch(PDO::FETCH_ASSOC);
$licensesChain = $row["LicensesChain"];*/
if($licenses){
if(!preg_match('/AND(\s+)?$/', $where) && !empty($where))
$where .= " AND ";
$where .= " FIND_IN_SET(l.LicId, '$licenses') ";
}
}
if($onlyConfirmed){
if(!preg_match('/AND(\s+)?$/', $where) && !empty($where))
$where .= " AND ";
$where .= " ls.REGER IS NOT NULL ";
}
if($nextState){
if ($nextState == "END") {
$l = "(";
$r = ")";
$extra = " OR FIND_IN_SET('STOP', lst.PostCodes) ";
} else {
$l = $r = $extra = '';
}
if(!preg_match('/AND(\s+)?$/', $where) && !empty($where))
$where .= " AND $l";
else
$where .= "$l";
$where .= " FIND_IN_SET('".$nextState."', lst.PostCodes) ";
$where .= $extra.$r;
}
if($id){
$where = " WHERE l.LicId=:id ";
}else {
$where = (!empty($where) ? "WHERE (" . $where . ")" : "");
}
if($idRegion){
if(!preg_match('/AND(\s+)?$/', $where) && !empty($where))
$where .= " AND ";
$where .= " FIND_IN_SET(:ID_REGION, mrl.ParentIds) ";
}
if($refBoxLicId){
if(!preg_match('/AND(\s+)?$/', $where) && !empty($where)){
$where.=" AND ";
}else{
$where = " WHERE ";
}
$where.=" l.LicId = {$refBoxLicId} ";
}
//ЮД получаем определённую лицензию для вывода информации в разделе "Протоколы"
if($lastAddedId){
if(!preg_match('/AND(\s+)?$/', $where) && !empty($where)){
$where.=" AND ";
}else{
$where = " WHERE ";
}
$where.=" l.LicId<>{$lastAddedId} ";
}
$sortquery="l.BlankDate DESC";
if($sort) {
$sortquery=$sort[0]->property." ".$sort[0]->direction;
}
//$sql = $mainSql." ".$where." ORDER BY l.BlankDate DESC";
$sql = $mainSql." ".$where." ORDER BY ".$sortquery;
//АИ если нам пришел айдишник, то лимиты не нужны
if(!$id && (isset($start) && isset($limit))){
$sql .= ' LIMIT '.$start.','.$limit;
}
$countSql = "SELECT FOUND_ROWS() AS CNT";
$result = $DBH->prepare($sql);
$countResult = $DBH->prepare($countSql);
if($filters) {
foreach ($filters as $key=>$filter) {
if(!isset($filter->value) || $filter->value==='' || empty($filter->value)) continue;
if($filter->property == "RegistrTypeId"){
continue;
}
if($filter->property == "LicensiarId"){
continue;
}
if($filter->property == "LicenseState"){
continue;
}
if ($filter->type == "kinds_multi") {
continue;
}
if(($filter->property == "isExpired" && !$filter->value) || ($filter->property == "onlyIncorrect" && !$filter->value)) continue;
switch($filter->type){
case "like":
$value = "%".$filter->value."%";
break;
case "in":
$value = is_array($filter->value) ? join(",", $filter->value) : $filter->value;
break;
case "date_to":
case "date_from":
$value = ConvertDateTime($filter->value, "YYYY-MM-DD");
break;
case "custom";
continue 2;
default:
$value = $filter->value;
}
$result->bindValue(":".$filter->property, $value);
//$countResult->bindValue(":".$filter->property, $value);
}
}
if($id){
$result->bindValue(":id", $id);
}
if($idRegion){
$result->bindValue(":ID_REGION", $idRegion);
//$countResult->bindValue(":ID_REGION", $idRegion);
}
if(!$id && $registrId){
$result->bindValue(":registrId", $registrId);
}
$result->execute();
$data = $result->fetchAll(PDO::FETCH_ASSOC);
if(empty($refBoxLicId) && empty($id)) {
$countResult->execute();
$count = $countResult->fetch();
$count = $count["CNT"];
}
if($lastAddedId && $page == 1) {
$sql = $mainSql." WHERE l.LicId={$lastAddedId}";
$result = $DBH->query($sql);
$rowData = $result->fetch(PDO::FETCH_ASSOC);
array_unshift($data,$rowData);
}
// АК получение значений обязательных полей лицензии
/* foreach ($data as &$license) {
$sqlRequiredFields = "
SELECT
mc.ValId,
mc.LSRId,
mlc.RegistrTypeId,
mlc.ComplNeed,
mc.ComplParId,
mc.Value
FROM md_complparvalues mc
LEFT JOIN md_licensecomplpar mlc ON mlc.ComplParId = mc.ComplParId
WHERE mc.LicId = {$license['LicId']} AND mlc.ComplNeed = 1
";
$rsRequiredFields = $DBH->prepare($sqlRequiredFields);
$rsRequiredFields->execute();
$arFieldsValue = $rsRequiredFields->fetchAll(PDO::FETCH_ASSOC);
foreach ($arFieldsValue as $fieldValues) {
$license['field_' . $fieldValues['ComplParId']] = \Micros\Fields\base::getValue($fieldValues['Value'], $fieldValues['ComplParId']);
}
} */
echo json_encode(array("data"=>$data, "total"=>($refBoxLicId || $id ? 1 : $count)));
break;
case "add":
$isAdd = true;
case "update":
if(MDUserRights::CheckRights("LICENSES") < MDUserRights::WRITE){
die(json_encode(array("success"=>false, "msg"=>MDLang::GetMessage("MSG_NOT_RIGHTS"))));
}
if(empty($request)) die();
global $USER;
$DBH->beginTransaction();
try {
/*if($request->LastOperCode == "DOUBLE" || $request->LastOperCode == "REFORM" ||
$request->LastOperCode == "LONG_WITH_NEW_BLANK"){
$request->lic_LicId = $request->LicId;
$request->LicId = null;
$request->LSRId = null;
$isAdd = true;
}*/
/*
* АК проверяем окончания регистрации вид деятельности
*/
if ($request->LicKindId > 0 && $request->LSRBeg) {
$sqlcheck = "SELECT ml.LicKindName" . MDLang::GetPostFix() . " as name, ml.LicKindActEnd AS date, ml.LicKindIsExclusion AS ex FROM md_licensekinds ml WHERE ml.LicKindId = " . (int)$request->LicKindId;
$resultcheck = $DBH->prepare($sqlcheck);
$resultcheck->execute();
$archeck = $resultcheck->fetch(PDO::FETCH_ASSOC);
// срок окончания регистрации
$kindEndDate = date_create($archeck['date']);
// срок начало действия лицензии
$licenseBeginDate = date_create($request->LSRBeg);
// Начало действия лицензии не должен перевешать дату окончания действия лицензии
if ($licenseBeginDate > $kindEndDate && $archeck['ex']) { // Еще и галочка "Исключение"($archeck['ex']) тоже должна быть у вид деятельности
$kindEndDateFormat = date_format($kindEndDate, "d.m.Y");
$licenseBeginDateFormat = date_format($licenseBeginDate, "d.m.Y");
//$errorMess = "Невозможно добавить лицензию. Дата действия ({$licenseBeginDateFormat}) лицензии позже чем дата окончания действия ({$kindEndDateFormat}) вид деятельности ({$archeck['name']})";
$errorMess = MDLang::GetMessage("ERROR_NO_ADD_UPDATE_LICENSE_ERROR_BEGIN_DATE", array(
"#LICENSE_BEGING_DATE#" => $licenseBeginDateFormat,
"#KIND_END_DATE#" => $kindEndDateFormat,
"#KIND_NAME#" => $archeck['name'],
));
die(json_encode(array("success" => false, "msg" => $errorMess)));
}
}
if (!$isAdd && !empty($request->LicId)) {
$DBH->exec("SET @ID={$request->LicId}");
}
if(!$request->LicensiatId){
$sql = "SELECT ml.LicensiatId FROM md_licensiat ml WHERE ml.TIN=:tin LIMIT 1";
$result = $DBH->prepare($sql);
$result->bindValue(":tin", $request->LicINN);
$result->execute();
$data = $result->fetch(PDO::FETCH_ASSOC);
if($data){
$DBH->exec("SET @LicensiatId={$data["LicensiatId"]}");
}
$sql = "CALL iu_Licensiat(@LicensiatId, :OrgId, :PersonId, :TIN, :Name_RU, :Name_UZ,
:OPFId, :OrgOKPO, :ID_REGION, :OrgBeg, :OrgEnd, :Post, :Address, :Phone,
:EMail, :OrgBossPIN, :OrgBossName, :OrgStatus, :Comment, :OrgType, :Type, :GuvNumb, :GuvNumbInReestr,
:GuvRegDate, :BankAccount, :BankId, :AddressOfActivity, :OrgShortName_RU, :OrgShortName_UZ,
:PersonPaspSer, :PersonPaspNumb, :PersonPaspOuter, :PersonPaspOutDate, :PersonPaspEndDate,
:PersonPIN, :PersonBeg, :PersonEnd, :UserId)";
$result = $DBH->prepare($sql);
$result->bindValue(":OrgId", $request->OrgId);
$result->bindValue(":PersonId", $request->PersonId);
$result->bindValue(":TIN", $request->LicINN);
$result->bindValue(":Name_RU", $request->LicensiatName_RU);
$result->bindValue(":Name_UZ", $request->LicensiatName_UZ);
$result->bindValue(":OPFId", $request->OPFId);
$result->bindValue(":OrgOKPO", null);
$result->bindValue(":ID_REGION", $request->ID_REGION);
$result->bindValue(":OrgBeg", null);
$result->bindValue(":OrgEnd", null);
$result->bindValue(":Post", $request->LicPostIndex);
$result->bindValue(":Address", $request->LicAddress);
$result->bindValue(":Phone", $request->LSRPhone);
$result->bindValue(":EMail", $request->LSREMail);
$result->bindValue(":OrgBossPIN", null);
$result->bindValue(":OrgBossName", $request->LSRHead);
$result->bindValue(":OrgStatus", null);
$result->bindValue(":Comment", null);
$result->bindValue(":OrgType", null);
$result->bindValue(":Type", $request->LicensiatType);
$result->bindValue(":GuvNumb", $request->GuvNumb);
$result->bindValue(":GuvNumbInReestr", $request->GuvNumbInReestr);
$result->bindValue(":GuvRegDate", $request->GuvRegDate);
$result->bindValue(":BankAccount", $request->LSRBankAccount);
$result->bindValue(":BankId", $request->BankId);
$result->bindValue(":AddressOfActivity", $request->AddressOfActivity);
$result->bindValue(":OrgShortName_RU", $request->LicensiatShortName_RU);
$result->bindValue(":OrgShortName_UZ", $request->LicensiatShortName_UZ);
$result->bindValue(":PersonPaspSer", $request->LicPaspSer);
$result->bindValue(":PersonPaspNumb", $request->LicPaspNumb);
$result->bindValue(":PersonPaspOuter", $request->LicPaspOuter);
$result->bindValue(":PersonPaspOutDate", $request->LicPaspOutDate);
$result->bindValue(":PersonPaspEndDate", $request->LicPaspEndDate);
$result->bindValue(":PersonPIN", null);
$result->bindValue(":PersonBeg", null);
$result->bindValue(":PersonEnd", null);
$result->bindValue(":UserId", $USER->GetID());
$result->execute();
$result = $DBH->query("SELECT @LicensiatId as ID;");
$data = $result->fetch(PDO::FETCH_ASSOC);
$request->LicensiatId = $data["ID"];
}
$sql = "CALL iu_Licenses_WEB(@ID, :lic_LicId, :licKindId, :LicSer, :LicNumb, :BlankNumb,
:NumbInReestr, :BlankDate, :LicINN, :LicQrCode, :LicPin, :LicensiatName_RU, :LicensiatName_UZ, :GuvNumb,
:GuvNumbInReestr, :GuvRegDate, :GuvOutDate, :LicOPF, :OPFId, :LicPostIndex,
:LicAddress, :AddressOfActivity, :LicPaspSer, :LicPaspNumb, :LicPaspOuter, :LicPaspOutDate,
:LicPaspEndDate, :LicKind, :IsLicContr, :RegisterTypeId, :LicensiarId, :UserId, :PersonId,
:OrgId, :LicensiatId, :LSRId, :lic_LSRId, :LSRBeg, :LSREnd, :LSRPeriod, :LSRMinSal, :LSRStateDutyInMS,
:LSRStateDuty, :LSRStateDutyDate, :LSRStateDutyPeriod, :LSRStateId, :LSRStateDate, :LSRStateReason,
:LSRApplayInpDate, :LSRBankAccount, :BankId, :LSRBank, :LSREMail, :LSRPhone, :LSRFax,
:LSRHead, :LSRRem, :OperCode, :StopDays, :IsBegInput, :LSRNumber, :LSRDate, :LSROrdNumber, :LicKindText,
:LicensiatShortName_RU, :LicensiatShortName_UZ, :ID_REGION, :ReqId, :TimesCount, :IsPerionInYearLicense)";
$result = $DBH->prepare($sql);
$isLicQrCode = $request->LicQrCode ? 1 : true;
$result->bindValue(":LicPin", $request->LicPin);
$result->bindValue(":LicQrCode", $isLicQrCode);
$result->bindValue(":lic_LicId", $request->lic_LicId);
$result->bindValue(":licKindId", $request->LicKindId);
$result->bindValue(":LicSer", $request->LicSer);
$result->bindValue(":LicNumb", $request->LicNumb);
$result->bindValue(":BlankNumb", $request->BlankNumb);
$result->bindValue(":NumbInReestr", $request->NumbInReestr);
$result->bindValue(":BlankDate", $request->BlankDate);
$result->bindValue(":LicINN", $request->LicINN);
$result->bindValue(":LicensiatName_RU", $request->LicensiatName_RU);
$result->bindValue(":LicensiatName_UZ", $request->LicensiatName_UZ);
$result->bindValue(":GuvNumb", $request->GuvNumb);
$result->bindValue(":GuvNumbInReestr", $request->GuvNumbInReestr);
$result->bindValue(":GuvRegDate", $request->GuvRegDate);
$result->bindValue(":GuvOutDate", $request->GuvOutDate);
$result->bindValue(":LicOPF", $request->LicOPF);
$result->bindValue(":OPFId", $request->OPFId);
$result->bindValue(":LicPostIndex", $request->LicPostIndex);
$result->bindValue(":LicAddress", $request->LicAddress);
$result->bindValue(":AddressOfActivity", $request->AddressOfActivity);
$result->bindValue(":LicPaspSer", $request->LicensiatType == 0 ? $request->BossPaspSer : $request->LicPaspSer);
$result->bindValue(":LicPaspNumb", $request->LicensiatType == 0 ? $request->BossPaspNumb : $request->LicPaspNumb);
$result->bindValue(":LicPaspOuter", $request->LicensiatType == 0 ? $request->BossPaspOuter : $request->LicPaspOuter);
$result->bindValue(":LicPaspOutDate", $request->LicensiatType == 0 ? $request->BossPaspOutDate : $request->LicPaspOutDate);
$result->bindValue(":LicPaspEndDate", $request->LicensiatType == 0 ? $request->BossPaspEndDate : $request->LicPaspEndDate);
$result->bindValue(":LicKind", $request->LicKind);
$result->bindValue(":IsLicContr", $request->IsLicContr);
$result->bindValue(":RegisterTypeId", $request->RegistrTypeId);
$result->bindValue(":LicensiarId", $request->LicensiarId);
$result->bindValue(":UserId", $USER->GetID());
$result->bindValue(":PersonId", null);//???
$result->bindValue(":OrgId", null);//???
$result->bindValue(":LicensiatId", $request->LicensiatId);
$result->bindValue(":LSRId", $request->LSRId);
$result->bindValue(":lic_LSRId", $request->lic_LSRId);
$result->bindValue(":LSRBeg", $request->LSRBeg);
$result->bindValue(":LSREnd", $request->isUnlimited ? null : $request->LSREnd);
$result->bindValue(":LSRPeriod", $request->isUnlimited ? 0 : $request->LSRPeriod);
$result->bindValue(":LSRMinSal", $request->LSRMinSal);
$result->bindValue(":LSRStateDutyInMS", $request->LSRStateDutyInMS);
$result->bindValue(":LSRStateDuty", $request->LSRStateDuty);
$result->bindValue(":LSRStateDutyDate", $request->LSRStateDutyDate);
$result->bindValue(":LSRStateDutyPeriod", $request->LSRStateDutyPeriod);
$result->bindValue(":LSRStateId", null);//???
$result->bindValue(":LSRStateDate", $request->LSRStateDate);
$result->bindValue(":LSRStateReason", $request->LSRStateReason);
$result->bindValue(":LSRApplayInpDate", $request->LSRApplayInpDate);
$result->bindValue(":LSRBankAccount", $request->LSRBankAccount);
$result->bindValue(":BankId", $request->BankId);
$result->bindValue(":LSRBank", $request->LSRBank);
$result->bindValue(":LSREMail", $request->LSREMail);
$result->bindValue(":LSRPhone", $request->LSRPhone);
$result->bindValue(":LSRFax", $request->LSRFax);
$result->bindValue(":LSRHead", $request->LSRHead);
$result->bindValue(":LSRRem", $request->LSRRem);
$result->bindValue(":OperCode", $request->LastOperCode);
$result->bindValue(":StopDays", $request->StopDays);
$result->bindValue(":IsBegInput", $request->IsBegInput);
$result->bindValue(":LSRNumber", $request->LSRNumber);
$result->bindValue(":LSRDate", $request->LSRDate);
$result->bindValue(":LSROrdNumber", $request->LSROrdNumber);
$result->bindValue(":LicKindText", $request->LicKindText);
$result->bindValue(":LicensiatShortName_RU", $request->LicensiatType == 0 ? $request->LicensiatShortName_RU : $request->LicensiatName_RU);
$result->bindValue(":LicensiatShortName_UZ", $request->LicensiatType == 0 ? $request->LicensiatShortName_UZ : $request->LicensiatName_UZ);
$result->bindValue(":ID_REGION", $request->ID_REGION);
$result->bindValue(":ReqId", $request->ReqId);
$result->bindValue(":TimesCount", $request->isUnlimitedCount ? null : $request->TimesCount);
$result->bindValue(":IsPerionInYearLicense", $request->isUnlimited ? 0 : $request->IsPerionInYearLicense, PDO::PARAM_BOOL);
$result->execute();
if($isAdd){
$result = $DBH->query("SELECT @ID as ID;");
$data = $result->fetch(PDO::FETCH_ASSOC);
$licId = $data["ID"];
}else{
$licId = $request->LicId;
}
if($request->ReqId){
$sql = "UPDATE md_docarchive md SET md.LicId=:LicId WHERE md.ReqId=:ReqId";
$result = $DBH->prepare($sql);
$result->bindValue(":LicId", $licId);
$result->bindValue(":ReqId", $request->ReqId);
$result->execute();
}
//АИ сохранение дополнительных полей
$additionalValues = (array)$request->additionalValues;
$sql = "CALL iu_ComplParValues(:ComplParId, :LicId, :Value)";
$result = $DBH->prepare($sql);
foreach($additionalValues as $complParId=>$value){
$result->bindValue(":ComplParId", $complParId);
$result->bindValue(":LicId", $licId);
$result->bindValue(":Value", \Micros\Fields\base::setValue($value, $complParId));
$result->execute();
}
//АИ сохранение разделов
$divisionValues = $request->divisionValues;
$sql = "CALL i_Par4Kind2Lic(:Ids, :LicId, :ReqId)";
$result = $DBH->prepare($sql);
$result->bindValue(":Ids", $divisionValues);
$result->bindValue(":LicId", $licId);
$result->bindValue(":ReqId", null);
$result->execute();
//АИ для начального ввода сразу регистрируем последний статус
if($request->IsBegInput && $isAdd){
$sql = "CALL ChangeLastLicenseStatus(:LicId, :UserId, :Status)";
$result = $DBH->prepare($sql);
$result->bindValue(":LicId", $licId);
$result->bindValue(":UserId", $USER->GetID());
$result->bindValue(":Status", true);
$result->execute();
}
$sql = $mainSql." WHERE l.LicId={$licId}";
$result = $DBH->query($sql);
$DBH->commit();
$rowData = $result->fetch(PDO::FETCH_ASSOC);
echo json_encode(array("success"=>true, "data"=>$rowData));
}catch (PDOException $e) {
$DBH->rollBack();
$error = MDLang::ParseError($DBH, $e);
echo json_encode(array("success"=>false, "msg"=>$error));
}
break;
case "delete":
if(empty($request)) die();
$ids = explode(",", $request->ids);
try {
// АК проверяем нет ли у лицензии привязанные заявки
if (is_array($ids) && count($ids) > 0) {
$requeryExits = false;
$error = false;
$sql = "SELECT
mr1.MCode,
mr.Number,
mr.AddresantTIN,
IFNULL(mr.LicensiatName COLLATE utf8_unicode_ci, mr.AddresantName_RU COLLATE utf8_unicode_ci) AS AddresantName
FROM md_requery mr
LEFT JOIN md_requeryrefers mr1 ON mr1.ReqRefId = mr.ReqRefId
WHERE mr.LicId IN(:LicId)";
$resultRequeries = $DBH->prepare($sql);
$resultRequeries->bindValue(':LicId', $request->ids);
$resultRequeries->execute();
$requeries = $resultRequeries->fetchAll(PDO::FETCH_ASSOC);
foreach ($requeries as $key => $requery) {
$requeryExits = true;
$requeries[$key]['NUM'] = $requery['MCode'] . '-' . str_pad($requery['Number'], 6, "0", STR_PAD_LEFT);
}
if ($requeryExits) {
$error = MDLang::GetMessage('ERROR_DONT_DELETE_LICENSE_CONNECT_REQUERIES') . "<br>";
$error .= "<table border=\"1\" style=\"border-collapse: collapse; margin-top: 10px;\">
<tr>
<th style=\"padding: 3px 4px;\">" . MDLang::GetMessage("LABEL_NO_REQUERY") . "</th>
<th style=\"padding: 3px 4px;\">" . MDLang::GetMessage("MULTI_ADRESANT_INN") . "</th>
<th style=\"padding: 3px 4px;\">" . MDLang::GetMessage("MULTI_ADRESANT_NAME") . "</th>
</tr>
";
foreach ($requeries as $requery) {
$error .= "
<tr>
<td style=\"padding: 3px 4px;\">{$requery['NUM']}</td>
<td style=\"padding: 3px 4px;\">{$requery['AddresantTIN']}</td>
<td style=\"padding: 3px 4px;\">{$requery['AddresantName']}</td>
</tr>
";
}
$error .= "</table>";
die(json_encode(array("success" => false, "msg" => $error)));
}
}
foreach($ids as $id) {
$sql = "CALL d_Licenses(:LicId)";
$result = $DBH->prepare($sql);
$result->bindValue(":LicId", $id);
$result->execute();
}
echo json_encode(array("success"=>true));
}catch (PDOException $e) {
$error = MDLang::ParseError($DBH, $e);
echo json_encode(array("success"=>false, "msg"=>$error));
}
break;
case "notify":
if(empty($request)) die();
$ids = explode(",", $request->ids);
$errors = "";
foreach ($ids as $id) {
try {
$DBH->beginTransaction();
//АИ получение лицензии для которой отправляется уведомление
$sql = $mainSql." WHERE l.LicId=:id";
$result = $DBH->prepare($sql);
$result->bindValue(":id", $id);
$result->execute();
$data = $result->fetch(PDO::FETCH_ASSOC);
//echo '<pre>'; print_r($data); echo '</pre>';
//АИ пропускаем, если лицензия не просрочена
if($data["isExpired"] == 0 && !$data["NotifyDate"]) continue;
$mail = $data["LSREMail"];
if(!$mail){
$msg=MDLang::GetMessage("MSG_NO_LICENSIAT_EMAIL_IN_LICENSE");
$msg=str_replace("#NAME#", $data["LicensiatName".MDLang::GetPostFix()], $msg);
$msg=str_replace("#SER#", $data["LicSer"], $msg);
$msg=str_replace("#NUMB#", $data["LicNumb"], $msg);
//throw new Exception("Не указан E-Mail лицензиата ".$data["LicensiatName_RU"]." в лицензии ".$data["LicSer"]." ".$data["LicNumb"]."!");
throw new Exception($msg);
}
$sql = "SELECT IF(DATEDIFF(GetLicenseExpiredDate(l.LicId), NOW()) <= mr1.DaysToNotify,
DATEDIFF(NOW(), l.NotifyDate) >= mr1.DaysToReplyNotify, 0) AS isReply
FROM md_licenses l
LEFT JOIN md_registers r ON r.RegisterId = l.RegisterId
LEFT JOIN md_registrtypes mr1 ON mr1.RegistrTypeId=r.RegistrTypeId
WHERE l.LicId=:id";
$result = $DBH->prepare($sql);
$result->bindValue(":id", $id);
$result->execute();
$data = $result->fetch(PDO::FETCH_ASSOC);
$isReply = $data["isReply"];
$sql = "UPDATE md_licenses ml SET ml.ReplyNotifyDate=".($isReply ? "NOW()" : "NULL").",
ml.NotifyDate=".(!$isReply ? "NOW()" : "ml.NotifyDate")." WHERE ml.LicId=:id";
$result = $DBH->prepare($sql);
$result->bindValue(":id", $id);
$result->execute();
$sql = "SELECT ml.LicensiarName_RU, ml.LicensiarName_UZ FROM md_registers mr
LEFT JOIN md_licensiar ml ON ml.LicensiarId=mr.LicensiarId
WHERE mr.RegisterId=:RegisterId";
$result = $DBH->prepare($sql);
$result->bindValue(":RegisterId", $data["RegisterId"]);
$result->execute();
$licensiarData = $result->fetch(PDO::FETCH_ASSOC);
$sendData = array(
"IS_REPLY_RU" => $data["ReplyNotifyDate"] ? "Повторное" : "",
"IS_REPLY_UZ" => $data["ReplyNotifyDate"] ? "Takroran" : "",
"LICENSIAT_NAME" => $data["LicensiatName_RU"],
"LICENSIAT_ADDRESS" => $data["LicAddress"],
"LICENSE_OR_RESOLUTION_RU" => "лицензии", //"лицензии/разрешения (рус.)",
"LICENSE_OR_RESOLUTION_UZ" => "litsenziya", //"лицензии/разрешения (узб.)",
"LICENSE_KIND_NAME_RU" => $data["LicKindName_RU"],
"LICENSE_KIND_NAME_UZ" => $data["LicKindName_UZ"],
"LICENSE_SERIAL" => $data["LicSer"],
"LICENSE_NUMBER" => $data["LicNumb"],
"LICENSE_BLANK_DATE" => date_format(date_create_from_format("Y-m-d", $data["BlankDate"]), "d.m.Y"),
"LICENSE_FROM_DATE" => date_format(date_create_from_format("Y-m-d", $data["LSRBeg"]), "d.m.Y"),
"LICENSE_TO_DATE" => date_format(date_create_from_format("Y-m-d", $data["LSREnd"]), "d.m.Y"),
"LICENSE_NUMBER_IN_REGISTR" => $data["NumbInReestr"],
"REGISTRAR_NAME_RU" => $licensiarData["LicensiarName_RU"],
"REGISTRAR_NAME_UZ" => $licensiarData["LicensiarName_UZ"],
"NOTIFY_TYPE_RU" => $data["isLicenseEnd"] ? "лицензии" : "госпошлины",//"лицензии/разрешения/госпошлины (рус.)",
"NOTIFY_TYPE_UZ" => $data["isLicenseEnd"] ? "litsenziyani" : "davlat bojini", //"лицензии/разрешения/госпошлины (узб.)",
"DAYS_LEFT" => $data["DaysLeft"] > 0 ? $data["DaysLeft"] : 0,
"LICENSE_OR_RESOLUTION_2_RU" => "лицензия", //"лицензия/разрешение (рус.)",
"LICENSE_OR_RESOLUTION_2_UZ" => "litsenziya", //"лицензия/разрешение (узб.)",
"LICENSE_LEFTED_ENDING_RU" => "а",//"окончание в слове прекращена(о) (рус.)",
"LICENSE_LEFTED_ENDING_UZ" => "а", //"окончание в слове прекращена(о) (узб.)",
"LICENSIAT_EMAIL" => $data["LSREMail"]
);
CEvent::Send("LICENSE_NOTIFY", "s1", $sendData, "N", 123);
$DBH->commit();
}catch (PDOException $e) {
$DBH->rollBack();
$error = MDLang::ParseError($DBH, $e);
$errors.=$error."<br>";
//echo json_encode(array("success"=>false, "msg"=>$error));
}catch(Exception $e){
$errors.=$e->getMessage()."<br>";
//echo json_encode(array("success"=>false, "msg"=>$e->getMessage()));
}
}
if($errors){
echo json_encode(array("success"=>false, "msg"=>$e->getMessage()));
}else {
echo json_encode(array("success" => true));
}
break;
case "check_data":
if(empty($request)) die();
try {
$sql = "CALL MarkNotCorrectLicensesByRegistr(:RegistrTypeId, :LicensiarId)";
$result = $DBH->prepare($sql);
$result->bindValue(":RegistrTypeId", $request->registrTypeId);
$result->bindValue(":LicensiarId", $request->licensiarId);
$result->execute();
echo json_encode(array("success"=>true));
}catch (PDOException $e) {
$error = MDLang::ParseError($DBH, $e);
echo json_encode(array("success"=>false, "msg"=>$error));
}
break;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment