From e9ed6cf562bebc6e013af48d43674320124995d2 Mon Sep 17 00:00:00 2001 From: diptighosalkar Date: Tue, 4 Oct 2016 21:47:06 +0530 Subject: Dynamic PDF Generator --- fossee_stats.module | 3388 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 2101 insertions(+), 1287 deletions(-) (limited to 'fossee_stats.module') diff --git a/fossee_stats.module b/fossee_stats.module index 5406323..163c49f 100755 --- a/fossee_stats.module +++ b/fossee_stats.module @@ -15,15 +15,15 @@ function fossee_stats_permission() "title" => t("Manage Workshop"), "description" => t("Allows users to manage workshop.") ), - "view postalcampaign" => array( + "view postalcampaign" => array( "title" => t("View postalcampaign"), "description" => t("Allows users to view postalcampaign.") ), - "manage postalcampaign" => array( + "manage postalcampaign" => array( "title" => t("Manage Postalcampaign"), "description" => t("Allows users to manage postalcampaign.") ), - "view tutorial" => array( + "view tutorial" => array( "title" => t("View Spoken Tutorial"), "description" => t("Allows users to view spoken tutorial.") ), @@ -39,11 +39,11 @@ function fossee_stats_permission() "title" => t("Manage Events"), "description" => t("Allows users to manage events.") ), - "administer events" => array( + "administer events" => array( "title" => t("Events upload setting"), "description" => t("Allows users to manage postalcampaign.") ) - + ); } @@ -76,26 +76,26 @@ function fossee_stats_menu() ); //Fetch the list of self workshop with all detail after filter is applied and count is received $items['completed-workshops-list'] = array( - 'title' => '', + 'title' => '', 'page callback' => 'completed_workshops_list', - 'page arguments' => array( + 'page arguments' => array( 5 ), "access arguments" => array( - "access fossee_stats" + "access fossee_stats" ), - //'access callback' => TRUE, - "type" => MENU_CALLBACK - ); - //Fetch the Details of self workshop - $items['view-completed-workshop'] = array( - 'title' => 'Workshop Details', - 'page callback' => 'view_completed_workshop', - 'access callback' => TRUE, - ); - + //'access callback' => TRUE, + "type" => MENU_CALLBACK + ); + //Fetch the Details of self workshop + $items['view-completed-workshop'] = array( + 'title' => 'Workshop Details', + 'page callback' => 'view_completed_workshop', + 'access callback' => TRUE + ); + //Following are menu of Events (Workshop, Conference along with testimonial and images and speakers) - + $items["events/add"] = array( "title" => "Add Events", "page callback" => "workshop_display_all", @@ -104,7 +104,7 @@ function fossee_stats_menu() ), "type" => MENU_CALLBACK ); - //To edit existing events detail + //To edit existing events detail $items["events/edit"] = array( "title" => "Edit Events", "page callback" => "workshop_edit_all", @@ -113,7 +113,7 @@ function fossee_stats_menu() ), "type" => MENU_CALLBACK ); - //To delete existing events + //To delete existing events $items["events/delete"] = array( "title" => "Delete Events", "page callback" => "workshop_delete_all", @@ -131,7 +131,17 @@ function fossee_stats_menu() ), "type" => MENU_CALLBACK ); - //List of images added to particular event + //Generate PDF + $items["events/pdfgenerate"] = array( + "title" => "Generate PDF of Selected Event", + "page callback" => "generate_pdf", + "access arguments" => array( + "view workshop" + ), + "type" => MENU_CALLBACK + ); + + //List of images added to particular event $items["events/images"] = array( "title" => "Event's Images", "page callback" => "workshop_view_image_all", @@ -140,7 +150,7 @@ function fossee_stats_menu() ), "type" => MENU_CALLBACK ); - //For changing image + //For changing image $items["events/images/change"] = array( "title" => "Event's Images", "page callback" => "workshop_view_image_change", @@ -167,7 +177,7 @@ function fossee_stats_menu() ), "type" => MENU_CALLBACK ); - + $items["events"] = array( "title" => "Events", "page callback" => "event_seminar_view_all", @@ -176,7 +186,7 @@ function fossee_stats_menu() ), "type" => MENU_CALLBACK ); - + $items["testconf"] = array( "title" => "Activities", "page callback" => "event_activities_all", @@ -186,9 +196,9 @@ function fossee_stats_menu() "type" => MENU_CALLBACK ); - - // List of all Postal Campaign - $items["postalcampaign"] = array( + + // List of all Postal Campaign + $items["postalcampaign"] = array( "title" => "Postal Campaign", "page callback" => "postalcampaign_view_withoutfilter", "access arguments" => array( @@ -196,7 +206,7 @@ function fossee_stats_menu() ), "type" => MENU_CALLBACK ); - // Add Postal Campaign + // Add Postal Campaign $items["postalcampaign/add"] = array( "title" => "Add Postal Campaign", "page callback" => "postalcampaign_display_all", @@ -205,8 +215,8 @@ function fossee_stats_menu() ), "type" => MENU_CALLBACK ); - // Edit Postal Campaign - $items["postalcampaign/edit"] = array( + // Edit Postal Campaign + $items["postalcampaign/edit"] = array( "title" => "Edit Postal Campaign", "page callback" => "postalcampaign_edit_all", "access arguments" => array( @@ -214,7 +224,7 @@ function fossee_stats_menu() ), "type" => MENU_CALLBACK ); - // Delete Postal Campaign + // Delete Postal Campaign $items["postalcampaign/delete"] = array( "title" => "Delete Postal Campaign", "page callback" => "postalcampaign_delete_all", @@ -223,7 +233,7 @@ function fossee_stats_menu() ), "type" => MENU_CALLBACK ); - // View detail of selected Postal Campaign + // View detail of selected Postal Campaign $items["postalcampaign/view_details"] = array( "title" => "Postal Campaign Detail", "page callback" => "postalcampaign_view_details_all", @@ -232,8 +242,8 @@ function fossee_stats_menu() ), "type" => MENU_CALLBACK ); - //To download postal campaign poster in zip format - $items["postalcampaign/download"] = array( + //To download postal campaign poster in zip format + $items["postalcampaign/download"] = array( "title" => "Download Postal Campaign", "page callback" => "createZipOfPosterMaterial", "access arguments" => array( @@ -241,11 +251,11 @@ function fossee_stats_menu() ), "type" => MENU_CALLBACK ); - + /*Spoken Tutorial*/ - - //Add Spoken Tutorial - + + //Add Spoken Tutorial + $items["spokentutorial/add"] = array( "title" => "Add Spoken Tutorial", "page callback" => "spokentutorial_display_all", @@ -254,7 +264,7 @@ function fossee_stats_menu() ), "type" => MENU_CALLBACK ); - + /* ADMIN SETTINGS */ //For mentioning extension allowed for image and pdf $items['admin/settings/events'] = array( @@ -275,21 +285,22 @@ function fossee_stats_menu() //Folder path to save all uploaded images of events function events_images_path() - { - return $_SERVER['DOCUMENT_ROOT'] . base_path() . 'events_images/'; - } +{ + return $_SERVER['DOCUMENT_ROOT'] . base_path() . 'events_images/'; +} //Folder path to save all uploaded images/PDF of postal campaign -function posters_path() { - - return $_SERVER['DOCUMENT_ROOT'] . base_path() . 'campaign_posters/'; +function posters_path() +{ + + return $_SERVER['DOCUMENT_ROOT'] . base_path() . 'campaign_posters/'; } //Main Page Form function fossee_stats_form($form, &$form_state) { /* First Dropdown for Foss type */ - + $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); @@ -313,8 +324,8 @@ function fossee_stats_form($form, &$form_state) ) ) ); - /* Second Dropdown for Activities like TBC, LM and other */ - + /* Second Dropdown for Activities like TBC, LM and other */ + 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(get_activities_list($foss_project)); } else { @@ -344,8 +355,8 @@ function fossee_stats_form($form, &$form_state) ) ) ); - - /* third Dropdown for Status like Completed and In Progress */ + + /* third Dropdown for Status like Completed and In Progress */ 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 { @@ -378,7 +389,7 @@ function fossee_stats_form($form, &$form_state) ) ) ); - /* Start Date for Filter */ + /* Start Date for Filter */ $form['start_date'] = array( '#type' => 'date_popup', '#title' => t('From Date:'), @@ -401,7 +412,7 @@ function fossee_stats_form($form, &$form_state) ) ) ); - /* End Date for Filter */ + /* End Date for Filter */ $form['end_date'] = array( '#type' => 'date_popup', '#title' => t('To Date:'), @@ -424,7 +435,7 @@ function fossee_stats_form($form, &$form_state) ) ) ); - /* Country list for Filter */ + /* Country list for Filter */ if (isset($form_state['values']['countryname']) && isset($form_state['values']['statename']) && isset($form_state['values']['cityname'])) { $countryname = isset($form_state['values']['countryname']) ? $form_state['values']['countryname'] : key(get_country_list($foss_project, $foss_sub_project)); } else { @@ -466,7 +477,7 @@ function fossee_stats_form($form, &$form_state) ) ); - /* State list for Filter */ + /* State list for Filter */ if (isset($form_state['values']['countryname']) && isset($form_state['values']['statename']) && isset($form_state['values']['cityname'])) { $statename = isset($form_state['values']['statename']) ? $form_state['values']['statename'] : key(get_state_list($foss_project, $foss_sub_project, $countryname)); } else { @@ -510,7 +521,7 @@ function fossee_stats_form($form, &$form_state) ) ); -/* City list for Filter */ + /* City list for Filter */ if (isset($form_state['values']['countryname']) && isset($form_state['values']['statename']) && isset($form_state['values']['cityname'])) { $cityname = isset($form_state['values']['cityname']) ? $form_state['values']['cityname'] : key(get_city_list($foss_project, $foss_sub_project, $countryname, $statename)); } else { @@ -553,13 +564,13 @@ function fossee_stats_form($form, &$form_state) 'message' => '' ) ), - '#value' => t('Filter'), + '#value' => t('Filter'), '#prefix' => '', '#suffix' => '' ); $form['reset'] = array( '#type' => 'submit', - '#value' => t('Reset'), + '#value' => t('Reset'), '#prefix' => '', '#suffix' => '' ); @@ -582,28 +593,28 @@ function fossee_stats_form($form, &$form_state)
  • Conference
  • Spoken Tutorial
  • ' - ); + ); $TBC_getchart = getchart("TBC"); $LM_getchart = getchart("LM"); - $form['tab_content'] = array( + $form['tab_content'] = array( '#type' => 'item', '#markup' => '
    -
    ' . get_tabledata_TBC_or_LM("TBC", "1960/01/01", "").' +
    ' . get_tabledata_TBC_or_LM("TBC", "1960/01/01", "") . '
    ' . drupal_render($TBC_getchart) . '
    -
    ' . get_tabledata_TBC_or_LM("LM", "1960/01/01", "").' +
    ' . get_tabledata_TBC_or_LM("LM", "1960/01/01", "") . '
    ' . drupal_render($LM_getchart) . '
    -
    ' . workshop_view_all(0,1960-01-01, date("Y-m-d")).'
    +
    ' . workshop_view_all(0, 1960 - 01 - 01, date("Y-m-d")) . '
    -
    '.getselfworkshoplcount(0,1960-01-01, date("Y-m-d"),"","").'
    +
    ' . getselfworkshoplcount(0, 1960 - 01 - 01, date("Y-m-d"), "", "") . '
    -
    ' . conference_seminar_view_all(0, "", "").'
    +
    ' . conference_seminar_view_all(0, "", "") . '
    -
    '.spokentutorial_view_all("").'
    +
    ' . spokentutorial_view_all("") . '
    ' ); $form['lastdiv'] = array( @@ -619,7 +630,7 @@ function getchart($sub_type) { $title = ""; if ($sub_type == "TBC") { - $title = "Textbook Companion Statictics"; + $title = "Textbook Companion Statistics"; } else { $title = "Lab Migration Statistics"; } @@ -649,7 +660,7 @@ function getchartforselectedProject($foss_type, $sub_type, $startdate, $enddate, $title = ""; if ($sub_type == "TBC") { - $title = $foss_type . "" . "'s Completed Textbook Companion Statictics"; + $title = $foss_type . "" . "'s Completed Textbook Companion Statistics"; } else { $title = $foss_type . "" . "'s Completed Lab Migration Statistics"; } @@ -662,7 +673,7 @@ function getchartforselectedProject($foss_type, $sub_type, $startdate, $enddate, '#legend_position' => 'bottom', '#data_labels' => TRUE, '#tooltips' => TRUE, - '#width' => 800, + '#width' => 800, '#height' => 300 ); $chart['pie_data'] = array( @@ -681,7 +692,7 @@ function getpiechartforselectedProject($foss_type, $sub_type, $startdate, $endda $title = ""; if ($sub_type == "TBC") { - $title = $foss_type . "" . "'s Textbook Companion Statictics"; + $title = $foss_type . "" . "'s Textbook Companion Statistics"; } else { $title = $foss_type . "" . "'s Lab Migration Statistics"; } @@ -693,7 +704,7 @@ function getpiechartforselectedProject($foss_type, $sub_type, $startdate, $endda '#legend_position' => 'right', '#data_labels' => TRUE, '#tooltips' => TRUE, - '#width' => 700, + '#width' => 700, '#height' => 300 ); $chart['pie_data'] = array( @@ -929,7 +940,7 @@ function list_tbc_and_lm_detail($String, $foss_type, $sub_type, $status, $startd $page_content .= "
      "; $i = 1; while ($preference_data = $query2->fetchObject()) { - $page_content .= "
    1. " . $i++ . ". "; + $page_content .= "
    2. "; $page_content .= "id . " target='_blank'>" . $preference_data->book . " by " . $preference_data->author . ", " . $preference_data->publisher . ", " . $preference_data->year . ""; @@ -942,7 +953,7 @@ function list_tbc_and_lm_detail($String, $foss_type, $sub_type, $status, $startd $page_content .= "
        "; $i = 1; while ($preference_data = $query2->fetchObject()) { - $page_content .= "
      1. " . $i++ . ". "; + $page_content .= "
      2. "; $page_content .= $preference_data->book . " by " . $preference_data->author . ", " . $preference_data->publisher . ", " . $preference_data->year; $page_content .= "
      3. "; } @@ -990,7 +1001,7 @@ function list_tbc_and_lm_detail($String, $foss_type, $sub_type, $status, $startd $page_content .= "
          "; $i = 1; while ($row = $query2->fetchObject()) { - $page_content .= "
        1. " . $i++ . ". "; + $page_content .= "
        2. "; $approval_date = date("Y", $row->approval_date); $page_content .= "id . " target='_blank'>" . $row->lab_title . " " . $approval_date . " (Proposed by " . $row->name . ") "; //$page_content .= l($row->lab_title . " " . $approval_date,$foss_detail->lm_run."/". $row->id); @@ -1002,7 +1013,7 @@ function list_tbc_and_lm_detail($String, $foss_type, $sub_type, $status, $startd $page_content .= "
            "; $i = 1; while ($row = $query2->fetchObject()) { - $page_content .= "
          1. " . $i++ . ". "; + $page_content .= "
          2. "; $approval_date = date("Y", $row->approval_date); $page_content .= $row->lab_title . " " . $approval_date . " (Proposed by " . $row->name . ")"; $page_content .= "
          3. "; @@ -1230,12 +1241,12 @@ function get_data_for_chart_selectedproject($foss_type, $sub_type, $startdate, $ ':startdate' => $startdate, ':enddate' => $enddate )); - /* $query3 = db_query("SELECT COUNT( pe.book ) AS book_count FROM textbook_companion_preference pe LEFT JOIN textbook_companion_proposal po ON pe.proposal_id = po.id WHERE po.proposal_status !=3 AND pe.approval_status =1 AND pe.category>0 AND po.city LIKE :city AND po.state LIKE :state AND po.country LIKE :country AND FROM_UNIXTIME(po.completion_date) >= :startdate AND FROM_UNIXTIME(po.completion_date) <= :enddate", array( - ':city' => $cityname, - ':state' => $statename, - ':country' => $countryname, - ':startdate' => $startdate, - ':enddate' => $enddate + /* $query3 = db_query("SELECT COUNT( pe.book ) AS book_count FROM textbook_companion_preference pe LEFT JOIN textbook_companion_proposal po ON pe.proposal_id = po.id WHERE po.proposal_status !=3 AND pe.approval_status =1 AND pe.category>0 AND po.city LIKE :city AND po.state LIKE :state AND po.country LIKE :country AND FROM_UNIXTIME(po.completion_date) >= :startdate AND FROM_UNIXTIME(po.completion_date) <= :enddate", array( + ':city' => $cityname, + ':state' => $statename, + ':country' => $countryname, + ':startdate' => $startdate, + ':enddate' => $enddate ));*/ } else { $query2 = db_query("SELECT COUNT( pe.book ) AS book_count ,FROM_UNIXTIME(po.completion_date, '%Y') AS year FROM textbook_companion_preference pe LEFT JOIN textbook_companion_proposal po ON pe.proposal_id = po.id WHERE po.proposal_status =3 AND pe.approval_status =1 AND pe.category>0 AND po.city LIKE :city AND po.state LIKE :state AND po.country LIKE :country AND FROM_UNIXTIME(po.completion_date) >= :startdate AND FROM_UNIXTIME(po.completion_date) <= :enddate Group by FROM_UNIXTIME(po.completion_date, '%Y')", array( @@ -1245,12 +1256,12 @@ function get_data_for_chart_selectedproject($foss_type, $sub_type, $startdate, $ ':startdate' => $startdate, ':enddate' => $enddate )); - /* $query3 = db_query("SELECT COUNT( pe.book ) AS book_count FROM textbook_companion_preference pe LEFT JOIN textbook_companion_proposal po ON pe.proposal_id = po.id WHERE po.proposal_status !=3 AND pe.approval_status =1 AND pe.category>0 AND po.city LIKE :city AND po.state LIKE :state AND po.country LIKE :country AND FROM_UNIXTIME(po.completion_date) >= :startdate AND FROM_UNIXTIME(po.completion_date) <= :enddate", array( - ':city' => $cityname, - ':state' => $statename, - ':country' => $countryname, - ':startdate' => $startdate, - ':enddate' => $enddate + /* $query3 = db_query("SELECT COUNT( pe.book ) AS book_count FROM textbook_companion_preference pe LEFT JOIN textbook_companion_proposal po ON pe.proposal_id = po.id WHERE po.proposal_status !=3 AND pe.approval_status =1 AND pe.category>0 AND po.city LIKE :city AND po.state LIKE :state AND po.country LIKE :country AND FROM_UNIXTIME(po.completion_date) >= :startdate AND FROM_UNIXTIME(po.completion_date) <= :enddate", array( + ':city' => $cityname, + ':state' => $statename, + ':country' => $countryname, + ':startdate' => $startdate, + ':enddate' => $enddate ));*/ } } else { @@ -1262,49 +1273,49 @@ function get_data_for_chart_selectedproject($foss_type, $sub_type, $startdate, $ ':enddate' => $enddate )); /*$query3 = db_query("SELECT COUNT( pe.book ) AS book_count FROM textbook_companion_preference pe LEFT JOIN textbook_companion_proposal po ON pe.proposal_id = po.id WHERE po.proposal_status !=3 AND pe.approval_status =1 AND po.city LIKE :city AND po.state LIKE :state AND po.country LIKE :country AND FROM_UNIXTIME(po.completion_date) >= :startdate AND FROM_UNIXTIME(po.completion_date) <= :enddate", array( - ':city' => $cityname, - ':state' => $statename, - ':country' => $countryname, - ':startdate' => $startdate, - ':enddate' => $enddate + ':city' => $cityname, + ':state' => $statename, + ':country' => $countryname, + ':startdate' => $startdate, + ':enddate' => $enddate ));*/ } db_set_active('default'); // We need to call the main (drupal) db back db_set_active(); - + $result = $query2->fetchAll(); - + foreach ($result as $tbc_yearwise_count) { - - $completedbookcount= $tbc_yearwise_count->book_count; - $option1 = array( - $tbc_yearwise_count->year, - (int) $completedbookcount - ); - array_push($rows, $option1); - } - /* while ($tbc_yearwise_count = $result->fetchObject()) { - $completedbookcount= $tbc_yearwise_count->book_count; - $option1 = array( - $tbc_yearwise_count->year, - (int) $completedbookcount + + $completedbookcount = $tbc_yearwise_count->book_count; + $option1 = array( + $tbc_yearwise_count->year, + (int) $completedbookcount + ); + array_push($rows, $option1); + } + /* while ($tbc_yearwise_count = $result->fetchObject()) { + $completedbookcount= $tbc_yearwise_count->book_count; + $option1 = array( + $tbc_yearwise_count->year, + (int) $completedbookcount ); array_push($rows, $option1); - - }*/ - - + + }*/ + + //$completedbookcount = $query2->fetchObject()->book_count; - + //$pendingbookcount = $query3->fetchObject()->book_count; /*$option1 = array( - "Completed TBC", - (int) $completedbookcount + "Completed TBC", + (int) $completedbookcount ); array_push($rows, $option1);*/ - /* $option2 = array( - "In Progress TBC", - (int) $pendingbookcount + /* $option2 = array( + "In Progress TBC", + (int) $pendingbookcount ); array_push($rows, $option2);*/ } else { @@ -1315,7 +1326,7 @@ function get_data_for_chart_selectedproject($foss_type, $sub_type, $startdate, $ //$query2->condition('author', '%'.$extrafilter.'%', 'LIKE'); $query2->condition('approved', 1); $result2 = $query2->execute(); - + /*$query3 = db_select('tbc_book'); $query3->addExpression('count(*)', 'count'); //$query3->condition('author', '%'.$extrafilter.'%', 'LIKE'); @@ -1331,8 +1342,8 @@ function get_data_for_chart_selectedproject($foss_type, $sub_type, $startdate, $ ); array_push($rows, $option1); /*$option2 = array( - "In Progress TBC", - (int) $pendingbookcount + "In Progress TBC", + (int) $pendingbookcount ); array_push($rows, $option2);*/ } @@ -1363,50 +1374,50 @@ function get_data_for_chart_selectedproject($foss_type, $sub_type, $startdate, $ ':startdate' => $startdate, ':enddate' => $enddate )); - /* $query4 = db_query("SELECT COUNT(*) AS count from lab_migration_proposal WHERE approval_status=1 AND city LIKE :city AND state LIKE :state AND country LIKE :country AND FROM_UNIXTIME(approval_date) >=:startdate AND FROM_UNIXTIME(approval_date) <=:enddate", array( - ':city' => $cityname, - ':state' => $statename, - ':country' => $countryname, - ':startdate' => $startdate, - ':enddate' => $enddate + /* $query4 = db_query("SELECT COUNT(*) AS count from lab_migration_proposal WHERE approval_status=1 AND city LIKE :city AND state LIKE :state AND country LIKE :country AND FROM_UNIXTIME(approval_date) >=:startdate AND FROM_UNIXTIME(approval_date) <=:enddate", array( + ':city' => $cityname, + ':state' => $statename, + ':country' => $countryname, + ':startdate' => $startdate, + ':enddate' => $enddate ));*/ db_set_active('default'); // We need to call the main (drupal) db back db_set_active(); - + $result = $query3->fetchAll(); - - foreach ($result as $lm_yearwise_count) { - - $completedlabcount= $lm_yearwise_count->count; - $option1 = array( - $lm_yearwise_count->year, - (int) $completedlabcount - ); - array_push($rows, $option1); - } - /*$result = $query3->execute(); - - while ($lm_yearwise_count = $result->fetchObject()) { - $completedlabcount= $lm_yearwise_count->count; - $option1 = array( + foreach ($result as $lm_yearwise_count) { + + $completedlabcount = $lm_yearwise_count->count; + $option1 = array( $lm_yearwise_count->year, (int) $completedlabcount ); array_push($rows, $option1); - - }*/ - + } + + /*$result = $query3->execute(); + + while ($lm_yearwise_count = $result->fetchObject()) { + $completedlabcount= $lm_yearwise_count->count; + $option1 = array( + $lm_yearwise_count->year, + (int) $completedlabcount + ); + array_push($rows, $option1); + + }*/ + /*$completedlabcount = $query3->fetchObject()->count; //$pendinglabcount = $query4->fetchObject()->count; $option1 = array( - "Completed Labs", - (int) $completedlabcount + "Completed Labs", + (int) $completedlabcount ); array_push($rows, $option1);*/ /*$option2 = array( - "In Progress labs", - (int) $pendinglabcount + "In Progress labs", + (int) $pendinglabcount ); array_push($rows, $option2);*/ } @@ -1446,55 +1457,55 @@ function _ajax_example_get_first_dropdown_options() //List of option to fill secong drop down ie. Activities /*function _ajax_example_get_second_dropdown_options($foss_project = '') { - if ($foss_project != NULL) { - $query = db_select('foss_type'); - $query->fields('foss_type', array( - 'tbc', - 'lab_migration', - 'workshop', - 'self_workshop', - 'conference' - )); - $query->fields('foss_type', array( - 'spoken_tutorial', - 'postal_campaigns' - )); - $query->condition('id', $foss_project); - $result = $query->execute(); - $subproject_detail = $result->fetchObject(); - $optiondata = array( - "tbc", - "lab_migration", - "workshop", - "self_workshop", - "conference", - "spoken_tutorial", - "postal_campaigns" - ); - $optionvalue = array( - " ", - "Textbook Companion", - "Lab Migration", - "Workshop", - "Self Workshop", - "Conference", - "Spoken Tutorial", - "Postal Campaigns" - ); - $options = array(); - $options[0] = "--------------"; - $i = 0; - foreach ($optiondata as $value) { - $i++; - if (($subproject_detail->$value) != 0) { - $options[$i] = $optionvalue[$i]; - } - } - return $options; - } else { - $options[0] = "--------------"; - return $options; - } +if ($foss_project != NULL) { +$query = db_select('foss_type'); +$query->fields('foss_type', array( +'tbc', +'lab_migration', +'workshop', +'self_workshop', +'conference' +)); +$query->fields('foss_type', array( +'spoken_tutorial', +'postal_campaigns' +)); +$query->condition('id', $foss_project); +$result = $query->execute(); +$subproject_detail = $result->fetchObject(); +$optiondata = array( +"tbc", +"lab_migration", +"workshop", +"self_workshop", +"conference", +"spoken_tutorial", +"postal_campaigns" +); +$optionvalue = array( +" ", +"Textbook Companion", +"Lab Migration", +"Workshop", +"Self Workshop", +"Conference", +"Spoken Tutorial", +"Postal Campaigns" +); +$options = array(); +$options[0] = "--------------"; +$i = 0; +foreach ($optiondata as $value) { +$i++; +if (($subproject_detail->$value) != 0) { +$options[$i] = $optionvalue[$i]; +} +} +return $options; +} else { +$options[0] = "--------------"; +return $options; +} }*/ //List of option to fill secong drop down ie. Activities @@ -1605,7 +1616,7 @@ function ajax_foss_type_dependent_dropdown_callback($form, &$form_state)
            ' . get_tabledata_TBC_or_LM("TBC", $startdate, $enddate) . ' -
            ' . drupal_render(getchart("TBC")). '
            +
            ' . drupal_render(getchart("TBC")) . '
            ' . get_tabledata_TBC_or_LM("LM", $startdate, $enddate) . ' @@ -1614,11 +1625,11 @@ function ajax_foss_type_dependent_dropdown_callback($form, &$form_state)
            ' . workshop_view_all(0, $startdate, $enddate) . '
            -
            '.getselfworkshoplcount(0,$startdate,$enddate,"","").'
            +
            ' . getselfworkshoplcount(0, $startdate, $enddate, "", "") . '
            -
            ' . conference_seminar_view_all(0, $startdate, $enddate) .'
            +
            ' . conference_seminar_view_all(0, $startdate, $enddate) . '
            -
            '.spokentutorial_view_all("").'
            +
            ' . spokentutorial_view_all("") . '
            '; $commands[] = ajax_command_html("#default_load", drupal_render($form['default_load'])); $form['load_city']['#markup'] = ""; @@ -1635,7 +1646,7 @@ function ajax_foss_type_dependent_dropdown_callback($form, &$form_state) $commands[] = ajax_command_html("#dropdown-third-replace", ""); } else if ($foss_sub_project == '3') { - + $form['startdate']['#markup'] = ""; $commands[] = ajax_command_html("#startdate", ""); $form['enddate']['#markup'] = ""; @@ -1646,11 +1657,11 @@ function ajax_foss_type_dependent_dropdown_callback($form, &$form_state) $commands[] = ajax_command_html("#load_state", ""); $form['load_country']['#markup'] = ""; $commands[] = ajax_command_html("#load_country", ""); - $form['dropdown-second-replace']['#markup'] = ""; + $form['dropdown-second-replace']['#markup'] = ""; $commands[] = ajax_command_html("#dropdown-second-replace", ""); $form['dropdown-third-replace']['#markup'] = ""; $commands[] = ajax_command_html("#dropdown-third-replace", ""); - + } @@ -1679,9 +1690,9 @@ function ajax_foss_type_dependent_dropdown_callback($form, &$form_state) 'maxDate' => 0 ); $commands[] = ajax_command_html("#enddate", drupal_render($form['end_date'])); - - - $form['load_city']['#markup'] = ""; + + + $form['load_city']['#markup'] = ""; $commands[] = ajax_command_html("#load_city", ""); $form['load_state']['#markup'] = ""; $commands[] = ajax_command_html("#load_state", ""); @@ -1695,18 +1706,18 @@ function ajax_foss_type_dependent_dropdown_callback($form, &$form_state) if ($foss_sub_project != "" && ($foss_sub_project_activities == 1 || $foss_sub_project_activities == 2)) { - - if($foss_sub_project==3){ - $foss_sub_project_activities=""; - $form['dropdown-third-replace']['#markup'] = ""; - $commands[] = ajax_command_html("#dropdown-third-replace", ""); - }else{ - $form['foss_sub_project_status']['#type'] = "select"; - $form['foss_sub_project_status']['#title'] = t("Status"); - $form['foss_sub_project_status']['#options'] = _ajax_example_get_third_dropdown_options($foss_sub_project_activities); - $commands[] = ajax_command_html("#dropdown-third-replace", drupal_render($form['foss_sub_project_status'])); - } - + + if ($foss_sub_project == 3) { + $foss_sub_project_activities = ""; + $form['dropdown-third-replace']['#markup'] = ""; + $commands[] = ajax_command_html("#dropdown-third-replace", ""); + } else { + $form['foss_sub_project_status']['#type'] = "select"; + $form['foss_sub_project_status']['#title'] = t("Status"); + $form['foss_sub_project_status']['#options'] = _ajax_example_get_third_dropdown_options($foss_sub_project_activities); + $commands[] = ajax_command_html("#dropdown-third-replace", drupal_render($form['foss_sub_project_status'])); + } + } else { $form['dropdown-third-replace']['#markup'] = ""; $commands[] = ajax_command_html("#dropdown-third-replace", ""); @@ -1720,156 +1731,156 @@ function ajax_foss_type_dependent_dropdown_callback($form, &$form_state) //this is ajax callback method for second dropdown ie Activities type function ajax_foss_sub_project_dependent_dropdown_callback($form, &$form_state) { - $foss_project = $form_state['values']['foss_sub_project']; - $foss_type = $form_state['values']['foss_type']; - - - + $foss_project = $form_state['values']['foss_sub_project']; + $foss_type = $form_state['values']['foss_type']; + + + if ($foss_type != "" && $foss_project != 0 && $foss_type != 3) { - - if($foss_project==7){ - $form['load_city']['#markup'] = ""; - $commands[] = ajax_command_html("#load_city", ""); - $form['load_country']['#markup'] = ""; - $commands[] = ajax_command_html("#load_country", ""); - $form['load_state']['#markup'] = ""; - $commands[] = ajax_command_html("#load_state", ""); - - }else if($foss_project==6){ - $form['load_city']['#markup'] = ""; - $commands[] = ajax_command_html("#load_city", ""); - $form['load_country']['#markup'] = ""; - $commands[] = ajax_command_html("#load_country", ""); - $form['load_state']['#markup'] = ""; - $commands[] = ajax_command_html("#load_state", ""); - $form['end_date']['#markup'] = ""; - $commands[] = ajax_command_html("#enddate", ""); - $form['start_date']['#markup'] = ""; - $commands[] = ajax_command_html("#startdate", ""); - - }else{ - - $form['countryname']['#type'] = "select"; - $form['countryname']['#title'] = t("Select Country"); - $form['countryname']['#option'] = get_country_list($foss_type, $foss_project); - $form['countryname']['#prefix'] = "
            "; - $form['countryname']['#suffix'] = "
            "; - $commands[] = ajax_command_html("#load_country", drupal_render($form['countryname'])); - $country_value = $form_state['values']['countryname']; - - $form['statename']['#type'] = "select"; - $form['statename']['#title'] = t("State Name"); - $form['statename']['#options'] = get_state_list($foss_type, $foss_project, $country_value); - $form['statename']['#prefix'] = "
            "; - $form['statename']['#suffix'] = "
            "; - $commands[] = ajax_command_html("#load_state", drupal_render($form['statename'])); - $state_value = $form_state['values']['statename']; - - $form['cityname']['#type'] = "select"; - $form['cityname']['#title'] = t("City Name"); - $form['cityname']['#options'] = get_city_list($foss_type, $foss_project, $country_value, $state_value); - $form['cityname']['#prefix'] = "
            "; - $form['cityname']['#suffix'] = "
            "; - $commands[] = ajax_command_html("#load_city", drupal_render($form['cityname'])); - - } + + if ($foss_project == 7) { + $form['load_city']['#markup'] = ""; + $commands[] = ajax_command_html("#load_city", ""); + $form['load_country']['#markup'] = ""; + $commands[] = ajax_command_html("#load_country", ""); + $form['load_state']['#markup'] = ""; + $commands[] = ajax_command_html("#load_state", ""); + + } else if ($foss_project == 6) { + $form['load_city']['#markup'] = ""; + $commands[] = ajax_command_html("#load_city", ""); + $form['load_country']['#markup'] = ""; + $commands[] = ajax_command_html("#load_country", ""); + $form['load_state']['#markup'] = ""; + $commands[] = ajax_command_html("#load_state", ""); + $form['end_date']['#markup'] = ""; + $commands[] = ajax_command_html("#enddate", ""); + $form['start_date']['#markup'] = ""; + $commands[] = ajax_command_html("#startdate", ""); + + } else { + + $form['countryname']['#type'] = "select"; + $form['countryname']['#title'] = t("Select Country"); + $form['countryname']['#option'] = get_country_list($foss_type, $foss_project); + $form['countryname']['#prefix'] = "
            "; + $form['countryname']['#suffix'] = "
            "; + $commands[] = ajax_command_html("#load_country", drupal_render($form['countryname'])); + $country_value = $form_state['values']['countryname']; + + $form['statename']['#type'] = "select"; + $form['statename']['#title'] = t("State Name"); + $form['statename']['#options'] = get_state_list($foss_type, $foss_project, $country_value); + $form['statename']['#prefix'] = "
            "; + $form['statename']['#suffix'] = "
            "; + $commands[] = ajax_command_html("#load_state", drupal_render($form['statename'])); + $state_value = $form_state['values']['statename']; + + $form['cityname']['#type'] = "select"; + $form['cityname']['#title'] = t("City Name"); + $form['cityname']['#options'] = get_city_list($foss_type, $foss_project, $country_value, $state_value); + $form['cityname']['#prefix'] = "
            "; + $form['cityname']['#suffix'] = "
            "; + $commands[] = ajax_command_html("#load_city", drupal_render($form['cityname'])); + + } } else { - if ($foss_project == 3 || $foss_project == 4 || $foss_project == 5) { - - $form['start_date']['#type'] = "date_popup"; - $form['start_date']['#title'] = t('From Date:'); - $form['start_date']['#date_label_position'] = ''; - $form['start_date']['#description'] = ''; - $form['start_date']['#default_value'] = ''; - $form['start_date']['#date_format'] = 'Y-m-d'; - $form['start_date']['#date_increment'] = 0; - $form['start_date']['#date_year_range'] = '2011:+0'; - $form['start_date']['#datepicker_options'] = array( - 'maxDate' => 0 - ); - $commands[] = ajax_command_html("#startdate", drupal_render($form['start_date'])); - $form['end_date']['#type'] = "date_popup"; - $form['end_date']['#title'] = t('To Date:'); - $form['end_date']['#date_label_position'] = ''; - $form['end_date']['#description'] = ''; - $form['end_date']['#default_value'] = ''; - $form['end_date']['#date_format'] = 'Y-m-d'; - $form['end_date']['#date_increment'] = 0; - $form['end_date']['#date_year_range'] = '2011:+0'; - $form['end_date']['#datepicker_options'] = array( - 'maxDate' => 0 - ); - $commands[] = ajax_command_html("#enddate", drupal_render($form['end_date'])); - - $form['countryname']['#type'] = "select"; - $form['countryname']['#title'] = t("Select Country"); - $form['countryname']['#option'] = get_country_list($foss_type, $foss_project); - $form['countryname']['#prefix'] = "
            "; - $form['countryname']['#suffix'] = "
            "; - $commands[] = ajax_command_html("#load_country", drupal_render($form['countryname'])); - - $country_value = $form_state['values']['countryname']; - - $form['statename']['#type'] = "select"; - $form['statename']['#title'] = t("State Name"); - $form['statename']['#options'] = get_state_list($foss_type, $foss_project, $country_value); - $form['statename']['#prefix'] = "
            "; - $form['statename']['#suffix'] = "
            "; - $commands[] = ajax_command_html("#load_state", drupal_render($form['statename'])); - $state_value = $form_state['values']['statename']; - - $form['cityname']['#type'] = "select"; - $form['cityname']['#title'] = t("City Name"); - $form['cityname']['#options'] = get_city_list($foss_type, $foss_project, $country_value, $state_value); - $form['cityname']['#prefix'] = "
            "; - $form['cityname']['#suffix'] = "
            "; - $commands[] = ajax_command_html("#load_city", drupal_render($form['cityname'])); - - - }else if($foss_project == 7){ - $form['start_date']['#type'] = "date_popup"; - $form['start_date']['#title'] = t('From Date:'); - $form['start_date']['#date_label_position'] = ''; - $form['start_date']['#description'] = ''; - $form['start_date']['#default_value'] = ''; - $form['start_date']['#date_format'] = 'Y-m-d'; - $form['start_date']['#date_increment'] = 0; - $form['start_date']['#date_year_range'] = '2011:+0'; - $form['start_date']['#datepicker_options'] = array( - 'maxDate' => 0 - ); - $commands[] = ajax_command_html("#startdate", drupal_render($form['start_date'])); - $form['end_date']['#type'] = "date_popup"; - $form['end_date']['#title'] = t('To Date:'); - $form['end_date']['#date_label_position'] = ''; - $form['end_date']['#description'] = ''; - $form['end_date']['#default_value'] = ''; - $form['end_date']['#date_format'] = 'Y-m-d'; - $form['end_date']['#date_increment'] = 0; - $form['end_date']['#date_year_range'] = '2011:+0'; - $form['end_date']['#datepicker_options'] = array( - 'maxDate' => 0 - ); - $commands[] = ajax_command_html("#enddate", drupal_render($form['end_date'])); - $form['load_city']['#markup'] = ""; - $commands[] = ajax_command_html("#load_city", ""); - $form['load_country']['#markup'] = ""; - $commands[] = ajax_command_html("#load_country", ""); - $form['load_state']['#markup'] = ""; - $commands[] = ajax_command_html("#load_state", ""); - }else if($foss_project == 6){ - $form['load_city']['#markup'] = ""; - $commands[] = ajax_command_html("#load_city", ""); - $form['load_country']['#markup'] = ""; - $commands[] = ajax_command_html("#load_country", ""); - $form['load_state']['#markup'] = ""; - $commands[] = ajax_command_html("#load_state", ""); - $form['end_date']['#markup'] = ""; - $commands[] = ajax_command_html("#enddate", ""); - $form['start_date']['#markup'] = ""; - $commands[] = ajax_command_html("#startdate", ""); - } + if ($foss_project == 3 || $foss_project == 4 || $foss_project == 5) { + + $form['start_date']['#type'] = "date_popup"; + $form['start_date']['#title'] = t('From Date:'); + $form['start_date']['#date_label_position'] = ''; + $form['start_date']['#description'] = ''; + $form['start_date']['#default_value'] = ''; + $form['start_date']['#date_format'] = 'Y-m-d'; + $form['start_date']['#date_increment'] = 0; + $form['start_date']['#date_year_range'] = '2011:+0'; + $form['start_date']['#datepicker_options'] = array( + 'maxDate' => 0 + ); + $commands[] = ajax_command_html("#startdate", drupal_render($form['start_date'])); + $form['end_date']['#type'] = "date_popup"; + $form['end_date']['#title'] = t('To Date:'); + $form['end_date']['#date_label_position'] = ''; + $form['end_date']['#description'] = ''; + $form['end_date']['#default_value'] = ''; + $form['end_date']['#date_format'] = 'Y-m-d'; + $form['end_date']['#date_increment'] = 0; + $form['end_date']['#date_year_range'] = '2011:+0'; + $form['end_date']['#datepicker_options'] = array( + 'maxDate' => 0 + ); + $commands[] = ajax_command_html("#enddate", drupal_render($form['end_date'])); + + $form['countryname']['#type'] = "select"; + $form['countryname']['#title'] = t("Select Country"); + $form['countryname']['#option'] = get_country_list($foss_type, $foss_project); + $form['countryname']['#prefix'] = "
            "; + $form['countryname']['#suffix'] = "
            "; + $commands[] = ajax_command_html("#load_country", drupal_render($form['countryname'])); + + $country_value = $form_state['values']['countryname']; + + $form['statename']['#type'] = "select"; + $form['statename']['#title'] = t("State Name"); + $form['statename']['#options'] = get_state_list($foss_type, $foss_project, $country_value); + $form['statename']['#prefix'] = "
            "; + $form['statename']['#suffix'] = "
            "; + $commands[] = ajax_command_html("#load_state", drupal_render($form['statename'])); + $state_value = $form_state['values']['statename']; + + $form['cityname']['#type'] = "select"; + $form['cityname']['#title'] = t("City Name"); + $form['cityname']['#options'] = get_city_list($foss_type, $foss_project, $country_value, $state_value); + $form['cityname']['#prefix'] = "
            "; + $form['cityname']['#suffix'] = "
            "; + $commands[] = ajax_command_html("#load_city", drupal_render($form['cityname'])); + + + } else if ($foss_project == 7) { + $form['start_date']['#type'] = "date_popup"; + $form['start_date']['#title'] = t('From Date:'); + $form['start_date']['#date_label_position'] = ''; + $form['start_date']['#description'] = ''; + $form['start_date']['#default_value'] = ''; + $form['start_date']['#date_format'] = 'Y-m-d'; + $form['start_date']['#date_increment'] = 0; + $form['start_date']['#date_year_range'] = '2011:+0'; + $form['start_date']['#datepicker_options'] = array( + 'maxDate' => 0 + ); + $commands[] = ajax_command_html("#startdate", drupal_render($form['start_date'])); + $form['end_date']['#type'] = "date_popup"; + $form['end_date']['#title'] = t('To Date:'); + $form['end_date']['#date_label_position'] = ''; + $form['end_date']['#description'] = ''; + $form['end_date']['#default_value'] = ''; + $form['end_date']['#date_format'] = 'Y-m-d'; + $form['end_date']['#date_increment'] = 0; + $form['end_date']['#date_year_range'] = '2011:+0'; + $form['end_date']['#datepicker_options'] = array( + 'maxDate' => 0 + ); + $commands[] = ajax_command_html("#enddate", drupal_render($form['end_date'])); + $form['load_city']['#markup'] = ""; + $commands[] = ajax_command_html("#load_city", ""); + $form['load_country']['#markup'] = ""; + $commands[] = ajax_command_html("#load_country", ""); + $form['load_state']['#markup'] = ""; + $commands[] = ajax_command_html("#load_state", ""); + } else if ($foss_project == 6) { + $form['load_city']['#markup'] = ""; + $commands[] = ajax_command_html("#load_city", ""); + $form['load_country']['#markup'] = ""; + $commands[] = ajax_command_html("#load_country", ""); + $form['load_state']['#markup'] = ""; + $commands[] = ajax_command_html("#load_state", ""); + $form['end_date']['#markup'] = ""; + $commands[] = ajax_command_html("#enddate", ""); + $form['start_date']['#markup'] = ""; + $commands[] = ajax_command_html("#startdate", ""); + } } if ($foss_project == 1 || $foss_project == 2) { $form['foss_sub_project_status']['#type'] = "select"; @@ -1879,7 +1890,7 @@ function ajax_foss_sub_project_dependent_dropdown_callback($form, &$form_state) } else { $form['dropdown-third-replace']['#markup'] = ""; $commands[] = ajax_command_html("#dropdown-third-replace", ""); - + } return array( '#type' => 'ajax', @@ -1941,38 +1952,38 @@ function ajax_example_submit_driven_callback($form, &$form_state)
            -
            ' . get_tabledata_TBC_or_LM("TBC", $startdate, $enddate) .' +
            ' . get_tabledata_TBC_or_LM("TBC", $startdate, $enddate) . '
            ' . drupal_render(getchart("TBC")) . '
            -
            ' . get_tabledata_TBC_or_LM("LM", $startdate, $enddate) .' +
            ' . get_tabledata_TBC_or_LM("LM", $startdate, $enddate) . '
            ' . drupal_render(getchart("LM")) . '
            -
            ' . workshop_view_all(0, $startdate, $enddate) .'
            +
            ' . workshop_view_all(0, $startdate, $enddate) . '
            -
            ' . getselfworkshoplcount(0,$startdate,$enddate,"","").'
            +
            ' . getselfworkshoplcount(0, $startdate, $enddate, "", "") . '
            -
            ' . conference_seminar_view_all(0, "", "") .'
            +
            ' . conference_seminar_view_all(0, "", "") . '
            -
            '.spokentutorial_view_all("").'
            +
            ' . spokentutorial_view_all("") . '
            '; $commands[] = ajax_command_html("#default_load", drupal_render($form['default_load'])); } else if ($foss_type != '--------------' && (($foss_sub_project == "--------------") || ($foss_sub_project == "No Sub-Project Available"))) { - - $tbcdatacheck=""; - $tbcchartcheck=""; - $lmdatacheck=""; - $lmchartcheck=""; - $workshopdatacheck=""; - $self_workshopdatacheck=""; - $conferencedatacheck=""; - $spoken_tutorialdatacheck=""; - - - - + + $tbcdatacheck = ""; + $tbcchartcheck = ""; + $lmdatacheck = ""; + $lmchartcheck = ""; + $workshopdatacheck = ""; + $self_workshopdatacheck = ""; + $conferencedatacheck = ""; + $spoken_tutorialdatacheck = ""; + + + + $form['displaytext']['#markup'] = "Statistic of project : " . $foss_type; $commands[] = ajax_command_html("#displaytext", drupal_render($form['displaytext'])); db_set_active('default'); // We need to call the main (drupal) db back @@ -2013,146 +2024,146 @@ function ajax_example_submit_driven_callback($form, &$form_state) ); $i = 0; $pagecontent = ""; - // foreach ($optiondata as $value) { - // $i++; - // //$options[$i]=$optionvalue[$i]; - // if (($subproject_detail->$value) != 0) { - // if ($value == "tbc") { - // $pagecontent .= "
            - // - // - //
            " . get_tabledata_selectedFoss_TBC_LM($foss_type, 'TBC', 'all', $startdate, $enddate, $countryname, $statename, $cityname, $link_flag) . "
            " . drupal_render(getchartforselectedProject($foss_type, "TBC", $startdate, $enddate, $countryname, $statename, $cityname)) . "
            "; - // } else if ($value == "lab_migration") { - // $pagecontent .= "
            - // - // - //
            - //
            " . get_tabledata_selectedFoss_TBC_LM($foss_type, 'LM', "all", $startdate, $enddate, $countryname, $statename, $cityname, $link_flag) . "
            - //
            " . drupal_render(getchartforselectedProject($foss_type, "LM", $startdate, $enddate, $countryname, $statename, $cityname)) . "
            "; - // } else if ($value == "workshop") { - - // $event_type = "Workshop"; - // $pagecontent .= "
            - // - // - //
            " . events_view_filter($foss_type, $event_type, $startdate, $enddate, $countryname, $statename, $cityname) . "
            "; - // } else if ($value == "self_workshop") { - // $pagecontent .= "
            - // - // - //
            ".getselfworkshoplcount($foss_type,$startdate,$enddate, $statename, $cityname)."
            "; - // } else if ($value == "conference") { - // $event_type = "Conference"; - // $pagecontent .= "
            - // - // - //
            " . events_view_filter($foss_type, $event_type, $startdate, $enddate, $countryname, $statename, $cityname) . "
            "; - // } else if ($value == "spoken_tutorial") { - // $pagecontent .= "
            - // - // - //
            ".spokentutorial_view_all($foss_type)."
            "; - // } - - - // } else { - // if ($value == "tbc") { - // $pagecontent .= "
            - // - // - //
            " . t(" - //
            TextBook Companion Project Not Present
            ") . "
            "; - // } else if ($value == "lab_migration") { - // $pagecontent .= "
            - // - // - //
            - //
            " . t(" - //
            Lab Migration Project Not Present
            ") . "
            "; - // } else if ($value == "workshop") { - // $pagecontent .= "
            - // - // - //
            " . t(" - //
            No Workshop were conducted
            ") . "
            "; - // } else if ($value == "self_workshop") { - // $pagecontent .= "
            - // - // - //
            " . t(" - //
            No Self Workshop were conducted
            ") . "
            "; - // } else if ($value == "conference") { - // $pagecontent .= "
            - // - // - //
            " . t(" - //
            No Conference were conducted
            ") . "
            "; - // } else if ($value == "spoken_tutorial") { - // $pagecontent .= "
            - // - // - //
            " . t(" - //
            Spoken Tutorial Not Present
            ") . "
            "; - // } - // } - // } - // $form['default_load']['#markup'] = $pagecontent; - - -foreach ($optiondata as $value) { - $i++; + // foreach ($optiondata as $value) { + // $i++; + // //$options[$i]=$optionvalue[$i]; + // if (($subproject_detail->$value) != 0) { + // if ($value == "tbc") { + // $pagecontent .= "
            + // + // + //
            " . get_tabledata_selectedFoss_TBC_LM($foss_type, 'TBC', 'all', $startdate, $enddate, $countryname, $statename, $cityname, $link_flag) . "
            " . drupal_render(getchartforselectedProject($foss_type, "TBC", $startdate, $enddate, $countryname, $statename, $cityname)) . "
            "; + // } else if ($value == "lab_migration") { + // $pagecontent .= "
            + // + // + //
            + //
            " . get_tabledata_selectedFoss_TBC_LM($foss_type, 'LM', "all", $startdate, $enddate, $countryname, $statename, $cityname, $link_flag) . "
            + //
            " . drupal_render(getchartforselectedProject($foss_type, "LM", $startdate, $enddate, $countryname, $statename, $cityname)) . "
            "; + // } else if ($value == "workshop") { + + // $event_type = "Workshop"; + // $pagecontent .= "
            + // + // + //
            " . events_view_filter($foss_type, $event_type, $startdate, $enddate, $countryname, $statename, $cityname) . "
            "; + // } else if ($value == "self_workshop") { + // $pagecontent .= "
            + // + // + //
            ".getselfworkshoplcount($foss_type,$startdate,$enddate, $statename, $cityname)."
            "; + // } else if ($value == "conference") { + // $event_type = "Conference"; + // $pagecontent .= "
            + // + // + //
            " . events_view_filter($foss_type, $event_type, $startdate, $enddate, $countryname, $statename, $cityname) . "
            "; + // } else if ($value == "spoken_tutorial") { + // $pagecontent .= "
            + // + // + //
            ".spokentutorial_view_all($foss_type)."
            "; + // } + + + // } else { + // if ($value == "tbc") { + // $pagecontent .= "
            + // + // + //
            " . t(" + //
            TextBook Companion Project Not Present
            ") . "
            "; + // } else if ($value == "lab_migration") { + // $pagecontent .= "
            + // + // + //
            + //
            " . t(" + //
            Lab Migration Project Not Present
            ") . "
            "; + // } else if ($value == "workshop") { + // $pagecontent .= "
            + // + // + //
            " . t(" + //
            No Workshop were conducted
            ") . "
            "; + // } else if ($value == "self_workshop") { + // $pagecontent .= "
            + // + // + //
            " . t(" + //
            No Self Workshop were conducted
            ") . "
            "; + // } else if ($value == "conference") { + // $pagecontent .= "
            + // + // + //
            " . t(" + //
            No Conference were conducted
            ") . "
            "; + // } else if ($value == "spoken_tutorial") { + // $pagecontent .= "
            + // + // + //
            " . t(" + //
            Spoken Tutorial Not Present
            ") . "
            "; + // } + // } + // } + // $form['default_load']['#markup'] = $pagecontent; + + + foreach ($optiondata as $value) { + $i++; //$options[$i]=$optionvalue[$i]; - if (($subproject_detail->$value) != 0) { - if ($value == "tbc") { - $tbcdatacheck=get_tabledata_selectedFoss_TBC_LM($foss_type, 'TBC', 'all', $startdate, $enddate, $countryname, $statename, $cityname, $link_flag); - - $tbcchartcheck=drupal_render(getchartforselectedProject($foss_type, 'TBC', $startdate, $enddate, $countryname, $statename, $cityname)); - - } else if ($value == "lab_migration") { - $lmdatacheck= get_tabledata_selectedFoss_TBC_LM($foss_type, 'LM', 'all', $startdate, $enddate, $countryname, $statename, $cityname, $link_flag) ; - $lmchartcheck=drupal_render(getchartforselectedProject($foss_type, 'LM', $startdate, $enddate, $countryname, $statename, $cityname)); - } else if ($value == "workshop") { - $event_type = "Workshop"; - $workshopdatacheck= events_view_filter($foss_type, $event_type, $startdate, $enddate, $countryname, $statename, $cityname); - } else if ($value == "self_workshop") { - $self_workshopdatacheck=getselfworkshoplcount($foss_type,$startdate,$enddate, $statename, $cityname); - } else if ($value == "conference") { - $event_type = "Conference"; - $conferencedatacheck= events_view_filter($foss_type, $event_type, $startdate, $enddate, $countryname, $statename, $cityname); - } else if ($value == "spoken_tutorial") { - $spoken_tutorialdatacheck= spokentutorial_view_all($foss_type); - } - - - } else { - if ($value == "tbc") { - $tbcdatacheck="
            TextBook Companion Project Not Present
            "; - $tbcchartcheck=""; - } else if ($value == "lab_migration") { - $lmdatacheck="
            Lab Migration Project Not Present
            "; - $lmchartcheck=""; - } else if ($value == "workshop") { - $workshopdatacheck= "
            No Workshop were conducted
            "; - } else if ($value == "self_workshop") { - $self_workshopdatacheck="
            No Self Workshop were conducted
            "; - } else if ($value == "conference") { - $conferencedatacheck="
            No Conference were conducted
            "; - } else if ($value == "spoken_tutorial") { - - $spoken_tutorialdatacheck="
            Spoken Tutorial Not Present
            "; - } - } - } - - // var_dump($tbcdatacheck."::::::".$lmdatacheck."::::::".$workshopdatacheck.":::::::".$self_workshopdatacheck.":::::::".$conferencedatacheck."::::::".$spoken_tutorialdatacheck); -//die; - - - - - $form['default_load']['#markup'] = '
            -
            ' .events_view_filter($foss_type, $foss_sub_project, $startdate, $enddate, $countryname, $statename, $cityname) .'
            '; +
            ' . events_view_filter($foss_type, $foss_sub_project, $startdate, $enddate, $countryname, $statename, $cityname) . '
            '; $form['default_load']['#markup'] = $pagecontent; $commands[] = ajax_command_html("#default_load", drupal_render($form['default_load'])); @@ -2228,18 +2239,18 @@ foreach ($optiondata as $value) { $form['displaytext']['#markup'] = "Statistic of project : " . $foss_type; $commands[] = ajax_command_html("#displaytext", drupal_render($form['displaytext'])); - + $pagecontent = ""; $pagecontent .= '
            -
            ' . getselfworkshoplcount($foss_type,$startdate,$enddate, $statename, $cityname).'
            '; +
            ' . getselfworkshoplcount($foss_type, $startdate, $enddate, $statename, $cityname) . '
            '; $form['default_load']['#markup'] = $pagecontent; $commands[] = ajax_command_html("#default_load", drupal_render($form['default_load'])); - }else if ($foss_type != '--------------' && $foss_sub_project == "Conference") { + } else if ($foss_type != '--------------' && $foss_sub_project == "Conference") { $form['displaytext']['#markup'] = "Statistic of project : " . $foss_type; $commands[] = ajax_command_html("#displaytext", drupal_render($form['displaytext'])); @@ -2250,12 +2261,12 @@ foreach ($optiondata as $value) {
          4. Conference
          5. -
            ' . events_view_filter($foss_type, $foss_sub_project, $startdate, $enddate, $countryname, $statename, $cityname).'
            '; +
            ' . events_view_filter($foss_type, $foss_sub_project, $startdate, $enddate, $countryname, $statename, $cityname) . '
            '; $form['default_load']['#markup'] = $pagecontent; $commands[] = ajax_command_html("#default_load", drupal_render($form['default_load'])); - }else if ($foss_type != '--------------' && $foss_sub_project == "Spoken Tutorial") { + } else if ($foss_type != '--------------' && $foss_sub_project == "Spoken Tutorial") { $form['displaytext']['#markup'] = "Statistic of project : " . $foss_type; $commands[] = ajax_command_html("#displaytext", drupal_render($form['displaytext'])); @@ -2266,30 +2277,30 @@ foreach ($optiondata as $value) {
          6. Spoken Tutorial
          7. -
            '.spokentutorial_view_all($foss_type) .'
            '; - - $form['default_load']['#markup'] = $pagecontent; - $commands[] = ajax_command_html("#default_load", drupal_render($form['default_load'])); -} - -/* else if ($foss_type != '--------------' && $foss_sub_project == "Postal Campaigns") { - - $form['displaytext']['#markup'] = "Statistic of project : " . $foss_type; - $commands[] = ajax_command_html("#displaytext", drupal_render($form['displaytext'])); - - - $pagecontent = ""; - $pagecontent .= "
            - - -
            " . postalcampaign_view_all($foss_type, $startdate, $enddate) . "
            "; +
            ' . spokentutorial_view_all($foss_type) . '
    '; $form['default_load']['#markup'] = $pagecontent; $commands[] = ajax_command_html("#default_load", drupal_render($form['default_load'])); - + } + + /* else if ($foss_type != '--------------' && $foss_sub_project == "Postal Campaigns") { + + $form['displaytext']['#markup'] = "Statistic of project : " . $foss_type; + $commands[] = ajax_command_html("#displaytext", drupal_render($form['displaytext'])); + + + $pagecontent = ""; + $pagecontent .= "
    + + +
    " . postalcampaign_view_all($foss_type, $startdate, $enddate) . "
    "; + + $form['default_load']['#markup'] = $pagecontent; + $commands[] = ajax_command_html("#default_load", drupal_render($form['default_load'])); + }*/ - - else if ($foss_type != '--------------' && ($foss_sub_project == "Textbook Companion" || $foss_sub_project == "Lab Migration") && $foss_sub_project_status != "--------------") { + + else if ($foss_type != '--------------' && ($foss_sub_project == "Textbook Companion" || $foss_sub_project == "Lab Migration") && $foss_sub_project_status != "--------------") { if ($foss_sub_project == "Textbook Companion" && $foss_sub_project_status == "Completed Books") { $title = "Textbook Companion"; $datatable = get_tabledata_selectedFoss_TBC_LM($foss_type, 'TBC', "completed", $startdate, $enddate, $countryname, $statename, $cityname, $link_flag); @@ -2308,7 +2319,7 @@ foreach ($optiondata as $value) { $form['default_load']['#markup'] = '
    -
    '. $datatable . '
    +
    ' . $datatable . '
    '; $commands[] = ajax_command_html("#default_load", drupal_render($form['default_load'])); @@ -2407,10 +2418,10 @@ function get_tabledata_TBC_or_LM($sub_type, $startdate, $enddate) $clink = "" . $completedbookcount . ""; $completedbookcount = $clink; } - - /* For setting completion date for pending TBC and LM more */ - $pending_enddate = date('Y-m-d', strtotime("+5 months", strtotime( $enddate))); - + + /* For setting completion date for pending TBC and LM more */ + $pending_enddate = date('Y-m-d', strtotime("+5 months", strtotime($enddate))); + if ($foss_detail->foss_name != 'eSim' && $foss_detail->foss_name != 'OpenFOAM' && $foss_detail->foss_name != 'OR-Tools') { if ($foss_detail->foss_name != 'DWSIM') { $query3 = db_query("SELECT COUNT( pe.book ) AS book_count FROM textbook_companion_preference pe LEFT JOIN textbook_companion_proposal po ON pe.proposal_id = po.id WHERE po.proposal_status !=3 AND pe.approval_status =1 AND FROM_UNIXTIME(po.completion_date) >= :startdate AND FROM_UNIXTIME(po.completion_date) <= :enddate ", array( @@ -3044,170 +3055,169 @@ function ajax_state_list_dependent_dropdown_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']]; $country = $form['countryname']['#options'][$form_state['values']['countryname']]; - + $options = array(); - if($country!="--------------"){ + if ($country != "--------------") { + if ($foss_sub_project == "Textbook Companion") { + $sub_project = "textbook_companion_proposal"; + + db_set_active($foss_type); //Active other database + + $options[0] = '--------------'; + $query = " + SELECT * FROM " . $sub_project . " + WHERE country = :country + "; + $args = array( + ":country" => $country + ); + $result = db_query($query, $args); + while ($state_detail = $result->fetchObject()) { + $options[$state_detail->state] = $state_detail->state; + } + + } else if ($foss_sub_project == "Lab Migration") { + $sub_project = "lab_migration_proposal"; + + db_set_active($foss_type); //Active other database + //$options = array(); + $options[0] = '--------------'; + $query = " + SELECT * FROM " . $sub_project . " + WHERE country = :country + "; + $args = array( + ":country" => $country + ); + $result = db_query($query, $args); + while ($state_detail = $result->fetchObject()) { + $options[$state_detail->state] = $state_detail->state; + } + + } else if ($foss_sub_project == "Workshop") { + $sub_project = "workshop"; + $foss_type_db = 'default'; + + db_set_active($foss_type_db); //Active other database + //$options = array(); + $options[0] = '--------------'; + $query = " + SELECT * FROM " . $sub_project . " + WHERE country = :country and foss_name = :foss_name + "; + $args = array( + ":country" => $country, + ":foss_name" => $foss_type + ); + $result = db_query($query, $args); + while ($state_detail = $result->fetchObject()) { + $options[$state_detail->state] = $state_detail->state; + } + } else if ($foss_sub_project == "Conference") { + $sub_project = "workshop"; + $foss_type_db = 'default'; + + db_set_active($foss_type_db); //Active other database + //$options = array(); + $options[0] = '--------------'; + $query = " + SELECT * FROM " . $sub_project . " + WHERE country = :country and foss_name = :foss_name + "; + $args = array( + ":country" => $country, + ":foss_name" => $foss_type + ); + $result = db_query($query, $args); + while ($state_detail = $result->fetchObject()) { + $options[$state_detail->state] = $state_detail->state; + } + } else if ($foss_sub_project == "Self Workshop") { + + + //Get self workshop foss number for spoken + + $query = db_select('foss_type'); + $query->fields('foss_type', array( + 'id' + )); + $query->fields('foss_type', array( + 'foss_name' + )); + $query->fields('foss_type', array( + 'foss_selfworkshop_no' + )); + $query->condition('foss_name', $foss_type); + $result = $query->execute(); + $foss_detail = $result->fetchObject(); + $foss_selfworkshop_no = $foss_detail->foss_selfworkshop_no; + + db_set_active('selfworkshop'); //Active other database + $options[0] = '--------------'; + $query = "SELECT distinct (s.name) as state FROM events_training t, events_academiccenter ac, events_city c, events_state s WHERE t.academic_id=ac.id and ac.city_id=c.id and c.state_id=s.id and (t.status = 4 AND t.foss_id = :foss_id ) + "; + $args = array( + ":foss_id" => $foss_selfworkshop_no + ); + $result = db_query($query, $args); + + while ($state_detail = $result->fetchObject()) { + $options[$state_detail->state] = $state_detail->state; + + } + + } + } else { + $options[0] = '--------------'; + } + + db_set_active('default'); // We need to call the main (drupal) db back + + $form['statename']['#options'] = $options; + $commands[] = ajax_command_replace("#load_state", drupal_render($form['statename'])); + + $optionscity = array(); + $optionscity[0] = '--------------'; + $form['cityname']['#options'] = $optionscity; + $commands[] = ajax_command_replace("#load_city", drupal_render($form['cityname'])); + + return array( + '#type' => 'ajax', + '#commands' => $commands + ); +} + +//Get the list of City according to country selection .It is ajax method for state +function ajax_city_list_dependent_dropdown_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']]; + $country = $form['countryname']['#options'][$form_state['values']['countryname']]; + $state = $form['statename']['#options'][$form_state['values']['statename']]; if ($foss_sub_project == "Textbook Companion") { $sub_project = "textbook_companion_proposal"; db_set_active($foss_type); //Active other database - + $options = array(); $options[0] = '--------------'; $query = " SELECT * FROM " . $sub_project . " - WHERE country = :country + WHERE country = :country and state = :state "; $args = array( - ":country" => $country + ":country" => $country, + ":state" => $state ); $result = db_query($query, $args); - while ($state_detail = $result->fetchObject()) { - $options[$state_detail->state] = $state_detail->state; + while ($city_detail = $result->fetchObject()) { + $options[$city_detail->city] = $city_detail->city; } } else if ($foss_sub_project == "Lab Migration") { $sub_project = "lab_migration_proposal"; db_set_active($foss_type); //Active other database - //$options = array(); - $options[0] = '--------------'; - $query = " - SELECT * FROM " . $sub_project . " - WHERE country = :country - "; - $args = array( - ":country" => $country - ); - $result = db_query($query, $args); - while ($state_detail = $result->fetchObject()) { - $options[$state_detail->state] = $state_detail->state; - } - - } else if ($foss_sub_project == "Workshop") { - $sub_project = "workshop"; - $foss_type_db = 'default'; - - db_set_active($foss_type_db); //Active other database - //$options = array(); - $options[0] = '--------------'; - $query = " - SELECT * FROM " . $sub_project . " - WHERE country = :country and foss_name = :foss_name - "; - $args = array( - ":country" => $country, - ":foss_name" => $foss_type - ); - $result = db_query($query, $args); - while ($state_detail = $result->fetchObject()) { - $options[$state_detail->state] = $state_detail->state; - } - }else if ($foss_sub_project == "Conference") { - $sub_project = "workshop"; - $foss_type_db = 'default'; - - db_set_active($foss_type_db); //Active other database - //$options = array(); - $options[0] = '--------------'; - $query = " - SELECT * FROM " . $sub_project . " - WHERE country = :country and foss_name = :foss_name - "; - $args = array( - ":country" => $country, - ":foss_name" => $foss_type - ); - $result = db_query($query, $args); - while ($state_detail = $result->fetchObject()) { - $options[$state_detail->state] = $state_detail->state; - } - } -else if ($foss_sub_project == "Self Workshop"){ - - - //Get self workshop foss number for spoken - - $query = db_select('foss_type'); - $query->fields('foss_type', array( - 'id' - )); - $query->fields('foss_type', array( - 'foss_name' - )); - $query->fields('foss_type', array( - 'foss_selfworkshop_no' - )); - $query->condition('foss_name', $foss_type); - $result = $query->execute(); - $foss_detail = $result->fetchObject(); - $foss_selfworkshop_no=$foss_detail->foss_selfworkshop_no; - - db_set_active('selfworkshop'); //Active other database - $options[0] = '--------------'; - $query = "SELECT distinct (s.name) as state FROM events_training t, events_academiccenter ac, events_city c, events_state s WHERE t.academic_id=ac.id and ac.city_id=c.id and c.state_id=s.id and (t.status = 4 AND t.foss_id = :foss_id ) - "; - $args = array( - ":foss_id" => $foss_selfworkshop_no, - ); - $result = db_query($query, $args); - - while ($state_detail = $result->fetchObject()) { - $options[$state_detail->state] = $state_detail->state; - - } - - } - }else{ - $options[0] = '--------------'; - } - - db_set_active('default'); // We need to call the main (drupal) db back - - $form['statename']['#options'] = $options; - $commands[] = ajax_command_replace("#load_state", drupal_render($form['statename'])); - - $optionscity = array(); - $optionscity[0] = '--------------'; - $form['cityname']['#options'] = $optionscity; - $commands[] = ajax_command_replace("#load_city", drupal_render($form['cityname'])); - - return array( - '#type' => 'ajax', - '#commands' => $commands - ); -} - -//Get the list of City according to country selection .It is ajax method for state -function ajax_city_list_dependent_dropdown_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']]; - $country = $form['countryname']['#options'][$form_state['values']['countryname']]; - $state = $form['statename']['#options'][$form_state['values']['statename']]; - if ($foss_sub_project == "Textbook Companion") { - $sub_project = "textbook_companion_proposal"; - - db_set_active($foss_type); //Active other database - $options = array(); - $options[0] = '--------------'; - $query = " - SELECT * FROM " . $sub_project . " - WHERE country = :country and state = :state - "; - $args = array( - ":country" => $country, - ":state" => $state - ); - $result = db_query($query, $args); - while ($city_detail = $result->fetchObject()) { - $options[$city_detail->city] = $city_detail->city; - } - - } else if ($foss_sub_project == "Lab Migration") { - $sub_project = "lab_migration_proposal"; - - db_set_active($foss_type); //Active other database - $options = array(); + $options = array(); $options[0] = '--------------'; $query = " SELECT * FROM " . $sub_project . " @@ -3242,7 +3252,7 @@ function ajax_city_list_dependent_dropdown_callback($form, &$form_state) while ($city_detail = $result->fetchObject()) { $options[$city_detail->city] = $city_detail->city; } - }else if ($foss_sub_project == "Conference") { + } else if ($foss_sub_project == "Conference") { $sub_project = "workshop"; $foss_type_db = 'default'; @@ -3262,41 +3272,41 @@ function ajax_city_list_dependent_dropdown_callback($form, &$form_state) while ($city_detail = $result->fetchObject()) { $options[$city_detail->city] = $city_detail->city; } - }else if ($foss_sub_project == "Self Workshop"){ - - //Get self workshop foss number for spoken - - $query = db_select('foss_type'); + } else if ($foss_sub_project == "Self Workshop") { + + //Get self workshop foss number for spoken + + $query = db_select('foss_type'); $query->fields('foss_type', array( 'id' )); $query->fields('foss_type', array( 'foss_name' )); - $query->fields('foss_type', array( + $query->fields('foss_type', array( 'foss_selfworkshop_no' )); $query->condition('foss_name', $foss_type); $result = $query->execute(); $foss_detail = $result->fetchObject(); - $foss_selfworkshop_no=$foss_detail->foss_selfworkshop_no; - db_set_active('selfworkshop'); //Active other database + $foss_selfworkshop_no = $foss_detail->foss_selfworkshop_no; + db_set_active('selfworkshop'); //Active other database $options[0] = '--------------'; - - $query="SELECT distinct (c.name) as city FROM events_training t, events_academiccenter ac, events_city c, events_state s WHERE t.academic_id=ac.id and ac.city_id=c.id and c.state_id=s.id and (t.status = 4 AND t.foss_id = :foss_id ) and s.name LIKE :statename"; - - $args = array( - ":foss_id" => $foss_selfworkshop_no, - ":statename"=>$state, - ); - $result = db_query($query, $args); - - while ($city_detail = $result->fetchObject()) { - $options[$city_detail->city] = $city_detail->city; - - } - - } + + $query = "SELECT distinct (c.name) as city FROM events_training t, events_academiccenter ac, events_city c, events_state s WHERE t.academic_id=ac.id and ac.city_id=c.id and c.state_id=s.id and (t.status = 4 AND t.foss_id = :foss_id ) and s.name LIKE :statename"; + + $args = array( + ":foss_id" => $foss_selfworkshop_no, + ":statename" => $state + ); + $result = db_query($query, $args); + + while ($city_detail = $result->fetchObject()) { + $options[$city_detail->city] = $city_detail->city; + + } + + } db_set_active('default'); // We need to call the main (drupal) db back @@ -3314,7 +3324,7 @@ function ajax_city_list_dependent_dropdown_callback($form, &$form_state) function get_country_list($foss_type, $foss_sub_project) { - if ($foss_type!= 0) { + if ($foss_type != 0) { if ($foss_sub_project != 0) { $query = db_select('foss_type'); @@ -3330,8 +3340,8 @@ function get_country_list($foss_type, $foss_sub_project) $foss_type_name = $foss_detail->foss_name; $options = array(); - if ($foss_sub_project == 1 && $foss_type!=3) { - + if ($foss_sub_project == 1 && $foss_type != 3) { + $sub_project = "textbook_companion_proposal"; db_set_active($foss_type_name); //Active other database @@ -3345,9 +3355,9 @@ function get_country_list($foss_type, $foss_sub_project) while ($country_detail = $result->fetchObject()) { $options[$country_detail->country] = $country_detail->country; } - - } else if ($foss_sub_project == 2 && $foss_type!=3) { + + } else if ($foss_sub_project == 2 && $foss_type != 3) { $sub_project = "lab_migration_proposal"; db_set_active($foss_type_name); //Active other database @@ -3362,7 +3372,7 @@ function get_country_list($foss_type, $foss_sub_project) $options[$country_detail->country] = $country_detail->country; } - } else if ($foss_sub_project == 3||$foss_sub_project == 5) { + } else if ($foss_sub_project == 3 || $foss_sub_project == 5) { $sub_project = "workshop"; $foss_type_db = 'default'; @@ -3381,11 +3391,11 @@ function get_country_list($foss_type, $foss_sub_project) $options[$country_detail->country] = $country_detail->country; } - }else if ($foss_sub_project == 4) { + } else if ($foss_sub_project == 4) { $options[0] = '--------------'; $options[1] = 'India'; - + } @@ -3404,7 +3414,7 @@ function get_country_list($foss_type, $foss_sub_project) //Get list of state function get_state_list($foss_type, $foss_sub_project, $country) { - if (($foss_type != 0) && $foss_sub_project != 0 && $country != "") { + if (($foss_type != 0) && $foss_sub_project != 0 && $country != "") { $query = db_select('foss_type'); $query->fields('foss_type', array( @@ -3413,18 +3423,18 @@ function get_state_list($foss_type, $foss_sub_project, $country) $query->fields('foss_type', array( 'foss_name' )); - $query->fields('foss_type', array( + $query->fields('foss_type', array( 'foss_selfworkshop_no' )); $query->condition('id', $foss_type); $result = $query->execute(); $foss_detail = $result->fetchObject(); $foss_type_name = $foss_detail->foss_name; - $foss_selfworkshop_no=$foss_detail->foss_selfworkshop_no; + $foss_selfworkshop_no = $foss_detail->foss_selfworkshop_no; $options = array(); - - if ($foss_sub_project == 1 && $foss_type!=3) { - $options = array(); + + if ($foss_sub_project == 1 && $foss_type != 3) { + $options = array(); $sub_project = "textbook_companion_proposal"; db_set_active($foss_type_name); //Active other database @@ -3442,11 +3452,11 @@ function get_state_list($foss_type, $foss_sub_project, $country) $options[$state_detail->state] = $state_detail->state; } - } else if ($foss_sub_project == 2 && $foss_type!=3) { + } else if ($foss_sub_project == 2 && $foss_type != 3) { $sub_project = "lab_migration_proposal"; $options = array(); db_set_active($foss_type_name); //Active other database - + $options[0] = '--------------'; $query = " SELECT * FROM " . $sub_project . " @@ -3460,13 +3470,13 @@ function get_state_list($foss_type, $foss_sub_project, $country) $options[$state_detail->state] = $state_detail->state; } - } else if ($foss_sub_project == 3||$foss_sub_project == 5) { -$options = array(); + } else if ($foss_sub_project == 3 || $foss_sub_project == 5) { + $options = array(); $sub_project = "workshop"; $foss_type_db = 'default'; db_set_active($foss_type_db); //Active other database - + $options[0] = '--------------'; $query = "SELECT * FROM " . $sub_project . " WHERE country = :country and foss_name = :foss_name @@ -3481,21 +3491,21 @@ $options = array(); } } else if ($foss_sub_project == 4) { - + db_set_active('selfworkshop'); //Active other database $options[0] = '--------------'; $query = "SELECT distinct (s.name) as state FROM events_training t, events_academiccenter ac, events_city c, events_state s WHERE t.academic_id=ac.id and ac.city_id=c.id and c.state_id=s.id and (t.status = 4 AND t.foss_id = :foss_id ) "; $args = array( - ":foss_id" => $foss_selfworkshop_no, + ":foss_id" => $foss_selfworkshop_no ); $result = db_query($query, $args); - + while ($state_detail = $result->fetchObject()) { $options[$state_detail->state] = $state_detail->state; - + } - + } db_set_active('default'); // We need to call the main (drupal) db back @@ -3510,8 +3520,8 @@ $options = array(); function get_city_list($foss_type, $foss_sub_project, $country, $state) { - if (($foss_type != 0 ) && $foss_sub_project != 0 && $country != "" && $state != "") { - + if (($foss_type != 0) && $foss_sub_project != 0 && $country != "" && $state != "") { + $query = db_select('foss_type'); $query->fields('foss_type', array( 'id' @@ -3519,15 +3529,15 @@ function get_city_list($foss_type, $foss_sub_project, $country, $state) $query->fields('foss_type', array( 'foss_name' )); - $query->fields('foss_type', array( + $query->fields('foss_type', array( 'foss_selfworkshop_no' )); $query->condition('id', $foss_type); $result = $query->execute(); $foss_detail = $result->fetchObject(); $foss_type = $foss_detail->foss_name; - $foss_selfworkshop_no=$foss_detail->foss_selfworkshop_no; - if ($foss_sub_project == 1 && $foss_type!="Python") { + $foss_selfworkshop_no = $foss_detail->foss_selfworkshop_no; + if ($foss_sub_project == 1 && $foss_type != "Python") { $sub_project = "textbook_companion_proposal"; db_set_active($foss_type); //Active other database $options = array(); @@ -3545,7 +3555,7 @@ function get_city_list($foss_type, $foss_sub_project, $country, $state) $options[$city_detail->city] = $city_detail->city; } - } else if ($foss_sub_project == 2 && $foss_type!="Python") { + } else if ($foss_sub_project == 2 && $foss_type != "Python") { $sub_project = "lab_migration_proposal"; db_set_active($foss_type); //Active other database $options = array(); @@ -3564,7 +3574,7 @@ function get_city_list($foss_type, $foss_sub_project, $country, $state) } - } else if ($foss_sub_project == 3||$foss_sub_project == 5) { + } else if ($foss_sub_project == 3 || $foss_sub_project == 5) { $sub_project = "workshop"; $foss_type_db = 'default'; @@ -3585,25 +3595,25 @@ function get_city_list($foss_type, $foss_sub_project, $country, $state) $options[$city_detail->city] = $city_detail->city; } } else if ($foss_sub_project == 4) { - - - db_set_active('selfworkshop'); //Active other database - $options[0] = '--------------'; - - $query="SELECT distinct (c.name) as city FROM events_training t, events_academiccenter ac, events_city c, events_state s WHERE t.academic_id=ac.id and ac.city_id=c.id and c.state_id=s.id and (t.status = 4 AND t.foss_id = :foss_id ) and s.name LIKE :statename"; - - $args = array( + + + db_set_active('selfworkshop'); //Active other database + $options[0] = '--------------'; + + $query = "SELECT distinct (c.name) as city FROM events_training t, events_academiccenter ac, events_city c, events_state s WHERE t.academic_id=ac.id and ac.city_id=c.id and c.state_id=s.id and (t.status = 4 AND t.foss_id = :foss_id ) and s.name LIKE :statename"; + + $args = array( ":foss_id" => $foss_selfworkshop_no, - ":statename"=>$state, + ":statename" => $state ); $result = db_query($query, $args); - + while ($city_detail = $result->fetchObject()) { $options[$city_detail->city] = $city_detail->city; - + } - - } + + } @@ -3618,13 +3628,13 @@ function get_city_list($foss_type, $foss_sub_project, $country, $state) } } -/*Add Event form (Workshop and seminar aling with photos testimonials and speakers) - Same form is used for editing existing events +/*Add Event form (Workshop and seminar along with photos testimonials and speakers) +Same form is used for editing existing events */ function workshop_add_form($form, &$form_state, $workshop_id = 0, $no_js_use = FALSE) { - -$query = " + + $query = " SELECT * FROM workshop WHERE w_id = :workshop_id "; @@ -3634,7 +3644,7 @@ $query = " $result = db_query($query, $args); $row = $result->fetchObject(); $form = array(); - + if ($workshop_id == 0) { $form['foss_select'] = array( '#type' => 'select', @@ -3642,7 +3652,7 @@ $query = " '#options' => get_first_dropdown_options_foss_name(), '#default_value' => '', "#required" => TRUE - ); + ); $form['type'] = array( '#type' => 'select', '#title' => t('Selected Type'), @@ -3796,6 +3806,12 @@ $query = " "#default_value" => '', "#required" => TRUE ); + + $form["event_link"] = array( + "#type" => "textfield", + "#title" => "Link to event's website", + "#default_value" => '' + ); $form["body"] = array( "#type" => "textarea", "#title" => "Details", @@ -3820,17 +3836,17 @@ $query = " ); $form['speakers_fieldset'][$i]["speakername"] = array( "#type" => "textfield", - "#title" => "Name", + "#title" => "Name: ", "#default_value" => "" ); $form['speakers_fieldset'][$i]["institute"] = array( "#type" => "textfield", - "#title" => "Institute", + "#title" => "Institute: ", "#default_value" => "" ); $form['speakers_fieldset'][$i]["place"] = array( "#type" => "textfield", - "#title" => "Place", + "#title" => "Place: ", "#default_value" => "" ); } @@ -3870,6 +3886,10 @@ $query = " } unset($form['speakers_fieldset']['add_speakers']['#ajax']); } + + + // adding testimonial fieldset + $form['testimonial_fieldset'] = array( '#type' => 'fieldset', '#tree' => TRUE, @@ -3888,22 +3908,22 @@ $query = " ); $form['testimonial_fieldset'][$i]["t_name"] = array( "#type" => "textfield", - "#title" => "Name", + "#title" => "Name: ", "#default_value" => "" ); $form['testimonial_fieldset'][$i]["t_department"] = array( "#type" => "textfield", - "#title" => "Department", + "#title" => "Department: ", "#default_value" => "" ); $form['testimonial_fieldset'][$i]["t_university"] = array( "#type" => "textfield", - "#title" => "University", + "#title" => "University: ", "#default_value" => "" ); $form['testimonial_fieldset'][$i]["t_body"] = array( "#type" => "textarea", - "#title" => "Testimonial" + "#title" => "Testimonial: " ); } $form["testimonial_count"] = array( @@ -3942,6 +3962,76 @@ $query = " } unset($form['testimonial_fieldset']['add_testimonial']['#ajax']); } + + + //Adding video link with title + + $form['videolink_fieldset'] = array( + '#type' => 'fieldset', + '#tree' => TRUE, + '#prefix' => '' + ); + if (empty($form_state['num_videolink'])) { + $form_state['num_videolink'] = 1; + } + $temp = 0; + for ($i = 0; $i < $form_state['num_videolink']; $i++) { + $temp1 = $i; + $form['videolink_fieldset'][$i]["v_text"] = array( + "#type" => "item", + "#markup" => "

    " + ); + $form['videolink_fieldset'][$i]["videolink_title"] = array( + "#type" => "textfield", + "#title" => "Title: ", + "#default_value" => "" + ); + $form['videolink_fieldset'][$i]["videolink_link"] = array( + "#type" => "textfield", + "#title" => "Link: ", + "#default_value" => "" + ); + + } + $form["videolink_count"] = array( + "#type" => "hidden", + "#value" => $temp1 + ); + $form['videolink_fieldset']['add_videolink'] = array( + '#type' => 'submit', + '#value' => t('Add Video Link'), + '#limit_validation_errors' => array(), + '#submit' => array( + 'videolink_add_more_add_one' + ), + '#ajax' => array( + 'callback' => 'videolink_add_more_callback', + 'wrapper' => 'videolink-fieldset-wrapper' + ) + ); + if ($form_state['num_videolink'] > 1) { + $form['videolink_fieldset']['remove_videolink'] = array( + '#type' => 'submit', + '#value' => t('Remove Video Link'), + '#limit_validation_errors' => array(), + '#submit' => array( + 'videolink_add_more_remove_one' + ), + '#ajax' => array( + 'callback' => 'videolink_add_more_callback', + 'wrapper' => 'videolink-fieldset-wrapper' + ) + ); + } + if ($no_js_use) { + if (!empty($form['videolink_fieldset']['remove_videolink']['#ajax'])) { + unset($form['videolink_fieldset']['remove_videolink']['#ajax']); + } + unset($form['videolink_fieldset']['add_videolink']['#ajax']); + } + + $form['names_fieldset'] = array( '#type' => 'fieldset', '#tree' => TRUE, @@ -4162,6 +4252,14 @@ $query = " "#default_value" => $row->no_of_participant, "#required" => TRUE ); + + $form["event_link"] = array( + "#type" => "textfield", + "#title" => "Link to event's website", + "#default_value" => $row->event_link + + ); + $form["body"] = array( "#type" => "textarea", "#title" => "Details", @@ -4169,12 +4267,250 @@ $query = " "#required" => TRUE ); /*Edit Speakers*/ - /*Edit Testimonial*/ - $query_t = db_select('testimonials'); - $query_t->fields('testimonials'); - $query_t->condition('w_id', $workshop_id); - $result_t = $query_t->execute(); - $num_of_results = $result_t->rowCount(); + + $query_s = db_select('speakers'); + $query_s->fields('speakers'); + $query_s->condition('w_id', $workshop_id); + $result_s = $query_s->execute(); + $num_of_speakerresults = $result_s->rowCount(); + + $form['speakers_fieldset'] = array( + '#type' => 'fieldset', + '#tree' => TRUE, + '#prefix' => '
    ', + '#suffix' => '
    ' + ); + + if ($num_of_speakerresults != 0) { + + $form_state['num_speakers'] = $num_of_speakerresults; + $temp = 0; + $i = 0; + while ($row_s = $result_s->fetchObject()) { + $temp = $i; + $form['speakers_fieldset'][$i]["s_text"] = array( + "#type" => "item", + "#markup" => "

    " + ); + $form['speakers_fieldset'][$i]["s_id"] = array( + "#type" => "hidden", + "#default_value" => $row_s->s_id + ); + $form['speakers_fieldset'][$i]["speakername"] = array( + "#type" => "textfield", + "#title" => "Name", + "#default_value" => $row_s->name + ); + $form['speakers_fieldset'][$i]["institute"] = array( + "#type" => "textfield", + "#title" => "Institute", + "#default_value" => $row_s->institute + ); + $form['speakers_fieldset'][$i]["place"] = array( + "#type" => "textfield", + "#title" => "Place", + "#default_value" => $row_s->place + ); + + $i++; + } + + + $form["speakers_count"] = array( + "#type" => "hidden", + "#value" => $temp + ); + + } else { + if (empty($form_state['num_speakers'])) { + $form_state['num_speakers'] = 1; + } + $temp = 0; + for ($i = 0; $i < $form_state['num_speakers']; $i++) { + $temp = $i; + $form['speakers_fieldset'][$i]["s_text"] = array( + "#type" => "item", + "#markup" => "

    " + ); + $form['speakers_fieldset'][$i]["speakername"] = array( + "#type" => "textfield", + "#title" => "Name", + "#default_value" => "" + ); + $form['speakers_fieldset'][$i]["institute"] = array( + "#type" => "textfield", + "#title" => "Department", + "#default_value" => "" + ); + $form['speakers_fieldset'][$i]["place"] = array( + "#type" => "textfield", + "#title" => "University", + "#default_value" => "" + ); + + } + $form["speakers_count"] = array( + "#type" => "hidden", + "#value" => $temp + ); + $form['speakers_fieldset']['add_speakers'] = array( + '#type' => 'submit', + '#value' => t('Add Speaker'), + '#limit_validation_errors' => array(), + '#submit' => array( + 'speakers_add_more_add_one' + ), + '#ajax' => array( + 'callback' => 'speakers_add_more_callback', + 'wrapper' => 'speakers-fieldset-wrapper' + ) + ); + if ($form_state['num_speakers'] > 1) { + $form['speakers_fieldset']['remove_speakers'] = array( + '#type' => 'submit', + '#value' => t('Remove'), + '#limit_validation_errors' => array(), + '#submit' => array( + 'speakers_add_more_remove_one' + ), + '#ajax' => array( + 'callback' => 'speakers_add_more_callback', + 'wrapper' => 'speakers-fieldset-wrapper' + ) + ); + } + if ($no_js_use) { + if (!empty($form['speakers_fieldset']['remove_speakers']['#ajax'])) { + unset($form['speakers_fieldset']['remove_speakers']['#ajax']); + } + unset($form['speakers_fieldset']['add_speakers']['#ajax']); + } + } + + + /* Edit Video Links */ + + $query_v = db_select('workshop_videolinks'); + $query_v->fields('workshop_videolinks'); + $query_v->condition('w_id', $workshop_id); + $result_v = $query_v->execute(); + $num_of_videoresults = $result_v->rowCount(); + + $form['videolink_fieldset'] = array( + '#type' => 'fieldset', + '#tree' => TRUE, + '#prefix' => '' + ); + + if ($num_of_videoresults != 0) { + + $form_state['num_videolink'] = $num_of_videoresults; + $temp = 0; + $i = 0; + while ($row_v = $result_v->fetchObject()) { + $temp = $i; + $form['videolink_fieldset'][$i]["v_text"] = array( + "#type" => "item", + "#markup" => "

    " + ); + $form['videolink_fieldset'][$i]["v_id"] = array( + "#type" => "hidden", + "#default_value" => $row_v->v_id + ); + $form['videolink_fieldset'][$i]["videolink_title"] = array( + "#type" => "textfield", + "#title" => "Title: ", + "#default_value" => $row_v->title + ); + $form['videolink_fieldset'][$i]["videolink_link"] = array( + "#type" => "textfield", + "#title" => "Institute", + "#default_value" => $row_v->link + ); + + $i++; + } + + + $form["videolink_count"] = array( + "#type" => "hidden", + "#value" => $temp + ); + + } else { + if (empty($form_state['num_videolink'])) { + $form_state['num_videolink'] = 1; + } + $temp = 0; + for ($i = 0; $i < $form_state['num_videolink']; $i++) { + $temp = $i; + $form['videolink_fieldset'][$i]["v_text"] = array( + "#type" => "item", + "#markup" => "

    " + ); + $form['videolink_fieldset'][$i]["videolink_title"] = array( + "#type" => "textfield", + "#title" => "Title: ", + "#default_value" => "" + ); + $form['videolink_fieldset'][$i]["videolink_link"] = array( + "#type" => "textfield", + "#title" => "Link: ", + "#default_value" => "" + ); + + + } + $form["videolink_count"] = array( + "#type" => "hidden", + "#value" => $temp + ); + $form['videolink_fieldset']['add_videolink'] = array( + '#type' => 'submit', + '#value' => t('Add Video'), + '#limit_validation_errors' => array(), + '#submit' => array( + 'videolink_add_more_add_one' + ), + '#ajax' => array( + 'callback' => 'videolink_add_more_callback', + 'wrapper' => 'videolink-fieldset-wrapper' + ) + ); + if ($form_state['num_videolink'] > 1) { + $form['videolink_fieldset']['remove_videolink'] = array( + '#type' => 'submit', + '#value' => t('Remove'), + '#limit_validation_errors' => array(), + '#submit' => array( + 'videolink_add_more_remove_one' + ), + '#ajax' => array( + 'callback' => 'videolink_add_more_callback', + 'wrapper' => 'videolink-fieldset-wrapper' + ) + ); + } + if ($no_js_use) { + if (!empty($form['videolink_fieldset']['remove_videolink']['#ajax'])) { + unset($form['videolink_fieldset']['remove_videolink']['#ajax']); + } + unset($form['videolink_fieldset']['add_videolink']['#ajax']); + } + } + + + + + + + /*Edit Testimonial*/ + $query_t = db_select('testimonials'); + $query_t->fields('testimonials'); + $query_t->condition('w_id', $workshop_id); + $result_t = $query_t->execute(); + $num_of_results = $result_t->rowCount(); $form['testimonial_fieldset'] = array( '#type' => 'fieldset', '#tree' => TRUE, @@ -4463,6 +4799,29 @@ function speakers_add_more_remove_one($form, &$form_state) } +function videolink_add_more_callback($form, $form_state) +{ + return $form['videolink_fieldset']; +} + + +function videolink_add_more_add_one($form, &$form_state) +{ + $form_state['num_videolink']++; + $form_state['rebuild'] = TRUE; + //$form_state['no_redirect'] = TRUE; +} + + +function videolink_add_more_remove_one($form, &$form_state) +{ + if ($form_state['num_videolink'] > 1) { + $form_state['num_videolink']--; + } + $form_state['rebuild'] = TRUE; +} + + function testimonial_add_more_callback($form, $form_state) { return $form['testimonial_fieldset']; @@ -4576,15 +4935,111 @@ function workshop_add_form_submit($form, &$form_state) 'state' => $v["all_state"], 'city' => $v["city"], 'pincode' => $v["pincode"], + 'event_link' => $v["event_link"], 'no_of_participant' => $v["no_of_participant"], 'body' => $v["body"] )); $query->condition('w_id', $v["workshop_id"]); $result = $query->execute(); + + /*For editing speakers */ + + $speakersupload = 0; + for ($i = 0; $i <= $v["speakers_count"]; $i++) { + $s_id = $v['speakers_fieldset'][$i]["s_id"]; + if ($s_id != "") { + if ($v['speakers_fieldset'][$i]["speakername"] != "") { + $query = db_update('speakers'); + $query->fields(array( + 'name' => $v['speakers_fieldset'][$i]["speakername"], + 'institute' => $v['speakers_fieldset'][$i]["institute"], + 'place' => $v['speakers_fieldset'][$i]["place"] + )); + $query->condition('s_id', $v['speakers_fieldset'][$i]["s_id"]); + $result = $query->execute(); + if ($result != 0) { + $speakersupload++; + } + } + } else { + if ($v['speakers_fieldset'][$i]["speakername"] != "") { + $speakersquery = " + INSERT INTO speakers + (w_id,name,institute,place) + VALUES + (:w_id,:name,:institute,:place) + "; + $speakersargs = array( + ":w_id" => $v["workshop_id"], + ":name" => $v['speakers_fieldset'][$i]["speakername"], + ":institute" => $v['speakers_fieldset'][$i]["institute"], + ":place" => $v['speakers_fieldset'][$i]["place"] + ); + /* storing the row id in $result */ + $speakersresult = db_query($speakersquery, $speakersargs, array( + 'return' => Database::RETURN_INSERT_ID + )); + if ($speakersresult != 0) { + $speakersupload++; + } + } + } + } + + + + /*For editing video */ + + $videolink_upload = 0; + for ($i = 0; $i <= $v["videolink_count"]; $i++) { + $v_id = $v['videolink_fieldset'][$i]["v_id"]; + if ($v_id != "") { + if ($v['videolink_fieldset'][$i]["videolink_title"] != "") { + $query = db_update('workshop_videolinks'); + $query->fields(array( + 'title' => $v['videolink_fieldset'][$i]["videolink_title"], + 'link' => $v['videolink_fieldset'][$i]["videolink_link"] + + )); + $query->condition('v_id', $v['videolink_fieldset'][$i]["v_id"]); + $result = $query->execute(); + if ($result != 0) { + $videolink_upload++; + } + } + } else { + if ($v['videolink_fieldset'][$i]["videolink_title"] != "") { + $videolinkquery = " + INSERT INTO workshop_videolinks + (w_id,title,link) + VALUES + (:w_id,:title,:link) + "; + $videolinkargs = array( + ":w_id" => $v["workshop_id"], + ":title" => $v['videolink_fieldset'][$i]["videolink_title"], + ":link" => $v['videolink_fieldset'][$i]["videolink_link"] + + ); + /* storing the row id in $result */ + $videolinkresult = db_query($videolinkquery, $videolinkargs, array( + 'return' => Database::RETURN_INSERT_ID + )); + if ($videolinkresult != 0) { + $videolink_upload++; + } + } + } + } + + + + /* For editing Testimonials */ $testimonialupload = 0; for ($i = 0; $i <= $v["testimonial_count"]; $i++) { - if ($v['testimonial_fieldset'][$i]["t_id"] != "") { + $t_id = $v['testimonial_fieldset'][$i]["t_id"]; + if ($t_id != "") { if ($v['testimonial_fieldset'][$i]["t_name"] != "") { $query = db_update('testimonials'); $query->fields(array( @@ -4631,11 +5086,11 @@ function workshop_add_form_submit($form, &$form_state) $query_img->fields('workshop_images'); $query_img->condition('w_id', $v["workshop_id"]); $result_img = $query_img->execute(); - $root_path=events_images_path(); + $root_path = events_images_path(); while ($row_img = $result_img->fetchObject()) { if ($form_state['values']['imagecheck@' . $row_img->id] == 1) { - if (file_exists($root_path.$row_img->path)) { - unlink($root_path.$row_img->path); + if (file_exists($root_path . $row_img->path)) { + unlink($root_path . $row_img->path); $query2 = db_delete('workshop_images'); $query2->condition('id', $row_img->id); $delete_img = $query2->execute(); @@ -4655,6 +5110,7 @@ function workshop_add_form_submit($form, &$form_state) if (!is_dir($root_path . $dest_path)) { mkdir($root_path . $dest_path); } + $imageupload = 0; /* uploading files */ foreach ($_FILES['files']['name'] as $file_form_name => $file_name) { if ($file_name) { @@ -4664,7 +5120,7 @@ function workshop_add_form_submit($form, &$form_state) )), 'error'); return; } - $imageupload = 0; + /* uploading file */ if (move_uploaded_file($_FILES['files']['tmp_name'][$file_form_name], $root_path . $dest_path . $_FILES['files']['name'][$file_form_name])) { $imagequery = " @@ -4691,7 +5147,7 @@ function workshop_add_form_submit($form, &$form_state) } } } - if (!$result && $imageupload == 0 && $deletecounter == 0) { + if (!$result && $imageupload == 0 && $deletecounter == 0 && $videolink_upload == 0) { drupal_set_message("Something went wrong, please try again.", "error"); } else { drupal_set_message("Workshop updated successfully", "status"); @@ -4705,13 +5161,13 @@ function workshop_add_form_submit($form, &$form_state) } else { $query = " INSERT INTO workshop - (foss_name,type,w_name, startdate, starttime,enddate, endtime, venue, street, country,state,city,pincode,no_of_participant,body) - VALUES (:foss_name,:type,:w_name, :startdate, :starttime,:enddate, :endtime, :venue, :street, :country, :state, :city, :pincode, + (foss_name, type, w_name, startdate, starttime,enddate, endtime, venue, street, country, state, city, pincode, event_link, no_of_participant,body) + VALUES (:foss_name, :type, :w_name, :startdate, :starttime,:enddate, :endtime, :venue, :street, :country, :state, :city, :pincode, :event_link, :no_of_participant, :body) "; $args = array( - ":type" => $v["type"], ":foss_name" => $v["foss_select"], + ":type" => $v["type"], ":w_name" => $v["name"], ":startdate" => $v["start_date"], ":starttime" => "00:00", @@ -4723,6 +5179,7 @@ function workshop_add_form_submit($form, &$form_state) ":state" => $v["all_state"], ":city" => $v["city"], ":pincode" => $v["pincode"], + ":event_link" => $v["event_link"], ":no_of_participant" => $v["no_of_participant"], ":body" => $v["body"] ); @@ -4781,6 +5238,34 @@ function workshop_add_form_submit($form, &$form_state) } } } + + /* Adding video links */ + + $videolinkupload = 0; + for ($i = 0; $i <= $v["videolink_count"]; $i++) { + if ($v['videolink_fieldset'][$i]["videolink_title"] != "") { + $videolinkquery = " + INSERT INTO workshop_videolinks + (w_id,title,link) + VALUES + (:w_id,:title,:link) + "; + $videolinkargs = array( + ":w_id" => $result, + ":title" => $v['videolink_fieldset'][$i]["videolink_title"], + ":link" => $v['videolink_fieldset'][$i]["videolink_link"] + ); + /* storing the row id in $result */ + $videolinkresult = db_query($videolinkquery, $videolinkargs, array( + 'return' => Database::RETURN_INSERT_ID + )); + if ($videolinkresult != 0) { + $videolinkupload++; + } + } + } + + /* For adding images of events*/ $items = array(); $root_path = events_images_path(); @@ -4838,6 +5323,9 @@ function workshop_add_form_submit($form, &$form_state) if ($speakerupload != 0) { drupal_set_message("Speaker's Detail are added successfully", "status"); } + if ($videolinkupload != 0) { + drupal_set_message("Video links are added successfully", "status"); + } } } } @@ -4946,7 +5434,7 @@ function workshop_view_selected_testimonial($id = 0) function workshop_view_all_testimonials($workshop_id = 0) { $page_content = ""; - + $query = db_select('testimonials'); $query->fields('testimonials'); $query->condition('w_id', $workshop_id); @@ -4971,7 +5459,7 @@ function workshop_view_all_testimonials($workshop_id = 0) "; } $page_content .= "
    "; - + $page_content .= theme('pager', array( 'header' => NULL, 'rows' => 4 @@ -5051,7 +5539,7 @@ function workshop_delete_all($workshop_id = 0) $query3 = db_delete('workshop'); $query3->condition('w_id', $workshop_id); $result3 = $query3->execute(); - + if (!$result3) { drupal_set_message("Something went wrong, please try again.", "error"); } else { @@ -5105,10 +5593,9 @@ function workshop_edit_all($workshop_id = 0) } -function events_view_filter($foss_name, $event_type, $startdate, $enddate, - $countryname, $statename, $cityname) +function events_view_filter($foss_name, $event_type, $startdate, $enddate, $countryname, $statename, $cityname) { - + $page_content = ""; $headers = array( "Name", @@ -5148,7 +5635,7 @@ function events_view_filter($foss_name, $event_type, $startdate, $enddate, $cityname = trim($cityname); } - + $rows = array(); $query = db_select('workshop'); $query->fields('workshop'); @@ -5214,7 +5701,7 @@ function workshop_view_all($workshop_id, $startdate, $enddate) $row->startdate, $row->venue, $row->no_of_participant, - + "w_id} target='_blank' title='Click to view detail'>Details" ); array_push($rows1, $item); @@ -5246,7 +5733,7 @@ function conference_seminar_view_all($workshop_id, $startdate, $enddate) $row->startdate, $row->venue, $row->no_of_participant, - + "w_id} target='_blank' title='Click to view detail'>Details" ); array_push($rows1, $item); @@ -5256,7 +5743,7 @@ function conference_seminar_view_all($workshop_id, $startdate, $enddate) } function event_activities_all() -{ +{ //This is used for displaying text (tab sta) $form['displaytext'] = array( '#type' => 'markup', @@ -5275,18 +5762,18 @@ function event_activities_all()
  • Conference
  • ' - ); - - $form['tab_content'] = array( + ); + + $form['tab_content'] = array( '#type' => 'item', '#markup' => '
    -
    ' . workshop_view_all(0,1960-01-01, date("Y-m-d")).'
    +
    ' . workshop_view_all(0, 1960 - 01 - 01, date("Y-m-d")) . '
    -
    ' . conference_seminar_view_all(0, "", "").'
    +
    ' . conference_seminar_view_all(0, "", "") . '
    ' ); @@ -5296,7 +5783,7 @@ function event_activities_all() '#suffix' => '' ); return $form; - + } function event_seminar_view_all($workshop_id, $startdate, $enddate) @@ -5321,7 +5808,7 @@ function event_seminar_view_all($workshop_id, $startdate, $enddate) $row->startdate, $row->venue, $row->no_of_participant, - + "w_id} target='_blank' title='Click to view detail'>Details" ); array_push($rows1, $item); @@ -5359,9 +5846,9 @@ $(document).ready(function(){ }); })(jQuery);"; drupal_add_js($testimonial_scroll_js, 'inline', 'header'); - - - $testimonial_scroll_CSS="#testimonials-wrapper .testimonial { + + + $testimonial_scroll_CSS = "#testimonials-wrapper .testimonial { position: relative; text-align: justify; margin: 25px 0 0 0; @@ -5385,70 +5872,63 @@ $(document).ready(function(){ border-radius: 5px; } - - #testimonials_front{ - padding: 10px 20px 15px 20px; - background:url('../images/open-quote.png') no-repeat ; - background-size: 22px 22px; - background-position: 18px 23px; - text-align:justify; - min-height:90px; - margin-top: 10px; - -moz-border-radius:12px; - -webkit-border-radius:12px; - border-radius:12px; - box-shadow: 1px 1px 4px 1px #888888; - height:135px; - + padding: 10px 20px 15px 20px; + background:url('../images/open-quote.png') no-repeat ; + background-size: 22px 22px; + background-position: 18px 23px; + text-align:justify; + min-height:90px; + margin-top: 10px; + -moz-border-radius:12px; + -webkit-border-radius:12px; + border-radius:12px; + box-shadow: 1px 1px 4px 1px #888888; + height:135px; + } - - #testimonials_front a{ - /* float:left; */ + /* float:left; */ } .testimonial_head { - - text-align:left; - margin-top:-14px; - font-size:16px; + + text-align:left; + margin-top:-14px; + font-size:16px; } #testimonials_front li{ display:none;} -#testimonials_front li:first-child{ display:block;} +#testimonials_front li:first-child{ display:block;width:100%} #testimonials_front ul{ list-style:none;} - #testimonials_front h4{ color:#424242; margin-top:-20px; - + } - - #testimonials_one{ - padding: 10px 20px 15px 20px; - background:url('../images/open-quote.png') no-repeat ; - background-size: 22px 22px; - background-position: 18px 23px; - text-align:justify; - min-height:90px; - margin-top: 10px; - -moz-border-radius:12px; - -webkit-border-radius:12px; - border-radius:12px; - box-shadow: 1px 1px 4px 1px #888888; - height:135px; - + padding: 7px 20px 1px 20px; + background:url('../images/open-quote.png') no-repeat ; + background-size: 22px 22px; + background-position: 18px 23px; + text-align:justify; + margin-top: 10px; + -moz-border-radius:12px; + -webkit-border-radius:12px; + border-radius:2px; + box-shadow: 1px 1px 4px 1px #888888; + width: 94%; +margin: 30px; + } #testimonials_one a{ - /* float:left; */ + /* float:left; */ } @@ -5461,12 +5941,13 @@ margin-top:-20px; #testimonials_one h4{ color:#424242; margin-top:-20px; + } "; - drupal_add_css($testimonial_scroll_CSS, 'inline', 'header'); - + drupal_add_css($testimonial_scroll_CSS, 'inline', 'header'); + $page_content = ""; $row = ""; $row1 = ""; @@ -5480,16 +5961,18 @@ margin-top:-20px; $speakerquery->condition('w_id', $workshop_id); $speakerresult = $speakerquery->execute(); $num_of_speakercount = $speakerresult->rowCount(); - if($num_of_speakercount!=0){ - $textdisplay = ""; - $counter = 1; - while ($speakerrow = $speakerresult->fetchObject()) { - $var = $counter++; - $textdisplay .= "

    " . $var . ". " . $speakerrow->name . " " . $speakerrow->institute . ", " . $speakerrow->place . "

    "; + if ($num_of_speakercount != 0) { + $textdisplay = ""; + $counter = 1; + while ($speakerrow = $speakerresult->fetchObject()) { + $var = $counter++; + $textdisplay .= "" . $var . ". " . $speakerrow->name . "" . $speakerrow->institute . ", " . $speakerrow->place . "

    "; + } } - } //$starttime= strftime('%I:%M %p', strtotime($row->starttime)); //$endtime= strftime('%I:%M %p', strtotime($row->endtime)); + $event_link = $row->event_link; + $startdate = $row->startdate; $enddate = $row->enddate; $date = $row->startdate . " , " . $row->enddate; @@ -5507,15 +5990,21 @@ margin-top:-20px; $dayCount = ((strtotime($date1) - strtotime($date2)) / $daylen) + 1; //$time=$starttime." - ".$endtime; $page_content .= ""; + //if($row->foss_name=="FOSSEE-Laptop"){ + $page_content .= "
    Download as PDF
    "; + //} $page_content .= ""; $page_content .= ""; $page_content .= ""; $page_content .= ""; $page_content .= ""; - if($num_of_speakercount!=0){ - $page_content .= ""; + if ($num_of_speakercount != 0) { + $page_content .= ""; } $page_content .= ""; + if (trim(strlen($event_link) != 0)) { + $page_content .= ''; + } $query = db_select('workshop_images'); $query->fields('workshop_images'); $query->condition('w_id', $workshop_id); @@ -5547,16 +6036,16 @@ margin-top:-20px; if (strlen($row->body) >= 260) { $cut1 = substr($row->body, 0, 200); $cut = $cut1 . " ... "; - $page_testimonial = "
  • {$cut}t_id . " name=" . $row1->t_id . " id=" . $row1->t_id . " class='autodialog' title='Click to read more'>Read more

    + $page_testimonial = "
  • {$cut}t_id . " name=" . $row1->t_id . " id=" . $row1->t_id . " class='autodialog' title='Click to read more'>Read more


    -

    {$row->name},{$row->department},

    -

    {$row->university}.

    +

    {$row->name},{$row->department},

    +

    {$row->university}.

  • "; } else { - $page_testimonial = "
  • $row->body

    + $page_testimonial = "
  • {$row->body}


    -

    {$row->name},{$row->department},

    -

    {$row->university}.

    +

    {$row->name},{$row->department},

    +

    {$row->university}.

  • "; } } @@ -5573,16 +6062,16 @@ margin-top:-20px; if (strlen($row->body) >= 260) { $cut1 = substr($row->body, 0, 200); $cut = $cut1 . " ... "; - $page_testimonial = "
  • {$cut}t_id . " name=" . $row1->t_id . " id=" . $row1->t_id . " class='autodialog' title='Click to read more'>Read more

    + $page_testimonial = "
  • {$cut}t_id . " name=" . $row1->t_id . " id=" . $row1->t_id . " class='autodialog' title='Click to read more'>Read more


    -

    {$row->name},{$row->department},

    -

    {$row->university}.

    +

    {$row->name},{$row->department},

    +

    {$row->university}.

  • "; } else { - $page_testimonial = "
  • $row->body

    + $page_testimonial = "
  • $row->body


    -

    {$row->name},{$row->department},

    -

    {$row->university}.

    +

    {$row->name},{$row->department},

    +

    {$row->university}.

  • "; } } @@ -5591,6 +6080,27 @@ margin-top:-20px; $page_content .= ""; } } + + $videolink_query = db_select('workshop_videolinks'); + $videolink_query->fields('workshop_videolinks'); + $videolink_query->condition('w_id', $workshop_id); + $videolink_query->orderBy('v_id', 'ASC'); + $videolink_result = $videolink_query->execute(); + $videolink_of_results = $videolink_result->rowCount(); + + if ($videolink_of_results != 0) { + + $page_content .= "

    Video Links

    "; + $page_content .= ''; + } + return $page_content; } @@ -5628,26 +6138,27 @@ function _list_of_cities() //Self Workshop from spoken db -function getselfworkshoplcount($foss_name,$startdate,$enddate,$state,$city){ - - if($foss_name=="0"||$foss_name==""){ - $foss_name="%"; - }else{ - $foss_name=$foss_name; - } - - if ($city == "" || $city == "null") { +function getselfworkshoplcount($foss_name, $startdate, $enddate, $state, $city) +{ + + if ($foss_name == "0" || $foss_name == "") { + $foss_name = "%"; + } else { + $foss_name = $foss_name; + } + + if ($city == "" || $city == "null") { $city = "%"; } else { $city = $city; } - + if ($state == "" || $state == "null") { - $state= "%"; + $state = "%"; } else { $state = $state; } - if ($startdate == "") { + if ($startdate == "") { $startdate = '1960-01-01'; } else { $startdate = $startdate; @@ -5663,7 +6174,7 @@ function getselfworkshoplcount($foss_name,$startdate,$enddate,$state,$city){ $page_content = ""; $headers = array( "Foss Name", - "No. of Workshop Conducted", + "No. of Workshop Conducted" ); $query = db_select('foss_type'); @@ -5679,275 +6190,325 @@ function getselfworkshoplcount($foss_name,$startdate,$enddate,$state,$city){ $query->condition('foss_name', $foss_name, 'LIKE'); $query->condition('foss_selfworkshop_no', "null", '!='); $result = $query->execute(); - if($result!=null){ - $page_content = ""; - -if($city == "%"&&$state!="%"){ -$city="NONE"; -while ($foss_detail = $result->fetchObject()) { - - db_set_active('selfworkshop'); - $query2 = db_query("SELECT count(t.id) as count FROM events_training t, events_academiccenter ac, events_city c, events_state s WHERE t.academic_id=ac.id and ac.city_id=c.id and c.state_id=s.id and (t.status = 4 AND t.foss_id = :foss_id ) and s.name LIKE :state AND t.tdate >= :startdate AND t.tdate <= :enddate ", array( - ':foss_id' => $foss_detail->foss_selfworkshop_no, - ':state'=>$state, - ':startdate'=>$startdate, - ':enddate'=>$enddate, - )); - - $count = $query2->fetchObject()->count; - - db_set_active('default'); // We need to call the main (drupal) db back - db_set_active(); - $item = array( - $foss_detail->foss_name, - "foss_selfworkshop_no . "/" .$city."/".$state."/".$startdate."/".$enddate. " target='_blank' title='Click to view workshop list'>".$count."" - ); - - array_push($rows, $item); + if ($result != null) { + $page_content = ""; + + if ($city == "%" && $state != "%") { + $city = "NONE"; + while ($foss_detail = $result->fetchObject()) { + + db_set_active('selfworkshop'); + $query2 = db_query("SELECT count(t.id) as count FROM events_training t, events_academiccenter ac, events_city c, events_state s WHERE t.academic_id=ac.id and ac.city_id=c.id and c.state_id=s.id and (t.status = 4 AND t.foss_id = :foss_id ) and s.name LIKE :state AND t.tdate >= :startdate AND t.tdate <= :enddate ", array( + ':foss_id' => $foss_detail->foss_selfworkshop_no, + ':state' => $state, + ':startdate' => $startdate, + ':enddate' => $enddate + )); + + $count = $query2->fetchObject()->count; + + db_set_active('default'); // We need to call the main (drupal) db back + db_set_active(); + $item = array( + $foss_detail->foss_name, + "foss_selfworkshop_no . "/" . $city . "/" . $state . "/" . $startdate . "/" . $enddate . " target='_blank' title='Click to view workshop list'>" . $count . "" + ); + + array_push($rows, $item); + } + + + } else if ($state == "%" && $city != "%") { + $state = "NONE"; + while ($foss_detail = $result->fetchObject()) { + + db_set_active('selfworkshop'); + $query2 = db_query("SELECT count(t.id) as count FROM events_training t, events_academiccenter ac, events_city c, events_state s WHERE t.academic_id=ac.id and ac.city_id=c.id and c.state_id=s.id and (t.status = 4 AND t.foss_id = :foss_id ) and c.name LIKE :city AND t.tdate >= :startdate AND t.tdate <= :enddate ", array( + ':foss_id' => $foss_detail->foss_selfworkshop_no, + ':city' => $city, + + ':startdate' => $startdate, + ':enddate' => $enddate + )); + + $count = $query2->fetchObject()->count; + + db_set_active('default'); // We need to call the main (drupal) db back + db_set_active(); + $item = array( + $foss_detail->foss_name, + "foss_selfworkshop_no . "/" . $city . "/" . $state . "/" . $startdate . "/" . $enddate . " target='_blank' title='Click to view workshop list'>" . $count . "" + ); + + array_push($rows, $item); + } + + } else if ($city == "%" && $state == "%") { + $city = "NONE"; + $state = "NONE"; + while ($foss_detail = $result->fetchObject()) { + + db_set_active('selfworkshop'); + $query2 = db_query("SELECT count(t.id) as count FROM events_training t, events_academiccenter ac, events_city c, events_state s WHERE t.academic_id=ac.id and ac.city_id=c.id and c.state_id=s.id and (t.status = 4 AND t.foss_id = :foss_id ) AND t.tdate >= :startdate AND t.tdate <= :enddate ", array( + ':foss_id' => $foss_detail->foss_selfworkshop_no, + + ':startdate' => $startdate, + ':enddate' => $enddate + )); + + $count = $query2->fetchObject()->count; + + db_set_active('default'); // We need to call the main (drupal) db back + db_set_active(); + $item = array( + $foss_detail->foss_name, + "foss_selfworkshop_no . "/" . $city . "/" . $state . "/" . $startdate . "/" . $enddate . " target='_blank' title='Click to view workshop list'>" . $count . "" + ); + + array_push($rows, $item); + } + + } else { + + while ($foss_detail = $result->fetchObject()) { + + db_set_active('selfworkshop'); + $query2 = db_query("SELECT count(t.id) as count FROM events_training t, events_academiccenter ac, events_city c, events_state s WHERE t.academic_id=ac.id and ac.city_id=c.id and c.state_id=s.id and (t.status = 4 AND t.foss_id = :foss_id ) and c.name LIKE :city and s.name LIKE :state AND t.tdate >= :startdate AND t.tdate <= :enddate ", array( + ':foss_id' => $foss_detail->foss_selfworkshop_no, + ':city' => $city, + ':state' => $state, + ':startdate' => $startdate, + ':enddate' => $enddate + )); + + $count = $query2->fetchObject()->count; + + db_set_active('default'); // We need to call the main (drupal) db back + db_set_active(); + $item = array( + $foss_detail->foss_name, + "foss_selfworkshop_no . "/" . $city . "/" . $state . "/" . $startdate . "/" . $enddate . " target='_blank' title='Click to view workshop list'>" . $count . "" + ); + + array_push($rows, $item); + } + + } + + $page_content .= bootstrap_table_format($headers, $rows); + + + } else { + $page_content = "No Record Found"; } + return $page_content; + +} -}else if($state == "%"&&$city!="%"){ -$state="NONE"; -while ($foss_detail = $result->fetchObject()) { - - db_set_active('selfworkshop'); - $query2 = db_query("SELECT count(t.id) as count FROM events_training t, events_academiccenter ac, events_city c, events_state s WHERE t.academic_id=ac.id and ac.city_id=c.id and c.state_id=s.id and (t.status = 4 AND t.foss_id = :foss_id ) and c.name LIKE :city AND t.tdate >= :startdate AND t.tdate <= :enddate ", array( - ':foss_id' => $foss_detail->foss_selfworkshop_no, - ':city'=>$city, - - ':startdate'=>$startdate, - ':enddate'=>$enddate, - )); - - $count = $query2->fetchObject()->count; - - db_set_active('default'); // We need to call the main (drupal) db back - db_set_active(); - $item = array( - $foss_detail->foss_name, - "foss_selfworkshop_no . "/" .$city."/".$state."/".$startdate."/".$enddate. " target='_blank' title='Click to view workshop list'>".$count."" - ); - - array_push($rows, $item); +function completed_workshops_list($String, $foss_id, $city, $state, $startdate, $enddate) +{ + + + $query = db_select('foss_type'); + $query->fields('foss_type', array( + 'id' + )); + $query->fields('foss_type', array( + 'foss_name' + )); + + $query->condition('foss_selfworkshop_no', $foss_id); + $result = $query->execute(); + $fossdetail = $result->fetchObject(); + $fossname = $fossdetail->foss_name; + $caption = "

    List of Workshop under FOSS : " . $fossname . "

    "; + + if ($city == "NONE") { + $city = "%"; + } else { + $city = $city; } - -}else if($city == "%"&&$state == "%"){ -$city="NONE"; -$state="NONE"; -while ($foss_detail = $result->fetchObject()) { - - db_set_active('selfworkshop'); - $query2 = db_query("SELECT count(t.id) as count FROM events_training t, events_academiccenter ac, events_city c, events_state s WHERE t.academic_id=ac.id and ac.city_id=c.id and c.state_id=s.id and (t.status = 4 AND t.foss_id = :foss_id ) AND t.tdate >= :startdate AND t.tdate <= :enddate ", array( - ':foss_id' => $foss_detail->foss_selfworkshop_no, - - ':startdate'=>$startdate, - ':enddate'=>$enddate, - )); - - $count = $query2->fetchObject()->count; - - db_set_active('default'); // We need to call the main (drupal) db back - db_set_active(); - $item = array( - $foss_detail->foss_name, - "foss_selfworkshop_no . "/" .$city."/".$state."/".$startdate."/".$enddate. " target='_blank' title='Click to view workshop list'>".$count."" - ); - - array_push($rows, $item); + if ($state == "NONE") { + $state = "%"; + } else { + $state = $state; } - -}else{ - -while ($foss_detail = $result->fetchObject()) { - - db_set_active('selfworkshop'); - $query2 = db_query("SELECT count(t.id) as count FROM events_training t, events_academiccenter ac, events_city c, events_state s WHERE t.academic_id=ac.id and ac.city_id=c.id and c.state_id=s.id and (t.status = 4 AND t.foss_id = :foss_id ) and c.name LIKE :city and s.name LIKE :state AND t.tdate >= :startdate AND t.tdate <= :enddate ", array( - ':foss_id' => $foss_detail->foss_selfworkshop_no, - ':city'=>$city, - ':state'=>$state, - ':startdate'=>$startdate, - ':enddate'=>$enddate, - )); - - $count = $query2->fetchObject()->count; - - db_set_active('default'); // We need to call the main (drupal) db back - db_set_active(); - $item = array( - $foss_detail->foss_name, - "foss_selfworkshop_no . "/" .$city."/".$state."/".$startdate."/".$enddate. " target='_blank' title='Click to view workshop list'>".$count."" - ); - + + $query = ""; + $count_query = ""; + $rows = array(); + db_set_active('selfworkshop'); + + + $header = array( + array( + 'data' => 'Institution', + 'field' => 'ac.institution_name' + ), + array( + 'data' => 'City', + 'field' => 'c.name' + ), + array( + 'data' => 'Workshop_Date', + 'field' => 't.tdate', + 'sort' => 'desc' + ), + array( + 'data' => 'No. of students', + 'field' => 't.participant_count' + ), + array( + 'data' => '' + ) + ); + + + db_set_active('workshop_info'); + $query = db_select('events_training', 't'); + $query->join('events_academiccenter', 'ac', 'ac.id=t.academic_id'); + $query->join('events_city', 'c', 'c.id=ac.city_id'); + $query->join('events_state', 's', 's.id=c.state_id'); + $query->fields('t', array( + 'id', + 'foss_id', + 'tdate', + 'participant_count' + )); + $query->fields('ac', array( + 'institution_name' + )); + $query->fields('c', array( + 'name' + )); + $query->addField('c', 'name', 'city'); + $query->condition('t.status', 4); + $query->condition('t.foss_id', $foss_id); + $query->condition('c.name', $city, 'LIKE'); + $query->condition('s.name', $state, 'LIKE'); + $query->condition('t.tdate', $startdate, '>='); + $query->condition('t.tdate', $enddate, '<='); + $result = $query->extend('PagerDefault')->limit(50)->extend('TableSort')->orderByHeader($header)->execute(); + $number_of_rows = $result->rowCount(); + + + while ($row = $result->fetchObject()) { + $item = array( + $row->institution_name, + $row->city, + $row->tdate, + $row->participant_count, + "id . " target='_blank' title='Click to view detail'>View" + ); array_push($rows, $item); } - -} - $page_content .= bootstrap_table_format($headers, $rows); - - }else{ - $page_content = "No Record Found"; - } - return $page_content; - + if ($number_of_rows == 0) { + $output .= '
    List is empty.
    '; + } else { + + $build['pager_table'] = array( + '#theme' => 'table', + '#header' => $header, + '#rows' => $rows, + '#caption' => $caption, + '#attributes' => array( + 'class' => array( + 'table table-bordered table-hover' + ) + ) + ); + + // Attach the pager theme. + $build['pager_pager'] = array( + '#theme' => 'pager' + ); + $output = $build; + + + } + + db_set_active('default'); + return $output; + } -function completed_workshops_list($String,$foss_id,$city,$state,$startdate,$enddate){ - - - $query = db_select('foss_type'); - $query->fields('foss_type', array( - 'id' - )); - $query->fields('foss_type', array( - 'foss_name' - )); - - $query->condition('foss_selfworkshop_no', $foss_id); - $result = $query->execute(); - $fossdetail = $result->fetchObject(); - $fossname=$fossdetail->foss_name; - $caption="

    List of Workshop under FOSS : ".$fossname."

    "; - - if($city=="NONE"){ - $city="%"; - }else{ - $city=$city; - } - if($state=="NONE"){ - $state="%"; - }else{ - $state=$state; - } - - $query = ""; - $count_query = ""; - $rows=array(); - db_set_active('selfworkshop'); - - - $header = array( - array('data'=>'Institution', 'field'=>'ac.institution_name'), - array('data'=>'City', 'field'=>'c.name'), - array('data'=>'Workshop_Date', 'field'=>'t.tdate', 'sort'=>'desc'), - array('data'=>'No. of students', 'field'=>'t.participant_count'), - array('data'=>''), - ); - - - db_set_active('workshop_info'); - $query = db_select('events_training', 't'); - $query->join('events_academiccenter','ac','ac.id=t.academic_id'); - $query->join('events_city','c','c.id=ac.city_id'); - $query->join('events_state','s','s.id=c.state_id'); - $query->fields('t', array('id', 'foss_id', 'tdate', 'participant_count')); - $query->fields('ac', array('institution_name')); - $query->fields('c', array('name')); - $query->addField('c','name','city'); - $query->condition('t.status', 4); - $query->condition('t.foss_id', $foss_id); - $query->condition('c.name',$city,'LIKE'); - $query->condition('s.name',$state,'LIKE'); - $query->condition('t.tdate', $startdate, '>='); - $query->condition('t.tdate', $enddate, '<='); - $result = $query->extend('PagerDefault')->limit(50)->extend('TableSort')->orderByHeader($header)->execute(); - $number_of_rows = $result->rowCount(); - - - while ($row = $result->fetchObject()) { - $item = array($row->institution_name, $row->city, $row->tdate, $row->participant_count, - "id." target='_blank' title='Click to view detail'>View", - ); - array_push($rows, $item); - } - - - if ($number_of_rows==0) { - $output .= '
    List is empty.
    '; - } else { - - $build['pager_table'] = array( - '#theme' => 'table', - '#header' => $header, - '#rows' => $rows, - '#caption'=>$caption, - '#attributes' => array ( - 'class' => array('table table-bordered table-hover'), - ), - ); - - // Attach the pager theme. - $build['pager_pager'] = array('#theme' => 'pager'); - $output = $build; - - - } - - db_set_active('default'); - return $output; - - } - - -function view_completed_workshop($id = NULL){ - - if($id){ - - db_set_active('selfworkshop'); - $query = db_select('events_training', 't'); - $query->join('events_academiccenter','ac','ac.id=t.academic_id'); - $query->join('events_city','c','c.id=ac.city_id'); - $query->join('creation_fosscategory','f','f.id=t.foss_id'); - $query->fields('f', array('foss')); - $query->fields('ac', array('address', 'academic_code', 'institution_name')); - $query->fields('c', array('name')); - $query->addField('c','name','city'); - $query->fields('t', array('organiser_id', 'training_code', 'tdate', 'participant_count')); - $query->condition('t.id', $id); - $result = $query->execute(); - - if($result){ - - $item =$result->fetchObject(); - - db_set_active('selfworkshop'); - $query = db_select('events_organiser', 'o'); - $query->join('auth_user','u','u.id=o.user_id'); - $query->fields('u', array('first_name', 'last_name')); - $query->condition('o.id', 2); - $result = $query->execute(); - - //db_set_active('workshop_info'); - //$result = db_query($query); - db_set_active('default'); - $organiser = $result->fetchObject(); - - $output .= '

    Name{$row->w_name}
    Start Date$startdate
    End Date$enddate
    No. of Participants{$row->no_of_participant}
    Venue{$row->venue}
    Speakers$textdisplay
    Speakers$textdisplay
    Details{$row->body}
    Event website' . $event_link . '
    '; - $output .= ''; - $output .= ''; - $output .= ''; - $output .= ''; - $output .= ''; + + $output .= ''; + $output .= ''; + $output .= ''; + $output .= ''; + $output .= '
    Workshop Code'.$item->training_code.'
    Foss Category'.$item->foss.'
    Date & Time'.$item->tdate.'
    No.of Participants '.$item->participant_count.'
    Organiser '.$organiser->first_name.' '.$organiser->last_name.' +function view_completed_workshop($id = NULL) +{ + + if ($id) { + + db_set_active('selfworkshop'); + $query = db_select('events_training', 't'); + $query->join('events_academiccenter', 'ac', 'ac.id=t.academic_id'); + $query->join('events_city', 'c', 'c.id=ac.city_id'); + $query->join('creation_fosscategory', 'f', 'f.id=t.foss_id'); + $query->fields('f', array( + 'foss' + )); + $query->fields('ac', array( + 'address', + 'academic_code', + 'institution_name' + )); + $query->fields('c', array( + 'name' + )); + $query->addField('c', 'name', 'city'); + $query->fields('t', array( + 'organiser_id', + 'training_code', + 'tdate', + 'participant_count' + )); + $query->condition('t.id', $id); + $result = $query->execute(); + + if ($result) { + + $item = $result->fetchObject(); + + db_set_active('selfworkshop'); + $query = db_select('events_organiser', 'o'); + $query->join('auth_user', 'u', 'u.id=o.user_id'); + $query->fields('u', array( + 'first_name', + 'last_name' + )); + $query->condition('o.id', 2); + $result = $query->execute(); + + //db_set_active('workshop_info'); + //$result = db_query($query); + db_set_active('default'); + $organiser = $result->fetchObject(); + + $output .= ''; + $output .= ''; + $output .= ''; + $output .= ''; + $output .= ''; + $output .= ''; - $output .= ''; - - $output .= ''; - $output .= ''; - $output .= ''; - $output .= ''; - $output .= '
    Workshop Code' . $item->training_code . '
    Foss Category' . $item->foss . '
    Date & Time' . $item->tdate . '
    No.of Participants ' . $item->participant_count . '
    Organiser ' . $organiser->first_name . ' ' . $organiser->last_name . '
    Academic Center Code'.$item->academic_code.'
    Institution Name'.$item->institution_name.'
    Street'.$item->address.'
    City'.$item->city.'
    '; - - return $output; - }else { - drupal_set_message('Error accessing database selfworkshop'); - } - }else{ - return "

    Sorry, no data found.

    "; - } - } + $output .= '
    Academic Center Code' . $item->academic_code . '
    Institution Name' . $item->institution_name . '
    Street' . $item->address . '
    City' . $item->city . '
    '; + + return $output; + } else { + drupal_set_message('Error accessing database selfworkshop'); + } + } else { + return "

    Sorry, no data found.

    "; + } +} function postalcampaign_display_all() { @@ -5969,7 +6530,7 @@ function postalcampaign_add_form($form, &$form_state, $postalcampaign_id = 0, $n $result = db_query($query, $args); $row = $result->fetchObject(); $form = array(); - + if ($postalcampaign_id == 0) { $form['foss_select'] = array( '#type' => 'select', @@ -5978,7 +6539,7 @@ function postalcampaign_add_form($form, &$form_state, $postalcampaign_id = 0, $n '#default_value' => '', "#required" => TRUE ); - + $form["name"] = array( "#type" => "textfield", "#title" => "Name", @@ -6108,20 +6669,20 @@ function postalcampaign_add_form($form, &$form_state, $postalcampaign_id = 0, $n $query1->condition('p_id', $postalcampaign_id); $result1 = $query1->execute(); while ($row1 = $result1->fetchObject()) { - $suffix=""; - $ext = explode(".", $row1->name); - if(($ext[1]=="png")||($ext[1]=="PNG")||($ext[1]=="jpeg")||($ext[1]=="JPEG")||($ext[1]=="jpg")||($ext[1]=="JPG")){ - $suffix='p_name) . "/" . $row1->name . ' />'; - }else{ - $suffix='p_name) . "/" . $row1->name ." target="."_blank >".$row1->name.''; - } - + $suffix = ""; + $ext = explode(".", $row1->name); + if (($ext[1] == "png") || ($ext[1] == "PNG") || ($ext[1] == "jpeg") || ($ext[1] == "JPEG") || ($ext[1] == "jpg") || ($ext[1] == "JPG")) { + $suffix = 'p_name) . "/" . $row1->name . ' />'; + } else { + $suffix = 'p_name) . "/" . $row1->name . " target=" . "_blank >" . $row1->name . ''; + } + $form['postercheck@' . $row1->id] = array( '#type' => 'checkbox', - '#field_suffix' => $suffix, - - - + '#field_suffix' => $suffix + + + ); } $form['enduploadposter'] = array( @@ -6194,8 +6755,8 @@ function postalcampaign_add_form($form, &$form_state, $postalcampaign_id = 0, $n function postalcampaign_add_form_submit($form, &$form_state) { - $v = $form_state["values"]; - $posterupload = 0; + $v = $form_state["values"]; + $posterupload = 0; if ($v["postercampaign_id"]) { $query = db_update('postercampaign'); $query->fields(array( @@ -6206,7 +6767,7 @@ function postalcampaign_add_form_submit($form, &$form_state) )); $query->condition('p_id', $v["postercampaign_id"]); $result = $query->execute(); - + /* For editing Event images */ /* For deleting existing images */ /* For deleting existing images */ @@ -6215,11 +6776,11 @@ function postalcampaign_add_form_submit($form, &$form_state) $query_poster->fields('postercampaign_poster'); $query_poster->condition('p_id', $v["postercampaign_id"]); $result_poster = $query_poster->execute(); - $root_path=posters_path(); + $root_path = posters_path(); while ($row_poster = $result_poster->fetchObject()) { if ($form_state['values']['postercheck@' . $row_poster->id] == 1) { - if (file_exists($root_path.$row_poster->path)) { - unlink($root_path.$row_poster->path); + if (file_exists($root_path . $row_poster->path)) { + unlink($root_path . $row_poster->path); $query2 = db_delete('postercampaign_poster'); $query2->condition('id', $row_poster->id); $delete_poster = $query2->execute(); @@ -6232,7 +6793,7 @@ function postalcampaign_add_form_submit($form, &$form_state) } } /* For adding more images to existing event */ - $items = array(); + $items = array(); $root_path = posters_path(); $eventfolder = str_replace(' ', '_', $v["name"]); $dest_path = $eventfolder . '/'; @@ -6302,7 +6863,7 @@ function postalcampaign_add_form_submit($form, &$form_state) $result = db_query($query, $args, array( 'return' => Database::RETURN_INSERT_ID )); - + /* For adding poster of events*/ $items = array(); $root_path = posters_path(); @@ -6396,7 +6957,7 @@ function postalcampaign_add_form_validate($form, &$form_state) break; } $allowed_extensions = explode(',', $allowed_extensions_str); - $allowed_ext= explode('.', strtolower($_FILES['files']['name'][$file_form_name])); + $allowed_ext = explode('.', strtolower($_FILES['files']['name'][$file_form_name])); $temp_extension = end($allowed_ext); if (!in_array($temp_extension, $allowed_extensions)) form_set_error($file_form_name, t('Only file with ' . $allowed_extensions_str . ' extensions can be uploaded.')); @@ -6468,11 +7029,11 @@ function postalcampaign_delete_all($postercampaign_id = 0) } else { drupal_set_message(t("Event directory not present : " . $dir_path . ". Skipping deleting directory."), 'status'); } - + $query3 = db_delete('postercampaign'); $query3->condition('p_id', $postercampaign_id); $result3 = $query3->execute(); - + if (!$result3) { drupal_set_message("Something went wrong, please try again.", "error"); } else { @@ -6487,7 +7048,7 @@ function postalcampaign_delete_all($postercampaign_id = 0) function postalcampaign_view_details_all($postalcampaign_id = 0) { - + $page_content = ""; $row = ""; $row1 = ""; @@ -6496,22 +7057,22 @@ function postalcampaign_view_details_all($postalcampaign_id = 0) $query->condition('p_id', $postalcampaign_id); $result = $query->execute(); $row = $result->fetchObject(); - + //createZipOfPosterMaterial($row->p_name); $startdate = $row->startdate; - $eventfolder = str_replace(' ', '_',$row->p_name); + $eventfolder = str_replace(' ', '_', $row->p_name); $page_content .= ""; $page_content .= ""; $page_content .= ""; $page_content .= ""; $page_content .= "
    Name{$row->p_name}
    Date$startdate
    Details{$row->body}
    "; - + $page_content .= ""; $page_content .= ""; -$page_content .=""; - + Click to Download"; + $page_content .= ""; + $query = db_select('postercampaign_poster'); $query->fields('postercampaign_poster'); $query->condition('p_id', $postalcampaign_id); @@ -6520,27 +7081,27 @@ $page_content .=""; if ($num_of_results != 0) { $page_content .= "
    Campaign Posters - Click to Download
    "; while ($row1 = $result->fetchObject()) { - $ext = explode(".", $row1->name); - if(($ext[1]=="png")||($ext[1]=="PNG")||($ext[1]=="jpeg")||($ext[1]=="JPEG")||($ext[1]=="jpg")||($ext[1]=="JPG")){ - $page_content .= "p_name) . "/" . $row1->name . ">p_name) . "/" . $row1->name . " />"; - - } - } + $ext = explode(".", $row1->name); + if (($ext[1] == "png") || ($ext[1] == "PNG") || ($ext[1] == "jpeg") || ($ext[1] == "JPEG") || ($ext[1] == "jpg") || ($ext[1] == "JPG")) { + $page_content .= "p_name) . "/" . $row1->name . ">p_name) . "/" . $row1->name . " />"; + + } + } $page_content .= "
    "; - $page_content .= "

    Poster's PDF

    "; - $query = db_select('postercampaign_poster'); + $page_content .= "

    Poster's PDF

    "; + $query = db_select('postercampaign_poster'); $query->fields('postercampaign_poster'); $query->condition('p_id', $postalcampaign_id); $result = $query->execute(); - - while ($row1 = $result->fetchObject()) { - $ext = explode(".", $row1->name); - if(($ext[1]=="pdf")||($ext[1]=="PDF")){ - $page_content .= "p_name) . "/" . $row1->name . " target='_blank' title='Click to view'>".$row1->name.""; - - } - } - + + while ($row1 = $result->fetchObject()) { + $ext = explode(".", $row1->name); + if (($ext[1] == "pdf") || ($ext[1] == "PDF")) { + $page_content .= "p_name) . "/" . $row1->name . " target='_blank' title='Click to view'>" . $row1->name . ""; + + } + } + } else { $page_content .= ""; } @@ -6548,33 +7109,34 @@ $page_content .=""; return $page_content; } -function createZipOfPosterMaterial($name = ""){ - -$root_path = posters_path(); -$eventfolder = $name; -$zip_filename=$root_path.$eventfolder.".zip"; - -$zip = new ZipArchive(); -// open archive -if ($zip->open($root_path.$eventfolder.".zip", ZIPARCHIVE::CREATE) !== TRUE) { -die ("Could not open archive"); -} -$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($root_path.$eventfolder."/")); -// iterate over the directory -// add each file found to the archive -foreach ($iterator as $key=>$value) { - -//Check for valid file -if(strpos(basename($key),'.')!=0){ -$zip->addFile(realpath($key), basename($key)) or die ("ERROR: Could not add file: $key"); -} -} -// close and save archive -$zip->close(); - - /* download zip file */ +function createZipOfPosterMaterial($name = "") +{ + + $root_path = posters_path(); + $eventfolder = $name; + $zip_filename = $root_path . $eventfolder . ".zip"; + + $zip = new ZipArchive(); + // open archive + if ($zip->open($root_path . $eventfolder . ".zip", ZIPARCHIVE::CREATE) !== TRUE) { + die("Could not open archive"); + } + $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($root_path . $eventfolder . "/")); + // iterate over the directory + // add each file found to the archive + foreach ($iterator as $key => $value) { + + //Check for valid file + if (strpos(basename($key), '.') != 0) { + $zip->addFile(realpath($key), basename($key)) or die("ERROR: Could not add file: $key"); + } + } + // close and save archive + $zip->close(); + + /* download zip file */ header('Content-Type: application/zip'); - header('Content-disposition: attachment; filename="'.$eventfolder.'.zip"'); + header('Content-disposition: attachment; filename="' . $eventfolder . '.zip"'); header('Content-Length: ' . filesize($zip_filename)); ob_clean(); //flush(); @@ -6582,17 +7144,18 @@ $zip->close(); unlink($zip_filename); } -function postalcampaign_view_withoutfilter(){ -$foss_name=""; -$startdate="1960-01-01"; -$enddate=date("Y-m-d"); -$pagecontent=postalcampaign_view_all($foss_name, $startdate, $enddate); -return $pagecontent; +function postalcampaign_view_withoutfilter() +{ + $foss_name = ""; + $startdate = "1960-01-01"; + $enddate = date("Y-m-d"); + $pagecontent = postalcampaign_view_all($foss_name, $startdate, $enddate); + return $pagecontent; } function postalcampaign_view_all($foss_name, $startdate, $enddate) { - + if ($startdate == "") { $startdate = "1960-01-01"; } else { @@ -6604,9 +7167,9 @@ function postalcampaign_view_all($foss_name, $startdate, $enddate) } else { $enddate = $enddate; } - - if (strlen($foss_name) == 0 || $foss_name == "null") { - $foss_name= "%"; + + if (strlen($foss_name) == 0 || $foss_name == "null") { + $foss_name = "%"; } else { $foss_name = $foss_name; } @@ -6620,7 +7183,7 @@ function postalcampaign_view_all($foss_name, $startdate, $enddate) $rows1 = array(); $query1 = db_select('postercampaign'); $query1->fields('postercampaign'); - $query1->condition('foss_name', $foss_name,'LIKE'); + $query1->condition('foss_name', $foss_name, 'LIKE'); $query1->condition('startdate', $startdate, '>='); $query1->condition('startdate', $enddate, '<='); $query1->orderBy('startdate', 'DESC'); @@ -6629,7 +7192,7 @@ function postalcampaign_view_all($foss_name, $startdate, $enddate) $item = array( $row->p_name, $row->startdate, - + "p_id} target='_blank' title='Click to view detail'>Details" ); array_push($rows1, $item); @@ -6651,7 +7214,7 @@ function spokentutorial_display_all() function spokentutorial_add_form($form, &$form_state, $spokentutorial_id = 0, $no_js_use = FALSE) { -$query = " + $query = " SELECT * FROM spokentutorial WHERE v_id = :spokentutorial_id "; @@ -6661,9 +7224,9 @@ $query = " $result = db_query($query, $args); $row = $result->fetchObject(); $form = array(); - - - if ($spokentutorial_id == 0) { + + + if ($spokentutorial_id == 0) { $form['foss_select'] = array( '#type' => 'select', '#title' => t('Select FOSS under which event took place '), @@ -6671,24 +7234,24 @@ $query = " '#default_value' => '', "#required" => TRUE ); - + $form["count"] = array( "#type" => "textfield", "#title" => "Count of Videos :", "#default_value" => '', "#required" => TRUE ); - - $form["videolink"] = array( + + $form["videolink"] = array( "#type" => "textfield", "#title" => "Link of Video :", "#default_value" => '', "#required" => TRUE ); - - - }else{ - $form = array(); + + + } else { + $form = array(); $form['foss_select'] = array( '#type' => 'select', '#title' => t('Select FOSS under which event took place '), @@ -6702,15 +7265,15 @@ $query = " "#default_value" => $row->count, "#required" => TRUE ); - $form["videolink"] = array( + $form["videolink"] = array( "#type" => "textfield", "#title" => "Link of Video :", "#default_value" => $row->link, "#required" => TRUE ); - - - } + + + } $form["spokentutorial_id"] = array( "#type" => "hidden", "#value" => $spokentutorial_id @@ -6720,25 +7283,25 @@ $query = " "#value" => "Submit" ); return $form; - + } function spokentutorial_add_form_submit($form, &$form_state) { - $v = $form_state["values"]; - + $v = $form_state["values"]; + if ($v["spokentutorial_id"]) { - $query = db_update('spokentutorial'); + $query = db_update('spokentutorial'); $query->fields(array( 'foss_name' => $v["foss_select"], 'count' => $v["count"], - 'link' => $v["videolink"], + 'link' => $v["videolink"] )); $query->condition('v_id', $v["spokentutorial_id"]); $result = $query->execute(); - }else{ - $query = " + } else { + $query = " INSERT INTO spokentutorial (foss_name,count,link) VALUES (:foss_name,:count, :link) @@ -6747,26 +7310,26 @@ function spokentutorial_add_form_submit($form, &$form_state) ":foss_name" => $v["foss_select"], ":count" => $v["count"], ":link" => $v["videolink"] - + ); /* storing the row id in $result */ $result = db_query($query, $args, array( 'return' => Database::RETURN_INSERT_ID )); - } - - if (!$result) { - drupal_set_message("Something went wrong, please try again.", "error"); - } else { - drupal_set_message("Spoken tutorial details added successfully", "status"); - - } + } + + if (!$result) { + drupal_set_message("Something went wrong, please try again.", "error"); + } else { + drupal_set_message("Spoken tutorial details added successfully", "status"); + + } } function spokentutorial_view_all($foss_name) { - - if (strlen($foss_name) == 0 || $foss_name == "null") { - $foss_name= "%"; + + if (strlen($foss_name) == 0 || $foss_name == "null") { + $foss_name = "%"; } else { $foss_name = $foss_name; } @@ -6780,12 +7343,12 @@ function spokentutorial_view_all($foss_name) $rows1 = array(); $query1 = db_select('spokentutorial'); $query1->fields('spokentutorial'); - $query1->condition('foss_name', $foss_name,'LIKE'); + $query1->condition('foss_name', $foss_name, 'LIKE'); $result1 = $query1->execute(); while ($row = $result1->fetchObject()) { $item = array( $row->foss_name, - "". $row->count."", + "" . $row->count . "" ); array_push($rows1, $item); } @@ -6793,13 +7356,264 @@ function spokentutorial_view_all($foss_name) return $page_content; } +function generate_pdf($workshop_id = 0) +{ + + // Include the main TCPDF library (search for installation path). + require_once('tcpdf_include.php'); + + + // Extend the TCPDF class to create custom Header and Footer + class MYPDF extends TCPDF + { + + //Page header + /*public function Header() { + // Logo + $image_file = K_PATH_IMAGES."fosseelogo.png"; + $this->Image($image_file, 10, 10, 25, 0, 'PNG', 'http://fossee.in'); + // Set font + $this->SetFont('helvetica', 'B', 20); + // Title + //$this->Cell(0, 15, '', 0, false, 'C', 0, '', 0, false, 'M', 'M'); + }*/ + + // Page footer + public function Footer() + { + // Position at 15 mm from bottom + + $this->SetY(-15); + // Set font + $this->SetFont('helvetica', 'I', 8); + // Page number + + $this->Cell(0, 10, 'Page ' . $this->getAliasNumPage() . '/' . $this->getAliasNbPages(), 0, false, 'R', 0, '', 0, false, 'T', 'M'); + + $html = 'http://fossee.in'; + $this->writeHTML($html, true, false, true, false, ''); + } + } + + + + // create new PDF document + $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); + + // set document information + $pdf->SetCreator(PDF_CREATOR); + + $pdf->SetTitle('Free and Open Software in Education'); + + // set default header data + $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, "", ""); + + // set header and footer fonts + $pdf->setHeaderFont(Array( + PDF_FONT_NAME_MAIN, + '', + PDF_FONT_SIZE_MAIN + )); + $pdf->setFooterFont(Array( + PDF_FONT_NAME_DATA, + '', + PDF_FONT_SIZE_DATA + )); + + // set default monospaced font + $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); + + // set margins + $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); + $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); + $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); + + // set auto page breaks + $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); + + // set image scale factor + $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); + + // set some language-dependent strings (optional) + if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) { + require_once(dirname(__FILE__) . '/lang/eng.php'); + $pdf->setLanguageArray($l); + } + + // --------------------------------------------------------- + + + // add a page + $pdf->AddPage(); + + $page_content = "

    Event Detail :


    "; + $page_content .= '
    '; + $row = ""; + $row1 = ""; + $query = db_select('workshop'); + $query->fields('workshop'); + $query->condition('w_id', $workshop_id); + $result = $query->execute(); + $row = $result->fetchObject(); + $speakerquery = db_select('speakers'); + $speakerquery->fields('speakers'); + $speakerquery->condition('w_id', $workshop_id); + $speakerresult = $speakerquery->execute(); + $num_of_speakercount = $speakerresult->rowCount(); + if ($num_of_speakercount != 0) { + $textdisplay = ""; + $counter = 1; + while ($speakerrow = $speakerresult->fetchObject()) { + $var = $counter++; + $textdisplay .= "" . $var . ". " . $speakerrow->name . " " . $speakerrow->institute . ", " . $speakerrow->place . "
    "; + } + } + + + $startdate = $row->startdate; + $enddate = $row->enddate; + $date = $row->startdate . " , " . $row->enddate; + + $daylen = 60 * 60 * 24; + $date1 = $row->enddate; + $date2 = $row->startdate; + + $dayCount = ((strtotime($date1) - strtotime($date2)) / $daylen) + 1; + + $page_content .= ''; + $page_content .= ' + + + + + + + + + '; + + if ($num_of_speakercount != 0) { + $page_content .= ''; + } + + $page_content .= ''; + + if (trim(strlen($row->event_link)) != 0) { + $page_content .= ''; + } + $page_content .= '
    Name' . $row->w_name . '
    Start Date' . $startdate . '
    End Date' . $enddate . '
    No. of Participants' . $row->no_of_participant . '
    Venue' . $row->venue . '
    Speakers' . $textdisplay . '
    Details' . $row->body . '
    Event website' . $row->event_link . '
    '; + + /* For adding images to PDF*/ + + $query = db_select('workshop_images'); + $query->fields('workshop_images'); + $query->condition('w_id', $workshop_id); + $result = $query->execute(); + $num_of_results = $result->rowCount(); + if ($num_of_results != 0) { + $i = 0; + $page_content .= "

    Pictures

    "; + $page_content .= ''; + while ($row1 = $result->fetchObject()) { + $i++; + + + if (($i % 2) == 0) { + $page = '"' . $GLOBALS['base_url'] . "/events_images/" . str_replace(' ', '_', $row->w_name) . "/" . $row1->name . '"'; + $page_content .= ''; + + $page_content .= ""; + + } else { + $page = '"' . $GLOBALS['base_url'] . "/events_images/" . str_replace(' ', '_', $row->w_name) . "/" . $row1->name . '"'; + $page_content .= ''; + + } + + } + + $page_content .= "
    "; + + } + + /* For adding Testimonial to the PDF*/ + + $testimonial_query = db_select('testimonials'); + $testimonial_query->fields('testimonials'); + $testimonial_query->condition('w_id', $workshop_id); + $testimonial_query->orderBy('t_id', 'ASC'); + $testimonial_result = $testimonial_query->execute(); + $testimonial_of_results = $testimonial_result->rowCount(); + + if ($testimonial_of_results != 0) { + $counter = 0; + $page_content .= "

    Testimonials

    "; + $page_content .= ''; + } + + + /* For adding videolinks to pdf*/ + + $videolink_query = db_select('workshop_videolinks'); + $videolink_query->fields('workshop_videolinks'); + $videolink_query->condition('w_id', $workshop_id); + $videolink_query->orderBy('v_id', 'ASC'); + $videolink_result = $videolink_query->execute(); + $videolink_of_results = $videolink_result->rowCount(); + + if ($videolink_of_results != 0) { + + $page_content .= "

    Video Links

    "; + $page_content .= ''; + } + + + $page_content .= '
    '; + + // output the HTML content + $pdf->writeHTML($page_content, true, false, true, false, ''); + + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + // reset pointer to the last page + $pdf->lastPage(); + + // --------------------------------------------------------- + + //Close and output PDF document + $pdf->Output(str_replace(' ', '_', $row->w_name) . ".pdf", 'I'); + + //============================================================+ + // END OF FILE + //============================================================+ + + +} + function fossee_stats_init() { $path = drupal_get_path('module', 'fossee_stats'); drupal_add_js($path . '/js/all_charts.js'); - // drupal_add_css(drupal_get_path("module", "fossee_stats") . "/css/fossee_stats_base.css"); - drupal_add_css(drupal_get_path("module", "fossee_stats") . "/css/bootstrap.css"); - //drupal_add_css(drupal_get_path("module", "fossee_stats") . "/css/fossee_stats_main.css"); + drupal_add_css(drupal_get_path("module", "fossee_stats") . "/css/bootstrap.css"); drupal_add_js(drupal_get_path("module", "fossee_stats") . "/js/confirm.js"); drupal_add_js(drupal_get_path("module", "fossee_stats") . "/js/testimonials_script.js"); } -- cgit