Source for file consume.php
Documentation is available at consume.php
* Edit/create/delete consumables records
* @author Stuart Prescott
* @copyright Copyright Stuart Prescott
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* path (bumblebee root)/inc/actions/consume.php
/** Load ancillary functions */
require_once 'inc/typeinfo.php';
/** ConsumableUse object */
require_once 'inc/bb/consumableuse.php';
require_once 'inc/bb/consumable.php';
require_once 'inc/bb/user.php';
require_once 'inc/bb/daterange.php';
/** date manipulation routines */
require_once 'inc/date.php';
require_once 'inc/formslib/anchortablelist.php';
require_once 'inc/actions/actionaction.php';
* Edit/create/delete consumables records
* @param BumblebeeAuth $auth Authorisation object
* @param array $pdata extra state data from the call path
if (isset
($this->PD['list'])) {
$daterange =
new DateRange('daterange', T_('Select date range'),
T_('Enter the dates over which you want to report consumable use'));
$daterange->update($this->PD);
$daterange->checkValid();
if ($daterange->newObject ||
!$daterange->isValid) {
echo
$daterange->display($this->PD);
} elseif (isset
($this->PD['consumableid'])) {
} elseif (isset
($this->PD['user'])) {
} elseif (isset
($this->PD['delete'])) {
(! isset
($this->PD['id'])) &&
(! isset
($this->PD['user'])) ||
(! isset
($this->PD['consumableid']))
if (! isset
($this->PD['user'])) {
if (! isset
($this->PD['consumableid'])) {
echo
"<br /><br /><a href='".
makeURL('consume').
"'>".
T_('Return to consumable use list').
"</a>";
* Select which user is consuming the item
if (isset
($this->PD['consumableid'])) {
$path['consumableid'] =
$this->PD['consumableid'];
$userselect->deleted =
false; // don't show deleted users
$userselect->connectDB("users", array('id', 'name', 'username'));
$userselect->hrefbase =
makeURL('consume', array_merge($path, array('user' =>
'__id__')));
$userselect->setFormat('id', '%s', array('name'), ' %s', array('username'));
if (isset
($this->PD['consumableid']) &&
$this->PD['consumableid'] >
0) {
echo
'<p>'.
sprintf(T_('<a href="%s">View listing</a> for selected consumable'),
echo
$userselect->display();
* Select what item is being consumed
if (isset
($this->PD['user'])) {
$path['user'] =
$this->PD['user'];
$consumableselect =
new AnchorTableList(T_('Consumables'), T_('Select which Consumables to use'));
$consumableselect->deleted =
false; // don't show deleted consumables
$consumableselect->connectDB('consumables', array('id', 'name', 'longname'));
$consumableselect->hrefbase =
makeURL('consume', array_merge($path, array('consumableid' =>
'__id__')));
$consumableselect->setFormat('id', '%s', array('name'), ' %50.50s', array('longname'));
if (isset
($this->PD['user']) &&
$this->PD['user'] >
0) {
echo
'<p>'.
sprintf(T_('<a href="%s">View listing</a> for selected user'),
echo
$consumableselect->display();
$recordid = isset
($this->PD['id']) ?
$this->PD['id'] : -
1;
$userid = isset
($this->PD['user']) ?
$this->PD['user'] : -
1;
$consumableid = isset
($this->PD['consumableid']) ?
$this->PD['consumableid'] : -
1;
$ip =
$this->auth->getRemoteIP();
$uid, $ip, $today->dateString());
STATUS_OK =>
($recordid <
0 ?
T_('Consumption recorded')
:
T_('Consumption record updated')),
STATUS_ERR =>
T_('Consumption record could not be changed:').
' '.
$rec->errorMessage
$submit =
T_('Record consumable use');
$submit =
T_('Update entry');
$delete =
T_('Delete entry');
echo
"<input type='submit' name='submit' value='$submit' />";
if ($delete) echo
"<input type='submit' name='delete' value='$delete' />";
STATUS_ERR =>
T_('Consumption record could not be deleted:')
.
'<br/><br/>'.
$rec->errorMessage
* list the consumption records for this particular consumable
* @param integer $consumableID table ID number of consumable to be displayed
* @param DateRange $daterange time period over which consumption records are to be displayed
$start =
$daterange->getStart();
$stop =
$daterange->getStop();
.
sprintf(T_('Consumption records for %s'), $consumable->fields['name']->value)
T_('Select the consumption record to view'), 3);
$recselect->deleted =
NULL;
$recselect->setTableHeadings(array(T_('Date'), T_('User'), T_('Quantity')));
$recselect->connectDB('consumables_use',
array(array('consumables_use.id','conid'), 'consumable', 'usewhen', 'username', 'name', 'quantity'),
'consumable='.
qw($consumableID)
.
' AND usewhen >= '.
qw($start->dateTimeString())
.
' AND usewhen < '.
qw($stop->dateTimeString()),
array('consumables_use.id','conid'),
array('users'=>
'userid=users.id'));
$recselect->hrefbase =
makeURL('consume', array('id'=>
'__id__'));
$recselect->setFormat('conid', '%s', array('usewhen'), ' %s (%s)', array('name', 'username'), '%s', array('quantity'));
echo
$recselect->display();
* list the consumption records for this particular consumable
* @param integer $userID table ID number of user to be displayed
* @param DateRange $daterange time period over which consumption records are to be displayed
$start =
$daterange->getStart();
$stop =
$daterange->getStop();
$user =
new User($userID, true);
.
sprintf(T_('Consumption records for %s (%s)'),
$user->fields['username']->value,
$user->fields['name']->value)
T_('Select the consumption record to view'), 3);
$recselect->deleted =
NULL;
$recselect->setTableHeadings(array(T_('Date'), T_('Item'), T_('Quantity')));
$recselect->connectDB('consumables_use',
array(array('consumables_use.id','conid'), 'consumable', 'usewhen', 'name', 'longname', 'quantity'),
.
' AND usewhen >= '.
qw($start->dateTimeString())
.
' AND usewhen < '.
qw($stop->dateTimeString()),
array('consumables_use.id','conid'),
array('consumables'=>
'consumable=consumables.id'));
$recselect->hrefbase =
makeURL('consume', array('id'=>
'__id__'));
$recselect->setFormat('conid', '%s', array('usewhen'), ' %s (%30.30s)', array('name', 'longname'), '%s', array('quantity'));
echo
$recselect->display();
Documentation generated on Tue, 06 Mar 2007 10:01:08 +0000 by phpDocumentor 1.3.0