Add Activities

Activities are used to launch Reports and Procedures that have been designed using PHP and the nuBuilder Report Builder.

There are three types of activities available: Reports, Exports and *Procedures .

Activities are created via the Add Activity Button on the Setup Tab and once they have been created, you can access any of them from the same list.

* Procedures are ideal for running PHP code the doesn't need to return a result for the user.

Its basically works the same way as a report, except that its job isn't to display something (just to run php).
It will just give you a blank html page when its finished, although you can echo stuff out to this page if you want.

eg.It can be used for recreating Primary and Foreign keys that nuBuilder can handle..

//-- create the 2 variables for each table that needs a new primary key.
$pk_table['gig']['old_pk']      = 'gig_id';
$pk_table['gig']['new_pk']      = 'nuest_customer_id';
//-- then create 2 variables for each table that will be linked by a foreign key to this table.
$pk_table['gig'][0]['fk_table'] = 'gig_artist';
$pk_table['gig'][0]['fk_field'] = 'art_gig_id';
//$pk_table['customer'][1]['fk_table'] = 'customer_group_link';
//$pk_table['customer'][1]['fk_field'] = 'cgl_customer_id';
foreach( $pk_table as $table => $value){
//--- create a new field that will become the new primary key
        $old_pk                      = $pk_table[$table]['old_pk'];
        $new_pk                      = $pk_table[$table]['new_pk'];
        nuRunQuery("ALTER TABLE `$table` ADD `$new_pk` VARCHAR(15) NOT NULL FIRST");
        for($i = 2 ; $i < count($pk_table[$table]) ; $i++){
//--- create a new field that will become the new foreign key 
//--- (it will be the same name as the current fk but prefixed with 'nu_')
            $FT                      = $pk_table[$table][$i-2]['fk_table'];
            $FF                      = $pk_table[$table][$i-2]['fk_field'];
            $update_string           = "ALTER TABLE `$FT` ADD ";
            $update_string          .= "`nu_$FF` VARCHAR(15) NOT NULL ;";
        $t                           = nuRunQuery("SELECT `$old_pk` FROM $table ORDER BY `$old_pk`");
        while($r                     = db_fetch_row($t)){
            $new_id                  = uniqid('1');
            $old_id                  = $r[0];
            $update_string           = "UPDATE `$table` SET `$new_pk` = '$new_id' ";
            $update_string          .= "WHERE `$old_pk` = '$old_id'";
            for($i = 2 ; $i < count($pk_table[$table]) ; $i++){
                $FT                  = $pk_table[$table][$i-2]['fk_table'];
                $FF                  = $pk_table[$table][$i-2]['fk_field'];
                $update_string       = "UPDATE `$FT` SET `nu_$FF` = '$new_id' ";
                $update_string      .= "WHERE `$FF` = '$old_id'";

Created by: steven. Last Modification: Friday 02 of July, 2010 11:19:13 CST by steven.