本文整理汇总了PHP中ABS函数的典型用法代码示例。如果您正苦于以下问题:PHP ABS函数的具体用法?PHP ABS怎么用?PHP ABS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ABS函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: procDistanceTime2
function procDistanceTime2($coor, $thiscoor, $ref, $mode)
{
$xdistance = ABS($thiscoor['x'] - $coor['x']);
if ($xdistance > WORLD_MAX) {
$xdistance = 2 * WORLD_MAX + 1 - $xdistance;
}
$ydistance = ABS($thiscoor['y'] - $coor['y']);
if ($ydistance > WORLD_MAX) {
$ydistance = 2 * WORLD_MAX + 1 - $ydistance;
}
$distance = SQRT(POW($xdistance, 2) + POW($ydistance, 2));
if (!$mode) {
if ($ref == 1) {
$speed = 16;
} else {
if ($ref == 2) {
$speed = 12;
} else {
if ($ref == 3) {
$speed = 24;
} else {
if ($ref == 300) {
$speed = 5;
} else {
$speed = 1;
}
}
}
}
} else {
$speed = $ref;
}
return round($distance / $speed * 3600 / INCREASE_SPEED);
}
示例2: Offset
/**
* compose time offset string
* @param int $mns -- offset in minutes
* @return string hh:mm
*/
function Offset($mns)
{
$n = ABS($mns);
$h = floor($n / 60);
$m = $n % 60;
$c = $mns > 0 ? '-' : '+';
$c .= str_pad($h, 2, '0', STR_PAD_LEFT) . ':' . str_pad($m, 2, '0', STR_PAD_LEFT);
return $c;
}
示例3: procDistanceTime
public function procDistanceTime($coor, $thiscoor, $ref, $mode)
{
global $bid28, $bid14, $building;
$xdistance = ABS($thiscoor['x'] - $coor['x']);
if ($xdistance > WORLD_MAX) {
$xdistance = 2 * WORLD_MAX + 1 - $xdistance;
}
$ydistance = ABS($thiscoor['y'] - $coor['y']);
if ($ydistance > WORLD_MAX) {
$ydistance = 2 * WORLD_MAX + 1 - $ydistance;
}
$distance = SQRT(POW($xdistance, 2) + POW($ydistance, 2));
if (!$mode) {
if ($ref == 1) {
$speed = 16;
} else {
if ($ref == 2) {
$speed = 12;
} else {
if ($ref == 3) {
$speed = 24;
} else {
if ($ref == 300) {
$speed = 5;
} else {
$speed = 1;
}
}
}
}
} else {
$speed = $ref;
if ($building->getTypeLevel(14) != 0 && $distance >= TS_THRESHOLD) {
$speed = $speed * ($bid14[$building->gettypeLevel(14)]['attri'] / 100);
}
}
if ($speed != 0) {
return round($distance / $speed * 3600 / INCREASE_SPEED);
} else {
return round($distance * 3600 / INCREASE_SPEED);
}
}
示例4: create_results
function create_results($res,$title) {
global $table,$row,$row_category;
$table.=$row_category;
$table = str_replace("##TITLE##",$title,$table);
$x=1;
while($res->next_record()) {
$smicro = $res->f("start");
$stmicro = $res->f("stop");
$smicro = explode(".",$smicro);
$stmicro = explode(".",$stmicro);
$micro = (ABS($stmicro[1]-$smicro[1]));
if ($micro<1000) $micro = "0".$micro;
if ($micro<100) $micro = "0".$micro;
$rtable.=$row;
$rtable =str_replace("##FULL_NAME##",$res->f("full_name"),$rtable);
$rtable =str_replace("##PLACE##",$x,$rtable);
$rtable =str_replace("##TIME##",$res->f("end_time"),$rtable);
$rtable =str_replace("##TIME2##",substr($micro,0,2),$rtable);
$x++;
}
$table = str_replace("##RESULTS##",$rtable,$table);
$rtable = '';
}
示例5: DateAdd
$_POST['ItemDue_' . $OrderLine->LineNumber] = DateAdd(Date($_SESSION['DefaultDateFormat']), 'd', $_SESSION['Items' . $identifier]->DeliveryDays);
}
if (isset($_POST['OverrideDiscount_' . $OrderLine->LineNumber])) {
$_POST['OverrideDiscount_' . $OrderLine->LineNumber] = 1;
} else {
$_POST['OverrideDiscount_' . $OrderLine->LineNumber] = 0;
}
if ($Quantity < 0 or $Price < 0 or $DiscountPercentage > 100 or $DiscountPercentage < 0) {
prnMsg(_('The item could not be updated because you are attempting to set the quantity ordered to less than 0 or the price less than 0 or the discount more than 100% or less than 0%'), 'warn');
} elseif ($_SESSION['Items' . $identifier]->Some_Already_Delivered($OrderLine->LineNumber) != 0 and $_SESSION['Items' . $identifier]->LineItems[$OrderLine->LineNumber]->Price != $Price) {
prnMsg(_('The item you attempting to modify the price for has already had some quantity invoiced at the old price the items unit price cannot be modified retrospectively'), 'warn');
} elseif ($_SESSION['Items' . $identifier]->Some_Already_Delivered($OrderLine->LineNumber) != 0 and $_SESSION['Items' . $identifier]->LineItems[$OrderLine->LineNumber]->DiscountPercent != $DiscountPercentage / 100) {
prnMsg(_('The item you attempting to modify has had some quantity invoiced at the old discount percent the items discount cannot be modified retrospectively'), 'warn');
} elseif ($_SESSION['Items' . $identifier]->LineItems[$OrderLine->LineNumber]->QtyInv > $Quantity) {
prnMsg(_('You are attempting to make the quantity ordered a quantity less than has already been invoiced') . '. ' . _('The quantity delivered and invoiced cannot be modified retrospectively'), 'warn');
} elseif ($OrderLine->Quantity != $Quantity or $OrderLine->Price != $Price or ABS($OrderLine->DiscountPercent - $DiscountPercentage / 100) > 0.001 or $OrderLine->Narrative != $Narrative or $OrderLine->ItemDue != $_POST['ItemDue_' . $OrderLine->LineNumber] or $OrderLine->POLine != $_POST['POLine_' . $OrderLine->LineNumber] or $OrderLine->OverrideDiscount != $_POST['OverrideDiscount_' . $OrderLine->LineNumber] or isset($PropertiesArray)) {
$_SESSION['Items' . $identifier]->update_cart_item($OrderLine->LineNumber, $Quantity, $Price, $_POST['Units_' . $OrderLine->LineNumber], $_POST['ConversionFactor_' . $OrderLine->LineNumber], $DiscountPercentage / 100, $_POST['OverrideDiscount_' . $OrderLine->LineNumber], $Narrative, 'Yes', $_POST['ItemDue_' . $OrderLine->LineNumber], $_POST['POLine_' . $OrderLine->LineNumber], $_POST['GPPercent_' . $OrderLine->LineNumber], $PropertiesArray[$OrderLine->LineNumber]);
}
}
//page not called from itself - POST variables not set
}
}
if (isset($_POST['DeliveryDetails'])) {
echo '<meta http-equiv="Refresh" content="0; url=' . $rootpath . '/DeliveryDetails.php?identifier=' . $identifier . '">';
prnMsg(_('You should automatically be forwarded to the entry of the delivery details page') . '. ' . _('if this does not happen') . ' (' . _('if the browser does not support META Refresh') . ') ' . '<a href="' . $rootpath . '/DeliveryDetails.php?identifier=' . $identifier . '">' . _('click here') . '</a> ' . _('to continue'), 'info');
exit;
}
if (isset($NewItem)) {
/* get the item details from the database and hold them in the cart object make the quantity 1 by default then add it to the cart */
/*Now figure out if the item is a kit set - the field MBFlag='K'*/
$sql = "SELECT stockmaster.mbflag\n\t\t \t\tFROM stockmaster\n\t\t\t\tWHERE stockmaster.stockid='" . $NewItem . "'";
示例6: _
<th class="ascending">' . _('Cheque No') . '</th>
<th class="ascending">' . _('Ref') . '</th>
<th class="ascending">' . $TypeName . '</th>
<th class="ascending">' . _('Date') . '</th>
<th class="ascending">' . _('Amount') . '</th>
<th class="ascending">' . _('Outstanding') . '</th>
<th colspan="3">' . _('Clear') . ' / ' . _('Unclear') . '</th>
</tr>';
$k = 0;
//row colour counter
$i = 1;
//no of rows counter
while ($myrow = DB_fetch_array($PaymentsResult)) {
$DisplayTranDate = ConvertSQLDate($myrow['transdate']);
$Outstanding = $myrow['amt'] - $myrow['amountcleared'];
if (ABS($Outstanding) < 0.008999999999999999) {
/*the payment is cleared dont show the check box*/
printf('<tr style="background-color:#CCCEEE">
<td>%s</td>
<td>%s</td>
<td>%s</td>
<td class="number">%s</td>
<td class="number">%s</td>
<td colspan="2">%s</td>
<td><input type="checkbox" name="Unclear_%s" /><input type="hidden" name="BankTrans_%s" value="%s" /></td>
</tr>', $myrow['ref'], $myrow['banktranstype'], $DisplayTranDate, locale_number_format($myrow['amt'], $CurrDecimalPlaces), locale_number_format($Outstanding, $CurrDecimalPlaces), _('Unclear'), $i, $i, $myrow['banktransid']);
} else {
if ($k == 1) {
echo '<tr class="EvenTableRows">';
$k = 0;
} else {
示例7: foreach
/* end of if quick entry */
/*Now do non-quick entry delete/edits/adds */
if (isset($_SESSION['Items' . $identifier]) or isset($NewItem)) {
if (isset($_GET['Delete'])) {
$_SESSION['Items' . $identifier]->remove_from_cart($_GET['Delete']);
/*Don't do any DB updates*/
}
$AlreadyWarnedAboutCredit = false;
foreach ($_SESSION['Items' . $identifier]->LineItems as $OrderLine) {
if (isset($_POST['Quantity_' . $OrderLine->LineNumber])) {
$Quantity = round(filter_number_format($_POST['Quantity_' . $OrderLine->LineNumber]), $OrderLine->DecimalPlaces);
if (ABS($OrderLine->Price - filter_number_format($_POST['Price_' . $OrderLine->LineNumber])) > 0.01) {
/*There is a new price being input for the line item */
$Price = filter_number_format($_POST['Price_' . $OrderLine->LineNumber]);
$_POST['GPPercent_' . $OrderLine->LineNumber] = ($Price * (1 - filter_number_format($_POST['Discount_' . $OrderLine->LineNumber]) / 100) - $OrderLine->StandardCost * $ExRate) / ($Price * (1 - filter_number_format($_POST['Discount_' . $OrderLine->LineNumber])) / 100);
} elseif (ABS($OrderLine->GPPercent - filter_number_format($_POST['GPPercent_' . $OrderLine->LineNumber])) >= 0.01) {
/* A GP % has been input so need to do a recalculation of the price at this new GP Percentage */
prnMsg(_('Recalculated the price from the GP % entered - the GP % was') . ' ' . $OrderLine->GPPercent . ' the new GP % is ' . filter_number_format($_POST['GPPercent_' . $OrderLine->LineNumber]), 'info');
$Price = $OrderLine->StandardCost * $ExRate / (1 - (filter_number_format($_POST['GPPercent_' . $OrderLine->LineNumber]) + filter_number_format($_POST['Discount_' . $OrderLine->LineNumber])) / 100);
} else {
$Price = filter_number_format($_POST['Price_' . $OrderLine->LineNumber]);
}
$DiscountPercentage = filter_number_format($_POST['Discount_' . $OrderLine->LineNumber]);
if ($_SESSION['AllowOrderLineItemNarrative'] == 1) {
$Narrative = $_POST['Narrative_' . $OrderLine->LineNumber];
} else {
$Narrative = '';
}
if (!isset($OrderLine->DiscountPercent)) {
$OrderLine->DiscountPercent = 0;
}
示例8: multipleAdjustmentAction
//.........这里部分代码省略.........
/* $placement = new Model_Placements();
$placement->form_values['stock_batch_id'] = $batch_id;
$placement->form_values['quantity'] = $data['quantity'];
$placement->form_values['placement_location_id'] = $data['pick_from'];
$placement->form_values['stock_detail_id'] = $detail_id;
$placement->addPlacement(); */
}
$em->getConnection()->commit();
$this->redirect("/stock/multiple-adjustment");
// For Data Show
$temp_stock_list = $stock_master->getTempStocksList();
if ($temp_stock_list != false) {
// $form->transaction_number->setValue($temp_stock_list[0]['transaction_number']);
$form->transaction_date->setValue(date("d/m/Y h:i A", strtotime($temp_stock_list[0]['transaction_date'])));
$form->warehouse_name->setValue($temp_stock_list[0]['to_warehouse']);
$form->transaction_reference->setValue($temp_stock_list[0]['transaction_reference']);
$form->hdn_to_warehouse_id->setValue($temp_stock_list[0]['to_warehouse_id']);
$form->product->setValue($temp_stock_list[0]['to_warehouse_id']);
$arr_data['warehouse_name'] = $temp_stock_list[0]['to_warehouse'];
// $arr_data['warehouse_name'] = $temp_stock_list[0]['to_warehouse'];
$form->activity_id->setValue($temp_stock_list[0]['activity_id']);
$arr_data['tempstocks'] = $temp_stock_list;
$form->makeFieldReadonly();
} else {
$form->transaction_date->setValue(date("d/m/Y h:i A"));
}
}
} catch (Exception $e) {
$em->getConnection()->rollback();
$em->close();
App_FileLogger::info($e);
switch ($e->getMessage()) {
case 'PLCD_QTY_GREATER_THAN_ISSUE_QTY':
$this->view->status = false;
$this->view->msg = "Issue quantity should not greater than placed quantity!";
break;
}
}
$this->view->form = $form;
$this->view->arr_data = $arr_data;
if ($this->_request->type == 's') {
$this->redirect("/stock/issue-search");
}
}
$stock_master->form_values = $form_values;
$temp_stock = $stock_master->getTempStock();
if ($temp_stock != false) {
$arr_data = array_merge($arr_data, $temp_stock);
}
if (!empty($temp_stock['stock_id'])) {
$form->hdn_stock_id->setValue($temp_stock['stock_id']);
$form->hdn_master_id->setValue($temp_stock['stock_id']);
} elseif (!empty($stockid)) {
$form->hdn_stock_id->setValue($stock_id);
$form->hdn_master_id->setValue($stock_id);
}
$this->view->form = $form;
$base_url = Zend_Registry::get('baseurl');
switch ($this->_user_level) {
case 1:
case 2:
case 3:
$this->view->menu_type = 1;
$this->view->inlineScript()->appendFile($base_url . '/js/all_level_combos.js');
break;
case 4:
case 5:
case 6:
$this->view->menu_type = 2;
$this->view->inlineScript()->appendFile($base_url . '/js/level_combos.js');
break;
}
// Edit Issue Start
if (!empty($this->_request->id)) {
$detail_id = $this->_request->id;
$issue = $this->_em->getRepository("StockDetail")->find($detail_id);
$form->transaction_number->setValue($issue->getStockMaster()->getTransactionNumber());
$form->transaction_date->setValue($issue->getStockMaster()->getTransactionDate()->format("d/m/Y h:i A"));
$form->warehouse_name->setValue($issue->getStockMaster()->getToWarehouse()->getWarehouseName());
$form->transaction_reference->setValue($issue->getStockMaster()->getTransactionReference());
//$form->activity_id->setValue($issue->getStockMaster()->getStakeholderActivity()->getPkId());
$arr_data['warehouse_name'] = $issue->getStockMaster()->getToWarehouse()->getWarehouseName();
$form->item_id->setValue($issue->getStockBatch()->getItemPackSize()->getPkId());
$form->fillBatchCombo($issue->getStockBatch()->getItemPackSize()->getPkId());
$form->number->setValue($issue->getStockBatch()->getPkId());
$form->vvm_stage->setValue($issue->getVvmStage());
$form->quantity->setValue($issue->getQuantity());
$av_qty = $issue->getStockBatch()->getQuantity() + ABS($issue->getQuantity());
$form->available_quantity->setValue($av_qty);
$form->expiry_date->setValue($issue->getStockBatch()->getExpiryDate()->format("d/m/Y"));
$this->view->issueedit = true;
$this->view->detail_id = $this->_request->id;
}
// Edit Issue End
$this->view->arr_data = $arr_data;
$this->view->type = $this->_request->getParam("t", "issue");
$this->view->wh_id = $this->_identity->getWarehouseId();
$this->view->params = array("province" => $this->_identity->getProvinceId(), "district" => $this->_identity->getDistrictId());
$this->view->role = $this->_identity->getRoleId();
}
示例9: locale_money_format
}
echo '<td></td>
<td class="number"><b>' . locale_money_format(-$PeriodTotal, $_SESSION['CompanyRecord']['currencydefault']) . '</b></td>
<td></td>
</tr>';
} else {
//its a debit balance b/fwd
if ($PandLAccount == True) {
$RunningTotal = 0;
}
echo '<td class="number"><b>' . locale_money_format($PeriodTotal, $_SESSION['CompanyRecord']['currencydefault']) . '</b></td>
<td colspan="2"></td>
</tr>';
}
$IntegrityReport .= '<br />' . _('Period') . ': ' . $PeriodNo . _('Account movement per transaction') . ': ' . locale_money_format($PeriodTotal, $_SESSION['CompanyRecord']['currencydefault']) . ' ' . _('Movement per ChartDetails record') . ': ' . locale_money_format($ChartDetailRow['actual'], $_SESSION['CompanyRecord']['currencydefault']) . ' ' . _('Period difference') . ': ' . locale_money_format($PeriodTotal - $ChartDetailRow['actual'], $_SESSION['CompanyRecord']['currencydefault']);
if (ABS($PeriodTotal - $ChartDetailRow['actual']) > 0.01) {
$ShowIntegrityReport = True;
}
}
$PeriodNo = $myrow['periodno'];
$PeriodTotal = 0;
}
if ($k == 1) {
echo '<tr class="EvenTableRows">';
$k = 0;
} else {
echo '<tr class="OddTableRows">';
$k++;
}
$RunningTotal += $myrow['amount'];
$PeriodTotal += $myrow['amount'];
示例10: substr
if ($positiontime >= $glb_time) {
$dtime = substr($globalwaketime, 0, 5);
$flagtime = strtotime($theExactTime . " " . $this->config->item('flagtime'));
if ($flagtime < $glb_time) {
$this->config->set_item('flagtime', $globalwaketime);
}
}
}
///////////////////////////////
if (isset($dtime)) {
///////////////////////////////////////////////////////
$atime = substr($time->time, 0, 5);
$nextDay = $dtime > $atime ? 1 : 0;
$dep = EXPLODE(':', $dtime);
$arr = EXPLODE(':', $atime);
$diff = ABS(MKTIME($dep[0], $dep[1], 0, DATE('n'), DATE('j'), DATE('y')) - MKTIME($arr[0], $arr[1], 0, DATE('n'), DATE('j') + $nextDay, DATE('y')));
$hours = FLOOR($diff / (60 * 60));
$mins = FLOOR(($diff - $hours * 60 * 60) / 60);
$secs = FLOOR($diff - ($hours * 60 * 60 + $mins * 60));
if (STRLEN($hours) < 2) {
$hours = "0" . $hours;
}
if (STRLEN($mins) < 2) {
$mins = "0" . $mins;
}
$hours += $mins / 60;
///////////////////////////////////////////
if ($flagw == 1 && $hours > 3 || $flagw == 0 && $hours >= 0.5) {
$timedata['currenttime'] = $time->time;
$timedata['flagw'] = $flagw;
$timedata['type'] = "Snack";
示例11: foreach
}
/* end of if quick entry */
/*Now do non-quick entry delete/edits/adds */
if (isset($_SESSION['Items' . $identifier]) or isset($NewItem)) {
if (isset($_GET['Delete'])) {
$_SESSION['Items' . $identifier]->remove_from_cart($_GET['Delete']);
/*Don't do any DB updates*/
}
foreach ($_SESSION['Items' . $identifier]->LineItems as $ReturnItemLine) {
if (isset($_POST['Quantity_' . $ReturnItemLine->LineNumber])) {
$Quantity = round(filter_number_format($_POST['Quantity_' . $ReturnItemLine->LineNumber]), $ReturnItemLine->DecimalPlaces);
if (ABS($ReturnItemLine->Price - filter_number_format($_POST['Price_' . $ReturnItemLine->LineNumber])) > 0.01) {
/*There is a new price being input for the line item */
$Price = filter_number_format($_POST['Price_' . $ReturnItemLine->LineNumber]);
$_POST['GPPercent_' . $ReturnItemLine->LineNumber] = ($Price * (1 - filter_number_format($_POST['Discount_' . $ReturnItemLine->LineNumber]) / 100) - $ReturnItemLine->StandardCost * $ExRate) / ($Price * (1 - filter_number_format($_POST['Discount_' . $ReturnItemLine->LineNumber])) / 100);
} elseif (ABS($ReturnItemLine->GPPercent - filter_number_format($_POST['GPPercent_' . $ReturnItemLine->LineNumber])) >= 0.01) {
/* A GP % has been input so need to do a recalculation of the price at this new GP Percentage */
prnMsg(_('Recalculated the price from the GP % entered - the GP % was') . ' ' . $ReturnItemLine->GPPercent . ' the new GP % is ' . filter_number_format($_POST['GPPercent_' . $ReturnItemLine->LineNumber]), 'info');
$Price = $ReturnItemLine->StandardCost * $ExRate / (1 - (filter_number_format($_POST['GPPercent_' . $ReturnItemLine->LineNumber]) + filter_number_format($_POST['Discount_' . $ReturnItemLine->LineNumber])) / 100);
} else {
$Price = filter_number_format($_POST['Price_' . $ReturnItemLine->LineNumber]);
}
$DiscountPercentage = filter_number_format($_POST['Discount_' . $ReturnItemLine->LineNumber]);
if ($_SESSION['AllowOrderLineItemNarrative'] == 1) {
$Narrative = $_POST['Narrative_' . $ReturnItemLine->LineNumber];
} else {
$Narrative = '';
}
if (!isset($ReturnItemLine->DiscountPercent)) {
$ReturnItemLine->DiscountPercent = 0;
}
示例12: give_rate_by_id_kom
public function give_rate_by_id_kom($id)
{
$data['id_user'] = Users::where('id', '=', Session::get('user_id'))->first()->id;
$data['id_komunitas'] = $id;
$data['rating'] = Input::get('rating');
$jml = $this->rating->count_rate_row_by_id($data['id_user']);
$jmlplus = $jml + 1;
$total = $this->rating->count_all_rating_by_id($data['id_user']);
$totalplus = $total + $data['rating'];
$avgrate['avg_rate'] = $totalplus / $jmlplus;
$jml2 = $this->komunitas->count_komunitas_rate_by_id($id);
$jml2plus = $jml2 + 1;
$ratetotal = $this->komunitas->count_totalrate_by_idkom($id);
$totalrate = $ratetotal + $data['rating'];
$ratekom['avg_rate'] = $totalrate / $jml2plus;
UserRating::create($data);
UserAvgRate::where('id_user', '=', Session::get('user_id'))->update($avgrate);
Komunitas::where('id', '=', $id)->update($ratekom);
$totrate = $this->rating->count_rate_row_by_id($data['id_user']);
if ($totrate > 1) {
$ratesim = $this->rating->get_all_user_rate($data['id_user'], $id);
//$ratesim = $this->komunitas->get_komunitas_rated_except($id);
foreach ($ratesim as $rated) {
$similar['id_kom1'] = $id;
$similar['id_kom2'] = $rated->id_komunitas;
//$similar['id_kom2'] = $rated->id;
$user_avg = $this->average->get_average_rate($data['id_user']);
$rate1 = $this->rating->get_rating_only($data['id_user'], $similar['id_kom1']);
$rate2 = $this->rating->get_rating_only($data['id_user'], $similar['id_kom2']);
$similar['similarity'] = ($rate1 - $user_avg) * ($rate2 - $user_avg) / (sqrt(pow($rate1 - $user_avg, 2)) * sqrt(pow($rate2 - $user_avg, 2)));
$check = $this->komsimilarity->is_compared($similar['id_kom1'], $similar['id_kom2']);
if ($check == TRUE) {
KomSimilarity::where('id_kom1', '=', $id)->where('id_kom2', '=', $rated->id_komunitas)->update($similar);
} else {
KomSimilarity::create($similar);
}
}
// $allkom = Komunitas::get();
$allkom = $this->komunitas->get_komunitas_rated_except($id);
foreach ($allkom as $kom) {
$israted = $this->rating->is_rated($data['id_user'], $kom->id);
if ($israted == FALSE) {
$ceksimilarity = $this->komsimilarity->get_similarity($kom->id);
foreach ($ceksimilarity as $mirip) {
// $ratekomp = $this->rating->get_rating_only($data['id_user'], $mirip->id_kom2);
$ratekomp = $this->rating->get_rating($mirip->id_kom2);
$simvalue = $this->komsimilarity->get_similarity_value($mirip->id_kom1, $mirip->id_kom2);
$predict['id_user'] = $data['id_user'];
$predict['id_komunitas'] = $mirip->id_kom2;
$predict['rate_predict'] = $ratekomp * $simvalue / ABS($simvalue);
$ceki = $this->predict->is_predicted($data['id_user'], $mirip->id_kom2);
if ($ceki == TRUE) {
KomRatePredict::where('id_user', '=', $data['id_user'])->where('id_komunitas', '=', $mirip->id_kom2)->update($predict);
} else {
KomRatePredict::create($predict);
}
}
}
}
}
// // $allkom = Komunitas::get();
// $allkom = $this->komunitas->get_komunitas_rated_except($id);
// foreach ($allkom as $kom) {
// $israted = $this->rating->is_rated($data['id_user'], $kom->id);
// if ($israted == FALSE) {
// $ceksimilarity = $this->komsimilarity->get_similarity($kom->id);
// foreach ($ceksimilarity as $mirip) {
// $cekrating = $this->rating->is_rated($data['id_user'], $mirip->id_kom2);
// if ($cekrating == FALSE) {
// $ratekomp = $this->rating->get_rating_only($data['id_user'], $mirip->id_kom1);
// $simvalue = $this->komsimilarity->get_similarity_value($mirip->id_kom1, $mirip->id_kom2);
// $predict['id_user'] = $data['id_user'];
// $predict['id_komunitas'] = $mirip->id_kom2;
// $predict['rate_predict'] = (($ratekomp * $simvalue)/(ABS($simvalue)));
// $ceki = $this->predict->is_predicted($data['id_user'], $mirip->id_kom2);
// if ($ceki == TRUE) {
// KomRatePredict::update($predict);
// } else {
// KomRatePredict::create($predict);
// }
// }
// }
// }
// }
$slug = Komunitas::where('id', '=', $id)->first()->slug;
return Redirect::to('/komunitas/' . $slug);
}
示例13: getPlannedIssueByWh
public function getPlannedIssueByWh($wh_id)
{
$str_sql = $this->_em->createQueryBuilder()->select("fa")->from("PipelineConsignments", "fa")->where("fa.fromWarehouse = " . $wh_id)->andWhere("fa.status != 'Received'")->andWhere("fa.transactionType = 2")->andWhere("fa.itemPackSize IN (" . Zend_Registry::get('barcode_products') . ")");
$rows = $str_sql->getQuery()->getResult();
if (count($rows) > 0) {
$arr_data = array();
foreach ($rows as $row) {
$arr_data[] = array('record_id' => $row->getPkId(), 'trans_no' => $row->getVoucherNumber(), 'arrival_date' => $row->getExpectedArrivalDate()->format("Y-m-d"), 'reference_no' => $row->getReferenceNumber(), 'description' => $row->getDescription(), 'gtin' => $row->getManufacturer()->getGtin(), 'quantity_per_pack' => $row->getManufacturer()->getQuantityPerPack(), 'item_pack_size_id' => $row->getItemPackSize()->getPkId(), 'item_category' => $row->getItemPackSize()->getItemCategory()->getPkId(), 'item_name' => $row->getItemPackSize()->getItemName(), 'batch_no' => $row->getBatchNumber(), 'batch_id' => $row->getStockBatch() != null ? $row->getStockBatch()->getPkId() : 0, 'production_date' => $row->getProductionDate() != null ? $row->getProductionDate()->format("Y-m-d") : '', 'expiry_date' => $row->getExpiryDate()->format("Y-m-d"), 'manufacturer' => $row->getManufacturer()->getStakeholder()->getStakeholderName(), 'manufacturer_id' => $row->getManufacturer()->getStakeholder()->getPkId(), 'stakeholder_item_pack_size_id' => $row->getManufacturer()->getPkId(), 'quantity' => $row->getQuantity(), 'received_quantity' => ABS($row->getReceivedQuantity()), 'from_wh_name' => $row->getFromWarehouse()->getWarehouseName(), 'from_wh_id' => $row->getFromWarehouse()->getPkId(), 'to_wh_id' => $row->getToWarehouse()->getPkId(), 'to_wh_name' => $row->getToWarehouse()->getWarehouseName());
}
return $arr_data;
} else {
return array(array("message" => "No record found"));
}
}
示例14: get_eliminated_pointcount
function get_eliminated_pointcount($slide, $len, $path1)
{
$WP_EXACT_MATCH_ERROR = get_config_var("min_wp_dist");
// $WP_EXACT_MATCH_ERROR=3;
$pointcount = 0;
$iend = (int) (($path1['lk'] - $slide) / $len);
for ($i = 0; $i < $iend; $i++) {
$matchcount = 0;
$start = $slide + $len * $i;
$end = $start + $len;
for ($j = $start; $j <= $end; $j++) {
$dist_x = ABS($path1[$j + $len]['x'] - $path1[$j]['x']);
$dist_y = ABS($path1[$j + $len]['y'] - $path1[$j]['y']);
$dist = sqrt($dist_x * $dist_x + $dist_y * $dist_y);
//parse_debug_report("len=$len, slide=$slide,iend=$iend, start=$start, end=$end,j=$j,j2=".($j+$len)." total nodes =".$path1['lk']." dist=$dist x1=".$path1[$j+$len]['x']." y1 =".$path1[$j+$len]['y']." x2=".$path1[$j]['x']." y2=".$path1[$j]['y']."");
if ($dist < $WP_EXACT_MATCH_ERROR) {
$matchcount++;
}
}
if ($matchcount == $len) {
$pointcount += $len;
}
// $pointcount += $matchcount;
}
return $pointcount;
}
示例15: tender
function tender($right, $strl)
{
$tender_upc = "";
$dollar = $_SESSION["dollarOver"];
// // set_error_handler("prehkeys_dataError");
if ($_SESSION["LastID"] == 0) {
boxMsg("transaction in progress");
} elseif ($strl > 999999) {
xboxMsg("tender amount of " . truncate2($strl / 100) . "<BR>exceeds allowable limit");
} elseif ($right == "WT") {
xboxMsg("WIC tender not applicable");
} elseif ($right == "CK" && $_SESSION["ttlflag"] == 1 && ($_SESSION["isMember"] != 0 || $_SESSION["isStaff"] != 0) && $strl / 100 - $_SESSION["amtdue"] - 0.005 > $dollar && $_SESSION["cashOverLimit"] == 1) {
boxMsg("member or staff check tender cannot exceed total purchase by over \$" . $dollar . ".00");
} elseif (($right == "CC" || $right == "TB") && $strl / 100 > $_SESSION["amtdue"] + 0.005 && $_SESSION["refundTotal"] == 0) {
xboxMsg("credit card tender cannot exceed purchase amount");
} elseif ($right == "FS" && $strl / 100 > $_SESSION["fsEligible"] + 0.005 && $_SESSION["refundTotal"] == 0) {
xboxMsg("EBT food tender cannot exceed eligible amount");
} elseif ($right == "EF" && truncate2($strl / 100) > $_SESSION["fsEligible"]) {
xboxMsg("no way!");
} else {
getsubtotals();
if ($_SESSION["ttlflag"] == 1 && ($right == "CX" || $right == "MI")) {
// added ttlflag on 2/28/05 apbw
$charge_ok = chargeOk();
if ($right == "CX" && $charge_ok == 1 && strlen($_SESSION["memberID"]) == 5 && substr($_SESSION["memberID"], 0, 1) == "5") {
$charge_ok = 1;
} elseif ($right == "MI" && $charge_ok == 1) {
$charge_ok = 1;
} else {
$charge_ok = 0;
}
}
// else $_SESSION["chargetender"] = 0; // commented out by apbw 2/14/05 - reset flag in printlib only
$strl = $strl / 100;
if ($_SESSION["ttlflag"] == 0) {
boxMsg("transaction must be totaled before tender can be accepted");
} elseif (($right == "FS" || $right == "EF") && $_SESSION["fntlflag"] == 0) {
boxMsg("eligble amount must be totaled before foodstamp tender can be accepted");
} elseif ($right == "EF" && $_SESSION["fntlflag"] == 1 && $_SESSION["fsEligible"] + 10 <= $strl) {
xboxMsg("Foodstamp tender cannot exceed elible amount by over \$10.00");
} elseif ($right == "CX" && $charge_ok == 0) {
xboxMsg("member " . $_SESSION["memberID"] . "<BR>is not authorized<BR>to make corporate charges");
} elseif ($right == "MI" && $_SESSION["isStaff"] == 0) {
// apbw 2/15/05 SCR
xboxMsg("member " . $_SESSION["memberID"] . "<BR>is not authorized<BR>to make employee charges");
// apbw 2/15/05 SCR
} elseif ($right == "MI" && $charge_ok == 0 && $_SESSION["availBal"] < 0) {
xboxMsg("member " . $_SESSION["memberID"] . "<BR> has \$" . $_SESSION["availBal"] . " available.");
} elseif ($right == "MI" && $charge_ok == 1 && $_SESSION["availBal"] < 0) {
xboxMsg("member " . $_SESSION["memberID"] . "<BR>is over limit");
} elseif ($right == "MI" && $charge_ok == 0) {
xboxMsg("member " . $_SESSION["memberID"] . "<BR>is not authorized to make employee charges");
} elseif ($right == "MI" && $charge_ok == 1 && $_SESSION["availBal"] + $_SESSION["memChargeTotal"] - $strl <= 0) {
xboxMsg("member " . $_SESSION["memberID"] . "<br> has exceeded charge limit");
} elseif ($right == "MI" && $charge_ok == 1 && ABS($_SESSION["memChargeTotal"]) + $strl >= $_SESSION["availBal"] + 0.005 && $_SESSION["store"] == "WFC") {
$memChargeRemain = $_SESSION["availBal"];
$memChargeCommitted = $memChargeRemain + $_SESSION["memChargeTotal"];
xboxMsg("available balance for charge <br>is only \$" . $memChargeCommitted . ".<br><b><font size = 5>\$" . number_format($memChargeRemain, 2) . "</font></b><br>may still be used on this purchase.");
} elseif (($right == "MI" || $right == "CX") && truncate2($_SESSION["amtdue"]) < truncate2($strl)) {
xboxMsg("charge tender exceeds purchase amount");
} else {
$query = "select * from tenders where tendercode = '" . $right . "'";
$db = pDataConnect();
$result = sql_query($query, $db);
$num_rows = sql_num_rows($result);
if ($num_rows == 0) {
inputUnknown();
} else {
$row = sql_fetch_array($result);
$tender_code = $right;
$tendered = -1 * $strl;
if ($tender_code == "CC" && $_SESSION["CCintegrate"] == 1) {
$tender_upc = $_SESSION["troutd"];
}
/* else{
$tender_desc = $row["TenderName"];
}
*/
$tender_desc = $row["TenderName"];
$_SESSION["tenderamt"] = $strl;
$unit_price = 0;
if ($tender_code == "FS" && $strl > $_SESSION["fsEligible"] && $strl < $_SESSION["subtotal"]) {
$unit_price = -1 * $_SESSION["fsEligible"];
} elseif ($tender_code == "FS") {
$unit_price = -1 * $strl;
}
if ($strl - $_SESSION["amtdue"] > 0) {
$_SESSION["change"] = $strl - $_SESSION["amtdue"];
} else {
$_SESSION["change"] = 0;
}
// ccm-rle 9-23-09 This is where the pop-up screen requires check endorsement. CCM will comment out because they don't require check endorsement. problem is this is the start of a if statement and without it the else needs to be removed as well and the following bracket
// if ($right == "CK" && $_SESSION["msgrepeat"] == 0) {
// $_SESSION["boxMsg"] = "<BR>insert check</B><BR>press [enter] to endorse<P><FONT size='-1'>[clear] to cancel</FONT>";
// $_SESSION["endorseType"] = "check";
// boxMsgscreen();
// }
// elseif ($right == "TC" && $_SESSION["msgrepeat"] == 0) { // commented out to prevent gift cert franking
// $_SESSION["boxMsg"] = "<B> insert gift certificate<B><BR>press [enter] to endorse<P><FONT size='-1'>[clear] to cancel</FONT>";
// $_SESSION["endorseType"] = "check";
//.........这里部分代码省略.........