Exemplo n.º 1
0
 public function validateProductDiscount()
 {
     if (isset($_POST['ProductDiscount'])) {
         $valid = true;
         $this->_productdiscount = array();
         /*Yii::log( "ProductCreateAction: ".CVarDumper::dumpAsString( $_POST['ProductOption'] ),
         			CLogger::LEVEL_ERROR, "product.actions.create" 
         		);*/
         foreach ($_POST['ProductDiscount'] as $i => $pdiscount) {
             if (isset($_POST['ProductDiscount'][$i])) {
                 $discount = new ProductDiscount();
                 $discount->product_id = 0;
                 $discount->attributes = $_POST['ProductDiscount'][$i];
                 $discount->date_start = date('Y-m-d', strtotime($_POST['ProductDiscount'][$i]['date_start']));
                 $discount->date_end = date('Y-m-d', strtotime($_POST['ProductDiscount'][$i]['date_end']));
                 Yii::log("ProductCreateAction: " . $discount->date_start . " " . $discount->date_end, CLogger::LEVEL_ERROR, "product.actions.create");
                 $valid = $discount->validate() && $valid;
                 $this->_productdiscount[] = $discount;
             }
         }
         if (!$valid) {
             return false;
         }
     }
     return true;
 }