本文整理汇总了PHP中qa函数的典型用法代码示例。如果您正苦于以下问题:PHP qa函数的具体用法?PHP qa怎么用?PHP qa使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qa函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
$this->module_name = "cache";
$this->module_position = 1;
$this->version = 2.229;
// 2.229 - 2014-07-28 - menu generation speed improvement
// 2.228 - 2014-05-12 - cache bug fixing
// 2.227 - 2013-10-02 - cache bug fixing
// 2.226 - 2013-09-12 - hopefully a BIG new speed improvement - change advanced cache_enabled to 1
// 2.225 - 2013-09-12 - debug_cache advanced option added
// 2.224 - 2013-09-10 - dashboard speed fix
// 2.223 - 2013-09-08 - cache size fix
// 2.222 - 2013-09-06 - cache_objects configuration variable (not cache_object)
// 2.221 - 2013-09-03 - cache improvements and bug fixing
// 2.22 - 2013-08-31 - cache and speed improvements
// 2.21 - 2013-08-30 - better memcache support
// 2.2 - 2013-08-30 - starting work on memcache support
// version bug fix? maybe?
// use memcache if it exists
if (class_exists('Memcache', false) && module_config::c('cache_enabled', 1) && module_config::c('memcache_active', 0)) {
self::$_memcache_instance = new Memcache();
if (self::$_memcache_instance->connect(module_config::c('memcache_address', '127.0.0.1'), module_config::c('memcache_port', '11211'))) {
//module_config::c('memcache_address','localhost'), )){
self::$_memcache_prefix = md5(session_id() . _UCM_SECRET . _DB_PREFIX . _DB_NAME . _DB_USER . _DB_PASS);
// what version of information are we requesting (inremented each time something is deleted, inserted or updated)
// bad, but cannot think of any other easy quick way to invalidate caches upon updates
self::$_memcache_version = self::$_memcache_instance->get(self::$_memcache_prefix . 'version');
if (!self::$_memcache_version) {
self::$_memcache_version = 1;
}
self::$_use_memcache = true;
}
} else {
if (module_config::c('cache_enabled', 1) && $this->db_table_exists('cache_store')) {
$sql = "SELECT * FROM `" . _DB_PREFIX . "cache_store` WHERE expire_time > " . time();
foreach (qa($sql) as $res) {
if (!isset(self::$_db_cache[$res['cache_group']])) {
self::$_db_cache[$res['cache_group']] = array();
}
self::$_db_cache[$res['cache_group']][$res['cache_key']] = $res['cache_data'];
}
register_shutdown_function('module_cache::shutdown_write_cached_data');
}
}
// change to low number by default
if (module_config::c('cache_objects', 120) == 3600) {
module_config::save_config('cache_objects', 120);
}
if (module_config::c('cache_enabled', 1) && $this->db_table_exists('cache')) {
$sql = "SELECT * FROM `" . _DB_PREFIX . "cache`";
foreach (qa($sql) as $r) {
self::$_cache_expiry[$r['cache_group']] = $r['expire_time'];
}
}
}
示例2: run_cron
public function run_cron($debug = false)
{
// check for payments.
$sql = "SELECT * FROM `" . _DB_PREFIX . "invoice_payment` ip WHERE 1 ";
$sql .= " AND `method` = 'paynl' ";
$sql .= " AND `date_paid` = '0000-00-00' ";
$sql .= " AND `other_id` != '' ";
foreach (qa($sql) as $payment) {
// check api status:
$strUrl = 'https://token:' . module_config::c('payment_method_paynl_token', '') . '@rest-api.pay.nl/v5/Transaction/info/json?';
$arrArguments = array();
$arrArguments['transactionId'] = $payment['other_id'];
# Prepare and call API URL
$strUrl .= http_build_query($arrArguments);
if ($debug) {
echo "Checking URL {$strUrl} <br>\n";
$jsonResult = file_get_contents($strUrl);
} else {
$jsonResult = @file_get_contents($strUrl);
}
$json = @json_decode($jsonResult, true);
if ($debug) {
echo "Got result: <br>\n";
print_r($json);
}
if ($json && isset($json['paymentDetails']) && isset($json['paymentDetails']['stateName']) && isset($json['paymentDetails']['amount'])) {
module_paymethod_paynl::add_payment_data($payment['invoice_payment_id'], 'log', "PayNL Status " . $json['paymentDetails']['stateName'] . ": \n " . var_export($json, true));
switch ($json['paymentDetails']['stateName']) {
case 'PENDING':
// defauly, still waiting for payment.
break;
case 'PAID':
update_insert("invoice_payment_id", $payment['invoice_payment_id'], "invoice_payment", array('date_paid' => date('Y-m-d'), 'amount' => $json['paymentDetails']['amount'] / 100, 'other_id' => ''));
module_invoice::save_invoice($payment['invoice_id'], array());
break;
case 'CANCEL':
update_insert("invoice_payment_id", $payment['invoice_payment_id'], "invoice_payment", array('other_id' => ''));
module_invoice::save_invoice($payment['invoice_id'], array());
send_error('PayNL payment cancelled for invoice: ' . module_invoice::link_open($payment['invoice_id'], true));
break;
}
} else {
module_paymethod_paynl::add_payment_data($payment['invoice_payment_id'], 'log', "PayNL Status ERROR: \n " . $jsonResult);
}
}
}
示例3: display_notes
public static function display_notes($options)
{
$owner_table = isset($options['owner_table']) && $options['owner_table'] ? $options['owner_table'] : false;
global $plugins;
// permission checking.
$can_create = $can_edit = $can_view = $can_delete = true;
if ($options && isset($options['bypass_security'])) {
// do nothing?
} else {
if (isset($options) && isset($options['owner_table']) && $options['owner_table'] && isset($options['title']) && $options['title']) {
$can_view = $plugins[$options['owner_table']]->can_i('view', $options['title']);
$can_edit = $plugins[$options['owner_table']]->can_i('edit', $options['title']);
$can_create = $plugins[$options['owner_table']]->can_i('create', $options['title']);
$can_delete = $plugins[$options['owner_table']]->can_i('delete', $options['title']);
}
}
/*if(!module_security::is_page_editable()){
$can_edit=$can_create=$can_delete=false;
}*/
if (!$can_view) {
return '';
}
// display links in a popup?
$popup_links = get_display_mode() != 'mobile';
// disable popups in mobile version.
$owner_id = isset($options['owner_id']) && $options['owner_id'] ? (int) $options['owner_id'] : false;
if ($owner_id && $owner_table) {
// we have all that we need to display some notes!! yey!!
// do we display a summary or not?
$note_items = self::get_notes(array('owner_table' => $owner_table, 'owner_id' => $owner_id));
$display_summary = isset($options['display_summary']) && $options['display_summary'];
if (isset($options['summary_owners']) && is_array($options['summary_owners'])) {
// generate a list of other notes we have to display int eh list.
foreach ($options['summary_owners'] as $summary_owner_table => $summary_owner_ids) {
if (is_array($summary_owner_ids) && count($summary_owner_ids) > 0) {
//$sql = "SELECT *, note_id AS id FROM `"._DB_PREFIX."note` n WHERE owner_table = '".mysql_real_escape_string($summary_owner_table)."' AND ( ";
$sql = "SELECT *, note_id AS id FROM `" . _DB_PREFIX . "note` n WHERE n.`owner_table` = '" . mysql_real_escape_string($summary_owner_table) . "' AND n.`owner_id` IN ( ";
/*foreach($summary_owner_ids as $summary_owner_id){
//$note_items = array_merge($note_items,self::get_notes(array('owner_table'=>$summary_owner_table,'owner_id'=>$summary_owner_id)));
$sql .= " `owner_id` = '".(int)$summary_owner_id."' OR ";
}
$sql = rtrim($sql,'OR ');*/
foreach ($summary_owner_ids as $k => $summary_owner_id) {
$summary_owner_ids[$k] = (int) $summary_owner_id;
}
$sql .= implode(',', $summary_owner_ids);
$sql .= " )";
$note_items = array_merge($note_items, qa($sql));
}
}
}
// moved to 'note_list.php'
/*foreach($note_items as $key=>$note_item){
$note_items[$key]['html'] = self::print_note($note_item['note_id'],$note_item,$display_summary,$can_edit,$can_delete,$options);
}*/
uasort($note_items, 'sort_notes');
if (isset($options['view_link'])) {
$blah = parse_url($options['view_link']);
if ($blah && isset($blah['path']) && isset($blah['query'])) {
$options['view_link'] = $blah['path'] . '?' . $blah['query'];
}
$rel_data = $options['view_link'];
}
$note_list_safe = true;
include "pages/note_list.php";
}
}
示例4: get_reports
public static function get_reports($search = array())
{
// limit based on customer id
/*if(!isset($_REQUEST['customer_id']) || !(int)$_REQUEST['customer_id']){
return array();
}*/
// build up a custom search sql query based on the provided search fields
$sql = "SELECT u.*,u.report_id AS id ";
$sql .= ", u.report_title AS name ";
// add in our extra fields for the csv export
//if(isset($_REQUEST['import_export_go']) && $_REQUEST['import_export_go'] == 'yes'){
if (class_exists('module_extra', false)) {
$sql .= " , (SELECT GROUP_CONCAT(ex.`extra_key` ORDER BY ex.`extra_id` ASC SEPARATOR '" . _EXTRA_FIELD_DELIM . "') FROM `" . _DB_PREFIX . "extra` ex WHERE owner_id = u.report_id AND owner_table = 'report') AS extra_keys";
$sql .= " , (SELECT GROUP_CONCAT(ex.`extra` ORDER BY ex.`extra_id` ASC SEPARATOR '" . _EXTRA_FIELD_DELIM . "') FROM `" . _DB_PREFIX . "extra` ex WHERE owner_id = u.report_id AND owner_table = 'report') AS extra_vals";
}
$from = " FROM `" . _DB_PREFIX . "report` u ";
$where = " WHERE 1 ";
if (isset($search['generic']) && $search['generic']) {
$str = mysql_real_escape_string($search['generic']);
$where .= " AND ( ";
$where .= " u.report_title LIKE '%{$str}%' ";
$where .= ' ) ';
}
$group_order = ' GROUP BY u.report_id ORDER BY u.report_title';
// stop when multiple company sites have same region
$sql = $sql . $from . $where . $group_order;
$result = qa($sql);
//module_security::filter_data_set("report",$result);
return $result;
// return get_multiple("report",$search,"report_id","fuzzy","name");
}
示例5: get_statuses
public static function get_statuses()
{
$sql = "SELECT `status` FROM `" . _DB_PREFIX . "file` GROUP BY `status` ORDER BY `status`";
$statuses = array();
foreach (qa($sql) as $r) {
$statuses[$r['status']] = $r['status'];
}
return $statuses;
}
示例6: run_cron
public function run_cron($debug = false)
{
// we only want to perform these cron actions if we're after a certain time of day
// because we dont want to be generating these renewals and sending them at midnight, can get confusing
$after_time = module_config::c('invoice_automatic_after_time', 7);
$time_of_day = date('G');
if ($time_of_day < $after_time) {
if ($debug) {
echo "Not performing automatic invoice operations until after {$after_time}:00 - it is currently {$time_of_day}:" . date('i') . "<br>\n";
}
return;
}
// find automaitic invoice overdues
$sql = "SELECT * FROM `" . _DB_PREFIX . "invoice` ";
$sql .= " WHERE date_due != '0000-00-00' AND date_due <= '" . date('Y-m-d') . "' AND date_paid = '0000-00-00' AND date_cancel = '0000-00-00'";
$invoice_items = qa($sql);
if ($debug) {
echo "Processing " . count($invoice_items) . " overdue invoices: <br>\n";
}
foreach ($invoice_items as $invoice_item) {
module_cache::clear('invoice');
$invoice = module_invoice::get_invoice($invoice_item['invoice_id']);
if ($invoice['overdue'] && $invoice['overdue_email_auto']) {
if ($debug) {
echo "Processing overdue for invoice: " . module_invoice::link_open($invoice['invoice_id'], true) . " <br>\n";
}
if ($debug) {
echo " - last sent: " . $invoice['date_sent'] . " <br>\n";
}
if ($debug) {
echo " - due date: " . $invoice['date_due'] . " <br>\n";
}
if ($debug) {
echo " - now: " . date('Y-m-d') . " ( " . time() . " ) <br>\n";
}
// if you change this calculation make sure it is changed in the dashboard alerts above to
$send_email_on = false;
if ($invoice['date_sent'] && $invoice['date_sent'] != '0000-00-00' && strtotime($invoice['date_sent']) > strtotime($invoice['date_due'])) {
// we have sent a reminder already (todo: this isn't correct logic, fix it up so it can tell for sure if we have sent a reminder already or not (eg: look through email history table)
$last_invoice_sent = strtotime($invoice['date_sent']);
if (module_config::c('overdue_email_auto_days_repeat', 7) <= 0) {
continue;
// skip sendin repeat reminders.
}
$send_email_on = strtotime('+' . module_config::c('overdue_email_auto_days_repeat', 7) . ' days', $last_invoice_sent);
} else {
if ($invoice['date_sent'] && $invoice['date_sent'] != '0000-00-00') {
$invoice_is_due = strtotime($invoice['date_due']);
$send_email_on = strtotime('+' . module_config::c('overdue_email_auto_days', 3) . ' days', $invoice_is_due);
if ($debug) {
echo module_config::c('overdue_email_auto_days', 3) . " days from " . $invoice['date_due'] . " is " . date('Y-m-d', $send_email_on) . "<br>\n";
}
} else {
// this invoice has not been sent yet, so we don't send an automated overdue notice.
// the user has to pick a "sent datE" before the system will send overdue notices.
if ($debug) {
echo " - NOT Sending Overdue Invoice Notice for " . module_invoice::link_open($invoice['invoice_id'], true) . " because it has no SENT DATE.<br>\n";
}
$send_email_on = false;
}
}
if ($invoice['date_sent'] && $invoice['date_sent'] != '0000-00-00' && date('Y-m-d', $send_email_on) == $invoice['date_sent']) {
if ($debug) {
echo " - NOT Sending Overdue Invoice Notice for " . module_invoice::link_open($invoice['invoice_id'], true) . " because it was last sent today already.<br>\n";
}
$send_email_on = false;
}
if ($send_email_on !== false && $debug) {
echo " - will send next invoice at: " . date('Y-m-d', $send_email_on) . " ( {$send_email_on} ) <br>\n";
}
if ($send_email_on !== false && $send_email_on <= strtotime(date('Y-m-d'))) {
if ($debug) {
echo " - Automatically Sending Overdue Invoice Notice for " . module_invoice::link_open($invoice['invoice_id'], true) . "<br>\n";
}
if ($debug) {
echo " - Emailing invoice to customer...";
}
if (module_invoice::email_invoice_to_customer($invoice['invoice_id'], $debug)) {
if ($debug) {
echo "sent successfully<br>\n";
}
} else {
echo "sending overdue invoice email failed for " . module_invoice::link_open($invoice['invoice_id'], true) . "<br>\n";
}
if ($debug) {
echo "<br>\n";
}
}
}
}
// find automatic invoice renewals
$sql = "SELECT i.* FROM `" . _DB_PREFIX . "invoice` i ";
$sql .= " WHERE i.date_renew != '0000-00-00'";
$sql .= " AND i.date_create != '0000-00-00'";
$sql .= " AND i.date_cancel = '0000-00-00'";
$sql .= " AND i.date_renew <= '" . date('Y-m-d') . "'";
$sql .= " AND (i.renew_invoice_id IS NULL OR i.renew_invoice_id = 0)";
$sql .= " AND (i.renew_auto = 1)";
$renew_invoices = qa($sql);
foreach ($renew_invoices as $renew_invoice) {
//.........这里部分代码省略.........
示例7: get_newsletter_content
public function get_newsletter_content($db = false, $newsletter_content_id)
{
if (!$db) {
$db = db_connect();
}
$sql = "SELECT * FROM " . _DB_PREFIX . "newsletter_content WHERE newsletter_content_id = '" . (int) $newsletter_content_id . "'";
$res = array_shift(qa($sql, $db));
$folder = _IMAGES_DIR . 'newsletter-' . $res['newsletter_id'] . '/';
if (is_file($folder . $newsletter_content_id . '-thumb.jpg')) {
$res['image_thumb'] = $folder . $newsletter_content_id . '-thumb.jpg';
}
if (is_file($folder . $newsletter_content_id . '.jpg')) {
$res['image_main'] = $folder . $newsletter_content_id . '.jpg';
}
return $res;
}
示例8: run_pagination_hook
public static function run_pagination_hook(&$rows)
{
if (isset($_REQUEST['import_export_go']) && $_REQUEST['import_export_go'] == 'yes') {
// we are posting back tot his script with a go!
if (is_resource($rows)) {
$new_rows = array();
while ($row = mysql_fetch_assoc($rows)) {
$new_rows[] = $row;
}
$rows = $new_rows;
} else {
// rows stays the same.
}
// add these items to the import_export.
if (is_array($rows) && count($rows)) {
$fields = self::$pagination_options['fields'];
// export as CSV file:
ob_end_clean();
ob_start();
foreach ($fields as $key => $val) {
echo '"' . str_replace('"', '""', $key) . '",';
}
// check for extra fields.
if (class_exists('module_extra', false) && isset(self::$pagination_options['extra']) && count(self::$pagination_options['extra'])) {
if (isset(self::$pagination_options['extra']['owner_table'])) {
self::$pagination_options['extra'] = array(self::$pagination_options['extra']);
}
foreach (self::$pagination_options['extra'] as $extra_field_id => $extra_field_settings) {
$sql = "SELECT `extra_key` FROM `" . _DB_PREFIX . "extra` WHERE owner_table = '" . mysql_real_escape_string($extra_field_settings['owner_table']) . "' AND `extra_key` != '' GROUP BY `extra_key` ORDER BY `extra_key`";
self::$pagination_options['extra'][$extra_field_id]['extra_fields'] = qa($sql);
foreach (self::$pagination_options['extra'][$extra_field_id]['extra_fields'] as $extra_field) {
echo '"' . str_replace('"', '""', $extra_field['extra_key']) . '",';
}
}
}
// check for group fields.
if (class_exists('module_group', false) && isset(self::$pagination_options['group']) && self::$pagination_options['group']) {
// find groups for this entry
foreach (self::$pagination_options['group'] as $group_search) {
echo '"' . str_replace('"', '""', $group_search['title']) . '",';
}
}
echo "\n";
foreach ($rows as $row) {
foreach ($fields as $key => $val) {
echo '"' . str_replace('"', '""', isset($row[$val]) ? $row[$val] : '') . '",';
}
// check for extra fields.
if (class_exists('module_extra', false) && isset(self::$pagination_options['extra']) && count(self::$pagination_options['extra'])) {
foreach (self::$pagination_options['extra'] as $extra_field_id => $extra_field_settings) {
$extra_vals = array();
if (isset($row[$extra_field_settings['owner_id']]) && $row[$extra_field_settings['owner_id']] > 0) {
$sql = "SELECT `extra_key` AS `id`, `extra` FROM `" . _DB_PREFIX . "extra` WHERE owner_table = '" . mysql_real_escape_string($extra_field_settings['owner_table']) . "' AND `owner_id` = '" . (int) $row[$extra_field_settings['owner_id']] . "' ORDER BY `extra_key`";
$extra_vals = qa($sql);
}
foreach ($extra_field_settings['extra_fields'] as $extra_field) {
echo '"';
echo isset($extra_vals[$extra_field['extra_key']]) ? str_replace('"', '""', $extra_vals[$extra_field['extra_key']]['extra']) : '';
echo '",';
}
}
}
// check for group fields.
if (class_exists('module_group', false) && isset(self::$pagination_options['group']) && self::$pagination_options['group']) {
// find groups for this entry
foreach (self::$pagination_options['group'] as $group_search) {
$g = array();
$groups = module_group::get_groups_search(array('owner_table' => $group_search['owner_table'], 'owner_id' => isset($row[$group_search['owner_id']]) ? $row[$group_search['owner_id']] : 0));
foreach ($groups as $group) {
$g[] = $group['name'];
}
echo '"' . str_replace('"', '""', implode(', ', $g)) . '",';
}
}
echo "\n";
}
// is there a summary to add at the end of the export?
if (isset(self::$pagination_options['summary']) && is_array(self::$pagination_options['summary'])) {
foreach (self::$pagination_options['summary'] as $summary_row) {
foreach ($fields as $key => $val) {
echo '"';
if (isset($summary_row[$val])) {
echo $summary_row[$val];
}
echo '",';
}
echo "\n";
}
}
$csv = ob_get_clean();
if (module_config::c('export_csv_debug', 0)) {
echo '<pre>' . $csv . '</pre>';
exit;
}
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private", false);
header("Content-Type: text/csv");
//todo: correct file name
//.........这里部分代码省略.........
示例9: get_upgrade_sql
//.........这里部分代码省略.........
$sql .= 'ALTER TABLE `' . _DB_PREFIX . 'job` ADD `c_total_amount_invoicable` DECIMAL( 10,2 ) NOT NULL DEFAULT \'-1\' AFTER `total_percent_complete`;';
}
if (!isset($fields['c_staff_total_amount'])) {
$sql .= 'ALTER TABLE `' . _DB_PREFIX . 'job` ADD `c_staff_total_amount` DECIMAL( 10,2 ) NOT NULL DEFAULT \'-1\' AFTER `c_total_amount_invoicable`;';
}
if (!isset($fields['c_total_net_amount'])) {
$sql .= 'ALTER TABLE `' . _DB_PREFIX . 'job` ADD `c_total_net_amount` DECIMAL( 10,2 ) NOT NULL DEFAULT \'-1\' AFTER `c_staff_total_amount`;';
}
if (!isset($fields['c_staff_total_grouped'])) {
$sql .= 'ALTER TABLE `' . _DB_PREFIX . 'job` ADD `c_staff_total_grouped` TEXT NOT NULL DEFAULT \'\' AFTER `c_total_net_amount`;';
}
if (!isset($fields['description'])) {
$sql .= 'ALTER TABLE `' . _DB_PREFIX . 'job` ADD `description` TEXT NOT NULL DEFAULT \'\' AFTER `c_total_net_amount`;';
}
if (!isset($fields['discount_amount'])) {
$sql .= 'ALTER TABLE `' . _DB_PREFIX . 'job` ADD `discount_amount` DECIMAL(10,2) NOT NULL DEFAULT \'0\' AFTER `description`;';
}
if (!isset($fields['discount_description'])) {
$sql .= 'ALTER TABLE `' . _DB_PREFIX . 'job` ADD `discount_description` varchar(255) NOT NULL DEFAULT \'\' AFTER `discount_amount`;';
}
if (!isset($fields['discount_type'])) {
$sql .= 'ALTER TABLE `' . _DB_PREFIX . 'job` ADD `discount_type` INT NOT NULL DEFAULT \'0\' AFTER `discount_description`;';
}
if (!isset($fields['time_start'])) {
$sql .= 'ALTER TABLE `' . _DB_PREFIX . 'job` ADD `time_start` varchar(10) NOT NULL DEFAULT \'\' AFTER `date_start`;';
}
if (!isset($fields['time_end'])) {
$sql .= 'ALTER TABLE `' . _DB_PREFIX . 'job` ADD `time_end` varchar(10) NOT NULL DEFAULT \'\' AFTER `time_start`;';
}
$fields = get_fields('task');
if (!isset($fields['long_description'])) {
$sql .= 'ALTER TABLE `' . _DB_PREFIX . 'task` ADD `long_description` LONGTEXT NULL;';
}
if (!isset($fields['task_order'])) {
$sql .= 'ALTER TABLE `' . _DB_PREFIX . 'task` ADD `task_order` int(11) NOT NULL DEFAULT \'0\' AFTER `approval_required`;';
}
if (!isset($fields['date_done'])) {
$sql .= 'ALTER TABLE `' . _DB_PREFIX . 'task` ADD `date_done` date NOT NULL AFTER `date_due`;';
}
if (!isset($fields['taxable'])) {
$sql .= 'ALTER TABLE `' . _DB_PREFIX . 'task` ADD `taxable` tinyint(1) NOT NULL DEFAULT \'1\' AFTER `amount`;';
}
if (!isset($fields['manual_percent'])) {
$sql .= 'ALTER TABLE `' . _DB_PREFIX . 'task` ADD `manual_percent` int(4) NOT NULL DEFAULT \'-1\' AFTER `taxable`;';
}
if (!isset($fields['manual_task_type'])) {
// if -1 then we use job default_task_type
$sql .= 'ALTER TABLE `' . _DB_PREFIX . 'task` ADD `manual_task_type` tinyint(2) NOT NULL DEFAULT \'-1\' AFTER `manual_percent`;';
}
if (!isset($fields['hours_mins'])) {
$sql .= 'ALTER TABLE `' . _DB_PREFIX . 'task` ADD `hours_mins` DECIMAL(10,2) NOT NULL DEFAULT \'0\' AFTER `hours`;';
}
/*
`billable` tinyint(2) NOT NULL DEFAULT '1',
`staff_hours` decimal(10,2) NOT NULL DEFAULT '0',
`staff_hours_mins` decimal(10,2) NOT NULL DEFAULT '0',
`staff_amount` decimal(10,2) NOT NULL DEFAULT '0',
`staff_taxable` tinyint(1) NOT NULL DEFAULT '1',
`staff_billable` tinyint(2) NOT NULL DEFAULT '1',
*/
if (!isset($fields['staff_split'])) {
$sql .= 'ALTER TABLE `' . _DB_PREFIX . 'task` ADD `staff_split` tinyint(1) NOT NULL DEFAULT \'0\' AFTER `billable`;';
}
if (!isset($fields['staff_hours'])) {
$sql .= 'ALTER TABLE `' . _DB_PREFIX . 'task` ADD `staff_hours` DECIMAL(10,2) NOT NULL DEFAULT \'0\' AFTER `staff_split`;';
}
if (!isset($fields['staff_hours_mins'])) {
$sql .= 'ALTER TABLE `' . _DB_PREFIX . 'task` ADD `staff_hours_mins` DECIMAL(10,2) NOT NULL DEFAULT \'0\' AFTER `staff_hours`;';
}
if (!isset($fields['staff_amount'])) {
$sql .= 'ALTER TABLE `' . _DB_PREFIX . 'task` ADD `staff_amount` DECIMAL(10,2) NOT NULL DEFAULT \'0\' AFTER `staff_hours_mins`;';
}
if (!isset($fields['staff_taxable'])) {
$sql .= 'ALTER TABLE `' . _DB_PREFIX . 'task` ADD `staff_taxable` tinyint(1) NOT NULL DEFAULT \'1\' AFTER `staff_amount`;';
}
if (!isset($fields['staff_billable'])) {
$sql .= 'ALTER TABLE `' . _DB_PREFIX . 'task` ADD `staff_billable` tinyint(2) NOT NULL DEFAULT \'1\' AFTER `staff_taxable`;';
}
/*if(!isset($fields['task_type'])){
$sql .= 'ALTER TABLE `'._DB_PREFIX.'task` ADD `task_type` tinyint(2) NOT NULL DEFAULT \'0\' AFTER `task_order`;';
}*/
if (!self::db_table_exists('job_tax')) {
$sql .= "CREATE TABLE `" . _DB_PREFIX . "job_tax` (\r\r\n `job_tax_id` int(11) NOT NULL AUTO_INCREMENT,\r\r\n `job_id` int(11) NOT NULL,\r\r\n `percent` decimal(10,2) NOT NULL DEFAULT '0',\r\r\n `amount` decimal(10,2) NOT NULL DEFAULT '0',\r\r\n `name` varchar(50) NOT NULL DEFAULT '',\r\r\n `order` INT( 4 ) NOT NULL DEFAULT '0',\r\r\n `increment` TINYINT( 1 ) NOT NULL DEFAULT '0',\r\r\n `create_user_id` int(11) NOT NULL,\r\r\n `update_user_id` int(11) NULL,\r\r\n `date_created` date NOT NULL,\r\r\n `date_updated` date NULL,\r\r\n PRIMARY KEY (`job_tax_id`),\r\r\n KEY (`job_id`)\r\r\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
}
self::add_table_index('job', 'customer_id');
self::add_table_index('job', 'user_id');
self::add_table_index('job', 'website_id');
self::add_table_index('job', 'quote_id');
self::add_table_index('task', 'job_id');
self::add_table_index('task', 'user_id');
self::add_table_index('task', 'invoice_id');
self::add_table_index('task_log', 'task_id');
self::add_table_index('task_log', 'job_Id');
$bug_check = "SELECT * FROM `" . _DB_PREFIX . "job` WHERE (customer_id IS NULL OR customer_id = 0) AND (website_id IS NULL OR website_id = 0) AND `name` = '' AND `type` = '' AND `date_start` = '0000-00-00' AND c_total_net_amount = 0 AND `user_id` = 0 AND (`discount_description` = '' OR `discount_description` IS NULL)";
$count = qa($bug_check);
if (count($count)) {
$sql .= "DELETE FROM `" . _DB_PREFIX . "job` WHERE (customer_id IS NULL OR customer_id = 0) AND (website_id IS NULL OR website_id = 0) AND `name` = '' AND `type` = '' AND `date_start` = '0000-00-00' AND c_total_net_amount = 0 AND `user_id` = 0 AND (`discount_description` = '' OR `discount_description` IS NULL);";
}
return $sql;
}
示例10: get_types
public static function get_types()
{
$sql = "SELECT `type` FROM `" . _DB_PREFIX . "quote` GROUP BY `type` ORDER BY `type`";
$statuses = module_job::get_types();
foreach (qa($sql) as $r) {
$statuses[$r['type']] = $r['type'];
}
return $statuses;
}
示例11: get_remaining_changes
public static function get_remaining_changes($website_id)
{
$change_request_website = get_single('change_request_website', 'website_id', $website_id);
$changes = array(0, isset($change_request_website['limit_number']) ? $change_request_website['limit_number'] : 5);
if (isset($change_request_website['limit_per'])) {
switch ($change_request_website['limit_per']) {
case 1:
// week
$period = 'week';
$start_time = date('Y-m-d H:i:s', strtotime('-7 days'));
break;
case 2:
// month
$period = 'month';
$start_time = date('Y-m-d H:i:s', strtotime('-1 month'));
break;
case 3:
// year
$period = 'year';
$start_time = date('Y-m-d H:i:s', strtotime('-1 year'));
break;
default:
// all time.
$period = 'all time';
$start_time = 0;
}
$changes[2] = $period;
$sql = " SELECT * FROM `" . _DB_PREFIX . "change_request` ";
$sql .= " WHERE website_id = " . (int) $website_id;
$sql .= " AND (`status` = 1 OR `status` = 2) ";
if ($start_time) {
$sql .= " AND `date_created` >= '" . mysql_real_escape_string($start_time) . "'";
}
$all = qa($sql);
$changes[0] = count($all);
}
/*$all = $wpdb->get_results("SELECT * FROM $table_name
WHERE (published = 1 OR published = 2) AND `user_id` = '$user_id' AND `time` > '$start_time'"); //completed or published.
$changes[0] = count($all);*/
return $changes;
}
示例12: count
echo count($staff_messages);
?>
in <?php
echo count($staff_tickets);
?>
tickets
</td>
<td>
<?php
echo count($staff_private_messages);
?>
</td>
<td>
<?php
$sql = "SELECT * FROM `" . _DB_PREFIX . "ticket` WHERE last_message_timestamp >= " . (int) strtotime(input_date($search['date_from'])) . " AND last_message_timestamp <= " . (int) strtotime(input_date($search['date_to'])) . " AND assigned_user_id = " . (int) $staff_member['user_id'];
$tickets = qa($sql);
echo count($tickets);
?>
</td>
<td>
<?php
$r = 0;
foreach ($tickets as $ticket) {
if ($ticket['status_id'] == _TICKET_STATUS_RESOLVED_ID) {
$r++;
}
}
echo $r;
?>
</td>
</tr>
示例13: handle_import
public static function handle_import($data, $group = false, $extra_options)
{
$imported = 0;
if (!_DEMO_MODE && isset($extra_options['language_id']) && $extra_options['language_id'] > 0 && count($data) > 1) {
foreach ($data as $row) {
if (isset($row['word']) && strlen($row['word']) && isset($row['translation']) && strlen($row['translation'])) {
// ready to import this word!
$sql = "SELECT lw.language_word_id, lw.`word` ";
$sql .= " FROM ";
$sql .= " `" . _DB_PREFIX . "language_word` lw ";
$sql .= " WHERE lw.`word` = '" . mysql_real_escape_string($row['word']) . "'";
$res = qa($sql);
$language_word_id = false;
if (is_array($res)) {
foreach ($res as $r) {
if ($r['word'] == $row['word']) {
$language_word_id = $r['language_word_id'];
}
}
}
/*if($row['word'] == 'Dashboard'){
echo 'dash';
echo $sql;
print_r($res);
exit;
}*/
if (!$language_word_id) {
// create a new one, unless our ignore option is setup
if (isset($extra_options['new_words']) && $extra_options['new_words'] == 'ignore') {
continue;
// skip this word
}
$language_word_id = update_insert('language_word_id', false, 'language_word', array('word' => $row['word']));
}
$sql = "REPLACE INTO `" . _DB_PREFIX . "language_translation` SET `language_id` = " . (int) $extra_options['language_id'] . ", ";
$sql .= "`language_word_id` = " . (int) $language_word_id . ", `translation` = '" . mysql_real_escape_string($row['translation']) . "'";
query($sql);
// add this translation to the file.
$imported++;
}
}
} else {
if (_DEMO_MODE) {
set_error('Import disabled in demo mode');
}
}
return $imported;
}
示例14: get_member_groups
public static function get_member_groups($owner_table, $owner_id)
{
$sql = "SELECT * FROM `" . _DB_PREFIX . "group_member` WHERE ";
$sql .= " `owner_id` = '" . (int) $owner_id . "' AND ";
$sql .= " `owner_table` = '" . mysql_real_escape_string($owner_table) . "'";
return qa($sql);
}
示例15: get_faqs
public static function get_faqs($search = array())
{
//return get_multiple('faq',array(),'faq_id','exact','question');
$sql = "SELECT f.*, f.faq_id AS `id` ";
$sql .= " FROM `" . _DB_PREFIX . "faq` f ";
$sql .= " LEFT JOIN `" . _DB_PREFIX . "faq_product_rel` r ON f.faq_id = r.faq_id ";
$sql .= " WHERE 1 ";
if (isset($search['question']) && $search['question']) {
$sql .= " AND f.question LIKE '%" . mysql_real_escape_string($search['question']) . "%'";
}
if (isset($search['faq_product_id']) && $search['faq_product_id']) {
$sql .= " AND r.faq_product_id = " . (int) $search['faq_product_id'];
}
$sql .= " GROUP BY f.faq_id";
return qa($sql);
}