Payment and shipment status
This commit is contained in:
parent
ad73c0c1dc
commit
2bc97c84ff
@ -51,6 +51,9 @@ class RetailcrmConfigProvider
|
||||
/** @var bool|null|string */
|
||||
private static $corporateClient;
|
||||
|
||||
/** @var bool|null|string $shipmentDeducted */
|
||||
private static $shipmentDeducted;
|
||||
|
||||
/** @var array $sitesList */
|
||||
private static $sitesList;
|
||||
|
||||
@ -517,6 +520,20 @@ class RetailcrmConfigProvider
|
||||
return static::$shops;
|
||||
}
|
||||
|
||||
/**
|
||||
* getShipmentDeducted
|
||||
*
|
||||
* @return bool|string|null
|
||||
*/
|
||||
public static function getShipmentDeducted()
|
||||
{
|
||||
if (self::isEmptyNotZero(static::$shipmentDeducted)) {
|
||||
static::$shipmentDeducted = static::getOption(RetailcrmConstants::CRM_SHIPMENT_DEDUCTED);
|
||||
}
|
||||
|
||||
return static::$shipmentDeducted;
|
||||
}
|
||||
|
||||
/**
|
||||
* isPhoneRequired
|
||||
*
|
||||
|
@ -76,4 +76,5 @@ class RetailcrmConstants
|
||||
const CRM_ORDER_DIMENSIONS = 'order_dimensions';
|
||||
const CANCEL_PROPERTY_CODE = 'INTAROCRM_IS_CANCELED';
|
||||
const CRM_INTEGRATION_DELIVERY = 'integration_delivery';
|
||||
const CRM_SHIPMENT_DEDUCTED = 'shipment_deducted';
|
||||
}
|
||||
|
@ -212,6 +212,7 @@ class RetailCrmHistory
|
||||
$optionsCanselOrder = RetailcrmConfigProvider::getCancellableOrderPaymentStatuses();
|
||||
$currency = RetailcrmConfigProvider::getCurrencyOrDefault();
|
||||
$contragentTypes = array_flip(RetailcrmConfigProvider::getContragentTypes());
|
||||
$shipmentDeducted = RetailcrmConfigProvider::getShipmentDeducted();
|
||||
|
||||
$api = new RetailCrm\ApiClient(RetailcrmConfigProvider::getApiUrl(), RetailcrmConfigProvider::getApiKey());
|
||||
|
||||
@ -1127,6 +1128,32 @@ class RetailCrmHistory
|
||||
unset($orderCrm);
|
||||
}
|
||||
|
||||
if (isset($order['fullPaidAt']) && is_string($order['fullPaidAt'])) {
|
||||
$newOrder->setField('PAID', 'Y');
|
||||
}
|
||||
|
||||
if ($shipmentDeducted === 'Y') {
|
||||
$collection = $newOrder->getShipmentCollection()->getNotSystemItems();
|
||||
|
||||
if (isset($order['shipped'])) {
|
||||
if ($order['shipped']) {
|
||||
if ($collection->count() === 0) {
|
||||
$collection = $newOrder->getShipmentCollection();
|
||||
$shipment = $collection->createItem();
|
||||
$shipment->setField('DEDUCTED', 'Y');
|
||||
} else {
|
||||
foreach ($collection as $shipment) {
|
||||
$shipment->setField('DEDUCTED', 'Y');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach ($collection as $shipment) {
|
||||
$shipment->setField('DEDUCTED', 'N');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$newOrder->setField('PRICE', $orderSumm);
|
||||
self::orderSave($newOrder);
|
||||
|
||||
|
@ -462,6 +462,13 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
||||
UnRegisterModuleDependences("main", "OnBeforeProlog", $mid, "RetailCrmDc", "add");
|
||||
}
|
||||
|
||||
//shipment
|
||||
if (htmlspecialchars(trim($_POST['shipment_deducted'])) == 'Y') {
|
||||
$shipment_deducted = 'Y';
|
||||
} else {
|
||||
$shipment_deducted = 'N';
|
||||
}
|
||||
|
||||
//corporate-cliente
|
||||
if (htmlspecialchars(trim($_POST['corp-client'])) == 'Y') {
|
||||
$cc = 'Y';
|
||||
@ -563,6 +570,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
||||
|
||||
COption::SetOptionString($mid, $CRM_DISCOUNT_ROUND, $discount_round);
|
||||
COption::SetOptionString($mid, $CRM_PURCHASE_PRICE_NULL, $purchasePrice_null);
|
||||
COption::SetOptionString($mid, RetailcrmConstants::CRM_SHIPMENT_DEDUCTED, $shipment_deducted);
|
||||
|
||||
COption::SetOptionString($mid, $CRM_CC, $cc);
|
||||
COption::SetOptionString($mid, $CRM_CORP_SHOPS, serialize(RCrmActions::clearArr($bitrixCorpShopsArr)));
|
||||
@ -682,6 +690,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
||||
|
||||
$optionDiscRound = COption::GetOptionString($mid, $CRM_DISCOUNT_ROUND, 0);
|
||||
$optionPricePrchaseNull = COption::GetOptionString($mid, $CRM_PURCHASE_PRICE_NULL, 0);
|
||||
$optionShipmentDeducted = RetailcrmConfigProvider::getShipmentDeducted();
|
||||
|
||||
//corporate-cliente
|
||||
$optionCorpClient = COption::GetOptionString($mid, $CRM_CC, 0);
|
||||
@ -1460,6 +1469,14 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
||||
<?php endforeach;?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="heading">
|
||||
<td colspan="2" class="option-other-heading">
|
||||
<b>
|
||||
<label><input class="addr" type="checkbox" name="shipment_deducted" value="Y" <?php if($optionShipmentDeducted === 'Y') echo "checked"; ?>><?php echo "Изменять статус отгрузки при получении соответствующего флага из crm" ?></label>
|
||||
</b>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif;?>
|
||||
<?php $tabControl->Buttons(); ?>
|
||||
<input type="hidden" name="Update" value="Y" />
|
||||
|
Loading…
Reference in New Issue
Block a user