Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace tomal\connector;
- class Moy
- {
- //class MySklad extends Connector{
- private $idModule;
- private $counterPartyTable;
- private $assortmentTable;
- private $currencyTable;
- private $productTable;
- private $serviceTable;
- private $bundleTable;
- private $productFolderTable;
- private $variantTable;
- private $consignmentTable;
- private $contractTable;
- private $projectTable;
- private $expenseItemTable;
- private $countriesTable;
- private $groupsTable;
- private $discountTable;
- private $uomTable;
- private $employeesTable;
- private $storesTable;
- private $organizationsTable;
- private $accountsTable;
- private $retailStoreTable;
- private $cashiersTable;
- private $taskTable;
- private $retailshiftTable;
- private $enterTable;
- private $customerOrdersTable;
- private $purchaseOrderTable;
- private $invoiceOutTable;
- private $invoiceInTable;
- private $paymentInTable;
- private $paymentOutTable;
- private $cashInTable;
- private $cashOutTable;
- private $demandTable;
- private $supplyTable;
- private $lossTable;
- private $moveTable;
- private $retailDemandTable;
- private $retailSalesReturnTable;
- private $retailDrawerCashInTable;
- private $retailDrawerCashOutTable;
- private $salesReturnTable;
- private $purchaseReturnTable;
- private $factureOutTable;
- private $factureInTable;
- private $inventoryTable;
- private $commissionReportInTable;
- private $commissionReportOutTable;
- private $pricelistTable;
- private $processingPlanTable;
- private $processingOrderTable;
- private $processingTable;
- private $internalOrderTable;
- private $stockAllTable;
- private $stockByStoreTable;
- private $reportDashboardDayTable;
- private $reportDashboardWeekTable;
- private $reportDashboardMonthTable;
- private $auditTable;
- private $salePricesTable;
- private $barcodesTable;
- private $positionsInvoicesArrayTable;
- private $positionsInvoicesTable;
- private $positionsOrdersArrayTable;
- private $positionsOrdersTable;
- private $positionsDemandsArrayTable;
- private $positionsDemandTable;
- private $positionsSuppliesArrayTable;
- private $positionsSupplyTable;
- private $positionsLossArrayTable;
- private $positionsLossTable;
- private $login;
- private $username;
- private $password;
- private $limit;
- private $project;
- public function __construct($module, $login, $project, $username, $password)
- {
- error_reporting(E_ALL & ~E_NOTICE);
- $this->idModule = $module;
- $this->project = $project;
- $this->counterPartyTable = "{$login}_{$project}_moy_sklad_counter_party";
- $this->assortmentTable = "{$login}_{$project}_moy_sklad_assortment";
- $this->currencyTable = "{$login}_{$project}_moy_sklad_currency";
- $this->productTable = "{$login}_{$project}_moy_sklad_product";
- $this->serviceTable = "{$login}_{$project}_moy_sklad_service";
- $this->bundleTable = "{$login}_{$project}_moy_sklad_bundle";
- $this->productFolderTable = "{$login}_{$project}_moy_sklad_productfolder";
- $this->variantTable = "{$login}_{$project}_moy_sklad_variant";
- $this->consignmentTable = "{$login}_{$project}_moy_sklad_consignment";
- $this->contractTable = "{$login}_{$project}_moy_sklad_contract";
- $this->projectTable = "{$login}_{$project}_moy_sklad_project";
- $this->expenseItemTable = "{$login}_{$project}_moy_sklad_expense_item";
- $this->countriesTable = "{$login}_{$project}_moy_sklad_countries";
- $this->groupsTable = "{$login}_{$project}_moy_sklad_groups";
- $this->discountTable = "{$login}_{$project}_moy_sklad_discount";
- $this->uomTable = "{$login}_{$project}_moy_sklad_uom";
- $this->employeesTable = "{$login}_{$project}_moy_sklad_employees";
- $this->storesTable = "{$login}_{$project}_moy_sklad_stores";
- $this->organizationsTable = "{$login}_{$project}_moy_sklad_organizations";
- $this->accountsTable = "{$login}_{$project}_moy_sklad_accounts";
- $this->retailStoreTable = "{$login}_{$project}_moy_sklad_retail_store";
- $this->cashiersTable = "{$login}_{$project}_moy_sklad_cashiers";
- $this->taskTable = "{$login}_{$project}_moy_sklad_task";
- $this->retailshiftTable = "{$login}_{$project}_moy_sklad_retailshift";
- $this->enterTable = "{$login}_{$project}_moy_sklad_enter";
- $this->customerOrdersTable = "{$login}_{$project}_moy_sklad_customer_orders";
- $this->purchaseOrderTable = "{$login}_{$project}_moy_sklad_customer_purchase_order";
- $this->invoiceOutTable = "{$login}_{$project}_moy_sklad_invoice_out";
- $this->invoiceInTable = "{$login}_{$project}_moy_sklad_invoice_in";
- $this->paymentInTable = "{$login}_{$project}_moy_sklad_payment_in";
- $this->paymentOutTable = "{$login}_{$project}_moy_sklad_payment_out";
- $this->cashInTable = "{$login}_{$project}_moy_sklad_cash_in";
- $this->cashOutTable = "{$login}_{$project}_moy_sklad_cash_out";
- $this->demandTable = "{$login}_{$project}_moy_sklad_demand";
- $this->supplyTable = "{$login}_{$project}_moy_entity_supply";
- $this->lossTable = "{$login}_{$project}_moy_sklad_loss";
- $this->moveTable = "{$login}_{$project}_moy_sklad_move";
- $this->retailDemandTable = "{$login}_{$project}_moy_sklad_retail_demand";
- $this->retailSalesReturnTable = "{$login}_{$project}_moy_sklad_retail_sales_return";
- $this->retailDrawerCashInTable = "{$login}_{$project}_moy_sklad_retail_drawer_cash_in";
- $this->retailDrawerCashOutTable = "{$login}_{$project}_moy_sklad_retail_drawer_cash_out";
- $this->salesReturnTable = "{$login}_{$project}_moy_sklad_sales_return";
- $this->purchaseReturnTable = "{$login}_{$project}_moy_sklad_purchase_return";
- $this->factureOutTable = "{$login}_{$project}_moy_sklad_facture_out";
- $this->factureOutTable = "{$login}_{$project}_moy_sklad_facture_in";
- $this->inventoryTable = "{$login}_{$project}_moy_sklad_inventory";
- $this->commissionReportInTable = "{$login}_{$project}_moy_sklad_commission_report_in";
- $this->commissionReportInTable = "{$login}_{$project}_moy_sklad_commission_report_out";
- $this->pricelistTable = "{$login}_{$project}_moy_sklad_pricelist";
- $this->processingPlanTable = "{$login}_{$project}_moy_sklad_processing_plan";
- $this->processingOrderTable = "{$login}_{$project}_moy_sklad_processing_order";
- $this->processingTable = "{$login}_{$project}_moy_sklad_processing";
- $this->internalOrderTable = "{$login}_{$project}_moy_sklad_internal_order";
- $this->stockAllTable = "{$login}_{$project}_moy_sklad_stock_all";
- $this->stockByStoreTable = "{$login}_{$project}_moy_sklad_stock_by_store";
- $this->reportDashboardDayTable = "{$login}_{$project}_moy_sklad_report_dashboard_day";
- $this->reportDashboardWeekTable = "{$login}_{$project}_moy_sklad_report_dashboard_week";
- $this->reportDashboardMonthTable = "{$login}_{$project}_moy_sklad_report_dashboard_month";
- $this->salePricesTable = "{$login}_{$project}_moy_sklad_sale_prices";
- $this->barcodesTable = "{$login}_{$project}_moy_sklad_barcodes";
- $this->auditTable = "{$login}_{$project}_moy_sklad_audit";
- $this->positionsInvoicesArrayTable = "{$login}_{$project}_moy_sklad_positions_invoices_array";
- $this->positionsInvoicesTable = "{$login}_{$project}_moy_sklad_positions_invoice";
- $this->positionsOrdersArrayTable = "{$login}_{$project}_moy_sklad_positions_orders_array";
- $this->positionsOrdersTable = "{$login}_{$project}_moy_sklad_positions_order";
- $this->positionsDemandsArrayTable = "{$login}_{$project}_moy_sklad_positions_demands_array";
- $this->positionsDemandTable = "{$login}_{$project}_moy_sklad_positions_demand";
- $this->positionsSuppliesArrayTable = "{$login}_{$project}_moy_sklad_positions_supplies_array";
- $this->positionsSupplyTable = "{$login}_{$project}_moy_sklad_positions_supply";
- $this->login = $login;
- $this->username = $username;
- $this->password = $password;
- $this->limit = 100;
- if ($this->makeAuth()) {
- $this->dropTable() && $this->createTable() && $this->init();
- }
- return true;
- }
- public function init()
- {
- // $r =
- $this->updateCounterPartyTable();
- $this->updateAssortmentTable();
- $this->updateCurrencyTable();
- $this->updateProductTable();
- // $this->updateServiceTable();
- // $this->updateBundleTable();
- $this->updateProductFolderTable();
- // $this->updateVariantTable();
- // $this->updateConsignmentTable();
- // $this->updateContractTable();
- $this->updateProjectTable();
- $this->updateExpenseItemTable();
- $this->updateCountriesTable();
- $this->updateGroupsTable();
- $this->updateDiscountTable();
- $this->updateUomTable();
- $this->updateEmployeesTable();
- $this->updateStoresTable();
- $this->updateOrganizationsTable();
- $this->updateRetailStoreTable();
- // $this->updateCashiersTable();
- // $this->updateTaskTable();
- // $this->updateRetailshiftTable();
- // $this->updateEnterTable();
- $this->updateCustomerOrdersTable();
- $this->updatePurchaseOrderTable();
- $this->updateInvoiceOutTable();
- $this->updateInvoiceInTable();
- $this->updatePaymentInTable();
- $this->updatePaymentOutTable();
- $this->updateCashInTable();
- $this->updateCashOutTable();
- $this->updateDemandTable();
- $this->updateSupplyTable();
- $this->updateLossTable();
- // $this->updateMoveTable();
- // $this->updateRetaildemandTable();
- // $this->updateRetailsalesreturnTable();
- // $this->updateRetaildrawerCashInTable();
- // $this->updateRetaildrawerCashOutTable();
- // $this->updateSalesReturnTable();
- // $this->updatePurchasereturn();
- // $this->updateFactureout();
- // $this->updateFacturein();
- // $this->updateInventoryTable();
- // $this->updateCommissionreportin();
- // $this->updateCommissionreportout();
- // $this->updatePricelist();
- // $this->updateProcessingplan();
- // $this->updateProcessingOrderTable();
- // $this->updateProcessing();
- // $this->updateInternalorder();
- // $this->updateStockAllTable();
- // $this->updateStockBySort();
- // $this->updateReportDashboardDayTable();
- // $this->updateReportDashboardWeekTable();
- // $this->updateReportDashboardMonthTable();
- // $this->updateAuditTable();
- // var_dump($r);
- }
- private function updateCounterPartyTable()
- {
- $method = "entity/counterparty";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- $dataOwnerDecoded = json_decode($this->curlPost($row->owner->meta->href, $this->username, $this->password));
- $dataStateDecoded = json_decode($this->curlPost($row->state->meta->href, $this->username, $this->password));
- if (!empty($dataOwnerDecoded->id)) $ownerId = $dataOwnerDecoded->id; else $ownerId = null;
- if (!empty($dataStateDecoded->stateType)) $stateType = $dataStateDecoded->stateType; else $stateType = null;
- if (!empty($row->version)) $version = $row->version; else $version = null;
- if (!empty($row->updated)) $updated = $row->updated; else $updated = null;
- if (!empty($row->name)) $name = $row->name; else $name = null;
- if (!empty($row->description)) $description = $row->description; else $description = null;
- if (!empty($row->code)) $code = $row->code; else $code = null;
- if (!empty($row->externalCode)) $externalCode = $row->externalCode; else $externalCode = null;
- if (!empty($row->created)) $created = $row->created; else $created = null;
- if (!empty($row->email)) $email = $row->email; else $email = null;
- if (!empty($row->phone)) $phone = $row->phone; else $phone = null;
- if (!empty($row->fax)) $fax = $row->fax; else $fax = null;
- if (!empty($row->actualAddress)) $actualAddress = $row->actualAddress; else $actualAddress = null;
- if (!empty($row->legalTitle)) $legalTitle = $row->legalTitle; else $legalTitle = null;
- if (!empty($row->legalAddress)) $legalAddress = $row->legalAddress; else $legalAddress = null;
- if (!empty($row->inn)) $inn = $row->inn; else $inn = null;
- if (!empty($row->kpp)) $kpp = $row->kpp; else $kpp = null;
- if (!empty($row->discountCardNumber)) $discountCardNumber = $row->discountCardNumber; else $discountCardNumber = null;
- if (!empty($row->ogrn)) $ogrn = $row->ogrn; else $ogrn = null;
- if (!empty($row->okpo)) $okpo = $row->okpo; else $okpo = null;
- if (!empty($row->ogrnip)) $ogrnip = $row->ogrnip; else $ogrnip = null;
- if (!empty($row->certificateNumber)) $certificateNumber = $row->certificateNumber; else $certificateNumber = null;
- if (!empty($row->certificateDate)) $certificateDate = $row->certificateDate; else $certificateDate = null;
- if (!empty($row->salesAmount)) $salesAmount = $row->salesAmount; else $salesAmount = null;
- $archived = $this->checkIfArchived($row);
- $shared = $this->checkIfShared($row);
- $companyType = $this->getCompanyType($row);
- $groupId = $this->getGroupId($row->group->meta->href);
- $sql = "
- INSERT INTO `{$this->counterPartyTable}` (`counter_party_id`, `owner_id`, `group_id`, `shared`, `version`, `updated`, `name`, `description`, `code`, `external_code`, `archived`, `created`, `email`, `phone`, `fax`, `actual_address`, `company_type`, `legal_title`, `legal_address`, `inn`, `kpp`, `ogrn`,`okpo`,`ogrnip`,`certificateNumber`, `certificateDate`, `discount_card_number`, `state_type`, `sales_amount`)
- VALUES ('{$row->id}', '{$ownerId}', '{$groupId}', '{$shared}', '{$version}', '{$updated}', '{$name}', '{$description}', '{$code}', '{$externalCode}', '{$archived}', '{$created}', '{$email}', '{$phone}', '{$fax}', '{$actualAddress}', '{$companyType}', '{$legalTitle}', '{$legalAddress}', '{$inn}', '{$kpp}', '{$ogrn}', '{$okpo}', '{$ogrnip}', '{$certificateNumber}', '{$certificateDate}', '{$discountCardNumber}', '{$stateType}', '{$salesAmount}');
- ";
- $this->makeYiiOperation($sql);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateAssortmentTable()
- {
- $method = "entity/assortment";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- $assortmentId = $row->id;
- $dataOwnerDecoded = json_decode($this->curlPost($row->owner->meta->href, $this->username, $this->password));
- $dataUomDecoded = json_decode($this->curlPost($row->uom->meta->href, $this->username, $this->password));
- if (!empty($dataOwnerDecoded->id)) $ownerId = $dataOwnerDecoded->id; else $ownerId = null;
- if (!empty($dataUomDecoded->id)) $uomId = $dataUomDecoded->id; else $uomId = null;
- if (!empty($row->version)) $version = $row->version; else $version = null;
- if (!empty($row->updated)) $updated = $row->updated; else $updated = null;
- if (!empty($row->name)) $name = $row->name; else $name = null;
- if (!empty($row->code)) $code = $row->code; else $code = null;
- if (!empty($row->externalCode)) $externalCode = $row->externalCode; else $externalCode = null;
- if (!empty($row->pathName)) $pathName = $row->pathName; else $pathName = null;
- if (!empty($row->minPrice)) $minPrice = $row->minPrice; else $minPrice = null;
- if (!empty($row->weight)) $weight = $row->weight; else $weight = null;
- if (!empty($row->volume)) $volume = $row->volume; else $volume = null;
- if (!empty($row->stock)) $stock = $row->stock; else $stock = null;
- if (!empty($row->reserve)) $reserve = $row->reserve; else $reserve = null;
- if (!empty($row->inTransit)) $inTransit = $row->inTransit; else $inTransit = null;
- if (!empty($row->quantity)) $quantity = $row->quantity; else $quantity = null;
- $archived = $this->checkIfArchived($row);
- $shared = $this->checkIfShared($row);
- if ($row->isSerialTrackable) $isSerialTrackable = "Да"; else $isSerialTrackable = "Нет";
- $groupId = $this->getGroupId($row->group->meta->href);
- if (!empty($row->barcodes)) {
- foreach ($row->salePrices as $salePrice) {
- $dataCurrencyDecoded = json_decode($this->curlPost($salePrice->currency->meta->href, $this->username, $this->password));
- $salePriceValue = $salePrice->value;
- $salePriceCurrencyCode = $dataCurrencyDecoded->code;
- $salePriceType = $salePrice->priceType;
- $this->updateSalePricesTable($assortmentId, $salePriceValue, $salePriceCurrencyCode, $salePriceType);
- }
- }
- if (!empty($row->barcodes)) {
- foreach ($row->barcodes as $barcode) {
- $this->updateBarcodesTable($assortmentId, $barcode);
- }
- }
- $sql = "
- INSERT INTO `{$this->assortmentTable}` (`assortment_id`, `owner_id`, `group_id`, `shared`, `version`, `updated`, `name`, `code`, `external_code`, `archived`, `path_name`, `uom_id`, `min_price`, `weight`, `volume`, `is_serial_trackable`, `stock`, `reserve`, `in_transit`, `quantity`)
- VALUES ('{$assortmentId}', '{$ownerId}', '{$groupId}', '{$shared}', '{$version}', '{$updated}', '{$name}', '$code}', '{$externalCode}', '{$archived}', '{$pathName}', '{$uomId}', '{$minPrice}', '{$weight}', '{$volume}', '{$isSerialTrackable}', '{$stock}', '{$reserve}', '{$inTransit}', '{$quantity}');
- ";
- $this->makeYiiOperation($sql);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateSalePricesTable($assortmentId, $salePriceValue, $salePriceCurrencyCode, $salePriceType)
- {
- $sql = "
- INSERT INTO `{$this->salePricesTable}` (`assortment_id`, `value`, `currency_code`, `price_type`)
- VALUES ('{$assortmentId}', '{$salePriceValue}', '{$salePriceCurrencyCode}', '{$salePriceType}');
- ";
- $this->makeYiiOperation($sql);
- }
- private function updateBarcodesTable($assortmentId, $barcode)
- {
- $sql = "
- INSERT INTO `{$this->barcodesTable}` (`assortment_id`, `barcode`)
- VALUES ('{$assortmentId}', '{$barcode}');
- ";
- $this->makeYiiOperation($sql);
- }
- private function updateCurrencyTable()
- {
- $method = "entity/currency";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- if (!empty($row->code)) $code = $row->code; else $code = null;
- if (!empty($row->name)) $name = $row->name; else $name = null;
- if (!empty($row->fullName)) $fullName = $row->fullName; else $fullName = null;
- if (!empty($row->isoCode)) $isoCode = $row->isoCode; else $isoCode = null;
- $sql = "
- INSERT INTO `{$this->currencyTable}` (`code`, `name`, `full_name`, `iso_code`)
- VALUES ('{$code}', '{$name}', '{$fullName}', '{$isoCode}');
- ";
- $this->makeYiiOperation($sql);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateProductTable()
- {
- $method = "entity/product";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- $productId = $row->id;
- $dataOwnerDecoded = json_decode($this->curlPost($row->owner->meta->href, $this->username, $this->password));
- $dataUomDecoded = json_decode($this->curlPost($row->uom->meta->href, $this->username, $this->password));
- if (!empty($dataOwnerDecoded->id)) $ownerId = $dataOwnerDecoded->id; else $ownerId = null;
- if (!empty($dataUomDecoded->id)) $uomId = $dataUomDecoded->id; else $uomId = null;
- if (!empty($row->version)) $version = $row->version; else $version = null;
- if (!empty($row->updated)) $updated = $row->updated; else $updated = null;
- if (!empty($row->name)) $name = $row->name; else $name = null;
- if (!empty($row->description)) $description = $row->description; else $description = null;
- if (!empty($row->code)) $code = $row->code; else $code = null;
- if (!empty($row->externalCode)) $externalCode = $row->externalCode; else $externalCode = null;
- if (!empty($row->pathName)) $pathName = $row->pathName; else $pathName = null;
- if (!empty($row->vat)) $vat = $row->vat; else $vat = null;
- if (!empty($row->effectiveVat)) $effectiveVat = $row->effectiveVat; else $effectiveVat = null;
- if (!empty($row->minPrice)) $minPrice = $row->minPrice; else $minPrice = null;
- if (!empty($row->buyPrice->value)) $buyPrice = $row->buyPrice->value; else $buyPrice = null;
- if (!empty($row->modificationsCount)) $modificationsCount = $row->modificationsCount; else $modificationsCount = null;
- if (!empty($row->minimumBalance)) $minimumBalance = $row->minimumBalance; else $minimumBalance = null;
- $archived = $this->checkIfArchived($row);
- $shared = $this->checkIfShared($row);
- if ($row->isSerialTrackable) $isSerialTrackable = "Да"; else $isSerialTrackable = "Нет";
- $groupId = $this->getGroupId($row->group->meta->href);
- if (!empty($row->barcodes)) {
- foreach ($row->salePrices as $salePrice) {
- $dataCurrencyDecoded = json_decode($this->curlPost($salePrice->currency->meta->href, $this->username, $this->password));
- $salePriceValue = $salePrice->value;
- $salePriceCurrencyCode = $dataCurrencyDecoded->code;
- $salePriceType = $salePrice->priceType;
- $this->updateSalePricesTable($productId, $salePriceValue, $salePriceCurrencyCode, $salePriceType);
- }
- }
- if (!empty($row->barcodes)) {
- foreach ($row->barcodes as $barcode) {
- $this->updateBarcodesTable($productId, $barcode);
- }
- }
- $sql = "
- INSERT INTO `{$this->productTable}` (`product_id`, `owner_id`, `shared`, `group_id`, `version`, `updated`, `name`, `description`, `code`, `external_code`, `archived`, `path_name`, `vat`, `effective_vat`, `uom`, `min_price`, `buy_price`, `modifications_count`, `minimum_balance`, `is_serial_trackable`)
- VALUES ('{$row->id}', '{$ownerId}', '{$shared}', '{$groupId}', '{$version}', '{$updated}', '{$name}', '{$description}', '{$code}', '{$externalCode}', '{$archived}', '{$pathName}', '{$vat}', '{$effectiveVat}', '{$uomId}', '{$minPrice}', '{$buyPrice}', '{$modificationsCount}', '{$minimumBalance}', '{$isSerialTrackable}');
- ";
- $this->makeYiiOperation($sql);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateServiceTable()
- {
- $method = "entity/service";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- var_dump($row);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateBundleTable()
- {
- $method = "entity/bundle";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- var_dump($row);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateProductFolderTable()
- {
- $method = "entity/productfolder";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- $dataOwnerDecoded = json_decode($this->curlPost($row->owner->meta->href, $this->username, $this->password));
- if (!empty($dataOwnerDecoded->id)) $ownerId = $dataOwnerDecoded->id; else $ownerId = null;
- if (!empty($row->version)) $version = $row->version; else $version = null;
- if (!empty($row->updated)) $updated = $row->updated; else $updated = null;
- if (!empty($row->name)) $name = $row->name; else $name = null;
- if (!empty($row->description)) $description = $row->description; else $description = null;
- if (!empty($row->code)) $code = $row->code; else $code = null;
- if (!empty($row->externalCode)) $externalCode = $row->externalCode; else $externalCode = null;
- if (!empty($row->pathName)) $pathName = $row->pathName; else $pathName = null;
- if (!empty($row->vat)) $vat = $row->vat; else $vat = null;
- if (!empty($row->effectiveVat)) $effectiveVat = $row->effectiveVat; else $effectiveVat = null;
- $shared = $this->checkIfShared($row);
- $archived = $this->checkIfArchived($row);
- $groupId = $this->getGroupId($row->group->meta->href);
- $sql = "
- INSERT INTO `{$this->productFolderTable}` (`product_folder_id`, `owner_id`, `shared`, `group_id`, `version`, `updated`, `name`, `description`, `code`, `external_code`, `archived`, `path_name`, `vat`, `effective_vat`)
- VALUES ('{$row->id}', '{$ownerId}', '{$shared}', '{$groupId}', '{$version}', '{$updated}', '{$name}', '{$description}', '{$code}', '{$externalCode}', '{$archived}', '{$pathName}', '{$vat}', '{$effectiveVat}');
- ";
- $this->makeYiiOperation($sql);
- if (!empty($row->productFolder)) {
- $dataProductFolderDecoded = json_decode($this->curlPost($row->productFolder->meta->href, $this->username, $this->password));
- $this->plusProductFolder($dataProductFolderDecoded);
- }
- }
- }
- }
- return true;
- }
- return false;
- }
- private function plusProductFolder($row)
- {
- $dataOwnerDecoded = json_decode($this->curlPost($row->owner->meta->href, $this->username, $this->password));
- if (!empty($dataOwnerDecoded->id)) $ownerId = $dataOwnerDecoded->id; else $ownerId = null;
- if (!empty($row->version)) $version = $row->version; else $version = null;
- if (!empty($row->updated)) $updated = $row->updated; else $updated = null;
- if (!empty($row->name)) $name = $row->name; else $name = null;
- if (!empty($row->description)) $description = $row->description; else $description = null;
- if (!empty($row->code)) $code = $row->code; else $code = null;
- if (!empty($row->externalCode)) $externalCode = $row->externalCode; else $externalCode = null;
- if (!empty($row->pathName)) $pathName = $row->pathName; else $pathName = null;
- if (!empty($row->vat)) $vat = $row->vat; else $vat = null;
- if (!empty($row->effectiveVat)) $effectiveVat = $row->effectiveVat; else $effectiveVat = null;
- $shared = $this->checkIfShared($row);
- $archived = $this->checkIfArchived($row);
- $groupId = $this->getGroupId($row->group->meta->href);
- $sql = "
- INSERT INTO `{$this->productFolderTable}` (`product_folder_id`, `owner_id`, `shared`, `group_id`, `version`, `updated`, `name`, `description`, `code`, `external_code`, `archived`, `path_name`, `vat`, `effective_vat`)
- VALUES ('{$row->id}', '{$ownerId}', '{$shared}', '{$groupId}', '{$version}', '{$updated}', '{$name}', '{$description}', '{$code}', '{$externalCode}', '{$archived}', '{$pathName}', '{$vat}', '{$effectiveVat}');
- ";
- $this->makeYiiOperation($sql);
- if (!empty($row->productFolder)) {
- $dataProductFolderDecoded = json_decode($this->curlPost($row->productFolder->meta->href, $this->username, $this->password));
- $this->plusProductFolder($dataProductFolderDecoded);
- }
- }
- private function updateVariantTable()
- {
- $method = "entity/variant";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- var_dump($row);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateConsignmentTable()
- {
- $method = "entity/consignment";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- var_dump($row);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateContractTable()
- {
- $method = "entity/contract";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- var_dump($row);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateProjectTable()
- {
- $method = "entity/project";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- $dataOwnerDecoded = json_decode($this->curlPost($row->owner->meta->href, $this->username, $this->password));
- if (!empty($dataOwnerDecoded->id)) $ownerId = $dataOwnerDecoded->id; else $ownerId = null;
- if (!empty($row->version)) $version = $row->version; else $version = null;
- if (!empty($row->updated)) $updated = $row->updated; else $updated = null;
- if (!empty($row->name)) $name = $row->name; else $name = null;
- if (!empty($row->description)) $description = $row->description; else $description = null;
- if (!empty($row->code)) $code = $row->code; else $code = null;
- if (!empty($row->externalCode)) $externalCode = $row->externalCode; else $externalCode = null;
- $archived = $this->checkIfArchived($row);
- $shared = $this->checkIfShared($row);
- $groupId = $this->getGroupId($row->group->meta->href);
- $sql = "
- INSERT INTO `{$this->projectTable}` (`project_id`, `owner_id`, `shared`, `group_id`, `version`, `updated`, `name`, `description`, `code`, `external_code`, `archived`)
- VALUES ('{$row->id}', '{$ownerId}', '{$shared}', '{$groupId}', '{$version}', '{$updated}', '{$name}', '{$description}', '{$code}', '{$externalCode}', '{$archived}');
- ";
- $this->makeYiiOperation($sql);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateExpenseItemTable()
- {
- $method = "entity/expenseitem";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- if (!empty($row->version)) $version = $row->version; else $version = null;
- if (!empty($row->updated)) $updated = $row->updated; else $updated = null;
- if (!empty($row->name)) $name = $row->name; else $name = null;
- if (!empty($row->description)) $description = $row->description; else $description = null;
- if (!empty($row->code)) $code = $row->code; else $code = null;
- if (!empty($row->externalCode)) $externalCode = $row->externalCode; else $externalCode = null;
- $sql = "
- INSERT INTO `{$this->expenseItemTable}` (`expense_item_id`, `version`, `updated`, `name`, `description`, `code`, `external_code`)
- VALUES ('{$row->id}', '{$version}', '{$updated}', '{$name}', '{$description}', '{$code}', '{$externalCode}');
- ";
- $this->makeYiiOperation($sql);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateCountriesTable()
- {
- $method = "entity/country";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- $sql = "
- INSERT INTO `{$this->countriesTable}` (`country_id`, `name`, `description`, `code`, `external_code`)
- VALUES ('{$row->id}', '{$row->name}', '{$row->description}', '{$row->code}', '{$row->externalCode}');
- ";
- $this->makeYiiOperation($sql);
- }
- }
- }
- return true;
- }
- return false;
- }
- //
- private function updateGroupsTable()
- {
- $method = "entity/group";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- $group_id = $this->getGroupId($row->meta->href);
- $sql = "
- INSERT INTO `{$this->groupsTable}` (`group_id`, `name`)
- VALUES ('{$group_id}', '{$row->name}');
- ";
- $this->makeYiiOperation($sql);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateDiscountTable()
- {
- $method = "entity/discount";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- var_dump($row);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateUomTable()
- {
- $method = "entity/uom";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- $sql = "
- INSERT INTO `{$this->uomTable}` (`uom_id`, `version`, `updated`, `name`,`description`, `code`, `external_code`)
- VALUES ('{$row->id}', '{$row->version}', '{$row->updated}', '{$row->description}', '{$row->code}', '{$row->name}', '{$row->externalCode}');
- ";
- $this->makeYiiOperation($sql);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateEmployeesTable()
- {
- $method = "entity/employee";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- $dataOwnerDecoded = json_decode($this->curlPost($row->owner->meta->href, $this->username, $this->password));
- $dataRetailStoreDecoded = json_decode($this->curlPost($row->cashier->retailStore->meta->href, $this->username, $this->password));
- if (!empty($dataOwnerDecoded->id)) $ownerId = $dataOwnerDecoded->id; else $ownerId = null;
- if (!empty($row->cashier->id)) $cashierId = $row->cashier->id; else $cashierId = null;
- if (!empty($dataRetailStoreDecoded->id)) $retailStoreId = $dataRetailStoreDecoded->id; else $retailStoreId = null;
- if (!empty($row->version)) $version = $row->version; else $version = null;
- if (!empty($row->updated)) $updated = $row->updated; else $updated = null;
- if (!empty($row->externalCode)) $externalCode = $row->externalCode; else $externalCode = null;
- if (!empty($row->created)) $created = $row->created; else $created = null;
- if (!empty($row->uid)) $uid = $row->uid; else $uid = null;
- if (!empty($row->email)) $email = $row->email; else $email = null;
- if (!empty($row->phone)) $phone = $row->phone; else $phone = null;
- if (!empty($row->fullName)) $fullName = $row->fullName; else $fullName = null;
- if (!empty($row->shortFio)) $shortFio = $row->shortFio; else $shortFio = null;
- $archived = $this->checkIfArchived($row);
- $shared = $this->checkIfShared($row);
- $groupId = $this->getGroupId($row->group->meta->href);
- $sql = "
- INSERT INTO `{$this->employeesTable}` (`employee_id`, `owner_id`, `group_id`, `shared`, `version`, `updated`, `external_code`, `archived`, `created`, `uid`, `email`, `phone`, `full_name`, `short_fio`, `cashier_id`, `retail_store_id`)
- VALUES ('{$row->id}', '{$ownerId}', '{$groupId}', '{$shared}', '{$version}', '{$updated}', '{$externalCode}', '{$archived}', '{$created}', '{$uid}', '{$email}', '{$phone}', '{$fullName}', '{$shortFio}', '{$cashierId}', '{$retailStoreId}');
- ";
- $this->makeYiiOperation($sql);
- }
- }
- }
- return true;
- }
- return false;
- }
- //
- private function updateStoresTable()
- {
- $method = "entity/store";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- $dataOwnerDecoded = json_decode($this->curlPost($row->owner->meta->href, $this->username, $this->password));
- if (!empty($dataOwnerDecoded->id)) $ownerId = $dataOwnerDecoded->id; else $ownerId = null;
- if (!empty($row->version)) $version = $row->version; else $version = null;
- if (!empty($row->updated)) $updated = $row->updated; else $updated = null;
- if (!empty($row->name)) $name = $row->name; else $name = null;
- if (!empty($row->description)) $description = $row->description; else $description = null;
- if (!empty($row->code)) $code = $row->code; else $code = null;
- if (!empty($row->externalCode)) $externalCode = $row->externalCode; else $externalCode = null;
- if (!empty($row->address)) $address = $row->address; else $address = null;
- if (!empty($row->parent)) $parent = $row->parent; else $parent = null;
- if (!empty($row->pathName)) $pathName = $row->pathName; else $pathName = null;
- $archived = $this->checkIfArchived($row);
- $shared = $this->checkIfShared($row);
- $groupId = $this->getGroupId($row->group->meta->href);
- $sql = "
- INSERT INTO `{$this->storesTable}` (`store_id`, `owner_id`, `shared`, `group_id`, `version`, `updated`, `name`, `description`, `code`, `external_code`, `archived`, `address`, `parent`, `path_name`)
- VALUES ('{$row->id}', '{$ownerId}', '{$shared}', '{$groupId}', '{$version}', '{$updated}', '{$name}', '{$description}', '{$code}', '{$externalCode}', '{$archived}', '{$address}', '{$parent}', '{$pathName}');
- ";
- $this->makeYiiOperation($sql);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateOrganizationsTable()
- {
- $method = "entity/organization";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- $organizationId = $row->id;
- $dataOwnerDecoded = json_decode($this->curlPost($row->owner->meta->href, $this->username, $this->password));
- $dataAccountsDecoded = json_decode($this->curlPost($row->accounts->meta->href, $this->username, $this->password));
- if (!empty($dataOwnerDecoded->id)) $ownerId = $dataOwnerDecoded->id; else $ownerId = null;
- if (!empty($row->version)) $version = $row->version; else $version = null;
- if (!empty($row->updated)) $updated = $row->updated; else $updated = null;
- if (!empty($row->name)) $name = $row->name; else $name = null;
- if (!empty($row->description)) $description = $row->description; else $description = null;
- if (!empty($row->code)) $code = $row->code; else $code = null;
- if (!empty($row->externalCode)) $externalCode = $row->externalCode; else $externalCode = null;
- if (!empty($row->created)) $created = $row->created; else $created = null;
- if (!empty($row->legalTitle)) $legalTitle = $row->legalTitle; else $legalTitle = null;
- if (!empty($row->legalAddress)) $legalAddress = $row->legalAddress; else $legalAddress = null;
- if (!empty($row->inn)) $inn = $row->inn; else $inn = null;
- if (!empty($row->kpp)) $kpp = $row->kpp; else $kpp = null;
- if (!empty($row->ogrn)) $ogrn = $row->ogrn; else $ogrn = null;
- if (!empty($row->okpo)) $okpo = $row->okpo; else $okpo = null;
- if (!empty($row->ogrnip)) $ogrnip = $row->ogrnip; else $ogrnip = null;
- if (!empty($row->certificateNumber)) $certificateNumber = $row->certificateNumber; else $certificateNumber = null;
- if (!empty($row->certificateDate)) $certificateDate = $row->certificateDate; else $certificateDate = null;
- if (!empty($row->email)) $email = $row->email; else $email = null;
- if (!empty($row->phone)) $phone = $row->phone; else $phone = null;
- if (!empty($row->fax)) $fax = $row->fax; else $fax = null;
- if (!empty($row->fsrarId)) $fsrarId = $row->fsrarId; else $fsrarId = null;
- if (!empty($row->utmUrl)) $utmUrl = $row->utmUrl; else $utmUrl = null;
- if (!empty($row->actualAddress)) $actualAddress = $row->actualAddress; else $actualAddress = null;
- if (!empty($row->director)) $director = $row->director; else $director = null;
- if (!empty($row->chiefAccountant)) $chiefAccountant = $row->chiefAccountant; else $chiefAccountant = null;
- $archived = $this->checkIfArchived($row);
- $shared = $this->checkIfShared($row);
- $groupId = $this->getGroupId($row->group->meta->href);
- $companyType = $this->getCompanyType($row);
- $isEgaisEnable = $this->checkIfEgaisEnable($row);
- $payerVat = $this->checkPayerVat($row);
- $sql = "
- INSERT INTO `{$this->organizationsTable}` (`organisation_id`, `owner_id`, `shared`, `group_id`, `version`, `updated`, `name`, `description`, `code`, `external_code`, `archived`, `created`, `company_type`, `legal_title`, `legal_address`, `inn`, `kpp`, `ogrn`, `ogrnip`, `okpo`, `certificate_number`, `certificate_date`, `email`, `phone`, `fax`, `is_egais_enable`, `fsrar_id`, `payer_vat`, `utm_url`, `actual_address`, `director`, `chief_accountant`)
- VALUES ('{$organizationId}', '{$ownerId}', '{$shared}', '{$groupId}', '{$version}', '{$updated}', '{$name}', '{$description}', '{$code}', '{$externalCode}', '{$archived}', '{$created}', '{$companyType}', '{$legalTitle}', '{$legalAddress}', '{$inn}', '{$kpp}', '{$ogrn}', '{$ogrnip}', '{$okpo}', '{$certificateNumber}', '{$certificateDate}', '{$email}', '{$phone}', '{$fax}', '{$isEgaisEnable}', '{$fsrarId}', '{$payerVat}', '{$utmUrl}', '{$actualAddress}', '{$director}', '{$chiefAccountant}');
- ";
- $this->updateAccountsTable($organizationId, $dataAccountsDecoded);
- $this->makeYiiOperation($sql);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateAccountsTable($organizationId, $dataAccountsDecoded)
- {
- $dataAgencyDecoded = json_decode($this->curlPost($dataAccountsDecoded->agent->meta->href, $this->username, $this->password));
- if (!empty($dataAgencyDecoded->id)) $agencyId = $dataAgencyDecoded->id; else $agencyId = null;
- if (!empty($dataAccountsDecoded->version)) $version = $dataAccountsDecoded->version; else $version = null;
- if (!empty($dataAccountsDecoded->updated)) $updated = $dataAccountsDecoded->updated; else $updated = null;
- if (!empty($dataAccountsDecoded->accountNumber)) $accountNumber = $dataAccountsDecoded->accountNumber; else $accountNumber = null;
- if (!empty($dataAccountsDecoded->bankName)) $bankName = $dataAccountsDecoded->bankName; else $bankName = null;
- if (!empty($dataAccountsDecoded->bankLocation)) $bankLocation = $dataAccountsDecoded->bankLocation; else $bankLocation = null;
- if (!empty($dataAccountsDecoded->correspondentAccount)) $correspondentAccount = $dataAccountsDecoded->correspondentAccount; else $correspondentAccount = null;
- if (!empty($dataAccountsDecoded->bic)) $bic = $dataAccountsDecoded->bic; else $bic = null;
- $isDefault = $this->checkIsDefault($dataAccountsDecoded);
- $sql = "
- INSERT INTO `{$this->accountsTable}` (`account_id`, `organisation_id`, `version`, `updated`, `is_default`, `account_number`, `bank_name`, `bank_location`, `correspondent_account`, `bic`, `agent_id`)
- VALUES ('{$dataAccountsDecoded->id}', '{$organizationId}', '{$version}', '{$updated}', '{$isDefault}', '{$accountNumber}', '{$bankName}', '{$bankLocation}', '{$correspondentAccount}', '{$bic}', '{$agencyId}');
- ";
- $this->makeYiiOperation($sql);
- }
- private function updateRetailStoreTable()
- {
- $method = "entity/retailstore";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- $dataOwnerDecoded = json_decode($this->curlPost($row->{'owner'}->{'meta'}->{'href'}, $this->username, $this->password));
- $sql = "
- INSERT INTO `{$this->retailStoreTable}` (`login`, `retail_store_id`, `updated`, `name`, `discount_max_percent`, `price_type`, `owner_name`, `owner_email`, `owner_phone`)
- VALUES ('{$this->login}', '{$row->{'id'}}', '{$row->{'updated'}}', '{$row->{'name'}}', '{$row->{'discountMaxPercent'}}', '{$row->{'priceType'}}', '{$dataOwnerDecoded->{'name'}}', '{$dataOwnerDecoded->{'email'}}', '{$dataOwnerDecoded->{'phone'}}');
- ";
- $this->makeYiiOperation($sql);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateCashiersTable()
- {
- $method = "entity/cashiers";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- var_dump($row);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateTaskTable()
- {
- $method = "entity/task";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- var_dump($row);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateRetailshiftTable()
- {
- $method = "entity/retailshift";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- var_dump($row);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateEnterTable()
- {
- $method = "entity/enter";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- var_dump($row);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateCustomerOrdersTable()
- {
- $method = "entity/customerorder";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- $customerOrderId = $row->id;
- $dataAgencyDecoded = json_decode($this->curlPost($row->agent->meta->href, $this->username, $this->password));
- $dataRateDecoded = json_decode($this->curlPost($row->rate->currency->meta->href, $this->username, $this->password));
- $dataProject = json_decode($this->curlPost($row->project->meta->href, $this->username, $this->password));
- $dataOwnerDecoded = json_decode($this->curlPost($row->owner->meta->href, $this->username, $this->password));
- $dataStoreDecoded = json_decode($this->curlPost($row->store->meta->href, $this->username, $this->password));
- $dataOrganizationDecoded = json_decode($this->curlPost($row->organization->meta->href, $this->username, $this->password));
- if (!empty($dataOrganizationDecoded->id)) $organizationId = $dataOrganizationDecoded->id; else $organizationId = null;
- if (!empty($dataStoreDecoded->id)) $storeId = $dataStoreDecoded->id; else $storeId = null;
- if (!empty($dataRateDecoded->code)) $rateId = $dataRateDecoded->code; else $rateId = null;
- if (!empty($dataProject->id)) $projectId = $dataProject->id; else $projectId = null;
- if (!empty($dataAgencyDecoded->id)) $agencyId = $dataAgencyDecoded->id; else $agencyId = null;
- if (!empty($dataOwnerDecoded->id)) $ownerId = $dataOwnerDecoded->id; else $ownerId = null;
- if (!empty($row->version)) $version = $row->version; else $version = null;
- if (!empty($row->updated)) $updated = $row->updated; else $updated = null;
- if (!empty($row->deleted)) $deleted = $row->deleted; else $deleted = null;
- if (!empty($row->name)) $name = $row->name; else $name = null;
- if (!empty($row->sum)) $sum = $row->sum; else $sum = null;
- if (!empty($row->description)) $description = $row->description; else $description = null;
- if (!empty($row->externalCode)) $externalCode = $row->externalCode; else $externalCode = null;
- if (!empty($row->moment)) $moment = $row->moment; else $moment = null;
- if (!empty($row->created)) $created = $row->created; else $created = null;
- if (!empty($row->deliveryPlannedMoment)) $deliveryPlannedMoment = $row->deliveryPlannedMoment; else $deliveryPlannedMoment = null;
- if (!empty($row->payedSum)) $payedSum = $row->payedSum; else $payedSum = null;
- if (!empty($row->vatSum)) $vatSum = $row->vatSum; else $vatSum = null;
- if (!empty($row->reservedSum)) $reservedSum = $row->reservedSum; else $reservedSum = null;
- if (!empty($row->shippedSum)) $shippedSum = $row->shippedSum; else $shippedSum = null;
- if (!empty($row->invoicedSum)) $invoicedSum = $row->invoicedSum; else $invoicedSum = null;
- $shared = $this->checkIfShared($row);
- $groupId = $this->getGroupId($row->group->meta->href);
- $applicable = $this->checkIfApplicable($row);
- $vatEnabled = $this->checkIfVatEnable($row);
- $positionsHref = $row->positions->meta->href;
- $this->updateOrdersPositionsArrayTable($customerOrderId, $positionsHref);
- $sql = "
- INSERT INTO `{$this->customerOrdersTable}` (`customer_order_id`, `owner_id`, `version`, `updated`, `deleted`, `name`, `description`, `external_code`, `moment`, `applicable`, `vat_enabled`, `sum`, `rate`, `shared`, `group_id`, `organization_id`, `agent_id`, `store_id`, `created`, `vat_sum`, `reserved_sum`, `delivery_planned_moment`, `payed_sum`, `shipped_sum`, `invoiced_sum`, `project_id`)
- VALUES ('{$customerOrderId}', '{$ownerId}', '{$version}', '{$updated}', '{$deleted}', '{$name}', '{$description}', '{$externalCode}', '{$moment}', '{$applicable}', '{$vatEnabled}', '{$sum}', '{$rateId}', '{$shared}', '{$groupId}', '{$organizationId}', '{$agencyId}', '{$storeId}', '{$created}', '{$vatSum}', '{$reservedSum}', '{$deliveryPlannedMoment}', '{$payedSum}', '{$shippedSum}', '{$invoicedSum}', '{$projectId}');
- ";
- $this->makeYiiOperation($sql);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updatePurchaseOrderTable()
- {
- $method = "entity/purchaseorder";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- $purchaseOrderId = $row->id;
- $dataAgencyDecoded = json_decode($this->curlPost($row->agent->meta->href, $this->username, $this->password));
- $dataRateDecoded = json_decode($this->curlPost($row->rate->currency->meta->href, $this->username, $this->password));
- $dataProject = json_decode($this->curlPost($row->project->meta->href, $this->username, $this->password));
- $dataOwnerDecoded = json_decode($this->curlPost($row->owner->meta->href, $this->username, $this->password));
- $dataStoreDecoded = json_decode($this->curlPost($row->store->meta->href, $this->username, $this->password));
- $dataOrganizationDecoded = json_decode($this->curlPost($row->organization->meta->href, $this->username, $this->password));
- if (!empty($dataOrganizationDecoded->id)) $organizationId = $dataOrganizationDecoded->id; else $organizationId = null;
- if (!empty($dataStoreDecoded->id)) $storeId = $dataStoreDecoded->id; else $storeId = null;
- if (!empty($dataRateDecoded->code)) $rateId = $dataRateDecoded->code; else $rateId = null;
- if (!empty($dataProject->id)) $projectId = $dataProject->id; else $projectId = null;
- if (!empty($dataAgencyDecoded->id)) $agencyId = $dataAgencyDecoded->id; else $agencyId = null;
- if (!empty($dataOwnerDecoded->id)) $ownerId = $dataOwnerDecoded->id; else $ownerId = null;
- if (!empty($row->version)) $version = $row->version; else $version = null;
- if (!empty($row->updated)) $updated = $row->updated; else $updated = null;
- if (!empty($row->deleted)) $deleted = $row->deleted; else $deleted = null;
- if (!empty($row->name)) $name = $row->name; else $name = null;
- if (!empty($row->sum)) $sum = $row->sum; else $sum = null;
- if (!empty($row->description)) $description = $row->description; else $description = null;
- if (!empty($row->externalCode)) $externalCode = $row->externalCode; else $externalCode = null;
- if (!empty($row->moment)) $moment = $row->moment; else $moment = null;
- if (!empty($row->created)) $created = $row->created; else $created = null;
- if (!empty($row->deliveryPlannedMoment)) $deliveryPlannedMoment = $row->deliveryPlannedMoment; else $deliveryPlannedMoment = null;
- if (!empty($row->payedSum)) $payedSum = $row->payedSum; else $payedSum = null;
- if (!empty($row->vatSum)) $vatSum = $row->vatSum; else $vatSum = null;
- if (!empty($row->reservedSum)) $reservedSum = $row->reservedSum; else $reservedSum = null;
- if (!empty($row->shippedSum)) $shippedSum = $row->shippedSum; else $shippedSum = null;
- if (!empty($row->invoicedSum)) $invoicedSum = $row->invoicedSum; else $invoicedSum = null;
- if (!empty($row->waitSum)) $waitSum = $row->waitSum; else $waitSum = null;
- $shared = $this->checkIfShared($row);
- $groupId = $this->getGroupId($row->group->meta->href);
- $applicable = $this->checkIfApplicable($row);
- $vatEnabled = $this->checkIfVatEnable($row);
- $positionsHref = $row->positions->meta->href;
- $this->updateOrdersPositionsArrayTable($purchaseOrderId, $positionsHref);
- $sql = "
- INSERT INTO `{$this->purchaseOrderTable}` (`purchase_order_id`, `owner_id`, `version`, `updated`, `deleted`, `name`, `description`, `external_code`, `moment`, `applicable`, `vat_enabled`, `sum`, `rate`, `shared`, `group_id`, `organization_id`, `agent_id`, `store_id`, `created`, `vat_sum`, `reserved_sum`, `delivery_planned_moment`, `payed_sum`, `shipped_sum`, `invoiced_sum`, `project_id`, `wait_sum`)
- VALUES ('{$purchaseOrderId}', '{$ownerId}', '{$version}', '{$updated}', '{$deleted}', '{$name}', '{$description}', '{$externalCode}', '{$moment}', '{$applicable}', '{$vatEnabled}', '{$sum}', '{$rateId}', '{$shared}', '{$groupId}', '{$organizationId}', '{$agencyId}', '{$storeId}', '{$created}', '{$vatSum}', '{$reservedSum}', '{$deliveryPlannedMoment}', '{$payedSum}', '{$shippedSum}', '{$invoicedSum}', '{$projectId}', '{$waitSum}');
- ";
- $this->makeYiiOperation($sql);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateOrdersPositionsArrayTable($orderId, $positionsHref)
- {
- $dataDecoded = json_decode($this->curlPost($positionsHref, $this->username, $this->password));
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($dataDecoded->rows as $row) {
- $this->updateOrdersPositionsTable($row);
- $sql = "
- INSERT INTO `{$this->positionsOrdersArrayTable}` (`positions_array_id`, `position_id`)
- VALUES ('{$orderId}', '{$row->id}');
- ";
- $this->makeYiiOperation($sql);
- }
- }
- }
- return true;
- }
- private function updateOrdersPositionsTable($row)
- {
- $dataAssortmentDecoded = json_decode($this->curlPost($row->assortment->meta->href, $this->username, $this->password));
- if (!empty($row->quantity)) $quantity = $row->quantity; else $quantity = null;
- if (!empty($dataAssortmentDecoded->id)) $assortmentId = $dataAssortmentDecoded->id; else $assortmentId = null;
- if (!empty($row->price)) $price = $row->price; else $price = null;
- if (!empty($row->discount)) $discount = $row->discount; else $discount = null;
- if (!empty($row->vat)) $vat = $row->vat; else $vat = null;
- if (!empty($row->shipped)) $shipped = $row->shipped; else $shipped = null;
- if (!empty($row->reserve)) $reserve = $row->reserve; else $reserve = null;
- if (!empty($row->wait)) $wait = $row->wait; else $wait = null;
- $sql = "
- INSERT INTO `{$this->positionsOrdersTable}` (`position_id`, `quantity`, `price`, `discount`, `vat`, `assortment_id`, `shipped`, `reserve`, `wait`)
- VALUES ('{$row->id}', '{$quantity}', '{$price}', '{$discount}', '{$vat}', '{$assortmentId}', '{$shipped}', '{$reserve}', '{$wait}');
- ";
- $this->makeYiiOperation($sql);
- }
- private function updateInvoiceOutTable()
- {
- $method = "entity/invoiceout";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- $dataOwnerDecoded = json_decode($this->curlPost($row->owner->meta->href, $this->username, $this->password));
- $dataStoreDecoded = json_decode($this->curlPost($row->store->meta->href, $this->username, $this->password));
- $dataOrganizationDecoded = json_decode($this->curlPost($row->organization->meta->href, $this->username, $this->password));
- $dataAgencyDecoded = json_decode($this->curlPost($row->agent->meta->href, $this->username, $this->password));
- $dataRateDecoded = json_decode($this->curlPost($row->rate->currency->meta->href, $this->username, $this->password));
- $dataCustomerOrder = json_decode($this->curlPost($row->customerOrder->meta->href, $this->username, $this->password));
- $dataProject = json_decode($this->curlPost($row->project->meta->href, $this->username, $this->password));
- if (!empty($dataAgencyDecoded->id)) $agencyId = $dataAgencyDecoded->id; else $agencyId = null;
- if (!empty($dataOrganizationDecoded->id)) $organizationId = $dataOrganizationDecoded->id; else $organizationId = null;
- if (!empty($dataOwnerDecoded->id)) $ownerId = $dataOwnerDecoded->id; else $ownerId = null;
- if (!empty($dataStoreDecoded->id)) $storeId = $dataStoreDecoded->id; else $storeId = null;
- if (!empty($dataCustomerOrder->id)) $customerOrderId = $dataCustomerOrder->id; else $customerOrderId = null;
- if (!empty($dataRateDecoded->code)) $rateId = $dataRateDecoded->code; else $rateId = null;
- if (!empty($dataProject->id)) $projectId = $dataProject->id; else $projectId = null;
- if (!empty($row->version)) $version = $row->version; else $version = null;
- if (!empty($row->updated)) $updated = $row->updated; else $updated = null;
- if (!empty($row->name)) $name = $row->name; else $name = null;
- if (!empty($row->externalCode)) $externalCode = $row->externalCode; else $externalCode = null;
- if (!empty($row->moment)) $moment = $row->moment; else $moment = null;
- if (!empty($row->sum)) $sum = $row->sum; else $sum = null;
- if (!empty($row->created)) $created = $row->created; else $created = null;
- if (!empty($row->vatSum)) $vatSum = $row->vatSum; else $vatSum = null;
- if (!empty($row->paymentPlannedMoment)) $paymentPlannedMoment = $row->paymentPlannedMoment; else $paymentPlannedMoment = null;
- if (!empty($row->payedSum)) $payedSum = $row->payedSum; else $payedSum = null;
- if (!empty($row->shippedSum)) $shippedSum = $row->shippedSum; else $shippedSum = null;
- $shared = $this->checkIfShared($row->shared);
- $groupId = $this->getGroupId($row->group->meta->href);
- $applicable = $this->checkIfApplicable($row);
- $vatEnabled = $this->checkIfVatEnable($row);
- $positionsHref = $row->positions->meta->href;
- $this->updateInvoicesPositionsArrayTable($row->id, $positionsHref);
- $sql = "
- INSERT INTO `{$this->invoiceOutTable}` (`invoice_out_id`, `owner_id`, `shared`, `group_id`, `version`, `updated`, `name`, `external_code`, `moment`, `applicable`, `rate`, `sum`, `store_id`, `agent_id`, `organization_id`, `created`, `vat_enabled`, `vat_sum`, `payment_planned_moment`, `payed_sum`, `shipped_sum`, `project_id`, `customer_order_id`)
- VALUES ('{$row->id}', '{$ownerId}', '{$shared}', '{$groupId}', '{$version}', '{$updated}', '{$name}', '{$externalCode}', '{$moment}', '{$applicable}', '{$rateId}', '{$sum}', '{$storeId}', '{$agencyId}', '{$organizationId}', '{$created}', '{$vatEnabled}', '{$vatSum}', '{$paymentPlannedMoment}', '{$payedSum}', '{$shippedSum}', '{$projectId}', '{$customerOrderId}');
- ";
- $this->makeYiiOperation($sql);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateInvoiceInTable()
- {
- $method = "entity/invoicein";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- $dataOwnerDecoded = json_decode($this->curlPost($row->owner->meta->href, $this->username, $this->password));
- $dataStoreDecoded = json_decode($this->curlPost($row->store->meta->href, $this->username, $this->password));
- $dataOrganizationDecoded = json_decode($this->curlPost($row->organization->meta->href, $this->username, $this->password));
- $dataAgencyDecoded = json_decode($this->curlPost($row->agent->meta->href, $this->username, $this->password));
- $dataRateDecoded = json_decode($this->curlPost($row->rate->currency->meta->href, $this->username, $this->password));
- $dataProject = json_decode($this->curlPost($row->project->meta->href, $this->username, $this->password));
- if (!empty($dataAgencyDecoded->id)) $agencyId = $dataAgencyDecoded->id; else $agencyId = null;
- if (!empty($dataOrganizationDecoded->id)) $organizationId = $dataOrganizationDecoded->id; else $organizationId = null;
- if (!empty($dataOwnerDecoded->id)) $ownerId = $dataOwnerDecoded->id; else $ownerId = null;
- if (!empty($dataStoreDecoded->id)) $storeId = $dataStoreDecoded->id; else $storeId = null;
- if (!empty($dataProject->id)) $projectId = $dataProject->id; else $projectId = null;
- if (!empty($row->version)) $version = $row->version; else $version = null;
- if (!empty($row->updated)) $updated = $row->updated; else $updated = null;
- if (!empty($row->name)) $name = $row->name; else $name = null;
- if (!empty($row->externalCode)) $externalCode = $row->externalCode; else $externalCode = null;
- if (!empty($row->moment)) $moment = $row->moment; else $moment = null;
- if (!empty($row->sum)) $sum = $row->sum; else $sum = null;
- if (!empty($dataRateDecoded->code)) $rateId = $dataRateDecoded->code; else $rateId = null;
- if (!empty($row->created)) $created = $row->created; else $created = null;
- if (!empty($row->vatSum)) $vatSum = $row->vatSum; else $vatSum = null;
- if (!empty($row->paymentPlannedMoment)) $paymentPlannedMoment = $row->paymentPlannedMoment; else $paymentPlannedMoment = null;
- if (!empty($row->payedSum)) $payedSum = $row->payedSum; else $payedSum = null;
- if (!empty($row->shippedSum)) $shippedSum = $row->shippedSum; else $shippedSum = null;
- if (!empty($row->incomingNumber)) $incomingNumber = $row->incomingNumber; else $incomingNumber = null;
- if (!empty($row->incomingDate)) $incomingDate = $row->incomingDate; else $incomingDate = null;
- $shared = $this->checkIfShared($row->shared);
- $groupId = $this->getGroupId($row->group->meta->href);
- $applicable = $this->checkIfApplicable($row);
- $vatEnabled = $this->checkIfVatEnable($row);
- $positionsHref = $row->positions->meta->href;
- $this->updateInvoicesPositionsArrayTable($row->id, $positionsHref);
- $sql = "
- INSERT INTO `{$this->invoiceInTable}` (`invoice_in_id`, `owner_id`, `shared`, `group_id`, `version`, `updated`, `name`, `external_code`, `moment`, `applicable`, `rate`, `sum`, `store_id`, `agent_id`, `organization_id`, `created`, `vat_enabled`, `vat_sum`, `payment_planned_moment`, `payed_sum`, `shipped_sum`, `project_id`, `incoming_number`, `incoming_date` )
- VALUES ('{$row->id}', '{$ownerId}', '{$shared}', '{$groupId}', '{$version}', '{$updated}', '{$name}', '{$externalCode}', '{$moment}', '{$applicable}', '{$rateId}', '{$sum}', '{$storeId}', '{$agencyId}', '{$organizationId}', '{$created}', '{$vatEnabled}', '{$vatSum}', '{$paymentPlannedMoment}', '{$payedSum}', '{$shippedSum}', '{$projectId}', '{$incomingNumber}', '{$incomingDate}');
- ";
- $this->makeYiiOperation($sql);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateInvoicesPositionsArrayTable($invoiceId, $positionsHref)
- {
- $dataDecoded = json_decode($this->curlPost($positionsHref, $this->username, $this->password));
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($dataDecoded->rows as $row) {
- $this->updateInvoicesPositionsTable($row);
- $sql = "
- INSERT INTO `{$this->positionsInvoicesArrayTable}` (`positions_array_id`, `position_id`)
- VALUES ('{$invoiceId}', '{$row->id}');
- ";
- $this->makeYiiOperation($sql);
- }
- }
- }
- return true;
- }
- private function updateInvoicesPositionsTable($row)
- {
- $dataAssortmentDecoded = json_decode($this->curlPost($row->assortment->meta->href, $this->username, $this->password));
- if (!empty($row->quantity)) $quantity = $row->quantity; else $quantity = null;
- if (!empty($dataAssortmentDecoded->id)) $assortmentId = $dataAssortmentDecoded->id; else $assortmentId = null;
- if (!empty($row->price)) $price = $row->price; else $price = null;
- if (!empty($row->discount)) $discount = $row->discount; else $discount = null;
- if (!empty($row->vat)) $vat = $row->vat; else $vat = null;
- $sql = "
- INSERT INTO `{$this->positionsInvoicesTable}` (`position_id`, `quantity`, `price`, `discount`, `vat`, `assortment_id`)
- VALUES ('{$row->id}', '{$quantity}', '{$price}', '{$discount}', '{$vat}', '{$assortmentId}' );
- ";
- $this->makeYiiOperation($sql);
- }
- private function updatePaymentInTable()
- {
- $method = "entity/paymentin";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- $dataOwnerDecoded = json_decode($this->curlPost($row->owner->meta->href, $this->username, $this->password));
- $dataAgencyDecoded = json_decode($this->curlPost($row->agent->meta->href, $this->username, $this->password));
- $dataOrganizationDecoded = json_decode($this->curlPost($row->organization->meta->href, $this->username, $this->password));
- $dataRateDecoded = json_decode($this->curlPost($row->rate->currency->meta->href, $this->username, $this->password));
- if (!empty($dataOwnerDecoded->id)) $ownerId = $dataOwnerDecoded->id; else $ownerId = null;
- if (!empty($dataAgencyDecoded->id)) $agencyId = $dataAgencyDecoded->id; else $agencyId = null;
- if (!empty($dataOrganizationDecoded->id)) $organizationId = $dataOrganizationDecoded->id; else $organizationId = null;
- if (!empty($dataRateDecoded->code)) $rateId = $dataRateDecoded->code; else $rateId = null;
- if (!empty($row->version)) $version = $row->version; else $version = null;
- if (!empty($row->updated)) $updated = $row->updated; else $updated = null;
- if (!empty($row->deleted)) $deleted = $row->deleted; else $deleted = null;
- if (!empty($row->name)) $name = $row->name; else $name = null;
- if (!empty($row->description)) $description = $row->description; else $description = null;
- if (!empty($row->externalCode)) $externalCode = $row->externalCode; else $externalCode = null;
- if (!empty($row->moment)) $moment = $row->moment; else $moment = null;
- if (!empty($row->sum)) $sum = $row->sum; else $sum = null;
- if (!empty($row->created)) $created = $row->created; else $created = null;
- if (!empty($row->paymentPurpose)) $paymentPurpose = $row->paymentPurpose; else $paymentPurpose = null;
- if (!empty($row->vatSum)) $vatSum = $row->vatSum; else $vatSum = null;
- if (!empty($row->incomingDate)) $incomingDate = $row->incomingDate; else $incomingDate = null;
- if (!empty($row->incomingNumber)) $incomingNumber = $row->incomingNumber; else $incomingNumber = null;
- $groupId = $this->getGroupId($row->group->meta->href);
- $applicable = $this->checkIfApplicable($row);
- $shared = $this->checkIfShared($row);
- $sql = "
- INSERT INTO `{$this->paymentInTable}` (`payment_in_id`, `version`, `updated`, `deleted`, `name`, `description`, `external_code`, `moment`, `applicable`, `sum`, `rate`, `owner_id`, `shared`, `group_id`, `organization_id`, `agent_id`, `created`, `payment_purpose`, `vat_sum`, `incoming_date`, `incoming_number`)
- VALUES ('{$row->id}', '{$version}', '{$updated}', '{$deleted}', '{$name}', '{$description}', '{$externalCode}', '{$moment}', '{$applicable}', '{$sum}', '{$rateId}', '{$ownerId}', '{$shared}', '{$groupId}', '{$organizationId}', '{$agencyId}', '{$created}', '{$paymentPurpose}', '{$vatSum}', '{$incomingDate}', '{$incomingNumber}');
- ";
- $this->makeYiiOperation($sql);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updatePaymentOutTable()
- {
- $method = "entity/paymentout";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- $dataOwnerDecoded = json_decode($this->curlPost($row->owner->meta->href, $this->username, $this->password));
- $dataAgencyDecoded = json_decode($this->curlPost($row->agent->meta->href, $this->username, $this->password));
- $dataOrganizationDecoded = json_decode($this->curlPost($row->organization->meta->href, $this->username, $this->password));
- $dataRateDecoded = json_decode($this->curlPost($row->rate->currency->meta->href, $this->username, $this->password));
- $dataExpenseItemDecoded = json_decode($this->curlPost($row->expenseItem->meta->href, $this->username, $this->password));
- if (!empty($dataOwnerDecoded->id)) $ownerId = $dataOwnerDecoded->id; else $ownerId = null;
- if (!empty($dataAgencyDecoded->id)) $agencyId = $dataAgencyDecoded->id; else $agencyId = null;
- if (!empty($dataOrganizationDecoded->id)) $organizationId = $dataOrganizationDecoded->id; else $organizationId = null;
- if (!empty($dataRateDecoded->code)) $rateId = $dataRateDecoded->code; else $rateId = null;
- if (!empty($dataExpenseItemDecoded->id)) $expenseItemId = $dataExpenseItemDecoded->id; else $expenseItemId = null;
- if (!empty($row->version)) $version = $row->version; else $version = null;
- if (!empty($row->updated)) $updated = $row->updated; else $updated = null;
- if (!empty($row->deleted)) $deleted = $row->deleted; else $deleted = null;
- if (!empty($row->name)) $name = $row->name; else $name = null;
- if (!empty($row->description)) $description = $row->description; else $description = null;
- if (!empty($row->externalCode)) $externalCode = $row->externalCode; else $externalCode = null;
- if (!empty($row->moment)) $moment = $row->moment; else $moment = null;
- if (!empty($row->sum)) $sum = $row->sum; else $sum = null;
- if (!empty($row->created)) $created = $row->created; else $created = null;
- if (!empty($row->paymentPurpose)) $paymentPurpose = $row->paymentPurpose; else $paymentPurpose = null;
- if (!empty($row->vatSum)) $vatSum = $row->vatSum; else $vatSum = null;
- $groupId = $this->getGroupId($row->group->meta->href);
- $applicable = $this->checkIfApplicable($row);
- $shared = $this->checkIfShared($row);
- $sql = "
- INSERT INTO `{$this->paymentOutTable}` (`payment_in_id`, `version`, `updated`, `deleted`, `name`, `description`, `external_code`, `moment`, `applicable`, `sum`, `rate`, `owner_id`, `shared`, `group_id`, `organization_id`, `agent_id`, `created`, `payment_purpose`, `vat_sum`, `expense_item_id`)
- VALUES ('{$row->id}', '{$version}', '{$updated}', '{$deleted}', '{$name}', '{$description}', '{$externalCode}', '{$moment}', '{$applicable}', '{$sum}', '{$rateId}', '{$ownerId}', '{$shared}', '{$groupId}', '{$organizationId}', '{$agencyId}', '{$created}', '{$paymentPurpose}', '{$vatSum}', '{$expenseItemId}');
- ";
- $this->makeYiiOperation($sql);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateCashInTable()
- {
- $method = "entity/cashin";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- $dataOwnerDecoded = json_decode($this->curlPost($row->owner->meta->href, $this->username, $this->password));
- $dataAgencyDecoded = json_decode($this->curlPost($row->agent->meta->href, $this->username, $this->password));
- $dataOrganizationDecoded = json_decode($this->curlPost($row->organization->meta->href, $this->username, $this->password));
- $dataRateDecoded = json_decode($this->curlPost($row->rate->currency->meta->href, $this->username, $this->password));
- if (!empty($dataOwnerDecoded->id)) $ownerId = $dataOwnerDecoded->id; else $ownerId = null;
- if (!empty($dataAgencyDecoded->id)) $agencyId = $dataAgencyDecoded->id; else $agencyId = null;
- if (!empty($dataOrganizationDecoded->id)) $organizationId = $dataOrganizationDecoded->id; else $organizationId = null;
- if (!empty($dataRateDecoded->code)) $rateId = $dataRateDecoded->code; else $rateId = null;
- if (!empty($row->version)) $version = $row->version; else $version = null;
- if (!empty($row->updated)) $updated = $row->updated; else $updated = null;
- if (!empty($row->deleted)) $deleted = $row->deleted; else $deleted = null;
- if (!empty($row->name)) $name = $row->name; else $name = null;
- if (!empty($row->description)) $description = $row->description; else $description = null;
- if (!empty($row->externalCode)) $externalCode = $row->externalCode; else $externalCode = null;
- if (!empty($row->moment)) $moment = $row->moment; else $moment = null;
- if (!empty($row->sum)) $sum = $row->sum; else $sum = null;
- if (!empty($row->created)) $created = $row->created; else $created = null;
- if (!empty($row->paymentPurpose)) $paymentPurpose = $row->paymentPurpose; else $paymentPurpose = null;
- if (!empty($row->vatSum)) $vatSum = $row->vatSum; else $vatSum = null;
- if (!empty($row->incomingDate)) $incomingDate = $row->incomingDate; else $incomingDate = null;
- if (!empty($row->incomingNumber)) $incomingNumber = $row->incomingNumber; else $incomingNumber = null;
- $groupId = $this->getGroupId($row->group->meta->href);
- $applicable = $this->checkIfApplicable($row);
- $shared = $this->checkIfShared($row);
- $sql = "
- INSERT INTO `{$this->cashInTable}` (`cash_in_id`, `version`, `updated`, `deleted`, `name`, `description`, `external_code`, `moment`, `applicable`, `sum`, `rate`, `owner_id`, `shared`, `group_id`, `organization_id`, `agent_id`, `created`, `payment_purpose`, `vat_sum`, `incoming_date`, `incoming_number`)
- VALUES ('{$row->id}', '{$version}', '{$updated}', '{$deleted}', '{$name}', '{$description}', '{$externalCode}', '{$moment}', '{$applicable}', '{$sum}', '{$rateId}', '{$ownerId}', '{$shared}', '{$groupId}', '{$organizationId}', '{$agencyId}', '{$created}', '{$paymentPurpose}', '{$vatSum}', '{$incomingDate}', '{$incomingNumber}');
- ";
- $this->makeYiiOperation($sql);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateCashOutTable()
- {
- $method = "entity/cashout";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- $dataOwnerDecoded = json_decode($this->curlPost($row->owner->meta->href, $this->username, $this->password));
- $dataAgencyDecoded = json_decode($this->curlPost($row->agent->meta->href, $this->username, $this->password));
- $dataOrganizationDecoded = json_decode($this->curlPost($row->organization->meta->href, $this->username, $this->password));
- $dataRateDecoded = json_decode($this->curlPost($row->rate->currency->meta->href, $this->username, $this->password));
- $dataExpenseItemDecoded = json_decode($this->curlPost($row->expenseItem->meta->href, $this->username, $this->password));
- if (!empty($dataOwnerDecoded->id)) $ownerId = $dataOwnerDecoded->id; else $ownerId = null;
- if (!empty($dataAgencyDecoded->id)) $agencyId = $dataAgencyDecoded->id; else $agencyId = null;
- if (!empty($dataOrganizationDecoded->id)) $organizationId = $dataOrganizationDecoded->id; else $organizationId = null;
- if (!empty($dataRateDecoded->code)) $rateId = $dataRateDecoded->code; else $rateId = null;
- if (!empty($dataExpenseItemDecoded->id)) $expenseItemId = $dataExpenseItemDecoded->id; else $expenseItemId = null;
- if (!empty($row->version)) $version = $row->version; else $version = null;
- if (!empty($row->updated)) $updated = $row->updated; else $updated = null;
- if (!empty($row->deleted)) $deleted = $row->deleted; else $deleted = null;
- if (!empty($row->name)) $name = $row->name; else $name = null;
- if (!empty($row->description)) $description = $row->description; else $description = null;
- if (!empty($row->externalCode)) $externalCode = $row->externalCode; else $externalCode = null;
- if (!empty($row->moment)) $moment = $row->moment; else $moment = null;
- if (!empty($row->sum)) $sum = $row->sum; else $sum = null;
- if (!empty($row->created)) $created = $row->created; else $created = null;
- if (!empty($row->paymentPurpose)) $paymentPurpose = $row->paymentPurpose; else $paymentPurpose = null;
- if (!empty($row->vatSum)) $vatSum = $row->vatSum; else $vatSum = null;
- $groupId = $this->getGroupId($row->group->meta->href);
- $applicable = $this->checkIfApplicable($row);
- $shared = $this->checkIfShared($row);
- $sql = "
- INSERT INTO `{$this->cashOutTable}` (`cash_out_id`, `version`, `updated`, `deleted`, `name`, `description`, `external_code`, `moment`, `applicable`, `sum`, `rate`, `owner_id`, `shared`, `group_id`, `organization_id`, `agent_id`, `created`, `payment_purpose`, `vat_sum`, `expense_item_id`)
- VALUES ('{$row->id}', '{$version}', '{$updated}', '{$deleted}', '{$name}', '{$description}', '{$externalCode}', '{$moment}', '{$applicable}', '{$sum}', '{$rateId}', '{$ownerId}', '{$shared}', '{$groupId}', '{$organizationId}', '{$agencyId}', '{$created}', '{$paymentPurpose}', '{$vatSum}', '{$expenseItemId}');
- ";
- $this->makeYiiOperation($sql);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateDemandTable()
- {
- $method = "entity/demand";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- $demandId = $row->id;
- $dataOwnerDecoded = json_decode($this->curlPost($row->owner->meta->href, $this->username, $this->password));
- $dataAgencyDecoded = json_decode($this->curlPost($row->agent->meta->href, $this->username, $this->password));
- $dataOrganizationDecoded = json_decode($this->curlPost($row->organization->meta->href, $this->username, $this->password));
- $dataRateDecoded = json_decode($this->curlPost($row->rate->currency->meta->href, $this->username, $this->password));
- $dataStoreDecoded = json_decode($this->curlPost($row->store->meta->href, $this->username, $this->password));
- if (!empty($dataOwnerDecoded->id)) $ownerId = $dataOwnerDecoded->id; else $ownerId = null;
- if (!empty($dataAgencyDecoded->id)) $agencyId = $dataAgencyDecoded->id; else $agencyId = null;
- if (!empty($dataOrganizationDecoded->id)) $organizationId = $dataOrganizationDecoded->id; else $organizationId = null;
- if (!empty($dataStoreDecoded->id)) $storeId = $dataStoreDecoded->id; else $storeId = null;
- if (!empty($dataRateDecoded->code)) $rateId = $dataRateDecoded->code; else $rateId = null;
- if (!empty($row->version)) $version = $row->version; else $version = null;
- if (!empty($row->updated)) $updated = $row->updated; else $updated = null;
- if (!empty($row->name)) $name = $row->name; else $name = null;
- if (!empty($row->description)) $description = $row->name; else $description = null;
- if (!empty($row->externalCode)) $externalCode = $row->externalCode; else $externalCode = null;
- if (!empty($row->moment)) $moment = $row->moment; else $moment = null;
- if (!empty($row->sum)) $sum = $row->sum; else $sum = null;
- if (!empty($row->created)) $created = $row->created; else $created = null;
- $groupId = $this->getGroupId($row->group->meta->href);
- $applicable = $this->checkIfApplicable($row);
- $shared = $this->checkIfShared($row);
- $positionsHref = $row->positions->meta->href;
- $vatEnabled = $this->checkIfVatEnable($row);
- $this->updateDemandsPositionsArrayTable($demandId, $positionsHref);
- $sql = "
- INSERT INTO `{$this->demandTable}` (`demand_id`, `owner_id`, `shared`, `group_id`, `version`, `updated`, `name`, `description`, `external_code`, `moment`, `applicable`, `vat_enabled`, `rate`, `sum`, `store_id`, `agent_id`, `organization_id`, `created`)
- VALUES ('{$demandId}', '{$ownerId}', '{$shared}', '{$groupId}', '{$version}', '{$updated}', '{$name}', '{$description}', '{$externalCode}', '{$moment}', '{$applicable}', '{$vatEnabled}', '{$rateId}', '{$sum}', '{$storeId}', '{$agencyId}', '{$organizationId}', '{$created}');
- ";
- $this->makeYiiOperation($sql);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateDemandsPositionsArrayTable($demandId, $positionsHref)
- {
- $dataDecoded = json_decode($this->curlPost($positionsHref, $this->username, $this->password));
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($dataDecoded->rows as $row) {
- $this->updateDemandPositionsTable($row);
- $sql = "
- INSERT INTO `{$this->positionsDemandsArrayTable}` (`positions_array_id`, `position_id`)
- VALUES ('{$demandId}', '{$row->id}');
- ";
- $this->makeYiiOperation($sql);
- }
- }
- }
- return true;
- }
- private function updateDemandPositionsTable($row)
- {
- $dataAssortmentDecoded = json_decode($this->curlPost($row->assortment->meta->href, $this->username, $this->password));
- if (!empty($row->quantity)) $quantity = $row->quantity; else $quantity = null;
- if (!empty($dataAssortmentDecoded->id)) $assortmentId = $dataAssortmentDecoded->id; else $assortmentId = null;
- if (!empty($row->price)) $price = $row->price; else $price = null;
- if (!empty($row->discount)) $discount = $row->discount; else $discount = null;
- if (!empty($row->vat)) $vat = $row->vat; else $vat = null;
- if (!empty($row->cost)) $cost = $row->cost; else $cost = null;
- $sql = "
- INSERT INTO `{$this->positionsDemandTable}` (`position_id`, `quantity`, `price`, `discount`, `vat`, `assortment_id`, `cost`)
- VALUES ('{$row->id}', '{$quantity}', '{$price}', '{$discount}', '{$vat}', '{$assortmentId}', '{$cost}' );
- ";
- $this->makeYiiOperation($sql);
- }
- private function updateSupplyTable()
- {
- $method = "entity/supply";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- $supplyId = $row->id;
- $dataOwnerDecoded = json_decode($this->curlPost($row->owner->meta->href, $this->username, $this->password));
- $dataAgencyDecoded = json_decode($this->curlPost($row->agent->meta->href, $this->username, $this->password));
- $dataOrganizationDecoded = json_decode($this->curlPost($row->organization->meta->href, $this->username, $this->password));
- $dataRateDecoded = json_decode($this->curlPost($row->rate->currency->meta->href, $this->username, $this->password));
- $dataStoreDecoded = json_decode($this->curlPost($row->store->meta->href, $this->username, $this->password));
- if (!empty($dataOwnerDecoded->id)) $ownerId = $dataOwnerDecoded->id; else $ownerId = null;
- if (!empty($dataAgencyDecoded->id)) $agencyId = $dataAgencyDecoded->id; else $agencyId = null;
- if (!empty($dataOrganizationDecoded->id)) $organizationId = $dataOrganizationDecoded->id; else $organizationId = null;
- if (!empty($dataStoreDecoded->id)) $storeId = $dataStoreDecoded->id; else $storeId = null;
- if (!empty($dataRateDecoded->code)) $rateId = $dataRateDecoded->code; else $rateId = null;
- if (!empty($row->version)) $version = $row->version; else $version = null;
- if (!empty($row->updated)) $updated = $row->updated; else $updated = null;
- if (!empty($row->name)) $name = $row->name; else $name = null;
- if (!empty($row->description)) $description = $row->name; else $description = null;
- if (!empty($row->externalCode)) $externalCode = $row->externalCode; else $externalCode = null;
- if (!empty($row->moment)) $moment = $row->moment; else $moment = null;
- if (!empty($row->sum)) $sum = $row->sum; else $sum = null;
- if (!empty($row->created)) $created = $row->created; else $created = null;
- $groupId = $this->getGroupId($row->group->meta->href);
- $applicable = $this->checkIfApplicable($row);
- $shared = $this->checkIfShared($row);
- $positionsHref = $row->positions->meta->href;
- $vatEnabled = $this->checkIfVatEnable($row);
- $this->updateSupplyPositionsArrayTable($supplyId, $positionsHref);
- $sql = "
- INSERT INTO `{$this->supplyTable}` (`demand_id`, `owner_id`, `shared`, `group_id`, `version`, `updated`, `name`, `description`, `external_code`, `moment`, `applicable`, `vat_enabled`, `rate`, `sum`, `store_id`, `agent_id`, `organization_id`, `created`)
- VALUES ('{$supplyId}', '{$ownerId}', '{$shared}', '{$groupId}', '{$version}', '{$updated}', '{$name}', '{$description}', '{$externalCode}', '{$moment}', '{$applicable}', '{$vatEnabled}', '{$rateId}', '{$sum}', '{$storeId}', '{$agencyId}', '{$organizationId}', '{$created}');
- ";
- $this->makeYiiOperation($sql);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateSupplyPositionsArrayTable($supplyId, $positionsHref)
- {
- $dataDecoded = json_decode($this->curlPost($positionsHref, $this->username, $this->password));
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($dataDecoded->rows as $row) {
- $this->updateSupplyPositionsTable($row);
- $sql = "
- INSERT INTO `{$this->positionsSuppliesArrayTable}` (`positions_array_id`, `position_id`)
- VALUES ('{$supplyId}', '{$row->id}');
- ";
- $this->makeYiiOperation($sql);
- }
- }
- }
- return true;
- }
- private function updateSupplyPositionsTable($row)
- {
- $dataAssortmentDecoded = json_decode($this->curlPost($row->assortment->meta->href, $this->username, $this->password));
- $dataCountryDecoded = json_decode($this->curlPost($row->country->meta->href, $this->username, $this->password));
- if (!empty($row->quantity)) $quantity = $row->quantity; else $quantity = null;
- if (!empty($dataAssortmentDecoded->id)) $assortmentId = $dataAssortmentDecoded->id; else $assortmentId = null;
- if (!empty($dataCountryDecoded->id)) $countryId = $dataCountryDecoded->id; else $countryId = null;
- if (!empty($row->price)) $price = $row->price; else $price = null;
- if (!empty($row->discount)) $discount = $row->discount; else $discount = null;
- if (!empty($row->vat)) $vat = $row->vat; else $vat = null;
- if (!empty($row->gtd)) $gtd = $row->gtd; else $gtd = null;
- $sql = "
- INSERT INTO `{$this->positionsSupplyTable}` (`position_id`, `quantity`, `price`, `discount`, `vat`, `assortment_id`, `gtd`, `country_id`)
- VALUES ('{$row->id}', '{$quantity}', '{$price}', '{$discount}', '{$vat}', '{$assortmentId}', '{$gtd}', '{$countryId}');
- ";
- $this->makeYiiOperation($sql);
- }
- private function updateLossTable()
- {
- $method = "entity/loss";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- $lossId = $row->id;
- $dataOwnerDecoded = json_decode($this->curlPost($row->owner->meta->href, $this->username, $this->password));
- $dataOrganizationDecoded = json_decode($this->curlPost($row->organization->meta->href, $this->username, $this->password));
- $dataRateDecoded = json_decode($this->curlPost($row->rate->currency->meta->href, $this->username, $this->password));
- $dataStoreDecoded = json_decode($this->curlPost($row->store->meta->href, $this->username, $this->password));
- $dataProject = json_decode($this->curlPost($row->project->meta->href, $this->username, $this->password));
- if (!empty($dataOwnerDecoded->id)) $ownerId = $dataOwnerDecoded->id; else $ownerId = null;
- if (!empty($dataProject->id)) $projectId = $dataProject->id; else $projectId = null;
- if (!empty($dataOrganizationDecoded->id)) $organizationId = $dataOrganizationDecoded->id; else $organizationId = null;
- if (!empty($dataStoreDecoded->id)) $storeId = $dataStoreDecoded->id; else $storeId = null;
- if (!empty($dataRateDecoded->code)) $rateId = $dataRateDecoded->code; else $rateId = null;
- if (!empty($row->version)) $version = $row->version; else $version = null;
- if (!empty($row->updated)) $updated = $row->updated; else $updated = null;
- if (!empty($row->deleted)) $deleted = $row->deleted; else $deleted = null;
- if (!empty($row->name)) $name = $row->name; else $name = null;
- if (!empty($row->description)) $description = $row->name; else $description = null;
- if (!empty($row->externalCode)) $externalCode = $row->externalCode; else $externalCode = null;
- if (!empty($row->moment)) $moment = $row->moment; else $moment = null;
- if (!empty($row->sum)) $sum = $row->sum; else $sum = null;
- if (!empty($row->created)) $created = $row->created; else $created = null;
- $groupId = $this->getGroupId($row->group->meta->href);
- $applicable = $this->checkIfApplicable($row);
- $shared = $this->checkIfShared($row);
- $positionsHref = $row->positions->meta->href;
- $this->updateLossPositionsArrayTable($lossId, $positionsHref);
- $sql = "
- INSERT INTO `{$this->lossTable}` (`loss_id`, `version`, `updated`, `deleted`, `name`, `description`, `external_code`, `moment`, `applicable`, `sum`, `rate`, `owner_id`, `shared`, `group_id`, `organization_id`, `store_id`, `project_id`, `created`)
- VALUES ('{$lossId}', '{$version}', '{$updated}', '{$deleted}', '{$name}', '{$description}', '{$externalCode}', '{$moment}', '{$applicable}', '{$sum}', '{$rateId}', '{$ownerId}', '{$shared}', '{$groupId}', '{$organizationId}', '{$storeId}', '{$projectId}', '{$created}');
- ";
- $this->makeYiiOperation($sql);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateLossPositionsArrayTable($lossId, $positionsHref)
- {
- $dataDecoded = json_decode($this->curlPost($positionsHref, $this->username, $this->password));
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($dataDecoded->rows as $row) {
- $this->updateLossPositionsTable($row);
- $sql = "
- INSERT INTO `{$this->positionsLossArrayTable}` (`positions_array_id`, `position_id`)
- VALUES ('{$lossId}', '{$row->id}');
- ";
- $this->makeYiiOperation($sql);
- }
- }
- }
- return true;
- }
- private function updateLossPositionsTable($row)
- {
- $dataAssortmentDecoded = json_decode($this->curlPost($row->assortment->meta->href, $this->username, $this->password));
- if (!empty($row->quantity)) $quantity = $row->quantity; else $quantity = null;
- if (!empty($dataAssortmentDecoded->id)) $assortmentId = $dataAssortmentDecoded->id; else $assortmentId = null;
- if (!empty($row->price)) $price = $row->price; else $price = null;
- if (!empty($row->reason)) $reason = $row->reason; else $reason = null;
- $sql = "
- INSERT INTO `{$this->positionsLossTable}` (`position_id`, `quantity`, `price`, `assortment_id`, `reason`)
- VALUES ('{$row->id}', '{$quantity}', '{$price}', '{$assortmentId}', '{$reason}');
- ";
- $this->makeYiiOperation($sql);
- }
- private function updateMoveTable()
- {
- $method = "entity/move";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- $dataOwnerDecoded = json_decode($this->curlPost($row->{'owner'}->{'meta'}->{'href'}, $this->username, $this->password));
- $dataGroupDecoded = json_decode($this->curlPost($row->{'group'}->{'meta'}->{'href'}, $this->username, $this->password));
- $dataPositionsDecoded = json_decode($this->curlPost($row->{'positions'}->{'meta'}->{'href'}, $this->username, $this->password));
- $dataSourceStoreDecoded = json_decode($this->curlPost($row->{'sourceStore'}->{'meta'}->{'href'}, $this->username, $this->password));
- $dataTargetStoreDecoded = json_decode($this->curlPost($row->{'targetStore'}->{'meta'}->{'href'}, $this->username, $this->password));
- if (!empty($dataOwnerDecoded->{'sum'})) $sum = $row->{'sum'}; else $sum = null;
- if (!empty($dataOwnerDecoded->{'vatSum'})) $vatSum = $row->{'vatSum'}; else $vatSum = null;
- if (!empty($dataPositionsDecoded->{'quantity'})) $quantity = $dataPositionsDecoded->{'quantity'}; else $quantity = null;
- if (!empty($dataPositionsDecoded->{'price'})) $price = $dataPositionsDecoded->{'price'}; else $price = null;
- if (!empty($dataPositionsDecoded->{'discount'})) $discount = $dataPositionsDecoded->{'discount'}; else $discount = null;
- $sql = "
- INSERT INTO `{$this->moveTable}` (`login`, `move_id`, `name`, `sum`, `owner_name`, `owner_email`, `owner_phone`, `owner_sum`, `owner_vat_sum`, `group_name`, `position_quantity`, `position_price`, `position_discount`, `source_store_name`, `target_store_name`)
- VALUES ('{$this->login}', '{$row->{'id'}}', '{$row->{'name'}}', '{$row->{'sum'}}', '{$dataOwnerDecoded->{'name'}}', '{$dataOwnerDecoded->{'email'}}', '{$dataOwnerDecoded->{'phone'}}', '{$sum}', '{$vatSum}', '{$dataGroupDecoded->{'name'}}', '{$quantity}', '{$price}', '{$discount}', '{$dataSourceStoreDecoded->{'name'}}', '{$dataTargetStoreDecoded->{'name'}}');
- ";
- $this->makeYiiOperation($sql);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateRetaildemandTable()
- {
- $method = "entity/retaildemand";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- var_dump($row);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateRetailsalesreturnTable()
- {
- $method = "entity/retailsalesreturn";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- var_dump($row);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateRetaildrawerCashInTable()
- {
- $method = "entity/retaildrawercashin";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- var_dump($row);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateRetaildrawerCashOutTable()
- {
- $method = "entity/retaildrawercashout";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- var_dump($row);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateSalesReturnTable()
- {
- $method = "entity/salesreturn";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- var_dump($row);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updatePurchasereturn()
- {
- $method = "entity/purchasereturn";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- var_dump($row);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateFactureout()
- {
- $method = "entity/factureout";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- var_dump($row);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateFacturein()
- {
- $method = "entity/facturein";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- var_dump($row);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateInventoryTable()
- {
- $method = "entity/inventory";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- $dataOwnerDecoded = json_decode($this->curlPost($row->{'owner'}->{'meta'}->{'href'}, $this->username, $this->password));
- $dataGroupDecoded = json_decode($this->curlPost($row->{'group'}->{'meta'}->{'href'}, $this->username, $this->password));
- $dataStoreDecoded = json_decode($this->curlPost($row->{'store'}->{'meta'}->{'href'}, $this->username, $this->password));
- $dataPositionsDecoded = json_decode($this->curlPost($row->{'positions'}->{'meta'}->{'href'}, $this->username, $this->password));
- if (!empty($dataOwnerDecoded->{'sum'})) $sum = $row->{'sum'}; else $sum = null;
- if (!empty($dataOwnerDecoded->{'vatSum'})) $vatSum = $row->{'vatSum'}; else $vatSum = null;
- if (!empty($dataPositionsDecoded->{'quantity'})) $quantity = $dataPositionsDecoded->{'quantity'}; else $quantity = null;
- if (!empty($dataPositionsDecoded->{'price'})) $price = $dataPositionsDecoded->{'price'}; else $price = null;
- if (!empty($dataPositionsDecoded->{'discount'})) $discount = $dataPositionsDecoded->{'discount'}; else $discount = null;
- $sql = "
- INSERT INTO `{$this->inventoryTable}` (`login`, `inventory_id`, `name`, `sum`, `owner_name`, `owner_email`, `owner_phone`, `owner_sum`, `owner_vat_sum`, `group_name`, `store_name`, `position_quantity`, `position_price`, `position_discount`)
- VALUES ('{$this->login}', '{$row->{'id'}}', '{$row->{'name'}}', '{$row->{'sum'}}', '{$dataOwnerDecoded->{'name'}}', '{$dataOwnerDecoded->{'email'}}', '{$dataOwnerDecoded->{'phone'}}', '{$sum}', '{$vatSum}', '{$dataGroupDecoded->{'name'}}', '{$dataStoreDecoded->{'name'}}', '{$quantity}', '{$price}', '{$discount}');
- ";
- $this->makeYiiOperation($sql);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateCommissionreportin()
- {
- $method = "entity/commissionreportin";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- var_dump($row);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateCommissionreportout()
- {
- $method = "entity/commissionreportout";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- var_dump($row);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updatePricelist()
- {
- $method = "entity/pricelist";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- var_dump($row);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateProcessingplan()
- {
- $method = "entity/processingplan";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- var_dump($row);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateProcessingOrderTable()
- {
- $method = "entity/processingorder";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- $dataOwnerDecoded = json_decode($this->curlPost($row->{'owner'}->{'meta'}->{'href'}, $this->username, $this->password));
- $dataGroupDecoded = json_decode($this->curlPost($row->{'group'}->{'meta'}->{'href'}, $this->username, $this->password));
- if (!empty($dataOwnerDecoded->{'sum'})) $sum = $row->{'sum'}; else $sum = null;
- if (!empty($dataOwnerDecoded->{'vatSum'})) $vatSum = $row->{'vatSum'}; else $vatSum = null;
- $sql = "
- INSERT INTO `{$this->processingOrderTable}` (`login`, `processing_order_id`, `name`, `quantity`, `owner_name`, `owner_email`, `owner_phone`, `owner_sum`, `owner_vat_sum`, `group_name`)
- VALUES ('{$this->login}', '{$row->{'id'}}', '{$row->{'name'}}', '{$row->{'quantity'}}', '{$dataOwnerDecoded->{'name'}}', '{$dataOwnerDecoded->{'email'}}', '{$dataOwnerDecoded->{'phone'}}', '{$sum}', '{$vatSum}', '{$dataGroupDecoded->{'name'}}');
- ";
- $this->makeYiiOperation($sql);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateProcessing()
- {
- $method = "entity/processing";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- var_dump($row);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateInternalorder()
- {
- $method = "entity/internalorder";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- var_dump($row);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateStockAllTable()
- {
- $method = "report/stock/all";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- $sql = "
- INSERT INTO `{$this->stockAllTable}` (`login`, `stock`, `in_transit`, `reserve`, `quantity`, `name`, `code`, `price`, `sale_price`)
- VALUES ('{$this->login}', '{$row->{'stock'}}', '{$row->{'inTransit'}}', '{$row->{'reserve'}}', '{$row->{'quantity'}}', '{$row->{'name'}}', '{$row->{'code'}}', '{$row->{'price'}}', '{$row->{'salePrice'}}');
- ";
- $this->makeYiiOperation($sql);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateStockBySort()
- {
- $method = "report/stock/bystore";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- var_dump($row);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateReportCounterparty()
- {
- $method = "report/counterparty";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- var_dump($row);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateReportDashboardDayTable()
- {
- $method = "/report/dashboard/day";
- $dataDecoded = json_decode($this->moySkladApi($method));
- if (!empty($dataDecoded)) {
- var_dump($dataDecoded->sales->count);
- return true;
- }
- return false;
- }
- private function updateReportDashboardWeekTable()
- {
- $method = "/report/dashboard/week";
- $dataDecoded = json_decode($this->moySkladApi($method));
- if (!empty($dataDecoded)) {
- var_dump($dataDecoded->sales->count);
- return true;
- }
- return false;
- }
- private function updateReportDashboardMonthTable()
- {
- $method = "/report/dashboard/month";
- $dataDecoded = json_decode($this->moySkladApi($method));
- if (!empty($dataDecoded)) {
- var_dump($dataDecoded->sales->count);
- return true;
- }
- return false;
- }
- private function updateAuditTable()
- {
- $method = "audit";
- $dataDecoded = $this->getAllRows($method, 100);
- if (!empty($dataDecoded)) {
- foreach ($dataDecoded as $paginationItem) {
- if (!empty($paginationItem)) {
- foreach ($paginationItem as $row) {
- var_dump($row->id);
- $sql = "
- INSERT INTO `{$this->auditTable}` (`login`, `audit_id`, `uid`)
- VALUES ('{$this->login}', '{$row->{'id'}}', '{$row->{'uid'}}');
- ";
- $this->makeYiiOperation($sql);
- }
- }
- }
- return true;
- }
- return false;
- }
- private function updateMonthTable()
- {
- $offset = 0;
- $method = "report/dashboard/month?limit={$this->limit}&offset={$offset}";
- $response = $this->moySkladApi($method);
- var_dump($response);
- $dataDecoded = json_decode($response);
- if (!empty($dataDecoded)) {
- $sql = "
- INSERT INTO `{$this->reportDashboardMonthTable}` (`login`, `sales_count`, `sales_amount`, `sales_movement_amount`, `orders_count`, `orders_amount`, `orders_movement_amount`, `income`, `outcome`, `balance`, `today_movement`, `movement`)
- VALUES ('{$this->login}', '{$dataDecoded->{'sales'}->{'count'}}', '{$dataDecoded->{'sales'}->{'amount'}}', '{$dataDecoded->{'sales'}->{'movementAmount'}}', '{$dataDecoded->{'orders'}->{'count'}}', '{$dataDecoded->{'orders'}->{'amount'}}', '{$dataDecoded->{'orders'}->{'movementAmount'}}', '{$dataDecoded->{'money'}->{'income'}}', '{$dataDecoded->{'money'}->{'outcome'}}', '{$dataDecoded->{'money'}->{'balance'}}', '{$dataDecoded->{'money'}->{'todayMovement'}}', '{$dataDecoded->{'money'}->{'movement'}}');
- ";
- $this->makeYiiOperation($sql);
- return true;
- }
- return false;
- }
- private function curlPost($url, $username, $password)
- {
- $curl = curl_init();
- curl_setopt($curl, CURLOPT_USERPWD, $username . ":" . $password);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($curl, CURLOPT_URL, $url);
- $result = curl_exec($curl);
- curl_close($curl);
- return $result;
- }
- private function moySkladApi($method)
- {
- $response = $this->curlPost("https://online.moysklad.ru/api/remap/1.1/{$method}", $this->username, $this->password);
- return $response;
- }
- private function getAllRows($method, $limit = 100)
- {
- $start = microtime(true);
- $this->makeSomeLogBitch($method);
- $offset = 0;
- $response = json_decode($this->moySkladApi("{$method}?limit=1&offset={$offset}"));
- $size = $response->meta->size;
- $iteration = ceil($size / $limit);
- $data = [];
- for ($i = 1; $i <= $iteration; $i++) {
- $response = json_decode($this->moySkladApi("{$method}?limit={$limit}&offset={$offset}"));
- $data[] = $response->rows;
- $offset += $limit;
- }
- var_dump($data);
- $time = microtime(true) - $start;
- printf("Выгрузка длилась %.4F сек.", $time);
- echo "\n";
- return $data;
- }
- private function makeAuth()
- {
- $method = "/report/dashboard/day";
- $dataDecoded = json_decode($this->moySkladApi($method));
- if ($dataDecoded->errors) {
- echo "Ошибка аутентификации: Неправильный пароль или имя пользователя";
- return false;
- } else {
- return true;
- }
- }
- private function checkIfArchived($row)
- {
- if ($row->archived) {
- $archived = "Заархивировано";
- } else {
- $archived = "Не в архиве";
- }
- return $archived;
- }
- private function checkIfShared($row)
- {
- if ($row->shared) {
- $shared = "Общий доступ";
- } else {
- $shared = "Приватный доступ";
- }
- return $shared;
- }
- private function checkIfApplicable($row)
- {
- if ($row->applicable) {
- $applicable = "Проведен";
- } else {
- $applicable = "Не проведен";
- }
- return $applicable;
- }
- private function checkIfEgaisEnable($row)
- {
- if ($row->shared) {
- $shared = "ЕГАИС включен";
- } else {
- $shared = "ЕГАИС выключен";
- }
- return $shared;
- }
- private function checkPayerVat($row)
- {
- if ($row->shared) {
- $shared = "Плательщик НДС";
- } else {
- $shared = "Не плательщик НДС";
- }
- return $shared;
- }
- private function checkIsDefault($row)
- {
- if ($row->isDefault) {
- $isDefault = "Основной счёт";
- } else {
- $isDefault = "Не основной счёт";
- }
- return $isDefault;
- }
- private function getCompanyType($row)
- {
- switch ($row->companyType) {
- case "legal":
- $companyType = "Юридическое лицо";
- break;
- case "entrepreneur":
- $companyType = "Индивидуальный предприниматель";
- break;
- case "individual":
- $companyType = "Физическое лицо";
- break;
- }
- return $companyType;
- }
- private function checkIfVatEnable($row)
- {
- if ($row->shared) {
- $shared = "НДС учитывается";
- } else {
- $shared = "НДС не учитывается";
- }
- return $shared;
- }
- private function getGroupId($group_id)
- {
- return substr($group_id, 54);
- }
- private function makeSomeLogBitch($method)
- {
- echo "Начинаем выгрузку-хуигрузку " . $method . "\n";
- }
- private function makeYiiOperation($sql)
- {
- // $command = \Yii::$app->mysklad_db->createCommand($sql);
- //
- // try {
- // $command->execute();
- // } catch (\yii\db\Exception $e) {
- // parent::log($e->getMessage());
- // }
- }
- private function createTable()
- {
- $sql = "
- CREATE TABLE IF NOT EXISTS `{$this->counterPartyTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `counter_party_id` varchar(255),
- `owner_id` varchar(255),
- `group_id` varchar(255),
- `shared` varchar(255),
- `version` varchar(255),
- `updated` varchar(255),
- `name` varchar(255),
- `description` varchar(255),
- `code` varchar(255),
- `external_code` varchar(255),
- `archived` varchar(255),
- `created` varchar(255),
- `email` varchar(255),
- `phone` varchar(255),
- `fax` varchar(255),
- `actual_address` varchar(255),
- `company_type` varchar(255),
- `legal_title` varchar(255),
- `legal_address` varchar(255),
- `inn` varchar(255),
- `kpp` varchar(255),
- `ogrn` varchar(255),
- `okpo` varchar(255),
- `ogrnip` varchar(255),
- `certificateNumber` varchar(255),
- `certificateDate` varchar(255),
- `discount_card_number` varchar(255),
- `state_type` varchar(255),
- `sales_amount` varchar(255)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->assortmentTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `assortment_id` varchar(255) NOT NULL,
- `owner_id` varchar(255) NOT NULL,
- `group_id` varchar(255) NOT NULL,
- `shared` varchar(255) NOT NULL,
- `version` text NOT NULL,
- `updated` text NOT NULL,
- `name` varchar(255) NOT NULL,
- `code` varchar(255) NOT NULL,
- `external_code` varchar(255) NOT NULL,
- `archived` text NOT NULL,
- `path_name` varchar(255) NOT NULL,
- `uom_id` varchar(255) NOT NULL,
- `min_price` varchar(255) NOT NULL,
- `weight` varchar(255) NOT NULL,
- `volume` varchar(255) NOT NULL,
- `is_serial_trackable` varchar(255) NOT NULL,
- `stock` varchar(255) NOT NULL,
- `reserve` varchar(255) NOT NULL,
- `in_transit` varchar(255) NOT NULL,
- `quantity` varchar(255) NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->currencyTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `code` varchar(255) NOT NULL,
- `name` varchar(255) NOT NULL,
- `full_name` varchar(255) NOT NULL,
- `iso_code` varchar(255) NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->productTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `product_id` varchar(255) NOT NULL,
- `owner_id` varchar(255) NOT NULL,
- `shared` varchar(255) NOT NULL,
- `group_id` varchar(255) NOT NULL,
- `version` varchar(255) NOT NULL,
- `updated` varchar(255) NOT NULL,
- `name` varchar(255) NOT NULL,
- `description` varchar(255) NOT NULL,
- `code` varchar(255) NOT NULL,
- `external_code` varchar(255) NOT NULL,
- `archived` varchar(255) NOT NULL,
- `path_name` varchar(255) NOT NULL,
- `vat` varchar(255) NOT NULL,
- `effective_vat` varchar(255) NOT NULL,
- `uom` varchar(255) NOT NULL,
- `min_price` varchar(255) NOT NULL,
- `buy_price` varchar(255) NOT NULL,
- `modifications_count` varchar(255) NOT NULL,
- `minimum_balance` varchar(255) NOT NULL,
- `is_serial_trackable` varchar(255) NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->positionsOrdersArrayTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `positions_array_id` varchar(255) NOT NULL,
- `position_id` text NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->positionsOrdersTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `position_id` varchar(255) NOT NULL,
- `quantity` varchar(255) NOT NULL,
- `price` varchar(255) NOT NULL,
- `discount` varchar(255) NOT NULL,
- `vat` varchar(255) NOT NULL,
- `assortment_id` varchar(255) NOT NULL,
- `shipped` varchar(255) NOT NULL,
- `reserve` varchar(255) NOT NULL,
- `wait` varchar(255) NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->customerOrdersTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `customer_order_id` varchar(255) NOT NULL,
- `owner_id` varchar(255) NOT NULL,
- `version` varchar(255) NOT NULL,
- `updated` varchar(255) NOT NULL,
- `deleted` varchar(255) NOT NULL,
- `name` varchar(255) NOT NULL,
- `description` varchar(255) NOT NULL,
- `external_code` varchar(255) NOT NULL,
- `moment` varchar(255) NOT NULL,
- `applicable` varchar(255) NOT NULL,
- `vat_enabled` varchar(255) NOT NULL,
- `sum` varchar(255) NOT NULL,
- `rate` varchar(255) NOT NULL,
- `shared` varchar(255) NOT NULL,
- `group_id` varchar(255) NOT NULL,
- `organization_id` varchar(255) NOT NULL,
- `agent_id` varchar(255) NOT NULL,
- `store_id` varchar(255) NOT NULL,
- `created` varchar(255) NOT NULL,
- `vat_sum` varchar(255) NOT NULL,
- `reserved_sum` varchar(255) NOT NULL,
- `delivery_planned_moment` varchar(255) NOT NULL,
- `payed_sum` varchar(255) NOT NULL,
- `shipped_sum` varchar(255) NOT NULL,
- `invoiced_sum` varchar(255) NOT NULL,
- `project_id` varchar(255) NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->positionsInvoicesArrayTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `positions_array_id` varchar(255) NOT NULL,
- `position_id` text NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->positionsInvoicesTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `position_id` varchar(255) NOT NULL,
- `quantity` text NOT NULL,
- `price` text NOT NULL,
- `discount` text NOT NULL,
- `vat` text NOT NULL,
- `assortment_id` text NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->invoiceOutTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `invoice_out_id` varchar(255) NOT NULL,
- `owner_id` varchar(255) NOT NULL,
- `shared` text NOT NULL,
- `group_id` varchar(255) NOT NULL,
- `version` varchar(255) NOT NULL,
- `updated` varchar(255) NOT NULL,
- `name` varchar(255) NOT NULL,
- `external_code` varchar(255) NOT NULL,
- `moment` varchar(255) NOT NULL,
- `applicable` varchar(255) NOT NULL,
- `rate` varchar(255) NOT NULL,
- `sum` varchar(255) NOT NULL,
- `store_id` varchar(255) NOT NULL,
- `agent_id` varchar(255) NOT NULL,
- `organization_id` varchar(255) NOT NULL,
- `created` varchar(255) NOT NULL,
- `vat_enabled` varchar(255) NOT NULL,
- `vat_sum` varchar(255) NOT NULL,
- `payment_planned_moment` varchar(255) NOT NULL,
- `payed_sum` varchar(255) NOT NULL,
- `shipped_sum` varchar(255) NOT NULL,
- `project_id` varchar(255) NOT NULL,
- `customer_order_id` varchar(255) NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->paymentInTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `payment_in_id` varchar(255) NOT NULL,
- `version` text NOT NULL,
- `updated` varchar(255) NOT NULL,
- `deleted` varchar(255) NOT NULL,
- `name` varchar(255) NOT NULL,
- `description` varchar(255) NOT NULL,
- `external_code` varchar(255) NOT NULL,
- `moment` varchar(255) NOT NULL,
- `applicable` varchar(255) NOT NULL,
- `sum` varchar(255) NOT NULL,
- `rate` varchar(255) NOT NULL,
- `owner_id` varchar(255) NOT NULL,
- `shared` varchar(255) NOT NULL,
- `group_id` varchar(255) NOT NULL,
- `organization_id` varchar(255) NOT NULL,
- `agent_id` varchar(255) NOT NULL,
- `created` varchar(255) NOT NULL,
- `payment_purpose` varchar(255) NOT NULL,
- `vat_sum` varchar(255) NOT NULL,
- `incoming_date` varchar(255) NOT NULL,
- `incoming_number` varchar(255) NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->paymentOutTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `payment_in_id` varchar(255) NOT NULL,
- `version` text NOT NULL,
- `updated` varchar(255) NOT NULL,
- `deleted` varchar(255) NOT NULL,
- `name` varchar(255) NOT NULL,
- `description` varchar(255) NOT NULL,
- `external_code` varchar(255) NOT NULL,
- `moment` varchar(255) NOT NULL,
- `applicable` varchar(255) NOT NULL,
- `sum` varchar(255) NOT NULL,
- `rate` varchar(255) NOT NULL,
- `owner_id` varchar(255) NOT NULL,
- `shared` varchar(255) NOT NULL,
- `group_id` varchar(255) NOT NULL,
- `organization_id` varchar(255) NOT NULL,
- `agent_id` varchar(255) NOT NULL,
- `created` varchar(255) NOT NULL,
- `payment_purpose` varchar(255) NOT NULL,
- `vat_sum` varchar(255) NOT NULL,
- `expense_item_id` varchar(255) NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->productFolderTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `product_folder_id` varchar(255) NOT NULL,
- `owner_id` varchar(255) NOT NULL,
- `shared` varchar(255) NOT NULL,
- `group_id` varchar(255) NOT NULL,
- `version` text NOT NULL,
- `updated` varchar(255) NOT NULL,
- `name` varchar(255) NOT NULL,
- `description` varchar(255) NOT NULL,
- `code` varchar(255) NOT NULL,
- `external_code` varchar(255) NOT NULL,
- `archived` varchar(255) NOT NULL,
- `path_name` varchar(255) NOT NULL,
- `vat` varchar(255) NOT NULL,
- `effective_vat` varchar(255) NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->projectTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `project_id` varchar(255) NOT NULL,
- `owner_id` varchar(255) NOT NULL,
- `shared` varchar(255) NOT NULL,
- `group_id` varchar(255) NOT NULL,
- `version` text NOT NULL,
- `updated` varchar(255) NOT NULL,
- `name` varchar(255) NOT NULL,
- `description` varchar(255) NOT NULL,
- `code` varchar(255) NOT NULL,
- `external_code` varchar(255) NOT NULL,
- `archived` varchar(255) NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->expenseItemTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `expense_item_id` varchar(255) NOT NULL,
- `version` varchar(255) NOT NULL,
- `updated` varchar(255) NOT NULL,
- `name` varchar(255) NOT NULL,
- `description` text NOT NULL,
- `code` varchar(255) NOT NULL,
- `external_code` varchar(255) NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->countriesTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `country_id` int(11) NOT NULL,
- `name` varchar(255) NOT NULL,
- `description` varchar(255) NOT NULL,
- `code` varchar(255) NOT NULL,
- `external_code` varchar(255) NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->groupsTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `login` varchar(255) NOT NULL,
- `name` text NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->uomTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `uom_id` int(11) NOT NULL,
- `version` int(11) NOT NULL,
- `updated` int(11) NOT NULL,
- `name` varchar(255) NOT NULL,
- `description` varchar(255) NOT NULL,
- `code` varchar(255) NOT NULL,
- `external_code` varchar(255) NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->employeesTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `employee_id` varchar(255) NOT NULL,
- `owner_id` varchar(255) NOT NULL,
- `group_id` varchar(255) NOT NULL,
- `shared` varchar(255) NOT NULL,
- `version` varchar(255) NOT NULL,
- `updated` varchar(255) NOT NULL,
- `external_code` varchar(255) NOT NULL,
- `archived` varchar(255) NOT NULL,
- `created` varchar(255) NOT NULL,
- `uid` varchar(255) NOT NULL,
- `email` varchar(255) NOT NULL,
- `phone` varchar(255) NOT NULL,
- `full_name` varchar(255) NOT NULL,
- `short_fio` varchar(255) NOT NULL,
- `cashier_id` varchar(255) NOT NULL,
- `retail_store_id` varchar(255) NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->storesTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `store_id` varchar(255) NOT NULL,
- `owner_id` text NOT NULL,
- `shared` text NOT NULL,
- `group_id` text NOT NULL,
- `version` text NOT NULL,
- `updated` text NOT NULL,
- `name` text NOT NULL,
- `description` text NOT NULL,
- `code` text NOT NULL,
- `external_code` text NOT NULL,
- `archived` varchar(255) NOT NULL,
- `address` varchar(255) NOT NULL,
- `parent` varchar(255) NOT NULL,
- `path_name` varchar(255) NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->organizationsTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `organisation_id` varchar(255) NOT NULL,
- `owner_id` varchar(255) NOT NULL,
- `shared` varchar(255) NOT NULL,
- `group_id` varchar(255) NOT NULL,
- `version` varchar(255) NOT NULL,
- `updated` varchar(255) NOT NULL,
- `name` varchar(255) NOT NULL,
- `description` varchar(255) NOT NULL,
- `code` varchar(255) NOT NULL,
- `external_code` varchar(255) NOT NULL,
- `archived` varchar(255) NOT NULL,
- `created` varchar(255) NOT NULL,
- `company_type` varchar(255) NOT NULL,
- `legal_title` varchar(255) NOT NULL,
- `legal_address` varchar(255) NOT NULL,
- `inn` varchar(255) NOT NULL,
- `kpp` varchar(255) NOT NULL,
- `ogrn` varchar(255) NOT NULL,
- `ogrnip` varchar(255) NOT NULL,
- `okpo` varchar(255) NOT NULL,
- `certificate_number` varchar(255) NOT NULL,
- `certificate_date` varchar(255) NOT NULL,
- `email` varchar(255) NOT NULL,
- `phone` varchar(255) NOT NULL,
- `fax` varchar(255) NOT NULL,
- `is_egais_enable` varchar(255) NOT NULL,
- `fsrar_id` varchar(255) NOT NULL,
- `payer_vat` varchar(255) NOT NULL,
- `utm_url` varchar(255) NOT NULL,
- `actual_address` varchar(255) NOT NULL,
- `director` varchar(255) NOT NULL,
- `chief_accountant` varchar(255) NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->accountsTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `account_id` varchar(255) NOT NULL,
- `organisation_id` varchar(255) NOT NULL,
- `version` text NOT NULL,
- `updated` varchar(255) NOT NULL,
- `is_default` varchar(255) NOT NULL,
- `account_number` varchar(255) NOT NULL,
- `bank_name` varchar(255) NOT NULL,
- `bank_location` varchar(255) NOT NULL,
- `correspondent_account` varchar(255) NOT NULL,
- `bic` varchar(255) NOT NULL,
- `agent_id` varchar(255) NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->retailStoreTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `login` varchar(255) NOT NULL,
- `retail_store_id` text NOT NULL,
- `updated` varchar(255) NOT NULL,
- `name` varchar(255) NOT NULL,
- `discount_max_percent` varchar(255) NOT NULL,
- `price_type` varchar(255) NOT NULL,
- `owner_name` varchar(255) NOT NULL,
- `owner_email` varchar(255) NOT NULL,
- `owner_phone` varchar(255) NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->purchaseOrderTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `purchase_order_id` varchar(255) NOT NULL,
- `owner_id` varchar(255) NOT NULL,
- `version` varchar(255) NOT NULL,
- `updated` varchar(255) NOT NULL,
- `deleted` varchar(255) NOT NULL,
- `name` varchar(255) NOT NULL,
- `description` varchar(255) NOT NULL,
- `external_code` varchar(255) NOT NULL,
- `moment` varchar(255) NOT NULL,
- `applicable` varchar(255) NOT NULL,
- `vat_enabled` varchar(255) NOT NULL,
- `sum` varchar(255) NOT NULL,
- `rate` varchar(255) NOT NULL,
- `shared` varchar(255) NOT NULL,
- `group_id` varchar(255) NOT NULL,
- `organization_id` varchar(255) NOT NULL,
- `agent_id` varchar(255) NOT NULL,
- `store_id` varchar(255) NOT NULL,
- `created` varchar(255) NOT NULL,
- `vat_sum` varchar(255) NOT NULL,
- `reserved_sum` varchar(255) NOT NULL,
- `delivery_planned_moment` varchar(255) NOT NULL,
- `payed_sum` varchar(255) NOT NULL,
- `shipped_sum` varchar(255) NOT NULL,
- `invoiced_sum` varchar(255) NOT NULL,
- `project_id` varchar(255) NOT NULL,
- `wait_sum` varchar(255) NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->positionsDemandsArrayTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `positions_array_id` varchar(255) NOT NULL,
- `position_id` text NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->positionsDemandTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `position_id` varchar(255) NOT NULL,
- `quantity` text NOT NULL,
- `price` text NOT NULL,
- `discount` text NOT NULL,
- `vat` text NOT NULL,
- `assortment_id` text NOT NULL,
- `cost` text NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->positionsSuppliesArrayTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `positions_array_id` varchar(255) NOT NULL,
- `position_id` text NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->positionsSupplyTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `position_id` varchar(255) NOT NULL,
- `quantity` text NOT NULL,
- `price` text NOT NULL,
- `discount` text NOT NULL,
- `vat` text NOT NULL,
- `assortment_id` text NOT NULL,
- `gtd` text NOT NULL,
- `country_id` text NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->cashInTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `cash_in_id` varchar(255) NOT NULL,
- `version` varchar(255) NOT NULL,
- `updated` varchar(255) NOT NULL,
- `deleted` varchar(255) NOT NULL,
- `name` varchar(255) NOT NULL,
- `description` varchar(255) NOT NULL,
- `external_code` varchar(255) NOT NULL,
- `moment` varchar(255) NOT NULL,
- `applicable` varchar(255) NOT NULL,
- `sum` varchar(255) NOT NULL,
- `rate` varchar(255) NOT NULL,
- `owner_id` varchar(255) NOT NULL,
- `shared` varchar(255) NOT NULL,
- `group_id` varchar(255) NOT NULL,
- `organization_id` varchar(255) NOT NULL,
- `agent_id` varchar(255) NOT NULL,
- `created` varchar(255) NOT NULL,
- `payment_purpose` varchar(255) NOT NULL,
- `vat_sum` varchar(255) NOT NULL,
- `incoming_date` varchar(255) NOT NULL,
- `incoming_number` varchar(255) NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->cashOutTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `cash_out_id` varchar(255) NOT NULL,
- `version` varchar(255) NOT NULL,
- `updated` varchar(255) NOT NULL,
- `deleted` varchar(255) NOT NULL,
- `name` varchar(255) NOT NULL,
- `description` varchar(255) NOT NULL,
- `external_code` varchar(255) NOT NULL,
- `moment` varchar(255) NOT NULL,
- `applicable` varchar(255) NOT NULL,
- `sum` varchar(255) NOT NULL,
- `rate` varchar(255) NOT NULL,
- `owner_id` varchar(255) NOT NULL,
- `shared` varchar(255) NOT NULL,
- `group_id` varchar(255) NOT NULL,
- `organization_id` varchar(255) NOT NULL,
- `agent_id` varchar(255) NOT NULL,
- `created` varchar(255) NOT NULL,
- `payment_purpose` varchar(255) NOT NULL,
- `vat_sum` varchar(255) NOT NULL,
- `expense_item_id` varchar(255) NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->demandTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `demand_id` varchar(255) NOT NULL,
- `owner_id` varchar(255) NOT NULL,
- `shared` varchar(255) NOT NULL,
- `group_id` varchar(255) NOT NULL,
- `version` varchar(255) NOT NULL,
- `updated` varchar(255) NOT NULL,
- `name` varchar(255) NOT NULL,
- `description` varchar(255) NOT NULL,
- `external_code` varchar(255) NOT NULL,
- `moment` varchar(255) NOT NULL,
- `applicable` varchar(255) NOT NULL,
- `vat_enabled` varchar(255) NOT NULL,
- `rate` varchar(255) NOT NULL,
- `sum` varchar(255) NOT NULL,
- `store_id` varchar(255) NOT NULL,
- `agent_id` varchar(255) NOT NULL,
- `organization_id` varchar(255) NOT NULL,
- `created` varchar(255) NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->supplyTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `demand_id` varchar(255) NOT NULL,
- `owner_id` varchar(255) NOT NULL,
- `shared` varchar(255) NOT NULL,
- `group_id` varchar(255) NOT NULL,
- `version` varchar(255) NOT NULL,
- `updated` varchar(255) NOT NULL,
- `name` varchar(255) NOT NULL,
- `description` varchar(255) NOT NULL,
- `external_code` varchar(255) NOT NULL,
- `moment` varchar(255) NOT NULL,
- `applicable` varchar(255) NOT NULL,
- `vat_enabled` varchar(255) NOT NULL,
- `rate` varchar(255) NOT NULL,
- `sum` varchar(255) NOT NULL,
- `store_id` varchar(255) NOT NULL,
- `agent_id` varchar(255) NOT NULL,
- `organization_id` varchar(255) NOT NULL,
- `created` varchar(255) NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->lossTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `loss_id` varchar(255) NOT NULL,
- `version` varchar(255) NOT NULL,
- `updated` varchar(255) NOT NULL,
- `deleted` varchar(255) NOT NULL,
- `name` varchar(255) NOT NULL,
- `description` varchar(255) NOT NULL,
- `external_code` varchar(255) NOT NULL,
- `moment` varchar(255) NOT NULL,
- `applicable` varchar(255) NOT NULL,
- `sum` varchar(255) NOT NULL,
- `rate` varchar(255) NOT NULL,
- `owner_id` varchar(255) NOT NULL,
- `shared` varchar(255) NOT NULL,
- `group_id` varchar(255) NOT NULL,
- `organization_id` varchar(255) NOT NULL,
- `store_id` varchar(255) NOT NULL,
- `project_id` varchar(255) NOT NULL,
- `created` varchar(255) NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->positionsLossArrayTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `positions_array_id` varchar(255) NOT NULL,
- `position_id` text NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->positionsLossTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `position_id` varchar(255) NOT NULL,
- `quantity` text NOT NULL,
- `price` text NOT NULL,
- `assortment_id` text NOT NULL,
- `reason` text NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->moveTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `login` varchar(255) NOT NULL,
- `move_id` varchar(255) NOT NULL,
- `name` varchar(255) NOT NULL,
- `sum` varchar(255) NOT NULL,
- `owner_name` varchar(255) NOT NULL,
- `owner_email` varchar(255) NOT NULL,
- `owner_phone` varchar(255) NOT NULL,
- `owner_sum` varchar(255) NOT NULL,
- `owner_vat_sum` varchar(255) NOT NULL,
- `group_name` varchar(255) NOT NULL,
- `position_quantity` varchar(255) NOT NULL,
- `position_price` varchar(255) NOT NULL,
- `position_discount` varchar(255) NOT NULL,
- `source_store_name` text NOT NULL,
- `target_store_name` varchar(255) NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->factureOutTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `login` varchar(255) NOT NULL,
- `facture_out_id` text NOT NULL,
- `name` text NOT NULL,
- `sum` text NOT NULL,
- `owner_name` text NOT NULL,
- `owner_email` text NOT NULL,
- `owner_phone` text NOT NULL,
- `owner_sum` text NOT NULL,
- `owner_vat_sum` text NOT NULL,
- `group_name` text NOT NULL,
- `agency_name` text NOT NULL,
- `agency_legal_title` text NOT NULL,
- `agency_legal_address` text NOT NULL,
- `agency_inn` text NOT NULL,
- `agency_kpp` text NOT NULL,
- `agency_sales_amount` text NOT NULL,
- `position_quantity` text NOT NULL,
- `position_price` text NOT NULL,
- `position_discount` text NOT NULL,
- `source_store_name` text NOT NULL,
- `target_store_name` varchar(255) NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->inventoryTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `login` varchar(255) NOT NULL,
- `inventory_id` text NOT NULL,
- `name` varchar(255) NOT NULL,
- `sum` varchar(255) NOT NULL,
- `owner_name` varchar(255) NOT NULL,
- `owner_email` varchar(255) NOT NULL,
- `owner_phone` varchar(255) NOT NULL,
- `owner_sum` varchar(255) NOT NULL,
- `owner_vat_sum` varchar(255) NOT NULL,
- `group_name` varchar(255) NOT NULL,
- `store_name` varchar(255) NOT NULL,
- `position_quantity` varchar(255) NOT NULL,
- `position_price` varchar(255) NOT NULL,
- `position_discount` varchar(255) NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->processingPlanTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `login` varchar(255) NOT NULL,
- `processing_plan_id` text NOT NULL,
- `name` text NOT NULL,
- `cost` text NOT NULL,
- `owner_name` text NOT NULL,
- `owner_email` text NOT NULL,
- `owner_phone` text NOT NULL,
- `owner_sum` text NOT NULL,
- `owner_vat_sum` text NOT NULL,
- `owner_payed_sum` text NOT NULL,
- `group_name` text NOT NULL,
- `material_quantity` text NOT NULL,
- `product_name` varchar(255) NOT NULL,
- `product_min_price` varchar(255) NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->processingOrderTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `login` varchar(255) NOT NULL,
- `processing_order_id` text NOT NULL,
- `name` text NOT NULL,
- `quantity` text NOT NULL,
- `owner_name` text NOT NULL,
- `owner_email` text NOT NULL,
- `owner_phone` varchar(255) NOT NULL,
- `owner_sum` varchar(255) NOT NULL,
- `owner_vat_sum` varchar(255) NOT NULL,
- `group_name` varchar(255) NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->auditTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `login` varchar(255) NOT NULL,
- `audit_id` text NOT NULL,
- `uid` varchar(255) NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->stockAllTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `login` varchar(255) NOT NULL,
- `stock` text NOT NULL,
- `in_transit` varchar(255) NOT NULL,
- `reserve` varchar(255) NOT NULL,
- `quantity` varchar(255) NOT NULL,
- `name` varchar(255) NOT NULL,
- `code` varchar(255) NOT NULL,
- `price` varchar(255) NOT NULL,
- `sale_price` varchar(255) NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->salePricesTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `assortment_id` varchar(255) NOT NULL,
- `value` text NOT NULL,
- `currency_code` varchar(255) NOT NULL,
- `price_type` varchar(255) NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$this->barcodesTable}` (
- `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `assortment_id` varchar(255) NOT NULL,
- `barcode` text NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- ";
- $this->makeYiiOperation($sql);
- return true;
- }
- private function dropTable()
- {
- $sql = "
- DROP TABLE IF EXISTS `{$this->serviceTable}`;
- DROP TABLE IF EXISTS `{$this->bundleTable}`;
- DROP TABLE IF EXISTS `{$this->productFolderTable}`;
- DROP TABLE IF EXISTS `{$this->variantTable}`;
- DROP TABLE IF EXISTS `{$this->consignmentTable}`;
- DROP TABLE IF EXISTS `{$this->contractTable}`;
- DROP TABLE IF EXISTS `{$this->projectTable}`;
- DROP TABLE IF EXISTS `{$this->groupsTable}`;
- DROP TABLE IF EXISTS `{$this->retailStoreTable}`;
- DROP TABLE IF EXISTS `{$this->cashiersTable}`;
- DROP TABLE IF EXISTS `{$this->taskTable}`;
- DROP TABLE IF EXISTS `{$this->retailshiftTable}`;
- DROP TABLE IF EXISTS `{$this->enterTable}`;
- DROP TABLE IF EXISTS `{$this->cashInTable}`;
- DROP TABLE IF EXISTS `{$this->cashOutTable}`;
- DROP TABLE IF EXISTS `{$this->demandTable}`;
- DROP TABLE IF EXISTS `{$this->supplyTable}`;
- DROP TABLE IF EXISTS `{$this->lossTable}`;
- DROP TABLE IF EXISTS `{$this->moveTable}`;
- DROP TABLE IF EXISTS `{$this->retailDemandTable}`;
- DROP TABLE IF EXISTS `{$this->retailSalesReturnTable}`;
- DROP TABLE IF EXISTS `{$this->retailDrawerCashInTable}`;
- DROP TABLE IF EXISTS `{$this->retailDrawerCashOutTable}`;
- DROP TABLE IF EXISTS `{$this->salesReturnTable}`;
- DROP TABLE IF EXISTS `{$this->purchaseReturnTable}`;
- DROP TABLE IF EXISTS `{$this->factureOutTable}`;
- DROP TABLE IF EXISTS `{$this->factureInTable}`;
- DROP TABLE IF EXISTS `{$this->inventoryTable}`;
- DROP TABLE IF EXISTS `{$this->commissionReportInTable}`;
- DROP TABLE IF EXISTS `{$this->commissionReportOutTable}`;
- DROP TABLE IF EXISTS `{$this->pricelistTable}`;
- DROP TABLE IF EXISTS `{$this->commissionReportOutTable}`;
- DROP TABLE IF EXISTS `{$this->processingPlanTable}`;
- DROP TABLE IF EXISTS `{$this->processingOrderTable}`;
- DROP TABLE IF EXISTS `{$this->processingTable}`;
- DROP TABLE IF EXISTS `{$this->internalOrderTable}`;
- DROP TABLE IF EXISTS `{$this->stockAllTable}`;
- DROP TABLE IF EXISTS `{$this->stockByStoreTable}`;
- DROP TABLE IF EXISTS `{$this->reportDashboardDayTable}`;
- DROP TABLE IF EXISTS `{$this->reportDashboardWeekTable}`;
- DROP TABLE IF EXISTS `{$this->reportDashboardMonthTable}`;
- DROP TABLE IF EXISTS `{$this->auditTable}`;
- DROP TABLE IF EXISTS `{$this->counterPartyTable}`;
- DROP TABLE IF EXISTS `{$this->assortmentTable}`;
- DROP TABLE IF EXISTS `{$this->currencyTable}`;
- DROP TABLE IF EXISTS `{$this->productTable}`;
- DROP TABLE IF EXISTS `{$this->salePricesTable}`;
- DROP TABLE IF EXISTS `{$this->barcodesTable}`;
- DROP TABLE IF EXISTS `{$this->positionsOrdersArrayTable}`;
- DROP TABLE IF EXISTS `{$this->positionsOrdersTable}`;
- DROP TABLE IF EXISTS `{$this->customerOrdersTable}`;
- DROP TABLE IF EXISTS `{$this->invoiceInTable}`;
- DROP TABLE IF EXISTS `{$this->invoiceOutTable}`;
- DROP TABLE IF EXISTS `{$this->positionsInvoicesTable}`;
- DROP TABLE IF EXISTS `{$this->positionsInvoicesArrayTable}`;
- DROP TABLE IF EXISTS `{$this->expenseItemTable}`;
- DROP TABLE IF EXISTS `{$this->countriesTable}`;
- DROP TABLE IF EXISTS `{$this->discountTable}`;
- DROP TABLE IF EXISTS `{$this->uomTable}`;
- DROP TABLE IF EXISTS `{$this->employeesTable}`;
- DROP TABLE IF EXISTS `{$this->storesTable}`;
- DROP TABLE IF EXISTS `{$this->organizationsTable}`;
- DROP TABLE IF EXISTS `{$this->accountsTable}`;
- DROP TABLE IF EXISTS `{$this->purchaseOrderTable}`;
- DROP TABLE IF EXISTS `{$this->paymentInTable}`;
- DROP TABLE IF EXISTS `{$this->paymentOutTable}`;
- DROP TABLE IF EXISTS `{$this->positionsDemandsArrayTable}`;
- DROP TABLE IF EXISTS `{$this->positionsDemandTable}`;
- DROP TABLE IF EXISTS `{$this->positionsSuppliesArrayTable}`;
- DROP TABLE IF EXISTS `{$this->positionsSupplyTable}`;
- DROP TABLE IF EXISTS `{$this->positionsLossArrayTable}`;
- DROP TABLE IF EXISTS `{$this->positionsLossTable}`;
- ";
- $this->makeYiiOperation($sql);
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement