コード例 #1
0
ファイル: arka_classes.php プロジェクト: konvita2/portal_php
 public static function RegisterStop($user_id, $deal_id)
 {
     $res = false;
     $iblock_id = 65;
     $stop_code = "timestop";
     $dur_code = "duration";
     $qpos_code = "qpositions";
     // количество позиций
     $arFilter = array("IBLOCK_ID" => $iblock_id, "PROPERTY_USER" => $user_id, "PROPERTY_DEAL" => $deal_id);
     $rsItems = CIBlockElement::GetList(array("SORT" => "ASC"), $arFilter, false, false, array());
     while (($ob = $rsItems->GetNextElement()) && !$res) {
         $arFields = $ob->GetFields();
         $arProps = $ob->GetProperties();
         $element_id = $arFields["ID"];
         //define timestart
         $found = false;
         foreach ($arProps as $kk => $vv) {
             if ($vv["CODE"] == "timestart") {
                 $timestart = $vv["VALUE"];
                 $found = true;
                 break;
             }
         }
         //получить количество позиций в сделке
         $qpos = CArkaCrm::GetQPosByDealID($deal_id);
         if (!empty($timestart) && $found) {
             foreach ($arProps as $key => $val) {
                 $cod = $val["CODE"];
                 if ($cod == "timestop") {
                     $timestop = $val["VALUE"];
                     if (empty($timestop)) {
                         // update this record with curr time as timestop
                         $curr_time = time();
                         $prev_time = MakeTimeStamp($timestart);
                         $period = $curr_time - $prev_time;
                         $curr_time_site = ConvertTimeStamp($curr_time, FULL);
                         CIBlockElement::SetPropertyValues($element_id, $iblock_id, $curr_time_site, $stop_code);
                         CIBlockElement::SetPropertyValues($element_id, $iblock_id, $period, $dur_code);
                         CIBlockElement::SetPropertyValues($element_id, $iblock_id, $qpos, $qpos_code);
                         $res = true;
                         break;
                     }
                 }
             }
         }
     }
     return $res;
 }