コード例 #1
0
 public function index()
 {
     if (!$this->acl_read) {
         echo lang('no access');
         $GLOBALS['phpgw']->common->phpgw_exit();
     }
     $app = phpgw::get_var('app', 'string', 'GET');
     //get session's values
     $data = phpgwapi_cache::session_get($app, 'id_debug');
     if (isset($data)) {
         //clear session
         phpgwapi_cache::session_clear($app, 'id_debug');
         //replace '<' and '>'
         if (is_array($data)) {
             self::_my_print_rec($data, 0);
         } else {
             $data = htmlspecialchars($data);
         }
         _debug_array($data);
     } else {
         echo "empty session's value";
     }
     $GLOBALS['phpgw']->common->phpgw_exit();
 }
コード例 #2
0
 public function view()
 {
     $GLOBALS['phpgw']->translation->add_app('property');
     $bo = CreateObject('property.botts');
     $ticketid = phpgw::get_var('id');
     $ticket = $bo->read_single($ticketid);
     $assignedto = $ticket['assignedto'];
     if (isset($assignedto) && $assignedto != '') {
         $assignedto_account = $GLOBALS['phpgw']->accounts->get($assignedto);
         //var_dump($assignedto_account);
         if ($assignedto_account) {
             $ticket['assigned_to_name'] = $assignedto_account->__toString();
         }
     }
     $contact_id = $ticket['contact_id'];
     if (isset($contact_id) && $contact_id != '') {
         $contacts = CreateObject('phpgwapi.contacts');
         $contact_data = $contacts->read_single_entry($contact_id, array('fn', 'tel_work', 'email'));
         $ticket['value_contact_name'] = $contact_data[0]['fn'];
         $ticket['value_contact_email'] = $contact_data[0]['email'];
         $ticket['value_contact_tel'] = $contact_data[0]['tel_work'];
     }
     $vendor_id = $ticket['vendor_id'];
     if (isset($vendor_id) && $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' => $vendor_id), $vendor_data);
         if (is_array($vendor_data)) {
             foreach ($vendor_data['attributes'] as $attribute) {
                 if ($attribute['name'] == 'org_name') {
                     $ticket['value_vendor_name'] = $attribute['value'];
                     break;
                 }
             }
         }
     }
     $notes = $bo->read_additional_notes($ticketid);
     //$history = $bo->read_record_history($ticketid);
     $tickethistory = array();
     foreach ($notes as $note) {
         if ($note['value_publish']) {
             $tickethistory[] = array('date' => $note['value_date'], 'user' => $note['value_user'], 'note' => $note['value_note']);
         }
     }
     /*
     			foreach($history as $story)
     			{
     				
     				 // String search for filtering out ticket history. If the status contains e.g. "Budget changed"
     				 // the history bullet will not be incuded in the ticket history shown to frontend users.
     				 
     				if(
     					(	
     						strpos($story['value_action'],'Budget changed') === false && 
     						strpos($story['value_action'],'Priority changed') === false &&
     						strpos($story['value_action'],'actual cost changed') === false &&
     						strpos($story['value_action'],'Billable hours changed') === false
     					)
     				)
     				{
     					$tickethistory[] = array(
     						'date' => $story['value_date'],
     						'user' => $story['value_user'],
     						'action'=> $story['value_action'],
     						'new_value' => $story['value_new_value'],
     						'old_value' => $story['value_old_value']
     					);
     				}
     			}*/
     usort($tickethistory, array($this, "cmp"));
     $i = 0;
     foreach ($tickethistory as $foo) {
         $tickethistory2['record' . $i] = $foo;
         $i++;
     }
     $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, 'ticketinfo' => array('ticket' => $ticket, 'tickethistory' => $tickethistory2));
     $GLOBALS['phpgw']->xslttpl->add_file(array('frontend', 'ticketview'));
     $GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('app_data' => $data));
 }
コード例 #3
0
 /**
  * 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);
 }
コード例 #4
0
    /**
     * Public method. 
     * 
     * @return unknown_type
     */
    public function index()
    {
        // Set the submit button label to its initial state
        $this->import_button_label = "Start import";
        $this->download_template_button_label = 'Download template';
        $check_method = 0;
        $get_identificator = false;
        if ($this->conv_type = phpgw::get_var('conv_type')) {
            $check_method++;
            $get_identificator = true;
        }
        if ($this->location_id = phpgw::get_var('location_id', 'int')) {
            $check_method++;
            $get_identificator = true;
        }
        if ($table = phpgw::get_var('table')) {
            $check_method++;
            $get_identificator = true;
        }
        if ($check_method > 1) {
            phpgwapi_cache::session_set('property', 'import_message', 'choose only one target!');
            $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'property.uiimport.index'));
        }
        phpgwapi_cache::session_set('property', 'import_settings', $_POST);
        $download_template = phpgw::get_var('download_template');
        if ($download_template) {
            $this->get_template($this->location_id);
        }
        // If the parameter 'importsubmit' exist (submit button in import form), set path
        if (phpgw::get_var("importsubmit")) {
            if ($GLOBALS['phpgw']->session->is_repost() && !phpgw::get_var('debug', 'bool')) {
                phpgwapi_cache::session_set('property', 'import_message', 'Hmm... looks like a repost!');
                $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'property.uiimport.index'));
            }
            $start_time = time();
            // Start time of import
            $start = date("G:i:s", $start_time);
            echo "<h3>Import started at: {$start}</h3>";
            echo "<ul>";
            if ($this->conv_type) {
                if (preg_match('/\\.\\./', $this->conv_type)) {
                    throw new Exception("Not a valid file: {$this->conv_type}");
                }
                $file = PHPGW_SERVER_ROOT . "/property/inc/import/{$GLOBALS['phpgw_info']['user']['domain']}/{$this->conv_type}";
                if (is_file($file)) {
                    require_once $file;
                }
            } else {
                require_once PHPGW_SERVER_ROOT . "/property/inc/import/import_update_generic.php";
            }
            $this->debug = phpgw::get_var('debug', 'bool');
            $this->import_conversion = new import_conversion($this->location_id, $this->debug);
            // Get the path for user input or use a default path
            $files = array();
            if (isset($_FILES['file']['tmp_name']) && $_FILES['file']['tmp_name']) {
                $files[] = array('name' => $_FILES['file']['tmp_name'], 'type' => $_FILES['file']['type']);
            } else {
                $path = phpgw::get_var('path', 'string');
                $files = $this->get_files($path);
            }
            if (!$files) {
                phpgwapi_cache::session_set('property', 'import_message', 'Ingen filer er valgt');
                $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'property.uiimport.index'));
            }
            foreach ($files as $file) {
                $valid_type = false;
                switch ($file['type']) {
                    case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
                    case 'application/vnd.oasis.opendocument.spreadsheet':
                    case 'application/vnd.ms-excel':
                        $this->csvdata = $this->getexceldata($file['name'], $get_identificator);
                        $valid_type = true;
                        break;
                    case 'text/csv':
                    case 'text/comma-separated-values':
                        $this->csvdata = $this->getcsvdata($file['name'], $get_identificator);
                        $valid_type = true;
                        break;
                    default:
                        throw new Exception("Not a valid filetype: {$file['type']}");
                }
                if ($valid_type) {
                    $result = $this->import();
                    $this->messages = array_merge($this->messages, $this->import_conversion->messages);
                    $this->warnings = array_merge($this->warnings, $this->import_conversion->warnings);
                    $this->errors = array_merge($this->errors, $this->import_conversion->errors);
                    $this->csvdata = array();
                    echo '<li class="info">Import: finished step ' . $result . '</li>';
                }
            }
            echo "</ul>";
            $end_time = time();
            $difference = ($end_time - $start_time) / 60;
            $end = date("G:i:s", $end_time);
            echo "<h3>Import ended at: {$end}. Import lasted {$difference} minutes.";
            if ($this->errors) {
                echo "<ul>";
                foreach ($this->errors as $error) {
                    echo '<li class="error">Error: ' . $error . '</li>';
                }
                echo "</ul>";
            }
            if ($this->warnings) {
                echo "<ul>";
                foreach ($this->warnings as $warning) {
                    echo '<li class="warning">Warning: ' . $warning . '</li>';
                }
                echo "</ul>";
            }
            if ($this->messages) {
                echo "<ul>";
                foreach ($this->messages as $message) {
                    echo '<li class="info">Message: ' . $message . '</li>';
                }
                echo "</ul>";
            }
            echo '<a href="' . $GLOBALS['phpgw']->link('/home.php') . '">Home</a>';
            echo '</br><a href="' . $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uiimport.index')) . '">Import</a>';
        } else {
            $import_settings = phpgwapi_cache::session_get('property', 'import_settings');
            $import_message = phpgwapi_cache::session_get('property', 'import_message');
            phpgwapi_cache::session_clear('property', 'import_message');
            $conv_list = $this->get_import_conv($import_settings['conv_type']);
            $conv_option = '<option value="">' . lang('none selected') . '</option>' . "\n";
            foreach ($conv_list as $conv) {
                $selected = '';
                if ($conv['selected']) {
                    $selected = 'selected =  "selected"';
                }
                $conv_option .= <<<HTML
\t\t\t\t\t<option value='{$conv['id']}'{$selected}>{$conv['name']}</option>
HTML;
            }
            $tables = $this->valid_tables;
            ksort($tables);
            $table_option = '<option value="">' . lang('none selected') . '</option>' . "\n";
            foreach ($tables as $table => $table_info) {
                $selected = $import_settings['table'] == $table ? 'selected =  "selected"' : '';
                $table_option .= <<<HTML
\t\t\t\t\t<option value='{$table}'{$selected}>{$table_info['name']}::{$table_info['permission']}</option>
HTML;
            }
            $entity = CreateObject('property.soadmin_entity');
            $entity_list = $entity->read(array('allrows' => true));
            $category_option = '<option value="">' . lang('none selected') . '</option>' . "\n";
            foreach ($entity_list as $entry) {
                $category_list = $entity->read_category_tree2($entry['id']);
                foreach ($category_list as $category) {
                    $selected = $import_settings['location_id'] == $category['location_id'] ? 'selected =  "selected"' : '';
                    $category_option .= <<<HTML
\t\t\t\t\t\t<option value="{$category['location_id']}"{$selected}>{$category['name']}</option>
HTML;
                }
            }
            $home = $GLOBALS['phpgw']->link('/home.php');
            $action = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uiimport.index'));
            $debug_checked = isset($import_settings['debug']) && $import_settings['debug'] ? 'checked =  "checked"' : '';
            $html = <<<HTML
\t\t\t\t<h1><img src="rental/templates/base/images/32x32/actions/document-save.png" /> Importer ( MsExcel / CSV )</h1>
\t\t\t\t<div id="messageHolder">{$import_message}</div>
\t\t\t\t<form action="{$action}" method="post" enctype="multipart/form-data">
\t\t\t\t\t<fieldset>
\t\t\t\t\t\t<p>
\t\t\t\t\t\t\t<label for="file">Choose file:</label>
\t\t\t\t\t\t\t<input type="file" name="file" id="file" title = 'Single file'/>
\t\t\t\t\t\t</p>
\t\t\t\t\t\t<p>
\t\t\t\t\t\t\t<label for="path">Local path:</label>
\t\t\t\t\t\t\t<input type="text" name="path" id="path" value = '{$import_settings['path']}' title = 'Alle filer i katalogen'/>
\t\t\t\t\t\t</p>
\t\t\t\t\t\t<p>
\t\t\t\t\t\t\t<label for="conv_type">Choose conversion:</label>
\t\t\t\t\t\t\t<select name="conv_type" id="conv_type">
\t\t\t\t\t\t\t{$conv_option}
\t\t\t\t\t\t</select>
\t\t\t\t\t\t</p>
\t\t\t\t\t\t<p>
\t\t\t\t\t\t\t<label for="table">Choose Table:</label>
\t\t\t\t\t\t\t<select name="table" id="table">
\t\t\t\t\t\t\t{$table_option}
\t\t\t\t\t\t</select>
\t\t\t\t\t\t</p>
\t\t\t\t\t\t<p>
\t\t\t\t\t\t\t<label for="category">Choose category:</label>
\t\t\t\t\t\t\t<select name="location_id" id="category">
\t\t\t\t\t\t\t{$category_option}
\t\t\t\t\t\t</select>
\t\t\t\t\t\t</p>

\t\t\t\t\t\t<p>
\t\t\t\t\t\t\t<label for="debug">Debug:</label>
\t\t\t\t\t\t\t<input type="checkbox" name="debug" id="debug" {$debug_checked} value ='1' />
\t\t\t\t\t\t</p>
\t\t\t\t\t\t<p>
\t\t\t\t\t\t\t<input type="submit" name="download_template" value="{$this->download_template_button_label}"  />
\t\t\t\t\t\t</p>
\t\t\t\t\t\t<p>
\t\t\t\t\t\t\t<input type="submit" name="importsubmit" value="{$this->import_button_label}"  />
\t\t\t\t\t\t</p>
\t\t \t\t\t</fieldset>
\t\t\t\t</form>
\t\t\t\t<br><a href='{$home}'>Home</a>
HTML;
            echo $html;
        }
    }
コード例 #5
0
 /**
  * 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) . '&amp;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));
 }
コード例 #6
0
 function index()
 {
     $receipt = array();
     $voucher_id = phpgw::get_var('voucher_id', 'int');
     $line_id = phpgw::get_var('line_id', 'int');
     if (phpgw::get_var('phpgw_return_as') == 'json') {
         return $this->query();
     }
     if (isset($this->config->config_data['invoice_acl']) && $this->config->config_data['invoice_acl'] == 'dimb') {
         $janitor_list = $this->bo->get_dimb_role_user(1, '', $janitor);
         $supervisor_list = $this->bo->get_dimb_role_user(2, '', $supervisor);
         $budget_responsible_list = $this->bo->get_dimb_role_user(3, '', $budget_responsible);
     } else {
         $janitor_list = $this->bocommon->get_user_list_right(32, $janitor, '.invoice');
         $supervisor_list = $this->bocommon->get_user_list_right(64, $supervisor, '.invoice');
         $budget_responsible_list = $this->bocommon->get_user_list_right(128, $budget_responsible, '.invoice');
     }
     $userlist_default = array();
     $userlist_default[] = array('id' => '*' . $GLOBALS['phpgw']->accounts->get($this->account_id)->lid, 'name' => lang('mine vouchers'));
     $userlist_default[] = array('id' => '', 'name' => lang('no user'));
     $voucher_list = array();
     if ($voucher_id) {
         $voucher_list = $this->bo->get_vouchers(array('query' => $voucher_id));
     }
     if (!$voucher_list) {
         $voucher_list = array('id' => '', 'name' => lang('select'));
     }
     foreach ($userlist_default as $default) {
         $janitor_list = array_merge(array($default), $janitor_list);
         $supervisor_list = array_merge(array($default), $supervisor_list);
         $budget_responsible_list = array_merge(array($default), $budget_responsible_list);
     }
     $msgbox_data = array();
     if (phpgw::get_var('phpgw_return_as') != 'json' && ($receipt = phpgwapi_cache::session_get('phpgwapi', 'phpgw_messages'))) {
         phpgwapi_cache::session_clear('phpgwapi', 'phpgw_messages');
         $msgbox_data = $GLOBALS['phpgw']->common->msgbox_data($receipt);
         $msgbox_data = $GLOBALS['phpgw']->common->msgbox($msgbox_data);
     }
     $user = $GLOBALS['phpgw']->accounts->get($GLOBALS['phpgw_info']['user']['id']);
     $myColumnDefs = array();
     $datavalues = array();
     $myButtons = array();
     $datavalues[] = array('name' => "0", 'values' => $this->query(), 'total_records' => 0, 'permission' => "''", 'is_paginator' => 1, 'edit_action' => "''", 'footer' => 0);
     $datatable = array(array('key' => 'id', 'hidden' => true), array('key' => 'approve_line', 'label' => lang('select'), 'sortable' => false, 'formatter' => 'FormatterCenter'), array('key' => 'status_line', 'label' => lang('status'), 'sortable' => false, 'formatter' => 'FormatterCenter'), array('key' => 'amount', 'label' => lang('amount'), 'formatter' => 'FormatterRight', 'sortable' => true), array('key' => 'approved_amount', 'label' => lang('approved amount'), 'sortable' => true, 'formatter' => 'FormatterRight'), array('key' => 'split', 'label' => lang('split line'), 'sortable' => false, 'formatter' => 'FormatterCenter'), array('key' => 'budget_account', 'label' => lang('budget account'), 'sortable' => false, 'formatter' => 'FormatterCenter'), array('key' => 'dima', 'label' => lang('dim a'), 'sortable' => false, 'formatter' => 'FormatterCenter'), array('key' => 'dimb', 'label' => lang('dim b'), 'sortable' => false, 'formatter' => 'FormatterCenter'), array('key' => 'order_id', 'label' => lang('order'), 'sortable' => false, 'formatter' => 'FormatterRight'), array('key' => 'dime', 'label' => lang('dime'), 'sortable' => false, 'formatter' => 'FormatterRight'), array('key' => 'project_group', 'label' => lang('project group'), 'sortable' => false, 'formatter' => 'FormatterRight'), array('key' => 'line_text', 'label' => lang('invoice line text'), 'sortable' => false, 'formatter' => 'FormatterCenter'), array('key' => 'approved_amount_hidden', 'hidden' => true));
     $myColumnDefs[0] = array('name' => "0", 'values' => json_encode($datatable));
     $criteria_list = array(array('id' => 'voucher_id', 'name' => lang('voucher id')), array('id' => 'invoice_id', 'name' => lang('invoice number')), array('id' => 'vendor_id', 'name' => lang('vendor')), array('id' => 'order_id', 'name' => lang('order id')), array('id' => 'b_account', 'name' => lang('budget account')), array('id' => 'dimb', 'name' => lang('dimb')));
     $data = array('td_count' => '""', 'base_java_url' => "{menuaction:'property.uiinvoice2.query'}", 'property_js' => json_encode($GLOBALS['phpgw_info']['server']['webserver_url'] . "/property/js/yahoo/property2.js"), 'email_base_url' => json_encode($GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uiinvoice2.index'), true, true)), 'datatable' => $datavalues, 'myColumnDefs' => $myColumnDefs, 'myButtons' => $myButtons, 'msgbox_data' => $msgbox_data, 'invoice_layout_config' => json_encode(execMethod('phpgwapi.template_portico.retrieve_local', 'invoice_layout_config')), 'preferences_url' => $GLOBALS['phpgw']->link('/preferences/index.php'), 'preferences_text' => lang('preferences'), 'home_url' => $GLOBALS['phpgw']->link('/home.php'), 'home_text' => lang('home'), 'home_icon' => 'icon icon-home', 'about_url' => $GLOBALS['phpgw']->link('/about.php', array('app' => $GLOBALS['phpgw_info']['flags']['currentapp'])), 'about_text' => lang('about'), 'logout_url' => $GLOBALS['phpgw']->link('/logout.php'), 'logout_text' => lang('logout'), 'user_fullname' => $user->__toString(), 'site_title' => "{$GLOBALS['phpgw_info']['server']['site_title']}", 'filter_form' => array('janitor_list' => array('options' => $janitor_list), 'supervisor_list' => array('options' => $supervisor_list), 'budget_responsible_list' => array('options' => $budget_responsible_list), 'criteria_list' => array('options' => $criteria_list)), 'filter_invoice' => array('voucher_list' => array('options' => $voucher_list)), 'voucher_info' => $this->get_single_line($line_id), 'update_action' => self::link(array('menuaction' => 'property.uiinvoice2.update_voucher')));
     //_debug_array($data);die();
     $GLOBALS['phpgw_info']['flags']['noframework'] = true;
     $GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/layout/assets/skins/sam/layout.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');
     phpgwapi_yui::load_widget('layout');
     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_jquery::load_widget('core');
     self::add_javascript('property', 'portico', 'ajax_invoice.js');
     self::add_javascript('property', 'yahoo', 'invoice2.index.js');
     self::add_javascript('phpgwapi', 'tinybox2', 'packed.js');
     $GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/tinybox2/style.css');
     $GLOBALS['phpgw']->xslttpl->add_file(array('invoice2'));
     $GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('data' => $data));
 }
コード例 #7
0
ファイル: navbar.inc.php プロジェクト: HaakonME/porticoestate
function parse_navbar($force = False)
{
    $navbar = array();
    $navbar = execMethod('phpgwapi.menu.get', 'navbar');
    $user = $GLOBALS['phpgw']->accounts->get($GLOBALS['phpgw_info']['user']['id']);
    $var = array('print_url' => strpos($_SERVER['REQUEST_URI'], '?') ? "{$_SERVER['REQUEST_URI']}&phpgw_return_as=noframes" : "{$_SERVER['REQUEST_URI']}?phpgw_return_as=noframes", 'print_text' => lang('print'), 'home_url' => $GLOBALS['phpgw']->link('/home.php'), 'home_text' => lang('home'), 'home_icon' => 'icon icon-home', 'about_url' => $GLOBALS['phpgw']->link('/about.php', array('app' => $GLOBALS['phpgw_info']['flags']['currentapp'])), 'about_text' => lang('about'), 'logout_url' => $GLOBALS['phpgw']->link('/logout.php'), 'logout_text' => lang('logout'), 'user_fullname' => $user->__toString());
    if ($GLOBALS['phpgw']->acl->check('run', PHPGW_ACL_READ, 'preferences')) {
        $var['preferences_url'] = $GLOBALS['phpgw']->link('/preferences/index.php');
        $var['preferences_text'] = lang('preferences');
    }
    if (isset($GLOBALS['phpgw_info']['user']['apps']['manual'])) {
        $var['help_url'] = "javascript:openwindow('" . $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'manual.uimanual.help', 'app' => $GLOBALS['phpgw_info']['flags']['currentapp'], 'section' => isset($GLOBALS['phpgw_info']['apps']['manual']['section']) ? $GLOBALS['phpgw_info']['apps']['manual']['section'] : '', 'referer' => phpgw::get_var('menuaction'))) . "','700','600')";
        $var['help_text'] = lang('help');
        $var['help_icon'] = 'icon icon-help';
    }
    if (isset($GLOBALS['phpgw_info']['server']['support_address']) && $GLOBALS['phpgw_info']['server']['support_address']) {
        $var['support_url'] = "javascript:openwindow('" . $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'manual.uisupport.send', 'app' => $GLOBALS['phpgw_info']['flags']['currentapp'])) . "','700','600')";
        $var['support_text'] = lang('support');
        $var['support_icon'] = 'icon icon-help';
    }
    if (isset($GLOBALS['phpgw_info']['user']['apps']['admin'])) {
        $var['debug_url'] = "javascript:openwindow('" . $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uidebug_json.index', 'app' => $GLOBALS['phpgw_info']['flags']['currentapp'])) . "','','')";
        $var['debug_text'] = lang('debug');
        $var['debug_icon'] = 'icon icon-debug';
    }
    $GLOBALS['phpgw']->template->set_root(PHPGW_TEMPLATE_DIR);
    $GLOBALS['phpgw']->template->set_file('navbar', 'navbar.tpl');
    $flags =& $GLOBALS['phpgw_info']['flags'];
    $var['current_app_title'] = isset($flags['app_header']) ? $flags['app_header'] : lang($GLOBALS['phpgw_info']['flags']['currentapp']);
    $flags['menu_selection'] = isset($flags['menu_selection']) ? $flags['menu_selection'] : '';
    // breadcrumbs
    $current_url = array('id' => $flags['menu_selection'], 'url' => phpgw::get_var('REQUEST_URI', 'string', 'SERVER'), 'name' => $var['current_app_title']);
    $breadcrumbs = phpgwapi_cache::session_get('phpgwapi', 'breadcrumbs');
    $breadcrumbs = $breadcrumbs ? $breadcrumbs : array();
    // first one
    if ($breadcrumbs[0]['id'] != $flags['menu_selection']) {
        array_unshift($breadcrumbs, $current_url);
    }
    if (count($breadcrumbs) >= 5) {
        array_pop($breadcrumbs);
    }
    phpgwapi_cache::session_set('phpgwapi', 'breadcrumbs', $breadcrumbs);
    $breadcrumbs = array_reverse($breadcrumbs);
    $navigation = array();
    if (!isset($GLOBALS['phpgw_info']['user']['preferences']['property']['nonavbar']) || $GLOBALS['phpgw_info']['user']['preferences']['property']['nonavbar'] != 'yes') {
        prepare_navbar($navbar);
    } else {
        foreach ($navbar as &$app_tmp) {
            $app_tmp['text'] = ' ...';
        }
    }
    if (isset($GLOBALS['phpgw_info']['user']['preferences']['common']['sidecontent']) && $GLOBALS['phpgw_info']['user']['preferences']['common']['sidecontent'] == 'ajax_menu') {
        $exclude = array('logout', 'about', 'preferences');
        $i = 1;
        foreach ($navbar as $app => $app_data) {
            if (in_array($app, $exclude)) {
                continue;
            }
            $applications[] = array('value' => array('id' => $i, 'app' => $app, 'label' => $app_data['text'], 'href' => str_replace('&amp;', '&', $app_data['url'])), 'children' => array());
            $mapping[$i] = array('id' => $i, 'name' => $app, 'expanded' => false, 'highlight' => $app == $currentapp ? true : false, 'is_leaf' => false);
            $i++;
        }
        $applications = json_encode($applications);
        $mapping = json_encode($mapping);
        $_menu_selection = str_replace('::', '|', $GLOBALS['phpgw_info']['flags']['menu_selection']);
        $var['treemenu'] = <<<HTML
\t\t\t\t<div id="MenutreeDiv1"></div>
\t\t\t\t<script type="text/javascript">
\t\t \t\t\tvar apps = {$applications};
\t\t\t\t\tvar mapping = {$mapping};
\t\t\t\t\tvar proxy_data = ['first_element_is_dummy'];
\t\t\t\t\tvar menu_selection = '{$_menu_selection}';
\t\t\t\t</script>
HTML;
    } else {
        //			prepare_navbar($navbar);
        $navigation = execMethod('phpgwapi.menu.get', 'navigation');
        $treemenu = '';
        foreach ($navbar as $app => $app_data) {
            if (!in_array($app, array('logout', 'about', 'preferences'))) {
                $submenu = isset($navigation[$app]) ? render_submenu($app, $navigation[$app]) : '';
                $treemenu .= render_item($app_data, "navbar::{$app}", $submenu);
            }
        }
        $var['treemenu'] = <<<HTML
\t\t\t<ul id="navbar">
{$treemenu}
\t\t\t</ul>

HTML;
    }
    if (isset($GLOBALS['phpgw_info']['user']['preferences']['common']['sidecontent']) && $GLOBALS['phpgw_info']['user']['preferences']['common']['sidecontent'] == 'jsmenu') {
        $var['treemenu'] .= <<<JS
\t\t\t\t<script type="text/javascript">
\t\t\t\t\$(function() {
\t\t\t\t\$("#navbar").menu();
\t\t\t});
\t\t\t</script>
JS;
    }
    $GLOBALS['phpgw']->template->set_var($var);
    $GLOBALS['phpgw']->template->pfp('out', 'navbar');
    if (phpgw::get_var('phpgw_return_as') != 'json' && ($global_message = phpgwapi_cache::system_get('phpgwapi', 'phpgw_global_message'))) {
        echo "<div class='msg_good'>";
        echo nl2br($global_message);
        echo '</div>';
    }
    if (phpgw::get_var('phpgw_return_as') != 'json' && $breadcrumbs && isset($GLOBALS['phpgw_info']['user']['preferences']['common']['show_breadcrumbs']) && $GLOBALS['phpgw_info']['user']['preferences']['common']['show_breadcrumbs']) {
        $history_url = array();
        foreach ($breadcrumbs as $breadcrumb) {
            $history_url[] = "<a href='{$breadcrumb['url']}'>{$breadcrumb['name']}</a>";
        }
        $breadcrumbs = '<div class="breadcrumbs"><h4>' . implode(' >> ', $history_url) . '</h4></div>';
        echo $breadcrumbs;
    }
    if (phpgw::get_var('phpgw_return_as') != 'json' && ($receipt = phpgwapi_cache::session_get('phpgwapi', 'phpgw_messages'))) {
        phpgwapi_cache::session_clear('phpgwapi', 'phpgw_messages');
        $msgbox_data = $GLOBALS['phpgw']->common->msgbox_data($receipt);
        $msgbox_data = $GLOBALS['phpgw']->common->msgbox($msgbox_data);
        foreach ($msgbox_data as &$message) {
            echo "<div class='{$message['msgbox_class']}'>";
            echo $message['msgbox_text'];
            echo '</div>';
        }
    }
    $GLOBALS['phpgw']->hooks->process('after_navbar');
    register_shutdown_function('parse_footer_end');
}
コード例 #8
0
 function import_calculation()
 {
     $GLOBALS['phpgw_info']['flags']['noframework'] = true;
     $workorder_id = phpgw::get_var('workorder_id');
     if ($_FILES) {
         $this->_import_calculation($workorder_id);
         $bofiles = CreateObject('property.bofiles');
         $file_name = @str_replace(' ', '_', $_FILES['file']['name']);
         $to_file = "{$bofiles->fakebase}/workorder/{$workorder_id}/{$file_name}";
         if ($bofiles->vfs->file_exists(array('string' => $to_file, 'relatives' => array(RELATIVE_NONE)))) {
             phpgwapi_cache::message_set(lang('This file already exists !'), 'error');
         } else {
             $bofiles->create_document_dir("workorder/{$workorder_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)))) {
                 phpgwapi_cache::message_set(lang('Failed to upload file !'), 'error');
             }
             $bofiles->vfs->override_acl = 0;
         }
     }
     if ($receipt = phpgwapi_cache::session_get('phpgwapi', 'phpgw_messages')) {
         phpgwapi_cache::session_clear('phpgwapi', 'phpgw_messages');
     }
     $data = array('redirect' => $redirect ? $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uiinvoice.list_sub', 'user_lid' => $user_lid, 'voucher_id' => $voucher_id, 'paid' => $paid)) : null, 'msgbox_data' => $GLOBALS['phpgw']->common->msgbox($GLOBALS['phpgw']->common->msgbox_data($receipt)), 'form_action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'property.uiwo_hour.import_calculation')), 'workorder_id' => $workorder_id);
     $GLOBALS['phpgw']->xslttpl->add_file('wo_hour');
     $GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('import_calculation' => $data));
 }
コード例 #9
0
 /**
  * Import Facilit data to Portico Estate's rental module
  * The function assumes CSV files have been uploaded to a location on the server reachable by the
  * web server user.  The CSV files must correspond to the table names from Facilit, as exported
  * from Access. Field should be enclosed in single quotes and separated by comma.  The CSV files
  * must contain the column headers on the first line.
  * 
  * @return unknown_type
  */
 public function import()
 {
     $steps = 7;
     /* Import logic:
      * 
      * 1. Do step logic if the session variable is not set
      * 2. Set step result on session
      * 3. Set label for import button
      * 4. Log messages for this step
      *  
      */
     $this->messages = array();
     $this->warnings = array();
     $this->errors = array();
     // Import contract parties if not done before and put them on the users session
     if (!phpgwapi_cache::session_get('rental', 'facilit_parties')) {
         phpgwapi_cache::session_set('rental', 'facilit_parties', $this->import_parties());
         $this->log_messages(1);
         return '1';
     }
     // Import composites if not done before and put them on the users session
     if (!phpgwapi_cache::session_get('rental', 'facilit_composites')) {
         phpgwapi_cache::session_set('rental', 'facilit_composites', $this->import_composites());
         $this->log_messages(2);
         return '2';
     }
     // Load composite to contract link table if not done before and put them on the users session
     if (!phpgwapi_cache::session_get('rental', 'facilit_rentalobject_to_contract')) {
         phpgwapi_cache::session_set('rental', 'facilit_rentalobject_to_contract', $this->import_rentalobject_to_contract());
         $this->log_messages(3);
         return '3';
     }
     // Import contracts if not done before and put them on the users session
     // Prerequisites: Composites, parties, contract to composite bindings, and default values for accounts/project number for
     if (!phpgwapi_cache::session_get('rental', 'facilit_contracts')) {
         $composites = phpgwapi_cache::session_get('rental', 'facilit_composites');
         $rentalobject_to_contract = phpgwapi_cache::session_get('rental', 'facilit_rentalobject_to_contract');
         $parties = phpgwapi_cache::session_get('rental', 'facilit_parties');
         $location_id = $this->location_id;
         $defalt_values['account_in'] = rental_socontract::get_instance()->get_default_account($location_id, true);
         //IN
         $defalt_values['account_out'] = rental_socontract::get_instance()->get_default_account($location_id, false);
         //OUT
         $defalt_values['project_number'] = rental_socontract::get_instance()->get_default_project_number($location_id);
         //PROJECTNUMBER
         phpgwapi_cache::session_set('rental', 'facilit_contracts', $this->import_contracts($composites, $rentalobject_to_contract, $parties, $defalt_values));
         $this->log_messages(4);
         return '4';
     }
     // Import price items if not done before and put them on the users session
     // Prerequisites: Contracts
     if (!phpgwapi_cache::session_get('rental', 'facilit_contract_price_items')) {
         $contracts = phpgwapi_cache::session_get('rental', 'facilit_contracts');
         phpgwapi_cache::session_set('rental', 'facilit_contract_price_items', $this->import_contract_price_items($contracts));
         $this->log_messages(5);
         return '5';
     }
     // Import events if not done before and put them on the users session
     // Prerequistes: Contracts
     if (!phpgwapi_cache::session_get('rental', 'facilit_events')) {
         $contracts = phpgwapi_cache::session_get('rental', 'facilit_contracts');
         $event_data = phpgwapi_cache::session_get('rental', 'facilit_events');
         $regulation_id_location_id = isset($event_data) ? $event_data : array();
         phpgwapi_cache::session_set('rental', 'facilit_events', $this->import_events($contracts, $regulation_id_location_id));
         $this->log_messages(6);
         return '6';
     }
     // Import adjustments
     // Prerequistes: Contracts
     if (!phpgwapi_cache::session_get('rental', 'facilit_adjustments')) {
         $contracts = phpgwapi_cache::session_get('rental', 'facilit_contracts');
         $event_data = phpgwapi_cache::session_get('rental', 'facilit_events');
         $regulation_id_location_id = isset($event_data) ? $event_data : array();
         $this->import_adjustments($contracts, $regulation_id_location_id);
         $this->log_messages(7);
         $this->clean_up();
     }
     // We're done with the import, so clear all session variables so we're ready for a new one
     // We do not clear parties (same for all responsibility areas)
     // We do not clear event data, the array is just added for each
     phpgwapi_cache::session_clear('rental', 'facilit_composites');
     phpgwapi_cache::session_clear('rental', 'facilit_rentalobject_to_contract');
     phpgwapi_cache::session_clear('rental', 'facilit_contracts');
     phpgwapi_cache::session_clear('rental', 'facilit_contract_price_items');
     phpgwapi_cache::session_clear('rental', 'facilit_events');
     phpgwapi_cache::session_clear('rental', 'facilit_adjustments');
     return '7';
 }
コード例 #10
0
 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));
     }
 }
コード例 #11
0
 function get_tabs()
 {
     // Get tabs from location hierarchy
     // tabs [location identidier] = {label => ..., link => ...}
     $locations = frontend_bofrontend::get_sections();
     $tabs = array();
     foreach ($locations as $key => $entry) {
         $name = $entry['name'];
         $location = $entry['location'];
         if ($GLOBALS['phpgw']->acl->check($location, PHPGW_ACL_READ, 'frontend')) {
             $location_id = $GLOBALS['phpgw']->locations->get_id('frontend', $location);
             $tabs[$location_id] = array('label' => lang($name), 'link' => $GLOBALS['phpgw']->link('/', array('menuaction' => "frontend.ui{$name}.index", 'location_id' => $location_id, 'noframework' => $noframework)));
         }
         unset($location);
     }
     // this one is for generic entitysupport from the app 'property'
     $entity_frontend = isset($this->config->config_data['entity_frontend']) && $this->config->config_data['entity_frontend'] ? $this->config->config_data['entity_frontend'] : array();
     if ($entity_frontend) {
         $entity = CreateObject('property.soadmin_entity');
     }
     foreach ($entity_frontend as $location) {
         if ($GLOBALS['phpgw']->acl->check($location, PHPGW_ACL_READ, 'property')) {
             $location_id = $GLOBALS['phpgw']->locations->get_id('property', $location);
             $location_arr = explode('.', $location);
             $category = $entity->read_single_category($location_arr[2], $location_arr[3]);
             $tabs[$location_id] = array('label' => $category['name'], 'link' => $GLOBALS['phpgw']->link('/', array('menuaction' => "frontend.uientity.index", 'location_id' => $location_id, 'noframework' => $noframework)));
         }
     }
     $extra_tabs = phpgwapi_cache::session_get('frontend', 'extra_tabs');
     if (isset($extra_tabs)) {
         $tabs = array_merge($extra_tabs, $tabs);
     }
     phpgwapi_cache::session_clear('frontend', 'extra_tabs');
     return $tabs;
 }
コード例 #12
0
 protected function clear_user_orgnr_from_session()
 {
     phpgwapi_cache::session_clear($this->get_module(), self::ORGNR_SESSION_KEY);
 }
 public function edit_location()
 {
     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->so_control->register_control_to_location($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' => 'controller.uicontrol_register_to_location.index'));
     }
 }
コード例 #14
0
 /**
  * Delete the phpgw_info cache data for a user
  *
  * @param integer $ignored this value isn't used
  *
  * @return void
  * @deprecated see phpgwapi_cache::session_clear()
  */
 public function delete_cache($ignored = null)
 {
     phpgwapi_cache::session_clear('phpgwapi', 'phpgw_info');
 }
コード例 #15
0
 /**
  * Import Facilit data to Portico Estate's rental module
  * The function assumes CSV files have been uploaded to a location on the server reachable by the
  * web server user.  The CSV files must correspond to the table names from Facilit, as exported
  * from Access. Field should be enclosed in single quotes and separated by comma.  The CSV files
  * must contain the column headers on the first line.
  * 
  * @return unknown_type
  */
 public function import()
 {
     $steps = 1;
     /* Import logic:
      * 
      * 1. Do step logic if the session variable is not set
      * 2. Set step result on session
      * 3. Set label for import button
      * 4. Log messages for this step
      *  
      */
     $this->messages = array();
     $this->warnings = array();
     $this->errors = array();
     // Import arenas if not done before and put them on the users session
     if (!phpgwapi_cache::session_get('activitycalendar', 'arenas')) {
         phpgwapi_cache::session_set('activitycalendar', 'arenas', $this->import_organizations());
         $this->log_messages(1);
         return '1';
         $this->clean_up();
     }
     // We're done with the import, so clear all session variables so we're ready for a new one
     // We do not clear parties (same for all responsibility areas)
     // We do not clear event data, the array is just added for each
     phpgwapi_cache::session_clear('activitycalendar', 'arenas');
     return '1';
 }