public function get_db() { if ($this->db && is_object($this->db)) { return $this->db; } $config = CreateObject('phpgwapi.config', 'rental'); $config->read(); if (!$config->config_data['external_db_host'] || !$this->ping($config->config_data['external_db_host'])) { $message = "Database server {$config->config_data['external_db_host']} is not accessible"; phpgwapi_cache::message_set($message, 'error'); return false; } $db = createObject('phpgwapi.db', null, null, true); $db->debug = !!$config->config_data['external_db_debug']; $db->Host = $config->config_data['external_db_host']; $db->Port = $config->config_data['external_db_port']; $db->Type = $config->config_data['external_db_type']; $db->Database = $config->config_data['external_db_name']; $db->User = $config->config_data['external_db_user']; $db->Password = $config->config_data['external_db_password']; try { $db->connect(); $this->connected = true; } catch (Exception $e) { $status = lang('unable_to_connect_to_database'); } $this->db = $db; return $db; }
public function get_db() { if ($this->db && is_object($this->db)) { return $this->db; } $config = CreateObject('phpgwapi.config', 'rental'); $config->read(); if (!$config->config_data['external_db_host'] || !$this->ping($config->config_data['external_db_host'])) { $message = "Database server {$config->config_data['external_db_host']} is not accessible"; phpgwapi_cache::message_set($message, 'error'); return false; } $db = createObject('phpgwapi.db', null, null, true); $db->debug = !!$config->config_data['external_db_debug']; $db->Host = $config->config_data['external_db_host']; $db->Port = $config->config_data['external_db_port']; $db->Type = $config->config_data['external_db_type']; $db->Database = $config->config_data['external_db_name']; $db->User = $config->config_data['external_db_user']; $db->Password = $config->config_data['external_db_password']; $db->Halt_On_Error = 'no'; try { $db->connect(); } catch (Exception $e) { phpgwapi_cache::message_set('Could not connect to backend-server ' . $config->config_data['external_db_host'], 'error'); $GLOBALS['phpgw']->redirect_link('/home.php'); } $this->db = $db; return $db; }
/** * Add a contact to a location * * @return void */ public function add_location_contact($data) { if (!isset($data['location_code']) || !$data['location_code']) { phpgwapi_cache::message_set("location_code not set", 'error'); return false; } $value_set = array(); $value_set['location_code'] = $data['location_code']; $value_set['contact_id'] = $data['contact_id']; $value_set['user_id'] = $GLOBALS['phpgw_info']['user']['account_id']; $value_set['entry_date'] = time(); $value_set['modified_date'] = time(); $cols = implode(',', array_keys($value_set)); $values = $GLOBALS['phpgw']->db->validate_insert(array_values($value_set)); $sql = "INSERT INTO fm_location_contact ({$cols}) VALUES ({$values})"; $GLOBALS['phpgw']->db->query($sql, __LINE__, __FILE__); if ($data['email']) { $pref = CreateObject('phpgwapi.preferences', $data['account_id']); $pref->read(); $pref->add('property', 'email', $data['email'], 'user'); $pref->save_repository(); } $message = lang('user %1 added to %2', $data['account_lid'], $data['location_code']); phpgwapi_cache::message_set($message, 'message'); }
public function store_doc_to_vfs($file) { $root_directory = self::$ROOT_FOR_DOCUMENTS; $type_directory = self::$HELP_DOCUMENTS; $lang_directory = self::$LANG_DIR; $vfs = CreateObject('phpgwapi.vfs'); $vfs->override_acl = 1; $path = $root_directory; $dir = array('string' => $path, RELATIVE_NONE); if (!$vfs->file_exists($dir)) { if (!$vfs->mkdir($dir)) { return; } } $path .= $type_directory; $dir = array('string' => $path, RELATIVE_NONE); if (!$vfs->file_exists($dir)) { if (!$vfs->mkdir($dir)) { return; } } $path .= $lang_directory; $dir = array('string' => $path, RELATIVE_NONE); if (!$vfs->file_exists($dir)) { if (!$vfs->mkdir($dir)) { return; } } $mime_magic = createObject('phpgwapi.mime_magic'); $mime = $mime_magic->filename2mime($file['name']); if ($mime != 'application/pdf') { $message = 'Only PDF is supported for this one'; phpgwapi_cache::message_set($message, 'error'); return $message; } $file_path = "{$path}/helpdesk.index.pdf"; $result = $vfs->write(array('string' => $file_path, RELATIVE_NONE, 'content' => file_get_contents($file['tmp_name']))); if ($result) { $message = 'Stored in vfs'; phpgwapi_cache::message_set($message, 'message'); return $message; } return "something failed..."; }
/** * Add a contact to a location * * @return void */ public function add_contract_from_composite(&$data) { if (!isset($data['location_code']) || !$data['location_code']) { phpgwapi_cache::message_set("location_code not set", 'error'); return false; } $criteria = array('appname' => 'rental', 'location' => $data['acl_location'], 'pre_commit' => true, 'allrows' => true); $custom_functions = $GLOBALS['phpgw']->custom_functions->find($criteria); foreach ($custom_functions as $entry) { // prevent path traversal if (preg_match('/\\.\\./', $entry['file_name'])) { continue; } $file = PHPGW_SERVER_ROOT . "/rental/inc/custom/{$GLOBALS['phpgw_info']['user']['domain']}/{$entry['file_name']}"; if ($entry['active'] && is_file($file) && !$entry['client_side']) { require $file; } } }
public function get_username() { $config = CreateObject('phpgwapi.config', 'rental'); $config->read(); if (!$config->config_data['external_db_host'] || !$this->ping($config->config_data['external_db_host'])) { $message = "Database server {$config->config_data['external_db_host']} is not accessible"; phpgwapi_cache::message_set($message, 'error'); return false; } $db = createObject('phpgwapi.db', null, null, true); $db->debug = !!$config->config_data['external_db_debug']; $db->Host = $config->config_data['external_db_host']; $db->Port = $config->config_data['external_db_port']; $db->Type = $config->config_data['external_db_type']; $db->Database = $config->config_data['external_db_name']; $db->User = $config->config_data['external_db_user']; $db->Password = $config->config_data['external_db_password']; try { $db->connect(); } catch (Exception $e) { $message = lang('unable_to_connect_to_database'); phpgwapi_cache::message_set($message, 'error'); return false; } $headers = getallheaders(); // $headers['Osso-User-Dn'] = 'cn=02035701829,cn=users,dc=usrv,dc=ubergenkom,dc=no';// test $header_regular_expression = '/^cn=(.*),cn=users.*$/'; $header_key = 'Osso-User-Dn'; $matches = array(); preg_match_all($header_regular_expression, $headers[$header_key], $matches); $fodsels_nr = $matches[1][0]; $uid = $headers['uid']; $fodsels_nr = $uid ? $uid : $fodsels_nr; $sql = "SELECT BRUKERNAVN FROM V_AD_PERSON WHERE FODSELSNR ='{$fodsels_nr}'"; $db->query($sql, __LINE__, __FILE__); $db->next_record(); return $db->f('BRUKERNAVN', true); }
public function __construct() { $this->db =& $GLOBALS['phpgw']->db; $location_id = $GLOBALS['phpgw']->locations->get_id('admin', 'vfs_filedata'); $c = CreateObject('admin.soconfig', $location_id); $section = 'braArkiv'; $location_url = $c->config_data[$section]['location_url']; //'http://braarkiv.adm.bgo/service/services.asmx'; $braarkiv_user = $c->config_data[$section]['braarkiv_user']; $braarkiv_pass = $c->config_data[$section]['braarkiv_pass']; if (!isset($c->config_data) || !$c->config_data) { $this->config = $c; $this->init_config(); } if (!$location_url || !$braarkiv_pass || !$braarkiv_pass) { throw new Exception('braArkiv is not configured'); } $wdsl = "{$location_url}?WSDL"; $options = array(); $options[Bra5WsdlClass::WSDL_URL] = $wdsl; $options[Bra5WsdlClass::WSDL_ENCODING] = 'UTF-8'; $options[Bra5WsdlClass::WSDL_TRACE] = false; $options[Bra5WsdlClass::WSDL_SOAP_VERSION] = SOAP_1_2; try { $wsdlObject = new Bra5WsdlClass($options); } catch (Exception $e) { if ($e) { phpgwapi_cache::message_set($e->getMessage(), 'error'); return false; } } $bra5ServiceLogin = new Bra5ServiceLogin(); if ($bra5ServiceLogin->Login(new Bra5StructLogin($braarkiv_user, $braarkiv_pass))) { $this->secKey = $bra5ServiceLogin->getResult()->getLoginResult()->LoginResult; } else { throw new Exception('vfs_fileoperation_braArkiv::Login failed'); } }
/** * Public function for deleting a document. Deletes the document from * the database and the virtual file system (vfs). * * @param HTTP::id the document id * @return true if successful, false if error, permission denied message on * not enough privileges */ public function delete() { $document_id = intval(phpgw::get_var('id')); $document = $this->so->get_single($document_id); $procedure_id = intval(phpgw::get_var('procedure_id')); if (!$this->delete) { phpgwapi_cache::message_set('No access', 'error'); $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'controller.uidocument.show', 'procedure_id' => $procedure_id, 'tab' => 'documents')); } $procedure = $this->so_procedure->get_single($procedure_id); $document_properties = $this->get_type_and_id($document); /*if(!$this->check_permissions($document,$document_properties)) { $this->render('permission_denied.php'); return; }*/ $result = $this->so->delete_document_from_vfs($document_properties['document_type'], $document_properties['id'], $document->get_name()); if ($result) { $this->so->delete_document($document_id); $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'controller.uidocument.show', 'procedure_id' => $procedure->get_id(), 'tab' => 'documents')); } // TODO: communicate error/message to user return false; }
/** * Check the consumption on an order - and notify the coordinator * @param integer $order_id */ function notify_coordinator_on_consumption($order_id) { $notify_coordinator = true; if (!$notify_coordinator) { return false; } $toarray = array(); $workorder = $this->so->read_single($order_id); if (!$workorder['continuous']) { return false; } $project = ExecMethod('property.boproject.read_single_mini', $workorder['project_id']); $coordinator = $project['coordinator']; $prefs_coordinator = $this->bocommon->create_preferences('property', $coordinator); if (isset($prefs_coordinator['email']) && $prefs_coordinator['email']) { $toarray[] = $prefs_coordinator['email']; } if ($toarray) { $budget_info = $this->so->get_order_budget_percent($order_id); if ($budget_info['percent'] < 90) { return false; } if (isset($GLOBALS['phpgw_info']['user']['preferences']['property']['email']) && $GLOBALS['phpgw_info']['user']['preferences']['property']['email']) { $from_name = $GLOBALS['phpgw_info']['user']['fullname']; $from_email = $GLOBALS['phpgw_info']['user']['preferences']['property']['email']; } else { $from_name = 'noreply'; $from_email = "{$from_name}<*****@*****.**>"; } $subject = "Bestilling # {$order_id} har disponert {$budget_info['percent']} prosent av budsjettet"; $lang_budget = lang('budget'); $lang_actual_cost = lang('actual cost'); $lang_percent = lang('percent'); $lang_obligation = lang('obligation'); $_budget = number_format($budget_info['budget'], 0, ',', ' '); $_actual_cost = number_format($budget_info['actual_cost'], 0, ',', ' '); $_budget = number_format($budget_info['budget'], 0, ',', ' '); $_obligation = number_format($budget_info['obligation'], 0, ',', ' '); $to = implode(';', $toarray); $cc = false; $bcc = false; $body = '<a href ="' . $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uiworkorder.edit', 'id' => $order_id), false, true) . '">' . lang('workorder %1 has been edited', $order_id) . '</a>' . "\n"; $body .= <<<HTML \t\t\t\t</br> \t\t\t\t<h2>{$workorder['title']}</h2> \t\t\t\t</br> \t\t\t\t</br> \t\t\t\t<table> \t\t\t\t\t<tr> \t\t\t\t\t\t<td> \t\t\t\t\t\t\t{$lang_budget} \t\t\t\t\t\t</td> \t\t\t\t\t\t<td align = 'right'> \t\t\t\t\t\t\t{$_budget} \t\t\t\t\t\t</td> \t\t\t\t\t</tr> \t\t\t\t\t<tr> \t\t\t\t\t\t<td> \t\t\t\t\t\t\t{$lang_actual_cost} \t\t\t\t\t\t</td> \t\t\t\t\t\t<td align = 'right'> \t\t\t\t\t\t\t{$_actual_cost} \t\t\t\t\t\t</td> \t\t\t\t\t</tr> \t\t\t\t\t<tr> \t\t\t\t\t\t<td> \t\t\t\t\t\t\t{$lang_percent} \t\t\t\t\t\t</td> \t\t\t\t\t\t<td align = 'right'> \t\t\t\t\t\t\t{$budget_info['percent']} \t\t\t\t\t\t</td> \t\t\t\t\t</tr> \t\t\t\t\t<tr> \t\t\t\t\t\t<td> \t\t\t\t\t\t\t{$lang_obligation} \t\t\t\t\t\t</td> \t\t\t\t\t\t<td align = 'right'> \t\t\t\t\t\t\t{$_obligation} \t\t\t\t\t\t</td> \t\t\t\t\t</tr> \t\t\t\t</table> HTML; if (!is_object($GLOBALS['phpgw']->send)) { $GLOBALS['phpgw']->send = CreateObject('phpgwapi.send'); } try { $ok = $GLOBALS['phpgw']->send->msg('email', $to, $subject, $body, false, $cc, $bcc, $from_email, $from_name, 'html'); } catch (phpmailerException $e) { phpgwapi_cache::message_set($e->getMessage(), 'error'); } if ($ok) { $historylog = CreateObject('property.historylog', 'workorder'); $historylog->add('ON', $order_id, lang('%1 is notified', $to)); $historylog->add('RM', $order_id, $subject); return true; } } }
/** * Import deviations found in the survey to the database from a spreadsheet * * @param int $id entity id * * @return void */ private function _handle_import($id) { $id = (int) $id; if (!$id) { throw new Exception('uicondition_survey::_handle_import() - missing id'); } $step = phpgw::get_var('step', 'int', 'REQUEST'); $sheet_id = phpgw::get_var('sheet_id', 'int', 'REQUEST'); $sheet_id = $sheet_id ? $sheet_id : phpgw::get_var('selected_sheet_id', 'int', 'REQUEST'); if (!$step) { if ($cached_file = phpgwapi_cache::session_get('property', 'condition_survey_import_file')) { phpgwapi_cache::session_clear('property', 'condition_survey_import_file'); unlink($cached_file); unset($cached_file); } } if ($start_line = phpgw::get_var('start_line', 'int', 'REQUEST')) { phpgwapi_cache::system_set('property', 'import_sheet_start_line', $start_line); } else { $start_line = phpgwapi_cache::system_get('property', 'import_sheet_start_line'); $start_line = $start_line ? $start_line : 1; } if ($columns = phpgw::get_var('columns')) { phpgwapi_cache::system_set('property', 'import_sheet_columns', $columns); } else { $columns = phpgwapi_cache::system_get('property', 'import_sheet_columns'); $columns = $columns && is_array($columns) ? $columns : array(); } if ($step > 1) { $cached_file = phpgwapi_cache::session_get('property', 'condition_survey_import_file'); } if ($step == 1 || isset($_FILES['import_file']['tmp_name'])) { $file = $_FILES['import_file']['tmp_name']; $cached_file = "{$file}_temporary_import_file"; // save a copy to survive multiple steps file_put_contents($cached_file, file_get_contents($file)); phpgwapi_cache::session_set('property', 'condition_survey_import_file', $cached_file); $step = 1; // Add the file to documents $bofiles = CreateObject('property.bofiles'); $to_file = "{$bofiles->fakebase}/condition_survey/{$id}/" . str_replace(' ', '_', $_FILES['import_file']['name']); $bofiles->vfs->rm(array('string' => $to_file, 'relatives' => array(RELATIVE_NONE))); $bofiles->create_document_dir("condition_survey/{$id}"); $bofiles->vfs->override_acl = 1; $bofiles->vfs->cp(array('from' => $_FILES['import_file']['tmp_name'], 'to' => $to_file, 'relatives' => array(RELATIVE_NONE | VFS_REAL, RELATIVE_ALL))); $bofiles->vfs->override_acl = 0; unset($bofiles); } $tabs = array(); switch ($step) { case 0: $active_tab = 'step_1'; $lang_submit = lang('continue'); $tabs['step_1'] = array('label' => lang('choose file'), 'link' => '#step_1'); $tabs['step_2'] = array('label' => lang('choose sheet'), 'link' => null); $tabs['step_3'] = array('label' => lang('choose start line'), 'link' => null); $tabs['step_4'] = array('label' => lang('choose columns'), 'link' => null); break; case 1: $active_tab = 'step_2'; $lang_submit = lang('continue'); $tabs['step_1'] = array('label' => lang('choose file'), 'link' => self::link(array('menuaction' => 'property.uicondition_survey.import', 'id' => $id, 'step' => 0, 'sheet_id' => $sheet_id, 'start_line' => $start_line))); $tabs['step_2'] = array('label' => lang('choose sheet'), 'link' => '#step_2'); $tabs['step_3'] = array('label' => lang('choose start line'), 'link' => null); $tabs['step_4'] = array('label' => lang('choose columns'), 'link' => null); break; case 2: $active_tab = 'step_3'; $lang_submit = lang('continue'); $tabs['step_1'] = array('label' => lang('choose file'), 'link' => self::link(array('menuaction' => 'property.uicondition_survey.import', 'id' => $id, 'step' => 0, 'sheet_id' => $sheet_id, 'start_line' => $start_line))); $tabs['step_2'] = array('label' => lang('choose sheet'), 'link' => self::link(array('menuaction' => 'property.uicondition_survey.import', 'id' => $id, 'step' => 1, 'sheet_id' => $sheet_id, 'start_line' => $start_line))); $tabs['step_3'] = array('label' => lang('choose start line'), 'link' => '#step_3'); $tabs['step_4'] = array('label' => lang('choose columns'), 'link' => null); break; case 3: $active_tab = 'step_4'; $lang_submit = lang('import'); $tabs['step_1'] = array('label' => lang('choose file'), 'link' => self::link(array('menuaction' => 'property.uicondition_survey.import', 'id' => $id, 'step' => 0, 'sheet_id' => $sheet_id, 'start_line' => $start_line))); $tabs['step_2'] = array('label' => lang('choose sheet'), 'link' => self::link(array('menuaction' => 'property.uicondition_survey.import', 'id' => $id, 'step' => 1, 'sheet_id' => $sheet_id, 'start_line' => $start_line))); $tabs['step_3'] = array('label' => lang('choose start line'), 'link' => self::link(array('menuaction' => 'property.uicondition_survey.import', 'id' => $id, 'step' => 2, 'sheet_id' => $sheet_id, 'start_line' => $start_line))); $tabs['step_4'] = array('label' => lang('choose columns'), 'link' => '#step_4'); break; /* case 4://temporary phpgwapi_cache::session_clear('property', 'condition_survey_import_file'); unlink($cached_file); $GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction' => 'property.uicondition_survey.import', 'id' =>$id, 'step' => 0)); break; */ } //----------- if (!$step) { phpgwapi_cache::session_clear('property', 'condition_survey_import_file'); unlink($cached_file); } else { if ($cached_file) { phpgw::import_class('phpgwapi.phpexcel'); try { $objPHPExcel = PHPExcel_IOFactory::load($cached_file); $AllSheets = $objPHPExcel->getSheetNames(); $sheets = array(); if ($AllSheets) { foreach ($AllSheets as $key => $sheet) { $sheets[] = array('id' => $key, 'name' => $sheet, 'selected' => $sheet_id == $key); } } $objPHPExcel->setActiveSheetIndex((int) $sheet_id); } catch (Exception $e) { if ($e) { phpgwapi_cache::message_set($e->getMessage(), 'error'); phpgwapi_cache::session_clear('property', 'condition_survey_import_file'); unlink($cached_file); } } } } $survey = $this->bo->read_single(array('id' => $id, 'view' => $mode == 'view')); $rows = $objPHPExcel->getActiveSheet()->getHighestDataRow(); $highestColumm = $objPHPExcel->getActiveSheet()->getHighestDataColumn(); $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumm); $i = 0; $html_table = '<table border="1">'; if ($rows > 1 && $step == 2) { $cols = array(); for ($j = 0; $j < $highestColumnIndex; $j++) { $cols[] = $this->getexcelcolumnname($j); } $html_table .= "<tr><th align = 'center'>" . lang('start') . "</th><th align='center'>" . implode("</th><th align='center'>", $cols) . '</th></tr>'; foreach ($objPHPExcel->getActiveSheet()->getRowIterator() as $row) { if ($i > 20) { break; } $i++; $row_key = $i; $_checked = ''; if ($start_line == $row_key) { $_checked = 'checked="checked"'; } $_radio = "[{$row_key}]<input id=\"start_line\" type =\"radio\" {$_checked} name=\"start_line\" value=\"{$row_key}\">"; $cellIterator = $row->getCellIterator(); $cellIterator->setIterateOnlyExistingCells(false); $row_values = array(); foreach ($cellIterator as $cell) { if (!is_null($cell)) { $row_values[] = $cell->getCalculatedValue(); } } $html_table .= "<tr><td><pre>{$_radio}</pre></td><td>" . implode('</td><td>', $row_values) . '</td></tr>'; } echo '</table>'; } else { if ($rows > 1 && $step == 3) { $_options = array('_skip_import_' => 'Utelates fra import/implisitt', 'import_type' => 'import type', 'building_part' => 'bygningsdels kode', 'descr' => 'Tilstandbeskrivelse', 'title' => 'Tiltak/overskrift', 'condition_degree' => 'Tilstandsgrad', 'condition_type' => 'Konsekvenstype', 'consequence' => 'Konsekvensgrad', 'probability' => 'Sannsynlighet', 'due_year' => 'År (innen)', 'amount_investment' => 'Beløp investering', 'amount_operation' => 'Beløp drift', 'amount_potential_grants' => 'Potensial for offentlig støtte'); $custom = createObject('phpgwapi.custom_fields'); $attributes = $custom->find('property', '.project.request', 0, '', '', '', true, true); foreach ($attributes as $attribute) { $_options["custom_attribute_{$attribute['id']}"] = $attribute['input_text']; } phpgw::import_class('phpgwapi.sbox'); for ($j = 0; $j < $highestColumnIndex; $j++) { $_column = $this->getexcelcolumnname($j); $_value = $objPHPExcel->getActiveSheet()->getCellByColumnAndRow($j, $start_line)->getCalculatedValue(); $selected = isset($columns[$_column]) && $columns[$_column] ? $columns[$_column] : ''; $_listbox = phpgwapi_sbox::getArrayItem("columns[{$_column}]", $selected, $_options, true); $html_table .= "<tr><td>[{$_column}] {$_value}</td><td>{$_listbox}</td><tr>"; } } else { if ($rows > 1 && $step == 4) { $rows = $objPHPExcel->getActiveSheet()->getHighestDataRow(); $rows = $rows ? $rows + 1 : 0; $import_data = array(); for ($i = $start_line; $i < $rows; $i++) { $_result = array(); foreach ($columns as $_row_key => $_value_key) { if ($_value_key != '_skip_import_') { $_result[$_value_key] = $objPHPExcel->getActiveSheet()->getCell("{$_row_key}{$i}")->getCalculatedValue(); } } $import_data[] = $_result; } if ($import_data) { try { $this->bo->import($survey, $import_data); } catch (Exception $e) { if ($e) { phpgwapi_cache::message_set($e->getMessage(), 'error'); } } } // $msg = "'{$cached_file}' contained " . count($import_data) . " lines"; // phpgwapi_cache::message_set($msg, 'message'); } } } $html_table .= '</table>'; if (isset($survey['location_code']) && $survey['location_code']) { $survey['location_data'] = execMethod('property.solocation.read_single', $survey['location_code']); } $bolocation = CreateObject('property.bolocation'); $location_data = $bolocation->initiate_ui_location(array('values' => $survey['location_data'], 'type_id' => 2, 'lookup_type' => 'view2', 'tenant' => false, 'lookup_entity' => array(), 'entity_data' => isset($survey['p']) ? $survey['p'] : '')); $data = array('lang_submit' => $lang_submit, 'survey' => $survey, 'location_data2' => $location_data, 'step' => $step + 1, 'sheet_id' => $sheet_id, 'start_line' => $start_line, 'html_table' => $html_table, 'sheets' => array('options' => $sheets), 'tabs' => $GLOBALS['phpgw']->common->create_tabs($tabs, $active_tab)); $GLOBALS['phpgw_info']['flags']['app_header'] = lang('property') . '::' . lang('condition survey import'); self::render_template_xsl(array('condition_survey_import'), $data); }
function edit($mode = 'edit') { $id = (int) phpgw::get_var('id', 'int'); if ($mode == 'edit' && (!$this->acl_add && !$this->acl_edit)) { $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'property.uiproject.view', 'id' => $id)); } if ($mode == 'view') { if (!$this->acl_read) { $this->bocommon->no_access(); return; } if (!$id) { phpgwapi_cache::message_set('ID is required for the function uiproject::view()', 'error'); $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'property.uiproject.index')); } } else { if (!$this->acl_add && !$this->acl_edit) { $this->bocommon->no_access(); return; } } $GLOBALS['phpgw']->xslttpl->add_file(array('project', 'files', 'attributes_form')); $location_id = $GLOBALS['phpgw']->locations->get_id('property', $this->acl_location); $config = CreateObject('phpgwapi.config', 'property'); $config->read(); $bolocation = CreateObject('property.bolocation'); if ($mode == 'edit') { $values = phpgw::get_var('values'); $values_attribute = phpgw::get_var('values_attribute'); $add_request = phpgw::get_var('add_request'); $values['project_group'] = phpgw::get_var('project_group'); $values['ecodimb'] = phpgw::get_var('ecodimb'); $values['b_account_id'] = phpgw::get_var('b_account_id', 'int', 'POST'); $values['b_account_name'] = phpgw::get_var('b_account_name', 'string', 'POST'); $values['contact_id'] = phpgw::get_var('contact', 'int', 'POST'); $auto_create = false; $datatable = array(); $insert_record = $GLOBALS['phpgw']->session->appsession('insert_record', 'property'); $insert_record_entity = $GLOBALS['phpgw']->session->appsession("insert_record_values{$this->acl_location}", 'property'); if (isset($insert_record_entity) && is_array($insert_record_entity)) { for ($j = 0; $j < count($insert_record_entity); $j++) { $insert_record['extra'][$insert_record_entity[$j]] = $insert_record_entity[$j]; } } $bypass = phpgw::get_var('bypass', 'bool'); //_debug_array($_REQUEST); if (phpgw::get_var('origin') == '.project.request' && phpgw::get_var('origin_id', 'int') && !$bypass) { $id = phpgw::get_var('project_id', 'int'); $add_request = array('request_id' => array(phpgw::get_var('origin_id', 'int'))); } if ($add_request) { $receipt = $this->bo->add_request($add_request, $id); } if ($_POST && !$bypass && isset($insert_record) && is_array($insert_record)) { $values = $this->bocommon->collect_locationdata($values, $insert_record); } else { $location_code = phpgw::get_var('location_code'); $tenant_id = phpgw::get_var('tenant_id', 'int'); $values['descr'] = phpgw::get_var('descr'); $p_entity_id = phpgw::get_var('p_entity_id', 'int'); $p_cat_id = phpgw::get_var('p_cat_id', 'int'); $values['p'][$p_entity_id]['p_entity_id'] = $p_entity_id; $values['p'][$p_entity_id]['p_cat_id'] = $p_cat_id; $values['p'][$p_entity_id]['p_num'] = phpgw::get_var('p_num'); $origin = phpgw::get_var('origin'); $origin_id = phpgw::get_var('origin_id', 'int'); if ($origin == '.ticket' && $origin_id && !$values['descr']) { $boticket = CreateObject('property.botts'); $ticket = $boticket->read_single($origin_id); $values['descr'] = $ticket['details']; $values['name'] = $ticket['subject'] ? $ticket['subject'] : $ticket['category_name']; $ticket_notes = $boticket->read_additional_notes($origin_id); $i = count($ticket_notes) - 1; if (isset($ticket_notes[$i]['value_note']) && $ticket_notes[$i]['value_note']) { $values['descr'] .= ": " . $ticket_notes[$i]['value_note']; } $values['contact_id'] = $ticket['contact_id']; $tts_status_create_project = isset($GLOBALS['phpgw_info']['user']['preferences']['property']['tts_status_create_project']) ? $GLOBALS['phpgw_info']['user']['preferences']['property']['tts_status_create_project'] : ''; if ($tts_status_create_project) { $boticket->update_status(array('status' => $tts_status_create_project), $origin_id); } if (isset($GLOBALS['phpgw_info']['user']['preferences']['property']['auto_create_project_from_ticket']) && $GLOBALS['phpgw_info']['user']['preferences']['property']['auto_create_project_from_ticket'] == 'yes') { $auto_create = true; } } if ($p_entity_id && $p_cat_id) { if (!is_object($boadmin_entity)) { $boadmin_entity = CreateObject('property.boadmin_entity'); } $entity_category = $boadmin_entity->read_single_category($p_entity_id, $p_cat_id); $values['p'][$p_entity_id]['p_cat_name'] = $entity_category['name']; } if ($location_code) { $values['location_data'] = $bolocation->read_single($location_code, array('tenant_id' => $tenant_id, 'p_num' => $p_num, 'view' => true)); } } if (isset($values['origin']) && $values['origin']) { $origin = $values['origin']; $origin_id = $values['origin_id']; } $interlink = CreateObject('property.interlink'); if (isset($origin) && $origin) { unset($values['origin']); unset($values['origin_id']); $values['origin'][0]['location'] = $origin; $values['origin'][0]['descr'] = $interlink->get_location_name($origin); $values['origin'][0]['data'][] = array('id' => $origin_id, 'link' => $interlink->get_relation_link(array('location' => $origin), $origin_id)); } if ($save = phpgw::get_var('save', 'bool')) { if ($GLOBALS['phpgw']->session->is_repost()) { // $receipt['error'][]=array('msg'=>lang('Hmm... looks like a repost!')); } if (isset($config->config_data['invoice_acl']) && $config->config_data['invoice_acl'] == 'dimb') { if (!$this->acl_manage) { if (!isset($values['ecodimb']) || !$values['ecodimb']) { $receipt['error'][] = array('msg' => lang('Please select dimb!')); $error_id = true; } $approve_role = execMethod('property.boinvoice.check_role', $values['ecodimb']); if (!$approve_role['is_supervisor'] && !$approve_role['is_budget_responsible']) { $receipt['error'][] = array('msg' => lang('you are not approved for this dimb: %1', $values['ecodimb'])); $error_id = true; } } } if (!isset($values['location'])) { $receipt['error'][] = array('msg' => lang('Please select a location !')); $error_id = true; } if (isset($values['b_account_id']) && $values['b_account_id']) { $sogeneric = CreateObject('property.sogeneric'); $sogeneric->get_location_info('b_account_category', false); $status_data = $sogeneric->read_single(array('id' => (int) $values['b_account_id']), array()); if (isset($status_data['project_group']) && $status_data['project_group']) { if (!isset($values['project_group']) || !$values['project_group']) { $receipt['error'][] = array('msg' => lang('Please select a project group!')); $error_id = true; } } } if (isset($values['new_project_id']) && $values['new_project_id'] && !$this->bo->read_single_mini($values['new_project_id'])) { $receipt['error'][] = array('msg' => lang('the project %1 does not exist', $values['new_project_id'])); } if (isset($values['new_project_id']) && $values['new_project_id'] && $values['new_project_id'] == $id) { unset($values['new_project_id']); } if (!isset($values['end_date']) || !$values['end_date']) { $receipt['error'][] = array('msg' => lang('Please select an end date!')); $error_id = true; } if (!isset($values['project_type_id']) || !$values['project_type_id']) { $receipt['error'][] = array('msg' => lang('Please select a project type!')); $error_id = true; } if (!$values['name']) { $receipt['error'][] = array('msg' => lang('Please enter a project NAME !')); $error_id = true; } if (!isset($config->config_data['project_optional_category']) || !$config->config_data['project_optional_category']) { if (!$values['cat_id']) { $receipt['error'][] = array('msg' => lang('Please select a category !')); $error_id = true; } } if (isset($values['cat_id']) && $values['cat_id']) { $_category = $this->cats->return_single($values['cat_id']); if (!$_category[0]['active']) { $receipt['error'][] = array('msg' => lang('invalid category')); } } if (!$values['coordinator']) { $receipt['error'][] = array('msg' => lang('Please select a coordinator !')); $error_id = true; } if (!$values['status']) { $receipt['error'][] = array('msg' => lang('Please select a status !')); $error_id = true; } if (isset($values['budget']) && $values['budget'] && !ctype_digit(ltrim($values['budget'], '-'))) { $receipt['error'][] = array('msg' => lang('budget') . ': ' . lang('Please enter an integer !')); $error_id = true; } if (isset($values['reserve']) && $values['reserve'] && !ctype_digit(ltrim($values['reserve'], '-'))) { $receipt['error'][] = array('msg' => lang('reserve') . ': ' . lang('Please enter an integer !')); $error_id = true; } if (isset($values_attribute) && is_array($values_attribute)) { foreach ($values_attribute as $attribute) { if ($attribute['nullable'] != 1 && (!$attribute['value'] && !$values['extra'][$attribute['name']])) { $receipt['error'][] = array('msg' => lang('Please enter value for attribute %1', $attribute['input_text'])); } } } if ($values['approval'] && $values['mail_address'] && $config->config_data['project_approval']) { if (isset($config->config_data['project_approval_status']) && $config->config_data['project_approval_status']) { $values['status'] = $config->config_data['project_approval_status']; } } if ($id) { $values['id'] = $id; $action = 'edit'; } if (!$receipt['error']) { if ($values['copy_project']) { $action = 'add'; } $receipt = $this->bo->save($values, $action, $values_attribute); if (!$receipt['error']) { $id = $receipt['id']; } //----------files $bofiles = CreateObject('property.bofiles'); if (isset($values['file_action']) && is_array($values['file_action'])) { $bofiles->delete_file("/project/{$id}/", $values); } $file_name = @str_replace(' ', '_', $_FILES['file']['name']); if ($file_name) { $to_file = "{$bofiles->fakebase}/project/{$id}/{$file_name}"; if ($bofiles->vfs->file_exists(array('string' => $to_file, 'relatives' => array(RELATIVE_NONE)))) { $receipt['error'][] = array('msg' => lang('This file already exists !')); } else { $bofiles->create_document_dir("project/{$id}"); $bofiles->vfs->override_acl = 1; if (!$bofiles->vfs->cp(array('from' => $_FILES['file']['tmp_name'], 'to' => $to_file, 'relatives' => array(RELATIVE_NONE | VFS_REAL, RELATIVE_ALL)))) { $receipt['error'][] = array('msg' => lang('Failed to upload file !')); } $bofiles->vfs->override_acl = 0; } } //----------- if (isset($GLOBALS['phpgw_info']['server']['smtp_server']) && $GLOBALS['phpgw_info']['server']['smtp_server']) { $historylog = CreateObject('property.historylog', 'project'); if (!is_object($GLOBALS['phpgw']->send)) { $GLOBALS['phpgw']->send = CreateObject('phpgwapi.send'); } $action_params['responsible'] = $_account_id; $from_name = $GLOBALS['phpgw_info']['user']['fullname']; $from_email = $GLOBALS['phpgw_info']['user']['preferences']['property']['email']; $subject = lang(Approval) . ": " . $id; $message = '<a href ="' . $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uiproject.edit', 'id' => $id), false, true) . '">' . lang('project %1 needs approval', $id) . '</a>'; $bcc = ''; //$from_email; $action_params = array('appname' => 'property', 'location' => '.project', 'id' => $id, 'responsible' => '', 'responsible_type' => 'user', 'action' => 'approval', 'remark' => '', 'deadline' => ''); if (isset($values['mail_address']) && is_array($values['mail_address'])) { foreach ($values['mail_address'] as $_account_id => $_address) { if (isset($values['approval'][$_account_id]) && $values['approval'][$_account_id]) { $rcpt = $GLOBALS['phpgw']->send->msg('email', $_address, $subject, stripslashes($message), '', $cc, $bcc, $from_email, $from_name, 'html'); $action_params['responsible'] = $_account_id; execMethod('property.sopending_action.set_pending_action', $action_params); if (!$rcpt) { $receipt['error'][] = array('msg' => "uiproject::edit: sending message to '" . $_address . "', subject='{$subject}' failed !!!"); $receipt['error'][] = array('msg' => $GLOBALS['phpgw']->send->err['desc']); $bypass_error = true; } else { $historylog->add('AP', $id, lang('%1 is notified', $_address)); $receipt['message'][] = array('msg' => lang('%1 is notified', $_address)); } } } } $toarray = array(); $toarray_sms = array(); if (isset($receipt['notice_owner']) && is_array($receipt['notice_owner'])) { if ($this->account != $values['coordinator'] && isset($GLOBALS['phpgw_info']['user']['preferences']['property']['notify_project_owner']) && $GLOBALS['phpgw_info']['user']['preferences']['property']['notify_project_owner']) { $prefs_coordinator = $this->bocommon->create_preferences('property', $values['coordinator']); if (isset($prefs_coordinator['email']) && $prefs_coordinator['email']) { $toarray[] = $prefs_coordinator['email']; } } } $notify_list = execMethod('property.notify.read', array('location_id' => $location_id, 'location_item_id' => $id)); $subject = lang('project %1 has been edited', $id); if (isset($GLOBALS['phpgw_info']['user']['apps']['sms'])) { $sms_text = "{$subject}. \r\n{$GLOBALS['phpgw_info']['user']['fullname']} \r\n{$GLOBALS['phpgw_info']['user']['preferences']['property']['email']}"; $sms = CreateObject('sms.sms'); foreach ($notify_list as $entry) { if ($entry['is_active'] && $entry['notification_method'] == 'sms' && $entry['sms']) { $sms->websend2pv($this->account, $entry['sms'], $sms_text); $toarray_sms[] = "{$entry['first_name']} {$entry['last_name']}({$entry['sms']})"; $receipt['message'][] = array('msg' => lang('%1 is notified', "{$entry['first_name']} {$entry['last_name']}")); } } unset($entry); if ($toarray_sms) { $historylog->add('MS', $id, implode(',', $toarray_sms)); } } reset($notify_list); foreach ($notify_list as $entry) { if ($entry['is_active'] && $entry['notification_method'] == 'email' && $entry['email']) { $toarray[] = "{$entry['first_name']} {$entry['last_name']}<{$entry['email']}>"; } } unset($entry); if ($toarray) { $to = implode(';', $toarray); $from_name = $GLOBALS['phpgw_info']['user']['fullname']; $from_email = $GLOBALS['phpgw_info']['user']['preferences']['property']['email']; $body = '<a href ="' . $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uiproject.edit', 'id' => $id), false, true) . '">' . lang('project %1 has been edited', $id) . '</a>' . "\n"; foreach ($receipt['notice_owner'] as $notice) { $body .= $notice . "\n"; } $body .= lang('Altered by') . ': ' . $from_name . "\n"; $body .= lang('remark') . ': ' . $values['remark'] . "\n"; $body = nl2br($body); $returncode = $GLOBALS['phpgw']->send->msg('email', $to, $subject, $body, false, false, false, $from_email, $from_name, 'html'); if (!$returncode) { $receipt['error'][] = array('msg' => "uiproject::edit: sending message to '{$to}' subject='{$subject}' failed !!!"); $receipt['error'][] = array('msg' => $GLOBALS['phpgw']->send->err['desc']); $bypass_error = true; } else { $historylog->add('ON', $id, lang('%1 is notified', $to)); $receipt['message'][] = array('msg' => lang('%1 is notified', $to)); } } } } if ($receipt['error'] && !isset($bypass_error)) { if (isset($values['location']) && is_array($values['location'])) { $location_code = implode("-", $values['location']); $values['extra']['view'] = true; $values['location_data'] = $bolocation->read_single($location_code, $values['extra']); } if (isset($values['extra']['p_num'])) { $values['p'][$values['extra']['p_entity_id']]['p_num'] = $values['extra']['p_num']; $values['p'][$values['extra']['p_entity_id']]['p_entity_id'] = $values['extra']['p_entity_id']; $values['p'][$values['extra']['p_entity_id']]['p_cat_id'] = $values['extra']['p_cat_id']; $values['p'][$values['extra']['p_entity_id']]['p_cat_name'] = phpgw::get_var('entity_cat_name_' . $values['extra']['p_entity_id'], 'string', 'POST'); } } } } //$record_history = ''; $record_history = array(); if (isset($bypass_error) || (!isset($receipt['error']) || $add_request) && !$bypass && $id) { $_transfer_new_project = isset($values['new_project_id']) && $values['new_project_id'] ? true : false; $values = $this->bo->read_single($id); if (!isset($values['origin'])) { $values['origin'] = ''; } if (!isset($values['workorder_budget']) && $save && !$_transfer_new_project && !$values['project_type_id'] == 3) { $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'property.uiworkorder.edit', 'project_id' => $id)); } if (!$this->bocommon->check_perms($values['grants'], PHPGW_ACL_EDIT)) { $receipt['error'][] = array('msg' => lang('You have no edit right for this project')); $GLOBALS['phpgw']->session->appsession('receipt', 'property', $receipt); $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'property.uiproject.view', 'id' => $id)); } else { $record_history = $this->bo->read_record_history($id); } } /* Preserve attribute values from post */ if (isset($receipt['error']) && (isset($values_attribute) && is_array($values_attribute))) { $values = $this->bocommon->preserve_attribute_values($values, $values_attribute); } if ($id) { $function_msg = lang("{$mode} project"); } else { $function_msg = lang('Add Project'); $values = $this->bo->read_single(0, $values); } $tabs = array(); if (isset($values['attributes']) && is_array($values['attributes'])) { foreach ($values['attributes'] as &$attribute) { if ($attribute['history'] == true) { $link_history_data = array('menuaction' => 'property.uiproject.attrib_history', 'attrib_id' => $attribute['id'], 'id' => $id, 'edit' => true); $attribute['link_history'] = $GLOBALS['phpgw']->link('/index.php', $link_history_data); } } } if (isset($values['cat_id'])) { $this->cat_id = $values['cat_id']; } $lookup_type = $mode == 'edit' ? 'form' : 'view'; //_debug_array($values); $location_data = $bolocation->initiate_ui_location(array('values' => isset($values['location_data']) ? $values['location_data'] : '', 'type_id' => -1, 'no_link' => false, 'tenant' => true, 'lookup_type' => $lookup_type, 'lookup_entity' => $this->bocommon->get_lookup_entity('project'), 'entity_data' => isset($values['p']) ? $values['p'] : '')); $b_account_data = array(); $ecodimb_data = array(); if (isset($config->config_data['budget_at_project']) && $config->config_data['budget_at_project']) { $b_account_data = $this->bocommon->initiate_ui_budget_account_lookup(array('b_account_id' => $values['b_account_id'], 'b_account_name' => $values['b_account_name'], 'role' => 'group', 'type' => $lookup_type)); $ecodimb_data = $this->bocommon->initiate_ecodimb_lookup(array('ecodimb' => $values['ecodimb'], 'ecodimb_descr' => $values['ecodimb_descr'], 'disabled' => $mode == 'view')); } $contact_data = $this->bocommon->initiate_ui_contact_lookup(array('contact_id' => $values['contact_id'], 'contact_name' => $values['contact_name'], 'field' => 'contact', 'type' => $lookup_type)); if (isset($values['contact_phone'])) { for ($i = 0; $i < count($location_data['location']); $i++) { if ($location_data['location'][$i]['input_name'] == 'contact_phone') { $location_data['location'][$i]['value'] = $values['contact_phone']; } } } $link_data = array('menuaction' => 'property.uiproject.edit', 'id' => $id); $link_request_data = array('menuaction' => 'property.uirequest.index', 'query' => isset($values['location_data']['loc1']) ? $values['location_data']['loc1'] : '', 'project_id' => isset($id) ? $id : ''); $supervisor_email = array(); if ($need_approval = isset($config->config_data['project_approval']) ? $config->config_data['project_approval'] : '') { $invoice = CreateObject('property.soinvoice'); if (isset($config->config_data['invoice_acl']) && $config->config_data['invoice_acl'] == 'dimb') { $supervisor_id = $invoice->get_default_dimb_role_user(2, $values['ecodimb']); $sodimb_role_users = execMethod('property.sodimb_role_user.read', array('dimb_id' => $values['ecodimb'], 'role_id' => 2, 'query_start' => date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']), 'get_netto_list' => true)); if (isset($sodimb_role_users[$values['ecodimb']][2]) && is_array($sodimb_role_users[$values['ecodimb']][2])) { foreach ($sodimb_role_users[$values['ecodimb']][2] as $supervisor_id => $entry) { $prefs = $this->bocommon->create_preferences('property', $supervisor_id); $supervisor_email[] = array('id' => $supervisor_id, 'address' => $prefs['email'], 'default' => $entry['default_user']); } } $supervisor2_id = $invoice->get_default_dimb_role_user(3, $values['ecodimb']); $prefs2 = $this->bocommon->create_preferences('property', $supervisor2_id); $supervisor_email[] = array('id' => $supervisor2_id, 'address' => $prefs2['email']); // $supervisor_email = array_reverse($supervisor_email); unset($prefs); unset($prefs2); unset($invoice); } else { $supervisor_id = 0; if (isset($GLOBALS['phpgw_info']['user']['preferences']['property']['approval_from']) && $GLOBALS['phpgw_info']['user']['preferences']['property']['approval_from']) { $supervisor_id = $GLOBALS['phpgw_info']['user']['preferences']['property']['approval_from']; } if ($supervisor_id) { $prefs = $this->bocommon->create_preferences('property', $supervisor_id); $supervisor_email[] = array('id' => $supervisor_id, 'address' => $prefs['email']); if (isset($prefs['approval_from'])) { $prefs2 = $this->bocommon->create_preferences('property', $prefs['approval_from']); if (isset($prefs2['email'])) { $supervisor_email[] = array('id' => $prefs['approval_from'], 'address' => $prefs2['email']); $supervisor_email = array_reverse($supervisor_email); } unset($prefs2); } unset($prefs); } } } $project_status = isset($GLOBALS['phpgw_info']['user']['preferences']['property']['project_status']) ? $GLOBALS['phpgw_info']['user']['preferences']['property']['project_status'] : ''; $project_category = isset($GLOBALS['phpgw_info']['user']['preferences']['property']['project_category']) ? $GLOBALS['phpgw_info']['user']['preferences']['property']['project_category'] : ''; if (!isset($values['status'])) { $values['status'] = $project_status; } if (!isset($values['cat_id'])) { $values['cat_id'] = $project_category; } if (!isset($values['coordinator'])) { $values['coordinator'] = $this->account; } if (!isset($values['start_date']) || !$values['start_date']) { $values['start_date'] = $GLOBALS['phpgw']->common->show_date(mktime(0, 0, 0, date("m"), date("d"), date("Y")), $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']); } if (isset($receipt) && is_array($receipt)) { $msgbox_data = $this->bocommon->msgbox_data($receipt); } else { $msgbox_data = ''; } $values['sum'] = isset($values['budget']) ? $values['budget'] : 0; if (isset($values['reserve']) && $values['reserve'] != 0) { $reserve_remainder = $values['reserve'] - $values['deviation']; $remainder_percent = number_format($reserve_remainder / $values['reserve'] * 100, 2, ',', ''); $values['sum'] = $values['sum'] + $values['reserve']; } $value_remainder = $values['sum']; $GLOBALS['phpgw']->jqcal->add_listener('values_start_date'); $GLOBALS['phpgw']->jqcal->add_listener('values_end_date'); $project_group_data = $this->bocommon->initiate_project_group_lookup(array('project_group' => $values['project_group'], 'project_group_descr' => $values['project_group_descr'])); //---datatable settings--------------------------------------------------- $sum_actual_cost = 0; $sum_oblications = 0; $rows_per_page = 10; $initial_page = 1; if ($id) { $content_budget = $this->bo->get_budget($id); $lang_delete = lang('Check to delete period'); $lang_close = lang('Check to close period'); $lang_active = lang('Check to activate period'); $values['sum'] = 0; if ($content_budget && $values['periodization_id']) { $_year_count = array(); foreach ($content_budget as $key => $row) { $_year_count[$row['year']] += 1; $rows_per_page = $_year_count[$row['year']]; } $initial_page = floor(count($content_budget) / $rows_per_page); } /* if($content_budget) { foreach ($content_budget as $key => $row) { $_year_arg[$key] = $row['year']; $_month_arg[$key] = $row['month']; } array_multisort($_year_arg, SORT_DESC, $_month_arg, SORT_ASC, $content_budget); reset($content_budget); } */ foreach ($content_budget as &$b_entry) { if ($b_entry['active']) { $sum_actual_cost += $b_entry['actual_cost']; $sum_oblications += $b_entry['sum_oblications']; $values['sum'] += $b_entry['budget']; } $checked = $b_entry['closed'] ? 'checked="checked"' : ''; $checked2 = $b_entry['active'] ? 'checked="checked"' : ''; $b_entry['flag_active'] = $b_entry['active']; $b_entry['delete_year'] = "<input type='checkbox' name='values[delete_b_period][]' value='{$b_entry['year']}_{$b_entry['month']}' title='{$lang_delete}'>"; $b_entry['closed'] = "<input type='checkbox' name='values[closed_b_period][]' value='{$b_entry['year']}_{$b_entry['month']}' title='{$lang_close}' {$checked}>"; $b_entry['closed_orig'] = "<input type='checkbox' name='values[closed_orig_b_period][]' value='{$b_entry['year']}_{$b_entry['month']}' {$checked}>"; $b_entry['active'] = "<input type='checkbox' name='values[active_b_period][]' value='{$b_entry['year']}_{$b_entry['month']}' title='{$lang_active}' {$checked2}>"; $b_entry['active_orig'] = "<input type='checkbox' name='values[active_orig_b_period][]' value='{$b_entry['year']}_{$b_entry['month']}' {$checked2}>"; } unset($b_entry); } if (isset($values['reserve']) && $values['reserve'] != 0) { $reserve_remainder = $values['reserve'] - $values['deviation']; $remainder_percent = number_format($reserve_remainder / $values['reserve'] * 100, 2, ',', ''); $values['sum'] = $values['sum'] + $values['reserve']; } $value_remainder = $values['sum'] - $sum_actual_cost - $sum_oblications; $values['sum'] = number_format($values['sum'], 0, ',', ' '); $value_remainder = number_format($value_remainder, 0, ',', ' '); if (isset($values['project_type_id']) && $values['project_type_id'] == 3) { $rows_per_page = 10; $initial_page = 1; $myColumnDefs[0] = array('name' => "0", 'values' => json_encode(array(array('key' => 'year', 'label' => lang('year'), 'sortable' => false, 'resizeable' => true), array('key' => 'entry_date', 'label' => lang('entry date'), 'sortable' => true, 'resizeable' => true), array('key' => 'amount_in', 'label' => lang('amount in'), 'sortable' => false, 'resizeable' => true, 'formatter' => 'FormatterAmount0'), array('key' => 'from_project', 'label' => lang('from project'), 'sortable' => true, 'resizeable' => true, 'formatter' => 'project_link'), array('key' => 'amount_out', 'label' => lang('amount out'), 'sortable' => false, 'resizeable' => true, 'formatter' => 'FormatterAmount0'), array('key' => 'to_project', 'label' => lang('to project'), 'sortable' => true, 'resizeable' => true, 'formatter' => 'project_link'), array('key' => 'remark', 'label' => lang('remark'), 'sortable' => true, 'resizeable' => true)))); $content_budget = $this->bo->get_buffer_budget($id); foreach ($content_budget as &$b_entry) { $b_entry['entry_date'] = $GLOBALS['phpgw']->common->show_date($b_entry['entry_date'], $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']); } unset($b_entry); } else { $myColumnDefs[0] = array('name' => "0", 'values' => json_encode(array(array('key' => 'year', 'label' => lang('year'), 'sortable' => false, 'resizeable' => true), array('key' => 'month', 'label' => lang('month'), 'sortable' => false, 'resizeable' => true), array('key' => 'budget', 'label' => lang('budget'), 'sortable' => false, 'resizeable' => true, 'formatter' => 'FormatterAmount0'), array('key' => 'sum_oblications', 'label' => lang('sum orders'), 'sortable' => false, 'resizeable' => true, 'formatter' => 'FormatterAmount0'), array('key' => 'actual_cost', 'label' => lang('actual cost'), 'sortable' => false, 'resizeable' => true, 'formatter' => 'FormatterAmount0'), array('key' => 'diff', 'label' => lang('difference'), 'sortable' => false, 'resizeable' => true, 'formatter' => 'FormatterAmount0'), array('key' => 'deviation_period', 'label' => lang('deviation'), 'sortable' => false, 'resizeable' => true, 'formatter' => 'FormatterAmount0'), array('key' => 'deviation_acc', 'label' => lang('deviation') . '::' . lang('accumulated'), 'sortable' => false, 'resizeable' => true, 'formatter' => 'FormatterAmount0'), array('key' => 'deviation_percent_period', 'label' => lang('deviation') . '::' . lang('percent'), 'sortable' => false, 'resizeable' => true, 'formatter' => 'FormatterAmount2'), array('key' => 'deviation_percent_acc', 'label' => lang('percent') . '::' . lang('accumulated'), 'sortable' => false, 'resizeable' => true, 'formatter' => 'FormatterAmount2'), array('key' => 'closed', 'label' => lang('closed'), 'sortable' => false, 'resizeable' => true, 'formatter' => 'FormatterCenter'), array('key' => 'closed_orig', 'hidden' => true), array('key' => 'active', 'label' => lang('active'), 'sortable' => false, 'resizeable' => true, 'formatter' => 'FormatterCenter'), array('key' => 'active_orig', 'hidden' => true), array('key' => 'flag_active', 'hidden' => true), array('key' => 'delete_year', 'label' => lang('Delete'), 'sortable' => false, 'resizeable' => true, 'formatter' => 'FormatterCenter')))); } $datavalues[0] = array('name' => "0", 'values' => json_encode($content_budget), 'total_records' => count($content_budget), 'edit_action' => "''", 'permission' => "''", 'is_paginator' => 1, 'rows_per_page' => $rows_per_page, 'initial_page' => $initial_page, 'footer' => 0); //_debug_array($values['workorder_budget']);die(); $content_orders = $this->get_orders($id, date('Y')); // _debug_array($content_orders);die(); foreach ($content_orders as &$_order_entry) { $_order_entry['send_order'] = ''; if (isset($_order_entry['mail_recipients'][0]) && $_order_entry['mail_recipients'][0]) { $_title = implode(';', $_order_entry['mail_recipients']); $_order_entry['send_order'] = "<input type='checkbox' name='values[send_order][]' value='{$_order_entry['workorder_id']}' title='{$_title}'>"; } } //FIXME: deviation from this one $datavalues[1] = array('name' => "1", 'values' => json_encode($content_orders), 'total_records' => count($content_orders), 'edit_action' => json_encode($GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uiworkorder.edit'))), 'is_paginator' => 1, 'rows_per_page' => 10, 'initial_page' => 1, 'footer' => 0); $myColumnDefs[1] = array('name' => "1", 'values' => json_encode(array(array('key' => 'workorder_id', 'label' => lang('Workorder'), 'sortable' => true, 'resizeable' => true, 'formatter' => 'YAHOO.widget.DataTable.formatLink'), array('key' => 'title', 'label' => lang('title'), 'sortable' => true, 'resizeable' => true), array('key' => 'b_account_id', 'label' => lang('Budget account'), 'sortable' => true, 'resizeable' => true, 'formatter' => 'FormatterRight'), array('key' => 'budget', 'label' => lang('budget'), 'sortable' => true, 'resizeable' => true, 'formatter' => 'FormatterAmount0'), array('key' => 'cost', 'label' => lang('cost'), 'sortable' => true, 'resizeable' => true, 'formatter' => 'FormatterAmount0'), array('key' => 'addition_percentage', 'label' => '%', 'sortable' => false, 'resizeable' => true, 'formatter' => 'FormatterRight'), array('key' => 'obligation', 'label' => lang('sum orders'), 'sortable' => true, 'resizeable' => true, 'formatter' => 'FormatterAmount0'), array('key' => 'actual_cost', 'label' => lang('actual cost'), 'sortable' => true, 'resizeable' => true, 'formatter' => 'FormatterAmount0'), array('key' => 'diff', 'label' => lang('difference'), 'sortable' => true, 'resizeable' => true, 'formatter' => 'FormatterAmount0'), array('key' => 'vendor_name', 'label' => lang('Vendor'), 'sortable' => true, 'resizeable' => true), array('key' => 'status', 'label' => lang('Status'), 'sortable' => true, 'resizeable' => true), array('key' => 'send_order', 'label' => lang('send workorder'), 'sortable' => false, 'resizeable' => true, 'formatter' => 'FormatterCenter')))); $invoices = array(); $content_invoice = array(); if ($id) { $content_invoice = $this->get_vouchers($id, date('Y')); } $datavalues[2] = array('name' => "2", 'values' => json_encode($content_invoice), 'total_records' => count($content_invoice), 'edit_action' => json_encode($GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uiinvoice.index'))), 'is_paginator' => 1, 'rows_per_page' => 10, 'initial_page' => 1, 'footer' => 0); $_formatter_voucher_link = isset($config->config_data['invoicehandler']) && $config->config_data['invoicehandler'] == 2 ? 'YAHOO.widget.DataTable.formatLink_invoicehandler_2' : 'YAHOO.widget.DataTable.formatLink_voucher'; $myColumnDefs[2] = array('name' => "2", 'values' => json_encode(array(array('key' => 'workorder_id', 'label' => lang('Workorder'), 'sortable' => true, 'resizeable' => true, 'formatter' => 'YAHOO.widget.DataTable.formatLink'), array('key' => 'voucher_id', 'label' => lang('bilagsnr'), 'sortable' => true, 'resizeable' => true, 'formatter' => $_formatter_voucher_link), array('key' => 'voucher_out_id', 'hidden' => true), array('key' => 'invoice_id', 'label' => lang('invoice number'), 'sortable' => false, 'resizeable' => true), array('key' => 'vendor', 'label' => lang('vendor'), 'sortable' => false, 'resizeable' => true), array('key' => 'amount', 'label' => lang('amount'), 'sortable' => true, 'resizeable' => true, 'formatter' => 'FormatterAmount2'), array('key' => 'approved_amount', 'label' => lang('approved amount'), 'sortable' => false, 'resizeable' => true, 'formatter' => 'FormatterAmount2'), array('key' => 'period', 'label' => lang('period'), 'sortable' => true, 'resizeable' => true), array('key' => 'periodization', 'label' => lang('periodization'), 'sortable' => false, 'resizeable' => true), array('key' => 'periodization_start', 'label' => lang('periodization start'), 'sortable' => false, 'resizeable' => true), array('key' => 'currency', 'label' => lang('currency'), 'sortable' => false, 'resizeable' => true), array('key' => 'type', 'label' => lang('type'), 'sortable' => true, 'resizeable' => true), array('key' => 'budget_responsible', 'label' => lang('budget responsible'), 'sortable' => true, 'resizeable' => true), array('key' => 'budsjettsigndato', 'label' => lang('budsjettsigndato'), 'sortable' => true, 'resizeable' => true), array('key' => 'transfer_time', 'label' => lang('transfer time'), 'sortable' => true, 'resizeable' => true)))); $notify_info = execMethod('property.notify.get_yui_table_def', array('location_id' => $location_id, 'location_item_id' => $id, 'count' => count($myColumnDefs))); $datavalues[] = $notify_info['datavalues']; $myColumnDefs[3] = $notify_info['column_defs']; $myButtons = array(); if ($mode == 'edit') { $myButtons[3] = $notify_info['buttons']; } $datavalues[4] = array('name' => "4", 'values' => json_encode($record_history), 'total_records' => count($record_history), 'edit_action' => "''", 'is_paginator' => 0, 'footer' => 0); $myColumnDefs[4] = array('name' => "4", 'values' => json_encode(array(array('key' => 'value_date', 'label' => lang('Date'), 'sortable' => true, 'resizeable' => true), array('key' => 'value_user', 'label' => lang('User'), 'Action' => true, 'resizeable' => true), array('key' => 'value_action', 'label' => lang('action'), 'sortable' => true, 'resizeable' => true), array('key' => 'value_old_value', 'label' => lang('old value'), 'sortable' => true, 'resizeable' => true), array('key' => 'value_new_value', 'label' => lang('new value'), 'sortable' => true, 'resizeable' => true)))); //--------------files $link_file_data = array('menuaction' => 'property.uiproject.view_file', 'id' => $id); $link_to_files = isset($config->config_data['files_url']) ? $config->config_data['files_url'] : ''; $link_view_file = $GLOBALS['phpgw']->link('/index.php', $link_file_data); $_files = $this->bo->get_files($id); $lang_view_file = lang('click to view file'); $lang_delete_file = lang('Check to delete file'); $z = 0; $content_files = array(); foreach ($_files as $_file) { if ($link_to_files) { $content_files[$z]['file_name'] = "<a href='{$link_to_files}/{$_file['directory']}/{$_file['file_name']}' target=\"_blank\" title='{$lang_view_file}'>{$_file['name']}</a>"; } else { $content_files[$z]['file_name'] = "<a href=\"{$link_view_file}&file_name={$_file['file_name']}\" target=\"_blank\" title=\"{$lang_view_file}\">{$_file['name']}</a>"; } $content_files[$z]['delete_file'] = "<input type=\"checkbox\" name=\"values[file_action][]\" value=\"{$_file['name']}\" title=\"{$lang_delete_file}\">"; $z++; } $datavalues[5] = array('name' => "5", 'values' => json_encode($content_files), 'total_records' => count($content_files), 'edit_action' => "''", 'is_paginator' => 1, 'rows_per_page' => $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'], 'footer' => 0); $myColumnDefs[5] = array('name' => "5", 'values' => json_encode(array(array('key' => 'file_name', 'label' => lang('Filename'), 'sortable' => false, 'resizeable' => true), array('key' => 'delete_file', 'label' => lang('Delete file'), 'sortable' => false, 'resizeable' => true)))); //--------------files $lang_delete_request_statustext = lang('Check to delete this request from this project'); $_origin = array(); if (isset($values['origin']) && $values['origin']) { foreach ($values['origin'] as $__origin) { foreach ($__origin['data'] as $_origin_data) { $_select = ''; if ($__origin['location'] == '.project.request') { $_select = "<input type=\"checkbox\" name=\"values[delete_request][]\" value=\"{$_origin_data['id']}\" title=\"{$lang_delete_request_statustext}\">"; } $_origin[] = array('url' => "<a href='{$_origin_data['link']}'>{$_origin_data['id']} </a>", 'type' => $__origin['descr'], 'title' => $_origin_data['title'], 'status' => $_origin_data['statustext'], 'select' => $_select); } } } $datavalues[6] = array('name' => "6", 'values' => json_encode($_origin), 'total_records' => count($_origin), 'edit_action' => "''", 'is_paginator' => 1, 'rows_per_page' => 5, 'footer' => 0); $myColumnDefs[6] = array('name' => "6", 'values' => json_encode(array(array('key' => 'url', 'label' => lang('id'), 'sortable' => true, 'resizeable' => true), array('key' => 'type', 'label' => lang('type'), 'sortable' => true, 'resizeable' => true), array('key' => 'title', 'label' => lang('title'), 'sortable' => false, 'resizeable' => true), array('key' => 'status', 'label' => lang('status'), 'sortable' => false, 'resizeable' => true), array('key' => 'select', 'label' => lang('select'), 'sortable' => false, 'resizeable' => true)))); // _debug_array($myButtons);die(); //----------------------------------------------datatable settings-------- $suppresscoordination = isset($config->config_data['project_suppresscoordination']) && $config->config_data['project_suppresscoordination'] ? 1 : ''; $year = date('Y') - 1; $limit = $year + 8; while ($year < $limit) { $year_list[] = array('id' => $year, 'name' => $year); $year++; } $periodization_list = $this->bo->get_periodizations_with_outline(); $sub_entry_action_data = array(); $sub_entry_action_data = array('menuaction' => 'property.uiworkorder.edit', 'project_id' => $id); if ($id && !$values['project_type_id'] == 3) { $sub_entry_action_data = array('menuaction' => 'property.uiworkorder.edit', 'project_id' => $id); } else { if ($id && $values['project_type_id'] == 3) { $sub_entry_action_data = array('menuaction' => 'property.uiproject.edit', 'bypass' => 1, 'parent_id' => $id, 'origin' => '.project', 'origin_id' => $id); } } $selected_tab = phpgw::get_var('tab', 'string', 'REQUEST', 'general'); $project_type_id = isset($values['project_type_id']) && $values['project_type_id'] ? $values['project_type_id'] : $GLOBALS['phpgw_info']['user']['preferences']['property']['default_project_type']; $property_js = "/property/js/yahoo/property2.js"; if (!isset($GLOBALS['phpgw_info']['server']['no_jscombine']) || !$GLOBALS['phpgw_info']['server']['no_jscombine']) { $cachedir = urlencode($GLOBALS['phpgw_info']['server']['temp_dir']); $property_js = "/phpgwapi/inc/combine.php?cachedir={$cachedir}&type=javascript&files=" . str_replace('/', '--', ltrim($property_js, '/')); } $data = array('property_js' => json_encode($GLOBALS['phpgw_info']['server']['webserver_url'] . $property_js), 'project_types' => array('options' => $this->bo->get_project_types($project_type_id)), 'project_type_id' => $values['project_type_id'], 'inherit_location' => $id ? $values['inherit_location'] : 1, 'mode' => $mode, 'suppressmeter' => isset($config->config_data['project_suppressmeter']) && $config->config_data['project_suppressmeter'] ? 1 : '', 'suppresscoordination' => $suppresscoordination, 'custom_attributes' => array('attributes' => $values['attributes']), 'lookup_functions' => isset($values['lookup_functions']) ? $values['lookup_functions'] : '', 'b_account_data' => $b_account_data, 'ecodimb_data' => $ecodimb_data, 'contact_data' => $contact_data, 'datatable' => $datavalues, 'myColumnDefs' => $myColumnDefs, 'myButtons' => $myButtons, 'tabs' => self::_generate_tabs($tabs, array('documents' => $id ? false : true, 'history' => $id ? false : true), $selected_tab), 'msgbox_data' => $GLOBALS['phpgw']->common->msgbox($msgbox_data), 'value_origin' => isset($values['origin']) ? $values['origin'] : '', 'value_origin_type' => isset($origin) ? $origin : '', 'value_origin_id' => isset($origin_id) ? $origin_id : '', 'year_list' => array('options' => $year_list), 'order_time_span' => array('options' => $this->bo->get_order_time_span($id)), 'periodization_list' => array('options' => $periodization_list), 'lang_select_request_statustext' => lang('Add request for this project'), 'lang_request_statustext' => lang('Link to the request for this project'), 'link_select_request' => $GLOBALS['phpgw']->link('/index.php', $link_request_data), 'add_sub_entry_action' => $GLOBALS['phpgw']->link('/index.php', $sub_entry_action_data), 'lang_add_sub_entry' => $values['project_type_id'] == 3 ? lang('add project') : lang('Add workorder'), 'lang_add_sub_entry_statustext' => $values['project_type_id'] == 3 ? lang('add a project to this buffer') : lang('Add a workorder to this project'), 'lang_no_workorders' => lang('No workorder budget'), 'workorder_link' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uiworkorder.edit')), 'record_history' => $record_history, 'table_header_history' => $table_header_history, 'lang_history' => lang('History'), 'lang_no_history' => lang('No history'), 'lang_start_date_statustext' => lang('Select the estimated end date for the Project'), 'lang_start_date' => lang('Project start date'), 'value_start_date' => $values['start_date'], 'lang_end_date_statustext' => lang('Select the estimated end date for the Project'), 'lang_end_date' => lang('Project end date'), 'value_end_date' => isset($values['end_date']) ? $values['end_date'] : '', 'lang_copy_project' => lang('Copy project ?'), 'lang_copy_project_statustext' => lang('Choose Copy Project to copy this project to a new project'), 'lang_charge_tenant' => lang('Charge tenant'), 'lang_charge_tenant_statustext' => lang('Choose charge tenant if the tenant i to pay for this project'), 'charge_tenant' => isset($values['charge_tenant']) ? $values['charge_tenant'] : '', 'lang_power_meter' => lang('Power meter'), 'lang_power_meter_statustext' => lang('Enter the power meter'), 'value_power_meter' => isset($values['power_meter']) ? $values['power_meter'] : '', 'value_budget' => isset($values['budget']) ? $values['budget'] : '', 'lang_reserve' => lang('reserve'), 'value_reserve' => isset($values['reserve']) ? $values['reserve'] : '', 'lang_reserve_statustext' => lang('Enter the reserve'), 'value_sum' => isset($values['sum']) ? $values['sum'] : '', 'lang_reserve_remainder' => lang('reserve remainder'), 'value_reserve_remainder' => isset($reserve_remainder) ? $reserve_remainder : '', 'value_reserve_remainder_percent' => isset($remainder_percent) ? $remainder_percent : '', 'location_data' => $location_data, 'location_type' => 'form', 'form_action' => $GLOBALS['phpgw']->link('/index.php', $link_data), 'done_action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uiproject.index')), 'lang_year' => lang('Year'), 'lang_category' => lang('category'), 'lang_save' => lang('save'), 'lang_done' => lang('done'), 'lang_name' => lang('Name'), 'lang_project_id' => lang('Project ID'), 'value_project_id' => isset($id) ? $id : '', 'project_group_data' => $project_group_data, 'value_name' => isset($values['name']) ? $values['name'] : '', 'lang_name_statustext' => lang('Enter Project Name'), 'lang_other_branch' => lang('Other branch'), 'lang_other_branch_statustext' => lang('Enter other branch if not found in the list'), 'value_other_branch' => isset($values['other_branch']) ? $values['other_branch'] : '', 'lang_descr_statustext' => lang('Enter a description of the project'), 'lang_descr' => lang('Description'), 'value_descr' => isset($values['descr']) ? $values['descr'] : '', 'lang_remark_statustext' => lang('Enter a remark to add to the history of the project'), 'lang_remark' => lang('remark'), 'value_remark' => isset($values['remark']) ? $values['remark'] : '', 'lang_done_statustext' => lang('Back to the list'), 'lang_save_statustext' => lang('Save the project'), 'lang_no_cat' => lang('Select category'), 'value_cat_id' => isset($values['cat_id']) ? $values['cat_id'] : '', 'cat_select' => $this->cats->formatted_xslt_list(array('select_name' => 'values[cat_id]', 'selected' => $values['cat_id'])), 'lang_workorder_id' => lang('Workorder ID'), 'lang_sum' => lang('Sum'), 'value_remainder' => $value_remainder, 'lang_remainder' => lang('remainder'), 'lang_coordinator' => lang('Coordinator'), 'lang_user_statustext' => lang('Select the coordinator the project belongs to. To do not use a category select NO USER'), 'select_user_name' => 'values[coordinator]', 'lang_no_user' => lang('Select coordinator'), 'user_list' => $this->bocommon->get_user_list_right2('select', 4, $values['coordinator'], $this->acl_location), 'status_list' => $this->bo->select_status_list('select', $values['status']), 'status_name' => 'values[status]', 'lang_no_status' => lang('Select status'), 'lang_status' => lang('Status'), 'lang_status_statustext' => lang('What is the current status of this project ?'), 'lang_confirm_status' => lang('Confirm status'), 'lang_confirm_statustext' => lang('Confirm status to the history'), 'branch_list' => $this->bo->select_branch_p_list(isset($id) ? $id : ''), 'lang_branch' => lang('branch'), 'lang_branch_statustext' => lang('Select the branches for this project'), 'key_responsible_list' => $this->bo->select_branch_list(isset($values['key_responsible']) ? $values['key_responsible'] : ''), 'lang_no_key_responsible' => lang('Select key responsible'), 'lang_key_responsible' => lang('key responsible'), 'lang_key_responsible_statustext' => lang('Select the key responsible for this project'), 'key_fetch_list' => $this->bo->select_key_location_list(isset($values['key_fetch']) ? $values['key_fetch'] : ''), 'lang_no_key_fetch' => lang('Where to fetch the key'), 'lang_key_fetch' => lang('key fetch location'), 'lang_key_fetch_statustext' => lang('Select where to fetch the key'), 'key_deliver_list' => $this->bo->select_key_location_list(isset($values['key_deliver']) ? $values['key_deliver'] : ''), 'lang_no_key_deliver' => lang('Where to deliver the key'), 'lang_key_deliver' => lang('key deliver location'), 'lang_key_deliver_statustext' => lang('Select where to deliver the key'), 'need_approval' => $need_approval, 'lang_ask_approval' => lang('Ask for approval'), 'lang_ask_approval_statustext' => lang('Check this to send a mail to your supervisor for approval'), 'value_approval_mail_address' => $supervisor_email, 'currency' => $GLOBALS['phpgw_info']['user']['preferences']['common']['currency'], 'base_java_notify_url' => "{menuaction:'property.notify.update_data',location_id:{$location_id},location_item_id:{$id}}", 'edit_action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uiproject.edit', 'id' => $id)), 'lang_edit_statustext' => lang('Edit this entry '), 'lang_edit' => lang('Edit')); //_debug_array($data);die; if ($auto_create) { $location = explode('-', $values['location_data']['location_code']); $level = count($location); for ($i = 1; $i < $level + 1; $i++) { $values['location']["loc{$i}"] = $location[$i - 1]; } $values['street_name'] = $values['location_data']['street_name']; $values['street_number'] = $values['location_data']['street_number']; $values['location_name'] = $values['location_data']["loc{$level}_name"]; $values['extra'] = $values['p'][0]; unset($values['location_data']); unset($values['p']); $receipt = $this->bo->save($values, 'add', array()); if (!$receipt['error']) { $id = $receipt['id']; $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'property.uiworkorder.edit', 'project_id' => $id)); } } phpgwapi_yui::load_widget('dragdrop'); phpgwapi_yui::load_widget('datatable'); phpgwapi_yui::load_widget('menu'); phpgwapi_yui::load_widget('connection'); phpgwapi_yui::load_widget('loader'); phpgwapi_yui::load_widget('tabview'); phpgwapi_yui::load_widget('paginator'); phpgwapi_yui::load_widget('animation'); // $template_vars = array(); // $template_vars['datatable'] = $datatable; $GLOBALS['phpgw']->css->validate_file('datatable'); $GLOBALS['phpgw']->css->validate_file('property'); $GLOBALS['phpgw']->css->add_external_file('property/templates/base/css/property.css'); $GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/datatable/assets/skins/sam/datatable.css'); $GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/paginator/assets/skins/sam/paginator.css'); $GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/container/assets/skins/sam/container.css'); $appname = lang('project'); $GLOBALS['phpgw_info']['flags']['app_header'] = lang('property') . ' - ' . $appname . ': ' . $function_msg; $GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('edit' => $data)); $GLOBALS['phpgw']->js->validate_file('yahoo', 'project.edit', 'property'); phpgwapi_jquery::load_widget('core'); $GLOBALS['phpgw']->js->validate_file('portico', 'ajax_project_edit', 'property'); }
private function _pdf_order($id = 0, $preview = false, $show_cost = false) { if (!$this->acl_read) { $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'property.uilocation.stop', 'perm' => 1, 'acl_location' => $this->acl_location)); } $GLOBALS['phpgw_info']['flags']['noheader'] = true; $GLOBALS['phpgw_info']['flags']['nofooter'] = true; $GLOBALS['phpgw_info']['flags']['xslt_app'] = false; if (!$id) { $id = phpgw::get_var('id'); // in case of bigint $show_cost = phpgw::get_var('show_cost', 'bool'); } if (!$show_cost) { $show_cost = phpgw::get_var('show_cost', 'bool'); } $ticket = $this->bo->read_single($id, $values); if (isset($this->bo->config->config_data['invoice_acl']) && $this->bo->config->config_data['invoice_acl'] == 'dimb') { $approve_role = execMethod('property.boinvoice.check_role', $ticket['ecodimb']); $_ok = false; if ($approve_role['is_supervisor']) { $_ok = true; } else { if ($approve_role['is_budget_responsible']) { $_ok = true; } } //FIXME /* else if( $common_data['workorder']['approved'] ) { $_ok = true; } */ if (!$_ok) { phpgwapi_cache::message_set(lang('order is not approved'), 'error'); $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'property.uitts.view', 'id' => $id)); } unset($_ok); } //FIXME $content = array(); //$this->_get_order_details($common_data['content'], $show_cost); $dateformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']; $date = $GLOBALS['phpgw']->common->show_date(time(), $dateformat); set_time_limit(1800); $pdf = CreateObject('phpgwapi.pdf'); $pdf->ezSetMargins(50, 70, 50, 50); $pdf->selectFont(PHPGW_API_INC . '/pdf/fonts/Helvetica.afm'); // put a line top and bottom on all the pages $all = $pdf->openObject(); $pdf->saveState(); if (isset($this->bo->config->config_data['order_logo']) && $this->bo->config->config_data['order_logo']) { $pdf->addJpegFromFile($this->bo->config->config_data['order_logo'], 40, 800, isset($this->bo->config->config_data['order_logo_width']) && $this->bo->config->config_data['order_logo_width'] ? $this->bo->config->config_data['order_logo_width'] : 80); } $pdf->setStrokeColor(0, 0, 0, 1); $pdf->line(20, 40, 578, 40); // $pdf->line(20,820,578,820); // $pdf->addText(50,823,6,lang('order')); $pdf->addText(50, 28, 6, $this->bo->config->config_data['org_name']); $pdf->addText(300, 28, 6, $date); if ($preview) { $pdf->setColor(1, 0, 0); $pdf->addText(200, 400, 40, lang('DRAFT'), -10); $pdf->setColor(1, 0, 0); } $pdf->restoreState(); $pdf->closeObject(); // note that object can be told to appear on just odd or even pages by changing 'all' to 'odd' // or 'even'. $pdf->addObject($all, 'all'); // $pdf->ezSetDy(-100); $pdf->ezStartPageNumbers(500, 28, 6, 'right', '{PAGENUM} ' . lang('of') . ' {TOTALPAGENUM}', 1); $data = array(array('col1' => "{$this->bo->config->config_data['org_name']}\n\nOrg.nr: {$this->bo->config->config_data['org_unit_id']}", 'col2' => lang('Order'), 'col3' => lang('order id') . "\n\n{$ticket['order_id']}")); $pdf->ezTable($data, array('col1' => '', 'col2' => '', 'col3' => ''), '', array('showHeadings' => 0, 'shaded' => 0, 'xPos' => 0, 'xOrientation' => 'right', 'width' => 500, 'gridlines' => EZ_GRIDLINE_ALL, 'cols' => array('col1' => array('justification' => 'right', 'width' => 200, 'justification' => 'left'), 'col2' => array('justification' => 'right', 'width' => 100, 'justification' => 'center'), 'col3' => array('justification' => 'right', 'width' => 200)))); $delivery_address = lang('delivery address') . ':'; if (isset($this->bo->config->config_data['delivery_address']) && $this->bo->config->config_data['delivery_address']) { $delivery_address .= "\n{$this->bo->config->config_data['delivery_address']}"; } else { $location_code = $ticket['location_data']['location_code']; $address_element = execMethod('property.botts.get_address_element', $location_code); foreach ($address_element as $entry) { $delivery_address .= "\n{$entry['text']}: {$entry['value']}"; } } $invoice_address = lang('invoice address') . ":\n{$this->bo->config->config_data['invoice_address']}"; $GLOBALS['phpgw']->preferences->set_account_id($common_data['workorder']['user_id'], true); $on_behalf_of_assigned = phpgw::get_var('on_behalf_of_assigned', 'bool'); if ($on_behalf_of_assigned && isset($ticket['assignedto_name'])) { $from_name = $ticket['assignedto_name']; $GLOBALS['phpgw']->preferences->set_account_id($ticket['assignedto'], true); $GLOBALS['phpgw_info']['user']['preferences'] = $GLOBALS['phpgw']->preferences->data; } else { $from_name = $GLOBALS['phpgw_info']['user']['fullname']; } $from = lang('date') . ": {$date}\n"; $from .= lang('dimb') . ": {$ticket['ecodimb']}\n"; $from .= lang('from') . ":\n {$from_name}"; $from .= "\n {$GLOBALS['phpgw']->preferences->data['property']['email']}"; $from .= "\n {$GLOBALS['phpgw']->preferences->data['property']['cellphone']}"; if (isset($ticket['vendor_id']) && $ticket['vendor_id']) { $contacts = CreateObject('property.sogeneric'); $contacts->get_location_info('vendor', false); $custom = createObject('property.custom_fields'); $vendor_data['attributes'] = $custom->find('property', '.vendor', 0, '', 'ASC', 'attrib_sort', true, true); $vendor_data = $contacts->read_single(array('id' => $ticket['vendor_id']), $vendor_data); if (is_array($vendor_data)) { foreach ($vendor_data['attributes'] as $attribute) { if ($attribute['name'] == 'org_name') { $ticket['vendor_name'] = $attribute['value']; break; } } } unset($contacts); } $data = array(array('col1' => lang('vendor') . ":\n{$ticket['vendor_name']}", 'col2' => $delivery_address), array('col1' => $from, 'col2' => $invoice_address)); $pdf->ezTable($data, array('col1' => '', 'col2' => ''), '', array('showHeadings' => 0, 'shaded' => 0, 'xPos' => 0, 'xOrientation' => 'right', 'width' => 500, 'gridlines' => EZ_GRIDLINE_ALL, 'cols' => array('col1' => array('justification' => 'right', 'width' => 250, 'justification' => 'left'), 'col2' => array('justification' => 'right', 'width' => 250, 'justification' => 'left')))); $pdf->ezSetDy(-10); $pdf->selectFont(PHPGW_API_INC . '/pdf/fonts/Helvetica-Bold.afm'); $pdf->ezText(lang('descr') . ':', 20); $pdf->selectFont(PHPGW_API_INC . '/pdf/fonts/Helvetica.afm'); $ressursnr = $GLOBALS['phpgw_info']['user']['preferences']['property']['ressursnr']; $contact_data = $this->bocommon->initiate_ui_contact_lookup(array('contact_id' => $ticket['contact_id'], 'field' => 'contact', 'type' => 'form')); if (isset($contact_data['value_contact_name']) && $contact_data['value_contact_name']) { $contact_name = ltrim($contact_data['value_contact_name']); } if (isset($contact_data['value_contact_email']) && $contact_data['value_contact_email']) { $contact_email = $contact_data['value_contact_email']; } if (isset($contact_data['value_contact_tel']) && $contact_data['value_contact_tel']) { $contact_phone = $contact_data['value_contact_tel']; } $pdf->ezText($ticket['order_descr'], 14); $pdf->ezSetDy(-20); $pdf->selectFont(PHPGW_API_INC . '/pdf/fonts/Helvetica-Bold.afm'); $pdf->ezText('Kontakt på bygget:', 14); $pdf->selectFont(PHPGW_API_INC . '/pdf/fonts/Helvetica.afm'); $pdf->ezText($contact_name, 14); $pdf->ezText($contact_email, 14); $pdf->ezText($contact_phone, 14); $pdf->ezSetDy(-20); $pdf->selectFont(PHPGW_API_INC . '/pdf/fonts/Helvetica-Bold.afm'); $pdf->ezText("Faktura må merkes med ordrenummer: {$ticket['order_id']} og ressursnr.:{$ressursnr}", 14); $pdf->selectFont(PHPGW_API_INC . '/pdf/fonts/Helvetica.afm'); if ($content) { $pdf->ezSetDy(-20); $pdf->ezTable($content, '', lang('details'), array('xPos' => 0, 'xOrientation' => 'right', 'width' => 500, 0, 'shaded' => 0, 'fontSize' => 8, 'gridlines' => EZ_GRIDLINE_ALL, 'titleFontSize' => 12, 'outerLineThickness' => 2, 'cols' => array(lang('bill per unit') => array('justification' => 'right', 'width' => 50), lang('quantity') => array('justification' => 'right', 'width' => 50), lang('cost') => array('justification' => 'right', 'width' => 50), lang('unit') => array('width' => 40), lang('descr') => array('width' => 120)))); } if (isset($this->bo->config->config_data['order_footer_header']) && $this->bo->config->config_data['order_footer_header']) { if (!$content) { $pdf->ezSetDy(-100); } $pdf->ezText($this->bo->config->config_data['order_footer_header'], 12); $pdf->ezText($this->bo->config->config_data['order_footer'], 10); } $document = $pdf->ezOutput(); if ($preview) { $pdf->print_pdf($document, "order_{$ticket['order_id']}"); } else { return $document; } }
function edit($view = '') { $get_history = phpgw::get_var('get_history', 'bool', 'POST'); $change_type = phpgw::get_var('change_type', 'int', 'POST'); $lookup_tenant = phpgw::get_var('lookup_tenant', 'bool'); $location_code = phpgw::get_var('location_code'); $sibling = phpgw::get_var('sibling'); $parent = phpgw::get_var('parent'); $values_attribute = phpgw::get_var('values_attribute'); $location = explode('-', $location_code); $error_id = false; if ($sibling) { $parent = array(); $sibling = explode('-', $sibling); $this->type_id = count($sibling); for ($i = 0; $i < count($sibling) - 1; $i++) { $parent[] = $sibling[$i]; } $parent = implode('-', $parent); } $type_id = $this->type_id; if ($location_code) { $type_id = count($location); } if ($type_id && !$lookup_tenant) { $GLOBALS['phpgw_info']['flags']['menu_selection'] .= "::loc_{$type_id}"; } else { $GLOBALS['phpgw_info']['flags']['menu_selection'] .= '::tenant'; } if ($view) { if (!$this->acl_read) { $this->bocommon->no_access(); return; } $mode = 'view'; } else { if (!$this->acl_add && !$this->acl_edit) { $this->bocommon->no_access(); return; } $mode = 'edit'; } $values = array(); if (isset($_POST['save']) && !$view) { $insert_record = $GLOBALS['phpgw']->session->appsession('insert_record', 'property'); $GLOBALS['phpgw']->session->appsession('insert_record', 'property', ''); if (isset($insert_record['location']) && is_array($insert_record['location'])) { for ($i = 0; $i < count($insert_record['location']); $i++) { $values[$insert_record['location'][$i]] = phpgw::get_var($insert_record['location'][$i], 'string', 'POST'); } } $insert_record_attributes = $GLOBALS['phpgw']->session->appsession('insert_record_values' . '.location.' . $this->type_id, 'property'); if (is_array($insert_record_attributes)) { foreach ($insert_record_attributes as $attribute) { foreach ($values_attribute as &$attr) { if ($attr['name'] == $attribute) { $attr['value'] = phpgw::get_var($attribute, 'string', 'POST'); } } } } if (isset($insert_record['extra']) && is_array($insert_record['extra'])) { for ($i = 0; $i < count($insert_record['extra']); $i++) { $values[$insert_record['extra'][$i]] = phpgw::get_var($insert_record['extra'][$i], 'string', 'POST'); } } } $GLOBALS['phpgw']->xslttpl->add_file(array('location', 'attributes_form')); if ($values) { for ($i = 1; $i < $type_id + 1; $i++) { if (!$values["loc{$i}"] && (!isset($location[$i - 1]) || !$location[$i - 1]) || !$values["loc{$i}"]) { $receipt['error'][] = array('msg' => lang('Please select a location %1 ID !', $i)); $error_id = true; } $values['location_code'][] = $values["loc{$i}"]; if ($i < $type_id) { $location_parent[] = $values["loc{$i}"]; } } if (!$values['cat_id']) { $receipt['error'][] = array('msg' => lang('Please select a category')); } if (isset($values_attribute) && is_array($values_attribute)) { foreach ($values_attribute as $attribute) { if ($attribute['nullable'] != 1 && !$attribute['value']) { $receipt['error'][] = array('msg' => lang('Please enter value for attribute %1', $attribute['input_text'])); } if ($attribute['datatype'] == 'I' && isset($attribute['value']) && $attribute['value'] && !ctype_digit($attribute['value'])) { $receipt['error'][] = array('msg' => lang('Please enter integer for attribute %1', $attribute['input_text'])); } } } if (isset($insert_record['extra']) && array_search('street_id', $insert_record['extra']) && (!isset($values['street_id']) || !$values['street_id'])) { $receipt['error'][] = array('msg' => lang('Please select a street')); } if (isset($insert_record['extra']) && array_search('part_of_town_id', $insert_record['extra']) && (!isset($values['part_of_town_id']) || !$values['part_of_town_id'])) { $receipt['error'][] = array('msg' => lang('Please select a part of town')); } if (isset($insert_record['extra']) && array_search('owner_id', $insert_record['extra']) && (!isset($values['owner_id']) || !$values['owner_id'])) { $receipt['error'][] = array('msg' => lang('Please select an owner')); } $values['location_code'] = implode("-", $values['location_code']); if ($values['location_code'] && !$location_code) { if ($this->bo->check_location($values['location_code'], $type_id)) { $receipt['error'][] = array('msg' => lang('This location is already registered!') . '[ ' . $values['location_code'] . ' ]'); $error_location_id = true; $error_id = true; } } if ($location_code) { $action = 'edit'; $values['change_type'] = $change_type; if (!$values['change_type']) { $receipt['error'][] = array('msg' => lang('Please select change type')); } } if (!isset($receipt['error'])) { $receipt = $this->bo->save($values, $values_attribute, $action, $type_id, isset($location_parent) ? $location_parent : ''); $error_id = isset($receipt['location_code']) && $receipt['location_code'] ? false : true; $location_code = $receipt['location_code']; } else { if (isset($location_parent) && $location_parent) { $location_code_parent = implode('-', $location_parent); $values = $this->bo->read_single($location_code_parent); $values['attributes'] = $this->bo->find_attribute(".location.{$this->type_id}"); $values = $this->bo->prepare_attribute($values, ".location.{$this->type_id}"); /* restore date from posting */ if (isset($insert_record['extra']) && is_array($insert_record['extra'])) { for ($i = 0; $i < count($insert_record['extra']); $i++) { $values[$insert_record['extra'][$i]] = phpgw::get_var($insert_record['extra'][$i], 'string', 'POST'); } } } } } if (!$error_id && $location_code) { $values = $this->bo->read_single($location_code, array('tenant_id' => 'lookup')); $check_history = $this->bo->check_history($location_code); if ($get_history) { $history = $this->bo->get_history($location_code); $uicols = $this->bo->uicols; $j = 0; if (isset($history) && is_array($history)) { foreach ($history as $entry) { $k = 0; for ($i = 0; $i < count($uicols['name']); $i++) { if ($uicols['input_type'][$i] != 'hidden') { $content[$j]['row'][$k]['value'] = $entry[$uicols['name'][$i]]; $content[$j]['row'][$k]['name'] = $uicols['name'][$i]; } $content[$j]['hidden'][$k]['value'] = $entry[$uicols['name'][$i]]; $content[$j]['hidden'][$k]['name'] = $uicols['name'][$i]; $k++; } $j++; } } $uicols_count = count($uicols['descr']); for ($i = 0; $i < $uicols_count; $i++) { if ($uicols['input_type'][$i] != 'hidden') { $table_header[$i]['header'] = $uicols['descr'][$i]; $table_header[$i]['width'] = '5%'; $table_header[$i]['align'] = 'center'; } } } } /* Preserve attribute values from post */ if (isset($receipt['error']) && (isset($values_attribute) && is_array($values_attribute))) { $values = $this->bocommon->preserve_attribute_values($values, $values_attribute); unset($values['location_code']); } if (!$values) { $values['attributes'] = $this->bo->find_attribute(".location.{$this->type_id}"); $values = $this->bo->prepare_attribute($values, ".location.{$this->type_id}"); } if ($values['cat_id']) { $this->cat_id = $values['cat_id']; } $link_data = array('menuaction' => $view ? 'property.uilocation.view' : 'property.uilocation.edit', 'location_code' => $location_code, 'type_id' => $type_id, 'lookup_tenant' => $lookup_tenant); $lookup_type = $view ? 'view' : 'form'; if (!$location_code && $parent) { $_values = $this->bo->read_single($parent, array('noattrib' => true)); $_values['attributes'] = $values['attributes']; } else { $_values = $values; } $location_data = $this->bo->initiate_ui_location(array('values' => $_values, 'type_id' => $type_id - 1, 'no_link' => $type_id, 'tenant' => false, 'lookup_type' => $lookup_type)); unset($_values); $location_types = $this->bo->location_types; $config = $this->bo->config; if ($location_code) { $function_msg = lang('edit'); } else { $function_msg = lang('add'); } $function_msg .= ' ' . $location_types[$type_id - 1]['name']; $insert_record = $GLOBALS['phpgw']->session->appsession('insert_record', 'property'); if (!is_array($insert_record)) { $insert_record = array(); } $j = 0; $additional_fields[$j]['input_text'] = $location_types[$type_id - 1]['name']; $additional_fields[$j]['statustext'] = $location_types[$type_id - 1]['descr']; $additional_fields[$j]['datatype'] = 'varchar'; $additional_fields[$j]['input_name'] = 'loc' . $type_id; $additional_fields[$j]['name'] = 'loc' . $type_id; $additional_fields[$j]['value'] = isset($values[$additional_fields[$j]['input_name']]) ? $values[$additional_fields[$j]['input_name']] : ''; $additional_fields[$j]['class'] = 'th_text'; $insert_record['extra'][] = $additional_fields[$j]['input_name']; $j++; $additional_fields[$j]['input_text'] = lang('name'); $additional_fields[$j]['statustext'] = lang('enter the name for this location'); $additional_fields[$j]['datatype'] = 'varchar'; $additional_fields[$j]['input_name'] = 'loc' . $type_id . '_name'; $additional_fields[$j]['name'] = 'loc' . $type_id . '_name'; $additional_fields[$j]['value'] = isset($values[$additional_fields[$j]['input_name']]) ? $values[$additional_fields[$j]['input_name']] : ''; $additional_fields[$j]['size'] = $additional_fields[$j]['value'] ? strlen($additional_fields[$j]['value']) + 5 : 30; $insert_record['extra'][] = $additional_fields[$j]['input_name']; $j++; //_debug_array($attributes_values); $_config = CreateObject('phpgwapi.config', 'property'); $_config->read(); $insert_record['extra'][] = 'cat_id'; $config_count = count($config); for ($j = 0; $j < $config_count; $j++) { if ($config[$j]['location_type'] == $type_id) { if ($config[$j]['column_name'] == 'street_id') { $edit_street = true; $insert_record['extra'][] = 'street_id'; $insert_record['extra'][] = 'street_number'; } if ($config[$j]['column_name'] == 'tenant_id') { if (!isset($_config->config_data['suppress_tenant']) || !$_config->config_data['suppress_tenant']) { $edit_tenant = true; $insert_record['extra'][] = 'tenant_id'; } } if ($config[$j]['column_name'] == 'part_of_town_id') { $edit_part_of_town = true; $select_name_part_of_town = 'part_of_town_id'; $part_of_town_list = $this->bocommon->select_part_of_town('select', $values['part_of_town_id']); $lang_town_statustext = lang('Select the part of town the property belongs to. To do not use a part of town - select NO PART OF TOWN'); $insert_record['extra'][] = 'part_of_town_id'; } if ($config[$j]['column_name'] == 'owner_id') { $edit_owner = true; $lang_owner = lang('Owner'); $owner_list = $this->bo->get_owner_list('', $values['owner_id']); $lang_select_owner = lang('Select owner'); $lang_owner_statustext = lang('Select the owner'); $insert_record['extra'][] = 'owner_id'; } } } $GLOBALS['phpgw']->session->appsession('insert_record', 'property', $insert_record); if (isset($receipt)) { $msgbox_data = $this->bocommon->msgbox_data($receipt); } if ($location_code) { $change_type_list = $this->bo->select_change_type($values['change_type']); $location_types = $this->soadmin_location->read(array('order' => 'id', 'sort' => 'ASC')); foreach ($location_types as $location_type) { if ($type_id != $location_type['id']) { if ($type_id > $location_type['id']) { $entities_link[] = array('entity_link' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => "property.uilocation.{$mode}", 'location_code' => implode('-', array_slice($location, 0, $location_type['id'])))), 'lang_entity_statustext' => $location_type['descr'], 'text_entity' => '<- ' . $location_type['name']); } else { $_location_code = implode('-', array_slice($location, 0, $location_type['id'])); $marker = str_repeat('-', $location_type['id'] - $type_id); $entities_link[] = array('entity_link' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uilocation.index', 'type_id' => $location_type['id'], 'query' => $_location_code, 'location_code' => $_location_code)), 'lang_entity_statustext' => $location_type['descr'], 'text_entity' => "{$marker}> " . $location_type['name']); unset($_location_code); } } } } phpgwapi_yui::tabview_setup('location_edit_tabview'); $tabs = array(); $tabs['general'] = array('label' => $location_types[$type_id - 1]['name'], 'link' => '#general'); if (isset($values['attributes']) && is_array($values['attributes'])) { foreach ($values['attributes'] as &$attribute) { if ($attribute['history'] == true) { $link_history_data = array('menuaction' => 'property.uilocation.attrib_history', 'entity_id' => $this->entity_id, 'cat_id' => $this->cat_id, 'attrib_id' => $attribute['id'], 'id' => $id, 'edit' => true); $attribute['link_history'] = $GLOBALS['phpgw']->link('/index.php', $link_history_data); } } $location = ".location.{$type_id}"; $attributes_groups = $this->bo->get_attribute_groups($location, $values['attributes']); // _debug_array($attributes_groups);die(); $attributes_general = array(); $attributes = array(); foreach ($attributes_groups as $group) { if (isset($group['attributes']) && isset($group['group_sort'])) { $tabs[str_replace(' ', '_', $group['name'])] = array('label' => $group['name'], 'link' => '#' . str_replace(' ', '_', $group['name'])); $group['link'] = str_replace(' ', '_', $group['name']); $attributes[] = $group; } else { if (isset($group['attributes']) && !isset($group['group_sort'])) { $attributes_general = array_merge($attributes_general, $group['attributes']); } } } unset($attributes_groups); } $documents = array(); $file_tree = array(); $integration = array(); if ($location_code) { $_role_criteria = array('type' => 'responsibility_role', 'filter' => array('location_level' => $type_id), 'order' => 'name'); $roles = execMethod('property.sogeneric.get_list', $_role_criteria); $soresponsible = CreateObject('property.soresponsible'); $contacts = createObject('phpgwapi.contacts'); foreach ($roles as &$role) { $responsible_item = $soresponsible->get_active_responsible_at_location($location_code, $role['id']); $role['responsibility_contact'] = $contacts->get_name_of_person_id($responsible_item['contact_id']); $responsibility = $soresponsible->read_single_contact($responsible_item['id']); $role['responsibility_name'] = $responsibility['responsibility_name']; } if ($roles) { $tabs['roles'] = array('label' => lang('contacts'), 'link' => '#roles'); } //_debug_array($roles);die(); $location_arr = explode('-', $location_code); //_debug_array($location_arr);die(); $related = array(); $_location_level_arr = array(); foreach ($location_arr as $_location_level) { $_exact = $location_code == $_location_level ? false : true; $_location_level_arr[] = $_location_level; $location_level = implode('-', $_location_level_arr); $related[$location_level] = $this->bo->read_entity_to_link($location_level, $_exact); } //_debug_array($related);die(); $location_type_info = $this->soadmin_location->read_single($type_id); $documents = array(); if ($location_type_info['list_documents']) { $document = CreateObject('property.sodocument'); $documents = $document->get_files_at_location(array('location_code' => $location_code)); } if ($documents) { $tabs['document'] = array('label' => lang('document'), 'link' => '#document'); $documents = json_encode($documents); } $_dirname = ''; $_files_maxlevel = 0; if (isset($_config->config_data['external_files_maxlevel']) && $_config->config_data['external_files_maxlevel']) { $_files_maxlevel = $_config->config_data['external_files_maxlevel']; } $_files_filterlevel = 0; if (isset($_config->config_data['external_files_filterlevel']) && $_config->config_data['external_files_filterlevel']) { $_files_filterlevel = $_config->config_data['external_files_filterlevel']; } $_filter_info = explode('-', $location_code); if (isset($_config->config_data['external_files']) && $_config->config_data['external_files']) { $_dirname = $_config->config_data['external_files']; $file_tree = $document->read_file_tree($_dirname, $_files_maxlevel, $_files_filterlevel, $_filter_info[0]); } unset($_config); if ($file_tree) { $tabs['file_tree'] = array('label' => lang('Files'), 'link' => '#file_tree'); $file_tree = json_encode($file_tree); } $_related = array(); foreach ($related as $_location_level => $related_info) { if (isset($related_info['related'])) { foreach ($related_info as $related_key => $related_data) { if ($related_key == 'gab') { foreach ($related_data as $entry) { $entities_link[] = array('entity_link' => $entry['entity_link'], 'lang_entity_statustext' => $entry['descr'], 'text_entity' => $entry['name']); } } else { foreach ($related_data as $entry) { $_related[] = array('where' => $_location_level, 'url' => "<a href=\"{$entry['entity_link']}\" > {$entry['name']}</a>"); } } } } } $related_link = $_related ? true : false; $tabs['related'] = array('label' => lang('related'), 'link' => '#related'); $datavalues = array(); $myColumnDefs = array(); $datavalues[0] = array('name' => "0", 'values' => json_encode($_related), 'total_records' => count($_related), 'edit_action' => "''", 'is_paginator' => 0, 'footer' => 0); $myColumnDefs[0] = array('name' => "0", 'values' => json_encode(array(array('key' => 'where', 'label' => lang('where'), 'sortable' => false, 'resizeable' => true), array('key' => 'url', 'label' => lang('what'), 'sortable' => false, 'resizeable' => true)))); // ---- START INTEGRATION ------------------------- $location_id = $GLOBALS['phpgw']->locations->get_id('property', $this->acl_location); $custom_config = CreateObject('admin.soconfig', $location_id); $_config = isset($custom_config->config_data) && $custom_config->config_data ? $custom_config->config_data : array(); //_debug_array($custom_config->config_data);die(); // required settings: /* integration_tab integration_height integration_url integration_parametres integration_action integration_action_view integration_action_edit integration_auth_key_name integration_auth_url integration_auth_hash_name integration_auth_hash_value integration_location_data */ foreach ($_config as $_config_section => $_config_section_data) { if (isset($_config_section_data['tab'])) { if (!isset($_config_section_data['url'])) { phpgwapi_cache::message_set("'url' is a required setting for integrations, '{$_config_section}' is disabled", 'error'); break; } //get session key from remote system $arguments = array($_config_section_data['auth_hash_name'] => $_config_section_data['auth_hash_value']); $query = http_build_query($arguments); $auth_url = $_config_section_data['auth_url']; $request = "{$auth_url}?{$query}"; $aContext = array('http' => array('request_fulluri' => true)); if (isset($GLOBALS['phpgw_info']['server']['httpproxy_server'])) { $aContext['http']['proxy'] = "{$GLOBALS['phpgw_info']['server']['httpproxy_server']}:{$GLOBALS['phpgw_info']['server']['httpproxy_port']}"; } $cxContext = stream_context_create($aContext); $response = trim(file_get_contents($request, False, $cxContext)); $_config_section_name = str_replace(' ', '_', $_config_section); $integration[] = array('section' => $_config_section_name, 'height' => isset($_config_section_data['height']) && $_config_section_data['height'] ? $_config_section_data['height'] : 500); $_config_section_data['url'] = htmlspecialchars_decode($_config_section_data['url']); $_config_section_data['parametres'] = htmlspecialchars_decode($_config_section_data['parametres']); /* * 'parametres' In the form: * <targetparameter1>=__<attrbute_name1>__&<targetparameter2>=__<attrbute_name2>__& * Example: objId=__id__&lon=__posisjon_lengde__&lat=__posisjon_bredde__ */ parse_str($_config_section_data['parametres'], $output); $_values = array(); foreach ($output as $_dummy => $_substitute) { $_keys[] = $_substitute; $__value = false; if (!($__value = urlencode($values[trim($_substitute, '_')]))) { foreach ($values['attributes'] as $_attribute) { if (trim($_substitute, '_') == $_attribute['name']) { $__value = urlencode($_attribute['value']); break; } } } if ($__value) { $_values[] = $__value; } } //_debug_array($_config_section_data['parametres']); //_debug_array($_values); unset($output); unset($__value); $_sep = '?'; if (stripos($_config_section_data['url'], '?')) { $_sep = '&'; } $_param = $_config_section_data['parametres'] ? $_sep . str_replace($_keys, $_values, $_config_section_data['parametres']) : ''; unset($_keys); unset($_values); // $integration_src = phpgw::safe_redirect("{$_config_section_data['url']}{$_sep}{$_param}"); $integration_src = "{$_config_section_data['url']}{$_param}"; if ($_config_section_data['action']) { $_sep = '?'; if (stripos($integration_src, '?')) { $_sep = '&'; } //$integration_src .= "{$_sep}{$_config_section_data['action']}=" . $_config_section_data["action_{$mode}"]; } $arguments = array($_config_section_data['auth_key_name'] => $response); //in the form: sakstittel=__loc1__.__loc4__ if (isset($_config_section_data['location_data']) && $_config_section_data['location_data']) { $_config_section_data['location_data'] = htmlspecialchars_decode($_config_section_data['location_data']); parse_str($_config_section_data['location_data'], $output); foreach ($output as $_dummy => $_substitute) { //$_substitute = '__loc1__.__loc4__%'; $regex = "/__([\\w]+)__/"; preg_match_all($regex, $_substitute, $matches); foreach ($matches[1] as $__substitute) { $_values[] = urlencode($values[$__substitute]); } } //FIXME $integration_src .= $_config_section_data['url_separator'] . str_replace($matches[0], $_values, $_config_section_data['location_data']); } if (isset($_config_section_data['auth_key_name']) && $_config_section_data['auth_key_name']) { $integration_src .= "&{$_config_section_data['auth_key_name']}={$response}"; } //FIXME NOT WORKING!! test for webservice, auth... if (isset($_config_section_data['method']) && $_config_section_data['method'] == 'POST') { $aContext = array('http' => array('method' => 'POST', 'request_fulluri' => true)); if (isset($GLOBALS['phpgw_info']['server']['httpproxy_server'])) { $aContext['http']['proxy'] = "{$GLOBALS['phpgw_info']['server']['httpproxy_server']}:{$GLOBALS['phpgw_info']['server']['httpproxy_port']}"; } $cxContext = stream_context_create($aContext); $response = trim(file_get_contents($integration_src, False, $cxContext)); } //_debug_array($values); //_debug_array($integration_src);die(); $tabs[$_config_section] = array('label' => $_config_section_data['tab'], 'link' => "#{$_config_section_name}", 'function' => "document.getElementById('{$_config_section_name}_content').src = '{$integration_src}';"); } } // ---- END INTEGRATION ------------------------- } unset($values['attributes']); $property_js = "/property/js/yahoo/property2.js"; if (!isset($GLOBALS['phpgw_info']['server']['no_jscombine']) || !$GLOBALS['phpgw_info']['server']['no_jscombine']) { $cachedir = urlencode($GLOBALS['phpgw_info']['server']['temp_dir']); $property_js = "/phpgwapi/inc/combine.php?cachedir={$cachedir}&type=javascript&files=" . str_replace('/', '--', ltrim($property_js, '/')); } $data = array('property_js' => json_encode($GLOBALS['phpgw_info']['server']['webserver_url'] . $property_js), 'datatable' => $datavalues, 'myColumnDefs' => $myColumnDefs, 'integration' => $integration, 'roles' => $roles, 'edit' => $view ? '' : true, 'lang_change_type' => lang('Change type'), 'lang_no_change_type' => lang('No Change type'), 'lang_change_type_statustext' => lang('Type of changes'), 'change_type_list' => isset($change_type_list) ? $change_type_list : '', 'check_history' => isset($check_history) ? $check_history : '', 'lang_history' => lang('History'), 'lang_history_statustext' => lang('Fetch the history for this item'), 'table_header' => isset($table_header) ? $table_header : '', 'values' => isset($content) ? $content : '', 'lang_related_info' => lang('related info'), 'entities_link' => isset($entities_link) ? $entities_link : '', 'related_link' => $related_link, 'edit_street' => isset($edit_street) ? $edit_street : '', 'edit_tenant' => isset($edit_tenant) ? $edit_tenant : '', 'edit_part_of_town' => isset($edit_part_of_town) ? $edit_part_of_town : '', 'edit_owner' => isset($edit_owner) ? $edit_owner : '', 'select_name_part_of_town' => isset($select_name_part_of_town) ? $select_name_part_of_town : '', 'part_of_town_list' => isset($part_of_town_list) ? $part_of_town_list : '', 'lang_town_statustext' => isset($lang_town_statustext) ? $lang_town_statustext : '', 'lang_part_of_town' => lang('Part of town'), 'lang_no_part_of_town' => lang('No part of town'), 'lang_owner' => isset($lang_owner) ? $lang_owner : '', 'owner_list' => isset($owner_list) ? $owner_list : '', 'lang_select_owner' => isset($lang_select_owner) ? $lang_select_owner : '', 'lang_owner_statustext' => isset($lang_owner_statustext) ? $lang_owner_statustext : '', 'additional_fields' => $additional_fields, 'attributes_group' => $attributes, 'attributes_general' => array('attributes' => $attributes_general), 'lookup_functions' => isset($values['lookup_functions']) ? $values['lookup_functions'] : '', 'lang_none' => lang('None'), 'msgbox_data' => isset($msgbox_data) ? $GLOBALS['phpgw']->common->msgbox($msgbox_data) : '', 'street_link' => "menuaction:'" . 'property' . ".uilookup.street'", 'lang_street' => lang('Address'), 'lang_select_street_help' => lang('Select the street name'), 'lang_street_num_statustext' => lang('Enter the street number'), 'value_street_id' => isset($values['street_id']) ? $values['street_id'] : '', 'value_street_name' => isset($values['street_name']) ? $values['street_name'] : '', 'value_street_number' => isset($values['street_number']) ? $values['street_number'] : '', 'tenant_link' => "menuaction:'" . 'property' . ".uilookup.tenant'", 'lang_tenant' => lang('tenant'), 'value_tenant_id' => isset($values['tenant_id']) ? $values['tenant_id'] : '', 'value_last_name' => isset($values['last_name']) ? $values['last_name'] : '', 'value_first_name' => isset($values['first_name']) ? $values['first_name'] : '', 'lang_tenant_statustext' => lang('Select a tenant'), 'size_last_name' => isset($values['last_name']) ? strlen($values['last_name']) : '', 'size_first_name' => isset($values['first_name']) ? strlen($values['first_name']) : '', 'lookup_type' => $lookup_type, 'location_data' => $location_data, 'form_action' => $GLOBALS['phpgw']->link('/index.php', $link_data), 'done_action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uilocation.index', 'type_id' => $type_id, 'lookup_tenant' => $lookup_tenant)), 'lang_save' => lang('save'), 'lang_done' => lang('done'), 'lang_done_statustext' => lang('Back to the list'), 'lang_save_statustext' => lang('Save the location'), 'lang_category' => lang('category'), 'lang_no_cat' => lang('no category'), 'lang_cat_statustext' => lang('Select the category the location belongs to. To do not use a category select NO CATEGORY'), 'select_name' => 'cat_id', 'cat_list' => $this->bocommon->select_category_list(array('format' => 'select', 'selected' => $values['cat_id'], 'type' => 'location', 'type_id' => $type_id, 'order' => 'descr')), 'textareacols' => isset($GLOBALS['phpgw_info']['user']['preferences']['property']['textareacols']) && $GLOBALS['phpgw_info']['user']['preferences']['property']['textareacols'] ? $GLOBALS['phpgw_info']['user']['preferences']['property']['textareacols'] : 40, 'textarearows' => isset($GLOBALS['phpgw_info']['user']['preferences']['property']['textarearows']) && $GLOBALS['phpgw_info']['user']['preferences']['property']['textarearows'] ? $GLOBALS['phpgw_info']['user']['preferences']['property']['textarearows'] : 6, 'tabs' => phpgwapi_yui::tabview_generate($tabs, 'general'), 'documents' => $documents, 'file_tree' => $file_tree, 'lang_expand_all' => lang('expand all'), 'lang_collapse_all' => lang('collapse all')); $GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/examples/treeview/assets/css/folders/tree.css'); phpgwapi_yui::load_widget('dragdrop'); phpgwapi_yui::load_widget('datatable'); phpgwapi_yui::load_widget('menu'); phpgwapi_yui::load_widget('connection'); phpgwapi_yui::load_widget('loader'); phpgwapi_yui::load_widget('tabview'); phpgwapi_yui::load_widget('paginator'); phpgwapi_yui::load_widget('animation'); phpgwapi_yui::load_widget('treeview'); $GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/datatable/assets/skins/sam/datatable.css'); $GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/paginator/assets/skins/sam/paginator.css'); $GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/container/assets/skins/sam/container.css'); $GLOBALS['phpgw']->js->validate_file('yahoo', 'location.edit', 'property'); $appname = lang('location'); $GLOBALS['phpgw_info']['flags']['app_header'] = lang('property') . ' - ' . $appname . ': ' . $function_msg; $GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('edit' => $data)); }
public function login($frontend = '') { if (isset($_REQUEST['skip_remote']) && $_REQUEST['skip_remote']) { $GLOBALS['phpgw_remote_user_fallback'] = 'sql'; } if (isset($_GET['logout']) && $_GET['logout']) { $GLOBALS['phpgw_remote_user_fallback'] = 'sql'; $_REQUEST['skip_remote'] = true; } require_once dirname(realpath(__FILE__)) . '/sso/include_login.inc.php'; $lightbox = isset($_REQUEST['lightbox']) && $_REQUEST['lightbox'] ? true : false; $partial_url = "{$frontend}/login.php"; $phpgw_url_for_sso = 'phpgwapi/inc/sso/login_server.php'; if (isset($GLOBALS['phpgw_remote_user']) && !empty($GLOBALS['phpgw_remote_user'])) { $partial_url = 'phpgwapi/inc/sso/login_server.php'; } if ($frontend) { $GLOBALS['phpgw']->hooks->process('set_auth_type', array($frontend)); } if (isset($_REQUEST['skip_remote']) && $_REQUEST['skip_remote']) { $GLOBALS['phpgw_info']['server']['auth_type'] = $GLOBALS['phpgw_remote_user_fallback']; } /* Program starts here */ $uilogin = new phpgw_uilogin($tmpl, $GLOBALS['phpgw_info']['server']['auth_type'] == 'remoteuser' && !isset($GLOBALS['phpgw_remote_user'])); if ($GLOBALS['phpgw_info']['server']['auth_type'] == 'remoteuser' && isset($GLOBALS['phpgw_info']['server']['mapping']) && !empty($GLOBALS['phpgw_info']['server']['mapping']) && isset($_SERVER['REMOTE_USER'])) { $login = $GLOBALS['phpgw']->mapping->get_mapping($_SERVER['REMOTE_USER']); if ($login == '') { if (isset($GLOBALS['phpgw_info']['server']['auto_create_acct']) && $GLOBALS['phpgw_info']['server']['auto_create_acct'] == true) { // Redirection to create the new account : $GLOBALS['phpgw']->redirect_link('/phpgwapi/inc/sso/create_account.php'); } else { if ($GLOBALS['phpgw_info']['server']['mapping'] == 'table' || $GLOBALS['phpgw_info']['server']['mapping'] == 'all') { // Redirection to create a new mapping : $GLOBALS['phpgw']->redirect_link('/phpgwapi/inc/sso/create_mapping.php'); } else { if (!(isset($_GET['cd']) && $_GET['cd'] != '0')) { // An error occurs, bailed out $GLOBALS['phpgw']->redirect_link('/' . $partial_url, array('cd' => '20')); } } } } $passwd = $login; if (!(isset($_GET['cd']) && $_GET['cd'] != '0')) { $_POST['submitit'] = true; } } else { $login = phpgw::get_var('login', 'string', 'POST'); // remove entities to stop mangling $passwd = html_entity_decode(phpgw::get_var('passwd', 'string', 'POST')); } if ($GLOBALS['phpgw_info']['server']['auth_type'] == 'http' && isset($_SERVER['PHP_AUTH_USER'])) { $submit = true; $login = $_SERVER['PHP_AUTH_USER']; $passwd = $_SERVER['PHP_AUTH_PW']; } if ($GLOBALS['phpgw_info']['server']['auth_type'] == 'ntlm' && isset($_SERVER['REMOTE_USER']) && (!isset($_REQUEST['skip_remote']) || !$_REQUEST['skip_remote'])) { $login = $_SERVER['REMOTE_USER']; $passwd = ''; $GLOBALS['hook_values'] = array('account_lid' => $login); $GLOBALS['phpgw']->hooks->process('auto_addaccount', array('frontend')); //------------------Start login ntlm $GLOBALS['sessionid'] = $GLOBALS['phpgw']->session->create($login, $passwd); if (!isset($GLOBALS['sessionid']) || !$GLOBALS['sessionid']) { $cd_array = array(); if ($GLOBALS['phpgw']->session->cd_reason) { $cd_array['cd'] = $GLOBALS['phpgw']->session->cd_reason; } $cd_array['skip_remote'] = true; $GLOBALS['phpgw']->redirect_link("/{$partial_url}", $cd_array); exit; } $forward = phpgw::get_var('phpgw_forward'); if ($forward) { $extra_vars['phpgw_forward'] = $forward; foreach ($_GET as $name => $value) { if (preg_match('/phpgw_/', $name)) { $name = urlencode($name); $extra_vars[$name] = urlencode($value); } } } if (!isset($GLOBALS['phpgw_info']['server']['disable_autoload_langfiles']) || !$GLOBALS['phpgw_info']['server']['disable_autoload_langfiles']) { // $uilogin->check_langs(); } $extra_vars['cd'] = 'yes'; $GLOBALS['phpgw']->hooks->process('login'); $GLOBALS['phpgw']->redirect_link("{$frontend}/home.php", $extra_vars); //----------------- End login ntlm } # Apache + mod_ssl style SSL certificate authentication # Certificate (chain) verification occurs inside mod_ssl if ($GLOBALS['phpgw_info']['server']['auth_type'] == 'sqlssl' && isset($_SERVER['SSL_CLIENT_S_DN']) && !isset($_GET['cd'])) { # an X.509 subject looks like: # /CN=john.doe/OU=Department/O=Company/C=xx/Email=john@comapy.tld/L=City/ # the username is deliberately lowercase, to ease LDAP integration $sslattribs = explode('/', $_SERVER['SSL_CLIENT_S_DN']); # skip the part in front of the first '/' (nothing) while ($sslattrib = next($sslattribs)) { list($key, $val) = explode('=', $sslattrib); $sslattributes[$key] = $val; } if (isset($sslattributes['Email'])) { $submit = true; # login will be set here if the user logged out and uses a different username with # the same SSL-certificate. if (!isset($_POST['login']) && isset($sslattributes['Email'])) { $login = $sslattributes['Email']; # not checked against the database, but delivered to authentication module $passwd = $_SERVER['SSL_CLIENT_S_DN']; } } unset($key); unset($val); unset($sslattributes); } if ($GLOBALS['phpgw_info']['server']['auth_type'] == 'customsso' && !isset($_GET['cd'])) { //Reset auth object $GLOBALS['phpgw']->auth = createObject('phpgwapi.auth'); $login = $GLOBALS['phpgw']->auth->get_username(); $GLOBALS['sessionid'] = $GLOBALS['phpgw']->session->create($login, ''); if (!isset($GLOBALS['sessionid']) || !$GLOBALS['sessionid']) { $cd_array = array(); if ($GLOBALS['phpgw']->session->cd_reason) { $cd_array['cd'] = $GLOBALS['phpgw']->session->cd_reason; } $cd_array['skip_remote'] = true; $GLOBALS['phpgw']->redirect_link("/{$partial_url}", $cd_array); exit; } $forward = phpgw::get_var('phpgw_forward'); if ($forward) { $extra_vars['phpgw_forward'] = $forward; foreach ($_GET as $name => $value) { if (preg_match('/phpgw_/', $name)) { $name = urlencode($name); $extra_vars[$name] = urlencode($value); } } } $extra_vars['cd'] = 'yes'; $GLOBALS['phpgw']->hooks->process('login'); $GLOBALS['phpgw']->redirect_link("{$frontend}/home.php", $extra_vars); } if (isset($_POST['submitit']) || isset($_POST['submit_x']) || isset($_POST['submit_y'])) { if ($_SERVER['REQUEST_METHOD'] != 'POST' && !isset($_SERVER['PHP_AUTH_USER']) && !isset($_SERVER['REMOTE_USER']) && !isset($_SERVER['SSL_CLIENT_S_DN'])) { $GLOBALS['phpgw']->redirect_link('/' . $partial_url, array('cd' => '5')); } $logindomain = phpgw::get_var('logindomain', 'string', 'POST'); if (strstr($login, '#') === false && $logindomain) { $login .= "#{$logindomain}"; } $receipt = array(); if (isset($GLOBALS['phpgw_info']['server']['usecookies']) && $GLOBALS['phpgw_info']['server']['usecookies']) { if (isset($_COOKIE['domain']) && $_COOKIE['domain'] != $logindomain) { $GLOBALS['phpgw']->session->phpgw_setcookie('kp3'); $GLOBALS['phpgw']->session->phpgw_setcookie('domain'); // $GLOBALS['phpgw']->redirect_link("/{$partial_url}", array('cd' =>22)); // already within a session // exit; $receipt[] = lang('Info: you have changed domain from "%1" to "%2"', $_COOKIE['domain'], $logindomain); } } $GLOBALS['sessionid'] = $GLOBALS['phpgw']->session->create($login, $passwd); if (!isset($GLOBALS['sessionid']) || !$GLOBALS['sessionid']) { $cd_array = array(); if ($GLOBALS['phpgw']->session->cd_reason) { $cd_array['cd'] = $GLOBALS['phpgw']->session->cd_reason; } $cd_array['skip_remote'] = true; $cd_array['lightbox'] = $lightbox; $GLOBALS['phpgw']->redirect_link("/{$partial_url}", $cd_array); exit; } if ($receipt) { phpgwapi_cache::message_set($receipt, 'message'); } $forward = phpgw::get_var('phpgw_forward'); if ($forward) { $extra_vars['phpgw_forward'] = $forward; foreach ($_GET as $name => $value) { if (preg_match('/phpgw_/', $name)) { //$extra_vars[$name] = $value; $name = urlencode($name); $extra_vars[$name] = urlencode($value); } } } if (!isset($GLOBALS['phpgw_info']['server']['disable_autoload_langfiles']) || !$GLOBALS['phpgw_info']['server']['disable_autoload_langfiles']) { // $uilogin->check_langs(); } $extra_vars['cd'] = 'yes'; $GLOBALS['phpgw']->hooks->process('login'); if ($lightbox) { $GLOBALS['phpgw']->redirect_link("{$frontend}/login.php", array('hide_lightbox' => true)); } else { $GLOBALS['phpgw']->redirect_link("{$frontend}/home.php", $extra_vars); } } //Build vars : $variables = array(); $variables['lang_login'] = lang('login'); $variables['partial_url'] = $partial_url; $variables['lang_frontend'] = $frontend ? lang($frontend) : ''; if (isset($GLOBALS['phpgw_info']['server']['half_remote_user']) && $GLOBALS['phpgw_info']['server']['half_remote_user'] == 'remoteuser') { $variables['lang_additional_url'] = lang('use sso login'); $variables['additional_url'] = $GLOBALS['phpgw']->link('/' . $phpgw_url_for_sso); } $uilogin->phpgw_display_login($variables); }
public function bulk_update_status($start_date, $end_date, $status_filter, $status_new, $execute, $type, $user_id = 0, $ids, $paid = false, $closed_orders = false, $ecodimb = 0, $transfer_budget_year = 0, $new_budget = array(), $b_account_id = 0) { if ($transfer_budget_year && $execute && $new_budget) { // echo "<H1> Overføre budsjett for valgte prosjekt/bestillinger til år {$transfer_budget_year} </H1>"; $soworkorder = CreateObject('property.soworkorder'); foreach ($ids as $_id) { if ((int) $new_budget[$_id]['latest_year'] >= (int) $transfer_budget_year) { continue; } switch ($type) { case 'project': try { $this->transfer_budget($_id, $new_budget[$_id], $transfer_budget_year); } catch (Exception $e) { if ($e) { phpgwapi_cache::message_set($e->getMessage(), 'error'); } } break; case 'workorder': try { $soworkorder->transfer_budget($_id, $new_budget[$_id], $transfer_budget_year); } catch (Exception $e) { if ($e) { phpgwapi_cache::message_set($e->getMessage(), 'error'); } } break; default: throw new Exception('property_soproject::bulk_update_status() - not a valid type'); } } // die(); } $start_date = $start_date ? phpgwapi_datetime::date_to_timestamp($start_date) : time(); $start_date -= 3600 * 24; $end_date = $end_date ? phpgwapi_datetime::date_to_timestamp($end_date) : time(); $filter = ''; if ($user_id) { $user_id = (int) $user_id; $filter .= "AND fm_{$type}.user_id = {$user_id}"; } if ($ecodimb) { $ecodimb = (int) $ecodimb; $filter .= "AND fm_{$type}.ecodimb = {$ecodimb}"; } if ($status_filter) { if ($status_filter == 'open') { $filter .= " AND fm_{$type}_status.closed IS NULL"; } else { $filter .= " AND fm_{$type}.status='{$status_filter}' "; } } switch ($type) { case 'project': $sql_budget = "SELECT DISTINCT year, month, active, sum(budget) as amount FROM fm_project_budget WHERE "; $sql_budget .= 'project_id = %d GROUP BY year, month, active ORDER BY year'; if ($closed_orders) { $filter .= " AND fm_open_workorder_view.project_id IS NULL"; } $table = 'fm_project'; $status_table = 'fm_project_status'; $title_field = 'fm_project.name as title'; $this->_update_status_project($execute, $status_new, $ids); $sql = "SELECT DISTINCT {$table}.id,{$status_table}.closed, {$status_table}.descr as status ,{$title_field},{$table}.start_date,{$table}.project_type_id, count(project_id) as num_open FROM {$table}" . " {$this->join} {$status_table} ON {$table}.status = {$status_table}.id " . " {$this->left_join} fm_open_workorder_view ON {$table}.id = fm_open_workorder_view.project_id " . " WHERE ({$table}.start_date > {$start_date} AND {$table}.start_date < {$end_date} OR {$table}.start_date IS NULL) {$filter}" . " GROUP BY {$table}.id, {$status_table}.closed, {$status_table}.descr ,{$table}.name, {$table}.start_date,project_type_id" . " ORDER BY {$table}.id DESC"; break; case 'workorder': $sql_budget = "SELECT DISTINCT year, month, active, sum(combined_cost) as amount FROM fm_workorder_budget WHERE "; $sql_budget .= 'order_id = %d GROUP BY year, month, active ORDER BY year'; if ($b_account_id) { $filter .= " AND fm_workorder.account_id = '{$b_account_id}'"; } $table = 'fm_workorder'; $status_table = 'fm_workorder_status'; $title_field = 'fm_workorder.title'; $actual_cost = ',actual_cost'; $join_method = "{$this->join} {$status_table} ON {$table}.status = {$status_table}.id"; $join_method .= " {$this->join} fm_project ON {$table}.project_id = fm_project.id"; if ($paid) { $join_method .= " {$this->join} fm_orders_actual_cost_view ON fm_workorder.id = fm_orders_actual_cost_view.order_id"; $actual_cost = ',fm_orders_actual_cost_view.actual_cost'; $group_method = ''; } else { $start_period = date('Y') - 1 . '00'; $end_period = date('Y') - 1 . 13; $join_method .= " {$this->left_join} fm_ecobilagoverf ON ( fm_workorder.id = fm_ecobilagoverf.pmwrkord_code AND fm_ecobilagoverf.periode > {$start_period} AND fm_ecobilagoverf.periode < {$end_period})"; $actual_cost = ',sum(fm_ecobilagoverf.godkjentbelop) AS actual_cost'; $group_method = "GROUP BY fm_workorder.id, fm_workorder.project_id, fm_workorder.account_id, fm_workorder_status.closed,fm_workorder_status.descr,fm_project.project_type_id,fm_workorder.title,fm_workorder.start_date,fm_workorder.continuous"; } $this->_update_status_workorder($execute, $status_new, $ids); $sql = "SELECT {$table}.id, {$table}.project_id,{$status_table}.closed, {$table}.account_id, {$status_table}.descr as status ,{$title_field},{$table}.start_date {$actual_cost}," . " project_type_id, continuous" . " FROM {$table} {$join_method}" . " WHERE ({$table}.start_date > {$start_date} AND {$table}.start_date < {$end_date} {$filter}) OR {$table}.start_date is NULL" . " {$group_method} ORDER BY {$table}.id DESC"; break; default: return array(); } $project_types = array(1 => lang('operation'), 2 => lang('investment'), 3 => lang('buffer'), 4 => lang('maintenance')); $this->db->query($sql, __LINE__, __FILE__); $values = array(); $dateformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']; while ($this->db->next_record()) { $values[] = array('id' => $this->db->f('id'), 'project_id' => $this->db->f('project_id'), 'closed' => $this->db->f('closed'), 'title' => $this->db->f('title', true), 'status' => $this->db->f('status', true), 'actual_cost' => (double) $this->db->f('actual_cost'), 'start_date' => $GLOBALS['phpgw']->common->show_date($this->db->f('start_date'), $dateformat), 'num_open' => (int) $this->db->f('num_open'), 'project_type_id' => $this->db->f('project_type_id'), 'continuous' => $this->db->f('continuous') ? X : '', 'project_type' => $project_types[$this->db->f('project_type_id')], 'b_account_id' => $this->db->f('account_id')); } foreach ($values as &$entry) { $sql = sprintf($sql_budget, $entry['id']); $this->db->query($sql, __LINE__, __FILE__); $budget = array(); $_budget = array(); $_year = 0; $_active_amount = array(); while ($this->db->next_record()) { $_year = $this->db->f('year'); $_amount = $this->db->f('amount'); $_active = $this->db->f('active') ? X : 0; if ($_active) { $_active_amount[$_year] += $_amount; } $_budget[$_year] += $_amount; } foreach ($_budget as $__year => $__budget) { $budget[] = $__year . ' [' . number_format((int) $_active_amount[$__year], 0, ',', '.') . '/' . number_format((int) $__budget, 0, ',', '.') . ']'; } $entry['budget'] = implode(' ;', $budget); $entry['latest_year'] = $_year; $entry['active_amount'] = array_sum($_active_amount); } return $values; }
/** * Add Person Enviromet, this controls all process to add a person * * @param * @return */ function add_person() { //set some variables which will be used $this->mode = 'add'; $this->section = $this->tab_main_persons; $this->form_action = array('menuaction' => 'addressbook.uiaddressbook.add_person', 'nonavbar' => $this->nonavbar); $this->form_index = array('menuaction' => 'addressbook.uiaddressbook.index', 'section' => $this->section, 'nonavbar' => $this->nonavbar); //get all vars which was send in post or get $this->get_vars(); //check if is the first time that get into edit if ($this->firsttime) { $this->entry = ''; $this->clear_tab_session(); $this->load_tabs('cache'); } //validate if add/edit/delete functions would be run $this->managment_functions($this->action); //save the old tab data if they exists if (isset($this->entry['old_tab'])) { $this->save_tab_session(stripslashes($this->entry['old_tab']), $this->entry); } //if not exist tab selected use as defaul person_data if (!$this->tab) { $this->tab = $this->tab_person_data; } //evaluate the submit action switch ($this->submit) { case 'save': $fields = $this->get_all_entry(); if (!$fields['tab_person_data']['per_first_name'] && !$fields['tab_person_data']['per_last_name']) { $message = 'Need at least First Name or Last Name'; phpgwapi_cache::message_set($message, 'error'); break; } $fields['owner'] = $GLOBALS['phpgw_info']['user']['account_id']; $ab_id = $this->bo->add_person($fields); $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'addressbook.uiaddressbook.view_person', 'ab_id' => $ab_id, 'referer' => $this->referer, 'nonavbar' => $this->nonavbar)); $GLOBALS['phpgw']->common->phpgw_exit(); break; case 'cancel': $GLOBALS['phpgw']->redirect_link('/index.php', $this->form_index); break; case 'delete': break; case 'clear': $this->entry = ''; $this->clear_tab_session(); //$this->load_tabs(); break; } //read the current tab information $this->entry = $this->read_tab_session($this->tab); //start to draw the add window // $GLOBALS['phpgw']->common->phpgw_header(); // echo parse_navbar(); //draw the tabs and detail form $this->entry['old_tab'] = $this->tab; $this->main_form($this->entry, $this->section, $this->tab); }
function parse($parsexsl = true, $parsexml = true) { $output_header = !(isset($GLOBALS['phpgw_info']['flags']['noframework']) && $GLOBALS['phpgw_info']['flags']['noframework']); $stripped_htm = phpgw::get_var('phpgw_return_as') == 'stripped_html'; if ($this->output != 'wml' && !$stripped_htm) { $GLOBALS['phpgw']->common->phpgw_header($output_header); } if ($parsexsl) { $this->xsl_parse(); } if ($parsexml) { $this->xml_parse(); } $xml = new DOMDocument(); $xml->loadXML($this->xmldata); $xsl = new DOMDocument(); $xsl->loadXML($this->xsldata); // Configure the transformer libxml_use_internal_errors(true); $proc = new XSLTProcessor(); $proc->registerPHPFunctions(); $proc->importStyleSheet($xsl); // attach the xsl rules $html = trim($proc->transformToXML($xml)); if (!$html || $html == '<?xml version="1.0"?>') { $message = 'Systemfeil - kontakt adminstrator'; if (!isset($GLOBALS['phpgw_info']['user']['apps']['admin']) || !$GLOBALS['phpgw_info']['user']['apps']['admin']) { phpgwapi_cache::message_set($message, 'error'); } else { $message .= '<br>' . $_SERVER['SERVER_ADDR'] . $_SERVER['SCRIPT_NAME']; $message .= isset($_REQUEST['menuaction']) ? "?menuaction={$_REQUEST['menuaction']}" : ''; echo '<div class="error">'; echo $message; echo '</div>'; $errors = libxml_get_errors(); _debug_array($errors); libxml_clear_errors(); echo "<h2>xml-data</h2>"; $this->list_lineno($this->xmldata, true); echo "<h2>xsl-data</h2>"; $this->list_lineno($this->xsldata); } return ''; } switch ($this->output) { case 'wml': case 'html5': $html = preg_replace('/<\\?xml version([^>])+>/', '', $html); break; default: } $html = preg_replace('/<!DOCTYPE([^>])+>/', '', $html); return $html; }
function update_voucher() { $receipt = array(); $voucher_id = phpgw::get_var('voucher_id', 'int'); $line_id = phpgw::get_var('line_id', 'int'); if ($values = phpgw::get_var('values')) { if ($values['order_id'] != $values['order_id_orig']) { return $this->reassign_order($line_id, $values['order_id'], $voucher_id); } $cats = CreateObject('phpgwapi.categories', -1, 'property', '.project'); $cats->supress_info = true; $category = $cats->return_single((int) $values['dim_e']); if (!isset($category[0]) || $category[0]['active'] != 1) { $receipt['error'][] = true; phpgwapi_cache::message_set(lang('not a valid category'), 'error'); } if (!$this->bo->check_valid_b_account($values['b_account_id'])) { $receipt['error'][] = true; phpgwapi_cache::message_set(lang('not a valid budget account'), 'error'); } $order = execMethod('property.soworkorder.read_single', $values['order_id']); $project = execMethod('property.soproject.read_single', $order['project_id']); if ($project['closed']) { $receipt['error'][] = true; phpgwapi_cache::message_set(lang('Project is closed'), 'error'); } $approve = execMethod('property.boinvoice.get_approve_role', $values['dim_b']); if (!$approve) { $receipt['error'][] = true; phpgwapi_cache::message_set(lang('you are not approved for this task'), 'error'); } $values['voucher_id'] = $voucher_id; $values['line_id'] = $line_id; if (!$receipt['error']) { if ($this->bo->update_voucher2($values)) { $result = array('status' => 'updated'); } else { $result = array('status' => 'error'); } } } if (phpgw::get_var('phpgw_return_as') == 'json') { if ($receipt = phpgwapi_cache::session_get('phpgwapi', 'phpgw_messages')) { phpgwapi_cache::session_clear('phpgwapi', 'phpgw_messages'); $result['receipt'] = $receipt; } return $result; } else { $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'property.uiinvoice2.index', 'voucher_id' => $voucher_id, 'line_id' => $line_id)); } }
public function update_actual_cost_from_archive($orders_affected) { $soworkorder = CreateObject('property.soworkorder'); $orders = array(); if ($orders_affected) { $sql = 'SELECT order_id, actual_cost FROM fm_orders_actual_cost_view WHERE order_id IN (' . implode(',', array_keys($orders_affected)) . ')'; $this->db->query($sql, __LINE__, __FILE__); while ($this->db->next_record()) { $orders[] = array('order_id' => $this->db->f('order_id'), 'actual_cost' => $this->db->f('actual_cost')); } foreach ($orders as $order) { $this->db->query("UPDATE fm_workorder SET actual_cost = '{$order['actual_cost']}' WHERE id = '{$order['order_id']}'", __LINE__, __FILE__); $this->db->query("SELECT max(periode) AS period, max(amount) AS amount FROM fm_orders_paid_or_pending_view WHERE order_id = {$order['order_id']} AND periode IS NOT NULL", __LINE__, __FILE__); $this->db->next_record(); $period = $this->db->f('period'); $amount = $this->db->f('amount'); $year = $period ? (int) substr($period, 0, 4) : date('Y'); $this->db->query("SELECT order_id FROM fm_workorder_budget WHERE order_id = {$order['order_id']} AND year = {$year}", __LINE__, __FILE__); if (!$this->db->next_record()) { try { $soworkorder->transfer_budget($order['order_id'], array('budget_amount' => $amount, 'latest_year' => $year - 1), $year); } catch (Exception $e) { if ($e) { phpgwapi_cache::message_set($e->getMessage(), 'error'); } } } } reset($orders_affected); foreach ($orders_affected as $order_id => $dummy) { phpgwapi_cache::system_clear('property', "budget_order_{$order_id}"); // Not yet processed $this->db->query("SELECT max(amount) AS amount FROM fm_orders_paid_or_pending_view WHERE order_id = {$order_id} AND periode IS NULL", __LINE__, __FILE__); $this->db->next_record(); $amount = $this->db->f('amount'); if ($amount) { $year = date('Y'); $this->db->query("SELECT order_id FROM fm_workorder_budget WHERE order_id = {$order_id} AND year = {$year}", __LINE__, __FILE__); if (!$this->db->next_record()) { try { $soworkorder->transfer_budget($order_id, array('budget_amount' => $amount, 'latest_year' => $year - 1), $year); } catch (Exception $e) { if ($e) { phpgwapi_cache::message_set($e->getMessage(), 'error'); } } } } } } }
private function _import_calculation($workorder_id) { $error = false; $data = array(); if (isset($_FILES['file']['tmp_name']) && $_FILES['file']['tmp_name']) { $file = array('name' => $_FILES['file']['tmp_name'], 'type' => $_FILES['file']['type']); } else { phpgwapi_cache::message_set('Ingen fil er valgt', 'error'); return; } switch ($file['type']) { case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': case 'application/vnd.oasis.opendocument.spreadsheet': case 'application/vnd.ms-excel': $data = $this->getexceldata($file['name']); break; default: phpgwapi_cache::message_set("Not a valid filetype: {$file['type']}", 'error'); $error = true; } if ($data) { try { //Import $this->bo->import_calculation($data, $workorder_id); } catch (Exception $e) { if ($e) { phpgwapi_cache::message_set($e->getMessage(), 'error'); $error = true; } } } if (!$error) { phpgwapi_cache::message_set(lang('workorder is updated'), 'message'); } }
public function edit() { $user_id = phpgw::get_var('user_id', 'int'); $dimb_id = phpgw::get_var('dimb_id', 'int'); $role_id = phpgw::get_var('role_id', 'int'); $query = phpgw::get_var('query'); if ($values = phpgw::get_var('values')) { if (!$GLOBALS['phpgw']->acl->check('.admin', PHPGW_ACL_EDIT, 'property')) { $receipt['error'][] = true; phpgwapi_cache::message_set(lang('you are not approved for this task'), 'error'); } if (!$receipt['error']) { if ($this->bo->edit($values)) { $result = array('status' => 'updated'); } else { $result = array('status' => 'error'); } } } if (phpgw::get_var('phpgw_return_as') == 'json') { if ($receipt = phpgwapi_cache::session_get('phpgwapi', 'phpgw_messages')) { phpgwapi_cache::session_clear('phpgwapi', 'phpgw_messages'); $result['receipt'] = $receipt; } else { $result['receipt'] = array(); } return $result; } else { $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'property.uidimb_role_user.index', 'user_id' => $user_id, 'dimb_id' => $dimb_id, 'role_id' => $role_id, 'query' => $query)); } }
public function save_group_and_item_order() { if (!$this->add && !$this->edit) { phpgwapi_cache::message_set('No access', 'error'); $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'controller.uicontrol_group.index')); } $control_id = phpgw::get_var('control_id'); $item_order_str = phpgw::get_var('item_order'); $group_order_str = phpgw::get_var('group_order'); $status = 1; $group_order_arr = explode(",", $group_order_str); $item_order_arr = explode(",", $item_order_str); $db_control_group_list = $this->so_control_group_list->get_db(); // Saves order for control groups foreach ($group_order_arr as $group_id_order) { $group_id_order_arr = explode(":", $group_id_order); $group_id = $group_id_order_arr[0]; $group_order_nr = $group_id_order_arr[1]; // Gets control_group_list object from db if it exists $control_group_list = $this->so_control_group_list->get_group_list_by_control_and_group($control_id, $group_id); $db_control_group_list->transaction_begin(); // Updates group order if control_group_list object exists if ($control_group_list != null) { $control_group_list->set_order_nr($group_order_nr); $id = $this->so_control_group_list->update($control_group_list); if ($id > 0) { $db_control_group_list->transaction_commit(); } else { $db_control_group_list->transaction_abort(); $status = 0; } } else { echo "Error: group not found"; $status = 0; } } $db_control_item_list = $this->so_control_item_list->get_db(); // Saves order for control items foreach ($item_order_arr as $item_id_order) { $item_id_order_arr = explode(":", $item_id_order); $control_item_id = $item_id_order_arr[0]; $item_order_nr = $item_id_order_arr[1]; $control_item_list = $this->so_control_item_list->get_single_2($control_id, $control_item_id); $db_control_item_list->transaction_begin(); // Updates item order if control_item_list object exists if ($control_item_list != null) { $control_item_list->set_order_nr($item_order_nr); $id = $this->so_control_item_list->update($control_item_list); if ($id > 0) { $db_control_item_list->transaction_commit(); } else { $db_control_item_list->transaction_abort(); $status = 0; } } else { echo "Error: item not found"; $status = 0; } } return $status; }
function get_location_info($type, $type_id) { $type_id = (int) $type_id; $this->type = $type; $this->type_id = $type_id; $info = array(); if (!$type) { return $info; } switch ($type) { //-------- ID type integer case 'part_of_town': $info = array('table' => 'fm_part_of_town', 'id' => array('name' => 'part_of_town_id', 'type' => 'int', 'descr' => lang('id')), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar', 'nullable' => false, 'size' => 20), array('name' => 'district_id', 'descr' => lang('district'), 'type' => 'select', 'nullable' => false, 'filter' => true, 'values_def' => array('valueset' => false, 'method' => 'property.bogeneric.get_list', 'method_input' => array('type' => 'district', 'selected' => '##district_id##')))), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('part of town'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::location::town', 'check_grant' => false); break; case 'project_group': $info = array('table' => 'fm_project_group', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar'), array('name' => 'budget', 'descr' => lang('budget'), 'type' => 'int')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => '', 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::project_group'); break; case 'dimb': $info = array('table' => 'fm_ecodimb', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar'), array('name' => 'org_unit_id', 'descr' => lang('department'), 'type' => 'select', 'nullable' => false, 'filter' => true, 'sortable' => true, 'values_def' => array('valueset' => false, 'method' => 'property.bogeneric.get_list', 'method_input' => array('type' => 'org_unit', 'selected' => '##org_unit_id##')))), 'custom_criteria' => array('dimb_role_user' => array('join' => array("{$this->_db->join} fm_ecodimb_role_user ON fm_ecodimb.id = fm_ecodimb_role_user.ecodimb"), 'filter' => array('fm_ecodimb_role_user.user_id = ' . (int) $this->account))), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('dimb'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::accounting::accounting_dimb'); break; case 'dimd': $info = array('table' => 'fm_ecodimd', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('dimd'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::accounting::accounting_dimd'); break; case 'periodization': $info = array('table' => 'fm_eco_periodization', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar'), array('name' => 'active', 'descr' => lang('active'), 'type' => 'checkbox', 'default' => 'checked')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('periodization'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::accounting::periodization'); break; case 'tax': $info = array('table' => 'fm_ecomva', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'percent', 'descr' => lang('percent'), 'type' => 'int'), array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => '', 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::accounting::accounting_tax'); break; case 'voucher_cat': $info = array('table' => 'fm_ecobilag_category', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => '', 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::accounting::voucher_cats'); break; case 'voucher_type': $info = array('table' => 'fm_ecoart', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => '', 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::accounting::voucher_type'); break; case 'tender_chapter': $info = array('table' => 'fm_chapter', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => '', 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::tender'); break; case 'location': $this->_db->query("SELECT id FROM fm_location_type WHERE id ={$type_id}", __LINE__, __FILE__); if ($this->_db->next_record()) { $info = array('table' => "fm_location{$type_id}_category", 'id' => array('name' => 'id', 'type' => 'varchar'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => '', 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => "admin::property::location::location::category_{$type_id}"); } else { throw new Exception(lang('ERROR: illegal type %1', $type_id)); } break; case 'owner_cats': $info = array('table' => 'fm_owner_category', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => '', 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::owner::owner_cats'); break; case 'tenant_cats': $info = array('table' => 'fm_tenant_category', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('tenant category'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::tenant::tenant_cats'); break; case 'vendor_cats': $info = array('table' => 'fm_vendor_category', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('vendor category'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::vendor::vendor_cats'); break; case 'vendor': $info = array('table' => 'fm_vendor', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'contact_phone', 'descr' => lang('contact phone'), 'type' => 'varchar'), array('name' => 'category', 'descr' => lang('category'), 'type' => 'select', 'nullable' => false, 'filter' => true, 'sortable' => true, 'values_def' => array('valueset' => false, 'method' => 'property.bogeneric.get_list', 'method_input' => array('type' => 'vendor_cats', 'selected' => '##category##'))), array('name' => 'member_of', 'descr' => lang('member'), 'type' => 'multiple_select', 'nullable' => true, 'filter' => true, 'sortable' => false, 'hidden' => true, 'values_def' => array('valueset' => false, 'method' => 'property.bocommon.get_categories', 'method_input' => array('app' => 'property', 'acl_location' => '.vendor', 'selected' => '##member_of##')))), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('vendor'), 'acl_app' => 'property', 'acl_location' => '.vendor', 'menu_selection' => 'property::invoice::vendor', 'default' => array('owner_id' => array('add' => '$this->account'), 'entry_date' => array('add' => 'time()'))); break; case 'owner': $info = array('table' => 'fm_owner', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'remark', 'descr' => lang('remark'), 'type' => 'text'), array('name' => 'category', 'descr' => lang('category'), 'type' => 'select', 'nullable' => false, 'filter' => true, 'sortable' => true, 'values_def' => array('valueset' => false, 'method' => 'property.bogeneric.get_list', 'method_input' => array('type' => 'owner_cats', 'selected' => '##category##')))), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('owner'), 'acl_app' => 'property', 'acl_location' => '.owner', 'menu_selection' => 'admin::property::owner', 'default' => array('owner_id' => array('add' => '$this->account'), 'entry_date' => array('add' => 'time()'))); break; case 'tenant': $info = array('table' => 'fm_tenant', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'contact_email', 'descr' => lang('contact_email'), 'type' => 'varchar', 'sortable' => true), array('name' => 'category', 'descr' => lang('category'), 'type' => 'select', 'nullable' => false, 'filter' => true, 'sortable' => true, 'values_def' => array('valueset' => false, 'method' => 'property.bogeneric.get_list', 'method_input' => array('type' => 'tenant_cats', 'selected' => '##category##')))), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('tenant'), 'acl_app' => 'property', 'acl_location' => '.tenant', 'menu_selection' => 'admin::property::tenant', 'default' => array('owner_id' => array('add' => '$this->account'), 'entry_date' => array('add' => 'time()'))); break; case 'district': $info = array('table' => 'fm_district', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('district'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::location::district'); break; case 'street': $info = array('table' => 'fm_streetaddress', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('streetaddress'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::location::street'); break; case 's_agreement': $info = array('table' => 'fm_s_agreement_category', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => '', 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::agreement::service_agree_cats'); break; case 'tenant_claim': $info = array('table' => 'fm_tenant_claim_category', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => '', 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::tenant::claims_cats'); break; case 'wo_hours': $info = array('table' => 'fm_wo_hours_category', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => '', 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::workorder_detail'); break; case 'r_condition_type': $info = array('table' => 'fm_request_condition_type', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => 'condition type', 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::request_condition'); break; case 'authorities_demands': $info = array('table' => 'fm_authorities_demands', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('authorities demands'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::authorities_demands', 'default' => array('user_id' => array('add' => '$this->account'), 'entry_date' => array('add' => 'time()'), 'modified_date' => array('edit' => 'time()')), 'check_grant' => false); break; case 'b_account': case 'b_account_category': $info = array('table' => 'fm_b_account_category', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar'), array('name' => 'active', 'descr' => lang('active'), 'type' => 'checkbox', 'default' => 'checked', 'filter' => true, 'sortable' => true, 'values_def' => array('valueset' => array(array('id' => 1, 'name' => lang('active'))))), array('name' => 'project_group', 'descr' => lang('mandatory project group'), 'type' => 'checkbox')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('budget account group'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::accounting::accounting_cats'); break; case 'dimb_role': $info = array('table' => 'fm_ecodimb_role', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar')), 'edit_msg' => lang('edit role'), 'add_msg' => lang('add role'), 'name' => lang('dimb role'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::accounting::dimb_role'); break; case 'condition_survey_status': $info = array('table' => 'fm_condition_survey_status', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar'), array('name' => 'sorting', 'descr' => lang('sorting'), 'type' => 'integer', 'sortable' => true), array('name' => 'in_progress', 'descr' => lang('In progress'), 'type' => 'checkbox'), array('name' => 'delivered', 'descr' => lang('delivered'), 'type' => 'checkbox'), array('name' => 'closed', 'descr' => lang('closed'), 'type' => 'checkbox')), 'edit_msg' => lang('edit status'), 'add_msg' => lang('add status'), 'name' => lang('request status'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::condition_survey_status'); break; case 'request_responsible_unit': $_lang_responsible_unit = lang('responsible unit'); $info = array('table' => 'fm_request_responsible_unit', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit') . ' ' . $_lang_responsible_unit, 'add_msg' => lang('add') . ' ' . $_lang_responsible_unit, 'name' => $_lang_responsible_unit, 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::request_responsible_unit'); break; case 'ticket_priority': $_lang_priority = lang('priority'); $info = array('table' => 'fm_tts_priority', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar')), 'edit_msg' => lang('edit') . ' ' . $_lang_priority, 'add_msg' => lang('add') . ' ' . $_lang_priority, 'name' => $_lang_priority, 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::ticket::ticket_priority'); break; //-------- ID type varchar //-------- ID type varchar case 'project_status': $info = array('table' => 'fm_project_status', 'id' => array('name' => 'id', 'type' => 'varchar'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar'), array('name' => 'approved', 'descr' => lang('approved'), 'type' => 'checkbox'), array('name' => 'closed', 'descr' => lang('closed'), 'type' => 'checkbox')), 'edit_msg' => lang('edit status'), 'add_msg' => lang('add status'), 'name' => lang('project status'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::project_status'); break; case 'workorder_status': $info = array('table' => 'fm_workorder_status', 'id' => array('name' => 'id', 'type' => 'varchar'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar'), array('name' => 'approved', 'descr' => lang('approved'), 'type' => 'checkbox'), array('name' => 'in_progress', 'descr' => lang('In progress'), 'type' => 'checkbox'), array('name' => 'delivered', 'descr' => lang('delivered'), 'type' => 'checkbox'), array('name' => 'closed', 'descr' => lang('closed'), 'type' => 'checkbox')), 'edit_msg' => lang('edit status'), 'add_msg' => lang('add status'), 'name' => lang('workorder status'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::workorder_status'); break; case 'request_status': $info = array('table' => 'fm_request_status', 'id' => array('name' => 'id', 'type' => 'varchar'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar'), array('name' => 'sorting', 'descr' => lang('sorting'), 'type' => 'integer', 'sortable' => true), array('name' => 'in_progress', 'descr' => lang('In progress'), 'type' => 'checkbox'), array('name' => 'delivered', 'descr' => lang('delivered'), 'type' => 'checkbox'), array('name' => 'closed', 'descr' => lang('closed'), 'type' => 'checkbox')), 'edit_msg' => lang('edit status'), 'add_msg' => lang('add status'), 'name' => lang('request status'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::request_status'); break; case 'agreement_status': $info = array('table' => 'fm_agreement_status', 'id' => array('name' => 'id', 'type' => 'varchar'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit status'), 'add_msg' => lang('add status'), 'name' => lang('agreement status'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::agreement::agreement_status'); break; case 'building_part': $config = CreateObject('phpgwapi.config', 'property'); $config->read(); $filter_buildingpart = isset($config->config_data['filter_buildingpart']) ? $config->config_data['filter_buildingpart'] : array(); $info = array('table' => 'fm_building_part', 'id' => array('name' => 'id', 'type' => 'varchar'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar'), array('name' => 'filter_1', 'descr' => isset($filter_buildingpart[1]) && $filter_buildingpart[1] ? $filter_buildingpart[1] : 'Filter 1', 'type' => 'checkbox', 'filter' => true, 'sortable' => true, 'values_def' => array('valueset' => array(array('id' => 1, 'name' => lang('active'))))), array('name' => 'filter_2', 'descr' => isset($filter_buildingpart[2]) && $filter_buildingpart[2] ? $filter_buildingpart[2] : 'Filter 2', 'type' => 'checkbox', 'filter' => true, 'sortable' => true, 'values_def' => array('valueset' => array(array('id' => 1, 'name' => lang('active'))))), array('name' => 'filter_3', 'descr' => isset($filter_buildingpart[3]) && $filter_buildingpart[3] ? $filter_buildingpart[3] : 'Filter 3', 'type' => 'checkbox', 'filter' => true, 'sortable' => true, 'values_def' => array('valueset' => array(array('id' => 1, 'name' => lang('active'))))), array('name' => 'filter_4', 'descr' => isset($filter_buildingpart[4]) && $filter_buildingpart[4] ? $filter_buildingpart[4] : 'Filter 4', 'type' => 'checkbox', 'filter' => true, 'sortable' => true, 'values_def' => array('valueset' => array(array('id' => 1, 'name' => lang('active')))))), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('building part'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::building_part'); break; case 'document_status': $info = array('table' => 'fm_document_status', 'id' => array('name' => 'id', 'type' => 'varchar'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit status'), 'add_msg' => lang('add status'), 'name' => lang('document status'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::document_status'); break; case 'unit': $info = array('table' => 'fm_standard_unit', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit unit'), 'add_msg' => lang('add unit'), 'name' => lang('unit'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::unit'); break; case 'budget_account': $info = array('table' => 'fm_b_account', 'id' => array('name' => 'id', 'type' => 'varchar'), 'fields' => array(array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar', 'nullable' => false, 'size' => 60, 'sortable' => true), array('name' => 'category', 'descr' => lang('category'), 'type' => 'select', 'nullable' => false, 'filter' => true, 'sortable' => true, 'values_def' => array('valueset' => false, 'method' => 'property.bogeneric.get_list', 'method_input' => array('type' => 'b_account', 'selected' => '##category##'))), array('name' => 'mva', 'descr' => lang('tax code'), 'type' => 'int', 'nullable' => true, 'size' => 4, 'sortable' => true), array('name' => 'responsible', 'descr' => lang('responsible'), 'type' => 'select', 'filter' => true, 'get_single' => 'get_user', 'values_def' => array('valueset' => false, 'method' => 'property.bocommon.get_user_list_right2', 'method_input' => array('selected' => '##responsible##', 'right' => 128, 'acl_location' => '.invoice'))), array('name' => 'active', 'descr' => lang('active'), 'type' => 'checkbox', 'default' => 'checked')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('budget account'), 'acl_app' => 'property', 'acl_location' => '.b_account', 'menu_selection' => 'property::invoice::budget_account', 'default' => array('user_id' => array('add' => '$this->account'), 'entry_date' => array('add' => 'time()'), 'modified_date' => array('edit' => 'time()')), 'check_grant' => false); break; case 'voucher_process_code': $info = array('table' => 'fm_ecobilag_process_code', 'id' => array('name' => 'id', 'type' => 'varchar'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar')), 'edit_msg' => lang('edit process code'), 'add_msg' => lang('add process code'), 'name' => lang('process code'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::accounting::process_code', 'default' => array('user_id' => array('add' => '$this->account'), 'entry_date' => array('add' => 'time()'), 'modified_date' => array('edit' => 'time()'))); break; case 'org_unit': $info = array('table' => 'fm_org_unit', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar', 'nullable' => false, 'size' => 60, 'sortable' => true), array('name' => 'parent_id', 'descr' => lang('parent'), 'type' => 'select', 'sortable' => true, 'nullable' => true, 'filter' => false, 'role' => 'parent', 'values_def' => array('valueset' => false, 'method' => 'property.bogeneric.get_list', 'method_input' => array('type' => 'org_unit', 'role' => 'parent', 'selected' => '##parent_id##')))), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('department'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::accounting::org_unit', 'default' => array('created_by' => array('add' => '$this->account'), 'created_on' => array('add' => 'time()'), 'modified_by' => array('edit' => '$this->account'), 'modified_on' => array('edit' => 'time()')), 'check_grant' => false); break; //-------- ID type auto //-------- ID type auto case 'dimb_role_user': $info = array('table' => 'fm_ecodimb_role_user', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'ecodimb', 'descr' => lang('dim b'), 'type' => 'select', 'nullable' => false, 'filter' => true, 'sortable' => true, 'values_def' => array('valueset' => false, 'method' => 'property.bogeneric.get_list', 'method_input' => array('type' => 'dimb', 'selected' => '##ecodimb##'))), array('name' => 'role_id', 'descr' => lang('role type'), 'type' => 'select', 'filter' => true, 'sortable' => true, 'values_def' => array('valueset' => false, 'method' => 'property.bogeneric.get_list', 'method_input' => array('type' => 'dimb_role', 'selected' => '##role_id##'))), array('name' => 'user_id', 'descr' => lang('user'), 'type' => 'select', 'filter' => true, 'get_single' => 'get_user', 'values_def' => array('valueset' => false, 'method' => 'property.bocommon.get_user_list_right2', 'method_input' => array('selected' => '##user_id##', 'right' => 1, 'acl_location' => '.invoice'))), array('name' => 'default_user', 'descr' => lang('default'), 'type' => 'checkbox', 'default' => 'checked')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('dimb role'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::accounting::dimb_role_user', 'default' => array('created_by' => array('add' => '$this->account'), 'created_on' => array('add' => 'time()')), 'check_grant' => false); break; case 'order_dim1': $info = array('table' => 'fm_order_dim1', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'num', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar', 'nullable' => false)), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('order_dim1'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::order_dim1'); break; case 'branch': $info = array('table' => 'fm_branch', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'num', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('branch'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::branch'); break; case 'key_location': $info = array('table' => 'fm_key_loc', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'num', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'descr', 'descr' => lang('key location'), 'type' => 'text')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('branch'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::key_location'); break; case 'async': $info = array('table' => 'fm_async_method', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'data', 'descr' => lang('data'), 'type' => 'text'), array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'text')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('Async services'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::async'); break; case 'event_action': $info = array('table' => 'fm_event_action', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'action', 'descr' => lang('action'), 'type' => 'varchar'), array('name' => 'data', 'descr' => lang('data'), 'type' => 'text'), array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'text')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('event action'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::event_action', 'default' => array('user_id' => array('add' => '$this->account'), 'entry_date' => array('add' => 'time()'), 'modified_date' => array('edit' => 'time()'))); break; case 'ticket_status': $info = array('table' => 'fm_tts_status', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'sorting', 'descr' => lang('sorting'), 'type' => 'integer', 'sortable' => true), array('name' => 'color', 'descr' => lang('color'), 'type' => 'varchar'), array('name' => 'approved', 'descr' => lang('approved'), 'type' => 'checkbox'), array('name' => 'in_progress', 'descr' => lang('In progress'), 'type' => 'checkbox'), array('name' => 'delivered', 'descr' => lang('delivered'), 'type' => 'checkbox'), array('name' => 'closed', 'descr' => lang('closed'), 'type' => 'checkbox'), array('name' => 'actual_cost', 'descr' => lang('mandatory actual cost'), 'type' => 'checkbox')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('ticket status'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::ticket::ticket_status'); break; case 'regulations': $info = array('table' => 'fm_regulations', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'parent_id', 'descr' => lang('parent'), 'type' => 'select', 'sortable' => true, 'nullable' => true, 'filter' => false, 'role' => 'parent', 'values_def' => array('valueset' => false, 'method' => 'property.bogeneric.get_list', 'method_input' => array('type' => 'regulations', 'role' => 'parent', 'selected' => '##parent_id##'))), array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar', 'sortable' => true), array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'text'), array('name' => 'external_ref', 'descr' => lang('external ref'), 'type' => 'link')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('regulations'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::regulations', 'default' => array('user_id' => array('add' => '$this->account'), 'entry_date' => array('add' => 'time()'), 'modified_date' => array('edit' => 'time()'))); break; //START HELPDESK - APP //START HELPDESK - APP case 'helpdesk_status': // the helpdesk app $info = array('table' => 'phpgw_helpdesk_status', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'sorting', 'descr' => lang('sorting'), 'type' => 'integer', 'sortable' => true), array('name' => 'color', 'descr' => lang('color'), 'type' => 'varchar'), array('name' => 'approved', 'descr' => lang('approved'), 'type' => 'checkbox'), array('name' => 'in_progress', 'descr' => lang('In progress'), 'type' => 'checkbox'), array('name' => 'delivered', 'descr' => lang('delivered'), 'type' => 'checkbox'), array('name' => 'closed', 'descr' => lang('closed'), 'type' => 'checkbox')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('event action'), 'acl_app' => 'helpdesk', 'acl_location' => '.admin', 'menu_selection' => 'admin::helpdesk::ticket_status'); break; //END HELPDESK - APP //END HELPDESK - APP case 'pending_action_type': $info = array('table' => 'fm_action_pending_category', 'id' => array('name' => 'num', 'type' => 'varchar'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'text')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('Pending action type'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::action_type'); break; case 'order_template': $info = array('table' => 'fm_order_template', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'content', 'descr' => lang('content'), 'type' => 'text'), array('name' => 'public', 'descr' => lang('public'), 'type' => 'checkbox')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('order template'), 'acl_app' => 'property', 'acl_location' => '.ticket.order', 'menu_selection' => 'property::helpdesk::order_template', 'default' => array('user_id' => array('add' => '$this->account'), 'entry_date' => array('add' => 'time()'), 'modified_date' => array('edit' => 'time()')), 'check_grant' => true); break; case 'response_template': $info = array('table' => 'fm_response_template', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'content', 'descr' => lang('content'), 'type' => 'text'), array('name' => 'public', 'descr' => lang('public'), 'type' => 'checkbox')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('response template'), 'acl_app' => 'property', 'acl_location' => '.ticket', 'menu_selection' => 'property::helpdesk::response_template', 'default' => array('user_id' => array('add' => '$this->account'), 'entry_date' => array('add' => 'time()'), 'modified_date' => array('edit' => 'time()')), 'check_grant' => true); break; case 'responsibility_role': $info = array('table' => 'fm_responsibility_role', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'remark', 'descr' => lang('remark'), 'type' => 'text'), array('name' => 'location_level', 'descr' => lang('location level'), 'type' => 'select', 'values_def' => array('valueset' => false, 'method' => 'preferences.boadmin_acl.get_locations', 'method_input' => array('acl_app' => 'property', 'selected' => '##location##'))), array('name' => 'responsibility_id', 'descr' => lang('responsibility'), 'type' => 'select', 'values_def' => array('valueset' => false, 'get_single_value' => 'property.soresponsible.get_responsibility_name', 'method' => 'property.boresponsible.get_responsibilities', 'method_input' => array('appname' => '$this->appname', 'selected' => '##responsibility_id##')))), 'edit_action' => 'property.uiresponsible.edit_role', 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('responsibility role'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::responsibility_role', 'default' => array('appname' => array('add' => '$this->appname'), 'user_id' => array('add' => '$this->account'), 'entry_date' => array('add' => 'time()'), 'modified_date' => array('edit' => 'time()')), 'check_grant' => false, 'filter' => array('appname' => '$this->appname')); break; case 'custom_menu_items': $info = array('table' => 'fm_custom_menu_items', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'parent_id', 'descr' => lang('parent'), 'type' => 'select', 'sortable' => true, 'nullable' => true, 'filter' => false, 'role' => 'parent', 'values_def' => array('valueset' => false, 'method' => 'property.bogeneric.get_list', 'method_input' => array('type' => 'custom_menu_items', 'role' => 'parent', 'selected' => '##parent_id##', 'mapping' => array('name' => 'text')))), array('name' => 'text', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'url', 'descr' => lang('url'), 'type' => 'text'), array('name' => 'target', 'descr' => lang('target'), 'type' => 'select', 'filter' => false, 'values_def' => array('valueset' => array(array('id' => '_blank', 'name' => '_blank'), array('id' => '_parent', 'name' => '_parent')))), array('name' => 'location', 'descr' => lang('location'), 'type' => 'select', 'filter' => true, 'values_def' => array('valueset' => false, 'method' => 'preferences.boadmin_acl.get_locations', 'method_input' => array('acl_app' => 'property', 'selected' => '##location##'))), array('name' => 'local_files', 'descr' => lang('local files'), 'type' => 'checkbox', 'default' => '')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('custom menu items'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::custom_menu_items', 'default' => array('user_id' => array('add' => '$this->account'), 'entry_date' => array('add' => 'time()'), 'modified_date' => array('edit' => 'time()')), 'check_grant' => false, 'mapping' => array('name' => 'text')); break; case 'location_contact': $info = array('table' => 'fm_location_contact', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'contact_id', 'descr' => lang('contact'), 'type' => 'int', 'nullable' => false), array('name' => 'location_code', 'descr' => lang('location_code'), 'type' => 'varchar', 'nullable' => false)), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('location contact'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::location::location_contact', 'default' => array('user_id' => array('add' => '$this->account'), 'entry_date' => array('add' => 'time()'), 'modified_date' => array('edit' => 'time()'))); break; case 'periodization_outline': $valueset_month = array(); for ($i = 1; $i < 13; $i++) { $valueset_month[] = array('id' => $i, 'name' => $i); } $info = array('table' => 'fm_eco_periodization_outline', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'periodization_id', 'descr' => lang('periodization'), 'type' => 'select', 'nullable' => false, 'filter' => true, 'sortable' => true, 'values_def' => array('valueset' => false, 'method' => 'property.bogeneric.get_list', 'method_input' => array('type' => 'periodization', 'selected' => '##periodization_id##'))), array('name' => 'month', 'descr' => lang('month'), 'type' => 'select', 'nullable' => false, 'filter' => true, 'sortable' => true, 'values_def' => array('valueset' => $valueset_month)), array('name' => 'value', 'descr' => lang('value'), 'type' => 'numeric', 'nullable' => true, 'size' => 4, 'sortable' => true), array('name' => 'dividend', 'descr' => lang('fraction::dividend'), 'type' => 'integer', 'nullable' => true, 'size' => 4, 'sortable' => true), array('name' => 'divisor', 'descr' => lang('fraction::divisor'), 'type' => 'integer', 'nullable' => true, 'size' => 4, 'sortable' => true), array('name' => 'remark', 'descr' => lang('remark'), 'type' => 'varchar', 'nullable' => false, 'size' => 60, 'sortable' => true)), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('periodization'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::accounting::periodization_outline'); break; case 'period_transition': $valueset_month = array(); $valueset_day = array(); $valueset_hour = array(); $lang_default = lang('default'); for ($i = 1; $i < 14; $i++) { $valueset_month[] = array('id' => $i, 'name' => $i == 13 ? "{$i} ({$lang_default})" : $i); } for ($i = 1; $i < 32; $i++) { $valueset_day[] = array('id' => $i, 'name' => $i); } for ($i = 1; $i < 25; $i++) { $valueset_hour[] = array('id' => $i, 'name' => $i); } $info = array('table' => 'fm_eco_period_transition', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'month', 'descr' => lang('month'), 'type' => 'select', 'nullable' => false, 'filter' => true, 'sortable' => true, 'values_def' => array('valueset' => $valueset_month)), array('name' => 'day', 'descr' => lang('day'), 'type' => 'select', 'nullable' => false, 'size' => 4, 'sortable' => true, 'values_def' => array('valueset' => $valueset_day)), array('name' => 'hour', 'descr' => lang('hour'), 'type' => 'select', 'nullable' => true, 'size' => 4, 'sortable' => true, 'values_def' => array('valueset' => $valueset_hour)), array('name' => 'remark', 'descr' => lang('remark'), 'type' => 'varchar', 'nullable' => true, 'size' => 60, 'sortable' => true)), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('period transition'), 'acl_app' => 'property', 'acl_location' => '.admin', 'menu_selection' => 'admin::property::accounting::period_transition', 'default' => array('user_id' => array('add' => '$this->account'), 'entry_date' => array('add' => 'time()'), 'modified_date' => array('edit' => 'time()'))); break; case 'entity_group': $info = array('table' => 'fm_entity_group', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'descr', 'descr' => lang('descr'), 'type' => 'varchar'), array('name' => 'active', 'descr' => lang('active'), 'type' => 'checkbox', 'default' => 'checked')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('entity group'), 'acl_app' => 'property', 'acl_location' => '.admin.entity', 'menu_selection' => 'admin::property::entity::entity_group', 'default' => array('user_id' => array('add' => '$this->account'), 'entry_date' => array('add' => 'time()'), 'modified_date' => array('add' => 'time()', 'edit' => 'time()')), 'check_grant' => false); break; // START BOOKING TABLES // START BOOKING TABLES case 'bb_office': $info = array('table' => 'bb_office', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'description', 'descr' => lang('description'), 'type' => 'text')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => $GLOBALS['phpgw']->translation->translate('office', array(), false, 'booking'), 'acl_app' => 'booking', 'acl_location' => '.office', 'menu_selection' => 'booking::settings::office', 'default' => array('user_id' => array('add' => '$this->account'), 'entry_date' => array('add' => 'time()'), 'modified_date' => array('edit' => 'time()')), 'check_grant' => false); break; case 'bb_office_user': $info = array('table' => 'bb_office_user', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'office', 'descr' => $GLOBALS['phpgw']->translation->translate('office', array(), false, 'booking'), 'type' => 'select', 'filter' => true, 'values_def' => array('valueset' => false, 'method' => 'property.bogeneric.get_list', 'method_input' => array('type' => 'bb_office', 'selected' => '##office##')))), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => $GLOBALS['phpgw']->translation->translate('office user', array(), false, 'booking'), 'acl_app' => 'booking', 'acl_location' => '.office.user', 'menu_selection' => 'booking::settings::office::office_user', 'default' => array('user_id' => array('add' => '$this->account'), 'entry_date' => array('add' => 'time()'), 'modified_date' => array('edit' => 'time()')), 'check_grant' => false); break; // END BOOKING TABLES // START CONTROLLER TABLES // END BOOKING TABLES // START CONTROLLER TABLES case 'controller_check_item_status': $info = array('table' => 'controller_check_item_status', 'id' => array('name' => 'id', 'type' => 'auto'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'sorting', 'descr' => lang('sorting'), 'type' => 'integer', 'sortable' => true), array('name' => 'open', 'descr' => lang('open'), 'type' => 'checkbox'), array('name' => 'pending', 'descr' => lang('pending'), 'type' => 'checkbox'), array('name' => 'closed', 'descr' => lang('closed'), 'type' => 'checkbox')), 'edit_msg' => lang('edit'), 'add_msg' => lang('add'), 'name' => lang('status'), 'acl_app' => 'controller', 'acl_location' => 'admin', 'menu_selection' => 'admin::controller::check_item_status'); break; // END CONTROLLER TABLES // START RENTAL TABLES // END CONTROLLER TABLES // START RENTAL TABLES case 'composite_standard': $info = array('table' => 'rental_composite_standard', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar'), array('name' => 'factor', 'descr' => lang('factor'), 'type' => 'numeric', 'nullable' => false, 'size' => 4, 'sortable' => true)), 'edit_msg' => lang('edit unit'), 'add_msg' => lang('add unit'), 'name' => lang('unit'), 'acl_app' => 'rental', 'acl_location' => '.admin', 'menu_selection' => 'admin::rental::composite_standard'); break; case 'responsibility_unit': $info = array('table' => 'rental_contract_responsibility_unit', 'id' => array('name' => 'id', 'type' => 'int'), 'fields' => array(array('name' => 'name', 'descr' => lang('name'), 'type' => 'varchar')), 'edit_msg' => lang('edit unit'), 'add_msg' => lang('add unit'), 'name' => lang('unit'), 'acl_app' => 'rental', 'acl_location' => '.admin', 'menu_selection' => 'admin::rental::responsibility_unit'); break; // END RENTAL TABLES // END RENTAL TABLES default: $message = lang('ERROR: illegal type %1', $type); phpgwapi_cache::message_set($message, 'error'); // throw new Exception(lang('ERROR: illegal type %1', $type)); } $this->location_info = $info; return $info; }
/** * Prepare data for view and edit - depending on mode * * @param array $values populated object in case of retry * @param string $mode edit or view * @param int $id entity id - no id means 'new' * * @return void */ public function edit($values = array(), $mode = 'edit') { $bo =& $this->bo; $id = phpgw::get_var('id'); $values = $bo->read_single(array('id' => $id, 'entity_id' => $this->entity_id, 'cat_id' => $this->cat_id, 'view' => true)); //_debug_array($values); $entity = $this->soadmin_entity->read_single($this->entity_id); $category = $this->soadmin_entity->read_single_category($this->entity_id, $this->cat_id); $location_data = array(); if ($entity['location_form'] && $category['location_level'] > 0) { $bolocation = CreateObject('property.bolocation'); $location_data = $bolocation->initiate_ui_location(array('values' => $values['location_data'], 'type_id' => (int) $category['location_level'], 'no_link' => $_no_link, 'lookup_type' => $lookup_type, 'tenant' => $lookup_tenant, 'lookup_entity' => $lookup_entity, 'entity_data' => isset($values['p']) ? $values['p'] : '')); } // ---- START INTEGRATION ------------------------- $custom_config = CreateObject('admin.soconfig', $GLOBALS['phpgw']->locations->get_id($this->type_app[$this->type], $this->acl_location)); $_config = isset($custom_config->config_data) && $custom_config->config_data ? $custom_config->config_data : array(); //_debug_array($custom_config->config_data);die(); // required settings: /* integration_tab integration_height integration_url integration_parametres integration_action integration_action_view integration_action_edit integration_auth_key_name integration_auth_url integration_auth_hash_name integration_auth_hash_value integration_location_data */ $tabs = array(); $tabs['info'] = array('label' => 'Info', 'link' => '#info'); $active_tab = $active_tab ? $active_tab : 'info'; $integration = array(); foreach ($_config as $_config_section => $_config_section_data) { if (isset($_config_section_data['tab']) && $values['id']) { if (!isset($_config_section_data['url'])) { phpgwapi_cache::message_set("'url' is a required setting for integrations, '{$_config_section}' is disabled", 'error'); break; } //get session key from remote system $arguments = array($_config_section_data['auth_hash_name'] => $_config_section_data['auth_hash_value']); $query = http_build_query($arguments); $auth_url = $_config_section_data['auth_url']; $request = "{$auth_url}?{$query}"; $aContext = array('http' => array('request_fulluri' => true)); if (isset($GLOBALS['phpgw_info']['server']['httpproxy_server'])) { $aContext['http']['proxy'] = "{$GLOBALS['phpgw_info']['server']['httpproxy_server']}:{$GLOBALS['phpgw_info']['server']['httpproxy_port']}"; } $cxContext = stream_context_create($aContext); $response = trim(file_get_contents($request, False, $cxContext)); $_config_section_data['url'] = htmlspecialchars_decode($_config_section_data['url']); $_config_section_data['parametres'] = htmlspecialchars_decode($_config_section_data['parametres']); parse_str($_config_section_data['parametres'], $output); foreach ($output as $_dummy => $_substitute) { $_keys[] = $_substitute; $__value = false; if (!($__value = urlencode($values[str_replace(array('__', '*'), array('', ''), $_substitute)]))) { foreach ($values['attributes'] as $_attribute) { if (str_replace(array('__', '*'), array('', ''), $_substitute) == $_attribute['name']) { $__value = urlencode($_attribute['value']); break; } } } if ($__value) { $_values[] = $__value; } } //_debug_array($_config_section_data['parametres']); // _debug_array($_values); // _debug_array($output); unset($output); unset($__value); $_sep = '?'; if (stripos($_config_section_data['url'], '?')) { $_sep = '&'; } $_param = str_replace($_keys, $_values, $_config_section_data['parametres']); unset($_keys); unset($_values); // $integration_src = phpgw::safe_redirect("{$_config_section_data['url']}{$_sep}{$_param}"); $integration_src = "{$_config_section_data['url']}{$_sep}{$_param}"; if ($_config_section_data['action']) { $_sep = '?'; if (stripos($integration_src, '?')) { $_sep = '&'; } $integration_src .= "{$_sep}{$_config_section_data['action']}=" . $_config_section_data["action_{$mode}"]; } $arguments = array($_config_section_data['auth_key_name'] => $response); if (isset($_config_section_data['location_data']) && $_config_section_data['location_data']) { $_config_section_data['location_data'] = htmlspecialchars_decode($_config_section_data['location_data']); parse_str($_config_section_data['location_data'], $output); foreach ($output as $_dummy => $_substitute) { $_keys[] = $_substitute; $_values[] = urlencode($values['location_data'][trim($_substitute, '_')]); } $integration_src .= '&' . str_replace($_keys, $_values, $_config_section_data['location_data']); } $integration_src .= "&{$_config_section_data['auth_key_name']}={$response}"; //_debug_array($values); //_debug_array($integration_src);die(); $tabs[$_config_section] = array('label' => $_config_section_data['tab'], 'link' => "#{$_config_section}", 'function' => "document.getElementById('{$_config_section}_content').src = '{$integration_src}';"); $integration[] = array('section' => $_config_section, 'height' => isset($_config_section_data['height']) && $_config_section_data['height'] ? $_config_section_data['height'] : 500, 'src' => $integration_src); } } //_debug_array($integration);die(); // ---- END INTEGRATION ------------------------- $link_file_data = array('menuaction' => 'property.uientity.view_file', 'loc1' => $values['location_data']['loc1'], 'id' => $id, 'cat_id' => $this->cat_id, 'entity_id' => $this->entity_id, 'type' => $this->type); $img_types = array('image/jpeg', 'image/png', 'image/gif'); $content_files = array(); for ($z = 0; $z < count($values['files']); $z++) { $content_files[$z]['url'] = '<a href="' . $GLOBALS['phpgw']->link('/index.php', $link_file_data) . '&file_name=' . $values['files'][$z]['name'] . '" target="_blank" title="' . lang('click to view file') . '">' . $values['files'][$z]['name'] . '</a>'; $content_files[$z]['file_name'] = $values['files'][$z]['name']; if (in_array($values['files'][$z]['mime_type'], $img_types)) { $content_files[$z]['file_name'] = urlencode($values['files'][$z]['name']); $content_files[$z]['directory'] = urlencode($values['files'][$z]['directory']); $content_files[$z]['img_id'] = $values['files'][$z]['file_id']; } } $datavalues[0] = array('name' => "0", 'values' => json_encode($content_files), 'total_records' => count($content_files), 'edit_action' => "''", 'is_paginator' => 0, 'footer' => 0); $myColumnDefs[0] = array('name' => "0", 'values' => json_encode(array(array('key' => 'url', 'label' => lang('Filename'), 'sortable' => false, 'resizeable' => true), array('key' => 'file_name', 'hidden' => true), array('key' => 'img_id', 'hidden' => true), array('key' => 'directory', 'hidden' => true), array('key' => 'picture', 'label' => 'picture', 'sortable' => false, 'resizeable' => false, 'visible' => true, 'formatter' => 'show_picture')))); $msglog = phpgwapi_cache::session_get('frontend', 'msgbox'); phpgwapi_cache::session_clear('frontend', 'msgbox'); $data = array('header' => $this->header_state, 'msgbox_data' => isset($msglog) ? $GLOBALS['phpgw']->common->msgbox($GLOBALS['phpgw']->common->msgbox_data($msglog)) : array(), 'tabs' => $this->tabs, 'entityinfo' => array('entitylist' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'frontend.uientity.index', 'location_id' => $this->location_id)), 'entityedit' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'frontend.uientity.edit', 'location_id' => $this->location_id, 'id' => $id)), 'start_ticket' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'frontend.uihelpdesk.add_ticket', 'noframework' => 1, 'p_entity_id' => $this->entity_id, 'p_cat_id' => $this->cat_id, 'type' => $this->type, 'bypass' => true, 'origin' => ".{$this->type}.{$this->entity_id}.{$this->cat_id}", 'location_code' => $this->location_code, 'origin_id' => $id, 'p_num' => $id)), 'location_id' => $this->location_id, 'id' => $id, 'entity' => $entity, 'entityhistory' => $entityhistory2, 'custom_attributes' => array('attributes' => $values['attributes']), 'location_data' => $location_data, 'files' => isset($values['files']) ? $values['files'] : '', 'property_js' => json_encode($GLOBALS['phpgw_info']['server']['webserver_url'] . "/property/js/yahoo/property2.js"), 'base_java_url' => "{menuaction:'property.uientity.get_files'," . "id:'{$id}'," . "entity_id:'{$this->entity_id}'," . "cat_id:'{$this->cat_id}'," . "type:'{$this->type}'}", 'datatable' => $datavalues, 'myColumnDefs' => $myColumnDefs, 'tabs' => phpgwapi_yui::tabview_generate($tabs, $active_tab), 'active_tab' => $active_tab, 'integration' => $integration)); phpgwapi_yui::load_widget('dragdrop'); phpgwapi_yui::load_widget('datatable'); phpgwapi_yui::load_widget('connection'); phpgwapi_yui::load_widget('loader'); phpgwapi_yui::load_widget('animation'); $GLOBALS['phpgw']->js->validate_file('yahoo', 'entity.view', 'frontend'); $GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/datatable/assets/skins/sam/datatable.css'); $GLOBALS['phpgw']->js->validate_file('tinybox2', 'packed', 'phpgwapi'); $GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/tinybox2/style.css'); $GLOBALS['phpgw']->xslttpl->add_file(array('frontend', 'entityview', 'attributes_view')); $GLOBALS['phpgw']->xslttpl->add_file(array('location_view', 'files'), PHPGW_SERVER_ROOT . '/property/templates/base'); $GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('app_data' => $data)); }
<?php /**************************************************************************\ * eGroupWare - FeLaMiMail * * http://www.egroupware.org * * http://www.phpgw.de * * http://www.linux-at-work.de * * Written by Lars Kneschke [lkneschke@linux-at-work.de] * * ----------------------------------------------- * * This program is free software; you can redistribute it and/or modify it * * under the terms of the GNU General Public License as published by the * * Free Software Foundation; either version 2 of the License, or (at your * * option) any later version. * \**************************************************************************/ /* $Id$ */ // this is to get css inclusion working $_GET['menuaction'] = 'felamimail.uifelamimail.viewMainScreen'; $GLOBALS['phpgw_info']['flags'] = array('currentapp' => 'felamimail', 'noheader' => True, 'nonavbar' => True, 'include_xajax' => True); include '../header.inc.php'; try { execmethod('felamimail.uifelamimail.viewMainScreen'); } catch (Exception $e) { phpgwapi_cache::message_set($e->getMessage(), 'error'); $GLOBALS['phpgw']->redirect_link('/home.php'); }
public function get_db() { if ($this->db && is_object($this->db)) { return $this->db; } if (!$this->config->config_data['fellesdata']['host'] || !$this->ping($this->config->config_data['fellesdata']['host'])) { $message = "Database server {$this->config->config_data['fellesdata']['host']} is not accessible"; phpgwapi_cache::message_set($message, 'error'); return false; } $db = createObject('phpgwapi.db', null, null, true); $db->debug = false; $db->Host = $this->config->config_data['fellesdata']['host']; $db->Port = $this->config->config_data['fellesdata']['port']; $db->Type = 'oracle'; $db->Database = $this->config->config_data['fellesdata']['db_name']; $db->User = $this->config->config_data['fellesdata']['user']; $db->Password = $this->config->config_data['fellesdata']['password']; try { $db->connect(); $this->connected = true; } catch (Exception $e) { $status = lang('unable_to_connect_to_database'); } $this->db = $db; return $db; }
/** * * @param string $from_name * @param string $from_address * @param string $to_name * @param string $to_address * @param int $startTime * @param int $endTime * @param string $subject * @param string $html_description * @param string $text_description * @param string $location * @return type */ function sendIcalEvent($from_name, $from_address, $to_name, $to_address, $startTime, $endTime, $subject, $html_description, $text_description, $location) { // https://www.exchangecore.com/blog/sending-outlookemail-calendar-events-php/ $domain = $GLOBALS['phpgw_info']['server']['hostname']; //Create Email Headers $mime_boundary = "----Meeting Booking----" . md5(time()); //Create Email Body (HTML) $message = <<<HTML \t\t\t--{$mime_boundary} \t\t\tContent-Type: text/html; charset=UTF-8 \t\t\tContent-Transfer-Encoding: 8bit \t\t\t<html> \t\t\t<body> \t\t\t<p>Dear {$to_name}</p> \t\t\t<p>{$html_description}</p> \t\t\t</body> \t\t\t</html> \t\t\t--{$mime_boundary} HTML; //Create Email Body (HTML) $message = <<<HTML \t\t\t<html> \t\t\t<body> \t\t\t<p>Dear {$to_name}</p> \t\t\t<p>{$html_description}</p> \t\t\t</body> \t\t\t</html> HTML; $last_modified = date("Ymd\\TGis"); $uid = date("Ymd\\TGis", $startTime) . rand() . "@" . $domain; $dtstamp = date("Ymd\\TGis"); $dtstart = date("Ymd\\THis", $startTime); $dtend = date("Ymd\\THis", $endTime); $timezone = $GLOBALS['phpgw_info']['user']['preferences']['common']['timezone']; $ical = <<<HTML BEGIN:VCALENDAR PRODID: controller {$domain} VERSION:2.0 CALSCALE:GREGORIAN METHOD:REQUEST X-WR-TIMEZONE:Europe/Oslo BEGIN:VEVENT ORGANIZER;CN="{$to_name}":MAILTO:{$to_address} ATTENDEE;CN="{$to_name}";ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:{$to_address} DTSTAMP:{$dtstamp} DTSTART:{$dtstart} DTEND:{$dtend} SEQUENCE:0 STATUS:TENTATIVE SUMMARY:{$subject} LOCATION:{$location} DESCRIPTION:{$text_description} UID:{$uid} BEGIN:VALARM TRIGGER:-PT15M ACTION:DISPLAY DESCRIPTION:Reminder END:VALARM END:VEVENT END:VCALENDAR HTML; //ORGANIZER;CN="{$from_name}":MAILTO:{$from_address} //ATTENDEE;CN="{$to_name}";ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:{$to_address} // $message .= $ical; $message = $ical; //Might work.... $attachment = array('content' => $ical, 'name' => 'meeting.ics', 'encoding' => '7bit', 'type' => "text/calendar;charset=utf-8; method=REQUEST", 'disposition' => 'inline'); //test $mail = createObject('phpgwapi.mailer_smtp'); $mail->Subject = $subject; $mail->Body = <<<HTML \t\t\t<html> \t\t\t<body> \t\t\t<p>{$to_name}:</p> \t\t\t<p>{$html_description}</p> \t\t\t</body> \t\t\t</html> HTML; $mail->AltBody = $text_description; // For non HTML email client $mail->Ical = $ical; //Your manually created ical code $mail->IsHTML(true); $mail->isSMTP(); $mail->AddAddress($to_address); $from = str_replace(array('[', ']'), array('<', '>'), $from_address); $from_array = explode('<', $from); unset($from); if (count($from_array) == 2) { $mail->From = trim($from_array[1], '>'); $mail->FromName = $from_array[0]; } else { $mail->From = $from_array[0]; $mail->FromName = $from_name; } try { $mail->Send(); } catch (phpmailerException $e) { phpgwapi_cache::message_set($e->getMessage(), 'error'); } return; //test $rc = false; if (isset($GLOBALS['phpgw_info']['server']['smtp_server']) && $GLOBALS['phpgw_info']['server']['smtp_server']) { $send = CreateObject('phpgwapi.send'); try { $rc = $send->msg('email', $to_address, $subject, $message, $msgtype = 'Ical', $cc = '', $bcc = '', $from_address, $from_name, 'html', $mime_boundary); //, array($attachment)); } catch (phpmailerException $e) { phpgwapi_cache::message_set($e->getMessage(), 'error'); } } else { phpgwapi_cache::message_set(lang('SMTP server is not set! (admin section)'), 'error'); } return $rc; }
/** * Create catalog - starting with fakebase * * @param string $type part of path pointing to end target * * @return bool true on success. */ private function create_document_dir($dir) { $ok = false; $this->vfs->override_acl = 1; if (!$this->vfs->mkdir(array('string' => $dir, 'relatives' => array(RELATIVE_NONE)))) { $message = lang('failed to create directory') . ' :' . $dir; phpgwapi_cache::message_set($message, 'error'); } else { $message = lang('directory created') . ' :' . $dir; phpgwapi_cache::message_set($message, 'message'); $ok = true; } $this->vfs->override_acl = 0; return $ok; }
function save($project, $action = '', $values_attribute = array()) { //_debug_array($project); while (is_array($project['location']) && (list(, $value) = each($project['location']))) { if ($value) { $location[] = $value; } } $project['location_code'] = implode("-", $location); $project['start_date'] = phpgwapi_datetime::date_to_timestamp($project['start_date']); $project['end_date'] = phpgwapi_datetime::date_to_timestamp($project['end_date']); if (is_array($values_attribute)) { $values_attribute = $this->custom->convert_attribute_save($values_attribute); } // Custom rules - pre commit $criteria = array('appname' => 'property', 'location' => '.project', 'allrows' => true); $custom_functions = $GLOBALS['phpgw']->custom_functions->find($criteria); foreach ($custom_functions as $entry) { // prevent path traversal if (preg_match('/\\.\\./', $entry['file_name'])) { continue; } $file = PHPGW_SERVER_ROOT . "/property/inc/custom/{$GLOBALS['phpgw_info']['user']['domain']}/{$entry['file_name']}"; if ($entry['active'] && is_file($file) && !$entry['client_side'] && $entry['pre_commit']) { require_once $file; } } unset($entry); reset($custom_functions); if ($action == 'edit') { try { $receipt = $this->so->edit($project, $values_attribute); } catch (Exception $e) { if ($e) { phpgwapi_cache::message_set($e->getMessage(), 'error'); $receipt['id'] = $project['id']; } } if (isset($project['send_order']) && $project['send_order']) { $uiwo_hour = CreateObject('property.uiwo_hour'); foreach ($project['send_order'] as $_order_id) { try { $uiwo_hour->send_order($_order_id); } catch (Exception $e) { if ($e) { phpgwapi_cache::message_set($e->getMessage(), 'error'); } } } } } else { $receipt = $this->so->add($project, $values_attribute); } foreach ($custom_functions as $entry) { // prevent path traversal if (preg_match('/\\.\\./', $entry['file_name'])) { continue; } $file = PHPGW_SERVER_ROOT . "/property/inc/custom/{$GLOBALS['phpgw_info']['user']['domain']}/{$entry['file_name']}"; if ($entry['active'] && is_file($file) && !$entry['client_side'] && !$entry['pre_commit']) { require_once $file; } } return $receipt; }
private function update_ticket($id, $project, $values_attribute) { $_finnish_date = (int) $project['end_date']; if (!$_finnish_date) { return; } $finnish_date = $_finnish_date; $note = 'FerdigDato er automatisk til prosjekt sluttDato'; if ($project['b_account_id'] == 48) { //search for 2 working day delay for ($i = 2; $i < 10; $i++) { $finnish_date = $_finnish_date + 86400 * $i; $working_days = phpgwapi_datetime::get_working_days($_finnish_date, $finnish_date); if ($working_days == 2) { $note = 'FerdigDato er automatisk oppdatert til 2 virkedager etter prosjekt sluttDato'; break; } } } $this->db->query("SELECT status, finnish_date, finnish_date2 FROM fm_tts_tickets WHERE id='{$id}'", __LINE__, __FILE__); $this->db->next_record(); $status = $this->db->f('status'); /** * Kun oppdatere åpne meldinger */ if ($status == 'X') { return; } $oldfinnish_date = (int) $this->db->f('finnish_date'); $oldfinnish_date2 = (int) $this->db->f('finnish_date2'); $update = false; if ($oldfinnish_date && $finnish_date && $oldfinnish_date2 != $finnish_date) { $this->db->query("UPDATE fm_tts_tickets SET finnish_date2='{$finnish_date}' WHERE id='{$id}'", __LINE__, __FILE__); $old_value = $oldfinnish_date2; $update = true; } else { if (!$oldfinnish_date && $finnish_date && $oldfinnish_date != $finnish_date) { $this->db->query("UPDATE fm_tts_tickets SET finnish_date='{$finnish_date}' , finnish_date2='{$finnish_date}' WHERE id='{$id}'", __LINE__, __FILE__); $old_value = $oldfinnish_date; $update = true; } } if ($update) { $fields_updated = array('finnish_date'); $this->historylog->add('F', $id, $finnish_date, $old_value); $this->historylog->add('C', $id, $note); $this->botts->mail_ticket($id, $fields_updated, $receipt = array(), $project['location_code'], false, true); phpgwapi_cache::message_set(lang('finnish date changed'), 'message'); } }