Fixes for live environment and updates to admin/service/update

This commit is contained in:
Deon George 2011-07-22 11:04:20 +10:00
parent 27cdab1fe4
commit c8c4c5176d
41 changed files with 2457 additions and 82 deletions

View File

@ -0,0 +1,232 @@
/* The main calendar widget. DIV containing a table. */
div.calendar { position: relative; }
.calendar, .calendar table {
border: 1px solid #556;
font-size: 11px;
color: #000;
cursor: default;
background: #eef;
font-family: tahoma,verdana,sans-serif;
}
/* Header part -- contains navigation buttons and day names. */
.calendar .button { /* "<<", "<", ">", ">>" buttons have this class */
text-align: center; /* They are the navigation buttons */
padding: 2px; /* Make the buttons seem like they're pressing */
}
.calendar .nav {
background: #778 url(dhtml.menuarrow.gif) no-repeat 100% 100%;
}
.calendar thead .title { /* This holds the current "month, year" */
font-weight: bold; /* Pressing it will take you to the current date */
text-align: center;
background: #fff;
color: #000;
padding: 2px;
}
.calendar thead .headrow { /* Row <TR> containing navigation buttons */
background: #778;
color: #fff;
}
.calendar thead .daynames { /* Row <TR> containing the day names */
background: #bdf;
}
.calendar thead .name { /* Cells <TD> containing the day names */
border-bottom: 1px solid #556;
padding: 2px;
text-align: center;
color: #000;
}
.calendar thead .weekend { /* How a weekend day name shows in header */
color: #a66;
}
.calendar thead .hilite { /* How do the buttons in header appear when hover */
background-color: #aaf;
color: #000;
border: 1px solid #04f;
padding: 1px;
}
.calendar thead .active { /* Active (pressed) buttons in header */
background-color: #77c;
padding: 2px 0px 0px 2px;
}
/* The body part -- contains all the days in month. */
.calendar tbody .day { /* Cells <TD> containing month days dates */
width: 2em;
color: #456;
text-align: right;
padding: 2px 4px 2px 2px;
}
.calendar tbody .day.othermonth {
font-size: 80%;
color: #bbb;
}
.calendar tbody .day.othermonth.oweekend {
color: #fbb;
}
.calendar table .wn {
padding: 2px 3px 2px 2px;
border-right: 1px solid #000;
background: #bdf;
}
.calendar tbody .rowhilite td {
background: #def;
}
.calendar tbody .rowhilite td.wn {
background: #eef;
}
.calendar tbody td.hilite { /* Hovered cells <TD> */
background: #def;
padding: 1px 3px 1px 1px;
border: 1px solid #bbb;
}
.calendar tbody td.active { /* Active (pressed) cells <TD> */
background: #cde;
padding: 2px 2px 0px 2px;
}
.calendar tbody td.selected { /* Cell showing today date */
font-weight: bold;
border: 1px solid #000;
padding: 1px 3px 1px 1px;
background: #fff;
color: #000;
}
.calendar tbody td.weekend { /* Cells showing weekend days */
color: #a66;
}
.calendar tbody td.today { /* Cell showing selected date */
font-weight: bold;
color: #00f;
}
.calendar tbody .disabled { color: #999; }
.calendar tbody .emptycell { /* Empty cells (the best is to hide them) */
visibility: hidden;
}
.calendar tbody .emptyrow { /* Empty row (some months need less than 6 rows) */
display: none;
}
/* The footer part -- status bar and "Close" button */
.calendar tfoot .footrow { /* The <TR> in footer (only one right now) */
text-align: center;
background: #556;
color: #fff;
}
.calendar tfoot .ttip { /* Tooltip (status bar) cell <TD> */
background: #fff;
color: #445;
border-top: 1px solid #556;
padding: 1px;
}
.calendar tfoot .hilite { /* Hover style for buttons in footer */
background: #aaf;
border: 1px solid #04f;
color: #000;
padding: 1px;
}
.calendar tfoot .active { /* Active (pressed) style for buttons in footer */
background: #77c;
padding: 2px 0px 0px 2px;
}
/* Combo boxes (menus that display months/years for direct selection) */
.calendar .combo {
position: absolute;
display: none;
top: 0px;
left: 0px;
width: 4em;
cursor: default;
border: 1px solid #655;
background: #def;
color: #000;
font-size: 90%;
z-index: 100;
}
.calendar .combo .label,
.calendar .combo .label-IEfix {
text-align: center;
padding: 1px;
}
.calendar .combo .label-IEfix {
width: 4em;
}
.calendar .combo .hilite {
background: #acf;
}
.calendar .combo .active {
border-top: 1px solid #46a;
border-bottom: 1px solid #46a;
background: #eef;
font-weight: bold;
}
.calendar td.time {
border-top: 1px solid #000;
padding: 1px 0px;
text-align: center;
background-color: #f4f0e8;
}
.calendar td.time .hour,
.calendar td.time .minute,
.calendar td.time .ampm {
padding: 0px 3px 0px 4px;
border: 1px solid #889;
font-weight: bold;
background-color: #fff;
}
.calendar td.time .ampm {
text-align: center;
}
.calendar td.time .colon {
padding: 0px 2px 0px 3px;
font-weight: bold;
}
.calendar td.time span.hilite {
border-color: #000;
background-color: #667;
color: #fff;
}
.calendar td.time span.active {
border-color: #f00;
background-color: #000;
color: #0f0;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 B

View File

@ -0,0 +1,9 @@
/*
* Calendar EN language
* Author: Mihai Bazon, <mihai_bazon@yahoo.com>
*/
Calendar._DN=new Array
("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday");Calendar._SDN=new Array
("Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sun");Calendar._FD=0;Calendar._MN=new Array
("January","February","March","April","May","June","July","August","September","October","November","December");Calendar._SMN=new Array
("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");Calendar._TT={};Calendar._TT["INFO"]="About the calendar";Calendar._TT["ABOUT"]="DHTML Date/Time Selector\n"+"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n"+"For latest version visit: http://www.dynarch.com/projects/calendar/\n"+"Distributed under GNU LGPL. See http://gnu.org/licenses/lgpl.html for details."+"\n\n"+"Date selection:\n"+"- Use the \xab, \xbb buttons to select year\n"+"- Use the "+String.fromCharCode(0x2039)+", "+String.fromCharCode(0x203a)+" buttons to select month\n"+"- Hold mouse button on any of the above buttons for faster selection.";Calendar._TT["ABOUT_TIME"]="\n\n"+"Time selection:\n"+"- Click on any of the time parts to increase it\n"+"- or Shift-click to decrease it\n"+"- or click and drag for faster selection.";Calendar._TT["PREV_YEAR"]="Prev. year (hold for menu)";Calendar._TT["PREV_MONTH"]="Prev. month (hold for menu)";Calendar._TT["GO_TODAY"]="Go Today";Calendar._TT["NEXT_MONTH"]="Next month (hold for menu)";Calendar._TT["NEXT_YEAR"]="Next year (hold for menu)";Calendar._TT["SEL_DATE"]="Select date";Calendar._TT["DRAG_TO_MOVE"]="Drag to move";Calendar._TT["PART_TODAY"]=" (today)";Calendar._TT["DAY_FIRST"]="Display %s first";Calendar._TT["WEEKEND"]="0,6";Calendar._TT["CLOSE"]="Close";Calendar._TT["TODAY"]="Today";Calendar._TT["TIME_PART"]="(Shift-)Click or drag to change value";Calendar._TT["DEF_DATE_FORMAT"]="%Y-%m-%d";Calendar._TT["TT_DATE_FORMAT"]="%a, %b %e";Calendar._TT["WK"]="wk";Calendar._TT["TIME"]="Time:";

View File

@ -0,0 +1,200 @@
/* Copyright Mihai Bazon, 2002, 2003 | http://dynarch.com/mishoo/
* ---------------------------------------------------------------------------
*
* The DHTML Calendar
*
* Details and latest version at:
* http://dynarch.com/mishoo/calendar.epl
*
* This script is distributed under the GNU Lesser General Public License.
* Read the entire license text here: http://www.gnu.org/licenses/lgpl.html
*
* This file defines helper functions for setting up the calendar. They are
* intended to help non-programmers get a working calendar on their site
* quickly. This script should not be seen as part of the calendar. It just
* shows you what one can do with the calendar, while in the same time
* providing a quick and simple method for setting it up. If you need
* exhaustive customization of the calendar creation process feel free to
* modify this code to suit your needs (this is recommended and much better
* than modifying calendar.js itself).
*/
// $Id$
/**
* This function "patches" an input field (or other element) to use a calendar
* widget for date selection.
*
* The "params" is a single object that can have the following properties:
*
* prop. name | description
* -------------------------------------------------------------------------------------------------
* inputField | the ID of an input field to store the date
* displayArea | the ID of a DIV or other element to show the date
* button | ID of a button or other element that will trigger the calendar
* eventName | event that will trigger the calendar, without the "on" prefix (default: "click")
* ifFormat | date format that will be stored in the input field
* daFormat | the date format that will be used to display the date in displayArea
* singleClick | (true/false) wether the calendar is in single click mode or not (default: true)
* firstDay | numeric: 0 to 6. "0" means display Sunday first, "1" means display Monday first, etc.
* align | alignment (default: "Br"); if you don't know what's this see the calendar documentation
* range | array with 2 elements. Default: [1900, 2999] -- the range of years available
* weekNumbers | (true/false) if it's true (default) the calendar will display week numbers
* flat | null or element ID; if not null the calendar will be a flat calendar having the parent with the given ID
* flatCallback | function that receives a JS Date object and returns an URL to point the browser to (for flat calendar)
* disableFunc | function that receives a JS Date object and should return true if that date has to be disabled in the calendar
* onSelect | function that gets called when a date is selected. You don't _have_ to supply this (the default is generally okay)
* onClose | function that gets called when the calendar is closed. [default]
* onUpdate | function that gets called after the date is updated in the input field. Receives a reference to the calendar.
* date | the date that the calendar will be initially displayed to
* showsTime | default: false; if true the calendar will include a time selector
* timeFormat | the time format; can be "12" or "24", default is "12"
* electric | if true (default) then given fields/date areas are updated for each move; otherwise they're updated only on close
* step | configures the step of the years in drop-down boxes; default: 2
* position | configures the calendar absolute position; default: null
* cache | if "true" (but default: "false") it will reuse the same calendar object, where possible
* showOthers | if "true" (but default: "false") it will show days from other months too
*
* None of them is required, they all have default values. However, if you
* pass none of "inputField", "displayArea" or "button" you'll get a warning
* saying "nothing to setup".
*/
Calendar.setup = function (params) {
function param_default(pname, def) { if (typeof params[pname] == "undefined") { params[pname] = def; } };
param_default("inputField", null);
param_default("displayArea", null);
param_default("button", null);
param_default("eventName", "click");
param_default("ifFormat", "%Y/%m/%d");
param_default("daFormat", "%Y/%m/%d");
param_default("singleClick", true);
param_default("disableFunc", null);
param_default("dateStatusFunc", params["disableFunc"]); // takes precedence if both are defined
param_default("dateText", null);
param_default("firstDay", null);
param_default("align", "Br");
param_default("range", [1900, 2999]);
param_default("weekNumbers", true);
param_default("flat", null);
param_default("flatCallback", null);
param_default("onSelect", null);
param_default("onClose", null);
param_default("onUpdate", null);
param_default("date", null);
param_default("showsTime", false);
param_default("timeFormat", "24");
param_default("electric", true);
param_default("step", 2);
param_default("position", null);
param_default("cache", false);
param_default("showOthers", false);
param_default("multiple", null);
var tmp = ["inputField", "displayArea", "button"];
for (var i in tmp) {
if (typeof params[tmp[i]] == "string") {
params[tmp[i]] = document.getElementById(params[tmp[i]]);
}
}
if (!(params.flat || params.multiple || params.inputField || params.displayArea || params.button)) {
alert("Calendar.setup:\n Nothing to setup (no fields found). Please check your code");
return false;
}
function onSelect(cal) {
var p = cal.params;
var update = (cal.dateClicked || p.electric);
if (update && p.inputField) {
p.inputField.value = cal.date.print(p.ifFormat);
if (typeof p.inputField.onchange == "function")
p.inputField.onchange();
}
if (update && p.displayArea)
p.displayArea.innerHTML = cal.date.print(p.daFormat);
if (update && typeof p.onUpdate == "function")
p.onUpdate(cal);
if (update && p.flat) {
if (typeof p.flatCallback == "function")
p.flatCallback(cal);
}
if (update && p.singleClick && cal.dateClicked)
cal.callCloseHandler();
};
if (params.flat != null) {
if (typeof params.flat == "string")
params.flat = document.getElementById(params.flat);
if (!params.flat) {
alert("Calendar.setup:\n Flat specified but can't find parent.");
return false;
}
var cal = new Calendar(params.firstDay, params.date, params.onSelect || onSelect);
cal.showsOtherMonths = params.showOthers;
cal.showsTime = params.showsTime;
cal.time24 = (params.timeFormat == "24");
cal.params = params;
cal.weekNumbers = params.weekNumbers;
cal.setRange(params.range[0], params.range[1]);
cal.setDateStatusHandler(params.dateStatusFunc);
cal.getDateText = params.dateText;
if (params.ifFormat) {
cal.setDateFormat(params.ifFormat);
}
if (params.inputField && typeof params.inputField.value == "string") {
cal.parseDate(params.inputField.value);
}
cal.create(params.flat);
cal.show();
return false;
}
var triggerEl = params.button || params.displayArea || params.inputField;
triggerEl["on" + params.eventName] = function() {
var dateEl = params.inputField || params.displayArea;
var dateFmt = params.inputField ? params.ifFormat : params.daFormat;
var mustCreate = false;
var cal = window.calendar;
if (dateEl)
params.date = Date.parseDate(dateEl.value || dateEl.innerHTML, dateFmt);
if (!(cal && params.cache)) {
window.calendar = cal = new Calendar(params.firstDay,
params.date,
params.onSelect || onSelect,
params.onClose || function(cal) { cal.hide(); });
cal.showsTime = params.showsTime;
cal.time24 = (params.timeFormat == "24");
cal.weekNumbers = params.weekNumbers;
mustCreate = true;
} else {
if (params.date)
cal.setDate(params.date);
cal.hide();
}
if (params.multiple) {
cal.multiple = {};
for (var i = params.multiple.length; --i >= 0;) {
var d = params.multiple[i];
var ds = d.print("%Y%m%d");
cal.multiple[ds] = d;
}
}
cal.showsOtherMonths = params.showOthers;
cal.yearStep = params.step;
cal.setRange(params.range[0], params.range[1]);
cal.params = params;
cal.setDateStatusHandler(params.dateStatusFunc);
cal.getDateText = params.dateText;
cal.setDateFormat(dateFmt);
if (mustCreate)
cal.create();
cal.refresh();
if (!params.position)
cal.showAtElement(params.button || params.displayArea || params.inputField, params.align);
else
cal.showAt(params.position[0], params.position[1]);
return false;
};
return cal;
};

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,76 @@
var defaults = new Array();
function dateSelector(id) {
var el = document.getElementById(id);
var format = gettype(el.id);
var epoch;
var parse = false;
var cal = new Calendar(0, null, onSelect, onClose);
if (defaults['f_time_'+id]) {
cal.showsTime = true;
} else {
cal.showsTime = false;
}
cal.weekNumbers = true;
cal.showsOtherMonths = true;
cal.create();
// convert to milliseconds (Epoch is usually expressed in seconds, but Javascript uses Milliseconds)
switch (format) {
case '%es' : epoch = el.value * 86400 * 1000;
format = '%s';
parse = true;
break;
case '%s' : epoch = el.value * 1000;
parse = true;
break;
}
// Convert the value to the date so that the calendar will display it
if (parse) {
var dDate = new Date();
dDate.setTime(epoch);
cal.setDateFormat('%a, %d %b %Y'); // set the specified date format
cal.parseDate(dDate.toString()); // try to parse the text in field
cal.setDateFormat(format); // set the specified date format
} else {
cal.setDateFormat(format); // set the specified date format
cal.parseDate(el.value); // try to parse the text in field
}
cal.sel = el; // inform it what input field we use
cal.showAtElement(el, 'BR'); // show the calendar
}
function onSelect(calendar,date) {
switch (gettype(calendar.sel.id)) {
case '%es' : date = Math.round(date / 86400);
break;
}
calendar.sel.value = date;
if (calendar.dateClicked)
onClose(calendar);
}
function onClose(calendar,date) {
calendar.hide();
}
function gettype(attr) {
if (typeof defaults == "undefined") {
return '%s';
}
if (typeof defaults[attr] == "undefined") {
if (typeof default_date_format == "undefined") {
return '%s';
} else {
return default_date_format;
}
} else {
return defaults[attr];
}
}

View File

@ -15,7 +15,7 @@ class Model_Account extends Model_Auth_UserDefault {
'group' => array('through' => 'account_group'), 'group' => array('through' => 'account_group'),
'invoice' => array('far_key'=>'id'), 'invoice' => array('far_key'=>'id'),
'payment'=>array(), 'payment'=>array(),
'service' => array(), 'service' => array('far_key'=>'id'),
); );
/** /**

View File

@ -13,7 +13,7 @@
class Model_ADSL_Supplier extends ORMOSB { class Model_ADSL_Supplier extends ORMOSB {
// Relationships // Relationships
protected $_has_many = array( protected $_has_many = array(
'adsl_supplier_plan'=>array('foreign_key'=>'supplier_id'), 'adsl_supplier_plan'=>array('foreign_key'=>'supplier_id','far_key'=>'id'),
); );
protected $_updated_column = FALSE; protected $_updated_column = FALSE;
@ -32,6 +32,7 @@ class Model_ADSL_Supplier extends ORMOSB {
foreach ($aspo->adsl_plan->find_all() as $apo) foreach ($aspo->adsl_plan->find_all() as $apo)
// Find all the services who use this plan // Find all the services who use this plan
foreach ($apo->service->find_all() as $so) foreach ($apo->service->find_all() as $so)
if (! $active OR $so->active)
array_push($services,$so); array_push($services,$so);
return $services; return $services;

View File

@ -13,7 +13,7 @@
class Model_ADSL_Supplier_Plan extends ORMOSB { class Model_ADSL_Supplier_Plan extends ORMOSB {
// Relationships // Relationships
protected $_has_many = array( protected $_has_many = array(
'adsl_plan'=>array(), 'adsl_plan'=>array('far_key'=>'id'),
); );
protected $_belongs_to = array( protected $_belongs_to = array(
'adsl_supplier'=>array('foreign_key'=>'supplier_id'), 'adsl_supplier'=>array('foreign_key'=>'supplier_id'),

View File

@ -71,7 +71,7 @@ function CORE_database_join_fields($result, $linked)
while (!$rss->EOF) { while (!$rss->EOF) {
for ($ii=0; $ii < count($result); $ii++ ) { for ($ii=0; $ii < count($result); $ii++ ) {
if($result[$ii][$field] == $rss->fields[id]) { if($result[$ii][$field] == $rss->fields[id]) {
if(ereg(',',$link_field)) { if(preg_match('/,/',$link_field)) {
$fields = explode(',',$link_field); $fields = explode(',',$link_field);
for($iii=0; $iii<count($fields); $iii++) { for($iii=0; $iii<count($fields); $iii++) {
$fieldname = $fields[$iii]; $fieldname = $fields[$iii];

View File

@ -56,7 +56,7 @@ class email_template extends OSB_module {
$template = $db->Execute(sqlselect($db,'email_template','*',array('name'=>$template_name))); $template = $db->Execute(sqlselect($db,'email_template','*',array('name'=>$template_name)));
# If the template is not active, return. # If the template is not active, return.
if (! $template || $template->fields['status'] != '1') if (! $template || $template->fields['active'] != '1')
return; return;
# Setup our Email # Setup our Email

View File

@ -37,10 +37,13 @@ class Controller_Admin_Export extends Controller_TemplateDefault {
* This is the main call to export, providing a list of items to export and * This is the main call to export, providing a list of items to export and
* setting up the page to call the export plugin when submitted. * setting up the page to call the export plugin when submitted.
*/ */
public function action_index($daysago=30) { public function action_index($daysago) {
// @todo this should come from a file list // @todo this should come from a file list
$TBRexportplugins = array('quicken'=>'Export to Quicken'); $TBRexportplugins = array('quicken'=>'Export to Quicken');
if (! $daysago)
$daysago = 30;
$payments = ORM::factory('payment') $payments = ORM::factory('payment')
->export($daysago); ->export($daysago);

View File

@ -16,7 +16,7 @@ class Export {
public function __construct() { public function __construct() {
$this->plugin = preg_replace('/^'.get_parent_class($this).'_/','',get_class($this)); $this->plugin = preg_replace('/^'.get_parent_class($this).'_/','',get_class($this));
$this->request = Request::current(); $this->response = Response::factory();
} }
} }
?> ?>

View File

@ -190,9 +190,9 @@ class Export_Quicken extends Export {
} }
if (! empty($qo)) if (! empty($qo))
$this->request->response = $qo->export(); $this->response->body($qo->export());
$this->request->send_file(TRUE,'quicken-import.iif'); $this->response->send_file(TRUE,'quicken-import.iif',array('mime_type'=>'text/plain'));
} }
} }
?> ?>

View File

@ -203,7 +203,7 @@ class pdf_invoice_overview extends pdf_invoice_base {
$this->SetXY($x,$y); $this->Cell(0,0,'This invoice can also be paid by:'); $y += 4; $this->SetXY($x,$y); $this->Cell(0,0,'This invoice can also be paid by:'); $y += 4;
# Direct Credit # Direct Credit
$logo = sprintf('%s/%s',PATH_THEMES.DEFAULT_THEME,'invoice/invoice-payment-dd.png'); $logo = sprintf('%s/%s','/afs/local/home/gh/.web/au.net.graytech.www/osb/modules/invoice/media/img/','invoice-payment-dd.png');
$this->Image($logo,$x+1,$y,8); $this->Image($logo,$x+1,$y,8);
$this->SetFont('helvetica','B',8); $this->SetFont('helvetica','B',8);
$this->SetXY($x+10,$y); $this->Cell(0,0,'Direct Credit to our Bank Account'); $y += 3; $this->SetXY($x+10,$y); $this->Cell(0,0,'Direct Credit to our Bank Account'); $y += 3;
@ -231,7 +231,8 @@ class pdf_invoice_overview extends pdf_invoice_base {
# Paypal # Paypal
$y += 3; $y += 3;
$logo = sprintf('%s/%s',PATH_THEMES.DEFAULT_THEME,'invoice/invoice-payment-pp.png'); // $logo = sprintf('%s/%s',PATH_THEMES.DEFAULT_THEME,'invoice/invoice-payment-pp.png');
$logo = sprintf('%s/%s','/afs/local/home/gh/.web/au.net.graytech.www/osb/modules/invoice/media/img/','invoice-payment-pp.png');
$this->Image($logo,$x+1,$y,8); $this->Image($logo,$x+1,$y,8);
$this->SetFont('helvetica','B',8); $this->SetFont('helvetica','B',8);
$this->SetXY($x+10,$y); $this->Cell(0,0,'Pay Pal/Credit Card'); $y += 3; $this->SetXY($x+10,$y); $this->Cell(0,0,'Pay Pal/Credit Card'); $y += 3;

View File

@ -618,7 +618,7 @@ class invoice extends OSB_module {
$account_where = ''; $account_where = '';
if (is_null($fields)) if (is_null($fields))
$fields = 'DISTINCT service.id AS sid,account.id AS account_id,invoice.id AS iid,FROM_UNIXTIME(service.date_next_invoice,\'%Y-%m-%d\') AS invoice_date,service.sku AS sku,service.price AS price,account.first_name AS first_name,account.last_name AS last_name,account.currency_id AS billed_currency_id,service.date_orig AS date_orig'; $fields = 'DISTINCT service.id AS sid,account.id AS account_id,FROM_UNIXTIME(service.date_next_invoice,\'%Y-%m-%d\') AS invoice_date,service.sku AS sku,service.price AS price,account.first_name AS first_name,account.last_name AS last_name,account.currency_id AS billed_currency_id,service.date_orig AS date_orig';
if (is_null($orderby)) if (is_null($orderby))
$orderby = 'ORDER BY account_id,invoice_date,sid'; $orderby = 'ORDER BY account_id,invoice_date,sid';
@ -638,7 +638,6 @@ class invoice extends OSB_module {
SELECT %s SELECT %s
FROM {p}service AS service FROM {p}service AS service
JOIN {p}account AS account ON (service.account_id=account.id AND account.site_id={s}) JOIN {p}account AS account ON (service.account_id=account.id AND account.site_id={s})
LEFT JOIN {p}invoice AS invoice ON (service.invoice_id=invoice.id AND invoice.site_id={s})
%s %s
WHERE service.site_id={s} WHERE service.site_id={s}
AND service.active=1 AND service.active=1

View File

@ -13,7 +13,7 @@
class Model_Payment extends ORMOSB { class Model_Payment extends ORMOSB {
// Relationships // Relationships
protected $_has_many = array( protected $_has_many = array(
'payment_item'=>array(), 'payment_item'=>array('far_key'=>'id'),
'invoice'=>array('through'=>'payment_item'), 'invoice'=>array('through'=>'payment_item'),
); );
protected $_belongs_to = array( protected $_belongs_to = array(
@ -23,9 +23,13 @@ class Model_Payment extends ORMOSB {
protected $_sorting = array('date_payment'=>'DESC'); protected $_sorting = array('date_payment'=>'DESC');
protected $_formats = array( protected $_display_filters = array(
'date_payment'=>array('Model_Invoice::_filters'=>array('date','d-m-Y')), 'date_payment'=>array(
'total_amt'=>array('Currency::display'=>array()), array('Config::date',array(':value')),
),
'total_amt'=>array(
array('Currency::display',array(':value')),
),
); );
/** /**

View File

@ -144,5 +144,14 @@ class Model_Product extends ORMOSB {
else else
return FALSE; return FALSE;
} }
public function show_thumb() {
$mediapath = Route::get('default/media');
$thumb = $mediapath->uri(array('file'=>'img/thumbnails/'.$this->thumbnail));
// @todo Change the ALT to the product name.
echo HTML::image($thumb,array('alt'=>_('Thumb Nail')));
}
} }
?> ?>

View File

@ -27,14 +27,16 @@ echo Form::open('cart/add');
<td style="background-color: #FFFFFF;"> <td style="background-color: #FFFFFF;">
<table width="100%" border="0" cellpadding="4"> <table width="100%" border="0" cellpadding="4">
<tr> <tr>
<td class="body"><?php echo $translate->description_full; ?></td> <td class="body" rowspan="3"><?php echo $translate->description_full; ?></td>
<td style="text-align: right;"><?php if ($record->thumbnail) $record->show_thumb(); ?></td>
</tr>
<tr>
<?php if ($record->prod_plugin && method_exists($record->prod_plugin_file,'product_view')) { <?php if ($record->prod_plugin && method_exists($record->prod_plugin_file,'product_view')) {
$pio = new $record->prod_plugin_file; $pio = new $record->prod_plugin_file;
echo '<td style="vertical-align: top;">'.$pio->product_view($record->prod_plugin_data).'</td>'; echo '<td style="vertical-align: bottom;">'.$pio->product_view($record->prod_plugin_data).'</td>';
} ?> } ?>
</tr> </tr>
<tr> <tr>
<td class="spacer">&nbsp;</td>
<?php if ($record->prod_plugin && method_exists($record->prod_plugin_file,'contract_view')) { <?php if ($record->prod_plugin && method_exists($record->prod_plugin_file,'contract_view')) {
$pio = new $record->prod_plugin_file; $pio = new $record->prod_plugin_file;
echo '<td style="vertical-align: top;">'.$pio->contract_view($record->prod_plugin_data,$record->price_base,$record->price_setup).'</td>'; echo '<td style="vertical-align: top;">'.$pio->contract_view($record->prod_plugin_data,$record->price_base,$record->price_setup).'</td>';

View File

@ -9,7 +9,6 @@
* @author Deon George * @author Deon George
* @copyright (c) 2010 Open Source Billing * @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html * @license http://dev.osbill.net/license.html
* @todo Replace View::factory files to use $this->viewpath()
*/ */
class Controller_Admin_Service extends Controller_TemplateDefault { class Controller_Admin_Service extends Controller_TemplateDefault {
protected $control = array('Services'=>'services'); protected $control = array('Services'=>'services');
@ -51,14 +50,14 @@ ORDER BY c.id,s.recur_schedule,c.name,a.company,a.last_name,a.first_name
if (($si != $last_account) AND $last_account) { if (($si != $last_account) AND $last_account) {
if ($sc > 1) if ($sc > 1)
$output .= View::factory('service/list/bycheckout_subtotal') $output .= View::factory('service/admin/list/bycheckout_subtotal')
->set('subtotal',Currency::display($st)) ->set('subtotal',Currency::display($st))
->set('i',$i++%2); ->set('i',$i++%2);
$sc = $st = 0; $sc = $st = 0;
} }
if (($service['cid'] != $last_checkout) OR (! is_null($last_checkout) AND ! $last_checkout)) { if (($service['cid'] != $last_checkout) OR (! is_null($last_checkout) AND ! $last_checkout)) {
$output .= View::factory('service/list/bycheckout_header') $output .= View::factory('service/admin/list/bycheckout_header')
->set('checkout_name',$service['checkout_plugin_name']) ->set('checkout_name',$service['checkout_plugin_name'])
->set('last_checkout',$last_checkout); ->set('last_checkout',$last_checkout);
} }
@ -69,14 +68,14 @@ ORDER BY c.id,s.recur_schedule,c.name,a.company,a.last_name,a.first_name
$st += round($so->price+$so->tax(),2); $st += round($so->price+$so->tax(),2);
$sc++; $sc++;
$output .= View::factory('service/list/bycheckout_body') $output .= View::factory('service/admin/list/bycheckout_body')
->set('service',$so) ->set('service',$so)
->set('i',$i++%2); ->set('i',$i++%2);
} }
// Last subtotal // Last subtotal
if ($sc > 1) if ($sc > 1)
$output .= View::factory('service/list/bycheckout_subtotal') $output .= View::factory('service/admin/list/bycheckout_subtotal')
->set('subtotal',$st) ->set('subtotal',$st)
->set('i',$i++%2); ->set('i',$i++%2);
@ -124,13 +123,13 @@ ORDER BY C.last_name,B.account_id,A.service_number
if ($i) if ($i)
$output .= '<tr><td colspan="10">&nbsp;</td></tr>'; $output .= '<tr><td colspan="10">&nbsp;</td></tr>';
$output .= View::factory('service/list/adslservices_header') $output .= View::factory('service/admin/list/adslservices_header')
->set('service',$so); ->set('service',$so);
$last_account = $so->account_id; $last_account = $so->account_id;
} }
$output .= View::factory('service/list/adslservices_body') $output .= View::factory('service/admin/list/adslservices_body')
->set('service',$so) ->set('service',$so)
->set('i',$i++%2); ->set('i',$i++%2);
} }
@ -218,13 +217,13 @@ ORDER BY C.last_name,B.account_id,A.service_number
if ($i) if ($i)
$output .= '<tr><td colspan="10">&nbsp;</td></tr>'; $output .= '<tr><td colspan="10">&nbsp;</td></tr>';
$output .= View::factory('service/list/adslservices_header') $output .= View::factory('service/admin/list/adslservices_header')
->set('service',$so); ->set('service',$so);
$last_account = $so->account_id; $last_account = $so->account_id;
} }
$output .= View::factory('service/list/adslservices_body') $output .= View::factory('service/admin/list/adslservices_body')
->set('service',$so) ->set('service',$so)
->set('i',$i++%2); ->set('i',$i++%2);
} }
@ -294,7 +293,7 @@ GROUP BY DATE_FORMAT(DATE,"%%Y-%%m"),SID
$i = $j = 0; $i = $j = 0;
$total = 0; $total = 0;
$summary = ''; $summary = '';
$output = View::factory('service/list/adslbilling_head'); $output = View::factory('service/admin/list/adslbilling_head');
$output .= '<table class="box-left">'; $output .= '<table class="box-left">';
foreach ($aso->services(TRUE) as $so) { foreach ($aso->services(TRUE) as $so) {
// Reset our uploaded data // Reset our uploaded data
@ -307,7 +306,7 @@ GROUP BY DATE_FORMAT(DATE,"%%Y-%%m"),SID
// Record the the exception if the cost is not expected // Record the the exception if the cost is not expected
if (round($so->service_adsl->adsl_plan->adsl_supplier_plan->base_cost+$so->service_adsl->adsl_plan->adsl_supplier_plan->tax(),2) != $uploaded['amount']) { if (round($so->service_adsl->adsl_plan->adsl_supplier_plan->base_cost+$so->service_adsl->adsl_plan->adsl_supplier_plan->tax(),2) != $uploaded['amount']) {
$summary .= View::factory('service/list/adslbilling_summary') $summary .= View::factory('service/admin/list/adslbilling_summary')
->set('service',$so) ->set('service',$so)
->set('amount',$uploaded['amount']) ->set('amount',$uploaded['amount'])
->set('i',$j++%2); ->set('i',$j++%2);
@ -325,7 +324,7 @@ GROUP BY DATE_FORMAT(DATE,"%%Y-%%m"),SID
} }
$total += $uploaded['amount']; $total += $uploaded['amount'];
$output .= View::factory('service/list/adslbilling_body') $output .= View::factory('service/admin/list/adslbilling_body')
->set('service',$so) ->set('service',$so)
->set('checked',$uploaded['checked']) ->set('checked',$uploaded['checked'])
->set('amount',$uploaded['amount']) ->set('amount',$uploaded['amount'])
@ -333,7 +332,7 @@ GROUP BY DATE_FORMAT(DATE,"%%Y-%%m"),SID
->set('i',$i++%2); ->set('i',$i++%2);
} }
$output .= View::factory('service/list/adslbilling_foot') $output .= View::factory('service/admin/list/adslbilling_foot')
->set('total',$total); ->set('total',$total);
$output .= '</table>'; $output .= '</table>';
@ -341,7 +340,7 @@ GROUP BY DATE_FORMAT(DATE,"%%Y-%%m"),SID
// Summary Report of remaining CSV items. // Summary Report of remaining CSV items.
if (! empty($csv)) if (! empty($csv))
foreach ($csv as $service => $item) { foreach ($csv as $service => $item) {
$summary .= View::factory('service/list/adslbilling_summary_exception') $summary .= View::factory('service/admin/list/adslbilling_summary_exception')
->set('service',$service) ->set('service',$service)
->set('item',$item) ->set('item',$item)
->set('i',$j++%2); ->set('i',$j++%2);
@ -433,8 +432,31 @@ GROUP BY DATE_FORMAT(DATE,"%%Y-%%m"),SID
'title'=>sprintf('%s %s:%s',_('Update Service'),$so->id(),$so->name()), 'title'=>sprintf('%s %s:%s',_('Update Service'),$so->id(),$so->name()),
'body'=>View::factory($so->viewpath()) 'body'=>View::factory($so->viewpath())
->set('so',$so) ->set('so',$so)
->set('mediapath',Route::get('default/media'))
->set('plugin_form',$so->admin_update()), ->set('plugin_form',$so->admin_update()),
)); ));
// @todo Investigate a better way of preparing for jscalendar
Script::add(array(
'type'=>'file',
'data'=>'js/dhtml.calendar.js',
));
Script::add(array(
'type'=>'file',
'data'=>'js/dhtml.calendar-setup.js',
));
Script::add(array(
'type'=>'file',
'data'=>'js/dhtml.calendar-en.js',
));
Script::add(array(
'type'=>'file',
'data'=>'js/dhtml.date_selector.js',
));
Style::add(array(
'type'=>'file',
'data'=>'css/dhtml.calendar.css',
));
} }
} }
?> ?>

View File

@ -32,7 +32,7 @@ class Controller_User_Service extends Controller_TemplateDefault {
public function action_list() { public function action_list() {
Block::add(array( Block::add(array(
'title'=>sprintf('%s: %s - %s',_('Services For'),$this->ao->accnum(),$this->ao->name(TRUE)), 'title'=>sprintf('%s: %s - %s',_('Services For'),$this->ao->accnum(),$this->ao->name(TRUE)),
'body'=>View::factory('service/list') 'body'=>View::factory('service/user/list')
->set('services',$this->ao->service->find_all()), ->set('services',$this->ao->service->find_all()),
)); ));
} }
@ -47,7 +47,7 @@ class Controller_User_Service extends Controller_TemplateDefault {
Block::add(array( Block::add(array(
'title'=>sprintf('%s: %s',$so->id(),$so->product->name()), 'title'=>sprintf('%s: %s',$so->id(),$so->product->name()),
'body'=>View::factory('service/view') 'body'=>View::factory('service/user/view')
->set('so',$so), ->set('so',$so),
)); ));
} }

View File

@ -76,7 +76,7 @@ class Model_Service extends ORMOSB {
/** /**
* Return the object of the product plugin * Return the object of the product plugin
*/ */
public function plugin() { private function plugin() {
if (! $this->product->prod_plugin_file) if (! $this->product->prod_plugin_file)
return NULL; return NULL;

View File

@ -183,7 +183,8 @@ class Model_Service_ADSL extends Model_Service {
} }
public function traffic_lastmonth($string=TRUE) { public function traffic_lastmonth($string=TRUE) {
return $this->traffic_month(strtotime('last month'),$string); // We need it to be last month as of yesterday
return $this->traffic_month(strtotime('last month')-86400,$string);
} }
public function traffic_thismonth($string=TRUE) { public function traffic_thismonth($string=TRUE) {
@ -225,8 +226,8 @@ class Model_Service_ADSL extends Model_Service {
$traffic_type = $this->get_traffic_data_daily($period,TRUE); $traffic_type = $this->get_traffic_data_daily($period,TRUE);
$day = count($traffic_type) ? max(array_keys($traffic_type)) : 1; $day = count($traffic_type) ? max(array_keys($traffic_type)) : 1;
$date = mktime(0,0,0,date('m',$period),$day,date('Y',$period)); $date = mktime(0,0,0,date('n',$period),$day,date('Y',$period));
$daysleft = date('d',strtotime('last day ',$date))-$day; $daysleft = date('d',strtotime('last day of',$date))-$day;
$google = GoogleChart::factory('vertical_bar'); $google = GoogleChart::factory('vertical_bar');
$google->title = sprintf('DSL traffic usage as at %s',Config::date($date)); $google->title = sprintf('DSL traffic usage as at %s',Config::date($date));
@ -248,7 +249,7 @@ class Model_Service_ADSL extends Model_Service {
switch ($item) { switch ($item) {
case 'MONTH_GRAPH': $value = (string)$google; break; case 'MONTH_GRAPH': $value = (string)$google; break;
case 'MONTH_TABLE': $value = $google->html_table(FALSE,array( case 'MONTH_TABLE': $value = $google->html_table(FALSE,array(
'table'=>'style="border: 1px solid #bebcb7; padding: 5px 5px; background: none repeat scroll 0% 0% #f8f7f5;"', 'table'=>'style="border: 1px solid #bebcb7; padding: 5px 5px; background: none repeat scroll 0% 0% #f8f7f5; font-size: 70%;"',
)); break; )); break;
case 'OFFPEAK_ALLOWANCE': $value = isset($allowance['base_down_offpeak']) ? $allowance['base_down_offpeak'].' MB' : '-'; break; case 'OFFPEAK_ALLOWANCE': $value = isset($allowance['base_down_offpeak']) ? $allowance['base_down_offpeak'].' MB' : '-'; break;
@ -331,7 +332,7 @@ class Model_Service_ADSL extends Model_Service {
} }
protected function _service_view() { protected function _service_view() {
return View::factory('service/adsl/view') return View::factory($this->viewpath(strtolower($this->service->prod_plugin_name)))
->set('so',$this); ->set('so',$this);
} }
@ -356,13 +357,14 @@ class Model_Service_ADSL extends Model_Service {
protected function _admin_update() { protected function _admin_update() {
return View::factory($this->viewpath(strtolower($this->service->prod_plugin_name))) return View::factory($this->viewpath(strtolower($this->service->prod_plugin_name)))
->set('mediapath',Route::get('default/media'))
->set('so',$this); ->set('so',$this);
} }
/** /**
* Render a google chart of traffic * Render a google chart of traffic
*/ */
public function graph_traffic($month=null) { public function graph_traffic($month=NULL) {
$google = GoogleChart::factory('vertical_bar'); $google = GoogleChart::factory('vertical_bar');
// If we came in via a post to show a particular month, then show that, otherwise show the yearly result // If we came in via a post to show a particular month, then show that, otherwise show the yearly result
@ -382,9 +384,6 @@ class Model_Service_ADSL extends Model_Service {
'axis'=>'r', 'axis'=>'r',
'data'=>array((isset($friendly['cumulative'.$k]) ? $friendly['cumulative'.$k] : 'cumulative'.$k)=>$this->cumulative($traffic_data[$k])))); 'data'=>array((isset($friendly['cumulative'.$k]) ? $friendly['cumulative'.$k] : 'cumulative'.$k)=>$this->cumulative($traffic_data[$k]))));
$graph_data = View::factory('service/view_detail_adsl_traffic')
->set('traffic',$this->traffic_month(strtotime($_POST['month'].'-01'),FALSE));
} else { } else {
// @todo Change the date to the last record date // @todo Change the date to the last record date
$google->title = sprintf('Monthly DSL traffic usage as at %s',Config::date(strtotime('yesterday'))); $google->title = sprintf('Monthly DSL traffic usage as at %s',Config::date(strtotime('yesterday')));
@ -399,5 +398,10 @@ class Model_Service_ADSL extends Model_Service {
return (string)$google; return (string)$google;
} }
public function table_traffic($month=NULL) {
return View::factory('service/user/adsl/table_traffic')
->set('traffic',$this->traffic_month((! is_null($month) AND trim($month)) ? strtotime($month.'-01') : NULL,FALSE));
}
} }
?> ?>

View File

@ -1,11 +1,8 @@
<!-- @todo NEEDS TO BE TRANSLATED --> <!-- @todo NEEDS TO BE TRANSLATED -->
<table width="100%"> <table width="100%">
<tr> <tr>
<td class="head">Plugin Details</td> <td class="head" colspan="2">Plugin Details</td>
</tr> </tr>
<tr>
<td style="width: 50%; vertical-align: top;">
<table>
<tr> <tr>
<td style="width: 40%;">Service Number</td> <td style="width: 40%;">Service Number</td>
<td style="width: 60%;" class="data"><?php echo Form::input('plugin[service_number]',$so->service_number); ?></td> <td style="width: 60%;" class="data"><?php echo Form::input('plugin[service_number]',$so->service_number); ?></td>
@ -16,7 +13,13 @@
</tr> </tr>
<tr> <tr>
<td>Service Connect Date</td> <td>Service Connect Date</td>
<td class="data"><?php echo Form::input('plugin[service_connect_date]',$so->service_connect_date); ?></td> <td class="data">
<?php echo Form::input('plugin[service_connect_date]',$so->service_connect_date,array('id'=>'service_connect_date')); ?>
<?php echo HTML::anchor('#',
HTML::image($mediapath->uri(array('file'=>'img/calendar.png')),array('alt'=>_('Calendar'),'style'=>'cursor: pointer;')),
array('title'=>'Click to popup a dialog to select a date graphically','onclick'=>"dateSelector('service_connect_date')")); ?>
<script type="text/javascript">defaults['service_connect_date'] = '%s';</script>
</td>
</tr> </tr>
<tr> <tr>
<td>Service Username</td> <td>Service Username</td>
@ -31,6 +34,3 @@
<td class="data"><?php echo Form::input('plugin[ipaddress]',$so->ipaddress); ?></td> <td class="data"><?php echo Form::input('plugin[ipaddress]',$so->ipaddress); ?></td>
</tr> </tr>
</table> </table>
</td>
</tr>
</table>

View File

@ -2,7 +2,7 @@
<td><?php echo $service->service_adsl->display('service_number'); ?></td> <td><?php echo $service->service_adsl->display('service_number'); ?></td>
<td><?php echo $service->service_adsl->ipaddress(); ?></td> <td><?php echo $service->service_adsl->ipaddress(); ?></td>
<td><?php printf('%s (%s)',$service->name(),$service->id); ?></td> <td><?php printf('%s (%s)',$service->name(),$service->id); ?></td>
<td><?php echo $service->service_adsl->adsl_plan->allowance(); ?></td> <td><?php echo $service->product->prod_plugin_file ? $service->product->plugin()->allowance() : 'No Details'; ?></td>
<td><?php echo $service->service_adsl->traffic_thismonth(); ?></td> <td><?php echo $service->service_adsl->traffic_thismonth(); ?></td>
<td><?php echo $service->service_adsl->traffic_lastmonth(); ?></td> <td><?php echo $service->service_adsl->traffic_lastmonth(); ?></td>
<td><?php echo $service->display('price'); ?></td> <td><?php echo $service->display('price'); ?></td>

View File

@ -3,7 +3,7 @@
<table width="100%"> <table width="100%">
<tr> <tr>
<td style="width: 50%; vertical-align: top;"> <td style="width: 50%; vertical-align: top;">
<table> <table width="100%">
<tr> <tr>
<td style="width: 40%;">Service Active</td> <td style="width: 40%;">Service Active</td>
<td style="width: 60%;" class="data"><?php echo StaticList_YesNo::form('active',$so->active); ?></td> <td style="width: 60%;" class="data"><?php echo StaticList_YesNo::form('active',$so->active); ?></td>
@ -22,7 +22,13 @@
</tr> </tr>
<tr> <tr>
<td>Date Next Invoice</td> <td>Date Next Invoice</td>
<td class="data"><?php echo $so->display('date_next_invoice'); ?></td> <td class="data">
<?php echo Form::input('date_next_invoice',$so->date_next_invoice,array('id'=>'date_next_invoice')); ?>
<?php echo HTML::anchor('#',
HTML::image($mediapath->uri(array('file'=>'img/calendar.png')),array('alt'=>_('Calendar'),'style'=>'cursor: pointer;')),
array('title'=>'Click to popup a dialog to select a date graphically','onclick'=>"dateSelector('date_next_invoice')")); ?>
<script type="text/javascript">defaults['date_next_invoice'] = '%s';</script>
</td>
</tr> </tr>
<tr> <tr>
<td>Taxable</td> <td>Taxable</td>

View File

@ -67,6 +67,7 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"><?php echo $so->graph_traffic(isset($_POST['month']) ? $_POST['month'] : ''); ?><td> <td><?php echo $so->graph_traffic(isset($_POST['month']) ? $_POST['month'] : ''); ?><td>
<td><?php echo $so->table_traffic(isset($_POST['month']) ? $_POST['month'] : ''); ?><td>
</tr> </tr>
</table> </table>

View File

@ -12,7 +12,7 @@
<tr class="<?php echo ++$i%2 ? 'odd' : 'even'; ?>"> <tr class="<?php echo ++$i%2 ? 'odd' : 'even'; ?>">
<td><?php echo HTML::anchor('user/service/view/'.$service->id,$service->id); ?></td> <td><?php echo HTML::anchor('user/service/view/'.$service->id,$service->id); ?></td>
<td><?php echo $service->display('type'); ?></td> <td><?php echo $service->display('type'); ?></td>
<td><?php echo $service->invoice_display(); ?></td> <td><?php echo $service->name(); ?></td>
<td><?php echo $service->display('recur_schedule');?></td> <td><?php echo $service->display('recur_schedule');?></td>
<td><?php echo $service->display('price'); ?></td> <td><?php echo $service->display('price'); ?></td>
<td><?php echo $service->display('active'); ?></td> <td><?php echo $service->display('active'); ?></td>

View File

@ -18,7 +18,7 @@ class Model_StaticPage extends ORMOSB {
); );
protected $_has_many = array( protected $_has_many = array(
'staticpage_translate'=>array('foreign_key'=>'static_page_id'), 'staticpage_translate'=>array('foreign_key'=>'static_page_id','far_key'=>'id'),
); );
protected $_belongs_to = array( protected $_belongs_to = array(