Ejemplo n.º 1
0
 public function actionPriceHistory($item_id)
 {
     $model = new ItemPrice('search');
     $model->unsetAttributes();
     //
     $item = Item::model()->getItemInfo($item_id);
     if (Yii::app()->request->isAjaxRequest) {
         $cs = Yii::app()->clientScript;
         $cs->scriptMap = array('jquery.js' => false, 'bootstrap.js' => false, 'jquery.ba-bbq.min.js' => false, 'jquery.yiigridview.js' => false, 'bootstrap.min.js' => false, 'jquery.min.js' => false, 'bootstrap.notify.js' => false, 'bootstrap.bootbox.min.js' => false);
         Yii::app()->clientScript->scriptMap['*.js'] = false;
         //Yii::app()->clientScript->scriptMap['*.css'] = false;
         if (isset($_GET['ajax']) && $_GET['ajax'] == 'pricehistory-grid') {
             $this->render('_price_history', array('model' => $model, 'item_id' => $item_id, 'item' => $item));
         } else {
             echo CJSON::encode(array('status' => 'render', 'div' => $this->renderPartial('_price_history', array('model' => $model, 'item_id' => $item_id, 'item' => $item), true, true)));
             Yii::app()->end();
         }
     } else {
         $this->render('_price_history', array('model' => $model, 'item_id' => $item_id, 'item' => $item));
     }
 }
Ejemplo n.º 2
0
 public function d011($id = null)
 {
     if (!is_null($id)) {
         $result = ItemPrice::find($id);
         $result->delete();
         ZiUtil::to_json(json_encode("{ success: true}"));
         return;
     }
     App::flash('error', 'Terjadi kesalahan pada inputan anda.');
     App::redirect('itemprice.index');
 }
Ejemplo n.º 3
0
 /** Populates ItemPrices.price_supplement for uk_vat */
 public function uk_vat()
 {
     App::import('model', 'ItemPrice');
     $this->ItemPrice = new ItemPrice();
     $sql = "SELECT * FROM item_prices WHERE item_price_type_id = 6 AND start_date <= NOW() AND (end_date IS NULL OR end_date > NOW())";
     $results = $this->ItemPrice->query($sql);
     foreach ($results as $result) {
         //end item price
         $this->ItemPrice->id = $result['item_prices']['id'];
         $this->ItemPrice->saveField('end_date', DboSource::expression('NOW()'));
         $original_price = $result['item_prices']['price'];
         $price_supplement = round($original_price / 6, 2);
         $new_price = $original_price - $price_supplement;
         unset($result['item_prices']['id']);
         $result['item_prices']['price'] = $new_price;
         $result['item_prices']['price_supplement'] = $price_supplement;
         $result['item_prices']['start_date'] = DboSource::expression('NOW()');
         //add new record
         $new_item = new ItemPrice();
         $new_item->create();
         $new_item->save($result['item_prices']);
     }
 }
Ejemplo n.º 4
0
 public function saveItemPrice($item_id, $new_price, $old_price)
 {
     if ($new_price != $old_price) {
         $item_price = new ItemPrice();
         $item_price->item_id = $item_id;
         $item_price->old_price = $old_price;
         $item_price->new_price = $new_price;
         $item_price->employee_id = Yii::app()->session['employeeid'];
         $item_price->modified_date = date('Y-m-d H:i:s');
         $item_price->save();
     }
 }
Ejemplo n.º 5
0
 protected function updateItemPrice($item_id, $cur_unit_price, $unit_price, $employee_id, $trans_date)
 {
     if ($cur_unit_price != $unit_price) {
         $item_price = new ItemPrice();
         $item_price->item_id = $item_id;
         $item_price->old_price = $cur_unit_price;
         $item_price->new_price = $unit_price;
         $item_price->employee_id = $employee_id;
         $item_price->modified_date = $trans_date;
         $item_price->save();
     }
 }