function save($check_notify = FALSE) { global $sugar_config; if (empty($this->id) || $this->new_with_id) { if (isset($_POST['group_id'])) { unset($_POST['group_id']); } if (isset($_POST['product_id'])) { unset($_POST['product_id']); } if (isset($_POST['service_id'])) { unset($_POST['service_id']); } if ($sugar_config['dbconfig']['db_type'] == 'mssql') { $this->number = $this->db->getOne("SELECT MAX(CAST(number as INT))+1 FROM aos_quotes"); } else { $this->number = $this->db->getOne("SELECT MAX(CAST(number as UNSIGNED))+1 FROM aos_quotes"); } if ($this->number < $sugar_config['aos']['quotes']['initialNumber']) { $this->number = $sugar_config['aos']['quotes']['initialNumber']; } } require_once 'modules/AOS_Products_Quotes/AOS_Utils.php'; perform_aos_save($this); parent::save($check_notify); require_once 'modules/AOS_Line_Item_Groups/AOS_Line_Item_Groups.php'; $productQuoteGroup = new AOS_Line_Item_Groups(); $productQuoteGroup->save_groups($_POST, $this, 'group_'); }
function save($check_notify = FALSE) { if (empty($this->id)) { unset($_POST['group_id']); unset($_POST['product_id']); unset($_POST['service_id']); } if (isset($_POST['renewal_reminder_date']) && !empty($_POST['renewal_reminder_date'])) { $this->createReminder(); } parent::save($check_notify); require_once 'modules/AOS_Line_Item_Groups/AOS_Line_Item_Groups.php'; $productQuoteGroup = new AOS_Line_Item_Groups(); $productQuoteGroup->save_groups($_POST, $this, 'group_'); if (isset($_POST['renewal_reminder_date']) && !empty($_POST['renewal_reminder_date'])) { $this->createLink(); } }
public function testsave_groups() { error_reporting(E_ERROR | E_PARSE); $aosLineItemGroup = new AOS_Line_Item_Groups(); //populate required values $post_data = array(); $post_data['group_number'] = array(0, 0); $post_data['name'] = array('test1', 'test2'); $post_data['total_amount'] = array('100', '200'); $post_data['total_amount_usdollar'] = array('100', '200'); //create parent bean for line item groups $aosContract = new AOS_Contracts(); $aosContract->id = 1; $aosLineItemGroup->save_groups($post_data, $aosContract); //get the linked beans and verify if records created $line_item_groups = $aosContract->get_linked_beans('aos_line_item_groups', $aosContract->object_name); $this->assertEquals(count($post_data['group_number']), count($line_item_groups)); //cleanup afterwards foreach ($line_item_groups as $lineItem) { $lineItem->mark_deleted($lineItem->id); } }