コード例 #1
0
ファイル: CrmTask.class.php プロジェクト: Cloudrexx/cloudrexx
 /**
  * add /edit task
  *
  * @global array $_ARRAYLANG
  * @global object $objDatabase
  * @return true
  */
 public function _modifyTask()
 {
     global $_ARRAYLANG, $objDatabase, $objJs, $objFWUser;
     \JS::registerCSS("modules/Crm/View/Style/contact.css");
     if (gettype($objFWUser) === 'NULL') {
         $objFWUser = \FWUser::getFWUserObject();
     }
     $objtpl = $this->_objTpl;
     $_SESSION['pageTitle'] = empty($_GET['id']) ? $_ARRAYLANG['TXT_CRM_ADDTASK'] : $_ARRAYLANG['TXT_CRM_EDITTASK'];
     $this->_objTpl->loadTemplateFile('module_' . $this->moduleNameLC . '_addtasks.html');
     $objtpl->setGlobalVariable("MODULE_NAME", $this->moduleName);
     $settings = $this->getSettings();
     $id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : '';
     $date = date('Y-m-d H:i:s');
     $title = isset($_POST['taskTitle']) ? contrexx_input2raw($_POST['taskTitle']) : '';
     $type = isset($_POST['taskType']) ? (int) $_POST['taskType'] : 0;
     $customer = isset($_REQUEST['customerId']) ? (int) $_REQUEST['customerId'] : '';
     $duedate = isset($_POST['date']) ? $_POST['date'] : $date;
     $assignedto = isset($_POST['assignedto']) ? intval($_POST['assignedto']) : 0;
     $description = isset($_POST['description']) ? contrexx_input2raw($_POST['description']) : '';
     $notify = isset($_POST['notify']);
     $taskId = isset($_REQUEST['searchType']) ? intval($_REQUEST['searchType']) : 0;
     $taskTitle = isset($_REQUEST['searchTitle']) ? contrexx_input2raw($_REQUEST['searchTitle']) : '';
     $redirect = isset($_REQUEST['redirect']) ? $_REQUEST['redirect'] : base64_encode('&act=task');
     // check permission
     if (!empty($id)) {
         $objResult = $objDatabase->Execute("SELECT `added_by`,\n                                                       `assigned_to`\n                                                    FROM `" . DBPREFIX . "module_{$this->moduleNameLC}_task`\n                                                 WHERE `id` = '{$id}'\n                                               ");
         $added_user = (int) $objResult->fields['added_by'];
         $assigned_user = (int) $objResult->fields['assigned_to'];
         if ($objResult) {
             list($task_edit_permission) = $this->getTaskPermission($added_user, $assigned_user);
             if (!$task_edit_permission) {
                 \Permission::noAccess();
             }
         }
     }
     if (isset($_POST['addtask'])) {
         if (!empty($id)) {
             if ($objFWUser->objUser->getAdminStatus() || $added_user == $objFWUser->objUser->getId() || $assigned_user == $assignedto) {
                 $fields = array('task_title' => $title, 'task_type_id' => $type, 'customer_id' => $customer, 'due_date' => $duedate, 'assigned_to' => $assignedto, 'description' => $description);
                 $query = \SQL::update("module_{$this->moduleNameLC}_task", $fields, array('escape' => true)) . " WHERE `id` = {$id}";
                 $_SESSION['strOkMessage'] = $_ARRAYLANG['TXT_CRM_TASK_UPDATE_MESSAGE'];
             } else {
                 $_SESSION['strErrMessage'] = $_ARRAYLANG['TXT_CRM_TASK_RESPONSIBLE_ERR'];
             }
         } else {
             $addedDate = date('Y-m-d H:i:s');
             $fields = array('task_title' => $title, 'task_type_id' => $type, 'customer_id' => $customer, 'due_date' => $duedate, 'assigned_to' => $assignedto, 'added_by' => $objFWUser->objUser->getId(), 'added_date_time' => $addedDate, 'task_status' => '0', 'description' => $description);
             $query = \SQL::insert("module_{$this->moduleNameLC}_task", $fields, array('escape' => true));
             $_SESSION['strOkMessage'] = $_ARRAYLANG['TXT_CRM_TASK_OK_MESSAGE'];
         }
         $db = $objDatabase->Execute($query);
         if ($db) {
             if ($notify) {
                 $cx = \Cx\Core\Core\Controller\Cx::instanciate();
                 $id = !empty($id) ? $id : $objDatabase->INSERT_ID();
                 $info['substitution'] = array('CRM_ASSIGNED_USER_NAME' => contrexx_raw2xhtml(\FWUser::getParsedUserTitle($assignedto)), 'CRM_ASSIGNED_USER_EMAIL' => $objFWUser->objUser->getUser($assignedto)->getEmail(), 'CRM_DOMAIN' => ASCMS_PROTOCOL . "://{$_SERVER['HTTP_HOST']}" . $cx->getCodeBaseOffsetPath(), 'CRM_TASK_NAME' => $title, 'CRM_TASK_LINK' => "<a href='" . ASCMS_PROTOCOL . "://{$_SERVER['HTTP_HOST']}" . $cx->getCodeBaseOffsetPath() . $cx->getBackendFolderName() . "/index.php?cmd=" . $this->moduleName . "&act=task&tpl=modify&id={$id}'>{$title}</a>", 'CRM_TASK_URL' => ASCMS_PROTOCOL . "://{$_SERVER['HTTP_HOST']}" . $cx->getCodeBaseOffsetPath() . $cx->getBackendFolderName() . "/index.php?cmd=" . $this->moduleName . "&act=task&tpl=modify&id={$id}", 'CRM_TASK_DUE_DATE' => $duedate, 'CRM_TASK_CREATED_USER' => contrexx_raw2xhtml(\FWUser::getParsedUserTitle($objFWUser->objUser->getId())), 'CRM_TASK_DESCRIPTION_TEXT_VERSION' => contrexx_html2plaintext($description), 'CRM_TASK_DESCRIPTION_HTML_VERSION' => $description);
                 //setting email template lang id
                 $availableMailTempLangAry = $this->getActiveEmailTemLangId('Crm', CRM_EVENT_ON_TASK_CREATED);
                 $availableLangId = $this->getEmailTempLang($availableMailTempLangAry, $objFWUser->objUser->getUser($assignedto)->getEmail());
                 $info['lang_id'] = $availableLangId;
                 $dispatcher = CrmEventDispatcher::getInstance();
                 $dispatcher->triggerEvent(CRM_EVENT_ON_TASK_CREATED, null, $info);
             }
             \Cx\Core\Csrf\Controller\Csrf::header("Location:./index.php?cmd=" . $this->moduleName . base64_decode($redirect));
             exit;
         }
     } elseif (!empty($id)) {
         $objValue = $objDatabase->Execute("SELECT task_id,\n                                                            task_title,\n                                                            task_type_id,\n                                                            due_date,\n                                                            assigned_to,\n                                                            description,\n                                                            c.id,\n                                                            c.customer_name,\n                                                            c.contact_familyname\n                                                       FROM `" . DBPREFIX . "module_{$this->moduleNameLC}_task` AS t\n                                                       LEFT JOIN `" . DBPREFIX . "module_{$this->moduleNameLC}_contacts` AS c\n                                                            ON t.customer_id = c.id\n                                                       WHERE t.id='{$id}'");
         $title = $objValue->fields['task_title'];
         $type = $objValue->fields['task_type_id'];
         $customer = $objValue->fields['id'];
         $customerName = !empty($objValue->fields['customer_name']) ? $objValue->fields['customer_name'] . " " . $objValue->fields['contact_familyname'] : '';
         $duedate = $objValue->fields['due_date'];
         $assignedto = $objValue->fields['assigned_to'];
         $description = $objValue->fields['description'];
         $taskAutoId = $objValue->fields['task_id'];
     }
     $this->_getResourceDropDown('Members', $assignedto, $settings['emp_default_user_group']);
     $this->taskTypeDropDown($objtpl, $type);
     if (!empty($customer)) {
         // Get customer Name
         $objCustomer = $objDatabase->Execute("SELECT customer_name, contact_familyname  FROM `" . DBPREFIX . "module_crm_contacts` WHERE id = {$customer}");
         $customerName = $objCustomer->fields['customer_name'] . " " . $objCustomer->fields['contact_familyname'];
     }
     $objtpl->setVariable(array('CRM_LOGGED_USER_ID' => $objFWUser->objUser->getId(), 'CRM_TASK_AUTOID' => contrexx_raw2xhtml($taskAutoId), 'CRM_TASK_ID' => (int) $id, 'CRM_TASKTITLE' => contrexx_raw2xhtml($title), 'CRM_DUE_DATE' => contrexx_raw2xhtml($duedate), 'CRM_CUSTOMER_ID' => intval($customer), 'CRM_CUSTOMER_NAME' => contrexx_raw2xhtml($customerName), 'CRM_TASK_DESC' => new \Cx\Core\Wysiwyg\Wysiwyg('description', contrexx_raw2xhtml($description)), 'CRM_BACK_LINK' => base64_decode($redirect), 'TXT_CRM_ADD_TASK' => empty($id) ? $_ARRAYLANG['TXT_CRM_ADD_TASK'] : $_ARRAYLANG['TXT_CRM_EDITTASK'], 'TXT_CRM_TASK_ID' => $_ARRAYLANG['TXT_CRM_TASK_ID'], 'TXT_CRM_TASK_TITLE' => $_ARRAYLANG['TXT_CRM_TASK_TITLE'], 'TXT_CRM_TASK_TYPE' => $_ARRAYLANG['TXT_CRM_TASK_TYPE'], 'TXT_CRM_SELECT_TASK_TYPE' => $_ARRAYLANG['TXT_CRM_SELECT_TASK_TYPE'], 'TXT_CRM_CUSTOMER_NAME' => $_ARRAYLANG['TXT_CRM_CUSTOMER_NAME'], 'TXT_CRM_TASK_DUE_DATE' => $_ARRAYLANG['TXT_CRM_TASK_DUE_DATE'], 'TXT_CRM_TASK_RESPONSIBLE' => $_ARRAYLANG['TXT_CRM_TASK_RESPONSIBLE'], 'TXT_CRM_SELECT_MEMBER_NAME' => $_ARRAYLANG['TXT_CRM_SELECT_MEMBER_NAME'], 'TXT_CRM_OVERVIEW' => $_ARRAYLANG['TXT_CRM_OVERVIEW'], 'TXT_CRM_TASK_DESCRIPTION' => $_ARRAYLANG['TXT_CRM_TASK_DESCRIPTION'], 'TXT_CRM_FIND_COMPANY_BY_NAME' => $_ARRAYLANG['TXT_CRM_FIND_COMPANY_BY_NAME'], 'TXT_CRM_SAVE' => $_ARRAYLANG['TXT_CRM_SAVE'], 'TXT_CRM_BACK' => $_ARRAYLANG['TXT_CRM_BACK'], 'TXT_CRM_NOTIFY' => $_ARRAYLANG['TXT_CRM_NOTIFY'], 'TXT_CRM_MANDATORY_FIELDS_NOT_FILLED_OUT' => $_ARRAYLANG['TXT_CRM_MANDATORY_FIELDS_NOT_FILLED_OUT']));
 }
コード例 #2
0
 /**
  * notify the staffs regarding the account modification of a contact
  *
  * @param Integer $customerId    customer id
  * @param String  $first_name customer first name
  * @param String  $last_name customer last name
  *
  * @access public
  * @global object $objTemplate
  * @global array  $_ARRAYLANG
  *
  * @return null
  */
 public function notifyStaffOnContactAccModification($customerId = 0, $first_name = '', $last_name = '', $gender = 0)
 {
     global $objDatabase, $_ARRAYLANG;
     if (empty($customerId)) {
         return false;
     }
     $objFWUser = \FWUser::getFWUserObject();
     $settings = $this->getSettings();
     $resources = $this->getResources($settings['emp_default_user_group']);
     $customer_name = $first_name . " " . $last_name;
     $contact_gender = $gender == 1 ? "gender_female" : ($gender == 2 ? "gender_male" : 'gender_undefined');
     $emailIds = array();
     foreach ($resources as $key => $value) {
         $emailIds[] = $value['email'];
     }
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     foreach ($emailIds as $emails) {
         if (!empty($emails)) {
             $objUsers = $objFWUser->objUser->getUsers($filter = array('email' => addslashes($emails)));
             $info['substitution'] = array('CRM_ASSIGNED_USER_NAME' => contrexx_raw2xhtml(\FWUser::getParsedUserTitle($objUsers->getId())), 'CRM_ASSIGNED_USER_EMAIL' => $emails, 'CRM_CONTACT_FIRSTNAME' => contrexx_raw2xhtml($first_name), 'CRM_CONTACT_LASTNAME' => contrexx_raw2xhtml($last_name), 'CRM_CONTACT_GENDER' => contrexx_raw2xhtml($contact_gender), 'CRM_DOMAIN' => ASCMS_PROTOCOL . "://{$_SERVER['HTTP_HOST']}" . $cx->getCodeBaseOffsetPath(), 'CRM_CONTACT_DETAILS_URL' => ASCMS_PROTOCOL . "://{$_SERVER['HTTP_HOST']}" . $cx->getCodeBaseOffsetPath() . $cx->getBackendFolderName() . "/index.php?cmd=" . $this->moduleName . "&act=customers&tpl=showcustdetail&id={$customerId}", 'CRM_CONTACT_DETAILS_LINK' => "<a href='" . ASCMS_PROTOCOL . "://{$_SERVER['HTTP_HOST']}" . $cx->getCodeBaseOffsetPath() . $cx->getBackendFolderName() . "/index.php?cmd=" . $this->moduleName . "&act=customers&tpl=showcustdetail&id={$customerId}'>" . $customer_name . "</a>");
             //setting email template lang id
             $availableMailTempLangAry = $this->getActiveEmailTemLangId('Crm', CRM_EVENT_ON_ACCOUNT_UPDATED);
             $availableLangId = $this->getEmailTempLang($availableMailTempLangAry, $emails);
             $info['lang_id'] = $availableLangId;
             $dispatcher = CrmEventDispatcher::getInstance();
             $dispatcher->triggerEvent(CRM_EVENT_ON_ACCOUNT_UPDATED, null, $info);
         }
     }
 }
コード例 #3
0
 /**
  * PHP5 constructor
  *
  * @global object $objTemplate
  * @global array $_ARRAYLANG
  */
 public function __construct($name)
 {
     global $objTemplate, $_ARRAYLANG, $objJs;
     parent::__construct($name);
     $objJs = new CrmJavascript();
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     $this->_mediaPath = $cx->getWebsiteMediaCrmPath();
     $this->_objTpl = new \Cx\Core\Html\Sigma($cx->getCodeBaseModulePath() . '/' . $this->moduleName . '/View/Template/Backend');
     \Cx\Core\Csrf\Controller\Csrf::add_placeholder($this->_objTpl);
     $this->_objTpl->setErrorHandling(PEAR_ERROR_DIE);
     $this->act = $_REQUEST['act'];
     $contentNavigation = '';
     if (\Permission::checkAccess($this->customerAccessId, 'static', true)) {
         $contentNavigation .= "<a href='index.php?cmd=" . $this->moduleName . "&act=customers' class='" . ($this->act == 'customers' ? 'active' : '') . "'  title='" . $_ARRAYLANG['TXT_CRM_CUSTOMERS'] . "'>{$_ARRAYLANG['TXT_CRM_CUSTOMERS']}</a>";
     }
     $contentNavigation .= "<a href='index.php?cmd=" . $this->moduleName . "&act=task' class='" . ($this->act == 'task' ? 'active' : '') . "' title='{$_ARRAYLANG['TXT_CRM_TASKS']}'>{$_ARRAYLANG['TXT_CRM_TASKS']}</a>\n             <a href='index.php?cmd=" . $this->moduleName . "&act=deals' class='" . ($this->act == 'deals' ? 'active' : '') . "' title='{$_ARRAYLANG['TXT_CRM_OPPORTUNITY']}'>{$_ARRAYLANG['TXT_CRM_OPPORTUNITY']}</a>";
     if (\Permission::checkAccess($this->adminAccessId, 'static', true)) {
         $contentNavigation .= "<a href='index.php?cmd=" . $this->moduleName . "&act=settings' class='" . ($this->act == 'settings' || $this->act == 'mailtemplate_overview' || $this->act == 'mailtemplate_edit' ? 'active' : '') . "' title='" . $_ARRAYLANG['TXT_CRM_SETTINGS'] . "'>" . $_ARRAYLANG['TXT_CRM_SETTINGS'] . "</a>";
     }
     $objTemplate->setVariable("CONTENT_NAVIGATION", $contentNavigation);
     $dispatcher = CrmEventDispatcher::getInstance();
     $default_handler = new \Cx\Modules\Crm\Model\Events\CrmDefaultEventHandler();
     $dispatcher->addHandler(CRM_EVENT_ON_USER_ACCOUNT_CREATED, $default_handler);
     $dispatcher->addHandler(CRM_EVENT_ON_TASK_CREATED, $default_handler);
     $dispatcher->addHandler(CRM_EVENT_ON_ACCOUNT_UPDATED, $default_handler);
     $this->_initCrmModule();
 }