示例#1
0
 /**
  * Send SMS (Creates SMS Entity record, links it with related CRM record and triggers provider to send sms)
  *
  * @param String $message
  * @param Array $tonumbers
  * @param Integer $ownerid User id to assign the SMS record
  * @param mixed $linktoids List of CRM record id to link SMS record
  * @param String $linktoModule Modulename of CRM record to link with (if not provided lookup it will be calculated)
  */
 static function sendsms($message, $tonumbers, $ownerid = false, $linktoids = false, $linktoModule = false)
 {
     global $current_user, $adb;
     if ($ownerid === false) {
         if (isset($current_user) && !empty($current_user)) {
             $ownerid = $current_user->id;
         } else {
             $ownerid = 1;
         }
     }
     $moduleName = 'SMSNotifier';
     $focus = CRMEntity::getInstance($moduleName);
     $focus->column_fields['message'] = $message;
     $focus->column_fields['assigned_user_id'] = $ownerid;
     $focus->save($moduleName);
     if ($linktoids !== false) {
         if ($linktoModule !== false) {
             relateEntities($focus, $moduleName, $focus->id, $linktoModule, $linktoids);
         } else {
             // Link modulename not provided (linktoids can belong to mix of module so determine proper modulename)
             $linkidsetypes = $adb->pquery("SELECT setype,crmid FROM vtiger_crmentity WHERE crmid IN (" . generateQuestionMarks($linktoids) . ")", array($linktoids));
             if ($linkidsetypes && $adb->num_rows($linkidsetypes)) {
                 while ($linkidsetypesrow = $adb->fetch_array($linkidsetypes)) {
                     relateEntities($focus, $moduleName, $focus->id, $linkidsetypesrow['setype'], $linkidsetypesrow['crmid']);
                 }
             }
         }
     }
     $responses = self::fireSendSMS($message, $tonumbers);
     $focus->processFireSendSMSResponse($responses);
 }
示例#2
0
function vtws_internal_setrelation($elementId, $moduleName, $withTheseIds)
{
    global $adb;
    if (!is_array($withTheseIds)) {
        $withTheseIds = array($withTheseIds);
    }
    $focus = CRMEntity::getInstance($moduleName);
    foreach ($withTheseIds as $withThisId) {
        list($withModuleId, $withElementId) = vtws_getIdComponents($withThisId);
        $withModuleName = $adb->query_result($adb->pquery('select name from vtiger_ws_entity where id=?', array($withModuleId)), 0, 0);
        relateEntities($focus, $moduleName, $elementId, $withModuleName, $withElementId);
    }
}
 function saveentity($module, $fileid = '')
 {
     global $current_user, $adb;
     //$adb added by raju for mass mailing
     $insertion_mode = $this->mode;
     $columnFields = $this->column_fields;
     $anyValue = false;
     foreach ($columnFields as $value) {
         if (!empty($value)) {
             $anyValue = true;
             break;
         }
     }
     if (!$anyValue) {
         die("<center>" . getTranslatedString('LBL_MANDATORY_FIELD_MISSING') . "</center>");
     }
     $this->db->println("TRANS saveentity starts {$module}");
     $this->db->startTransaction();
     foreach ($this->tab_name as $table_name) {
         if ($table_name == "vtiger_crmentity") {
             $this->insertIntoCrmEntity($module, $fileid);
         } else {
             $this->insertIntoEntityTable($table_name, $module, $fileid);
         }
     }
     //Calling the Module specific save code
     $this->save_module($module);
     $this->db->completeTransaction();
     $this->db->println("TRANS saveentity ends");
     // vtlib customization: Hook provide to enable generic module relation.
     if ($_REQUEST['createmode'] == 'link') {
         $for_module = vtlib_purify($_REQUEST['return_module']);
         $for_crmid = vtlib_purify($_REQUEST['return_id']);
         $with_module = $module;
         $with_crmid = $this->id;
         $on_focus = CRMEntity::getInstance($for_module);
         if ($for_module && $for_crmid && $with_module && $with_crmid) {
             relateEntities($on_focus, $for_module, $for_crmid, $with_module, $with_crmid);
         }
     }
     // END
 }
示例#4
0
$parenttab = getParentTab();
$forCRMRecord = vtlib_purify($_REQUEST['parentid']);
$mode = $_REQUEST['mode'];
if (isset($override_action)) {
    $action = $override_action;
} elseif ($singlepane_view == 'true') {
    $action = 'DetailView';
} else {
    $action = 'CallRelatedList';
}
$focus = CRMEntity::getInstance($currentModule);
if ($mode == 'delete') {
    // Split the string of ids
    $ids = explode(';', $idlist);
    if (!empty($ids)) {
        $focus->delete_related_module($currentModule, $forCRMRecord, $destinationModule, $ids);
    }
} else {
    if (!empty($_REQUEST['idlist'])) {
        // Split the string of ids
        $ids = explode(';', trim($idlist, ';'));
    } else {
        if (!empty($_REQUEST['entityid'])) {
            $ids = $_REQUEST['entityid'];
        }
    }
    if (!empty($ids)) {
        relateEntities($focus, $currentModule, $forCRMRecord, $destinationModule, $ids);
    }
}
header("Location: index.php?module={$currentModule}&record={$forCRMRecord}&action={$action}&parenttab={$parenttab}");
示例#5
0
 function saveentity($module, $fileid = '')
 {
     global $current_user, $adb;
     //$adb added by raju for mass mailing
     $insertion_mode = $this->mode;
     if (property_exists($module, 'HasDirectImageField') and $this->HasDirectImageField) {
         // we have to save these names to delete previous overwritten values in uitype 69 field
         $sql = 'SELECT tablename,columnname FROM vtiger_field WHERE uitype=69 and vtiger_field.tabid = ?';
         $tabid = getTabid($module);
         $result = $adb->pquery($sql, array($tabid));
         while ($finfo = $adb->fetch_array($result)) {
             $mrowrs = $adb->pquery('select ' . $finfo['columnname'] . ' from ' . $finfo['tablename'] . ' where ' . $this->tab_name_index[$finfo['tablename']] . '=?', array($this->id));
             $this->DirectImageFieldValues[$finfo['columnname']] = $adb->query_result($mrowrs, 0, 0);
         }
     }
     $columnFields = $this->column_fields;
     $anyValue = false;
     foreach ($columnFields as $value) {
         if (!empty($value)) {
             $anyValue = true;
             break;
         }
     }
     if (!$anyValue) {
         die("<center>" . getTranslatedString('LBL_MANDATORY_FIELD_MISSING') . "</center>");
     }
     $this->db->println("TRANS saveentity starts {$module}");
     $this->db->startTransaction();
     foreach ($this->tab_name as $table_name) {
         if ($table_name == "vtiger_crmentity") {
             $this->insertIntoCrmEntity($module, $fileid);
         } else {
             $this->insertIntoEntityTable($table_name, $module, $fileid);
         }
     }
     //Calling the Module specific save code
     $this->save_module($module);
     $this->db->completeTransaction();
     $this->db->println("TRANS saveentity ends");
     // vtlib customization: Hook provide to enable generic module relation.
     if (isset($_REQUEST['createmode']) and $_REQUEST['createmode'] == 'link') {
         $for_module = vtlib_purify($_REQUEST['return_module']);
         $for_crmid = vtlib_purify($_REQUEST['return_id']);
         $with_module = $module;
         $with_crmid = $this->id;
         $on_focus = CRMEntity::getInstance($for_module);
         if ($for_module && $for_crmid && $with_module && $with_crmid) {
             relateEntities($on_focus, $for_module, $for_crmid, $with_module, $with_crmid);
         }
     }
     // END
 }
示例#6
0
 public function addRelation($sourcerecordId, $destinationRecordId)
 {
     $sourceModule = $this->getParentModuleModel();
     $sourceModuleName = $sourceModule->get('name');
     $sourceModuleFocus = CRMEntity::getInstance($sourceModuleName);
     $destinationModuleName = $this->getRelationModuleModel()->get('name');
     relateEntities($sourceModuleFocus, $sourceModuleName, $sourcerecordId, $destinationModuleName, $destinationRecordId);
 }
 /**
  * Save messages from Vkontakte
  * @param $source_record
  * @param $source_module
  * @param $messages
  */
 static function saveVkMsg($source_record, $source_module, $messages)
 {
     global $current_user;
     $moduleName = 'SPSocialConnector';
     $focus = CRMEntity::getInstance($moduleName);
     foreach ($messages as $message) {
         $focus->column_fields['message'] = $message->body;
         $focus->column_fields['assigned_user_id'] = $current_user->id;
         $focus->column_fields['vk_message_id'] = $message->id;
         $date = new DateTime(date('c', $message->date));
         $focus->column_fields['message_datetime'] = $date->format('Y-m-d H:i:s');
         if ($message->out == 0) {
             $focus->column_fields['vk_status'] = 'Received';
             $focus->column_fields['type'] = 'Incoming';
         } else {
             $focus->column_fields['vk_status'] = 'Sent';
             $focus->column_fields['type'] = 'Outbound';
         }
         $focus->save($moduleName);
         relateEntities($focus, $moduleName, $focus->id, $source_module, $source_record);
     }
 }
示例#8
0
 function saveentity($module, $fileid = '')
 {
     global $current_user, $adb, $log;
     //$adb added by raju for mass mailing
     $log->debug("Entering CRMEntity::saveentity(" . $module . "," . $fileid . ") method ...");
     $insertion_mode = $this->mode;
     //echo "<pre>";print_r($this);echo "</pre>";
     $columnFields = $this->column_fields;
     //echo "<pre>";print_r($columnFields);echo "</pre>";
     $anyValue = false;
     foreach ($columnFields as $value) {
         if (!empty($value)) {
             $anyValue = true;
             break;
         }
     }
     if (!$anyValue) {
         die("<center>" . getTranslatedString('LBL_MANDATORY_FIELD_MISSING') . "</center>");
     }
     $this->db->println("TRANS saveentity starts {$module}");
     $this->db->startTransaction();
     foreach ($this->tab_name as $table_name) {
         if ($table_name == "vtiger_crmentity") {
             $this->insertIntoCrmEntity($module, $fileid);
         } else {
             $this->insertIntoEntityTable($table_name, $module, $fileid);
         }
     }
     //Calling the Module specific save code
     $this->save_module($module);
     $this->db->completeTransaction();
     $this->db->println("TRANS saveentity ends");
     // vtlib customization: Hook provide to enable generic module relation.
     if ($_REQUEST['createmode'] == 'link') {
         $for_module = vtlib_purify($_REQUEST['return_module']);
         $for_crmid = vtlib_purify($_REQUEST['return_id']);
         $with_module = $module;
         $with_crmid = $this->id;
         $on_focus = CRMEntity::getInstance($for_module);
         if ($for_module && $for_crmid && $with_module && $with_crmid) {
             relateEntities($on_focus, $for_module, $for_crmid, $with_module, $with_crmid);
         }
     }
     // END
     //150903大熊追加
     #		if(
     #			($module === 'SalesOrder' && $_POST['division'] === '202:Webコミュ' )
     #			 ||
     #			$module === 'Accounts'
     #			 ||
     #			$module === 'Contacts'
     #			 ||
     #			($module === 'Products' && $_POST['productcategory'] === 'SEO')
     #			 ||
     #			($module === 'Services' && $_POST['servicecategory'] === 'SEO')
     #		  ) $this->jas_save($module, $this->id);
     $log->debug("Exiting saveentity(" . $module . "," . $fileid . ") method ...");
 }
 * 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.
 *********************************************************************************/
require_once 'include/database/PearDatabase.php';
require_once 'user_privileges/default_module_view.php';
global $singlepane_view, $currentModule;
$idlist = vtlib_purify($_REQUEST['idlist']);
$dest_mod = vtlib_purify($_REQUEST['destination_module']);
$parenttab = vtlib_purify($_REQUEST['parenttab']);
$forCRMRecord = vtlib_purify($_REQUEST['parentid']);
if ($singlepane_view == 'true') {
    $action = "DetailView";
} else {
    $action = "CallRelatedList";
}
$storearray = array();
if (!empty($_REQUEST['idlist'])) {
    // Split the string of ids
    $storearray = explode(";", trim($idlist, ";"));
} else {
    if (!empty($_REQUEST['entityid'])) {
        $storearray = array($_REQUEST['entityid']);
    }
}
$focus = CRMEntity::getInstance($currentModule);
if (!empty($storearray)) {
    relateEntities($focus, $currentModule, $forCRMRecord, $dest_mod, $storearray);
}
header("Location: index.php?action={$action}&module={$currentModule}&record={$forCRMRecord}&parenttab={$parenttab}");
示例#10
0
/** 	function used to create ticket which has been created from customer portal
 * 	@param array $input_array - array which contains the following values
  => 	int $id - customer id
  int $sessionid - session id
  string $title - title of the ticket
  string $description - description of the ticket
  string $priority - priority of the ticket
  string $severity - severity of the ticket
  string $category - category of the ticket
  string $user_name - customer name
  int $parent_id - parent id ie., customer id as this customer is the parent for this ticket
  int $product_id - product id for the ticket
  string $module - module name where as based on this module we will get the module owner and assign this ticket to that corresponding user
 * 	return array - currently created ticket array, if this is not created then all tickets list will be returned
 */
function create_ticket($input_array)
{
    $adb = PearDatabase::getInstance();
    $log = vglobal('log');
    $adb->println("Inside customer portal function create_ticket");
    $adb->println($input_array);
    $id = $input_array['id'];
    $sessionid = $input_array['sessionid'];
    $title = $input_array['title'];
    $description = $input_array['description'];
    $priority = $input_array['priority'];
    $severity = $input_array['severity'];
    $category = $input_array['category'];
    $user_name = $input_array['user_name'];
    $parent_id = (int) $input_array['parent_id'];
    $product_id = (int) $input_array['product_id'];
    $module = $input_array['module'];
    //$assigned_to = $input_array['assigned_to'];
    $servicecontractid = (int) $input_array['serviceid'];
    $projectid = (int) $input_array['projectid'];
    if (!validateSession($id, $sessionid)) {
        return null;
    }
    $ticket = CRMEntity::getInstance('HelpDesk');
    $ticket->column_fields[ticket_title] = vtlib_purify($title);
    $ticket->column_fields[description] = vtlib_purify($description);
    $ticket->column_fields[ticketpriorities] = $priority;
    $ticket->column_fields[ticketseverities] = $severity;
    $ticket->column_fields[ticketcategories] = $category;
    $ticket->column_fields[ticketstatus] = 'Open';
    $ticket->column_fields[product_id] = $product_id;
    if ($servicecontractid != 0) {
        $ticket->column_fields[servicecontractsid] = $servicecontractid;
    }
    if ($projectid != 0) {
        $ticket->column_fields[projectid] = $projectid;
    }
    $defaultAssignee = getDefaultAssigneeId();
    $ticket->column_fields['assigned_user_id'] = $defaultAssignee;
    $ticket->column_fields['from_portal'] = 1;
    $accountResult = $adb->pquery('SELECT parentid FROM vtiger_contactdetails WHERE contactid = ?', array($parent_id));
    $accountId = $adb->query_result($accountResult, 0, 'parentid');
    if (!empty($accountId)) {
        $ticket->column_fields['parent_id'] = $accountId;
    }
    $ticket->save('HelpDesk');
    relateEntities($ticket, 'HelpDesk', $ticket->id, 'Contacts', $parent_id);
    $ticketresult = $adb->pquery("select vtiger_troubletickets.ticketid from vtiger_troubletickets\n\t\tinner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_troubletickets.ticketid inner join vtiger_ticketcf on vtiger_ticketcf.ticketid = vtiger_troubletickets.ticketid\n\t\twhere vtiger_crmentity.deleted=0 and vtiger_troubletickets.ticketid = ?", array($ticket->id));
    if ($adb->num_rows($ticketresult) == 1) {
        $record_save = 1;
        $record_array[0]['new_ticket']['ticketid'] = $adb->query_result($ticketresult, 0, 'ticketid');
    }
    if ($record_save == 1) {
        $adb->println("Ticket from Portal is saved with id => " . $ticket->id);
        return $record_array;
    } else {
        $adb->println("There may be error in saving the ticket.");
        return null;
    }
}
示例#11
0
 * 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.
 * Contributor(s): mmbrich
 ********************************************************************************/
require_once 'modules/CustomView/CustomView.php';
require_once 'user_privileges/default_module_view.php';
global $currentModule, $current_user;
$queryGenerator = new QueryGenerator(vtlib_purify($_REQUEST["list_type"]), $current_user);
if ($_REQUEST["cvid"] != "0") {
    $queryGenerator->initForCustomViewById(vtlib_purify($_REQUEST["cvid"]));
} else {
    $queryGenerator->initForDefaultCustomView();
}
$rs = $adb->query($queryGenerator->getQuery());
if ($_REQUEST["list_type"] == "Leads") {
    $reltable = "vtiger_campaignleadrel";
    $relid = "leadid";
} elseif ($_REQUEST["list_type"] == "Contacts") {
    $reltable = "vtiger_campaigncontrel";
    $relid = "contactid";
} elseif ($_REQUEST["list_type"] == "Accounts") {
    $reltable = "vtiger_campaignaccountrel";
    $relid = "accountid";
}
$focus = CRMEntity::getInstance($currentModule);
while ($row = $adb->fetch_array($rs)) {
    relateEntities($focus, $currentModule, vtlib_purify($_REQUEST['return_id']), vtlib_purify($_REQUEST["list_type"]), $row[$relid]);
}
header("Location: index.php?module=Campaigns&action=CampaignsAjax&file=CallRelatedList&ajax=true&" . "record=" . vtlib_purify($_REQUEST['return_id']));
示例#12
0
 function saveentity($module, $fileid = '')
 {
     $insertion_mode = $this->mode;
     $columnFields = $this->column_fields;
     $anyValue = false;
     foreach ($columnFields as $value) {
         if (!empty($value)) {
             $anyValue = true;
             break;
         }
     }
     if (!$anyValue) {
         throw new AppException(vtranslate('LBL_MANDATORY_FIELD_MISSING'));
     }
     foreach ($this->tab_name as $table_name) {
         if ($table_name == 'vtiger_crmentity') {
             $this->insertIntoCrmEntity($module, $fileid);
         } else {
             $this->insertIntoEntityTable($table_name, $module, $fileid);
         }
     }
     //Calling the Module specific save code
     $this->save_module($module);
     // vtlib customization: Hook provide to enable generic module relation.
     if ($_REQUEST['createmode'] == 'link') {
         $for_module = vtlib_purify($_REQUEST['return_module']);
         $for_crmid = vtlib_purify($_REQUEST['return_id']);
         $with_module = $module;
         $with_crmid = $this->id;
         $on_focus = CRMEntity::getInstance($for_module);
         if ($for_module && $for_crmid && $with_module && $with_crmid) {
             relateEntities($on_focus, $for_module, $for_crmid, $with_module, $with_crmid);
         }
     }
     // END
 }