function display() { $db = DBManagerFactory::getInstance(); /* <<<<<<< HEAD $sql = "SELECT p.id,p.first_name,p.last_name,p.dob FROM reg_patient p WHERE p.id not in (SELECT distinct pe.reg_patient_reg_encounterreg_patient_ida FROM `reg_patient_reg_encounter_c` pe, reg_encounter_cstm e WHERE pe.reg_patient_reg_encounterreg_encounter_idb=e.id_c AND e.next_pmp_review_due_c is not null) ORDER By p.last_name, p.first_name"; ======= */ $sql = "SELECT p.id,p.first_name,p.last_name,p.dob, rec.mrn_c AS mrn,(SELECT p1b.name provname FROM reg_provider p1b,reg_provider_reg_patient_c p2b WHERE p2b.reg_provider_reg_patientreg_provider_ida = p1b.id AND p2b.reg_provider_reg_patientreg_patient_idb = p.id AND p2b.deleted =0)provname FROM reg_patient p LEFT JOIN reg_patient_cstm rec ON rec.id_c = p.id WHERE p.id not in (SELECT distinct pe.reg_patient_reg_encounterreg_patient_ida FROM `reg_patient_reg_encounter_c` pe, reg_encounter_cstm e WHERE pe.reg_patient_reg_encounterreg_encounter_idb=e.id_c AND e.last_pmp_review_done_c is not null) ORDER By p.last_name, p.first_name"; // >>>>>>> 3097a71433de82fec730df252659026274347e46 $resultb = $db->query($sql, true); $final = array(); while ($row = $db->fetchByAssoc($resultb)) { $final[] = $row; } $sql1 = "SELECT p.id, rec.mrn_c AS mrn,(SELECT p1b.name provname FROM reg_provider p1b,reg_provider_reg_patient_c p2b WHERE p2b.reg_provider_reg_patientreg_provider_ida = p1b.id AND p2b.reg_provider_reg_patientreg_patient_idb = p.id AND p2b.deleted =0)provname FROM reg_patient p LEFT JOIN reg_patient_cstm rec ON rec.id_c = p.id WHERE p.id not in (SELECT distinct pe.reg_patient_reg_encounterreg_patient_ida FROM `reg_patient_reg_encounter_c` pe, reg_encounter_cstm e WHERE pe.reg_patient_reg_encounterreg_encounter_idb=e.id_c AND e.last_pmp_review_done_c is not null) GROUP BY provname ORDER By p.last_name, p.first_name"; $resultb1 = $db->query($sql1, true); $final1 = array(); while ($row1 = $db->fetchByAssoc($resultb1)) { $final1[] = $row1; } $sugarSmarty = new Sugar_Smarty(); $sugarSmarty->assign("data", $final); $sugarSmarty->assign("data1", $final1); $sugarSmarty->assign("title", "Patients who do not have PMP"); $sugarSmarty->display('custom/modules/REG_Patient/tpls/Report1REG_Patient.tpl'); // parent::display(); }
/** * This methods schedules the Jobs * * @param int $perJob * @return array|mixed */ public static function scheduleRevenueLineItemUpdateJobs($perJob = 100) { /* @var $db DBManager */ $db = DBManagerFactory::getInstance(); // get all the opps to break into groups of 100 and go newest to oldest $sql = "select id from revenue_line_items where deleted = 0 ORDER BY date_modified DESC;"; $results = $db->query($sql); $jobs = array(); $toProcess = array(); while ($row = $db->fetchRow($results)) { $toProcess[] = $row['id']; if (count($toProcess) == $perJob) { $jobs[] = static::createJob($toProcess); $toProcess = array(); } } if (!empty($toProcess)) { $jobs[] = static::createJob($toProcess); } // if only one job was created, just return that id if (count($jobs) == 1) { return array_shift($jobs); } return $jobs; }
function display() { $focus = new AirlinesTicketsLists(); $ss = new Sugar_Smarty(); $db = DBManagerFactory::getInstance(); // ONLY LOAD A RECORD IF A RECORD ID IS GIVEN; // A RECORD ID IS NOT GIVEN WHEN VIEWING IN LAYOUT EDITOR $record = isset($_GET["record"]) ? htmlspecialchars($_GET["record"]) : ''; $template = file_get_contents('modules/AirlinesTicketsLists/tpls/export.tpl'); $sql = "Select * From AirlinesTicketsLists p Where p.id = '" . $record . "' And p.deleted = 0"; $result = $db->query($sql); $row = $db->fetchByAssoc($result); $fromitinerary = ""; $itinerary = ""; $time = ""; $itinerary2 = ""; $time2 = ""; $template = str_replace("{FIT_RECORE}", $focus->get_AirlinesTickets_list($record, $fromitinerary, $itinerary, $time, $itinerary2, $time2), $template); $template = str_replace("{TITLE}", $row['name'], $template); $template = str_replace("{FROM}", $fromitinerary, $template); $template = str_replace("{CHUYENBAY1}", $itinerary, $template); $template = str_replace("{TIME1}", $time, $template); $template = str_replace("{CHUYENBAY2}", $itinerary2, $template); $template = str_replace("{TIME2}", $time2, $template); $size = strlen($template); $filename = "DANH_SACH_DOAN_" . strtoupper($row['code']) . ".doc"; ob_end_clean(); header("Cache-Control: private"); header("Content-Type: application/force-download;"); header("Content-Disposition:attachment; filename=\"{$filename}\""); header("Content-length:{$size}"); echo $template; ob_flush(); }
function start() { $this->db = DBManagerFactory::getInstance(); $this->userDemoData = new UserDemoData($this->user, false); $this->trackerManager = TrackerManager::getInstance(); foreach ($this->modules as $mod) { $query = "select id from {$mod}"; $result = $this->db->limitQuery($query, 0, 50); $ids = array(); while ($row = $this->db->fetchByAssoc($result)) { $ids[] = $row['id']; } //while $this->beanIdMap[$mod] = $ids; } while ($this->monitorIds-- > 0) { $this->monitorId = create_guid(); $this->trackerManager->setMonitorId($this->monitorId); $this->user = $this->userDemoData->guids[array_rand($this->userDemoData->guids)]; $this->module = $this->modules[array_rand($this->modules)]; $this->action = $this->actions[array_rand($this->actions)]; $this->date = $this->randomTimestamp(); $this->populate_tracker(); $this->populate_tracker_perf(); $this->populate_tracker_sessions(); $this->populate_tracker_queries(); $this->trackerManager->save(); } }
/** * Commit a manager forecast from the draft records * * @param User $manager * @param string $timeperiod * @return bool */ public function commitManagerForecast(User $manager, $timeperiod) { global $current_user; // make sure that the User passed in is actually a manager if (!User::isManager($manager->id)) { return false; } /* @var $db DBManager */ $db = DBManagerFactory::getInstance(); $sql = 'SELECT name, assigned_user_id, team_id, team_set_id, quota, best_case, best_case_adjusted, likely_case, likely_case_adjusted, worst_case, worst_case_adjusted, currency_id, base_rate, timeperiod_id, user_id, opp_count, pipeline_opp_count, pipeline_amount, closed_amount ' . 'FROM ' . $this->table_name . ' ' . 'WHERE assigned_user_id = ' . $db->quoted($manager->id) . ' AND user_id != ' . $db->quoted($manager->id) . ' ' . 'AND timeperiod_id = ' . $db->quoted($timeperiod) . ' AND draft = 1 AND deleted = 0 ' . 'UNION ALL ' . 'SELECT name, assigned_user_id, team_id, team_set_id, quota, best_case, best_case_adjusted, likely_case, likely_case_adjusted, worst_case, worst_case_adjusted, currency_id, base_rate, timeperiod_id, user_id, opp_count, pipeline_opp_count, pipeline_amount, closed_amount ' . 'FROM ' . $this->table_name . ' ' . 'WHERE assigned_user_id = ' . $db->quoted($manager->id) . ' AND user_id = ' . $db->quoted($manager->id) . ' ' . 'AND timeperiod_id = ' . $db->quoted($timeperiod) . ' AND draft = 1 AND deleted = 0'; $results = $db->query($sql); $this->fixTopLevelManagerQuotaRollup($manager->id, $timeperiod); while ($row = $db->fetchByAssoc($results)) { /* @var $worksheet ForecastManagerWorksheet */ $worksheet = BeanFactory::getBean('ForecastManagerWorksheets'); $worksheet->retrieve_by_string_fields(array('user_id' => $row['user_id'], 'assigned_user_id' => $row['assigned_user_id'], 'timeperiod_id' => $row['timeperiod_id'], 'draft' => 0, 'deleted' => 0)); foreach ($row as $key => $value) { $worksheet->{$key} = $value; } $worksheet->draft = 0; // make sure this is always 0! $worksheet->save(); $type = $worksheet->user_id == $current_user->id ? 'Direct' : 'Rollup'; $disableAS = $worksheet->user_id == $current_user->id; $this->_assignQuota($worksheet->quota, $type, $worksheet->user_id, $timeperiod, $disableAS); } return true; }
/** * Add visibility clauses to the WHERE part of the query * @param string $query * @return string */ public function addVisibilityWhere(&$query) { global $current_user; if (!empty($this->targetModuleField) && !$current_user->isAdmin()) { $table_alias = $this->getOption('table_alias'); $db = DBManagerFactory::getInstance(); if (empty($table_alias)) { $table_alias = $this->bean->table_name; } $modules = array_map(function ($value) use($db) { return $db->quoted($value); }, $current_user->getDeveloperModules()); if (empty($modules)) { $devWhere = "{$table_alias}.{$this->targetModuleField} IS NULL"; } else { $devWhere = "{$table_alias}.{$this->targetModuleField} IN (" . implode(',', $modules) . ")"; } if (!empty($query)) { $query .= " AND {$devWhere}"; } else { $query = $devWhere; } } return $query; }
function display() { global $sugar_config, $timedate; $focus = new GroupLists(); $ss = new Sugar_Smarty(); $db = DBManagerFactory::getInstance(); // ONLY LOAD A RECORD IF A RECORD ID IS GIVEN; // A RECORD ID IS NOT GIVEN WHEN VIEWING IN LAYOUT EDITOR $record = isset($_GET["record"]) ? htmlspecialchars($_GET["record"]) : ''; $template = file_get_contents('modules/GroupLists/tpls/Export.tpl'); $sql = "SELECT\r\n g.groupprogram_code\r\n ,g.tour_name\r\n ,g.end_date_group\r\n ,g.start_date_group\r\n FROM\r\n groupprograms g INNER JOIN grouplists_roupprograms_c ggr ON g.id = ggr.grouplistsf242rograms_idb \r\n INNER JOIN grouplists gl ON gl.id = ggr.grouplists87eduplists_ida \r\n WHERE gl.deleted = 0 AND ggr.deleted = 0 AND g.deleted = 0 AND ggr.grouplists87eduplists_ida = '" . $record . "'"; $result = $db->query($sql); $row = $db->fetchByAssoc($result); $template = str_replace("{TOURNAME}", mb_strtoupper($row['tour_name'], 'utf-8'), $template); $template = str_replace("{SITE_URL}", $sugar_config['site_url'], $template); $template = str_replace("{CODE}", $row['groupprogram_code'], $template); $template = str_replace("{START_DATE}", $timedate->to_display_date($row['start_date_group'], true), $template); $template = str_replace("{END_DATE}", $timedate->to_display_date($row['end_date_group'], true), $template); $template = str_replace("{SOLUONG}", $focus->get_count($record), $template); $template = str_replace("{TEL}", '', $template); $template = str_replace("{FAX}", '', $template); //$template = str_replace("{LIST_GIT}", $focus->get_GIT_to_report("('".$record."')"),$template); $template = str_replace("{LIST_FIT}", $focus->get_customer_list("('" . $record . "')"), $template); $template = str_replace("{DATE}", date('d/m/Y'), $template); $size = strlen($template); $filename = "DS Doan " . mb_strtoupper($row['tour_name'], 'utf-8') . ".doc"; ob_end_clean(); header("Cache-Control: private"); header("Content-Type: application/force-download;"); header("Content-Disposition:attachment; filename=\"{$filename}\""); header("Content-length:{$size}"); echo $template; ob_flush(); }
public function setUp() { $this->_db = DBManagerFactory::getInstance(); if (get_class($this->_db) != 'FreeTDSManager') { $this->markTestSkipped("Skipping test if not mssql configuration"); } }
function add_prospects_to_prospect_list($query, $parent_module, $parent_type, $parent_id, $child_id, $link_attribute, $link_type) { $GLOBALS['log']->debug('add_prospects_to_prospect_list:parameters:' . $query); $GLOBALS['log']->debug('add_prospects_to_prospect_list:parameters:' . $parent_module); $GLOBALS['log']->debug('add_prospects_to_prospect_list:parameters:' . $parent_type); $GLOBALS['log']->debug('add_prospects_to_prospect_list:parameters:' . $parent_id); $GLOBALS['log']->debug('add_prospects_to_prospect_list:parameters:' . $child_id); $GLOBALS['log']->debug('add_prospects_to_prospect_list:parameters:' . $link_attribute); $GLOBALS['log']->debug('add_prospects_to_prospect_list:parameters:' . $link_type); if (!class_exists($parent_type)) { require_once 'modules/' . $parent_module . '/' . $parent_type . '.php'; } $focus = new $parent_type(); $focus->retrieve($parent_id); //if link_type is default then load relationship once and add all the child ids. $relationship_attribute = $link_attribute; //find all prospects based on the query $db = DBManagerFactory::getInstance(); $result = $db->query($query); while (($row = $db->fetchByAssoc($result)) != null) { $GLOBALS['log']->debug('target_id' . $row[$child_id]); if ($link_type != 'default') { $relationship_attribute = strtolower($row[$link_attribute]); } $GLOBALS['log']->debug('add_prospects_to_prospect_list:relationship_attribute:' . $relationship_attribute); //load relationship for the first time or on change of relationship atribute. if (empty($focus->{$relationship_attribute})) { $focus->load_relationship($relationship_attribute); } //add $focus->{$relationship_attribute}->add($row[$child_id]); } }
function snippet() { /* get sort order from session */ //session_start(); // Make a reference to the current session object,set order //$_SESSION['regnamesort']= 'test' ; Set a value in a session variable //$GLOBALS['log']->fatal('start display'); //var_dump($this->bean); $smarty = new Sugar_Smarty(); //parent::display(); $db = DBManagerFactory::getInstance(); $myquery = "SELECT tab4a.first_name fname, tab4a.last_name lname, tab5a.mrn_c mrn, tab4a.gender gender FROM reg_patient tab4a , reg_patient_cstm tab5a WHERE tab4a.id = tab5a.id_c AND tab4a.id = '" . $_REQUEST['patid'] . "'"; $result = $db->query($myquery); $patdata = null; $row = $db->fetchRow($result); $smarty->assign("patdata", $row); $risk = new RiskEvaluation(); //when week filter need to add week interval //get patient risk if exists //if ($_POST['mysort'] == 'week') if (!empty($_REQUEST['patid'])) { $risk->getRisk($_REQUEST['patid']); $smarty->assign("pid", $_REQUEST['patid']); } //echo 'request'.$_REQUEST['patid']; //else return false; //param not found //var_dump($risk); $smarty->assign("myrisk", $risk); global $current_user; $smarty->assign("myuser", $current_user); $smarty->assign("test", "test"); return $smarty->fetch('custom/modules/REG_Patient/tpls/RiskEvaluationREG_Patient.tpl'); }
function zuckerreports_query($session, $sql) { global $current_user; $util = new SugarWebServiceUtilv4_1(); if (!$util->validate_authenticated($session)) { return array('result' => 'error', 'message' => 'ZuckerReports Query invalid session'); } $admin = new Administration(); $admin->retrieveSettings(); $sugaruser = $admin->settings['zuckerreports2_ondemandsugaruser']; if ($current_user->user_name != $sugaruser) { return array('result' => 'error', 'message' => 'ZuckerReports Query invalid user (' . $current_user->user_name . ')'); } $db = DBManagerFactory::getInstance(); $result = $db->query($sql); $row_list = array(); $colnames_list = array(); while (($row = $db->fetchByAssoc($result)) != null) { if (empty($colnames_list)) { foreach ($row as $colname => $colval) { $colnames_list[] = $colname; } } $json_row = array(); foreach ($row as $colname => $colval) { $json_row[] = $colval; } $row_list[] = $json_row; } return array('result' => 'ok', 'columnnames_list' => $colnames_list, 'rows_list' => $row_list); }
function display() { $focus = new Insurances(); $ss = new Sugar_Smarty(); $db = DBManagerFactory::getInstance(); // ONLY LOAD A RECORD IF A RECORD ID IS GIVEN; // A RECORD ID IS NOT GIVEN WHEN VIEWING IN LAYOUT EDITOR $record = isset($_GET["record"]) ? htmlspecialchars($_GET["record"]) : ''; $template = file_get_contents('modules/Insurances/tpls/export.tpl'); $name = ""; $start = ""; $end = ""; $canhan = ""; $giadinh = ""; $canhan = $focus->get_data_insurances_canhan($record, $name, $start, $end); $giadinh = $focus->get_data_insurances_giadinh($record, $name, $start, $end); $template = str_replace("{CANHAN}", $canhan, $template); $template = str_replace("{GIADINH}", $giadinh, $template); $template = str_replace("{TITLE}", $name, $template); $template = str_replace("{NGAYBATDAU}", $start, $template); $template = str_replace("{NGAYKETTHUC}", $end, $template); $size = strlen($template); $filename = strtoupper($name) . ".doc"; ob_end_clean(); header("Cache-Control: private"); header("Content-Type: application/force-download;"); header("Content-Disposition:attachment; filename=\"{$filename}\""); header("Content-length:{$size}"); echo $template; ob_flush(); }
/** * Find custom address fields added to default modules (ones that show up in the field_meta_data table) * and upgrade them */ public function upgradeFieldsMetaDataTable() { //Get unupgraded address_street fields (fields whose names follow the pattern %_street_c) $query = "SELECT id FROM fields_meta_data WHERE type <> 'text' AND deleted = 0 AND name LIKE '%_street_c'"; $db = DBManagerFactory::getInstance(); $result = $db->query($query); $updatedStreets = array(); while ($street = $db->fetchByAssoc($result, false)) { //Search for a matching city row to add robustness (in case the user created a field named like %_street_c //that isn't actually a street address field) $uniqueNameIdx = strpos($street['id'], '_street_c'); $uniqueName = substr($street['id'], 0, $uniqueNameIdx); $cityName = $db->quoted($uniqueName . '_city_c'); $query = "SELECT id FROM fields_meta_data WHERE deleted = 0 AND id = {$cityName}"; $result2 = $db->query($query); $city = $db->fetchByAssoc($result2, false); if ($city) { $updatedStreets[] = $db->quoted($street['id']); } } $updatedStreets = implode(',', $updatedStreets); if (!empty($updatedStreets)) { $query = "UPDATE fields_meta_data SET type = 'text', ext3 = 'varchar' WHERE id IN ({$updatedStreets})"; $db->query($query); } }
/** * sole constructor */ function CurrencyService() { global $sugar_config; if (!class_exists('DBManagerFactory')) { } $this->db =& DBManagerFactory::getInstance(); }
function display() { $focus = new PassportList(); $ss = new Sugar_Smarty(); $db = DBManagerFactory::getInstance(); // ONLY LOAD A RECORD IF A RECORD ID IS GIVEN; // A RECORD ID IS NOT GIVEN WHEN VIEWING IN LAYOUT EDITOR $record = isset($_GET["record"]) ? htmlspecialchars($_GET["record"]) : ''; $template = file_get_contents('modules/PassportList/tpls/export.tpl'); $sql = "Select p.name,gp.start_date_group,gp.end_date_group,p.code From passportlist p, groupprograpassportlist_c gpc,groupprograms gp Where p.id = '" . $record . "' And p.id = gpc.groupprogrc66dortlist_idb And gp.id = groupprogr20c9rograms_ida And p.deleted = 0 And gpc.deleted = 0 And gp.deleted = 0"; $result = $db->query($sql); $row = $db->fetchByAssoc($result); $template = str_replace("{FIT_RECORE}", $focus->get_passports_list($record), $template); $template = str_replace("{TITLE}", $row['name'], $template); $template = str_replace("{NGAYBATDAU}", $row['start_date_group'], $template); $template = str_replace("{NGAYKETTHUC}", $row['end_date_group'], $template); $size = strlen($template); $filename = "DANH_SACH_DOAN_" . strtoupper($row['code']) . ".doc"; ob_end_clean(); header("Cache-Control: private"); header("Content-Type: application/force-download;"); header("Content-Disposition:attachment; filename=\"{$filename}\""); header("Content-length:{$size}"); echo $template; ob_flush(); }
/** * BreadCrumbStack * Constructor for BreadCrumbStack that builds list of breadcrumbs using tracker table * * @param $user_id String value of user id to get bread crumb items for * @param $modules mixed value of module name(s) to provide extra filtering */ public function __construct($user_id, $modules = '') { $this->stack = array(); $this->stackMap = array(); $admin = new Administration(); $admin->retrieveSettings('tracker'); $this->deleteInvisible = !empty($admin->settings['tracker_Tracker']); $db = DBManagerFactory::getInstance(); $module_query = ''; if (!empty($modules)) { $history_max_viewed = 10; $module_query = is_array($modules) ? ' AND module_name IN (\'' . implode("','", $modules) . '\')' : ' AND module_name = \'' . $modules . '\''; } else { $history_max_viewed = !empty($GLOBALS['sugar_config']['history_max_viewed']) ? $GLOBALS['sugar_config']['history_max_viewed'] : 50; } $query = 'SELECT distinct item_id AS item_id, id, item_summary, module_name, monitor_id, date_modified FROM tracker WHERE user_id = \'' . $user_id . '\' AND deleted = 0 AND visible = 1 ' . $module_query . ' ORDER BY date_modified DESC'; $result = $db->limitQuery($query, 0, $history_max_viewed); $items = array(); while ($row = $db->fetchByAssoc($result)) { $items[] = $row; } $items = array_reverse($items); foreach ($items as $item) { $this->push($item); } }
function display() { $tour = new Tour(); global $sugar_config; // $ss = new Sugar_Smarty(); $db = DBManagerFactory::getInstance(); // ONLY LOAD A RECORD IF A RECORD ID IS GIVEN; // A RECORD ID IS NOT GIVEN WHEN VIEWING IN LAYOUT EDITOR $record = isset($_GET["record"]) ? htmlspecialchars($_GET["record"]) : ''; $tour->retrieve($record); $template = file_get_contents('modules/Tours/tpls/exports/template-dos.htm'); $template = str_replace('${SITE_URL}', $sugar_config['site_url'], $template); $template = str_replace('${TOUR_NOTE}', html_entity_decode_utf8($tour->description), $template); $template = str_replace('${CODE}', $tour->tour_code, $template); $template = str_replace('${NAME}', $tour->name, $template); $template = str_replace('${TRANSPORT}', $tour->transport2, $template); $template = str_replace('${START_DATE}', $tour->start_date, $template); $template = str_replace('${DURATION}', $tour->duration, $template); // Hieu fix issue 1438 if ($tour->picture) { $main_picture = ' <!--[if gte vml 1]> <o:wrapblock> <v:shape id="Picture_x0020_11" o:spid="_x0000_s1028" type="#_x0000_t75" alt="" style=\'position:absolute;margin-left:0;margin-top:0;width:470.55pt;height:234pt; z-index:251657216;visibility:visible;mso-wrap-style:square; mso-width-percent:0;mso-height-percent:0;mso-wrap-distance-left:9pt; mso-wrap-distance-top:0;mso-wrap-distance-right:9pt; mso-wrap-distance-bottom:0;mso-position-horizontal:center; mso-position-horizontal-relative:margin;mso-position-vertical:absolute; mso-position-vertical-relative:text;mso-width-percent:0;mso-height-percent:0; mso-width-relative:page;mso-height-relative:page\'> <v:imagedata src="' . $sugar_config['site_url'] . "/modules/images/" . $tour->picture . '" o:title="phan%20thiet%20beach"/> <o:lock v:ext="edit" aspectratio="f"/> <w:wrap type="topAndBottom" anchorx="margin"/> </v:shape><![endif]--><![if !vml]><img width=627 height=312 src="' . $sugar_config['site_url'] . "/modules/images/" . $tour->picture . '" alt="" v:shapes="Picture_x0020_11"><![endif]><!--[if gte vml 1]></o:wrapblock> <![endif]--> '; } else { $main_picture = ''; } $template = str_replace('${PICTURE}', $main_picture, $template); // End issue 1438 $template = str_replace('${TOUR_PROGRAM_LINES}', html_entity_decode_utf8($tour->get_data_to_expor2word()), $template); $size = strlen($template); $filename = "TOUR_PROGRAM_" . $tour->name . ".doc"; ob_end_clean(); header("Cache-Control: private"); header("Content-Type: application/force-download;"); header("Content-Disposition:attachment; filename=\"{$filename}\""); header("Content-length:{$size}"); echo $template; ob_flush(); }
function GetProviders() { global $current_user; $db = DBManagerFactory::getInstance(); $locations = ""; $sql = ""; $providers = ""; if (isset($current_user) and $current_user->check_role_membership('PRESCRIBER_ONLY')) { $sql = "SELECT prov.name provname, prov.id provid FROM users_reg_provider_1_c provlink, reg_provider prov where prov.id = provlink.users_reg_provider_1reg_provider_idb\n\t\t\tAND users_reg_provider_1users_ida = '" . $current_user->id . "'"; } if (isset($current_user) and $current_user->check_role_membership('MULTI_LOCATION')) { $locations = GetLocations(); $sql = "SELECT prov.name provname, prov.id provid FROM reg_provider prov, reg_provider_cstm cstm where cstm.id_c = prov.id\n\t\t AND cstm.provider_location_c IN ({$locations})"; } if ($sql == "") { return "''"; } $sql = $db->query($sql); while (($a = $db->fetchByAssoc($sql)) != null) { //echo "<p>". $a["provname"] . "</p>"; if ($providers == "") { $providers = "'" . $a["provid"] . "'"; } else { $providers = "'" . $a["provid"] . "'," . $providers; } } //echo "list of providers: " . $providers; return $providers; }
/** * This method implements the run function of RunnableSchedulerJob and handles processing a SchedulersJob * * @param Mixed $data parameter passed in from the job_queue.data column when a SchedulerJob is run * @return bool true on success, false on error */ public function run($data) { $data = unserialize($data); if (!is_array($data)) { // data must be array of arrays $this->job->failJob('invalid query data'); return false; } /* @var $db DBManager */ $db = DBManagerFactory::getInstance(); foreach ($data as $query) { if (!is_string($query) || empty($query)) { // bad format? we're done $this->job->failJob('invalid query: ' . $query); return false; } $result = $db->query($query); if (!$result) { $this->job->failJob('query failed: ' . $query); return false; } } $this->job->succeedJob(); return true; }
function __construct() { parent::__construct(); $this->db = DBManagerFactory::getInstance(); $this->dbManager = DBManagerFactory::getInstance(); $this->disable_row_level_security = true; }
function query_opportunity_subject_exists($subj) { $db = DBManagerFactory::getInstance(); $subject = $db->quoted($subj); $query = "select count(id) from opportunities where name = {$subject} and deleted = 0"; return $db->getOne($query) > 0; }
function display() { global $sugar_config; $focus = new AirlinesTickets(); $db = DBManagerFactory::getInstance(); $record = isset($_GET["record"]) ? htmlspecialchars($_GET["record"]) : ''; $sql = "select atk.name as name, air.name as airline,\r\n atk.messenger as messenger,atk.airlines_representative as representative,\r\n atk.ticket_agency as ticket_agency, atk.itinerary as itinerary,\r\n atk.booking_class as booking_class, atk.booking_code as booking_code,\r\n atk.fare as fare ,atk.commisson as commisson,atk.tax_fee_change as tax_fee_change,\r\n atk.nett as nett, atk.roe as roe,atk.equivalent_in_vn as equivalent_in_vn\r\n from airlinestickets atk , airlines air ,airlines_ailinestickets_c aac \r\n where atk.id = '" . $record . "' \r\n and air.id = aac.airlines_a476cirlines_ida \r\n and atk.id = aac.airlines_a1d09tickets_idb \r\n and atk.deleted = 0 and aac.deleted = 0 and air.deleted = 0"; // This query to get airline name and airlineticket info. $result = $db->query($sql); $template = file_get_contents('modules/AirlinesTickets/tpls/Export_exchangeorder.tpl'); $row = $db->fetchByAssoc($result); $template = str_replace("{SITE_URL}", $sugar_config['site_url'], $template); $template = str_replace("{AIRLINE}", $row['airline'], $template); $template = str_replace("{MESSENGER}", $row['messenger'], $template); $template = str_replace("{REPRESENTATIVE}", $row['representative'], $template); $template = str_replace("{TICKET_AGENCY}", $row['ticket_agency'], $template); $template = str_replace("{FARE}", $row['fare'], $template); $template = str_replace("{COMMISSION}", $row['commisson'], $template); $template = str_replace("{TAXFEECHANGE}", $row['tax_fee_change'], $template); $template = str_replace("{NETT}", $row['nett'], $template); $template = str_replace("{ROE}", $row['roe'], $template); $template = str_replace("{EQUIVALENT}", $row['equivalent_in_vn'], $template); $template = str_replace("{RECORDS}", $focus->get_ticket_exchange_order_record($record, $row['itinerary'], $row['booking_class'], $row['booking_code']), $template); $size = strlen($template); $filename = "Ticket Exchange Order " . $row['name'] . ".doc"; ob_end_clean(); header("Cache-Control: private"); header("Content-Type: application/force-download;"); header("Content-Disposition:attachment; filename=\"{$filename}\""); header("Content-length:{$size}"); echo $template; ob_flush(); }
function checkForDuplicates($prefix) { require_once 'include/formbase.php'; $focus = BeanFactory::getBean('Quotes'); if (!checkRequired($prefix, array_keys($focus->required_fields))) { return null; } $query = ''; $baseQuery = 'select id, name, quote_stage, from quotes where deleted!=1 and ('; if (isset($_POST[$prefix . 'name']) && !empty($_POST[$prefix . 'name'])) { $query = $baseQuery . " name like '%" . $_POST[$prefix . 'name'] . "%'"; $query .= getLikeForEachWord('name', $_POST[$prefix . 'name']); } if (!empty($query)) { $rows = array(); $db = DBManagerFactory::getInstance(); $result = $db->query($query . ');'); while ($row = $db->fetchByAssoc($result)) { $rows[] = $row; } if (count($rows) > 0) { return $rows; } } return null; }
function listViewProcess() { $GLOBALS['log'] = LoggerManager::getLogger('SugarCRM'); global $sugar_config; global $current_user; global $app_strings; global $timedate; $type = clean_string($_REQUEST['module']); $db = DBManagerFactory::getInstance(); /* $query = $_REQUEST['query']; if($query){ $ret_array = generateSearchWhere($type, $_REQUEST['current_post']); $w = $ret_array['where']; $where = "IN ( SELECT id from grouplists WHERE ".$w .")"; } else{ $where = ''; } */ /*$ids = $_REQUEST['uid']; if($ids) { $ids = explode(',', $ids); $ids = "'" . implode("','", $ids) . "'"; $where = "in ($ids)"; } else if (isset($_REQUEST['all']) ){ $where = '';//get all } else { if(!empty($_REQUEST['current_post'])) { $ret_array = generateSearchWhere($type, $_REQUEST['current_post']); $w = $ret_array['where']; $where = "IN ( SELECT id from grouplists WHERE ".$w .")"; } else { $where = ''; } }*/ $focus = new GroupLists(); // $query = $focus->create_new_list_query($order_by, $where,$filter=array(),$params=array(), $show_deleted = 0,$join_type='', $return_array = false, $parentbean=null, $singleSelect = false); $query = $focus->{$start_date} = $_REQUEST['start_date']; $end_date = $_REQUEST['end_date']; $template = file_get_contents('modules/GroupLists/tpls/report.tpl'); $template = str_replace('{START}', $start_date, $template); $template = str_replace('{END}', $end_date, $template); $template = str_replace('{LIST_GIT}', $focus->get_GIT_to_report($where), $template); $template = str_replace('{LIST_FIT}', $focus->get_FIT_to_report($where), $template); $size = strlen($template); $filename = "DS KHACH DI TOUR TU " . $start_date . " DEN " . $end_date . ".doc"; ob_end_clean(); header("Cache-Control: private"); header("Content-Type: application/force-download;"); header("Content-Disposition:attachment; filename=\"{$filename}\""); header("Content-length:{$size}"); echo $template; ob_flush(); // header("Location: index.php?module=GroupLists&action=index"); sugar_cleanup(true); }
function ModuleInstaller() { $this->ms = new ModuleScanner(); $this->modules = $this->getModuleDirs(); $this->db = DBManagerFactory::getInstance(); include "ModuleInstall/extensions.php"; $this->extensions = $extensions; }
/** * @group 39635 */ public function testRepairTableParams() { $bigInt = 9876543210.0; $fieldDef = array('dbType' => 'long'); $oDB = DBManagerFactory::getInstance(); $result = $oDB->massageValue($bigInt, $fieldDef); $this->assertEquals($bigInt, $result); }
protected function getDb() { global $db; if (empty($db)) { $db = DBManagerFactory::getInstance(); } return $db; }
function ModuleInstaller() { $this->ms = new ModuleScanner(); $this->modules = get_module_dir_list(); $this->db =& DBManagerFactory::getInstance(); include "ModuleInstall/extensions.php"; $this->extensions = $extensions; }
/** * @dataProvider getBrokenField * @group 42406 */ public function testVardef($field, $error) { $fieldsdefs = array('broken_field' => $field, 'test' => array('name' => 'test', 'type' => 'varchar')); $indices = array(); $db = DBManagerFactory::getInstance(); $result = $db->repairTableParams('contacts', $fieldsdefs, $indices, false); $this->assertRegExp('/\\/\\* ' . $error . ' IS MISSING IN VARDEF contacts::broken_field \\*\\//', $result, 'Broken vardef is passed to db'); }
/** * Returns most active users for last n days * @param $api * @param $args * @return array */ public function getMostActiveUsers($api, $args) { $days = isset($args['days']) ? (int) $args['days'] : 30; $db = DBManagerFactory::getInstance(); // meetings $query = "SELECT meetings.assigned_user_id, count(meetings.id) meetings_count, users.first_name, users.last_name\n FROM meetings, users\n WHERE meetings.assigned_user_id = users.id\n AND users.deleted = 0\n AND meetings.status='Held'\n AND " . $db->convert('meetings.date_modified', 'add_date', array($days, 'DAY')) . " > " . $db->convert('', 'today') . "\n GROUP BY meetings.assigned_user_id, users.first_name, users.last_name\n ORDER BY meetings_count DESC"; $GLOBALS['log']->debug("Finding most active users for Meetings: " . $query); $result = $db->limitQuery($query, 0, 1); $meetings = array(); if (false !== ($row = $db->fetchByAssoc($result))) { if (!empty($row)) { $meetings['user_id'] = $row['assigned_user_id']; $meetings['count'] = $row['meetings_count']; $meetings['first_name'] = $row['first_name']; $meetings['last_name'] = $row['last_name']; } } // calls $query = "SELECT calls.assigned_user_id, count(calls.id) calls_count, users.first_name, users.last_name\n FROM calls, users\n WHERE calls.assigned_user_id = users.id\n AND users.deleted = 0\n AND calls.status='Held'\n AND " . $db->convert('calls.date_modified', 'add_date', array($days, 'DAY')) . " > " . $db->convert('', 'today') . "\n GROUP BY calls.assigned_user_id, users.first_name, users.last_name\n ORDER BY calls_count DESC"; $GLOBALS['log']->debug("Finding most active users for Calls: " . $query); $result = $db->limitQuery($query, 0, 1); $calls = array(); if (false !== ($row = $db->fetchByAssoc($result))) { if (!empty($row)) { $calls['user_id'] = $row['assigned_user_id']; $calls['count'] = $row['calls_count']; $calls['first_name'] = $row['first_name']; $calls['last_name'] = $row['last_name']; } } // inbound emails $query = "SELECT emails.assigned_user_id, count(emails.id) emails_count, users.first_name, users.last_name\n FROM emails, users\n WHERE emails.assigned_user_id = users.id\n AND users.deleted = 0\n AND emails.type = 'inbound'\n AND " . $db->convert('emails.date_entered', 'add_date', array($days, 'DAY')) . " > " . $db->convert('', 'today') . "\n GROUP BY emails.assigned_user_id, users.first_name, users.last_name\n ORDER BY emails_count DESC"; $GLOBALS['log']->debug("Finding most active users for Inbound Emails: " . $query); $result = $db->limitQuery($query, 0, 1); $inbounds = array(); if (false !== ($row = $db->fetchByAssoc($result))) { if (!empty($row)) { $inbounds['user_id'] = $row['assigned_user_id']; $inbounds['count'] = $row['emails_count']; $inbounds['first_name'] = $row['first_name']; $inbounds['last_name'] = $row['last_name']; } } // outbound emails $query = "SELECT emails.assigned_user_id, count(emails.id) emails_count, users.first_name, users.last_name\n FROM emails, users\n WHERE emails.assigned_user_id = users.id\n AND users.deleted = 0\n AND emails.status='sent'\n AND emails.type = 'out'\n AND " . $db->convert('emails.date_entered', 'add_date', array($days, 'DAY')) . " > " . $db->convert('', 'today') . "\n GROUP BY emails.assigned_user_id, users.first_name, users.last_name\n ORDER BY emails_count DESC"; $GLOBALS['log']->debug("Finding most active users for Outbound Emails: " . $query); $result = $db->limitQuery($query, 0, 1); $outbounds = array(); if (false !== ($row = $db->fetchByAssoc($result))) { if (!empty($row)) { $outbounds['user_id'] = $row['assigned_user_id']; $outbounds['count'] = $row['emails_count']; $outbounds['first_name'] = $row['first_name']; $outbounds['last_name'] = $row['last_name']; } } return array('meetings' => $meetings, 'calls' => $calls, 'inbound_emails' => $inbounds, 'outbound_emails' => $outbounds); }