public function calculateCompanyFeeAction() { $out = ''; $params = $this->getRequest()->getParams(); $c_code = '£'; $total = $params['total']; $payment_type = $params["payment_type"]; $type = $params['type']; $ob_type = $type == 'order' ? 's' : 'b'; // Company $user = (array) Zend_Auth::getInstance()->getIdentity(); $company = $this->getCompanies()->getById($user['company_id']); $company = !is_null($company) ? $company->toArray() : array(); $company_fee_type = $company[$payment_type . '_' . $ob_type . '_fee_type']; $company_fee_flat = $company[$payment_type . '_' . $ob_type . '_flat_fee']; $company_fee_percentage = $company[$payment_type . '_' . $ob_type . '_percentage_fee']; $company_fee_minimum = $company[$payment_type . '_' . $ob_type . '_minimum_fee']; $v = ''; // Flat if ($company_fee_type == 'flat') { if ($type == 'order') { $total += $company_fee_flat; $cf_symbol = '+'; } elseif ($type == 'buyback') { $total -= $company_fee_flat; $cf_symbol = '-'; } // Percentage } else { if ($company_fee_type == 'percentage') { $company_fee_percentage_out = $total * $company_fee_percentage / 100; if ($type == 'order') { $total += $company_fee_percentage_out; $cf_symbol = '+'; } elseif ($type == 'buyback') { $total -= $company_fee_percentage_out; $cf_symbol = '-'; } } } // Caluclate minimum if ($company_fee_percentage < $company_fee_minimum) { if ($type == 'order') { $total += $company_fee_minimum; $cf_symbol = '+'; } elseif ($type == 'buyback') { $total -= $company_fee_minimum; $cf_symbol = '-'; } $company_fee_type = 'minimum'; } // Company flat fee if ($company_fee_type == 'flat' && $company_fee_flat != 0) { $v = $cf_symbol . ' ' . $c_code . ' ' . round2Nr($company_fee_flat); // Company percentage fee } else { if ($company_fee_type == 'percentage' && $company_fee_percentage != 0) { $v = $cf_symbol . ' % ' . round2Nr($company_fee_percentage) . ' = ' . $c_code . ' ' . round2Nr($company_fee_percentage_out); // Company minimum fee } else { if ($company_fee_type == 'minimum' && $company_fee_minimum != 0) { $v = $cf_symbol . ' ' . $c_code . ' ' . round2Nr($company_fee_minimum); } } } // If any type of company fee if (!empty($v)) { $out .= '<div class="form-group"> <label>Company <i>"' . $company['name'] . '"</i> flat fee</label> <br /> <input type="text" value=" ' . $v . ' " class="form-control" disabled /> </div>'; } else { $out .= '<div class="form-group"> <lable><i>"' . $company['name'] . '" has no company fees for this type of ' . $type . ' </div>'; } $data = array('total' => $total, 'html' => $out); echo json_encode($data); }
/** * Render CRUD Table * * @param mixed $table * @param mixed $s_text * @param mixed $icon_class * @param mixed $del_in_value * @param mixed $array_in * @param mixed $array_nv */ public static function renderCrudTable($thisss, $table = '', $s_text = '', $icon_class = '', $del_in_value = '', $array_in = array(), $array_nv = array(), $other_status = false, $extra_text = '', $show_add = true, $show_edit = true, $show_delete = true, $inFront = false, $extra_html = '', $extra_columns = array(), $withApproveReject = false) { include APPLICATION_PATH . '/views/helpers/ShowStatusChange.php'; $sscHelper = new Zend_View_Helper_ShowStatusChange(); $_table = $s_text == 'order' || $s_text == 'buyback' ? $table . '?type=' . $s_text : $table; $_title = $s_text == 'order' || $s_text == 'buyback' ? $s_text : $table; $out = '<header>'; if ($show_add) { $out .= '<a href="#" class="btn btn-primary pull-right ajax-add-item" data-table="' . $_table . '" data-title="' . $_title . '"> <span class="glyphicon glyphicon-plus"></span> Add ' . ucfirst($s_text) . '</a>'; } $out .= '<h2><span class="' . $icon_class . '"></span> ' . (!empty($extra_text) ? $extra_text : ucfirst($table)) . '</h2>'; $out .= !empty($extra_html) ? $extra_html : ''; $out .= '<hr /> </header>'; if (!empty($array_in)) { if ($withApproveReject) { $out .= '<form enctype="multipart/form-data" method="post" action="' . $thisss->baseUrl('approve-reject-ob') . '" class="pullLeft" id="arObForm"> <div class="pull-left"> <button type="submit" name="' . $s_text . '_approved" class="btn btn-primary mr10"> <span class="glyphicon glyphicon-ok"></span> Approve selected</button> <button type="submit" name="' . $s_text . '_rejected" class="btn btn-primary mr10 reject-selected"> <span class="glyphicon glyphicon-remove"></span> Reject selected</button> <a href="#" class="btn btn-primary mr10 check-all">Check all</a> <a href="#" class="btn btn-primary mr10 uncheck-all">Uncheck all</a> </div> <div class="clearfix"> </div> '; } $out .= ' <table class="table table-striped"> <thead>'; if ($inFront) { if (!empty($extra_columns)) { foreach ($extra_columns as $column) { $out .= '<th>' . $column['column_name'] . '</th>'; } } if ($withApproveReject) { $out .= '<th style="text-align: center;">Check</th>'; $out .= '<th style="text-align: center;">Approve</th>'; $out .= '<th style="text-align: center;">Reject</th>'; } if ($show_delete) { $out .= '<th style="text-align: center;">Delete</th>'; } if ($show_edit) { $out .= '<th style="text-align: center;">Edit</th>'; } if (!$other_status) { $out .= '<th style="text-align: center;">Status</th>'; } } foreach ($array_nv as $i) { $text = $i[0]; $name = $i[1]; $type = $i[2]; $out .= '<th>' . $text . '</th>'; } if (!$inFront) { if (!empty($extra_columns)) { foreach ($extra_columns as $column) { $out .= '<th>' . $column['column_name'] . '</th>'; } } if ($withApproveReject) { $out .= '<th style="text-align: center;">Check</th>'; $out .= '<th style="text-align: center;">Approve</th>'; $out .= '<th style="text-align: center;">Reject</th>'; } if (!$other_status) { $out .= '<th style="text-align: center;">Status</th>'; } if ($show_edit) { $out .= '<th style="text-align: center;">Edit</th>'; } if ($show_delete) { $out .= '<th style="text-align: center;">Delete</th>'; } } $out .= '</thead> <tbody>'; foreach ($array_in as $a) { $out .= '<tr>'; if ($inFront) { if (!empty($extra_columns)) { foreach ($extra_columns as $column) { $out .= '<td style="text-align: center;">' . $column['column_content'] . '</td>'; } } if ($withApproveReject) { $out .= '<td style="text-align: center;"> <input type="checkbox" name="uid[' . $a['uid'] . ']" class="uid-checkbox" /> </td> <td style="text-align: center;"> <a href="' . $thisss->baseUrl('approve-reject-ob?type=' . $s_text . '&uid=' . $a['uid'] . '&status=approved&single_uid=true') . '"> <span class="glyphicon glyphicon-ok"> </span> </a> </td>'; $out .= '<td style="text-align: center;"> <a href="' . $thisss->baseUrl('approve-reject-ob?type=' . $s_text . '&uid=' . $a['uid'] . '&status=rejected&single_uid=true') . '"> <span class="glyphicon glyphicon-remove"> </span> </a> </td>'; } if ($show_delete) { $out .= '<td style="text-align: center;">' . $sscHelper->showStatusChange($thisss, $a['id'], $table, 'deleted', $a[$del_in_value]) . '</td>'; } if ($show_edit) { $out .= '<td style="text-align: center;"><a data-table="' . $_table . '" data-title="' . $_title . '" data-id="' . $a['id'] . '" class="ajax ajax-edit-item"><img src="img/edit.png" class="img-30" /></a></td>'; } if (!$other_status) { $out .= '<td style="text-align: center;">' . $sscHelper->showStatusChange($thisss, $a['id'], $table, $a['status']) . '</td>'; } } foreach ($array_nv as $i) { $text = $i[0]; $name = $i[1]; $type = $i[2]; switch ($type) { case 'text': $out .= '<td' . (!empty($a[$name]) && !is_null($a[$name]) ? '>' . $a[$name] : ' style="text-align: center;">-') . '</td>'; break; case 'round': $out .= '<td' . (!empty($a[$name]) && !is_null($a[$name]) ? '>' . round2Nr($a[$name]) : ' style="text-align: center;">-') . '</td>'; break; case 'check': $out .= '<td>' . ($a[$name] == 1 ? '<b>Yes</b>' : 'No') . '</td>'; break; case 'date': $out .= '<td' . (!empty($a[$name]) && !is_null($a[$name]) ? '>' . convertUStoUKdate($a[$name]) : ' style="text-align: center;">-') . '</td>'; break; case 'image': $out .= '<td>' . NL_Render::renderImageInTbl($a[$name]) . '</td>'; break; case 'bg_color': $out .= '<td style="background-color: ' . $a[$name] . '"></td>'; break; case 'array': $out .= '<td' . (!empty($a[$name][$i[3]]) && !is_null($a[$name][$i[3]]) ? '>' . $a[$name][$i[3]] : ' style="text-align: center;">-') . '</td>'; break; case 'link': $out .= '<td' . (!empty($a[$name]) && !is_null($a[$name]) ? '>' . '<a href="' . $i[3] . $a[$name] . '" target="_blank"> <span class="glyphicon glyphicon-print"></span> ' . $a[$name] . '</a>' : ' style="text-align: center;">-') . '</td>'; } } if (!$inFront) { if (!empty($extra_columns)) { foreach ($extra_columns as $column) { $out .= '<td style="text-align: center;">' . $column['column_content'] . '</td>'; } } if (!$other_status) { $out .= '<td style="text-align: center;">' . $sscHelper->showStatusChange($thisss, $a['id'], $table, $a['status']) . '</td>'; } if ($show_edit) { $out .= '<td style="text-align: center;"><a data-table="' . $_table . '" data-title="' . $_title . '" data-id="' . $a['id'] . '" class="ajax ajax-edit-item"><img src="img/edit.png" class="img-30" /></a></td>'; } if ($show_delete) { $out .= '<td style="text-align: center;">' . $sscHelper->showStatusChange($thisss, $a['id'], $table, 'deleted', $a[$del_in_value]) . '</td>'; } } $out .= '</tr>'; } $out .= '</tbody> </table>'; } else { $out .= '<div class="panel"> <h4 style="margin-left: 10px;">No ' . (!empty($extra_text) ? strtolower($extra_text) : $table) . ' listed</h5> </div>'; } if ($withApproveReject) { $out .= "</form>\n <script>\n \$(document).ready(function(){\n \$('.check-all').on('click', function(){\n \$('.uid-checkbox').prop('checked', true);\n });\n\n \$('.uncheck-all').on('click', function(){\n \$('.uid-checkbox').prop('checked', false);\n });\n });\n </script>"; } return $out; }
} elseif ($_POST['feed_type'] == 'buyback') { $feed_buy_percentage = $result['FeedExchange'] * $result['FeedBuy'] / 100; $feed_rate = $result['FeedExchange'] + $feed_buy_percentage; } // Do the amount to receive if ($_POST['which'] == 'spend') { $amount_receive = $_POST['amount_spend'] / $feed_rate; $result['amount_receive'] = round2Nr($amount_receive); // Do the amount to spend } else { if ($_POST['which'] == 'receive') { $amount_spend = $_POST['amount_receive'] * $feed_rate; $result['amount_spend'] = round2Nr($amount_spend); } } $result['feed_rate'] = round2Nr($feed_rate); echo json_encode($result); break; /** * CHECKOUT */ /** * CHECKOUT */ case 'checkout': /** @var send email $api_send_email */ $api_send_email = 1; $api_ip = $api_ip; $api_url = 'http://' . $api_ip . '/master/api/'; $subject = 'K-FX%20-%20Checkout%20Informations'; $api_url .= 'sendmail?env=kfx&subject=' . $subject . '&template=checkout&email=' . $_POST['email'] . '&';