' . "Zasob TABELA ID={$tblProblemsId} nie istnieje" . ''; //echo UserActivity::showSimpleList(); return; } $korespObj = ProcesHelper::getZasobTableInfo($tblKorespId); if (!$korespObj) { echo '
' . "Zasob TABELA ID={$tblKorespId} nie istnieje" . '
'; //echo UserActivity::showSimpleList(); return; } //UserActivity::add($tblProblemsId); $userAcl = User::getAcl(); $userAcl->fetchGroups(); if (!$userAcl->hasTableAcl($zasobObj->ID)) { echo '
' . "Brak uprawnień do tabeli ID={$zasobObj->ID}" . '
'; //echo UserActivity::showSimpleList(); return; } if (!$userAcl->hasTableAcl($korespObj->ID)) { echo '
' . "Brak uprawnień do tabeli Korespondencja (ID={$korespObj->ID})" . '
'; //echo UserActivity::showSimpleList(); return; } $tblAcl = $userAcl->getTableAcl($zasobObj->ID); $korespAcl = $userAcl->getTableAcl($korespObj->ID); $forceTblAclInit = ('1' == V::get('_force', '', $_GET)); $tblAcl->init($forceTblAclInit); $korespAcl->init($forceTblAclInit); $module = new Ahmes_Reklamacje($tblAcl, $korespAcl, $_GET); $module->run(); } class Ahmes_Reklamacje { private $_args = null; private $_tbl = null; private $_acl = null; private $_zasobID = null; private $_dataSource = null; private $_htmlID = ''; public function __construct($tblAcl, $korespAcl, $args) { $this->_args = $args; $this->_tbl = $tblAcl->getName(); $this->_acl = $tblAcl; $this->_korespAcl = $korespAcl; $this->_zasobID = $tblAcl->getID(); $this->_dataSource = $tblAcl->getDataSource(); $this->_htmlID = 'Ahmes_Reklamacje'; } public function run() { Lib::loadClass('SE_Layout'); SE_Layout::menu(); $task = V::get('task', '', $this->_args); switch ($task) { case 'create_problem': $id_koresp = V::get('id_koresp', '', $this->_args); if (!$id_koresp) { echo '
' . "Brak numeru z dziennika pism!" . '
'; } else { $this->taskCreateProblem($id_koresp); } break; case 'create_koresp_out': $id_problem = V::get('id_problem', '', $this->_args); if (!$id_problem) { echo '
' . "Brak numeru z dziennika pism!" . '
'; } else { $this->taskCreateKorespOut($id_problem); } break; default: echo '
' . "Brak zadania do wykonania!" . '
'; } } private function renderError($msg) { echo '
' . $msg . '
'; } private function getKoresp($id_koresp) { $db = DB::getDB(); if (!$db) return false; $koresp = $db->get_by_id('IN7_DZIENNIK_KORESP', $id_koresp); return $koresp; } private function getProblem($id_problem) { $db = DB::getDB(); if (!$db) return false; $problem = $db->get_by_id('PROBLEMS', $id_problem); return $problem; } private function checkKorespUsed($id_koresp) { $db = DB::getDB(); if (!$db) return false; $sql = "select count(1) as cnt from `{$this->_tbl}` as p where p.`ID_KORESP_IN`='{$id_koresp}' "; $res = $db->query($sql); if ($r = $db->fetch($res)) { if ($r->cnt > 0) { return true; } } return false; } private function checkProblem($problem) { return true; } private function taskCreateProblem($id_koresp) { $koresp = $this->getKoresp($id_koresp); if (!$koresp) { $this->renderError("Brak dostępu do korespondecji lub korespondencja nie istnieje"); return; } if ($this->checkKorespUsed($id_koresp)) { $this->renderError("Korespondecja została już przypisana do problemu"); return; } if ('1' == V::get('frm_sent', '', $_POST)) { $frmSaved = $this->saveCreateProblemForm($koresp, $_POST); if ($frmSaved) return; } $this->renderCreateProblemForm($koresp); } public function saveCreateProblemForm($koresp, $args) { $DBG = ('1' == V::get('DBG', '', $_REQUEST)); if($DBG){echo'
TODO: save('.$koresp->ID.') (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($args);echo'
';} if($DBG){echo'
acl (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($this->_acl);echo'
';} $dbID = $this->_acl->getDB(); $db = DB::getDB($dbID); if (!$db) return false; $tblName = $this->_acl->getName(); $sqlObj = new stdClass(); $fields = $this->_acl->getFields(); if($DBG){echo'
fields (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($fields);echo'
';} foreach ($fields as $kID => $vField) { if (!$this->_acl->isAllowed($kID, 'C')) { continue; } if (array_key_exists("f{$kID}", $args)) { $sqlObj->{$vField['name']} = $args["f{$kID}"]; if (empty($args["f{$kID}"]) && strlen($args["f{$kID}"]) == 0) {// fix bug in input type date and value="0000-00-00" $sqlObj->{$vField['name']} = $this->_acl->fixEmptyValueFromUser($kID); } } } if($DBG){echo'
 (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($sqlObj);echo'
';} $sqlObj->ID_KORESP_IN = $koresp->ID; $retID = $db->ADD_NEW_OBJ($tblName, $sqlObj); if ($retID > 0) { ?>
Utworzono pomyślnie rekord Nr
Wystąpił błąd podczas tworzenia rekordu has_errors()) { $outArr = array(); $errorsSql = $db->get_errors(); foreach ($errorsSql as $vErr) { if (substr($vErr, 0, 18) == 'SQL QUERY FAILED: ') { $vErr = substr($vErr, 18); // Duplicate entry '123456-1' for key 'P_NIP' if (substr($vErr, 0, 16) == 'Duplicate entry ') { } } $outArr[] = $vErr; } echo implode('
', $outArr); } ?>
_args as $k => $v) { if (strlen($k) > 4 && substr($k, 0, 3) == 'ff_' && !empty($v)) {// force filter prefix $fldName = substr($k, 3); $forceFilterInit[$fldName] = $v; } } $forceFilterInit['data_nad_pism'] = $koresp->K_DATA_OTRZYMANEJ_KORESP; $forceFilterInit['data_wpl_pism'] = $koresp->K_DATA_OTRZYM_KORESP; $forceFilterInit['Osoba'] = $koresp->K_OD_KOGO; $forceFilterInit['ID_PROJECT'] = $koresp->ID_PROJECT; $fieldsList = $this->_acl->getFields(); foreach ($fieldsList as $kID => $vCol) { $defaultValue = ''; if ($vCol['name'] == 'ID') { unset($fieldsList[$kID]); continue; } if (!empty($forceFilterInit[$vCol['name']])) { $defaultValue = $forceFilterInit[$vCol['name']]; } // TODO: read from session cache $cols[$kID] = V::get("f{$kID}", $defaultValue, $_POST); $fieldsList[$kID]['label'] = (!empty($vCol['label']))? $vCol['label'] : $vCol['name']; } $korespFldsList = $this->_korespAcl->getFields(); $korespFldsList = array_filter($korespFldsList, function($fld) { $korespFldsName = array(); $korespFldsName[] = 'ID'; $korespFldsName[] = 'K_OD_KOGO'; $korespFldsName[] = 'K_TYP_KORESP'; $korespFldsName[] = 'K_TYP_RODZAJ'; $korespFldsName[] = 'K_DATA_OTRZYMANEJ_KORESP'; $korespFldsName[] = 'K_DATA_OTRZYM_KORESP'; if (in_array($fld['name'], $korespFldsName)) { return true; } return false; }); Lib::loadClass('SE_Layout'); ?>
Dodaj nowy Problem/Reklamację na podstawie pisma nr ID; ?>
$vFld) : ?>

: {$vFld['name']}; ?>

$vCol) : ?> _acl->isAllowed($kID, 'C')) : ?>
true, 'tabindex'=>(++$tabindex), 'maxGrid'=>8); echo $this->_acl->showFormItem('C', $kID, "f{$kID}", $cols[$kID], $fieldParams); ?>
getProblem($id_problem); if (!$problem) { $this->renderError("Brak dostępu do problemu lub problem nie istnieje"); return; } if (!$this->checkProblem($problem)) { $this->renderError("Problem nie może zostać użyty"); return; } if ('1' == V::get('frm_sent', '', $_POST)) { $frmSaved = $this->saveCreateKorespOutForm($problem, $_POST); if ($frmSaved) return; } $this->renderCreateKorespOutForm($problem); } public function renderCreateKorespOutForm($problem) { $DBG = ('1' == V::get('DBG', '', $_REQUEST)); $forceFilterInit = array(); foreach ($this->_args as $k => $v) { if (strlen($k) > 4 && substr($k, 0, 3) == 'ff_' && !empty($v)) {// force filter prefix $fldName = substr($k, 3); $forceFilterInit[$fldName] = $v; } } $forceFilterInit['K_TYP_KORESP'] = 'OUT'; $forceFilterInit['K_DATA_OTRZYMANEJ_KORESP'] = date('Y-m-d'); $forceFilterInit['K_OD_KOGO'] = $problem->Osoba; $fieldsList = $this->_korespAcl->getFields(); $fieldsList = array_filter($fieldsList, function($vCol) { return ($vCol['name'] != 'ID'); }); $fieldsList = array_map(function($vCol) { $vCol['label'] = (!empty($vCol['label']))? $vCol['label'] : $vCol['name']; return $vCol; }, $fieldsList); $cols = array(); foreach ($fieldsList as $kID => $vCol) { $defaultValue = ''; if (!empty($forceFilterInit[$vCol['name']])) { $defaultValue = $forceFilterInit[$vCol['name']]; } // TODO: read from session cache $cols[$kID] = V::get("f{$kID}", $defaultValue, $_POST); } $problFldsList = $this->_acl->getFields(); $problFldsList = array_filter($problFldsList, function($fld) { $problFldsName = array(); $problFldsName[] = 'ID'; $problFldsName[] = 'Osoba'; $problFldsName[] = 'nazwa_jedn'; $problFldsName[] = 'miejscowosc'; $problFldsName[] = 'data_nad_pism'; $problFldsName[] = 'data_wpl_pism'; $problFldsName[] = 'data_real'; $problFldsName[] = 'A_PROBLEM_DESC_HTML'; if (in_array($fld['name'], $problFldsName)) { return true; } return false; }); Lib::loadClass('SE_Layout'); ?>
Dodaj korespondencję na podstawie problemu nr ID; ?>
$vFld) : ?>

: {$vFld['name']}; ?>

$vCol) : ?> _korespAcl->isAllowed($kID, 'C')) : ?>
true, 'tabindex'=>(++$tabindex), 'maxGrid'=>8); echo $this->_korespAcl->showFormItem('C', $kID, "f{$kID}", $cols[$kID], $fieldParams); ?>
TODO: save('.$problem->ID.') (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($args);echo'';} if($DBG){echo'
acl (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($this->_korespAcl);echo'
';} $dbID = $this->_korespAcl->getDB(); $db = DB::getDB($dbID); if (!$db) return false; $tblName = $this->_korespAcl->getName(); $sqlObj = new stdClass(); $fields = $this->_korespAcl->getFields(); if($DBG){echo'
fields (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($fields);echo'
';} foreach ($fields as $kID => $vField) { if (!$this->_korespAcl->isAllowed($kID, 'C')) { continue; } if (array_key_exists("f{$kID}", $args)) { $sqlObj->{$vField['name']} = $args["f{$kID}"]; if (empty($args["f{$kID}"]) && strlen($args["f{$kID}"]) == 0) {// fix bug in input type date and value="0000-00-00" $sqlObj->{$vField['name']} = $this->_korespAcl->fixEmptyValueFromUser($kID); } } } if($DBG){echo'
 (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($sqlObj);echo'
';} $retID = $db->ADD_NEW_OBJ($tblName, $sqlObj); if ($retID > 0) { ?>
Utworzono pomyślnie rekord Nr
_acl->getDB(); $dbProblem = DB::getDB($dbProblemId); $tblProblemName = $this->_acl->getName(); $sqlProblemObj = new stdClass(); $sqlProblemObj->ID = $problem->ID; $sqlProblemObj->ID_KORESP_OUT = $retID; // TODO: ? $sqlProblemObj->data real "data realizacji" defautl today - date('Y-m-d') $affectes = $dbProblem->UPDATE_OBJ($tblProblemName, $sqlProblemObj); return true; } ?>
Wystąpił błąd podczas tworzenia rekordu has_errors()) { $outArr = array(); $errorsSql = $db->get_errors(); foreach ($errorsSql as $vErr) { if (substr($vErr, 0, 18) == 'SQL QUERY FAILED: ') { $vErr = substr($vErr, 18); // Duplicate entry '123456-1' for key 'P_NIP' if (substr($vErr, 0, 16) == 'Duplicate entry ') { } } $outArr[] = $vErr; } echo implode('
', $outArr); } ?>
TODO: save ID(' . $id . ') (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($args);echo'';} if($DBG){echo'
acl (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($this->_acl);echo'
';} $dbID = $this->_acl->getDB(); $db = DB::getDB($dbID); if (!$db) { header('HTTP/1.0 406 Not Acceptable'); echo '{"type":"ERROR", "msg": "' . "Błąd połączenia z bazą danych!" . '"}'; exit; } $tblName = $this->_acl->getName(); $sqlObj = new stdClass(); $fields = $this->_acl->getFields(); if($DBG){echo'
fields (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($fields);echo'
';} foreach ($fields as $kID => $vField) { if (!$this->_acl->isAllowed($kID, 'C')) { continue; } if (array_key_exists("f{$kID}", $args)) { $sqlObj->{$vField['name']} = $args["f{$kID}"]; if (empty($args["f{$kID}"]) && strlen($args["f{$kID}"]) == 0) {// fix bug in input type date and value="0000-00-00" $sqlObj->{$vField['name']} = $this->_acl->fixEmptyValueFromUser($kID); } } } if($DBG){echo'
 (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($sqlObj);echo'
';} $retID = $db->ADD_NEW_OBJ($tblName, $sqlObj); $retJson = new stdClass(); $retJson->type = ''; $retJson->msg = ''; if ($retID > 0) { $retJson->type = 'SUCCESS'; $retJson->msg = "Utworzono pomyślnie rekord: ID = {$retID}"; $retJson->id = $retID; } else { header('HTTP/1.0 404 Not Found'); $retJson->type = 'ERROR'; $retJson->msg = ""; if ($db->has_errors()) { $outArr = array(); $errorsSql = $db->get_errors(); foreach ($errorsSql as $vErr) { if (substr($vErr, 0, 18) == 'SQL QUERY FAILED: ') { $vErr = substr($vErr, 18); // Duplicate entry '123456-1' for key 'P_NIP' if (substr($vErr, 0, 16) == 'Duplicate entry ') { } } $outArr[] = $vErr; } $retJson->msg .= implode('
', $outArr); } } echo json_encode($retJson); exit; } }