[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [10234] Logistic: Functionality for adding requiremen
From: |
Torstein |
Subject: |
[Fmsystem-commits] [10234] Logistic: Functionality for adding requirement values |
Date: |
Tue, 16 Oct 2012 09:13:36 +0000 |
Revision: 10234
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=10234
Author: vator
Date: 2012-10-16 09:13:36 +0000 (Tue, 16 Oct 2012)
Log Message:
-----------
Logistic: Functionality for adding requirement values
Modified Paths:
--------------
trunk/logistic/inc/class.uirequirement.inc.php
trunk/logistic/inc/class.uiresource_type_requirement.inc.php
Modified: trunk/logistic/inc/class.uirequirement.inc.php
===================================================================
--- trunk/logistic/inc/class.uirequirement.inc.php 2012-10-16 09:12:52 UTC
(rev 10233)
+++ trunk/logistic/inc/class.uirequirement.inc.php 2012-10-16 09:13:36 UTC
(rev 10234)
@@ -31,6 +31,9 @@
phpgw::import_class('phpgwapi.uicommon');
phpgw::import_class('logistic.sorequirement');
phpgw::import_class('logistic.soactivity');
+ phpgw::import_class('logistic.soproject');
+ phpgw::import_class('property.soadmin_entity');
+ phpgw::import_class('logistic.soresource_type_requirement');
include_class('logistic', 'requirement');
phpgw::import_class('phpgwapi.datetime');
@@ -38,22 +41,33 @@
class uirequirement extends phpgwapi_uicommon
{
private $so;
+ private $so_requirement_value;
+ private $so_entity;
private $so_activity;
+ private $so_project;
+ private $so_resource_type_requirement;
public $public_functions = array(
'query' => true,
'index' => true,
'add' => true,
'edit' => true,
- 'view' => true
+ 'view' => true,
+ 'add_requirement_values' => true,
+ 'get_custom_attributes' => true
);
public function __construct()
{
parent::__construct();
-
+
$this->so = CreateObject('logistic.sorequirement');
+ $this->so_requirement_value =
CreateObject('logistic.sorequirement_value');
+ $this->so_entity =
CreateObject('property.soadmin_entity');
$this->so_activity =
CreateObject('logistic.soactivity');
+ $this->so_project = CreateObject('logistic.soproject');
+ $this->so_resource_type_requirement =
CreateObject('logistic.soresource_type_requirement');
+
$GLOBALS['phpgw_info']['flags']['menu_selection'] =
"logistic::project::requirement";
}
@@ -227,8 +241,7 @@
}
$location_info =
$GLOBALS['phpgw']->locations->get_name($requirement->get_location_id());
- echo $requirement->get_location_id();
- print_r($location_info);
+
$data = array
(
'value_id' => !empty($requirement) ?
$requirement->get_id() : 0,
@@ -263,7 +276,8 @@
if ($activity_id && is_numeric($activity_id))
{
- $activity =
$this->so_activity->get_single($activity_id);
+ $activity = $this->so_activity->get_single(
$activity_id );
+ $project = $this->so_project->get_single(
$activity->get_project_id() );
}
if (isset($_POST['save_requirement']))
@@ -271,14 +285,15 @@
$requirement->set_id( phpgw::get_var('id') );
$requirement->set_activity_id(
phpgw::get_var('activity_id') );
$requirement->set_no_of_items(
phpgw::get_var('no_of_items') );
+ $requirement->set_location_id(
phpgw::get_var('location_id') );
+ /*
$entity_id = phpgw::get_var('entity_id');
$category_id = phpgw::get_var('category_id');
$location_id =
$GLOBALS['phpgw']->locations->get_id('property',".entity.{$entity_id}.{$category_id}");
-
- $requirement->set_location_id($location_id);
-
+ */
+
if(phpgw::get_var('start_date','string') != '')
{
$start_date_ts =
phpgwapi_datetime::date_to_timestamp( phpgw::get_var('start_date','string') );
@@ -303,7 +318,7 @@
$requirement->set_create_user($user_id);
$requirement_id =
$this->so->store($requirement);
- $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'logistic.uirequirement.view', 'id' => $requirement_id));
+ $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'logistic.uirequirement.add_requirement_values',
'requirement_id' => $requirement_id));
}
else if (isset($_POST['cancel_requirement']))
{
@@ -314,20 +329,132 @@
$accounts =
$GLOBALS['phpgw']->acl->get_user_list_right(PHPGW_ACL_READ, 'run', 'logistic');
$entity_list =
execMethod('property.soadmin_entity.read', array('allrows' => true));
+
+ //$filters = array('project_type_id' =>
$project->get_project_type_id());
+ $filters = array('project_type_id' =>
$project->get_project_type_id());
+ //$search_type =
'resource_type_requirement_list';
+ $search_type = 'distinct_location_id';
+ //$sort_field = 'type_requirement.location_id';
+ $distict_location_ids =
$this->so_resource_type_requirement->get($start_index, $num_of_objects,
$sort_field, $sort_ascending, $search_for, $search_type, $filters);
+
+ $distict_location_ids_array = array();
+
+ foreach($distict_location_ids as
$logistic_resource_type_requirement )
+ {
+ $location_id =
$logistic_resource_type_requirement->get_id();
+ $loc_arr =
$GLOBALS['phpgw']->locations->get_name($location_id);
+
+ $loc_arr['location_id'] = $location_id;
+
+ $distict_locations_array[] = $loc_arr;
+ }
+
+ $custom =
createObject('phpgwapi.custom_fields');
+
+ $attribute_requirement_array = array();
+
+ foreach($attribute_requirement_types as
$attribute_requirement){
+ $location_id =
$attribute_requirement->get_location_id();
+ $cust_attribute_id =
$attribute_requirement->get_cust_attribute_id();
+
+ $loc_arr =
$GLOBALS['phpgw']->locations->get_name($location_id);
+ $entity_arr =
explode('.',$loc_arr['location']);
+
+ $entity_id = $entity_arr[2];
+ $cat_id = $entity_arr[3];
+
+ $attrib_data = $custom->get('property',
".entity.{$entity_id}.{$cat_id}", $cust_attribute_id);
+
+ $attribute_requirement_array[] =
$attrib_data;
+ }
+
+ $tabs = $this->make_tab_menu($requirement_id);
+
+ $data = array
+ (
+ 'tabs'
=> $GLOBALS['phpgw']->common->create_tabs($tabs, 0),
+ 'view'
=> "requirement_details",
+ 'requirement' =>
$requirement,
+ 'distict_locations' =>
$distict_locations_array,
+ // 'attribute_requirement_array' =>
$attribute_requirement_array,
+ 'editable' => true,
+ // 'entity_list' => $entity_list,
+ // 'entity_id' => $entity_id,
+ // 'category_id' => $category_id
+ );
+
+ if($activity_id > 0)
+ {
+ $data['activity'] = $activity;
+ }
+
+
+
$GLOBALS['phpgw']->jqcal->add_listener('start_date');
+
$GLOBALS['phpgw']->jqcal->add_listener('end_date');
+
+ //self::add_javascript('logistic', 'logistic',
'requirement.js');
+
self::render_template_xsl(array('requirement/requirement_tabs',
'requirement/requirement_item'), $data);
+ }
+ }
+ public function add_requirement_values()
+ {
+ $requirement_id = phpgw::get_var('requirement_id');
+
+ if ($requirement_id && is_numeric($requirement_id))
+ {
+ $requirement =
$this->so->get_single($requirement_id);
+ }
+ else
+ {
+ $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'logistic.uirequirement.edit'));
+ }
+
+ if (isset($_POST['save_requirement_values']))
+ {
+ $attributes_array = array();
+ $attributes_array =
phpgw::get_var('cust_attributes');
+
+ foreach($attributes_array as $attribute)
+ {
+ $attribute_array = explode ( ":",
$attribute );
+ $cust_attribute_id =
$attribute_array[0];
+ $operator = $attribute_array[1];
+ $value = $attribute_array[2];
+
+ $requirement_value = new
logistic_requirement_value();
+ $requirement_value->set_id(
phpgw::get_var('id') );
+
+ $requirement_value->set_requirement_id(
$requirement_id );
+ $requirement_value->set_value( $value );
+ $requirement_value->set_operator(
$operator );
+
$requirement_value->set_cust_attribute_id( $cust_attribute_id );
+ $user_id =
$GLOBALS['phpgw_info']['user']['id'];
+
$requirement_value->set_create_user($user_id);
+
+ $requirement_id =
$this->so_requirement_value->store($requirement_value);
+ }
+
+ $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'logistic.uirequirement.add_requirement_values',
'requirement_id' => $requirement_id));
+ }
+ else
+ {
$location_id = $requirement->get_location_id();
+ $activity_id = $requirement->get_activity_id();
- $system_location =
$GLOBALS['phpgw']->locations->get_name($location_id);
- print_r($system_location);
- $location_info =
$GLOBALS['phpgw']->locations->read($location_id);
+ $custom_attributes_array = array();
+ $custom_attributes_array =
$this->get_custom_attributes($location_id, $activity_id);
- print_r($location_info);
+ $tabs = $this->make_tab_menu($requirement_id);
$data = array
(
- 'requirement' => $requirement,
- 'editable' => true,
- 'entity_list' => $entity_list
+ 'tabs'
=>
$GLOBALS['phpgw']->common->create_tabs($tabs, 1),
+ 'view'
=> "requirement_values",
+ 'requirement'
=> $requirement,
+ 'custom_attributes_array' =>
$custom_attributes_array,
+ 'distict_locations'
=> $distict_locations_array,
+ 'editable'
=> true,
);
if($activity_id > 0)
@@ -338,8 +465,73 @@
$GLOBALS['phpgw']->jqcal->add_listener('start_date');
$GLOBALS['phpgw']->jqcal->add_listener('end_date');
- self::add_javascript('logistic', 'logistic',
'resource_type_requirement.js');
-
self::render_template_xsl(array('requirement/requirement_item'), $data);
+ self::add_javascript('logistic', 'logistic',
'requirement.js');
+
self::render_template_xsl(array('requirement/requirement_tabs',
'requirement/requirement_values'), $data);
}
}
- }
+
+ public function get_custom_attributes($location_id,
$activity_id){
+
+ if($location_id == "")
+ {
+ $location_id =
phpgw::get_var('location_id');
+ }
+
+ if($activity_id == "")
+ {
+ $activity_id =
phpgw::get_var('activity_id');
+ }
+
+ $activity = $this->so_activity->get_single(
$activity_id );
+ $project = $this->so_project->get_single(
$activity->get_project_id() );
+ $project_type_id =
$project->get_project_type_id();
+
+ $filters = array('location_id' => $location_id,
'project_type_id' => $project_type_id);
+ $requirement_custom_attributes_array =
$this->so_resource_type_requirement->get($start_index, $num_of_objects,
$sort_field, $sort_ascending, $search_for, $search_type, $filters);
+
+ $custom =
createObject('phpgwapi.custom_fields');
+
+ $attribute_requirement_array = array();
+
+ foreach($requirement_custom_attributes_array as
$attribute_requirement){
+ $location_id =
$attribute_requirement->get_location_id();
+ $cust_attribute_id =
$attribute_requirement->get_cust_attribute_id();
+
+ $loc_arr =
$GLOBALS['phpgw']->locations->get_name($location_id);
+ $entity_arr =
explode('.',$loc_arr['location']);
+
+ $entity_id = $entity_arr[2];
+ $cat_id = $entity_arr[3];
+
+ $attrib_data = $custom->get('property',
".entity.{$entity_id}.{$cat_id}", $cust_attribute_id);
+
+ $attribute_requirement_array[] =
$attrib_data;
+ }
+
+ return $attribute_requirement_array;
+ }
+
+ function make_tab_menu($control_id){
+ $tabs = array();
+
+ if($requirement_id > 0){
+
+ $requirement =
$this->so->get_single($requirement_id);
+
+ $tabs[] = array(
+ 'label' => "1: " .
lang('Details'),
+ 'link' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'controller.uirequirement.edit',
+
'id' => $requirement->get_id()))
+ );
+ }else{
+ $tabs = array(
+ array(
+ 'label' => "1: " .
lang('Details')
+ ), array(
+ 'label' => "2: " .
lang('Add_requirement_values')
+ ));
+ }
+
+ return $tabs;
+ }
+ }
\ No newline at end of file
Modified: trunk/logistic/inc/class.uiresource_type_requirement.inc.php
===================================================================
--- trunk/logistic/inc/class.uiresource_type_requirement.inc.php
2012-10-16 09:12:52 UTC (rev 10233)
+++ trunk/logistic/inc/class.uiresource_type_requirement.inc.php
2012-10-16 09:13:36 UTC (rev 10234)
@@ -397,7 +397,7 @@
return $attrib_data;
}
-
+
public function view()
{
$entity_so =
CreateObject('property.soadmin_entity');
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [10234] Logistic: Functionality for adding requirement values,
Torstein <=