Exemple #1
0
 function fill_in_additional_detail_fields()
 {
     global $current_language, $theme;
     $mod_strings = return_module_language($current_language, "ZuckerWordTemplate");
     if (!empty($this->filename)) {
         $this->template_url = $this->get_resources_dir() . $this->filename;
         $this->extension = substr($this->filename, strrpos($this->filename, ".") + 1);
     }
     $this->action_module = $this->module_dir;
     $seed = new QueryTemplate();
     $this->querytemplate = $seed->retrieve($this->querytemplate_id);
     if (empty($this->querytemplate)) {
         $seed = new ListingTemplate();
         $this->querytemplate = $seed->retrieve($this->querytemplate_id);
     }
     if (!empty($this->querytemplate)) {
         $this->querytemplate_name = $this->querytemplate->name;
         $this->querytemplate_link = "index.php?module=" . $this->querytemplate->module_dir . "&action=DetailView&record=" . $this->querytemplate->id;
     }
     if ($this->extension == "stw" || $this->extension == "odt") {
         $this->type_desc = $mod_strings["LBL_OPENOFFICE"];
         $this->image_html = get_image("themes/" . $theme . "/images/ZuckerOpenOfficeTemplate", "alt=\"ZuckerOpenOfficeTemplate\"");
         $this->image_module = "ZuckerOpenOfficeTemplate";
     } else {
         if ($this->extension == "doc") {
             $this->type_desc = $mod_strings["LBL_WORD"];
             $this->image_html = get_image("themes/" . $theme . "/images/ZuckerWordTemplate", "alt=\"ZuckerWordTemplate\"");
             $this->image_module = "ZuckerWordTemplate";
         }
     }
     $this->assigned_user_name = get_assigned_user_name($this->assigned_user_id);
     $this->team_name = SimpleTeams::get_assigned_team_name($this);
 }
Exemple #2
0
<?php

require_once 'include/formbase.php';
require_once 'include/upload_file.php';
require_once 'modules/ZuckerQueryTemplate/QueryTemplate.php';
$template = new QueryTemplate();
if (!empty($_REQUEST['record'])) {
    $template->retrieve($_REQUEST['record']);
    $template = $template->retrieve($_REQUEST['record']);
    if ($template == null) {
        echo "no access";
        exit;
    }
}
$template = populateFromPost("", $template);
if (!$template->ACLAccess('Save')) {
    ACLController::displayNoAccess(true);
    sugar_cleanup(true);
}
$template->sql1 = $_REQUEST['sql'];
$_REQUEST['return_id'] = $template->save();
$_REQUEST['return_action'] = "DetailView";
$_REQUEST['return_module'] = "ZuckerQueryTemplate";
handleRedirect($return_id, "ZuckerQueryTemplate");
Exemple #3
0
if (empty($focus->assigned_name) && empty($focus->id)) {
    $focus->assigned_user_name = $current_user->user_name;
}
$assigned_user = get_user_array(TRUE, "Active", $focus->assigned_user_id);
asort($assigned_user);
$xtpl->assign("ASSIGNED_USER_OPTIONS", get_select_options_with_id($assigned_user, $focus->assigned_user_id));
$xtpl->assign("ASSIGNED_USER_NAME", $focus->assigned_user_name);
$xtpl->assign("ASSIGNED_USER_ID", $focus->assigned_user_id);
/// Users Popup
$popup_request_data = array('call_back_function' => 'set_return', 'form_name' => 'EditView', 'field_to_name_array' => array('id' => 'assigned_user_id', 'user_name' => 'assigned_user_name'));
$xtpl->assign('encoded_users_popup_request_data', $json->encode($popup_request_data));
require_once 'modules/ZuckerReports/SimpleTeams.php';
$xtpl->assign("TEAM_SELECTION", SimpleTeams::xtplGetTeamSelection($xtpl, $focus));
$xtpl->assign("ERROR_MSG", $_REQUEST["ZR_ERROR_MSG"]);
$qtselect = array();
$qtseed = new QueryTemplate();
$qtlist = $qtseed->get_all("name");
if (!empty($qtlist)) {
    foreach ($qtlist as $qt) {
        $qtselect[$qt->id] = $qt->name;
    }
}
$ltseed = new ListingTemplate();
$ltlist = $ltseed->get_all("name");
if (!empty($ltlist)) {
    foreach ($ltlist as $lt) {
        $qtselect[$lt->id] = $lt->name;
    }
}
asort($qtselect);
$xtpl->assign("QUERYTEMPLATE_SELECTION", get_select_options_with_id($qtselect, $querytemplate_id));
Exemple #4
0
<?php

require_once 'include/formbase.php';
require_once 'include/upload_file.php';
require_once 'modules/ZuckerQueryTemplate/QueryTemplate.php';
if (!empty($_REQUEST['record'])) {
    $template = new QueryTemplate();
    $template->retrieve($_REQUEST['record']);
    if (!$template->ACLAccess('Delete')) {
        ACLController::displayNoAccess(true);
        sugar_cleanup(true);
    }
    $template->mark_deleted($_REQUEST['record']);
}
header("Location: index.php?module=" . $_REQUEST['return_module'] . "&action=" . $_REQUEST['return_action'] . "&record=" . $_REQUEST['return_id']);
Exemple #5
0
 function execute($format = 'CSV', $parameter_values = array())
 {
     global $sugar_config, $current_user, $theme;
     $date = date("ymd_His");
     if ($format == 'CSV') {
         $this->report_result_type = "FILE";
         $this->report_result_name = $date . "_" . $this->name . ".csv";
         $this->report_result_name = strtolower(join("_", explode(" ", $this->report_result_name)));
         $this->report_result = $this->archive_dir . "/" . $this->report_result_name;
     } else {
         if ($format == 'HTML' || $format == 'SIMPLEHTML') {
             $this->report_result_type = "FILE";
             $this->report_result_name = $date . "_" . $this->name . ".html";
             $this->report_result_name = strtolower(join("_", explode(" ", $this->report_result_name)));
             $this->report_result = $this->archive_dir . "/" . $this->report_result_name;
         } else {
             $this->report_result_type = "INLINE";
         }
     }
     $seed = new QueryTemplate();
     $bean = $seed->retrieve($this->id, false);
     $sql = $bean->sql1;
     foreach ($parameter_values as $name => $value) {
         $sql = str_replace('$' . $name, '' . $value, $sql);
     }
     $sql = str_replace('$SUGAR_USER_ID', $current_user->id, $sql);
     $sql = str_replace('$SUGAR_USER_NAME', $current_user->user_name, $sql);
     $sql = str_replace('$SUGAR_SESSION_ID', $_REQUEST['PHPSESSID'], $sql);
     $this->report_output .= "Query: " . $sql . "<br/>";
     $rs =& $this->db->query($sql, false, "Error executing query: ");
     if ($rs) {
         $rows_found = $this->db->getRowCount($rs);
         $this->report_output .= "Found " . $rows_found . "<br/>";
         $this->report_output .= "Writing to " . $this->report_result . "<br/>";
         $fields = $this->db->getFieldsArray($rs);
         if ($format == "CSV") {
             $f = fopen($this->report_result, "w");
             if ($this->include_header) {
                 foreach ($fields as $field) {
                     fwrite($f, $field);
                     fwrite($f, $this->col_delim);
                 }
                 fwrite($f, $this->row_delim);
             }
             for ($row = $this->db->fetchByAssoc($rs); $row; $row = $this->db->fetchByAssoc($rs)) {
                 for ($i = 0; $i < count($fields); $i++) {
                     $field = $fields[$i];
                     $pieces = explode("\n", $row[$field]);
                     $cleaned_pieces = array();
                     foreach ($pieces as $piece) {
                         $cleaned_pieces[] = trim($piece);
                     }
                     fwrite($f, join(" ", $cleaned_pieces));
                     if ($i != count($fields) - 1) {
                         fwrite($f, $this->col_delim);
                     }
                 }
                 fwrite($f, $this->row_delim);
             }
             fclose($f);
         } else {
             if ($format == "HTML") {
                 $f = fopen($this->report_result, "w");
                 $c = file_get_contents("modules/ZuckerQueryTemplate/html/header.html");
                 $c = str_replace("{SITE_URL}", $sugar_config["site_url"], $c);
                 $c = str_replace("{THEME_URL}", $sugar_config["site_url"] . "/themes/" . $theme, $c);
                 $c = str_replace("{CHARSET}", $this->get_charset(), $c);
                 fwrite($f, $c);
                 fwrite($f, file_get_contents("modules/ZuckerQueryTemplate/html/table_header.html"));
                 if ($this->include_header) {
                     fwrite($f, file_get_contents("modules/ZuckerQueryTemplate/html/table_header_row_start.html"));
                     foreach ($fields as $field) {
                         $c = file_get_contents("modules/ZuckerQueryTemplate/html/table_header_col.html");
                         $c = str_replace('{VALUE}', $field, $c);
                         fwrite($f, $c);
                     }
                     fwrite($f, file_get_contents("modules/ZuckerQueryTemplate/html/table_header_row_end.html"));
                 }
                 $ext = "1";
                 for ($row = $this->db->fetchByAssoc($rs); $row; $row = $this->db->fetchByAssoc($rs)) {
                     fwrite($f, file_get_contents("modules/ZuckerQueryTemplate/html/table_row_start.html"));
                     foreach ($fields as $field) {
                         if (empty($row[$field])) {
                             $value = "&nbsp;";
                         } else {
                             $value = $this->format_value_for_html($row[$field]);
                         }
                         $c = file_get_contents("modules/ZuckerQueryTemplate/html/table_row_col" . $ext . ".html");
                         $c = str_replace('{VALUE}', $value, $c);
                         fwrite($f, $c);
                     }
                     fwrite($f, file_get_contents("modules/ZuckerQueryTemplate/html/table_row_end.html"));
                     if ($ext == "1") {
                         $ext = "2";
                     } else {
                         $ext = "1";
                     }
                 }
                 fwrite($f, file_get_contents("modules/ZuckerQueryTemplate/html/table_footer.html"));
                 fwrite($f, file_get_contents("modules/ZuckerQueryTemplate/html/footer.html"));
                 fclose($f);
             } else {
                 if ($format == "SIMPLEHTML") {
                     $f = fopen($this->report_result, "w");
                     fwrite($f, "<!DOCTYPE html PUBLIC \"-//W3C//DTD html 4.01 Transitional//" . $this->get_charset() . "\">\n");
                     fwrite($f, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=" . $this->get_charset() . "\"></head>");
                     fwrite($f, "<body><table border=\"1\">");
                     if ($this->include_header) {
                         fwrite($f, "\n<tr>");
                         foreach ($fields as $field) {
                             fwrite($f, "<th>" . $field . "</th>");
                         }
                         fwrite($f, "</tr>");
                     }
                     for ($row = $this->db->fetchByAssoc($rs); $row; $row = $this->db->fetchByAssoc($rs)) {
                         fwrite($f, "\n<tr>");
                         foreach ($fields as $field) {
                             if (empty($row[$field])) {
                                 fwrite($f, "<td>&nbsp;</td>");
                             } else {
                                 fwrite($f, "<td>" . $this->format_value_for_html($row[$field]) . "</td>");
                             }
                         }
                         fwrite($f, "</tr>");
                     }
                     fwrite($f, "\n</table></body></html>");
                     fclose($f);
                 } else {
                     $this->report_result = file_get_contents("modules/ZuckerQueryTemplate/html/table_header.html");
                     if ($this->include_header) {
                         $this->report_result .= file_get_contents("modules/ZuckerQueryTemplate/html/table_header_row_start.html");
                         foreach ($fields as $field) {
                             $c = file_get_contents("modules/ZuckerQueryTemplate/html/table_header_col.html");
                             $c = str_replace('{VALUE}', $field, $c);
                             $this->report_result .= $c;
                         }
                         $this->report_result .= file_get_contents("modules/ZuckerQueryTemplate/html/table_header_row_end.html");
                     }
                     $ext = "1";
                     for ($row = $this->db->fetchByAssoc($rs); $row; $row = $this->db->fetchByAssoc($rs)) {
                         $this->report_result .= file_get_contents("modules/ZuckerQueryTemplate/html/table_row_start.html");
                         foreach ($fields as $field) {
                             if (empty($row[$field])) {
                                 $value = "&nbsp;";
                             } else {
                                 $value = $this->format_value_for_html($row[$field]);
                             }
                             $c = file_get_contents("modules/ZuckerQueryTemplate/html/table_row_col" . $ext . ".html");
                             $c = str_replace('{VALUE}', $value, $c);
                             $this->report_result .= $c;
                         }
                         $this->report_result .= file_get_contents("modules/ZuckerQueryTemplate/html/table_row_end.html");
                         if ($ext == "1") {
                             $ext = "2";
                         } else {
                             $ext = "1";
                         }
                     }
                     $this->report_result .= file_get_contents("modules/ZuckerQueryTemplate/html/table_footer.html");
                 }
             }
         }
         $result = true;
     } else {
         $result = false;
         if ($this->db->dbType == "mysql") {
             $this->report_output .= "MySQL error " . mysql_errno() . ": " . mysql_error() . "<br/>";
         } else {
             $this->report_output .= $this->database->getMessage() . "<br/>";
         }
     }
     return $result;
 }