} elseif (isset($userJobs[$newJob]) && $userJobs[$newJob]['supervisor'] != $_POST['position']) { $editedEmployee->removeJob($_GET['edit_placement']); } } $editedEmployee->addJob($editedUser, $newJob, $values['branch'], $_POST['position']); $message = _OPERATIONCOMPLETEDSUCCESFULLY; $message_type = 'success'; } } } catch (Exception $e) { handleNormalFlowExceptions($e); } $smarty->assign("T_FORM", $form->toArray()); } else { $branchTree = new EfrontBranchesTree(); $branches = $branchTree->toPathString(); $smarty->assign("T_BRANCHES_PATH", $branches); $placements = $editedEmployee->getJobs(); $smarty->assign("T_PLACEMENTS", $placements); } } } #cpp#endif function eF_local_printBranchJobs($branch) { $result = $branch->getJobDescriptions(); $branchJobs = array("--- {$branch->branch['name']} ---"); foreach ($result as $value) { $branchJobs[$value['description']] = $value['description']; } $branchJobs['#empty#'] = "--- " . _OTHERBRANCHJOBS . " ---";
private function doJobCourses() { $smarty = $this->getSmartyVar(); $currentUser = $this->getCurrentUser(); $result = eF_getTableData("module_hcd_job_description j left outer join module_hcd_course_to_job_description cj on cj.job_description_ID=j.job_description_ID", "j.job_description_ID,description,branch_ID,count(courses_ID) as total_courses", "", "", "j.job_description_ID"); $branchesTree = new EfrontBranchesTree(); $branchesTreePaths = $branchesTree->toPathString(); $jobs = array(); foreach ($result as $value) { $jobsArray[$value['job_description_ID']] = $value; $jobs[$value['job_description_ID']] = $branchesTreePaths[$value['branch_ID']] . " → " . $value['description'] . " (" . $value['total_courses'] . ")"; } $form = new HTML_QuickForm("job_courses_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=module&op=module_administrator_tools&tab=job_courses&do=enterprise", "", null, true); $form->addElement('select', 'job', _JOBDESCRIPTION, $jobs); $form->addElement("submit", "submit", _MODULE_ADMINISTRATOR_TOOLS_COPYCOURSESELECTION, 'class = "flatButton"'); $form->addElement("static", "", _MODULE_ADMINISTRATOR_TOOLS_COPYCOURSESELECTIONTOALLSIMILARJOBS); $form->setDefaults(array("idle_from_timestamp" => $_SESSION['timestamp_from'])); if ($form->isSubmitted() && $form->validate()) { $GLOBALS['currentEmployee'] = $currentUser->aspects['hcd']; $job = new EfrontJob($form->exportValue('job')); $courses = $job->getJobCourses(); foreach ($sameJobs = $job->getSameDescriptions() as $value) { eF_deleteTableData("module_hcd_course_to_job_description", "job_description_id = '" . $value . "'"); } $job->associateCoursesToJob($courses, true); $message = str_replace(array("%x", "%y"), array(sizeof($sameJobs), sizeof($courses)), _MODULE_ADMINISTRATOR_TOOLS_SUCCESSFULLYASSIGNEDCOURSESTOJOBS); $message_type = 'success'; $this->setMessageVar($message, $message_type); } $smarty->assign("T_JOB_COURSES_FORM", $form->toArray()); }
$constraints['required_fields'] = array('active_in_course', 'user_type', 'completed'); $courses = $user->getUserCoursesAggregatingResults($constraints); $totalCourses = sizeof($courses); $incompleteCourses = 0; foreach ($courses as $key => $course) { $course['completed'] or $incompleteCourses++; } if ($totalCourses) { $tooltipInfo[] = '<div class = "infoEntry"> <span>' . _COURSESINCOMPLETETOTAL . "</span><span>: " . $incompleteCourses . "/" . $totalCourses . "</span></div>"; } } if (G_VERSIONTYPE == 'enterprise') { #cpp#ifdef ENTERPRISE $branchesTree = new EfrontBranchesTree(); $pathStrings = $branchesTree->toPathString(); $jobs = $user->aspects['hcd']->getJobs(); $branches = $user->aspects['hcd']->getBranches(); foreach ($jobs as $value) { $tooltipInfo[] = ' <div class = "infoEntry"> <span>' . _JOBDESCRIPTION . '</span><span>: ' . $value['description'] . ' <b>(' . (isset($branches['supervisor'][$value['branch_ID']]) ? _SUPERVISOR : _USER) . ')</b></span> <span> ' . _ATBRANCH . ': </span><span style = "font-weight:bold">' . $pathStrings[$value['branch_ID']] . '</span> </div> '; } $supervisors = array(); foreach ($user->aspects['hcd']->getSupervisors() as $value) { $supervisors[] = formatLogin($value); } if (!empty($supervisors)) {
/** * The main functionality * * (non-PHPdoc) * @see libraries/EfrontModule#getModule() */ public function getModule() { $smarty = $this->getSmartyVar(); $smarty->assign("T_MODULE_BASEDIR", $this->moduleBaseDir); $smarty->assign("T_MODULE_BASELINK", $this->moduleBaseLink); $smarty->assign("T_MODULE_BASEURL", $this->moduleBaseUrl); $dir = $this->moduleBaseDir . 'assets/'; if (!is_dir($dir)) { mkdir($dir, 0755); } if ($_SESSION['s_type'] == 'administrator') { try { $form = new HTML_QuickForm("upload_files_form", "post", $this->moduleBaseUrl . '&tab=upload', "", null, true); $form->registerRule('checkParameter', 'callback', 'eF_checkParameter'); //Register this rule for checking user input with our function, eF_checkParameter $form->addElement('file', 'file', _UPLOADFILE); if (G_VERSIONTYPE == 'enterprise') { $tree = new EfrontBranchesTree(); $pathString = $tree->toPathString(); //$result = eF_getTableData("module_hcd_branch", "*", "url is not null and url !=''"); $handle = '<img id = "busy" src = "images/16x16/clock.png" style = "display:none;" alt = "{$smarty.const._LOADING}" title = "{$smarty.const._LOADING}"/><div id = "autocomplete_leaflet_branches" class = "autocomplete"></div> '; $form->addElement('static', 'sidenote', $handle); $form->addElement('text', 'leaflet_branch_autoselect', _BRANCH, 'class = "autoCompleteTextBox" id = "autocomplete"'); $form->addElement('hidden', 'leaflet_branch', '', 'id = "leaflet_branch_value"'); } $form->setMaxFileSize(FileSystemTree::getUploadMaxSize() * 1024); $form->addElement('submit', 'submit_upload', _UPLOAD, 'class = "flatButton"'); if ($form->isSubmitted() && $form->validate()) { $values = $form->exportValues(); try { if ($values['leaflet_branch'] && eF_checkParameter($values['leaflet_branch'], 'id')) { $branch = new EfrontBranch($values['leaflet_branch']); if (!$branch->branch['url']) { throw new Exception("You must assign a url to the selected branch to upload files for it"); } $dir = $this->moduleBaseDir . 'assets/' . $branch->branch['url']; mkdir($dir, 0755); } $filesystem = new FileSystemTree($dir); $file = $filesystem->uploadFile("file", $dir); } catch (Exception $e) { $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString()); $message = $e->getMessage() . ' (' . $e->getCode() . ') <a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>'; $message_type = failure; $this->setMessageVar($message, $message_type); } } $smarty->assign('T_UPLOAD_FORM', $form->toArray()); $url = $this->moduleBaseUrl; $basedir = $dir; $options = array('zip' => false, 'upload' => false, 'create_folder' => false, 'folders' => true); /**The file manager*/ include "file_manager.php"; } catch (Exception $e) { $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString()); $message = $e->getMessage() . ' (' . $e->getCode() . ') <a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>'; $message_type = 'failure'; $this->setMessageVar($message, $message_type); } } else { if (defined('G_BRANCH_URL') && G_BRANCH_URL) { try { $assets_path = $root_path = $this->moduleBaseDir . 'assets/' . G_BRANCH_URL; } catch (Exception $e) { //do nothing here if the directory doesn't exist } } else { $assets_path = $root_path = $this->moduleBaseDir . 'assets/'; } $files = array(); if (!empty($_GET['folder'])) { $folder = urldecode($_GET['folder']); if (is_dir($assets_path . $folder)) { $folder = new EfrontDirectory($assets_path . $folder); if (strpos(realpath($folder['path']), $root_path) === false) { throw new Exception("Invalid folder"); } $parent_folder = dirname($folder['path']); $url = urlencode(str_replace($root_path, '', $folder['path'])); $assets_path = $folder['path']; $parent_url = $this->moduleBaseUrl . "&folder=" . urlencode(str_replace($root_path, '', dirname($folder['path']) . '/')); $parent_url or $parent_url = $this->moduleBaseUrl . 'assets/'; $files[] = array('text' => '.. (Up one level)', 'image' => $this->moduleBaseLink . 'ico/folders.png', 'href' => $parent_url); } } //pr($url);pr($parent_url); // $filesystem = new FileSystemTree($assets_path, true); foreach ($filesystem->tree as $key => $value) { if ($value instanceof EfrontDirectory) { $files[] = array('text' => basename($key), 'image' => $this->moduleBaseLink . 'ico/folders.png', 'href' => $this->moduleBaseUrl . "&folder=" . urlencode(str_replace($root_path, '', $value['path'] . '/'))); } } foreach ($filesystem->tree as $key => $value) { if ($value instanceof EfrontFile) { if (is_file($this->moduleBaseDir . 'ico/' . pathinfo($key, PATHINFO_EXTENSION) . '.png')) { $icon = $this->moduleBaseLink . 'ico/' . pathinfo($key, PATHINFO_EXTENSION) . '.png'; } else { $icon = $this->moduleBaseLink . 'ico/unknown.png'; } $files[] = array('text' => basename($key), 'image' => $icon, 'href' => $this->moduleBaseLink . str_replace($this->moduleBaseDir, '', $key)); } } $smarty->assign("T_FILES", $files); } return true; }
function askBranches() { try { if (G_VERSIONTYPE == 'enterprise') { #cpp#ifdef ENTERPRISE if (!isset($_SESSION['supervises_branches'])) { include_once $path . "module_hcd_tools.php"; //Automatically fix missing branch assignments for supervisors eF_assignSupervisorMissingSubBranchesRecursive(); //discover employee role in the hierarchy eF_getRights(); } } #cpp#endif eF_checkParameter($_POST['preffix'], 'text') ? $preffix = $_POST['preffix'] : ($preffix = '%'); if ($_SESSION['s_type'] == "administrator") { $result = eF_getTableData("(module_hcd_branch LEFT OUTER JOIN (module_hcd_employee_works_at_branch JOIN users ON module_hcd_employee_works_at_branch.users_LOGIN = users.login) ON module_hcd_branch.branch_ID = module_hcd_employee_works_at_branch.branch_ID AND module_hcd_employee_works_at_branch.assigned = '1') LEFT OUTER JOIN module_hcd_branch as branch1 ON module_hcd_branch.father_branch_ID = branch1.branch_ID GROUP BY module_hcd_branch.branch_ID ORDER BY branch1.branch_ID", "module_hcd_branch.branch_ID, module_hcd_branch.name, module_hcd_branch.city, module_hcd_branch.address, sum(CASE WHEN users.active=1 THEN 1 END) as employees, sum(CASE WHEN users.active=0 THEN 1 END) as inactive_employees, branch1.branch_ID as father_ID, branch1.name as father, supervisor", ""); } elseif ($_SESSION['supervises_branches']) { $result = eF_getTableData("(module_hcd_branch LEFT OUTER JOIN (module_hcd_employee_works_at_branch JOIN users ON module_hcd_employee_works_at_branch.users_LOGIN = users.login) ON module_hcd_branch.branch_ID = module_hcd_employee_works_at_branch.branch_ID AND module_hcd_employee_works_at_branch.assigned = '1') LEFT OUTER JOIN module_hcd_branch as branch1 ON module_hcd_branch.father_branch_ID = branch1.branch_ID WHERE module_hcd_branch.branch_ID IN (" . $_SESSION['supervises_branches'] . ") GROUP BY module_hcd_branch.branch_ID ORDER BY branch1.branch_ID", "module_hcd_branch.name, module_hcd_branch.city, module_hcd_branch.address, sum(CASE WHEN users.active=1 THEN 1 END) as employees, sum(CASE WHEN users.active=0 THEN 1 END) as inactive_employees, module_hcd_branch.branch_ID, branch1.branch_ID as father_ID, branch1.name as father", ""); } else { $result = array(); } $branches = array(); foreach ($result as $value) { $branches[$value['branch_ID']] = $value; } $tree = new EfrontBranchesTree(); $branchKeys = array_keys($branches); $branchKeys = array_combine($branchKeys, $branchKeys); $branch_results = array(); foreach ($tree->toPathString() as $key => $branch) { if (isset($branchKeys[$key])) { if ($preffix == '%' || stripos($branch, $preffix) !== false || stripos($branch, htmlentities($preffix)) !== false) { $truncated = eF_truncatePath($branch, 80, 6, "...", " → "); $hiname = highlightSearch($truncated, $preffix); $branch_results[$key] = array('branch_ID' => $key, 'name' => $branch, 'path_string' => $hiname); } } } $strs = array(); $strs[] = '<ul>'; foreach ($branch_results as $key => $branch) { $strs[] = '<li id=' . $key . '>' . $branch['path_string'] . '</li>'; } $strs[] = '</ul>'; echo implode("", $strs); } catch (Exception $e) { handleAjaxExceptions($e); } }