<?
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/header.php");
$APPLICATION->SetTitle("Обновление прайс-листа");
?>
<? if(!CModule::IncludeModule("iblock")) return;?>
<style type="text/css">
.title{ padding: 5px 5px 5px 5px ; font-weight: bold; font-size: 16px; color: #195C95; }
.title_munu{ padding: 5px 5px 5px 5px ; color: #023977; }
.title_munu_link{padding: 3px 5px 3px 20px ;font-size: larger;color: #023977;}
.table_title{border-color: #000066;border-style: dotted;border-width: 1px;}
.table_content{margin-top: 3px;border-color: #000066;border-top-style: dotted;border-top-width: 1px;}
.name{padding: 5px 5px 5px 5px ;font-weight: bold;color: #195C95; }
a:hover.doun{color: #FFFF33;}
a.doun{ padding: 3px 5px 3px 3px;border-width: 1px;background-color: #000066;color: #FFFFCC;margin-left: 20px;}
.title_munu_link_1{padding: 3px 5px 3px 20px ;font-size: larger;color: #FFFFFF;}
</style>
<? $ar = array();
$f = fopen("price.csv","r") or die("Ошибка");
if ($f)
{
$arSelect = Array("ID");
$del = CIBlockElement::GetList(Array(), Array("IBLOCK_ID"=>"84"), false, false, $arSelect);
while($ob_del = $del->GetNextElement())
{
$delete = $ob_del->GetFields();
$DB->StartTransaction();
if(!CIBlockElement::Delete($delete['ID'])){
$strWarning .= 'Error!';
$DB->Rollback();
}
else
$DB->Commit();
}
}
for($i=0; $data = fgetcsv($f, 1000, ";"); $i++)
{
$ar[] = $data;
}
fclose($f);
; ?>
<table border="1" class="table_title" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#195C95" >
<td class="title_munu_link_1"><b>Название</b></td>
<td class="title_munu_link_1"><b>Кол - во рабочих мест</b></td>
<td class="title_munu_link_1"><b>Скидка</b></td>
<td class="title_munu_link_1"><b>Цена за 1 РМ</b></td>
<td class="title_munu_link_1"><b>Цена</b></td>
</tr>
<? foreach ($ar as $value): ?>
<?
$el = new CIBlockElement;
$PROP = array();
$PROP[327] = $value['1']; // кол -во рабочих мест
$PROP[328] = $value['2']; // скидка
$PROP[329] = $value['3']; // стоимость за 1 рабочее место
$PROP[331] = $value['4']; // цена
$arLoadProductArray = Array(
"MODIFIED_BY" => $USER->GetID(), // элемент изменен текущим пользователем
"IBLOCK_SECTION" => $value['5'], // элемент лежит в корне раздела
"IBLOCK_ID" => 84,
"PROPERTY_VALUES"=> $PROP,
"NAME" => $value['0'],
"ACTIVE" => "Y", // активен
);
if($PRODUCT_ID = $el->Add($arLoadProductArray)){
"New ID: ".$PRODUCT_ID;
$arSelect = Array("ID", "NAME", "PROPERTY_raboch_mest", "PROPERTY_skidka", "PROPERTY_price_1work", "PROPERTY_price");
$res = CIBlockElement::GetList(Array(), Array("IBLOCK_ID"=>"84", "ID" => $PRODUCT_ID), false, Array("nPageSize"=>100), $arSelect);
while($ob = $res->GetNextElement())
{
$arFields = $ob->GetFields();
?>
<tr>
<td class="title_munu_link" width="200"><?=$arFields['NAME'];?></td>
<td class="title_munu_link" align="center" width="100">
<?=$arFields['PROPERTY_RABOCH_MEST_VALUE'];?>
</td>
<td class="title_munu_link" align="center" width="100">
<?=$arFields['PROPERTY_SKIDKA_VALUE'];?>
</td>
<td class="title_munu_link" align="center" width="100">
<?=$arFields['PROPERTY_PRICE_1WORK_VALUE'];?>
</td>
<td class="title_munu_link" align="center" width="100">
<?=$arFields['PROPERTY_PRICE_VALUE'];?>
</td>
</tr>
<? } ?>
<?
}else{
"Error: ".$el->LAST_ERROR;
}
?>
<? endforeach; ?>
</table>
<?require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php");?>
|