function listPatches()
{
    global $patch;
    //if(mysql_num_rows(mysqlQuery("SHOW TABLES LIKE '".TB_PREFIX."sql_patchmanager'")) == 1) {
    $display_block = <<<EOD
\t\t<b>Simple Invoices :: Database Upgrade Manager</b><br /><br />
\t\t
\t\tYour version of Simple Invoices has been upgraded<br /><br />  
\t\tWith this new release there are database patches that need to be applied<br /><br />
\t\t
\t\t<hr />

\t\t<table align="center">
\t\t\t<tr>
\t\t\t\t<td>
\t\t\t\t\t<br />
\t\t\t\t\t\tThe list below describes which patches have and have not been applied to the database, the aim is to have them all applied.  If there are patches that have not been applied to the Simple Invoices database, please run the Update database by clicking update 
\t\t\t\t</td>
\t\t\t</tr>
\t\t</table>
\t\t
\t\t
\t\t<table class="buttons" align="center">
\t<tr>
\t\t
\t\t<td>

            <a href="./index.php?case=run" class="positive">
                <img src="./images/common/tick.png" alt="" />
                Update
            </a>
    
        </td>
    </tr>
</table>
\t\t
\t\t
\t\t<br />
\t\t<img src="./images/common/important.png" alt="" /><font color="red">Warning: Please backup your database before upgrading!</font>
\t\t<br />
\t\t<br />
<table align="center">
EOD;
    for ($p = 0; $p < count($patch); $p++) {
        $patch_name = htmlsafe($patch[$p]['name']);
        $patch_date = htmlsafe($patch[$p]['date']);
        if (check_sql_patch($p, $patch[$p]['name'])) {
            $display_block .= "\n<tr><td>SQL patch {$p}, {$patch_name} <i>has</i> already been applied in release {$patch_date}</td></tr>";
        } else {
            $display_block .= "\n<tr><td>SQL patch {$p}, {$patch_name} <b>has not</b> been applied to the database</td></tr>";
        }
    }
    $display_block .= "\n</table>";
    global $smarty;
    $smarty->assign("display_block", $display_block);
}
function listPatches()
{
    global $patch;
    //if(mysql_num_rows(mysqlQuery("SHOW TABLES LIKE '".TB_PREFIX."sql_patchmanager'")) == 1) {
    $smarty_datas = array();
    $smarty_datas['message'] = "Your version of Simple Invoices can now be upgraded.\tWith this new release there are database patches that need to be applied";
    $smarty_datas['html'] = <<<EOD
\t<p>
\t\t\tThe list below describes which patches have and have not been applied to the database, the aim is to have them all applied.<br />  
\t\t\tIf there are patches that have not been applied to the Simple Invoices database, please run the Update database by clicking update 
\t</p>

\t<div class="si_message_warning">Warning: Please backup your database before upgrading!</div>

\t<div class="si_toolbar si_toolbar_form"><a href="./index.php?case=run" class=""><img src="./images/common/tick.png" alt="" />Update</a></div>
EOD;
    for ($p = 0; $p < count($patch); $p++) {
        $patch_name = htmlsafe($patch[$p]['name']);
        $patch_date = htmlsafe($patch[$p]['date']);
        if (check_sql_patch($p, $patch[$p]['name'])) {
            $smarty_datas['rows'][$p]['text'] = "SQL patch {$p}, {$patch_name} <i>has</i> already been applied in release {$patch_date}";
            $smarty_datas['rows'][$p]['result'] = 'skip';
        } else {
            $smarty_datas['rows'][$p]['text'] = "SQL patch {$p}, {$patch_name} <b>has not</b> been applied to the database";
            $smarty_datas['rows'][$p]['result'] = 'todo';
        }
    }
    global $smarty;
    $smarty->assign("page", $smarty_datas);
}