Index: content_complete.admin.inc
===================================================================
--- content_complete.admin.inc	(revision 371)
+++ content_complete.admin.inc	(working copy)
@@ -19,6 +19,18 @@
 }
 
 /**
+ * Menu Callback Function
+ *  Build output of the tagged content_complete fields
+ *  and allow the ability to assign custom percentages for each field
+ */
+function content_complete_percentage_settings() {
+  $header = t('Displays selected fields for content completion. Give each field a desired percentage.<br />'
+  	. 'The fields will only show up once they have been enabled on the !fieldspage page. They can also be disabled there if no longer required.', array('!fieldspage' => l('Fields', 'admin/settings/content_complete')));
+  $form = drupal_get_form('content_complete_percentage_settings_form');
+  return $header . $form;
+}
+
+/**
  * Admin settings form
  */
 function content_complete_admin_settings_form() {
@@ -63,20 +75,34 @@
  */
 function content_complete_admin_settings_form_submit($form, &$form_state) {
   if (is_array($form_state['values']) && ! empty($form_state['values'])) {
-    db_query("DELETE FROM {content_complete}");
-    foreach ($form_state['values'] as $content_type => $value) {
+  	
+  	$sql = "SELECT * FROM {content_complete}";
+  	$result = db_query($sql);
 
-      if (is_array($value) && isset($value['fields'])) {
-        //$content = array_filter($value['content']);
-        $fields = array_filter($value['fields']);
+	while ($rows = db_fetch_object($result)) {
+		$available[$rows->type][$rows->field_name]['name'] = $rows->field_name;
+		$available[$rows->type][$rows->field_name]['percent'] = $rows->percentage;
+	}
+	
+	// Delete all values since we have saved them in the above array
+	db_query("DELETE FROM {content_complete}");
+  	
+  	foreach($form_state['values'] as $content_type => $value) {
+  		if (is_array($value) && (isset($value['fields']))) {
+  			$fields = array_filter($value['fields']);
+  			foreach($fields as $field) {
+  				// Provide a default percentage
+  				$percentage = 0;
+  				// Already in the database, so maintain the percentage value
+  				if ( ($field == $available[$content_type][$field]['name']) && ($available[$content_type][$field]['percent'] != 0) ) {
+  					$percentage = $available[$content_type][$field]['percent'];
+  				}
+  				$sql = "INSERT INTO {content_complete} VALUES ('%s', '%s', '%s')";
+  				db_query($sql, $content_type, $field, $percentage);
+  			}
+  		}
+  	}
 
-        foreach ($fields as $field) {
-          db_query("INSERT INTO {content_complete} VALUES ('%s', '%s')", $content_type, $field);
-        }
-
-      }
-    }
-
     drupal_set_message(t("Your settings have been saved."));
   }
 }
@@ -115,3 +141,113 @@
   
   return $data;
 }
+
+/**
+ * Admin percentages form
+ */
+function content_complete_percentage_settings_form() {
+	// get all content types
+	$types = node_get_types('names');
+  
+	foreach($types as $content_type => $content_name) {
+
+		$data = content_complete_percentage_settings_form_data($content_type);
+		$id = $content_type;
+		$type_set = empty($data['default']['type']) ? FALSE : TRUE;
+		
+		$form[$id]['fields'] = array(
+  			'#suffix' => 'Test',
+  		);
+		
+		// Only display content types that have been tagged  	
+  		if (isset($data['default']['type'][0])) {
+  			$found = true;
+			$form[$id] = array(
+				'#title' => $content_name . ' (' . $data['percentage'] . '%)',
+				'#type' => 'fieldset',
+				'#collapsible' => TRUE,
+				'#collapsed' => !$type_set
+  			);
+  			
+  			// Create a textbox with percentage values for each field
+  			foreach($data['default'] as $fields) {
+  				foreach($fields as $key => $field) {
+  					if ($key) {
+  						$form[$id]['fields'][$key] = array (
+							'#title' => $key,
+							'#type' => 'textfield',
+							'#size' => 5,
+							'#default_value' => $field,
+  						);
+  					}
+  				}
+  			}  		  			  		
+  		}  		
+  		$total_percentage += $data['percentage'];  		  		
+  	}
+  	
+  	if ($total_percentage < 100) {
+  		$warning = "You need a further " . (100 - $total_percentage) . '%';  		
+  	} elseif ($total_percentage > 100) {
+  		$warning = "You need to reduce " . ($total_percentage - 100) . '%';
+  	} else {
+  		$warning = false;
+  	}
+  	
+  	if ($warning && $total_percentage != 0) {
+  		drupal_set_message(t("Total percentage is $total_percentage% - $warning"), 'warning', false);
+  	}
+  
+	$form['submit'] = array(
+		'#type' => 'submit', 
+		'#value' => t('Save') 
+	); 
+    
+	$form['#tree'] = TRUE; // return nested array of fields
+	
+	if ($found) {	
+		return $form;
+	}
+}
+
+/**
+ * Admin percentages form submit
+ */
+function content_complete_percentage_settings_form_submit($form, &$form_state) {
+	foreach($form_state['values'] as $content_type => $value) {
+		if (is_array($value) && isset($value['fields'])) {
+			$fields = array_filter($value['fields']);
+			foreach($fields as $field => $value) {
+				$sql = "UPDATE {content_complete} SET percentage = '%s' WHERE field_name = '%s' AND type = '%s'";
+				$result = db_query($sql, $value, $field, $content_type);
+			}
+		}
+	}
+	drupal_set_message(t("Your settings have been saved."));
+}
+
+function content_complete_percentage_settings_form_data($content_type) {  
+  /**
+   * Put the default values
+   */
+  $default_type = $default_fields = array();
+  $tagged_fields = content_complete_get_tagged_fields($content_type);
+  if (! empty($tagged_fields)) {
+    $default_type[] = $content_type;
+    foreach ($tagged_fields as $tagged_field) {
+    	
+    	$sql = "SELECT percentage FROM {content_complete} WHERE field_name = '%s' AND type = '%s'";
+    	$result = db_query($sql, $tagged_field, $content_type);
+    	while ($rows = db_fetch_object($result)) {
+    		$default_fields[$tagged_field] = $rows->percentage;
+    		$percentage += $rows->percentage;
+    	}
+    }
+  }
+  
+  $data['default']['type'] = $default_type;
+  $data['default']['fields'] = $default_fields;
+  $data['percentage'] = $percentage;
+  
+  return $data;
+}
\ No newline at end of file
Index: content_complete.install
===================================================================
--- content_complete.install	(revision 371)
+++ content_complete.install	(working copy)
@@ -25,6 +25,9 @@
       'field_name' => array(
         'type' => 'varchar', 'length' => '32', 'not null' => TRUE, 'default' => '', 'description' => t('{content_node_field}.field_name') 
       ) 
+      ,'percentage' => array(
+  		'type' => 'int', 'length' => '3', 'not null' => FALSE, 'default' => '0', 'description' => t('{content_node_field}.percentage')
+  	  )
     ) 
   );
   
Index: content_complete.module
===================================================================
--- content_complete.module	(revision 371)
+++ content_complete.module	(working copy)
@@ -21,16 +21,24 @@
  * Implementation of hook_menu()
  */
 function content_complete_menu() {  
-  $items['admin/settings/content_complete'] = array(
-    'title' => 'Content Complete', 
-    'description' => 'Tag CCK fields as required for percent complete handling.', 
-    'page callback' => 'content_complete_admin_settings', 
-    'access arguments' => array(
-      'administer content complete' 
-    ), 
+  $items['admin/settings/content_complete/fields'] = array(
+    'title' => 'Fields',
+    'description' => 'Tag CCK fields as required for percent complete handling.',
+    'page callback' => 'content_complete_admin_settings',
+    'access arguments' => array('administer content complete'),
+    'type' => MENU_DEFAULT_LOCAL_TASK,
     'file' => 'content_complete.admin.inc'
   );
   
+  $items['admin/settings/content_complete/percentages'] = array(
+  	'title' => 'Percentages',
+  	'description' => 'Tag CCK fields as required for percent complete handling.',
+  	'page callback' => 'content_complete_percentage_settings',
+  	'access arguments' => array('administer content complete'),
+  	'type' => MENU_LOCAL_TASK,
+  	'file' => 'content_complete.admin.inc'  
+  );
+  
   return $items;
 }
 
@@ -47,18 +55,41 @@
           $blocks[$type]['info'] = t('Content Complete: !name', array('!name' => $name));
           $blocks[$type]['cache'] = BLOCK_NO_CACHE;
         }
+        $blocks['collate_all_profiles']['info'] = t('Content Complete: Collate all profiles');
+        $blocks['collate_all_profiles']['cache'] = BLOCK_NO_CACHE;
         return $blocks;
         break;
       case 'view':
         $type = $delta;
         $types = node_get_types('names');
-        if (! isset($types[$type]))
-          return;
-        $complete_data = content_complete_get_data($type);
+        $special_block = "collate_all_profiles";
+        
+        if (! isset($types[$type])){
+          if($type !== $special_block){
+            return;
+          }
+        }
+        
+        if($delta == $special_block) {
+          $result = db_query("SELECT distinct type FROM {content_complete}");
+          $content_types = array();
+          while ($data = db_fetch_object($result)) {
+            $content_types[] = $data->type;
+          }
+          $complete_data = content_complete_get_data($content_types);
+        } else {
+          $complete_data = content_complete_get_data($type);
+        }
+        
         $block['subject'] = t('!name', array(
           '!name' => $types[$type] 
           )
         );
+        
+        if (!isset($types[$type])) {
+        	$block['subject'] = t('Collate All Profiles');
+        }
+        
         // only display the block when 100% has not been reached
         if (! empty($complete_data) && $complete_data['percent'] != 100) {
           $block['content'] = theme('content_complete_profile_percent_complete', $complete_data);
@@ -134,18 +165,43 @@
  *   completed etc.
  */
 function content_complete_get_data($content_type, &$user = NULL) {
+  
+  $user_fields_original = array();
+  $user_fields = array();
+  $tagged_fields = array();
+  $fields = array();
   if (!$user) {
     global $user;
   }
   
-  $fields = content_complete_get_fields($content_type); // all fields
-  $tagged_fields = content_complete_get_tagged_fields($content_type); // fields tagged for completed (can be empty)
-  $user_fields = content_complete_get_user_fields($content_type, $user); // fields completed by the user (can be empty)  
+  if(!is_array($content_type)){
+    $fields = content_complete_get_fields($content_type); // all fields
+    $tagged_fields = content_complete_get_tagged_fields($content_type); // fields tagged for completed (can be empty)
+    $user_fields = content_complete_get_user_fields($content_type, $user); // fields completed by the user (can be empty)
+  } else {
+    foreach($content_type as $type) {
+      $fields = array_merge($fields, content_complete_get_fields($type)); // all fields
+      $tagged_fields = array_merge($tagged_fields, content_complete_get_tagged_fields($type));
+      //store contents of content_complete_get_user_fields within $user_fields_original with a key of nid.
+      //this is used later on to retrieve the nid of a field element.
+      $tmp = content_complete_get_user_fields($type, $user);
+      $nid = $tmp[0]['nid']; //$nid associated with the user fields returned.
+      $user_fields_original[$type] = $tmp[0];
+      // Make sure the array has at least some content
+      if (count($tmp) > 0) {
+      	$user_fields = array_merge($user_fields, $tmp[0]);
+      }
+      #unset($user_fields['title']);
+      unset($user_fields['nid']);
+    }
+  }    
 
   /**
    * Only consider the first instance for now
    */
   if (is_array($user_fields) && !empty($user_fields)) {
+  	  	
+  	if(!is_array($content_type))
     $user_fields = $user_fields[0];
   } 
   else {
@@ -158,29 +214,70 @@
   $total = 0;
   $nextfield_set = FALSE;
   
-  // compare the two arrays and compute percentages etc.
-  foreach ($tagged_fields as $key => $value) {
-    if ($user_fields[$value] == '') { // empty field
-      if ($nextfield_set === FALSE) {
-        $nextfield_set = TRUE;
-        $nextfield = $fields[$value]['label'];
-        $nextname = $value;
-      }
-    } 
-    else {
-      $complete++;
-    }
+  $incomplete_fields = array();
+  
+  if (is_array($content_type)) {
+  	foreach ($user_fields_original as $individual_type => $individual_fields) {
+  	  foreach ($individual_fields as $individual_field => $individual_value) {
+  	  	if ($individual_value == '' && $individual_field != 'nid') { // empty field
+  	  	  $incomplete_fields[] = $individual_field;
+  	  	}
+  	  }
+  	}
+  } else {  
+    foreach ($tagged_fields as $key => $value) {
+  	  if ($user_fields[$value] == '') { // empty field
+  	    $incomplete_fields[] = $value;
+  	    if ($nextfield_set === FALSE) {
+  	  	  $nextfield_set = TRUE;
+  	  	  $nextfield = $fields[$value]['label'];
+  	  	  $nextname = $value;
+  	    }
+  	  } else {
+  	    $complete++;
+  	  }
+    }  
   }
+  
+  $complete_data = array();
 
-  $dec = 0;
-  if (count($tagged_fields)) {
-    $dec = number_format(($complete / count($tagged_fields)), 2);
+  // Only work out the percentage if the content type is individual  
+  if (!is_array($content_type)) {
+  	$dec = 0;
+  	if (count($tagged_fields)) {
+      $dec = number_format(($complete / count($tagged_fields)), 2);
+  	}
+  	$percent = $dec * 100;
+  	if ($nextfield_set) {
+      $next = number_format((($complete + 1) / count($tagged_fields)), 2);
+      $nextpercent = $next * 100;
+  	}
+  } else {
+  	$complete_data['allprofiles'] = true;
+  	$sql = "SELECT * FROM {content_complete} WHERE field_name = '%s' AND type = '%s'";
+  	foreach ($user_fields_original as $individual_type => $individual_fields) {
+  	  // Check to make sure there is at least some data in the array
+  	  if (count($individual_fields) > 0) {
+  	    foreach ($individual_fields as $individual_field => $individual_value) {
+  	      // Exclude the 'nid' value as it shouldn't be included
+  	      if ($individual_field != 'nid') {
+  	      	// Field has data
+  	      	if ($individual_value != '') {
+  	      	  $result = db_query($sql, $individual_field, $individual_type);
+  	      	  while ($log = db_fetch_object($result)) {
+  	      	  	$percent += $log->percentage;
+  	      	  }
+  	      	// Field is empty, include in incomplete_fields
+  	      	} else {
+  	      	  $complete_data['incomplete_fields'][$individual_fields['nid']][$individual_field]['machine_name'] = $individual_field;
+  	      	  $complete_data['incomplete_fields'][$individual_fields['nid']][$individual_field]['readable_name'] = $fields[$individual_field]['label'];
+  	      	  $complete_data['incomplete_fields'][$individual_fields['nid']][$individual_field]['type'] = $individual_type;
+  	      	}
+  	  	  }
+  	    }
+  	  }
+  	}
   }
-  $percent = $dec * 100;
-  if ($nextfield_set) {
-    $next = number_format((($complete + 1) / count($tagged_fields)), 2);
-    $nextpercent = $next * 100;
-  }
   
   $incomplete = count($tagged_fields) - $complete;
   $total = count($tagged_fields);
@@ -193,8 +290,7 @@
     if ($percent <= $leq_percent) break;
     $leq_percent+=25;
   }
-  
-  $complete_data = array();
+
   $complete_data['nid'] = $nid;
   $complete_data['percent'] = $percent;
   $complete_data['leq_percent'] = $leq_percent;
@@ -210,8 +306,8 @@
   if (module_exists('i18ncontent')) {
     $complete_data['name'] = tt("nodetype:type:$content_type:name", $type_names[$content_type]);
   }
-  else {
-    $complete_data['name'] = $type_names[$content_type];
+  elseif(!is_array($content_type)) {
+    $complete_data['name'] = $type_names[$content_type]; // put human readble name
   }
   
   return $complete_data;
Index: content_complete.theme.inc
===================================================================
--- content_complete.theme.inc	(revision 371)
+++ content_complete.theme.inc	(working copy)
@@ -40,14 +40,32 @@
   $output .= '</div>';
   $output .= '</div>';
 
-  if ($complete_data['nextfield'] && $complete_data['nextpercent']) {
-    $output .= t('Filling out <i>!nextfield</i> will bring !typename to !complete%.', array(
-      '!nextfield' => l($complete_data['nextfield'], 'node/'. $complete_data['nid'] .'/edit', array(
-        'query' => 'content_complete_fieldname='. $complete_data['nextname'] 
-      )),
-      '!typename' => $complete_data['name'],
-      '!complete' => $complete_data['nextpercent']
-    ));
+  if(!isset($complete_data['allprofiles']) && !$complete_data['allprofiles']){
+    if ($complete_data['nextfield'] && $complete_data['nextpercent']) {
+      $output .= t('Filling out <i>!nextfield</i> will bring !typename to !complete%.', array(
+          '!nextfield' => l($complete_data['nextfield'], 'node/'. $complete_data['nid'] .'/edit', array(
+          'query' => 'content_complete_fieldname='. $complete_data['nextname']
+                 )),
+          '!typename' => $complete_data['name'],
+          '!complete' => $complete_data['nextpercent']
+      ));
+    }
+  } else {
+    if(isset($complete_data['incomplete_fields'])){
+      foreach( $complete_data['incomplete_fields'] as $nid => $field_a ){
+        foreach( $field_a as $field_name => $name_a ){
+        	#print $field_name .' - '. $name_a['type'];
+        	$sql = "SELECT percentage FROM {content_complete} WHERE field_name = '%s' AND type = '%s'";
+        	$result = db_query($sql, $field_name, $name_a['type']);
+        	while ($data = db_fetch_object($result)) {
+				$percentage = $data->percentage;
+			}
+          $output .= "<li>Fill out ";
+          $output .= l($name_a['readable_name'], "node/$nid/edit");
+          $output .= " (+ " . $percentage . "%)</li>";
+        }
+      }
+    }
   }
   
   return $output;
