14 public static function getEdit($collection, $formName, $formPrefix, array $post = array())
16 global $APPLICATION, $USER;
18 $saleModulePermissions = $APPLICATION->GetGroupRight(
"sale");
20 $userCompanyId =
null;
22 if($saleModulePermissions ==
"P")
24 $userCompanyList = Manager::getUserCompanyList($USER->GetID());
25 if (!empty($userCompanyList) && is_array($userCompanyList) && count($userCompanyList) == 1)
27 $userCompanyId = reset($userCompanyList);
29 if ($collection->getId() == 0)
31 if (intval($userCompanyId) > 0)
33 $collection->setField(
'COMPANY_ID', $userCompanyId);
36 $collection->setField(
'RESPONSIBLE_ID', $USER->GetID());
44 if(get_class($collection) ==
'Bitrix\Sale\Order')
45 $orderLocked = \Bitrix\Sale\Order::isLocked($collection->getId());
49 $blockEmpResponsible =
'';
50 if (isset($data[
'EMP_RESPONSIBLE']) && !empty($data[
'EMP_RESPONSIBLE']))
52 $blockEmpResponsible =
'
54 <td class="adm-detail-content-cell-l fwb vat" width="40%"></td>
55 <td class="adm-detail-content-cell-r">
56 <div>'.Loc::getMessage(
'SALE_ORDER_ADDITIONAL_INFO_CHANGE_BY').
': <span style="color: #66878F" id="order_additional_info_date_responsible">'.$data[
'DATE_RESPONSIBLE'].
'</span> <a href="" id="order_additional_info_emp_responsible">'.htmlspecialcharsbx($data[
'EMP_RESPONSIBLE']).
'</a></div>
64 if (isset($data[
'ADDITIONAL_INFO']) && !empty($data[
'ADDITIONAL_INFO']))
67 <table class="adm-detail-content-table edit-table" border="0" width="100%" cellpadding="0" cellspacing="0">
70 <td class="adm-detail-content-cell-l vat" width="40%">'.Loc::getMessage(
'SALE_ORDER_ADDITIONAL_INFO_ADDITIONAL_INFO').
':</td>
71 <td class="adm-detail-content-cell-r">'.$data[
'ADDITIONAL_INFO'].
'</td>
77 $data[
'COMPANIES'] = Manager::getListWithRestrictions($collection, \
Bitrix\
Sale\Services\Company\Restrictions\Manager::MODE_MANAGER);
79 if (!empty($data[
'COMPANIES']))
82 if ($saleModulePermissions ==
"P")
85 if (count($userCompanyList) == 1)
87 $companyName = $data[
'COMPANIES'][$userCompanyId][
"NAME"].
" [".$data[
'COMPANIES'][$userCompanyId][
"ID"].
"]";
88 $companies = htmlspecialcharsbx($companyName);
92 foreach ($data[
'COMPANIES'] as $companyId => $companyData)
94 $foundCompany =
false;
95 foreach ($userCompanyList as $userCompanyId)
97 if ($userCompanyId == $companyId)
106 unset($data[
'COMPANIES'][$companyId]);
111 if (count($data[
'COMPANIES']) == 1)
113 $company = reset($data[
'COMPANIES']);
114 $companies = htmlspecialcharsbx($company[
"NAME"].
" [".$company[
"ID"].
"]");
120 if (empty($companies) && $formPrefix ===
'ORDER')
123 $formPrefix.
'[COMPANY_ID]',
125 isset($post[
"COMPANY_ID"]) ? $post[
"COMPANY_ID"] : $data[
"COMPANY_ID"],
128 "class" =>
"adm-bus-select",
129 "id" => $formPrefix.
"_COMPANY_ID"
136 if ($saleModulePermissions >=
"W")
138 $companies = str_replace(
"#URL#",
"/bitrix/admin/sale_company_edit.php?lang=".$lang,
Loc::getMessage(
'SALE_ORDER_SHIPMENT_ADD_COMPANY'));
142 if (!empty($companies))
145 <table border="0" cellspacing="0" cellpadding="0" width="100%" class="adm-detail-content-table edit-table ">
148 <td class="adm-detail-content-cell-l" width="40%">'.Loc::getMessage(
'SALE_ORDER_ADDITIONAL_INFO_COMPANY').
':</td>
149 <td class="adm-detail-content-cell-r">'.$companies.
'</td>
157 <input type="hidden" name="'.$formPrefix.
'[RESPONSIBLE_ID]" id="RESPONSIBLE_ID" value="'.$data[
'RESPONSIBLE_ID'].
'" onChange="BX.Sale.Admin.OrderAdditionalInfo.changePerson();">
158 <div class="adm-bus-moreInfo_part1">
159 <table class="adm-detail-content-table edit-table" border="0" width="100%" cellpadding="0" cellspacing="0">
162 <td class="adm-detail-content-cell-l vat" width="40%">'.
Loc::getMessage(
'SALE_ORDER_ADDITIONAL_INFO_RESPONSIBLE').
':</td>
163 <td class="adm-detail-content-cell-r">
164 <div class="adm-s-order-person-choose">'.static::renderResponsibleLink($data).
'
166 <a class="adm-s-bus-morelinkqhsw" onclick="BX.Sale.Admin.OrderAdditionalInfo.choosePerson(\''.$formName.
'\', \
''.LANGUAGE_ID.
'\');
" href="javascript:void(0);
">
167 '.Loc::getMessage('SALE_ORDER_ADDITIONAL_INFO_CHANGE').'
172 '.$blockEmpResponsible.'
176 <div class="adm-bus-moreInfo_part1-5
">
179 <div class="adm-s-gray-title
">'.Loc::getMessage('SALE_ORDER_ADDITIONAL_INFO_COMMENT').'</div>
181 <div class="adm-bus-moreInfo_part2
">
182 <table class="adm-detail-content-table edit-table
" border="0
" width="100%
" cellpadding="0
" cellspacing="0
">
185 <td class="adm-detail-content-cell-l vat
" width="40%
">'.Loc::getMessage('SALE_ORDER_ADDITIONAL_INFO_MANAGER_COMMENT').':</td>
186 <td class="adm-detail-content-cell-r
">
188 <textarea style="width:400px;min-height:100px;
" name="'.$formPrefix.'[COMMENTS]
" id="COMMENTS
"'.($orderLocked ? ' disabled' : '').'>'
189 .htmlspecialcharsbx($data['COMMENTS']).
199 public static function getView($collection, $formName)
201 $data = self::prepareData($collection);
202 $blockEmpResponsible = '';
204 if(get_class($collection) == 'Bitrix\Sale\Order')
205 $orderLocked = \Bitrix\Sale\Order::isLocked($collection->getId());
207 $orderLocked = false;
209 if ($formName == "archive
")
212 if (isset($data['EMP_RESPONSIBLE']) && !empty($data['EMP_RESPONSIBLE']))
214 $blockEmpResponsible = '
216 <td class="adm-detail-content-cell-l vat
" width="40%
"></td>
217 <td class="adm-detail-content-cell-r
">
218 <div>'.Loc::getMessage('SALE_ORDER_ADDITIONAL_INFO_CHANGE_BY').': <span style="color: #66878F
" id="order_additional_info_date_responsible
">'.$data['DATE_RESPONSIBLE'].'</span> <a href="" id="order_additional_info_emp_responsible
">'.htmlspecialcharsbx($data['EMP_RESPONSIBLE']).'</a></div>
224 $additionalInfo = '';
226 if (isset($data['ADDITIONAL_INFO']) && !empty($data['ADDITIONAL_INFO']))
229 <table class="adm-detail-content-table edit-table
" border="0
" width="100%
" cellpadding="0
" cellspacing="0
">
232 <td class="adm-detail-content-cell-l vat
" width="40%
">'.Loc::getMessage('SALE_ORDER_ADDITIONAL_INFO_ADDITIONAL_INFO').':</td>
233 <td class="adm-detail-content-cell-r
">'.$data['ADDITIONAL_INFO'].'</td>
239 if (isset($data['COMPANY_ID']) && !empty($data['COMPANY_ID']))
241 $companyList = OrderEdit::getCompanyList();
244 <table class="adm-detail-content-table edit-table
" border="0
" width="100%
" cellpadding="0
" cellspacing="0
">
247 <td class="adm-detail-content-cell-l vat
" width="40%
">'.Loc::getMessage('SALE_ORDER_ADDITIONAL_INFO_COMPANY').':</td>
248 <td class="adm-detail-content-cell-r
">'.htmlspecialcharsbx($companyList[$data['COMPANY_ID']]).'</td>
255 <table class="adm-detail-content-table edit-table
" border="0
" width="100%
" cellpadding="0
" cellspacing="0
">
258 <td class="adm-detail-content-cell-l vat
" width="40%
">'.Loc::getMessage('SALE_ORDER_ADDITIONAL_INFO_RESPONSIBLE').':</td>
259 <td class="adm-detail-content-cell-r
">
260 <div>'.static::renderResponsibleLink($data).'</div>
263 '.$blockEmpResponsible.'
267 <table class="adm-detail-content-table edit-table
" border="0
" width="100%
" cellpadding="0
" cellspacing="0
">
270 <td class="adm-detail-content-cell-l
'.($orderLocked ? '' : ' vat
').'" width="40%
">'.Loc::getMessage('SALE_ORDER_ADDITIONAL_INFO_MANAGER_COMMENT').':</td>
271 <td class="adm-detail-content-cell-r
">'.($orderLocked ? '' : '<a href="javascript:void(0);
" style="text-decoration: none; border-bottom: 1px dashed
" onClick="BX.Sale.Admin.OrderAdditionalInfo.showCommentsDialog(\
''.$collection->getField(
'ID').
'\',
BX(\
'sale-adm-comments-view\'))">'.
Loc::getMessage(
'SALE_ORDER_ADDITIONAL_INFO_COMMENT_TITLE').
'</a>').
272 '<p id="sale-adm-comments-view" style="color:gray; max-width:800px; overflow:auto;">'.($data[
'COMMENTS'] <>
'' ? nl2br(htmlspecialcharsbx($data[
'COMMENTS'])) :
'').
'</p>
304 if (is_null($collection))
306 $data[
'COMMENTS'] =
'';
310 if (intval($collection->getField(
'EMP_RESPONSIBLE_ID')) > 0)
311 $data[
'EMP_RESPONSIBLE'] = \Bitrix\Sale\Helpers\Admin\OrderEdit::getUserName($collection->getField(
'EMP_RESPONSIBLE_ID'));
313 $dateResponsibleId = $collection->getField(
'DATE_RESPONSIBLE_ID');
314 if (!is_null($dateResponsibleId))
315 $data[
'DATE_RESPONSIBLE'] = $dateResponsibleId->toString();
317 $data[
'COMMENTS'] = $collection->getField(
'COMMENTS');
320 if (intval($collection->getField(
'RESPONSIBLE_ID')) > 0)
322 $data[
'RESPONSIBLE'] = \Bitrix\Sale\Helpers\Admin\OrderEdit::getUserName($collection->getField(
'RESPONSIBLE_ID'));
323 $data[
'RESPONSIBLE_ID'] = intval($collection->getField(
'RESPONSIBLE_ID'));
327 $data[
'RESPONSIBLE_ID'] =
'';
331 if(in_array(
"ADDITIONAL_INFO", $collection->getAvailableFields()))
332 if($collection->getField(
"ADDITIONAL_INFO") <>
'')
333 $data[
"ADDITIONAL_INFO"] = $collection->getField(
"ADDITIONAL_INFO");
335 if(in_array(
"COMPANY_ID", $collection->getAvailableFields()))
337 if(strval($collection->getField(
"COMPANY_ID")) !=
'')
339 $data[
"COMPANY_ID"] = $collection->getField(
"COMPANY_ID");