phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] hrm/inc class.uijob.inc.php, 1.4 class.sojob.inc.php,


From: sigurdne
Subject: [Phpgroupware-cvs] hrm/inc class.uijob.inc.php, 1.4 class.sojob.inc.php, 1.5 class.bojob.inc.php, 1.4 class.menu.inc.php, 1.3 class.bocommon.inc.php, 1.3
Date: Tue, 22 Nov 2005 14:26:00 +0100

Update of hrm/inc

Modified Files:
     Branch: MAIN
            class.uijob.inc.php lines: +108 -23
            class.sojob.inc.php lines: +144 -16
            class.bojob.inc.php lines: +19 -1
            class.menu.inc.php lines: +3 -3
            class.bocommon.inc.php lines: +3 -3

Log Message:
*** empty log message ***

====================================================
Index: hrm/inc/class.uijob.inc.php
diff -u hrm/inc/class.uijob.inc.php:1.3 hrm/inc/class.uijob.inc.php:1.4
--- hrm/inc/class.uijob.inc.php:1.3     Mon Nov 21 20:25:33 2005
+++ hrm/inc/class.uijob.inc.php Tue Nov 22 13:26:35 2005
@@ -28,11 +28,13 @@

                var $public_functions = array
                (
-                       'index'         => True,
-                       'view'          => True,
-                       'edit_job'      => True,
-                       'edit'          => True,
-                       'delete'        => True
+                       'index'                         => True,
+                       'view'                          => True,
+                       'edit_job'                      => True,
+                       'edit'                          => True,
+                       'delete'                        => True,
+                       'delete_job'                    => True,
+                       'reset_job_type_hierarchy'      => True
                );

                function uijob()
@@ -94,12 +96,15 @@
                                        'descr'                         => 
$entry['descr'],
                                        'link_add_sub'                  => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uijob.edit_job&parent_id='
 . $entry['id']),
                                        'link_edit'                     => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uijob.edit_job&id='
 . $entry['id']),
+                                       'link_delete'                   => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uijob.delete_job&job_id='
 . $entry['id']),
                                        'link_view'                     => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uijob.view_job&id='
 . $entry['id']),
                                        'lang_view_job_text'            => 
lang('view the job'),
                                        'lang_edit_job_text'            => 
lang('edit the job'),
+                                       'lang_delete_job_text'          => 
lang('delete the job'),
                                        'lang_add_sub_text'             => 
lang('Add a new sub-job'),
                                        'text_view'                     => 
lang('view'),
                                        'text_edit'                     => 
lang('edit'),
+                                       'text_delete'                   => 
lang('delete'),
                                        'text_add_sub'                  => 
lang('Add sub'),
                                );
                        }
@@ -122,14 +127,22 @@
                                'lang_name'     => lang('name'),
                                'lang_descr'    => lang('descr'),
                                'lang_edit'     => lang('edit'),
+                               'lang_delete'   => lang('delete'),
                                'lang_view'     => lang('view'),
                        );

                        $table_add[] = array
                        (
                                'lang_add'                              => 
lang('add'),
-                               'lang_add_categorytext' => lang('add a 
category'),
-                               'add_action'                    => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uijob.edit_job')
+                               'lang_add_statustext'   => lang('add a 
category'),
+                               'add_action'                    => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uijob.edit_job'),
+                               'lang_reset'            => lang('reset 
hierarchy'),
+                               'lang_reset_statustext' => lang('Reset the 
hierarchy'),
+                               'reset_action'          => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uijob.reset_job_type_hierarchy')
+                       );
+
+                       $table_reset_job_type[] = array
+                       (
                        );

                        if(!$this->allrows)
@@ -163,14 +176,14 @@
                                'record_limit'                                  
=> $record_limit,
                                'num_records'                                   
=> count($job_info),
                                'all_records'                                   
=> $this->bo->total_records,
-                               'link_url'                                      
        => $GLOBALS['phpgw']->link('/index.php',$link_data),
-                               'img_path'                                      
        => $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
-                               'lang_searchfield_categorytext' => lang('Enter 
the search string. To show all entries, empty this field and press the SUBMIT 
button again'),
-                               'lang_searchbutton_categorytext'        => 
lang('Submit the search string'),
+                               'link_url'                                      
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+                               'img_path'                                      
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+                               'lang_searchfield_statustext'   => lang('Enter 
the search string. To show all entries, empty this field and press the SUBMIT 
button again'),
+                               'lang_searchbutton_statustext'  => lang('Submit 
the search string'),
                                'query'                                         
        => $this->query,
                                'lang_search'                                   
=> lang('search'),
                                'table_header'                                  
=> $table_header,
-                               'values'                                        
        => $content,
+                               'values'                                        
=> $content,
                                'table_add_job'                                 
=> $table_add
                        );

@@ -270,10 +283,10 @@
                                'lang_name_status_text'                 => 
lang('name of the job-type'),


-                               'lang_id_categorytext'  => lang('Enter the 
category ID'),
-                               'lang_descr_categorytext'                       
=> lang('Enter a description the category'),
-                               'lang_done_categorytext'                        
=> lang('Back to the list'),
-                               'lang_save_categorytext'                        
=> lang('Save the category'),
+                               'lang_id_statustext'    => lang('Enter the 
category ID'),
+                               'lang_descr_statustext'                 => 
lang('Enter a description the category'),
+                               'lang_done_statustext'                  => 
lang('Back to the list'),
+                               'lang_save_statustext'                  => 
lang('Save the category'),
                                'type_id'                               => 
$values['type_id'],
                                'value_descr'                                   
=> $values['descr'],
                                'value_name'                                    
=> $values['name'],
@@ -371,10 +384,10 @@
                                'lang_save'                                     
        => lang('save'),
                                'lang_done'                                     
        => lang('done'),
                                'value_id'                              => $id,
-                               'lang_id_categorytext'  => lang('Enter the 
category ID'),
-                               'lang_descr_categorytext'                       
=> lang('Enter a description the category'),
-                               'lang_done_categorytext'                        
=> lang('Back to the list'),
-                               'lang_save_categorytext'                        
=> lang('Save the category'),
+                               'lang_id_statustext'    => lang('Enter the 
category ID'),
+                               'lang_descr_statustext'                 => 
lang('Enter a description the category'),
+                               'lang_done_statustext'                  => 
lang('Back to the list'),
+                               'lang_save_statustext'                  => 
lang('Save the category'),
                                'type_id'                               => 
$category['type_id'],
                                'value_descr'                                   
=> $category['descr']
                        );
@@ -414,12 +427,84 @@
                                'delete_action'                 => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uijob.delete&id='
 . $id.'&type='.$type . '&type_id=' . $type_id),
                                'lang_confirm_msg'              => lang('do you 
really want to delete this entry'),
                                'lang_yes'                              => 
lang('yes'),
-                               'lang_yes_categorytext' => lang('Delete the 
entry'),
-                               'lang_no_categorytext'  => lang('Back to the 
list'),
+                               'lang_yes_statustext'   => lang('Delete the 
entry'),
+                               'lang_no_statustext'    => lang('Back to the 
list'),
                                'lang_no'                               => 
lang('no')
                        );

                        $appname                                        = 
lang('HRM');
+                       $function_msg                                   = 
lang('delete');
+
+                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
+               }
+
+               function delete_job()
+               {
+                       $job_id = get_var('job_id',array('POST','GET'));
+                       $confirm                = 
get_var('confirm',array('POST'));
+
+                       $link_data = array
+                       (
+                               'menuaction' => 
$this->currentapp.'.uijob.index',
+                               'job_id' => $job_id
+                       );
+
+                       if (get_var('confirm',array('POST')))
+                       {
+                               $this->bo->delete_job($job_id);
+                               Header('Location: ' . 
$GLOBALS['phpgw']->link('/index.php',$link_data));
+                       }
+
+                       
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
+
+                       $data = array
+                       (
+                               'done_action'                   => 
$GLOBALS['phpgw']->link('/index.php',$link_data),
+                               'delete_action'                 => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uijob.delete_job&job_id='
 . $job_id),
+                               'lang_confirm_msg'              => lang('do you 
really want to delete this entry'),
+                               'lang_yes'                              => 
lang('yes'),
+                               'lang_yes_statustext'   => lang('Delete the 
entry'),
+                               'lang_no_statustext'    => lang('Back to the 
list'),
+                               'lang_no'                               => 
lang('no')
+                       );
+
+                       $appname                                        = 
lang('job');
+                       $function_msg                                   = 
lang('delete');
+
+                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
+               }
+
+               function reset_job_type_hierarchy()
+               {
+                       $confirm                = 
get_var('confirm',array('POST'));
+
+                       $link_data = array
+                       (
+                               'menuaction' => $this->currentapp.'.uijob.index'
+                       );
+
+                       if (get_var('confirm',array('POST')))
+                       {
+                               $this->bo->reset_job_type_hierarchy();
+                               Header('Location: ' . 
$GLOBALS['phpgw']->link('/index.php',$link_data));
+                       }
+
+                       
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
+
+                       $data = array
+                       (
+                               'done_action'                   => 
$GLOBALS['phpgw']->link('/index.php',$link_data),
+                               'delete_action'                 => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uijob.reset_job_type_hierarchy'),
+                               'lang_confirm_msg'              => lang('do you 
really want to reset the hierarchy'),
+                               'lang_yes'                              => 
lang('yes'),
+                               'lang_yes_statustext'   => lang('Reset the 
hierarchy'),
+                               'lang_no_statustext'    => lang('Back to the 
list'),
+                               'lang_no'                               => 
lang('no')
+                       );
+
+                       $appname                                        = 
lang('job');
                        $function_msg                                   = 
lang('delete');

                        $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;

====================================================
Index: hrm/inc/class.sojob.inc.php
diff -u hrm/inc/class.sojob.inc.php:1.4 hrm/inc/class.sojob.inc.php:1.5
--- hrm/inc/class.sojob.inc.php:1.4     Mon Nov 21 21:35:50 2005
+++ hrm/inc/class.sojob.inc.php Tue Nov 22 13:26:35 2005
@@ -209,7 +209,7 @@
                        $insert_values=array(
                                $values['name'],
                                $values['descr'],
-                               $values['parent_id'],
+                               intval($values['parent_id']),
                                $level,
                                time(),
                                $this->account
@@ -231,19 +231,49 @@

                function edit_job($values)
                {
-
                        $this->db->transaction_begin();
                        $table = 'hrm_job';
+
+                       $this->db->query("SELECT job_level FROM $table  where 
id=" . intval($values['id']),__LINE__,__FILE__);
+                       $this->db->next_record();
+                       $old_level      = (int)$this->db->f('job_level');
+
                        if($values['parent_id'])
                        {
                                $this->db->query("SELECT job_level FROM $table  
where id=" . intval($values['parent_id']),__LINE__,__FILE__);
                                $this->db->next_record();
                                $level  = (int)$this->db->f('job_level') +1;
                        }
+                       else
+                       {
+                               $level  = 0;
+                       }

+                       if($old_level !=$level)
+                       {
+                               $this->level = $level;
+                               $this->parent_gap = 1;
+                               $this->job_parent = $values['id'];
+                               while ($this->job_parent)
+                               {
+                                       $this->check_move_child();
+
+                               }
+
+                               if (is_array($this->move_child))
+                               {
+                                       foreach ($this->move_child as $child)
+                                       {
+                                               $new_level = 
$child['new_level'];
+                                               $this->db->query("UPDATE $table 
set job_level= $new_level WHERE id=" . intval($child['id']),__LINE__,__FILE__);
+                                       }
+                               }
+
+                       }
+
                        $value_set['descr']                     = 
$this->db->db_addslashes($values['descr']);
                        $value_set['name']                      = 
$this->db->db_addslashes($values['name']);
-                       $value_set['job_parent']                = 
$values['parent_id'];
+                       $value_set['job_parent']                = 
intval($values['parent_id']);
                        $value_set['job_level']         = $level;

                        $value_set      = 
$this->bocommon->validate_db_update($value_set);
@@ -257,6 +287,75 @@
                        $receipt['message'][]=array('msg'=>lang('job has been 
edited'));
                        return $receipt;
                }
+
+               function check_move_child()
+               {
+                       $continue = false;
+                       $move_child = array();
+                       $this->db->query("SELECT id FROM hrm_job  where 
job_parent=" . intval($this->job_parent),__LINE__,__FILE__);
+                       while ($this->db->next_record())
+                       {
+                               $this->move_child[] = array(
+                                       'id'            
=>(int)$this->db->f('id'),
+                                       'job_parent'    
=>(int)$this->job_parent,
+                                       'new_level'     => ($this->level + 
$this->parent_gap)
+                                       );
+
+                               $move_child[] = (int)$this->db->f('id');
+                               $continue = true;
+                       }
+                       if($continue)
+                       {
+                               $this->parent_gap++;
+                               foreach ($move_child as $parent_id)
+                               {
+                                       $this->job_parent = $parent_id;
+                                       $this->check_move_child();
+                               }
+
+                       }
+                       else
+                       {
+                               $this->job_parent = false;
+                       }
+               }
+
+
+               function check_move_child_delete()
+               {
+                       $continue = false;
+                       $move_child = array();
+
+                       $this->db->query("SELECT id FROM hrm_job  where 
job_parent=" . intval($this->job_id),__LINE__,__FILE__);
+                       while ($this->db->next_record())
+                       {
+                               $this->move_child[] = array(
+                                       'id'            
=>(int)$this->db->f('id'),
+                                       'job_parent'    =>$this->job_parent,
+                                       'new_level'     => ($this->level)
+                                       );
+
+                               $move_child[] = (int)$this->db->f('id');
+                               $continue = true;
+                       }
+                       unset ($this->job_parent);
+                       if($continue)
+                       {
+                               $this->level++;
+                               foreach ($move_child as $job_id)
+                               {
+                                       $this->job_id = $job_id;
+                                       $this->check_move_child_delete();
+                               }
+
+                       }
+                       else
+                       {
+                               $this->check_parent = false;
+                       }
+               }
+
+
                function edit($category,$type,$type_id)
                {

@@ -272,25 +371,54 @@
                        return $receipt;
                }

-               function delete($id,$type,$type_id)
+               function delete_job($id)
                {
-                       $table = $this->select_table($type,$type_id);
+                       $this->db->transaction_begin();
+
+                       $this->db->query("SELECT job_parent,job_level FROM 
hrm_job  where id=" . intval($id),__LINE__,__FILE__);
+                       $this->db->next_record();
+                       $this->level            = 
(int)$this->db->f('job_level');
+                       $this->job_parent       = 
(int)$this->db->f('job_parent');
+
+                       $this->check_parent = true;
+                       $this->job_id = $id;
+                       while ($this->check_parent)
+                       {
+                               $this->check_move_child_delete();
+                       }

-                       $this->db->query("DELETE FROM $table WHERE id='" . $id 
. "'",__LINE__,__FILE__);
+                       if (is_array($this->move_child))
+                       {
+                               foreach ($this->move_child as $child)
+                               {
+                                       $new_level = $child['new_level'];
+                                       $child['job_parent'];
+                                       if($child['job_parent'] || 
$child['job_parent']===0)
+                                       {
+                                               $sql = "UPDATE hrm_job set 
job_level= $new_level,job_parent = " . intval($child['job_parent']) .  " WHERE 
id=" . intval($child['id']);
+                                       }
+                                       else
+                                       {
+                                               $sql = "UPDATE hrm_job set 
job_level= $new_level WHERE id=" . intval($child['id']);
+                                       }
+                                       
$this->db->query($sql,__LINE__,__FILE__);
+                               }
+                       }
+
+                       $this->db->query("DELETE FROM hrm_job WHERE id=" . 
intval($id),__LINE__,__FILE__);
+                       $this->db->transaction_commit();
                }

                function select_job_list()
                {
-                       $this->db->query("SELECT * FROM hrm_job  ORDER BY name 
");
-
-                       $i = 0;
-                       while ($this->db->next_record())
-                       {
-                               $job[$i]['id']          = $this->db->f('id');
-                               $job[$i]['name']        = 
stripslashes($this->db->f('name'));
-                               $i++;
-                       }
+                       $job = $this->read(array('allrows'=>true));
                        return $job;
+               }
+
+               function reset_job_type_hierarchy()
+               {
+                       $sql = "UPDATE hrm_job set job_level= 0,job_parent = 0";
+                       $this->db->query($sql,__LINE__,__FILE__);
                }

        }

====================================================
Index: hrm/inc/class.bojob.inc.php
diff -u hrm/inc/class.bojob.inc.php:1.3 hrm/inc/class.bojob.inc.php:1.4
--- hrm/inc/class.bojob.inc.php:1.3     Mon Nov 21 20:25:33 2005
+++ hrm/inc/class.bojob.inc.php Tue Nov 22 13:26:35 2005
@@ -170,12 +170,30 @@
                        $this->so->delete($id,$type,$type_id);
                }

+               function delete_job($id)
+               {
+                       $this->so->delete_job($id);
+               }
+
+               function reset_job_type_hierarchy()
+               {
+                       $this->so->reset_job_type_hierarchy();
+               }
+
                function select_job_list($selected='')
                {
                        $jobs= $this->so->select_job_list();

                        while (is_array($jobs) && list(,$job) = each($jobs))
                        {
+
+                               if ($job['level'] > 0)
+                               {
+                                       $space = '--';
+                                       $spaceset = 
str_repeat($space,$job['level']);
+                                       $job['name'] = $spaceset . $job['name'];
+                               }
+
                                $sel_job = '';
                                if ($job['id']==$selected)
                                {

====================================================
Index: hrm/inc/class.menu.inc.php
diff -u hrm/inc/class.menu.inc.php:1.2 hrm/inc/class.menu.inc.php:1.3
--- hrm/inc/class.menu.inc.php:1.2      Mon Nov 21 20:25:33 2005
+++ hrm/inc/class.menu.inc.php  Tue Nov 22 13:26:35 2005
@@ -72,8 +72,8 @@
                                        $menu['sub_menu'][$j]['this']=True;
                                }
                                $menu['sub_menu'][$j]['link']                   
=       
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uijob.hierarchy&paid=true');
-                               $menu['sub_menu'][$j]['name']                   
=       lang('hierarchy');
-                               $menu['sub_menu'][$j]['statustext']             
=       lang('hierarchy');
+                               $menu['sub_menu'][$j]['name']                   
=       lang('Organisation');
+                               $menu['sub_menu'][$j]['statustext']             
=       lang('Organisation');
                                $j++;
                        }


====================================================
Index: hrm/inc/class.bocommon.inc.php
diff -u hrm/inc/class.bocommon.inc.php:1.2 hrm/inc/class.bocommon.inc.php:1.3
--- hrm/inc/class.bocommon.inc.php:1.2  Mon Nov 21 20:25:33 2005
+++ hrm/inc/class.bocommon.inc.php      Tue Nov 22 13:26:35 2005
@@ -1202,7 +1202,7 @@
                {
                        foreach($values as $value)
                        {
-                               if($value)
+                               if($value || $value === 0)
                                {
                                        $insert_value[] = "'".$value."'";
                                }
@@ -1220,7 +1220,7 @@
                {
                        while (is_array($value_set) && list($field,$value) = 
each($value_set))
                        {
-                               if($value)
+                               if($value || $value === 0)
                                {
                                        $value_entry[]= "$field='$value'";
                                }






reply via email to

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