Changeset 152 for www/finance/finance.php
- Timestamp:
- Feb 16, 2009, 2:09:57 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
www/finance/finance.php
r70 r152 1 1 <?php 2 2 3 include('../global.php'); 4 include_once('classes.php'); 3 class Finance extends Module 4 { 5 5 6 function MakeLink($Target, $Title)7 {8 return('<a href="'.$Target.'">'.$Title.'</a>');9 }10 11 function Table($Table)12 {13 $Result = '<table cellspacing="0" border="1" cellpadding="3" class="BasicTable">';14 $Result .= '<tr>';15 foreach($Table['Header'] as $Item)16 $Result .= '<th>'.$Item.'</th>';17 $Result .= '</tr>';18 foreach($Table['Rows'] as $Row)19 {20 $Result .= '<tr>';21 foreach($Row as $Item)22 $Result .= '<td>'.$Item.'</td>';23 $Result .= '</tr>';24 }25 $Result .= '</table>';26 return($Result);27 }28 29 function ShowEditTable($ClassName, $Values)30 {31 global $Classes, $Types, $Database;32 33 $Class = $Classes[$ClassName];34 $Table = array(35 'Header' => array('Položka', 'Hodnota'),36 'Rows' => array(),37 );38 39 foreach($Class['Items'] as $Index => $Item)40 {41 if(!array_key_exists($Index, $Values)) $Values[$Index] = $Item['Default'];42 switch($Item['Type'])43 {44 case 'Boolean':45 if($Values[$Index] == 0) $Checked = ''; else $Checked = ' CHECKED';46 $Edit = '<input type="checkbox" name="'.$Index.'"'.$Checked.'>';47 break;48 case 'String':49 $Edit = '<input type="text" name="'.$Index.'" value="'.$Values[$Index].'">';50 break;51 case 'Integer':52 $Edit = '<input type="text" name="'.$Index.'" value="'.$Values[$Index].'">';53 break;54 case 'Float':55 $Edit = '<input type="text" name="'.$Index.'" value="'.$Values[$Index].'">';56 break;57 case 'Time':58 if($Values[$Index] == 'Now') $Values[$Index] = date('j.n.Y');59 $Edit = '<input type="text" name="'.$Index.'" value="'.$Values[$Index].'">';60 break;61 case 'FinanceSubject':62 63 $Edit = '<select name="'.$Index.'">';64 $DbResult = $Database->select('users', 'id, CONCAT(second_name, " ", first_name) as fullname', 'role=2 ORDER BY fullname');65 while($Row = $DbResult->fetch_array())66 $Edit .= '<option value="'.$Row['id'].'">'.$Row['fullname'].'</option>';67 $Edit .= '</select>';68 break;69 case 'Array':70 $Edit = ShowEditTable($Item['ItemClass'], array());71 $Edit .= '<form action="?Operation=AddItem&dsd" method="post"><input type="submit" value="Přidat položku"></form>';72 break;73 default:74 $Edit = 'Neznámý typ';75 }76 array_push($Table['Rows'], array($Item['Caption'], $Edit));77 }78 $Output = '<h3>'.$Class['Title'].'</h3>'.Table($Table);79 return($Output);80 }81 82 function LoadSubmitedData($ClassName)83 {84 global $Classes, $Types, $Database;85 86 $Class = $Classes[$ClassName];87 $Values = array();88 89 foreach($Class['Items'] as $Index => $Item)90 {91 switch($Item['Type'])92 {93 case 'Boolean':94 if(array_key_exists($Index, $_POST)) $Values[$Index] = 1;95 else $Values[$Index] = 0;96 break;97 case 'String':98 $Values[$Index] = $_POST[$Index];99 break;100 case 'Integer':101 $Values[$Index] = $_POST[$Index];102 break;103 case 'Float':104 $Values[$Index] = $_POST[$Index];105 break;106 case 'Time':107 $Values[$Index] = explode('.', $_POST[$Index]);108 $Values[$Index] = mktime(0, 0, 0, $Values[$Index][1], $Values[$Index][0], $Values[$Index][2]);109 break;110 case 'FinanceSubject':111 $Values[$Index] = $_POST[$Index];112 break;113 default:114 }115 }116 return($Values);117 6 } 118 7
Note:
See TracChangeset
for help on using the changeset viewer.