Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 686

Přidáno uživatelem Michal Kliment před více než 14 roky(ů)

Dalsi pokracovani na hlasovani - pridana tarka kompletni sprava hlasovacich sablon (pridavani, editovani, mazani) a jejich polozek (pridavani, editovani, mazani, zmena priorit).

Zobrazit rozdíly:

freenetis/trunk/kohana/application/i18n/cs_CZ/texts.php
'add new account' => 'Přidat nový účet',
'add new admin' => 'Přidat nového správce',
'add new approval template' => 'Přidat novou hlasovací šablonu',
'add new approval template item' => 'Přidat novou položku hlasovací šablony',
'add new approval type' => 'Přidat nový hlasovací typ',
'add new backup' => 'Přidat novou zálohu',
'add new bank account' => 'Přidat nový bankovní účet',
......
'back to ip address' => 'Zpět na IP adresu',
'back to ip addresses list' => 'Zpět na seznam IP adres',
'back to list' => 'Zpět na seznam',
'back to list of all approval templates' => 'Zpět na seznam všech schvalovacích šablon',
'back to list of all approval types' => 'Zpět na seznam všech schvalovacích typů',
'back to list of all approval templates' => 'Zpět na seznam všech hlasovacích šablon',
'back to list of all approval types' => 'Zpět na seznam všech hlasovacích typů',
'back to list of all address points' => 'Zpět na seznam všech adresních bodů',
'back to list of all confirmed works' => 'Zpět na seznam všech potvrzených prací',
'back to list of all devices' => 'Zpět na seznam všech zařízení',
......
'back to profile of association' => 'Zpět na profil sdružení',
'back to project accounts' => 'Zpět na projektové účty',
'back to segments list' => 'Zpět na seznam segmentů',
'back to the approval template' => 'Zpátky k hlasovací šabloně',
'back to the approval type' => 'Zpátky k hlasovacímu typu',
'back to the cloud list' => 'Zpět na seznam oblastí',
'back to the double-entry accounts' => 'Zpět na podvojné účty',
......
'edit' => 'Upravit',
'edit account' => 'Upravit účet',
'edit address point' => 'Upravit adresní bod',
'edit approval type' => 'Upravit schvalovací typ',
'edit approval template' => 'Upravit hlasovací šablonu',
'edit approval template item' => 'Upravit položku hlasovací šablony',
'edit approval type' => 'Upravit hlasovací typ',
'edit cloud' => 'Upravit oblast',
'edit device' => 'Upravit zařízení',
'edit device admin' => 'Upravit správce zařízení',
......
'it is not possible vote about locked work' => 'Není možné hlasovat o zamčené práci.',
'it is possible to deduct fees only in one year' => 'Členské příspěvky je možné strhávat jen v rámci jednoho roku.',
'it\'s not possible to write your htacess file for clean urls' => 'Není možné zapsat váš soubor .htacess pro čistá URL.',
'item' => 'Položka',
'item number' => 'Položka č.',
'item separator' => 'Oddělovač položek',
'item(s) have been successfully added' => 'položka(ek) bylo úspěšně přidáno',
......
'limit of member' => 'Limit člena',
'limit has been successfully changed' => 'Limit byl úspěšně změněn.',
'list of all address points' => 'Seznam všech adresních bodů',
'list of all approval templates' => 'Seznam všech schvalovacích šablon',
'list of all approval types' => 'Seznam všech schvalovacích typů',
'list of all approval templates' => 'Seznam všech hlasovacích šablon',
'list of all approval types' => 'Seznam všech hlasovacích typů',
'list of all approved works' => 'Seznam všech schválených prací',
'list of all backups' => 'Seznam všech záloh konfigurací',
'list of all calls' => 'Výpis všech hovorů',
......
'segments' => 'Segmenty',
'select' => 'Vyber',
'select action' => 'Vyber činnost',
'select approval type' => 'Vyber hlasovací typ',
'select area' => 'Vyber oblast',
'select area prefix' => 'Vyber prefix oblasti',
'select cloud' => 'Vyber oblast',
......
'show all transfers on the account' => 'Ukaž všechny převody tohoto účtu',
'show all unconfirmed works' => 'Zobraz všechnny nepotvrzené práce',
'show answer for this message' => 'Zobrazit odpověď na tuto zprávu',
'show approval template' => 'Zobrazit schvalovací šablonu',
'show approval type' => 'Zobrazit schvalovací typ',
'show approval template' => 'Zobrazit hlasovací šablonu',
'show approval type' => 'Zobrazit hlasovací typ',
'show clouds' => 'Zobrazit oblasti',
'show devices' => 'Zobrazit zařízení',
'show help' => 'Zobrazit nápovědu',
......
'template' => 'Šablona',
'template has been successfully added' => 'Šablona byla úspěšně přidána.',
'template has been successfully updated' => 'Šablona byla úspěšně upravena.',
'template items' => 'Položky šablony',
'template name' => 'Název šablony',
'tenth-degree certified engineers' => 'Certifikování technici desátého stupně',
'terminating call' => 'Příchozí volání',
......
'there are no items yet' => 'Neobsahuje žádné záznamy.',
'third-degree certified engineers' => 'Certifikovaní technici třetího stupně',
'this account does not exist' => 'Tento účet neexistuje.',
'this approval template already contains approval type with the same priority' => 'Tato hlasovací šablona již obsahuje hlasovací typ se stejnou prioritou.',
'this approval template already contains this approval type' => 'Tato hlasovací šablona již obsahuje tento hlasovací typ.',
'this month has been already deducted!' => 'Tento měsíc už byl stržen!',
'time' => 'Čas',
'time deposits' => 'Termínované vklady',
freenetis/trunk/kohana/application/models/approval_template_item.php
ORDER BY i.priority');
}
public function get_lowest_priority_of_template($template_id)
{
$query = self::$db->query('SELECT min(priority) AS min FROM approval_template_items GROUP BY approval_template_id HAVING approval_template_id = '.$template_id);
if (!$query)
return NULL;
return $query->current()->min;
}
public function get_highest_priority_of_template($template_id)
{
$query = self::$db->query('SELECT max(priority) AS max FROM approval_template_items GROUP BY approval_template_id HAVING approval_template_id = '.$template_id);
if (!$query)
return NULL;
return $query->current()->max;
}
}
?>
freenetis/trunk/kohana/application/controllers/work_reports.php
tbody.appendChild(new_tr);
var new_a = document.createElement("a");
new_th.appendChild(new_a);
var new_text = document.createTextNode("Přidat novou práci");
var new_text = document.createTextNode("'.url_lang::lang('texts.Add new work').'");
new_a.appendChild(new_text);
new_a.setAttribute("href", "#");
new_a.setAttribute("onclick", "return add_work_row("+i+", new Array(\''.url_lang::lang('texts.Work').'\', \''.url_lang::lang('texts.Description').'\', \''.url_lang::lang('texts.Date').'\', \''.url_lang::lang('texts.Hours').'\', \''.url_lang::lang('texts.Km').'\', \''.url_lang::lang('texts.Suggest amount').'\'));");
freenetis/trunk/kohana/application/controllers/approval_templates.php
if (!$approval_template_id || !is_numeric($approval_template_id))
Controller::warning(PARAMETER);
$approval_template = new Approval_template_Model($approval_template_id);
$this->approval_template = new Approval_template_Model($approval_template_id);
if (!$approval_template->id)
if (!$this->approval_template->id)
Controller::error(RECORD);
$approval_template_item_model = new Approval_template_item_Model();
$approval_template_items = $approval_template_item_model->get_all_items_by_template_id($approval_template->id);
$approval_template_items = $approval_template_item_model->get_all_items_by_template_id($this->approval_template->id);
// create grid
$items_grid = new Grid(url_lang::base().'approval_templates/show/'.$approval_template->id, '', array(
$items_grid = new Grid(url_lang::base().'approval_templates/show/'.$this->approval_template->id, '', array(
//'separator' => '',
'use_paginator' => false,
'use_selector' => false,
'total_items' => count ($approval_template_items)
));
$items_grid->add_new_button(url_lang::base().'approval_template_items/add/'.$this->approval_template->id, url_lang::lang('texts.Add new approval template item'));
$items_grid->field('type_id')->label(url_lang::lang('texts.Id'));
$items_grid->callback_field('name')->label(url_lang::lang('texts.Name'))->callback('Approval_types_Controller::name_field');
$items_grid->callback_field('group_id')->label(url_lang::lang('texts.Group'))->callback('Approval_types_Controller::group_field');
$items_grid->callback_field('type')->label(url_lang::lang('texts.Type'))->callback('Approval_types_Controller::type_field');
$items_grid->callback_field('interval')->label(url_lang::lang('texts.Interval'))->callback('Approval_types_Controller::interval_field');
$items_grid->callback_field('min_suggest_amount')->label(url_lang::lang('texts.Minimal suggest amount'))->callback('Approval_types_Controller::min_suggest_amount_field');
$items_grid->field('priority')->label(url_lang::lang('texts.Priority'));
$items_grid->callback_field('priority')->label(url_lang::lang('texts.Priority'))->callback('Approval_templates_Controller::priority_field');
$items_grid->action_field('id')->label(url_lang::lang('texts.Item'))->url(url_lang::base().'approval_template_items/edit')->action(url_lang::lang('texts.Edit'))->class('center');
$items_grid->action_field('id')->label(url_lang::lang('texts.Item'))->url(url_lang::base().'approval_template_items/delete')->action(url_lang::lang('texts.Delete'))->class('delete_link center');
$items_grid->datasource($approval_template_items);
$view = new View('main');
$view->title = url_lang::lang('texts.Show approval template');
$view->content = new View('approval_templates_show');
$view->content->approval_template = $approval_template;
$view->content->approval_template = $this->approval_template;
$view->content->items_grid = $items_grid;
$view->render(TRUE);
}
public function add()
{
// creates form
$form = new Forge(url_lang::base().'approval_templates/add', '', 'POST', array('id' => 'article_form'));
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
$form->group('')->label(url_lang::lang('texts.Basic information'));
$form->input('name')->label(url_lang::lang('texts.Name').':')->rules('required|length[0,100]');
$form->textarea('comment')->label(url_lang::lang('texts.Comment').':')->rules('length[0,65535]');
$form->submit('submit')->value(url_lang::lang('texts.Save'));
special::required_forge_style($form, ' *', 'required');
if ($form->validate())
{
$form_data = $form->as_array();
$approval_template = new Approval_template_Model();
$approval_template->name = $form_data['name'];
$approval_template->comment = $form_data['comment'];
$approval_template->save();
url::redirect(url_lang::base().'approval_templates/show/'.$approval_template->id);
}
$view = new View('main');
$view->title = url_lang::lang('texts.Add new approval template');
$view->content = new View('form');
$view->content->headline = url_lang::lang('texts.Add new approval template');
$view->content->link_back = html::anchor(url_lang::base().'approval_templates/show_all', url_lang::lang('texts.Back to list of all approval templates'));
$view->content->form = '';
$view->content->form = $form->html();
$view->render(TRUE);
}
......
{
echo $item->comment;
}
public static function priority_field($item, $name)
{
echo $item->priority;
echo '  ';
$approval_template_item_model = new Approval_template_item_Model();
if ($item->priority > $approval_template_item_model->get_lowest_priority_of_template($item->approval_template_id))
echo html::anchor(url_lang::base().'approval_template_items/move_up/'.$item->id, html::image(url::base().'media/images/uparrow.png'));
echo '&nbsp';
if ($item->priority < $approval_template_item_model->get_highest_priority_of_template($item->approval_template_id))
echo html::anchor(url_lang::base().'approval_template_items/move_down/'.$item->id, html::image(url::base().'media/images/downarrow.png'));
}
}
freenetis/trunk/kohana/application/controllers/approval_types.php
}
// form
$form = new Forge(url_lang::base().'approval_types/add', '', 'POST', array('id' => 'article_form'));
$form = new Forge(url::base().url::current(TRUE), '', 'POST', array('id' => 'article_form'));
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
$form->group('')->label(url_lang::lang('texts.Basic information'));
......
$approval_type->save();
$this->session->set_flash('message', url_lang::lang('texts.Approval type has been successfully added.'));
url::redirect(url_lang::base().'approval_types/show/'.$approval_type->id);
// for popup adding
if ($this->popup)
{
echo "<script type=text/javascript>";
echo "var approval_type = opener.document.getElementById('approval_type_id');";
echo "approval_type.options[approval_type.options.length] = new Option('".$approval_type->name."', '".$approval_type->id."', true);";
echo "approval_type.selectedIndex = approval_type.options.length-1;";
echo "self.close();";
echo "</script>";
}
// classic addijng
else
url::redirect(url_lang::base().'approval_types/show/'.$approval_type->id);
}
$view = new View('main');
freenetis/trunk/kohana/application/controllers/approval_template_items.php
<?php
/**
*
* @author Michal Kliment
* @copyright (c) 2010 Kliment Michal
* @license GNU GPLv3
* @license http://www.gnu.org/licenses/gpl.txt
*/
class Approval_template_items_Controller extends Controller
{
private $approval_template = NULL;
private $approval_template_item = NULL;
public function index()
{
url::redirect(url_lang::base().'approval_template_items/show_all');
}
public function add($approval_template_id = NULL)
{
if (!$approval_template_id || !is_numeric($approval_template_id))
Controller::warning(PARAMETER);
$this->approval_template = new Approval_template_Model($approval_template_id);
if (!$this->approval_template->id)
Controller::error(RECORD);
$approval_type_model = new Approval_type_Model();
$approval_types = $approval_type_model->find_all();
$arr_approval_types = array();
foreach ($approval_types as $approval_type)
{
$arr_approval_types[$approval_type->id] = $approval_type->name;
}
$arr_approval_types = arr::merge(array(NULL => '----- '.url_lang::lang('texts.select approval type').' -----'), $arr_approval_types);
// creates form
$form = new Forge(url_lang::base().'approval_template_items/add/'.$this->approval_template->id, '', 'POST', array('id' => 'article_form'));
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
$form->group('')->label(url_lang::lang('texts.Basic information'));
$form->dropdown('approval_type_id')->label(url_lang::lang('texts.Approval type').':')->rules('required')->options($arr_approval_types)->callback(array($this, 'valid_approval_type'))->add_button('approval_types');
$form->input('priority')->label(url_lang::lang('texts.Priority').':')->rules('valid_numeric')->value(0)->callback(array($this, 'valid_priority'));
$form->submit('submit')->value(url_lang::lang('texts.Save'));
special::required_forge_style($form, ' *', 'required');
if ($form->validate())
{
$form_data = $form->as_array();
$approval_template_item = new Approval_template_item_Model();
$approval_template_item->approval_template_id = $this->approval_template->id;
$approval_template_item->approval_type_id = $form_data['approval_type_id'];
$approval_template_item->priority = $form_data['priority'];
$approval_template_item->save();
url::redirect(url_lang::base().'approval_templates/show/'.$this->approval_template->id);
}
$view = new View('main');
$view->title = url_lang::lang('texts.Add new approval template item');
$view->content = new View('form');
$view->content->headline = url_lang::lang('texts.Add new approval template item');
$view->content->link_back = html::anchor(url_lang::base().'approval_templates/show/'.$this->approval_template->id, url_lang::lang('texts.Back to the approval template'));
$view->content->form = $form->html();
$view->render(TRUE);
}
public function edit($approval_template_item_id = NULL)
{
if (!$approval_template_item_id || !is_numeric($approval_template_item_id))
Controller::warning(PARAMETER);
$this->approval_template_item = new Approval_template_item_Model($approval_template_item_id);
if (!$this->approval_template_item->id)
Controller::error(RECORD);
$this->approval_template = $this->approval_template_item->approval_template;
$approval_type_model = new Approval_type_Model();
$approval_types = $approval_type_model->find_all();
$arr_approval_types = array();
foreach ($approval_types as $approval_type)
{
$arr_approval_types[$approval_type->id] = $approval_type->name;
}
$arr_approval_types = arr::merge(array(NULL => '----- '.url_lang::lang('texts.select approval type').' -----'), $arr_approval_types);
// creates form
$form = new Forge(url_lang::base().'approval_template_items/edit/'.$this->approval_template_item->id, '', 'POST', array('id' => 'article_form'));
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
$form->group('')->label(url_lang::lang('texts.Basic information'));
$form->dropdown('approval_type_id')->label(url_lang::lang('texts.Approval type').':')->rules('required')->options($arr_approval_types)->selected($this->approval_template_item->approval_type_id)->callback(array($this, 'valid_approval_type'))->add_button('approval_types');
$form->input('priority')->label(url_lang::lang('texts.Priority').':')->rules('valid_numeric')->value($this->approval_template_item->priority)->callback(array($this, 'valid_priority'));
$form->submit('submit')->value(url_lang::lang('texts.Save'));
special::required_forge_style($form, ' *', 'required');
if ($form->validate())
{
$form_data = $form->as_array();
$approval_template_item = new Approval_template_item_Model($this->approval_template_item->id);
$approval_template_item->approval_type_id = $form_data['approval_type_id'];
$approval_template_item->priority = $form_data['priority'];
$approval_template_item->save();
url::redirect(url_lang::base().'approval_templates/show/'.$this->approval_template->id);
}
$view = new View('main');
$view->title = url_lang::lang('texts.Edit approval template item');
$view->content = new View('form');
$view->content->headline = url_lang::lang('texts.Edit approval template item');
$view->content->link_back = html::anchor(url_lang::base().'approval_templates/show/'.$this->approval_template_item->approval_template_id, url_lang::lang('texts.Back to the approval template'));
$view->content->form = $form->html();
$view->render(TRUE);
}
public function move_up($approval_template_item_id = NULL)
{
$this->move($approval_template_item_id, 'up');
}
public function move_down($approval_template_item_id = NULL)
{
$this->move($approval_template_item_id, 'down');
}
private function move($approval_template_item_id, $direction)
{
if (!$approval_template_item_id || !is_numeric($approval_template_item_id))
Controller::warning(PARAMETER);
$approval_template_item = new Approval_template_item_Model($approval_template_item_id);
if (!$approval_template_item->id)
Controller::error(RECORD);
if ($direction == 'up')
$approval_template_items = $approval_template_item->where('approval_template_id',$approval_template_item->approval_template_id)->where('priority < ',$approval_template_item->priority)->orderby('priority','desc')->find_all();
else
$approval_template_items = $approval_template_item->where('approval_template_id',$approval_template_item->approval_template_id)->where('priority > ',$approval_template_item->priority)->orderby('priority','asc')->find_all();
if (count($approval_template_items))
{
$second_approval_template_item = $approval_template_items->current();
$priority = $second_approval_template_item->priority;
$second_approval_template_item->priority = $approval_template_item->priority;
$approval_template_item->priority = $priority;
$approval_template_item->save();
$second_approval_template_item->save();
}
url::redirect(url_lang::base().'approval_templates/show/'.$approval_template_item->approval_template_id);
}
public function delete($approval_template_item_id = NULL)
{
if (!$approval_template_item_id || !is_numeric($approval_template_item_id))
Controller::warning(PARAMETER);
$approval_template_item = new Approval_template_item_Model($approval_template_item_id);
if (!$approval_template_item->id)
Controller::error(RECORD);
$approval_template_id = $approval_template_item->approval_template_id;
$approval_template_item->delete();
url::redirect(url_lang::base().'approval_templates/show/'.$approval_template_id);
}
public function valid_approval_type($input)
{
$approval_type_id = $input->value;
$approval_template_item_model = new Approval_template_item_Model();
$approval_template_item = $approval_template_item_model->where('approval_template_id', $this->approval_template->id)->where('approval_type_id', $approval_type_id)->find();
if ($approval_template_item && $approval_template_item->id && (!$this->approval_template_item || $approval_template_item->id != $this->approval_template_item->id))
{
$input->add_error('required', url_lang::lang('texts.This approval template already contains this approval type.'));
}
}
public function valid_priority($input)
{
$priority = $input->value;
$approval_template_item_model = new Approval_template_item_Model();
$approval_template_item = $approval_template_item_model->where('approval_template_id', $this->approval_template->id)->where('priority', $priority)->find();
if ($approval_template_item && $approval_template_item->id && (!$this->approval_template_item || $approval_template_item->id != $this->approval_template_item->id))
{
$input->add_error('required', url_lang::lang('texts.This approval template already contains approval type with the same priority.'));
}
}
}
freenetis/trunk/kohana/application/views/approval_templates_show.php
<td><?php echo $approval_template->comment ?></td>
</tr>
</table>
<br /><br />
<h3><?php echo url_lang::lang('texts.Template items') ?></h3>
<?php echo $items_grid ?>
freenetis/trunk/kohana/application/views/grid_template.php
// action field
if ($field instanceof Action_Field) :
$property = $field->name; ?>
<td <?php echo ' class="'.$field->class.' noprint"'?>><?php echo html::anchor($field->url.'/'.$item->$property, $field->action, $field->script)?></td>
<td class="noprint"><?php echo html::anchor($field->url.'/'.$item->$property, $field->action, array('script' => $field->script,'class'=> $field->class))?></td>
<?php elseif ($field->bool != ''): ?>
<td <?php echo $class_td?>><?php echo $field->bool[(bool)$item->$field] ?>
</td>

Také k dispozici: Unified diff