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

SF.net SVN: ledger-smb:[4427] branches/1.3



Revision: 4427
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4427&view=rev
Author:   einhverfr
Date:     2012-03-10 09:31:41 +0000 (Sat, 10 Mar 2012)
Log Message:
-----------
Closing bug  3486840, unable to set which employees are managers

Modified Paths:
--------------
    branches/1.3/LedgerSMB/DBObject/Employee.pm
    branches/1.3/UI/Contact/contact.html
    branches/1.3/sql/modules/Employee.sql

Modified: branches/1.3/LedgerSMB/DBObject/Employee.pm
===================================================================
--- branches/1.3/LedgerSMB/DBObject/Employee.pm	2012-03-10 09:07:21 UTC (rev 4426)
+++ branches/1.3/LedgerSMB/DBObject/Employee.pm	2012-03-10 09:31:41 UTC (rev 4427)
@@ -96,12 +96,34 @@
 sub save {
    my ($self) = @_;
    $self->set_entity_class();
+   if ($self->{is_manager}) {
+       $self->{role} = 'manager';
+   } else {
+       $self->{role} = 'user';
+   }
    my ($ref) = $self->exec_method(funcname => 'person__save');
    $self->{entity_id} = $ref->{'person__save'};
    $self->exec_method(funcname => 'employee__save');
    $self->{dbh}->commit;
 }
 
+
+=item get_managers 
+
+Retrieves a set of managers and attaches to $self->{all_managers}
+
+=cut
+
+sub get_managers {
+    my ($self) = @_;
+    my @results = $self->exec_method(funcname => 'employee__all_managers');
+    for my $ref (@results) {
+        $ref->{label} = $ref->{employeenumber} . '--' . $ref->{last_name};
+    }
+    $self->{all_managers} = ..hidden..;
+    return @results;
+}
+
 =item save_location
 
 Saves the location data for the contact.
@@ -170,7 +192,7 @@
 
 sub get_metadata {
     my $self = shift @_;
-
+    $self->get_managers;
     @{$self->{entity_classes}} = 
 		$self->exec_method(funcname => 'entity__list_classes');
 
@@ -220,6 +242,9 @@
 sub get {
     my $self = shift @_;
     my ($ref) = $self->exec_method(funcname => 'employee__get');
+    if ($ref->{role} eq 'manager'){
+        $ref->{is_manager} = 1;
+    }
     $self->merge($ref);
     @{$self->{locations}} = $self->exec_method(
 		funcname => 'person__list_locations');

Modified: branches/1.3/UI/Contact/contact.html
===================================================================
--- branches/1.3/UI/Contact/contact.html	2012-03-10 09:07:21 UTC (rev 4426)
+++ branches/1.3/UI/Contact/contact.html	2012-03-10 09:31:41 UTC (rev 4427)
@@ -98,7 +98,7 @@
                 name = "entity_id"
                value = entity_id
 } ?>	
-<div class="input" id="person_name_div"><?lsmb #text('Name:')?>&nbsp;
+<div class="input_line" id="person_name_div"><?lsmb #text('Name:')?>&nbsp;
 <div class="input_group">
 <!-- TODO:  Add Saluatation -->
 <?lsmb PROCESS input element_data = {
@@ -118,6 +118,8 @@
 	size = 20
 } ?>
 </div>
+</div>
+<div class="input_line" id='person_name2_div'>
 <div class="input_group">
 <?lsmb PROCESS input element_data = {
 	label = text('Last Name') #'
@@ -127,8 +129,6 @@
 	size = 20
 } ?>
 </div>
-</div>
-<div id="job_title_div">
 <!-- Note that the strange # ' constructs are only necessary to help VIM avoid
 problems with multi-word single-quoted constructs in PI tags. -CT  -->
 <div class="input_group">
@@ -140,6 +140,8 @@
 	size = 20
 } # ' ?>
 </div>
+</div>
+<div class="input_line" id="person-role-div">
 <div class="input_group">
 <?lsmb PROCESS input element_data = {
 	label = text('Sales')
@@ -150,6 +152,17 @@
 } ?>
 </div>
 <div class="input_group">
+<?lsmb PROCESS input element_data = {
+        label = text('Manager')
+        value = 'manager'
+        type = "checkbox"
+        checked = is_manager
+        name = "is_manager"
+} ?>
+</div>
+</div>
+<div class="input_line" id="person-country-div">
+<div class="input_group">
        <?lsmb country_list.unshift({}) ?>
 		<?lsmb INCLUDE select element_data = {
 			text_attr = "name"
@@ -172,14 +185,15 @@
 } # ' ?>
 </div>
 <div class="input_group">
-<label for="manager_select"><?lsmb text('Manager') ?></label>
-<select id="manager_select" name="manager_id">
-<?lsmb FOREACH e = employee ?>
-<option value = e.entity_id <?lsmb (manager_id == e.entity_id) ? "SELECTED" : ""?><?lsmb e.name ?></option>
-<?lsmb END ?>
-</select>
+<?lsmb PROCESS select element_data = {
+         label = text('Manager')
+          name = 'manager_id'
+       options = all_managers
+default_values = [manager_id]
+     text_attr = 'label'
+    value_attr = 'id'
+} ?> 
 </div>
-</div>
 <div id="hr_dates_div">
 <div class="input_group">
 <?lsmb PROCESS input element_data = {

Modified: branches/1.3/sql/modules/Employee.sql
===================================================================
--- branches/1.3/sql/modules/Employee.sql	2012-03-10 09:07:21 UTC (rev 4426)
+++ branches/1.3/sql/modules/Employee.sql	2012-03-10 09:31:41 UTC (rev 4427)
@@ -88,6 +88,22 @@
     country_id int
 );
 
+CREATE OR REPLACE FUNCTION employee__all_managers()
+RETURNS setof employee_result AS
+$$
+   SELECT p.entity_id, p.id, s.salutation,
+          p.first_name, p.middle_name, p.last_name,
+          ee.startdate, ee.enddate, ee.role, ee.ssn, ee.sales, ee.manager_id,
+          mp.first_name, mp.last_name, ee.employeenumber, ee.dob, e.country_id
+     FROM person p
+     JOIN entity_employee ee on (ee.entity_id = p.entity_id)
+     JOIN entity e ON (p.entity_id = e.id)
+LEFT JOIN salutation s on (p.salutation_id = s.id)
+LEFT JOIN person mp ON ee.manager_id = p.entity_id
+    WHERE ee.role = 'manager'
+ ORDER BY ee.employeenumber;
+$$ LANGUAGE SQL; 
+
 CREATE OR REPLACE FUNCTION employee__get
 (in_entity_id integer)
 returns employee_result as

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.