<?php

require_once dirname(__FILE__) . '/../vendor/phpQuery.php';
$deparments_path = dirname(__FILE__) . '/walmart-departments.txt';
if (!file_exists($deparments_path)) {
    echo "---- exec getAllDeparments() ----\n\r";
    getAllDepartments($deparments_path);
} else {
    getAllSubCategories($deparments_path);
}
function getAllDepartments($filename)
{
    echo "---- run getAllDeparments() ----\n\r";
    $doc = phpQuery::newDocumentHTML(file_get_contents(dirname(__FILE__) . '/deparments.html'));
    phpQuery::selectDocument($doc);
    echo "---- loading dom html ----\n\r";
    $categories = array();
    foreach (pq('.accordion div') as $el) {
        echo "---- reading a deparment and childrens ----\n\r";
        $link = pq($el)->find('h4 a:last-child')->attr('href');
        $name = pq($el)->find('h4 a:last-child span')->text();
        foreach (pq($el)->find('li') as $ele) {
            echo "---- reading a deparment's children ----\n\r";
            $subcategories[] = array('link' => pq($ele)->find('a')->attr('href'), 'name' => pq($ele)->find('a')->text());
        }
        echo "---- wrapping deparments ----\n\r";
        $categories[] = array('name' => $name, 'link' => $link, 'childrens' => $subcategories);
    }
    echo "---- creating deparment file ----\n\r";
    $file = fopen($filename, 'a+');
    echo "---- writing deparment file ----\n\r";
示例#2
0
    header('Location: http://localhost/qa/index.php');
    die;
}
$header_tag_extras = "";
$header_section_styles = "";
$header_section_metas = "";
$header_section_scripts = "";
$header_section_extras = "";
$body_tag_extras = "";
$navbar_signup_login = "";
$body_section_styles = "";
$body_section_scripts = "";
require '../database/models.php';
$loggedin_user_info = getUserInfoByUserID($_SESSION['user_id']);
$logged_in_name = "Welcome " . $loggedin_user_info['name'];
$result_allDepartments = getAllDepartments();
$_REQUEST['year'] = substr($_REQUEST['year'], 0, 4);
$allDepartmentsTotalAverageProgress = 0;
$count = 0;
$body_section_content = '<h1>List of Departments</h1>';
$body_section_content .= '<ol>';
foreach ($result_allDepartments as $val) {
    $allDepartmentsTotalAverageProgress += getAvgDepartmentProgessBySemester($val['ID'], $_REQUEST['year'], $_REQUEST['semster']);
    $progress = getAvgDepartmentProgessBySemester($val['ID'], $_REQUEST['year'], $_REQUEST['semster']);
    $body_section_content .= '<li>' . $val['name'] . '
        <progress value="' . $progress . '" max="1"></progress></li>';
    $count++;
}
$body_section_content .= '</ol><br>Total Progress of all departments for semster ' . $_REQUEST['semster'] . ' ' . $_REQUEST['year'] . ' is <progress value="' . $allDepartmentsTotalAverageProgress / $count . '" max"1"></progress>';
$navbar_signup_login = false;
$navbar_content = array(array("../index.php", "Home"), array("http://localhost/qa/quality-assurance/index.php", "DashBoard"), array("../about.php", "About"), array("../contact.php", "Contact"));