コード例 #1
0
ファイル: Campaigns.php プロジェクト: kikojover/corebos
    public static function createPotentialRelatedTo($relatedto, $campaignid)
    {
        global $adb, $current_user;
        $checkrs = $adb->pquery('select 1
			from vtiger_potential
			inner join vtiger_crmentity on crmid=potentialid
			where deleted=0 and related_to=? and campaignid=?', array($relatedto, $campaignid));
        if ($adb->num_rows($checkrs) == 0) {
            require_once 'modules/Potentials/Potentials.php';
            $entity = new Potentials();
            $entity->mode = '';
            $cname = getEntityName('Campaigns', $campaignid);
            $cname = $cname[$campaignid] . ' - ';
            $setype = getSalesEntityType($relatedto);
            $rname = getEntityName($setype, $relatedto);
            $rname = $rname[$relatedto];
            $cbMapid = GlobalVariable::getVariable('BusinessMapping_PotentialOnCampaignRelation', cbMap::getMapIdByName('PotentialOnCampaignRelation'));
            if ($cbMapid) {
                $cmp = CRMEntity::getInstance('Campaigns');
                $cmp->retrieve_entity_info($campaignid, 'Campaigns');
                if ($setype == 'Accounts') {
                    $cmp->column_fields['AccountName'] = $rname;
                    $cmp->column_fields['ContactName'] = '';
                } else {
                    $cmp->column_fields['AccountName'] = '';
                    $cmp->column_fields['ContactName'] = $rname;
                }
                $cbMap = cbMap::getMapByID($cbMapid);
                $entity->column_fields = $cbMap->Mapping($cmp->column_fields, array());
            }
            if (empty($entity->column_fields['assigned_user_id'])) {
                $entity->column_fields['assigned_user_id'] = $current_user->id;
            }
            $entity->column_fields['related_to'] = $relatedto;
            $entity->column_fields['campaignid'] = $campaignid;
            if (empty($entity->column_fields['closingdate'])) {
                $dt = new DateTimeField();
                $entity->column_fields['closingdate'] = $dt->getDisplayDate();
            }
            if (empty($entity->column_fields['potentialname'])) {
                $entity->column_fields['potentialname'] = $cname . $rname;
            }
            if (empty($entity->column_fields['sales_stage'])) {
                $entity->column_fields['sales_stage'] = 'Prospecting';
            }
            $_REQUEST['assigntype'] = 'U';
            $_REQUEST['assigned_user_id'] = $entity->column_fields['assigned_user_id'];
            $entity->save('Potentials');
        }
    }
コード例 #2
0
ファイル: PopulateSeedData.php プロジェクト: nvh3010/quancrm
    $opp = new Potentials();
    $opp->column_fields["assigned_user_id"] = $assigned_user_id;
    $opp->column_fields["potentialname"] = $account_name . " - 1000 units";
    $opp->column_fields["closingdate"] =& create_date();
    $key = array_rand($comboFieldArray['leadsource_dom']);
    $opp->column_fields["leadsource"] = $comboFieldArray['leadsource_dom'][$key];
    $comboSalesStageArray = array("Closed Won", "Needs Analysis", "Value Proposition", "Qualification", "Prospecting", "Id. Decision Makers");
    $key = array_rand($comboSalesStageArray);
    $opp->column_fields["sales_stage"] = $comboSalesStageArray[$key];
    $key = array_rand($comboFieldArray['opportunity_type_dom']);
    $opp->column_fields["opportunity_type"] = $comboFieldArray['opportunity_type_dom'][$key];
    $amount = array("10000", "25000", "50000", "75000");
    $key = array_rand($amount);
    $opp->column_fields["amount"] = $amount[$key];
    $opp->column_fields["related_to"] = $account->id;
    $opp->save("Potentials");
    $opportunity_ids[] = $opp->id;
}
for ($i = 0; $i < 10; $i++) {
    $contact = new Contacts();
    $contact->column_fields["firstname"] = ucfirst(strtolower($first_name_array[$i]));
    $contact->column_fields["lastname"] = ucfirst(strtolower($last_name_array[$i]));
    $contact->column_fields["assigned_user_id"] = $assigned_user_id;
    $contact->column_fields["email"] = strtolower($contact->column_fields["firstname"]) . "_" . strtolower($contact->column_fields["lastname"]) . "@company.com";
    $contact->column_fields["phone"] = create_phone_number();
    $contact->column_fields["homephone"] = create_phone_number();
    $contact->column_fields["mobile"] = create_phone_number();
    // Fill in a bogus address
    $key = array_rand($street_address_array);
    $contact->column_fields["mailingstreet"] = $street_address_array[$key];
    $key = array_rand($city_array);