| Server IP : 138.197.176.125 / Your IP : 216.73.217.54 Web Server : Apache/2.4.41 (Ubuntu) System : Linux SuiteCRM-8 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : root ( 0) PHP Version : 8.3.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/eyeclinic/modules/SpectacleExamJan30/ |
Upload File : |
<?php
/*+**********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
************************************************************************************/
include_once 'modules/Vtiger/CRMEntity.php';
class SpectacleExam extends Vtiger_CRMEntity {
var $table_name = 'vtiger_spectacleexam';
var $table_index= 'spectacleexamid';
/**
* Mandatory table for supporting custom fields.
*/
var $customFieldTable = Array('vtiger_spectacleexamcf', 'spectacleexamid');
/**
* Mandatory for Saving, Include tables related to this module.
*/
var $tab_name = Array('vtiger_crmentity', 'vtiger_spectacleexam', 'vtiger_spectacleexamcf','vtiger_historyandsymptom','vtiger_ophthalmoscopy_external_examination','vtiger_further_investigative_techniques');
/**
* Mandatory for Saving, Include tablename and tablekey columnname here.
*/
var $tab_name_index = Array(
'vtiger_crmentity' => 'crmid',
'vtiger_spectacleexam' => 'spectacleexamid',
'vtiger_spectacleexamcf'=>'spectacleexamid',
'vtiger_historyandsymptom' => 'historyandsymptomid',
'vtiger_ophthalmoscopy_external_examination' => 'ophthalmoscopyid',
'vtiger_further_investigative_techniques' => 'furtherinvestigativetechid');
/**
* Mandatory for Listing (Related listview)
*/
var $list_fields = Array (
/* Format: Field Label => Array(tablename, columnname) */
// tablename should not have prefix 'vtiger_'
'Spectacle Exam No' => Array('spectacleexam', 'spectacle_exam_no'),
'Assigned To' => Array('crmentity','smownerid')
);
var $list_fields_name = Array (
/* Format: Field Label => fieldname */
'Spectacle Exam No' => 'spectacle_exam_no',
'Assigned To' => 'assigned_user_id',
);
// Make the field link to detail view
var $list_link_field = 'spectacle_exam_no';
// For Popup listview and UI type support
var $search_fields = Array(
/* Format: Field Label => Array(tablename, columnname) */
// tablename should not have prefix 'vtiger_'
'Spectacle Exam No' => Array('spectacleexam', 'spectacle_exam_no'),
'Assigned To' => Array('vtiger_crmentity','assigned_user_id'),
);
var $search_fields_name = Array (
/* Format: Field Label => fieldname */
'Spectacle Exam No' => 'spectacle_exam_no',
'Assigned To' => 'assigned_user_id',
);
// For Popup window record selection
var $popup_fields = Array ('spectacle_exam_no');
// For Alphabetical search
var $def_basicsearch_col = 'spectacle_exam_no';
// Column value to use on detail view record text display
var $def_detailview_recname = 'spectacle_exam_no';
// Used when enabling/disabling the mandatory fields for the module.
// Refers to vtiger_field.fieldname values.
var $mandatory_fields = Array('spectacle_exam_no','assigned_user_id');
var $default_order_by = 'spectacle_exam_no';
var $default_sort_order='ASC';
/**
* Invoked when special actions are performed on the module.
* @param String Module name
* @param String Event Type
*/
function vtlib_handler($moduleName, $eventType) {
global $adb;
if($eventType == 'module.postinstall') {
// TODO Handle actions after this module is installed.
} else if($eventType == 'module.disabled') {
// TODO Handle actions before this module is being uninstalled.
} else if($eventType == 'module.preuninstall') {
// TODO Handle actions when this module is about to be deleted.
} else if($eventType == 'module.preupdate') {
// TODO Handle actions before this module is updated.
} else if($eventType == 'module.postupdate') {
// TODO Handle actions after this module is updated.
}
}
function save_module($module){
$this->insertIntoAttachment($this->id,$module);
}
function insertIntoAttachment($id,$module)
{
global $log,$adb;
$log->debug("Entering into insertIntoAttachment($id,$module) method.");
$file_saved = false;
foreach($_FILES as $fileindex => $files)
{
if($files['name'] != '' && $files['size'] > 0)
{
if($_REQUEST[$fileindex.'_hidden'] != '')
$files['original_name'] = vtlib_purify($_REQUEST[$fileindex.'_hidden']);
else
$files['original_name'] = stripslashes($files['name']);
$files['original_name'] = str_replace('"','',$files['original_name']);
if($fileindex == 'eyeclinic_image_1'){
$file_saved = $this->uploadAndSaveFile($id,$module,$files);
}else{
$file_saved = $this->uploadAndSaveFile($id,'SpectacleExam1',$files);
}
}
}
//Updating image information in main table of products
$existingImageSql = 'SELECT name, vtiger_crmentity.setype FROM vtiger_seattachmentsrel INNER JOIN vtiger_attachments ON
vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid LEFT JOIN vtiger_ophthalmoscopy_external_examination ON
vtiger_ophthalmoscopy_external_examination.ophthalmoscopyid = vtiger_seattachmentsrel.crmid WHERE vtiger_seattachmentsrel.crmid = ?';
$existingImages = $adb->pquery($existingImageSql,array($id));
$numOfRows = $adb->num_rows($existingImages);
$eyeclinicImage1Map = $eyeclinicImage2Map = array();
for ($i = 0; $i < $numOfRows; $i++) {
$imageName = $adb->query_result($existingImages, $i, "name");
$setype = $adb->query_result($existingImages, $i, "setype");
if($setype == 'SpectacleExam RightEye Image'){
array_push($eyeclinicImage2Map, decode_html($imageName));
}else if($setype == 'SpectacleExam LeftEye Image'){
array_push($eyeclinicImage1Map, decode_html($imageName));
}
}
$commaSeperatedFileNames1 = implode(",", $eyeclinicImage1Map);
$commaSeperatedFileNames2 = implode(",", $eyeclinicImage2Map);
$adb->pquery('UPDATE vtiger_ophthalmoscopy_external_examination SET eyeclinic_image_1 = ? WHERE ophthalmoscopyid = ?',array($commaSeperatedFileNames1,$id));
$adb->pquery('UPDATE vtiger_ophthalmoscopy_external_examination SET eyeclinic_image_2 = ? WHERE ophthalmoscopyid = ?',array($commaSeperatedFileNames2,$id));
//Remove the deleted vtiger_attachments from db - Products
/*if($module == 'Products' && $_REQUEST['del_file_list'] != '')
{
$del_file_list = explode("###",trim($_REQUEST['del_file_list'],"###"));
foreach($del_file_list as $del_file_name)
{
$attach_res = $adb->pquery("select vtiger_attachments.attachmentsid from vtiger_attachments inner join vtiger_seattachmentsrel on vtiger_attachments.attachmentsid=vtiger_seattachmentsrel.attachmentsid where crmid=? and name=?", array($id,$del_file_name));
$attachments_id = $adb->query_result($attach_res,0,'attachmentsid');
$del_res1 = $adb->pquery("delete from vtiger_attachments where attachmentsid=?", array($attachments_id));
$del_res2 = $adb->pquery("delete from vtiger_seattachmentsrel where attachmentsid=?", array($attachments_id));
}
}*/
$log->debug("Exiting from insertIntoAttachment($id,$module) method.");
}
}