Ejemplo n.º 1
0
 /**
  * Creates a new entry in the database.
  *
  * @param array $params
  *   (reference) an assoc array of name/value pairs.
  *
  * @return CRM_Price_DAO_LineItem
  */
 public static function create(&$params)
 {
     $id = CRM_Utils_Array::value('id', $params);
     if ($id) {
         CRM_Utils_Hook::pre('edit', 'LineItem', $id, $params);
         $op = CRM_Core_Action::UPDATE;
     } else {
         CRM_Utils_Hook::pre('create', 'LineItem', $params['entity_id'], $params);
         $op = CRM_Core_Action::ADD;
     }
     // unset entity table and entity id in $params
     // we never update the entity table and entity id during update mode
     if ($id) {
         unset($params['entity_id'], $params['entity_table']);
     }
     if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() && CRM_Utils_Array::value('check_permissions', $params)) {
         if (empty($params['financial_type_id'])) {
             throw new Exception('Mandatory key(s) missing from params array: financial_type_id');
         }
         CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($types, $op);
         if (!in_array($params['financial_type_id'], array_keys($types))) {
             throw new Exception('You do not have permission to create this line item');
         }
     }
     $lineItemBAO = new CRM_Price_BAO_LineItem();
     $lineItemBAO->copyValues($params);
     $return = $lineItemBAO->save();
     if ($id) {
         CRM_Utils_Hook::post('edit', 'LineItem', $id, $lineItemBAO);
     } else {
         CRM_Utils_Hook::post('create', 'LineItem', $lineItemBAO->id, $lineItemBAO);
     }
     return $return;
 }
Ejemplo n.º 2
0
 /**
  * Creates a new entry in the database.
  *
  * @param array $params (reference) an assoc array of name/value pairs
  *
  * @return object CRM_Price_DAO_LineItem object
  * @access public
  * @static
  */
 static function create(&$params)
 {
     //create mode only as we don't support editing line items
     CRM_Utils_Hook::pre('create', 'LineItem', $params['entity_id'], $params);
     $lineItemBAO = new CRM_Price_BAO_LineItem();
     $lineItemBAO->copyValues($params);
     $return = $lineItemBAO->save();
     CRM_Utils_Hook::post('create', 'LineItem', $params['entity_id'], $params);
     return $return;
 }
Ejemplo n.º 3
0
 /**
  * Creates a new entry in the database.
  *
  * @param array $params
  *   (reference) an assoc array of name/value pairs.
  *
  * @return CRM_Price_DAO_LineItem
  */
 public static function create(&$params)
 {
     $id = CRM_Utils_Array::value('id', $params);
     if ($id) {
         CRM_Utils_Hook::pre('edit', 'LineItem', $id, $params);
     } else {
         CRM_Utils_Hook::pre('create', 'LineItem', $params['entity_id'], $params);
     }
     // unset entity table and entity id in $params
     // we never update the entity table and entity id during update mode
     if ($id) {
         unset($params['entity_id'], $params['entity_table']);
     }
     $lineItemBAO = new CRM_Price_BAO_LineItem();
     $lineItemBAO->copyValues($params);
     $return = $lineItemBAO->save();
     if ($id) {
         CRM_Utils_Hook::post('edit', 'LineItem', $id, $lineItemBAO);
     } else {
         CRM_Utils_Hook::post('create', 'LineItem', $lineItemBAO->id, $lineItemBAO);
     }
     return $return;
 }
Ejemplo n.º 4
0
 /**
  * Creates a new entry in the database.
  *
  * @param array $params (reference) an assoc array of name/value pairs
  *
  * @return object CRM_Price_DAO_LineItem object
  * @access public
  * @static
  */
 static function create(&$params)
 {
     $lineItemBAO = new CRM_Price_BAO_LineItem();
     $lineItemBAO->copyValues($params);
     return $lineItemBAO->save();
 }