first commit

This commit is contained in:
BACHIR SOULDI
2025-09-28 08:49:37 +01:00
commit 2794e62571
16819 changed files with 2664196 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
<?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.
*************************************************************************************/
class Leads_ConvertLead_View extends Vtiger_Index_View {
function checkPermission(Vtiger_Request $request) {
$moduleName = $request->getModule();
$moduleModel = Vtiger_Module_Model::getInstance($moduleName);
$currentUserPriviligesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
if(!$currentUserPriviligesModel->hasModuleActionPermission($moduleModel->getId(), 'ConvertLead')) {
throw new AppException(vtranslate('LBL_PERMISSION_DENIED', $moduleName));
}
}
function process(Vtiger_Request $request) {
$currentUserPriviligeModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
$viewer = $this->getViewer($request);
$recordId = $request->get('record');
$moduleName = $request->getModule();
$recordModel = Vtiger_Record_Model::getInstanceById($recordId);
$imageDetails = $recordModel->getImageDetails();
if(count($imageDetails)) {
$imageAttachmentId = $imageDetails[0]['id'];
$viewer->assign('IMAGE_ATTACHMENT_ID', $imageAttachmentId);
}
$moduleModel = $recordModel->getModule();
$viewer->assign('MODULE', $moduleName);
$viewer->assign('USER_MODEL', Users_Record_Model::getCurrentUserModel());
$viewer->assign('CURRENT_USER_PRIVILEGE', $currentUserPriviligeModel);
$viewer->assign('RECORD', $recordModel);
$viewer->assign('CONVERT_LEAD_FIELDS', $recordModel->getConvertLeadFields());
$assignedToFieldModel = $moduleModel->getField('assigned_user_id');
$assignedToFieldModel->set('fieldvalue', $recordModel->get('assigned_user_id'));
$viewer->assign('ASSIGN_TO', $assignedToFieldModel);
$potentialModuleModel = Vtiger_Module_Model::getInstance('Potentials');
$accountField = Vtiger_Field_Model::getInstance('related_to', $potentialModuleModel);
$contactField = Vtiger_Field_Model::getInstance('contact_id', $potentialModuleModel);
$viewer->assign('ACCOUNT_FIELD_MODEL', $accountField);
$viewer->assign('CONTACT_FIELD_MODEL', $contactField);
$contactsModuleModel = Vtiger_Module_Model::getInstance('Contacts');
$accountField = Vtiger_Field_Model::getInstance('account_id', $contactsModuleModel);
$viewer->assign('CONTACT_ACCOUNT_FIELD_MODEL', $accountField);
$viewer->view('ConvertLead.tpl', $moduleName);
}
}

View File

@@ -0,0 +1,14 @@
<?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.
* *********************************************************************************** */
class Leads_Detail_View extends Accounts_Detail_View {
}

View File

@@ -0,0 +1,40 @@
<?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.
* *********************************************************************************** */
class Leads_Edit_View extends Vtiger_Edit_View {
public function process(Vtiger_Request $request) {
$moduleName = $request->getModule();
$recordId = $request->get('record');
$recordModel = $this->record;
if(!$recordModel){
if (!empty($recordId)) {
$recordModel = Vtiger_Record_Model::getInstanceById($recordId, $moduleName);
} else {
$recordModel = Vtiger_Record_Model::getCleanInstance($moduleName);
}
}
$viewer = $this->getViewer($request);
$salutationFieldModel = Vtiger_Field_Model::getInstance('salutationtype', $recordModel->getModule());
$salutationValue = $request->get('salutationtype');
if(!empty($salutationValue)){
$salutationFieldModel->set('fieldvalue', $salutationValue);
} else{
$salutationFieldModel->set('fieldvalue', $recordModel->get('salutationtype'));
}
$viewer->assign('SALUTATION_FIELD_MODEL', $salutationFieldModel);
parent::process($request);
}
}

View File

@@ -0,0 +1,12 @@
<?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.
*************************************************************************************/
class Leads_QuickCreateAjax_View extends Contacts_QuickCreateAjax_View {
}

View File

@@ -0,0 +1,122 @@
<?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.
*************************************************************************************/
vimport('~~/include/Webservices/ConvertLead.php');
class Leads_SaveConvertLead_View extends Vtiger_View_Controller {
function checkPermission(Vtiger_Request $request) {
$moduleName = $request->getModule();
$moduleModel = Vtiger_Module_Model::getInstance($moduleName);
$currentUserPrivilegesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
if(!$currentUserPrivilegesModel->hasModuleActionPermission($moduleModel->getId(), 'ConvertLead')) {
throw new AppException(vtranslate('LBL_CONVERT_LEAD_PERMISSION_DENIED', $moduleName));
}
}
public function process(Vtiger_Request $request) {
$recordId = $request->get('record');
$modules = $request->get('modules');
$assignId = $request->get('assigned_user_id');
$currentUser = Users_Record_Model::getCurrentUserModel();
$entityValues = array();
$entityValues['transferRelatedRecordsTo'] = $request->get('transferModule');
$entityValues['assignedTo'] = vtws_getWebserviceEntityId(vtws_getOwnerType($assignId), $assignId);
$entityValues['leadId'] = vtws_getWebserviceEntityId($request->getModule(), $recordId);
$entityValues['imageAttachmentId'] = $request->get('imageAttachmentId');
$recordModel = Vtiger_Record_Model::getInstanceById($recordId, $request->getModule());
$convertLeadFields = $recordModel->getConvertLeadFields();
$availableModules = array('Accounts', 'Contacts', 'Potentials');
foreach ($availableModules as $module) {
if(vtlib_isModuleActive($module)&& in_array($module, $modules)) {
$entityValues['entities'][$module]['create'] = true;
$entityValues['entities'][$module]['name'] = $module;
// Converting lead should save records source as CRM instead of WEBSERVICE
$entityValues['entities'][$module]['source'] = 'CRM';
foreach ($convertLeadFields[$module] as $fieldModel) {
$fieldName = $fieldModel->getName();
$fieldValue = $request->get($fieldName);
//Potential Amount Field value converting into DB format
if ($fieldModel->getFieldDataType() === 'currency') {
if($fieldModel->get('uitype') == 72){
// Some of the currency fields like Unit Price, Totoal , Sub-total - doesn't need currency conversion during save
$fieldValue = Vtiger_Currency_UIType::convertToDBFormat($fieldValue, null, true);
} else {
$fieldValue = Vtiger_Currency_UIType::convertToDBFormat($fieldValue);
}
} elseif ($fieldModel->getFieldDataType() === 'date') {
$fieldValue = DateTimeField::convertToDBFormat($fieldValue);
} elseif ($fieldModel->getFieldDataType() === 'reference' && $fieldValue) {
$ids = vtws_getIdComponents($fieldValue);
if (count($ids) === 1) {
$fieldValue = vtws_getWebserviceEntityId(getSalesEntityType($fieldValue), $fieldValue);
}
}
$entityValues['entities'][$module][$fieldName] = $fieldValue;
}
}
}
try {
$result = vtws_convertlead($entityValues, $currentUser);
} catch(Exception $e) {
$this->showError($request, $e);
exit;
}
if(!empty($result['Accounts'])) {
$accountIdComponents = vtws_getIdComponents($result['Accounts']);
$accountId = $accountIdComponents[1];
}
if(!empty($result['Contacts'])) {
$contactIdComponents = vtws_getIdComponents($result['Contacts']);
$contactId = $contactIdComponents[1];
}
if(!empty($accountId)) {
header("Location: index.php?view=Detail&module=Accounts&record=$accountId");
} elseif (!empty($contactId)) {
header("Location: index.php?view=Detail&module=Contacts&record=$contactId");
} else {
$this->showError($request);
exit;
}
}
function showError($request, $exception=false) {
$viewer = $this->getViewer($request);
$moduleName = $request->getModule();
$isDupicatesFailure = false;
if ($exception != false) {
$viewer->assign('EXCEPTION', $exception->getMessage());
if ($exception instanceof DuplicateException) {
$isDupicatesFailure = true;
$viewer->assign('EXCEPTION', $exception->getDuplicationMessage());
}
}
$currentUser = Users_Record_Model::getCurrentUserModel();
$viewer->assign('IS_DUPICATES_FAILURE', $isDupicatesFailure);
$viewer->assign('CURRENT_USER', $currentUser);
$viewer->assign('MODULE', $moduleName);
$viewer->view('ConvertLeadError.tpl', $moduleName);
}
public function validateRequest(Vtiger_Request $request) {
$request->validateWriteAccess();
}
}