<?php $instanceArray = array(); $obj = new Fund(); $instanceArray = $obj->allAsArray(); echo "<div class='adminRightHeader'>Fund</div>"; if (count($instanceArray) > 0) { ?> <table class='linedDataTable' > <tr> <th>Code</th> <th>Name</th> <th style='width:20px;'> </th> <th style='width:20px;'> </th> <th style='width:20px;'> </th> </tr> <?php foreach ($instanceArray as $instance) { echo "<tr>"; echo "<td>" . $instance['fundCode'] . "</td>"; echo "<td id='fund-short-name'>" . $instance['shortName'] . "</td>"; echo "<td><a href='ajax_forms.php?action=getAdminFundUpdateForm&updateID=" . $instance['fundID'] . "&height=178&width=260&modal=true' class='thickbox'><img src='images/edit.gif' alt='edit' title='edit'></a></td>"; echo "<td><a href='javascript:deleteFund(\"Fund\", \"" . $instance['fundID'] . "\");'><img src='images/cross.gif' alt='remove' title='remove'></a></td>"; if ($instance['archived'] == 1) { echo "<td><input type='checkbox' title='Archive' id='archived' checked value=" . $instance['archived'] . " onclick='javascript:archiveFund(this.checked, \"" . $instance['fundID'] . "\", \"" . $instance['fundCode'] . "\", \"" . $instance['shortName'] . "\");' > </input></td>"; } else { echo "<td><input type='checkbox' title='Archive' id='archived' onclick='javascript:archiveFund( this.checked, \"" . $instance['fundID'] . "\", \"" . $instance['fundCode'] . "\", \"" . $instance['shortName'] . "\");' > </input></td>"; } echo "</tr>"; } ?>
} } else { $error = _("Unable to get columns headers from the file"); } } else { $error = _("Unable to open the uploaded file"); } if ($error) { print "<p>" . _("Error: ") . $error . "</p>"; } else { // Let's analyze this file if (($handle = fopen($uploadfile, "r")) !== FALSE) { $row = 0; while (($data = fgetcsv($handle)) !== FALSE) { $Fund = new Fund(); $funds = $Fund->allAsArray(); // Convert to UTF-8 $data = array_map(function ($row) { return mb_convert_encoding($row, 'UTF-8'); }, $data); $Fund->fundCode = array_values($data)['0']; $Fund->shortName = array_values($data)['1']; $Fund->save(); $row++; } print "<h2>" . _("Results") . "</h2>"; print "<p> {$row} " . _("rows have been processed.") . "</p>"; } } } else { ?>
<tr> <td class='searchRow'><label for='searchFund'><b><?php echo _("Fund"); ?> </b></label> <br /> <select name='search[fund]' id='searchFund' style='width:150px' class ='changeInput'> <option value=''>All</option> <?php if ($search['fund'] == "none") { echo "<option value='none' selected>" . _("(none)") . "</option>"; } else { echo "<option value='none'>" . _("(none)") . "</option>"; } $fundType = new Fund(); foreach ($fundType->allAsArray() as $fund) { $fundCodeLength = strlen($fund['fundCode']) + 3; $combinedLength = strlen($fund['shortName']) + $fundCodeLength; $fundName = $combinedLength <= 50 ? $fund['shortName'] : substr($fund['shortName'], 0, 49 - $fundCodeLength) . "…"; $fundName .= " [" . $fund['fundCode'] . "]</option>"; echo "<option value='" . $fund['fundID'] . "'>" . $fundName . "</option>"; } ?> </select> </td> </tr> <tr> <td class='searchRow'><label for='searchAcquisitionTypeID'><b><?php