hoangweb
3/7/2018 - 1:28 PM

bitrix-php crm.deal

<?php
namespace Bitrix24\CRM\Deal;

$de = new Bitrix24\CRM\Deal();
//Add a new deal to CRM
$fields = { 
    "TITLE": "Regular sale", 
    "TYPE_ID": "GOODS", 
    "STAGE_ID": "NEW", 					
    "COMPANY_ID": 3,
    "CONTACT_ID": 3,
    "OPENED": "Y", 
    "ASSIGNED_BY_ID": 1, 
    "PROBABILITY": 30,
    "CURRENCY_ID": "USD", 
    "OPPORTUNITY": 5000,
    "BEGINDATE": date2str(current),
    "CLOSEDATE": date2str(nextMonth)					
};
$params = { "REGISTER_SONET_EVENT": "Y" };
$de->add($fields, $params);

//update deal by id
$de->update($dealId, $fields, $params);

//delete deal by id
$de->delete($dealId);

//get list of deal fields with description
$de->fields();

//get deal by id
$de->get($dealId);

//Get list of deal items
$order = { "STAGE_ID": "ASC" };
$filter = { ">PROBABILITY": 50 };
$select = [ "ID", "TITLE", "STAGE_ID", "PROBABILITY", "OPPORTUNITY", "CURRENCY_ID" ];
$start = 0;
$result = $de->getList($order, $filter, $select, $start);
$result->data();
if($result->more())
  $result->next();

/*-------------------------------------------------
  Contact for deal
*/