PageRenderTime 43ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 1ms

/modules/Documents/EditView.php

https://bitbucket.org/jhunsinfotech/blue-blues
PHP | 238 lines | 192 code | 29 blank | 17 comment | 62 complexity | 1071a76241d85d00383907335a35c349 MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0, LGPL-3.0
  1. <?php
  2. /*+**********************************************************************************
  3. * The contents of this file are subject to the vtiger CRM Public License Version 1.0
  4. * ("License"); You may not use this file except in compliance with the License
  5. * The Original Code is: vtiger CRM Open Source
  6. * The Initial Developer of the Original Code is vtiger.
  7. * Portions created by vtiger are Copyright (C) vtiger.
  8. * All Rights Reserved.
  9. ************************************************************************************/
  10. require_once('Smarty_setup.php');
  11. require_once('data/Tracker.php');
  12. require_once('include/utils/utils.php');
  13. global $app_strings,$app_list_strings,$mod_strings,$theme,$currentModule;
  14. $module = vtlib_purify($_REQUEST['module']);
  15. $focus = CRMEntity::getInstance($currentModule);
  16. $smarty = new vtigerCRM_Smarty();
  17. //added to fix the issue4600
  18. $searchurl = getBasic_Advance_SearchURL();
  19. $smarty->assign("SEARCH", $searchurl);
  20. //4600 ends
  21. $smarty->assign("UPLOADSIZE", $upload_maxsize/1000000); //Convert to MB
  22. $smarty->assign("UPLOAD_MAXSIZE",$upload_maxsize);
  23. if($_REQUEST['upload_error'] == true)
  24. {
  25. echo '<br><b><font color="red"> '.$mod_strings['FILE_HAS_NO_DATA'].'.</font></b><br>';
  26. }
  27. if(isset($_REQUEST['record']) && $_REQUEST['record'] !='')
  28. {
  29. $focus->id = $_REQUEST['record'];
  30. $focus->mode = 'edit';
  31. $focus->retrieve_entity_info($_REQUEST['record'],"Documents");
  32. $focus->name=$focus->column_fields['notes_title'];
  33. }
  34. if($focus->mode != 'edit')
  35. {
  36. if(isset($_REQUEST['parent_id']) && isset($_REQUEST['return_module']))
  37. {
  38. $owner = getRecordOwnerId($_REQUEST['parent_id']);
  39. if(isset($owner['Users']) && $owner['Users'] != '') {
  40. $permitted_users = get_user_array('true', 'Active',$current_user->id);
  41. if(!in_array($owner['Users'],$permitted_users)){
  42. $owner['Users'] = $current_user->id;
  43. }
  44. $focus->column_fields['assigntype'] = 'U';
  45. $focus->column_fields['assigned_user_id'] = $owner['Users'];
  46. } elseif(isset($owner['Groups']) && $owner['Groups'] != '') {
  47. $focus->column_fields['assigntype'] = 'T';
  48. $focus->column_fields['assigned_user_id'] = $owner['Groups'];
  49. }
  50. }
  51. }
  52. if(empty($_REQUEST['record']) && $focus->mode != 'edit'){
  53. setObjectValuesFromRequest($focus);
  54. }
  55. if(isset($_REQUEST['parent_id']) && $focus->mode != 'edit') {
  56. $smarty->assign("PARENTID",vtlib_purify($_REQUEST['parent_id']));
  57. }
  58. $dbQuery="select filename from vtiger_notes where notesid = ?";
  59. $result=$adb->pquery($dbQuery,array($focus->id));
  60. $filename=$adb->query_result($result,0,'filename');
  61. if(is_null($filename) || $filename == '')
  62. {
  63. $smarty->assign("FILE_EXIST","no");
  64. }
  65. else
  66. {
  67. $smarty->assign("FILE_NAME",$filename);
  68. $smarty->assign("FILE_EXIST","yes");
  69. }
  70. //setting default flag value so due date and time not required
  71. if (!isset($focus->id)) $focus->date_due_flag = 'on';
  72. //needed when creating a new case with default values passed in
  73. if (isset($_REQUEST['contact_name']) && is_null($focus->contact_name)) {
  74. $focus->contact_name = $_REQUEST['contact_name'];
  75. }
  76. if (isset($_REQUEST['contact_id']) /* && is_null($focus->contact_id) */ ) {
  77. $focus->contact_id = $_REQUEST['contact_id'];
  78. }
  79. if (isset($_REQUEST['parent_name']) && is_null($focus->parent_name)) {
  80. $focus->parent_name = $_REQUEST['parent_name'];
  81. }
  82. if (isset($_REQUEST['parent_id']) /* && is_null($focus->parent_id) */ ) {
  83. $focus->parent_id = $_REQUEST['parent_id'];
  84. }
  85. if (isset($_REQUEST['parent_type'])) {
  86. $focus->parent_type = $_REQUEST['parent_type'];
  87. }
  88. elseif (!isset($focus->parent_type)) {
  89. $focus->parent_type = $app_list_strings['record_type_default_key'];
  90. }
  91. $theme_path="themes/".$theme."/";
  92. $image_path=$theme_path."images/";
  93. $disp_view = getView($focus->mode);
  94. if($disp_view == 'edit_view')
  95. $smarty->assign("BLOCKS",getBlocks($currentModule,$disp_view,$mode,$focus->column_fields));
  96. else
  97. {
  98. $smarty->assign("BASBLOCKS",getBlocks($currentModule,$disp_view,$mode,$focus->column_fields,'BAS'));
  99. }
  100. $smarty->assign("OP_MODE",$disp_view);
  101. $category = getParentTab();
  102. $smarty->assign("CATEGORY",$category);
  103. $log->info("Document detail view");
  104. $smarty->assign("MOD", $mod_strings);
  105. $smarty->assign("APP", $app_strings);
  106. $smarty->assign("MODULE",$currentModule);
  107. $smarty->assign("SINGLE_MOD",'Document');
  108. //Display the RTE or not? -- configure $USE_RTE in config.php
  109. $USE_RTE = vt_hasRTE();
  110. if(getFieldVisibilityPermission('Documents',$current_user->id,'notecontent') != '0')
  111. $USE_RTE = false;
  112. $smarty->assign("USE_RTE",$USE_RTE);
  113. if (isset($focus->name))
  114. $smarty->assign("NAME", $focus->name);
  115. else
  116. $smarty->assign("NAME", "");
  117. if($focus->mode == 'edit')
  118. {
  119. $smarty->assign("UPDATEINFO",updateInfo($focus->id));
  120. $smarty->assign("MODE", $focus->mode);
  121. }
  122. else
  123. {
  124. $smarty->assign("MODE",'create');
  125. }
  126. $smarty->assign('CREATEMODE', vtlib_purify($_REQUEST['createmode']));
  127. if (isset($_REQUEST['return_module']))
  128. $smarty->assign("RETURN_MODULE", vtlib_purify($_REQUEST['return_module']));
  129. else
  130. $smarty->assign("RETURN_MODULE","Documents");
  131. if (isset($_REQUEST['return_action']))
  132. $smarty->assign("RETURN_ACTION", vtlib_purify($_REQUEST['return_action']));
  133. else
  134. $smarty->assign("RETURN_ACTION","index");
  135. if (isset($_REQUEST['return_id']))
  136. $smarty->assign("RETURN_ID", vtlib_purify($_REQUEST['return_id']));
  137. if (isset($_REQUEST['email_id']))
  138. $smarty->assign("EMAILID", vtlib_purify($_REQUEST['email_id']));
  139. if (isset($_REQUEST['ticket_id'])) $smarty->assign("TICKETID", vtlib_purify($_REQUEST['ticket_id']));
  140. if (isset($_REQUEST['fileid']))
  141. $smarty->assign("FILEID", vtlib_purify($_REQUEST['fileid']));
  142. if (isset($_REQUEST['record']))
  143. {
  144. $smarty->assign("CANCELACTION", "DetailView");
  145. }
  146. else
  147. {
  148. $smarty->assign("CANCELACTION", "index");
  149. }
  150. if (isset($_REQUEST['return_viewname']))
  151. $smarty->assign("RETURN_VIEWNAME", vtlib_purify($_REQUEST['return_viewname']));
  152. $smarty->assign("THEME", $theme);
  153. $smarty->assign("IMAGE_PATH", $image_path);
  154. $smarty->assign("PRINT_URL", "phprint.php?jt=".session_id().$GLOBALS['request_string']);
  155. $smarty->assign("ID", $focus->id);
  156. $smarty->assign("OLD_ID", $old_id );
  157. if ( empty($focus->filename))
  158. {
  159. $smarty->assign("FILENAME_TEXT", "");
  160. $smarty->assign("FILENAME", "");
  161. }
  162. else
  163. {
  164. $smarty->assign("FILENAME_TEXT", "(".$focus->filename.")");
  165. $smarty->assign("FILENAME", $focus->filename);
  166. }
  167. if (isset($focus->parent_type) && $focus->parent_type != "") {
  168. $change_parent_button = "<input title='".$app_strings['LBL_CHANGE_BUTTON_TITLE']."' accessKey='".$app_strings['LBL_CHANGE_BUTTON_KEY']."' vtiger_tabindex='3' type='button' class='button' value='".$app_strings['LBL_CHANGE_BUTTON_LABEL']."' name='button' LANGUAGE=javascript onclick='return window.open(\"index.php?module=\"+ document.EditView.parent_type.value + \"&action=Popup&html=Popup_picker&form=TasksEditView\",\"test\",\"width=600,height=400,resizable=1,scrollbars=1\");'>";
  169. $smarty->assign("CHANGE_PARENT_BUTTON", $change_parent_button);
  170. }
  171. if ($focus->parent_type == "Account") $smarty->assign("DEFAULT_SEARCH", "&query=true&account_id=$focus->parent_id&account_name=".urlencode($focus->parent_name));
  172. $check_button = Button_Check($module);
  173. $smarty->assign("CHECK", $check_button);
  174. $smarty->assign("CALENDAR_LANG", $app_strings['LBL_JSCALENDAR_LANG']);
  175. $tabid = getTabid("Documents");
  176. $validationData = getDBValidationData($focus->tab_name,$tabid);
  177. $data = split_validationdataArray($validationData);
  178. $smarty->assign("VALIDATION_DATA_FIELDNAME",$data['fieldname']);
  179. $smarty->assign("VALIDATION_DATA_FIELDDATATYPE",$data['datatype']);
  180. $smarty->assign("VALIDATION_DATA_FIELDLABEL",$data['fieldlabel']);
  181. $smarty->assign("DUPLICATE",vtlib_purify($_REQUEST['isDuplicate']));
  182. global $adb;
  183. // Module Sequence Numbering
  184. $mod_seq_field = getModuleSequenceField($currentModule);
  185. if($focus->mode != 'edit' && $mod_seq_field != null) {
  186. $autostr = getTranslatedString('MSG_AUTO_GEN_ON_SAVE');
  187. $mod_seq_string = $adb->pquery("SELECT prefix, cur_id from vtiger_modentity_num where semodule = ? and active=1",array($currentModule));
  188. $mod_seq_prefix = $adb->query_result($mod_seq_string,0,'prefix');
  189. $mod_seq_no = $adb->query_result($mod_seq_string,0,'cur_id');
  190. if($adb->num_rows($mod_seq_string) == 0 || $focus->checkModuleSeqNumber($focus->table_name, $mod_seq_field['column'], $mod_seq_prefix.$mod_seq_no))
  191. echo '<br><font color="#FF0000"><b>'. getTranslatedString('LBL_DUPLICATE'). ' '. getTranslatedString($mod_seq_field['label'])
  192. .' - '. getTranslatedString('LBL_CLICK') .' <a href="index.php?module=Settings&action=CustomModEntityNo&parenttab=Settings&selmodule='.$currentModule.'">'.getTranslatedString('LBL_HERE').'</a> '
  193. . getTranslatedString('LBL_TO_CONFIGURE'). ' '. getTranslatedString($mod_seq_field['label']) .'</b></font>';
  194. else
  195. $smarty->assign("MOD_SEQ_ID",$autostr);
  196. } else {
  197. $smarty->assign("MOD_SEQ_ID", $focus->column_fields[$mod_seq_field['name']]);
  198. }
  199. // END
  200. // Gather the help information associated with fields
  201. $smarty->assign('FIELDHELPINFO', vtlib_getFieldHelpInfo($currentModule));
  202. // END
  203. $picklistDependencyDatasource = Vtiger_DependencyPicklist::getPicklistDependencyDatasource($currentModule);
  204. $smarty->assign("PICKIST_DEPENDENCY_DATASOURCE", Zend_Json::encode($picklistDependencyDatasource));
  205. if($focus->mode == 'edit')
  206. $smarty->display("salesEditView.tpl");
  207. else
  208. $smarty->display("CreateView.tpl");
  209. ?>