103 lines
3.9 KiB
PHP
103 lines
3.9 KiB
PHP
|
|
<?php
|
||
|
|
$page = "admin_ats_tracking_prices";
|
||
|
|
include "admin_header.php";
|
||
|
|
include '../language/lang_'.strtolower(SE_Language::info('language_name')).'_ats_tracking.php';
|
||
|
|
|
||
|
|
|
||
|
|
if(isset($_POST['task'])) { $task = $_POST['task']; } elseif(isset($_GET['task'])) { $task = $_GET['task']; } else { $task = "main"; }
|
||
|
|
if(isset($_POST['item_id'])) { $item_id = $_POST['item_id']; } elseif(isset($_GET['item_id'])) { $item_id = $_GET['item_id']; } else { $item_id = 0; }
|
||
|
|
|
||
|
|
// **** PRICES ****
|
||
|
|
|
||
|
|
$is_error = 0;
|
||
|
|
$error_message = '';
|
||
|
|
$sSql = 'SELECT * FROM `se_ats_setting`';
|
||
|
|
$rSql = $database->database_query($sSql);
|
||
|
|
$SETT = array();
|
||
|
|
while($aSetting = $database->database_fetch_assoc($rSql))
|
||
|
|
{
|
||
|
|
$SETT[$aSetting['setting_code']] = $aSetting['setting_value'];
|
||
|
|
}
|
||
|
|
switch ($task)
|
||
|
|
{
|
||
|
|
case "create":
|
||
|
|
$iColDays = intVal($_POST['col_days']);
|
||
|
|
$fPrice = floatVal($_POST['price']);
|
||
|
|
if($_POST['price'] == '')
|
||
|
|
$fPrice = -1;
|
||
|
|
$error_message = '';
|
||
|
|
if ($fPrice>=0 && $iColDays>0)
|
||
|
|
{
|
||
|
|
if($database->database_num_rows($database->database_query('SELECT true FROM `se_ats_tracking_price` WHERE col_days = '.$iColDays.' LIMIT 1'))>0)
|
||
|
|
{
|
||
|
|
$is_error = 1;
|
||
|
|
$error_message .= '<div class="errorinner"><img src="../images/icons/error16.gif"/>'.$admin_ats_tracking_prices['count_exists'].'</div>';
|
||
|
|
}else{
|
||
|
|
$database->database_query('INSERT INTO `se_ats_tracking_price` (col_days, price) VALUES ('.$iColDays.','.$fPrice.')');
|
||
|
|
}
|
||
|
|
}else{
|
||
|
|
$is_error = 1;
|
||
|
|
if ($fPrice<=0)
|
||
|
|
$error_message .= '<div class="errorinner"><img src="../images/icons/error16.gif"/>'.$admin_ats_tracking_prices['price_must_be_positive'].'</div>';
|
||
|
|
if ($iColDays<=0)
|
||
|
|
$error_message .= '<div class="errorinner"><img src="../images/icons/error16.gif"/>'.$admin_ats_tracking_prices['days_must_be_positive'].'</div>';
|
||
|
|
}
|
||
|
|
echo "<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'><script type='text/javascript'>";
|
||
|
|
echo "window.parent.createResult('$is_error', '".str_replace("'", "'", $error_message)."');";
|
||
|
|
echo "</script></head><body></body></html>";
|
||
|
|
exit();
|
||
|
|
case "edit":
|
||
|
|
$iColDays = intVal($_POST['col_days']);
|
||
|
|
$iPrice = floatVal($_POST['price']);
|
||
|
|
if (!$item_id)
|
||
|
|
{
|
||
|
|
exit();
|
||
|
|
}
|
||
|
|
if($iPrice>0 && $iColDays>0)
|
||
|
|
{
|
||
|
|
if($database->database_num_rows($database->database_query('SELECT true FROM `se_ats_tracking_price` WHERE col_days = '.$iPrice.' LIMIT 1'))>0)
|
||
|
|
{
|
||
|
|
$is_error = 1;
|
||
|
|
$error_message = $admin_ats_tracking_prices['count_exists'];
|
||
|
|
}else{
|
||
|
|
$database->database_query('UPDATE `se_ats_tracking_price` SET price = "'.$iPrice.'", col_days = "'.$iColDays.'" WHERE id = '.$item_id);
|
||
|
|
}
|
||
|
|
}else{
|
||
|
|
$is_error = 1;
|
||
|
|
$error_message = $admin_ats_tracking_prices['price_must_be_positive'];
|
||
|
|
}
|
||
|
|
echo "<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'><script type='text/javascript'>";
|
||
|
|
echo "window.parent.createResult('$is_error', '".str_replace("'", "'", $error_message)."');";
|
||
|
|
echo "</script></head><body></body></html>";
|
||
|
|
break;
|
||
|
|
case "delete":
|
||
|
|
if($item_id)
|
||
|
|
{
|
||
|
|
$database->database_query('DELETE FROM `se_ats_tracking_price` WHERE id = '.$item_id);
|
||
|
|
}
|
||
|
|
cheader($page.'.php');
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
|
||
|
|
$rSql = $database->database_query('SELECT * FROM `se_ats_tracking_price` ORDER BY col_days, price');
|
||
|
|
$aItems = array();
|
||
|
|
while($aItem = $database->database_fetch_assoc($rSql))
|
||
|
|
{
|
||
|
|
$aItems[] = $aItem;
|
||
|
|
}
|
||
|
|
|
||
|
|
// **** PAYMENTS ****
|
||
|
|
|
||
|
|
$sSql = 'SELECT p.*,u.user FROM se_ats_tracking_payment AS p INNER JOIN se_users AS u USING(user_id) ORDER BY payment_to_date DESC ';
|
||
|
|
$rSql = $database->database_query($sSql);
|
||
|
|
$aPayment = array();
|
||
|
|
while($aPayments[] = $database->database_fetch_assoc($rSql));
|
||
|
|
|
||
|
|
$smarty->assign(
|
||
|
|
array(
|
||
|
|
'items' => $aItems,
|
||
|
|
'aPayments' => $aPayments,
|
||
|
|
'sCurrency' => $SETT['currency']
|
||
|
|
));
|
||
|
|
include "admin_footer.php";
|
||
|
|
?>
|