Example #1
0
 public function saveStoreId()
 {
     return Delivery\ExtraServices\Manager::saveStoreIdForShipment($this->getId(), $this->getDeliveryId(), $this->getStoreId());
 }
Example #2
0
 /**
  * Function performs a conversion between a shared cache and the particular structure of our $arResult
  * @param mixed[] $cached Cached data taken from obtainDataReferences()
  * @return mixed[] Data structure that is appropriate for our $arResult
  */
 protected function adaptCachedReferences($cached)
 {
     $formed = array();
     // form person type
     $formed["PERSON_TYPE"] = $cached['PERSON_TYPE'][$this->dbResult["PERSON_TYPE_ID"]];
     // form status
     $formed['STATUS'] = $cached['STATUS'][$this->dbResult["STATUS_ID"]];
     // form delivery
     foreach ($this->dbResult['SHIPMENT'] as $shipment) {
         $shipment['DELIVERY'] = $cached['DELIVERY'][$shipment["DELIVERY_ID"]];
         $shipment['DELIVERY']['STORE'] = \Bitrix\Sale\Delivery\ExtraServices\Manager::getStoresList($shipment["DELIVERY_ID"]);
         $formed['SHIPMENT'][] = $shipment;
     }
     $formed['DELIVERY'] = $formed['SHIPMENT'][0]['DELIVERY'];
     return $formed;
 }
Example #3
0
 /**
  * @param $arFields
  * @param array $arOptions
  * @return bool|int
  * @throws Exception
  * @deprecated
  */
 static function Add($arFields, $arOptions = array())
 {
     $fields = array_intersect_key($arFields, Bitrix\Sale\Delivery\Services\Table::getMap());
     if (array_key_exists("LOGOTIP", $arFields) && is_array($arFields["LOGOTIP"])) {
         $arFields["LOGOTIP"]["MODULE_ID"] = "sale";
         CFile::SaveForDB($arFields, "LOGOTIP", "sale/delivery/logotip");
         $fields["LOGOTIP"] = $arFields["LOGOTIP"];
     }
     $fields["CODE"] = isset($arFields["CODE"]) ? $arFields["CODE"] : strval(mktime());
     $fields["PARENT_ID"] = 0;
     $fields["CLASS_NAME"] = '\\Bitrix\\Sale\\Delivery\\Services\\Configurable';
     $fields["CONFIG"] = array("MAIN" => array("PRICE" => $arFields["PRICE"], "PERIOD" => array("FROM" => $arFields["PERIOD_FROM"], "TO" => $arFields["PERIOD_TO"], "TYPE" => $arFields["PERIOD_TYPE"])));
     $res = \Bitrix\Sale\Delivery\Services\Table::add($fields);
     if (!$res->isSuccess()) {
         return false;
     }
     $newId = $res->getId();
     $res = \Bitrix\Sale\Delivery\Restrictions\Table::add(array("DELIVERY_ID" => $newId, "CLASS_NAME" => '\\Bitrix\\Sale\\Delivery\\Restrictions\\BySite', "PARAMS" => array("SITE_ID" => array($arFields["LID"]))));
     if (intval($arFields["WEIGHT_FROM"]) > 0 || intval($arFields["WEIGHT_TO"]) > 0) {
         $res = \Bitrix\Sale\Delivery\Restrictions\Table::add(array("DELIVERY_ID" => $newId, "CLASS_NAME" => '\\Bitrix\\Sale\\Delivery\\Restrictions\\ByWeight', "PARAMS" => array("MIN_WEIGHT" => $arFields["WEIGHT_FROM"], "MAX_WEIGHT" => $arFields["WEIGHT_TO"])));
     }
     if (intval($arFields["ORDER_PRICE_FROM"]) > 0 || intval($arFields["ORDER_PRICE_TO"]) > 0) {
         $res = \Bitrix\Sale\Delivery\Restrictions\Table::add(array("DELIVERY_ID" => $newId, "CLASS_NAME" => '\\Bitrix\\Sale\\Delivery\\Restrictions\\ByPrice', "PARAMS" => array("MIN_PRICE" => $arFields["ORDER_PRICE_FROM"], "MAX_PRICE" => $arFields["ORDER_PRICE_TO"], "CURRENCY" => $arFields["ORDER_CURRENCY"])));
     }
     if (isset($arFields["LOCATIONS"]) && is_array($arFields["LOCATIONS"])) {
         Helper::resetLocationsForEntity($newId, $arFields['LOCATIONS'], self::CONN_ENTITY_NAME, !!$arOptions['EXPECT_LOCATION_CODES']);
     }
     if (isset($arFields["PAY_SYSTEM"])) {
         CSaleDelivery::UpdateDeliveryPay($newId, $arFields["PAY_SYSTEM"]);
     }
     if (isset($arFields["STORE"])) {
         $stores = unserialize($arFields["STORE"]);
         if ($stores) {
             \Bitrix\Sale\Delivery\ExtraServices\Manager::saveStores($newId, $stores);
         }
     }
     return $newId;
 }
echo $ID;
?>
">
<input type="hidden" name="DELIVERY_ID" value="<?php 
echo $DELIVERY_ID;
?>
">
<?php 
echo bitrix_sessid_post();
?>

<?php 
$tabControl->Begin();
/* General settings */
$tabControl->BeginNextTab();
$manager = new ExtraServices\Manager(array($fields));
?>
<tr class="adm-detail-required-field">
	<td width="40%"><?php 
echo Loc::getMessage("SALE_ESDE_FIELD_TYPE");
?>
:</td>
	<td width="60%">
		<?php 
if (!isset($fields["RIGHTS"]["ADMIN"]) || $fields["RIGHTS"]["ADMIN"] == "Y" || $ID <= 0) {
    ?>
			<select name="CLASS_NAME" onchange="top.BX.showWait(); this.form.submit(); /* elements.apply.click();*/">
				<option value=""></option>
				<?php 
    foreach (ExtraServices\Manager::getClassesList() as $class) {
        ?>
Example #5
0
        $result = new Result();
        $storesFields = self::getStoresFields($deliveryId);
        if (!empty($storesFields)) {
            $res = Table::update($storesFields["ID"], array("PARAMS" => array("STORES" => $storesList)));
        } else {
            $res = Table::add(array("CODE" => self::STORE_PICKUP_CODE, "NAME" => Loc::getMessage("DELIVERY_SERVICE_MANAGER_ES_NAME"), "DESCRIPTION" => Loc::getMessage("DELIVERY_SERVICE_MANAGER_ES_DESCRIPTION"), "CLASS_NAME" => self::STORE_PICKUP_CLASS, "DELIVERY_ID" => $deliveryId, "RIGHTS" => "YYY", "PARAMS" => array("STORES" => $storesList)));
        }
        if (!$res->isSuccess()) {
            foreach ($res->getErrors() as $error) {
                $result->addError($error);
            }
        }
        return $result;
    }
    protected static function getByDeliveryId($deliveryId)
    {
        static $hitCache = array();
        if (isset($hitCache[$deliveryId])) {
            return $hitCache[$deliveryId];
        }
        $result = array();
        $dbRes = Table::getList(array("order" => array("SORT" => "ASC", "NAME" => "ASC"), "filter" => array("=DELIVERY_ID" => $deliveryId, "=ACTIVE" => "Y", "=CLASS_NAME" => self::getClassesList()), "select" => array("*", "CURRENCY" => "DELIVERY_SERVICE.CURRENCY")));
        while ($row = $dbRes->fetch()) {
            $result[$row["ID"]] = $row;
        }
        $hitCache[$deliveryId] = $result;
        return $result;
    }
}
\Bitrix\Sale\Delivery\ExtraServices\Manager::initClassesList();
:</td>
			<td width="60%">
				<?php 
    echo CCurrency::SelectBox("CURRENCY", $fields["CURRENCY"], "", true, "");
    ?>
			</td>
		</tr>
	<?php 
}
?>

	<?php 
if (array_key_exists("STORES", $showFieldsList)) {
    ?>
		<?php 
    $stores = ExtraServices\Manager::getStoresFields($ID);
    ?>
		<?php 
    $storeClassName = ExtraServices\Manager::STORE_PICKUP_CLASS;
    ?>
		<tr>
			<td width="40%"><?php 
    echo Loc::getMessage("SALE_DSE_FORM_STORES_SHOW");
    ?>
:</td>
			<td width="60%">
				<input type="checkbox" name="STORES_SHOW" value="Y" <?php 
    echo !empty($stores) ? " checked" : "";
    ?>
 onchange="BX.Sale.Delivery.toggleStores();">
			</td>
Example #7
0
 protected static function getStoresList($deliveryId)
 {
     $result = array();
     if (!\Bitrix\Main\Loader::includeModule('catalog')) {
         return $result;
     }
     $storesIds = \Bitrix\Sale\Delivery\ExtraServices\Manager::getStoresList($deliveryId);
     if (!empty($storesIds)) {
         $dbList = \CCatalogStore::GetList(array("SORT" => "DESC", "ID" => "DESC"), array("ACTIVE" => "Y", "ISSUING_CENTER" => "Y", "ID" => $storesIds), false, false, array("ID", "SITE_ID", "TITLE", "ADDRESS", "DESCRIPTION", "IMAGE_ID", "PHONE", "SCHEDULE", "LOCATION_ID", "GPS_N", "GPS_S"));
         while ($store = $dbList->Fetch()) {
             $result[$store["ID"]] = $store;
         }
     }
     return $result;
 }
Example #8
0
                     $arDelivery["PERIOD_TEXT"] = $calcResult->getPeriodDescription();
                 }
                 $arResult["DELIVERY_PRICE"] = roundEx($calcResult->getPrice(), SALE_VALUE_PRECISION);
             } elseif (count($calcResult->getErrorMessages()) > 0) {
                 foreach ($calcResult->getErrorMessages() as $message) {
                     $arDelivery["CALCULATE_ERRORS"] .= $message . '<br>';
                 }
             } else {
                 $arDelivery = GetMessage("SOA_DELIVERY_CALCULATE_ERROR");
             }
         }
         if (intval($deliveryObj->logotip) > 0) {
             $arDelivery["LOGOTIP"] = CFile::GetFileArray($deliveryObj->logotip);
         }
         $arDelivery['EXTRA_SERVICES'] = $deliveryObj->getExtraServices()->getItems();
         $arDelivery['STORE'] = \Bitrix\Sale\Delivery\ExtraServices\Manager::getStoresList($deliveryObj->getId());
         $arDelivery['SORT'] = $deliveryObj->sort;
         $arResult["DELIVERY"][$deliveryObj->id] = $arDelivery;
         $bFirst = false;
         if (isset($_POST["BUYER_STORE"]) && !empty($arDelivery['STORE']) && is_array($arDelivery['STORE']) && in_array($_POST["BUYER_STORE"], $arDelivery['STORE'])) {
             $arUserResult['DELIVERY_STORE'] = $arDelivery["ID"];
         }
     }
 }
 uasort($arResult["DELIVERY"], array('CSaleBasketHelper', 'cmpBySort'));
 // resort delivery arrays according to SORT value
 //If none delivery service was selected let's select the first one.
 if (!$bSelected && !empty($arResult["DELIVERY"])) {
     reset($arResult["DELIVERY"]);
     $key = key($arResult["DELIVERY"]);
     $arResult["DELIVERY"][$key]["CHECKED"] = "Y";
$ID = intval($_GET['ID']);
$strError = "";
if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "delete_extra_service" && isset($_REQUEST["ES_ID"])) {
    if (intval($_REQUEST["ES_ID"] > 0)) {
        $res = ExtraServices\Table::delete(intval($_REQUEST["ES_ID"]));
        if (!$res->isSuccess()) {
            $strError .= Loc::getMessage("SALE_ESDE_ERROR_DELETE") . ' ' . implode("<br>\n", $res->getErrorMessages());
        }
    } else {
        $strError .= Loc::getMessage("SALE_ESDE_ERROR_ID");
    }
}
$tableId = 'table_delivery_extra_service';
$oSort = new \CAdminSorting($tableId);
$lAdmin = new \CAdminList($tableId, $oSort);
$res = \Bitrix\Sale\Delivery\ExtraServices\Table::getList(array('filter' => array('DELIVERY_ID' => $ID, '=CLASS_NAME' => ExtraServices\Manager::getClassesList()), 'select' => array('ID', 'CODE', 'NAME', 'DESCRIPTION', 'CLASS_NAME', 'RIGHTS', 'ACTIVE', 'SORT'), 'order' => array('SORT' => 'ASC', 'ID' => 'DESC')));
$data = $res->fetchAll();
$dbRes = new \CDBResult();
$dbRes->InitFromArray($data);
$dbRecords = new \CAdminResult($dbRes, $tableId);
$dbRecords->NavStart();
$lAdmin->NavText($dbRecords->GetNavPrint(Loc::getMessage('SALE_ESDL_LIST')));
$header = array(array('id' => 'ID', 'content' => Loc::getMessage('SALE_ESDL_COL_ID'), "sort" => "", 'default' => true), array('id' => 'CODE', 'content' => Loc::getMessage('SALE_ESDL_COL_CODE'), "sort" => "", 'default' => false), array('id' => 'NAME', 'content' => Loc::getMessage('SALE_ESDL_COL_NAME'), "sort" => "", 'default' => true), array('id' => 'SORT', 'content' => Loc::getMessage('SALE_ESDL_COL_SORT'), "sort" => "", 'default' => true), array('id' => 'RIGHTS', 'content' => Loc::getMessage('SALE_ESDL_COL_RIGHTS'), "sort" => "", 'default' => false), array('id' => 'ACTIVE', 'content' => Loc::getMessage('SALE_ESDL_COL_ACTIVE'), "sort" => "", 'default' => true), array('id' => 'CLASS_NAME', 'content' => Loc::getMessage('SALE_ESDL_COL_CLASS_NAME'), "sort" => "", 'default' => true), array('id' => 'DESCRIPTION', 'content' => Loc::getMessage('SALE_ESDL_COL_DESCRIPTION'), "sort" => "", 'default' => true));
$lAdmin->AddHeaders($header);
while ($record = $dbRecords->Fetch()) {
    $link = 'sale_delivery_eservice_edit.php?ID=' . $record['ID'] . '&lang=' . LANGUAGE_ID . '&' . $tabControl->ActiveTabParam() . '&back_url=' . urlencode($APPLICATION->GetCurPageParam());
    $row =& $lAdmin->AddRow($record['ID'], $record, $link, '');
    $row->AddField('ID', '<a href="' . $link . '">' . $record['ID'] . '</a>');
    $row->AddField('CODE', $record['CODE']);
    $row->AddField('NAME', $record['NAME']);
    $row->AddField('SORT', $record['SORT']);