1
0
mirror of synced 2024-11-28 08:16:07 +03:00

Installation & options. v0.2a

This commit is contained in:
Grisha Pomadchin 2013-07-05 21:15:23 +04:00
parent 8e7fdf7bca
commit ef13d4a277
8 changed files with 153 additions and 41 deletions

View File

@ -1,9 +1,4 @@
<?php <?php
/*
*
* Add autoload classes here
*
*/
CModule::AddAutoloadClasses( CModule::AddAutoloadClasses(
'intaro.crm', // module name 'intaro.crm', // module name
array ( array (
@ -11,5 +6,4 @@ CModule::AddAutoloadClasses(
'ICrmApi' => 'classes/general/ICrmApi.php' 'ICrmApi' => 'classes/general/ICrmApi.php'
) )
); );
?> ?>

View File

@ -24,6 +24,7 @@ class intaro_crm extends CModule
var $CRM_API_HOST_OPTION = 'api_host'; var $CRM_API_HOST_OPTION = 'api_host';
var $CRM_API_KEY_OPTION = 'api_key'; 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_DELIVERY_TYPES_ARR = 'deliv_types_arr';
var $CRM_PAYMENT_TYPES = 'pay_types_arr'; var $CRM_PAYMENT_TYPES = 'pay_types_arr';
var $CRM_PAYMENT_STATUSES = 'pay_statuses_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_VERSION_DATE = $arModuleVersion["VERSION_DATE"];
$this->MODULE_NAME = GetMessage('MODULE_NAME'); $this->MODULE_NAME = GetMessage('MODULE_NAME');
$this->MODULE_DESCRIPTION = GetMessage('MODULE_DESCRIPTION'); $this->MODULE_DESCRIPTION = GetMessage('MODULE_DESCRIPTION');
$this->PARTNER_NAME = GetMessage('MODULE_PARTNER_NAME'); $this->PARTNER_NAME = GetMessage('MODULE_PARTNER_NAME');
$this->PARTNER_URI = GetMessage('MODULE_PARTNER_URI'); $this->PARTNER_URI = GetMessage('MODULE_PARTNER_URI');
} }
/** /**
@ -54,7 +55,7 @@ class intaro_crm extends CModule
{ {
global $APPLICATION, $step, $arResult; global $APPLICATION, $step, $arResult;
include($this->INSTALL_PATH . '/../classes/general/IntaroCrmRestApi.php'); include($this->INSTALL_PATH . '/../classes/general/ICrmApi.php');
$step = intval($_REQUEST['step']); $step = intval($_REQUEST['step']);
@ -80,7 +81,7 @@ class intaro_crm extends CModule
return; 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(); $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); COption::SetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, $api_key);
//prepare crm lists //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['deliveryTypesList'] = $this->INTARO_CRM_API->deliveryTypesList();
$arResult['paymentTypesList'] = $this->INTARO_CRM_API->paymentTypesList(); $arResult['paymentTypesList'] = $this->INTARO_CRM_API->paymentTypesList();
$arResult['paymentStatusesList'] = $this->INTARO_CRM_API->paymentStatusesList(); $arResult['paymentStatusesList'] = $this->INTARO_CRM_API->paymentStatusesList();
//bitrix orderTypesList //bitrix orderTypesList -- personTypes
/* $dbOrderTypesList = CSalePersonType::GetList(
* ...some code here... 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 //bitrix deliveryTypesList
$dbDeliveryTypesList = CSaleDelivery::GetList( $dbDeliveryTypesList = CSaleDelivery::GetList(
@ -175,6 +191,28 @@ class intaro_crm extends CModule
//handler //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 //bitrix deliveryTypesList
$dbDeliveryTypesList = CSaleDelivery::GetList( $dbDeliveryTypesList = CSaleDelivery::GetList(
array( array(
@ -229,40 +267,40 @@ class intaro_crm extends CModule
); );
//form payment statuses ids arr //form payment statuses ids arr
$paymentStatusesArr = array(); $paymentStatusesArr = array();
if ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch()) { if ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch()) {
do { do {
$paymentStatusesArr[$arPaymentStatusesList['ID']] = $_POST['payment-status-' . $arPaymentStatusesList['ID']]; $paymentStatusesArr[$arPaymentStatusesList['ID']] = $_POST['payment-status-' . $arPaymentStatusesList['ID']];
} while ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch()); } 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_DELIVERY_TYPES_ARR, serialize($deliveryTypesArr));
COption::SetOptionString($this->MODULE_ID, $this->CRM_PAYMENT_TYPES, serialize($paymentTypesArr)); COption::SetOptionString($this->MODULE_ID, $this->CRM_PAYMENT_TYPES, serialize($paymentTypesArr));
COption::SetOptionString($this->MODULE_ID, $this->CRM_PAYMENT_STATUSES, serialize($paymentStatusesArr)); COption::SetOptionString($this->MODULE_ID, $this->CRM_PAYMENT_STATUSES, serialize($paymentStatusesArr));
RegisterModule($this->MODULE_ID); RegisterModule($this->MODULE_ID);
$APPLICATION->IncludeAdminFile( $APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'), GetMessage('MODULE_INSTALL_TITLE'),
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step3.php' $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step3.php'
); );
}
}
} }
function DoUninstall() { 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_HOST_OPTION);
COption::RemoveOption($this->MODULE_ID, $this->CRM_API_KEY_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_DELIVERY_TYPES_ARR);
COption::RemoveOption($this->MODULE_ID, $this->CRM_PAYMENT_TYPES); COption::RemoveOption($this->MODULE_ID, $this->CRM_PAYMENT_TYPES);
COption::RemoveOption($this->MODULE_ID, $this->CRM_PAYMENT_STATUSES); COption::RemoveOption($this->MODULE_ID, $this->CRM_PAYMENT_STATUSES);
$APPLICATION->IncludeAdminFile( $APPLICATION->IncludeAdminFile(
GetMessage('MODULE_UNINSTALL_TITLE'), GetMessage('MODULE_UNINSTALL_TITLE'),
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/unstep1.php' $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/unstep1.php'
); );
} }
} }

View File

@ -73,6 +73,26 @@
</td> </td>
</tr> </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="" 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> </tbody>
</table> </table>
<br /> <br />

View File

@ -6,5 +6,5 @@ echo CAdminMessage::ShowNote(GetMessage("MOD_INST_OK")); ?>
<input type="hidden" name="lang" value="<?php echo LANG; ?>"> <input type="hidden" name="lang" value="<?php echo LANG; ?>">
<input type="hidden" name="id" value="intaro.crm"> <input type="hidden" name="id" value="intaro.crm">
<input type="hidden" name="install" value="Y"> <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> <form>

View File

@ -6,5 +6,5 @@
<input type="hidden" name="uninstall" value="Y"> <input type="hidden" name="uninstall" value="Y">
<input type="hidden" name="step" value="2"> <input type="hidden" name="step" value="2">
<?php echo CAdminMessage::ShowMessage(GetMessage("MOD_UNINST_WARN")); ?> <?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> </form>

View File

@ -1,6 +1,6 @@
<? <?
$arModuleVersion = array( $arModuleVersion = array(
'VERSION' => '0.1b', 'VERSION' => '0.2a',
'VERSION_DATE' => '2013-08-04 18:12:00', 'VERSION_DATE' => '2013-07-05 21:08:00',
); );
?> ?>

View File

@ -4,4 +4,5 @@ $MESS ['MOD_NEXT_STEP'] = 'Следующий шаг';
$MESS ['DELIVERY_TYPES_LIST'] = 'Способы доставки'; $MESS ['DELIVERY_TYPES_LIST'] = 'Способы доставки';
$MESS ['PAYMENT_TYPES_LIST'] = 'Способы оплаты'; $MESS ['PAYMENT_TYPES_LIST'] = 'Способы оплаты';
$MESS ['PAYMENT_STATUS_LIST'] = 'Статусы оплаты'; $MESS ['PAYMENT_STATUS_LIST'] = 'Статусы оплаты';
$MESS ['ORDER_TYPES_LIST'] = 'Типы плательщиков';
?> ?>

View File

@ -20,7 +20,7 @@ if (isset($_POST['Update']) && $_POST['Update']=='Y') {
$api_key = htmlspecialchars(trim($_POST['api_key'])); $api_key = htmlspecialchars(trim($_POST['api_key']));
if($api_host && $api_key) { if($api_host && $api_key) {
$api = new IntaroCrmRestApi($api_host, $api_key); $api = new ICrmApi($api_host, $api_key);
$api->paymentStatusesList(); $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 //bitrix deliveryTypesList
$dbDeliveryTypesList = CSaleDelivery::GetList( $dbDeliveryTypesList = CSaleDelivery::GetList(
array( array(
@ -49,7 +71,7 @@ if (isset($_POST['Update']) && $_POST['Update']=='Y') {
); );
//form delivery types ids arr //form delivery types ids arr
$deliveryTypesArr = array(); $deliveryTypesArr = array();
if ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch()) { if ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch()) {
do { do {
$deliveryTypesArr[$arDeliveryTypesList['ID']] = $_POST['delivery-type-' . $arDeliveryTypesList['ID']]; $deliveryTypesArr[$arDeliveryTypesList['ID']] = $_POST['delivery-type-' . $arDeliveryTypesList['ID']];
@ -95,6 +117,7 @@ if (isset($_POST['Update']) && $_POST['Update']=='Y') {
} while ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch()); } while ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch());
} }
COption::SetOptionString($mid, 'order_types_arr', serialize($orderTypesArr));
COption::SetOptionString($mid, 'deliv_types_arr', serialize($deliveryTypesArr)); COption::SetOptionString($mid, 'deliv_types_arr', serialize($deliveryTypesArr));
COption::SetOptionString($mid, 'pay_types_arr', serialize($paymentTypesArr)); COption::SetOptionString($mid, 'pay_types_arr', serialize($paymentTypesArr));
COption::SetOptionString($mid, 'pay_statuses_arr', serialize($paymentStatusesArr)); 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_host = COption::GetOptionString($mid, 'api_host', 0);
$api_key = COption::GetOptionString($mid, 'api_key', 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 //prepare crm lists
//$orderTypes = $api->orderTypesList(); -- no such method $arResult['orderTypesList'] = $api->orderTypesList();
$arResult['deliveryTypesList'] = $api->deliveryTypesList(); $arResult['deliveryTypesList'] = $api->deliveryTypesList();
$arResult['paymentTypesList'] = $api->paymentTypesList(); $arResult['paymentTypesList'] = $api->paymentTypesList();
$arResult['paymentStatusesList'] = $api->paymentStatusesList(); $arResult['paymentStatusesList'] = $api->paymentStatusesList();
//bitrix orderTypesList //bitrix orderTypesList -- personTypes
/* $dbOrderTypesList = CSalePersonType::GetList(
* ...some code here... 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 //bitrix deliveryTypesList
$dbDeliveryTypesList = CSaleDelivery::GetList( $dbDeliveryTypesList = CSaleDelivery::GetList(
@ -174,6 +212,7 @@ if (isset($_POST['Update']) && $_POST['Update']=='Y') {
} }
//saved cat params //saved cat params
$optionsOrderTypes = unserialize(COption::GetOptionString($mid, 'order_types_arr', 0));
$optionsDelivTypes = unserialize(COption::GetOptionString($mid, 'deliv_types_arr', 0)); $optionsDelivTypes = unserialize(COption::GetOptionString($mid, 'deliv_types_arr', 0));
$optionsPayTypes = unserialize(COption::GetOptionString($mid, 'pay_types_arr', 0)); $optionsPayTypes = unserialize(COption::GetOptionString($mid, 'pay_types_arr', 0));
$optionsPayStatuses = unserialize(COption::GetOptionString($mid, 'pay_statuses_arr', 0)); $optionsPayStatuses = unserialize(COption::GetOptionString($mid, 'pay_statuses_arr', 0));
@ -273,7 +312,27 @@ if (isset($_POST['Update']) && $_POST['Update']=='Y') {
</select> </select>
</td> </td>
</tr> </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->BeginNextTab(); ?>
<?php $tabControl->Buttons(); ?> <?php $tabControl->Buttons(); ?>
<input type="hidden" name="Update" value="Y" /> <input type="hidden" name="Update" value="Y" />