Exemplo n.º 1
0
         // remove the rule but save its ID
         if ($p->price_rule_id() != 0) {
             $ruleID = $p->price_rule_id();
             $p->price_rule_id(0);
         }
         $p->save();
         // make sure no other item is using the same
         // rule before deleting it
         if ($ruleID > 1) {
             $ruleProd->reset();
             $ruleProd->price_rule_id($ruleID);
             if (count($ruleProd->find()) == 0) {
                 // no products are using this rule
                 $rule = new PriceRulesModel($dbc);
                 $rule->priceRuleID($ruleID);
                 $rule->delete();
             }
         }
     }
     break;
 case 'newPrice':
     $vid = FormLib::get_form_value('vendorID');
     $bid = FormLib::get_form_value('batchID');
     $sid = FormLib::get_form_value('queueID', 0);
     if ($sid == 99) {
         $sid = 0;
     }
     $price = FormLib::get_form_value('price', 0);
     $viP = $dbc->prepare('
     UPDATE vendorItems
     SET srp=?,
Exemplo n.º 2
0
 public function saveFormData($upc)
 {
     $db = $this->db();
     $new_rule = FormLib::get('price-rule-id', 0);
     $old_rule = FormLib::get('current-price-rule-id', 0);
     if ($new_rule != $old_rule) {
         $prod = new ProductsModel($db);
         $prod->upc(BarcodeLib::padUPC($upc));
         $prod->store_id(1);
         $rule = new PriceRulesModel($db);
         switch ($new_rule) {
             case 0:
                 // no custom rule
             // no custom rule
             case 1:
                 // generic variable pricing
                 /**
                   Update the product with the generic rule ID
                   If it was previously set to a custom rule,
                   that custom rule can be deleted
                 */
                 $prod->price_rule_id($new_rule);
                 if ($old_rule > 1) {
                     $rule->priceRuleID($old_rule);
                     $rule->delete();
                 }
                 break;
             default:
                 // custom rule
                 /**
                   If the product is already using a custom rule,
                   just update that rule record. Otherwise create
                   a new one.
                 */
                 $rule->reviewDate(FormLib::get('rule-review-date'));
                 $rule->details(FormLib::get('rule-details'));
                 $rule->priceRuleTypeID(FormLib::get('price-rule-type'));
                 if ($old_rule > 1) {
                     $rule->priceRuleID($old_rule);
                     $prod->price_rule_id($old_rule);
                     // just in case
                 } else {
                     $new_rule_id = $rule->save();
                     $prod->price_rule_id($new_rule_id);
                 }
         }
         $prod->save();
     }
     return true;
 }