Example #1
0
 /**
  * function to edit the combo values
  * @param object $evctl
  */
 public function eventEditComboValues(EventControler $evctl)
 {
     $idfields = (int) $evctl->idfields;
     if ($idfields > 0) {
         $referrar_module_id = (int) $evctl->referrar_module_id;
         $pick_values_seperated = preg_split('/[\\r\\n]+/', $evctl->pick_values, -1, PREG_SPLIT_NO_EMPTY);
         $this->update_combo_values($idfields, $pick_values_seperated);
         //check if the field is mapped with some other fields and if yes then update the mapped fields also
         $do_crm_fields_mapping = new CRMFieldsMapping();
         $mapped_fields = $do_crm_fields_mapping->is_mapped($idfields);
         if (is_array($mapped_fields) && count($mapped_fields) > 0) {
             foreach ($mapped_fields as $mapped_fieldid) {
                 $this->update_combo_values($mapped_fieldid, $pick_values_seperated);
             }
         }
         $_SESSION["do_crm_messages"]->set_message('success', _('Data has been updated successfully.'));
         $next_page = NavigationControl::getNavigationLink("Settings", "picklist");
         $dis = new Display($next_page);
         $dis->addParam("cmid", $referrar_module_id);
         $evctl->setDisplayNext($dis);
     }
 }
Example #2
0
								<th width="15%"><?php echo $modules_info[4]["label"];?></th>
								<th width="15%"><?php echo $modules_info[5]["label"];?></th>
							</tr>
						</thead>
					</table>
				</th>
				<th width="10%"><?php echo _('Action'); ?></th>
			</tr>
		</thead>
	</table>
	<table class="datadisplay_collapse_center">  
		<tbody>
			<?php
			if ($do_custom_field->getNumRows() > 0) {
				$count = 0 ;
				$do_fields_mapping = new CRMFieldsMapping();
				while ($do_custom_field->next()) {
					$fieldobject = 'FieldType'.$do_custom_field->field_type;
					$field_type_name = $fieldobject::get_field_type();
					$mapped_fields_info = $do_fields_mapping->get_custom_field_mapped_detail($do_custom_field->idfields);
			?>
			<tr>
				<td width="5%"><?php echo ++$count; ?></td>
				<td width="25%"><?php echo $do_custom_field->field_label;?></td>
				<td width="15%"><?php echo $field_type_name ; ?></td>
				<?php 
				if (count($mapped_fields_info) > 0) {
				?>
				<td colspan=1 width="15%"><?php echo $mapped_fields_info["organization"]["mapped_fieldlabel"]; ?></td>
				<td colspan=1 width="15%"><?php echo $mapped_fields_info["contacts"]["mapped_fieldlabel"]; ?></td>
				<td colspan=1 width="15%"><?php echo $mapped_fields_info["potentials"]["mapped_fieldlabel"]; ?></td>
Example #3
0
 /**
  * Event function to convert lead
  * The conversion process goes as -
  * if a new organization is set to be created then create it and transfer other information and mapped custom fields.
  * if a new contact is set to be created then create it and transfer other information and mapped custom fields.
  * if a new potential is set to be created then create it and transfer other information and mapped custom fields,also
  * see the related to and if organization is created or selected then the related to is set to idorganization, else related
  * to should be idcontacts depending on if its created or selected from the conversion form.
  * if no potential is set to be created then check what is set to be created, and if just organization or contact is set to 
  * be created then create and transfer the data and custom fields mapped information.
  * if both organization and contact is set to be created then the created contact is mapped to the organization which is created
  * or selected.
  * if both organization and contact or one of them is set to be conveted and instead of creating if the values are selected
  * then nothing to be done.
  * @param object $evctl
  * @see popups/convert_lead_modal.php
  */
 public function eventConvertLeads(EventControler $evctl)
 {
     $idleads = (int) $evctl->idleads;
     $idcontacts = 0;
     $idorganization = 0;
     $idpotentials = 0;
     $create_potential = false;
     $create_organization = false;
     $create_contact = false;
     $assigned_to_as_group = false;
     $group_id = 0;
     $assigned_to = $evctl->assigned_to_selector;
     if ($assigned_to == 'user') {
         $fld_value = $evctl->user_selector;
     } else {
         $fld_value = 0;
         $group_id = $evctl->group_selector;
         $assigned_to_as_group = true;
     }
     $assigned_to_data = array("value" => $fld_value, "assigned_to_as_group" => $assigned_to_as_group, "group_id" => $group_id);
     if ($evctl->pot_convertion == 'on' && true === $_SESSION["do_crm_action_permission"]->action_permitted('add', 5)) {
         $create_potential = true;
     }
     if ($evctl->org_convertion == 'on' && true === $_SESSION["do_crm_action_permission"]->action_permitted('add', 6)) {
         $create_organization = true;
     }
     if ($evctl->cnt_convertion == 'on' && true === $_SESSION["do_crm_action_permission"]->action_permitted('add', 4)) {
         $create_contact = true;
     }
     $do_convert = true;
     if ($create_organization === true && $evctl->select_org == 'on' && $create_potential === false && $create_contact === false) {
         $do_convert = false;
     }
     if ($create_contact === true && $evctl->select_cnt == 'on' && $create_potential === false && $create_organization === false) {
         $do_convert = false;
     }
     if ($do_convert === true) {
         $this->getId($idleads);
         $do_feed_queue = new LiveFeedQueue();
         $do_data_history = new DataHistory();
         $related_identifier_data = array("related_identifier" => $this->firstname . ' ' . $this->lastname, "related_identifier_idrecord" => $idleads, "related_identifier_idmodule" => 3);
         //add to feed queue
         $feed_other_assigne = array();
         if ($this->idgroup > 0) {
             $feed_other_assigne = array("related" => "group", "data" => array("key" => "oldgroup", "val" => $this->idgroup));
         }
         $do_feed_queue->add_feed_queue($idleads, 3, $this->firstname . ' ' . $this->lastname, 'lead_covert', $feed_other_assigne);
         // add to data history
         $do_data_history->add_history($idleads, 3, 'add');
         $do_fields_mapping = new CRMFieldsMapping();
         $qry_mapped_fields = "\n\t\t\tselect custom_field_mapping.*,\n\t\t\tfields.field_name as lead_field_name\n\t\t\tfrom custom_field_mapping\n\t\t\tinner join fields on fields.idfields = custom_field_mapping.mapping_field_id";
         $stmt = $do_fields_mapping->getDbConnection()->executeQuery($qry_mapped_fields);
         $mapped_fields = $stmt->fetchAll();
         $do_custom_field_map = false;
         if (count($mapped_fields) > 0) {
             $do_custom_field_map = true;
         }
         if ($create_organization === true) {
             if ($evctl->create_org == 'on') {
                 $idorganization = $this->create_new_organization_converted($evctl, $assigned_to_data);
                 // add to feed queue
                 $feed_other_assigne = array();
                 if ($assigned_to_as_group === true) {
                     $feed_other_assigne = array("related" => "group", "data" => array("key" => "newgroup", "val" => $group_id));
                 }
                 $do_feed_queue->add_feed_queue($idorganization, 6, $evctl->organization_name, 'add_organization_lead_convert', $feed_other_assigne, $related_identifier_data);
                 // add to data history
                 $do_data_history->add_history($idorganization, 6, 'add');
                 $map_entity = "\n\t\t\t\t\tUPDATE \n\t\t\t\t\t`organization`\n\t\t\t\t\tset \n\t\t\t\t\t`rating` = ?,\n\t\t\t\t\t`phone` = ?,\n\t\t\t\t\t`fax` = ? \n\t\t\t\t\twhere `idorganization` = ? limit 1 ";
                 $this->getDbConnection()->executeQuery($map_entity, array($this->rating, $this->phone, $this->fax, $idorganization));
                 $map_addr = "\n\t\t\t\t\tUPDATE \n\t\t\t\t\t`organization_address` \n\t\t\t\t\tset\n\t\t\t\t\t`org_bill_address` = ?,\n\t\t\t\t\t`org_bill_pobox` = ?,\n\t\t\t\t\t`org_bill_city` = ?,\n\t\t\t\t\t`org_bill_state` = ?,\n\t\t\t\t\t`org_bill_postalcode` = ?,\n\t\t\t\t\t`org_bill_country` = ?\n\t\t\t\t\twhere `idorganization` = ? limit 1 ";
                 $this->getDbConnection()->executeQuery($map_addr, array($this->street, $this->po_box, $this->city, $this->state, $this->postal_code, $this->country, $idorganization));
                 if ($do_custom_field_map === true) {
                     $this->update_mapped_fields_data(6, $idorganization, $mapped_fields);
                 }
             } elseif ($evctl->select_org == 'on') {
                 $idorganization = $evctl->idorganization;
             }
         }
         if ($create_contact === true) {
             if ($evctl->create_cnt == 'on') {
                 $idcontacts = $this->create_new_contact_converted($evctl, $assigned_to_data, $idorganization);
                 // add to feed queue
                 $feed_other_assigne = array();
                 if ($assigned_to_as_group === true) {
                     $feed_other_assigne = array("related" => "group", "data" => array("key" => "newgroup", "val" => $group_id));
                 }
                 $do_feed_queue->add_feed_queue($idcontacts, 4, $evctl->firstname . ' ' . $evctl->lastname, 'add_contact_lead_convert', $feed_other_assigne, $related_identifier_data);
                 // add to data history
                 $do_data_history->add_history($idcontacts, 4, 'add');
                 $map_entity = "\n\t\t\t\t\tUPDATE\n\t\t\t\t\t`contacts`\n\t\t\t\t\tset \n\t\t\t\t\t`office_phone` = ?,\n\t\t\t\t\t`mobile_num` = ?,\n\t\t\t\t\t`leadsource` = ?,\n\t\t\t\t\t`title` = ?,\n\t\t\t\t\t`fax` = ?\n\t\t\t\t\twhere `idcontacts` = ? limit 1 ";
                 $this->getDbConnection()->executeQuery($map_entity, array($this->phone, $this->mobile, $this->leadsource, $this->title, $this->fax, $idcontacts));
                 $map_addr = "\n\t\t\t\t\tUPDATE\n\t\t\t\t\t`contacts_address`\n\t\t\t\t\tset\n\t\t\t\t\t`cnt_mail_street` = ?,\n\t\t\t\t\t`cnt_mail_pobox` = ?,\n\t\t\t\t\t`cnt_mailing_city` = ?,\n\t\t\t\t\t`cnt_mailing_state` = ?,\n\t\t\t\t\t`cnt_mailing_postalcode` = ?,\n\t\t\t\t\t`cnt_mailing_country` = ?\n\t\t\t\t\twhere `idcontacts` = ? limit 1 ";
                 $this->getDbConnection()->executeQuery($map_addr, array($this->street, $this->po_box, $this->city, $this->state, $this->postal_code, $this->country, $idcontacts));
                 if ($do_custom_field_map === true) {
                     $this->update_mapped_fields_data(4, $idcontacts, $mapped_fields);
                 }
             } elseif ($evctl->select_cnt == 'on') {
                 $idcontacts = $evctl->idcontacts;
             }
         }
         if ($create_potential === true) {
             if ($idorganization > 0 && $create_organization === true) {
                 $related_to = $idorganization;
                 $related_to_module = 6;
             } elseif ($idcontacts > 0 && $create_contact === true) {
                 $related_to = $idcontacts;
                 $related_to_module = 4;
             } else {
                 $related_to = $idorganization;
                 $related_to_module = 6;
             }
             $idpotentials = $this->create_new_potential_converted($evctl, $assigned_to_data, $related_to, $related_to_module);
             if ($do_custom_field_map === true) {
                 $this->update_mapped_fields_data(5, $idpotentials, $mapped_fields);
             }
             // add to feed queue
             $feed_other_assigne = array();
             if ($assigned_to_as_group === true) {
                 $feed_other_assigne = array("related" => "group", "data" => array("key" => "newgroup", "val" => $group_id));
             }
             $do_feed_queue->add_feed_queue($idpotentials, 5, $evctl->potential_name, 'add_potential_lead_convert', $feed_other_assigne, $related_identifier_data);
             // add to data history
             $do_data_history->add_history($idpotentials, 5, 'add');
         }
         if ($idpotentials > 0) {
             $next_page = NavigationControl::getNavigationLink("Potentials", "detail");
             $sqrecord = $idpotentials;
         } elseif ($idorganization > 0 && $evctl->create_org == 'on') {
             $next_page = NavigationControl::getNavigationLink("Organization", "detail");
             $sqrecord = $idorganization;
         } else {
             $next_page = NavigationControl::getNavigationLink("Contacts", "detail");
             $sqrecord = $idcontacts;
         }
         $this->query("update " . $this->getTable() . " set `converted` = 1 where idleads = ? limit 1", array($idleads));
         if ($evctl->create_org == 'on') {
             $idorganization_converted = $idorganization;
         } else {
             $idorganization_converted = 0;
         }
         if ($evctl->create_cnt == 'on') {
             $idcontacts_converted = $idcontacts;
         } else {
             $idcontacts_converted = 0;
         }
         $this->record_lead_conversion_matrix($idleads, $idpotentials, $idorganization_converted, $idcontacts_converted);
         // transfer the related data to the selected one
         if ((int) $evctl->transfer_related_data == 1) {
             $transfer_module_id = 6;
             $idtransfer_to = $idorganization;
         } elseif ((int) $evctl->transfer_related_data == 2) {
             $transfer_module_id = 4;
             $idtransfer_to = $idcontacts;
         } elseif ((int) $evctl->transfer_related_data == 3) {
             $transfer_module_id = 5;
             $idtransfer_to = $idpotentials;
         }
         $this->transfer_relateddata_on_conversion($idleads, $idtransfer_to, $transfer_module_id);
         $dis = new Display($next_page);
         $dis->addParam("sqrecord", $sqrecord);
         $evctl->setDisplayNext($dis);
     } else {
         $_SESSION["do_crm_messages"]->set_message('error', _('No conversion has been done, please try again !'));
     }
 }
Example #4
0
<?php

// Copyright SQCRM. For licensing, reuse, modification and distribution see license.txt
/**
* Custom field mapping
* @author Abhik Chakraborty
*/
$modules_info = $_SESSION["do_module"]->get_modules_with_full_info();
$do_fields_mapping = new CRMFieldsMapping();
$custom_fields_mapping_info = $do_fields_mapping->get_custom_field_mappings();
$custom_fields = new CustomFields();
$contacts_custom_fields = $custom_fields->get_custom_fields_as_array(4);
$potentials_custom_fields = $custom_fields->get_custom_fields_as_array(5);
$organization_custom_fields = $custom_fields->get_custom_fields_as_array(6);
require_once 'view/customfield_mapping_view.php';