1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
contractor.php
См. документацию.
1<?php
2
5
7{
8 protected static function checkFields($action, &$arFields)
9 {
10 $personType = intval($arFields["PERSON_TYPE"]);
11
12 if($personType == CONTRACTOR_JURIDICAL && is_set($arFields, "COMPANY") && $arFields["COMPANY"] == '')
13 {
14 $GLOBALS["APPLICATION"]->ThrowException(Loc::getMessage("CC_EMPTY_COMPANY"));
15 return false;
16 }
17 if (((($action == 'ADD' || is_set($arFields, "PERSON_NAME")) && $arFields["PERSON_NAME"] == '') && $personType == CONTRACTOR_INDIVIDUAL))
18 {
19 $GLOBALS["APPLICATION"]->ThrowException(Loc::getMessage("CC_WRONG_PERSON_LASTNAME"));
20 return false;
21 }
22 if (($action == 'UPDATE') && is_set($arFields, "ID"))
23 unset($arFields["ID"]);
24
25 return true;
26 }
27
28 public static function update($id, $arFields)
29 {
30 global $DB, $APPLICATION;
31
32 if (Contractor\Provider\Manager::isActiveProviderExists())
33 {
34 $APPLICATION->throwException('This API has been deprecated and is no longer available');
35 return false;
36 }
37
38 $id = intval($id);
39
40 if(array_key_exists('DATE_CREATE', $arFields))
41 unset($arFields['DATE_CREATE']);
42 if(array_key_exists('DATE_MODIFY', $arFields))
43 unset($arFields['DATE_MODIFY']);
44 if(array_key_exists('CREATED_BY', $arFields))
45 unset($arFields['CREATED_BY']);
46
47 $arFields['~DATE_MODIFY'] = $DB->GetNowFunction();
48
49 if($id <= 0 || !self::checkFields('UPDATE', $arFields))
50 return false;
51 $strUpdate = $DB->PrepareUpdate("b_catalog_contractor", $arFields);
52
53 if(!empty($strUpdate))
54 {
55 $strSql = "UPDATE b_catalog_contractor SET ".$strUpdate." WHERE ID = ".$id." ";
56 $DB->Query($strSql);
57 }
58 return $id;
59 }
60
61 public static function delete($id)
62 {
63 global $DB, $APPLICATION;
64
65 if (Contractor\Provider\Manager::isActiveProviderExists())
66 {
67 $APPLICATION->throwException('This API has been deprecated and is no longer available');
68 return false;
69 }
70
71 $id = intval($id);
72 if($id > 0)
73 {
74 $dbDocument = CCatalogDocs::getList(array(), array("CONTRACTOR_ID" => $id));
75 if($arDocument = $dbDocument->Fetch())
76 {
77 $GLOBALS["APPLICATION"]->ThrowException(Loc::getMessage("CC_CONTRACTOR_HAVE_DOCS_EXT"));
78 return false;
79 }
80
81 return $DB->Query("DELETE FROM b_catalog_contractor WHERE ID = ".$id." ", true);
82 }
83 return false;
84 }
85}
const CONTRACTOR_INDIVIDUAL
Определения include.php:54
global $APPLICATION
Определения include.php:80
const CONTRACTOR_JURIDICAL
Определения include.php:55
static update($id, $arFields)
Определения contractor.php:28
static checkFields($action, &$arFields)
Определения contractor.php:8
$arFields
Определения dblapprove.php:5
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
global $DB
Определения cron_frame.php:29
is_set($a, $k=false)
Определения tools.php:2133
$action
Определения file_dialog.php:21
$GLOBALS['_____370096793']
Определения update_client.php:1