public static function createProspect($id = '', $attributes = array()) { $prospect = new Prospect(); $first_name = 'SugarProspectFirst'; $last_name = 'SugarProspectLast'; $email1 = '*****@*****.**'; $title = 'Test prospect title'; $prospect->first_name = $first_name; $prospect->last_name = $last_name; $prospect->title = $title; $prospect->email1 = '*****@*****.**'; if (!empty($id)) { $prospect->new_with_id = true; $prospect->id = $id; } if (!empty($attributes)) { if (!empty($attributes['id'])) { $prospect->new_with_id = true; $prospect->id = $attributes['id']; unset($attributes['id']); } foreach ($attributes as $attribute => $value) { $prospect->{$attribute} = $value; } } $prospect->save(); self::$_createdProspects[] = $prospect; return $prospect; }
function pre_editview() { //IF we have a prospect id leads convert it to a lead if (empty($this->bean->id) && !empty($_REQUEST['return_module']) && $_REQUEST['return_module'] == 'Prospects') { $prospect = new Prospect(); $prospect->retrieve($_REQUEST['return_id']); foreach ($prospect->field_defs as $key => $value) { if ($key == 'id' or $key == 'deleted') { continue; } if (isset($this->bean->field_defs[$key])) { $this->bean->{$key} = $prospect->{$key}; } } $_POST['is_converted'] = true; } return true; }
function openAction() { $id = AF::get($this->params, 'id', false); if (!$id) { throw new AFHttpException(0, 'no_id'); } $modelProspect = new Prospect(); /* if( !$modelProspect->fillFromDbPk($id) ) throw new AFHttpException(0, 'incorrect_id'); */ if (!$modelProspect->fillFromDbPkOpen($id)) { throw new AFHttpException(0, 'incorrect_id'); } $this->addToPageTitle(__('Prospect Customer')); $lables = $modelProspect->attributeLabels(); $infoFields = array('prospect_id', 'created_formatted', 'ip_formatted', 'email', 'phone', 'fname', 'lname', 'address1', 'address2', 'city', 'state_formatted', 'country_formatted', 'zip'); $this->render('open', array('model' => $modelProspect, 'lables' => $lables, 'infoFields' => $infoFields)); }
public static function createProspect($id = '') { $first_name = 'SugarProspectFirst'; $last_name = 'SugarProspectLast'; $email1 = '*****@*****.**'; $title = 'Test prospect title'; $prospect = new Prospect(); $prospect->first_name = $first_name; $prospect->last_name = $last_name; $prospect->title = $title; $prospect->email1 = '*****@*****.**'; if (!empty($id)) { $prospect->new_with_id = true; $prospect->id = $id; } $prospect->save(); self::$_createdProspects[] = $prospect; return $prospect; }
public function show($id) { try { $prospect = Prospect::findOrFail($id); $prospect->load('agent'); return View::make('thank_you')->with(['prospect' => $prospect]); } catch (Exception $e) { Log::error('Failed to find a specific record', array(404, "prospect: " . $prospect->id)); App::abort(404); //this goes directly to the missing method in global.php } }
/** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load * @return void */ function loadBox($max = 5) { global $user, $langs, $db, $conf; $this->max = $max; include_once DOL_DOCUMENT_ROOT . "/societe/class/societe.class.php"; $thirdpartystatic = new Societe($db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedProspects", $max)); if ($user->rights->societe->lire) { $sql = "SELECT s.nom, s.rowid as socid, s.fk_stcomm, s.datec, s.tms, s.status"; $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s"; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; } $sql .= " WHERE s.client IN (2, 3)"; $sql .= " AND s.entity IN (" . getEntity('societe', 1) . ")"; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = "******" AND s.rowid = " . $user->societe_id; } $sql .= " ORDER BY s.tms DESC"; $sql .= $db->plimit($max, 0); dol_syslog("box_prospect::loadBox sql=" . $sql, LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; $prospectstatic = new Prospect($db); while ($i < $num) { $objp = $db->fetch_object($resql); $datec = $db->jdate($objp->datec); $datem = $db->jdate($objp->tms); $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => $this->boximg, 'url' => DOL_URL_ROOT . "/comm/prospect/fiche.php?socid=" . $objp->socid); $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $objp->nom, 'url' => DOL_URL_ROOT . "/comm/prospect/fiche.php?socid=" . $objp->socid); $this->info_box_contents[$i][2] = array('td' => 'align="right"', 'text' => dol_print_date($datem, "day")); $this->info_box_contents[$i][3] = array('td' => 'align="right" width="18"', 'text' => str_replace('img ', 'img height="14" ', $prospectstatic->LibProspStatut($objp->fk_stcomm, 3))); $this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $thirdpartystatic->LibStatut($objp->status, 3)); $i++; } if ($num == 0) { $this->info_box_contents[$i][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoRecordedProspects")); } } else { $this->info_box_contents[0][0] = array('td' => 'align="left"', 'maxlength' => 500, 'text' => $db->error() . ' sql=' . $sql); } } else { dol_syslog("box_prospect::loadBox not allowed de read this box content", LOG_ERR); $this->info_box_contents[0][0] = array('td' => 'align="left"', 'text' => $langs->trans("ReadPermissionNotAllowed")); } }
public static function boot() { parent::boot(); static::created(function ($notification) { switch ($notification->type) { case 'new_prospect': $prospect = Prospect::find($notification->type_id); $user = User::find($notification->user_id); Clickatell::send("Nuevo Interesado en " . $prospect->type . " - Nombre: " . $prospect->name . " Email: " . $prospect->email . " Tel.: " . $prospect->phone, $user->phone); $data = ['name' => $prospect->name, 'email' => $prospect->email, 'phone' => $prospect->phone]; Mail::queue('emails.notify.new-prospect', $data, function ($message) use($user) { $message->from('*****@*****.**', 'MLMfunnel'); $message->to($user->email, $user->full_name)->subject('Nuevo prospecto! - MLMfunnel'); }); break; } }); }
print ' '; print '</td>'; print '<td class="liste_titre" align="center">'; print $form->selectarray('search_status', array('0' => $langs->trans('ActivityCeased'), '1' => $langs->trans('InActivity')), $search_status); print '</td>'; // Print the search button print '<td class="liste_titre" align="right">'; print '<input class="liste_titre" name="button_search" type="image" src="' . img_picto($langs->trans("Search"), 'search.png', '', '', 1) . '" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">'; print '</td>'; $parameters = array(); $formconfirm = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print "</tr>\n"; $i = 0; $var = true; $prospectstatic = new Prospect($db); $prospectstatic->client = 2; while ($i < min($num, $conf->liste_limit)) { $obj = $db->fetch_object($resql); $var = !$var; print '<tr ' . $bc[$var] . '>'; print '<td>'; $prospectstatic->id = $obj->rowid; $prospectstatic->nom = $obj->nom; $prospectstatic->status = $obj->status; $prospectstatic->code_client = $obj->code_client; $prospectstatic->client = $obj->client; $prospectstatic->fk_prospectlevel = $obj->fk_prospectlevel; print $prospectstatic->getNomUrl(1, 'prospect'); print '</td>'; print "<td>" . $obj->zip . " </td>";
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road, * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com. * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU Affero General Public License version 3. * * In accordance with Section 7(b) of the GNU Affero General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * SugarCRM" logo. If the display of the logo is not reasonably feasible for * technical reasons, the Appropriate Legal Notices must display the words * "Powered by SugarCRM". ********************************************************************************/ /********************************************************************************* * Description: TODO: To be written. * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. ********************************************************************************/ global $mod_strings; $focus = new Prospect(); if (!isset($_REQUEST['record'])) { sugar_die($mod_strings['ERR_DELETE_RECORD']); } $focus->retrieve($_REQUEST['record']); if (!$focus->ACLAccess('Delete')) { ACLController::displayNoAccess(true); sugar_cleanup(true); } $focus->mark_deleted($_REQUEST['record']); header("Location: index.php?module=" . $_REQUEST['return_module'] . "&action=" . $_REQUEST['return_action'] . "&record=" . $_REQUEST['return_id']);
function ImportProspect() { parent::Prospect(); }
if (isset($_REQUEST['record']) && isset($_REQUEST['record'])) { $focus->retrieve($_REQUEST['record']); } if (isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') { $focus->id = ""; } $convertingprospect = false; $prospect_id = null; $campaign = null; if (isset($_REQUEST['prospect_id']) && !empty($_REQUEST['prospect_id'])) { $prospect_id = $_REQUEST['prospect_id']; $convertingprospect = true; if (!class_exists('Prospect')) { require_once 'modules/Prospects/Prospect.php'; } $prospect = new Prospect(); $prospect->retrieve($_REQUEST['prospect_id']); foreach ($prospect->field_defs as $key => $value) { //exceptions. if ($key == 'id' or $key == 'deleted') { continue; } if (isset($focus->field_defs[$key])) { $focus->{$key} = $prospect->{$key}; } } //additional assignments. $focus->assigned_user_name = get_assigned_user_name($prospect->assigned_user_id); //add campaign selector. require_once 'include/JSON.php'; $lbl_select_label = $mod_strings['LBL_TARGET_BUTTON_LABEL'];
print '<td class="liste_titre" align="center">'; print ' '; print '</td>'; // Print the search button print '<td class="liste_titre" align="right">'; print '<input class="liste_titre" name="button_search" type="image" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">'; print '</td>'; print "</tr>\n"; $i = 0; $var=true; $prospectstatic=new Prospect($db); $prospectstatic->client=2; while ($i < min($num,$conf->liste_limit)) { $obj = $db->fetch_object($resql); $var=!$var; print '<tr '.$bc[$var].'>'; print '<td>'; $prospectstatic->id=$obj->rowid; $prospectstatic->nom=$obj->nom; $prospectstatic->status=$obj->status; print $prospectstatic->getNomUrl(1,'prospect'); print '</td>';
public function createAction() { $model = new Order(); $_POST['status'] = 'new'; $isPayment = AF::get($_POST, 'is_payment'); if (!$isPayment) { $_POST['ps'] = 'pn'; $_POST['payment_method'] = 'cc_debit'; } /*$rtr = ''; foreach($_POST as $k => $v) { $rtr .= " '".$k."' => '".$v."',"; } Message::echoJsonSuccess($rtr);*/ // is this also a new customer creation if (isset($_POST['newCus']) && $_POST['newCus'] == 1) { $cust = new Customer(); $this->performAjaxValidation($cust); //$shipData = (array)json_decode($_POST['shipAddr']); //$shipData['address_type'] = 'shipping'; $this->performAjaxFormFieldsValidation($_POST, explode(',', 'shipping_fname,shipping_lname,shipping_phone,shipping_address1,shipping_city,shipping_state_id,shipping_country_id,shipping_zip')); //Message::echoJsonSuccess('made it2'); if (!$_POST['billingSameAsShipping']) { //$billData = (array)json_decode($_POST['billAddr']); //$billData['address_type'] = 'billing'; $this->performAjaxFormFieldsValidation($_POST, explode(',', 'billing_fname,billing_lname,billing_phone,billing_address1,billing_city,billing_state_id,billing_country_id,billing_zip')); } $orderRules = "campaign_id,gateway_id,shipping_id,amount_product,amount_shipping,payment_total"; } else { $_POST['newCus'] = 0; $orderRules = "customer_id,campaign_id,gateway_id,shipping_id,amount_product,amount_shipping,payment_total,address_id,billing_address_id"; if (isset($_POST['address_id']) && empty($_POST['billing_address_id'])) { $_POST['billing_address_id'] = $_POST['address_id']; } // before billing validation } // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model, explode(',', $orderRules)); if (isset($_POST['model']) && $_POST['model'] == 'Order') { $isOrderPay = $this->access->actionAccess('order_is_pay') ? (bool) AF::get($_POST, 'is_payment') : false; $_POST['is_payment'] = $isOrderPay ? 1 : 0; // JSON success and error commands handled in the WS functions $ws = new WS(); $ws->crmInit($_POST); $ws->process(); } $orderID = AF::get($this->params, 'order_id', false); $prospectID = AF::get($this->params, 'prospect_id', false); $payments = array(); if ($orderID) { $model->fillFromDbPk($orderID); // if we use clone model then we cannot grab related fields $model->getCopyModel(); $orderProducts = OrderProducts::getProductsArrayByOrder($model->order_id); $payment_methods = ProfileGateways::getMethodsByProfileGateway($model->campaign->profile_id, $model->gateway_id); $cPayments = new Payments('Payment'); $payments = $cPayments->getResultsByCustomerId($model->customer_id, false); } elseif ($prospectID) { $modelProspect = Prospect::model()->findByPk($prospectID); if (!$modelProspect) { throw new AFHttpException(0, 'incorrect_id'); } $model->customer_id = $modelProspect->customer_id; $model->campaign_id = $modelProspect->campaign_id; $model->address_id = $modelProspect->address_id; $orderProducts = array(); $payment_methods = array(); } else { $orderProducts = array(); $payment_methods = array(); } $productModel = new Product(); $products = $productModel->getAvailableByCampaignID($model->campaign_id); $countryModel = new Country(); $languages = $countryModel->getLanguages(); $states = $model->country_id ? State::model()->getStatesByCID($model->country_id) : array(); //$model->country_ids='de,ir'; $countries = $countryModel->getCountries(); $campaigns = Campaign::model()->cache()->findAllInArray(); $shippingModel = new Shipping(); $shipping = $shippingModel->getAvailableByCampaignID($model->campaign_id); $modelGateways = new Gateway(); //$modelGateways->getGateways() $gateways = $orderID ? $modelGateways->getAvailableByCampaignID($model->campaign_id) : array(); $methods = Method::model()->cache()->findAllInArray(); $fields_expyear = array('current_year' => date("Y"), 'last_year' => date("Y") + 12); Assets::js('jquery.form'); Assets::js('jquery.autocomplete'); Assets::js('as24.bind-1.3.5.min'); Assets::js('jquery-ui'); Assets::css('jquery-ui'); $this->addToPageTitle('Create Order'); $this->render('create', array('model' => $model, 'products' => $products, 'languages' => $languages, 'campaigns' => $campaigns, 'states' => $states, 'countries' => $countries, 'fields_expyear' => $fields_expyear, 'shipping' => $shipping, 'gateways' => $gateways, 'orderProducts' => $orderProducts, 'payment_methods' => $payment_methods, 'payments' => $payments, 'methods' => $methods)); }
public static function deleteProspectOkOrder($order_id) { if (!$order_id) { return false; } $o = Order::model()->fillFromDbPk($order_id); $p = new Prospect(); $p->prospectExists($o->customer_id, $o->campaign_id); // update silver pop record to 'is customer' and delete if ($p->prospect_id) { $p->updateSilverpopCustomer(); $p->delete(); } unset($p); unset($o); }
function prospectsAction() { $clearArray = array('c_campaign_id', 'currency_id', 'detail_dates', 'aff_id'); $this->filter($clearArray); if (!isset($this->params['dates'])) { $today = date("d.m.Y"); $this->params['dates'] = $today . '-' . $today; } $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params, 'ajax' => true)); $models = isset($this->params['download_csv']) ? AFActiveDataProvider::models('Prospect', $this->params) : AFActiveDataProvider::models('Prospect', $this->params, $pagination); //if(isset($this->params['download_csv'])) { /* $fields = array( 'c.`campaign_id`', 'c.`campaign_name`', 'c.`url`', 'SUM(o.`amount_product`) as sum_amount_product', 'COUNT(o.`amount_product`) as count_amount_product', 'SUM(o.`amount_shipping`) as sum_amount_shipping', 'SUM(o.`amount_product` + o.`amount_shipping`) as total_revenue', 'AVG(o.`amount_product` + o.`amount_shipping`) as average_revenue', 'SUM(o.`amount_refunded`) as sum_amount_refunded', 'COUNT(Distinct o.`aff_id`) as count_afid', ); $models->getCsv($fields); */ //} $groupDate = !isset($this->params['detail_dates']) ? false : true; $subAff = isset($this->params['subAff']) && $this->params['subAff'] ? $this->params['subAff'] : false; $dataProvider = $models->getReport($groupDate, $subAff); $filterFields = Campaign::$FilterFields = $models->getoutFilterFields($clearArray, array('dates')); $fields = array('campaign_full_formatted', 'prospect_count', 'initial_customers', 'conversion_rate_formatted', 'gross_revenue_formatted', 'average_revenue_formatted'); if ($subAff) { array_unshift($fields, $subAff); } if ($groupDate) { array_unshift($fields, 'created'); } $currency = $models->getCurrency(); $total = array(); if (count($currency) == 1 || isset($filterFields['currency_id']) && count($filterFields['currency_id']) == 1) { $models2 = AFActiveDataProvider::models('Prospect', $this->params); $total = $models2->getRTotal(); if ($subAff) { array_unshift($total, $subAff); } unset($models2); } $campaignsFilter = $models->getRCampaigns(); $affFilter = $models->getRAffiliates(); // set ajax table if (AF::isAjaxRequestModels()) { $this->view->includeFile('_prospects_table', array('application', 'views', 'reports'), array('access' => $this->access, 'controller' => $this->controller, 'dataProvider' => $dataProvider, 'pagination' => $pagination, 'filterFields' => $filterFields, 'fields' => $fields, 'total' => $total, 'campaigns' => $campaignsFilter, 'afids' => $affFilter, 'currencies' => $currency)); die; } $this->addToPageTitle(__('sales_by_prospects')); $from = AF::get($this->params, 'from', false); //Currency::getSingPrice($model->amount_product, $model->currency_id) if ($from == 'afids') { $bTitle = isset($filterFields['aff_id'][0]) ? 'aff_id ' . $filterFields['aff_id'][0] : __('afid_campaign_report'); $breadLink = array(__('afid_report') => array('reports' => 'campaigns'), $bTitle); } else { $breadLink = array(__('sales_by_prospects')); //array_push($fields, 'count_afid_link'); } // CSV if (isset($this->params['download_csv'])) { $csv = array(); $headers = array(); // build header $labels = Prospect::model()->attributeLabels(); foreach ($fields as $f) { $headers[] = $labels[$f]; } $csv[] = $headers; $fields2 = array('campaign', 'prospect_count', 'initial_customers', 'conversion_rate', 'gross_revenue', 'average_revenue'); if ($groupDate) { array_unshift($fields2, 'created'); } // build report rows foreach ($dataProvider as $dp) { $row = array(); foreach ($fields2 as $f) { $row[] = $f == 'campaign' ? '[' . $dp->campaign_id . ']' . $dp->campaign_name : $dp->{$f}; } $csv[] = $row; } // if total, build row if ($total) { $row = array(); foreach ($fields2 as $f) { if ($f == 'campaign') { $row[] = 'Total'; } else { $row[] = $f == 'created' ? '' : $total[$f]; } } $csv[] = $row; } $fName = 'Prospects'; if (isset($this->params['aff_id'])) { $aff = new Affiliate(); if ($aff->fillFromDbPk($this->params['aff_id'])) { $fName .= 'For' . $aff->aff_ref; } } self::csvReport($csv, $fName); die; } Assets::css('jquery-ui'); Assets::js('jquery-ui'); //Assets::js('//code.jquery.com/ui/1.10.3/jquery-ui.js'); Assets::js('dateRange/jquery.daterange'); Assets::js('jquery.form'); // for ajax submission used to build csv Assets::js('ajax_table'); Assets::js('af_input_field'); $this->render('prospects', array('dataProvider' => $dataProvider, 'pagination' => $pagination, 'models' => $models, 'campaigns' => $campaignsFilter, 'afids' => $affFilter, 'filterFields' => $filterFields, 'currencies' => $currency, 'from' => $from, 'breadLink' => $breadLink, 'fields' => $fields, 'total' => $total)); }
function run_prospect() { $prospect = new Prospect(); $prospect->run(); }
$rModule = $_SESSION['MAILMERGE_MODULE']; } } if ($rModule == 'CampaignProspects') { $rModule = 'Campaigns'; } $_SESSION['MAILMERGE_MODULE'] = $rModule; if (!empty($rModule) && $rModule != "MailMerge") { $class_name = $beanList[$rModule]; $includedir = $beanFiles[$class_name]; require_once $includedir; $seed = new $class_name(); $selected_objects = ''; foreach ($_SESSION['MAILMERGE_RECORD'] as $record_id) { if ($rModule == 'Campaigns') { $prospect = new Prospect(); $prospect_module_list = array('leads', 'contacts', 'prospects', 'users'); foreach ($prospect_module_list as $mname) { $pList = $prospect->retrieveTargetList("campaigns.id = '{$record_id}' AND related_type = #{$mname}#", array('id', 'first_name', 'last_name')); foreach ($pList['list'] as $bean) { $selected_objects .= $bean->id . '=' . str_replace("&", "##", $bean->name) . '&'; } } } else { $seed->retrieve($record_id); $selected_objects .= $record_id . '=' . str_replace("&", "##", $seed->name) . '&'; } } if ($rModule != 'Contacts' && $rModule != 'Leads' && $rModule != 'Products' && $rModule != 'Campaigns' && $rModule != 'Projects') { $_SESSION['MAILMERGE_SKIP_REL'] = false; $xtpl->assign("STEP", "2");
function handleSave($prefix, $redirect = true, $useRequired = false, $do_save = true, $exist_lead = null) { require_once 'modules/Campaigns/utils.php'; require_once 'include/formbase.php'; if (empty($exist_lead)) { $focus = new Lead(); } else { $focus = $exist_lead; } if ($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))) { return null; } $focus = populateFromPost($prefix, $focus); if (!$focus->ACLAccess('Save')) { ACLController::displayNoAccess(true); sugar_cleanup(true); } if (!isset($_POST[$prefix . 'email_opt_out'])) { $focus->email_opt_out = 0; } if (!isset($_POST[$prefix . 'do_not_call'])) { $focus->do_not_call = 0; } if ($do_save) { if (!empty($GLOBALS['check_notify'])) { $focus->save($GLOBALS['check_notify']); } else { $focus->save(FALSE); } } $return_id = $focus->id; if (isset($_POST[$prefix . 'prospect_id']) && !empty($_POST[$prefix . 'prospect_id'])) { $prospect = new Prospect(); $prospect->retrieve($_POST[$prefix . 'prospect_id']); $prospect->lead_id = $focus->id; $prospect->save(); //if prospect id exists, make sure we are coming from prospect detail if (strtolower($_POST['return_module']) == 'prospects' && strtolower($_POST['return_action']) == 'detailview') { //create campaing_log entry if (isset($focus->campaign_id) && $focus->campaign_id != null) { campaign_log_lead_entry($focus->campaign_id, $prospect, $focus, 'lead'); } } } /////////////////////////////////////////////////////////////////////////////// //// INBOUND EMAIL HANDLING /////////////////////////////////////////////////////////////////////////////// if (isset($_REQUEST['inbound_email_id']) && !empty($_REQUEST['inbound_email_id'])) { if (!isset($current_user)) { global $current_user; } // fake this case like it's already saved. $email = new Email(); $email->retrieve($_REQUEST['inbound_email_id']); $email->parent_type = 'Leads'; $email->parent_id = $focus->id; $email->assigned_user_id = $current_user->id; $email->status = 'read'; $email->save(); $email->load_relationship('leads'); $email->leads->add($focus->id); header("Location: index.php?&module=Emails&action=EditView&type=out&inbound_email_id=" . $_REQUEST['inbound_email_id'] . "&parent_id=" . $email->parent_id . "&parent_type=" . $email->parent_type . '&start=' . $_REQUEST['start']); exit; } //// END INBOUND EMAIL HANDLING /////////////////////////////////////////////////////////////////////////////// $GLOBALS['log']->debug("Saved record with id of " . $return_id); if ($redirect) { handleRedirect($return_id, 'Leads'); } else { return $focus; } }
function handleSave($prefix, $redirect = true, $useRequired = false) { require_once 'modules/Leads/Lead.php'; require_once 'include/formbase.php'; $focus = new Lead(); if ($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))) { return null; } $focus = populateFromPost($prefix, $focus); if (!$focus->ACLAccess('Save')) { ACLController::displayNoAccess(true); sugar_cleanup(true); } if (!isset($_POST[$prefix . 'email_opt_out'])) { $focus->email_opt_out = 'off'; } if (!isset($_POST[$prefix . 'do_not_call'])) { $focus->do_not_call = 'off'; } if (!empty($GLOBALS['check_notify'])) { $focus->save($GLOBALS['check_notify']); } else { $focus->save(FALSE); } $return_id = $focus->id; if (isset($_POST[$prefix . 'prospect_id']) && !empty($_POST[$prefix . 'prospect_id'])) { if (!class_exists('Prospect')) { require_once 'modules/Prospects/Prospect.php'; } $prospect = new Prospect(); $prospect->retrieve($_POST[$prefix . 'prospect_id']); $prospect->lead_id = $focus->id; $prospect->save(); $linked_beans = $prospect->get_linked_beans('campaigns', 'CampaignLog'); if (empty($linked_beans)) { $linked_beans = array(); } foreach ($linked_beans as $thebean) { $thebean->id = null; $thebean->target_id = $focus->id; $thebean->target_type = 'Leads'; $thebean->archived = 1; $thebean->save(); } } /////////////////////////////////////////////////////////////////////////////// //// INBOUND EMAIL HANDLING /////////////////////////////////////////////////////////////////////////////// if (isset($_REQUEST['inbound_email_id']) && !empty($_REQUEST['inbound_email_id'])) { if (!isset($current_user)) { global $current_user; } // fake this case like it's already saved. require_once 'modules/Emails/Email.php'; $email = new Email(); $email->retrieve($_REQUEST['inbound_email_id']); $email->parent_type = 'Leads'; $email->parent_id = $focus->id; $email->assigned_user_id = $current_user->id; $email->status = 'read'; $email->save(); $email->load_relationship('leads'); $email->leads->add($focus->id); header("Location: index.php?&module=Emails&action=EditView&type=out&inbound_email_id=" . $_REQUEST['inbound_email_id'] . "&parent_id=" . $email->parent_id . "&parent_type=" . $email->parent_type . '&start=' . $_REQUEST['start']); exit; } //// END INBOUND EMAIL HANDLING /////////////////////////////////////////////////////////////////////////////// $GLOBALS['log']->debug("Saved record with id of " . $return_id); if ($redirect) { handleRedirect($return_id, 'Leads'); } else { return $focus; } }
} if ($conf->lead->enabled) { dol_include_once("/lead/lib/lead.lib.php"); } $langs->load('companies'); $langs->load('lead@lead'); $langs->load('projects'); $langs->load('propal'); $langs->load('commercial'); // Security check $socid = GETPOST('socid', 'int'); if ($user->societe_id) { $socid = $user->societe_id; } $result = restrictedArea($user, 'societe', $socid, '&societe'); $object = new Prospect($db); /* * Actions */ if ($_GET["action"] == 'cstc') { $sql = "UPDATE " . MAIN_DB_PREFIX . "societe SET fk_stcomm = " . $_GET["stcomm"]; $sql .= " WHERE rowid = " . $_GET["socid"]; $db->query($sql); $actioncomm = new ActionComm($db); $actioncomm->addAutoTask('AC_PROSPECT', $_GET["stcomm"] . " Statut de prospection : " . $obj->libelle, $_GET["socid"], '', ''); if ($objp->fk_stcomm == 0 && $_GET["stcomm"] > 0) { $actioncomm = new ActionComm($db); $actioncomm->addAutoTask('AC_SUSP', "Statut de prospection : " . $obj->libelle, $_GET["socid"], '', ''); } if (!empty($_GET["backtopage"])) { header("Location: " . $_GET["backtopage"]);
********************************************************************************/ require_once 'XTemplate/xtpl.php'; require_once 'data/Tracker.php'; require_once 'modules/Prospects/Prospect.php'; require_once 'modules/Prospects/Forms.php'; global $timedate; global $mod_strings; global $app_list_strings; global $app_strings; global $current_user; global $sugar_version, $sugar_config; // Unimplemented until jscalendar language files are fixed // global $current_language; // global $default_language; // global $cal_codes; $focus = new Prospect(); if (isset($_REQUEST['record'])) { $GLOBALS['log']->debug("In prospect edit view, about to retrieve record: " . $_REQUEST['record']); $result = $focus->retrieve($_REQUEST['record']); if ($result == null) { sugar_die($app_strings['ERROR_NO_RECORD']); } } if (isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') { $focus->id = ""; } global $theme; $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; require_once $theme_path . 'layout_utils.php'; $GLOBALS['log']->info("Prospect detail view");
function handleSave($prefix, $redirect = true, $useRequired = false, $do_save = true, $exist_lead = null) { require_once 'modules/Campaigns/utils.php'; require_once 'include/formbase.php'; if (empty($exist_lead)) { $focus = new Lead(); } else { $focus = $exist_lead; } if ($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))) { return null; } $focus = populateFromPost($prefix, $focus); if (!$focus->ACLAccess('Save')) { ACLController::displayNoAccess(true); sugar_cleanup(true); } //Check for duplicate Leads if (empty($_POST['record']) && empty($_POST['dup_checked'])) { $duplicateLeads = $this->checkForDuplicates($prefix); if (isset($duplicateLeads)) { //Set the redirect location to call the ShowDuplicates action. This will map to view.showduplicates.php $location = 'module=Leads&action=ShowDuplicates'; $get = ''; if (isset($_POST['inbound_email_id']) && !empty($_POST['inbound_email_id'])) { $get .= '&inbound_email_id=' . $_POST['inbound_email_id']; } if (isset($_POST['relate_to']) && !empty($_POST['relate_to'])) { $get .= '&Leadsrelate_to=' . $_POST['relate_to']; } if (isset($_POST['relate_id']) && !empty($_POST['relate_id'])) { $get .= '&Leadsrelate_id=' . $_POST['relate_id']; } //add all of the post fields to redirect get string foreach ($focus->column_fields as $field) { if (!empty($focus->{$field}) && !is_object($focus->{$field})) { $get .= "&Leads{$field}=" . urlencode($focus->{$field}); } } foreach ($focus->additional_column_fields as $field) { if (!empty($focus->{$field})) { $get .= "&Leads{$field}=" . urlencode($focus->{$field}); } } if ($focus->hasCustomFields()) { foreach ($focus->field_defs as $name => $field) { if (!empty($field['source']) && $field['source'] == 'custom_fields') { $get .= "&Leads{$name}=" . urlencode($focus->{$name}); } } } $emailAddress = new SugarEmailAddress(); $get .= $emailAddress->getFormBaseURL($focus); //create list of suspected duplicate lead ids in redirect get string $i = 0; foreach ($duplicateLeads as $lead) { $get .= "&duplicate[{$i}]=" . $lead['id']; $i++; } //add return_module, return_action, and return_id to redirect get string $get .= "&return_module="; if (!empty($_POST['return_module'])) { $get .= $_POST['return_module']; } else { $get .= "Leads"; } $get .= "&return_action="; if (!empty($_POST['return_action'])) { $get .= $_POST['return_action']; } if (!empty($_POST['return_id'])) { $get .= "&return_id=" . $_POST['return_id']; } if (!empty($_POST['popup'])) { $get .= '&popup=' . $_POST['popup']; } if (!empty($_POST['create'])) { $get .= '&create=' . $_POST['create']; } // for InboundEmail flow if (!empty($_POST['start'])) { $get .= '&start=' . $_POST['start']; } $_SESSION['SHOW_DUPLICATES'] = $get; if (!empty($_POST['is_ajax_call']) && $_POST['is_ajax_call'] == '1') { ob_clean(); $json = getJSONobj(); echo $json->encode(array('status' => 'dupe', 'get' => $location)); } else { if (!empty($_REQUEST['ajax_load'])) { echo "<script>SUGAR.ajaxUI.loadContent('index.php?{$location}');</script>"; } else { if (!empty($_POST['to_pdf'])) { $location .= '&to_pdf=' . $_POST['to_pdf']; } header("Location: index.php?{$location}"); } } return null; } } if (!isset($_POST[$prefix . 'email_opt_out'])) { $focus->email_opt_out = 0; } if (!isset($_POST[$prefix . 'do_not_call'])) { $focus->do_not_call = 0; } if ($do_save) { if (!empty($GLOBALS['check_notify'])) { $focus->save($GLOBALS['check_notify']); } else { $focus->save(FALSE); } } $return_id = $focus->id; if (isset($_POST[$prefix . 'prospect_id']) && !empty($_POST[$prefix . 'prospect_id'])) { $prospect = new Prospect(); $prospect->retrieve($_POST[$prefix . 'prospect_id']); $prospect->lead_id = $focus->id; // Set to keep email in target $prospect->in_workflow = true; $prospect->save(); //if prospect id exists, make sure we are coming from prospect detail if (strtolower($_POST['return_module']) == 'prospects' && strtolower($_POST['return_action']) == 'detailview') { //create campaing_log entry if (isset($focus->campaign_id) && $focus->campaign_id != null) { campaign_log_lead_entry($focus->campaign_id, $prospect, $focus, 'lead'); } } } /////////////////////////////////////////////////////////////////////////////// //// INBOUND EMAIL HANDLING /////////////////////////////////////////////////////////////////////////////// if (isset($_REQUEST['inbound_email_id']) && !empty($_REQUEST['inbound_email_id'])) { if (!isset($current_user)) { global $current_user; } // fake this case like it's already saved. $email = new Email(); $email->retrieve($_REQUEST['inbound_email_id']); $email->parent_type = 'Leads'; $email->parent_id = $focus->id; $email->assigned_user_id = $current_user->id; $email->status = 'read'; $email->save(); $email->load_relationship('leads'); $email->leads->add($focus->id); header("Location: index.php?&module=Emails&action=EditView&type=out&inbound_email_id=" . $_REQUEST['inbound_email_id'] . "&parent_id=" . $email->parent_id . "&parent_type=" . $email->parent_type . '&start=' . $_REQUEST['start']); exit; } //// END INBOUND EMAIL HANDLING /////////////////////////////////////////////////////////////////////////////// $GLOBALS['log']->debug("Saved record with id of " . $return_id); if ($redirect) { handleRedirect($return_id, 'Leads'); } else { return $focus; } }
public function testget_unlinked_email_query() { $prospect = new Prospect(); $expected = "SELECT emails.id FROM emails JOIN (select DISTINCT email_id from emails_email_addr_rel eear\n\n\tjoin email_addr_bean_rel eabr on eabr.bean_id ='' and eabr.bean_module = 'Prospects' and\n\teabr.email_address_id = eear.email_address_id and eabr.deleted=0\n\twhere eear.deleted=0 and eear.email_id not in\n\t(select eb.email_id from emails_beans eb where eb.bean_module ='Prospects' and eb.bean_id = '')\n\t) derivedemails on derivedemails.email_id = emails.id"; $actual = $prospect->get_unlinked_email_query(); $this->assertSame($expected, $actual); }
* All Rights Reserved. * Contributor(s): ______________________________________.. ********************************************************************************/ require_once 'modules/Campaigns/utils.php'; global $mod_strings, $app_list_strings, $app_strings, $current_user, $import_bean_map; global $import_file_name, $theme; $focus = 0; if (isset($_REQUEST['return_module'])) { if ($_REQUEST['return_module'] == 'Contacts') { $focus = new Contact(); } if ($_REQUEST['return_module'] == 'Leads') { $focus = new Lead(); } if ($_REQUEST['return_module'] == 'Prospects') { $focus = new Prospect(); } } if (isset($_REQUEST['record'])) { Log::debug("In Subscriptions, about to retrieve record: " . $_REQUEST['record']); $result = $focus->retrieve($_REQUEST['record']); if ($result == null) { sugar_die($app_strings['ERROR_NO_RECORD']); } } $this->ss->assign("MOD", $mod_strings); $this->ss->assign("APP", $app_strings); if (isset($_REQUEST['return_module'])) { $this->ss->assign("RETURN_MODULE", $_REQUEST['return_module']); } else { $this->ss->assign("RETURN_MODULE", '');
*/ if ($conf->highcharts->enabled && $user->rights->highcharts->read) { dol_include_once("/highCharts/class/highCharts.class.php"); $langs->load("highcharts@highCharts"); $graph = new HighCharts($db); $graph->width = "100%"; $graph->height = "300px"; $graph->name = "ProspectionStatus"; $graph->label = $langs->trans("ProspectionStatus"); if ($user->rights->highcharts->all) { $graph->mine = 0; } $graph->ProspectStatus(); } //print '<br>'; $prospect = new Prospect($db); $prospect->ProspectStatus(); /* * Last modified customers or prospects */ if ($conf->societe->enabled && $user->rights->societe->lire) { $langs->load("boxes"); $sql = "SELECT s.rowid,s.nom,s.client,s.datec,s.tms"; $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s"; if (!$user->rights->societe->client->voir && !$socid) { $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; } $sql .= " WHERE s.client IN (1, 2, 3)"; $sql .= " AND s.entity = " . $conf->entity; if (!$user->rights->societe->client->voir && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id;