Installation & options. v0.2a
This commit is contained in:
parent
8e7fdf7bca
commit
ef13d4a277
@ -1,9 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
*
|
||||
* Add autoload classes here
|
||||
*
|
||||
*/
|
||||
CModule::AddAutoloadClasses(
|
||||
'intaro.crm', // module name
|
||||
array (
|
||||
@ -11,5 +6,4 @@ CModule::AddAutoloadClasses(
|
||||
'ICrmApi' => 'classes/general/ICrmApi.php'
|
||||
)
|
||||
);
|
||||
|
||||
?>
|
||||
|
@ -24,6 +24,7 @@ class intaro_crm extends CModule
|
||||
|
||||
var $CRM_API_HOST_OPTION = 'api_host';
|
||||
var $CRM_API_KEY_OPTION = 'api_key';
|
||||
var $CRM_ORDER_TYPES_ARR = 'order_types_arr';
|
||||
var $CRM_DELIVERY_TYPES_ARR = 'deliv_types_arr';
|
||||
var $CRM_PAYMENT_TYPES = 'pay_types_arr';
|
||||
var $CRM_PAYMENT_STATUSES = 'pay_statuses_arr';
|
||||
@ -41,8 +42,8 @@ class intaro_crm extends CModule
|
||||
$this->MODULE_VERSION_DATE = $arModuleVersion["VERSION_DATE"];
|
||||
$this->MODULE_NAME = GetMessage('MODULE_NAME');
|
||||
$this->MODULE_DESCRIPTION = GetMessage('MODULE_DESCRIPTION');
|
||||
$this->PARTNER_NAME = GetMessage('MODULE_PARTNER_NAME');
|
||||
$this->PARTNER_URI = GetMessage('MODULE_PARTNER_URI');
|
||||
$this->PARTNER_NAME = GetMessage('MODULE_PARTNER_NAME');
|
||||
$this->PARTNER_URI = GetMessage('MODULE_PARTNER_URI');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -54,7 +55,7 @@ class intaro_crm extends CModule
|
||||
{
|
||||
global $APPLICATION, $step, $arResult;
|
||||
|
||||
include($this->INSTALL_PATH . '/../classes/general/IntaroCrmRestApi.php');
|
||||
include($this->INSTALL_PATH . '/../classes/general/ICrmApi.php');
|
||||
|
||||
$step = intval($_REQUEST['step']);
|
||||
|
||||
@ -80,7 +81,7 @@ class intaro_crm extends CModule
|
||||
return;
|
||||
}
|
||||
|
||||
$this->INTARO_CRM_API = new IntaroCrmRestApi($api_host, $api_key);
|
||||
$this->INTARO_CRM_API = new ICrmApi($api_host, $api_key);
|
||||
|
||||
$this->INTARO_CRM_API->paymentStatusesList();
|
||||
|
||||
@ -100,15 +101,30 @@ class intaro_crm extends CModule
|
||||
COption::SetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, $api_key);
|
||||
|
||||
//prepare crm lists
|
||||
//$orderTypes = $this->INTARO_CRM_API->orderTypesList(); -- no such method
|
||||
$arResult['orderTypesList'] = $this->INTARO_CRM_API->orderTypesList();
|
||||
$arResult['deliveryTypesList'] = $this->INTARO_CRM_API->deliveryTypesList();
|
||||
$arResult['paymentTypesList'] = $this->INTARO_CRM_API->paymentTypesList();
|
||||
$arResult['paymentStatusesList'] = $this->INTARO_CRM_API->paymentStatusesList();
|
||||
|
||||
//bitrix orderTypesList
|
||||
/*
|
||||
* ...some code here...
|
||||
*/
|
||||
//bitrix orderTypesList -- personTypes
|
||||
$dbOrderTypesList = CSalePersonType::GetList(
|
||||
array(
|
||||
"SORT" => "ASC",
|
||||
"NAME" => "ASC"
|
||||
),
|
||||
array(
|
||||
"ACTIVE" => "Y",
|
||||
),
|
||||
false,
|
||||
false,
|
||||
array()
|
||||
);
|
||||
|
||||
if ($arOrderTypesList = $dbOrderTypesList->Fetch()) {
|
||||
do {
|
||||
$arResult['bitrixOrderTypesList'][] = $arOrderTypesList;
|
||||
} while ($arOrderTypesList = $dbOrderTypesList->Fetch());
|
||||
}
|
||||
|
||||
//bitrix deliveryTypesList
|
||||
$dbDeliveryTypesList = CSaleDelivery::GetList(
|
||||
@ -174,6 +190,28 @@ class intaro_crm extends CModule
|
||||
if(!CModule::IncludeModule("sale")) {
|
||||
//handler
|
||||
}
|
||||
|
||||
//bitrix orderTypesList -- personTypes
|
||||
$dbOrderTypesList = CSalePersonType::GetList(
|
||||
array(
|
||||
"SORT" => "ASC",
|
||||
"NAME" => "ASC"
|
||||
),
|
||||
array(
|
||||
"ACTIVE" => "Y",
|
||||
),
|
||||
false,
|
||||
false,
|
||||
array()
|
||||
);
|
||||
|
||||
//form order types ids arr
|
||||
$orderTypesArr = array();
|
||||
if ($arOrderTypesList = $dbOrderTypesList->Fetch()) {
|
||||
do {
|
||||
$orderTypesArr[$arOrderTypesList['ID']] = $_POST['order-type-' . $arOrderTypesList['ID']];
|
||||
} while ($arOrderTypesList = $dbOrderTypesList->Fetch());
|
||||
}
|
||||
|
||||
//bitrix deliveryTypesList
|
||||
$dbDeliveryTypesList = CSaleDelivery::GetList(
|
||||
@ -229,40 +267,40 @@ class intaro_crm extends CModule
|
||||
);
|
||||
|
||||
//form payment statuses ids arr
|
||||
$paymentStatusesArr = array();
|
||||
$paymentStatusesArr = array();
|
||||
if ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch()) {
|
||||
do {
|
||||
$paymentStatusesArr[$arPaymentStatusesList['ID']] = $_POST['payment-status-' . $arPaymentStatusesList['ID']];
|
||||
} while ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch());
|
||||
}
|
||||
|
||||
COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_TYPES_ARR, serialize($orderTypesArr));
|
||||
COption::SetOptionString($this->MODULE_ID, $this->CRM_DELIVERY_TYPES_ARR, serialize($deliveryTypesArr));
|
||||
COption::SetOptionString($this->MODULE_ID, $this->CRM_PAYMENT_TYPES, serialize($paymentTypesArr));
|
||||
COption::SetOptionString($this->MODULE_ID, $this->CRM_PAYMENT_STATUSES, serialize($paymentStatusesArr));
|
||||
RegisterModule($this->MODULE_ID);
|
||||
|
||||
$APPLICATION->IncludeAdminFile(
|
||||
$APPLICATION->IncludeAdminFile(
|
||||
GetMessage('MODULE_INSTALL_TITLE'),
|
||||
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step3.php'
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function DoUninstall() {
|
||||
global $APPLICATION;
|
||||
global $APPLICATION;
|
||||
|
||||
UnRegisterModule($this->MODULE_ID);
|
||||
UnRegisterModule($this->MODULE_ID);
|
||||
|
||||
COption::RemoveOption($this->MODULE_ID, $this->CRM_API_HOST_OPTION);
|
||||
COption::RemoveOption($this->MODULE_ID, $this->CRM_API_KEY_OPTION);
|
||||
COption::RemoveOption($this->MODULE_ID, $this->CRM_DELIVERY_TYPES_ARR);
|
||||
COption::RemoveOption($this->MODULE_ID, $this->CRM_API_HOST_OPTION);
|
||||
COption::RemoveOption($this->MODULE_ID, $this->CRM_API_KEY_OPTION);
|
||||
COption::RemoveOption($this->MODULE_ID, $this->CRM_DELIVERY_TYPES_ARR);
|
||||
COption::RemoveOption($this->MODULE_ID, $this->CRM_PAYMENT_TYPES);
|
||||
COption::RemoveOption($this->MODULE_ID, $this->CRM_PAYMENT_STATUSES);
|
||||
|
||||
$APPLICATION->IncludeAdminFile(
|
||||
GetMessage('MODULE_UNINSTALL_TITLE'),
|
||||
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/unstep1.php'
|
||||
$APPLICATION->IncludeAdminFile(
|
||||
GetMessage('MODULE_UNINSTALL_TITLE'),
|
||||
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/unstep1.php'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -73,6 +73,26 @@
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<tr class="heading">
|
||||
<td colspan="2"><b><?php echo GetMessage('ORDER_TYPES_LIST'); ?></b></td>
|
||||
</tr>
|
||||
<?php foreach($arResult['bitrixOrderTypesList'] as $bitrixOrderType): ?>
|
||||
<tr>
|
||||
<td width="50%" class="adm-detail-content-cell-l" name="<?php echo $bitrixOrderType['ID']; ?>">
|
||||
<?php echo $bitrixOrderType['NAME']; ?>
|
||||
</td>
|
||||
<td width="50%" class="adm-detail-content-cell-r">
|
||||
<select name="order-type-<?php echo $bitrixOrderType['ID']; ?>" class="typeselect">
|
||||
<option value="" selected=""></option>
|
||||
<?php foreach($arResult['orderTypesList'] as $orderType): ?>
|
||||
<option value="<?php echo $orderType['code']; ?>">
|
||||
<?php echo $APPLICATION->ConvertCharset($orderType['name'], 'utf-8', SITE_CHARSET); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<br />
|
||||
|
@ -6,5 +6,5 @@ echo CAdminMessage::ShowNote(GetMessage("MOD_INST_OK")); ?>
|
||||
<input type="hidden" name="lang" value="<?php echo LANG; ?>">
|
||||
<input type="hidden" name="id" value="intaro.crm">
|
||||
<input type="hidden" name="install" value="Y">
|
||||
<input type="submit" name="" value="<?php echo GetMessage("MOD_BACK"); ?>">
|
||||
<input type="submit" name="" value="<?php echo GetMessage("MOD_BACK"); ?>" class="adm-btn-save">
|
||||
<form>
|
||||
|
@ -6,5 +6,5 @@
|
||||
<input type="hidden" name="uninstall" value="Y">
|
||||
<input type="hidden" name="step" value="2">
|
||||
<?php echo CAdminMessage::ShowMessage(GetMessage("MOD_UNINST_WARN")); ?>
|
||||
<input type="submit" name="inst" value="<?php echo GetMessage("MOD_UNINST_DEL"); ?>">
|
||||
<input type="submit" name="inst" value="<?php echo GetMessage("MOD_UNINST_DEL"); ?>" class="adm-btn-save">
|
||||
</form>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?
|
||||
$arModuleVersion = array(
|
||||
'VERSION' => '0.1b',
|
||||
'VERSION_DATE' => '2013-08-04 18:12:00',
|
||||
'VERSION' => '0.2a',
|
||||
'VERSION_DATE' => '2013-07-05 21:08:00',
|
||||
);
|
||||
?>
|
||||
|
@ -4,4 +4,5 @@ $MESS ['MOD_NEXT_STEP'] = 'Следующий шаг';
|
||||
$MESS ['DELIVERY_TYPES_LIST'] = 'Способы доставки';
|
||||
$MESS ['PAYMENT_TYPES_LIST'] = 'Способы оплаты';
|
||||
$MESS ['PAYMENT_STATUS_LIST'] = 'Статусы оплаты';
|
||||
$MESS ['ORDER_TYPES_LIST'] = 'Типы плательщиков';
|
||||
?>
|
||||
|
@ -20,7 +20,7 @@ if (isset($_POST['Update']) && $_POST['Update']=='Y') {
|
||||
$api_key = htmlspecialchars(trim($_POST['api_key']));
|
||||
|
||||
if($api_host && $api_key) {
|
||||
$api = new IntaroCrmRestApi($api_host, $api_key);
|
||||
$api = new ICrmApi($api_host, $api_key);
|
||||
|
||||
$api->paymentStatusesList();
|
||||
|
||||
@ -34,6 +34,28 @@ if (isset($_POST['Update']) && $_POST['Update']=='Y') {
|
||||
}
|
||||
}
|
||||
|
||||
//bitrix orderTypesList -- personTypes
|
||||
$dbOrderTypesList = CSalePersonType::GetList(
|
||||
array(
|
||||
"SORT" => "ASC",
|
||||
"NAME" => "ASC"
|
||||
),
|
||||
array(
|
||||
"ACTIVE" => "Y",
|
||||
),
|
||||
false,
|
||||
false,
|
||||
array()
|
||||
);
|
||||
|
||||
//form order types ids arr
|
||||
$orderTypesArr = array();
|
||||
if ($arOrderTypesList = $dbOrderTypesList->Fetch()) {
|
||||
do {
|
||||
$orderTypesArr[$arOrderTypesList['ID']] = $_POST['order-type-' . $arOrderTypesList['ID']];
|
||||
} while ($arOrderTypesList = $dbOrderTypesList->Fetch());
|
||||
}
|
||||
|
||||
//bitrix deliveryTypesList
|
||||
$dbDeliveryTypesList = CSaleDelivery::GetList(
|
||||
array(
|
||||
@ -49,7 +71,7 @@ if (isset($_POST['Update']) && $_POST['Update']=='Y') {
|
||||
);
|
||||
|
||||
//form delivery types ids arr
|
||||
$deliveryTypesArr = array();
|
||||
$deliveryTypesArr = array();
|
||||
if ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch()) {
|
||||
do {
|
||||
$deliveryTypesArr[$arDeliveryTypesList['ID']] = $_POST['delivery-type-' . $arDeliveryTypesList['ID']];
|
||||
@ -94,7 +116,8 @@ if (isset($_POST['Update']) && $_POST['Update']=='Y') {
|
||||
$paymentStatusesArr[$arPaymentStatusesList['ID']] = $_POST['payment-status-' . $arPaymentStatusesList['ID']];
|
||||
} while ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch());
|
||||
}
|
||||
|
||||
|
||||
COption::SetOptionString($mid, 'order_types_arr', serialize($orderTypesArr));
|
||||
COption::SetOptionString($mid, 'deliv_types_arr', serialize($deliveryTypesArr));
|
||||
COption::SetOptionString($mid, 'pay_types_arr', serialize($paymentTypesArr));
|
||||
COption::SetOptionString($mid, 'pay_statuses_arr', serialize($paymentStatusesArr));
|
||||
@ -105,18 +128,33 @@ if (isset($_POST['Update']) && $_POST['Update']=='Y') {
|
||||
$api_host = COption::GetOptionString($mid, 'api_host', 0);
|
||||
$api_key = COption::GetOptionString($mid, 'api_key', 0);
|
||||
|
||||
$api = new IntaroCrmRestApi($api_host, $api_key);
|
||||
$api = new ICrmApi($api_host, $api_key);
|
||||
|
||||
//prepare crm lists
|
||||
//$orderTypes = $api->orderTypesList(); -- no such method
|
||||
$arResult['orderTypesList'] = $api->orderTypesList();
|
||||
$arResult['deliveryTypesList'] = $api->deliveryTypesList();
|
||||
$arResult['paymentTypesList'] = $api->paymentTypesList();
|
||||
$arResult['paymentStatusesList'] = $api->paymentStatusesList();
|
||||
|
||||
//bitrix orderTypesList
|
||||
/*
|
||||
* ...some code here...
|
||||
*/
|
||||
//bitrix orderTypesList -- personTypes
|
||||
$dbOrderTypesList = CSalePersonType::GetList(
|
||||
array(
|
||||
"SORT" => "ASC",
|
||||
"NAME" => "ASC"
|
||||
),
|
||||
array(
|
||||
"ACTIVE" => "Y",
|
||||
),
|
||||
false,
|
||||
false,
|
||||
array()
|
||||
);
|
||||
|
||||
if ($arOrderTypesList = $dbOrderTypesList->Fetch()) {
|
||||
do {
|
||||
$arResult['bitrixOrderTypesList'][] = $arOrderTypesList;
|
||||
} while ($arOrderTypesList = $dbOrderTypesList->Fetch());
|
||||
}
|
||||
|
||||
//bitrix deliveryTypesList
|
||||
$dbDeliveryTypesList = CSaleDelivery::GetList(
|
||||
@ -174,6 +212,7 @@ if (isset($_POST['Update']) && $_POST['Update']=='Y') {
|
||||
}
|
||||
|
||||
//saved cat params
|
||||
$optionsOrderTypes = unserialize(COption::GetOptionString($mid, 'order_types_arr', 0));
|
||||
$optionsDelivTypes = unserialize(COption::GetOptionString($mid, 'deliv_types_arr', 0));
|
||||
$optionsPayTypes = unserialize(COption::GetOptionString($mid, 'pay_types_arr', 0));
|
||||
$optionsPayStatuses = unserialize(COption::GetOptionString($mid, 'pay_statuses_arr', 0));
|
||||
@ -273,7 +312,27 @@ if (isset($_POST['Update']) && $_POST['Update']=='Y') {
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endforeach; ?>
|
||||
<tr class="heading">
|
||||
<td colspan="2"><b><?php echo GetMessage('ORDER_TYPES_LIST'); ?></b></td>
|
||||
</tr>
|
||||
<?php foreach($arResult['bitrixOrderTypesList'] as $bitrixOrderType): ?>
|
||||
<tr>
|
||||
<td width="50%" class="adm-detail-content-cell-l" name="<?php echo $bitrixOrderType['ID']; ?>">
|
||||
<?php echo $bitrixOrderType['NAME']; ?>
|
||||
</td>
|
||||
<td width="50%" class="adm-detail-content-cell-r">
|
||||
<select name="order-type-<?php echo $bitrixOrderType['ID']; ?>" class="typeselect">
|
||||
<option value=""></option>
|
||||
<?php foreach($arResult['orderTypesList'] as $orderType): ?>
|
||||
<option value="<?php echo $orderType['code']; ?>" <?php if ($optionsOrderTypes[$bitrixOrderType['ID']] == $orderType['code']) echo 'selected'; ?>>
|
||||
<?php echo $APPLICATION->ConvertCharset($orderType['name'], 'utf-8', SITE_CHARSET); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php $tabControl->BeginNextTab(); ?>
|
||||
<?php $tabControl->Buttons(); ?>
|
||||
<input type="hidden" name="Update" value="Y" />
|
||||
|
Loading…
Reference in New Issue
Block a user