Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1249

Přidáno uživatelem Ondřej Fibich před asi 13 roky(ů)

Upravy:

- upravy v zobrazeni pracovnich vykazu
- pri pridavani prace se pocita navrhovana castka ze sazby a poctu hodin/kilometru

Zobrazit rozdíly:

freenetis/branches/testing/application/helpers/callback.php
}
/**
* Callback for work report payment type
* Callback for work report rating
*
* @author Ondrej Fibich
* @param object $item
* @param string $name
*/
public static function work_report_payment_type($item, $name)
public static function work_report_rating($item, $name)
{
$value = $item->$name;
$rating = $item->$name;
if ($value == Job_report_Model::PAYMENT_BY_CASH)
if (is_numeric($rating))
{
echo '<span class="red">';
echo html::anchor(
'transfers/show/'.$item->transfer_id,
number_format($rating, 2, ',', ' ').' '.
__(Settings::get('currency'))
);
}
echo Job_report_Model::get_name_of_payment_type($value);
if ($value == Job_report_Model::PAYMENT_BY_CASH)
else
{
echo '</span>';
echo '<span class="red">' . $rating . '</span>';
}
}
freenetis/branches/testing/application/models/job.php
{
return $this->db->query("
SELECT q.*, (agree_count - disagree_count) AS approval_state,
IF(IFNULL(q.transfer_id, 0), 1, 0) AS approved
IF(q.state = 3, 1, 0) AS approved
FROM (SELECT j.*, CONCAT(u.name, ' ', u.surname) AS uname, v.vote, v.comment,
(
SELECT COUNT(*)
freenetis/branches/testing/application/models/job_report.php
}
/**
* Gets suggest amount of work reports from it's works
* Gets suggest amount of work report from it's works
*
* @author Ondřej Fibich
* @staticvar array $cache Cache for amounts
......
return $cache[$this->id];
}
/**
* Gets rating of work report from it's works
*
* @author Ondřej Fibich
* @staticvar array $cache Cache for amounts
* @return double
*/
public function get_rating()
{
static $cache = array();
if (!$this->id)
{
return FALSE;
}
if (!isset($cache[$this->id]))
{
$cache[$this->id] = $this->db->query("
SELECT IFNULL(SUM(suggest_amount), 0) AS amount
FROM jobs
WHERE job_report_id = ? AND state = 3
", $this->id)->current()->amount;
}
return $cache[$this->id];
}
/**
* Gets count of unvoted work reports of voter
......
r.description, SUM(j.suggest_amount) AS suggest_amount,
MIN(j.date) AS date_from, MAX(j.date) AS date_to, r.type,
SUM(j.hours) AS hours, SUM(j.km) AS km, r.payment_type,
IF(MIN(state) <= 1, MIN(state), MAX(state)) AS state
IF(MIN(state) <= 1, MIN(state), MAX(state)) AS state,
IFNULL(t.amount, IF(r.payment_type = 1, ?, 0)) AS rating,
r.transfer_id
FROM job_reports r
LEFT JOIN transfers t ON t.id = r.transfer_id
LEFT JOIN users u ON u.id = r.user_id
LEFT JOIN jobs j ON r.id = j.job_report_id
WHERE r.concept = 0
......
ORDER BY " . $this->db->escape_column($order_by) . " " . $order_by_direction . "
LIMIT " . intval($limit_from) . ", " . intval($limit_results) . "
) wr $filter_sql
", $state);
", __('Payment by cash'), $state);
}
/**
......
SELECT r.id, r.user_id, CONCAT(u.name, \' \', u.surname) as uname,
r.description, SUM(j.suggest_amount) AS suggest_amount,
MIN(j.date) AS date_from, MAX(j.date) AS date_to, r.type,
SUM(j.hours) AS hours, SUM(j.km) AS km,
SUM(j.hours) AS hours, SUM(j.km) AS km, r.transfer_id,
IF(MIN(state) <= 1, MIN(state), MAX(state)) AS state,
r.transfer_id, t.amount AS rating
IFNULL(t.amount, IF(r.payment_type = 1, ?, 0)) AS rating
FROM job_reports r
LEFT JOIN users u ON u.id = r.user_id
LEFT JOIN transfers t ON t.id = r.transfer_id
......
WHERE r.concept = 0 AND r.user_id = ?
GROUP BY r.id
HAVING state ' . ($lower ? '<' : '=') . ' ?
', $user_id, $state);
', __('Payment by cash'), $user_id, $state);
}
/**
freenetis/branches/testing/application/controllers/work_reports.php
->label(__('Km'));
$grid->order_callback_field('suggest_amount')
->label(__('Rating'))
->callback('Works_Controller::suggest_amount');
$grid->order_callback_field('payment_type')
->callback('callback::work_report_payment_type');
$grid->order_callback_field('rating')
->label(__('Rating'))
->callback('callback::work_report_rating');
// access control
if ($this->acl_check_view('Users_Controller','work'))
......
->callback('Works_Controller::suggest_amount');
$grid_approved->callback_field('rating')
->callback('Works_Controller::rating');
->callback('callback::work_report_rating');
$actions = $grid_approved->grouped_action_field();
......
case 3:
$state_text = '<span style="color: green;">'.__('Approved');
if ($work_report->suggest_amount != $work_report_model->transfer->amount)
if ($work_report->suggest_amount != $work_report_model->get_rating())
{
$state_text .= ' (' . __('Partially') . ')';
}
freenetis/branches/testing/application/controllers/works.php
}
// form
$form = new Forge(
$this->_form = $form = new Forge(
url_lang::base() . 'works/add' . (isset($user_id) ? '/' . $user_id : ''),
'', 'POST', array('id' => 'article_form')
);
......
->label(__('Km') . ':')
->rules('length[0,250]|valid_numeric');
$form->input('suggest_amount')
->label(__('Suggest amount') . ':')
$form->input('payment_per_hour')
->rules('required|valid_numeric');
$form->input('price_per_kilometre')
->rules('valid_numeric')
->callback(array($this, 'valid_price_per_km'));
if ($this->acl_check_view('approval', 'templates'))
{
......
$form->description->value($clone_work->description);
$form->date->value(strtotime($clone_work->date));
$form->hours->value($clone_work->hours);
$form->suggest_amount->value($clone_work->suggest_amount);
if (!empty($clone_work->km))
{
$form->km->value($clone_work->km);
}
if ($clone_work->job_report_id)
{
$form->payment_per_hour->value($clone_work->job_report->price_per_hour);
$form->price_per_kilometre->value($clone_work->job_report->price_per_km);
}
$form->previous_rejected_work_id->value($clone_work->id);
}
......
if ($form->validate())
{
$form_data = $form->as_array();
// calculate suggested amount
$suggest_amount =
$form_data['hours'] * $form_data['payment_per_hour'] +
$form_data['km'] * $form_data['price_per_kilometre'];
// creates new work
$work = new Job_Model();
$work->user_id = $form_data['user_id'];
$work->added_by_id = $this->session->get('user_id');
$work->description = $form_data['description'];
$work->suggest_amount = $form_data['suggest_amount'];
$work->suggest_amount = $suggest_amount;
$work->date = date('Y-m-d', $form_data['date']);
$work->create_date = date('Y-m-d H:i:s');
$work->hours = $form_data['hours'];
......
echo $input->html();
}
}
/**
* Check validity of price per km field
*
* @param object $input
*/
public function valid_price_per_km($input)
{
if (intval($this->_form->km->value) && !intval($input->value))
{
$input->add_error('required', __('Fill in'));
}
}
}
freenetis/branches/testing/application/libraries/forge/Form_Input.php
public function __construct($name)
{
$this->data['name'] = $name;
$this->data['label'] = __(utf8::ucwords(inflector::humanize($name))).':';
$this->data['label'] = __(utf8::ucfirst(inflector::humanize($name))).':';
}
/**
freenetis/branches/testing/application/views/work_reports/show.php
<th><?php echo __('State') ?></th>
<td><b><?php echo $state_text ?></b></td>
</tr>
<?php if ($work_report->state == 3 && $work_report->payment_type == Job_report_Model::PAYMENT_BY_CREDIT): ?>
<?php if ($work_report->state == 3): ?>
<?php if($work_report->payment_type == Job_report_Model::PAYMENT_BY_CREDIT): ?>
<tr>
<th><?php echo __('Confirmed time') ?></th>
<td><?php echo $transfer->creation_datetime ?></td>
......
<th><?php echo __('Rating') ?></th>
<td><?php echo html::anchor(url_lang::base() . 'transfers/show/' . $transfer->id, number_format($transfer->amount, 2, ',', ' ') . ' ' . __($this->settings->get('currency'))) ?></td>
</tr>
<?php else: ?>
<tr>
<th><?php echo __('Rating') ?></th>
<td><b><?php echo number_format($work_report_model->get_rating(), 2, ',', ' ') . ' ' . __($this->settings->get('currency')) ?></b></td>
</tr>
<?php endif ?>
<?php endif ?>
</table>
freenetis/branches/testing/application/views/works_show.php
<th><?php echo __('State') ?></th>
<td><b><?php echo $state_text ?></b></td>
</tr>
<?php if ($work->state == 3): ?>
<?php if ($work->state == 3 && $transfer->id): ?>
<tr>
<th><?php echo __('Confirmed time') ?></th>
<td><?php echo $transfer->creation_datetime ?></td>

Také k dispozici: Unified diff