Ejemplo n.º 1
0
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     //find the group
     $this->layout = '//layouts/group';
     $group = Group::model()->findByPk($id);
     $this->group = $group;
     //find all groupProduct that belong to that group
     $model = new GroupProduct('search');
     $model->unsetAttributes();
     // clear any default values
     if (isset($_GET['GroupProduct'])) {
         $model->attributes = $_GET['GroupProduct'];
     }
     $this->render('view', array('model' => $model, 'group' => $group));
 }
Ejemplo n.º 2
0
 public function actionDialogGroupProduct()
 {
     $criteria = new CDbCriteria();
     $criteria->order = 'group_product_name';
     $model = GroupProduct::model()->findAll($criteria);
     $this->render('//Dialog/DialogGroupProduct', array('model' => $model));
 }
Ejemplo n.º 3
0
 public function actionGetGroupProductInfo($group_product_code)
 {
     $attributes = array();
     $attributes["group_product_code"] = Util::input($group_product_code);
     $model = GroupProduct::model()->findByAttributes($attributes);
     echo CJSON::encode($model);
 }
Ejemplo n.º 4
0
 public function actionEventGroupProduct($id)
 {
     $this->layout = '//layouts/eventDetail';
     $this->eventDetail_model = Event::model()->with(array('GroupProductsCount', 'JoinedGroups'))->findByPk($id);
     if ($this->eventDetail_model == null) {
         throw new CHttpException(404, 'The specified Event cannot be found.');
     }
     $model = new GroupProduct('search');
     $model->unsetAttributes();
     // clear any default values
     if (isset($_GET['GroupProduct'])) {
         $model->attributes = $_GET['GroupProduct'];
     }
     $this->render('eventGroupProduct', array('dataprovider' => $model->getOnlyEventData($id)));
 }
Ejemplo n.º 5
0
 public function actionFollowingGroup()
 {
     $user = User::model()->findByPk(Yii::app()->user->id);
     if ($user == null) {
         throw new CHttpException(404, 'The specified user cannot be found.');
     }
     $model = new GroupProduct('search');
     $model->unsetAttributes();
     // clear any default values
     if (isset($_GET['GroupProduct'])) {
         $model->attributes = $_GET['GroupProduct'];
     }
     $this->render('followingGroup', array('model' => $model, 'user' => $user));
 }
Ejemplo n.º 6
0
 function actionProductForm($id = null)
 {
     $this->checkLogin();
     $model = new Product();
     $default_product_expire = 'expire';
     $default_product_return = 'in';
     $default_product_sale_condition = 'sale';
     if (!empty($_POST)) {
         $pk = Util::input($_POST["Product"]["product_id"]);
         if (!empty($pk)) {
             $model = Product::model()->findByPk((int) $pk);
         }
         // group_product_code to group_product_id
         $pk = Util::input($_POST['Product']['group_product_id']);
         $groupProduct = GroupProduct::model()->findByAttributes(array("group_product_code" => $pk));
         if (empty($groupProduct)) {
             $groupProduct = GroupProduct::model()->findByPk($pk);
         }
         $model->attributes = Util::input($_POST["Product"]);
         $model->group_product_id = @$groupProduct->group_product_id;
         $model->weight = Util::input($_POST['weight']);
         if (!empty($_POST['product_tag'])) {
             $model->product_tag = Util::input($_POST['product_tag']);
         } else {
             $model->product_tag = 0;
         }
         // process total small unit
         if (!empty($_POST['Product']['product_quantity_of_pack'])) {
             $total = $model->product_total_per_pack * $model->product_quantity_of_pack;
             $model->product_quantity = $total;
         }
         // product_expire_date
         if (!empty($_POST['Product']['product_expire_date'])) {
             $product_expire_date = Util::input($_POST['Product']['product_expire_date']);
             $model->product_expire_date = Util::thaiToMySQLDate($product_expire_date);
         }
         // save image of product and upload
         if ($_FILES['product_pic']['name'] != "") {
             $name = $_FILES['product_pic']['name'];
             $tmp = $_FILES['product_pic']['tmp_name'];
             $ext = explode(".", $name);
             $ext = $ext[count($ext) - 1];
             $ext = strtolower($ext);
             if ($ext == "png" || $ext == "jpg") {
                 $name = microtime();
                 $name = str_replace(" ", "", $name);
                 $name = str_replace("0.", "", $name);
                 $name = $name . "." . $ext;
                 if (move_uploaded_file($tmp, "upload/{$name}")) {
                     // remove old image
                     if (!empty($model->product_pic)) {
                         $oldImg = $model->product_pic;
                         if (file_exists("upload/{$oldImg}")) {
                             unlink("upload/{$oldImg}");
                         }
                     }
                     // set new image
                     $model->product_pic = $name;
                 }
             }
         }
         // save
         if ($model->save()) {
             $this->redirect(array('ProductIndex'));
         }
     }
     $barcodePrices = null;
     if (!empty($id)) {
         $model = Product::model()->findByPk((int) $id);
         $model->product_expire_date = Util::mysqlToThaiDate($model->product_expire_date);
         $barcodePrices = BarcodePrice::model()->findAllByAttributes(array('barcode_fk' => $model->product_code));
     } else {
         $model->product_total_per_pack = 1;
     }
     $params['model'] = $model;
     $params['default_product_expire'] = $default_product_expire;
     $params['default_product_return'] = $default_product_return;
     $params['default_product_sale_condition'] = $default_product_sale_condition;
     $params['barcodePrices'] = $barcodePrices;
     $this->render('//Config/ProductForm', $params);
 }
Ejemplo n.º 7
0
 /**
  * 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 $id the ID of the model to be loaded
  * @return GroupProduct the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = GroupProduct::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 function actionSaleSumPerType()
 {
     $month = date('m');
     $year = date('Y');
     $yearList = array();
     $yearStart = date('Y');
     for ($i = $yearStart - 5; $i <= $yearStart; $i++) {
         $yearList[$i] = $i;
     }
     if ($_POST) {
         $year = $_POST['year'];
         $month = $_POST['month'];
     }
     $billSale = new BillSale();
     $monthRange = Util::monthRange();
     $groupProducts = GroupProduct::model()->findAll(array('order' => 'group_product_name'));
     $this->render('//Report/ReportSaleSumPerType', array('sum' => 0, 'n' => 1, 'yearList' => $yearList, 'groupProducts' => $groupProducts, 'monthRange' => $monthRange, 'year' => $year, 'month' => $month * 1, 'billSale' => $billSale));
 }
Ejemplo n.º 9
0
 public function getNewerGroupProduct()
 {
     $groupProduct = GroupProduct::model()->newerGroupProduct($this->group_id, $this->id)->findAll();
     return $groupProduct;
 }
Ejemplo n.º 10
0
 public function getGroupProduct()
 {
     return GroupProduct::model()->findByAttributes(array("group_product_code" => $this->group_product_id));
 }
Ejemplo n.º 11
0
 public function run()
 {
     $mostPopularNonR18GroupProduct = GroupProduct::getNonR18MostPopular(5);
     $mostPopularR18GroupProduct = GroupProduct::getR18MostPopular(5);
     $this->render('application.components.view._PopularGroupProductWidget', array('mostPopularNonR18GroupProduct' => $mostPopularNonR18GroupProduct));
 }
Ejemplo n.º 12
0
        $("#formProductExcel").submit();
      }
    });
  }
</script>

<div class="panel panel-info" style="margin: 10px">
  <div class="panel-heading">
    <?php 
echo Yii::t('lang', 'product_info');
?>
    <?php 
if (!empty($group_product_id)) {
    ?>
      <?php 
    $groupProduct = GroupProduct::model()->findByPk($group_product_id);
    ?>
      : <?php 
    echo Yii::t('lang', 'category');
    ?>
      <span class="label label-danger" style="font-size: 12px">
        <?php 
    echo $groupProduct->group_product_name;
    ?>
      </span>
    <?php 
}
?>
  </div>
  <div class="navbar-primary mynav">
    <ul class="nav navbar-nav">