+38(073) 413-59-71  info@binliz.org.ua

Стоит ли магазин на битрикс своих денег часть 3 (цены продолжение 1)

 22.10.2016
php, 1C-Bitrix

И так немного поколдовав над админкой у меня получилосьсделать полный редактор типа цен исходный код страницы списка:

<?php
define("ADMIN_MODULE_NAME", "binliz.sale");
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_before.php");
IncludeModuleLangFile(__FILE__);
IncludeModuleLangFile(__DIR__.'/menu.php');
if (!$USER->IsAdmin())
{
	$APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
}
if (!CModule::IncludeModule(ADMIN_MODULE_NAME))
{
	$APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
}
use Binliz\Main;
use Bitrix\Main\Application;

$APPLICATION->SetTitle(GetMessage("HEADER_TITLE"));

CAdminMessage::ShowMessage($strError);

$context = Application::getInstance()->getContext();
$request = $context->getRequest();
$flag = $request->isPost();
$sTableID = "tbl_binliz_sale_cataolg_price_type";
$oSort = new CAdminSorting($sTableID, "NAME", "asc");
$lAdmin = new CAdminList($sTableID, $oSort);

// Действия
// сохранение отредактированных элементов
if($lAdmin->EditAction())
{
    // пройдем по списку переданных элементов
    foreach($FIELDS as $ID=>$arFields)
    {
        if(!$lAdmin->IsUpdated($ID))
            continue;
        
        // сохраним изменения каждого элемента
        $DB->StartTransaction();
        $ID = IntVal($ID);
        $cData = new Binliz\Sale\SaleCatalogPriceTypeTable;
        if(($rsData = $cData->GetByID($ID)) && ($arData = $rsData->Fetch()))
        {
            foreach($arFields as $key=>$value)
                $arData[$key]=$value;
            if(!$cData->Update($ID, $arData))
            {
                $lAdmin->AddGroupError(GetMessage("rub_save_error")." ".$cData->LAST_ERROR, $ID);
                $DB->Rollback();
            }
        }
        else
        {
            $lAdmin->AddGroupError(GetMessage("rub_save_error")." ".GetMessage("rub_no_rubric"), $ID);
            $DB->Rollback();
        }
        $DB->Commit();
    }
}

// обработка одиночных и групповых действий
if(($arID = $lAdmin->GroupAction()))
{
    // если выбрано "Для всех элементов"
    if($_REQUEST['action_target']=='selected')
    {
        $cData = new Binliz\Sale\SaleCatalogPriceTypeTable;
        $rsData = $cData->GetList(array( 'order'=>array($by=>$order), 'filter'=>array(),'select'=>array('ID')));
        while($arRes = $rsData->Fetch())
            $arID[] = $arRes['ID'];
    }

    // пройдем по списку элементов
    foreach($arID as $ID)
    {
        if(strlen($ID)<=0)
            continue;
       	$ID = IntVal($ID);
        
        // для каждого элемента совершим требуемое действие
        switch($_REQUEST['action'])
        {
        // удаление
        case "delete":
            @set_time_limit(0);
            $DB->StartTransaction();
            if(!Binliz\Sale\SaleCatalogPriceTypeTable::Delete($ID))
            {
                $DB->Rollback();
                $lAdmin->AddGroupError(GetMessage("rub_del_err"), $ID);
            }else{
						$resulgroup = \Binliz\Sale\SaleCatalogPriceTypeGroupTable::GetList(array('filter'=>array('PRICE_TYPE'=>$ID),'select'=>array('ID')));
						$needDelete = array();
						while($rcGrp = $resulgroup->Fetch()){
							$needDelete[] = $rcGrp['ID'];
						}
						foreach($needDelete as $ElGroupID){
							\Binliz\Sale\SaleCatalogPriceTypeGroupTable::Delete($ElGroupID);
						}
				}
            $DB->Commit();
            break;
        
        // активация/деактивация
        case "activate":
        case "deactivate":
            $cData = new Binliz\Sale\SaleCatalogPriceTypeTable;
            if(($rsData = $cData->GetByID($ID)) && ($arFields = $rsData->Fetch()))
            {
                $arFields["ACTIVE"]=($_REQUEST['action']=="activate"?1:0);
                if(!$cData->Update($ID, $arFields))
                    $lAdmin->AddGroupError(GetMessage("rub_save_error").$cData->LAST_ERROR, $ID);
            }
            else
                $lAdmin->AddGroupError(GetMessage("rub_save_error")." ".GetMessage("rub_no_rubric"), $ID);
            break;
        }

    }
}
//var_dump($_REQUEST);

// --- Действия



$arHeaders = array(
	array("id"=>"ID", "content"=>"ID", "sort"=>"ID", "default"=>true),
	array("id"=>"SORT", "content"=>GetMessage('HEAD_SORT'), "sort"=>"SORT","default"=>true),
	array("id"=>"NAME", "content"=>GetMessage('HEAD_NAME'), "sort"=>"NAME", "default"=>true),
	array("id"=>"ACTIVE", "content"=>GetMessage('HEAD_ACTIVE'), "sort"=>"ACTIVE","default"=>true)
);

$lAdmin->AddHeaders($arHeaders);

// menu
if ($_REQUEST["mode"] !== "list")
{
	$aMenu = array(
		array(
			"TEXT"	=> GetMessage('BUTTON_ADD'),
			"TITLE"	=> GetMessage('BUTTON_ADD'),
			"LINK"	=> "binliz_store_price_types_edit.php?lang=".LANGUAGE_ID,
			"ICON"	=> "btn_new",
		)
	);

	$context = new CAdminContextMenu($aMenu);
}

$aContext = array(
		array(
			"TEXT"	=> GetMessage('BUTTON_ADD'),
			"TITLE"	=> GetMessage('BUTTON_ADD'),
			"LINK"	=> "binliz_store_price_types_edit.php?lang=".LANGUAGE_ID,
			"ICON"	=> "btn_new",
		)
);

// и прикрепим его к списку
$lAdmin->AddAdminContextMenu($aContext);


// select data
$rsData = Binliz\Sale\SaleCatalogPriceTypeTable::getList(array(
	"select" => $lAdmin->GetVisibleHeaderColumns(),
	"order" => array($by => strtoupper($order))
));

$rsData = new CAdminResult($rsData, $sTableID);
$rsData->NavStart();

// build list
$lAdmin->NavText($rsData->GetNavPrint(GetMessage("PAGES")));
while($arRes = $rsData->NavNext(true, "f_"))
{
	$row = $lAdmin->AddRow($f_ID, $arRes);
	if($f_ACTIVE)
	   $row->AddViewField("ACTIVE",  "Y");
	else
	   $row->AddViewField("ACTIVE",  "N");

	$can_edit = true;

	$arActions = Array();

	$arActions[] = array(
		"ICON"=>"edit",
		"TEXT"=>GetMessage($can_edit ? "MAIN_ADMIN_MENU_EDIT" : "MAIN_ADMIN_MENU_VIEW"),
		"ACTION"=>$lAdmin->ActionRedirect("binliz_store_price_types_edit.php?ID=".$f_ID)
	);

	$arActions[] = array(
		"ICON"=>"delete",
		"TEXT" => GetMessage("MAIN_ADMIN_MENU_DELETE"),
      "ACTION"=>"if(confirm('".GetMessage('rub_del_conf')."')) ".$lAdmin->ActionDoGroup($f_ID, "delete")
	);

	$row->AddActions($arActions);
}

$lAdmin->AddFooter(
  array(
    array("title"=>GetMessage("MAIN_ADMIN_LIST_SELECTED"), "value"=>$rsData->SelectedRowsCount()), // кол-во элементов
    array("counter"=>true, "title"=>GetMessage("MAIN_ADMIN_LIST_CHECKED"), "value"=>"0"), // счетчик выбранных элементов
  )
);

// групповые действия
$lAdmin->AddGroupActionTable(Array(
  "delete"=>GetMessage("MAIN_ADMIN_LIST_DELETE"), // удалить выбранные элементы
  "activate"=>GetMessage("MAIN_ADMIN_LIST_ACTIVATE"), // активировать выбранные элементы
  "deactivate"=>GetMessage("MAIN_ADMIN_LIST_DEACTIVATE"), // деактивировать выбранные элементы
  ));


// view


if ($_REQUEST["mode"] == "list" || $_REQUEST["mode"] == "frame")
{
	require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_js.php");
}
else
{
	require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_after.php");

	$context->Show();
}

$lAdmin->CheckListMode();

$lAdmin->DisplayList();


if ($_REQUEST["mode"] == "list" || $_REQUEST["mode"] == "frame")
	require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_admin_js.php");
else 
	require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_admin.php");


И детальная страница

<?php
define("ADMIN_MODULE_NAME", "binliz.sale");
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_before.php");
IncludeModuleLangFile(__FILE__);
IncludeModuleLangFile(__DIR__.'/menu.php');
if (!$USER->IsAdmin())
{
	$APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
}
if (!CModule::IncludeModule(ADMIN_MODULE_NAME))
{
	$APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
}
use Binliz\Main;
use Bitrix\Main\Application;

$APPLICATION->SetTitle(GetMessage("HEADER_TITLE"));

$context = Application::getInstance()->getContext();
$request = $context->getRequest();
$flag = $request->isPost();

if($flag && check_bitrix_sessid()){
	$ID = $request->getPost('ID');
	$save = $request->getPost('save');
	$apply = $request->getPost('apply');

	$updateArr=$request->getPostList()->toArray();
	$keys = array();
	$rsData = \Binliz\Sale\SaleCatalogPriceTypeTable::GetMap();
	foreach($rsData as $key=>$item){
		if($item instanceof Bitrix\Main\Entity\ReferenceField);else $keys[] = $key;

	}
	$updateArrNonFree =  $updateArr;
	$updateArr = array_intersect_key($updateArr,array_flip($keys));

	if($request->getPost('Update') == "Y"){
	}	
	if($updateArr){
			if($ID>0){ 
				$rsData = \Binliz\Sale\SaleCatalogPriceTypeTable::update($ID,$updateArr);
			}
			else{
				$rsData = \Binliz\Sale\SaleCatalogPriceTypeTable::add($updateArr);
			}
			if($rsData->isSuccess()){
					$elementID = $rsData->getId();
					if($updateArrNonFree['USER_GROUP_BUY']){
// Список групп которые уже есть
						$resulgroup = \Binliz\Sale\SaleCatalogPriceTypeGroupTable::GetList(array('filter'=>array('PRICE_TYPE'=>$elementID),'select'=>array('GROUP_ID','ID')));
						$isIn = array();
						$needAdd = array();
						$needDelete = array();
						while($rcGrp = $resulgroup->Fetch()){
								$isIn[] = $rcGrp['GROUP_ID'];
								if(in_array($rcGrp['GROUP_ID'],$updateArrNonFree['USER_GROUP_BUY'])) ;
								else $needDelete[] = $rcGrp['ID'];
						}
						$needAdd = array_intersect($updateArrNonFree['USER_GROUP_BUY'],$isIn);
						foreach($needDelete as $ElGroupID){
							\Binliz\Sale\SaleCatalogPriceTypeGroupTable::Delete($ElGroupID);
						}
							
						foreach($updateArrNonFree['USER_GROUP_BUY']  as $group){
							if(!in_array($group,$needAdd))
							\Binliz\Sale\SaleCatalogPriceTypeGroupTable::add(array('PRICE_TYPE'=>$elementID, 'GROUP_ID'=>$group));
						}
					}
			}

		if($save){
			LocalRedirect('/bitrix/admin/binliz_store_price_types.php');
		}
	}
	
}
if($request->getQuery('action') == "delete" && check_bitrix_sessid()){
	$ID = $request->getQuery('ID');
	$rsData = \Binliz\Sale\SaleCatalogPriceTypeTable::Delete($ID);
	LocalRedirect('/bitrix/admin/binliz_store_price_types.php');
}


if($ID){

	$res = Binliz\Main\ElementReviewTable::GetById($ID);
	$arCatalogGroup = $res->Fetch();
}


$arUserGroupList = [];
$rsUserGroups = CGroup::GetList(($by="sort"), ($order="asc"));
while ($arGroup = $rsUserGroups->Fetch())
{
	$arUserGroupList[] = array(
		'ID' => intval($arGroup['ID']),
		'NAME' => $arGroup['NAME'],
	);
}
$arGroupUserList = [];

$arCatalogGroup = [
'ACTIVE'=>1,
'SORT'=>100,
];
if($ID){

	$res = Binliz\Sale\SaleCatalogPriceTypeGroupTable::GetList(array('filter'=>array('PRICE_TYPE'=>$ID),'select'=>array('GROUP_ID','ID')));
	while($arOneGList = $res->Fetch()){
		$arGroupUserList[] = $arOneGList['GROUP_ID'];
	}

	$res = Binliz\Sale\SaleCatalogPriceTypeTable::GetById($ID);
	$arCatalogGroup = $res->Fetch();
}


// view

if ($_REQUEST["mode"] == "list")
{
	require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_js.php");
}
else
{
	require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_after.php");

}

CAdminMessage::ShowMessage($strError);

?>

<form method="POST" action="<?echo $sDocPath ?>?lang=<?echo LANG ?>" ENCTYPE="multipart/form-data" name="dataload" id="dataload">
<input type="hidden" name="Update" value="Y">
<input type="hidden" name="lang" value="<?echo LANGUAGE_ID ?>">
<input type="hidden" name="ID" value="<?echo $ID ?>">
<?=bitrix_sessid_post()?>

<?
$aTabs = array(
	array(
		"DIV" => "edit1",
		"TAB" => "Настройка типа цены" ,
		"ICON" => "iblock",
		"TITLE" => "",
	) 
);
$tabControl = new CAdminTabControl("tabControl", $aTabs, false, true);
$tabControl->Begin();
$tabControl->BeginNextTab();
?>
<?	if ($ID>0):?>
		<tr>
			<td width="40%">ID:</td>
			<td width="60%"><?echo $ID ?></td>
		</tr>
	<?endif;?>
	<tr>
		<td width="40%"><?echo GetMessage("FIELD_ACTIVE") ?></td>
		<td width="60%">
			<input type="hidden" name="ACTIVE" id="IS_ACTIVE_N" value="0">
			<input type="checkbox" name="ACTIVE" id="IS_ACTIVE_Y" value="1" <?if($arCatalogGroup['ACTIVE'] ==1) echo "checked";?>>
</td>
	</tr>

	<tr class="adm-detail-required-field">
		<td width="40%"><?echo GetMessage("FIELD_NAME") ?></td>
		<td width="60%"><input type="text" name="NAME" value="<? echo htmlspecialcharsbx($arCatalogGroup['NAME']); ?>"></td>
	</tr>
	<tr>
		<td width="40%"><?echo GetMessage("FIELD_SORT") ?></td>
		<td width="60%"><input type="text" name="SORT" value="<? echo intval($arCatalogGroup['SORT']); ?>"></td>
	</tr>
	<tr class="adm-detail-required-field">
		<td valign="top" width="40%">
			<?echo GetMessage('FIELD_GROUP');?>
		</td>
		<td width="60%">
			<select name="USER_GROUP_BUY[]" multiple size="8">
			<?
			foreach ($arUserGroupList as &$arOneGroup)
			{
				?><option value="<? echo $arOneGroup["ID"]; ?>"<?if (in_array($arOneGroup["ID"], $arGroupUserList)) echo " selected"?>><? echo "[".$arOneGroup["ID"]."] ".htmlspecialcharsex($arOneGroup["NAME"]); ?></option><?
			}
			if (isset($arOneGroup))
				unset($arOneGroup);
			?>
			</select>
		</td>
	</tr>


<?
$tabControl->EndTab();
$tabControl->Buttons(array("disabled"=>false,"back_url"=>'binliz_store_price_types.php?lang='.LANGUAGE_ID));
?>
<?$tabControl->End();?>


</form>
<?
if ($_REQUEST["mode"] == "list")
	require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_admin_js.php");
else 
	require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_admin.php");


Внешний вид страниц стал следующий


 

 
AJuidePeli

Compression est comment calleux votre sang pousse contre les parois de vos arteres lorsque votre coeur essence pompe le sang. Arteres sont les tubes qui transportent prendre offre sang loin de votre coeur. Chaque temps votre manque de sensibilite bat, il pompe le sang par de vos arteres a la vacances de votre corps. https://www.cialispascherfr24.com/cialis-original-20mg/

  • 1