Your IP : 216.73.216.54


Current Path : /home/zqegovsj/public_html/us3.supplierlist.com/webmaster/
Upload File :
Current File : /home/zqegovsj/public_html/us3.supplierlist.com/webmaster/company.php

<?php 



$inc_path = "../haibo/cn/";$ua_sm_compile_dir = "ua-admin/";

require($inc_path."global.php");

require($inc_path .APP_NAME. 'configs/db_session.php');

uses("company","member","area","companytype", "attachment", "indreccompany", "membertype");

require($inc_path.APP_NAME.'include/page_admin.php');





if(!isset($_SESSION['worker'])){require("session_cp.inc.php");}

$membertype = new Membertypes();

$indreccompany = new Indreccompanies();

$attach = new Attachments();

$companytype = new Companytypes();

$member = new Members();

$company = new Companies();

$area = new Areas();

if(isset($_SESSION['worker'])){$conditions="work_id= ".$_SESSION['worker'];}else

{$conditions = "1";}



$tpl_file = "company_index";

$result = $companytype->findAll("id as CompanytypeId,name as CompanytypeName","1", " id desc", 0,15);

$company_types = array();

foreach ($result as $key=>$val) {

	$company_types[$val['CompanytypeId']] = $val['CompanytypeName'];

}

setvar("CompanyTypes",$company_types);

setvar("CompanyStatus",$member->member_status);

if ($_POST['del_x'] && !empty($_POST['cid'])) {

	$result = $company->del($_POST['cid']);

	

}

if (isset($_POST['check'])){

	if (isset($_POST['check']['in'])) {

		$result = $company->check($_POST['cid'],1);

	}elseif (isset($_POST['check']['out'])){

		$result = $company->check($_POST['cid'],0);

	}

	

}



if (isset($_POST['setvip_x']) && !empty($_POST['cid'])) {

	$default_index_id = $membertype->field("id"," if_index=1");

	$company_ids = implode(",", $_POST['cid']);

	$member_ids = $company->findAll("member_id", "id in (".$company_ids.")", null);

	foreach ($member_ids as $val) {

		$tmp_ups[] = $val['member_id'];

	}

	$member_ids = null;

	$member_ids = implode(",", $tmp_ups);

	$result = $g_db->Execute("update ".$member->getTable()." set user_type=".$default_index_id." where id in (".$member_ids.")");

	if ($result) {

		flash("alert.php", "company.php", "Update successfully.");

	}

}

if (isset($_POST['recommend_x'])){

	$ids = implode(",", $_POST['cid']);

	$sql = "select Member.username as MemberUsername,Member.id as MemberId,Company.industry_id as CompanyIndustryId,Company.id as CompanyId from ".$company->getTable(true)." left join ".$member->getTable(true)." on Company.member_id=Member.id where Company.id in (".$ids.") and Company.industry_id>0";

	$company_res = $g_db->GetAll($sql);

	foreach ($company_res as $val) {

		$ind_exists = $indreccompany->field("id", "industry_id=".$val['CompanyIndustryId']." and company_id=".$val['CompanyId']);

		if(!$ind_exists){

			$g_db->Execute("insert into ".$indreccompany->getTable()." (industry_id,member_id,company_id,username) value ('".$val['CompanyIndustryId']."','".$val['MemberId']."','".$val['CompanyId']."','".$val['MemberUsername']."')");

		}

	}

	

}

if (isset($_POST['edit_company'])) {





	$company_id = $_POST['id'];

	$vals['name'] = $_POST['company']['name'];

	if ($_POST['cindustry']) {

		$industryid = $_POST['cindustry'];

	}else if($_POST['bindustry']){

		$industryid = $_POST['bindustry'];

	}else if($_POST['aindustry']){

		$industryid = $_POST['aindustry'];

	}

	if($industryid) $vals['industry_id'] = uaAddSlashes($industryid);

	

	$vals['employee_amount'] = $_POST['company']['employee_amount'];

	if($_POST['manage_type'])

	{

		$managetype = implode(",",$_POST['manage_type']);

		$vals['manage_type'] = $managetype;

	}

	$vals['type_id'] = $_POST['company']['type_id'];

	$vals['property'] 	= $_POST['company']['property'];

	$vals['year_annual'] = $_POST['company']['AnnualRevenue'];

	$vals['main_prod'] 	= $_POST['company']['main_prod'];

	$vals['reg_address'] = $_POST['company']['reg_address'];

	$vals['description'] =htmlspecialchars($_POST['company']['description']);

	$vals['main_brand'] = $_POST['company']['brand'];

	$vals['boss_name'] = $_POST['company']['boss_name'];

	$vals['reg_fund'] 	= $_POST['company']['reg_fund'];

	if ($_POST['FoundDate'] !="None") {

		$vals['found_date'] = uaDateConvert($_POST['FoundDate']);

	}

	$vals['main_customer'] = $_POST['company']['main_customer'];

	$vals['main_biz_place'] = $_POST['company']['main_biz_place'];

	$vals['link_man'] = $_POST['company']['link_man'];

	$vals['link_man_gender'] = $_POST['company']['link_man_gender'];

	$vals['position'] = $_POST['company']['position'];

	$vals['telcode'] = $_POST['tel']['code'];

	$vals['telzone'] = $_POST['tel']['zone'];

	$vals['tel'] = $_POST['tel']['number'];

	$vals['faxcode'] = $_POST['fax']['code'];

	$vals['faxzone'] = $_POST['fax']['zone'];

	$vals['fax'] = $_POST['fax']['number'];

	$vals['bank_from'] = $_POST['company']['bank_from'];

	$vals['bank_account'] = $_POST['company']['bank_account'];

	$vals['mobile'] = $_POST['company']['mobile'];

	$vals['address'] = $_POST['company']['address'];

	$vals['zipcode'] = $_POST['company']['zipcode'];

	$vals['site_url'] = $_POST['company']['site_url'];

	$vals['style_id'] = $_POST['company']['style_id'];

	$vals['email'] = $_POST['company']['email'];

	if($_POST['provinceid']!='')$vals['province_code_id'] = $_POST['provinceid'];

	if($_POST['cityid']!='')$vals['city_code_id'] = $_POST['cityid'];

	if($_POST['company']['main_market']) $mainmarket = implode(",",$_POST['company']['main_market']);

	$vals['main_market'] = $mainmarket;

	array_walk($vals,"uatrim");

	if($company_id){

		$result = $company->save($vals, "update", $company_id);

	}else{

		$vals['created'] = $time_stamp;

		$result = $company->save($vals);

	}

	

}

if ($_GET['action'] == "mod") {

	$company_id = intval($_GET['id']);

	$vals = null;

	if(!empty($company_id)){

		$fields = "id as AttachmentId,title as AttachmentTitle,description as AttachmentDescription,attachment as AttachmentFileName,created as AttachmentCreateDate";

		$honour_res = $attach->findAll($fields, "status=1 and company_id=".$company_id, "id desc", 0, 15);

		setvar("HonourResult", $honour_res);

		$sql = "SELECT Company.*,Member.username AS MemberUserName,Parea.name as pname,Carea.name as cname FROM ".$company->getTable(true)." LEFT JOIN members as Member ON Company.member_id=Member.id left join cn_areas as Parea on Company.province_code_id=Parea.code_id left join cn_areas as Carea on Company.city_code_id=Carea.code_id WHERE Company.id=".$company_id;

	

		$res = $g_db->GetRow($sql);

		$res['description']=stripslashes($res['description']);

		$res['description']=html_entity_decode($res['description']);

		setvar("CompanyInfo",$res);

		$selected['properties'] = explode(",",$res['manage_type']);

		setvar("SelectedManageType",$selected['properties']);

		$selected['markets'] = explode(",",$res['main_market']);

		setvar("SelectedMarket",$selected['markets']);

		uses("industry");

		$industry = new Industries();

		$current_industry = $industry->searchParentIndustry(intval($res['industry_id']));

		if (is_array($current_industry)) {

			$search_industry_ids = implode(",",$current_industry);

			setvar("CurrentIndustry",$g_db->GetArray("SELECT name AS IndustryName FROM ".$industry->getTable()." WHERE id in (".$search_industry_ids.")"));

		}

	}

	$res['description']=html_entity_decode($res['description']);

	uaAssign(array("CompanyProperty"=>$company->economic_type,"ManageTypes"=>$company->manage_type,"MainMarkets"=>$company->main_market,"CompanyFunds"=>$company->company_funds,"CompanyAnual"=>$company->year_annuals,"LinkmanPositions"=>$member->ua_positions,"EmployeeAmounts"=>$company->employee_amount,"Genders"=>$member->genders));

	$tpl_file = "company_edit";

}

$tables = $company->getTable(true);

$fields = "Company.id AS CompanyID,Member.id AS MemberID,Member.username AS MemberName,CONCAT(Member.firstname,Member.lastname) AS NickName,Company.name AS CompanyName,Company.status AS CompanyStatus,Member.user_type AS MemberType,Member.credit_level AS SuranceLevel,Company.created AS CreateDate,AreaProvince.name AS CompanyProvince,AreaCity.name AS CompanyCity";

if (isset($_POST['search'])) {



	if ($_POST['member']['username']) {

		$ujoins.=" left join ".$member->getTable(true)." on Member.id=Company.member_id";

		$conditions.= " AND Member.username like '%".$_POST['member']['username']."%'";

	}

	if ($_POST['company']['name']) $conditions.= " AND Company.name like '%".$_POST['company']['name']."%'";

	if ($_POST['membertype']) $conditions.= " AND Member.user_type =".$_POST['membertype'];

	if ($_POST['FromDate'] && $_POST['FromDate']!="None" && $_POST['ToDate'] && $_POST['ToDate']!="None") {

		$conditions.= " AND Member.created BETWEEN ";

		$conditions.= uaDateConvert($_POST['FromDate']);

		$conditions.= " AND ";

		$conditions.= uaDateConvert($_POST['ToDate']);

	}

	if ($_POST['industryid']) $conditions.= " AND Company.industry_id=".$_POST['industryid'];

	if ($_POST['companystatus']!="-1") $conditions.= " AND Company.status=".$_POST['companystatus'];

	if ($_POST['companytype']!="-1") $conditions.= " AND Company.type_id=".$_POST['companytype'];

}

$amount = $company->findCount($conditions,"Company.id", null, $ujoins);

if ($_POST['gopage'] && intval($_POST['topage'])) {

	$page = intval($_POST['topage']);

}

pageft($amount,15);

$joins = array(

"Member"=>array("fullTableName"=>"members as Member","foreignKey"=>"member_id","fields"=>null),

"AreaProvince"=>array("fullTableName"=>$area->getTable()." as AreaProvince","foreignKey"=>"province_code_id","PrimaryKey"=>"code_id","fields"=>null),

"AreaCity"=>array("fullTableName"=>$area->getTable()." as AreaCity","foreignKey"=>"city_code_id","PrimaryKey"=>"code_id","fields"=>null)

);

setvar("CompanyList",$company->findAll($fields,$conditions,"Company.id DESC",$firstcount,$displaypg));

setvar("UserTypes",$member->ua_member_types);

setvar("Status",$company->company_status);

uaAssign(array("Amount"=>$amount,"PageHeader"=>$page_header,"ByPages"=>$pagenav));

template("ua-admin/".$tpl_file);

?>