summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordiptighosalkar2015-07-02 17:43:31 +0530
committerdiptighosalkar2015-07-02 17:43:31 +0530
commitdba6af3f096e91d5dad3fc41ce7217f18ec2996d (patch)
treea76da07c490eefebba2d75a901e3e6d2a1059d6f
parent82b86b1ab4158dc98fa5553069b8954692e538b0 (diff)
downloadFOSSEE_Stats_Deprecated-dba6af3f096e91d5dad3fc41ce7217f18ec2996d.tar.gz
FOSSEE_Stats_Deprecated-dba6af3f096e91d5dad3fc41ce7217f18ec2996d.tar.bz2
FOSSEE_Stats_Deprecated-dba6af3f096e91d5dad3fc41ce7217f18ec2996d.zip
modify code
-rwxr-xr-xfossee_stats.module728
1 files changed, 398 insertions, 330 deletions
diff --git a/fossee_stats.module b/fossee_stats.module
index 5fd4756..689d57b 100755
--- a/fossee_stats.module
+++ b/fossee_stats.module
@@ -1,19 +1,19 @@
<?php
- function fossee_stats_permission() {
- return array(
- "access fossee_stats" => array(
- "title" => t("Access fossee_stats"),
- "description" => t("Allows users to view job postings.")
- ),
- "manage fossee_stats" => array(
- "title" => t("Manage fossee_stats"),
- "description" => t("Allows users to manage job postings.")
- ),
- );
- }
+ function fossee_stats_permission() {
+ return array(
+ "access fossee_stats" => array(
+ "title" => t("Access fossee_stats"),
+ "description" => t("Allows users to view job postings.")
+ ),
+ "manage fossee_stats" => array(
+ "title" => t("Manage fossee_stats"),
+ "description" => t("Allows users to manage job postings.")
+ ),
+ );
+ }
- function fossee_stats_menu() {
+ function fossee_stats_menu() {
$items = array();
$items["fossee-stats"] = array(
"title" => "FOSSEE STATS",
@@ -28,371 +28,439 @@
"access arguments" => array("access fossee_stats"),
"type" => MENU_NORMAL_ITEM,
);
-
+ $items["example-charts"] = array(
+ "title" => "Example",
+ "page callback" => "example_page",
+ "access arguments" => array("access content"),
+ "type" => MENU_NORMAL_ITEM,
+ );
$items["jobs/ajax"] = array(
"title" => "Ajax callbacks",
"page callback" => "fossee_stats_ajax",
"access arguments" => array("access fossee_stats"),
"type" => MENU_CALLBACK
);
-
return $items;
- }
-
- function fossee_stats_all(){
- $page = "";
+ }
+ function fossee_stats_all(){
+ $page = "";
$fossee_stats = drupal_get_form('fossee_stats_form');
$page .= drupal_render($fossee_stats);
-
- $page .= "<div id ='fossee-stats-all'>";
-
-
+ $page .= "<div id ='fossee-stats-all'>";
$page .= "</div>";
return $page;
- }
+ }
- function fossee_stats_form($form, &$form_state) {
- $options_first = _ajax_example_get_first_dropdown_options();
-
- // If we have a value for the first dropdown from $form_state['values'] we use
- // this both as the default value for the first dropdown and also as a
- // parameter to pass to the function that retrieves the options for the
- // second dropdown.
- if(isset($form_state['values']['foss_sub_project'])&&isset($form_state['values']['foss_type'])&&isset($form_state['values']['foss_sub_project_status'])){
- $foss_project = isset($form_state['values']['foss_type']) ? $form_state['values']['foss_type'] : key($options_first);
- }else{
- $foss_project = '';
+ function fossee_stats_form($form, &$form_state) {
+
+ $options_first = _ajax_example_get_first_dropdown_options();
+
+ if(isset($form_state['values']['foss_sub_project'])&&isset($form_state['values']['foss_type'])&&isset($form_state['values']['foss_sub_project_status'])){
+ $foss_project = isset($form_state['values']['foss_type']) ? $form_state['values']['foss_type'] : key ($options_first);
+ }else{
+ $foss_project = '';
}
- //$foss_project=$selected;
+
$form['foss_type'] = array(
- '#type' => 'select',
- '#title' => 'FOSS Type',
- '#options' => $options_first,
- '#default_value' => $foss_project,
- // Bind an ajax callback to the change event (which is the default for the
- // select form type) of the first dropdown. It will replace the second
- // dropdown when rebuilt.
- '#ajax' => array(
-
- /* When 'event' occurs, Drupal will perform an ajax request in the background. Usually the default value is sufficient (eg. change for select elements), but valid values include any jQuery event, most notably 'mousedown', 'blur', and 'submit'. 'event' => 'change',*/
- 'callback' =>'ajax_example_dependent_dropdown_callback',
- 'wrapper' => 'dropdown-second-replace',
- ),
- );
- if(isset($form_state['values']['foss_sub_project'])&&isset($form_state['values']['foss_type'])&&isset($form_state['values']['foss_sub_project_status'])){
- $foss_sub_project = isset($form_state['values']['foss_sub_project']) ? $form_state['values']['foss_sub_project'] : key(_ajax_example_get_second_dropdown_options($foss_project));
- }else{
- $foss_sub_project = '';
- }
- $form['foss_sub_project'] = array(
- '#type' => 'select',
- '#title' => t('Foss Sub Project'),
- '#options' => _ajax_example_get_second_dropdown_options($foss_project),
- // The entire enclosing div created here gets replaced when foss_type
- // is changed.
- '#prefix' => '<div id="dropdown-second-replace">',
- '#suffix' => '</div>',
- // When the form is rebuilt during ajax processing, the $selected variable
- // will now have the new value and so the options will change.
- // '#options' => _ajax_example_get_second_dropdown_options($selected),
- '#default_value' => '',
- '#ajax' => array(
-
- // When 'event' occurs, Drupal will perform an ajax request in the
- // background. Usually the default value is sufficient (eg. change for
- // select elements), but valid values include any jQuery event,
- // most notably 'mousedown', 'blur', and 'submit'.
- // 'event' => 'change',
- 'callback' =>'ajax_example_dependent_dropdown_callback1',
- 'wrapper' => 'dropdown-third-replace',
- ),
- );
+ '#type' => 'select',
+ '#title' => 'FOSS Type',
+ '#options' => $options_first,
+ '#default_value' => $foss_project,
+
+ '#ajax' => array(
+ 'callback' =>'ajax_example_dependent_dropdown_callback',
+ 'wrapper' => 'dropdown-second-replace',
+ ),
+ );
+
+
+ if(isset($form_state['values']['foss_sub_project'])&&isset($form_state['values']['foss_type'])&&isset($form_state['values']['foss_sub_project_status'])){
+ $foss_sub_project = isset($form_state['values']['foss_sub_project']) ? $form_state['values']['foss_sub_project'] : key(_ajax_example_get_second_dropdown_options($foss_project));
+ }else{
+ $foss_sub_project = '';
+ }
+
+ $form['foss_sub_project'] = array(
+ '#type' => 'select',
+ '#title' => t('Foss Sub Project'),
+ '#options' => _ajax_example_get_second_dropdown_options($foss_project),
+ '#prefix' => '<div id="dropdown-second-replace">',
+ '#suffix' => '</div>',
+ '#default_value' => '',
+ '#ajax' => array(
+ 'callback' =>'ajax_example_dependent_dropdown_callback1',
+ 'wrapper' => 'dropdown-third-replace',
+ ),
+ );
+
+
if(isset($form_state['values']['foss_sub_project'])&&isset($form_state['values']['foss_type'])&&isset($form_state['values']['foss_sub_project_status'])){
- $foss_sub_project_status = isset($form_state['values']['$foss_sub_project_status']) ? $form_state['values']['$foss_sub_project_status'] : '';
- }else{
- $foss_sub_project_status = '';
- }
+ $foss_sub_project_status = isset($form_state['values']['$foss_sub_project_status']) ? $form_state['values']['$foss_sub_project_status'] : '';
+ }else{
+ $foss_sub_project_status = '';
+ }
- $form['foss_sub_project_status'] = array(
- '#type' => 'select',
- '#title' => t('Status'),
- '#options' => _ajax_example_get_third_dropdown_options($foss_sub_project),
- // The entire enclosing div created here gets replaced when foss_type
- // is changed.
- '#prefix' => '<div id="dropdown-third-replace">',
- '#suffix' => '</div>',
-
- // When the form is rebuilt during ajax processing, the $selected variable
- // will now have the new value and so the options will change.
- // '#options' => _ajax_example_get_second_dropdown_options($selected),
- '#default_value' => $foss_sub_project_status,
- );
+ $form['foss_sub_project_status'] = array(
+ '#type' => 'select',
+ '#title' => t('Status'),
+ '#options' => _ajax_example_get_third_dropdown_options($foss_sub_project),
+ '#prefix' => '<div id="dropdown-third-replace">',
+ '#suffix' => '</div>',
+ '#default_value' => $foss_sub_project_status,
+ );
- if(isset($form_state['values']['foss_sub_project'])&&isset($form_state['values']['foss_type'])&&isset($form_state['values']['foss_sub_project_status'])){
- $foss_select_branch = isset($form_state['values']['foss_select_branch']) ? $form_state['values']['foss_select_branch'] : '';
- }else{
- $foss_select_branch = '';
- }
+ if(isset($form_state['values']['foss_sub_project'])&&isset($form_state['values']['foss_type'])&&isset($form_state['values']['foss_sub_project_status'])){
+ $foss_select_branch = isset($form_state['values']['foss_select_branch']) ? $form_state['values']['foss_select_branch'] : '';
+ }else{
+ $foss_select_branch = '';
+ }
- $form['foss_select_branch'] = array(
- '#type' => 'select',
- '#title' => t('Branch'),
- '#options' => _ajax_get_branch_options($foss_project,$foss_sub_project),
- // The entire enclosing div created here gets replaced when foss_type
- // is changed.
- '#prefix' => '<div id="dropdown-fourth-replace">',
- '#suffix' => '</div>',
-
- // When the form is rebuilt during ajax processing, the $selected variable
- // will now have the new value and so the options will change.
- // '#options' => _ajax_example_get_second_dropdown_options($selected),
- '#default_value' => $foss_select_branch,
- );
-
-
-
- $today = date("Y-m-d H:i:s");
- $form['start_date'] = array(
- '#type' => 'date_popup',
-
- '#default_value' => $today,
- '#date_type' => DATE_DATETIME,
- '#date_format' => 'd/m/Y',
- '#date_increment' => 1,
- '#date_year_range' => '-3:+3',
- );
- $today = date("Y-m-d H:i:s");
- $form['end_date'] = array(
- '#type' => 'date_popup',
- '#default_value' => $today,
- '#date_type' => DATE_DATETIME,
- '#date_format' => 'd/m/Y',
- '#date_increment' => 1,
- '#date_year_range' => '-3:+3',
- );
+ $form['foss_select_branch'] = array(
+ '#type' => 'select',
+ '#title' => t('Branch'),
+ '#options' => _ajax_get_branch_options($form, $form_state),
+ '#prefix' => '<div id="dropdown-fourth-replace">',
+ '#suffix' => '</div>',
+ '#default_value' => $foss_select_branch,
+ );
+
+ $form['start_date'] = array(
+ '#type' => 'date_popup',
+ '#title' => t('Start Date:'),
+ '#date_label_position' => '',
+ '#description' => '',
+ '#default_value' => '',
+ '#date_type' => DATE_DATETIME,
+ '#date_format' => 'd/m/Y',
+ '#date_increment' => 1,
+ '#date_year_range' => '-3:+3',
+ );
+
+ $form['end_date'] = array(
+ '#type' => 'date_popup',
+ '#title' => t('End Date:'),
+ '#date_label_position' => '',
+ '#description' => '',
+ '#default_value' =>'',
+ '#date_type' => DATE_DATETIME,
+ '#date_format' => 'd/m/Y',
+ '#date_increment' => 1,
+ '#date_year_range' => '-3:+3',
+ );
- $form['submit'] = array(
- '#type' => 'submit',
- '#ajax' => array(
- 'callback' => 'ajax_example_submit_driven_callback',
- 'wrapper' => 'box',
- ),
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#ajax' => array(
+ 'callback' => 'ajax_example_submit_driven_callback',
+ 'wrapper' => 'box',
+ ),
'#value' => t('Filter'),
- );
- $form['reset'] = array(
- '#type' => 'submit',
- '#value' => t('Reset'),
- );
- $form['box'] = array(
- '#type' => 'markup',
- '#prefix' => '<div id="box">',
- '#suffix' => '</div>',
- '#markup' => '<h1>Initial markup for box</h1>',
- );
+ );
+
+ $form['reset'] = array(
+ '#type' => 'submit',
+ '#value' => t('Reset'),
+ );
+
+ $form['displaytext'] = array(
+ '#type' => 'markup',
+ '#prefix' => '<div id="displaytext">',
+ '#suffix' => '</div>',
+ '#markup' => '',
+ );
+
+ $form['box'] = array(
+ '#type' => 'markup',
+ '#prefix' => '<div id="box">',
+ '#suffix' => '</div>',
+ '#markup' => '<h1>Initial markup for box</h1>',
+ );
return $form;
}
- function ajax_example_submit_driven_callback($form, $form_state) {
- // In most cases, it is recomended that you put this logic in form generation
- // rather than the callback. Submit driven forms are an exception, because
- $headers = array(
- "#", "Foss Name", "TBC", "Lab Migration",
- );
- $query = db_select('foss_type');
- $query->fields('foss_type');
- $result = $query->execute()->fetchAll();
- $rows = array();
- $i=1;
- foreach($result as $row) {
- $item = array(
- $i,
- $row->foss_name,
- $row->tbc,
- $row->lab_migration,
-
- );
- array_push($rows, $item);
- $i++;
- }
-
- // you may not want to return the form at all.
- $element = $form['box'];
- $element['#markup'] = bootstrap_table_format($headers, $rows);
- return $element;
- }
- function _ajax_example_get_first_dropdown_options(){
- $query = db_select('foss_type');
- $query->fields('foss_type', array('id'));
- $query->fields('foss_type', array('foss_name'));
- $result = $query->execute();
- $options = array();
- $options[''] = "--------------";
- while ($foss_detail = $result->fetchObject())
- {
- $options[$foss_detail->id] = $foss_detail->foss_name;
- }
+ /**
+ * Callback function for menu item.
+ */
+ function example_page() {
+ $data = array(
+ array('fruit' => 'apple', 'votes' => 16),
+ array('fruit' => 'mango', 'votes' => 10),
+ array('fruit' => 'banana', 'votes' => 34),
+ array('fruit' => 'peach', 'votes' => 20),
+ array('fruit' => 'orange', 'votes' => 15),
+ );
+
+ $options_pie = array(
+ 'title' => 'Favourite fruits',
+ 'fields' => array(
+ 'votes' => array(
+ 'label' => t('Votes'),
+ 'enabled' => TRUE,
+ ),
+ ),
+ 'xAxis' => array(
+ 'labelField' => 'fruit',
+ ),
+ 'data' => $data,
+ 'type' => 'pie',
+ );
+
+ $options_column = array(
+ 'title' => 'Favourite fruits',
+ 'fields' => array(
+ 'votes' => array(
+ 'label' => t('Votes'),
+ 'enabled' => TRUE,
+ ),
+ ),
+ 'xAxis' => array(
+ 'labelField' => 'fruit',
+ ),
+ 'data' => $data,
+ 'type' => 'column',
+ );
+
+ $build['pie'] = array(
+ '#theme' => 'visualization',
+ '#options' => $options_pie,
+ );
+
+ return $build;
+ }
+
+
+
+ function _ajax_example_get_first_dropdown_options(){
+ $query = db_select('foss_type');
+ $query->fields('foss_type', array('id'));
+ $query->fields('foss_type', array('foss_name'));
+ $result = $query->execute();
+ $options = array();
+ $options[''] = "--------------";
+ while ($foss_detail = $result->fetchObject())
+ {
+ $options[$foss_detail->id] = $foss_detail->foss_name;
+ }
return $options;
}
- function _ajax_example_get_second_dropdown_options($foss_project = ''){
- if($foss_project != NULL){
- $query = db_select('foss_type');
- $query->fields('foss_type', array('tbc'));
- $query->fields('foss_type', array('lab_migration'));
- $query->condition('id',$foss_project);
- $result = $query->execute();
- $subproject_detail = $result->fetchObject();
- $options = array();
+ function _ajax_example_get_second_dropdown_options($foss_project = ''){
+
+ if($foss_project != NULL){
+ $query = db_select('foss_type');
+ $query->fields('foss_type', array('tbc'));
+ $query->fields('foss_type', array('lab_migration'));
+ $query->condition('id',$foss_project);
+ $result = $query->execute();
+ $subproject_detail = $result->fetchObject();
+ $options = array();
- if(($subproject_detail->tbc)!=0&&($subproject_detail->lab_migration)!=0){
- $options[0] = "--------------";
- $options[1] = "Textbook Companion";
- $options[2] = "Lab Migration";
- }else if(($subproject_detail->tbc)!=0&&($subproject_detail->lab_migration)==0){
- $options[0] = "--------------";
- $options[1] = "Textbook Companion";
- }else if(($subproject_detail->tbc)==0&&($subproject_detail->lab_migration)!=0){
- $options[1] = "--------------";
- $options[2] = "Lab Migration";
- }else if(($subproject_detail->tbc)==0&&($subproject_detail->lab_migration)==0) {
- $options[0] = "No Sub-Project Available";
- }else {
+ if(($subproject_detail->tbc)!=0&&($subproject_detail->lab_migration)!=0){
+ $options[0] = "--------------";
+ $options[1] = "Textbook Companion";
+ $options[2] = "Lab Migration";
+ }else if(($subproject_detail->tbc)!=0&&($subproject_detail->lab_migration)==0){
+ $options[0] = "--------------";
+ $options[1] = "Textbook Companion";
+ }else if(($subproject_detail->tbc)==0&&($subproject_detail->lab_migration)!=0){
+ $options[0] = "--------------";
+ $options[2] = "Lab Migration";
+ }else if(($subproject_detail->tbc)==0&&($subproject_detail->lab_migration)==0) {
+ $options[0] = "No Sub-Project Available";
+ }else{
$options[0] = "--------------";
- }
- return $options;
- }else{
- $options[0] = "--------------";
- return $options;
- }
- }
+ }
+
+ return $options;
+
+ }else{
+ $options[0] = "--------------";
+ return $options;
+ }
+ }
function _ajax_example_get_third_dropdown_options($foss_sub_project=''){
+
$options = array();
-
- if($foss_sub_project!=0){
+ if($foss_sub_project!=0){
- if($foss_sub_project==1){
- $options[0] = "----------";
- $options[1] = "Books In Progress";
- $options[2] = "Completed Books";
- }else if($foss_sub_project==2){
- $options[0] = "----------";
- $options[1] = "Labs in Progress";
- $options[2] = "Completed Labs";
- }else {
- $options[0] = "----------";
- }
+ if($foss_sub_project==1){
+ $options[0] = "--------------";
+ $options[1] = "Books In Progress";
+ $options[2] = "Completed Books";
+ }else if($foss_sub_project==2){
+ $options[0] = "--------------";
+ $options[1] = "Labs in Progress";
+ $options[2] = "Completed Labs";
+ }else{
+ $options[0] = "--------------";
+ }
- }else{
- $options[0] = "----------";
- }
+ }else{
+ $options[0] = "--------------";
+ }
- return $options;
- }
+ return $options;
+ }
-function _ajax_get_branch_options($foss_project = '',$foss_sub_project=''){
-
-if($foss_project!=0){
-//$other_database = array(
- // 'database' => 'scilab_nolinks',
- // 'username' => 'root', // assuming this is necessary
- // 'password' => 'root', // assuming this is necessary
- // 'host' => 'localhost', // assumes localhost
- // 'driver' => 'mysql', // replace with your database driver
- //);
- ////// replace 'YourDatabaseKey' with something that's unique to your module
- //Database::addConnectionInfo('YourDatabaseKey', 'default', $other_database);
- // db_set_active('YourDatabaseKey');
- db_set_active('scilab_db');
- $options = array();
+ function _ajax_get_branch_options($form, $form_state){
+
+ $foss_sub_projectname=$form['foss_sub_project']['#options'][$form_state['values']['foss_sub_project']];
+ $foss_project=$form['foss_type']['#options'][$form_state['values']['foss_type']];
+
+ if($foss_project!='--------------'){
+
+ db_set_active($foss_project);//Active other database
+ $options = array();
-if($foss_sub_project==1){
- $query = db_select('textbook_companion_proposal');
- $query->fields('textbook_companion_proposal', array('branch'));
- $query->distinct();
- $result = $query->execute();
- $options['0'] = "--------------";
- $x = 1;
- while ($foss_branch = $result->fetchObject())
- {
- $options[$x++] = $foss_branch->branch;
- }
-
-}else{
-
-$query = db_select('lab_migration_proposal');
- $query->fields('lab_migration_proposal', array('department'));
- $query->distinct();
- $result = $query->execute();
- $options['0'] = "--------------";
+ if($foss_sub_projectname=='Textbook Companion'){
+ $query = db_select('textbook_companion_proposal');
+ $query->fields('textbook_companion_proposal', array('branch'));
+ $query->distinct();
+ $query->orderBy('branch', 'ASC');
+ $result = $query->execute();
+ $options['0'] = "--------------";
+ $x = 1;
+ while ($foss_branch = $result->fetchObject())
+ {
+ $options[$x++] = $foss_branch->branch;
+ }
+
+ }else if($foss_sub_projectname=='No Sub-Project Available'||$foss_sub_projectname=='--------------'){
+
+ $options[0] ="--------------";
+
+ }else if($foss_sub_projectname=='Lab Migration'){
+
+ $query = db_select('lab_migration_proposal');
+ $query->fields('lab_migration_proposal', array('department'));
+ $query->distinct();
+ $query->orderBy('department', 'ASC');
+ $result = $query->execute();
+ $options['0'] = "--------------";
$x = 1;
- while ($foss_branch = $result->fetchObject())
- {
- $options[$x++] = $foss_branch->department;
- }
-}
+ while ($foss_branch = $result->fetchObject())
+ {
+ $options[$x++] = $foss_branch->department;
+ }
+ }
- db_set_active('default'); // We need to call the main (drupal) db back
-
-
- return $options;
- db_set_active(); // without the paramater means set back to the default for the site
- drupal_set_message(t('The queries have been made.'));
+ db_set_active('default'); // We need to call the main (drupal) db back
+ return $options;
+ db_set_active(); // without the paramater means set back to the default for the site
+
- }else{
+ }else{
-$options[0] ='-----------';
-}
- return $options;
- }
+ $options[0] ="--------------";
+ }
+ return $options;
+ }
- function ajax_example_dependent_dropdown_callback($form, $form_state){
- //$form['foss_sub_project']['#value'] = '';
- //$form['foss_sub_project_status']['#value'] = '';
- $form['foss_sub_project_status']['#options']=_ajax_example_get_third_dropdown_options($foss_sub_project);
- $form['foss_select_branch']['#value'] = '';
- // $commands = array();
- $commands[] = ajax_command_replace("#dropdown-second-replace", drupal_render($form['foss_sub_project']));
- $commands[] = ajax_command_replace("#dropdown-third-replace", drupal_render($form['foss_sub_project_status']));
- $commands[] = ajax_command_replace("#dropdown-fourth-replace", drupal_render($form['foss_select_branch']));
- return array('#type' => 'ajax', '#commands' => $commands);
- //return $form['foss_sub_project'];
- }
+ function ajax_example_dependent_dropdown_callback($form, $form_state){
+
+ $form['foss_sub_project_status']['#options']=_ajax_example_get_third_dropdown_options($foss_sub_project);
+ $form['foss_select_branch']['#value'] = '';
+ $commands[] = ajax_command_replace("#dropdown-second-replace", drupal_render($form['foss_sub_project']));
+ $commands[] = ajax_command_replace("#dropdown-third-replace", drupal_render($form['foss_sub_project_status']));
+ $commands[] = ajax_command_replace("#dropdown-fourth-replace", drupal_render($form['foss_select_branch']));
+ return array('#type' => 'ajax', '#commands' => $commands);
+ }
- function ajax_example_dependent_dropdown_callback1($form, $form_state){
- $commands[] = ajax_command_replace("#dropdown-third-replace", drupal_render($form['foss_sub_project_status']));
- $commands[] = ajax_command_replace("#dropdown-fourth-replace", drupal_render($form['foss_select_branch']));
- return array('#type' => 'ajax', '#commands' => $commands);
- }
+ function ajax_example_dependent_dropdown_callback1($form, $form_state){
+ $commands[] = ajax_command_replace("#dropdown-third-replace", drupal_render($form['foss_sub_project_status']));
+ $commands[] = ajax_command_replace("#dropdown-fourth-replace", drupal_render($form['foss_select_branch']));
+ return array('#type' => 'ajax', '#commands' => $commands);
+ }
- function bootstrap_table_format($headers, $rows) {
- $thead = "";
- $tbody = "";
- foreach($headers as $header) {
- $thead .= "<th>{$header}</th>";
- }
- foreach($rows as $row) {
- $tbody .= "<tr>";
- foreach($row as $data) {
- $tbody .= "<td>{$data}</td>";
+ function ajax_example_submit_driven_callback($form, $form_state) {
+
+ $foss_type=$form['foss_type']['#options'][$form_state['values']['foss_type']];
+ $foss_sub_project=$form['foss_sub_project']['#options'][$form_state['values']['foss_sub_project']];
+ $foss_sub_project_status=$form['foss_sub_project_status']['#options'][$form_state['values']['foss_sub_project_status']];
+ $foss_select_branch=$form['foss_select_branch']['#options'][$form_state['values']['foss_select_branch']];
+ $startdate=$form_state['values']['start_date'];
+ $end_date=$form_state['values']['end_date'];
+
+ //Get completed book count from tbc
+ db_set_active($foss_type);
+ if($foss_sub_project!='--------------'){
+ if($foss_sub_project=='Textbook Companion'){
+ $query = db_select('textbook_companion_proposal');
+ $query->addExpression('count(*)', 'count');
+ $query->condition('proposal_status', 3);
+ $query->where('FROM_UNIXTIME(completion_date) LIKE :val', array('val'=>'%'));
+ $query->condition('branch', '%', 'LIKE');
+ $query->orderBy('id', 'ASC');
+ $result = $query->execute();
+ $completedbooks = $result->fetchObject();
+ }else{
+ $query = db_select('textbook_companion_proposal');
+ $query->addExpression('count(*)', 'count');
+ $query->condition('proposal_status',3,'<>' );
+ $query->where('FROM_UNIXTIME(completion_date) LIKE :val', array('val'=>'%'));
+ $query->condition('branch', '%', 'LIKE');
+ $query->orderBy('id', 'ASC');
+ $result = $query->execute();
+ $pendingbooks = $result->fetchObject();
+ }
+ }
+ db_set_active('default'); // We need to call the main (drupal) db back
+ db_set_active();
+
+ $headers = array(
+ "#", "test", "TBC", "Lab Migration",
+ );
+ $query = db_select('foss_type');
+ $query->fields('foss_type');
+ $result = $query->execute()->fetchAll();
+ $rows = array();
+ $i=1;
+ foreach($result as $row) {
+ $item = array(
+ $i,
+ $row->foss_name,
+ $row->tbc,
+ $row->lab_migration,
+
+ );
+ array_push($rows, $item);
+ $i++;
}
- $tbody .= "</tr>";
- }
- $table = "
- <table class='table table-bordered table-hover' style='margin-left:-140px'>
- <thead>{$thead}</thead>
- <tbody>{$tbody}</tbody>
- </table>
- ";
- return $table;
- }
-
-
-
+
+ $form['box']['#markup']=bootstrap_table_format($headers, $rows).drupal_render(example_page());
+ //$form['displaytext']['#markup']=t("Total number of books completed : ".(string)$completedbooks);
+ //$commands[] = ajax_command_replace("#displaytext", drupal_render($form['displaytext']));
+ $commands[] = ajax_command_replace("#box", drupal_render($form['box']));
+ return array('#type' => 'ajax', '#commands' => $commands);
+
+ }
+
+ function bootstrap_table_format($headers, $rows) {
+ $thead = "";
+ $tbody = "";
+ foreach($headers as $header) {
+ $thead .= "<th>{$header}</th>";
+ }
+ foreach($rows as $row){
+ $tbody .= "<tr>";
+ foreach($row as $data) {
+ $tbody .= "<td>{$data}</td>";
+ }
+ $tbody .= "</tr>";
+ }
+ $table = "
+ <table class='table table-bordered table-hover' style='margin-left:-140px'>
+ <thead>{$thead}</thead>
+ <tbody>{$tbody}</tbody>
+ </table>
+ ";
+ return $table;
+ }