function change_type() { global $APPLICATION, $PROFILE; $profile = new CExportproProfile(); $types = $profile->GetTypes(); $siteEncoding = array('utf-8' => 'utf8', 'UTF8' => 'utf8', 'UTF-8' => 'utf8', 'WINDOWS-1251' => 'cp1251', 'windows-1251' => 'cp1251', 'CP1251' => 'cp1251'); if (!isset($_REQUEST["ID"])) { $obProfile = new CExportproProfileDB(); $dbProcessProfiles = $obProfile->GetProcessList(array($by => $order), array()); $arActualProfileNames = array(); while ($arProcessProfile = $dbProcessProfiles->Fetch()) { $arActualProfileNames[] = $arProcessProfile["NAME"]; } if (!in_array($PROFILE["TYPE"], $arActualProfileNames)) { $profileCode = $PROFILE["TYPE"]; } else { $bCorrentProfileName = false; $iProfileNameIndex = 1; while (!$bCorrentProfileName) { if (!in_array($PROFILE["TYPE"] . $iProfileNameIndex, $arActualProfileNames)) { $profileCode = $PROFILE["TYPE"] . $iProfileNameIndex; $bCorrentProfileName = true; } $iProfileNameIndex++; } } ob_start(); ?> <input type="text" size="30" name="PROFILE[NAME]" value="<?php echo $profileCode; ?> "/> <?php $dataProfileName = ob_get_clean(); ob_start(); ?> <input type="text" size="30" name="PROFILE[CODE]" value="<?php echo $profileCode; ?> "/> <?php $dataProfileCode = ob_get_clean(); ob_start(); ?> <input type="text" size="30" name="PROFILE[SETUP][URL_DATA_FILE]" value="/acrit.exportpro/<?php echo $profileCode; ?> .<?php if ($PROFILE["TYPE"] == "advantshop") { ?> csv<?php } else { ?> xml<?php } ?> "/> <?php $exportFilePath = ob_get_clean(); ob_start(); ?> <td colspan="2"></td> <?php $advantShopCheckCompessArea = ob_get_clean(); ob_start(); ?> <td colspan="2"> <input type="hidden" name="PROFILE[SETUP][FILE_TYPE]" value="csv" /> </td> <?php $advantShopFilePathArea = ob_get_clean(); ob_start(); ?> <input type="text" name="PROFILE[SETUP][EXPORT_STEP]" id="export_step_value" value="50000" disabled="disabled"> <?php $advantShopExportStepBlock = ob_get_clean(); } ob_start(); ?> <textarea name="PROFILE[FORMAT]" rows="5" cols="150"><?php echo $types[$PROFILE['TYPE']]['FORMAT']; ?> </textarea> <?php $data1 = ob_get_clean(); ob_start(); ?> <textarea name="PROFILE[OFFER_TEMPLATE]" rows="5" cols="150"><?php echo htmlspecialcharsbx($types[$PROFILE['TYPE']]['ITEMS_FORMAT']); ?> </textarea> <?php $data2 = ob_get_clean(); ob_start(); ?> <textarea name="PROFILE[CATEGORY_TEMPLATE]" rows="5" cols="150"><?php echo htmlspecialcharsbx($types[$PROFILE['TYPE']]['SECTIONS']); ?> </textarea> <?php $data3 = ob_get_clean(); ob_start(); ?> <textarea name="PROFILE[CURRENCY_TEMPLATE]" rows="5" cols="150"><?php echo htmlspecialcharsbx($types[$PROFILE['TYPE']]['CURRENCIES']); ?> </textarea> <?php $data4 = ob_get_clean(); ob_start(); $iblockList = array(); $dbIblock = CIBlock::GetList(); while ($arIBlock = $dbIblock->Fetch()) { $iblockList[] = $arIBlock['ID']; } $options = $profile->createFieldset2($PROFILE['IBLOCK_ID'], true); $fieldType = array('none' => GetMessage('ACRIT_EXPORTPRO_NE_VYBRANO'), 'field' => GetMessage('ACRIT_EXPORTPRO_FIELDSET_FIELD'), 'const' => GetMessage('ACRIT_EXPORTPRO_FIELDSET_CONST')); ?> <tbody> <?php $idCnt = 0; ?> <?php foreach ($types[$PROFILE['TYPE']]['FIELDS'] as $id => $field) { ?> <?php $useCondition = $field['USE_CONDITION'] == 'Y' ? 'checked="checked"' : ''; $hideCondition = $useCondition ? '' : 'hide'; $hideConstBlock = $field['TYPE'] == 'const' ? '' : 'hide'; $hideFieldBlock = $field['TYPE'] != 'field' && !$hideConstBlock || $field['TYPE'] == 'none' || !$field['TYPE'] ? 'hide' : ''; $required = $field['REQUIRED'] == 'Y' ? 'checked="checked"' : ''; $deleteOnEmpty = $field['DELETE_ONEMPTY'] == 'N' ? '' : 'checked="checked"'; $htmlEncode = $field['HTML_ENCODE'] == 'N' ? '' : 'checked="checked"'; $htmlToTxt = $field['HTML_TO_TXT'] == 'N' ? '' : 'checked="checked"'; $skipUntermElement = $field['SKIP_UNTERM_ELEMENT'] == 'N' ? '' : 'checked="checked"'; $urlEncode = $field['URL_ENCODE'] == 'Y' ? 'checked="checked"' : ''; $convertCase = $field['CONVERT_CASE'] == 'Y' ? 'checked="checked"' : ''; ?> <tr class="fieldset-item" data-id="<?php echo $idCnt++; ?> "> <td > <label for="PROFILE[XMLDATA][<?php echo $id; ?> ]"><?php echo $field['NAME']; ?> </label> <input type="hidden" name="PROFILE[XMLDATA][<?php echo $id; ?> ][NAME]" value="<?php echo $field['NAME']; ?> " /> </td> <td colspan="2"> <input type="text" name="PROFILE[XMLDATA][<?php echo $id; ?> ][CODE]" value="<?php echo $field['CODE']; ?> " /> <select name="PROFILE[XMLDATA][<?php echo $id; ?> ][TYPE]" onchange="ShowConvalueBlock(this)" data-id="<?php echo $id; ?> "> <?php foreach ($fieldType as $typeId => $typeName) { ?> <?php $selected = $typeId == $field['TYPE'] ? 'selected="selected"' : ''; ?> <option value="<?php echo $typeId; ?> " <?php echo $selected; ?> ><?php echo $typeName; ?> </option> <?php } ?> </select> <select id="field-block" name="PROFILE[XMLDATA][<?php echo $id; ?> ][VALUE]" class="<?php echo $hideFieldBlock; ?> "> <option value="">--<?php echo GetMessage("ACRIT_EXPORTPRO_NE_VYBRANO"); ?> --</option> <?php if ($field['TYPE'] == 'field') { $opt = $profile->selectFieldset2($options, $field['VALUE']); echo implode("\n", $opt); unset($opt); } ?> </select> <div id="const-block" class="<?php echo $hideConstBlock; ?> " > <?php $hideContvalueFalse = !$useCondition ? 'hide' : ''; ?> <?php $showPlaceholder = !$hideContvalueFalse ? 'placeholder' : 'data-placeholder'; ?> <textarea name="PROFILE[XMLDATA][<?php echo $id; ?> ][CONTVALUE_TRUE]" <?php echo $showPlaceholder; ?> ="<?php echo GetMessage('ACRIT_EXPORTPRO_FIELDSET_CONDITION_TRUE'); ?> "><?php echo $field['CONTVALUE_TRUE']; ?> </textarea> <textarea name="PROFILE[XMLDATA][<?php echo $id; ?> ][CONTVALUE_FALSE]" placeholder="<?php echo GetMessage('ACRIT_EXPORTPRO_FIELDSET_CONDITION_FALSE'); ?> " class="<?php echo $hideContvalueFalse; ?> "><?php echo $field['CONTVALUE_FALSE']; ?> </textarea> </div> <span class="fieldset-item-delete">×</span> <div style="margin: 10px 0px 10px 15px;"> <span id="hint_EXPORTPRO_FIELDSET_REQUIRED"></span><script type="text/javascript">BX.hint_replace( BX( 'hint_EXPORTPRO_FIELDSET_REQUIRED' ), '<?php echo GetMessage("ACRIT_EXPORTPRO_FIELDSET_REQUIRED_HELP"); ?> ' );</script> <input type="checkbox" name="PROFILE[XMLDATA][<?php echo $id; ?> ][REQUIRED]" value="Y" <?php echo $required; ?> /> <label for="PROFILE[XMLDATA][<?php echo $id; ?> ][REQUIRED]"><?php echo GetMessage('ACRIT_EXPORTPRO_FIELDSET_REQUIRED'); ?> </label> <div style="height: 5px;"> </div> <span id="hint_EXPORTPRO_FIELDSET_CONDITION"></span><script type="text/javascript">BX.hint_replace( BX( 'hint_EXPORTPRO_FIELDSET_CONDITION' ), '<?php echo GetMessage("ACRIT_EXPORTPRO_FIELDSET_CONDITION_HELP"); ?> ' );</script> <input type="checkbox" name="PROFILE[XMLDATA][<?php echo $id; ?> ][USE_CONDITION]" <?php echo $useCondition; ?> value="Y" data-id="<?php echo $id; ?> " onclick="ShowConditionBlock(this, <?php echo $idCnt; ?> )"/> <label for="PROFILE[XMLDATA][<?php echo $id; ?> ][USE_CONDITION]"><?php echo GetMessage('ACRIT_EXPORTPRO_FIELDSET_CONDITION'); ?> </label> <div style="height: 5px;"> </div> <span id="hint_EXPORTPRO_FIELDSET_DELETE_ONEMPTY"></span><script type="text/javascript">BX.hint_replace( BX( 'hint_EXPORTPRO_FIELDSET_DELETE_ONEMPTY' ), '<?php echo GetMessage("ACRIT_EXPORTPRO_FIELDSET_DELETE_ONEMPTY_HELP"); ?> ' );</script> <input type="checkbox" name="PROFILE[XMLDATA][<?php echo $id; ?> ][DELETE_ONEMPTY]" <?php echo $deleteOnEmpty; ?> value="Y"> <label for="PROFILE[XMLDATA][<?php echo $id; ?> ][DELETE_ONEMPTY]"><?php echo GetMessage('ACRIT_EXPORTPRO_FIELDSET_DELETE_ONEMPTY'); ?> </label> <div style="height: 5px;"> </div> <span id="hint_EXPORTPRO_FIELDSET_URL_ENCODE"></span><script type="text/javascript">BX.hint_replace( BX( 'hint_EXPORTPRO_FIELDSET_URL_ENCODE' ), '<?php echo GetMessage("ACRIT_EXPORTPRO_FIELDSET_URL_ENCODE_HELP"); ?> ' );</script> <input type="checkbox" name="PROFILE[XMLDATA][<?php echo $id; ?> ][URL_ENCODE]" <?php echo $urlEncode; ?> value="Y"> <label for="PROFILE[XMLDATA][<?php echo $id; ?> ][URL_ENCODE]"><?php echo GetMessage('ACRIT_EXPORTPRO_FIELDSET_URL_ENCODE'); ?> </label> <div style="height: 5px;"> </div> <span id="hint_EXPORTPRO_FIELDSET_CONVERT_CASE"></span><script type="text/javascript">BX.hint_replace( BX( 'hint_EXPORTPRO_FIELDSET_CONVERT_CASE' ), '<?php echo GetMessage("ACRIT_EXPORTPRO_FIELDSET_CONVERT_CASE_HELP"); ?> ' );</script> <input type="checkbox" name="PROFILE[XMLDATA][<?php echo $id; ?> ][CONVERT_CASE]" <?php echo $convertCase; ?> value="Y"> <label for="PROFILE[XMLDATA][<?php echo $id; ?> ][CONVERT_CASE]"><?php echo GetMessage('ACRIT_EXPORTPRO_FIELDSET_CONVERT_CASE'); ?> </label> <div style="height: 5px;"> </div> <span id="hint_EXPORTPRO_FIELDSET_HTML_ENCODE"></span><script type="text/javascript">BX.hint_replace( BX( 'hint_EXPORTPRO_FIELDSET_HTML_ENCODE' ), '<?php echo GetMessage("ACRIT_EXPORTPRO_FIELDSET_HTML_ENCODE_HELP"); ?> ' );</script> <input type="checkbox" name="PROFILE[XMLDATA][<?php echo $id; ?> ][HTML_ENCODE]" <?php echo $htmlEncode; ?> value="Y"> <label for="PROFILE[XMLDATA][<?php echo $id; ?> ][HTML_ENCODE]"><?php echo GetMessage('ACRIT_EXPORTPRO_FIELDSET_HTML_ENCODE'); ?> </label> <div style="height: 5px;"> </div> <span id="hint_EXPORTPRO_FIELDSET_HTML_TO_TXT"></span><script type="text/javascript">BX.hint_replace( BX( 'hint_EXPORTPRO_FIELDSET_HTML_TO_TXT' ), '<?php echo GetMessage("ACRIT_EXPORTPRO_FIELDSET_HTML_TO_TXT_HELP"); ?> ' );</script> <input type="checkbox" name="PROFILE[XMLDATA][<?php echo $id; ?> ][HTML_TO_TXT]" <?php echo $htmlToTxt; ?> value="Y"> <label for="PROFILE[XMLDATA][<?php echo $id; ?> ][HTML_TO_TXT]"><?php echo GetMessage('ACRIT_EXPORTPRO_FIELDSET_HTML_TO_TXT'); ?> </label> <div style="height: 5px;"> </div> <span id="hint_EXPORTPRO_FIELDSET_SKIP_UNTERM_ELEMENT"></span><script type="text/javascript">BX.hint_replace( BX( 'hint_EXPORTPRO_FIELDSET_SKIP_UNTERM_ELEMENT' ), '<?php echo GetMessage("ACRIT_EXPORTPRO_FIELDSET_SKIP_UNTERM_ELEMENT_HELP"); ?> ' );</script> <input type="checkbox" name="PROFILE[XMLDATA][<?php echo $id; ?> ][SKIP_UNTERM_ELEMENT]" <?php echo $skipUntermElement; ?> value="Y"> <label for="PROFILE[XMLDATA][<?php echo $id; ?> ][SKIP_UNTERM_ELEMENT]"><?php echo GetMessage('ACRIT_EXPORTPRO_FIELDSET_SKIP_UNTERM_ELEMENT'); ?> </label> </div> <div id="PROFILE_XMLDATA_<?php echo $id; ?> _CONDITION" class="condition-block <?php echo $hideCondition; ?> "> <?php if ($field['USE_CONDITION'] == 'Y') { $obCond = new CAcritExportproCatalogCond(); CAcritExportproProps::$arIBlockFilter = $profile->PrepareIBlock($PROFILE['IBLOCK_ID'], $PROFILE['USE_SKU']); $boolCond = $obCond->Init(0, 0, array('FORM_NAME' => 'exportpro_form', 'CONT_ID' => 'PROFILE_XMLDATA_' . $id . '_CONDITION', 'JS_NAME' => 'JSCatCond_field_' . $idCnt, 'PREFIX' => 'PROFILE[XMLDATA][' . $id . '][CONDITION]')); if (!$boolCond) { if ($ex = $APPLICATION->GetException()) { echo $ex->GetString() . "<br>"; } } $obCond->Show($field['CONDITION']); } ?> </div> </td> </tr> <tr> <td colspan="2"> <hr style="opacity: 0.2;"> </td> </tr> <?php } ?> </tbody> <?php $data5 = ob_get_clean(); ob_start(); ?> <a href="<?php echo $types[$PROFILE["TYPE"]]["PORTAL_REQUIREMENTS"]; ?> " target="_blank"><?php echo $types[$PROFILE["TYPE"]]["PORTAL_REQUIREMENTS"]; ?> </a> <?php $dataPortalRequirements = ob_get_clean(); ob_start(); $encoding = $siteEncoding[SITE_CHARSET] == 'utf8' ? 'utf-8' : $siteEncoding[SITE_CHARSET]; echo '<pre>', htmlspecialchars($types[$PROFILE['TYPE']]['EXAMPLE'], ENT_COMPAT | ENT_HTML401, $encoding), '</pre>'; $data6 = ob_get_clean(); ob_start(); echo $types[$PROFILE['TYPE']]['SCHEME_DESCRIPTION']; $data7 = ob_get_clean(); ob_start(); echo $types[$PROFILE['TYPE']]['SCHEME_OFFER_DESCRIPTION']; $data8 = ob_get_clean(); $APPLICATION->RestartBuffer(); $upFieldList = array(array('id' => '#scheme_format', 'html' => $data1), array('id' => '#scheme_offer', 'html' => $data2), array('id' => '#scheme_category', 'html' => $data3), array('id' => '#scheme_currency', 'html' => $data4), array('id' => '#fieldset-container', 'html' => $data5), array('id' => '#step3 #portal_requirements', 'html' => $dataPortalRequirements), array('id' => '#step3 #description', 'html' => $data6), array('id' => '#scheme_main_add_descr', 'html' => $data7), array('id' => '#scheme_main_add_offer_descr', 'html' => $data8)); if (strlen($profileCode) > 0) { $upFieldList[] = array('id' => '#profile_name', 'html' => $dataProfileName); $upFieldList[] = array('id' => '#profile_code', 'html' => $dataProfileCode); $upFieldList[] = array("id" => "#export_file_path", "html" => $exportFilePath); } if ($profileCode == "advantshop") { $upFieldList[] = array("id" => "#tr_type_file", "html" => $advantShopFilePathArea); $upFieldList[] = array("id" => "#export_step_block", "html" => $advantShopExportStepBlock); $upFieldList[] = array("id" => "#check_compress_block", "html" => $advantShopCheckCompessArea); } echo Bitrix\Main\Web\Json::encode(array('result' => 'ok', 'blocks' => $upFieldList)); die; }
if (!CModule::IncludeModule('iblock')) { return false; } IncludeModuleLangFile(__FILE__); $sTableID = "tbl_acritprofile"; function CheckFilter() { global $FilterArr, $lAdmin; foreach ($FilterArr as $f) { global ${$f}; } return true; } $oSort = new CAdminSorting($sTableID, "ID", "desc"); $lAdmin = new CAdminList($sTableID, $oSort); $cData = new CExportproProfileDB(); $FilterArr = array("find", "find_id", "find_name", "find_active", "find_type", "find_type_run", "find_timestamp", "find_start_last_time"); $lAdmin->InitFilter($FilterArr); if (CheckFilter()) { $arFilter = array("ID" => $find != "" && $find_type == "id" ? $find : $find_id, "NAME" => $find_name, "ACTIVE" => $find_active, "TYPE" => $find_type, "TYPE_RUN" => $find_type_run, "TIMESTAMP" => $find_timestamp_1, "START_LAST_TIME" => $find_start_last_time_1); } if ($lAdmin->EditAction() && $POST_RIGHT == "W") { foreach ($FIELDS as $ID => $arFields) { if (!$lAdmin->IsUpdated($ID)) { continue; } $DB->StartTransaction(); $ID = IntVal($ID); if (!$ob->Update($ID, $arFields)) { $lAdmin->AddUpdateError(GetMessage("export_save_err") . $ID . ": " . $ob->LAST_ERROR, $ID); $DB->Rollback();
?> "> </form> <br><br> </td> </tr> </table> </div> </div> </div> <?php CAdminFileDialog::ShowScript(array("event" => "BtnClick", "arResultDest" => array("FORM_NAME" => 'exportprofile_form', "FORM_ELEMENT_NAME" => "URL_DATA_FILE_IMPORT"), "arPath" => array("SITE" => SITE_ID, "PATH" => "/upload"), "select" => 'F', "operation" => 'O', "showUploadTab" => true, "showAddToMenuTab" => false, "fileFilter" => 'txt', "allowAllFiles" => true, "SaveConfig" => true)); } else { $profiles = file_get_contents($_SERVER["DOCUMENT_ROOT"] . $_REQUEST['URL_DATA_FILE_IMPORT']); $arProfile = Bitrix\Main\Web\Json::decode($profiles); $cData = new CExportproProfileDB(); foreach ($arProfile as $prof) { $id = $cData->Add($prof); switch ($prof['SETUP']['TYPE_RUN']) { case 'cron': CExportproCron::CronRun($id, $prof['SETUP']); break; case 'comp': CExportproCron::CronRun($id, $prof['SETUP'], true); break; } $message[] = "<li>[{$id}] {$prof['NAME']}</li>"; } if (count($message) > 0) { $message = GetMessage('ACRIT_EXPORTPRO_PROFILE_LIST_EXPORTED3') . '<ul>' . implode("\r\n", $message) . '</ul>'; CAdminMessage::ShowMessage(array("MESSAGE" => $message, "TYPE" => 'OK', 'HTML' => true));
<?php IncludeModuleLangFile(__FILE__); $CODING = array("cp1251" => "cp1251", "utf8" => "utf8"); $activeChecekd = $arProfile["ACTIVE"] == "Y" ? 'checked="checked"' : ""; $profileDefaults = $profileUtils->GetDefaults($arProfile["IBLOCK_ID"], true); $obProfile = new CExportproProfileDB(); $dbProcessProfiles = $obProfile->GetProcessList(array($by => $order), array()); $arActualProfileNames = array(); while ($arProcessProfile = $dbProcessProfiles->Fetch()) { $arActualProfileNames[] = $arProcessProfile["NAME"]; } if (!in_array($arProfile["TYPE"], $arActualProfileNames)) { $profileDefaults["PROFILE_CODE"] = $arProfile["TYPE"]; } else { $bCorrentProfileName = false; $iProfileNameIndex = 1; while (!$bCorrentProfileName) { if (!in_array($arProfile["TYPE"] . $iProfileNameIndex, $arActualProfileNames)) { $profileDefaults["PROFILE_CODE"] = $arProfile["TYPE"] . $iProfileNameIndex; $bCorrentProfileName = true; } $iProfileNameIndex++; } } ?> <tr class="heading" align="center"> <td colspan="2"><b><?php echo GetMessage("ACRIT_EXPORTPRO_STEP1_GENERAL"); ?> </b></td>
<?php $moduleId = 'acrit.exportpro'; require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_before.php"; require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/{$moduleId}/include.php"; IncludeModuleLangFile(__FILE__); global $ID, $PROFILE, $save, $apply, $copy; $dbProfile = new CExportproProfileDB(); $profileUtils = new CExportproProfile(); $siteEncoding = array('utf-8' => 'utf8', 'UTF8' => 'utf8', 'UTF-8' => 'utf8', 'WINDOWS-1251' => 'cp1251', 'windows-1251' => 'cp1251', 'CP1251' => 'cp1251'); CModule::IncludeModule('catalog'); function CheckFields() { global $PROFILE, $APPLICATION, $ID; if (intval($ID) > 0) { $export = new CAcritExportproExport($ID); if ($export->isLock()) { $APPLICATION->ThrowException(GetMessage('ACRIT_EXPORTPRO_EXPORT_RUN')); return false; } } $requiredFields = array('NAME', 'CODE', 'SHOPNAME', 'COMPANY', 'DOMAIN_NAME'); foreach ($requiredFields as $field) { if (!$PROFILE[$field]) { $APPLICATION->ThrowException(GetMessage('ACRIT_EXPORTPRO_REQUIRED_FIELD_FAIL') . '"' . GetMessage('ACRIT_EXPORTPRO_STEP1_' . $field) . '"'); return false; } } foreach ($PROFILE['XMLDATA'] as $id => $field) { if ($field['REQUIRED'] == 'Y') { if ($field['TYPE'] == 'field' && !$field['VALUE'] || $field['TYPE'] == 'const' && !$field['CONTVALUE_TRUE'] || $field['TYPE'] == 'none') {