public function doRefreshRates() { $valCur = array('USD' => 840, 'EUR' => 978, 'RUB' => 643); $idVal = Input::get('id'); $valCurrency = Input::get('currency'); $client = new RatesClient("Currency"); $client->call("getCurrencyRate", array("type" => 0, "currencyId" => $valCur[$valCurrency])); $client->getCurrencyRateParse(); $client->call("getCurrencyRate", array("type" => 1, "currencyId" => $valCur[$valCurrency])); $alfaBuy = $client->getCurrencyRateParse(); $client->call("getCurrencyRate", array("type" => 2, "currencyId" => $valCur[$valCurrency])); $alfaSale = $client->getCurrencyRateParse(); if ($alfaBuy > 0 && $alfaSale > 0) { $ratesOld = Rates::where('id', $idVal)->get(); foreach ($ratesOld as $rate) { $saleOld = $rate->sale; $buyOld = $rate->buy; $updateTime = $rate->updated_at; } $saleInequality = $alfaSale - $saleOld; $buyInequality = $alfaBuy - $buyOld; if (date('Y-m-d', strtotime($updateTime)) != date('Y-m-d')) { $ratesNew = Rates::where('id', $idVal)->update(array('sale_old' => round($saleOld, 2), 'buy_old' => round($buyOld, 2), 'sale_inequality' => round($saleInequality, 2), 'buy_inequality' => round($buyInequality, 2), 'sale' => round($alfaSale, 2), 'buy' => round($alfaBuy, 2))); } if ($ratesNew == "1") { return Response::json(array('status' => true)); } } else { return Response::json(array('status' => false)); } }
public function fire() { $valCur = array('6' => 840, '9' => 978, '4' => 643); foreach ($valCur as $key => $value) { $client = new RatesClient("Currency"); $client->call("getCurrencyRate", array("type" => 0, "currencyId" => $value)); $client->getCurrencyRateParse(); $client->call("getCurrencyRate", array("type" => 1, "currencyId" => $value)); $alfaBuy = $client->getCurrencyRateParse(); $client->call("getCurrencyRate", array("type" => 2, "currencyId" => $value)); $alfaSale = $client->getCurrencyRateParse(); if ($alfaBuy > 0 && $alfaSale > 0) { $ratesOld = Rates::where('id', $key)->get(); foreach ($ratesOld as $rate) { $saleOld = $rate->sale; $buyOld = $rate->buy; $updateTime = $rate->updated_at; } $saleInequality = round($alfaSale, 2) - round($saleOld, 2); $buyInequality = round($alfaBuy, 2) - round($buyOld, 2); if (date('Y-m-d', strtotime($updateTime)) != date('Y-m-d')) { Rates::where('id', $key)->update(array('sale_old' => round($saleOld, 2), 'buy_old' => round($buyOld, 2), 'sale_inequality' => round($saleInequality, 2), 'buy_inequality' => round($buyInequality, 2), 'sale' => round($alfaSale, 2), 'buy' => round($alfaBuy, 2))); } } } }
function edit_place($mode = '') { if ($mode == 'rates') { $r = new Rates(); $r->where('id', Input::get('rowid')); $r->get(); if (Input::get('colid') == 'rate_per_day') { $r->rate_per_day = Input::get('new'); } if (Input::get('colid') == 'pagibig_amount') { $r->pagibig_amount = Input::get('new'); } $r->save(); exit; } if ($mode == 'jo_days') { $j = new Jo_days(); $j->where('id', Input::get('rowid')); $j->get(); if (Input::get('colid') == 'hours') { $j->hours = Input::get('new'); } if (Input::get('colid') == 'days') { $j->days = Input::get('new'); } $j->save(); exit; } if ($mode == 'status') { $c = new Cos_status(); $c->where('id', Input::get('rowid')); $c->get(); $c->status = Input::get('new'); $c->save(); exit; } }
<th width="40%" bgcolor="#D6D6D6"><strong>Employee Name</strong></th> <th width="16%" bgcolor="#D6D6D6">Rate per Day</th> <th width="31%" bgcolor="#D6D6D6">Pag-ibig Personal Contribution</th> <th width="31%" bgcolor="#D6D6D6"> </th> </tr> <?php $i = 0; ?> <?php $r = new Rates(); ?> <?php foreach ($rows as $row) { ?> <?php $r->where('employee_id', $row['employee_id']); $r->get(); $onclick0 = "onClick=\"dg_editCell(offices,'" . $r->id . "','rate_per_day','offices.0.{$i}', 'cto_balance')\""; $onclick1 = "onClick=\"dg_editCell(offices,'" . $r->id . "','pagibig_amount','offices.1.{$i}', 'cto_balance')\""; ?> <?php $bg = $this->Helps->set_line_colors(); ?> <tr bgcolor="<?php echo $bg; ?> " onmouseover="this.bgColor = '<?php echo $this->config->item('mouseover_linecolor'); ?> ';" onmouseout ="this.bgColor = '<?php