pquery($query); if ($adb->num_rows($result) == 0) { $logstring = date('Y-m-d H:i:s').' - отель с id = '.$id.' не найден'.PHP_EOL; file_put_contents('logs/GetHotel.log', $logstring, FILE_APPEND); $output = null; } else { $logstring = date('Y-m-d H:i:s').' - найден отель '.$adb->query_result($result, 0, 'tickersymbol').PHP_EOL; file_put_contents('logs/GetHotel.log', $logstring, FILE_APPEND); $output = []; $output['name'] = $adb->query_result($result, 0, 'tickersymbol'); $output['legal'] = $adb->query_result($result, 0, 'accountname'); $output['email'] = $adb->query_result($result, 0, 'email1'); $output['phone'] = $adb->query_result($result, 0, 'phone'); $output['inn'] = $adb->query_result($result, 0, 'inn'); $output['ogrn'] = $adb->query_result($result, 0, 'ogrn'); $output['kpp'] = $adb->query_result($result, 0, 'kpp'); $output['website'] = $adb->query_result($result, 0, 'website'); $output['bill_state'] = $adb->query_result($result, 0, 'bill_state'); $output['bill_city'] = $adb->query_result($result, 0, 'bill_city'); $output['bill_street'] = $adb->query_result($result, 0, 'bill_street'); $output['ship_state'] = $adb->query_result($result, 0, 'ship_state'); $output['ship_city'] = $adb->query_result($result, 0, 'ship_city'); $output['ship_street'] = $adb->query_result($result, 0, 'ship_street'); $output['stars'] = $adb->query_result($result, 0, 'stars'); $output['type'] = explode(' |##| ', $adb->query_result($result, 0, 'type')); $output['decnum'] = $adb->query_result($result, 0, 'decnum'); $output['decdate'] = $adb->query_result($result, 0, 'decdate'); $output['certnum'] = $adb->query_result($result, 0, 'certnum'); $output['certdate'] = $adb->query_result($result, 0, 'certdate'); $output['expire'] = $adb->query_result($result, 0, 'expire'); $output['regnum'] = $adb->query_result($result, 0, 'regnum'); $output['rating'] = $adb->query_result($result, 0, 'rating'); $output['images'] = []; $query = 'select n.title, a.path, a.storedname, s.attachmentsid from vtiger_senotesrel r left join vtiger_notes n on n.notesid = r.notesid left join vtiger_seattachmentsrel s on s.crmid = r.notesid left join vtiger_attachments a on a.attachmentsid = s.attachmentsid where (n.filetype = "image/png" or n.filetype = "image/jpeg") and n.folderid = 6 and r.crmid = '.$id; // n.folderid = 6 - это папка viewhotel, в которой лежат официальные фотки владельцев отелей $images = $adb->pquery($query); if ($adb->num_rows($images) > 0) { for ($i=0; $i<$adb->num_rows($images); $i++) { $output['images'][$i]['title'] = $adb->query_result($images, $i, 'title'); $output['images'][$i]['path'] = $adb->query_result($images, $i, 'path').$adb->query_result($images, $i, 'attachmentsid').'_'.$adb->query_result($images, $i, 'storedname'); } } $logstring = date('Y-m-d H:i:s').' - поиск картинок завершен'.PHP_EOL; file_put_contents('logs/GetHotel.log', $logstring, FILE_APPEND); } return $output; }