<?php

/* * *******************************************************************************
 * SugarCRM is a customer relationship management program developed by
 * SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU Affero General Public License along with
 * this program; if not, see http://www.gnu.org/licenses or write to the Free
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301 USA.
 * 
 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
 * 
 * The interactive user interfaces in modified source and object code versions
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU Affero General Public License version 3.
 * 
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
 * these Appropriate Legal Notices must retain the display of the "Powered by
 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
 * technical reasons, the Appropriate Legal Notices must display the words
 * "Powered by SugarCRM".
 * ****************************************************************************** */

/**
 * THIS CLASS IS FOR DEVELOPERS TO MAKE CUSTOMIZATIONS IN
 */
class EcmWorker extends SugarBean {

	var $new_schema = true;
	var $module_dir = 'EcmWorkers';
	var $object_name = 'EcmWorker';
	var $table_name = 'ecmworkers';
	var $importable = false;
	var $disable_row_level_security = true; // to ensure that modules created and deployed under CE will continue to function under team security if the instance is upgraded to PRO
	var $id;
	var $name;
	var $date_entered;
	var $date_modified;
	var $modified_user_id;
	var $modified_by_name;
	var $created_by;
	var $created_by_name;
	var $description;
	var $deleted;
	var $created_by_link;
	var $modified_user_link;
	var $assigned_user_id;
	var $assigned_user_name;
	var $assigned_user_link;
	var $salutation;
	var $department;
	var $first_name;
	var $last_name;
	var $phone_home;
	var $phone_mobile;
	var $phone_work;
	var $email1;
	var $email2;
	var $primary_address_street;
	var $primary_address_city;
	var $primary_address_state;
	var $primary_address_postalcode;
	var $primary_address_country;
	var $alt_address_street;
	var $alt_address_city;
	var $alt_address_state;
	var $alt_address_postalcode;
	var $alt_address_country;
	var $second_name;
	var $inland_revenue;
	var $health_insurance;
	var $pesel;
	var $birthday;
	var $birth_place;
	var $marital_status;
	var $family_name;
	var $gender;
	var $spouse_name;
	var $id_card_number;
	var $id_card_issued;
	var $id_card_date;
	var $citizenship;
	var $nationality;
	var $education;
	var $school_completed;
	var $account_ledger;
	var $position_office;
	var $cost;
	var $registration_number;
	var $form_employment;
	var $date_employment;
	var $date_internship;
	var $employment;
	var $zus_group;
	var $work_group;
	var $primary_address_community;
	var $primary_address_district;
	var $alt_address_community;
	var $alt_address_district;
	var $alt_mail;
	var $primary_mail;
	var $permanent_residence_card;
	var $mother_name;
	var $father_name;
	var $base_salary;
	var $category;
	var $temporary_residence_card;
	var $insurance_code;
	var $period_of_disability_from;
	var $period_of_disability_to;
	var $date_insurance;
	var $working_time;
	var $retirement;
	var $form_dismissal;
	var $sickness;
	var $disability;
	var $accidental;
	var $date_obligation;
	var $date_sickness;
	var $date_commencement;
	var $date_dismissal;
	var $date_graduation;
	var $phone_fax;
	var $date_retirement;
	var $employee_group;
	var $work_schedule;
	var $code_relationship;
	var $code_education;
	var $code_deregistration;
	var $code_profession;
	var $amount_contributions;
	var $name_bank;
	var $bank_account_number;
	var $bank_account;
	var $dismissal_reason;
	var $debtors_account;
	var $zus_date_disability;
	var $zus_annual_amount;
	var $zus_annual_base;
	var $person_id_series_number;
	var $person_relief;
	var $person_child_tax_credit;
	var $zus_common_household_employer;
	var $person_current_profession;
	var $person_learned_profession;
	var $zus_code_discrepancies;
	var $zus_date_discrepancies_from;
	var $zus_date_discrepancies_to;
	var $zus_code_mining_work;
	var $zus_date_mining_work_from;
	var $zus_date_mining_work_to;
	var $zus_code_charity_work;
	var $zus_date_charity_work_from;
	var $zus_date_charity_work_to;
//	var $worker_name;
//	var $worker_id;

	function EcmWorker() {
	    if (!self::checkAcces()) {ACLController::displayNoAccess(true); sugar_die();}
		parent::SugarBean();
		$worker_name = $this->first_name . " " . $this->last_name;
	}

	function bean_implements($interface) {
		switch ($interface) {
			case 'ACL': return true;
		}
		return false;
	}
	
	function get_list_view_data(){
	
		$the_array        = parent::get_list_view_data();

		$this->retrieve($this->id);
		
		$the_array['STAN']="<a href='index.php?module=EcmWorkers&action=status&record=".$this->id."&set=". (int)(!$this->active2)."'>".($this->active2?'Tak':'Nie')."</a>";
	
		return  $the_array;
	}
	
	function checkAcces() {
	    global $current_user;
	    if ($_REQUEST['action'] == 'Popup') return true;
        if ($current_user->is_admin || 
        		$current_user->id=='49584975-a4a4-6c28-3b31-54bcb71a8f2b' || 
        		$current_user->id=='e3a315cd-5752-4e83-aa73-5236e2a2d39c' || 
        		$current_user->id=='54eb00ac-d71a-1749-1111-524ad6b2886a')
            return true;
        else
	       return false;
	}
	
	function save($check_notify = FALSE) {
		$this->name = $this->first_name . " " . $this->last_name;
		parent::save($check_notify);
		
	}
	
	function get_summary_text() {
		return $this->first_name . " " . $this->last_name;
	}

	function fill_in_additional_detail_fields() {
		parent::fill_in_additional_detail_fields();
	//	$worker_name = $this->first_name;
	//	$worker_id = $this->id;
	}

}
