初始版本
This commit is contained in:
commit
6ef7faefd8
123
form/form.php
Normal file
123
form/form.php
Normal file
@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
class UIForm
|
||||
{
|
||||
protected $name;
|
||||
|
||||
private $method;
|
||||
private $action=null;
|
||||
private $on_submit=null;
|
||||
|
||||
private $style_class="form-inline";
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$a = func_get_args();
|
||||
$i = func_num_args();
|
||||
|
||||
if (method_exists($this,$f='__construct'.$i))
|
||||
call_user_func_array(array($this,$f),$a);
|
||||
}
|
||||
|
||||
public function __construct2($n,$m)
|
||||
{
|
||||
$this->name=$n;
|
||||
$this->method=$m;
|
||||
}
|
||||
|
||||
public function __construct3($n,$m,$a)
|
||||
{
|
||||
$this->name=$n;
|
||||
$this->method=$m;
|
||||
$this->action=$a;
|
||||
}
|
||||
|
||||
public function __construct4($n,$m,$a,$o)
|
||||
{
|
||||
$this->name=$n;
|
||||
$this->method=$m;
|
||||
$this->action=$a;
|
||||
$this->on_submit=$o;
|
||||
}
|
||||
|
||||
public function get_name()
|
||||
{
|
||||
return $name;
|
||||
}
|
||||
|
||||
public function set_on_sumbit($s)
|
||||
{
|
||||
$this->on_submit=$s;
|
||||
}
|
||||
|
||||
public function set_class($s)
|
||||
{
|
||||
$this->$style_class=$s;
|
||||
}
|
||||
|
||||
public function add_hidden_value($input_name,$value)
|
||||
{
|
||||
echo '<input name="'.$input_name.'" type="hidden" value="'.$value.'"/>';
|
||||
}
|
||||
|
||||
function add_edit_date($flag)
|
||||
{
|
||||
echo '<input type="text" name="'.$flag.'" value="'.date("Y-m-d H:i").'"/>';
|
||||
}
|
||||
|
||||
public function start()
|
||||
{
|
||||
echo '<form name="'.$this->name.'" method="'.$this->method.'" ';
|
||||
|
||||
if($this->action !=null)echo 'action="' .$this->action .'" ';
|
||||
if($this->on_submit !=null)echo 'onsubmit="return '.$this->on_submit .'()" ';
|
||||
if($this->style_class !=null)echo 'class="' .$this->style_class .'">';
|
||||
|
||||
$_SESSION["final_submit"]=time();
|
||||
|
||||
$this->add_hidden_value('form_time',$_SESSION["final_submit"]);
|
||||
}
|
||||
|
||||
public function submit_end($submit_name)
|
||||
{
|
||||
echo '<input type="submit" value="'.$submit_name.'" class="btn btn-primary"/>';
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
public function end()
|
||||
{
|
||||
echo '</form>';
|
||||
}
|
||||
};//class UIForm
|
||||
|
||||
function repeat_submit_check()
|
||||
{
|
||||
if($_SESSION["final_submit"]==$_POST['form_time'])
|
||||
{
|
||||
$_SESSION["final_submit"]=time();
|
||||
return true;
|
||||
}
|
||||
|
||||
echo '请不要重复提交';
|
||||
return false;
|
||||
}
|
||||
|
||||
function start_form_get($name,$action)
|
||||
{
|
||||
return(new UIForm($name,"get",$action));
|
||||
}
|
||||
|
||||
function start_form_post($name,$action)
|
||||
{
|
||||
return(new UIForm($name,"post",$action));
|
||||
}
|
||||
|
||||
function start_form_get_js($name,$action,$js_func)
|
||||
{
|
||||
return(new UIForm($name,"get",$action,$js_func));
|
||||
}
|
||||
|
||||
function start_form_post_js($name,$action,$js_func)
|
||||
{
|
||||
return(new UIForm($name,"post",$action,$js_func));
|
||||
}
|
52
form/form_button.php
Normal file
52
form/form_button.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
class UIButton
|
||||
{
|
||||
private $style='class="btn"';
|
||||
private $text="";
|
||||
private $onclick="";
|
||||
|
||||
public function SetText($t)
|
||||
{
|
||||
$this->text=$t;
|
||||
}
|
||||
|
||||
public function SetGlyph($g)
|
||||
{
|
||||
$this->text='<span class="glpyhicon glyphicon-'.$g.'"></span>';
|
||||
}
|
||||
|
||||
public function SetStyle($bs)
|
||||
{
|
||||
if($bs==null)
|
||||
$this->style='class="btn"';
|
||||
else
|
||||
$this->style='class="btn btn-'.$bs.'"';
|
||||
}
|
||||
|
||||
public function SetOnClick($js)
|
||||
{
|
||||
$this->onclick='onclick="'.$js.'"';
|
||||
}
|
||||
|
||||
public function SetOpenWindow($link)
|
||||
{
|
||||
$this->onclick='onclick="javascript:window.open(\''.$link.'\')"';
|
||||
}
|
||||
|
||||
public function SetLocalLink($link)
|
||||
{
|
||||
$this->onclick='onclick="javascript:location.href=\''.$link.'\'"';
|
||||
}
|
||||
|
||||
public function echo()
|
||||
{
|
||||
echo '<button '.$this->style.' '.$this->onclick.'>'.$this->text.'</button>';
|
||||
}
|
||||
};//class UIButton
|
||||
|
||||
function create_js_button($text,$js_func)
|
||||
{
|
||||
echo '<button type="button" onclick="'.$js_func.'" class="btn btn-primary">'.$text.'</button>';
|
||||
}
|
||||
?>
|
60
form/form_editbox.php
Normal file
60
form/form_editbox.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
class UIEditBox
|
||||
{
|
||||
private $type=null;
|
||||
private $id=null;
|
||||
private $size=null;
|
||||
|
||||
public function __construct($t,$i,$s)
|
||||
{
|
||||
$this->type=$t;
|
||||
$this->id=$i;
|
||||
$this->size=$s;
|
||||
}
|
||||
|
||||
public function echo()
|
||||
{
|
||||
echo '<input type="'.$this->type.'" class="form-control" name="'.$this->id.'" size="'.$this->size.'">';
|
||||
}
|
||||
};//class UIEditBox
|
||||
|
||||
class UIInputGroup extends UIEditBox
|
||||
{
|
||||
private $addon_front=null;
|
||||
private $addon_back=null;
|
||||
|
||||
public function __construct($t,$i,$s)
|
||||
{
|
||||
parent::__construct($t,$i,$s);
|
||||
}
|
||||
|
||||
public function SetAddonFront($text)
|
||||
{
|
||||
$this->addon_front='<span class="input-group-addon">'.$text.'</span>';
|
||||
}
|
||||
|
||||
public function SetAddonBack($text)
|
||||
{
|
||||
$this->addon_back='<span class="input-group-addon">'.$text.'</span>';
|
||||
}
|
||||
|
||||
public function echo()
|
||||
{
|
||||
echo '<div class="input-group">';
|
||||
echo $this->addon_front;
|
||||
parent::echo();
|
||||
echo $this->addon_back;
|
||||
echo '</div>';
|
||||
}
|
||||
};//class UIInputGroup
|
||||
|
||||
function CreateInputGroup($type,$id,$label,$size)
|
||||
{
|
||||
$but=new UIInputGroup($type,$id,$size);
|
||||
$but->SetAddonFront($label);
|
||||
$but->echo();
|
||||
|
||||
return $but;
|
||||
}
|
||||
?>
|
35
form/form_radio.php
Normal file
35
form/form_radio.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
class UIRadio
|
||||
{
|
||||
private $name;
|
||||
private $selected;
|
||||
|
||||
public function __construct1($n)
|
||||
{
|
||||
$this->name=$n;
|
||||
$this->selected=null;
|
||||
}
|
||||
|
||||
public function __construct2($n,$s)
|
||||
{
|
||||
$this->name=$n;
|
||||
$this->selected=$s;
|
||||
}
|
||||
|
||||
public function SetSelected($s)
|
||||
{
|
||||
$this->selected=$s;
|
||||
}
|
||||
|
||||
public function option($value)
|
||||
{
|
||||
echo '<input type="radio" name="'.$this->name.'" value="'.$value.'"';
|
||||
|
||||
if($this->selected==$value)
|
||||
echo ' checked="checked"';
|
||||
|
||||
echo '/>';
|
||||
}
|
||||
}
|
||||
?>
|
43
form/form_select.php
Normal file
43
form/form_select.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
class UISelect
|
||||
{
|
||||
private $name;
|
||||
private $selected;
|
||||
|
||||
public function __construct1($n)
|
||||
{
|
||||
$this->name=$n;
|
||||
$this->selected=null;
|
||||
}
|
||||
|
||||
public function __construct2($n,$s)
|
||||
{
|
||||
$this->name=$n;
|
||||
$this->selected=$s;
|
||||
}
|
||||
|
||||
public function SetSelected($s)
|
||||
{
|
||||
$this->selected=$s;
|
||||
}
|
||||
|
||||
public function start()
|
||||
{
|
||||
echo '<select name="'.$this->name.'">';
|
||||
}
|
||||
|
||||
public function option($value,$text)
|
||||
{
|
||||
if($this->selected==$value)
|
||||
echo '<option value="'.$value.'" selected="selected">'.$text.'</option>';
|
||||
else
|
||||
echo '<option value="'.$value.'">'.$text.'</option>';
|
||||
}
|
||||
|
||||
public function end()
|
||||
{
|
||||
echo '</select>';
|
||||
}
|
||||
}
|
||||
?>
|
3
phptools.kdev4
Normal file
3
phptools.kdev4
Normal file
@ -0,0 +1,3 @@
|
||||
[Project]
|
||||
Manager=KDevGenericManager
|
||||
Name=phptools
|
7
phptools.php
Normal file
7
phptools.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
require_once 'tools.php';
|
||||
|
||||
require_once 'form/form_editbox.php';
|
||||
require_once 'form/form_button.php';
|
||||
require_once 'form/form.php';
|
58
tools.php
Normal file
58
tools.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
function echo_html_header($title)
|
||||
{
|
||||
echo '<html>
|
||||
<head>
|
||||
<title>'.$title.'</title>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<meta name="viewport" content="initial-scale=1.0, user-scalable=yes, minimum-scale=0.25, maximum-scale=5.0, width=device-width" />
|
||||
<script src="http://cdn.alloyui.com/3.0.1/aui/aui-min.js"></script>
|
||||
<link href="http://cdn.alloyui.com/3.0.1/aui-css/css/bootstrap.min.css" rel="stylesheet"/></link>
|
||||
</head>
|
||||
<body>
|
||||
';
|
||||
}
|
||||
|
||||
function echo_title()
|
||||
{
|
||||
echo '<center><h1 style="margin-top: 10px">Enterprise Resource Management System</h1></center>';
|
||||
}
|
||||
|
||||
function echo_html_end()
|
||||
{
|
||||
echo '
|
||||
</body></html>';
|
||||
}
|
||||
|
||||
function echo_hr()
|
||||
{
|
||||
echo '<hr size="1"/>';
|
||||
}
|
||||
|
||||
function echo_include_script($filename)
|
||||
{
|
||||
echo '<script src="'.$filename.'"></script>';
|
||||
}
|
||||
|
||||
function echo_autogoto($time,$page)
|
||||
{
|
||||
echo '<meta http-equiv="refresh" content="'.$time.';url='.$page.'">';
|
||||
}
|
||||
|
||||
function echo_span_glyph($glyph)
|
||||
{
|
||||
echo '<span class="glyphicon glyphicon-'.$glyph.'"></span>';
|
||||
}
|
||||
|
||||
function echo_span_label($style,$text)
|
||||
{
|
||||
echo '<span class="label label-'.$style.'">'.$text.'</span>';
|
||||
}
|
||||
|
||||
function echo_alert($style,$text)
|
||||
{
|
||||
echo '<div class="alert alert-'.$style.'" role="alert">'.$text.'</div>';
|
||||
}
|
||||
?>
|
219
tools_currency.php
Normal file
219
tools_currency.php
Normal file
@ -0,0 +1,219 @@
|
||||
<?php
|
||||
|
||||
require_once "ui_select.php";
|
||||
require_once "ui_table.php";
|
||||
|
||||
function echo_currency_select($label)
|
||||
{
|
||||
$s=new UISelect($label);
|
||||
|
||||
$s->SetSelected($_SESSION['currency']); //设定当前营业厅主要货币为默认选中货币
|
||||
|
||||
$s->start();
|
||||
$s->option("AED","United Arab Emirates Dirham");
|
||||
$s->option("AFN","Afghanistan Afghani");
|
||||
$s->option("ALL","Albania Lek");
|
||||
$s->option("AMD","Armenia Dram");
|
||||
$s->option("ANG","Netherlands Antilles Guilder");
|
||||
$s->option("AOA","Angola Kwanza");
|
||||
$s->option("ARS","Argentina Peso");
|
||||
$s->option("AUD","Australia Dollar");
|
||||
$s->option("AWG","Aruba Guilder");
|
||||
$s->option("AZN","Azerbaijan New Manat");
|
||||
$s->option("BAM","Bosnia and Herzegovina Convertible Marka");
|
||||
$s->option("BBD","Barbados Dollar");
|
||||
$s->option("BDT","Bangladesh Taka");
|
||||
$s->option("BGN","Bulgaria Lev");
|
||||
$s->option("BHD","Bahrain Dinar");
|
||||
$s->option("BIF","Burundi Franc");
|
||||
$s->option("BMD","Bermuda Dollar");
|
||||
$s->option("BND","Brunei Darussalam Dollar");
|
||||
$s->option("BOB","Bolivia Boliviano");
|
||||
$s->option("BRL","Brazil Real");
|
||||
$s->option("BSD","Bahamas Dollar");
|
||||
$s->option("BTN","Bhutan Ngultrum");
|
||||
$s->option("BWP","Botswana Pula");
|
||||
$s->option("BYR","Belarus Ruble");
|
||||
$s->option("BZD","Belize Dollar");
|
||||
$s->option("CAD","Canada Dollar");
|
||||
$s->option("CDF","Congo/Kinshasa Franc");
|
||||
$s->option("CHF","Switzerland Franc");
|
||||
$s->option("CLP","Chile Peso");
|
||||
$s->option("CNY","China Yuan Renminbi");
|
||||
$s->option("COP","Colombia Peso");
|
||||
$s->option("CRC","Costa Rica Colon");
|
||||
$s->option("CUC","Cuba Convertible Peso");
|
||||
$s->option("CUP","Cuba Peso");
|
||||
$s->option("CVE","Cape Verde Escudo");
|
||||
$s->option("CZK","Czech Republic Koruna");
|
||||
$s->option("DJF","Djibouti Franc");
|
||||
$s->option("DKK","Denmark Krone");
|
||||
$s->option("DOP","Dominican Republic Peso");
|
||||
$s->option("DZD","Algeria Dinar");
|
||||
$s->option("EGP","Egypt Pound");
|
||||
$s->option("ERN","Eritrea Nakfa");
|
||||
$s->option("ETB","Ethiopia Birr");
|
||||
$s->option("EUR","Euro Member Countries");
|
||||
$s->option("FJD","Fiji Dollar");
|
||||
$s->option("FKP","Falkland Islands (Malvinas) Pound");
|
||||
$s->option("GBP","United Kingdom Pound");
|
||||
$s->option("GEL","Georgia Lari");
|
||||
$s->option("GGP","Guernsey Pound");
|
||||
$s->option("GHS","Ghana Cedi");
|
||||
$s->option("GIP","Gibraltar Pound");
|
||||
$s->option("GMD","Gambia Dalasi");
|
||||
$s->option("GNF","Guinea Franc");
|
||||
$s->option("GTQ","Guatemala Quetzal");
|
||||
$s->option("GYD","Guyana Dollar");
|
||||
$s->option("HKD","Hong Kong Dollar");
|
||||
$s->option("HNL","Honduras Lempira");
|
||||
$s->option("HRK","Croatia Kuna");
|
||||
$s->option("HTG","Haiti Gourde");
|
||||
$s->option("HUF","Hungary Forint");
|
||||
$s->option("IDR","Indonesia Rupiah");
|
||||
$s->option("ILS","Israel Shekel");
|
||||
$s->option("IMP","Isle of Man Pound");
|
||||
$s->option("INR","India Rupee");
|
||||
$s->option("IQD","Iraq Dinar");
|
||||
$s->option("IRR","Iran Rial");
|
||||
$s->option("ISK","Iceland Krona");
|
||||
$s->option("JEP","Jersey Pound");
|
||||
$s->option("JMD","Jamaica Dollar");
|
||||
$s->option("JOD","Jordan Dinar");
|
||||
$s->option("JPY","Japan Yen");
|
||||
$s->option("KES","Kenya Shilling");
|
||||
$s->option("KGS","Kyrgyzstan Som");
|
||||
$s->option("KHR","Cambodia Riel");
|
||||
$s->option("KMF","Comoros Franc");
|
||||
$s->option("KPW","Korea (North) Won");
|
||||
$s->option("KRW","Korea (South) Won");
|
||||
$s->option("KWD","Kuwait Dinar");
|
||||
$s->option("KYD","Cayman Islands Dollar");
|
||||
$s->option("KZT","Kazakhstan Tenge");
|
||||
$s->option("LAK","Laos Kip");
|
||||
$s->option("LBP","Lebanon Pound");
|
||||
$s->option("LKR","Sri Lanka Rupee");
|
||||
$s->option("LRD","Liberia Dollar");
|
||||
$s->option("LSL","Lesotho Loti");
|
||||
$s->option("LYD","Libya Dinar");
|
||||
$s->option("MAD","Morocco Dirham");
|
||||
$s->option("MDL","Moldova Leu");
|
||||
$s->option("MGA","Madagascar Ariary");
|
||||
$s->option("MKD","Macedonia Denar");
|
||||
$s->option("MMK","Myanmar (Burma) Kyat");
|
||||
$s->option("MNT","Mongolia Tughrik");
|
||||
$s->option("MOP","Macau Pataca");
|
||||
$s->option("MRO","Mauritania Ouguiya");
|
||||
$s->option("MUR","Mauritius Rupee");
|
||||
$s->option("MVR","Maldives (Maldive Islands) Rufiyaa");
|
||||
$s->option("MWK","Malawi Kwacha");
|
||||
$s->option("MXN","Mexico Peso");
|
||||
$s->option("MYR","Malaysia Ringgit");
|
||||
$s->option("MZN","Mozambique Metical");
|
||||
$s->option("NAD","Namibia Dollar");
|
||||
$s->option("NGN","Nigeria Naira");
|
||||
$s->option("NIO","Nicaragua Cordoba");
|
||||
$s->option("NOK","Norway Krone");
|
||||
$s->option("NPR","Nepal Rupee");
|
||||
$s->option("NZD","New Zealand Dollar");
|
||||
$s->option("OMR","Oman Rial");
|
||||
$s->option("PAB","Panama Balboa");
|
||||
$s->option("PEN","Peru Nuevo Sol");
|
||||
$s->option("PGK","Papua New Guinea Kina");
|
||||
$s->option("PHP","Philippines Peso");
|
||||
$s->option("PKR","Pakistan Rupee");
|
||||
$s->option("PLN","Poland Zloty");
|
||||
$s->option("PYG","Paraguay Guarani");
|
||||
$s->option("QAR","Qatar Riyal");
|
||||
$s->option("RON","Romania New Leu");
|
||||
$s->option("RSD","Serbia Dinar");
|
||||
$s->option("RUB","Russia Ruble");
|
||||
$s->option("RWF","Rwanda Franc");
|
||||
$s->option("SAR","Saudi Arabia Riyal");
|
||||
$s->option("SBD","Solomon Islands Dollar");
|
||||
$s->option("SCR","Seychelles Rupee");
|
||||
$s->option("SDG","Sudan Pound");
|
||||
$s->option("SEK","Sweden Krona");
|
||||
$s->option("SGD","Singapore Dollar");
|
||||
$s->option("SHP","Saint Helena Pound");
|
||||
$s->option("SLL","Sierra Leone Leone");
|
||||
$s->option("SOS","Somalia Shilling");
|
||||
$s->option("SPL","Seborga Luigino");
|
||||
$s->option("SRD","Suriname Dollar");
|
||||
$s->option("STD","São Tomé and Príncipe Dobra");
|
||||
$s->option("SVC","El Salvador Colon");
|
||||
$s->option("SYP","Syria Pound");
|
||||
$s->option("SZL","Swaziland Lilangeni");
|
||||
$s->option("THB","Thailand Baht");
|
||||
$s->option("TJS","Tajikistan Somoni");
|
||||
$s->option("TMT","Turkmenistan Manat");
|
||||
$s->option("TND","Tunisia Dinar");
|
||||
$s->option("TOP","Tonga Pa'anga");
|
||||
$s->option("TRY","Turkey Lira");
|
||||
$s->option("TTD","Trinidad and Tobago Dollar");
|
||||
$s->option("TVD","Tuvalu Dollar");
|
||||
$s->option("TWD","Taiwan New Dollar");
|
||||
$s->option("TZS","Tanzania Shilling");
|
||||
$s->option("UAH","Ukraine Hryvnia");
|
||||
$s->option("UGX","Uganda Shilling");
|
||||
$s->option("USD","United States Dollar");
|
||||
$s->option("UYU","Uruguay Peso");
|
||||
$s->option("UZS","Uzbekistan Som");
|
||||
$s->option("VEF","Venezuela Bolivar");
|
||||
$s->option("VND","Viet Nam Dong");
|
||||
$s->option("VUV","Vanuatu Vatu");
|
||||
$s->option("WST","Samoa Tala");
|
||||
$s->option("XAF","Communauté Financière Africaine (BEAC) CFA Franc BEAC");
|
||||
$s->option("XCD","East Caribbean Dollar");
|
||||
$s->option("XDR","International Monetary Fund (IMF) Special Drawing Rights");
|
||||
$s->option("XOF","Communauté Financière Africaine (BCEAO) Franc");
|
||||
$s->option("XPF","Comptoirs Français du Pacifique (CFP) Franc");
|
||||
$s->option("YER","Yemen Rial");
|
||||
$s->option("ZAR","South Africa Rand");
|
||||
$s->option("ZMW","Zambia Kwacha");
|
||||
$s->option("ZWD","Zimbabwe Dollar");
|
||||
$s->end();
|
||||
}
|
||||
|
||||
function get_base_rate($source,$target)
|
||||
{
|
||||
return file_get_contents('http://download.finance.yahoo.com/d/quotes.csv?s='.$source.$target.'=X&f=l1&e=.csv');
|
||||
}
|
||||
|
||||
function get_service_hall_cash($currency)
|
||||
{
|
||||
$sql=get_sql();
|
||||
|
||||
if(!$sql)return 0;
|
||||
|
||||
$sql_string='select Number from ServiceHall_Cash where SubCode="'.$_SESSION['service_hall'].'_'.$currency.'"';
|
||||
|
||||
// echo $sql_string;
|
||||
|
||||
$sql_result=$sql->query($sql_string);
|
||||
|
||||
if(!$sql_result)return 0;
|
||||
|
||||
$row=$sql_result->fetch_row();
|
||||
|
||||
return $row[0];
|
||||
}
|
||||
|
||||
|
||||
function save_cash_to_service_hall($currency,$number)
|
||||
{
|
||||
$sql=get_sql();
|
||||
|
||||
if(!$sql)return;
|
||||
|
||||
$sql_result=$sql->query('INSERT INTO ServiceHall_Cash(SubCode,Code,Currency,Number) VALUES("'.$_SESSION['service_hall'].'_'.$currency.'","'.$_SESSION['service_hall'].'","'.$currency.'",'.$number.') ON DUPLICATE KEY UPDATE Number=Number+'.$number);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
function show_cash_from_service_hall($label)
|
||||
{
|
||||
$table=new UISQLTable($label,"ServiceHall_Cash",array("Currency","Number"),'Code="'.$_SESSION['service_hall'].'"');
|
||||
|
||||
$table->echo();
|
||||
}
|
15
tools_firstpage.js
Normal file
15
tools_firstpage.js
Normal file
@ -0,0 +1,15 @@
|
||||
function on_first_page()
|
||||
{
|
||||
var form=document.forms["cm_first_form"];
|
||||
|
||||
var username=form["username"].value;
|
||||
var password=form["password"].value;
|
||||
|
||||
if(username==null||username==""){alert("username must be filled out");return;}
|
||||
if(password==null||password==""){alert("password must be filled out");return;}
|
||||
|
||||
form["width" ].value=document.body.clientWidth;
|
||||
form["height" ].value=document.body.clientHeight;
|
||||
|
||||
form.submit();
|
||||
}
|
19
tools_form.php
Normal file
19
tools_form.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
function echo_button($link,$name)
|
||||
{
|
||||
echo '<a class="btn btn-primary" href="'.$link.'" onclick="';
|
||||
echo "ga('send', 'event', 'Homepage', 'Demo'";
|
||||
echo ');">'.$name.'</a>';
|
||||
}
|
||||
|
||||
function echo_field_start($name)
|
||||
{
|
||||
echo '<fieldset><legend>'.$name.'</legend>';
|
||||
}
|
||||
|
||||
function echo_field_end()
|
||||
{
|
||||
echo '</fieldset>';
|
||||
}
|
||||
?>
|
26
tools_session.php
Normal file
26
tools_session.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
function init_session()
|
||||
{
|
||||
if (!isset($_SESSION))
|
||||
session_start();
|
||||
|
||||
if (!isset($_SESSION['id']))
|
||||
return ;
|
||||
|
||||
$now = time();
|
||||
|
||||
if(($now-$_SESSION['session_time'])>1200) //超时时间,单位:秒,这里设为20分钟
|
||||
{
|
||||
unset($_SESSION['id']); //超时了.
|
||||
return;
|
||||
}
|
||||
|
||||
$_SESSION['session_time']=$now; //还没超时
|
||||
}
|
||||
|
||||
function clear_session()
|
||||
{
|
||||
session_destroy();
|
||||
}
|
||||
?>
|
131
tools_sql.php
Normal file
131
tools_sql.php
Normal file
@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
$cmi_sql=null;
|
||||
|
||||
function get_sql()
|
||||
{
|
||||
global $cmi_sql;
|
||||
|
||||
if($cmi_sql)
|
||||
return $cmi_sql;
|
||||
|
||||
$cmi_sql=new mysqli("localhost","root","123456","CMI_ERP");
|
||||
|
||||
if($cmi_sql->connect_error)
|
||||
{
|
||||
echo "Connection mysql error: ".$sql->connect_error;
|
||||
return null;
|
||||
}
|
||||
|
||||
$cmi_sql->query("SET NAMES 'utf8'");
|
||||
$cmi_sql->query("use CMI_ERP");
|
||||
|
||||
return $cmi_sql;
|
||||
}
|
||||
|
||||
function get_field_list($table_name)
|
||||
{
|
||||
$sql=get_sql();
|
||||
|
||||
if($sql==null)return null;
|
||||
|
||||
$sql_result=$sql->query("desc ".$table_name);
|
||||
|
||||
if(!$sql_result)
|
||||
return null;
|
||||
|
||||
$field_list=array();
|
||||
while ($row = $sql_result->fetch_object())
|
||||
$field_list[] = $row->Field;
|
||||
|
||||
return $field_list;
|
||||
}
|
||||
|
||||
function select_table($table_name,$field_list,$where,$start,$count)
|
||||
{
|
||||
$sql=get_sql();
|
||||
|
||||
if($sql==null)return;
|
||||
|
||||
$sql_string="select";
|
||||
|
||||
if($field_list==null)
|
||||
{
|
||||
$sql_string=$sql_string." * from ".$table_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
for($i=0;$i<count($field_list);$i++)
|
||||
if($i==0)
|
||||
$sql_string=$sql_string.' '.$field_list[$i];
|
||||
else
|
||||
$sql_string=$sql_string.','.$field_list[$i];
|
||||
|
||||
$sql_string=$sql_string." from ".$table_name;
|
||||
}
|
||||
|
||||
if($where!=null&&strlen($where)>3)
|
||||
$sql_string=$sql_string." where ".$where;
|
||||
|
||||
if($count!=0)$sql_string=$sql_string." limit ".$start.",".$count;
|
||||
|
||||
$sql_result=$sql->query($sql_string);
|
||||
|
||||
$result=array();
|
||||
$index=0;
|
||||
|
||||
while($row=$sql_result->fetch_row())
|
||||
{
|
||||
$result[$index]=$row;
|
||||
$index++;
|
||||
}
|
||||
|
||||
$sql_result->close();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function select_field($table_name,$field,$where)
|
||||
{
|
||||
$sql=get_sql();
|
||||
|
||||
if($sql==null)return;
|
||||
|
||||
$sql_string="select ".$field." from ".$table_name." where ".$where;
|
||||
|
||||
$sql_result=$sql->query($sql_string);
|
||||
|
||||
if(!$sql_result)
|
||||
return null;
|
||||
|
||||
$row=$sql_result->fetch_object();
|
||||
|
||||
$sql_result->close();
|
||||
return $row;
|
||||
}
|
||||
|
||||
function sql_insert($table_name,$data_array)
|
||||
{
|
||||
$sql=get_sql();
|
||||
|
||||
if($sql==null)return;
|
||||
|
||||
$sql_string="insert into ".$table_name." SET";
|
||||
|
||||
$count=0;
|
||||
|
||||
foreach($data_array as $field=>$value)
|
||||
{
|
||||
|
||||
if($count==0)
|
||||
$sql_string=$sql_string.' '.$field.'="'.$value.'"';
|
||||
else
|
||||
$sql_string=$sql_string.','.$field.'="'.$value.'"';
|
||||
|
||||
++$count;
|
||||
}
|
||||
|
||||
echo 'SQLString: '.$sql_string;
|
||||
$sql->query($sql_string);
|
||||
}
|
||||
?>
|
79
ui_sidebar.php
Normal file
79
ui_sidebar.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
require_once "tools.php";
|
||||
require_once "tools_session.php";
|
||||
|
||||
class UISideBar
|
||||
{
|
||||
private $active="";
|
||||
|
||||
public function __construct($a)
|
||||
{
|
||||
$this->active=$a;
|
||||
}
|
||||
|
||||
private function echo_item($link,$text)
|
||||
{
|
||||
echo '<a class="list-group-item';
|
||||
|
||||
if($link==$this->active)
|
||||
echo ' active';
|
||||
|
||||
echo '" href="'.$link.'.php">'.$text.'</a>';
|
||||
}
|
||||
|
||||
private function echo_header()
|
||||
{
|
||||
init_session();
|
||||
|
||||
echo_html_header("CMI MoneyCabinet");
|
||||
|
||||
echo_title();
|
||||
|
||||
echo '<center><p><h5>';
|
||||
|
||||
echo_span_label("primary",$_SESSION['service_hall_fullname']);echo' ';
|
||||
echo_span_label("Warning",$_SESSION['usercode']);echo' ';
|
||||
echo_span_label("default",$_SESSION['name']);echo' ';
|
||||
echo_span_label("danger",$_SESSION['currency']);
|
||||
|
||||
echo '</h5></p>
|
||||
</center>';
|
||||
|
||||
echo_hr();
|
||||
}
|
||||
|
||||
public function start()
|
||||
{
|
||||
$this->echo_header();
|
||||
|
||||
echo '<div class="col-xs-2 bs-docs-sidebar">
|
||||
<div class="list-group bs-docs-sidenav affix-top">';
|
||||
|
||||
$this->echo_item("main", "现金总览" );
|
||||
$this->echo_item("main_money_cabinet", "钱柜" );
|
||||
$this->echo_item("main_service_hall", "营业厅" );
|
||||
$this->echo_item("main_staff", "工作人员" );
|
||||
$this->echo_item("main_customer", "客户总览" );
|
||||
$this->echo_item("main_customer_currency", "客户详情" );
|
||||
$this->echo_item("main_deposit", "存款" );
|
||||
$this->echo_item("main_teller", "取款" );
|
||||
$this->echo_item("main_exchange", "存款兑换" );
|
||||
$this->echo_item("main_cash_exchange", "现金兑换" );
|
||||
$this->echo_item("main_transfer", "汇款" );
|
||||
$this->echo_item("main_transfer_to_bank", "汇至银行" );
|
||||
$this->echo_item("main_transfer_from_bank", "银行入帐" );
|
||||
|
||||
echo '</div>
|
||||
</div>
|
||||
<div div class="col-xs-10">';
|
||||
}
|
||||
|
||||
public function end()
|
||||
{
|
||||
echo '</div>';
|
||||
|
||||
echo_html_end();
|
||||
}
|
||||
};//class UISideBar
|
||||
?>
|
69
ui_tab.php
Normal file
69
ui_tab.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
class UITabView
|
||||
{
|
||||
private $title=null;
|
||||
private $active_page=null;
|
||||
|
||||
public function __construct($name)
|
||||
{
|
||||
$this->title=$name;
|
||||
}
|
||||
|
||||
public function tab_start($active)
|
||||
{
|
||||
echo '<div id="'.$this->title.'">
|
||||
<ul class="nav nav-tabs">';
|
||||
|
||||
$this->count=0;
|
||||
$this->active_page=$active;
|
||||
}
|
||||
|
||||
public function tab_add($label,$name)
|
||||
{
|
||||
if($this->active_page==$label)
|
||||
echo '<li class="active"><a href="#'.$label.'">'.$name.'</a></li>';
|
||||
else
|
||||
echo '<li><a href="#'.$label.'">'.$name.'</a></li>';
|
||||
}
|
||||
|
||||
public function content_start()
|
||||
{
|
||||
echo '</ul>
|
||||
|
||||
<div class="tab-content">';
|
||||
}
|
||||
|
||||
public function page_start($label)
|
||||
{
|
||||
if($this->active_page==$label)
|
||||
echo '<div id="'.$label.'">';
|
||||
else
|
||||
echo '<div id="'.$label.'" class="tab-pane">';
|
||||
}
|
||||
|
||||
public function page_end()
|
||||
{
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
public function tab_end()
|
||||
{
|
||||
echo '</div>
|
||||
</div>';
|
||||
|
||||
echo "<script>
|
||||
YUI().use(
|
||||
'aui-tabview',
|
||||
function(Y) {
|
||||
new Y.TabView(
|
||||
{
|
||||
srcNode: '#".$this->title."'
|
||||
}
|
||||
).render();
|
||||
}
|
||||
);
|
||||
</script>";
|
||||
}
|
||||
};//class UITabView
|
||||
?>
|
196
ui_table.php
Normal file
196
ui_table.php
Normal file
@ -0,0 +1,196 @@
|
||||
<?php
|
||||
|
||||
require_once "tools_sql.php";
|
||||
|
||||
class UITable
|
||||
{
|
||||
private $title="";
|
||||
protected $columns=null;
|
||||
protected $columns_label=array(); //即使用label来显示列头
|
||||
|
||||
private $row_out=0;
|
||||
private $col_out=0;
|
||||
|
||||
public function __construct1($name)
|
||||
{
|
||||
$this->title=$name;
|
||||
}
|
||||
|
||||
public function __construct2($name,$field_list)
|
||||
{
|
||||
$this->title=$name;
|
||||
$this->columns=$field_list;
|
||||
}
|
||||
|
||||
public function set_cols($name)
|
||||
{
|
||||
$this->columns=$name;
|
||||
}
|
||||
|
||||
public function add_col($name,$label=null)
|
||||
{
|
||||
if($this->columns==null)
|
||||
$this->columns=array();
|
||||
|
||||
if(is_array($name))
|
||||
{
|
||||
for($i=0;$i<count($name);$i++)
|
||||
$this->columns[]=$name[$i];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->columns[]=$name; //增加$name到columns数组中去,不需要返回值的情况下比array_push快(PHP.net官网说的)
|
||||
|
||||
if($label!=null)
|
||||
$this->columns_label[$name]=$label;
|
||||
}
|
||||
}
|
||||
|
||||
public function set_col_label($name,$label)
|
||||
{
|
||||
if($name!=null&&$label!=null)
|
||||
$this->columns_label[$name]=$label;
|
||||
}
|
||||
|
||||
public function echo()
|
||||
{
|
||||
echo '<div id="'.$this->title.'"></div>';
|
||||
}
|
||||
|
||||
private function echo_col($index)
|
||||
{
|
||||
$name=$this->columns[$index];
|
||||
|
||||
if(array_key_exists($name,$this->columns_label))
|
||||
echo '{ key: "'.$name.'", label: "'.$this->columns_label[$name].'"}';
|
||||
else
|
||||
echo $name;
|
||||
}
|
||||
|
||||
public function start()
|
||||
{
|
||||
echo "<script>
|
||||
YUI().use(
|
||||
'aui-datatable',
|
||||
function(Y)
|
||||
{
|
||||
var columns = [";
|
||||
|
||||
echo "'";$this->echo_col(0);echo "'";
|
||||
|
||||
for($i=1;$i<count($this->columns);$i++)
|
||||
{
|
||||
echo ",'";$this->echo_col($i);echo "'";
|
||||
}
|
||||
|
||||
echo "];
|
||||
|
||||
var data=[";
|
||||
}
|
||||
|
||||
public function start_row()
|
||||
{
|
||||
if($this->row_out!=0)
|
||||
echo ',
|
||||
{';
|
||||
else
|
||||
echo '{';
|
||||
|
||||
$this->col_out=0;
|
||||
}
|
||||
|
||||
public function out_col($contact)
|
||||
{
|
||||
echo $this->columns[$this->col_out]." : '".$contact."'";
|
||||
|
||||
++$this->col_out;
|
||||
|
||||
if($this->col_out<count($this->columns))
|
||||
echo ',';
|
||||
else
|
||||
{
|
||||
echo '}';
|
||||
++$this->row_out;
|
||||
}
|
||||
}
|
||||
|
||||
public function end()
|
||||
{
|
||||
echo "];
|
||||
|
||||
new Y.DataTable.Base(
|
||||
{
|
||||
columnset: columns,
|
||||
recordset: data
|
||||
}
|
||||
).render('#".$this->title."');
|
||||
}
|
||||
);
|
||||
|
||||
</script>";
|
||||
}
|
||||
};//class UITable
|
||||
|
||||
class UISQLTable extends UITable
|
||||
{
|
||||
private $sql_result=null;
|
||||
private $bool_text=array();
|
||||
|
||||
public function __construct($label,$sql_table_name,$field_list,$where)
|
||||
{
|
||||
parent::__construct2($label,$field_list);
|
||||
|
||||
if($field_list==null)
|
||||
{
|
||||
$field_list=get_field_list($sql_table_name);
|
||||
|
||||
$this->set_cols($field_list);
|
||||
|
||||
$this->sql_result=select_table($sql_table_name,null,$where,0,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->set_cols($field_list);
|
||||
|
||||
$this->sql_result=select_table($sql_table_name,$field_list,$where,0,0);
|
||||
}
|
||||
}
|
||||
|
||||
public function SetBoolText($field,$true_text,$false_text)
|
||||
{
|
||||
$this->bool_text[$field]=array($false_text,$true_text);
|
||||
}
|
||||
|
||||
public function get_sql_result()
|
||||
{
|
||||
return $this->sql_result;
|
||||
}
|
||||
|
||||
public function echo()
|
||||
{
|
||||
parent::echo();
|
||||
|
||||
$this->start();
|
||||
|
||||
for($r=0;$r<count($this->sql_result);$r++)
|
||||
{
|
||||
$row=$this->sql_result[$r];
|
||||
|
||||
$this->start_row();
|
||||
for($c=0;$c<count($row);$c++)
|
||||
{
|
||||
if(array_key_exists($this->columns[$c],$this->bool_text))
|
||||
{
|
||||
$this->out_col($this->bool_text[$this->columns[$c]][$row[$c]]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->out_col($row[$c]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->end();
|
||||
}
|
||||
};//class UISQLTable
|
||||
?>
|
34
ui_toolbar.php
Normal file
34
ui_toolbar.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
class UIToolBar
|
||||
{
|
||||
private $label="";
|
||||
|
||||
function __construct($lab)
|
||||
{
|
||||
$this->label=$lab;
|
||||
}
|
||||
|
||||
function start()
|
||||
{
|
||||
echo '<div id="'.$this->label.'" class="toolbar">';
|
||||
}
|
||||
|
||||
function end()
|
||||
{
|
||||
echo "</div>
|
||||
<script>
|
||||
YUI().use(
|
||||
'aui-toolbar',
|
||||
function(Y) {
|
||||
new Y.Toolbar(
|
||||
{
|
||||
boundingBox: '#".$this->label."'
|
||||
}
|
||||
).render();
|
||||
}
|
||||
);
|
||||
</script>";
|
||||
}
|
||||
};//class UIToolBar
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user