commit 6ef7faefd8d2e9942a2a05d4a39f325fdacdf0c4 Author: hyzboy Date: Sun Aug 21 23:06:17 2016 +0400 初始版本 diff --git a/form/form.php b/form/form.php new file mode 100644 index 0000000..9493564 --- /dev/null +++ b/form/form.php @@ -0,0 +1,123 @@ +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 ''; + } + + function add_edit_date($flag) + { + echo ''; + } + + public function start() + { + echo '
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 ''; + echo '
'; + } + + public function end() + { + echo ''; + } + };//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)); + } diff --git a/form/form_button.php b/form/form_button.php new file mode 100644 index 0000000..c1b51d0 --- /dev/null +++ b/form/form_button.php @@ -0,0 +1,52 @@ +text=$t; + } + + public function SetGlyph($g) + { + $this->text=''; + } + + 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 ''; + } + };//class UIButton + + function create_js_button($text,$js_func) + { + echo ''; + } +?> diff --git a/form/form_editbox.php b/form/form_editbox.php new file mode 100644 index 0000000..efac16b --- /dev/null +++ b/form/form_editbox.php @@ -0,0 +1,60 @@ +type=$t; + $this->id=$i; + $this->size=$s; + } + + public function echo() + { + echo ''; + } + };//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=''.$text.''; + } + + public function SetAddonBack($text) + { + $this->addon_back=''.$text.''; + } + + public function echo() + { + echo '
'; + echo $this->addon_front; + parent::echo(); + echo $this->addon_back; + echo '
'; + } + };//class UIInputGroup + + function CreateInputGroup($type,$id,$label,$size) + { + $but=new UIInputGroup($type,$id,$size); + $but->SetAddonFront($label); + $but->echo(); + + return $but; + } +?> diff --git a/form/form_radio.php b/form/form_radio.php new file mode 100644 index 0000000..4b2d4cb --- /dev/null +++ b/form/form_radio.php @@ -0,0 +1,35 @@ +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 'selected==$value) + echo ' checked="checked"'; + + echo '/>'; + } + } +?> diff --git a/form/form_select.php b/form/form_select.php new file mode 100644 index 0000000..7048419 --- /dev/null +++ b/form/form_select.php @@ -0,0 +1,43 @@ +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 ''; + } + } +?> diff --git a/phptools.kdev4 b/phptools.kdev4 new file mode 100644 index 0000000..63ae9b4 --- /dev/null +++ b/phptools.kdev4 @@ -0,0 +1,3 @@ +[Project] +Manager=KDevGenericManager +Name=phptools diff --git a/phptools.php b/phptools.php new file mode 100644 index 0000000..1080121 --- /dev/null +++ b/phptools.php @@ -0,0 +1,7 @@ + + + '.$title.' + + + + + + + + '; + } + + function echo_title() + { + echo '

Enterprise Resource Management System

'; + } + + function echo_html_end() + { + echo ' + '; + } + + function echo_hr() + { + echo '
'; + } + + function echo_include_script($filename) + { + echo ''; + } + + function echo_autogoto($time,$page) + { + echo ''; + } + + function echo_span_glyph($glyph) + { + echo ''; + } + + function echo_span_label($style,$text) + { + echo ''.$text.''; + } + + function echo_alert($style,$text) + { + echo ''; + } +?> diff --git a/tools_currency.php b/tools_currency.php new file mode 100644 index 0000000..55fe2b1 --- /dev/null +++ b/tools_currency.php @@ -0,0 +1,219 @@ +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(); + } diff --git a/tools_firstpage.js b/tools_firstpage.js new file mode 100644 index 0000000..8fb7b87 --- /dev/null +++ b/tools_firstpage.js @@ -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(); +} diff --git a/tools_form.php b/tools_form.php new file mode 100644 index 0000000..2a3083f --- /dev/null +++ b/tools_form.php @@ -0,0 +1,19 @@ +'.$name.''; + } + + function echo_field_start($name) + { + echo '
'.$name.''; + } + + function echo_field_end() + { + echo '
'; + } +?> diff --git a/tools_session.php b/tools_session.php new file mode 100644 index 0000000..d559e08 --- /dev/null +++ b/tools_session.php @@ -0,0 +1,26 @@ +1200) //超时时间,单位:秒,这里设为20分钟 + { + unset($_SESSION['id']); //超时了. + return; + } + + $_SESSION['session_time']=$now; //还没超时 + } + + function clear_session() + { + session_destroy(); + } +?> \ No newline at end of file diff --git a/tools_sql.php b/tools_sql.php new file mode 100644 index 0000000..caf6fd3 --- /dev/null +++ b/tools_sql.php @@ -0,0 +1,131 @@ +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;$i3) + $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); + } +?> diff --git a/ui_sidebar.php b/ui_sidebar.php new file mode 100644 index 0000000..6f24406 --- /dev/null +++ b/ui_sidebar.php @@ -0,0 +1,79 @@ +active=$a; + } + + private function echo_item($link,$text) + { + echo ''.$text.''; + } + + private function echo_header() + { + init_session(); + + echo_html_header("CMI MoneyCabinet"); + + echo_title(); + + echo '

'; + + 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 '

+
'; + + echo_hr(); + } + + public function start() + { + $this->echo_header(); + + echo '
+
'; + + $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 '
+
+
'; + } + + public function end() + { + echo '
'; + + echo_html_end(); + } + };//class UISideBar +?> diff --git a/ui_tab.php b/ui_tab.php new file mode 100644 index 0000000..1d0ba22 --- /dev/null +++ b/ui_tab.php @@ -0,0 +1,69 @@ +title=$name; + } + + public function tab_start($active) + { + echo '
+ + +
'; + } + + public function page_start($label) + { + if($this->active_page==$label) + echo '
'; + else + echo '
'; + } + + public function page_end() + { + echo '
'; + } + + public function tab_end() + { + echo '
+
'; + + echo ""; + } + };//class UITabView +?> diff --git a/ui_table.php b/ui_table.php new file mode 100644 index 0000000..c2ad792 --- /dev/null +++ b/ui_table.php @@ -0,0 +1,196 @@ +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;$icolumns[]=$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 '
'; + } + + 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 ""; + } + };//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;$rsql_result);$r++) + { + $row=$this->sql_result[$r]; + + $this->start_row(); + for($c=0;$ccolumns[$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 +?> diff --git a/ui_toolbar.php b/ui_toolbar.php new file mode 100644 index 0000000..3f7f18a --- /dev/null +++ b/ui_toolbar.php @@ -0,0 +1,34 @@ +label=$lab; + } + + function start() + { + echo '
'; + } + + function end() + { + echo "
+ "; + } + };//class UIToolBar +?>