assign("MOD", $mod_strings); $xtpl->assign("APP", $app_strings); $xtpl->assign("PRINT_URL", "index.php?".$GLOBALS['request_string']); $xtpl->assign("HEADER", $mod_strings['LBL_ADD_BUSINESSCARD']); $xtpl->assign("MODULE", $_REQUEST['module']); if ($error_msg != '') { $xtpl->assign("ERROR", $error_msg); $xtpl->parse("main.error"); } if(isset($_POST['handle']) && $_POST['handle'] == 'Save'){ require_once('modules/Contacts/ContactFormBase.php'); $contactForm = new ContactFormBase(); require_once('modules/Accounts/AccountFormBase.php'); $accountForm = new AccountFormBase(); require_once('modules/Opportunities/OpportunityFormBase.php'); $oppForm = new OpportunityFormBase(); if(!isset($_POST['selectedContact']) && !isset($_POST['ContinueContact'])){ $duplicateContacts = $contactForm->checkForDuplicates('Contacts'); if(isset($duplicateContacts)){ $formBody = $contactForm->buildTableForm($duplicateContacts); $xtpl->assign('FORMBODY', $formBody); $xtpl->parse('main.formnoborder'); $xtpl->parse('main'); $xtpl->out('main'); return; } } if(empty($_POST['selectedAccount']) && empty($_POST['ContinueAccount'])){ $duplicateAccounts = $accountForm->checkForDuplicates('Accounts'); if(isset($duplicateAccounts)){ $xtpl->assign('FORMBODY', $accountForm->buildTableForm($duplicateAccounts)); $xtpl->parse('main.formnoborder'); $xtpl->parse('main'); $xtpl->out('main'); return; } } if(isset($_POST['newopportunity']) && $_POST['newopportunity']=='on' &&!isset($_POST['selectedOpportunity']) && !isset($_POST['ContinueOpportunity'])){ $duplicateOpps = $oppForm->checkForDuplicates('Opportunities'); if(isset($duplicateOpps)){ $xtpl->assign('FORMBODY', $oppForm->buildTableForm($duplicateOpps)); $xtpl->parse('main.formnoborder'); $xtpl->parse('main'); $xtpl->out('main'); return; } } if(!empty($_POST['selectedContact'])){ $contact = new Contact(); $contact->retrieve($_POST['selectedContact']); }else{ $contact= $contactForm->handleSave('Contacts',false, false); } if(!empty($_POST['selectedAccount'])){ $account = new Account(); $account->retrieve($_POST['selectedAccount']); }else if(isset($_POST['newaccount']) && $_POST['newaccount']=='on' ){ $account= $accountForm->handleSave('Accounts',false, false); } if(isset($_POST['newopportunity']) && $_POST['newopportunity']=='on' ){ if(!empty($_POST['selectedOpportunity'])){ $opportunity = new Opportunity(); $opportunity->retrieve($_POST['selectedOpportunity']); }else{ if(isset($account)){ $_POST['Opportunitiesaccount_id'] = $account->id; $_POST['Opportunitiesaccount_name'] = $account->name; } if(isset($_POST['Contactslead_source']) && !empty($_POST['Contactslead_source'])){ $_POST['Opportunitieslead_source'] = $_POST['Contactslead_source']; } $opportunity= $oppForm->handleSave('Opportunities',false, false); } } require_once('modules/Notes/NoteFormBase.php'); $noteForm = new NoteFormBase(); if(isset($account)) $_POST['AccountNotesparent_id'] = $account->id; $accountnote= $noteForm->handleSave('AccountNotes',false, false); if(isset($contact)) $_POST['ContactNotesparent_type'] = "Contacts"; $_POST['ContactNotesparent_id'] = $contact->id; $contactnote= $noteForm->handleSave('ContactNotes',false, false); if(isset($opportunity)){ $_POST['OpportunityNotesparent_type'] = "Opportunities"; $_POST['OpportunityNotesparent_id'] = $opportunity->id; $opportunitynote= $noteForm->handleSave('OpportunityNotes',false, false); } if(isset($_POST['newappointment']) && $_POST['newappointment']=='on' ){ if(isset($_POST['appointment']) && $_POST['appointment'] == 'Meeting'){ require_once('modules/Meetings/MeetingFormBase.php'); $meetingForm = new MeetingFormBase(); $meeting= $meetingForm->handleSave('Appointments',false, false); }else{ require_once('modules/Calls/CallFormBase.php'); $callForm = new CallFormBase(); $call= $callForm->handleSave('Appointments',false, false); } } if(isset($call)){ if(isset($contact)) { $call->load_relationship('contacts'); $call->contacts->add($contact->id); } else if(isset($account)){ $call->load_relationship('account'); $call->account->add($account->id); }else if(isset($opportunity)){ $call->load_relationship('opportunity'); $call->opportunity->add($opportunity->id); } } if(isset($meeting)){ if(isset($contact)) { $meeting->load_relationship('contacts'); $meeting->contacts->add($contact->id); } else if(isset($account)){ $meeting->load_relationship('account'); $meeting->account->add($account->id); }else if(isset($opportunity)){ $meeting->load_relationship('opportunity'); $meeting->opportunity->add($opportunity->id); } } if(isset($account)){ if(isset($contact)) { $account->load_relationship('contacts'); $account->contacts->add($contact->id); } else if(isset($accountnote)){ $account->load_relationship('notes'); $account->notes->add($accountnote->id); }else if(isset($opportunity)){ $account->load_relationship('opportunities'); $account->opportunities->add($opportunity->id); } } if(isset($opportunity)){ if(isset($contact)) { $opportunity->load_relationship('contacts'); $opportunity->contacts->add($contact->id); } else if(isset($accountnote)){ $opportunity->load_relationship('notes'); $opportunity->notes->add($accountnote->id); } } if(isset($contact)){ if(isset($contactnote)){ $contact->load_relationship('notes'); $contact->notes->add($contactnote->id); } } if(isset($contact)){ $contact->track_view($current_user->id, 'Contacts'); if(isset($_POST['selectedContact']) && $_POST['selectedContact'] == $contact->id){ $xtpl->assign('ROWVALUE', "
  • ".$mod_strings['LBL_EXISTING_CONTACT']." - ".$locale->getLocaleFormattedName($contact->first_name, $contact->last_name)."" ); $xtpl->parse('main.row'); }else{ $xtpl->assign('ROWVALUE', "
  • ".$mod_strings['LBL_CREATED_CONTACT']." - ".$locale->getLocaleFormattedName($contact->first_name, $contact->last_name)."" ); $xtpl->parse('main.row'); } } if(isset($account)){ $account->track_view($current_user->id, 'Accounts'); if(isset($_POST['selectedAccount']) && $_POST['selectedAccount'] == $account->id){ $xtpl->assign('ROWVALUE', "
  • ".$mod_strings['LBL_EXISTING_ACCOUNT']. " - ".$account->name.""); $xtpl->parse('main.row'); }else{ $xtpl->assign('ROWVALUE', "
  • ".$mod_strings['LBL_CREATED_ACCOUNT']. " - ".$account->name.""); $xtpl->parse('main.row'); } } if(isset($opportunity)){ $opportunity->track_view($current_user->id, 'Opportunities'); if(isset($_POST['selectedOpportunity']) && $_POST['selectedOpportunity'] == $opportunity->id){ $xtpl->assign('ROWVALUE', "
  • ".$mod_strings['LBL_EXISTING_OPPORTUNITY']. " - ".$opportunity->name.""); $xtpl->parse('main.row'); }else{ $xtpl->assign('ROWVALUE', "
  • ".$mod_strings['LBL_CREATED_OPPORTUNITY']. " - ".$opportunity->name.""); $xtpl->parse('main.row'); } } if(isset($call)){ $call->track_view($current_user->id, 'Calls'); $xtpl->assign('ROWVALUE', "
  • ".$mod_strings['LBL_CREATED_CALL']. " - ".$call->name.""); $xtpl->parse('main.row'); } if(isset($meeting)){ $meeting->track_view($current_user->id, 'Meetings'); $xtpl->assign('ROWVALUE', "
  • ".$mod_strings['LBL_CREATED_MEETING']. " - ".$meeting->name.""); $xtpl->parse('main.row'); } $xtpl->assign('ROWVALUE'," "); $xtpl->parse('main.row'); $xtpl->assign('ROWVALUE',"{$mod_strings['LBL_ADDMORE_BUSINESSCARD']}"); $xtpl->parse('main.row'); $xtpl->parse('main'); $xtpl->out('main'); } else{ //CONTACT $xtpl->assign('FORMHEADER',$mod_strings['LNK_NEW_CONTACT']); $xtpl->parse("main.startform"); $xtpl->parse("main.savebegin"); require_once('modules/Contacts/ContactFormBase.php'); $xtpl->assign('OPPNEEDSACCOUNT',$mod_strings['NTC_OPPORTUNITY_REQUIRES_ACCOUNT']); if ($sugar_config['require_accounts']) { $xtpl->assign('CHECKOPPORTUNITY', "&& checkOpportunity()"); } else { $xtpl->assign('CHECKOPPORTUNITY', ""); } $contactForm = new ContactFormBase(); $xtpl->assign('FORMBODY',$contactForm->getWideFormBody('Contacts', 'Contacts', 'BusinessCard', '', false)); $xtpl->assign('TABLECLASS', 'edit view'); $xtpl->assign('CLASS', 'dataLabel'); require_once('modules/Notes/NoteFormBase.php'); $noteForm = new NoteFormBase(); $postform = "
    ${mod_strings['LNK_NEW_NOTE']}
    "; $postform .= ''; $xtpl->assign('POSTFORM',$postform); $xtpl->parse("main.form"); $xtpl->assign('HEADER', $app_strings['LBL_RELATED_RECORDS']); $xtpl->parse("main.hrrow"); $popup_request_data = array( 'call_back_function' => 'set_return', 'form_name' => 'BusinessCard', 'field_to_name_array' => array( 'id' => 'selectedAccount', 'name' => 'display_account_name', ), ); $json = getJSONobj(); $encoded_contact_popup_request_data = $json->encode($popup_request_data); //Account require_once('include/QuickSearchDefaults.php'); $qsd = QuickSearchDefaults::getQuickSearchDefaults(); $qsd->setFormName('BusinessCard'); $sqs_objects = array('BusinessCard_display_account_name' => $qsd->getQSParent()); $sqs_objects['BusinessCard_display_account_name']['populate_list'] = array('display_account_name', 'selectedAccount'); $quicksearch_js = ''; $selectAccountButton = $quicksearch_js; $selectAccountButton .= "

    "; $xtpl->assign('FORMHEADER',get_form_header($mod_strings['LNK_NEW_ACCOUNT'], '', '')); require_once('modules/Accounts/AccountFormBase.php'); $accountForm = new AccountFormBase(); $xtpl->assign('CLASS', 'evenListRow'); $xtpl->assign('FORMBODY',$selectAccountButton." ".$mod_strings['LNK_NEW_ACCOUNT']."