<?php

/*
  PHP version 5
  Copyright (c) 2002-2019ECISP.CN、EarcLink.COM
  警告：这不是一个免费的软件，请在许可范围内使用，请尊重知识产权，侵权必究，举报有奖
  作者：黄祥云 E-mail:6326420@qq.com  QQ:6326420 TEL:18665655030 / 13797552220
*/


use application\ESPCMS_AdminAuthority;
use application\ESPCMS_Core;
use modul_application\ESPCMS_MemberDB;
use admin_application\link\MenuLink;
use admin_application\link\OrderLink;

class OrderWidget {

	private static $mothodName;

	public function __construct() {
		ESPCMS_AdminAuthority::authorityBaseVerify(true);
		self::$mothodName = 'OrderMain';
		$order_app_config = ESPCMS_Core::get_app_config('order', false);
		if (!$order_app_config['isetup']) {
			espcms_message_err('public_pack-espcms_module_file_err', array(self::$mothodName));
		}
	}

	public static function widgetOutput() {
		$espcms_widget_templates = espcms_admin_template();
		$espcms_widget_templates->libfile = true;
		$widget_read = ESPCMS_Core::get_widget_view(0, self::$mothodName);
		$widget_read['link'] = MenuLink::getLink('link', $widget_read);
		$widget_read['ajaxlink'] = MenuLink::getLink('ajaxlink', $widget_read);
		$espcms_widget_templates->into('widget_read', $widget_read);
		$output = $espcms_widget_templates->fetch('order/order_widget');
		return $output;
	}

	public static function widgetList() {
		global $espcms_admin_templates, $espcms_link_db;
		$db_table = ESPCMS_DB_PREFIX . "order";
		$db_query = $espcms_link_db->db_query(espcms_db_list_out($db_table, '', 'oid', 'DESC', 0, 5));
		while ($fetch_row = $espcms_link_db->db_array_list($db_query)) {
			$fetch_row['username'] = ESPCMS_MemberDB::get_member_noatt_view($fetch_row['userid'], 'username');
			$fetch_row['edit'] = OrderLink::Order_link_array('edit', $fetch_row);
			$fetch_row['view'] = OrderLink::Order_link_array('view', $fetch_row);
			$array[] = $fetch_row;
		}
		$espcms_admin_templates->into('array', $array);
		$espcms_admin_templates->output('order/order_widget_list');
	}

}
