当前位置: 首页>>代码示例>>PHP>>正文


PHP Opportunity类代码示例

本文整理汇总了PHP中Opportunity的典型用法代码示例。如果您正苦于以下问题:PHP Opportunity类的具体用法?PHP Opportunity怎么用?PHP Opportunity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Opportunity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setSalesStatus

 /**
  * Set the Sales Status based on the associated RLI's sales_stage
  *
  * @param Opportunity $bean
  * @param string $event
  * @param array $args
  */
 public static function setSalesStatus(Opportunity $bean, $event, $args)
 {
     if (static::useRevenueLineItems() && $bean->ACLFieldAccess('sales_status', 'write')) {
         // we have a new bean so set the value to new and dump out
         if (empty($bean->fetched_row)) {
             $bean->sales_status = Opportunity::STATUS_NEW;
             return;
         }
         // Load forecast config so we have the sales_stage data.
         static::loadForecastSettings();
         // we don't have a new row, so figure out what we need to set it to
         $closed_won = static::$settings['sales_stage_won'];
         $closed_lost = static::$settings['sales_stage_lost'];
         $won_rlis = count($bean->get_linked_beans('revenuelineitems', 'RevenueLineItems', array(), 0, -1, 0, "sales_stage in ('" . join("', '", $closed_won) . "')"));
         $lost_rlis = count($bean->get_linked_beans('revenuelineitems', 'RevenueLineItems', array(), 0, -1, 0, "sales_stage in ('" . join("', '", $closed_lost) . "')"));
         $total_rlis = count($bean->get_linked_beans('revenuelineitems', 'RevenueLineItems'));
         if ($total_rlis > $won_rlis + $lost_rlis || $total_rlis === 0) {
             // still in progress
             $bean->sales_status = Opportunity::STATUS_IN_PROGRESS;
         } else {
             // they are equal so if the total lost == total rlis then it's closed lost,
             // otherwise it's always closed won
             if ($lost_rlis == $total_rlis) {
                 $bean->sales_status = Opportunity::STATUS_CLOSED_LOST;
             } else {
                 $bean->sales_status = Opportunity::STATUS_CLOSED_WON;
             }
         }
     }
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:37,代码来源:OpportunityHooks.php

示例2: CustomScheduler

function CustomScheduler()
{
    global $sugar_config, $db;
    $timeDate = new TimeDate();
    $timeDateNow = $timeDate->getNow(true)->asDb();
    $days_offset = 15;
    $GLOBALS['log']->fatal("Checking Opportunities...");
    $query = "select opportunities.id from opportunities\n\twhere opportunities.sales_stage != 'Closed Won'\n\tand DATEDIFF(opportunities.date_modified,'" . $timeDateNow . "') < " . $days_offset . "\n\tand !opportunities.deleted";
    $GLOBALS['log']->fatal("Query: " . $query);
    $res = $db->query($query, true, 'Error: ');
    while ($row = $db->fetchByAssoc($res)) {
        $opportunity = new Opportunity();
        if (!is_null($opportunity->retrieve($row['id']))) {
            $user = new User();
            if (!is_null($user->retrieve($opportunity->assigned_user_id))) {
                $emailsTo = array();
                $emailSubject = "Opportunity Alert";
                $emailBody = "The following Opportunity has " . $days_offset . " days without changes.<br /><br />\n\t\t\t\tName: " . $opportunity->name . "<br />\n\t\t\t\tAccount: " . $opportunity->account_name . "<br />\n\t\t\t\tAmount: " . $opportunity->amount . "<br />\n\t\t\t\tSales Stage: " . $opportunity->sales_stage . "<br />\n\t\t\t\tDate Close: " . $opportunity->date_closed . "<br /><br />\n\t\t\t\tYou can see the opportunity here:<br />\n\t\t\t\t<a href=\"" . $sugar_config['site_url'] . "/index.php?module=Opportunities&action=DetailView&record=" . $opportunity->id . "\">" . $opportunity->name . "</a>";
                $emailsTo[] = $user->email1;
                SendEmail($emailsTo, $emailSubject, $emailBody);
            }
        }
    }
    $GLOBALS['log']->fatal("Opportunities checked");
    return true;
}
开发者ID:julieth756,项目名称:SugarCRMSchedulers,代码行数:26,代码来源:CustomSchedulers.php

示例3: actionLoadOpportunitiesSampler

 public function actionLoadOpportunitiesSampler()
 {
     if (!Group::isUserASuperAdministrator(Yii::app()->user->userModel)) {
         throw new NotSupportedException();
     }
     for ($i = 0; $i < 11; $i++) {
         $owner = Yii::app()->user->userModel;
         $name = 'Mass Delete ' . $i;
         $currencies = Currency::getAll();
         $currencyValue = new CurrencyValue();
         $currencyValue->value = 500.54;
         $currencyValue->currency = $currencies[0];
         $opportunity = new Opportunity();
         $opportunity->owner = $owner;
         $opportunity->name = $name;
         $opportunity->amount = $currencyValue;
         $opportunity->closeDate = '2011-01-01';
         //eventually fix to make correct format
         $opportunity->stage->value = 'Negotiating';
         $saved = $opportunity->save();
         if (!$saved) {
             throw new NotSupportedException();
         }
     }
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:25,代码来源:DemoController.php

示例4: testDefaultCurrencyFieldsArePopulated

 /**
  * Tests that currency-related properties are filled in at model layer
  * even when opportunity currency is the default one.
  */
 public function testDefaultCurrencyFieldsArePopulated()
 {
     $opportunity = new Opportunity();
     // disable row level security just to simplify the test
     $opportunity->disable_row_level_security = true;
     $opportunity->retrieve($this->opportunity->id);
     $this->assertNotEmpty($opportunity->currency_name);
     $this->assertNotEmpty($opportunity->currency_symbol);
 }
开发者ID:delkyd,项目名称:sugarcrm_dev,代码行数:13,代码来源:Bug52438Tets.php

示例5: addRealty

 function addRealty(&$bean)
 {
     $bean->load_relationship("realty_contracts");
     $bean->realty_contracts->delete($bean->id);
     $opp = new Opportunity();
     $opp->retrieve($bean->opp_id);
     $realty_list = $opp->get_linked_beans('realty_opportunities', 'Opportunities');
     foreach ($realty_list as $realty) {
         $bean->realty_contracts->add($realty->id);
     }
 }
开发者ID:omusico,项目名称:sugar_work,代码行数:11,代码来源:AddRealtyFromOpportunities.php

示例6: create

 function create(&$bean)
 {
     if ($bean->code_inc == '') {
         $relate_field = "contact_id";
         $opportunity = new Opportunity();
         $opportunity->name = "Сделка с клиентом " . $bean->last_name . " " . $bean->first_name . " от " . date("d.m.Y");
         $opportunity->{$relate_field} = $bean->id;
         $opportunity->assigned_user_id = $bean->assigned_user_id;
         $opportunity->type_of_realty = "client";
         $opportunity->save();
     }
 }
开发者ID:omusico,项目名称:sugar_work,代码行数:12,代码来源:create_new_opportunity.php

示例7: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     UserTestHelper::createBasicUser('jim');
     AllPermissionsOptimizationUtil::rebuild();
     OpportunityTestHelper::createOpportunityStagesIfDoesNotExist();
     OpportunityTestHelper::createOpportunitySourcesIfDoesNotExist();
     $currencies = Currency::getAll();
     //Make opportunities for testing chart data.
     $currencyValue = new CurrencyValue();
     $currencyValue->value = 200;
     $currencyValue->currency = $currencies[0];
     $opportunity = new Opportunity();
     $opportunity->owner = $super;
     $opportunity->name = 'abc1';
     $opportunity->amount = $currencyValue;
     $opportunity->closeDate = '2011-01-01';
     $opportunity->stage->value = 'Negotiating';
     $opportunity->source->value = 'Outbound';
     assert($opportunity->save());
     // Not Coding Standard
     $currencyValue = new CurrencyValue();
     $currencyValue->value = 350;
     $currencyValue->currency = $currencies[0];
     $opportunity = new Opportunity();
     $opportunity->owner = $super;
     $opportunity->name = 'abc2';
     $opportunity->amount = $currencyValue;
     $opportunity->closeDate = '2011-01-01';
     $opportunity->stage->value = 'Negotiating';
     $opportunity->source->value = 'Trade Show';
     assert($opportunity->save());
     // Not Coding Standard
     $currencyValue = new CurrencyValue();
     $currencyValue->value = 100;
     $currencyValue->currency = $currencies[0];
     $opportunity = new Opportunity();
     $opportunity->owner = $super;
     $opportunity->name = 'abc2';
     $opportunity->amount = $currencyValue;
     $opportunity->closeDate = '2011-01-01';
     $opportunity->stage->value = 'Verbal';
     $opportunity->source->value = 'Trade Show';
     assert($opportunity->save());
     // Not Coding Standard
 }
开发者ID:RamaKavanan,项目名称:BaseVersion,代码行数:49,代码来源:OpportunitiesChartDataProviderTest.php

示例8: testSaveAndRetrievePortlet

 public function testSaveAndRetrievePortlet()
 {
     $user = UserTestHelper::createBasicUser('Billy');
     $opportunities = Opportunity::getByName('superOpp');
     $portlet = new Portlet();
     $portlet->column = 2;
     $portlet->position = 5;
     $portlet->layoutId = 'Test';
     $portlet->collapsed = true;
     $portlet->viewType = 'OpportunitiesForContactRelatedList';
     $portlet->serializedViewData = serialize(array('title' => 'Testing Title'));
     $portlet->user = $user;
     $this->assertTrue($portlet->save());
     $portlet = Portlet::getById($portlet->id);
     $params = array('controllerId' => 'test', 'relationModuleId' => 'test', 'relationModel' => $opportunities[0], 'redirectUrl' => 'someRedirect');
     $portlet->params = $params;
     $unserializedViewData = unserialize($portlet->serializedViewData);
     $this->assertEquals(2, $portlet->column);
     $this->assertEquals(5, $portlet->position);
     $this->assertEquals('Testing Title', $portlet->getTitle());
     $this->assertEquals(false, $portlet->isEditable());
     $this->assertEquals('Test', $portlet->layoutId);
     //$this->assertEquals(true,                  $portlet->collapsed); //reenable once working
     $this->assertEquals('OpportunitiesForContactRelatedList', $portlet->viewType);
     $this->assertEquals($user->id, $portlet->user->id);
     $view = $portlet->getView();
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:27,代码来源:OpportunitiesRelatedListPortletTest.php

示例9: testLoad

 public function testLoad()
 {
     $this->assertEquals(2, Group::getCount());
     $this->assertEquals(0, Role::getCount());
     $this->assertEquals(0, Account::getCount());
     $this->assertEquals(0, Contact::getCount());
     $this->assertEquals(0, Opportunity::getCount());
     $this->assertEquals(0, Meeting::getCount());
     $this->assertEquals(0, Note::getCount());
     $this->assertEquals(0, Task::getCount());
     $this->assertEquals(1, User::getCount());
     $this->assertEquals(0, ProductCatalog::getCount());
     $this->assertEquals(0, ProductCategory::getCount());
     $this->assertEquals(0, ProductTemplate::getCount());
     $this->assertEquals(0, Product::getCount());
     $messageLogger = new MessageLogger();
     DemoDataUtil::unsetLoadedModules();
     DemoDataUtil::load($messageLogger, 3);
     $this->assertEquals(8, Group::getCount());
     $this->assertEquals(3, Role::getCount());
     $this->assertEquals(3, Account::getCount());
     $this->assertEquals(16, Contact::getCount());
     $this->assertEquals(6, Opportunity::getCount());
     $this->assertEquals(18, Meeting::getCount());
     $this->assertEquals(12, Note::getCount());
     $this->assertEquals(9, Task::getCount());
     $this->assertEquals(10, User::getCount());
     $this->assertEquals(1, ProductCatalog::getCount());
     $this->assertEquals(6, ProductCategory::getCount());
     $this->assertEquals(32, ProductTemplate::getCount());
     $this->assertEquals(59, Product::getCount());
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:32,代码来源:DemoDataUtilTest.php

示例10: run

 public function run()
 {
     if (!$this->toFlavor('ent') && !$this->toFlavor('ult') || !version_compare($this->from_version, '7.0', '<')) {
         return;
     }
     $settings = Opportunity::getSettings();
     if ($settings['opps_view_by'] !== 'RevenueLineItems') {
         $this->log('Not using Revenue Line Items; Skipping Upgrade Script');
         return;
     }
     // get the get_widget helper and the StandardField Helper
     require_once 'modules/DynamicFields/FieldCases.php';
     require_once 'modules/ModuleBuilder/parsers/StandardField.php';
     // we are working with opportunities
     $module = 'Opportunities';
     $bean = BeanFactory::getBean('Opportunities');
     // the field set we need
     $fields = array('best_case', 'amount', 'worst_case', 'date_closed');
     // loop over each field
     foreach ($fields as $field) {
         // get the field defs
         $field_defs = $bean->getFieldDefinition($field);
         // load the field type up
         $f = get_widget($field_defs['type']);
         // populate the row from the vardefs that were loaded
         $f->populateFromRow($field_defs);
         // lets make sure that the calculated is true
         $f->calculated = true;
         // now lets save, since these are OOB field, we use StandardField
         $df = new StandardField($module);
         $df->setup($bean);
         $f->module = $bean;
         $f->save($df);
     }
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:35,代码来源:7_OpportunityFixCalculatedFields.php

示例11: handleSave

 function handleSave()
 {
     $out = "<script>ajaxStatus.flashStatus(SUGAR.language.get('app_strings', 'LBL_REQUEST_PROCESSED'), 2000);</script>";
     if (!empty($_REQUEST['relationships'])) {
         $out .= $this->removeCustomRelationships();
     }
     if (!empty($_REQUEST['fields'])) {
         $out .= $this->removeCustomFields();
     }
     if (!empty($_REQUEST['layouts'])) {
         $out .= $this->removeCustomLayouts();
     }
     if (!empty($_REQUEST['labels'])) {
         $out .= $this->removeCustomLabels();
     }
     if (!empty($_REQUEST['extensions'])) {
         $out .= $this->removeCustomExtensions();
     }
     if ($this->module === 'Opportunities') {
         $opp_settings = Opportunity::getSettings();
         if ($opp_settings['opps_view_by'] == 'RevenueLineItems') {
             require_once 'modules/Opportunities/include/OpportunityWithRevenueLineItem.php';
             $opp_setup = new OpportunityWithRevenueLineItem();
             $opp_setup->doMetadataConvert();
             $out .= 'Enabling Opportunities with RevenueLineItems<br />';
         }
     }
     $out .= "Complete!";
     $ajax = new AjaxCompose();
     $ajax->addCrumb(translate('LBL_STUDIO'), 'ModuleBuilder.main("studio")');
     $ajax->addCrumb(translate($this->module), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view_module=' . $this->module . '")');
     $ajax->addCrumb("Reset " . translate($this->module), '');
     $ajax->addSection('center', "Reset " . translate($this->module), $out);
     echo $ajax->getJavascript();
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:35,代码来源:view.resetmodule.php

示例12: run

 /**
  * Upgrade Task to Run
  */
 public function run()
 {
     if (version_compare($this->from_version, '7.0.0', '<') && ($this->toFlavor('ent') || $this->toFlavor('ult'))) {
         $settings = Opportunity::getSettings();
         if ($settings['opps_view_by'] !== 'RevenueLineItems') {
             $this->log('Not using Revenue Line Items; Skipping Upgrade Script');
             return;
         }
         $filename = 'custom/Extension/modules/Opportunities/Ext/Vardefs/sugarfield_date_closed.php';
         if (!is_file($filename)) {
             return;
         }
         require $filename;
         if (!empty($dictionary['Opportunity']['fields'])) {
             $fileString = file_get_contents($filename);
             // PAT-584, need to set the field Expected Close Date to false when upgrade because:
             // In 6.7, the field Expected Close Date is Required and no formula associated out of box.
             // In 7, the field Expected Close Date is Not Required and there's a formula associated out of box.
             // So use steps from PAT-584, it results in a Required field with a formula associated.
             if (isset($dictionary['Opportunity']['fields']['date_closed']['required']) && $dictionary['Opportunity']['fields']['date_closed']['required'] == true) {
                 $this->log("Change Opportunity field date_closed to not required");
                 $fileString = preg_replace('/(\\$dictionary\\[\'Opportunity\'\\]\\[\'fields\'\\]\\[\'date_closed\'\\]\\[\'required\'\\]\\s*=\\s*)true\\s*;/', '${1}false;', $fileString);
                 sugar_file_put_contents_atomic($filename, $fileString);
             }
         }
     }
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:30,代码来源:7_OpportunityUpdateDateClosed.php

示例13: populateSeedDataForSearchTest

 function populateSeedDataForSearchTest($user_id)
 {
     $results = array();
     $a1_id = create_guid();
     $a1 = new Account();
     $a1->id = $a1_id;
     $a1->new_with_id = TRUE;
     $a1->name = "UNIT TEST {$a1_id}";
     $a1->assigned_user_id = $user_id;
     $a1->save();
     $results[] = array('id' => $a1_id, 'fieldName' => 'name', 'fieldValue' => "UNIT TEST {$a1_id}");
     $a2_id = create_guid();
     $a2 = new Account();
     $a2->new_with_id = TRUE;
     $a2->id = $a2_id;
     $a2->name = "UNIT TEST {$a2_id}";
     $a2->assigned_user_id = 'unittest';
     $a2->save();
     $results[] = array('id' => $a2_id, 'fieldName' => 'name', 'fieldValue' => "UNIT TEST {$a2_id}");
     $c1_id = create_guid();
     $c1 = new Contact();
     $c1->id = $c1_id;
     $c1->new_with_id = TRUE;
     $c1->first_name = "UNIT TEST";
     $c1->last_name = "UNIT_TEST";
     $c1->assigned_user_id = $user_id;
     $c1->save();
     $results[] = array('id' => $c1_id, 'fieldName' => 'name', 'fieldValue' => $c1->first_name . ' ' . $c1->last_name);
     $op1_id = create_guid();
     $op1 = new Opportunity();
     $op1->new_with_id = TRUE;
     $op1->id = $op1_id;
     $op1->name = "UNIT TEST {$op1_id}";
     $op1->assigned_user_id = $user_id;
     $op1->save();
     $results[] = array('id' => $op1_id, 'fieldName' => 'name', 'fieldValue' => "UNIT TEST {$op1_id}");
     $op2_id = create_guid();
     $op2 = new Opportunity();
     $op2->new_with_id = TRUE;
     $op2->id = $op2_id;
     $op2->name = "UNIT TEST {$op2_id}";
     $op2->assigned_user_id = 'unittest';
     $op2->save();
     $results[] = array('id' => $op2_id, 'fieldName' => 'name', 'fieldValue' => "UNIT TEST {$op2_id}");
     $GLOBALS['db']->commit();
     return $results;
 }
开发者ID:jgera,项目名称:sugarcrm_dev,代码行数:47,代码来源:APIv3Helper.php

示例14: getNames

 public static function getNames()
 {
     $arr = Opportunity::model()->findAll();
     $names = array(0 => 'None');
     foreach ($arr as $opportunity) {
         $names[$opportunity->id] = $opportunity->name;
     }
     return $names;
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:9,代码来源:Opportunity.php

示例15: process

 /**
  * main method that runs reminding process
  * @return boolean
  */
 public function process()
 {
     $admin = new Administration();
     $admin->retrieveSettings();
     $GLOBALS['log']->info('----->test');
     $opportunities = $this->getOpportunitiesForRemind();
     foreach ($opportunities as $id) {
         echo "----->id:{$id}";
         $recipients = $this->getRecipients($id);
         $bean = new Opportunity();
         $bean->retrieve($id);
         if ($this->sendReminders($bean, $admin, $recipients)) {
             $bean->date_remind = 0;
             $bean->save();
         }
     }
     return true;
 }
开发者ID:omusico,项目名称:sugar_work,代码行数:22,代码来源:Reminder.php


注:本文中的Opportunity类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。