fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [10351]


From: Torstein
Subject: [Fmsystem-commits] [10351]
Date: Thu, 25 Oct 2012 11:11:26 +0000

Revision: 10351
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=10351
Author:   vator
Date:     2012-10-25 11:11:26 +0000 (Thu, 25 Oct 2012)
Log Message:
-----------


Modified Paths:
--------------
    trunk/logistic/inc/class.sorequirement_resource_allocation.inc.php
    trunk/logistic/inc/class.uiactivity.inc.php
    trunk/logistic/inc/class.uirequirement_resource_allocation.inc.php
    trunk/logistic/inc/model/class.requirement_resource_allocation.inc.php
    trunk/logistic/templates/base/allocation/allocation_suggestions.xsl
    trunk/logistic/templates/base/css/base.css

Modified: trunk/logistic/inc/class.sorequirement_resource_allocation.inc.php
===================================================================
--- trunk/logistic/inc/class.sorequirement_resource_allocation.inc.php  
2012-10-25 09:22:25 UTC (rev 10350)
+++ trunk/logistic/inc/class.sorequirement_resource_allocation.inc.php  
2012-10-25 11:11:26 UTC (rev 10351)
@@ -43,36 +43,82 @@
                        $this->local_db = clone $this->db;
                }
 
-               protected function add(&$object)
+               protected function add(&$resource_alloc)
                {
+                       $cols = array(
+                               'requirement_id',
+                               'resource_id',
+                               'location_id',
+                               'create_user',
+                               'create_date'
+                       );
 
+                       $values = array(
+                               
$this->marshal($resource_alloc->get_requirement_id(), 'int'),
+                               
$this->marshal($resource_alloc->get_resource_id(), 'int'),
+                               
$this->marshal($resource_alloc->get_location_id(), 'int'),
+                               
$this->marshal($resource_alloc->get_create_user(), 'int'),
+                               $this->marshal(strtotime('now'), 'int')
+                       );
+
+                       $sql = 'INSERT INTO lg_requirement_resource_allocation 
(' . join(',', $cols) . ') VALUES (' . join(',', $values) . ')';
+                       $result = $this->db->query($sql, __LINE__,__FILE__);
+
+                       if($result)
+                       {
+                               return 
$this->db->get_last_insert_id('lg_requirement_resource_allocation', 'id');
+                       }
+                       else
+                       {
+                               return 0;
+                       }
                }
 
+               protected function update($resource_alloc)
+               {
+                       $id = intval($resource_alloc->get_id());
+               
+                       $values = array(
+                               'requirement_id=' . 
$this->marshal($resource_alloc->get_requirement_id(), 'string'),
+                               'resource_id=' . 
$this->marshal($resource_alloc->get_resource_id(), 'string'),
+                               'location_id=' . 
$this->marshal($resource_alloc->get_location_id(), 'int')
+                       );
+
+                       $result = $this->db->query('UPDATE 
lg_requirement_resource_allocation SET ' . join(',', $values) . " WHERE 
id=$id", __LINE__,__FILE__);
+
+                       if($result)
+                       {
+                               return $id;
+                       }
+                       else
+                       {
+                               return 0;
+                       }
+               }
+
                protected function get_id_field_name()
                {
+                       if(!$extended_info)
+                       {
+                               $ret = 'id';
+                       }
+                       else
+                       {
+                               $ret = array
+                               (
+                                       'table'                 => 
'lg_requirement_resource_allocation', // alias
+                                       'field'                 => 'id',
+                                       'translated'    => 'id'
+                               );
+                       }
 
+                       return $ret;
                }
 
                protected function get_query(string $sort_field, boolean 
$ascending, string $search_for, string $search_type, array $filters, boolean 
$return_count)
                {
                        $clauses = array('1=1');
 
-                       /*if($search_for)
-                       {
-                               $like_pattern = "'%" . 
$this->db->db_addslashes($search_for) . "%'";
-                               $like_clauses = array();
-                               switch($search_type)
-                               {
-                                       default:
-                                               $like_clauses[] = 
"{$table_alias}.name $this->like $like_pattern";
-                                               break;
-                               }
-                               if(count($like_clauses))
-                               {
-                                       $clauses[] = '(' . join(' OR ', 
$like_clauses) . ')';
-                               }
-                       }*/
-
                        $filter_clauses = array();
                        if(isset($filters[$this->get_id_field_name()]))
                        {
@@ -94,11 +140,10 @@
 
                        $condition =  join(' AND ', $clauses);
 
-                       //$joins = " {$this->left_join} controller_control_area 
ON (controller_procedure.control_area_id = controller_control_area.id)";
 
                        $tables = "lg_requirement_resource_allocation 
allocation";
 
-                       if($return_count) // We should only return a count
+                       if($return_count)
                        {
                                $cols = 'COUNT(DISTINCT(allocation.id)) AS 
count';
                        }
@@ -127,11 +172,6 @@
                        return $allocation;
                }
 
-               protected function update($object)
-               {
-
-               }
-
                public static function get_instance()
                {
                        if (self::$so == null)

Modified: trunk/logistic/inc/class.uiactivity.inc.php
===================================================================
--- trunk/logistic/inc/class.uiactivity.inc.php 2012-10-25 09:22:25 UTC (rev 
10350)
+++ trunk/logistic/inc/class.uiactivity.inc.php 2012-10-25 11:11:26 UTC (rev 
10351)
@@ -237,7 +237,6 @@
                        $result_count = 0;
 
                        //Retrieve a contract identifier and load corresponding 
contract
-                       //$activity_id = phpgw::get_var('activity_id');
 
                        $exp_param = phpgw::get_var('export');
                        $export = false;

Modified: trunk/logistic/inc/class.uirequirement_resource_allocation.inc.php
===================================================================
--- trunk/logistic/inc/class.uirequirement_resource_allocation.inc.php  
2012-10-25 09:22:25 UTC (rev 10350)
+++ trunk/logistic/inc/class.uirequirement_resource_allocation.inc.php  
2012-10-25 11:11:26 UTC (rev 10351)
@@ -32,6 +32,7 @@
        include_class('logistic', 'activity', '/inc/model/');
        include_class('logistic', 'requirement', '/inc/model/');
        include_class('logistic', 'requirement_value', '/inc/model/');
+       include_class('logistic', 'requirement_resource_allocation', 
'/inc/model/');
 
 
        class logistic_uirequirement_resource_allocation extends 
phpgwapi_uicommon
@@ -58,37 +59,36 @@
                        'add'   => true,
                        'edit' => true,
                        'view' => true,
-                       'index' => true
+                       'index' => true,
+                       'save' => true
                );
 
                public function __construct()
                {
                        parent::__construct();
 
-                       $this->so = 
createObject('logistic.sorequirement_resource_allocation');
-                 $this->bo                                     = 
CreateObject('property.bolocation',true);
-                       $this->bocommon                         = & 
$this->bo->bocommon;
-
-                       $this->so_activity = 
createObject('logistic.soactivity');
-                       $this->so_requirement = 
createObject('logistic.sorequirement');
+                       $this->so                                               
                        = 
createObject('logistic.sorequirement_resource_allocation');
+                       $this->so_activity                                      
= createObject('logistic.soactivity');
+                       $this->so_requirement                   = 
createObject('logistic.sorequirement');
                        $this->so_requirement_value = 
CreateObject('logistic.sorequirement_value');
+                       
+                 $this->bo                                                     
                        = CreateObject('property.bolocation',true);
+                       $this->bocommon                                         
        = & $this->bo->bocommon;
 
-                       $this->type_id                          = 
$this->bo->type_id;
+                       $this->type_id                                          
        = $this->bo->type_id;
 
-                       $this->start                            = 
$this->bo->start;
-                       $this->query                            = 
$this->bo->query;
-                       $this->sort                                     = 
$this->bo->sort;
-                       $this->order                            = 
$this->bo->order;
-                       $this->filter                           = 
$this->bo->filter;
-                       $this->cat_id                           = 
$this->bo->cat_id;
-                       $this->part_of_town_id          = 
$this->bo->part_of_town_id;
-                       $this->district_id                      = 
$this->bo->district_id;
-                       $this->status                           = 
$this->bo->status;
-                       $this->allrows                          = 
$this->bo->allrows;
-                       $this->lookup                           = 
$this->bo->lookup;
-                       $this->location_code            = 
$this->bo->location_code;
-
-                       $GLOBALS['phpgw_info']['flags']['menu_selection'] = 
"logistic::project::activity";
+                       $this->start                                            
                = $this->bo->start;
+                       $this->query                                            
                = $this->bo->query;
+                       $this->sort                                             
                        = $this->bo->sort;
+                       $this->order                                            
                = $this->bo->order;
+                       $this->filter                                           
                = $this->bo->filter;
+                       $this->cat_id                                           
                = $this->bo->cat_id;
+                       $this->part_of_town_id                  = 
$this->bo->part_of_town_id;
+                       $this->district_id                                      
= $this->bo->district_id;
+                       $this->status                                           
                = $this->bo->status;
+                       $this->allrows                                          
        = $this->bo->allrows;
+                       $this->lookup                                           
                = $this->bo->lookup;
+                       $this->location_code                            = 
$this->bo->location_code;
                }
 
                public function index()
@@ -245,6 +245,7 @@
                        {
                                $activity = 
$this->so_activity->get_single($activity_id);
                        }
+                       
                        if($requirement_id && is_numeric($requirement_id))
                        {
                                $requirement = 
$this->so_requirement->get_single($requirement_id);
@@ -315,6 +316,8 @@
                        $so_entity      = 
CreateObject('property.soentity',$entity_id,$cat_id);
                        $allocation_suggestions = 
$so_entity->get_eav_list($criterias_array);
 
+                       print_r($allocation_suggestions);
+                       
                        $data = array
                        (
                                'requirement'                                   
        => $requirement,
@@ -328,10 +331,28 @@
 
                public function save()
                {
+                       $requirement_id = phpgw::get_var('requirement_id');
                        
-                       
$allocation->set_requirement_id(phpgw::get_var('requirement_id'));
-                       
$allocation->set_article_id(phpgw::get_var('article_id'));
-                       $allocation->set_type(phpgw::get_var('type'));
+                       if($requirement_id && is_numeric($requirement_id))
+                       {
+                               $requirement = 
$this->so_requirement->get_single($requirement_id);
+                       }
+                       
+                       $chosen_resources = phpgw::get_var('chosen_resources');
+                       
+                       $user_id = $GLOBALS['phpgw_info']['user']['id'];
+                       
+                       foreach($chosen_resources as $resource_id)
+                       {
+                               $resource_alloc = new 
logistic_requirement_resource_allocation();
+                               $resource_alloc->set_requirement_id( 
$requirement->get_id() );
+                               $resource_alloc->set_resource_id( $resource_id 
);
+                               $resource_alloc->set_location_id( 
$requirement->get_location_id() );
+                               $resource_alloc->set_create_user( $user_id );
+                               
+                               $resource_alloc_id = $this->so->store( 
$resource_alloc );
+                       }
+                       
 
                        $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'logistic.uirequirement_resource_allocation.view', 'id' 
=> $allocation_id));
                }

Modified: trunk/logistic/inc/model/class.requirement_resource_allocation.inc.php
===================================================================
--- trunk/logistic/inc/model/class.requirement_resource_allocation.inc.php      
2012-10-25 09:22:25 UTC (rev 10350)
+++ trunk/logistic/inc/model/class.requirement_resource_allocation.inc.php      
2012-10-25 11:11:26 UTC (rev 10351)
@@ -33,10 +33,11 @@
        {
                public static $so;
 
-               protected static $id;
-               protected static $requirement_id;
-               protected static $resource_id;
-               protected static $location_id;
+               protected $id;
+               protected $requirement_id;
+               protected $resource_id;
+               protected $location_id;
+               protected $create_user;
 
                /**
                 * Constructor.  Takes an optional ID.  If a contract is 
created from outside
@@ -88,7 +89,17 @@
                {
                        return $this->location_id;
                }
+               
+               public function set_create_user($create_user)
+               {
+                       $this->create_user = $create_user;
+               }
 
+               public function get_create_user()
+               {
+                       return $this->create_user;
+               }
+
                /**
                * Get a static reference to the storage object associated with 
this model object
                *
@@ -105,23 +116,5 @@
 
                public function serialize()
                {
-                       $entity_so      = 
CreateObject('property.soadmin_entity');
-                       $project_so = CreateObject('logistic.soproject');
-                       $loc_arr = 
$GLOBALS['phpgw']->locations->get_name($this->get_location_id());
-                       $entity_arr = explode('.',$loc_arr['location']);
-
-                       $entity = $entity_so->read_single($entity_arr[2]);
-                       $category = 
$entity_so->read_single_category($entity_arr[2],$entity_arr[3]);
-                       $entity_label = $entity['name'];
-                       $category_label = $category['name'];
-                       $project_type_label  = 
$project_so->get_project_type_label($this->get_project_type_id());
-
-                       return array(
-                               'id' => $this->get_id(),
-                               'location_id' => $this->get_location_id(),
-                               'entity_label' => $entity_label,
-                               'category_label' => $category_label,
-                               'project_type_label' => $project_type_label
-                       );
                }
        }
\ No newline at end of file

Modified: trunk/logistic/templates/base/allocation/allocation_suggestions.xsl
===================================================================
--- trunk/logistic/templates/base/allocation/allocation_suggestions.xsl 
2012-10-25 09:22:25 UTC (rev 10350)
+++ trunk/logistic/templates/base/allocation/allocation_suggestions.xsl 
2012-10-25 11:11:26 UTC (rev 10351)
@@ -30,14 +30,12 @@
                                </li>
                                </ul>
                        </div>
-                        
-                       <hr style="border-color: #9FB9D7;margin: 0 15px;" />
                        
                        <xsl:variable name="action_url">
                                <xsl:value-of 
select="php:function('get_phpgw_link', '/index.php', 
'menuaction:logistic.uirequirement_resource_allocation.save')" />
                        </xsl:variable>
                        <form action="{$action_url}" method="post">
-                               <input type="hidden" name="id" value = 
"{requirement/id}" />
+                               <input type="hidden" name="requirement_id" 
value="{requirement/id}" />
 
                                <div id="resource-list">
                                        <div class="resource heading">
@@ -66,6 +64,8 @@
                                                </div>
                                        </xsl:for-each>
                                </div>                  
+                               
+                               <input type="submit" value="Lagre" />
                        </form>
        </div>
 </div>

Modified: trunk/logistic/templates/base/css/base.css
===================================================================
--- trunk/logistic/templates/base/css/base.css  2012-10-25 09:22:25 UTC (rev 
10350)
+++ trunk/logistic/templates/base/css/base.css  2012-10-25 11:11:26 UTC (rev 
10351)
@@ -2280,8 +2280,8 @@
     
 }
 
-#requirement-wrp h2{
-       margin:0 0 10px;
+#requirement-wrp h2 {
+    margin: 0 0 15px;
 }
 
 #requirement-wrp ul li{




reply via email to

[Prev in Thread] Current Thread [Next in Thread]