fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [12023] property: more on calculation import to worko


From: Sigurd Nes
Subject: [Fmsystem-commits] [12023] property: more on calculation import to workorder
Date: Wed, 25 Jun 2014 11:03:00 +0000

Revision: 12023
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=12023
Author:   sigurdne
Date:     2014-06-25 11:02:58 +0000 (Wed, 25 Jun 2014)
Log Message:
-----------
property: more on calculation import to workorder

Modified Paths:
--------------
    trunk/property/inc/class.bowo_hour.inc.php
    trunk/property/inc/class.sowo_hour.inc.php

Modified: trunk/property/inc/class.bowo_hour.inc.php
===================================================================
--- trunk/property/inc/class.bowo_hour.inc.php  2014-06-24 11:56:20 UTC (rev 
12022)
+++ trunk/property/inc/class.bowo_hour.inc.php  2014-06-25 11:02:58 UTC (rev 
12023)
@@ -421,16 +421,16 @@
                                $section_name = $valueset['name'];
                                foreach($valueset['data'] as $entry)
                                {
-                                       if((int)$entry[4] > 0)
+                                       if((int)$entry[5] > 0)
                                        {
                                                $values = array
                                                (
                                                        'activity_num'          
=> $entry[0],
                                                        'descr'                 
        => $entry[1],
-                                                       'unit'                  
        => 8, // FIXME
-                                                       'cost'                  
        => $entry[5],
-                                                       'quantity'              
        => $entry[4],
-                                                       'billperae'             
        => $entry[3],
+                                                       'unit'                  
        => $entry[2],
+                                                       'cost'                  
        => $entry[6],
+                                                       'quantity'              
        => $entry[5],
+                                                       'billperae'             
        => $entry[4],
                                                        'ns3420_id'             
        => '',
                                                        'dim_d'                 
        => '',
                                                        'new_grouping'          
=> $section_name,

Modified: trunk/property/inc/class.sowo_hour.inc.php
===================================================================
--- trunk/property/inc/class.sowo_hour.inc.php  2014-06-24 11:56:20 UTC (rev 
12022)
+++ trunk/property/inc/class.sowo_hour.inc.php  2014-06-25 11:02:58 UTC (rev 
12023)
@@ -275,10 +275,25 @@
                        return $receipt;
                }
 
+               /**
+                * Fetch ids from within given grouping serie
+                * @param integer $workorder_id
+                * @param integer $grouping_id
+                * @return integer
+                */
+               function next_record($workorder_id, $grouping_id = 0)
+               {
+                       $grouping_id = (int) $grouping_id;
+                       if($grouping_id)
+                       {
+                               $gouping_filter = "AND  grouping_id = 
{$grouping_id}";
+                       }
+                       else
+                       {
+                               $gouping_filter = "AND  grouping_id IS NULL";
+                       }
 
-               function next_record($workorder_id)
-               {
-                       $this->db->query("SELECT  max(record) as record FROM 
fm_wo_hours where workorder_id='$workorder_id'",__LINE__,__FILE__);
+                       $this->db->query("SELECT  max(record) as record FROM 
fm_wo_hours where workorder_id='{$workorder_id}' 
{$gouping_filter}",__LINE__,__FILE__);
                        $this->db->next_record();
                        $record = $this->db->f('record')+1;
                        return $record;
@@ -312,11 +327,13 @@
 
                        $hour = $this->read(array('workorder_id' => 
$workorder_id));
 
-                       $record = $this->next_record($workorder_id);
 
                        for ($i=0; $i<count($hour); $i++)
                        {
-                               $values_insert= array(
+                               $record = 
$this->next_record($workorder_id,$hour[$i]['grouping_id']);
+
+                               $values_insert= array
+                               (
                                        $hour[$i]['activity_id'],
                                        $hour[$i]['activity_num'],
                                        $this->account,
@@ -333,7 +350,8 @@
                                        $hour[$i]['tolerance'],
                                        $hour[$i]['building_part'],
                                        $record,
-                                       $template_id );
+                                       $template_id
+                               );
 
                                $values_insert  = 
$this->db->validate_insert($values_insert);
 
@@ -357,7 +375,8 @@
 
                        for ($i=0; $i<count($hour); $i++)
                        {
-                               $values= array(
+                               $values= array
+                               (
                                        $hour[$i]['activity_id'],
                                        $hour[$i]['activity_num'],
                                        $this->account,
@@ -393,8 +412,6 @@
                function add_hour_from_template($hour,$workorder_id)
                {
 
-                       $record = $this->next_record($workorder_id);
-
                        if($hour[0]['chapter_id'])
                        {
                                $this->db->query("UPDATE fm_workorder set
@@ -422,6 +439,8 @@
                                        $grouping_descr = 
$hour[$i]['new_grouping'];
                                }
 
+                               $record = 
$this->next_record($workorder_id,$grouping_id);
+
                                $values= array(
                                        $this->account,
                                        $hour[$i]['activity_id'],
@@ -461,7 +480,6 @@
 
                function add_custom_hour($hour,$workorder_id)
                {
-                       $hour['record'] = $this->next_record($workorder_id);
 
                        if($hour['chapter_id'])
                        {
@@ -483,6 +501,7 @@
                                if ( $this->db->f('grouping_id'))
                                {
                                        $hour['grouping_id']    = 
$this->db->f('grouping_id');
+
                                }
                                else
                                {
@@ -494,6 +513,8 @@
                                $hour['grouping_descr'] = $hour['new_grouping'];
                        }
 
+                       $hour['record'] = 
$this->next_record($workorder_id,$hour['grouping_id']);
+
                        if(!$hour['cat_per_cent'])
                        {
                                $hour['cat_per_cent']= 100;




reply via email to

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