Пример #1
0
	Webservice For Get Company ID and Name for dropdown.
	Created By   : MD. Shamsad Ahmed
	Created Date : 24 September 2014
	Usage        : Get All Details Using Company ID.
	Copyright@Techila Solutions
*/
include_once 'DBConnect.php';
//Database Connection
include_once 'Abstract/classResponse.php';
//
function getCompanyList()
{
    $rm = new Response_Methods();
    $companyDetailsArray = array();
    //$dataResultSet=$rm->getSpecificDetails($companyID,'company_details_t','company_id');
    $dataResultSet = $rm->getAllDetails('company_details_t');
    if (mysql_num_rows($dataResultSet) > 0) {
        while ($row = mysql_fetch_array($dataResultSet)) {
            $getCompanyFields['companyID'] = $row['company_id'];
            $getCompanyFields['companyName'] = $row['company_name'];
            array_push($companyDetailsArray, $getCompanyFields);
        }
        $result = $rm->get_anything_details_success($companyDetailsArray, 'Company');
        return $result;
    } else {
        $result = $rm->get_anything_details_fail('Company');
        return $result;
    }
}
echo getCompanyList();
Пример #2
0
<?php

require '/resources/php/generalFunctions.php';
require '/resources/php/profileFunctions.php';
if (session_id() == '' || !isset($_SESSION)) {
    // session isn't started
    session_start();
}
$mysqli = createDBConnection();
//db connection object
$history = getCompanyHistory($_SESSION['user_id']);
//employment history of user
$companies = getCompanyList($mysqli);
//company list for dropdown
$companyArray = array();
while ($row = $companies->fetch_assoc()) {
    $companyArray[] = $row;
}
$companyList = json_encode($companyArray);
$userInfo = getUserInfo($_SESSION['user_id']);
//user info
$userInfo = $userInfo->fetch_assoc();
$positionCount = getPostCount($mysqli, $_SESSION['user_id']);
$postScoreSQL = "SELECT IFNULL(TRUNCATE(AVG(`rating`), 2), '-') AS 'rating'\n                FROM\n                (\n                SELECT `post_id`\n                FROM `position_post`\n                WHERE `fk_user_id` = " . $_SESSION['user_id'] . "\n                ) A\n                LEFT JOIN `position_post_rating`\n                ON `A`.`post_id` = `position_post_rating`.`fk_position_post`";
$postScoreQuery = $mysqli->query($postScoreSQL)->fetch_assoc();
$postScore = $postScoreQuery['rating'];
$mysqli->close();
?>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="UTF-8">
Пример #3
0
function uploadValueAtRisk($c, $status, $file)
{
    // c : taiwan or china
    // file : 上傳的檔案
    // status : 公司狀態
    if ($status === tse or $status === es or $status === "T") {
        $fp = loadExcelFile($file, 0);
    } else {
        $fp = loadExcelFile($file, 1);
    }
    // line 1 : tile列 公司ID 公司名稱 季別
    // line 2 start : data列 公司ID 公司名稱 該季風險值
    // step 1 : checkCompany(cid)
    // step 2 : checkFinancialInfo(taiwan, cid, season) ? 修改該id x season資料風險值欄位 : 新增該id x season資料
    //          同時儲存公司ID LIST
    // loop step 1 2 until data[0] = ''
    // checkCompanyList(status, list)
    if ($fp) {
        // 取得季別
        //設計是先column在row,跟一般習慣相反…
        $season = $fp->getCellByColumnAndRow(THIRDCOLUMN, 1)->getValue();
        // 檢查季別是否與使用者輸入的季別相同
        // 若相同則繼續上傳動作
        if (checkUploadSeason($season)) {
            // 取得原本status下的公司ID清單
            $old_company_list = getCompanyList($c, $status);
            $company_index = 0;
            if ($c === TAIWAN) {
                $table_name = 'company_financial_information';
            } else {
                $table_name = 'china_company_financial_information';
            }
            // 若status不等於上市, 將原本該status下的公司狀態改為null
            if ($status != tse) {
                $condition = '`status`="' . $status . '"';
                $GLOBALS['dbc_object']->updateData($table_name, 'status', 'null', $condition);
            }
            // 取得資料列數
            $highestRow = $fp->getHighestRow();
            // 照row的順序讀取每一家公司資料
            //row start from 1, and column start from 0?
            for ($row = 2; $row <= $highestRow; $row++) {
                if ($fp->getCellByColumnAndRow(FIRSTCOLUMN, $row)->getValue() === '') {
                    break;
                }
                // 讀取該公司資料
                $cid = $fp->getCellByColumnAndRow(FIRSTCOLUMN, $row)->getValue();
                $company_name = $fp->getCellByColumnAndRow(SECONDCOLUMN, $row)->getValue();
                $value_at_risk = checkNull($fp->getCellByColumnAndRow(THIRDCOLUMN, $row)->getCalculatedValue());
                // 檢查公司是否存在於資料庫 若存在 existedCompany = 1 反之 = 0
                $existedCompany = checkCompany($c, $cid);
                if ($existedCompany) {
                    // 檢查該id x season資料是否存在
                    if (checkFinancialInfo($c, $cid, $season)) {
                        echo '公司代號' . $cid . ' 季別' . $season . '風險值資料已存在<br>';
                    } else {
                        if ($c === TAIWAN) {
                            $insert_value = '(`company_id`, `season`, `value_at_risk`, `stock`, `cashflow_operating`, `cashflow_investment`, `proceed_fm_newIssue`) 
						VALUES ("' . $cid . '","' . $season . '", ' . $value_at_risk . ', null, null, null, null)';
                        } else {
                            $insertvalue = '(`company_id`, `season`, `value_at_risk`, `cashflow_operating`, `cashflow_investment`, `proceed_fm_newIssue`) 
						VALUES ("' . $cid . '","' . $season . '",' . $value_at_risk . ', null, null, null)';
                        }
                        $GLOBALS['dbc_object']->insertData($table_name, $insert_value);
                    }
                    // 將該公司狀態改為status
                    $status_value = '"' . $status . '"';
                    $condition = '`company_id`="' . $cid . '"';
                    $GLOBALS['dbc_object']->updateData($table_name, 'status', $status_value, $condition);
                    // search 公司id是否存在於old_company_list並刪除該element
                    $index = array_search($cid, $old_company_list);
                    if ($index !== FALSE) {
                        unset($old_company_list[$index]);
                    }
                } else {
                    echo '公司ID' . $cid . '不存在於資料庫中';
                }
            }
            echo '上季公司名單中<br>';
            $old_company_list = array_values($old_company_list);
            for ($i = 0; $i < count($old_company_list); $i++) {
                echo '公司ID' . $old_company_list[$i] . '<br>';
            }
            echo '不存在在這季風險值檔案中';
        } else {
            printError('檔案內的季別與輸入的上傳季別不一致 取消上傳動作');
        }
    }
}