work on accessories

This commit is contained in:
Cornelius Weiß 2005-02-28 15:19:31 +00:00
parent 37fa750990
commit 5eac376f6e
6 changed files with 65 additions and 21 deletions

View File

@ -42,6 +42,7 @@ class bo_resources
'short_description' => $query['search']
);
$cats = $query['filter'] ? array($query['filter'] => '') : $this->acl->get_cats(PHPGW_ACL_READ);
$accessory_of = $query['view_accs_of'] ? $query['view_accs_of'] : -1;
$rows = array( 0 => array( 'id' => '',
'name' => '',
@ -56,7 +57,8 @@ class bo_resources
$order_by = $query['order'] ? $query['order'].' '. $query['sort'] : '';
$nr = $this->so->search($criteria,$cats,&$rows,$accessory_of=-1,$order_by,$offset=$query['start'],$num_rows=0);
$nr = $this->so->search($criteria,$cats,&$rows,$accessory_of,$order_by,$offset=$query['start'],$num_rows=0);
foreach($rows as $num => $resource)
{
if (!$this->acl->is_permitted($resource['cat_id'],PHPGW_ACL_EDIT))
@ -67,6 +69,10 @@ class bo_resources
{
$readonlys["delete[$resource[id]]"] = true;
}
if ((!$this->acl->is_permitted($resource['cat_id'],PHPGW_ACL_ADD)) || $accessory_of != -1)
{
$readonlys["new_acc[$resource[id]]"] = true;
}
if (!$resource['bookable'] /* && calender-acl viewable */)
{
$readonlys["bookable[$resource[id]]"] = true;
@ -181,6 +187,10 @@ class bo_resources
{
$this->link->link('resources',$resource['id'],$resource['link_to']['to_id']);
}
if($resource['accessory_of'] != -1)
{ echo $resource['id'].', '.$resource['accessory_of'];
$this->link->link('resources',$resource['id'],'resources',$resource['accessory_of']);
}
return $this->so->save($resource) ? false : lang('Something went wrong by saving resource');
}
@ -365,7 +375,7 @@ class bo_resources
@param bool $size false = thumb, true = full pic
@return string url of picture
*/
function get_picture($id,$size=false)
function get_picture($id=0,$size=false)
{
if ($id > 0)
{

View File

@ -69,6 +69,7 @@ class so_resources
{
$data[$n] = $this->db->row();
}
unset($data[0]);
return $nr;
}

View File

@ -51,22 +51,38 @@ class ui_resources
{
if (isset($content['nm']['rows']))
{
if (isset($content['nm']['rows']['edit']))
{
list($id) = each($content['nm']['rows']['edit']);
return $this->edit($id);
}
elseif (isset($content['nm']['rows']['delete']))
unset($content['nm']['rows']['checkbox']);
switch (key($content['nm']['rows']))
{
list($id) = each($content['nm']['rows']['delete']);
return $this->delete($id);
case 'edit':
list($id) = each($content['nm']['rows']['edit']);
return $this->edit($id);
case 'delete':
list($id) = each($content['nm']['rows']['delete']);
return $this->delete($id);
case 'new_acc':
list($id) = each($content['nm']['rows']['new_acc']);
return $this->edit(array('resource_id' => 0, 'accessory_of' => $id));
case 'view_acc':
list($id) = each($content['nm']['rows']['view_acc']);
$content['view_accs_of'] = $id;
break;
case 'view':
case 'bookable':
case 'buyable':
}
}
if (isset($content['add']))
{
return $this->edit(0);
}
if (isset($content['back']))
{
return $this->index();
}
}
$this->tmpl->read('resources.show');
$content['nm']['get_rows'] = 'resources.bo_resources.get_rows';
$content['nm']['no_filter'] = False;
@ -82,8 +98,17 @@ class ui_resources
{
$no_button['add'] = true;
}
$no_button['back'] = true;
$this->tmpl->read('resources.show');
if($content['view_accs_of'])
{
$content['nm']['get_rows'] = 'resources.bo_resources.get_rows';
$content['nm']['no_filter'] = true;
$content['nm']['no_filter2'] = true;
$content['nm']['view_accs_of'] = $content['view_accs_of'];
$no_button['add'] = true;
$no_button['back'] = false;
}
$this->tmpl->exec('resources.ui_resources.index',$content,$sel_options,$no_button,$preserv);
}
@ -126,9 +151,6 @@ class ui_resources
{
$resource_id = $content;
$content = array('resource_id' => $resource_id);
// some presetes
$content['quantity'] = $content['useable'] = 1;
$content['accessory_of'] = -1;
if ($resource_id > 0)
{
@ -139,13 +161,23 @@ class ui_resources
'to_id' => $resource_id,
'to_app' => 'resources'
);
// $sel_options += array('acc_list' => $this->bo->get_acc_list($resource_id));
}
$content['resource_picture'] = $this->bo->get_picture($resource_id,$content['picture_src'],$size=true);
}
$sel_options['cat_id'] = $this->bo->acl->get_cats(PHPGW_ACL_ADD);
// some presetes
$content['resource_picture'] = $this->bo->get_picture($content['resource_id'],$content['picture_src'],$size=true);
$content['accessory_of'] = $content['accessory_of'] ? $content['accessory_of'] : -1;
$content['quantity'] = $content['quantity'] ? $content['quantity'] : 1;
$content['useable'] = $content['useable'] ? $content['useable'] : 1;
$sel_options['cat_id'] = $this->bo->acl->get_cats(PHPGW_ACL_ADD);
$sel_options['cat_id'] = count($sel_options['cat_id']) == 1 ? $sel_options['cat_id'] : array('' => lang('select one')) + $sel_options['cat_id'];
if($content['accessory_of'] != -1)
{
$catofmaster = $this->bo->so->get_value('cat_id',$content['accessory_of']);
$sel_options['cat_id'] = array($catofmaster => $sel_options['cat_id'][$catofmaster]);
}
$sel_options['gen_src_list'] = $this->bo->get_genpicturelist();
$no_button = array(); // TODO: show delete button only if allowed to delete resource

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
.buttonbox {vertical-align: top;}