コード例 #1
0
 /**
  * Updates shippers and shipments that have been changed in the form
  *
  * Backend use only.
  * @return  boolean                     True on success, false an failure,
  *                                      null on noop.
  * @static
  */
 static function update_shipments_from_post()
 {
     if (empty($_POST['bshipment'])) {
         return null;
     }
     $success = true;
     $changed = false;
     // Update all shipment conditions
     if (!empty($_POST['max_weight'])) {
         foreach ($_POST['max_weight'] as $shipment_id => $max_weight) {
             $max_weight = Weight::getWeight(contrexx_input2raw($max_weight));
             $shipper_id = intval($_POST['sid'][$shipment_id]);
             $fee = floatval($_POST['fee'][$shipment_id]);
             $free_from = floatval($_POST['free_from'][$shipment_id]);
             if ($max_weight == Weight::getWeight(self::$arrShipments[$shipper_id][$shipment_id]['max_weight']) && $free_from == self::$arrShipments[$shipper_id][$shipment_id]['free_from'] && $fee == self::$arrShipments[$shipper_id][$shipment_id]['fee']) {
                 continue;
             }
             //DBG::log("Shipment::update_shipments_from_post(): max_weight $max_weight == ".self::$arrShipments[$shipper_id][$shipment_id]['max_weight'].", free_from $free_from == ".self::$arrShipments[$shipper_id][$shipment_id]['free_from'].", fee $fee == ".self::$arrShipments[$shipper_id][$shipment_id]['fee']);
             $changed = true;
             $success &= self::_update_shipment($shipment_id, $shipper_id, $fee, $free_from, $max_weight);
         }
     }
     foreach ($_POST['shipper_name'] as $shipper_id => $shipper_name) {
         $shipper_name = contrexx_input2raw($shipper_name);
         $active = !empty($_POST['active'][$shipper_id]);
         $zone_id = intval($_POST['zone_id'][$shipper_id]);
         $zone_id_old = Zones::getZoneIdByShipperId($shipper_id);
         if ($shipper_name == self::$arrShippers[$shipper_id]['name'] && $active == self::$arrShippers[$shipper_id]['active'] && $zone_id == $zone_id_old) {
             continue;
         }
         $changed = true;
         $success &= self::_update_shipper($shipper_id, $active);
         $success &= self::_rename_shipper($shipper_id, $shipper_name);
         $success &= Zones::update_shipper_relation($zone_id, $shipper_id);
     }
     if ($changed) {
         return $success;
     }
     return null;
 }
コード例 #2
0
ファイル: ShopManager.class.php プロジェクト: Niggu/cloudrexx
 /**
  * The shipment settings view
  */
 static function view_settings_shipment()
 {
     // start show shipment
     self::$objTemplate->addBlockfile('SHOP_SETTINGS_FILE', 'settings_block', 'module_shop_settings_shipment.html');
     self::$objTemplate->setGlobalVariable('SHOP_CURRENCY', Currency::getDefaultCurrencySymbol());
     $arrShipments = Shipment::getShipmentsArray();
     $i = 0;
     foreach (Shipment::getShippersArray() as $shipper_id => $arrShipper) {
         $zone_id = Zones::getZoneIdByShipperId($shipper_id);
         // Inner block first
         self::$objTemplate->setCurrentBlock('shopShipment');
         // Show all possible shipment conditions for each shipper
         if (isset($arrShipments[$shipper_id])) {
             foreach ($arrShipments[$shipper_id] as $shipment_id => $arrConditions) {
                 self::$objTemplate->setVariable(array('SHOP_SHIPMENT_STYLE' => 'row' . (++$i % 2 + 1), 'SHOP_SHIPPER_ID' => $shipper_id, 'SHOP_SHIPMENT_ID' => $shipment_id, 'SHOP_SHIPMENT_MAX_WEIGHT' => $arrConditions['max_weight'], 'SHOP_SHIPMENT_PRICE_FREE' => $arrConditions['free_from'], 'SHOP_SHIPMENT_COST' => $arrConditions['fee']));
                 //self::$objTemplate->parseCurrentBlock();
                 self::$objTemplate->parse('shopShipment');
             }
         }
         // Outer block
         self::$objTemplate->setCurrentBlock('shopShipper');
         self::$objTemplate->setVariable(array('SHOP_SHIPMENT_STYLE' => 'row' . (++$i % 2 + 1), 'SHOP_SHIPPER_ID' => $shipper_id, 'SHOP_SHIPPER_NAME' => \Html::getInputText('shipper_name[' . $shipper_id . ']', $arrShipper['name']), 'SHOP_ZONE_SELECTION' => Zones::getMenu($zone_id, 'zone_id[' . $shipper_id . ']'), 'SHOP_SHIPPER_STATUS' => $arrShipper['active'] ? \Html::ATTRIBUTE_CHECKED : ''));
         self::$objTemplate->parse('shopShipper');
     }
     self::$objTemplate->setVariable('SHOP_ZONE_SELECTION_NEW', Zones::getMenu(0, 'zone_id_new'));
 }