Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1271

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

Opravy:

- opravy floating point chyb ve vykazech
- nahrazeni chybne pouzivane funkce mysql_real_escape ve tride Filter_form

Zobrazit rozdíly:

freenetis/branches/testing/application/models/job_report.php
r.price_per_hour, r.price_per_km, r.type, r.concept,
r.added_by_id, j.transfer_id, u.member_id, r.payment_type,
CONCAT(u.name, ' ', u.surname) as uname,
SUM(j.suggest_amount) AS suggest_amount, MIN(j.date) AS date_from,
ROUND(SUM(j.suggest_amount), 2) AS suggest_amount,
MIN(j.date) AS date_from,
MAX(j.date) AS date_to, IFNULL(SUM(j.hours), 0) AS hours,
SUM(j.km) AS km,
ROUND(SUM(j.km), 2) AS km,
IF(MIN(j.state) <= 1, MIN(j.state), MAX(j.state)) AS state
FROM job_reports r
LEFT JOIN users u ON u.id = r.user_id
......
SELECT * FROM
(
SELECT r.id, r.user_id, CONCAT(u.name, ' ', u.surname) as uname,
r.description, SUM(j.suggest_amount) AS suggest_amount,
r.description, ROUND(SUM(j.suggest_amount), 2) 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,
ROUND(SUM(j.hours), 2) AS hours, SUM(j.km) AS km, r.payment_type,
IF(MIN(state) <= 1, MIN(state), MAX(state)) AS state,
IFNULL(t.amount, IF(r.payment_type = 1, ?, 0)) AS rating,
r.transfer_id
......
{
return $this->db->query('
SELECT r.id, r.user_id, CONCAT(u.name, \' \', u.surname) as uname,
r.description, SUM(j.suggest_amount) AS suggest_amount,
r.description, ROUND(SUM(j.suggest_amount), 2) 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.transfer_id,
SUM(j.hours) AS hours, ROUND(SUM(j.km), 2) AS km, r.transfer_id,
IF(MIN(state) <= 1, MIN(state), MAX(state)) AS state,
IFNULL(t.amount, IF(r.payment_type = 1, ?, 0)) AS rating
FROM job_reports r
......
{
return $this->db->query("
SELECT r.id, r.user_id, CONCAT(u.name, ' ', u.surname) as uname,
r.description, IFNULL(SUM(j.suggest_amount), 0.0) AS suggest_amount,
r.description,
IFNULL(ROUND(SUM(j.suggest_amount), 2), 0.0) AS suggest_amount,
MIN(j.date) AS date_from, MAX(j.date) AS date_to, r.type,
IFNULL(SUM(j.hours), 0) AS hours, IFNULL(SUM(j.km), 0) AS km,
IFNULL(ROUND(SUM(j.hours), 2), 0) AS hours,
IFNULL(SUM(j.km), 0) AS km,
IF(MIN(state) <= 1, MIN(state), MAX(state)) AS state
FROM job_reports r
LEFT JOIN users u ON u.id = r.user_id
freenetis/branches/testing/application/controllers/votes.php
$work = new Job_Model($work_id);
// work doesn't exist
if (!$work->id)
if (!$work->id || $work->job_report_id)
Controller::error(RECORD);
$approval_template_item_model = new Approval_template_item_Model();
freenetis/branches/testing/application/controllers/work_reports.php
$works_grid->field('date');
$works_grid->field('description');
$works_grid->callback_field('description')
->callback('callback::limited_text');
$works_grid->field('hours');
......
$operating_id, $credit_id, null, null,
$this->session->get('user_id'), null, date('Y-m-d'),
date('Y-m-d H:i:s'), __('Work report approval'),
$amount
round($amount, 2)
);
$work_report_model->transfer_id = $transfer_id;
freenetis/branches/testing/application/controllers/works.php
->label(__('Vote'))
->callback('callback::vote');
$vote_grids[$i]->order_link_field('user_id')
$vote_grids[$i]->link_field('user_id')
->link('users/show', 'uname')
->label('Worker');
......
->label(__('Vote'))
->callback('callback::vote');
$vote_grids[$i]->order_link_field('user_id')
$vote_grids[$i]->link_field('user_id')
->link('users/show', 'uname')
->label('Worker');
freenetis/branches/testing/application/libraries/Filter_form.php
{
if (!preg_match(
$this->opers[$this->operations[$i]]['pattern'],
mysql_real_escape_string($value), $matches
Database::instance()->escape_str($value), $matches
))
{
continue;
......
foreach ($matches as $key => $value)
{
$sql = str_replace('{'.$key.'}', mysql_real_escape_string($value), $sql);
$sql = str_replace('{'.$key.'}', Database::instance()->escape_str($value), $sql);
}
}
......
{
$queries[] = $this->opers[$this->operations[$i]]['function']
. "(" . $table_pom . $filter->name . ") "
. str_replace("{VALUE}", mysql_real_escape_string($value), $sql);
. str_replace("{VALUE}", Database::instance()->escape_str($value), $sql);
}
else
{
$queries[] = $table_pom . $filter->name . " "
. str_replace("{VALUE}", mysql_real_escape_string($value), $sql);
. str_replace("{VALUE}", Database::instance()->escape_str($value), $sql);
}
}
freenetis/branches/testing/application/views/js/__pieces/work_report_form_functions.php
hours_count = hours_count + parseFloat(val);
}
});
$('#total_hours_count').text(round(hours_count, 2) + ' h');
$('#total_hours_count').text(hours_count.toString() + ' h');
var pph = $('#price_per_hour').val();
if (!pph.length)
......
var price = pph * hours_count;
$('#total_hours_price').text(price.toString() + currency);
$('#total_hours_price').text(number_format(price, 2, ',', ' ') + currency);
price = price + parseFloat($('#total_km_price').text());
......
}
});
$('#total_km_count').text(km_count.toString() + ' km');
$('#total_km_count').text(number_format(km_count, 0) + ' km');
var ppkm = $('#price_per_km').val();
......
$('#price_per_km').removeClass('error');
}
var price = ppkm * km_count;
$('#total_km_price').text(number_format(price, 2, ',', ' ') + currency);
$('#total_km_price').text(price.toString() + currency);
price = price + parseFloat($('#total_hours_price').text());
price = Math.round(price * 100) / 100;
$('#total_price').text(number_format(price, 2, ',', ' ') + currency);
}
......
{
km_filled = true;
if (parseInt($(this).val()) <= 0)
if (parseInt($(this).val()) < 0)
{
$(this).addClass('error');
valid = false;
freenetis/branches/testing/application/views/work_reports/show.php
</tr>
<tr>
<th><?php echo __('Hours') ?></th>
<td><?php echo $work_report->hours ?></td>
<td><?php echo round($work_report->hours, 2) ?></td>
</tr>
<tr>
<th><?php echo __('Payment per hour') ?></th>
......
<?php if ($work_report->km): ?>
<tr>
<th><?php echo __('Km') ?></th>
<td><?php echo $work_report->km ?></td>
<td><?php echo round($work_report->km, 2) ?></td>
</tr>
<tr>
<th><?php echo __('Price per kilometre') ?></th>
freenetis/branches/testing/application/views/work_reports/edit.php
<th></th>
<th style="text-align: right; padding-right: 10px"><?php echo __('Price per one hour, kilometre') ?>:</th>
<th class="left" style="padding-left: 0">
<input name="price_per_hour" maxlength="5" id="price_per_hour" value="<?php echo $work_report->price_per_hour ?>" style="width: 30px;" />
<input name="price_per_hour" maxlength="5" id="price_per_hour" value="<?php echo str_replace(',', '.', $work_report->price_per_hour) ?>" style="width: 30px;" />
<span class="normal"><?php echo __(Settings::get('currency')) ?></span>
</th>
<th class="left" style="padding-left: 0">
<input name="price_per_km" maxlength="5" id="price_per_km" value="<?php echo empty($work_report->price_per_km) ? '' : $work_report->price_per_km; ?>" style="width: 20px" />
<input name="price_per_km" maxlength="5" id="price_per_km" value="<?php echo empty($work_report->price_per_km) ? '' : str_replace(',', '.', $work_report->price_per_km); ?>" style="width: 20px" />
<span class="normal"><?php echo __(Settings::get('currency')) ?></span>
</th>
<th></th>
......
<textarea name="work_description[<?php echo $index ?>]" class="one_row_textarea" style="width: 450px"><?php echo (empty($job)) ? '' : $job->description ?></textarea>
</td>
<td>
<input type="text" name="work_hours[<?php echo $index ?>]" value="<?php echo (empty($job)) ? '' : $job->hours ?>" maxlength="5" style="width: 30px" />
<input type="text" name="work_hours[<?php echo $index ?>]" value="<?php echo (empty($job)) ? '' : str_replace(',', '.', $job->hours) ?>" maxlength="5" style="width: 30px" />
</td>
<td>
<input type="text" name="work_km[<?php echo $index ?>]" value="<?php echo empty($job->km) ? '' : $job->km ?>" maxlength="6" style="width: 30px" />

Také k dispozici: Unified diff