condition = "PROD_ID=:prodID "; $criteria->params = array(':prodID' => $Product->ID,); $ProductBranch = StockBranch::model()->findAll($criteria); foreach ($ProductBranch as $StockQty) { $id = $StockQty->BRANCH_ID; ?>< input name='productID[]' value='ID?>' > < input name='branch[]' value='BRANCH_ID?>' > 'off', 'style' => ' width:80px; height:20px; vertical-align:top; text-align:right;', )); ?> Controllerfor ($i; $i < sizeof($_POST['branch']); $i++) { $stockQty = 0; $branch_id = $_POST['branch'][$i]; $product_id = $_POST['productID'][$i]; $stockQty = $_POST['stockQTY'][$i]; if ($stockQty == NULL) { $stockQty = 0; } else { $stockQty = $_POST['stockQTY'][$i]; } $onStock = StockBranch::model()->findByAttributes( array('BRANCH_ID' => $branch_id, 'PROD_ID' => $product_id) ); $updQty = StockBranch::model()->updateAll(array( 'STOCK_QTY'=>$onStock->STOCK_QTY + $stockQty, 'LASTUPDATE' => new CDbExpression('NOW()'), ), 'BRANCH_ID="' .$branch_id. '" AND PROD_ID="' . $product_id . '"' ); } // End Loop
วันพุธที่ 2 เมษายน พ.ศ. 2557
Yii Update Database From Array Data
From
Yii Database Relation | Basic
public function relations() { // NOTE: you may need to adjust the relation name and the related // class name for the relations automatically generated below. return array( 'TProdtype' => array(self::BELONGS_TO, 'Producttypes', array('ID' => 'PRODTYPE_ID')), 'TPrice' => array(self::BELONGS_TO, 'ProductBranch', array('ID' => 'PROD_ID')), 'TBrand' => array(self::BELONGS_TO, 'Brands', array('BRAND_ID' => 'ID')), 'TUnit' => array(self::BELONGS_TO, 'Units', array('UNIT_ID' => 'ID')), ); }
Yii View GridView | Currency (฿)
array(
'name' => 'UNIT_PRICE',
'value' => 'Yii::app()->numberFormatter->formatCurrency($data->UNIT_PRICE, "THB")',
),
array(
'name' => 'TOTAL_PRICE',
'value' => 'Yii::app()->numberFormatter->formatCurrency($data->TOTAL_PRICE, "THB")',
),
: Display ฿1234,00
Yii View | yii cgridview image size
<?php
$this->widget('bootstrap.widgets.TbGridView', array(
'type' => 'striped bordered condensed',
'itemsCssClass' => 'table table-striped table-bordered table-condensed',
'id' => 'search-grid', // id ของตาราง CGridView
'dataProvider' => $tmpOrderList, // ข้อมูล dataProvider จากภายใน Model ของ function search()
'template' => "{items}",
'columns' => array(
array(
'header' => 'No.',
'value' => '$this->grid->dataProvider->pagination->currentPage*$this->grid->dataProvider->pagination->pageSize + $row+1', // row is zero based
),
array(
'name' => 'pictures',
'type' => 'html',
'value' => '(!empty($data->PICTURES))?CHtml::image("./images/Purchase/".$data->PICTURES,"",array("style"=>"width:180px;")):"no image"',
),
'PRODUCT_CODE',
'REF_CODE',
'DESING',
'COLOR',
'SIZE_S',
'SIZE_M',
'SIZE_XL',
'SIZE_F',
'ORDER_QTY',
'UNIT_PRICE',
array(
'name' => 'UNIT_PRICE',
'value' => 'Yii::app()->numberFormatter->formatCurrency($data->UNIT_PRICE, "THB")',
),
array(
'name' => 'TOTAL_PRICE',
'value' => 'Yii::app()->numberFormatter->formatCurrency($data->TOTAL_PRICE, "THB")',
),
array(
'class' => 'bootstrap.widgets.TbButtonColumn',
'template' => ' {edit} {delete}',
'buttons' => array
(
'edit' => array
(
'label' => 'Edit',
'icon' => 'pencil white',
'url' => 'Yii::app()->createUrl("Product/AddProduct", array("prdID"=>$data->ID))',
'options' => array(
'class' => 'btn btn-small btn-success',
),
),
'delete' => array
(
'label' => 'Del',
'icon' => 'icon-trash white',
'url' => 'Yii::app()->createUrl("Product/delProduct", array("prdID"=>$data->ID))',
'options' => array(
'class' => 'btn btn-small btn-danger',
),
),
),
'htmlOptions' => array(
'style' => 'width: 80px',
),
)
),
));
?>
สมัครสมาชิก:
บทความ (Atom)