本文整理汇总了PHP中Discount::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Discount::save方法的具体用法?PHP Discount::save怎么用?PHP Discount::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Discount
的用法示例。
在下文中一共展示了Discount::save方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
DB::table('discounts')->truncate();
$discount = new Discount();
$discount->role_id = 5;
//Đại lý chính thức
$discount->branch_id = 1;
//Giày dép
$discount->from_rate = 0;
$discount->to_rate = 3000000;
$discount->percentage = 5;
$discount->save();
$discount = new Discount();
$discount->role_id = 5;
//Đại lý chính thức
$discount->branch_id = 1;
//Giày dép
$discount->from_rate = 3000001;
$discount->to_rate = 6000000;
$discount->percentage = 15;
$discount->save();
$discount = new Discount();
$discount->role_id = 5;
//Đại lý chính thức
$discount->branch_id = 1;
//Giày dép
$discount->from_rate = 6000001;
$discount->to_rate = 300000000;
$discount->percentage = 25;
$discount->save();
}
示例2: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Discount();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Discount'])) {
$model->attributes = $_POST['Discount'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model));
}
示例3: store
public function store()
{
$nominal = Input::get('nominal');
$nominal = str_replace(",", ".", $nominal);
$nominal = str_replace(".", "", $nominal);
$nominal = substr($nominal, 0, -2);
$discount = new Discount();
$discount->name = Input::get('name');
$discount->given_by = Input::get('given_by');
$discount->nominal = $nominal;
$discount->save();
Session::flash('message', 'Sukses menambahkan data baru!');
}
示例4: makeDiscountType
public function makeDiscountType()
{
$cpage = 'discounts';
$i = Input::all();
$validator = Validator::make($i, array('name' => 'min:3|required', 'description' => 'min:5|required'));
$error_output = null;
//$discount = Discount::where('id', $i['discount_id'])->first();
if ($validator->fails()) {
$error_array = $validator->messages()->toArray();
foreach ($error_array as $errors) {
$error_output .= ' ' . $errors[0];
}
return Redirect::to('adminsite/discount')->with('error', $error_output);
}
if (isset($i['type']) && $i['type'] == 0) {
$codes = explode(';', $i['code']);
try {
foreach ($codes as $code) {
$discount = new Discount();
$discount->name = $i['name'];
$discount->type = $i['type'];
$discount->effect_type = $i['effect_type'];
$discount->effect = $i['effect'];
$discount->description = $i['description'];
$discount->code = $code;
$discount->save();
}
} catch (Illuminate\Database\QueryException $e) {
return Redirect::to('adminsite/discount')->with('error', $e->errorInfo[2]);
}
return Redirect::to('adminsite/discount')->with('success', 'You have successfuly set a customer discount.');
} else {
$discount = new Discount();
$discount->name = $i['name'];
$discount->type = $i['type'];
$discount->effect_type = $i['effect_type'];
$discount->effect = $i['effect'];
$discount->description = $i['description'];
$discount->code = null;
try {
if ($discount->save()) {
return Redirect::to('adminsite/discount')->with('success', 'You have successfuly set a customer discount.');
}
} catch (Illuminate\Database\QueryException $e) {
return Redirect::to('adminsite/discount')->with('error', $e->errorInfo[2]);
}
}
}
示例5: dirname
$dateFrom = time();
if (Configuration::get('PS_ORDER_RETURN')) {
$dateFrom = $dateFrom + 60 * 60 * 24 * intval(Configuration::get('PS_ORDER_RETURN_NB_DAYS'));
}
$voucher->date_from = date('Y-m-d H:i:s', $dateFrom);
$voucher->date_to = date('Y-m-d H:i:s', $dateFrom + 31536000);
// + 1 year
$voucher->minimal = 0;
$voucher->active = 1;
$languages = Language::getLanguages(true);
$default_text = Configuration::get('PS_LOYALTY_VOUCHER_DETAILS', intval(Configuration::get('PS_LANG_DEFAULT')));
foreach ($languages as $language) {
$text = Configuration::get('PS_LOYALTY_VOUCHER_DETAILS', intval($language['id_lang']));
$voucher->description[intval($language['id_lang'])] = $text ? strval($text) : strval($default_text);
}
$voucher->save();
/* register order(s) which contribute to create this voucher */
LoyaltyModule::registerDiscount($voucher);
Tools::redirect('modules/loyalty/loyalty-program.php');
}
include dirname(__FILE__) . '/../../header.php';
$orders = LoyaltyModule::getAllByIdCustomer(intval($cookie->id_customer), intval($cookie->id_lang));
$smarty->assign(array('orders' => $orders, 'totalPoints' => $customerPoints, 'voucher' => LoyaltyModule::getVoucherValue($customerPoints, intval($cookie->id_currency)), 'validation_id' => LoyaltyStateModule::getValidationId(), 'transformation_allowed' => $customerPoints > 0));
/* Discounts */
$nbDiscounts = 0;
$discounts = array();
if ($ids_discount = LoyaltyModule::getDiscountByIdCustomer(intval($cookie->id_customer))) {
$nbDiscounts = count($ids_discount);
foreach ($ids_discount as $key => $discount) {
$discounts[$key] = new Discount($discount['id_discount'], intval($cookie->id_lang));
$discounts[$key]->date_add = $discount['date_add'];
示例6: actionAddDiscount
/**
* Add discount to Book
*/
public function actionAddDiscount()
{
$bookID = $_POST["book"];
$name = $_POST["discount"];
$value = $_POST["value"];
$model = new Discount();
$model->BookID = $bookID;
$model->Name = $name;
$model->Value = $value;
$model->UserID = Yii::app()->user->ID;
if ($model->save()) {
$criteria = new CDbCriteria();
$criteria->condition = "UserID = :userid AND BookID = :bookid";
$criteria->params = array(':userid' => Yii::app()->user->ID, ':bookid' => $model->BookID);
$modelExtra = Extra::model()->findAll($criteria);
$modelDiscount = Discount::model()->findAll($criteria);
echo "<h2 class='extra'>Suplementos</h2>";
if (count($modelExtra) == 0) {
echo "<p>No hay suplementos</p>";
}
foreach ($modelExtra as $extra) {
echo "<p><span class='deleteExtra' id='" . $extra->ID . "'>X</span> " . $extra->Name . " (" . str_replace(',', '.', $extra->Value) . "€)</p>";
}
echo "<h2 class='extra'>Descuentos</h2>";
if (count($modelDiscount) == 0) {
echo "<p>No hay suplementos</p>";
}
foreach ($modelDiscount as $discount) {
echo "<p><span class='deleteDiscount' id='" . $discount->ID . "'>X</span> " . $discount->Name . " (" . $discount->Value . "%)</p>";
}
echo '<script>
function calculaPrecio(start,finish,room,pax)
{
var request = $.ajax({
url: "' . $this->createURL("book/calculateprice") . '",
type: "POST",
data: {
start : start,
finish : finish,
room : room,
pax : pax,
book : ' . $model->BookID . '
},
dataType: "html"
});
request.done(function(msg) {
$("#pvp").html(msg);
});
}
// Delete Extra from Book
$(".deleteExtra").click(function(){
if(confirm("\\u00bfSeguro que quieres eliminar este suplemento?"))
{
var request = $.ajax({
url: "' . $this->createURL("book/deleteExtra") . '",
type: "POST",
dataType: "html",
data: {
extra : $(this).attr("id"),
book : ' . $model->BookID . '
}
});
request.done(function(msg) {
$("#extraDiscount").html(msg);
calculaPrecio($("#Book_Start").val(), $("#Book_Finish").val(), $("#Book_RoomID").val(), $("#Book_Pax").val());
});
}
});
// Delete Discount from Book
$(".deleteDiscount").click(function(){
if(confirm("\\u00bfSeguro que quieres eliminar este descuento?"))
{
var request = $.ajax({
url: "' . $this->createURL("book/deleteDiscount") . '",
type: "POST",
dataType: "html",
data: {
discount : $(this).attr("id"),
book : ' . $model->BookID . '
}
});
request.done(function(msg) {
$("#extraDiscount").html(msg);
calculaPrecio($("#Book_Start").val(), $("#Book_Finish").val(), $("#Book_RoomID").val(), $("#Book_Pax").val());
});
}
});
</script>';
} else {
//.........这里部分代码省略.........
示例7: billdiscount
public static function billdiscount($account_id, $for_month, $amount, $bill)
{
$bill_info = Billinformation::where('bill_no', $bill->bill_no)->get();
foreach ($bill_info as $key) {
$amount_id[] = $key->discount_id;
}
if (count($bill_info) == 0) {
$amount_id[] = NULL;
}
$bill_amount = Discount::whereIn('id', $amount_id)->sum('amount');
if ($bill->discount == $bill_amount) {
return $bill_amount;
} else {
if ($bill->discount && $bill_amount == 0) {
$discount = new Discount();
$discount->account_id = $account_id;
$discount->for_month = $for_month;
$discount->amount = $amount;
$discount->date = date('Y-m-d');
$discount->remarks = "billdiscount retransaction";
$discount->is_considered = 1;
$discount->save();
$bill_info = Discount::discounts($discount->id, $discount->account_id, $discount->for_month);
return $discount->amount;
} else {
if ($bill->discount != $bill_amount) {
return false;
}
}
}
}