Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/tbar0970/jethro-pmm
Browse files Browse the repository at this point in the history
  • Loading branch information
tbar0970 committed Aug 9, 2017
2 parents 701062c + 335ff9f commit a32ec6d
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 17 deletions.
10 changes: 6 additions & 4 deletions include/db_object.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -710,13 +710,15 @@ public function processFieldInterface($name, $prefix='')
{
if (!$this->id || $this->haveLock()) {
$value = process_widget($prefix.$name, $this->fields[$name]);
if (!is_null($value) || $this->fields[$name]['type'] == 'reference') {
// For a reference field, 'null' might be a meaninful value
// For other fields, it means the field hasn't been submitted.
if ($value !== NULL) {
if (($this->fields[$name]['type'] == 'reference') && ($value === 0)) {
// process_widget returns 0 when the user selects the 'empty' option
// but we want to save NULL to the db.
$value = NULL;
}
$this->setValue($name, $value);
}
}

}


Expand Down
6 changes: 5 additions & 1 deletion include/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,11 @@ function process_widget($name, $params, $index=NULL, $preserveEmpties=FALSE)
}
break;
case 'reference':
$value = empty($rawVal) ? NULL : (int)$rawVal;
if (!array_key_exists($name, $_REQUEST)) {
$value = NULL;
} else {
$value = (int)$rawVal;
}
break;
default:
$value = $rawVal;
Expand Down
10 changes: 8 additions & 2 deletions views/view_8_services.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class View_services extends View

static function getMenuPermissionLevel()
{
return PERM_EDITSERVICE;
return PERM_VIEWSERVICE;
}

function processView()
Expand Down Expand Up @@ -138,14 +138,20 @@ function printView()
<div class="row-fluid">
<div class="span6">
<h3>
<?php
if ($GLOBALS['user_system']->havePerm(PERM_EDITSERVICE)) {
?>
<span class="pull-right">
<small>
<a href="<?php echo build_url(Array('editing' => 1)); ?>"><i class="icon-wrench"></i>Edit</a> &nbsp;
&nbsp;
<a class="med-popup" href="?call=service_plan&serviceid=<?php echo $this->service->id; ?>"><i class="icon-print"></i>Printable</a>
</small>
</span>
Run Sheet
<?php
}
echo _('Run Sheet');
?>
</h3>

<?php
Expand Down
22 changes: 12 additions & 10 deletions views/view_8_services__1_list_all.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class View_Services__List_All extends View
private $_dummy_service = NULL;
private $_editing = FALSE;
private $_saved = FALSE;
private $_have_run_sheets = FALSE;

static function getMenuPermissionLevel()
{
Expand Down Expand Up @@ -93,6 +94,7 @@ private function _loadServices()
foreach ($services as $id => $details) {
$details['id'] = $id;
$this->_grouped_services[$details['date']][$details['congregationid']] = $details;
if ($details['has_items']) $this->_have_run_sheets = TRUE;
}
}
}
Expand Down Expand Up @@ -259,6 +261,8 @@ function _printServiceProgram()
$message = '';
if ($GLOBALS['user_system']->havePerm(PERM_EDITSERVICE)) {
$message .= _('Click a service below to edit its run sheet');
} else if ($this->_have_run_sheets) {
$message .= _('Click a service below to view its run sheet');
}
if ($GLOBALS['user_system']->havePerm(PERM_BULKSERVICE)) {
$message .= ', '._('or click the "edit" button above to edit the service schedule including bible readings and titles.');
Expand Down Expand Up @@ -419,16 +423,14 @@ function _printParamsForm()
function _printServiceViewCell($congid, $date, $data)
{
if (empty($data)) return;
if ($GLOBALS['user_system']->havePerm(PERM_EDITSERVICE)) {
if ($data['has_items']) {
?>
<a class="take-parent-click pull-right" title="View service run sheet" href="?view=services&date=<?php echo $date; ?>&congregationid=<?php echo $congid; ?>"><i class="icon-list"></i></a>
<?php
} else {
?>
<a class="take-parent-click pull-right" title="Create service run sheet" href="?view=services&editing=1&date=<?php echo $date; ?>&congregationid=<?php echo $congid; ?>"><i class="icon-plus-sign"></i></a>
<?php
}
if ($data['has_items']) {
?>
<a class="take-parent-click pull-right" title="View service run sheet" href="?view=services&date=<?php echo $date; ?>&congregationid=<?php echo $congid; ?>"><i class="icon-list"></i></a>
<?php
} else if ($GLOBALS['user_system']->havePerm(PERM_EDITSERVICE)) {
?>
<a class="take-parent-click pull-right" title="Create service run sheet" href="?view=services&editing=1&date=<?php echo $date; ?>&congregationid=<?php echo $congid; ?>"><i class="icon-plus-sign"></i></a>
<?php
}
$this->_dummy_service->populate($data['id'], $data);
$this->_dummy_service->printFieldValue('summary');
Expand Down

0 comments on commit a32ec6d

Please sign in to comment.