1
0
mirror of synced 2024-11-21 21:06:09 +03:00

+copy export files via installation; v0.3b

This commit is contained in:
Grisha Pomadchin 2013-07-10 18:21:13 +04:00
parent 4166e448f5
commit 0634cc3afe
19 changed files with 82 additions and 10 deletions

48
intaro.crm/classes/general/ICrmOrderActions.php Normal file → Executable file
View File

@ -1,5 +1,4 @@
<?php
//namespace IntaroCrm;
class ICrmOrderActions
{
@ -245,12 +244,44 @@ class ICrmOrderActions
return true; //all ok!
}
public static function orderHistory() {
if (!CModule::IncludeModule('iblock')) {
//handle err
self::eventLog('iblock', 'module not found');
return false;
}
if (!CModule::IncludeModule("sale")) {
//handle err
self::eventLog('sale', 'module not found');
return false;
}
if (!CModule::IncludeModule("catalog")) {
//handle err
self::eventLog('catalog', 'module not found');
return false;
}
$api_host = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_HOST_OPTION, 0);
$api_key = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_KEY_OPTION, 0);
//saved cat params
$optionsOrderTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_TYPES_ARR, 0));
$optionsDelivTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_DELIVERY_TYPES_ARR, 0));
$optionsPayTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT_TYPES, 0));
$optionsPayStatuses = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT_STATUSES, 0)); // --statuses
$optionsPayment = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT, 0));
$api = new IntaroCrm\RestApi($api_host, $api_key);
var_dump($api->orderHistory());
}
/**
*
* w event in bitrix log
* @param type $auditType
* @param type $itemId
* @param type $description
* w+ event in bitrix log
*/
private static function eventLog($itemId, $description) {
CEventLog::Add(array(
@ -264,6 +295,12 @@ class ICrmOrderActions
self::sendEmail($itemId, $description);
}
/**
*
* send email to admin
*/
private static function sendEmail($itemId, $description) {
$title = 'Error: Intaro CRM.';
$text = 'Error: ' . $itemId . ' - ' . $description;
@ -285,7 +322,6 @@ class ICrmOrderActions
return 'ICrmOrderActions::uploadOrdersAgent();';
else return;
}
}

0
intaro.crm/classes/general/RestApi.php Normal file → Executable file
View File

0
intaro.crm/include.php Normal file → Executable file
View File

38
intaro.crm/install/index.php Normal file → Executable file
View File

@ -307,6 +307,8 @@ class intaro_crm extends CModule
30
);
$this->CopyFiles();
$APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'),
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step3.php'
@ -318,7 +320,6 @@ class intaro_crm extends CModule
global $APPLICATION;
CAgent::RemoveAgent("ICrmOrderActions::uploadOrdersAgent();", $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);
@ -328,10 +329,45 @@ class intaro_crm extends CModule
COption::RemoveOption($this->MODULE_ID, $this->CRM_PAYMENT);
COption::RemoveOption($this->MODULE_ID, $this->CRM_ORDER_LAST_ID);
$this->DeleteFiles();
UnRegisterModule($this->MODULE_ID);
$APPLICATION->IncludeAdminFile(
GetMessage('MODULE_UNINSTALL_TITLE'),
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/unstep1.php'
);
}
/**
*
* Recursive copy files from folder
* @param type $src
* @param type $dst
*/
function rCopy($src, $dst) {
if (is_dir($src)) {
mkdir($dst);
$files = scandir($src);
foreach ($files as $file)
if ($file != "." && $file != "..")
$this->rCopy("$src/$file", "$dst/$file");
}
else if (file_exists($src))
copy($src, $dst);
}
function CopyFiles() {
$this->rCopy(
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/export/', $_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/'
);
}
function DeleteFiles() {
unlink($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/crm_run.php');
unlink($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/crm_setup.php');
}
}
?>

0
intaro.crm/install/step1.php Normal file → Executable file
View File

0
intaro.crm/install/step2.php Normal file → Executable file
View File

0
intaro.crm/install/step3.php Normal file → Executable file
View File

0
intaro.crm/install/unstep1.php Normal file → Executable file
View File

0
intaro.crm/install/unstep2.php Normal file → Executable file
View File

4
intaro.crm/install/version.php Normal file → Executable file
View File

@ -1,6 +1,6 @@
<?
$arModuleVersion = array(
'VERSION' => '0.3a',
'VERSION_DATE' => '2013-07-10 16:49:00',
'VERSION' => '0.3b',
'VERSION_DATE' => '2013-07-10 18:19:00',
);
?>

0
intaro.crm/lang/ru/install/index.php Normal file → Executable file
View File

0
intaro.crm/lang/ru/install/step1.php Normal file → Executable file
View File

0
intaro.crm/lang/ru/install/step2.php Normal file → Executable file
View File

0
intaro.crm/lang/ru/install/step3.php Normal file → Executable file
View File

0
intaro.crm/lang/ru/install/unstep1.php Normal file → Executable file
View File

0
intaro.crm/lang/ru/options.php Normal file → Executable file
View File

0
intaro.crm/options.php Normal file → Executable file
View File