Пример #1
0
 public function __construct()
 {
     trigger_error('phpgwapi_sbox2 is no longer used, please port your code to phpgw_sbox', E_USER_NOTICE);
     parent::__construct();
 }
Пример #2
0
$var = array('title' => lang('Calendar preferences'), 'action_url' => $phpgw->link('/' . $phpgw_info['flags']['currentapp'] . '/preferences.php'), 'bg_color' => $phpgw_info['theme']['th_bg'], 'submit_lang' => lang('submit'));
$p->set_var($var);
$p->set_var('text', ' ');
$p->parse('row', 'pref_colspan', True);
//	if ($totalerrors)
//	{
//		echo '<p><center>' . $phpgw->common->error_list($errors) . '</center>';
//	}
$str = '<input type="checkbox" name="mainscreen_showevents" value="True"' . ($phpgw_info['user']['preferences']['calendar']['mainscreen_showevents'] == 'Y' || $phpgw_info['user']['preferences']['calendar']['mainscreen_showevents'] == True ? ' checked' : '') . '>';
display_item(lang('show day view on main screen'), $str);
$t_weekday[$phpgw_info['user']['preferences']['calendar']['weekdaystarts']] = ' selected';
$str = '<select name="weekdaystarts">' . '<option value="Monday"' . $t_weekday['Monday'] . '>' . lang('Monday') . '</option>' . '<option value="Sunday"' . $t_weekday['Sunday'] . '>' . lang('Sunday') . '</option>' . '<option value="Saturday"' . $t_weekday['Saturday'] . '>' . lang('Saturday') . '</option>' . '</select>';
display_item(lang('weekday starts on'), $str);
$str = phpgwapi_sbox::hour_text('workdaystarts', $phpgw_info['user']['preferences']['calendar']['workdaystarts']);
display_item(lang('work day starts on'), $str);
$str = phpgwapi_sbox::hour_text('workdayends', $phpgw_info['user']['preferences']['calendar']['workdayends']);
display_item(lang('work day ends on'), $str);
$selected[$phpgw_info['user']['preferences']['calendar']['defaultcalendar']] = ' selected';
if (!isset($phpgw_info['user']['preferences']['calendar']['defaultcalendar'])) {
    $selected['month.php'] = ' selected';
}
$str = '<select name="defaultcalendar">' . '<option value="year.php"' . $selected['year.php'] . '>' . lang('Yearly') . '</option>' . '<option value="month.php"' . $selected['month.php'] . '>' . lang('Monthly') . '</option>' . '<option value="week.php"' . $selected['week.php'] . '>' . lang('Weekly') . '</option>' . '<option value="day.php"' . $selected['day.php'] . '>' . lang('Daily') . '</option>' . '</select>';
display_item(lang('default calendar view'), $str);
$selected = array();
$selected[$phpgw_info['user']['preferences']['calendar']['defaultfilter']] = ' selected';
if (!isset($phpgw_info['user']['preferences']['calendar']['defaultfilter']) || $phpgw_info['user']['preferences']['calendar']['defaultfilter'] == 'private') {
    $selected['private'] = ' selected';
}
$str = '<select name="defaultfilter">' . '<option value="all"' . $selected['all'] . '>' . lang('all') . '</option>' . '<option value="private"' . $selected['private'] . '>' . lang('private only') . '</option>' . '</select>';
display_item(lang('Default calendar filter'), $str);
$selected = array();
Пример #3
0
    private static function input_html($id, $namespace, $date, $format, $title)
    {
        $html = <<<HTML
\t\t\t<div id="{$id}-container" class="calendar_container">

HTML;
        $date_str = $date;
        //date(str_replace('M', 'm', $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']), $date);
        switch ($format) {
            case 'select':
                $posies = array_flip(self::get_date_pos());
                foreach ($posies as $pos) {
                    switch ($pos) {
                        case 'd':
                            $html .= phpgwapi_sbox::getDays($name, $selected = null);
                    }
                }
            case 'input':
            default:
                $html .= <<<HTML
\t\t\t\t\t<input type="text" id="{$id}" name="{$id}" value="{$date_str}" onchange="updateCalFromSelect('{$namespace}', '{$id}');">

HTML;
        }
        $img = $GLOBALS['phpgw']->common->image('phpgwapi', 'cal');
        $alt = lang('date selector trigger');
        $html .= <<<HTML
\t\t\t\t<img src="{$img}" alt="{$alt}" title="{$title}">
\t\t\t</div>

HTML;
        return $html;
    }
 /**
  * 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);
 }
Пример #5
0
 function edit()
 {
     $todo_id = isset($_REQUEST['todo_id']) ? (int) $_REQUEST['todo_id'] : 0;
     $cat_id = isset($_POST['cat_id']) ? (int) $_POST['cat_id'] : 0;
     $new_cat = isset($_POST['new_cat']) ? (int) $_POST['new_cat'] : 0;
     $values = isset($_POST['values']) ? (array) $_POST['values'] : array();
     $submit = isset($_POST['submit']) ? !!$_POST['submit'] : false;
     $new_parent = isset($_POST['new_parent']) ? $_POST['new_parent'] : 0;
     $parent = isset($_POST['parent']) ? (int) $_POST['parent'] : 0;
     $assigned = isset($_POST['assigned']) ? $_POST['assigned'] : 0;
     $assigned_group = isset($_POST['assigned_group']) ? $_POST['assigned_group'] : 0;
     if ($new_parent) {
         $parent = $new_parent;
     }
     if ($new_cat) {
         $cat_id = $new_cat;
     }
     if ($submit) {
         $values['cat'] = $cat_id;
         $values['parent'] = $parent;
         $values['id'] = $todo_id;
         if (is_array($assigned)) {
             $values['assigned'] = implode(',', $assigned);
             if (count($assigned) > 1) {
                 $values['assigned'] = ',' . $values['assigned'] . ',';
             }
         }
         if (is_array($assigned_group)) {
             $values['assigned_group'] = implode(',', $assigned_group);
             if (count($assigned_group) > 1) {
                 $values['assigned_group'] = ',' . $values['assigned_group'] . ',';
             }
         }
         $error = $this->botodo->check_values($values);
         if (is_array($error)) {
             $this->t->set_var('error', $GLOBALS['phpgw']->common->error_list($error));
         } else {
             $this->botodo->save($values, 'edit');
             $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'todo.uitodo.show_list', 'cat_id' => $cat_id));
             $GLOBALS['phpgw_info']['flags']['nodisplay'] = True;
             exit;
         }
     }
     $GLOBALS['phpgw']->common->phpgw_header(true);
     $this->t->set_file(array('todo_edit' => 'form.tpl'));
     $this->t->set_block('todo_edit', 'add', 'addhandle');
     $this->t->set_block('todo_edit', 'edit', 'edithandle');
     $this->set_app_langs();
     $this->t->set_var('actionurl', $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'todo.uitodo.edit', 'todo_id' => $todo_id)));
     $values = $this->botodo->read($todo_id);
     if ($values['parent'] != 0) {
         $this->t->set_var('lang_todo_action', lang('Edit sub project'));
     } else {
         $this->t->set_var('lang_todo_action', lang('Edit main project'));
     }
     $this->t->set_var('cat_list', $this->cats->formatted_list('select', 'all', $values['cat'], 'True'));
     $this->t->set_var('todo_list', $this->formatted_todo($values['parent']));
     $this->t->set_var('descr', $GLOBALS['phpgw']->strip_html($values['descr']));
     $this->t->set_var('title', $GLOBALS['phpgw']->strip_html($values['title']));
     $this->t->set_var('pri_list', phpgwapi_sbox::getPriority('values[pri]', $values['pri']));
     $this->t->set_var('stat_list', phpgwapi_sbox::getPercentage('values[status]', $values['status']));
     $this->t->set_var('user_list', $this->formatted_user($this->botodo->format_assigned($values['assigned']), 'accounts'));
     $this->t->set_var('group_list', $this->formatted_user($this->botodo->format_assigned($values['assigned_group']), 'groups'));
     if ($values['sdate'] == 0) {
         $values['sday'] = 0;
         $values['smonth'] = 0;
         $values['syear'] = 0;
     } else {
         $values['sday'] = date('d', $values['sdate']);
         $values['smonth'] = date('m', $values['sdate']);
         $values['syear'] = date('Y', $values['sdate']);
     }
     $this->t->set_var('start_select_date', $GLOBALS['phpgw']->common->dateformatorder(phpgwapi_sbox::getYears('values[syear]', $values['syear']), phpgwapi_sbox::getMonthText('values[smonth]', $values['smonth']), phpgwapi_sbox::getDays('values[sday]', $values['sday'])));
     if ($values['edate'] == 0) {
         $values['eday'] = 0;
         $values['emonth'] = 0;
         $values['eyear'] = 0;
     } else {
         $values['eday'] = date('d', $values['edate']);
         $values['emonth'] = date('m', $values['edate']);
         $values['eyear'] = date('Y', $values['edate']);
     }
     $this->t->set_var('end_select_date', $GLOBALS['phpgw']->common->dateformatorder(phpgwapi_sbox::getYears('values[eyear]', $values['eyear']), phpgwapi_sbox::getMonthText('values[emonth]', $values['emonth']), phpgwapi_sbox::getDays('values[eday]', $values['eday'])));
     $this->t->set_var('selfortoday', '&nbsp;');
     $this->t->set_var('lang_selfortoday', '&nbsp;');
     $this->t->set_var('lang_daysfromstartdate', '&nbsp;');
     $this->t->set_var('daysfromstartdate', '&nbsp;');
     $this->t->set_var('access_list', '<input type="checkbox" name="values[access]" value="True"' . ($values['access'] == 'private' ? ' checked' : '') . '>');
     if ($this->botodo->check_perms($this->grants[$values['owner']], PHPGW_ACL_DELETE) || $values['owner'] == $GLOBALS['phpgw_info']['user']['account_id']) {
         $this->t->set_var('delete', '<form method="POST" action="' . $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'todo.uitodo.delete', 'todo_id' => $values['id'])) . '"><input type="submit" value="' . lang('Delete') . '"></form>');
     } else {
         $this->t->set_var('delete', '&nbsp;');
     }
     $this->t->set_var('lang_submit', lang('Submit'));
     $this->t->set_var('edithandle', '');
     $this->t->set_var('addhandle', '');
     $this->t->pfp('out', 'todo_edit');
     $this->t->pfp('edithandle', 'edit');
 }