add create themplate options in admin panel
This commit is contained in:
parent
555bd6350e
commit
720da1a294
2 changed files with 52 additions and 21 deletions
|
@ -5,6 +5,7 @@ namespace Intaro\RetailCrm\Controller;
|
|||
use Bitrix\Main\Engine\ActionFilter\Authentication;
|
||||
use Bitrix\Main\Engine\Controller;
|
||||
use Intaro\RetailCrm\Component\ConfigProvider;
|
||||
use Intaro\RetailCrm\Component\Constants;
|
||||
|
||||
class AdminPanel extends Controller
|
||||
{
|
||||
|
@ -35,11 +36,29 @@ class AdminPanel extends Controller
|
|||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function CreateSaleTemplateAction($templates): array
|
||||
public function createSaleTemplateAction($templates): array
|
||||
{
|
||||
foreach ($templates as $template){
|
||||
$pathFrom = $_SERVER['DOCUMENT_ROOT']
|
||||
. '/bitrix/modules/'
|
||||
. Constants::MODULE_ID
|
||||
. '/install/export/local/components/intaro/sale.order.ajax/templates/.default';
|
||||
|
||||
$pathTo = $_SERVER['DOCUMENT_ROOT']
|
||||
. '/local/templates/'
|
||||
. $template
|
||||
. '/components/bitrix/sale.order.ajax/intaro.retailCRM';
|
||||
|
||||
$status = CopyDirFiles(
|
||||
$pathFrom,
|
||||
$pathTo,
|
||||
true,
|
||||
true,
|
||||
false
|
||||
);
|
||||
}
|
||||
return [
|
||||
'status' => 'ok',
|
||||
'templates' => $templates,
|
||||
'status' => $status,
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -769,6 +769,17 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
|
|||
CJSCore::Init(array("jquery"));
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
|
||||
function createSaleTemplates() {
|
||||
BX.ajax.runAction( 'intaro:retailcrm.api.adminpanel.createSaleTemplate',
|
||||
{
|
||||
data: {
|
||||
sessid: BX.bitrix_sessid(),
|
||||
templates: ['.default']
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function editSaleTemplates(method){
|
||||
|
||||
|
@ -1348,8 +1359,26 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
|
|||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<?php echo GetMessage('LP_TEMP_CHOICE_MSG'); ?>
|
||||
<div style="text-align: center;"><h4>Создание дополнительного шаблона</h4></div>
|
||||
<?php echo GetMessage('LP_CUSTOM_TEMP_CREATE_MSG'); ?>
|
||||
<div style="text-align: center;">
|
||||
<input type="button" onclick="createSaleTemplates()" class="adm-btn-save" value="<?php echo GetMessage('LP_CREATE_TEMPLATE'); ?>"/>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<div style="text-align: center;"><h4>Замена стандартного шаблона</h4></div>
|
||||
<?php echo GetMessage('LP_DEF_TEMP_CREATE_MSG'); ?>
|
||||
<hr>
|
||||
<?php echo GetMessage('LP_TEMP_CHOICE_MSG'); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="50%" >
|
||||
<input type="button" onclick="editSaleTemplates('replaceDefSaleTemplate')" class="adm-btn-save" value="<?php echo GetMessage('LP_REPLACE_TEMPLATE'); ?>" />
|
||||
</td>
|
||||
<td width="50%" >
|
||||
<div id="lp-templates">
|
||||
<?php
|
||||
$templates = TemplateRepository::getAllIds();
|
||||
|
@ -1359,23 +1388,6 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
|
|||
<?php } ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="20%" >
|
||||
<button type="button" onclick="editSaleTemplates('createSaleTemplate')"><?php echo GetMessage('LP_CREATE_TEMPLATE'); ?></button>
|
||||
</td>
|
||||
<td width="80%">
|
||||
<?php echo GetMessage('LP_CUSTOM_TEMP_CREATE_MSG'); ?>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="20%" >
|
||||
<button type="button" onclick="editSaleTemplates('replaceDefSaleTemplate')"><?php echo GetMessage('LP_REPLACE_TEMPLATE'); ?></button>
|
||||
</td>
|
||||
<td width="80%" >
|
||||
<?php echo GetMessage('LP_DEF_TEMP_CREATE_MSG'); ?>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</table>
|
||||
|
|
Loading…
Add table
Reference in a new issue