当前位置: 首页>>代码示例>>PHP>>正文


PHP Discount::model方法代码示例

本文整理汇总了PHP中Discount::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Discount::model方法的具体用法?PHP Discount::model怎么用?PHP Discount::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Discount的用法示例。


在下文中一共展示了Discount::model方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: attach

 /**
  * Attach behavior to model
  * @param $owner
  */
 public function attach($owner)
 {
     if (!$owner->isNewRecord && Yii::app()->controller instanceof Controller) {
         if (DiscountBehavior::$discounts === null) {
             DiscountBehavior::$discounts = Discount::model()->activeOnly()->applyDate()->findAll();
         }
         parent::attach($owner);
     }
 }
开发者ID:kolbensky,项目名称:rybolove,代码行数:13,代码来源:DiscountBehavior.php

示例2: actionDelete

 /**
  * Delete discount
  * @param array $id
  */
 public function actionDelete($id = array())
 {
     if (Yii::app()->request->isPostRequest) {
         $model = Discount::model()->findAllByPk($_REQUEST['id']);
         if (!empty($model)) {
             foreach ($model as $m) {
                 $m->delete();
             }
         }
         if (!Yii::app()->request->isAjaxRequest) {
             $this->redirect('index');
         }
     }
 }
开发者ID:kolbensky,项目名称:rybolove,代码行数:18,代码来源:DefaultController.php

示例3: array

    echo CHtml::button('Contabilizar', array('id' => 'addDiscount', 'style' => 'margin-top: 12px;'));
    ?>
			</div>
			
			<div style="clear:both"></div>
		
		</div>
		
		<div style="width:35%; float:right;" id="extraDiscount">
			
			<?php 
    $criteria = new CDbCriteria();
    $criteria->condition = "UserID = :userid AND BookID = :bookid";
    $criteria->params = array(':userid' => Yii::app()->user->ID, ':bookid' => $model->ID);
    $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) . "&euro;)</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>";
    }
    ?>
开发者ID:FranHurtado,项目名称:hotels,代码行数:31,代码来源:_form.php

示例4: actionUpdate

 public function actionUpdate()
 {
     $id = $_GET['id'];
     $userid = Commonmodel::getOrganID();
     $organid = Commonmodel::getOrganID();
     $title = $_POST['Title'];
     $rate = $_POST['Rate'];
     //$type=$_POST['Type'];
     $starttime = strtotime($_POST['StartTime']);
     $endtime = strtotime($_POST['EndTime']);
     $content = $_POST['Content'];
     $time = time();
     $ownerID = $_POST['iddata'];
     $ownerID = substr($ownerID, 0, -1);
     $ownerID = explode(',', $ownerID);
     $ownerName = $_POST['namedata'];
     $ownerName = substr($ownerName, 0, -1);
     $ownerName = explode(',', $ownerName);
     $lice = $_POST['licedata'];
     $lice = substr($lice, 0, -1);
     $lice = explode(',', $lice);
     $carID = $_POST['cardata'];
     $carID = substr($carID, 0, -1);
     $carID = explode(',', $carID);
     $ownerPhone = $_POST['phonedata'];
     $ownerPhone = substr($ownerPhone, 0, -1);
     $ownerPhone = explode(',', $ownerPhone);
     $nickname = $_POST['nickdata'];
     $nickname = substr($nickname, 0, -1);
     $nickname = explode(',', $nickname);
     //
     $model = Discount::model()->updateAll(array('Title' => $title, 'Content' => $content, 'Rate' => $rate, 'StartTime' => $starttime, 'EndTime' => $endtime, 'UpdateTime' => $time), "ID={$id}");
     $result = DiscountCode::model()->findAll('DiscountID=:id', array(':id' => $id));
     if (!empty($result)) {
         foreach ($result as $value) {
             if (!in_array($value['CarID'], $carID)) {
                 if (!empty($value['CarID'])) {
                     $sql = "delete from tbl_discount_code where CarID={$value['CarID']} and DiscountID={$id}";
                     $result = Yii::app()->db->createCommand($sql)->execute();
                 }
             } else {
                 $arr[] = $value['CarID'];
             }
         }
         foreach ($carID as $val) {
             if (!in_array($val, $arr)) {
                 $code = $this->code();
                 $sql = "select a.OwnerID,b.Name,b.Phone,a.LicensePlate,b.NickName from tbl_car_info a,tbl_car_owner b\n\t\t\t\t\twhere a.ID='{$val}' and a.UserID='{$userid}' \n\t\t\t      and a.OrganID='{$organid}' and a.OwnerID=b.ID";
                 $result = Yii::app()->db->createCommand($sql)->queryRow();
                 $data = Yii::app()->db->createCommand()->insert('tbl_discount_code', array('DiscountID' => $id, 'CarID' => $val, 'OwnerID' => $result['OwnerID'], 'OwnerName' => $result['Name'], 'OwnerPhone' => $result['Phone'], 'Code' => $code, 'LicensePlate' => $result['LicensePlate'], 'NickName' => $result['NickName']));
             }
         }
         echo json_encode($data);
     } else {
         for ($i = 0; $i < count($ownerID); $i++) {
             $code = $this->code();
             $data = Yii::app()->db->createCommand()->insert('tbl_discount_code', array('DiscountID' => $id, 'OwnerID' => $ownerID[$i], 'OwnerName' => $ownerName[$i], 'OwnerPhone' => $ownerPhone[$i], 'Code' => $code, 'LicensePlate' => $lice[$i], 'NickName' => $nickname[$i]));
         }
         echo json_encode($data);
     }
 }
开发者ID:zwq,项目名称:unpei,代码行数:61,代码来源:ServicefavorableController.php

示例5: loadModel

 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = null;
     if ($id > 0) {
         $model = Discount::model()->findByPk($id);
     }
     if ($model === null) {
         return new Discount();
     }
     //throw new CHttpException(404,'The requested page does not exist.');
     return $model;
 }
开发者ID:BGCX067,项目名称:facecom-svn-to-git,代码行数:17,代码来源:DiscountController.php

示例6: actionDeleteExtra

    /**
     *	Delete extra from Book
     */
    public function actionDeleteExtra()
    {
        $model = Extra::model()->findByPK($_POST["extra"]);
        $model->delete();
        $criteria = new CDbCriteria();
        $criteria->condition = "UserID = :userid AND BookID = :bookid";
        $criteria->params = array(':userid' => Yii::app()->user->ID, ':bookid' => $_POST["book"]);
        $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) . "&euro;)</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 : ' . $_POST["book"] . '
	                },
	                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 : ' . $_POST["book"] . '
						}
		        });
		
		        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 : ' . $_POST["book"] . '
						}
		        });
		
		        request.done(function(msg) {
		        		$("#extraDiscount").html(msg);
		        		calculaPrecio($("#Book_Start").val(), $("#Book_Finish").val(), $("#Book_RoomID").val(), $("#Book_Pax").val());
		        });
		    }

		});
		</script>
		';
    }
开发者ID:FranHurtado,项目名称:hotels,代码行数:95,代码来源:BookController.php


注:本文中的Discount::model方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。