function api_getConstituencies_date($date) {
	if ($date = parse_date($date)) {
		api_getConstituencies('"' . $date['iso'] . '"');
	} else {
		api_error('Invalid date format');
	}
}
Esempio n. 2
0
function api_getMembers_date($house, $date) {
	if ($date = parse_date($date)) {
		api_getMembers($house, '"' . $date['iso'] . '"');
	} else {
		api_error('Invalid date format');
	}
}
Esempio n. 3
0
 public function getArgs()
 {
     $args = array();
     if (get_http_var('f') == 'csv') {
         $args['f'] = 'csv';
     }
     $date = get_http_var('date');
     if ($date) {
         $date = parse_date($date);
         if ($date) {
             $args['date'] = $date['iso'];
         }
     } elseif (get_http_var('all')) {
         $args['all'] = true;
     }
     if ($this->type == 'peers') {
         $args['order'] = 'name';
     }
     $order = get_http_var('o');
     $orders = array('n' => 'name', 'f' => 'given_name', 'l' => 'family_name', 'c' => 'constituency', 'p' => 'party', 'd' => 'debates');
     if (array_key_exists($order, $orders)) {
         $args['order'] = $orders[$order];
     }
     return $args;
 }
Esempio n. 4
0
function api_getCommittee_name($name) {
	$db = new ParlDB;

	$name = preg_replace('#\s+Committee#', '', $name);

	$date = parse_date(get_http_var('date'));
	if ($date) $date = '"' . $date['iso'] . '"';
	else $date = 'date(now())';
	$q = $db->query("select distinct(dept) from moffice
		where dept like '%" . mysql_real_escape_string($name) . "%Committee'
		and from_date <= " . $date . ' and '
		. $date . ' <= to_date');
	if ($q->rows() > 1) {
		# More than one committee matches
		for ($i=0; $i<$q->rows(); $i++) {
			$output['committees'][] = array(
				'name' => $q->field($i, 'dept')
			);
		}
		api_output($output);
	} elseif ($q->rows()) {
		# One committee
		$q = $db->query("select * from moffice,member
			where moffice.person = member.person_id
			and dept like '%" . mysql_real_escape_string($name) . "%Committee'
			and from_date <= " . $date . ' and ' . $date . " <= to_date
			and entered_house <= " . $date . ' and ' . $date . ' <= left_house');
		if ($q->rows()) {
			$output = array();
			$output['committee'] = $q->field(0, 'dept');
			for ($i=0; $i<$q->rows(); $i++) {
				$member = array(
'person_id' => $q->field($i, 'person'),
'name' => $q->field($i, 'first_name') . ' ' . $q->field($i, 'last_name'),
				);
				if ($q->field($i, 'position') == 'Chairman') {
					$member['position'] = $q->field($i, 'position');
				}
				$output['members'][] = $member;
			}
			api_output($output);
		} else {
			api_error('That committee has no members...?');
		}
	} else {
		api_error('That name was not recognised');
	}
}
Esempio n. 5
0
 private function parse_date_params()
 {
     $searchstring = '';
     if (get_http_var('from') || get_http_var('to')) {
         $from = parse_date(get_http_var('from'));
         if ($from) {
             $from = $from['iso'];
         } else {
             $from = '1935-10-01';
         }
         $to = parse_date(get_http_var('to'));
         if ($to) {
             $to = $to['iso'];
         } else {
             $to = date('Y-m-d');
         }
         $searchstring .= " {$from}..{$to}";
     }
     return $searchstring;
 }
Esempio n. 6
0
function create_unit($data)
{
    $fields = array('unit_number', 'element', 'rarity', 'cost', 'hit_count', 'bb_hits', 'sbb_hits', 'bb_fill', 'sbb_fill', 'lord_hp', 'lord_atk', 'lord_def', 'lord_rec', 'anima_hp', 'anima_atk', 'anima_def', 'anima_rec', 'breaker_hp', 'breaker_atk', 'breaker_def', 'breaker_rec', 'guardian_hp', 'guardian_atk', 'guardian_def', 'guardian_rec', 'oracle_hp', 'oracle_atk', 'oracle_def', 'oracle_rec', 'leaders_skill_effect', 'brave_burst_effect', 'super_brave_burst_effect');
    $type = 'unit';
    $valid_type = function_exists('post_type_exists') && post_type_exists($type);
    if (!$valid_type) {
        //$this->log['error']["type-{$type}"] = sprintf('Unknown post type "%s".', $type);
    }
    $new_post = array('post_title' => convert_chars($data['unit_name']), 'post_content' => 'Not available', 'post_status' => 'publish', 'post_type' => $type, 'post_date' => parse_date(time()));
    // create!
    $id = wp_insert_post($new_post);
    //Now that we have a new post ID update the associated field data
    foreach ($fields as $field) {
        if (array_key_exists($field, $data)) {
            update_field($field, $data[$field], $id);
        } else {
            return "<b>The field {$field} does not exist.</b>";
        }
    }
    return $id;
}
Esempio n. 7
0
function list_reps($type, $rep_plural, $search_sidebar)
{
    global $this_page, $PAGE, $DATA;
    $this_page = $type;
    $args = array();
    if ($type == 'peers') {
        $args['order'] = 'name';
    }
    $date = get_http_var('date');
    if ($date) {
        $date = parse_date($date);
        if ($date) {
            $DATA->set_page_metadata($this_page, 'title', $rep_plural . ', as on ' . format_date($date['iso'], LONGDATEFORMAT));
            $args['date'] = $date['iso'];
        }
    } elseif (get_http_var('all')) {
        $DATA->set_page_metadata($this_page, 'title', 'All ' . $rep_plural . ', including former ones');
        $args['all'] = true;
    } else {
        $DATA->set_page_metadata($this_page, 'title', 'All ' . $rep_plural);
    }
    if (get_http_var('f') != 'csv') {
        $PAGE->page_start();
        $PAGE->stripe_start();
        $format = 'html';
    } else {
        $format = 'csv';
    }
    $order = get_http_var('o');
    $orders = array('n' => 'name', 'f' => 'given_name', 'l' => 'family_name', 'c' => 'constituency', 'p' => 'party', 'd' => 'debates');
    if (array_key_exists($order, $orders)) {
        $args['order'] = $orders[$order];
    }
    $PEOPLE = new PEOPLE();
    $PEOPLE->display($type, $args, $format);
    if (get_http_var('f') != 'csv') {
        $PAGE->stripe_end(array(array('type' => 'include', 'content' => 'minisurvey'), array('type' => 'include', 'content' => 'people'), array('type' => 'include', 'content' => $search_sidebar)));
        $PAGE->page_end();
    }
}
Esempio n. 8
0
     // Update the 'approved' property
     $req = new Request();
     $approved = empty($_POST['approved']) ? 'false' : 'true';
     $query = 'UPDATE request SET approved=' . $approved . ' WHERE id=' . $_POST['rid'];
     $req->query($query);
     // What's the id of the person this job is assigned to?
     $user = new Users();
     $user->fullname = $_POST['assign_to'];
     $user->find();
     $aid = $user->uid;
     // Insert the new assignment
     $asn = new Assign();
     $asn->rid = $_POST['rid'];
     $asn->hours = $_POST['hours'];
     $asn->cost = str_replace('$', '', $_POST['cost']);
     $asn->complete = parse_date($_POST);
     $asn->aid = $aid;
     $asn->insert();
     header('Location: index.php');
 }
 // Initialize values!
 $name = '';
 $phone = '';
 $year = '';
 $month = '';
 $day = '';
 $desc = '';
 $checked = '';
 $id = isset($_GET['id']) ? $_GET['id'] : null;
 if ($id) {
     $req = new Request();
 public static function Get_summary_list($account1_id, $account2_id, $start_date, $end_date, &$summary_list)
 {
     $summary_list = array();
     $error = '';
     // VALIDATE
     $start_time = parse_date($start_date);
     $end_time = parse_date($end_date);
     if ($start_time == -1) {
         return 'Start date is invalid';
     } elseif ($end_time == -1) {
         return 'End date is invalid';
     }
     $start_date_sql = date('Y-m-d', $start_time);
     $end_date_sql = date('Y-m-d', $end_time);
     // Query the normal balance of the selected accounts
     $sql = "SELECT a.account_id, a.account_debit " . "FROM Accounts a \n" . "WHERE account_id IN (:account1_id, :account2_id) ";
     $pdo = db_connect_pdo();
     $ps = $pdo->prepare($sql);
     $ps->bindParam(':account1_id', $account1_id);
     $ps->bindParam(':account2_id', $account2_id);
     $success = $ps->execute();
     if (!$success) {
         return get_pdo_error($ps);
     }
     $account1_debit = 1;
     $account2_debit = 1;
     while ($row = $ps->fetch(PDO::FETCH_ASSOC)) {
         if ($row['account_id'] == $account1_id) {
             $account1_debit = $row['account_debit'];
         } elseif ($row['account_id'] == $account2_id) {
             $account2_debit = $row['account_debit'];
         }
     }
     // SQL statement: group the summary by month & year (once per account)
     for ($i = 0; $i < 2; $i++) {
         $group_sql = "month(t.accounting_date), year(t.accounting_date) ";
         $month_sql = "month(t.accounting_date) as accounting_month, ";
         if ($i == 0 || $i == 2) {
             $account_id = $account1_id;
             $account_debit = $account1_debit;
         } elseif ($i == 1 || $i == 3) {
             $account_id = $account2_id;
             $account_debit = $account2_debit;
         }
         if ($i == 2 || $i == 3) {
             // yearly summary
             $group_sql = "year(t.accounting_date) \n";
             // count as month 13, as this sorts after december
             $month_sql = "13 as accounting_month, ";
         }
         $sql = "SELECT sum(ledger_amount * a.account_debit * :account_debit) " . "  as account_sum, {$month_sql} " . "  year(t.accounting_date) as accounting_year \n" . "FROM Transactions t \n" . "INNER JOIN Ledger_Entries le on le.trans_id = t.trans_id \n" . "INNER JOIN Accounts a on a.account_id = le.account_id \n" . "LEFT JOIN Accounts a2 on a.account_parent_id = a2.account_id \n" . "WHERE (a.account_id = :account_id OR " . "  a2.account_id = :account_id OR " . "  a2.account_parent_id = :account_id) " . "  and t.accounting_date >= :start_date_sql " . "  and t.accounting_date <= :end_date_sql \n" . "GROUP BY {$group_sql} \n" . "ORDER BY year(accounting_date) ASC, month(accounting_date) ASC ";
         $ps = $pdo->prepare($sql);
         $ps->bindParam(':account_debit', $account_debit);
         $ps->bindParam(':account_id', $account_id);
         $ps->bindParam(':start_date_sql', $start_date_sql);
         $ps->bindParam(':end_date_sql', $end_date_sql);
         $success = $ps->execute();
         if (!$success) {
             return get_pdo_error($ps);
         }
         $ytd_total = 0;
         $last_key = '';
         $last_year = 0;
         // (YYYY-MM) => (month, year, account1_sum, account2_sum)
         while ($row = $ps->fetch(PDO::FETCH_ASSOC)) {
             $summary_year = $row['accounting_year'];
             if ($summary_year != $last_year) {
                 // new year; reset the YTD totals
                 $ytd_total = 0;
             }
             $summary_month = $row['accounting_month'];
             $summary_month = str_pad($summary_month, 2, '0', STR_PAD_LEFT);
             $key = $summary_year . '-' . $summary_month;
             $ytd_total += $row['account_sum'];
             if ($i == 0 || $i == 2) {
                 // account 1 query (always a new list item)
                 $summary_list[$key] = array((int) $summary_month, $summary_year, $row['account_sum'], 0, $ytd_total, 0);
                 if ($last_key != '') {
                     // for account YTD, when not on first row,
                     // grab last month's value as default.
                     // This is in case this month has no data;
                     // the YTD should still stay the same.
                     //						$summary_list[$key][3] =
                     //							$summary_list[$last_key][3];
                     //						$summary_list[$key][5] =
                     //							$summary_list[$last_key][5];
                 }
             } else {
                 // account2: check for existing list item
                 if (array_key_exists($key, $summary_list)) {
                     $summary_list[$key][3] = $row['account_sum'];
                     $summary_list[$key][5] = $ytd_total;
                 } else {
                     // no existing data for this month
                     $summary_list[$key] = array((int) $summary_month, $summary_year, 0, $row['account_sum'], 0, $ytd_total);
                 }
             }
             $last_key = $key;
             $last_year = $summary_year;
         }
         // row loop
     }
     // account loop
     $pdo = null;
     // re-sort by the key in descending order
     ksort($summary_list);
     return $error;
 }
Esempio n. 10
0
function process_csv($filename, $override_imports, $override_expiry, $separator = ',', $quote = '"')
{
    $sql = e107::getDb();
    $pref['ban_durations'] = e107::getPref('ban_durations');
    $mes = e107::getMessage();
    //  echo "Read CSV: {$filename} separator: {$separator}, quote: {$quote}  override imports: {$override_imports}  override expiry: {$override_expiry}<br />";
    // Renumber imported bans
    if ($override_imports) {
        $sql->db_Update('banlist', "`banlist_bantype`=" . eIPHandler::BAN_TYPE_TEMPORARY . " WHERE `banlist_bantype` = " . eIPHandler::BAN_TYPE_IMPORTED);
    }
    $temp = file($filename);
    $line_num = 0;
    foreach ($temp as $line) {
        // Process one entry
        $line = trim($line);
        $line_num++;
        if ($line) {
            $fields = explode($separator, $line);
            $field_num = 0;
            $field_list = array('banlist_bantype' => eIPHandler::BAN_TYPE_IMPORTED);
            foreach ($fields as $f) {
                $f = trim($f);
                if (substr($f, 0, 1) == $quote) {
                    if (substr($f, -1, 1) == $quote) {
                        // Strip quotes
                        $f = substr($f, 1, -1);
                        // Strip off the quotes
                    } else {
                        $mes->addError(BANLAN_49 . $line_num);
                        return BANLAN_49 . $line_num;
                    }
                }
                // Now handle the field
                $field_num++;
                switch ($field_num) {
                    case 1:
                        // IP address
                        $field_list['banlist_ip'] = e107::getIPHandler()->ipEncode($f);
                        break;
                    case 2:
                        // Original date of ban
                        $field_list['banlist_datestamp'] = parse_date($f);
                        break;
                    case 3:
                        // Expiry of ban - depends on $override_expiry
                        if ($override_expiry) {
                            $field_list['banlist_banexpires'] = parse_date($f);
                        } else {
                            // Use default ban time from now
                            $field_list['banlist_banexpires'] = $pref['ban_durations'][eIPHandler::BAN_TYPE_IMPORTED] ? time() + 60 * 60 * $pref['ban_durations'][eIPHandler::BAN_TYPE_IMPORTED] : 0;
                        }
                        break;
                    case 4:
                        // Original ban type - we always ignore this and force to 'imported'
                        break;
                    case 5:
                        // Ban reason originally generated by E107
                        $field_list['banlist_reason'] = $f;
                        break;
                    case 6:
                        // Any user notes added
                        $field_list['banlist_notes'] = $f;
                        break;
                    default:
                        // Just ignore any others
                }
            }
            $qry = "REPLACE INTO `#banlist` (" . implode(',', array_keys($field_list)) . ") values ('" . implode("', '", $field_list) . "')";
            //	  echo count($field_list)." elements, query: ".$qry."<br />";
            if (!$sql->db_Select_gen($qry)) {
                $mes->addError(BANLAN_50 . $line_num);
                return BANLAN_50 . $line_num;
            }
        }
    }
    // Success here - may need to delete old imported bans
    if ($override_imports) {
        $sql->db_Delete('banlist', "`banlist_bantype` = " . eIPHandler::BAN_TYPE_TEMPORARY);
    }
    @unlink($filename);
    // Delete file once done
    $mes->addSuccess(str_replace('--NUM--', $line_num, BANLAN_51) . $filename);
    return str_replace('--NUM--', $line_num, BANLAN_51) . $filename;
}
Esempio n. 11
0
function era_callback(&$out)
{
    global $encount, $debug, $claim_status_codes, $adjustment_reasons, $remark_codes;
    global $invoice_total, $last_code, $paydate, $INTEGRATED_AR;
    global $InsertionId;
    //last inserted ID of
    // Some heading information.
    $chk_123 = $out['check_number'];
    $chk_123 = str_replace(' ', '_', $chk_123);
    if (isset($_REQUEST['chk' . $chk_123])) {
        if ($encount == 0) {
            writeMessageLine('#ffffff', 'infdetail', "Payer: " . htmlspecialchars($out['payer_name'], ENT_QUOTES));
            if ($debug) {
                writeMessageLine('#ffffff', 'infdetail', "WITHOUT UPDATE is selected; no changes will be applied.");
            }
        }
        $last_code = '';
        $invoice_total = 0.0;
        $bgcolor = ++$encount & 1 ? "#ddddff" : "#ffdddd";
        list($pid, $encounter, $invnumber) = slInvoiceNumber($out);
        // Get details, if we have them, for the invoice.
        $inverror = true;
        $codes = array();
        if ($pid && $encounter) {
            // Get invoice data into $arrow or $ferow.
            if ($INTEGRATED_AR) {
                $ferow = sqlQuery("SELECT e.*, p.fname, p.mname, p.lname " . "FROM form_encounter AS e, patient_data AS p WHERE " . "e.pid = '{$pid}' AND e.encounter = '{$encounter}' AND " . "p.pid = e.pid");
                if (empty($ferow)) {
                    $pid = $encounter = 0;
                    $invnumber = $out['our_claim_id'];
                } else {
                    $inverror = false;
                    $codes = ar_get_invoice_summary($pid, $encounter, true);
                    // $svcdate = substr($ferow['date'], 0, 10);
                }
            } else {
                $arres = SLQuery("SELECT ar.id, ar.notes, ar.shipvia, customer.name " . "FROM ar, customer WHERE ar.invnumber = '{$invnumber}' AND " . "customer.id = ar.customer_id");
                if ($sl_err) {
                    die($sl_err);
                }
                $arrow = SLGetRow($arres, 0);
                if ($arrow) {
                    $inverror = false;
                    $codes = get_invoice_summary($arrow['id'], true);
                } else {
                    // oops, no such invoice
                    $pid = $encounter = 0;
                    $invnumber = $out['our_claim_id'];
                }
            }
            // end not internal a/r
        }
        // Show the claim status.
        $csc = $out['claim_status_code'];
        $inslabel = 'Ins1';
        if ($csc == '1' || $csc == '19') {
            $inslabel = 'Ins1';
        }
        if ($csc == '2' || $csc == '20') {
            $inslabel = 'Ins2';
        }
        if ($csc == '3' || $csc == '21') {
            $inslabel = 'Ins3';
        }
        $primary = $inslabel == 'Ins1';
        writeMessageLine($bgcolor, 'infdetail', "Claim status {$csc}: " . $claim_status_codes[$csc]);
        // Show an error message if the claim is missing or already posted.
        if ($inverror) {
            writeMessageLine($bgcolor, 'errdetail', "The following claim is not in our database");
        } else {
            // Skip this test. Claims can get multiple CLPs from the same payer!
            //
            // $insdone = strtolower($arrow['shipvia']);
            // if (strpos($insdone, 'ins1') !== false) {
            //  $inverror = true;
            //  writeMessageLine($bgcolor, 'errdetail',
            //   "Primary insurance EOB was already posted for the following claim");
            // }
        }
        if ($csc == '4') {
            //Denial case, code is stored in the claims table for display in the billing manager screen with reason explained.
            $inverror = true;
            if (!$debug) {
                if ($pid && $encounter) {
                    $code_value = '';
                    foreach ($out['svc'] as $svc) {
                        foreach ($svc['adj'] as $adj) {
                            //Per code and modifier the reason will be showed in the billing manager.
                            $code_value .= $svc['code'] . '_' . $svc['mod'] . '_' . $adj['group_code'] . '_' . $adj['reason_code'] . ',';
                        }
                    }
                    $code_value = substr($code_value, 0, -1);
                    //We store the reason code to display it with description in the billing manager screen.
                    //process_file is used as for the denial case file name will not be there, and extra field(to store reason) can be avoided.
                    updateClaim(true, $pid, $encounter, $_REQUEST['InsId'], substr($inslabel, 3), 7, 0, $code_value);
                }
            }
            writeMessageLine($bgcolor, 'errdetail', "Not posting adjustments for denied claims, please follow up manually!");
        } else {
            if ($csc == '22') {
                $inverror = true;
                writeMessageLine($bgcolor, 'errdetail', "Payment reversals are not automated, please enter manually!");
            }
        }
        if ($out['warnings']) {
            writeMessageLine($bgcolor, 'infdetail', nl2br(rtrim($out['warnings'])));
        }
        // Simplify some claim attributes for cleaner code.
        $service_date = parse_date($out['dos']);
        $check_date = $paydate ? $paydate : parse_date($out['check_date']);
        $production_date = $paydate ? $paydate : parse_date($out['production_date']);
        if ($INTEGRATED_AR) {
            $insurance_id = arGetPayerID($pid, $service_date, substr($inslabel, 3));
            if (empty($ferow['lname'])) {
                $patient_name = $out['patient_fname'] . ' ' . $out['patient_lname'];
            } else {
                $patient_name = $ferow['fname'] . ' ' . $ferow['lname'];
            }
        } else {
            $insurance_id = 0;
            foreach ($codes as $cdata) {
                if ($cdata['ins']) {
                    $insurance_id = $cdata['ins'];
                    break;
                }
            }
            $patient_name = $arrow['name'] ? $arrow['name'] : $out['patient_fname'] . ' ' . $out['patient_lname'];
        }
        $error = $inverror;
        // This loops once for each service item in this claim.
        foreach ($out['svc'] as $svc) {
            // Treat a modifier in the remit data as part of the procedure key.
            // This key will then make its way into SQL-Ledger.
            $codekey = $svc['code'];
            if ($svc['mod']) {
                $codekey .= ':' . $svc['mod'];
            }
            $prev = $codes[$codekey];
            $codetype = '';
            //will hold code type, if exists
            // This reports detail lines already on file for this service item.
            if ($prev) {
                $codetype = $codes[$codekey]['code_type'];
                //store code type
                writeOldDetail($prev, $patient_name, $invnumber, $service_date, $codekey, $bgcolor);
                // Check for sanity in amount charged.
                $prevchg = sprintf("%.2f", $prev['chg'] + $prev['adj']);
                if ($prevchg != abs($svc['chg'])) {
                    writeMessageLine($bgcolor, 'errdetail', "EOB charge amount " . $svc['chg'] . " for this code does not match our invoice");
                    $error = true;
                }
                // Check for already-existing primary remittance activity.
                // Removed this check because it was not allowing for copays manually
                // entered into the invoice under a non-copay billing code.
                /****
                   if ((sprintf("%.2f",$prev['chg']) != sprintf("%.2f",$prev['bal']) ||
                       $prev['adj'] != 0) && $primary)
                   {
                       writeMessageLine($bgcolor, 'errdetail',
                           "This service item already has primary payments and/or adjustments!");
                       $error = true;
                   }
                   ****/
                unset($codes[$codekey]);
            } else {
                // This is not an error. If we are not in error mode and not debugging,
                // insert the service item into SL.  Then display it (in green if it
                // was inserted, or in red if we are in error mode).
                $description = "CPT4:{$codekey} Added by {$inslabel} {$production_date}";
                if (!$error && !$debug) {
                    if ($INTEGRATED_AR) {
                        arPostCharge($pid, $encounter, 0, $svc['chg'], 1, $service_date, $codekey, $description, $debug, '', $codetype);
                    } else {
                        slPostCharge($arrow['id'], $svc['chg'], 1, $service_date, $codekey, $insurance_id, $description, $debug);
                    }
                    $invoice_total += $svc['chg'];
                }
                $class = $error ? 'errdetail' : 'newdetail';
                writeDetailLine($bgcolor, $class, $patient_name, $invnumber, $codekey, $production_date, $description, $svc['chg'], $error ? '' : $invoice_total);
            }
            $class = $error ? 'errdetail' : 'newdetail';
            // Report Allowed Amount.
            if ($svc['allowed']) {
                // A problem here is that some payers will include an adjustment
                // reflecting the allowed amount, others not.  So here we need to
                // check if the adjustment exists, and if not then create it.  We
                // assume that any nonzero CO (Contractual Obligation) or PI
                // (Payer Initiated) adjustment is good enough.
                $contract_adj = sprintf("%.2f", $svc['chg'] - $svc['allowed']);
                foreach ($svc['adj'] as $adj) {
                    if (($adj['group_code'] == 'CO' || $adj['group_code'] == 'PI') && $adj['amount'] != 0) {
                        $contract_adj = 0;
                    }
                }
                if ($contract_adj > 0) {
                    $svc['adj'][] = array('group_code' => 'CO', 'reason_code' => 'A2', 'amount' => $contract_adj);
                }
                writeMessageLine($bgcolor, 'infdetail', 'Allowed amount is ' . sprintf("%.2f", $svc['allowed']));
            }
            // Report miscellaneous remarks.
            if ($svc['remark']) {
                $rmk = $svc['remark'];
                writeMessageLine($bgcolor, 'infdetail', "{$rmk}: " . $remark_codes[$rmk]);
            }
            // Post and report the payment for this service item from the ERA.
            // By the way a 'Claim' level payment is probably going to be negative,
            // i.e. a payment reversal.
            if ($svc['paid']) {
                if (!$error && !$debug) {
                    if ($INTEGRATED_AR) {
                        arPostPayment($pid, $encounter, $InsertionId[$out['check_number']], $svc['paid'], $codekey, substr($inslabel, 3), $out['check_number'], $debug, '', $codetype);
                    } else {
                        slPostPayment($arrow['id'], $svc['paid'], $check_date, "{$inslabel}/" . $out['check_number'], $codekey, $insurance_id, $debug);
                    }
                    $invoice_total -= $svc['paid'];
                }
                $description = "{$inslabel}/" . $out['check_number'] . ' payment';
                if ($svc['paid'] < 0) {
                    $description .= ' reversal';
                }
                writeDetailLine($bgcolor, $class, $patient_name, $invnumber, $codekey, $check_date, $description, 0 - $svc['paid'], $error ? '' : $invoice_total);
            }
            // Post and report adjustments from this ERA.  Posted adjustment reasons
            // must be 25 characters or less in order to fit on patient statements.
            foreach ($svc['adj'] as $adj) {
                $description = $adj['reason_code'] . ': ' . $adjustment_reasons[$adj['reason_code']];
                if ($adj['group_code'] == 'PR' || !$primary) {
                    // Group code PR is Patient Responsibility.  Enter these as zero
                    // adjustments to retain the note without crediting the claim.
                    if ($primary) {
                        /****
                                       $reason = 'Pt resp: '; // Reasons should be 25 chars or less.
                                       if ($adj['reason_code'] == '1') $reason = 'To deductible: ';
                                       else if ($adj['reason_code'] == '2') $reason = 'Coinsurance: ';
                                       else if ($adj['reason_code'] == '3') $reason = 'Co-pay: ';
                           ****/
                        $reason = "{$inslabel} ptresp: ";
                        // Reasons should be 25 chars or less.
                        if ($adj['reason_code'] == '1') {
                            $reason = "{$inslabel} dedbl: ";
                        } else {
                            if ($adj['reason_code'] == '2') {
                                $reason = "{$inslabel} coins: ";
                            } else {
                                if ($adj['reason_code'] == '3') {
                                    $reason = "{$inslabel} copay: ";
                                }
                            }
                        }
                    } else {
                        $reason = "{$inslabel} note " . $adj['reason_code'] . ': ';
                        /****
                                       $reason .= sprintf("%.2f", $adj['amount']);
                           ****/
                    }
                    $reason .= sprintf("%.2f", $adj['amount']);
                    // Post a zero-dollar adjustment just to save it as a comment.
                    if (!$error && !$debug) {
                        if ($INTEGRATED_AR) {
                            arPostAdjustment($pid, $encounter, $InsertionId[$out['check_number']], 0, $codekey, substr($inslabel, 3), $reason, $debug, '', $codetype);
                        } else {
                            slPostAdjustment($arrow['id'], 0, $production_date, $out['check_number'], $codekey, $insurance_id, $reason, $debug);
                        }
                    }
                    writeMessageLine($bgcolor, $class, $description . ' ' . sprintf("%.2f", $adj['amount']));
                } else {
                    if (!$error && !$debug) {
                        if ($INTEGRATED_AR) {
                            arPostAdjustment($pid, $encounter, $InsertionId[$out['check_number']], $adj['amount'], $codekey, substr($inslabel, 3), "Adjust code " . $adj['reason_code'], $debug, '', $codetype);
                        } else {
                            slPostAdjustment($arrow['id'], $adj['amount'], $production_date, $out['check_number'], $codekey, $insurance_id, "{$inslabel} adjust code " . $adj['reason_code'], $debug);
                        }
                        $invoice_total -= $adj['amount'];
                    }
                    writeDetailLine($bgcolor, $class, $patient_name, $invnumber, $codekey, $production_date, $description, 0 - $adj['amount'], $error ? '' : $invoice_total);
                }
            }
        }
        // End of service item
        // Report any existing service items not mentioned in the ERA, and
        // determine if any of them are still missing an insurance response
        // (if so, then insurance is not yet done with the claim).
        $insurance_done = true;
        foreach ($codes as $code => $prev) {
            // writeOldDetail($prev, $arrow['name'], $invnumber, $service_date, $code, $bgcolor);
            writeOldDetail($prev, $patient_name, $invnumber, $service_date, $code, $bgcolor);
            $got_response = false;
            foreach ($prev['dtl'] as $ddata) {
                if ($ddata['pmt'] || $ddata['rsn']) {
                    $got_response = true;
                }
            }
            if (!$got_response) {
                $insurance_done = false;
            }
        }
        // Cleanup: If all is well, mark Ins<x> done and check for secondary billing.
        if (!$error && !$debug && $insurance_done) {
            if ($INTEGRATED_AR) {
                $level_done = 0 + substr($inslabel, 3);
                if ($out['crossover'] == 1) {
                    //Automatic forward case.So need not again bill from the billing manager screen.
                    sqlStatement("UPDATE form_encounter " . "SET last_level_closed = {$level_done},last_level_billed=" . $level_done . " WHERE " . "pid = '{$pid}' AND encounter = '{$encounter}'");
                    writeMessageLine($bgcolor, 'infdetail', 'This claim is processed by Insurance ' . $level_done . ' and automatically forwarded to Insurance ' . ($level_done + 1) . ' for processing. ');
                } else {
                    "UPDATE form_encounter " . "SET last_level_closed = {$level_done} WHERE " . "pid = '{$pid}' AND encounter = '{$encounter}'";
                }
                // Check for secondary insurance.
                if ($primary && arGetPayerID($pid, $service_date, 2)) {
                    arSetupSecondary($pid, $encounter, $debug, $out['crossover']);
                    if ($out['crossover'] != 1) {
                        writeMessageLine($bgcolor, 'infdetail', 'This claim is now re-queued for secondary paper billing');
                    }
                }
            } else {
                $shipvia = 'Done: Ins1';
                if ($inslabel != 'Ins1') {
                    $shipvia .= ',Ins2';
                }
                if ($inslabel == 'Ins3') {
                    $shipvia .= ',Ins3';
                }
                $query = "UPDATE ar SET shipvia = '{$shipvia}' WHERE id = " . $arrow['id'];
                SLQuery($query);
                if ($sl_err) {
                    die($sl_err);
                }
                // Check for secondary insurance.
                $insgot = strtolower($arrow['notes']);
                if ($primary && strpos($insgot, 'ins2') !== false) {
                    slSetupSecondary($arrow['id'], $debug);
                    if ($out['crossover'] != 1) {
                        writeMessageLine($bgcolor, 'infdetail', 'This claim is now re-queued for secondary paper billing');
                    }
                }
            }
        }
    }
}
 function parse_date($date)
 {
     if (function_exists('parse_date')) {
         return parse_date($date);
     } else {
         $split_pattern = '[\\/\\-\\.]';
         if (preg_match("/(\\d{4}){$split_pattern}(\\d{1,2}){$split_pattern}(\\d{1,2})/", $date, $matches)) {
             return array('year' => $matches[1], 'month' => $matches[2], 'day' => $matches[3]);
         } else {
             return false;
         }
     }
 }
// set default vars
$dateArr = getdate();
// start: first of last year
// end: today
$start_time = mktime(0, 0, 0, 1, 1, $dateArr['year'] - 1);
$start_date = date('m/d/Y', $start_time);
$end_date = date('12/31/Y');
$account1_id = $_SESSION['default_summary1'];
$account2_id = $_SESSION['default_summary2'];
$net_multiplier = -1;
if (isset($_POST['calc'])) {
    $date_verify = parse_date($_POST['start_date']);
    if ($date_verify == -1) {
        $error = 'Bad start date';
    } else {
        $date_verify = parse_date($_POST['end_date']);
        if ($date_verify == -1) {
            $error = 'Bad end date';
        }
    }
    // refresh data
    if ($error == '') {
        // don't update dates unless valid
        $start_date = $_POST['start_date'];
        $end_date = $_POST['end_date'];
        $net_multiplier = (int) $_POST['net_multiplier'];
    }
    $account1_id = $_POST['account1_id'];
    $account2_id = $_POST['account2_id'];
}
// Add or subtract display vars
Esempio n. 14
0
/**
 * Find Nth (day) in (month) of (year)
 * Return timestamp for 2 AM of user's timezone - we use this for DST, and DST usually is effective at 2?
 */
function find_day_of_month($n, $day, $month, $year)
{
    global $time_zone_offset;
    $times_day_found = 0;
    $date_month = $month;
    $date = 1;
    while (($times_day_found < $n || $n == 'last') && $date_month == $month) {
        $time = parse_date("{$month} {$date}, {$year}");
        $date_month = date('M', $time + $time_zone_offset);
        $day_found = date('D', $time + $time_zone_offset);
        if ($day_found == $day) {
            $times_day_found++;
        }
        $date++;
    }
    return $time;
}
Esempio n. 15
0
                                    ?>
</a>.
			   </h5>
			   <p><?php 
                                    echo $row_bookmark['title'];
                                    ?>
</p>
			   <p><a href="<?php 
                                    echo $row_bookmark['url'];
                                    ?>
" target="_blank"><?php 
                                    echo $row_notes['url'];
                                    ?>
</a></p>
			   <p><i class="icon-time"></i>  <?php 
                                    echo parse_date($row_friends_activities_query['date']);
                                    ?>
 </p>
		 </div>
		 <?php 
                                    if ($_SESSION['logged'] == true) {
                                        vote_up($row_friends_activities_query['activity_tracker'], 'bookmark', $row_friends_activities_query['profile_ida']);
                                    }
                                    ?>
	</div>
 
 <?php 
                                }
                            }
                        }
                    }
Esempio n. 16
0
 function __construct($start_str, $end_str, $log_info = NULL)
 {
     $this->start = parse_date($start_str, null, $log_info);
     $this->end = parse_date($end_str, $this->start, $log_info);
 }
function api_getCommittee_date($date) {
	$db = new ParlDB;

	$date = parse_date($date);
	if ($date) $date = '"' . $date['iso'] . '"';
	else $date = 'date(now())';
	$q = $db->query("select distinct(dept) from moffice
		where source = 'chgpages/selctee'
		and from_date <= " . $date . ' and '
		. $date . ' <= to_date');
	if ($q->rows()) {
		for ($i=0; $i<$q->rows(); $i++) {
			$output['committees'][] = array(
				'name' => $q->field($i, 'dept')
			);
		}
		api_output($output);
	} else {
		api_error('No committees found');
	}
}
Esempio n. 18
0
<?php

if ($save && !$errors) {
    ?>
<script language="JavaScript">
    
<!--
      window.location="<?php 
    echo SITE_HTTP_ROOT;
    ?>
organizer/day/date/<?php 
    echo parse_date('{Y}-{m}-{d}', $event->start_date, true);
    ?>
/";
//-->
</script>
<?php 
} else {
    $start_date = '';
    $stop_date = '';
    $start_time = '10:00';
    $stop_time = '11:00';
    if ($event->start_date != '') {
        $start_date = format_date('{d}.{m}.{Y}', $event->start_date);
        if ($start_date == '00.00.0000') {
            $start_date = '';
        }
    }
    if ($event->stop_date != '') {
        $stop_date = format_date('{d}.{m}.{Y}', $event->stop_date);
        if ($stop_date == '00.00.0000') {
Esempio n. 19
0
//показывать время новости
$p_date = $news_conf->p_date;
//показывать дату новости
$img_height = $news_conf->img_height;
//высота для миникартинки новости
define('LIMIT_NEWS_ON_PAGE', $am_news);
if ($id > 0) {
    $news = new news();
    $news->news_id = $id;
    $news->Load();
    include SITE_FILE_ROOT . 'template/header.php';
    include SITE_FILE_ROOT . 'template/' . $STORAGE['module'] . '/' . $STORAGE['action'] . '-id.php';
    include SITE_FILE_ROOT . 'template/footer.php';
} else {
    if ($date) {
        $linedate = parse_date('{Y}-{m}-{d}', $date, true);
    } else {
        $linedate = date('Y-m-d', time());
    }
    $newses = array();
    $query = 'SELECT COUNT(*) as num FROM ' . TABLE_NEWS . ' WHERE news_date = \'' . $linedate . '\'  limit ' . LIMIT_NEWS_ON_PAGE;
    $db->query($query);
    $all_num = $db->value[0]['num'];
    if ($all_num < LIMIT_NEWS_ON_PAGE) {
        $query = 'SELECT * FROM ' . TABLE_NEWS . ' WHERE news_date <= \'' . $linedate . '\' ORDER BY news_id ASC  limit ' . LIMIT_NEWS_ON_PAGE;
        $db->query($query);
        $newses = $db->value;
    } else {
        $query = 'SELECT * FROM ' . TABLE_NEWS . ' WHERE news_date = \'' . $linedate . '\' ORDER BY news_id ASC  limit ' . LIMIT_NEWS_ON_PAGE;
        $db->query($query);
        $newses = $db->value;
Esempio n. 20
0
// Our items
$items = get_items($_GET['id']);
foreach ($items as &$item) {
    // The description
    if (isset($item['description'])) {
        if (appcast_info('format') == 'sparkledotnet' && appcast_info('formatVersion') == '0.1' || appcast_info('convertDescriptionToLink') === true) {
            // Don't override if we already have a link
            if (!isset($item['sparkle:releaseNotesLink'])) {
                $item['sparkle:releaseNotesLink'] = curPageURL() . '&amp;echo=' . urlencode($item['description']);
            }
        }
        unset($item['description']);
    }
    // The publish date
    if (isset($item['pubDate'])) {
        $item['pubDate'] = parse_date($item['pubDate']);
    }
    // Filesize and content type
    $cacheid = $item['enclosure']['_params']['url'];
    if (isset($item['enclosure']['_params']['type']) && isset($item['enclosure']['_params']['length'])) {
        //
    } elseif (!isset($data['cache'][$cacheid])) {
        $headers = get_remote_headers($item['enclosure']['_params']['url']);
        $type = get_content_type($headers);
        $length = get_content_length($headers);
        if (!$headers) {
            appcastr_die('Appcastr can\'t make a connection to <code>' . $item['enclosure']['url'] . '</code>, or the file doesn\'t exist.');
        } else {
            $item['enclosure']['_params']['type'] = $type;
            $item['enclosure']['_params']['length'] = $length;
            $data['cache'][$cacheid] = array('type' => $type, 'length' => $length);
Esempio n. 21
0
?>
</th>
			    </tr>
			  </thead>
			  <tbody>
			  	
			  	<?php 
$q = 'SELECT * FROM subscribers WHERE complaint = 1 AND last_campaign = ' . mysqli_real_escape_string($mysqli, $_GET['c']) . ' ORDER BY timestamp DESC LIMIT 10';
$r = mysqli_query($mysqli, $q);
if ($r && mysqli_num_rows($r) > 0) {
    while ($row = mysqli_fetch_array($r)) {
        $subscriber_id = stripslashes($row['id']);
        $name = stripslashes($row['name']);
        $email = stripslashes($row['email']);
        $listID = stripslashes($row['list']);
        $timestamp = parse_date($row['timestamp'], 'short', true);
        if ($name == '') {
            $name = '[' . _('No name') . ']';
        }
        $q2 = 'SELECT name FROM lists WHERE id = ' . $listID;
        $r2 = mysqli_query($mysqli, $q2);
        if ($r2 && mysqli_num_rows($r2) > 0) {
            while ($row = mysqli_fetch_array($r2)) {
                $list_name = stripslashes($row['name']);
            }
        }
        echo '
				  			
				  			<tr>
						      <td><a href="#subscriber-info" data-id="' . $subscriber_id . '" data-toggle="modal" class="subscriber-info">' . $name . '</a></td>
						      <td><a href="#subscriber-info" data-id="' . $subscriber_id . '" data-toggle="modal" class="subscriber-info">' . $email . '</a></td>
Esempio n. 22
0
     foreach ($SKUs as $SKU) {
         $SKUsFinal[] = "'" . $SKU . "'";
     }
     $s_sku = implode(",", $SKUsFinal);
     $sql_where .= " AND ( oi.order_id IN ( SELECT order_id FROM va_orders_items WHERE item_code IN (" . $s_sku . ") ) )";
 }
 if (strlen($s_category)) {
     $sql_where .= " AND ( oi.order_id IN ( SELECT order_id FROM va_orders_items WHERE item_id IN ( SELECT item_id FROM va_items_categories WHERE category_id=" . $db->tosql($s_category, INTEGER) . ") ) )";
 }
 //END customization
 if (strlen($s_sd)) {
     $s_sd_value = parse_date($s_sd, $date_edit_format, $date_errors);
     $sql_where .= " AND o.order_placed_date>=" . $db->tosql($s_sd_value, DATE);
 }
 if (strlen($s_ed)) {
     $end_date = parse_date($s_ed, $date_edit_format, $date_errors);
     $day_after_end = mktime(0, 0, 0, $end_date[MONTH], $end_date[DAY] + 1, $end_date[YEAR]);
     $sql_where .= " AND o.order_placed_date<" . $db->tosql($day_after_end, DATE);
 }
 if (strlen($s_os)) {
     $sql_where .= " AND o.order_status=" . $db->tosql($s_os, INTEGER);
 }
 if (strlen($s_ci)) {
     if ($order_info["show_delivery_country_id"] == 1) {
         $sql_where .= " AND o.delivery_country_id=" . $db->tosql($s_ci, INTEGER);
     } else {
         if ($order_info["show_country_id"] == 1) {
             $sql_where .= " AND o.country_id=" . $db->tosql($s_ci, INTEGER);
         }
     }
 }
Esempio n. 23
0
										});
									    </script>
								    </tr>
					  			';
            }
        } else {
            if ($error_stack != '') {
                $download_errors = ' | <a href="' . get_app_info('path') . '/includes/app/download-errors-csv.php?c=' . $id . '" title="' . _('Download CSV of emails that were not delivered to even after retrying') . '">' . $no_of_errors . ' ' . _('not delivered') . '</a>';
            } else {
                $download_errors = '';
            }
            echo '
				  				<tr id="' . $id . '">
							      <td><span class="label label-success">' . _('Sent') . '</span></a> <a href="' . get_app_info('path') . '/report?i=' . get_app_info('app') . '&c=' . $id . '" title="' . _('View report for this campaign') . '">' . $title . '</a>' . $download_errors . '</td>
							      <td>' . number_format($recipients) . '</td>
							      <td>' . parse_date($sent, 'long', true) . '</td>
							      <td><span class="label">' . $percentage_opened . '%</span> ' . number_format($opens_unique) . ' ' . _('opened') . '</td>
							      <td><span class="label">' . $percentage_clicked . '%</span> ' . number_format(get_click_percentage($id)) . ' ' . _('clicked') . '</td>
							      <td><a href="#duplicate-modal" title="" id="duplicate-btn-' . $id . '" data-toggle="modal" data-cid="' . $id . '" class="duplicate-btn"><i class="icon icon-copy"></i></a></td>
							      <td><a href="javascript:void(0)" title="Delete ' . $title . '?" id="delete-btn-' . $id . '" class="delete-campaign"><i class="icon icon-trash"></i></a></td>
							      <script type="text/javascript">
							    	$("#delete-btn-' . $id . '").click(function(e){
									e.preventDefault(); 
									c = confirm(\'' . _('Confirm delete') . ' ' . addslashes($title) . '?\');
									if(c)
									{
										$.post("includes/campaigns/delete.php", { campaign_id: ' . $id . ' },
										  function(data) {
										      if(data)
										      {
										      	$("#' . $id . '").fadeOut();
Esempio n. 24
0
<?php

$id = intval(get_request_variable('id', 0));
$kio = get_request_variable('kio', '');
$kio_id = get_request_variable('kio_id', 0);
$ika_id = get_request_variable('ika_id', 0);
$exec_id = get_request_variable('exec_id', 0);
$from_id = get_request_variable('from_id', 0);
$jr_work = get_request_variable('jr_work', 2);
$jr_state = get_request_variable('jr_state', '');
$date = get_request_variable('date', '');
$date2 = get_request_variable('date2', '');
$start_time = get_request_variable('start_time', '');
$stop_time = get_request_variable('stop_time', '');
$date = parse_date('{Y}-{m}-{d}', $date, false);
$date2 = parse_date('{Y}-{m}-{d}', $date2, false);
$description = get_request_variable('description', '');
if ($id == 0) {
    $jr_state = 1;
}
$save = get_request_variable('save', '');
$_REQUEST['callback'] = get_request_variable('callback', '');
$db = db_class::get_instance();
$journal = new journal();
$journal->id = $id;
if ($id > 0) {
    if (!$journal->Load()) {
        $journal->id = 0;
    }
}
for ($i = 0; $i < count($STORAGE['menu']); $i++) {
Esempio n. 25
0
# vim:sw=4:ts=4:et:nowrap
include_once "../../includes/easyparliament/init.php";
include_once INCLUDESPATH . "easyparliament/member.php";
include_once INCLUDESPATH . "easyparliament/glossary.php";
// From http://cvs.sourceforge.net/viewcvs.py/publicwhip/publicwhip/website/
include_once INCLUDESPATH . "postcode.inc";
if (get_http_var('s') != '' || get_http_var('pid') != '') {
    if (get_http_var('pid') == 16407) {
        header('Location: /search/?pid=10133');
        exit;
    }
    // We're searching for something.
    $this_page = 'search';
    $searchstring = trim(get_http_var('s'));
    $searchstring = filter_user_input($searchstring, 'strict');
    $time = parse_date($searchstring);
    if ($time['iso']) {
        header('Location: /hansard/?d=' . $time['iso']);
        exit;
    }
    $searchspeaker = trim(get_http_var('pid'));
    if ($searchspeaker) {
        $searchstring .= ($searchstring ? ' ' : '') . 'speaker:' . $searchspeaker;
    }
    $searchmajor = trim(get_http_var('section'));
    if (!$searchmajor) {
        // Legacy URLs used maj
        $searchmajor = trim(get_http_var('maj'));
    }
    if ($searchmajor) {
        $searchstring .= " section:" . $searchmajor;
Esempio n. 26
0
function importTabFilePBrown()
{
    //global $mysqli;
    $file = NULL;
    try {
        $file = new SplFileObject("uploads/upload-p-brown.txt");
    } catch (Exception $error) {
        echo '<div class="jumbotron"><h1 class="text-danger">Unable to open uploaded file. Please try again.</h1><p>' . $error->getMessage() . '</p></div>';
        return;
    }
    $counter = 0;
    while ($line = $file->fgets()) {
        if ($counter++ == 0) {
            continue;
        }
        //discard first line because it only contains headers
        $fields = explode("\t", $line);
        $alternativeTitles = array($fields[1], $fields[2]);
        //$parsed_date = parse_date('1765 - 1775');
        $subjectHeadings = parseSubjectHeadings($fields[5]);
        $parsedDate = parse_date('1765 - 1775');
        //the following lines combine several fields into the notes field for solr
        $notes = '';
        //$fields[14]; //digitization specifications
        $notes = $notes . (trim($fields[17]) != '') ? 'Scanner technician: ' . $fields[17] . ' ' : '';
        $notes = $notes . (trim($fields[18]) != '') ? 'Metadata cataloguer: ' . $fields[18] . ' ' : '';
        $notes = $notes . (trim($fields[19]) != '') ? 'Collection administrator: ' . $fields[19] . ' ' : '';
        $notes = $notes . (trim($fields[20]) != '') ? 'Collection maintenance: ' . $fields[20] . ' ' : '';
        $document = array('title' => $fields[0], 'shelfmark' => $fields[4], 'subject_heading' => $subjectHeadings, 'language' => $fields[6], 'archive' => $fields[7], 'contributing_institution' => $fields[9], 'use_permissions' => trim($fields[10]), 'type_content' => $fields[11], 'file_format' => $fields[12], 'type_digital' => $fields[13], 'description' => $fields[14], 'year_begin' => $parsedDate['year_begin'], 'month_begin' => $parsedDate['month_begin'], 'day_begin' => $parsedDate['day_begin'], 'year_end' => $parsedDate['year_end'], 'month_end' => $parsedDate['month_end'], 'day_end' => $parsedDate['day_end'], 'years' => $parsedDate['years'], 'date_digital' => $fields[15], 'geolocation_human' => $fields[21] . (trim($fields[22]) != '') ? ' - ' . $fields[22] : '', 'id' => $fields[26], 'url' => $fields[26], 'notes' => $notes);
        indexDocument($document);
        //$date_parsed = parse_date($date);
        //$date_digital_parsed = parse_date($date_digital);
    }
}
Esempio n. 27
0
	function get_criteria_clause($lhs = true, $operand = true, $rhs = true, $rhs1 = false, $rhs2 = false, $add_del = true)
	{

		$cls = "";

		if ( $this -> _use == "SHOW/HIDE-and-GROUPBY") $add_del = false;

		if ( $this->column_value == "(ALL)" )
			return $cls;

		if ( $this->column_value == "(NOTFOUND)" )
		{
			$cls = " AND 1 = 0";
			return $cls;
		}

		if ( !$this->column_value ) 
		{
			return ($cls);
		}

		$del = '';

		switch($this->criteria_type)
		{

			case "ANY":
			case "ANYCHAR":
			case "TEXTFIELD":
				if ( $add_del )
					$del = $this->get_value_delimiter();

				$extract= explode(',', $this->column_value);
				if ( is_array($extract) )
				{
					$ct = 0;
					foreach ( $extract as $col )
					{
						if ( is_string($col) )
						{
							$col = trim($col);
						}
	
						if ( !$col )
							continue;

						if ( $col == "(ALL)" )
						{
							continue;
						}

						if ( $ct == 0 )
						{
							if ( $lhs )
							{
								//$cls .= " XX".$this->table_name.".".$this->column_name;
								$cls .= " AND ".$this->column_name;
							}
							if ( $rhs )
							{
								if ( $operand )
									$cls .= " IN (";
								$cls .= $del.$col.$del;
							}
						}
						else
							if ( $rhs )
								$cls .= ",".$del.$col.$del;
						$ct++;
					}

					if ( $ct > 0 && $rhs )
						if ( $operand )
							$cls .= " )";
				}
				else
				{
					if ( $lhs )
					{
						if ( $this->table_name  && $this->column_name )
							$cls .= " AND ".$this->table_name.".".$this->column_name;
						else 
							if ( $this->column_name )
								$cls .= " AND ".$this->column_name;
					}
					if ( $rhs )
						if ( $operand )
							$cls .= " =".$del.$this->column_value.$del;
						else
							$cls .= $del.$this->column_value.$del;
				}
				break;

			case "LIST":
				if ( $add_del )
					$del = $this->get_value_delimiter();

				if ( !is_array($this->column_value) )
					$this->column_value = explode(',', $this->column_value);

				if ( is_array($this->column_value) )
				{
					$ct = 0;
					foreach ( $this->column_value as $col )
					{
						if ( is_string($col) )
						{
							$col = trim($col);
						}

						if ( $col == "(ALL)" )
						{
							continue;
						}

						if ( $ct == 0 )
						{
							if ( $lhs )
							{
								if ( $this->table_name  && $this->column_name )
									$cls .= " AND ".$this->table_name.".".$this->column_name;
								else 
									if ( $this->column_name )
										$cls .= " AND ".$this->column_name;
							}
							if ( $rhs )
							{
								if ( $operand )
									$cls .= " IN (";
								$cls .= $del.$col.$del;
							}
						}
						else
							if ( $rhs )
								$cls .= ",".$del.$col.$del;
						$ct++;
					}

					if ( $ct > 0 )
						if ( $operand )
							$cls .= " )";
				}
				else
				{
					if ( $lhs )
					{
						if ( $this->table_name  && $this->column_name )
							$cls .= " AND ".$this->table_name.".".$this->column_name;
						else 
							if ( $this->column_name )
								$cls .= " AND ".$this->column_name;
					}
					if ( $rhs )
					{
						if ( $operand )
							$cls .= " =".$del.$this->column_value.$del;
						else
							$cls .= $del.$this->column_value.$del;
					}
				}
				break;
				
			case "DATE":
				$cls = "";
				if ( $this->column_value )
				{
					$val1 = parse_date($this->column_value, false, SW_PREP_DATEFORMAT);
					$val1 = convertYMDtoLocal($val1, SW_PREP_DATEFORMAT, SW_DB_DATEFORMAT);
					if ( $lhs )
					{
						if ( $this->table_name  && $this->column_name )
							$cls .= " AND ".$this->table_name.".".$this->column_name;
						else 
							if ( $this->column_name )
								$cls .= " AND ".$this->column_name;
					}
					if ( $add_del )
						$del = $this->get_value_delimiter();

					if ( $rhs )
					{
						if ( $operand )
							$cls .= " = ";
						$cls .= $del.$val1.$del;
					}
				}
				break;
				
			case "DATERANGE":
				$cls = "";
				if ( $this->column_value )
				{
                    // If daterange value here is a range in a single value then its been
                    // run directly from command line and needs splitting up using "-"


					$val1 = parse_date($this->column_value,false, SW_PREP_DATEFORMAT);
					$val2 = parse_date($this->column_value2,false, SW_PREP_DATEFORMAT);
					$val1 = convertYMDtoLocal($val1, SW_PREP_DATEFORMAT, SW_DB_DATEFORMAT);
					$val2 = convertYMDtoLocal($val2, SW_PREP_DATEFORMAT, SW_DB_DATEFORMAT);
					if ( $lhs )
					{	
						if ( $this->table_name  && $this->column_name )
							$cls .= " AND ".$this->table_name.".".$this->column_name;
						else 
							if ( $this->column_name )
								$cls .= " AND ".$this->column_name;
					}

					if ( $add_del )
						$del = $this->get_value_delimiter();
					if ( $rhs )
					{
						$cls .= " BETWEEN ";
						//$cls .= $del.$this->column_value.$del;
						$cls .= $del.$val1.$del;
						$cls .= " AND ";
						//$cls .= $del.$this->column_value2.$del;
						$cls .= $del.$val2.$del;
					}
					if ( $rhs1 )
					{
						$cls = $del.$val1.$del;
					}
					if ( $rhs2 )
					{
						$cls = $del.$val2.$del;
					}
				}
				break;
				
			case "LOOKUP":
				if ( $add_del )
					$del = $this->get_value_delimiter();

				if ( !is_array($this->column_value) )
					$this->column_value = explode(',', $this->column_value);

				if ( is_array($this->column_value) )
				{
					$ct = 0;
					foreach ( $this->column_value as $col )
					{
						if ( is_string($col) )
						{
							$col = trim($col);
						}

						if ( $col == "(ALL)" )
						{
							continue;
						}

						if ( $ct == 0 )
						{
							if ( $lhs )
							{
								if ( $this->table_name  && $this->column_name )
									$cls .= " AND ".$this->table_name.".".$this->column_name;
								else 
									if ( $this->column_name )
										$cls .= " AND ".$this->column_name;
							}
							if ( $rhs )
							{
								if ( $operand )
									$cls .= " IN (";
								$cls .= $del.$col.$del;
							}
						}
						else
							if ( $rhs )
								$cls .= ",".$del.$col.$del;
						$ct++;
					}

					if ( $ct > 0 )
						if ( $operand )
							$cls .= " )";
				}
				else
				{
					if ( $lhs )
					{
						if ( $this->table_name  && $this->column_name )
							$cls .= " AND ".$this->table_name.".".$this->column_name;
						else 
							if ( $this->column_name )
								$cls .= " AND ".$this->column_name;
					}
					if ( $rhs )
					{
						if ( $operand )
							$cls .= " =".$del.$this->column_value.$del;
						else
							$cls .= $del.$this->column_value.$del;
					}
				}
				break;
				
			default:
				break;
		}

		return($cls);
	}
Esempio n. 28
0
<?php

require_once 'Request.php';
require_once 'check_cookie.php';
require_once 'show_list.php';
if (check_cookie($_SERVER['PHP_SELF'], null)) {
    if (!empty($_POST)) {
        $req = new Request();
        $req->uid = $_COOKIE['uid'];
        $req->name = $_POST['name'];
        // Remove '-' from phone number.
        $req->phone = str_replace('-', '', $_POST['phone']);
        $req->description = $_POST['description'];
        // Force date into correct format.
        $req->deadline = parse_date($_POST);
        $req->insert();
        header('Location: index.php?conf=true');
    }
    ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Job Request Form</title>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="jquery-1.7.min.js"></script>
<script type="text/javascript" src="validator.js"></script>
<script type="text/javascript" src="validate_request.js"></script>
</head>
<body onload="loadEventHandlers();">
<?php 
Esempio n. 29
0
    if (!trim($stop_date)) {
        $stop_date = $start_date;
    }
    $event->stop_date = parse_date('{Y}-{m}-{d}', $stop_date, false);
    $wholeday = get_request_variable('wholeday', '');
    if ($wholeday) {
        $event->start_time = null;
        $event->stop_time = null;
    } else {
        $start_time = get_request_variable('start_time', date('H:i'));
        $event->start_time = parse_time('{H}:{i}', $start_time);
        $stop_time = get_request_variable('stop_time', date('H:i'));
        $event->stop_time = parse_time('{H}:{i}', $stop_time);
    }
    $errors = $event->IsValidData();
    if (count($errors) == 0) {
        $event->start_date = parse_date('{Y}-{m}-{d}', $start_date, true);
        $event->stop_date = parse_date('{Y}-{m}-{d}', $stop_date, true);
        $db->begin();
        $event->Save();
        $db->commit();
    }
}
if ($event->id_event == 0) {
    $event->start_date = $start_date;
    $event->stop_date = $stop_date;
}
$wholeday = $event->start_time == '';
include SITE_FILE_ROOT . 'template/header.php';
include SITE_FILE_ROOT . 'template/' . $STORAGE['module'] . '/' . $STORAGE['action'] . '.php';
include SITE_FILE_ROOT . 'template/footer.php';
Esempio n. 30
0
    
    <div class="row write-header">
	    <div class="large-8 large-centered columns">
	
	        <h2>Which Lord would you like to write to?</h2>
	
	    </div>
	</div>
	
	<div class="row">
	    <div class="large-12 columns">
		
<?php 
// Date of birth
if ($date = get_http_var('d')) {
    $date = parse_date($date);
    if (isset($date['epoch'])) {
        $f = file('../phplib/DoBsP.bsv');
        $matches = array();
        foreach ($f as $r) {
            list($id, $dob) = explode('|', $r);
            $dob = preg_replace('# \\d+$#', '', $dob);
            if (!$dob) {
                continue;
            }
            $d = strtotime($dob);
            if (date('d/m', $date['epoch']) == date('d/m', strtotime($dob))) {
                $ids = dadem_get_same_person('uk.org.publicwhip/person/' . $id);
                if (dadem_get_error($ids)) {
                    continue;
                }